summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-06-16 16:20:17 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-06 02:06:20 +0000
commitd94d4cc45e39297cd4e072a07c8fca714715fa18 (patch)
tree19873d2936d701b02c7f778ab99166115d42a08a /test
parent17fed25d34ec92fa0c7c3bfc738e4ca63c20bba4 (diff)
downloadchrome-ec-d94d4cc45e39297cd4e072a07c8fca714715fa18.tar.gz
tcpmc2: fix TD.PD.LL3.E2 Retransmission test
We are retrying in both the TCPC hardware (4 total) and in the Protocol layer (3 total) when we do not get a GoodCRC back from the port partner. We are only suppose to retry up to nRetryCount times which is 2. This means we should be sending 3 total replies. Also correct a misinterpretation of the spec around SOP' and SOP" retries. We were not retrying those packets, but we should be retry them as the SOP. The SOP' device will not retry, but we (as the SOP) should retry packet that we are sending to them. The TCPM is not fast enough to meet the timing for tRetry (195 usec), so we need to perform the retries in the TCPC hardware layer. BRANCH=none BUG=b:150617035 TEST=Verify passing compliance test with GRL-C2 on Trembyle Change-Id: I55c4ab2f5ce8f64acf21af943862d96d9088622d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2248960
Diffstat (limited to 'test')
-rw-r--r--test/usb_prl_old.c133
-rw-r--r--test/usb_tcpmv2_tcpci.c94
2 files changed, 84 insertions, 143 deletions
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c
index 22da3629d3..4c06c41b8b 100644
--- a/test/usb_prl_old.c
+++ b/test/usb_prl_old.c
@@ -859,135 +859,6 @@ static int test_send_ctrl_msg(void)
return EC_SUCCESS;
}
-static int test_send_ctrl_msg_with_retry_and_fail(void)
-{
- int i;
- int port = PORT0;
-
- enable_prl(port, 1);
-
- /*
- * TEST: Control message transmission fail with retry
- */
- task_wake(PD_PORT_TO_TASK_ID(port));
- task_wait_event(MSEC);
-
- TEST_EQ(prl_tx_get_state(port),
- PRL_TX_WAIT_FOR_MESSAGE_REQUEST, "%u");
-
- TEST_NE(simulate_send_ctrl_msg_request_from_pe(port,
- TCPC_TX_SOP, PD_CTRL_ACCEPT), 0, "%d");
-
- cycle_through_state_machine(port, 1, MSEC);
-
- simulate_goodcrc(port, pd_port[port].power_role,
- pd_port[port].msg_tx_id);
-
- /* Do not increment tx_id so phy layer will not transmit message */
-
- /* Let statemachine settle */
- cycle_through_state_machine(port, 10, MSEC);
-
- TEST_EQ(pd_port[port].mock_got_soft_reset, 0, "%d");
- TEST_NE(pd_port[port].mock_pe_message_sent, 0, "%d");
-
- task_wake(PD_PORT_TO_TASK_ID(port));
- task_wait_event(MSEC);
-
- TEST_EQ(prl_tx_get_state(port),
- PRL_TX_WAIT_FOR_MESSAGE_REQUEST, "%u");
-
- pd_port[port].mock_pe_message_sent = 0;
- prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT);
- cycle_through_state_machine(port, 1, MSEC);
-
- for (i = 0; i < N_RETRY_COUNT + 1; i++) {
- /* Ensure that we have timed out */
- cycle_through_state_machine(port, 12, MSEC);
-
- TEST_EQ(pd_port[port].mock_got_soft_reset, 0, "%d");
- TEST_EQ(pd_port[port].mock_pe_message_sent, 0, "%d");
- if (i == N_RETRY_COUNT)
- TEST_EQ(pd_port[port].mock_pe_error,
- ERR_TCH_XMIT, "%d");
- else
- TEST_LE(pd_port[port].mock_pe_error, 0, "%d");
- }
-
- enable_prl(port, 0);
-
- return EC_SUCCESS;
-}
-
-static int test_send_ctrl_msg_with_retry_and_success(void)
-{
- int i;
- int port = PORT0;
-
- enable_prl(port, 1);
-
- /*
- * TEST: Control message transmission fail with retry
- */
-
- TEST_EQ(prl_tx_get_state(port),
- PRL_TX_WAIT_FOR_MESSAGE_REQUEST, "%u");
-
- pd_port[port].mock_got_soft_reset = 0;
- pd_port[port].mock_pe_error = -1;
- pd_port[port].mock_pe_message_sent = 0;
-
- prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT);
- task_wait_event(40 * MSEC);
-
- task_wake(PD_PORT_TO_TASK_ID(port));
- task_wait_event(40 * MSEC);
-
- simulate_goodcrc(port, pd_port[port].power_role,
- pd_port[port].msg_tx_id);
-
- /* Do not increment tx_id. */
-
- cycle_through_state_machine(port, 3, 10 * MSEC);
-
- TEST_EQ(pd_port[port].mock_got_soft_reset, 0, "%d");
- TEST_NE(pd_port[port].mock_pe_message_sent, 0, "%d");
-
- task_wake(PD_PORT_TO_TASK_ID(port));
- task_wait_event(40 * MSEC);
-
- TEST_EQ(prl_tx_get_state(port),
- PRL_TX_WAIT_FOR_MESSAGE_REQUEST, "%u");
-
- pd_port[port].mock_pe_message_sent = 0;
- prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT);
- task_wait_event(30 * MSEC);
-
- task_wake(PD_PORT_TO_TASK_ID(port));
- task_wait_event(30 * MSEC);
-
- for (i = 0; i < N_RETRY_COUNT + 1; i++) {
- if (i == N_RETRY_COUNT)
- inc_tx_id(port);
-
- simulate_goodcrc(port, pd_port[port].power_role,
- pd_port[port].msg_tx_id);
-
- cycle_through_state_machine(port, 3, MSEC);
-
- TEST_EQ(pd_port[port].mock_got_soft_reset, 0, "%d");
- if (i == N_RETRY_COUNT)
- TEST_NE(pd_port[port].mock_pe_message_sent, 0, "%d");
- else
- TEST_EQ(pd_port[port].mock_pe_message_sent, 0, "%d");
- TEST_LE(pd_port[port].mock_pe_error, 0, "%d");
- }
-
- enable_prl(port, 0);
-
- return EC_SUCCESS;
-}
-
static int test_send_data_msg(void)
{
int i;
@@ -1415,8 +1286,6 @@ void run_test(int argc, char **argv)
init_port(PORT0, PD_REV20);
RUN_TEST(test_prl_reset);
RUN_TEST(test_send_ctrl_msg);
- RUN_TEST(test_send_ctrl_msg_with_retry_and_fail);
- RUN_TEST(test_send_ctrl_msg_with_retry_and_success);
RUN_TEST(test_send_data_msg);
RUN_TEST(test_send_data_msg_to_much_data);
RUN_TEST(test_receive_control_msg);
@@ -1434,8 +1303,6 @@ void run_test(int argc, char **argv)
init_port(PORT0, PD_REV30);
RUN_TEST(test_prl_reset);
RUN_TEST(test_send_ctrl_msg);
- RUN_TEST(test_send_ctrl_msg_with_retry_and_fail);
- RUN_TEST(test_send_ctrl_msg_with_retry_and_success);
RUN_TEST(test_send_data_msg);
RUN_TEST(test_send_data_msg_to_much_data);
RUN_TEST(test_send_extended_data_msg);
diff --git a/test/usb_tcpmv2_tcpci.c b/test/usb_tcpmv2_tcpci.c
index 84bedd3e66..b383791faf 100644
--- a/test/usb_tcpmv2_tcpci.c
+++ b/test/usb_tcpmv2_tcpci.c
@@ -12,6 +12,7 @@
#include "timer.h"
#include "usb_mux.h"
#include "usb_tc_sm.h"
+#include "usb_prl_sm.h"
#define PORT0 0
@@ -167,8 +168,8 @@ __maybe_unused static int test_connect_as_pd3_source(void)
/*
* c) The Tester waits for Source_Capabilities for tNoResponse max.
*/
- TEST_EQ(mock_tcpci_wait_for_transmit(
- TCPC_TX_SOP, 0, PD_DATA_SOURCE_CAP), EC_SUCCESS, "%d");
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_SOURCE_CAP),
+ EC_SUCCESS, "%d");
/*
* d) The Tester replies GoodCrc on reception of the
* Source_Capabilities.
@@ -184,14 +185,14 @@ __maybe_unused static int test_connect_as_pd3_source(void)
1, PD_REV30, 0),
&rdo);
mock_set_alert(TCPC_REG_ALERT_RX_STATUS);
- TEST_EQ(mock_tcpci_wait_for_transmit(
- TCPC_TX_SOP, PD_CTRL_ACCEPT, 0), EC_SUCCESS, "%d");
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_ACCEPT, 0),
+ EC_SUCCESS, "%d");
mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
/*
* f) The Tester waits for PS_RDY for tPSSourceOn max.
*/
- TEST_EQ(mock_tcpci_wait_for_transmit(
- TCPC_TX_SOP, PD_CTRL_PS_RDY, 0), EC_SUCCESS, "%d");
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_PS_RDY, 0),
+ EC_SUCCESS, "%d");
mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
/*
@@ -201,8 +202,8 @@ __maybe_unused static int test_connect_as_pd3_source(void)
* the test fails. During this period, the Tester replies any message
* sent from the UUT with a proper response.
*/
- TEST_EQ(mock_tcpci_wait_for_transmit(
- TCPC_TX_SOP_PRIME, 0, PD_DATA_VENDOR_DEF), EC_SUCCESS, "%d");
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP_PRIME, 0, PD_DATA_VENDOR_DEF),
+ EC_SUCCESS, "%d");
mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
task_wait_event(10 * MSEC);
mock_tcpci_receive(PD_MSG_SOP_PRIME,
@@ -212,8 +213,8 @@ __maybe_unused static int test_connect_as_pd3_source(void)
NULL);
mock_set_alert(TCPC_REG_ALERT_RX_STATUS);
- TEST_EQ(mock_tcpci_wait_for_transmit(
- TCPC_TX_SOP, 0, PD_DATA_VENDOR_DEF), EC_SUCCESS, "%d");
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_VENDOR_DEF),
+ EC_SUCCESS, "%d");
mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
task_wait_event(10 * MSEC);
mock_tcpci_receive(PD_MSG_SOP,
@@ -232,6 +233,77 @@ __maybe_unused static int test_connect_as_pd3_source(void)
return EC_SUCCESS;
}
+__maybe_unused static int test_retry_count_sop(void)
+{
+ /* DRP auto-toggling with AP in S0, source enabled. */
+ TEST_EQ(test_startup_and_resume(), EC_SUCCESS, "%d");
+
+ /*
+ * The test starts in a disconnected state.
+ */
+ mock_tcpci_set_reg(TCPC_REG_EXT_STATUS, TCPC_REG_EXT_STATUS_SAFE0V);
+ mock_set_alert(TCPC_REG_ALERT_EXT_STATUS);
+ task_wait_event(10 * SECOND);
+
+ /*
+ * The Tester applies Rd and waits for Vbus for tNoResponse max.
+ */
+ mock_set_cc(MOCK_CC_WE_ARE_SRC, MOCK_CC_SRC_OPEN, MOCK_CC_SRC_RD);
+ mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
+
+ /*
+ * The Tester waits for Source_Capabilities for tNoResponse max.
+ *
+ * Source Caps is SOP message which should be retried at TCPC layer
+ */
+ TEST_EQ(verify_tcpci_tx_retry_count(CONFIG_PD_RETRY_COUNT), EC_SUCCESS,
+ "%d");
+ return EC_SUCCESS;
+}
+
+__maybe_unused static int test_retry_count_hard_reset(void)
+{
+ /* DRP auto-toggling with AP in S0, source enabled. */
+ TEST_EQ(test_startup_and_resume(), EC_SUCCESS, "%d");
+
+ /*
+ * The test starts in a disconnected state.
+ */
+ mock_tcpci_set_reg(TCPC_REG_EXT_STATUS, TCPC_REG_EXT_STATUS_SAFE0V);
+ mock_set_alert(TCPC_REG_ALERT_EXT_STATUS);
+ task_wait_event(10 * SECOND);
+
+ /*
+ * The Tester applies Rd and waits for Vbus for tNoResponse max.
+ */
+ mock_set_cc(MOCK_CC_WE_ARE_SRC, MOCK_CC_SRC_OPEN, MOCK_CC_SRC_RD);
+ mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
+
+ /*
+ * The Tester waits for Source_Capabilities for tNoResponse max.
+ */
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_SOURCE_CAP),
+ EC_SUCCESS, "%d");
+ /*
+ * The Tester replies GoodCrc on reception of the Source_Capabilities.
+ */
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+
+ /*
+ * Now that PRL is running since we are connected, we can send a hard
+ * reset.
+ */
+
+ /* Request that DUT send hard reset */
+ prl_execute_hard_reset(PORT0);
+
+ /* The retry count for hard resets should be 0 */
+ TEST_EQ(verify_tcpci_tx_retry_count(0), EC_SUCCESS, "%d");
+
+ return EC_SUCCESS;
+}
+
void before_test(void)
{
mock_usb_mux_reset();
@@ -249,6 +321,8 @@ void run_test(int argc, char **argv)
RUN_TEST(test_connect_as_nonpd_sink);
RUN_TEST(test_startup_and_resume);
RUN_TEST(test_connect_as_pd3_source);
+ RUN_TEST(test_retry_count_sop);
+ RUN_TEST(test_retry_count_hard_reset);
test_print_result();
}