diff options
author | Sam Hurst <shurst@google.com> | 2020-08-14 13:05:20 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-22 01:49:02 +0000 |
commit | c2c19821c41f0e20de1cc0c3f6103d338f868198 (patch) | |
tree | 859ea9e3dc66ae683280c3b81d1b426237b8d61d /test | |
parent | 213015c44bd470565091a5eb429a593e79dfc52f (diff) | |
download | chrome-ec-c2c19821c41f0e20de1cc0c3f6103d338f868198.tar.gz |
TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequence
Delay sending a new message during the reception or
transmitting of Chunked messages.
BRANCH=none
BUG=b:161836223
TEST=make -j buildall
manual: Transmitted an extended message and verified
that the sequence was not interrupted by attempting
to send a VDM message.
Without patch
Chunked message request that was interrupted.
20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00
20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400
20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00
20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400
Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f
20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00
20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400
20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00
20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400
20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00
With patch.
Chunked message request was not interrupted.
20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00
20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400
20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00
20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400
Try to send VDM. Message delayed
20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00
20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400
20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00
20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400
20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00
20-08-14 10:50:56.242 C1: RECV 0c90/0
Try to send VDM.
Signed-off-by: Sam Hurst <shurst@google.com>wq
Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
Diffstat (limited to 'test')
-rw-r--r-- | test/usb_pe_drp_old.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/test/usb_pe_drp_old.c b/test/usb_pe_drp_old.c index 3cf1eceece..cc4594f6ae 100644 --- a/test/usb_pe_drp_old.c +++ b/test/usb_pe_drp_old.c @@ -11,6 +11,7 @@ #include "timer.h" #include "usb_emsg.h" #include "usb_mux.h" +#include "usb_pd.h" #include "usb_pe.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" @@ -29,6 +30,13 @@ const struct svdm_response svdm_rsp = { const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT]; const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT]; +static bool prl_is_busy_flag; + +bool prl_is_busy(int port) +{ + return prl_is_busy_flag; +} + int board_vbus_source_enabled(int port) { return 0; @@ -304,6 +312,56 @@ test_static int test_extended_message_not_supported_snk(void) return test_extended_message_not_supported(); } +test_static int test_prl_is_busy(enum pd_power_role pr) +{ + int ready_state; + + if (pr == PD_ROLE_SOURCE) + ready_state = PE_SRC_READY; + else + ready_state = PE_SNK_READY; + + /* Start in ready state with Protocol Layer busy */ + TEST_ASSERT(get_state_pe(PORT0) == ready_state); + prl_is_busy_flag = true; + + /* Make a request to perform a Port Discovery */ + pe_dpm_request(PORT0, DPM_REQUEST_PORT_DISCOVERY); + task_wait_event(10 * MSEC); + task_wait_event(10 * MSEC); + + /* + * We should still be in ready state because the Protocol + * Layer is busy and can't send our message at this time. + */ + TEST_ASSERT(get_state_pe(PORT0) == ready_state); + + /* Protocol Layer is not busy now */ + prl_is_busy_flag = false; + task_wait_event(10 * MSEC); + task_wait_event(10 * MSEC); + + /* + * The Protocol Layer is no longer busy so we can switch to the + * state that will handle sending the Port Discovery messages. + */ + TEST_ASSERT(get_state_pe(PORT0) != ready_state); + + return EC_SUCCESS; +} + +test_static int test_prl_is_busy_snk(void) +{ + setup_sink(); + return test_prl_is_busy(PD_ROLE_SINK); +} + +test_static int test_prl_is_busy_src(void) +{ + setup_source(); + return test_prl_is_busy(PD_ROLE_SOURCE); +} + static int test_send_caps_error(void) { /* @@ -349,9 +407,11 @@ void run_test(int argc, char **argv) #ifndef CONFIG_USB_PD_EXTENDED_MESSAGES RUN_TEST(test_extended_message_not_supported_src); RUN_TEST(test_extended_message_not_supported_snk); +#else + RUN_TEST(test_prl_is_busy_src); + RUN_TEST(test_prl_is_busy_snk); #endif RUN_TEST(test_send_caps_error); - /* Do basic state machine validity checks last. */ RUN_TEST(test_pe_no_parent_cycles); |