[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251114150738.32426-8-damien.riegel@silabs.com>
Date: Fri, 14 Nov 2025 10:07:33 -0500
From: Damien Riégel <damien.riegel@...abs.com>
To: greybus-dev@...ts.linaro.org, Johan Hovold <johan@...nel.org>,
Alex Elder <elder@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org
Cc: Silicon Labs Kernel Team <linux-devel@...abs.com>,
Damien Riégel <damien.riegel@...abs.com>
Subject: [RFC PATCH v2 07/12] greybus: cpc: account for CPC header size in RX and TX path
Account that a CPC header is prepended to every frame in the RX and TX
path. For now, nothing is done with that headroom but at least bytes are
reserved for it.
Signed-off-by: Damien Riégel <damien.riegel@...abs.com>
---
drivers/greybus/cpc/host.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/greybus/cpc/host.c b/drivers/greybus/cpc/host.c
index d797845497a..1cce4f987e3 100644
--- a/drivers/greybus/cpc/host.c
+++ b/drivers/greybus/cpc/host.c
@@ -9,6 +9,7 @@
#include <linux/skbuff.h>
#include "cpc.h"
+#include "header.h"
#include "host.h"
@@ -49,11 +50,13 @@ static int cpc_hd_message_send(struct cpc_host_device *cpc_hd, u16 cport_id,
return -EINVAL;
}
- size = sizeof(*message->header) + message->payload_size;
+ size = sizeof(*message->header) + message->payload_size + CPC_HEADER_SIZE;
skb = alloc_skb(size, gfp_mask);
if (!skb)
return -ENOMEM;
+ skb_reserve(skb, CPC_HEADER_SIZE);
+
/* Header and payload are already contiguous in Greybus message */
skb_put_data(skb, message->buffer, sizeof(*message->header) + message->payload_size);
@@ -210,9 +213,11 @@ void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, struct sk_buff *skb)
u16 cport_id;
/* Prevent an out-of-bound access if called with non-sensical parameters. */
- if (skb->len < sizeof(*gb_hdr))
+ if (skb->len < (sizeof(*gb_hdr) + CPC_HEADER_SIZE))
goto free_skb;
+ skb_pull(skb, CPC_HEADER_SIZE);
+
/* Retrieve cport ID that was packed in Greybus header */
gb_hdr = (struct gb_operation_msg_hdr *)skb->data;
cport_id = cpc_cport_unpack(gb_hdr);
--
2.49.0
Powered by blists - more mailing lists