No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / isc / atheros_hal / dist / ar5212 / ar5212_phy.c
blob8d6b596d784efc511adadf257e6c9fe1cf8107d0
1 /*
2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * $Id: ar5212_phy.c,v 1.2 2008/12/11 05:30:29 alc Exp $
19 #include "opt_ah.h"
21 #include "ah.h"
22 #include "ah_internal.h"
24 #include "ar5212/ar5212.h"
26 /* shorthands to compact tables for readability */
27 #define OFDM IEEE80211_T_OFDM
28 #define CCK IEEE80211_T_CCK
29 #define TURBO IEEE80211_T_TURBO
31 HAL_RATE_TABLE ar5212_11a_table = {
32 8, /* number of rates */
33 { 0 },
35 /* short ctrl */
36 /* valid rateCode Preamble dot11Rate Rate */
37 /* 6 Mb */ { AH_TRUE, OFDM, 6000, 0x0b, 0x00, (0x80|12), 0, 0, 0 },
38 /* 9 Mb */ { AH_TRUE, OFDM, 9000, 0x0f, 0x00, 18, 0, 0, 0 },
39 /* 12 Mb */ { AH_TRUE, OFDM, 12000, 0x0a, 0x00, (0x80|24), 2, 0, 0 },
40 /* 18 Mb */ { AH_TRUE, OFDM, 18000, 0x0e, 0x00, 36, 2, 0, 0 },
41 /* 24 Mb */ { AH_TRUE, OFDM, 24000, 0x09, 0x00, (0x80|48), 4, 0, 0 },
42 /* 36 Mb */ { AH_TRUE, OFDM, 36000, 0x0d, 0x00, 72, 4, 0, 0 },
43 /* 48 Mb */ { AH_TRUE, OFDM, 48000, 0x08, 0x00, 96, 4, 0, 0 },
44 /* 54 Mb */ { AH_TRUE, OFDM, 54000, 0x0c, 0x00, 108, 4, 0, 0 }
48 HAL_RATE_TABLE ar5212_half_table = {
49 8, /* number of rates */
50 { 0 },
52 /* short ctrl */
53 /* valid rateCode Preamble dot11Rate Rate */
54 /* 6 Mb */ { AH_TRUE, OFDM, 3000, 0x0b, 0x00, (0x80|6), 0, 0, 0 },
55 /* 9 Mb */ { AH_TRUE, OFDM, 4500, 0x0f, 0x00, 9, 0, 0, 0 },
56 /* 12 Mb */ { AH_TRUE, OFDM, 6000, 0x0a, 0x00, (0x80|12), 2, 0, 0 },
57 /* 18 Mb */ { AH_TRUE, OFDM, 9000, 0x0e, 0x00, 18, 2, 0, 0 },
58 /* 24 Mb */ { AH_TRUE, OFDM, 12000, 0x09, 0x00, (0x80|24), 4, 0, 0 },
59 /* 36 Mb */ { AH_TRUE, OFDM, 18000, 0x0d, 0x00, 36, 4, 0, 0 },
60 /* 48 Mb */ { AH_TRUE, OFDM, 24000, 0x08, 0x00, 48, 4, 0, 0 },
61 /* 54 Mb */ { AH_TRUE, OFDM, 27000, 0x0c, 0x00, 54, 4, 0, 0 }
65 HAL_RATE_TABLE ar5212_quarter_table = {
66 8, /* number of rates */
67 { 0 },
69 /* short ctrl */
70 /* valid rateCode Preamble dot11Rate Rate */
71 /* 6 Mb */ { AH_TRUE, OFDM, 1500, 0x0b, 0x00, (0x80|3), 0, 0, 0 },
72 /* 9 Mb */ { AH_TRUE, OFDM, 2250, 0x0f, 0x00, 4, 0, 0, 0 },
73 /* 12 Mb */ { AH_TRUE, OFDM, 3000, 0x0a, 0x00, (0x80|6), 2, 0, 0 },
74 /* 18 Mb */ { AH_TRUE, OFDM, 4500, 0x0e, 0x00, 9, 2, 0, 0 },
75 /* 24 Mb */ { AH_TRUE, OFDM, 6000, 0x09, 0x00, (0x80|12), 4, 0, 0 },
76 /* 36 Mb */ { AH_TRUE, OFDM, 9000, 0x0d, 0x00, 18, 4, 0, 0 },
77 /* 48 Mb */ { AH_TRUE, OFDM, 12000, 0x08, 0x00, 24, 4, 0, 0 },
78 /* 54 Mb */ { AH_TRUE, OFDM, 13500, 0x0c, 0x00, 27, 4, 0, 0 }
82 HAL_RATE_TABLE ar5212_turbog_table = {
83 7, /* number of rates */
84 { 0 },
86 /* short ctrl */
87 /* valid rateCode Preamble dot11Rate Rate */
88 /* 6 Mb */ { AH_TRUE, TURBO, 6000, 0x0b, 0x00, (0x80|12), 0, 0, 0 },
89 /* 12 Mb */ { AH_TRUE, TURBO, 12000, 0x0a, 0x00, (0x80|24), 2, 0, 0 },
90 /* 18 Mb */ { AH_TRUE, TURBO, 18000, 0x0e, 0x00, 36, 2, 0, 0 },
91 /* 24 Mb */ { AH_TRUE, TURBO, 24000, 0x09, 0x00, (0x80|48), 3, 0, 0 },
92 /* 36 Mb */ { AH_TRUE, TURBO, 36000, 0x0d, 0x00, 72, 3, 0, 0 },
93 /* 48 Mb */ { AH_TRUE, TURBO, 48000, 0x08, 0x00, 96, 3, 0, 0 },
94 /* 54 Mb */ { AH_TRUE, TURBO, 54000, 0x0c, 0x00, 108, 3, 0, 0 }
98 HAL_RATE_TABLE ar5212_turboa_table = {
99 8, /* number of rates */
100 { 0 },
102 /* short ctrl */
103 /* valid rateCode Preamble dot11Rate Rate */
104 /* 6 Mb */ { AH_TRUE, TURBO, 6000, 0x0b, 0x00, (0x80|12), 0, 0, 0 },
105 /* 9 Mb */ { AH_TRUE, TURBO, 9000, 0x0f, 0x00, 18, 0, 0, 0 },
106 /* 12 Mb */ { AH_TRUE, TURBO, 12000, 0x0a, 0x00, (0x80|24), 2, 0, 0 },
107 /* 18 Mb */ { AH_TRUE, TURBO, 18000, 0x0e, 0x00, 36, 2, 0, 0 },
108 /* 24 Mb */ { AH_TRUE, TURBO, 24000, 0x09, 0x00, (0x80|48), 4, 0, 0 },
109 /* 36 Mb */ { AH_TRUE, TURBO, 36000, 0x0d, 0x00, 72, 4, 0, 0 },
110 /* 48 Mb */ { AH_TRUE, TURBO, 48000, 0x08, 0x00, 96, 4, 0, 0 },
111 /* 54 Mb */ { AH_TRUE, TURBO, 54000, 0x0c, 0x00, 108, 4, 0, 0 }
115 HAL_RATE_TABLE ar5212_11b_table = {
116 4, /* number of rates */
117 { 0 },
119 /* short ctrl */
120 /* valid rateCode Preamble dot11Rate Rate */
121 /* 1 Mb */ { AH_TRUE, CCK, 1000, 0x1b, 0x00, (0x80| 2), 0, 0, 0 },
122 /* 2 Mb */ { AH_TRUE, CCK, 2000, 0x1a, 0x04, (0x80| 4), 1, 0, 0 },
123 /* 5.5 Mb */ { AH_TRUE, CCK, 5500, 0x19, 0x04, (0x80|11), 1, 0, 0 },
124 /* 11 Mb */ { AH_TRUE, CCK, 11000, 0x18, 0x04, (0x80|22), 1, 0, 0 }
129 /* Venice TODO: roundUpRate() is broken when the rate table does not represent rates
130 * in increasing order e.g. 5.5, 11, 6, 9.
131 * An average rate of 6 Mbps will currently map to 11 Mbps.
133 HAL_RATE_TABLE ar5212_11g_table = {
134 12, /* number of rates */
135 { 0 },
137 /* short ctrl */
138 /* valid rateCode Preamble dot11Rate Rate */
139 /* 1 Mb */ { AH_TRUE, CCK, 1000, 0x1b, 0x00, (0x80| 2), 0, 0, 0 },
140 /* 2 Mb */ { AH_TRUE, CCK, 2000, 0x1a, 0x04, (0x80| 4), 1, 0, 0 },
141 /* 5.5 Mb */ { AH_TRUE, CCK, 5500, 0x19, 0x04, (0x80|11), 2, 0, 0 },
142 /* 11 Mb */ { AH_TRUE, CCK, 11000, 0x18, 0x04, (0x80|22), 3, 0, 0 },
143 /* remove rates 6, 9 from rate ctrl */
144 /* 6 Mb */ { AH_FALSE, OFDM, 6000, 0x0b, 0x00, 12, 4, 0, 0 },
145 /* 9 Mb */ { AH_FALSE, OFDM, 9000, 0x0f, 0x00, 18, 4, 0, 0 },
146 /* 12 Mb */ { AH_TRUE, OFDM, 12000, 0x0a, 0x00, 24, 6, 0, 0 },
147 /* 18 Mb */ { AH_TRUE, OFDM, 18000, 0x0e, 0x00, 36, 6, 0, 0 },
148 /* 24 Mb */ { AH_TRUE, OFDM, 24000, 0x09, 0x00, 48, 8, 0, 0 },
149 /* 36 Mb */ { AH_TRUE, OFDM, 36000, 0x0d, 0x00, 72, 8, 0, 0 },
150 /* 48 Mb */ { AH_TRUE, OFDM, 48000, 0x08, 0x00, 96, 8, 0, 0 },
151 /* 54 Mb */ { AH_TRUE, OFDM, 54000, 0x0c, 0x00, 108, 8, 0, 0 }
155 #undef OFDM
156 #undef CCK
157 #undef TURBO
158 #undef XR
160 const HAL_RATE_TABLE *
161 ar5212GetRateTable(struct ath_hal *ah, u_int mode)
163 HAL_RATE_TABLE *rt;
164 switch (mode) {
165 case HAL_MODE_11A:
166 rt = &ar5212_11a_table;
167 break;
168 case HAL_MODE_11B:
169 rt = &ar5212_11b_table;
170 break;
171 case HAL_MODE_11G:
172 #ifdef notdef
173 case HAL_MODE_PUREG:
174 #endif
175 rt = &ar5212_11g_table;
176 break;
177 case HAL_MODE_108A:
178 case HAL_MODE_TURBO:
179 rt = &ar5212_turboa_table;
180 break;
181 case HAL_MODE_108G:
182 rt = &ar5212_turbog_table;
183 break;
184 case HAL_MODE_11A_HALF_RATE:
185 case HAL_MODE_11G_HALF_RATE:
186 rt = &ar5212_half_table;
187 break;
188 case HAL_MODE_11A_QUARTER_RATE:
189 case HAL_MODE_11G_QUARTER_RATE:
190 rt = &ar5212_quarter_table;
191 break;
192 default:
193 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
194 __func__, mode);
195 return AH_NULL;
197 ath_hal_setupratetable(ah, rt);
198 return rt;