Skip to content

Commit

Permalink
mac80211: reduce reliance on netdev
Browse files Browse the repository at this point in the history
For bluetooth 3, we will most likely not have
a netdev for a virtual interface (sdata), so
prepare for that by reducing the reliance on
having a netdev. This patch moves the name
and address fields into the sdata struct and
uses them from there all over. Some work is
needed to keep them sync'ed, but that's not
a lot of work and in slow paths anyway.

In doing so, this also reduces the number of
pointer dereferences in many places, because
of things like sdata->dev->dev_addr becoming
sdata->vif.addr.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Dec 21, 2009
1 parent abe6063 commit 47846c9
Show file tree
Hide file tree
Showing 28 changed files with 223 additions and 207 deletions.
2 changes: 2 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,14 @@ struct ieee80211_conf {
* @type: type of this virtual interface
* @bss_conf: BSS configuration for this interface, either our own
* or the BSS we're associated to
* @addr: address of this interface
* @drv_priv: data area for driver use, will always be aligned to
* sizeof(void *).
*/
struct ieee80211_vif {
enum nl80211_iftype type;
struct ieee80211_bss_conf bss_conf;
u8 addr[ETH_ALEN];
/* must be last */
u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
};
Expand Down
6 changes: 3 additions & 3 deletions net/mac80211/agg-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d

if (!skb) {
printk(KERN_DEBUG "%s: failed to allocate buffer "
"for addba resp frame\n", sdata->dev->name);
"for addba resp frame\n", sdata->name);
return;
}

skb_reserve(skb, local->hw.extra_tx_headroom);
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
memset(mgmt, 0, 24);
memcpy(mgmt->da, da, ETH_ALEN);
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
if (sdata->vif.type == NL80211_IFTYPE_AP ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);

Expand Down
14 changes: 7 additions & 7 deletions net/mac80211/agg-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,

if (!skb) {
printk(KERN_ERR "%s: failed to allocate buffer "
"for addba request frame\n", sdata->dev->name);
"for addba request frame\n", sdata->name);
return;
}
skb_reserve(skb, local->hw.extra_tx_headroom);
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
memset(mgmt, 0, 24);
memcpy(mgmt->da, da, ETH_ALEN);
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
if (sdata->vif.type == NL80211_IFTYPE_AP ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);

Expand Down Expand Up @@ -104,7 +104,7 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1
skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom);
if (!skb) {
printk(KERN_ERR "%s: failed to allocate buffer for "
"bar frame\n", sdata->dev->name);
"bar frame\n", sdata->name);
return;
}
skb_reserve(skb, local->hw.extra_tx_headroom);
Expand All @@ -113,7 +113,7 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1
bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
IEEE80211_STYPE_BACK_REQ);
memcpy(bar->ra, ra, ETH_ALEN);
memcpy(bar->ta, sdata->dev->dev_addr, ETH_ALEN);
memcpy(bar->ta, sdata->vif.addr, ETH_ALEN);
bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL;
bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA;
bar_control |= (u16)(tid << 12);
Expand Down Expand Up @@ -489,7 +489,7 @@ void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif,
#ifdef CONFIG_MAC80211_HT_DEBUG
if (net_ratelimit())
printk(KERN_WARNING "%s: Not enough memory, "
"dropping start BA session", skb->dev->name);
"dropping start BA session", sdata->name);
#endif
return;
}
Expand Down Expand Up @@ -621,7 +621,7 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif,
#ifdef CONFIG_MAC80211_HT_DEBUG
if (net_ratelimit())
printk(KERN_WARNING "%s: Not enough memory, "
"dropping stop BA session", skb->dev->name);
"dropping stop BA session", sdata->name);
#endif
return;
}
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
} else
sdata = IEEE80211_DEV_TO_SUB_IF(dev);

if (compare_ether_addr(mac, dev->dev_addr) == 0)
if (compare_ether_addr(mac, sdata->vif.addr) == 0)
return -EINVAL;

if (is_multicast_ether_addr(mac))
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/debugfs_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ KEY_CONF_FILE(keyidx, D);
KEY_CONF_FILE(hw_key_idx, D);
KEY_FILE(flags, X);
KEY_FILE(tx_rx_count, D);
KEY_READ(ifindex, sdata->dev->ifindex, 20, "%d\n");
KEY_READ(ifindex, sdata->name, IFNAMSIZ + 2, "%s\n");
KEY_OPS(ifindex);

static ssize_t key_algorithm_read(struct file *file,
Expand Down
55 changes: 5 additions & 50 deletions net/mac80211/debugfs_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,11 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
}
}

static int notif_registered;

void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
{
char buf[10+IFNAMSIZ];

if (!notif_registered)
return;

sprintf(buf, "netdev:%s", sdata->dev->name);
sprintf(buf, "netdev:%s", sdata->name);
sdata->debugfs.dir = debugfs_create_dir(buf,
sdata->local->hw.wiphy->debugfsdir);
add_files(sdata);
Expand All @@ -304,58 +299,18 @@ void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
sdata->debugfs.dir = NULL;
}

static int netdev_notify(struct notifier_block *nb,
unsigned long state,
void *ndev)
void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
{
struct net_device *dev = ndev;
struct dentry *dir;
struct ieee80211_sub_if_data *sdata;
char buf[10+IFNAMSIZ];

if (state != NETDEV_CHANGENAME)
return 0;

if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
return 0;

if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
return 0;

sdata = IEEE80211_DEV_TO_SUB_IF(dev);
char buf[10 + IFNAMSIZ];

dir = sdata->debugfs.dir;

if (!dir)
return 0;
return;

sprintf(buf, "netdev:%s", dev->name);
sprintf(buf, "netdev:%s", sdata->name);
if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
"dir to %s\n", buf);

return 0;
}

static struct notifier_block mac80211_debugfs_netdev_notifier = {
.notifier_call = netdev_notify,
};

void ieee80211_debugfs_netdev_init(void)
{
int err;

err = register_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
if (err) {
printk(KERN_ERR
"mac80211: failed to install netdev notifier,"
" disabling per-netdev debugfs!\n");
} else
notif_registered = 1;
}

void ieee80211_debugfs_netdev_exit(void)
{
unregister_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
notif_registered = 0;
}
9 changes: 3 additions & 6 deletions net/mac80211/debugfs_netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
#ifdef CONFIG_MAC80211_DEBUGFS
void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata);
void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata);
void ieee80211_debugfs_netdev_init(void);
void ieee80211_debugfs_netdev_exit(void);
void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata);
#else
static inline void ieee80211_debugfs_add_netdev(
struct ieee80211_sub_if_data *sdata)
{}
static inline void ieee80211_debugfs_remove_netdev(
struct ieee80211_sub_if_data *sdata)
{}
static inline void ieee80211_debugfs_netdev_init(void)
{}

static inline void ieee80211_debugfs_netdev_exit(void)
static inline void ieee80211_debugfs_rename_netdev(
struct ieee80211_sub_if_data *sdata)
{}
#endif

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/debugfs_sta.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static const struct file_operations sta_ ##name## _ops = { \
STA_OPS(name)

STA_FILE(aid, sta.aid, D);
STA_FILE(dev, sdata->dev->name, S);
STA_FILE(dev, sdata->name, S);
STA_FILE(rx_packets, rx_packets, LU);
STA_FILE(tx_packets, tx_packets, LU);
STA_FILE(rx_bytes, rx_bytes, LU);
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/driver-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ static inline int drv_add_interface(struct ieee80211_local *local,
struct ieee80211_if_init_conf *conf)
{
int ret = local->ops->add_interface(&local->hw, conf);
trace_drv_add_interface(local, conf->mac_addr, conf->vif, ret);
trace_drv_add_interface(local, conf->vif, ret);
return ret;
}

static inline void drv_remove_interface(struct ieee80211_local *local,
struct ieee80211_if_init_conf *conf)
{
local->ops->remove_interface(&local->hw, conf);
trace_drv_remove_interface(local, conf->mac_addr, conf->vif);
trace_drv_remove_interface(local, conf->vif);
}

static inline int drv_config(struct ieee80211_local *local, u32 changed)
Expand Down
12 changes: 5 additions & 7 deletions net/mac80211/driver-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ TRACE_EVENT(drv_stop,

TRACE_EVENT(drv_add_interface,
TP_PROTO(struct ieee80211_local *local,
const u8 *addr,
struct ieee80211_vif *vif,
int ret),

TP_ARGS(local, addr, vif, ret),
TP_ARGS(local, vif, ret),

TP_STRUCT__entry(
LOCAL_ENTRY
Expand All @@ -86,7 +85,7 @@ TRACE_EVENT(drv_add_interface,
TP_fast_assign(
LOCAL_ASSIGN;
VIF_ASSIGN;
memcpy(__entry->addr, addr, 6);
memcpy(__entry->addr, vif->addr, 6);
__entry->ret = ret;
),

Expand All @@ -97,10 +96,9 @@ TRACE_EVENT(drv_add_interface,
);

TRACE_EVENT(drv_remove_interface,
TP_PROTO(struct ieee80211_local *local,
const u8 *addr, struct ieee80211_vif *vif),
TP_PROTO(struct ieee80211_local *local, struct ieee80211_vif *vif),

TP_ARGS(local, addr, vif),
TP_ARGS(local, vif),

TP_STRUCT__entry(
LOCAL_ENTRY
Expand All @@ -111,7 +109,7 @@ TRACE_EVENT(drv_remove_interface,
TP_fast_assign(
LOCAL_ASSIGN;
VIF_ASSIGN;
memcpy(__entry->addr, addr, 6);
memcpy(__entry->addr, vif->addr, 6);
),

TP_printk(
Expand Down
6 changes: 3 additions & 3 deletions net/mac80211/ht.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,

if (!skb) {
printk(KERN_ERR "%s: failed to allocate buffer "
"for delba frame\n", sdata->dev->name);
"for delba frame\n", sdata->name);
return;
}

skb_reserve(skb, local->hw.extra_tx_headroom);
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
memset(mgmt, 0, 24);
memcpy(mgmt->da, da, ETH_ALEN);
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
if (sdata->vif.type == NL80211_IFTYPE_AP ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);

Expand Down
Loading

0 comments on commit 47846c9

Please sign in to comment.