1 /*
2  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021, 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(__SMEINSIDE_H)
21 #define __SMEINSIDE_H
22 
23 /**
24  * \file  sme_inside.h
25  *
26  * \brief prototype for SME structures and APIs used insside SME
27  */
28 
29 /*--------------------------------------------------------------------------
30   Include Files
31   ------------------------------------------------------------------------*/
32 #include "qdf_status.h"
33 #include "qdf_lock.h"
34 #include "qdf_trace.h"
35 #include "qdf_mem.h"
36 #include "qdf_types.h"
37 #include "sir_api.h"
38 #include "csr_internal.h"
39 #include "sme_qos_api.h"
40 #include "sme_qos_internal.h"
41 
42 #include "sme_rrm_api.h"
43 #include "wlan_serialization_legacy_api.h"
44 ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue);
45 
46 /*--------------------------------------------------------------------------
47   Type declarations
48   ------------------------------------------------------------------------*/
49 /*
50  * In case MAX num of STA are connected to SAP, switching off SAP causes
51  * two SME cmd to be enqueued for each STA. Keeping SME total cmds as following
52  * to make sure we have space for these cmds + some additional cmds.
53  */
54 #define SME_TOTAL_COMMAND                (HAL_NUM_STA * 3)
55 
56 typedef struct sGenericQosCmd {
57 	struct sme_qos_wmmtspecinfo tspecInfo;
58 	enum qca_wlan_ac_type ac;
59 	uint8_t tspec_mask;
60 } tGenericQosCmd;
61 
62 /**
63  * struct s_nss_update_cmd - Format of nss update request
64  * @new_nss: new nss value
65  * @ch_width: new channel width - optional
66  * @session_id: Session ID
67  * @set_hw_mode_cb: HDD nss update callback
68  * @context: Adapter context
69  * @next_action: Action to be taken after nss update
70  * @reason: reason for nss update
71  * @original_vdev_id: original request hwmode change vdev id
72  * @request_id: request id for connection manager
73  */
74 struct s_nss_update_cmd {
75 	uint32_t new_nss;
76 	uint32_t ch_width;
77 	uint32_t session_id;
78 	void *nss_update_cb;
79 	void *context;
80 	uint8_t next_action;
81 	enum policy_mgr_conn_update_reason reason;
82 	uint32_t original_vdev_id;
83 	uint32_t request_id;
84 };
85 
86 /**
87  * struct sir_sap_ch_width_update_cmd - Format of ch_width update request
88  * @ch_width: new channel width
89  * @vdev_id: vdev ID
90  * @reason: reason for ch_width update
91  * @conc_vdev_id: Concurrent connection vdev_id that is causing ch_width update
92  * @request_id: request id for connection manager
93  */
94 struct sir_sap_ch_width_update_cmd {
95 	uint32_t ch_width;
96 	uint32_t vdev_id;
97 	enum policy_mgr_conn_update_reason reason;
98 	uint32_t conc_vdev_id;
99 	uint32_t request_id;
100 };
101 
102 typedef struct tagSmeCmd {
103 	tListElem Link;
104 	eSmeCommandType command;
105 	uint32_t cmd_id;
106 	uint32_t vdev_id;
107 	union {
108 		struct roam_cmd roamCmd;
109 		struct wmstatus_changecmd wmStatusChangeCmd;
110 		tGenericQosCmd qosCmd;
111 		struct policy_mgr_hw_mode set_hw_mode_cmd;
112 		struct s_nss_update_cmd nss_update_cmd;
113 		struct policy_mgr_dual_mac_config set_dual_mac_cmd;
114 		struct sir_antenna_mode_param set_antenna_mode_cmd;
115 		struct sir_sap_ch_width_update_cmd bw_update_cmd;
116 	} u;
117 } tSmeCmd;
118 
119 /*--------------------------------------------------------------------------
120   Internal to SME
121   ------------------------------------------------------------------------*/
122 /**
123  * csr_get_cmd_type() - to convert sme command type to serialization cmd type
124  * @sme_cmd: sme command pointer
125  *
126  * This API will convert SME command type to serialization command type which
127  * new serialization module understands
128  *
129  * Return: serialization cmd type based on sme command type
130  */
131 enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd);
132 /**
133  * csr_set_serialization_params_to_cmd() - take sme params and create new
134  *						serialization command
135  * @mac_ctx: pointer to mac context
136  * @sme_cmd: sme command pointer
137  * @cmd: serialization command pointer
138  * @high_priority: if command is high priority
139  *
140  * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
141  */
142 QDF_STATUS csr_set_serialization_params_to_cmd(struct mac_context *mac_ctx,
143 		tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
144 		uint8_t high_priority);
145 tSmeCmd *sme_get_command_buffer(struct mac_context *mac);
146 void sme_release_command(struct mac_context *mac, tSmeCmd *pCmd);
147 bool qos_process_command(struct mac_context *mac, tSmeCmd *pCommand);
148 void qos_release_command(struct mac_context *mac, tSmeCmd *pCommand);
149 QDF_STATUS csr_roam_process_command(struct mac_context *mac, tSmeCmd *pCommand);
150 
151 /**
152  * csr_roam_wm_status_change_complete() - Remove WM status change command
153  *                                        from SME active command list
154  * @mac_ctx: global mac context
155  * @session_id: session id
156  *
157  * This API removes WM status change command from SME active command list
158  * if present.
159  *
160  * Return: void
161  */
162 void csr_roam_wm_status_change_complete(struct mac_context *mac_ctx,
163 					uint8_t session_id);
164 void csr_roam_process_wm_status_change_command(struct mac_context *mac,
165 		tSmeCmd *pCommand);
166 
167 void csr_reinit_roam_cmd(struct mac_context *mac, tSmeCmd *pCommand);
168 void csr_reinit_wm_status_change_cmd(struct mac_context *mac,
169 				     tSmeCmd *pCommand);
170 
171 QDF_STATUS sme_acquire_global_lock(struct sme_context *sme);
172 QDF_STATUS sme_release_global_lock(struct sme_context *sme);
173 
174 ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue);
175 void csr_process_set_dual_mac_config(struct mac_context *mac, tSmeCmd *command);
176 void csr_process_set_antenna_mode(struct mac_context *mac, tSmeCmd *command);
177 void csr_process_set_hw_mode(struct mac_context *mac, tSmeCmd *command);
178 void csr_process_nss_update_req(struct mac_context *mac, tSmeCmd *command);
179 void csr_process_sap_ch_width_update(struct mac_context *mac, tSmeCmd *command);
180 #endif /* #if !defined( __SMEINSIDE_H ) */
181