Browse Source

qcacld-3.0: Add check to validate the Tx chainmask value

Add a sanity check to validate the Tx chainmask value
sent from the user space for each HW mode.

Change-Id: I2705efe20fcb13bf8343088ceecb4207e2562789
CRs-Fixed: 2943363
Aditya Kodukula 3 years ago
parent
commit
2d3512006a
1 changed files with 30 additions and 0 deletions
  1. 30 0
      core/wma/src/wma_main.c

+ 30 - 0
core/wma/src/wma_main.c

@@ -843,6 +843,28 @@ static void wma_set_dtim_period(tp_wma_handle wma,
 
 }
 
+static inline bool wma_is_tx_chainmask_valid(int value,
+					     struct target_psoc_info *tgt_hdl)
+{
+	struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
+	uint8_t total_mac_phy_cnt, i;
+
+	mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
+	if (!mac_phy_cap) {
+		wma_err("Invalid MAC PHY capabilities handle");
+		return false;
+	}
+
+	total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
+	for (i = 0; i < total_mac_phy_cnt; i++) {
+		if (((mac_phy_cap[i].tx_chain_mask_5G) & (value))) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 /**
  * wma_process_cli_set_cmd() - set parameters to fw
  * @wma: wma handle
@@ -914,6 +936,14 @@ static void wma_process_cli_set_cmd(tp_wma_handle wma,
 				return;
 			}
 		}
+
+		if (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK) {
+			if (!wma_is_tx_chainmask_valid(privcmd->param_value,
+						       tgt_hdl)) {
+				wma_debug("Chainmask value is invalid");
+				return;
+			}
+		}
 		pdev_param.param_id = privcmd->param_id;
 		pdev_param.param_value = privcmd->param_value;
 		ret = wmi_unified_pdev_param_send(wma->wmi_handle,