linux/include/uapi/linux/usb/cdc.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 * USB Communications Device Class (CDC) definitions
 *
 * CDC says how to talk to lots of different types of network adapters,
 * notably ethernet adapters and various modems.  It's used mostly with
 * firmware based USB peripherals.
 */

#ifndef __UAPI_LINUX_USB_CDC_H
#define __UAPI_LINUX_USB_CDC_H

#include <linux/types.h>

#define USB_CDC_SUBCLASS_ACM
#define USB_CDC_SUBCLASS_ETHERNET
#define USB_CDC_SUBCLASS_WHCM
#define USB_CDC_SUBCLASS_DMM
#define USB_CDC_SUBCLASS_MDLM
#define USB_CDC_SUBCLASS_OBEX
#define USB_CDC_SUBCLASS_EEM
#define USB_CDC_SUBCLASS_NCM
#define USB_CDC_SUBCLASS_MBIM

#define USB_CDC_PROTO_NONE

#define USB_CDC_ACM_PROTO_AT_V25TER
#define USB_CDC_ACM_PROTO_AT_PCCA101
#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE
#define USB_CDC_ACM_PROTO_AT_GSM
#define USB_CDC_ACM_PROTO_AT_3G
#define USB_CDC_ACM_PROTO_AT_CDMA
#define USB_CDC_ACM_PROTO_VENDOR

#define USB_CDC_PROTO_EEM

#define USB_CDC_NCM_PROTO_NTB
#define USB_CDC_MBIM_PROTO_NTB

/*-------------------------------------------------------------------------*/

/*
 * Class-Specific descriptors ... there are a couple dozen of them
 */

#define USB_CDC_HEADER_TYPE
#define USB_CDC_CALL_MANAGEMENT_TYPE
#define USB_CDC_ACM_TYPE
#define USB_CDC_UNION_TYPE
#define USB_CDC_COUNTRY_TYPE
#define USB_CDC_NETWORK_TERMINAL_TYPE
#define USB_CDC_ETHERNET_TYPE
#define USB_CDC_WHCM_TYPE
#define USB_CDC_MDLM_TYPE
#define USB_CDC_MDLM_DETAIL_TYPE
#define USB_CDC_DMM_TYPE
#define USB_CDC_OBEX_TYPE
#define USB_CDC_NCM_TYPE
#define USB_CDC_MBIM_TYPE
#define USB_CDC_MBIM_EXTENDED_TYPE

/* "Header Functional Descriptor" from CDC spec  5.2.3.1 */
struct usb_cdc_header_desc {} __attribute__ ((packed));

/* "Call Management Descriptor" from CDC spec  5.2.3.2 */
struct usb_cdc_call_mgmt_descriptor {} __attribute__ ((packed));

/* "Abstract Control Management Descriptor" from CDC spec  5.2.3.3 */
struct usb_cdc_acm_descriptor {} __attribute__ ((packed));

/* capabilities from 5.2.3.3 */

#define USB_CDC_COMM_FEATURE
#define USB_CDC_CAP_LINE
#define USB_CDC_CAP_BRK
#define USB_CDC_CAP_NOTIFY

/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
struct usb_cdc_union_desc {} __attribute__ ((packed));

/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
struct usb_cdc_country_functional_desc {} __attribute__ ((packed));

/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
struct usb_cdc_network_terminal_desc {} __attribute__ ((packed));

/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
struct usb_cdc_ether_desc {} __attribute__ ((packed));

/* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */
struct usb_cdc_dmm_desc {} __attribute__ ((packed));

/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
struct usb_cdc_mdlm_desc {} __attribute__ ((packed));

/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
struct usb_cdc_mdlm_detail_desc {} __attribute__ ((packed));

/* "OBEX Control Model Functional Descriptor" */
struct usb_cdc_obex_desc {} __attribute__ ((packed));

/* "NCM Control Model Functional Descriptor" */
struct usb_cdc_ncm_desc {} __attribute__ ((packed));

/* "MBIM Control Model Functional Descriptor" */
struct usb_cdc_mbim_desc {} __attribute__ ((packed));

/* "MBIM Extended Functional Descriptor" from CDC MBIM spec 1.0 errata-1 */
struct usb_cdc_mbim_extended_desc {} __attribute__ ((packed));

/*-------------------------------------------------------------------------*/

/*
 * Class-Specific Control Requests (6.2)
 *
 * section 3.6.2.1 table 4 has the ACM profile, for modems.
 * section 3.8.2 table 10 has the ethernet profile.
 *
 * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
 * heavily dependent on the encapsulated (proprietary) command mechanism.
 */

#define USB_CDC_SEND_ENCAPSULATED_COMMAND
#define USB_CDC_GET_ENCAPSULATED_RESPONSE
#define USB_CDC_REQ_SET_LINE_CODING
#define USB_CDC_REQ_GET_LINE_CODING
#define USB_CDC_REQ_SET_CONTROL_LINE_STATE
#define USB_CDC_REQ_SEND_BREAK
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS
#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER
#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER
#define USB_CDC_SET_ETHERNET_PACKET_FILTER
#define USB_CDC_GET_ETHERNET_STATISTIC
#define USB_CDC_GET_NTB_PARAMETERS
#define USB_CDC_GET_NET_ADDRESS
#define USB_CDC_SET_NET_ADDRESS
#define USB_CDC_GET_NTB_FORMAT
#define USB_CDC_SET_NTB_FORMAT
#define USB_CDC_GET_NTB_INPUT_SIZE
#define USB_CDC_SET_NTB_INPUT_SIZE
#define USB_CDC_GET_MAX_DATAGRAM_SIZE
#define USB_CDC_SET_MAX_DATAGRAM_SIZE
#define USB_CDC_GET_CRC_MODE
#define USB_CDC_SET_CRC_MODE

/* Line Coding Structure from CDC spec 6.2.13 */
struct usb_cdc_line_coding {} __attribute__ ((packed));

/* Control Signal Bitmap Values from 6.2.14 SetControlLineState */
#define USB_CDC_CTRL_DTR
#define USB_CDC_CTRL_RTS

/* table 62; bits in multicast filter */
#define USB_CDC_PACKET_TYPE_PROMISCUOUS
#define USB_CDC_PACKET_TYPE_ALL_MULTICAST
#define USB_CDC_PACKET_TYPE_DIRECTED
#define USB_CDC_PACKET_TYPE_BROADCAST
#define USB_CDC_PACKET_TYPE_MULTICAST


/*-------------------------------------------------------------------------*/

/*
 * Class-Specific Notifications (6.3) sent by interrupt transfers
 *
 * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
 * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
 * RNDIS also defines its own bit-incompatible notifications
 */

#define USB_CDC_NOTIFY_NETWORK_CONNECTION
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE
#define USB_CDC_NOTIFY_SERIAL_STATE
#define USB_CDC_NOTIFY_SPEED_CHANGE

struct usb_cdc_notification {} __attribute__ ((packed));

/* UART State Bitmap Values from 6.3.5 SerialState */
#define USB_CDC_SERIAL_STATE_DCD
#define USB_CDC_SERIAL_STATE_DSR
#define USB_CDC_SERIAL_STATE_BREAK
#define USB_CDC_SERIAL_STATE_RING_SIGNAL
#define USB_CDC_SERIAL_STATE_FRAMING
#define USB_CDC_SERIAL_STATE_PARITY
#define USB_CDC_SERIAL_STATE_OVERRUN

struct usb_cdc_speed_change {} __attribute__ ((packed));

/*-------------------------------------------------------------------------*/

/*
 * Class Specific structures and constants
 *
 * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
 *
 */

struct usb_cdc_ncm_ntb_parameters {} __attribute__ ((packed));

/*
 * CDC NCM transfer headers, CDC NCM subclass 3.2
 */

#define USB_CDC_NCM_NTH16_SIGN
#define USB_CDC_NCM_NTH32_SIGN

struct usb_cdc_ncm_nth16 {} __attribute__ ((packed));

struct usb_cdc_ncm_nth32 {} __attribute__ ((packed));

/*
 * CDC NCM datagram pointers, CDC NCM subclass 3.3
 */

#define USB_CDC_NCM_NDP16_CRC_SIGN
#define USB_CDC_NCM_NDP16_NOCRC_SIGN
#define USB_CDC_NCM_NDP32_CRC_SIGN
#define USB_CDC_NCM_NDP32_NOCRC_SIGN

#define USB_CDC_MBIM_NDP16_IPS_SIGN
#define USB_CDC_MBIM_NDP32_IPS_SIGN
#define USB_CDC_MBIM_NDP16_DSS_SIGN
#define USB_CDC_MBIM_NDP32_DSS_SIGN

/* 16-bit NCM Datagram Pointer Entry */
struct usb_cdc_ncm_dpe16 {} __attribute__((packed));

/* 16-bit NCM Datagram Pointer Table */
struct usb_cdc_ncm_ndp16 {} __attribute__ ((packed));

/* 32-bit NCM Datagram Pointer Entry */
struct usb_cdc_ncm_dpe32 {} __attribute__((packed));

/* 32-bit NCM Datagram Pointer Table */
struct usb_cdc_ncm_ndp32 {} __attribute__ ((packed));

/* CDC NCM subclass 3.2.1 and 3.2.2 */
#define USB_CDC_NCM_NDP16_INDEX_MIN
#define USB_CDC_NCM_NDP32_INDEX_MIN

/* CDC NCM subclass 3.3.3 Datagram Formatting */
#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC
#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC

/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS
#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO

/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
#define USB_CDC_NCM_NCAP_ETH_FILTER
#define USB_CDC_NCM_NCAP_NET_ADDRESS
#define USB_CDC_NCM_NCAP_ENCAP_COMMAND
#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE
#define USB_CDC_NCM_NCAP_CRC_MODE
#define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE

/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
#define USB_CDC_NCM_NTB16_SUPPORTED
#define USB_CDC_NCM_NTB32_SUPPORTED

/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE
#define USB_CDC_NCM_NTB_MAX_LENGTH

/* CDC NCM subclass 6.2.5 SetNtbFormat */
#define USB_CDC_NCM_NTB16_FORMAT
#define USB_CDC_NCM_NTB32_FORMAT

/* CDC NCM subclass 6.2.7 SetNtbInputSize */
#define USB_CDC_NCM_NTB_MIN_IN_SIZE
#define USB_CDC_NCM_NTB_MIN_OUT_SIZE

/* NTB Input Size Structure */
struct usb_cdc_ncm_ndp_input_size {} __attribute__ ((packed));

/* CDC NCM subclass 6.2.11 SetCrcMode */
#define USB_CDC_NCM_CRC_NOT_APPENDED
#define USB_CDC_NCM_CRC_APPENDED

#endif /* __UAPI_LINUX_USB_CDC_H */