Commit 7e9ed188 authored by Daniel Drake's avatar Daniel Drake Committed by David S. Miller

[MAC80211]: improved short preamble handling

Similarly to CTS protection, whether short preambles are used for 802.11b
transmissions should be a per-subif setting, not device global.

For STAs, this patch makes short preamble handling automatic based on the ERP
IE. For APs, hostapd still uses the prism ioctls, but the write ioctl has been
restricted to AP-only subifs.

ieee80211_txrx_data.short_preamble (an unused field) was removed.

Unfortunately, some API changes were required for the following functions:
 - ieee80211_generic_frame_duration
 - ieee80211_rts_duration
 - ieee80211_ctstoself_duration
 - ieee80211_rts_get
 - ieee80211_ctstoself_get
Affected drivers were updated accordingly.
Signed-off-by: default avatarDaniel Drake <dsd@gentoo.org>
Signed-off-by: default avatarJiri Benc <jbenc@suse.cz>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d5d08def
...@@ -67,6 +67,7 @@ struct rtl8187_priv { ...@@ -67,6 +67,7 @@ struct rtl8187_priv {
struct rtl818x_csr *map; struct rtl818x_csr *map;
void (*rf_init)(struct ieee80211_hw *); void (*rf_init)(struct ieee80211_hw *);
int mode; int mode;
int if_id;
/* rtl8187 specific */ /* rtl8187 specific */
struct ieee80211_channel channels[14]; struct ieee80211_channel channels[14];
......
...@@ -96,7 +96,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb, ...@@ -96,7 +96,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) {
tmp |= RTL8187_TX_FLAG_RTS; tmp |= RTL8187_TX_FLAG_RTS;
hdr->rts_duration = hdr->rts_duration =
ieee80211_rts_duration(dev, skb->len, control); ieee80211_rts_duration(dev, priv->if_id, skb->len, control);
} }
if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)
tmp |= RTL8187_TX_FLAG_CTS; tmp |= RTL8187_TX_FLAG_CTS;
...@@ -510,6 +510,8 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id, ...@@ -510,6 +510,8 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id,
struct rtl8187_priv *priv = dev->priv; struct rtl8187_priv *priv = dev->priv;
int i; int i;
priv->if_id = if_id;
for (i = 0; i < ETH_ALEN; i++) for (i = 0; i < ETH_ALEN; i++)
rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]); rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]);
......
...@@ -835,6 +835,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, ...@@ -835,6 +835,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
/** /**
* ieee80211_rts_get - RTS frame generation function * ieee80211_rts_get - RTS frame generation function
* @hw: pointer obtained from ieee80211_alloc_hw(). * @hw: pointer obtained from ieee80211_alloc_hw().
* @if_id: interface ID from &struct ieee80211_if_init_conf.
* @frame: pointer to the frame that is going to be protected by the RTS. * @frame: pointer to the frame that is going to be protected by the RTS.
* @frame_len: the frame length (in octets). * @frame_len: the frame length (in octets).
* @frame_txctl: &struct ieee80211_tx_control of the frame. * @frame_txctl: &struct ieee80211_tx_control of the frame.
...@@ -845,7 +846,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, ...@@ -845,7 +846,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
* the next RTS frame from the 802.11 code. The low-level is responsible * the next RTS frame from the 802.11 code. The low-level is responsible
* for calling this function before and RTS frame is needed. * for calling this function before and RTS frame is needed.
*/ */
void ieee80211_rts_get(struct ieee80211_hw *hw, void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
const void *frame, size_t frame_len, const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl, const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_rts *rts); struct ieee80211_rts *rts);
...@@ -853,6 +854,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, ...@@ -853,6 +854,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw,
/** /**
* ieee80211_rts_duration - Get the duration field for an RTS frame * ieee80211_rts_duration - Get the duration field for an RTS frame
* @hw: pointer obtained from ieee80211_alloc_hw(). * @hw: pointer obtained from ieee80211_alloc_hw().
* @if_id: interface ID from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame that is going to be protected by the RTS. * @frame_len: the length of the frame that is going to be protected by the RTS.
* @frame_txctl: &struct ieee80211_tx_control of the frame. * @frame_txctl: &struct ieee80211_tx_control of the frame.
* *
...@@ -860,13 +862,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, ...@@ -860,13 +862,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw,
* the duration field, the low-level driver uses this function to receive * the duration field, the low-level driver uses this function to receive
* the duration field value in little-endian byteorder. * the duration field value in little-endian byteorder.
*/ */
__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl); const struct ieee80211_tx_control *frame_txctl);
/** /**
* ieee80211_ctstoself_get - CTS-to-self frame generation function * ieee80211_ctstoself_get - CTS-to-self frame generation function
* @hw: pointer obtained from ieee80211_alloc_hw(). * @hw: pointer obtained from ieee80211_alloc_hw().
* @if_id: interface ID from &struct ieee80211_if_init_conf.
* @frame: pointer to the frame that is going to be protected by the CTS-to-self. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
* @frame_len: the frame length (in octets). * @frame_len: the frame length (in octets).
* @frame_txctl: &struct ieee80211_tx_control of the frame. * @frame_txctl: &struct ieee80211_tx_control of the frame.
...@@ -877,7 +880,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, ...@@ -877,7 +880,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
* the next CTS-to-self frame from the 802.11 code. The low-level is responsible * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
* for calling this function before and CTS-to-self frame is needed. * for calling this function before and CTS-to-self frame is needed.
*/ */
void ieee80211_ctstoself_get(struct ieee80211_hw *hw, void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
const void *frame, size_t frame_len, const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl, const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_cts *cts); struct ieee80211_cts *cts);
...@@ -885,6 +888,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, ...@@ -885,6 +888,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
/** /**
* ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
* @hw: pointer obtained from ieee80211_alloc_hw(). * @hw: pointer obtained from ieee80211_alloc_hw().
* @if_id: interface ID from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame that is going to be protected by the CTS-to-self. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
* @frame_txctl: &struct ieee80211_tx_control of the frame. * @frame_txctl: &struct ieee80211_tx_control of the frame.
* *
...@@ -892,20 +896,21 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, ...@@ -892,20 +896,21 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
* the duration field, the low-level driver uses this function to receive * the duration field, the low-level driver uses this function to receive
* the duration field value in little-endian byteorder. * the duration field value in little-endian byteorder.
*/ */
__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl); const struct ieee80211_tx_control *frame_txctl);
/** /**
* ieee80211_generic_frame_duration - Calculate the duration field for a frame * ieee80211_generic_frame_duration - Calculate the duration field for a frame
* @hw: pointer obtained from ieee80211_alloc_hw(). * @hw: pointer obtained from ieee80211_alloc_hw().
* @if_id: interface ID from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame. * @frame_len: the length of the frame.
* @rate: the rate (in 100kbps) at which the frame is going to be transmitted. * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
* *
* Calculate the duration field of some generic frame, given its * Calculate the duration field of some generic frame, given its
* length and transmission rate (in 100kbps). * length and transmission rate (in 100kbps).
*/ */
__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, size_t frame_len,
int rate); int rate);
......
...@@ -127,7 +127,6 @@ struct ieee80211_txrx_data { ...@@ -127,7 +127,6 @@ struct ieee80211_txrx_data {
struct ieee80211_tx_control *control; struct ieee80211_tx_control *control;
unsigned int unicast:1; unsigned int unicast:1;
unsigned int ps_buffered:1; unsigned int ps_buffered:1;
unsigned int short_preamble:1;
unsigned int probe_last_frag:1; unsigned int probe_last_frag:1;
struct ieee80211_hw_mode *mode; struct ieee80211_hw_mode *mode;
struct ieee80211_rate *rate; struct ieee80211_rate *rate;
...@@ -286,6 +285,11 @@ struct ieee80211_sub_if_data { ...@@ -286,6 +285,11 @@ struct ieee80211_sub_if_data {
unsigned int promisc:1; unsigned int promisc:1;
unsigned int use_protection:1; /* CTS protect ERP frames */ unsigned int use_protection:1; /* CTS protect ERP frames */
/* use short preamble with IEEE 802.11b: this flag is set when the AP
* or beacon generator reports that there are no present stations that
* cannot support short preambles */
unsigned int short_preamble:1;
struct net_device_stats stats; struct net_device_stats stats;
int drop_unencrypted; int drop_unencrypted;
int eapol; /* 0 = process EAPOL frames as normal data frames, int eapol; /* 0 = process EAPOL frames as normal data frames,
...@@ -447,7 +451,6 @@ struct ieee80211_local { ...@@ -447,7 +451,6 @@ struct ieee80211_local {
int fragmentation_threshold; int fragmentation_threshold;
int short_retry_limit; /* dot11ShortRetryLimit */ int short_retry_limit; /* dot11ShortRetryLimit */
int long_retry_limit; /* dot11LongRetryLimit */ int long_retry_limit; /* dot11LongRetryLimit */
int short_preamble; /* use short preamble with IEEE 802.11b */
struct crypto_blkcipher *wep_tx_tfm; struct crypto_blkcipher *wep_tx_tfm;
struct crypto_blkcipher *wep_rx_tfm; struct crypto_blkcipher *wep_rx_tfm;
......
...@@ -1061,7 +1061,10 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev, ...@@ -1061,7 +1061,10 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
break; break;
case PRISM2_PARAM_PREAMBLE: case PRISM2_PARAM_PREAMBLE:
local->short_preamble = value; if (sdata->type != IEEE80211_IF_TYPE_AP)
ret = -ENOENT;
else
sdata->short_preamble = value;
break; break;
case PRISM2_PARAM_STAT_TIME: case PRISM2_PARAM_STAT_TIME:
...@@ -1184,7 +1187,7 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev, ...@@ -1184,7 +1187,7 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
break; break;
case PRISM2_PARAM_PREAMBLE: case PRISM2_PARAM_PREAMBLE:
*param = local->short_preamble; *param = sdata->short_preamble;
break; break;
case PRISM2_PARAM_STAT_TIME: case PRISM2_PARAM_STAT_TIME:
......
...@@ -318,6 +318,7 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value) ...@@ -318,6 +318,7 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value)
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_if_sta *ifsta = &sdata->u.sta; struct ieee80211_if_sta *ifsta = &sdata->u.sta;
int use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0; int use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
int preamble_mode = (erp_value & WLAN_ERP_BARKER_PREAMBLE) != 0;
if (use_protection != sdata->use_protection) { if (use_protection != sdata->use_protection) {
if (net_ratelimit()) { if (net_ratelimit()) {
...@@ -329,6 +330,18 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value) ...@@ -329,6 +330,18 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value)
} }
sdata->use_protection = use_protection; sdata->use_protection = use_protection;
} }
if (!preamble_mode != sdata->short_preamble) {
if (net_ratelimit()) {
printk(KERN_DEBUG "%s: switched to %s barker preamble"
" (BSSID=" MAC_FMT ")\n",
dev->name,
(preamble_mode == WLAN_ERP_PREAMBLE_SHORT) ?
"short" : "long",
MAC_ARG(ifsta->bssid));
}
sdata->short_preamble = !preamble_mode;
}
} }
...@@ -415,6 +428,7 @@ static void ieee80211_set_associated(struct net_device *dev, ...@@ -415,6 +428,7 @@ static void ieee80211_set_associated(struct net_device *dev,
ieee80211_sta_send_associnfo(dev, ifsta); ieee80211_sta_send_associnfo(dev, ifsta);
} else { } else {
netif_carrier_off(dev); netif_carrier_off(dev);
sdata->short_preamble = 0;
sdata->use_protection = 0; sdata->use_protection = 0;
memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
} }
...@@ -2281,7 +2295,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, ...@@ -2281,7 +2295,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev,
"for IBSS beacon\n", dev->name); "for IBSS beacon\n", dev->name);
break; break;
} }
control.tx_rate = (local->short_preamble && control.tx_rate = (sdata->short_preamble &&
(rate->flags & IEEE80211_RATE_PREAMBLE2)) ? (rate->flags & IEEE80211_RATE_PREAMBLE2)) ?
rate->val2 : rate->val; rate->val2 : rate->val;
control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; control.antenna_sel_tx = local->hw.conf.antenna_sel_tx;
......
...@@ -173,7 +173,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, ...@@ -173,7 +173,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr,
* to closest integer */ * to closest integer */
dur = ieee80211_frame_duration(local, 10, rate, erp, dur = ieee80211_frame_duration(local, 10, rate, erp,
local->short_preamble); tx->sdata->short_preamble);
if (next_frag_len) { if (next_frag_len) {
/* Frame is fragmented: duration increases with time needed to /* Frame is fragmented: duration increases with time needed to
...@@ -182,7 +182,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, ...@@ -182,7 +182,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr,
/* next fragment */ /* next fragment */
dur += ieee80211_frame_duration(local, next_frag_len, dur += ieee80211_frame_duration(local, next_frag_len,
txrate->rate, erp, txrate->rate, erp,
local->short_preamble); tx->sdata->short_preamble);
} }
return dur; return dur;
...@@ -627,12 +627,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) ...@@ -627,12 +627,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx)
tx->u.tx.control->rate = tx->u.tx.rate; tx->u.tx.control->rate = tx->u.tx.rate;
} }
tx->u.tx.control->tx_rate = tx->u.tx.rate->val; tx->u.tx.control->tx_rate = tx->u.tx.rate->val;
if ((tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) &&
tx->local->short_preamble &&
(!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) {
tx->u.tx.short_preamble = 1;
tx->u.tx.control->tx_rate = tx->u.tx.rate->val2;
}
return TXRX_CONTINUE; return TXRX_CONTINUE;
} }
...@@ -641,6 +635,7 @@ static ieee80211_txrx_result ...@@ -641,6 +635,7 @@ static ieee80211_txrx_result
ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
u16 fc = le16_to_cpu(hdr->frame_control);
u16 dur; u16 dur;
struct ieee80211_tx_control *control = tx->u.tx.control; struct ieee80211_tx_control *control = tx->u.tx.control;
struct ieee80211_hw_mode *mode = tx->u.tx.mode; struct ieee80211_hw_mode *mode = tx->u.tx.mode;
...@@ -677,6 +672,16 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) ...@@ -677,6 +672,16 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
!(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS))
control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT; control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT;
/* Transmit data frames using short preambles if the driver supports
* short preambles at the selected rate and short preambles are
* available on the network at the current point in time. */
if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
(tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) &&
tx->sdata->short_preamble &&
(!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) {
tx->u.tx.control->tx_rate = tx->u.tx.rate->val2;
}
/* Setup duration field for the first fragment of the frame. Duration /* Setup duration field for the first fragment of the frame. Duration
* for remaining fragments will be updated when they are being sent * for remaining fragments will be updated when they are being sent
* to low-level driver in ieee80211_tx(). */ * to low-level driver in ieee80211_tx(). */
...@@ -1750,7 +1755,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, ...@@ -1750,7 +1755,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
return NULL; return NULL;
} }
control->tx_rate = (local->short_preamble && control->tx_rate = (sdata->short_preamble &&
(rate->flags & IEEE80211_RATE_PREAMBLE2)) ? (rate->flags & IEEE80211_RATE_PREAMBLE2)) ?
rate->val2 : rate->val; rate->val2 : rate->val;
control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
...@@ -1765,7 +1770,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, ...@@ -1765,7 +1770,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
} }
EXPORT_SYMBOL(ieee80211_beacon_get); EXPORT_SYMBOL(ieee80211_beacon_get);
void ieee80211_rts_get(struct ieee80211_hw *hw, void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
const void *frame, size_t frame_len, const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl, const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_rts *rts) struct ieee80211_rts *rts)
...@@ -1775,13 +1780,13 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, ...@@ -1775,13 +1780,13 @@ void ieee80211_rts_get(struct ieee80211_hw *hw,
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS;
rts->frame_control = cpu_to_le16(fctl); rts->frame_control = cpu_to_le16(fctl);
rts->duration = ieee80211_rts_duration(hw, frame_len, frame_txctl); rts->duration = ieee80211_rts_duration(hw, if_id, frame_len, frame_txctl);
memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); memcpy(rts->ra, hdr->addr1, sizeof(rts->ra));
memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); memcpy(rts->ta, hdr->addr2, sizeof(rts->ta));
} }
EXPORT_SYMBOL(ieee80211_rts_get); EXPORT_SYMBOL(ieee80211_rts_get);
void ieee80211_ctstoself_get(struct ieee80211_hw *hw, void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
const void *frame, size_t frame_len, const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl, const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_cts *cts) struct ieee80211_cts *cts)
...@@ -1791,7 +1796,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, ...@@ -1791,7 +1796,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS;
cts->frame_control = cpu_to_le16(fctl); cts->frame_control = cpu_to_le16(fctl);
cts->duration = ieee80211_ctstoself_duration(hw, frame_len, frame_txctl); cts->duration = ieee80211_ctstoself_duration(hw, if_id, frame_len, frame_txctl);
memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));
} }
EXPORT_SYMBOL(ieee80211_ctstoself_get); EXPORT_SYMBOL(ieee80211_ctstoself_get);
......
...@@ -314,31 +314,46 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, ...@@ -314,31 +314,46 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
} }
/* Exported duration function for driver use */ /* Exported duration function for driver use */
__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, int rate) size_t frame_len, int rate)
{ {
struct ieee80211_local *local = hw_to_local(hw); struct ieee80211_local *local = hw_to_local(hw);
struct net_device *bdev = dev_get_by_index(if_id);
struct ieee80211_sub_if_data *sdata;
u16 dur; u16 dur;
int erp; int erp;
if (unlikely(!bdev))
return 0;
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); erp = ieee80211_is_erp_rate(hw->conf.phymode, rate);
dur = ieee80211_frame_duration(local, frame_len, rate, dur = ieee80211_frame_duration(local, frame_len, rate,
erp, local->short_preamble); erp, sdata->short_preamble);
dev_put(bdev);
return cpu_to_le16(dur); return cpu_to_le16(dur);
} }
EXPORT_SYMBOL(ieee80211_generic_frame_duration); EXPORT_SYMBOL(ieee80211_generic_frame_duration);
__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl) const struct ieee80211_tx_control *frame_txctl)
{ {
struct ieee80211_local *local = hw_to_local(hw); struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_rate *rate; struct ieee80211_rate *rate;
int short_preamble = local->short_preamble; struct net_device *bdev = dev_get_by_index(if_id);
struct ieee80211_sub_if_data *sdata;
int short_preamble;
int erp; int erp;
u16 dur; u16 dur;
if (unlikely(!bdev))
return 0;
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
short_preamble = sdata->short_preamble;
rate = frame_txctl->rts_rate; rate = frame_txctl->rts_rate;
erp = !!(rate->flags & IEEE80211_RATE_ERP); erp = !!(rate->flags & IEEE80211_RATE_ERP);
...@@ -352,20 +367,29 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, ...@@ -352,20 +367,29 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
dur += ieee80211_frame_duration(local, 10, rate->rate, dur += ieee80211_frame_duration(local, 10, rate->rate,
erp, short_preamble); erp, short_preamble);
dev_put(bdev);
return cpu_to_le16(dur); return cpu_to_le16(dur);
} }
EXPORT_SYMBOL(ieee80211_rts_duration); EXPORT_SYMBOL(ieee80211_rts_duration);
__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
size_t frame_len, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl) const struct ieee80211_tx_control *frame_txctl)
{ {
struct ieee80211_local *local = hw_to_local(hw); struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_rate *rate; struct ieee80211_rate *rate;
int short_preamble = local->short_preamble; struct net_device *bdev = dev_get_by_index(if_id);
struct ieee80211_sub_if_data *sdata;
int short_preamble;
int erp; int erp;
u16 dur; u16 dur;
if (unlikely(!bdev))
return 0;
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
short_preamble = sdata->short_preamble;
rate = frame_txctl->rts_rate; rate = frame_txctl->rts_rate;
erp = !!(rate->flags & IEEE80211_RATE_ERP); erp = !!(rate->flags & IEEE80211_RATE_ERP);
...@@ -378,6 +402,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, ...@@ -378,6 +402,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
erp, short_preamble); erp, short_preamble);
} }
dev_put(bdev);
return cpu_to_le16(dur); return cpu_to_le16(dur);
} }
EXPORT_SYMBOL(ieee80211_ctstoself_duration); EXPORT_SYMBOL(ieee80211_ctstoself_duration);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment