PERFORCE change 134246 for review
Sam Leffler
sam at FreeBSD.org
Sun Jan 27 13:48:33 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134246
Change 134246 by sam at sam_ebb on 2008/01/27 21:48:08
Revamp according to my original code:
o expose rate table so we can inline routines
o use SYSINT to setup rate tables
o eliminate dependence on channel; change api's to ues
rate tables (drivers should cache this on channel change)
While here also move/expose dfly stuff (especially for bwi).
Affected files ...
.. //depot/projects/vap/sys/net80211/ieee80211_phy.c#2 edit
.. //depot/projects/vap/sys/net80211/ieee80211_phy.h#2 edit
Differences ...
==== //depot/projects/vap/sys/net80211/ieee80211_phy.c#2 (text+ko) ====
@@ -45,31 +45,6 @@
#include <net80211/ieee80211_phy.h>
#ifdef notyet
-/*
- * Contention window (slots).
- */
-#define IEEE80211_CW_MAX 1023 /* aCWmax */
-#define IEEE80211_CW_MIN_0 31 /* DS/CCK aCWmin, ERP aCWmin(0) */
-#define IEEE80211_CW_MIN_1 15 /* OFDM aCWmin, ERP aCWmin(1) */
-
-/*
- * SIFS (microseconds).
- */
-#define IEEE80211_DUR_SIFS 10 /* DS/CCK/ERP SIFS */
-#define IEEE80211_DUR_OFDM_SIFS 16 /* OFDM SIFS */
-
-/*
- * Slot time (microseconds).
- */
-#define IEEE80211_DUR_SLOT 20 /* DS/CCK slottime, ERP long slottime */
-#define IEEE80211_DUR_SHSLOT 9 /* ERP short slottime */
-#define IEEE80211_DUR_OFDM_SLOT 9 /* OFDM slottime */
-
-/*
- * DIFS (microseconds).
- */
-#define IEEE80211_DUR_DIFS(sifs, slot) ((sifs) + 2 * (slot))
-
struct ieee80211_ds_plcp_hdr {
uint8_t i_signal;
uint8_t i_service;
@@ -79,29 +54,6 @@
#endif /* notyet */
-struct ieee80211_rate_table {
- int rateCount; /* NB: for proper padding */
- uint8_t rateCodeToIndex[256]; /* back mapping */
- struct {
- uint8_t phy; /* CCK/OFDM/TURBO */
- uint32_t rateKbps; /* transfer rate in kbs */
- uint8_t shortPreamble; /* mask for enabling short
- * preamble in CCK rate code */
- uint8_t dot11Rate; /* value for supported rates
- * info element of MLME */
- uint8_t ctlRateIndex; /* index of next lower basic
- * rate; used for dur. calcs */
- uint16_t lpAckDuration; /* long preamble ACK dur. */
- uint16_t spAckDuration; /* short preamble ACK dur. */
- } info[32];
-};
-
-#ifdef notyet
-uint8_t ieee80211_plcp2rate(uint8_t, int);
-uint8_t ieee80211_ack_rate(const struct ieee80211_rate_table *,
- uint8_t rate);
-#endif /* notyet */
-
/* shorthands to compact tables for readability */
#define OFDM IEEE80211_T_OFDM
#define CCK IEEE80211_T_CCK
@@ -233,36 +185,6 @@
#undef TURBO
#undef XR
-static void ieee80211_setup_ratetable(struct ieee80211_rate_table *);
-static uint16_t ieee80211_compute_dur(const struct ieee80211_rate_table *,
- uint32_t, uint16_t, int);
-
-/* 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
@@ -307,9 +229,9 @@
* current rate, so control rate's reverse lookup entry
* has been installed and following call is safe.
*/
- rt->info[i].lpAckDuration = ieee80211_compute_dur(rt,
+ rt->info[i].lpAckDuration = ieee80211_compute_duration(rt,
WLAN_CTRL_FRAME_SIZE, ctl_rate, 0);
- rt->info[i].spAckDuration = ieee80211_compute_dur(rt,
+ rt->info[i].spAckDuration = ieee80211_compute_duration(rt,
WLAN_CTRL_FRAME_SIZE, ctl_rate, IEEE80211_F_SHPREAMBLE);
}
@@ -317,8 +239,34 @@
#undef N
}
-void
-ieee80211_set_ratetable(struct ieee80211_channel *c)
+/* Setup all rate tables */
+static void
+ieee80211_phy_init(void)
+{
+#define N(arr) (int)(sizeof(arr) / sizeof(arr[0]))
+ 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;
+
+ for (i = 0; i < N(ratetables); ++i)
+ ieee80211_setup_ratetable(ratetables[i]);
+
+#undef N
+}
+SYSINIT(wlan_phy, SI_SUB_DRIVERS, SI_ORDER_FIRST, ieee80211_phy_init, NULL);
+
+const struct ieee80211_rate_table *
+ieee80211_get_ratetable(struct ieee80211_channel *c)
{
const struct ieee80211_rate_table *rt;
@@ -348,13 +296,11 @@
panic("%s: no rate table for channel; freq %u flags 0x%x\n",
__func__, c->ic_freq, c->ic_flags);
}
- c->ic_rt = rt;
+ return rt;
}
-#ifdef notyet
-
/*
- * Covert PLCP signal/rate field to net80211 rate (.5Mbits/s)
+ * Covert PLCP signal/rate field to 802.11 rate (.5Mbits/s)
*/
uint8_t
ieee80211_plcp2rate(uint8_t plcp, int ofdm)
@@ -392,65 +338,14 @@
return 0;
}
-uint8_t
-ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate)
-{
- uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex;
- return rt->info[cix].dot11Rate;
-}
-
-#endif /* notyet */
-
-enum ieee80211_phytype
-ieee80211_rate2phytype(const struct ieee80211_channel *c, uint8_t rate)
-{
- const struct ieee80211_rate_table *rt = c->ic_rt;
- uint8_t rix = rt->rateCodeToIndex[rate];
-
- KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate));
- return rt->info[rix].phy;
-}
-
-/*
- * Calculate duration field for
- * o non-fragment data frames
- * o management frames
- * sent using rate, phy and short preamble setting.
- */
-uint16_t
-ieee80211_ack_duration(const struct ieee80211_channel *c,
- uint8_t rate, int flags)
-{
- const struct ieee80211_rate_table *rt = c->ic_rt;
- uint8_t rix = rt->rateCodeToIndex[rate];
-
- KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate));
- if (flags & IEEE80211_F_SHPREAMBLE) {
- KASSERT(rt->info[rix].spAckDuration != 0,
- ("shpreamble ack dur is not computed!\n"));
- return rt->info[rix].spAckDuration;
- } else {
- KASSERT(rt->info[rix].lpAckDuration != 0,
- ("lgpreamble ack dur is not computed!\n"));
- return rt->info[rix].lpAckDuration;
- }
-}
-
-uint16_t
-ieee80211_compute_duration(const struct ieee80211_channel *c,
- uint32_t frameLen, uint16_t rate, int flags)
-{
- return ieee80211_compute_dur(c->ic_rt, frameLen, rate, flags);
-}
-
/*
* Compute the time to transmit a frame of length frameLen bytes
* using the specified rate, phy, and short preamble setting.
* SIFS is included.
*/
-static uint16_t
-ieee80211_compute_dur(const struct ieee80211_rate_table *rt,
- uint32_t frameLen, uint16_t rate, int flags)
+uint16_t
+ieee80211_compute_duration(const struct ieee80211_rate_table *rt,
+ uint32_t frameLen, uint16_t rate, int isShortPreamble)
{
uint8_t rix = rt->rateCodeToIndex[rate];
uint32_t bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
@@ -467,8 +362,7 @@
#define CCK_PREAMBLE_BITS 144
#define CCK_PLCP_BITS 48
phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
- if ((flags & IEEE80211_F_SHPREAMBLE) &&
- rt->info[rix].shortPreamble)
+ if (isShortPreamble && rt->info[rix].shortPreamble)
phyTime >>= 1;
numBits = frameLen << 3;
txTime = CCK_SIFS_TIME + phyTime
==== //depot/projects/vap/sys/net80211/ieee80211_phy.h#2 (text+ko) ====
@@ -29,20 +29,109 @@
#define _NET80211_IEEE80211_PHY_H_
#ifdef _KERNEL
+/*
+ * IEEE 802.11 PHY-related definitions.
+ */
+
+/*
+ * Contention window (slots).
+ */
+#define IEEE80211_CW_MAX 1023 /* aCWmax */
+#define IEEE80211_CW_MIN_0 31 /* DS/CCK aCWmin, ERP aCWmin(0) */
+#define IEEE80211_CW_MIN_1 15 /* OFDM aCWmin, ERP aCWmin(1) */
+
+/*
+ * SIFS (microseconds).
+ */
+#define IEEE80211_DUR_SIFS 10 /* DS/CCK/ERP SIFS */
+#define IEEE80211_DUR_OFDM_SIFS 16 /* OFDM SIFS */
+
+/*
+ * Slot time (microseconds).
+ */
+#define IEEE80211_DUR_SLOT 20 /* DS/CCK slottime, ERP long slottime */
+#define IEEE80211_DUR_SHSLOT 9 /* ERP short slottime */
+#define IEEE80211_DUR_OFDM_SLOT 9 /* OFDM slottime */
+
+/*
+ * DIFS (microseconds).
+ */
+#define IEEE80211_DUR_DIFS(sifs, slot) ((sifs) + 2 * (slot))
struct ieee80211_channel;
-/* Initialization functions */
-void ieee80211_phy_init(void);
-void ieee80211_set_ratetable(struct ieee80211_channel *);
+struct ieee80211_rate_table {
+ int rateCount; /* NB: for proper padding */
+ uint8_t rateCodeToIndex[256]; /* back mapping */
+ struct {
+ uint8_t phy; /* CCK/OFDM/TURBO */
+ uint32_t rateKbps; /* transfer rate in kbs */
+ uint8_t shortPreamble; /* mask for enabling short
+ * preamble in CCK rate code */
+ uint8_t dot11Rate; /* value for supported rates
+ * info element of MLME */
+ uint8_t ctlRateIndex; /* index of next lower basic
+ * rate; used for dur. calcs */
+ uint16_t lpAckDuration; /* long preamble ACK dur. */
+ uint16_t spAckDuration; /* short preamble ACK dur. */
+ } info[32];
+};
+
+const struct ieee80211_rate_table *ieee80211_get_ratetable(
+ struct ieee80211_channel *);
+
+static __inline__ uint8_t
+ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate)
+{
+ uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex;
+ KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate));
+ return rt->info[cix].dot11Rate;
+}
+
+static __inline__ enum ieee80211_phytype
+ieee80211_rate2phytype(const struct ieee80211_rate_table *rt, uint8_t rate)
+{
+ uint8_t rix = rt->rateCodeToIndex[rate];
+ KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate));
+ return rt->info[rix].phy;
+}
+
+/*
+ * Calculate ACK field for
+ * o non-fragment data frames
+ * o management frames
+ * sent using rate, phy and short preamble setting.
+ */
+static __inline__ uint16_t
+ieee80211_ack_duration(const struct ieee80211_rate_table *rt,
+ uint8_t rate, int isShortPreamble)
+{
+ uint8_t rix = rt->rateCodeToIndex[rate];
-uint16_t ieee80211_ack_duration(const struct ieee80211_channel *,
- uint8_t, int);
-uint16_t ieee80211_compute_duration(const struct ieee80211_channel *,
- uint32_t, uint16_t, int);
-enum ieee80211_phytype ieee80211_rate2phytype(
- const struct ieee80211_channel *, uint8_t);
+ KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate));
+ if (isShortPreamble) {
+ KASSERT(rt->info[rix].spAckDuration != 0,
+ ("shpreamble ack dur is not computed!\n"));
+ return rt->info[rix].spAckDuration;
+ } else {
+ KASSERT(rt->info[rix].lpAckDuration != 0,
+ ("lgpreamble ack dur is not computed!\n"));
+ return rt->info[rix].lpAckDuration;
+ }
+}
+/*
+ * Compute the time to transmit a frame of length frameLen bytes
+ * using the specified 802.11 rate code, phy, and short preamble
+ * setting.
+ *
+ * NB: SIFS is included.
+ */
+uint16_t ieee80211_compute_duration(const struct ieee80211_rate_table *,
+ uint32_t frameLen, uint16_t rate, int isShortPreamble);
+/*
+ * Covert PLCP signal/rate field to 802.11 rate code (.5Mbits/s)
+ */
+uint8_t ieee80211_plcp2rate(uint8_t, int);
#endif /* _KERNEL */
-
#endif /* !_NET80211_IEEE80211_PHY_H_ */
More information about the p4-projects
mailing list