summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-09-30 14:26:46 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-05 18:45:38 +0000
commit192450c603c19c87cf8107b7981aa027369a54a1 (patch)
treee664e273e5fff6db664cbb101d1fb3c481998cde
parent2be9a464452adaac4ebed940cf6b57e290f98e61 (diff)
downloadchrome-ec-192450c603c19c87cf8107b7981aa027369a54a1.tar.gz
TCPMv2: Remove PE_HANDLE_CUSTOM_VDM
Remove support for handling unstructured VDMs from the Policy Engine. TCPMv2 boards do not actually support any unstructured VDMs, so the code is unused. BUG=b:250015035 TEST=make buildall BRANCH=none LOW_COVERAGE_REASON=See b:251211412. This test covers source code paths. Covering identical sink paths would be "trivial" but too tedious to justify right now. Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I5b5c14c14cd637ee74e66564658e920969ae19df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3931178 Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c106
-rw-r--r--test/usb_pe.h1
2 files changed, 24 insertions, 83 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 0aa7e52daa..ab1312037c 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -258,7 +258,6 @@ enum usb_pe_state {
PE_INIT_VDM_MODES_REQUEST,
PE_VDM_REQUEST_DPM,
PE_VDM_RESPONSE,
- PE_HANDLE_CUSTOM_VDM_REQUEST,
PE_WAIT_FOR_ERROR_RECOVERY,
PE_BIST_TX,
PE_DEU_SEND_ENTER_USB,
@@ -391,7 +390,6 @@ __maybe_unused static __const_data const char *const pe_state_names[] = {
[PE_INIT_VDM_MODES_REQUEST] = "PE_INIT_VDM_Modes_Request",
[PE_VDM_REQUEST_DPM] = "PE_VDM_Request_DPM",
[PE_VDM_RESPONSE] = "PE_VDM_Response",
- [PE_HANDLE_CUSTOM_VDM_REQUEST] = "PE_Handle_Custom_Vdm_Request",
[PE_WAIT_FOR_ERROR_RECOVERY] = "PE_Wait_For_Error_Recovery",
[PE_BIST_TX] = "PE_Bist_TX",
[PE_DEU_SEND_ENTER_USB] = "PE_DEU_Send_Enter_USB",
@@ -2783,16 +2781,16 @@ static void pe_src_ready_run(int port)
case PD_DATA_SINK_CAP:
break;
case PD_DATA_VENDOR_DEF:
- if (PD_HEADER_TYPE(rx_emsg[port].header) ==
- PD_DATA_VENDOR_DEF) {
- if (PD_VDO_SVDM(*payload)) {
- set_state_pe(port,
- PE_VDM_RESPONSE);
- } else
- set_state_pe(
- port,
- PE_HANDLE_CUSTOM_VDM_REQUEST);
- }
+ if (PD_VDO_SVDM(*payload))
+ set_state_pe(port, PE_VDM_RESPONSE);
+ /* The TCPM does not support any unstructured
+ * VDMs. For PD 3.x, send Not Supported. For
+ * PD 2.0, ignore.
+ */
+ else if (prl_get_rev(port, TCPCI_MSG_SOP) >
+ PD_REV20)
+ set_state_pe(port,
+ PE_SEND_NOT_SUPPORTED);
return;
case PD_DATA_BIST:
set_state_pe(port, PE_BIST_TX);
@@ -3632,22 +3630,22 @@ static void pe_snk_ready_run(int port)
switch (type) {
case PD_DATA_SOURCE_CAP:
set_state_pe(port, PE_SNK_EVALUATE_CAPABILITY);
- break;
+ return;
case PD_DATA_VENDOR_DEF:
- if (PD_HEADER_TYPE(rx_emsg[port].header) ==
- PD_DATA_VENDOR_DEF) {
- if (PD_VDO_SVDM(*payload))
- set_state_pe(port,
- PE_VDM_RESPONSE);
- else
- set_state_pe(
- port,
- PE_HANDLE_CUSTOM_VDM_REQUEST);
- }
- break;
+ if (PD_VDO_SVDM(*payload))
+ set_state_pe(port, PE_VDM_RESPONSE);
+ /* The TCPM does not support any unstructured
+ * VDMs. For PD 3.x, send Not Supported. For
+ * PD 2.0, ignore.
+ */
+ else if (prl_get_rev(port, TCPCI_MSG_SOP) >
+ PD_REV20)
+ set_state_pe(port,
+ PE_SEND_NOT_SUPPORTED);
+ return;
case PD_DATA_BIST:
set_state_pe(port, PE_BIST_TX);
- break;
+ return;
#ifdef CONFIG_USB_PD_REV30
case PD_DATA_ALERT:
set_state_pe(port, PE_ALERT_RECEIVED);
@@ -3655,8 +3653,8 @@ static void pe_snk_ready_run(int port)
#endif /* CONFIG_USB_PD_REV30 */
default:
set_state_pe(port, PE_SEND_NOT_SUPPORTED);
+ return;
}
- return;
}
/* Control Messages */
else {
@@ -5392,57 +5390,6 @@ static void pe_wait_for_error_recovery_run(int port)
/* Stay here until error recovery is complete */
}
-/**
- * PE_Handle_Custom_Vdm_Request
- */
-static void pe_handle_custom_vdm_request_entry(int port)
-{
- /* Get the message */
- 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;
-
- print_current_state(port);
-
- /* This is an Interruptible AMS */
- PE_SET_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS);
-
- rlen = pd_custom_vdm(port, cnt, payload, &rdata);
- if (rlen > 0) {
- tx_emsg[port].len = rlen * 4;
- memcpy(tx_emsg[port].buf, (uint8_t *)rdata, tx_emsg[port].len);
- send_data_msg(port, sop, PD_DATA_VENDOR_DEF);
- } else {
- if (prl_get_rev(port, TCPCI_MSG_SOP) > PD_REV20) {
- set_state_pe(port, PE_SEND_NOT_SUPPORTED);
- } else {
- PE_CLR_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS);
- pe_set_ready_state(port);
- }
- }
-}
-
-static void pe_handle_custom_vdm_request_run(int port)
-{
- /* Wait for ACCEPT, WAIT or Reject message to send. */
- if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) {
- PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE);
-
- /*
- * Message sent. Transition back to
- * PE_SRC_Ready or PE_SINK_Ready
- */
- pe_set_ready_state(port);
- }
-}
-
-static void pe_handle_custom_vdm_request_exit(int port)
-{
- PE_CLR_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS);
-}
-
static enum vdm_response_result parse_vdm_response_common(int port)
{
/* Retrieve the message information */
@@ -8168,11 +8115,6 @@ static __const_data const struct usb_state pe_states[] = {
.run = pe_vdm_response_run,
.exit = pe_vdm_response_exit,
},
- [PE_HANDLE_CUSTOM_VDM_REQUEST] = {
- .entry = pe_handle_custom_vdm_request_entry,
- .run = pe_handle_custom_vdm_request_run,
- .exit = pe_handle_custom_vdm_request_exit,
- },
[PE_DEU_SEND_ENTER_USB] = {
.entry = pe_enter_usb_entry,
.run = pe_enter_usb_run,
diff --git a/test/usb_pe.h b/test/usb_pe.h
index 41891af557..c5f636270b 100644
--- a/test/usb_pe.h
+++ b/test/usb_pe.h
@@ -73,7 +73,6 @@ enum usb_pe_state {
PE_INIT_VDM_MODES_REQUEST,
PE_VDM_REQUEST_DPM,
PE_VDM_RESPONSE,
- PE_HANDLE_CUSTOM_VDM_REQUEST,
PE_WAIT_FOR_ERROR_RECOVERY,
PE_BIST_TX,
PE_DEU_SEND_ENTER_USB,