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