Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/net80211/wlantxtime/wlantxtime.c
Show All 25 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
/* | /* | ||||
* IEEE 802.11 PHY-related support. | * IEEE 802.11 PHY-related support. | ||||
*/ | */ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/types.h> | |||||
#include <net/if_llc.h> | #include <net/if_llc.h> | ||||
#include <net80211/_ieee80211.h> | #include <net80211/_ieee80211.h> | ||||
#include <net80211/ieee80211.h> | #include <net80211/ieee80211.h> | ||||
#define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ | #define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
* We use this as a key that indicates whether or not | * We use this as a key that indicates whether or not | ||||
* we've previously setup the reverse lookup table. | * we've previously setup the reverse lookup table. | ||||
* | * | ||||
* XXX not reentrant, but shouldn't matter | * XXX not reentrant, but shouldn't matter | ||||
*/ | */ | ||||
static void | static void | ||||
ieee80211_setup_ratetable(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 \ | #define WLAN_CTRL_FRAME_SIZE \ | ||||
(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) | (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) | ||||
int i; | int i; | ||||
for (i = 0; i < N(rt->rateCodeToIndex); i++) | for (i = 0; i < nitems(rt->rateCodeToIndex); i++) | ||||
rt->rateCodeToIndex[i] = (uint8_t) -1; | rt->rateCodeToIndex[i] = (uint8_t) -1; | ||||
for (i = 0; i < rt->rateCount; i++) { | for (i = 0; i < rt->rateCount; i++) { | ||||
uint8_t code = rt->info[i].dot11Rate; | uint8_t code = rt->info[i].dot11Rate; | ||||
uint8_t cix = rt->info[i].ctlRateIndex; | uint8_t cix = rt->info[i].ctlRateIndex; | ||||
uint8_t ctl_rate = rt->info[cix].dot11Rate; | uint8_t ctl_rate = rt->info[cix].dot11Rate; | ||||
rt->rateCodeToIndex[code] = i; | rt->rateCodeToIndex[code] = i; | ||||
if (code & IEEE80211_RATE_BASIC) { | if (code & IEEE80211_RATE_BASIC) { | ||||
Show All 16 Lines | for (i = 0; i < rt->rateCount; i++) { | ||||
*/ | */ | ||||
rt->info[i].lpAckDuration = ieee80211_compute_duration(rt, | rt->info[i].lpAckDuration = ieee80211_compute_duration(rt, | ||||
WLAN_CTRL_FRAME_SIZE, ctl_rate, 0); | WLAN_CTRL_FRAME_SIZE, ctl_rate, 0); | ||||
rt->info[i].spAckDuration = ieee80211_compute_duration(rt, | rt->info[i].spAckDuration = ieee80211_compute_duration(rt, | ||||
WLAN_CTRL_FRAME_SIZE, ctl_rate, IEEE80211_F_SHPREAMBLE); | WLAN_CTRL_FRAME_SIZE, ctl_rate, IEEE80211_F_SHPREAMBLE); | ||||
} | } | ||||
#undef WLAN_CTRL_FRAME_SIZE | #undef WLAN_CTRL_FRAME_SIZE | ||||
#undef N | |||||
} | } | ||||
/* Setup all rate tables */ | /* Setup all rate tables */ | ||||
static void | static void | ||||
ieee80211_phy_init(void) | ieee80211_phy_init(void) | ||||
{ | { | ||||
#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) | |||||
static struct ieee80211_rate_table * const ratetables[] = { | static struct ieee80211_rate_table * const ratetables[] = { | ||||
&ieee80211_half_table, | &ieee80211_half_table, | ||||
&ieee80211_quarter_table, | &ieee80211_quarter_table, | ||||
&ieee80211_11a_table, | &ieee80211_11a_table, | ||||
&ieee80211_11g_table, | &ieee80211_11g_table, | ||||
&ieee80211_turbog_table, | &ieee80211_turbog_table, | ||||
&ieee80211_turboa_table, | &ieee80211_turboa_table, | ||||
&ieee80211_turboa_table, | &ieee80211_turboa_table, | ||||
&ieee80211_11a_table, | &ieee80211_11a_table, | ||||
&ieee80211_11g_table, | &ieee80211_11g_table, | ||||
&ieee80211_11b_table | &ieee80211_11b_table | ||||
}; | }; | ||||
int i; | unsigned int i; | ||||
for (i = 0; i < N(ratetables); ++i) | for (i = 0; i < nitems(ratetables); ++i) | ||||
ieee80211_setup_ratetable(ratetables[i]); | ieee80211_setup_ratetable(ratetables[i]); | ||||
#undef N | |||||
} | } | ||||
#define CCK_SIFS_TIME 10 | #define CCK_SIFS_TIME 10 | ||||
#define CCK_PREAMBLE_BITS 144 | #define CCK_PREAMBLE_BITS 144 | ||||
#define CCK_PLCP_BITS 48 | #define CCK_PLCP_BITS 48 | ||||
#define OFDM_SIFS_TIME 16 | #define OFDM_SIFS_TIME 16 | ||||
#define OFDM_PREAMBLE_TIME 20 | #define OFDM_PREAMBLE_TIME 20 | ||||
#define OFDM_PLCP_BITS 22 | #define OFDM_PLCP_BITS 22 | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |