aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-04-20 12:39:05 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-04-22 16:57:17 -0400
commitb9a5f8cab751d362f7c2d94899ca788c22fcd1ef (patch)
treee769e2f59ef845cf7c7cc93b64d33eeed49bb9f7 /net/mac80211
parent9e52b0623c6eb49c3f23a326c1fb97bdecc49ba1 (diff)
nl80211: Add set/get for frag/rts threshold and retry limits
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. Signed-off-by: Jouni Malinen <j@w1.fi> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/cfg.c27
-rw-r--r--net/mac80211/debugfs.c8
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/main.c6
-rw-r--r--net/mac80211/tx.c9
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/mac80211/wext.c138
7 files changed, 44 insertions, 149 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 14013dc64474..5e1c230744b5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1298,6 +1298,32 @@ static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1298 return ieee80211_ibss_leave(sdata); 1298 return ieee80211_ibss_leave(sdata);
1299} 1299}
1300 1300
1301static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1302{
1303 struct ieee80211_local *local = wiphy_priv(wiphy);
1304
1305 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1306 int err;
1307
1308 if (local->ops->set_rts_threshold) {
1309 err = local->ops->set_rts_threshold(
1310 local_to_hw(local), wiphy->rts_threshold);
1311 if (err)
1312 return err;
1313 }
1314 }
1315
1316 if (changed & WIPHY_PARAM_RETRY_SHORT)
1317 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1318 if (changed & WIPHY_PARAM_RETRY_LONG)
1319 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1320 if (changed &
1321 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1322 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1323
1324 return 0;
1325}
1326
1301struct cfg80211_ops mac80211_config_ops = { 1327struct cfg80211_ops mac80211_config_ops = {
1302 .add_virtual_intf = ieee80211_add_iface, 1328 .add_virtual_intf = ieee80211_add_iface,
1303 .del_virtual_intf = ieee80211_del_iface, 1329 .del_virtual_intf = ieee80211_del_iface,
@@ -1336,4 +1362,5 @@ struct cfg80211_ops mac80211_config_ops = {
1336 .disassoc = ieee80211_disassoc, 1362 .disassoc = ieee80211_disassoc,
1337 .join_ibss = ieee80211_join_ibss, 1363 .join_ibss = ieee80211_join_ibss,
1338 .leave_ibss = ieee80211_leave_ibss, 1364 .leave_ibss = ieee80211_leave_ibss,
1365 .set_wiphy_params = ieee80211_set_wiphy_params,
1339}; 1366};
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 210b9b6fecd2..5001328be46b 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -52,13 +52,13 @@ static const struct file_operations name## _ops = { \
52DEBUGFS_READONLY_FILE(frequency, 20, "%d", 52DEBUGFS_READONLY_FILE(frequency, 20, "%d",
53 local->hw.conf.channel->center_freq); 53 local->hw.conf.channel->center_freq);
54DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d", 54DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
55 local->rts_threshold); 55 local->hw.wiphy->rts_threshold);
56DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d", 56DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
57 local->fragmentation_threshold); 57 local->hw.wiphy->frag_threshold);
58DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d", 58DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
59 local->hw.conf.short_frame_max_tx_count); 59 local->hw.wiphy->retry_short);
60DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d", 60DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
61 local->hw.conf.long_frame_max_tx_count); 61 local->hw.wiphy->retry_long);
62DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", 62DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
63 local->total_ps_buffered); 63 local->total_ps_buffered);
64DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x", 64DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x",
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 92a573bf1035..dba78d89a10c 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -643,9 +643,6 @@ struct ieee80211_local {
643 643
644 struct rate_control_ref *rate_ctrl; 644 struct rate_control_ref *rate_ctrl;
645 645
646 int rts_threshold;
647 int fragmentation_threshold;
648
649 struct crypto_blkcipher *wep_tx_tfm; 646 struct crypto_blkcipher *wep_tx_tfm;
650 struct crypto_blkcipher *wep_rx_tfm; 647 struct crypto_blkcipher *wep_rx_tfm;
651 u32 wep_iv; 648 u32 wep_iv;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index d26fc399285e..5320e08434ac 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -776,10 +776,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
776 /* set up some defaults */ 776 /* set up some defaults */
777 local->hw.queues = 1; 777 local->hw.queues = 1;
778 local->hw.max_rates = 1; 778 local->hw.max_rates = 1;
779 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; 779 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
780 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; 780 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
781 local->hw.conf.long_frame_max_tx_count = 4;
782 local->hw.conf.short_frame_max_tx_count = 7;
783 local->hw.conf.radio_enabled = true; 781 local->hw.conf.radio_enabled = true;
784 782
785 INIT_LIST_HEAD(&local->interfaces); 783 INIT_LIST_HEAD(&local->interfaces);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c53d77db3e4f..9ab49826c15a 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -516,7 +516,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
516 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 516 sband = tx->local->hw.wiphy->bands[tx->channel->band];
517 517
518 len = min_t(int, tx->skb->len + FCS_LEN, 518 len = min_t(int, tx->skb->len + FCS_LEN,
519 tx->local->fragmentation_threshold); 519 tx->local->hw.wiphy->frag_threshold);
520 520
521 /* set up the tx rate control struct we give the RC algo */ 521 /* set up the tx rate control struct we give the RC algo */
522 txrc.hw = local_to_hw(tx->local); 522 txrc.hw = local_to_hw(tx->local);
@@ -527,8 +527,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
527 txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx; 527 txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx;
528 528
529 /* set up RTS protection if desired */ 529 /* set up RTS protection if desired */
530 if (tx->local->rts_threshold < IEEE80211_MAX_RTS_THRESHOLD && 530 if (len > tx->local->hw.wiphy->rts_threshold) {
531 len > tx->local->rts_threshold) {
532 txrc.rts = rts = true; 531 txrc.rts = rts = true;
533 } 532 }
534 533
@@ -770,7 +769,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
770 struct sk_buff *skb = tx->skb; 769 struct sk_buff *skb = tx->skb;
771 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 770 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
772 struct ieee80211_hdr *hdr = (void *)skb->data; 771 struct ieee80211_hdr *hdr = (void *)skb->data;
773 int frag_threshold = tx->local->fragmentation_threshold; 772 int frag_threshold = tx->local->hw.wiphy->frag_threshold;
774 int hdrlen; 773 int hdrlen;
775 int fragnum; 774 int fragnum;
776 775
@@ -1088,7 +1087,7 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
1088 1087
1089 if (tx->flags & IEEE80211_TX_FRAGMENTED) { 1088 if (tx->flags & IEEE80211_TX_FRAGMENTED) {
1090 if ((tx->flags & IEEE80211_TX_UNICAST) && 1089 if ((tx->flags & IEEE80211_TX_UNICAST) &&
1091 skb->len + FCS_LEN > local->fragmentation_threshold && 1090 skb->len + FCS_LEN > local->hw.wiphy->frag_threshold &&
1092 !(info->flags & IEEE80211_TX_CTL_AMPDU)) 1091 !(info->flags & IEEE80211_TX_CTL_AMPDU))
1093 tx->flags |= IEEE80211_TX_FRAGMENTED; 1092 tx->flags |= IEEE80211_TX_FRAGMENTED;
1094 else 1093 else
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 3dd490fa4b68..11244212f41d 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1044,7 +1044,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1044 1044
1045 /* setup RTS threshold */ 1045 /* setup RTS threshold */
1046 if (local->ops->set_rts_threshold) 1046 if (local->ops->set_rts_threshold)
1047 local->ops->set_rts_threshold(hw, local->rts_threshold); 1047 local->ops->set_rts_threshold(hw, hw->wiphy->rts_threshold);
1048 1048
1049 /* reconfigure hardware */ 1049 /* reconfigure hardware */
1050 ieee80211_hw_config(local, ~0); 1050 ieee80211_hw_config(local, ~0);
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index eb63fc148019..1eb6d8642a77 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -472,132 +472,6 @@ static int ieee80211_ioctl_giwtxpower(struct net_device *dev,
472 return 0; 472 return 0;
473} 473}
474 474
475static int ieee80211_ioctl_siwrts(struct net_device *dev,
476 struct iw_request_info *info,
477 struct iw_param *rts, char *extra)
478{
479 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
480
481 if (rts->disabled)
482 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
483 else if (!rts->fixed)
484 /* if the rts value is not fixed, then take default */
485 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
486 else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
487 return -EINVAL;
488 else
489 local->rts_threshold = rts->value;
490
491 /* If the wlan card performs RTS/CTS in hardware/firmware,
492 * configure it here */
493
494 if (local->ops->set_rts_threshold)
495 local->ops->set_rts_threshold(local_to_hw(local),
496 local->rts_threshold);
497
498 return 0;
499}
500
501static int ieee80211_ioctl_giwrts(struct net_device *dev,
502 struct iw_request_info *info,
503 struct iw_param *rts, char *extra)
504{
505 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
506
507 rts->value = local->rts_threshold;
508 rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD);
509 rts->fixed = 1;
510
511 return 0;
512}
513
514
515static int ieee80211_ioctl_siwfrag(struct net_device *dev,
516 struct iw_request_info *info,
517 struct iw_param *frag, char *extra)
518{
519 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
520
521 if (frag->disabled)
522 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
523 else if (!frag->fixed)
524 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
525 else if (frag->value < 256 ||
526 frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
527 return -EINVAL;
528 else {
529 /* Fragment length must be even, so strip LSB. */
530 local->fragmentation_threshold = frag->value & ~0x1;
531 }
532
533 return 0;
534}
535
536static int ieee80211_ioctl_giwfrag(struct net_device *dev,
537 struct iw_request_info *info,
538 struct iw_param *frag, char *extra)
539{
540 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
541
542 frag->value = local->fragmentation_threshold;
543 frag->disabled = (frag->value >= IEEE80211_MAX_FRAG_THRESHOLD);
544 frag->fixed = 1;
545
546 return 0;
547}
548
549
550static int ieee80211_ioctl_siwretry(struct net_device *dev,
551 struct iw_request_info *info,
552 struct iw_param *retry, char *extra)
553{
554 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
555
556 if (retry->disabled ||
557 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
558 return -EINVAL;
559
560 if (retry->flags & IW_RETRY_MAX) {
561 local->hw.conf.long_frame_max_tx_count = retry->value;
562 } else if (retry->flags & IW_RETRY_MIN) {
563 local->hw.conf.short_frame_max_tx_count = retry->value;
564 } else {
565 local->hw.conf.long_frame_max_tx_count = retry->value;
566 local->hw.conf.short_frame_max_tx_count = retry->value;
567 }
568
569 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
570
571 return 0;
572}
573
574
575static int ieee80211_ioctl_giwretry(struct net_device *dev,
576 struct iw_request_info *info,
577 struct iw_param *retry, char *extra)
578{
579 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
580
581 retry->disabled = 0;
582 if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) {
583 /* first return min value, iwconfig will ask max value
584 * later if needed */
585 retry->flags |= IW_RETRY_LIMIT;
586 retry->value = local->hw.conf.short_frame_max_tx_count;
587 if (local->hw.conf.long_frame_max_tx_count !=
588 local->hw.conf.short_frame_max_tx_count)
589 retry->flags |= IW_RETRY_MIN;
590 return 0;
591 }
592 if (retry->flags & IW_RETRY_MAX) {
593 retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
594 retry->value = local->hw.conf.long_frame_max_tx_count;
595 }
596
597 return 0;
598}
599
600
601static int ieee80211_ioctl_siwencode(struct net_device *dev, 475static int ieee80211_ioctl_siwencode(struct net_device *dev,
602 struct iw_request_info *info, 476 struct iw_request_info *info,
603 struct iw_point *erq, char *keybuf) 477 struct iw_point *erq, char *keybuf)
@@ -1050,14 +924,14 @@ static const iw_handler ieee80211_handler[] =
1050 (iw_handler) NULL, /* -- hole -- */ 924 (iw_handler) NULL, /* -- hole -- */
1051 (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */ 925 (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */
1052 (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */ 926 (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */
1053 (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */ 927 (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
1054 (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */ 928 (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
1055 (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */ 929 (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
1056 (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */ 930 (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
1057 (iw_handler) ieee80211_ioctl_siwtxpower, /* SIOCSIWTXPOW */ 931 (iw_handler) ieee80211_ioctl_siwtxpower, /* SIOCSIWTXPOW */
1058 (iw_handler) ieee80211_ioctl_giwtxpower, /* SIOCGIWTXPOW */ 932 (iw_handler) ieee80211_ioctl_giwtxpower, /* SIOCGIWTXPOW */
1059 (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */ 933 (iw_handler) cfg80211_wext_siwretry, /* SIOCSIWRETRY */
1060 (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */ 934 (iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */
1061 (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */ 935 (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */
1062 (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */ 936 (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */
1063 (iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */ 937 (iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */