USB: cdc.h: ncm: add missed constants and structures
authorYauheni Kaliuta <yauheni.kaliuta@nokia.com>
Mon, 20 Sep 2010 12:40:28 +0000 (15:40 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:21:47 +0000 (10:21 -0700)
Make a dedicated structure for datagram pointer entry. There is no
explicit declaration in the spec, but it's used by the host
implementation and makes the structure more clear.

Add some missed constants from the spec

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/usb/cdc.h

index 583264abca0c5adf3f71992610503fb86b0d4544..2d5b6f296aa3eeeae6fa8afeabfc595655c53d9e 100644 (file)
@@ -32,6 +32,8 @@
 
 #define USB_CDC_PROTO_EEM                      7
 
+#define USB_CDC_NCM_PROTO_NTB                  1
+
 /*-------------------------------------------------------------------------*/
 
 /*
@@ -325,14 +327,26 @@ struct usb_cdc_ncm_nth32 {
 #define USB_CDC_NCM_NDP32_CRC_SIGN     0x316D636E /* ncm1 */
 #define USB_CDC_NCM_NDP32_NOCRC_SIGN   0x306D636E /* ncm0 */
 
+/* 16-bit NCM Datagram Pointer Entry */
+struct usb_cdc_ncm_dpe16 {
+       __le16  wDatagramIndex;
+       __le16  wDatagramLength;
+} __attribute__((__packed__));
+
 /* 16-bit NCM Datagram Pointer Table */
 struct usb_cdc_ncm_ndp16 {
        __le32  dwSignature;
        __le16  wLength;
        __le16  wNextFpIndex;
-       __u8    data[0];
+       struct  usb_cdc_ncm_dpe16 dpe16[0];
 } __attribute__ ((packed));
 
+/* 32-bit NCM Datagram Pointer Entry */
+struct usb_cdc_ncm_dpe32 {
+       __le32  wDatagramIndex;
+       __le32  wDatagramLength;
+} __attribute__((__packed__));
+
 /* 32-bit NCM Datagram Pointer Table */
 struct usb_cdc_ncm_ndp32 {
        __le32  dwSignature;
@@ -340,7 +354,46 @@ struct usb_cdc_ncm_ndp32 {
        __le16  wReserved6;
        __le32  dwNextNdpIndex;
        __le32  dwReserved12;
-       __u8    data[0];
+       struct  usb_cdc_ncm_dpe32 dpe32[0];
 } __attribute__ ((packed));
 
+/* CDC NCM subclass 3.2.1 and 3.2.2 */
+#define USB_CDC_NCM_NDP16_INDEX_MIN                    0x000C
+#define USB_CDC_NCM_NDP32_INDEX_MIN                    0x0010
+
+/* CDC NCM subclass 3.3.3 Datagram Formatting */
+#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC                        0x30
+#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC              0X31
+
+/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
+#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS       0x00
+#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO            0xFE
+
+/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
+#define USB_CDC_NCM_NCAP_ETH_FILTER                    (1 << 0)
+#define USB_CDC_NCM_NCAP_NET_ADDRESS                   (1 << 1)
+#define USB_CDC_NCM_NCAP_ENCAP_COMMAND                 (1 << 2)
+#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE             (1 << 3)
+#define USB_CDC_NCM_NCAP_CRC_MODE                      (1 << 4)
+
+/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
+#define USB_CDC_NCM_NTB16_SUPPORTED                    (1 << 0)
+#define USB_CDC_NCM_NTB32_SUPPORTED                    (1 << 1)
+
+/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
+#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE                 0x04
+#define USB_CDC_NCM_NTB_MAX_LENGTH                     0x1C
+
+/* CDC NCM subclass 6.2.5 SetNtbFormat */
+#define USB_CDC_NCM_NTB16_FORMAT                       0x00
+#define USB_CDC_NCM_NTB32_FORMAT                       0x01
+
+/* CDC NCM subclass 6.2.7 SetNtbInputSize */
+#define USB_CDC_NCM_NTB_MIN_IN_SIZE                    2048
+#define USB_CDC_NCM_NTB_MIN_OUT_SIZE                   2048
+
+/* CDC NCM subclass 6.2.11 SetCrcMode */
+#define USB_CDC_NCM_CRC_NOT_APPENDED                   0x00
+#define USB_CDC_NCM_CRC_APPENDED                       0x01
+
 #endif /* __LINUX_USB_CDC_H */