greybus: introduce CPC as transport layer
v3 cover greybus: introduce CPC as transport layer
Hi,
This patchset brings support for Silicon Labs' CPC protocol as transport layer for Greybus. CPC stands for Co-Processor Communication and currently exists as a userspace daemon [1] that enables multiple applications on a coprocessor to share a single physical link to a Linux host, using a protocol loosely based on HDLC [2].
While the userspace implementations serves its purpose, it has some redundancies with Greybus that makes it not very suitable for kernel integration as-is, and so the protocol has been modified to better fit with Greybus. Even though kernel and userspace implementations share the same name, they are not the same protocol and are not compatible. The kernel integration with Greybus is intended to superseed the userspace implementation.
CPC is introduced as a module that sits between Greybus and CPC Host Device Drivers implementations, like SDIO or SPI. This patchset includes SDIO as physical layer but the protocol is not final and might change, it's mostly there to showcase all the elements.
+----------------------------------------------------+
| Greybus |
+----------------------------------------------------+
/|\
|
\|/
+----------------------------------------------------+
| CPC |
+----------------------------------------------------+
/|\ /|\ /|\
| | |
\|/ \|/ \|/
+----------+ +---------+ +-----------+
| SDIO | | SPI | | Others |
+----------+ +---------+ +-----------+CPC implements some of the features of Unipro that Greybus relies upon, like reliable transmission. CPC takes care of detecting transmission errors and retransmit frames if necessary, but that feature is not part of the RFC to keep it concise. There's also a flow-control feature, preventing sending messages to already full cports.
In order to implement these features, a 4-byte header is prepended to Greybus messages, making the whole header 12 bytes (Greybus header is 8 bytes).
This RFC starts by implementing a shim layer between physical bus drivers (like SDIO and SPI) and Greybus, and progressively add more elements to it to make it useful in its own right. Finally, an SDIO driver is added to enable the communication with a remote device.
[1] https://github.com/SiliconLabs/cpc-daemon
[2] https://en.wikipedia.org/wiki/High-Level_Data_Link_Control
Changes in v3:
- addressed Jerome's review comments, mostly for SDIO driver
- rewrote cover letter and commit messages across the series
Changes in v2:
- addressed review comments and errors reported by kernel bot
- for SDIO driver, remove padding between headers and payloads when aggregating packets together
Damien Riégel (13):
greybus: cpc: add minimal CPC Host Device infrastructure
greybus: cpc: introduce CPC cport structure
greybus: cpc: use socket buffers instead of gb_message in TX path
greybus: cpc: pack cport ID in Greybus header
greybus: cpc: switch RX path to socket buffers
greybus: cpc: introduce CPC header structure
greybus: cpc: account for CPC header size in RX and TX path
greybus: cpc: add and validate sequence numbers
greybus: cpc: acknowledge all incoming messages
greybus: cpc: use holding queue instead of sending out immediately
greybus: cpc: honour remote's RX window
greybus: cpc: let host device drivers dequeue TX frames
greybus: cpc: add private data pointer in CPC Host Device
Gabriel Beaulieu (1):
greybus: cpc: add CPC SDIO host driver
MAINTAINERS | 6 + drivers/greybus/Kconfig | 2 + drivers/greybus/Makefile | 2 + drivers/greybus/cpc/Kconfig | 24 ++ drivers/greybus/cpc/Makefile | 9 + drivers/greybus/cpc/cpc.h | 75 ++++++ drivers/greybus/cpc/cport.c | 112 ++++++++ drivers/greybus/cpc/header.c | 136 ++++++++++ drivers/greybus/cpc/header.h | 52 ++++ drivers/greybus/cpc/host.c | 319 ++++++++++++++++++++++ drivers/greybus/cpc/host.h | 63 +++++ drivers/greybus/cpc/protocol.c | 170 ++++++++++++ drivers/greybus/cpc/sdio.c | 480 +++++++++++++++++++++++++++++++++ 13 files changed, 1450 insertions(+) create mode 100644 drivers/greybus/cpc/Kconfig create mode 100644 drivers/greybus/cpc/Makefile create mode 100644 drivers/greybus/cpc/cpc.h create mode 100644 drivers/greybus/cpc/cport.c create mode 100644 drivers/greybus/cpc/header.c create mode 100644 drivers/greybus/cpc/header.h create mode 100644 drivers/greybus/cpc/host.c create mode 100644 drivers/greybus/cpc/host.h create mode 100644 drivers/greybus/cpc/protocol.c create mode 100644 drivers/greybus/cpc/sdio.c
Signature · 1 line
2.52.0
PATCH v3 1/14 greybus: cpc: add minimal CPC Host Device infrastructure
CPC stands for Co-Processor Communication and currently exists as a userspace daemon [1]. It enables multiple applications running on a coprocessor to share a single physical link to a Linux host.
CPC userspace and kernel implementations differ, as the kernel implementation relies on Greybus. So even though both share the "CPC" name, they are not the same protocol and are not intended to be compatible with each other. Kernel integration is intended to superseed the userspace daemon.
The point of the kernel integration is gain access to more physical links, like SDIO, and eventually add Greybus drivers that integrate into kernel stacks like Wi-Fi and Bluetooth.
The first step to add CPC support with Greybus is to add a very minimal module for CPC Host Devices. For now, this module only proxies calls to the Greybus Host Device API and does nothing useful, but further commits will use this base to build upon.
[1] https://github.com/SiliconLabs/cpc-daemon
---
Changes in v3:
- rewrite commit message and Kconfig help message to better explain what CPC is
MAINTAINERS | 6 +++ drivers/greybus/Kconfig | 2 + drivers/greybus/Makefile | 2 + drivers/greybus/cpc/Kconfig | 12 ++++++ drivers/greybus/cpc/Makefile | 6 +++ drivers/greybus/cpc/host.c | 84 ++++++++++++++++++++++++++++++++++++ drivers/greybus/cpc/host.h | 40 +++++++++++++++++ 7 files changed, 152 insertions(+) create mode 100644 drivers/greybus/cpc/Kconfig create mode 100644 drivers/greybus/cpc/Makefile create mode 100644 drivers/greybus/cpc/host.c create mode 100644 drivers/greybus/cpc/host.h
MAINTAINERS +6 -0
@@ -10774,6 +10774,12 @@ S: Maintained F: Documentation/devicetree/bindings/net/ti,cc1352p7.yaml F: drivers/greybus/gb-beagleplay.c +GREYBUS CPC DRIVERS +M: Damien Riégel <[email protected]> +R: Silicon Labs Kernel Team <[email protected]> +S: Supported +F: drivers/greybus/cpc/* + GREYBUS SUBSYSTEM M: Johan Hovold <[email protected]> M: Alex Elder <[email protected]>
drivers/greybus/Kconfig +2 -0
@@ -30,6 +30,8 @@ config GREYBUS_BEAGLEPLAY To compile this code as a module, chose M here: the module will be called gb-beagleplay.ko +source "drivers/greybus/cpc/Kconfig" + config GREYBUS_ES2 tristate "Greybus ES3 USB host controller" depends on USB
drivers/greybus/Makefile +2 -0
@@ -21,6 +21,8 @@ ccflags-y += -I$(src) obj-$(CONFIG_GREYBUS_BEAGLEPLAY) += gb-beagleplay.o # Greybus Host controller drivers +obj-$(CONFIG_GREYBUS_CPC) += cpc/ + gb-es2-y := es2.o obj-$(CONFIG_GREYBUS_ES2) += gb-es2.o
drivers/greybus/cpc/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0 + +config GREYBUS_CPC + tristate "Greybus CPC driver" + help + CPC (Co-Processor Communication) is a protocol for sharing a single + physical link to a coprocessor between multiple users. CPC adds + checksumming, retransmissions and flow control to Greybus to transmit + messages as reliably as possible. + + To compile this code as a module, chose M here: the module will be + called gb-cpc.ko
drivers/greybus/cpc/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 + +gb-cpc-y := host.o + +# CPC core +obj-$(CONFIG_GREYBUS_CPC) += gb-cpc.o
drivers/greybus/cpc/host.c new file +84 -0
84 lines not on this page · raw message
drivers/greybus/cpc/host.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025, Silicon Laboratories, Inc. +*/ + +#ifndef __CPC_HOST_H +#define __CPC_HOST_H + +#include <linux/device.h> +#include <linux/greybus.h> +#include <linux/types.h> + +#define GB_CPC_MSG_SIZE_MAX 4096 +#define GB_CPC_NUM_CPORTS 8 + +struct cpc_host_device ; + +struct cpc_hd_driver { +int (*message_send)(struct cpc_host_device *hd,u16 dest_cport_id, +struct gb_message *message,gfp_t gfp_mask); +void (*message_cancel)(struct gb_message *message); +}; + +/** +* struct cpc_host_device - CPC host device. +* @gb_hd: pointer to Greybus Host Device this device belongs to. +* @driver: driver operations. +*/ +struct cpc_host_device { +struct gb_host_device *gb_hd; +const struct cpc_hd_driver *driver; +}; + +struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent); +int cpc_hd_add (struct cpc_host_device *cpc_hd); +void cpc_hd_put (struct cpc_host_device *cpc_hd); +void cpc_hd_del (struct cpc_host_device *cpc_hd); +void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u16 cport_id,u8 *data,size_t length); + +#endif
Signature · 1 line
2.52.0
PATCH v3 2/14 greybus: cpc: introduce CPC cport structure
In reply to Damien RiégelA number of CPC features, like retransmission or remote's receive window, are cport-based. In order to prepare for these features, introduce a CPC CPort context structure.
The CPC Host Device module now implements cport_allocate and cport_release callbacks in order to allocate and release these structures when requested by Greybus module.
---
Changes in v3:
- simplify cpc_hd_cport_allocate so that cport with ID "i"is at offset
"i" in cpc_hd->cports array
drivers/greybus/cpc/Makefile | 2 +- drivers/greybus/cpc/cpc.h | 29 +++++++++ drivers/greybus/cpc/cport.c | 37 +++++++++++ drivers/greybus/cpc/host.c | 115 ++++++++++++++++++++++++++++++++++- drivers/greybus/cpc/host.h | 12 ++++ 5 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 drivers/greybus/cpc/cpc.h create mode 100644 drivers/greybus/cpc/cport.c
drivers/greybus/cpc/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -gb-cpc-y := host.o +gb-cpc-y := cport.o host.o # CPC core obj-$(CONFIG_GREYBUS_CPC) += gb-cpc.o
drivers/greybus/cpc/cpc.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025, Silicon Laboratories, Inc. +*/ + +#ifndef __CPC_H +#define __CPC_H + +#include <linux/device.h> +#include <linux/greybus.h> +#include <linux/types.h> + +/** +* struct cpc_cport - CPC cport +* @id: cport ID +* @cpc_hd: pointer to the CPC host device this cport belongs to +*/ +struct cpc_cport { +u16 id; + +struct cpc_host_device *cpc_hd; +}; + +struct cpc_cport *cpc_cport_alloc (u16 cport_id,gfp_t gfp_mask); +void cpc_cport_release (struct cpc_cport *cport); + +int cpc_cport_message_send (struct cpc_cport *cport,struct gb_message *message,gfp_t gfp_mask); + +#endif
drivers/greybus/cpc/cport.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2025, Silicon Laboratories, Inc. +*/ + +#include "cpc.h" +#include "host.h" + +/** +* cpc_cport_alloc() - Allocate and initialize CPC cport. +* @cport_id: cport ID. +* @gfp_mask: GFP mask for allocation. +* +* Return: Pointer to allocated and initialized cpc_cport, or NULL on failure. +*/ +struct cpc_cport *cpc_cport_alloc (u16 cport_id,gfp_t gfp_mask) +{ +struct cpc_cport *cport; + + cport =kzalloc (sizeof (*cport), gfp_mask); +if (!cport) +return NULL ; + + cport->id = cport_id; + +return cport; +} + +void cpc_cport_release (struct cpc_cport *cport) +{ +kfree (cport); +} + +int cpc_cport_message_send (struct cpc_cport *cport,struct gb_message *message,gfp_t gfp_mask) +{ +return cport->cpc_hd->driver->message_send (cport->cpc_hd, cport->id, message, gfp_mask); +}
drivers/greybus/cpc/host.c +114 -1
150 lines not on this page · raw message
drivers/greybus/cpc/host.h +12 -0
@@ -8,11 +8,13 @@#include <linux/device.h> #include <linux/greybus.h> +#include <linux/mutex.h> #include <linux/types.h> #define GB_CPC_MSG_SIZE_MAX 4096#define GB_CPC_NUM_CPORTS 8 +struct cpc_cport ;struct cpc_host_device ;struct cpc_hd_driver {
@@ -25,12 +27,22 @@ struct cpc_hd_driver {* struct cpc_host_device - CPC host device. * @gb_hd: pointer to Greybus Host Device this device belongs to. * @driver: driver operations. +* @lock: mutex to synchronize access to cport array. +* @cports: array of cport pointers allocated by Greybus core. */ struct cpc_host_device {struct gb_host_device *gb_hd;const struct cpc_hd_driver *driver; + +struct mutex lock;/* Synchronize access to cports */ +struct cpc_cport *cports[GB_CPC_NUM_CPORTS ]; }; +static inline struct device *cpc_hd_dev (struct cpc_host_device *cpc_hd) +{ +return &cpc_hd->gb_hd->dev; +} +struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent);int cpc_hd_add (struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);
Signature · 1 line
2.52.0
PATCH v3 3/14 greybus: cpc: use socket buffers instead of gb_message in TX path
In reply to Damien RiégelCPC comes with its own header, whose support is added in a future commit of this series. Without skb, the CPC host device drivers have to get two pointers to get a full packet: one pointer to the CPC header and one pointer to the GB message.
In order to make implementations simpler, convert the GB message into an SKB in the message_send() operation. That way, CPC internally works only with SKBs, and only convert back to GB messages when notifying Greybus core that a message has been transmitted or received.
--- drivers/greybus/cpc/cpc.h | 11 +++++++++- drivers/greybus/cpc/cport.c | 11 ++++++++-- drivers/greybus/cpc/host.c | 41 ++++++++++++++++++++++++++++++++++--- drivers/greybus/cpc/host.h | 7 ++++--- 4 files changed, 61 insertions(+), 9 deletions(-)
drivers/greybus/cpc/cpc.h +10 -1
@@ -24,6 +24,15 @@ struct cpc_cport {struct cpc_cport *cpc_cport_alloc (u16 cport_id,gfp_t gfp_mask);void cpc_cport_release (struct cpc_cport *cport); -int cpc_cport_message_send (struct cpc_cport *cport,struct gb_message *message,gfp_t gfp_mask); +int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb); + +struct cpc_skb_cb { +struct cpc_cport *cport; + +/* Keep track of the GB message the skb originates from */ +struct gb_message *gb_message; +}; + +#define CPC_SKB_CB (__skb) ((struct cpc_skb_cb *)&((__skb)->cb[0]))#endif
drivers/greybus/cpc/cport.c +9 -2
@@ -31,7 +31,14 @@ void cpc_cport_release(struct cpc_cport *cport)kfree (cport); } -int cpc_cport_message_send (struct cpc_cport *cport,struct gb_message *message,gfp_t gfp_mask) +/** +* cpc_cport_transmit() - Transmit skb over cport. +* @cport: cport. +* @skb: skb to be transmitted. +*/ +int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb) { -return cport->cpc_hd->driver->message_send (cport->cpc_hd, cport->id, message, gfp_mask); +struct cpc_host_device *cpc_hd = cport->cpc_hd; + +return cpc_hd_send_skb (cpc_hd, skb); }
drivers/greybus/cpc/host.c +38 -3
77 lines not on this page · raw message
drivers/greybus/cpc/host.h +4 -3
@@ -18,9 +18,7 @@ struct cpc_cport;struct cpc_host_device ;struct cpc_hd_driver { -int (*message_send)(struct cpc_host_device *hd,u16 dest_cport_id, -struct gb_message *message,gfp_t gfp_mask); -void (*message_cancel)(struct gb_message *message); +int (*transmit)(struct cpc_host_device *hd,struct sk_buff *skb); };/**
@@ -48,5 +46,8 @@ int cpc_hd_add(struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd);void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u16 cport_id,u8 *data,size_t length); +void cpc_hd_message_sent (struct sk_buff *skb,int status); + +int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb);#endif
Signature · 1 line
2.52.0
PATCH v3 4/14 greybus: cpc: pack cport ID in Greybus header
In reply to Damien RiégelTake advantage of the padding bytes present in the Greybus header to store the CPort ID and minimize overhead. This technique is already used by the es2 driver.
---
Changes in v2:
- clear pad bytes when unpacking CPort ID
drivers/greybus/cpc/cpc.h | 3 +++ drivers/greybus/cpc/cport.c | 34 ++++++++++++++++++++++++++++++++++ drivers/greybus/cpc/host.c | 13 ++++++++++++- drivers/greybus/cpc/host.h | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-)
drivers/greybus/cpc/cpc.h +3 -0
@@ -24,6 +24,9 @@ struct cpc_cport {struct cpc_cport *cpc_cport_alloc (u16 cport_id,gfp_t gfp_mask);void cpc_cport_release (struct cpc_cport *cport); +void cpc_cport_pack (struct gb_operation_msg_hdr *gb_hdr,u16 cport_id); +u16 cpc_cport_unpack (struct gb_operation_msg_hdr *gb_hdr); +int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb);struct cpc_skb_cb {
drivers/greybus/cpc/cport.c +34 -0
@@ -3,6 +3,9 @@* Copyright (c) 2025, Silicon Laboratories, Inc. */ +#include <linux/unaligned.h> +#include <linux/skbuff.h> +#include "cpc.h" #include "host.h"
@@ -31,6 +34,32 @@ void cpc_cport_release(struct cpc_cport *cport)kfree (cport); } +/** +* cpc_cport_pack() - Pack CPort ID into Greybus Operation Message header. +* @gb_hdr: Greybus operation message header. +* @cport_id: CPort ID to pack. +*/ +void cpc_cport_pack (struct gb_operation_msg_hdr *gb_hdr,u16 cport_id) +{ +put_unaligned_le16 (cport_id, gb_hdr->pad); +} + +/** +* cpc_cport_unpack() - Unpack CPort ID from Greybus Operation Message header. +* @gb_hdr: Greybus operation message header. +* +* Return: CPort ID packed in the header. +*/ +u16 cpc_cport_unpack (struct gb_operation_msg_hdr *gb_hdr) +{ +u16 cport_id =get_unaligned_le16 (gb_hdr->pad); + +// Clear padding bytes +put_unaligned_le16 (0 , gb_hdr->pad); + +return cport_id; +} +/** * cpc_cport_transmit() - Transmit skb over cport. * @cport: cport.
@@ -39,6 +68,11 @@ void cpc_cport_release(struct cpc_cport *cport)int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb) {struct cpc_host_device *cpc_hd = cport->cpc_hd; +struct gb_operation_msg_hdr *gb_hdr; + +/* Inject cport ID in Greybus header */ + gb_hdr = (struct gb_operation_msg_hdr *)skb->data; +cpc_cport_pack (gb_hdr, cport->id);return cpc_hd_send_skb (cpc_hd, skb); }
drivers/greybus/cpc/host.c +12 -1
@@ -209,8 +209,19 @@ void cpc_hd_message_sent(struct sk_buff *skb, int status) }EXPORT_SYMBOL_GPL (cpc_hd_message_sent); -void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u16 cport_id,u8 *data,size_t length) +void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u8 *data,size_t length) { +struct gb_operation_msg_hdr *gb_hdr; +u16 cport_id; + +/* Prevent an out-of-bound access if called with non-sensical parameters. */ +if (!data || length <sizeof (*gb_hdr)) +return ; + +/* Retrieve cport ID that was packed in Greybus header */ + gb_hdr = (struct gb_operation_msg_hdr *)data; + cport_id =cpc_cport_unpack (gb_hdr); +greybus_data_rcvd (cpc_hd->gb_hd, cport_id, data, length); }EXPORT_SYMBOL_GPL (cpc_hd_rcvd);
drivers/greybus/cpc/host.h +1 -1
@@ -45,7 +45,7 @@ struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct devicint cpc_hd_add (struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd); -void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u16 cport_id,u8 *data,size_t length); +void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u8 *data,size_t length);void cpc_hd_message_sent (struct sk_buff *skb,int status);int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb);
Signature · 1 line
2.52.0
PATCH v3 5/14 greybus: cpc: switch RX path to socket buffers
In reply to Damien RiégelFor symmetry, also convert the RX path to use socket buffers instead of u8* buffers. Before this commit CPC host device drivers were responsible for allocating and freeing the buffers.
Now they are only responsible for allocating the SKBs and pass it to the upper layer, the CPC "core" module will take of converting the SKBs into a buffer that can be consumed by Greybus' core and releasing the SKBs.
--- drivers/greybus/cpc/host.c | 13 ++++++++----- drivers/greybus/cpc/host.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/greybus/cpc/host.c +8 -5
@@ -209,20 +209,23 @@ void cpc_hd_message_sent(struct sk_buff *skb, int status) }EXPORT_SYMBOL_GPL (cpc_hd_message_sent); -void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u8 *data,size_t length) +void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb) {struct gb_operation_msg_hdr *gb_hdr;u16 cport_id;/* Prevent an out-of-bound access if called with non-sensical parameters. */ -if (!data || length <sizeof (*gb_hdr)) -return ; +if (skb->len <sizeof (*gb_hdr)) + goto free_skb;/* Retrieve cport ID that was packed in Greybus header */ - gb_hdr = (struct gb_operation_msg_hdr *)data; + gb_hdr = (struct gb_operation_msg_hdr *)skb->data; cport_id =cpc_cport_unpack (gb_hdr); -greybus_data_rcvd (cpc_hd->gb_hd, cport_id, data, length); +greybus_data_rcvd (cpc_hd->gb_hd, cport_id, skb->data, skb->len); + +free_skb: +kfree_skb (skb); }EXPORT_SYMBOL_GPL (cpc_hd_rcvd);
drivers/greybus/cpc/host.h +1 -1
@@ -45,7 +45,7 @@ struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct devicint cpc_hd_add (struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd); -void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,u8 *data,size_t length); +void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb);void cpc_hd_message_sent (struct sk_buff *skb,int status);int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb);
Signature · 1 line
2.52.0
PATCH v3 6/14 greybus: cpc: introduce CPC header structure
In reply to Damien RiégelCPC main features are reliable transmission and remote's receive window management. To implement these features, an additional header is needed. This header is prepended to all Greybus messages before going on the wire.
Reliable transmission: to make transmission reliable, messages are sequenced and acknowledged. That constitutes two bytes of the header, one for the sequence number, one for the acknowledgment number. If a message is not acked in a timely manner, a retransmission mechanism will attempt another transmission. That mechanism will be implemented in a future patch set.
Remote's receive window: the remote advertises the number of reception buffers that are available on this cport. The other peer must take care of not sending more messages than advertised by the remote. This is a sort of flow control. That accounts for one byte in the header.
The remaining byte carries some flags. For instance, there is a flag to indicate if it's a CPC message or a Greybus message.
---
Changes in v3:
- remove CPC_HEADER_SIZE and GREYBUS_HEADER_SIZE macros
Changes in v2:
- Minor tweaks to structure documentation
drivers/greybus/cpc/header.h | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 drivers/greybus/cpc/header.h
drivers/greybus/cpc/header.h new file +41 -0
@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025, Silicon Laboratories, Inc. +*/ + +#ifndef __CPC_HEADER_H +#define __CPC_HEADER_H + +#include <linux/greybus.h> +#include <linux/types.h> + +#define CPC_HEADER_MAX_RX_WINDOW U8_MAX + +/** +* struct cpc header - Representation of CPC header. +* @ctrl_flags: contains the type of frame and other control flags. +* @recv_wnd: number of buffers that the cport can receive without blocking. +* @seq: sequence number. +* @ack: acknowledge number, indicate to the remote the next sequence number +* this peer expects to see. +* +* Each peer can confirm reception of frames by setting the acknowledgment number to the next frame +* it expects to see, i.e. setting the ack number to X effectively acknowledges frames with sequence +* number up to X-1. +* +* CPC is designed around the concept that each cport has its pool of reception buffers. The number +* of buffers in a pool is advertised to the remote via the @recv_wnd attribute. This acts as +* software flow-control, and a peer shall not send frames to a remote if the @recv_wnd is zero. +* +* The eighth-bit (0x80) of the control byte indicates if the frame targets CPC or Greybus. If the +* bit is set, the frame should be interpreted as a CPC control frame. For simplicity, control +* frames have the same encoding as Greybus frames. +*/ +struct cpc_header { +__u8 ctrl_flags; +__u8 recv_wnd; +__u8 seq; +__u8 ack; +} __packed; + +#endif
Signature · 1 line
2.52.0
PATCH v3 7/14 greybus: cpc: account for CPC header size in RX and TX path
In reply to Damien RiégelAccount 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.
--- drivers/greybus/cpc/host.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/greybus/cpc/host.c +7 -2
@@ -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);
Signature · 1 line
2.52.0
PATCH v3 8/14 greybus: cpc: add and validate sequence numbers
In reply to Damien RiégelThe 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.
--- 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
drivers/greybus/cpc/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -gb-cpc-y := cport.o host.o +gb-cpc-y := cport.o header.o host.o protocol.o # CPC core obj-$(CONFIG_GREYBUS_CPC) += gb-cpc.o
drivers/greybus/cpc/cpc.h +20 -0
@@ -8,17 +8,32 @@#include <linux/device.h> #include <linux/greybus.h> +#include <linux/mutex.h> #include <linux/types.h> +struct sk_buff ; +/** * struct cpc_cport - CPC cport * @id: cport ID * @cpc_hd: pointer to the CPC host device this cport belongs to +* @lock: mutex to synchronize accesses to tcb and other attributes +* @tcb: Transmission Control Block */ struct cpc_cport {u16 id;struct cpc_host_device *cpc_hd; +struct mutex lock;/* Synchronize access to state variables */ + +/* +* @ack: current acknowledge number +* @seq: current sequence number +*/ +struct { +u8 ack; +u8 seq; + } tcb; };struct cpc_cport *cpc_cport_alloc (u16 cport_id,gfp_t gfp_mask);
@@ -34,8 +49,13 @@ struct cpc_skb_cb {/* Keep track of the GB message the skb originates from */ struct gb_message *gb_message; + + u8 seq; };#define CPC_SKB_CB (__skb) ((struct cpc_skb_cb *)&((__skb)->cb[0])) +void cpc_protocol_prepare_header (struct sk_buff *skb,u8 ack); +void cpc_protocol_on_data (struct cpc_cport *cport,struct sk_buff *skb); +#endif
drivers/greybus/cpc/cport.c +25 -0
@@ -9,6 +9,16 @@#include "cpc.h" #include "host.h" +/** +* cpc_cport_tcb_reset() - Reset cport's TCB to initial values. +* @cport: cport pointer +*/ +static void cpc_cport_tcb_reset (struct cpc_cport *cport) +{ + cport->tcb.ack =0 ; + cport->tcb.seq =0 ; +} +/** * cpc_cport_alloc() - Allocate and initialize CPC cport. * @cport_id: cport ID.
@@ -25,6 +35,9 @@ struct cpc_cport *cpc_cport_alloc(u16 cport_id, gfp_t gfp_mask)return NULL ; cport->id = cport_id; +cpc_cport_tcb_reset (cport); + +mutex_init (&cport->lock);return cport; }
@@ -69,10 +82,22 @@ int cpc_cport_transmit(struct cpc_cport *cport, struct sk_buff *skb) {struct cpc_host_device *cpc_hd = cport->cpc_hd;struct gb_operation_msg_hdr *gb_hdr; +u8 ack;/* Inject cport ID in Greybus header */ gb_hdr = (struct gb_operation_msg_hdr *)skb->data;cpc_cport_pack (gb_hdr, cport->id); +mutex_lock (&cport->lock); + +CPC_SKB_CB (skb)->seq = cport->tcb.seq; + + cport->tcb.seq++; + ack = cport->tcb.ack; + +mutex_unlock (&cport->lock); + +cpc_protocol_prepare_header (skb, ack); +return cpc_hd_send_skb (cpc_hd, skb); }
drivers/greybus/cpc/header.c new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2025, Silicon Laboratories, Inc. +*/ + +#include "header.h" + +/** +* cpc_header_get_seq() - Get the sequence number. +* @hdr: CPC header. +* +* Return: Sequence number. +*/ +u8 cpc_header_get_seq (const struct cpc_header *hdr) +{ +return hdr->seq; +}
drivers/greybus/cpc/header.h +2 -0
@@ -38,4 +38,6 @@ struct cpc_header { __u8 ack; } __packed; +u8 cpc_header_get_seq (const struct cpc_header *hdr); +#endif
drivers/greybus/cpc/host.c +9 -4
@@ -215,19 +215,24 @@ EXPORT_SYMBOL_GPL(cpc_hd_message_sent);void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb) {struct gb_operation_msg_hdr *gb_hdr; +struct cpc_cport *cport;u16 cport_id;/* Prevent an out-of-bound access if called with non-sensical parameters. */ 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; + gb_hdr = (struct gb_operation_msg_hdr *)(skb->data +sizeof (struct cpc_header )); cport_id =cpc_cport_unpack (gb_hdr); -greybus_data_rcvd (cpc_hd->gb_hd, cport_id, skb->data, skb->len); + cport =cpc_hd_get_cport (cpc_hd, cport_id); +if (!cport) { +dev_warn (cpc_hd_dev (cpc_hd),"cport %u not allocated\n" , cport_id); + goto free_skb; + } + +cpc_protocol_on_data (cport, skb); free_skb:kfree_skb (skb);
drivers/greybus/cpc/protocol.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v3 9/14 greybus: cpc: acknowledge all incoming messages
In reply to Damien RiégelCurrently, CPC doesn't send messages on its own, it only prepends its header to outgoing messages. This can lead to messages not being acknowledged, for instance in the case of an SVC Ping
Host Device
SVC Ping (seq=X, ack=Y)
SVC Ping Reply (seq=Y, ack=X+1)
The "Ping Reply" is never acknowledged at the CPC level, which can lead to retransmissions, or worst the device might think the link is broken and attempt to recover.
To prevent that scenario, an ack mechanism is implemented in the most straightforward manner: send an ACK to all incoming messages. Here, two flags need to be added:
- First, a flag is needed to differentiate between pure CPC frames, that are only meaningful at the CPC level, and regular Greybus operations. This flag is called "CONTROL". Currently there is only one type of control frame, the standalone ack. Control messages have the same format as Greybus operations.
- Second, ack themselves should not be acked, so to determine if a message should be acked or not, a REQUEST_ACK flag is added.
---
Changes in v2:
- add missing cpu_to_le16 conversion when setting message size
drivers/greybus/cpc/cpc.h | 3 ++ drivers/greybus/cpc/cport.c | 1 + drivers/greybus/cpc/header.c | 41 +++++++++++++++++++++++++ drivers/greybus/cpc/header.h | 3 ++ drivers/greybus/cpc/protocol.c | 55 +++++++++++++++++++++++++++++----- 5 files changed, 96 insertions(+), 7 deletions(-)
drivers/greybus/cpc/cpc.h +3 -0
@@ -51,6 +51,9 @@ struct cpc_skb_cb {struct gb_message *gb_message;u8 seq; + +#define CPC_SKB_FLAG_REQ_ACK (1 << 0) +u8 cpc_flags; };#define CPC_SKB_CB (__skb) ((struct cpc_skb_cb *)&((__skb)->cb[0]))
drivers/greybus/cpc/cport.c +1 -0
@@ -91,6 +91,7 @@ int cpc_cport_transmit(struct cpc_cport *cport, struct sk_buff *skb)mutex_lock (&cport->lock);CPC_SKB_CB (skb)->seq = cport->tcb.seq; +CPC_SKB_CB (skb)->cpc_flags =CPC_SKB_FLAG_REQ_ACK ; cport->tcb.seq++; ack = cport->tcb.ack;
drivers/greybus/cpc/header.c +41 -0
52 lines not on this page · raw message
drivers/greybus/cpc/header.h +3 -0
@@ -38,6 +38,9 @@ struct cpc_header { __u8 ack; } __packed; +bool cpc_header_is_control (const struct cpc_header *hdr);u8 cpc_header_get_seq (const struct cpc_header *hdr); +bool cpc_header_get_req_ack (const struct cpc_header *hdr); +u8 cpc_header_encode_ctrl_flags (bool control,bool req_ack);#endif
drivers/greybus/cpc/protocol.c +48 -7
80 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v3 10/14 greybus: cpc: use holding queue instead of sending out immediately
In reply to Damien RiégelA feature of CPC is the RX window. This value, advertised in every packet, indicates to the remote peer how many reception buffers are available for that CPort. The remote peer must not send more messages than advertised, as these extra messages are almost guaranteed to be dropped by the receiver. This is a bit similar to TCP's receive window, but expressed in a number of messages instead of bytes.
As the first step to handle remote's RX window, store the skb in a sk_buff_head list, instead of sending a message immediately when pushed by Greybus. skbs are still sent out straight away for now, but a future commit will make sure they stay in the holding queue instead of being sent out immediately if the remote's RX window is too small.
--- drivers/greybus/cpc/cpc.h | 10 ++++++---- drivers/greybus/cpc/cport.c | 21 ++++++++++++--------- drivers/greybus/cpc/host.c | 4 +++- drivers/greybus/cpc/protocol.c | 25 ++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 15 deletions(-)
drivers/greybus/cpc/cpc.h +6 -4
@@ -9,15 +9,15 @@#include <linux/device.h> #include <linux/greybus.h> #include <linux/mutex.h> +#include <linux/skbuff.h> #include <linux/types.h> -struct sk_buff ; -/** * struct cpc_cport - CPC cport * @id: cport ID * @cpc_hd: pointer to the CPC host device this cport belongs to * @lock: mutex to synchronize accesses to tcb and other attributes +* @holding_queue: list of frames queued to be sent * @tcb: Transmission Control Block */ struct cpc_cport {
@@ -26,6 +26,8 @@ struct cpc_cport {struct cpc_host_device *cpc_hd;struct mutex lock;/* Synchronize access to state variables */ +struct sk_buff_head holding_queue; +/* * @ack: current acknowledge number * @seq: current sequence number
@@ -42,7 +44,7 @@ void cpc_cport_release(struct cpc_cport *cport);void cpc_cport_pack (struct gb_operation_msg_hdr *gb_hdr,u16 cport_id);u16 cpc_cport_unpack (struct gb_operation_msg_hdr *gb_hdr); -int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb); +void cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb);struct cpc_skb_cb {struct cpc_cport *cport;
@@ -58,7 +60,7 @@ struct cpc_skb_cb {#define CPC_SKB_CB (__skb) ((struct cpc_skb_cb *)&((__skb)->cb[0])) -void cpc_protocol_prepare_header (struct sk_buff *skb,u8 ack);void cpc_protocol_on_data (struct cpc_cport *cport,struct sk_buff *skb); +void __cpc_protocol_write_head (struct cpc_cport *cport);#endif
drivers/greybus/cpc/cport.c +12 -9
@@ -7,7 +7,6 @@#include <linux/skbuff.h> #include "cpc.h" -#include "host.h" /** * cpc_cport_tcb_reset() - Reset cport's TCB to initial values.
@@ -38,15 +37,23 @@ struct cpc_cport *cpc_cport_alloc(u16 cport_id, gfp_t gfp_mask)cpc_cport_tcb_reset (cport);mutex_init (&cport->lock); +skb_queue_head_init (&cport->holding_queue);return cport; }void cpc_cport_release (struct cpc_cport *cport) { +skb_queue_purge (&cport->holding_queue);kfree (cport); } +static void cpc_cport_queue_skb (struct cpc_cport *cport,struct sk_buff *skb) +{ +__skb_header_release (skb); +__skb_queue_tail (&cport->holding_queue, skb); +} +/** * cpc_cport_pack() - Pack CPort ID into Greybus Operation Message header. * @gb_hdr: Greybus operation message header.
@@ -78,11 +85,9 @@ u16 cpc_cport_unpack(struct gb_operation_msg_hdr *gb_hdr)* @cport: cport. * @skb: skb to be transmitted. */ -int cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb) +void cpc_cport_transmit (struct cpc_cport *cport,struct sk_buff *skb) { -struct cpc_host_device *cpc_hd = cport->cpc_hd;struct gb_operation_msg_hdr *gb_hdr; -u8 ack;/* Inject cport ID in Greybus header */ gb_hdr = (struct gb_operation_msg_hdr *)skb->data;
@@ -94,11 +99,9 @@ int cpc_cport_transmit(struct cpc_cport *cport, struct sk_buff *skb)CPC_SKB_CB (skb)->cpc_flags =CPC_SKB_FLAG_REQ_ACK ; cport->tcb.seq++; - ack = cport->tcb.ack; + +cpc_cport_queue_skb (cport, skb); +__cpc_protocol_write_head (cport);mutex_unlock (&cport->lock); - -cpc_protocol_prepare_header (skb, ack); - -return cpc_hd_send_skb (cpc_hd, skb); }
drivers/greybus/cpc/host.c +3 -1
@@ -62,7 +62,9 @@ static int cpc_hd_message_send(struct cpc_host_device *cpc_hd, u16 cport_id,CPC_SKB_CB (skb)->cport = cport;CPC_SKB_CB (skb)->gb_message = message; -return cpc_cport_transmit (cport, skb); +cpc_cport_transmit (cport, skb); + +return 0 ; }static int cpc_hd_cport_allocate (struct cpc_host_device *cpc_hd,int cport_id,unsigned long flags)
drivers/greybus/cpc/protocol.c +24 -1
@@ -14,7 +14,7 @@ static bool cpc_skb_is_sequenced(struct sk_buff *skb)return CPC_SKB_CB (skb)->cpc_flags &CPC_SKB_FLAG_REQ_ACK ; } -void cpc_protocol_prepare_header (struct sk_buff *skb,u8 ack) +static void cpc_protocol_prepare_header (struct sk_buff *skb,u8 ack) {struct cpc_header *hdr;
@@ -86,3 +86,26 @@ void cpc_protocol_on_data(struct cpc_cport *cport, struct sk_buff *skb)greybus_data_rcvd (cport->cpc_hd->gb_hd, cport->id, skb->data, skb->len); } } + +static void __cpc_protocol_write_skb (struct cpc_cport *cport,struct sk_buff *skb,u8 ack) +{ +cpc_protocol_prepare_header (skb, ack); + +cpc_hd_send_skb (cport->cpc_hd, skb); +} + +/* Write skbs at the head of holding queue */ +void __cpc_protocol_write_head (struct cpc_cport *cport) +{ +struct sk_buff *skb; +u8 ack; + + ack = cport->tcb.ack; + +/* For each SKB in the holding queue, clone it and pass it to lower layer */ +while ((skb =skb_peek (&cport->holding_queue))) { +skb_unlink (skb, &cport->holding_queue); + +__cpc_protocol_write_skb (cport, skb, ack); + } +}
Signature · 1 line
2.52.0
kernel test robot
build botRe: [PATCH v3 10/14] greybus: cpc: use holding queue instead of sending out immediately
kernel test robot noticed the following build errors:
Hi Damien,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.19 next-20260212]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Damien-Ri-gel/greybus-cpc-add-minimal-CPC-Host-Device-infrastructure/20260212-232259 base: linus/master patch link: https://lore.kernel.org/r/20260212144352.93043-11-damien.riegel%40silabs.com patch subject: [PATCH v3 10/14] greybus: cpc: use holding queue instead of sending out immediately config: arm-randconfig-r133-20260213 (https://download.01.org/0day-ci/archive/20260213/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.4.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
ERROR: modpost: "skb_put" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_queue_purge_reason" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "__alloc_skb" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_pull" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "sk_skb_reason_drop" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_push" [drivers/greybus/cpc/gb-cpc.ko] undefined!
>> ERROR: modpost: "skb_unlink" [drivers/greybus/cpc/gb-cpc.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 11/14 greybus: cpc: honour remote's RX window
In reply to Damien RiégelThe RX window indicates how many reception buffers the peer has available for that cport. The other peer must not send more messages than that window, or the chances of those messages being lost is very high, leading to retransmissions and poor performance.
The RX window is associated with the ack number, and indicates the valid range of sequence number the other peer can use:
Ack RX window Valid Sequence Range X 0 None X 1 X X 2 X -> X+1
So everytime an ack is received, the driver evaluates if the valid sequence range has changed and if so pops message from its holding queue.
SKBs used to be passed directly to the driver for transmission. Now SBKs still need to be passed to driver for transmission, but CPC also needs to keep track of them, to be able to trigger a retransmission if they are not acked in a timely manner. As SKBs cannot be in two lists at the same time, drivers now get cloned SKBs.
---
Changes in v2:
- fix documentation of cpc_header_number_in_window which documented a unexisting parameter end
- simplify implementation of cpc_header_get_frames_acked_count
drivers/greybus/cpc/cpc.h | 9 ++++ drivers/greybus/cpc/cport.c | 5 +++ drivers/greybus/cpc/header.c | 78 ++++++++++++++++++++++++++++++++++ drivers/greybus/cpc/header.h | 6 +++ drivers/greybus/cpc/host.c | 9 ---- drivers/greybus/cpc/host.h | 1 - drivers/greybus/cpc/protocol.c | 71 ++++++++++++++++++++++++++++--- 7 files changed, 163 insertions(+), 16 deletions(-)
drivers/greybus/cpc/cpc.h +9 -0
@@ -18,6 +18,7 @@* @cpc_hd: pointer to the CPC host device this cport belongs to * @lock: mutex to synchronize accesses to tcb and other attributes * @holding_queue: list of frames queued to be sent +* @retx_queue: list of frames sent and waiting for acknowledgment * @tcb: Transmission Control Block */ struct cpc_cport {
@@ -27,12 +28,20 @@ struct cpc_cport {struct mutex lock;/* Synchronize access to state variables */ struct sk_buff_head holding_queue; +struct sk_buff_head retx_queue;/* +* @send_wnd: send window, maximum number of frames that the remote can accept. +* TX frames should have a sequence in the range [send_una; send_una + send_wnd] +* @send_nxt: send next, the next sequence number that will be used for transmission +* @send_una: send unacknowledged, the oldest unacknowledged sequence number * @ack: current acknowledge number * @seq: current sequence number */ struct { +u8 send_wnd; +u8 send_nxt; +u8 send_una;u8 ack;u8 seq; } tcb;
drivers/greybus/cpc/cport.c +5 -0
@@ -16,6 +16,9 @@ static void cpc_cport_tcb_reset(struct cpc_cport *cport) { cport->tcb.ack =0 ; cport->tcb.seq =0 ; + cport->tcb.send_nxt =0 ; + cport->tcb.send_una =0 ; + cport->tcb.send_wnd =1 ; }/**
@@ -38,12 +41,14 @@ struct cpc_cport *cpc_cport_alloc(u16 cport_id, gfp_t gfp_mask)mutex_init (&cport->lock);skb_queue_head_init (&cport->holding_queue); +skb_queue_head_init (&cport->retx_queue);return cport; }void cpc_cport_release (struct cpc_cport *cport) { +skb_queue_purge (&cport->retx_queue);skb_queue_purge (&cport->holding_queue);kfree (cport); }
drivers/greybus/cpc/header.c +78 -0
93 lines not on this page · raw message
drivers/greybus/cpc/header.h +6 -0
@@ -39,8 +39,14 @@ struct cpc_header { } __packed;bool cpc_header_is_control (const struct cpc_header *hdr); +u8 cpc_header_get_recv_wnd (const struct cpc_header *hdr);u8 cpc_header_get_seq (const struct cpc_header *hdr); +u8 cpc_header_get_ack (const struct cpc_header *hdr);bool cpc_header_get_req_ack (const struct cpc_header *hdr);u8 cpc_header_encode_ctrl_flags (bool control,bool req_ack); +u8 cpc_header_get_frames_acked_count (u8 seq,u8 ack); +bool cpc_header_number_in_window (u8 start,u8 wnd,u8 n); +bool cpc_header_number_in_range (u8 start,u8 end,u8 n); +#endif
drivers/greybus/cpc/host.c +0 -9
@@ -205,15 +205,6 @@ void cpc_hd_del(struct cpc_host_device *cpc_hd) }EXPORT_SYMBOL_GPL (cpc_hd_del); -void cpc_hd_message_sent (struct sk_buff *skb,int status) -{ -struct cpc_host_device *cpc_hd =CPC_SKB_CB (skb)->cport->cpc_hd; -struct gb_host_device *hd = cpc_hd->gb_hd; - -greybus_message_sent (hd,CPC_SKB_CB (skb)->gb_message, status); -} -EXPORT_SYMBOL_GPL (cpc_hd_message_sent); -void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb) {struct gb_operation_msg_hdr *gb_hdr;
drivers/greybus/cpc/host.h +0 -1
@@ -46,7 +46,6 @@ int cpc_hd_add(struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd);void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb); -void cpc_hd_message_sent (struct sk_buff *skb,int status);int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb);
drivers/greybus/cpc/protocol.c +65 -6
124 lines not on this page · raw message
Signature · 1 line
2.52.0
kernel test robot
build botRe: [PATCH v3 11/14] greybus: cpc: honour remote's RX window
kernel test robot noticed the following build errors:
Hi Damien,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.19 next-20260213]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Damien-Ri-gel/greybus-cpc-add-minimal-CPC-Host-Device-infrastructure/20260212-232259 base: linus/master patch link: https://lore.kernel.org/r/20260212144352.93043-12-damien.riegel%40silabs.com patch subject: [PATCH v3 11/14] greybus: cpc: honour remote's RX window config: arm-randconfig-r133-20260213 (https://download.01.org/0day-ci/archive/20260214/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.4.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260214/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
ERROR: modpost: "skb_put" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_dequeue" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_queue_purge_reason" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "__alloc_skb" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_queue_tail" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_pull" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "sk_skb_reason_drop" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_push" [drivers/greybus/cpc/gb-cpc.ko] undefined!
ERROR: modpost: "skb_unlink" [drivers/greybus/cpc/gb-cpc.ko] undefined!
>> ERROR: modpost: "skb_clone" [drivers/greybus/cpc/gb-cpc.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 12/14 greybus: cpc: let host device drivers dequeue TX frames
In reply to Damien RiégelThis lets the CPC host device drivers dequeue frames when it's convenient for them to do so, instead of forcing each to them to implement a queue to store pending skbs.
The callback is changed from transmit to wake_tx and let CPC core notify these drivers when there is something to transmit.
--- drivers/greybus/cpc/host.c | 74 ++++++++++++++++++++++++++++++++++++-- drivers/greybus/cpc/host.h | 12 +++++-- 2 files changed, 81 insertions(+), 5 deletions(-)
drivers/greybus/cpc/host.c +71 -3
@@ -161,6 +161,7 @@ static struct gb_hd_driver cpc_gb_driver = {static void cpc_hd_init (struct cpc_host_device *cpc_hd) {mutex_init (&cpc_hd->lock); +skb_queue_head_init (&cpc_hd->tx_queue); }struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent)
@@ -168,7 +169,7 @@ struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct devicstruct cpc_host_device *cpc_hd;struct gb_host_device *hd; -if (!driver->transmit) { +if (!driver->wake_tx) {dev_err (parent,"missing mandatory callback\n" );return ERR_PTR (-EINVAL ); }
@@ -237,13 +238,80 @@ EXPORT_SYMBOL_GPL(cpc_hd_rcvd);* @cpc_hd: Host device to send SKB over. * @skb: SKB to send. */ -int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb) +void cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb) {const struct cpc_hd_driver *drv = cpc_hd->driver; -return drv->transmit (cpc_hd, skb); +mutex_lock (&cpc_hd->lock); +skb_queue_tail (&cpc_hd->tx_queue, skb); +mutex_unlock (&cpc_hd->lock); + + drv->wake_tx (cpc_hd); } +/** +* cpc_hd_tx_queue_empty() - Check if transmit queue is empty. +* @cpc_hd: CPC Host Device. +* +* Return: True if transmit queue is empty, false otherwise. +*/ +bool cpc_hd_tx_queue_empty (struct cpc_host_device *cpc_hd) +{ +bool empty; + +mutex_lock (&cpc_hd->lock); + empty =skb_queue_empty (&cpc_hd->tx_queue); +mutex_unlock (&cpc_hd->lock); + +return empty; +} +EXPORT_SYMBOL_GPL (cpc_hd_tx_queue_empty); + +/** +* cpc_hd_dequeue() - Get the next SKB that was queued for transmission. +* @cpc_hd: CPC Host Device. +* +* Get an SKB that was previously queued by cpc_hd_send_skb(). +* +* Return: An SKB, or %NULL if queue was empty. +*/ +struct sk_buff *cpc_hd_dequeue (struct cpc_host_device *cpc_hd) +{ +struct sk_buff *skb; + +mutex_lock (&cpc_hd->lock); + skb =skb_dequeue (&cpc_hd->tx_queue); +mutex_unlock (&cpc_hd->lock); + +return skb; +} +EXPORT_SYMBOL_GPL (cpc_hd_dequeue); + +/** +* cpc_hd_dequeue_many() - Get the next max_frames SKBs that were queued for transmission. +* @cpc_hd: CPC host device. +* @frame_list: Caller-provided sk_buff_head to fill with dequeued frames. +* @max_frames: Maximum number of frames to dequeue. +* +* Return: Number of frames actually dequeued. +*/ +u32 cpc_hd_dequeue_many (struct cpc_host_device *cpc_hd,struct sk_buff_head *frame_list, +unsigned int max_frames) +{ +struct sk_buff *skb; +unsigned int count =0 ; + +mutex_lock (&cpc_hd->lock); +while (count < max_frames && (skb =skb_dequeue (&cpc_hd->tx_queue))) { +skb_queue_tail (frame_list, skb); + count++; + } +mutex_unlock (&cpc_hd->lock); + +return count; +} +EXPORT_SYMBOL_GPL (cpc_hd_dequeue_many); +MODULE_DESCRIPTION ("Greybus over CPC" );MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Silicon Laboratories, Inc." );
drivers/greybus/cpc/host.h +10 -2
@@ -9,6 +9,7 @@#include <linux/device.h> #include <linux/greybus.h> #include <linux/mutex.h> +#include <linux/skbuff.h> #include <linux/types.h> #define GB_CPC_MSG_SIZE_MAX 4096
@@ -18,7 +19,7 @@ struct cpc_cport;struct cpc_host_device ;struct cpc_hd_driver { -int (*transmit)(struct cpc_host_device *hd,struct sk_buff *skb); +int (*wake_tx)(struct cpc_host_device *cpc_hd); };/**
@@ -34,6 +35,8 @@ struct cpc_host_device {struct mutex lock;/* Synchronize access to cports */ struct cpc_cport *cports[GB_CPC_NUM_CPORTS ]; + +struct sk_buff_head tx_queue; };static inline struct device *cpc_hd_dev (struct cpc_host_device *cpc_hd)
@@ -47,6 +50,11 @@ void cpc_hd_put(struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd);void cpc_hd_rcvd (struct cpc_host_device *cpc_hd,struct sk_buff *skb); -int cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb); +void cpc_hd_send_skb (struct cpc_host_device *cpc_hd,struct sk_buff *skb); + +bool cpc_hd_tx_queue_empty (struct cpc_host_device *cpc_hd); +struct sk_buff *cpc_hd_dequeue (struct cpc_host_device *cpc_hd); +u32 cpc_hd_dequeue_many (struct cpc_host_device *cpc_hd,struct sk_buff_head *frame_list, +unsigned int max_frames);#endif
Signature · 1 line
2.52.0
PATCH v3 13/14 greybus: cpc: add private data pointer in CPC Host Device
In reply to Damien RiégelAdd a private data pointer when creating a CPC Host Device. This lets the host device drivers get back their context more easily in the callbacks.
--- drivers/greybus/cpc/host.c | 4 +++- drivers/greybus/cpc/host.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/greybus/cpc/host.c +3 -1
@@ -164,7 +164,8 @@ static void cpc_hd_init(struct cpc_host_device *cpc_hd)skb_queue_head_init (&cpc_hd->tx_queue); } -struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent) +struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent, +void *priv) {struct cpc_host_device *cpc_hd;struct gb_host_device *hd;
@@ -181,6 +182,7 @@ struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct devic cpc_hd =gb_hd_to_cpc_hd (hd); cpc_hd->gb_hd = hd; cpc_hd->driver = driver; + cpc_hd->priv = priv;cpc_hd_init (cpc_hd);
drivers/greybus/cpc/host.h +4 -1
@@ -37,6 +37,8 @@ struct cpc_host_device {struct cpc_cport *cports[GB_CPC_NUM_CPORTS ];struct sk_buff_head tx_queue; + +void *priv; };static inline struct device *cpc_hd_dev (struct cpc_host_device *cpc_hd)
@@ -44,7 +46,8 @@ static inline struct device *cpc_hd_dev(struct cpc_host_device *cpc_hd)return &cpc_hd->gb_hd->dev; } -struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent); +struct cpc_host_device *cpc_hd_create (struct cpc_hd_driver *driver,struct device *parent, +void *priv);int cpc_hd_add (struct cpc_host_device *cpc_hd);void cpc_hd_put (struct cpc_host_device *cpc_hd);void cpc_hd_del (struct cpc_host_device *cpc_hd);
Signature · 1 line
2.52.0
PATCH v3 14/14 greybus: cpc: add CPC SDIO host driver
In reply to Damien RiégelFrom: Gabriel Beaulieu <[email protected]>
This introduces a new module gb-cpc-sdio, in order to communicate with a Greybus CPC device over SDIO.
Most of the complexity stems from aggregation: packets are aggregated to minimize the number of CMD53s. In the first block, the first le32 is the number of packets in this transfer. Immediately after that are all the packet headers (CPC + Greybus). This lets the device process all the headers in a single interrupt, and prepare the ADMA descriptors for all the payloads in one go.
Payloads start at the beginning of the second block and are concatained. Their lengths must be 32-bit aligned, so the driver takes care of adding and removing padding if necessary.
---
Changes in v3:
- rework defines to group together address-related defines and remove orphaned value
- remove trivial comments
- all RX and TX are now done from the workqueue. In previous iterations, transfers could either be done from the threaded IRQ or from the workqueue.
- remove erroneous SDIO VID/PID
- remove padding between headers and payloads when aggregating
Changes in v2:
- change formatting from %lu to %zu when printing size_t's
- remove "/**" kernel-doc marker for static functions not actually using the kernel-doc format
- reduce header inclusion list
- use reverse christmas tree variable declarations consistently
- update aggregation functions to try to be more legible
- use define instead of constant value 0x0C for the address where to read the number of bytes the device wants to send
drivers/greybus/cpc/Kconfig | 12 + drivers/greybus/cpc/Makefile | 3 + drivers/greybus/cpc/sdio.c | 480 +++++++++++++++++++++++++++++++++++ 3 files changed, 495 insertions(+) create mode 100644 drivers/greybus/cpc/sdio.c
drivers/greybus/cpc/Kconfig +12 -0
@@ -10,3 +10,15 @@ config GREYBUS_CPC To compile this code as a module, chose M here: the module will be called gb-cpc.ko + +config GREYBUS_CPC_SDIO + tristate "Greybus CPC over SDIO" + depends on GREYBUS_CPC && MMC + help + This driver provides Greybus CPC host support for devices + connected via SDIO interface. + + To compile this driver as a module, choose M here: the module + will be called gb-cpc-sdio. + + If unsure, say N.
drivers/greybus/cpc/Makefile +3 -0
@@ -4,3 +4,6 @@ gb-cpc-y := cport.o header.o host.o protocol.o # CPC core obj-$(CONFIG_GREYBUS_CPC) += gb-cpc.o + +gb-cpc-sdio-y := sdio.o +obj-$(CONFIG_GREYBUS_CPC_SDIO) += gb-cpc-sdio.o
drivers/greybus/cpc/sdio.c new file +480 -0
480 lines not on this page · raw message
Signature · 1 line
2.52.0
kernel test robot
build botRe: [PATCH v3 14/14] greybus: cpc: add CPC SDIO host driver
kernel test robot noticed the following build warnings:
Hi Damien,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.19 next-20260212]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Damien-Ri-gel/greybus-cpc-add-minimal-CPC-Host-Device-infrastructure/20260212-232259 base: linus/master patch link: https://lore.kernel.org/r/20260212144352.93043-15-damien.riegel%40silabs.com patch subject: [PATCH v3 14/14] greybus: cpc: add CPC SDIO host driver config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260213/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/greybus/cpc/sdio.c: In function 'gb_cpc_sdio_tx':
>> drivers/greybus/cpc/sdio.c:286:13: warning: variable 'err' set but not used [-Wunused-but-set-variable]
286 | int err;
| ^~~vim +/err +286 drivers/greybus/cpc/sdio.c
279
280 static int gb_cpc_sdio_tx(struct cpc_sdio *ctx)
281 {
282 struct sk_buff_head frame_list;
283 unsigned char *tx_buff;
284 size_t tx_len;
285 int pkt_sent;
> 286 int err;
287
288 skb_queue_head_init(&frame_list);
289
290 cpc_hd_dequeue_many(ctx->cpc_hd, &frame_list, ctx->max_aggregation);
291
292 if (skb_queue_empty(&frame_list))
293 return 0;
294
295 tx_len = cpc_sdio_build_aggregated_frame(ctx, &frame_list, &tx_buff);
296 if (!tx_len) {
297 dev_err(ctx->dev, "failed to build aggregated frame\n");
298 goto cleanup_frames;
299 }
300
301 sdio_claim_host(ctx->func);
302 err = sdio_writesb(ctx->func, GB_CPC_SDIO_ADDR_FIFO, tx_buff, tx_len);
303 sdio_release_host(ctx->func);
304
305 kfree(tx_buff);
306
307 cleanup_frames:
308 pkt_sent = skb_queue_len(&frame_list);
309 skb_queue_purge(&frame_list);
310
311 return pkt_sent;
312 }
313
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 14/14] greybus: cpc: add CPC SDIO host driver
In reply to Damien RiégelHello Damien,
Quoted 45 lines · On Thursday 12 February 2026 15:43:52 Central European Standard Time Damien…
From: Gabriel Beaulieu <[email protected]>
This introduces a new module gb-cpc-sdio, in order to communicate with a Greybus CPC device over SDIO.
Most of the complexity stems from aggregation: packets are aggregated to minimize the number of CMD53s. In the first block, the first le32 is the number of packets in this transfer. Immediately after that are all the packet headers (CPC + Greybus). This lets the device process all the headers in a single interrupt, and prepare the ADMA descriptors for all the payloads in one go.
Payloads start at the beginning of the second block and are concatained. Their lengths must be 32-bit aligned, so the driver takes care of adding and removing padding if necessary.
Signed-off-by Gabriel Beaulieu <[email protected]>Signed-off-by Damien Riégel <[email protected]>---
Changes in v3:
- rework defines to group together address-related defines and remove orphaned value
- remove trivial comments
- all RX and TX are now done from the workqueue. In previous iterations, transfers could either be done from the threaded IRQ or from the workqueue.
- remove erroneous SDIO VID/PID
- remove padding between headers and payloads when aggregatingChanges in v2:
- change formatting from %lu to %zu when printing size_t's
- remove "/**" kernel-doc marker for static functions not actually using the kernel-doc format
- reduce header inclusion list
- use reverse christmas tree variable declarations consistently
- update aggregation functions to try to be more legible
- use define instead of constant value0x0Cfor the address where to read the number of bytes the device wants to senddrivers/greybus/cpc/Kconfig | 12 + drivers/greybus/cpc/Makefile | 3 + drivers/greybus/cpc/sdio.c | 480 +++++++++++++++++++++++++++++++++++ 3 files changed, 495 insertions(+) create mode 100644 drivers/greybus/cpc/sdio.c
[...]
drivers/greybus/cpc/sdio.c line 460
Quoted 3 lines
drivers/greybus/cpc/sdio.c new file +3
-0+static const struct sdio_device_id sdio_ids[] = { +/* No official ID */ + {SDIO_DEVICE (0x0000 ,0x1000 ), },
Can you provide some details about how it's work? I assume Silabs sells OEM products and each vendor has to set their own VID/PID, that's it?
I assume Silabs also has samples products. How it works for them? Is there a default VID/PID or the sample firmware won't compile until the user changes the VID/PID?
In any case, I believe we can't publish a driver with VID = 0.
(BTW, I suggest to include [email protected] as recipient of this PR).
Signature · 1 line
Jérôme Pouiller
Re: [PATCH v3 14/14] greybus: cpc: add CPC SDIO host driver
Quoted 56 lines · Jérôme Pouiller
Hello Damien,
Quoted 45 lines · On Thursday 12 February 2026 15:43:52 Central European Standard Time Damien…
From: Gabriel Beaulieu <[email protected]>
This introduces a new module gb-cpc-sdio, in order to communicate with a Greybus CPC device over SDIO.
Most of the complexity stems from aggregation: packets are aggregated to minimize the number of CMD53s. In the first block, the first le32 is the number of packets in this transfer. Immediately after that are all the packet headers (CPC + Greybus). This lets the device process all the headers in a single interrupt, and prepare the ADMA descriptors for all the payloads in one go.
Payloads start at the beginning of the second block and are concatained. Their lengths must be 32-bit aligned, so the driver takes care of adding and removing padding if necessary.
Signed-off-by Gabriel Beaulieu <[email protected]>Signed-off-by Damien Riégel <[email protected]>---
Changes in v3:
- rework defines to group together address-related defines and remove orphaned value
- remove trivial comments
- all RX and TX are now done from the workqueue. In previous iterations, transfers could either be done from the threaded IRQ or from the workqueue.
- remove erroneous SDIO VID/PID
- remove padding between headers and payloads when aggregatingChanges in v2:
- change formatting from %lu to %zu when printing size_t's
- remove "/**" kernel-doc marker for static functions not actually using the kernel-doc format
- reduce header inclusion list
- use reverse christmas tree variable declarations consistently
- update aggregation functions to try to be more legible
- use define instead of constant value0x0Cfor the address where to read the number of bytes the device wants to senddrivers/greybus/cpc/Kconfig | 12 + drivers/greybus/cpc/Makefile | 3 + drivers/greybus/cpc/sdio.c | 480 +++++++++++++++++++++++++++++++++++ 3 files changed, 495 insertions(+) create mode 100644 drivers/greybus/cpc/sdio.c[...]
drivers/greybus/cpc/sdio.c line 460
Quoted 3 lines
drivers/greybus/cpc/sdio.c new file +3
-0+static const struct sdio_device_id sdio_ids[] = { +/* No official ID */ + {SDIO_DEVICE (0x0000 ,0x1000 ), },Can you provide some details about how it's work? I assume Silabs sells OEM products and each vendor has to set their own VID/PID, that's it?
Quoted 3 lines
I assume Silabs also has samples products. How it works for them? Is there a default VID/PID or the sample firmware won't compile until the user changes the VID/PID?
That's not something we have defined yet, but I think we could at least define one VID/PID for "Greybus/CPC compatible devices", that every vendor could use if they don't make any changes to the protocol. Each vendor would have to create the manifest based on their products (like enable WiFi for product X, enable WiFi & Bluetooth for product Y).
Quoted 1 line
In any case, I believe we can't publish a driver with VID = 0.
Noted, the patchset can't be applied as is. I'll check what the process is to assign a VID/PID.
Quoted 2 lines
(BTW, I suggest to include [email protected] as recipient of this PR).
I decided to wait a bit to avoid creating noise on linux-mmc, considering this patchset is still in early review phase, but I'll add that list for future versions.
thanks,
damien
Re: [PATCH v3 14/14] greybus: cpc: add CPC SDIO host driver
Quoted 5 lines · Damien Riégel
Quoted 1 line · Jérôme Pouiller
In any case, I believe we can't publish a driver with VID = 0.
Noted, the patchset can't be applied as is. I'll check what the process is to assign a VID/PID.
I'm still trying to figure out internally how I can get a VID/PID for this driver. We thought we had a valid vendor ID we could use, based on a JEDEC ID that we already have assigned, but upon further investigation I don't think we have the right to derive an SDIO VID from that JEDEC ID, so the whole process might take a bit of time.
In the meantime, may I suggest that we continue the review as if a valid VID/PID was assigned? You can keep your "Reviewed-by" until we actually have valid IDs. If we have to get in touch with external organizations, it might take a few weeks or even months to get sorted, I have no idea how long that process will be.
Alternatively, I could just drop the SDIO VID/PID and just rely on device tree instead? That leaves the question of what the compatible string should be. Rob Herring doesn't want a generic "silabs,greybus" string, it must be a real product and we don't have that yet.
I'd be happy to take any input that helps make progress :)
thanks,
damien