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