summaryrefslogtreecommitdiff
path: root/test/usb_pe_drp.c
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-07-27 19:01:55 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-01 04:00:43 +0000
commit44504b4e0a648e81bd353b6a3d19cdfc3bc107da (patch)
tree34e8f59bd95d09184ab6d59898599b2451964b43 /test/usb_pe_drp.c
parent0f93e28bc7d3bfe61ba792d31d6a9ed7be43728e (diff)
downloadchrome-ec-44504b4e0a648e81bd353b6a3d19cdfc3bc107da.tar.gz
TCPMv2: Soft reset on failure to send source caps
pe_report_error() defers to PE_SRC_SEND_CAPABILITIES for custom error handling (via PE_FLAGS_PROTOCOL_ERROR). pe_src_send_capabilities_run() was correctly going to PE_SRC_DISCOVERY when we are not connected (PD 3.0 8.3.3.2.3), but it was failing to send soft reset when we are already connected (PD 3.0 8.3.3.4.1.1). BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp PD 3.0 compliance test TD.PD.SRC3.E26 (Soft_Reset sent regardless of Rp value) Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Id71e38a69006e95b7ff4f7145e86bd5ac64c7577 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321869 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'test/usb_pe_drp.c')
-rw-r--r--test/usb_pe_drp.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c
index 18eee89c68..6cd1fb2bde 100644
--- a/test/usb_pe_drp.c
+++ b/test/usb_pe_drp.c
@@ -278,6 +278,41 @@ test_static int test_extended_message_not_supported_snk(void)
return test_extended_message_not_supported();
}
+static int test_send_caps_error(void)
+{
+ /*
+ * See section 8.3.3.4.1.1 PE_SRC_Send_Soft_Reset State and section
+ * 8.3.3.2.3 PE_SRC_Send_Capabilities State.
+ *
+ * Transition to the PE_SRC_Discovery state when:
+ * 1) The Protocol Layer indicates that the Message has not been sent
+ * and we are presently not Connected
+ */
+ fake_prl_clear_last_sent_ctrl_msg(PORT0);
+ pe_set_flag(PORT0, PE_FLAGS_PROTOCOL_ERROR);
+ pe_clr_flag(PORT0, PE_FLAGS_PD_CONNECTION);
+ set_state_pe(PORT0, PE_SRC_SEND_CAPABILITIES);
+ task_wait_event(10 * MSEC);
+ TEST_EQ(fake_prl_get_last_sent_ctrl_msg(PORT0), 0, "%d");
+ TEST_EQ(get_state_pe(PORT0), PE_SRC_DISCOVERY, "%d");
+
+ /*
+ * Send soft reset when:
+ * 1) The Protocol Layer indicates that the Message has not been sent
+ * and we are already Connected
+ */
+ fake_prl_clear_last_sent_ctrl_msg(PORT0);
+ pe_set_flag(PORT0, PE_FLAGS_PROTOCOL_ERROR);
+ pe_set_flag(PORT0, PE_FLAGS_PD_CONNECTION);
+ set_state_pe(PORT0, PE_SRC_SEND_CAPABILITIES);
+ task_wait_event(10 * MSEC);
+ TEST_EQ(fake_prl_get_last_sent_ctrl_msg(PORT0),
+ PD_CTRL_SOFT_RESET, "%d");
+ TEST_EQ(get_state_pe(PORT0), PE_SEND_SOFT_RESET, "%d");
+
+ return EC_SUCCESS;
+}
+
void run_test(int argc, char **argv)
{
test_reset();
@@ -288,6 +323,7 @@ void run_test(int argc, char **argv)
RUN_TEST(test_extended_message_not_supported_src);
RUN_TEST(test_extended_message_not_supported_snk);
#endif
+ RUN_TEST(test_send_caps_error);
/* Do basic state machine validity checks last. */
RUN_TEST(test_pe_no_parent_cycles);