2 * USB CDC NCM auxiliary definitions
5 #ifndef __LINUX_USB_NCM_H
6 #define __LINUX_USB_NCM_H
8 #include <linux/types.h>
9 #include <linux/usb/cdc.h>
10 #include <asm/unaligned.h>
12 #define NCM_NTB_MIN_IN_SIZE 2048
13 #define NCM_NTB_MIN_OUT_SIZE 2048
15 #define NCM_CONTROL_TIMEOUT (5 * 1000)
17 /* bmNetworkCapabilities */
19 #define NCM_NCAP_ETH_FILTER (1 << 0)
20 #define NCM_NCAP_NET_ADDRESS (1 << 1)
21 #define NCM_NCAP_ENCAP_COMM (1 << 2)
22 #define NCM_NCAP_MAX_DGRAM (1 << 3)
23 #define NCM_NCAP_CRC_MODE (1 << 4)
26 * Here are options for NCM Datagram Pointer table (NDP) parser.
27 * There are 2 different formats: NDP16 and NDP32 in the spec (ch. 3),
28 * in NDP16 offsets and sizes fields are 1 16bit word wide,
29 * in NDP32 -- 2 16bit words wide. Also signatures are different.
30 * To make the parser code the same, put the differences in the structure,
31 * and switch pointers to the structures when the format is changed.
34 struct ndp_parser_opts
{
39 unsigned ndplen_align
;
40 /* sizes in u16 units */
41 unsigned dgram_item_len
; /* index or length */
42 unsigned block_length
;
46 unsigned next_fp_index
;
49 #define INIT_NDP16_OPTS { \
50 .nth_sign = NCM_NTH16_SIGN, \
51 .ndp_sign = NCM_NDP16_NOCRC_SIGN, \
52 .nth_size = sizeof(struct usb_cdc_ncm_nth16), \
53 .ndp_size = sizeof(struct usb_cdc_ncm_ndp16), \
55 .dgram_item_len = 1, \
64 #define INIT_NDP32_OPTS { \
65 .nth_sign = NCM_NTH32_SIGN, \
66 .ndp_sign = NCM_NDP32_NOCRC_SIGN, \
67 .nth_size = sizeof(struct usb_cdc_ncm_nth32), \
68 .ndp_size = sizeof(struct usb_cdc_ncm_ndp32), \
70 .dgram_item_len = 2, \
78 static inline void put_ncm(__le16
**p
, unsigned size
, unsigned val
)
82 put_unaligned_le16((u16
)val
, *p
);
85 put_unaligned_le32((u32
)val
, *p
);
95 static inline unsigned get_ncm(__le16
**p
, unsigned size
)
101 tmp
= get_unaligned_le16(*p
);
104 tmp
= get_unaligned_le32(*p
);
114 #endif /* __LINUX_USB_NCM_H */