aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorAyala Beker <ayala.beker@intel.com>2016-09-20 10:31:14 -0400
committerJohannes Berg <johannes.berg@intel.com>2016-09-30 07:21:19 -0400
commit708d50edb149fe488c7c96f59ba9a89a64985cf2 (patch)
treea6ce214b208019439758c9a326beb4010308a6e4 /net/mac80211
parentcb3b7d87652aeb37cfb5295a6157a3280dae10cb (diff)
mac80211: add boilerplate code for start / stop NAN
This code doesn't do much besides allowing to start and stop the vif. Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Ayala Beker <ayala.beker@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/cfg.c36
-rw-r--r--net/mac80211/chan.c3
-rw-r--r--net/mac80211/driver-ops.h27
-rw-r--r--net/mac80211/iface.c8
-rw-r--r--net/mac80211/main.c5
-rw-r--r--net/mac80211/offchannel.c3
-rw-r--r--net/mac80211/trace.h50
-rw-r--r--net/mac80211/util.c3
8 files changed, 131 insertions, 4 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a74027f887bc..9aabb0932d24 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 * Copyright 2013-2015 Intel Mobile Communications GmbH 5 * Copyright 2013-2015 Intel Mobile Communications GmbH
6 * Copyright (C) 2015-2016 Intel Deutschland GmbH
6 * 7 *
7 * This file is GPLv2 as found in COPYING. 8 * This file is GPLv2 as found in COPYING.
8 */ 9 */
@@ -152,6 +153,39 @@ static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
152 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev)); 153 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
153} 154}
154 155
156static int ieee80211_start_nan(struct wiphy *wiphy,
157 struct wireless_dev *wdev,
158 struct cfg80211_nan_conf *conf)
159{
160 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
161 int ret;
162
163 mutex_lock(&sdata->local->chanctx_mtx);
164 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
165 mutex_unlock(&sdata->local->chanctx_mtx);
166 if (ret < 0)
167 return ret;
168
169 ret = ieee80211_do_open(wdev, true);
170 if (ret)
171 return ret;
172
173 ret = drv_start_nan(sdata->local, sdata, conf);
174 if (ret)
175 ieee80211_sdata_stop(sdata);
176
177 return ret;
178}
179
180static void ieee80211_stop_nan(struct wiphy *wiphy,
181 struct wireless_dev *wdev)
182{
183 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
184
185 drv_stop_nan(sdata->local, sdata);
186 ieee80211_sdata_stop(sdata);
187}
188
155static int ieee80211_set_noack_map(struct wiphy *wiphy, 189static int ieee80211_set_noack_map(struct wiphy *wiphy,
156 struct net_device *dev, 190 struct net_device *dev,
157 u16 noack_map) 191 u16 noack_map)
@@ -3464,4 +3498,6 @@ const struct cfg80211_ops mac80211_config_ops = {
3464 .set_ap_chanwidth = ieee80211_set_ap_chanwidth, 3498 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
3465 .add_tx_ts = ieee80211_add_tx_ts, 3499 .add_tx_ts = ieee80211_add_tx_ts,
3466 .del_tx_ts = ieee80211_del_tx_ts, 3500 .del_tx_ts = ieee80211_del_tx_ts,
3501 .start_nan = ieee80211_start_nan,
3502 .stop_nan = ieee80211_stop_nan,
3467}; 3503};
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index d035801569eb..e75cbf6ecc26 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -647,6 +647,9 @@ static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
647 struct ieee80211_chanctx *curr_ctx = NULL; 647 struct ieee80211_chanctx *curr_ctx = NULL;
648 int ret = 0; 648 int ret = 0;
649 649
650 if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_NAN))
651 return -ENOTSUPP;
652
650 conf = rcu_dereference_protected(sdata->vif.chanctx_conf, 653 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
651 lockdep_is_held(&local->chanctx_mtx)); 654 lockdep_is_held(&local->chanctx_mtx));
652 655
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index fe35a1c0dc86..e52cfb855bd9 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -162,6 +162,7 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
162 return; 162 return;
163 163
164 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE || 164 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
165 sdata->vif.type == NL80211_IFTYPE_NAN ||
165 (sdata->vif.type == NL80211_IFTYPE_MONITOR && 166 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
166 !sdata->vif.mu_mimo_owner))) 167 !sdata->vif.mu_mimo_owner)))
167 return; 168 return;
@@ -1165,4 +1166,30 @@ static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1165 local->ops->wake_tx_queue(&local->hw, &txq->txq); 1166 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1166} 1167}
1167 1168
1169static inline int drv_start_nan(struct ieee80211_local *local,
1170 struct ieee80211_sub_if_data *sdata,
1171 struct cfg80211_nan_conf *conf)
1172{
1173 int ret;
1174
1175 might_sleep();
1176 check_sdata_in_driver(sdata);
1177
1178 trace_drv_start_nan(local, sdata, conf);
1179 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1180 trace_drv_return_int(local, ret);
1181 return ret;
1182}
1183
1184static inline void drv_stop_nan(struct ieee80211_local *local,
1185 struct ieee80211_sub_if_data *sdata)
1186{
1187 might_sleep();
1188 check_sdata_in_driver(sdata);
1189
1190 trace_drv_stop_nan(local, sdata);
1191 local->ops->stop_nan(&local->hw, &sdata->vif);
1192 trace_drv_return_void(local);
1193}
1194
1168#endif /* __MAC80211_DRIVER_OPS */ 1195#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index e694ca2baad0..507f46a8eb1c 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -327,6 +327,9 @@ static int ieee80211_check_queues(struct ieee80211_sub_if_data *sdata,
327 int n_queues = sdata->local->hw.queues; 327 int n_queues = sdata->local->hw.queues;
328 int i; 328 int i;
329 329
330 if (iftype == NL80211_IFTYPE_NAN)
331 return 0;
332
330 if (iftype != NL80211_IFTYPE_P2P_DEVICE) { 333 if (iftype != NL80211_IFTYPE_P2P_DEVICE) {
331 for (i = 0; i < IEEE80211_NUM_ACS; i++) { 334 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
332 if (WARN_ON_ONCE(sdata->vif.hw_queue[i] == 335 if (WARN_ON_ONCE(sdata->vif.hw_queue[i] ==
@@ -647,7 +650,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
647 local->fif_probe_req++; 650 local->fif_probe_req++;
648 } 651 }
649 652
650 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE) 653 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
654 sdata->vif.type != NL80211_IFTYPE_NAN)
651 changed |= ieee80211_reset_erp_info(sdata); 655 changed |= ieee80211_reset_erp_info(sdata);
652 ieee80211_bss_info_change_notify(sdata, changed); 656 ieee80211_bss_info_change_notify(sdata, changed);
653 657
@@ -1726,7 +1730,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1726 1730
1727 ASSERT_RTNL(); 1731 ASSERT_RTNL();
1728 1732
1729 if (type == NL80211_IFTYPE_P2P_DEVICE) { 1733 if (type == NL80211_IFTYPE_P2P_DEVICE || type == NL80211_IFTYPE_NAN) {
1730 struct wireless_dev *wdev; 1734 struct wireless_dev *wdev;
1731 1735
1732 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size, 1736 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index ac053a9df36d..b5cf2c5cc166 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -821,6 +821,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
821 !local->ops->tdls_recv_channel_switch)) 821 !local->ops->tdls_recv_channel_switch))
822 return -EOPNOTSUPP; 822 return -EOPNOTSUPP;
823 823
824 if (WARN_ON(local->hw.wiphy->interface_modes &
825 BIT(NL80211_IFTYPE_NAN) &&
826 (!local->ops->start_nan || !local->ops->stop_nan)))
827 return -EINVAL;
828
824#ifdef CONFIG_PM 829#ifdef CONFIG_PM
825 if (hw->wiphy->wowlan && (!local->ops->suspend || !local->ops->resume)) 830 if (hw->wiphy->wowlan && (!local->ops->suspend || !local->ops->resume))
826 return -EINVAL; 831 return -EINVAL;
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 75d5c960ce67..c3f610bba3fe 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -128,7 +128,8 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
128 if (!ieee80211_sdata_running(sdata)) 128 if (!ieee80211_sdata_running(sdata))
129 continue; 129 continue;
130 130
131 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) 131 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
132 sdata->vif.type == NL80211_IFTYPE_NAN)
132 continue; 133 continue;
133 134
134 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) 135 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 77e4c53baefb..deefbfb9f6fb 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -1700,6 +1700,56 @@ TRACE_EVENT(drv_get_expected_throughput,
1700 ) 1700 )
1701); 1701);
1702 1702
1703TRACE_EVENT(drv_start_nan,
1704 TP_PROTO(struct ieee80211_local *local,
1705 struct ieee80211_sub_if_data *sdata,
1706 struct cfg80211_nan_conf *conf),
1707
1708 TP_ARGS(local, sdata, conf),
1709 TP_STRUCT__entry(
1710 LOCAL_ENTRY
1711 VIF_ENTRY
1712 __field(u8, master_pref)
1713 __field(u8, dual)
1714 ),
1715
1716 TP_fast_assign(
1717 LOCAL_ASSIGN;
1718 VIF_ASSIGN;
1719 __entry->master_pref = conf->master_pref;
1720 __entry->dual = conf->dual;
1721 ),
1722
1723 TP_printk(
1724 LOCAL_PR_FMT VIF_PR_FMT
1725 ", master preference: %u, dual: %d",
1726 LOCAL_PR_ARG, VIF_PR_ARG, __entry->master_pref,
1727 __entry->dual
1728 )
1729);
1730
1731TRACE_EVENT(drv_stop_nan,
1732 TP_PROTO(struct ieee80211_local *local,
1733 struct ieee80211_sub_if_data *sdata),
1734
1735 TP_ARGS(local, sdata),
1736
1737 TP_STRUCT__entry(
1738 LOCAL_ENTRY
1739 VIF_ENTRY
1740 ),
1741
1742 TP_fast_assign(
1743 LOCAL_ASSIGN;
1744 VIF_ASSIGN;
1745 ),
1746
1747 TP_printk(
1748 LOCAL_PR_FMT VIF_PR_FMT,
1749 LOCAL_PR_ARG, VIF_PR_ARG
1750 )
1751);
1752
1703/* 1753/*
1704 * Tracing for API calls that drivers call. 1754 * Tracing for API calls that drivers call.
1705 */ 1755 */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 2c78541f695c..5b57fcaaec9b 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1209,7 +1209,8 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1209 } 1209 }
1210 1210
1211 if (sdata->vif.type != NL80211_IFTYPE_MONITOR && 1211 if (sdata->vif.type != NL80211_IFTYPE_MONITOR &&
1212 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE) { 1212 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
1213 sdata->vif.type != NL80211_IFTYPE_NAN) {
1213 sdata->vif.bss_conf.qos = enable_qos; 1214 sdata->vif.bss_conf.qos = enable_qos;
1214 if (bss_notify) 1215 if (bss_notify)
1215 ieee80211_bss_info_change_notify(sdata, 1216 ieee80211_bss_info_change_notify(sdata,