aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rx.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-11-25 11:46:19 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-12-21 18:38:52 -0500
commit47846c9b0c10808d9337d2e7d09361f3e0a0a71a (patch)
tree8e5d0dbf3309b7868fa73a888f9561ffea1580e3 /net/mac80211/rx.c
parentabe60632f311d515b082b450504ee24006023951 (diff)
mac80211: reduce reliance on netdev
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>
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r--net/mac80211/rx.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 5bae28693da8..d0136e3da487 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -283,15 +283,15 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
283 skb->protocol = htons(ETH_P_802_2); 283 skb->protocol = htons(ETH_P_802_2);
284 284
285 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 285 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
286 if (!netif_running(sdata->dev))
287 continue;
288
289 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) 286 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
290 continue; 287 continue;
291 288
292 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) 289 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)
293 continue; 290 continue;
294 291
292 if (!netif_running(sdata->dev))
293 continue;
294
295 if (prev_dev) { 295 if (prev_dev) {
296 skb2 = skb_clone(skb, GFP_ATOMIC); 296 skb2 = skb_clone(skb, GFP_ATOMIC);
297 if (skb2) { 297 if (skb2) {
@@ -476,7 +476,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
476{ 476{
477 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 477 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
478 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); 478 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
479 char *dev_addr = rx->sdata->dev->dev_addr; 479 char *dev_addr = rx->sdata->vif.addr;
480 480
481 if (ieee80211_is_data(hdr->frame_control)) { 481 if (ieee80211_is_data(hdr->frame_control)) {
482 if (is_multicast_ether_addr(hdr->addr1)) { 482 if (is_multicast_ether_addr(hdr->addr1)) {
@@ -1024,7 +1024,7 @@ static void ap_sta_ps_start(struct sta_info *sta)
1024 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); 1024 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta);
1025#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1025#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1026 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", 1026 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n",
1027 sdata->dev->name, sta->sta.addr, sta->sta.aid); 1027 sdata->name, sta->sta.addr, sta->sta.aid);
1028#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1028#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1029} 1029}
1030 1030
@@ -1038,13 +1038,13 @@ static void ap_sta_ps_end(struct sta_info *sta)
1038 1038
1039#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1039#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1040 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", 1040 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n",
1041 sdata->dev->name, sta->sta.addr, sta->sta.aid); 1041 sdata->name, sta->sta.addr, sta->sta.aid);
1042#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1042#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1043 1043
1044 if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) { 1044 if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) {
1045#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1045#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1046 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", 1046 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n",
1047 sdata->dev->name, sta->sta.addr, sta->sta.aid); 1047 sdata->name, sta->sta.addr, sta->sta.aid);
1048#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1048#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1049 return; 1049 return;
1050 } 1050 }
@@ -1156,7 +1156,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
1156 printk(KERN_DEBUG "%s: RX reassembly removed oldest " 1156 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
1157 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " 1157 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
1158 "addr1=%pM addr2=%pM\n", 1158 "addr1=%pM addr2=%pM\n",
1159 sdata->dev->name, idx, 1159 sdata->name, idx,
1160 jiffies - entry->first_frag_time, entry->seq, 1160 jiffies - entry->first_frag_time, entry->seq,
1161 entry->last_frag, hdr->addr1, hdr->addr2); 1161 entry->last_frag, hdr->addr1, hdr->addr2);
1162#endif 1162#endif
@@ -1424,7 +1424,6 @@ static int
1424__ieee80211_data_to_8023(struct ieee80211_rx_data *rx) 1424__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
1425{ 1425{
1426 struct ieee80211_sub_if_data *sdata = rx->sdata; 1426 struct ieee80211_sub_if_data *sdata = rx->sdata;
1427 struct net_device *dev = sdata->dev;
1428 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 1427 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
1429 1428
1430 if (ieee80211_has_a4(hdr->frame_control) && 1429 if (ieee80211_has_a4(hdr->frame_control) &&
@@ -1436,7 +1435,7 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
1436 (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) 1435 (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr)))
1437 return -1; 1436 return -1;
1438 1437
1439 return ieee80211_data_to_8023(rx->skb, dev->dev_addr, sdata->vif.type); 1438 return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
1440} 1439}
1441 1440
1442/* 1441/*
@@ -1453,7 +1452,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
1453 * of whether the frame was encrypted or not. 1452 * of whether the frame was encrypted or not.
1454 */ 1453 */
1455 if (ehdr->h_proto == htons(ETH_P_PAE) && 1454 if (ehdr->h_proto == htons(ETH_P_PAE) &&
1456 (compare_ether_addr(ehdr->h_dest, rx->sdata->dev->dev_addr) == 0 || 1455 (compare_ether_addr(ehdr->h_dest, rx->sdata->vif.addr) == 0 ||
1457 compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) 1456 compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0))
1458 return true; 1457 return true;
1459 1458
@@ -1721,7 +1720,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1721 1720
1722 /* Frame has reached destination. Don't forward */ 1721 /* Frame has reached destination. Don't forward */
1723 if (!is_multicast_ether_addr(hdr->addr1) && 1722 if (!is_multicast_ether_addr(hdr->addr1) &&
1724 compare_ether_addr(sdata->dev->dev_addr, hdr->addr3) == 0) 1723 compare_ether_addr(sdata->vif.addr, hdr->addr3) == 0)
1725 return RX_CONTINUE; 1724 return RX_CONTINUE;
1726 1725
1727 mesh_hdr->ttl--; 1726 mesh_hdr->ttl--;
@@ -1738,10 +1737,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1738 1737
1739 if (!fwd_skb && net_ratelimit()) 1738 if (!fwd_skb && net_ratelimit())
1740 printk(KERN_DEBUG "%s: failed to clone mesh frame\n", 1739 printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
1741 sdata->dev->name); 1740 sdata->name);
1742 1741
1743 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; 1742 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
1744 memcpy(fwd_hdr->addr2, sdata->dev->dev_addr, ETH_ALEN); 1743 memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN);
1745 info = IEEE80211_SKB_CB(fwd_skb); 1744 info = IEEE80211_SKB_CB(fwd_skb);
1746 memset(info, 0, sizeof(*info)); 1745 memset(info, 0, sizeof(*info));
1747 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1746 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
@@ -1870,7 +1869,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
1870 struct sk_buff *skb; 1869 struct sk_buff *skb;
1871 struct ieee80211_mgmt *resp; 1870 struct ieee80211_mgmt *resp;
1872 1871
1873 if (compare_ether_addr(mgmt->da, sdata->dev->dev_addr) != 0) { 1872 if (compare_ether_addr(mgmt->da, sdata->vif.addr) != 0) {
1874 /* Not to own unicast address */ 1873 /* Not to own unicast address */
1875 return; 1874 return;
1876 } 1875 }
@@ -1894,7 +1893,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
1894 resp = (struct ieee80211_mgmt *) skb_put(skb, 24); 1893 resp = (struct ieee80211_mgmt *) skb_put(skb, 24);
1895 memset(resp, 0, 24); 1894 memset(resp, 0, 24);
1896 memcpy(resp->da, mgmt->sa, ETH_ALEN); 1895 memcpy(resp->da, mgmt->sa, ETH_ALEN);
1897 memcpy(resp->sa, sdata->dev->dev_addr, ETH_ALEN); 1896 memcpy(resp->sa, sdata->vif.addr, ETH_ALEN);
1898 memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); 1897 memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1899 resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 1898 resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1900 IEEE80211_STYPE_ACTION); 1899 IEEE80211_STYPE_ACTION);
@@ -2274,7 +2273,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2274 if (!bssid && !sdata->u.mgd.use_4addr) 2273 if (!bssid && !sdata->u.mgd.use_4addr)
2275 return 0; 2274 return 0;
2276 if (!multicast && 2275 if (!multicast &&
2277 compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) { 2276 compare_ether_addr(sdata->vif.addr, hdr->addr1) != 0) {
2278 if (!(sdata->dev->flags & IFF_PROMISC)) 2277 if (!(sdata->dev->flags & IFF_PROMISC))
2279 return 0; 2278 return 0;
2280 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2279 rx->flags &= ~IEEE80211_RX_RA_MATCH;
@@ -2291,7 +2290,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2291 return 0; 2290 return 0;
2292 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2291 rx->flags &= ~IEEE80211_RX_RA_MATCH;
2293 } else if (!multicast && 2292 } else if (!multicast &&
2294 compare_ether_addr(sdata->dev->dev_addr, 2293 compare_ether_addr(sdata->vif.addr,
2295 hdr->addr1) != 0) { 2294 hdr->addr1) != 0) {
2296 if (!(sdata->dev->flags & IFF_PROMISC)) 2295 if (!(sdata->dev->flags & IFF_PROMISC))
2297 return 0; 2296 return 0;
@@ -2308,7 +2307,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2308 break; 2307 break;
2309 case NL80211_IFTYPE_MESH_POINT: 2308 case NL80211_IFTYPE_MESH_POINT:
2310 if (!multicast && 2309 if (!multicast &&
2311 compare_ether_addr(sdata->dev->dev_addr, 2310 compare_ether_addr(sdata->vif.addr,
2312 hdr->addr1) != 0) { 2311 hdr->addr1) != 0) {
2313 if (!(sdata->dev->flags & IFF_PROMISC)) 2312 if (!(sdata->dev->flags & IFF_PROMISC))
2314 return 0; 2313 return 0;
@@ -2319,11 +2318,11 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2319 case NL80211_IFTYPE_AP_VLAN: 2318 case NL80211_IFTYPE_AP_VLAN:
2320 case NL80211_IFTYPE_AP: 2319 case NL80211_IFTYPE_AP:
2321 if (!bssid) { 2320 if (!bssid) {
2322 if (compare_ether_addr(sdata->dev->dev_addr, 2321 if (compare_ether_addr(sdata->vif.addr,
2323 hdr->addr1)) 2322 hdr->addr1))
2324 return 0; 2323 return 0;
2325 } else if (!ieee80211_bssid_match(bssid, 2324 } else if (!ieee80211_bssid_match(bssid,
2326 sdata->dev->dev_addr)) { 2325 sdata->vif.addr)) {
2327 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 2326 if (!(rx->flags & IEEE80211_RX_IN_SCAN))
2328 return 0; 2327 return 0;
2329 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2328 rx->flags &= ~IEEE80211_RX_RA_MATCH;
@@ -2444,7 +2443,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2444 printk(KERN_DEBUG "%s: failed to copy " 2443 printk(KERN_DEBUG "%s: failed to copy "
2445 "multicast frame for %s\n", 2444 "multicast frame for %s\n",
2446 wiphy_name(local->hw.wiphy), 2445 wiphy_name(local->hw.wiphy),
2447 prev->dev->name); 2446 prev->name);
2448 continue; 2447 continue;
2449 } 2448 }
2450 ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); 2449 ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate);