1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** USBX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Device CDC_ECM Class */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
#define UX_SOURCE_CODE |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/* Include necessary system files. */ |
26 |
|
|
|
27 |
|
|
#include "ux_api.h" |
28 |
|
|
#include "ux_device_class_cdc_ecm.h" |
29 |
|
|
#include "ux_device_stack.h" |
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _ux_device_class_cdc_ecm_control_request PORTABLE C */ |
36 |
|
|
/* 6.1.12 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function manages the based sent by the host on the control */ |
44 |
|
|
/* endpoints with a CLASS or VENDOR SPECIFIC type. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* cdc_ecm Pointer to cdc_ecm class */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* None */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* _ux_utility_short_get Get 16-bit value */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLED BY */ |
59 |
|
|
/* */ |
60 |
|
|
/* CDC_ECM Class */ |
61 |
|
|
/* */ |
62 |
|
|
/**************************************************************************/ |
63 |
|
8 |
UINT _ux_device_class_cdc_ecm_control_request(UX_SLAVE_CLASS_COMMAND *command) |
64 |
|
|
{ |
65 |
|
|
|
66 |
|
|
UX_SLAVE_TRANSFER *transfer_request; |
67 |
|
|
UX_SLAVE_DEVICE *device; |
68 |
|
|
ULONG request; |
69 |
|
|
ULONG request_value; |
70 |
|
|
UX_SLAVE_CLASS *class_ptr; |
71 |
|
|
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm; |
72 |
|
|
|
73 |
|
|
/* Get the pointer to the device. */ |
74 |
|
8 |
device = &_ux_system_slave -> ux_system_slave_device; |
75 |
|
|
|
76 |
|
|
/* Get the pointer to the transfer request associated with the control endpoint. */ |
77 |
|
8 |
transfer_request = &device -> ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request; |
78 |
|
|
|
79 |
|
|
/* Extract all necessary fields of the request. */ |
80 |
|
8 |
request = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_REQUEST); |
81 |
|
8 |
request_value = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE); |
82 |
|
|
|
83 |
|
|
/* Get the class container. */ |
84 |
|
8 |
class_ptr = command -> ux_slave_class_command_class_ptr; |
85 |
|
|
|
86 |
|
|
/* Get the cdc_ecm instance from this class container. */ |
87 |
|
8 |
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance; |
88 |
|
|
|
89 |
|
|
/* Here we proceed only the standard request we know of at the device level. */ |
90 |
✓✓✓✓
|
8 |
switch (request) |
91 |
|
|
{ |
92 |
|
|
|
93 |
|
2 |
case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_MULTICAST_FILTER : |
94 |
|
|
|
95 |
|
|
/* Save the multicast filter. */ |
96 |
|
2 |
cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_multicast_filter = request_value; |
97 |
|
2 |
break ; |
98 |
|
|
|
99 |
|
2 |
case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_POWER_MANAGEMENT_FILTER : |
100 |
|
|
|
101 |
|
|
/* Save the power management filter. */ |
102 |
|
2 |
cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_power_management_filter = request_value; |
103 |
|
2 |
break ; |
104 |
|
|
|
105 |
|
2 |
case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_PACKET_FILTER : |
106 |
|
|
|
107 |
|
|
/* Save the packet filter. */ |
108 |
|
2 |
cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_packet_filter = request_value; |
109 |
|
2 |
break ; |
110 |
|
|
|
111 |
|
2 |
case UX_DEVICE_CLASS_CDC_ECM_GET_ETHERNET_POWER_MANAGEMENT_FILTER : |
112 |
|
|
default: |
113 |
|
|
|
114 |
|
|
/* Unknown function. It's not handled. */ |
115 |
|
2 |
return(UX_ERROR); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
/* It's handled. */ |
119 |
|
6 |
return(UX_SUCCESS); |
120 |
|
|
} |
121 |
|
|
|