ieee80211_phy.h (193072) | ieee80211_phy.h (252727) |
---|---|
1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * | 1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/sys/net80211/ieee80211_phy.h 193072 2009-05-29 23:39:16Z sam $ | 25 * $FreeBSD: head/sys/net80211/ieee80211_phy.h 252727 2013-07-04 21:16:49Z adrian $ |
26 */ 27 28#ifndef _NET80211_IEEE80211_PHY_H_ 29#define _NET80211_IEEE80211_PHY_H_ 30 31#ifdef _KERNEL 32/* 33 * IEEE 802.11 PHY-related definitions. --- 21 unchanged lines hidden (view full) --- 55 56/* 57 * DIFS (microseconds). 58 */ 59#define IEEE80211_DUR_DIFS(sifs, slot) ((sifs) + 2 * (slot)) 60 61struct ieee80211_channel; 62 | 26 */ 27 28#ifndef _NET80211_IEEE80211_PHY_H_ 29#define _NET80211_IEEE80211_PHY_H_ 30 31#ifdef _KERNEL 32/* 33 * IEEE 802.11 PHY-related definitions. --- 21 unchanged lines hidden (view full) --- 55 56/* 57 * DIFS (microseconds). 58 */ 59#define IEEE80211_DUR_DIFS(sifs, slot) ((sifs) + 2 * (slot)) 60 61struct ieee80211_channel; 62 |
63#define IEEE80211_RATE_TABLE_SIZE 128 64 |
|
63struct ieee80211_rate_table { 64 int rateCount; /* NB: for proper padding */ 65 uint8_t rateCodeToIndex[256]; /* back mapping */ 66 struct { 67 uint8_t phy; /* CCK/OFDM/TURBO */ 68 uint32_t rateKbps; /* transfer rate in kbs */ 69 uint8_t shortPreamble; /* mask for enabling short 70 * preamble in CCK rate code */ 71 uint8_t dot11Rate; /* value for supported rates 72 * info element of MLME */ 73 uint8_t ctlRateIndex; /* index of next lower basic 74 * rate; used for dur. calcs */ 75 uint16_t lpAckDuration; /* long preamble ACK dur. */ 76 uint16_t spAckDuration; /* short preamble ACK dur. */ | 65struct ieee80211_rate_table { 66 int rateCount; /* NB: for proper padding */ 67 uint8_t rateCodeToIndex[256]; /* back mapping */ 68 struct { 69 uint8_t phy; /* CCK/OFDM/TURBO */ 70 uint32_t rateKbps; /* transfer rate in kbs */ 71 uint8_t shortPreamble; /* mask for enabling short 72 * preamble in CCK rate code */ 73 uint8_t dot11Rate; /* value for supported rates 74 * info element of MLME */ 75 uint8_t ctlRateIndex; /* index of next lower basic 76 * rate; used for dur. calcs */ 77 uint16_t lpAckDuration; /* long preamble ACK dur. */ 78 uint16_t spAckDuration; /* short preamble ACK dur. */ |
77 } info[32]; | 79 } info[IEEE80211_RATE_TABLE_SIZE]; |
78}; 79 80const struct ieee80211_rate_table *ieee80211_get_ratetable( 81 struct ieee80211_channel *); 82 83static __inline__ uint8_t 84ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate) 85{ | 80}; 81 82const struct ieee80211_rate_table *ieee80211_get_ratetable( 83 struct ieee80211_channel *); 84 85static __inline__ uint8_t 86ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate) 87{ |
86 uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex; | 88 /* 89 * XXX Assert this is for a legacy rate; not for an MCS rate. 90 * If the caller wishes to use it for a basic rate, they should 91 * clear the high bit first. 92 */ 93 KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); 94 95 uint8_t cix = rt->info[rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]].ctlRateIndex; |
87 KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); 88 return rt->info[cix].dot11Rate; 89} 90 91static __inline__ uint8_t 92ieee80211_ctl_rate(const struct ieee80211_rate_table *rt, uint8_t rate) 93{ | 96 KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); 97 return rt->info[cix].dot11Rate; 98} 99 100static __inline__ uint8_t 101ieee80211_ctl_rate(const struct ieee80211_rate_table *rt, uint8_t rate) 102{ |
94 uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex; | 103 /* 104 * XXX Assert this is for a legacy rate; not for an MCS rate. 105 * If the caller wishes to use it for a basic rate, they should 106 * clear the high bit first. 107 */ 108 KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); 109 110 uint8_t cix = rt->info[rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]].ctlRateIndex; |
95 KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); 96 return rt->info[cix].dot11Rate; 97} 98 99static __inline__ enum ieee80211_phytype 100ieee80211_rate2phytype(const struct ieee80211_rate_table *rt, uint8_t rate) 101{ | 111 KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); 112 return rt->info[cix].dot11Rate; 113} 114 115static __inline__ enum ieee80211_phytype 116ieee80211_rate2phytype(const struct ieee80211_rate_table *rt, uint8_t rate) 117{ |
102 uint8_t rix = rt->rateCodeToIndex[rate]; | 118 /* 119 * XXX Assert this is for a legacy rate; not for an MCS rate. 120 * If the caller wishes to use it for a basic rate, they should 121 * clear the high bit first. 122 */ 123 KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); 124 125 uint8_t rix = rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]; |
103 KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate)); 104 return rt->info[rix].phy; 105} 106 107static __inline__ int 108ieee80211_isratevalid(const struct ieee80211_rate_table *rt, uint8_t rate) 109{ | 126 KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate)); 127 return rt->info[rix].phy; 128} 129 130static __inline__ int 131ieee80211_isratevalid(const struct ieee80211_rate_table *rt, uint8_t rate) 132{ |
133 /* 134 * XXX Assert this is for a legacy rate; not for an MCS rate. 135 * If the caller wishes to use it for a basic rate, they should 136 * clear the high bit first. 137 */ 138 KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); 139 |
|
110 return rt->rateCodeToIndex[rate] != (uint8_t)-1; 111} 112 113/* 114 * Calculate ACK field for 115 * o non-fragment data frames 116 * o management frames 117 * sent using rate, phy and short preamble setting. --- 11 unchanged lines hidden (view full) --- 129 return rt->info[rix].spAckDuration; 130 } else { 131 KASSERT(rt->info[rix].lpAckDuration != 0, 132 ("lgpreamble ack dur is not computed!\n")); 133 return rt->info[rix].lpAckDuration; 134 } 135} 136 | 140 return rt->rateCodeToIndex[rate] != (uint8_t)-1; 141} 142 143/* 144 * Calculate ACK field for 145 * o non-fragment data frames 146 * o management frames 147 * sent using rate, phy and short preamble setting. --- 11 unchanged lines hidden (view full) --- 159 return rt->info[rix].spAckDuration; 160 } else { 161 KASSERT(rt->info[rix].lpAckDuration != 0, 162 ("lgpreamble ack dur is not computed!\n")); 163 return rt->info[rix].lpAckDuration; 164 } 165} 166 |
167static __inline__ uint8_t 168ieee80211_legacy_rate_lookup(const struct ieee80211_rate_table *rt, 169 uint8_t rate) 170{ 171 172 return (rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]); 173} 174 |
|
137/* 138 * Compute the time to transmit a frame of length frameLen bytes 139 * using the specified 802.11 rate code, phy, and short preamble 140 * setting. 141 * 142 * NB: SIFS is included. 143 */ 144uint16_t ieee80211_compute_duration(const struct ieee80211_rate_table *, 145 uint32_t frameLen, uint16_t rate, int isShortPreamble); 146/* 147 * Convert PLCP signal/rate field to 802.11 rate code (.5Mbits/s) 148 */ 149uint8_t ieee80211_plcp2rate(uint8_t, enum ieee80211_phytype); 150/* 151 * Convert 802.11 rate code to PLCP signal. 152 */ 153uint8_t ieee80211_rate2plcp(int, enum ieee80211_phytype); | 175/* 176 * Compute the time to transmit a frame of length frameLen bytes 177 * using the specified 802.11 rate code, phy, and short preamble 178 * setting. 179 * 180 * NB: SIFS is included. 181 */ 182uint16_t ieee80211_compute_duration(const struct ieee80211_rate_table *, 183 uint32_t frameLen, uint16_t rate, int isShortPreamble); 184/* 185 * Convert PLCP signal/rate field to 802.11 rate code (.5Mbits/s) 186 */ 187uint8_t ieee80211_plcp2rate(uint8_t, enum ieee80211_phytype); 188/* 189 * Convert 802.11 rate code to PLCP signal. 190 */ 191uint8_t ieee80211_rate2plcp(int, enum ieee80211_phytype); |
192 193uint32_t ieee80211_compute_duration_ht(uint32_t frameLen, 194 uint16_t rate, int streams, int isht40, 195 int isShortGI); 196 |
|
154#endif /* _KERNEL */ 155#endif /* !_NET80211_IEEE80211_PHY_H_ */ | 197#endif /* _KERNEL */ 198#endif /* !_NET80211_IEEE80211_PHY_H_ */ |