316 HAL_STATUS *status) 317{ 318 HAL_BOOL r; 319 HAL_HT_MACMODE macmode; 320 struct ath_hal_private *ap = AH_PRIVATE(ah); 321 322 macmode = 323 IEEE80211_IS_CHAN_HT40(chan) ? 324 HAL_HT_MACMODE_2040 : HAL_HT_MACMODE_20; 325 326 r = ar9300_reset(ah, opmode, chan, macmode, 327 ap->ah_caps.halTxChainMask, 328 ap->ah_caps.halRxChainMask, 329 HAL_HT_EXTPROTSPACING_20, /* always 20Mhz channel spacing */ 330 bChannelChange, 331 status, 332 AH_FALSE); /* XXX should really extend ath_hal_reset() */ 333 334 return (r); 335} 336 337void 338ar9300_config_pcie_freebsd(struct ath_hal *ah, HAL_BOOL restore, 339 HAL_BOOL powerOff) 340{ 341 342 ar9300_config_pci_power_save(ah, restore ? 1 : 0, powerOff ? 1 : 0); 343} 344 345/* 346 * This is a copy from ar9300_eeprom_get(), purely because the FreeBSD 347 * API is very silly and inconsistent. 348 * 349 * The AR93xx HAL doesn't call the eepromGetFlag() function, so this 350 * only occurs for FreeBSD code. 351 * 352 * When I fix this particular API, I'll undo this. 353 */ 354HAL_STATUS 355ar9300_eeprom_get_freebsd(struct ath_hal *ah, int param, void *val) 356{ 357 358 switch (param) { 359 case AR_EEP_FSTCLK_5G: 360 return HAL_OK; 361 default: 362 ath_hal_printf(ah, "%s: called, param=%d\n", 363 __func__, param); 364 return HAL_EIO; 365 } 366} 367 368HAL_BOOL 369ar9300_stop_tx_dma_freebsd(struct ath_hal *ah, u_int q) 370{ 371 372 return ar9300_stop_tx_dma(ah, q, 1000); 373} 374 375void 376ar9300_ani_poll_freebsd(struct ath_hal *ah, 377 const struct ieee80211_channel *chan) 378{ 379 380 HAL_NODE_STATS stats; 381 HAL_ANISTATS anistats; 382 HAL_SURVEY_SAMPLE survey; 383 384 OS_MEMZERO(&stats, sizeof(stats)); 385 OS_MEMZERO(&anistats, sizeof(anistats)); 386 OS_MEMZERO(&survey, sizeof(survey)); 387 388 ar9300_ani_ar_poll(ah, &stats, chan, &anistats); 389 390 /* 391 * If ANI stats are valid, use them to update the 392 * channel survey. 393 */ 394 if (anistats.valid) { 395 survey.cycle_count = anistats.cyclecnt_diff; 396 survey.chan_busy = anistats.rxclr_cnt; 397 survey.ext_chan_busy = anistats.extrxclr_cnt; 398 survey.tx_busy = anistats.txframecnt_diff; 399 survey.rx_busy = anistats.rxframecnt_diff; 400 ath_hal_survey_add_sample(ah, &survey); 401 } 402} 403 404/* 405 * Setup the configuration parameters in the style the AR9300 HAL 406 * wants. 407 */ 408void 409ar9300_config_defaults_freebsd(struct ath_hal *ah, HAL_OPS_CONFIG *ah_config) 410{ 411 412 /* Until FreeBSD's HAL does this by default - just copy */ 413 OS_MEMCPY(&ah->ah_config, ah_config, sizeof(HAL_OPS_CONFIG)); 414 ah->ah_config.ath_hal_enable_ani = AH_TRUE; 415} 416 417HAL_BOOL 418ar9300_stop_dma_receive_freebsd(struct ath_hal *ah) 419{ 420 421 return ar9300_stop_dma_receive(ah, 1000); 422} 423 424HAL_BOOL 425ar9300_get_pending_interrupts_freebsd(struct ath_hal *ah, HAL_INT *masked) 426{ 427 428 /* Non-MSI, so no MSI vector; and 'nortc' = 0 */ 429 return ar9300_get_pending_interrupts(ah, masked, HAL_INT_LINE, 0, 0); 430} 431 432HAL_INT 433ar9300_set_interrupts_freebsd(struct ath_hal *ah, HAL_INT ints) 434{ 435 436 /* nortc = 0 */ 437 return ar9300_set_interrupts(ah, ints, 0); 438} 439 440HAL_BOOL 441ar9300_per_calibration_freebsd(struct ath_hal *ah, 442 struct ieee80211_channel *chan, u_int rxchainmask, HAL_BOOL long_cal, 443 HAL_BOOL *isCalDone) 444{ 445 /* XXX fake scheduled calibrations for now */ 446 u_int32_t sched_cals = 0xfffffff; 447 448 return ar9300_calibration(ah, chan, 449 AH_PRIVATE(ah)->ah_caps.halRxChainMask, 450 long_cal, 451 isCalDone, 452 0, /* is_scan */ 453 &sched_cals); 454} 455 456HAL_BOOL 457ar9300_reset_cal_valid_freebsd(struct ath_hal *ah, 458 const struct ieee80211_channel *chan) 459{ 460 461 HAL_BOOL is_cal_done = AH_TRUE; 462 463 ar9300_reset_cal_valid(ah, chan, &is_cal_done, 0xffffffff); 464 return (is_cal_done); 465} 466 467 468void 469ar9300_start_pcu_receive_freebsd(struct ath_hal *ah) 470{ 471 472 /* is_scanning flag == NULL */ 473 ar9300_start_pcu_receive(ah, AH_FALSE); 474} 475 476/* 477 * FreeBSD will just pass in the descriptor value as 'pa'. 478 * The Atheros HAL treats 'pa' as the physical address of the RX 479 * descriptor and 'bufaddr' as the physical address of the RX buffer. 480 * I'm not sure why they didn't collapse them - the AR9300 RX descriptor 481 * routine doesn't check 'pa'. 482 */ 483HAL_STATUS 484ar9300_proc_rx_desc_freebsd(struct ath_hal *ah, struct ath_desc *ds, 485 uint32_t pa, struct ath_desc *ds_next, uint64_t tsf, 486 struct ath_rx_status *rxs) 487{ 488 489 return (ar9300_proc_rx_desc_fast(ah, ds, 0, ds_next, rxs, 490 (void *) ds)); 491} 492 493void 494ar9300_ani_rxmonitor_freebsd(struct ath_hal *ah, const HAL_NODE_STATS *stats, 495 const struct ieee80211_channel *chan) 496{ 497 498} 499 500void 501ar9300_freebsd_get_desc_link(struct ath_hal *ah, void *ds, uint32_t *link) 502{ 503 struct ar9300_txc *ads = AR9300TXC(ds); 504 505 (*link) = ads->ds_link; 506} 507 508/* 509 * TX descriptor field setting wrappers - eek. 510 */ 511 512 513HAL_BOOL 514ar9300_freebsd_setup_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 515 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower, 516 u_int txRate0, u_int txTries0, u_int keyIx, u_int antMode, u_int flags, 517 u_int rtsctsRate, u_int rtsCtsDuration, u_int compicvLen, 518 u_int compivLen, u_int comp) 519{ 520 struct ath_hal_9300 *ahp = AH9300(ah); 521 522 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 523 524 if (keyIx != HAL_TXKEYIX_INVALID) 525 keyType = ahp->ah_keytype[keyIx]; 526 527 /* XXX bounds check keyix */ 528 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 529 keyType, flags); 530 531 return AH_TRUE; 532} 533 534HAL_BOOL 535ar9300_freebsd_setup_x_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 536 u_int txRate1, u_int txTries1, 537 u_int txRate2, u_int txTries2, 538 u_int txRate3, u_int txTries3) 539{ 540 541#if 0 542 ath_hal_printf(ah, "%s: called, 0x%x/%d, 0x%x/%d, 0x%x/%d\n", 543 __func__, 544 txRate1, txTries1, 545 txRate2, txTries2, 546 txRate3, txTries3); 547#endif 548 549 /* XXX should only be called during probe */ 550 return (AH_TRUE); 551} 552 553HAL_BOOL 554ar9300_freebsd_fill_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 555 HAL_DMA_ADDR *bufListPtr, uint32_t *segLenPtr, u_int descId, u_int qid, 556 HAL_BOOL firstSeg, HAL_BOOL lastSeg, 557 const struct ath_desc *ds0) 558{ 559 HAL_KEY_TYPE keyType = 0; 560 const struct ar9300_txc *ads = AR9300TXC_CONST(ds0); 561 562 /* 563 * FreeBSD's HAL doesn't pass the keytype to fill_tx_desc(); 564 * it's copied as part of the descriptor chaining. 565 * 566 * So, extract it from ds0. 567 */ 568 keyType = MS(ads->ds_ctl17, AR_encr_type); 569 570 return ar9300_fill_tx_desc(ah, ds, bufListPtr, segLenPtr, descId, 571 qid, keyType, firstSeg, lastSeg, ds0); 572} 573 574HAL_BOOL 575ar9300_freebsd_get_tx_completion_rates(struct ath_hal *ah, 576 const struct ath_desc *ds0, int *rates, int *tries) 577{ 578 579 ath_hal_printf(ah, "%s: called\n", __func__); 580 return AH_FALSE; /* XXX for now */ 581} 582 583 584/* 585 * 802.11n TX descriptor wrappers 586 */ 587void 588ar9300_freebsd_set_11n_rate_scenario(struct ath_hal *ah, struct ath_desc *ds, 589 u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], 590 u_int nseries, u_int flags) 591{ 592 593 /* lastds=NULL, rtscts_duration is 0, smart antenna is 0 */ 594 ar9300_set_11n_rate_scenario(ah, (void *) ds, (void *)ds, durUpdateEn, 595 rtsctsRate, 0, series, nseries, flags, 0); 596} 597 598/* chaintxdesc */ 599HAL_BOOL 600ar9300_freebsd_chain_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 601 HAL_DMA_ADDR *bufLenList, uint32_t *segLenList, 602 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int keyIx, 603 HAL_CIPHER cipher, uint8_t numDelims, 604 HAL_BOOL firstSeg, HAL_BOOL lastSeg, HAL_BOOL lastAggr) 605{ 606 607 ath_hal_printf(ah, "%s: called\n", __func__); 608 return AH_FALSE; 609} 610 611/* setupfirsttxdesc */ 612HAL_BOOL 613ar9300_freebsd_setup_first_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 614 u_int aggrLen, u_int flags, u_int txPower, u_int txRate0, 615 u_int txTries0, u_int antMode, u_int rtsctsRate, u_int rtsctsDuration) 616{ 617 618 ath_hal_printf(ah, "%s: called\n", __func__); 619 return AH_FALSE; 620} 621 622/* setuplasttxdesc */ 623/* 624 * This gets called but for now let's not log anything; 625 * it's only used to update the rate control information. 626 */ 627HAL_BOOL 628ar9300_freebsd_setup_last_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 629 const struct ath_desc *ds0) 630{ 631 632// ath_hal_printf(ah, "%s: called\n", __func__); 633 return AH_FALSE; 634} 635 636void 637ar9300_freebsd_setup_11n_desc(struct ath_hal *ah, void *ds, u_int pktLen, 638 HAL_PKT_TYPE type, u_int txPower, u_int keyIx, u_int flags) 639{ 640 ath_hal_printf(ah, "%s: called\n", __func__); 641#if 0 642 struct ath_hal_9300 *ahp = AH9300(ah); 643 644 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 645 646 if (keyIx != HAL_TXKEYIX_INVALID) 647 keyType = ahp->ah_keytype[keyIx]; 648 649 /* XXX bounds check keyix */ 650 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 651 keyType, flags); 652#endif 653} 654 655HAL_STATUS 656ar9300_freebsd_proc_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 657 struct ath_tx_status *ts) 658{ 659 660 return ar9300_proc_tx_desc(ah, ts); 661} 662 663void 664ar9300_freebsd_beacon_init(struct ath_hal *ah, uint32_t next_beacon, 665 uint32_t beacon_period) 666{ 667 668 ar9300_beacon_init(ah, next_beacon, beacon_period, 0, 669 AH_PRIVATE(ah)->ah_opmode); 670} 671 672HAL_BOOL 673ar9300_freebsd_get_mib_cycle_counts(struct ath_hal *ah, 674 HAL_SURVEY_SAMPLE *hs) 675 676{ 677 678 return (AH_FALSE); 679} 680 681HAL_BOOL 682ar9300_freebsd_get_dfs_default_thresh(struct ath_hal *ah, 683 HAL_PHYERR_PARAM *pe) 684{ 685 686 /* XXX not yet */ 687 688 return (AH_FALSE); 689} 690 691/* 692 * Clear multicast filter by index - from FreeBSD ar5212_recv.c 693 */ 694static HAL_BOOL 695ar9300ClrMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 696{ 697 uint32_t val; 698 699 if (ix >= 64) 700 return (AH_FALSE); 701 if (ix >= 32) { 702 val = OS_REG_READ(ah, AR_MCAST_FIL1); 703 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val &~ (1<<(ix-32)))); 704 } else { 705 val = OS_REG_READ(ah, AR_MCAST_FIL0); 706 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val &~ (1<<ix))); 707 } 708 return AH_TRUE; 709} 710 711/* 712 * Set multicast filter by index - from FreeBSD ar5212_recv.c 713 */ 714static HAL_BOOL 715ar9300SetMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 716{ 717 uint32_t val; 718 719 if (ix >= 64) 720 return (AH_FALSE); 721 if (ix >= 32) { 722 val = OS_REG_READ(ah, AR_MCAST_FIL1); 723 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val | (1<<(ix-32)))); 724 } else { 725 val = OS_REG_READ(ah, AR_MCAST_FIL0); 726 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val | (1<<ix))); 727 } 728 return (AH_TRUE); 729} 730 731#define TU_TO_USEC(_tu) ((_tu) << 10) 732#define ONE_EIGHTH_TU_TO_USEC(_tu8) ((_tu8) << 7) 733 734/* 735 * Initializes all of the hardware registers used to 736 * send beacons. Note that for station operation the 737 * driver calls ar9300_set_sta_beacon_timers instead. 738 */ 739static void 740ar9300_beacon_set_beacon_timers(struct ath_hal *ah, 741 const HAL_BEACON_TIMERS *bt) 742{ 743 uint32_t bperiod; 744 745#if 0 746 HALASSERT(opmode == HAL_M_IBSS || opmode == HAL_M_HOSTAP); 747 if (opmode == HAL_M_IBSS) { 748 OS_REG_SET_BIT(ah, AR_TXCFG, AR_TXCFG_ADHOC_BEACON_ATIM_TX_POLICY); 749 } 750#endif 751 752 /* XXX TODO: should migrate the HAL code to always use ONE_EIGHTH_TU */ 753 OS_REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bt->bt_nexttbtt)); 754 OS_REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextdba)); 755 OS_REG_WRITE(ah, AR_NEXT_SWBA, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextswba)); 756 OS_REG_WRITE(ah, AR_NEXT_NDP_TIMER, TU_TO_USEC(bt->bt_nextatim)); 757 758 bperiod = TU_TO_USEC(bt->bt_intval & HAL_BEACON_PERIOD); 759 /* XXX TODO! */ 760// ahp->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD; 761 OS_REG_WRITE(ah, AR_BEACON_PERIOD, bperiod); 762 OS_REG_WRITE(ah, AR_DMA_BEACON_PERIOD, bperiod); 763 OS_REG_WRITE(ah, AR_SWBA_PERIOD, bperiod); 764 OS_REG_WRITE(ah, AR_NDP_PERIOD, bperiod); 765 766 /* 767 * Reset TSF if required. 768 */ 769 if (bt->bt_intval & HAL_BEACON_RESET_TSF) 770 ar9300_reset_tsf(ah); 771 772 /* enable timers */ 773 /* NB: flags == 0 handled specially for backwards compatibility */ 774 OS_REG_SET_BIT(ah, AR_TIMER_MODE, 775 bt->bt_flags != 0 ? bt->bt_flags : 776 AR_TBTT_TIMER_EN | AR_DBA_TIMER_EN | AR_SWBA_TIMER_EN); 777} 778 779 780/* 781 * RF attach stubs 782 */ 783 784static HAL_BOOL 785rf9330_attach(struct ath_hal *ah, HAL_STATUS *status) 786{ 787 788 (*status) = HAL_EINVAL; 789 return (AH_FALSE); 790} 791 792static HAL_BOOL 793rf9330_probe(struct ath_hal *ah) 794{ 795 return (AH_FALSE); 796} 797 798AH_RF(RF9330, rf9330_probe, rf9330_attach); 799
| 317 HAL_STATUS *status) 318{ 319 HAL_BOOL r; 320 HAL_HT_MACMODE macmode; 321 struct ath_hal_private *ap = AH_PRIVATE(ah); 322 323 macmode = 324 IEEE80211_IS_CHAN_HT40(chan) ? 325 HAL_HT_MACMODE_2040 : HAL_HT_MACMODE_20; 326 327 r = ar9300_reset(ah, opmode, chan, macmode, 328 ap->ah_caps.halTxChainMask, 329 ap->ah_caps.halRxChainMask, 330 HAL_HT_EXTPROTSPACING_20, /* always 20Mhz channel spacing */ 331 bChannelChange, 332 status, 333 AH_FALSE); /* XXX should really extend ath_hal_reset() */ 334 335 return (r); 336} 337 338void 339ar9300_config_pcie_freebsd(struct ath_hal *ah, HAL_BOOL restore, 340 HAL_BOOL powerOff) 341{ 342 343 ar9300_config_pci_power_save(ah, restore ? 1 : 0, powerOff ? 1 : 0); 344} 345 346/* 347 * This is a copy from ar9300_eeprom_get(), purely because the FreeBSD 348 * API is very silly and inconsistent. 349 * 350 * The AR93xx HAL doesn't call the eepromGetFlag() function, so this 351 * only occurs for FreeBSD code. 352 * 353 * When I fix this particular API, I'll undo this. 354 */ 355HAL_STATUS 356ar9300_eeprom_get_freebsd(struct ath_hal *ah, int param, void *val) 357{ 358 359 switch (param) { 360 case AR_EEP_FSTCLK_5G: 361 return HAL_OK; 362 default: 363 ath_hal_printf(ah, "%s: called, param=%d\n", 364 __func__, param); 365 return HAL_EIO; 366 } 367} 368 369HAL_BOOL 370ar9300_stop_tx_dma_freebsd(struct ath_hal *ah, u_int q) 371{ 372 373 return ar9300_stop_tx_dma(ah, q, 1000); 374} 375 376void 377ar9300_ani_poll_freebsd(struct ath_hal *ah, 378 const struct ieee80211_channel *chan) 379{ 380 381 HAL_NODE_STATS stats; 382 HAL_ANISTATS anistats; 383 HAL_SURVEY_SAMPLE survey; 384 385 OS_MEMZERO(&stats, sizeof(stats)); 386 OS_MEMZERO(&anistats, sizeof(anistats)); 387 OS_MEMZERO(&survey, sizeof(survey)); 388 389 ar9300_ani_ar_poll(ah, &stats, chan, &anistats); 390 391 /* 392 * If ANI stats are valid, use them to update the 393 * channel survey. 394 */ 395 if (anistats.valid) { 396 survey.cycle_count = anistats.cyclecnt_diff; 397 survey.chan_busy = anistats.rxclr_cnt; 398 survey.ext_chan_busy = anistats.extrxclr_cnt; 399 survey.tx_busy = anistats.txframecnt_diff; 400 survey.rx_busy = anistats.rxframecnt_diff; 401 ath_hal_survey_add_sample(ah, &survey); 402 } 403} 404 405/* 406 * Setup the configuration parameters in the style the AR9300 HAL 407 * wants. 408 */ 409void 410ar9300_config_defaults_freebsd(struct ath_hal *ah, HAL_OPS_CONFIG *ah_config) 411{ 412 413 /* Until FreeBSD's HAL does this by default - just copy */ 414 OS_MEMCPY(&ah->ah_config, ah_config, sizeof(HAL_OPS_CONFIG)); 415 ah->ah_config.ath_hal_enable_ani = AH_TRUE; 416} 417 418HAL_BOOL 419ar9300_stop_dma_receive_freebsd(struct ath_hal *ah) 420{ 421 422 return ar9300_stop_dma_receive(ah, 1000); 423} 424 425HAL_BOOL 426ar9300_get_pending_interrupts_freebsd(struct ath_hal *ah, HAL_INT *masked) 427{ 428 429 /* Non-MSI, so no MSI vector; and 'nortc' = 0 */ 430 return ar9300_get_pending_interrupts(ah, masked, HAL_INT_LINE, 0, 0); 431} 432 433HAL_INT 434ar9300_set_interrupts_freebsd(struct ath_hal *ah, HAL_INT ints) 435{ 436 437 /* nortc = 0 */ 438 return ar9300_set_interrupts(ah, ints, 0); 439} 440 441HAL_BOOL 442ar9300_per_calibration_freebsd(struct ath_hal *ah, 443 struct ieee80211_channel *chan, u_int rxchainmask, HAL_BOOL long_cal, 444 HAL_BOOL *isCalDone) 445{ 446 /* XXX fake scheduled calibrations for now */ 447 u_int32_t sched_cals = 0xfffffff; 448 449 return ar9300_calibration(ah, chan, 450 AH_PRIVATE(ah)->ah_caps.halRxChainMask, 451 long_cal, 452 isCalDone, 453 0, /* is_scan */ 454 &sched_cals); 455} 456 457HAL_BOOL 458ar9300_reset_cal_valid_freebsd(struct ath_hal *ah, 459 const struct ieee80211_channel *chan) 460{ 461 462 HAL_BOOL is_cal_done = AH_TRUE; 463 464 ar9300_reset_cal_valid(ah, chan, &is_cal_done, 0xffffffff); 465 return (is_cal_done); 466} 467 468 469void 470ar9300_start_pcu_receive_freebsd(struct ath_hal *ah) 471{ 472 473 /* is_scanning flag == NULL */ 474 ar9300_start_pcu_receive(ah, AH_FALSE); 475} 476 477/* 478 * FreeBSD will just pass in the descriptor value as 'pa'. 479 * The Atheros HAL treats 'pa' as the physical address of the RX 480 * descriptor and 'bufaddr' as the physical address of the RX buffer. 481 * I'm not sure why they didn't collapse them - the AR9300 RX descriptor 482 * routine doesn't check 'pa'. 483 */ 484HAL_STATUS 485ar9300_proc_rx_desc_freebsd(struct ath_hal *ah, struct ath_desc *ds, 486 uint32_t pa, struct ath_desc *ds_next, uint64_t tsf, 487 struct ath_rx_status *rxs) 488{ 489 490 return (ar9300_proc_rx_desc_fast(ah, ds, 0, ds_next, rxs, 491 (void *) ds)); 492} 493 494void 495ar9300_ani_rxmonitor_freebsd(struct ath_hal *ah, const HAL_NODE_STATS *stats, 496 const struct ieee80211_channel *chan) 497{ 498 499} 500 501void 502ar9300_freebsd_get_desc_link(struct ath_hal *ah, void *ds, uint32_t *link) 503{ 504 struct ar9300_txc *ads = AR9300TXC(ds); 505 506 (*link) = ads->ds_link; 507} 508 509/* 510 * TX descriptor field setting wrappers - eek. 511 */ 512 513 514HAL_BOOL 515ar9300_freebsd_setup_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 516 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower, 517 u_int txRate0, u_int txTries0, u_int keyIx, u_int antMode, u_int flags, 518 u_int rtsctsRate, u_int rtsCtsDuration, u_int compicvLen, 519 u_int compivLen, u_int comp) 520{ 521 struct ath_hal_9300 *ahp = AH9300(ah); 522 523 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 524 525 if (keyIx != HAL_TXKEYIX_INVALID) 526 keyType = ahp->ah_keytype[keyIx]; 527 528 /* XXX bounds check keyix */ 529 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 530 keyType, flags); 531 532 return AH_TRUE; 533} 534 535HAL_BOOL 536ar9300_freebsd_setup_x_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 537 u_int txRate1, u_int txTries1, 538 u_int txRate2, u_int txTries2, 539 u_int txRate3, u_int txTries3) 540{ 541 542#if 0 543 ath_hal_printf(ah, "%s: called, 0x%x/%d, 0x%x/%d, 0x%x/%d\n", 544 __func__, 545 txRate1, txTries1, 546 txRate2, txTries2, 547 txRate3, txTries3); 548#endif 549 550 /* XXX should only be called during probe */ 551 return (AH_TRUE); 552} 553 554HAL_BOOL 555ar9300_freebsd_fill_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 556 HAL_DMA_ADDR *bufListPtr, uint32_t *segLenPtr, u_int descId, u_int qid, 557 HAL_BOOL firstSeg, HAL_BOOL lastSeg, 558 const struct ath_desc *ds0) 559{ 560 HAL_KEY_TYPE keyType = 0; 561 const struct ar9300_txc *ads = AR9300TXC_CONST(ds0); 562 563 /* 564 * FreeBSD's HAL doesn't pass the keytype to fill_tx_desc(); 565 * it's copied as part of the descriptor chaining. 566 * 567 * So, extract it from ds0. 568 */ 569 keyType = MS(ads->ds_ctl17, AR_encr_type); 570 571 return ar9300_fill_tx_desc(ah, ds, bufListPtr, segLenPtr, descId, 572 qid, keyType, firstSeg, lastSeg, ds0); 573} 574 575HAL_BOOL 576ar9300_freebsd_get_tx_completion_rates(struct ath_hal *ah, 577 const struct ath_desc *ds0, int *rates, int *tries) 578{ 579 580 ath_hal_printf(ah, "%s: called\n", __func__); 581 return AH_FALSE; /* XXX for now */ 582} 583 584 585/* 586 * 802.11n TX descriptor wrappers 587 */ 588void 589ar9300_freebsd_set_11n_rate_scenario(struct ath_hal *ah, struct ath_desc *ds, 590 u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], 591 u_int nseries, u_int flags) 592{ 593 594 /* lastds=NULL, rtscts_duration is 0, smart antenna is 0 */ 595 ar9300_set_11n_rate_scenario(ah, (void *) ds, (void *)ds, durUpdateEn, 596 rtsctsRate, 0, series, nseries, flags, 0); 597} 598 599/* chaintxdesc */ 600HAL_BOOL 601ar9300_freebsd_chain_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 602 HAL_DMA_ADDR *bufLenList, uint32_t *segLenList, 603 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int keyIx, 604 HAL_CIPHER cipher, uint8_t numDelims, 605 HAL_BOOL firstSeg, HAL_BOOL lastSeg, HAL_BOOL lastAggr) 606{ 607 608 ath_hal_printf(ah, "%s: called\n", __func__); 609 return AH_FALSE; 610} 611 612/* setupfirsttxdesc */ 613HAL_BOOL 614ar9300_freebsd_setup_first_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 615 u_int aggrLen, u_int flags, u_int txPower, u_int txRate0, 616 u_int txTries0, u_int antMode, u_int rtsctsRate, u_int rtsctsDuration) 617{ 618 619 ath_hal_printf(ah, "%s: called\n", __func__); 620 return AH_FALSE; 621} 622 623/* setuplasttxdesc */ 624/* 625 * This gets called but for now let's not log anything; 626 * it's only used to update the rate control information. 627 */ 628HAL_BOOL 629ar9300_freebsd_setup_last_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 630 const struct ath_desc *ds0) 631{ 632 633// ath_hal_printf(ah, "%s: called\n", __func__); 634 return AH_FALSE; 635} 636 637void 638ar9300_freebsd_setup_11n_desc(struct ath_hal *ah, void *ds, u_int pktLen, 639 HAL_PKT_TYPE type, u_int txPower, u_int keyIx, u_int flags) 640{ 641 ath_hal_printf(ah, "%s: called\n", __func__); 642#if 0 643 struct ath_hal_9300 *ahp = AH9300(ah); 644 645 HAL_KEY_TYPE keyType = 0; /* XXX No padding */ 646 647 if (keyIx != HAL_TXKEYIX_INVALID) 648 keyType = ahp->ah_keytype[keyIx]; 649 650 /* XXX bounds check keyix */ 651 ar9300_set_11n_tx_desc(ah, ds, pktLen, type, txPower, keyIx, 652 keyType, flags); 653#endif 654} 655 656HAL_STATUS 657ar9300_freebsd_proc_tx_desc(struct ath_hal *ah, struct ath_desc *ds, 658 struct ath_tx_status *ts) 659{ 660 661 return ar9300_proc_tx_desc(ah, ts); 662} 663 664void 665ar9300_freebsd_beacon_init(struct ath_hal *ah, uint32_t next_beacon, 666 uint32_t beacon_period) 667{ 668 669 ar9300_beacon_init(ah, next_beacon, beacon_period, 0, 670 AH_PRIVATE(ah)->ah_opmode); 671} 672 673HAL_BOOL 674ar9300_freebsd_get_mib_cycle_counts(struct ath_hal *ah, 675 HAL_SURVEY_SAMPLE *hs) 676 677{ 678 679 return (AH_FALSE); 680} 681 682HAL_BOOL 683ar9300_freebsd_get_dfs_default_thresh(struct ath_hal *ah, 684 HAL_PHYERR_PARAM *pe) 685{ 686 687 /* XXX not yet */ 688 689 return (AH_FALSE); 690} 691 692/* 693 * Clear multicast filter by index - from FreeBSD ar5212_recv.c 694 */ 695static HAL_BOOL 696ar9300ClrMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 697{ 698 uint32_t val; 699 700 if (ix >= 64) 701 return (AH_FALSE); 702 if (ix >= 32) { 703 val = OS_REG_READ(ah, AR_MCAST_FIL1); 704 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val &~ (1<<(ix-32)))); 705 } else { 706 val = OS_REG_READ(ah, AR_MCAST_FIL0); 707 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val &~ (1<<ix))); 708 } 709 return AH_TRUE; 710} 711 712/* 713 * Set multicast filter by index - from FreeBSD ar5212_recv.c 714 */ 715static HAL_BOOL 716ar9300SetMulticastFilterIndex(struct ath_hal *ah, uint32_t ix) 717{ 718 uint32_t val; 719 720 if (ix >= 64) 721 return (AH_FALSE); 722 if (ix >= 32) { 723 val = OS_REG_READ(ah, AR_MCAST_FIL1); 724 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val | (1<<(ix-32)))); 725 } else { 726 val = OS_REG_READ(ah, AR_MCAST_FIL0); 727 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val | (1<<ix))); 728 } 729 return (AH_TRUE); 730} 731 732#define TU_TO_USEC(_tu) ((_tu) << 10) 733#define ONE_EIGHTH_TU_TO_USEC(_tu8) ((_tu8) << 7) 734 735/* 736 * Initializes all of the hardware registers used to 737 * send beacons. Note that for station operation the 738 * driver calls ar9300_set_sta_beacon_timers instead. 739 */ 740static void 741ar9300_beacon_set_beacon_timers(struct ath_hal *ah, 742 const HAL_BEACON_TIMERS *bt) 743{ 744 uint32_t bperiod; 745 746#if 0 747 HALASSERT(opmode == HAL_M_IBSS || opmode == HAL_M_HOSTAP); 748 if (opmode == HAL_M_IBSS) { 749 OS_REG_SET_BIT(ah, AR_TXCFG, AR_TXCFG_ADHOC_BEACON_ATIM_TX_POLICY); 750 } 751#endif 752 753 /* XXX TODO: should migrate the HAL code to always use ONE_EIGHTH_TU */ 754 OS_REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bt->bt_nexttbtt)); 755 OS_REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextdba)); 756 OS_REG_WRITE(ah, AR_NEXT_SWBA, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextswba)); 757 OS_REG_WRITE(ah, AR_NEXT_NDP_TIMER, TU_TO_USEC(bt->bt_nextatim)); 758 759 bperiod = TU_TO_USEC(bt->bt_intval & HAL_BEACON_PERIOD); 760 /* XXX TODO! */ 761// ahp->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD; 762 OS_REG_WRITE(ah, AR_BEACON_PERIOD, bperiod); 763 OS_REG_WRITE(ah, AR_DMA_BEACON_PERIOD, bperiod); 764 OS_REG_WRITE(ah, AR_SWBA_PERIOD, bperiod); 765 OS_REG_WRITE(ah, AR_NDP_PERIOD, bperiod); 766 767 /* 768 * Reset TSF if required. 769 */ 770 if (bt->bt_intval & HAL_BEACON_RESET_TSF) 771 ar9300_reset_tsf(ah); 772 773 /* enable timers */ 774 /* NB: flags == 0 handled specially for backwards compatibility */ 775 OS_REG_SET_BIT(ah, AR_TIMER_MODE, 776 bt->bt_flags != 0 ? bt->bt_flags : 777 AR_TBTT_TIMER_EN | AR_DBA_TIMER_EN | AR_SWBA_TIMER_EN); 778} 779 780 781/* 782 * RF attach stubs 783 */ 784 785static HAL_BOOL 786rf9330_attach(struct ath_hal *ah, HAL_STATUS *status) 787{ 788 789 (*status) = HAL_EINVAL; 790 return (AH_FALSE); 791} 792 793static HAL_BOOL 794rf9330_probe(struct ath_hal *ah) 795{ 796 return (AH_FALSE); 797} 798 799AH_RF(RF9330, rf9330_probe, rf9330_attach); 800
|