diff options
author | Diana Z <dzigterman@chromium.org> | 2022-04-27 14:44:08 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-04 16:42:39 +0000 |
commit | 8a50ae7b4008c6e78fedc238999609092036aa2f (patch) | |
tree | 63cb49fe472f429813046b8e4475a71353691abd | |
parent | 8c881cee916331afa1e2a3bc804f8346bacc72c9 (diff) | |
download | chrome-ec-8a50ae7b4008c6e78fedc238999609092036aa2f.tar.gz |
PRL test: Correct received data and power roles
Simulated partner messages should contain the opposite data and power
roles to our own unless they're specifically testing error handling for
data role mismatch.
BRANCH=None
BUG=b:155418161
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I38879eb5e2caf9833d6efa8cd0d36f9363a80fe5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3612213
Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r-- | test/usb_prl.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test/usb_prl.c b/test/usb_prl.c index 061bb1ad3c..3ef3450649 100644 --- a/test/usb_prl.c +++ b/test/usb_prl.c @@ -32,6 +32,18 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; +static enum pd_power_role get_partner_power_role(int port) +{ + return pd_get_power_role(port) == PD_ROLE_SINK ? + PD_ROLE_SOURCE : PD_ROLE_SINK; +} + +static enum pd_data_role get_partner_data_role(int port) +{ + return pd_get_data_role(port) == PD_ROLE_UFP ? + PD_ROLE_DFP : PD_ROLE_UFP; +} + static void enable_prl(int port, int en) { tcpm_set_rx_enable(port, en); @@ -47,8 +59,8 @@ static int test_receive_control_msg(void) { int port = PORT0; uint16_t header = PD_HEADER(PD_CTRL_DR_SWAP, - pd_get_power_role(port), - pd_get_data_role(port), + get_partner_power_role(port), + get_partner_data_role(port), mock_tc_port[port].msg_rx_id, 0, mock_tc_port[port].rev, 0); @@ -99,8 +111,8 @@ static int test_discard_queued_tx_when_rx_happens(void) { int port = PORT0; uint16_t header = PD_HEADER(PD_CTRL_DR_SWAP, - pd_get_power_role(port), - pd_get_data_role(port), + get_partner_power_role(port), + get_partner_data_role(port), mock_tc_port[port].msg_rx_id, 0, mock_tc_port[port].rev, 0); uint8_t *buf = tx_emsg[port].buf; |