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