ar5211_phy.c revision 185377
1185377Ssam/*
2185377Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3185377Ssam * Copyright (c) 2002-2006 Atheros Communications, Inc.
4185377Ssam *
5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any
6185377Ssam * purpose with or without fee is hereby granted, provided that the above
7185377Ssam * copyright notice and this permission notice appear in all copies.
8185377Ssam *
9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16185377Ssam *
17185377Ssam * $Id: ar5211_phy.c,v 1.3 2008/11/10 01:19:37 sam Exp $
18185377Ssam */
19185377Ssam#include "opt_ah.h"
20185377Ssam
21185377Ssam#ifdef AH_SUPPORT_AR5211
22185377Ssam
23185377Ssam#include "ah.h"
24185377Ssam#include "ah_internal.h"
25185377Ssam
26185377Ssam#include "ar5211/ar5211.h"
27185377Ssam
28185377Ssam/* shorthands to compact tables for readability */
29185377Ssam#define	OFDM	IEEE80211_T_OFDM
30185377Ssam#define	CCK	IEEE80211_T_CCK
31185377Ssam#define	TURBO	IEEE80211_T_TURBO
32185377Ssam
33185377SsamHAL_RATE_TABLE ar5211_11a_table = {
34185377Ssam	8,  /* number of rates */
35185377Ssam	{ 0 },
36185377Ssam	{
37185377Ssam/*                                                  short            ctrl  */
38185377Ssam/*                valid                 rateCode Preamble  dot11Rate Rate */
39185377Ssam/*   6 Mb */ {  AH_TRUE, OFDM,    6000,     0x0b,    0x00, (0x80|12),   0 },
40185377Ssam/*   9 Mb */ {  AH_TRUE, OFDM,    9000,     0x0f,    0x00,        18,   0 },
41185377Ssam/*  12 Mb */ {  AH_TRUE, OFDM,   12000,     0x0a,    0x00, (0x80|24),   2 },
42185377Ssam/*  18 Mb */ {  AH_TRUE, OFDM,   18000,     0x0e,    0x00,        36,   2 },
43185377Ssam/*  24 Mb */ {  AH_TRUE, OFDM,   24000,     0x09,    0x00, (0x80|48),   4 },
44185377Ssam/*  36 Mb */ {  AH_TRUE, OFDM,   36000,     0x0d,    0x00,        72,   4 },
45185377Ssam/*  48 Mb */ {  AH_TRUE, OFDM,   48000,     0x08,    0x00,        96,   4 },
46185377Ssam/*  54 Mb */ {  AH_TRUE, OFDM,   54000,     0x0c,    0x00,       108,   4 }
47185377Ssam	},
48185377Ssam};
49185377Ssam
50185377SsamHAL_RATE_TABLE ar5211_turbo_table = {
51185377Ssam	8,  /* number of rates */
52185377Ssam	{ 0 },
53185377Ssam	{
54185377Ssam/*                                                 short            ctrl  */
55185377Ssam/*                valid                rateCode Preamble  dot11Rate Rate */
56185377Ssam/*   6 Mb */ {  AH_TRUE, TURBO,   6000,    0x0b,    0x00, (0x80|12),   0 },
57185377Ssam/*   9 Mb */ {  AH_TRUE, TURBO,   9000,    0x0f,    0x00,        18,   0 },
58185377Ssam/*  12 Mb */ {  AH_TRUE, TURBO,  12000,    0x0a,    0x00, (0x80|24),   2 },
59185377Ssam/*  18 Mb */ {  AH_TRUE, TURBO,  18000,    0x0e,    0x00,        36,   2 },
60185377Ssam/*  24 Mb */ {  AH_TRUE, TURBO,  24000,    0x09,    0x00, (0x80|48),   4 },
61185377Ssam/*  36 Mb */ {  AH_TRUE, TURBO,  36000,    0x0d,    0x00,        72,   4 },
62185377Ssam/*  48 Mb */ {  AH_TRUE, TURBO,  48000,    0x08,    0x00,        96,   4 },
63185377Ssam/*  54 Mb */ {  AH_TRUE, TURBO,  54000,    0x0c,    0x00,       108,   4 }
64185377Ssam	},
65185377Ssam};
66185377Ssam
67185377SsamHAL_RATE_TABLE ar5211_11b_table = {
68185377Ssam	4,  /* number of rates */
69185377Ssam	{ 0 },
70185377Ssam	{
71185377Ssam/*                                                 short            ctrl  */
72185377Ssam/*                valid                rateCode Preamble  dot11Rate Rate */
73185377Ssam/*   1 Mb */ {  AH_TRUE,  CCK,    1000,    0x0b,    0x00, (0x80| 2),   0 },
74185377Ssam/*   2 Mb */ {  AH_TRUE,  CCK,    2000,    0x0a,    0x04, (0x80| 4),   1 },
75185377Ssam/* 5.5 Mb */ {  AH_TRUE,  CCK,    5500,    0x09,    0x04, (0x80|11),   1 },
76185377Ssam/*  11 Mb */ {  AH_TRUE,  CCK,   11000,    0x08,    0x04, (0x80|22),   1 }
77185377Ssam	},
78185377Ssam};
79185377Ssam
80185377Ssam#undef	OFDM
81185377Ssam#undef	CCK
82185377Ssam#undef	TURBO
83185377Ssam
84185377Ssam
85185377Ssamconst HAL_RATE_TABLE *
86185377Ssamar5211GetRateTable(struct ath_hal *ah, u_int mode)
87185377Ssam{
88185377Ssam	HAL_RATE_TABLE *rt;
89185377Ssam	switch (mode) {
90185377Ssam	case HAL_MODE_11A:
91185377Ssam		rt = &ar5211_11a_table;
92185377Ssam		break;
93185377Ssam	case HAL_MODE_11B:
94185377Ssam		rt = &ar5211_11b_table;
95185377Ssam		break;
96185377Ssam	case HAL_MODE_TURBO:
97185377Ssam		rt =  &ar5211_turbo_table;
98185377Ssam		break;
99185377Ssam	default:
100185377Ssam		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
101185377Ssam		    __func__, mode);
102185377Ssam		return AH_NULL;
103185377Ssam	}
104185377Ssam	ath_hal_setupratetable(ah, rt);
105185377Ssam	return rt;
106185377Ssam}
107185377Ssam#endif /* AH_SUPPORT_AR5211 */
108