Skip to contentSkip to conversation

mctp: Add MCTP-over-USB hardware transport binding

PATCH Applied Jeremy Kerr 2 participants 4 messages Feb 21, 2025 – Feb 22, 2025

Subsystems (4)
lore
Share & tools
lore

Jeremy Kerr

author maintainer
#0 lore raw

v3 cover mctp: Add MCTP-over-USB hardware transport binding

Add an implementation of the DMTF standard DSP0283, providing an MCTP channel over high-speed USB.

This is a fairly trivial first implementation, in that we only submit one tx and one rx URB at a time. We do accept multi-packet transfers, but do not yet generate them on transmit.

Of course, questions and comments are most welcome, particularly on the USB interfaces.

---
Changes in v3:
- Use GPL2 consistently, rather that 2+
- Changes from Jakub Kicinsk: u8 over __u8
- Changes from Jakub Kicinsk: use dstats helpers
- Changes from Jakub Kicinsk: skb_cow_head before skb_push
- recovery mechanism for rx alloc
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- greg k-h claims that it is 2025; update copyright year
- Add spec references
- Clean up dbg/warn output
- Changes from Oliver Neukum: drop usbdev ref, avoid a GFP_ATOMIC alloc
- Changes from Simon Horman: do rx stats before netif_rx
- Add module metadata
- specify phys binding type
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeremy Kerr (2):
usb: Add base USB MCTP definitions
net: mctp: Add MCTP USB transport driver

 MAINTAINERS                  |   1 +
 drivers/net/mctp/Kconfig     |  10 ++
 drivers/net/mctp/Makefile    |   1 +
 drivers/net/mctp/mctp-usb.c  | 385 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/mctp-usb.h |  30 ++++
 include/uapi/linux/usb/ch9.h |   1 +
 6 files changed, 428 insertions(+)

---
base-commit: be1d2a1b151deb195cd9749988163aa26ad6f616
change-id: 20250206-dev-mctp-usb-c59dea025395

Best regards,

Signature · 1 line
Jeremy Kerr <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/2 usb: Add base USB MCTP definitions

Upcoming changes will add a USB host (and later gadget) driver for the MCTP-over-USB protocol. Add a header that provides common definitions for protocol support: the packet header format and a few framing definitions. Add a define for the MCTP class code, as per
https://usb.org/defined-class-codes.

---
v3:
- __u8 -> u8
- GPL-2 rather than 2+
v2:
- add reference & URL to DSP0283
- update copyright year

---
 MAINTAINERS                  |  1 +
 include/linux/usb/mctp-usb.h | 30 ++++++++++++++++++++++++++++++
 include/uapi/linux/usb/ch9.h |  1 +
 3 files changed, 32 insertions(+)
MAINTAINERS +1 -0
index 67665d9dd536..e7b326dba9a9 100644
@@ -13903,6 +13903,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/networking/mctp.rst
 F:	drivers/net/mctp/
+F:	include/linux/usb/mctp-usb.h
 F:	include/net/mctp.h
 F:	include/net/mctpdevice.h
 F:	include/net/netns/mctp.h
include/linux/usb/mctp-usb.h new file +30 -0
new file mode 100644
index 000000000000..a2f6f1e04efb
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mctp-usb.h - MCTP USB transport binding: common definitions,
+ * based on DMTF0283 specification:
+ * https://www.dmtf.org/sites/default/files/standards/documents/DSP0283_1.0.1.pdf
+ *
+ * These are protocol-level definitions, that may be shared between host
+ * and gadget drivers.
+ *
+ * Copyright (C) 2024-2025 Code Construct Pty Ltd
+ */
+
+#ifndef __LINUX_USB_MCTP_USB_H
+#define __LINUX_USB_MCTP_USB_H
+
+#include <linux/types.h>
+
+struct mctp_usb_hdr {
+	__be16	id;
+	u8	rsvd;
+	u8	len;
+} __packed;
+
+#define MCTP_USB_XFER_SIZE	512
+#define MCTP_USB_BTU		68
+#define MCTP_USB_MTU_MIN	MCTP_USB_BTU
+#define MCTP_USB_MTU_MAX	(U8_MAX - sizeof(struct mctp_usb_hdr))
+#define MCTP_USB_DMTF_ID	0x1ab4
+
+#endif /*  __LINUX_USB_MCTP_USB_H */
include/uapi/linux/usb/ch9.h +1 -0
index 91f0f7e214a5..052290652046 100644
@@ -330,6 +330,7 @@ struct usb_device_descriptor {
 #define USB_CLASS_AUDIO_VIDEO		0x10
 #define USB_CLASS_BILLBOARD		0x11
 #define USB_CLASS_USB_TYPE_C_BRIDGE	0x12
+#define USB_CLASS_MCTP			0x14
 #define USB_CLASS_MISC			0xef
 #define USB_CLASS_APP_SPEC		0xfe
 #define USB_SUBCLASS_DFU			0x01
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH v3 2/2 net: mctp: Add MCTP USB transport driver

In reply to Jeremy Kerr

Add an implementation for DMTF DSP0283, which defines a MCTP-over-USB transport. As per that spec, we're restricted to full speed mode, requiring 512-byte transfers.

Each MCTP-over-USB interface is a peer-to-peer link to a single MCTP endpoint, so no physical addressing is required (of course, that MCTP endpoint may then bridge to further MCTP endpoints). Consequently, interfaces will report with no lladdr data:

    # mctp link
    dev lo index 1 address 00:00:00:00:00:00 net 1 mtu 65536 up
    dev mctpusb0 index 6 address none net 1 mtu 68 up

This is a simple initial implementation, with single rx & tx urbs, and no multi-packet tx transfers - although we do accept multi-packet rx from the device.

Includes suggested fixes from Santosh Puranik <[email protected]>.

Cc Santosh Puranik <[email protected]>

---
v3:
- implement recovery on rx alloc failure
- GPL-2+ -> GPL-2
- __u8 -> u8
- use existing dstats helper
- remove unnecessary zero inits for dev->priv data
v2:
- update copyright year to 2025
- improve dbg messages: use netdev, demote from _err, remove __func__
- pass gfp_t to mctp_usb_rx_queue, allocate first as GFP_KERNEL
- release ->usbdev on disconnect
- include MODULE_{DESCRIPTION,AUTHOR,DEVICE_TABLE}
- more sensible driver->name
- do rx stats update before netif_rx()
- specify phys binding type via mctp_register_netdev()

---
 drivers/net/mctp/Kconfig    |  10 ++
 drivers/net/mctp/Makefile   |   1 +
 drivers/net/mctp/mctp-usb.c | 385 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 396 insertions(+)
drivers/net/mctp/Kconfig +10 -0
index 15860d6ac39f..cf325ab0b1ef 100644
@@ -47,6 +47,16 @@ config MCTP_TRANSPORT_I3C
 	  A MCTP protocol network device is created for each I3C bus
 	  having a "mctp-controller" devicetree property.
 
+config MCTP_TRANSPORT_USB
+	tristate "MCTP USB transport"
+	depends on USB
+	help
+	  Provides a driver to access MCTP devices over USB transport,
+	  defined by DMTF specification DSP0283.
+
+	  MCTP-over-USB interfaces are peer-to-peer, so each interface
+	  represents a physical connection to one remote MCTP endpoint.
+
 endmenu
 
 endif
drivers/net/mctp/Makefile +1 -0
index e1cb99ced54a..c36006849a1e 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_MCTP_SERIAL) += mctp-serial.o
 obj-$(CONFIG_MCTP_TRANSPORT_I2C) += mctp-i2c.o
 obj-$(CONFIG_MCTP_TRANSPORT_I3C) += mctp-i3c.o
+obj-$(CONFIG_MCTP_TRANSPORT_USB) += mctp-usb.o
drivers/net/mctp/mctp-usb.c new file +385 -0

385 lines not on this page · raw message

Signature · 1 line
2.39.5
#3 lore raw
In reply to Jeremy Kerr
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 21 Feb 2025 08:56:56 +0800 you wrote:

Add an implementation of the DMTF standard DSP0283, providing an MCTP channel over high-speed USB.

This is a fairly trivial first implementation, in that we only submit one tx and one rx URB at a time. We do accept multi-packet transfers, but do not yet generate them on transmit.

[...]

Here is the summary with links:
- [net-next,v3,1/2] usb: Add base USB MCTP definitions

    https://git.kernel.org/netdev/net-next/c/dcc35baae732
  - [net-next,v3,2/2] net: mctp: Add MCTP USB transport driver
    https://git.kernel.org/netdev/net-next/c/0791c0327a6e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html