1*572ff6f6SMatthew Dillon /*
2*572ff6f6SMatthew Dillon * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3*572ff6f6SMatthew Dillon * Copyright (c) 2002-2008 Atheros Communications, Inc.
4*572ff6f6SMatthew Dillon *
5*572ff6f6SMatthew Dillon * Permission to use, copy, modify, and/or distribute this software for any
6*572ff6f6SMatthew Dillon * purpose with or without fee is hereby granted, provided that the above
7*572ff6f6SMatthew Dillon * copyright notice and this permission notice appear in all copies.
8*572ff6f6SMatthew Dillon *
9*572ff6f6SMatthew Dillon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*572ff6f6SMatthew Dillon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*572ff6f6SMatthew Dillon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*572ff6f6SMatthew Dillon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*572ff6f6SMatthew Dillon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*572ff6f6SMatthew Dillon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*572ff6f6SMatthew Dillon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*572ff6f6SMatthew Dillon *
17*572ff6f6SMatthew Dillon * $FreeBSD$
18*572ff6f6SMatthew Dillon */
19*572ff6f6SMatthew Dillon #include "opt_ah.h"
20*572ff6f6SMatthew Dillon
21*572ff6f6SMatthew Dillon #include "ah.h"
22*572ff6f6SMatthew Dillon #include "ah_internal.h"
23*572ff6f6SMatthew Dillon
24*572ff6f6SMatthew Dillon #include "ar5416/ar5416.h"
25*572ff6f6SMatthew Dillon
26*572ff6f6SMatthew Dillon /* shorthands to compact tables for readability */
27*572ff6f6SMatthew Dillon #define OFDM IEEE80211_T_OFDM
28*572ff6f6SMatthew Dillon #define CCK IEEE80211_T_CCK
29*572ff6f6SMatthew Dillon #define HT IEEE80211_T_HT
30*572ff6f6SMatthew Dillon
31*572ff6f6SMatthew Dillon HAL_RATE_TABLE ar5416_11ng_table = {
32*572ff6f6SMatthew Dillon 28, /* number of rates */
33*572ff6f6SMatthew Dillon { 0 },
34*572ff6f6SMatthew Dillon {
35*572ff6f6SMatthew Dillon /* short ctrl */
36*572ff6f6SMatthew Dillon /* valid rateCode Preamble dot11Rate Rate */
37*572ff6f6SMatthew Dillon /* 1 Mb */ { AH_TRUE, CCK, 1000, 0x1b, 0x00, (0x80| 2), 0 },
38*572ff6f6SMatthew Dillon /* 2 Mb */ { AH_TRUE, CCK, 2000, 0x1a, 0x04, (0x80| 4), 1 },
39*572ff6f6SMatthew Dillon /* 5.5 Mb */ { AH_TRUE, CCK, 5500, 0x19, 0x04, (0x80|11), 2 },
40*572ff6f6SMatthew Dillon /* 11 Mb */ { AH_TRUE, CCK, 11000, 0x18, 0x04, (0x80|22), 3 },
41*572ff6f6SMatthew Dillon /* Remove rates 6, 9 from rate ctrl */
42*572ff6f6SMatthew Dillon /* 6 Mb */ { AH_FALSE, OFDM, 6000, 0x0b, 0x00, 12, 4 },
43*572ff6f6SMatthew Dillon /* 9 Mb */ { AH_FALSE, OFDM, 9000, 0x0f, 0x00, 18, 4 },
44*572ff6f6SMatthew Dillon /* 12 Mb */ { AH_TRUE, OFDM, 12000, 0x0a, 0x00, 24, 6 },
45*572ff6f6SMatthew Dillon /* 18 Mb */ { AH_TRUE, OFDM, 18000, 0x0e, 0x00, 36, 6 },
46*572ff6f6SMatthew Dillon /* 24 Mb */ { AH_TRUE, OFDM, 24000, 0x09, 0x00, 48, 8 },
47*572ff6f6SMatthew Dillon /* 36 Mb */ { AH_TRUE, OFDM, 36000, 0x0d, 0x00, 72, 8 },
48*572ff6f6SMatthew Dillon /* 48 Mb */ { AH_TRUE, OFDM, 48000, 0x08, 0x00, 96, 8 },
49*572ff6f6SMatthew Dillon /* 54 Mb */ { AH_TRUE, OFDM, 54000, 0x0c, 0x00, 108, 8 },
50*572ff6f6SMatthew Dillon /* 6.5 Mb */ { AH_TRUE, HT, 6500, 0x80, 0x00, 0, 8 },
51*572ff6f6SMatthew Dillon /* 13 Mb */ { AH_TRUE, HT, 13000, 0x81, 0x00, 1, 8 },
52*572ff6f6SMatthew Dillon /*19.5 Mb */ { AH_TRUE, HT, 19500, 0x82, 0x00, 2, 8 },
53*572ff6f6SMatthew Dillon /* 26 Mb */ { AH_TRUE, HT, 26000, 0x83, 0x00, 3, 8 },
54*572ff6f6SMatthew Dillon /* 39 Mb */ { AH_TRUE, HT, 39000, 0x84, 0x00, 4, 8 },
55*572ff6f6SMatthew Dillon /* 52 Mb */ { AH_TRUE, HT, 52000, 0x85, 0x00, 5, 8 },
56*572ff6f6SMatthew Dillon /*58.5 Mb */ { AH_TRUE, HT, 58500, 0x86, 0x00, 6, 8 },
57*572ff6f6SMatthew Dillon /* 65 Mb */ { AH_TRUE, HT, 65000, 0x87, 0x00, 7, 8 },
58*572ff6f6SMatthew Dillon /* 13 Mb */ { AH_TRUE, HT, 13000, 0x88, 0x00, 8, 8 },
59*572ff6f6SMatthew Dillon /* 26 Mb */ { AH_TRUE, HT, 26000, 0x89, 0x00, 9, 8 },
60*572ff6f6SMatthew Dillon /* 39 Mb */ { AH_TRUE, HT, 39000, 0x8a, 0x00, 10, 8 },
61*572ff6f6SMatthew Dillon /* 52 Mb */ { AH_TRUE, HT, 52000, 0x8b, 0x00, 11, 8 },
62*572ff6f6SMatthew Dillon /* 78 Mb */ { AH_TRUE, HT, 78000, 0x8c, 0x00, 12, 8 },
63*572ff6f6SMatthew Dillon /* 104 Mb */ { AH_TRUE, HT, 104000, 0x8d, 0x00, 13, 8 },
64*572ff6f6SMatthew Dillon /* 117 Mb */ { AH_TRUE, HT, 117000, 0x8e, 0x00, 14, 8 },
65*572ff6f6SMatthew Dillon /* 130 Mb */ { AH_TRUE, HT, 130000, 0x8f, 0x00, 15, 8 },
66*572ff6f6SMatthew Dillon },
67*572ff6f6SMatthew Dillon };
68*572ff6f6SMatthew Dillon
69*572ff6f6SMatthew Dillon static HAL_RATE_TABLE ar5416_11na_table = {
70*572ff6f6SMatthew Dillon 24, /* number of rates */
71*572ff6f6SMatthew Dillon { 0 },
72*572ff6f6SMatthew Dillon {
73*572ff6f6SMatthew Dillon /* short ctrl */
74*572ff6f6SMatthew Dillon /* valid rateCode Preamble dot11Rate Rate */
75*572ff6f6SMatthew Dillon /* 6 Mb */ { AH_TRUE, OFDM, 6000, 0x0b, 0x00, (0x80|12), 0 },
76*572ff6f6SMatthew Dillon /* 9 Mb */ { AH_TRUE, OFDM, 9000, 0x0f, 0x00, 18, 0 },
77*572ff6f6SMatthew Dillon /* 12 Mb */ { AH_TRUE, OFDM, 12000, 0x0a, 0x00, (0x80|24), 2 },
78*572ff6f6SMatthew Dillon /* 18 Mb */ { AH_TRUE, OFDM, 18000, 0x0e, 0x00, 36, 2 },
79*572ff6f6SMatthew Dillon /* 24 Mb */ { AH_TRUE, OFDM, 24000, 0x09, 0x00, (0x80|48), 4 },
80*572ff6f6SMatthew Dillon /* 36 Mb */ { AH_TRUE, OFDM, 36000, 0x0d, 0x00, 72, 4 },
81*572ff6f6SMatthew Dillon /* 48 Mb */ { AH_TRUE, OFDM, 48000, 0x08, 0x00, 96, 4 },
82*572ff6f6SMatthew Dillon /* 54 Mb */ { AH_TRUE, OFDM, 54000, 0x0c, 0x00, 108, 4 },
83*572ff6f6SMatthew Dillon /* 6.5 Mb */ { AH_TRUE, HT, 6500, 0x80, 0x00, 0, 4 },
84*572ff6f6SMatthew Dillon /* 13 Mb */ { AH_TRUE, HT, 13000, 0x81, 0x00, 1, 4 },
85*572ff6f6SMatthew Dillon /*19.5 Mb */ { AH_TRUE, HT, 19500, 0x82, 0x00, 2, 4 },
86*572ff6f6SMatthew Dillon /* 26 Mb */ { AH_TRUE, HT, 26000, 0x83, 0x00, 3, 4 },
87*572ff6f6SMatthew Dillon /* 39 Mb */ { AH_TRUE, HT, 39000, 0x84, 0x00, 4, 4 },
88*572ff6f6SMatthew Dillon /* 52 Mb */ { AH_TRUE, HT, 52000, 0x85, 0x00, 5, 4 },
89*572ff6f6SMatthew Dillon /*58.5 Mb */ { AH_TRUE, HT, 58500, 0x86, 0x00, 6, 4 },
90*572ff6f6SMatthew Dillon /* 65 Mb */ { AH_TRUE, HT, 65000, 0x87, 0x00, 7, 4 },
91*572ff6f6SMatthew Dillon /* 13 Mb */ { AH_TRUE, HT, 13000, 0x88, 0x00, 8, 4 },
92*572ff6f6SMatthew Dillon /* 26 Mb */ { AH_TRUE, HT, 26000, 0x89, 0x00, 9, 4 },
93*572ff6f6SMatthew Dillon /* 39 Mb */ { AH_TRUE, HT, 39000, 0x8a, 0x00, 10, 4 },
94*572ff6f6SMatthew Dillon /* 52 Mb */ { AH_TRUE, HT, 52000, 0x8b, 0x00, 11, 4 },
95*572ff6f6SMatthew Dillon /* 78 Mb */ { AH_TRUE, HT, 78000, 0x8c, 0x00, 12, 4 },
96*572ff6f6SMatthew Dillon /* 104 Mb */ { AH_TRUE, HT, 104000, 0x8d, 0x00, 13, 4 },
97*572ff6f6SMatthew Dillon /* 117 Mb */ { AH_TRUE, HT, 117000, 0x8e, 0x00, 14, 4 },
98*572ff6f6SMatthew Dillon /* 130 Mb */ { AH_TRUE, HT, 130000, 0x8f, 0x00, 15, 4 },
99*572ff6f6SMatthew Dillon },
100*572ff6f6SMatthew Dillon };
101*572ff6f6SMatthew Dillon
102*572ff6f6SMatthew Dillon #undef OFDM
103*572ff6f6SMatthew Dillon #undef CCK
104*572ff6f6SMatthew Dillon #undef HT
105*572ff6f6SMatthew Dillon
106*572ff6f6SMatthew Dillon const HAL_RATE_TABLE *
ar5416GetRateTable(struct ath_hal * ah,u_int mode)107*572ff6f6SMatthew Dillon ar5416GetRateTable(struct ath_hal *ah, u_int mode)
108*572ff6f6SMatthew Dillon {
109*572ff6f6SMatthew Dillon HAL_RATE_TABLE *rt;
110*572ff6f6SMatthew Dillon switch (mode) {
111*572ff6f6SMatthew Dillon case HAL_MODE_11NG_HT20:
112*572ff6f6SMatthew Dillon case HAL_MODE_11NG_HT40PLUS:
113*572ff6f6SMatthew Dillon case HAL_MODE_11NG_HT40MINUS:
114*572ff6f6SMatthew Dillon rt = &ar5416_11ng_table;
115*572ff6f6SMatthew Dillon break;
116*572ff6f6SMatthew Dillon case HAL_MODE_11NA_HT20:
117*572ff6f6SMatthew Dillon case HAL_MODE_11NA_HT40PLUS:
118*572ff6f6SMatthew Dillon case HAL_MODE_11NA_HT40MINUS:
119*572ff6f6SMatthew Dillon rt = &ar5416_11na_table;
120*572ff6f6SMatthew Dillon break;
121*572ff6f6SMatthew Dillon default:
122*572ff6f6SMatthew Dillon return ar5212GetRateTable(ah, mode);
123*572ff6f6SMatthew Dillon }
124*572ff6f6SMatthew Dillon ath_hal_setupratetable(ah, rt);
125*572ff6f6SMatthew Dillon return rt;
126*572ff6f6SMatthew Dillon }
127