From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Subject: [RFC 06/11] cfg80211: implement IWRATE
Date: Wed, 24 Jun 2009 14:07:51 +0200 [thread overview]
Message-ID: <20090624120809.431227350@sipsolutions.net> (raw)
In-Reply-To: 20090624120745.239294066@sipsolutions.net
For now, let's implement that using a very hackish way:
simply mirror the wext API in the cfg80211 API. This
will have to be changed later when we implement proper
bitrate API.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
include/net/cfg80211.h | 11 ++++++
net/mac80211/cfg.c | 73 +++++++++++++++++++++++++++++++++++++++++++
net/mac80211/wext.c | 76 +--------------------------------------------
net/wireless/wext-compat.c | 28 ++++++++++++++++
4 files changed, 114 insertions(+), 74 deletions(-)
--- wireless-testing.orig/include/net/cfg80211.h 2009-06-24 13:54:08.000000000 +0200
+++ wireless-testing/include/net/cfg80211.h 2009-06-24 13:54:08.000000000 +0200
@@ -1006,6 +1006,10 @@ struct cfg80211_ops {
/* some temporary stuff to finish wext */
int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
bool enabled, int timeout);
+ int (*set_bitrate)(struct wiphy *wiphy, struct net_device *dev,
+ struct iw_param *rate);
+ int (*get_bitrate)(struct wiphy *wiphy, struct net_device *dev,
+ struct iw_param *rate);
};
/*
@@ -1568,6 +1572,13 @@ int cfg80211_wext_giwauth(struct net_dev
struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
struct iw_freq *freq);
+int cfg80211_wext_siwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *rate, char *extra);
+int cfg80211_wext_giwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *rate, char *extra);
+
int cfg80211_wext_siwrts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *rts, char *extra);
--- wireless-testing.orig/net/mac80211/cfg.c 2009-06-24 13:54:08.000000000 +0200
+++ wireless-testing/net/mac80211/cfg.c 2009-06-24 13:54:08.000000000 +0200
@@ -1411,6 +1411,77 @@ static int ieee80211_set_power_mgmt(stru
return 0;
}
+static int ieee80211_set_bitrate(struct wiphy *wiphy,
+ struct net_device *dev,
+ struct iw_param *rate)
+{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+ int i, err = -EINVAL;
+ u32 target_rate = rate->value / 100000;
+ struct ieee80211_supported_band *sband;
+
+ sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+
+ /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
+ * target_rate = X, rate->fixed = 1 means only rate X
+ * target_rate = X, rate->fixed = 0 means all rates <= X */
+ sdata->max_ratectrl_rateidx = -1;
+ sdata->force_unicast_rateidx = -1;
+ if (rate->value < 0)
+ return 0;
+
+ for (i=0; i< sband->n_bitrates; i++) {
+ struct ieee80211_rate *brate = &sband->bitrates[i];
+ int this_rate = brate->bitrate;
+
+ if (target_rate == this_rate) {
+ sdata->max_ratectrl_rateidx = i;
+ if (rate->fixed)
+ sdata->force_unicast_rateidx = i;
+ err = 0;
+ break;
+ }
+ }
+
+ return err;
+}
+
+static int ieee80211_get_bitrate(struct wiphy *wiphy,
+ struct net_device *dev,
+ struct iw_param *rate)
+{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+ struct sta_info *sta;
+ struct ieee80211_supported_band *sband;
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ if (sdata->vif.type != NL80211_IFTYPE_STATION)
+ return -EOPNOTSUPP;
+
+ sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+
+ rcu_read_lock();
+
+ sta = sta_info_get(local, sdata->u.mgd.bssid);
+
+ if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
+ rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
+ else
+ rate->value = 0;
+
+ rcu_read_unlock();
+
+ if (!sta)
+ return -ENODEV;
+
+ rate->value *= 100000;
+
+ return 0;
+}
+
struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -1455,4 +1526,6 @@ struct cfg80211_ops mac80211_config_ops
.set_wds_peer = ieee80211_set_wds_peer,
.rfkill_poll = ieee80211_rfkill_poll,
.set_power_mgmt = ieee80211_set_power_mgmt,
+ .set_bitrate = ieee80211_set_bitrate,
+ .get_bitrate = ieee80211_get_bitrate,
};
--- wireless-testing.orig/net/mac80211/wext.c 2009-06-24 13:54:08.000000000 +0200
+++ wireless-testing/net/mac80211/wext.c 2009-06-24 13:54:08.000000000 +0200
@@ -168,78 +168,6 @@ static int ieee80211_ioctl_giwap(struct
}
-static int ieee80211_ioctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rate, char *extra)
-{
- struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
- int i, err = -EINVAL;
- u32 target_rate = rate->value / 100000;
- struct ieee80211_sub_if_data *sdata;
- struct ieee80211_supported_band *sband;
-
- sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-
- sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-
- /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
- * target_rate = X, rate->fixed = 1 means only rate X
- * target_rate = X, rate->fixed = 0 means all rates <= X */
- sdata->max_ratectrl_rateidx = -1;
- sdata->force_unicast_rateidx = -1;
- if (rate->value < 0)
- return 0;
-
- for (i=0; i< sband->n_bitrates; i++) {
- struct ieee80211_rate *brate = &sband->bitrates[i];
- int this_rate = brate->bitrate;
-
- if (target_rate == this_rate) {
- sdata->max_ratectrl_rateidx = i;
- if (rate->fixed)
- sdata->force_unicast_rateidx = i;
- err = 0;
- break;
- }
- }
- return err;
-}
-
-static int ieee80211_ioctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rate, char *extra)
-{
- struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
- struct sta_info *sta;
- struct ieee80211_sub_if_data *sdata;
- struct ieee80211_supported_band *sband;
-
- sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-
- if (sdata->vif.type != NL80211_IFTYPE_STATION)
- return -EOPNOTSUPP;
-
- sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-
- rcu_read_lock();
-
- sta = sta_info_get(local, sdata->u.mgd.bssid);
-
- if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
- rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
- else
- rate->value = 0;
-
- rcu_read_unlock();
-
- if (!sta)
- return -ENODEV;
-
- rate->value *= 100000;
-
- return 0;
-}
-
/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
{
@@ -343,8 +271,8 @@ static const iw_handler ieee80211_handle
(iw_handler) NULL, /* SIOCGIWNICKN */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */
- (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */
- (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */
+ (iw_handler) cfg80211_wext_siwrate, /* SIOCSIWRATE */
+ (iw_handler) cfg80211_wext_giwrate, /* SIOCGIWRATE */
(iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
(iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
(iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
--- wireless-testing.orig/net/wireless/wext-compat.c 2009-06-24 13:54:08.000000000 +0200
+++ wireless-testing/net/wireless/wext-compat.c 2009-06-24 13:54:08.000000000 +0200
@@ -954,3 +954,31 @@ int cfg80211_wds_wext_giwap(struct net_d
return 0;
}
EXPORT_SYMBOL_GPL(cfg80211_wds_wext_giwap);
+
+int cfg80211_wext_siwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *rate, char *extra)
+{
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+
+ if (!rdev->ops->set_bitrate)
+ return -EOPNOTSUPP;
+
+ return rdev->ops->set_bitrate(wdev->wiphy, dev, rate);
+}
+EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate);
+
+int cfg80211_wext_giwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *rate, char *extra)
+{
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+
+ if (!rdev->ops->get_bitrate)
+ return -EOPNOTSUPP;
+
+ return rdev->ops->get_bitrate(wdev->wiphy, dev, rate);
+}
+EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate);
--
next prev parent reply other threads:[~2009-06-24 12:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 12:07 [RFC 00/11] cfg80211 connect API + wireless extension move Johannes Berg
2009-06-24 12:07 ` [RFC 01/11] cfg80211: connect/disconnect API Johannes Berg
2009-06-24 15:30 ` Samuel Ortiz
2009-06-24 12:07 ` [RFC 02/11] cfg80211: emulate connect with auth/assoc Johannes Berg
2009-06-24 12:07 ` [RFC 03/11] cfg80211: managed mode wext compatibility Johannes Berg
2009-06-24 12:07 ` [RFC 04/11] cfg80211: implement iwpower Johannes Berg
2009-06-24 12:07 ` [RFC 05/11] cfg80211: implement IWAP for WDS Johannes Berg
2009-06-24 12:07 ` Johannes Berg [this message]
2009-06-24 12:07 ` [RFC 07/11] cfg80211: implement get_wireless_stats Johannes Berg
2009-06-24 12:07 ` [RFC 08/11] cfg80211: combine iwfreq implementations Johannes Berg
2009-06-24 12:07 ` [RFC 09/11] cfg80211: combine IWAP handlers Johannes Berg
2009-06-24 12:07 ` [RFC 10/11] cfg80211: combine IWESSID handlers Johannes Berg
2009-06-24 12:07 ` [RFC 11/11] cfg80211: self-contained wext handling Johannes Berg
2009-06-24 20:24 ` [RFC 00/11] cfg80211 connect API + wireless extension move Luis R. Rodriguez
2009-06-25 20:37 ` Dave
2009-06-26 20:18 ` Johannes Berg
2009-06-28 9:26 ` Dave
2009-06-29 8:35 ` Johannes Berg
2009-06-26 21:01 ` Johannes Berg
2009-06-28 8:43 ` Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090624120809.431227350@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).