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@silabs.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 66c4d7fd0b8..759322759bd 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"
static struct cpc_host_device *gb_hd_to_cpc_hd(struct gb_host_device *hd) @@ -48,11 +49,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(struct cpc_header) + sizeof(*message->header) + message->payload_size; skb = alloc_skb(size, gfp_mask); if (!skb) return -ENOMEM;
+ skb_reserve(skb, sizeof(struct cpc_header)); + /* Header and payload are already contiguous in Greybus message */ skb_put_data(skb, message->buffer, sizeof(*message->header) + message->payload_size);
@@ -215,9 +218,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) + sizeof(struct cpc_header))) goto free_skb;
+ skb_pull(skb, sizeof(struct cpc_header)); + /* 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);