Browse Source

qcacld-3.0: add sme interface for requesting channel switch

Add new api sme_switch_channel(), which posts eWNI_SME_CSA_REQ
with specified parameters; set lim_handle_csa_offload_msg as the
handler for this new message.

Change-Id: Id015ac5f9f3674ff06d110f7a0dccd85364b3d86
CRs-Fixed: 2960191
Yu Wang 3 năm trước cách đây
mục cha
commit
af7b3788a6

+ 2 - 1
core/mac/inc/wni_api.h

@@ -255,7 +255,8 @@ enum eWniMsgTypes {
 	CM_DISCONNECT_REQ = SIR_SME_MSG_TYPES_BEGIN + 173,
 	CM_REASSOC_REQ = SIR_SME_MSG_TYPES_BEGIN + 174,
 	CM_PREAUTH_REQ = SIR_SME_MSG_TYPES_BEGIN + 175,
-	eWNI_SME_MSG_TYPES_END = SIR_SME_MSG_TYPES_BEGIN + 176
+	eWNI_SME_CSA_REQ = SIR_SME_MSG_TYPES_BEGIN + 176,
+	eWNI_SME_MSG_TYPES_END = SIR_SME_MSG_TYPES_BEGIN + 177
 };
 
 typedef struct sAniCfgTxRateCtrs {

+ 1 - 0
core/mac/src/pe/lim/lim_process_message_queue.c

@@ -1894,6 +1894,7 @@ static void lim_process_messages(struct mac_context *mac_ctx,
 		lim_handle_delete_bss_rsp(mac_ctx, msg->bodyptr);
 		break;
 	case WMA_CSA_OFFLOAD_EVENT:
+	case eWNI_SME_CSA_REQ:
 		lim_handle_csa_offload_msg(mac_ctx, msg);
 		break;
 	case WMA_SET_BSSKEY_RSP:

+ 13 - 0
core/sme/inc/sme_api.h

@@ -4491,4 +4491,17 @@ static inline uint32_t sme_get_eht_ch_width(void)
 }
 #endif /* WLAN_FEATURE_11BE */
 
+/**
+ * sme_switch_channel() - Request to switch channel
+ * @mac_handle: Opaque handle to the MAC context
+ * @bssid: current connected bssid
+ * @chan_freq: new channel frequency
+ * @chan_width: new channel width
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS sme_switch_channel(mac_handle_t mac_handle,
+			      struct qdf_mac_addr *bssid,
+			      qdf_freq_t chan_freq,
+			      enum phy_ch_width chan_width);
 #endif /* #if !defined( __SME_API_H ) */

+ 43 - 0
core/sme/src/common/sme_api.c

@@ -16535,3 +16535,46 @@ enum csr_cfgdot11mode sme_phy_mode_to_dot11mode(enum wlan_phymode phy_mode)
 	return csr_phy_mode_to_dot11mode(phy_mode);
 }
 
+QDF_STATUS sme_switch_channel(mac_handle_t mac_handle,
+			      struct qdf_mac_addr *bssid,
+			      qdf_freq_t chan_freq,
+			      enum phy_ch_width chan_width)
+{
+	struct scheduler_msg msg = {0};
+	struct csa_offload_params *csa_offload_event;
+	struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle);
+
+	csa_offload_event = qdf_mem_malloc(sizeof(*csa_offload_event));
+	if (!csa_offload_event)
+		return QDF_STATUS_E_NOMEM;
+
+	qdf_mem_copy(csa_offload_event->bssId, bssid->bytes,
+		     QDF_MAC_ADDR_SIZE);
+	csa_offload_event->csa_chan_freq = (uint32_t)chan_freq;
+	csa_offload_event->new_ch_width = (uint8_t)chan_width;
+	csa_offload_event->channel =
+		wlan_reg_freq_to_chan(mac_ctx->pdev,
+				      csa_offload_event->csa_chan_freq);
+	csa_offload_event->switch_mode = 1;
+
+	sme_debug("bssid " QDF_MAC_ADDR_FMT " freq %u width %u",
+		  QDF_MAC_ADDR_REF(csa_offload_event->bssId),
+		  csa_offload_event->csa_chan_freq,
+		  csa_offload_event->new_ch_width);
+
+	msg.type = eWNI_SME_CSA_REQ;
+	msg.reserved = 0;
+	msg.bodyptr = csa_offload_event;
+
+	if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
+							 QDF_MODULE_ID_PE,
+							 QDF_MODULE_ID_PE,
+							 &msg)) {
+		qdf_mem_free(csa_offload_event);
+		sme_err("Not able to post WMA_CSA_OFFLOAD_EVENT to PE");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+