aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r--net/mac80211/tx.c122
1 files changed, 92 insertions, 30 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 37e3d5ef7e3..457238a2f3f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -35,6 +35,7 @@
35#define IEEE80211_TX_OK 0 35#define IEEE80211_TX_OK 0
36#define IEEE80211_TX_AGAIN 1 36#define IEEE80211_TX_AGAIN 1
37#define IEEE80211_TX_FRAG_AGAIN 2 37#define IEEE80211_TX_FRAG_AGAIN 2
38#define IEEE80211_TX_PENDING 3
38 39
39/* misc utils */ 40/* misc utils */
40 41
@@ -330,6 +331,22 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
330 return TX_CONTINUE; 331 return TX_CONTINUE;
331} 332}
332 333
334static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta,
335 struct sk_buff *skb)
336{
337 if (!ieee80211_is_mgmt(fc))
338 return 0;
339
340 if (sta == NULL || !test_sta_flags(sta, WLAN_STA_MFP))
341 return 0;
342
343 if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *)
344 skb->data))
345 return 0;
346
347 return 1;
348}
349
333static ieee80211_tx_result 350static ieee80211_tx_result
334ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) 351ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
335{ 352{
@@ -409,11 +426,17 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
409 tx->key = NULL; 426 tx->key = NULL;
410 else if (tx->sta && (key = rcu_dereference(tx->sta->key))) 427 else if (tx->sta && (key = rcu_dereference(tx->sta->key)))
411 tx->key = key; 428 tx->key = key;
429 else if (ieee80211_is_mgmt(hdr->frame_control) &&
430 (key = rcu_dereference(tx->sdata->default_mgmt_key)))
431 tx->key = key;
412 else if ((key = rcu_dereference(tx->sdata->default_key))) 432 else if ((key = rcu_dereference(tx->sdata->default_key)))
413 tx->key = key; 433 tx->key = key;
414 else if (tx->sdata->drop_unencrypted && 434 else if (tx->sdata->drop_unencrypted &&
415 (tx->skb->protocol != cpu_to_be16(ETH_P_PAE)) && 435 (tx->skb->protocol != cpu_to_be16(ETH_P_PAE)) &&
416 !(info->flags & IEEE80211_TX_CTL_INJECTED)) { 436 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
437 (!ieee80211_is_robust_mgmt_frame(hdr) ||
438 (ieee80211_is_action(hdr->frame_control) &&
439 tx->sta && test_sta_flags(tx->sta, WLAN_STA_MFP)))) {
417 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); 440 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
418 return TX_DROP; 441 return TX_DROP;
419 } else 442 } else
@@ -428,10 +451,19 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
428 if (ieee80211_is_auth(hdr->frame_control)) 451 if (ieee80211_is_auth(hdr->frame_control))
429 break; 452 break;
430 case ALG_TKIP: 453 case ALG_TKIP:
431 case ALG_CCMP:
432 if (!ieee80211_is_data_present(hdr->frame_control)) 454 if (!ieee80211_is_data_present(hdr->frame_control))
433 tx->key = NULL; 455 tx->key = NULL;
434 break; 456 break;
457 case ALG_CCMP:
458 if (!ieee80211_is_data_present(hdr->frame_control) &&
459 !ieee80211_use_mfp(hdr->frame_control, tx->sta,
460 tx->skb))
461 tx->key = NULL;
462 break;
463 case ALG_AES_CMAC:
464 if (!ieee80211_is_mgmt(hdr->frame_control))
465 tx->key = NULL;
466 break;
435 } 467 }
436 } 468 }
437 469
@@ -789,6 +821,8 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
789 return ieee80211_crypto_tkip_encrypt(tx); 821 return ieee80211_crypto_tkip_encrypt(tx);
790 case ALG_CCMP: 822 case ALG_CCMP:
791 return ieee80211_crypto_ccmp_encrypt(tx); 823 return ieee80211_crypto_ccmp_encrypt(tx);
824 case ALG_AES_CMAC:
825 return ieee80211_crypto_aes_cmac_encrypt(tx);
792 } 826 }
793 827
794 /* not reached */ 828 /* not reached */
@@ -844,7 +878,6 @@ ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
844 return TX_CONTINUE; 878 return TX_CONTINUE;
845} 879}
846 880
847
848/* actual transmit path */ 881/* actual transmit path */
849 882
850/* 883/*
@@ -984,12 +1017,20 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
984 tx->sta = sta_info_get(local, hdr->addr1); 1017 tx->sta = sta_info_get(local, hdr->addr1);
985 1018
986 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control)) { 1019 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control)) {
1020 unsigned long flags;
987 qc = ieee80211_get_qos_ctl(hdr); 1021 qc = ieee80211_get_qos_ctl(hdr);
988 tid = *qc & IEEE80211_QOS_CTL_TID_MASK; 1022 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
989 1023
1024 spin_lock_irqsave(&tx->sta->lock, flags);
990 state = &tx->sta->ampdu_mlme.tid_state_tx[tid]; 1025 state = &tx->sta->ampdu_mlme.tid_state_tx[tid];
991 if (*state == HT_AGG_STATE_OPERATIONAL) 1026 if (*state == HT_AGG_STATE_OPERATIONAL) {
992 info->flags |= IEEE80211_TX_CTL_AMPDU; 1027 info->flags |= IEEE80211_TX_CTL_AMPDU;
1028 if (local->hw.ampdu_queues)
1029 skb_set_queue_mapping(
1030 skb, tx->local->hw.queues +
1031 tx->sta->tid_to_tx_q[tid]);
1032 }
1033 spin_unlock_irqrestore(&tx->sta->lock, flags);
993 } 1034 }
994 1035
995 if (is_multicast_ether_addr(hdr->addr1)) { 1036 if (is_multicast_ether_addr(hdr->addr1)) {
@@ -1053,9 +1094,9 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
1053 int ret, i; 1094 int ret, i;
1054 1095
1055 if (skb) { 1096 if (skb) {
1056 if (netif_subqueue_stopped(local->mdev, skb)) 1097 if (ieee80211_queue_stopped(&local->hw,
1057 return IEEE80211_TX_AGAIN; 1098 skb_get_queue_mapping(skb)))
1058 info = IEEE80211_SKB_CB(skb); 1099 return IEEE80211_TX_PENDING;
1059 1100
1060 ret = local->ops->tx(local_to_hw(local), skb); 1101 ret = local->ops->tx(local_to_hw(local), skb);
1061 if (ret) 1102 if (ret)
@@ -1070,8 +1111,8 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
1070 info = IEEE80211_SKB_CB(tx->extra_frag[i]); 1111 info = IEEE80211_SKB_CB(tx->extra_frag[i]);
1071 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | 1112 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
1072 IEEE80211_TX_CTL_FIRST_FRAGMENT); 1113 IEEE80211_TX_CTL_FIRST_FRAGMENT);
1073 if (netif_subqueue_stopped(local->mdev, 1114 if (ieee80211_queue_stopped(&local->hw,
1074 tx->extra_frag[i])) 1115 skb_get_queue_mapping(tx->extra_frag[i])))
1075 return IEEE80211_TX_FRAG_AGAIN; 1116 return IEEE80211_TX_FRAG_AGAIN;
1076 1117
1077 ret = local->ops->tx(local_to_hw(local), 1118 ret = local->ops->tx(local_to_hw(local),
@@ -1181,8 +1222,9 @@ retry:
1181 * queues, there's no reason for a driver to reject 1222 * queues, there's no reason for a driver to reject
1182 * a frame there, warn and drop it. 1223 * a frame there, warn and drop it.
1183 */ 1224 */
1184 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) 1225 if (ret != IEEE80211_TX_PENDING)
1185 goto drop; 1226 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
1227 goto drop;
1186 1228
1187 store = &local->pending_packet[queue]; 1229 store = &local->pending_packet[queue];
1188 1230
@@ -1298,6 +1340,19 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
1298 return 0; 1340 return 0;
1299 } 1341 }
1300 1342
1343 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
1344 local->hw.conf.dynamic_ps_timeout > 0) {
1345 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
1346 ieee80211_stop_queues_by_reason(&local->hw,
1347 IEEE80211_QUEUE_STOP_REASON_PS);
1348 queue_work(local->hw.workqueue,
1349 &local->dynamic_ps_disable_work);
1350 }
1351
1352 mod_timer(&local->dynamic_ps_timer, jiffies +
1353 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
1354 }
1355
1301 memset(info, 0, sizeof(*info)); 1356 memset(info, 0, sizeof(*info));
1302 1357
1303 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1358 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
@@ -1392,10 +1447,31 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
1392 struct net_device *dev) 1447 struct net_device *dev)
1393{ 1448{
1394 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1449 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1450 struct ieee80211_channel *chan = local->hw.conf.channel;
1395 struct ieee80211_radiotap_header *prthdr = 1451 struct ieee80211_radiotap_header *prthdr =
1396 (struct ieee80211_radiotap_header *)skb->data; 1452 (struct ieee80211_radiotap_header *)skb->data;
1397 u16 len_rthdr; 1453 u16 len_rthdr;
1398 1454
1455 /*
1456 * Frame injection is not allowed if beaconing is not allowed
1457 * or if we need radar detection. Beaconing is usually not allowed when
1458 * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
1459 * Passive scan is also used in world regulatory domains where
1460 * your country is not known and as such it should be treated as
1461 * NO TX unless the channel is explicitly allowed in which case
1462 * your current regulatory domain would not have the passive scan
1463 * flag.
1464 *
1465 * Since AP mode uses monitor interfaces to inject/TX management
1466 * frames we can make AP mode the exception to this rule once it
1467 * supports radar detection as its implementation can deal with
1468 * radar detection by itself. We can do that later by adding a
1469 * monitor flag interfaces used for AP support.
1470 */
1471 if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
1472 IEEE80211_CHAN_PASSIVE_SCAN)))
1473 goto fail;
1474
1399 /* check for not even having the fixed radiotap header part */ 1475 /* check for not even having the fixed radiotap header part */
1400 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) 1476 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))
1401 goto fail; /* too short to be possibly valid */ 1477 goto fail; /* too short to be possibly valid */
@@ -1479,19 +1555,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1479 goto fail; 1555 goto fail;
1480 } 1556 }
1481 1557
1482 if (!(local->hw.flags & IEEE80211_HW_NO_STACK_DYNAMIC_PS) &&
1483 local->dynamic_ps_timeout > 0) {
1484 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
1485 ieee80211_stop_queues_by_reason(&local->hw,
1486 IEEE80211_QUEUE_STOP_REASON_PS);
1487 queue_work(local->hw.workqueue,
1488 &local->dynamic_ps_disable_work);
1489 }
1490
1491 mod_timer(&local->dynamic_ps_timer, jiffies +
1492 msecs_to_jiffies(local->dynamic_ps_timeout));
1493 }
1494
1495 nh_pos = skb_network_header(skb) - skb->data; 1558 nh_pos = skb_network_header(skb) - skb->data;
1496 h_pos = skb_transport_header(skb) - skb->data; 1559 h_pos = skb_transport_header(skb) - skb->data;
1497 1560
@@ -1572,7 +1635,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1572 case NL80211_IFTYPE_STATION: 1635 case NL80211_IFTYPE_STATION:
1573 fc |= cpu_to_le16(IEEE80211_FCTL_TODS); 1636 fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
1574 /* BSSID SA DA */ 1637 /* BSSID SA DA */
1575 memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN); 1638 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN);
1576 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1639 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1577 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1640 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1578 hdrlen = 24; 1641 hdrlen = 24;
@@ -1581,7 +1644,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1581 /* DA SA BSSID */ 1644 /* DA SA BSSID */
1582 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1645 memcpy(hdr.addr1, skb->data, ETH_ALEN);
1583 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1646 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1584 memcpy(hdr.addr3, sdata->u.sta.bssid, ETH_ALEN); 1647 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN);
1585 hdrlen = 24; 1648 hdrlen = 24;
1586 break; 1649 break;
1587 default: 1650 default:
@@ -1867,7 +1930,6 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1867 struct ieee80211_tx_info *info; 1930 struct ieee80211_tx_info *info;
1868 struct ieee80211_sub_if_data *sdata = NULL; 1931 struct ieee80211_sub_if_data *sdata = NULL;
1869 struct ieee80211_if_ap *ap = NULL; 1932 struct ieee80211_if_ap *ap = NULL;
1870 struct ieee80211_if_sta *ifsta = NULL;
1871 struct beacon_data *beacon; 1933 struct beacon_data *beacon;
1872 struct ieee80211_supported_band *sband; 1934 struct ieee80211_supported_band *sband;
1873 enum ieee80211_band band = local->hw.conf.channel->band; 1935 enum ieee80211_band band = local->hw.conf.channel->band;
@@ -1919,13 +1981,13 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1919 } else 1981 } else
1920 goto out; 1982 goto out;
1921 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1983 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1984 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
1922 struct ieee80211_hdr *hdr; 1985 struct ieee80211_hdr *hdr;
1923 ifsta = &sdata->u.sta;
1924 1986
1925 if (!ifsta->probe_resp) 1987 if (!ifibss->probe_resp)
1926 goto out; 1988 goto out;
1927 1989
1928 skb = skb_copy(ifsta->probe_resp, GFP_ATOMIC); 1990 skb = skb_copy(ifibss->probe_resp, GFP_ATOMIC);
1929 if (!skb) 1991 if (!skb)
1930 goto out; 1992 goto out;
1931 1993