Skip to content

Commit

Permalink
mac80211: move interface type to vif structure
Browse files Browse the repository at this point in the history
Drivers that support mixed AP/STA operation may well need to
know the type of a virtual interface when iterating over them.
The easiest way to support that is to move the interface type
variable into the vif structure.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and David S. Miller committed Jan 28, 2008
1 parent 32bfd35 commit 51fb61e
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 117 deletions.
2 changes: 2 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,12 @@ enum ieee80211_if_types {
* Data in this structure is continually present for driver
* use during the life of a virtual interface.
*
* @type: type of this virtual interface
* @drv_priv: data area for driver use, will always be aligned to
* sizeof(void *).
*/
struct ieee80211_vif {
enum ieee80211_if_types type;
/* must be last */
u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
};
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,

sdata = IEEE80211_DEV_TO_SUB_IF(dev);

if (sdata->type == IEEE80211_IF_TYPE_VLAN)
if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN)
return -EOPNOTSUPP;

ieee80211_if_reinit(dev);
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/debugfs_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
if (!sdata->debugfsdir)
return;

switch (sdata->type) {
switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_STA:
case IEEE80211_IF_TYPE_IBSS:
add_sta_files(sdata);
Expand Down Expand Up @@ -353,7 +353,7 @@ void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)

void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
{
del_files(sdata, sdata->type);
del_files(sdata, sdata->vif.type);
debugfs_remove(sdata->debugfsdir);
sdata->debugfsdir = NULL;
}
Expand Down
36 changes: 18 additions & 18 deletions net/mac80211/ieee80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,21 @@ static int ieee80211_open(struct net_device *dev)
/*
* check whether it may have the same address
*/
if (!identical_mac_addr_allowed(sdata->type,
nsdata->type))
if (!identical_mac_addr_allowed(sdata->vif.type,
nsdata->vif.type))
return -ENOTUNIQ;

/*
* can only add VLANs to enabled APs
*/
if (sdata->type == IEEE80211_IF_TYPE_VLAN &&
nsdata->type == IEEE80211_IF_TYPE_AP &&
if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
netif_running(nsdata->dev))
sdata->u.vlan.ap = nsdata;
}
}

switch (sdata->type) {
switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_WDS:
if (is_zero_ether_addr(sdata->u.wds.remote_addr))
return -ENOLINK;
Expand Down Expand Up @@ -222,7 +222,7 @@ static int ieee80211_open(struct net_device *dev)
ieee80211_led_radio(local, local->hw.conf.radio_enabled);
}

switch (sdata->type) {
switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_VLAN:
list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
/* no need to tell driver */
Expand All @@ -244,7 +244,7 @@ static int ieee80211_open(struct net_device *dev)
/* fall through */
default:
conf.vif = &sdata->vif;
conf.type = sdata->type;
conf.type = sdata->vif.type;
conf.mac_addr = dev->dev_addr;
res = local->ops->add_interface(local_to_hw(local), &conf);
if (res && !local->open_count && local->ops->stop)
Expand All @@ -256,7 +256,7 @@ static int ieee80211_open(struct net_device *dev)
ieee80211_reset_erp_info(dev);
ieee80211_enable_keys(sdata);

if (sdata->type == IEEE80211_IF_TYPE_STA &&
if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
!(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
netif_carrier_off(dev);
else
Expand Down Expand Up @@ -322,7 +322,7 @@ static int ieee80211_stop(struct net_device *dev)
dev_mc_unsync(local->mdev, dev);

/* down all dependent devices, that is VLANs */
if (sdata->type == IEEE80211_IF_TYPE_AP) {
if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
struct ieee80211_sub_if_data *vlan, *tmp;

list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
Expand All @@ -333,7 +333,7 @@ static int ieee80211_stop(struct net_device *dev)

local->open_count--;

switch (sdata->type) {
switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_VLAN:
list_del(&sdata->u.vlan.list);
sdata->u.vlan.ap = NULL;
Expand Down Expand Up @@ -379,7 +379,7 @@ static int ieee80211_stop(struct net_device *dev)
/* fall through */
default:
conf.vif = &sdata->vif;
conf.type = sdata->type;
conf.type = sdata->vif.type;
conf.mac_addr = dev->dev_addr;
/* disable all keys for as long as this netdev is down */
ieee80211_disable_keys(sdata);
Expand Down Expand Up @@ -502,13 +502,13 @@ static int __ieee80211_if_config(struct net_device *dev,
return 0;

memset(&conf, 0, sizeof(conf));
conf.type = sdata->type;
if (sdata->type == IEEE80211_IF_TYPE_STA ||
sdata->type == IEEE80211_IF_TYPE_IBSS) {
conf.type = sdata->vif.type;
if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
conf.bssid = sdata->u.sta.bssid;
conf.ssid = sdata->u.sta.ssid;
conf.ssid_len = sdata->u.sta.ssid_len;
} else if (sdata->type == IEEE80211_IF_TYPE_AP) {
} else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
conf.ssid = sdata->u.ap.ssid;
conf.ssid_len = sdata->u.ap.ssid_len;
conf.beacon = beacon;
Expand Down Expand Up @@ -703,7 +703,7 @@ static void ieee80211_tasklet_handler(unsigned long data)
case IEEE80211_RX_MSG:
/* status is in skb->cb */
memcpy(&rx_status, skb->cb, sizeof(rx_status));
/* Clear skb->type in order to not confuse kernel
/* Clear skb->pkt_type in order to not confuse kernel
* netstack. */
skb->pkt_type = 0;
__ieee80211_rx(local_to_hw(local), skb, &rx_status);
Expand Down Expand Up @@ -962,7 +962,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
if (!monitors || !skb)
goto out;

if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
if (!netif_running(sdata->dev))
continue;
monitors--;
Expand Down Expand Up @@ -1084,7 +1084,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
mdev->header_ops = &ieee80211_header_ops;
mdev->set_multicast_list = ieee80211_master_set_multicast_list;

sdata->type = IEEE80211_IF_TYPE_AP;
sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = mdev;
sdata->local = local;
sdata->u.ap.force_unicast_rateidx = -1;
Expand Down
1 change: 0 additions & 1 deletion net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ struct ieee80211_if_sta {
#define IEEE80211_SDATA_USERSPACE_MLME BIT(4)
struct ieee80211_sub_if_data {
struct list_head list;
enum ieee80211_if_types type;

struct wireless_dev wdev;

Expand Down
10 changes: 5 additions & 5 deletions net/mac80211/ieee80211_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int ieee80211_if_add(struct net_device *dev, const char *name,
sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
ndev->ieee80211_ptr = &sdata->wdev;
sdata->wdev.wiphy = local->hw.wiphy;
sdata->type = IEEE80211_IF_TYPE_AP;
sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = ndev;
sdata->local = local;
ieee80211_if_sdata_init(sdata);
Expand Down Expand Up @@ -98,7 +98,7 @@ int ieee80211_if_add(struct net_device *dev, const char *name,
void ieee80211_if_set_type(struct net_device *dev, int type)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
int oldtype = sdata->type;
int oldtype = sdata->vif.type;

/*
* We need to call this function on the master interface
Expand All @@ -116,7 +116,7 @@ void ieee80211_if_set_type(struct net_device *dev, int type)

/* most have no BSS pointer */
sdata->bss = NULL;
sdata->type = type;
sdata->vif.type = type;

switch (type) {
case IEEE80211_IF_TYPE_WDS:
Expand Down Expand Up @@ -181,7 +181,7 @@ void ieee80211_if_reinit(struct net_device *dev)

ieee80211_if_sdata_deinit(sdata);

switch (sdata->type) {
switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_INVALID:
/* cannot happen */
WARN_ON(1);
Expand Down Expand Up @@ -279,7 +279,7 @@ int ieee80211_if_remove(struct net_device *dev, const char *name, int id)
ASSERT_RTNL();

list_for_each_entry_safe(sdata, n, &local->interfaces, list) {
if ((sdata->type == id || id == -1) &&
if ((sdata->vif.type == id || id == -1) &&
strcmp(name, sdata->dev->name) == 0 &&
sdata->dev != local->mdev) {
list_del_rcu(&sdata->list);
Expand Down
Loading

0 comments on commit 51fb61e

Please sign in to comment.