xref: /freebsd/sys/dev/ath/ath_hal/ar5211/ar5211_phy.c (revision 22d7dd834bc5cd189810e414701e3ad1e98102e4)
1 /*-
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
5  * Copyright (c) 2002-2006 Atheros Communications, Inc.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 #include "opt_ah.h"
20 
21 #include "ah.h"
22 #include "ah_internal.h"
23 
24 #include "ar5211/ar5211.h"
25 
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
30 
31 HAL_RATE_TABLE ar5211_11a_table = {
32 	8,  /* number of rates */
33 	{ 0 },
34 	{
35 /*                                                  short            ctrl  */
36 /*                valid                 rateCode Preamble  dot11Rate Rate */
37 /*   6 Mb */ {  AH_TRUE, OFDM,    6000,     0x0b,    0x00, (0x80|12),   0 },
38 /*   9 Mb */ {  AH_TRUE, OFDM,    9000,     0x0f,    0x00,        18,   0 },
39 /*  12 Mb */ {  AH_TRUE, OFDM,   12000,     0x0a,    0x00, (0x80|24),   2 },
40 /*  18 Mb */ {  AH_TRUE, OFDM,   18000,     0x0e,    0x00,        36,   2 },
41 /*  24 Mb */ {  AH_TRUE, OFDM,   24000,     0x09,    0x00, (0x80|48),   4 },
42 /*  36 Mb */ {  AH_TRUE, OFDM,   36000,     0x0d,    0x00,        72,   4 },
43 /*  48 Mb */ {  AH_TRUE, OFDM,   48000,     0x08,    0x00,        96,   4 },
44 /*  54 Mb */ {  AH_TRUE, OFDM,   54000,     0x0c,    0x00,       108,   4 }
45 	},
46 };
47 
48 HAL_RATE_TABLE ar5211_turbo_table = {
49 	8,  /* number of rates */
50 	{ 0 },
51 	{
52 /*                                                 short            ctrl  */
53 /*                valid                rateCode Preamble  dot11Rate Rate */
54 /*   6 Mb */ {  AH_TRUE, TURBO,  12000,    0x0b,    0x00, (0x80|12),   0 },
55 /*   9 Mb */ {  AH_TRUE, TURBO,  18000,    0x0f,    0x00,        18,   0 },
56 /*  12 Mb */ {  AH_TRUE, TURBO,  24000,    0x0a,    0x00, (0x80|24),   2 },
57 /*  18 Mb */ {  AH_TRUE, TURBO,  36000,    0x0e,    0x00,        36,   2 },
58 /*  24 Mb */ {  AH_TRUE, TURBO,  48000,    0x09,    0x00, (0x80|48),   4 },
59 /*  36 Mb */ {  AH_TRUE, TURBO,  72000,    0x0d,    0x00,        72,   4 },
60 /*  48 Mb */ {  AH_TRUE, TURBO,  96000,    0x08,    0x00,        96,   4 },
61 /*  54 Mb */ {  AH_TRUE, TURBO, 108000,    0x0c,    0x00,       108,   4 }
62 	},
63 };
64 
65 HAL_RATE_TABLE ar5211_11b_table = {
66 	4,  /* number of rates */
67 	{ 0 },
68 	{
69 /*                                                 short            ctrl  */
70 /*                valid                rateCode Preamble  dot11Rate Rate */
71 /*   1 Mb */ {  AH_TRUE,  CCK,    1000,    0x0b,    0x00, (0x80| 2),   0 },
72 /*   2 Mb */ {  AH_TRUE,  CCK,    2000,    0x0a,    0x04, (0x80| 4),   1 },
73 /* 5.5 Mb */ {  AH_TRUE,  CCK,    5500,    0x09,    0x04, (0x80|11),   1 },
74 /*  11 Mb */ {  AH_TRUE,  CCK,   11000,    0x08,    0x04, (0x80|22),   1 }
75 	},
76 };
77 
78 #undef	OFDM
79 #undef	CCK
80 #undef	TURBO
81 
82 const HAL_RATE_TABLE *
83 ar5211GetRateTable(struct ath_hal *ah, u_int mode)
84 {
85 	HAL_RATE_TABLE *rt;
86 	switch (mode) {
87 	case HAL_MODE_11A:
88 		rt = &ar5211_11a_table;
89 		break;
90 	case HAL_MODE_11B:
91 		rt = &ar5211_11b_table;
92 		break;
93 	case HAL_MODE_TURBO:
94 		rt =  &ar5211_turbo_table;
95 		break;
96 	default:
97 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
98 		    __func__, mode);
99 		return AH_NULL;
100 	}
101 	ath_hal_setupratetable(ah, rt);
102 	return rt;
103 }
104