xref: /freebsd/sys/dev/rtwn/if_rtwnvar.h (revision 99429157e8615dc3b7f11afbe3ed92de7476a5db)
1 /*-
2  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
3  * Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
18  * $FreeBSD$
19  */
20 
21 #ifndef IF_RTWNVAR_H
22 #define IF_RTWNVAR_H
23 
24 #include "opt_rtwn.h"
25 
26 #define RTWN_TX_DESC_SIZE	64
27 
28 #define RTWN_TXBUFSZ		(16 * 1024)
29 
30 #define RTWN_BCN_MAX_SIZE	512
31 #define RTWN_CAM_ENTRY_LIMIT	64
32 
33 #define RTWN_MACID_BC		1	/* Broadcast. */
34 #define RTWN_MACID_UNDEFINED	0x7fff
35 #define RTWN_MACID_VALID 	0x8000
36 #define RTWN_MACID_LIMIT	128
37 
38 #define RTWN_TX_TIMEOUT		5000	/* ms */
39 #define RTWN_MAX_EPOUT		4
40 #define RTWN_PORT_COUNT		2
41 
42 #define RTWN_LED_LINK		0
43 #define RTWN_LED_DATA		1
44 
45 struct rtwn_rx_radiotap_header {
46 	struct ieee80211_radiotap_header wr_ihdr;
47 	uint64_t	wr_tsft;
48 	uint8_t		wr_flags;
49 	uint8_t		wr_rate;
50 	uint16_t	wr_chan_freq;
51 	uint16_t	wr_chan_flags;
52 	int8_t		wr_dbm_antsignal;
53 	int8_t		wr_dbm_antnoise;
54 } __packed __aligned(8);
55 
56 #define RTWN_RX_RADIOTAP_PRESENT			\
57 	(1 << IEEE80211_RADIOTAP_TSFT |			\
58 	 1 << IEEE80211_RADIOTAP_FLAGS |		\
59 	 1 << IEEE80211_RADIOTAP_RATE |			\
60 	 1 << IEEE80211_RADIOTAP_CHANNEL |		\
61 	 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL |	\
62 	 1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)
63 
64 struct rtwn_tx_radiotap_header {
65 	struct ieee80211_radiotap_header wt_ihdr;
66 	uint8_t		wt_flags;
67 	uint16_t	wt_chan_freq;
68 	uint16_t	wt_chan_flags;
69 } __packed __aligned(8);
70 
71 #define RTWN_TX_RADIOTAP_PRESENT			\
72 	(1 << IEEE80211_RADIOTAP_FLAGS |		\
73 	 1 << IEEE80211_RADIOTAP_CHANNEL)
74 
75 struct rtwn_tx_buf {
76 	uint8_t		txd[RTWN_TX_DESC_SIZE];
77 } __attribute__((aligned(4)));
78 
79 #define RTWN_PHY_STATUS_SIZE	32
80 struct rtwn_tx_phystat {
81 	uint32_t	phydw[RTWN_PHY_STATUS_SIZE / sizeof(uint32_t)];
82 };
83 
84 
85 struct rtwn_softc;
86 
87 union sec_param {
88 	struct ieee80211_key	key;
89 	int			macid;
90 };
91 
92 #define CMD_FUNC_PROTO		void (*func)(struct rtwn_softc *, \
93 				    union sec_param *)
94 
95 struct rtwn_cmdq {
96 	union sec_param		data;
97 	CMD_FUNC_PROTO;
98 };
99 #define RTWN_CMDQ_SIZE		16
100 
101 struct rtwn_node {
102 	struct ieee80211_node	ni;	/* must be the first */
103 	int			id;
104 
105 	struct rtwn_tx_phystat	last_physt;
106 	int			avg_pwdb;
107 };
108 #define RTWN_NODE(ni)		((struct rtwn_node *)(ni))
109 
110 struct rtwn_vap {
111 	struct ieee80211vap	vap;
112 	int			id;
113 #define RTWN_VAP_ID_INVALID	-1
114 	int			curr_mode;
115 
116 	struct rtwn_tx_buf	bcn_desc;
117 	struct mbuf		*bcn_mbuf;
118 	struct timeout_task	tx_beacon_csa;
119 
120 	struct callout		tsf_sync_adhoc;
121 	struct task		tsf_sync_adhoc_task;
122 
123 	const struct ieee80211_key	*keys[IEEE80211_WEP_NKID];
124 
125 	int			(*newstate)(struct ieee80211vap *,
126 				    enum ieee80211_state, int);
127 	void			(*recv_mgmt)(struct ieee80211_node *,
128 				    struct mbuf *, int,
129 				    const struct ieee80211_rx_stats *,
130 				    int, int);
131 };
132 #define	RTWN_VAP(vap)		((struct rtwn_vap *)(vap))
133 
134 /*
135  * Rx data types.
136  */
137 enum {
138 	RTWN_RX_DATA,
139 	RTWN_RX_TX_REPORT,
140 	RTWN_RX_OTHER
141 };
142 
143 /*
144  * Firmware reset reasons.
145  */
146 enum {
147 	RTWN_FW_RESET_DOWNLOAD,
148 	RTWN_FW_RESET_CHECKSUM,
149 	RTWN_FW_RESET_SHUTDOWN
150 };
151 
152 /*
153  * Rate control algorithm selection.
154  */
155 enum {
156 	RTWN_RATECTL_NONE,
157 	RTWN_RATECTL_NET80211,
158 	RTWN_RATECTL_FW,
159 	RTWN_RATECTL_MAX
160 };
161 
162 /*
163  * Control h/w crypto usage.
164  */
165 enum {
166 	RTWN_CRYPTO_SW,
167 	RTWN_CRYPTO_PAIR,
168 	RTWN_CRYPTO_FULL,
169 	RTWN_CRYPTO_MAX,
170 };
171 
172 struct rtwn_softc {
173 	struct ieee80211com	sc_ic;
174 	struct mbufq		sc_snd;
175 	device_t		sc_dev;
176 
177 #if 1
178 	int			sc_ht40;
179 #endif
180 	uint32_t		sc_debug;
181 	int			sc_hwcrypto;
182 	int			sc_ratectl_sysctl;
183 	int			sc_ratectl;
184 
185 	uint8_t			sc_detached;
186 	uint8_t			sc_flags;
187 /* Device flags */
188 #define RTWN_FLAG_CCK_HIPWR	0x01
189 #define RTWN_FLAG_EXT_HDR	0x02
190 #define RTWN_FLAG_CAM_FIXED	0x04
191 /* Driver state */
192 #define RTWN_STARTED		0x08
193 #define RTWN_RUNNING		0x10
194 #define RTWN_FW_LOADED		0x20
195 #define RTWN_TEMP_MEASURED	0x40
196 #define RTWN_RCR_LOCKED		0x80
197 
198 #define RTWN_CHIP_HAS_BCNQ1(_sc)	\
199 	((_sc)->bcn_status_reg[0] != (_sc)->bcn_status_reg[1])
200 
201 	void			*sc_priv;
202 	const char		*name;
203 	int			sc_ant;
204 
205 	struct rtwn_tx_phystat	last_physt;
206 	uint8_t			thcal_temp;
207 	int			cur_bcnq_id;
208 
209 	int			nvaps;
210 	int			ap_vaps;
211 	int			bcn_vaps;
212 	int			mon_vaps;
213 
214 	int			vaps_running;
215 	int			monvaps_running;
216 
217 	uint16_t		next_rom_addr;
218 	uint8_t			keys_bmap[howmany(RTWN_CAM_ENTRY_LIMIT, NBBY)];
219 
220 	struct rtwn_vap		*vaps[RTWN_PORT_COUNT];
221 	struct ieee80211_node	*node_list[RTWN_MACID_LIMIT];
222 	struct mtx		nt_mtx;
223 
224 	struct callout		sc_calib_to;
225 	struct callout		sc_pwrmode_init;
226 #ifndef D4054
227 	struct callout		sc_watchdog_to;
228 	int			sc_tx_timer;
229 #endif
230 
231 	struct mtx		sc_mtx;
232 
233 	struct rtwn_cmdq	cmdq[RTWN_CMDQ_SIZE];
234 	struct mtx		cmdq_mtx;
235 	struct task		cmdq_task;
236 	uint8_t			cmdq_first;
237 	uint8_t			cmdq_last;
238 
239 	struct wmeParams	cap_wmeParams[WME_NUM_AC];
240 
241 	struct rtwn_rx_radiotap_header	sc_rxtap;
242 	struct rtwn_tx_radiotap_header	sc_txtap;
243 
244 	int			ntxchains;
245 	int			nrxchains;
246 
247 	int			ledlink;
248 	uint8_t			thermal_meter;
249 
250 	int			sc_tx_n_active;
251 	uint8_t			qfullmsk;
252 
253 	/* Firmware-specific */
254 	const char		*fwname;
255 	uint16_t		fwver;
256 	uint16_t		fwsig;
257 	int			fwcur;
258 
259 	void		(*sc_node_free)(struct ieee80211_node *);
260 	void		(*sc_scan_curchan)(struct ieee80211_scan_state *,
261 			    unsigned long);
262 
263 	/* Interface-specific. */
264 	int		(*sc_write_1)(struct rtwn_softc *, uint16_t,
265 			    uint8_t);
266 	int		(*sc_write_2)(struct rtwn_softc *, uint16_t,
267 			    uint16_t);
268 	int		(*sc_write_4)(struct rtwn_softc *, uint16_t,
269 			    uint32_t);
270 	uint8_t		(*sc_read_1)(struct rtwn_softc *, uint16_t);
271 	uint16_t	(*sc_read_2)(struct rtwn_softc *, uint16_t);
272 	uint32_t	(*sc_read_4)(struct rtwn_softc *, uint16_t);
273 	/* XXX eliminate */
274 	void		(*sc_delay)(struct rtwn_softc *, int);
275 	int		(*sc_tx_start)(struct rtwn_softc *,
276 			    struct ieee80211_node *, struct mbuf *, uint8_t *,
277 			    uint8_t, int);
278 	void		(*sc_start_xfers)(struct rtwn_softc *);
279 	void		(*sc_reset_lists)(struct rtwn_softc *,
280 			    struct ieee80211vap *);
281 	void		(*sc_abort_xfers)(struct rtwn_softc *);
282 	int		(*sc_fw_write_block)(struct rtwn_softc *,
283 			    const uint8_t *, uint16_t, int);
284 	uint16_t	(*sc_get_qmap)(struct rtwn_softc *);
285 	void		(*sc_set_desc_addr)(struct rtwn_softc *);
286 	void		(*sc_drop_incorrect_tx)(struct rtwn_softc *);
287 	void		(*sc_beacon_update_begin)(struct rtwn_softc *,
288 			    struct ieee80211vap *);
289 	void		(*sc_beacon_update_end)(struct rtwn_softc *,
290 			    struct ieee80211vap *);
291 	void		(*sc_beacon_unload)(struct rtwn_softc *, int);
292 
293 	/* XXX drop checks for PCIe? */
294 	int		bcn_check_interval;
295 
296 	/* Device-specific. */
297 	uint32_t	(*sc_rf_read)(struct rtwn_softc *, int, uint8_t);
298 	void		(*sc_rf_write)(struct rtwn_softc *, int, uint8_t,
299 			    uint32_t);
300 	int		(*sc_check_condition)(struct rtwn_softc *,
301 			    const uint8_t[]);
302 	void		(*sc_efuse_postread)(struct rtwn_softc *);
303 	void		(*sc_parse_rom)(struct rtwn_softc *, uint8_t *);
304 	void		(*sc_set_led)(struct rtwn_softc *, int, int);
305 	int		(*sc_power_on)(struct rtwn_softc *);
306 	void		(*sc_power_off)(struct rtwn_softc *);
307 #ifndef RTWN_WITHOUT_UCODE
308 	void		(*sc_fw_reset)(struct rtwn_softc *, int);
309 	void		(*sc_fw_download_enable)(struct rtwn_softc *, int);
310 #endif
311 	int		(*sc_llt_init)(struct rtwn_softc *);
312 	int		(*sc_set_page_size)(struct rtwn_softc *);
313 	void		(*sc_lc_calib)(struct rtwn_softc *);
314 	void		(*sc_iq_calib)(struct rtwn_softc *);
315 	void		(*sc_read_chipid_vendor)(struct rtwn_softc *,
316 			    uint32_t);
317 	void		(*sc_adj_devcaps)(struct rtwn_softc *);
318 	void		(*sc_vap_preattach)(struct rtwn_softc *,
319 			    struct ieee80211vap *);
320 	void		(*sc_postattach)(struct rtwn_softc *);
321 	void		(*sc_detach_private)(struct rtwn_softc *);
322 	void		(*sc_fill_tx_desc)(struct rtwn_softc *,
323 			    struct ieee80211_node *, struct mbuf *,
324 			    void *, uint8_t, int);
325 	void		(*sc_fill_tx_desc_raw)(struct rtwn_softc *,
326 			    struct ieee80211_node *, struct mbuf *,
327 			    void *, const struct ieee80211_bpf_params *);
328 	void		(*sc_fill_tx_desc_null)(struct rtwn_softc *,
329 			    void *, int, int, int);
330 	void		(*sc_dump_tx_desc)(struct rtwn_softc *, const void *);
331 	uint8_t		(*sc_tx_radiotap_flags)(const void *);
332 	uint8_t		(*sc_rx_radiotap_flags)(const void *);
333 	void		(*sc_beacon_init)(struct rtwn_softc *, void *, int);
334 	void		(*sc_beacon_enable)(struct rtwn_softc *, int, int);
335 	void		(*sc_beacon_set_rate)(void *, int);
336 	void		(*sc_beacon_select)(struct rtwn_softc *, int);
337 	void		(*sc_set_chan)(struct rtwn_softc *,
338 			    struct ieee80211_channel *);
339 	void		(*sc_set_media_status)(struct rtwn_softc *, int);
340 #ifndef RTWN_WITHOUT_UCODE
341 	int		(*sc_set_rsvd_page)(struct rtwn_softc *, int, int,
342 			    int);
343 	int		(*sc_set_pwrmode)(struct rtwn_softc *,
344 			    struct ieee80211vap *, int);
345 	void		(*sc_set_rssi)(struct rtwn_softc *);
346 #endif
347 	void		(*sc_get_rx_stats)(struct rtwn_softc *,
348 			    struct ieee80211_rx_stats *, const void *,
349 			    const void *);
350 	int8_t		(*sc_get_rssi_cck)(struct rtwn_softc *, void *);
351 	int8_t		(*sc_get_rssi_ofdm)(struct rtwn_softc *, void *);
352 	int		(*sc_classify_intr)(struct rtwn_softc *, void *, int);
353 	void		(*sc_handle_tx_report)(struct rtwn_softc *, uint8_t *,
354 			    int);
355 	void		(*sc_handle_c2h_report)(struct rtwn_softc *,
356 			    uint8_t *, int);
357 	int		(*sc_check_frame)(struct rtwn_softc *, struct mbuf *);
358 	void		(*sc_temp_measure)(struct rtwn_softc *);
359 	uint8_t		(*sc_temp_read)(struct rtwn_softc *);
360 	void		(*sc_init_tx_agg)(struct rtwn_softc *);
361 	void		(*sc_init_rx_agg)(struct rtwn_softc *);
362 	void		(*sc_init_intr)(struct rtwn_softc *);
363 	void		(*sc_init_ampdu)(struct rtwn_softc *);
364 	void		(*sc_init_edca)(struct rtwn_softc *);
365 	void		(*sc_init_bb)(struct rtwn_softc *);
366 	void		(*sc_init_rf)(struct rtwn_softc *);
367 	void		(*sc_init_antsel)(struct rtwn_softc *);
368 	void		(*sc_post_init)(struct rtwn_softc *);
369 	int		(*sc_init_bcnq1_boundary)(struct rtwn_softc *);
370 
371 	const uint8_t			*chan_list_5ghz[3];
372 	int				chan_num_5ghz[3];
373 
374 	const struct rtwn_mac_prog	*mac_prog;
375 	int				mac_size;
376 	const struct rtwn_bb_prog	*bb_prog;
377 	int				bb_size;
378 	const struct rtwn_agc_prog	*agc_prog;
379 	int				agc_size;
380 	const struct rtwn_rf_prog	*rf_prog;
381 
382 	int				page_count;
383 	int				pktbuf_count;
384 
385 	int				ackto;
386 
387 	int				npubqpages;
388 	int				nhqpages;
389 	int				nnqpages;
390 	int				nlqpages;
391 	int				page_size;
392 
393 	int				txdesc_len;
394 	int				efuse_maxlen;
395 	int				efuse_maplen;
396 
397 	uint16_t			rx_dma_size;
398 
399 	int				macid_limit;
400 	int				cam_entry_limit;
401 	int				fwsize_limit;
402 	int				temp_delta;
403 
404 	uint16_t			bcn_status_reg[RTWN_PORT_COUNT];
405 	uint32_t			rcr;	/* Rx filter */
406 };
407 MALLOC_DECLARE(M_RTWN_PRIV);
408 
409 #define	RTWN_LOCK(sc)			mtx_lock(&(sc)->sc_mtx)
410 #define	RTWN_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
411 #define	RTWN_ASSERT_LOCKED(sc)		mtx_assert(&(sc)->sc_mtx, MA_OWNED)
412 
413 #define RTWN_CMDQ_LOCK_INIT(sc) \
414 	mtx_init(&(sc)->cmdq_mtx, "cmdq lock", NULL, MTX_DEF)
415 #define RTWN_CMDQ_LOCK(sc)		mtx_lock(&(sc)->cmdq_mtx)
416 #define RTWN_CMDQ_UNLOCK(sc)		mtx_unlock(&(sc)->cmdq_mtx)
417 #define RTWN_CMDQ_LOCK_INITIALIZED(sc)	mtx_initialized(&(sc)->cmdq_mtx)
418 #define RTWN_CMDQ_LOCK_DESTROY(sc)	mtx_destroy(&(sc)->cmdq_mtx)
419 
420 #define RTWN_NT_LOCK_INIT(sc) \
421 	mtx_init(&(sc)->nt_mtx, "node table lock", NULL, MTX_DEF)
422 #define RTWN_NT_LOCK(sc)		mtx_lock(&(sc)->nt_mtx)
423 #define RTWN_NT_UNLOCK(sc)		mtx_unlock(&(sc)->nt_mtx)
424 #define RTWN_NT_LOCK_INITIALIZED(sc)	mtx_initialized(&(sc)->nt_mtx)
425 #define RTWN_NT_LOCK_DESTROY(sc)	mtx_destroy(&(sc)->nt_mtx)
426 
427 
428 void	rtwn_sysctlattach(struct rtwn_softc *);
429 
430 int	rtwn_attach(struct rtwn_softc *);
431 void	rtwn_detach(struct rtwn_softc *);
432 void	rtwn_resume(struct rtwn_softc *);
433 void	rtwn_suspend(struct rtwn_softc *);
434 
435 
436 /* Interface-specific. */
437 #define rtwn_write_1(_sc, _addr, _val) \
438 	(((_sc)->sc_write_1)((_sc), (_addr), (_val)))
439 #define rtwn_write_2(_sc, _addr, _val) \
440 	(((_sc)->sc_write_2)((_sc), (_addr), (_val)))
441 #define rtwn_write_4(_sc, _addr, _val) \
442 	(((_sc)->sc_write_4)((_sc), (_addr), (_val)))
443 #define rtwn_read_1(_sc, _addr) \
444 	(((_sc)->sc_read_1)((_sc), (_addr)))
445 #define rtwn_read_2(_sc, _addr) \
446 	(((_sc)->sc_read_2)((_sc), (_addr)))
447 #define rtwn_read_4(_sc, _addr) \
448 	(((_sc)->sc_read_4)((_sc), (_addr)))
449 #define rtwn_delay(_sc, _usec) \
450 	(((_sc)->sc_delay)((_sc), (_usec)))
451 #define rtwn_tx_start(_sc, _ni, _m, _desc, _type, _id) \
452 	(((_sc)->sc_tx_start)((_sc), (_ni), (_m), (_desc), (_type), (_id)))
453 #define rtwn_start_xfers(_sc) \
454 	(((_sc)->sc_start_xfers)((_sc)))
455 #define rtwn_reset_lists(_sc, _vap) \
456 	(((_sc)->sc_reset_lists)((_sc), (_vap)))
457 #define rtwn_abort_xfers(_sc) \
458 	(((_sc)->sc_abort_xfers)((_sc)))
459 #define rtwn_fw_write_block(_sc, _buf, _reg, _len) \
460 	(((_sc)->sc_fw_write_block)((_sc), (_buf), (_reg), (_len)))
461 #define rtwn_get_qmap(_sc) \
462 	(((_sc)->sc_get_qmap)((_sc)))
463 #define rtwn_set_desc_addr(_sc) \
464 	(((_sc)->sc_set_desc_addr)((_sc)))
465 #define rtwn_drop_incorrect_tx(_sc) \
466 	(((_sc)->sc_drop_incorrect_tx)((_sc)))
467 #define rtwn_beacon_update_begin(_sc, _vap) \
468 	(((_sc)->sc_beacon_update_begin)((_sc), (_vap)))
469 #define rtwn_beacon_update_end(_sc, _vap) \
470 	(((_sc)->sc_beacon_update_end)((_sc), (_vap)))
471 #define rtwn_beacon_unload(_sc, _id) \
472 	(((_sc)->sc_beacon_unload)((_sc), (_id)))
473 
474 /* Aliases. */
475 #define	rtwn_bb_write		rtwn_write_4
476 #define	rtwn_bb_read		rtwn_read_4
477 #define	rtwn_bb_setbits		rtwn_setbits_4
478 
479 /* Device-specific. */
480 #define rtwn_rf_read(_sc, _chain, _addr) \
481 	(((_sc)->sc_rf_read)((_sc), (_chain), (_addr)))
482 #define rtwn_rf_write(_sc, _chain, _addr, _val) \
483 	(((_sc)->sc_rf_write)((_sc), (_chain), (_addr), (_val)))
484 #define rtwn_check_condition(_sc, _cond) \
485 	(((_sc)->sc_check_condition)((_sc), (_cond)))
486 #define rtwn_efuse_postread(_sc) \
487 	(((_sc)->sc_efuse_postread)((_sc)))
488 #define rtwn_parse_rom(_sc, _rom) \
489 	(((_sc)->sc_parse_rom)((_sc), (_rom)))
490 #define rtwn_set_led(_sc, _led, _on) \
491 	(((_sc)->sc_set_led)((_sc), (_led), (_on)))
492 #define rtwn_get_rx_stats(_sc, _rxs, _desc, _physt) \
493 	(((_sc)->sc_get_rx_stats((_sc), (_rxs), (_desc), (_physt))))
494 #define rtwn_get_rssi_cck(_sc, _physt) \
495 	(((_sc)->sc_get_rssi_cck)((_sc), (_physt)))
496 #define rtwn_get_rssi_ofdm(_sc, _physt) \
497 	(((_sc)->sc_get_rssi_ofdm)((_sc), (_physt)))
498 #define rtwn_power_on(_sc) \
499 	(((_sc)->sc_power_on)((_sc)))
500 #define rtwn_power_off(_sc) \
501 	(((_sc)->sc_power_off)((_sc)))
502 #ifndef RTWN_WITHOUT_UCODE
503 #define rtwn_fw_reset(_sc, _reason) \
504 	(((_sc)->sc_fw_reset)((_sc), (_reason)))
505 #define rtwn_fw_download_enable(_sc, _enable) \
506 	(((_sc)->sc_fw_download_enable)((_sc), (_enable)))
507 #endif
508 #define rtwn_llt_init(_sc) \
509 	(((_sc)->sc_llt_init)((_sc)))
510 #define rtwn_set_page_size(_sc) \
511 	(((_sc)->sc_set_page_size)((_sc)))
512 #define rtwn_lc_calib(_sc) \
513 	(((_sc)->sc_lc_calib)((_sc)))
514 #define rtwn_iq_calib(_sc) \
515 	(((_sc)->sc_iq_calib)((_sc)))
516 #define rtwn_read_chipid_vendor(_sc, _reg) \
517 	(((_sc)->sc_read_chipid_vendor)((_sc), (_reg)))
518 #define rtwn_adj_devcaps(_sc) \
519 	(((_sc)->sc_adj_devcaps)((_sc)))
520 #define rtwn_vap_preattach(_sc, _vap) \
521 	(((_sc)->sc_vap_preattach)((_sc), (_vap)))
522 #define rtwn_postattach(_sc) \
523 	(((_sc)->sc_postattach)((_sc)))
524 #define rtwn_detach_private(_sc) \
525 	(((_sc)->sc_detach_private)((_sc)))
526 #define rtwn_fill_tx_desc(_sc, _ni, _m, \
527 	    _buf, _ridx, _maxretry) \
528 	(((_sc)->sc_fill_tx_desc)((_sc), (_ni), \
529 	    (_m), (_buf), (_ridx), (_maxretry)))
530 #define rtwn_fill_tx_desc_raw(_sc, _ni, _m, \
531 	    _buf, _params) \
532 	(((_sc)->sc_fill_tx_desc_raw)((_sc), (_ni), \
533 	    (_m), (_buf), (_params)))
534 #define rtwn_fill_tx_desc_null(_sc, _buf, _11b, _qos, _id) \
535 	(((_sc)->sc_fill_tx_desc_null)((_sc), \
536 	    (_buf), (_11b), (_qos), (_id)))
537 #define rtwn_dump_tx_desc(_sc, _desc) \
538 	(((_sc)->sc_dump_tx_desc)((_sc), (_desc)))
539 #define rtwn_tx_radiotap_flags(_sc, _buf) \
540 	(((_sc)->sc_tx_radiotap_flags)((_buf)))
541 #define rtwn_rx_radiotap_flags(_sc, _buf) \
542 	(((_sc)->sc_rx_radiotap_flags)((_buf)))
543 #define rtwn_set_chan(_sc, _c) \
544 	(((_sc)->sc_set_chan)((_sc), (_c)))
545 #ifndef RTWN_WITHOUT_UCODE
546 #define rtwn_set_rsvd_page(_sc, _resp, _null, _qos_null) \
547 	(((_sc)->sc_set_rsvd_page)((_sc), \
548 	    (_resp), (_null), (_qos_null)))
549 #define rtwn_set_pwrmode(_sc, _vap, _off) \
550 	(((_sc)->sc_set_pwrmode)((_sc), (_vap), (_off)))
551 #define rtwn_set_rssi(_sc) \
552 	(((_sc)->sc_set_rssi)((_sc)))
553 #endif
554 #define rtwn_classify_intr(_sc, _buf, _len) \
555 	(((_sc)->sc_classify_intr)((_sc), (_buf), (_len)))
556 #define rtwn_handle_tx_report(_sc, _buf, _len) \
557 	(((_sc)->sc_handle_tx_report)((_sc), (_buf), (_len)))
558 #define rtwn_handle_c2h_report(_sc, _buf, _len) \
559 	(((_sc)->sc_handle_c2h_report)((_sc), (_buf), (_len)))
560 #define rtwn_check_frame(_sc, _m) \
561 	(((_sc)->sc_check_frame)((_sc), (_m)))
562 #define rtwn_beacon_init(_sc, _buf, _id) \
563 	(((_sc)->sc_beacon_init)((_sc), (_buf), (_id)))
564 #define rtwn_beacon_enable(_sc, _id, _enable) \
565 	(((_sc)->sc_beacon_enable)((_sc), (_id), (_enable)))
566 #define rtwn_beacon_set_rate(_sc, _buf, _is5ghz) \
567 	(((_sc)->sc_beacon_set_rate)((_buf), (_is5ghz)))
568 #define rtwn_beacon_select(_sc, _id) \
569 	(((_sc)->sc_beacon_select)((_sc), (_id)))
570 #define rtwn_temp_measure(_sc) \
571 	(((_sc)->sc_temp_measure)((_sc)))
572 #define rtwn_temp_read(_sc) \
573 	(((_sc)->sc_temp_read)((_sc)))
574 #define rtwn_init_tx_agg(_sc) \
575 	(((_sc)->sc_init_tx_agg)((_sc)))
576 #define rtwn_init_rx_agg(_sc) \
577 	(((_sc)->sc_init_rx_agg)((_sc)))
578 #define rtwn_init_intr(_sc) \
579 	(((_sc)->sc_init_intr)((_sc)))
580 #define rtwn_init_ampdu(_sc) \
581 	(((_sc)->sc_init_ampdu)((_sc)))
582 #define rtwn_init_edca(_sc) \
583 	(((_sc)->sc_init_edca)((_sc)))
584 #define rtwn_init_bb(_sc) \
585 	(((_sc)->sc_init_bb)((_sc)))
586 #define rtwn_init_rf(_sc) \
587 	(((_sc)->sc_init_rf)((_sc)))
588 #define rtwn_init_antsel(_sc) \
589 	(((_sc)->sc_init_antsel)((_sc)))
590 #define rtwn_post_init(_sc) \
591 	(((_sc)->sc_post_init)((_sc)))
592 #define rtwn_init_bcnq1_boundary(_sc) \
593 	(((_sc)->sc_init_bcnq1_boundary)((_sc)))
594 
595 
596 /*
597  * Methods to access subfields in registers.
598  */
599 static __inline int
600 rtwn_setbits_1(struct rtwn_softc *sc, uint16_t addr, uint8_t clr,
601     uint8_t set)
602 {
603 	return (rtwn_write_1(sc, addr,
604 	    (rtwn_read_1(sc, addr) & ~clr) | set));
605 }
606 
607 static __inline int
608 rtwn_setbits_1_shift(struct rtwn_softc *sc, uint16_t addr, uint32_t clr,
609     uint32_t set, int shift)
610 {
611 	return (rtwn_setbits_1(sc, addr + shift, clr >> shift * NBBY,
612 	    set >> shift * NBBY));
613 }
614 
615 static __inline int
616 rtwn_setbits_2(struct rtwn_softc *sc, uint16_t addr, uint16_t clr,
617     uint16_t set)
618 {
619 	return (rtwn_write_2(sc, addr,
620 	    (rtwn_read_2(sc, addr) & ~clr) | set));
621 }
622 
623 static __inline int
624 rtwn_setbits_4(struct rtwn_softc *sc, uint16_t addr, uint32_t clr,
625     uint32_t set)
626 {
627 	return (rtwn_write_4(sc, addr,
628 	    (rtwn_read_4(sc, addr) & ~clr) | set));
629 }
630 
631 static __inline void
632 rtwn_rf_setbits(struct rtwn_softc *sc, int chain, uint8_t addr,
633     uint32_t clr, uint32_t set)
634 {
635 	rtwn_rf_write(sc, chain, addr,
636 	    (rtwn_rf_read(sc, chain, addr) & ~clr) | set);
637 }
638 
639 #endif	/* IF_RTWNVAR_H */
640