nl80211: Add set/get for frag/rts threshold and retry limits
Subsystems (2)
Johannes Berg
maintainerPATCH 1/1 nl80211: Add set/get for frag/rts threshold and retry limits
From: Jouni Malinen <[email protected]>
Add new nl80211 attributes that can be used with NL80211_CMD_SET_WIPHY and NL80211_CMD_GET_WIPHY to manage fragmentation/RTS threshold and retry limits.
Since these values are stored in struct wiphy, remove the local copy from mac80211 where feasible (frag & rts threshold). The retry limits are currently needed in struct ieee80211_conf, but these could be eventually removed since the driver should have access to the values in struct wiphy.
Johannes: Rebase, and additionally move the wext handlers to cfg80211 and correct the retry wext handler to use wireless extensions v21 (retry long/short rather than min/max).
--- include/linux/nl80211.h | 24 ++++++ include/net/cfg80211.h | 50 ++++++++++++++ net/mac80211/cfg.c | 27 +++++++ net/mac80211/debugfs.c | 8 +- net/mac80211/ieee80211_i.h | 3 net/mac80211/main.c | 6 - net/mac80211/tx.c | 9 +- net/mac80211/util.c | 2 net/mac80211/wext.c | 138 +-------------------------------------- net/wireless/core.c | 10 ++ net/wireless/nl80211.c | 95 +++++++++++++++++++++++++++ net/wireless/wext-compat.c | 158 +++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 379 insertions(+), 151 deletions(-)
v2: make set_wiphy_params() a notification function that does not return
an error code (too complex to figure out what to do on error and not much of a problem if the new values are left in struct wiphy)
v3: (Johannes -- no userspace API/ABI changes)
* actually make set_wiphy_params() have an error return again
* rebase
* wext handlers moved & wext v21
include/linux/nl80211.h +22 -2
@@ -46,8 +46,10 @@* to get a list of all present wiphys. * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME, -* %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ, and/or -* %NL80211_ATTR_WIPHY_CHANNEL_TYPE. +* %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ, +* %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT, +* %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD, +* and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD. * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request * or rename notification. Has attributes %NL80211_ATTR_WIPHY and * %NL80211_ATTR_WIPHY_NAME.
@@ -337,6 +339,18 @@ enum nl80211_commands {* NL80211_CHAN_HT20 = HT20 only * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel +* @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is +* less than or equal to the RTS threshold; allowed range: 1..255; +* dot11ShortRetryLimit; u8 +* @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is +* greater than the RTS threshold; allowed range: 1..255; +* dot11ShortLongLimit; u8 +* @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum +* length in octets for frames; allowed range: 256..8000, disable +* fragmentation with (u32)-1; dot11FragmentationThreshold; u32 +* @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length +* larger than or equal to this use RTS/CTS handshake); allowed range: +* 0..65536, disable with (u32)-1; dot11RTSThreshold; u32 * * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on * @NL80211_ATTR_IFNAME: network interface name
@@ -565,6 +579,12 @@ enum nl80211_attrs {NL80211_ATTR_FREQ_FIXED , + +NL80211_ATTR_WIPHY_RETRY_SHORT , +NL80211_ATTR_WIPHY_RETRY_LONG , +NL80211_ATTR_WIPHY_FRAG_THRESHOLD , +NL80211_ATTR_WIPHY_RTS_THRESHOLD , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +50 -0
86 lines not on this page · raw message
net/mac80211/cfg.c +27 -0
@@ -1297,6 +1297,32 @@ static int ieee80211_leave_ibss(struct wreturn ieee80211_ibss_leave (sdata); } +static int ieee80211_set_wiphy_params (struct wiphy *wiphy,u32 changed) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); + +if (changed &WIPHY_PARAM_RTS_THRESHOLD ) { +int err; + +if (local->ops->set_rts_threshold) { + err = local->ops->set_rts_threshold ( +local_to_hw (local), wiphy->rts_threshold); +if (err) +return err; + } + } + +if (changed &WIPHY_PARAM_RETRY_SHORT ) + local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; +if (changed &WIPHY_PARAM_RETRY_LONG ) + local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; +if (changed & + (WIPHY_PARAM_RETRY_SHORT |WIPHY_PARAM_RETRY_LONG )) +ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_RETRY_LIMITS ); + +return 0 ; +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1335,4 +1361,5 @@ struct cfg80211_ops mac80211_config_ops .disassoc = ieee80211_disassoc, .join_ibss = ieee80211_join_ibss, .leave_ibss = ieee80211_leave_ibss, + .set_wiphy_params = ieee80211_set_wiphy_params, };
net/wireless/nl80211.c +95 -0
119 lines not on this page · raw message
net/mac80211/debugfs.c +4 -4
@@ -52,13 +52,13 @@ static const struct file_operations nameDEBUGFS_READONLY_FILE (frequency,20 ,"%d" , local->hw.conf.channel->center_freq);DEBUGFS_READONLY_FILE (rts_threshold,20 ,"%d" , - local->rts_threshold); + local->hw.wiphy->rts_threshold);DEBUGFS_READONLY_FILE (fragmentation_threshold,20 ,"%d" , - local->fragmentation_threshold); + local->hw.wiphy->frag_threshold);DEBUGFS_READONLY_FILE (short_retry_limit,20 ,"%d" , - local->hw.conf.short_frame_max_tx_count); + local->hw.wiphy->retry_short);DEBUGFS_READONLY_FILE (long_retry_limit,20 ,"%d" , - local->hw.conf.long_frame_max_tx_count); + local->hw.wiphy->retry_long);DEBUGFS_READONLY_FILE (total_ps_buffered,20 ,"%d" , local->total_ps_buffered); DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x",
net/mac80211/ieee80211_i.h +0 -3
@@ -643,9 +643,6 @@ struct ieee80211_local {struct rate_control_ref *rate_ctrl; -int rts_threshold; -int fragmentation_threshold; -struct crypto_blkcipher *wep_tx_tfm;struct crypto_blkcipher *wep_rx_tfm;u32 wep_iv;
net/mac80211/main.c +2 -4
@@ -776,10 +776,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(/* set up some defaults */ local->hw.queues =1 ; local->hw.max_rates =1 ; - local->rts_threshold =IEEE80211_MAX_RTS_THRESHOLD ; - local->fragmentation_threshold =IEEE80211_MAX_FRAG_THRESHOLD ; - local->hw.conf.long_frame_max_tx_count =4 ; - local->hw.conf.short_frame_max_tx_count =7 ; + local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; + local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; local->hw.conf.radio_enabled = true;INIT_LIST_HEAD (&local->interfaces);
net/mac80211/tx.c +4 -5
@@ -500,7 +500,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 sband = tx->local->hw.wiphy->bands[tx->channel->band]; len =min_t (int, tx->skb->len +FCS_LEN , - tx->local->fragmentation_threshold); + tx->local->hw.wiphy->frag_threshold);/* set up the tx rate control struct we give the RC algo */ txrc.hw =local_to_hw (tx->local);
@@ -511,8 +511,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx;/* set up RTS protection if desired */ -if (tx->local->rts_threshold <IEEE80211_MAX_RTS_THRESHOLD && - len > tx->local->rts_threshold) { +if (len > tx->local->hw.wiphy->rts_threshold) { txrc.rts = rts = true; }
@@ -754,7 +753,7 @@ ieee80211_tx_h_fragment(struct ieee80211struct sk_buff *skb = tx->skb;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_hdr *hdr = (void *)skb->data; -int frag_threshold = tx->local->fragmentation_threshold; +int frag_threshold = tx->local->hw.wiphy->frag_threshold;int hdrlen;int fragnum;
@@ -1072,7 +1071,7 @@ __ieee80211_tx_prepare(struct ieee80211_if (tx->flags &IEEE80211_TX_FRAGMENTED ) {if ((tx->flags &IEEE80211_TX_UNICAST ) && - skb->len +FCS_LEN > local->fragmentation_threshold && + skb->len +FCS_LEN > local->hw.wiphy->frag_threshold && !(info->flags &IEEE80211_TX_CTL_AMPDU )) tx->flags |=IEEE80211_TX_FRAGMENTED ;else
net/mac80211/util.c +1 -1
@@ -1046,7 +1046,7 @@ int ieee80211_reconfig(struct ieee80211_/* setup RTS threshold */ if (local->ops->set_rts_threshold) - local->ops->set_rts_threshold (hw, local->rts_threshold); + local->ops->set_rts_threshold (hw, hw->wiphy->rts_threshold);/* reconfigure hardware */ ieee80211_hw_config (local, ~0 );
net/mac80211/wext.c +6 -132
152 lines not on this page · raw message
net/wireless/core.c +10 -0
@@ -273,6 +273,16 @@ struct wiphy *wiphy_new(struct cfg80211_ drv->wiphy.dev.class = &ieee80211_class; drv->wiphy.dev.platform_data = drv; +/* +* Initialize wiphy parameters to IEEE 802.11 MIB default values. +* Fragmentation and RTS threshold are disabled by default with the +* special -1 value. +*/ + drv->wiphy.retry_short =7 ; + drv->wiphy.retry_long =4 ; + drv->wiphy.frag_threshold = (u32) -1 ; + drv->wiphy.rts_threshold = (u32) -1 ; +return &drv->wiphy; }EXPORT_SYMBOL (wiphy_new);
net/wireless/wext-compat.c +158 -0
161 lines not on this page · raw message
Johannes Berg
maintainerPATCH v4 1/1 nl80211: Add set/get for frag/rts threshold and retry limits
From: Jouni Malinen <[email protected]>
Add new nl80211 attributes that can be used with NL80211_CMD_SET_WIPHY and NL80211_CMD_GET_WIPHY to manage fragmentation/RTS threshold and retry limits.
Since these values are stored in struct wiphy, remove the local copy from mac80211 where feasible (frag & rts threshold). The retry limits are currently needed in struct ieee80211_conf, but these could be eventually removed since the driver should have access to the values in struct wiphy.
---
v2: make set_wiphy_params() a notification function that does not return
an error code (too complex to figure out what to do on error and not much of a problem if the new values are left in struct wiphy)
v3: (Johannes)
* actually make set_wiphy_params() have an error return again
* rebase
v4: (Johannes)
* remove stray debug printks
include/linux/nl80211.h | 24 ++++++- include/net/cfg80211.h | 50 ++++++++++++++ net/mac80211/cfg.c | 27 ++++++++ net/mac80211/debugfs.c | 8 +- net/mac80211/ieee80211_i.h | 3 net/mac80211/main.c | 6 - net/mac80211/tx.c | 9 +- net/mac80211/util.c | 2 net/mac80211/wext.c | 138 +---------------------------------------- net/wireless/core.c | 10 ++ net/wireless/nl80211.c | 95 ++++++++++++++++++++++++++++ net/wireless/wext-compat.c | 151 +++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 372 insertions(+), 151 deletions(-)
include/linux/nl80211.h +22 -2
@@ -46,8 +46,10 @@* to get a list of all present wiphys. * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME, -* %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ, and/or -* %NL80211_ATTR_WIPHY_CHANNEL_TYPE. +* %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ, +* %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT, +* %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD, +* and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD. * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request * or rename notification. Has attributes %NL80211_ATTR_WIPHY and * %NL80211_ATTR_WIPHY_NAME.
@@ -337,6 +339,18 @@ enum nl80211_commands {* NL80211_CHAN_HT20 = HT20 only * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel +* @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is +* less than or equal to the RTS threshold; allowed range: 1..255; +* dot11ShortRetryLimit; u8 +* @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is +* greater than the RTS threshold; allowed range: 1..255; +* dot11ShortLongLimit; u8 +* @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum +* length in octets for frames; allowed range: 256..8000, disable +* fragmentation with (u32)-1; dot11FragmentationThreshold; u32 +* @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length +* larger than or equal to this use RTS/CTS handshake); allowed range: +* 0..65536, disable with (u32)-1; dot11RTSThreshold; u32 * * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on * @NL80211_ATTR_IFNAME: network interface name
@@ -565,6 +579,12 @@ enum nl80211_attrs {NL80211_ATTR_FREQ_FIXED , + +NL80211_ATTR_WIPHY_RETRY_SHORT , +NL80211_ATTR_WIPHY_RETRY_LONG , +NL80211_ATTR_WIPHY_FRAG_THRESHOLD , +NL80211_ATTR_WIPHY_RTS_THRESHOLD , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +50 -0
86 lines not on this page · raw message
net/mac80211/cfg.c +27 -0
@@ -1297,6 +1297,32 @@ static int ieee80211_leave_ibss(struct wreturn ieee80211_ibss_leave (sdata); } +static int ieee80211_set_wiphy_params (struct wiphy *wiphy,u32 changed) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); + +if (changed &WIPHY_PARAM_RTS_THRESHOLD ) { +int err; + +if (local->ops->set_rts_threshold) { + err = local->ops->set_rts_threshold ( +local_to_hw (local), wiphy->rts_threshold); +if (err) +return err; + } + } + +if (changed &WIPHY_PARAM_RETRY_SHORT ) + local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; +if (changed &WIPHY_PARAM_RETRY_LONG ) + local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; +if (changed & + (WIPHY_PARAM_RETRY_SHORT |WIPHY_PARAM_RETRY_LONG )) +ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_RETRY_LIMITS ); + +return 0 ; +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1335,4 +1361,5 @@ struct cfg80211_ops mac80211_config_ops .disassoc = ieee80211_disassoc, .join_ibss = ieee80211_join_ibss, .leave_ibss = ieee80211_leave_ibss, + .set_wiphy_params = ieee80211_set_wiphy_params, };
net/wireless/nl80211.c +95 -0
119 lines not on this page · raw message
net/mac80211/debugfs.c +4 -4
@@ -52,13 +52,13 @@ static const struct file_operations nameDEBUGFS_READONLY_FILE (frequency,20 ,"%d" , local->hw.conf.channel->center_freq);DEBUGFS_READONLY_FILE (rts_threshold,20 ,"%d" , - local->rts_threshold); + local->hw.wiphy->rts_threshold);DEBUGFS_READONLY_FILE (fragmentation_threshold,20 ,"%d" , - local->fragmentation_threshold); + local->hw.wiphy->frag_threshold);DEBUGFS_READONLY_FILE (short_retry_limit,20 ,"%d" , - local->hw.conf.short_frame_max_tx_count); + local->hw.wiphy->retry_short);DEBUGFS_READONLY_FILE (long_retry_limit,20 ,"%d" , - local->hw.conf.long_frame_max_tx_count); + local->hw.wiphy->retry_long);DEBUGFS_READONLY_FILE (total_ps_buffered,20 ,"%d" , local->total_ps_buffered); DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x",
net/mac80211/ieee80211_i.h +0 -3
@@ -643,9 +643,6 @@ struct ieee80211_local {struct rate_control_ref *rate_ctrl; -int rts_threshold; -int fragmentation_threshold; -struct crypto_blkcipher *wep_tx_tfm;struct crypto_blkcipher *wep_rx_tfm;u32 wep_iv;
net/mac80211/main.c +2 -4
@@ -776,10 +776,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(/* set up some defaults */ local->hw.queues =1 ; local->hw.max_rates =1 ; - local->rts_threshold =IEEE80211_MAX_RTS_THRESHOLD ; - local->fragmentation_threshold =IEEE80211_MAX_FRAG_THRESHOLD ; - local->hw.conf.long_frame_max_tx_count =4 ; - local->hw.conf.short_frame_max_tx_count =7 ; + local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; + local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; local->hw.conf.radio_enabled = true;INIT_LIST_HEAD (&local->interfaces);
net/mac80211/tx.c +4 -5
@@ -500,7 +500,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 sband = tx->local->hw.wiphy->bands[tx->channel->band]; len =min_t (int, tx->skb->len +FCS_LEN , - tx->local->fragmentation_threshold); + tx->local->hw.wiphy->frag_threshold);/* set up the tx rate control struct we give the RC algo */ txrc.hw =local_to_hw (tx->local);
@@ -511,8 +511,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021 txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx;/* set up RTS protection if desired */ -if (tx->local->rts_threshold <IEEE80211_MAX_RTS_THRESHOLD && - len > tx->local->rts_threshold) { +if (len > tx->local->hw.wiphy->rts_threshold) { txrc.rts = rts = true; }
@@ -754,7 +753,7 @@ ieee80211_tx_h_fragment(struct ieee80211struct sk_buff *skb = tx->skb;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_hdr *hdr = (void *)skb->data; -int frag_threshold = tx->local->fragmentation_threshold; +int frag_threshold = tx->local->hw.wiphy->frag_threshold;int hdrlen;int fragnum;
@@ -1072,7 +1071,7 @@ __ieee80211_tx_prepare(struct ieee80211_if (tx->flags &IEEE80211_TX_FRAGMENTED ) {if ((tx->flags &IEEE80211_TX_UNICAST ) && - skb->len +FCS_LEN > local->fragmentation_threshold && + skb->len +FCS_LEN > local->hw.wiphy->frag_threshold && !(info->flags &IEEE80211_TX_CTL_AMPDU )) tx->flags |=IEEE80211_TX_FRAGMENTED ;else
net/mac80211/util.c +1 -1
@@ -1046,7 +1046,7 @@ int ieee80211_reconfig(struct ieee80211_/* setup RTS threshold */ if (local->ops->set_rts_threshold) - local->ops->set_rts_threshold (hw, local->rts_threshold); + local->ops->set_rts_threshold (hw, hw->wiphy->rts_threshold);/* reconfigure hardware */ ieee80211_hw_config (local, ~0 );
net/mac80211/wext.c +6 -132
152 lines not on this page · raw message
net/wireless/core.c +10 -0
@@ -273,6 +273,16 @@ struct wiphy *wiphy_new(struct cfg80211_ drv->wiphy.dev.class = &ieee80211_class; drv->wiphy.dev.platform_data = drv; +/* +* Initialize wiphy parameters to IEEE 802.11 MIB default values. +* Fragmentation and RTS threshold are disabled by default with the +* special -1 value. +*/ + drv->wiphy.retry_short =7 ; + drv->wiphy.retry_long =4 ; + drv->wiphy.frag_threshold = (u32) -1 ; + drv->wiphy.rts_threshold = (u32) -1 ; +return &drv->wiphy; }EXPORT_SYMBOL (wiphy_new);
net/wireless/wext-compat.c +151 -0
154 lines not on this page · raw message