iwl-channel.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #ifndef __iwl_channel_h__
  27. #define __iwl_channel_h__
  28. #define IWL_NUM_SCAN_RATES (2)
  29. struct iwl_channel_tgd_info {
  30. u8 type;
  31. s8 max_power;
  32. };
  33. struct iwl_channel_tgh_info {
  34. s64 last_radar_time;
  35. };
  36. /* current Tx power values to use, one for each rate for each channel.
  37. * requested power is limited by:
  38. * -- regulatory EEPROM limits for this channel
  39. * -- hardware capabilities (clip-powers)
  40. * -- spectrum management
  41. * -- user preference (e.g. iwconfig)
  42. * when requested power is set, base power index must also be set. */
  43. struct iwl_channel_power_info {
  44. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  45. s8 power_table_index; /* actual (compenst'd) index into gain table */
  46. s8 base_power_index; /* gain index for power at factory temp. */
  47. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  48. };
  49. /* current scan Tx power values to use, one for each scan rate for each
  50. * channel. */
  51. struct iwl_scan_power_info {
  52. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  53. s8 power_table_index; /* actual (compenst'd) index into gain table */
  54. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  55. };
  56. /* Channel unlock period is 15 seconds. If no beacon or probe response
  57. * has been received within 15 seconds on a locked channel then the channel
  58. * remains locked. */
  59. #define TX_UNLOCK_PERIOD 15
  60. /* CSA lock period is 15 seconds. If a CSA has been received on a channel in
  61. * the last 15 seconds, the channel is locked */
  62. #define CSA_LOCK_PERIOD 15
  63. /*
  64. * One for each channel, holds all channel setup data
  65. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  66. * with one another!
  67. */
  68. #define IWL4965_MAX_RATE (33)
  69. struct iwl_channel_info {
  70. struct iwl_channel_tgd_info tgd;
  71. struct iwl_channel_tgh_info tgh;
  72. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  73. struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  74. * FAT channel */
  75. u8 channel; /* channel number */
  76. u8 flags; /* flags copied from EEPROM */
  77. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  78. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  79. s8 min_power; /* always 0 */
  80. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  81. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  82. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  83. u8 phymode; /* MODE_IEEE80211{A,B,G} */
  84. /* Radio/DSP gain settings for each "normal" data Tx rate.
  85. * These include, in addition to RF and DSP gain, a few fields for
  86. * remembering/modifying gain settings (indexes). */
  87. struct iwl_channel_power_info power_info[IWL4965_MAX_RATE];
  88. #if IWL == 4965
  89. /* FAT channel info */
  90. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  91. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  92. s8 fat_min_power; /* always 0 */
  93. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  94. u8 fat_flags; /* flags copied from EEPROM */
  95. u8 fat_extension_channel;
  96. #endif
  97. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  98. struct iwl_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  99. };
  100. struct iwl_clip_group {
  101. /* maximum power level to prevent clipping for each rate, derived by
  102. * us from this band's saturation power in EEPROM */
  103. const s8 clip_powers[IWL_MAX_RATES];
  104. };
  105. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  106. {
  107. if (ch_info == NULL)
  108. return 0;
  109. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  110. }
  111. static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
  112. {
  113. return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
  114. }
  115. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  116. {
  117. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  118. }
  119. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  120. {
  121. return ch_info->phymode == MODE_IEEE80211A;
  122. }
  123. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  124. {
  125. return ((ch_info->phymode == MODE_IEEE80211B) ||
  126. (ch_info->phymode == MODE_IEEE80211G));
  127. }
  128. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  129. {
  130. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  131. }
  132. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  133. {
  134. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  135. }
  136. extern const struct iwl_channel_info *iwl_get_channel_info(
  137. const struct iwl_priv *priv, int phymode, u16 channel);
  138. #endif