summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Hurst <shurst@google.com>2020-03-13 11:24:05 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-21 03:00:54 +0000
commit777f57c6f406292435dd7f836914e3f7ad435ed5 (patch)
tree2856ff1f7db9280564ecfaa6d119bc207bde3637
parentd68abb5d52c3474aa247a47c23375354d08be600 (diff)
downloadchrome-ec-777f57c6f406292435dd7f836914e3f7ad435ed5.tar.gz
TCPMv2: Split PD message buffers into separate TX/RX buffers
Use separate buffers for transmit and reception of PD messages. This prevents the potential corruption of PD messages waiting to be transmitted when an unexpected PD message is received BUG=b:150637227 BUG=b:149662829 BRANCH=none TEST=make -j buildall Manual tests: Tested hatch device and powered dock. Used total phase to verify that transmitted messages were not corrupted by unexpected message reception. Change-Id: I12df471f59fb7510e642bb92b769ccbddd79c84f Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2103253 Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/usb_pe_ctvpd_sm.c8
-rw-r--r--common/usbc/usb_pe_drp_sm.c210
-rw-r--r--common/usbc/usb_prl_sm.c85
-rw-r--r--include/usb_emsg.h4
-rw-r--r--test/fake_prl.c3
-rw-r--r--test/usb_pe_drp.c4
-rw-r--r--test/usb_prl.c46
7 files changed, 185 insertions, 175 deletions
diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c
index 3e78ebcbb5..8f3233e0d7 100644
--- a/common/usbc/usb_pe_ctvpd_sm.c
+++ b/common/usbc/usb_pe_ctvpd_sm.c
@@ -115,9 +115,9 @@ void pe_message_sent(int port)
static void pe_request_run(const int port)
{
- uint32_t *payload = (uint32_t *)emsg[port].buf;
- uint32_t header = emsg[port].header;
- uint32_t vdo = payload[0];
+ uint32_t *payload = (uint32_t *)tx_emsg[port].buf;
+ uint32_t header = rx_emsg[port].header;
+ uint32_t vdo = *(uint32_t *)rx_emsg[port].buf;
if (pe[port].flags & PE_FLAGS_MSG_RECEIVED) {
pe[port].flags &= ~PE_FLAGS_MSG_RECEIVED;
@@ -187,7 +187,7 @@ static void pe_request_run(const int port)
);
/* 20 bytes, 5 data objects */
- emsg[port].len = 20;
+ tx_emsg[port].len = 20;
/* Set to highest revision supported by both ports. */
prl_set_rev(port, TCPC_TX_SOP_PRIME,
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index c058c39c99..63bd28a802 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -968,8 +968,8 @@ static void send_source_cap(int port)
prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT);
}
- emsg[port].len = src_pdo_cnt * 4;
- memcpy(emsg[port].buf, (uint8_t *)src_pdo, emsg[port].len);
+ tx_emsg[port].len = src_pdo_cnt * 4;
+ memcpy(tx_emsg[port].buf, (uint8_t *)src_pdo, tx_emsg[port].len);
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_SOURCE_CAP);
}
@@ -996,9 +996,9 @@ static void pe_send_request_msg(int port)
pe[port].curr_limit = curr_limit;
pe[port].supply_voltage = supply_voltage;
- emsg[port].len = 4;
+ tx_emsg[port].len = 4;
- memcpy(emsg[port].buf, (uint8_t *)&rdo, emsg[port].len);
+ memcpy(tx_emsg[port].buf, (uint8_t *)&rdo, tx_emsg[port].len);
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_REQUEST);
}
@@ -1369,15 +1369,16 @@ static void pe_src_send_capabilities_run(int port)
/*
* Request Message Received?
*/
- if (PD_HEADER_CNT(emsg[port].header) > 0 &&
- PD_HEADER_TYPE(emsg[port].header) == PD_DATA_REQUEST) {
+ if (PD_HEADER_CNT(rx_emsg[port].header) > 0 &&
+ PD_HEADER_TYPE(rx_emsg[port].header) ==
+ PD_DATA_REQUEST) {
/*
* Set to highest revision supported by both
* ports.
*/
prl_set_rev(port, TCPC_TX_SOP,
- MIN(PD_REVISION, PD_HEADER_REV(emsg[port].header)));
+ MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header)));
/*
* If port partner runs PD 2.0, cable communication must
@@ -1470,7 +1471,7 @@ static void pe_src_negotiate_capability_entry(int port)
print_current_state(port);
/* Get message payload */
- payload = *(uint32_t *)(&emsg[port].buf);
+ payload = *(uint32_t *)(&rx_emsg[port].buf);
/*
* Evaluate the Request from the Attached Sink
@@ -1629,10 +1630,10 @@ static void pe_src_ready_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
- payload = *(uint32_t *)emsg[port].buf;
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
+ payload = *(uint32_t *)rx_emsg[port].buf;
/* Extended Message Requests */
if (ext > 0) {
@@ -1658,7 +1659,7 @@ static void pe_src_ready_run(int port)
case PD_DATA_SINK_CAP:
break;
case PD_DATA_VENDOR_DEF:
- if (PD_HEADER_TYPE(emsg[port].header) ==
+ if (PD_HEADER_TYPE(rx_emsg[port].header) ==
PD_DATA_VENDOR_DEF) {
if (PD_VDO_SVDM(payload)) {
set_state_pe(port,
@@ -2056,9 +2057,9 @@ static void pe_snk_wait_for_capabilities_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt > 0) && (type == PD_DATA_SOURCE_CAP)) {
set_state_pe(port, PE_SNK_EVALUATE_CAPABILITY);
@@ -2078,8 +2079,8 @@ static void pe_snk_wait_for_capabilities_run(int port)
*/
static void pe_snk_evaluate_capability_entry(int port)
{
- uint32_t *pdo = (uint32_t *)emsg[port].buf;
- uint32_t num = emsg[port].len >> 2;
+ uint32_t *pdo = (uint32_t *)rx_emsg[port].buf;
+ uint32_t num = rx_emsg[port].len >> 2;
int i;
print_current_state(port);
@@ -2089,7 +2090,7 @@ static void pe_snk_evaluate_capability_entry(int port)
/* Set to highest revision supported by both ports. */
prl_set_rev(port, TCPC_TX_SOP,
- MIN(PD_REVISION, PD_HEADER_REV(emsg[port].header)));
+ MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header)));
/*
* If port partner runs PD 2.0, cable communication must
@@ -2148,8 +2149,8 @@ static void pe_snk_select_capability_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
/*
* Transition to the PE_SNK_Transition_Sink state when:
@@ -2261,8 +2262,8 @@ static void pe_snk_transition_sink_run(int port)
/*
* PS_RDY message received
*/
- if ((PD_HEADER_CNT(emsg[port].header) == 0) &&
- (PD_HEADER_TYPE(emsg[port].header) ==
+ if ((PD_HEADER_CNT(rx_emsg[port].header) == 0) &&
+ (PD_HEADER_TYPE(rx_emsg[port].header) ==
PD_CTRL_PS_RDY)) {
/*
* Set first message flag to trigger a wait and add
@@ -2365,10 +2366,10 @@ static void pe_snk_ready_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
- payload = *(uint32_t *)emsg[port].buf;
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
+ payload = *(uint32_t *)rx_emsg[port].buf;
/* Extended Message Request */
if (ext > 0) {
@@ -2393,7 +2394,7 @@ static void pe_snk_ready_run(int port)
PE_SNK_EVALUATE_CAPABILITY);
break;
case PD_DATA_VENDOR_DEF:
- if (PD_HEADER_TYPE(emsg[port].header) ==
+ if (PD_HEADER_TYPE(rx_emsg[port].header) ==
PD_DATA_VENDOR_DEF) {
if (PD_VDO_SVDM(payload))
set_state_pe(port,
@@ -2626,7 +2627,7 @@ static void pe_snk_get_source_cap_entry(int port)
print_current_state(port);
/* Send a Get_Source_Cap Message */
- emsg[port].len = 0;
+ tx_emsg[port].len = 0;
prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_GET_SOURCE_CAP);
}
@@ -2698,9 +2699,9 @@ static void pe_send_soft_reset_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0) && (type == PD_CTRL_ACCEPT)) {
if (pe[port].power_role == PD_ROLE_SINK)
@@ -2799,8 +2800,8 @@ static void pe_src_ping_run(int port)
*/
static void pe_give_battery_cap_entry(int port)
{
- uint32_t payload = *(uint32_t *)(&emsg[port].buf);
- uint16_t *msg = (uint16_t *)emsg[port].buf;
+ uint32_t payload = *(uint32_t *)(&rx_emsg[port].buf);
+ uint16_t *msg = (uint16_t *)tx_emsg[port].buf;
if (!IS_ENABLED(CONFIG_BATTERY))
return;
@@ -2872,7 +2873,7 @@ static void pe_give_battery_cap_entry(int port)
}
/* Extended Battery Cap data is 9 bytes */
- emsg[port].len = 9;
+ tx_emsg[port].len = 9;
prl_send_ext_data_msg(port, TCPC_TX_SOP, PD_EXT_BATTERY_CAP);
}
@@ -2893,8 +2894,8 @@ static void pe_give_battery_cap_run(int port)
*/
static void pe_give_battery_status_entry(int port)
{
- uint32_t payload = *(uint32_t *)(&emsg[port].buf);
- uint32_t *msg = (uint32_t *)emsg[port].buf;
+ uint32_t payload = *(uint32_t *)(&rx_emsg[port].buf);
+ uint32_t *msg = (uint32_t *)tx_emsg[port].buf;
if (!IS_ENABLED(CONFIG_BATTERY))
return;
@@ -2949,7 +2950,7 @@ static void pe_give_battery_status_entry(int port)
}
/* Battery Status data is 4 bytes */
- emsg[port].len = 4;
+ tx_emsg[port].len = 4;
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_BATTERY_STATUS);
}
@@ -3103,9 +3104,9 @@ static void pe_drs_send_swap_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0)) {
if (type == PD_CTRL_ACCEPT) {
@@ -3237,9 +3238,9 @@ static void pe_prs_src_snk_wait_source_on_run(int port)
PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0) && (type == PD_CTRL_PS_RDY)) {
tc_pr_swap_complete(port);
@@ -3305,9 +3306,9 @@ static void pe_prs_src_snk_send_swap_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0)) {
if (type == PD_CTRL_ACCEPT)
@@ -3399,9 +3400,9 @@ static void pe_prs_snk_src_transition_to_off_run(int port)
else if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0) && (type == PD_CTRL_PS_RDY)) {
/*
@@ -3554,9 +3555,9 @@ static void pe_prs_snk_src_send_swap_run(int port)
else if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((ext == 0) && (cnt == 0)) {
if (type == PD_CTRL_ACCEPT)
@@ -3627,7 +3628,7 @@ static void pe_prs_frs_shared_exit(int port)
*/
static void pe_bist_tx_entry(int port)
{
- uint32_t *payload = (uint32_t *)emsg[port].buf;
+ uint32_t *payload = (uint32_t *)rx_emsg[port].buf;
uint8_t mode = BIST_MODE(payload[0]);
print_current_state(port);
@@ -3684,8 +3685,8 @@ static void pe_bist_rx_entry(int port)
print_current_state(port);
- emsg[port].len = sizeof(bdo);
- memcpy(emsg[port].buf, (uint8_t *)&bdo, emsg[port].len);
+ tx_emsg[port].len = sizeof(bdo);
+ memcpy(tx_emsg[port].buf, (uint8_t *)&bdo, tx_emsg[port].len);
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_BIST);
/* Delay at least enough for partner to finish BIST */
@@ -3712,8 +3713,8 @@ static void pe_snk_give_sink_cap_entry(int port)
print_current_state(port);
/* Send a Sink_Capabilities Message */
- emsg[port].len = pd_snk_pdo_cnt * 4;
- memcpy(emsg[port].buf, (uint8_t *)pd_snk_pdo, emsg[port].len);
+ tx_emsg[port].len = pd_snk_pdo_cnt * 4;
+ memcpy(tx_emsg[port].buf, (uint8_t *)pd_snk_pdo, tx_emsg[port].len);
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_SINK_CAP);
}
@@ -3748,9 +3749,9 @@ static void pe_wait_for_error_recovery_run(int port)
static void pe_handle_custom_vdm_request_entry(int port)
{
/* Get the message */
- uint32_t *payload = (uint32_t *)emsg[port].buf;
- int cnt = PD_HEADER_CNT(emsg[port].header);
- int sop = PD_HEADER_GET_SOP(emsg[port].header);
+ uint32_t *payload = (uint32_t *)rx_emsg[port].buf;
+ int cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ int sop = PD_HEADER_GET_SOP(rx_emsg[port].header);
int rlen = 0;
uint32_t *rdata;
@@ -3761,8 +3762,8 @@ static void pe_handle_custom_vdm_request_entry(int port)
rlen = pd_custom_vdm(port, cnt, payload, &rdata);
if (rlen > 0) {
- emsg[port].len = rlen * 4;
- memcpy(emsg[port].buf, (uint8_t *)rdata, emsg[port].len);
+ tx_emsg[port].len = rlen * 4;
+ memcpy(tx_emsg[port].buf, (uint8_t *)rdata, tx_emsg[port].len);
prl_send_data_msg(port, sop, PD_DATA_VENDOR_DEF);
}
}
@@ -3817,7 +3818,7 @@ static void pe_do_port_discovery_entry(int port)
static void pe_do_port_discovery_run(int port)
{
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
- uint32_t *payload = (uint32_t *)emsg[port].buf;
+ uint32_t *payload = (uint32_t *)rx_emsg[port].buf;
struct svdm_amode_data *modep =
pd_get_amode_data(port, PD_VDO_VID(payload[0]));
int ret = 0;
@@ -3956,13 +3957,13 @@ static void pe_vdm_send_request_exit(int port)
*/
static void pe_vdm_identity_request_cbl_entry(int port)
{
- uint32_t *msg = (uint32_t *)emsg[port].buf;
+ uint32_t *msg = (uint32_t *)tx_emsg[port].buf;
print_current_state(port);
msg[0] = VDO(USB_SID_PD, 1, VDO_SVDM_VERS(VDM_VER20)
| DISCOVER_IDENTITY);
- emsg[port].len = sizeof(uint32_t);
+ tx_emsg[port].len = sizeof(uint32_t);
prl_send_data_msg(port, TCPC_TX_SOP_PRIME, PD_DATA_VENDOR_DEF);
@@ -3982,11 +3983,11 @@ static void pe_vdm_identity_request_cbl_run(int port)
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
/* Retrieve the message information */
- payload = (uint32_t *)emsg[port].buf;
- sop = PD_HEADER_GET_SOP(emsg[port].header);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ payload = (uint32_t *)rx_emsg[port].buf;
+ sop = PD_HEADER_GET_SOP(rx_emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if (sop == TCPC_TX_SOP_PRIME && type == PD_DATA_VENDOR_DEF &&
cnt > 0 && ext == 0) {
@@ -4001,7 +4002,7 @@ static void pe_vdm_identity_request_cbl_run(int port)
* PE_INIT_PORT_VDM_Identity_ACKed embedded here
*/
pe[port].cable.rev =
- PD_HEADER_REV(emsg[port].header);
+ PD_HEADER_REV(rx_emsg[port].header);
pe[port].cable.type = PD_IDH_PTYPE(payload[1]);
pe[port].cable.attr.raw_value = payload[3];
if (cnt > 4)
@@ -4045,7 +4046,7 @@ static void pe_vdm_identity_request_cbl_run(int port)
pe[port].cable.discovery = PD_DISC_FAIL;
CPRINTS("C%d: Unexpected cable response: "
"0x%04x 0x%04x", port,
- emsg[port].header, payload[0]);
+ rx_emsg[port].header, payload[0]);
}
/* Return to calling state (SRC_DISCOVERY, or ready) */
set_state_pe(port, get_last_state_pe(port));
@@ -4127,11 +4128,11 @@ static void pe_vdm_request_entry(int port)
/* Copy Vendor Data Objects (VDOs) into message buffer */
if (pe[port].vdm_cnt > 0) {
/* Copy data after header */
- memcpy(&emsg[port].buf,
+ memcpy(&tx_emsg[port].buf,
(uint8_t *)pe[port].vdm_data,
pe[port].vdm_cnt * 4);
/* Update len with the number of VDO bytes */
- emsg[port].len = pe[port].vdm_cnt * 4;
+ tx_emsg[port].len = pe[port].vdm_cnt * 4;
}
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_VENDOR_DEF);
@@ -4162,11 +4163,11 @@ static void pe_vdm_request_run(int port)
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
/* Get the message */
- payload = (uint32_t *)emsg[port].buf;
- sop = PD_HEADER_GET_SOP(emsg[port].header);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
+ payload = (uint32_t *)rx_emsg[port].buf;
+ sop = PD_HEADER_GET_SOP(rx_emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
if ((sop == TCPC_TX_SOP || sop == TCPC_TX_SOP_PRIME) &&
type == PD_DATA_VENDOR_DEF && cnt > 0 &&
@@ -4261,9 +4262,9 @@ static void pe_vdm_acked_entry(int port)
print_current_state(port);
/* Get the message */
- payload = (uint32_t *)emsg[port].buf;
+ payload = (uint32_t *)rx_emsg[port].buf;
vdo_cmd = PD_VDO_CMD(payload[0]);
- sop = PD_HEADER_GET_SOP(emsg[port].header);
+ sop = PD_HEADER_GET_SOP(rx_emsg[port].header);
if (sop == TCPC_TX_SOP) {
/*
@@ -4271,7 +4272,7 @@ static void pe_vdm_acked_entry(int port)
*/
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
- int cnt = PD_HEADER_CNT(emsg[port].header);
+ int cnt = PD_HEADER_CNT(rx_emsg[port].header);
struct svdm_amode_data *modep;
modep = pd_get_amode_data(port, PD_VDO_VID(payload[0]));
@@ -4335,7 +4336,8 @@ static void pe_vdm_acked_entry(int port)
static void pe_vdm_response_entry(int port)
{
int ret = 0;
- uint32_t *payload;
+ uint32_t *rx_payload;
+ uint32_t *tx_payload;
uint8_t vdo_cmd;
int cmd_type;
svdm_rsp_func func = NULL;
@@ -4346,10 +4348,10 @@ static void pe_vdm_response_entry(int port)
PE_SET_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS);
/* Get the message */
- payload = (uint32_t *)emsg[port].buf;
- vdo_cmd = PD_VDO_CMD(payload[0]);
- cmd_type = PD_VDO_CMDT(payload[0]);
- payload[0] &= ~VDO_CMDT_MASK;
+ rx_payload = (uint32_t *)rx_emsg[port].buf;
+ vdo_cmd = PD_VDO_CMD(rx_payload[0]);
+ cmd_type = PD_VDO_CMDT(rx_payload[0]);
+ rx_payload[0] &= ~VDO_CMDT_MASK;
if (cmd_type != CMDT_INIT) {
CPRINTF("ERR:CMDT:%d\n", vdo_cmd);
@@ -4389,7 +4391,7 @@ static void pe_vdm_response_entry(int port)
* attention is only SVDM with no response
* (just goodCRC) return zero here.
*/
- dfp_consume_attention(port, payload);
+ dfp_consume_attention(port, rx_payload);
if (pe[port].power_role == PD_ROLE_SOURCE)
set_state_pe(port, PE_SRC_READY);
else
@@ -4400,11 +4402,13 @@ static void pe_vdm_response_entry(int port)
CPRINTF("VDO ERR:CMD:%d\n", vdo_cmd);
}
+ tx_payload = (uint32_t *)tx_emsg[port].buf;
+
if (func) {
- ret = func(port, payload);
+ ret = func(port, rx_payload);
if (ret)
/* ACK */
- payload[0] = VDO(
+ tx_payload[0] = VDO(
USB_VID_GOOGLE,
1, /* Structured VDM */
VDO_SVDM_VERS(pd_get_vdo_ver(port)) |
@@ -4412,7 +4416,7 @@ static void pe_vdm_response_entry(int port)
vdo_cmd);
else if (!ret)
/* NAK */
- payload[0] = VDO(
+ tx_payload[0] = VDO(
USB_VID_GOOGLE,
1, /* Structured VDM */
VDO_SVDM_VERS(pd_get_vdo_ver(port)) |
@@ -4420,7 +4424,7 @@ static void pe_vdm_response_entry(int port)
vdo_cmd);
else
/* BUSY */
- payload[0] = VDO(
+ tx_payload[0] = VDO(
USB_VID_GOOGLE,
1, /* Structured VDM */
VDO_SVDM_VERS(pd_get_vdo_ver(port)) |
@@ -4431,7 +4435,7 @@ static void pe_vdm_response_entry(int port)
ret = 4;
} else {
/* not supported : NACK it */
- payload[0] = VDO(
+ tx_payload[0] = VDO(
USB_VID_GOOGLE,
1, /* Structured VDM */
VDO_SVDM_VERS(pd_get_vdo_ver(port)) |
@@ -4441,7 +4445,7 @@ static void pe_vdm_response_entry(int port)
}
/* Send ACK, NAK, or BUSY */
- emsg[port].len = ret;
+ tx_emsg[port].len = ret;
prl_send_data_msg(port, TCPC_TX_SOP, PD_DATA_VENDOR_DEF);
}
@@ -4566,8 +4570,8 @@ static void pe_vcs_send_swap_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
/* Only look at control messages */
if (cnt == 0) {
@@ -4638,8 +4642,8 @@ static void pe_vcs_wait_for_vconn_swap_run(int port)
/*
* PS_RDY message received
*/
- if ((PD_HEADER_CNT(emsg[port].header) == 0) &&
- (PD_HEADER_TYPE(emsg[port].header) ==
+ if ((PD_HEADER_CNT(rx_emsg[port].header) == 0) &&
+ (PD_HEADER_TYPE(rx_emsg[port].header) ==
PD_CTRL_PS_RDY)) {
set_state_pe(port, PE_VCS_TURN_OFF_VCONN_SWAP);
return;
@@ -4842,10 +4846,10 @@ static void pe_dr_snk_get_sink_cap_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) {
PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED);
- type = PD_HEADER_TYPE(emsg[port].header);
- cnt = PD_HEADER_CNT(emsg[port].header);
- ext = PD_HEADER_EXT(emsg[port].header);
- payload = *(uint32_t *)emsg[port].buf;
+ type = PD_HEADER_TYPE(rx_emsg[port].header);
+ cnt = PD_HEADER_CNT(rx_emsg[port].header);
+ ext = PD_HEADER_EXT(rx_emsg[port].header);
+ payload = *(uint32_t *)rx_emsg[port].buf;
if ((ext == 0) && (cnt == 0)) {
if (type == PD_CTRL_ACCEPT) {
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index 7d83b51c0a..5805d1278e 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -208,14 +208,16 @@ static struct pd_message {
/* Number of 32-bit objects in chk_buf */
uint16_t data_objs;
/* temp chunk buffer */
- uint32_t chk_buf[7];
+ uint32_t tx_chk_buf[7];
+ uint32_t rx_chk_buf[7];
uint32_t chunk_number_expected;
uint32_t num_bytes_received;
uint32_t chunk_number_to_send;
uint32_t send_offset;
} pdmsg[CONFIG_USB_PD_PORT_MAX_COUNT];
-struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
+struct extended_msg rx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
+struct extended_msg tx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
/* Common Protocol Layer Message Transmission */
static void prl_tx_construct_message(int port);
@@ -373,7 +375,7 @@ void prl_send_ctrl_msg(int port,
pdmsg[port].xmit_type = type;
pdmsg[port].msg_type = msg;
pdmsg[port].ext = 0;
- emsg[port].len = 0;
+ tx_emsg[port].len = 0;
TCH_SET_FLAG(port, PRL_FLAGS_MSG_XMIT);
task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_SM, 0);
@@ -541,7 +543,7 @@ static void prl_tx_wait_for_message_request_run(const int port)
* Soft Reset Message Message pending
*/
if ((pdmsg[port].msg_type == PD_CTRL_SOFT_RESET) &&
- (emsg[port].len == 0)) {
+ (tx_emsg[port].len == 0)) {
set_state_prl_tx(port, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
}
/*
@@ -664,7 +666,7 @@ static void prl_tx_construct_message(const int port)
/* Pass message to PHY Layer */
tcpm_transmit(port, pdmsg[port].xmit_type, header,
- pdmsg[port].chk_buf);
+ pdmsg[port].tx_chk_buf);
}
/*
@@ -701,7 +703,7 @@ static void prl_tx_wait_for_phy_response_run(const int port)
if (prl_tx[port].retry_counter > N_RETRY_COUNT ||
(pdmsg[port].ext &&
PD_EXT_HEADER_DATA_SIZE(GET_EXT_HEADER(
- pdmsg[port].chk_buf[0]) > 26))) {
+ pdmsg[port].tx_chk_buf[0]) > 26))) {
/*
* NOTE: PRL_Tx_Transmission_Error State embedded
@@ -764,7 +766,7 @@ static void prl_tx_src_pending_run(const int port)
* Soft Reset Message pending &
* SinkTxTimer timeout
*/
- if ((emsg[port].len == 0) &&
+ if ((tx_emsg[port].len == 0) &&
(pdmsg[port].msg_type == PD_CTRL_SOFT_RESET)) {
set_state_prl_tx(port, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
}
@@ -794,7 +796,7 @@ static void prl_tx_snk_pending_run(const int port)
* Rp = SinkTxOk
*/
if ((pdmsg[port].msg_type == PD_CTRL_SOFT_RESET) &&
- (emsg[port].len == 0)) {
+ (tx_emsg[port].len == 0)) {
set_state_prl_tx(port, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
}
/*
@@ -933,14 +935,15 @@ static void prl_hr_wait_for_pe_hard_reset_complete_exit(const int port)
static void copy_chunk_to_ext(int port)
{
/* Calculate number of bytes */
- pdmsg[port].num_bytes_received = (PD_HEADER_CNT(emsg[port].header) * 4);
+ pdmsg[port].num_bytes_received =
+ (PD_HEADER_CNT(rx_emsg[port].header) * 4);
/* Copy chunk into extended message */
- memcpy((uint8_t *)emsg[port].buf, (uint8_t *)pdmsg[port].chk_buf,
+ memcpy((uint8_t *)rx_emsg[port].buf, (uint8_t *)pdmsg[port].rx_chk_buf,
pdmsg[port].num_bytes_received);
/* Set extended message length */
- emsg[port].len = pdmsg[port].num_bytes_received;
+ rx_emsg[port].len = pdmsg[port].num_bytes_received;
}
/*
@@ -967,8 +970,9 @@ static void rch_wait_for_message_from_protocol_layer_run(const int port)
* this an extended message?
*/
if (prl_get_rev(port, pdmsg[port].xmit_type) == PD_REV30 &&
- PD_HEADER_EXT(emsg[port].header)) {
- uint16_t exhdr = GET_EXT_HEADER(*pdmsg[port].chk_buf);
+ PD_HEADER_EXT(rx_emsg[port].header)) {
+ uint16_t exhdr =
+ GET_EXT_HEADER(*pdmsg[port].rx_chk_buf);
uint8_t chunked = PD_EXT_HEADER_CHUNKED(exhdr);
/*
@@ -988,7 +992,7 @@ static void rch_wait_for_message_from_protocol_layer_run(const int port)
pdmsg[port].chunk_number_expected = 0;
pdmsg[port].num_bytes_received = 0;
pdmsg[port].msg_type =
- PD_HEADER_TYPE(emsg[port].header);
+ PD_HEADER_TYPE(rx_emsg[port].header);
set_state_rch(port,
RCH_PROCESSING_EXTENDED_MESSAGE);
@@ -1013,7 +1017,7 @@ static void rch_wait_for_message_from_protocol_layer_run(const int port)
/*
* Received Non-Extended Message
*/
- else if (!PD_HEADER_EXT(emsg[port].header)) {
+ else if (!PD_HEADER_EXT(rx_emsg[port].header)) {
/* Copy chunk to extended buffer */
copy_chunk_to_ext(port);
set_state_rch(port, RCH_PASS_UP_MESSAGE);
@@ -1043,7 +1047,7 @@ static void rch_pass_up_message_entry(const int port)
*/
static void rch_processing_extended_message_run(const int port)
{
- uint16_t exhdr = GET_EXT_HEADER(pdmsg[port].chk_buf[0]);
+ uint16_t exhdr = GET_EXT_HEADER(pdmsg[port].rx_chk_buf[0]);
uint8_t chunk_num = PD_EXT_HEADER_CHUNK_NUM(exhdr);
uint32_t data_size = PD_EXT_HEADER_DATA_SIZE(exhdr);
uint32_t byte_num;
@@ -1075,9 +1079,10 @@ static void rch_processing_extended_message_run(const int port)
/* Append data */
/* Add 2 to chk_buf to skip over extended message header */
- memcpy(((uint8_t *)emsg[port].buf +
+ memcpy(((uint8_t *)rx_emsg[port].buf +
pdmsg[port].num_bytes_received),
- (uint8_t *)pdmsg[port].chk_buf + 2, byte_num);
+ (uint8_t *)pdmsg[port].rx_chk_buf + 2,
+ byte_num);
/* increment chunk number expected */
pdmsg[port].chunk_number_expected++;
/* adjust num bytes received */
@@ -1085,7 +1090,7 @@ static void rch_processing_extended_message_run(const int port)
/* Was that the last chunk? */
if (pdmsg[port].num_bytes_received >= data_size) {
- emsg[port].len = pdmsg[port].num_bytes_received;
+ rx_emsg[port].len = pdmsg[port].num_bytes_received;
/* Pass Message to Policy Engine */
set_state_rch(port, RCH_PASS_UP_MESSAGE);
}
@@ -1111,7 +1116,7 @@ static void rch_requesting_chunk_entry(const int port)
* Send Chunk Request to Protocol Layer
* with chunk number = Chunk_Number_Expected
*/
- pdmsg[port].chk_buf[0] = PD_EXT_HEADER(
+ pdmsg[port].tx_chk_buf[0] = PD_EXT_HEADER(
pdmsg[port].chunk_number_expected,
1, /* Request Chunk */
0 /* Data Size */
@@ -1167,8 +1172,9 @@ static void rch_waiting_chunk_run(const int port)
* will be cleared in rch_report_error state.
*/
- if (PD_HEADER_EXT(emsg[port].header)) {
- uint16_t exhdr = GET_EXT_HEADER(pdmsg[port].chk_buf[0]);
+ if (PD_HEADER_EXT(rx_emsg[port].header)) {
+ uint16_t exhdr =
+ GET_EXT_HEADER(pdmsg[port].rx_chk_buf[0]);
/*
* Other Message Received from Protocol Layer
*/
@@ -1284,7 +1290,7 @@ static void tch_wait_for_message_request_from_pe_run(const int port)
*/
{
/* Make sure buffer doesn't overflow */
- if (emsg[port].len > BUFFER_SIZE) {
+ if (tx_emsg[port].len > BUFFER_SIZE) {
tch[port].error = ERR_TCH_XMIT;
set_state_tch(port, TCH_REPORT_ERROR);
return;
@@ -1292,11 +1298,11 @@ static void tch_wait_for_message_request_from_pe_run(const int port)
/* NOTE: TCH_Pass_Down_Message embedded here */
/* Copy message to chunked buffer */
- memset((uint8_t *)pdmsg[port].chk_buf,
+ memset((uint8_t *)pdmsg[port].tx_chk_buf,
0, BUFFER_SIZE);
- memcpy((uint8_t *)pdmsg[port].chk_buf,
- (uint8_t *)emsg[port].buf,
- emsg[port].len);
+ memcpy((uint8_t *)pdmsg[port].tx_chk_buf,
+ (uint8_t *)tx_emsg[port].buf,
+ tx_emsg[port].len);
/*
* Pad length to 4-byte boundary and
* convert to number of 32-bit objects.
@@ -1305,7 +1311,7 @@ static void tch_wait_for_message_request_from_pe_run(const int port)
* 2-bits.
*/
pdmsg[port].data_objs =
- (emsg[port].len + 3) >> 2;
+ (tx_emsg[port].len + 3) >> 2;
/* Pass Message to Protocol Layer */
PRL_TX_SET_FLAG(port, PRL_FLAGS_MSG_XMIT);
set_state_tch(port,
@@ -1357,9 +1363,9 @@ static void tch_construct_chunked_message_entry(const int port)
/* Prepare to copy chunk into chk_buf */
- ext_hdr = (uint16_t *)pdmsg[port].chk_buf;
- data = ((uint8_t *)pdmsg[port].chk_buf + 2);
- num = emsg[port].len - pdmsg[port].send_offset;
+ ext_hdr = (uint16_t *)pdmsg[port].tx_chk_buf;
+ data = ((uint8_t *)pdmsg[port].tx_chk_buf + 2);
+ num = tx_emsg[port].len - pdmsg[port].send_offset;
if (num > 26)
num = 26;
@@ -1367,11 +1373,11 @@ static void tch_construct_chunked_message_entry(const int port)
/* Set the chunks extended header */
*ext_hdr = PD_EXT_HEADER(pdmsg[port].chunk_number_to_send,
0, /* Chunk Request */
- emsg[port].len);
+ tx_emsg[port].len);
/* Copy the message chunk into chk_buf */
memset(data, 0, 28);
- memcpy(data, emsg[port].buf + pdmsg[port].send_offset, num);
+ memcpy(data, tx_emsg[port].buf + pdmsg[port].send_offset, num);
pdmsg[port].send_offset += num;
/*
@@ -1412,9 +1418,8 @@ static void tch_sending_chunked_message_run(const int port)
* Message Transmitted from Protocol Layer &
* Last Chunk
*/
- else if (emsg[port].len == pdmsg[port].send_offset) {
+ else if (tx_emsg[port].len == pdmsg[port].send_offset)
set_state_tch(port, TCH_MESSAGE_SENT);
- }
/*
* Any message received and not in state TCH_Wait_Chunk_Request
*/
@@ -1447,10 +1452,10 @@ static void tch_wait_chunk_request_run(const int port)
if (TCH_CHK_FLAG(port, PRL_FLAGS_MSG_RECEIVED)) {
TCH_CLR_FLAG(port, PRL_FLAGS_MSG_RECEIVED);
- if (PD_HEADER_EXT(emsg[port].header)) {
+ if (PD_HEADER_EXT(rx_emsg[port].header)) {
uint16_t exthdr;
- exthdr = GET_EXT_HEADER(pdmsg[port].chk_buf[0]);
+ exthdr = GET_EXT_HEADER(pdmsg[port].rx_chk_buf[0]);
if (PD_EXT_HEADER_REQ_CHUNK(exthdr)) {
/*
* Chunk Request Received &
@@ -1534,10 +1539,10 @@ static void prl_rx_wait_for_phy_message(const int port, int evt)
/* If we don't have any message, just stop processing now. */
if (!tcpm_has_pending_message(port) ||
- tcpm_dequeue_message(port, pdmsg[port].chk_buf, &header))
+ tcpm_dequeue_message(port, pdmsg[port].rx_chk_buf, &header))
return;
- emsg[port].header = header;
+ rx_emsg[port].header = header;
type = PD_HEADER_TYPE(header);
cnt = PD_HEADER_CNT(header);
msid = PD_HEADER_ID(header);
@@ -1598,7 +1603,7 @@ static void prl_rx_wait_for_phy_message(const int port, int evt)
*/
if (cnt == 0 && type == PD_CTRL_PING) {
/* NOTE: RTR_PING State embedded here. */
- emsg[port].len = 0;
+ rx_emsg[port].len = 0;
pe_message_received(port);
return;
}
diff --git a/include/usb_emsg.h b/include/usb_emsg.h
index 7847cf6967..759864b2dc 100644
--- a/include/usb_emsg.h
+++ b/include/usb_emsg.h
@@ -18,6 +18,6 @@ struct extended_msg {
};
/* Defined in usb_prl_sm.c */
-extern struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
-
+extern struct extended_msg tx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
+extern struct extended_msg rx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
#endif /* __CROS_EC_USB_EBUF_H */
diff --git a/test/fake_prl.c b/test/fake_prl.c
index 77e3331729..ac64594e61 100644
--- a/test/fake_prl.c
+++ b/test/fake_prl.c
@@ -8,7 +8,8 @@
#include "usb_emsg.h"
#include "usb_prl_sm.h"
-struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
+struct extended_msg rx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
+struct extended_msg tx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
void prl_end_ams(int port)
{}
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c
index 1efd2ea4ec..64699c4d02 100644
--- a/test/usb_pe_drp.c
+++ b/test/usb_pe_drp.c
@@ -85,7 +85,7 @@ static int test_pe_frs(void)
/*
* Accept the partners PS_RDY control message
*/
- emsg[PORT0].header = PD_HEADER(PD_CTRL_ACCEPT, 0, 0, 0, 0, 0, 0);
+ rx_emsg[PORT0].header = PD_HEADER(PD_CTRL_ACCEPT, 0, 0, 0, 0, 0, 0);
pe_set_flag(PORT0, PE_FLAGS_MSG_RECEIVED);
pe_run(PORT0, EVT_IGNORED, ENABLED);
TEST_ASSERT(!pe_chk_flag(PORT0, PE_FLAGS_MSG_RECEIVED));
@@ -95,7 +95,7 @@ static int test_pe_frs(void)
/*
* Send back our PS_RDY
*/
- emsg[PORT0].header = PD_HEADER(PD_CTRL_PS_RDY, 0, 0, 0, 0, 0, 0);
+ rx_emsg[PORT0].header = PD_HEADER(PD_CTRL_PS_RDY, 0, 0, 0, 0, 0, 0);
pe_set_flag(PORT0, PE_FLAGS_MSG_RECEIVED);
TEST_ASSERT(!tc_is_attached_src(PORT0));
pe_run(PORT0, EVT_IGNORED, ENABLED);
diff --git a/test/usb_prl.c b/test/usb_prl.c
index 198cfdd0f3..b99a6fdb51 100644
--- a/test/usb_prl.c
+++ b/test/usb_prl.c
@@ -235,19 +235,19 @@ static int verify_data_reception(int port, uint16_t header, int len)
if (!pd_port[port].mock_pe_message_received)
return 0;
- if (emsg[port].header != header)
+ if (rx_emsg[port].header != header)
return 0;
- if (emsg[port].len != cnt)
+ if (rx_emsg[port].len != cnt)
return 0;
for (i = 0; i < cnt; i++) {
if (i < len) {
- if (emsg[port].buf[i] !=
+ if (rx_emsg[port].buf[i] !=
*((unsigned char *)test_data + i))
return 0;
} else {
- if (emsg[port].buf[i] != 0)
+ if (rx_emsg[port].buf[i] != 0)
return 0;
}
}
@@ -275,13 +275,13 @@ static int verify_chunk_data_reception(int port, uint16_t header, int len)
return 0;
}
- if (emsg[port].len != len) {
- ccprintf("emsg len (%d) != 0\n", emsg[port].len);
+ if (rx_emsg[port].len != len) {
+ ccprintf("emsg len (%d) != 0\n", rx_emsg[port].len);
return 0;
}
for (i = 0; i < len; i++) {
- if (emsg[port].buf[i] != td[i]) {
+ if (rx_emsg[port].buf[i] != td[i]) {
ccprintf("emsg buf[%d] != td\n", i);
return 0;
}
@@ -302,9 +302,9 @@ static int simulate_receive_data(int port, enum pd_data_msg_type msg_type,
pd_port[port].mock_pe_error = -1;
pd_port[port].mock_pe_message_received = 0;
- emsg[port].header = 0;
- emsg[port].len = 0;
- memset(emsg[port].buf, 0, 260);
+ rx_emsg[port].header = 0;
+ rx_emsg[port].len = 0;
+ memset(rx_emsg[port].buf, 0, 260);
for (i = 0; i < 28; i++) {
if (i < len)
@@ -341,9 +341,9 @@ static int simulate_receive_extended_data(int port,
pd_port[port].mock_pe_error = -1;
pd_port[port].mock_pe_message_received = 0;
- emsg[port].header = 0;
- emsg[port].len = 0;
- memset(emsg[port].buf, 0, 260);
+ rx_emsg[port].header = 0;
+ rx_emsg[port].len = 0;
+ memset(rx_emsg[port].buf, 0, 260);
dsize = len;
for (j = 0; j < 10; j++) {
@@ -378,9 +378,9 @@ static int simulate_receive_extended_data(int port,
return 0;
}
- if (emsg[port].len != 0) {
+ if (rx_emsg[port].len != 0) {
ccprintf("emsg len (%d) != 0 iteration (%d)\n",
- emsg[port].len, j);
+ rx_emsg[port].len, j);
return 0;
}
@@ -547,7 +547,7 @@ static int simulate_send_data_msg_request_from_pe(int port,
enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg_type, int len)
{
int i;
- uint8_t *buf = emsg[port].buf;
+ uint8_t *buf = tx_emsg[port].buf;
uint8_t *td = (uint8_t *)test_data;
pd_port[port].mock_got_soft_reset = 0;
@@ -557,7 +557,7 @@ static int simulate_send_data_msg_request_from_pe(int port,
for (i = 0; i < len; i++)
buf[i] = td[i];
- emsg[port].len = len;
+ tx_emsg[port].len = len;
prl_send_data_msg(port, type, msg_type);
cycle_through_state_machine(port, 1, MSEC);
@@ -683,11 +683,11 @@ static int simulate_send_extended_data_msg(int port,
int len)
{
int i;
- uint8_t *buf = emsg[port].buf;
+ uint8_t *buf = tx_emsg[port].buf;
uint8_t *td = (uint8_t *)test_data;
memset(buf, 0, 260);
- emsg[port].len = len;
+ tx_emsg[port].len = len;
/* don't overflow buffer */
if (len > 260)
@@ -1097,8 +1097,8 @@ static int test_receive_soft_reset_msg(void)
TEST_ASSERT(pd_port[port].mock_got_soft_reset);
TEST_ASSERT(pd_port[port].mock_pe_error < 0);
TEST_ASSERT(pd_port[port].mock_pe_message_received);
- TEST_ASSERT(expected_header == emsg[port].header);
- TEST_ASSERT(emsg[port].len == 0);
+ TEST_ASSERT(expected_header == rx_emsg[port].header);
+ TEST_ASSERT(rx_emsg[port].len == 0);
enable_prl(port, 0);
@@ -1140,8 +1140,8 @@ static int test_receive_control_msg(void)
TEST_ASSERT(!pd_port[port].mock_got_soft_reset);
TEST_ASSERT(pd_port[port].mock_pe_error < 0);
TEST_ASSERT(pd_port[port].mock_pe_message_received);
- TEST_ASSERT(expected_header == emsg[port].header);
- TEST_ASSERT(emsg[port].len == 0);
+ TEST_ASSERT(expected_header == rx_emsg[port].header);
+ TEST_ASSERT(rx_emsg[port].len == 0);
enable_prl(port, 0);