1 /* 2 * Copyright (c) 2011-2012, 2014-2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #if !defined(__RRMGLOBAL_H) 21 #define __RRMGLOBAL_H 22 23 /**========================================================================= 24 25 \file rrm_global.h 26 27 \brief Definitions for SME APIs 28 29 ========================================================================*/ 30 31 #define MAX_MEASUREMENT_REQUEST 5 32 #define MAX_NUM_CHANNELS 255 33 34 #define DEFAULT_RRM_IDX 0 35 36 typedef enum eRrmRetStatus { 37 eRRM_SUCCESS, 38 eRRM_INCAPABLE, 39 eRRM_REFUSED, 40 eRRM_FAILURE 41 } tRrmRetStatus; 42 43 typedef enum eRrmMsgReqSource { 44 eRRM_MSG_SOURCE_LEGACY_ESE = 1, /* legacy ese */ 45 eRRM_MSG_SOURCE_11K = 2, /* 11k */ 46 eRRM_MSG_SOURCE_ESE_UPLOAD = 3, /* ese upload approach */ 47 } tRrmMsgReqSource; 48 49 struct sir_channel_info { 50 uint8_t reg_class; 51 uint8_t chan_num; 52 uint32_t chan_freq; 53 }; 54 55 /** 56 * struct rrm_reporting - Contains info for rrm_ reporting IE present in 57 * channel load request received from AP 58 * @reporting_condition: reporting condition 59 * @threshold: threshold value to report channel load request 60 */ 61 struct rrm_reporting { 62 uint8_t reporting_condition; 63 uint8_t threshold; 64 }; 65 66 /** 67 * struct bw_ind_element - Contains info for Bandwidth Indication IE 68 * present in channel load request received from AP 69 * @is_bw_ind_element: to check Bandwidth Indication optional IE present 70 * @channel_width: channel width 71 * @ccfi0: center channel frequency index segment 0 72 * @ccfi1: center channel frequency index segment 1 73 * @center_freq: center freq segment for 320 MHz request 74 */ 75 struct bw_ind_element { 76 bool is_bw_ind_element; 77 uint8_t channel_width; 78 uint8_t ccfi0; 79 uint8_t ccfi1; 80 qdf_freq_t center_freq; 81 }; 82 83 /** 84 * struct wide_bw_chan_switch - Contains info for Wide Bandwidth Channel 85 * Switch IE present in channel load request received from AP 86 * @is_wide_bw_chan_switch: to check Bandwidth Indication optional IE present 87 * @channel_width: channel width 88 * @center_chan_freq0: center freq segment 0 for till 160 MHz request 89 * @center_chan_freq1: center freq segment 1 for till 160 MHz request 90 */ 91 struct wide_bw_chan_switch { 92 uint8_t is_wide_bw_chan_switch; 93 uint8_t channel_width; 94 uint8_t center_chan_freq0; 95 uint8_t center_chan_freq1; 96 }; 97 98 /** 99 * struct ch_load_ind - Contains info for channel load request received from AP 100 * @message_type: message type eWNI_SME_CHAN_LOAD_REQ_IND 101 * @length: size of struct chan_load_req_ind 102 * @measurement_idx: measurement index for channel load request 103 * @peer_addr: connected peer mac address 104 * @dialog_token: dialog token 105 * @msg_source: message source of type enum tRrmMsgReqSource 106 * @op_class: regulatory class 107 * @channel: channel number 108 * @req_freq: freq as per channel load req 109 * @randomization_intv: Random interval in ms 110 * @meas_duration: measurement duration in ms 111 * @bw_ind: Info for bandwidth indication IE 112 * @wide_bw: Info for wide bandwidth channel switch IE 113 */ 114 struct ch_load_ind { 115 uint16_t message_type; 116 uint16_t length; 117 uint8_t measurement_idx; 118 struct qdf_mac_addr peer_addr; 119 uint16_t dialog_token; 120 tRrmMsgReqSource msg_source; 121 uint8_t op_class; 122 uint8_t channel; 123 qdf_freq_t req_freq; 124 uint16_t randomization_intv; 125 uint16_t meas_duration; 126 struct bw_ind_element bw_ind; 127 struct wide_bw_chan_switch wide_bw; 128 }; 129 130 /** 131 * struct chan_load_xmit_ind - Contains info for channel load xmit indication 132 * @messageType: message type eWNI_SME_CHAN_LOAD_REPORT_RESP_XMIT_IND 133 * @length: size of struct chan_load_req_ind 134 * @measurement_idx: measurement index for channel load request 135 * @peer_addr: MAC address of the BSS 136 * @dialog_token: dialog token 137 * @op_class: regulatory class 138 * @channel: channel number 139 * @duration: measurement duration in ms 140 * @chan_load: channel utilization measurement 141 * @rrm_scan_tsf: time at which driver triggers rrm scan for channel load 142 * @is_report_success: need to send failure report or not 143 * @bw_ind: Info for bandwidth indication IE 144 * @wide_bw: Info for wide bandwidth channel switch IE 145 */ 146 struct chan_load_xmit_ind { 147 uint16_t messageType; 148 uint16_t length; 149 uint8_t measurement_idx; 150 struct qdf_mac_addr peer_addr; 151 uint16_t dialog_token; 152 uint8_t op_class; 153 uint8_t channel; 154 uint16_t duration; 155 uint8_t chan_load; 156 qdf_time_t rrm_scan_tsf; 157 bool is_report_success; 158 struct bw_ind_element bw_ind; 159 struct wide_bw_chan_switch wide_bw; 160 }; 161 162 typedef struct sSirBeaconReportReqInd { 163 uint16_t messageType; /* eWNI_SME_BEACON_REPORT_REQ_IND */ 164 uint16_t length; 165 uint8_t measurement_idx; 166 tSirMacAddr bssId; 167 uint16_t measurementDuration[SIR_ESE_MAX_MEAS_IE_REQS]; /* ms */ 168 uint16_t randomizationInterval; /* ms */ 169 struct sir_channel_info channel_info; 170 /* 0: wildcard */ 171 tSirMacAddr macaddrBssid; 172 /* 0:Passive, 1: Active, 2: table mode */ 173 uint8_t fMeasurementtype[SIR_ESE_MAX_MEAS_IE_REQS]; 174 tAniSSID ssId; /* May be wildcard. */ 175 uint16_t uDialogToken; 176 struct report_channel_list channel_list; /* From AP channel report. */ 177 tRrmMsgReqSource msgSource; 178 } tSirBeaconReportReqInd, *tpSirBeaconReportReqInd; 179 180 typedef struct sSirBeaconReportXmitInd { 181 uint16_t messageType; /* eWNI_SME_BEACON_REPORT_RESP_XMIT_IND */ 182 uint16_t length; 183 uint8_t measurement_idx; 184 tSirMacAddr bssId; 185 uint16_t uDialogToken; 186 uint8_t fMeasureDone; 187 uint16_t duration; 188 uint8_t regClass; 189 uint8_t numBssDesc; 190 struct bss_description *pBssDescription[SIR_BCN_REPORT_MAX_BSS_DESC]; 191 } tSirBeaconReportXmitInd, *tpSirBeaconReportXmitInd; 192 193 typedef struct sSirNeighborReportReqInd { 194 /* eWNI_SME_NEIGHBOR_REPORT_REQ_IND */ 195 uint16_t messageType; 196 uint16_t length; 197 /* For the session. */ 198 tSirMacAddr bssId; 199 /* true - dont include SSID in the request. */ 200 uint16_t noSSID; 201 /* false include the SSID. It may be null (wildcard) */ 202 tSirMacSSid ucSSID; 203 } tSirNeighborReportReqInd, *tpSirNeighborReportReqInd; 204 205 typedef struct sSirNeighborBssDescription { 206 uint16_t length; 207 tSirMacAddr bssId; 208 uint8_t regClass; 209 uint8_t channel; 210 uint8_t phyType; 211 union sSirNeighborBssidInfo { 212 struct _rrmInfo { 213 /* see IEEE 802.11k Table 7-43a */ 214 uint32_t fApPreauthReachable:2; 215 uint32_t fSameSecurityMode:1; 216 uint32_t fSameAuthenticator:1; 217 /* see IEEE 802.11k Table 7-95d */ 218 uint32_t fCapSpectrumMeasurement:1; 219 uint32_t fCapQos:1; 220 uint32_t fCapApsd:1; 221 uint32_t fCapRadioMeasurement:1; 222 uint32_t fCapDelayedBlockAck:1; 223 uint32_t fCapImmediateBlockAck:1; 224 uint32_t fMobilityDomain:1; 225 uint32_t reserved:21; 226 } rrmInfo; 227 struct _eseInfo { 228 uint32_t channelBand:8; 229 uint32_t minRecvSigPower:8; 230 uint32_t apTxPower:8; 231 uint32_t roamHysteresis:8; 232 uint32_t adaptScanThres:8; 233 234 uint32_t transitionTime:8; 235 uint32_t tsfOffset:16; 236 237 uint32_t beaconInterval:16; 238 uint32_t reserved:16; 239 } eseInfo; 240 } bssidInfo; 241 242 /* Optional sub IEs....ignoring for now. */ 243 } tSirNeighborBssDescription, *tpSirNeighborBssDescripton; 244 245 typedef struct sSirNeighborReportInd { 246 uint16_t messageType; /* eWNI_SME_NEIGHBOR_REPORT_IND */ 247 uint16_t length; 248 uint8_t sessionId; 249 uint8_t measurement_idx; 250 uint16_t numNeighborReports; 251 tSirMacAddr bssId; /* For the session. */ 252 QDF_FLEX_ARRAY(tSirNeighborBssDescription, sNeighborBssDescription); 253 } tSirNeighborReportInd, *tpSirNeighborReportInd; 254 255 typedef struct eid_ext_info { 256 uint8_t eid; 257 uint8_t num_eid_ext; 258 uint8_t eid_ext[255]; 259 } eid_ext_info; 260 261 typedef struct sRRMBeaconReportRequestedIes { 262 uint8_t num; 263 uint8_t *pElementIds; 264 eid_ext_info ext_info; 265 } tRRMBeaconReportRequestedIes, *tpRRMBeaconReportRequestedIes; 266 267 /* Reporting detail defines. */ 268 /* Reference - IEEE Std 802.11k-2008 section 7.3.2.21.6 Table 7-29h */ 269 #define BEACON_REPORTING_DETAIL_NO_FF_IE 0 270 #define BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE 1 271 #define BEACON_REPORTING_DETAIL_ALL_FF_IE 2 272 273 typedef struct sRRMReq { 274 uint8_t measurement_idx; /* Index of the measurement report in frame */ 275 uint8_t dialog_token; /* In action frame; */ 276 uint8_t token; /* Within individual request; */ 277 uint8_t type; 278 union { 279 struct { 280 uint8_t reportingDetail; 281 uint8_t last_beacon_report_indication; 282 tRRMBeaconReportRequestedIes reqIes; 283 } Beacon; 284 } request; 285 uint8_t sendEmptyBcnRpt; 286 } tRRMReq, *tpRRMReq; 287 288 typedef struct sRRMCaps { 289 uint8_t LinkMeasurement:1; 290 uint8_t NeighborRpt:1; 291 uint8_t parallel:1; 292 uint8_t repeated:1; 293 uint8_t BeaconPassive:1; 294 uint8_t BeaconActive:1; 295 uint8_t BeaconTable:1; 296 uint8_t BeaconRepCond:1; 297 uint8_t FrameMeasurement:1; 298 uint8_t ChannelLoad:1; 299 uint8_t NoiseHistogram:1; 300 uint8_t statistics:1; 301 uint8_t LCIMeasurement:1; 302 uint8_t LCIAzimuth:1; 303 uint8_t TCMCapability:1; 304 uint8_t triggeredTCM:1; 305 uint8_t APChanReport:1; 306 uint8_t RRMMIBEnabled:1; 307 uint8_t operatingChanMax:3; 308 uint8_t nonOperatingChanMax:3; 309 uint8_t MeasurementPilot:3; 310 uint8_t MeasurementPilotEnabled:1; 311 uint8_t NeighborTSFOffset:1; 312 uint8_t RCPIMeasurement:1; 313 uint8_t RSNIMeasurement:1; 314 uint8_t BssAvgAccessDelay:1; 315 uint8_t BSSAvailAdmission:1; 316 uint8_t AntennaInformation:1; 317 uint8_t fine_time_meas_rpt:1; 318 uint8_t lci_capability:1; 319 uint8_t reserved:4; 320 } tRRMCaps, *tpRRMCaps; 321 322 /** 323 * struct rrm_sta_stats - RRM sta stats structure 324 * @rrm_report: rrm_report 325 * @peer: peer address 326 * @index: current req index 327 * @rrm_sta_stats_res_count: sta stats response count 328 * @vdev_id: vdev_id 329 */ 330 struct rrm_sta_stats { 331 tSirMacRadioMeasureReport rrm_report; 332 tSirMacAddr peer; 333 uint8_t index; 334 uint8_t rrm_sta_stats_res_count; 335 uint8_t vdev_id; 336 }; 337 338 typedef struct sRrmPEContext { 339 uint8_t rrmEnable; 340 /* 341 * Used during scan/measurement to store the start TSF. 342 * this is not used directly in beacon reports. 343 */ 344 uint32_t startTSF[2]; 345 /* 346 * This value is stored into bssdescription and beacon report 347 * gets it from bss decsription. 348 */ 349 tRRMCaps rrmEnabledCaps; 350 int8_t txMgmtPower; 351 /* Dialog token for the request initiated from station. */ 352 uint8_t DialogToken; 353 uint16_t prev_rrm_report_seq_num; 354 uint8_t num_active_request; 355 tpRRMReq pCurrentReq[MAX_MEASUREMENT_REQUEST]; 356 uint32_t beacon_rpt_chan_list[MAX_NUM_CHANNELS]; 357 uint8_t beacon_rpt_chan_num; 358 struct rrm_sta_stats rrm_sta_stats; 359 } tRrmPEContext, *tpRrmPEContext; 360 361 /* 2008 11k spec reference: 18.4.8.5 RCPI Measurement */ 362 #define RCPI_LOW_RSSI_VALUE (-110) 363 #define RCPI_MAX_VALUE (220) 364 #define CALCULATE_RCPI(rssi) (((rssi) + 110) * 2) 365 366 /* Bit mask are defined as per Draft P802.11REVmc_D4.2 */ 367 368 /** 369 * enum mask_rm_capability_byte1 - mask for supported capability 370 * @RM_CAP_LINK_MEASUREMENT: Link Measurement capability 371 * @RM_CAP_NEIGHBOR_REPORT: Neighbor report capability 372 * @RM_CAP_PARALLEL_MEASUREMENT: Parallel Measurement capability 373 * @RM_CAP_REPEATED_MEASUREMENT: Repeated Measurement capability 374 * @RM_CAP_BCN_PASSIVE_MEASUREMENT: Beacon passive measurement capability 375 * @RM_CAP_BCN_ACTIVE_MEASUREMENT: Beacon active measurement capability 376 * @RM_CAP_BCN_TABLE_MEASUREMENT: Beacon table measurement capability 377 * @RM_CAP_BCN_MEAS_REPORTING_COND: Beacon measurement reporting conditions 378 */ 379 enum mask_rm_capability_byte1 { 380 RM_CAP_LINK_MEASUREMENT = (1 << (0)), 381 RM_CAP_NEIGHBOR_REPORT = (1 << (1)), 382 RM_CAP_PARALLEL_MEASUREMENT = (1 << (2)), 383 RM_CAP_REPEATED_MEASUREMENT = (1 << (3)), 384 RM_CAP_BCN_PASSIVE_MEASUREMENT = (1 << (4)), 385 RM_CAP_BCN_ACTIVE_MEASUREMENT = (1 << (5)), 386 RM_CAP_BCN_TABLE_MEASUREMENT = (1 << (6)), 387 RM_CAP_BCN_MEAS_REPORTING_COND = (1 << (7)), 388 }; 389 390 /** 391 * enum mask_rm_capability_byte2 - mask for supported capability 392 * @RM_CAP_FRAME_MEASUREMENT: Frame Measurement capability 393 * @RM_CAP_CHAN_LOAD_MEASUREMENT: Channel load measurement capability 394 * @RM_CAP_NOISE_HIST_MEASUREMENT: Noise Histogram Measurement capability 395 * @RM_CAP_STATISTICS_MEASUREMENT: Statistics Measurement capability 396 * @RM_CAP_LCI_MEASUREMENT: LCI measurement capability 397 * @RM_CAP_LCI_AZIMUTH: LCI Azimuth capability 398 * @RM_CAP_TX_CATEGORY_MEASUREMENT: Transmit category measurement capability 399 * @RM_CAP_TRIG_TX_CATEGORY_MEASUREMENT: 400 * Triggered Transmit category measurement capability 401 */ 402 enum mask_rm_capability_byte2 { 403 RM_CAP_FRAME_MEASUREMENT = (1 << (0)), 404 RM_CAP_CHAN_LOAD_MEASUREMENT = (1 << (1)), 405 RM_CAP_NOISE_HIST_MEASUREMENT = (1 << (2)), 406 RM_CAP_STATISTICS_MEASUREMENT = (1 << (3)), 407 RM_CAP_LCI_MEASUREMENT = (1 << (4)), 408 RM_CAP_LCI_AZIMUTH = (1 << (5)), 409 RM_CAP_TX_CATEGORY_MEASUREMENT = (1 << (6)), 410 RM_CAP_TRIG_TX_CATEGORY_MEASUREMENT = (1 << (7)), 411 }; 412 413 /** 414 * enum mask_rm_capability_byte3 - mask for supported capability 415 * @RM_CAP_AP_CHAN_REPORT: AP channel report capability 416 * @RM_CAP_RM_MIB: RM MIB capability 417 * @RM_CAP_OPER_CHAN_MAX_DURATION_1: OPER_CHAN_MAX_DURATION bit1 418 * @RM_CAP_OPER_CHAN_MAX_DURATION_2: OPER_CHAN_MAX_DURATION bit2 419 * @RM_CAP_OPER_CHAN_MAX_DURATION_3: OPER_CHAN_MAX_DURATION bit3 420 * @RM_CAP_NONOPER_CHAN_MAX_DURATION_1: NONOPER_CHAN_MAX bit1 421 * @RM_CAP_NONOPER_CHAN_MAX_DURATION_2: NONOPER_CHAN_MAX bit2 422 * @RM_CAP_NONOPER_CHAN_MAX_DURATION_3: NONOPER_CHAN_MAX bit3 423 * @RM_CAP_OPER_CHAN_MAX_DURATION: Operating Channel Max Measurement Duration 424 * @RM_CAP_NONOPER_CHAN_MAX_DURATION: 425 * Nonoperating Channel Max Measurement Duration 426 */ 427 428 enum mask_rm_capability_byte3 { 429 RM_CAP_AP_CHAN_REPORT = (1 << (0)), 430 RM_CAP_RM_MIB = (1 << (1)), 431 RM_CAP_OPER_CHAN_MAX_DURATION_1 = (1 << (2)), 432 RM_CAP_OPER_CHAN_MAX_DURATION_2 = (1 << (3)), 433 RM_CAP_OPER_CHAN_MAX_DURATION_3 = (1 << (4)), 434 RM_CAP_NONOPER_CHAN_MAX_DURATION_1 = (1 << (5)), 435 RM_CAP_NONOPER_CHAN_MAX_DURATION_2 = (1 << (6)), 436 RM_CAP_NONOPER_CHAN_MAX_DURATION_3 = (1 << (7)), 437 RM_CAP_OPER_CHAN_MAX_DURATION = (RM_CAP_OPER_CHAN_MAX_DURATION_1 | 438 RM_CAP_OPER_CHAN_MAX_DURATION_2 | 439 RM_CAP_OPER_CHAN_MAX_DURATION_3), 440 RM_CAP_NONOPER_CHAN_MAX_DURATION = 441 (RM_CAP_NONOPER_CHAN_MAX_DURATION_1 | 442 RM_CAP_NONOPER_CHAN_MAX_DURATION_2 | 443 RM_CAP_NONOPER_CHAN_MAX_DURATION_3), 444 }; 445 446 /** 447 * enum mask_rm_capability_byte4 - mask for supported capability 448 * @RM_CAP_MEASUREMENT_PILOT_1: MEASUREMENT_PILOT bit1 449 * @RM_CAP_MEASUREMENT_PILOT_2: MEASUREMENT_PILOT bit2 450 * @RM_CAP_MEASUREMENT_PILOT_3: MEASUREMENT_PILOT bit3 451 * @RM_CAP_MEAS_PILOT_TX_INFO: Measurement Pilot Transmission Capability 452 * @RM_CAP_NEIGHBOR_RPT_TSF_OFFSET: Neighbor Report TSF Offset Capability 453 * @RM_CAP_RCPI_MEASUREMENT: RCPI Measurement Capability 454 * @RM_CAP_RSNI_MEASUREMENT: RSNI Measurement Capability 455 * @RM_CAP_BSS_AVG_ACCESS_DELAY: BSS Average Access Delay Capability 456 * @RM_CAP_MEASUREMENT_PILOT: Measurement pilot capability 457 */ 458 459 enum mask_rm_capability_byte4 { 460 RM_CAP_MEASUREMENT_PILOT_1 = (1 << (0)), 461 RM_CAP_MEASUREMENT_PILOT_2 = (1 << (1)), 462 RM_CAP_MEASUREMENT_PILOT_3 = (1 << (2)), 463 RM_CAP_MEAS_PILOT_TX_INFO = (1 << (3)), 464 RM_CAP_NEIGHBOR_RPT_TSF_OFFSET = (1 << (4)), 465 RM_CAP_RCPI_MEASUREMENT1 = (1 << (5)), 466 RM_CAP_RSNI_MEASUREMENT = (1 << (6)), 467 RM_CAP_BSS_AVG_ACCESS_DELAY = (1 << (7)), 468 RM_CAP_MEASUREMENT_PILOT = (RM_CAP_MEASUREMENT_PILOT_1 | 469 RM_CAP_MEASUREMENT_PILOT_2 | 470 RM_CAP_MEASUREMENT_PILOT_3), 471 }; 472 473 /** 474 * enum mask_rm_capability_byte5 - mask for supported capability 475 * @RM_CAP_BSS_AVAIL_ADMISSION: BSS Available Admission Capacity Capability 476 * @RM_CAP_ANTENNA: Antenna Capability 477 * @RM_CAP_FTM_RANGE_REPORT: FTM Range Report Capability 478 * @RM_CAP_CIVIC_LOC_MEASUREMENT: Civic Location Measurement capability 479 * 480 * 4 bits are reserved 481 */ 482 enum mask_rm_capability_byte5 { 483 RM_CAP_BSS_AVAIL_ADMISSION = (1 << (0)), 484 RM_CAP_ANTENNA = (1 << (1)), 485 RM_CAP_FTM_RANGE_REPORT = (1 << (2)), 486 RM_CAP_CIVIC_LOC_MEASUREMENT = (1 << (3)), 487 }; 488 489 #endif /* #if defined __RRMGLOBAL_H */ 490