Mistake on this page?
Report an issue in GitHub or email us
whd_cdc_bdc.h
1 /*
2  * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef INCLUDED_WHD_CDC_BDC_H
19 #define INCLUDED_WHD_CDC_BDC_H
20 
21 #include "whd.h"
22 #include "cyabs_rtos.h"
23 #include "whd_events_int.h"
24 #include "whd_types_int.h"
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 /******************************************************
32 * Constants
33 ******************************************************/
34 
35 /* CDC flag definition taken from bcmcdc.h */
36 #define CDCF_IOC_SET (0x02) /** 0=get, 1=set cmd */
37 #define WHD_EVENT_HANDLER_LIST_SIZE (5) /** Maximum number of simultaneously registered event handlers */
38 #define WHD_SDALIGN 32
39 
40 /* CDC flag definitions taken from bcmcdc.h */
41 #define CDCF_IOC_ERROR (0x01) /** 0=success, 1=ioctl cmd failed */
42 #define CDCF_IOC_IF_MASK (0xF000) /** I/F index */
43 #define CDCF_IOC_IF_SHIFT (12) /** # of bits of shift for I/F Mask */
44 #define CDCF_IOC_ID_MASK (0xFFFF0000) /** used to uniquely id an ioctl req/resp pairing */
45 #define CDCF_IOC_ID_SHIFT (16) /** # of bits of shift for ID Mask */
46 
47 #define DATA_AFTER_HEADER(x) ( (void *)(&x[1]) )
48 
49 #define BDC_HEADER_LEN (4)
50 
51 /******************************************************
52 * Enumerations
53 ******************************************************/
54 
55 typedef enum sdpcm_command_type_enum
56 {
57  CDC_GET = 0x00,
58  CDC_SET = CDCF_IOC_SET
59 } cdc_command_type_t;
60 
61 /******************************************************
62 * Structures
63 ******************************************************/
64 #pragma pack(1)
65 typedef struct
66 {
67  uint32_t cmd; /* ioctl command value */
68  uint32_t len; /* lower 16: output buflen; upper 16: input buflen (excludes header) */
69  uint32_t flags; /* flag defns given in bcmcdc.h */
70  uint32_t status; /* status code returned from the device */
71 } cdc_header_t;
72 
73 typedef struct
74 {
75  uint8_t flags; /* Flags */
76  uint8_t priority; /* 802.1d Priority (low 3 bits) */
77  uint8_t flags2;
78  uint8_t data_offset; /* Offset from end of BDC header to packet data, in 4-uint8_t words.
79  * Leaves room for optional headers.*/
80 } bdc_header_t;
81 
82 typedef struct
83 {
84  whd_mac_t destination_address;
85  whd_mac_t source_address;
86  uint16_t ethertype;
88 
89 #pragma pack()
90 
91 /** Event list element structure
92  *
93  * events : A pointer to a whd_event_num_t array that is terminated with a WLC_E_NONE event
94  * handler: A pointer to the whd_event_handler_t function that will receive the event
95  * handler_user_data : User provided data that will be passed to the handler when a matching event occurs
96  */
97 typedef struct
98 {
99  whd_bool_t event_set;
100  whd_event_num_t events[WHD_MAX_EVENT_SUBSCRIPTION];
101  whd_event_handler_t handler;
102  void *handler_user_data;
103  uint8_t ifidx;
105 
106 /** @endcond */
107 
108 typedef struct whd_cdc_info
109 {
110  /* Event list variables */
111  event_list_elem_t whd_event_list[WHD_EVENT_HANDLER_LIST_SIZE];
112  cy_semaphore_t event_list_mutex;
113 
114  /* IOCTL variables*/
115  uint16_t requested_ioctl_id;
116  cy_semaphore_t ioctl_mutex;
117  whd_buffer_t ioctl_response;
118  cy_semaphore_t ioctl_sleep;
119 
121 /** Error list element structure
122  *
123  * events : set event of error type
124  * handler: A pointer to the whd_error_handler_t function that will receive the event
125  * handler_user_data : User provided data that will be passed to the handler when a matching event occurs
126  */
127 typedef struct
128 {
129  whd_error_handler_t handler;
130  void *handler_user_data;
131  whd_bool_t event_set;
132  uint8_t events;
134 
135 /** @endcond */
136 
137 typedef struct whd_error_info
138 {
139  /* Event list variables */
140  error_list_elem_t whd_event_list[WHD_EVENT_HANDLER_LIST_SIZE];
141  cy_semaphore_t event_list_mutex;
143 
144 /******************************************************
145 * Function Declarations
146 ******************************************************/
147 
148 whd_result_t whd_cdc_bdc_info_init(whd_driver_t whd_driver);
149 void whd_cdc_bdc_info_deinit(whd_driver_t whd_driver);
150 
151 whd_result_t whd_cdc_send_iovar(whd_interface_t ifp, cdc_command_type_t type,
152  whd_buffer_t send_buffer_hnd,
153  whd_buffer_t *response_buffer_hnd);
154 
155 whd_result_t whd_cdc_send_ioctl(whd_interface_t ifp, cdc_command_type_t type, uint32_t command,
156  whd_buffer_t send_buffer_hnd,
157  whd_buffer_t *response_buffer_hnd);
158 
159 void *whd_cdc_get_iovar_buffer(whd_driver_t whd_driver,
160  whd_buffer_t *buffer,
161  uint16_t data_length,
162  const char *name);
163 void whd_network_send_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer);
164 
165 void *whd_cdc_get_ioctl_buffer(whd_driver_t whd_driver,
166  whd_buffer_t *buffer,
167  uint16_t data_length);
168 
169 void whd_process_cdc(whd_driver_t whd_driver, whd_buffer_t buffer);
170 
171 void whd_process_bdc(whd_driver_t whd_driver, whd_buffer_t buffer);
172 
173 void whd_process_bdc_event(whd_driver_t whd_driver, whd_buffer_t buffer, uint16_t size);
174 
175 #ifdef __cplusplus
176 } /* extern "C" */
177 #endif
178 
179 #endif /* ifndef INCLUDED_WHD_CDC_BDC_H */
180 
void *(* whd_event_handler_t)(whd_interface_t ifp, const whd_event_header_t *event_header, const uint8_t *event_data, void *handler_user_data)
Event handler prototype definition.
Definition: whd_events.h:187
Provides abstract pointer type to act as instance for: driver, interface, buffer funcs, network funcs, resource funcs and bus funcs.
Event list element structure.
Definition: whd_cdc_bdc.h:97
whd_bool_t
Boolean values.
Definition: whd_types.h:162
Structure for storing a MAC address (Wi-Fi Media Access Control address).
Definition: whd_types.h:385
uint32_t whd_result_t
WHD result is specified as uint32_t value.
Definition: whd_types.h:776
void *(* whd_error_handler_t)(whd_driver_t whd_driver, const uint8_t *error_type, const uint8_t *event_data, void *handler_user_data)
Error handler prototype definition.
Definition: whd_events.h:200
void whd_network_send_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer)
To send an ethernet frame to WHD (called by the Network Stack)
Error list element structure.
Definition: whd_cdc_bdc.h:127
Defines common constants used with WHD within src folder.
Header for Event detection.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.