qcacld-3.0: Verify the nss config with rf chains supported

The driver fills the nss chains params in the vdev during
vdev create. The nss and chain params are filled by the user
in the ini file, but it may happen that the user filled the
nss param for that particular vdev as 2, and the number of
supported rf chains are 1, which is sent to the driver by FW,
so that would result in nss as 2, and chains as 1, which cannot
be supported.

Fix is to downgrade the nss to the number of chains supported by
the FW.

Change-Id: Ifa3ee74dbe5b8d19c6dc11ff64e42dbffadaa018
CRs-Fixed: 2354205
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index 0123147..bbac5f8 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -4806,6 +4806,17 @@
 }
 
 static void
+sme_check_nss_chain_ini_param(struct wlan_mlme_nss_chains *vdev_ini_cfg,
+			      uint8_t rf_chains_supported,
+			      enum nss_chains_band_info band)
+{
+	vdev_ini_cfg->rx_nss[band] = QDF_MIN(vdev_ini_cfg->rx_nss[band],
+					     rf_chains_supported);
+	vdev_ini_cfg->tx_nss[band] = QDF_MIN(vdev_ini_cfg->tx_nss[band],
+					     rf_chains_supported);
+}
+
+static void
 sme_fill_nss_chain_params(struct mac_context *mac_ctx,
 			  struct wlan_mlme_nss_chains *vdev_ini_cfg,
 			  enum QDF_OPMODE device_mode,
@@ -4864,6 +4875,14 @@
 
 	vdev_ini_cfg->disable_tx_mrc[band] =
 				nss_chains_ini_cfg->disable_tx_mrc[band];
+	/*
+	 * Check whether the rx/tx nss is greater than the number of rf chains
+	 * supported by FW, if so downgrade the nss to the number of chains
+	 * supported, as higher nss cannot be supported with less chains.
+	 */
+	sme_check_nss_chain_ini_param(vdev_ini_cfg, rf_chains_supported,
+				      band);
+
 }
 
 void sme_populate_nss_chain_params(mac_handle_t mac_handle,