From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 126A535F192; Fri, 3 Jul 2026 05:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.29.241.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783057704; cv=none; b=Fh9A1cZ87sxuombTR4D81tYxlb7SWPKZAOEX0Hpv0OXlFa+1Wg4aBklH7PdOt9HnzKBXli1T+eKy2es9wWfwRTNtktXVK3k/f/mV6LNAP3RL/6ervey+jGyBBWMyY6Ohwfsfy6MyZMmqKYLcknBg9S0y9pqCl8XbYMq/t+xZzRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783057704; c=relaxed/simple; bh=EgB+vBpXw4eXQcU1VwIA+lTtRwEQuf/vVem5ALUYzUI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eqaIsNJCdyKe3g1v/BR4/9TTo0x7/U1/nZJJKyBYWbggJK5pEwNcStmfe+o0bp5pQUSK0GhuRpspp9mCgAIASbm0DOU2rcW3rkXTNQS9cfHvzkqslOZXnt39P2WLun9be9q7P4RS2lcymQ2PRAZxtSWnLw+uU1z7p5X1/7OGYJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au; spf=pass smtp.mailfrom=codeconstruct.com.au; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b=RHK4I/pE; arc=none smtp.client-ip=203.29.241.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b="RHK4I/pE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1783057671; bh=SMRFXUUSftRXXsDSm0VxSKfsxk1JKeuUIqQA2u7GE6s=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=RHK4I/pEk2/X3+Oi2898oRjmrt5he5IKLDcly45657mdZ6RoUsOROzv9C4ss5JYMw 7+irAcCbKxYfmDSdjVA75fCCoB3Bwez7Wf0qYRtFACqZGWC+3VQGCNQSh7jqk1tJwN tiMcuUIeFnBIXhsY/FGfpM3fXP3mwfvL8R1M7/MyuLPF1z8BDnXyNJNh/ba7SD3WO0 996r/yli1VgH/6lRQxlOJnIDPoonfYFNnmeDyneRjB1hOQuAwJeixoYDgAQC6mM5ts dukCA2ssgfvKLn/p5fY1oDQMVsrrJGT7ZtkQ9Z1HzHD7L5mPlCwXykWwPY0mVq2VEm 2+VSfGhob0+fw== Received: by codeconstruct.com.au (Postfix, from userid 10000) id D515166291; Fri, 3 Jul 2026 13:47:51 +0800 (AWST) From: Jeremy Kerr Date: Fri, 03 Jul 2026 13:47:27 +0800 Subject: [PATCH net-next v2 07/12] net: mctp: usb: Accommodate DSP0283 v1.1 header format Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260703-dev-mctp-usb-1-1-v2-7-60367b861b33@codeconstruct.com.au> References: <20260703-dev-mctp-usb-1-1-v2-0-60367b861b33@codeconstruct.com.au> In-Reply-To: <20260703-dev-mctp-usb-1-1-v2-0-60367b861b33@codeconstruct.com.au> To: Matt Johnston , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org X-Mailer: b4 0.16-dev In the v1.1 update to DSP0283, we have a larger header field, of 13 bits rather than 8. In order to accommodate this, in preparation for proper v1.1 support, expand our struct mctp_usb_hdr's len field to a u16, and endian-convert when necessary. Because we don't yet support spanning mode, we will never receive or transmit with the top 5 bits set, so we always mask out anyway. This allows for a future change where we allow spanning mode with >512-byte transfers. Signed-off-by: Jeremy Kerr --- v2: - fix short packet (hdr) debug message: use endian-converted value --- drivers/net/mctp/mctp-usblib.c | 14 ++++++++------ include/linux/usb/mctp-usb.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/mctp/mctp-usblib.c b/drivers/net/mctp/mctp-usblib.c index f2221dbc1019..13dbeb84a0b7 100644 --- a/drivers/net/mctp/mctp-usblib.c +++ b/drivers/net/mctp/mctp-usblib.c @@ -88,6 +88,7 @@ int mctp_usblib_rx_complete(struct net_device *netdev, while (skb) { struct sk_buff *skb2 = NULL; struct mctp_usb_hdr *hdr; + u16 hdr_len; /* length of MCTP packet, no USB header */ u8 pkt_len; @@ -105,21 +106,23 @@ int mctp_usblib_rx_complete(struct net_device *netdev, break; } - if (hdr->len < + hdr_len = be16_to_cpu(hdr->len) & MCTP_USB_1_0_PKTLEN_MAX; + + if (hdr_len < sizeof(struct mctp_hdr) + sizeof(struct mctp_usb_hdr)) { netdev_dbg(netdev, "rx: short packet (hdr) %d\n", - hdr->len); + hdr_len); rc = -EPROTO; break; } /* we know we have at least sizeof(struct mctp_usb_hdr) here */ - pkt_len = hdr->len - sizeof(struct mctp_usb_hdr); + pkt_len = hdr_len - sizeof(struct mctp_usb_hdr); if (pkt_len > skb->len) { rc = -EPROTO; netdev_dbg(netdev, "rx: short packet (xfer) %d, actual %d\n", - hdr->len, skb->len); + hdr_len, skb->len); break; } @@ -386,8 +389,7 @@ static int mctp_usblib_tx_skb_prepare(struct sk_buff *skb, } hdr->id = cpu_to_be16(MCTP_USB_DMTF_ID); - hdr->rsvd = 0; - hdr->len = plen + sizeof(*hdr); + hdr->len = cpu_to_be16(plen + sizeof(*hdr)); return 0; } diff --git a/include/linux/usb/mctp-usb.h b/include/linux/usb/mctp-usb.h index 9d9b1f5eee5c..00e94ddfadcb 100644 --- a/include/linux/usb/mctp-usb.h +++ b/include/linux/usb/mctp-usb.h @@ -2,7 +2,7 @@ /* * 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 + * https://www.dmtf.org/sites/default/files/standards/documents/DSP0283_1.1.0.pdf * * These are protocol-level definitions, that may be shared between host * and gadget drivers. @@ -17,10 +17,15 @@ #include #include +/* + * MCTP-over-USB transport header. DSP0283 v1.0 has an 8-bit length field + * (preceded by 8 reserved bits), v1.1 has a 13-bit length field (preceded by + * 3 reserved bits). We use a be16 for our length to handle the larger v1.1 + * representation, and mask as appropriate. + */ struct mctp_usb_hdr { __be16 id; - u8 rsvd; - u8 len; + __be16 len; } __packed; /* max transfer size for DSP0283 v1.0 */ -- 2.47.3