Skip to content

Commit ad9360b

Browse files
committed
Merge tag 'mac80211-next-for-davem-2015-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
Johannes Berg says: ==================== This pull request got a bit bigger than I wanted, due to needing to reshuffle and fix some bugs. I merged mac80211 to get the right base for some of these changes. * new mac80211 API for upcoming driver changes: EOSP handling, key iteration * scan abort changes allowing to cancel an ongoing scan * VHT IBSS 80+80 MHz support * re-enable full AP client state tracking after fixes * various small fixes (that weren't relevant for mac80211) * various cleanups ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4c9668d + 1b89452 commit ad9360b

28 files changed

+1328
-957
lines changed

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 81 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ struct mac80211_hwsim_data {
495495
const struct ieee80211_regdomain *regd;
496496

497497
struct ieee80211_channel *tmp_chan;
498+
struct ieee80211_channel *roc_chan;
499+
u32 roc_duration;
500+
struct delayed_work roc_start;
498501
struct delayed_work roc_done;
499502
struct delayed_work hw_scan;
500503
struct cfg80211_scan_request *hw_scan_request;
@@ -514,6 +517,7 @@ struct mac80211_hwsim_data {
514517
bool ps_poll_pending;
515518
struct dentry *debugfs;
516519

520+
uintptr_t pending_cookie;
517521
struct sk_buff_head pending; /* packets pending */
518522
/*
519523
* Only radios in the same group can communicate together (the
@@ -810,6 +814,9 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
810814
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_skb);
811815
struct ieee80211_rate *txrate = ieee80211_get_tx_rate(hw, info);
812816

817+
if (WARN_ON(!txrate))
818+
return;
819+
813820
if (!netif_running(hwsim_mon))
814821
return;
815822

@@ -960,6 +967,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
960967
unsigned int hwsim_flags = 0;
961968
int i;
962969
struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES];
970+
uintptr_t cookie;
963971

964972
if (data->ps != PS_DISABLED)
965973
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
@@ -1018,7 +1026,10 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
10181026
goto nla_put_failure;
10191027

10201028
/* We create a cookie to identify this skb */
1021-
if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, (unsigned long) my_skb))
1029+
data->pending_cookie++;
1030+
cookie = data->pending_cookie;
1031+
info->rate_driver_data[0] = (void *)cookie;
1032+
if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, cookie))
10221033
goto nla_put_failure;
10231034

10241035
genlmsg_end(skb, msg_head);
@@ -1247,6 +1258,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
12471258
{
12481259
struct mac80211_hwsim_data *data = hw->priv;
12491260
struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb);
1261+
struct ieee80211_hdr *hdr = (void *)skb->data;
12501262
struct ieee80211_chanctx_conf *chanctx_conf;
12511263
struct ieee80211_channel *channel;
12521264
bool ack;
@@ -1292,6 +1304,22 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
12921304
ARRAY_SIZE(txi->control.rates));
12931305

12941306
txi->rate_driver_data[0] = channel;
1307+
1308+
if (skb->len >= 24 + 8 &&
1309+
ieee80211_is_probe_resp(hdr->frame_control)) {
1310+
/* fake header transmission time */
1311+
struct ieee80211_mgmt *mgmt;
1312+
struct ieee80211_rate *txrate;
1313+
u64 ts;
1314+
1315+
mgmt = (struct ieee80211_mgmt *)skb->data;
1316+
txrate = ieee80211_get_tx_rate(hw, txi);
1317+
ts = mac80211_hwsim_get_tsf_raw();
1318+
mgmt->u.probe_resp.timestamp =
1319+
cpu_to_le64(ts + data->tsf_offset +
1320+
24 * 8 * 10 / txrate->bitrate);
1321+
}
1322+
12951323
mac80211_hwsim_monitor_rx(hw, skb, channel);
12961324

12971325
/* wmediumd mode check */
@@ -1871,7 +1899,8 @@ static void hw_scan_work(struct work_struct *work)
18711899
req->channels[hwsim->scan_chan_idx]->center_freq);
18721900

18731901
hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx];
1874-
if (hwsim->tmp_chan->flags & IEEE80211_CHAN_NO_IR ||
1902+
if (hwsim->tmp_chan->flags & (IEEE80211_CHAN_NO_IR |
1903+
IEEE80211_CHAN_RADAR) ||
18751904
!req->n_ssids) {
18761905
dwell = 120;
18771906
} else {
@@ -1987,6 +2016,23 @@ static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw,
19872016
mutex_unlock(&hwsim->mutex);
19882017
}
19892018

2019+
static void hw_roc_start(struct work_struct *work)
2020+
{
2021+
struct mac80211_hwsim_data *hwsim =
2022+
container_of(work, struct mac80211_hwsim_data, roc_start.work);
2023+
2024+
mutex_lock(&hwsim->mutex);
2025+
2026+
wiphy_debug(hwsim->hw->wiphy, "hwsim ROC begins\n");
2027+
hwsim->tmp_chan = hwsim->roc_chan;
2028+
ieee80211_ready_on_channel(hwsim->hw);
2029+
2030+
ieee80211_queue_delayed_work(hwsim->hw, &hwsim->roc_done,
2031+
msecs_to_jiffies(hwsim->roc_duration));
2032+
2033+
mutex_unlock(&hwsim->mutex);
2034+
}
2035+
19902036
static void hw_roc_done(struct work_struct *work)
19912037
{
19922038
struct mac80211_hwsim_data *hwsim =
@@ -2014,23 +2060,22 @@ static int mac80211_hwsim_roc(struct ieee80211_hw *hw,
20142060
return -EBUSY;
20152061
}
20162062

2017-
hwsim->tmp_chan = chan;
2063+
hwsim->roc_chan = chan;
2064+
hwsim->roc_duration = duration;
20182065
mutex_unlock(&hwsim->mutex);
20192066

20202067
wiphy_debug(hw->wiphy, "hwsim ROC (%d MHz, %d ms)\n",
20212068
chan->center_freq, duration);
2069+
ieee80211_queue_delayed_work(hw, &hwsim->roc_start, HZ/50);
20222070

2023-
ieee80211_ready_on_channel(hw);
2024-
2025-
ieee80211_queue_delayed_work(hw, &hwsim->roc_done,
2026-
msecs_to_jiffies(duration));
20272071
return 0;
20282072
}
20292073

20302074
static int mac80211_hwsim_croc(struct ieee80211_hw *hw)
20312075
{
20322076
struct mac80211_hwsim_data *hwsim = hw->priv;
20332077

2078+
cancel_delayed_work_sync(&hwsim->roc_start);
20342079
cancel_delayed_work_sync(&hwsim->roc_done);
20352080

20362081
mutex_lock(&hwsim->mutex);
@@ -2375,6 +2420,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
23752420
hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb);
23762421
}
23772422

2423+
INIT_DELAYED_WORK(&data->roc_start, hw_roc_start);
23782424
INIT_DELAYED_WORK(&data->roc_done, hw_roc_done);
23792425
INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work);
23802426

@@ -2411,6 +2457,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
24112457
NL80211_FEATURE_STATIC_SMPS |
24122458
NL80211_FEATURE_DYNAMIC_SMPS |
24132459
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
2460+
wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
24142461

24152462
/* ask mac80211 to reserve space for magic */
24162463
hw->vif_data_size = sizeof(struct hwsim_vif_priv);
@@ -2710,7 +2757,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
27102757
struct mac80211_hwsim_data *data2;
27112758
struct ieee80211_tx_info *txi;
27122759
struct hwsim_tx_rate *tx_attempts;
2713-
unsigned long ret_skb_ptr;
2760+
u64 ret_skb_cookie;
27142761
struct sk_buff *skb, *tmp;
27152762
const u8 *src;
27162763
unsigned int hwsim_flags;
@@ -2728,15 +2775,20 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
27282775

27292776
src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]);
27302777
hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]);
2731-
ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);
2778+
ret_skb_cookie = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);
27322779

27332780
data2 = get_hwsim_data_ref_from_addr(src);
27342781
if (!data2)
27352782
goto out;
27362783

27372784
/* look for the skb matching the cookie passed back from user */
27382785
skb_queue_walk_safe(&data2->pending, skb, tmp) {
2739-
if ((unsigned long)skb == ret_skb_ptr) {
2786+
u64 skb_cookie;
2787+
2788+
txi = IEEE80211_SKB_CB(skb);
2789+
skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0];
2790+
2791+
if (skb_cookie == ret_skb_cookie) {
27402792
skb_unlink(skb, &data2->pending);
27412793
found = true;
27422794
break;
@@ -2827,10 +2879,25 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
28272879

28282880
/* A frame is received from user space */
28292881
memset(&rx_status, 0, sizeof(rx_status));
2830-
/* TODO: Check ATTR_FREQ if it exists, and maybe throw away off-channel
2831-
* packets?
2832-
*/
2833-
rx_status.freq = data2->channel->center_freq;
2882+
if (info->attrs[HWSIM_ATTR_FREQ]) {
2883+
/* throw away off-channel packets, but allow both the temporary
2884+
* ("hw" scan/remain-on-channel) and regular channel, since the
2885+
* internal datapath also allows this
2886+
*/
2887+
mutex_lock(&data2->mutex);
2888+
rx_status.freq = nla_get_u32(info->attrs[HWSIM_ATTR_FREQ]);
2889+
2890+
if (rx_status.freq != data2->channel->center_freq &&
2891+
(!data2->tmp_chan ||
2892+
rx_status.freq != data2->tmp_chan->center_freq)) {
2893+
mutex_unlock(&data2->mutex);
2894+
goto out;
2895+
}
2896+
mutex_unlock(&data2->mutex);
2897+
} else {
2898+
rx_status.freq = data2->channel->center_freq;
2899+
}
2900+
28342901
rx_status.band = data2->channel->band;
28352902
rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
28362903
rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);

include/net/cfg80211.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,8 @@ struct cfg80211_qos_map {
23212321
* the driver, and will be valid until passed to cfg80211_scan_done().
23222322
* For scan results, call cfg80211_inform_bss(); you can call this outside
23232323
* the scan/scan_done bracket too.
2324+
* @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
2325+
* indicate the status of the scan through cfg80211_scan_done().
23242326
*
23252327
* @auth: Request to authenticate with the specified peer
23262328
* (invoked with the wireless_dev mutex held)
@@ -2593,6 +2595,7 @@ struct cfg80211_ops {
25932595

25942596
int (*scan)(struct wiphy *wiphy,
25952597
struct cfg80211_scan_request *request);
2598+
void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
25962599

25972600
int (*auth)(struct wiphy *wiphy, struct net_device *dev,
25982601
struct cfg80211_auth_request *req);
@@ -5173,8 +5176,11 @@ size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
51735176
* buffer starts, which may be @ielen if the entire (remainder)
51745177
* of the buffer should be used.
51755178
*/
5176-
size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5177-
const u8 *ids, int n_ids, size_t offset);
5179+
static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5180+
const u8 *ids, int n_ids, size_t offset)
5181+
{
5182+
return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
5183+
}
51785184

51795185
/**
51805186
* cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN

include/net/mac80211.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,11 +1321,15 @@ struct ieee80211_channel_switch {
13211321
* interface. This flag should be set during interface addition,
13221322
* but may be set/cleared as late as authentication to an AP. It is
13231323
* only valid for managed/station mode interfaces.
1324+
* @IEEE80211_VIF_GET_NOA_UPDATE: request to handle NOA attributes
1325+
* and send P2P_PS notification to the driver if NOA changed, even
1326+
* this is not pure P2P vif.
13241327
*/
13251328
enum ieee80211_vif_flags {
13261329
IEEE80211_VIF_BEACON_FILTER = BIT(0),
13271330
IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1),
13281331
IEEE80211_VIF_SUPPORTS_UAPSD = BIT(2),
1332+
IEEE80211_VIF_GET_NOA_UPDATE = BIT(3),
13291333
};
13301334

13311335
/**
@@ -1901,6 +1905,11 @@ struct ieee80211_txq {
19011905
* @IEEE80211_HW_BEACON_TX_STATUS: The device/driver provides TX status
19021906
* for sent beacons.
19031907
*
1908+
* @IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR: Hardware (or driver) requires that each
1909+
* station has a unique address, i.e. each station entry can be identified
1910+
* by just its MAC address; this prevents, for example, the same station
1911+
* from connecting to two virtual AP interfaces at the same time.
1912+
*
19041913
* @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
19051914
*/
19061915
enum ieee80211_hw_flags {
@@ -1936,6 +1945,7 @@ enum ieee80211_hw_flags {
19361945
IEEE80211_HW_TDLS_WIDER_BW,
19371946
IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
19381947
IEEE80211_HW_BEACON_TX_STATUS,
1948+
IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
19391949

19401950
/* keep last, obviously */
19411951
NUM_IEEE80211_HW_FLAGS
@@ -4862,6 +4872,28 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
48624872
*/
48634873
void ieee80211_sta_eosp(struct ieee80211_sta *pubsta);
48644874

4875+
/**
4876+
* ieee80211_send_eosp_nullfunc - ask mac80211 to send NDP with EOSP
4877+
* @pubsta: the station
4878+
* @tid: the tid of the NDP
4879+
*
4880+
* Sometimes the device understands that it needs to close
4881+
* the Service Period unexpectedly. This can happen when
4882+
* sending frames that are filling holes in the BA window.
4883+
* In this case, the device can ask mac80211 to send a
4884+
* Nullfunc frame with EOSP set. When that happens, the
4885+
* driver must have called ieee80211_sta_set_buffered() to
4886+
* let mac80211 know that there are no buffered frames any
4887+
* more, otherwise mac80211 will get the more_data bit wrong.
4888+
* The low level driver must have made sure that the frame
4889+
* will be sent despite the station being in power-save.
4890+
* Mac80211 won't call allow_buffered_frames().
4891+
* Note that calling this function, doesn't exempt the driver
4892+
* from closing the EOSP properly, it will still have to call
4893+
* ieee80211_sta_eosp when the NDP is sent.
4894+
*/
4895+
void ieee80211_send_eosp_nullfunc(struct ieee80211_sta *pubsta, int tid);
4896+
48654897
/**
48664898
* ieee80211_iter_keys - iterate keys programmed into the device
48674899
* @hw: pointer obtained from ieee80211_alloc_hw()
@@ -4889,6 +4921,30 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
48894921
void *data),
48904922
void *iter_data);
48914923

4924+
/**
4925+
* ieee80211_iter_keys_rcu - iterate keys programmed into the device
4926+
* @hw: pointer obtained from ieee80211_alloc_hw()
4927+
* @vif: virtual interface to iterate, may be %NULL for all
4928+
* @iter: iterator function that will be called for each key
4929+
* @iter_data: custom data to pass to the iterator function
4930+
*
4931+
* This function can be used to iterate all the keys known to
4932+
* mac80211, even those that weren't previously programmed into
4933+
* the device. Note that due to locking reasons, keys of station
4934+
* in removal process will be skipped.
4935+
*
4936+
* This function requires being called in an RCU critical section,
4937+
* and thus iter must be atomic.
4938+
*/
4939+
void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
4940+
struct ieee80211_vif *vif,
4941+
void (*iter)(struct ieee80211_hw *hw,
4942+
struct ieee80211_vif *vif,
4943+
struct ieee80211_sta *sta,
4944+
struct ieee80211_key_conf *key,
4945+
void *data),
4946+
void *iter_data);
4947+
48924948
/**
48934949
* ieee80211_iter_chan_contexts_atomic - iterate channel contexts
48944950
* @hw: pointre obtained from ieee80211_alloc_hw().

include/uapi/linux/nl80211.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,10 @@
820820
* as an event to indicate changes for devices with wiphy-specific regdom
821821
* management.
822822
*
823+
* @NL80211_CMD_ABORT_SCAN: Stop an ongoing scan. Returns -ENOENT if a scan is
824+
* not running. The driver indicates the status of the scan through
825+
* cfg80211_scan_done().
826+
*
823827
* @NL80211_CMD_MAX: highest used command number
824828
* @__NL80211_CMD_AFTER_LAST: internal use
825829
*/
@@ -1006,6 +1010,8 @@ enum nl80211_commands {
10061010

10071011
NL80211_CMD_WIPHY_REG_CHANGE,
10081012

1013+
NL80211_CMD_ABORT_SCAN,
1014+
10091015
/* add new commands above here */
10101016

10111017
/* used to define NL80211_CMD_MAX below */
@@ -1764,8 +1770,9 @@ enum nl80211_commands {
17641770
* over all channels.
17651771
*
17661772
* @NL80211_ATTR_SCHED_SCAN_DELAY: delay before the first cycle of a
1767-
* scheduled scan (or a WoWLAN net-detect scan) is started, u32
1768-
* in seconds.
1773+
* scheduled scan is started. Or the delay before a WoWLAN
1774+
* net-detect scan is started, counting from the moment the
1775+
* system is suspended. This value is a u32, in seconds.
17691776
17701777
* @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device
17711778
* is operating in an indoor environment.

0 commit comments

Comments
 (0)