diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2010-10-11 09:38:07 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-11 15:04:25 -0400 |
commit | 3590eea41815679e268c90d30795a13a732b8413 (patch) | |
tree | 2bb4aa64db2afd5fb522a402643ca151edc99774 /drivers | |
parent | cdfd2c5cffac2e744c855f9998212867387bb2de (diff) |
rt2x00: Validate MCS on RX path
Similar to the PLCP signal and bitrates values,
we should validate the MCS value from the RX descriptor
before sending it to mac80211.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00dev.c | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 9b745faef0ed..db25209688fb 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -432,36 +432,44 @@ static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev, | |||
432 | struct ieee80211_supported_band *sband; | 432 | struct ieee80211_supported_band *sband; |
433 | const struct rt2x00_rate *rate; | 433 | const struct rt2x00_rate *rate; |
434 | unsigned int i; | 434 | unsigned int i; |
435 | int signal; | 435 | int signal = rxdesc->signal; |
436 | int type; | 436 | int type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK); |
437 | 437 | ||
438 | /* | 438 | switch (rxdesc->rate_mode) { |
439 | * For non-HT rates the MCS value needs to contain the | 439 | case RATE_MODE_CCK: |
440 | * actually used rate modulation (CCK or OFDM). | 440 | case RATE_MODE_OFDM: |
441 | */ | 441 | /* |
442 | if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS) | 442 | * For non-HT rates the MCS value needs to contain the |
443 | signal = RATE_MCS(rxdesc->rate_mode, rxdesc->signal); | 443 | * actually used rate modulation (CCK or OFDM). |
444 | else | 444 | */ |
445 | signal = rxdesc->signal; | 445 | if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS) |
446 | 446 | signal = RATE_MCS(rxdesc->rate_mode, signal); | |
447 | type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK); | 447 | |
448 | 448 | sband = &rt2x00dev->bands[rt2x00dev->curr_band]; | |
449 | sband = &rt2x00dev->bands[rt2x00dev->curr_band]; | 449 | for (i = 0; i < sband->n_bitrates; i++) { |
450 | for (i = 0; i < sband->n_bitrates; i++) { | 450 | rate = rt2x00_get_rate(sband->bitrates[i].hw_value); |
451 | rate = rt2x00_get_rate(sband->bitrates[i].hw_value); | 451 | if (((type == RXDONE_SIGNAL_PLCP) && |
452 | 452 | (rate->plcp == signal)) || | |
453 | if (((type == RXDONE_SIGNAL_PLCP) && | 453 | ((type == RXDONE_SIGNAL_BITRATE) && |
454 | (rate->plcp == signal)) || | 454 | (rate->bitrate == signal)) || |
455 | ((type == RXDONE_SIGNAL_BITRATE) && | 455 | ((type == RXDONE_SIGNAL_MCS) && |
456 | (rate->bitrate == signal)) || | 456 | (rate->mcs == signal))) { |
457 | ((type == RXDONE_SIGNAL_MCS) && | 457 | return i; |
458 | (rate->mcs == signal))) { | 458 | } |
459 | return i; | ||
460 | } | 459 | } |
460 | break; | ||
461 | case RATE_MODE_HT_MIX: | ||
462 | case RATE_MODE_HT_GREENFIELD: | ||
463 | if (signal >= 0 && signal <= 76) | ||
464 | return signal; | ||
465 | break; | ||
466 | default: | ||
467 | break; | ||
461 | } | 468 | } |
462 | 469 | ||
463 | WARNING(rt2x00dev, "Frame received with unrecognized signal, " | 470 | WARNING(rt2x00dev, "Frame received with unrecognized signal, " |
464 | "signal=0x%.4x, type=%d.\n", signal, type); | 471 | "mode=0x%.4x, signal=0x%.4x, type=%d.\n", |
472 | rxdesc->rate_mode, signal, type); | ||
465 | return 0; | 473 | return 0; |
466 | } | 474 | } |
467 | 475 | ||
@@ -523,18 +531,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry) | |||
523 | skb_trim(entry->skb, rxdesc.size); | 531 | skb_trim(entry->skb, rxdesc.size); |
524 | 532 | ||
525 | /* | 533 | /* |
526 | * Check if the frame was received using HT. In that case, | 534 | * Translate the signal to the correct bitrate index. |
527 | * the rate is the MCS index and should be passed to mac80211 | ||
528 | * directly. Otherwise we need to translate the signal to | ||
529 | * the correct bitrate index. | ||
530 | */ | 535 | */ |
531 | if (rxdesc.rate_mode == RATE_MODE_CCK || | 536 | rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc); |
532 | rxdesc.rate_mode == RATE_MODE_OFDM) { | 537 | if (rxdesc.rate_mode == RATE_MODE_HT_MIX || |
533 | rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc); | 538 | rxdesc.rate_mode == RATE_MODE_HT_GREENFIELD) |
534 | } else { | ||
535 | rxdesc.flags |= RX_FLAG_HT; | 539 | rxdesc.flags |= RX_FLAG_HT; |
536 | rate_idx = rxdesc.signal; | ||
537 | } | ||
538 | 540 | ||
539 | /* | 541 | /* |
540 | * Update extra components | 542 | * Update extra components |