Pārlūkot izejas kodu

qcacmn: Add support for BE monitor buf processing

Add support for BE monitor buffer processing

Change-Id: I2b7563e7a2c4d7e091ed093774b4f24047791708
CRs-Fixed: 3010502
Naga 3 gadi atpakaļ
vecāks
revīzija
5475a38feb

+ 98 - 8
dp/wifi3.0/monitor/2.0/dp_rx_mon_2.0.c

@@ -14,15 +14,105 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <dp_types.h>
-#include "dp_rx.h"
-#include "dp_peer.h"
-#include <dp_htt.h>
-#include <dp_mon_filter.h>
-#include <dp_mon.h>
-#include <dp_rx_mon.h>
-#include <dp_rx_mon_2.0.h>
+#include "hal_be_hw_headers.h"
+#include "dp_types.h"
+#include "hal_be_rx.h"
+#include "hal_api.h"
+#include "qdf_trace.h"
+#include "hal_be_api_mon.h"
+#include "dp_internal.h"
+#include "qdf_mem.h"   /* qdf_mem_malloc,free */
+#include "dp_mon.h"
 #include <dp_mon_2.0.h>
+#include <dp_rx_mon_2.0.h>
+#include <dp_be.h>
+#include <hal_be_api_mon.h>
+
+static inline uint32_t
+dp_rx_mon_srng_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
+			   uint32_t mac_id, uint32_t quota)
+{
+	struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
+	void *rx_mon_dst_ring_desc;
+	hal_soc_handle_t hal_soc;
+	void *mon_dst_srng;
+	struct dp_mon_pdev *mon_pdev;
+	struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
+	struct dp_mon_soc_be *monitor_soc = be_soc->monitor_soc_be;
+	uint32_t work_done = 0;
+
+	if (!pdev) {
+		dp_mon_err("%pK: pdev is null for mac_id = %d", soc, mac_id);
+		return work_done;
+	}
+
+	mon_pdev = pdev->monitor_pdev;
+	mon_dst_srng = soc->rxdma_mon_dst_ring[mac_id].hal_srng;
+
+	if (!mon_dst_srng || !hal_srng_initialized(mon_dst_srng)) {
+		dp_mon_err("%pK: : HAL Monitor Destination Ring Init Failed -- %pK",
+			   soc, mon_dst_srng);
+		return work_done;
+	}
+
+	hal_soc = soc->hal_soc;
+
+	qdf_assert((hal_soc && pdev));
+
+	qdf_spin_lock_bh(&mon_pdev->mon_lock);
+
+	if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, mon_dst_srng))) {
+		dp_mon_err("%s %d : HAL Mon Dest Ring access Failed -- %pK",
+			   __func__, __LINE__, mon_dst_srng);
+		qdf_spin_unlock_bh(&mon_pdev->mon_lock);
+		return work_done;
+	}
+
+	while (qdf_likely((rx_mon_dst_ring_desc =
+			  (void *)hal_srng_dst_get_next(hal_soc, mon_dst_srng))
+				&& quota--)) {
+		struct hal_mon_desc hal_mon_rx_desc;
+		struct dp_mon_desc *mon_desc;
+		struct dp_mon_desc_pool *rx_desc_pool;
+
+		rx_desc_pool = &monitor_soc->rx_desc_mon;
+		hal_mon_buf_get(soc->hal_soc,
+				rx_mon_dst_ring_desc,
+				&hal_mon_rx_desc);
+		mon_desc = (struct dp_mon_desc *)(uintptr_t)(hal_mon_rx_desc.buf_addr);
+		qdf_assert_always(mon_desc);
+
+		if (!mon_desc->unmapped) {
+			qdf_mem_unmap_page(soc->osdev, mon_desc->paddr,
+					   QDF_DMA_FROM_DEVICE,
+					   rx_desc_pool->buf_size);
+			mon_desc->unmapped = 1;
+		}
+
+		dp_rx_mon_process_status_tlv(soc, pdev,
+					     &hal_mon_rx_desc,
+					     mon_desc->paddr);
+
+		qdf_frag_free(mon_desc->buf_addr);
+		work_done++;
+	}
+	dp_srng_access_end(int_ctx, soc, mon_dst_srng);
+
+	qdf_spin_unlock_bh(&mon_pdev->mon_lock);
+	dp_mon_info("mac_id: %d, work_done:%d", mac_id, work_done);
+	return work_done;
+}
+
+uint32_t
+dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
+		      uint32_t mac_id, uint32_t quota)
+{
+	uint32_t work_done;
+
+	work_done = dp_rx_mon_srng_process_2_0(soc, int_ctx, mac_id, quota);
+
+	return work_done;
+}
 
 void
 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc)

+ 16 - 0
dp/wifi3.0/monitor/2.0/dp_rx_mon_2.0.h

@@ -17,6 +17,9 @@
 #ifndef _DP_RX_MON_2_0_H_
 #define _DP_RX_MON_2_0_H_
 
+#include <qdf_nbuf_frag.h>
+#include <hal_be_api_mon.h>
+
 /*
  * dp_rx_mon_buffers_alloc() - allocate rx monitor buffers
  * @soc: DP soc handle
@@ -70,4 +73,17 @@ void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc);
 QDF_STATUS
 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc);
 
+/*
+ * dp_rx_mon_process_status_tlv() - process status tlv
+ * @soc: dp soc handle
+ * @pdev: dp pdev handle
+ * @mon_ring_desc: HAL monitor ring descriptor
+ * @frag_addr: frag address
+ *
+ */
+void dp_rx_mon_process_status_tlv(struct dp_soc *soc,
+				  struct dp_pdev *pdev,
+				  struct hal_mon_desc *mon_ring_desc,
+				  qdf_dma_addr_t addr);
+
 #endif /* _DP_RX_MON_2_0_H_ */

+ 17 - 0
dp/wifi3.0/monitor/2.0/dp_rx_mon_status_2.0.c

@@ -13,3 +13,20 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "dp_types.h"
+#include "qdf_nbuf.h"
+#include "dp_internal.h"
+#include "qdf_mem.h"   /* qdf_mem_malloc,free */
+#include <qdf_nbuf_frag.h>
+#include <hal_be_api_mon.h>
+#include <dp_mon.h>
+#include <dp_mon_2.0.h>
+#include <dp_rx_mon_2.0.h>
+
+void dp_rx_mon_process_status_tlv(struct dp_soc *soc,
+				  struct dp_pdev *pdev,
+				  struct hal_mon_desc *mon_ring_desc,
+				  qdf_dma_addr_t addr)
+{
+	/* API to process status tlv */
+}

+ 98 - 7
dp/wifi3.0/monitor/2.0/dp_tx_mon_2.0.c

@@ -14,14 +14,105 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <dp_types.h>
-#include "dp_tx.h"
-#include "dp_peer.h"
-#include <dp_htt.h>
-#include <dp_mon_filter.h>
-#include <dp_mon.h>
-#include <dp_tx_mon_2.0.h>
+#include "hal_be_hw_headers.h"
+#include "dp_types.h"
+#include "hal_be_tx.h"
+#include "hal_api.h"
+#include "qdf_trace.h"
+#include "hal_be_api_mon.h"
+#include "dp_internal.h"
+#include "qdf_mem.h"   /* qdf_mem_malloc,free */
+#include "dp_mon.h"
 #include <dp_mon_2.0.h>
+#include <dp_tx_mon_2.0.h>
+#include <dp_be.h>
+#include <hal_be_api_mon.h>
+
+static inline uint32_t
+dp_tx_mon_srng_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
+			   uint32_t mac_id, uint32_t quota)
+{
+	struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
+	void *tx_mon_dst_ring_desc;
+	hal_soc_handle_t hal_soc;
+	void *mon_dst_srng;
+	struct dp_mon_pdev *mon_pdev;
+	uint32_t work_done = 0;
+	struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
+	struct dp_mon_soc_be *monitor_soc = be_soc->monitor_soc_be;
+
+	if (!pdev) {
+		dp_mon_err("%pK: pdev is null for mac_id = %d", soc, mac_id);
+		return work_done;
+	}
+
+	mon_pdev = pdev->monitor_pdev;
+	mon_dst_srng = monitor_soc->tx_mon_dst_ring[mac_id].hal_srng;
+
+	if (!mon_dst_srng || !hal_srng_initialized(mon_dst_srng)) {
+		dp_mon_err("%pK: : HAL Monitor Destination Ring Init Failed -- %pK",
+			   soc, mon_dst_srng);
+		return work_done;
+	}
+
+	hal_soc = soc->hal_soc;
+
+	qdf_assert((hal_soc && pdev));
+
+	qdf_spin_lock_bh(&mon_pdev->mon_lock);
+
+	if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, mon_dst_srng))) {
+		dp_mon_err("%s %d : HAL Mon Dest Ring access Failed -- %pK",
+			   __func__, __LINE__, mon_dst_srng);
+		qdf_spin_unlock_bh(&mon_pdev->mon_lock);
+		return work_done;
+	}
+
+	while (qdf_likely((tx_mon_dst_ring_desc =
+		(void *)hal_srng_dst_get_next(hal_soc, mon_dst_srng))
+				&& quota--)) {
+		struct hal_mon_desc hal_mon_tx_desc;
+		struct dp_mon_desc *mon_desc;
+		struct dp_mon_desc_pool *tx_desc_pool;
+
+		tx_desc_pool = &monitor_soc->tx_desc_mon;
+		hal_mon_buf_get(soc->hal_soc,
+				tx_mon_dst_ring_desc,
+				&hal_mon_tx_desc);
+		mon_desc = (struct dp_mon_desc *)(uintptr_t)(hal_mon_tx_desc.buf_addr);
+		qdf_assert_always(mon_desc);
+
+		if (!mon_desc->unmapped) {
+			qdf_mem_unmap_page(soc->osdev, mon_desc->paddr,
+					   QDF_DMA_FROM_DEVICE,
+					   tx_desc_pool->buf_size);
+			mon_desc->unmapped = 1;
+		}
+
+		dp_tx_mon_process_status_tlv(soc, pdev,
+					     &hal_mon_tx_desc,
+					     mon_desc->paddr);
+
+		qdf_frag_free(mon_desc->buf_addr);
+		work_done++;
+	}
+	dp_srng_access_end(int_ctx, soc, mon_dst_srng);
+
+	qdf_spin_unlock_bh(&mon_pdev->mon_lock);
+	dp_mon_info("mac_id: %d, work_done:%d", mac_id, work_done);
+	return work_done;
+}
+
+uint32_t
+dp_tx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
+		      uint32_t mac_id, uint32_t quota)
+{
+	uint32_t work_done;
+
+	work_done = dp_tx_mon_srng_process_2_0(soc, int_ctx, mac_id, quota);
+
+	return work_done;
+}
 
 void
 dp_tx_mon_buf_desc_pool_deinit(struct dp_soc *soc)

+ 16 - 0
dp/wifi3.0/monitor/2.0/dp_tx_mon_2.0.h

@@ -17,6 +17,9 @@
 #ifndef _DP_TX_MON_2_0_H_
 #define _DP_TX_MON_2_0_H_
 
+#include <qdf_nbuf_frag.h>
+#include <hal_be_api_mon.h>
+
 /*
  * dp_tx_mon_buffers_alloc() - allocate tx monitor buffers
  * @soc: DP soc handle
@@ -70,4 +73,17 @@ void dp_tx_mon_buf_desc_pool_free(struct dp_soc *soc);
 QDF_STATUS
 dp_tx_mon_buf_desc_pool_alloc(struct dp_soc *soc);
 
+/*
+ * dp_tx_mon_process_status_tlv() - process status tlv
+ * @soc: dp soc handle
+ * @pdev: dp pdev handle
+ * @mon_ring_desc: monitor ring descriptor
+ * @frag_addr: frag address
+ *
+ */
+void dp_tx_mon_process_status_tlv(struct dp_soc *soc,
+				  struct dp_pdev *pdev,
+				  struct hal_mon_desc *mon_ring_desc,
+				  qdf_dma_addr_t addr);
+
 #endif /* _DP_TX_MON_2_0_H_ */

+ 17 - 0
dp/wifi3.0/monitor/2.0/dp_tx_mon_status_2.0.c

@@ -13,3 +13,20 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "dp_types.h"
+#include "qdf_nbuf.h"
+#include "dp_internal.h"
+#include "qdf_mem.h"   /* qdf_mem_malloc,free */
+#include <qdf_nbuf_frag.h>
+#include <hal_be_api_mon.h>
+#include <dp_mon.h>
+#include <dp_mon_2.0.h>
+#include <dp_tx_mon_2.0.h>
+
+void dp_tx_mon_process_status_tlv(struct dp_soc *soc,
+				  struct dp_pdev *pdev,
+				  struct hal_mon_desc *mon_ring_desc,
+				  qdf_dma_addr_t addr)
+{
+	/* API to process tlv */
+}