1 /*
2  * Copyright (c) 2011-2012, 2014-2018, 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 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(__SMERRMINTERNAL_H)
21 #define __SMERRMINTERNAL_H
22 
23 /**
24  * \file  sme_rrm_internal.h
25  *
26  * \brief prototype for SME RRM APIs
27  */
28 
29 /*--------------------------------------------------------------------------
30   Include Files
31   ------------------------------------------------------------------------*/
32 #include "qdf_lock.h"
33 #include "qdf_trace.h"
34 #include "qdf_mem.h"
35 #include "qdf_types.h"
36 #include "rrm_global.h"
37 
38 /*--------------------------------------------------------------------------
39   Type declarations
40   ------------------------------------------------------------------------*/
41 typedef struct sRrmNeighborReportDesc {
42 	tListElem List;
43 	tSirNeighborBssDescription *pNeighborBssDescription;
44 	uint32_t roamScore;
45 	uint8_t sessionId;
46 } tRrmNeighborReportDesc, *tpRrmNeighborReportDesc;
47 
48 typedef void (*NeighborReportRspCallback)(void *context,
49 		QDF_STATUS qdf_status);
50 
51 typedef struct sRrmNeighborRspCallbackInfo {
52 	uint32_t timeout;       /* in ms.. min value is 10 (10ms) */
53 	NeighborReportRspCallback neighborRspCallback;
54 	void *neighborRspCallbackContext;
55 } tRrmNeighborRspCallbackInfo, *tpRrmNeighborRspCallbackInfo;
56 
57 typedef struct sRrmNeighborRequestControlInfo {
58 	/* To check whether a neighbor req is already sent & response pending */
59 	bool isNeighborRspPending;
60 	qdf_mc_timer_t neighborRspWaitTimer;
61 	tRrmNeighborRspCallbackInfo neighborRspCallbackInfo;
62 } tRrmNeighborRequestControlInfo, *tpRrmNeighborRequestControlInfo;
63 
64 /**
65  * enum rrm_measurement_type: measurement type
66  * @RRM_CHANNEL_LOAD: measurement type for channel load req
67  * @RRM_BEACON_REPORT: measurement type for beacon report request
68  */
69 enum rrm_measurement_type {
70 	RRM_CHANNEL_LOAD = 0,
71 	RRM_BEACON_REPORT = 1,
72 };
73 
74 /**
75  * enum channel_load_req_info: channel load request info
76  * @channel: channel for which the host receives the channel load req from AP
77  * @req_chan_width: channel width for which the host receives the channel load
78  * req from AP
79  * @rrm_scan_tsf: to store jiffies for RRM scan to process chan load req
80  * @bw_ind: Contains info for Bandwidth Indication IE
81  * @wide_bw: Contains info for Wide Bandwidth Channel IE
82  */
83 struct channel_load_req_info {
84 	uint8_t channel;
85 	qdf_freq_t req_freq;
86 	enum phy_ch_width req_chan_width;
87 	qdf_time_t rrm_scan_tsf;
88 	struct bw_ind_element bw_ind;
89 	struct wide_bw_chan_switch wide_bw;
90 };
91 
92 typedef struct sRrmSMEContext {
93 	uint16_t token;
94 	struct qdf_mac_addr sessionBssId;
95 	uint8_t regClass;
96 	uint8_t measurement_idx;
97 	enum rrm_measurement_type measurement_type;
98 	struct channel_load_req_info chan_load_req_info;
99 	/* list of all channels to be measured. */
100 	tCsrChannelInfo channelList;
101 	uint8_t currentIndex;
102 	/* SSID used in the measuring beacon report. */
103 	tAniSSID ssId;
104 	tSirMacAddr bssId;      /* bssid used for beacon report measurement. */
105 	/* Randomization interval to be used in subsequent measurements. */
106 	uint16_t randnIntvl;
107 	uint16_t duration[SIR_ESE_MAX_MEAS_IE_REQS];
108 	uint8_t measMode[SIR_ESE_MAX_MEAS_IE_REQS];
109 	uint32_t scan_id;
110 	tDblLinkList neighborReportCache;
111 	tRrmNeighborRequestControlInfo neighborReqControlInfo;
112 
113 #ifdef FEATURE_WLAN_ESE
114 	tCsrEseBeaconReq eseBcnReqInfo;
115 	bool eseBcnReqInProgress;
116 #endif /* FEATURE_WLAN_ESE */
117 	tRrmMsgReqSource msgSource;
118 	wlan_scan_requester req_id;
119 } tRrmSMEContext, *tpRrmSMEContext;
120 
121 typedef struct sRrmNeighborReq {
122 	uint8_t no_ssid;
123 	tSirMacSSid ssid;
124 	bool neighbor_report_offload;
125 } tRrmNeighborReq, *tpRrmNeighborReq;
126 
127 /**
128  * sme_rrm_issue_scan_req() - To issue rrm scan request
129  * @mac_ctx: pointer to mac context
130  *
131  * This routine is called to issue rrm scan request
132  *
133  * Return: QDF_STATUS
134  */
135 QDF_STATUS sme_rrm_issue_scan_req(struct mac_context *mac_ctx, uint8_t idx);
136 
137 #endif /* #if !defined( __SMERRMINTERNAL_H ) */
138