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 $
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 }
160 const HAL_RATE_TABLE
*
161 ar5212GetRateTable(struct ath_hal
*ah
, u_int mode
)
166 rt
= &ar5212_11a_table
;
169 rt
= &ar5212_11b_table
;
175 rt
= &ar5212_11g_table
;
179 rt
= &ar5212_turboa_table
;
182 rt
= &ar5212_turbog_table
;
184 case HAL_MODE_11A_HALF_RATE
:
185 case HAL_MODE_11G_HALF_RATE
:
186 rt
= &ar5212_half_table
;
188 case HAL_MODE_11A_QUARTER_RATE
:
189 case HAL_MODE_11G_QUARTER_RATE
:
190 rt
= &ar5212_quarter_table
;
193 HALDEBUG(ah
, HAL_DEBUG_ANY
, "%s: invalid mode 0x%x\n",
197 ath_hal_setupratetable(ah
, rt
);