diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2012-02-13 05:23:13 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-22 14:51:13 -0500 |
commit | 3dfea27d103e9913698cf1a2c86745a74c7c556b (patch) | |
tree | 4794a2ca538aef954ae65a913a1b9e941f36c9be /drivers/net/wireless/iwlegacy | |
parent | 93a984a4eec83f45abddb80724da7dcb85b4db6b (diff) |
iwlegacy: gather all 4965 handlers in one place
Handers belongs logically into 4965-mac.c file.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy')
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965-mac.c | 307 | ||||
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965.c | 312 | ||||
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlegacy/common.h | 2 |
4 files changed, 305 insertions, 325 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 7bf78bf866ca..4560021bb96d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c | |||
@@ -2548,6 +2548,308 @@ il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, | |||
2548 | return 0; | 2548 | return 0; |
2549 | } | 2549 | } |
2550 | 2550 | ||
2551 | static inline bool | ||
2552 | il4965_is_tx_success(u32 status) | ||
2553 | { | ||
2554 | status &= TX_STATUS_MSK; | ||
2555 | return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE); | ||
2556 | } | ||
2557 | |||
2558 | static u8 | ||
2559 | il4965_find_station(struct il_priv *il, const u8 *addr) | ||
2560 | { | ||
2561 | int i; | ||
2562 | int start = 0; | ||
2563 | int ret = IL_INVALID_STATION; | ||
2564 | unsigned long flags; | ||
2565 | |||
2566 | if (il->iw_mode == NL80211_IFTYPE_ADHOC) | ||
2567 | start = IL_STA_ID; | ||
2568 | |||
2569 | if (is_broadcast_ether_addr(addr)) | ||
2570 | return il->hw_params.bcast_id; | ||
2571 | |||
2572 | spin_lock_irqsave(&il->sta_lock, flags); | ||
2573 | for (i = start; i < il->hw_params.max_stations; i++) | ||
2574 | if (il->stations[i].used && | ||
2575 | (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { | ||
2576 | ret = i; | ||
2577 | goto out; | ||
2578 | } | ||
2579 | |||
2580 | D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); | ||
2581 | |||
2582 | out: | ||
2583 | /* | ||
2584 | * It may be possible that more commands interacting with stations | ||
2585 | * arrive before we completed processing the adding of | ||
2586 | * station | ||
2587 | */ | ||
2588 | if (ret != IL_INVALID_STATION && | ||
2589 | (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || | ||
2590 | ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && | ||
2591 | (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { | ||
2592 | IL_ERR("Requested station info for sta %d before ready.\n", | ||
2593 | ret); | ||
2594 | ret = IL_INVALID_STATION; | ||
2595 | } | ||
2596 | spin_unlock_irqrestore(&il->sta_lock, flags); | ||
2597 | return ret; | ||
2598 | } | ||
2599 | |||
2600 | static int | ||
2601 | il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) | ||
2602 | { | ||
2603 | if (il->iw_mode == NL80211_IFTYPE_STATION) | ||
2604 | return IL_AP_ID; | ||
2605 | else { | ||
2606 | u8 *da = ieee80211_get_DA(hdr); | ||
2607 | |||
2608 | return il4965_find_station(il, da); | ||
2609 | } | ||
2610 | } | ||
2611 | |||
2612 | static inline u32 | ||
2613 | il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) | ||
2614 | { | ||
2615 | return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; | ||
2616 | } | ||
2617 | |||
2618 | static inline u32 | ||
2619 | il4965_tx_status_to_mac80211(u32 status) | ||
2620 | { | ||
2621 | status &= TX_STATUS_MSK; | ||
2622 | |||
2623 | switch (status) { | ||
2624 | case TX_STATUS_SUCCESS: | ||
2625 | case TX_STATUS_DIRECT_DONE: | ||
2626 | return IEEE80211_TX_STAT_ACK; | ||
2627 | case TX_STATUS_FAIL_DEST_PS: | ||
2628 | return IEEE80211_TX_STAT_TX_FILTERED; | ||
2629 | default: | ||
2630 | return 0; | ||
2631 | } | ||
2632 | } | ||
2633 | |||
2634 | /** | ||
2635 | * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue | ||
2636 | */ | ||
2637 | static int | ||
2638 | il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, | ||
2639 | struct il4965_tx_resp *tx_resp, int txq_id, | ||
2640 | u16 start_idx) | ||
2641 | { | ||
2642 | u16 status; | ||
2643 | struct agg_tx_status *frame_status = tx_resp->u.agg_status; | ||
2644 | struct ieee80211_tx_info *info = NULL; | ||
2645 | struct ieee80211_hdr *hdr = NULL; | ||
2646 | u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
2647 | int i, sh, idx; | ||
2648 | u16 seq; | ||
2649 | if (agg->wait_for_ba) | ||
2650 | D_TX_REPLY("got tx response w/o block-ack\n"); | ||
2651 | |||
2652 | agg->frame_count = tx_resp->frame_count; | ||
2653 | agg->start_idx = start_idx; | ||
2654 | agg->rate_n_flags = rate_n_flags; | ||
2655 | agg->bitmap = 0; | ||
2656 | |||
2657 | /* num frames attempted by Tx command */ | ||
2658 | if (agg->frame_count == 1) { | ||
2659 | /* Only one frame was attempted; no block-ack will arrive */ | ||
2660 | status = le16_to_cpu(frame_status[0].status); | ||
2661 | idx = start_idx; | ||
2662 | |||
2663 | D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
2664 | agg->frame_count, agg->start_idx, idx); | ||
2665 | |||
2666 | info = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]); | ||
2667 | info->status.rates[0].count = tx_resp->failure_frame + 1; | ||
2668 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
2669 | info->flags |= il4965_tx_status_to_mac80211(status); | ||
2670 | il4965_hwrate_to_tx_control(il, rate_n_flags, info); | ||
2671 | |||
2672 | D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, | ||
2673 | tx_resp->failure_frame); | ||
2674 | D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); | ||
2675 | |||
2676 | agg->wait_for_ba = 0; | ||
2677 | } else { | ||
2678 | /* Two or more frames were attempted; expect block-ack */ | ||
2679 | u64 bitmap = 0; | ||
2680 | int start = agg->start_idx; | ||
2681 | struct sk_buff *skb; | ||
2682 | |||
2683 | /* Construct bit-map of pending frames within Tx win */ | ||
2684 | for (i = 0; i < agg->frame_count; i++) { | ||
2685 | u16 sc; | ||
2686 | status = le16_to_cpu(frame_status[i].status); | ||
2687 | seq = le16_to_cpu(frame_status[i].sequence); | ||
2688 | idx = SEQ_TO_IDX(seq); | ||
2689 | txq_id = SEQ_TO_QUEUE(seq); | ||
2690 | |||
2691 | if (status & | ||
2692 | (AGG_TX_STATE_FEW_BYTES_MSK | | ||
2693 | AGG_TX_STATE_ABORT_MSK)) | ||
2694 | continue; | ||
2695 | |||
2696 | D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
2697 | agg->frame_count, txq_id, idx); | ||
2698 | |||
2699 | skb = il->txq[txq_id].skbs[idx]; | ||
2700 | if (WARN_ON_ONCE(skb == NULL)) | ||
2701 | return -1; | ||
2702 | hdr = (struct ieee80211_hdr *) skb->data; | ||
2703 | |||
2704 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
2705 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
2706 | IL_ERR("BUG_ON idx doesn't match seq control" | ||
2707 | " idx=%d, seq_idx=%d, seq=%d\n", idx, | ||
2708 | SEQ_TO_SN(sc), hdr->seq_ctrl); | ||
2709 | return -1; | ||
2710 | } | ||
2711 | |||
2712 | D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, | ||
2713 | SEQ_TO_SN(sc)); | ||
2714 | |||
2715 | sh = idx - start; | ||
2716 | if (sh > 64) { | ||
2717 | sh = (start - idx) + 0xff; | ||
2718 | bitmap = bitmap << sh; | ||
2719 | sh = 0; | ||
2720 | start = idx; | ||
2721 | } else if (sh < -64) | ||
2722 | sh = 0xff - (start - idx); | ||
2723 | else if (sh < 0) { | ||
2724 | sh = start - idx; | ||
2725 | start = idx; | ||
2726 | bitmap = bitmap << sh; | ||
2727 | sh = 0; | ||
2728 | } | ||
2729 | bitmap |= 1ULL << sh; | ||
2730 | D_TX_REPLY("start=%d bitmap=0x%llx\n", start, | ||
2731 | (unsigned long long)bitmap); | ||
2732 | } | ||
2733 | |||
2734 | agg->bitmap = bitmap; | ||
2735 | agg->start_idx = start; | ||
2736 | D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
2737 | agg->frame_count, agg->start_idx, | ||
2738 | (unsigned long long)agg->bitmap); | ||
2739 | |||
2740 | if (bitmap) | ||
2741 | agg->wait_for_ba = 1; | ||
2742 | } | ||
2743 | return 0; | ||
2744 | } | ||
2745 | |||
2746 | /** | ||
2747 | * il4965_hdl_tx - Handle standard (non-aggregation) Tx response | ||
2748 | */ | ||
2749 | static void | ||
2750 | il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) | ||
2751 | { | ||
2752 | struct il_rx_pkt *pkt = rxb_addr(rxb); | ||
2753 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
2754 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
2755 | int idx = SEQ_TO_IDX(sequence); | ||
2756 | struct il_tx_queue *txq = &il->txq[txq_id]; | ||
2757 | struct sk_buff *skb; | ||
2758 | struct ieee80211_hdr *hdr; | ||
2759 | struct ieee80211_tx_info *info; | ||
2760 | struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
2761 | u32 status = le32_to_cpu(tx_resp->u.status); | ||
2762 | int uninitialized_var(tid); | ||
2763 | int sta_id; | ||
2764 | int freed; | ||
2765 | u8 *qc = NULL; | ||
2766 | unsigned long flags; | ||
2767 | |||
2768 | if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { | ||
2769 | IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " | ||
2770 | "is out of range [0-%d] %d %d\n", txq_id, idx, | ||
2771 | txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); | ||
2772 | return; | ||
2773 | } | ||
2774 | |||
2775 | txq->time_stamp = jiffies; | ||
2776 | |||
2777 | skb = txq->skbs[txq->q.read_ptr]; | ||
2778 | info = IEEE80211_SKB_CB(skb); | ||
2779 | memset(&info->status, 0, sizeof(info->status)); | ||
2780 | |||
2781 | hdr = (struct ieee80211_hdr *) skb->data; | ||
2782 | if (ieee80211_is_data_qos(hdr->frame_control)) { | ||
2783 | qc = ieee80211_get_qos_ctl(hdr); | ||
2784 | tid = qc[0] & 0xf; | ||
2785 | } | ||
2786 | |||
2787 | sta_id = il4965_get_ra_sta_id(il, hdr); | ||
2788 | if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { | ||
2789 | IL_ERR("Station not known\n"); | ||
2790 | return; | ||
2791 | } | ||
2792 | |||
2793 | spin_lock_irqsave(&il->sta_lock, flags); | ||
2794 | if (txq->sched_retry) { | ||
2795 | const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); | ||
2796 | struct il_ht_agg *agg = NULL; | ||
2797 | WARN_ON(!qc); | ||
2798 | |||
2799 | agg = &il->stations[sta_id].tid[tid].agg; | ||
2800 | |||
2801 | il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); | ||
2802 | |||
2803 | /* check if BAR is needed */ | ||
2804 | if (tx_resp->frame_count == 1 && | ||
2805 | !il4965_is_tx_success(status)) | ||
2806 | info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; | ||
2807 | |||
2808 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
2809 | idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
2810 | D_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
2811 | "%d idx %d\n", scd_ssn, idx); | ||
2812 | freed = il4965_tx_queue_reclaim(il, txq_id, idx); | ||
2813 | if (qc) | ||
2814 | il4965_free_tfds_in_queue(il, sta_id, tid, | ||
2815 | freed); | ||
2816 | |||
2817 | if (il->mac80211_registered && | ||
2818 | il_queue_space(&txq->q) > txq->q.low_mark && | ||
2819 | agg->state != IL_EMPTYING_HW_QUEUE_DELBA) | ||
2820 | il_wake_queue(il, txq); | ||
2821 | } | ||
2822 | } else { | ||
2823 | info->status.rates[0].count = tx_resp->failure_frame + 1; | ||
2824 | info->flags |= il4965_tx_status_to_mac80211(status); | ||
2825 | il4965_hwrate_to_tx_control(il, | ||
2826 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2827 | info); | ||
2828 | |||
2829 | D_TX_REPLY("TXQ %d status %s (0x%08x) " | ||
2830 | "rate_n_flags 0x%x retries %d\n", txq_id, | ||
2831 | il4965_get_tx_fail_reason(status), status, | ||
2832 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2833 | tx_resp->failure_frame); | ||
2834 | |||
2835 | freed = il4965_tx_queue_reclaim(il, txq_id, idx); | ||
2836 | if (qc && likely(sta_id != IL_INVALID_STATION)) | ||
2837 | il4965_free_tfds_in_queue(il, sta_id, tid, freed); | ||
2838 | else if (sta_id == IL_INVALID_STATION) | ||
2839 | D_TX_REPLY("Station not known\n"); | ||
2840 | |||
2841 | if (il->mac80211_registered && | ||
2842 | il_queue_space(&txq->q) > txq->q.low_mark) | ||
2843 | il_wake_queue(il, txq); | ||
2844 | } | ||
2845 | if (qc && likely(sta_id != IL_INVALID_STATION)) | ||
2846 | il4965_txq_check_empty(il, sta_id, tid, txq_id); | ||
2847 | |||
2848 | il4965_check_abort_status(il, tx_resp->frame_count, status); | ||
2849 | |||
2850 | spin_unlock_irqrestore(&il->sta_lock, flags); | ||
2851 | } | ||
2852 | |||
2551 | /** | 2853 | /** |
2552 | * translate ucode response to mac80211 tx status control values | 2854 | * translate ucode response to mac80211 tx status control values |
2553 | */ | 2855 | */ |
@@ -3868,10 +4170,11 @@ il4965_setup_handlers(struct il_priv *il) | |||
3868 | /* Rx handlers */ | 4170 | /* Rx handlers */ |
3869 | il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; | 4171 | il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; |
3870 | il->handlers[N_RX_MPDU] = il4965_hdl_rx; | 4172 | il->handlers[N_RX_MPDU] = il4965_hdl_rx; |
4173 | il->handlers[N_RX] = il4965_hdl_rx; | ||
3871 | /* block ack */ | 4174 | /* block ack */ |
3872 | il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; | 4175 | il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; |
3873 | /* Set up hardware specific Rx handlers */ | 4176 | /* Tx response */ |
3874 | il->ops->lib->handler_setup(il); | 4177 | il->handlers[C_TX] = il4965_hdl_tx; |
3875 | } | 4178 | } |
3876 | 4179 | ||
3877 | /** | 4180 | /** |
diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index aea84bf4e935..cf49a7af6c6e 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c | |||
@@ -1737,317 +1737,6 @@ il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) | |||
1737 | return (u16) sizeof(struct il4965_addsta_cmd); | 1737 | return (u16) sizeof(struct il4965_addsta_cmd); |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | static inline u32 | ||
1741 | il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) | ||
1742 | { | ||
1743 | return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; | ||
1744 | } | ||
1745 | |||
1746 | static inline u32 | ||
1747 | il4965_tx_status_to_mac80211(u32 status) | ||
1748 | { | ||
1749 | status &= TX_STATUS_MSK; | ||
1750 | |||
1751 | switch (status) { | ||
1752 | case TX_STATUS_SUCCESS: | ||
1753 | case TX_STATUS_DIRECT_DONE: | ||
1754 | return IEEE80211_TX_STAT_ACK; | ||
1755 | case TX_STATUS_FAIL_DEST_PS: | ||
1756 | return IEEE80211_TX_STAT_TX_FILTERED; | ||
1757 | default: | ||
1758 | return 0; | ||
1759 | } | ||
1760 | } | ||
1761 | |||
1762 | static inline bool | ||
1763 | il4965_is_tx_success(u32 status) | ||
1764 | { | ||
1765 | status &= TX_STATUS_MSK; | ||
1766 | return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE); | ||
1767 | } | ||
1768 | |||
1769 | /** | ||
1770 | * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue | ||
1771 | */ | ||
1772 | static int | ||
1773 | il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, | ||
1774 | struct il4965_tx_resp *tx_resp, int txq_id, | ||
1775 | u16 start_idx) | ||
1776 | { | ||
1777 | u16 status; | ||
1778 | struct agg_tx_status *frame_status = tx_resp->u.agg_status; | ||
1779 | struct ieee80211_tx_info *info = NULL; | ||
1780 | struct ieee80211_hdr *hdr = NULL; | ||
1781 | u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
1782 | int i, sh, idx; | ||
1783 | u16 seq; | ||
1784 | if (agg->wait_for_ba) | ||
1785 | D_TX_REPLY("got tx response w/o block-ack\n"); | ||
1786 | |||
1787 | agg->frame_count = tx_resp->frame_count; | ||
1788 | agg->start_idx = start_idx; | ||
1789 | agg->rate_n_flags = rate_n_flags; | ||
1790 | agg->bitmap = 0; | ||
1791 | |||
1792 | /* num frames attempted by Tx command */ | ||
1793 | if (agg->frame_count == 1) { | ||
1794 | /* Only one frame was attempted; no block-ack will arrive */ | ||
1795 | status = le16_to_cpu(frame_status[0].status); | ||
1796 | idx = start_idx; | ||
1797 | |||
1798 | D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
1799 | agg->frame_count, agg->start_idx, idx); | ||
1800 | |||
1801 | info = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]); | ||
1802 | info->status.rates[0].count = tx_resp->failure_frame + 1; | ||
1803 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
1804 | info->flags |= il4965_tx_status_to_mac80211(status); | ||
1805 | il4965_hwrate_to_tx_control(il, rate_n_flags, info); | ||
1806 | |||
1807 | D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, | ||
1808 | tx_resp->failure_frame); | ||
1809 | D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); | ||
1810 | |||
1811 | agg->wait_for_ba = 0; | ||
1812 | } else { | ||
1813 | /* Two or more frames were attempted; expect block-ack */ | ||
1814 | u64 bitmap = 0; | ||
1815 | int start = agg->start_idx; | ||
1816 | struct sk_buff *skb; | ||
1817 | |||
1818 | /* Construct bit-map of pending frames within Tx win */ | ||
1819 | for (i = 0; i < agg->frame_count; i++) { | ||
1820 | u16 sc; | ||
1821 | status = le16_to_cpu(frame_status[i].status); | ||
1822 | seq = le16_to_cpu(frame_status[i].sequence); | ||
1823 | idx = SEQ_TO_IDX(seq); | ||
1824 | txq_id = SEQ_TO_QUEUE(seq); | ||
1825 | |||
1826 | if (status & | ||
1827 | (AGG_TX_STATE_FEW_BYTES_MSK | | ||
1828 | AGG_TX_STATE_ABORT_MSK)) | ||
1829 | continue; | ||
1830 | |||
1831 | D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
1832 | agg->frame_count, txq_id, idx); | ||
1833 | |||
1834 | skb = il->txq[txq_id].skbs[idx]; | ||
1835 | if (WARN_ON_ONCE(skb == NULL)) | ||
1836 | return -1; | ||
1837 | hdr = (struct ieee80211_hdr *) skb->data; | ||
1838 | |||
1839 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
1840 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
1841 | IL_ERR("BUG_ON idx doesn't match seq control" | ||
1842 | " idx=%d, seq_idx=%d, seq=%d\n", idx, | ||
1843 | SEQ_TO_SN(sc), hdr->seq_ctrl); | ||
1844 | return -1; | ||
1845 | } | ||
1846 | |||
1847 | D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, | ||
1848 | SEQ_TO_SN(sc)); | ||
1849 | |||
1850 | sh = idx - start; | ||
1851 | if (sh > 64) { | ||
1852 | sh = (start - idx) + 0xff; | ||
1853 | bitmap = bitmap << sh; | ||
1854 | sh = 0; | ||
1855 | start = idx; | ||
1856 | } else if (sh < -64) | ||
1857 | sh = 0xff - (start - idx); | ||
1858 | else if (sh < 0) { | ||
1859 | sh = start - idx; | ||
1860 | start = idx; | ||
1861 | bitmap = bitmap << sh; | ||
1862 | sh = 0; | ||
1863 | } | ||
1864 | bitmap |= 1ULL << sh; | ||
1865 | D_TX_REPLY("start=%d bitmap=0x%llx\n", start, | ||
1866 | (unsigned long long)bitmap); | ||
1867 | } | ||
1868 | |||
1869 | agg->bitmap = bitmap; | ||
1870 | agg->start_idx = start; | ||
1871 | D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
1872 | agg->frame_count, agg->start_idx, | ||
1873 | (unsigned long long)agg->bitmap); | ||
1874 | |||
1875 | if (bitmap) | ||
1876 | agg->wait_for_ba = 1; | ||
1877 | } | ||
1878 | return 0; | ||
1879 | } | ||
1880 | |||
1881 | static u8 | ||
1882 | il4965_find_station(struct il_priv *il, const u8 * addr) | ||
1883 | { | ||
1884 | int i; | ||
1885 | int start = 0; | ||
1886 | int ret = IL_INVALID_STATION; | ||
1887 | unsigned long flags; | ||
1888 | |||
1889 | if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) | ||
1890 | start = IL_STA_ID; | ||
1891 | |||
1892 | if (is_broadcast_ether_addr(addr)) | ||
1893 | return il->hw_params.bcast_id; | ||
1894 | |||
1895 | spin_lock_irqsave(&il->sta_lock, flags); | ||
1896 | for (i = start; i < il->hw_params.max_stations; i++) | ||
1897 | if (il->stations[i].used && | ||
1898 | (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { | ||
1899 | ret = i; | ||
1900 | goto out; | ||
1901 | } | ||
1902 | |||
1903 | D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); | ||
1904 | |||
1905 | out: | ||
1906 | /* | ||
1907 | * It may be possible that more commands interacting with stations | ||
1908 | * arrive before we completed processing the adding of | ||
1909 | * station | ||
1910 | */ | ||
1911 | if (ret != IL_INVALID_STATION && | ||
1912 | (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || | ||
1913 | ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && | ||
1914 | (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { | ||
1915 | IL_ERR("Requested station info for sta %d before ready.\n", | ||
1916 | ret); | ||
1917 | ret = IL_INVALID_STATION; | ||
1918 | } | ||
1919 | spin_unlock_irqrestore(&il->sta_lock, flags); | ||
1920 | return ret; | ||
1921 | } | ||
1922 | |||
1923 | static int | ||
1924 | il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) | ||
1925 | { | ||
1926 | if (il->iw_mode == NL80211_IFTYPE_STATION) { | ||
1927 | return IL_AP_ID; | ||
1928 | } else { | ||
1929 | u8 *da = ieee80211_get_DA(hdr); | ||
1930 | return il4965_find_station(il, da); | ||
1931 | } | ||
1932 | } | ||
1933 | |||
1934 | /** | ||
1935 | * il4965_hdl_tx - Handle standard (non-aggregation) Tx response | ||
1936 | */ | ||
1937 | static void | ||
1938 | il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) | ||
1939 | { | ||
1940 | struct il_rx_pkt *pkt = rxb_addr(rxb); | ||
1941 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
1942 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
1943 | int idx = SEQ_TO_IDX(sequence); | ||
1944 | struct il_tx_queue *txq = &il->txq[txq_id]; | ||
1945 | struct sk_buff *skb; | ||
1946 | struct ieee80211_hdr *hdr; | ||
1947 | struct ieee80211_tx_info *info; | ||
1948 | struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
1949 | u32 status = le32_to_cpu(tx_resp->u.status); | ||
1950 | int uninitialized_var(tid); | ||
1951 | int sta_id; | ||
1952 | int freed; | ||
1953 | u8 *qc = NULL; | ||
1954 | unsigned long flags; | ||
1955 | |||
1956 | if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { | ||
1957 | IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " | ||
1958 | "is out of range [0-%d] %d %d\n", txq_id, idx, | ||
1959 | txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); | ||
1960 | return; | ||
1961 | } | ||
1962 | |||
1963 | txq->time_stamp = jiffies; | ||
1964 | |||
1965 | skb = txq->skbs[txq->q.read_ptr]; | ||
1966 | info = IEEE80211_SKB_CB(skb); | ||
1967 | memset(&info->status, 0, sizeof(info->status)); | ||
1968 | |||
1969 | hdr = (struct ieee80211_hdr *) skb->data; | ||
1970 | if (ieee80211_is_data_qos(hdr->frame_control)) { | ||
1971 | qc = ieee80211_get_qos_ctl(hdr); | ||
1972 | tid = qc[0] & 0xf; | ||
1973 | } | ||
1974 | |||
1975 | sta_id = il4965_get_ra_sta_id(il, hdr); | ||
1976 | if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { | ||
1977 | IL_ERR("Station not known\n"); | ||
1978 | return; | ||
1979 | } | ||
1980 | |||
1981 | spin_lock_irqsave(&il->sta_lock, flags); | ||
1982 | if (txq->sched_retry) { | ||
1983 | const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); | ||
1984 | struct il_ht_agg *agg = NULL; | ||
1985 | WARN_ON(!qc); | ||
1986 | |||
1987 | agg = &il->stations[sta_id].tid[tid].agg; | ||
1988 | |||
1989 | il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); | ||
1990 | |||
1991 | /* check if BAR is needed */ | ||
1992 | if ((tx_resp->frame_count == 1) && | ||
1993 | !il4965_is_tx_success(status)) | ||
1994 | info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; | ||
1995 | |||
1996 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
1997 | idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
1998 | D_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
1999 | "%d idx %d\n", scd_ssn, idx); | ||
2000 | freed = il4965_tx_queue_reclaim(il, txq_id, idx); | ||
2001 | if (qc) | ||
2002 | il4965_free_tfds_in_queue(il, sta_id, tid, | ||
2003 | freed); | ||
2004 | |||
2005 | if (il->mac80211_registered && | ||
2006 | il_queue_space(&txq->q) > txq->q.low_mark && | ||
2007 | agg->state != IL_EMPTYING_HW_QUEUE_DELBA) | ||
2008 | il_wake_queue(il, txq); | ||
2009 | } | ||
2010 | } else { | ||
2011 | info->status.rates[0].count = tx_resp->failure_frame + 1; | ||
2012 | info->flags |= il4965_tx_status_to_mac80211(status); | ||
2013 | il4965_hwrate_to_tx_control(il, | ||
2014 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2015 | info); | ||
2016 | |||
2017 | D_TX_REPLY("TXQ %d status %s (0x%08x) " | ||
2018 | "rate_n_flags 0x%x retries %d\n", txq_id, | ||
2019 | il4965_get_tx_fail_reason(status), status, | ||
2020 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2021 | tx_resp->failure_frame); | ||
2022 | |||
2023 | freed = il4965_tx_queue_reclaim(il, txq_id, idx); | ||
2024 | if (qc && likely(sta_id != IL_INVALID_STATION)) | ||
2025 | il4965_free_tfds_in_queue(il, sta_id, tid, freed); | ||
2026 | else if (sta_id == IL_INVALID_STATION) | ||
2027 | D_TX_REPLY("Station not known\n"); | ||
2028 | |||
2029 | if (il->mac80211_registered && | ||
2030 | il_queue_space(&txq->q) > txq->q.low_mark) | ||
2031 | il_wake_queue(il, txq); | ||
2032 | } | ||
2033 | if (qc && likely(sta_id != IL_INVALID_STATION)) | ||
2034 | il4965_txq_check_empty(il, sta_id, tid, txq_id); | ||
2035 | |||
2036 | il4965_check_abort_status(il, tx_resp->frame_count, status); | ||
2037 | |||
2038 | spin_unlock_irqrestore(&il->sta_lock, flags); | ||
2039 | } | ||
2040 | |||
2041 | /* Set up 4965-specific Rx frame reply handlers */ | ||
2042 | static void | ||
2043 | il4965_handler_setup(struct il_priv *il) | ||
2044 | { | ||
2045 | /* Legacy Rx frames */ | ||
2046 | il->handlers[N_RX] = il4965_hdl_rx; | ||
2047 | /* Tx response */ | ||
2048 | il->handlers[C_TX] = il4965_hdl_tx; | ||
2049 | } | ||
2050 | |||
2051 | static struct il_hcmd_ops il4965_hcmd = { | 1740 | static struct il_hcmd_ops il4965_hcmd = { |
2052 | .rxon_assoc = il4965_send_rxon_assoc, | 1741 | .rxon_assoc = il4965_send_rxon_assoc, |
2053 | .commit_rxon = il4965_commit_rxon, | 1742 | .commit_rxon = il4965_commit_rxon, |
@@ -2205,7 +1894,6 @@ static struct il_lib_ops il4965_lib = { | |||
2205 | .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, | 1894 | .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, |
2206 | .txq_free_tfd = il4965_hw_txq_free_tfd, | 1895 | .txq_free_tfd = il4965_hw_txq_free_tfd, |
2207 | .txq_init = il4965_hw_tx_queue_init, | 1896 | .txq_init = il4965_hw_tx_queue_init, |
2208 | .handler_setup = il4965_handler_setup, | ||
2209 | .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, | 1897 | .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, |
2210 | .init_alive_start = il4965_init_alive_start, | 1898 | .init_alive_start = il4965_init_alive_start, |
2211 | .load_ucode = il4965_load_bsm, | 1899 | .load_ucode = il4965_load_bsm, |
diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 83ab60496388..befa7e60e956 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h | |||
@@ -67,8 +67,6 @@ void il4965_rx_replenish_now(struct il_priv *il); | |||
67 | void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); | 67 | void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); |
68 | int il4965_rxq_stop(struct il_priv *il); | 68 | int il4965_rxq_stop(struct il_priv *il); |
69 | int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); | 69 | int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); |
70 | void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb); | ||
71 | void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb); | ||
72 | void il4965_rx_handle(struct il_priv *il); | 70 | void il4965_rx_handle(struct il_priv *il); |
73 | 71 | ||
74 | /* tx */ | 72 | /* tx */ |
@@ -84,7 +82,6 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, | |||
84 | int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, | 82 | int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, |
85 | struct ieee80211_sta *sta, u16 tid); | 83 | struct ieee80211_sta *sta, u16 tid); |
86 | int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); | 84 | int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); |
87 | void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); | ||
88 | int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); | 85 | int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); |
89 | void il4965_hw_txq_ctx_free(struct il_priv *il); | 86 | void il4965_hw_txq_ctx_free(struct il_priv *il); |
90 | int il4965_txq_ctx_alloc(struct il_priv *il); | 87 | int il4965_txq_ctx_alloc(struct il_priv *il); |
@@ -106,12 +103,6 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); | |||
106 | void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, | 103 | void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, |
107 | int tx_fifo_id, int scd_retry); | 104 | int tx_fifo_id, int scd_retry); |
108 | 105 | ||
109 | /* rx */ | ||
110 | void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb); | ||
111 | bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); | ||
112 | void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); | ||
113 | void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); | ||
114 | |||
115 | /* scan */ | 106 | /* scan */ |
116 | int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); | 107 | int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); |
117 | 108 | ||
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 37bc40636c1e..1c0d969e9cf7 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h | |||
@@ -1600,8 +1600,6 @@ struct il_lib_ops { | |||
1600 | u16 len, u8 reset, u8 pad); | 1600 | u16 len, u8 reset, u8 pad); |
1601 | void (*txq_free_tfd) (struct il_priv *il, struct il_tx_queue *txq); | 1601 | void (*txq_free_tfd) (struct il_priv *il, struct il_tx_queue *txq); |
1602 | int (*txq_init) (struct il_priv *il, struct il_tx_queue *txq); | 1602 | int (*txq_init) (struct il_priv *il, struct il_tx_queue *txq); |
1603 | /* setup Rx handler */ | ||
1604 | void (*handler_setup) (struct il_priv *il); | ||
1605 | /* alive notification after init uCode load */ | 1603 | /* alive notification after init uCode load */ |
1606 | void (*init_alive_start) (struct il_priv *il); | 1604 | void (*init_alive_start) (struct il_priv *il); |
1607 | /* check validity of rtc data address */ | 1605 | /* check validity of rtc data address */ |