xref: /dflybsd-src/sys/dev/netif/ath/ath_hal/ar5211/ar5211_phy.c (revision 572ff6f6e8b95055988f178b6ba12ce77bb5b3c2)
1*572ff6f6SMatthew Dillon /*
2*572ff6f6SMatthew Dillon  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3*572ff6f6SMatthew Dillon  * Copyright (c) 2002-2006 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 "ar5211/ar5211.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	TURBO	IEEE80211_T_TURBO
30*572ff6f6SMatthew Dillon 
31*572ff6f6SMatthew Dillon HAL_RATE_TABLE ar5211_11a_table = {
32*572ff6f6SMatthew Dillon 	8,  /* 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 /*   6 Mb */ {  AH_TRUE, OFDM,    6000,     0x0b,    0x00, (0x80|12),   0 },
38*572ff6f6SMatthew Dillon /*   9 Mb */ {  AH_TRUE, OFDM,    9000,     0x0f,    0x00,        18,   0 },
39*572ff6f6SMatthew Dillon /*  12 Mb */ {  AH_TRUE, OFDM,   12000,     0x0a,    0x00, (0x80|24),   2 },
40*572ff6f6SMatthew Dillon /*  18 Mb */ {  AH_TRUE, OFDM,   18000,     0x0e,    0x00,        36,   2 },
41*572ff6f6SMatthew Dillon /*  24 Mb */ {  AH_TRUE, OFDM,   24000,     0x09,    0x00, (0x80|48),   4 },
42*572ff6f6SMatthew Dillon /*  36 Mb */ {  AH_TRUE, OFDM,   36000,     0x0d,    0x00,        72,   4 },
43*572ff6f6SMatthew Dillon /*  48 Mb */ {  AH_TRUE, OFDM,   48000,     0x08,    0x00,        96,   4 },
44*572ff6f6SMatthew Dillon /*  54 Mb */ {  AH_TRUE, OFDM,   54000,     0x0c,    0x00,       108,   4 }
45*572ff6f6SMatthew Dillon 	},
46*572ff6f6SMatthew Dillon };
47*572ff6f6SMatthew Dillon 
48*572ff6f6SMatthew Dillon HAL_RATE_TABLE ar5211_turbo_table = {
49*572ff6f6SMatthew Dillon 	8,  /* number of rates */
50*572ff6f6SMatthew Dillon 	{ 0 },
51*572ff6f6SMatthew Dillon 	{
52*572ff6f6SMatthew Dillon /*                                                 short            ctrl  */
53*572ff6f6SMatthew Dillon /*                valid                rateCode Preamble  dot11Rate Rate */
54*572ff6f6SMatthew Dillon /*   6 Mb */ {  AH_TRUE, TURBO,  12000,    0x0b,    0x00, (0x80|12),   0 },
55*572ff6f6SMatthew Dillon /*   9 Mb */ {  AH_TRUE, TURBO,  18000,    0x0f,    0x00,        18,   0 },
56*572ff6f6SMatthew Dillon /*  12 Mb */ {  AH_TRUE, TURBO,  24000,    0x0a,    0x00, (0x80|24),   2 },
57*572ff6f6SMatthew Dillon /*  18 Mb */ {  AH_TRUE, TURBO,  36000,    0x0e,    0x00,        36,   2 },
58*572ff6f6SMatthew Dillon /*  24 Mb */ {  AH_TRUE, TURBO,  48000,    0x09,    0x00, (0x80|48),   4 },
59*572ff6f6SMatthew Dillon /*  36 Mb */ {  AH_TRUE, TURBO,  72000,    0x0d,    0x00,        72,   4 },
60*572ff6f6SMatthew Dillon /*  48 Mb */ {  AH_TRUE, TURBO,  96000,    0x08,    0x00,        96,   4 },
61*572ff6f6SMatthew Dillon /*  54 Mb */ {  AH_TRUE, TURBO, 108000,    0x0c,    0x00,       108,   4 }
62*572ff6f6SMatthew Dillon 	},
63*572ff6f6SMatthew Dillon };
64*572ff6f6SMatthew Dillon 
65*572ff6f6SMatthew Dillon HAL_RATE_TABLE ar5211_11b_table = {
66*572ff6f6SMatthew Dillon 	4,  /* number of rates */
67*572ff6f6SMatthew Dillon 	{ 0 },
68*572ff6f6SMatthew Dillon 	{
69*572ff6f6SMatthew Dillon /*                                                 short            ctrl  */
70*572ff6f6SMatthew Dillon /*                valid                rateCode Preamble  dot11Rate Rate */
71*572ff6f6SMatthew Dillon /*   1 Mb */ {  AH_TRUE,  CCK,    1000,    0x0b,    0x00, (0x80| 2),   0 },
72*572ff6f6SMatthew Dillon /*   2 Mb */ {  AH_TRUE,  CCK,    2000,    0x0a,    0x04, (0x80| 4),   1 },
73*572ff6f6SMatthew Dillon /* 5.5 Mb */ {  AH_TRUE,  CCK,    5500,    0x09,    0x04, (0x80|11),   1 },
74*572ff6f6SMatthew Dillon /*  11 Mb */ {  AH_TRUE,  CCK,   11000,    0x08,    0x04, (0x80|22),   1 }
75*572ff6f6SMatthew Dillon 	},
76*572ff6f6SMatthew Dillon };
77*572ff6f6SMatthew Dillon 
78*572ff6f6SMatthew Dillon #undef	OFDM
79*572ff6f6SMatthew Dillon #undef	CCK
80*572ff6f6SMatthew Dillon #undef	TURBO
81*572ff6f6SMatthew Dillon 
82*572ff6f6SMatthew Dillon 
83*572ff6f6SMatthew Dillon const HAL_RATE_TABLE *
ar5211GetRateTable(struct ath_hal * ah,u_int mode)84*572ff6f6SMatthew Dillon ar5211GetRateTable(struct ath_hal *ah, u_int mode)
85*572ff6f6SMatthew Dillon {
86*572ff6f6SMatthew Dillon 	HAL_RATE_TABLE *rt;
87*572ff6f6SMatthew Dillon 	switch (mode) {
88*572ff6f6SMatthew Dillon 	case HAL_MODE_11A:
89*572ff6f6SMatthew Dillon 		rt = &ar5211_11a_table;
90*572ff6f6SMatthew Dillon 		break;
91*572ff6f6SMatthew Dillon 	case HAL_MODE_11B:
92*572ff6f6SMatthew Dillon 		rt = &ar5211_11b_table;
93*572ff6f6SMatthew Dillon 		break;
94*572ff6f6SMatthew Dillon 	case HAL_MODE_TURBO:
95*572ff6f6SMatthew Dillon 		rt =  &ar5211_turbo_table;
96*572ff6f6SMatthew Dillon 		break;
97*572ff6f6SMatthew Dillon 	default:
98*572ff6f6SMatthew Dillon 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
99*572ff6f6SMatthew Dillon 		    __func__, mode);
100*572ff6f6SMatthew Dillon 		return AH_NULL;
101*572ff6f6SMatthew Dillon 	}
102*572ff6f6SMatthew Dillon 	ath_hal_setupratetable(ah, rt);
103*572ff6f6SMatthew Dillon 	return rt;
104*572ff6f6SMatthew Dillon }
105