1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3 * Copyright (C) 2024-2025 Intel Corporation
4 */
5 #ifndef __iwl_mld_scan_h__
6 #define __iwl_mld_scan_h__
7
8 int iwl_mld_alloc_scan_cmd(struct iwl_mld *mld);
9
10 int iwl_mld_regular_scan_start(struct iwl_mld *mld, struct ieee80211_vif *vif,
11 struct cfg80211_scan_request *req,
12 struct ieee80211_scan_ies *ies);
13
14 void iwl_mld_int_mlo_scan(struct iwl_mld *mld, struct ieee80211_vif *vif);
15
16 void iwl_mld_handle_scan_iter_complete_notif(struct iwl_mld *mld,
17 struct iwl_rx_packet *pkt);
18
19 int iwl_mld_scan_stop(struct iwl_mld *mld, int type, bool notify);
20
21 int iwl_mld_sched_scan_start(struct iwl_mld *mld,
22 struct ieee80211_vif *vif,
23 struct cfg80211_sched_scan_request *req,
24 struct ieee80211_scan_ies *ies,
25 int type);
26
27 void iwl_mld_handle_match_found_notif(struct iwl_mld *mld,
28 struct iwl_rx_packet *pkt);
29
30 void iwl_mld_handle_scan_complete_notif(struct iwl_mld *mld,
31 struct iwl_rx_packet *pkt);
32
33 #define WFA_TPC_IE_LEN 9
34
iwl_mld_scan_max_template_size(void)35 static inline int iwl_mld_scan_max_template_size(void)
36 {
37 #define MAC_HDR_LEN 24
38 #define DS_IE_LEN 3
39 #define SSID_IE_LEN 2
40
41 /* driver create the 802.11 header, WFA TPC IE, DS parameter and SSID IE */
42 #define DRIVER_TOTAL_IES_LEN \
43 (MAC_HDR_LEN + WFA_TPC_IE_LEN + DS_IE_LEN + SSID_IE_LEN)
44
45 BUILD_BUG_ON(SCAN_OFFLOAD_PROBE_REQ_SIZE < DRIVER_TOTAL_IES_LEN);
46
47 return SCAN_OFFLOAD_PROBE_REQ_SIZE - DRIVER_TOTAL_IES_LEN;
48 }
49
50 void iwl_mld_report_scan_aborted(struct iwl_mld *mld);
51
52 enum iwl_mld_scan_status {
53 IWL_MLD_SCAN_NONE = 0,
54 IWL_MLD_SCAN_REGULAR = BIT(0),
55 IWL_MLD_SCAN_SCHED = BIT(1),
56 IWL_MLD_SCAN_NETDETECT = BIT(2),
57 IWL_MLD_SCAN_INT_MLO = BIT(3),
58 };
59
60 /* enum iwl_mld_pass_all_sched_results_states - Defines the states for
61 * handling/passing scheduled scan results to mac80211
62 * @SCHED_SCAN_PASS_ALL_STATE_DISABLED: Don't pass all scan results, only when
63 * a match found.
64 * @SCHED_SCAN_PASS_ALL_STATE_ENABLED: Pass all scan results is enabled
65 * (no filtering).
66 * @SCHED_SCAN_PASS_ALL_STATE_FOUND: A scan result is found, pass it on the
67 * next scan iteration complete notification.
68 */
69 enum iwl_mld_pass_all_sched_results_states {
70 SCHED_SCAN_PASS_ALL_STATE_DISABLED,
71 SCHED_SCAN_PASS_ALL_STATE_ENABLED,
72 SCHED_SCAN_PASS_ALL_STATE_FOUND,
73 };
74
75 /**
76 * enum iwl_mld_traffic_load - Levels of traffic load
77 *
78 * @IWL_MLD_TRAFFIC_LOW: low traffic load
79 * @IWL_MLD_TRAFFIC_MEDIUM: medium traffic load
80 * @IWL_MLD_TRAFFIC_HIGH: high traffic load
81 */
82 enum iwl_mld_traffic_load {
83 IWL_MLD_TRAFFIC_LOW,
84 IWL_MLD_TRAFFIC_MEDIUM,
85 IWL_MLD_TRAFFIC_HIGH,
86 };
87
88 /**
89 * struct iwl_mld_scan - Scan data
90 * @status: scan status, a combination of %enum iwl_mld_scan_status,
91 * reflects the %scan.uid_status array.
92 * @uid_status: array to track the scan status per uid.
93 * @start_tsf: start time of last scan in TSF of the link that requested
94 * the scan.
95 * @last_ebs_failed: true if the last EBS (Energy Based Scan) failed.
96 * @pass_all_sched_res: see %enum iwl_mld_pass_all_sched_results_states.
97 * @fw_link_id: the current (regular) scan fw link id, used by scan
98 * complete notif.
99 * @traffic_load: traffic load related data
100 * @traffic_load.last_stats_ts_usec: The timestamp of the last statistics
101 * notification, used to calculate the elapsed time between two
102 * notifications and determine the traffic load
103 * @traffic_load.status: The current traffic load status, see
104 * &enum iwl_mld_traffic_load
105 * @cmd_size: size of %cmd.
106 * @cmd: pointer to scan cmd buffer (allocated once in op mode start).
107 * @last_6ghz_passive_jiffies: stores the last 6GHz passive scan time
108 * in jiffies.
109 * @last_start_time_jiffies: stores the last start time in jiffies
110 * (interface up/reset/resume).
111 * @last_mlo_scan_time: start time of the last MLO scan in nanoseconds since
112 * boot.
113 */
114 struct iwl_mld_scan {
115 /* Add here fields that need clean up on restart */
116 struct_group(zeroed_on_hw_restart,
117 unsigned int status;
118 u32 uid_status[IWL_MAX_UMAC_SCANS];
119 u64 start_tsf;
120 bool last_ebs_failed;
121 enum iwl_mld_pass_all_sched_results_states pass_all_sched_res;
122 u8 fw_link_id;
123 struct {
124 u32 last_stats_ts_usec;
125 enum iwl_mld_traffic_load status;
126 } traffic_load;
127 );
128 /* And here fields that survive a fw restart */
129 size_t cmd_size;
130 void *cmd;
131 unsigned long last_6ghz_passive_jiffies;
132 unsigned long last_start_time_jiffies;
133 unsigned long last_mlo_scan_time;
134 };
135
136 #endif /* __iwl_mld_scan_h__ */
137