Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Reinette Chatre | eb7ae89 | 2008-03-11 16:17:17 -0700 | [diff] [blame] | 3 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 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 | |
| 27 | #ifndef __iwl_3945_rs_h__ |
| 28 | #define __iwl_3945_rs_h__ |
| 29 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 30 | struct iwl3945_rate_info { |
Ben Cahill | 9fbab51 | 2007-11-29 11:09:47 +0800 | [diff] [blame] | 31 | u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ |
| 32 | u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 33 | u8 prev_ieee; /* previous rate in IEEE speeds */ |
| 34 | u8 next_ieee; /* next rate in IEEE speeds */ |
| 35 | u8 prev_rs; /* previous rate used in rs algo */ |
| 36 | u8 next_rs; /* next rate used in rs algo */ |
| 37 | u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ |
| 38 | u8 next_rs_tgg; /* next rate used in TGG rs algo */ |
Tomas Winkler | 8211ef7 | 2008-03-02 01:36:04 +0200 | [diff] [blame] | 39 | u8 table_rs_index; /* index in rate scale table cmd */ |
| 40 | u8 prev_table_rs; /* prev in rate table cmd */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Ben Cahill | 9fbab51 | 2007-11-29 11:09:47 +0800 | [diff] [blame] | 43 | /* |
| 44 | * These serve as indexes into |
| 45 | * struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT]; |
| 46 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 47 | enum { |
Mohamed Abbas | 14577f2 | 2007-11-12 11:37:42 +0800 | [diff] [blame] | 48 | IWL_RATE_1M_INDEX = 0, |
| 49 | IWL_RATE_2M_INDEX, |
| 50 | IWL_RATE_5M_INDEX, |
| 51 | IWL_RATE_11M_INDEX, |
| 52 | IWL_RATE_6M_INDEX, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 53 | IWL_RATE_9M_INDEX, |
| 54 | IWL_RATE_12M_INDEX, |
| 55 | IWL_RATE_18M_INDEX, |
| 56 | IWL_RATE_24M_INDEX, |
| 57 | IWL_RATE_36M_INDEX, |
| 58 | IWL_RATE_48M_INDEX, |
| 59 | IWL_RATE_54M_INDEX, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 60 | IWL_RATE_COUNT, |
| 61 | IWL_RATE_INVM_INDEX, |
| 62 | IWL_RATE_INVALID = IWL_RATE_INVM_INDEX |
| 63 | }; |
| 64 | |
| 65 | enum { |
Mohamed Abbas | 14577f2 | 2007-11-12 11:37:42 +0800 | [diff] [blame] | 66 | IWL_RATE_6M_INDEX_TABLE = 0, |
| 67 | IWL_RATE_9M_INDEX_TABLE, |
| 68 | IWL_RATE_12M_INDEX_TABLE, |
| 69 | IWL_RATE_18M_INDEX_TABLE, |
| 70 | IWL_RATE_24M_INDEX_TABLE, |
| 71 | IWL_RATE_36M_INDEX_TABLE, |
| 72 | IWL_RATE_48M_INDEX_TABLE, |
| 73 | IWL_RATE_54M_INDEX_TABLE, |
| 74 | IWL_RATE_1M_INDEX_TABLE, |
| 75 | IWL_RATE_2M_INDEX_TABLE, |
| 76 | IWL_RATE_5M_INDEX_TABLE, |
| 77 | IWL_RATE_11M_INDEX_TABLE, |
| 78 | IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX, |
| 79 | }; |
| 80 | |
| 81 | enum { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 82 | IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX, |
| 83 | IWL_LAST_OFDM_RATE = IWL_RATE_54M_INDEX, |
| 84 | IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX, |
| 85 | IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX, |
| 86 | }; |
| 87 | |
| 88 | /* #define vs. enum to keep from defaulting to 'large integer' */ |
Reinette Chatre | 8a1b024 | 2008-01-14 17:46:25 -0800 | [diff] [blame] | 89 | #define IWL_RATE_6M_MASK (1 << IWL_RATE_6M_INDEX) |
| 90 | #define IWL_RATE_9M_MASK (1 << IWL_RATE_9M_INDEX) |
| 91 | #define IWL_RATE_12M_MASK (1 << IWL_RATE_12M_INDEX) |
| 92 | #define IWL_RATE_18M_MASK (1 << IWL_RATE_18M_INDEX) |
| 93 | #define IWL_RATE_24M_MASK (1 << IWL_RATE_24M_INDEX) |
| 94 | #define IWL_RATE_36M_MASK (1 << IWL_RATE_36M_INDEX) |
| 95 | #define IWL_RATE_48M_MASK (1 << IWL_RATE_48M_INDEX) |
| 96 | #define IWL_RATE_54M_MASK (1 << IWL_RATE_54M_INDEX) |
| 97 | #define IWL_RATE_1M_MASK (1 << IWL_RATE_1M_INDEX) |
| 98 | #define IWL_RATE_2M_MASK (1 << IWL_RATE_2M_INDEX) |
| 99 | #define IWL_RATE_5M_MASK (1 << IWL_RATE_5M_INDEX) |
| 100 | #define IWL_RATE_11M_MASK (1 << IWL_RATE_11M_INDEX) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 101 | |
Ben Cahill | 9fbab51 | 2007-11-29 11:09:47 +0800 | [diff] [blame] | 102 | /* 3945 uCode API values for (legacy) bit rates, both OFDM and CCK */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 103 | enum { |
| 104 | IWL_RATE_6M_PLCP = 13, |
| 105 | IWL_RATE_9M_PLCP = 15, |
| 106 | IWL_RATE_12M_PLCP = 5, |
| 107 | IWL_RATE_18M_PLCP = 7, |
| 108 | IWL_RATE_24M_PLCP = 9, |
| 109 | IWL_RATE_36M_PLCP = 11, |
| 110 | IWL_RATE_48M_PLCP = 1, |
| 111 | IWL_RATE_54M_PLCP = 3, |
| 112 | IWL_RATE_1M_PLCP = 10, |
| 113 | IWL_RATE_2M_PLCP = 20, |
| 114 | IWL_RATE_5M_PLCP = 55, |
| 115 | IWL_RATE_11M_PLCP = 110, |
| 116 | }; |
| 117 | |
Ben Cahill | 9fbab51 | 2007-11-29 11:09:47 +0800 | [diff] [blame] | 118 | /* MAC header values for bit rates */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 119 | enum { |
| 120 | IWL_RATE_6M_IEEE = 12, |
| 121 | IWL_RATE_9M_IEEE = 18, |
| 122 | IWL_RATE_12M_IEEE = 24, |
| 123 | IWL_RATE_18M_IEEE = 36, |
| 124 | IWL_RATE_24M_IEEE = 48, |
| 125 | IWL_RATE_36M_IEEE = 72, |
| 126 | IWL_RATE_48M_IEEE = 96, |
| 127 | IWL_RATE_54M_IEEE = 108, |
| 128 | IWL_RATE_1M_IEEE = 2, |
| 129 | IWL_RATE_2M_IEEE = 4, |
| 130 | IWL_RATE_5M_IEEE = 11, |
| 131 | IWL_RATE_11M_IEEE = 22, |
| 132 | }; |
| 133 | |
| 134 | #define IWL_CCK_BASIC_RATES_MASK \ |
| 135 | (IWL_RATE_1M_MASK | \ |
| 136 | IWL_RATE_2M_MASK) |
| 137 | |
| 138 | #define IWL_CCK_RATES_MASK \ |
| 139 | (IWL_BASIC_RATES_MASK | \ |
| 140 | IWL_RATE_5M_MASK | \ |
| 141 | IWL_RATE_11M_MASK) |
| 142 | |
| 143 | #define IWL_OFDM_BASIC_RATES_MASK \ |
| 144 | (IWL_RATE_6M_MASK | \ |
| 145 | IWL_RATE_12M_MASK | \ |
| 146 | IWL_RATE_24M_MASK) |
| 147 | |
| 148 | #define IWL_OFDM_RATES_MASK \ |
| 149 | (IWL_OFDM_BASIC_RATES_MASK | \ |
| 150 | IWL_RATE_9M_MASK | \ |
| 151 | IWL_RATE_18M_MASK | \ |
| 152 | IWL_RATE_36M_MASK | \ |
| 153 | IWL_RATE_48M_MASK | \ |
| 154 | IWL_RATE_54M_MASK) |
| 155 | |
| 156 | #define IWL_BASIC_RATES_MASK \ |
| 157 | (IWL_OFDM_BASIC_RATES_MASK | \ |
| 158 | IWL_CCK_BASIC_RATES_MASK) |
| 159 | |
Reinette Chatre | 8a1b024 | 2008-01-14 17:46:25 -0800 | [diff] [blame] | 160 | #define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 161 | |
Tomas Winkler | 28447f3 | 2008-03-06 17:36:54 -0800 | [diff] [blame] | 162 | #define IWL_INV_TPT -1 |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 163 | |
| 164 | #define IWL_MIN_RSSI_VAL -100 |
| 165 | #define IWL_MAX_RSSI_VAL 0 |
| 166 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 167 | extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT]; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 168 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 169 | static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 170 | { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 171 | u8 rate = iwl3945_rates[rate_index].prev_ieee; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 172 | |
| 173 | if (rate == IWL_RATE_INVALID) |
| 174 | rate = rate_index; |
| 175 | return rate; |
| 176 | } |
| 177 | |
| 178 | /** |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 179 | * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 180 | * |
Ian Schram | 01ebd06 | 2007-10-25 17:15:22 +0800 | [diff] [blame] | 181 | * The specific throughput table used is based on the type of network |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 182 | * the associated with, including A, B, G, and G w/ TGG protection |
| 183 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 184 | extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 185 | |
| 186 | /** |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 187 | * iwl3945_rate_control_register - Register the rate control algorithm callbacks |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 188 | * |
| 189 | * Since the rate control algorithm is hardware specific, there is no need |
| 190 | * or reason to place it as a stand alone module. The driver can call |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 191 | * iwl3945_rate_control_register in order to register the rate control callbacks |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 192 | * with the mac80211 subsystem. This should be performed prior to calling |
| 193 | * ieee80211_register_hw |
| 194 | * |
| 195 | */ |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 196 | extern int iwl3945_rate_control_register(void); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 197 | |
| 198 | /** |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 199 | * iwl3945_rate_control_unregister - Unregister the rate control callbacks |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 200 | * |
| 201 | * This should be called after calling ieee80211_unregister_hw, but before |
| 202 | * the driver is unloaded. |
| 203 | */ |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 204 | extern void iwl3945_rate_control_unregister(void); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 205 | |
| 206 | #endif |