diff mbox series

[v3] wifi: cfg80211: call reg_notifier for self managed wiphy from driver hint

Message ID 20230201070327.27578-1-quic_wgong@quicinc.com (mailing list archive)
State Rejected
Delegated to: Johannes Berg
Headers show
Series [v3] wifi: cfg80211: call reg_notifier for self managed wiphy from driver hint | expand

Commit Message

Wen Gong Feb. 1, 2023, 7:03 a.m. UTC
Currently the regulatory driver does not call the regulatory callback
reg_notifier for self managed wiphys. Sometimes driver needs cfg80211
to calculate the info of ieee80211_channel such as flags and power,
and driver needs to get the info of ieee80211_channel after hint of
driver, but driver does not know when calculation of the info of
ieee80211_channel become finished, so add notify to driver in
reg_process_self_managed_hint() from cfg80211 is a good way, then
driver could get the correct info in callback of reg_notifier.

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
---
v3: use hole for BIT(24) which delete by commit 585b6e1304dc ("wifi: cfg80211: remove support for static WEP") 

v2:
   1. add flag WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER
   2. change to use reg_call_notifier()

 include/net/cfg80211.h | 4 ++++
 net/wireless/reg.c     | 3 +++
 2 files changed, 7 insertions(+)


base-commit: 922932ca02191a390f7f52fb6e21c44b50e14025
prerequisite-patch-id: e365a8f3f2dda71872409315b416797c771a6c51

Comments

Wen Gong Feb. 15, 2023, 6:10 a.m. UTC | #1
On 2/1/2023 3:03 PM, Wen Gong wrote:
> Currently the regulatory driver does not call the regulatory callback
> reg_notifier for self managed wiphys. Sometimes driver needs cfg80211
> to calculate the info of ieee80211_channel such as flags and power,
> and driver needs to get the info of ieee80211_channel after hint of
> driver, but driver does not know when calculation of the info of
> ieee80211_channel become finished, so add notify to driver in
> reg_process_self_managed_hint() from cfg80211 is a good way, then
> driver could get the correct info in callback of reg_notifier.
>
> Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
> ---
> v3: use hole for BIT(24) which delete by commit 585b6e1304dc ("wifi: cfg80211: remove support for static WEP")
Hi Johannes,

I see you have merged v2 to wireless-next.git and this v3's state is reject.
So do you mean we should not keep hole BIT 24 in enum wiphy_flags from 
now as well as
hole 11/12 in commit 8e8b41f9d8c8/ca986ad9bcd3?

If that, then backport this patch will be more complex, because the 
backport kernel already have
WIPHY_FLAG_HAS_STATIC_WEP= BIT(24), then firstly the backport kernel 
need backport other
patch(585b6e1304dc ("wifi: cfg80211: remove support for static WEP")) 
which is not really needed.
>
> v2:
>     1. add flag WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER
>     2. change to use reg_call_notifier()
>
>   include/net/cfg80211.h | 4 ++++
>   net/wireless/reg.c     | 3 +++
>   2 files changed, 7 insertions(+)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 1f8f827290a2..ef96fc5b060d 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -4682,6 +4682,8 @@ struct cfg80211_ops {
>    *	in order to not have them reachable in normal drivers, until we have
>    *	complete feature/interface combinations/etc. advertisement. No driver
>    *	should set this flag for now.
> + * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
> + *	NL80211_REGDOM_SET_BY_DRIVER.
>    */
>   enum wiphy_flags {
>   	WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK		= BIT(0),
> @@ -4707,6 +4709,8 @@ enum wiphy_flags {
>   	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(21),
>   	WIPHY_FLAG_SUPPORTS_5_10_MHZ		= BIT(22),
>   	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(23),
> +	/* use hole at 24 */
> +	WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER	= BIT(25),
>   };
>   
>   /**
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 4f3f31244e8b..cb35c8e9ced7 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -3198,6 +3198,9 @@ static void reg_process_self_managed_hint(struct wiphy *wiphy)
>   	request.alpha2[1] = regd->alpha2[1];
>   	request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
>   
> +	if (wiphy->flags & WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER)
> +		reg_call_notifier(wiphy, &request);
> +
>   	nl80211_send_wiphy_reg_change_event(&request);
>   }
>   
>
> base-commit: 922932ca02191a390f7f52fb6e21c44b50e14025
> prerequisite-patch-id: e365a8f3f2dda71872409315b416797c771a6c51
Johannes Berg Feb. 15, 2023, 7:31 a.m. UTC | #2
Hi Wen,

> I see you have merged v2 to wireless-next.git and this v3's state is reject.

Yeah. Actually, I saw v3 only after I merged v2, but then I saw what the
change was and figured that was unnecessary anyway.

> So do you mean we should not keep hole BIT 24 in enum wiphy_flags from 
> now as well as hole 11/12 in commit 8e8b41f9d8c8/ca986ad9bcd3?

Indeed. The point of the comment saying "use" was to actually, well,
_use_ the hole next time. I haven't really enforced that since I keep
forgetting (and we're nowhere near running out of bits), but yes, the
point is that you could even have used bit 11 or 12.

> If that, then backport this patch will be more complex, because the 
> backport kernel already have
> WIPHY_FLAG_HAS_STATIC_WEP= BIT(24), then firstly the backport kernel 
> need backport other
> patch(585b6e1304dc ("wifi: cfg80211: remove support for static WEP")) 
> which is not really needed.

I guess it could use another bit number (such as 11) in a backport, but
I don't see that this really _needs_ to be backported? And if you're
using backports to backport the whole wifi stack then this isn't even a
question since it all comes in backports.

johannes
Wen Gong Feb. 15, 2023, 8:04 a.m. UTC | #3
On 2/15/2023 3:31 PM, Johannes Berg wrote:
> Hi Wen,
>
>> I see you have merged v2 to wireless-next.git and this v3's state is reject.
> Yeah. Actually, I saw v3 only after I merged v2, but then I saw what the
> change was and figured that was unnecessary anyway.
>
>> So do you mean we should not keep hole BIT 24 in enum wiphy_flags from
>> now as well as hole 11/12 in commit 8e8b41f9d8c8/ca986ad9bcd3?
> Indeed. The point of the comment saying "use" was to actually, well,
> _use_ the hole next time. I haven't really enforced that since I keep
> forgetting (and we're nowhere near running out of bits), but yes, the
> point is that you could even have used bit 11 or 12.
>
>> If that, then backport this patch will be more complex, because the
>> backport kernel already have
>> WIPHY_FLAG_HAS_STATIC_WEP= BIT(24), then firstly the backport kernel
>> need backport other
>> patch(585b6e1304dc ("wifi: cfg80211: remove support for static WEP"))
>> which is not really needed.
> I guess it could use another bit number (such as 11) in a backport, but
> I don't see that this really _needs_ to be backported? And if you're
> using backports to backport the whole wifi stack then this isn't even a
> question since it all comes in backports.

If use another bit such as 11 while backport this patch, then it will 
easily lead mismatch/error

and increase difficulty of maintain code.

I need backport this patch soon.

> johannes
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1f8f827290a2..ef96fc5b060d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4682,6 +4682,8 @@  struct cfg80211_ops {
  *	in order to not have them reachable in normal drivers, until we have
  *	complete feature/interface combinations/etc. advertisement. No driver
  *	should set this flag for now.
+ * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
+ *	NL80211_REGDOM_SET_BY_DRIVER.
  */
 enum wiphy_flags {
 	WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK		= BIT(0),
@@ -4707,6 +4709,8 @@  enum wiphy_flags {
 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(21),
 	WIPHY_FLAG_SUPPORTS_5_10_MHZ		= BIT(22),
 	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(23),
+	/* use hole at 24 */
+	WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER	= BIT(25),
 };
 
 /**
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 4f3f31244e8b..cb35c8e9ced7 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -3198,6 +3198,9 @@  static void reg_process_self_managed_hint(struct wiphy *wiphy)
 	request.alpha2[1] = regd->alpha2[1];
 	request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
 
+	if (wiphy->flags & WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER)
+		reg_call_notifier(wiphy, &request);
+
 	nl80211_send_wiphy_reg_change_event(&request);
 }