diff options
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 683 |
1 files changed, 299 insertions, 384 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 0941e5d6a522..6d9ae67c27ca 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -61,22 +61,147 @@ static inline int should_drop_frame(struct ieee80211_rx_status *status, | |||
61 | int present_fcs_len, | 61 | int present_fcs_len, |
62 | int radiotap_len) | 62 | int radiotap_len) |
63 | { | 63 | { |
64 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 64 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
65 | 65 | ||
66 | if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) | 66 | if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) |
67 | return 1; | 67 | return 1; |
68 | if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len)) | 68 | if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len)) |
69 | return 1; | 69 | return 1; |
70 | if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == | 70 | if (ieee80211_is_ctl(hdr->frame_control) && |
71 | cpu_to_le16(IEEE80211_FTYPE_CTL)) && | 71 | !ieee80211_is_pspoll(hdr->frame_control) && |
72 | ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) != | 72 | !ieee80211_is_back_req(hdr->frame_control)) |
73 | cpu_to_le16(IEEE80211_STYPE_PSPOLL)) && | ||
74 | ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) != | ||
75 | cpu_to_le16(IEEE80211_STYPE_BACK_REQ))) | ||
76 | return 1; | 73 | return 1; |
77 | return 0; | 74 | return 0; |
78 | } | 75 | } |
79 | 76 | ||
77 | static int | ||
78 | ieee80211_rx_radiotap_len(struct ieee80211_local *local, | ||
79 | struct ieee80211_rx_status *status) | ||
80 | { | ||
81 | int len; | ||
82 | |||
83 | /* always present fields */ | ||
84 | len = sizeof(struct ieee80211_radiotap_header) + 9; | ||
85 | |||
86 | if (status->flag & RX_FLAG_TSFT) | ||
87 | len += 8; | ||
88 | if (local->hw.flags & IEEE80211_HW_SIGNAL_DB || | ||
89 | local->hw.flags & IEEE80211_HW_SIGNAL_DBM) | ||
90 | len += 1; | ||
91 | if (local->hw.flags & IEEE80211_HW_NOISE_DBM) | ||
92 | len += 1; | ||
93 | |||
94 | if (len & 1) /* padding for RX_FLAGS if necessary */ | ||
95 | len++; | ||
96 | |||
97 | /* make sure radiotap starts at a naturally aligned address */ | ||
98 | if (len % 8) | ||
99 | len = roundup(len, 8); | ||
100 | |||
101 | return len; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * ieee80211_add_rx_radiotap_header - add radiotap header | ||
106 | * | ||
107 | * add a radiotap header containing all the fields which the hardware provided. | ||
108 | */ | ||
109 | static void | ||
110 | ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | ||
111 | struct sk_buff *skb, | ||
112 | struct ieee80211_rx_status *status, | ||
113 | struct ieee80211_rate *rate, | ||
114 | int rtap_len) | ||
115 | { | ||
116 | struct ieee80211_radiotap_header *rthdr; | ||
117 | unsigned char *pos; | ||
118 | |||
119 | rthdr = (struct ieee80211_radiotap_header *)skb_push(skb, rtap_len); | ||
120 | memset(rthdr, 0, rtap_len); | ||
121 | |||
122 | /* radiotap header, set always present flags */ | ||
123 | rthdr->it_present = | ||
124 | cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | | ||
125 | (1 << IEEE80211_RADIOTAP_RATE) | | ||
126 | (1 << IEEE80211_RADIOTAP_CHANNEL) | | ||
127 | (1 << IEEE80211_RADIOTAP_ANTENNA) | | ||
128 | (1 << IEEE80211_RADIOTAP_RX_FLAGS)); | ||
129 | rthdr->it_len = cpu_to_le16(rtap_len); | ||
130 | |||
131 | pos = (unsigned char *)(rthdr+1); | ||
132 | |||
133 | /* the order of the following fields is important */ | ||
134 | |||
135 | /* IEEE80211_RADIOTAP_TSFT */ | ||
136 | if (status->flag & RX_FLAG_TSFT) { | ||
137 | *(__le64 *)pos = cpu_to_le64(status->mactime); | ||
138 | rthdr->it_present |= | ||
139 | cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); | ||
140 | pos += 8; | ||
141 | } | ||
142 | |||
143 | /* IEEE80211_RADIOTAP_FLAGS */ | ||
144 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) | ||
145 | *pos |= IEEE80211_RADIOTAP_F_FCS; | ||
146 | pos++; | ||
147 | |||
148 | /* IEEE80211_RADIOTAP_RATE */ | ||
149 | *pos = rate->bitrate / 5; | ||
150 | pos++; | ||
151 | |||
152 | /* IEEE80211_RADIOTAP_CHANNEL */ | ||
153 | *(__le16 *)pos = cpu_to_le16(status->freq); | ||
154 | pos += 2; | ||
155 | if (status->band == IEEE80211_BAND_5GHZ) | ||
156 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM | | ||
157 | IEEE80211_CHAN_5GHZ); | ||
158 | else | ||
159 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_DYN | | ||
160 | IEEE80211_CHAN_2GHZ); | ||
161 | pos += 2; | ||
162 | |||
163 | /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ | ||
164 | if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { | ||
165 | *pos = status->signal; | ||
166 | rthdr->it_present |= | ||
167 | cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL); | ||
168 | pos++; | ||
169 | } | ||
170 | |||
171 | /* IEEE80211_RADIOTAP_DBM_ANTNOISE */ | ||
172 | if (local->hw.flags & IEEE80211_HW_NOISE_DBM) { | ||
173 | *pos = status->noise; | ||
174 | rthdr->it_present |= | ||
175 | cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTNOISE); | ||
176 | pos++; | ||
177 | } | ||
178 | |||
179 | /* IEEE80211_RADIOTAP_LOCK_QUALITY is missing */ | ||
180 | |||
181 | /* IEEE80211_RADIOTAP_ANTENNA */ | ||
182 | *pos = status->antenna; | ||
183 | pos++; | ||
184 | |||
185 | /* IEEE80211_RADIOTAP_DB_ANTSIGNAL */ | ||
186 | if (local->hw.flags & IEEE80211_HW_SIGNAL_DB) { | ||
187 | *pos = status->signal; | ||
188 | rthdr->it_present |= | ||
189 | cpu_to_le32(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL); | ||
190 | pos++; | ||
191 | } | ||
192 | |||
193 | /* IEEE80211_RADIOTAP_DB_ANTNOISE is not used */ | ||
194 | |||
195 | /* IEEE80211_RADIOTAP_RX_FLAGS */ | ||
196 | /* ensure 2 byte alignment for the 2 byte field as required */ | ||
197 | if ((pos - (unsigned char *)rthdr) & 1) | ||
198 | pos++; | ||
199 | /* FIXME: when radiotap gets a 'bad PLCP' flag use it here */ | ||
200 | if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) | ||
201 | *(__le16 *)pos |= cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS); | ||
202 | pos += 2; | ||
203 | } | ||
204 | |||
80 | /* | 205 | /* |
81 | * This function copies a received frame to all monitor interfaces and | 206 | * This function copies a received frame to all monitor interfaces and |
82 | * returns a cleaned-up SKB that no longer includes the FCS nor the | 207 | * returns a cleaned-up SKB that no longer includes the FCS nor the |
@@ -89,17 +214,6 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
89 | { | 214 | { |
90 | struct ieee80211_sub_if_data *sdata; | 215 | struct ieee80211_sub_if_data *sdata; |
91 | int needed_headroom = 0; | 216 | int needed_headroom = 0; |
92 | struct ieee80211_radiotap_header *rthdr; | ||
93 | __le64 *rttsft = NULL; | ||
94 | struct ieee80211_rtap_fixed_data { | ||
95 | u8 flags; | ||
96 | u8 rate; | ||
97 | __le16 chan_freq; | ||
98 | __le16 chan_flags; | ||
99 | u8 antsignal; | ||
100 | u8 padding_for_rxflags; | ||
101 | __le16 rx_flags; | ||
102 | } __attribute__ ((packed)) *rtfixed; | ||
103 | struct sk_buff *skb, *skb2; | 217 | struct sk_buff *skb, *skb2; |
104 | struct net_device *prev_dev = NULL; | 218 | struct net_device *prev_dev = NULL; |
105 | int present_fcs_len = 0; | 219 | int present_fcs_len = 0; |
@@ -116,8 +230,8 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
116 | if (status->flag & RX_FLAG_RADIOTAP) | 230 | if (status->flag & RX_FLAG_RADIOTAP) |
117 | rtap_len = ieee80211_get_radiotap_len(origskb->data); | 231 | rtap_len = ieee80211_get_radiotap_len(origskb->data); |
118 | else | 232 | else |
119 | /* room for radiotap header, always present fields and TSFT */ | 233 | /* room for the radiotap header based on driver features */ |
120 | needed_headroom = sizeof(*rthdr) + sizeof(*rtfixed) + 8; | 234 | needed_headroom = ieee80211_rx_radiotap_len(local, status); |
121 | 235 | ||
122 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) | 236 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) |
123 | present_fcs_len = FCS_LEN; | 237 | present_fcs_len = FCS_LEN; |
@@ -163,55 +277,9 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
163 | } | 277 | } |
164 | 278 | ||
165 | /* if necessary, prepend radiotap information */ | 279 | /* if necessary, prepend radiotap information */ |
166 | if (!(status->flag & RX_FLAG_RADIOTAP)) { | 280 | if (!(status->flag & RX_FLAG_RADIOTAP)) |
167 | rtfixed = (void *) skb_push(skb, sizeof(*rtfixed)); | 281 | ieee80211_add_rx_radiotap_header(local, skb, status, rate, |
168 | rtap_len = sizeof(*rthdr) + sizeof(*rtfixed); | 282 | needed_headroom); |
169 | if (status->flag & RX_FLAG_TSFT) { | ||
170 | rttsft = (void *) skb_push(skb, sizeof(*rttsft)); | ||
171 | rtap_len += 8; | ||
172 | } | ||
173 | rthdr = (void *) skb_push(skb, sizeof(*rthdr)); | ||
174 | memset(rthdr, 0, sizeof(*rthdr)); | ||
175 | memset(rtfixed, 0, sizeof(*rtfixed)); | ||
176 | rthdr->it_present = | ||
177 | cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | | ||
178 | (1 << IEEE80211_RADIOTAP_RATE) | | ||
179 | (1 << IEEE80211_RADIOTAP_CHANNEL) | | ||
180 | (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | | ||
181 | (1 << IEEE80211_RADIOTAP_RX_FLAGS)); | ||
182 | rtfixed->flags = 0; | ||
183 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) | ||
184 | rtfixed->flags |= IEEE80211_RADIOTAP_F_FCS; | ||
185 | |||
186 | if (rttsft) { | ||
187 | *rttsft = cpu_to_le64(status->mactime); | ||
188 | rthdr->it_present |= | ||
189 | cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); | ||
190 | } | ||
191 | |||
192 | /* FIXME: when radiotap gets a 'bad PLCP' flag use it here */ | ||
193 | rtfixed->rx_flags = 0; | ||
194 | if (status->flag & | ||
195 | (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) | ||
196 | rtfixed->rx_flags |= | ||
197 | cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS); | ||
198 | |||
199 | rtfixed->rate = rate->bitrate / 5; | ||
200 | |||
201 | rtfixed->chan_freq = cpu_to_le16(status->freq); | ||
202 | |||
203 | if (status->band == IEEE80211_BAND_5GHZ) | ||
204 | rtfixed->chan_flags = | ||
205 | cpu_to_le16(IEEE80211_CHAN_OFDM | | ||
206 | IEEE80211_CHAN_5GHZ); | ||
207 | else | ||
208 | rtfixed->chan_flags = | ||
209 | cpu_to_le16(IEEE80211_CHAN_DYN | | ||
210 | IEEE80211_CHAN_2GHZ); | ||
211 | |||
212 | rtfixed->antsignal = status->ssi; | ||
213 | rthdr->it_len = cpu_to_le16(rtap_len); | ||
214 | } | ||
215 | 283 | ||
216 | skb_reset_mac_header(skb); | 284 | skb_reset_mac_header(skb); |
217 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 285 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
@@ -253,33 +321,33 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
253 | 321 | ||
254 | static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | 322 | static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) |
255 | { | 323 | { |
256 | u8 *data = rx->skb->data; | 324 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
257 | int tid; | 325 | int tid; |
258 | 326 | ||
259 | /* does the frame have a qos control field? */ | 327 | /* does the frame have a qos control field? */ |
260 | if (WLAN_FC_IS_QOS_DATA(rx->fc)) { | 328 | if (ieee80211_is_data_qos(hdr->frame_control)) { |
261 | u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN; | 329 | u8 *qc = ieee80211_get_qos_ctl(hdr); |
262 | /* frame has qos control */ | 330 | /* frame has qos control */ |
263 | tid = qc[0] & QOS_CONTROL_TID_MASK; | 331 | tid = *qc & IEEE80211_QOS_CTL_TID_MASK; |
264 | if (qc[0] & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT) | 332 | if (*qc & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT) |
265 | rx->flags |= IEEE80211_RX_AMSDU; | 333 | rx->flags |= IEEE80211_RX_AMSDU; |
266 | else | 334 | else |
267 | rx->flags &= ~IEEE80211_RX_AMSDU; | 335 | rx->flags &= ~IEEE80211_RX_AMSDU; |
268 | } else { | 336 | } else { |
269 | if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) { | 337 | /* |
270 | /* Separate TID for management frames */ | 338 | * IEEE 802.11-2007, 7.1.3.4.1 ("Sequence Number field"): |
271 | tid = NUM_RX_DATA_QUEUES - 1; | 339 | * |
272 | } else { | 340 | * Sequence numbers for management frames, QoS data |
273 | /* no qos control present */ | 341 | * frames with a broadcast/multicast address in the |
274 | tid = 0; /* 802.1d - Best Effort */ | 342 | * Address 1 field, and all non-QoS data frames sent |
275 | } | 343 | * by QoS STAs are assigned using an additional single |
344 | * modulo-4096 counter, [...] | ||
345 | * | ||
346 | * We also use that counter for non-QoS STAs. | ||
347 | */ | ||
348 | tid = NUM_RX_DATA_QUEUES - 1; | ||
276 | } | 349 | } |
277 | 350 | ||
278 | I802_DEBUG_INC(rx->local->wme_rx_queue[tid]); | ||
279 | /* only a debug counter, sta might not be assigned properly yet */ | ||
280 | if (rx->sta) | ||
281 | I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]); | ||
282 | |||
283 | rx->queue = tid; | 351 | rx->queue = tid; |
284 | /* Set skb->priority to 1d tag if highest order bit of TID is not set. | 352 | /* Set skb->priority to 1d tag if highest order bit of TID is not set. |
285 | * For now, set skb->priority to 0 for other cases. */ | 353 | * For now, set skb->priority to 0 for other cases. */ |
@@ -289,9 +357,10 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | |||
289 | static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx) | 357 | static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx) |
290 | { | 358 | { |
291 | #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT | 359 | #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT |
360 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | ||
292 | int hdrlen; | 361 | int hdrlen; |
293 | 362 | ||
294 | if (!WLAN_FC_DATA_PRESENT(rx->fc)) | 363 | if (!ieee80211_is_data_present(hdr->frame_control)) |
295 | return; | 364 | return; |
296 | 365 | ||
297 | /* | 366 | /* |
@@ -313,7 +382,7 @@ static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx) | |||
313 | * header and the payload is not supported, the driver is required | 382 | * header and the payload is not supported, the driver is required |
314 | * to move the 802.11 header further back in that case. | 383 | * to move the 802.11 header further back in that case. |
315 | */ | 384 | */ |
316 | hdrlen = ieee80211_get_hdrlen(rx->fc); | 385 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
317 | if (rx->flags & IEEE80211_RX_AMSDU) | 386 | if (rx->flags & IEEE80211_RX_AMSDU) |
318 | hdrlen += ETH_HLEN; | 387 | hdrlen += ETH_HLEN; |
319 | WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3); | 388 | WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3); |
@@ -321,51 +390,9 @@ static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx) | |||
321 | } | 390 | } |
322 | 391 | ||
323 | 392 | ||
324 | static u32 ieee80211_rx_load_stats(struct ieee80211_local *local, | ||
325 | struct sk_buff *skb, | ||
326 | struct ieee80211_rx_status *status, | ||
327 | struct ieee80211_rate *rate) | ||
328 | { | ||
329 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
330 | u32 load = 0, hdrtime; | ||
331 | |||
332 | /* Estimate total channel use caused by this frame */ | ||
333 | |||
334 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, | ||
335 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | ||
336 | |||
337 | if (status->band == IEEE80211_BAND_5GHZ || | ||
338 | (status->band == IEEE80211_BAND_5GHZ && | ||
339 | rate->flags & IEEE80211_RATE_ERP_G)) | ||
340 | hdrtime = CHAN_UTIL_HDR_SHORT; | ||
341 | else | ||
342 | hdrtime = CHAN_UTIL_HDR_LONG; | ||
343 | |||
344 | load = hdrtime; | ||
345 | if (!is_multicast_ether_addr(hdr->addr1)) | ||
346 | load += hdrtime; | ||
347 | |||
348 | /* TODO: optimise again */ | ||
349 | load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; | ||
350 | |||
351 | /* Divide channel_use by 8 to avoid wrapping around the counter */ | ||
352 | load >>= CHAN_UTIL_SHIFT; | ||
353 | |||
354 | return load; | ||
355 | } | ||
356 | |||
357 | /* rx handlers */ | 393 | /* rx handlers */ |
358 | 394 | ||
359 | static ieee80211_rx_result | 395 | static ieee80211_rx_result debug_noinline |
360 | ieee80211_rx_h_if_stats(struct ieee80211_rx_data *rx) | ||
361 | { | ||
362 | if (rx->sta) | ||
363 | rx->sta->channel_use_raw += rx->load; | ||
364 | rx->sdata->channel_use_raw += rx->load; | ||
365 | return RX_CONTINUE; | ||
366 | } | ||
367 | |||
368 | static ieee80211_rx_result | ||
369 | ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) | 396 | ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) |
370 | { | 397 | { |
371 | struct ieee80211_local *local = rx->local; | 398 | struct ieee80211_local *local = rx->local; |
@@ -394,14 +421,11 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) | |||
394 | static ieee80211_rx_result | 421 | static ieee80211_rx_result |
395 | ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | 422 | ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) |
396 | { | 423 | { |
397 | int hdrlen = ieee80211_get_hdrlen(rx->fc); | 424 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
398 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 425 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
399 | 426 | ||
400 | #define msh_h_get(h, l) ((struct ieee80211s_hdr *) ((u8 *)h + l)) | 427 | if (ieee80211_is_data(hdr->frame_control)) { |
401 | 428 | if (!ieee80211_has_a4(hdr->frame_control)) | |
402 | if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) { | ||
403 | if (!((rx->fc & IEEE80211_FCTL_FROMDS) && | ||
404 | (rx->fc & IEEE80211_FCTL_TODS))) | ||
405 | return RX_DROP_MONITOR; | 429 | return RX_DROP_MONITOR; |
406 | if (memcmp(hdr->addr4, rx->dev->dev_addr, ETH_ALEN) == 0) | 430 | if (memcmp(hdr->addr4, rx->dev->dev_addr, ETH_ALEN) == 0) |
407 | return RX_DROP_MONITOR; | 431 | return RX_DROP_MONITOR; |
@@ -414,27 +438,30 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
414 | if (!rx->sta || sta_plink_state(rx->sta) != PLINK_ESTAB) { | 438 | if (!rx->sta || sta_plink_state(rx->sta) != PLINK_ESTAB) { |
415 | struct ieee80211_mgmt *mgmt; | 439 | struct ieee80211_mgmt *mgmt; |
416 | 440 | ||
417 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT) | 441 | if (!ieee80211_is_mgmt(hdr->frame_control)) |
418 | return RX_DROP_MONITOR; | 442 | return RX_DROP_MONITOR; |
419 | 443 | ||
420 | switch (rx->fc & IEEE80211_FCTL_STYPE) { | 444 | if (ieee80211_is_action(hdr->frame_control)) { |
421 | case IEEE80211_STYPE_ACTION: | ||
422 | mgmt = (struct ieee80211_mgmt *)hdr; | 445 | mgmt = (struct ieee80211_mgmt *)hdr; |
423 | if (mgmt->u.action.category != PLINK_CATEGORY) | 446 | if (mgmt->u.action.category != PLINK_CATEGORY) |
424 | return RX_DROP_MONITOR; | 447 | return RX_DROP_MONITOR; |
425 | /* fall through on else */ | ||
426 | case IEEE80211_STYPE_PROBE_REQ: | ||
427 | case IEEE80211_STYPE_PROBE_RESP: | ||
428 | case IEEE80211_STYPE_BEACON: | ||
429 | return RX_CONTINUE; | 448 | return RX_CONTINUE; |
430 | break; | ||
431 | default: | ||
432 | return RX_DROP_MONITOR; | ||
433 | } | 449 | } |
434 | 450 | ||
435 | } else if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | 451 | if (ieee80211_is_probe_req(hdr->frame_control) || |
436 | is_multicast_ether_addr(hdr->addr1) && | 452 | ieee80211_is_probe_resp(hdr->frame_control) || |
437 | mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->dev)) | 453 | ieee80211_is_beacon(hdr->frame_control)) |
454 | return RX_CONTINUE; | ||
455 | |||
456 | return RX_DROP_MONITOR; | ||
457 | |||
458 | } | ||
459 | |||
460 | #define msh_h_get(h, l) ((struct ieee80211s_hdr *) ((u8 *)h + l)) | ||
461 | |||
462 | if (ieee80211_is_data(hdr->frame_control) && | ||
463 | is_multicast_ether_addr(hdr->addr1) && | ||
464 | mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->dev)) | ||
438 | return RX_DROP_MONITOR; | 465 | return RX_DROP_MONITOR; |
439 | #undef msh_h_get | 466 | #undef msh_h_get |
440 | 467 | ||
@@ -442,16 +469,14 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
442 | } | 469 | } |
443 | 470 | ||
444 | 471 | ||
445 | static ieee80211_rx_result | 472 | static ieee80211_rx_result debug_noinline |
446 | ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | 473 | ieee80211_rx_h_check(struct ieee80211_rx_data *rx) |
447 | { | 474 | { |
448 | struct ieee80211_hdr *hdr; | 475 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
449 | |||
450 | hdr = (struct ieee80211_hdr *) rx->skb->data; | ||
451 | 476 | ||
452 | /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */ | 477 | /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */ |
453 | if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) { | 478 | if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) { |
454 | if (unlikely(rx->fc & IEEE80211_FCTL_RETRY && | 479 | if (unlikely(ieee80211_has_retry(hdr->frame_control) && |
455 | rx->sta->last_seq_ctrl[rx->queue] == | 480 | rx->sta->last_seq_ctrl[rx->queue] == |
456 | hdr->seq_ctrl)) { | 481 | hdr->seq_ctrl)) { |
457 | if (rx->flags & IEEE80211_RX_RA_MATCH) { | 482 | if (rx->flags & IEEE80211_RX_RA_MATCH) { |
@@ -480,15 +505,14 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
480 | if (ieee80211_vif_is_mesh(&rx->sdata->vif)) | 505 | if (ieee80211_vif_is_mesh(&rx->sdata->vif)) |
481 | return ieee80211_rx_mesh_check(rx); | 506 | return ieee80211_rx_mesh_check(rx); |
482 | 507 | ||
483 | if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA || | 508 | if (unlikely((ieee80211_is_data(hdr->frame_control) || |
484 | ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL && | 509 | ieee80211_is_pspoll(hdr->frame_control)) && |
485 | (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) && | ||
486 | rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 510 | rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
487 | (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) { | 511 | (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC)))) { |
488 | if ((!(rx->fc & IEEE80211_FCTL_FROMDS) && | 512 | if ((!ieee80211_has_fromds(hdr->frame_control) && |
489 | !(rx->fc & IEEE80211_FCTL_TODS) && | 513 | !ieee80211_has_tods(hdr->frame_control) && |
490 | (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) | 514 | ieee80211_is_data(hdr->frame_control)) || |
491 | || !(rx->flags & IEEE80211_RX_RA_MATCH)) { | 515 | !(rx->flags & IEEE80211_RX_RA_MATCH)) { |
492 | /* Drop IBSS frames and frames for other hosts | 516 | /* Drop IBSS frames and frames for other hosts |
493 | * silently. */ | 517 | * silently. */ |
494 | return RX_DROP_MONITOR; | 518 | return RX_DROP_MONITOR; |
@@ -501,10 +525,10 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
501 | } | 525 | } |
502 | 526 | ||
503 | 527 | ||
504 | static ieee80211_rx_result | 528 | static ieee80211_rx_result debug_noinline |
505 | ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | 529 | ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) |
506 | { | 530 | { |
507 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 531 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
508 | int keyidx; | 532 | int keyidx; |
509 | int hdrlen; | 533 | int hdrlen; |
510 | ieee80211_rx_result result = RX_DROP_UNUSABLE; | 534 | ieee80211_rx_result result = RX_DROP_UNUSABLE; |
@@ -536,7 +560,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
536 | * possible. | 560 | * possible. |
537 | */ | 561 | */ |
538 | 562 | ||
539 | if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) | 563 | if (!ieee80211_has_protected(hdr->frame_control)) |
540 | return RX_CONTINUE; | 564 | return RX_CONTINUE; |
541 | 565 | ||
542 | /* | 566 | /* |
@@ -565,7 +589,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
565 | (rx->status->flag & RX_FLAG_IV_STRIPPED)) | 589 | (rx->status->flag & RX_FLAG_IV_STRIPPED)) |
566 | return RX_CONTINUE; | 590 | return RX_CONTINUE; |
567 | 591 | ||
568 | hdrlen = ieee80211_get_hdrlen(rx->fc); | 592 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
569 | 593 | ||
570 | if (rx->skb->len < 8 + hdrlen) | 594 | if (rx->skb->len < 8 + hdrlen) |
571 | return RX_DROP_UNUSABLE; /* TODO: count this? */ | 595 | return RX_DROP_UNUSABLE; /* TODO: count this? */ |
@@ -592,17 +616,12 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
592 | rx->key->tx_rx_count++; | 616 | rx->key->tx_rx_count++; |
593 | /* TODO: add threshold stuff again */ | 617 | /* TODO: add threshold stuff again */ |
594 | } else { | 618 | } else { |
595 | #ifdef CONFIG_MAC80211_DEBUG | ||
596 | if (net_ratelimit()) | ||
597 | printk(KERN_DEBUG "%s: RX protected frame," | ||
598 | " but have no key\n", rx->dev->name); | ||
599 | #endif /* CONFIG_MAC80211_DEBUG */ | ||
600 | return RX_DROP_MONITOR; | 619 | return RX_DROP_MONITOR; |
601 | } | 620 | } |
602 | 621 | ||
603 | /* Check for weak IVs if possible */ | 622 | /* Check for weak IVs if possible */ |
604 | if (rx->sta && rx->key->conf.alg == ALG_WEP && | 623 | if (rx->sta && rx->key->conf.alg == ALG_WEP && |
605 | ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | 624 | ieee80211_is_data(hdr->frame_control) && |
606 | (!(rx->status->flag & RX_FLAG_IV_STRIPPED) || | 625 | (!(rx->status->flag & RX_FLAG_IV_STRIPPED) || |
607 | !(rx->status->flag & RX_FLAG_DECRYPTED)) && | 626 | !(rx->status->flag & RX_FLAG_DECRYPTED)) && |
608 | ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | 627 | ieee80211_wep_is_weak_iv(rx->skb, rx->key)) |
@@ -633,10 +652,8 @@ static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta) | |||
633 | 652 | ||
634 | sdata = sta->sdata; | 653 | sdata = sta->sdata; |
635 | 654 | ||
636 | if (sdata->bss) | 655 | atomic_inc(&sdata->bss->num_sta_ps); |
637 | atomic_inc(&sdata->bss->num_sta_ps); | 656 | set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); |
638 | sta->flags |= WLAN_STA_PS; | ||
639 | sta->flags &= ~WLAN_STA_PSPOLL; | ||
640 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 657 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
641 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", | 658 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", |
642 | dev->name, print_mac(mac, sta->addr), sta->aid); | 659 | dev->name, print_mac(mac, sta->addr), sta->aid); |
@@ -649,15 +666,14 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
649 | struct sk_buff *skb; | 666 | struct sk_buff *skb; |
650 | int sent = 0; | 667 | int sent = 0; |
651 | struct ieee80211_sub_if_data *sdata; | 668 | struct ieee80211_sub_if_data *sdata; |
652 | struct ieee80211_tx_packet_data *pkt_data; | 669 | struct ieee80211_tx_info *info; |
653 | DECLARE_MAC_BUF(mac); | 670 | DECLARE_MAC_BUF(mac); |
654 | 671 | ||
655 | sdata = sta->sdata; | 672 | sdata = sta->sdata; |
656 | 673 | ||
657 | if (sdata->bss) | 674 | atomic_dec(&sdata->bss->num_sta_ps); |
658 | atomic_dec(&sdata->bss->num_sta_ps); | ||
659 | 675 | ||
660 | sta->flags &= ~(WLAN_STA_PS | WLAN_STA_PSPOLL); | 676 | clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL); |
661 | 677 | ||
662 | if (!skb_queue_empty(&sta->ps_tx_buf)) | 678 | if (!skb_queue_empty(&sta->ps_tx_buf)) |
663 | sta_info_clear_tim_bit(sta); | 679 | sta_info_clear_tim_bit(sta); |
@@ -669,13 +685,13 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
669 | 685 | ||
670 | /* Send all buffered frames to the station */ | 686 | /* Send all buffered frames to the station */ |
671 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { | 687 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { |
672 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; | 688 | info = IEEE80211_SKB_CB(skb); |
673 | sent++; | 689 | sent++; |
674 | pkt_data->flags |= IEEE80211_TXPD_REQUEUE; | 690 | info->flags |= IEEE80211_TX_CTL_REQUEUE; |
675 | dev_queue_xmit(skb); | 691 | dev_queue_xmit(skb); |
676 | } | 692 | } |
677 | while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { | 693 | while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { |
678 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; | 694 | info = IEEE80211_SKB_CB(skb); |
679 | local->total_ps_buffered--; | 695 | local->total_ps_buffered--; |
680 | sent++; | 696 | sent++; |
681 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 697 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
@@ -683,19 +699,19 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
683 | "since STA not sleeping anymore\n", dev->name, | 699 | "since STA not sleeping anymore\n", dev->name, |
684 | print_mac(mac, sta->addr), sta->aid); | 700 | print_mac(mac, sta->addr), sta->aid); |
685 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 701 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
686 | pkt_data->flags |= IEEE80211_TXPD_REQUEUE; | 702 | info->flags |= IEEE80211_TX_CTL_REQUEUE; |
687 | dev_queue_xmit(skb); | 703 | dev_queue_xmit(skb); |
688 | } | 704 | } |
689 | 705 | ||
690 | return sent; | 706 | return sent; |
691 | } | 707 | } |
692 | 708 | ||
693 | static ieee80211_rx_result | 709 | static ieee80211_rx_result debug_noinline |
694 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | 710 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) |
695 | { | 711 | { |
696 | struct sta_info *sta = rx->sta; | 712 | struct sta_info *sta = rx->sta; |
697 | struct net_device *dev = rx->dev; | 713 | struct net_device *dev = rx->dev; |
698 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 714 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
699 | 715 | ||
700 | if (!sta) | 716 | if (!sta) |
701 | return RX_CONTINUE; | 717 | return RX_CONTINUE; |
@@ -725,24 +741,26 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
725 | 741 | ||
726 | sta->rx_fragments++; | 742 | sta->rx_fragments++; |
727 | sta->rx_bytes += rx->skb->len; | 743 | sta->rx_bytes += rx->skb->len; |
728 | sta->last_rssi = rx->status->ssi; | ||
729 | sta->last_signal = rx->status->signal; | 744 | sta->last_signal = rx->status->signal; |
745 | sta->last_qual = rx->status->qual; | ||
730 | sta->last_noise = rx->status->noise; | 746 | sta->last_noise = rx->status->noise; |
731 | 747 | ||
732 | if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) { | 748 | if (!ieee80211_has_morefrags(hdr->frame_control) && |
749 | (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP || | ||
750 | rx->sdata->vif.type == IEEE80211_IF_TYPE_VLAN)) { | ||
733 | /* Change STA power saving mode only in the end of a frame | 751 | /* Change STA power saving mode only in the end of a frame |
734 | * exchange sequence */ | 752 | * exchange sequence */ |
735 | if ((sta->flags & WLAN_STA_PS) && !(rx->fc & IEEE80211_FCTL_PM)) | 753 | if (test_sta_flags(sta, WLAN_STA_PS) && |
754 | !ieee80211_has_pm(hdr->frame_control)) | ||
736 | rx->sent_ps_buffered += ap_sta_ps_end(dev, sta); | 755 | rx->sent_ps_buffered += ap_sta_ps_end(dev, sta); |
737 | else if (!(sta->flags & WLAN_STA_PS) && | 756 | else if (!test_sta_flags(sta, WLAN_STA_PS) && |
738 | (rx->fc & IEEE80211_FCTL_PM)) | 757 | ieee80211_has_pm(hdr->frame_control)) |
739 | ap_sta_ps_start(dev, sta); | 758 | ap_sta_ps_start(dev, sta); |
740 | } | 759 | } |
741 | 760 | ||
742 | /* Drop data::nullfunc frames silently, since they are used only to | 761 | /* Drop data::nullfunc frames silently, since they are used only to |
743 | * control station power saving mode. */ | 762 | * control station power saving mode. */ |
744 | if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | 763 | if (ieee80211_is_nullfunc(hdr->frame_control)) { |
745 | (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) { | ||
746 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); | 764 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); |
747 | /* Update counter and free packet here to avoid counting this | 765 | /* Update counter and free packet here to avoid counting this |
748 | * as a dropped packed. */ | 766 | * as a dropped packed. */ |
@@ -768,7 +786,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
768 | sdata->fragment_next = 0; | 786 | sdata->fragment_next = 0; |
769 | 787 | ||
770 | if (!skb_queue_empty(&entry->skb_list)) { | 788 | if (!skb_queue_empty(&entry->skb_list)) { |
771 | #ifdef CONFIG_MAC80211_DEBUG | 789 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
772 | struct ieee80211_hdr *hdr = | 790 | struct ieee80211_hdr *hdr = |
773 | (struct ieee80211_hdr *) entry->skb_list.next->data; | 791 | (struct ieee80211_hdr *) entry->skb_list.next->data; |
774 | DECLARE_MAC_BUF(mac); | 792 | DECLARE_MAC_BUF(mac); |
@@ -780,7 +798,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
780 | jiffies - entry->first_frag_time, entry->seq, | 798 | jiffies - entry->first_frag_time, entry->seq, |
781 | entry->last_frag, print_mac(mac, hdr->addr1), | 799 | entry->last_frag, print_mac(mac, hdr->addr1), |
782 | print_mac(mac2, hdr->addr2)); | 800 | print_mac(mac2, hdr->addr2)); |
783 | #endif /* CONFIG_MAC80211_DEBUG */ | 801 | #endif |
784 | __skb_queue_purge(&entry->skb_list); | 802 | __skb_queue_purge(&entry->skb_list); |
785 | } | 803 | } |
786 | 804 | ||
@@ -837,7 +855,7 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | |||
837 | return NULL; | 855 | return NULL; |
838 | } | 856 | } |
839 | 857 | ||
840 | static ieee80211_rx_result | 858 | static ieee80211_rx_result debug_noinline |
841 | ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | 859 | ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) |
842 | { | 860 | { |
843 | struct ieee80211_hdr *hdr; | 861 | struct ieee80211_hdr *hdr; |
@@ -901,18 +919,8 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
901 | break; | 919 | break; |
902 | } | 920 | } |
903 | rpn = rx->key->u.ccmp.rx_pn[rx->queue]; | 921 | rpn = rx->key->u.ccmp.rx_pn[rx->queue]; |
904 | if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) { | 922 | if (memcmp(pn, rpn, CCMP_PN_LEN)) |
905 | if (net_ratelimit()) | ||
906 | printk(KERN_DEBUG "%s: defrag: CCMP PN not " | ||
907 | "sequential A2=%s" | ||
908 | " PN=%02x%02x%02x%02x%02x%02x " | ||
909 | "(expected %02x%02x%02x%02x%02x%02x)\n", | ||
910 | rx->dev->name, print_mac(mac, hdr->addr2), | ||
911 | rpn[0], rpn[1], rpn[2], rpn[3], rpn[4], | ||
912 | rpn[5], pn[0], pn[1], pn[2], pn[3], | ||
913 | pn[4], pn[5]); | ||
914 | return RX_DROP_UNUSABLE; | 923 | return RX_DROP_UNUSABLE; |
915 | } | ||
916 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); | 924 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); |
917 | } | 925 | } |
918 | 926 | ||
@@ -953,7 +961,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
953 | return RX_CONTINUE; | 961 | return RX_CONTINUE; |
954 | } | 962 | } |
955 | 963 | ||
956 | static ieee80211_rx_result | 964 | static ieee80211_rx_result debug_noinline |
957 | ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | 965 | ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) |
958 | { | 966 | { |
959 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 967 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); |
@@ -988,7 +996,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
988 | * Tell TX path to send one frame even though the STA may | 996 | * Tell TX path to send one frame even though the STA may |
989 | * still remain is PS mode after this frame exchange. | 997 | * still remain is PS mode after this frame exchange. |
990 | */ | 998 | */ |
991 | rx->sta->flags |= WLAN_STA_PSPOLL; | 999 | set_sta_flags(rx->sta, WLAN_STA_PSPOLL); |
992 | 1000 | ||
993 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1001 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
994 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", | 1002 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", |
@@ -1016,7 +1024,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1016 | * have nothing buffered for it? | 1024 | * have nothing buffered for it? |
1017 | */ | 1025 | */ |
1018 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " | 1026 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " |
1019 | "though there is no buffered frames for it\n", | 1027 | "though there are no buffered frames for it\n", |
1020 | rx->dev->name, print_mac(mac, rx->sta->addr)); | 1028 | rx->dev->name, print_mac(mac, rx->sta->addr)); |
1021 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1029 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1022 | } | 1030 | } |
@@ -1028,22 +1036,22 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1028 | return RX_QUEUED; | 1036 | return RX_QUEUED; |
1029 | } | 1037 | } |
1030 | 1038 | ||
1031 | static ieee80211_rx_result | 1039 | static ieee80211_rx_result debug_noinline |
1032 | ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx) | 1040 | ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx) |
1033 | { | 1041 | { |
1034 | u16 fc = rx->fc; | ||
1035 | u8 *data = rx->skb->data; | 1042 | u8 *data = rx->skb->data; |
1036 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data; | 1043 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)data; |
1037 | 1044 | ||
1038 | if (!WLAN_FC_IS_QOS_DATA(fc)) | 1045 | if (!ieee80211_is_data_qos(hdr->frame_control)) |
1039 | return RX_CONTINUE; | 1046 | return RX_CONTINUE; |
1040 | 1047 | ||
1041 | /* remove the qos control field, update frame type and meta-data */ | 1048 | /* remove the qos control field, update frame type and meta-data */ |
1042 | memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2); | 1049 | memmove(data + IEEE80211_QOS_CTL_LEN, data, |
1043 | hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2); | 1050 | ieee80211_hdrlen(hdr->frame_control) - IEEE80211_QOS_CTL_LEN); |
1051 | hdr = (struct ieee80211_hdr *)skb_pull(rx->skb, IEEE80211_QOS_CTL_LEN); | ||
1044 | /* change frame type to non QOS */ | 1052 | /* change frame type to non QOS */ |
1045 | rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA; | 1053 | rx->fc &= ~IEEE80211_STYPE_QOS_DATA; |
1046 | hdr->frame_control = cpu_to_le16(fc); | 1054 | hdr->frame_control &= ~cpu_to_le16(IEEE80211_STYPE_QOS_DATA); |
1047 | 1055 | ||
1048 | return RX_CONTINUE; | 1056 | return RX_CONTINUE; |
1049 | } | 1057 | } |
@@ -1051,14 +1059,9 @@ ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx) | |||
1051 | static int | 1059 | static int |
1052 | ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) | 1060 | ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) |
1053 | { | 1061 | { |
1054 | if (unlikely(!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED))) { | 1062 | if (unlikely(!rx->sta || |
1055 | #ifdef CONFIG_MAC80211_DEBUG | 1063 | !test_sta_flags(rx->sta, WLAN_STA_AUTHORIZED))) |
1056 | if (net_ratelimit()) | ||
1057 | printk(KERN_DEBUG "%s: dropped frame " | ||
1058 | "(unauthorized port)\n", rx->dev->name); | ||
1059 | #endif /* CONFIG_MAC80211_DEBUG */ | ||
1060 | return -EACCES; | 1064 | return -EACCES; |
1061 | } | ||
1062 | 1065 | ||
1063 | return 0; | 1066 | return 0; |
1064 | } | 1067 | } |
@@ -1138,16 +1141,8 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1138 | memcpy(src, hdr->addr2, ETH_ALEN); | 1141 | memcpy(src, hdr->addr2, ETH_ALEN); |
1139 | 1142 | ||
1140 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP && | 1143 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP && |
1141 | sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) { | 1144 | sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) |
1142 | if (net_ratelimit()) | ||
1143 | printk(KERN_DEBUG "%s: dropped ToDS frame " | ||
1144 | "(BSSID=%s SA=%s DA=%s)\n", | ||
1145 | dev->name, | ||
1146 | print_mac(mac, hdr->addr1), | ||
1147 | print_mac(mac2, hdr->addr2), | ||
1148 | print_mac(mac3, hdr->addr3)); | ||
1149 | return -1; | 1145 | return -1; |
1150 | } | ||
1151 | break; | 1146 | break; |
1152 | case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): | 1147 | case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): |
1153 | /* RA TA DA SA */ | 1148 | /* RA TA DA SA */ |
@@ -1155,17 +1150,8 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1155 | memcpy(src, hdr->addr4, ETH_ALEN); | 1150 | memcpy(src, hdr->addr4, ETH_ALEN); |
1156 | 1151 | ||
1157 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS && | 1152 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS && |
1158 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) { | 1153 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) |
1159 | if (net_ratelimit()) | ||
1160 | printk(KERN_DEBUG "%s: dropped FromDS&ToDS " | ||
1161 | "frame (RA=%s TA=%s DA=%s SA=%s)\n", | ||
1162 | rx->dev->name, | ||
1163 | print_mac(mac, hdr->addr1), | ||
1164 | print_mac(mac2, hdr->addr2), | ||
1165 | print_mac(mac3, hdr->addr3), | ||
1166 | print_mac(mac4, hdr->addr4)); | ||
1167 | return -1; | 1154 | return -1; |
1168 | } | ||
1169 | break; | 1155 | break; |
1170 | case IEEE80211_FCTL_FROMDS: | 1156 | case IEEE80211_FCTL_FROMDS: |
1171 | /* DA BSSID SA */ | 1157 | /* DA BSSID SA */ |
@@ -1182,27 +1168,13 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1182 | memcpy(dst, hdr->addr1, ETH_ALEN); | 1168 | memcpy(dst, hdr->addr1, ETH_ALEN); |
1183 | memcpy(src, hdr->addr2, ETH_ALEN); | 1169 | memcpy(src, hdr->addr2, ETH_ALEN); |
1184 | 1170 | ||
1185 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) { | 1171 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) |
1186 | if (net_ratelimit()) { | ||
1187 | printk(KERN_DEBUG "%s: dropped IBSS frame " | ||
1188 | "(DA=%s SA=%s BSSID=%s)\n", | ||
1189 | dev->name, | ||
1190 | print_mac(mac, hdr->addr1), | ||
1191 | print_mac(mac2, hdr->addr2), | ||
1192 | print_mac(mac3, hdr->addr3)); | ||
1193 | } | ||
1194 | return -1; | 1172 | return -1; |
1195 | } | ||
1196 | break; | 1173 | break; |
1197 | } | 1174 | } |
1198 | 1175 | ||
1199 | if (unlikely(skb->len - hdrlen < 8)) { | 1176 | if (unlikely(skb->len - hdrlen < 8)) |
1200 | if (net_ratelimit()) { | ||
1201 | printk(KERN_DEBUG "%s: RX too short data frame " | ||
1202 | "payload\n", dev->name); | ||
1203 | } | ||
1204 | return -1; | 1177 | return -1; |
1205 | } | ||
1206 | 1178 | ||
1207 | payload = skb->data + hdrlen; | 1179 | payload = skb->data + hdrlen; |
1208 | ethertype = (payload[6] << 8) | payload[7]; | 1180 | ethertype = (payload[6] << 8) | payload[7]; |
@@ -1345,7 +1317,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1345 | } | 1317 | } |
1346 | } | 1318 | } |
1347 | 1319 | ||
1348 | static ieee80211_rx_result | 1320 | static ieee80211_rx_result debug_noinline |
1349 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | 1321 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) |
1350 | { | 1322 | { |
1351 | struct net_device *dev = rx->dev; | 1323 | struct net_device *dev = rx->dev; |
@@ -1394,10 +1366,8 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1394 | 1366 | ||
1395 | padding = ((4 - subframe_len) & 0x3); | 1367 | padding = ((4 - subframe_len) & 0x3); |
1396 | /* the last MSDU has no padding */ | 1368 | /* the last MSDU has no padding */ |
1397 | if (subframe_len > remaining) { | 1369 | if (subframe_len > remaining) |
1398 | printk(KERN_DEBUG "%s: wrong buffer size\n", dev->name); | ||
1399 | return RX_DROP_UNUSABLE; | 1370 | return RX_DROP_UNUSABLE; |
1400 | } | ||
1401 | 1371 | ||
1402 | skb_pull(skb, sizeof(struct ethhdr)); | 1372 | skb_pull(skb, sizeof(struct ethhdr)); |
1403 | /* if last subframe reuse skb */ | 1373 | /* if last subframe reuse skb */ |
@@ -1418,8 +1388,6 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1418 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | 1388 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + |
1419 | padding); | 1389 | padding); |
1420 | if (!eth) { | 1390 | if (!eth) { |
1421 | printk(KERN_DEBUG "%s: wrong buffer size\n", | ||
1422 | dev->name); | ||
1423 | dev_kfree_skb(frame); | 1391 | dev_kfree_skb(frame); |
1424 | return RX_DROP_UNUSABLE; | 1392 | return RX_DROP_UNUSABLE; |
1425 | } | 1393 | } |
@@ -1462,7 +1430,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1462 | return RX_QUEUED; | 1430 | return RX_QUEUED; |
1463 | } | 1431 | } |
1464 | 1432 | ||
1465 | static ieee80211_rx_result | 1433 | static ieee80211_rx_result debug_noinline |
1466 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | 1434 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) |
1467 | { | 1435 | { |
1468 | struct net_device *dev = rx->dev; | 1436 | struct net_device *dev = rx->dev; |
@@ -1493,21 +1461,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | |||
1493 | return RX_QUEUED; | 1461 | return RX_QUEUED; |
1494 | } | 1462 | } |
1495 | 1463 | ||
1496 | static ieee80211_rx_result | 1464 | static ieee80211_rx_result debug_noinline |
1497 | ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | 1465 | ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) |
1498 | { | 1466 | { |
1499 | struct ieee80211_local *local = rx->local; | 1467 | struct ieee80211_local *local = rx->local; |
1500 | struct ieee80211_hw *hw = &local->hw; | 1468 | struct ieee80211_hw *hw = &local->hw; |
1501 | struct sk_buff *skb = rx->skb; | 1469 | struct sk_buff *skb = rx->skb; |
1502 | struct ieee80211_bar *bar = (struct ieee80211_bar *) skb->data; | 1470 | struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data; |
1503 | struct tid_ampdu_rx *tid_agg_rx; | 1471 | struct tid_ampdu_rx *tid_agg_rx; |
1504 | u16 start_seq_num; | 1472 | u16 start_seq_num; |
1505 | u16 tid; | 1473 | u16 tid; |
1506 | 1474 | ||
1507 | if (likely((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL)) | 1475 | if (likely(!ieee80211_is_ctl(bar->frame_control))) |
1508 | return RX_CONTINUE; | 1476 | return RX_CONTINUE; |
1509 | 1477 | ||
1510 | if ((rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ) { | 1478 | if (ieee80211_is_back_req(bar->frame_control)) { |
1511 | if (!rx->sta) | 1479 | if (!rx->sta) |
1512 | return RX_CONTINUE; | 1480 | return RX_CONTINUE; |
1513 | tid = le16_to_cpu(bar->control) >> 12; | 1481 | tid = le16_to_cpu(bar->control) >> 12; |
@@ -1537,7 +1505,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1537 | return RX_CONTINUE; | 1505 | return RX_CONTINUE; |
1538 | } | 1506 | } |
1539 | 1507 | ||
1540 | static ieee80211_rx_result | 1508 | static ieee80211_rx_result debug_noinline |
1541 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | 1509 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) |
1542 | { | 1510 | { |
1543 | struct ieee80211_sub_if_data *sdata; | 1511 | struct ieee80211_sub_if_data *sdata; |
@@ -1561,41 +1529,27 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1561 | struct ieee80211_hdr *hdr, | 1529 | struct ieee80211_hdr *hdr, |
1562 | struct ieee80211_rx_data *rx) | 1530 | struct ieee80211_rx_data *rx) |
1563 | { | 1531 | { |
1564 | int keyidx, hdrlen; | 1532 | int keyidx; |
1533 | unsigned int hdrlen; | ||
1565 | DECLARE_MAC_BUF(mac); | 1534 | DECLARE_MAC_BUF(mac); |
1566 | DECLARE_MAC_BUF(mac2); | 1535 | DECLARE_MAC_BUF(mac2); |
1567 | 1536 | ||
1568 | hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb); | 1537 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1569 | if (rx->skb->len >= hdrlen + 4) | 1538 | if (rx->skb->len >= hdrlen + 4) |
1570 | keyidx = rx->skb->data[hdrlen + 3] >> 6; | 1539 | keyidx = rx->skb->data[hdrlen + 3] >> 6; |
1571 | else | 1540 | else |
1572 | keyidx = -1; | 1541 | keyidx = -1; |
1573 | 1542 | ||
1574 | if (net_ratelimit()) | ||
1575 | printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC " | ||
1576 | "failure from %s to %s keyidx=%d\n", | ||
1577 | dev->name, print_mac(mac, hdr->addr2), | ||
1578 | print_mac(mac2, hdr->addr1), keyidx); | ||
1579 | |||
1580 | if (!rx->sta) { | 1543 | if (!rx->sta) { |
1581 | /* | 1544 | /* |
1582 | * Some hardware seem to generate incorrect Michael MIC | 1545 | * Some hardware seem to generate incorrect Michael MIC |
1583 | * reports; ignore them to avoid triggering countermeasures. | 1546 | * reports; ignore them to avoid triggering countermeasures. |
1584 | */ | 1547 | */ |
1585 | if (net_ratelimit()) | ||
1586 | printk(KERN_DEBUG "%s: ignored spurious Michael MIC " | ||
1587 | "error for unknown address %s\n", | ||
1588 | dev->name, print_mac(mac, hdr->addr2)); | ||
1589 | goto ignore; | 1548 | goto ignore; |
1590 | } | 1549 | } |
1591 | 1550 | ||
1592 | if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) { | 1551 | if (!ieee80211_has_protected(hdr->frame_control)) |
1593 | if (net_ratelimit()) | ||
1594 | printk(KERN_DEBUG "%s: ignored spurious Michael MIC " | ||
1595 | "error for a frame with no PROTECTED flag (src " | ||
1596 | "%s)\n", dev->name, print_mac(mac, hdr->addr2)); | ||
1597 | goto ignore; | 1552 | goto ignore; |
1598 | } | ||
1599 | 1553 | ||
1600 | if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) { | 1554 | if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) { |
1601 | /* | 1555 | /* |
@@ -1604,24 +1558,12 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1604 | * group keys and only the AP is sending real multicast | 1558 | * group keys and only the AP is sending real multicast |
1605 | * frames in the BSS. | 1559 | * frames in the BSS. |
1606 | */ | 1560 | */ |
1607 | if (net_ratelimit()) | ||
1608 | printk(KERN_DEBUG "%s: ignored Michael MIC error for " | ||
1609 | "a frame with non-zero keyidx (%d)" | ||
1610 | " (src %s)\n", dev->name, keyidx, | ||
1611 | print_mac(mac, hdr->addr2)); | ||
1612 | goto ignore; | 1561 | goto ignore; |
1613 | } | 1562 | } |
1614 | 1563 | ||
1615 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA && | 1564 | if (!ieee80211_is_data(hdr->frame_control) && |
1616 | ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || | 1565 | !ieee80211_is_auth(hdr->frame_control)) |
1617 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) { | ||
1618 | if (net_ratelimit()) | ||
1619 | printk(KERN_DEBUG "%s: ignored spurious Michael MIC " | ||
1620 | "error for a frame that cannot be encrypted " | ||
1621 | "(fc=0x%04x) (src %s)\n", | ||
1622 | dev->name, rx->fc, print_mac(mac, hdr->addr2)); | ||
1623 | goto ignore; | 1566 | goto ignore; |
1624 | } | ||
1625 | 1567 | ||
1626 | mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr); | 1568 | mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr); |
1627 | ignore: | 1569 | ignore: |
@@ -1710,67 +1652,57 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx) | |||
1710 | dev_kfree_skb(skb); | 1652 | dev_kfree_skb(skb); |
1711 | } | 1653 | } |
1712 | 1654 | ||
1713 | typedef ieee80211_rx_result (*ieee80211_rx_handler)(struct ieee80211_rx_data *); | ||
1714 | static ieee80211_rx_handler ieee80211_rx_handlers[] = | ||
1715 | { | ||
1716 | ieee80211_rx_h_if_stats, | ||
1717 | ieee80211_rx_h_passive_scan, | ||
1718 | ieee80211_rx_h_check, | ||
1719 | ieee80211_rx_h_decrypt, | ||
1720 | ieee80211_rx_h_sta_process, | ||
1721 | ieee80211_rx_h_defragment, | ||
1722 | ieee80211_rx_h_ps_poll, | ||
1723 | ieee80211_rx_h_michael_mic_verify, | ||
1724 | /* this must be after decryption - so header is counted in MPDU mic | ||
1725 | * must be before pae and data, so QOS_DATA format frames | ||
1726 | * are not passed to user space by these functions | ||
1727 | */ | ||
1728 | ieee80211_rx_h_remove_qos_control, | ||
1729 | ieee80211_rx_h_amsdu, | ||
1730 | ieee80211_rx_h_data, | ||
1731 | ieee80211_rx_h_ctrl, | ||
1732 | ieee80211_rx_h_mgmt, | ||
1733 | NULL | ||
1734 | }; | ||
1735 | 1655 | ||
1736 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | 1656 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, |
1737 | struct ieee80211_rx_data *rx, | 1657 | struct ieee80211_rx_data *rx, |
1738 | struct sk_buff *skb) | 1658 | struct sk_buff *skb) |
1739 | { | 1659 | { |
1740 | ieee80211_rx_handler *handler; | ||
1741 | ieee80211_rx_result res = RX_DROP_MONITOR; | 1660 | ieee80211_rx_result res = RX_DROP_MONITOR; |
1742 | 1661 | ||
1743 | rx->skb = skb; | 1662 | rx->skb = skb; |
1744 | rx->sdata = sdata; | 1663 | rx->sdata = sdata; |
1745 | rx->dev = sdata->dev; | 1664 | rx->dev = sdata->dev; |
1746 | 1665 | ||
1747 | for (handler = ieee80211_rx_handlers; *handler != NULL; handler++) { | 1666 | #define CALL_RXH(rxh) \ |
1748 | res = (*handler)(rx); | 1667 | res = rxh(rx); \ |
1749 | 1668 | if (res != RX_CONTINUE) \ | |
1750 | switch (res) { | 1669 | goto rxh_done; |
1751 | case RX_CONTINUE: | 1670 | |
1752 | continue; | 1671 | CALL_RXH(ieee80211_rx_h_passive_scan) |
1753 | case RX_DROP_UNUSABLE: | 1672 | CALL_RXH(ieee80211_rx_h_check) |
1754 | case RX_DROP_MONITOR: | 1673 | CALL_RXH(ieee80211_rx_h_decrypt) |
1755 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | 1674 | CALL_RXH(ieee80211_rx_h_sta_process) |
1756 | if (rx->sta) | 1675 | CALL_RXH(ieee80211_rx_h_defragment) |
1757 | rx->sta->rx_dropped++; | 1676 | CALL_RXH(ieee80211_rx_h_ps_poll) |
1758 | break; | 1677 | CALL_RXH(ieee80211_rx_h_michael_mic_verify) |
1759 | case RX_QUEUED: | 1678 | /* must be after MMIC verify so header is counted in MPDU mic */ |
1760 | I802_DEBUG_INC(sdata->local->rx_handlers_queued); | 1679 | CALL_RXH(ieee80211_rx_h_remove_qos_control) |
1761 | break; | 1680 | CALL_RXH(ieee80211_rx_h_amsdu) |
1762 | } | 1681 | CALL_RXH(ieee80211_rx_h_data) |
1763 | break; | 1682 | CALL_RXH(ieee80211_rx_h_ctrl) |
1764 | } | 1683 | CALL_RXH(ieee80211_rx_h_mgmt) |
1765 | 1684 | ||
1685 | #undef CALL_RXH | ||
1686 | |||
1687 | rxh_done: | ||
1766 | switch (res) { | 1688 | switch (res) { |
1767 | case RX_CONTINUE: | ||
1768 | case RX_DROP_MONITOR: | 1689 | case RX_DROP_MONITOR: |
1690 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | ||
1691 | if (rx->sta) | ||
1692 | rx->sta->rx_dropped++; | ||
1693 | /* fall through */ | ||
1694 | case RX_CONTINUE: | ||
1769 | ieee80211_rx_cooked_monitor(rx); | 1695 | ieee80211_rx_cooked_monitor(rx); |
1770 | break; | 1696 | break; |
1771 | case RX_DROP_UNUSABLE: | 1697 | case RX_DROP_UNUSABLE: |
1698 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | ||
1699 | if (rx->sta) | ||
1700 | rx->sta->rx_dropped++; | ||
1772 | dev_kfree_skb(rx->skb); | 1701 | dev_kfree_skb(rx->skb); |
1773 | break; | 1702 | break; |
1703 | case RX_QUEUED: | ||
1704 | I802_DEBUG_INC(sdata->local->rx_handlers_queued); | ||
1705 | break; | ||
1774 | } | 1706 | } |
1775 | } | 1707 | } |
1776 | 1708 | ||
@@ -1801,9 +1733,13 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1801 | case IEEE80211_IF_TYPE_IBSS: | 1733 | case IEEE80211_IF_TYPE_IBSS: |
1802 | if (!bssid) | 1734 | if (!bssid) |
1803 | return 0; | 1735 | return 0; |
1804 | if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && | 1736 | if (ieee80211_is_beacon(hdr->frame_control)) { |
1805 | (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) | 1737 | if (!rx->sta) |
1738 | rx->sta = ieee80211_ibss_add_sta(sdata->dev, | ||
1739 | rx->skb, bssid, hdr->addr2, | ||
1740 | BIT(rx->status->rate_idx)); | ||
1806 | return 1; | 1741 | return 1; |
1742 | } | ||
1807 | else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { | 1743 | else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { |
1808 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) | 1744 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) |
1809 | return 0; | 1745 | return 0; |
@@ -1816,7 +1752,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1816 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1752 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1817 | } else if (!rx->sta) | 1753 | } else if (!rx->sta) |
1818 | rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb, | 1754 | rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb, |
1819 | bssid, hdr->addr2); | 1755 | bssid, hdr->addr2, |
1756 | BIT(rx->status->rate_idx)); | ||
1820 | break; | 1757 | break; |
1821 | case IEEE80211_IF_TYPE_MESH_POINT: | 1758 | case IEEE80211_IF_TYPE_MESH_POINT: |
1822 | if (!multicast && | 1759 | if (!multicast && |
@@ -1840,15 +1777,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1840 | return 0; | 1777 | return 0; |
1841 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1778 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1842 | } | 1779 | } |
1843 | if (sdata->dev == sdata->local->mdev && | ||
1844 | !(rx->flags & IEEE80211_RX_IN_SCAN)) | ||
1845 | /* do not receive anything via | ||
1846 | * master device when not scanning */ | ||
1847 | return 0; | ||
1848 | break; | 1780 | break; |
1849 | case IEEE80211_IF_TYPE_WDS: | 1781 | case IEEE80211_IF_TYPE_WDS: |
1850 | if (bssid || | 1782 | if (bssid || !ieee80211_is_data(hdr->frame_control)) |
1851 | (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) | ||
1852 | return 0; | 1783 | return 0; |
1853 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) | 1784 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) |
1854 | return 0; | 1785 | return 0; |
@@ -1872,7 +1803,6 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1872 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | 1803 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, |
1873 | struct sk_buff *skb, | 1804 | struct sk_buff *skb, |
1874 | struct ieee80211_rx_status *status, | 1805 | struct ieee80211_rx_status *status, |
1875 | u32 load, | ||
1876 | struct ieee80211_rate *rate) | 1806 | struct ieee80211_rate *rate) |
1877 | { | 1807 | { |
1878 | struct ieee80211_local *local = hw_to_local(hw); | 1808 | struct ieee80211_local *local = hw_to_local(hw); |
@@ -1891,7 +1821,6 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1891 | rx.local = local; | 1821 | rx.local = local; |
1892 | 1822 | ||
1893 | rx.status = status; | 1823 | rx.status = status; |
1894 | rx.load = load; | ||
1895 | rx.rate = rate; | 1824 | rx.rate = rate; |
1896 | rx.fc = le16_to_cpu(hdr->frame_control); | 1825 | rx.fc = le16_to_cpu(hdr->frame_control); |
1897 | type = rx.fc & IEEE80211_FCTL_FTYPE; | 1826 | type = rx.fc & IEEE80211_FCTL_FTYPE; |
@@ -2000,7 +1929,6 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2000 | struct ieee80211_rx_status status; | 1929 | struct ieee80211_rx_status status; |
2001 | u16 head_seq_num, buf_size; | 1930 | u16 head_seq_num, buf_size; |
2002 | int index; | 1931 | int index; |
2003 | u32 pkt_load; | ||
2004 | struct ieee80211_supported_band *sband; | 1932 | struct ieee80211_supported_band *sband; |
2005 | struct ieee80211_rate *rate; | 1933 | struct ieee80211_rate *rate; |
2006 | 1934 | ||
@@ -2035,12 +1963,9 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2035 | sizeof(status)); | 1963 | sizeof(status)); |
2036 | sband = local->hw.wiphy->bands[status.band]; | 1964 | sband = local->hw.wiphy->bands[status.band]; |
2037 | rate = &sband->bitrates[status.rate_idx]; | 1965 | rate = &sband->bitrates[status.rate_idx]; |
2038 | pkt_load = ieee80211_rx_load_stats(local, | ||
2039 | tid_agg_rx->reorder_buf[index], | ||
2040 | &status, rate); | ||
2041 | __ieee80211_rx_handle_packet(hw, | 1966 | __ieee80211_rx_handle_packet(hw, |
2042 | tid_agg_rx->reorder_buf[index], | 1967 | tid_agg_rx->reorder_buf[index], |
2043 | &status, pkt_load, rate); | 1968 | &status, rate); |
2044 | tid_agg_rx->stored_mpdu_num--; | 1969 | tid_agg_rx->stored_mpdu_num--; |
2045 | tid_agg_rx->reorder_buf[index] = NULL; | 1970 | tid_agg_rx->reorder_buf[index] = NULL; |
2046 | } | 1971 | } |
@@ -2082,11 +2007,8 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2082 | sizeof(status)); | 2007 | sizeof(status)); |
2083 | sband = local->hw.wiphy->bands[status.band]; | 2008 | sband = local->hw.wiphy->bands[status.band]; |
2084 | rate = &sband->bitrates[status.rate_idx]; | 2009 | rate = &sband->bitrates[status.rate_idx]; |
2085 | pkt_load = ieee80211_rx_load_stats(local, | ||
2086 | tid_agg_rx->reorder_buf[index], | ||
2087 | &status, rate); | ||
2088 | __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], | 2010 | __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], |
2089 | &status, pkt_load, rate); | 2011 | &status, rate); |
2090 | tid_agg_rx->stored_mpdu_num--; | 2012 | tid_agg_rx->stored_mpdu_num--; |
2091 | tid_agg_rx->reorder_buf[index] = NULL; | 2013 | tid_agg_rx->reorder_buf[index] = NULL; |
2092 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); | 2014 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); |
@@ -2103,32 +2025,29 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | |||
2103 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 2025 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
2104 | struct sta_info *sta; | 2026 | struct sta_info *sta; |
2105 | struct tid_ampdu_rx *tid_agg_rx; | 2027 | struct tid_ampdu_rx *tid_agg_rx; |
2106 | u16 fc, sc; | 2028 | u16 sc; |
2107 | u16 mpdu_seq_num; | 2029 | u16 mpdu_seq_num; |
2108 | u8 ret = 0, *qc; | 2030 | u8 ret = 0; |
2109 | int tid; | 2031 | int tid; |
2110 | 2032 | ||
2111 | sta = sta_info_get(local, hdr->addr2); | 2033 | sta = sta_info_get(local, hdr->addr2); |
2112 | if (!sta) | 2034 | if (!sta) |
2113 | return ret; | 2035 | return ret; |
2114 | 2036 | ||
2115 | fc = le16_to_cpu(hdr->frame_control); | ||
2116 | |||
2117 | /* filter the QoS data rx stream according to | 2037 | /* filter the QoS data rx stream according to |
2118 | * STA/TID and check if this STA/TID is on aggregation */ | 2038 | * STA/TID and check if this STA/TID is on aggregation */ |
2119 | if (!WLAN_FC_IS_QOS_DATA(fc)) | 2039 | if (!ieee80211_is_data_qos(hdr->frame_control)) |
2120 | goto end_reorder; | 2040 | goto end_reorder; |
2121 | 2041 | ||
2122 | qc = skb->data + ieee80211_get_hdrlen(fc) - QOS_CONTROL_LEN; | 2042 | tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; |
2123 | tid = qc[0] & QOS_CONTROL_TID_MASK; | ||
2124 | 2043 | ||
2125 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) | 2044 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) |
2126 | goto end_reorder; | 2045 | goto end_reorder; |
2127 | 2046 | ||
2128 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; | 2047 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; |
2129 | 2048 | ||
2130 | /* null data frames are excluded */ | 2049 | /* qos null data frames are excluded */ |
2131 | if (unlikely(fc & IEEE80211_STYPE_NULLFUNC)) | 2050 | if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) |
2132 | goto end_reorder; | 2051 | goto end_reorder; |
2133 | 2052 | ||
2134 | /* new un-ordered ampdu frame - process it */ | 2053 | /* new un-ordered ampdu frame - process it */ |
@@ -2165,7 +2084,6 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2165 | struct ieee80211_rx_status *status) | 2084 | struct ieee80211_rx_status *status) |
2166 | { | 2085 | { |
2167 | struct ieee80211_local *local = hw_to_local(hw); | 2086 | struct ieee80211_local *local = hw_to_local(hw); |
2168 | u32 pkt_load; | ||
2169 | struct ieee80211_rate *rate = NULL; | 2087 | struct ieee80211_rate *rate = NULL; |
2170 | struct ieee80211_supported_band *sband; | 2088 | struct ieee80211_supported_band *sband; |
2171 | 2089 | ||
@@ -2205,11 +2123,8 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2205 | return; | 2123 | return; |
2206 | } | 2124 | } |
2207 | 2125 | ||
2208 | pkt_load = ieee80211_rx_load_stats(local, skb, status, rate); | ||
2209 | local->channel_use_raw += pkt_load; | ||
2210 | |||
2211 | if (!ieee80211_rx_reorder_ampdu(local, skb)) | 2126 | if (!ieee80211_rx_reorder_ampdu(local, skb)) |
2212 | __ieee80211_rx_handle_packet(hw, skb, status, pkt_load, rate); | 2127 | __ieee80211_rx_handle_packet(hw, skb, status, rate); |
2213 | 2128 | ||
2214 | rcu_read_unlock(); | 2129 | rcu_read_unlock(); |
2215 | } | 2130 | } |