diff mbox series

[net-next,1/2] usb: Add base USB MCTP definitions

Message ID 20250206-dev-mctp-usb-v1-1-81453fe26a61@codeconstruct.com.au (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series mctp: Add MCTP-over-USB hardware transport binding | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 27 this patch: 27
netdev/build_tools success Errors and warnings before: 26 (+1) this patch: 26 (+1)
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1680 this patch: 1680
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 386 this patch: 386
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 42 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 16 this patch: 16
netdev/source_inline success Was 0 now: 0

Commit Message

Jeremy Kerr Feb. 6, 2025, 6:48 a.m. UTC
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>
---
 MAINTAINERS                  |  1 +
 include/linux/usb/mctp-usb.h | 28 ++++++++++++++++++++++++++++
 include/uapi/linux/usb/ch9.h |  1 +
 3 files changed, 30 insertions(+)

Comments

Greg Kroah-Hartman Feb. 6, 2025, 7:03 a.m. UTC | #1
On Thu, Feb 06, 2025 at 02:48:23PM +0800, Jeremy Kerr wrote:
> 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>
> ---
>  MAINTAINERS                  |  1 +
>  include/linux/usb/mctp-usb.h | 28 ++++++++++++++++++++++++++++
>  include/uapi/linux/usb/ch9.h |  1 +
>  3 files changed, 30 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 79756f2100e001177191b129c48cf49e90173a68..f4e093674cf07260ca1cbb5a8873bdff782c614d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13775,6 +13775,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 0000000000000000000000000000000000000000..ad58a7edff8d5228717f9add22615c3fad7d4cde
> --- /dev/null
> +++ b/include/linux/usb/mctp-usb.h
> @@ -0,0 +1,28 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * mctp-usb.h - MCTP USB transport binding: common definitions.
> + *
> + * These are protocol-level definitions, that may be shared between host
> + * and gadget drivers.

Perhaps add a link to the spec?

> + *
> + * Copyright (C) 2024 Code Construct Pty Ltd

It's 2025 now :)

thanks,

greg k-h
Jeremy Kerr Feb. 6, 2025, 7:11 a.m. UTC | #2
Hi Greg,

Thanks for the review.

> > --- /dev/null
> > +++ b/include/linux/usb/mctp-usb.h
> > @@ -0,0 +1,28 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +/*
> > + * mctp-usb.h - MCTP USB transport binding: common definitions.
> > + *
> > + * These are protocol-level definitions, that may be shared between host
> > + * and gadget drivers.
> 
> Perhaps add a link to the spec?

Can do. I have one in the actual driver, but can replicate that here if
it's helpful.

> > + *
> > + * Copyright (C) 2024 Code Construct Pty Ltd
> 
> It's 2025 now :)

WHAT?!

:D

(this was started in 2024, and I have some preliminary versions up since
then, but I assume the last date is preferrable)

Unless I hear otherwise, I'll v2 this after a netdev-appropriate
backoff, with the added link and 2025 for both patches.

Cheers,


Jeremy
Greg Kroah-Hartman Feb. 6, 2025, 7:22 a.m. UTC | #3
On Thu, Feb 06, 2025 at 03:11:25PM +0800, Jeremy Kerr wrote:
> Hi Greg,
> 
> Thanks for the review.
> 
> > > --- /dev/null
> > > +++ b/include/linux/usb/mctp-usb.h
> > > @@ -0,0 +1,28 @@
> > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > +/*
> > > + * mctp-usb.h - MCTP USB transport binding: common definitions.
> > > + *
> > > + * These are protocol-level definitions, that may be shared between host
> > > + * and gadget drivers.
> > 
> > Perhaps add a link to the spec?
> 
> Can do. I have one in the actual driver, but can replicate that here if
> it's helpful.

Isn't this a usb.org spec and not a vendor-specific one?

> > > + * Copyright (C) 2024 Code Construct Pty Ltd
> > 
> > It's 2025 now :)
> 
> WHAT?!
> 
> :D
> 
> (this was started in 2024, and I have some preliminary versions up since
> then, but I assume the last date is preferrable)

As per copyright norms, list the real dates, so that would be:
	Copyright (C) 2024-2025 ...

thanks,

greg k-h
Jeremy Kerr Feb. 6, 2025, 7:36 a.m. UTC | #4
> 
Hi Greg,

> > Can do. I have one in the actual driver, but can replicate that
> > here if it's helpful.
> 
> Isn't this a usb.org spec and not a vendor-specific one?

Nope, all defined by the DMTF - so not really a vendor, but external to
the USB-IF at least. The only mention of this under USB-IF is the class
code allocation, along with the note:

   [0x14] This base class is defined for devices that conform to the
   “MCTP over USB” found at the DMTF website as DSP0283. This
   specification defines the usable set of SubClass and Protocol
   values. Values outside of this defined spec are reserved. These
   class codes can only be used in Interface Descriptors.

> As per copyright norms, list the real dates, so that would be:
>         Copyright (C) 2024-2025 ...

ack, will do.

Cheers,


Jeremy
Greg Kroah-Hartman Feb. 6, 2025, 8:14 a.m. UTC | #5
On Thu, Feb 06, 2025 at 03:36:05PM +0800, Jeremy Kerr wrote:
> > 
> Hi Greg,
> 
> > > Can do. I have one in the actual driver, but can replicate that
> > > here if it's helpful.
> > 
> > Isn't this a usb.org spec and not a vendor-specific one?
> 
> Nope, all defined by the DMTF - so not really a vendor, but external to
> the USB-IF at least. The only mention of this under USB-IF is the class
> code allocation, along with the note:
> 
>    [0x14] This base class is defined for devices that conform to the
>    “MCTP over USB” found at the DMTF website as DSP0283. This
>    specification defines the usable set of SubClass and Protocol
>    values. Values outside of this defined spec are reserved. These
>    class codes can only be used in Interface Descriptors.

Ah, ok, then a link to the DSP0283 spec here in the .h file would be
good.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 79756f2100e001177191b129c48cf49e90173a68..f4e093674cf07260ca1cbb5a8873bdff782c614d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13775,6 +13775,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 0000000000000000000000000000000000000000..ad58a7edff8d5228717f9add22615c3fad7d4cde
--- /dev/null
+++ b/include/linux/usb/mctp-usb.h
@@ -0,0 +1,28 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * mctp-usb.h - MCTP USB transport binding: common definitions.
+ *
+ * These are protocol-level definitions, that may be shared between host
+ * and gadget drivers.
+ *
+ * Copyright (C) 2024 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 91f0f7e214a5a57c8bee3f44c4dbf7b175843d8c..052290652046591fba46f1f0cb5cf77fd965f555 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -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