xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/wl_export.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Required functions exported by the port-specific (os-dependent) driver
3  * to common (os-independent) driver code.
4  *
5  * Copyright (C) 2020, Broadcom.
6  *
7  *      Unless you and Broadcom execute a separate written software license
8  * agreement governing use of this software, this software is licensed to you
9  * under the terms of the GNU General Public License version 2 (the "GPL"),
10  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11  * following added to such license:
12  *
13  *      As a special exception, the copyright holders of this software give you
14  * permission to link this software with independent modules, and to copy and
15  * distribute the resulting executable under terms of your choice, provided that
16  * you also meet, for each linked independent module, the terms and conditions of
17  * the license of that module.  An independent module is a module which is not
18  * derived from this software.  The special exception does not apply to any
19  * modifications of the software.
20  *
21  *
22  * <<Broadcom-WL-IPTag/Open:>>
23  *
24  * $Id$
25  */
26 
27 #ifndef _wl_export_h_
28 #define _wl_export_h_
29 
30 /* misc callbacks */
31 struct wl_info;
32 struct wl_if;
33 struct wlc_if;
34 struct wlc_event;
35 struct wlc_info;
36 struct wl_timer;
37 struct wl_rxsts;
38 struct wl_txsts;
39 struct reorder_rxcpl_id_list;
40 
41 /** wl_init() is called upon fault ('big hammer') conditions and as part of a 'wlc up' */
42 extern void wl_init(struct wl_info *wl);
43 extern uint wl_reset(struct wl_info *wl);
44 extern void wl_intrson(struct wl_info *wl);
45 extern void wl_intrsoff(struct wl_info *wl, bcm_int_bitmask_t *curr_mask);
46 extern void wl_intrsrestore(struct wl_info *wl, bcm_int_bitmask_t *macintmask);
47 extern int wl_up(struct wl_info *wl);
48 extern void wl_down(struct wl_info *wl);
49 extern void wl_dump_ver(struct wl_info *wl, struct bcmstrbuf *b);
50 extern void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state, int prio);
51 extern void wl_set_copycount_bytes(struct wl_info *wl, uint16 copycount,
52 	uint16 d11rxoffset);
53 extern int wl_bus_pcie_config_access(struct wl_info *wl, uint32 configaddr, uint32 *configdata,
54 	bool read);
55 
56 extern bool wl_alloc_dma_resources(struct wl_info *wl, uint dmaddrwidth);
57 
58 #ifdef TKO
59 extern void * wl_get_tko(struct wl_info *wl, struct wl_if *wlif);
60 #endif	/* TKO */
61 #ifdef ICMP
62 extern void * wl_get_icmp(struct wl_info *wl, struct wl_if *wlif);
63 #endif	/* ICMP */
64 /* timer functions */
65 extern struct wl_timer *wl_init_timer(struct wl_info *wl, void (*fn)(void* arg), void *arg,
66 	const char *name);
67 extern void wl_free_timer(struct wl_info *wl, struct wl_timer *timer);
68 /* Add timer guarantees the callback fn will not be called until AT LEAST ms later.  In the
69  *  case of a periodic timer, this guarantee is true of consecutive callback fn invocations.
70  *  As a result, the period may not average ms duration and the callbacks may "drift".
71  *
72  * A periodic timer must have a non-zero ms delay.
73  */
74 extern void wl_add_timer(struct wl_info *wl, struct wl_timer *timer, uint ms, int periodic);
75 extern void wl_add_timer_us(struct wl_info *wl, struct wl_timer *timer, uint us, int periodic);
76 extern bool wl_del_timer(struct wl_info *wl, struct wl_timer *timer);
77 
78 #ifdef WLATF_DONGLE
79 int wlfc_upd_flr_weight(struct wl_info *wl, uint8 mac_handle, uint8 tid, void* params);
80 int wlfc_enab_fair_fetch_scheduling(struct wl_info *wl, uint32 enab);
81 int wlfc_get_fair_fetch_scheduling(struct wl_info *wl, uint32 *status);
82 #endif /* WLATF_DONGLE */
83 
84 #ifdef MONITOR_DNGL_CONV
85 extern void wl_sendup_monitor(struct wl_info *wl, void *p);
86 #endif
87 
88 /* data receive and interface management functions */
89 extern void wl_sendup_fp(struct wl_info *wl, struct wl_if *wlif, void *p);
90 extern void wl_sendup(struct wl_info *wl, struct wl_if *wlif, void *p, int numpkt);
91 extern void wl_sendup_event(struct wl_info *wl, struct wl_if *wlif, void *pkt);
92 extern void wl_event(struct wl_info *wl, char *ifname, struct wlc_event *e);
93 extern void wl_event_sync(struct wl_info *wl, char *ifname, struct wlc_event *e);
94 extern void wl_event_sendup(struct wl_info *wl, const struct wlc_event *e, uint8 *data, uint32 len);
95 
96 /* interface manipulation functions */
97 extern char *wl_ifname(struct wl_info *wl, struct wl_if *wlif);
98 void wl_set_ifname(struct wl_if *wlif, char *name);
99 extern struct wl_if *wl_add_if(struct wl_info *wl, struct wlc_if* wlcif, uint unit,
100 	struct ether_addr *remote);
101 extern void wl_del_if(struct wl_info *wl, struct wl_if *wlif);
102 /* RSDB specific interface update function */
103 void wl_update_wlcif(struct wlc_if *wlcif);
104 extern void wl_update_if(struct wl_info *from_wl, struct wl_info *to_wl, struct wl_if *from_wlif,
105 	struct wlc_if *to_wlcif);
106 int wl_find_if(struct wl_if *wlif);
107 extern int wl_rebind_if(struct wl_if *wlif, int idx, bool rebind);
108 
109 /* contexts in wlif structure. Currently following are valid */
110 #define IFCTX_ARPI	(1)
111 #define IFCTX_NDI	(2)
112 #define IFCTX_NETDEV	(3)
113 extern void *wl_get_ifctx(struct wl_info *wl, int ctx_id, struct wl_if *wlif);
114 
115 /* pcie root complex operations
116 	op == 0: get link capability in configuration space
117 	op == 1: hot reset
118 */
119 extern int wl_osl_pcie_rc(struct wl_info *wl, uint op, int param);
120 
121 /* monitor mode functions */
122 #ifndef MONITOR_DNGL_CONV
123 extern void wl_monitor(struct wl_info *wl, struct wl_rxsts *rxsts, void *p);
124 #endif
125 extern void wl_set_monitor(struct wl_info *wl, int val);
126 
127 #define wl_sort_bsslist(a, b, c) FALSE
128 
129 #if defined(D0_COALESCING) || defined(WLAWDL)
130 extern void wl_sendup_no_filter(struct wl_info *wl, struct wl_if *wlif, void *p, int numpkt);
131 #endif
132 
133 #ifdef LINUX_CRYPTO
134 struct wlc_key_info;
135 extern int wl_tkip_miccheck(struct wl_info *wl, void *p, int hdr_len, bool group_key, int id);
136 extern int wl_tkip_micadd(struct wl_info *wl, void *p, int hdr_len);
137 extern int wl_tkip_encrypt(struct wl_info *wl, void *p, int hdr_len);
138 extern int wl_tkip_decrypt(struct wl_info *wl, void *p, int hdr_len, bool group_key);
139 extern void wl_tkip_printstats(struct wl_info *wl, bool group_key);
140 #ifdef BCMINTERNAL
141 extern int wl_tkip_keydump(struct wl_info *wl, bool group);
142 #endif /*  BCMINTERNAL */
143 extern int wl_tkip_keyset(struct wl_info *wl, const struct wlc_key_info *key_info,
144 	const uint8 *key_data, size_t key_len, const uint8 *rx_seq, size_t rx_seq_len);
145 #endif /* LINUX_CRYPTO */
146 
147 #ifdef DONGLEBUILD
148 /* XXX 156-byte dongle size savings hack (rte version of routine doesn't use names) */
149 #define wl_init_timer(wl, fn, arg, name)	wl_init_timer(wl, fn, arg, NULL)
150 extern int wl_busioctl(struct wl_info *wl, uint32 cmd, void *buf, int len, int *used,
151 	int *needed, int set);
152 extern void wl_isucodereclaimed(uint8 *value);
153 extern void wl_reclaim(void);
154 extern void wl_reclaim_postattach(void);
155 extern bool wl_dngl_is_ss(struct wl_info *wl);
156 extern void wl_sendctl_tx(struct wl_info *wl, uint8 type, uint32 op, void *opdata);
157 extern void wl_flowring_ctl(struct wl_info *wl, uint32 op, void *opdata);
158 extern void wl_indicate_maccore_state(struct wl_info *wl, uint8 state);
159 extern void wl_indicate_macwake_state(struct wl_info *wl, uint8 state);
160 extern void wl_flush_rxreorderqeue_flow(struct wl_info *wl, struct reorder_rxcpl_id_list *list);
161 extern uint32 wl_chain_rxcomplete_id(struct reorder_rxcpl_id_list *list, uint16 id, bool head);
162 extern void wl_chain_rxcompletions_amsdu(osl_t *osh, void *p, bool norxcpl);
163 extern void wl_timesync_add_rx_timestamp(struct wl_info *wl, void *p,
164 		uint32 ts_low, uint32 ts_high);
165 extern void wl_timesync_add_tx_timestamp(struct wl_info *wl, void *p,
166 		uint32 ts_low, uint32 ts_high);
167 extern void wl_timesync_get_tx_timestamp(struct wl_info *wl, void *p,
168 		uint32 *ts_low, uint32 *ts_high);
169 
170 #define wl_chain_rxcomplete_id_tail(a, b) wl_chain_rxcomplete_id(a, b, FALSE)
171 #define wl_chain_rxcomplete_id_head(a, b) wl_chain_rxcomplete_id(a, b, TRUE)
172 extern void wl_inform_additional_buffers(struct wl_info *wl, uint16 buf_cnts);
173 extern void wl_health_check_notify(struct wl_info *wl, mbool notification, bool state);
174 extern void wl_health_check_notify_clear_all(struct wl_info *wl);
175 extern void wl_health_check_log(struct wl_info *wl,  uint32 hc_log_type,
176 	uint32 val, uint32 caller);
177 #ifdef BCMPCIEDEV
178 extern bool wl_get_hcapistimesync(void);
179 extern bool wl_get_hcapispkttxs(void);
180 #endif /* BCMPCIEDEV */
181 #else
182 #define wl_indicate_maccore_state(a, b) do { } while (0)
183 #define wl_indicate_macwake_state(a, b) do { } while (0)
184 #define wl_flush_rxreorderqeue_flow(a, b) do { } while (0)
185 #define wl_chain_rxcomplete_id_tail(a, b) 0
186 #define wl_chain_rxcomplete_id_head(a, b) 0
187 #define wl_chain_rxcompletions_amsdu(a, b, c) do {} while (0)
188 #define wl_inform_additional_buffers(a, b) do { } while (0)
189 #define wl_health_check_notify(a, b, c) do { } while (0)
190 #define wl_health_check_notify_clear_all(a) do { } while (0)
191 #define wl_health_check_log(a, b, c, d) do { } while (0)
192 #define wl_get_hcapistimesync() do  { } while (0)
193 #define wl_get_hcapispkttxs() do  { } while (0)
194 #endif /* DONGLEBUILD */
195 
196 extern int wl_fatal_error(void * wl, int rc);
197 
198 #ifdef NEED_HARD_RESET
199 extern int wl_powercycle(void * wl);
200 extern bool wl_powercycle_inprogress(void * wl);
201 #else
202 #define wl_powercycle(a)
203 #define wl_powercycle_inprogress(a) (0)
204 #endif /* NEED_HARD_RESET */
205 
206 void *wl_create_fwdpkt(struct wl_info *wl, void *p, struct wl_if *wlif);
207 
208 #ifdef BCMFRWDPOOLREORG
209 void wl_upd_frwd_resrv_bufcnt(struct wl_info *wl);
210 #endif /* BCMFRWDPOOLREORG */
211 #ifdef BCMFRWDPKT
212 void wl_prepare_frwd_pkt_rxcmplt(struct wl_info *wl, void *p);
213 #endif /* BCMFRWDPKT */
214 
215 #ifdef WL_NATOE
216 void wl_natoe_notify_pktc(struct wl_info *wl, uint8 action);
217 int wl_natoe_ampdu_config_upd(struct wl_info *wl);
218 #endif /* WL_NATOE */
219 
220 #ifdef ENABLE_CORECAPTURE
221 extern int wl_log_system_state(void * wl, const char * reason, bool capture);
222 #else
223 #define wl_log_system_state(a, b, c)
224 #endif
225 
226 #define WL_DUMP_MEM_SOCRAM	1
227 #define WL_DUMP_MEM_UCM		2
228 
229 extern void wl_dump_mem(char *addr, int len, int type);
230 
231 #ifdef HEALTH_CHECK
232 typedef int (*wl_health_check_fn)(uint8 *buffer, uint16 length, void *context,
233 		int16 *bytes_written);
234 typedef int (*health_check_event_mask_fn)(void *context, bool get, uint32 *evt_bits);
235 extern int wl_health_check_evtmask_upd(struct wl_info *wl, int module_id, bool get,
236 	uint32 *evt_mask);
237 
238 typedef struct health_check_info health_check_info_t;
239 typedef struct health_check_client_info health_check_client_info_t;
240 
241 /* WL wrapper to health check APIs. */
242 extern health_check_client_info_t* wl_health_check_module_register(struct wl_info *wl,
243 	const char* name, wl_health_check_fn fn, health_check_event_mask_fn evt_fn,
244 	void *context, int module_id);
245 
246 extern void wl_health_check_execute(void *wl);
247 
248 extern int wl_health_check_execute_clients(struct wl_info *wl,
249 	health_check_client_info_t** modules, uint16 num_modules);
250 
251 /* Following are not implemented in dongle health check */
252 extern int wl_health_check_deinit(struct wl_info *wl);
253 extern int wl_health_check_module_unregister(struct wl_info *wl,
254 	health_check_client_info_t *client);
255 #endif /* HEALTH_CHECK */
256 
257 #ifdef ECOUNTERS
258 #define WL_ECOUNTERS_CALLBACK_V2
259 typedef int (*wl_ecounters_stats_get)(uint16 stats_type, struct wlc_info *wlc,
260 	const ecounters_stats_types_report_req_t * req, struct bcm_xtlvbuf *xtlvbuf,
261 	uint32 *cookie, const bcm_xtlv_t* tlv, uint16 *attempted_write_len);
262 
263 extern int wl_ecounters_register_source(struct wl_info *wl, uint16 stats_type,
264 	wl_ecounters_stats_get some_fn);
265 extern int wl_ecounters_register_source_periodic(struct wl_info *wl, uint16 stats_type,
266 	wl_ecounters_stats_get periodic_fn, wl_ecounters_stats_get some_fn);
267 
268 extern int wl_ecounters_trigger(void *trigger_context, uint16 reason);
269 #endif
270 extern bool wl_health_check_enabled(struct wl_info *wl);
271 typedef void (*wl_send_if_event_cb_fn_t)(void *ctx);
272 extern int wl_if_event_send_cb_fn_register(struct wl_info *wl, wl_send_if_event_cb_fn_t fn,
273 	void *arg);
274 extern int wl_if_event_send_cb_fn_unregister(struct wl_info *wl,
275 	wl_send_if_event_cb_fn_t fn, void *arg);
276 extern uint32 wl_get_ramsize(void);
277 #ifdef PACKET_FILTER
278 extern void wl_periodic_pktfltr_cntrs_state_upd(wlc_info_t *wlc);
279 #endif /* PACKET_FILTER */
280 
281 #ifdef BCMPCIE_LATENCY
282 int wl_bus_pcie_latency_enab(struct wl_info *wl, bool val);
283 #endif /* BCMPCIE_LATENCY */
284 void wl_hp2p_update_prio(struct wl_info *wl, void *p);
285 #endif	/* _wl_export_h_ */
286