xref: /freebsd/sys/dev/ath/ath_hal/ar5210/ar5210_phy.c (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1 /*-
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
5  * Copyright (c) 2002-2004 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 "ar5210/ar5210.h"
25 
26 /* shorthands to compact tables for readability */
27 #define	OFDM	IEEE80211_T_OFDM
28 #define	TURBO	IEEE80211_T_TURBO
29 
30 HAL_RATE_TABLE ar5210_11a_table = {
31 	8,  /* number of rates */
32 	{ 0 },
33 	{
34 /*                                                  short            ctrl  */
35 /*                valid                 rateCode Preamble  dot11Rate Rate */
36 /*   6 Mb */ {  AH_TRUE, OFDM,    6000,     0x0b,    0x00, (0x80|12),   0 },
37 /*   9 Mb */ {  AH_TRUE, OFDM,    9000,     0x0f,    0x00,        18,   0 },
38 /*  12 Mb */ {  AH_TRUE, OFDM,   12000,     0x0a,    0x00, (0x80|24),   2 },
39 /*  18 Mb */ {  AH_TRUE, OFDM,   18000,     0x0e,    0x00,        36,   2 },
40 /*  24 Mb */ {  AH_TRUE, OFDM,   24000,     0x09,    0x00, (0x80|48),   4 },
41 /*  36 Mb */ {  AH_TRUE, OFDM,   36000,     0x0d,    0x00,        72,   4 },
42 /*  48 Mb */ {  AH_TRUE, OFDM,   48000,     0x08,    0x00,        96,   4 },
43 /*  54 Mb */ {  AH_TRUE, OFDM,   54000,     0x0c,    0x00,       108,   4 }
44 	},
45 };
46 
47 HAL_RATE_TABLE ar5210_turbo_table = {
48 	8,  /* number of rates */
49 	{ 0 },
50 	{
51 /*                                                 short            ctrl  */
52 /*                valid                rateCode Preamble  dot11Rate Rate */
53 /*   6 Mb */ {  AH_TRUE, TURBO,  12000,    0x0b,    0x00, (0x80|12),   0 },
54 /*   9 Mb */ {  AH_TRUE, TURBO,  18000,    0x0f,    0x00,        18,   0 },
55 /*  12 Mb */ {  AH_TRUE, TURBO,  24000,    0x0a,    0x00, (0x80|24),   2 },
56 /*  18 Mb */ {  AH_TRUE, TURBO,  36000,    0x0e,    0x00,        36,   2 },
57 /*  24 Mb */ {  AH_TRUE, TURBO,  48000,    0x09,    0x00, (0x80|48),   4 },
58 /*  36 Mb */ {  AH_TRUE, TURBO,  72000,    0x0d,    0x00,        72,   4 },
59 /*  48 Mb */ {  AH_TRUE, TURBO,  96000,    0x08,    0x00,        96,   4 },
60 /*  54 Mb */ {  AH_TRUE, TURBO, 108000,    0x0c,    0x00,       108,   4 }
61 	},
62 };
63 
64 #undef	OFDM
65 #undef	TURBO
66 
67 const HAL_RATE_TABLE *
68 ar5210GetRateTable(struct ath_hal *ah, u_int mode)
69 {
70 	HAL_RATE_TABLE *rt;
71 	switch (mode) {
72 	case HAL_MODE_11A:
73 		rt = &ar5210_11a_table;
74 		break;
75 	case HAL_MODE_TURBO:
76 		rt =  &ar5210_turbo_table;
77 		break;
78 	default:
79 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
80 		    __func__, mode);
81 		return AH_NULL;
82 	}
83 	ath_hal_setupratetable(ah, rt);
84 	return rt;
85 }
86