Mistake on this page?
Report an issue in GitHub or email us
whd_cdc_bdc.h
1 /*
2  * Copyright 2020 Cypress Semiconductor Corporation
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 
122 /******************************************************
123 * Function Declarations
124 ******************************************************/
125 
126 whd_result_t whd_cdc_bdc_info_init(whd_driver_t whd_driver);
127 void whd_cdc_bdc_info_deinit(whd_driver_t whd_driver);
128 
129 whd_result_t whd_cdc_send_iovar(whd_interface_t ifp, cdc_command_type_t type,
130  whd_buffer_t send_buffer_hnd,
131  whd_buffer_t *response_buffer_hnd);
132 
133 whd_result_t whd_cdc_send_ioctl(whd_interface_t ifp, cdc_command_type_t type, uint32_t command,
134  whd_buffer_t send_buffer_hnd,
135  whd_buffer_t *response_buffer_hnd);
136 
137 void *whd_cdc_get_iovar_buffer(whd_driver_t whd_driver,
138  whd_buffer_t *buffer,
139  uint16_t data_length,
140  const char *name);
141 void whd_network_send_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer);
142 
143 void *whd_cdc_get_ioctl_buffer(whd_driver_t whd_driver,
144  whd_buffer_t *buffer,
145  uint16_t data_length);
146 
147 void whd_process_cdc(whd_driver_t whd_driver, whd_buffer_t buffer);
148 
149 void whd_process_bdc(whd_driver_t whd_driver, whd_buffer_t buffer);
150 
151 void whd_process_bdc_event(whd_driver_t whd_driver, whd_buffer_t buffer, uint16_t size);
152 
153 #ifdef __cplusplus
154 } /* extern "C" */
155 #endif
156 
157 #endif /* ifndef INCLUDED_WHD_CDC_BDC_H */
158 
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_network_send_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer)
To send an ethernet frame to WHD (called by the Network Stack)
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.