mac80211: rt2x00: import upstream changes and rebase our patches
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 020-10-rt2x00-separte-filling-tx-status-from-rt2x00lib_txdo.patch
1 From 5edb05afebba8f488a30db29550e55c42eea6d6a Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Wed, 15 Feb 2017 10:25:06 +0100
4 Subject: [PATCH 10/19] rt2x00: separte filling tx status from rt2x00lib_txdone
5
6 This makes rt2x00lib_txdone a bit simpler and will allow to reuse code
7 in different variant of txdone which I'm preparing.
8
9 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
10 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
11 ---
12 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 141 +++++++++++++------------
13 1 file changed, 76 insertions(+), 65 deletions(-)
14
15 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
16 index dd6678109b7e..b5d90fefc96b 100644
17 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
18 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
19 @@ -313,73 +313,14 @@ static inline int rt2x00lib_txdone_bar_status(struct queue_entry *entry)
20 return ret;
21 }
22
23 -void rt2x00lib_txdone(struct queue_entry *entry,
24 - struct txdone_entry_desc *txdesc)
25 +static void rt2x00lib_fill_tx_status(struct rt2x00_dev *rt2x00dev,
26 + struct ieee80211_tx_info *tx_info,
27 + struct skb_frame_desc *skbdesc,
28 + struct txdone_entry_desc *txdesc,
29 + bool success)
30 {
31 - struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
32 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
33 - struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
34 - unsigned int header_length, i;
35 u8 rate_idx, rate_flags, retry_rates;
36 - u8 skbdesc_flags = skbdesc->flags;
37 - bool success;
38 -
39 - /*
40 - * Unmap the skb.
41 - */
42 - rt2x00queue_unmap_skb(entry);
43 -
44 - /*
45 - * Remove the extra tx headroom from the skb.
46 - */
47 - skb_pull(entry->skb, rt2x00dev->extra_tx_headroom);
48 -
49 - /*
50 - * Signal that the TX descriptor is no longer in the skb.
51 - */
52 - skbdesc->flags &= ~SKBDESC_DESC_IN_SKB;
53 -
54 - /*
55 - * Determine the length of 802.11 header.
56 - */
57 - header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
58 -
59 - /*
60 - * Remove L2 padding which was added during
61 - */
62 - if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_L2PAD))
63 - rt2x00queue_remove_l2pad(entry->skb, header_length);
64 -
65 - /*
66 - * If the IV/EIV data was stripped from the frame before it was
67 - * passed to the hardware, we should now reinsert it again because
68 - * mac80211 will expect the same data to be present it the
69 - * frame as it was passed to us.
70 - */
71 - if (rt2x00_has_cap_hw_crypto(rt2x00dev))
72 - rt2x00crypto_tx_insert_iv(entry->skb, header_length);
73 -
74 - /*
75 - * Send frame to debugfs immediately, after this call is completed
76 - * we are going to overwrite the skb->cb array.
77 - */
78 - rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry);
79 -
80 - /*
81 - * Determine if the frame has been successfully transmitted and
82 - * remove BARs from our check list while checking for their
83 - * TX status.
84 - */
85 - success =
86 - rt2x00lib_txdone_bar_status(entry) ||
87 - test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
88 - test_bit(TXDONE_UNKNOWN, &txdesc->flags);
89 -
90 - /*
91 - * Update TX statistics.
92 - */
93 - rt2x00dev->link.qual.tx_success += success;
94 - rt2x00dev->link.qual.tx_failed += !success;
95 + int i;
96
97 rate_idx = skbdesc->tx_rate_idx;
98 rate_flags = skbdesc->tx_rate_flags;
99 @@ -448,6 +389,76 @@ void rt2x00lib_txdone(struct queue_entry *entry,
100 else
101 rt2x00dev->low_level_stats.dot11RTSFailureCount++;
102 }
103 +}
104 +
105 +void rt2x00lib_txdone(struct queue_entry *entry,
106 + struct txdone_entry_desc *txdesc)
107 +{
108 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
109 + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
110 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
111 + u8 skbdesc_flags = skbdesc->flags;
112 + unsigned int header_length;
113 + bool success;
114 +
115 + /*
116 + * Unmap the skb.
117 + */
118 + rt2x00queue_unmap_skb(entry);
119 +
120 + /*
121 + * Remove the extra tx headroom from the skb.
122 + */
123 + skb_pull(entry->skb, rt2x00dev->extra_tx_headroom);
124 +
125 + /*
126 + * Signal that the TX descriptor is no longer in the skb.
127 + */
128 + skbdesc->flags &= ~SKBDESC_DESC_IN_SKB;
129 +
130 + /*
131 + * Determine the length of 802.11 header.
132 + */
133 + header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
134 +
135 + /*
136 + * Remove L2 padding which was added during
137 + */
138 + if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_L2PAD))
139 + rt2x00queue_remove_l2pad(entry->skb, header_length);
140 +
141 + /*
142 + * If the IV/EIV data was stripped from the frame before it was
143 + * passed to the hardware, we should now reinsert it again because
144 + * mac80211 will expect the same data to be present it the
145 + * frame as it was passed to us.
146 + */
147 + if (rt2x00_has_cap_hw_crypto(rt2x00dev))
148 + rt2x00crypto_tx_insert_iv(entry->skb, header_length);
149 +
150 + /*
151 + * Send frame to debugfs immediately, after this call is completed
152 + * we are going to overwrite the skb->cb array.
153 + */
154 + rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry);
155 +
156 + /*
157 + * Determine if the frame has been successfully transmitted and
158 + * remove BARs from our check list while checking for their
159 + * TX status.
160 + */
161 + success =
162 + rt2x00lib_txdone_bar_status(entry) ||
163 + test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
164 + test_bit(TXDONE_UNKNOWN, &txdesc->flags);
165 +
166 + /*
167 + * Update TX statistics.
168 + */
169 + rt2x00dev->link.qual.tx_success += success;
170 + rt2x00dev->link.qual.tx_failed += !success;
171 +
172 + rt2x00lib_fill_tx_status(rt2x00dev, tx_info, skbdesc, txdesc, success);
173
174 /*
175 * Only send the status report to mac80211 when it's a frame
176 --
177 2.12.1
178