1 /*
2 * Header file describing the internal (inter-module) DHD interfaces.
3 *
4 * Provides type definitions and function prototypes used to link the
5 * DHD OS, bus, and protocol modules.
6 *
7 * Copyright (C) 1999-2019, Broadcom.
8 *
9 * Unless you and Broadcom execute a separate written software license
10 * agreement governing use of this software, this software is licensed to you
11 * under the terms of the GNU General Public License version 2 (the "GPL"),
12 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13 * following added to such license:
14 *
15 * As a special exception, the copyright holders of this software give you
16 * permission to link this software with independent modules, and to copy and
17 * distribute the resulting executable under terms of your choice, provided that
18 * you also meet, for each linked independent module, the terms and conditions
19 * of the license of that module. An independent module is a module which is
20 * not derived from this software. The special exception does not apply to any
21 * modifications of the software.
22 *
23 * Notwithstanding the above, under no circumstances may you combine this
24 * software in any way with any other Broadcom software provided under a license
25 * other than the GPL, without Broadcom's express prior written consent.
26 *
27 *
28 * <<Broadcom-WL-IPTag/Open:>>
29 *
30 * $Id: dhd_proto.h 814912 2019-04-15 10:38:59Z $
31 */
32
33 #ifndef _dhd_proto_h_
34 #define _dhd_proto_h_
35
36 #include <dhdioctl.h>
37 #include <wlioctl.h>
38 #ifdef BCMPCIE
39 #include <dhd_flowring.h>
40 #endif // endif
41
42 #define DEFAULT_IOCTL_RESP_TIMEOUT 5000
43 #ifndef IOCTL_RESP_TIMEOUT
44 /* In milli second default value for Production FW */
45 #define IOCTL_RESP_TIMEOUT DEFAULT_IOCTL_RESP_TIMEOUT
46 #endif /* IOCTL_RESP_TIMEOUT */
47
48 /* In milli second default value for Production FW */
49 #define IOCTL_DMAXFER_TIMEOUT 10000
50
51 #ifndef MFG_IOCTL_RESP_TIMEOUT
52 #define MFG_IOCTL_RESP_TIMEOUT \
53 20000 /* In milli second default value for MFG FW */
54 #endif /* MFG_IOCTL_RESP_TIMEOUT */
55
56 #define DEFAULT_D3_ACK_RESP_TIMEOUT 2000
57 #ifndef D3_ACK_RESP_TIMEOUT
58 #define D3_ACK_RESP_TIMEOUT DEFAULT_D3_ACK_RESP_TIMEOUT
59 #endif /* D3_ACK_RESP_TIMEOUT */
60
61 #define DEFAULT_DHD_BUS_BUSY_TIMEOUT (IOCTL_RESP_TIMEOUT + 1000)
62 #ifndef DHD_BUS_BUSY_TIMEOUT
63 #define DHD_BUS_BUSY_TIMEOUT DEFAULT_DHD_BUS_BUSY_TIMEOUT
64 #endif /* DEFAULT_DHD_BUS_BUSY_TIMEOUT */
65
66 #define DS_EXIT_TIMEOUT 1000 /* In ms */
67 #define DS_ENTER_TIMEOUT 1000 /* In ms */
68
69 #define IOCTL_DISABLE_TIMEOUT 0
70
71 /*
72 * Exported from the dhd protocol module (dhd_cdc, dhd_rndis)
73 */
74
75 /* Linkage, sets prot link and updates hdrlen in pub */
76 extern int dhd_prot_attach(dhd_pub_t *dhdp);
77
78 /* Initilizes the index block for dma'ing indices */
79 extern int dhd_prot_dma_indx_init(dhd_pub_t *dhdp, uint32 rw_index_sz,
80 uint8 type, uint32 length);
81
82 /* Unlink, frees allocated protocol memory (including dhd_prot) */
83 extern void dhd_prot_detach(dhd_pub_t *dhdp);
84
85 /* Initialize protocol: sync w/dongle state.
86 * Sets dongle media info (iswl, drv_version, mac address).
87 */
88 extern int dhd_sync_with_dongle(dhd_pub_t *dhdp);
89
90 /* Protocol initialization needed for IOCTL/IOVAR path */
91 extern int dhd_prot_init(dhd_pub_t *dhd);
92
93 /* Stop protocol: sync w/dongle state. */
94 extern void dhd_prot_stop(dhd_pub_t *dhdp);
95
96 /* Add any protocol-specific data header.
97 * Caller must reserve prot_hdrlen prepend space.
98 */
99 extern void dhd_prot_hdrpush(dhd_pub_t *, int ifidx, void *txp);
100 extern uint dhd_prot_hdrlen(dhd_pub_t *, void *txp);
101
102 /* Remove any protocol-specific data header. */
103 extern int dhd_prot_hdrpull(dhd_pub_t *, int *ifidx, void *rxp, uchar *buf,
104 uint *len);
105
106 /* Use protocol to issue ioctl to dongle */
107 extern int dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf,
108 int len);
109
110 /* Handles a protocol control response asynchronously */
111 extern int dhd_prot_ctl_complete(dhd_pub_t *dhd);
112
113 /* Check for and handle local prot-specific iovar commands */
114 extern int dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name, void *params,
115 int plen, void *arg, int len, bool set);
116
117 /* Add prot dump output to a buffer */
118 extern void dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
119
120 /* Dump extended trap data */
121 extern int dhd_prot_dump_extended_trap(dhd_pub_t *dhdp, struct bcmstrbuf *b,
122 bool raw);
123
124 /* Update local copy of dongle statistics */
125 extern void dhd_prot_dstats(dhd_pub_t *dhdp);
126
127 extern int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf,
128 uint buflen);
129
130 extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
131
132 extern int dhd_process_pkt_reorder_info(dhd_pub_t *dhd, uchar *reorder_info_buf,
133 uint reorder_info_len, void **pkt,
134 uint32 *free_buf_count);
135
136 #ifdef BCMPCIE
137 extern bool dhd_prot_process_msgbuf_txcpl(dhd_pub_t *dhd, uint bound,
138 int ringtype);
139 extern bool dhd_prot_process_msgbuf_rxcpl(dhd_pub_t *dhd, uint bound,
140 int ringtype);
141 extern bool dhd_prot_process_msgbuf_infocpl(dhd_pub_t *dhd, uint bound);
142 extern int dhd_prot_process_ctrlbuf(dhd_pub_t *dhd);
143 extern int dhd_prot_process_trapbuf(dhd_pub_t *dhd);
144 extern bool dhd_prot_dtohsplit(dhd_pub_t *dhd);
145 extern int dhd_post_dummy_msg(dhd_pub_t *dhd);
146 extern int dhdmsgbuf_lpbk_req(dhd_pub_t *dhd, uint len);
147 extern void dhd_prot_rx_dataoffset(dhd_pub_t *dhd, uint32 offset);
148 extern int dhd_prot_txdata(dhd_pub_t *dhd, void *p, uint8 ifidx);
149 extern int dhdmsgbuf_dmaxfer_req(dhd_pub_t *dhd, uint len, uint srcdelay,
150 uint destdelay, uint d11_lpbk, uint core_num);
151 extern int dhdmsgbuf_dmaxfer_status(dhd_pub_t *dhd, dma_xfer_info_t *result);
152
153 extern void dhd_dma_buf_init(dhd_pub_t *dhd, void *dma_buf, void *va,
154 uint32 len, dmaaddr_t pa, void *dmah,
155 void *secdma);
156 extern void dhd_prot_flowrings_pool_release(dhd_pub_t *dhd, uint16 flowid,
157 void *msgbuf_ring);
158 extern int dhd_prot_flow_ring_create(dhd_pub_t *dhd,
159 flow_ring_node_t *flow_ring_node);
160 extern int dhd_post_tx_ring_item(dhd_pub_t *dhd, void *PKTBUF, uint8 ifindex);
161 extern int dhd_prot_flow_ring_delete(dhd_pub_t *dhd,
162 flow_ring_node_t *flow_ring_node);
163 extern int dhd_prot_flow_ring_flush(dhd_pub_t *dhd,
164 flow_ring_node_t *flow_ring_node);
165 extern int dhd_prot_ringupd_dump(dhd_pub_t *dhd, struct bcmstrbuf *b);
166 extern uint32 dhd_prot_metadata_dbg_set(dhd_pub_t *dhd, bool val);
167 extern uint32 dhd_prot_metadata_dbg_get(dhd_pub_t *dhd);
168 extern uint32 dhd_prot_metadatalen_set(dhd_pub_t *dhd, uint32 val, bool rx);
169 extern uint32 dhd_prot_metadatalen_get(dhd_pub_t *dhd, bool rx);
170 extern void dhd_prot_print_flow_ring(dhd_pub_t *dhd, void *msgbuf_flow_info,
171 struct bcmstrbuf *strbuf, const char *fmt);
172 extern void dhd_prot_print_info(dhd_pub_t *dhd, struct bcmstrbuf *strbuf);
173 extern void dhd_prot_update_txflowring(dhd_pub_t *dhdp, uint16 flow_id,
174 void *msgring_info);
175 extern void dhd_prot_txdata_write_flush(dhd_pub_t *dhd, uint16 flow_id);
176 extern uint32 dhd_prot_txp_threshold(dhd_pub_t *dhd, bool set, uint32 val);
177 extern void dhd_prot_reset(dhd_pub_t *dhd);
178 extern uint16 dhd_get_max_flow_rings(dhd_pub_t *dhd);
179
180 #ifdef IDLE_TX_FLOW_MGMT
181 extern int dhd_prot_flow_ring_batch_suspend_request(dhd_pub_t *dhd,
182 uint16 *ringid,
183 uint16 count);
184 extern int dhd_prot_flow_ring_resume(dhd_pub_t *dhd,
185 flow_ring_node_t *flow_ring_node);
186 #endif /* IDLE_TX_FLOW_MGMT */
187 extern int dhd_prot_init_info_rings(dhd_pub_t *dhd);
188 #ifdef DHD_HP2P
189 extern int dhd_prot_init_hp2p_rings(dhd_pub_t *dhd);
190 #endif /* DHD_HP2P */
191
192 extern int dhd_prot_check_tx_resource(dhd_pub_t *dhd);
193
194 extern void dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t *dhd);
195 extern void dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t *dhd);
196 #else
dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t * dhd)197 static INLINE void dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t *dhd)
198 {
199 return;
200 }
dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t * dhd)201 static INLINE void dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t *dhd)
202 {
203 return;
204 }
205 #endif /* BCMPCIE */
206
207 #ifdef DHD_LB
208 extern void dhd_lb_tx_compl_handler(unsigned long data);
209 extern void dhd_lb_rx_compl_handler(unsigned long data);
210 extern void dhd_lb_rx_process_handler(unsigned long data);
211 #endif /* DHD_LB */
212 extern int dhd_prot_h2d_mbdata_send_ctrlmsg(dhd_pub_t *dhd, uint32 mb_data);
213
214 #ifdef BCMPCIE
215 extern int dhd_prot_send_host_timestamp(dhd_pub_t *dhdp, uchar *tlv,
216 uint16 tlv_len, uint16 seq,
217 uint16 xt_id);
218 extern bool dhd_prot_data_path_tx_timestamp_logging(dhd_pub_t *dhd, bool enable,
219 bool set);
220 extern bool dhd_prot_data_path_rx_timestamp_logging(dhd_pub_t *dhd, bool enable,
221 bool set);
222 extern bool dhd_prot_pkt_noretry(dhd_pub_t *dhd, bool enable, bool set);
223 extern bool dhd_prot_pkt_noaggr(dhd_pub_t *dhd, bool enable, bool set);
224 extern bool dhd_prot_pkt_fixed_rate(dhd_pub_t *dhd, bool enable, bool set);
225 #else /* BCMPCIE */
226 #define dhd_prot_send_host_timestamp(a, b, c, d, e) 0
227 #define dhd_prot_data_path_tx_timestamp_logging(a, b, c) 0
228 #define dhd_prot_data_path_rx_timestamp_logging(a, b, c) 0
229 #endif /* BCMPCIE */
230
231 extern void dhd_prot_dma_indx_free(dhd_pub_t *dhd);
232
233 #ifdef EWP_EDL
234 int dhd_prot_init_edl_rings(dhd_pub_t *dhd);
235 bool dhd_prot_process_msgbuf_edl(dhd_pub_t *dhd);
236 int dhd_prot_process_edl_complete(dhd_pub_t *dhd, void *evt_decode_data);
237 #endif /* EWP_EDL */
238
239 /* APIs for managing a DMA-able buffer */
240 int dhd_dma_buf_alloc(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf, uint32 buf_len);
241 void dhd_dma_buf_free(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf);
242
243 /********************************
244 * For version-string expansion *
245 */
246 #if defined(BDC)
247 #define DHD_PROTOCOL "bdc"
248 #elif defined(CDC)
249 #define DHD_PROTOCOL "cdc"
250 #else
251 #define DHD_PROTOCOL "unknown"
252 #endif /* proto */
253
254 int dhd_get_hscb_info(dhd_pub_t *dhd, void **va, uint32 *len);
255 int dhd_get_hscb_buff(dhd_pub_t *dhd, uint32 offset, uint32 length, void *buff);
256
257 #ifdef DHD_HP2P
258 extern uint8 dhd_prot_hp2p_enable(dhd_pub_t *dhd, bool set, int enable);
259 extern uint32 dhd_prot_pkt_threshold(dhd_pub_t *dhd, bool set, uint32 val);
260 extern uint32 dhd_prot_time_threshold(dhd_pub_t *dhd, bool set, uint32 val);
261 extern uint32 dhd_prot_pkt_expiry(dhd_pub_t *dhd, bool set, uint32 val);
262 #endif // endif
263
264 #ifdef DHD_MAP_LOGGING
265 extern void dhd_prot_smmu_fault_dump(dhd_pub_t *dhdp);
266 #endif /* DHD_MAP_LOGGING */
267 #endif /* _dhd_proto_h_ */
268