diff options
Diffstat (limited to 'drivers/net/wireless/ath9k/xmit.c')
-rw-r--r-- | drivers/net/wireless/ath9k/xmit.c | 163 |
1 files changed, 59 insertions, 104 deletions
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c index baf5cb9d967e..b2d0cca6f4a6 100644 --- a/drivers/net/wireless/ath9k/xmit.c +++ b/drivers/net/wireless/ath9k/xmit.c | |||
@@ -176,25 +176,6 @@ static int get_hw_crypto_keytype(struct sk_buff *skb) | |||
176 | return ATH9K_KEY_TYPE_CLEAR; | 176 | return ATH9K_KEY_TYPE_CLEAR; |
177 | } | 177 | } |
178 | 178 | ||
179 | static void setup_rate_retries(struct ath_softc *sc, struct sk_buff *skb) | ||
180 | { | ||
181 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | ||
182 | struct ieee80211_tx_rate *rates = tx_info->control.rates; | ||
183 | struct ieee80211_hdr *hdr; | ||
184 | __le16 fc; | ||
185 | |||
186 | hdr = (struct ieee80211_hdr *)skb->data; | ||
187 | fc = hdr->frame_control; | ||
188 | |||
189 | if (ieee80211_has_morefrags(fc) || | ||
190 | (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) { | ||
191 | rates[1].count = rates[2].count = rates[3].count = 0; | ||
192 | rates[1].idx = rates[2].idx = rates[3].idx = 0; | ||
193 | /* reset tries but keep rate index */ | ||
194 | rates[0].count = ATH_TXMAXTRY; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | /* Called only when tx aggregation is enabled and HT is supported */ | 179 | /* Called only when tx aggregation is enabled and HT is supported */ |
199 | 180 | ||
200 | static void assign_aggr_tid_seqno(struct sk_buff *skb, | 181 | static void assign_aggr_tid_seqno(struct sk_buff *skb, |
@@ -468,27 +449,23 @@ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
468 | * width - 0 for 20 MHz, 1 for 40 MHz | 449 | * width - 0 for 20 MHz, 1 for 40 MHz |
469 | * half_gi - to use 4us v/s 3.6 us for symbol time | 450 | * half_gi - to use 4us v/s 3.6 us for symbol time |
470 | */ | 451 | */ |
471 | |||
472 | static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, | 452 | static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, |
473 | int width, int half_gi, bool shortPreamble) | 453 | int width, int half_gi, bool shortPreamble) |
474 | { | 454 | { |
475 | const struct ath9k_rate_table *rt = sc->sc_currates; | 455 | struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode]; |
476 | u32 nbits, nsymbits, duration, nsymbols; | 456 | u32 nbits, nsymbits, duration, nsymbols; |
477 | u8 rc; | 457 | u8 rc; |
478 | int streams, pktlen; | 458 | int streams, pktlen; |
479 | 459 | ||
480 | pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen; | 460 | pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen; |
481 | rc = rt->info[rix].rateCode; | 461 | rc = rate_table->info[rix].ratecode; |
482 | 462 | ||
483 | /* | 463 | /* for legacy rates, use old function to compute packet duration */ |
484 | * for legacy rates, use old function to compute packet duration | ||
485 | */ | ||
486 | if (!IS_HT_RATE(rc)) | 464 | if (!IS_HT_RATE(rc)) |
487 | return ath9k_hw_computetxtime(sc->sc_ah, rt, pktlen, rix, | 465 | return ath9k_hw_computetxtime(sc->sc_ah, rate_table, pktlen, |
488 | shortPreamble); | 466 | rix, shortPreamble); |
489 | /* | 467 | |
490 | * find number of symbols: PLCP + data | 468 | /* find number of symbols: PLCP + data */ |
491 | */ | ||
492 | nbits = (pktlen << 3) + OFDM_PLCP_BITS; | 469 | nbits = (pktlen << 3) + OFDM_PLCP_BITS; |
493 | nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width]; | 470 | nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width]; |
494 | nsymbols = (nbits + nsymbits - 1) / nsymbits; | 471 | nsymbols = (nbits + nsymbits - 1) / nsymbits; |
@@ -498,9 +475,7 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, | |||
498 | else | 475 | else |
499 | duration = SYMBOL_TIME_HALFGI(nsymbols); | 476 | duration = SYMBOL_TIME_HALFGI(nsymbols); |
500 | 477 | ||
501 | /* | 478 | /* addup duration for legacy/ht training and signal fields */ |
502 | * addup duration for legacy/ht training and signal fields | ||
503 | */ | ||
504 | streams = HT_RC_2_STREAMS(rc); | 479 | streams = HT_RC_2_STREAMS(rc); |
505 | duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); | 480 | duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); |
506 | 481 | ||
@@ -512,114 +487,104 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, | |||
512 | static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) | 487 | static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) |
513 | { | 488 | { |
514 | struct ath_hal *ah = sc->sc_ah; | 489 | struct ath_hal *ah = sc->sc_ah; |
515 | const struct ath9k_rate_table *rt; | 490 | struct ath_rate_table *rt; |
516 | struct ath_desc *ds = bf->bf_desc; | 491 | struct ath_desc *ds = bf->bf_desc; |
517 | struct ath_desc *lastds = bf->bf_lastbf->bf_desc; | 492 | struct ath_desc *lastds = bf->bf_lastbf->bf_desc; |
518 | struct ath9k_11n_rate_series series[4]; | 493 | struct ath9k_11n_rate_series series[4]; |
519 | int i, flags, rtsctsena = 0; | ||
520 | u32 ctsduration = 0; | ||
521 | u8 rix = 0, cix, ctsrate = 0; | ||
522 | struct ath_node *an = NULL; | 494 | struct ath_node *an = NULL; |
523 | struct sk_buff *skb; | 495 | struct sk_buff *skb; |
524 | struct ieee80211_tx_info *tx_info; | 496 | struct ieee80211_tx_info *tx_info; |
525 | struct ieee80211_tx_rate *rates; | 497 | struct ieee80211_tx_rate *rates; |
498 | struct ieee80211_hdr *hdr; | ||
499 | int i, flags, rtsctsena = 0; | ||
500 | u32 ctsduration = 0; | ||
501 | u8 rix = 0, cix, ctsrate = 0; | ||
502 | __le16 fc; | ||
503 | |||
504 | memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4); | ||
526 | 505 | ||
527 | skb = (struct sk_buff *)bf->bf_mpdu; | 506 | skb = (struct sk_buff *)bf->bf_mpdu; |
507 | hdr = (struct ieee80211_hdr *)skb->data; | ||
508 | fc = hdr->frame_control; | ||
528 | tx_info = IEEE80211_SKB_CB(skb); | 509 | tx_info = IEEE80211_SKB_CB(skb); |
529 | rates = tx_info->rate_driver_data[0]; | 510 | rates = tx_info->control.rates; |
530 | 511 | ||
531 | if (tx_info->control.sta) | 512 | if (tx_info->control.sta) |
532 | an = (struct ath_node *)tx_info->control.sta->drv_priv; | 513 | an = (struct ath_node *)tx_info->control.sta->drv_priv; |
533 | 514 | ||
534 | /* | 515 | if (ieee80211_has_morefrags(fc) || |
535 | * get the cix for the lowest valid rix. | 516 | (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) { |
536 | */ | 517 | rates[1].count = rates[2].count = rates[3].count = 0; |
537 | rt = sc->sc_currates; | 518 | rates[1].idx = rates[2].idx = rates[3].idx = 0; |
519 | rates[0].count = ATH_TXMAXTRY; | ||
520 | } | ||
521 | |||
522 | /* get the cix for the lowest valid rix */ | ||
523 | rt = sc->hw_rate_table[sc->sc_curmode]; | ||
538 | for (i = 3; i >= 0; i--) { | 524 | for (i = 3; i >= 0; i--) { |
539 | if (rates[i].count) { | 525 | if (rates[i].count && (rates[i].idx >= 0)) { |
540 | rix = rates[i].idx; | 526 | rix = rates[i].idx; |
541 | break; | 527 | break; |
542 | } | 528 | } |
543 | } | 529 | } |
530 | |||
544 | flags = (bf->bf_flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)); | 531 | flags = (bf->bf_flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)); |
545 | cix = rt->info[rix].controlRate; | 532 | cix = rt->info[rix].ctrl_rate; |
546 | 533 | ||
547 | /* | 534 | /* |
548 | * If 802.11g protection is enabled, determine whether | 535 | * If 802.11g protection is enabled, determine whether to use RTS/CTS or |
549 | * to use RTS/CTS or just CTS. Note that this is only | 536 | * just CTS. Note that this is only done for OFDM/HT unicast frames. |
550 | * done for OFDM/HT unicast frames. | ||
551 | */ | 537 | */ |
552 | if (sc->sc_protmode != PROT_M_NONE && | 538 | if (sc->sc_protmode != PROT_M_NONE && !(bf->bf_flags & ATH9K_TXDESC_NOACK) |
553 | (rt->info[rix].phy == PHY_OFDM || | 539 | && (rt->info[rix].phy == WLAN_PHY_OFDM || |
554 | rt->info[rix].phy == PHY_HT) && | 540 | WLAN_RC_PHY_HT(rt->info[rix].phy))) { |
555 | (bf->bf_flags & ATH9K_TXDESC_NOACK) == 0) { | ||
556 | if (sc->sc_protmode == PROT_M_RTSCTS) | 541 | if (sc->sc_protmode == PROT_M_RTSCTS) |
557 | flags = ATH9K_TXDESC_RTSENA; | 542 | flags = ATH9K_TXDESC_RTSENA; |
558 | else if (sc->sc_protmode == PROT_M_CTSONLY) | 543 | else if (sc->sc_protmode == PROT_M_CTSONLY) |
559 | flags = ATH9K_TXDESC_CTSENA; | 544 | flags = ATH9K_TXDESC_CTSENA; |
560 | 545 | ||
561 | cix = rt->info[sc->sc_protrix].controlRate; | 546 | cix = rt->info[sc->sc_protrix].ctrl_rate; |
562 | rtsctsena = 1; | 547 | rtsctsena = 1; |
563 | } | 548 | } |
564 | 549 | ||
565 | /* For 11n, the default behavior is to enable RTS for | 550 | /* For 11n, the default behavior is to enable RTS for hw retried frames. |
566 | * hw retried frames. We enable the global flag here and | 551 | * We enable the global flag here and let rate series flags determine |
567 | * let rate series flags determine which rates will actually | 552 | * which rates will actually use RTS. |
568 | * use RTS. | ||
569 | */ | 553 | */ |
570 | if ((ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) && bf_isdata(bf)) { | 554 | if ((ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) && bf_isdata(bf)) { |
571 | /* | 555 | /* 802.11g protection not needed, use our default behavior */ |
572 | * 802.11g protection not needed, use our default behavior | ||
573 | */ | ||
574 | if (!rtsctsena) | 556 | if (!rtsctsena) |
575 | flags = ATH9K_TXDESC_RTSENA; | 557 | flags = ATH9K_TXDESC_RTSENA; |
576 | } | 558 | } |
577 | 559 | ||
578 | /* | 560 | /* Set protection if aggregate protection on */ |
579 | * Set protection if aggregate protection on | ||
580 | */ | ||
581 | if (sc->sc_config.ath_aggr_prot && | 561 | if (sc->sc_config.ath_aggr_prot && |
582 | (!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) { | 562 | (!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) { |
583 | flags = ATH9K_TXDESC_RTSENA; | 563 | flags = ATH9K_TXDESC_RTSENA; |
584 | cix = rt->info[sc->sc_protrix].controlRate; | 564 | cix = rt->info[sc->sc_protrix].ctrl_rate; |
585 | rtsctsena = 1; | 565 | rtsctsena = 1; |
586 | } | 566 | } |
587 | 567 | ||
588 | /* | 568 | /* For AR5416 - RTS cannot be followed by a frame larger than 8K */ |
589 | * For AR5416 - RTS cannot be followed by a frame larger than 8K. | 569 | if (bf_isaggr(bf) && (bf->bf_al > ah->ah_caps.rts_aggr_limit)) |
590 | */ | ||
591 | if (bf_isaggr(bf) && (bf->bf_al > ah->ah_caps.rts_aggr_limit)) { | ||
592 | /* | ||
593 | * Ensure that in the case of SM Dynamic power save | ||
594 | * while we are bursting the second aggregate the | ||
595 | * RTS is cleared. | ||
596 | */ | ||
597 | flags &= ~(ATH9K_TXDESC_RTSENA); | 570 | flags &= ~(ATH9K_TXDESC_RTSENA); |
598 | } | ||
599 | |||
600 | /* | ||
601 | * CTS transmit rate is derived from the transmit rate | ||
602 | * by looking in the h/w rate table. We must also factor | ||
603 | * in whether or not a short preamble is to be used. | ||
604 | * NB: cix is set above where RTS/CTS is enabled | ||
605 | */ | ||
606 | BUG_ON(cix == 0xff); | ||
607 | ctsrate = rt->info[cix].rateCode | | ||
608 | (bf_isshpreamble(bf) ? rt->info[cix].shortPreamble : 0); | ||
609 | 571 | ||
610 | /* | 572 | /* |
611 | * Setup HAL rate series | 573 | * CTS transmit rate is derived from the transmit rate by looking in the |
574 | * h/w rate table. We must also factor in whether or not a short | ||
575 | * preamble is to be used. NB: cix is set above where RTS/CTS is enabled | ||
612 | */ | 576 | */ |
613 | memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4); | 577 | ctsrate = rt->info[cix].ratecode | |
578 | (bf_isshpreamble(bf) ? rt->info[cix].short_preamble : 0); | ||
614 | 579 | ||
615 | for (i = 0; i < 4; i++) { | 580 | for (i = 0; i < 4; i++) { |
616 | if (!rates[i].count) | 581 | if (!rates[i].count || (rates[i].idx < 0)) |
617 | continue; | 582 | continue; |
618 | 583 | ||
619 | rix = rates[i].idx; | 584 | rix = rates[i].idx; |
620 | 585 | ||
621 | series[i].Rate = rt->info[rix].rateCode | | 586 | series[i].Rate = rt->info[rix].ratecode | |
622 | (bf_isshpreamble(bf) ? rt->info[rix].shortPreamble : 0); | 587 | (bf_isshpreamble(bf) ? rt->info[rix].short_preamble : 0); |
623 | 588 | ||
624 | series[i].Tries = rates[i].count; | 589 | series[i].Tries = rates[i].count; |
625 | 590 | ||
@@ -645,13 +610,9 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) | |||
645 | series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; | 610 | series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; |
646 | } | 611 | } |
647 | 612 | ||
648 | /* | 613 | /* set dur_update_en for l-sig computation except for PS-Poll frames */ |
649 | * set dur_update_en for l-sig computation except for PS-Poll frames | 614 | ath9k_hw_set11n_ratescenario(ah, ds, lastds, !bf_ispspoll(bf), |
650 | */ | 615 | ctsrate, ctsduration, |
651 | ath9k_hw_set11n_ratescenario(ah, ds, lastds, | ||
652 | !bf_ispspoll(bf), | ||
653 | ctsrate, | ||
654 | ctsduration, | ||
655 | series, 4, flags); | 616 | series, 4, flags); |
656 | 617 | ||
657 | if (sc->sc_config.ath_aggr_prot && flags) | 618 | if (sc->sc_config.ath_aggr_prot && flags) |
@@ -662,7 +623,6 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) | |||
662 | * Function to send a normal HT (non-AMPDU) frame | 623 | * Function to send a normal HT (non-AMPDU) frame |
663 | * NB: must be called with txq lock held | 624 | * NB: must be called with txq lock held |
664 | */ | 625 | */ |
665 | |||
666 | static int ath_tx_send_normal(struct ath_softc *sc, | 626 | static int ath_tx_send_normal(struct ath_softc *sc, |
667 | struct ath_txq *txq, | 627 | struct ath_txq *txq, |
668 | struct ath_atx_tid *tid, | 628 | struct ath_atx_tid *tid, |
@@ -1256,7 +1216,6 @@ static u32 ath_lookup_rate(struct ath_softc *sc, | |||
1256 | struct ath_atx_tid *tid) | 1216 | struct ath_atx_tid *tid) |
1257 | { | 1217 | { |
1258 | struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode]; | 1218 | struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode]; |
1259 | const struct ath9k_rate_table *rt = sc->sc_currates; | ||
1260 | struct sk_buff *skb; | 1219 | struct sk_buff *skb; |
1261 | struct ieee80211_tx_info *tx_info; | 1220 | struct ieee80211_tx_info *tx_info; |
1262 | struct ieee80211_tx_rate *rates; | 1221 | struct ieee80211_tx_rate *rates; |
@@ -1280,7 +1239,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc, | |||
1280 | 1239 | ||
1281 | for (i = 0; i < 4; i++) { | 1240 | for (i = 0; i < 4; i++) { |
1282 | if (rates[i].count) { | 1241 | if (rates[i].count) { |
1283 | if (rt->info[rates[i].idx].phy != PHY_HT) { | 1242 | if (!WLAN_RC_PHY_HT(rate_table->info[rates[i].idx].phy)) { |
1284 | legacy = 1; | 1243 | legacy = 1; |
1285 | break; | 1244 | break; |
1286 | } | 1245 | } |
@@ -1325,7 +1284,7 @@ static int ath_compute_num_delims(struct ath_softc *sc, | |||
1325 | struct ath_buf *bf, | 1284 | struct ath_buf *bf, |
1326 | u16 frmlen) | 1285 | u16 frmlen) |
1327 | { | 1286 | { |
1328 | const struct ath9k_rate_table *rt = sc->sc_currates; | 1287 | struct ath_rate_table *rt = sc->hw_rate_table[sc->sc_curmode]; |
1329 | struct sk_buff *skb = bf->bf_mpdu; | 1288 | struct sk_buff *skb = bf->bf_mpdu; |
1330 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 1289 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1331 | u32 nsymbits, nsymbols, mpdudensity; | 1290 | u32 nsymbits, nsymbols, mpdudensity; |
@@ -1362,7 +1321,7 @@ static int ath_compute_num_delims(struct ath_softc *sc, | |||
1362 | 1321 | ||
1363 | rix = tx_info->control.rates[0].idx; | 1322 | rix = tx_info->control.rates[0].idx; |
1364 | flags = tx_info->control.rates[0].flags; | 1323 | flags = tx_info->control.rates[0].flags; |
1365 | rc = rt->info[rix].rateCode; | 1324 | rc = rt->info[rix].ratecode; |
1366 | width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0; | 1325 | width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0; |
1367 | half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0; | 1326 | half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0; |
1368 | 1327 | ||
@@ -1713,10 +1672,6 @@ static void ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf, | |||
1713 | bf->bf_keyix = ATH9K_TXKEYIX_INVALID; | 1672 | bf->bf_keyix = ATH9K_TXKEYIX_INVALID; |
1714 | } | 1673 | } |
1715 | 1674 | ||
1716 | /* Rate series */ | ||
1717 | |||
1718 | setup_rate_retries(sc, skb); | ||
1719 | |||
1720 | /* Assign seqno, tidno */ | 1675 | /* Assign seqno, tidno */ |
1721 | 1676 | ||
1722 | if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR)) | 1677 | if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR)) |