PERFORCE change 133188 for review
Sepherosa Ziehau
sephe at FreeBSD.org
Sun Jan 13 05:07:22 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133188
Change 133188 by sephe at sephe_zealot:sam_wifi on 2008/01/13 13:07:16
- Add ieee80211_phy into wlan module
- During wlan module loading, initialize various rate tables
- During ieee80211_ifattach() set channel's rate table
Affected files ...
.. //depot/projects/wifi/sys/modules/wlan/Makefile#10 edit
.. //depot/projects/wifi/sys/net80211/_ieee80211.h#27 edit
.. //depot/projects/wifi/sys/net80211/ieee80211.c#59 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#32 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_phy.c#2 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_phy.h#1 add
Differences ...
==== //depot/projects/wifi/sys/modules/wlan/Makefile#10 (text+ko) ====
@@ -7,7 +7,7 @@
ieee80211_freebsd.c ieee80211_input.c ieee80211_ioctl.c \
ieee80211_node.c ieee80211_output.c ieee80211_power.c \
ieee80211_proto.c ieee80211_scan.c ieee80211_regdomain.c \
- ieee80211_ht.c
+ ieee80211_ht.c ieee80211_phy.c
SRCS+= bus_if.h device_if.h opt_compat.h opt_inet.h opt_ipx.h
.if !defined(KERNBUILDDIR)
==== //depot/projects/wifi/sys/net80211/_ieee80211.h#27 (text+ko) ====
@@ -102,6 +102,7 @@
/*
* Channels are specified by frequency and attributes.
*/
+struct ieee80211_rate_table;
struct ieee80211_channel {
uint32_t ic_flags; /* see below */
uint16_t ic_freq; /* setting in Mhz */
@@ -111,6 +112,7 @@
int8_t ic_minpower; /* minimum tx power in .5 dBm */
uint8_t ic_state; /* dynamic state */
uint8_t ic_extieee; /* HT40 extension channel number */
+ const struct ieee80211_rate_table *ic_rt; /* rate table */
};
#define IEEE80211_CHAN_MAX 255
==== //depot/projects/wifi/sys/net80211/ieee80211.c#59 (text+ko) ====
@@ -42,6 +42,7 @@
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_phy.h>
#include <net/bpf.h>
@@ -181,6 +182,9 @@
setbit(ic->ic_modecaps, IEEE80211_MODE_11NA);
if (IEEE80211_IS_CHAN_HTG(c))
setbit(ic->ic_modecaps, IEEE80211_MODE_11NG);
+
+ c->ic_rt = ieee80211_get_ratetable(c);
+ KASSERT(c->ic_rt != NULL, ("no channel rate table\n"));
}
/* initialize candidate channels to all available */
memcpy(ic->ic_chan_active, ic->ic_chan_avail,
==== //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#32 (text+ko) ====
@@ -46,6 +46,7 @@
#include <net/route.h>
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_phy.h>
SYSCTL_NODE(_net, OID_AUTO, wlan, CTLFLAG_RD, 0, "IEEE 80211 parameters");
@@ -413,6 +414,7 @@
case MOD_LOAD:
if (bootverbose)
printf("wlan: <802.11 Link Layer>\n");
+ ieee80211_phy_init();
return 0;
case MOD_UNLOAD:
return 0;
==== //depot/projects/wifi/sys/net80211/ieee80211_phy.c#2 (text+ko) ====
@@ -42,7 +42,9 @@
#include <net/if_media.h>
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_phy.h>
+#ifdef notyet
/*
* Contention window (slots).
*/
@@ -75,7 +77,7 @@
uint16_t i_crc;
} __packed;
-uint8_t ieee80211_plcp2rate(uint8_t, int);
+#endif /* notyet */
struct ieee80211_rate_table {
int rateCount; /* NB: for proper padding */
@@ -94,14 +96,15 @@
} info[32];
};
-const struct ieee80211_rate_table *ieee80211_getratetable(
- struct ieee80211_channel *);
+#ifdef notyet
+uint8_t ieee80211_plcp2rate(uint8_t, int);
enum ieee80211_phytype ieee80211_rate2phytype(
const struct ieee80211_rate_table *, uint8_t rate);
uint8_t ieee80211_ack_rate(const struct ieee80211_rate_table *,
uint8_t rate);
uint16_t ieee80211_compute_txtime(const struct ieee80211_rate_table *,
uint32_t frameLen, uint16_t rate, int flags);
+#endif /* notyet */
/* shorthands to compact tables for readability */
#define OFDM IEEE80211_T_OFDM
@@ -168,8 +171,8 @@
{
/* short ctrl */
/* Preamble dot11Rate Rate */
-/* 6 Mb */ { OFDM, 3000, 0x00, (0x80|6), 0 },
-/* 9 Mb */ { OFDM, 4500, 0x00, 9, 0 },
+/* 6 Mb */ { OFDM, 3000, 0x00, (0x80| 6), 0 },
+/* 9 Mb */ { OFDM, 4500, 0x00, 9, 0 },
/* 12 Mb */ { OFDM, 6000, 0x00, (0x80|12), 2 },
/* 18 Mb */ { OFDM, 9000, 0x00, 18, 2 },
/* 24 Mb */ { OFDM, 12000, 0x00, (0x80|24), 4 },
@@ -185,9 +188,9 @@
{
/* short ctrl */
/* Preamble dot11Rate Rate */
-/* 6 Mb */ { OFDM, 1500, 0x00, (0x80|3), 0 },
-/* 9 Mb */ { OFDM, 2250, 0x00, 4, 0 },
-/* 12 Mb */ { OFDM, 3000, 0x00, (0x80|6), 2 },
+/* 6 Mb */ { OFDM, 1500, 0x00, (0x80| 3), 0 },
+/* 9 Mb */ { OFDM, 2250, 0x00, 4, 0 },
+/* 12 Mb */ { OFDM, 3000, 0x00, (0x80| 6), 2 },
/* 18 Mb */ { OFDM, 4500, 0x00, 9, 2 },
/* 24 Mb */ { OFDM, 6000, 0x00, (0x80|12), 4 },
/* 36 Mb */ { OFDM, 9000, 0x00, 18, 4 },
@@ -234,6 +237,34 @@
#undef TURBO
#undef XR
+static void ieee80211_setup_ratetable(struct ieee80211_rate_table *);
+
+/* Setup all rate tables */
+void
+ieee80211_phy_init(void)
+{
+ static struct ieee80211_rate_table * const ratetables[] = {
+ &ieee80211_half_table,
+ &ieee80211_quarter_table,
+ &ieee80211_11a_table,
+ &ieee80211_11g_table,
+ &ieee80211_turbog_table,
+ &ieee80211_turboa_table,
+ &ieee80211_turboa_table,
+ &ieee80211_11a_table,
+ &ieee80211_11g_table,
+ &ieee80211_11b_table
+ };
+ int i;
+
+#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
+
+ for (i = 0; i < N(ratetables); ++i)
+ ieee80211_setup_ratetable(ratetables[i]);
+
+#undef N
+}
+
/*
* Setup a rate table's reverse lookup table and fill in
* ack durations. The reverse lookup tables are assumed
@@ -244,7 +275,7 @@
* XXX not reentrant, but shouldn't matter
*/
static void
-ieee80211_setupratetable(struct ieee80211_rate_table *rt)
+ieee80211_setup_ratetable(struct ieee80211_rate_table *rt)
{
#define N(a) (sizeof(a)/sizeof(a[0]))
#define WLAN_CTRL_FRAME_SIZE (2+2+6+4) /* ACK+FCS */
@@ -254,13 +285,11 @@
rt->rateCodeToIndex[i] = (uint8_t) -1;
for (i = 0; i < rt->rateCount; i++) {
uint8_t code = rt->info[i].dot11Rate;
+#ifdef notyet
uint8_t cix = rt->info[i].controlRate;
+#endif
- KASSERT(code < N(rt->rateCodeToIndex), ("code %d", code));
rt->rateCodeToIndex[code] = i;
- KASSERT((code | rt->info[i].shortPreamble) <
- N(rt->rateCodeToIndex),
- ("code %d preamble %d", code, rt->info[i].shortPreamble));
rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i;
if (code & IEEE80211_RATE_BASIC) {
/*
@@ -270,6 +299,8 @@
rt->rateCodeToIndex[code] = i;
rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i;
}
+
+#ifdef notyet
/*
* XXX for 11g the control rate to use for 5.5 and 11 Mb/s
* depends on whether they are marked as basic rates;
@@ -280,13 +311,14 @@
WLAN_CTRL_FRAME_SIZE, cix, 0);
rt->info[i].spAckDuration = ieee80211_compute_txtime(rt,
WLAN_CTRL_FRAME_SIZE, cix, 1);
+#endif /* notyet */
}
#undef WLAN_CTRL_FRAME_SIZE
#undef N
}
const struct ieee80211_rate_table *
-ieee80211_getratetable(struct ieee80211_channel *c)
+ieee80211_get_ratetable(struct ieee80211_channel *c)
{
struct ieee80211_rate_table *rt;
@@ -313,15 +345,14 @@
rt = &ieee80211_11b_table;
else {
/* NB: should not get here */
- printf("%s: no rate table for channel; freq %u flags 0x%x\n",
- __func__, c->ic_freq, c->ic_flags);
- return NULL;
+ panic("%s: no rate table for channel; freq %u flags 0x%x\n",
+ __func__, c->ic_freq, c->ic_flags);
}
- if (rt != NULL && rt->rateCodeToIndex[0] == 0) /* not setup */
- ieee80211_setupratetable(rt);
return rt;
}
+#ifdef notyet
+
/*
* Covert PLCP signal/rate field to net80211 rate (.5Mbits/s)
*/
@@ -484,3 +515,5 @@
}
return txTime;
}
+
+#endif /* notyet */
More information about the p4-projects
mailing list