From 2cdd98104ece869f3a5eda3dd9c2b02f5b4c318d Mon Sep 17 00:00:00 2001 From: nminaylov Date: Mon, 27 Apr 2026 14:40:18 +0300 Subject: NCM caps enum --- src/class/net/ncm_device.c | 3 +-- src/class/net/net_device.h | 10 ++++++++++ src/device/usbd.h | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/class/net/ncm_device.c b/src/class/net/ncm_device.c index a1ad9b205..83e8bffab 100644 --- a/src/class/net/ncm_device.c +++ b/src/class/net/ncm_device.c @@ -999,8 +999,7 @@ bool netd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t case NCM_SET_ETHERNET_PACKET_FILTER: { tud_control_xfer(rhport, request, NULL, 0); - } break; - + } break; // unsupported request default: diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h index 96c03fd61..61ff6b2d6 100644 --- a/src/class/net/net_device.h +++ b/src/class/net/net_device.h @@ -50,6 +50,16 @@ typedef enum NCM_DATA_PROTOCOL_NETWORK_TRANSFER_BLOCK = 0x01 } ncm_data_interface_protocol_code_t; +// Table 5.2 bmNetworkCapabilities bits +typedef enum { + NCM_NETWORK_CAPS_NONE = 0x00, + NCM_NETWORK_CAPS_ETH_FILTER = (1 << 0), + NCM_NETWORK_CAPS_NET_ADDRESS = (1 << 1), + NCM_NETWORK_CAPS_ENCAP_COMMAND = (1 << 2), + NCM_NETWORK_CAPS_MAX_DATAGRAM_SIZE = (1 << 3), + NCM_NETWORK_CAPS_CRC_MODE = (1 << 4), + NCM_NETWORK_CAPS_NTB_INPUT_SIZE = (1 << 5) +} ncm_network_capabilities_t; #ifdef __cplusplus extern "C" { diff --git a/src/device/usbd.h b/src/device/usbd.h index 45beb7c4c..96144350e 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -1023,6 +1023,9 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ // CDC-NCM Descriptor Templates //--------------------------------------------------------------------+ +// NCM Capabilities, bitmap of NCM_NETWORK_CAPS_* bits. +#define TUD_CDC_NCM_CAPS (NCM_NETWORK_CAPS_ETH_FILTER) + // Length of template descriptor #define TUD_CDC_NCM_DESC_LEN (8+9+5+5+13+6+7+9+9+7+7) @@ -1040,7 +1043,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ /* CDC-NCM Functional Descriptor */\ 13, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_ETHERNET_NETWORKING, _mac_stridx, 0, 0, 0, 0, U16_TO_U8S_LE(_maxsegmentsize), U16_TO_U8S_LE(0), 0, \ /* CDC-NCM Functional Descriptor */\ - 6, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_NCM, U16_TO_U8S_LE(0x0100), 0x01, \ + 6, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_NCM, U16_TO_U8S_LE(0x0100), TUD_CDC_NCM_CAPS, \ /* Endpoint Notification */\ 7, TUSB_DESC_ENDPOINT, _ep_notif, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_notif_size), 50,\ /* CDC Data Interface (default inactive) */\ -- cgit v1.3.1