1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Header file describing the internal (inter-module) DHD interfaces.
4 *
5 * Provides type definitions and function prototypes used to link the
6 * DHD OS, bus, and protocol modules.
7 *
8 * Copyright (C) 1999-2019, Broadcom.
9 *
10 * Unless you and Broadcom execute a separate written software license
11 * agreement governing use of this software, this software is licensed to you
12 * under the terms of the GNU General Public License version 2 (the "GPL"),
13 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
14 * following added to such license:
15 *
16 * As a special exception, the copyright holders of this software give you
17 * permission to link this software with independent modules, and to copy and
18 * distribute the resulting executable under terms of your choice, provided that
19 * you also meet, for each linked independent module, the terms and conditions of
20 * the license of that module. An independent module is a module which is not
21 * derived from this software. The special exception does not apply to any
22 * modifications of the software.
23 *
24 * Notwithstanding the above, under no circumstances may you combine this
25 * software in any way with any other Broadcom software provided under a license
26 * other than the GPL, without Broadcom's express prior written consent.
27 *
28 *
29 * <<Broadcom-WL-IPTag/Open:>>
30 *
31 * $Id: dhd_proto.h 814912 2019-04-15 10:38:59Z $
32 */
33
34 #ifndef _dhd_proto_h_
35 #define _dhd_proto_h_
36
37 #include <dhdioctl.h>
38 #include <wlioctl.h>
39 #ifdef BCMPCIE
40 #include <dhd_flowring.h>
41 #endif // endif
42
43 #define DEFAULT_IOCTL_RESP_TIMEOUT 5000
44 #ifndef IOCTL_RESP_TIMEOUT
45 /* In milli second default value for Production FW */
46 #define IOCTL_RESP_TIMEOUT DEFAULT_IOCTL_RESP_TIMEOUT
47 #endif /* IOCTL_RESP_TIMEOUT */
48
49 /* In milli second default value for Production FW */
50 #define IOCTL_DMAXFER_TIMEOUT 10000
51
52 #ifndef MFG_IOCTL_RESP_TIMEOUT
53 #define MFG_IOCTL_RESP_TIMEOUT 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, uint *len);
104
105 /* Use protocol to issue ioctl to dongle */
106 extern int dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len);
107
108 /* Handles a protocol control response asynchronously */
109 extern int dhd_prot_ctl_complete(dhd_pub_t *dhd);
110
111 /* Check for and handle local prot-specific iovar commands */
112 extern int dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name,
113 void *params, int plen, void *arg, int len, bool set);
114
115 /* Add prot dump output to a buffer */
116 extern void dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
117
118 /* Dump extended trap data */
119 extern int dhd_prot_dump_extended_trap(dhd_pub_t *dhdp, struct bcmstrbuf *b, bool raw);
120
121 /* Update local copy of dongle statistics */
122 extern void dhd_prot_dstats(dhd_pub_t *dhdp);
123
124 extern int dhd_ioctl(dhd_pub_t * dhd_pub, dhd_ioctl_t *ioc, void * buf, uint buflen);
125
126 extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
127
128 extern int dhd_process_pkt_reorder_info(dhd_pub_t *dhd, uchar *reorder_info_buf,
129 uint reorder_info_len, void **pkt, uint32 *free_buf_count);
130
131 #ifdef BCMPCIE
132 extern bool dhd_prot_process_msgbuf_txcpl(dhd_pub_t *dhd, uint bound, int ringtype);
133 extern bool dhd_prot_process_msgbuf_rxcpl(dhd_pub_t *dhd, uint bound, int ringtype);
134 extern bool dhd_prot_process_msgbuf_infocpl(dhd_pub_t *dhd, uint bound);
135 extern int dhd_prot_process_ctrlbuf(dhd_pub_t * dhd);
136 extern int dhd_prot_process_trapbuf(dhd_pub_t * dhd);
137 extern bool dhd_prot_dtohsplit(dhd_pub_t * dhd);
138 extern int dhd_post_dummy_msg(dhd_pub_t *dhd);
139 extern int dhdmsgbuf_lpbk_req(dhd_pub_t *dhd, uint len);
140 extern void dhd_prot_rx_dataoffset(dhd_pub_t *dhd, uint32 offset);
141 extern int dhd_prot_txdata(dhd_pub_t *dhd, void *p, uint8 ifidx);
142 extern int dhdmsgbuf_dmaxfer_req(dhd_pub_t *dhd,
143 uint len, uint srcdelay, uint destdelay, uint d11_lpbk, uint core_num);
144 extern int dhdmsgbuf_dmaxfer_status(dhd_pub_t *dhd, dma_xfer_info_t *result);
145
146 extern void dhd_dma_buf_init(dhd_pub_t *dhd, void *dma_buf,
147 void *va, uint32 len, dmaaddr_t pa, void *dmah, void *secdma);
148 extern void dhd_prot_flowrings_pool_release(dhd_pub_t *dhd,
149 uint16 flowid, void *msgbuf_ring);
150 extern int dhd_prot_flow_ring_create(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
151 extern int dhd_post_tx_ring_item(dhd_pub_t *dhd, void *PKTBUF, uint8 ifindex);
152 extern int dhd_prot_flow_ring_delete(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
153 extern int dhd_prot_flow_ring_flush(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
154 extern int dhd_prot_ringupd_dump(dhd_pub_t *dhd, struct bcmstrbuf *b);
155 extern uint32 dhd_prot_metadata_dbg_set(dhd_pub_t *dhd, bool val);
156 extern uint32 dhd_prot_metadata_dbg_get(dhd_pub_t *dhd);
157 extern uint32 dhd_prot_metadatalen_set(dhd_pub_t *dhd, uint32 val, bool rx);
158 extern uint32 dhd_prot_metadatalen_get(dhd_pub_t *dhd, bool rx);
159 extern void dhd_prot_print_flow_ring(dhd_pub_t *dhd, void *msgbuf_flow_info,
160 struct bcmstrbuf *strbuf, const char * fmt);
161 extern void dhd_prot_print_info(dhd_pub_t *dhd, struct bcmstrbuf *strbuf);
162 extern void dhd_prot_update_txflowring(dhd_pub_t *dhdp, uint16 flow_id, void *msgring_info);
163 extern void dhd_prot_txdata_write_flush(dhd_pub_t *dhd, uint16 flow_id);
164 extern uint32 dhd_prot_txp_threshold(dhd_pub_t *dhd, bool set, uint32 val);
165 extern void dhd_prot_reset(dhd_pub_t *dhd);
166 extern uint16 dhd_get_max_flow_rings(dhd_pub_t *dhd);
167
168 #ifdef IDLE_TX_FLOW_MGMT
169 extern int dhd_prot_flow_ring_batch_suspend_request(dhd_pub_t *dhd, uint16 *ringid, uint16 count);
170 extern int dhd_prot_flow_ring_resume(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node);
171 #endif /* IDLE_TX_FLOW_MGMT */
172 extern int dhd_prot_init_info_rings(dhd_pub_t *dhd);
173 #ifdef DHD_HP2P
174 extern int dhd_prot_init_hp2p_rings(dhd_pub_t *dhd);
175 #endif /* DHD_HP2P */
176
177 extern int dhd_prot_check_tx_resource(dhd_pub_t *dhd);
178
179 extern void dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t *dhd);
180 extern void dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t *dhd);
181 #else
dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t * dhd)182 static INLINE void dhd_prot_update_pktid_txq_stop_cnt(dhd_pub_t *dhd) { return; }
dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t * dhd)183 static INLINE void dhd_prot_update_pktid_txq_start_cnt(dhd_pub_t *dhd) { return; }
184 #endif /* BCMPCIE */
185
186 #ifdef DHD_LB
187 extern void dhd_lb_tx_compl_handler(unsigned long data);
188 extern void dhd_lb_rx_compl_handler(unsigned long data);
189 extern void dhd_lb_rx_process_handler(unsigned long data);
190 #endif /* DHD_LB */
191 extern int dhd_prot_h2d_mbdata_send_ctrlmsg(dhd_pub_t *dhd, uint32 mb_data);
192
193 #ifdef BCMPCIE
194 extern int dhd_prot_send_host_timestamp(dhd_pub_t *dhdp, uchar *tlv, uint16 tlv_len,
195 uint16 seq, uint16 xt_id);
196 extern bool dhd_prot_data_path_tx_timestamp_logging(dhd_pub_t *dhd, bool enable, bool set);
197 extern bool dhd_prot_data_path_rx_timestamp_logging(dhd_pub_t *dhd, bool enable, bool set);
198 extern bool dhd_prot_pkt_noretry(dhd_pub_t *dhd, bool enable, bool set);
199 extern bool dhd_prot_pkt_noaggr(dhd_pub_t *dhd, bool enable, bool set);
200 extern bool dhd_prot_pkt_fixed_rate(dhd_pub_t *dhd, bool enable, bool set);
201 #else /* BCMPCIE */
202 #define dhd_prot_send_host_timestamp(a, b, c, d, e) 0
203 #define dhd_prot_data_path_tx_timestamp_logging(a, b, c) 0
204 #define dhd_prot_data_path_rx_timestamp_logging(a, b, c) 0
205 #endif /* BCMPCIE */
206
207 extern void dhd_prot_dma_indx_free(dhd_pub_t *dhd);
208
209 #ifdef EWP_EDL
210 int dhd_prot_init_edl_rings(dhd_pub_t *dhd);
211 bool dhd_prot_process_msgbuf_edl(dhd_pub_t *dhd);
212 int dhd_prot_process_edl_complete(dhd_pub_t *dhd, void *evt_decode_data);
213 #endif /* EWP_EDL */
214
215 /* APIs for managing a DMA-able buffer */
216 int dhd_dma_buf_alloc(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf, uint32 buf_len);
217 void dhd_dma_buf_free(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf);
218
219 /********************************
220 * For version-string expansion *
221 */
222 #if defined(BDC)
223 #define DHD_PROTOCOL "bdc"
224 #elif defined(CDC)
225 #define DHD_PROTOCOL "cdc"
226 #else
227 #define DHD_PROTOCOL "unknown"
228 #endif /* proto */
229
230 int dhd_get_hscb_info(dhd_pub_t *dhd, void ** va, uint32 *len);
231 int dhd_get_hscb_buff(dhd_pub_t *dhd, uint32 offset, uint32 length, void * buff);
232
233 #ifdef DHD_HP2P
234 extern uint8 dhd_prot_hp2p_enable(dhd_pub_t *dhd, bool set, int enable);
235 extern uint32 dhd_prot_pkt_threshold(dhd_pub_t *dhd, bool set, uint32 val);
236 extern uint32 dhd_prot_time_threshold(dhd_pub_t *dhd, bool set, uint32 val);
237 extern uint32 dhd_prot_pkt_expiry(dhd_pub_t *dhd, bool set, uint32 val);
238 #endif // endif
239
240 #ifdef DHD_MAP_LOGGING
241 extern void dhd_prot_smmu_fault_dump(dhd_pub_t *dhdp);
242 #endif /* DHD_MAP_LOGGING */
243 #endif /* _dhd_proto_h_ */
244