* [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
@ 2025-04-27 15:30 Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 1/3] usb: Add base USB MCTP definitions Santosh Puranik
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-04-27 15:30 UTC (permalink / raw)
To: openbmc, joel, andrew, jk
This series backports the MCTP over USB binding driver and associated
definitions.
Patches 1 and 2 were cherry-picked from upstream linux master and
patch 3 includes fixes needed to backport the binding to 6.6.
This was tested against NVIDIA BMC (machine gb200nvl-obmc) running
on ASPEED AST2600.
Jeremy Kerr (2):
usb: Add base USB MCTP definitions
net: mctp: Add MCTP USB transport driver
Santosh Puranik (1):
drivers: net: mctp: usb: Port for kernel 6.6
MAINTAINERS | 1 +
drivers/net/mctp/Kconfig | 10 +
drivers/net/mctp/Makefile | 1 +
drivers/net/mctp/mctp-usb.c | 387 +++++++++++++++++++++++++++++++++++
include/linux/usb/mctp-usb.h | 30 +++
include/uapi/linux/usb/ch9.h | 1 +
6 files changed, 430 insertions(+)
create mode 100644 drivers/net/mctp/mctp-usb.c
create mode 100644 include/linux/usb/mctp-usb.h
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH linux dev-6.6 1/3] usb: Add base USB MCTP definitions
2025-04-27 15:30 [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Santosh Puranik
@ 2025-04-27 15:30 ` Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 2/3] net: mctp: Add MCTP USB transport driver Santosh Puranik
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-04-27 15:30 UTC (permalink / raw)
To: openbmc, joel, andrew, jk
From: Jeremy Kerr <jk@codeconstruct.com.au>
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.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20250221-dev-mctp-usb-v3-1-3353030fe9cc@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit dcc35baae732b9079b2c6595cfd86da02b34a4e6)
Signed-off-by: Santosh Puranik <santosh.puranik.ibm@gmail.com>
---
MAINTAINERS | 1 +
include/linux/usb/mctp-usb.h | 30 ++++++++++++++++++++++++++++++
include/uapi/linux/usb/ch9.h | 1 +
3 files changed, 32 insertions(+)
create mode 100644 include/linux/usb/mctp-usb.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 6afbb4f7b33c..5da10b86be0b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12647,6 +12647,7 @@ L: netdev@vger.kernel.org
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
diff --git a/include/linux/usb/mctp-usb.h b/include/linux/usb/mctp-usb.h
new file mode 100644
index 000000000000..a2f6f1e04efb
--- /dev/null
+++ b/include/linux/usb/mctp-usb.h
@@ -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 */
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index 8a147abfc680..dce954da45ac 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -327,6 +327,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_CLASS_VENDOR_SPEC 0xff
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH linux dev-6.6 2/3] net: mctp: Add MCTP USB transport driver
2025-04-27 15:30 [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 1/3] usb: Add base USB MCTP definitions Santosh Puranik
@ 2025-04-27 15:30 ` Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6 Santosh Puranik
2025-04-28 1:43 ` [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Jeremy Kerr
3 siblings, 0 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-04-27 15:30 UTC (permalink / raw)
To: openbmc, joel, andrew, jk
From: Jeremy Kerr <jk@codeconstruct.com.au>
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 <spuranik@nvidia.com>.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Santosh Puranik <spuranik@nvidia.com>
Link: https://patch.msgid.link/20250221-dev-mctp-usb-v3-2-3353030fe9cc@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 0791c0327a6e4e7691d6fc5ad334c215de04dcc9)
Signed-off-by: Santosh Puranik <santosh.puranik.ibm@gmail.com>
---
drivers/net/mctp/Kconfig | 10 +
drivers/net/mctp/Makefile | 1 +
drivers/net/mctp/mctp-usb.c | 385 ++++++++++++++++++++++++++++++++++++
3 files changed, 396 insertions(+)
create mode 100644 drivers/net/mctp/mctp-usb.c
diff --git a/drivers/net/mctp/Kconfig b/drivers/net/mctp/Kconfig
index ce9d2d2ccf3b..569cb5cfba62 100644
--- a/drivers/net/mctp/Kconfig
+++ b/drivers/net/mctp/Kconfig
@@ -42,6 +42,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
diff --git a/drivers/net/mctp/Makefile b/drivers/net/mctp/Makefile
index e1cb99ced54a..c36006849a1e 100644
--- a/drivers/net/mctp/Makefile
+++ b/drivers/net/mctp/Makefile
@@ -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
diff --git a/drivers/net/mctp/mctp-usb.c b/drivers/net/mctp/mctp-usb.c
new file mode 100644
index 000000000000..e8d4b01c3f34
--- /dev/null
+++ b/drivers/net/mctp/mctp-usb.c
@@ -0,0 +1,385 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * mctp-usb.c - MCTP-over-USB (DMTF DSP0283) transport binding driver.
+ *
+ * DSP0283 is available at:
+ * https://www.dmtf.org/sites/default/files/standards/documents/DSP0283_1.0.1.pdf
+ *
+ * Copyright (C) 2024-2025 Code Construct Pty Ltd
+ */
+
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/usb.h>
+#include <linux/usb/mctp-usb.h>
+
+#include <net/mctp.h>
+#include <net/mctpdevice.h>
+#include <net/pkt_sched.h>
+
+#include <uapi/linux/if_arp.h>
+
+struct mctp_usb {
+ struct usb_device *usbdev;
+ struct usb_interface *intf;
+ bool stopped;
+
+ struct net_device *netdev;
+
+ u8 ep_in;
+ u8 ep_out;
+
+ struct urb *tx_urb;
+ struct urb *rx_urb;
+
+ struct delayed_work rx_retry_work;
+};
+
+static void mctp_usb_out_complete(struct urb *urb)
+{
+ struct sk_buff *skb = urb->context;
+ struct net_device *netdev = skb->dev;
+ int status;
+
+ status = urb->status;
+
+ switch (status) {
+ case -ENOENT:
+ case -ECONNRESET:
+ case -ESHUTDOWN:
+ case -EPROTO:
+ dev_dstats_tx_dropped(netdev);
+ break;
+ case 0:
+ dev_dstats_tx_add(netdev, skb->len);
+ netif_wake_queue(netdev);
+ consume_skb(skb);
+ return;
+ default:
+ netdev_dbg(netdev, "unexpected tx urb status: %d\n", status);
+ dev_dstats_tx_dropped(netdev);
+ }
+
+ kfree_skb(skb);
+}
+
+static netdev_tx_t mctp_usb_start_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ struct mctp_usb *mctp_usb = netdev_priv(dev);
+ struct mctp_usb_hdr *hdr;
+ unsigned int plen;
+ struct urb *urb;
+ int rc;
+
+ plen = skb->len;
+
+ if (plen + sizeof(*hdr) > MCTP_USB_XFER_SIZE)
+ goto err_drop;
+
+ rc = skb_cow_head(skb, sizeof(*hdr));
+ if (rc)
+ goto err_drop;
+
+ hdr = skb_push(skb, sizeof(*hdr));
+ if (!hdr)
+ goto err_drop;
+
+ hdr->id = cpu_to_be16(MCTP_USB_DMTF_ID);
+ hdr->rsvd = 0;
+ hdr->len = plen + sizeof(*hdr);
+
+ urb = mctp_usb->tx_urb;
+
+ usb_fill_bulk_urb(urb, mctp_usb->usbdev,
+ usb_sndbulkpipe(mctp_usb->usbdev, mctp_usb->ep_out),
+ skb->data, skb->len,
+ mctp_usb_out_complete, skb);
+
+ rc = usb_submit_urb(urb, GFP_ATOMIC);
+ if (rc)
+ goto err_drop;
+ else
+ netif_stop_queue(dev);
+
+ return NETDEV_TX_OK;
+
+err_drop:
+ dev_dstats_tx_dropped(dev);
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+}
+
+static void mctp_usb_in_complete(struct urb *urb);
+
+/* If we fail to queue an in urb atomically (either due to skb allocation or
+ * urb submission), we will schedule a rx queue in nonatomic context
+ * after a delay, specified in jiffies
+ */
+static const unsigned long RX_RETRY_DELAY = HZ / 4;
+
+static int mctp_usb_rx_queue(struct mctp_usb *mctp_usb, gfp_t gfp)
+{
+ struct sk_buff *skb;
+ int rc;
+
+ skb = __netdev_alloc_skb(mctp_usb->netdev, MCTP_USB_XFER_SIZE, gfp);
+ if (!skb) {
+ rc = -ENOMEM;
+ goto err_retry;
+ }
+
+ usb_fill_bulk_urb(mctp_usb->rx_urb, mctp_usb->usbdev,
+ usb_rcvbulkpipe(mctp_usb->usbdev, mctp_usb->ep_in),
+ skb->data, MCTP_USB_XFER_SIZE,
+ mctp_usb_in_complete, skb);
+
+ rc = usb_submit_urb(mctp_usb->rx_urb, gfp);
+ if (rc) {
+ netdev_dbg(mctp_usb->netdev, "rx urb submit failure: %d\n", rc);
+ kfree_skb(skb);
+ if (rc == -ENOMEM)
+ goto err_retry;
+ }
+
+ return rc;
+
+err_retry:
+ schedule_delayed_work(&mctp_usb->rx_retry_work, RX_RETRY_DELAY);
+ return rc;
+}
+
+static void mctp_usb_in_complete(struct urb *urb)
+{
+ struct sk_buff *skb = urb->context;
+ struct net_device *netdev = skb->dev;
+ struct mctp_usb *mctp_usb = netdev_priv(netdev);
+ struct mctp_skb_cb *cb;
+ unsigned int len;
+ int status;
+
+ status = urb->status;
+
+ switch (status) {
+ case -ENOENT:
+ case -ECONNRESET:
+ case -ESHUTDOWN:
+ case -EPROTO:
+ kfree_skb(skb);
+ return;
+ case 0:
+ break;
+ default:
+ netdev_dbg(netdev, "unexpected rx urb status: %d\n", status);
+ kfree_skb(skb);
+ return;
+ }
+
+ len = urb->actual_length;
+ __skb_put(skb, len);
+
+ while (skb) {
+ struct sk_buff *skb2 = NULL;
+ struct mctp_usb_hdr *hdr;
+ u8 pkt_len; /* length of MCTP packet, no USB header */
+
+ hdr = skb_pull_data(skb, sizeof(*hdr));
+ if (!hdr)
+ break;
+
+ if (be16_to_cpu(hdr->id) != MCTP_USB_DMTF_ID) {
+ netdev_dbg(netdev, "rx: invalid id %04x\n",
+ be16_to_cpu(hdr->id));
+ break;
+ }
+
+ if (hdr->len <
+ sizeof(struct mctp_hdr) + sizeof(struct mctp_usb_hdr)) {
+ netdev_dbg(netdev, "rx: short packet (hdr) %d\n",
+ hdr->len);
+ break;
+ }
+
+ /* we know we have at least sizeof(struct mctp_usb_hdr) here */
+ pkt_len = hdr->len - sizeof(struct mctp_usb_hdr);
+ if (pkt_len > skb->len) {
+ netdev_dbg(netdev,
+ "rx: short packet (xfer) %d, actual %d\n",
+ hdr->len, skb->len);
+ break;
+ }
+
+ if (pkt_len < skb->len) {
+ /* more packets may follow - clone to a new
+ * skb to use on the next iteration
+ */
+ skb2 = skb_clone(skb, GFP_ATOMIC);
+ if (skb2) {
+ if (!skb_pull(skb2, pkt_len)) {
+ kfree_skb(skb2);
+ skb2 = NULL;
+ }
+ }
+ skb_trim(skb, pkt_len);
+ }
+
+ dev_dstats_rx_add(netdev, skb->len);
+
+ skb->protocol = htons(ETH_P_MCTP);
+ skb_reset_network_header(skb);
+ cb = __mctp_cb(skb);
+ cb->halen = 0;
+ netif_rx(skb);
+
+ skb = skb2;
+ }
+
+ if (skb)
+ kfree_skb(skb);
+
+ mctp_usb_rx_queue(mctp_usb, GFP_ATOMIC);
+}
+
+static void mctp_usb_rx_retry_work(struct work_struct *work)
+{
+ struct mctp_usb *mctp_usb = container_of(work, struct mctp_usb,
+ rx_retry_work.work);
+
+ if (READ_ONCE(mctp_usb->stopped))
+ return;
+
+ mctp_usb_rx_queue(mctp_usb, GFP_KERNEL);
+}
+
+static int mctp_usb_open(struct net_device *dev)
+{
+ struct mctp_usb *mctp_usb = netdev_priv(dev);
+
+ WRITE_ONCE(mctp_usb->stopped, false);
+
+ return mctp_usb_rx_queue(mctp_usb, GFP_KERNEL);
+}
+
+static int mctp_usb_stop(struct net_device *dev)
+{
+ struct mctp_usb *mctp_usb = netdev_priv(dev);
+
+ netif_stop_queue(dev);
+
+ /* prevent RX submission retry */
+ WRITE_ONCE(mctp_usb->stopped, true);
+
+ usb_kill_urb(mctp_usb->rx_urb);
+ usb_kill_urb(mctp_usb->tx_urb);
+
+ cancel_delayed_work_sync(&mctp_usb->rx_retry_work);
+
+ return 0;
+}
+
+static const struct net_device_ops mctp_usb_netdev_ops = {
+ .ndo_start_xmit = mctp_usb_start_xmit,
+ .ndo_open = mctp_usb_open,
+ .ndo_stop = mctp_usb_stop,
+};
+
+static void mctp_usb_netdev_setup(struct net_device *dev)
+{
+ dev->type = ARPHRD_MCTP;
+
+ dev->mtu = MCTP_USB_MTU_MIN;
+ dev->min_mtu = MCTP_USB_MTU_MIN;
+ dev->max_mtu = MCTP_USB_MTU_MAX;
+
+ dev->hard_header_len = sizeof(struct mctp_usb_hdr);
+ dev->tx_queue_len = DEFAULT_TX_QUEUE_LEN;
+ dev->flags = IFF_NOARP;
+ dev->netdev_ops = &mctp_usb_netdev_ops;
+ dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
+}
+
+static int mctp_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+{
+ struct usb_endpoint_descriptor *ep_in, *ep_out;
+ struct usb_host_interface *iface_desc;
+ struct net_device *netdev;
+ struct mctp_usb *dev;
+ int rc;
+
+ /* only one alternate */
+ iface_desc = intf->cur_altsetting;
+
+ rc = usb_find_common_endpoints(iface_desc, &ep_in, &ep_out, NULL, NULL);
+ if (rc) {
+ dev_err(&intf->dev, "invalid endpoints on device?\n");
+ return rc;
+ }
+
+ netdev = alloc_netdev(sizeof(*dev), "mctpusb%d", NET_NAME_ENUM,
+ mctp_usb_netdev_setup);
+ if (!netdev)
+ return -ENOMEM;
+
+ SET_NETDEV_DEV(netdev, &intf->dev);
+ dev = netdev_priv(netdev);
+ dev->netdev = netdev;
+ dev->usbdev = usb_get_dev(interface_to_usbdev(intf));
+ dev->intf = intf;
+ usb_set_intfdata(intf, dev);
+
+ dev->ep_in = ep_in->bEndpointAddress;
+ dev->ep_out = ep_out->bEndpointAddress;
+
+ dev->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
+ dev->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->tx_urb || !dev->rx_urb) {
+ rc = -ENOMEM;
+ goto err_free_urbs;
+ }
+
+ INIT_DELAYED_WORK(&dev->rx_retry_work, mctp_usb_rx_retry_work);
+
+ rc = mctp_register_netdev(netdev, NULL, MCTP_PHYS_BINDING_USB);
+ if (rc)
+ goto err_free_urbs;
+
+ return 0;
+
+err_free_urbs:
+ usb_free_urb(dev->tx_urb);
+ usb_free_urb(dev->rx_urb);
+ free_netdev(netdev);
+ return rc;
+}
+
+static void mctp_usb_disconnect(struct usb_interface *intf)
+{
+ struct mctp_usb *dev = usb_get_intfdata(intf);
+
+ mctp_unregister_netdev(dev->netdev);
+ usb_free_urb(dev->tx_urb);
+ usb_free_urb(dev->rx_urb);
+ usb_put_dev(dev->usbdev);
+ free_netdev(dev->netdev);
+}
+
+static const struct usb_device_id mctp_usb_devices[] = {
+ { USB_INTERFACE_INFO(USB_CLASS_MCTP, 0x0, 0x1) },
+ { 0 },
+};
+
+MODULE_DEVICE_TABLE(usb, mctp_usb_devices);
+
+static struct usb_driver mctp_usb_driver = {
+ .name = "mctp-usb",
+ .id_table = mctp_usb_devices,
+ .probe = mctp_usb_probe,
+ .disconnect = mctp_usb_disconnect,
+};
+
+module_usb_driver(mctp_usb_driver)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jeremy Kerr <jk@codeconstruct.com.au>");
+MODULE_DESCRIPTION("MCTP USB transport");
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6
2025-04-27 15:30 [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 1/3] usb: Add base USB MCTP definitions Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 2/3] net: mctp: Add MCTP USB transport driver Santosh Puranik
@ 2025-04-27 15:30 ` Santosh Puranik
2025-04-28 1:43 ` Jeremy Kerr
2025-04-28 1:43 ` [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Jeremy Kerr
3 siblings, 1 reply; 11+ messages in thread
From: Santosh Puranik @ 2025-04-27 15:30 UTC (permalink / raw)
To: openbmc, joel, andrew, jk
From: Santosh Puranik <spuranik@nvidia.com>
Fix the way the mctp usb binding driver records netdev stats.
Fix the netdev register call.
Signed-off-by: Santosh Puranik <santosh.puranik.ibm@gmail.com>
---
drivers/net/mctp/mctp-usb.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mctp/mctp-usb.c b/drivers/net/mctp/mctp-usb.c
index e8d4b01c3f34..0c293d6d3607 100644
--- a/drivers/net/mctp/mctp-usb.c
+++ b/drivers/net/mctp/mctp-usb.c
@@ -48,16 +48,17 @@ static void mctp_usb_out_complete(struct urb *urb)
case -ECONNRESET:
case -ESHUTDOWN:
case -EPROTO:
- dev_dstats_tx_dropped(netdev);
+ netdev->stats.tx_dropped++;
break;
case 0:
- dev_dstats_tx_add(netdev, skb->len);
+ netdev->stats.tx_packets++;
+ netdev->stats.tx_bytes += skb->len;
netif_wake_queue(netdev);
consume_skb(skb);
return;
default:
netdev_dbg(netdev, "unexpected tx urb status: %d\n", status);
- dev_dstats_tx_dropped(netdev);
+ netdev->stats.tx_dropped++;
}
kfree_skb(skb);
@@ -105,7 +106,7 @@ static netdev_tx_t mctp_usb_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
err_drop:
- dev_dstats_tx_dropped(dev);
+ dev->stats.tx_dropped++;
kfree_skb(skb);
return NETDEV_TX_OK;
}
@@ -223,7 +224,8 @@ static void mctp_usb_in_complete(struct urb *urb)
skb_trim(skb, pkt_len);
}
- dev_dstats_rx_add(netdev, skb->len);
+ netdev->stats.rx_packets++;
+ netdev->stats.rx_bytes += skb->len;
skb->protocol = htons(ETH_P_MCTP);
skb_reset_network_header(skb);
@@ -340,7 +342,7 @@ static int mctp_usb_probe(struct usb_interface *intf,
INIT_DELAYED_WORK(&dev->rx_retry_work, mctp_usb_rx_retry_work);
- rc = mctp_register_netdev(netdev, NULL, MCTP_PHYS_BINDING_USB);
+ rc = mctp_register_netdev(netdev, NULL);
if (rc)
goto err_free_urbs;
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
2025-04-27 15:30 [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Santosh Puranik
` (2 preceding siblings ...)
2025-04-27 15:30 ` [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6 Santosh Puranik
@ 2025-04-28 1:43 ` Jeremy Kerr
2025-04-28 13:45 ` Santosh Puranik
2025-04-30 3:58 ` Andrew Jeffery
3 siblings, 2 replies; 11+ messages in thread
From: Jeremy Kerr @ 2025-04-28 1:43 UTC (permalink / raw)
To: Santosh Puranik, openbmc, joel, andrew
Hi Santosh,
> This series backports the MCTP over USB binding driver and associated
> definitions.
>
> Patches 1 and 2 were cherry-picked from upstream linux master and
> patch 3 includes fixes needed to backport the binding to 6.6.
We'll want to have f5d83cf0eeb9 ("net: mctp: unshare packets when
reassembling") included too:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/mctp?id=f5d83cf0eeb90fade4d5c4d17d24b8bee9ceeecc
- that should come from the 6.6 stable updates, but doesn't look like it
has hit the openbmc tree yet. Could just be a matter of sequencing vs.
that update, or you could include explicitly.
(Andrew or Joel may have opinions one way or the other)
A couple of comments on 3/3 too.
Cheers,
Jeremy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6
2025-04-27 15:30 ` [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6 Santosh Puranik
@ 2025-04-28 1:43 ` Jeremy Kerr
2025-04-28 13:43 ` Santosh Puranik
0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Kerr @ 2025-04-28 1:43 UTC (permalink / raw)
To: Santosh Puranik, openbmc, joel, andrew
Hi Santosh,
> --- a/drivers/net/mctp/mctp-usb.c
> +++ b/drivers/net/mctp/mctp-usb.c
> @@ -48,16 +48,17 @@ static void mctp_usb_out_complete(struct urb *urb)
> case -ECONNRESET:
> case -ESHUTDOWN:
> case -EPROTO:
> - dev_dstats_tx_dropped(netdev);
> + netdev->stats.tx_dropped++;
Some weird indenting happening here (and with most of the other
additions too).
If we don't want to use dstats, we should also remove
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
Have you checked that the stats look correct in your backport?
> @@ -340,7 +342,7 @@ static int mctp_usb_probe(struct usb_interface *intf,
>
> INIT_DELAYED_WORK(&dev->rx_retry_work, mctp_usb_rx_retry_work);
>
> - rc = mctp_register_netdev(netdev, NULL, MCTP_PHYS_BINDING_USB);
> + rc = mctp_register_netdev(netdev, NULL);
> if (rc)
> goto err_free_urbs;
Alternatively, we could consider backporting 580db513b4a9 ("net: mctp:
Expose transport binding identifier via IFLA attribute") too. This would
be user-visible, as we would now have an new IFLA_MCTP_PHYS_BINDING
attribute on netlink update messages, but that should be entirely
backward-compatible for applications.
Cheers,
Jeremy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6
2025-04-28 1:43 ` Jeremy Kerr
@ 2025-04-28 13:43 ` Santosh Puranik
0 siblings, 0 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-04-28 13:43 UTC (permalink / raw)
To: Jeremy Kerr, openbmc, joel, andrew
Hi Jeremy,
Thank you for the review.
On 28/04/25 7:13 AM, Jeremy Kerr wrote:
> Hi Santosh,
>
>> --- a/drivers/net/mctp/mctp-usb.c
>> +++ b/drivers/net/mctp/mctp-usb.c
>> @@ -48,16 +48,17 @@ static void mctp_usb_out_complete(struct urb *urb)
>> case -ECONNRESET:
>> case -ESHUTDOWN:
>> case -EPROTO:
>> - dev_dstats_tx_dropped(netdev);
>> + netdev->stats.tx_dropped++;
>
> Some weird indenting happening here (and with most of the other
> additions too).
Will fix in v2. Thanks.
>
> If we don't want to use dstats, we should also remove
>
> dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
>
> Have you checked that the stats look correct in your backport?
Yes, they did, for ex:
```
mctpusb0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:68 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11 (11.0 B) TX bytes:13 (13.0 B)
```
I will remove the stat_type assignment and re-run the test before
submitting v2.
>
>> @@ -340,7 +342,7 @@ static int mctp_usb_probe(struct usb_interface *intf,
>>
>> INIT_DELAYED_WORK(&dev->rx_retry_work, mctp_usb_rx_retry_work);
>>
>> - rc = mctp_register_netdev(netdev, NULL, MCTP_PHYS_BINDING_USB);
>> + rc = mctp_register_netdev(netdev, NULL);
>> if (rc)
>> goto err_free_urbs;
>
> Alternatively, we could consider backporting 580db513b4a9 ("net: mctp:
> Expose transport binding identifier via IFLA attribute") too. This would
> be user-visible, as we would now have an new IFLA_MCTP_PHYS_BINDING
> attribute on netlink update messages, but that should be entirely
> backward-compatible for applications.
Ack. Please Let me know if you have a preference.
>
> Cheers,
>
>
> Jeremy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
2025-04-28 1:43 ` [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Jeremy Kerr
@ 2025-04-28 13:45 ` Santosh Puranik
2025-04-30 3:58 ` Andrew Jeffery
1 sibling, 0 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-04-28 13:45 UTC (permalink / raw)
To: Jeremy Kerr, openbmc, joel, andrew
Hi Jeremy,
On 28/04/25 7:13 AM, Jeremy Kerr wrote:
> Hi Santosh,
>
>> This series backports the MCTP over USB binding driver and associated
>> definitions.
>>
>> Patches 1 and 2 were cherry-picked from upstream linux master and
>> patch 3 includes fixes needed to backport the binding to 6.6.
>
> We'll want to have f5d83cf0eeb9 ("net: mctp: unshare packets when
> reassembling") included too:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/mctp?id=f5d83cf0eeb90fade4d5c4d17d24b8bee9ceeecc
>
> - that should come from the 6.6 stable updates, but doesn't look like it
> has hit the openbmc tree yet. Could just be a matter of sequencing vs.
> that update, or you could include explicitly.
>
> (Andrew or Joel may have opinions one way or the other)
OK, will wait to hear before cherry-picking that commit.
>
> A couple of comments on 3/3 too.
Ack, thanks.
>
> Cheers,
>
>
> Jeremy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
2025-04-28 1:43 ` [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Jeremy Kerr
2025-04-28 13:45 ` Santosh Puranik
@ 2025-04-30 3:58 ` Andrew Jeffery
2025-05-06 7:11 ` Andrew Jeffery
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Jeffery @ 2025-04-30 3:58 UTC (permalink / raw)
To: Jeremy Kerr, Santosh Puranik, openbmc, joel
On Mon, 2025-04-28 at 09:43 +0800, Jeremy Kerr wrote:
> Hi Santosh,
>
> > This series backports the MCTP over USB binding driver and associated
> > definitions.
> >
> > Patches 1 and 2 were cherry-picked from upstream linux master and
> > patch 3 includes fixes needed to backport the binding to 6.6.
>
> We'll want to have f5d83cf0eeb9 ("net: mctp: unshare packets when
> reassembling") included too:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/mctp?id=f5d83cf0eeb90fade4d5c4d17d24b8bee9ceeecc
>
> - that should come from the 6.6 stable updates, but doesn't look like it
> has hit the openbmc tree yet. Could just be a matter of sequencing vs.
> that update, or you could include explicitly.
>
> (Andrew or Joel may have opinions one way or the other)
I can take care of it: There are some other related changes that need
backporting as well as they haven't come in via the stable trees (I've
just pushed recipe bumps integrating v6.6.88 for openbmc/linux).
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
2025-04-30 3:58 ` Andrew Jeffery
@ 2025-05-06 7:11 ` Andrew Jeffery
2025-05-07 17:41 ` Santosh Puranik
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Jeffery @ 2025-05-06 7:11 UTC (permalink / raw)
To: Jeremy Kerr, Santosh Puranik, openbmc, joel
On Wed, 2025-04-30 at 11:58 +0800, Andrew Jeffery wrote:
> On Mon, 2025-04-28 at 09:43 +0800, Jeremy Kerr wrote:
> > Hi Santosh,
> >
> > > This series backports the MCTP over USB binding driver and associated
> > > definitions.
> > >
> > > Patches 1 and 2 were cherry-picked from upstream linux master and
> > > patch 3 includes fixes needed to backport the binding to 6.6.
> >
> > We'll want to have f5d83cf0eeb9 ("net: mctp: unshare packets when
> > reassembling") included too:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/mctp?id=f5d83cf0eeb90fade4d5c4d17d24b8bee9ceeecc
> >
> > - that should come from the 6.6 stable updates, but doesn't look like it
> > has hit the openbmc tree yet. Could just be a matter of sequencing vs.
> > that update, or you could include explicitly.
> >
> > (Andrew or Joel may have opinions one way or the other)
>
> I can take care of it: There are some other related changes that need
> backporting as well as they haven't come in via the stable trees (I've
> just pushed recipe bumps integrating v6.6.88 for openbmc/linux).
I've backported several fixes now, including the one above:
- https://gerrit.openbmc.org/c/openbmc/openbmc/+/80040
- https://gerrit.openbmc.org/c/openbmc/openbmc/+/80041
Santosh: Feel free to rebase your series and re-send it after
addressing Jeremy's concerns.
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding
2025-05-06 7:11 ` Andrew Jeffery
@ 2025-05-07 17:41 ` Santosh Puranik
0 siblings, 0 replies; 11+ messages in thread
From: Santosh Puranik @ 2025-05-07 17:41 UTC (permalink / raw)
To: Andrew Jeffery, Jeremy Kerr, openbmc, joel
On 06/05/25 12:41 PM, Andrew Jeffery wrote:
> On Wed, 2025-04-30 at 11:58 +0800, Andrew Jeffery wrote:
>> On Mon, 2025-04-28 at 09:43 +0800, Jeremy Kerr wrote:
>>> Hi Santosh,
>>>
>>>> This series backports the MCTP over USB binding driver and associated
>>>> definitions.
>>>>
>>>> Patches 1 and 2 were cherry-picked from upstream linux master and
>>>> patch 3 includes fixes needed to backport the binding to 6.6.
>>>
>>> We'll want to have f5d83cf0eeb9 ("net: mctp: unshare packets when
>>> reassembling") included too:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/mctp?id=f5d83cf0eeb90fade4d5c4d17d24b8bee9ceeecc
>>>
>>> - that should come from the 6.6 stable updates, but doesn't look like it
>>> has hit the openbmc tree yet. Could just be a matter of sequencing vs.
>>> that update, or you could include explicitly.
>>>
>>> (Andrew or Joel may have opinions one way or the other)
>>
>> I can take care of it: There are some other related changes that need
>> backporting as well as they haven't come in via the stable trees (I've
>> just pushed recipe bumps integrating v6.6.88 for openbmc/linux).
>
> I've backported several fixes now, including the one above:
>
> - https://gerrit.openbmc.org/c/openbmc/openbmc/+/80040
> - https://gerrit.openbmc.org/c/openbmc/openbmc/+/80041
>
> Santosh: Feel free to rebase your series and re-send it after
> addressing Jeremy's concerns.
Thanks, Andrew. I have rebased, addressed the review comments and sent a v2.
>
> Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-05-07 17:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-27 15:30 [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 1/3] usb: Add base USB MCTP definitions Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 2/3] net: mctp: Add MCTP USB transport driver Santosh Puranik
2025-04-27 15:30 ` [PATCH linux dev-6.6 3/3] net: mctp: usb: Port for kernel 6.6 Santosh Puranik
2025-04-28 1:43 ` Jeremy Kerr
2025-04-28 13:43 ` Santosh Puranik
2025-04-28 1:43 ` [PATCH linux dev-6.6 0/3] Backport MCTP Over USB Binding Jeremy Kerr
2025-04-28 13:45 ` Santosh Puranik
2025-04-30 3:58 ` Andrew Jeffery
2025-05-06 7:11 ` Andrew Jeffery
2025-05-07 17:41 ` Santosh Puranik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.