Skip to content

Commit efcbc67

Browse files
ForstPaolo Abeni
authored andcommitted
usbnet: ipheth: break up NCM header size computation
Originally, the total NCM header size was computed as the sum of two vaguely labelled constants. While accurate, it wasn't particularly clear where they were coming from. Use sizes of existing NCM structs where available. Define the total NDP16 size based on the maximum amount of DPEs that can fit into the iOS-specific fixed-size header. This change does not fix any particular issue. Rather, it introduces intermediate constants that will simplify subsequent commits. It should also make it clearer for the reader where the constant values come from. Cc: [email protected] # 6.5.x Signed-off-by: Foster Snowhill <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2a9a196 commit efcbc67

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/net/usb/ipheth.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,18 @@
6161
#define IPHETH_USBINTF_PROTO 1
6262

6363
#define IPHETH_IP_ALIGN 2 /* padding at front of URB */
64-
#define IPHETH_NCM_HEADER_SIZE (12 + 96) /* NCMH + NCM0 */
64+
/* On iOS devices, NCM headers in RX have a fixed size regardless of DPE count:
65+
* - NTH16 (NCMH): 12 bytes, as per CDC NCM 1.0 spec
66+
* - NDP16 (NCM0): 96 bytes, of which
67+
* - NDP16 fixed header: 8 bytes
68+
* - maximum of 22 DPEs (21 datagrams + trailer), 4 bytes each
69+
*/
70+
#define IPHETH_NDP16_MAX_DPE 22
71+
#define IPHETH_NDP16_HEADER_SIZE (sizeof(struct usb_cdc_ncm_ndp16) + \
72+
IPHETH_NDP16_MAX_DPE * \
73+
sizeof(struct usb_cdc_ncm_dpe16))
74+
#define IPHETH_NCM_HEADER_SIZE (sizeof(struct usb_cdc_ncm_nth16) + \
75+
IPHETH_NDP16_HEADER_SIZE)
6576
#define IPHETH_TX_BUF_SIZE ETH_FRAME_LEN
6677
#define IPHETH_RX_BUF_SIZE_LEGACY (IPHETH_IP_ALIGN + ETH_FRAME_LEN)
6778
#define IPHETH_RX_BUF_SIZE_NCM 65536

0 commit comments

Comments
 (0)