aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-07-26 11:24:39 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-10-17 05:02:09 -0400
commit55de908ab292c03f1eb280f51170ddb9c6b57e31 (patch)
treebc75bb5cea581cadf6fe8b4f121cce02d07c276a /net/mac80211/tx.c
parentfe57d9f5c0a2c1ef97ba8cdc42cfda5743f287b8 (diff)
mac80211: use channel contexts
Instead of operating on a single channel only, use the new channel context infrastructure in all mac80211 code. This enables drivers that want to use the new channel context infrastructure to use multiple channels, while nothing should change for all the other drivers that don't support it. Right now this disables both TX power settings and spatial multiplexing powersave. Both need to be re-enabled on a channel context basis. Additionally, when channel contexts are used drop the connection when channel switch is received rather than trying to handle it. This will have to be improved later. [With fixes from Eliad and Emmanuel incorporated] Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r--net/mac80211/tx.c183
1 files changed, 115 insertions, 68 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c9bf83f36657..eee448ac71ff 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -324,11 +324,6 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
324 struct ieee80211_sub_if_data *sdata; 324 struct ieee80211_sub_if_data *sdata;
325 struct sta_info *sta; 325 struct sta_info *sta;
326 326
327 /*
328 * virtual interfaces are protected by RCU
329 */
330 rcu_read_lock();
331
332 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 327 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
333 struct ieee80211_if_ap *ap; 328 struct ieee80211_if_ap *ap;
334 if (sdata->vif.type != NL80211_IFTYPE_AP) 329 if (sdata->vif.type != NL80211_IFTYPE_AP)
@@ -360,8 +355,6 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
360 } 355 }
361 } 356 }
362 357
363 rcu_read_unlock();
364
365 local->total_ps_buffered = total; 358 local->total_ps_buffered = total;
366 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); 359 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged);
367} 360}
@@ -1372,7 +1365,8 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1372 * Returns false if the frame couldn't be transmitted but was queued instead. 1365 * Returns false if the frame couldn't be transmitted but was queued instead.
1373 */ 1366 */
1374static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, 1367static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1375 struct sk_buff *skb, bool txpending) 1368 struct sk_buff *skb, bool txpending,
1369 enum ieee80211_band band)
1376{ 1370{
1377 struct ieee80211_local *local = sdata->local; 1371 struct ieee80211_local *local = sdata->local;
1378 struct ieee80211_tx_data tx; 1372 struct ieee80211_tx_data tx;
@@ -1386,20 +1380,18 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1386 return true; 1380 return true;
1387 } 1381 }
1388 1382
1389 rcu_read_lock();
1390
1391 /* initialises tx */ 1383 /* initialises tx */
1392 led_len = skb->len; 1384 led_len = skb->len;
1393 res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); 1385 res_prepare = ieee80211_tx_prepare(sdata, &tx, skb);
1394 1386
1395 if (unlikely(res_prepare == TX_DROP)) { 1387 if (unlikely(res_prepare == TX_DROP)) {
1396 ieee80211_free_txskb(&local->hw, skb); 1388 ieee80211_free_txskb(&local->hw, skb);
1397 goto out; 1389 return true;
1398 } else if (unlikely(res_prepare == TX_QUEUED)) { 1390 } else if (unlikely(res_prepare == TX_QUEUED)) {
1399 goto out; 1391 return true;
1400 } 1392 }
1401 1393
1402 info->band = local->hw.conf.channel->band; 1394 info->band = band;
1403 1395
1404 /* set up hw_queue value early */ 1396 /* set up hw_queue value early */
1405 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || 1397 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) ||
@@ -1410,8 +1402,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1410 if (!invoke_tx_handlers(&tx)) 1402 if (!invoke_tx_handlers(&tx))
1411 result = __ieee80211_tx(local, &tx.skbs, led_len, 1403 result = __ieee80211_tx(local, &tx.skbs, led_len,
1412 tx.sta, txpending); 1404 tx.sta, txpending);
1413 out: 1405
1414 rcu_read_unlock();
1415 return result; 1406 return result;
1416} 1407}
1417 1408
@@ -1446,7 +1437,8 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
1446 return 0; 1437 return 0;
1447} 1438}
1448 1439
1449void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) 1440void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
1441 enum ieee80211_band band)
1450{ 1442{
1451 struct ieee80211_local *local = sdata->local; 1443 struct ieee80211_local *local = sdata->local;
1452 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1444 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1454,8 +1446,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1454 int headroom; 1446 int headroom;
1455 bool may_encrypt; 1447 bool may_encrypt;
1456 1448
1457 rcu_read_lock();
1458
1459 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); 1449 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT);
1460 1450
1461 headroom = local->tx_headroom; 1451 headroom = local->tx_headroom;
@@ -1466,7 +1456,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1466 1456
1467 if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { 1457 if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
1468 ieee80211_free_txskb(&local->hw, skb); 1458 ieee80211_free_txskb(&local->hw, skb);
1469 rcu_read_unlock();
1470 return; 1459 return;
1471 } 1460 }
1472 1461
@@ -1478,13 +1467,11 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1478 !is_multicast_ether_addr(hdr->addr1) && 1467 !is_multicast_ether_addr(hdr->addr1) &&
1479 mesh_nexthop_resolve(skb, sdata)) { 1468 mesh_nexthop_resolve(skb, sdata)) {
1480 /* skb queued: don't free */ 1469 /* skb queued: don't free */
1481 rcu_read_unlock();
1482 return; 1470 return;
1483 } 1471 }
1484 1472
1485 ieee80211_set_qos_hdr(sdata, skb); 1473 ieee80211_set_qos_hdr(sdata, skb);
1486 ieee80211_tx(sdata, skb, false); 1474 ieee80211_tx(sdata, skb, false, band);
1487 rcu_read_unlock();
1488} 1475}
1489 1476
1490static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) 1477static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb)
@@ -1574,7 +1561,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1574 struct net_device *dev) 1561 struct net_device *dev)
1575{ 1562{
1576 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1563 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1577 struct ieee80211_channel *chan = local->hw.conf.channel; 1564 struct ieee80211_chanctx_conf *chanctx_conf;
1565 struct ieee80211_channel *chan;
1578 struct ieee80211_radiotap_header *prthdr = 1566 struct ieee80211_radiotap_header *prthdr =
1579 (struct ieee80211_radiotap_header *)skb->data; 1567 (struct ieee80211_radiotap_header *)skb->data;
1580 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1568 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1583,26 +1571,6 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1583 u16 len_rthdr; 1571 u16 len_rthdr;
1584 int hdrlen; 1572 int hdrlen;
1585 1573
1586 /*
1587 * Frame injection is not allowed if beaconing is not allowed
1588 * or if we need radar detection. Beaconing is usually not allowed when
1589 * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
1590 * Passive scan is also used in world regulatory domains where
1591 * your country is not known and as such it should be treated as
1592 * NO TX unless the channel is explicitly allowed in which case
1593 * your current regulatory domain would not have the passive scan
1594 * flag.
1595 *
1596 * Since AP mode uses monitor interfaces to inject/TX management
1597 * frames we can make AP mode the exception to this rule once it
1598 * supports radar detection as its implementation can deal with
1599 * radar detection by itself. We can do that later by adding a
1600 * monitor flag interfaces used for AP support.
1601 */
1602 if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
1603 IEEE80211_CHAN_PASSIVE_SCAN)))
1604 goto fail;
1605
1606 /* check for not even having the fixed radiotap header part */ 1574 /* check for not even having the fixed radiotap header part */
1607 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) 1575 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))
1608 goto fail; /* too short to be possibly valid */ 1576 goto fail; /* too short to be possibly valid */
@@ -1688,11 +1656,45 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1688 } 1656 }
1689 } 1657 }
1690 1658
1691 ieee80211_xmit(sdata, skb); 1659 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1660 if (!chanctx_conf) {
1661 tmp_sdata = rcu_dereference(local->monitor_sdata);
1662 if (tmp_sdata)
1663 chanctx_conf =
1664 rcu_dereference(tmp_sdata->vif.chanctx_conf);
1665 }
1666 if (!chanctx_conf)
1667 goto fail_rcu;
1668
1669 chan = chanctx_conf->channel;
1670
1671 /*
1672 * Frame injection is not allowed if beaconing is not allowed
1673 * or if we need radar detection. Beaconing is usually not allowed when
1674 * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
1675 * Passive scan is also used in world regulatory domains where
1676 * your country is not known and as such it should be treated as
1677 * NO TX unless the channel is explicitly allowed in which case
1678 * your current regulatory domain would not have the passive scan
1679 * flag.
1680 *
1681 * Since AP mode uses monitor interfaces to inject/TX management
1682 * frames we can make AP mode the exception to this rule once it
1683 * supports radar detection as its implementation can deal with
1684 * radar detection by itself. We can do that later by adding a
1685 * monitor flag interfaces used for AP support.
1686 */
1687 if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
1688 IEEE80211_CHAN_PASSIVE_SCAN)))
1689 goto fail_rcu;
1690
1691 ieee80211_xmit(sdata, skb, chan->band);
1692 rcu_read_unlock(); 1692 rcu_read_unlock();
1693 1693
1694 return NETDEV_TX_OK; 1694 return NETDEV_TX_OK;
1695 1695
1696fail_rcu:
1697 rcu_read_unlock();
1696fail: 1698fail:
1697 dev_kfree_skb(skb); 1699 dev_kfree_skb(skb);
1698 return NETDEV_TX_OK; /* meaning, we dealt with the skb */ 1700 return NETDEV_TX_OK; /* meaning, we dealt with the skb */
@@ -1734,6 +1736,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1734 bool multicast; 1736 bool multicast;
1735 u32 info_flags = 0; 1737 u32 info_flags = 0;
1736 u16 info_id = 0; 1738 u16 info_id = 0;
1739 struct ieee80211_chanctx_conf *chanctx_conf;
1740 struct ieee80211_sub_if_data *ap_sdata;
1741 enum ieee80211_band band;
1737 1742
1738 if (unlikely(skb->len < ETH_HLEN)) 1743 if (unlikely(skb->len < ETH_HLEN))
1739 goto fail; 1744 goto fail;
@@ -1743,9 +1748,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1743 ethertype = (skb->data[12] << 8) | skb->data[13]; 1748 ethertype = (skb->data[12] << 8) | skb->data[13];
1744 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); 1749 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
1745 1750
1751 rcu_read_lock();
1752
1746 switch (sdata->vif.type) { 1753 switch (sdata->vif.type) {
1747 case NL80211_IFTYPE_AP_VLAN: 1754 case NL80211_IFTYPE_AP_VLAN:
1748 rcu_read_lock();
1749 sta = rcu_dereference(sdata->u.vlan.sta); 1755 sta = rcu_dereference(sdata->u.vlan.sta);
1750 if (sta) { 1756 if (sta) {
1751 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); 1757 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
@@ -1758,7 +1764,12 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1758 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); 1764 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
1759 wme_sta = test_sta_flag(sta, WLAN_STA_WME); 1765 wme_sta = test_sta_flag(sta, WLAN_STA_WME);
1760 } 1766 }
1761 rcu_read_unlock(); 1767 ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
1768 u.ap);
1769 chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf);
1770 if (!chanctx_conf)
1771 goto fail_rcu;
1772 band = chanctx_conf->channel->band;
1762 if (sta) 1773 if (sta)
1763 break; 1774 break;
1764 /* fall through */ 1775 /* fall through */
@@ -1769,6 +1780,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1769 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); 1780 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN);
1770 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); 1781 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
1771 hdrlen = 24; 1782 hdrlen = 24;
1783 if (sdata->vif.type == NL80211_IFTYPE_AP)
1784 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1785 if (!chanctx_conf)
1786 goto fail_rcu;
1787 band = chanctx_conf->channel->band;
1772 break; 1788 break;
1773 case NL80211_IFTYPE_WDS: 1789 case NL80211_IFTYPE_WDS:
1774 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); 1790 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
@@ -1778,15 +1794,20 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1778 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1794 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1779 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); 1795 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
1780 hdrlen = 30; 1796 hdrlen = 30;
1797 /*
1798 * This is the exception! WDS style interfaces are prohibited
1799 * when channel contexts are in used so this must be valid
1800 */
1801 band = local->hw.conf.channel->band;
1781 break; 1802 break;
1782#ifdef CONFIG_MAC80211_MESH 1803#ifdef CONFIG_MAC80211_MESH
1783 case NL80211_IFTYPE_MESH_POINT: 1804 case NL80211_IFTYPE_MESH_POINT:
1784 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { 1805 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) {
1785 /* Do not send frames with mesh_ttl == 0 */ 1806 /* Do not send frames with mesh_ttl == 0 */
1786 sdata->u.mesh.mshstats.dropped_frames_ttl++; 1807 sdata->u.mesh.mshstats.dropped_frames_ttl++;
1787 goto fail; 1808 goto fail_rcu;
1788 } 1809 }
1789 rcu_read_lock(); 1810
1790 if (!is_multicast_ether_addr(skb->data)) { 1811 if (!is_multicast_ether_addr(skb->data)) {
1791 mpath = mesh_path_lookup(skb->data, sdata); 1812 mpath = mesh_path_lookup(skb->data, sdata);
1792 if (!mpath) 1813 if (!mpath)
@@ -1803,7 +1824,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1803 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { 1824 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) {
1804 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1825 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
1805 skb->data, skb->data + ETH_ALEN); 1826 skb->data, skb->data + ETH_ALEN);
1806 rcu_read_unlock();
1807 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, 1827 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr,
1808 sdata, NULL, NULL); 1828 sdata, NULL, NULL);
1809 } else { 1829 } else {
@@ -1819,7 +1839,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1819 mesh_da = mppath->mpp; 1839 mesh_da = mppath->mpp;
1820 else if (mpath) 1840 else if (mpath)
1821 mesh_da = mpath->dst; 1841 mesh_da = mpath->dst;
1822 rcu_read_unlock();
1823 1842
1824 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1843 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
1825 mesh_da, sdata->vif.addr); 1844 mesh_da, sdata->vif.addr);
@@ -1839,13 +1858,16 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1839 skb->data + ETH_ALEN); 1858 skb->data + ETH_ALEN);
1840 1859
1841 } 1860 }
1861 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1862 if (!chanctx_conf)
1863 goto fail_rcu;
1864 band = chanctx_conf->channel->band;
1842 break; 1865 break;
1843#endif 1866#endif
1844 case NL80211_IFTYPE_STATION: 1867 case NL80211_IFTYPE_STATION:
1845 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { 1868 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) {
1846 bool tdls_peer = false; 1869 bool tdls_peer = false;
1847 1870
1848 rcu_read_lock();
1849 sta = sta_info_get(sdata, skb->data); 1871 sta = sta_info_get(sdata, skb->data);
1850 if (sta) { 1872 if (sta) {
1851 authorized = test_sta_flag(sta, 1873 authorized = test_sta_flag(sta,
@@ -1856,7 +1878,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1856 tdls_auth = test_sta_flag(sta, 1878 tdls_auth = test_sta_flag(sta,
1857 WLAN_STA_TDLS_PEER_AUTH); 1879 WLAN_STA_TDLS_PEER_AUTH);
1858 } 1880 }
1859 rcu_read_unlock();
1860 1881
1861 /* 1882 /*
1862 * If the TDLS link is enabled, send everything 1883 * If the TDLS link is enabled, send everything
@@ -1871,7 +1892,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1871 if (tdls_direct) { 1892 if (tdls_direct) {
1872 /* link during setup - throw out frames to peer */ 1893 /* link during setup - throw out frames to peer */
1873 if (!tdls_auth) 1894 if (!tdls_auth)
1874 goto fail; 1895 goto fail_rcu;
1875 1896
1876 /* DA SA BSSID */ 1897 /* DA SA BSSID */
1877 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1898 memcpy(hdr.addr1, skb->data, ETH_ALEN);
@@ -1896,6 +1917,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1896 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1917 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1897 hdrlen = 24; 1918 hdrlen = 24;
1898 } 1919 }
1920 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1921 if (!chanctx_conf)
1922 goto fail_rcu;
1923 band = chanctx_conf->channel->band;
1899 break; 1924 break;
1900 case NL80211_IFTYPE_ADHOC: 1925 case NL80211_IFTYPE_ADHOC:
1901 /* DA SA BSSID */ 1926 /* DA SA BSSID */
@@ -1903,9 +1928,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1903 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1928 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1904 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); 1929 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN);
1905 hdrlen = 24; 1930 hdrlen = 24;
1931 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1932 if (!chanctx_conf)
1933 goto fail_rcu;
1934 band = chanctx_conf->channel->band;
1906 break; 1935 break;
1907 default: 1936 default:
1908 goto fail; 1937 goto fail_rcu;
1909 } 1938 }
1910 1939
1911 /* 1940 /*
@@ -1915,13 +1944,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1915 */ 1944 */
1916 multicast = is_multicast_ether_addr(hdr.addr1); 1945 multicast = is_multicast_ether_addr(hdr.addr1);
1917 if (!multicast) { 1946 if (!multicast) {
1918 rcu_read_lock();
1919 sta = sta_info_get(sdata, hdr.addr1); 1947 sta = sta_info_get(sdata, hdr.addr1);
1920 if (sta) { 1948 if (sta) {
1921 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); 1949 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
1922 wme_sta = test_sta_flag(sta, WLAN_STA_WME); 1950 wme_sta = test_sta_flag(sta, WLAN_STA_WME);
1923 } 1951 }
1924 rcu_read_unlock();
1925 } 1952 }
1926 1953
1927 /* For mesh, the use of the QoS header is mandatory */ 1954 /* For mesh, the use of the QoS header is mandatory */
@@ -1949,7 +1976,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1949 1976
1950 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); 1977 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
1951 1978
1952 goto fail; 1979 goto fail_rcu;
1953 } 1980 }
1954 1981
1955 if (unlikely(!multicast && skb->sk && 1982 if (unlikely(!multicast && skb->sk &&
@@ -2004,7 +2031,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2004 kfree_skb(tmp_skb); 2031 kfree_skb(tmp_skb);
2005 2032
2006 if (!skb) 2033 if (!skb)
2007 goto fail; 2034 goto fail_rcu;
2008 } 2035 }
2009 2036
2010 hdr.frame_control = fc; 2037 hdr.frame_control = fc;
@@ -2052,7 +2079,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2052 head_need = max_t(int, 0, head_need); 2079 head_need = max_t(int, 0, head_need);
2053 if (ieee80211_skb_resize(sdata, skb, head_need, true)) { 2080 if (ieee80211_skb_resize(sdata, skb, head_need, true)) {
2054 ieee80211_free_txskb(&local->hw, skb); 2081 ieee80211_free_txskb(&local->hw, skb);
2055 return NETDEV_TX_OK; 2082 goto fail_rcu;
2056 } 2083 }
2057 } 2084 }
2058 2085
@@ -2104,10 +2131,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2104 info->flags = info_flags; 2131 info->flags = info_flags;
2105 info->ack_frame_id = info_id; 2132 info->ack_frame_id = info_id;
2106 2133
2107 ieee80211_xmit(sdata, skb); 2134 ieee80211_xmit(sdata, skb, band);
2135 rcu_read_unlock();
2108 2136
2109 return NETDEV_TX_OK; 2137 return NETDEV_TX_OK;
2110 2138
2139 fail_rcu:
2140 rcu_read_unlock();
2111 fail: 2141 fail:
2112 dev_kfree_skb(skb); 2142 dev_kfree_skb(skb);
2113 return NETDEV_TX_OK; 2143 return NETDEV_TX_OK;
@@ -2139,11 +2169,18 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
2139 struct sta_info *sta; 2169 struct sta_info *sta;
2140 struct ieee80211_hdr *hdr; 2170 struct ieee80211_hdr *hdr;
2141 bool result; 2171 bool result;
2172 struct ieee80211_chanctx_conf *chanctx_conf;
2142 2173
2143 sdata = vif_to_sdata(info->control.vif); 2174 sdata = vif_to_sdata(info->control.vif);
2144 2175
2145 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { 2176 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) {
2146 result = ieee80211_tx(sdata, skb, true); 2177 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2178 if (unlikely(!chanctx_conf)) {
2179 dev_kfree_skb(skb);
2180 return true;
2181 }
2182 result = ieee80211_tx(sdata, skb, true,
2183 chanctx_conf->channel->band);
2147 } else { 2184 } else {
2148 struct sk_buff_head skbs; 2185 struct sk_buff_head skbs;
2149 2186
@@ -2285,14 +2322,16 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2285 struct ieee80211_sub_if_data *sdata = NULL; 2322 struct ieee80211_sub_if_data *sdata = NULL;
2286 struct ieee80211_if_ap *ap = NULL; 2323 struct ieee80211_if_ap *ap = NULL;
2287 struct beacon_data *beacon; 2324 struct beacon_data *beacon;
2288 enum ieee80211_band band = local->oper_channel->band; 2325 enum ieee80211_band band;
2289 struct ieee80211_tx_rate_control txrc; 2326 struct ieee80211_tx_rate_control txrc;
2327 struct ieee80211_chanctx_conf *chanctx_conf;
2290 2328
2291 rcu_read_lock(); 2329 rcu_read_lock();
2292 2330
2293 sdata = vif_to_sdata(vif); 2331 sdata = vif_to_sdata(vif);
2332 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2294 2333
2295 if (!ieee80211_sdata_running(sdata)) 2334 if (!ieee80211_sdata_running(sdata) || !chanctx_conf)
2296 goto out; 2335 goto out;
2297 2336
2298 if (tim_offset) 2337 if (tim_offset)
@@ -2409,6 +2448,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2409 *pos++ = WLAN_EID_SSID; 2448 *pos++ = WLAN_EID_SSID;
2410 *pos++ = 0x0; 2449 *pos++ = 0x0;
2411 2450
2451 band = chanctx_conf->channel->band;
2452
2412 if (ieee80211_add_srates_ie(sdata, skb, true, band) || 2453 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
2413 mesh_add_ds_params_ie(skb, sdata) || 2454 mesh_add_ds_params_ie(skb, sdata) ||
2414 ieee80211_add_ext_srates_ie(sdata, skb, true, band) || 2455 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
@@ -2426,6 +2467,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2426 goto out; 2467 goto out;
2427 } 2468 }
2428 2469
2470 band = chanctx_conf->channel->band;
2471
2429 info = IEEE80211_SKB_CB(skb); 2472 info = IEEE80211_SKB_CB(skb);
2430 2473
2431 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; 2474 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
@@ -2656,14 +2699,17 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2656 struct ieee80211_if_ap *bss = NULL; 2699 struct ieee80211_if_ap *bss = NULL;
2657 struct beacon_data *beacon; 2700 struct beacon_data *beacon;
2658 struct ieee80211_tx_info *info; 2701 struct ieee80211_tx_info *info;
2702 struct ieee80211_chanctx_conf *chanctx_conf;
2659 2703
2660 sdata = vif_to_sdata(vif); 2704 sdata = vif_to_sdata(vif);
2661 bss = &sdata->u.ap; 2705 bss = &sdata->u.ap;
2662 2706
2663 rcu_read_lock(); 2707 rcu_read_lock();
2664 beacon = rcu_dereference(bss->beacon); 2708 beacon = rcu_dereference(bss->beacon);
2709 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2665 2710
2666 if (sdata->vif.type != NL80211_IFTYPE_AP || !beacon || !beacon->head) 2711 if (sdata->vif.type != NL80211_IFTYPE_AP || !beacon || !beacon->head ||
2712 !chanctx_conf)
2667 goto out; 2713 goto out;
2668 2714
2669 if (bss->dtim_count != 0 || !bss->dtim_bc_mc) 2715 if (bss->dtim_count != 0 || !bss->dtim_bc_mc)
@@ -2693,7 +2739,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2693 info = IEEE80211_SKB_CB(skb); 2739 info = IEEE80211_SKB_CB(skb);
2694 2740
2695 tx.flags |= IEEE80211_TX_PS_BUFFERED; 2741 tx.flags |= IEEE80211_TX_PS_BUFFERED;
2696 info->band = local->oper_channel->band; 2742 info->band = chanctx_conf->channel->band;
2697 2743
2698 if (invoke_tx_handlers(&tx)) 2744 if (invoke_tx_handlers(&tx))
2699 skb = NULL; 2745 skb = NULL;
@@ -2704,8 +2750,9 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2704} 2750}
2705EXPORT_SYMBOL(ieee80211_get_buffered_bc); 2751EXPORT_SYMBOL(ieee80211_get_buffered_bc);
2706 2752
2707void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, 2753void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
2708 struct sk_buff *skb, int tid) 2754 struct sk_buff *skb, int tid,
2755 enum ieee80211_band band)
2709{ 2756{
2710 int ac = ieee802_1d_to_ac[tid & 7]; 2757 int ac = ieee802_1d_to_ac[tid & 7];
2711 2758
@@ -2722,6 +2769,6 @@ void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
2722 * requirements are that we do not come into tx with bhs on. 2769 * requirements are that we do not come into tx with bhs on.
2723 */ 2770 */
2724 local_bh_disable(); 2771 local_bh_disable();
2725 ieee80211_xmit(sdata, skb); 2772 ieee80211_xmit(sdata, skb, band);
2726 local_bh_enable(); 2773 local_bh_enable();
2727} 2774}