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 struct rtwn_softc; 80 81 union sec_param { 82 struct ieee80211_key key; 83 int macid; 84 }; 85 86 #define CMD_FUNC_PROTO void (*func)(struct rtwn_softc *, \ 87 union sec_param *) 88 89 struct rtwn_cmdq { 90 union sec_param data; 91 CMD_FUNC_PROTO; 92 }; 93 #define RTWN_CMDQ_SIZE 16 94 95 struct rtwn_node { 96 struct ieee80211_node ni; /* must be the first */ 97 int id; 98 int8_t last_rssi; 99 int avg_pwdb; 100 }; 101 #define RTWN_NODE(ni) ((struct rtwn_node *)(ni)) 102 103 struct rtwn_vap { 104 struct ieee80211vap vap; 105 int id; 106 #define RTWN_VAP_ID_INVALID -1 107 int curr_mode; 108 109 struct rtwn_tx_buf bcn_desc; 110 struct mbuf *bcn_mbuf; 111 struct timeout_task tx_beacon_csa; 112 113 struct callout tsf_sync_adhoc; 114 struct task tsf_sync_adhoc_task; 115 116 const struct ieee80211_key *keys[IEEE80211_WEP_NKID]; 117 118 int (*newstate)(struct ieee80211vap *, 119 enum ieee80211_state, int); 120 void (*recv_mgmt)(struct ieee80211_node *, 121 struct mbuf *, int, 122 const struct ieee80211_rx_stats *, 123 int, int); 124 }; 125 #define RTWN_VAP(vap) ((struct rtwn_vap *)(vap)) 126 127 /* 128 * Rx data types. 129 */ 130 enum { 131 RTWN_RX_DATA, 132 RTWN_RX_TX_REPORT, 133 RTWN_RX_OTHER 134 }; 135 136 /* 137 * Firmware reset reasons. 138 */ 139 enum { 140 RTWN_FW_RESET_DOWNLOAD, 141 RTWN_FW_RESET_CHECKSUM, 142 RTWN_FW_RESET_SHUTDOWN 143 }; 144 145 /* 146 * Rate control algorithm selection. 147 */ 148 enum { 149 RTWN_RATECTL_NONE, 150 RTWN_RATECTL_NET80211, 151 RTWN_RATECTL_FW, 152 RTWN_RATECTL_MAX 153 }; 154 155 /* 156 * Control h/w crypto usage. 157 */ 158 enum { 159 RTWN_CRYPTO_SW, 160 RTWN_CRYPTO_PAIR, 161 RTWN_CRYPTO_FULL, 162 RTWN_CRYPTO_MAX, 163 }; 164 165 struct rtwn_softc { 166 struct ieee80211com sc_ic; 167 struct mbufq sc_snd; 168 device_t sc_dev; 169 170 #if 1 171 int sc_ht40; 172 #endif 173 uint32_t sc_debug; 174 int sc_hwcrypto; 175 int sc_ratectl_sysctl; 176 int sc_ratectl; 177 178 uint8_t sc_detached; 179 uint8_t sc_flags; 180 /* Device flags */ 181 #define RTWN_FLAG_CCK_HIPWR 0x01 182 #define RTWN_FLAG_EXT_HDR 0x02 183 #define RTWN_FLAG_CAM_FIXED 0x04 184 /* Driver state */ 185 #define RTWN_STARTED 0x08 186 #define RTWN_RUNNING 0x10 187 #define RTWN_FW_LOADED 0x20 188 #define RTWN_TEMP_MEASURED 0x40 189 #define RTWN_RCR_LOCKED 0x80 190 191 #define RTWN_CHIP_HAS_BCNQ1(_sc) \ 192 ((_sc)->bcn_status_reg[0] != (_sc)->bcn_status_reg[1]) 193 194 void *sc_priv; 195 const char *name; 196 int sc_ant; 197 198 int8_t last_rssi; 199 uint8_t thcal_temp; 200 int cur_bcnq_id; 201 202 int nvaps; 203 int ap_vaps; 204 int bcn_vaps; 205 int mon_vaps; 206 207 int vaps_running; 208 int monvaps_running; 209 210 uint16_t next_rom_addr; 211 uint8_t keys_bmap[howmany(RTWN_CAM_ENTRY_LIMIT, NBBY)]; 212 213 struct rtwn_vap *vaps[RTWN_PORT_COUNT]; 214 struct ieee80211_node *node_list[RTWN_MACID_LIMIT]; 215 struct mtx nt_mtx; 216 217 struct callout sc_calib_to; 218 struct callout sc_pwrmode_init; 219 #ifndef D4054 220 struct callout sc_watchdog_to; 221 int sc_tx_timer; 222 #endif 223 224 struct mtx sc_mtx; 225 226 struct rtwn_cmdq cmdq[RTWN_CMDQ_SIZE]; 227 struct mtx cmdq_mtx; 228 struct task cmdq_task; 229 uint8_t cmdq_first; 230 uint8_t cmdq_last; 231 232 struct wmeParams cap_wmeParams[WME_NUM_AC]; 233 234 struct rtwn_rx_radiotap_header sc_rxtap; 235 struct rtwn_tx_radiotap_header sc_txtap; 236 237 int ntxchains; 238 int nrxchains; 239 240 int ledlink; 241 uint8_t thermal_meter; 242 243 int sc_tx_n_active; 244 uint8_t qfullmsk; 245 246 /* Firmware-specific */ 247 const char *fwname; 248 uint16_t fwver; 249 uint16_t fwsig; 250 int fwcur; 251 252 void (*sc_node_free)(struct ieee80211_node *); 253 void (*sc_scan_curchan)(struct ieee80211_scan_state *, 254 unsigned long); 255 256 /* Interface-specific. */ 257 int (*sc_write_1)(struct rtwn_softc *, uint16_t, 258 uint8_t); 259 int (*sc_write_2)(struct rtwn_softc *, uint16_t, 260 uint16_t); 261 int (*sc_write_4)(struct rtwn_softc *, uint16_t, 262 uint32_t); 263 uint8_t (*sc_read_1)(struct rtwn_softc *, uint16_t); 264 uint16_t (*sc_read_2)(struct rtwn_softc *, uint16_t); 265 uint32_t (*sc_read_4)(struct rtwn_softc *, uint16_t); 266 /* XXX eliminate */ 267 void (*sc_delay)(struct rtwn_softc *, int); 268 int (*sc_tx_start)(struct rtwn_softc *, 269 struct ieee80211_node *, struct mbuf *, uint8_t *, 270 uint8_t, int); 271 void (*sc_start_xfers)(struct rtwn_softc *); 272 void (*sc_reset_lists)(struct rtwn_softc *, 273 struct ieee80211vap *); 274 void (*sc_abort_xfers)(struct rtwn_softc *); 275 int (*sc_fw_write_block)(struct rtwn_softc *, 276 const uint8_t *, uint16_t, int); 277 uint16_t (*sc_get_qmap)(struct rtwn_softc *); 278 void (*sc_set_desc_addr)(struct rtwn_softc *); 279 void (*sc_drop_incorrect_tx)(struct rtwn_softc *); 280 void (*sc_beacon_update_begin)(struct rtwn_softc *, 281 struct ieee80211vap *); 282 void (*sc_beacon_update_end)(struct rtwn_softc *, 283 struct ieee80211vap *); 284 void (*sc_beacon_unload)(struct rtwn_softc *, int); 285 286 /* XXX drop checks for PCIe? */ 287 int bcn_check_interval; 288 289 /* Device-specific. */ 290 uint32_t (*sc_rf_read)(struct rtwn_softc *, int, uint8_t); 291 void (*sc_rf_write)(struct rtwn_softc *, int, uint8_t, 292 uint32_t); 293 int (*sc_check_condition)(struct rtwn_softc *, 294 const uint8_t[]); 295 void (*sc_efuse_postread)(struct rtwn_softc *); 296 void (*sc_parse_rom)(struct rtwn_softc *, uint8_t *); 297 void (*sc_set_led)(struct rtwn_softc *, int, int); 298 int (*sc_power_on)(struct rtwn_softc *); 299 void (*sc_power_off)(struct rtwn_softc *); 300 #ifndef RTWN_WITHOUT_UCODE 301 void (*sc_fw_reset)(struct rtwn_softc *, int); 302 void (*sc_fw_download_enable)(struct rtwn_softc *, int); 303 #endif 304 int (*sc_set_page_size)(struct rtwn_softc *); 305 void (*sc_lc_calib)(struct rtwn_softc *); 306 void (*sc_iq_calib)(struct rtwn_softc *); 307 void (*sc_read_chipid_vendor)(struct rtwn_softc *, 308 uint32_t); 309 void (*sc_adj_devcaps)(struct rtwn_softc *); 310 void (*sc_vap_preattach)(struct rtwn_softc *, 311 struct ieee80211vap *); 312 void (*sc_postattach)(struct rtwn_softc *); 313 void (*sc_detach_private)(struct rtwn_softc *); 314 void (*sc_fill_tx_desc)(struct rtwn_softc *, 315 struct ieee80211_node *, struct mbuf *, 316 void *, uint8_t, int); 317 void (*sc_fill_tx_desc_raw)(struct rtwn_softc *, 318 struct ieee80211_node *, struct mbuf *, 319 void *, const struct ieee80211_bpf_params *); 320 void (*sc_fill_tx_desc_null)(struct rtwn_softc *, 321 void *, int, int, int); 322 void (*sc_dump_tx_desc)(struct rtwn_softc *, const void *); 323 uint8_t (*sc_tx_radiotap_flags)(const void *); 324 uint8_t (*sc_rx_radiotap_flags)(const void *); 325 void (*sc_beacon_init)(struct rtwn_softc *, void *, int); 326 void (*sc_beacon_enable)(struct rtwn_softc *, int, int); 327 void (*sc_beacon_set_rate)(void *, int); 328 void (*sc_beacon_select)(struct rtwn_softc *, int); 329 void (*sc_set_chan)(struct rtwn_softc *, 330 struct ieee80211_channel *); 331 void (*sc_set_media_status)(struct rtwn_softc *, int); 332 #ifndef RTWN_WITHOUT_UCODE 333 int (*sc_set_rsvd_page)(struct rtwn_softc *, int, int, 334 int); 335 int (*sc_set_pwrmode)(struct rtwn_softc *, 336 struct ieee80211vap *, int); 337 void (*sc_set_rssi)(struct rtwn_softc *); 338 #endif 339 int8_t (*sc_get_rssi_cck)(struct rtwn_softc *, void *); 340 int8_t (*sc_get_rssi_ofdm)(struct rtwn_softc *, void *); 341 int (*sc_classify_intr)(struct rtwn_softc *, void *, int); 342 void (*sc_handle_tx_report)(struct rtwn_softc *, uint8_t *, 343 int); 344 void (*sc_handle_c2h_report)(struct rtwn_softc *, 345 uint8_t *, int); 346 int (*sc_check_frame)(struct rtwn_softc *, struct mbuf *); 347 void (*sc_temp_measure)(struct rtwn_softc *); 348 uint8_t (*sc_temp_read)(struct rtwn_softc *); 349 void (*sc_init_tx_agg)(struct rtwn_softc *); 350 void (*sc_init_rx_agg)(struct rtwn_softc *); 351 void (*sc_init_intr)(struct rtwn_softc *); 352 void (*sc_init_ampdu)(struct rtwn_softc *); 353 void (*sc_init_edca)(struct rtwn_softc *); 354 void (*sc_init_bb)(struct rtwn_softc *); 355 void (*sc_init_rf)(struct rtwn_softc *); 356 void (*sc_init_antsel)(struct rtwn_softc *); 357 void (*sc_post_init)(struct rtwn_softc *); 358 int (*sc_init_bcnq1_boundary)(struct rtwn_softc *); 359 360 const uint8_t *chan_list_5ghz[3]; 361 int chan_num_5ghz[3]; 362 363 const struct rtwn_mac_prog *mac_prog; 364 int mac_size; 365 const struct rtwn_bb_prog *bb_prog; 366 int bb_size; 367 const struct rtwn_agc_prog *agc_prog; 368 int agc_size; 369 const struct rtwn_rf_prog *rf_prog; 370 371 int page_count; 372 int pktbuf_count; 373 374 int ackto; 375 376 int npubqpages; 377 int nhqpages; 378 int nnqpages; 379 int nlqpages; 380 int page_size; 381 382 int txdesc_len; 383 int efuse_maxlen; 384 int efuse_maplen; 385 386 uint16_t rx_dma_size; 387 388 int macid_limit; 389 int cam_entry_limit; 390 int fwsize_limit; 391 int temp_delta; 392 393 uint16_t bcn_status_reg[RTWN_PORT_COUNT]; 394 uint32_t rcr; /* Rx filter */ 395 }; 396 MALLOC_DECLARE(M_RTWN_PRIV); 397 398 #define RTWN_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 399 #define RTWN_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 400 #define RTWN_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) 401 402 #define RTWN_CMDQ_LOCK_INIT(sc) \ 403 mtx_init(&(sc)->cmdq_mtx, "cmdq lock", NULL, MTX_DEF) 404 #define RTWN_CMDQ_LOCK(sc) mtx_lock(&(sc)->cmdq_mtx) 405 #define RTWN_CMDQ_UNLOCK(sc) mtx_unlock(&(sc)->cmdq_mtx) 406 #define RTWN_CMDQ_LOCK_INITIALIZED(sc) mtx_initialized(&(sc)->cmdq_mtx) 407 #define RTWN_CMDQ_LOCK_DESTROY(sc) mtx_destroy(&(sc)->cmdq_mtx) 408 409 #define RTWN_NT_LOCK_INIT(sc) \ 410 mtx_init(&(sc)->nt_mtx, "node table lock", NULL, MTX_DEF) 411 #define RTWN_NT_LOCK(sc) mtx_lock(&(sc)->nt_mtx) 412 #define RTWN_NT_UNLOCK(sc) mtx_unlock(&(sc)->nt_mtx) 413 #define RTWN_NT_LOCK_INITIALIZED(sc) mtx_initialized(&(sc)->nt_mtx) 414 #define RTWN_NT_LOCK_DESTROY(sc) mtx_destroy(&(sc)->nt_mtx) 415 416 417 void rtwn_sysctlattach(struct rtwn_softc *); 418 419 int rtwn_attach(struct rtwn_softc *); 420 void rtwn_detach(struct rtwn_softc *); 421 void rtwn_resume(struct rtwn_softc *); 422 void rtwn_suspend(struct rtwn_softc *); 423 424 425 /* Interface-specific. */ 426 #define rtwn_write_1(_sc, _addr, _val) \ 427 (((_sc)->sc_write_1)((_sc), (_addr), (_val))) 428 #define rtwn_write_2(_sc, _addr, _val) \ 429 (((_sc)->sc_write_2)((_sc), (_addr), (_val))) 430 #define rtwn_write_4(_sc, _addr, _val) \ 431 (((_sc)->sc_write_4)((_sc), (_addr), (_val))) 432 #define rtwn_read_1(_sc, _addr) \ 433 (((_sc)->sc_read_1)((_sc), (_addr))) 434 #define rtwn_read_2(_sc, _addr) \ 435 (((_sc)->sc_read_2)((_sc), (_addr))) 436 #define rtwn_read_4(_sc, _addr) \ 437 (((_sc)->sc_read_4)((_sc), (_addr))) 438 #define rtwn_delay(_sc, _usec) \ 439 (((_sc)->sc_delay)((_sc), (_usec))) 440 #define rtwn_tx_start(_sc, _ni, _m, _desc, _type, _id) \ 441 (((_sc)->sc_tx_start)((_sc), (_ni), (_m), (_desc), (_type), (_id))) 442 #define rtwn_start_xfers(_sc) \ 443 (((_sc)->sc_start_xfers)((_sc))) 444 #define rtwn_reset_lists(_sc, _vap) \ 445 (((_sc)->sc_reset_lists)((_sc), (_vap))) 446 #define rtwn_abort_xfers(_sc) \ 447 (((_sc)->sc_abort_xfers)((_sc))) 448 #define rtwn_fw_write_block(_sc, _buf, _reg, _len) \ 449 (((_sc)->sc_fw_write_block)((_sc), (_buf), (_reg), (_len))) 450 #define rtwn_get_qmap(_sc) \ 451 (((_sc)->sc_get_qmap)((_sc))) 452 #define rtwn_set_desc_addr(_sc) \ 453 (((_sc)->sc_set_desc_addr)((_sc))) 454 #define rtwn_drop_incorrect_tx(_sc) \ 455 (((_sc)->sc_drop_incorrect_tx)((_sc))) 456 #define rtwn_beacon_update_begin(_sc, _vap) \ 457 (((_sc)->sc_beacon_update_begin)((_sc), (_vap))) 458 #define rtwn_beacon_update_end(_sc, _vap) \ 459 (((_sc)->sc_beacon_update_end)((_sc), (_vap))) 460 #define rtwn_beacon_unload(_sc, _id) \ 461 (((_sc)->sc_beacon_unload)((_sc), (_id))) 462 463 /* Aliases. */ 464 #define rtwn_bb_write rtwn_write_4 465 #define rtwn_bb_read rtwn_read_4 466 #define rtwn_bb_setbits rtwn_setbits_4 467 468 /* Device-specific. */ 469 #define rtwn_rf_read(_sc, _chain, _addr) \ 470 (((_sc)->sc_rf_read)((_sc), (_chain), (_addr))) 471 #define rtwn_rf_write(_sc, _chain, _addr, _val) \ 472 (((_sc)->sc_rf_write)((_sc), (_chain), (_addr), (_val))) 473 #define rtwn_check_condition(_sc, _cond) \ 474 (((_sc)->sc_check_condition)((_sc), (_cond))) 475 #define rtwn_efuse_postread(_sc) \ 476 (((_sc)->sc_efuse_postread)((_sc))) 477 #define rtwn_parse_rom(_sc, _rom) \ 478 (((_sc)->sc_parse_rom)((_sc), (_rom))) 479 #define rtwn_set_led(_sc, _led, _on) \ 480 (((_sc)->sc_set_led)((_sc), (_led), (_on))) 481 #define rtwn_get_rssi_cck(_sc, _physt) \ 482 (((_sc)->sc_get_rssi_cck)((_sc), (_physt))) 483 #define rtwn_get_rssi_ofdm(_sc, _physt) \ 484 (((_sc)->sc_get_rssi_ofdm)((_sc), (_physt))) 485 #define rtwn_power_on(_sc) \ 486 (((_sc)->sc_power_on)((_sc))) 487 #define rtwn_power_off(_sc) \ 488 (((_sc)->sc_power_off)((_sc))) 489 #ifndef RTWN_WITHOUT_UCODE 490 #define rtwn_fw_reset(_sc, _reason) \ 491 (((_sc)->sc_fw_reset)((_sc), (_reason))) 492 #define rtwn_fw_download_enable(_sc, _enable) \ 493 (((_sc)->sc_fw_download_enable)((_sc), (_enable))) 494 #endif 495 #define rtwn_set_page_size(_sc) \ 496 (((_sc)->sc_set_page_size)((_sc))) 497 #define rtwn_lc_calib(_sc) \ 498 (((_sc)->sc_lc_calib)((_sc))) 499 #define rtwn_iq_calib(_sc) \ 500 (((_sc)->sc_iq_calib)((_sc))) 501 #define rtwn_read_chipid_vendor(_sc, _reg) \ 502 (((_sc)->sc_read_chipid_vendor)((_sc), (_reg))) 503 #define rtwn_adj_devcaps(_sc) \ 504 (((_sc)->sc_adj_devcaps)((_sc))) 505 #define rtwn_vap_preattach(_sc, _vap) \ 506 (((_sc)->sc_vap_preattach)((_sc), (_vap))) 507 #define rtwn_postattach(_sc) \ 508 (((_sc)->sc_postattach)((_sc))) 509 #define rtwn_detach_private(_sc) \ 510 (((_sc)->sc_detach_private)((_sc))) 511 #define rtwn_fill_tx_desc(_sc, _ni, _m, \ 512 _buf, _ridx, _maxretry) \ 513 (((_sc)->sc_fill_tx_desc)((_sc), (_ni), \ 514 (_m), (_buf), (_ridx), (_maxretry))) 515 #define rtwn_fill_tx_desc_raw(_sc, _ni, _m, \ 516 _buf, _params) \ 517 (((_sc)->sc_fill_tx_desc_raw)((_sc), (_ni), \ 518 (_m), (_buf), (_params))) 519 #define rtwn_fill_tx_desc_null(_sc, _buf, _11b, _qos, _id) \ 520 (((_sc)->sc_fill_tx_desc_null)((_sc), \ 521 (_buf), (_11b), (_qos), (_id))) 522 #define rtwn_dump_tx_desc(_sc, _desc) \ 523 (((_sc)->sc_dump_tx_desc)((_sc), (_desc))) 524 #define rtwn_tx_radiotap_flags(_sc, _buf) \ 525 (((_sc)->sc_tx_radiotap_flags)((_buf))) 526 #define rtwn_rx_radiotap_flags(_sc, _buf) \ 527 (((_sc)->sc_rx_radiotap_flags)((_buf))) 528 #define rtwn_set_chan(_sc, _c) \ 529 (((_sc)->sc_set_chan)((_sc), (_c))) 530 #ifndef RTWN_WITHOUT_UCODE 531 #define rtwn_set_rsvd_page(_sc, _resp, _null, _qos_null) \ 532 (((_sc)->sc_set_rsvd_page)((_sc), \ 533 (_resp), (_null), (_qos_null))) 534 #define rtwn_set_pwrmode(_sc, _vap, _off) \ 535 (((_sc)->sc_set_pwrmode)((_sc), (_vap), (_off))) 536 #define rtwn_set_rssi(_sc) \ 537 (((_sc)->sc_set_rssi)((_sc))) 538 #endif 539 #define rtwn_classify_intr(_sc, _buf, _len) \ 540 (((_sc)->sc_classify_intr)((_sc), (_buf), (_len))) 541 #define rtwn_handle_tx_report(_sc, _buf, _len) \ 542 (((_sc)->sc_handle_tx_report)((_sc), (_buf), (_len))) 543 #define rtwn_handle_c2h_report(_sc, _buf, _len) \ 544 (((_sc)->sc_handle_c2h_report)((_sc), (_buf), (_len))) 545 #define rtwn_check_frame(_sc, _m) \ 546 (((_sc)->sc_check_frame)((_sc), (_m))) 547 #define rtwn_beacon_init(_sc, _buf, _id) \ 548 (((_sc)->sc_beacon_init)((_sc), (_buf), (_id))) 549 #define rtwn_beacon_enable(_sc, _id, _enable) \ 550 (((_sc)->sc_beacon_enable)((_sc), (_id), (_enable))) 551 #define rtwn_beacon_set_rate(_sc, _buf, _is5ghz) \ 552 (((_sc)->sc_beacon_set_rate)((_buf), (_is5ghz))) 553 #define rtwn_beacon_select(_sc, _id) \ 554 (((_sc)->sc_beacon_select)((_sc), (_id))) 555 #define rtwn_temp_measure(_sc) \ 556 (((_sc)->sc_temp_measure)((_sc))) 557 #define rtwn_temp_read(_sc) \ 558 (((_sc)->sc_temp_read)((_sc))) 559 #define rtwn_init_tx_agg(_sc) \ 560 (((_sc)->sc_init_tx_agg)((_sc))) 561 #define rtwn_init_rx_agg(_sc) \ 562 (((_sc)->sc_init_rx_agg)((_sc))) 563 #define rtwn_init_intr(_sc) \ 564 (((_sc)->sc_init_intr)((_sc))) 565 #define rtwn_init_ampdu(_sc) \ 566 (((_sc)->sc_init_ampdu)((_sc))) 567 #define rtwn_init_edca(_sc) \ 568 (((_sc)->sc_init_edca)((_sc))) 569 #define rtwn_init_bb(_sc) \ 570 (((_sc)->sc_init_bb)((_sc))) 571 #define rtwn_init_rf(_sc) \ 572 (((_sc)->sc_init_rf)((_sc))) 573 #define rtwn_init_antsel(_sc) \ 574 (((_sc)->sc_init_antsel)((_sc))) 575 #define rtwn_post_init(_sc) \ 576 (((_sc)->sc_post_init)((_sc))) 577 #define rtwn_init_bcnq1_boundary(_sc) \ 578 (((_sc)->sc_init_bcnq1_boundary)((_sc))) 579 580 581 /* 582 * Methods to access subfields in registers. 583 */ 584 static __inline int 585 rtwn_setbits_1(struct rtwn_softc *sc, uint16_t addr, uint8_t clr, 586 uint8_t set) 587 { 588 return (rtwn_write_1(sc, addr, 589 (rtwn_read_1(sc, addr) & ~clr) | set)); 590 } 591 592 static __inline int 593 rtwn_setbits_1_shift(struct rtwn_softc *sc, uint16_t addr, uint32_t clr, 594 uint32_t set, int shift) 595 { 596 return (rtwn_setbits_1(sc, addr + shift, clr >> shift * NBBY, 597 set >> shift * NBBY)); 598 } 599 600 static __inline int 601 rtwn_setbits_2(struct rtwn_softc *sc, uint16_t addr, uint16_t clr, 602 uint16_t set) 603 { 604 return (rtwn_write_2(sc, addr, 605 (rtwn_read_2(sc, addr) & ~clr) | set)); 606 } 607 608 static __inline int 609 rtwn_setbits_4(struct rtwn_softc *sc, uint16_t addr, uint32_t clr, 610 uint32_t set) 611 { 612 return (rtwn_write_4(sc, addr, 613 (rtwn_read_4(sc, addr) & ~clr) | set)); 614 } 615 616 static __inline void 617 rtwn_rf_setbits(struct rtwn_softc *sc, int chain, uint8_t addr, 618 uint32_t clr, uint32_t set) 619 { 620 rtwn_rf_write(sc, chain, addr, 621 (rtwn_rf_read(sc, chain, addr) & ~clr) | set); 622 } 623 624 #endif /* IF_RTWNVAR_H */ 625