diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/pcu.c')
-rw-r--r-- | drivers/net/wireless/ath/ath5k/pcu.c | 121 |
1 files changed, 7 insertions, 114 deletions
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c index f03c06d583e6..9ac763875a98 100644 --- a/drivers/net/wireless/ath/ath5k/pcu.c +++ b/drivers/net/wireless/ath/ath5k/pcu.c | |||
@@ -290,10 +290,10 @@ void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id) | |||
290 | */ | 290 | */ |
291 | if (ah->ah_version == AR5K_AR5212) { | 291 | if (ah->ah_version == AR5K_AR5212) { |
292 | ath5k_hw_reg_write(ah, get_unaligned_le32(common->bssidmask), | 292 | ath5k_hw_reg_write(ah, get_unaligned_le32(common->bssidmask), |
293 | AR5K_BSS_IDM0); | 293 | AR_BSSMSKL); |
294 | ath5k_hw_reg_write(ah, | 294 | ath5k_hw_reg_write(ah, |
295 | get_unaligned_le16(common->curbssid + 4), | 295 | get_unaligned_le16(common->curbssid + 4), |
296 | AR5K_BSS_IDM1); | 296 | AR_BSSMSKU); |
297 | } | 297 | } |
298 | 298 | ||
299 | /* | 299 | /* |
@@ -301,9 +301,9 @@ void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id) | |||
301 | */ | 301 | */ |
302 | low_id = get_unaligned_le32(bssid); | 302 | low_id = get_unaligned_le32(bssid); |
303 | high_id = get_unaligned_le16(bssid); | 303 | high_id = get_unaligned_le16(bssid); |
304 | ath5k_hw_reg_write(ah, low_id, AR5K_BSS_ID0); | 304 | ath5k_hw_reg_write(ah, low_id, AR_BSSMSKL); |
305 | ath5k_hw_reg_write(ah, high_id | ((assoc_id & 0x3fff) << | 305 | ath5k_hw_reg_write(ah, high_id | ((assoc_id & 0x3fff) << |
306 | AR5K_BSS_ID1_AID_S), AR5K_BSS_ID1); | 306 | AR5K_BSS_ID1_AID_S), AR_BSSMSKU); |
307 | 307 | ||
308 | if (assoc_id == 0) { | 308 | if (assoc_id == 0) { |
309 | ath5k_hw_disable_pspoll(ah); | 309 | ath5k_hw_disable_pspoll(ah); |
@@ -316,125 +316,18 @@ void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id) | |||
316 | ath5k_hw_enable_pspoll(ah, NULL, 0); | 316 | ath5k_hw_enable_pspoll(ah, NULL, 0); |
317 | } | 317 | } |
318 | 318 | ||
319 | /** | 319 | void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) |
320 | * ath5k_hw_set_bssid_mask - filter out bssids we listen | ||
321 | * | ||
322 | * @ah: the &struct ath5k_hw | ||
323 | * @mask: the bssid_mask, a u8 array of size ETH_ALEN | ||
324 | * | ||
325 | * BSSID masking is a method used by AR5212 and newer hardware to inform PCU | ||
326 | * which bits of the interface's MAC address should be looked at when trying | ||
327 | * to decide which packets to ACK. In station mode and AP mode with a single | ||
328 | * BSS every bit matters since we lock to only one BSS. In AP mode with | ||
329 | * multiple BSSes (virtual interfaces) not every bit matters because hw must | ||
330 | * accept frames for all BSSes and so we tweak some bits of our mac address | ||
331 | * in order to have multiple BSSes. | ||
332 | * | ||
333 | * NOTE: This is a simple filter and does *not* filter out all | ||
334 | * relevant frames. Some frames that are not for us might get ACKed from us | ||
335 | * by PCU because they just match the mask. | ||
336 | * | ||
337 | * When handling multiple BSSes you can get the BSSID mask by computing the | ||
338 | * set of ~ ( MAC XOR BSSID ) for all bssids we handle. | ||
339 | * | ||
340 | * When you do this you are essentially computing the common bits of all your | ||
341 | * BSSes. Later it is assumed the harware will "and" (&) the BSSID mask with | ||
342 | * the MAC address to obtain the relevant bits and compare the result with | ||
343 | * (frame's BSSID & mask) to see if they match. | ||
344 | */ | ||
345 | /* | ||
346 | * Simple example: on your card you have have two BSSes you have created with | ||
347 | * BSSID-01 and BSSID-02. Lets assume BSSID-01 will not use the MAC address. | ||
348 | * There is another BSSID-03 but you are not part of it. For simplicity's sake, | ||
349 | * assuming only 4 bits for a mac address and for BSSIDs you can then have: | ||
350 | * | ||
351 | * \ | ||
352 | * MAC: 0001 | | ||
353 | * BSSID-01: 0100 | --> Belongs to us | ||
354 | * BSSID-02: 1001 | | ||
355 | * / | ||
356 | * ------------------- | ||
357 | * BSSID-03: 0110 | --> External | ||
358 | * ------------------- | ||
359 | * | ||
360 | * Our bssid_mask would then be: | ||
361 | * | ||
362 | * On loop iteration for BSSID-01: | ||
363 | * ~(0001 ^ 0100) -> ~(0101) | ||
364 | * -> 1010 | ||
365 | * bssid_mask = 1010 | ||
366 | * | ||
367 | * On loop iteration for BSSID-02: | ||
368 | * bssid_mask &= ~(0001 ^ 1001) | ||
369 | * bssid_mask = (1010) & ~(0001 ^ 1001) | ||
370 | * bssid_mask = (1010) & ~(1001) | ||
371 | * bssid_mask = (1010) & (0110) | ||
372 | * bssid_mask = 0010 | ||
373 | * | ||
374 | * A bssid_mask of 0010 means "only pay attention to the second least | ||
375 | * significant bit". This is because its the only bit common | ||
376 | * amongst the MAC and all BSSIDs we support. To findout what the real | ||
377 | * common bit is we can simply "&" the bssid_mask now with any BSSID we have | ||
378 | * or our MAC address (we assume the hardware uses the MAC address). | ||
379 | * | ||
380 | * Now, suppose there's an incoming frame for BSSID-03: | ||
381 | * | ||
382 | * IFRAME-01: 0110 | ||
383 | * | ||
384 | * An easy eye-inspeciton of this already should tell you that this frame | ||
385 | * will not pass our check. This is beacuse the bssid_mask tells the | ||
386 | * hardware to only look at the second least significant bit and the | ||
387 | * common bit amongst the MAC and BSSIDs is 0, this frame has the 2nd LSB | ||
388 | * as 1, which does not match 0. | ||
389 | * | ||
390 | * So with IFRAME-01 we *assume* the hardware will do: | ||
391 | * | ||
392 | * allow = (IFRAME-01 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; | ||
393 | * --> allow = (0110 & 0010) == (0010 & 0001) ? 1 : 0; | ||
394 | * --> allow = (0010) == 0000 ? 1 : 0; | ||
395 | * --> allow = 0 | ||
396 | * | ||
397 | * Lets now test a frame that should work: | ||
398 | * | ||
399 | * IFRAME-02: 0001 (we should allow) | ||
400 | * | ||
401 | * allow = (0001 & 1010) == 1010 | ||
402 | * | ||
403 | * allow = (IFRAME-02 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; | ||
404 | * --> allow = (0001 & 0010) == (0010 & 0001) ? 1 :0; | ||
405 | * --> allow = (0010) == (0010) | ||
406 | * --> allow = 1 | ||
407 | * | ||
408 | * Other examples: | ||
409 | * | ||
410 | * IFRAME-03: 0100 --> allowed | ||
411 | * IFRAME-04: 1001 --> allowed | ||
412 | * IFRAME-05: 1101 --> allowed but its not for us!!! | ||
413 | * | ||
414 | */ | ||
415 | int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) | ||
416 | { | 320 | { |
417 | struct ath_common *common = ath5k_hw_common(ah); | 321 | struct ath_common *common = ath5k_hw_common(ah); |
418 | u32 low_id, high_id; | ||
419 | ATH5K_TRACE(ah->ah_sc); | 322 | ATH5K_TRACE(ah->ah_sc); |
420 | 323 | ||
421 | /* Cache bssid mask so that we can restore it | 324 | /* Cache bssid mask so that we can restore it |
422 | * on reset */ | 325 | * on reset */ |
423 | memcpy(common->bssidmask, mask, ETH_ALEN); | 326 | memcpy(common->bssidmask, mask, ETH_ALEN); |
424 | if (ah->ah_version == AR5K_AR5212) { | 327 | if (ah->ah_version == AR5K_AR5212) |
425 | low_id = get_unaligned_le32(mask); | 328 | ath_hw_setbssidmask(common); |
426 | high_id = get_unaligned_le16(mask + 4); | ||
427 | |||
428 | ath5k_hw_reg_write(ah, low_id, AR5K_BSS_IDM0); | ||
429 | ath5k_hw_reg_write(ah, high_id, AR5K_BSS_IDM1); | ||
430 | |||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | return -EIO; | ||
435 | } | 329 | } |
436 | 330 | ||
437 | |||
438 | /************\ | 331 | /************\ |
439 | * RX Control * | 332 | * RX Control * |
440 | \************/ | 333 | \************/ |