iwl-agn-hcmd-check.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include <linux/kernel.h>
  29. #include <net/mac80211.h>
  30. #include "iwl-dev.h"
  31. #include "iwl-debug.h"
  32. #include "iwl-commands.h"
  33. /**
  34. * iwl_check_rxon_cmd - validate RXON structure is valid
  35. *
  36. * NOTE: This is really only useful during development and can eventually
  37. * be #ifdef'd out once the driver is stable and folks aren't actively
  38. * making changes
  39. */
  40. int iwl_agn_check_rxon_cmd(struct iwl_priv *priv)
  41. {
  42. int error = 0;
  43. int counter = 1;
  44. struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
  45. if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
  46. error |= le32_to_cpu(rxon->flags &
  47. (RXON_FLG_TGJ_NARROW_BAND_MSK |
  48. RXON_FLG_RADAR_DETECT_MSK));
  49. if (error)
  50. IWL_WARN(priv, "check 24G fields %d | %d\n",
  51. counter++, error);
  52. } else {
  53. error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
  54. 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
  55. if (error)
  56. IWL_WARN(priv, "check 52 fields %d | %d\n",
  57. counter++, error);
  58. error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
  59. if (error)
  60. IWL_WARN(priv, "check 52 CCK %d | %d\n",
  61. counter++, error);
  62. }
  63. error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
  64. if (error)
  65. IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error);
  66. /* make sure basic rates 6Mbps and 1Mbps are supported */
  67. error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
  68. ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
  69. if (error)
  70. IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error);
  71. error |= (le16_to_cpu(rxon->assoc_id) > 2007);
  72. if (error)
  73. IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error);
  74. error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
  75. == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
  76. if (error)
  77. IWL_WARN(priv, "check CCK and short slot %d | %d\n",
  78. counter++, error);
  79. error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
  80. == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
  81. if (error)
  82. IWL_WARN(priv, "check CCK & auto detect %d | %d\n",
  83. counter++, error);
  84. error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
  85. RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
  86. if (error)
  87. IWL_WARN(priv, "check TGG and auto detect %d | %d\n",
  88. counter++, error);
  89. if (error)
  90. IWL_WARN(priv, "Tuning to channel %d\n",
  91. le16_to_cpu(rxon->channel));
  92. if (error) {
  93. IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n");
  94. return -1;
  95. }
  96. return 0;
  97. }