Browse Source

qcacld-3.0: Refactor formation of wmi peer assoc command

Move tlv formation of wmi peer assoc command to common wmi layer
from wma layer.

CRs-Fixed: 976998
Change-Id: I0562862a7acc16b88bbd295b998397f1acf7973a
Govind Singh 9 years ago
parent
commit
b30d4c0c71
3 changed files with 40 additions and 72 deletions
  1. 1 1
      core/wma/inc/wma_internal.h
  2. 6 6
      core/wma/src/wma_dev_if.c
  3. 33 65
      core/wma/src/wma_mgmt.c

+ 1 - 1
core/wma/inc/wma_internal.h

@@ -617,7 +617,7 @@ int wma_vdev_install_key_complete_event_handler(void *handle,
 						uint8_t *event,
 						uint32_t len);
 
-int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
+QDF_STATUS wma_send_peer_assoc(tp_wma_handle wma,
 					   tSirNwType nw_type,
 					   tpAddStaParams params);
 

+ 6 - 6
core/wma/src/wma_dev_if.c

@@ -3364,7 +3364,7 @@ static void wma_add_bss_sta_mode(tp_wma_handle wma, tpAddBssParams add_bss)
 			WMA_LOGD("Sent PKT_PWR_SAVE_5G_EBT cmd to target, val = %x, status = %d",
 				pps_val, status);
 
-		wmi_unified_send_peer_assoc(wma, add_bss->nwType,
+		wma_send_peer_assoc(wma, add_bss->nwType,
 					    &add_bss->staContext);
 		peer_assoc_sent = true;
 #ifdef WLAN_FEATURE_11W
@@ -3589,7 +3589,7 @@ static void wma_add_sta_req_ap_mode(tp_wma_handle wma, tpAddStaParams add_sta)
 		WMA_LOGE(FL("WMI_SERVICE_PEER_ASSOC_CONF not enabled"));
 	}
 
-	ret = wmi_unified_send_peer_assoc(wma, add_sta->nwType, add_sta);
+	ret = wma_send_peer_assoc(wma, add_sta->nwType, add_sta);
 	if (ret) {
 		add_sta->status = QDF_STATUS_E_FAILURE;
 		wma_remove_peer(wma, add_sta->staMac, add_sta->smesessionId,
@@ -3805,11 +3805,11 @@ static void wma_add_tdls_sta(tp_wma_handle wma, tpAddStaParams add_sta)
 			WMA_LOGE(FL("WMI_SERVICE_PEER_ASSOC_CONF not enabled"));
 		}
 
-		WMA_LOGD("%s: changeSta, calling wmi_unified_send_peer_assoc",
+		WMA_LOGD("%s: changeSta, calling wma_send_peer_assoc",
 			 __func__);
 
 		ret =
-			wmi_unified_send_peer_assoc(wma, add_sta->nwType, add_sta);
+			wma_send_peer_assoc(wma, add_sta->nwType, add_sta);
 		if (ret) {
 			add_sta->status = QDF_STATUS_E_FAILURE;
 			wma_remove_peer(wma, add_sta->staMac,
@@ -3909,7 +3909,7 @@ static void wma_add_sta_req_sta_mode(tp_wma_handle wma, tpAddStaParams params)
 		if (wma_is_roam_synch_in_progress(wma, params->smesessionId)) {
 			/* iface->nss = params->nss; */
 			/*In LFR2.0, the following operations are performed as
-			 * part of wmi_unified_send_peer_assoc. As we are
+			 * part of wma_send_peer_assoc. As we are
 			 * skipping this operation, we are just executing the
 			 * following which are useful for LFR3.0.*/
 			ol_txrx_peer_state_update(pdev, params->bssId,
@@ -3946,7 +3946,7 @@ static void wma_add_sta_req_sta_mode(tp_wma_handle wma, tpAddStaParams params)
 			WMA_LOGE(FL("WMI_SERVICE_PEER_ASSOC_CONF not enabled"));
 		}
 
-		ret = wmi_unified_send_peer_assoc(wma,
+		ret = wma_send_peer_assoc(wma,
 				iface->nwType,
 				(tAddStaParams *) iface->addBssStaContext);
 		if (ret) {

+ 33 - 65
core/wma/src/wma_mgmt.c

@@ -828,44 +828,44 @@ static inline uint8_t wma_parse_mpdudensity(uint8_t mpdudensity)
  * This function send peer assoc command to firmware with
  * different parameters.
  *
- * Return: 0 for success or error code
+ * Return: QDF_STATUS
  */
-int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
+QDF_STATUS wma_send_peer_assoc(tp_wma_handle wma,
 				    tSirNwType nw_type,
 				    tpAddStaParams params)
 {
 	ol_txrx_pdev_handle pdev;
-	wmi_peer_assoc_complete_cmd_fixed_param *cmd;
-	wmi_buf_t buf;
-	int32_t len;
+	struct peer_assoc_params *cmd;
 	int32_t ret, max_rates, i;
 	uint8_t rx_stbc, tx_stbc;
-	uint8_t *rate_pos, *buf_ptr;
+	uint8_t *rate_pos;
 	wmi_rate_set peer_legacy_rates, peer_ht_rates;
-	wmi_vht_rate_set *mcs;
-	uint32_t num_peer_legacy_rates;
-	uint32_t num_peer_ht_rates;
 	uint32_t num_peer_11b_rates = 0;
 	uint32_t num_peer_11a_rates = 0;
 	uint32_t phymode;
 	uint32_t peer_nss = 1;
 	struct wma_txrx_node *intr = NULL;
+	QDF_STATUS status;
 
-	if (NULL == params) {
-		WMA_LOGE("%s: params is NULL", __func__);
-		return -EINVAL;
+	cmd = qdf_mem_malloc(sizeof(struct peer_assoc_params));
+	if (!cmd) {
+		WMA_LOGE("Failed to allocate peer_assoc_params param");
+		return QDF_STATUS_E_NOMEM;
 	}
+
 	intr = &wma->interfaces[params->smesessionId];
 
 	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
 
 	if (NULL == pdev) {
 		WMA_LOGE("%s: Failed to get pdev", __func__);
-		return -EINVAL;
+		qdf_mem_free(cmd);
+		return QDF_STATUS_E_INVAL;
 	}
 
 	qdf_mem_zero(&peer_legacy_rates, sizeof(wmi_rate_set));
 	qdf_mem_zero(&peer_ht_rates, sizeof(wmi_rate_set));
+	qdf_mem_zero(cmd, sizeof(struct peer_assoc_params));
 
 	phymode = wma_peer_phymode(nw_type, params->staType,
 				   params->htCapable,
@@ -893,11 +893,9 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 	    (phymode == MODE_11B && num_peer_11b_rates == 0)) {
 		WMA_LOGW("%s: Invalid phy rates. phymode 0x%x, 11b_rates %d, 11a_rates %d",
 			__func__, phymode, num_peer_11b_rates, num_peer_11a_rates);
-		return -EINVAL;
+		qdf_mem_free(cmd);
+		return QDF_STATUS_E_INVAL;
 	}
-	/* Set the Legacy Rates to Word Aligned */
-	num_peer_legacy_rates = roundup(peer_legacy_rates.num_rates,
-					sizeof(uint32_t));
 
 	/* HT Rateset */
 	max_rates = sizeof(peer_ht_rates.rates) /
@@ -934,28 +932,6 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 			     peer_ht_rates.num_rates);
 	}
 
-	/* Set the Peer HT Rates to Word Aligned */
-	num_peer_ht_rates = roundup(peer_ht_rates.num_rates, sizeof(uint32_t));
-
-	len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + /* Place holder for peer legacy rate array */
-	      (num_peer_legacy_rates * sizeof(uint8_t)) + /* peer legacy rate array size */
-	      WMI_TLV_HDR_SIZE + /* Place holder for peer Ht rate array */
-	      (num_peer_ht_rates * sizeof(uint8_t)) +   /* peer HT rate array size */
-	      sizeof(wmi_vht_rate_set);
-
-	buf = wmi_buf_alloc(wma->wmi_handle, len);
-	if (!buf) {
-		WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
-		return -ENOMEM;
-	}
-
-	buf_ptr = (uint8_t *) wmi_buf_data(buf);
-	cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
-	WMITLV_SET_HDR(&cmd->tlv_header,
-		       WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
-		       WMITLV_GET_STRUCT_TLVLEN
-			       (wmi_peer_assoc_complete_cmd_fixed_param));
-
 	/* in ap/ibss mode and for tdls peer, use mac address of the peer in
 	 * the other end as the new peer address; in sta mode, use bss id to
 	 * be the new peer address
@@ -1076,7 +1052,7 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 			WMA_LOGE
 				("Set WMI_VDEV_PARAM_DROP_UNENCRY Param status:%d\n",
 				ret);
-			qdf_nbuf_free(buf);
+			qdf_mem_free(cmd);
 			return ret;
 		}
 	}
@@ -1096,24 +1072,16 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 		cmd->peer_rate_caps |= WMI_RC_DS_FLAG;
 
 	/* Update peer legacy rate information */
-	buf_ptr += sizeof(*cmd);
-	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, num_peer_legacy_rates);
-	buf_ptr += WMI_TLV_HDR_SIZE;
-	cmd->num_peer_legacy_rates = peer_legacy_rates.num_rates;
-	qdf_mem_copy(buf_ptr, peer_legacy_rates.rates,
+	cmd->peer_legacy_rates.num_rates = peer_legacy_rates.num_rates;
+	qdf_mem_copy(cmd->peer_legacy_rates.rates, peer_legacy_rates.rates,
 		     peer_legacy_rates.num_rates);
 
 	/* Update peer HT rate information */
-	buf_ptr += num_peer_legacy_rates;
-	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, num_peer_ht_rates);
-	buf_ptr += WMI_TLV_HDR_SIZE;
-	cmd->num_peer_ht_rates = peer_ht_rates.num_rates;
-	qdf_mem_copy(buf_ptr, peer_ht_rates.rates, peer_ht_rates.num_rates);
+	cmd->peer_ht_rates.num_rates = peer_ht_rates.num_rates;
+	qdf_mem_copy(cmd->peer_ht_rates.rates, peer_ht_rates.rates,
+				 peer_ht_rates.num_rates);
 
 	/* VHT Rates */
-	buf_ptr += num_peer_ht_rates;
-	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
-		       WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
 
 	cmd->peer_nss = peer_nss;
 	/*
@@ -1131,18 +1099,18 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 	WMA_LOGD("peer_nss %d peer_ht_rates.num_rates %d ", cmd->peer_nss,
 		 peer_ht_rates.num_rates);
 
-	mcs = (wmi_vht_rate_set *) buf_ptr;
+	cmd->vht_capable = params->vhtCapable;
 	if (params->vhtCapable) {
 #define VHT2x2MCSMASK 0xc
-		mcs->rx_max_rate = params->supportedRates.vhtRxHighestDataRate;
-		mcs->rx_mcs_set = params->supportedRates.vhtRxMCSMap;
-		mcs->tx_max_rate = params->supportedRates.vhtTxHighestDataRate;
-		mcs->tx_mcs_set = params->supportedRates.vhtTxMCSMap;
+		cmd->rx_max_rate = params->supportedRates.vhtRxHighestDataRate;
+		cmd->rx_mcs_set = params->supportedRates.vhtRxMCSMap;
+		cmd->tx_max_rate = params->supportedRates.vhtTxHighestDataRate;
+		cmd->tx_mcs_set = params->supportedRates.vhtTxMCSMap;
 
 		if (params->vhtSupportedRxNss) {
 			cmd->peer_nss = params->vhtSupportedRxNss;
 		} else {
-			cmd->peer_nss = ((mcs->rx_mcs_set & VHT2x2MCSMASK)
+			cmd->peer_nss = ((cmd->rx_mcs_set & VHT2x2MCSMASK)
 					 == VHT2x2MCSMASK) ? 1 : 2;
 		}
 	}
@@ -1166,14 +1134,14 @@ int32_t wmi_unified_send_peer_assoc(tp_wma_handle wma,
 		 cmd->peer_mpdu_density, params->encryptType,
 		 cmd->peer_vht_caps);
 
-	ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len,
-				   WMI_PEER_ASSOC_CMDID);
-	if (ret != EOK) {
+	status = wmi_unified_peer_assoc_send(wma->wmi_handle,
+					 cmd);
+	if (QDF_IS_STATUS_ERROR(status))
 		WMA_LOGP("%s: Failed to send peer assoc command ret = %d",
 			 __func__, ret);
-		qdf_nbuf_free(buf);
-	}
-	return ret;
+	qdf_mem_free(cmd);
+
+	return status;
 }
 
 /**