Skip to contentSkip to conversation

d80211: use sysfs instead of procfs

PATCH In review Jiri Benc 2 participants 15 messages Jun 8, 2006 – Jun 12, 2006

Subsystems (2)
lore
Share & tools
lore

Jiri Benc

author
#0 lore raw

cover d80211: use sysfs instead of procfs

The following series of patches makes d80211 to use sysfs instead of procfs. This means that custom reference counting in most structures is replaced by kobjects and nearly all informations from procfs files are converted to sysfs attributes.

The only information missing in sysfs (compared to procfs) is channels and rates info. Implementing this in a sysfs way (i. e. one information per attribute rule) requires a lot of code and (more important) adding kobjects to channel and rate structures. I doubt these informations are really so useful to be worth such complications. If there are good arguments why these informations should be exported via sysfs I will add them.

If you find a better name for some object (directory) or attribute (file) or just consider some name wrong or ugly, let me know please.

The third patch ("separate allocation of ieee80211_local") touches the code outside of net/d80211 - it adds ieee80211_ptr to net_device structure.

All of patches can be also obtained from 'master' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jbenc/dscape.git

---

Jiri Benc:
d80211: deinit sysfs in case of an error
d80211: better sysfs registration of symlinks to wiphy
d80211: separate allocation of ieee80211_local
d80211: fix Oops when writing to add_ and remove_iface
d80211: wiphy sysfs attributes
d80211: network interface sysfs attributes
d80211: rename sta_info_relase to sta_info_put
d80211: sysfs attributes for associated stations
d80211: remove useless parameters
d80211: rate_control sysfs attributes
d80211: encryption keys sysfs attributes
d80211: remove procfs files

 include/linux/netdevice.h        |    1 
 net/d80211/Makefile              |    2 
 net/d80211/ieee80211.c           |  206 +++++++---
 net/d80211/ieee80211_dev.c       |   17 +
 net/d80211/ieee80211_i.h         |   45 ++
 net/d80211/ieee80211_iface.c     |   43 +-
 net/d80211/ieee80211_ioctl.c     |  213 ++++++----
 net/d80211/ieee80211_key.h       |    2 
 net/d80211/ieee80211_proc.c      |  771 --------------------------------------
 net/d80211/ieee80211_proc.h      |   45 --
 net/d80211/ieee80211_scan.c      |   10 
 net/d80211/ieee80211_sta.c       |   68 ++-
 net/d80211/ieee80211_sysfs.c     |  706 +++++++++++++++++++++++++++++++++--
 net/d80211/ieee80211_sysfs_sta.c |  434 +++++++++++++++++++++
 net/d80211/rate_control.c        |   55 ++-
 net/d80211/rate_control.h        |   57 ++-
 net/d80211/sta_info.c            |  132 ++++---
 net/d80211/sta_info.h            |   16 -
 net/d80211/wme.c                 |   26 +
 19 files changed, 1663 insertions(+), 1186 deletions(-)
Signature · 2 lines
Jiri Benc
SUSE Labs
author
#1 lore raw

PATCH 1/12 d80211: deinit sysfs in case of an error

When ieee80211_wme_register fails in ieee80211_init, ieee80211 class was not unregistered.

---

 net/d80211/ieee80211.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

3aed246a5117bd4d1a4f2d5f5074c583d9b4941e

net/d80211/ieee80211.c +1 -0
index b850fb7..f549098 100644
@@ -4462,6 +4462,7 @@ static int __init ieee80211_init(void)
 		if (ret) {
 			printk(KERN_DEBUG "ieee80211_init: failed to "
 			       "initialize WME (err=%d)\n", ret);
+			ieee80211_sysfs_deinit();
 			ieee80211_proc_deinit();
 			return ret;
 		}
Signature · 1 line
1.3.0
author
#2 lore raw

PATCH 2/12 d80211: better sysfs registration of symlinks to wiphy

In reply to Jiri Benc

Lately, delayed sysfs registration of net_device (in netdev_run_todo) was removed. This allows us to remove hack that used class interface for sysfs registration.

---

 net/d80211/ieee80211.c       |   18 +++++++++++++++--
 net/d80211/ieee80211_i.h     |    2 ++
 net/d80211/ieee80211_iface.c |   15 ++++++++++++++
 net/d80211/ieee80211_sysfs.c |   45 ++++++------------------------------------
 4 files changed, 39 insertions(+), 41 deletions(-)

beb1533d9181d1c6d195de5743517b3559bfd9f9

net/d80211/ieee80211.c +16 -2
index f549098..9724a49 100644
@@ -4197,9 +4197,21 @@ int ieee80211_register_hw(struct net_dev
 
 	if (hw->fraglist)
 		dev->features |= NETIF_F_FRAGLIST;
-	result = register_netdev(dev);
-	if (result < 0)
+	rtnl_lock();
+	result = dev_alloc_name(dev, dev->name);
+	if (result < 0) {
+		rtnl_unlock();
+		goto fail_dev;
+	}
+	result = register_netdevice(dev);
+	if (result < 0) {
+		rtnl_unlock();
 		goto fail_dev;
+	}
+	result = ieee80211_sysfs_add_netdevice(dev);
+	rtnl_unlock();
+	if (result < 0)
+		goto fail_if_sysfs;
 
 	if (rate_control_initialize(local) < 0) {
 		printk(KERN_DEBUG "%s: Failed to initialize rate control "
@@ -4223,6 +4235,8 @@ int ieee80211_register_hw(struct net_dev
 	return 0;
 
 fail_rate:
+	ieee80211_sysfs_remove_netdevice(dev);
+fail_if_sysfs:
 	unregister_netdev(dev);
 fail_dev:
 	sta_info_stop(local);
net/d80211/ieee80211_i.h +2 -0
index 94e151d..19d9d98 100644
@@ -599,6 +599,8 @@ int ieee80211_if_add_mgmt(struct net_dev
 void ieee80211_if_del_mgmt(struct net_device *dev);
 
 /* ieee80211_sysfs.c */
+int ieee80211_sysfs_add_netdevice(struct net_device *dev);
+void ieee80211_sysfs_remove_netdevice(struct net_device *dev);
 int ieee80211_register_sysfs(struct ieee80211_local *local);
 void ieee80211_unregister_sysfs(struct ieee80211_local *local);
 int ieee80211_sysfs_init(void);
net/d80211/ieee80211_iface.c +15 -0
index 6631738..d534fe4 100644
@@ -76,6 +76,13 @@ int ieee80211_if_add(struct net_device *
 	ret = register_netdevice(ndev);
 	if (ret)
 		goto fail;
+	ret = ieee80211_sysfs_add_netdevice(ndev);
+	if (ret) {
+		/* ndev will be freed by ndev->destructor */
+		unregister_netdevice(ndev);
+		*new_dev = NULL;
+		return ret;
+	}
 
 	list_add(&sdata->list, &local->sub_if_list);
 	ieee80211_proc_init_virtual(ndev);
@@ -123,10 +130,16 @@ int ieee80211_if_add_mgmt(struct net_dev
 	ret = register_netdevice(ndev);
 	if (ret)
 		goto fail;
+	ret = ieee80211_sysfs_add_netdevice(ndev);
+	if (ret)
+		goto fail_sysfs;
 	if (local->open_count > 0)
 		dev_open(ndev);
 	local->apdev = ndev;
 	return 0;
+
+fail_sysfs:
+	unregister_netdevice(ndev);
 fail:
 	free_netdev(ndev);
 	return ret;
@@ -139,6 +152,7 @@ void ieee80211_if_del_mgmt(struct net_de
 
 	ASSERT_RTNL();
 	apdev = local->apdev;
+	ieee80211_sysfs_remove_netdevice(apdev);
 	local->apdev = NULL;
 	unregister_netdevice(apdev);
 }
@@ -293,6 +307,7 @@ void __ieee80211_if_del(struct ieee80211
 	ieee80211_if_reinit(dev);
 	list_del(&sdata->list);
 	ieee80211_proc_deinit_virtual(dev);
+	ieee80211_sysfs_remove_netdevice(dev);
 	unregister_netdevice(dev);
 	/* Except master interface, the net_device will be freed by
 	 * net_device->destructor (i. e. ieee80211_if_free). */
net/d80211/ieee80211_sysfs.c +6 -39

66 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#3 lore raw

PATCH 3/12 d80211: separate allocation of ieee80211_local

In reply to Jiri Benc

ieee80211_local has a separate class_device. That means it has reference counting independent of master net_device and can be freed at a different time, therefore these two structures cannot be allocated together.

Solve this by adding ieee80211_ptr pointer to net_device structure (similar to other pointers already presented there) and using it as a pointer to independently allocated ieee80211_local.

This also allows is_ieee80211_device function to be nice finally.

---

 include/linux/netdevice.h    |    1 
 net/d80211/ieee80211.c       |  100 +++++++++++++++++++++---------------------
 net/d80211/ieee80211_dev.c   |   17 +++++++
 net/d80211/ieee80211_i.h     |    9 +++-
 net/d80211/ieee80211_iface.c |   20 ++++----
 net/d80211/ieee80211_ioctl.c |   92 +++++++++++++++++++--------------------
 net/d80211/ieee80211_proc.c  |    6 +--
 net/d80211/ieee80211_scan.c  |   10 ++--
 net/d80211/ieee80211_sta.c   |   58 ++++++++++++------------
 net/d80211/ieee80211_sysfs.c |   26 ++++++++---
 net/d80211/rate_control.c    |    4 +-
 net/d80211/rate_control.h    |    4 +-
 net/d80211/wme.c             |   26 +++++------
 13 files changed, 206 insertions(+), 167 deletions(-)

3085d33e38881f0987329c4258514f60ffe824af

include/linux/netdevice.h +1 -0
index f4169bb..037e63a 100644
@@ -371,6 +371,7 @@ #define NETIF_F_UFO             8192    
 	void                    *ip6_ptr;       /* IPv6 specific data */
 	void			*ec_ptr;	/* Econet specific data	*/
 	void			*ax25_ptr;	/* AX.25 specific data */
+	void			*ieee80211_ptr;	/* IEEE 802.11 specific data */
 
 /*
  * Cache line mostly used on receive path (including eth_type_trans())
net/d80211/ieee80211.c +51 -49

337 lines not on this page · raw message

net/d80211/ieee80211_dev.c +17 -0
index 6278cfa..6c6ca91 100644
@@ -99,3 +99,20 @@ int ieee80211_dev_find_index(struct ieee
 	spin_unlock(&dev_list_lock);
 	return index;
 }
+
+struct ieee80211_local *ieee80211_dev_alloc(gfp_t flags)
+{
+	struct ieee80211_local *local;
+
+	local = kzalloc(sizeof(struct ieee80211_local), flags);
+	if (!local)
+		return NULL;
+	local->dev_index = -1;
+	ieee80211_dev_sysfs_init(local);
+	return local;
+}
+
+void ieee80211_dev_free(struct ieee80211_local *local)
+{
+	ieee80211_dev_sysfs_put(local);
+}
net/d80211/ieee80211_i.h +7 -2
index 19d9d98..84cc50e 100644
@@ -505,6 +505,7 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 
 
 /* ieee80211.c */
+void ieee80211_release_hw(struct ieee80211_local *local);
 int ieee80211_hw_config(struct net_device *dev);
 int ieee80211_if_config(struct net_device *dev);
 struct ieee80211_key_conf *
@@ -582,6 +583,8 @@ int ieee80211_dev_alloc_index(struct iee
 void ieee80211_dev_free_index(struct ieee80211_local *local);
 struct ieee80211_local *ieee80211_dev_find(int index);
 int ieee80211_dev_find_index(struct ieee80211_local *local);
+struct ieee80211_local *ieee80211_dev_alloc(gfp_t flags);
+void ieee80211_dev_free(struct ieee80211_local *local);
 
 /* ieee80211_iface.c */
 int ieee80211_if_add(struct net_device *dev, const char *name,
@@ -601,8 +604,10 @@ void ieee80211_if_del_mgmt(struct net_de
 /* ieee80211_sysfs.c */
 int ieee80211_sysfs_add_netdevice(struct net_device *dev);
 void ieee80211_sysfs_remove_netdevice(struct net_device *dev);
-int ieee80211_register_sysfs(struct ieee80211_local *local);
-void ieee80211_unregister_sysfs(struct ieee80211_local *local);
+void ieee80211_dev_sysfs_init(struct ieee80211_local *local);
+void ieee80211_dev_sysfs_put(struct ieee80211_local *local);
+int ieee80211_dev_sysfs_add(struct ieee80211_local *local);
+void ieee80211_dev_sysfs_del(struct ieee80211_local *local);
 int ieee80211_sysfs_init(void);
 void ieee80211_sysfs_deinit(void);
 
net/d80211/ieee80211_iface.c +10 -10
index d534fe4..8ab2c07 100644
@@ -29,7 +29,7 @@ int ieee80211_if_add(struct net_device *
 		     int format, struct net_device **new_dev)
 {
 	struct net_device *ndev, *tmp_dev;
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata = NULL, *sdata_parent;
 	int ret;
 	int i;
@@ -40,7 +40,7 @@ int ieee80211_if_add(struct net_device *
 	if (ndev == NULL)
 		return -ENOMEM;
 
-	ndev->priv = local;
+	ndev->ieee80211_ptr = local;
 	if (strlen(name) == 0) {
 		i = 0;
 		do {
@@ -98,7 +98,7 @@ fail:
 int ieee80211_if_add_mgmt(struct net_device *dev)
 {
 	struct net_device *ndev;
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata, *nsdata;
 	int ret;
 
@@ -113,7 +113,7 @@ int ieee80211_if_add_mgmt(struct net_dev
 	if (ret)
 		goto fail;
 
-	ndev->priv = local;
+	ndev->ieee80211_ptr = local;
 	memcpy(ndev->dev_addr, dev->dev_addr, ETH_ALEN);
 	ndev->base_addr = dev->base_addr;
 	ndev->irq = dev->irq;
@@ -147,7 +147,7 @@ fail:
 
 void ieee80211_if_del_mgmt(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct net_device *apdev;
 
 	ASSERT_RTNL();
@@ -207,7 +207,7 @@ void ieee80211_if_set_type(struct net_de
 /* Must be called with rtnl lock held. */
 void ieee80211_if_reinit(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct sta_info *sta;
 	int i;
@@ -316,7 +316,7 @@ void __ieee80211_if_del(struct ieee80211
 /* Must be called with rtnl lock held. */
 int ieee80211_if_remove(struct net_device *dev, const char *name, int id)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata, *n;
 
 	ASSERT_RTNL();
@@ -337,7 +337,7 @@ int ieee80211_if_remove(struct net_devic
 
 void ieee80211_if_free(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 
 	BUG_ON(dev == local->mdev || dev == local->apdev);
 	free_netdev(dev);
@@ -346,7 +346,7 @@ void ieee80211_if_free(struct net_device
 /* Must be called with rtnl lock held. */
 void ieee80211_if_flush(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata, *n;
 
 	ASSERT_RTNL();
@@ -357,7 +357,7 @@ void ieee80211_if_flush(struct net_devic
 
 void ieee80211_if_del(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
 	rtnl_lock();
net/d80211/ieee80211_ioctl.c +46 -46

368 lines not on this page · raw message

net/d80211/ieee80211_proc.c +3 -3
index c9f5567..4f3a6b9 100644
@@ -269,7 +269,7 @@ static int ieee80211_proc_sta_read(char 
 		     sta->tx_fragments, sta->tx_filtered_count);
 	p = ieee80211_proc_key(p, sta->key, 0, 1);
 
-	local = (struct ieee80211_local *) sta->dev->priv;
+	local = (struct ieee80211_local *) sta->dev->ieee80211_ptr;
 	if (sta->txrate >= 0 && sta->txrate < local->num_curr_rates) {
 		p += sprintf(p, "txrate=%d\n",
 			     local->curr_rates[sta->txrate].rate);
@@ -676,7 +676,7 @@ void ieee80211_proc_deinit_sta(struct ie
 void ieee80211_proc_init_virtual(struct net_device *dev)
 {
 	struct proc_dir_entry *entry;
-	struct ieee80211_local *local = (struct ieee80211_local *) dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 
 	if (!local->proc_iface)
 		return;
@@ -690,7 +690,7 @@ void ieee80211_proc_init_virtual(struct 
 
 void ieee80211_proc_deinit_virtual(struct net_device *dev)
 {
-	struct ieee80211_local *local = (struct ieee80211_local *) dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 
 	if (local->proc_iface)
 		remove_proc_entry(dev->name, local->proc_iface);
net/d80211/ieee80211_scan.c +5 -5
index 9984fd6..4184abf 100644
@@ -110,7 +110,7 @@ static void next_chan_all_modes(struct i
 static void ieee80211_scan_start(struct net_device *dev,
 				 struct ieee80211_scan_conf *conf)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	int old_mode_idx = local->scan.mode_idx;
 	int old_chan_idx = local->scan.chan_idx;
 	struct ieee80211_hw_modes *mode = NULL;
@@ -209,7 +209,7 @@ #endif
 static void ieee80211_scan_stop(struct net_device *dev,
 				struct ieee80211_scan_conf *conf)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_hw_modes *mode;
 	struct ieee80211_channel *chan;
 	int wait;
@@ -258,7 +258,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 static void ieee80211_scan_handler(unsigned long uldev)
 {
         struct net_device *dev = (struct net_device *) uldev;
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_scan_conf conf;
 
 	if (local->scan.interval == 0 && !local->scan.in_scan) {
@@ -286,7 +286,7 @@ static void ieee80211_scan_handler(unsig
 
 void ieee80211_init_scan(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_hdr hdr;
 	u16 fc;
 	int len = 10;
@@ -342,7 +342,7 @@ void ieee80211_init_scan(struct net_devi
 
 void ieee80211_stop_scan(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 
 	if (local->hw->passive_scan != 0) {
 		del_timer_sync(&local->scan.timer);
net/d80211/ieee80211_sta.c +29 -29

232 lines not on this page · raw message

net/d80211/ieee80211_sysfs.c +20 -6
index 5c7af9f..fb95e96 100644
@@ -53,6 +53,11 @@ static ssize_t store_remove_iface(struct
 	return res < 0 ? res : len;
 }
 
+static void ieee80211_class_dev_release(struct class_device *dev)
+{
+	ieee80211_release_hw(to_ieee80211_local(dev));
+}
+
 #ifdef CONFIG_HOTPLUG
 static int ieee80211_uevent(struct class_device *cd, char **envp,
 			    int num_envp, char *buf, int size)
@@ -79,28 +84,39 @@ static struct class_device_attribute iee
 static struct class ieee80211_class = {
 	.name = "ieee80211",
 	.class_dev_attrs = ieee80211_class_dev_attrs,
+	.release = ieee80211_class_dev_release,
 #ifdef CONFIG_HOTPLUG
 	.uevent = ieee80211_uevent,
 #endif
 };
 
-int ieee80211_register_sysfs(struct ieee80211_local *local)
+void ieee80211_dev_sysfs_init(struct ieee80211_local *local)
 {
 	local->class_dev.class = &ieee80211_class;
 	local->class_dev.class_data = local;
+	class_device_initialize(&local->class_dev);
+}
+
+void ieee80211_dev_sysfs_put(struct ieee80211_local *local)
+{
+	class_device_put(&local->class_dev);
+}
+
+int ieee80211_dev_sysfs_add(struct ieee80211_local *local)
+{
 	snprintf(local->class_dev.class_id, BUS_ID_SIZE,
 		 "phy%d", local->dev_index);
-	return class_device_register(&local->class_dev);
+	return class_device_add(&local->class_dev);
 }
 
-void ieee80211_unregister_sysfs(struct ieee80211_local *local)
+void ieee80211_dev_sysfs_del(struct ieee80211_local *local)
 {
 	class_device_del(&local->class_dev);
 }
 
 int ieee80211_sysfs_add_netdevice(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 
 	return sysfs_create_link(&dev->class_dev.kobj, &local->class_dev.kobj,
 				 "wiphy");
@@ -108,8 +124,6 @@ int ieee80211_sysfs_add_netdevice(struct
 
 void ieee80211_sysfs_remove_netdevice(struct net_device *dev)
 {
-	struct ieee80211_local *local = dev->priv;
-
 	sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
 }
 
net/d80211/rate_control.c +2 -2
index 429ef2b..3485302 100644
@@ -126,7 +126,7 @@ static void rate_control_simple_tx_statu
 					  struct sk_buff *skb,
 					  struct ieee80211_tx_status *status)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	struct sta_info *sta;
 	struct sta_rate_control *srctrl;
@@ -217,7 +217,7 @@ static struct ieee80211_rate *
 rate_control_simple_get_rate(struct net_device *dev, struct sk_buff *skb,
 			     struct rate_control_extra *extra)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	struct sta_info *sta;
net/d80211/rate_control.h +2 -2
index 26d3c0f..b509539 100644
@@ -64,7 +64,7 @@ static inline void rate_control_tx_statu
 					  struct sk_buff *skb,
 					  struct ieee80211_tx_status *status)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	local->rate_ctrl->tx_status(dev, skb, status);
 }
 
@@ -73,7 +73,7 @@ static inline struct ieee80211_rate *
 rate_control_get_rate(struct net_device *dev, struct sk_buff *skb,
 		      struct rate_control_extra *extra)
 {
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	return local->rate_ctrl->get_rate(dev, skb, extra);
 }
 
net/d80211/wme.c +13 -13
index f20d3e0..138f892 100644
@@ -175,7 +175,7 @@ static inline int wme_downgrade_ac(struc
  * negative return value indicates to drop the frame */
 static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
 {
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_tx_packet_data *pkt_data =
 		(struct ieee80211_tx_packet_data *) skb->cb;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -227,7 +227,7 @@ static inline int classify80211(struct s
 
 static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
 {
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
 	struct ieee80211_tx_packet_data *pkt_data =
 		(struct ieee80211_tx_packet_data *) skb->cb;
@@ -314,7 +314,7 @@ static struct sk_buff *wme_qdiscop_deque
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
 	struct net_device *dev = qd->dev;
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	struct ieee80211_tx_queue_stats stats;
 	struct sk_buff *skb;
@@ -351,7 +351,7 @@ static struct sk_buff *wme_qdiscop_deque
 static void wme_qdiscop_reset(struct Qdisc* qd)
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	int queue;
 
@@ -368,7 +368,7 @@ static void wme_qdiscop_reset(struct Qdi
 static void wme_qdiscop_destroy(struct Qdisc* qd)
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	struct tcf_proto *tp;
 	int queue;
@@ -409,7 +409,7 @@ static int wme_qdiscop_init(struct Qdisc
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
 	struct net_device *dev = qd->dev;
-	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_local *local = dev->ieee80211_ptr;
 	int queues = local->hw->queues;
 	int err = 0, i;
 
@@ -464,7 +464,7 @@ static int wme_classop_graft(struct Qdis
 			     struct Qdisc *new, struct Qdisc **old)
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	unsigned long queue = arg - 1;
 
@@ -488,7 +488,7 @@ static struct Qdisc *
 wme_classop_leaf(struct Qdisc *qd, unsigned long arg)
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	unsigned long queue = arg - 1;
 
@@ -501,7 +501,7 @@ wme_classop_leaf(struct Qdisc *qd, unsig
 
 static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid)
 {
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	unsigned long queue = TC_H_MIN(classid);
 
@@ -529,7 +529,7 @@ static int wme_classop_change(struct Qdi
 			      struct rtattr **tca, unsigned long *arg)
 {
 	unsigned long cl = *arg;
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	/* printk(KERN_DEBUG "entering %s\n", __func__); */
 
@@ -547,7 +547,7 @@ static int wme_classop_change(struct Qdi
  * when we add WMM-SA support - TSPECs may be deleted here */
 static int wme_classop_delete(struct Qdisc *qd, unsigned long cl)
 {
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	/* printk(KERN_DEBUG "entering %s\n", __func__); */
 
@@ -561,7 +561,7 @@ static int wme_classop_dump_class(struct
 				  struct sk_buff *skb, struct tcmsg *tcm)
 {
 	struct ieee80211_sched_data *q = qdisc_priv(qd);
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	/* printk(KERN_DEBUG "entering %s\n", __func__); */
 
@@ -576,7 +576,7 @@ static int wme_classop_dump_class(struct
 
 static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg)
 {
-	struct ieee80211_local *local = qd->dev->priv;
+	struct ieee80211_local *local = qd->dev->ieee80211_ptr;
 	struct ieee80211_hw *hw = local->hw;
 	int queue;
 	/* printk(KERN_DEBUG "entering %s\n", __func__); */
Signature · 1 line
1.3.0
author
#4 lore raw

Re: [PATCH 3/12] d80211: separate allocation of ieee80211_local

Quoted 7 lines · Jiri Benc

ieee80211_local has a separate class_device. That means it has reference counting independent of master net_device and can be freed at a different time, therefore these two structures cannot be allocated together.

Solve this by adding ieee80211_ptr pointer to net_device structure (similar to other pointers already presented there) and using it as a pointer to independently allocated ieee80211_local.

I suppose approval from Dave will be needed for adding that pointer to net_device, right?

Quoted 20 lines

[...]

 include/linux/netdevice.h    |    1 
 net/d80211/ieee80211.c       |  100 +++++++++++++++++++++---------------------
 net/d80211/ieee80211_dev.c   |   17 +++++++
 net/d80211/ieee80211_i.h     |    9 +++-
 net/d80211/ieee80211_iface.c |   20 ++++----
 net/d80211/ieee80211_ioctl.c |   92 +++++++++++++++++++--------------------
 net/d80211/ieee80211_proc.c  |    6 +--
 net/d80211/ieee80211_scan.c  |   10 ++--
 net/d80211/ieee80211_sta.c   |   58 ++++++++++++------------
 net/d80211/ieee80211_sysfs.c |   26 ++++++++---
 net/d80211/rate_control.c    |    4 +-
 net/d80211/rate_control.h    |    4 +-
 net/d80211/wme.c             |   26 +++++------
 13 files changed, 206 insertions(+), 167 deletions(-)

[...]

include/linux/netdevice.h #define NETIF_F_UFO 8192 · line 377

Quoted 8 lines
include/linux/netdevice.h +1 -0
@@ -371,6 +371,7 @@ #define NETIF_F_UFO             8192    
 	void                    *ip6_ptr;       /* IPv6 specific data */
 	void			*ec_ptr;	/* Econet specific data	*/
 	void			*ax25_ptr;	/* AX.25 specific data */
+	void			*ieee80211_ptr;	/* IEEE 802.11 specific data */
 
 /*
  * Cache line mostly used on receive path (including eth_type_trans())
[...]

Thanks,

Signature · 2 lines
Jiri Benc
SUSE Labs
#5 lore raw

Re: [PATCH 3/12] d80211: separate allocation of ieee80211_local

Quoted 11 lines · Jiri Benc
Quoted 7 lines · Jiri Benc

ieee80211_local has a separate class_device. That means it has reference counting independent of master net_device and can be freed at a different time, therefore these two structures cannot be allocated together.

Solve this by adding ieee80211_ptr pointer to net_device structure (similar to other pointers already presented there) and using it as a pointer to independently allocated ieee80211_local.

I suppose approval from Dave will be needed for adding that pointer to net_device, right?

Ulitmately, yes. :-)

John

Signature · 2 lines
John W. Linville
[email protected]
author
#6 lore raw

PATCH 4/12 d80211: fix Oops when writing to add_ and remove_iface

In reply to Jiri Benc

When add_iface or remove_iface sysfs attribute is opened just before device is unregistered and some data is written there afterwards, their handlers try to access master net_device which is released at that point.

A similar problem can happen when ioctl is invoked during unregistering - it is possible that interface the ioctl was called on is still there but master interface has been already freed.

Fix these problems by:
- checking if the device is unregistered in sysfs handlers and
- releasing all interfaces under single rtnl lock.

---

 net/d80211/ieee80211.c       |    9 +++++++--
 net/d80211/ieee80211_i.h     |    6 ++++++
 net/d80211/ieee80211_sysfs.c |   17 +++++++++++++++--
 3 files changed, 28 insertions(+), 4 deletions(-)

25dd82745a86401267b9954098b99ba4a60a71f6

net/d80211/ieee80211.c +7 -2
index 4fc2e7d..c983d70 100644
@@ -4225,6 +4225,8 @@ int ieee80211_register_hw(struct net_dev
 	result = ieee80211_if_add(dev, "wlan%d", 1, &sta_dev);
 	if (result == 0)
 		ieee80211_if_set_type(sta_dev, IEEE80211_IF_TYPE_STA);
+
+	local->reg_state = IEEE80211_DEV_REGISTERED;
 	rtnl_unlock();
 
 	return 0;
@@ -4290,14 +4292,17 @@ void ieee80211_unregister_hw(struct net_
 		del_timer_sync(&local->scan_timer);
 	ieee80211_rx_bss_list_deinit(dev);
 
+	rtnl_lock();
+	local->reg_state = IEEE80211_DEV_UNREGISTERED;
 	if (local->apdev)
-		ieee80211_if_del(local->apdev);
+		ieee80211_if_del_mgmt(local->apdev);
 
 	list_for_each_safe(ptr, n, &local->sub_if_list) {
 		struct ieee80211_sub_if_data *sdata =
 			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		ieee80211_if_del(sdata->dev);
+		__ieee80211_if_del(local, sdata);
 	}
+	rtnl_unlock();
 
 	sta_info_stop(local);
 	ieee80211_dev_sysfs_del(local);
net/d80211/ieee80211_i.h +6 -0
index 84cc50e..9fabf17 100644
@@ -321,6 +321,12 @@ struct ieee80211_local {
 	int dev_index;
 	struct class_device class_dev;
 
+	enum {
+		IEEE80211_DEV_UNITIALIZED = 0,
+		IEEE80211_DEV_REGISTERED,
+		IEEE80211_DEV_UNREGISTERED,
+	} reg_state;
+
 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
 	 * added to skb_queue will be processed, but frames in
 	 * skb_queue_unreliable may be dropped if the total length of these
net/d80211/ieee80211_sysfs.c +15 -2
index fb95e96..e799506 100644
@@ -17,6 +17,15 @@ #include "ieee80211_i.h"
 
 #define to_ieee80211_local(class)	container_of(class, struct ieee80211_local, class_dev)
 
+static inline int rtnl_lock_local(struct ieee80211_local *local)
+{
+	rtnl_lock();
+	if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
+		rtnl_unlock();
+		return -ENODEV;
+	}
+	return 0;
+}
 
 static ssize_t store_add_iface(struct class_device *dev,
 			       const char *buf, size_t len)
@@ -29,7 +38,9 @@ static ssize_t store_add_iface(struct cl
 		return -EPERM;
 	if (len > IFNAMSIZ)
 		return -EINVAL;
-	rtnl_lock();
+	res = rtnl_lock_local(local);
+	if (res)
+		return res;
 	res = ieee80211_if_add(local->mdev, buf, 0, &new_dev);
 	if (res == 0)
 		ieee80211_if_set_type(new_dev, IEEE80211_IF_TYPE_STA);
@@ -47,7 +58,9 @@ static ssize_t store_remove_iface(struct
 		return -EPERM;
 	if (len > IFNAMSIZ)
 		return -EINVAL;
-	rtnl_lock();
+	res = rtnl_lock_local(local);
+	if (res)
+		return res;
 	res = ieee80211_if_remove(local->mdev, buf, -1);
 	rtnl_unlock();
 	return res < 0 ? res : len;
Signature · 1 line
1.3.0
author
#7 lore raw

PATCH 5/12 d80211: wiphy sysfs attributes

In reply to Jiri Benc

Add /sys/class/ieee80211/phyX/* attributes.

---

 net/d80211/ieee80211_proc.c  |    4 -
 net/d80211/ieee80211_proc.h  |    3 
 net/d80211/ieee80211_sysfs.c |  304 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 302 insertions(+), 9 deletions(-)

b049b3afd8db895dd1f6985c1d1051eb733b887b

net/d80211/ieee80211_proc.c +2 -2
index 4f3a6b9..581b583 100644
@@ -442,7 +442,7 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 }
 
 
-static const char * ieee80211_mode_str_short(int mode)
+const char *ieee80211_mode_str_short(int mode)
 {
 	switch (mode) {
 	case MODE_IEEE80211A:
@@ -459,7 +459,7 @@ static const char * ieee80211_mode_str_s
 }
 
 
-static const char * ieee80211_mode_str(int mode)
+const char *ieee80211_mode_str(int mode)
 {
 	switch (mode) {
 	case MODE_IEEE80211A:
net/d80211/ieee80211_proc.h +3 -0
index 8c76560..4519d26 100644
@@ -42,4 +42,7 @@ static inline void ieee80211_proc_init(v
 static inline void ieee80211_proc_deinit(void) {}
 #endif /* CONFIG_PROC_FS */
 
+const char *ieee80211_mode_str(int mode);
+const char *ieee80211_mode_str_short(int mode);
+
 #endif /* IEEE80211_PROC_H */
net/d80211/ieee80211_sysfs.c +297 -7

349 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#8 lore raw

PATCH 6/12 d80211: network interface sysfs attributes

In reply to Jiri Benc

Add /sys/class/net/X/* attributes for 802.11 interfaces.

---

 net/d80211/ieee80211_i.h     |    3 
 net/d80211/ieee80211_iface.c |    1 
 net/d80211/ieee80211_sysfs.c |  299 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+), 2 deletions(-)

ad13a53621edc97c9bfb41a513a674415186c392

net/d80211/ieee80211_i.h +3 -0
index 9fabf17..7c1b621 100644
@@ -305,6 +305,8 @@ #define NUM_DEFAULT_KEYS 4
         } u;
         int channel_use;
         int channel_use_raw;
+
+	struct attribute_group *sysfs_group;
 };
 
 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
@@ -616,5 +618,6 @@ int ieee80211_dev_sysfs_add(struct ieee8
 void ieee80211_dev_sysfs_del(struct ieee80211_local *local);
 int ieee80211_sysfs_init(void);
 void ieee80211_sysfs_deinit(void);
+int ieee80211_sysfs_change_if_type(struct net_device *dev);
 
 #endif /* IEEE80211_I_H */
net/d80211/ieee80211_iface.c +1 -0
index 8ab2c07..727b5e3 100644
@@ -202,6 +202,7 @@ void ieee80211_if_set_type(struct net_de
 		printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
 		       dev->name, __FUNCTION__, type);
 	}
+	ieee80211_sysfs_change_if_type(dev);
 }
 
 /* Must be called with rtnl lock held. */
net/d80211/ieee80211_sysfs.c +297 -2

325 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#9 lore raw

PATCH 7/12 d80211: rename sta_info_relase to sta_info_put

In reply to Jiri Benc

sta_info structure has reference counting (will be converted to kobject in next patch). Therefore, sta_info_release should be divided into two functions - one for decrementing reference count and one for freeing the structure when the count drops to zero. sta_info_release is the name suitable for the second function.

This patch renames sta_info_release to sta_info_put to let next patch introduce a new sta_info_release function.

---

 net/d80211/ieee80211.c       |   18 +++++++++---------
 net/d80211/ieee80211_iface.c |    2 +-
 net/d80211/ieee80211_ioctl.c |   18 +++++++++---------
 net/d80211/ieee80211_sta.c   |    8 ++++----
 net/d80211/rate_control.c    |    4 ++--
 net/d80211/sta_info.c        |   10 +++++-----
 net/d80211/sta_info.h        |    2 +-
 7 files changed, 31 insertions(+), 31 deletions(-)

4ddde98ebbdede0d0b16a85156e1b9c192c0e764

net/d80211/ieee80211.c +9 -9
index c983d70..0c23607 100644
@@ -1153,7 +1153,7 @@ static int ieee80211_tx(struct net_devic
 	skb = tx.skb; /* handlers are allowed to change skb */
 
 	if (sta)
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 
 	if (unlikely(res == TXRX_DROP)) {
 		I802_DEBUG_INC(local->tx_handlers_drop);
@@ -1373,7 +1373,7 @@ static int ieee80211_subif_start_xmit(st
 			fc |= WLAN_FC_STYPE_QOS_DATA << 4;
 			hdrlen += 2;
 		}
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 	}
 
 	hdr.frame_control = cpu_to_le16(fc);
@@ -1743,7 +1743,7 @@ ieee80211_get_buffered_bc(struct net_dev
 	}
 
 	if (sta)
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 
 	return skb;
 }
@@ -2330,7 +2330,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 				skb = NULL;
 			}
 			if (dsta)
-				sta_info_release(local, dsta);
+				sta_info_put(local, dsta);
 		}
 	}
 
@@ -3469,7 +3469,7 @@ void __ieee80211_rx(struct net_device *d
 
   end:
 	if (sta)
-                sta_info_release(local, sta);
+		sta_info_put(local, sta);
 }
 
 
@@ -3806,7 +3806,7 @@ void ieee80211_tx_status(struct net_devi
 				status->excessive_retries = 0;
 				status->tx_filtered = 1;
 			}
-			sta_info_release(local, sta);
+			sta_info_put(local, sta);
 		}
 	}
 
@@ -3855,7 +3855,7 @@ void ieee80211_tx_status(struct net_devi
 				}
 				dev_kfree_skb(skb);
 			}
-			sta_info_release(local, sta);
+			sta_info_put(local, sta);
 			return;
 		}
 	} else {
@@ -3978,7 +3978,7 @@ int ieee80211_if_update_wds(struct net_d
 	/* Remove STA entry for the old peer */
 	sta = sta_info_get(local, sdata->u.wds.remote_addr);
 	if (sta) {
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 		sta_info_free(local, sta, 0);
 	} else {
 		printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
@@ -4522,7 +4522,7 @@ EXPORT_SYMBOL(ieee80211_get_hdrlen_from_
 EXPORT_SYMBOL(ieee80211_rate_control_register);
 EXPORT_SYMBOL(ieee80211_rate_control_unregister);
 EXPORT_SYMBOL(sta_info_get);
-EXPORT_SYMBOL(sta_info_release);
+EXPORT_SYMBOL(sta_info_put);
 EXPORT_SYMBOL(ieee80211_radar_status);
 EXPORT_SYMBOL(ieee80211_get_mc_list_item);
 
net/d80211/ieee80211_iface.c +1 -1
index 727b5e3..467dcba 100644
@@ -261,7 +261,7 @@ #endif
 	case IEEE80211_IF_TYPE_WDS:
 		sta = sta_info_get(local, sdata->u.wds.remote_addr);
 		if (sta) {
-			sta_info_release(local, sta);
+			sta_info_put(local, sta);
 			sta_info_free(local, sta, 0);
 		} else {
 #ifdef CONFIG_D80211_VERBOSE_DEBUG
net/d80211/ieee80211_ioctl.c +9 -9
index 8d593e8..e1bdc03 100644
@@ -294,7 +294,7 @@ static int ieee80211_ioctl_add_sta(struc
 		}
 	}
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 
 	return 0;
 }
@@ -308,7 +308,7 @@ static int ieee80211_ioctl_remove_sta(st
 
 	sta = sta_info_get(local, param->sta_addr);
 	if (sta) {
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 		sta_info_free(local, sta, 1);
 	}
 
@@ -393,7 +393,7 @@ static int ieee80211_ioctl_get_info_sta(
 	param->u.get_info_sta.last_rssi = sta->last_rssi;
 	param->u.get_info_sta.last_ack_rssi = sta->last_ack_rssi[2];
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 
 	return 0;
 }
@@ -421,7 +421,7 @@ static int ieee80211_ioctl_set_flags_sta
 			printk(KERN_DEBUG "%s: failed to set low-level driver "
 			       "PAE state (unauthorized) for " MACSTR "\n",
 			       dev->name, MAC2STR(sta->addr));
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 	}
 
 	return sta ? 0 : -ENOENT;
@@ -563,7 +563,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 				if (sta->flags & WLAN_STA_WME) {
 					try_hwaccel = 0;
 				}
-				sta_info_release(local, sta);
+				sta_info_put(local, sta);
 				sta = NULL;
 			}
 		}
@@ -643,7 +643,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
  done:
 	if (sta)
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 
 	return ret;
 }
@@ -813,7 +813,7 @@ static int ieee80211_ioctl_get_encryptio
 	}
 
 	if (sta)
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 
 	return ret;
 }
@@ -842,7 +842,7 @@ static int ieee80211_ioctl_wpa_trigger(s
 
 	sta->wpa_trigger = param->u.wpa_trigger.trigger;
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 	return 0;
 }
 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
@@ -1136,7 +1136,7 @@ #endif
 			sta->vlan_id = param->u.set_sta_vlan.vlan_id;
                         dev_put(new_vlan_dev);
                 }
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 	}
 
 	return sta ? 0 : -ENOENT;
net/d80211/ieee80211_sta.c +4 -4
index 66a4575..a42c387 100644
@@ -730,7 +730,7 @@ static void ieee80211_associated(struct 
 							 ifsta->ssid_len);
 			}
 		}
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 	}
 	if (disassoc) {
 		union iwreq_data wrqu;
@@ -1200,7 +1200,7 @@ static void ieee80211_rx_mgmt_assoc_resp
 	}
 
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 
 	ieee80211_associated(dev, ifsta);
 }
@@ -1443,7 +1443,7 @@ #endif /* IEEE80211_IBSS_DEBUG */
 			       dev->name, MAC2STR(sta->addr), prev_rates,
 			       supp_rates, sta->supp_rates);
 		}
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 	}
 
 	if (elems.ssid == NULL)
@@ -2834,7 +2834,7 @@ struct sta_info * ieee80211_ibss_add_sta
 
 	rate_control_rate_init(local, sta);
 
-	return sta; /* caller will call sta_info_release() */
+	return sta; /* caller will call sta_info_put() */
 }
 
 
net/d80211/rate_control.c +2 -2
index 3485302..9bcb8fc 100644
@@ -209,7 +209,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		}
 	}
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 }
 
 
@@ -260,7 +260,7 @@ rate_control_simple_get_rate(struct net_
 	extra->nonerp_idx = nonerp_idx;
 	extra->nonerp = &local->curr_rates[extra->nonerp_idx];
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 
 	return &local->curr_rates[rateidx];
 }
net/d80211/sta_info.c +5 -5
index de14821..9565c29 100644
@@ -98,7 +98,7 @@ int sta_info_min_txrate_get(struct ieee8
 }
 
 
-void sta_info_release(struct ieee80211_local *local, struct sta_info *sta)
+void sta_info_put(struct ieee80211_local *local, struct sta_info *sta)
 {
 	struct sk_buff *skb;
 
@@ -145,7 +145,7 @@ struct sta_info * sta_info_add(struct ie
 	atomic_inc(&sta->users); /* sta in hashlist etc, decremented by
 				  * sta_info_free() */
 	atomic_inc(&sta->users); /* sta used by caller, decremented by
-				  * sta_info_release() */
+				  * sta_info_put() */
 	spin_lock_bh(&local->sta_lock);
 	list_add(&sta->list, &local->sta_list);
 	local->num_sta++;
@@ -237,13 +237,13 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 	if (atomic_read(&sta->users) != 1) {
 		/* This is OK, but printed for debugging. The station structure
 		 * will be removed when the other user of the data calls
-		 * sta_info_release(). */
+		 * sta_info_put(). */
 		printk(KERN_DEBUG "%s: STA " MACSTR " users count %d when "
 		       "removing it\n", local->mdev->name, MAC2STR(sta->addr),
 		       atomic_read(&sta->users));
 	}
 
-	sta_info_release(local, sta);
+	sta_info_put(local, sta);
 }
 
 
@@ -302,7 +302,7 @@ static void sta_info_cleanup(unsigned lo
 		struct sta_info *sta = (struct sta_info *) ptr;
 		atomic_inc(&sta->users);
 		sta_info_cleanup_expire_buffered(local, sta);
-		sta_info_release(local, sta);
+		sta_info_put(local, sta);
 		ptr = ptr->next;
 	}
 	spin_unlock_bh(&local->sta_lock);
net/d80211/sta_info.h +1 -1
index 294cb0a..fddc80e 100644
@@ -134,7 +134,7 @@ struct ieee80211_local;
 
 struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
 int sta_info_min_txrate_get(struct ieee80211_local *local);
-void sta_info_release(struct ieee80211_local *local, struct sta_info *sta);
+void sta_info_put(struct ieee80211_local *local, struct sta_info *sta);
 struct sta_info * sta_info_add(struct ieee80211_local *local,
 			       struct net_device *dev, u8 *addr);
 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta,
Signature · 1 line
1.3.0
author
#10 lore raw

PATCH 8/12 d80211: sysfs attributes for associated stations

In reply to Jiri Benc

Add /sys/class/ieee80211/phyX/sta/* attributes.

---

 net/d80211/Makefile              |    1 
 net/d80211/ieee80211.c           |    5 +
 net/d80211/ieee80211_i.h         |   14 ++
 net/d80211/ieee80211_proc.c      |    3 -
 net/d80211/ieee80211_sysfs_sta.c |  228 ++++++++++++++++++++++++++++++++++++++
 net/d80211/sta_info.c            |  114 +++++++++++++------
 net/d80211/sta_info.h            |   11 +-
 7 files changed, 331 insertions(+), 45 deletions(-)
 create mode 100644 net/d80211/ieee80211_sysfs_sta.c

ed88547db8f143b83cf336c93221400edc2b3d81

net/d80211/Makefile +1 -0
index 66bfcff..7d1ec29 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_D80211) += 80211.o rate_con
 	ieee80211_dev.o \
 	ieee80211_iface.o \
 	ieee80211_sysfs.o \
+	ieee80211_sysfs_sta.o \
 	michael.o \
 	tkip.o \
 	aes_ccm.o \
net/d80211/ieee80211.c +4 -1
index 0c23607..15d43f8 100644
@@ -4188,7 +4188,9 @@ int ieee80211_register_hw(struct net_dev
 
 	ieee80211_update_hw(dev, hw);	/* Don't care about the result. */
 
-	sta_info_start(local);
+	result = sta_info_start(local);
+	if (result < 0)
+		goto fail_sta_info;
 
 	if (hw->fraglist)
 		dev->features |= NETIF_F_FRAGLIST;
@@ -4237,6 +4239,7 @@ fail_if_sysfs:
 	unregister_netdev(dev);
 fail_dev:
 	sta_info_stop(local);
+fail_sta_info:
 	ieee80211_dev_sysfs_del(local);
 fail_sysfs:
 	ieee80211_dev_free_index(local);
net/d80211/ieee80211_i.h +14 -0
index 7c1b621..212d12f 100644
@@ -344,9 +344,11 @@ #define IEEE80211_IRQSAFE_QUEUE_LIMIT 12
 
         spinlock_t generic_lock;
 	/* Station data structures */
+	struct kset sta_kset;
 	spinlock_t sta_lock; /* mutex for STA data structures */
 	int num_sta; /* number of stations in sta_list */
 	struct list_head sta_list;
+	struct list_head deleted_sta_list;
 	struct sta_info *sta_hash[STA_HASH_SIZE];
 	struct timer_list sta_cleanup;
 
@@ -511,6 +513,12 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 	int user_space_mlme;
 };
 
+struct sta_attribute {
+	struct attribute attr;
+	ssize_t (*show)(const struct sta_info *, char *buf);
+	ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
+};
+
 
 /* ieee80211.c */
 void ieee80211_release_hw(struct ieee80211_local *local);
@@ -620,4 +628,10 @@ int ieee80211_sysfs_init(void);
 void ieee80211_sysfs_deinit(void);
 int ieee80211_sysfs_change_if_type(struct net_device *dev);
 
+/* ieee80211_sysfs_sta.c */
+int ieee80211_sta_kset_sysfs_register(struct ieee80211_local *local);
+void ieee80211_sta_kset_sysfs_unregister(struct ieee80211_local *local);
+int ieee80211_sta_sysfs_add(struct sta_info *sta);
+void ieee80211_sta_sysfs_remove(struct sta_info *sta);
+
 #endif /* IEEE80211_I_H */
net/d80211/ieee80211_proc.c +0 -3
index 581b583..4bb3179 100644
@@ -241,7 +241,6 @@ static int ieee80211_proc_sta_read(char 
 	if (!sta || !sta->dev)
 		return -1;
 
-	p += sprintf(p, "users=%d\n", atomic_read(&sta->users));
 	p += sprintf(p, "aid=%d\n", sta->aid);
 	p += sprintf(p, "flags=0x%x %s%s%s%s%s%s%s%s%s%s\n", sta->flags,
 		     sta->flags & WLAN_STA_AUTH ? "[AUTH]" : "",
@@ -656,7 +655,6 @@ void ieee80211_proc_init_sta(struct ieee
 				       ieee80211_proc_sta_read, sta);
 	if (entry) {
 		entry->mode &= ~(S_IRWXG | S_IRWXO);
-		sta->proc_entry_added = 1;
 	}
 }
 
@@ -668,7 +666,6 @@ void ieee80211_proc_deinit_sta(struct ie
 	sprintf(buf, MACSTR, MAC2STR(sta->addr));
 	if (local->proc_sta) {
 		remove_proc_entry(buf, local->proc_sta);
-		sta->proc_entry_added = 0;
 	}
 }
 
net/d80211/ieee80211_sysfs_sta.c new file +228 -0

228 lines not on this page · raw message

net/d80211/sta_info.c +78 -36

224 lines not on this page · raw message

net/d80211/sta_info.h +6 -5
index fddc80e..ddfe50e 100644
@@ -32,8 +32,10 @@ #define WLAN_STA_WDS BIT(27)
 
 struct sta_info {
 	struct list_head list;
+	struct kobject kobj;
 	struct sta_info *hnext; /* next entry in hash table list */
-	atomic_t users; /* number of users (do not remove if > 0) */
+
+	struct ieee80211_local *local;
 
 	u8 addr[ETH_ALEN];
 	u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
@@ -92,7 +94,7 @@ struct sta_info {
 				  * filtering; used only if sta->key is not
 				  * set */
 
-	int proc_entry_added:1;
+	int sysfs_registered:1;
 	int assoc_ap:1; /* whether this is an AP that we are associated with
 			 * as a client */
 
@@ -130,8 +132,6 @@ #define STA_TX_BUFFER_EXPIRE (10 * HZ)
  */
 #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
 
-struct ieee80211_local;
-
 struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
 int sta_info_min_txrate_get(struct ieee80211_local *local);
 void sta_info_put(struct ieee80211_local *local, struct sta_info *sta);
@@ -139,8 +139,9 @@ struct sta_info * sta_info_add(struct ie
 			       struct net_device *dev, u8 *addr);
 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta,
 		   int locked);
+void sta_info_release(struct kobject *kobj);
 void sta_info_init(struct ieee80211_local *local);
-void sta_info_start(struct ieee80211_local *local);
+int sta_info_start(struct ieee80211_local *local);
 void sta_info_stop(struct ieee80211_local *local);
 void sta_info_remove_aid_ptr(struct sta_info *sta);
 void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
Signature · 1 line
1.3.0
author
#11 lore raw

PATCH 9/12 d80211: remove useless parameters

In reply to Jiri Benc

There is no necessity for passing ieee80211_local parameter to sta_info_put and sta_info_free now.

---

 net/d80211/ieee80211.c       |   18 +++++++++---------
 net/d80211/ieee80211_iface.c |    4 ++--
 net/d80211/ieee80211_ioctl.c |   20 ++++++++++----------
 net/d80211/ieee80211_sta.c   |    8 ++++----
 net/d80211/rate_control.c    |    4 ++--
 net/d80211/sta_info.c        |   16 ++++++++--------
 net/d80211/sta_info.h        |    5 ++---
 7 files changed, 37 insertions(+), 38 deletions(-)

bc9e55deef4924f5a4ba82487747726413636df6

net/d80211/ieee80211.c +9 -9
index 15d43f8..75aaa99 100644
@@ -1153,7 +1153,7 @@ static int ieee80211_tx(struct net_devic
 	skb = tx.skb; /* handlers are allowed to change skb */
 
 	if (sta)
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 
 	if (unlikely(res == TXRX_DROP)) {
 		I802_DEBUG_INC(local->tx_handlers_drop);
@@ -1373,7 +1373,7 @@ static int ieee80211_subif_start_xmit(st
 			fc |= WLAN_FC_STYPE_QOS_DATA << 4;
 			hdrlen += 2;
 		}
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 
 	hdr.frame_control = cpu_to_le16(fc);
@@ -1743,7 +1743,7 @@ ieee80211_get_buffered_bc(struct net_dev
 	}
 
 	if (sta)
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 
 	return skb;
 }
@@ -2330,7 +2330,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 				skb = NULL;
 			}
 			if (dsta)
-				sta_info_put(local, dsta);
+				sta_info_put(dsta);
 		}
 	}
 
@@ -3469,7 +3469,7 @@ void __ieee80211_rx(struct net_device *d
 
   end:
 	if (sta)
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 }
 
 
@@ -3806,7 +3806,7 @@ void ieee80211_tx_status(struct net_devi
 				status->excessive_retries = 0;
 				status->tx_filtered = 1;
 			}
-			sta_info_put(local, sta);
+			sta_info_put(sta);
 		}
 	}
 
@@ -3855,7 +3855,7 @@ void ieee80211_tx_status(struct net_devi
 				}
 				dev_kfree_skb(skb);
 			}
-			sta_info_put(local, sta);
+			sta_info_put(sta);
 			return;
 		}
 	} else {
@@ -3978,8 +3978,8 @@ int ieee80211_if_update_wds(struct net_d
 	/* Remove STA entry for the old peer */
 	sta = sta_info_get(local, sdata->u.wds.remote_addr);
 	if (sta) {
-		sta_info_put(local, sta);
-		sta_info_free(local, sta, 0);
+		sta_info_put(sta);
+		sta_info_free(sta, 0);
 	} else {
 		printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
 		       "peer " MACSTR "\n",
net/d80211/ieee80211_iface.c +2 -2
index 467dcba..960a90e 100644
@@ -261,8 +261,8 @@ #endif
 	case IEEE80211_IF_TYPE_WDS:
 		sta = sta_info_get(local, sdata->u.wds.remote_addr);
 		if (sta) {
-			sta_info_put(local, sta);
-			sta_info_free(local, sta, 0);
+			sta_info_put(sta);
+			sta_info_free(sta, 0);
 		} else {
 #ifdef CONFIG_D80211_VERBOSE_DEBUG
 			printk(KERN_DEBUG "%s: Someone had deleted my STA "
net/d80211/ieee80211_ioctl.c +10 -10
index e1bdc03..562b9f3 100644
@@ -294,7 +294,7 @@ static int ieee80211_ioctl_add_sta(struc
 		}
 	}
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 
 	return 0;
 }
@@ -308,8 +308,8 @@ static int ieee80211_ioctl_remove_sta(st
 
 	sta = sta_info_get(local, param->sta_addr);
 	if (sta) {
-		sta_info_put(local, sta);
-		sta_info_free(local, sta, 1);
+		sta_info_put(sta);
+		sta_info_free(sta, 1);
 	}
 
 	return sta ? 0 : -ENOENT;
@@ -393,7 +393,7 @@ static int ieee80211_ioctl_get_info_sta(
 	param->u.get_info_sta.last_rssi = sta->last_rssi;
 	param->u.get_info_sta.last_ack_rssi = sta->last_ack_rssi[2];
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 
 	return 0;
 }
@@ -421,7 +421,7 @@ static int ieee80211_ioctl_set_flags_sta
 			printk(KERN_DEBUG "%s: failed to set low-level driver "
 			       "PAE state (unauthorized) for " MACSTR "\n",
 			       dev->name, MAC2STR(sta->addr));
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 
 	return sta ? 0 : -ENOENT;
@@ -563,7 +563,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 				if (sta->flags & WLAN_STA_WME) {
 					try_hwaccel = 0;
 				}
-				sta_info_put(local, sta);
+				sta_info_put(sta);
 				sta = NULL;
 			}
 		}
@@ -643,7 +643,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
  done:
 	if (sta)
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 
 	return ret;
 }
@@ -813,7 +813,7 @@ static int ieee80211_ioctl_get_encryptio
 	}
 
 	if (sta)
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 
 	return ret;
 }
@@ -842,7 +842,7 @@ static int ieee80211_ioctl_wpa_trigger(s
 
 	sta->wpa_trigger = param->u.wpa_trigger.trigger;
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 	return 0;
 }
 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
@@ -1136,7 +1136,7 @@ #endif
 			sta->vlan_id = param->u.set_sta_vlan.vlan_id;
                         dev_put(new_vlan_dev);
                 }
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 
 	return sta ? 0 : -ENOENT;
net/d80211/ieee80211_sta.c +4 -4
index a42c387..37d40aa 100644
@@ -730,7 +730,7 @@ static void ieee80211_associated(struct 
 							 ifsta->ssid_len);
 			}
 		}
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 	if (disassoc) {
 		union iwreq_data wrqu;
@@ -1200,7 +1200,7 @@ static void ieee80211_rx_mgmt_assoc_resp
 	}
 
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 
 	ieee80211_associated(dev, ifsta);
 }
@@ -1443,7 +1443,7 @@ #endif /* IEEE80211_IBSS_DEBUG */
 			       dev->name, MAC2STR(sta->addr), prev_rates,
 			       supp_rates, sta->supp_rates);
 		}
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 
 	if (elems.ssid == NULL)
@@ -1836,7 +1836,7 @@ static void ieee80211_sta_expire(struct 
 			       IEEE80211_IBSS_INACTIVITY_LIMIT)) {
 			printk(KERN_DEBUG "%s: expiring inactive STA " MACSTR
 			       "\n", dev->name, MAC2STR(sta->addr));
-			sta_info_free(local, sta, 1);
+			sta_info_free(sta, 1);
 		}
 	}
 	spin_unlock_bh(&local->sta_lock);
net/d80211/rate_control.c +2 -2
index 9bcb8fc..e7e6791 100644
@@ -209,7 +209,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		}
 	}
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 }
 
 
@@ -260,7 +260,7 @@ rate_control_simple_get_rate(struct net_
 	extra->nonerp_idx = nonerp_idx;
 	extra->nonerp = &local->curr_rates[extra->nonerp_idx];
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 
 	return &local->curr_rates[rateidx];
 }
net/d80211/sta_info.c +8 -8
index bba4771..9c6adaa 100644
@@ -102,7 +102,7 @@ int sta_info_min_txrate_get(struct ieee8
 }
 
 
-void sta_info_put(struct ieee80211_local *local, struct sta_info *sta)
+void sta_info_put(struct sta_info *sta)
 {
 	kobject_put(&sta->kobj);
 }
@@ -200,13 +200,13 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 	ieee80211_proc_deinit_sta(local, sta);
 	ieee80211_sta_sysfs_remove(sta);
 
-	sta_info_put(local, sta);
+	sta_info_put(sta);
 }
 
-void sta_info_free(struct ieee80211_local *local, struct sta_info *sta,
-		   int locked)
+void sta_info_free(struct sta_info *sta, int locked)
 {
 	struct sk_buff *skb;
+	struct ieee80211_local *local = sta->local;
 	struct ieee80211_sub_if_data *sdata;
 
 	if (!locked)
@@ -320,7 +320,7 @@ static void sta_info_cleanup(unsigned lo
 		struct sta_info *sta = (struct sta_info *) ptr;
 		__sta_info_get(sta);
 		sta_info_cleanup_expire_buffered(local, sta);
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 		ptr = ptr->next;
 	}
 	spin_unlock_bh(&local->sta_lock);
@@ -368,7 +368,7 @@ static void sta_info_proc_add_task(void 
 		sta->sysfs_registered = 1;
 		ieee80211_sta_sysfs_add(sta);
 		ieee80211_proc_init_sta(local, sta);
-		sta_info_put(local, sta);
+		sta_info_put(sta);
 	}
 }
 
@@ -412,7 +412,7 @@ void sta_info_stop(struct ieee80211_loca
 		 * parameter to ensure all sysfs sta entries are
 		 * unregistered. We don't need locking at this
 		 * point. */
-		sta_info_free(local, sta, 0);
+		sta_info_free(sta, 0);
 	}
 	ieee80211_sta_kset_sysfs_unregister(local);
 }
@@ -449,7 +449,7 @@ void sta_info_flush(struct ieee80211_loc
 	list_for_each_safe(ptr, n, &local->sta_list) {
 		struct sta_info *sta = list_entry(ptr, struct sta_info, list);
 		if (dev == NULL || dev == sta->dev)
-			sta_info_free(local, sta, 1);
+			sta_info_free(sta, 1);
 	}
 	spin_unlock_bh(&local->sta_lock);
 }
net/d80211/sta_info.h +2 -3
index ddfe50e..70334e5 100644
@@ -134,11 +134,10 @@ #define STA_INFO_CLEANUP_INTERVAL (10 * 
 
 struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
 int sta_info_min_txrate_get(struct ieee80211_local *local);
-void sta_info_put(struct ieee80211_local *local, struct sta_info *sta);
+void sta_info_put(struct sta_info *sta);
 struct sta_info * sta_info_add(struct ieee80211_local *local,
 			       struct net_device *dev, u8 *addr);
-void sta_info_free(struct ieee80211_local *local, struct sta_info *sta,
-		   int locked);
+void sta_info_free(struct sta_info *sta, int locked);
 void sta_info_release(struct kobject *kobj);
 void sta_info_init(struct ieee80211_local *local);
 int sta_info_start(struct ieee80211_local *local);
Signature · 1 line
1.3.0
author
#12 lore raw

PATCH 10/12 d80211: rate_control sysfs attributes

In reply to Jiri Benc

Add support for sysfs attributes for rate_control modules.

---

 net/d80211/ieee80211.c    |   13 ++++++++++++-
 net/d80211/rate_control.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 net/d80211/rate_control.h |   36 ++++++++++++++++++++++++++++++++++++
 net/d80211/sta_info.c     |    4 ++++
 4 files changed, 94 insertions(+), 1 deletions(-)

9acfab1d1a4e4a82dace4055a089d605d5efa97f

net/d80211/ieee80211.c +12 -1
index 75aaa99..e4ac701 100644
@@ -4215,6 +4215,13 @@ int ieee80211_register_hw(struct net_dev
 		       "algorithm\n", dev->name);
 		goto fail_rate;
 	}
+	result = rate_control_add_attrs(local, local->rate_ctrl_priv,
+					&local->class_dev.kobj);
+	if (result < 0) {
+		printk(KERN_DEBUG "%s: Failed to register sysfs attributes "
+		       "for rate control\n", dev->name);
+		goto fail_rate_attrs;
+	}
 
 	/* TODO: add rtnl locking around device creation and qdisc install */
 	ieee80211_install_qdisc(dev);
@@ -4233,6 +4240,8 @@ int ieee80211_register_hw(struct net_dev
 
 	return 0;
 
+fail_rate_attrs:
+	rate_control_free(local);
 fail_rate:
 	ieee80211_sysfs_remove_netdevice(dev);
 fail_if_sysfs:
@@ -4308,6 +4317,8 @@ void ieee80211_unregister_hw(struct net_
 	rtnl_unlock();
 
 	sta_info_stop(local);
+	rate_control_remove_attrs(local, local->rate_ctrl_priv,
+				  &local->class_dev.kobj);
 	ieee80211_dev_sysfs_del(local);
 
 	for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
@@ -4327,7 +4338,6 @@ void ieee80211_unregister_hw(struct net_
 	skb_queue_purge(&local->skb_queue);
 	skb_queue_purge(&local->skb_queue_unreliable);
 
-	rate_control_free(local);
 	ieee80211_dev_free_index(local);
 }
 
@@ -4341,6 +4351,7 @@ void ieee80211_free_hw(struct net_device
 
 void ieee80211_release_hw(struct ieee80211_local *local)
 {
+	rate_control_free(local);
 	kfree(local);
 }
 
net/d80211/rate_control.c +42 -0

54 lines not on this page · raw message

net/d80211/rate_control.h +36 -0
index b509539..7705fb2 100644
@@ -53,6 +53,11 @@ struct rate_control_ops {
 	void (*free)(void *priv);
 	void * (*alloc_sta)(void);
 	void (*free_sta)(void *priv);
+
+	int (*add_attrs)(void *priv, struct kobject *kobj);
+	void (*remove_attrs)(void *priv, struct kobject *kobj);
+	int (*add_sta_attrs)(void *priv, struct kobject *kobj);
+	void (*remove_sta_attrs)(void *priv, struct kobject *kobj);
 };
 
 
@@ -132,4 +137,35 @@ static inline void rate_control_free_sta
 	local->rate_ctrl->free_sta(priv);
 }
 
+static inline int rate_control_add_attrs(struct ieee80211_local *local,
+					 void *priv, struct kobject *kobj)
+{
+	if (local->rate_ctrl->add_attrs)
+		return local->rate_ctrl->add_attrs(priv, kobj);
+	return 0;
+}
+
+static inline void rate_control_remove_attrs(struct ieee80211_local *local,
+					     void *priv, struct kobject *kobj)
+{
+	if (local->rate_ctrl->remove_attrs)
+		local->rate_ctrl->remove_attrs(priv, kobj);
+}
+
+static inline int rate_control_add_sta_attrs(struct ieee80211_local *local,
+					     void *priv, struct kobject *kobj)
+{
+	if (local->rate_ctrl->add_sta_attrs)
+		return local->rate_ctrl->add_sta_attrs(priv, kobj);
+	return 0;
+}
+
+static inline void rate_control_remove_sta_attrs(struct ieee80211_local *local,
+						 void *priv,
+						 struct kobject *kobj)
+{
+	if (local->rate_ctrl->remove_sta_attrs)
+		local->rate_ctrl->remove_sta_attrs(priv, kobj);
+}
+
 #endif /* RATE_CONTROL */
net/d80211/sta_info.c +4 -0
index 9c6adaa..96e8dc4 100644
@@ -178,6 +178,8 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 	if (!in_interrupt()) {
 		sta->sysfs_registered = 1;
 		ieee80211_sta_sysfs_add(sta);
+		rate_control_add_sta_attrs(local, sta->rate_ctrl_priv,
+					   &sta->kobj);
 		ieee80211_proc_init_sta(local, sta);
 	} else {
 		/* procfs entry adding might sleep, so schedule process context
@@ -197,6 +199,7 @@ #ifdef CONFIG_D80211_VERBOSE_DEBUG
 	       local->mdev->name, MAC2STR(sta->addr));
 #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
+	rate_control_remove_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
 	ieee80211_proc_deinit_sta(local, sta);
 	ieee80211_sta_sysfs_remove(sta);
 
@@ -367,6 +370,7 @@ static void sta_info_proc_add_task(void 
 
 		sta->sysfs_registered = 1;
 		ieee80211_sta_sysfs_add(sta);
+		rate_control_add_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
 		ieee80211_proc_init_sta(local, sta);
 		sta_info_put(sta);
 	}
Signature · 1 line
1.3.0
author
#13 lore raw

PATCH 11/12 d80211: encryption keys sysfs attributes

In reply to Jiri Benc

Add /sys/class/ieee80211/phyX/sta/*/key/* and /sys/class/net/X/keys/[0-3]/* attributes.

---

 net/d80211/ieee80211.c           |   33 ++++++
 net/d80211/ieee80211_i.h         |   11 ++
 net/d80211/ieee80211_ioctl.c     |  101 ++++++++++++-------
 net/d80211/ieee80211_key.h       |    2 
 net/d80211/ieee80211_sysfs.c     |   12 ++
 net/d80211/ieee80211_sysfs_sta.c |  206 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 326 insertions(+), 39 deletions(-)

9b2e2e2cc66e7fb3f1ae07d7e083ffa63dffbde7

net/d80211/ieee80211.c +31 -2
index e4ac701..1a03f07 100644
@@ -84,15 +84,44 @@ ieee80211_key_data2conf(struct ieee80211
 	return conf;
 }
 
+struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
+					  int idx, size_t key_len, gfp_t flags)
+{
+	struct ieee80211_key *key;
+	int res;
+
+	key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags);
+	if (!key)
+		return NULL;
+	if (sdata)
+		res = kobject_set_name(&key->kobj, "%d", idx);
+	else
+		res = kobject_set_name(&key->kobj, "key");
+	if (res) {
+		kfree(key);
+		return NULL;
+	}
+	ieee80211_key_sysfs_set_kset(key, sdata ? &sdata->key_kset : NULL);
+	kobject_init(&key->kobj);
+	return key;
+}
 
 void ieee80211_key_free(struct ieee80211_key *key)
 {
-	if (key && key->alg == ALG_CCMP)
+	if (key)
+		kobject_put(&key->kobj);
+}
+
+void ieee80211_key_release(struct kobject *kobj)
+{
+	struct ieee80211_key *key;
+
+	key = container_of(kobj, struct ieee80211_key, kobj);
+	if (key->alg == ALG_CCMP)
 		ieee80211_aes_key_free(key->u.ccmp.tfm);
 	kfree(key);
 }
 
-
 static int rate_list_match(int *rate_list, int rate)
 {
 	int i;
net/d80211/ieee80211_i.h +11 -0
index 212d12f..c1d7422 100644
@@ -294,6 +294,7 @@ struct ieee80211_sub_if_data {
 #define NUM_DEFAULT_KEYS 4
         struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
         struct ieee80211_key *default_key;
+	struct kset key_kset;
 
 	struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
 
@@ -527,7 +528,10 @@ int ieee80211_if_config(struct net_devic
 struct ieee80211_key_conf *
 ieee80211_key_data2conf(struct ieee80211_local *local,
 			struct ieee80211_key *data);
+struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
+					  int idx, size_t key_len, gfp_t flags);
 void ieee80211_key_free(struct ieee80211_key *key);
+void ieee80211_key_release(struct kobject *kobj);
 void ieee80211_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
 		       struct ieee80211_rx_status *status, u32 msg_type);
 void ieee80211_prepare_rates(struct net_device *dev);
@@ -633,5 +637,12 @@ int ieee80211_sta_kset_sysfs_register(st
 void ieee80211_sta_kset_sysfs_unregister(struct ieee80211_local *local);
 int ieee80211_sta_sysfs_add(struct sta_info *sta);
 void ieee80211_sta_sysfs_remove(struct sta_info *sta);
+int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset);
+int ieee80211_key_sysfs_add(struct ieee80211_key *key);
+void ieee80211_key_sysfs_remove(struct ieee80211_key *key);
+int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata);
 
 #endif /* IEEE80211_I_H */
net/d80211/ieee80211_ioctl.c +67 -34

164 lines not on this page · raw message

net/d80211/ieee80211_key.h +2 -0
index 4c688cd..64f2363 100644
@@ -40,6 +40,8 @@ #define CCMP_PN_LEN 6
 #define NUM_RX_DATA_QUEUES 17
 
 struct ieee80211_key {
+	struct kobject kobj;
+
 	int hw_key_idx; /* filled and used by low-level driver */
 	ieee80211_key_alg alg;
 	union {
net/d80211/ieee80211_sysfs.c +9 -3
index 12d16fd..10bf45c 100644
@@ -709,16 +709,22 @@ int ieee80211_sysfs_add_netdevice(struct
 	res = sysfs_create_link(&dev->class_dev.kobj, &local->class_dev.kobj,
 				"wiphy");
 	if (res)
-		goto out;
+		goto err_out;
 	res = ieee80211_add_if_group(&dev->class_dev.kobj, dev);
 	if (res)
-		sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
-out:
+		goto err_link;
+	res = ieee80211_key_kset_sysfs_register(IEEE80211_DEV_TO_SUB_IF(dev));
+	return res;
+
+err_link:
+	sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
+err_out:
 	return res;
 }
 
 void ieee80211_sysfs_remove_netdevice(struct net_device *dev)
 {
+	ieee80211_key_kset_sysfs_unregister(IEEE80211_DEV_TO_SUB_IF(dev));
 	ieee80211_remove_if_group(&dev->class_dev.kobj, dev);
 	sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
 }
net/d80211/ieee80211_sysfs_sta.c +206 -0

247 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#14 lore raw

PATCH 12/12 d80211: remove procfs files

In reply to Jiri Benc

Remove procfs support.

---

 net/d80211/Makefile          |    1 
 net/d80211/ieee80211.c       |    7 
 net/d80211/ieee80211_iface.c |    3 
 net/d80211/ieee80211_proc.c  |  768 ------------------------------------------
 net/d80211/ieee80211_proc.h  |   48 ---
 net/d80211/ieee80211_sysfs.c |   33 ++
 net/d80211/rate_control.c    |   25 -
 net/d80211/rate_control.h    |   17 -
 net/d80211/sta_info.c        |    4 
 9 files changed, 32 insertions(+), 874 deletions(-)
 delete mode 100644 net/d80211/ieee80211_proc.c
 delete mode 100644 net/d80211/ieee80211_proc.h

89c13fc02b12796d1f57c33c7fae1bcf875d846b

net/d80211/Makefile +0 -1
index 7d1ec29..c21e882 100644
@@ -6,7 +6,6 @@ obj-$(CONFIG_D80211) += 80211.o rate_con
 	sta_info.o \
 	wep.o \
 	wpa.o \
-	ieee80211_proc.o \
 	ieee80211_scan.o \
 	ieee80211_sta.o \
 	ieee80211_dev.o \
net/d80211/ieee80211.c +0 -7
index 1a03f07..a8ca8d1 100644
@@ -25,7 +25,6 @@ #include <net/d80211.h>
 #include <net/d80211_common.h>
 #include <net/d80211_mgmt.h>
 #include "ieee80211_i.h"
-#include "ieee80211_proc.h"
 #include "rate_control.h"
 #include "wep.h"
 #include "wpa.h"
@@ -4256,7 +4255,6 @@ int ieee80211_register_hw(struct net_dev
 	ieee80211_install_qdisc(dev);
 
         ieee80211_wep_init(local);
-	ieee80211_proc_init_interface(local);
 
 	/* add one default STA interface */
 	rtnl_lock();
@@ -4359,8 +4357,6 @@ void ieee80211_unregister_hw(struct net_
 		kfree(local->basic_rates[i]);
         }
 
-	ieee80211_proc_deinit_interface(local);
-
 	if (skb_queue_len(&local->skb_queue)
 			|| skb_queue_len(&local->skb_queue_unreliable))
 		printk(KERN_WARNING "%s: skb_queue not empty", dev->name);
@@ -4520,14 +4516,12 @@ static int __init ieee80211_init(void)
 		return ret;
 	}
 
-	ieee80211_proc_init();
 	{
 		ret = ieee80211_wme_register();
 		if (ret) {
 			printk(KERN_DEBUG "ieee80211_init: failed to "
 			       "initialize WME (err=%d)\n", ret);
 			ieee80211_sysfs_deinit();
-			ieee80211_proc_deinit();
 			return ret;
 		}
 	}
@@ -4539,7 +4533,6 @@ static int __init ieee80211_init(void)
 static void __exit ieee80211_exit(void)
 {
 	ieee80211_wme_unregister();
-	ieee80211_proc_deinit();
 	ieee80211_sysfs_deinit();
 }
 
net/d80211/ieee80211_iface.c +0 -3
index 960a90e..5abd713 100644
@@ -14,7 +14,6 @@ #include <linux/rtnetlink.h>
 #include <net/d80211.h>
 #include <net/d80211_mgmt.h>
 #include "ieee80211_i.h"
-#include "ieee80211_proc.h"
 #include "sta_info.h"
 
 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
@@ -85,7 +84,6 @@ int ieee80211_if_add(struct net_device *
 	}
 
 	list_add(&sdata->list, &local->sub_if_list);
-	ieee80211_proc_init_virtual(ndev);
 
 	return 0;
 
@@ -307,7 +305,6 @@ void __ieee80211_if_del(struct ieee80211
 
 	ieee80211_if_reinit(dev);
 	list_del(&sdata->list);
-	ieee80211_proc_deinit_virtual(dev);
 	ieee80211_sysfs_remove_netdevice(dev);
 	unregister_netdevice(dev);
 	/* Except master interface, the net_device will be freed by
net/d80211/ieee80211_proc.c deleted +0 -768

768 lines not on this page · raw message

net/d80211/ieee80211_proc.h deleted +0 -48

48 lines not on this page · raw message

net/d80211/ieee80211_sysfs.c +32 -1
index 10bf45c..fb1c6b5 100644
@@ -14,7 +14,6 @@ #include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
 #include <net/d80211.h>
 #include "ieee80211_i.h"
-#include "ieee80211_proc.h"
 #include "rate_control.h"
 
 #define to_ieee80211_local(class)	container_of(class, struct ieee80211_local, class_dev)
@@ -30,6 +29,38 @@ static inline int rtnl_lock_local(struct
 	return 0;
 }
 
+static const char *ieee80211_mode_str_short(int mode)
+{
+	switch (mode) {
+	case MODE_IEEE80211A:
+		return "802.11a";
+	case MODE_IEEE80211B:
+		return "802.11b";
+	case MODE_IEEE80211G:
+		return "802.11g";
+	case MODE_ATHEROS_TURBO:
+		return "AtherosTurbo";
+	default:
+		return "UNKNOWN";
+	}
+}
+
+static const char *ieee80211_mode_str(int mode)
+{
+	switch (mode) {
+	case MODE_IEEE80211A:
+		return "IEEE 802.11a";
+	case MODE_IEEE80211B:
+		return "IEEE 802.11b";
+	case MODE_IEEE80211G:
+		return "IEEE 802.11g";
+	case MODE_ATHEROS_TURBO:
+		return "Atheros Turbo (5 GHz)";
+	default:
+		return "UNKNOWN";
+	}
+}
+
 /* attributes in /sys/class/ieee80211/phyX/ */
 
 static ssize_t store_add_iface(struct class_device *dev,
net/d80211/rate_control.c +0 -25
index 33ba8e2..bf797ec 100644
@@ -327,29 +327,6 @@ static void rate_control_simple_free_sta
 	kfree(rctrl);
 }
 
-
-static int rate_control_simple_status_sta(struct ieee80211_local *local,
-					  struct sta_info *sta, char *buf)
-{
-	char *p = buf;
-	struct sta_rate_control *srctrl = sta->rate_ctrl_priv;
-
-	p += sprintf(p, "tx_avg_rate_sum=%d\n", srctrl->tx_avg_rate_sum);
-	p += sprintf(p, "tx_avg_rate_num=%d\n", srctrl->tx_avg_rate_num);
-	if (srctrl->tx_avg_rate_num)
-		p += sprintf(p, "tx_avg_rate_avg=%d\n",
-			     srctrl->tx_avg_rate_sum /
-			     srctrl->tx_avg_rate_num);
-	return p - buf;
-}
-
-
-static int rate_control_simple_status_global(struct ieee80211_local *local,
-					     char *buf)
-{
-	return 0;
-}
-
 static ssize_t show_sta_tx_avg_rate_sum(const struct sta_info *sta, char *buf)
 {
 	struct sta_rate_control *srctrl = sta->rate_ctrl_priv;
@@ -397,8 +374,6 @@ static struct rate_control_ops rate_cont
 	.get_rate = rate_control_simple_get_rate,
 	.rate_init = rate_control_simple_rate_init,
 	.clear = rate_control_simple_clear,
-	.status_sta = rate_control_simple_status_sta,
-	.status_global = rate_control_simple_status_global,
 	.alloc = rate_control_simple_alloc,
 	.free = rate_control_simple_free,
 	.alloc_sta = rate_control_simple_alloc_sta,
net/d80211/rate_control.h +0 -17
index 7705fb2..d8bdfed 100644
@@ -45,9 +45,6 @@ struct rate_control_ops {
 		    struct rate_control_extra *extra);
 	void (*rate_init)(struct ieee80211_local *local, struct sta_info *sta);
 	void (*clear)(void *priv);
-	int (*status_sta)(struct ieee80211_local *local,
-			  struct sta_info *sta, char *buf);
-	int (*status_global)(struct ieee80211_local *local, char *buf);
 
 	void * (*alloc)(struct ieee80211_local *local);
 	void (*free)(void *priv);
@@ -96,20 +93,6 @@ static inline void rate_control_clear(st
 }
 
 
-static inline int rate_control_status_sta(struct ieee80211_local *local,
-					  struct sta_info *sta, char *buf)
-{
-	return local->rate_ctrl->status_sta(local, sta, buf);
-}
-
-
-static inline int rate_control_status_global(struct ieee80211_local *local,
-					     char *buf)
-{
-	return local->rate_ctrl->status_global(local, buf);
-}
-
-
 static inline void * rate_control_alloc(struct ieee80211_local *local)
 {
 	return local->rate_ctrl->alloc(local);
net/d80211/sta_info.c +0 -4
index 96e8dc4..d3b4b42 100644
@@ -19,7 +19,6 @@ #include <linux/if_arp.h>
 
 #include <net/d80211.h>
 #include "ieee80211_i.h"
-#include "ieee80211_proc.h"
 #include "rate_control.h"
 
 
@@ -180,7 +179,6 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		ieee80211_sta_sysfs_add(sta);
 		rate_control_add_sta_attrs(local, sta->rate_ctrl_priv,
 					   &sta->kobj);
-		ieee80211_proc_init_sta(local, sta);
 	} else {
 		/* procfs entry adding might sleep, so schedule process context
 		 * task for adding proc entry for STAs that do not yet have
@@ -200,7 +198,6 @@ #ifdef CONFIG_D80211_VERBOSE_DEBUG
 #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
 	rate_control_remove_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
-	ieee80211_proc_deinit_sta(local, sta);
 	ieee80211_sta_sysfs_remove(sta);
 
 	sta_info_put(sta);
@@ -371,7 +368,6 @@ static void sta_info_proc_add_task(void 
 		sta->sysfs_registered = 1;
 		ieee80211_sta_sysfs_add(sta);
 		rate_control_add_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
-		ieee80211_proc_init_sta(local, sta);
 		sta_info_put(sta);
 	}
 }
Signature · 1 line
1.3.0