diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2020-07-15 11:03:25 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-29 03:33:52 +0000 |
commit | 545e72a8540f14416c3d91bf1b5483882a10519e (patch) | |
tree | ac91cc9b5159ad208aa931eea46677acc3c53da0 /test/usb_prl_old.c | |
parent | a3a577297d83798dd7a74771cfbc621d9228b838 (diff) | |
download | chrome-ec-545e72a8540f14416c3d91bf1b5483882a10519e.tar.gz |
TCPMv2: Optionally build extended message support
If CONFIG_USB_PD_EXTENDED_MESSAGES is defined, support sending and
receiving extended messages. If it is not, remove the chunking state
machines from the PRL and modify the PE to respond with Not Supported as
appropriate.
BUG=b:160374787,b:158572770
TEST=Attach various devices; observe PD traffic
TEST=make run-usb_prl_noextended; make run-usb_pe_drp_noextended
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I862020155927b5613d599274708e60678c49c43c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304263
Commit-Queue: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'test/usb_prl_old.c')
-rw-r--r-- | test/usb_prl_old.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c index 8a2dea0fd0..e75b81fde2 100644 --- a/test/usb_prl_old.c +++ b/test/usb_prl_old.c @@ -71,6 +71,13 @@ enum usb_prl_hr_state prl_hr_get_state(const int port); enum usb_rch_state rch_get_state(const int port); enum usb_tch_state tch_get_state(const int port); +#ifndef CONFIG_USB_PD_EXTENDED_MESSAGES +enum usb_rch_state rch_get_state(const int port) +{ + return RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER; +} +#endif + static uint32_t test_data[] = { 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, @@ -379,7 +386,8 @@ static int simulate_receive_extended_data(int port, return 0; } - if (pd_port[port].mock_pe_message_received) { + if (IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES) && + pd_port[port].mock_pe_message_received) { ccprintf("Mock pe msg received iteration (%d)\n", j); return 0; } @@ -402,6 +410,12 @@ static int simulate_receive_extended_data(int port, cycle_through_state_machine(port, 1, MSEC); inc_rx_id(port); + if (!IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + if (pd_port[port].mock_pe_message_received) + return 1; + return 0; + } + /* * If no more data, do expected to get a chunk request */ @@ -1049,6 +1063,11 @@ static int test_send_extended_data_msg(void) int i; int port = PORT0; + if (!IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + ccprints("CONFIG_USB_PD_EXTENDED_MESSAGES disabled; skipping"); + return EC_SUCCESS; + } + enable_prl(port, 1); /* @@ -1199,19 +1218,36 @@ static int test_receive_extended_data_msg(void) enable_prl(port, 1); - /* - * TEST: Receiving extended data message with 29 to 260 bytes - */ + if (IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { + /* + * TEST: Receiving extended data message with 29 to 260 bytes + */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); - TEST_EQ(rch_get_state(port), - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, "%u"); + TEST_EQ(rch_get_state(port), + RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, "%u"); - for (len = 29; len <= 260; len++) + for (len = 29; len <= 260; len++) { + TEST_NE(simulate_receive_extended_data(port, + PD_DATA_BATTERY_STATUS, len), 0, "%d"); + } + } else { + /* + * TEST: Receiving unsupported extended data message and then + * subsequently receiving a support non-extended data message. + */ + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); TEST_NE(simulate_receive_extended_data(port, - PD_DATA_BATTERY_STATUS, len), 0, "%d"); + PD_DATA_BATTERY_STATUS, 29), 0, "%d"); + + task_wake(PD_PORT_TO_TASK_ID(port)); + task_wait_event(40 * MSEC); + TEST_NE(simulate_receive_data(port, + PD_DATA_BATTERY_STATUS, 28), 0, "%d"); + } enable_prl(port, 0); @@ -1392,6 +1428,8 @@ void run_test(int argc, char **argv) /* TODO(shurst): More PD 2.0 Tests */ + ccprints("Starting PD 3.0 tests"); + /* Test PD 3.0 Protocol */ init_port(PORT0, PD_REV30); RUN_TEST(test_prl_reset); @@ -1418,4 +1456,3 @@ void run_test(int argc, char **argv) test_print_result(); } - |