1185377Ssam/*
2185377Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3185377Ssam * Copyright (c) 2002-2004 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 *
17191022Ssam * $FreeBSD$
18185377Ssam */
19185377Ssam#include "opt_ah.h"
20185377Ssam
21185377Ssam#include "ah.h"
22185377Ssam#include "ah_internal.h"
23185377Ssam
24185377Ssam#include "ar5210/ar5210.h"
25185377Ssam
26185377Ssam/* shorthands to compact tables for readability */
27185377Ssam#define	OFDM	IEEE80211_T_OFDM
28185377Ssam#define	TURBO	IEEE80211_T_TURBO
29185377Ssam
30185377SsamHAL_RATE_TABLE ar5210_11a_table = {
31185377Ssam	8,  /* number of rates */
32185377Ssam	{ 0 },
33185377Ssam	{
34185377Ssam/*                                                  short            ctrl  */
35185377Ssam/*                valid                 rateCode Preamble  dot11Rate Rate */
36185377Ssam/*   6 Mb */ {  AH_TRUE, OFDM,    6000,     0x0b,    0x00, (0x80|12),   0 },
37185377Ssam/*   9 Mb */ {  AH_TRUE, OFDM,    9000,     0x0f,    0x00,        18,   0 },
38185377Ssam/*  12 Mb */ {  AH_TRUE, OFDM,   12000,     0x0a,    0x00, (0x80|24),   2 },
39185377Ssam/*  18 Mb */ {  AH_TRUE, OFDM,   18000,     0x0e,    0x00,        36,   2 },
40185377Ssam/*  24 Mb */ {  AH_TRUE, OFDM,   24000,     0x09,    0x00, (0x80|48),   4 },
41185377Ssam/*  36 Mb */ {  AH_TRUE, OFDM,   36000,     0x0d,    0x00,        72,   4 },
42185377Ssam/*  48 Mb */ {  AH_TRUE, OFDM,   48000,     0x08,    0x00,        96,   4 },
43185377Ssam/*  54 Mb */ {  AH_TRUE, OFDM,   54000,     0x0c,    0x00,       108,   4 }
44185377Ssam	},
45185377Ssam};
46185377Ssam
47185377SsamHAL_RATE_TABLE ar5210_turbo_table = {
48185377Ssam	8,  /* number of rates */
49185377Ssam	{ 0 },
50185377Ssam	{
51185377Ssam/*                                                 short            ctrl  */
52185377Ssam/*                valid                rateCode Preamble  dot11Rate Rate */
53191022Ssam/*   6 Mb */ {  AH_TRUE, TURBO,  12000,    0x0b,    0x00, (0x80|12),   0 },
54191022Ssam/*   9 Mb */ {  AH_TRUE, TURBO,  18000,    0x0f,    0x00,        18,   0 },
55191022Ssam/*  12 Mb */ {  AH_TRUE, TURBO,  24000,    0x0a,    0x00, (0x80|24),   2 },
56191022Ssam/*  18 Mb */ {  AH_TRUE, TURBO,  36000,    0x0e,    0x00,        36,   2 },
57191022Ssam/*  24 Mb */ {  AH_TRUE, TURBO,  48000,    0x09,    0x00, (0x80|48),   4 },
58191022Ssam/*  36 Mb */ {  AH_TRUE, TURBO,  72000,    0x0d,    0x00,        72,   4 },
59191022Ssam/*  48 Mb */ {  AH_TRUE, TURBO,  96000,    0x08,    0x00,        96,   4 },
60191022Ssam/*  54 Mb */ {  AH_TRUE, TURBO, 108000,    0x0c,    0x00,       108,   4 }
61185377Ssam	},
62185377Ssam};
63185377Ssam
64185377Ssam#undef	OFDM
65185377Ssam#undef	TURBO
66185377Ssam
67185377Ssamconst HAL_RATE_TABLE *
68185377Ssamar5210GetRateTable(struct ath_hal *ah, u_int mode)
69185377Ssam{
70185377Ssam	HAL_RATE_TABLE *rt;
71185377Ssam	switch (mode) {
72185377Ssam	case HAL_MODE_11A:
73185377Ssam		rt = &ar5210_11a_table;
74185377Ssam		break;
75185377Ssam	case HAL_MODE_TURBO:
76185377Ssam		rt =  &ar5210_turbo_table;
77185377Ssam		break;
78185377Ssam	default:
79185377Ssam		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid mode 0x%x\n",
80185377Ssam		    __func__, mode);
81185377Ssam		return AH_NULL;
82185377Ssam	}
83185377Ssam	ath_hal_setupratetable(ah, rt);
84185377Ssam	return rt;
85185377Ssam}
86