1 /** @file mlan_11k.h
2  *
3  *  @brief Interface for the BTM module implemented in mlan_11k.c
4  *
5  *  Driver interface functions and type declarations for the process RRM data
6  *    module implemented in mlan_11k.c.
7  *
8  *  Copyright 2022-2024 NXP
9  *
10  *  SPDX-License-Identifier: BSD-3-Clause
11  *
12  */
13 
14 /********************************************************
15 Change log:
16     08/24/2022: initial version
17 ********************************************************/
18 
19 #ifndef _MLAN_11K_H_
20 #define _MLAN_11K_H_
21 
22 #if CONFIG_11K
23 /* Link Measurement Request frame */
24 typedef MLAN_PACK_START struct _mgmt_rrm_link_meas_request
25 {
26     t_u8 dialog_tok;
27     /* Transmit power used to transmit the frame containing the Link Measurement Request */
28     t_s8 tx_power;
29     /* The upper limit on the transmit power */
30     t_s8 max_tx_power;
31     t_u8 variable[1];
32 } MLAN_PACK_END mgmt_rrm_link_meas_request;
33 
34 /* Link Measurement Report frame */
35 typedef MLAN_PACK_START struct _mgmt_rrm_link_meas_report
36 {
37     t_u8 dialog_tok;
38     /* Transmit power and link margin information */
39     IEEEtypes_TPCReport_t tpc_report;
40     /* Receive Antenna ID */
41     t_u8 rx_ant_id;
42     /* Transmit Antenna ID */
43     t_u8 tx_ant_id;
44     /* Received channel power indicator in a dBm scale */
45     t_u8 rcpi;
46     /* Received signal to noise indicator in a dBm scale */
47     t_u8 rsni;
48     t_u8 variable[1];
49 } MLAN_PACK_END mgmt_rrm_link_meas_report;
50 
51 /* Measurement Request element */
52 typedef MLAN_PACK_START struct _mgmt_rrm_radio_meas_request
53 {
54     /* Element ID */
55     t_u8 ele_id;
56     /* Length */
57     t_u8 length;
58     /* Measurement Token */
59     t_u8 token;
60     /* Measurement Request Mode */
61     t_u8 mode;
62     /* Measurement Type */
63     t_u8 type;
64     /* Measurement Request */
65     t_u8 variable[1];
66 } MLAN_PACK_END mgmt_rrm_radio_meas_request;
67 
68 /* Beacon request */
69 typedef MLAN_PACK_START struct _mgmt_rrm_meas_beacon_request
70 {
71     /* Operating Class */
72     t_u8 oper_class;
73     /* Channel Number */
74     t_u8 channel;
75     /* Randomization Interval (in TUs) */
76     t_u16 rand_intv;
77     /* Measurement Duration (in TUs) */
78     t_u16 duration;
79     /* Measurement Mode */
80     t_u8 mode;
81     /* BSSID */
82     t_u8 bssid[IEEEtypes_ADDRESS_SIZE];
83     /* Optional Subelements */
84     t_u8 variable[1];
85 } MLAN_PACK_END mgmt_rrm_meas_beacon_request;
86 
87 /* Beacon report */
88 typedef MLAN_PACK_START struct _mgmt_rrm_meas_beacon_report
89 {
90     /* Operating Class */
91     t_u8 op_class;
92     /* Channel Number */
93     t_u8 channel;
94     /* Actual Measurement Start Time (in TSF of the BSS requesting the measurement) */
95     t_u64 m_start_time;
96     /* in TUs */
97     t_u16 duration;
98     /* Reported Frame Information */
99     t_u8 report_info;
100     /* Received channel power indicator in a dBm scale */
101     t_u8 rcpi;
102     /* Received signal to noise indicator in a dBm scale */
103     t_u8 rsni;
104     /* BSSID */
105     t_u8 bssid[IEEEtypes_ADDRESS_SIZE];
106     /* Antenna ID */
107     t_u8 ant_id;
108     /* Parent TSF */
109     t_u32 parent_tsf;
110     /* Optional Subelements */
111     t_u8 variable[1];
112 } MLAN_PACK_END mgmt_rrm_meas_beacon_report;
113 
114 /* Measurement requests type */
115 #define WLAN_RRM_MEASURE_TYPE_BEACON 5
116 
117 #ifndef BIT
118 #define BIT(x) (1 << (x))
119 #endif
120 
121 /* dot11PHYType */
122 enum wlan_phy_type
123 {
124     WLAN_PHY_TYPE_UNSPECIFIED = 0,
125     WLAN_PHY_TYPE_FHSS        = 1,
126     WLAN_PHY_TYPE_DSSS        = 2,
127     WLAN_PHY_TYPE_IRBASEBAND  = 3,
128     WLAN_PHY_TYPE_OFDM        = 4,
129     WLAN_PHY_TYPE_HRDSSS      = 5,
130     WLAN_PHY_TYPE_ERP         = 6,
131     WLAN_PHY_TYPE_HT          = 7,
132     WLAN_PHY_TYPE_DMG         = 8,
133     WLAN_PHY_TYPE_VHT         = 9,
134 };
135 
136 /* Measurement Mode of Beacon request */
137 enum wlan_rrm_beacon_report_mode
138 {
139     WLAN_RRM_MEASUREMENT_MODE_PASSIVE = 0,
140     WLAN_RRM_MEASUREMENT_MODE_ACTIVE  = 1,
141     WLAN_RRM_MEASUREMENT_MODE_TABLE   = 2,
142 };
143 
144 /* Beacon Request subelement IDs */
145 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_SSID             0
146 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_REPORTING_INFO   1
147 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_REPORTING_DETAIL 2
148 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_REQUEST          10
149 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_AP_CHANNEL       51
150 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_LAST_INDICATION  164
151 #define WLAN_RRM_BEACON_REQUEST_SUBELEMENT_VENDOR           221
152 
153 /* Measurement Report Mode field */
154 #define WLAN_RRM_REPORT_MODE_ACCEPT           0
155 #define WLAN_RRM_REPORT_MODE_REJECT_LATE      BIT(0)
156 #define WLAN_RRM_REPORT_MODE_REJECT_INCAPABLE BIT(1)
157 #define WLAN_RRM_REPORT_MODE_REJECT_REFUSED   BIT(2)
158 
159 /* Beacon report Subelement IDs */
160 #define WLAN_RRM_BEACON_REP_SUBELEM_FRAME_BODY             1
161 #define WLAN_RRM_BEACON_REP_SUBELEM_FRAME_BODY_FRAGMENT_ID 2
162 #define WLAN_RRM_BEACON_REP_SUBELEM_LAST_INDICATION        164
163 
164 #define WLAN_RRM_BEACON_REP_FRAME_BODY_FRAGMENT_SUB_LEN 4
165 #define WLAN_RRM_BEACON_REP_LAST_INDICATION_SUB_LEN     3
166 
167 /* Measurement Request Mode field */
168 #define WLAN_RRM_MEAS_REQUEST_MODE_PARALLEL           BIT(0)
169 #define WLAN_RRM_MEAS_REQUEST_MODE_ENABLE             BIT(1)
170 #define WLAN_RRM_MEAS_REQUEST_MODE_REQUEST            BIT(2)
171 #define WLAN_RRM_MEAS_REQUEST_MODE_REPORT             BIT(3)
172 #define WLAN_RRM_MEAS_REQUEST_MODE_DURATION_MANDATORY BIT(4)
173 
174 void wlan_process_radio_measurement_request(t_u8 *frame, t_u32 len, t_u8 *dest_addr, t_u8 *src_addr, bool protect);
175 void wlan_process_neighbor_report_response(t_u8 *frame, t_u32 len, t_u8 *dest_addr, t_u8 *src_addr, bool protect);
176 void wlan_process_link_measurement_request(
177     t_u8 *frame, t_u32 len, t_u8 *dest_addr, t_u8 *src_addr, bool protect, RxPD *rxpd);
178 void wlan_send_mgmt_rm_beacon_report(
179     t_u8 dialog_tok, t_u8 *src_addr, t_u8 *dst_addr, t_u8 *rep, t_u32 rep_len, bool protect);
180 void wlan_add_rm_beacon_report(wlan_rrm_beacon_report_data *rep_data,
181                                BSSDescriptor_t *bss_entry,
182                                t_u8 **buf_pos,
183                                t_s32 remained_len,
184                                t_u32 *pos_last_indication);
185 bool wlan_rrm_matched_ap_found(wlan_rrm_beacon_report_data *rep_data, BSSDescriptor_t *bss_entry);
186 
187 /** Add RRM Capabilities */
188 void wlan_dot11k_formatRrmCapabilities(IEEEtypes_RrmEnabledCapabilities_t *pRrmCapIe, t_u16 bcnInterval);
189 
190 /* send mgmt neighbor report request frame */
191 int wlan_send_mgmt_rm_neighbor_request(mlan_private *pmpriv, t_u8 *ssid, t_u8 ssid_len);
192 #endif /* CONFIG_11K */
193 
194 #endif /* !_MLAN_11K_H_ */
195