• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) 2020, 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 of
19  * the license of that module.  An independent module is a module which is not
20  * derived from this software.  The special exception does not apply to any
21  * modifications of the software.
22  *
23  *
24  * <<Broadcom-WL-IPTag/Open:>>
25  *
26  * $Id$
27  */
28 
29 #ifndef _dhd_proto_h_
30 #define _dhd_proto_h_
31 
32 #include <dhdioctl.h>
33 #include <wlioctl.h>
34 #ifdef BCMPCIE
35 #include <dhd_flowring.h>
36 #endif
37 
38 #ifdef BCMINTERNAL
39 #ifdef DHD_FWTRACE
40 #include <bcm_fwtrace.h>
41 #endif /* DHD_FWTRACE */
42 #endif /* BCMINTERNAL */
43 
44 #define DEFAULT_IOCTL_RESP_TIMEOUT	(5 * 1000) /* 5 seconds */
45 #ifndef IOCTL_RESP_TIMEOUT
46 #if defined(BCMQT_HW)
47 #define IOCTL_RESP_TIMEOUT  (600 * 1000) /* 600 sec in real time */
48 #elif defined(BCMFPGA_HW)
49 #define IOCTL_RESP_TIMEOUT  (60 * 1000) /* 60 sec in real time */
50 #else
51 /* In milli second default value for Production FW */
52 #define IOCTL_RESP_TIMEOUT  DEFAULT_IOCTL_RESP_TIMEOUT
53 #endif /* BCMQT */
54 #endif /* IOCTL_RESP_TIMEOUT */
55 
56 #if defined(BCMQT_HW)
57 #define IOCTL_DMAXFER_TIMEOUT  (260 * 1000) /* 260 seconds second */
58 #elif defined(BCMFPGA_HW)
59 #define IOCTL_DMAXFER_TIMEOUT  (120 * 1000) /* 120 seconds */
60 #else
61 /* In milli second default value for Production FW */
62 #define IOCTL_DMAXFER_TIMEOUT  (15 * 1000) /* 15 seconds for Production FW */
63 #endif /* BCMQT */
64 
65 #ifndef MFG_IOCTL_RESP_TIMEOUT
66 #define MFG_IOCTL_RESP_TIMEOUT  20000  /* In milli second default value for MFG FW */
67 #endif /* MFG_IOCTL_RESP_TIMEOUT */
68 
69 #define DEFAULT_D3_ACK_RESP_TIMEOUT	2000
70 #ifndef D3_ACK_RESP_TIMEOUT
71 #define D3_ACK_RESP_TIMEOUT		DEFAULT_D3_ACK_RESP_TIMEOUT
72 #endif /* D3_ACK_RESP_TIMEOUT */
73 
74 #define DEFAULT_DHD_BUS_BUSY_TIMEOUT	(IOCTL_RESP_TIMEOUT + 1000)
75 #ifndef DHD_BUS_BUSY_TIMEOUT
76 #define DHD_BUS_BUSY_TIMEOUT	DEFAULT_DHD_BUS_BUSY_TIMEOUT
77 #endif /* DEFAULT_DHD_BUS_BUSY_TIMEOUT */
78 
79 #define DS_EXIT_TIMEOUT	1000 /* In ms */
80 #define DS_ENTER_TIMEOUT 1000 /* In ms */
81 
82 #define IOCTL_DISABLE_TIMEOUT 0
83 
84 /*
85  * Exported from the dhd protocol module (dhd_cdc, dhd_rndis)
86  */
87 
88 /* Linkage, sets prot link and updates hdrlen in pub */
89 extern int dhd_prot_attach(dhd_pub_t *dhdp);
90 
91 /* Initilizes the index block for dma'ing indices */
92 extern int dhd_prot_dma_indx_init(dhd_pub_t *dhdp, uint32 rw_index_sz,
93 	uint8 type, uint32 length);
94 #ifdef DHD_DMA_INDICES_SEQNUM
95 extern int dhd_prot_dma_indx_copybuf_init(dhd_pub_t *dhd, uint32 buf_sz,
96 	uint8 type);
97 extern uint32 dhd_prot_read_seqnum(dhd_pub_t *dhd, bool host);
98 extern void dhd_prot_write_host_seqnum(dhd_pub_t *dhd, uint32 seq_num);
99 extern void dhd_prot_save_dmaidx(dhd_pub_t *dhd);
100 #endif /* DHD_DMA_INDICES_SEQNUM */
101 /* Unlink, frees allocated protocol memory (including dhd_prot) */
102 extern void dhd_prot_detach(dhd_pub_t *dhdp);
103 
104 /* Initialize protocol: sync w/dongle state.
105  * Sets dongle media info (iswl, drv_version, mac address).
106  */
107 extern int dhd_sync_with_dongle(dhd_pub_t *dhdp);
108 
109 /* Protocol initialization needed for IOCTL/IOVAR path */
110 extern int dhd_prot_init(dhd_pub_t *dhd);
111 
112 /* Stop protocol: sync w/dongle state. */
113 extern void dhd_prot_stop(dhd_pub_t *dhdp);
114 
115 /* Add any protocol-specific data header.
116  * Caller must reserve prot_hdrlen prepend space.
117  */
118 extern void dhd_prot_hdrpush(dhd_pub_t *, int ifidx, void *txp);
119 extern uint dhd_prot_hdrlen(dhd_pub_t *, void *txp);
120 
121 /* Remove any protocol-specific data header. */
122 extern int dhd_prot_hdrpull(dhd_pub_t *, int *ifidx, void *rxp, uchar *buf, uint *len);
123 
124 /* Use protocol to issue ioctl to dongle */
125 extern int dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len);
126 
127 /* Handles a protocol control response asynchronously */
128 extern int dhd_prot_ctl_complete(dhd_pub_t *dhd);
129 
130 /* Check for and handle local prot-specific iovar commands */
131 extern int dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name,
132                              void *params, int plen, void *arg, int len, bool set);
133 
134 /* Add prot dump output to a buffer */
135 extern void dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
136 
137 /* Dump extended trap data */
138 extern int dhd_prot_dump_extended_trap(dhd_pub_t *dhdp, struct bcmstrbuf *b, bool raw);
139 
140 /* Update local copy of dongle statistics */
141 extern void dhd_prot_dstats(dhd_pub_t *dhdp);
142 
143 extern int dhd_ioctl(dhd_pub_t * dhd_pub, dhd_ioctl_t *ioc, void * buf, uint buflen);
144 
145 extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
146 
147 extern int dhd_process_pkt_reorder_info(dhd_pub_t *dhd, uchar *reorder_info_buf,
148 	uint reorder_info_len, void **pkt, uint32 *free_buf_count);
149 
150 #ifdef BCMPCIE
151 extern bool dhd_prot_process_msgbuf_txcpl(dhd_pub_t *dhd, uint bound, int ringtype);
152 extern bool dhd_prot_process_msgbuf_rxcpl(dhd_pub_t *dhd, uint bound, int ringtype);
153 extern bool dhd_prot_process_msgbuf_infocpl(dhd_pub_t *dhd, uint bound);
154 #ifdef BTLOG
155 extern bool dhd_prot_process_msgbuf_btlogcpl(dhd_pub_t *dhd, uint bound);
156 #endif	/* BTLOG */
157 extern int dhd_prot_process_ctrlbuf(dhd_pub_t * dhd);
158 extern int dhd_prot_process_trapbuf(dhd_pub_t * dhd);
159 extern bool dhd_prot_dtohsplit(dhd_pub_t * dhd);
160 extern int dhd_post_dummy_msg(dhd_pub_t *dhd);
161 extern int dhdmsgbuf_lpbk_req(dhd_pub_t *dhd, uint len);
162 extern void dhd_prot_rx_dataoffset(dhd_pub_t *dhd, uint32 offset);
163 extern int dhd_prot_txdata(dhd_pub_t *dhd, void *p, uint8 ifidx);
164 extern void dhd_prot_schedule_aggregate_h2d_db(dhd_pub_t *dhd, uint16 flow_id);
165 extern int dhdmsgbuf_dmaxfer_req(dhd_pub_t *dhd,
166 	uint len, uint srcdelay, uint destdelay, uint d11_lpbk, uint core_num,
167 	uint32 mem_addr);
168 extern int dhdmsgbuf_dmaxfer_status(dhd_pub_t *dhd, dma_xfer_info_t *result);
169 
170 extern void dhd_dma_buf_init(dhd_pub_t *dhd, void *dma_buf,
171 	void *va, uint32 len, dmaaddr_t pa, void *dmah, void *secdma);
172 extern void dhd_prot_flowrings_pool_release(dhd_pub_t *dhd,
173 	uint16 flowid, void *msgbuf_ring);
174 extern int dhd_prot_flow_ring_create(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
175 extern int dhd_post_tx_ring_item(dhd_pub_t *dhd, void *PKTBUF, uint8 ifindex);
176 extern int dhd_prot_flow_ring_delete(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
177 extern int dhd_prot_flow_ring_flush(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
178 extern int dhd_prot_ringupd_dump(dhd_pub_t *dhd, struct bcmstrbuf *b);
179 extern uint32 dhd_prot_metadata_dbg_set(dhd_pub_t *dhd, bool val);
180 extern uint32 dhd_prot_metadata_dbg_get(dhd_pub_t *dhd);
181 extern uint32 dhd_prot_metadatalen_set(dhd_pub_t *dhd, uint32 val, bool rx);
182 extern uint32 dhd_prot_metadatalen_get(dhd_pub_t *dhd, bool rx);
183 extern void dhd_prot_print_flow_ring(dhd_pub_t *dhd, void *msgbuf_flow_info, bool h2d,
184 	struct bcmstrbuf *strbuf, const char * fmt);
185 extern void dhd_prot_print_info(dhd_pub_t *dhd, struct bcmstrbuf *strbuf);
186 extern void dhd_prot_update_txflowring(dhd_pub_t *dhdp, uint16 flow_id, void *msgring_info);
187 extern void dhd_prot_txdata_write_flush(dhd_pub_t *dhd, uint16 flow_id);
188 extern uint32 dhd_prot_txp_threshold(dhd_pub_t *dhd, bool set, uint32 val);
189 extern void dhd_prot_reset(dhd_pub_t *dhd);
190 extern uint16 dhd_get_max_flow_rings(dhd_pub_t *dhd);
191 
192 #ifdef IDLE_TX_FLOW_MGMT
193 extern int dhd_prot_flow_ring_batch_suspend_request(dhd_pub_t *dhd, uint16 *ringid, uint16 count);
194 extern int dhd_prot_flow_ring_resume(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
195 #endif /* IDLE_TX_FLOW_MGMT */
196 extern int dhd_prot_init_info_rings(dhd_pub_t *dhd);
197 #ifdef BTLOG
198 extern int dhd_prot_init_btlog_rings(dhd_pub_t *dhd);
199 #endif	/* BTLOG */
200 #ifdef DHD_HP2P
201 extern int dhd_prot_init_hp2p_rings(dhd_pub_t *dhd);
202 #endif /* DHD_HP2P */
203 extern int dhd_prot_check_tx_resource(dhd_pub_t *dhd);
204 #endif /* BCMPCIE */
205 
206 #ifdef DHD_LB
207 extern void dhd_lb_tx_compl_handler(unsigned long data);
208 extern void dhd_lb_rx_compl_handler(unsigned long data);
209 extern void dhd_lb_rx_process_handler(unsigned long data);
210 #endif /* DHD_LB */
211 extern int dhd_prot_h2d_mbdata_send_ctrlmsg(dhd_pub_t *dhd, uint32 mb_data);
212 
213 #ifdef BCMPCIE
214 extern int dhd_prot_send_host_timestamp(dhd_pub_t *dhdp, uchar *tlv, uint16 tlv_len,
215 	uint16 seq, uint16 xt_id);
216 extern bool dhd_prot_data_path_tx_timestamp_logging(dhd_pub_t *dhd,  bool enable, bool set);
217 extern bool dhd_prot_data_path_rx_timestamp_logging(dhd_pub_t *dhd,  bool enable, bool set);
218 extern bool dhd_prot_pkt_noretry(dhd_pub_t *dhd, bool enable, bool set);
219 extern bool dhd_prot_pkt_noaggr(dhd_pub_t *dhd, bool enable, bool set);
220 extern bool dhd_prot_pkt_fixed_rate(dhd_pub_t *dhd, bool enable, bool set);
221 #else /* BCMPCIE */
222 #define dhd_prot_send_host_timestamp(a, b, c, d, e)		0
223 #define dhd_prot_data_path_tx_timestamp_logging(a, b, c)	0
224 #define dhd_prot_data_path_rx_timestamp_logging(a, b, c)	0
225 #endif /* BCMPCIE */
226 
227 extern void dhd_prot_dma_indx_free(dhd_pub_t *dhd);
228 
229 #ifdef SNAPSHOT_UPLOAD
230 /* send request to take snapshot */
231 int dhd_prot_send_snapshot_request(dhd_pub_t *dhdp, uint8 snapshot_type, uint8 snapshot_param);
232 /* get uploaded snapshot */
233 int dhd_prot_get_snapshot(dhd_pub_t *dhdp, uint8 snapshot_type, uint32 offset,
234 	uint32 dst_buf_size, uint8 *dst_buf, uint32 *dst_size, bool *is_more);
235 #endif	/* SNAPSHOT_UPLOAD */
236 
237 #ifdef EWP_EDL
238 int dhd_prot_init_edl_rings(dhd_pub_t *dhd);
239 bool dhd_prot_process_msgbuf_edl(dhd_pub_t *dhd);
240 int dhd_prot_process_edl_complete(dhd_pub_t *dhd, void *evt_decode_data);
241 #endif /* EWP_EDL  */
242 
243 /* APIs for managing a DMA-able buffer */
244 int  dhd_dma_buf_alloc(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf, uint32 buf_len);
245 void dhd_dma_buf_free(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf);
246 void dhd_local_buf_reset(char *buf, uint32 len);
247 
248 /********************************
249  * For version-string expansion *
250  */
251 #if defined(BDC)
252 #define DHD_PROTOCOL "bdc"
253 #elif defined(CDC)
254 #define DHD_PROTOCOL "cdc"
255 #else
256 #define DHD_PROTOCOL "unknown"
257 #endif /* proto */
258 
259 int dhd_get_hscb_info(dhd_pub_t *dhd, void ** va, uint32 *len);
260 int dhd_get_hscb_buff(dhd_pub_t *dhd, uint32 offset, uint32 length, void * buff);
261 
262 #ifdef BCMINTERNAL
263 typedef struct host_page_location_info {
264 	uint32 addr_lo;
265 	uint32 addr_hi;
266 	uint32 binary_size;
267 	uint32 tlv_size;
268 	uint32 tlv_signature;
269 } host_page_location_info_t;
270 #define BCM_HOST_PAGE_LOCATION_SIGNATURE	0xFEED10C5u
271 
272 #ifdef DHD_FWTRACE
273 typedef struct host_fwtrace_buf_location_info {
274 	fwtrace_hostaddr_info_t host_buf_info;
275 	uint32 tlv_size;
276 	uint32 tlv_signature;
277 } host_fwtrace_buf_location_info_t;
278 /* Host buffer info for pushing the trace info */
279 #define BCM_HOST_FWTRACE_BUF_LOCATION_SIGNATURE	0xFEED10C6u
280 #endif /* DHD_FWTRACE */
281 #endif /* BCMINTERNAL */
282 
283 #ifdef DHD_HP2P
284 extern uint8 dhd_prot_hp2p_enable(dhd_pub_t *dhd, bool set, int enable);
285 extern uint32 dhd_prot_pkt_threshold(dhd_pub_t *dhd, bool set, uint32 val);
286 extern uint32 dhd_prot_time_threshold(dhd_pub_t *dhd, bool set, uint32 val);
287 extern uint32 dhd_prot_pkt_expiry(dhd_pub_t *dhd, bool set, uint32 val);
288 #endif
289 
290 #ifdef DHD_MAP_LOGGING
291 extern void dhd_prot_smmu_fault_dump(dhd_pub_t *dhdp);
292 #endif /* DHD_MAP_LOGGING */
293 
294 extern uint16 dhd_prot_get_h2d_max_txpost(dhd_pub_t *dhd);
295 extern void dhd_prot_set_h2d_max_txpost(dhd_pub_t *dhd, uint16 max_txpost);
296 
297 #if defined(DHD_HTPUT_TUNABLES)
298 extern uint16 dhd_prot_get_h2d_htput_max_txpost(dhd_pub_t *dhd);
299 extern void dhd_prot_set_h2d_htput_max_txpost(dhd_pub_t *dhd, uint16 max_txpost);
300 #endif /* DHD_HTPUT_TUNABLES */
301 
302 #endif /* _dhd_proto_h_ */
303