Skip to contentSkip to conversation

wifi: ath11k: fix layout of scan_flags in struct scan_req_params

PATCH In review Nicolas Escande 3 participants 7 messages Feb 9, 2024 – Feb 14, 2024 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

v2 cover wifi: ath11k: fix layout of scan_flags in struct scan_req_params

As previously discussed in [1] we have a mismatch in struct scan_req_params between the bitfield scan_f_xxx & the scan_flags when used with WMI_SCAN_XXX values.

To fix the issue & prevent it from happenning again lets stop using & remove scan_flags altogether in the driver and only use the bitfield instead. That way even if the bitfield doesn't match the WMI_SCAN_XXX flags, the right value will still be sent through the wmi command to the firmware (see ath11k_wmi_copy_scan_event_cntrl_flags).

Questions:
- In the same rationale shouldn't we remove scan_events from the same struct ?
- The same goes for ath12k, should I send a seperate patch or respin a v3 with similar patches for ath12k ?

[1] https://lore.kernel.org/all/[email protected]/

v2:
- remove explicit uses of scan_flags with WMI_SCAN_XXX flags
- remove the underlying union of scan_flags to only leave the bitfield

Nicolas Escande (2):
wifi: ath11k: Do not directly use scan_flags in struct scan_req_params
wifi: ath11k: remove scan_flags union from struct scan_req_params

 drivers/net/wireless/ath/ath11k/mac.c |  6 +--
 drivers/net/wireless/ath/ath11k/wmi.c |  2 +-
 drivers/net/wireless/ath/ath11k/wmi.h | 55 ++++++++++++---------------
 3 files changed, 29 insertions(+), 34 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 wifi: ath11k: Do not directly use scan_flags in struct scan_req_params

As discussed in [1] lets not use WMI_SCAN_XXX defines in combination with scan_flags directly when setting scan params in struct scan_req_params but use the underlying bitfield. This bitfield is then converted to WMI_SCAN_XXX when filling the WMI command to send to the firmware.

[1] https://lore.kernel.org/all/[email protected]/

Tested-on: QCN9074 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

---
 drivers/net/wireless/ath/ath11k/mac.c | 6 +++---
 drivers/net/wireless/ath/ath11k/wmi.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +3 -3
index be04f823566f..7bf5d1068164 100644
@@ -4013,7 +4013,7 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw,
 			       req->ssids[i].ssid_len);
 		}
 	} else {
-		arg->scan_flags |= WMI_SCAN_FLAG_PASSIVE;
+		arg->scan_f_passive = 1;
 	}
 
 	if (req->n_channels) {
@@ -9252,8 +9252,8 @@ static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
 	arg->dwell_time_active = scan_time_msec;
 	arg->dwell_time_passive = scan_time_msec;
 	arg->max_scan_time = scan_time_msec;
-	arg->scan_flags |= WMI_SCAN_FLAG_PASSIVE;
-	arg->scan_flags |= WMI_SCAN_FILTER_PROBE_REQ;
+	arg->scan_f_passive = 1;
+	arg->scan_f_filter_prb_req = 1;
 	arg->burst_duration = duration;
 
 	ret = ath11k_start_scan(ar, arg);
drivers/net/wireless/ath/ath11k/wmi.c +1 -1
index 688ee20528a0..78c11025c21c 100644
@@ -2098,7 +2098,7 @@ void ath11k_wmi_start_scan_init(struct ath11k *ar,
 				  WMI_SCAN_EVENT_BSS_CHANNEL |
 				  WMI_SCAN_EVENT_FOREIGN_CHAN |
 				  WMI_SCAN_EVENT_DEQUEUED;
-	arg->scan_flags |= WMI_SCAN_CHAN_STAT_EVENT;
+	arg->scan_f_chan_stat_evnt = 1;
 
 	if (test_bit(WMI_TLV_SERVICE_PASSIVE_SCAN_START_TIME_ENHANCE,
 		     ar->ab->wmi_ab.svc_map))
Signature · 1 line
2.43.0
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] wifi: ath11k: Do not directly use scan_flags in struct scan_req_params

Quoted 10 lines · Nicolas Escande

As discussed in [1] lets not use WMI_SCAN_XXX defines in combination with scan_flags directly when setting scan params in struct scan_req_params but use the underlying bitfield. This bitfield is then converted to WMI_SCAN_XXX when filling the WMI command to send to the firmware.

[1] https://lore.kernel.org/all/[email protected]/

Tested-on: QCN9074 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

#3 lore raw

Re: [PATCH v2 1/2] wifi: ath11k: Do not directly use scan_flags in struct scan_req_params

In reply to Nicolas Escande
Quoted 5 lines · Nicolas Escande

As discussed in [1] lets not use WMI_SCAN_XXX defines in combination with scan_flags directly when setting scan params in struct scan_req_params but use the underlying bitfield. This bitfield is then converted to WMI_SCAN_XXX when filling the WMI command to send to the firmware.

Quoted 7 lines

[1] https://lore.kernel.org/all/[email protected]/

Tested-on: QCN9074 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

2 patches applied to ath-next branch of ath.git, thanks.

64493a7ff74b wifi: ath11k: Do not directly use scan_flags in struct scan_req_params 79ad70c6df0a wifi: ath11k: Remove scan_flags union from struct scan_req_params

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#4 lore raw

PATCH v2 2/2 wifi: ath11k: Remove scan_flags union from struct scan_req_params

In reply to Nicolas Escande

Now that we do not use scan_flags directly with WMI_SCAN_XXX macros anymore but only the bitfield scan_f_xxx, lets remove the scan_flags & the underlying union.

This will prevent further problems as some entries in the scan_f_xxx bitfield don't match their corresponding WMI_SCAN_XXX flags as seen in [1]

[1] https://lore.kernel.org/all/[email protected]/

---
 drivers/net/wireless/ath/ath11k/wmi.h | 55 ++++++++++++---------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.h +25 -30
index 6dcd14700570..bc7adf7f13fb 100644
@@ -3394,36 +3394,31 @@ struct scan_req_params {
 	u32 idle_time;
 	u32 max_scan_time;
 	u32 probe_delay;
-	union {
-		struct {
-			u32 scan_f_passive:1,
-			    scan_f_bcast_probe:1,
-			    scan_f_cck_rates:1,
-			    scan_f_ofdm_rates:1,
-			    scan_f_chan_stat_evnt:1,
-			    scan_f_filter_prb_req:1,
-			    scan_f_bypass_dfs_chn:1,
-			    scan_f_continue_on_err:1,
-			    scan_f_offchan_mgmt_tx:1,
-			    scan_f_offchan_data_tx:1,
-			    scan_f_promisc_mode:1,
-			    scan_f_capture_phy_err:1,
-			    scan_f_strict_passive_pch:1,
-			    scan_f_half_rate:1,
-			    scan_f_quarter_rate:1,
-			    scan_f_force_active_dfs_chn:1,
-			    scan_f_add_tpc_ie_in_probe:1,
-			    scan_f_add_ds_ie_in_probe:1,
-			    scan_f_add_spoofed_mac_in_probe:1,
-			    scan_f_add_rand_seq_in_probe:1,
-			    scan_f_en_ie_whitelist_in_probe:1,
-			    scan_f_forced:1,
-			    scan_f_2ghz:1,
-			    scan_f_5ghz:1,
-			    scan_f_80mhz:1;
-		};
-		u32 scan_flags;
-	};
+	u32 scan_f_passive:1,
+	    scan_f_bcast_probe:1,
+	    scan_f_cck_rates:1,
+	    scan_f_ofdm_rates:1,
+	    scan_f_chan_stat_evnt:1,
+	    scan_f_filter_prb_req:1,
+	    scan_f_bypass_dfs_chn:1,
+	    scan_f_continue_on_err:1,
+	    scan_f_offchan_mgmt_tx:1,
+	    scan_f_offchan_data_tx:1,
+	    scan_f_promisc_mode:1,
+	    scan_f_capture_phy_err:1,
+	    scan_f_strict_passive_pch:1,
+	    scan_f_half_rate:1,
+	    scan_f_quarter_rate:1,
+	    scan_f_force_active_dfs_chn:1,
+	    scan_f_add_tpc_ie_in_probe:1,
+	    scan_f_add_ds_ie_in_probe:1,
+	    scan_f_add_spoofed_mac_in_probe:1,
+	    scan_f_add_rand_seq_in_probe:1,
+	    scan_f_en_ie_whitelist_in_probe:1,
+	    scan_f_forced:1,
+	    scan_f_2ghz:1,
+	    scan_f_5ghz:1,
+	    scan_f_80mhz:1;
 	enum scan_dwelltime_adaptive_mode adaptive_dwell_time_mode;
 	u32 burst_duration;
 	u32 num_chan;
Signature · 1 line
2.43.0
Acked-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] wifi: ath11k: Remove scan_flags union from struct scan_req_params

Quoted 9 lines · Nicolas Escande

Now that we do not use scan_flags directly with WMI_SCAN_XXX macros anymore but only the bitfield scan_f_xxx, lets remove the scan_flags & the underlying union.

This will prevent further problems as some entries in the scan_f_xxx bitfield don't match their corresponding WMI_SCAN_XXX flags as seen in [1]

[1] https://lore.kernel.org/all/[email protected]/

#6 lore raw
In reply to Nicolas Escande
Quoted 4 lines · Nicolas Escande

As previously discussed in [1] we have a mismatch in struct scan_req_params between the bitfield scan_f_xxx & the scan_flags when used with WMI_SCAN_XXX values.

Quoted 8 lines

To fix the issue & prevent it from happenning again lets stop using & remove scan_flags altogether in the driver and only use the bitfield instead. That way even if the bitfield doesn't match the WMI_SCAN_XXX flags, the right value will still be sent through the wmi command to the firmware (see ath11k_wmi_copy_scan_event_cntrl_flags).

Questions:
- In the same rationale shouldn't we remove scan_events from the same struct ?

yes, scan_events is unused so it and the union+struct can be removed, leaving just the u32 bitfield. feel free to submit that as a separate patch

Quoted 2 lines

- The same goes for ath12k, should I send a seperate patch or respin a v3 with similar patches for ath12k ?

please send a separate series for ath12k since it has a separate mailing list

Quoted 7 lines

[1] https://lore.kernel.org/all/[email protected]/

v2:
- remove explicit uses of scan_flags with WMI_SCAN_XXX flags
- remove the underlying union of scan_flags to only leave the bitfield

Quoted 9 lines

Nicolas Escande (2):
wifi: ath11k: Do not directly use scan_flags in struct scan_req_params
wifi: ath11k: remove scan_flags union from struct scan_req_params

 drivers/net/wireless/ath/ath11k/mac.c |  6 +--
 drivers/net/wireless/ath/ath11k/wmi.c |  2 +-
 drivers/net/wireless/ath/ath11k/wmi.h | 55 ++++++++++++---------------
 3 files changed, 29 insertions(+), 34 deletions(-)

Thank you for this cleanup!

/jeff