diff mbox series

[v6,1/3] nl80211: Add support for beacon tx mode

Message ID 20220325055949.3035053-2-quic_mkenna@quicinc.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series Add support to configure beacon tx mode | expand

Commit Message

Maharaja Kennadyrajan March 25, 2022, 5:59 a.m. UTC
User can configure the below beacon tx mode
1. Staggered mode and 2. Burst mode while bring-up the AP
or MESH.

Beacons can be sent out in burst(continuously in a single shot
one after another) or staggered (equally spread out over beacon
interval) mode.

Set the beacon_tx_mode as 1 for Staggered mode and 2 for
burst mode.

Hence, added the support in the nl80211/cfg80211
layer to honour the beacon tx mode configuration and pass
this value to the driver.

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-00630-QCAHKSWPL_SILICONZ-2

Signed-off-by: Maharaja Kennadyrajan <quic_mkenna@quicinc.com>
---
V6: Addressed Jeff's comment on v5 patch.

V5: Addressed Johannes's & Felix's comments on v4 patch.

V4: Rebases on latest ath.git TOT.

V3: Addressed Johnson's comment on v2 patch.

V2: Addressed Johannes's comment on v1 patch.

 include/net/cfg80211.h       |  4 ++++
 include/uapi/linux/nl80211.h | 21 +++++++++++++++++++++
 net/wireless/nl80211.c       | 11 +++++++++++
 3 files changed, 36 insertions(+)

Comments

Sven Eckelmann March 25, 2022, 7:48 a.m. UTC | #1
On Friday, 25 March 2022 06:59:47 CET Maharaja Kennadyrajan wrote:
> @@ -5555,6 +5558,10 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
>         params->dtim_period =
>                 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
>  
> +       if (info->attrs[NL80211_ATTR_BEACON_TX_MODE])
> +               params->beacon_tx_mode =
> +                       nla_get_u32(info->attrs[NL80211_ATTR_BEACON_TX_MODE]);
> +
>         err = cfg80211_validate_beacon_int(rdev, dev->ieee80211_ptr->iftype,
>                                            params->beacon_interval);
>         if (err)

But why are you setting it by vif when it is actually a PHY setting? [1]


And there is also the open question from Felix [2]:

On Tuesday, 10 August 2021 16:33:41 CET Felix Fietkau wrote:
> It still seems to me like something that the driver should detect and
> handle internally without user configuration, based on number of VAPs
> and maybe multicast/beacon rate (since the packet duration issue will be
> worse with CCK rates).

Kind regards,
        Sven

[1] https://lore.kernel.org/all/2718995.X0rUDs3ZmB@ripper/
    https://lore.kernel.org/all/4581459.tLtf2NohVe@ripper/
    https://lore.kernel.org/all/6210385.n8AMQ0p90U@ripper/
    https://lore.kernel.org/all/4594028.WNQrFERZ9z@ripper/
[2] https://lore.kernel.org/all/92b48724-277c-fc48-a922-6b1d49cd6a71@nbd.name/
Jeff Johnson March 25, 2022, 7:18 p.m. UTC | #2
On 3/24/2022 10:59 PM, Maharaja Kennadyrajan wrote:
[...snip...]

> +/**
> + * enum nl80211_beacon_tx_mode - Beacon Tx Mode enum.
> + * @NL80211_BEACON_STAGGERED_MODE: Used to configure beacon tx mode as
> + *	staggered mode. This is the default beacon tx mode.

Documentation doesn't match the code. There is now a default mode, and 
that is, well, the default mode

> + * @NL80211_BEACON_BURST_MODE: Used to configure beacon tx mode as burst mode.
> + */
> +enum nl80211_beacon_tx_mode {
> +	NL80211_BEACON_DEFAULT_MODE = 0,
> +	NL80211_BEACON_STAGGERED_MODE = 1,
> +	NL80211_BEACON_BURST_MODE = 2,
> +};
> +
Kalle Valo March 26, 2022, 8:48 a.m. UTC | #3
Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 3/24/2022 10:59 PM, Maharaja Kennadyrajan wrote:
> [...snip...]
>
>> +/**
>> + * enum nl80211_beacon_tx_mode - Beacon Tx Mode enum.
>> + * @NL80211_BEACON_STAGGERED_MODE: Used to configure beacon tx mode as
>> + *	staggered mode. This is the default beacon tx mode.
>
> Documentation doesn't match the code. There is now a default mode, and
> that is, well, the default mode

But what does the default mode mean in this case? :) Please document in
detail what the driver is supposed to do in this mode.
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 68713388b617..4f4839ebcce6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1297,6 +1297,7 @@  struct cfg80211_unsol_bcast_probe_resp {
  * @fils_discovery: FILS discovery transmission parameters
  * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
  * @mbssid_config: AP settings for multiple bssid
+ * @beacon_tx_mode: Beacon Tx Mode setting
  */
 struct cfg80211_ap_settings {
 	struct cfg80211_chan_def chandef;
@@ -1330,6 +1331,7 @@  struct cfg80211_ap_settings {
 	struct cfg80211_fils_discovery fils_discovery;
 	struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
 	struct cfg80211_mbssid_config mbssid_config;
+	enum nl80211_beacon_tx_mode beacon_tx_mode;
 };
 
 /**
@@ -2211,6 +2213,7 @@  struct mesh_config {
  *	to operate on DFS channels.
  * @control_port_over_nl80211: TRUE if userspace expects to exchange control
  *	port frames over NL80211 instead of the network interface.
+ * @beacon_tx_mode: Beacon Tx Mode setting.
  *
  * These parameters are fixed when the mesh is created.
  */
@@ -2234,6 +2237,7 @@  struct mesh_setup {
 	struct cfg80211_bitrate_mask beacon_rate;
 	bool userspace_handles_dfs;
 	bool control_port_over_nl80211;
+	enum nl80211_beacon_tx_mode beacon_tx_mode;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 0568a79097b8..42712ffc6d16 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2663,6 +2663,13 @@  enum nl80211_commands {
  *	association request when used with NL80211_CMD_NEW_STATION). Can be set
  *	only if %NL80211_STA_FLAG_WME is set.
  *
+ * @NL80211_ATTR_BEACON_TX_MODE: used to configure the beacon tx mode (u32),
+ *	as specified in the &enum nl80211_beacon_tx_mode. The user-space
+ *	can use this attribute to configure the tx mode of beacons.
+ *	Beacons can be sent out in burst(continuously in a single shot
+ *	one after another) or staggered (equally spread out over beacon
+ *	interval) mode.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3175,6 +3182,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_EHT_CAPABILITY,
 
+	NL80211_ATTR_BEACON_TX_MODE,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -7600,4 +7609,16 @@  enum nl80211_ap_settings_flags {
 	NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT	= 1 << 1,
 };
 
+/**
+ * enum nl80211_beacon_tx_mode - Beacon Tx Mode enum.
+ * @NL80211_BEACON_STAGGERED_MODE: Used to configure beacon tx mode as
+ *	staggered mode. This is the default beacon tx mode.
+ * @NL80211_BEACON_BURST_MODE: Used to configure beacon tx mode as burst mode.
+ */
+enum nl80211_beacon_tx_mode {
+	NL80211_BEACON_DEFAULT_MODE = 0,
+	NL80211_BEACON_STAGGERED_MODE = 1,
+	NL80211_BEACON_BURST_MODE = 2,
+};
+
 #endif /* __LINUX_NL80211_H */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ee1c2b6b6971..ccb4b486da1e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -790,6 +790,9 @@  static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 		NLA_POLICY_RANGE(NLA_BINARY,
 				 NL80211_EHT_MIN_CAPABILITY_LEN,
 				 NL80211_EHT_MAX_CAPABILITY_LEN),
+	[NL80211_ATTR_BEACON_TX_MODE] =
+		NLA_POLICY_RANGE(NLA_U32, NL80211_BEACON_STAGGERED_MODE,
+				 NL80211_BEACON_BURST_MODE),
 };
 
 /* policy for the key attributes */
@@ -5555,6 +5558,10 @@  static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
 	params->dtim_period =
 		nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
 
+	if (info->attrs[NL80211_ATTR_BEACON_TX_MODE])
+		params->beacon_tx_mode =
+			nla_get_u32(info->attrs[NL80211_ATTR_BEACON_TX_MODE]);
+
 	err = cfg80211_validate_beacon_int(rdev, dev->ieee80211_ptr->iftype,
 					   params->beacon_interval);
 	if (err)
@@ -12235,6 +12242,10 @@  static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
 			return -EINVAL;
 	}
 
+	if (info->attrs[NL80211_ATTR_BEACON_TX_MODE])
+		setup.beacon_tx_mode =
+			nla_get_u32(info->attrs[NL80211_ATTR_BEACON_TX_MODE]);
+
 	if (info->attrs[NL80211_ATTR_MESH_SETUP]) {
 		/* parse additional setup parameters if given */
 		err = nl80211_parse_mesh_setup(info, &setup);