Re: [PATCH v3 1/9] cfg80211: add start / stop NAN commands

2016-09-30 Thread Johannes Berg
All applied.

johannes


[PATCH v3 1/9] cfg80211: add start / stop NAN commands

2016-09-20 Thread Luca Coelho
From: Ayala Beker 

This allows user space to start/stop NAN interface.
A NAN interface is like P2P device in a few aspects: it
doesn't have a netdev associated to it.
Add the new interface type and prevent operations that
can't be executed on NAN interface like scan.

Define several attributes that may be configured by user space
when starting NAN functionality (master preference and dual
band operation)

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 include/net/cfg80211.h   | 21 +-
 include/uapi/linux/nl80211.h | 47 +++
 net/mac80211/cfg.c   |  2 +
 net/mac80211/chan.c  |  3 ++
 net/mac80211/iface.c |  4 ++
 net/mac80211/offchannel.c|  1 +
 net/mac80211/rx.c|  3 ++
 net/mac80211/util.c  |  1 +
 net/wireless/chan.c  |  2 +
 net/wireless/core.c  | 34 +
 net/wireless/core.h  |  3 ++
 net/wireless/mlme.c  |  1 +
 net/wireless/nl80211.c   | 91 ++--
 net/wireless/rdev-ops.h  | 20 ++
 net/wireless/trace.h | 27 +
 net/wireless/util.c  |  6 ++-
 16 files changed, 260 insertions(+), 6 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index d5e7f69..a3ea4cc 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2293,6 +2293,19 @@ struct cfg80211_qos_map {
 };
 
 /**
+ * struct cfg80211_nan_conf - NAN configuration
+ *
+ * This struct defines NAN configuration parameters
+ *
+ * @master_pref: master preference (1 - 255)
+ * @dual: dual band operation mode, see  nl80211_nan_dual_band_conf
+ */
+struct cfg80211_nan_conf {
+   u8 master_pref;
+   u8 dual;
+};
+
+/**
  * struct cfg80211_ops - backend description for wireless configuration
  *
  * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -2580,6 +2593,8 @@ struct cfg80211_qos_map {
  * and returning to the base channel for communication with the AP.
  * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
  * peers must be on the base channel when the call completes.
+ * @start_nan: Start the NAN interface.
+ * @stop_nan: Stop the NAN interface.
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2845,6 +2860,9 @@ struct cfg80211_ops {
void(*tdls_cancel_channel_switch)(struct wiphy *wiphy,
  struct net_device *dev,
  const u8 *addr);
+   int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
+struct cfg80211_nan_conf *conf);
+   void(*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
 };
 
 /*
@@ -3602,6 +3620,7 @@ struct cfg80211_cached_keys;
  * beacons, 0 when not valid
  * @address: The address for this device, valid only if @netdev is %NULL
  * @p2p_started: true if this is a P2P Device that has been started
+ * @nan_started: true if this is a NAN interface that has been started
  * @cac_started: true if DFS channel availability check has been started
  * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
  * @cac_time_ms: CAC time in ms
@@ -3633,7 +3652,7 @@ struct wireless_dev {
 
struct mutex mtx;
 
-   bool use_4addr, p2p_started;
+   bool use_4addr, p2p_started, nan_started;
 
u8 address[ETH_ALEN] __aligned(sizeof(u16));
 
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 2206941..a34eb18 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -838,6 +838,16 @@
  * not running. The driver indicates the status of the scan through
  * cfg80211_scan_done().
  *
+ * @NL80211_CMD_START_NAN: Start NAN operation, identified by its
+ * %NL80211_ATTR_WDEV interface. This interface must have been previously
+ * created with %NL80211_CMD_NEW_INTERFACE. After it has been started, the
+ * NAN interface will create or join a cluster. This command must have a
+ * valid %NL80211_ATTR_NAN_MASTER_PREF attribute and optional
+ * %NL80211_ATTR_NAN_DUAL attributes.
+ * After this command NAN functions can be added.
+ * @NL80211_CMD_STOP_NAN: Stop the NAN operation, identified by
+ * its %NL80211_ATTR_WDEV interface.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1026,6 +1036,9 @@ enum nl80211_commands {
 
NL80211_CMD_ABORT_SCAN,
 
+   NL80211_CMD_START_NAN,
+   NL80211_CMD_STOP_NAN,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -1733,6 +1746,12 @@ enum nl80211_commands {
  * regulatory indoor configuration would be