summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2023-01-16 14:53:34 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-25 20:35:02 +0000
commitc7d5e1da9ade15854ce1779a9ca4b906fb3f13a1 (patch)
tree1fa08c744ce92a93f859bc3170ad7611da5de33b
parent2a81b85c1b0a806891ed6d838650e83ee66d2b2b (diff)
downloadchrome-ec-c7d5e1da9ade15854ce1779a9ca4b906fb3f13a1.tar.gz
TCPMv2: Rearrange VDM response HC contents
The AP would like to consume VDM:Attention packets in the same host command as the VDM responses. To support this, pull the previous return error into a response structure field instead. Also correct an incorrect struct for the VDM response test utility (though it is functionally equivalent to the TYPEC_STATUS struct). BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Change-Id: I5d976dda6be40b72de15e84f4bbd9311d908a904 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171489 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/usb_pd_host.c7
-rw-r--r--include/ec_commands.h4
-rw-r--r--util/ectool.cc5
-rw-r--r--zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c22
-rw-r--r--zephyr/test/drivers/common/src/utils.c2
5 files changed, 18 insertions, 22 deletions
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c
index 2c08aee302..e2d1f36a61 100644
--- a/common/usbc/usb_pd_host.c
+++ b/common/usbc/usb_pd_host.c
@@ -252,7 +252,6 @@ static enum ec_status hc_typec_vdm_response(struct host_cmd_handler_args *args)
const struct ec_params_typec_vdm_response *p = args->params;
struct ec_response_typec_vdm_response *r = args->response;
uint32_t data[VDO_MAX_SIZE];
- enum ec_status rv;
if (p->port >= board_get_usb_pd_port_count())
return EC_RES_INVALID_PARAM;
@@ -262,14 +261,14 @@ static enum ec_status hc_typec_vdm_response(struct host_cmd_handler_args *args)
args->response_size = sizeof(*r);
- rv = dpm_copy_vdm_reply(p->port, &r->partner_type, &r->vdm_data_objects,
- data);
+ r->vdm_response_err = dpm_copy_vdm_reply(p->port, &r->partner_type,
+ &r->vdm_data_objects, data);
if (r->vdm_data_objects > 0)
memcpy(r->vdm_response, data,
r->vdm_data_objects * sizeof(uint32_t));
- return rv;
+ return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_TYPEC_VDM_RESPONSE, hc_typec_vdm_response,
EC_VER_MASK(0));
diff --git a/include/ec_commands.h b/include/ec_commands.h
index c63c17c535..35fe03d29d 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -7375,8 +7375,8 @@ struct ec_response_typec_vdm_response {
uint8_t vdm_data_objects;
/* Partner to address - see enum typec_partner_type */
uint8_t partner_type;
- /* Reserved */
- uint16_t reserved;
+ /* enum ec_status describing VDM response */
+ uint16_t vdm_response_err;
/* VDM data, including VDM header */
uint32_t vdm_response[VDO_MAX_SIZE];
} __ec_align1;
diff --git a/util/ectool.cc b/util/ectool.cc
index 4c066efc72..c413654d32 100644
--- a/util/ectool.cc
+++ b/util/ectool.cc
@@ -10719,13 +10719,14 @@ int cmd_typec_vdm_response(int argc, char *argv[])
if (rv < 0)
return -1;
- if (r->vdm_data_objects > 0) {
+ if (r->vdm_data_objects > 0 && r->vdm_response_err == EC_RES_SUCCESS) {
printf("VDM response from partner: %d", r->partner_type);
for (i = 0; i < r->vdm_data_objects; i++)
printf("\n 0x%08x", r->vdm_response[i]);
printf("\n");
} else {
- printf("No VDM response found\n");
+ printf("No VDM response found (err: %d)\n",
+ r->vdm_response_err);
}
return 0;
diff --git a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
index ad263b7627..da6fdc5512 100644
--- a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
+++ b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
@@ -337,6 +337,7 @@ ZTEST_F(ap_vdm_control, test_vdm_response_ack)
"Failed to see VDM ACK event");
vdm_resp = host_cmd_typec_vdm_response(TEST_PORT);
+ zassert_equal(vdm_resp.vdm_response_err, EC_RES_SUCCESS);
zassert_equal(vdm_resp.partner_type, req.partner_type,
"Failed to see correct partner");
zassert_equal(vdm_resp.vdm_data_objects, fixture->partner.identity_vdos,
@@ -375,6 +376,7 @@ ZTEST_F(ap_vdm_control, test_vdm_request_nak)
"Failed to see VDM NAK event");
vdm_resp = host_cmd_typec_vdm_response(TEST_PORT);
+ zassert_equal(vdm_resp.vdm_response_err, EC_RES_SUCCESS);
zassert_equal(vdm_resp.partner_type, req.partner_type,
"Failed to see correct partner");
zassert_equal(vdm_resp.vdm_data_objects,
@@ -390,9 +392,6 @@ ZTEST_F(ap_vdm_control, test_vdm_request_failed)
{
struct ec_response_typec_status status;
struct ec_response_typec_vdm_response vdm_resp;
- struct ec_params_typec_status params = { .port = TEST_PORT };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_TYPEC_VDM_RESPONSE, 0, vdm_resp, params);
uint32_t vdm_req_header = VDO(USB_SID_DISPLAYPORT, 1, CMD_ENTER_MODE) |
VDO_SVDM_VERS(VDM_VER20);
@@ -413,7 +412,8 @@ ZTEST_F(ap_vdm_control, test_vdm_request_failed)
zassert_true(status.events & PD_STATUS_EVENT_VDM_REQ_FAILED,
"Failed to see notice of no reply");
- zassert_equal(host_command_process(&args), EC_RES_UNAVAILABLE,
+ vdm_resp = host_cmd_typec_vdm_response(TEST_PORT);
+ zassert_equal(vdm_resp.vdm_response_err, EC_RES_UNAVAILABLE,
"Failed to get unavailable");
}
@@ -431,9 +431,6 @@ ZTEST_F(ap_vdm_control, test_vdm_request_bad_port)
ZTEST_F(ap_vdm_control, test_vdm_request_in_progress)
{
struct ec_response_typec_vdm_response vdm_resp;
- struct ec_params_typec_status params = { .port = TEST_PORT };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_TYPEC_VDM_RESPONSE, 0, vdm_resp, params);
uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT) |
VDO_SVDM_VERS(VDM_VER20);
@@ -446,18 +443,17 @@ ZTEST_F(ap_vdm_control, test_vdm_request_in_progress)
host_cmd_typec_control_vdm_req(TEST_PORT, req);
/* Give no processing time and immediately ask for our result */
- zassert_equal(host_command_process(&args), EC_RES_BUSY,
- "Failed to see busy");
+ vdm_resp = host_cmd_typec_vdm_response(TEST_PORT);
+ zassert_equal(vdm_resp.vdm_response_err, EC_RES_BUSY,
+ "Failed to get busy");
}
ZTEST_F(ap_vdm_control, test_vdm_request_no_send)
{
struct ec_response_typec_vdm_response vdm_resp;
- struct ec_params_typec_status params = { .port = TEST_PORT };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_TYPEC_VDM_RESPONSE, 0, vdm_resp, params);
/* Check for an error on a fresh connection with no VDM REQ sent */
- zassert_equal(host_command_process(&args), EC_RES_UNAVAILABLE,
+ vdm_resp = host_cmd_typec_vdm_response(TEST_PORT);
+ zassert_equal(vdm_resp.vdm_response_err, EC_RES_UNAVAILABLE,
"Failed to see no message ready");
}
diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c
index 83e82a090a..dda855ebba 100644
--- a/zephyr/test/drivers/common/src/utils.c
+++ b/zephyr/test/drivers/common/src/utils.c
@@ -608,7 +608,7 @@ void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req)
struct ec_response_typec_vdm_response host_cmd_typec_vdm_response(int port)
{
- struct ec_params_typec_status params = { .port = port };
+ struct ec_params_typec_vdm_response params = { .port = port };
struct ec_response_typec_vdm_response response;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
EC_CMD_TYPEC_VDM_RESPONSE, 0, response, params);