wlan: Redirect third party rx traffic to monitor interface

In STA + Monitor SCC, firmware can indicate third party rx traffic to
host with valid sta_id.

To handle this, add check for addr1 index and redirect traffic to
monitor interface if index is 254.

Note: Third party traffic here refers to data frames in which unicast
DA is other than self-sta mac address.

Change-Id: I5ab4e259e91a9276dadade37ea4bacacfa6d7b75
CRs-Fixed: 2184141
diff --git a/CORE/TL/src/wlan_qct_tl.c b/CORE/TL/src/wlan_qct_tl.c
index dd995b6..91f1ba6 100644
--- a/CORE/TL/src/wlan_qct_tl.c
+++ b/CORE/TL/src/wlan_qct_tl.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -6176,13 +6176,24 @@
    tpSirMacMgmtHdr pHdr = NULL;
    v_MACADDR_t *peerMacAddr = NULL;
    uint8_t i = 0;
-
-   if (vos_check_monitor_state() == false || WLANTL_STA_ID_MONIFACE(sta_id) == 0)
-      return false;
+   uint8_t addr1_index = WDA_GET_RX_ADDR1_IDX(pRxMetadata);
+   bool tp_data = false;
 
    pHdr = (tpSirMacMgmtHdr)pRxMetadata->mpduHeaderPtr;
+   peerMacAddr = (v_MACADDR_t *)pHdr->da;
 
-   if (WLANTL_IS_MGMT_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata))) {
+   if (vos_check_monitor_state() == false)
+       return false;
+
+   if ((addr1_index == 254) &&
+       WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) &&
+       !pRxMetadata->bcast) {
+       tp_data = true;
+   } else if (WLANTL_STA_ID_MONIFACE(sta_id) == 0) {
+       return false;
+   }
+
+   if (WLANTL_IS_MGMT_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) || tp_data) {
 
       if (pRxMetadata->bcast)
          return false;
@@ -6196,15 +6207,21 @@
             break;
       }
 
-      if (i == WLAN_MAX_STA_COUNT)
+      if (i == WLAN_MAX_STA_COUNT) {
+          if (tp_data)
+              return true;
+
          return false;
+      }
 
       pClientSTA = pTLCb->atlSTAClients[i];
-      peerMacAddr = (v_MACADDR_t *)pHdr->da;
 
       if (vos_is_macaddr_equal(peerMacAddr,
-          &pClientSTA->wSTADesc.vSelfMACAddress) ||
-          vos_is_macaddr_equal(peerMacAddr, &pTLCb->spoofMacAddr.spoofMac))
+          &pClientSTA->wSTADesc.vSelfMACAddress))
+         return false;
+
+      if (vos_is_macaddr_equal(peerMacAddr, &pTLCb->spoofMacAddr.spoofMac) &&
+          !tp_data)
           return false;
    }
 
diff --git a/CORE/WDA/inc/wlan_qct_wda.h b/CORE/WDA/inc/wlan_qct_wda.h
index 25ee44f..9a9a765 100644
--- a/CORE/WDA/inc/wlan_qct_wda.h
+++ b/CORE/WDA/inc/wlan_qct_wda.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -722,6 +722,9 @@
 /* WDA_GET_RX_ADDR3_IDX ******************************************************/
 #  define WDA_GET_RX_ADDR3_IDX(pRxMeta) (((WDI_DS_RxMetaInfoType*)(pRxMeta))->addr3Idx)
 
+/* WDA_GET_RX_ADDR1_IDX ******************************************************/
+#  define WDA_GET_RX_ADDR1_IDX(pRxMeta) (((WDI_DS_RxMetaInfoType*)(pRxMeta))->addr1Idx)
+
 /* WDA_GET_RX_CH *************************************************************/
 #  define WDA_GET_RX_CH(pRxMeta) (((WDI_DS_RxMetaInfoType*)(pRxMeta))->rxChannel)
 
diff --git a/CORE/WDI/DP/inc/wlan_qct_wdi_ds.h b/CORE/WDI/DP/inc/wlan_qct_wdi_ds.h
index 4f88b99..5745f2e 100644
--- a/CORE/WDI/DP/inc/wlan_qct_wdi_ds.h
+++ b/CORE/WDI/DP/inc/wlan_qct_wdi_ds.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, 2016-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -176,6 +176,7 @@
 #endif
    wpt_uint32 loggingData;
    wpt_uint32 indType;
+   wpt_uint8 addr1Idx;
 } WDI_DS_RxMetaInfoType;
 
 typedef struct sPktMetaInfo
diff --git a/CORE/WDI/TRP/DTS/src/wlan_qct_wdi_dts.c b/CORE/WDI/TRP/DTS/src/wlan_qct_wdi_dts.c
index 3708bfb..bc18282 100644
--- a/CORE/WDI/TRP/DTS/src/wlan_qct_wdi_dts.c
+++ b/CORE/WDI/TRP/DTS/src/wlan_qct_wdi_dts.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -856,6 +856,7 @@
       pRxMetadata->fc = isFcBd;
       pRxMetadata->staId = WDI_RX_BD_GET_STA_ID(pBDHeader);
       pRxMetadata->addr3Idx = WDI_RX_BD_GET_ADDR3_IDX(pBDHeader);
+      pRxMetadata->addr1Idx = WDI_RX_BD_GET_ADDR1_IDX(pBDHeader);
       pRxMetadata->rxChannel = WDI_RX_BD_GET_RX_CHANNEL(pBDHeader);
       pRxMetadata->rfBand = WDI_RX_BD_GET_RFBAND(pBDHeader);
       pRxMetadata->rtsf = WDI_RX_BD_GET_RTSF(pBDHeader);