diff options
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r-- | net/mac80211/tx.c | 841 |
1 files changed, 419 insertions, 422 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index aecec2a72b08..1ad9e664f287 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -91,11 +91,12 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr, | |||
91 | int next_frag_len) | 91 | int next_frag_len) |
92 | { | 92 | { |
93 | int rate, mrate, erp, dur, i; | 93 | int rate, mrate, erp, dur, i; |
94 | struct ieee80211_rate *txrate = tx->rate; | 94 | struct ieee80211_rate *txrate; |
95 | struct ieee80211_local *local = tx->local; | 95 | struct ieee80211_local *local = tx->local; |
96 | struct ieee80211_supported_band *sband; | 96 | struct ieee80211_supported_band *sband; |
97 | 97 | ||
98 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 98 | sband = local->hw.wiphy->bands[tx->channel->band]; |
99 | txrate = &sband->bitrates[tx->rate_idx]; | ||
99 | 100 | ||
100 | erp = 0; | 101 | erp = 0; |
101 | if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) | 102 | if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) |
@@ -212,18 +213,6 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr, | |||
212 | return dur; | 213 | return dur; |
213 | } | 214 | } |
214 | 215 | ||
215 | static inline int __ieee80211_queue_stopped(const struct ieee80211_local *local, | ||
216 | int queue) | ||
217 | { | ||
218 | return test_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]); | ||
219 | } | ||
220 | |||
221 | static inline int __ieee80211_queue_pending(const struct ieee80211_local *local, | ||
222 | int queue) | ||
223 | { | ||
224 | return test_bit(IEEE80211_LINK_STATE_PENDING, &local->state[queue]); | ||
225 | } | ||
226 | |||
227 | static int inline is_ieee80211_device(struct net_device *dev, | 216 | static int inline is_ieee80211_device(struct net_device *dev, |
228 | struct net_device *master) | 217 | struct net_device *master) |
229 | { | 218 | { |
@@ -237,12 +226,12 @@ static ieee80211_tx_result | |||
237 | ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | 226 | ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) |
238 | { | 227 | { |
239 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 228 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
240 | struct sk_buff *skb = tx->skb; | 229 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
241 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
242 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 230 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
231 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
243 | u32 sta_flags; | 232 | u32 sta_flags; |
244 | 233 | ||
245 | if (unlikely(tx->flags & IEEE80211_TX_INJECTED)) | 234 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) |
246 | return TX_CONTINUE; | 235 | return TX_CONTINUE; |
247 | 236 | ||
248 | if (unlikely(tx->local->sta_sw_scanning) && | 237 | if (unlikely(tx->local->sta_sw_scanning) && |
@@ -347,6 +336,8 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
347 | static ieee80211_tx_result | 336 | static ieee80211_tx_result |
348 | ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | 337 | ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) |
349 | { | 338 | { |
339 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
340 | |||
350 | /* | 341 | /* |
351 | * broadcast/multicast frame | 342 | * broadcast/multicast frame |
352 | * | 343 | * |
@@ -382,7 +373,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
382 | } | 373 | } |
383 | 374 | ||
384 | /* buffered in hardware */ | 375 | /* buffered in hardware */ |
385 | tx->control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM; | 376 | info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; |
386 | 377 | ||
387 | return TX_CONTINUE; | 378 | return TX_CONTINUE; |
388 | } | 379 | } |
@@ -391,6 +382,7 @@ static ieee80211_tx_result | |||
391 | ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | 382 | ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) |
392 | { | 383 | { |
393 | struct sta_info *sta = tx->sta; | 384 | struct sta_info *sta = tx->sta; |
385 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
394 | u32 staflags; | 386 | u32 staflags; |
395 | DECLARE_MAC_BUF(mac); | 387 | DECLARE_MAC_BUF(mac); |
396 | 388 | ||
@@ -403,7 +395,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
403 | 395 | ||
404 | if (unlikely((staflags & WLAN_STA_PS) && | 396 | if (unlikely((staflags & WLAN_STA_PS) && |
405 | !(staflags & WLAN_STA_PSPOLL))) { | 397 | !(staflags & WLAN_STA_PSPOLL))) { |
406 | struct ieee80211_tx_packet_data *pkt_data; | ||
407 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 398 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
408 | printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " | 399 | printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " |
409 | "before %d)\n", | 400 | "before %d)\n", |
@@ -427,8 +418,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
427 | if (skb_queue_empty(&sta->ps_tx_buf)) | 418 | if (skb_queue_empty(&sta->ps_tx_buf)) |
428 | sta_info_set_tim_bit(sta); | 419 | sta_info_set_tim_bit(sta); |
429 | 420 | ||
430 | pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb; | 421 | info->control.jiffies = jiffies; |
431 | pkt_data->jiffies = jiffies; | ||
432 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); | 422 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); |
433 | return TX_QUEUED; | 423 | return TX_QUEUED; |
434 | } | 424 | } |
@@ -460,17 +450,18 @@ static ieee80211_tx_result | |||
460 | ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | 450 | ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) |
461 | { | 451 | { |
462 | struct ieee80211_key *key; | 452 | struct ieee80211_key *key; |
453 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
463 | u16 fc = tx->fc; | 454 | u16 fc = tx->fc; |
464 | 455 | ||
465 | if (unlikely(tx->control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) | 456 | if (unlikely(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) |
466 | tx->key = NULL; | 457 | tx->key = NULL; |
467 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) | 458 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) |
468 | tx->key = key; | 459 | tx->key = key; |
469 | else if ((key = rcu_dereference(tx->sdata->default_key))) | 460 | else if ((key = rcu_dereference(tx->sdata->default_key))) |
470 | tx->key = key; | 461 | tx->key = key; |
471 | else if (tx->sdata->drop_unencrypted && | 462 | else if (tx->sdata->drop_unencrypted && |
472 | !(tx->control->flags & IEEE80211_TXCTL_EAPOL_FRAME) && | 463 | !(info->flags & IEEE80211_TX_CTL_EAPOL_FRAME) && |
473 | !(tx->flags & IEEE80211_TX_INJECTED)) { | 464 | !(info->flags & IEEE80211_TX_CTL_INJECTED)) { |
474 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); | 465 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); |
475 | return TX_DROP; | 466 | return TX_DROP; |
476 | } else | 467 | } else |
@@ -499,7 +490,156 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
499 | } | 490 | } |
500 | 491 | ||
501 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 492 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
502 | tx->control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 493 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
494 | |||
495 | return TX_CONTINUE; | ||
496 | } | ||
497 | |||
498 | static ieee80211_tx_result | ||
499 | ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | ||
500 | { | ||
501 | struct rate_selection rsel; | ||
502 | struct ieee80211_supported_band *sband; | ||
503 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
504 | |||
505 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | ||
506 | |||
507 | if (likely(tx->rate_idx < 0)) { | ||
508 | rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); | ||
509 | tx->rate_idx = rsel.rate_idx; | ||
510 | if (unlikely(rsel.probe_idx >= 0)) { | ||
511 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | ||
512 | tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG; | ||
513 | info->control.alt_retry_rate_idx = tx->rate_idx; | ||
514 | tx->rate_idx = rsel.probe_idx; | ||
515 | } else | ||
516 | info->control.alt_retry_rate_idx = -1; | ||
517 | |||
518 | if (unlikely(tx->rate_idx < 0)) | ||
519 | return TX_DROP; | ||
520 | } else | ||
521 | info->control.alt_retry_rate_idx = -1; | ||
522 | |||
523 | if (tx->sdata->bss_conf.use_cts_prot && | ||
524 | (tx->flags & IEEE80211_TX_FRAGMENTED) && (rsel.nonerp_idx >= 0)) { | ||
525 | tx->last_frag_rate_idx = tx->rate_idx; | ||
526 | if (rsel.probe_idx >= 0) | ||
527 | tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG; | ||
528 | else | ||
529 | tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG; | ||
530 | tx->rate_idx = rsel.nonerp_idx; | ||
531 | info->tx_rate_idx = rsel.nonerp_idx; | ||
532 | info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; | ||
533 | } else { | ||
534 | tx->last_frag_rate_idx = tx->rate_idx; | ||
535 | info->tx_rate_idx = tx->rate_idx; | ||
536 | } | ||
537 | info->tx_rate_idx = tx->rate_idx; | ||
538 | |||
539 | return TX_CONTINUE; | ||
540 | } | ||
541 | |||
542 | static ieee80211_tx_result | ||
543 | ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) | ||
544 | { | ||
545 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | ||
546 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
547 | u16 dur; | ||
548 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
549 | struct ieee80211_supported_band *sband; | ||
550 | |||
551 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | ||
552 | |||
553 | if (tx->sta) | ||
554 | info->control.aid = tx->sta->aid; | ||
555 | |||
556 | if (!info->control.retry_limit) { | ||
557 | if (!is_multicast_ether_addr(hdr->addr1)) { | ||
558 | int len = min_t(int, tx->skb->len + FCS_LEN, | ||
559 | tx->local->fragmentation_threshold); | ||
560 | if (len > tx->local->rts_threshold | ||
561 | && tx->local->rts_threshold < | ||
562 | IEEE80211_MAX_RTS_THRESHOLD) { | ||
563 | info->flags |= IEEE80211_TX_CTL_USE_RTS_CTS; | ||
564 | info->flags |= | ||
565 | IEEE80211_TX_CTL_LONG_RETRY_LIMIT; | ||
566 | info->control.retry_limit = | ||
567 | tx->local->long_retry_limit; | ||
568 | } else { | ||
569 | info->control.retry_limit = | ||
570 | tx->local->short_retry_limit; | ||
571 | } | ||
572 | } else { | ||
573 | info->control.retry_limit = 1; | ||
574 | } | ||
575 | } | ||
576 | |||
577 | if (tx->flags & IEEE80211_TX_FRAGMENTED) { | ||
578 | /* Do not use multiple retry rates when sending fragmented | ||
579 | * frames. | ||
580 | * TODO: The last fragment could still use multiple retry | ||
581 | * rates. */ | ||
582 | info->control.alt_retry_rate_idx = -1; | ||
583 | } | ||
584 | |||
585 | /* Use CTS protection for unicast frames sent using extended rates if | ||
586 | * there are associated non-ERP stations and RTS/CTS is not configured | ||
587 | * for the frame. */ | ||
588 | if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) && | ||
589 | (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_ERP_G) && | ||
590 | (tx->flags & IEEE80211_TX_UNICAST) && | ||
591 | tx->sdata->bss_conf.use_cts_prot && | ||
592 | !(info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)) | ||
593 | info->flags |= IEEE80211_TX_CTL_USE_CTS_PROTECT; | ||
594 | |||
595 | /* Transmit data frames using short preambles if the driver supports | ||
596 | * short preambles at the selected rate and short preambles are | ||
597 | * available on the network at the current point in time. */ | ||
598 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
599 | (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) && | ||
600 | tx->sdata->bss_conf.use_short_preamble && | ||
601 | (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) { | ||
602 | info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE; | ||
603 | } | ||
604 | |||
605 | /* Setup duration field for the first fragment of the frame. Duration | ||
606 | * for remaining fragments will be updated when they are being sent | ||
607 | * to low-level driver in ieee80211_tx(). */ | ||
608 | dur = ieee80211_duration(tx, is_multicast_ether_addr(hdr->addr1), | ||
609 | (tx->flags & IEEE80211_TX_FRAGMENTED) ? | ||
610 | tx->extra_frag[0]->len : 0); | ||
611 | hdr->duration_id = cpu_to_le16(dur); | ||
612 | |||
613 | if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || | ||
614 | (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { | ||
615 | struct ieee80211_rate *rate; | ||
616 | s8 baserate = -1; | ||
617 | int idx; | ||
618 | |||
619 | /* Do not use multiple retry rates when using RTS/CTS */ | ||
620 | info->control.alt_retry_rate_idx = -1; | ||
621 | |||
622 | /* Use min(data rate, max base rate) as CTS/RTS rate */ | ||
623 | rate = &sband->bitrates[tx->rate_idx]; | ||
624 | |||
625 | for (idx = 0; idx < sband->n_bitrates; idx++) { | ||
626 | if (sband->bitrates[idx].bitrate > rate->bitrate) | ||
627 | continue; | ||
628 | if (tx->sdata->basic_rates & BIT(idx) && | ||
629 | (baserate < 0 || | ||
630 | (sband->bitrates[baserate].bitrate | ||
631 | < sband->bitrates[idx].bitrate))) | ||
632 | baserate = idx; | ||
633 | } | ||
634 | |||
635 | if (baserate >= 0) | ||
636 | info->control.rts_cts_rate_idx = baserate; | ||
637 | else | ||
638 | info->control.rts_cts_rate_idx = 0; | ||
639 | } | ||
640 | |||
641 | if (tx->sta) | ||
642 | info->control.aid = tx->sta->aid; | ||
503 | 643 | ||
504 | return TX_CONTINUE; | 644 | return TX_CONTINUE; |
505 | } | 645 | } |
@@ -518,6 +658,17 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
518 | if (!(tx->flags & IEEE80211_TX_FRAGMENTED)) | 658 | if (!(tx->flags & IEEE80211_TX_FRAGMENTED)) |
519 | return TX_CONTINUE; | 659 | return TX_CONTINUE; |
520 | 660 | ||
661 | /* | ||
662 | * Warn when submitting a fragmented A-MPDU frame and drop it. | ||
663 | * This is an error and needs to be fixed elsewhere, but when | ||
664 | * done needs to take care of monitor interfaces (injection) | ||
665 | * etc. | ||
666 | */ | ||
667 | if (WARN_ON(tx->flags & IEEE80211_TX_CTL_AMPDU || | ||
668 | skb_get_queue_mapping(tx->skb) >= | ||
669 | ieee80211_num_regular_queues(&tx->local->hw))) | ||
670 | return TX_DROP; | ||
671 | |||
521 | first = tx->skb; | 672 | first = tx->skb; |
522 | 673 | ||
523 | hdrlen = ieee80211_get_hdrlen(tx->fc); | 674 | hdrlen = ieee80211_get_hdrlen(tx->fc); |
@@ -605,215 +756,22 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx) | |||
605 | } | 756 | } |
606 | 757 | ||
607 | static ieee80211_tx_result | 758 | static ieee80211_tx_result |
608 | ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | 759 | ieee80211_tx_h_stats(struct ieee80211_tx_data *tx) |
609 | { | ||
610 | struct rate_selection rsel; | ||
611 | struct ieee80211_supported_band *sband; | ||
612 | |||
613 | sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; | ||
614 | |||
615 | if (likely(!tx->rate)) { | ||
616 | rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); | ||
617 | tx->rate = rsel.rate; | ||
618 | if (unlikely(rsel.probe)) { | ||
619 | tx->control->flags |= | ||
620 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | ||
621 | tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG; | ||
622 | tx->control->alt_retry_rate = tx->rate; | ||
623 | tx->rate = rsel.probe; | ||
624 | } else | ||
625 | tx->control->alt_retry_rate = NULL; | ||
626 | |||
627 | if (!tx->rate) | ||
628 | return TX_DROP; | ||
629 | } else | ||
630 | tx->control->alt_retry_rate = NULL; | ||
631 | |||
632 | if (tx->sdata->bss_conf.use_cts_prot && | ||
633 | (tx->flags & IEEE80211_TX_FRAGMENTED) && rsel.nonerp) { | ||
634 | tx->last_frag_rate = tx->rate; | ||
635 | if (rsel.probe) | ||
636 | tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG; | ||
637 | else | ||
638 | tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG; | ||
639 | tx->rate = rsel.nonerp; | ||
640 | tx->control->tx_rate = rsel.nonerp; | ||
641 | tx->control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE; | ||
642 | } else { | ||
643 | tx->last_frag_rate = tx->rate; | ||
644 | tx->control->tx_rate = tx->rate; | ||
645 | } | ||
646 | tx->control->tx_rate = tx->rate; | ||
647 | |||
648 | return TX_CONTINUE; | ||
649 | } | ||
650 | |||
651 | static ieee80211_tx_result | ||
652 | ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) | ||
653 | { | ||
654 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | ||
655 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
656 | u16 dur; | ||
657 | struct ieee80211_tx_control *control = tx->control; | ||
658 | |||
659 | if (!control->retry_limit) { | ||
660 | if (!is_multicast_ether_addr(hdr->addr1)) { | ||
661 | if (tx->skb->len + FCS_LEN > tx->local->rts_threshold | ||
662 | && tx->local->rts_threshold < | ||
663 | IEEE80211_MAX_RTS_THRESHOLD) { | ||
664 | control->flags |= | ||
665 | IEEE80211_TXCTL_USE_RTS_CTS; | ||
666 | control->flags |= | ||
667 | IEEE80211_TXCTL_LONG_RETRY_LIMIT; | ||
668 | control->retry_limit = | ||
669 | tx->local->long_retry_limit; | ||
670 | } else { | ||
671 | control->retry_limit = | ||
672 | tx->local->short_retry_limit; | ||
673 | } | ||
674 | } else { | ||
675 | control->retry_limit = 1; | ||
676 | } | ||
677 | } | ||
678 | |||
679 | if (tx->flags & IEEE80211_TX_FRAGMENTED) { | ||
680 | /* Do not use multiple retry rates when sending fragmented | ||
681 | * frames. | ||
682 | * TODO: The last fragment could still use multiple retry | ||
683 | * rates. */ | ||
684 | control->alt_retry_rate = NULL; | ||
685 | } | ||
686 | |||
687 | /* Use CTS protection for unicast frames sent using extended rates if | ||
688 | * there are associated non-ERP stations and RTS/CTS is not configured | ||
689 | * for the frame. */ | ||
690 | if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) && | ||
691 | (tx->rate->flags & IEEE80211_RATE_ERP_G) && | ||
692 | (tx->flags & IEEE80211_TX_UNICAST) && | ||
693 | tx->sdata->bss_conf.use_cts_prot && | ||
694 | !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) | ||
695 | control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT; | ||
696 | |||
697 | /* Transmit data frames using short preambles if the driver supports | ||
698 | * short preambles at the selected rate and short preambles are | ||
699 | * available on the network at the current point in time. */ | ||
700 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
701 | (tx->rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && | ||
702 | tx->sdata->bss_conf.use_short_preamble && | ||
703 | (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) { | ||
704 | tx->control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | ||
705 | } | ||
706 | |||
707 | /* Setup duration field for the first fragment of the frame. Duration | ||
708 | * for remaining fragments will be updated when they are being sent | ||
709 | * to low-level driver in ieee80211_tx(). */ | ||
710 | dur = ieee80211_duration(tx, is_multicast_ether_addr(hdr->addr1), | ||
711 | (tx->flags & IEEE80211_TX_FRAGMENTED) ? | ||
712 | tx->extra_frag[0]->len : 0); | ||
713 | hdr->duration_id = cpu_to_le16(dur); | ||
714 | |||
715 | if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) || | ||
716 | (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { | ||
717 | struct ieee80211_supported_band *sband; | ||
718 | struct ieee80211_rate *rate, *baserate; | ||
719 | int idx; | ||
720 | |||
721 | sband = tx->local->hw.wiphy->bands[ | ||
722 | tx->local->hw.conf.channel->band]; | ||
723 | |||
724 | /* Do not use multiple retry rates when using RTS/CTS */ | ||
725 | control->alt_retry_rate = NULL; | ||
726 | |||
727 | /* Use min(data rate, max base rate) as CTS/RTS rate */ | ||
728 | rate = tx->rate; | ||
729 | baserate = NULL; | ||
730 | |||
731 | for (idx = 0; idx < sband->n_bitrates; idx++) { | ||
732 | if (sband->bitrates[idx].bitrate > rate->bitrate) | ||
733 | continue; | ||
734 | if (tx->sdata->basic_rates & BIT(idx) && | ||
735 | (!baserate || | ||
736 | (baserate->bitrate < sband->bitrates[idx].bitrate))) | ||
737 | baserate = &sband->bitrates[idx]; | ||
738 | } | ||
739 | |||
740 | if (baserate) | ||
741 | control->rts_cts_rate = baserate; | ||
742 | else | ||
743 | control->rts_cts_rate = &sband->bitrates[0]; | ||
744 | } | ||
745 | |||
746 | if (tx->sta) { | ||
747 | control->aid = tx->sta->aid; | ||
748 | tx->sta->tx_packets++; | ||
749 | tx->sta->tx_fragments++; | ||
750 | tx->sta->tx_bytes += tx->skb->len; | ||
751 | if (tx->extra_frag) { | ||
752 | int i; | ||
753 | tx->sta->tx_fragments += tx->num_extra_frag; | ||
754 | for (i = 0; i < tx->num_extra_frag; i++) { | ||
755 | tx->sta->tx_bytes += | ||
756 | tx->extra_frag[i]->len; | ||
757 | } | ||
758 | } | ||
759 | } | ||
760 | |||
761 | return TX_CONTINUE; | ||
762 | } | ||
763 | |||
764 | static ieee80211_tx_result | ||
765 | ieee80211_tx_h_load_stats(struct ieee80211_tx_data *tx) | ||
766 | { | 760 | { |
767 | struct ieee80211_local *local = tx->local; | 761 | int i; |
768 | struct sk_buff *skb = tx->skb; | ||
769 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
770 | u32 load = 0, hdrtime; | ||
771 | struct ieee80211_rate *rate = tx->rate; | ||
772 | |||
773 | /* TODO: this could be part of tx_status handling, so that the number | ||
774 | * of retries would be known; TX rate should in that case be stored | ||
775 | * somewhere with the packet */ | ||
776 | |||
777 | /* Estimate total channel use caused by this frame */ | ||
778 | |||
779 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, | ||
780 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | ||
781 | |||
782 | if (tx->channel->band == IEEE80211_BAND_5GHZ || | ||
783 | (tx->channel->band == IEEE80211_BAND_2GHZ && | ||
784 | rate->flags & IEEE80211_RATE_ERP_G)) | ||
785 | hdrtime = CHAN_UTIL_HDR_SHORT; | ||
786 | else | ||
787 | hdrtime = CHAN_UTIL_HDR_LONG; | ||
788 | |||
789 | load = hdrtime; | ||
790 | if (!is_multicast_ether_addr(hdr->addr1)) | ||
791 | load += hdrtime; | ||
792 | |||
793 | if (tx->control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | ||
794 | load += 2 * hdrtime; | ||
795 | else if (tx->control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | ||
796 | load += hdrtime; | ||
797 | 762 | ||
798 | /* TODO: optimise again */ | 763 | if (!tx->sta) |
799 | load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; | 764 | return TX_CONTINUE; |
800 | 765 | ||
766 | tx->sta->tx_packets++; | ||
767 | tx->sta->tx_fragments++; | ||
768 | tx->sta->tx_bytes += tx->skb->len; | ||
801 | if (tx->extra_frag) { | 769 | if (tx->extra_frag) { |
802 | int i; | 770 | tx->sta->tx_fragments += tx->num_extra_frag; |
803 | for (i = 0; i < tx->num_extra_frag; i++) { | 771 | for (i = 0; i < tx->num_extra_frag; i++) |
804 | load += 2 * hdrtime; | 772 | tx->sta->tx_bytes += tx->extra_frag[i]->len; |
805 | load += tx->extra_frag[i]->len * | ||
806 | tx->rate->bitrate; | ||
807 | } | ||
808 | } | 773 | } |
809 | 774 | ||
810 | /* Divide channel_use by 8 to avoid wrapping around the counter */ | ||
811 | load >>= CHAN_UTIL_SHIFT; | ||
812 | local->channel_use_raw += load; | ||
813 | if (tx->sta) | ||
814 | tx->sta->channel_use_raw += load; | ||
815 | tx->sdata->channel_use_raw += load; | ||
816 | |||
817 | return TX_CONTINUE; | 775 | return TX_CONTINUE; |
818 | } | 776 | } |
819 | 777 | ||
@@ -826,11 +784,12 @@ static ieee80211_tx_handler ieee80211_tx_handlers[] = | |||
826 | ieee80211_tx_h_ps_buf, | 784 | ieee80211_tx_h_ps_buf, |
827 | ieee80211_tx_h_select_key, | 785 | ieee80211_tx_h_select_key, |
828 | ieee80211_tx_h_michael_mic_add, | 786 | ieee80211_tx_h_michael_mic_add, |
829 | ieee80211_tx_h_fragment, | ||
830 | ieee80211_tx_h_encrypt, | ||
831 | ieee80211_tx_h_rate_ctrl, | 787 | ieee80211_tx_h_rate_ctrl, |
832 | ieee80211_tx_h_misc, | 788 | ieee80211_tx_h_misc, |
833 | ieee80211_tx_h_load_stats, | 789 | ieee80211_tx_h_fragment, |
790 | /* handlers after fragment must be aware of tx info fragmentation! */ | ||
791 | ieee80211_tx_h_encrypt, | ||
792 | ieee80211_tx_h_stats, | ||
834 | NULL | 793 | NULL |
835 | }; | 794 | }; |
836 | 795 | ||
@@ -857,12 +816,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
857 | (struct ieee80211_radiotap_header *) skb->data; | 816 | (struct ieee80211_radiotap_header *) skb->data; |
858 | struct ieee80211_supported_band *sband; | 817 | struct ieee80211_supported_band *sband; |
859 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); | 818 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); |
860 | struct ieee80211_tx_control *control = tx->control; | 819 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
861 | 820 | ||
862 | sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; | 821 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; |
863 | 822 | ||
864 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 823 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
865 | tx->flags |= IEEE80211_TX_INJECTED; | 824 | info->flags |= IEEE80211_TX_CTL_INJECTED; |
866 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | 825 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; |
867 | 826 | ||
868 | /* | 827 | /* |
@@ -899,7 +858,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
899 | r = &sband->bitrates[i]; | 858 | r = &sband->bitrates[i]; |
900 | 859 | ||
901 | if (r->bitrate == target_rate) { | 860 | if (r->bitrate == target_rate) { |
902 | tx->rate = r; | 861 | tx->rate_idx = i; |
903 | break; | 862 | break; |
904 | } | 863 | } |
905 | } | 864 | } |
@@ -910,7 +869,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
910 | * radiotap uses 0 for 1st ant, mac80211 is 1 for | 869 | * radiotap uses 0 for 1st ant, mac80211 is 1 for |
911 | * 1st ant | 870 | * 1st ant |
912 | */ | 871 | */ |
913 | control->antenna_sel_tx = (*iterator.this_arg) + 1; | 872 | info->antenna_sel_tx = (*iterator.this_arg) + 1; |
914 | break; | 873 | break; |
915 | 874 | ||
916 | #if 0 | 875 | #if 0 |
@@ -934,8 +893,8 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
934 | skb_trim(skb, skb->len - FCS_LEN); | 893 | skb_trim(skb, skb->len - FCS_LEN); |
935 | } | 894 | } |
936 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | 895 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) |
937 | control->flags &= | 896 | info->flags &= |
938 | ~IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 897 | ~IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
939 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | 898 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) |
940 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 899 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
941 | break; | 900 | break; |
@@ -970,12 +929,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
970 | static ieee80211_tx_result | 929 | static ieee80211_tx_result |
971 | __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | 930 | __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, |
972 | struct sk_buff *skb, | 931 | struct sk_buff *skb, |
973 | struct net_device *dev, | 932 | struct net_device *dev) |
974 | struct ieee80211_tx_control *control) | ||
975 | { | 933 | { |
976 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 934 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
977 | struct ieee80211_hdr *hdr; | 935 | struct ieee80211_hdr *hdr; |
978 | struct ieee80211_sub_if_data *sdata; | 936 | struct ieee80211_sub_if_data *sdata; |
937 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
979 | 938 | ||
980 | int hdrlen; | 939 | int hdrlen; |
981 | 940 | ||
@@ -984,7 +943,9 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
984 | tx->dev = dev; /* use original interface */ | 943 | tx->dev = dev; /* use original interface */ |
985 | tx->local = local; | 944 | tx->local = local; |
986 | tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 945 | tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
987 | tx->control = control; | 946 | tx->channel = local->hw.conf.channel; |
947 | tx->rate_idx = -1; | ||
948 | tx->last_frag_rate_idx = -1; | ||
988 | /* | 949 | /* |
989 | * Set this flag (used below to indicate "automatic fragmentation"), | 950 | * Set this flag (used below to indicate "automatic fragmentation"), |
990 | * it will be cleared/left by radiotap as desired. | 951 | * it will be cleared/left by radiotap as desired. |
@@ -1011,10 +972,10 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1011 | 972 | ||
1012 | if (is_multicast_ether_addr(hdr->addr1)) { | 973 | if (is_multicast_ether_addr(hdr->addr1)) { |
1013 | tx->flags &= ~IEEE80211_TX_UNICAST; | 974 | tx->flags &= ~IEEE80211_TX_UNICAST; |
1014 | control->flags |= IEEE80211_TXCTL_NO_ACK; | 975 | info->flags |= IEEE80211_TX_CTL_NO_ACK; |
1015 | } else { | 976 | } else { |
1016 | tx->flags |= IEEE80211_TX_UNICAST; | 977 | tx->flags |= IEEE80211_TX_UNICAST; |
1017 | control->flags &= ~IEEE80211_TXCTL_NO_ACK; | 978 | info->flags &= ~IEEE80211_TX_CTL_NO_ACK; |
1018 | } | 979 | } |
1019 | 980 | ||
1020 | if (tx->flags & IEEE80211_TX_FRAGMENTED) { | 981 | if (tx->flags & IEEE80211_TX_FRAGMENTED) { |
@@ -1027,16 +988,16 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1027 | } | 988 | } |
1028 | 989 | ||
1029 | if (!tx->sta) | 990 | if (!tx->sta) |
1030 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; | 991 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1031 | else if (test_and_clear_sta_flags(tx->sta, WLAN_STA_CLEAR_PS_FILT)) | 992 | else if (test_and_clear_sta_flags(tx->sta, WLAN_STA_CLEAR_PS_FILT)) |
1032 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; | 993 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1033 | 994 | ||
1034 | hdrlen = ieee80211_get_hdrlen(tx->fc); | 995 | hdrlen = ieee80211_get_hdrlen(tx->fc); |
1035 | if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) { | 996 | if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) { |
1036 | u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)]; | 997 | u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)]; |
1037 | tx->ethertype = (pos[0] << 8) | pos[1]; | 998 | tx->ethertype = (pos[0] << 8) | pos[1]; |
1038 | } | 999 | } |
1039 | control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT; | 1000 | info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; |
1040 | 1001 | ||
1041 | return TX_CONTINUE; | 1002 | return TX_CONTINUE; |
1042 | } | 1003 | } |
@@ -1046,14 +1007,12 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1046 | */ | 1007 | */ |
1047 | static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | 1008 | static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, |
1048 | struct sk_buff *skb, | 1009 | struct sk_buff *skb, |
1049 | struct net_device *mdev, | 1010 | struct net_device *mdev) |
1050 | struct ieee80211_tx_control *control) | ||
1051 | { | 1011 | { |
1052 | struct ieee80211_tx_packet_data *pkt_data; | 1012 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1053 | struct net_device *dev; | 1013 | struct net_device *dev; |
1054 | 1014 | ||
1055 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | 1015 | dev = dev_get_by_index(&init_net, info->control.ifindex); |
1056 | dev = dev_get_by_index(&init_net, pkt_data->ifindex); | ||
1057 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { | 1016 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { |
1058 | dev_put(dev); | 1017 | dev_put(dev); |
1059 | dev = NULL; | 1018 | dev = NULL; |
@@ -1061,7 +1020,7 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1061 | if (unlikely(!dev)) | 1020 | if (unlikely(!dev)) |
1062 | return -ENODEV; | 1021 | return -ENODEV; |
1063 | /* initialises tx with control */ | 1022 | /* initialises tx with control */ |
1064 | __ieee80211_tx_prepare(tx, skb, dev, control); | 1023 | __ieee80211_tx_prepare(tx, skb, dev); |
1065 | dev_put(dev); | 1024 | dev_put(dev); |
1066 | return 0; | 1025 | return 0; |
1067 | } | 1026 | } |
@@ -1069,50 +1028,49 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1069 | static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | 1028 | static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, |
1070 | struct ieee80211_tx_data *tx) | 1029 | struct ieee80211_tx_data *tx) |
1071 | { | 1030 | { |
1072 | struct ieee80211_tx_control *control = tx->control; | 1031 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1073 | int ret, i; | 1032 | int ret, i; |
1074 | 1033 | ||
1075 | if (!ieee80211_qdisc_installed(local->mdev) && | 1034 | if (netif_subqueue_stopped(local->mdev, skb)) |
1076 | __ieee80211_queue_stopped(local, 0)) { | ||
1077 | netif_stop_queue(local->mdev); | ||
1078 | return IEEE80211_TX_AGAIN; | 1035 | return IEEE80211_TX_AGAIN; |
1079 | } | 1036 | |
1080 | if (skb) { | 1037 | if (skb) { |
1081 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), | 1038 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), |
1082 | "TX to low-level driver", skb); | 1039 | "TX to low-level driver", skb); |
1083 | ret = local->ops->tx(local_to_hw(local), skb, control); | 1040 | ret = local->ops->tx(local_to_hw(local), skb); |
1084 | if (ret) | 1041 | if (ret) |
1085 | return IEEE80211_TX_AGAIN; | 1042 | return IEEE80211_TX_AGAIN; |
1086 | local->mdev->trans_start = jiffies; | 1043 | local->mdev->trans_start = jiffies; |
1087 | ieee80211_led_tx(local, 1); | 1044 | ieee80211_led_tx(local, 1); |
1088 | } | 1045 | } |
1089 | if (tx->extra_frag) { | 1046 | if (tx->extra_frag) { |
1090 | control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS | | ||
1091 | IEEE80211_TXCTL_USE_CTS_PROTECT | | ||
1092 | IEEE80211_TXCTL_CLEAR_PS_FILT | | ||
1093 | IEEE80211_TXCTL_FIRST_FRAGMENT); | ||
1094 | for (i = 0; i < tx->num_extra_frag; i++) { | 1047 | for (i = 0; i < tx->num_extra_frag; i++) { |
1095 | if (!tx->extra_frag[i]) | 1048 | if (!tx->extra_frag[i]) |
1096 | continue; | 1049 | continue; |
1097 | if (__ieee80211_queue_stopped(local, control->queue)) | 1050 | info = IEEE80211_SKB_CB(tx->extra_frag[i]); |
1051 | info->flags &= ~(IEEE80211_TX_CTL_USE_RTS_CTS | | ||
1052 | IEEE80211_TX_CTL_USE_CTS_PROTECT | | ||
1053 | IEEE80211_TX_CTL_CLEAR_PS_FILT | | ||
1054 | IEEE80211_TX_CTL_FIRST_FRAGMENT); | ||
1055 | if (netif_subqueue_stopped(local->mdev, | ||
1056 | tx->extra_frag[i])) | ||
1098 | return IEEE80211_TX_FRAG_AGAIN; | 1057 | return IEEE80211_TX_FRAG_AGAIN; |
1099 | if (i == tx->num_extra_frag) { | 1058 | if (i == tx->num_extra_frag) { |
1100 | control->tx_rate = tx->last_frag_rate; | 1059 | info->tx_rate_idx = tx->last_frag_rate_idx; |
1101 | 1060 | ||
1102 | if (tx->flags & IEEE80211_TX_PROBE_LAST_FRAG) | 1061 | if (tx->flags & IEEE80211_TX_PROBE_LAST_FRAG) |
1103 | control->flags |= | 1062 | info->flags |= |
1104 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | 1063 | IEEE80211_TX_CTL_RATE_CTRL_PROBE; |
1105 | else | 1064 | else |
1106 | control->flags &= | 1065 | info->flags &= |
1107 | ~IEEE80211_TXCTL_RATE_CTRL_PROBE; | 1066 | ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; |
1108 | } | 1067 | } |
1109 | 1068 | ||
1110 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), | 1069 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), |
1111 | "TX to low-level driver", | 1070 | "TX to low-level driver", |
1112 | tx->extra_frag[i]); | 1071 | tx->extra_frag[i]); |
1113 | ret = local->ops->tx(local_to_hw(local), | 1072 | ret = local->ops->tx(local_to_hw(local), |
1114 | tx->extra_frag[i], | 1073 | tx->extra_frag[i]); |
1115 | control); | ||
1116 | if (ret) | 1074 | if (ret) |
1117 | return IEEE80211_TX_FRAG_AGAIN; | 1075 | return IEEE80211_TX_FRAG_AGAIN; |
1118 | local->mdev->trans_start = jiffies; | 1076 | local->mdev->trans_start = jiffies; |
@@ -1125,17 +1083,20 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | |||
1125 | return IEEE80211_TX_OK; | 1083 | return IEEE80211_TX_OK; |
1126 | } | 1084 | } |
1127 | 1085 | ||
1128 | static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | 1086 | static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb) |
1129 | struct ieee80211_tx_control *control) | ||
1130 | { | 1087 | { |
1131 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1088 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1132 | struct sta_info *sta; | 1089 | struct sta_info *sta; |
1133 | ieee80211_tx_handler *handler; | 1090 | ieee80211_tx_handler *handler; |
1134 | struct ieee80211_tx_data tx; | 1091 | struct ieee80211_tx_data tx; |
1135 | ieee80211_tx_result res = TX_DROP, res_prepare; | 1092 | ieee80211_tx_result res = TX_DROP, res_prepare; |
1093 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1136 | int ret, i; | 1094 | int ret, i; |
1095 | u16 queue; | ||
1137 | 1096 | ||
1138 | WARN_ON(__ieee80211_queue_pending(local, control->queue)); | 1097 | queue = skb_get_queue_mapping(skb); |
1098 | |||
1099 | WARN_ON(test_bit(queue, local->queues_pending)); | ||
1139 | 1100 | ||
1140 | if (unlikely(skb->len < 10)) { | 1101 | if (unlikely(skb->len < 10)) { |
1141 | dev_kfree_skb(skb); | 1102 | dev_kfree_skb(skb); |
@@ -1145,7 +1106,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1145 | rcu_read_lock(); | 1106 | rcu_read_lock(); |
1146 | 1107 | ||
1147 | /* initialises tx */ | 1108 | /* initialises tx */ |
1148 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev, control); | 1109 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev); |
1149 | 1110 | ||
1150 | if (res_prepare == TX_DROP) { | 1111 | if (res_prepare == TX_DROP) { |
1151 | dev_kfree_skb(skb); | 1112 | dev_kfree_skb(skb); |
@@ -1155,6 +1116,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1155 | 1116 | ||
1156 | sta = tx.sta; | 1117 | sta = tx.sta; |
1157 | tx.channel = local->hw.conf.channel; | 1118 | tx.channel = local->hw.conf.channel; |
1119 | info->band = tx.channel->band; | ||
1158 | 1120 | ||
1159 | for (handler = ieee80211_tx_handlers; *handler != NULL; | 1121 | for (handler = ieee80211_tx_handlers; *handler != NULL; |
1160 | handler++) { | 1122 | handler++) { |
@@ -1163,7 +1125,8 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1163 | break; | 1125 | break; |
1164 | } | 1126 | } |
1165 | 1127 | ||
1166 | skb = tx.skb; /* handlers are allowed to change skb */ | 1128 | if (WARN_ON(tx.skb != skb)) |
1129 | goto drop; | ||
1167 | 1130 | ||
1168 | if (unlikely(res == TX_DROP)) { | 1131 | if (unlikely(res == TX_DROP)) { |
1169 | I802_DEBUG_INC(local->tx_handlers_drop); | 1132 | I802_DEBUG_INC(local->tx_handlers_drop); |
@@ -1187,7 +1150,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1187 | next_len = tx.extra_frag[i + 1]->len; | 1150 | next_len = tx.extra_frag[i + 1]->len; |
1188 | } else { | 1151 | } else { |
1189 | next_len = 0; | 1152 | next_len = 0; |
1190 | tx.rate = tx.last_frag_rate; | 1153 | tx.rate_idx = tx.last_frag_rate_idx; |
1191 | } | 1154 | } |
1192 | dur = ieee80211_duration(&tx, 0, next_len); | 1155 | dur = ieee80211_duration(&tx, 0, next_len); |
1193 | hdr->duration_id = cpu_to_le16(dur); | 1156 | hdr->duration_id = cpu_to_le16(dur); |
@@ -1197,34 +1160,41 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1197 | retry: | 1160 | retry: |
1198 | ret = __ieee80211_tx(local, skb, &tx); | 1161 | ret = __ieee80211_tx(local, skb, &tx); |
1199 | if (ret) { | 1162 | if (ret) { |
1200 | struct ieee80211_tx_stored_packet *store = | 1163 | struct ieee80211_tx_stored_packet *store; |
1201 | &local->pending_packet[control->queue]; | 1164 | |
1165 | /* | ||
1166 | * Since there are no fragmented frames on A-MPDU | ||
1167 | * queues, there's no reason for a driver to reject | ||
1168 | * a frame there, warn and drop it. | ||
1169 | */ | ||
1170 | if (WARN_ON(queue >= ieee80211_num_regular_queues(&local->hw))) | ||
1171 | goto drop; | ||
1172 | |||
1173 | store = &local->pending_packet[queue]; | ||
1202 | 1174 | ||
1203 | if (ret == IEEE80211_TX_FRAG_AGAIN) | 1175 | if (ret == IEEE80211_TX_FRAG_AGAIN) |
1204 | skb = NULL; | 1176 | skb = NULL; |
1205 | set_bit(IEEE80211_LINK_STATE_PENDING, | 1177 | set_bit(queue, local->queues_pending); |
1206 | &local->state[control->queue]); | ||
1207 | smp_mb(); | 1178 | smp_mb(); |
1208 | /* When the driver gets out of buffers during sending of | 1179 | /* |
1209 | * fragments and calls ieee80211_stop_queue, there is | 1180 | * When the driver gets out of buffers during sending of |
1210 | * a small window between IEEE80211_LINK_STATE_XOFF and | 1181 | * fragments and calls ieee80211_stop_queue, the netif |
1211 | * IEEE80211_LINK_STATE_PENDING flags are set. If a buffer | 1182 | * subqueue is stopped. There is, however, a small window |
1183 | * in which the PENDING bit is not yet set. If a buffer | ||
1212 | * gets available in that window (i.e. driver calls | 1184 | * gets available in that window (i.e. driver calls |
1213 | * ieee80211_wake_queue), we would end up with ieee80211_tx | 1185 | * ieee80211_wake_queue), we would end up with ieee80211_tx |
1214 | * called with IEEE80211_LINK_STATE_PENDING. Prevent this by | 1186 | * called with the PENDING bit still set. Prevent this by |
1215 | * continuing transmitting here when that situation is | 1187 | * continuing transmitting here when that situation is |
1216 | * possible to have happened. */ | 1188 | * possible to have happened. |
1217 | if (!__ieee80211_queue_stopped(local, control->queue)) { | 1189 | */ |
1218 | clear_bit(IEEE80211_LINK_STATE_PENDING, | 1190 | if (!__netif_subqueue_stopped(local->mdev, queue)) { |
1219 | &local->state[control->queue]); | 1191 | clear_bit(queue, local->queues_pending); |
1220 | goto retry; | 1192 | goto retry; |
1221 | } | 1193 | } |
1222 | memcpy(&store->control, control, | ||
1223 | sizeof(struct ieee80211_tx_control)); | ||
1224 | store->skb = skb; | 1194 | store->skb = skb; |
1225 | store->extra_frag = tx.extra_frag; | 1195 | store->extra_frag = tx.extra_frag; |
1226 | store->num_extra_frag = tx.num_extra_frag; | 1196 | store->num_extra_frag = tx.num_extra_frag; |
1227 | store->last_frag_rate = tx.last_frag_rate; | 1197 | store->last_frag_rate_idx = tx.last_frag_rate_idx; |
1228 | store->last_frag_rate_ctrl_probe = | 1198 | store->last_frag_rate_ctrl_probe = |
1229 | !!(tx.flags & IEEE80211_TX_PROBE_LAST_FRAG); | 1199 | !!(tx.flags & IEEE80211_TX_PROBE_LAST_FRAG); |
1230 | } | 1200 | } |
@@ -1244,24 +1214,57 @@ retry: | |||
1244 | 1214 | ||
1245 | /* device xmit handlers */ | 1215 | /* device xmit handlers */ |
1246 | 1216 | ||
1217 | static int ieee80211_skb_resize(struct ieee80211_local *local, | ||
1218 | struct sk_buff *skb, | ||
1219 | int head_need, bool may_encrypt) | ||
1220 | { | ||
1221 | int tail_need = 0; | ||
1222 | |||
1223 | /* | ||
1224 | * This could be optimised, devices that do full hardware | ||
1225 | * crypto (including TKIP MMIC) need no tailroom... But we | ||
1226 | * have no drivers for such devices currently. | ||
1227 | */ | ||
1228 | if (may_encrypt) { | ||
1229 | tail_need = IEEE80211_ENCRYPT_TAILROOM; | ||
1230 | tail_need -= skb_tailroom(skb); | ||
1231 | tail_need = max_t(int, tail_need, 0); | ||
1232 | } | ||
1233 | |||
1234 | if (head_need || tail_need) { | ||
1235 | /* Sorry. Can't account for this any more */ | ||
1236 | skb_orphan(skb); | ||
1237 | } | ||
1238 | |||
1239 | if (skb_header_cloned(skb)) | ||
1240 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | ||
1241 | else | ||
1242 | I802_DEBUG_INC(local->tx_expand_skb_head); | ||
1243 | |||
1244 | if (pskb_expand_head(skb, head_need, tail_need, GFP_ATOMIC)) { | ||
1245 | printk(KERN_DEBUG "%s: failed to reallocate TX buffer\n", | ||
1246 | wiphy_name(local->hw.wiphy)); | ||
1247 | return -ENOMEM; | ||
1248 | } | ||
1249 | |||
1250 | /* update truesize too */ | ||
1251 | skb->truesize += head_need + tail_need; | ||
1252 | |||
1253 | return 0; | ||
1254 | } | ||
1255 | |||
1247 | int ieee80211_master_start_xmit(struct sk_buff *skb, | 1256 | int ieee80211_master_start_xmit(struct sk_buff *skb, |
1248 | struct net_device *dev) | 1257 | struct net_device *dev) |
1249 | { | 1258 | { |
1250 | struct ieee80211_tx_control control; | 1259 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1251 | struct ieee80211_tx_packet_data *pkt_data; | ||
1252 | struct net_device *odev = NULL; | 1260 | struct net_device *odev = NULL; |
1253 | struct ieee80211_sub_if_data *osdata; | 1261 | struct ieee80211_sub_if_data *osdata; |
1254 | int headroom; | 1262 | int headroom; |
1263 | bool may_encrypt; | ||
1255 | int ret; | 1264 | int ret; |
1256 | 1265 | ||
1257 | /* | 1266 | if (info->control.ifindex) |
1258 | * copy control out of the skb so other people can use skb->cb | 1267 | odev = dev_get_by_index(&init_net, info->control.ifindex); |
1259 | */ | ||
1260 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | ||
1261 | memset(&control, 0, sizeof(struct ieee80211_tx_control)); | ||
1262 | |||
1263 | if (pkt_data->ifindex) | ||
1264 | odev = dev_get_by_index(&init_net, pkt_data->ifindex); | ||
1265 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { | 1268 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { |
1266 | dev_put(odev); | 1269 | dev_put(odev); |
1267 | odev = NULL; | 1270 | odev = NULL; |
@@ -1274,32 +1277,25 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1274 | dev_kfree_skb(skb); | 1277 | dev_kfree_skb(skb); |
1275 | return 0; | 1278 | return 0; |
1276 | } | 1279 | } |
1280 | |||
1277 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); | 1281 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); |
1278 | 1282 | ||
1279 | headroom = osdata->local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM; | 1283 | may_encrypt = !(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT); |
1280 | if (skb_headroom(skb) < headroom) { | 1284 | |
1281 | if (pskb_expand_head(skb, headroom, 0, GFP_ATOMIC)) { | 1285 | headroom = osdata->local->tx_headroom; |
1282 | dev_kfree_skb(skb); | 1286 | if (may_encrypt) |
1283 | dev_put(odev); | 1287 | headroom += IEEE80211_ENCRYPT_HEADROOM; |
1284 | return 0; | 1288 | headroom -= skb_headroom(skb); |
1285 | } | 1289 | headroom = max_t(int, 0, headroom); |
1290 | |||
1291 | if (ieee80211_skb_resize(osdata->local, skb, headroom, may_encrypt)) { | ||
1292 | dev_kfree_skb(skb); | ||
1293 | dev_put(odev); | ||
1294 | return 0; | ||
1286 | } | 1295 | } |
1287 | 1296 | ||
1288 | control.vif = &osdata->vif; | 1297 | info->control.vif = &osdata->vif; |
1289 | control.type = osdata->vif.type; | 1298 | ret = ieee80211_tx(odev, skb); |
1290 | if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS) | ||
1291 | control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS; | ||
1292 | if (pkt_data->flags & IEEE80211_TXPD_DO_NOT_ENCRYPT) | ||
1293 | control.flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | ||
1294 | if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) | ||
1295 | control.flags |= IEEE80211_TXCTL_REQUEUE; | ||
1296 | if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME) | ||
1297 | control.flags |= IEEE80211_TXCTL_EAPOL_FRAME; | ||
1298 | if (pkt_data->flags & IEEE80211_TXPD_AMPDU) | ||
1299 | control.flags |= IEEE80211_TXCTL_AMPDU; | ||
1300 | control.queue = pkt_data->queue; | ||
1301 | |||
1302 | ret = ieee80211_tx(odev, skb, &control); | ||
1303 | dev_put(odev); | 1299 | dev_put(odev); |
1304 | 1300 | ||
1305 | return ret; | 1301 | return ret; |
@@ -1309,7 +1305,7 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1309 | struct net_device *dev) | 1305 | struct net_device *dev) |
1310 | { | 1306 | { |
1311 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1307 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1312 | struct ieee80211_tx_packet_data *pkt_data; | 1308 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1313 | struct ieee80211_radiotap_header *prthdr = | 1309 | struct ieee80211_radiotap_header *prthdr = |
1314 | (struct ieee80211_radiotap_header *)skb->data; | 1310 | (struct ieee80211_radiotap_header *)skb->data; |
1315 | u16 len_rthdr; | 1311 | u16 len_rthdr; |
@@ -1331,14 +1327,12 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1331 | 1327 | ||
1332 | skb->dev = local->mdev; | 1328 | skb->dev = local->mdev; |
1333 | 1329 | ||
1334 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | ||
1335 | memset(pkt_data, 0, sizeof(*pkt_data)); | ||
1336 | /* needed because we set skb device to master */ | 1330 | /* needed because we set skb device to master */ |
1337 | pkt_data->ifindex = dev->ifindex; | 1331 | info->control.ifindex = dev->ifindex; |
1338 | 1332 | ||
1339 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; | 1333 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
1340 | /* Interfaces should always request a status report */ | 1334 | /* Interfaces should always request a status report */ |
1341 | pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS; | 1335 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; |
1342 | 1336 | ||
1343 | /* | 1337 | /* |
1344 | * fix up the pointers accounting for the radiotap | 1338 | * fix up the pointers accounting for the radiotap |
@@ -1382,7 +1376,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1382 | struct net_device *dev) | 1376 | struct net_device *dev) |
1383 | { | 1377 | { |
1384 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1378 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1385 | struct ieee80211_tx_packet_data *pkt_data; | 1379 | struct ieee80211_tx_info *info; |
1386 | struct ieee80211_sub_if_data *sdata; | 1380 | struct ieee80211_sub_if_data *sdata; |
1387 | int ret = 1, head_need; | 1381 | int ret = 1, head_need; |
1388 | u16 ethertype, hdrlen, meshhdrlen = 0, fc; | 1382 | u16 ethertype, hdrlen, meshhdrlen = 0, fc; |
@@ -1494,7 +1488,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1494 | } | 1488 | } |
1495 | 1489 | ||
1496 | /* receiver and we are QoS enabled, use a QoS type frame */ | 1490 | /* receiver and we are QoS enabled, use a QoS type frame */ |
1497 | if (sta_flags & WLAN_STA_WME && local->hw.queues >= 4) { | 1491 | if (sta_flags & WLAN_STA_WME && |
1492 | ieee80211_num_regular_queues(&local->hw) >= 4) { | ||
1498 | fc |= IEEE80211_STYPE_QOS_DATA; | 1493 | fc |= IEEE80211_STYPE_QOS_DATA; |
1499 | hdrlen += 2; | 1494 | hdrlen += 2; |
1500 | } | 1495 | } |
@@ -1558,32 +1553,26 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1558 | * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and | 1553 | * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and |
1559 | * alloc_skb() (net/core/skbuff.c) | 1554 | * alloc_skb() (net/core/skbuff.c) |
1560 | */ | 1555 | */ |
1561 | head_need = hdrlen + encaps_len + meshhdrlen + local->tx_headroom; | 1556 | head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); |
1562 | head_need -= skb_headroom(skb); | ||
1563 | 1557 | ||
1564 | /* We are going to modify skb data, so make a copy of it if happens to | 1558 | /* |
1565 | * be cloned. This could happen, e.g., with Linux bridge code passing | 1559 | * So we need to modify the skb header and hence need a copy of |
1566 | * us broadcast frames. */ | 1560 | * that. The head_need variable above doesn't, so far, include |
1561 | * the needed header space that we don't need right away. If we | ||
1562 | * can, then we don't reallocate right now but only after the | ||
1563 | * frame arrives at the master device (if it does...) | ||
1564 | * | ||
1565 | * If we cannot, however, then we will reallocate to include all | ||
1566 | * the ever needed space. Also, if we need to reallocate it anyway, | ||
1567 | * make it big enough for everything we may ever need. | ||
1568 | */ | ||
1567 | 1569 | ||
1568 | if (head_need > 0 || skb_header_cloned(skb)) { | 1570 | if (head_need > 0 || skb_header_cloned(skb)) { |
1569 | #if 0 | 1571 | head_need += IEEE80211_ENCRYPT_HEADROOM; |
1570 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " | 1572 | head_need += local->tx_headroom; |
1571 | "of headroom\n", dev->name, head_need); | 1573 | head_need = max_t(int, 0, head_need); |
1572 | #endif | 1574 | if (ieee80211_skb_resize(local, skb, head_need, true)) |
1573 | |||
1574 | if (skb_header_cloned(skb)) | ||
1575 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | ||
1576 | else | ||
1577 | I802_DEBUG_INC(local->tx_expand_skb_head); | ||
1578 | /* Since we have to reallocate the buffer, make sure that there | ||
1579 | * is enough room for possible WEP IV/ICV and TKIP (8 bytes | ||
1580 | * before payload and 12 after). */ | ||
1581 | if (pskb_expand_head(skb, (head_need > 0 ? head_need + 8 : 8), | ||
1582 | 12, GFP_ATOMIC)) { | ||
1583 | printk(KERN_DEBUG "%s: failed to reallocate TX buffer" | ||
1584 | "\n", dev->name); | ||
1585 | goto fail; | 1575 | goto fail; |
1586 | } | ||
1587 | } | 1576 | } |
1588 | 1577 | ||
1589 | if (encaps_data) { | 1578 | if (encaps_data) { |
@@ -1614,14 +1603,14 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1614 | nh_pos += hdrlen; | 1603 | nh_pos += hdrlen; |
1615 | h_pos += hdrlen; | 1604 | h_pos += hdrlen; |
1616 | 1605 | ||
1617 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | 1606 | info = IEEE80211_SKB_CB(skb); |
1618 | memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data)); | 1607 | memset(info, 0, sizeof(*info)); |
1619 | pkt_data->ifindex = dev->ifindex; | 1608 | info->control.ifindex = dev->ifindex; |
1620 | if (ethertype == ETH_P_PAE) | 1609 | if (ethertype == ETH_P_PAE) |
1621 | pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME; | 1610 | info->flags |= IEEE80211_TX_CTL_EAPOL_FRAME; |
1622 | 1611 | ||
1623 | /* Interfaces should always request a status report */ | 1612 | /* Interfaces should always request a status report */ |
1624 | pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS; | 1613 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; |
1625 | 1614 | ||
1626 | skb->dev = local->mdev; | 1615 | skb->dev = local->mdev; |
1627 | dev->stats.tx_packets++; | 1616 | dev->stats.tx_packets++; |
@@ -1646,46 +1635,55 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1646 | return ret; | 1635 | return ret; |
1647 | } | 1636 | } |
1648 | 1637 | ||
1649 | /* helper functions for pending packets for when queues are stopped */ | ||
1650 | 1638 | ||
1639 | /* | ||
1640 | * ieee80211_clear_tx_pending may not be called in a context where | ||
1641 | * it is possible that it packets could come in again. | ||
1642 | */ | ||
1651 | void ieee80211_clear_tx_pending(struct ieee80211_local *local) | 1643 | void ieee80211_clear_tx_pending(struct ieee80211_local *local) |
1652 | { | 1644 | { |
1653 | int i, j; | 1645 | int i, j; |
1654 | struct ieee80211_tx_stored_packet *store; | 1646 | struct ieee80211_tx_stored_packet *store; |
1655 | 1647 | ||
1656 | for (i = 0; i < local->hw.queues; i++) { | 1648 | for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) { |
1657 | if (!__ieee80211_queue_pending(local, i)) | 1649 | if (!test_bit(i, local->queues_pending)) |
1658 | continue; | 1650 | continue; |
1659 | store = &local->pending_packet[i]; | 1651 | store = &local->pending_packet[i]; |
1660 | kfree_skb(store->skb); | 1652 | kfree_skb(store->skb); |
1661 | for (j = 0; j < store->num_extra_frag; j++) | 1653 | for (j = 0; j < store->num_extra_frag; j++) |
1662 | kfree_skb(store->extra_frag[j]); | 1654 | kfree_skb(store->extra_frag[j]); |
1663 | kfree(store->extra_frag); | 1655 | kfree(store->extra_frag); |
1664 | clear_bit(IEEE80211_LINK_STATE_PENDING, &local->state[i]); | 1656 | clear_bit(i, local->queues_pending); |
1665 | } | 1657 | } |
1666 | } | 1658 | } |
1667 | 1659 | ||
1660 | /* | ||
1661 | * Transmit all pending packets. Called from tasklet, locks master device | ||
1662 | * TX lock so that no new packets can come in. | ||
1663 | */ | ||
1668 | void ieee80211_tx_pending(unsigned long data) | 1664 | void ieee80211_tx_pending(unsigned long data) |
1669 | { | 1665 | { |
1670 | struct ieee80211_local *local = (struct ieee80211_local *)data; | 1666 | struct ieee80211_local *local = (struct ieee80211_local *)data; |
1671 | struct net_device *dev = local->mdev; | 1667 | struct net_device *dev = local->mdev; |
1672 | struct ieee80211_tx_stored_packet *store; | 1668 | struct ieee80211_tx_stored_packet *store; |
1673 | struct ieee80211_tx_data tx; | 1669 | struct ieee80211_tx_data tx; |
1674 | int i, ret, reschedule = 0; | 1670 | int i, ret; |
1675 | 1671 | ||
1676 | netif_tx_lock_bh(dev); | 1672 | netif_tx_lock_bh(dev); |
1677 | for (i = 0; i < local->hw.queues; i++) { | 1673 | for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) { |
1678 | if (__ieee80211_queue_stopped(local, i)) | 1674 | /* Check that this queue is ok */ |
1675 | if (__netif_subqueue_stopped(local->mdev, i)) | ||
1679 | continue; | 1676 | continue; |
1680 | if (!__ieee80211_queue_pending(local, i)) { | 1677 | |
1681 | reschedule = 1; | 1678 | if (!test_bit(i, local->queues_pending)) { |
1679 | ieee80211_wake_queue(&local->hw, i); | ||
1682 | continue; | 1680 | continue; |
1683 | } | 1681 | } |
1682 | |||
1684 | store = &local->pending_packet[i]; | 1683 | store = &local->pending_packet[i]; |
1685 | tx.control = &store->control; | ||
1686 | tx.extra_frag = store->extra_frag; | 1684 | tx.extra_frag = store->extra_frag; |
1687 | tx.num_extra_frag = store->num_extra_frag; | 1685 | tx.num_extra_frag = store->num_extra_frag; |
1688 | tx.last_frag_rate = store->last_frag_rate; | 1686 | tx.last_frag_rate_idx = store->last_frag_rate_idx; |
1689 | tx.flags = 0; | 1687 | tx.flags = 0; |
1690 | if (store->last_frag_rate_ctrl_probe) | 1688 | if (store->last_frag_rate_ctrl_probe) |
1691 | tx.flags |= IEEE80211_TX_PROBE_LAST_FRAG; | 1689 | tx.flags |= IEEE80211_TX_PROBE_LAST_FRAG; |
@@ -1694,19 +1692,11 @@ void ieee80211_tx_pending(unsigned long data) | |||
1694 | if (ret == IEEE80211_TX_FRAG_AGAIN) | 1692 | if (ret == IEEE80211_TX_FRAG_AGAIN) |
1695 | store->skb = NULL; | 1693 | store->skb = NULL; |
1696 | } else { | 1694 | } else { |
1697 | clear_bit(IEEE80211_LINK_STATE_PENDING, | 1695 | clear_bit(i, local->queues_pending); |
1698 | &local->state[i]); | 1696 | ieee80211_wake_queue(&local->hw, i); |
1699 | reschedule = 1; | ||
1700 | } | 1697 | } |
1701 | } | 1698 | } |
1702 | netif_tx_unlock_bh(dev); | 1699 | netif_tx_unlock_bh(dev); |
1703 | if (reschedule) { | ||
1704 | if (!ieee80211_qdisc_installed(dev)) { | ||
1705 | if (!__ieee80211_queue_stopped(local, 0)) | ||
1706 | netif_wake_queue(dev); | ||
1707 | } else | ||
1708 | netif_schedule(dev); | ||
1709 | } | ||
1710 | } | 1700 | } |
1711 | 1701 | ||
1712 | /* functions for drivers to get certain frames */ | 1702 | /* functions for drivers to get certain frames */ |
@@ -1775,11 +1765,11 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local, | |||
1775 | } | 1765 | } |
1776 | 1766 | ||
1777 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | 1767 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, |
1778 | struct ieee80211_vif *vif, | 1768 | struct ieee80211_vif *vif) |
1779 | struct ieee80211_tx_control *control) | ||
1780 | { | 1769 | { |
1781 | struct ieee80211_local *local = hw_to_local(hw); | 1770 | struct ieee80211_local *local = hw_to_local(hw); |
1782 | struct sk_buff *skb; | 1771 | struct sk_buff *skb; |
1772 | struct ieee80211_tx_info *info; | ||
1783 | struct net_device *bdev; | 1773 | struct net_device *bdev; |
1784 | struct ieee80211_sub_if_data *sdata = NULL; | 1774 | struct ieee80211_sub_if_data *sdata = NULL; |
1785 | struct ieee80211_if_ap *ap = NULL; | 1775 | struct ieee80211_if_ap *ap = NULL; |
@@ -1789,9 +1779,10 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1789 | struct ieee80211_mgmt *mgmt; | 1779 | struct ieee80211_mgmt *mgmt; |
1790 | int *num_beacons; | 1780 | int *num_beacons; |
1791 | bool err = true; | 1781 | bool err = true; |
1782 | enum ieee80211_band band = local->hw.conf.channel->band; | ||
1792 | u8 *pos; | 1783 | u8 *pos; |
1793 | 1784 | ||
1794 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1785 | sband = local->hw.wiphy->bands[band]; |
1795 | 1786 | ||
1796 | rcu_read_lock(); | 1787 | rcu_read_lock(); |
1797 | 1788 | ||
@@ -1884,30 +1875,32 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1884 | goto out; | 1875 | goto out; |
1885 | } | 1876 | } |
1886 | 1877 | ||
1887 | if (control) { | 1878 | info = IEEE80211_SKB_CB(skb); |
1888 | rate_control_get_rate(local->mdev, sband, skb, &rsel); | ||
1889 | if (!rsel.rate) { | ||
1890 | if (net_ratelimit()) { | ||
1891 | printk(KERN_DEBUG "%s: ieee80211_beacon_get: " | ||
1892 | "no rate found\n", | ||
1893 | wiphy_name(local->hw.wiphy)); | ||
1894 | } | ||
1895 | dev_kfree_skb(skb); | ||
1896 | skb = NULL; | ||
1897 | goto out; | ||
1898 | } | ||
1899 | 1879 | ||
1900 | control->vif = vif; | 1880 | info->band = band; |
1901 | control->tx_rate = rsel.rate; | 1881 | rate_control_get_rate(local->mdev, sband, skb, &rsel); |
1902 | if (sdata->bss_conf.use_short_preamble && | 1882 | |
1903 | rsel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | 1883 | if (unlikely(rsel.rate_idx < 0)) { |
1904 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | 1884 | if (net_ratelimit()) { |
1905 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; | 1885 | printk(KERN_DEBUG "%s: ieee80211_beacon_get: " |
1906 | control->flags |= IEEE80211_TXCTL_NO_ACK; | 1886 | "no rate found\n", |
1907 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 1887 | wiphy_name(local->hw.wiphy)); |
1908 | control->retry_limit = 1; | 1888 | } |
1909 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; | 1889 | dev_kfree_skb(skb); |
1890 | skb = NULL; | ||
1891 | goto out; | ||
1910 | } | 1892 | } |
1893 | |||
1894 | info->control.vif = vif; | ||
1895 | info->tx_rate_idx = rsel.rate_idx; | ||
1896 | if (sdata->bss_conf.use_short_preamble && | ||
1897 | sband->bitrates[rsel.rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
1898 | info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE; | ||
1899 | info->antenna_sel_tx = local->hw.conf.antenna_sel_tx; | ||
1900 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | ||
1901 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | ||
1902 | info->control.retry_limit = 1; | ||
1903 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | ||
1911 | (*num_beacons)++; | 1904 | (*num_beacons)++; |
1912 | out: | 1905 | out: |
1913 | rcu_read_unlock(); | 1906 | rcu_read_unlock(); |
@@ -1917,7 +1910,7 @@ EXPORT_SYMBOL(ieee80211_beacon_get); | |||
1917 | 1910 | ||
1918 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1911 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1919 | const void *frame, size_t frame_len, | 1912 | const void *frame, size_t frame_len, |
1920 | const struct ieee80211_tx_control *frame_txctl, | 1913 | const struct ieee80211_tx_info *frame_txctl, |
1921 | struct ieee80211_rts *rts) | 1914 | struct ieee80211_rts *rts) |
1922 | { | 1915 | { |
1923 | const struct ieee80211_hdr *hdr = frame; | 1916 | const struct ieee80211_hdr *hdr = frame; |
@@ -1934,7 +1927,7 @@ EXPORT_SYMBOL(ieee80211_rts_get); | |||
1934 | 1927 | ||
1935 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1928 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1936 | const void *frame, size_t frame_len, | 1929 | const void *frame, size_t frame_len, |
1937 | const struct ieee80211_tx_control *frame_txctl, | 1930 | const struct ieee80211_tx_info *frame_txctl, |
1938 | struct ieee80211_cts *cts) | 1931 | struct ieee80211_cts *cts) |
1939 | { | 1932 | { |
1940 | const struct ieee80211_hdr *hdr = frame; | 1933 | const struct ieee80211_hdr *hdr = frame; |
@@ -1950,11 +1943,10 @@ EXPORT_SYMBOL(ieee80211_ctstoself_get); | |||
1950 | 1943 | ||
1951 | struct sk_buff * | 1944 | struct sk_buff * |
1952 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | 1945 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, |
1953 | struct ieee80211_vif *vif, | 1946 | struct ieee80211_vif *vif) |
1954 | struct ieee80211_tx_control *control) | ||
1955 | { | 1947 | { |
1956 | struct ieee80211_local *local = hw_to_local(hw); | 1948 | struct ieee80211_local *local = hw_to_local(hw); |
1957 | struct sk_buff *skb; | 1949 | struct sk_buff *skb = NULL; |
1958 | struct sta_info *sta; | 1950 | struct sta_info *sta; |
1959 | ieee80211_tx_handler *handler; | 1951 | ieee80211_tx_handler *handler; |
1960 | struct ieee80211_tx_data tx; | 1952 | struct ieee80211_tx_data tx; |
@@ -1963,10 +1955,11 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
1963 | struct ieee80211_sub_if_data *sdata; | 1955 | struct ieee80211_sub_if_data *sdata; |
1964 | struct ieee80211_if_ap *bss = NULL; | 1956 | struct ieee80211_if_ap *bss = NULL; |
1965 | struct beacon_data *beacon; | 1957 | struct beacon_data *beacon; |
1958 | struct ieee80211_tx_info *info; | ||
1966 | 1959 | ||
1967 | sdata = vif_to_sdata(vif); | 1960 | sdata = vif_to_sdata(vif); |
1968 | bdev = sdata->dev; | 1961 | bdev = sdata->dev; |
1969 | 1962 | bss = &sdata->u.ap; | |
1970 | 1963 | ||
1971 | if (!bss) | 1964 | if (!bss) |
1972 | return NULL; | 1965 | return NULL; |
@@ -1974,19 +1967,16 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
1974 | rcu_read_lock(); | 1967 | rcu_read_lock(); |
1975 | beacon = rcu_dereference(bss->beacon); | 1968 | beacon = rcu_dereference(bss->beacon); |
1976 | 1969 | ||
1977 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP || !beacon || | 1970 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP || !beacon || !beacon->head) |
1978 | !beacon->head) { | 1971 | goto out; |
1979 | rcu_read_unlock(); | ||
1980 | return NULL; | ||
1981 | } | ||
1982 | 1972 | ||
1983 | if (bss->dtim_count != 0) | 1973 | if (bss->dtim_count != 0) |
1984 | return NULL; /* send buffered bc/mc only after DTIM beacon */ | 1974 | goto out; /* send buffered bc/mc only after DTIM beacon */ |
1985 | memset(control, 0, sizeof(*control)); | 1975 | |
1986 | while (1) { | 1976 | while (1) { |
1987 | skb = skb_dequeue(&bss->ps_bc_buf); | 1977 | skb = skb_dequeue(&bss->ps_bc_buf); |
1988 | if (!skb) | 1978 | if (!skb) |
1989 | return NULL; | 1979 | goto out; |
1990 | local->total_ps_buffered--; | 1980 | local->total_ps_buffered--; |
1991 | 1981 | ||
1992 | if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) { | 1982 | if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) { |
@@ -1999,20 +1989,26 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
1999 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 1989 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
2000 | } | 1990 | } |
2001 | 1991 | ||
2002 | if (!ieee80211_tx_prepare(&tx, skb, local->mdev, control)) | 1992 | if (!ieee80211_tx_prepare(&tx, skb, local->mdev)) |
2003 | break; | 1993 | break; |
2004 | dev_kfree_skb_any(skb); | 1994 | dev_kfree_skb_any(skb); |
2005 | } | 1995 | } |
1996 | |||
1997 | info = IEEE80211_SKB_CB(skb); | ||
1998 | |||
2006 | sta = tx.sta; | 1999 | sta = tx.sta; |
2007 | tx.flags |= IEEE80211_TX_PS_BUFFERED; | 2000 | tx.flags |= IEEE80211_TX_PS_BUFFERED; |
2008 | tx.channel = local->hw.conf.channel; | 2001 | tx.channel = local->hw.conf.channel; |
2002 | info->band = tx.channel->band; | ||
2009 | 2003 | ||
2010 | for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) { | 2004 | for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) { |
2011 | res = (*handler)(&tx); | 2005 | res = (*handler)(&tx); |
2012 | if (res == TX_DROP || res == TX_QUEUED) | 2006 | if (res == TX_DROP || res == TX_QUEUED) |
2013 | break; | 2007 | break; |
2014 | } | 2008 | } |
2015 | skb = tx.skb; /* handlers are allowed to change skb */ | 2009 | |
2010 | if (WARN_ON(tx.skb != skb)) | ||
2011 | res = TX_DROP; | ||
2016 | 2012 | ||
2017 | if (res == TX_DROP) { | 2013 | if (res == TX_DROP) { |
2018 | I802_DEBUG_INC(local->tx_handlers_drop); | 2014 | I802_DEBUG_INC(local->tx_handlers_drop); |
@@ -2023,6 +2019,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2023 | skb = NULL; | 2019 | skb = NULL; |
2024 | } | 2020 | } |
2025 | 2021 | ||
2022 | out: | ||
2026 | rcu_read_unlock(); | 2023 | rcu_read_unlock(); |
2027 | 2024 | ||
2028 | return skb; | 2025 | return skb; |