summaryrefslogtreecommitdiff
path: root/common/usb_pd_policy.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-01-30 14:35:18 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-03 22:49:30 +0000
commitae9aea55280abdf2febb362cd9af7be656614eb2 (patch)
tree286e99979dcdb751bdb72752631257579131a062 /common/usb_pd_policy.c
parent6967f634ab7c558522236a3608766fe9a5a067fd (diff)
downloadchrome-ec-ae9aea55280abdf2febb362cd9af7be656614eb2.tar.gz
usb_pd TCPMv1: Maintain independent MessageId for SOP''
This patchset enables checking and storaging the MessageId counter received from the SOP'' messages. Since SOP*(Cable) communication and SOP(Port Partner) have separate MessageID counters, it is necessary to store separate messageIDs to avoid the the incoming packets from getting dropped. BUG=b:148481858 BRANCH=None TEST=Tested on Volteer, able to maintain separate MessageId count for SOP, SOP' and SOP'' communication. Change-Id: Id3a29594c5f9b354ecb650c6d351b16883d2126b Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032344 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_policy.c')
-rw-r--r--common/usb_pd_policy.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 93ce6fccb4..25dfea72f9 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -173,21 +173,32 @@ bool is_transmit_msg_sop_prime(int port)
(cable[port].flags & CABLE_FLAGS_SOP_PRIME_ENABLE));
}
-static bool is_transmit_msg_sop_prime_prime(int port)
+bool is_transmit_msg_sop_prime_prime(int port)
{
return (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP) &&
(cable[port].flags & CABLE_FLAGS_SOP_PRIME_PRIME_ENABLE));
}
-int cable_consume_repeat_message(int port, uint8_t msg_id)
+bool consume_sop_prime_repeat_msg(int port, uint8_t msg_id)
{
- if (cable[port].last_cable_msg_id != msg_id) {
- cable[port].last_cable_msg_id = msg_id;
- return 0;
+ if (cable[port].last_sop_p_msg_id != msg_id) {
+ cable[port].last_sop_p_msg_id = msg_id;
+ return false;
}
- CPRINTF("C%d Cable repeat msg_id %d\n", port, msg_id);
- return 1;
+ CPRINTF("C%d SOP Prime repeat msg_id %d\n", port, msg_id);
+ return true;
+}
+
+bool consume_sop_prime_prime_repeat_msg(int port, uint8_t msg_id)
+{
+
+ if (cable[port].last_sop_p_p_msg_id != msg_id) {
+ cable[port].last_sop_p_p_msg_id = msg_id;
+ return false;
+ }
+ CPRINTF("C%d SOP Prime Prime repeat msg_id %d\n", port, msg_id);
+ return true;
}
static void disable_transmit_sop_prime(int port)
@@ -245,14 +256,8 @@ void reset_pd_cable(int port)
{
if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) {
memset(&cable[port], 0, sizeof(cable[port]));
- /*
- * Invalidate the last cable messageId counter. The cable
- * Message id starts from 0 to 7 and if last_cable msg_id
- * is initialized to 0, it will lead to repetitive message
- * id with first received packet. Hence, initialize it with
- * an invalid value 0xff.
- */
- cable[port].last_cable_msg_id = 0xff;
+ cable[port].last_sop_p_msg_id = INVALID_MSG_ID_COUNTER;
+ cable[port].last_sop_p_p_msg_id = INVALID_MSG_ID_COUNTER;
}
}