qcacld-3.0: Update rate flags correctly

Currently in driver does  not update the rate flags correctly
in wma as rate flags should include all the subsets of the
lower rartesets, which is not thye case today and driver only
updates the higher rate flag. Because of which it leads to
invalid computation of txrate at the kernel.

Bug: 166722837
Change-Id: I5529532b3d41b68693b5b4b8952ee0f1414354db
CRs-Fixed: 2776370
diff --git a/core/wma/inc/wma_internal.h b/core/wma/inc/wma_internal.h
index 3ae6430..3553dcb 100644
--- a/core/wma/inc/wma_internal.h
+++ b/core/wma/inc/wma_internal.h
@@ -799,6 +799,14 @@
 void wma_set_bss_rate_flags(struct wma_txrx_node *iface,
 				   tpAddBssParams add_bss);
 
+/**
+ * wma_get_vht_rate_flags() - Return the VHT rate flags corresponding to the BW
+ * @ch_width: BW for which rate flags is required
+ *
+ * Return: Rate flags corresponding to ch_width
+ */
+tTxrateinfoflags wma_get_vht_rate_flags(enum phy_ch_width ch_width);
+
 int32_t wmi_unified_send_txbf(tp_wma_handle wma, tpAddStaParams params);
 
 /**
diff --git a/core/wma/src/wma_data.c b/core/wma/src/wma_data.c
index 20d4038..3fdefdd 100644
--- a/core/wma/src/wma_data.c
+++ b/core/wma/src/wma_data.c
@@ -737,6 +737,27 @@
 	return ret;
 }
 
+tTxrateinfoflags wma_get_vht_rate_flags(enum phy_ch_width ch_width)
+{
+	tTxrateinfoflags rate_flags = 0;
+
+	if (ch_width == CH_WIDTH_80P80MHZ)
+		rate_flags |= eHAL_TX_RATE_VHT80 | eHAL_TX_RATE_VHT40 |
+				eHAL_TX_RATE_VHT20;
+	if (ch_width == CH_WIDTH_160MHZ)
+		rate_flags |= eHAL_TX_RATE_VHT80 | eHAL_TX_RATE_VHT40 |
+				eHAL_TX_RATE_VHT20;
+	if (ch_width == CH_WIDTH_80MHZ)
+		rate_flags |= eHAL_TX_RATE_VHT80 | eHAL_TX_RATE_VHT40 |
+				eHAL_TX_RATE_VHT20;
+	else if (ch_width)
+		rate_flags |= eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_VHT20;
+	else
+		rate_flags |= eHAL_TX_RATE_VHT20;
+
+	return rate_flags;
+}
+
 /**
  * wma_set_bss_rate_flags() - set rate flags based on BSS capability
  * @iface: txrx_node ctx
@@ -750,16 +771,7 @@
 	iface->rate_flags = 0;
 
 	if (add_bss->vhtCapable) {
-		if (add_bss->ch_width == CH_WIDTH_80P80MHZ)
-			iface->rate_flags |= eHAL_TX_RATE_VHT80;
-		if (add_bss->ch_width == CH_WIDTH_160MHZ)
-			iface->rate_flags |= eHAL_TX_RATE_VHT80;
-		if (add_bss->ch_width == CH_WIDTH_80MHZ)
-			iface->rate_flags |= eHAL_TX_RATE_VHT80;
-		else if (add_bss->ch_width)
-			iface->rate_flags |= eHAL_TX_RATE_VHT40;
-		else
-			iface->rate_flags |= eHAL_TX_RATE_VHT20;
+		iface->rate_flags = wma_get_vht_rate_flags(add_bss->ch_width);
 	}
 	/* avoid to conflict with htCapable flag */
 	else if (add_bss->htCapable) {