2007-05-02 14:28:24

by Larry Finger

[permalink] [raw]
Subject: [PATCH] mac80211: Add support for SIOCGIWRATE ioctl to provide rate information

At present, transmission rate information for mac80211 is available only
if verbose debugging is turned on, and then only in the logs. This patch
implements the SIOCGIWRATE ioctl, which adds the current transmission rate to
the output of iwconfig.

Signed-off-by: Larry Finger <[email protected]>
---

Index: wireless-dev/net/mac80211/ieee80211_ioctl.c
===================================================================
--- wireless-dev.orig/net/mac80211/ieee80211_ioctl.c
+++ wireless-dev/net/mac80211/ieee80211_ioctl.c
@@ -2064,6 +2064,22 @@ static int ieee80211_ioctl_giwscan(struc
}


+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;
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ sta = sta_info_get(local, sdata->u.sta.bssid);
+ if (!sta)
+ return -ENODEV;
+ rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000;
+ return 0;
+}
+
static int ieee80211_ioctl_siwrts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *rts, char *extra)
@@ -3247,7 +3263,7 @@ static const iw_handler ieee80211_handle
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWRATE */
- (iw_handler) NULL, /* SIOCGIWRATE */
+ (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */
(iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */
(iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */
(iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */


2007-05-02 14:31:52

by Michael Wu

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add support for SIOCGIWRATE ioctl to provide rate information

On Wednesday 02 May 2007 10:28, Larry Finger wrote:
> +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;
> +
> + sdata = IEEE80211_DEV_TO_SUB_IF(dev);
> + sta = sta_info_get(local, sdata->u.sta.bssid);
> + if (!sta)
> + return -ENODEV;
> + rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000;
> + return 0;
> +}
> +
Memory leak. You need a sta_info_put.

-Michael Wu


Attachments:
(No filename) (618.00 B)
(No filename) (189.00 B)
Download all attachments