aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-10-07 07:02:03 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2010-10-14 12:47:09 -0400
commitdacefedb34e538e9934556ffe5eaad177e7a9718 (patch)
treeeece4baa9b45a840014fec91abdc6ec752d03e03 /drivers/net/wireless
parent34f5a70c08530bb0b4724991a712a0ef6bbec39a (diff)
iwlwifi: rewrite RXON checks
The RXON checking is a bit magical, and prints out too much information if something goes wrong. Make it less magical and print out only the items that were actually wrong. Also remove the comment about removing it -- the driver is constantly changing so these checks are useful. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c102
1 files changed, 50 insertions, 52 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 09a4d1700952..ecf5c9b90089 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -510,76 +510,74 @@ void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
510} 510}
511EXPORT_SYMBOL(iwl_set_rxon_hwcrypto); 511EXPORT_SYMBOL(iwl_set_rxon_hwcrypto);
512 512
513/** 513/* validate RXON structure is valid */
514 * iwl_check_rxon_cmd - validate RXON structure is valid
515 *
516 * NOTE: This is really only useful during development and can eventually
517 * be #ifdef'd out once the driver is stable and folks aren't actively
518 * making changes
519 */
520int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx) 514int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
521{ 515{
522 int error = 0;
523 int counter = 1;
524 struct iwl_rxon_cmd *rxon = &ctx->staging; 516 struct iwl_rxon_cmd *rxon = &ctx->staging;
517 bool error = false;
525 518
526 if (rxon->flags & RXON_FLG_BAND_24G_MSK) { 519 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
527 error |= le32_to_cpu(rxon->flags & 520 if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) {
528 (RXON_FLG_TGJ_NARROW_BAND_MSK | 521 IWL_WARN(priv, "check 2.4G: wrong narrow\n");
529 RXON_FLG_RADAR_DETECT_MSK)); 522 error = true;
530 if (error) 523 }
531 IWL_WARN(priv, "check 24G fields %d | %d\n", 524 if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) {
532 counter++, error); 525 IWL_WARN(priv, "check 2.4G: wrong radar\n");
526 error = true;
527 }
533 } else { 528 } else {
534 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ? 529 if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) {
535 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK); 530 IWL_WARN(priv, "check 5.2G: not short slot!\n");
536 if (error) 531 error = true;
537 IWL_WARN(priv, "check 52 fields %d | %d\n", 532 }
538 counter++, error); 533 if (rxon->flags & RXON_FLG_CCK_MSK) {
539 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK); 534 IWL_WARN(priv, "check 5.2G: CCK!\n");
540 if (error) 535 error = true;
541 IWL_WARN(priv, "check 52 CCK %d | %d\n", 536 }
542 counter++, error); 537 }
543 } 538 if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) {
544 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1; 539 IWL_WARN(priv, "mac/bssid mcast!\n");
545 if (error) 540 error = true;
546 IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error); 541 }
547 542
548 /* make sure basic rates 6Mbps and 1Mbps are supported */ 543 /* make sure basic rates 6Mbps and 1Mbps are supported */
549 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) && 544 if ((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0 &&
550 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0)); 545 (rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0) {
551 if (error) 546 IWL_WARN(priv, "neither 1 nor 6 are basic\n");
552 IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error); 547 error = true;
548 }
553 549
554 error |= (le16_to_cpu(rxon->assoc_id) > 2007); 550 if (le16_to_cpu(rxon->assoc_id) > 2007) {
555 if (error) 551 IWL_WARN(priv, "aid > 2007\n");
556 IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error); 552 error = true;
553 }
557 554
558 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) 555 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
559 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)); 556 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) {
560 if (error) 557 IWL_WARN(priv, "CCK and short slot\n");
561 IWL_WARN(priv, "check CCK and short slot %d | %d\n", 558 error = true;
562 counter++, error); 559 }
563 560
564 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) 561 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
565 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)); 562 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) {
566 if (error) 563 IWL_WARN(priv, "CCK and auto detect");
567 IWL_WARN(priv, "check CCK & auto detect %d | %d\n", 564 error = true;
568 counter++, error); 565 }
569 566
570 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | 567 if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
571 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK); 568 RXON_FLG_TGG_PROTECT_MSK)) ==
572 if (error) 569 RXON_FLG_TGG_PROTECT_MSK) {
573 IWL_WARN(priv, "check TGG and auto detect %d | %d\n", 570 IWL_WARN(priv, "TGg but no auto-detect\n");
574 counter++, error); 571 error = true;
572 }
575 573
576 if (error) 574 if (error)
577 IWL_WARN(priv, "Tuning to channel %d\n", 575 IWL_WARN(priv, "Tuning to channel %d\n",
578 le16_to_cpu(rxon->channel)); 576 le16_to_cpu(rxon->channel));
579 577
580 if (error) { 578 if (error) {
581 IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n"); 579 IWL_ERR(priv, "Invalid RXON\n");
582 return -1; 580 return -EINVAL;
583 } 581 }
584 return 0; 582 return 0;
585} 583}