On Thursday 15 January 2026 16:58:01 Central European Standard Time Damien Riégel wrote:
The first step in making the CPC header actually do something is to add the sequence number to outgoing messages and validate that incoming frames are received in order.
At this stage, the driver doesn't send standalone acks, so if a message with Sequence X is received, the remote will not be acknowledged until a message targeting that CPort comes from the Greybus layer. Only then the driver will ack with acknowledgedment number of X + 1.
Signed-off-by: Damien Riégel damien.riegel@silabs.com
Changes in v2:
- change dev_warn to ratelimited version in cpc_protocol_on_data
drivers/greybus/cpc/Makefile | 2 +- drivers/greybus/cpc/cpc.h | 20 +++++++++++++++ drivers/greybus/cpc/cport.c | 25 ++++++++++++++++++ drivers/greybus/cpc/header.c | 17 ++++++++++++ drivers/greybus/cpc/header.h | 2 ++ drivers/greybus/cpc/host.c | 13 +++++++--- drivers/greybus/cpc/protocol.c | 47 ++++++++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 drivers/greybus/cpc/header.c create mode 100644 drivers/greybus/cpc/protocol.c
[...]
diff --git a/drivers/greybus/cpc/protocol.c b/drivers/greybus/cpc/protocol.c new file mode 100644 index 00000000000..ff65757b40f --- /dev/null +++ b/drivers/greybus/cpc/protocol.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 +/*
- Copyright (c) 2025, Silicon Laboratories, Inc.
- */
+#include <linux/skbuff.h>
+#include "cpc.h" +#include "header.h" +#include "host.h"
+void cpc_protocol_prepare_header(struct sk_buff *skb, u8 ack) +{
- struct cpc_header *hdr;
- skb_push(skb, sizeof(*hdr));
- hdr = (struct cpc_header *)skb->data;
- hdr->ack = ack;
- hdr->recv_wnd = 0;
- hdr->ctrl_flags = 0;
- hdr->seq = CPC_SKB_CB(skb)->seq;
I suggest "memset(hdr, 0, sizeof(*hdr))", so there is no doubts all the members are set.
[...]