aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/adm8211.c4
-rw-r--r--drivers/net/wireless/at76c50x-usb.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c9
-rw-r--r--drivers/net/wireless/ath/carl9170/carl9170.h4
-rw-r--r--drivers/net/wireless/ath/carl9170/tx.c16
-rw-r--r--drivers/net/wireless/b43/main.c3
-rw-r--r--drivers/net/wireless/b43legacy/main.c1
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c6
-rw-r--r--drivers/net/wireless/iwlegacy/3945-mac.c12
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c26
-rw-r--r--drivers/net/wireless/iwlegacy/4965.h8
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/agn.h4
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c6
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/tx.c16
-rw-r--r--drivers/net/wireless/libertas_tf/main.c4
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c8
-rw-r--r--drivers/net/wireless/mwl8k.c17
-rw-r--r--drivers/net/wireless/p54/lmac.h4
-rw-r--r--drivers/net/wireless/p54/main.c2
-rw-r--r--drivers/net/wireless/p54/txrx.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c20
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/dev.c6
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187/dev.c6
-rw-r--r--drivers/net/wireless/rtlwifi/base.c3
-rw-r--r--drivers/net/wireless/rtlwifi/core.c8
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c16
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.h4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.h1
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c15
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h13
-rw-r--r--drivers/net/wireless/ti/wl1251/main.c4
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c6
-rw-r--r--drivers/net/wireless/ti/wlcore/tx.c61
-rw-r--r--drivers/net/wireless/ti/wlcore/tx.h4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c6
-rw-r--r--drivers/staging/winbond/wbusb.c4
-rw-r--r--include/linux/nl80211.h30
-rw-r--r--include/net/cfg80211.h40
-rw-r--r--include/net/ieee80211_radiotap.h11
-rw-r--r--include/net/mac80211.h87
-rw-r--r--net/mac80211/aes_cmac.c6
-rw-r--r--net/mac80211/cfg.c68
-rw-r--r--net/mac80211/debugfs.c32
-rw-r--r--net/mac80211/driver-ops.h11
-rw-r--r--net/mac80211/ibss.c15
-rw-r--r--net/mac80211/ieee80211_i.h30
-rw-r--r--net/mac80211/iface.c289
-rw-r--r--net/mac80211/main.c21
-rw-r--r--net/mac80211/mesh.c28
-rw-r--r--net/mac80211/mesh.h3
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mesh_pathtbl.c44
-rw-r--r--net/mac80211/mesh_plink.c38
-rw-r--r--net/mac80211/mlme.c240
-rw-r--r--net/mac80211/offchannel.c6
-rw-r--r--net/mac80211/rate.h2
-rw-r--r--net/mac80211/rx.c58
-rw-r--r--net/mac80211/scan.c12
-rw-r--r--net/mac80211/status.c22
-rw-r--r--net/mac80211/trace.h11
-rw-r--r--net/mac80211/tx.c71
-rw-r--r--net/mac80211/util.c57
-rw-r--r--net/wireless/chan.c7
-rw-r--r--net/wireless/core.c53
-rw-r--r--net/wireless/mlme.c10
-rw-r--r--net/wireless/nl80211.c122
-rw-r--r--net/wireless/radiotap.c2
-rw-r--r--net/wireless/util.c36
84 files changed, 1245 insertions, 617 deletions
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 689a71c1af71..154a4965be4f 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1661,7 +1661,9 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
1661} 1661}
1662 1662
1663/* Put adm8211_tx_hdr on skb and transmit */ 1663/* Put adm8211_tx_hdr on skb and transmit */
1664static void adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 1664static void adm8211_tx(struct ieee80211_hw *dev,
1665 struct ieee80211_tx_control *control,
1666 struct sk_buff *skb)
1665{ 1667{
1666 struct adm8211_tx_hdr *txhdr; 1668 struct adm8211_tx_hdr *txhdr;
1667 size_t payload_len, hdrlen; 1669 size_t payload_len, hdrlen;
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index efc162e0b511..abb520dec032 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -1726,7 +1726,9 @@ static void at76_mac80211_tx_callback(struct urb *urb)
1726 ieee80211_wake_queues(priv->hw); 1726 ieee80211_wake_queues(priv->hw);
1727} 1727}
1728 1728
1729static void at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 1729static void at76_mac80211_tx(struct ieee80211_hw *hw,
1730 struct ieee80211_tx_control *control,
1731 struct sk_buff *skb)
1730{ 1732{
1731 struct at76_priv *priv = hw->priv; 1733 struct at76_priv *priv = hw->priv;
1732 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer; 1734 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer;
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index 92ee3a0a5192..c89fa6ead615 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -55,7 +55,8 @@
55\********************/ 55\********************/
56 56
57static void 57static void
58ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 58ath5k_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
59 struct sk_buff *skb)
59{ 60{
60 struct ath5k_hw *ah = hw->priv; 61 struct ath5k_hw *ah = hw->priv;
61 u16 qnum = skb_get_queue_mapping(skb); 62 u16 qnum = skb_get_queue_mapping(skb);
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index b09285c36c4a..7373e4b92c92 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -280,6 +280,7 @@ struct ath_tx_control {
280 struct ath_txq *txq; 280 struct ath_txq *txq;
281 struct ath_node *an; 281 struct ath_node *an;
282 u8 paprd; 282 u8 paprd;
283 struct ieee80211_sta *sta;
283}; 284};
284 285
285#define ATH_TX_ERROR 0x01 286#define ATH_TX_ERROR 0x01
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 936e920fb88e..b30596fcf73a 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -542,6 +542,7 @@ void ath9k_htc_stop_ani(struct ath9k_htc_priv *priv);
542 542
543int ath9k_tx_init(struct ath9k_htc_priv *priv); 543int ath9k_tx_init(struct ath9k_htc_priv *priv);
544int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, 544int ath9k_htc_tx_start(struct ath9k_htc_priv *priv,
545 struct ieee80211_sta *sta,
545 struct sk_buff *skb, u8 slot, bool is_cab); 546 struct sk_buff *skb, u8 slot, bool is_cab);
546void ath9k_tx_cleanup(struct ath9k_htc_priv *priv); 547void ath9k_tx_cleanup(struct ath9k_htc_priv *priv);
547bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv, int subtype); 548bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv, int subtype);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
index 77d541feb910..f42d2eb6af99 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
@@ -326,7 +326,7 @@ static void ath9k_htc_send_buffered(struct ath9k_htc_priv *priv,
326 goto next; 326 goto next;
327 } 327 }
328 328
329 ret = ath9k_htc_tx_start(priv, skb, tx_slot, true); 329 ret = ath9k_htc_tx_start(priv, NULL, skb, tx_slot, true);
330 if (ret != 0) { 330 if (ret != 0) {
331 ath9k_htc_tx_clear_slot(priv, tx_slot); 331 ath9k_htc_tx_clear_slot(priv, tx_slot);
332 dev_kfree_skb_any(skb); 332 dev_kfree_skb_any(skb);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index c785129692ff..8a0ccf70aa14 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -856,7 +856,9 @@ set_timer:
856/* mac80211 Callbacks */ 856/* mac80211 Callbacks */
857/**********************/ 857/**********************/
858 858
859static void ath9k_htc_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 859static void ath9k_htc_tx(struct ieee80211_hw *hw,
860 struct ieee80211_tx_control *control,
861 struct sk_buff *skb)
860{ 862{
861 struct ieee80211_hdr *hdr; 863 struct ieee80211_hdr *hdr;
862 struct ath9k_htc_priv *priv = hw->priv; 864 struct ath9k_htc_priv *priv = hw->priv;
@@ -883,7 +885,7 @@ static void ath9k_htc_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
883 goto fail_tx; 885 goto fail_tx;
884 } 886 }
885 887
886 ret = ath9k_htc_tx_start(priv, skb, slot, false); 888 ret = ath9k_htc_tx_start(priv, control->sta, skb, slot, false);
887 if (ret != 0) { 889 if (ret != 0) {
888 ath_dbg(common, XMIT, "Tx failed\n"); 890 ath_dbg(common, XMIT, "Tx failed\n");
889 goto clear_slot; 891 goto clear_slot;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 47e61d0da33b..06cdcb772d78 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -333,12 +333,12 @@ static void ath9k_htc_tx_data(struct ath9k_htc_priv *priv,
333} 333}
334 334
335int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, 335int ath9k_htc_tx_start(struct ath9k_htc_priv *priv,
336 struct ieee80211_sta *sta,
336 struct sk_buff *skb, 337 struct sk_buff *skb,
337 u8 slot, bool is_cab) 338 u8 slot, bool is_cab)
338{ 339{
339 struct ieee80211_hdr *hdr; 340 struct ieee80211_hdr *hdr;
340 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 341 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
341 struct ieee80211_sta *sta = tx_info->control.sta;
342 struct ieee80211_vif *vif = tx_info->control.vif; 342 struct ieee80211_vif *vif = tx_info->control.vif;
343 struct ath9k_htc_sta *ista; 343 struct ath9k_htc_sta *ista;
344 struct ath9k_htc_vif *avp = NULL; 344 struct ath9k_htc_vif *avp = NULL;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 6049d8b82855..4d8dc9ff5a75 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -694,7 +694,9 @@ mutex_unlock:
694 return r; 694 return r;
695} 695}
696 696
697static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 697static void ath9k_tx(struct ieee80211_hw *hw,
698 struct ieee80211_tx_control *control,
699 struct sk_buff *skb)
698{ 700{
699 struct ath_softc *sc = hw->priv; 701 struct ath_softc *sc = hw->priv;
700 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 702 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -754,6 +756,7 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
754 756
755 memset(&txctl, 0, sizeof(struct ath_tx_control)); 757 memset(&txctl, 0, sizeof(struct ath_tx_control));
756 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)]; 758 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
759 txctl.sta = control->sta;
757 760
758 ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb); 761 ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb);
759 762
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 2c9da6b2ecb1..ef91f6cc2d79 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1773,11 +1773,12 @@ static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1773 TX_STAT_INC(txq->axq_qnum, queued); 1773 TX_STAT_INC(txq->axq_qnum, queued);
1774} 1774}
1775 1775
1776static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb, 1776static void setup_frame_info(struct ieee80211_hw *hw,
1777 struct ieee80211_sta *sta,
1778 struct sk_buff *skb,
1777 int framelen) 1779 int framelen)
1778{ 1780{
1779 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1781 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1780 struct ieee80211_sta *sta = tx_info->control.sta;
1781 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; 1782 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
1782 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1783 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1783 const struct ieee80211_rate *rate; 1784 const struct ieee80211_rate *rate;
@@ -1935,7 +1936,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1935{ 1936{
1936 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1937 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1937 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1938 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1938 struct ieee80211_sta *sta = info->control.sta; 1939 struct ieee80211_sta *sta = txctl->sta;
1939 struct ieee80211_vif *vif = info->control.vif; 1940 struct ieee80211_vif *vif = info->control.vif;
1940 struct ath_softc *sc = hw->priv; 1941 struct ath_softc *sc = hw->priv;
1941 struct ath_txq *txq = txctl->txq; 1942 struct ath_txq *txq = txctl->txq;
@@ -1979,7 +1980,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1979 !ieee80211_is_data(hdr->frame_control)) 1980 !ieee80211_is_data(hdr->frame_control))
1980 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; 1981 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
1981 1982
1982 setup_frame_info(hw, skb, frmlen); 1983 setup_frame_info(hw, sta, skb, frmlen);
1983 1984
1984 /* 1985 /*
1985 * At this point, the vif, hw_key and sta pointers in the tx control 1986 * At this point, the vif, hw_key and sta pointers in the tx control
diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index 376be11161c0..8f0cbc35816f 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -577,7 +577,9 @@ void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len);
577void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len); 577void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
578 578
579/* TX */ 579/* TX */
580void carl9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb); 580void carl9170_op_tx(struct ieee80211_hw *hw,
581 struct ieee80211_tx_control *control,
582 struct sk_buff *skb);
581void carl9170_tx_janitor(struct work_struct *work); 583void carl9170_tx_janitor(struct work_struct *work);
582void carl9170_tx_process_status(struct ar9170 *ar, 584void carl9170_tx_process_status(struct ar9170 *ar,
583 const struct carl9170_rsp *cmd); 585 const struct carl9170_rsp *cmd);
diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
index 6a8681407a1d..84377cf580e0 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -867,14 +867,15 @@ static bool carl9170_tx_cts_check(struct ar9170 *ar,
867 return false; 867 return false;
868} 868}
869 869
870static int carl9170_tx_prepare(struct ar9170 *ar, struct sk_buff *skb) 870static int carl9170_tx_prepare(struct ar9170 *ar,
871 struct ieee80211_sta *sta,
872 struct sk_buff *skb)
871{ 873{
872 struct ieee80211_hdr *hdr; 874 struct ieee80211_hdr *hdr;
873 struct _carl9170_tx_superframe *txc; 875 struct _carl9170_tx_superframe *txc;
874 struct carl9170_vif_info *cvif; 876 struct carl9170_vif_info *cvif;
875 struct ieee80211_tx_info *info; 877 struct ieee80211_tx_info *info;
876 struct ieee80211_tx_rate *txrate; 878 struct ieee80211_tx_rate *txrate;
877 struct ieee80211_sta *sta;
878 struct carl9170_tx_info *arinfo; 879 struct carl9170_tx_info *arinfo;
879 unsigned int hw_queue; 880 unsigned int hw_queue;
880 int i; 881 int i;
@@ -910,8 +911,6 @@ static int carl9170_tx_prepare(struct ar9170 *ar, struct sk_buff *skb)
910 else 911 else
911 cvif = NULL; 912 cvif = NULL;
912 913
913 sta = info->control.sta;
914
915 txc = (void *)skb_push(skb, sizeof(*txc)); 914 txc = (void *)skb_push(skb, sizeof(*txc));
916 memset(txc, 0, sizeof(*txc)); 915 memset(txc, 0, sizeof(*txc));
917 916
@@ -1457,20 +1456,21 @@ err_unlock_rcu:
1457 return false; 1456 return false;
1458} 1457}
1459 1458
1460void carl9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 1459void carl9170_op_tx(struct ieee80211_hw *hw,
1460 struct ieee80211_tx_control *control,
1461 struct sk_buff *skb)
1461{ 1462{
1462 struct ar9170 *ar = hw->priv; 1463 struct ar9170 *ar = hw->priv;
1463 struct ieee80211_tx_info *info; 1464 struct ieee80211_tx_info *info;
1464 struct ieee80211_sta *sta; 1465 struct ieee80211_sta *sta = control->sta;
1465 bool run; 1466 bool run;
1466 1467
1467 if (unlikely(!IS_STARTED(ar))) 1468 if (unlikely(!IS_STARTED(ar)))
1468 goto err_free; 1469 goto err_free;
1469 1470
1470 info = IEEE80211_SKB_CB(skb); 1471 info = IEEE80211_SKB_CB(skb);
1471 sta = info->control.sta;
1472 1472
1473 if (unlikely(carl9170_tx_prepare(ar, skb))) 1473 if (unlikely(carl9170_tx_prepare(ar, sta, skb)))
1474 goto err_free; 1474 goto err_free;
1475 1475
1476 carl9170_tx_accounting(ar, skb); 1476 carl9170_tx_accounting(ar, skb);
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 5efa77884704..e9a8f00e195c 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3407,7 +3407,8 @@ static void b43_tx_work(struct work_struct *work)
3407} 3407}
3408 3408
3409static void b43_op_tx(struct ieee80211_hw *hw, 3409static void b43_op_tx(struct ieee80211_hw *hw,
3410 struct sk_buff *skb) 3410 struct ieee80211_tx_control *control,
3411 struct sk_buff *skb)
3411{ 3412{
3412 struct b43_wl *wl = hw_to_b43_wl(hw); 3413 struct b43_wl *wl = hw_to_b43_wl(hw);
3413 3414
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 3ea1a85d38d1..291cdf654088 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2492,6 +2492,7 @@ static void b43legacy_tx_work(struct work_struct *work)
2492} 2492}
2493 2493
2494static void b43legacy_op_tx(struct ieee80211_hw *hw, 2494static void b43legacy_op_tx(struct ieee80211_hw *hw,
2495 struct ieee80211_tx_control *control,
2495 struct sk_buff *skb) 2496 struct sk_buff *skb)
2496{ 2497{
2497 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 2498 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 683a8652e155..04ecf03fc8cb 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -266,7 +266,9 @@ static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br)
266 } 266 }
267} 267}
268 268
269static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 269static void brcms_ops_tx(struct ieee80211_hw *hw,
270 struct ieee80211_tx_control *control,
271 struct sk_buff *skb)
270{ 272{
271 struct brcms_info *wl = hw->priv; 273 struct brcms_info *wl = hw->priv;
272 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 274 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -278,7 +280,7 @@ static void brcms_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
278 goto done; 280 goto done;
279 } 281 }
280 brcms_c_sendpkt_mac80211(wl->wlc, skb, hw); 282 brcms_c_sendpkt_mac80211(wl->wlc, skb, hw);
281 tx_info->rate_driver_data[0] = tx_info->control.sta; 283 tx_info->rate_driver_data[0] = control->sta;
282 done: 284 done:
283 spin_unlock_bh(&wl->lock); 285 spin_unlock_bh(&wl->lock);
284} 286}
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index faec40467208..e252acb9c862 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -460,7 +460,9 @@ il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd,
460 * start C_TX command process 460 * start C_TX command process
461 */ 461 */
462static int 462static int
463il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) 463il3945_tx_skb(struct il_priv *il,
464 struct ieee80211_sta *sta,
465 struct sk_buff *skb)
464{ 466{
465 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 467 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
466 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -512,7 +514,7 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
512 hdr_len = ieee80211_hdrlen(fc); 514 hdr_len = ieee80211_hdrlen(fc);
513 515
514 /* Find idx into station table for destination station */ 516 /* Find idx into station table for destination station */
515 sta_id = il_sta_id_or_broadcast(il, info->control.sta); 517 sta_id = il_sta_id_or_broadcast(il, sta);
516 if (sta_id == IL_INVALID_STATION) { 518 if (sta_id == IL_INVALID_STATION) {
517 D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); 519 D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1);
518 goto drop; 520 goto drop;
@@ -2859,7 +2861,9 @@ il3945_mac_stop(struct ieee80211_hw *hw)
2859} 2861}
2860 2862
2861static void 2863static void
2862il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 2864il3945_mac_tx(struct ieee80211_hw *hw,
2865 struct ieee80211_tx_control *control,
2866 struct sk_buff *skb)
2863{ 2867{
2864 struct il_priv *il = hw->priv; 2868 struct il_priv *il = hw->priv;
2865 2869
@@ -2868,7 +2872,7 @@ il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2868 D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 2872 D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
2869 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 2873 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
2870 2874
2871 if (il3945_tx_skb(il, skb)) 2875 if (il3945_tx_skb(il, control->sta, skb))
2872 dev_kfree_skb_any(skb); 2876 dev_kfree_skb_any(skb);
2873 2877
2874 D_MAC80211("leave\n"); 2878 D_MAC80211("leave\n");
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 34f61a0581a2..eac4dc8bc879 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -1526,8 +1526,11 @@ il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb,
1526} 1526}
1527 1527
1528static void 1528static void
1529il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd, 1529il4965_tx_cmd_build_rate(struct il_priv *il,
1530 struct ieee80211_tx_info *info, __le16 fc) 1530 struct il_tx_cmd *tx_cmd,
1531 struct ieee80211_tx_info *info,
1532 struct ieee80211_sta *sta,
1533 __le16 fc)
1531{ 1534{
1532 const u8 rts_retry_limit = 60; 1535 const u8 rts_retry_limit = 60;
1533 u32 rate_flags; 1536 u32 rate_flags;
@@ -1561,9 +1564,7 @@ il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd,
1561 rate_idx = info->control.rates[0].idx; 1564 rate_idx = info->control.rates[0].idx;
1562 if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0 1565 if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0
1563 || rate_idx > RATE_COUNT_LEGACY) 1566 || rate_idx > RATE_COUNT_LEGACY)
1564 rate_idx = 1567 rate_idx = rate_lowest_index(&il->bands[info->band], sta);
1565 rate_lowest_index(&il->bands[info->band],
1566 info->control.sta);
1567 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ 1568 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
1568 if (info->band == IEEE80211_BAND_5GHZ) 1569 if (info->band == IEEE80211_BAND_5GHZ)
1569 rate_idx += IL_FIRST_OFDM_RATE; 1570 rate_idx += IL_FIRST_OFDM_RATE;
@@ -1630,11 +1631,12 @@ il4965_tx_cmd_build_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info,
1630 * start C_TX command process 1631 * start C_TX command process
1631 */ 1632 */
1632int 1633int
1633il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 1634il4965_tx_skb(struct il_priv *il,
1635 struct ieee80211_sta *sta,
1636 struct sk_buff *skb)
1634{ 1637{
1635 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1638 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1636 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1639 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1637 struct ieee80211_sta *sta = info->control.sta;
1638 struct il_station_priv *sta_priv = NULL; 1640 struct il_station_priv *sta_priv = NULL;
1639 struct il_tx_queue *txq; 1641 struct il_tx_queue *txq;
1640 struct il_queue *q; 1642 struct il_queue *q;
@@ -1680,7 +1682,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
1680 sta_id = il->hw_params.bcast_id; 1682 sta_id = il->hw_params.bcast_id;
1681 else { 1683 else {
1682 /* Find idx into station table for destination station */ 1684 /* Find idx into station table for destination station */
1683 sta_id = il_sta_id_or_broadcast(il, info->control.sta); 1685 sta_id = il_sta_id_or_broadcast(il, sta);
1684 1686
1685 if (sta_id == IL_INVALID_STATION) { 1687 if (sta_id == IL_INVALID_STATION) {
1686 D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); 1688 D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1);
@@ -1786,7 +1788,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
1786 /* TODO need this for burst mode later on */ 1788 /* TODO need this for burst mode later on */
1787 il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); 1789 il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id);
1788 1790
1789 il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); 1791 il4965_tx_cmd_build_rate(il, tx_cmd, info, sta, fc);
1790 1792
1791 il_update_stats(il, true, fc, len); 1793 il_update_stats(il, true, fc, len);
1792 /* 1794 /*
@@ -5828,7 +5830,9 @@ il4965_mac_stop(struct ieee80211_hw *hw)
5828} 5830}
5829 5831
5830void 5832void
5831il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 5833il4965_mac_tx(struct ieee80211_hw *hw,
5834 struct ieee80211_tx_control *control,
5835 struct sk_buff *skb)
5832{ 5836{
5833 struct il_priv *il = hw->priv; 5837 struct il_priv *il = hw->priv;
5834 5838
@@ -5837,7 +5841,7 @@ il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
5837 D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 5841 D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
5838 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 5842 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
5839 5843
5840 if (il4965_tx_skb(il, skb)) 5844 if (il4965_tx_skb(il, control->sta, skb))
5841 dev_kfree_skb_any(skb); 5845 dev_kfree_skb_any(skb);
5842 5846
5843 D_MACDUMP("leave\n"); 5847 D_MACDUMP("leave\n");
diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h
index 1db677689cfe..2d092f328547 100644
--- a/drivers/net/wireless/iwlegacy/4965.h
+++ b/drivers/net/wireless/iwlegacy/4965.h
@@ -78,7 +78,9 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
78int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); 78int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
79void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, 79void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
80 struct ieee80211_tx_info *info); 80 struct ieee80211_tx_info *info);
81int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); 81int il4965_tx_skb(struct il_priv *il,
82 struct ieee80211_sta *sta,
83 struct sk_buff *skb);
82int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, 84int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
83 struct ieee80211_sta *sta, u16 tid, u16 * ssn); 85 struct ieee80211_sta *sta, u16 tid, u16 * ssn);
84int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, 86int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
@@ -163,7 +165,9 @@ void il4965_eeprom_release_semaphore(struct il_priv *il);
163int il4965_eeprom_check_version(struct il_priv *il); 165int il4965_eeprom_check_version(struct il_priv *il);
164 166
165/* mac80211 handlers (for 4965) */ 167/* mac80211 handlers (for 4965) */
166void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); 168void il4965_mac_tx(struct ieee80211_hw *hw,
169 struct ieee80211_tx_control *control,
170 struct sk_buff *skb);
167int il4965_mac_start(struct ieee80211_hw *hw); 171int il4965_mac_start(struct ieee80211_hw *hw);
168void il4965_mac_stop(struct ieee80211_hw *hw); 172void il4965_mac_stop(struct ieee80211_hw *hw);
169void il4965_configure_filter(struct ieee80211_hw *hw, 173void il4965_configure_filter(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/iwlwifi/dvm/agn.h b/drivers/net/wireless/iwlwifi/dvm/agn.h
index 9bb16bdf6d26..f0b8c1f7591c 100644
--- a/drivers/net/wireless/iwlwifi/dvm/agn.h
+++ b/drivers/net/wireless/iwlwifi/dvm/agn.h
@@ -201,7 +201,9 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
201 201
202 202
203/* tx */ 203/* tx */
204int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); 204int iwlagn_tx_skb(struct iwl_priv *priv,
205 struct ieee80211_sta *sta,
206 struct sk_buff *skb);
205int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, 207int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
206 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 208 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
207int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif, 209int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index a5f7bce96325..e64af60a37c1 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -511,14 +511,16 @@ static void iwlagn_mac_set_wakeup(struct ieee80211_hw *hw, bool enabled)
511} 511}
512#endif 512#endif
513 513
514static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 514static void iwlagn_mac_tx(struct ieee80211_hw *hw,
515 struct ieee80211_tx_control *control,
516 struct sk_buff *skb)
515{ 517{
516 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 518 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
517 519
518 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 520 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
519 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
520 522
521 if (iwlagn_tx_skb(priv, skb)) 523 if (iwlagn_tx_skb(priv, control->sta, skb))
522 dev_kfree_skb_any(skb); 524 dev_kfree_skb_any(skb);
523} 525}
524 526
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c
index 5971a23aa47d..d17799b316d7 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tx.c
@@ -127,6 +127,7 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
127static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv, 127static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
128 struct iwl_tx_cmd *tx_cmd, 128 struct iwl_tx_cmd *tx_cmd,
129 struct ieee80211_tx_info *info, 129 struct ieee80211_tx_info *info,
130 struct ieee80211_sta *sta,
130 __le16 fc) 131 __le16 fc)
131{ 132{
132 u32 rate_flags; 133 u32 rate_flags;
@@ -187,8 +188,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
187 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || 188 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS ||
188 (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY)) 189 (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY))
189 rate_idx = rate_lowest_index( 190 rate_idx = rate_lowest_index(
190 &priv->eeprom_data->bands[info->band], 191 &priv->eeprom_data->bands[info->band], sta);
191 info->control.sta);
192 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ 192 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
193 if (info->band == IEEE80211_BAND_5GHZ) 193 if (info->band == IEEE80211_BAND_5GHZ)
194 rate_idx += IWL_FIRST_OFDM_RATE; 194 rate_idx += IWL_FIRST_OFDM_RATE;
@@ -291,7 +291,9 @@ static int iwl_sta_id_or_broadcast(struct iwl_rxon_context *context,
291/* 291/*
292 * start REPLY_TX command process 292 * start REPLY_TX command process
293 */ 293 */
294int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) 294int iwlagn_tx_skb(struct iwl_priv *priv,
295 struct ieee80211_sta *sta,
296 struct sk_buff *skb)
295{ 297{
296 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 298 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
297 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 299 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -345,7 +347,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
345 sta_id = ctx->bcast_sta_id; 347 sta_id = ctx->bcast_sta_id;
346 else { 348 else {
347 /* Find index into station table for destination station */ 349 /* Find index into station table for destination station */
348 sta_id = iwl_sta_id_or_broadcast(ctx, info->control.sta); 350 sta_id = iwl_sta_id_or_broadcast(ctx, sta);
349 if (sta_id == IWL_INVALID_STATION) { 351 if (sta_id == IWL_INVALID_STATION) {
350 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 352 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
351 hdr->addr1); 353 hdr->addr1);
@@ -355,8 +357,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
355 357
356 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); 358 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
357 359
358 if (info->control.sta) 360 if (sta)
359 sta_priv = (void *)info->control.sta->drv_priv; 361 sta_priv = (void *)sta->drv_priv;
360 362
361 if (sta_priv && sta_priv->asleep && 363 if (sta_priv && sta_priv->asleep &&
362 (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) { 364 (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
@@ -397,7 +399,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
397 /* TODO need this for burst mode later on */ 399 /* TODO need this for burst mode later on */
398 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); 400 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id);
399 401
400 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc); 402 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, sta, fc);
401 403
402 memset(&info->status, 0, sizeof(info->status)); 404 memset(&info->status, 0, sizeof(info->status));
403 405
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index a03457292c88..7001856241e6 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -227,7 +227,9 @@ static void lbtf_free_adapter(struct lbtf_private *priv)
227 lbtf_deb_leave(LBTF_DEB_MAIN); 227 lbtf_deb_leave(LBTF_DEB_MAIN);
228} 228}
229 229
230static void lbtf_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 230static void lbtf_op_tx(struct ieee80211_hw *hw,
231 struct ieee80211_tx_control *control,
232 struct sk_buff *skb)
231{ 233{
232 struct lbtf_private *priv = hw->priv; 234 struct lbtf_private *priv = hw->priv;
233 235
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 00838395778c..72b0456e41bf 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -709,7 +709,9 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
709 return ack; 709 return ack;
710} 710}
711 711
712static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 712static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
713 struct ieee80211_tx_control *control,
714 struct sk_buff *skb)
713{ 715{
714 bool ack; 716 bool ack;
715 struct ieee80211_tx_info *txi; 717 struct ieee80211_tx_info *txi;
@@ -1727,6 +1729,7 @@ static const struct ieee80211_iface_limit hwsim_if_limits[] = {
1727#endif 1729#endif
1728 BIT(NL80211_IFTYPE_AP) | 1730 BIT(NL80211_IFTYPE_AP) |
1729 BIT(NL80211_IFTYPE_P2P_GO) }, 1731 BIT(NL80211_IFTYPE_P2P_GO) },
1732 { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) },
1730}; 1733};
1731 1734
1732static const struct ieee80211_iface_combination hwsim_if_comb = { 1735static const struct ieee80211_iface_combination hwsim_if_comb = {
@@ -1813,7 +1816,8 @@ static int __init init_mac80211_hwsim(void)
1813 BIT(NL80211_IFTYPE_P2P_CLIENT) | 1816 BIT(NL80211_IFTYPE_P2P_CLIENT) |
1814 BIT(NL80211_IFTYPE_P2P_GO) | 1817 BIT(NL80211_IFTYPE_P2P_GO) |
1815 BIT(NL80211_IFTYPE_ADHOC) | 1818 BIT(NL80211_IFTYPE_ADHOC) |
1816 BIT(NL80211_IFTYPE_MESH_POINT); 1819 BIT(NL80211_IFTYPE_MESH_POINT) |
1820 BIT(NL80211_IFTYPE_P2P_DEVICE);
1817 1821
1818 hw->flags = IEEE80211_HW_MFP_CAPABLE | 1822 hw->flags = IEEE80211_HW_MFP_CAPABLE |
1819 IEEE80211_HW_SIGNAL_DBM | 1823 IEEE80211_HW_SIGNAL_DBM |
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 224e03ade145..5099e5375cb3 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -1830,12 +1830,14 @@ static inline void mwl8k_tx_count_packet(struct ieee80211_sta *sta, u8 tid)
1830} 1830}
1831 1831
1832static void 1832static void
1833mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb) 1833mwl8k_txq_xmit(struct ieee80211_hw *hw,
1834 int index,
1835 struct ieee80211_sta *sta,
1836 struct sk_buff *skb)
1834{ 1837{
1835 struct mwl8k_priv *priv = hw->priv; 1838 struct mwl8k_priv *priv = hw->priv;
1836 struct ieee80211_tx_info *tx_info; 1839 struct ieee80211_tx_info *tx_info;
1837 struct mwl8k_vif *mwl8k_vif; 1840 struct mwl8k_vif *mwl8k_vif;
1838 struct ieee80211_sta *sta;
1839 struct ieee80211_hdr *wh; 1841 struct ieee80211_hdr *wh;
1840 struct mwl8k_tx_queue *txq; 1842 struct mwl8k_tx_queue *txq;
1841 struct mwl8k_tx_desc *tx; 1843 struct mwl8k_tx_desc *tx;
@@ -1867,7 +1869,6 @@ mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb)
1867 wh = &((struct mwl8k_dma_data *)skb->data)->wh; 1869 wh = &((struct mwl8k_dma_data *)skb->data)->wh;
1868 1870
1869 tx_info = IEEE80211_SKB_CB(skb); 1871 tx_info = IEEE80211_SKB_CB(skb);
1870 sta = tx_info->control.sta;
1871 mwl8k_vif = MWL8K_VIF(tx_info->control.vif); 1872 mwl8k_vif = MWL8K_VIF(tx_info->control.vif);
1872 1873
1873 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 1874 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
@@ -2019,8 +2020,8 @@ mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb)
2019 tx->pkt_phys_addr = cpu_to_le32(dma); 2020 tx->pkt_phys_addr = cpu_to_le32(dma);
2020 tx->pkt_len = cpu_to_le16(skb->len); 2021 tx->pkt_len = cpu_to_le16(skb->len);
2021 tx->rate_info = 0; 2022 tx->rate_info = 0;
2022 if (!priv->ap_fw && tx_info->control.sta != NULL) 2023 if (!priv->ap_fw && sta != NULL)
2023 tx->peer_id = MWL8K_STA(tx_info->control.sta)->peer_id; 2024 tx->peer_id = MWL8K_STA(sta)->peer_id;
2024 else 2025 else
2025 tx->peer_id = 0; 2026 tx->peer_id = 0;
2026 2027
@@ -4364,7 +4365,9 @@ static void mwl8k_rx_poll(unsigned long data)
4364/* 4365/*
4365 * Core driver operations. 4366 * Core driver operations.
4366 */ 4367 */
4367static void mwl8k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 4368static void mwl8k_tx(struct ieee80211_hw *hw,
4369 struct ieee80211_tx_control *control,
4370 struct sk_buff *skb)
4368{ 4371{
4369 struct mwl8k_priv *priv = hw->priv; 4372 struct mwl8k_priv *priv = hw->priv;
4370 int index = skb_get_queue_mapping(skb); 4373 int index = skb_get_queue_mapping(skb);
@@ -4376,7 +4379,7 @@ static void mwl8k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
4376 return; 4379 return;
4377 } 4380 }
4378 4381
4379 mwl8k_txq_xmit(hw, index, skb); 4382 mwl8k_txq_xmit(hw, index, control->sta, skb);
4380} 4383}
4381 4384
4382static int mwl8k_start(struct ieee80211_hw *hw) 4385static int mwl8k_start(struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/p54/lmac.h b/drivers/net/wireless/p54/lmac.h
index 3d8d622bec55..de1d46bf97df 100644
--- a/drivers/net/wireless/p54/lmac.h
+++ b/drivers/net/wireless/p54/lmac.h
@@ -526,7 +526,9 @@ int p54_init_leds(struct p54_common *priv);
526void p54_unregister_leds(struct p54_common *priv); 526void p54_unregister_leds(struct p54_common *priv);
527 527
528/* xmit functions */ 528/* xmit functions */
529void p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb); 529void p54_tx_80211(struct ieee80211_hw *dev,
530 struct ieee80211_tx_control *control,
531 struct sk_buff *skb);
530int p54_tx_cancel(struct p54_common *priv, __le32 req_id); 532int p54_tx_cancel(struct p54_common *priv, __le32 req_id);
531void p54_tx(struct p54_common *priv, struct sk_buff *skb); 533void p54_tx(struct p54_common *priv, struct sk_buff *skb);
532 534
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index 7cffea795ad2..5e91ad06dd5d 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -158,7 +158,7 @@ static int p54_beacon_update(struct p54_common *priv,
158 * to cancel the old beacon template by hand, instead the firmware 158 * to cancel the old beacon template by hand, instead the firmware
159 * will release the previous one through the feedback mechanism. 159 * will release the previous one through the feedback mechanism.
160 */ 160 */
161 p54_tx_80211(priv->hw, beacon); 161 p54_tx_80211(priv->hw, NULL, beacon);
162 priv->tsf_high32 = 0; 162 priv->tsf_high32 = 0;
163 priv->tsf_low32 = 0; 163 priv->tsf_low32 = 0;
164 164
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index f38786e02623..5861e13a6fd8 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -676,8 +676,9 @@ int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
676EXPORT_SYMBOL_GPL(p54_rx); 676EXPORT_SYMBOL_GPL(p54_rx);
677 677
678static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb, 678static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
679 struct ieee80211_tx_info *info, u8 *queue, 679 struct ieee80211_tx_info *info,
680 u32 *extra_len, u16 *flags, u16 *aid, 680 struct ieee80211_sta *sta,
681 u8 *queue, u32 *extra_len, u16 *flags, u16 *aid,
681 bool *burst_possible) 682 bool *burst_possible)
682{ 683{
683 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 684 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -746,8 +747,8 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
746 } 747 }
747 } 748 }
748 749
749 if (info->control.sta) 750 if (sta)
750 *aid = info->control.sta->aid; 751 *aid = sta->aid;
751 break; 752 break;
752 } 753 }
753} 754}
@@ -767,7 +768,9 @@ static u8 p54_convert_algo(u32 cipher)
767 } 768 }
768} 769}
769 770
770void p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb) 771void p54_tx_80211(struct ieee80211_hw *dev,
772 struct ieee80211_tx_control *control,
773 struct sk_buff *skb)
771{ 774{
772 struct p54_common *priv = dev->priv; 775 struct p54_common *priv = dev->priv;
773 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 776 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -784,7 +787,7 @@ void p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb)
784 u8 nrates = 0, nremaining = 8; 787 u8 nrates = 0, nremaining = 8;
785 bool burst_allowed = false; 788 bool burst_allowed = false;
786 789
787 p54_tx_80211_header(priv, skb, info, &queue, &extra_len, 790 p54_tx_80211_header(priv, skb, info, control->sta, &queue, &extra_len,
788 &hdr_flags, &aid, &burst_allowed); 791 &hdr_flags, &aid, &burst_allowed);
789 792
790 if (p54_tx_qos_accounting_alloc(priv, skb, queue)) { 793 if (p54_tx_qos_accounting_alloc(priv, skb, queue)) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 8afb546c2b2d..f991e8bedc70 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -1287,7 +1287,9 @@ void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp);
1287/* 1287/*
1288 * mac80211 handlers. 1288 * mac80211 handlers.
1289 */ 1289 */
1290void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); 1290void rt2x00mac_tx(struct ieee80211_hw *hw,
1291 struct ieee80211_tx_control *control,
1292 struct sk_buff *skb);
1291int rt2x00mac_start(struct ieee80211_hw *hw); 1293int rt2x00mac_start(struct ieee80211_hw *hw);
1292void rt2x00mac_stop(struct ieee80211_hw *hw); 1294void rt2x00mac_stop(struct ieee80211_hw *hw);
1293int rt2x00mac_add_interface(struct ieee80211_hw *hw, 1295int rt2x00mac_add_interface(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index a6b88bd4a1a5..a59048ffa092 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -194,7 +194,7 @@ static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
194 */ 194 */
195 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif); 195 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
196 while (skb) { 196 while (skb) {
197 rt2x00mac_tx(rt2x00dev->hw, skb); 197 rt2x00mac_tx(rt2x00dev->hw, NULL, skb);
198 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif); 198 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
199 } 199 }
200} 200}
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 4ff26c2159bf..c3d0f2f87b69 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -99,7 +99,9 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
99 return retval; 99 return retval;
100} 100}
101 101
102void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 102void rt2x00mac_tx(struct ieee80211_hw *hw,
103 struct ieee80211_tx_control *control,
104 struct sk_buff *skb)
103{ 105{
104 struct rt2x00_dev *rt2x00dev = hw->priv; 106 struct rt2x00_dev *rt2x00dev = hw->priv;
105 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 107 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index f7e74a0a7759..e488b944a034 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -315,6 +315,7 @@ static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev,
315static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev, 315static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev,
316 struct sk_buff *skb, 316 struct sk_buff *skb,
317 struct txentry_desc *txdesc, 317 struct txentry_desc *txdesc,
318 struct ieee80211_sta *sta,
318 const struct rt2x00_rate *hwrate) 319 const struct rt2x00_rate *hwrate)
319{ 320{
320 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 321 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -322,11 +323,11 @@ static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev,
322 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 323 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
323 struct rt2x00_sta *sta_priv = NULL; 324 struct rt2x00_sta *sta_priv = NULL;
324 325
325 if (tx_info->control.sta) { 326 if (sta) {
326 txdesc->u.ht.mpdu_density = 327 txdesc->u.ht.mpdu_density =
327 tx_info->control.sta->ht_cap.ampdu_density; 328 sta->ht_cap.ampdu_density;
328 329
329 sta_priv = sta_to_rt2x00_sta(tx_info->control.sta); 330 sta_priv = sta_to_rt2x00_sta(sta);
330 txdesc->u.ht.wcid = sta_priv->wcid; 331 txdesc->u.ht.wcid = sta_priv->wcid;
331 } 332 }
332 333
@@ -341,8 +342,8 @@ static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev,
341 * MIMO PS should be set to 1 for STA's using dynamic SM PS 342 * MIMO PS should be set to 1 for STA's using dynamic SM PS
342 * when using more then one tx stream (>MCS7). 343 * when using more then one tx stream (>MCS7).
343 */ 344 */
344 if (tx_info->control.sta && txdesc->u.ht.mcs > 7 && 345 if (sta && txdesc->u.ht.mcs > 7 &&
345 ((tx_info->control.sta->ht_cap.cap & 346 ((sta->ht_cap.cap &
346 IEEE80211_HT_CAP_SM_PS) >> 347 IEEE80211_HT_CAP_SM_PS) >>
347 IEEE80211_HT_CAP_SM_PS_SHIFT) == 348 IEEE80211_HT_CAP_SM_PS_SHIFT) ==
348 WLAN_HT_CAP_SM_PS_DYNAMIC) 349 WLAN_HT_CAP_SM_PS_DYNAMIC)
@@ -409,7 +410,8 @@ static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev,
409 410
410static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, 411static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
411 struct sk_buff *skb, 412 struct sk_buff *skb,
412 struct txentry_desc *txdesc) 413 struct txentry_desc *txdesc,
414 struct ieee80211_sta *sta)
413{ 415{
414 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 416 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
415 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 417 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -503,7 +505,7 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
503 505
504 if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags)) 506 if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags))
505 rt2x00queue_create_tx_descriptor_ht(rt2x00dev, skb, txdesc, 507 rt2x00queue_create_tx_descriptor_ht(rt2x00dev, skb, txdesc,
506 hwrate); 508 sta, hwrate);
507 else 509 else
508 rt2x00queue_create_tx_descriptor_plcp(rt2x00dev, skb, txdesc, 510 rt2x00queue_create_tx_descriptor_plcp(rt2x00dev, skb, txdesc,
509 hwrate); 511 hwrate);
@@ -595,7 +597,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
595 * after that we are free to use the skb->cb array 597 * after that we are free to use the skb->cb array
596 * for our information. 598 * for our information.
597 */ 599 */
598 rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc); 600 rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
599 601
600 /* 602 /*
601 * All information is retrieved from the skb->cb array, 603 * All information is retrieved from the skb->cb array,
@@ -740,7 +742,7 @@ int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev,
740 * after that we are free to use the skb->cb array 742 * after that we are free to use the skb->cb array
741 * for our information. 743 * for our information.
742 */ 744 */
743 rt2x00queue_create_tx_descriptor(rt2x00dev, intf->beacon->skb, &txdesc); 745 rt2x00queue_create_tx_descriptor(rt2x00dev, intf->beacon->skb, &txdesc, NULL);
744 746
745 /* 747 /*
746 * Fill in skb descriptor 748 * Fill in skb descriptor
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c
index aceaf689f737..021d83e1b1d3 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c
@@ -244,7 +244,9 @@ static irqreturn_t rtl8180_interrupt(int irq, void *dev_id)
244 return IRQ_HANDLED; 244 return IRQ_HANDLED;
245} 245}
246 246
247static void rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 247static void rtl8180_tx(struct ieee80211_hw *dev,
248 struct ieee80211_tx_control *control,
249 struct sk_buff *skb)
248{ 250{
249 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 251 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
250 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 252 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -710,7 +712,7 @@ static void rtl8180_beacon_work(struct work_struct *work)
710 /* TODO: use actual beacon queue */ 712 /* TODO: use actual beacon queue */
711 skb_set_queue_mapping(skb, 0); 713 skb_set_queue_mapping(skb, 0);
712 714
713 rtl8180_tx(dev, skb); 715 rtl8180_tx(dev, NULL, skb);
714 716
715resched: 717resched:
716 /* 718 /*
diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c
index 71a30b026089..05d8ca045afd 100644
--- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
@@ -228,7 +228,9 @@ static void rtl8187_tx_cb(struct urb *urb)
228 } 228 }
229} 229}
230 230
231static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 231static void rtl8187_tx(struct ieee80211_hw *dev,
232 struct ieee80211_tx_control *control,
233 struct sk_buff *skb)
232{ 234{
233 struct rtl8187_priv *priv = dev->priv; 235 struct rtl8187_priv *priv = dev->priv;
234 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 236 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1076,7 +1078,7 @@ static void rtl8187_beacon_work(struct work_struct *work)
1076 /* TODO: use actual beacon queue */ 1078 /* TODO: use actual beacon queue */
1077 skb_set_queue_mapping(skb, 0); 1079 skb_set_queue_mapping(skb, 0);
1078 1080
1079 rtl8187_tx(dev, skb); 1081 rtl8187_tx(dev, NULL, skb);
1080 1082
1081resched: 1083resched:
1082 /* 1084 /*
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 942e56b77b60..59381fe8ed06 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -1341,9 +1341,8 @@ int rtl_send_smps_action(struct ieee80211_hw *hw,
1341 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); 1341 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
1342 1342
1343 info->control.rates[0].idx = 0; 1343 info->control.rates[0].idx = 0;
1344 info->control.sta = sta;
1345 info->band = hw->conf.channel->band; 1344 info->band = hw->conf.channel->band;
1346 rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); 1345 rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc);
1347 } 1346 }
1348err_free: 1347err_free:
1349 return 0; 1348 return 0;
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index a18ad2a98938..a7c0e52869ba 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -124,7 +124,9 @@ static void rtl_op_stop(struct ieee80211_hw *hw)
124 mutex_unlock(&rtlpriv->locks.conf_mutex); 124 mutex_unlock(&rtlpriv->locks.conf_mutex);
125} 125}
126 126
127static void rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 127static void rtl_op_tx(struct ieee80211_hw *hw,
128 struct ieee80211_tx_control *control,
129 struct sk_buff *skb)
128{ 130{
129 struct rtl_priv *rtlpriv = rtl_priv(hw); 131 struct rtl_priv *rtlpriv = rtl_priv(hw);
130 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 132 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -138,8 +140,8 @@ static void rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
138 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) 140 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
139 goto err_free; 141 goto err_free;
140 142
141 if (!rtlpriv->intf_ops->waitq_insert(hw, skb)) 143 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
142 rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); 144 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
143 145
144 return; 146 return;
145 147
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 80f75d3ba84a..aad9d44c0a51 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -504,7 +504,7 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
504 _rtl_update_earlymode_info(hw, skb, 504 _rtl_update_earlymode_info(hw, skb,
505 &tcb_desc, tid); 505 &tcb_desc, tid);
506 506
507 rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); 507 rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
508 } 508 }
509 } 509 }
510} 510}
@@ -929,7 +929,7 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
929 info = IEEE80211_SKB_CB(pskb); 929 info = IEEE80211_SKB_CB(pskb);
930 pdesc = &ring->desc[0]; 930 pdesc = &ring->desc[0];
931 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, 931 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc,
932 info, pskb, BEACON_QUEUE, &tcb_desc); 932 info, NULL, pskb, BEACON_QUEUE, &tcb_desc);
933 933
934 __skb_queue_tail(&ring->queue, pskb); 934 __skb_queue_tail(&ring->queue, pskb);
935 935
@@ -1305,11 +1305,10 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1305} 1305}
1306 1306
1307static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, 1307static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw,
1308 struct ieee80211_sta *sta,
1308 struct sk_buff *skb) 1309 struct sk_buff *skb)
1309{ 1310{
1310 struct rtl_priv *rtlpriv = rtl_priv(hw); 1311 struct rtl_priv *rtlpriv = rtl_priv(hw);
1311 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1312 struct ieee80211_sta *sta = info->control.sta;
1313 struct rtl_sta_info *sta_entry = NULL; 1312 struct rtl_sta_info *sta_entry = NULL;
1314 u8 tid = rtl_get_tid(skb); 1313 u8 tid = rtl_get_tid(skb);
1315 1314
@@ -1337,13 +1336,14 @@ static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw,
1337 return true; 1336 return true;
1338} 1337}
1339 1338
1340static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb, 1339static int rtl_pci_tx(struct ieee80211_hw *hw,
1341 struct rtl_tcb_desc *ptcb_desc) 1340 struct ieee80211_sta *sta,
1341 struct sk_buff *skb,
1342 struct rtl_tcb_desc *ptcb_desc)
1342{ 1343{
1343 struct rtl_priv *rtlpriv = rtl_priv(hw); 1344 struct rtl_priv *rtlpriv = rtl_priv(hw);
1344 struct rtl_sta_info *sta_entry = NULL; 1345 struct rtl_sta_info *sta_entry = NULL;
1345 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1346 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1346 struct ieee80211_sta *sta = info->control.sta;
1347 struct rtl8192_tx_ring *ring; 1347 struct rtl8192_tx_ring *ring;
1348 struct rtl_tx_desc *pdesc; 1348 struct rtl_tx_desc *pdesc;
1349 u8 idx; 1349 u8 idx;
@@ -1418,7 +1418,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
1418 rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX); 1418 rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX);
1419 1419
1420 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, 1420 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc,
1421 info, skb, hw_queue, ptcb_desc); 1421 info, sta, skb, hw_queue, ptcb_desc);
1422 1422
1423 __skb_queue_tail(&ring->queue, skb); 1423 __skb_queue_tail(&ring->queue, skb);
1424 1424
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 52166640f167..390d6d4fcaa0 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -596,7 +596,9 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
596 596
597void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, 597void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
598 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 598 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
599 struct ieee80211_tx_info *info, struct sk_buff *skb, 599 struct ieee80211_tx_info *info,
600 struct ieee80211_sta *sta,
601 struct sk_buff *skb,
600 u8 hw_queue, struct rtl_tcb_desc *tcb_desc) 602 u8 hw_queue, struct rtl_tcb_desc *tcb_desc)
601{ 603{
602 struct rtl_priv *rtlpriv = rtl_priv(hw); 604 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -604,7 +606,6 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
604 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 606 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
605 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 607 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
606 bool defaultadapter = true; 608 bool defaultadapter = true;
607 struct ieee80211_sta *sta;
608 u8 *pdesc = pdesc_tx; 609 u8 *pdesc = pdesc_tx;
609 u16 seq_number; 610 u16 seq_number;
610 __le16 fc = hdr->frame_control; 611 __le16 fc = hdr->frame_control;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
index c4adb9777365..a7cdd514cb2e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
@@ -713,6 +713,7 @@ struct rx_desc_92c {
713void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, 713void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
714 struct ieee80211_hdr *hdr, 714 struct ieee80211_hdr *hdr,
715 u8 *pdesc, struct ieee80211_tx_info *info, 715 u8 *pdesc, struct ieee80211_tx_info *info,
716 struct ieee80211_sta *sta,
716 struct sk_buff *skb, u8 hw_queue, 717 struct sk_buff *skb, u8 hw_queue,
717 struct rtl_tcb_desc *ptcb_desc); 718 struct rtl_tcb_desc *ptcb_desc);
718bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw, 719bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
index 2e6eb356a93e..27863d773790 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
@@ -496,7 +496,9 @@ static void _rtl_tx_desc_checksum(u8 *txdesc)
496 496
497void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, 497void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
498 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 498 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
499 struct ieee80211_tx_info *info, struct sk_buff *skb, 499 struct ieee80211_tx_info *info,
500 struct ieee80211_sta *sta,
501 struct sk_buff *skb,
500 u8 queue_index, 502 u8 queue_index,
501 struct rtl_tcb_desc *tcb_desc) 503 struct rtl_tcb_desc *tcb_desc)
502{ 504{
@@ -504,7 +506,6 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
504 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 506 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
505 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 507 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
506 bool defaultadapter = true; 508 bool defaultadapter = true;
507 struct ieee80211_sta *sta = info->control.sta = info->control.sta;
508 u8 *qc = ieee80211_get_qos_ctl(hdr); 509 u8 *qc = ieee80211_get_qos_ctl(hdr);
509 u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 510 u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
510 u16 seq_number; 511 u16 seq_number;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
index 332b06e78b00..725c53accc58 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
@@ -420,7 +420,9 @@ struct sk_buff *rtl8192c_tx_aggregate_hdl(struct ieee80211_hw *,
420 struct sk_buff_head *); 420 struct sk_buff_head *);
421void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, 421void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
422 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 422 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
423 struct ieee80211_tx_info *info, struct sk_buff *skb, 423 struct ieee80211_tx_info *info,
424 struct ieee80211_sta *sta,
425 struct sk_buff *skb,
424 u8 queue_index, 426 u8 queue_index,
425 struct rtl_tcb_desc *tcb_desc); 427 struct rtl_tcb_desc *tcb_desc);
426void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc, 428void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index f80690d82c11..4686f340b9d6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -551,7 +551,9 @@ static void _rtl92de_insert_emcontent(struct rtl_tcb_desc *ptcb_desc,
551 551
552void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, 552void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
553 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 553 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
554 struct ieee80211_tx_info *info, struct sk_buff *skb, 554 struct ieee80211_tx_info *info,
555 struct ieee80211_sta *sta,
556 struct sk_buff *skb,
555 u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) 557 u8 hw_queue, struct rtl_tcb_desc *ptcb_desc)
556{ 558{
557 struct rtl_priv *rtlpriv = rtl_priv(hw); 559 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -559,7 +561,6 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
559 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 561 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
560 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 562 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
561 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 563 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
562 struct ieee80211_sta *sta = info->control.sta;
563 u8 *pdesc = pdesc_tx; 564 u8 *pdesc = pdesc_tx;
564 u16 seq_number; 565 u16 seq_number;
565 __le16 fc = hdr->frame_control; 566 __le16 fc = hdr->frame_control;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
index 057a52431b00..c1b5dfb79d53 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
@@ -730,6 +730,7 @@ struct rx_desc_92d {
730void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, 730void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
731 struct ieee80211_hdr *hdr, 731 struct ieee80211_hdr *hdr,
732 u8 *pdesc, struct ieee80211_tx_info *info, 732 u8 *pdesc, struct ieee80211_tx_info *info,
733 struct ieee80211_sta *sta,
733 struct sk_buff *skb, u8 hw_queue, 734 struct sk_buff *skb, u8 hw_queue,
734 struct rtl_tcb_desc *ptcb_desc); 735 struct rtl_tcb_desc *ptcb_desc);
735bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, 736bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 36d1cb3aef8a..28c53fb12aeb 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -591,14 +591,15 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
591 591
592void rtl92se_tx_fill_desc(struct ieee80211_hw *hw, 592void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
593 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 593 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
594 struct ieee80211_tx_info *info, struct sk_buff *skb, 594 struct ieee80211_tx_info *info,
595 struct ieee80211_sta *sta,
596 struct sk_buff *skb,
595 u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) 597 u8 hw_queue, struct rtl_tcb_desc *ptcb_desc)
596{ 598{
597 struct rtl_priv *rtlpriv = rtl_priv(hw); 599 struct rtl_priv *rtlpriv = rtl_priv(hw);
598 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 600 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
599 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 601 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
600 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 602 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
601 struct ieee80211_sta *sta = info->control.sta;
602 u8 *pdesc = pdesc_tx; 603 u8 *pdesc = pdesc_tx;
603 u16 seq_number; 604 u16 seq_number;
604 __le16 fc = hdr->frame_control; 605 __le16 fc = hdr->frame_control;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
index 011e7b0695f2..64dd66f287c1 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
@@ -31,6 +31,7 @@
31 31
32void rtl92se_tx_fill_desc(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, 32void rtl92se_tx_fill_desc(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
33 u8 *pdesc, struct ieee80211_tx_info *info, 33 u8 *pdesc, struct ieee80211_tx_info *info,
34 struct ieee80211_sta *sta,
34 struct sk_buff *skb, u8 hw_queue, 35 struct sk_buff *skb, u8 hw_queue,
35 struct rtl_tcb_desc *ptcb_desc); 36 struct rtl_tcb_desc *ptcb_desc);
36void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, bool firstseg, 37void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, bool firstseg,
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index aa970fc18a21..914046903cfd 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -848,8 +848,10 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb,
848 _rtl_submit_tx_urb(hw, _urb); 848 _rtl_submit_tx_urb(hw, _urb);
849} 849}
850 850
851static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb, 851static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
852 u16 hw_queue) 852 struct ieee80211_sta *sta,
853 struct sk_buff *skb,
854 u16 hw_queue)
853{ 855{
854 struct rtl_priv *rtlpriv = rtl_priv(hw); 856 struct rtl_priv *rtlpriv = rtl_priv(hw);
855 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 857 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -891,7 +893,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb,
891 seq_number += 1; 893 seq_number += 1;
892 seq_number <<= 4; 894 seq_number <<= 4;
893 } 895 }
894 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, info, skb, 896 rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, info, sta, skb,
895 hw_queue, &tcb_desc); 897 hw_queue, &tcb_desc);
896 if (!ieee80211_has_morefrags(hdr->frame_control)) { 898 if (!ieee80211_has_morefrags(hdr->frame_control)) {
897 if (qc) 899 if (qc)
@@ -901,7 +903,9 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb,
901 rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX); 903 rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX);
902} 904}
903 905
904static int rtl_usb_tx(struct ieee80211_hw *hw, struct sk_buff *skb, 906static int rtl_usb_tx(struct ieee80211_hw *hw,
907 struct ieee80211_sta *sta,
908 struct sk_buff *skb,
905 struct rtl_tcb_desc *dummy) 909 struct rtl_tcb_desc *dummy)
906{ 910{
907 struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw)); 911 struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
@@ -913,7 +917,7 @@ static int rtl_usb_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
913 if (unlikely(is_hal_stop(rtlhal))) 917 if (unlikely(is_hal_stop(rtlhal)))
914 goto err_free; 918 goto err_free;
915 hw_queue = rtlusb->usb_mq_to_hwq(fc, skb_get_queue_mapping(skb)); 919 hw_queue = rtlusb->usb_mq_to_hwq(fc, skb_get_queue_mapping(skb));
916 _rtl_usb_tx_preprocess(hw, skb, hw_queue); 920 _rtl_usb_tx_preprocess(hw, sta, skb, hw_queue);
917 _rtl_usb_transmit(hw, skb, hw_queue); 921 _rtl_usb_transmit(hw, skb, hw_queue);
918 return NETDEV_TX_OK; 922 return NETDEV_TX_OK;
919 923
@@ -923,6 +927,7 @@ err_free:
923} 927}
924 928
925static bool rtl_usb_tx_chk_waitq_insert(struct ieee80211_hw *hw, 929static bool rtl_usb_tx_chk_waitq_insert(struct ieee80211_hw *hw,
930 struct ieee80211_sta *sta,
926 struct sk_buff *skb) 931 struct sk_buff *skb)
927{ 932{
928 return false; 933 return false;
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index cdaa21f29710..40153e7bf702 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -122,7 +122,7 @@ enum rt_eeprom_type {
122 EEPROM_BOOT_EFUSE, 122 EEPROM_BOOT_EFUSE,
123}; 123};
124 124
125enum rtl_status { 125enum ttl_status {
126 RTL_STATUS_INTERFACE_START = 0, 126 RTL_STATUS_INTERFACE_START = 0,
127}; 127};
128 128
@@ -1418,6 +1418,7 @@ struct rtl_hal_ops {
1418 void (*fill_tx_desc) (struct ieee80211_hw *hw, 1418 void (*fill_tx_desc) (struct ieee80211_hw *hw,
1419 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 1419 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
1420 struct ieee80211_tx_info *info, 1420 struct ieee80211_tx_info *info,
1421 struct ieee80211_sta *sta,
1421 struct sk_buff *skb, u8 hw_queue, 1422 struct sk_buff *skb, u8 hw_queue,
1422 struct rtl_tcb_desc *ptcb_desc); 1423 struct rtl_tcb_desc *ptcb_desc);
1423 void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc, 1424 void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc,
@@ -1475,11 +1476,15 @@ struct rtl_intf_ops {
1475 int (*adapter_start) (struct ieee80211_hw *hw); 1476 int (*adapter_start) (struct ieee80211_hw *hw);
1476 void (*adapter_stop) (struct ieee80211_hw *hw); 1477 void (*adapter_stop) (struct ieee80211_hw *hw);
1477 1478
1478 int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb, 1479 int (*adapter_tx) (struct ieee80211_hw *hw,
1479 struct rtl_tcb_desc *ptcb_desc); 1480 struct ieee80211_sta *sta,
1481 struct sk_buff *skb,
1482 struct rtl_tcb_desc *ptcb_desc);
1480 void (*flush)(struct ieee80211_hw *hw, bool drop); 1483 void (*flush)(struct ieee80211_hw *hw, bool drop);
1481 int (*reset_trx_ring) (struct ieee80211_hw *hw); 1484 int (*reset_trx_ring) (struct ieee80211_hw *hw);
1482 bool (*waitq_insert) (struct ieee80211_hw *hw, struct sk_buff *skb); 1485 bool (*waitq_insert) (struct ieee80211_hw *hw,
1486 struct ieee80211_sta *sta,
1487 struct sk_buff *skb);
1483 1488
1484 /*pci */ 1489 /*pci */
1485 void (*disable_aspm) (struct ieee80211_hw *hw); 1490 void (*disable_aspm) (struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c
index 3118c425bcf1..441cbccbd381 100644
--- a/drivers/net/wireless/ti/wl1251/main.c
+++ b/drivers/net/wireless/ti/wl1251/main.c
@@ -354,7 +354,9 @@ out:
354 return ret; 354 return ret;
355} 355}
356 356
357static void wl1251_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 357static void wl1251_op_tx(struct ieee80211_hw *hw,
358 struct ieee80211_tx_control *control,
359 struct sk_buff *skb)
358{ 360{
359 struct wl1251 *wl = hw->priv; 361 struct wl1251 *wl = hw->priv;
360 unsigned long flags; 362 unsigned long flags;
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index 72548609f711..ff830cf50c70 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -1181,7 +1181,9 @@ out:
1181 return ret; 1181 return ret;
1182} 1182}
1183 1183
1184static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 1184static void wl1271_op_tx(struct ieee80211_hw *hw,
1185 struct ieee80211_tx_control *control,
1186 struct sk_buff *skb)
1185{ 1187{
1186 struct wl1271 *wl = hw->priv; 1188 struct wl1271 *wl = hw->priv;
1187 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1189 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1197,7 +1199,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1197 mapping = skb_get_queue_mapping(skb); 1199 mapping = skb_get_queue_mapping(skb);
1198 q = wl1271_tx_get_queue(mapping); 1200 q = wl1271_tx_get_queue(mapping);
1199 1201
1200 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); 1202 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb, control->sta);
1201 1203
1202 spin_lock_irqsave(&wl->wl_lock, flags); 1204 spin_lock_irqsave(&wl->wl_lock, flags);
1203 1205
diff --git a/drivers/net/wireless/ti/wlcore/tx.c b/drivers/net/wireless/ti/wlcore/tx.c
index f0081f746482..1a2f31c289c5 100644
--- a/drivers/net/wireless/ti/wlcore/tx.c
+++ b/drivers/net/wireless/ti/wlcore/tx.c
@@ -130,16 +130,13 @@ bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb)
130} 130}
131EXPORT_SYMBOL(wl12xx_is_dummy_packet); 131EXPORT_SYMBOL(wl12xx_is_dummy_packet);
132 132
133u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, 133static u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif,
134 struct sk_buff *skb) 134 struct sk_buff *skb, struct ieee80211_sta *sta)
135{ 135{
136 struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); 136 if (sta) {
137
138 if (control->control.sta) {
139 struct wl1271_station *wl_sta; 137 struct wl1271_station *wl_sta;
140 138
141 wl_sta = (struct wl1271_station *) 139 wl_sta = (struct wl1271_station *)sta->drv_priv;
142 control->control.sta->drv_priv;
143 return wl_sta->hlid; 140 return wl_sta->hlid;
144 } else { 141 } else {
145 struct ieee80211_hdr *hdr; 142 struct ieee80211_hdr *hdr;
@@ -156,7 +153,7 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif,
156} 153}
157 154
158u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, 155u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif,
159 struct sk_buff *skb) 156 struct sk_buff *skb, struct ieee80211_sta *sta)
160{ 157{
161 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 158 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
162 159
@@ -164,7 +161,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif,
164 return wl->system_hlid; 161 return wl->system_hlid;
165 162
166 if (wlvif->bss_type == BSS_TYPE_AP_BSS) 163 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
167 return wl12xx_tx_get_hlid_ap(wl, wlvif, skb); 164 return wl12xx_tx_get_hlid_ap(wl, wlvif, skb, sta);
168 165
169 if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || 166 if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) ||
170 test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) && 167 test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) &&
@@ -344,13 +341,12 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif,
344 341
345/* caller must hold wl->mutex */ 342/* caller must hold wl->mutex */
346static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, 343static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
347 struct sk_buff *skb, u32 buf_offset) 344 struct sk_buff *skb, u32 buf_offset, u8 hlid)
348{ 345{
349 struct ieee80211_tx_info *info; 346 struct ieee80211_tx_info *info;
350 u32 extra = 0; 347 u32 extra = 0;
351 int ret = 0; 348 int ret = 0;
352 u32 total_len; 349 u32 total_len;
353 u8 hlid;
354 bool is_dummy; 350 bool is_dummy;
355 bool is_gem = false; 351 bool is_gem = false;
356 352
@@ -359,9 +355,13 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
359 return -EINVAL; 355 return -EINVAL;
360 } 356 }
361 357
358 if (hlid == WL12XX_INVALID_LINK_ID) {
359 wl1271_error("invalid hlid. dropping skb 0x%p", skb);
360 return -EINVAL;
361 }
362
362 info = IEEE80211_SKB_CB(skb); 363 info = IEEE80211_SKB_CB(skb);
363 364
364 /* TODO: handle dummy packets on multi-vifs */
365 is_dummy = wl12xx_is_dummy_packet(wl, skb); 365 is_dummy = wl12xx_is_dummy_packet(wl, skb);
366 366
367 if ((wl->quirks & WLCORE_QUIRK_TKIP_HEADER_SPACE) && 367 if ((wl->quirks & WLCORE_QUIRK_TKIP_HEADER_SPACE) &&
@@ -386,11 +386,6 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
386 386
387 is_gem = (cipher == WL1271_CIPHER_SUITE_GEM); 387 is_gem = (cipher == WL1271_CIPHER_SUITE_GEM);
388 } 388 }
389 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb);
390 if (hlid == WL12XX_INVALID_LINK_ID) {
391 wl1271_error("invalid hlid. dropping skb 0x%p", skb);
392 return -EINVAL;
393 }
394 389
395 ret = wl1271_tx_allocate(wl, wlvif, skb, extra, buf_offset, hlid, 390 ret = wl1271_tx_allocate(wl, wlvif, skb, extra, buf_offset, hlid,
396 is_gem); 391 is_gem);
@@ -517,7 +512,8 @@ static struct sk_buff *wl12xx_lnk_skb_dequeue(struct wl1271 *wl,
517} 512}
518 513
519static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, 514static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl,
520 struct wl12xx_vif *wlvif) 515 struct wl12xx_vif *wlvif,
516 u8 *hlid)
521{ 517{
522 struct sk_buff *skb = NULL; 518 struct sk_buff *skb = NULL;
523 int i, h, start_hlid; 519 int i, h, start_hlid;
@@ -544,10 +540,11 @@ static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl,
544 if (!skb) 540 if (!skb)
545 wlvif->last_tx_hlid = 0; 541 wlvif->last_tx_hlid = 0;
546 542
543 *hlid = wlvif->last_tx_hlid;
547 return skb; 544 return skb;
548} 545}
549 546
550static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) 547static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, u8 *hlid)
551{ 548{
552 unsigned long flags; 549 unsigned long flags;
553 struct wl12xx_vif *wlvif = wl->last_wlvif; 550 struct wl12xx_vif *wlvif = wl->last_wlvif;
@@ -556,7 +553,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
556 /* continue from last wlvif (round robin) */ 553 /* continue from last wlvif (round robin) */
557 if (wlvif) { 554 if (wlvif) {
558 wl12xx_for_each_wlvif_continue(wl, wlvif) { 555 wl12xx_for_each_wlvif_continue(wl, wlvif) {
559 skb = wl12xx_vif_skb_dequeue(wl, wlvif); 556 skb = wl12xx_vif_skb_dequeue(wl, wlvif, hlid);
560 if (skb) { 557 if (skb) {
561 wl->last_wlvif = wlvif; 558 wl->last_wlvif = wlvif;
562 break; 559 break;
@@ -565,13 +562,15 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
565 } 562 }
566 563
567 /* dequeue from the system HLID before the restarting wlvif list */ 564 /* dequeue from the system HLID before the restarting wlvif list */
568 if (!skb) 565 if (!skb) {
569 skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[wl->system_hlid]); 566 skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[wl->system_hlid]);
567 *hlid = wl->system_hlid;
568 }
570 569
571 /* do a new pass over the wlvif list */ 570 /* do a new pass over the wlvif list */
572 if (!skb) { 571 if (!skb) {
573 wl12xx_for_each_wlvif(wl, wlvif) { 572 wl12xx_for_each_wlvif(wl, wlvif) {
574 skb = wl12xx_vif_skb_dequeue(wl, wlvif); 573 skb = wl12xx_vif_skb_dequeue(wl, wlvif, hlid);
575 if (skb) { 574 if (skb) {
576 wl->last_wlvif = wlvif; 575 wl->last_wlvif = wlvif;
577 break; 576 break;
@@ -591,6 +590,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
591 int q; 590 int q;
592 591
593 skb = wl->dummy_packet; 592 skb = wl->dummy_packet;
593 *hlid = wl->system_hlid;
594 q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); 594 q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
595 spin_lock_irqsave(&wl->wl_lock, flags); 595 spin_lock_irqsave(&wl->wl_lock, flags);
596 WARN_ON_ONCE(wl->tx_queue_count[q] <= 0); 596 WARN_ON_ONCE(wl->tx_queue_count[q] <= 0);
@@ -602,7 +602,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
602} 602}
603 603
604static void wl1271_skb_queue_head(struct wl1271 *wl, struct wl12xx_vif *wlvif, 604static void wl1271_skb_queue_head(struct wl1271 *wl, struct wl12xx_vif *wlvif,
605 struct sk_buff *skb) 605 struct sk_buff *skb, u8 hlid)
606{ 606{
607 unsigned long flags; 607 unsigned long flags;
608 int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); 608 int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
@@ -610,7 +610,6 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct wl12xx_vif *wlvif,
610 if (wl12xx_is_dummy_packet(wl, skb)) { 610 if (wl12xx_is_dummy_packet(wl, skb)) {
611 set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); 611 set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags);
612 } else { 612 } else {
613 u8 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb);
614 skb_queue_head(&wl->links[hlid].tx_queue[q], skb); 613 skb_queue_head(&wl->links[hlid].tx_queue[q], skb);
615 614
616 /* make sure we dequeue the same packet next time */ 615 /* make sure we dequeue the same packet next time */
@@ -686,26 +685,30 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
686 unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0}; 685 unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0};
687 int ret = 0; 686 int ret = 0;
688 int bus_ret = 0; 687 int bus_ret = 0;
688 u8 hlid;
689 689
690 if (unlikely(wl->state == WL1271_STATE_OFF)) 690 if (unlikely(wl->state == WL1271_STATE_OFF))
691 return 0; 691 return 0;
692 692
693 while ((skb = wl1271_skb_dequeue(wl))) { 693 while ((skb = wl1271_skb_dequeue(wl, &hlid))) {
694 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 694 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
695 bool has_data = false; 695 bool has_data = false;
696 696
697 wlvif = NULL; 697 wlvif = NULL;
698 if (!wl12xx_is_dummy_packet(wl, skb) && info->control.vif) 698 if (!wl12xx_is_dummy_packet(wl, skb) && info->control.vif)
699 wlvif = wl12xx_vif_to_data(info->control.vif); 699 wlvif = wl12xx_vif_to_data(info->control.vif);
700 else
701 hlid = wl->system_hlid;
700 702
701 has_data = wlvif && wl1271_tx_is_data_present(skb); 703 has_data = wlvif && wl1271_tx_is_data_present(skb);
702 ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); 704 ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset,
705 hlid);
703 if (ret == -EAGAIN) { 706 if (ret == -EAGAIN) {
704 /* 707 /*
705 * Aggregation buffer is full. 708 * Aggregation buffer is full.
706 * Flush buffer and try again. 709 * Flush buffer and try again.
707 */ 710 */
708 wl1271_skb_queue_head(wl, wlvif, skb); 711 wl1271_skb_queue_head(wl, wlvif, skb, hlid);
709 712
710 buf_offset = wlcore_hw_pre_pkt_send(wl, buf_offset, 713 buf_offset = wlcore_hw_pre_pkt_send(wl, buf_offset,
711 last_len); 714 last_len);
@@ -722,7 +725,7 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
722 * Firmware buffer is full. 725 * Firmware buffer is full.
723 * Queue back last skb, and stop aggregating. 726 * Queue back last skb, and stop aggregating.
724 */ 727 */
725 wl1271_skb_queue_head(wl, wlvif, skb); 728 wl1271_skb_queue_head(wl, wlvif, skb, hlid);
726 /* No work left, avoid scheduling redundant tx work */ 729 /* No work left, avoid scheduling redundant tx work */
727 set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); 730 set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags);
728 goto out_ack; 731 goto out_ack;
@@ -732,7 +735,7 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
732 * fw still expects dummy packet, 735 * fw still expects dummy packet,
733 * so re-enqueue it 736 * so re-enqueue it
734 */ 737 */
735 wl1271_skb_queue_head(wl, wlvif, skb); 738 wl1271_skb_queue_head(wl, wlvif, skb, hlid);
736 else 739 else
737 ieee80211_free_txskb(wl->hw, skb); 740 ieee80211_free_txskb(wl->hw, skb);
738 goto out_ack; 741 goto out_ack;
diff --git a/drivers/net/wireless/ti/wlcore/tx.h b/drivers/net/wireless/ti/wlcore/tx.h
index 1e939b016155..349520d8b724 100644
--- a/drivers/net/wireless/ti/wlcore/tx.h
+++ b/drivers/net/wireless/ti/wlcore/tx.h
@@ -243,10 +243,8 @@ u8 wlcore_rate_to_idx(struct wl1271 *wl, u8 rate, enum ieee80211_band band);
243u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, 243u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set,
244 enum ieee80211_band rate_band); 244 enum ieee80211_band rate_band);
245u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set); 245u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set);
246u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif,
247 struct sk_buff *skb);
248u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, 246u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif,
249 struct sk_buff *skb); 247 struct sk_buff *skb, struct ieee80211_sta *sta);
250void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); 248void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid);
251void wl1271_handle_tx_low_watermark(struct wl1271 *wl); 249void wl1271_handle_tx_low_watermark(struct wl1271 *wl);
252bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); 250bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb);
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index c9e2660e1263..459880104758 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -937,7 +937,9 @@ static int fill_ctrlset(struct zd_mac *mac,
937 * control block of the skbuff will be initialized. If necessary the incoming 937 * control block of the skbuff will be initialized. If necessary the incoming
938 * mac80211 queues will be stopped. 938 * mac80211 queues will be stopped.
939 */ 939 */
940static void zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 940static void zd_op_tx(struct ieee80211_hw *hw,
941 struct ieee80211_tx_control *control,
942 struct sk_buff *skb)
941{ 943{
942 struct zd_mac *mac = zd_hw_mac(hw); 944 struct zd_mac *mac = zd_hw_mac(hw);
943 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 945 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1176,7 +1178,7 @@ static void zd_beacon_done(struct zd_mac *mac)
1176 skb = ieee80211_get_buffered_bc(mac->hw, mac->vif); 1178 skb = ieee80211_get_buffered_bc(mac->hw, mac->vif);
1177 if (!skb) 1179 if (!skb)
1178 break; 1180 break;
1179 zd_op_tx(mac->hw, skb); 1181 zd_op_tx(mac->hw, NULL, skb);
1180 } 1182 }
1181 1183
1182 /* 1184 /*
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index ef360547ecec..b76d95e180fa 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -119,7 +119,9 @@ static void wbsoft_configure_filter(struct ieee80211_hw *dev,
119 *total_flags = new_flags; 119 *total_flags = new_flags;
120} 120}
121 121
122static void wbsoft_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 122static void wbsoft_tx(struct ieee80211_hw *dev,
123 struct ieee80211_tx_control *control,
124 struct sk_buff *skb)
123{ 125{
124 struct wbsoft_priv *priv = dev->priv; 126 struct wbsoft_priv *priv = dev->priv;
125 127
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 2f3878806403..458416279347 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -565,6 +565,14 @@
565 * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ with 565 * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ with
566 * %NL80211_ATTR_WIPHY_CHANNEL_TYPE. 566 * %NL80211_ATTR_WIPHY_CHANNEL_TYPE.
567 * 567 *
568 * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
569 * its %NL80211_ATTR_WDEV identifier. It must have been created with
570 * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
571 * P2P Device can be used for P2P operations, e.g. remain-on-channel and
572 * public action frame TX.
573 * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
574 * its %NL80211_ATTR_WDEV identifier.
575 *
568 * @NL80211_CMD_MAX: highest used command number 576 * @NL80211_CMD_MAX: highest used command number
569 * @__NL80211_CMD_AFTER_LAST: internal use 577 * @__NL80211_CMD_AFTER_LAST: internal use
570 */ 578 */
@@ -708,6 +716,9 @@ enum nl80211_commands {
708 716
709 NL80211_CMD_CH_SWITCH_NOTIFY, 717 NL80211_CMD_CH_SWITCH_NOTIFY,
710 718
719 NL80211_CMD_START_P2P_DEVICE,
720 NL80211_CMD_STOP_P2P_DEVICE,
721
711 /* add new commands above here */ 722 /* add new commands above here */
712 723
713 /* used to define NL80211_CMD_MAX below */ 724 /* used to define NL80211_CMD_MAX below */
@@ -1575,6 +1586,10 @@ enum nl80211_attrs {
1575 * @NL80211_IFTYPE_MESH_POINT: mesh point 1586 * @NL80211_IFTYPE_MESH_POINT: mesh point
1576 * @NL80211_IFTYPE_P2P_CLIENT: P2P client 1587 * @NL80211_IFTYPE_P2P_CLIENT: P2P client
1577 * @NL80211_IFTYPE_P2P_GO: P2P group owner 1588 * @NL80211_IFTYPE_P2P_GO: P2P group owner
1589 * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
1590 * and therefore can't be created in the normal ways, use the
1591 * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
1592 * commands to create and destroy one
1578 * @NL80211_IFTYPE_MAX: highest interface type number currently defined 1593 * @NL80211_IFTYPE_MAX: highest interface type number currently defined
1579 * @NUM_NL80211_IFTYPES: number of defined interface types 1594 * @NUM_NL80211_IFTYPES: number of defined interface types
1580 * 1595 *
@@ -1593,6 +1608,7 @@ enum nl80211_iftype {
1593 NL80211_IFTYPE_MESH_POINT, 1608 NL80211_IFTYPE_MESH_POINT,
1594 NL80211_IFTYPE_P2P_CLIENT, 1609 NL80211_IFTYPE_P2P_CLIENT,
1595 NL80211_IFTYPE_P2P_GO, 1610 NL80211_IFTYPE_P2P_GO,
1611 NL80211_IFTYPE_P2P_DEVICE,
1596 1612
1597 /* keep last */ 1613 /* keep last */
1598 NUM_NL80211_IFTYPES, 1614 NUM_NL80211_IFTYPES,
@@ -2994,12 +3010,18 @@ enum nl80211_ap_sme_features {
2994 * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested 3010 * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
2995 * to work properly to suppport receiving regulatory hints from 3011 * to work properly to suppport receiving regulatory hints from
2996 * cellular base stations. 3012 * cellular base stations.
3013 * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: If this is set, an active
3014 * P2P Device (%NL80211_IFTYPE_P2P_DEVICE) requires its own channel
3015 * in the interface combinations, even when it's only used for scan
3016 * and remain-on-channel. This could be due to, for example, the
3017 * remain-on-channel implementation requiring a channel context.
2997 */ 3018 */
2998enum nl80211_feature_flags { 3019enum nl80211_feature_flags {
2999 NL80211_FEATURE_SK_TX_STATUS = 1 << 0, 3020 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
3000 NL80211_FEATURE_HT_IBSS = 1 << 1, 3021 NL80211_FEATURE_HT_IBSS = 1 << 1,
3001 NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2, 3022 NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
3002 NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3, 3023 NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
3024 NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
3003}; 3025};
3004 3026
3005/** 3027/**
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 493fa0c79005..4c518f1f1aca 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1437,7 +1437,8 @@ struct cfg80211_gtk_rekey_data {
1437 * @add_virtual_intf: create a new virtual interface with the given name, 1437 * @add_virtual_intf: create a new virtual interface with the given name,
1438 * must set the struct wireless_dev's iftype. Beware: You must create 1438 * must set the struct wireless_dev's iftype. Beware: You must create
1439 * the new netdev in the wiphy's network namespace! Returns the struct 1439 * the new netdev in the wiphy's network namespace! Returns the struct
1440 * wireless_dev, or an ERR_PTR. 1440 * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
1441 * also set the address member in the wdev.
1441 * 1442 *
1442 * @del_virtual_intf: remove the virtual interface 1443 * @del_virtual_intf: remove the virtual interface
1443 * 1444 *
@@ -1616,6 +1617,9 @@ struct cfg80211_gtk_rekey_data {
1616 * @get_channel: Get the current operating channel for the virtual interface. 1617 * @get_channel: Get the current operating channel for the virtual interface.
1617 * For monitor interfaces, it should return %NULL unless there's a single 1618 * For monitor interfaces, it should return %NULL unless there's a single
1618 * current monitoring channel. 1619 * current monitoring channel.
1620 *
1621 * @start_p2p_device: Start the given P2P device.
1622 * @stop_p2p_device: Stop the given P2P device.
1619 */ 1623 */
1620struct cfg80211_ops { 1624struct cfg80211_ops {
1621 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); 1625 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -1832,6 +1836,11 @@ struct cfg80211_ops {
1832 (*get_channel)(struct wiphy *wiphy, 1836 (*get_channel)(struct wiphy *wiphy,
1833 struct wireless_dev *wdev, 1837 struct wireless_dev *wdev,
1834 enum nl80211_channel_type *type); 1838 enum nl80211_channel_type *type);
1839
1840 int (*start_p2p_device)(struct wiphy *wiphy,
1841 struct wireless_dev *wdev);
1842 void (*stop_p2p_device)(struct wiphy *wiphy,
1843 struct wireless_dev *wdev);
1835}; 1844};
1836 1845
1837/* 1846/*
@@ -2395,6 +2404,8 @@ struct cfg80211_cached_keys;
2395 * @cleanup_work: work struct used for cleanup that can't be done directly 2404 * @cleanup_work: work struct used for cleanup that can't be done directly
2396 * @beacon_interval: beacon interval used on this device for transmitting 2405 * @beacon_interval: beacon interval used on this device for transmitting
2397 * beacons, 0 when not valid 2406 * beacons, 0 when not valid
2407 * @address: The address for this device, valid only if @netdev is %NULL
2408 * @p2p_started: true if this is a P2P Device that has been started
2398 */ 2409 */
2399struct wireless_dev { 2410struct wireless_dev {
2400 struct wiphy *wiphy; 2411 struct wiphy *wiphy;
@@ -2413,7 +2424,9 @@ struct wireless_dev {
2413 2424
2414 struct work_struct cleanup_work; 2425 struct work_struct cleanup_work;
2415 2426
2416 bool use_4addr; 2427 bool use_4addr, p2p_started;
2428
2429 u8 address[ETH_ALEN] __aligned(sizeof(u16));
2417 2430
2418 /* currently used for IBSS and SME - might be rearranged later */ 2431 /* currently used for IBSS and SME - might be rearranged later */
2419 u8 ssid[IEEE80211_MAX_SSID_LEN]; 2432 u8 ssid[IEEE80211_MAX_SSID_LEN];
@@ -2461,6 +2474,13 @@ struct wireless_dev {
2461#endif 2474#endif
2462}; 2475};
2463 2476
2477static inline u8 *wdev_address(struct wireless_dev *wdev)
2478{
2479 if (wdev->netdev)
2480 return wdev->netdev->dev_addr;
2481 return wdev->address;
2482}
2483
2464/** 2484/**
2465 * wdev_priv - return wiphy priv from wireless_dev 2485 * wdev_priv - return wiphy priv from wireless_dev
2466 * 2486 *
@@ -3528,6 +3548,22 @@ void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
3528 */ 3548 */
3529u32 cfg80211_calculate_bitrate(struct rate_info *rate); 3549u32 cfg80211_calculate_bitrate(struct rate_info *rate);
3530 3550
3551/**
3552 * cfg80211_unregister_wdev - remove the given wdev
3553 * @wdev: struct wireless_dev to remove
3554 *
3555 * Call this function only for wdevs that have no netdev assigned,
3556 * e.g. P2P Devices. It removes the device from the list so that
3557 * it can no longer be used. It is necessary to call this function
3558 * even when cfg80211 requests the removal of the interface by
3559 * calling the del_virtual_intf() callback. The function must also
3560 * be called when the driver wishes to unregister the wdev, e.g.
3561 * when the device is unbound from the driver.
3562 *
3563 * Requires the RTNL to be held.
3564 */
3565void cfg80211_unregister_wdev(struct wireless_dev *wdev);
3566
3531/* Logging, debugging and troubleshooting/diagnostic helpers. */ 3567/* Logging, debugging and troubleshooting/diagnostic helpers. */
3532 3568
3533/* wiphy_printk helpers, similar to dev_printk */ 3569/* wiphy_printk helpers, similar to dev_printk */
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index 71392545d0a1..7f0df133d119 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -183,6 +183,9 @@ struct ieee80211_radiotap_header {
183 * Contains a bitmap of known fields/flags, the flags, and 183 * Contains a bitmap of known fields/flags, the flags, and
184 * the MCS index. 184 * the MCS index.
185 * 185 *
186 * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless
187 *
188 * Contains the AMPDU information for the subframe.
186 */ 189 */
187enum ieee80211_radiotap_type { 190enum ieee80211_radiotap_type {
188 IEEE80211_RADIOTAP_TSFT = 0, 191 IEEE80211_RADIOTAP_TSFT = 0,
@@ -205,6 +208,7 @@ enum ieee80211_radiotap_type {
205 IEEE80211_RADIOTAP_DATA_RETRIES = 17, 208 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
206 209
207 IEEE80211_RADIOTAP_MCS = 19, 210 IEEE80211_RADIOTAP_MCS = 19,
211 IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
208 212
209 /* valid in every it_present bitmap, even vendor namespaces */ 213 /* valid in every it_present bitmap, even vendor namespaces */
210 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 214 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
@@ -270,6 +274,13 @@ enum ieee80211_radiotap_type {
270#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 274#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08
271#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 275#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
272 276
277/* For IEEE80211_RADIOTAP_AMPDU_STATUS */
278#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001
279#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002
280#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004
281#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008
282#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010
283#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020
273 284
274/* helpers */ 285/* helpers */
275static inline int ieee80211_get_radiotap_len(unsigned char *data) 286static inline int ieee80211_get_radiotap_len(unsigned char *data)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index bb86aa6f98dd..71f8262fc1df 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -171,6 +171,7 @@ struct ieee80211_low_level_stats {
171 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. 171 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
172 * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) 172 * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
173 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) 173 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
174 * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
174 */ 175 */
175enum ieee80211_bss_change { 176enum ieee80211_bss_change {
176 BSS_CHANGED_ASSOC = 1<<0, 177 BSS_CHANGED_ASSOC = 1<<0,
@@ -190,6 +191,7 @@ enum ieee80211_bss_change {
190 BSS_CHANGED_IDLE = 1<<14, 191 BSS_CHANGED_IDLE = 1<<14,
191 BSS_CHANGED_SSID = 1<<15, 192 BSS_CHANGED_SSID = 1<<15,
192 BSS_CHANGED_AP_PROBE_RESP = 1<<16, 193 BSS_CHANGED_AP_PROBE_RESP = 1<<16,
194 BSS_CHANGED_PS = 1<<17,
193 195
194 /* when adding here, make sure to change ieee80211_reconfig */ 196 /* when adding here, make sure to change ieee80211_reconfig */
195}; 197};
@@ -266,6 +268,8 @@ enum ieee80211_rssi_event {
266 * @idle: This interface is idle. There's also a global idle flag in the 268 * @idle: This interface is idle. There's also a global idle flag in the
267 * hardware config which may be more appropriate depending on what 269 * hardware config which may be more appropriate depending on what
268 * your driver/device needs to do. 270 * your driver/device needs to do.
271 * @ps: power-save mode (STA only). This flag is NOT affected by
272 * offchannel/dynamic_ps operations.
269 * @ssid: The SSID of the current vif. Only valid in AP-mode. 273 * @ssid: The SSID of the current vif. Only valid in AP-mode.
270 * @ssid_len: Length of SSID given in @ssid. 274 * @ssid_len: Length of SSID given in @ssid.
271 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. 275 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
@@ -296,6 +300,7 @@ struct ieee80211_bss_conf {
296 bool arp_filter_enabled; 300 bool arp_filter_enabled;
297 bool qos; 301 bool qos;
298 bool idle; 302 bool idle;
303 bool ps;
299 u8 ssid[IEEE80211_MAX_SSID_LEN]; 304 u8 ssid[IEEE80211_MAX_SSID_LEN];
300 size_t ssid_len; 305 size_t ssid_len;
301 bool hidden_ssid; 306 bool hidden_ssid;
@@ -522,9 +527,6 @@ struct ieee80211_tx_rate {
522 * (2) driver internal use (if applicable) 527 * (2) driver internal use (if applicable)
523 * (3) TX status information - driver tells mac80211 what happened 528 * (3) TX status information - driver tells mac80211 what happened
524 * 529 *
525 * The TX control's sta pointer is only valid during the ->tx call,
526 * it may be NULL.
527 *
528 * @flags: transmit info flags, defined above 530 * @flags: transmit info flags, defined above
529 * @band: the band to transmit on (use for checking for races) 531 * @band: the band to transmit on (use for checking for races)
530 * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC 532 * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC
@@ -555,6 +557,7 @@ struct ieee80211_tx_info {
555 struct ieee80211_tx_rate rates[ 557 struct ieee80211_tx_rate rates[
556 IEEE80211_TX_MAX_RATES]; 558 IEEE80211_TX_MAX_RATES];
557 s8 rts_cts_rate_idx; 559 s8 rts_cts_rate_idx;
560 /* 3 bytes free */
558 }; 561 };
559 /* only needed before rate control */ 562 /* only needed before rate control */
560 unsigned long jiffies; 563 unsigned long jiffies;
@@ -562,7 +565,7 @@ struct ieee80211_tx_info {
562 /* NB: vif can be NULL for injected frames */ 565 /* NB: vif can be NULL for injected frames */
563 struct ieee80211_vif *vif; 566 struct ieee80211_vif *vif;
564 struct ieee80211_key_conf *hw_key; 567 struct ieee80211_key_conf *hw_key;
565 struct ieee80211_sta *sta; 568 /* 8 bytes free */
566 } control; 569 } control;
567 struct { 570 struct {
568 struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES]; 571 struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
@@ -673,21 +676,41 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
673 * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if 676 * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if
674 * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT 677 * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT
675 * to hw.radiotap_mcs_details to advertise that fact 678 * to hw.radiotap_mcs_details to advertise that fact
679 * @RX_FLAG_AMPDU_DETAILS: A-MPDU details are known, in particular the reference
680 * number (@ampdu_reference) must be populated and be a distinct number for
681 * each A-MPDU
682 * @RX_FLAG_AMPDU_REPORT_ZEROLEN: driver reports 0-length subframes
683 * @RX_FLAG_AMPDU_IS_ZEROLEN: This is a zero-length subframe, for
684 * monitoring purposes only
685 * @RX_FLAG_AMPDU_LAST_KNOWN: last subframe is known, should be set on all
686 * subframes of a single A-MPDU
687 * @RX_FLAG_AMPDU_IS_LAST: this subframe is the last subframe of the A-MPDU
688 * @RX_FLAG_AMPDU_DELIM_CRC_ERROR: A delimiter CRC error has been detected
689 * on this subframe
690 * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
691 * is stored in the @ampdu_delimiter_crc field)
676 */ 692 */
677enum mac80211_rx_flags { 693enum mac80211_rx_flags {
678 RX_FLAG_MMIC_ERROR = 1<<0, 694 RX_FLAG_MMIC_ERROR = BIT(0),
679 RX_FLAG_DECRYPTED = 1<<1, 695 RX_FLAG_DECRYPTED = BIT(1),
680 RX_FLAG_MMIC_STRIPPED = 1<<3, 696 RX_FLAG_MMIC_STRIPPED = BIT(3),
681 RX_FLAG_IV_STRIPPED = 1<<4, 697 RX_FLAG_IV_STRIPPED = BIT(4),
682 RX_FLAG_FAILED_FCS_CRC = 1<<5, 698 RX_FLAG_FAILED_FCS_CRC = BIT(5),
683 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 699 RX_FLAG_FAILED_PLCP_CRC = BIT(6),
684 RX_FLAG_MACTIME_MPDU = 1<<7, 700 RX_FLAG_MACTIME_MPDU = BIT(7),
685 RX_FLAG_SHORTPRE = 1<<8, 701 RX_FLAG_SHORTPRE = BIT(8),
686 RX_FLAG_HT = 1<<9, 702 RX_FLAG_HT = BIT(9),
687 RX_FLAG_40MHZ = 1<<10, 703 RX_FLAG_40MHZ = BIT(10),
688 RX_FLAG_SHORT_GI = 1<<11, 704 RX_FLAG_SHORT_GI = BIT(11),
689 RX_FLAG_NO_SIGNAL_VAL = 1<<12, 705 RX_FLAG_NO_SIGNAL_VAL = BIT(12),
690 RX_FLAG_HT_GF = 1<<13, 706 RX_FLAG_HT_GF = BIT(13),
707 RX_FLAG_AMPDU_DETAILS = BIT(14),
708 RX_FLAG_AMPDU_REPORT_ZEROLEN = BIT(15),
709 RX_FLAG_AMPDU_IS_ZEROLEN = BIT(16),
710 RX_FLAG_AMPDU_LAST_KNOWN = BIT(17),
711 RX_FLAG_AMPDU_IS_LAST = BIT(18),
712 RX_FLAG_AMPDU_DELIM_CRC_ERROR = BIT(19),
713 RX_FLAG_AMPDU_DELIM_CRC_KNOWN = BIT(20),
691}; 714};
692 715
693/** 716/**
@@ -711,17 +734,22 @@ enum mac80211_rx_flags {
711 * HT rates are use (RX_FLAG_HT) 734 * HT rates are use (RX_FLAG_HT)
712 * @flag: %RX_FLAG_* 735 * @flag: %RX_FLAG_*
713 * @rx_flags: internal RX flags for mac80211 736 * @rx_flags: internal RX flags for mac80211
737 * @ampdu_reference: A-MPDU reference number, must be a different value for
738 * each A-MPDU but the same for each subframe within one A-MPDU
739 * @ampdu_delimiter_crc: A-MPDU delimiter CRC
714 */ 740 */
715struct ieee80211_rx_status { 741struct ieee80211_rx_status {
716 u64 mactime; 742 u64 mactime;
717 u32 device_timestamp; 743 u32 device_timestamp;
718 u16 flag; 744 u32 ampdu_reference;
745 u32 flag;
719 u16 freq; 746 u16 freq;
720 u8 rate_idx; 747 u8 rate_idx;
721 u8 rx_flags; 748 u8 rx_flags;
722 u8 band; 749 u8 band;
723 u8 antenna; 750 u8 antenna;
724 s8 signal; 751 s8 signal;
752 u8 ampdu_delimiter_crc;
725}; 753};
726 754
727/** 755/**
@@ -1074,6 +1102,16 @@ enum sta_notify_cmd {
1074}; 1102};
1075 1103
1076/** 1104/**
1105 * struct ieee80211_tx_control - TX control data
1106 *
1107 * @sta: station table entry, this sta pointer may be NULL and
1108 * it is not allowed to copy the pointer, due to RCU.
1109 */
1110struct ieee80211_tx_control {
1111 struct ieee80211_sta *sta;
1112};
1113
1114/**
1077 * enum ieee80211_hw_flags - hardware flags 1115 * enum ieee80211_hw_flags - hardware flags
1078 * 1116 *
1079 * These flags are used to indicate hardware capabilities to 1117 * These flags are used to indicate hardware capabilities to
@@ -1203,6 +1241,10 @@ enum sta_notify_cmd {
1203 * queue mapping in order to use different queues (not just one per AC) 1241 * queue mapping in order to use different queues (not just one per AC)
1204 * for different virtual interfaces. See the doc section on HW queue 1242 * for different virtual interfaces. See the doc section on HW queue
1205 * control for more details. 1243 * control for more details.
1244 *
1245 * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
1246 * P2P Interface. This will be honoured even if more than one interface
1247 * is supported.
1206 */ 1248 */
1207enum ieee80211_hw_flags { 1249enum ieee80211_hw_flags {
1208 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, 1250 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
@@ -1230,6 +1272,7 @@ enum ieee80211_hw_flags {
1230 IEEE80211_HW_AP_LINK_PS = 1<<22, 1272 IEEE80211_HW_AP_LINK_PS = 1<<22,
1231 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, 1273 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
1232 IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24, 1274 IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24,
1275 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
1233}; 1276};
1234 1277
1235/** 1278/**
@@ -1884,10 +1927,14 @@ enum ieee80211_frame_release_type {
1884 * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit 1927 * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit
1885 * to this station changed. 1928 * to this station changed.
1886 * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed. 1929 * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed.
1930 * @IEEE80211_RC_SUPP_RATES_CHANGED: The supported rate set of this peer
1931 * changed (in IBSS mode) due to discovering more information about
1932 * the peer.
1887 */ 1933 */
1888enum ieee80211_rate_control_changed { 1934enum ieee80211_rate_control_changed {
1889 IEEE80211_RC_BW_CHANGED = BIT(0), 1935 IEEE80211_RC_BW_CHANGED = BIT(0),
1890 IEEE80211_RC_SMPS_CHANGED = BIT(1), 1936 IEEE80211_RC_SMPS_CHANGED = BIT(1),
1937 IEEE80211_RC_SUPP_RATES_CHANGED = BIT(2),
1891}; 1938};
1892 1939
1893/** 1940/**
@@ -2264,7 +2311,9 @@ enum ieee80211_rate_control_changed {
2264 * The callback is optional and can (should!) sleep. 2311 * The callback is optional and can (should!) sleep.
2265 */ 2312 */
2266struct ieee80211_ops { 2313struct ieee80211_ops {
2267 void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 2314 void (*tx)(struct ieee80211_hw *hw,
2315 struct ieee80211_tx_control *control,
2316 struct sk_buff *skb);
2268 int (*start)(struct ieee80211_hw *hw); 2317 int (*start)(struct ieee80211_hw *hw);
2269 void (*stop)(struct ieee80211_hw *hw); 2318 void (*stop)(struct ieee80211_hw *hw);
2270#ifdef CONFIG_PM 2319#ifdef CONFIG_PM
diff --git a/net/mac80211/aes_cmac.c b/net/mac80211/aes_cmac.c
index 8dfd70d8fcfb..a04752e91023 100644
--- a/net/mac80211/aes_cmac.c
+++ b/net/mac80211/aes_cmac.c
@@ -38,14 +38,10 @@ static void gf_mulx(u8 *pad)
38static void aes_128_cmac_vector(struct crypto_cipher *tfm, size_t num_elem, 38static void aes_128_cmac_vector(struct crypto_cipher *tfm, size_t num_elem,
39 const u8 *addr[], const size_t *len, u8 *mac) 39 const u8 *addr[], const size_t *len, u8 *mac)
40{ 40{
41 u8 scratch[2 * AES_BLOCK_SIZE]; 41 u8 cbc[AES_BLOCK_SIZE], pad[AES_BLOCK_SIZE];
42 u8 *cbc, *pad;
43 const u8 *pos, *end; 42 const u8 *pos, *end;
44 size_t i, e, left, total_len; 43 size_t i, e, left, total_len;
45 44
46 cbc = scratch;
47 pad = scratch + AES_BLOCK_SIZE;
48
49 memset(cbc, 0, AES_BLOCK_SIZE); 45 memset(cbc, 0, AES_BLOCK_SIZE);
50 46
51 total_len = 0; 47 total_len = 0;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index d41974aacf51..69b322f6ca2e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -102,6 +102,18 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
102 return 0; 102 return 0;
103} 103}
104 104
105static int ieee80211_start_p2p_device(struct wiphy *wiphy,
106 struct wireless_dev *wdev)
107{
108 return ieee80211_do_open(wdev, true);
109}
110
111static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
112 struct wireless_dev *wdev)
113{
114 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
115}
116
105static int ieee80211_set_noack_map(struct wiphy *wiphy, 117static int ieee80211_set_noack_map(struct wiphy *wiphy,
106 struct net_device *dev, 118 struct net_device *dev,
107 u16 noack_map) 119 u16 noack_map)
@@ -330,7 +342,7 @@ static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, in
330 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { 342 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
331 struct ieee80211_supported_band *sband; 343 struct ieee80211_supported_band *sband;
332 sband = sta->local->hw.wiphy->bands[ 344 sband = sta->local->hw.wiphy->bands[
333 sta->local->hw.conf.channel->band]; 345 sta->local->oper_channel->band];
334 rate->legacy = sband->bitrates[idx].bitrate; 346 rate->legacy = sband->bitrates[idx].bitrate;
335 } else 347 } else
336 rate->mcs = idx; 348 rate->mcs = idx;
@@ -725,25 +737,23 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
725static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, 737static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
726 const u8 *resp, size_t resp_len) 738 const u8 *resp, size_t resp_len)
727{ 739{
728 struct sk_buff *new, *old; 740 struct probe_resp *new, *old;
729 741
730 if (!resp || !resp_len) 742 if (!resp || !resp_len)
731 return 1; 743 return -EINVAL;
732 744
733 old = rtnl_dereference(sdata->u.ap.probe_resp); 745 old = rtnl_dereference(sdata->u.ap.probe_resp);
734 746
735 new = dev_alloc_skb(resp_len); 747 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
736 if (!new) 748 if (!new)
737 return -ENOMEM; 749 return -ENOMEM;
738 750
739 memcpy(skb_put(new, resp_len), resp, resp_len); 751 new->len = resp_len;
752 memcpy(new->data, resp, resp_len);
740 753
741 rcu_assign_pointer(sdata->u.ap.probe_resp, new); 754 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
742 if (old) { 755 if (old)
743 /* TODO: use call_rcu() */ 756 kfree_rcu(old, rcu_head);
744 synchronize_rcu();
745 dev_kfree_skb(old);
746 }
747 757
748 return 0; 758 return 0;
749} 759}
@@ -950,7 +960,7 @@ static void ieee80211_send_layer2_update(struct sta_info *sta)
950 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) 960 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
951 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ 961 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
952 962
953 memset(msg->da, 0xff, ETH_ALEN); 963 eth_broadcast_addr(msg->da);
954 memcpy(msg->sa, sta->sta.addr, ETH_ALEN); 964 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
955 msg->len = htons(6); 965 msg->len = htons(6);
956 msg->dsap = 0; 966 msg->dsap = 0;
@@ -1285,9 +1295,10 @@ static int ieee80211_change_station(struct wiphy *wiphy,
1285 mutex_unlock(&local->sta_mtx); 1295 mutex_unlock(&local->sta_mtx);
1286 1296
1287 if (sdata->vif.type == NL80211_IFTYPE_STATION && 1297 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1288 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) 1298 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1289 ieee80211_recalc_ps(local, -1); 1299 ieee80211_recalc_ps(local, -1);
1290 1300 ieee80211_recalc_ps_vif(sdata);
1301 }
1291 return 0; 1302 return 0;
1292} 1303}
1293 1304
@@ -1661,7 +1672,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1661 } 1672 }
1662 1673
1663 if (!sdata->vif.bss_conf.use_short_slot && 1674 if (!sdata->vif.bss_conf.use_short_slot &&
1664 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { 1675 sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) {
1665 sdata->vif.bss_conf.use_short_slot = true; 1676 sdata->vif.bss_conf.use_short_slot = true;
1666 changed |= BSS_CHANGED_ERP_SLOT; 1677 changed |= BSS_CHANGED_ERP_SLOT;
1667 } 1678 }
@@ -1775,6 +1786,7 @@ static int ieee80211_scan(struct wiphy *wiphy,
1775 case NL80211_IFTYPE_ADHOC: 1786 case NL80211_IFTYPE_ADHOC:
1776 case NL80211_IFTYPE_MESH_POINT: 1787 case NL80211_IFTYPE_MESH_POINT:
1777 case NL80211_IFTYPE_P2P_CLIENT: 1788 case NL80211_IFTYPE_P2P_CLIENT:
1789 case NL80211_IFTYPE_P2P_DEVICE:
1778 break; 1790 break;
1779 case NL80211_IFTYPE_P2P_GO: 1791 case NL80211_IFTYPE_P2P_GO:
1780 if (sdata->local->ops->hw_scan) 1792 if (sdata->local->ops->hw_scan)
@@ -1927,7 +1939,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
1927 enum nl80211_tx_power_setting type, int mbm) 1939 enum nl80211_tx_power_setting type, int mbm)
1928{ 1940{
1929 struct ieee80211_local *local = wiphy_priv(wiphy); 1941 struct ieee80211_local *local = wiphy_priv(wiphy);
1930 struct ieee80211_channel *chan = local->hw.conf.channel; 1942 struct ieee80211_channel *chan = local->oper_channel;
1931 u32 changes = 0; 1943 u32 changes = 0;
1932 1944
1933 switch (type) { 1945 switch (type) {
@@ -2079,6 +2091,7 @@ static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2079 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 2091 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2080 2092
2081 ieee80211_recalc_ps(local, -1); 2093 ieee80211_recalc_ps(local, -1);
2094 ieee80211_recalc_ps_vif(sdata);
2082 2095
2083 return 0; 2096 return 0;
2084} 2097}
@@ -2461,6 +2474,9 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
2461 if (!sdata->u.mgd.associated) 2474 if (!sdata->u.mgd.associated)
2462 need_offchan = true; 2475 need_offchan = true;
2463 break; 2476 break;
2477 case NL80211_IFTYPE_P2P_DEVICE:
2478 need_offchan = true;
2479 break;
2464 default: 2480 default:
2465 return -EOPNOTSUPP; 2481 return -EOPNOTSUPP;
2466 } 2482 }
@@ -2653,6 +2669,7 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2653 u16 status_code, struct sk_buff *skb) 2669 u16 status_code, struct sk_buff *skb)
2654{ 2670{
2655 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2671 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2672 struct ieee80211_local *local = sdata->local;
2656 struct ieee80211_tdls_data *tf; 2673 struct ieee80211_tdls_data *tf;
2657 2674
2658 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); 2675 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
@@ -2672,8 +2689,10 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2672 tf->u.setup_req.capability = 2689 tf->u.setup_req.capability =
2673 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2690 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2674 2691
2675 ieee80211_add_srates_ie(sdata, skb, false); 2692 ieee80211_add_srates_ie(sdata, skb, false,
2676 ieee80211_add_ext_srates_ie(sdata, skb, false); 2693 local->oper_channel->band);
2694 ieee80211_add_ext_srates_ie(sdata, skb, false,
2695 local->oper_channel->band);
2677 ieee80211_tdls_add_ext_capab(skb); 2696 ieee80211_tdls_add_ext_capab(skb);
2678 break; 2697 break;
2679 case WLAN_TDLS_SETUP_RESPONSE: 2698 case WLAN_TDLS_SETUP_RESPONSE:
@@ -2686,8 +2705,10 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2686 tf->u.setup_resp.capability = 2705 tf->u.setup_resp.capability =
2687 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2706 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2688 2707
2689 ieee80211_add_srates_ie(sdata, skb, false); 2708 ieee80211_add_srates_ie(sdata, skb, false,
2690 ieee80211_add_ext_srates_ie(sdata, skb, false); 2709 local->oper_channel->band);
2710 ieee80211_add_ext_srates_ie(sdata, skb, false,
2711 local->oper_channel->band);
2691 ieee80211_tdls_add_ext_capab(skb); 2712 ieee80211_tdls_add_ext_capab(skb);
2692 break; 2713 break;
2693 case WLAN_TDLS_SETUP_CONFIRM: 2714 case WLAN_TDLS_SETUP_CONFIRM:
@@ -2725,6 +2746,7 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2725 u16 status_code, struct sk_buff *skb) 2746 u16 status_code, struct sk_buff *skb)
2726{ 2747{
2727 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2748 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2749 struct ieee80211_local *local = sdata->local;
2728 struct ieee80211_mgmt *mgmt; 2750 struct ieee80211_mgmt *mgmt;
2729 2751
2730 mgmt = (void *)skb_put(skb, 24); 2752 mgmt = (void *)skb_put(skb, 24);
@@ -2747,8 +2769,10 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2747 mgmt->u.action.u.tdls_discover_resp.capability = 2769 mgmt->u.action.u.tdls_discover_resp.capability =
2748 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2770 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2749 2771
2750 ieee80211_add_srates_ie(sdata, skb, false); 2772 ieee80211_add_srates_ie(sdata, skb, false,
2751 ieee80211_add_ext_srates_ie(sdata, skb, false); 2773 local->oper_channel->band);
2774 ieee80211_add_ext_srates_ie(sdata, skb, false,
2775 local->oper_channel->band);
2752 ieee80211_tdls_add_ext_capab(skb); 2776 ieee80211_tdls_add_ext_capab(skb);
2753 break; 2777 break;
2754 default: 2778 default:
@@ -3005,6 +3029,8 @@ struct cfg80211_ops mac80211_config_ops = {
3005 .add_virtual_intf = ieee80211_add_iface, 3029 .add_virtual_intf = ieee80211_add_iface,
3006 .del_virtual_intf = ieee80211_del_iface, 3030 .del_virtual_intf = ieee80211_del_iface,
3007 .change_virtual_intf = ieee80211_change_iface, 3031 .change_virtual_intf = ieee80211_change_iface,
3032 .start_p2p_device = ieee80211_start_p2p_device,
3033 .stop_p2p_device = ieee80211_stop_p2p_device,
3008 .add_key = ieee80211_add_key, 3034 .add_key = ieee80211_add_key,
3009 .del_key = ieee80211_del_key, 3035 .del_key = ieee80211_del_key,
3010 .get_key = ieee80211_get_key, 3036 .get_key = ieee80211_get_key,
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index b8dfb440c8ef..97173f8144d4 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -63,8 +63,6 @@ DEBUGFS_READONLY_FILE(user_power, "%d",
63 local->user_power_level); 63 local->user_power_level);
64DEBUGFS_READONLY_FILE(power, "%d", 64DEBUGFS_READONLY_FILE(power, "%d",
65 local->hw.conf.power_level); 65 local->hw.conf.power_level);
66DEBUGFS_READONLY_FILE(frequency, "%d",
67 local->hw.conf.channel->center_freq);
68DEBUGFS_READONLY_FILE(total_ps_buffered, "%d", 66DEBUGFS_READONLY_FILE(total_ps_buffered, "%d",
69 local->total_ps_buffered); 67 local->total_ps_buffered);
70DEBUGFS_READONLY_FILE(wep_iv, "%#08x", 68DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
@@ -91,33 +89,6 @@ static const struct file_operations reset_ops = {
91 .llseek = noop_llseek, 89 .llseek = noop_llseek,
92}; 90};
93 91
94static ssize_t channel_type_read(struct file *file, char __user *user_buf,
95 size_t count, loff_t *ppos)
96{
97 struct ieee80211_local *local = file->private_data;
98 const char *buf;
99
100 switch (local->hw.conf.channel_type) {
101 case NL80211_CHAN_NO_HT:
102 buf = "no ht\n";
103 break;
104 case NL80211_CHAN_HT20:
105 buf = "ht20\n";
106 break;
107 case NL80211_CHAN_HT40MINUS:
108 buf = "ht40-\n";
109 break;
110 case NL80211_CHAN_HT40PLUS:
111 buf = "ht40+\n";
112 break;
113 default:
114 buf = "???";
115 break;
116 }
117
118 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
119}
120
121static ssize_t hwflags_read(struct file *file, char __user *user_buf, 92static ssize_t hwflags_read(struct file *file, char __user *user_buf,
122 size_t count, loff_t *ppos) 93 size_t count, loff_t *ppos)
123{ 94{
@@ -205,7 +176,6 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
205} 176}
206 177
207DEBUGFS_READONLY_FILE_OPS(hwflags); 178DEBUGFS_READONLY_FILE_OPS(hwflags);
208DEBUGFS_READONLY_FILE_OPS(channel_type);
209DEBUGFS_READONLY_FILE_OPS(queues); 179DEBUGFS_READONLY_FILE_OPS(queues);
210 180
211/* statistics stuff */ 181/* statistics stuff */
@@ -272,12 +242,10 @@ void debugfs_hw_add(struct ieee80211_local *local)
272 242
273 local->debugfs.keys = debugfs_create_dir("keys", phyd); 243 local->debugfs.keys = debugfs_create_dir("keys", phyd);
274 244
275 DEBUGFS_ADD(frequency);
276 DEBUGFS_ADD(total_ps_buffered); 245 DEBUGFS_ADD(total_ps_buffered);
277 DEBUGFS_ADD(wep_iv); 246 DEBUGFS_ADD(wep_iv);
278 DEBUGFS_ADD(queues); 247 DEBUGFS_ADD(queues);
279 DEBUGFS_ADD_MODE(reset, 0200); 248 DEBUGFS_ADD_MODE(reset, 0200);
280 DEBUGFS_ADD(channel_type);
281 DEBUGFS_ADD(hwflags); 249 DEBUGFS_ADD(hwflags);
282 DEBUGFS_ADD(user_power); 250 DEBUGFS_ADD(user_power);
283 DEBUGFS_ADD(power); 251 DEBUGFS_ADD(power);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index df9203199102..da9003b20004 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -9,7 +9,7 @@ static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
9{ 9{
10 WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), 10 WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", 11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata->dev->name, sdata->flags); 12 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
13} 13}
14 14
15static inline struct ieee80211_sub_if_data * 15static inline struct ieee80211_sub_if_data *
@@ -22,9 +22,11 @@ get_bss_sdata(struct ieee80211_sub_if_data *sdata)
22 return sdata; 22 return sdata;
23} 23}
24 24
25static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb) 25static inline void drv_tx(struct ieee80211_local *local,
26 struct ieee80211_tx_control *control,
27 struct sk_buff *skb)
26{ 28{
27 local->ops->tx(&local->hw, skb); 29 local->ops->tx(&local->hw, control, skb);
28} 30}
29 31
30static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, 32static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
@@ -526,6 +528,9 @@ static inline void drv_sta_rc_update(struct ieee80211_local *local,
526 sdata = get_bss_sdata(sdata); 528 sdata = get_bss_sdata(sdata);
527 check_sdata_in_driver(sdata); 529 check_sdata_in_driver(sdata);
528 530
531 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
532 sdata->vif.type != NL80211_IFTYPE_ADHOC);
533
529 trace_drv_sta_rc_update(local, sdata, sta, changed); 534 trace_drv_sta_rc_update(local, sdata, sta, changed);
530 if (local->ops->sta_rc_update) 535 if (local->ops->sta_rc_update)
531 local->ops->sta_rc_update(&local->hw, &sdata->vif, 536 local->ops->sta_rc_update(&local->hw, &sdata->vif,
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 5746d62faba1..a9d93285dba7 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -109,7 +109,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
109 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 109 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
110 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 110 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
111 IEEE80211_STYPE_PROBE_RESP); 111 IEEE80211_STYPE_PROBE_RESP);
112 memset(mgmt->da, 0xff, ETH_ALEN); 112 eth_broadcast_addr(mgmt->da);
113 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 113 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
114 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); 114 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN);
115 mgmt->u.beacon.beacon_int = cpu_to_le16(beacon_int); 115 mgmt->u.beacon.beacon_int = cpu_to_le16(beacon_int);
@@ -205,7 +205,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
205 mod_timer(&ifibss->timer, 205 mod_timer(&ifibss->timer,
206 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); 206 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
207 207
208 bss = cfg80211_inform_bss_frame(local->hw.wiphy, local->hw.conf.channel, 208 bss = cfg80211_inform_bss_frame(local->hw.wiphy, chan,
209 mgmt, skb->len, 0, GFP_KERNEL); 209 mgmt, skb->len, 0, GFP_KERNEL);
210 cfg80211_put_bss(bss); 210 cfg80211_put_bss(bss);
211 netif_carrier_on(sdata->dev); 211 netif_carrier_on(sdata->dev);
@@ -294,7 +294,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
294 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 294 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
295 struct ieee80211_local *local = sdata->local; 295 struct ieee80211_local *local = sdata->local;
296 struct sta_info *sta; 296 struct sta_info *sta;
297 int band = local->hw.conf.channel->band; 297 int band = local->oper_channel->band;
298 298
299 /* 299 /*
300 * XXX: Consider removing the least recently used entry and 300 * XXX: Consider removing the least recently used entry and
@@ -459,8 +459,11 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
459 } 459 }
460 } 460 }
461 461
462 if (sta && rates_updated) 462 if (sta && rates_updated) {
463 drv_sta_rc_update(local, sdata, &sta->sta,
464 IEEE80211_RC_SUPP_RATES_CHANGED);
463 rate_control_rate_init(sta); 465 rate_control_rate_init(sta);
466 }
464 467
465 rcu_read_unlock(); 468 rcu_read_unlock();
466 } 469 }
@@ -561,7 +564,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
561 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 564 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
562 struct ieee80211_local *local = sdata->local; 565 struct ieee80211_local *local = sdata->local;
563 struct sta_info *sta; 566 struct sta_info *sta;
564 int band = local->hw.conf.channel->band; 567 int band = local->oper_channel->band;
565 568
566 /* 569 /*
567 * XXX: Consider removing the least recently used entry and 570 * XXX: Consider removing the least recently used entry and
@@ -759,7 +762,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
759 return; 762 return;
760 } 763 }
761 sdata_info(sdata, "IBSS not allowed on %d MHz\n", 764 sdata_info(sdata, "IBSS not allowed on %d MHz\n",
762 local->hw.conf.channel->center_freq); 765 local->oper_channel->center_freq);
763 766
764 /* No IBSS found - decrease scan interval and continue 767 /* No IBSS found - decrease scan interval and continue
765 * scanning. */ 768 * scanning. */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index bb61f7718c4c..204bfedba306 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -193,8 +193,6 @@ struct ieee80211_tx_data {
193 struct sta_info *sta; 193 struct sta_info *sta;
194 struct ieee80211_key *key; 194 struct ieee80211_key *key;
195 195
196 struct ieee80211_channel *channel;
197
198 unsigned int flags; 196 unsigned int flags;
199}; 197};
200 198
@@ -274,9 +272,15 @@ struct beacon_data {
274 struct rcu_head rcu_head; 272 struct rcu_head rcu_head;
275}; 273};
276 274
275struct probe_resp {
276 struct rcu_head rcu_head;
277 int len;
278 u8 data[0];
279};
280
277struct ieee80211_if_ap { 281struct ieee80211_if_ap {
278 struct beacon_data __rcu *beacon; 282 struct beacon_data __rcu *beacon;
279 struct sk_buff __rcu *probe_resp; 283 struct probe_resp __rcu *probe_resp;
280 284
281 struct list_head vlans; 285 struct list_head vlans;
282 286
@@ -359,6 +363,7 @@ enum ieee80211_sta_flags {
359 IEEE80211_STA_NULLFUNC_ACKED = BIT(8), 363 IEEE80211_STA_NULLFUNC_ACKED = BIT(8),
360 IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9), 364 IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9),
361 IEEE80211_STA_DISABLE_40MHZ = BIT(10), 365 IEEE80211_STA_DISABLE_40MHZ = BIT(10),
366 IEEE80211_STA_DISABLE_VHT = BIT(11),
362}; 367};
363 368
364struct ieee80211_mgd_auth_data { 369struct ieee80211_mgd_auth_data {
@@ -1075,6 +1080,8 @@ struct ieee80211_local {
1075 struct idr ack_status_frames; 1080 struct idr ack_status_frames;
1076 spinlock_t ack_status_lock; 1081 spinlock_t ack_status_lock;
1077 1082
1083 struct ieee80211_sub_if_data __rcu *p2p_sdata;
1084
1078 /* dummy netdev for use w/ NAPI */ 1085 /* dummy netdev for use w/ NAPI */
1079 struct net_device napi_dev; 1086 struct net_device napi_dev;
1080 1087
@@ -1131,7 +1138,7 @@ struct ieee802_11_elems {
1131 u8 *prep; 1138 u8 *prep;
1132 u8 *perr; 1139 u8 *perr;
1133 struct ieee80211_rann_ie *rann; 1140 struct ieee80211_rann_ie *rann;
1134 u8 *ch_switch_elem; 1141 struct ieee80211_channel_sw_ie *ch_switch_ie;
1135 u8 *country_elem; 1142 u8 *country_elem;
1136 u8 *pwr_constr_elem; 1143 u8 *pwr_constr_elem;
1137 u8 *quiet_elem; /* first quite element */ 1144 u8 *quiet_elem; /* first quite element */
@@ -1157,7 +1164,6 @@ struct ieee802_11_elems {
1157 u8 preq_len; 1164 u8 preq_len;
1158 u8 prep_len; 1165 u8 prep_len;
1159 u8 perr_len; 1166 u8 perr_len;
1160 u8 ch_switch_elem_len;
1161 u8 country_elem_len; 1167 u8 country_elem_len;
1162 u8 pwr_constr_elem_len; 1168 u8 pwr_constr_elem_len;
1163 u8 quiet_elem_len; 1169 u8 quiet_elem_len;
@@ -1202,6 +1208,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
1202void ieee80211_send_pspoll(struct ieee80211_local *local, 1208void ieee80211_send_pspoll(struct ieee80211_local *local,
1203 struct ieee80211_sub_if_data *sdata); 1209 struct ieee80211_sub_if_data *sdata);
1204void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency); 1210void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1211void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
1205int ieee80211_max_network_latency(struct notifier_block *nb, 1212int ieee80211_max_network_latency(struct notifier_block *nb,
1206 unsigned long data, void *dummy); 1213 unsigned long data, void *dummy);
1207int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata); 1214int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
@@ -1291,6 +1298,8 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local);
1291void ieee80211_recalc_idle(struct ieee80211_local *local); 1298void ieee80211_recalc_idle(struct ieee80211_local *local);
1292void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata, 1299void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
1293 const int offset); 1300 const int offset);
1301int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1302void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
1294 1303
1295static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) 1304static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
1296{ 1305{
@@ -1425,7 +1434,6 @@ void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
1425 struct ieee80211_hdr *hdr); 1434 struct ieee80211_hdr *hdr);
1426void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, 1435void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
1427 struct ieee80211_hdr *hdr, bool ack); 1436 struct ieee80211_hdr *hdr, bool ack);
1428void ieee80211_beacon_connection_loss_work(struct work_struct *work);
1429 1437
1430void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw, 1438void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1431 enum queue_stop_reason reason); 1439 enum queue_stop_reason reason);
@@ -1457,13 +1465,15 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1457 u8 channel); 1465 u8 channel);
1458struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1466struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1459 u8 *dst, u32 ratemask, 1467 u8 *dst, u32 ratemask,
1468 struct ieee80211_channel *chan,
1460 const u8 *ssid, size_t ssid_len, 1469 const u8 *ssid, size_t ssid_len,
1461 const u8 *ie, size_t ie_len, 1470 const u8 *ie, size_t ie_len,
1462 bool directed); 1471 bool directed);
1463void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1472void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1464 const u8 *ssid, size_t ssid_len, 1473 const u8 *ssid, size_t ssid_len,
1465 const u8 *ie, size_t ie_len, 1474 const u8 *ie, size_t ie_len,
1466 u32 ratemask, bool directed, bool no_cck); 1475 u32 ratemask, bool directed, bool no_cck,
1476 struct ieee80211_channel *channel);
1467 1477
1468void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 1478void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
1469 const size_t supp_rates_len, 1479 const size_t supp_rates_len,
@@ -1487,9 +1497,11 @@ u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
1487u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap, 1497u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1488 u32 cap); 1498 u32 cap);
1489int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata, 1499int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
1490 struct sk_buff *skb, bool need_basic); 1500 struct sk_buff *skb, bool need_basic,
1501 enum ieee80211_band band);
1491int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata, 1502int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
1492 struct sk_buff *skb, bool need_basic); 1503 struct sk_buff *skb, bool need_basic,
1504 enum ieee80211_band band);
1493 1505
1494/* channel management */ 1506/* channel management */
1495enum ieee80211_chan_mode { 1507enum ieee80211_chan_mode {
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index bfb57dcc1538..59f8adc2aa5f 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -100,6 +100,10 @@ static u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
100 sdata->vif.bss_conf.idle = true; 100 sdata->vif.bss_conf.idle = true;
101 continue; 101 continue;
102 } 102 }
103
104 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
105 continue;
106
103 /* count everything else */ 107 /* count everything else */
104 sdata->vif.bss_conf.idle = false; 108 sdata->vif.bss_conf.idle = false;
105 count++; 109 count++;
@@ -121,7 +125,8 @@ static u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
121 125
122 list_for_each_entry(sdata, &local->interfaces, list) { 126 list_for_each_entry(sdata, &local->interfaces, list) {
123 if (sdata->vif.type == NL80211_IFTYPE_MONITOR || 127 if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
124 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 128 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
129 sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
125 continue; 130 continue;
126 if (sdata->old_idle == sdata->vif.bss_conf.idle) 131 if (sdata->old_idle == sdata->vif.bss_conf.idle)
127 continue; 132 continue;
@@ -204,6 +209,8 @@ static inline int identical_mac_addr_allowed(int type1, int type2)
204{ 209{
205 return type1 == NL80211_IFTYPE_MONITOR || 210 return type1 == NL80211_IFTYPE_MONITOR ||
206 type2 == NL80211_IFTYPE_MONITOR || 211 type2 == NL80211_IFTYPE_MONITOR ||
212 type1 == NL80211_IFTYPE_P2P_DEVICE ||
213 type2 == NL80211_IFTYPE_P2P_DEVICE ||
207 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_WDS) || 214 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_WDS) ||
208 (type1 == NL80211_IFTYPE_WDS && 215 (type1 == NL80211_IFTYPE_WDS &&
209 (type2 == NL80211_IFTYPE_WDS || 216 (type2 == NL80211_IFTYPE_WDS ||
@@ -406,9 +413,10 @@ static void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
406 * an error on interface type changes that have been pre-checked, so most 413 * an error on interface type changes that have been pre-checked, so most
407 * checks should be in ieee80211_check_concurrent_iface. 414 * checks should be in ieee80211_check_concurrent_iface.
408 */ 415 */
409static int ieee80211_do_open(struct net_device *dev, bool coming_up) 416int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
410{ 417{
411 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 418 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
419 struct net_device *dev = wdev->netdev;
412 struct ieee80211_local *local = sdata->local; 420 struct ieee80211_local *local = sdata->local;
413 struct sta_info *sta; 421 struct sta_info *sta;
414 u32 changed = 0; 422 u32 changed = 0;
@@ -443,6 +451,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
443 case NL80211_IFTYPE_STATION: 451 case NL80211_IFTYPE_STATION:
444 case NL80211_IFTYPE_MONITOR: 452 case NL80211_IFTYPE_MONITOR:
445 case NL80211_IFTYPE_ADHOC: 453 case NL80211_IFTYPE_ADHOC:
454 case NL80211_IFTYPE_P2P_DEVICE:
446 /* no special treatment */ 455 /* no special treatment */
447 break; 456 break;
448 case NL80211_IFTYPE_UNSPECIFIED: 457 case NL80211_IFTYPE_UNSPECIFIED:
@@ -471,7 +480,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
471 * Copy the hopefully now-present MAC address to 480 * Copy the hopefully now-present MAC address to
472 * this interface, if it has the special null one. 481 * this interface, if it has the special null one.
473 */ 482 */
474 if (is_zero_ether_addr(dev->dev_addr)) { 483 if (dev && is_zero_ether_addr(dev->dev_addr)) {
475 memcpy(dev->dev_addr, 484 memcpy(dev->dev_addr,
476 local->hw.wiphy->perm_addr, 485 local->hw.wiphy->perm_addr,
477 ETH_ALEN); 486 ETH_ALEN);
@@ -536,15 +545,23 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
536 local->fif_probe_req++; 545 local->fif_probe_req++;
537 } 546 }
538 547
539 changed |= ieee80211_reset_erp_info(sdata); 548 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
549 changed |= ieee80211_reset_erp_info(sdata);
540 ieee80211_bss_info_change_notify(sdata, changed); 550 ieee80211_bss_info_change_notify(sdata, changed);
541 551
542 if (sdata->vif.type == NL80211_IFTYPE_STATION || 552 switch (sdata->vif.type) {
543 sdata->vif.type == NL80211_IFTYPE_ADHOC || 553 case NL80211_IFTYPE_STATION:
544 sdata->vif.type == NL80211_IFTYPE_AP) 554 case NL80211_IFTYPE_ADHOC:
555 case NL80211_IFTYPE_AP:
556 case NL80211_IFTYPE_MESH_POINT:
545 netif_carrier_off(dev); 557 netif_carrier_off(dev);
546 else 558 break;
559 case NL80211_IFTYPE_WDS:
560 case NL80211_IFTYPE_P2P_DEVICE:
561 break;
562 default:
547 netif_carrier_on(dev); 563 netif_carrier_on(dev);
564 }
548 565
549 /* 566 /*
550 * set default queue parameters so drivers don't 567 * set default queue parameters so drivers don't
@@ -576,6 +593,9 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
576 } 593 }
577 594
578 rate_control_rate_init(sta); 595 rate_control_rate_init(sta);
596 netif_carrier_on(dev);
597 } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
598 rcu_assign_pointer(local->p2p_sdata, sdata);
579 } 599 }
580 600
581 /* 601 /*
@@ -601,7 +621,8 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
601 621
602 ieee80211_recalc_ps(local, -1); 622 ieee80211_recalc_ps(local, -1);
603 623
604 netif_tx_start_all_queues(dev); 624 if (dev)
625 netif_tx_start_all_queues(dev);
605 626
606 return 0; 627 return 0;
607 err_del_interface: 628 err_del_interface:
@@ -631,7 +652,7 @@ static int ieee80211_open(struct net_device *dev)
631 if (err) 652 if (err)
632 return err; 653 return err;
633 654
634 return ieee80211_do_open(dev, true); 655 return ieee80211_do_open(&sdata->wdev, true);
635} 656}
636 657
637static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, 658static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
@@ -652,7 +673,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
652 /* 673 /*
653 * Stop TX on this interface first. 674 * Stop TX on this interface first.
654 */ 675 */
655 netif_tx_stop_all_queues(sdata->dev); 676 if (sdata->dev)
677 netif_tx_stop_all_queues(sdata->dev);
656 678
657 ieee80211_roc_purge(sdata); 679 ieee80211_roc_purge(sdata);
658 680
@@ -691,14 +713,16 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
691 local->fif_probe_req--; 713 local->fif_probe_req--;
692 } 714 }
693 715
694 netif_addr_lock_bh(sdata->dev); 716 if (sdata->dev) {
695 spin_lock_bh(&local->filter_lock); 717 netif_addr_lock_bh(sdata->dev);
696 __hw_addr_unsync(&local->mc_list, &sdata->dev->mc, 718 spin_lock_bh(&local->filter_lock);
697 sdata->dev->addr_len); 719 __hw_addr_unsync(&local->mc_list, &sdata->dev->mc,
698 spin_unlock_bh(&local->filter_lock); 720 sdata->dev->addr_len);
699 netif_addr_unlock_bh(sdata->dev); 721 spin_unlock_bh(&local->filter_lock);
722 netif_addr_unlock_bh(sdata->dev);
700 723
701 ieee80211_configure_filter(local); 724 ieee80211_configure_filter(local);
725 }
702 726
703 del_timer_sync(&local->dynamic_ps_timer); 727 del_timer_sync(&local->dynamic_ps_timer);
704 cancel_work_sync(&local->dynamic_ps_enable_work); 728 cancel_work_sync(&local->dynamic_ps_enable_work);
@@ -708,7 +732,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
708 struct ieee80211_sub_if_data *vlan, *tmpsdata; 732 struct ieee80211_sub_if_data *vlan, *tmpsdata;
709 struct beacon_data *old_beacon = 733 struct beacon_data *old_beacon =
710 rtnl_dereference(sdata->u.ap.beacon); 734 rtnl_dereference(sdata->u.ap.beacon);
711 struct sk_buff *old_probe_resp = 735 struct probe_resp *old_probe_resp =
712 rtnl_dereference(sdata->u.ap.probe_resp); 736 rtnl_dereference(sdata->u.ap.probe_resp);
713 737
714 /* sdata_running will return false, so this will disable */ 738 /* sdata_running will return false, so this will disable */
@@ -720,7 +744,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
720 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); 744 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
721 synchronize_rcu(); 745 synchronize_rcu();
722 kfree(old_beacon); 746 kfree(old_beacon);
723 kfree_skb(old_probe_resp); 747 kfree(old_probe_resp);
724 748
725 /* down all dependent devices, that is VLANs */ 749 /* down all dependent devices, that is VLANs */
726 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, 750 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
@@ -759,6 +783,10 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
759 ieee80211_adjust_monitor_flags(sdata, -1); 783 ieee80211_adjust_monitor_flags(sdata, -1);
760 ieee80211_configure_filter(local); 784 ieee80211_configure_filter(local);
761 break; 785 break;
786 case NL80211_IFTYPE_P2P_DEVICE:
787 /* relies on synchronize_rcu() below */
788 rcu_assign_pointer(local->p2p_sdata, NULL);
789 /* fall through */
762 default: 790 default:
763 flush_work(&sdata->work); 791 flush_work(&sdata->work);
764 /* 792 /*
@@ -771,14 +799,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
771 skb_queue_purge(&sdata->skb_queue); 799 skb_queue_purge(&sdata->skb_queue);
772 800
773 /* 801 /*
774 * Disable beaconing here for mesh only, AP and IBSS
775 * are already taken care of.
776 */
777 if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
778 ieee80211_bss_info_change_notify(sdata,
779 BSS_CHANGED_BEACON_ENABLED);
780
781 /*
782 * Free all remaining keys, there shouldn't be any, 802 * Free all remaining keys, there shouldn't be any,
783 * except maybe group keys in AP more or WDS? 803 * except maybe group keys in AP more or WDS?
784 */ 804 */
@@ -877,9 +897,8 @@ static void ieee80211_set_multicast_list(struct net_device *dev)
877 * Called when the netdev is removed or, by the code below, before 897 * Called when the netdev is removed or, by the code below, before
878 * the interface type changes. 898 * the interface type changes.
879 */ 899 */
880static void ieee80211_teardown_sdata(struct net_device *dev) 900static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
881{ 901{
882 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
883 struct ieee80211_local *local = sdata->local; 902 struct ieee80211_local *local = sdata->local;
884 int flushed; 903 int flushed;
885 int i; 904 int i;
@@ -900,6 +919,11 @@ static void ieee80211_teardown_sdata(struct net_device *dev)
900 WARN_ON(flushed); 919 WARN_ON(flushed);
901} 920}
902 921
922static void ieee80211_uninit(struct net_device *dev)
923{
924 ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
925}
926
903static u16 ieee80211_netdev_select_queue(struct net_device *dev, 927static u16 ieee80211_netdev_select_queue(struct net_device *dev,
904 struct sk_buff *skb) 928 struct sk_buff *skb)
905{ 929{
@@ -909,7 +933,7 @@ static u16 ieee80211_netdev_select_queue(struct net_device *dev,
909static const struct net_device_ops ieee80211_dataif_ops = { 933static const struct net_device_ops ieee80211_dataif_ops = {
910 .ndo_open = ieee80211_open, 934 .ndo_open = ieee80211_open,
911 .ndo_stop = ieee80211_stop, 935 .ndo_stop = ieee80211_stop,
912 .ndo_uninit = ieee80211_teardown_sdata, 936 .ndo_uninit = ieee80211_uninit,
913 .ndo_start_xmit = ieee80211_subif_start_xmit, 937 .ndo_start_xmit = ieee80211_subif_start_xmit,
914 .ndo_set_rx_mode = ieee80211_set_multicast_list, 938 .ndo_set_rx_mode = ieee80211_set_multicast_list,
915 .ndo_change_mtu = ieee80211_change_mtu, 939 .ndo_change_mtu = ieee80211_change_mtu,
@@ -940,7 +964,7 @@ static u16 ieee80211_monitor_select_queue(struct net_device *dev,
940static const struct net_device_ops ieee80211_monitorif_ops = { 964static const struct net_device_ops ieee80211_monitorif_ops = {
941 .ndo_open = ieee80211_open, 965 .ndo_open = ieee80211_open,
942 .ndo_stop = ieee80211_stop, 966 .ndo_stop = ieee80211_stop,
943 .ndo_uninit = ieee80211_teardown_sdata, 967 .ndo_uninit = ieee80211_uninit,
944 .ndo_start_xmit = ieee80211_monitor_start_xmit, 968 .ndo_start_xmit = ieee80211_monitor_start_xmit,
945 .ndo_set_rx_mode = ieee80211_set_multicast_list, 969 .ndo_set_rx_mode = ieee80211_set_multicast_list,
946 .ndo_change_mtu = ieee80211_change_mtu, 970 .ndo_change_mtu = ieee80211_change_mtu,
@@ -1099,7 +1123,6 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1099 /* and set some type-dependent values */ 1123 /* and set some type-dependent values */
1100 sdata->vif.type = type; 1124 sdata->vif.type = type;
1101 sdata->vif.p2p = false; 1125 sdata->vif.p2p = false;
1102 sdata->dev->netdev_ops = &ieee80211_dataif_ops;
1103 sdata->wdev.iftype = type; 1126 sdata->wdev.iftype = type;
1104 1127
1105 sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE); 1128 sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE);
@@ -1107,8 +1130,11 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1107 1130
1108 sdata->noack_map = 0; 1131 sdata->noack_map = 0;
1109 1132
1110 /* only monitor differs */ 1133 /* only monitor/p2p-device differ */
1111 sdata->dev->type = ARPHRD_ETHER; 1134 if (sdata->dev) {
1135 sdata->dev->netdev_ops = &ieee80211_dataif_ops;
1136 sdata->dev->type = ARPHRD_ETHER;
1137 }
1112 1138
1113 skb_queue_head_init(&sdata->skb_queue); 1139 skb_queue_head_init(&sdata->skb_queue);
1114 INIT_WORK(&sdata->work, ieee80211_iface_work); 1140 INIT_WORK(&sdata->work, ieee80211_iface_work);
@@ -1146,6 +1172,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1146 break; 1172 break;
1147 case NL80211_IFTYPE_WDS: 1173 case NL80211_IFTYPE_WDS:
1148 case NL80211_IFTYPE_AP_VLAN: 1174 case NL80211_IFTYPE_AP_VLAN:
1175 case NL80211_IFTYPE_P2P_DEVICE:
1149 break; 1176 break;
1150 case NL80211_IFTYPE_UNSPECIFIED: 1177 case NL80211_IFTYPE_UNSPECIFIED:
1151 case NUM_NL80211_IFTYPES: 1178 case NUM_NL80211_IFTYPES:
@@ -1156,18 +1183,6 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1156 ieee80211_debugfs_add_netdev(sdata); 1183 ieee80211_debugfs_add_netdev(sdata);
1157} 1184}
1158 1185
1159static void ieee80211_clean_sdata(struct ieee80211_sub_if_data *sdata)
1160{
1161 switch (sdata->vif.type) {
1162 case NL80211_IFTYPE_MESH_POINT:
1163 mesh_path_flush_by_iface(sdata);
1164 break;
1165
1166 default:
1167 break;
1168 }
1169}
1170
1171static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata, 1186static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
1172 enum nl80211_iftype type) 1187 enum nl80211_iftype type)
1173{ 1188{
@@ -1225,7 +1240,7 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
1225 1240
1226 ieee80211_do_stop(sdata, false); 1241 ieee80211_do_stop(sdata, false);
1227 1242
1228 ieee80211_teardown_sdata(sdata->dev); 1243 ieee80211_teardown_sdata(sdata);
1229 1244
1230 ret = drv_change_interface(local, sdata, internal_type, p2p); 1245 ret = drv_change_interface(local, sdata, internal_type, p2p);
1231 if (ret) 1246 if (ret)
@@ -1240,7 +1255,7 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
1240 1255
1241 ieee80211_setup_sdata(sdata, type); 1256 ieee80211_setup_sdata(sdata, type);
1242 1257
1243 err = ieee80211_do_open(sdata->dev, false); 1258 err = ieee80211_do_open(&sdata->wdev, false);
1244 WARN(err, "type change: do_open returned %d", err); 1259 WARN(err, "type change: do_open returned %d", err);
1245 1260
1246 return ret; 1261 return ret;
@@ -1267,14 +1282,14 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1267 return ret; 1282 return ret;
1268 } else { 1283 } else {
1269 /* Purge and reset type-dependent state. */ 1284 /* Purge and reset type-dependent state. */
1270 ieee80211_teardown_sdata(sdata->dev); 1285 ieee80211_teardown_sdata(sdata);
1271 ieee80211_setup_sdata(sdata, type); 1286 ieee80211_setup_sdata(sdata, type);
1272 } 1287 }
1273 1288
1274 /* reset some values that shouldn't be kept across type changes */ 1289 /* reset some values that shouldn't be kept across type changes */
1275 sdata->vif.bss_conf.basic_rates = 1290 sdata->vif.bss_conf.basic_rates =
1276 ieee80211_mandatory_rates(sdata->local, 1291 ieee80211_mandatory_rates(sdata->local,
1277 sdata->local->hw.conf.channel->band); 1292 sdata->local->oper_channel->band);
1278 sdata->drop_unencrypted = 0; 1293 sdata->drop_unencrypted = 0;
1279 if (type == NL80211_IFTYPE_STATION) 1294 if (type == NL80211_IFTYPE_STATION)
1280 sdata->u.mgd.use_4addr = false; 1295 sdata->u.mgd.use_4addr = false;
@@ -1283,8 +1298,7 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1283} 1298}
1284 1299
1285static void ieee80211_assign_perm_addr(struct ieee80211_local *local, 1300static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1286 struct net_device *dev, 1301 u8 *perm_addr, enum nl80211_iftype type)
1287 enum nl80211_iftype type)
1288{ 1302{
1289 struct ieee80211_sub_if_data *sdata; 1303 struct ieee80211_sub_if_data *sdata;
1290 u64 mask, start, addr, val, inc; 1304 u64 mask, start, addr, val, inc;
@@ -1293,13 +1307,12 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1293 int i; 1307 int i;
1294 1308
1295 /* default ... something at least */ 1309 /* default ... something at least */
1296 memcpy(dev->perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN); 1310 memcpy(perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1297 1311
1298 if (is_zero_ether_addr(local->hw.wiphy->addr_mask) && 1312 if (is_zero_ether_addr(local->hw.wiphy->addr_mask) &&
1299 local->hw.wiphy->n_addresses <= 1) 1313 local->hw.wiphy->n_addresses <= 1)
1300 return; 1314 return;
1301 1315
1302
1303 mutex_lock(&local->iflist_mtx); 1316 mutex_lock(&local->iflist_mtx);
1304 1317
1305 switch (type) { 1318 switch (type) {
@@ -1312,11 +1325,24 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1312 list_for_each_entry(sdata, &local->interfaces, list) { 1325 list_for_each_entry(sdata, &local->interfaces, list) {
1313 if (sdata->vif.type != NL80211_IFTYPE_AP) 1326 if (sdata->vif.type != NL80211_IFTYPE_AP)
1314 continue; 1327 continue;
1315 memcpy(dev->perm_addr, sdata->vif.addr, ETH_ALEN); 1328 memcpy(perm_addr, sdata->vif.addr, ETH_ALEN);
1316 break; 1329 break;
1317 } 1330 }
1318 /* keep default if no AP interface present */ 1331 /* keep default if no AP interface present */
1319 break; 1332 break;
1333 case NL80211_IFTYPE_P2P_CLIENT:
1334 case NL80211_IFTYPE_P2P_GO:
1335 if (local->hw.flags & IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF) {
1336 list_for_each_entry(sdata, &local->interfaces, list) {
1337 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
1338 continue;
1339 if (!ieee80211_sdata_running(sdata))
1340 continue;
1341 memcpy(perm_addr, sdata->vif.addr, ETH_ALEN);
1342 goto out_unlock;
1343 }
1344 }
1345 /* otherwise fall through */
1320 default: 1346 default:
1321 /* assign a new address if possible -- try n_addresses first */ 1347 /* assign a new address if possible -- try n_addresses first */
1322 for (i = 0; i < local->hw.wiphy->n_addresses; i++) { 1348 for (i = 0; i < local->hw.wiphy->n_addresses; i++) {
@@ -1331,7 +1357,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1331 } 1357 }
1332 1358
1333 if (!used) { 1359 if (!used) {
1334 memcpy(dev->perm_addr, 1360 memcpy(perm_addr,
1335 local->hw.wiphy->addresses[i].addr, 1361 local->hw.wiphy->addresses[i].addr,
1336 ETH_ALEN); 1362 ETH_ALEN);
1337 break; 1363 break;
@@ -1382,7 +1408,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1382 } 1408 }
1383 1409
1384 if (!used) { 1410 if (!used) {
1385 memcpy(dev->perm_addr, tmp_addr, ETH_ALEN); 1411 memcpy(perm_addr, tmp_addr, ETH_ALEN);
1386 break; 1412 break;
1387 } 1413 }
1388 addr = (start & ~mask) | (val & mask); 1414 addr = (start & ~mask) | (val & mask);
@@ -1391,6 +1417,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1391 break; 1417 break;
1392 } 1418 }
1393 1419
1420 out_unlock:
1394 mutex_unlock(&local->iflist_mtx); 1421 mutex_unlock(&local->iflist_mtx);
1395} 1422}
1396 1423
@@ -1398,49 +1425,68 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1398 struct wireless_dev **new_wdev, enum nl80211_iftype type, 1425 struct wireless_dev **new_wdev, enum nl80211_iftype type,
1399 struct vif_params *params) 1426 struct vif_params *params)
1400{ 1427{
1401 struct net_device *ndev; 1428 struct net_device *ndev = NULL;
1402 struct ieee80211_sub_if_data *sdata = NULL; 1429 struct ieee80211_sub_if_data *sdata = NULL;
1403 int ret, i; 1430 int ret, i;
1404 int txqs = 1; 1431 int txqs = 1;
1405 1432
1406 ASSERT_RTNL(); 1433 ASSERT_RTNL();
1407 1434
1408 if (local->hw.queues >= IEEE80211_NUM_ACS) 1435 if (type == NL80211_IFTYPE_P2P_DEVICE) {
1409 txqs = IEEE80211_NUM_ACS; 1436 struct wireless_dev *wdev;
1410 1437
1411 ndev = alloc_netdev_mqs(sizeof(*sdata) + local->hw.vif_data_size, 1438 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size,
1412 name, ieee80211_if_setup, txqs, 1); 1439 GFP_KERNEL);
1413 if (!ndev) 1440 if (!sdata)
1414 return -ENOMEM; 1441 return -ENOMEM;
1415 dev_net_set(ndev, wiphy_net(local->hw.wiphy)); 1442 wdev = &sdata->wdev;
1416 1443
1417 ndev->needed_headroom = local->tx_headroom + 1444 sdata->dev = NULL;
1418 4*6 /* four MAC addresses */ 1445 strlcpy(sdata->name, name, IFNAMSIZ);
1419 + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */ 1446 ieee80211_assign_perm_addr(local, wdev->address, type);
1420 + 6 /* mesh */ 1447 memcpy(sdata->vif.addr, wdev->address, ETH_ALEN);
1421 + 8 /* rfc1042/bridge tunnel */ 1448 } else {
1422 - ETH_HLEN /* ethernet hard_header_len */ 1449 if (local->hw.queues >= IEEE80211_NUM_ACS)
1423 + IEEE80211_ENCRYPT_HEADROOM; 1450 txqs = IEEE80211_NUM_ACS;
1424 ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; 1451
1425 1452 ndev = alloc_netdev_mqs(sizeof(*sdata) +
1426 ret = dev_alloc_name(ndev, ndev->name); 1453 local->hw.vif_data_size,
1427 if (ret < 0) 1454 name, ieee80211_if_setup, txqs, 1);
1428 goto fail; 1455 if (!ndev)
1429 1456 return -ENOMEM;
1430 ieee80211_assign_perm_addr(local, ndev, type); 1457 dev_net_set(ndev, wiphy_net(local->hw.wiphy));
1431 memcpy(ndev->dev_addr, ndev->perm_addr, ETH_ALEN); 1458
1432 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy)); 1459 ndev->needed_headroom = local->tx_headroom +
1433 1460 4*6 /* four MAC addresses */
1434 /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ 1461 + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
1435 sdata = netdev_priv(ndev); 1462 + 6 /* mesh */
1436 ndev->ieee80211_ptr = &sdata->wdev; 1463 + 8 /* rfc1042/bridge tunnel */
1437 memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN); 1464 - ETH_HLEN /* ethernet hard_header_len */
1438 memcpy(sdata->name, ndev->name, IFNAMSIZ); 1465 + IEEE80211_ENCRYPT_HEADROOM;
1466 ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
1467
1468 ret = dev_alloc_name(ndev, ndev->name);
1469 if (ret < 0) {
1470 free_netdev(ndev);
1471 return ret;
1472 }
1473
1474 ieee80211_assign_perm_addr(local, ndev->perm_addr, type);
1475 memcpy(ndev->dev_addr, ndev->perm_addr, ETH_ALEN);
1476 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
1477
1478 /* don't use IEEE80211_DEV_TO_SUB_IF -- it checks too much */
1479 sdata = netdev_priv(ndev);
1480 ndev->ieee80211_ptr = &sdata->wdev;
1481 memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN);
1482 memcpy(sdata->name, ndev->name, IFNAMSIZ);
1483
1484 sdata->dev = ndev;
1485 }
1439 1486
1440 /* initialise type-independent data */ 1487 /* initialise type-independent data */
1441 sdata->wdev.wiphy = local->hw.wiphy; 1488 sdata->wdev.wiphy = local->hw.wiphy;
1442 sdata->local = local; 1489 sdata->local = local;
1443 sdata->dev = ndev;
1444#ifdef CONFIG_INET 1490#ifdef CONFIG_INET
1445 sdata->arp_filter_state = true; 1491 sdata->arp_filter_state = true;
1446#endif 1492#endif
@@ -1469,17 +1515,21 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1469 /* setup type-dependent data */ 1515 /* setup type-dependent data */
1470 ieee80211_setup_sdata(sdata, type); 1516 ieee80211_setup_sdata(sdata, type);
1471 1517
1472 if (params) { 1518 if (ndev) {
1473 ndev->ieee80211_ptr->use_4addr = params->use_4addr; 1519 if (params) {
1474 if (type == NL80211_IFTYPE_STATION) 1520 ndev->ieee80211_ptr->use_4addr = params->use_4addr;
1475 sdata->u.mgd.use_4addr = params->use_4addr; 1521 if (type == NL80211_IFTYPE_STATION)
1476 } 1522 sdata->u.mgd.use_4addr = params->use_4addr;
1523 }
1477 1524
1478 ndev->features |= local->hw.netdev_features; 1525 ndev->features |= local->hw.netdev_features;
1479 1526
1480 ret = register_netdevice(ndev); 1527 ret = register_netdevice(ndev);
1481 if (ret) 1528 if (ret) {
1482 goto fail; 1529 free_netdev(ndev);
1530 return ret;
1531 }
1532 }
1483 1533
1484 mutex_lock(&local->iflist_mtx); 1534 mutex_lock(&local->iflist_mtx);
1485 list_add_tail_rcu(&sdata->list, &local->interfaces); 1535 list_add_tail_rcu(&sdata->list, &local->interfaces);
@@ -1489,10 +1539,6 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1489 *new_wdev = &sdata->wdev; 1539 *new_wdev = &sdata->wdev;
1490 1540
1491 return 0; 1541 return 0;
1492
1493 fail:
1494 free_netdev(ndev);
1495 return ret;
1496} 1542}
1497 1543
1498void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata) 1544void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
@@ -1503,11 +1549,22 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
1503 list_del_rcu(&sdata->list); 1549 list_del_rcu(&sdata->list);
1504 mutex_unlock(&sdata->local->iflist_mtx); 1550 mutex_unlock(&sdata->local->iflist_mtx);
1505 1551
1506 /* clean up type-dependent data */
1507 ieee80211_clean_sdata(sdata);
1508
1509 synchronize_rcu(); 1552 synchronize_rcu();
1510 unregister_netdevice(sdata->dev); 1553
1554 if (sdata->dev) {
1555 unregister_netdevice(sdata->dev);
1556 } else {
1557 cfg80211_unregister_wdev(&sdata->wdev);
1558 kfree(sdata);
1559 }
1560}
1561
1562void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata)
1563{
1564 if (WARN_ON_ONCE(!test_bit(SDATA_STATE_RUNNING, &sdata->state)))
1565 return;
1566 ieee80211_do_stop(sdata, true);
1567 ieee80211_teardown_sdata(sdata);
1511} 1568}
1512 1569
1513/* 1570/*
@@ -1518,6 +1575,7 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
1518{ 1575{
1519 struct ieee80211_sub_if_data *sdata, *tmp; 1576 struct ieee80211_sub_if_data *sdata, *tmp;
1520 LIST_HEAD(unreg_list); 1577 LIST_HEAD(unreg_list);
1578 LIST_HEAD(wdev_list);
1521 1579
1522 ASSERT_RTNL(); 1580 ASSERT_RTNL();
1523 1581
@@ -1525,13 +1583,20 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
1525 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) { 1583 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1526 list_del(&sdata->list); 1584 list_del(&sdata->list);
1527 1585
1528 ieee80211_clean_sdata(sdata); 1586 if (sdata->dev)
1529 1587 unregister_netdevice_queue(sdata->dev, &unreg_list);
1530 unregister_netdevice_queue(sdata->dev, &unreg_list); 1588 else
1589 list_add(&sdata->list, &wdev_list);
1531 } 1590 }
1532 mutex_unlock(&local->iflist_mtx); 1591 mutex_unlock(&local->iflist_mtx);
1533 unregister_netdevice_many(&unreg_list); 1592 unregister_netdevice_many(&unreg_list);
1534 list_del(&unreg_list); 1593 list_del(&unreg_list);
1594
1595 list_for_each_entry_safe(sdata, tmp, &wdev_list, list) {
1596 list_del(&sdata->list);
1597 cfg80211_unregister_wdev(&sdata->wdev);
1598 kfree(sdata);
1599 }
1535} 1600}
1536 1601
1537static int netdev_notify(struct notifier_block *nb, 1602static int netdev_notify(struct notifier_block *nb,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index c26e231c733a..bd7529363193 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -207,6 +207,10 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
207 sdata->vif.bss_conf.bssid = NULL; 207 sdata->vif.bss_conf.bssid = NULL;
208 else if (ieee80211_vif_is_mesh(&sdata->vif)) { 208 else if (ieee80211_vif_is_mesh(&sdata->vif)) {
209 sdata->vif.bss_conf.bssid = zero; 209 sdata->vif.bss_conf.bssid = zero;
210 } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
211 sdata->vif.bss_conf.bssid = sdata->vif.addr;
212 WARN_ONCE(changed & ~(BSS_CHANGED_IDLE),
213 "P2P Device BSS changed %#x", changed);
210 } else { 214 } else {
211 WARN_ON(1); 215 WARN_ON(1);
212 return; 216 return;
@@ -514,6 +518,11 @@ ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = {
514 BIT(IEEE80211_STYPE_AUTH >> 4) | 518 BIT(IEEE80211_STYPE_AUTH >> 4) |
515 BIT(IEEE80211_STYPE_DEAUTH >> 4), 519 BIT(IEEE80211_STYPE_DEAUTH >> 4),
516 }, 520 },
521 [NL80211_IFTYPE_P2P_DEVICE] = {
522 .tx = 0xffff,
523 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
524 BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
525 },
517}; 526};
518 527
519static const struct ieee80211_ht_cap mac80211_ht_capa_mod_mask = { 528static const struct ieee80211_ht_cap mac80211_ht_capa_mod_mask = {
@@ -536,6 +545,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
536 int priv_size, i; 545 int priv_size, i;
537 struct wiphy *wiphy; 546 struct wiphy *wiphy;
538 547
548 if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config ||
549 !ops->add_interface || !ops->remove_interface ||
550 !ops->configure_filter))
551 return NULL;
552
539 if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) 553 if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove)))
540 return NULL; 554 return NULL;
541 555
@@ -588,13 +602,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
588 602
589 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); 603 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);
590 604
591 BUG_ON(!ops->tx);
592 BUG_ON(!ops->start);
593 BUG_ON(!ops->stop);
594 BUG_ON(!ops->config);
595 BUG_ON(!ops->add_interface);
596 BUG_ON(!ops->remove_interface);
597 BUG_ON(!ops->configure_filter);
598 local->ops = ops; 605 local->ops = ops;
599 606
600 /* set up some defaults */ 607 /* set up some defaults */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 856dcf49ce75..f4a636ffe023 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -109,11 +109,11 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
109 109
110 /* Disallow HT40+/- mismatch */ 110 /* Disallow HT40+/- mismatch */
111 if (ie->ht_operation && 111 if (ie->ht_operation &&
112 (local->_oper_channel_type == NL80211_CHAN_HT40MINUS || 112 (sdata->vif.bss_conf.channel_type == NL80211_CHAN_HT40MINUS ||
113 local->_oper_channel_type == NL80211_CHAN_HT40PLUS) && 113 sdata->vif.bss_conf.channel_type == NL80211_CHAN_HT40PLUS) &&
114 (sta_channel_type == NL80211_CHAN_HT40MINUS || 114 (sta_channel_type == NL80211_CHAN_HT40MINUS ||
115 sta_channel_type == NL80211_CHAN_HT40PLUS) && 115 sta_channel_type == NL80211_CHAN_HT40PLUS) &&
116 local->_oper_channel_type != sta_channel_type) 116 sdata->vif.bss_conf.channel_type != sta_channel_type)
117 goto mismatch; 117 goto mismatch;
118 118
119 return true; 119 return true;
@@ -355,17 +355,18 @@ int mesh_add_ds_params_ie(struct sk_buff *skb,
355{ 355{
356 struct ieee80211_local *local = sdata->local; 356 struct ieee80211_local *local = sdata->local;
357 struct ieee80211_supported_band *sband; 357 struct ieee80211_supported_band *sband;
358 struct ieee80211_channel *chan = local->oper_channel;
358 u8 *pos; 359 u8 *pos;
359 360
360 if (skb_tailroom(skb) < 3) 361 if (skb_tailroom(skb) < 3)
361 return -ENOMEM; 362 return -ENOMEM;
362 363
363 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 364 sband = local->hw.wiphy->bands[chan->band];
364 if (sband->band == IEEE80211_BAND_2GHZ) { 365 if (sband->band == IEEE80211_BAND_2GHZ) {
365 pos = skb_put(skb, 2 + 1); 366 pos = skb_put(skb, 2 + 1);
366 *pos++ = WLAN_EID_DS_PARAMS; 367 *pos++ = WLAN_EID_DS_PARAMS;
367 *pos++ = 1; 368 *pos++ = 1;
368 *pos++ = ieee80211_frequency_to_channel(local->hw.conf.channel->center_freq); 369 *pos++ = ieee80211_frequency_to_channel(chan->center_freq);
369 } 370 }
370 371
371 return 0; 372 return 0;
@@ -380,7 +381,7 @@ int mesh_add_ht_cap_ie(struct sk_buff *skb,
380 381
381 sband = local->hw.wiphy->bands[local->oper_channel->band]; 382 sband = local->hw.wiphy->bands[local->oper_channel->band];
382 if (!sband->ht_cap.ht_supported || 383 if (!sband->ht_cap.ht_supported ||
383 local->_oper_channel_type == NL80211_CHAN_NO_HT) 384 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT)
384 return 0; 385 return 0;
385 386
386 if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap)) 387 if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap))
@@ -397,7 +398,8 @@ int mesh_add_ht_oper_ie(struct sk_buff *skb,
397{ 398{
398 struct ieee80211_local *local = sdata->local; 399 struct ieee80211_local *local = sdata->local;
399 struct ieee80211_channel *channel = local->oper_channel; 400 struct ieee80211_channel *channel = local->oper_channel;
400 enum nl80211_channel_type channel_type = local->_oper_channel_type; 401 enum nl80211_channel_type channel_type =
402 sdata->vif.bss_conf.channel_type;
401 struct ieee80211_supported_band *sband = 403 struct ieee80211_supported_band *sband =
402 local->hw.wiphy->bands[channel->band]; 404 local->hw.wiphy->bands[channel->band];
403 struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; 405 struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap;
@@ -608,12 +610,14 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
608 sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL; 610 sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL;
609 sdata->vif.bss_conf.basic_rates = 611 sdata->vif.bss_conf.basic_rates =
610 ieee80211_mandatory_rates(sdata->local, 612 ieee80211_mandatory_rates(sdata->local,
611 sdata->local->hw.conf.channel->band); 613 sdata->local->oper_channel->band);
612 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | 614 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON |
613 BSS_CHANGED_BEACON_ENABLED | 615 BSS_CHANGED_BEACON_ENABLED |
614 BSS_CHANGED_HT | 616 BSS_CHANGED_HT |
615 BSS_CHANGED_BASIC_RATES | 617 BSS_CHANGED_BASIC_RATES |
616 BSS_CHANGED_BEACON_INT); 618 BSS_CHANGED_BEACON_INT);
619
620 netif_carrier_on(sdata->dev);
617} 621}
618 622
619void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) 623void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
@@ -621,9 +625,15 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
621 struct ieee80211_local *local = sdata->local; 625 struct ieee80211_local *local = sdata->local;
622 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 626 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
623 627
628 netif_carrier_off(sdata->dev);
629
630 /* stop the beacon */
624 ifmsh->mesh_id_len = 0; 631 ifmsh->mesh_id_len = 0;
625 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); 632 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
626 sta_info_flush(local, NULL); 633
634 /* flush STAs and mpaths on this iface */
635 sta_info_flush(sdata->local, sdata);
636 mesh_path_flush_by_iface(sdata);
627 637
628 del_timer_sync(&sdata->u.mesh.housekeeping_timer); 638 del_timer_sync(&sdata->u.mesh.housekeeping_timer);
629 del_timer_sync(&sdata->u.mesh.mesh_path_root_timer); 639 del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 13fd5b5fdb0a..25d0f17dec71 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -215,6 +215,9 @@ struct mesh_rmc {
215/* Maximum number of paths per interface */ 215/* Maximum number of paths per interface */
216#define MESH_MAX_MPATHS 1024 216#define MESH_MAX_MPATHS 1024
217 217
218/* Number of frames buffered per destination for unresolved destinations */
219#define MESH_FRAME_QUEUE_LEN 10
220
218/* Public interfaces */ 221/* Public interfaces */
219/* Various */ 222/* Various */
220int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, 223int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 494bc39f61a4..47aeee2d8db1 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -17,8 +17,6 @@
17#define MAX_METRIC 0xffffffff 17#define MAX_METRIC 0xffffffff
18#define ARITH_SHIFT 8 18#define ARITH_SHIFT 8
19 19
20/* Number of frames buffered per destination for unresolved destinations */
21#define MESH_FRAME_QUEUE_LEN 10
22#define MAX_PREQ_QUEUE_LEN 64 20#define MAX_PREQ_QUEUE_LEN 64
23 21
24/* Destination only */ 22/* Destination only */
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 075bc535c601..aa749818860e 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -203,23 +203,17 @@ void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
203{ 203{
204 struct sk_buff *skb; 204 struct sk_buff *skb;
205 struct ieee80211_hdr *hdr; 205 struct ieee80211_hdr *hdr;
206 struct sk_buff_head tmpq;
207 unsigned long flags; 206 unsigned long flags;
208 207
209 rcu_assign_pointer(mpath->next_hop, sta); 208 rcu_assign_pointer(mpath->next_hop, sta);
210 209
211 __skb_queue_head_init(&tmpq);
212
213 spin_lock_irqsave(&mpath->frame_queue.lock, flags); 210 spin_lock_irqsave(&mpath->frame_queue.lock, flags);
214 211 skb_queue_walk(&mpath->frame_queue, skb) {
215 while ((skb = __skb_dequeue(&mpath->frame_queue)) != NULL) {
216 hdr = (struct ieee80211_hdr *) skb->data; 212 hdr = (struct ieee80211_hdr *) skb->data;
217 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); 213 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN);
218 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN); 214 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN);
219 __skb_queue_tail(&tmpq, skb);
220 } 215 }
221 216
222 skb_queue_splice(&tmpq, &mpath->frame_queue);
223 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags); 217 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags);
224} 218}
225 219
@@ -285,40 +279,42 @@ static void mesh_path_move_to_queue(struct mesh_path *gate_mpath,
285 struct mesh_path *from_mpath, 279 struct mesh_path *from_mpath,
286 bool copy) 280 bool copy)
287{ 281{
288 struct sk_buff *skb, *cp_skb = NULL; 282 struct sk_buff *skb, *fskb, *tmp;
289 struct sk_buff_head gateq, failq; 283 struct sk_buff_head failq;
290 unsigned long flags; 284 unsigned long flags;
291 int num_skbs;
292 285
293 BUG_ON(gate_mpath == from_mpath); 286 BUG_ON(gate_mpath == from_mpath);
294 BUG_ON(!gate_mpath->next_hop); 287 BUG_ON(!gate_mpath->next_hop);
295 288
296 __skb_queue_head_init(&gateq);
297 __skb_queue_head_init(&failq); 289 __skb_queue_head_init(&failq);
298 290
299 spin_lock_irqsave(&from_mpath->frame_queue.lock, flags); 291 spin_lock_irqsave(&from_mpath->frame_queue.lock, flags);
300 skb_queue_splice_init(&from_mpath->frame_queue, &failq); 292 skb_queue_splice_init(&from_mpath->frame_queue, &failq);
301 spin_unlock_irqrestore(&from_mpath->frame_queue.lock, flags); 293 spin_unlock_irqrestore(&from_mpath->frame_queue.lock, flags);
302 294
303 num_skbs = skb_queue_len(&failq); 295 skb_queue_walk_safe(&failq, fskb, tmp) {
304 296 if (skb_queue_len(&gate_mpath->frame_queue) >=
305 while (num_skbs--) { 297 MESH_FRAME_QUEUE_LEN) {
306 skb = __skb_dequeue(&failq); 298 mpath_dbg(gate_mpath->sdata, "mpath queue full!\n");
307 if (copy) { 299 break;
308 cp_skb = skb_copy(skb, GFP_ATOMIC);
309 if (cp_skb)
310 __skb_queue_tail(&failq, cp_skb);
311 } 300 }
312 301
302 skb = skb_copy(fskb, GFP_ATOMIC);
303 if (WARN_ON(!skb))
304 break;
305
313 prepare_for_gate(skb, gate_mpath->dst, gate_mpath); 306 prepare_for_gate(skb, gate_mpath->dst, gate_mpath);
314 __skb_queue_tail(&gateq, skb); 307 skb_queue_tail(&gate_mpath->frame_queue, skb);
308
309 if (copy)
310 continue;
311
312 __skb_unlink(fskb, &failq);
313 kfree_skb(fskb);
315 } 314 }
316 315
317 spin_lock_irqsave(&gate_mpath->frame_queue.lock, flags);
318 skb_queue_splice(&gateq, &gate_mpath->frame_queue);
319 mpath_dbg(gate_mpath->sdata, "Mpath queue for gate %pM has %d frames\n", 316 mpath_dbg(gate_mpath->sdata, "Mpath queue for gate %pM has %d frames\n",
320 gate_mpath->dst, skb_queue_len(&gate_mpath->frame_queue)); 317 gate_mpath->dst, skb_queue_len(&gate_mpath->frame_queue));
321 spin_unlock_irqrestore(&gate_mpath->frame_queue.lock, flags);
322 318
323 if (!copy) 319 if (!copy)
324 return; 320 return;
@@ -531,7 +527,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
531 527
532 read_lock_bh(&pathtbl_resize_lock); 528 read_lock_bh(&pathtbl_resize_lock);
533 memcpy(new_mpath->dst, dst, ETH_ALEN); 529 memcpy(new_mpath->dst, dst, ETH_ALEN);
534 memset(new_mpath->rann_snd_addr, 0xff, ETH_ALEN); 530 eth_broadcast_addr(new_mpath->rann_snd_addr);
535 new_mpath->is_root = false; 531 new_mpath->is_root = false;
536 new_mpath->sdata = sdata; 532 new_mpath->sdata = sdata;
537 new_mpath->flags = 0; 533 new_mpath->flags = 0;
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index f20e9f26d137..9d7ad366ef09 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -117,7 +117,7 @@ static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
117 u16 ht_opmode; 117 u16 ht_opmode;
118 bool non_ht_sta = false, ht20_sta = false; 118 bool non_ht_sta = false, ht20_sta = false;
119 119
120 if (local->_oper_channel_type == NL80211_CHAN_NO_HT) 120 if (sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT)
121 return 0; 121 return 0;
122 122
123 rcu_read_lock(); 123 rcu_read_lock();
@@ -147,7 +147,8 @@ out:
147 147
148 if (non_ht_sta) 148 if (non_ht_sta)
149 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED; 149 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
150 else if (ht20_sta && local->_oper_channel_type > NL80211_CHAN_HT20) 150 else if (ht20_sta &&
151 sdata->vif.bss_conf.channel_type > NL80211_CHAN_HT20)
151 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ; 152 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
152 else 153 else
153 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; 154 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
@@ -215,12 +216,14 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
215 u8 *da, __le16 llid, __le16 plid, __le16 reason) { 216 u8 *da, __le16 llid, __le16 plid, __le16 reason) {
216 struct ieee80211_local *local = sdata->local; 217 struct ieee80211_local *local = sdata->local;
217 struct sk_buff *skb; 218 struct sk_buff *skb;
219 struct ieee80211_tx_info *info;
218 struct ieee80211_mgmt *mgmt; 220 struct ieee80211_mgmt *mgmt;
219 bool include_plid = false; 221 bool include_plid = false;
220 u16 peering_proto = 0; 222 u16 peering_proto = 0;
221 u8 *pos, ie_len = 4; 223 u8 *pos, ie_len = 4;
222 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) + 224 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
223 sizeof(mgmt->u.action.u.self_prot); 225 sizeof(mgmt->u.action.u.self_prot);
226 int err = -ENOMEM;
224 227
225 skb = dev_alloc_skb(local->tx_headroom + 228 skb = dev_alloc_skb(local->tx_headroom +
226 hdr_len + 229 hdr_len +
@@ -236,6 +239,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
236 sdata->u.mesh.ie_len); 239 sdata->u.mesh.ie_len);
237 if (!skb) 240 if (!skb)
238 return -1; 241 return -1;
242 info = IEEE80211_SKB_CB(skb);
239 skb_reserve(skb, local->tx_headroom); 243 skb_reserve(skb, local->tx_headroom);
240 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); 244 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
241 memset(mgmt, 0, hdr_len); 245 memset(mgmt, 0, hdr_len);
@@ -256,15 +260,18 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
256 pos = skb_put(skb, 2); 260 pos = skb_put(skb, 2);
257 memcpy(pos + 2, &plid, 2); 261 memcpy(pos + 2, &plid, 2);
258 } 262 }
259 if (ieee80211_add_srates_ie(sdata, skb, true) || 263 if (ieee80211_add_srates_ie(sdata, skb, true,
260 ieee80211_add_ext_srates_ie(sdata, skb, true) || 264 local->oper_channel->band) ||
265 ieee80211_add_ext_srates_ie(sdata, skb, true,
266 local->oper_channel->band) ||
261 mesh_add_rsn_ie(skb, sdata) || 267 mesh_add_rsn_ie(skb, sdata) ||
262 mesh_add_meshid_ie(skb, sdata) || 268 mesh_add_meshid_ie(skb, sdata) ||
263 mesh_add_meshconf_ie(skb, sdata)) 269 mesh_add_meshconf_ie(skb, sdata))
264 return -1; 270 goto free;
265 } else { /* WLAN_SP_MESH_PEERING_CLOSE */ 271 } else { /* WLAN_SP_MESH_PEERING_CLOSE */
272 info->flags |= IEEE80211_TX_CTL_NO_ACK;
266 if (mesh_add_meshid_ie(skb, sdata)) 273 if (mesh_add_meshid_ie(skb, sdata))
267 return -1; 274 goto free;
268 } 275 }
269 276
270 /* Add Mesh Peering Management element */ 277 /* Add Mesh Peering Management element */
@@ -283,11 +290,12 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
283 ie_len += 2; /* reason code */ 290 ie_len += 2; /* reason code */
284 break; 291 break;
285 default: 292 default:
286 return -EINVAL; 293 err = -EINVAL;
294 goto free;
287 } 295 }
288 296
289 if (WARN_ON(skb_tailroom(skb) < 2 + ie_len)) 297 if (WARN_ON(skb_tailroom(skb) < 2 + ie_len))
290 return -ENOMEM; 298 goto free;
291 299
292 pos = skb_put(skb, 2 + ie_len); 300 pos = skb_put(skb, 2 + ie_len);
293 *pos++ = WLAN_EID_PEER_MGMT; 301 *pos++ = WLAN_EID_PEER_MGMT;
@@ -308,14 +316,17 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
308 if (action != WLAN_SP_MESH_PEERING_CLOSE) { 316 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
309 if (mesh_add_ht_cap_ie(skb, sdata) || 317 if (mesh_add_ht_cap_ie(skb, sdata) ||
310 mesh_add_ht_oper_ie(skb, sdata)) 318 mesh_add_ht_oper_ie(skb, sdata))
311 return -1; 319 goto free;
312 } 320 }
313 321
314 if (mesh_add_vendor_ies(skb, sdata)) 322 if (mesh_add_vendor_ies(skb, sdata))
315 return -1; 323 goto free;
316 324
317 ieee80211_tx_skb(sdata, skb); 325 ieee80211_tx_skb(sdata, skb);
318 return 0; 326 return 0;
327free:
328 kfree_skb(skb);
329 return err;
319} 330}
320 331
321/** 332/**
@@ -360,9 +371,14 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata,
360 371
361 spin_lock_bh(&sta->lock); 372 spin_lock_bh(&sta->lock);
362 sta->last_rx = jiffies; 373 sta->last_rx = jiffies;
374 if (sta->plink_state == NL80211_PLINK_ESTAB) {
375 spin_unlock_bh(&sta->lock);
376 return sta;
377 }
378
363 sta->sta.supp_rates[band] = rates; 379 sta->sta.supp_rates[band] = rates;
364 if (elems->ht_cap_elem && 380 if (elems->ht_cap_elem &&
365 sdata->local->_oper_channel_type != NL80211_CHAN_NO_HT) 381 sdata->vif.bss_conf.channel_type != NL80211_CHAN_NO_HT)
366 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, 382 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
367 elems->ht_cap_elem, 383 elems->ht_cap_elem,
368 &sta->sta.ht_cap); 384 &sta->sta.ht_cap);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index cef0c9e79aba..b65b2149b23b 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -146,6 +146,9 @@ void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata)
146 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) 146 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
147 return; 147 return;
148 148
149 if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
150 return;
151
149 mod_timer(&sdata->u.mgd.bcn_mon_timer, 152 mod_timer(&sdata->u.mgd.bcn_mon_timer,
150 round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout)); 153 round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout));
151} 154}
@@ -182,15 +185,15 @@ static u32 ieee80211_config_ht_tx(struct ieee80211_sub_if_data *sdata,
182 u16 ht_opmode; 185 u16 ht_opmode;
183 bool disable_40 = false; 186 bool disable_40 = false;
184 187
185 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 188 sband = local->hw.wiphy->bands[local->oper_channel->band];
186 189
187 switch (sdata->vif.bss_conf.channel_type) { 190 switch (sdata->vif.bss_conf.channel_type) {
188 case NL80211_CHAN_HT40PLUS: 191 case NL80211_CHAN_HT40PLUS:
189 if (local->hw.conf.channel->flags & IEEE80211_CHAN_NO_HT40PLUS) 192 if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40PLUS)
190 disable_40 = true; 193 disable_40 = true;
191 break; 194 break;
192 case NL80211_CHAN_HT40MINUS: 195 case NL80211_CHAN_HT40MINUS:
193 if (local->hw.conf.channel->flags & IEEE80211_CHAN_NO_HT40MINUS) 196 if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40MINUS)
194 disable_40 = true; 197 disable_40 = true;
195 break; 198 break;
196 default: 199 default:
@@ -326,6 +329,26 @@ static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata,
326 ieee80211_ie_build_ht_cap(pos, &ht_cap, cap); 329 ieee80211_ie_build_ht_cap(pos, &ht_cap, cap);
327} 330}
328 331
332static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
333 struct sk_buff *skb,
334 struct ieee80211_supported_band *sband)
335{
336 u8 *pos;
337 u32 cap;
338 struct ieee80211_sta_vht_cap vht_cap;
339
340 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
341
342 memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap));
343
344 /* determine capability flags */
345 cap = vht_cap.cap;
346
347 /* reserve and fill IE */
348 pos = skb_put(skb, sizeof(struct ieee80211_vht_capabilities) + 2);
349 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
350}
351
329static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) 352static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
330{ 353{
331 struct ieee80211_local *local = sdata->local; 354 struct ieee80211_local *local = sdata->local;
@@ -371,6 +394,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
371 4 + /* power capability */ 394 4 + /* power capability */
372 2 + 2 * sband->n_channels + /* supported channels */ 395 2 + 2 * sband->n_channels + /* supported channels */
373 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ 396 2 + sizeof(struct ieee80211_ht_cap) + /* HT */
397 2 + sizeof(struct ieee80211_vht_capabilities) + /* VHT */
374 assoc_data->ie_len + /* extra IEs */ 398 assoc_data->ie_len + /* extra IEs */
375 9, /* WMM */ 399 9, /* WMM */
376 GFP_KERNEL); 400 GFP_KERNEL);
@@ -503,6 +527,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
503 ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, 527 ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param,
504 sband, local->oper_channel, ifmgd->ap_smps); 528 sband, local->oper_channel, ifmgd->ap_smps);
505 529
530 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
531 ieee80211_add_vht_ie(sdata, skb, sband);
532
506 /* if present, add any custom non-vendor IEs that go after HT */ 533 /* if present, add any custom non-vendor IEs that go after HT */
507 if (assoc_data->ie_len && assoc_data->ie) { 534 if (assoc_data->ie_len && assoc_data->ie) {
508 noffset = ieee80211_ie_split_vendor(assoc_data->ie, 535 noffset = ieee80211_ie_split_vendor(assoc_data->ie,
@@ -583,8 +610,6 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
583 IEEE80211_SKB_CB(skb)->flags |= 610 IEEE80211_SKB_CB(skb)->flags |=
584 IEEE80211_TX_INTFL_DONT_ENCRYPT; 611 IEEE80211_TX_INTFL_DONT_ENCRYPT;
585 612
586 drv_mgd_prepare_tx(local, sdata);
587
588 ieee80211_tx_skb(sdata, skb); 613 ieee80211_tx_skb(sdata, skb);
589 } 614 }
590} 615}
@@ -687,6 +712,7 @@ static void ieee80211_chswitch_work(struct work_struct *work)
687 /* XXX: shouldn't really modify cfg80211-owned data! */ 712 /* XXX: shouldn't really modify cfg80211-owned data! */
688 ifmgd->associated->channel = sdata->local->oper_channel; 713 ifmgd->associated->channel = sdata->local->oper_channel;
689 714
715 /* XXX: wait for a beacon first? */
690 ieee80211_wake_queues_by_reason(&sdata->local->hw, 716 ieee80211_wake_queues_by_reason(&sdata->local->hw,
691 IEEE80211_QUEUE_STOP_REASON_CSA); 717 IEEE80211_QUEUE_STOP_REASON_CSA);
692 out: 718 out:
@@ -763,36 +789,32 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
763 789
764 sdata->local->csa_channel = new_ch; 790 sdata->local->csa_channel = new_ch;
765 791
792 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
793
794 if (sw_elem->mode)
795 ieee80211_stop_queues_by_reason(&sdata->local->hw,
796 IEEE80211_QUEUE_STOP_REASON_CSA);
797
766 if (sdata->local->ops->channel_switch) { 798 if (sdata->local->ops->channel_switch) {
767 /* use driver's channel switch callback */ 799 /* use driver's channel switch callback */
768 struct ieee80211_channel_switch ch_switch; 800 struct ieee80211_channel_switch ch_switch = {
769 memset(&ch_switch, 0, sizeof(ch_switch)); 801 .timestamp = timestamp,
770 ch_switch.timestamp = timestamp; 802 .block_tx = sw_elem->mode,
771 if (sw_elem->mode) { 803 .channel = new_ch,
772 ch_switch.block_tx = true; 804 .count = sw_elem->count,
773 ieee80211_stop_queues_by_reason(&sdata->local->hw, 805 };
774 IEEE80211_QUEUE_STOP_REASON_CSA); 806
775 }
776 ch_switch.channel = new_ch;
777 ch_switch.count = sw_elem->count;
778 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
779 drv_channel_switch(sdata->local, &ch_switch); 807 drv_channel_switch(sdata->local, &ch_switch);
780 return; 808 return;
781 } 809 }
782 810
783 /* channel switch handled in software */ 811 /* channel switch handled in software */
784 if (sw_elem->count <= 1) { 812 if (sw_elem->count <= 1)
785 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); 813 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
786 } else { 814 else
787 if (sw_elem->mode)
788 ieee80211_stop_queues_by_reason(&sdata->local->hw,
789 IEEE80211_QUEUE_STOP_REASON_CSA);
790 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
791 mod_timer(&ifmgd->chswitch_timer, 815 mod_timer(&ifmgd->chswitch_timer,
792 jiffies + 816 TU_TO_EXP_TIME(sw_elem->count *
793 msecs_to_jiffies(sw_elem->count * 817 cbss->beacon_interval));
794 cbss->beacon_interval));
795 }
796} 818}
797 819
798static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, 820static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
@@ -1007,6 +1029,16 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency)
1007 ieee80211_change_ps(local); 1029 ieee80211_change_ps(local);
1008} 1030}
1009 1031
1032void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata)
1033{
1034 bool ps_allowed = ieee80211_powersave_allowed(sdata);
1035
1036 if (sdata->vif.bss_conf.ps != ps_allowed) {
1037 sdata->vif.bss_conf.ps = ps_allowed;
1038 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_PS);
1039 }
1040}
1041
1010void ieee80211_dynamic_ps_disable_work(struct work_struct *work) 1042void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
1011{ 1043{
1012 struct ieee80211_local *local = 1044 struct ieee80211_local *local =
@@ -1239,7 +1271,7 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
1239 } 1271 }
1240 1272
1241 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); 1273 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
1242 if (sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 1274 if (sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ)
1243 use_short_slot = true; 1275 use_short_slot = true;
1244 1276
1245 if (use_protection != bss_conf->use_cts_prot) { 1277 if (use_protection != bss_conf->use_cts_prot) {
@@ -1310,6 +1342,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
1310 ieee80211_recalc_smps(local); 1342 ieee80211_recalc_smps(local);
1311 mutex_unlock(&local->iflist_mtx); 1343 mutex_unlock(&local->iflist_mtx);
1312 1344
1345 ieee80211_recalc_ps_vif(sdata);
1346
1313 netif_tx_start_all_queues(sdata->dev); 1347 netif_tx_start_all_queues(sdata->dev);
1314 netif_carrier_on(sdata->dev); 1348 netif_carrier_on(sdata->dev);
1315} 1349}
@@ -1371,6 +1405,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1371 } 1405 }
1372 local->ps_sdata = NULL; 1406 local->ps_sdata = NULL;
1373 1407
1408 /* disable per-vif ps */
1409 ieee80211_recalc_ps_vif(sdata);
1410
1374 /* flush out any pending frame (e.g. DELBA) before deauth/disassoc */ 1411 /* flush out any pending frame (e.g. DELBA) before deauth/disassoc */
1375 if (tx) 1412 if (tx)
1376 drv_flush(local, false); 1413 drv_flush(local, false);
@@ -1540,7 +1577,8 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
1540 ssid_len = ssid[1]; 1577 ssid_len = ssid[1];
1541 1578
1542 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, 1579 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL,
1543 0, (u32) -1, true, false); 1580 0, (u32) -1, true, false,
1581 ifmgd->associated->channel);
1544 } 1582 }
1545 1583
1546 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); 1584 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms);
@@ -1643,7 +1681,9 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
1643 ssid_len = ssid[1]; 1681 ssid_len = ssid[1];
1644 1682
1645 skb = ieee80211_build_probe_req(sdata, cbss->bssid, 1683 skb = ieee80211_build_probe_req(sdata, cbss->bssid,
1646 (u32) -1, ssid + 2, ssid_len, 1684 (u32) -1,
1685 sdata->local->oper_channel,
1686 ssid + 2, ssid_len,
1647 NULL, 0, true); 1687 NULL, 0, true);
1648 1688
1649 return skb; 1689 return skb;
@@ -1654,7 +1694,6 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
1654{ 1694{
1655 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1695 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1656 struct ieee80211_local *local = sdata->local; 1696 struct ieee80211_local *local = sdata->local;
1657 u8 bssid[ETH_ALEN];
1658 u8 frame_buf[DEAUTH_DISASSOC_LEN]; 1697 u8 frame_buf[DEAUTH_DISASSOC_LEN];
1659 1698
1660 mutex_lock(&ifmgd->mtx); 1699 mutex_lock(&ifmgd->mtx);
@@ -1663,9 +1702,8 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
1663 return; 1702 return;
1664 } 1703 }
1665 1704
1666 memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); 1705 sdata_info(sdata, "Connection to AP %pM lost\n",
1667 1706 ifmgd->associated->bssid);
1668 sdata_info(sdata, "Connection to AP %pM lost\n", bssid);
1669 1707
1670 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 1708 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
1671 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, 1709 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
@@ -1683,7 +1721,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
1683 mutex_unlock(&local->mtx); 1721 mutex_unlock(&local->mtx);
1684} 1722}
1685 1723
1686void ieee80211_beacon_connection_loss_work(struct work_struct *work) 1724static void ieee80211_beacon_connection_loss_work(struct work_struct *work)
1687{ 1725{
1688 struct ieee80211_sub_if_data *sdata = 1726 struct ieee80211_sub_if_data *sdata =
1689 container_of(work, struct ieee80211_sub_if_data, 1727 container_of(work, struct ieee80211_sub_if_data,
@@ -2230,14 +2268,10 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
2230 mutex_unlock(&local->iflist_mtx); 2268 mutex_unlock(&local->iflist_mtx);
2231 } 2269 }
2232 2270
2233 if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && 2271 if (elems->ch_switch_ie &&
2234 (memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, 2272 memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0)
2235 ETH_ALEN) == 0)) { 2273 ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie,
2236 struct ieee80211_channel_sw_ie *sw_elem =
2237 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
2238 ieee80211_sta_process_chanswitch(sdata, sw_elem,
2239 bss, rx_status->mactime); 2274 bss, rx_status->mactime);
2240 }
2241} 2275}
2242 2276
2243 2277
@@ -2324,7 +2358,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2324 if (baselen > len) 2358 if (baselen > len)
2325 return; 2359 return;
2326 2360
2327 if (rx_status->freq != local->hw.conf.channel->center_freq) 2361 if (rx_status->freq != local->oper_channel->center_freq)
2328 return; 2362 return;
2329 2363
2330 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && 2364 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
@@ -2488,7 +2522,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2488 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) { 2522 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) {
2489 struct ieee80211_supported_band *sband; 2523 struct ieee80211_supported_band *sband;
2490 2524
2491 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2525 sband = local->hw.wiphy->bands[local->oper_channel->band];
2492 2526
2493 changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, 2527 changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation,
2494 bssid, true); 2528 bssid, true);
@@ -2671,7 +2705,8 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata)
2671 * will not answer to direct packet in unassociated state. 2705 * will not answer to direct packet in unassociated state.
2672 */ 2706 */
2673 ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], 2707 ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1],
2674 NULL, 0, (u32) -1, true, false); 2708 NULL, 0, (u32) -1, true, false,
2709 auth_data->bss->channel);
2675 } 2710 }
2676 2711
2677 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; 2712 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
@@ -2998,41 +3033,17 @@ int ieee80211_max_network_latency(struct notifier_block *nb,
2998 return 0; 3033 return 0;
2999} 3034}
3000 3035
3001static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, 3036static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3002 struct cfg80211_bss *cbss, bool assoc) 3037 struct cfg80211_bss *cbss)
3003{ 3038{
3004 struct ieee80211_local *local = sdata->local; 3039 struct ieee80211_local *local = sdata->local;
3005 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3040 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3006 struct ieee80211_bss *bss = (void *)cbss->priv;
3007 struct sta_info *sta = NULL;
3008 bool have_sta = false;
3009 int err;
3010 int ht_cfreq; 3041 int ht_cfreq;
3011 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; 3042 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
3012 const u8 *ht_oper_ie; 3043 const u8 *ht_oper_ie;
3013 const struct ieee80211_ht_operation *ht_oper = NULL; 3044 const struct ieee80211_ht_operation *ht_oper = NULL;
3014 struct ieee80211_supported_band *sband; 3045 struct ieee80211_supported_band *sband;
3015 3046
3016 if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data))
3017 return -EINVAL;
3018
3019 if (assoc) {
3020 rcu_read_lock();
3021 have_sta = sta_info_get(sdata, cbss->bssid);
3022 rcu_read_unlock();
3023 }
3024
3025 if (!have_sta) {
3026 sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
3027 if (!sta)
3028 return -ENOMEM;
3029 }
3030
3031 mutex_lock(&local->mtx);
3032 ieee80211_recalc_idle(sdata->local);
3033 mutex_unlock(&local->mtx);
3034
3035 /* switch to the right channel */
3036 sband = local->hw.wiphy->bands[cbss->channel->band]; 3047 sband = local->hw.wiphy->bands[cbss->channel->band];
3037 3048
3038 ifmgd->flags &= ~IEEE80211_STA_DISABLE_40MHZ; 3049 ifmgd->flags &= ~IEEE80211_STA_DISABLE_40MHZ;
@@ -3095,10 +3106,51 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3095 local->oper_channel = cbss->channel; 3106 local->oper_channel = cbss->channel;
3096 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 3107 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
3097 3108
3098 if (sta) { 3109 return 0;
3110}
3111
3112static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3113 struct cfg80211_bss *cbss, bool assoc)
3114{
3115 struct ieee80211_local *local = sdata->local;
3116 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3117 struct ieee80211_bss *bss = (void *)cbss->priv;
3118 struct sta_info *new_sta = NULL;
3119 bool have_sta = false;
3120 int err;
3121
3122 if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data))
3123 return -EINVAL;
3124
3125 if (assoc) {
3126 rcu_read_lock();
3127 have_sta = sta_info_get(sdata, cbss->bssid);
3128 rcu_read_unlock();
3129 }
3130
3131 if (!have_sta) {
3132 new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
3133 if (!new_sta)
3134 return -ENOMEM;
3135 }
3136
3137 mutex_lock(&local->mtx);
3138 ieee80211_recalc_idle(sdata->local);
3139 mutex_unlock(&local->mtx);
3140
3141 if (new_sta) {
3099 u32 rates = 0, basic_rates = 0; 3142 u32 rates = 0, basic_rates = 0;
3100 bool have_higher_than_11mbit; 3143 bool have_higher_than_11mbit;
3101 int min_rate = INT_MAX, min_rate_index = -1; 3144 int min_rate = INT_MAX, min_rate_index = -1;
3145 struct ieee80211_supported_band *sband;
3146
3147 sband = local->hw.wiphy->bands[cbss->channel->band];
3148
3149 err = ieee80211_prep_channel(sdata, cbss);
3150 if (err) {
3151 sta_info_free(local, new_sta);
3152 return err;
3153 }
3102 3154
3103 ieee80211_get_rates(sband, bss->supp_rates, 3155 ieee80211_get_rates(sband, bss->supp_rates,
3104 bss->supp_rates_len, 3156 bss->supp_rates_len,
@@ -3120,7 +3172,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3120 basic_rates = BIT(min_rate_index); 3172 basic_rates = BIT(min_rate_index);
3121 } 3173 }
3122 3174
3123 sta->sta.supp_rates[cbss->channel->band] = rates; 3175 new_sta->sta.supp_rates[cbss->channel->band] = rates;
3124 sdata->vif.bss_conf.basic_rates = basic_rates; 3176 sdata->vif.bss_conf.basic_rates = basic_rates;
3125 3177
3126 /* cf. IEEE 802.11 9.2.12 */ 3178 /* cf. IEEE 802.11 9.2.12 */
@@ -3143,10 +3195,10 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3143 BSS_CHANGED_BEACON_INT); 3195 BSS_CHANGED_BEACON_INT);
3144 3196
3145 if (assoc) 3197 if (assoc)
3146 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 3198 sta_info_pre_move_state(new_sta, IEEE80211_STA_AUTH);
3147 3199
3148 err = sta_info_insert(sta); 3200 err = sta_info_insert(new_sta);
3149 sta = NULL; 3201 new_sta = NULL;
3150 if (err) { 3202 if (err) {
3151 sdata_info(sdata, 3203 sdata_info(sdata,
3152 "failed to insert STA entry for the AP (error %d)\n", 3204 "failed to insert STA entry for the AP (error %d)\n",
@@ -3298,9 +3350,13 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3298 } 3350 }
3299 3351
3300 /* prepare assoc data */ 3352 /* prepare assoc data */
3301 3353
3302 ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N; 3354 /*
3303 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; 3355 * keep only the 40 MHz disable bit set as it might have
3356 * been set during authentication already, all other bits
3357 * should be reset for a new connection
3358 */
3359 ifmgd->flags &= IEEE80211_STA_DISABLE_40MHZ;
3304 3360
3305 ifmgd->beacon_crc_valid = false; 3361 ifmgd->beacon_crc_valid = false;
3306 3362
@@ -3316,21 +3372,34 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3316 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || 3372 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP ||
3317 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) { 3373 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) {
3318 ifmgd->flags |= IEEE80211_STA_DISABLE_11N; 3374 ifmgd->flags |= IEEE80211_STA_DISABLE_11N;
3375 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
3319 netdev_info(sdata->dev, 3376 netdev_info(sdata->dev,
3320 "disabling HT due to WEP/TKIP use\n"); 3377 "disabling HT/VHT due to WEP/TKIP use\n");
3321 } 3378 }
3322 } 3379 }
3323 3380
3324 if (req->flags & ASSOC_REQ_DISABLE_HT) 3381 if (req->flags & ASSOC_REQ_DISABLE_HT) {
3325 ifmgd->flags |= IEEE80211_STA_DISABLE_11N; 3382 ifmgd->flags |= IEEE80211_STA_DISABLE_11N;
3383 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
3384 }
3326 3385
3327 /* Also disable HT if we don't support it or the AP doesn't use WMM */ 3386 /* Also disable HT if we don't support it or the AP doesn't use WMM */
3328 sband = local->hw.wiphy->bands[req->bss->channel->band]; 3387 sband = local->hw.wiphy->bands[req->bss->channel->band];
3329 if (!sband->ht_cap.ht_supported || 3388 if (!sband->ht_cap.ht_supported ||
3330 local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used) { 3389 local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used) {
3331 ifmgd->flags |= IEEE80211_STA_DISABLE_11N; 3390 ifmgd->flags |= IEEE80211_STA_DISABLE_11N;
3332 netdev_info(sdata->dev, 3391 if (!bss->wmm_used)
3333 "disabling HT as WMM/QoS is not supported\n"); 3392 netdev_info(sdata->dev,
3393 "disabling HT as WMM/QoS is not supported by the AP\n");
3394 }
3395
3396 /* disable VHT if we don't support it or the AP doesn't use WMM */
3397 if (!sband->vht_cap.vht_supported ||
3398 local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used) {
3399 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT;
3400 if (!bss->wmm_used)
3401 netdev_info(sdata->dev,
3402 "disabling VHT as WMM/QoS is not supported by the AP\n");
3334 } 3403 }
3335 3404
3336 memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); 3405 memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa));
@@ -3465,14 +3534,17 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
3465 req->bssid, req->reason_code); 3534 req->bssid, req->reason_code);
3466 3535
3467 if (ifmgd->associated && 3536 if (ifmgd->associated &&
3468 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) 3537 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
3469 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 3538 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
3470 req->reason_code, true, frame_buf); 3539 req->reason_code, true, frame_buf);
3471 else 3540 } else {
3541 drv_mgd_prepare_tx(sdata->local, sdata);
3472 ieee80211_send_deauth_disassoc(sdata, req->bssid, 3542 ieee80211_send_deauth_disassoc(sdata, req->bssid,
3473 IEEE80211_STYPE_DEAUTH, 3543 IEEE80211_STYPE_DEAUTH,
3474 req->reason_code, true, 3544 req->reason_code, true,
3475 frame_buf); 3545 frame_buf);
3546 }
3547
3476 mutex_unlock(&ifmgd->mtx); 3548 mutex_unlock(&ifmgd->mtx);
3477 3549
3478 __cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); 3550 __cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN);
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 635c3250c668..507121dad082 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -116,6 +116,9 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
116 if (!ieee80211_sdata_running(sdata)) 116 if (!ieee80211_sdata_running(sdata))
117 continue; 117 continue;
118 118
119 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
120 continue;
121
119 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) 122 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
120 set_bit(SDATA_STATE_OFFCHANNEL, &sdata->state); 123 set_bit(SDATA_STATE_OFFCHANNEL, &sdata->state);
121 124
@@ -144,6 +147,9 @@ void ieee80211_offchannel_return(struct ieee80211_local *local,
144 147
145 mutex_lock(&local->iflist_mtx); 148 mutex_lock(&local->iflist_mtx);
146 list_for_each_entry(sdata, &local->interfaces, list) { 149 list_for_each_entry(sdata, &local->interfaces, list) {
150 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
151 continue;
152
147 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) 153 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
148 clear_bit(SDATA_STATE_OFFCHANNEL, &sdata->state); 154 clear_bit(SDATA_STATE_OFFCHANNEL, &sdata->state);
149 155
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index 6e4fd32c6617..10de668eb9f6 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -56,7 +56,7 @@ static inline void rate_control_rate_init(struct sta_info *sta)
56 if (!ref) 56 if (!ref)
57 return; 57 return;
58 58
59 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 59 sband = local->hw.wiphy->bands[local->oper_channel->band];
60 60
61 ref->ops->rate_init(ref->priv, sband, ista, priv_sta); 61 ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
62 set_sta_flag(sta, WLAN_STA_RATE_CONTROL); 62 set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0cb4edee6af5..b382605c5733 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -60,7 +60,9 @@ static inline int should_drop_frame(struct sk_buff *skb,
60 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 60 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
61 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 61 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
62 62
63 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) 63 if (status->flag & (RX_FLAG_FAILED_FCS_CRC |
64 RX_FLAG_FAILED_PLCP_CRC |
65 RX_FLAG_AMPDU_IS_ZEROLEN))
64 return 1; 66 return 1;
65 if (unlikely(skb->len < 16 + present_fcs_len)) 67 if (unlikely(skb->len < 16 + present_fcs_len))
66 return 1; 68 return 1;
@@ -91,6 +93,13 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,
91 if (status->flag & RX_FLAG_HT) /* HT info */ 93 if (status->flag & RX_FLAG_HT) /* HT info */
92 len += 3; 94 len += 3;
93 95
96 if (status->flag & RX_FLAG_AMPDU_DETAILS) {
97 /* padding */
98 while (len & 3)
99 len++;
100 len += 8;
101 }
102
94 return len; 103 return len;
95} 104}
96 105
@@ -215,6 +224,37 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
215 pos++; 224 pos++;
216 *pos++ = status->rate_idx; 225 *pos++ = status->rate_idx;
217 } 226 }
227
228 if (status->flag & RX_FLAG_AMPDU_DETAILS) {
229 u16 flags = 0;
230
231 /* ensure 4 byte alignment */
232 while ((pos - (u8 *)rthdr) & 3)
233 pos++;
234 rthdr->it_present |=
235 cpu_to_le32(1 << IEEE80211_RADIOTAP_AMPDU_STATUS);
236 put_unaligned_le32(status->ampdu_reference, pos);
237 pos += 4;
238 if (status->flag & RX_FLAG_AMPDU_REPORT_ZEROLEN)
239 flags |= IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN;
240 if (status->flag & RX_FLAG_AMPDU_IS_ZEROLEN)
241 flags |= IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN;
242 if (status->flag & RX_FLAG_AMPDU_LAST_KNOWN)
243 flags |= IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN;
244 if (status->flag & RX_FLAG_AMPDU_IS_LAST)
245 flags |= IEEE80211_RADIOTAP_AMPDU_IS_LAST;
246 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_ERROR)
247 flags |= IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR;
248 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_KNOWN)
249 flags |= IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN;
250 put_unaligned_le16(flags, pos);
251 pos += 2;
252 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_KNOWN)
253 *pos++ = status->ampdu_delimiter_crc;
254 else
255 *pos++ = 0;
256 *pos++ = 0;
257 }
218} 258}
219 259
220/* 260/*
@@ -2268,7 +2308,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2268 2308
2269 goto queue; 2309 goto queue;
2270 case WLAN_CATEGORY_SPECTRUM_MGMT: 2310 case WLAN_CATEGORY_SPECTRUM_MGMT:
2271 if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ) 2311 if (status->band != IEEE80211_BAND_5GHZ)
2272 break; 2312 break;
2273 2313
2274 if (sdata->vif.type != NL80211_IFTYPE_STATION) 2314 if (sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -2772,8 +2812,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
2772 if (!bssid) { 2812 if (!bssid) {
2773 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) 2813 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1))
2774 return 0; 2814 return 0;
2775 } else if (!ieee80211_bssid_match(bssid, 2815 } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) {
2776 sdata->vif.addr)) {
2777 /* 2816 /*
2778 * Accept public action frames even when the 2817 * Accept public action frames even when the
2779 * BSSID doesn't match, this is used for P2P 2818 * BSSID doesn't match, this is used for P2P
@@ -2793,9 +2832,18 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
2793 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) 2832 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
2794 return 0; 2833 return 0;
2795 break; 2834 break;
2835 case NL80211_IFTYPE_P2P_DEVICE:
2836 if (!ieee80211_is_public_action(hdr, skb->len) &&
2837 !ieee80211_is_probe_req(hdr->frame_control) &&
2838 !ieee80211_is_probe_resp(hdr->frame_control) &&
2839 !ieee80211_is_beacon(hdr->frame_control))
2840 return 0;
2841 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1))
2842 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
2843 break;
2796 default: 2844 default:
2797 /* should never get here */ 2845 /* should never get here */
2798 WARN_ON(1); 2846 WARN_ON_ONCE(1);
2799 break; 2847 break;
2800 } 2848 }
2801 2849
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index bcaee5d12839..ef1d69306315 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -416,7 +416,8 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
416 local->scan_req->ssids[i].ssid_len, 416 local->scan_req->ssids[i].ssid_len,
417 local->scan_req->ie, local->scan_req->ie_len, 417 local->scan_req->ie, local->scan_req->ie_len,
418 local->scan_req->rates[band], false, 418 local->scan_req->rates[band], false,
419 local->scan_req->no_cck); 419 local->scan_req->no_cck,
420 local->hw.conf.channel);
420 421
421 /* 422 /*
422 * After sending probe requests, wait for probe responses 423 * After sending probe requests, wait for probe responses
@@ -479,11 +480,10 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
479 if (local->ops->hw_scan) { 480 if (local->ops->hw_scan) {
480 __set_bit(SCAN_HW_SCANNING, &local->scanning); 481 __set_bit(SCAN_HW_SCANNING, &local->scanning);
481 } else if ((req->n_channels == 1) && 482 } else if ((req->n_channels == 1) &&
482 (req->channels[0]->center_freq == 483 (req->channels[0] == local->oper_channel)) {
483 local->hw.conf.channel->center_freq)) { 484 /*
484 485 * If we are scanning only on the operating channel
485 /* If we are scanning only on the current channel, then 486 * then we do not need to stop normal activities
486 * we do not need to stop normal activities
487 */ 487 */
488 unsigned long next_delay; 488 unsigned long next_delay;
489 489
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 8cd72914cdaf..b0801b7d572d 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -519,19 +519,27 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
519 u64 cookie = (unsigned long)skb; 519 u64 cookie = (unsigned long)skb;
520 acked = info->flags & IEEE80211_TX_STAT_ACK; 520 acked = info->flags & IEEE80211_TX_STAT_ACK;
521 521
522 /*
523 * TODO: When we have non-netdev frame TX,
524 * we cannot use skb->dev->ieee80211_ptr
525 */
526
527 if (ieee80211_is_nullfunc(hdr->frame_control) || 522 if (ieee80211_is_nullfunc(hdr->frame_control) ||
528 ieee80211_is_qos_nullfunc(hdr->frame_control)) 523 ieee80211_is_qos_nullfunc(hdr->frame_control)) {
529 cfg80211_probe_status(skb->dev, hdr->addr1, 524 cfg80211_probe_status(skb->dev, hdr->addr1,
530 cookie, acked, GFP_ATOMIC); 525 cookie, acked, GFP_ATOMIC);
531 else 526 } else if (skb->dev) {
532 cfg80211_mgmt_tx_status( 527 cfg80211_mgmt_tx_status(
533 skb->dev->ieee80211_ptr, cookie, skb->data, 528 skb->dev->ieee80211_ptr, cookie, skb->data,
534 skb->len, acked, GFP_ATOMIC); 529 skb->len, acked, GFP_ATOMIC);
530 } else {
531 struct ieee80211_sub_if_data *p2p_sdata;
532
533 rcu_read_lock();
534
535 p2p_sdata = rcu_dereference(local->p2p_sdata);
536 if (p2p_sdata) {
537 cfg80211_mgmt_tx_status(
538 &p2p_sdata->wdev, cookie, skb->data,
539 skb->len, acked, GFP_ATOMIC);
540 }
541 rcu_read_unlock();
542 }
535 } 543 }
536 544
537 if (unlikely(info->ack_frame_id)) { 545 if (unlikely(info->ack_frame_id)) {
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index c6d33b55b2df..18d9c8a52e9e 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -24,7 +24,7 @@
24 __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") 24 __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>")
25#define VIF_ASSIGN __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \ 25#define VIF_ASSIGN __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \
26 __entry->p2p = sdata->vif.p2p; \ 26 __entry->p2p = sdata->vif.p2p; \
27 __assign_str(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") 27 __assign_str(vif_name, sdata->dev ? sdata->dev->name : sdata->name)
28#define VIF_PR_FMT " vif:%s(%d%s)" 28#define VIF_PR_FMT " vif:%s(%d%s)"
29#define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" 29#define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : ""
30 30
@@ -274,9 +274,12 @@ TRACE_EVENT(drv_config,
274 __entry->dynamic_ps_timeout = local->hw.conf.dynamic_ps_timeout; 274 __entry->dynamic_ps_timeout = local->hw.conf.dynamic_ps_timeout;
275 __entry->max_sleep_period = local->hw.conf.max_sleep_period; 275 __entry->max_sleep_period = local->hw.conf.max_sleep_period;
276 __entry->listen_interval = local->hw.conf.listen_interval; 276 __entry->listen_interval = local->hw.conf.listen_interval;
277 __entry->long_frame_max_tx_count = local->hw.conf.long_frame_max_tx_count; 277 __entry->long_frame_max_tx_count =
278 __entry->short_frame_max_tx_count = local->hw.conf.short_frame_max_tx_count; 278 local->hw.conf.long_frame_max_tx_count;
279 __entry->center_freq = local->hw.conf.channel->center_freq; 279 __entry->short_frame_max_tx_count =
280 local->hw.conf.short_frame_max_tx_count;
281 __entry->center_freq = local->hw.conf.channel ?
282 local->hw.conf.channel->center_freq : 0;
280 __entry->channel_type = local->hw.conf.channel_type; 283 __entry->channel_type = local->hw.conf.channel_type;
281 __entry->smps = local->hw.conf.smps_mode; 284 __entry->smps = local->hw.conf.smps_mode;
282 ), 285 ),
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index acf712ffb5e6..3b807bcb8fc9 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -55,7 +55,7 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
55 if (WARN_ON_ONCE(info->control.rates[0].idx < 0)) 55 if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
56 return 0; 56 return 0;
57 57
58 sband = local->hw.wiphy->bands[tx->channel->band]; 58 sband = local->hw.wiphy->bands[info->band];
59 txrate = &sband->bitrates[info->control.rates[0].idx]; 59 txrate = &sband->bitrates[info->control.rates[0].idx];
60 60
61 erp = txrate->flags & IEEE80211_RATE_ERP_G; 61 erp = txrate->flags & IEEE80211_RATE_ERP_G;
@@ -615,7 +615,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
615 615
616 memset(&txrc, 0, sizeof(txrc)); 616 memset(&txrc, 0, sizeof(txrc));
617 617
618 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 618 sband = tx->local->hw.wiphy->bands[info->band];
619 619
620 len = min_t(u32, tx->skb->len + FCS_LEN, 620 len = min_t(u32, tx->skb->len + FCS_LEN,
621 tx->local->hw.wiphy->frag_threshold); 621 tx->local->hw.wiphy->frag_threshold);
@@ -626,13 +626,13 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
626 txrc.bss_conf = &tx->sdata->vif.bss_conf; 626 txrc.bss_conf = &tx->sdata->vif.bss_conf;
627 txrc.skb = tx->skb; 627 txrc.skb = tx->skb;
628 txrc.reported_rate.idx = -1; 628 txrc.reported_rate.idx = -1;
629 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[tx->channel->band]; 629 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band];
630 if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1) 630 if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1)
631 txrc.max_rate_idx = -1; 631 txrc.max_rate_idx = -1;
632 else 632 else
633 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; 633 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
634 memcpy(txrc.rate_idx_mcs_mask, 634 memcpy(txrc.rate_idx_mcs_mask,
635 tx->sdata->rc_rateidx_mcs_mask[tx->channel->band], 635 tx->sdata->rc_rateidx_mcs_mask[info->band],
636 sizeof(txrc.rate_idx_mcs_mask)); 636 sizeof(txrc.rate_idx_mcs_mask));
637 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || 637 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
638 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || 638 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
@@ -667,7 +667,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
667 "scanning and associated. Target station: " 667 "scanning and associated. Target station: "
668 "%pM on %d GHz band\n", 668 "%pM on %d GHz band\n",
669 tx->sdata->name, hdr->addr1, 669 tx->sdata->name, hdr->addr1,
670 tx->channel->band ? 5 : 2)) 670 info->band ? 5 : 2))
671 return TX_DROP; 671 return TX_DROP;
672 672
673 /* 673 /*
@@ -1131,7 +1131,6 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
1131 tx->skb = skb; 1131 tx->skb = skb;
1132 tx->local = local; 1132 tx->local = local;
1133 tx->sdata = sdata; 1133 tx->sdata = sdata;
1134 tx->channel = local->hw.conf.channel;
1135 __skb_queue_head_init(&tx->skbs); 1134 __skb_queue_head_init(&tx->skbs);
1136 1135
1137 /* 1136 /*
@@ -1204,6 +1203,7 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local,
1204 struct sk_buff_head *skbs, 1203 struct sk_buff_head *skbs,
1205 bool txpending) 1204 bool txpending)
1206{ 1205{
1206 struct ieee80211_tx_control control;
1207 struct sk_buff *skb, *tmp; 1207 struct sk_buff *skb, *tmp;
1208 unsigned long flags; 1208 unsigned long flags;
1209 1209
@@ -1240,10 +1240,10 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local,
1240 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 1240 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
1241 1241
1242 info->control.vif = vif; 1242 info->control.vif = vif;
1243 info->control.sta = sta; 1243 control.sta = sta;
1244 1244
1245 __skb_unlink(skb, skbs); 1245 __skb_unlink(skb, skbs);
1246 drv_tx(local, skb); 1246 drv_tx(local, &control, skb);
1247 } 1247 }
1248 1248
1249 return true; 1249 return true;
@@ -1399,8 +1399,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1399 goto out; 1399 goto out;
1400 } 1400 }
1401 1401
1402 tx.channel = local->hw.conf.channel; 1402 info->band = local->hw.conf.channel->band;
1403 info->band = tx.channel->band;
1404 1403
1405 /* set up hw_queue value early */ 1404 /* set up hw_queue value early */
1406 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || 1405 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) ||
@@ -1720,7 +1719,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1720 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1719 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1721 struct ieee80211_local *local = sdata->local; 1720 struct ieee80211_local *local = sdata->local;
1722 struct ieee80211_tx_info *info; 1721 struct ieee80211_tx_info *info;
1723 int ret = NETDEV_TX_BUSY, head_need; 1722 int head_need;
1724 u16 ethertype, hdrlen, meshhdrlen = 0; 1723 u16 ethertype, hdrlen, meshhdrlen = 0;
1725 __le16 fc; 1724 __le16 fc;
1726 struct ieee80211_hdr hdr; 1725 struct ieee80211_hdr hdr;
@@ -1736,10 +1735,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1736 u32 info_flags = 0; 1735 u32 info_flags = 0;
1737 u16 info_id = 0; 1736 u16 info_id = 0;
1738 1737
1739 if (unlikely(skb->len < ETH_HLEN)) { 1738 if (unlikely(skb->len < ETH_HLEN))
1740 ret = NETDEV_TX_OK;
1741 goto fail; 1739 goto fail;
1742 }
1743 1740
1744 /* convert Ethernet header to proper 802.11 header (based on 1741 /* convert Ethernet header to proper 802.11 header (based on
1745 * operation mode) */ 1742 * operation mode) */
@@ -1787,7 +1784,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1787 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { 1784 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) {
1788 /* Do not send frames with mesh_ttl == 0 */ 1785 /* Do not send frames with mesh_ttl == 0 */
1789 sdata->u.mesh.mshstats.dropped_frames_ttl++; 1786 sdata->u.mesh.mshstats.dropped_frames_ttl++;
1790 ret = NETDEV_TX_OK;
1791 goto fail; 1787 goto fail;
1792 } 1788 }
1793 rcu_read_lock(); 1789 rcu_read_lock();
@@ -1880,10 +1876,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1880 1876
1881 if (tdls_direct) { 1877 if (tdls_direct) {
1882 /* link during setup - throw out frames to peer */ 1878 /* link during setup - throw out frames to peer */
1883 if (!tdls_auth) { 1879 if (!tdls_auth)
1884 ret = NETDEV_TX_OK;
1885 goto fail; 1880 goto fail;
1886 }
1887 1881
1888 /* DA SA BSSID */ 1882 /* DA SA BSSID */
1889 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1883 memcpy(hdr.addr1, skb->data, ETH_ALEN);
@@ -1917,7 +1911,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1917 hdrlen = 24; 1911 hdrlen = 24;
1918 break; 1912 break;
1919 default: 1913 default:
1920 ret = NETDEV_TX_OK;
1921 goto fail; 1914 goto fail;
1922 } 1915 }
1923 1916
@@ -1962,7 +1955,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1962 1955
1963 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); 1956 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
1964 1957
1965 ret = NETDEV_TX_OK;
1966 goto fail; 1958 goto fail;
1967 } 1959 }
1968 1960
@@ -2017,10 +2009,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2017 skb = skb_clone(skb, GFP_ATOMIC); 2009 skb = skb_clone(skb, GFP_ATOMIC);
2018 kfree_skb(tmp_skb); 2010 kfree_skb(tmp_skb);
2019 2011
2020 if (!skb) { 2012 if (!skb)
2021 ret = NETDEV_TX_OK;
2022 goto fail; 2013 goto fail;
2023 }
2024 } 2014 }
2025 2015
2026 hdr.frame_control = fc; 2016 hdr.frame_control = fc;
@@ -2123,10 +2113,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2123 return NETDEV_TX_OK; 2113 return NETDEV_TX_OK;
2124 2114
2125 fail: 2115 fail:
2126 if (ret == NETDEV_TX_OK) 2116 dev_kfree_skb(skb);
2127 dev_kfree_skb(skb); 2117 return NETDEV_TX_OK;
2128
2129 return ret;
2130} 2118}
2131 2119
2132 2120
@@ -2301,12 +2289,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2301 struct ieee80211_sub_if_data *sdata = NULL; 2289 struct ieee80211_sub_if_data *sdata = NULL;
2302 struct ieee80211_if_ap *ap = NULL; 2290 struct ieee80211_if_ap *ap = NULL;
2303 struct beacon_data *beacon; 2291 struct beacon_data *beacon;
2304 struct ieee80211_supported_band *sband; 2292 enum ieee80211_band band = local->oper_channel->band;
2305 enum ieee80211_band band = local->hw.conf.channel->band;
2306 struct ieee80211_tx_rate_control txrc; 2293 struct ieee80211_tx_rate_control txrc;
2307 2294
2308 sband = local->hw.wiphy->bands[band];
2309
2310 rcu_read_lock(); 2295 rcu_read_lock();
2311 2296
2312 sdata = vif_to_sdata(vif); 2297 sdata = vif_to_sdata(vif);
@@ -2416,7 +2401,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2416 memset(mgmt, 0, hdr_len); 2401 memset(mgmt, 0, hdr_len);
2417 mgmt->frame_control = 2402 mgmt->frame_control =
2418 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 2403 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
2419 memset(mgmt->da, 0xff, ETH_ALEN); 2404 eth_broadcast_addr(mgmt->da);
2420 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 2405 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2421 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); 2406 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
2422 mgmt->u.beacon.beacon_int = 2407 mgmt->u.beacon.beacon_int =
@@ -2428,9 +2413,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2428 *pos++ = WLAN_EID_SSID; 2413 *pos++ = WLAN_EID_SSID;
2429 *pos++ = 0x0; 2414 *pos++ = 0x0;
2430 2415
2431 if (ieee80211_add_srates_ie(sdata, skb, true) || 2416 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
2432 mesh_add_ds_params_ie(skb, sdata) || 2417 mesh_add_ds_params_ie(skb, sdata) ||
2433 ieee80211_add_ext_srates_ie(sdata, skb, true) || 2418 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
2434 mesh_add_rsn_ie(skb, sdata) || 2419 mesh_add_rsn_ie(skb, sdata) ||
2435 mesh_add_ht_cap_ie(skb, sdata) || 2420 mesh_add_ht_cap_ie(skb, sdata) ||
2436 mesh_add_ht_oper_ie(skb, sdata) || 2421 mesh_add_ht_oper_ie(skb, sdata) ||
@@ -2453,12 +2438,12 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2453 2438
2454 memset(&txrc, 0, sizeof(txrc)); 2439 memset(&txrc, 0, sizeof(txrc));
2455 txrc.hw = hw; 2440 txrc.hw = hw;
2456 txrc.sband = sband; 2441 txrc.sband = local->hw.wiphy->bands[band];
2457 txrc.bss_conf = &sdata->vif.bss_conf; 2442 txrc.bss_conf = &sdata->vif.bss_conf;
2458 txrc.skb = skb; 2443 txrc.skb = skb;
2459 txrc.reported_rate.idx = -1; 2444 txrc.reported_rate.idx = -1;
2460 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; 2445 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band];
2461 if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1) 2446 if (txrc.rate_idx_mask == (1 << txrc.sband->n_bitrates) - 1)
2462 txrc.max_rate_idx = -1; 2447 txrc.max_rate_idx = -1;
2463 else 2448 else
2464 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; 2449 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
@@ -2482,7 +2467,8 @@ struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
2482 struct ieee80211_vif *vif) 2467 struct ieee80211_vif *vif)
2483{ 2468{
2484 struct ieee80211_if_ap *ap = NULL; 2469 struct ieee80211_if_ap *ap = NULL;
2485 struct sk_buff *presp = NULL, *skb = NULL; 2470 struct sk_buff *skb = NULL;
2471 struct probe_resp *presp = NULL;
2486 struct ieee80211_hdr *hdr; 2472 struct ieee80211_hdr *hdr;
2487 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 2473 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2488 2474
@@ -2496,10 +2482,12 @@ struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
2496 if (!presp) 2482 if (!presp)
2497 goto out; 2483 goto out;
2498 2484
2499 skb = skb_copy(presp, GFP_ATOMIC); 2485 skb = dev_alloc_skb(presp->len);
2500 if (!skb) 2486 if (!skb)
2501 goto out; 2487 goto out;
2502 2488
2489 memcpy(skb_put(skb, presp->len), presp->data, presp->len);
2490
2503 hdr = (struct ieee80211_hdr *) skb->data; 2491 hdr = (struct ieee80211_hdr *) skb->data;
2504 memset(hdr->addr1, 0, sizeof(hdr->addr1)); 2492 memset(hdr->addr1, 0, sizeof(hdr->addr1));
2505 2493
@@ -2610,9 +2598,9 @@ struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
2610 memset(hdr, 0, sizeof(*hdr)); 2598 memset(hdr, 0, sizeof(*hdr));
2611 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 2599 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2612 IEEE80211_STYPE_PROBE_REQ); 2600 IEEE80211_STYPE_PROBE_REQ);
2613 memset(hdr->addr1, 0xff, ETH_ALEN); 2601 eth_broadcast_addr(hdr->addr1);
2614 memcpy(hdr->addr2, vif->addr, ETH_ALEN); 2602 memcpy(hdr->addr2, vif->addr, ETH_ALEN);
2615 memset(hdr->addr3, 0xff, ETH_ALEN); 2603 eth_broadcast_addr(hdr->addr3);
2616 2604
2617 pos = skb_put(skb, ie_ssid_len); 2605 pos = skb_put(skb, ie_ssid_len);
2618 *pos++ = WLAN_EID_SSID; 2606 *pos++ = WLAN_EID_SSID;
@@ -2709,8 +2697,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2709 info = IEEE80211_SKB_CB(skb); 2697 info = IEEE80211_SKB_CB(skb);
2710 2698
2711 tx.flags |= IEEE80211_TX_PS_BUFFERED; 2699 tx.flags |= IEEE80211_TX_PS_BUFFERED;
2712 tx.channel = local->hw.conf.channel; 2700 info->band = local->oper_channel->band;
2713 info->band = tx.channel->band;
2714 2701
2715 if (invoke_tx_handlers(&tx)) 2702 if (invoke_tx_handlers(&tx))
2716 skb = NULL; 2703 skb = NULL;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 39b82fee4904..471fb0516c99 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -276,6 +276,9 @@ void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue)
276 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 276 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
277 int ac; 277 int ac;
278 278
279 if (!sdata->dev)
280 continue;
281
279 if (test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) 282 if (test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
280 continue; 283 continue;
281 284
@@ -364,6 +367,9 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
364 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 367 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
365 int ac; 368 int ac;
366 369
370 if (!sdata->dev)
371 continue;
372
367 for (ac = 0; ac < n_acs; ac++) { 373 for (ac = 0; ac < n_acs; ac++) {
368 if (sdata->vif.hw_queue[ac] == queue || 374 if (sdata->vif.hw_queue[ac] == queue ||
369 sdata->vif.cab_queue == queue) 375 sdata->vif.cab_queue == queue)
@@ -768,8 +774,11 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
768 elem_parse_failed = true; 774 elem_parse_failed = true;
769 break; 775 break;
770 case WLAN_EID_CHANNEL_SWITCH: 776 case WLAN_EID_CHANNEL_SWITCH:
771 elems->ch_switch_elem = pos; 777 if (elen != sizeof(struct ieee80211_channel_sw_ie)) {
772 elems->ch_switch_elem_len = elen; 778 elem_parse_failed = true;
779 break;
780 }
781 elems->ch_switch_ie = (void *)pos;
773 break; 782 break;
774 case WLAN_EID_QUIET: 783 case WLAN_EID_QUIET:
775 if (!elems->quiet_elem) { 784 if (!elems->quiet_elem) {
@@ -832,7 +841,7 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
832 841
833 memset(&qparam, 0, sizeof(qparam)); 842 memset(&qparam, 0, sizeof(qparam));
834 843
835 use_11b = (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) && 844 use_11b = (local->oper_channel->band == IEEE80211_BAND_2GHZ) &&
836 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); 845 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE);
837 846
838 /* 847 /*
@@ -899,7 +908,8 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
899 drv_conf_tx(local, sdata, ac, &qparam); 908 drv_conf_tx(local, sdata, ac, &qparam);
900 } 909 }
901 910
902 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) { 911 if (sdata->vif.type != NL80211_IFTYPE_MONITOR &&
912 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE) {
903 sdata->vif.bss_conf.qos = enable_qos; 913 sdata->vif.bss_conf.qos = enable_qos;
904 if (bss_notify) 914 if (bss_notify)
905 ieee80211_bss_info_change_notify(sdata, 915 ieee80211_bss_info_change_notify(sdata,
@@ -919,7 +929,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
919 if ((supp_rates[i] & 0x7f) * 5 > 110) 929 if ((supp_rates[i] & 0x7f) * 5 > 110)
920 have_higher_than_11mbit = 1; 930 have_higher_than_11mbit = 1;
921 931
922 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 932 if (local->oper_channel->band == IEEE80211_BAND_2GHZ &&
923 have_higher_than_11mbit) 933 have_higher_than_11mbit)
924 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 934 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
925 else 935 else
@@ -1100,6 +1110,7 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1100 1110
1101struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1111struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1102 u8 *dst, u32 ratemask, 1112 u8 *dst, u32 ratemask,
1113 struct ieee80211_channel *chan,
1103 const u8 *ssid, size_t ssid_len, 1114 const u8 *ssid, size_t ssid_len,
1104 const u8 *ie, size_t ie_len, 1115 const u8 *ie, size_t ie_len,
1105 bool directed) 1116 bool directed)
@@ -1109,7 +1120,7 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1109 struct ieee80211_mgmt *mgmt; 1120 struct ieee80211_mgmt *mgmt;
1110 size_t buf_len; 1121 size_t buf_len;
1111 u8 *buf; 1122 u8 *buf;
1112 u8 chan; 1123 u8 chan_no;
1113 1124
1114 /* FIXME: come up with a proper value */ 1125 /* FIXME: come up with a proper value */
1115 buf = kmalloc(200 + ie_len, GFP_KERNEL); 1126 buf = kmalloc(200 + ie_len, GFP_KERNEL);
@@ -1122,14 +1133,12 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1122 * badly-behaved APs don't respond when this parameter is included. 1133 * badly-behaved APs don't respond when this parameter is included.
1123 */ 1134 */
1124 if (directed) 1135 if (directed)
1125 chan = 0; 1136 chan_no = 0;
1126 else 1137 else
1127 chan = ieee80211_frequency_to_channel( 1138 chan_no = ieee80211_frequency_to_channel(chan->center_freq);
1128 local->hw.conf.channel->center_freq);
1129 1139
1130 buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len, 1140 buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len, chan->band,
1131 local->hw.conf.channel->band, 1141 ratemask, chan_no);
1132 ratemask, chan);
1133 1142
1134 skb = ieee80211_probereq_get(&local->hw, &sdata->vif, 1143 skb = ieee80211_probereq_get(&local->hw, &sdata->vif,
1135 ssid, ssid_len, 1144 ssid, ssid_len,
@@ -1154,11 +1163,13 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1154void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1163void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1155 const u8 *ssid, size_t ssid_len, 1164 const u8 *ssid, size_t ssid_len,
1156 const u8 *ie, size_t ie_len, 1165 const u8 *ie, size_t ie_len,
1157 u32 ratemask, bool directed, bool no_cck) 1166 u32 ratemask, bool directed, bool no_cck,
1167 struct ieee80211_channel *channel)
1158{ 1168{
1159 struct sk_buff *skb; 1169 struct sk_buff *skb;
1160 1170
1161 skb = ieee80211_build_probe_req(sdata, dst, ratemask, ssid, ssid_len, 1171 skb = ieee80211_build_probe_req(sdata, dst, ratemask, channel,
1172 ssid, ssid_len,
1162 ie, ie_len, directed); 1173 ie, ie_len, directed);
1163 if (skb) { 1174 if (skb) {
1164 if (no_cck) 1175 if (no_cck)
@@ -1359,7 +1370,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1359 switch (sdata->vif.type) { 1370 switch (sdata->vif.type) {
1360 case NL80211_IFTYPE_STATION: 1371 case NL80211_IFTYPE_STATION:
1361 changed |= BSS_CHANGED_ASSOC | 1372 changed |= BSS_CHANGED_ASSOC |
1362 BSS_CHANGED_ARP_FILTER; 1373 BSS_CHANGED_ARP_FILTER |
1374 BSS_CHANGED_PS;
1363 mutex_lock(&sdata->u.mgd.mtx); 1375 mutex_lock(&sdata->u.mgd.mtx);
1364 ieee80211_bss_info_change_notify(sdata, changed); 1376 ieee80211_bss_info_change_notify(sdata, changed);
1365 mutex_unlock(&sdata->u.mgd.mtx); 1377 mutex_unlock(&sdata->u.mgd.mtx);
@@ -1385,6 +1397,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1385 case NL80211_IFTYPE_MONITOR: 1397 case NL80211_IFTYPE_MONITOR:
1386 /* ignore virtual */ 1398 /* ignore virtual */
1387 break; 1399 break;
1400 case NL80211_IFTYPE_P2P_DEVICE:
1401 changed = BSS_CHANGED_IDLE;
1402 break;
1388 case NL80211_IFTYPE_UNSPECIFIED: 1403 case NL80211_IFTYPE_UNSPECIFIED:
1389 case NUM_NL80211_IFTYPES: 1404 case NUM_NL80211_IFTYPES:
1390 case NL80211_IFTYPE_P2P_CLIENT: 1405 case NL80211_IFTYPE_P2P_CLIENT:
@@ -1571,6 +1586,8 @@ void ieee80211_recalc_smps(struct ieee80211_local *local)
1571 list_for_each_entry(sdata, &local->interfaces, list) { 1586 list_for_each_entry(sdata, &local->interfaces, list) {
1572 if (!ieee80211_sdata_running(sdata)) 1587 if (!ieee80211_sdata_running(sdata))
1573 continue; 1588 continue;
1589 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
1590 continue;
1574 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1591 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1575 goto set; 1592 goto set;
1576 1593
@@ -1809,7 +1826,8 @@ ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper)
1809} 1826}
1810 1827
1811int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata, 1828int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
1812 struct sk_buff *skb, bool need_basic) 1829 struct sk_buff *skb, bool need_basic,
1830 enum ieee80211_band band)
1813{ 1831{
1814 struct ieee80211_local *local = sdata->local; 1832 struct ieee80211_local *local = sdata->local;
1815 struct ieee80211_supported_band *sband; 1833 struct ieee80211_supported_band *sband;
@@ -1817,7 +1835,7 @@ int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
1817 u8 i, rates, *pos; 1835 u8 i, rates, *pos;
1818 u32 basic_rates = sdata->vif.bss_conf.basic_rates; 1836 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
1819 1837
1820 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1838 sband = local->hw.wiphy->bands[band];
1821 rates = sband->n_bitrates; 1839 rates = sband->n_bitrates;
1822 if (rates > 8) 1840 if (rates > 8)
1823 rates = 8; 1841 rates = 8;
@@ -1840,7 +1858,8 @@ int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
1840} 1858}
1841 1859
1842int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata, 1860int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
1843 struct sk_buff *skb, bool need_basic) 1861 struct sk_buff *skb, bool need_basic,
1862 enum ieee80211_band band)
1844{ 1863{
1845 struct ieee80211_local *local = sdata->local; 1864 struct ieee80211_local *local = sdata->local;
1846 struct ieee80211_supported_band *sband; 1865 struct ieee80211_supported_band *sband;
@@ -1848,7 +1867,7 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
1848 u8 i, exrates, *pos; 1867 u8 i, exrates, *pos;
1849 u32 basic_rates = sdata->vif.bss_conf.basic_rates; 1868 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
1850 1869
1851 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1870 sband = local->hw.wiphy->bands[band];
1852 exrates = sband->n_bitrates; 1871 exrates = sband->n_bitrates;
1853 if (exrates > 8) 1872 if (exrates > 8)
1854 exrates -= 8; 1873 exrates -= 8;
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index d355f67d0cdd..2f876b9ee344 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -105,7 +105,7 @@ cfg80211_get_chan_state(struct wireless_dev *wdev,
105 105
106 ASSERT_WDEV_LOCK(wdev); 106 ASSERT_WDEV_LOCK(wdev);
107 107
108 if (!netif_running(wdev->netdev)) 108 if (wdev->netdev && !netif_running(wdev->netdev))
109 return; 109 return;
110 110
111 switch (wdev->iftype) { 111 switch (wdev->iftype) {
@@ -143,6 +143,11 @@ cfg80211_get_chan_state(struct wireless_dev *wdev,
143 case NL80211_IFTYPE_WDS: 143 case NL80211_IFTYPE_WDS:
144 /* these interface types don't really have a channel */ 144 /* these interface types don't really have a channel */
145 return; 145 return;
146 case NL80211_IFTYPE_P2P_DEVICE:
147 if (wdev->wiphy->features &
148 NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL)
149 *chanmode = CHAN_MODE_EXCLUSIVE;
150 return;
146 case NL80211_IFTYPE_UNSPECIFIED: 151 case NL80211_IFTYPE_UNSPECIFIED:
147 case NUM_NL80211_IFTYPES: 152 case NUM_NL80211_IFTYPES:
148 WARN_ON(1); 153 WARN_ON(1);
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 31b40cc4a9c3..91b300443f4b 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -230,9 +230,24 @@ static int cfg80211_rfkill_set_block(void *data, bool blocked)
230 rtnl_lock(); 230 rtnl_lock();
231 mutex_lock(&rdev->devlist_mtx); 231 mutex_lock(&rdev->devlist_mtx);
232 232
233 list_for_each_entry(wdev, &rdev->wdev_list, list) 233 list_for_each_entry(wdev, &rdev->wdev_list, list) {
234 if (wdev->netdev) 234 if (wdev->netdev) {
235 dev_close(wdev->netdev); 235 dev_close(wdev->netdev);
236 continue;
237 }
238 /* otherwise, check iftype */
239 switch (wdev->iftype) {
240 case NL80211_IFTYPE_P2P_DEVICE:
241 if (!wdev->p2p_started)
242 break;
243 rdev->ops->stop_p2p_device(&rdev->wiphy, wdev);
244 wdev->p2p_started = false;
245 rdev->opencount--;
246 break;
247 default:
248 break;
249 }
250 }
236 251
237 mutex_unlock(&rdev->devlist_mtx); 252 mutex_unlock(&rdev->devlist_mtx);
238 rtnl_unlock(); 253 rtnl_unlock();
@@ -407,6 +422,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
407 if (WARN_ON(wiphy->software_iftypes & types)) 422 if (WARN_ON(wiphy->software_iftypes & types))
408 return -EINVAL; 423 return -EINVAL;
409 424
425 /* Only a single P2P_DEVICE can be allowed */
426 if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
427 c->limits[j].max > 1))
428 return -EINVAL;
429
410 cnt += c->limits[j].max; 430 cnt += c->limits[j].max;
411 /* 431 /*
412 * Don't advertise an unsupported type 432 * Don't advertise an unsupported type
@@ -734,6 +754,35 @@ static void wdev_cleanup_work(struct work_struct *work)
734 dev_put(wdev->netdev); 754 dev_put(wdev->netdev);
735} 755}
736 756
757void cfg80211_unregister_wdev(struct wireless_dev *wdev)
758{
759 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
760
761 ASSERT_RTNL();
762
763 if (WARN_ON(wdev->netdev))
764 return;
765
766 mutex_lock(&rdev->devlist_mtx);
767 list_del_rcu(&wdev->list);
768 rdev->devlist_generation++;
769
770 switch (wdev->iftype) {
771 case NL80211_IFTYPE_P2P_DEVICE:
772 if (!wdev->p2p_started)
773 break;
774 rdev->ops->stop_p2p_device(&rdev->wiphy, wdev);
775 wdev->p2p_started = false;
776 rdev->opencount--;
777 break;
778 default:
779 WARN_ON_ONCE(1);
780 break;
781 }
782 mutex_unlock(&rdev->devlist_mtx);
783}
784EXPORT_SYMBOL(cfg80211_unregister_wdev);
785
737static struct device_type wiphy_type = { 786static struct device_type wiphy_type = {
738 .name = "wlan", 787 .name = "wlan",
739}; 788};
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 1cdb1d5e6b0f..8fd0242ee169 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -736,7 +736,6 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
736 const u8 *buf, size_t len, bool no_cck, 736 const u8 *buf, size_t len, bool no_cck,
737 bool dont_wait_for_ack, u64 *cookie) 737 bool dont_wait_for_ack, u64 *cookie)
738{ 738{
739 struct net_device *dev = wdev->netdev;
740 const struct ieee80211_mgmt *mgmt; 739 const struct ieee80211_mgmt *mgmt;
741 u16 stype; 740 u16 stype;
742 741
@@ -796,7 +795,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
796 case NL80211_IFTYPE_AP: 795 case NL80211_IFTYPE_AP:
797 case NL80211_IFTYPE_P2P_GO: 796 case NL80211_IFTYPE_P2P_GO:
798 case NL80211_IFTYPE_AP_VLAN: 797 case NL80211_IFTYPE_AP_VLAN:
799 if (!ether_addr_equal(mgmt->bssid, dev->dev_addr)) 798 if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev)))
800 err = -EINVAL; 799 err = -EINVAL;
801 break; 800 break;
802 case NL80211_IFTYPE_MESH_POINT: 801 case NL80211_IFTYPE_MESH_POINT:
@@ -809,6 +808,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
809 * cfg80211 doesn't track the stations 808 * cfg80211 doesn't track the stations
810 */ 809 */
811 break; 810 break;
811 case NL80211_IFTYPE_P2P_DEVICE:
812 /*
813 * fall through, P2P device only supports
814 * public action frames
815 */
812 default: 816 default:
813 err = -EOPNOTSUPP; 817 err = -EOPNOTSUPP;
814 break; 818 break;
@@ -819,7 +823,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
819 return err; 823 return err;
820 } 824 }
821 825
822 if (!ether_addr_equal(mgmt->sa, dev->dev_addr)) 826 if (!ether_addr_equal(mgmt->sa, wdev_address(wdev)))
823 return -EINVAL; 827 return -EINVAL;
824 828
825 /* Transmit the Action frame as requested by user space */ 829 /* Transmit the Action frame as requested by user space */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 97026f3b215a..787aeaa902fe 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1100,6 +1100,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
1100 if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS)) 1100 if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS))
1101 goto nla_put_failure; 1101 goto nla_put_failure;
1102 } 1102 }
1103 CMD(start_p2p_device, START_P2P_DEVICE);
1103 1104
1104#ifdef CONFIG_NL80211_TESTMODE 1105#ifdef CONFIG_NL80211_TESTMODE
1105 CMD(testmode_cmd, TESTMODE); 1106 CMD(testmode_cmd, TESTMODE);
@@ -1748,13 +1749,13 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags,
1748 1749
1749 if (dev && 1750 if (dev &&
1750 (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 1751 (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
1751 nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) || 1752 nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name)))
1752 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dev->dev_addr)))
1753 goto nla_put_failure; 1753 goto nla_put_failure;
1754 1754
1755 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 1755 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
1756 nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) || 1756 nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) ||
1757 nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) || 1757 nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
1758 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, wdev_address(wdev)) ||
1758 nla_put_u32(msg, NL80211_ATTR_GENERATION, 1759 nla_put_u32(msg, NL80211_ATTR_GENERATION,
1759 rdev->devlist_generation ^ 1760 rdev->devlist_generation ^
1760 (cfg80211_rdev_list_generation << 2))) 1761 (cfg80211_rdev_list_generation << 2)))
@@ -2021,8 +2022,10 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
2021 return PTR_ERR(wdev); 2022 return PTR_ERR(wdev);
2022 } 2023 }
2023 2024
2024 if (type == NL80211_IFTYPE_MESH_POINT && 2025 switch (type) {
2025 info->attrs[NL80211_ATTR_MESH_ID]) { 2026 case NL80211_IFTYPE_MESH_POINT:
2027 if (!info->attrs[NL80211_ATTR_MESH_ID])
2028 break;
2026 wdev_lock(wdev); 2029 wdev_lock(wdev);
2027 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != 2030 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN !=
2028 IEEE80211_MAX_MESH_ID_LEN); 2031 IEEE80211_MAX_MESH_ID_LEN);
@@ -2031,6 +2034,26 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
2031 memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]), 2034 memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]),
2032 wdev->mesh_id_up_len); 2035 wdev->mesh_id_up_len);
2033 wdev_unlock(wdev); 2036 wdev_unlock(wdev);
2037 break;
2038 case NL80211_IFTYPE_P2P_DEVICE:
2039 /*
2040 * P2P Device doesn't have a netdev, so doesn't go
2041 * through the netdev notifier and must be added here
2042 */
2043 mutex_init(&wdev->mtx);
2044 INIT_LIST_HEAD(&wdev->event_list);
2045 spin_lock_init(&wdev->event_lock);
2046 INIT_LIST_HEAD(&wdev->mgmt_registrations);
2047 spin_lock_init(&wdev->mgmt_registrations_lock);
2048
2049 mutex_lock(&rdev->devlist_mtx);
2050 wdev->identifier = ++rdev->wdev_id;
2051 list_add_rcu(&wdev->list, &rdev->wdev_list);
2052 rdev->devlist_generation++;
2053 mutex_unlock(&rdev->devlist_mtx);
2054 break;
2055 default:
2056 break;
2034 } 2057 }
2035 2058
2036 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, 2059 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0,
@@ -6053,6 +6076,7 @@ static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)
6053 case NL80211_IFTYPE_AP_VLAN: 6076 case NL80211_IFTYPE_AP_VLAN:
6054 case NL80211_IFTYPE_MESH_POINT: 6077 case NL80211_IFTYPE_MESH_POINT:
6055 case NL80211_IFTYPE_P2P_GO: 6078 case NL80211_IFTYPE_P2P_GO:
6079 case NL80211_IFTYPE_P2P_DEVICE:
6056 break; 6080 break;
6057 default: 6081 default:
6058 return -EOPNOTSUPP; 6082 return -EOPNOTSUPP;
@@ -6099,6 +6123,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
6099 case NL80211_IFTYPE_AP_VLAN: 6123 case NL80211_IFTYPE_AP_VLAN:
6100 case NL80211_IFTYPE_MESH_POINT: 6124 case NL80211_IFTYPE_MESH_POINT:
6101 case NL80211_IFTYPE_P2P_GO: 6125 case NL80211_IFTYPE_P2P_GO:
6126 case NL80211_IFTYPE_P2P_DEVICE:
6102 break; 6127 break;
6103 default: 6128 default:
6104 return -EOPNOTSUPP; 6129 return -EOPNOTSUPP;
@@ -6195,6 +6220,7 @@ static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *in
6195 case NL80211_IFTYPE_AP: 6220 case NL80211_IFTYPE_AP:
6196 case NL80211_IFTYPE_AP_VLAN: 6221 case NL80211_IFTYPE_AP_VLAN:
6197 case NL80211_IFTYPE_P2P_GO: 6222 case NL80211_IFTYPE_P2P_GO:
6223 case NL80211_IFTYPE_P2P_DEVICE:
6198 break; 6224 break;
6199 default: 6225 default:
6200 return -EOPNOTSUPP; 6226 return -EOPNOTSUPP;
@@ -6810,6 +6836,68 @@ static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info)
6810 return 0; 6836 return 0;
6811} 6837}
6812 6838
6839static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info)
6840{
6841 struct cfg80211_registered_device *rdev = info->user_ptr[0];
6842 struct wireless_dev *wdev = info->user_ptr[1];
6843 int err;
6844
6845 if (!rdev->ops->start_p2p_device)
6846 return -EOPNOTSUPP;
6847
6848 if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
6849 return -EOPNOTSUPP;
6850
6851 if (wdev->p2p_started)
6852 return 0;
6853
6854 mutex_lock(&rdev->devlist_mtx);
6855 err = cfg80211_can_add_interface(rdev, wdev->iftype);
6856 mutex_unlock(&rdev->devlist_mtx);
6857 if (err)
6858 return err;
6859
6860 err = rdev->ops->start_p2p_device(&rdev->wiphy, wdev);
6861 if (err)
6862 return err;
6863
6864 wdev->p2p_started = true;
6865 mutex_lock(&rdev->devlist_mtx);
6866 rdev->opencount++;
6867 mutex_unlock(&rdev->devlist_mtx);
6868
6869 return 0;
6870}
6871
6872static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info)
6873{
6874 struct cfg80211_registered_device *rdev = info->user_ptr[0];
6875 struct wireless_dev *wdev = info->user_ptr[1];
6876
6877 if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
6878 return -EOPNOTSUPP;
6879
6880 if (!rdev->ops->stop_p2p_device)
6881 return -EOPNOTSUPP;
6882
6883 if (!wdev->p2p_started)
6884 return 0;
6885
6886 rdev->ops->stop_p2p_device(&rdev->wiphy, wdev);
6887 wdev->p2p_started = false;
6888
6889 mutex_lock(&rdev->devlist_mtx);
6890 rdev->opencount--;
6891 mutex_unlock(&rdev->devlist_mtx);
6892
6893 if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) {
6894 rdev->scan_req->aborted = true;
6895 ___cfg80211_scan_done(rdev, true);
6896 }
6897
6898 return 0;
6899}
6900
6813#define NL80211_FLAG_NEED_WIPHY 0x01 6901#define NL80211_FLAG_NEED_WIPHY 0x01
6814#define NL80211_FLAG_NEED_NETDEV 0x02 6902#define NL80211_FLAG_NEED_NETDEV 0x02
6815#define NL80211_FLAG_NEED_RTNL 0x04 6903#define NL80211_FLAG_NEED_RTNL 0x04
@@ -6817,7 +6905,7 @@ static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info)
6817#define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\ 6905#define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\
6818 NL80211_FLAG_CHECK_NETDEV_UP) 6906 NL80211_FLAG_CHECK_NETDEV_UP)
6819#define NL80211_FLAG_NEED_WDEV 0x10 6907#define NL80211_FLAG_NEED_WDEV 0x10
6820/* If a netdev is associated, it must be UP */ 6908/* If a netdev is associated, it must be UP, P2P must be started */
6821#define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ 6909#define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\
6822 NL80211_FLAG_CHECK_NETDEV_UP) 6910 NL80211_FLAG_CHECK_NETDEV_UP)
6823 6911
@@ -6878,6 +6966,13 @@ static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb,
6878 } 6966 }
6879 6967
6880 dev_hold(dev); 6968 dev_hold(dev);
6969 } else if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP) {
6970 if (!wdev->p2p_started) {
6971 mutex_unlock(&cfg80211_mutex);
6972 if (rtnl)
6973 rtnl_unlock();
6974 return -ENETDOWN;
6975 }
6881 } 6976 }
6882 6977
6883 cfg80211_lock_rdev(rdev); 6978 cfg80211_lock_rdev(rdev);
@@ -7439,7 +7534,22 @@ static struct genl_ops nl80211_ops[] = {
7439 .internal_flags = NL80211_FLAG_NEED_NETDEV | 7534 .internal_flags = NL80211_FLAG_NEED_NETDEV |
7440 NL80211_FLAG_NEED_RTNL, 7535 NL80211_FLAG_NEED_RTNL,
7441 }, 7536 },
7442 7537 {
7538 .cmd = NL80211_CMD_START_P2P_DEVICE,
7539 .doit = nl80211_start_p2p_device,
7540 .policy = nl80211_policy,
7541 .flags = GENL_ADMIN_PERM,
7542 .internal_flags = NL80211_FLAG_NEED_WDEV |
7543 NL80211_FLAG_NEED_RTNL,
7544 },
7545 {
7546 .cmd = NL80211_CMD_STOP_P2P_DEVICE,
7547 .doit = nl80211_stop_p2p_device,
7548 .policy = nl80211_policy,
7549 .flags = GENL_ADMIN_PERM,
7550 .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
7551 NL80211_FLAG_NEED_RTNL,
7552 },
7443}; 7553};
7444 7554
7445static struct genl_multicast_group nl80211_mlme_mcgrp = { 7555static struct genl_multicast_group nl80211_mlme_mcgrp = {
diff --git a/net/wireless/radiotap.c b/net/wireless/radiotap.c
index c4ad7958af52..7d604c06c3dc 100644
--- a/net/wireless/radiotap.c
+++ b/net/wireless/radiotap.c
@@ -41,6 +41,8 @@ static const struct radiotap_align_size rtap_namespace_sizes[] = {
41 [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, 41 [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, },
42 [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, 42 [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, },
43 [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, 43 [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, },
44 [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, },
45 [IEEE80211_RADIOTAP_AMPDU_STATUS] = { .align = 4, .size = 8, },
44 /* 46 /*
45 * add more here as they are defined in radiotap.h 47 * add more here as they are defined in radiotap.h
46 */ 48 */
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 26f8cd30f712..d7b672262b5f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -684,22 +684,10 @@ EXPORT_SYMBOL(cfg80211_classify8021d);
684 684
685const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie) 685const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie)
686{ 686{
687 u8 *end, *pos; 687 if (bss->information_elements == NULL)
688
689 pos = bss->information_elements;
690 if (pos == NULL)
691 return NULL; 688 return NULL;
692 end = pos + bss->len_information_elements; 689 return cfg80211_find_ie(ie, bss->information_elements,
693 690 bss->len_information_elements);
694 while (pos + 1 < end) {
695 if (pos + 2 + pos[1] > end)
696 break;
697 if (pos[0] == ie)
698 return pos;
699 pos += 2 + pos[1];
700 }
701
702 return NULL;
703} 691}
704EXPORT_SYMBOL(ieee80211_bss_get_ie); 692EXPORT_SYMBOL(ieee80211_bss_get_ie);
705 693
@@ -812,6 +800,10 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
812 if (otype == NL80211_IFTYPE_AP_VLAN) 800 if (otype == NL80211_IFTYPE_AP_VLAN)
813 return -EOPNOTSUPP; 801 return -EOPNOTSUPP;
814 802
803 /* cannot change into P2P device type */
804 if (ntype == NL80211_IFTYPE_P2P_DEVICE)
805 return -EOPNOTSUPP;
806
815 if (!rdev->ops->change_virtual_intf || 807 if (!rdev->ops->change_virtual_intf ||
816 !(rdev->wiphy.interface_modes & (1 << ntype))) 808 !(rdev->wiphy.interface_modes & (1 << ntype)))
817 return -EOPNOTSUPP; 809 return -EOPNOTSUPP;
@@ -889,6 +881,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
889 case NUM_NL80211_IFTYPES: 881 case NUM_NL80211_IFTYPES:
890 /* not happening */ 882 /* not happening */
891 break; 883 break;
884 case NL80211_IFTYPE_P2P_DEVICE:
885 WARN_ON(1);
886 break;
892 } 887 }
893 } 888 }
894 889
@@ -1053,8 +1048,15 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
1053 list_for_each_entry(wdev_iter, &rdev->wdev_list, list) { 1048 list_for_each_entry(wdev_iter, &rdev->wdev_list, list) {
1054 if (wdev_iter == wdev) 1049 if (wdev_iter == wdev)
1055 continue; 1050 continue;
1056 if (!netif_running(wdev_iter->netdev)) 1051 if (wdev_iter->netdev) {
1057 continue; 1052 if (!netif_running(wdev_iter->netdev))
1053 continue;
1054 } else if (wdev_iter->iftype == NL80211_IFTYPE_P2P_DEVICE) {
1055 if (!wdev_iter->p2p_started)
1056 continue;
1057 } else {
1058 WARN_ON(1);
1059 }
1058 1060
1059 if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype)) 1061 if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype))
1060 continue; 1062 continue;