Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-21 Thread Arend Van Spriel


On 20-9-2016 16:36, Luca Coelho wrote:
> Hi Arend,
> 
> On Tue, 2016-09-20 at 14:29 +0200, Arend Van Spriel wrote:
>> On 20-9-2016 13:45, Beker, Ayala wrote:
>>> I don't think there is something in common to those interface types
>>> that can fit such a function semantically, so I decided not to
>>> change it.
>>> Do you have any idea?
>>
>> What is common is that these are both non-netdev interface types.
> 
> I tend to agree with you.  I also thought about an
> ieee80211_has_netdev() function for this, but I didn't check whether
> this was exactly what we need...

Maybe it does not fit all instances, but quite a few checks are there to
skip netdev related stuff.

> In any case, do you mind if we address this in a separate patch?

Fine by me.

Regards,
Arend

> --
> Cheers,
> Luca.
> 


Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-20 Thread Luca Coelho
Hi Arend,

On Tue, 2016-09-20 at 14:29 +0200, Arend Van Spriel wrote:
> On 20-9-2016 13:45, Beker, Ayala wrote:
> > I don't think there is something in common to those interface types
> > that can fit such a function semantically, so I decided not to
> > change it.
> > Do you have any idea?
> 
> What is common is that these are both non-netdev interface types.

I tend to agree with you.  I also thought about an
ieee80211_has_netdev() function for this, but I didn't check whether
this was exactly what we need...

In any case, do you mind if we address this in a separate patch?

--
Cheers,
Luca.


Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-20 Thread Arend Van Spriel
On 20-9-2016 13:45, Beker, Ayala wrote:
> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com] 
> Sent: Sunday, September 18, 2016 22:01
> To: Otcheretianski, Andrei <andrei.otcheretian...@intel.com>; Luca Coelho 
> <l...@coelho.fi>; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala <ayala.be...@intel.com>; 
> Grumbach, Emmanuel <emmanuel.grumb...@intel.com>; Coelho, Luciano 
> <luciano.coe...@intel.com>
> Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop 
> NAN
> 
> On 18-9-2016 9:59, Otcheretianski, Andrei wrote:
>>> -Original Message-
>>> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
>>> Sent: Friday, September 16, 2016 14:09
>>> To: Luca Coelho <l...@coelho.fi>; johan...@sipsolutions.net
>>> Cc: linux-wireless@vger.kernel.org; Beker, Ayala 
>>> <ayala.be...@intel.com>; Otcheretianski, Andrei 
>>> <andrei.otcheretian...@intel.com>; Grumbach, Emmanuel 
>>> <emmanuel.grumb...@intel.com>; Coelho, Luciano 
>>> <luciano.coe...@intel.com>
>>> Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start 
>>> / stop NAN
>>>
>>> On 16-9-2016 10:33, Luca Coelho wrote:
>>>> From: Ayala Beker <ayala.be...@intel.com>
>>>>
>>>> This code doesn't do much besides allowing to start and stop the vif.
>>>>
>>>> Signed-off-by: Andrei Otcheretianski 
>>>> <andrei.otcheretian...@intel.com>
>>>> Signed-off-by: Emmanuel Grumbach <emmanuel.grumb...@intel.com>
>>>> Signed-off-by: Ayala Beker <ayala.be...@intel.com>
>>>> Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
>>>> ---
>>>>  include/net/mac80211.h|  9 +
>>>>  net/mac80211/cfg.c| 36 ++
>>>>  net/mac80211/chan.c   |  3 +++
>>>>  net/mac80211/driver-ops.h | 29 ++-
>>>>  net/mac80211/iface.c  |  8 ++--
>>>>  net/mac80211/main.c   |  5 +
>>>>  net/mac80211/offchannel.c |  3 ++-
>>>>  net/mac80211/trace.h  | 50
>>> +++
>>>>  net/mac80211/util.c   |  3 ++-
>>>>  9 files changed, 141 insertions(+), 5 deletions(-)
>>>
>>> [...]
>>>
>>>> diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h 
>>>> index fe35a1c..67b42c8 100644
>>>> --- a/net/mac80211/driver-ops.h
>>>> +++ b/net/mac80211/driver-ops.h
>>>> @@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct 
>>>> ieee80211_local *local,
>>>>
>>>>if (WARN_ON_ONCE(sdata->vif.type ==
>>> NL80211_IFTYPE_P2P_DEVICE ||
>>>> (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
>>>> -!sdata->vif.mu_mimo_owner)))
>>>> +!sdata->vif.mu_mimo_owner) ||
>>>> +   sdata->vif.type == NL80211_IFTYPE_NAN))
>>>
>>> Might be more clear to move this up right after P2P_DEVICE check.
>>
>> Why? It's a completely separate new condition - so it goes to the end.
> 
>> I would say readability. Both P2P_DEVICE and NAN checks are single 
>> comparisons as opposed to the MONITOR check.
> 
>>>
>>>>return;
>>>>
>>>>if (!check_sdata_in_driver(sdata)) @@ -1165,4 +1166,30 @@ static 
>>>> inline void drv_wake_tx_queue(struct
>>> ieee80211_local *local,
>>>>local->ops->wake_tx_queue(>hw, >txq);  }
>>>>
>>>> +static inline int drv_start_nan(struct ieee80211_local *local,
>>>> +  struct ieee80211_sub_if_data *sdata,
>>>> +  struct cfg80211_nan_conf *conf) {
>>>> +  int ret;
>>>> +
>>>> +  might_sleep();
>>>> +  check_sdata_in_driver(sdata);
>>>> +
>>>> +  trace_drv_start_nan(local, sdata, conf);
>>>> +  ret = local->ops->start_nan(>hw, >vif, conf);
>>>> +  trace_drv_return_int(local, ret);
>>>> +  return ret;
>>>> +}
>>>> +
>>>> +static inline void drv_stop_nan(struct ieee80211_local *local,
>>>> +  struct ieee80211_sub_if_data *sdata) {
>>>> +  might_sleep();
>>

RE: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-20 Thread Beker, Ayala
-Original Message-
From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com] 
Sent: Sunday, September 18, 2016 22:01
To: Otcheretianski, Andrei <andrei.otcheretian...@intel.com>; Luca Coelho 
<l...@coelho.fi>; johan...@sipsolutions.net
Cc: linux-wireless@vger.kernel.org; Beker, Ayala <ayala.be...@intel.com>; 
Grumbach, Emmanuel <emmanuel.grumb...@intel.com>; Coelho, Luciano 
<luciano.coe...@intel.com>
Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

On 18-9-2016 9:59, Otcheretianski, Andrei wrote:
>> -Original Message-
>> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
>> Sent: Friday, September 16, 2016 14:09
>> To: Luca Coelho <l...@coelho.fi>; johan...@sipsolutions.net
>> Cc: linux-wireless@vger.kernel.org; Beker, Ayala 
>> <ayala.be...@intel.com>; Otcheretianski, Andrei 
>> <andrei.otcheretian...@intel.com>; Grumbach, Emmanuel 
>> <emmanuel.grumb...@intel.com>; Coelho, Luciano 
>> <luciano.coe...@intel.com>
>> Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start 
>> / stop NAN
>>
>> On 16-9-2016 10:33, Luca Coelho wrote:
>>> From: Ayala Beker <ayala.be...@intel.com>
>>>
>>> This code doesn't do much besides allowing to start and stop the vif.
>>>
>>> Signed-off-by: Andrei Otcheretianski 
>>> <andrei.otcheretian...@intel.com>
>>> Signed-off-by: Emmanuel Grumbach <emmanuel.grumb...@intel.com>
>>> Signed-off-by: Ayala Beker <ayala.be...@intel.com>
>>> Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
>>> ---
>>>  include/net/mac80211.h|  9 +
>>>  net/mac80211/cfg.c| 36 ++
>>>  net/mac80211/chan.c   |  3 +++
>>>  net/mac80211/driver-ops.h | 29 ++-
>>>  net/mac80211/iface.c  |  8 ++--
>>>  net/mac80211/main.c   |  5 +
>>>  net/mac80211/offchannel.c |  3 ++-
>>>  net/mac80211/trace.h  | 50
>> +++
>>>  net/mac80211/util.c   |  3 ++-
>>>  9 files changed, 141 insertions(+), 5 deletions(-)
>>
>> [...]
>>
>>> diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h 
>>> index fe35a1c..67b42c8 100644
>>> --- a/net/mac80211/driver-ops.h
>>> +++ b/net/mac80211/driver-ops.h
>>> @@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct 
>>> ieee80211_local *local,
>>>
>>> if (WARN_ON_ONCE(sdata->vif.type ==
>> NL80211_IFTYPE_P2P_DEVICE ||
>>>  (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
>>> - !sdata->vif.mu_mimo_owner)))
>>> + !sdata->vif.mu_mimo_owner) ||
>>> +sdata->vif.type == NL80211_IFTYPE_NAN))
>>
>> Might be more clear to move this up right after P2P_DEVICE check.
> 
> Why? It's a completely separate new condition - so it goes to the end.

> I would say readability. Both P2P_DEVICE and NAN checks are single 
> comparisons as opposed to the MONITOR check.

>>
>>> return;
>>>
>>> if (!check_sdata_in_driver(sdata)) @@ -1165,4 +1166,30 @@ static 
>>> inline void drv_wake_tx_queue(struct
>> ieee80211_local *local,
>>> local->ops->wake_tx_queue(>hw, >txq);  }
>>>
>>> +static inline int drv_start_nan(struct ieee80211_local *local,
>>> +   struct ieee80211_sub_if_data *sdata,
>>> +   struct cfg80211_nan_conf *conf) {
>>> +   int ret;
>>> +
>>> +   might_sleep();
>>> +   check_sdata_in_driver(sdata);
>>> +
>>> +   trace_drv_start_nan(local, sdata, conf);
>>> +   ret = local->ops->start_nan(>hw, >vif, conf);
>>> +   trace_drv_return_int(local, ret);
>>> +   return ret;
>>> +}
>>> +
>>> +static inline void drv_stop_nan(struct ieee80211_local *local,
>>> +   struct ieee80211_sub_if_data *sdata) {
>>> +   might_sleep();
>>> +   check_sdata_in_driver(sdata);
>>> +
>>> +   trace_drv_stop_nan(local, sdata);
>>> +   local->ops->stop_nan(>hw, >vif);
>>> +   trace_drv_return_void(local);
>>> +}
>>> +
>>>  #endif /* __MAC80211_DRIVER_OPS */
>>> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 
>>> e694ca2..507f46a 100644
>>>

Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-18 Thread Arend Van Spriel
On 18-9-2016 9:59, Otcheretianski, Andrei wrote:
>> -Original Message-
>> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
>> Sent: Friday, September 16, 2016 14:09
>> To: Luca Coelho <l...@coelho.fi>; johan...@sipsolutions.net
>> Cc: linux-wireless@vger.kernel.org; Beker, Ayala <ayala.be...@intel.com>;
>> Otcheretianski, Andrei <andrei.otcheretian...@intel.com>; Grumbach,
>> Emmanuel <emmanuel.grumb...@intel.com>; Coelho, Luciano
>> <luciano.coe...@intel.com>
>> Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop
>> NAN
>>
>> On 16-9-2016 10:33, Luca Coelho wrote:
>>> From: Ayala Beker <ayala.be...@intel.com>
>>>
>>> This code doesn't do much besides allowing to start and stop the vif.
>>>
>>> Signed-off-by: Andrei Otcheretianski <andrei.otcheretian...@intel.com>
>>> Signed-off-by: Emmanuel Grumbach <emmanuel.grumb...@intel.com>
>>> Signed-off-by: Ayala Beker <ayala.be...@intel.com>
>>> Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
>>> ---
>>>  include/net/mac80211.h|  9 +
>>>  net/mac80211/cfg.c| 36 ++
>>>  net/mac80211/chan.c   |  3 +++
>>>  net/mac80211/driver-ops.h | 29 ++-
>>>  net/mac80211/iface.c  |  8 ++--
>>>  net/mac80211/main.c   |  5 +
>>>  net/mac80211/offchannel.c |  3 ++-
>>>  net/mac80211/trace.h  | 50
>> +++
>>>  net/mac80211/util.c   |  3 ++-
>>>  9 files changed, 141 insertions(+), 5 deletions(-)
>>
>> [...]
>>
>>> diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
>>> index fe35a1c..67b42c8 100644
>>> --- a/net/mac80211/driver-ops.h
>>> +++ b/net/mac80211/driver-ops.h
>>> @@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct
>>> ieee80211_local *local,
>>>
>>> if (WARN_ON_ONCE(sdata->vif.type ==
>> NL80211_IFTYPE_P2P_DEVICE ||
>>>  (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
>>> - !sdata->vif.mu_mimo_owner)))
>>> + !sdata->vif.mu_mimo_owner) ||
>>> +sdata->vif.type == NL80211_IFTYPE_NAN))
>>
>> Might be more clear to move this up right after P2P_DEVICE check.
> 
> Why? It's a completely separate new condition - so it goes to the end.

I would say readability. Both P2P_DEVICE and NAN checks are single
comparisons as opposed to the MONITOR check.

>>
>>> return;
>>>
>>> if (!check_sdata_in_driver(sdata))
>>> @@ -1165,4 +1166,30 @@ static inline void drv_wake_tx_queue(struct
>> ieee80211_local *local,
>>> local->ops->wake_tx_queue(>hw, >txq);  }
>>>
>>> +static inline int drv_start_nan(struct ieee80211_local *local,
>>> +   struct ieee80211_sub_if_data *sdata,
>>> +   struct cfg80211_nan_conf *conf)
>>> +{
>>> +   int ret;
>>> +
>>> +   might_sleep();
>>> +   check_sdata_in_driver(sdata);
>>> +
>>> +   trace_drv_start_nan(local, sdata, conf);
>>> +   ret = local->ops->start_nan(>hw, >vif, conf);
>>> +   trace_drv_return_int(local, ret);
>>> +   return ret;
>>> +}
>>> +
>>> +static inline void drv_stop_nan(struct ieee80211_local *local,
>>> +   struct ieee80211_sub_if_data *sdata) {
>>> +   might_sleep();
>>> +   check_sdata_in_driver(sdata);
>>> +
>>> +   trace_drv_stop_nan(local, sdata);
>>> +   local->ops->stop_nan(>hw, >vif);
>>> +   trace_drv_return_void(local);
>>> +}
>>> +
>>>  #endif /* __MAC80211_DRIVER_OPS */
>>> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index
>>> e694ca2..507f46a 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,
>>> int n_queues = sdata->local->hw.queues;
>>> int i;
>>>
>>> +   if (iftype == NL80211_IFTYPE_NAN)
>>> +   return 0;
>>> +
>>> if (iftype != NL80211_IFTYPE_P2P_DEVICE) {
>>> for (i = 0; i < IEEE80211_NUM_ACS; i++) {
>>> if (WARN_ON_ONCE(sdata->vif.hw_queue[i] == @@
>> -647,7 +650,8 @@ int
>>> ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
>>> local->fif_probe_req++;
>>> }
>>>
>>> -   if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
>>> +   if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
>>> +   sdata->vif.type != NL80211_IFTYPE_NAN)
>>
>> similar check keeps reoccuring in various places so maybe we can create a
>> helper function for it.
> 
> Right, but not sure that it deserves a function.

If similar new iftypes are anticipated it would make sense as it would
mean adding it in one place.

Regards,
Arend


RE: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-18 Thread Otcheretianski, Andrei
> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
> Sent: Friday, September 16, 2016 14:09
> To: Luca Coelho <l...@coelho.fi>; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala <ayala.be...@intel.com>;
> Otcheretianski, Andrei <andrei.otcheretian...@intel.com>; Grumbach,
> Emmanuel <emmanuel.grumb...@intel.com>; Coelho, Luciano
> <luciano.coe...@intel.com>
> Subject: Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop
> NAN
> 
> On 16-9-2016 10:33, Luca Coelho wrote:
> > From: Ayala Beker <ayala.be...@intel.com>
> >
> > This code doesn't do much besides allowing to start and stop the vif.
> >
> > Signed-off-by: Andrei Otcheretianski <andrei.otcheretian...@intel.com>
> > Signed-off-by: Emmanuel Grumbach <emmanuel.grumb...@intel.com>
> > Signed-off-by: Ayala Beker <ayala.be...@intel.com>
> > Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
> > ---
> >  include/net/mac80211.h|  9 +
> >  net/mac80211/cfg.c| 36 ++
> >  net/mac80211/chan.c   |  3 +++
> >  net/mac80211/driver-ops.h | 29 ++-
> >  net/mac80211/iface.c  |  8 ++--
> >  net/mac80211/main.c   |  5 +
> >  net/mac80211/offchannel.c |  3 ++-
> >  net/mac80211/trace.h  | 50
> +++
> >  net/mac80211/util.c   |  3 ++-
> >  9 files changed, 141 insertions(+), 5 deletions(-)
> 
> [...]
> 
> > diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
> > index fe35a1c..67b42c8 100644
> > --- a/net/mac80211/driver-ops.h
> > +++ b/net/mac80211/driver-ops.h
> > @@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct
> > ieee80211_local *local,
> >
> > if (WARN_ON_ONCE(sdata->vif.type ==
> NL80211_IFTYPE_P2P_DEVICE ||
> >  (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
> > - !sdata->vif.mu_mimo_owner)))
> > + !sdata->vif.mu_mimo_owner) ||
> > +sdata->vif.type == NL80211_IFTYPE_NAN))
> 
> Might be more clear to move this up right after P2P_DEVICE check.

Why? It's a completely separate new condition - so it goes to the end.

> 
> > return;
> >
> > if (!check_sdata_in_driver(sdata))
> > @@ -1165,4 +1166,30 @@ static inline void drv_wake_tx_queue(struct
> ieee80211_local *local,
> > local->ops->wake_tx_queue(>hw, >txq);  }
> >
> > +static inline int drv_start_nan(struct ieee80211_local *local,
> > +   struct ieee80211_sub_if_data *sdata,
> > +   struct cfg80211_nan_conf *conf)
> > +{
> > +   int ret;
> > +
> > +   might_sleep();
> > +   check_sdata_in_driver(sdata);
> > +
> > +   trace_drv_start_nan(local, sdata, conf);
> > +   ret = local->ops->start_nan(>hw, >vif, conf);
> > +   trace_drv_return_int(local, ret);
> > +   return ret;
> > +}
> > +
> > +static inline void drv_stop_nan(struct ieee80211_local *local,
> > +   struct ieee80211_sub_if_data *sdata) {
> > +   might_sleep();
> > +   check_sdata_in_driver(sdata);
> > +
> > +   trace_drv_stop_nan(local, sdata);
> > +   local->ops->stop_nan(>hw, >vif);
> > +   trace_drv_return_void(local);
> > +}
> > +
> >  #endif /* __MAC80211_DRIVER_OPS */
> > diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index
> > e694ca2..507f46a 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,
> > int n_queues = sdata->local->hw.queues;
> > int i;
> >
> > +   if (iftype == NL80211_IFTYPE_NAN)
> > +   return 0;
> > +
> > if (iftype != NL80211_IFTYPE_P2P_DEVICE) {
> > for (i = 0; i < IEEE80211_NUM_ACS; i++) {
> > if (WARN_ON_ONCE(sdata->vif.hw_queue[i] == @@
> -647,7 +650,8 @@ int
> > ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
> > local->fif_probe_req++;
> > }
> >
> > -   if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
> > +   if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
> > +   sdata->vif.type != NL80211_IFTYPE_NAN)
> 
> similar check keeps reoccuring in various places so maybe we can create a
> helper function for it.

Right, but not sure that it deserves a function.

> 
> > changed |= ieee80211_reset_erp_info(sdata);
> > ieee80211_bss_info_change_notify(sdata, changed);
> >
> 
> Regards,
> Arend


Re: [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

2016-09-16 Thread Arend Van Spriel
On 16-9-2016 10:33, Luca Coelho wrote:
> From: Ayala Beker 
> 
> This code doesn't do much besides allowing to start and
> stop the vif.
> 
> Signed-off-by: Andrei Otcheretianski 
> Signed-off-by: Emmanuel Grumbach 
> Signed-off-by: Ayala Beker 
> Signed-off-by: Luca Coelho 
> ---
>  include/net/mac80211.h|  9 +
>  net/mac80211/cfg.c| 36 ++
>  net/mac80211/chan.c   |  3 +++
>  net/mac80211/driver-ops.h | 29 ++-
>  net/mac80211/iface.c  |  8 ++--
>  net/mac80211/main.c   |  5 +
>  net/mac80211/offchannel.c |  3 ++-
>  net/mac80211/trace.h  | 50 
> +++
>  net/mac80211/util.c   |  3 ++-
>  9 files changed, 141 insertions(+), 5 deletions(-)

[...]

> diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
> index fe35a1c..67b42c8 100644
> --- a/net/mac80211/driver-ops.h
> +++ b/net/mac80211/driver-ops.h
> @@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct 
> ieee80211_local *local,
>  
>   if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
>(sdata->vif.type == NL80211_IFTYPE_MONITOR &&
> -   !sdata->vif.mu_mimo_owner)))
> +   !sdata->vif.mu_mimo_owner) ||
> +  sdata->vif.type == NL80211_IFTYPE_NAN))

Might be more clear to move this up right after P2P_DEVICE check.

>   return;
>  
>   if (!check_sdata_in_driver(sdata))
> @@ -1165,4 +1166,30 @@ static inline void drv_wake_tx_queue(struct 
> ieee80211_local *local,
>   local->ops->wake_tx_queue(>hw, >txq);
>  }
>  
> +static inline int drv_start_nan(struct ieee80211_local *local,
> + struct ieee80211_sub_if_data *sdata,
> + struct cfg80211_nan_conf *conf)
> +{
> + int ret;
> +
> + might_sleep();
> + check_sdata_in_driver(sdata);
> +
> + trace_drv_start_nan(local, sdata, conf);
> + ret = local->ops->start_nan(>hw, >vif, conf);
> + trace_drv_return_int(local, ret);
> + return ret;
> +}
> +
> +static inline void drv_stop_nan(struct ieee80211_local *local,
> + struct ieee80211_sub_if_data *sdata)
> +{
> + might_sleep();
> + check_sdata_in_driver(sdata);
> +
> + trace_drv_stop_nan(local, sdata);
> + local->ops->stop_nan(>hw, >vif);
> + trace_drv_return_void(local);
> +}
> +
>  #endif /* __MAC80211_DRIVER_OPS */
> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
> index e694ca2..507f46a 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,
>   int n_queues = sdata->local->hw.queues;
>   int i;
>  
> + if (iftype == NL80211_IFTYPE_NAN)
> + return 0;
> +
>   if (iftype != NL80211_IFTYPE_P2P_DEVICE) {
>   for (i = 0; i < IEEE80211_NUM_ACS; i++) {
>   if (WARN_ON_ONCE(sdata->vif.hw_queue[i] ==
> @@ -647,7 +650,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool 
> coming_up)
>   local->fif_probe_req++;
>   }
>  
> - if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
> + if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
> + sdata->vif.type != NL80211_IFTYPE_NAN)

similar check keeps reoccuring in various places so maybe we can create
a helper function for it.

>   changed |= ieee80211_reset_erp_info(sdata);
>   ieee80211_bss_info_change_notify(sdata, changed);
>  

Regards,
Arend


[PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN

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

This code doesn't do much besides allowing to start and
stop the vif.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Ayala Beker 
Signed-off-by: Luca Coelho 
---
 include/net/mac80211.h|  9 +
 net/mac80211/cfg.c| 36 ++
 net/mac80211/chan.c   |  3 +++
 net/mac80211/driver-ops.h | 29 ++-
 net/mac80211/iface.c  |  8 ++--
 net/mac80211/main.c   |  5 +
 net/mac80211/offchannel.c |  3 ++-
 net/mac80211/trace.h  | 50 +++
 net/mac80211/util.c   |  3 ++-
 9 files changed, 141 insertions(+), 5 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5296100..df9b5cf 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3420,6 +3420,9 @@ enum ieee80211_reconfig_type {
  * synchronization which is needed in case driver has in its RSS queues
  * pending frames that were received prior to the control path action
  * currently taken (e.g. disassociation) but are not processed yet.
+ *
+ * @start_nan: join an existing NAN cluster, or create a new one.
+ * @stop_nan: leave the NAN cluster.
  */
 struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3655,6 +3658,12 @@ struct ieee80211_ops {
void (*wake_tx_queue)(struct ieee80211_hw *hw,
  struct ieee80211_txq *txq);
void (*sync_rx_queues)(struct ieee80211_hw *hw);
+
+   int (*start_nan)(struct ieee80211_hw *hw,
+struct ieee80211_vif *vif,
+struct cfg80211_nan_conf *conf);
+   int (*stop_nan)(struct ieee80211_hw *hw,
+   struct ieee80211_vif *vif);
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a74027f..9aabb09 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2006-2010 Johannes Berg 
  * Copyright 2013-2015  Intel Mobile Communications GmbH
+ * Copyright (C) 2015-2016 Intel Deutschland GmbH
  *
  * This file is GPLv2 as found in COPYING.
  */
@@ -152,6 +153,39 @@ static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
 }
 
+static int ieee80211_start_nan(struct wiphy *wiphy,
+  struct wireless_dev *wdev,
+  struct cfg80211_nan_conf *conf)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+   int ret;
+
+   mutex_lock(>local->chanctx_mtx);
+   ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
+   mutex_unlock(>local->chanctx_mtx);
+   if (ret < 0)
+   return ret;
+
+   ret = ieee80211_do_open(wdev, true);
+   if (ret)
+   return ret;
+
+   ret = drv_start_nan(sdata->local, sdata, conf);
+   if (ret)
+   ieee80211_sdata_stop(sdata);
+
+   return ret;
+}
+
+static void ieee80211_stop_nan(struct wiphy *wiphy,
+  struct wireless_dev *wdev)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+
+   drv_stop_nan(sdata->local, sdata);
+   ieee80211_sdata_stop(sdata);
+}
+
 static int ieee80211_set_noack_map(struct wiphy *wiphy,
  struct net_device *dev,
  u16 noack_map)
@@ -3464,4 +3498,6 @@ const struct cfg80211_ops mac80211_config_ops = {
.set_ap_chanwidth = ieee80211_set_ap_chanwidth,
.add_tx_ts = ieee80211_add_tx_ts,
.del_tx_ts = ieee80211_del_tx_ts,
+   .start_nan = ieee80211_start_nan,
+   .stop_nan = ieee80211_stop_nan,
 };
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index acb50f8..e4d147e 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,
struct ieee80211_chanctx *curr_ctx = NULL;
int ret = 0;
 
+   if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_NAN))
+   return -ENOTSUPP;
+
conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
 lockdep_is_held(>chanctx_mtx));
 
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index fe35a1c..67b42c8 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -163,7 +163,8 @@ static inline void drv_bss_info_changed(struct 
ieee80211_local *local,
 
if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
- !sdata->vif.mu_mimo_owner)))
+ !sdata->vif.mu_mimo_owner) ||
+