1 /* 2 * Copyright (c) 2012, 2013 Adrian Chadd <adrian@FreeBSD.org>. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #include "opt_ah.h" 18 19 #include "ah.h" 20 #include "ah_internal.h" 21 #include "ah_devid.h" 22 #include "ah_desc.h" 23 24 #include "ar9300.h" 25 #include "ar9300reg.h" 26 #include "ar9300phy.h" 27 #include "ar9300desc.h" 28 29 #include "ar9300_freebsd.h" 30 31 #include "ar9300_stub.h" 32 #include "ar9300_stub_funcs.h" 33 34 #define FIX_NOISE_FLOOR 1 35 #define NEXT_TBTT_NOW 5 36 static HAL_BOOL ar9300ClrMulticastFilterIndex(struct ath_hal *ah, uint32_t ix); 37 static HAL_BOOL ar9300SetMulticastFilterIndex(struct ath_hal *ah, uint32_t ix); 38 39 static void ar9300_beacon_set_beacon_timers(struct ath_hal *ah, 40 const HAL_BEACON_TIMERS *bt); 41 42 static void 43 ar9300SetChainMasks(struct ath_hal *ah, uint32_t tx_chainmask, 44 uint32_t rx_chainmask) 45 { 46 47 AH9300(ah)->ah_tx_chainmask = 48 tx_chainmask & AH_PRIVATE(ah)->ah_caps.halTxChainMask; 49 AH9300(ah)->ah_rx_chainmask = 50 rx_chainmask & AH_PRIVATE(ah)->ah_caps.halRxChainMask; 51 } 52 53 static u_int 54 ar9300GetSlotTime(struct ath_hal *ah) 55 { 56 u_int clks = OS_REG_READ(ah, AR_D_GBL_IFS_SLOT) & 0xffff; 57 return (ath_hal_mac_usec(ah, clks)); /* convert from system clocks */ 58 } 59 60 static HAL_BOOL 61 ar9300_freebsd_set_tx_power_limit(struct ath_hal *ah, uint32_t limit) 62 { 63 return (ar9300_set_tx_power_limit(ah, limit, 0, 0)); 64 } 65 66 static uint64_t 67 ar9300_get_next_tbtt(struct ath_hal *ah) 68 { 69 return (OS_REG_READ(ah, AR_NEXT_TBTT_TIMER)); 70 } 71 72 void 73 ar9300_attach_freebsd_ops(struct ath_hal *ah) 74 { 75 76 /* Global functions */ 77 ah->ah_detach = ar9300_detach; 78 ah->ah_getRateTable = ar9300_get_rate_table; 79 80 /* Reset functions */ 81 ah->ah_reset = ar9300_reset_freebsd; 82 ah->ah_phyDisable = ar9300_phy_disable; 83 ah->ah_disable = ar9300_disable; 84 ah->ah_configPCIE = ar9300_config_pcie_freebsd; 85 // ah->ah_disablePCIE = ar9300_disable_pcie_phy; 86 ah->ah_setPCUConfig = ar9300_set_pcu_config; 87 // perCalibration 88 ah->ah_perCalibrationN = ar9300_per_calibration_freebsd; 89 ah->ah_resetCalValid = ar9300_reset_cal_valid_freebsd; 90 ah->ah_setTxPowerLimit = ar9300_freebsd_set_tx_power_limit; 91 ah->ah_getChanNoise = ath_hal_getChanNoise; 92 93 /* Transmit functions */ 94 ah->ah_setupTxQueue = ar9300_setup_tx_queue; 95 ah->ah_setTxQueueProps = ar9300_set_tx_queue_props; 96 ah->ah_getTxQueueProps = ar9300_get_tx_queue_props; 97 ah->ah_releaseTxQueue = ar9300_release_tx_queue; 98 ah->ah_resetTxQueue = ar9300_reset_tx_queue; 99 ah->ah_getTxDP = ar9300_get_tx_dp; 100 ah->ah_setTxDP = ar9300_set_tx_dp; 101 ah->ah_numTxPending = ar9300_num_tx_pending; 102 ah->ah_startTxDma = ar9300_start_tx_dma; 103 ah->ah_stopTxDma = ar9300_stop_tx_dma_freebsd; 104 ah->ah_setupTxDesc = ar9300_freebsd_setup_tx_desc; 105 ah->ah_setupXTxDesc = ar9300_freebsd_setup_x_tx_desc; 106 ah->ah_fillTxDesc = ar9300_freebsd_fill_tx_desc; 107 ah->ah_procTxDesc = ar9300_freebsd_proc_tx_desc; 108 ah->ah_getTxIntrQueue = ar9300_get_tx_intr_queue; 109 // reqTxIntrDesc 110 ah->ah_getTxCompletionRates = ar9300_freebsd_get_tx_completion_rates; 111 ah->ah_setTxDescLink = ar9300_set_desc_link; 112 ah->ah_getTxDescLink = ar9300_freebsd_get_desc_link; 113 ah->ah_getTxDescLinkPtr = ar9300_get_desc_link_ptr; 114 ah->ah_setupTxStatusRing = ar9300_setup_tx_status_ring; 115 ah->ah_getTxRawTxDesc = ar9300_get_raw_tx_desc; 116 ah->ah_updateTxTrigLevel = ar9300_update_tx_trig_level; 117 118 /* RX functions */ 119 ah->ah_getRxDP = ar9300_get_rx_dp; 120 ah->ah_setRxDP = ar9300_set_rx_dp; 121 ah->ah_enableReceive = ar9300_enable_receive; 122 ah->ah_stopDmaReceive = ar9300_stop_dma_receive_freebsd; 123 ah->ah_startPcuReceive = ar9300_start_pcu_receive_freebsd; 124 ah->ah_stopPcuReceive = ar9300_stop_pcu_receive; 125 ah->ah_setMulticastFilter = ar9300_set_multicast_filter; 126 ah->ah_setMulticastFilterIndex = ar9300SetMulticastFilterIndex; 127 ah->ah_clrMulticastFilterIndex = ar9300ClrMulticastFilterIndex; 128 ah->ah_getRxFilter = ar9300_get_rx_filter; 129 ah->ah_setRxFilter = ar9300_set_rx_filter; 130 /* setupRxDesc */ 131 ah->ah_procRxDesc = ar9300_proc_rx_desc_freebsd; 132 ah->ah_rxMonitor = ar9300_ani_rxmonitor_freebsd; 133 ah->ah_aniPoll = ar9300_ani_poll_freebsd; 134 ah->ah_procMibEvent = ar9300_process_mib_intr; 135 136 /* Misc functions */ 137 ah->ah_getCapability = ar9300_get_capability; 138 ah->ah_setCapability = ar9300_set_capability; 139 ah->ah_getDiagState = ar9300_get_diag_state; 140 ah->ah_getMacAddress = ar9300_get_mac_address; 141 ah->ah_setMacAddress = ar9300_set_mac_address; 142 ah->ah_getBssIdMask = ar9300_get_bss_id_mask; 143 ah->ah_setBssIdMask = ar9300_set_bss_id_mask; 144 ah->ah_setRegulatoryDomain = ar9300_set_regulatory_domain; 145 ah->ah_setLedState = ar9300_set_led_state; 146 ah->ah_writeAssocid = ar9300_write_associd; 147 ah->ah_gpioCfgInput = ar9300_gpio_cfg_input; 148 ah->ah_gpioCfgOutput = ar9300_gpio_cfg_output; 149 ah->ah_gpioGet = ar9300_gpio_get; 150 ah->ah_gpioSet = ar9300_gpio_set; 151 ah->ah_gpioSetIntr = ar9300_gpio_set_intr; 152 /* polarity */ 153 /* mask */ 154 ah->ah_getTsf32 = ar9300_get_tsf32; 155 ah->ah_getTsf64 = ar9300_get_tsf64; 156 ah->ah_resetTsf = ar9300_reset_tsf; 157 ah->ah_detectCardPresent = ar9300_detect_card_present; 158 // ah->ah_updateMibCounters = ar9300_update_mib_counters; 159 ah->ah_getRfGain = ar9300_get_rfgain; 160 ah->ah_getDefAntenna = ar9300_get_def_antenna; 161 ah->ah_setDefAntenna = ar9300_set_def_antenna; 162 // ah->ah_getAntennaSwitch = ar9300_get_antenna_switch; 163 // ah->ah_setAntennaSwitch = ar9300_set_antenna_switch; 164 // ah->ah_setSifsTime = ar9300_set_sifs_time; 165 // ah->ah_getSifsTime = ar9300_get_sifs_time; 166 ah->ah_setSlotTime = ar9300_set_slot_time; 167 ah->ah_getSlotTime = ar9300GetSlotTime; 168 ah->ah_getAckTimeout = ar9300_get_ack_timeout; 169 ah->ah_setAckTimeout = ar9300_set_ack_timeout; 170 // XXX ack/ctsrate 171 // XXX CTS timeout 172 // XXX decompmask 173 // coverageclass 174 ah->ah_setQuiet = ar9300_set_quiet; 175 ah->ah_getMibCycleCounts = ar9300_freebsd_get_mib_cycle_counts; 176 177 /* DFS functions */ 178 ah->ah_enableDfs = ar9300_enable_dfs; 179 ah->ah_getDfsThresh = ar9300_get_dfs_thresh; 180 ah->ah_getDfsDefaultThresh = ar9300_freebsd_get_dfs_default_thresh; 181 // procradarevent 182 ah->ah_isFastClockEnabled = ar9300_is_fast_clock_enabled; 183 ah->ah_get11nExtBusy = ar9300_get_11n_ext_busy; 184 185 /* Key cache functions */ 186 ah->ah_getKeyCacheSize = ar9300_get_key_cache_size; 187 ah->ah_resetKeyCacheEntry = ar9300_reset_key_cache_entry; 188 ah->ah_isKeyCacheEntryValid = ar9300_is_key_cache_entry_valid; 189 ah->ah_setKeyCacheEntry = ar9300_set_key_cache_entry; 190 ah->ah_setKeyCacheEntryMac = ar9300_set_key_cache_entry_mac; 191 192 /* Power management functions */ 193 ah->ah_setPowerMode = ar9300_set_power_mode; 194 ah->ah_getPowerMode = ar9300_get_power_mode; 195 196 /* Beacon functions */ 197 /* ah_setBeaconTimers */ 198 ah->ah_beaconInit = ar9300_freebsd_beacon_init; 199 ah->ah_setBeaconTimers = ar9300_beacon_set_beacon_timers; 200 ah->ah_setStationBeaconTimers = ar9300_set_sta_beacon_timers; 201 /* ah_resetStationBeaconTimers */ 202 ah->ah_getNextTBTT = ar9300_get_next_tbtt; 203 204 /* Interrupt functions */ 205 ah->ah_isInterruptPending = ar9300_is_interrupt_pending; 206 ah->ah_getPendingInterrupts = ar9300_get_pending_interrupts_freebsd; 207 ah->ah_getInterrupts = ar9300_get_interrupts; 208 ah->ah_setInterrupts = ar9300_set_interrupts_freebsd; 209 210 /* Regulatory/internal functions */ 211 // AH_PRIVATE(ah)->ah_getNfAdjust = ar9300_get_nf_adjust; 212 AH_PRIVATE(ah)->ah_eepromRead = ar9300_eeprom_read_word; 213 // AH_PRIVATE(ah)->ah_getChipPowerLimits = ar9300_get_chip_power_limits; 214 AH_PRIVATE(ah)->ah_getWirelessModes = ar9300_get_wireless_modes; 215 AH_PRIVATE(ah)->ah_getChannelEdges = ar9300_get_channel_edges; 216 217 AH_PRIVATE(ah)->ah_eepromRead = ar9300_eeprom_read_word; 218 /* XXX ah_eeprom */ 219 /* XXX ah_eeversion */ 220 /* XXX ah_eepromDetach */ 221 /* XXX ah_eepromGet */ 222 AH_PRIVATE(ah)->ah_eepromGet = ar9300_eeprom_get_freebsd; 223 /* XXX ah_eepromSet */ 224 /* XXX ah_getSpurChan */ 225 /* XXX ah_eepromDiag */ 226 227 /* 802.11n functions */ 228 ah->ah_chainTxDesc = ar9300_freebsd_chain_tx_desc; 229 ah->ah_setupFirstTxDesc= ar9300_freebsd_setup_first_tx_desc; 230 ah->ah_setupLastTxDesc = ar9300_freebsd_setup_last_tx_desc; 231 ah->ah_set11nRateScenario = ar9300_freebsd_set_11n_rate_scenario; 232 ah->ah_set11nTxDesc = ar9300_freebsd_setup_11n_desc; 233 ah->ah_set11nAggrFirst = ar9300_set_11n_aggr_first; 234 ah->ah_set11nAggrMiddle = ar9300_set_11n_aggr_middle; 235 ah->ah_set11nAggrLast = ar9300_set_11n_aggr_last; 236 ah->ah_clr11nAggr = ar9300_clr_11n_aggr; 237 ah->ah_set11nBurstDuration = ar9300_set_11n_burst_duration; 238 /* ah_get11nExtBusy */ 239 ah->ah_set11nMac2040 = ar9300_set_11n_mac2040; 240 ah->ah_setChainMasks = ar9300SetChainMasks; 241 /* ah_get11nRxClear */ 242 /* ah_set11nRxClear */ 243 244 /* bluetooth coexistence functions */ 245 ah->ah_btCoexSetInfo = ar9300_set_bt_coex_info; 246 ah->ah_btCoexSetConfig = ar9300_bt_coex_config; 247 ah->ah_btCoexSetQcuThresh = ar9300_bt_coex_set_qcu_thresh; 248 ah->ah_btCoexSetWeights = ar9300_bt_coex_set_weights; 249 ah->ah_btCoexSetBmissThresh = ar9300_bt_coex_setup_bmiss_thresh; 250 ah->ah_btCoexSetParameter = ar9300_bt_coex_set_parameter; 251 ah->ah_btCoexDisable = ar9300_bt_coex_disable; 252 ah->ah_btCoexEnable = ar9300_bt_coex_enable; 253 254 /* MCI bluetooth functions */ 255 if (AR_SREV_JUPITER(ah) || AR_SREV_APHRODITE(ah)) { 256 ah->ah_btCoexSetWeights = ar9300_mci_bt_coex_set_weights; 257 ah->ah_btCoexDisable = ar9300_mci_bt_coex_disable; 258 ah->ah_btCoexEnable = ar9300_mci_bt_coex_enable; 259 } 260 ah->ah_btMciSetup = ar9300_mci_setup; 261 ah->ah_btMciSendMessage = ar9300_mci_send_message; 262 ah->ah_btMciGetInterrupt = ar9300_mci_get_interrupt; 263 ah->ah_btMciGetState = ar9300_mci_state; 264 ah->ah_btMciDetach = ar9300_mci_detach; 265 266 /* LNA diversity functions */ 267 ah->ah_divLnaConfGet = ar9300_ant_div_comb_get_config; 268 ah->ah_divLnaConfSet = ar9300_ant_div_comb_set_config; 269 } 270 271 HAL_BOOL 272 ar9300_reset_freebsd(struct ath_hal *ah, HAL_OPMODE opmode, 273 struct ieee80211_channel *chan, HAL_BOOL bChannelChange, 274 HAL_STATUS *status) 275 { 276 HAL_BOOL r; 277 HAL_HT_MACMODE macmode; 278 struct ath_hal_private *ap = AH_PRIVATE(ah); 279 280 macmode = 281 IEEE80211_IS_CHAN_HT40(chan) ? 282 HAL_HT_MACMODE_2040 : HAL_HT_MACMODE_20; 283 284 r = ar9300_reset(ah, opmode, chan, macmode, 285 ap->ah_caps.halTxChainMask, 286 ap->ah_caps.halRxChainMask, 287 HAL_HT_EXTPROTSPACING_20, /* always 20Mhz channel spacing */ 288 bChannelChange, 289 status, 290 AH_FALSE); /* XXX should really extend ath_hal_reset() */ 291 292 return (r); 293 } 294 295 void 296 ar9300_config_pcie_freebsd(struct ath_hal *ah, HAL_BOOL restore, 297 HAL_BOOL powerOff) 298 { 299 300 ar9300_config_pci_power_save(ah, restore ? 1 : 0, powerOff ? 1 : 0); 301 } 302 303 /* 304 * This is a copy from ar9300_eeprom_get(), purely because the FreeBSD 305 * API is very silly and inconsistent. 306 * 307 * The AR93xx HAL doesn't call the eepromGetFlag() function, so this 308 * only occurs for FreeBSD code. 309 * 310 * When I fix this particular API, I'll undo this. 311 */ 312 HAL_STATUS 313 ar9300_eeprom_get_freebsd(struct ath_hal *ah, int param, void *val) 314 { 315 316 switch (param) { 317 case AR_EEP_FSTCLK_5G: 318 return HAL_OK; 319 default: 320 ath_hal_printf(ah, "%s: called, param=%d\n", 321 __func__, param); 322 return HAL_EIO; 323 } 324 } 325 326 HAL_BOOL 327 ar9300_stop_tx_dma_freebsd(struct ath_hal *ah, u_int q) 328 { 329 330 return ar9300_stop_tx_dma(ah, q, 1000); 331 } 332 333 void 334 ar9300_ani_poll_freebsd(struct ath_hal *ah, 335 const struct ieee80211_channel *chan) 336 { 337 338 HAL_NODE_STATS stats; 339 HAL_ANISTATS anistats; 340 341 OS_MEMZERO(&stats, sizeof(stats)); 342 OS_MEMZERO(&anistats, sizeof(anistats)); 343 344 ar9300_ani_ar_poll(ah, &stats, chan, &anistats); 345 } 346 347 /* 348 * Setup the configuration parameters in the style the AR9300 HAL 349 * wants. 350 */ 351 void 352 ar9300_config_defaults_freebsd(struct ath_hal *ah, HAL_OPS_CONFIG *ah_config) 353 { 354 355 /* Until FreeBSD's HAL does this by default - just copy */ 356 OS_MEMCPY(&ah->ah_config, ah_config, sizeof(HAL_OPS_CONFIG)); 357 ah->ah_config.ath_hal_enable_ani = AH_TRUE; 358 } 359 360 HAL_BOOL 361 ar9300_stop_dma_receive_freebsd(struct ath_hal *ah) 362 { 363 364 return ar9300_stop_dma_receive(ah, 1000); 365 } 366 367 HAL_BOOL 368 ar9300_get_pending_interrupts_freebsd(struct ath_hal *ah, HAL_INT *masked) 369 { 370 371 /* Non-MSI, so no MSI vector; and 'nortc' = 0 */ 372 return ar9300_get_pending_interrupts(ah, masked, HAL_INT_LINE, 0, 0); 373 } 374 375 HAL_INT 376 ar9300_set_interrupts_freebsd(struct ath_hal *ah, HAL_INT ints) 377 { 378 379 /* nortc = 0 */ 380 return ar9300_set_interrupts(ah, ints, 0); 381 } 382 383 HAL_BOOL 384 ar9300_per_calibration_freebsd(struct ath_hal *ah, 385 struct ieee80211_channel *chan, u_int rxchainmask, HAL_BOOL long_cal, 386 HAL_BOOL *isCalDone) 387 { 388 /* XXX fake scheduled calibrations for now */ 389 u_int32_t sched_cals = 0xfffffff; 390 391 return ar9300_calibration(ah, chan, 392 AH_PRIVATE(ah)->ah_caps.halRxChainMask, 393 long_cal, 394 isCalDone, 395 0, /* is_scan */ 396 &sched_cals); 397 } 398 399 HAL_BOOL 400 ar9300_reset_cal_valid_freebsd(struct ath_hal *ah, 401 const struct ieee80211_channel *chan) 402 { 403 404 HAL_BOOL is_cal_done = AH_TRUE; 405 406 ar9300_reset_cal_valid(ah, chan, &is_cal_done, 0xffffffff); 407 return (is_cal_done); 408 } 409 410 411 void 412 ar9300_start_pcu_receive_freebsd(struct ath_hal *ah) 413 { 414 415 /* is_scanning flag == NULL */ 416 ar9300_start_pcu_receive(ah, AH_FALSE); 417 } 418 419 /* 420 * FreeBSD will just pass in the descriptor value as 'pa'. 421 * The Atheros HAL treats 'pa' as the physical address of the RX 422 * descriptor and 'bufaddr' as the physical address of the RX buffer. 423 * I'm not sure why they didn't collapse them - the AR9300 RX descriptor 424 * routine doesn't check 'pa'. 425 */ 426 HAL_STATUS 427 ar9300_proc_rx_desc_freebsd(struct ath_hal *ah, struct ath_desc *ds, 428 uint32_t pa, struct ath_desc *ds_next, uint64_t tsf, 429 struct ath_rx_status *rxs) 430 { 431 432 return (ar9300_proc_rx_desc_fast(ah, ds, 0, ds_next, rxs, 433 (void *) ds)); 434 } 435 436 void 437 ar9300_ani_rxmonitor_freebsd(struct ath_hal *ah, const HAL_NODE_STATS *stats, 438 const struct ieee80211_channel *chan) 439 { 440 441 } 442 443 void 444 ar9300_freebsd_get_desc_link(struct ath_hal *ah, void *ds, uint32_t *link) 445 { 446 struct ar9300_txc *ads = AR9300TXC(ds); 447 448 (*link) = ads->ds_link; 449 } 450 451 /* 452 * TX descriptor field setting wrappers - eek. 453 */ 454 455 456 HAL_BOOL 457 ar9300_freebsd_setup_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 458 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower, 459 u_int txRate0, u_int txTries0, u_int keyIx, u_int antMode, u_int flags, 460 u_int rtsctsRate, u_int rtsCtsDuration, u_int compicvLen, 461 u_int compivLen, u_int comp) 462 { 463 struct ath_hal_9300 *ahp = AH9300(ah); 464 465 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 466 467 if (keyIx != HAL_TXKEYIX_INVALID) 468 keyType = ahp->ah_keytype[keyIx]; 469 470 /* XXX bounds check keyix */ 471 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 472 keyType, flags); 473 474 return AH_TRUE; 475 } 476 477 HAL_BOOL 478 ar9300_freebsd_setup_x_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 479 u_int txRate1, u_int txTries1, 480 u_int txRate2, u_int txTries2, 481 u_int txRate3, u_int txTries3) 482 { 483 484 #if 0 485 ath_hal_printf(ah, "%s: called, 0x%x/%d, 0x%x/%d, 0x%x/%d\n", 486 __func__, 487 txRate1, txTries1, 488 txRate2, txTries2, 489 txRate3, txTries3); 490 #endif 491 492 /* XXX should only be called during probe */ 493 return (AH_TRUE); 494 } 495 496 HAL_BOOL 497 ar9300_freebsd_fill_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 498 HAL_DMA_ADDR *bufListPtr, uint32_t *segLenPtr, u_int descId, u_int qid, 499 HAL_BOOL firstSeg, HAL_BOOL lastSeg, 500 const struct ath_desc *ds0) 501 { 502 HAL_KEY_TYPE keyType = 0; 503 const struct ar9300_txc *ads = AR9300TXC_CONST(ds0); 504 505 /* 506 * FreeBSD's HAL doesn't pass the keytype to fill_tx_desc(); 507 * it's copied as part of the descriptor chaining. 508 * 509 * So, extract it from ds0. 510 */ 511 keyType = MS(ads->ds_ctl17, AR_encr_type); 512 513 return ar9300_fill_tx_desc(ah, ds, bufListPtr, segLenPtr, descId, 514 qid, keyType, firstSeg, lastSeg, ds0); 515 } 516 517 HAL_BOOL 518 ar9300_freebsd_get_tx_completion_rates(struct ath_hal *ah, 519 const struct ath_desc *ds0, int *rates, int *tries) 520 { 521 522 ath_hal_printf(ah, "%s: called\n", __func__); 523 return AH_FALSE; /* XXX for now */ 524 } 525 526 527 /* 528 * 802.11n TX descriptor wrappers 529 */ 530 void 531 ar9300_freebsd_set_11n_rate_scenario(struct ath_hal *ah, struct ath_desc *ds, 532 u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], 533 u_int nseries, u_int flags) 534 { 535 536 /* lastds=NULL, rtscts_duration is 0, smart antenna is 0 */ 537 ar9300_set_11n_rate_scenario(ah, (void *) ds, (void *)ds, durUpdateEn, 538 rtsctsRate, 0, series, nseries, flags, 0); 539 } 540 541 /* chaintxdesc */ 542 HAL_BOOL 543 ar9300_freebsd_chain_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 544 HAL_DMA_ADDR *bufLenList, uint32_t *segLenList, 545 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int keyIx, 546 HAL_CIPHER cipher, uint8_t numDelims, 547 HAL_BOOL firstSeg, HAL_BOOL lastSeg, HAL_BOOL lastAggr) 548 { 549 550 ath_hal_printf(ah, "%s: called\n", __func__); 551 return AH_FALSE; 552 } 553 554 /* setupfirsttxdesc */ 555 HAL_BOOL 556 ar9300_freebsd_setup_first_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 557 u_int aggrLen, u_int flags, u_int txPower, u_int txRate0, 558 u_int txTries0, u_int antMode, u_int rtsctsRate, u_int rtsctsDuration) 559 { 560 561 ath_hal_printf(ah, "%s: called\n", __func__); 562 return AH_FALSE; 563 } 564 565 /* setuplasttxdesc */ 566 /* 567 * This gets called but for now let's not log anything; 568 * it's only used to update the rate control information. 569 */ 570 HAL_BOOL 571 ar9300_freebsd_setup_last_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 572 const struct ath_desc *ds0) 573 { 574 575 // ath_hal_printf(ah, "%s: called\n", __func__); 576 return AH_FALSE; 577 } 578 579 void 580 ar9300_freebsd_setup_11n_desc(struct ath_hal *ah, void *ds, u_int pktLen, 581 HAL_PKT_TYPE type, u_int txPower, u_int keyIx, u_int flags) 582 { 583 ath_hal_printf(ah, "%s: called\n", __func__); 584 #if 0 585 struct ath_hal_9300 *ahp = AH9300(ah); 586 587 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 588 589 if (keyIx != HAL_TXKEYIX_INVALID) 590 keyType = ahp->ah_keytype[keyIx]; 591 592 /* XXX bounds check keyix */ 593 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 594 keyType, flags); 595 #endif 596 } 597 598 HAL_STATUS 599 ar9300_freebsd_proc_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 600 struct ath_tx_status *ts) 601 { 602 603 return ar9300_proc_tx_desc(ah, ts); 604 } 605 606 void 607 ar9300_freebsd_beacon_init(struct ath_hal *ah, uint32_t next_beacon, 608 uint32_t beacon_period) 609 { 610 611 ar9300_beacon_init(ah, next_beacon, beacon_period, 0, 612 AH_PRIVATE(ah)->ah_opmode); 613 } 614 615 HAL_BOOL 616 ar9300_freebsd_get_mib_cycle_counts(struct ath_hal *ah, 617 HAL_SURVEY_SAMPLE *hs) 618 619 { 620 621 return (AH_FALSE); 622 } 623 624 HAL_BOOL 625 ar9300_freebsd_get_dfs_default_thresh(struct ath_hal *ah, 626 HAL_PHYERR_PARAM *pe) 627 { 628 629 /* XXX not yet */ 630 631 return (AH_FALSE); 632 } 633 634 /* 635 * Clear multicast filter by index - from FreeBSD ar5212_recv.c 636 */ 637 static HAL_BOOL 638 ar9300ClrMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 639 { 640 uint32_t val; 641 642 if (ix >= 64) 643 return (AH_FALSE); 644 if (ix >= 32) { 645 val = OS_REG_READ(ah, AR_MCAST_FIL1); 646 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val &~ (1<<(ix-32)))); 647 } else { 648 val = OS_REG_READ(ah, AR_MCAST_FIL0); 649 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val &~ (1<<ix))); 650 } 651 return AH_TRUE; 652 } 653 654 /* 655 * Set multicast filter by index - from FreeBSD ar5212_recv.c 656 */ 657 static HAL_BOOL 658 ar9300SetMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 659 { 660 uint32_t val; 661 662 if (ix >= 64) 663 return (AH_FALSE); 664 if (ix >= 32) { 665 val = OS_REG_READ(ah, AR_MCAST_FIL1); 666 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val | (1<<(ix-32)))); 667 } else { 668 val = OS_REG_READ(ah, AR_MCAST_FIL0); 669 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val | (1<<ix))); 670 } 671 return (AH_TRUE); 672 } 673 674 #define TU_TO_USEC(_tu) ((_tu) << 10) 675 #define ONE_EIGHTH_TU_TO_USEC(_tu8) ((_tu8) << 7) 676 677 /* 678 * Initializes all of the hardware registers used to 679 * send beacons. Note that for station operation the 680 * driver calls ar9300_set_sta_beacon_timers instead. 681 */ 682 static void 683 ar9300_beacon_set_beacon_timers(struct ath_hal *ah, 684 const HAL_BEACON_TIMERS *bt) 685 { 686 uint32_t bperiod; 687 688 #if 0 689 HALASSERT(opmode == HAL_M_IBSS || opmode == HAL_M_HOSTAP); 690 if (opmode == HAL_M_IBSS) { 691 OS_REG_SET_BIT(ah, AR_TXCFG, AR_TXCFG_ADHOC_BEACON_ATIM_TX_POLICY); 692 } 693 #endif 694 695 /* XXX TODO: should migrate the HAL code to always use ONE_EIGHTH_TU */ 696 OS_REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bt->bt_nexttbtt)); 697 OS_REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextdba)); 698 OS_REG_WRITE(ah, AR_NEXT_SWBA, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextswba)); 699 OS_REG_WRITE(ah, AR_NEXT_NDP_TIMER, TU_TO_USEC(bt->bt_nextatim)); 700 701 bperiod = TU_TO_USEC(bt->bt_intval & HAL_BEACON_PERIOD); 702 /* XXX TODO! */ 703 // ahp->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD; 704 OS_REG_WRITE(ah, AR_BEACON_PERIOD, bperiod); 705 OS_REG_WRITE(ah, AR_DMA_BEACON_PERIOD, bperiod); 706 OS_REG_WRITE(ah, AR_SWBA_PERIOD, bperiod); 707 OS_REG_WRITE(ah, AR_NDP_PERIOD, bperiod); 708 709 /* 710 * Reset TSF if required. 711 */ 712 if (bt->bt_intval & HAL_BEACON_RESET_TSF) 713 ar9300_reset_tsf(ah); 714 715 /* enable timers */ 716 /* NB: flags == 0 handled specially for backwards compatibility */ 717 OS_REG_SET_BIT(ah, AR_TIMER_MODE, 718 bt->bt_flags != 0 ? bt->bt_flags : 719 AR_TBTT_TIMER_EN | AR_DBA_TIMER_EN | AR_SWBA_TIMER_EN); 720 } 721 722 723 /* 724 * RF attach stubs 725 */ 726 727 static HAL_BOOL 728 rf9330_attach(struct ath_hal *ah, HAL_STATUS *status) 729 { 730 731 (*status) = HAL_EINVAL; 732 return (AH_FALSE); 733 } 734 735 static HAL_BOOL 736 rf9330_probe(struct ath_hal *ah) 737 { 738 return (AH_FALSE); 739 } 740 741 AH_RF(RF9330, rf9330_probe, rf9330_attach); 742 743