qcacld-3.0: Set wlan phy mode in OEM channel info response

qcacld-2.0 to qcacld-3.0 propagation

Calculate and add wlan phy mode for each channel in OEM channel
info response.
Also send ANI_MSG_PEER_STATUS_IND indication for STA mode when
STA gets connected.

Change-Id: I91363e90698cabda72028135eb7fe9adeb1fbc86
CRs-Fixed: 1007004
diff --git a/core/hdd/src/wlan_hdd_oemdata.c b/core/hdd/src/wlan_hdd_oemdata.c
index c3d4ec7..7452022 100644
--- a/core/hdd/src/wlan_hdd_oemdata.c
+++ b/core/hdd/src/wlan_hdd_oemdata.c
@@ -415,6 +415,45 @@
 }
 
 /**
+ * update_channel_bw_info() - set bandwidth info for the chan
+ * @hdd_ctx: hdd context
+ * @chan: channel for which info are required
+ * @hdd_chan_info: struct where the bandwidth info is filled
+ *
+ * This function find the maximum bandwidth allowed, secondary
+ * channel offset and center freq for the channel as per regulatory
+ * domain and using these info calculate the phy mode for the
+ * channel.
+ *
+ * Return: void
+ */
+static void hdd_update_channel_bw_info(hdd_context_t *hdd_ctx,
+	uint16_t chan, tHddChannelInfo *hdd_chan_info)
+{
+	struct ch_params_s ch_params = {0};
+	uint16_t sec_ch_2g = 0;
+	WLAN_PHY_MODE phy_mode;
+	uint32_t wni_dot11_mode;
+
+	wni_dot11_mode = sme_get_wni_dot11_mode(hdd_ctx->hHal);
+
+	/* Passing CH_WIDTH_MAX will give the max bandwidth supported */
+	ch_params.ch_width = CH_WIDTH_MAX;
+
+	cds_set_channel_params(chan, sec_ch_2g, &ch_params);
+	if (ch_params.center_freq_seg0)
+		hdd_chan_info->band_center_freq1 =
+			cds_chan_to_freq(ch_params.center_freq_seg0);
+
+	hdd_info("chan %d dot11_mode %d ch_width %d sec offset %d freq_seg0 %d",
+		chan, wni_dot11_mode, ch_params.ch_width,
+		ch_params.sec_ch_offset, hdd_chan_info->band_center_freq1);
+
+	phy_mode = wma_chan_phy_mode(chan, ch_params.ch_width, wni_dot11_mode);
+	WMI_SET_CHANNEL_MODE(hdd_chan_info, phy_mode);
+}
+
+/**
  * oem_process_channel_info_req_msg() - process oem channel_info request
  * @numOfChannels: number of channels
  * @chanList: list of channel information
@@ -494,6 +533,9 @@
 			    cds_get_channel_state(chanId))
 				WMI_SET_CHANNEL_FLAG(&hddChanInfo,
 						     WMI_CHAN_FLAG_DFS);
+
+			hdd_update_channel_bw_info(p_hdd_ctx,
+						chanId, &hddChanInfo);
 			hddChanInfo.reg_info_1 = reg_info_1;
 			hddChanInfo.reg_info_2 = reg_info_2;
 		} else {
@@ -655,12 +697,13 @@
 
 /**
  * hdd_send_peer_status_ind_to_oem_app() -
- *	Function to send peer status to a registered application
+ * Function to send peer status to a registered application
  * @peerMac: MAC address of peer
  * @peerStatus: ePeerConnected or ePeerDisconnected
  * @peerTimingMeasCap: 0: RTT/RTT2, 1: RTT3. Default is 0
  * @sessionId: SME session id, i.e. vdev_id
  * @chan_info: operating channel information
+ * @dev_mode: dev mode for which indication is sent
  *
  * Return: none
  */
@@ -668,7 +711,8 @@
 					 uint8_t peerStatus,
 					 uint8_t peerTimingMeasCap,
 					 uint8_t sessionId,
-					 tSirSmeChanInfo *chan_info)
+					 tSirSmeChanInfo *chan_info,
+					 enum tQDF_ADAPTER_MODE dev_mode)
 {
 	struct sk_buff *skb;
 	struct nlmsghdr *nlh;
@@ -719,6 +763,9 @@
 	pPeerInfo->vdev_id = sessionId;
 	pPeerInfo->peer_capability = peerTimingMeasCap;
 	pPeerInfo->reserved0 = 0;
+	/* Set 0th bit of reserved0 for STA mode */
+	if (QDF_STA_MODE == dev_mode)
+		pPeerInfo->reserved0 |= 0x01;
 
 	if (chan_info) {
 		pPeerInfo->peer_chan_info.chan_id = chan_info->chan_id;