qca-wifi: Componentize Multicast Enhancement

Remove dependency of ME on VAP layer and radio(ic) layer data
structures

Change-Id: Ic1e93204e02083fb90e879a7c5f41c8ee7376c14
CRs-Fixed: 2580389
diff --git a/dp/wifi3.0/dp_txrx_me.c b/dp/wifi3.0/dp_txrx_me.c
index 8587ae3..e1c9d33 100644
--- a/dp/wifi3.0/dp_txrx_me.c
+++ b/dp/wifi3.0/dp_txrx_me.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -171,11 +171,12 @@
 {
 	struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
 
-	qdf_atomic_dec(&pdev->mc_num_vap_attached);
-	if (atomic_read(&pdev->mc_num_vap_attached) == 0) {
-		dp_tx_me_exit(pdev);
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
-			  "Disable MCAST_TO_UCAST");
+	if (atomic_read(&pdev->mc_num_vap_attached)) {
+		if (qdf_atomic_dec_and_test(&pdev->mc_num_vap_attached)) {
+			dp_tx_me_exit(pdev);
+			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
+				  "Disable MCAST_TO_UCAST");
+		}
 	}
 }
 
@@ -189,10 +190,10 @@
 QDF_STATUS
 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
 {
-	if (vdev->me_convert) {
-		if (vdev->me_convert(vdev->osif_vdev, nbuf) > 0)
-			return QDF_STATUS_SUCCESS;
-	}
+	if (dp_me_mcast_convert((struct cdp_soc_t *)(vdev->pdev->soc),
+				vdev->vdev_id, vdev->pdev->pdev_id,
+				nbuf) > 0)
+		return QDF_STATUS_SUCCESS;
 
 	return QDF_STATUS_E_FAILURE;
 }
@@ -231,7 +232,8 @@
 
 /**
  * dp_tx_me_send_convert_ucast(): function to convert multicast to unicast
- * @vdev: DP VDEV handle
+ * @soc: Datapath soc handle
+ * @vdev_id: vdev id
  * @nbuf: Multicast nbuf
  * @newmac: Table of the clients to which packets have to be sent
  * @new_mac_cnt: No of clients
@@ -239,11 +241,13 @@
  * return: no of converted packets
  */
 uint16_t
-dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle, qdf_nbuf_t nbuf,
-		uint8_t newmac[][QDF_MAC_ADDR_SIZE], uint8_t new_mac_cnt)
+dp_tx_me_send_convert_ucast(ol_txrx_soc_handle soc, uint8_t vdev_id,
+			    qdf_nbuf_t nbuf,
+			    uint8_t newmac[][QDF_MAC_ADDR_SIZE],
+			    uint8_t new_mac_cnt)
 {
-	struct dp_vdev *vdev = (struct dp_vdev *) vdev_handle;
-	struct dp_pdev *pdev = vdev->pdev;
+	struct dp_vdev *vdev;
+	struct dp_pdev *pdev;
 	qdf_ether_header_t *eh;
 	uint8_t *data;
 	uint16_t len;
@@ -266,6 +270,16 @@
 	uint8_t empty_entry_mac[QDF_MAC_ADDR_SIZE] = {0};
 	QDF_STATUS status;
 
+	vdev = dp_get_vdev_from_soc_vdev_id_wifi3((struct dp_soc *)soc,
+						  vdev_id);
+	if (!vdev)
+		return 1;
+
+	pdev = vdev->pdev;
+
+	if (!pdev)
+		return 1;
+
 	qdf_mem_zero(&msdu_info, sizeof(msdu_info));
 
 	dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
diff --git a/dp/wifi3.0/dp_txrx_me.h b/dp/wifi3.0/dp_txrx_me.h
index 9c7601e..7262723 100644
--- a/dp/wifi3.0/dp_txrx_me.h
+++ b/dp/wifi3.0/dp_txrx_me.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -17,7 +17,7 @@
  */
 #ifndef _DP_TXRX_ME_H_
 #define _DP_TXRX_ME_H_
-uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle,
+uint16_t dp_tx_me_send_convert_ucast(ol_txrx_soc_handle soc, uint8_t vdev_id,
 				     qdf_nbuf_t nbuf,
 				     uint8_t newmac[][QDF_MAC_ADDR_SIZE],
 				     uint8_t new_mac_cnt);
@@ -27,4 +27,9 @@
 void dp_tx_me_exit(struct dp_pdev *pdev);
 QDF_STATUS
 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
+extern int
+dp_me_mcast_convert(struct cdp_soc_t *soc,
+		    uint8_t vdev_id,
+		    uint8_t pdev_id,
+		    qdf_nbuf_t wbuf);
 #endif