// SPDX-License-Identifier: GPL-2.0
/*
 * Kunit tests for ChromeOS Embedded Controller protocol.
 */

#include <kunit/test.h>

#include <asm/unaligned.h>

#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_data/cros_ec_proto.h>

#include "cros_ec.h"
#include "cros_ec_proto_test_util.h"

#define BUFSIZE 512

struct cros_ec_proto_test_priv {
	struct cros_ec_device ec_dev;
	u8 dout[BUFSIZE];
	u8 din[BUFSIZE];
	struct cros_ec_command *msg;
	u8 _msg[BUFSIZE];
};

static void cros_ec_proto_test_prepare_tx_legacy_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct cros_ec_command *msg = priv->msg;
	int ret, i;
	u8 csum;

	ec_dev->proto_version = 2;

	msg->command = EC_CMD_HELLO;
	msg->outsize = EC_PROTO2_MAX_PARAM_SIZE;
	msg->data[0] = 0xde;
	msg->data[1] = 0xad;
	msg->data[2] = 0xbe;
	msg->data[3] = 0xef;

	ret = cros_ec_prepare_tx(ec_dev, msg);

	KUNIT_EXPECT_EQ(test, ret, EC_MSG_TX_PROTO_BYTES + EC_PROTO2_MAX_PARAM_SIZE);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[0], EC_CMD_VERSION0);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[1], EC_CMD_HELLO);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[2], EC_PROTO2_MAX_PARAM_SIZE);
	KUNIT_EXPECT_EQ(test, EC_MSG_TX_HEADER_BYTES, 3);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 0], 0xde);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 1], 0xad);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 2], 0xbe);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 3], 0xef);
	for (i = 4; i < EC_PROTO2_MAX_PARAM_SIZE; ++i)
		KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + i], 0);

	csum = EC_CMD_VERSION0;
	csum += EC_CMD_HELLO;
	csum += EC_PROTO2_MAX_PARAM_SIZE;
	csum += 0xde;
	csum += 0xad;
	csum += 0xbe;
	csum += 0xef;
	KUNIT_EXPECT_EQ(test,
			ec_dev->dout[EC_MSG_TX_HEADER_BYTES + EC_PROTO2_MAX_PARAM_SIZE],
			csum);
}

static void cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct cros_ec_command *msg = priv->msg;
	int ret;

	ec_dev->proto_version = 2;

	msg->outsize = EC_PROTO2_MAX_PARAM_SIZE + 1;

	ret = cros_ec_prepare_tx(ec_dev, msg);
	KUNIT_EXPECT_EQ(test, ret, -EINVAL);
}

static void cros_ec_proto_test_prepare_tx_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct cros_ec_command *msg = priv->msg;
	struct ec_host_request *request = (struct ec_host_request *)ec_dev->dout;
	int ret, i;
	u8 csum;

	msg->command = EC_CMD_HELLO;
	msg->outsize = 0x88;
	msg->data[0] = 0xde;
	msg->data[1] = 0xad;
	msg->data[2] = 0xbe;
	msg->data[3] = 0xef;

	ret = cros_ec_prepare_tx(ec_dev, msg);

	KUNIT_EXPECT_EQ(test, ret, sizeof(*request) + 0x88);

	KUNIT_EXPECT_EQ(test, request->struct_version, EC_HOST_REQUEST_VERSION);
	KUNIT_EXPECT_EQ(test, request->command, EC_CMD_HELLO);
	KUNIT_EXPECT_EQ(test, request->command_version, 0);
	KUNIT_EXPECT_EQ(test, request->data_len, 0x88);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 0], 0xde);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 1], 0xad);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 2], 0xbe);
	KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 3], 0xef);
	for (i = 4; i < 0x88; ++i)
		KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + i], 0);

	csum = EC_HOST_REQUEST_VERSION;
	csum += EC_CMD_HELLO;
	csum += 0x88;
	csum += 0xde;
	csum += 0xad;
	csum += 0xbe;
	csum += 0xef;
	KUNIT_EXPECT_EQ(test, request->checksum, (u8)-csum);
}

static void cros_ec_proto_test_prepare_tx_bad_msg_outsize(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct cros_ec_command *msg = priv->msg;
	int ret;

	msg->outsize = ec_dev->dout_size - sizeof(struct ec_host_request) + 1;

	ret = cros_ec_prepare_tx(ec_dev, msg);
	KUNIT_EXPECT_EQ(test, ret, -EINVAL);
}

static void cros_ec_proto_test_check_result(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct cros_ec_command *msg = priv->msg;
	int ret, i;
	static enum ec_status status[] = {
		EC_RES_SUCCESS,
		EC_RES_INVALID_COMMAND,
		EC_RES_ERROR,
		EC_RES_INVALID_PARAM,
		EC_RES_ACCESS_DENIED,
		EC_RES_INVALID_RESPONSE,
		EC_RES_INVALID_VERSION,
		EC_RES_INVALID_CHECKSUM,
		EC_RES_UNAVAILABLE,
		EC_RES_TIMEOUT,
		EC_RES_OVERFLOW,
		EC_RES_INVALID_HEADER,
		EC_RES_REQUEST_TRUNCATED,
		EC_RES_RESPONSE_TOO_BIG,
		EC_RES_BUS_ERROR,
		EC_RES_BUSY,
		EC_RES_INVALID_HEADER_VERSION,
		EC_RES_INVALID_HEADER_CRC,
		EC_RES_INVALID_DATA_CRC,
		EC_RES_DUP_UNAVAILABLE,
	};

	for (i = 0; i < ARRAY_SIZE(status); ++i) {
		msg->result = status[i];
		ret = cros_ec_check_result(ec_dev, msg);
		KUNIT_EXPECT_EQ(test, ret, 0);
	}

	msg->result = EC_RES_IN_PROGRESS;
	ret = cros_ec_check_result(ec_dev, msg);
	KUNIT_EXPECT_EQ(test, ret, -EAGAIN);
}

static void cros_ec_proto_test_query_all_pretest(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;

	/*
	 * cros_ec_query_all() will free din and dout and allocate them again to fit the usage by
	 * calling devm_kfree() and devm_kzalloc().  Set them to NULL as they aren't managed by
	 * ec_dev->dev but allocated statically in struct cros_ec_proto_test_priv
	 * (see cros_ec_proto_test_init()).
	 */
	ec_dev->din = NULL;
	ec_dev->dout = NULL;
}

static void cros_ec_proto_test_query_all_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->protocol_versions = BIT(3) | BIT(2);
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbf;
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_response_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_cmd_versions *)mock->o_data;
		data->version_mask = BIT(6) | BIT(5);
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		struct ec_response_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_cmd_versions *)mock->o_data;
		data->version_mask = BIT(1);
	}

	/* For cros_ec_get_host_event_wake_mask(). */
	{
		struct ec_response_host_event_mask *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_host_event_mask *)mock->o_data;
		data->mask = 0xbeef;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		KUNIT_EXPECT_EQ(test, ec_dev->max_request, 0xbe - sizeof(struct ec_host_request));
		KUNIT_EXPECT_EQ(test, ec_dev->max_response, 0xef - sizeof(struct ec_host_response));
		KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 3);
		KUNIT_EXPECT_EQ(test, ec_dev->din_size, 0xef + EC_MAX_RESPONSE_OVERHEAD);
		KUNIT_EXPECT_EQ(test, ec_dev->dout_size, 0xbe + EC_MAX_REQUEST_OVERHEAD);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0xbf - sizeof(struct ec_host_request));
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_params_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_get_cmd_versions *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT);

		KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 7);
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		struct ec_params_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_get_cmd_versions *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_HOST_SLEEP_EVENT);

		KUNIT_EXPECT_TRUE(test, ec_dev->host_sleep_v1);
	}

	/* For cros_ec_get_host_event_wake_mask(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		KUNIT_EXPECT_EQ(test, ec_dev->host_event_wake_mask, 0xbeef);
	}
}

static void cros_ec_proto_test_query_all_no_pd_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->max_passthru = 0xbf;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0);
	}
}

static void cros_ec_proto_test_query_all_no_pd_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->max_passthru = 0xbf;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0);
	}
}

static void cros_ec_proto_test_query_all_legacy_normal_v3_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		struct ec_response_hello *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_hello *)mock->o_data;
		data->out_data = 0xa1b2c3d4;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		struct ec_params_hello *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_hello *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0);

		KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2);
		KUNIT_EXPECT_EQ(test, ec_dev->max_request, EC_PROTO2_MAX_PARAM_SIZE);
		KUNIT_EXPECT_EQ(test, ec_dev->max_response, EC_PROTO2_MAX_PARAM_SIZE);
		KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0);
		KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL);
		KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES);
		KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES);
	}
}

static void cros_ec_proto_test_query_all_legacy_normal_v3_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		struct ec_response_hello *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_hello *)mock->o_data;
		data->out_data = 0xa1b2c3d4;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		struct ec_params_hello *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_hello *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0);

		KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2);
		KUNIT_EXPECT_EQ(test, ec_dev->max_request, EC_PROTO2_MAX_PARAM_SIZE);
		KUNIT_EXPECT_EQ(test, ec_dev->max_response, EC_PROTO2_MAX_PARAM_SIZE);
		KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0);
		KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL);
		KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES);
		KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES);
	}
}

static void cros_ec_proto_test_query_all_legacy_xfer_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, -EIO);
	KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello));
	}
}

static void cros_ec_proto_test_query_all_legacy_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, -EOPNOTSUPP);
	KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello));
	}
}

static void cros_ec_proto_test_query_all_legacy_data_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		struct ec_response_hello *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_hello *)mock->o_data;
		data->out_data = 0xbeefbfbf;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, -EBADMSG);
	KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello));
	}
}

static void cros_ec_proto_test_query_all_legacy_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, -EPROTO);
	KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info_legacy(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello));
	}
}

static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->mkbp_event_supported = 0xbf;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_response_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_cmd_versions *)mock->o_data;
		data->version_mask = 0;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_params_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_get_cmd_versions *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT);

		KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0);
	}
}

static void cros_ec_proto_test_query_all_no_mkbp_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->mkbp_event_supported = 0xbf;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_params_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_get_cmd_versions *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT);

		KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0);
	}
}

static void cros_ec_proto_test_query_all_no_mkbp_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->mkbp_event_supported = 0xbf;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_params_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_get_cmd_versions *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT);

		KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0);
	}
}

static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->host_sleep_v1 = true;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		struct ec_response_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_cmd_versions *)mock->o_data;
		data->version_mask = 0;
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));

		KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1);
	}
}

static void cros_ec_proto_test_query_all_no_host_sleep_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->host_sleep_v1 = true;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		struct ec_response_get_cmd_versions *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/* In order to pollute next cros_ec_get_host_command_version_mask(). */
		data = (struct ec_response_get_cmd_versions *)mock->o_data;
		data->version_mask = 0xbeef;
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));

		KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1);
	}
}

static void cros_ec_proto_test_query_all_default_wake_mask_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->host_event_wake_mask = U32_MAX;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_event_wake_mask(). */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For cros_ec_get_host_event_wake_mask(). */
	{
		u32 mask;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		mask = ec_dev->host_event_wake_mask;
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS), 0);
	}
}

static void cros_ec_proto_test_query_all_default_wake_mask_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;

	/* Set some garbage bytes. */
	ec_dev->host_event_wake_mask = U32_MAX;

	/* For cros_ec_get_proto_info() without passthru. */
	{
		struct ec_response_get_protocol_info *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		/*
		 * Although it doesn't check the value, provides valid sizes so that
		 * cros_ec_query_all() allocates din and dout correctly.
		 */
		data = (struct ec_response_get_protocol_info *)mock->o_data;
		data->max_request_packet_size = 0xbe;
		data->max_response_packet_size = 0xef;
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For get_host_event_wake_mask(). */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	cros_ec_proto_test_query_all_pretest(test);
	ret = cros_ec_query_all(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);

	/* For cros_ec_get_proto_info() without passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_proto_info() with passthru. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command,
				EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
				EC_CMD_GET_PROTOCOL_INFO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_protocol_info));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	/* For cros_ec_get_host_command_version_mask() for MKBP. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For cros_ec_get_host_command_version_mask() for host sleep v1. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_cmd_versions));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions));
	}

	/* For get_host_event_wake_mask(). */
	{
		u32 mask;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);

		mask = ec_dev->host_event_wake_mask;
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU), 0);
		KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS), 0);
	}
}

static void cros_ec_proto_test_cmd_xfer_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	DEFINE_RAW_FLEX(struct cros_ec_command, buf, data, 0x100);

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->max_passthru = 0xdd;

	buf->version = 0;
	buf->command = EC_CMD_HELLO;
	buf->insize = 4;
	buf->outsize = 2;
	buf->data[0] = 0x55;
	buf->data[1] = 0xaa;

	{
		u8 *data;

		mock = cros_kunit_ec_xfer_mock_add(test, 4);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (u8 *)mock->o_data;
		data[0] = 0xaa;
		data[1] = 0x55;
		data[2] = 0xcc;
		data[3] = 0x33;
	}

	ret = cros_ec_cmd_xfer(ec_dev, buf);
	KUNIT_EXPECT_EQ(test, ret, 4);

	{
		u8 *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, 4);
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2);

		data = (u8 *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data[0], 0x55);
		KUNIT_EXPECT_EQ(test, data[1], 0xaa);

		KUNIT_EXPECT_EQ(test, buf->data[0], 0xaa);
		KUNIT_EXPECT_EQ(test, buf->data[1], 0x55);
		KUNIT_EXPECT_EQ(test, buf->data[2], 0xcc);
		KUNIT_EXPECT_EQ(test, buf->data[3], 0x33);
	}
}

static void cros_ec_proto_test_cmd_xfer_excess_msg_insize(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	DEFINE_RAW_FLEX(struct cros_ec_command, buf, data, 0x100);

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->max_passthru = 0xdd;

	buf->version = 0;
	buf->command = EC_CMD_HELLO;
	buf->insize = 0xee + 1;
	buf->outsize = 2;

	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0xcc);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer(ec_dev, buf);
	KUNIT_EXPECT_EQ(test, ret, 0xcc);

	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, 0xee);
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2);
	}
}

static void cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	DEFINE_RAW_FLEX(struct cros_ec_command, buf, data, 0x100);

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->max_passthru = 0xdd;

	buf->version = 0;
	buf->command = EC_CMD_HELLO;
	buf->insize = 4;
	buf->outsize = 0xff + 1;

	ret = cros_ec_cmd_xfer(ec_dev, buf);
	KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE);
}

static void cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	DEFINE_RAW_FLEX(struct cros_ec_command, buf, data, 0x100);

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->max_passthru = 0xdd;

	buf->version = 0;
	buf->command = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) + EC_CMD_HELLO;
	buf->insize = 4;
	buf->outsize = 0xdd + 1;

	ret = cros_ec_cmd_xfer(ec_dev, buf);
	KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE);
}

static void cros_ec_proto_test_cmd_xfer_protocol_v3_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->proto_version = 3;
	ec_dev->cmd_xfer = cros_kunit_ec_cmd_xfer_mock;
	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, 0);

	KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 0);
	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 1);
}

static void cros_ec_proto_test_cmd_xfer_protocol_v3_no_op(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->proto_version = 3;
	ec_dev->cmd_xfer = cros_kunit_ec_cmd_xfer_mock;
	ec_dev->pkt_xfer = NULL;

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EIO);
}

static void cros_ec_proto_test_cmd_xfer_protocol_v2_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->proto_version = 2;
	ec_dev->cmd_xfer = cros_kunit_ec_cmd_xfer_mock;
	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, 0);

	KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 1);
	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 0);
}

static void cros_ec_proto_test_cmd_xfer_protocol_v2_no_op(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->proto_version = 2;
	ec_dev->cmd_xfer = NULL;
	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EIO);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS. */
	{
		struct ec_response_get_comms_status *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_comms_status *)mock->o_data;
		data->flags = 0;
	}

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_comms_status));

	KUNIT_EXPECT_EQ(test, msg.result, EC_RES_SUCCESS);

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_COMMS_STATUS);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_comms_status));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}

	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS EC_COMMAND_RETRIES times. */
	cros_kunit_ec_xfer_mock_default_ret = -EAGAIN;

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EAGAIN);

	/* For EC_CMD_GET_COMMS_STATUS EC_COMMAND_RETRIES times. */
	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS EC_COMMAND_RETRIES times. */
	{
		struct ec_response_get_comms_status *data;
		int i;

		for (i = 0; i < 50; ++i) {
			mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
			KUNIT_ASSERT_PTR_NE(test, mock, NULL);

			data = (struct ec_response_get_comms_status *)mock->o_data;
			data->flags |= EC_COMMS_STATUS_PROCESSING;
		}
	}

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EAGAIN);

	/* For EC_CMD_GET_COMMS_STATUS EC_COMMAND_RETRIES times. */
	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_xfer_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EIO);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, 0);

	KUNIT_EXPECT_EQ(test, msg.result, EC_RES_INVALID_COMMAND);

	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2);
}

static void cros_ec_proto_test_cmd_xfer_in_progress_return0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	ec_dev->pkt_xfer = cros_kunit_ec_pkt_xfer_mock;

	/* For the first host command to return EC_RES_IN_PROGRESS. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	/* For EC_CMD_GET_COMMS_STATUS. */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EPROTO);

	KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2);
}

static void cros_ec_proto_test_cmd_xfer_status_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	/* For cros_ec_cmd_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_add(test, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer_status(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, 0);
}

static void cros_ec_proto_test_cmd_xfer_status_xfer_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	struct cros_ec_command msg;

	memset(&msg, 0, sizeof(msg));

	/* For cros_ec_cmd_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_cmd_xfer_status(ec_dev, &msg);
	KUNIT_EXPECT_EQ(test, ret, -EPROTO);
}

static void cros_ec_proto_test_cmd_xfer_status_return_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret, i;
	struct cros_ec_command msg;
	static const int map[] = {
		[EC_RES_SUCCESS] = 0,
		[EC_RES_INVALID_COMMAND] = -EOPNOTSUPP,
		[EC_RES_ERROR] = -EIO,
		[EC_RES_INVALID_PARAM] = -EINVAL,
		[EC_RES_ACCESS_DENIED] = -EACCES,
		[EC_RES_INVALID_RESPONSE] = -EPROTO,
		[EC_RES_INVALID_VERSION] = -ENOPROTOOPT,
		[EC_RES_INVALID_CHECKSUM] = -EBADMSG,
		/*
		 * EC_RES_IN_PROGRESS is special because cros_ec_send_command() has extra logic to
		 * handle it.  Note that default cros_kunit_ec_xfer_mock_default_ret == 0 thus
		 * cros_ec_xfer_command() in cros_ec_wait_until_complete() returns 0.  As a result,
		 * it returns -EPROTO without calling cros_ec_map_error().
		 */
		[EC_RES_IN_PROGRESS] = -EPROTO,
		[EC_RES_UNAVAILABLE] = -ENODATA,
		[EC_RES_TIMEOUT] = -ETIMEDOUT,
		[EC_RES_OVERFLOW] = -EOVERFLOW,
		[EC_RES_INVALID_HEADER] = -EBADR,
		[EC_RES_REQUEST_TRUNCATED] = -EBADR,
		[EC_RES_RESPONSE_TOO_BIG] = -EFBIG,
		[EC_RES_BUS_ERROR] = -EFAULT,
		[EC_RES_BUSY] = -EBUSY,
		[EC_RES_INVALID_HEADER_VERSION] = -EBADMSG,
		[EC_RES_INVALID_HEADER_CRC] = -EBADMSG,
		[EC_RES_INVALID_DATA_CRC] = -EBADMSG,
		[EC_RES_DUP_UNAVAILABLE] = -ENODATA,
	};

	memset(&msg, 0, sizeof(msg));

	for (i = 0; i < ARRAY_SIZE(map); ++i) {
		mock = cros_kunit_ec_xfer_mock_addx(test, 0, i, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		ret = cros_ec_cmd_xfer_status(ec_dev, &msg);
		KUNIT_EXPECT_EQ(test, ret, map[i]);
	}
}

static void cros_ec_proto_test_get_next_event_no_mkbp_event(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	bool wake_event, more_events;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->mkbp_event_supported = 0;

	/* Set some garbage bytes. */
	wake_event = false;
	more_events = true;

	/* For get_keyboard_state_event(). */
	{
		union ec_response_get_next_data_v3 *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (union ec_response_get_next_data_v3 *)mock->o_data;
		data->host_event = 0xbeef;
	}

	ret = cros_ec_get_next_event(ec_dev, &wake_event, &more_events);
	KUNIT_EXPECT_EQ(test, ret, sizeof(union ec_response_get_next_data_v3));

	KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_KEY_MATRIX);
	KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.host_event, 0xbeef);

	KUNIT_EXPECT_TRUE(test, wake_event);
	KUNIT_EXPECT_FALSE(test, more_events);

	/* For get_keyboard_state_event(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MKBP_STATE);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(union ec_response_get_next_data_v3));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;

	ec_dev->mkbp_event_supported = 1;
	ec_dev->suspended = true;

	ret = cros_ec_get_next_event(ec_dev, NULL, NULL);
	KUNIT_EXPECT_EQ(test, ret, -EHOSTDOWN);
}

static void cros_ec_proto_test_get_next_event_mkbp_event_version0(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	bool wake_event, more_events;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->mkbp_event_supported = 1;

	/* Set some garbage bytes. */
	wake_event = true;
	more_events = false;

	/* For get_next_event_xfer(). */
	{
		struct ec_response_get_next_event *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_next_event *)mock->o_data;
		data->event_type = EC_MKBP_EVENT_SENSOR_FIFO | EC_MKBP_HAS_MORE_EVENTS;
		data->data.sysrq = 0xbeef;
	}

	ret = cros_ec_get_next_event(ec_dev, &wake_event, &more_events);
	KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event));

	KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_SENSOR_FIFO);
	KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef);

	KUNIT_EXPECT_FALSE(test, wake_event);
	KUNIT_EXPECT_TRUE(test, more_events);

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_next_event));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_next_event_mkbp_event_version2(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	bool wake_event, more_events;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->mkbp_event_supported = 3;

	/* Set some garbage bytes. */
	wake_event = false;
	more_events = true;

	/* For get_next_event_xfer(). */
	{
		struct ec_response_get_next_event_v1 *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_next_event_v1 *)mock->o_data;
		data->event_type = EC_MKBP_EVENT_FINGERPRINT;
		data->data.sysrq = 0xbeef;
	}

	ret = cros_ec_get_next_event(ec_dev, &wake_event, &more_events);
	KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event_v1));

	KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_FINGERPRINT);
	KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef);

	KUNIT_EXPECT_TRUE(test, wake_event);
	KUNIT_EXPECT_FALSE(test, more_events);

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 2);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_next_event_v1));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	bool wake_event;
	struct ec_response_get_next_event_v1 *data;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->mkbp_event_supported = 3;
	ec_dev->host_event_wake_mask = U32_MAX;

	/* Set some garbage bytes. */
	wake_event = true;

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_add(test,
						   sizeof(data->event_type) +
						   sizeof(data->data.host_event));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_next_event_v1 *)mock->o_data;
		data->event_type = EC_MKBP_EVENT_HOST_EVENT;
		put_unaligned_le32(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC), &data->data.host_event);
	}

	ret = cros_ec_get_next_event(ec_dev, &wake_event, NULL);
	KUNIT_EXPECT_EQ(test, ret, sizeof(data->event_type) + sizeof(data->data.host_event));

	KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_HOST_EVENT);

	KUNIT_EXPECT_FALSE(test, wake_event);

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 2);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_next_event_v1));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	bool wake_event;
	struct ec_response_get_next_event_v1 *data;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->mkbp_event_supported = 3;
	ec_dev->host_event_wake_mask = U32_MAX & ~EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED);

	/* Set some garbage bytes. */
	wake_event = true;

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_add(test,
						   sizeof(data->event_type) +
						   sizeof(data->data.host_event));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_next_event_v1 *)mock->o_data;
		data->event_type = EC_MKBP_EVENT_HOST_EVENT;
		put_unaligned_le32(EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED),
				   &data->data.host_event);
	}

	ret = cros_ec_get_next_event(ec_dev, &wake_event, NULL);
	KUNIT_EXPECT_EQ(test, ret, sizeof(data->event_type) + sizeof(data->data.host_event));

	KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_HOST_EVENT);

	KUNIT_EXPECT_FALSE(test, wake_event);

	/* For get_next_event_xfer(). */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 2);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT);
		KUNIT_EXPECT_EQ(test, mock->msg.insize,
				sizeof(struct ec_response_get_next_event_v1));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_host_event_no_mkbp_event(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;

	ec_dev->mkbp_event_supported = 0;

	ret = cros_ec_get_host_event(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);
}

static void cros_ec_proto_test_get_host_event_not_host_event(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;

	ec_dev->mkbp_event_supported = 1;
	ec_dev->event_data.event_type = EC_MKBP_EVENT_FINGERPRINT;

	ret = cros_ec_get_host_event(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);
}

static void cros_ec_proto_test_get_host_event_wrong_event_size(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;

	ec_dev->mkbp_event_supported = 1;
	ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT;
	ec_dev->event_size = 0xff;

	ret = cros_ec_get_host_event(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, 0);
}

static void cros_ec_proto_test_get_host_event_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	int ret;

	ec_dev->mkbp_event_supported = 1;
	ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT;
	ec_dev->event_size = sizeof(ec_dev->event_data.data.host_event);
	put_unaligned_le32(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC),
			   &ec_dev->event_data.data.host_event);

	ret = cros_ec_get_host_event(ec_dev);
	KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC));
}

static void cros_ec_proto_test_check_features_cached(struct kunit *test)
{
	int ret, i;
	static struct cros_ec_dev ec;

	ec.features.flags[0] = EC_FEATURE_MASK_0(EC_FEATURE_FINGERPRINT);
	ec.features.flags[1] = EC_FEATURE_MASK_0(EC_FEATURE_SCP);

	for (i = 0; i < EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK; ++i) {
		ret = cros_ec_check_features(&ec, i);
		switch (i) {
		case EC_FEATURE_FINGERPRINT:
		case EC_FEATURE_SCP:
			KUNIT_EXPECT_TRUE(test, ret);
			break;
		default:
			KUNIT_EXPECT_FALSE(test, ret);
			break;
		}
	}
}

static void cros_ec_proto_test_check_features_not_cached(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret, i;
	static struct cros_ec_dev ec;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec.ec_dev = ec_dev;
	ec.dev = ec_dev->dev;
	ec.cmd_offset = 0;
	ec.features.flags[0] = -1;
	ec.features.flags[1] = -1;

	/* For EC_CMD_GET_FEATURES. */
	{
		struct ec_response_get_features *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_get_features *)mock->o_data;
		data->flags[0] = EC_FEATURE_MASK_0(EC_FEATURE_FINGERPRINT);
		data->flags[1] = EC_FEATURE_MASK_0(EC_FEATURE_SCP);
	}

	for (i = 0; i < EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK; ++i) {
		ret = cros_ec_check_features(&ec, i);
		switch (i) {
		case EC_FEATURE_FINGERPRINT:
		case EC_FEATURE_SCP:
			KUNIT_EXPECT_TRUE(test, ret);
			break;
		default:
			KUNIT_EXPECT_FALSE(test, ret);
			break;
		}
	}

	/* For EC_CMD_GET_FEATURES. */
	{
		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_FEATURES);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_features));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
	}
}

static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	static struct cros_ec_dev ec;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec.ec_dev = ec_dev;
	ec.dev = ec_dev->dev;
	ec.cmd_offset = 0;

	/* For EC_CMD_MOTION_SENSE_CMD. */
	{
		struct ec_response_motion_sense *data;

		mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data));
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (struct ec_response_motion_sense *)mock->o_data;
		data->dump.sensor_count = 0xbf;
	}

	ret = cros_ec_get_sensor_count(&ec);
	KUNIT_EXPECT_EQ(test, ret, 0xbf);

	/* For EC_CMD_MOTION_SENSE_CMD. */
	{
		struct ec_params_motion_sense *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 1);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_motion_sense *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP);
	}
}

static void cros_ec_proto_test_get_sensor_count_xfer_error(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	static struct cros_ec_dev ec;

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec.ec_dev = ec_dev;
	ec.dev = ec_dev->dev;
	ec.cmd_offset = 0;

	/* For EC_CMD_MOTION_SENSE_CMD. */
	{
		mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);
	}

	ret = cros_ec_get_sensor_count(&ec);
	KUNIT_EXPECT_EQ(test, ret, -EPROTO);

	/* For EC_CMD_MOTION_SENSE_CMD. */
	{
		struct ec_params_motion_sense *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 1);
		KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

		data = (struct ec_params_motion_sense *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP);
	}
}

static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret, i;
	static struct cros_ec_dev ec;
	struct {
		u8 readmem_data;
		int expected_result;
	} test_data[] = {
		{ 0, 0 },
		{ EC_MEMMAP_ACC_STATUS_PRESENCE_BIT, 2 },
	};

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;
	ec_dev->cmd_readmem = cros_kunit_readmem_mock;
	ec.ec_dev = ec_dev;
	ec.dev = ec_dev->dev;
	ec.cmd_offset = 0;

	for (i = 0; i < ARRAY_SIZE(test_data); ++i) {
		/* For EC_CMD_MOTION_SENSE_CMD. */
		{
			mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0);
			KUNIT_ASSERT_PTR_NE(test, mock, NULL);
		}

		/* For readmem. */
		{
			cros_kunit_readmem_mock_data = kunit_kzalloc(test, 1, GFP_KERNEL);
			KUNIT_ASSERT_PTR_NE(test, cros_kunit_readmem_mock_data, NULL);
			cros_kunit_readmem_mock_data[0] = test_data[i].readmem_data;

			cros_kunit_ec_xfer_mock_default_ret = 1;
		}

		ret = cros_ec_get_sensor_count(&ec);
		KUNIT_EXPECT_EQ(test, ret, test_data[i].expected_result);

		/* For EC_CMD_MOTION_SENSE_CMD. */
		{
			struct ec_params_motion_sense *data;

			mock = cros_kunit_ec_xfer_mock_next();
			KUNIT_EXPECT_PTR_NE(test, mock, NULL);

			KUNIT_EXPECT_EQ(test, mock->msg.version, 1);
			KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD);
			KUNIT_EXPECT_EQ(test, mock->msg.insize,
					sizeof(struct ec_response_motion_sense));
			KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data));

			data = (struct ec_params_motion_sense *)mock->i_data;
			KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP);
		}

		/* For readmem. */
		{
			KUNIT_EXPECT_EQ(test, cros_kunit_readmem_mock_offset, EC_MEMMAP_ACC_STATUS);
		}
	}
}

static void cros_ec_proto_test_ec_cmd(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;
	struct ec_xfer_mock *mock;
	int ret;
	u8 out[3], in[2];

	ec_dev->max_request = 0xff;
	ec_dev->max_response = 0xee;

	out[0] = 0xdd;
	out[1] = 0xcc;
	out[2] = 0xbb;

	{
		u8 *data;

		mock = cros_kunit_ec_xfer_mock_add(test, 2);
		KUNIT_ASSERT_PTR_NE(test, mock, NULL);

		data = (u8 *)mock->o_data;
		data[0] = 0xaa;
		data[1] = 0x99;
	}

	ret = cros_ec_cmd(ec_dev, 0x88, 0x77, out, ARRAY_SIZE(out), in, ARRAY_SIZE(in));
	KUNIT_EXPECT_EQ(test, ret, 2);

	{
		u8 *data;

		mock = cros_kunit_ec_xfer_mock_next();
		KUNIT_EXPECT_PTR_NE(test, mock, NULL);

		KUNIT_EXPECT_EQ(test, mock->msg.version, 0x88);
		KUNIT_EXPECT_EQ(test, mock->msg.command, 0x77);
		KUNIT_EXPECT_EQ(test, mock->msg.insize, ARRAY_SIZE(in));
		KUNIT_EXPECT_EQ(test, mock->msg.outsize, ARRAY_SIZE(out));

		data = (u8 *)mock->i_data;
		KUNIT_EXPECT_EQ(test, data[0], 0xdd);
		KUNIT_EXPECT_EQ(test, data[1], 0xcc);
		KUNIT_EXPECT_EQ(test, data[2], 0xbb);
	}
}

static void cros_ec_proto_test_release(struct device *dev)
{
}

static int cros_ec_proto_test_init(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv;
	struct cros_ec_device *ec_dev;

	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;
	test->priv = priv;

	ec_dev = &priv->ec_dev;
	ec_dev->dout = (u8 *)priv->dout;
	ec_dev->dout_size = ARRAY_SIZE(priv->dout);
	ec_dev->din = (u8 *)priv->din;
	ec_dev->din_size = ARRAY_SIZE(priv->din);
	ec_dev->proto_version = EC_HOST_REQUEST_VERSION;
	ec_dev->dev = kunit_kzalloc(test, sizeof(*ec_dev->dev), GFP_KERNEL);
	if (!ec_dev->dev)
		return -ENOMEM;
	device_initialize(ec_dev->dev);
	dev_set_name(ec_dev->dev, "cros_ec_proto_test");
	ec_dev->dev->release = cros_ec_proto_test_release;
	ec_dev->cmd_xfer = cros_kunit_ec_xfer_mock;
	ec_dev->pkt_xfer = cros_kunit_ec_xfer_mock;
	mutex_init(&ec_dev->lock);

	priv->msg = (struct cros_ec_command *)priv->_msg;

	cros_kunit_mock_reset();

	return 0;
}

static void cros_ec_proto_test_exit(struct kunit *test)
{
	struct cros_ec_proto_test_priv *priv = test->priv;
	struct cros_ec_device *ec_dev = &priv->ec_dev;

	put_device(ec_dev->dev);
}

static struct kunit_case cros_ec_proto_test_cases[] = {
	KUNIT_CASE(cros_ec_proto_test_prepare_tx_legacy_normal),
	KUNIT_CASE(cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize),
	KUNIT_CASE(cros_ec_proto_test_prepare_tx_normal),
	KUNIT_CASE(cros_ec_proto_test_prepare_tx_bad_msg_outsize),
	KUNIT_CASE(cros_ec_proto_test_check_result),
	KUNIT_CASE(cros_ec_proto_test_query_all_normal),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_pd_return_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_pd_return0),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_normal_v3_return_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_normal_v3_return0),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_xfer_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_return_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_data_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_legacy_return0),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp_return_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp_return0),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_host_sleep),
	KUNIT_CASE(cros_ec_proto_test_query_all_no_host_sleep_return0),
	KUNIT_CASE(cros_ec_proto_test_query_all_default_wake_mask_return_error),
	KUNIT_CASE(cros_ec_proto_test_query_all_default_wake_mask_return0),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_normal),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_excess_msg_insize),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_protocol_v3_normal),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_protocol_v3_no_op),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_protocol_v2_normal),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_protocol_v2_no_op),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_normal),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_xfer_error),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_return_error),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_return0),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_status_normal),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_status_xfer_error),
	KUNIT_CASE(cros_ec_proto_test_cmd_xfer_status_return_error),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_no_mkbp_event),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_version0),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_version2),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc),
	KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked),
	KUNIT_CASE(cros_ec_proto_test_get_host_event_no_mkbp_event),
	KUNIT_CASE(cros_ec_proto_test_get_host_event_not_host_event),
	KUNIT_CASE(cros_ec_proto_test_get_host_event_wrong_event_size),
	KUNIT_CASE(cros_ec_proto_test_get_host_event_normal),
	KUNIT_CASE(cros_ec_proto_test_check_features_cached),
	KUNIT_CASE(cros_ec_proto_test_check_features_not_cached),
	KUNIT_CASE(cros_ec_proto_test_get_sensor_count_normal),
	KUNIT_CASE(cros_ec_proto_test_get_sensor_count_xfer_error),
	KUNIT_CASE(cros_ec_proto_test_get_sensor_count_legacy),
	KUNIT_CASE(cros_ec_proto_test_ec_cmd),
	{}
};

static struct kunit_suite cros_ec_proto_test_suite = {
	.name = "cros_ec_proto_test",
	.init = cros_ec_proto_test_init,
	.exit = cros_ec_proto_test_exit,
	.test_cases = cros_ec_proto_test_cases,
};

kunit_test_suite(cros_ec_proto_test_suite);

MODULE_DESCRIPTION("Kunit tests for ChromeOS Embedded Controller protocol");
MODULE_LICENSE("GPL");
