1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 /**************************************************************************/ 12 /**************************************************************************/ 13 /** */ 14 /** USBX Component */ 15 /** */ 16 /** CDC_ECM Class */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 /**************************************************************************/ 22 /* */ 23 /* COMPONENT DEFINITION RELEASE */ 24 /* */ 25 /* ux_device_class_cdc_ecm.h PORTABLE C */ 26 /* 6.3.0 */ 27 /* AUTHOR */ 28 /* */ 29 /* Chaoqiong Xiao, Microsoft Corporation */ 30 /* */ 31 /* DESCRIPTION */ 32 /* */ 33 /* This file defines the equivalences for the USBX Device Class */ 34 /* CDC_ECM component. */ 35 /* */ 36 /* RELEASE HISTORY */ 37 /* */ 38 /* DATE NAME DESCRIPTION */ 39 /* */ 40 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 41 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 42 /* used UX prefix to refer to */ 43 /* TX symbols instead of using */ 44 /* them directly, */ 45 /* resulting in version 6.1 */ 46 /* 08-02-2021 Wen Wang Modified comment(s), */ 47 /* fixed spelling error, */ 48 /* added extern "C" keyword */ 49 /* for compatibility with C++, */ 50 /* resulting in version 6.1.8 */ 51 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */ 52 /* fixed standalone compile, */ 53 /* resulting in version 6.1.11 */ 54 /* 10-31-2022 Chaoqiong Xiao Modified comment(s), */ 55 /* added wait definitions, */ 56 /* resulting in version 6.2.0 */ 57 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ 58 /* added zero copy support, */ 59 /* added a new mode to manage */ 60 /* endpoint buffer in classes, */ 61 /* resulting in version 6.3.0 */ 62 /* */ 63 /**************************************************************************/ 64 65 #ifndef UX_DEVICE_CLASS_CDC_ECM_H 66 #define UX_DEVICE_CLASS_CDC_ECM_H 67 68 /* Determine if a C++ compiler is being used. If so, ensure that standard 69 C is used to process the API information. */ 70 71 #ifdef __cplusplus 72 73 /* Yes, C++ compiler is present. Use standard C. */ 74 extern "C" { 75 76 #endif 77 78 #if !defined(UX_DEVICE_STANDALONE) 79 #include "nx_api.h" 80 #include "ux_network_driver.h" 81 #else 82 83 /* Assume NX definitions for compiling. */ 84 #define NX_PACKET VOID* 85 /* 86 UINT _ux_network_driver_deactivate(VOID *ux_instance, VOID *ux_network_handle); 87 VOID _ux_network_driver_link_up(VOID *ux_network_handle); 88 VOID _ux_network_driver_link_down(VOID *ux_network_handle); 89 */ 90 #ifndef _ux_network_driver_deactivate 91 #define _ux_network_driver_deactivate(a,b) do {} while(0) 92 #endif 93 #ifndef _ux_network_driver_link_up 94 #define _ux_network_driver_link_up(a) do {} while(0) 95 #endif 96 #ifndef _ux_network_driver_link_down 97 #define _ux_network_driver_link_down(a) do {} while(0) 98 #endif 99 #endif 100 101 102 /* Option: defined, it enables zero copy support (works if CDC_ECM owns endpoint buffer). 103 Enabled, it requires that the NX packet pool is in cache safe area, and buffer max size is 104 larger than UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE (1536). 105 */ 106 /* #define UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY */ 107 108 109 /* Bulk out endpoint buffer size, must be larger than endpoint and ethernet max packet size, and aligned in 4-bytes. */ 110 #if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY) 111 #define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE 0 112 #else 113 #define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_MAX_PACKET_LENGTH 114 #endif 115 116 /* Bulk in endpoint buffer size, must be larger than endpoint and ethernet max packet size, and aligned in 4-bytes. */ 117 #if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY) 118 #define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE 0 119 #else 120 #define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE 121 #endif 122 123 /* Interrupt in endpoint buffer size... */ 124 #define UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_LENGTH 125 126 127 /* Define generic CDC_ECM equivalences. */ 128 #define UX_DEVICE_CLASS_CDC_ECM_CLASS_COMMUNICATION_CONTROL 0x02 129 #define UX_DEVICE_CLASS_CDC_ECM_SUBCLASS_COMMUNICATION_CONTROL 0x06 130 #define UX_DEVICE_CLASS_CDC_ECM_CLASS_COMMUNICATION_DATA 0x0A 131 #define UX_DEVICE_CLASS_CDC_ECM_NEW_INTERRUPT_EVENT 0x01 132 #define UX_DEVICE_CLASS_CDC_ECM_NEW_BULKOUT_EVENT 0x02 133 #define UX_DEVICE_CLASS_CDC_ECM_NEW_BULKIN_EVENT 0x04 134 #define UX_DEVICE_CLASS_CDC_ECM_NEW_DEVICE_STATE_CHANGE_EVENT 0x08 135 #define UX_DEVICE_CLASS_CDC_ECM_NETWORK_NOTIFICATION_EVENT 0x10 136 #define UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_LENGTH 8 137 #define UX_DEVICE_CLASS_CDC_ECM_MAX_CONTROL_RESPONSE_LENGTH 256 138 #define UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_AVAILABLE_FLAG 1 139 #define UX_DEVICE_CLASS_CDC_ECM_BASE_IP_ADDRESS 0xC0A80001 140 #define UX_DEVICE_CLASS_CDC_ECM_BASE_IP_MASK 0xFFFFFF00 141 #define UX_DEVICE_CLASS_CDC_ECM_MAX_MTU 1518 142 #define UX_DEVICE_CLASS_CDC_ECM_ETHERNET_IP 0x0800 143 #define UX_DEVICE_CLASS_CDC_ECM_ETHERNET_ARP 0x0806 144 #define UX_DEVICE_CLASS_CDC_ECM_ETHERNET_RARP 0x8035 145 #define UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE 1536 146 #define UX_DEVICE_CLASS_CDC_ECM_NX_ALIGN_PADDING 2 147 #ifndef UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES 148 #define UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES 16 149 #endif 150 151 #define UX_DEVICE_CLASS_CDC_ECM_NX_PACKET_SIZE sizeof(NX_PACKET) 152 153 #define UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE_ASSERT UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE, UX_DEVICE_CLASS_CDC_ECM_NX_ALIGN_PADDING), UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE_calc_ovf) 154 #define UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE (UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE + UX_DEVICE_CLASS_CDC_ECM_NX_ALIGN_PADDING) 155 156 #define UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE_ASSERT \ 157 UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE_ASSERT \ 158 UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG( \ 159 UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE, \ 160 UX_DEVICE_CLASS_CDC_ECM_NX_PACKET_SIZE), \ 161 UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE_calc_ovf) 162 #define UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE (UX_DEVICE_CLASS_CDC_ECM_NX_PAYLOAD_SIZE + UX_DEVICE_CLASS_CDC_ECM_NX_PACKET_SIZE) 163 164 #define UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT \ 165 UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE_ASSERT \ 166 UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_MULC_ULONG( \ 167 UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES, \ 168 UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE), \ 169 UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_calc1_ovf) \ 170 UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG( \ 171 UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES * \ 172 UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE, \ 173 32), UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_calc2_ovf) 174 #define UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE (UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES * UX_DEVICE_CLASS_CDC_ECM_NX_BUFF_SIZE + 32) 175 176 #define UX_DEVICE_CLASS_CDC_ECM_ETHERNET_SIZE 14 177 #define UX_DEVICE_CLASS_CDC_ECM_NODE_ID_LENGTH 6 178 #define UX_DEVICE_CLASS_CDC_ECM_VENDOR_DESCRIPTION_MAX_LENGTH 64 179 #define UX_DEVICE_CLASS_CDC_ECM_MAC_OPTIONS 8 180 #define UX_DEVICE_CLASS_CDC_ECM_PACKET_HEADER_MSG 1 181 182 /* Device CDC_ECM Requests */ 183 #define UX_DEVICE_CLASS_CDC_ECM_SEND_ENCAPSULATED_COMMAND 0x00 184 #define UX_DEVICE_CLASS_CDC_ECM_GET_ENCAPSULATED_RESPONSE 0x01 185 #define UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_MULTICAST_FILTER 0x40 186 #define UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_POWER_MANAGEMENT_FILTER 0x41 187 #define UX_DEVICE_CLASS_CDC_ECM_GET_ETHERNET_POWER_MANAGEMENT_FILTER 0x42 188 #define UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_PACKET_FILTER 0x43 189 190 /* Define CDC_ECM Versions. Set to 1.0 here. */ 191 #define UX_DEVICE_CLASS_CDC_ECM_VERSION_MAJOR 0x00000001 192 #define UX_DEVICE_CLASS_CDC_ECM_VERSION_MINOR 0x00000000 193 194 /* Define CDC_ECM Connection type supported. Set to connectionless. */ 195 #define UX_DEVICE_CLASS_CDC_ECM_DF_CONNECTIONLESS 0x00000001 196 #define UX_DEVICE_CLASS_CDC_ECM_DF_CONNECTION_ORIENTED 0x00000002 197 #define UX_DEVICE_CLASS_CDC_ECM_DF_CONNECTION_SUPPORTED UX_DEVICE_CLASS_CDC_ECM_DF_CONNECTIONLESS 198 199 /* Define CDC_ECM Medium supported by the device. */ 200 #define UX_DEVICE_CLASS_CDC_ECM_MEDIUM_SUPPORTED 0x00000000 201 202 /* Define CDC_ECM Packet size and types supported. */ 203 #define UX_DEVICE_CLASS_CDC_ECM_MAX_PACKET_PER_TRANSFER 0x00000001 204 #define UX_DEVICE_CLASS_CDC_ECM_MAX_PACKET_TRANSFER_SIZE 0x00000640 205 #define UX_DEVICE_CLASS_CDC_ECM_PACKET_ALIGNEMENT_FACTOR 0x00000003 206 #define UX_DEVICE_CLASS_CDC_ECM_MAX_FRAME_SIZE 0x000005DC 207 #define UX_DEVICE_CLASS_CDC_ECM_MAX_PACKET_LENGTH 0x000005EA 208 209 /* Define LINK speeds. */ 210 #define UX_DEVICE_CLASS_CDC_ECM_LINK_SPEED_FS 0x0001D4C0 211 212 /* Define LINK states. */ 213 #define UX_DEVICE_CLASS_CDC_ECM_LINK_STATE_DOWN 0 214 #define UX_DEVICE_CLASS_CDC_ECM_LINK_STATE_UP 1 215 #define UX_DEVICE_CLASS_CDC_ECM_LINK_STATE_PENDING_UP 2 216 #define UX_DEVICE_CLASS_CDC_ECM_LINK_STATE_PENDING_DOWN 3 217 218 /* Define media connection values. */ 219 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_CONNECTED 0x00000000 220 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_DISCONNECTED 0x00000001 221 222 /* Define media supported values. */ 223 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_802_3 0x00000000 224 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_802_5 0x00000001 225 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_FDDI 0x00000002 226 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_WAN 0x00000003 227 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_LOCAL_TALK 0x00000004 228 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_DIX 0x00000005 229 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_ARCNET_RAW 0x00000006 230 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_ARCNET_878_2 0x00000007 231 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_ATM 0x00000008 232 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_WIRELESS_WAN 0x00000009 233 #define UX_DEVICE_CLASS_CDC_ECM_MEDIA_IRDA 0x0000000A 234 235 /* Define CDC_ECM status values. */ 236 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_SUCCESS 0x00000000 237 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_FAILURE 0xC0000001 238 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_INVALID_DATA 0xC0010015 239 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_NOT_SUPPORTED 0xC00000BB 240 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_MEDIA_CONNECTED 0x4001000B 241 #define UX_DEVICE_CLASS_CDC_ECM_STATUS_MEDIA_DISCONNECT 0x4001000C 242 243 /* Define CDC_ECM Control Messages values. */ 244 245 /* Define CDC_ECM State machine. */ 246 #define UX_DEVICE_CLASS_CDC_ECM_STATE_UNINITIALIZED 0x00000000 247 #define UX_DEVICE_CLASS_CDC_ECM_STATE_INITIALIZED 0x00000001 248 #define UX_DEVICE_CLASS_CDC_ECM_STATE_DATA_INITIALIZED 0x00000002 249 250 /* Define NetX errors inside the CDC_ECM class. */ 251 #define UX_DEVICE_CLASS_CDC_ECM_NX_SUCCESS 0x00 252 #define UX_DEVICE_CLASS_CDC_ECM_NX_NO_PACKET 0x01 253 #define UX_DEVICE_CLASS_CDC_ECM_NX_UNDERFLOW 0x02 254 #define UX_DEVICE_CLASS_CDC_ECM_NX_OVERFLOW 0x03 255 #define UX_DEVICE_CLASS_CDC_ECM_NX_NO_MAPPING 0x04 256 #define UX_DEVICE_CLASS_CDC_ECM_NX_DELETED 0x05 257 #define UX_DEVICE_CLASS_CDC_ECM_NX_POOL_ERROR 0x06 258 #define UX_DEVICE_CLASS_CDC_ECM_NX_PTR_ERROR 0x07 259 #define UX_DEVICE_CLASS_CDC_ECM_NX_WAIT_ERROR 0x08 260 #define UX_DEVICE_CLASS_CDC_ECM_NX_SIZE_ERROR 0x09 261 #define UX_DEVICE_CLASS_CDC_ECM_NX_OPTION_ERROR 0x0a 262 #define UX_DEVICE_CLASS_CDC_ECM_NX_DELETE_ERROR 0x10 263 #define UX_DEVICE_CLASS_CDC_ECM_NX_CALLER_ERROR 0x11 264 #define UX_DEVICE_CLASS_CDC_ECM_NX_INVALID_PACKET 0x12 265 #define UX_DEVICE_CLASS_CDC_ECM_NX_INVALID_SOCKET 0x13 266 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_ENABLED 0x14 267 #define UX_DEVICE_CLASS_CDC_ECM_NX_ALREADY_ENABLED 0x15 268 #define UX_DEVICE_CLASS_CDC_ECM_NX_ENTRY_NOT_FOUND 0x16 269 #define UX_DEVICE_CLASS_CDC_ECM_NX_NO_MORE_ENTRIES 0x17 270 #define UX_DEVICE_CLASS_CDC_ECM_NX_ARP_TIMER_ERROR 0x18 271 #define UX_DEVICE_CLASS_CDC_ECM_NX_RESERVED_CODE0 0x19 272 #define UX_DEVICE_CLASS_CDC_ECM_NX_WAIT_ABORTED 0x1A 273 #define UX_DEVICE_CLASS_CDC_ECM_NX_IP_INTERNAL_ERROR 0x20 274 #define UX_DEVICE_CLASS_CDC_ECM_NX_IP_ADDRESS_ERROR 0x21 275 #define UX_DEVICE_CLASS_CDC_ECM_NX_ALREADY_BOUND 0x22 276 #define UX_DEVICE_CLASS_CDC_ECM_NX_PORT_UNAVAILABLE 0x23 277 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_BOUND 0x24 278 #define UX_DEVICE_CLASS_CDC_ECM_NX_RESERVED_CODE1 0x25 279 #define UX_DEVICE_CLASS_CDC_ECM_NX_SOCKET_UNBOUND 0x26 280 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_CREATED 0x27 281 #define UX_DEVICE_CLASS_CDC_ECM_NX_SOCKETS_BOUND 0x28 282 #define UX_DEVICE_CLASS_CDC_ECM_NX_NO_RESPONSE 0x29 283 #define UX_DEVICE_CLASS_CDC_ECM_NX_POOL_DELETED 0x30 284 #define UX_DEVICE_CLASS_CDC_ECM_NX_ALREADY_RELEASED 0x31 285 #define UX_DEVICE_CLASS_CDC_ECM_NX_RESERVED_CODE2 0x32 286 #define UX_DEVICE_CLASS_CDC_ECM_NX_MAX_LISTEN 0x33 287 #define UX_DEVICE_CLASS_CDC_ECM_NX_DUPLICATE_LISTEN 0x34 288 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_CLOSED 0x35 289 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_LISTEN_STATE 0x36 290 #define UX_DEVICE_CLASS_CDC_ECM_NX_IN_PROGRESS 0x37 291 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_CONNECTED 0x38 292 #define UX_DEVICE_CLASS_CDC_ECM_NX_WINDOW_OVERFLOW 0x39 293 #define UX_DEVICE_CLASS_CDC_ECM_NX_ALREADY_SUSPENDED 0x40 294 #define UX_DEVICE_CLASS_CDC_ECM_NX_DISCONNECT_FAILED 0x41 295 #define UX_DEVICE_CLASS_CDC_ECM_NX_STILL_BOUND 0x42 296 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_SUCCESSFUL 0x43 297 #define UX_DEVICE_CLASS_CDC_ECM_NX_UNHANDLED_COMMAND 0x44 298 #define UX_DEVICE_CLASS_CDC_ECM_NX_NO_FREE_PORTS 0x45 299 #define UX_DEVICE_CLASS_CDC_ECM_NX_INVALID_PORT 0x46 300 #define UX_DEVICE_CLASS_CDC_ECM_NX_INVALID_RELISTEN 0x47 301 #define UX_DEVICE_CLASS_CDC_ECM_NX_CONNECTION_PENDING 0x48 302 #define UX_DEVICE_CLASS_CDC_ECM_NX_TX_QUEUE_DEPTH 0x49 303 #define UX_DEVICE_CLASS_CDC_ECM_NX_NOT_IMPLEMENTED 0x80 304 305 /* Define timeout packet allocation value. */ 306 #ifndef UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_WAIT 307 #define UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_WAIT 1000 308 #endif 309 310 #ifndef UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_INST_WAIT 311 #define UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_INST_WAIT 1000 312 #endif 313 314 #define UX_DEVICE_CLASS_CDC_ECM_LINK_CHECK_WAIT 10 315 316 /* Define Slave CDC_ECM Class Calling Parameter structure */ 317 318 typedef struct UX_SLAVE_CLASS_CDC_ECM_PARAMETER_STRUCT 319 { 320 VOID (*ux_slave_class_cdc_ecm_instance_activate)(VOID *); 321 VOID (*ux_slave_class_cdc_ecm_instance_deactivate)(VOID *); 322 ULONG ux_slave_class_cdc_ecm_parameter_media; 323 ULONG ux_slave_class_cdc_ecm_parameter_vendor_id; 324 ULONG ux_slave_class_cdc_ecm_parameter_driver_version; 325 UCHAR ux_slave_class_cdc_ecm_parameter_vendor_description[UX_DEVICE_CLASS_CDC_ECM_VENDOR_DESCRIPTION_MAX_LENGTH]; 326 UCHAR ux_slave_class_cdc_ecm_parameter_local_node_id[UX_DEVICE_CLASS_CDC_ECM_NODE_ID_LENGTH]; 327 UCHAR ux_slave_class_cdc_ecm_parameter_remote_node_id[UX_DEVICE_CLASS_CDC_ECM_NODE_ID_LENGTH]; 328 } UX_SLAVE_CLASS_CDC_ECM_PARAMETER; 329 330 /* Define CDC_ECM Class structure. */ 331 332 typedef struct UX_SLAVE_CLASS_CDC_ECM_STRUCT 333 { 334 UX_SLAVE_INTERFACE *ux_slave_class_cdc_ecm_interface; 335 UX_SLAVE_CLASS_CDC_ECM_PARAMETER ux_slave_class_cdc_ecm_parameter; 336 UX_SLAVE_ENDPOINT *ux_slave_class_cdc_ecm_bulkin_endpoint; 337 UX_SLAVE_ENDPOINT *ux_slave_class_cdc_ecm_bulkout_endpoint; 338 UX_SLAVE_ENDPOINT *ux_slave_class_cdc_ecm_interrupt_endpoint; 339 #if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1 340 UCHAR *ux_device_class_cdc_ecm_endpoint_buffer; 341 #endif 342 ULONG ux_slave_class_cdc_ecm_state; 343 ULONG ux_slave_class_cdc_ecm_current_alternate_setting; 344 ULONG ux_slave_class_cdc_ecm_max_transfer_size; 345 ULONG ux_slave_class_cdc_ecm_request_id; 346 ULONG ux_slave_class_cdc_ecm_statistics_xmit_ok; 347 ULONG ux_slave_class_cdc_ecm_statistics_rcv_ok; 348 ULONG ux_slave_class_cdc_ecm_statistics_xmit_error; 349 ULONG ux_slave_class_cdc_ecm_statistics_rcv_error; 350 ULONG ux_slave_class_cdc_ecm_statistics_rcv_no_buffer; 351 ULONG ux_slave_class_cdc_ecm_statistics_rcv_error_alignment; 352 ULONG ux_slave_class_cdc_ecm_statistics_xmit_one_collision; 353 ULONG ux_slave_class_cdc_ecm_statistics_xmit_more_collisions; 354 ULONG ux_slave_class_cdc_ecm_ethernet_multicast_filter; 355 ULONG ux_slave_class_cdc_ecm_ethernet_power_management_filter; 356 ULONG ux_slave_class_cdc_ecm_ethernet_packet_filter; 357 UCHAR ux_slave_class_cdc_ecm_local_node_id[UX_DEVICE_CLASS_CDC_ECM_NODE_ID_LENGTH]; 358 UCHAR ux_slave_class_cdc_ecm_remote_node_id[UX_DEVICE_CLASS_CDC_ECM_NODE_ID_LENGTH]; 359 ULONG ux_slave_class_cdc_ecm_nx_ip_address; 360 ULONG ux_slave_class_cdc_ecm_nx_ip_network_mask; 361 362 #if !defined(UX_DEVICE_STANDALONE) 363 NX_IP *ux_slave_class_cdc_ecm_nx_ip; 364 NX_INTERFACE *ux_slave_class_cdc_ecm_nx_interface; 365 NX_PACKET *ux_slave_class_cdc_ecm_xmit_queue; 366 NX_PACKET *ux_slave_class_cdc_ecm_xmit_queue_tail; 367 NX_PACKET *ux_slave_class_cdc_ecm_receive_queue; 368 NX_PACKET_POOL *ux_slave_class_cdc_ecm_packet_pool; 369 #endif 370 371 #if !defined(UX_DEVICE_STANDALONE) 372 UX_EVENT_FLAGS_GROUP ux_slave_class_cdc_ecm_event_flags_group; 373 UX_THREAD ux_slave_class_cdc_ecm_bulkin_thread; 374 UX_THREAD ux_slave_class_cdc_ecm_bulkout_thread; 375 UX_THREAD ux_slave_class_cdc_ecm_interrupt_thread; 376 UX_MUTEX ux_slave_class_cdc_ecm_mutex; 377 UCHAR *ux_slave_class_cdc_ecm_bulkin_thread_stack; 378 UCHAR *ux_slave_class_cdc_ecm_bulkout_thread_stack; 379 UCHAR *ux_slave_class_cdc_ecm_interrupt_thread_stack; 380 #endif 381 382 ULONG ux_slave_class_cdc_ecm_link_state; 383 VOID *ux_slave_class_cdc_ecm_network_handle; 384 385 } UX_SLAVE_CLASS_CDC_ECM; 386 387 /* Define CDC ECM endpoint buffer settings (when CDC ECM owns buffer). */ 388 #if defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY) 389 #define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW 0 /* No calculation, no overflow */ 390 #else 391 #define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW \ 392 (UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE, \ 393 UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE) || \ 394 UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE + \ 395 UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE, \ 396 UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE)) 397 #endif 398 #define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE (UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE + UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE + UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE) 399 #define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(ecm) ((ecm)->ux_device_class_cdc_ecm_endpoint_buffer) 400 #define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER(ecm) (UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(ecm) + UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE) 401 #define UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER(ecm) (UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER(ecm) + UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE) 402 403 404 /* Requests - Ethernet Networking Control Model */ 405 406 #define UX_DEVICE_CLASS_CDC_ECM_SEND_ENCAPSULATED_COMMAND 0x00 407 /* Issues a command in the format of the supported control 408 protocol. The intent of this mechanism is to support 409 networking devices (e.g., host-based cable modems) 410 that require an additional vendor-defined interface for 411 media specific hardware configuration and 412 management. */ 413 #define UX_DEVICE_CLASS_CDC_ECM_GET_ENCAPSULATED_RESPONSE 0x01 414 /* Requests a response in the format of the supported 415 control protocol. */ 416 417 418 /* Define buffer length for IN/OUT pipes. */ 419 420 #define UX_DEVICE_CLASS_CDC_ECM_BUFFER_SIZE 4096 421 422 423 /* Define Device CDC_ECM Class prototypes. */ 424 425 UINT _ux_device_class_cdc_ecm_activate(UX_SLAVE_CLASS_COMMAND *command); 426 UINT _ux_device_class_cdc_ecm_control_request(UX_SLAVE_CLASS_COMMAND *command); 427 UINT _ux_device_class_cdc_ecm_deactivate(UX_SLAVE_CLASS_COMMAND *command); 428 UINT _ux_device_class_cdc_ecm_change(UX_SLAVE_CLASS_COMMAND *command); 429 UINT _ux_device_class_cdc_ecm_entry(UX_SLAVE_CLASS_COMMAND *command); 430 UINT _ux_device_class_cdc_ecm_initialize(UX_SLAVE_CLASS_COMMAND *command); 431 UINT _ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND *command); 432 UINT _ux_device_class_cdc_ecm_write(VOID *cdc_ecm_class, NX_PACKET *packet); 433 VOID _ux_device_class_cdc_ecm_bulkin_thread(ULONG cdc_ecm_class); 434 VOID _ux_device_class_cdc_ecm_bulkout_thread(ULONG cdc_ecm_class); 435 VOID _ux_device_class_cdc_ecm_interrupt_thread(ULONG cdc_ecm_class); 436 437 438 /* Define Device CDC Class API prototypes. */ 439 440 #define ux_device_class_cdc_ecm_entry _ux_device_class_cdc_ecm_entry 441 #define ux_device_class_cdc_ecm_read _ux_device_class_cdc_ecm_read 442 #define ux_device_class_cdc_ecm_write _ux_device_class_cdc_ecm_write 443 444 /* Determine if a C++ compiler is being used. If so, complete the standard 445 C conditional started above. */ 446 #ifdef __cplusplus 447 } 448 #endif 449 450 #endif /* UX_DEVICE_CLASS_CDC_ECM_H */ 451