mac80211: split IBSS/managed code
Johannes Berg
maintainerThis patch splits out the ibss code and data from managed (station) mode. The reason to do this is to better separate the state machines, and have the code be contained better so it gets easier to determine what exactly a given change will affect, that in turn makes it easier to understand.
This is quite some churn, especially because I split sdata->u.sta into sdata->u.mgd and sdata->u.ibss, but I think it's easier to maintain that way. I've also shuffled around some code -- null function sending is only applicable to managed interfaces so put that into that file, some other functions are needed from various places so put them into util, and also rearranged the prototypes in ieee80211_i.h accordingly.
---
This passed my, fairly rigorous, testing:
* associate to AP
* create IBSS
* create different IBSS
* down
* up
* create another IBSS
* associate to AP
without any trouble.
It somewhat paves the way to making managed mode entirely optional should that ever be desired. I didn't do it because that would add a lot of #ifdefs especially in the wext code.
net/mac80211/Makefile | 1 net/mac80211/agg-rx.c | 6 net/mac80211/agg-tx.c | 5 net/mac80211/cfg.c | 45 - net/mac80211/debugfs_netdev.c | 48 - net/mac80211/ht.c | 6 net/mac80211/ibss.c | 883 ++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 111 ++ net/mac80211/iface.c | 76 + net/mac80211/key.c | 2 net/mac80211/main.c | 9 net/mac80211/mlme.c | 1634 ++++++++++-------------------------------- net/mac80211/rx.c | 37 net/mac80211/scan.c | 43 - net/mac80211/spectmgmt.c | 26 net/mac80211/tx.c | 11 net/mac80211/util.c | 176 ++++ net/mac80211/wext.c | 142 ++- 18 files changed, 1788 insertions(+), 1473 deletions(-)
net/mac80211/Makefile +1 -0
@@ -9,6 +9,7 @@ mac80211-y := \ wpa.o \ scan.o \ ht.o agg-tx.o agg-rx.o \ + ibss.o \ mlme.o \ iface.o \ rate.o \
net/mac80211/ibss.c new file +883 -0
883 lines not on this page · raw message
net/mac80211/ieee80211_i.h +78 -33
177 lines not on this page · raw message
net/mac80211/main.c +5 -4
@@ -169,9 +169,10 @@ int ieee80211_if_config(struct ieee80211memset (&conf,0 ,sizeof (conf)); -if (sdata->vif.type ==NL80211_IFTYPE_STATION || - sdata->vif.type ==NL80211_IFTYPE_ADHOC ) - conf.bssid = sdata->u.sta.bssid; +if (sdata->vif.type ==NL80211_IFTYPE_STATION ) + conf.bssid = sdata->u.mgd.bssid; +else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC ) + conf.bssid = sdata->u.ibss.bssid;else if (sdata->vif.type ==NL80211_IFTYPE_AP ) conf.bssid = sdata->dev->dev_addr;else if (ieee80211_vif_is_mesh (&sdata->vif)) {
@@ -210,7 +211,7 @@ int ieee80211_if_config(struct ieee80211 !!rcu_dereference (sdata->u.ap.beacon);break ;case NL80211_IFTYPE_ADHOC : - conf.enable_beacon = !!sdata->u.sta.probe_resp; + conf.enable_beacon = !!sdata->u.ibss.probe_resp;break ;case NL80211_IFTYPE_MESH_POINT : conf.enable_beacon = true;
net/mac80211/tx.c +5 -6
@@ -1623,7 +1623,7 @@ int ieee80211_subif_start_xmit(struct skcase NL80211_IFTYPE_STATION : fc |=cpu_to_le16 (IEEE80211_FCTL_TODS );/* BSSID SA DA */ -memcpy (hdr.addr1, sdata->u.sta.bssid,ETH_ALEN ); +memcpy (hdr.addr1, sdata->u.mgd.bssid,ETH_ALEN );memcpy (hdr.addr2, skb->data +ETH_ALEN ,ETH_ALEN );memcpy (hdr.addr3, skb->data,ETH_ALEN ); hdrlen =24 ;
@@ -1632,7 +1632,7 @@ int ieee80211_subif_start_xmit(struct sk/* DA SA BSSID */ memcpy (hdr.addr1, skb->data,ETH_ALEN );memcpy (hdr.addr2, skb->data +ETH_ALEN ,ETH_ALEN ); -memcpy (hdr.addr3, sdata->u.sta.bssid,ETH_ALEN ); +memcpy (hdr.addr3, sdata->u.ibss.bssid,ETH_ALEN ); hdrlen =24 ;break ;default :
@@ -1918,7 +1918,6 @@ struct sk_buff *ieee80211_beacon_get(strstruct ieee80211_tx_info *info;struct ieee80211_sub_if_data *sdata =NULL ;struct ieee80211_if_ap *ap =NULL ; -struct ieee80211_if_sta *ifsta =NULL ;struct beacon_data *beacon;struct ieee80211_supported_band *sband;enum ieee80211_band band = local->hw.conf.channel->band;
@@ -1970,13 +1969,13 @@ struct sk_buff *ieee80211_beacon_get(str }else goto out; }else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC ) { +struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;struct ieee80211_hdr *hdr; - ifsta = &sdata->u.sta; -if (!ifsta->probe_resp) +if (!ifibss->probe_resp) goto out; - skb =skb_copy (ifsta->probe_resp,GFP_ATOMIC ); + skb =skb_copy (ifibss->probe_resp,GFP_ATOMIC );if (!skb) goto out;
net/mac80211/wext.c +81 -61
295 lines not on this page · raw message
net/mac80211/agg-rx.c +3 -3
@@ -129,7 +129,6 @@ static void ieee80211_send_addba_resp(st u8 dialog_token, u16 status, u16 policy, u16 buf_size, u16 timeout) { - struct ieee80211_if_sta *ifsta = &sdata->u.sta; struct ieee80211_local *local = sdata->local;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;
@@ -151,8 +150,9 @@ static void ieee80211_send_addba_resp(stif (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/agg-tx.c +2 -3
@@ -49,7 +49,6 @@ static void ieee80211_send_addba_request u16 agg_size, u16 timeout) {struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;u16 capab;
@@ -69,8 +68,8 @@ static void ieee80211_send_addba_requestif (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/ht.c +3 -3
@@ -169,7 +169,6 @@ void ieee80211_send_delba(struct ieee802 u16 initiator, u16 reason_code) {struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;u16 params;
@@ -190,8 +189,9 @@ void ieee80211_send_delba(struct ieee802if (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/scan.c +7 -36
79 lines not on this page · raw message
net/mac80211/iface.c +44 -32
126 lines not on this page · raw message
net/mac80211/mlme.c +416 -1218
1,320 lines not on this page · raw message
net/mac80211/cfg.c +22 -23
45 lines not on this page · raw message
net/mac80211/debugfs_netdev.c +26 -22
48 lines not on this page · raw message
net/mac80211/key.c +1 -1
Lines of this file are not shown. View the raw message.
net/mac80211/rx.c +22 -15
Lines of this file are not shown. View the raw message.
net/mac80211/spectmgmt.c +13 -13
Lines of this file are not shown. View the raw message.
net/mac80211/util.c +176 -0
176 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Johannes Berg
maintainerPATCH v2 1/1 mac80211: split IBSS/managed code
This patch splits out the ibss code and data from managed (station) mode. The reason to do this is to better separate the state machines, and have the code be contained better so it gets easier to determine what exactly a given change will affect, that in turn makes it easier to understand.
This is quite some churn, especially because I split sdata->u.sta into sdata->u.mgd and sdata->u.ibss, but I think it's easier to maintain that way. I've also shuffled around some code -- null function sending is only applicable to managed interfaces so put that into that file, some other functions are needed from various places so put them into util, and also rearranged the prototypes in ieee80211_i.h accordingly.
---
This passed my, fairly rigorous, testing:
* associate to AP
* create IBSS
* create different IBSS
* down
* up
* create another IBSS
* associate to AP
without any trouble.
It somewhat paves the way to making managed mode entirely optional should that ever be desired. I didn't do it because that would add a lot of #ifdefs especially in the wext code.
v2: rebased onto current wireless-testing after Kalle's pspoll.
net/mac80211/Makefile | 1 net/mac80211/agg-rx.c | 6 net/mac80211/agg-tx.c | 5 net/mac80211/cfg.c | 45 - net/mac80211/debugfs_netdev.c | 48 - net/mac80211/ht.c | 6 net/mac80211/ibss.c | 883 ++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 111 +- net/mac80211/iface.c | 76 + net/mac80211/key.c | 2 net/mac80211/main.c | 9 net/mac80211/mlme.c | 1642 ++++++++++-------------------------------- net/mac80211/rx.c | 37 net/mac80211/scan.c | 43 - net/mac80211/spectmgmt.c | 26 net/mac80211/tx.c | 11 net/mac80211/util.c | 176 ++++ net/mac80211/wext.c | 142 ++- 18 files changed, 1791 insertions(+), 1478 deletions(-)
net/mac80211/Makefile +1 -0
@@ -9,6 +9,7 @@ mac80211-y := \ wpa.o \ scan.o \ ht.o agg-tx.o agg-rx.o \ + ibss.o \ mlme.o \ iface.o \ rate.o \
net/mac80211/ibss.c new file +883 -0
883 lines not on this page · raw message
net/mac80211/ieee80211_i.h +78 -33
179 lines not on this page · raw message
net/mac80211/main.c +5 -4
@@ -169,9 +169,10 @@ int ieee80211_if_config(struct ieee80211memset (&conf,0 ,sizeof (conf)); -if (sdata->vif.type ==NL80211_IFTYPE_STATION || - sdata->vif.type ==NL80211_IFTYPE_ADHOC ) - conf.bssid = sdata->u.sta.bssid; +if (sdata->vif.type ==NL80211_IFTYPE_STATION ) + conf.bssid = sdata->u.mgd.bssid; +else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC ) + conf.bssid = sdata->u.ibss.bssid;else if (sdata->vif.type ==NL80211_IFTYPE_AP ) conf.bssid = sdata->dev->dev_addr;else if (ieee80211_vif_is_mesh (&sdata->vif)) {
@@ -210,7 +211,7 @@ int ieee80211_if_config(struct ieee80211 !!rcu_dereference (sdata->u.ap.beacon);break ;case NL80211_IFTYPE_ADHOC : - conf.enable_beacon = !!sdata->u.sta.probe_resp; + conf.enable_beacon = !!sdata->u.ibss.probe_resp;break ;case NL80211_IFTYPE_MESH_POINT : conf.enable_beacon = true;
net/mac80211/tx.c +5 -6
@@ -1625,7 +1625,7 @@ int ieee80211_subif_start_xmit(struct skcase NL80211_IFTYPE_STATION : fc |=cpu_to_le16 (IEEE80211_FCTL_TODS );/* BSSID SA DA */ -memcpy (hdr.addr1, sdata->u.sta.bssid,ETH_ALEN ); +memcpy (hdr.addr1, sdata->u.mgd.bssid,ETH_ALEN );memcpy (hdr.addr2, skb->data +ETH_ALEN ,ETH_ALEN );memcpy (hdr.addr3, skb->data,ETH_ALEN ); hdrlen =24 ;
@@ -1634,7 +1634,7 @@ int ieee80211_subif_start_xmit(struct sk/* DA SA BSSID */ memcpy (hdr.addr1, skb->data,ETH_ALEN );memcpy (hdr.addr2, skb->data +ETH_ALEN ,ETH_ALEN ); -memcpy (hdr.addr3, sdata->u.sta.bssid,ETH_ALEN ); +memcpy (hdr.addr3, sdata->u.ibss.bssid,ETH_ALEN ); hdrlen =24 ;break ;default :
@@ -1920,7 +1920,6 @@ struct sk_buff *ieee80211_beacon_get(strstruct ieee80211_tx_info *info;struct ieee80211_sub_if_data *sdata =NULL ;struct ieee80211_if_ap *ap =NULL ; -struct ieee80211_if_sta *ifsta =NULL ;struct beacon_data *beacon;struct ieee80211_supported_band *sband;enum ieee80211_band band = local->hw.conf.channel->band;
@@ -1972,13 +1971,13 @@ struct sk_buff *ieee80211_beacon_get(str }else goto out; }else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC ) { +struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;struct ieee80211_hdr *hdr; - ifsta = &sdata->u.sta; -if (!ifsta->probe_resp) +if (!ifibss->probe_resp) goto out; - skb =skb_copy (ifsta->probe_resp,GFP_ATOMIC ); + skb =skb_copy (ifibss->probe_resp,GFP_ATOMIC );if (!skb) goto out;
net/mac80211/wext.c +81 -61
295 lines not on this page · raw message
net/mac80211/agg-rx.c +3 -3
@@ -129,7 +129,6 @@ static void ieee80211_send_addba_resp(st u8 dialog_token, u16 status, u16 policy, u16 buf_size, u16 timeout) { - struct ieee80211_if_sta *ifsta = &sdata->u.sta; struct ieee80211_local *local = sdata->local;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;
@@ -151,8 +150,9 @@ static void ieee80211_send_addba_resp(stif (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/agg-tx.c +2 -3
@@ -49,7 +49,6 @@ static void ieee80211_send_addba_request u16 agg_size, u16 timeout) {struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;u16 capab;
@@ -69,8 +68,8 @@ static void ieee80211_send_addba_requestif (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/ht.c +3 -3
@@ -169,7 +169,6 @@ void ieee80211_send_delba(struct ieee802 u16 initiator, u16 reason_code) {struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct sk_buff *skb;struct ieee80211_mgmt *mgmt;u16 params;
@@ -190,8 +189,9 @@ void ieee80211_send_delba(struct ieee802if (sdata->vif.type ==NL80211_IFTYPE_AP || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); +else if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +memcpy (mgmt->bssid, sdata->u.mgd.bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/scan.c +7 -36
79 lines not on this page · raw message
net/mac80211/iface.c +44 -32
126 lines not on this page · raw message
net/mac80211/mlme.c +419 -1223
1,318 lines not on this page · raw message
net/mac80211/cfg.c +22 -23
45 lines not on this page · raw message
net/mac80211/debugfs_netdev.c +26 -22
48 lines not on this page · raw message
net/mac80211/key.c +1 -1
Lines of this file are not shown. View the raw message.
net/mac80211/rx.c +22 -15
Lines of this file are not shown. View the raw message.
net/mac80211/spectmgmt.c +13 -13
Lines of this file are not shown. View the raw message.
net/mac80211/util.c +176 -0
176 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.