Browse Source

qcacmn: Change buffer replenishment model for SDX+Pine

For IPQ products, there is 1 refill ring which is of hardware type
and host replenishes the buffers onto this ring so that hardware can
use these buffers for Rx.

In IPA offload mode, the buffer replenishment model is different from
the one mentioned above. There are 3 refill rings, out of which,
2 are software refill rings (1 for host and 1 for IPA), and last ring
is hardware ring given to FW.
Ring given to IPA is to refill the buffers after processing the
regular Rx packets and ring given to host is to refill the buffers
after processing of exception packets. Since there are 2 entities to
refill the buffers, the hardware ring given to FW multiplexes these 2
software rings and provides the buffers to hardware.

Make changes to follow above replenishment model for SDX+Pine
integration.

Change-Id: I0d9e4ec811a3023a258e0a6b9ee22ccdffcebafa
CRs-Fixed: 3049633
Devender Kumar 3 năm trước cách đây
mục cha
commit
30482aa5c4

+ 4 - 2
dp/wifi3.0/dp_htt.c

@@ -437,12 +437,14 @@ int htt_srng_setup(struct htt_soc *soc, int mac_id,
 	case RXDMA_BUF:
 #ifdef QCA_HOST2FW_RXBUF_RING
 		if (srng_params.ring_id ==
-		    (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0)) {
+		    (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
+		    (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
 			htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
 			htt_ring_type = HTT_SW_TO_SW_RING;
 #ifdef IPA_OFFLOAD
 		} else if (srng_params.ring_id ==
-		    (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2)) {
+		    (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 +
+		    (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
 			htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
 			htt_ring_type = HTT_SW_TO_SW_RING;
 #endif

+ 157 - 70
dp/wifi3.0/dp_main.c

@@ -4505,15 +4505,69 @@ static QDF_STATUS dp_lro_hash_setup(struct dp_soc *soc, struct dp_pdev *pdev)
 	return status;
 }
 
+#if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
+/*
+ * dp_reap_timer_init() - initialize the reap timer
+ * @soc: data path SoC handle
+ *
+ * Return: void
+ */
+static void dp_reap_timer_init(struct dp_soc *soc)
+{
+	/*
+	 * Timer to reap rxdma status rings.
+	 * Needed until we enable ppdu end interrupts
+	 */
+	dp_monitor_reap_timer_init(soc);
+	dp_monitor_vdev_timer_init(soc);
+}
+
+/*
+ * dp_reap_timer_deinit() - de-initialize the reap timer
+ * @soc: data path SoC handle
+ *
+ * Return: void
+ */
+static void dp_reap_timer_deinit(struct dp_soc *soc)
+{
+	dp_monitor_reap_timer_deinit(soc);
+}
+#else
+/* WIN use case */
+static void dp_reap_timer_init(struct dp_soc *soc)
+{
+	/* Configure LMAC rings in Polled mode */
+	if (soc->lmac_polled_mode) {
+		/*
+		 * Timer to reap lmac rings.
+		 */
+		qdf_timer_init(soc->osdev, &soc->lmac_reap_timer,
+			       dp_service_lmac_rings, (void *)soc,
+			       QDF_TIMER_TYPE_WAKE_APPS);
+		soc->lmac_timer_init = 1;
+		qdf_timer_mod(&soc->lmac_reap_timer, DP_INTR_POLL_TIMER_MS);
+	}
+}
+
+static void dp_reap_timer_deinit(struct dp_soc *soc)
+{
+	if (soc->lmac_timer_init) {
+		qdf_timer_stop(&soc->lmac_reap_timer);
+		qdf_timer_free(&soc->lmac_reap_timer);
+		soc->lmac_timer_init = 0;
+	}
+}
+#endif
+
+#ifdef QCA_HOST2FW_RXBUF_RING
 /*
- * dp_rxdma_ring_setup() - configure the RX DMA rings
+ * dp_rxdma_ring_alloc() - allocate the RXDMA rings
  * @soc: data path SoC handle
  * @pdev: Physical device handle
  *
  * Return: 0 - success, > 0 - failure
  */
-#ifdef QCA_HOST2FW_RXBUF_RING
-static int dp_rxdma_ring_setup(struct dp_soc *soc, struct dp_pdev *pdev)
+static int dp_rxdma_ring_alloc(struct dp_soc *soc, struct dp_pdev *pdev)
 {
 	struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
 	int max_mac_rings;
@@ -4531,22 +4585,87 @@ static int dp_rxdma_ring_setup(struct dp_soc *soc, struct dp_pdev *pdev)
 			dp_init_err("%pK: failed rx mac ring setup", soc);
 			return QDF_STATUS_E_FAILURE;
 		}
+	}
+	return QDF_STATUS_SUCCESS;
+}
+
+/*
+ * dp_rxdma_ring_setup() - configure the RXDMA rings
+ * @soc: data path SoC handle
+ * @pdev: Physical device handle
+ *
+ * Return: 0 - success, > 0 - failure
+ */
+static int dp_rxdma_ring_setup(struct dp_soc *soc, struct dp_pdev *pdev)
+{
+	struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
+	int max_mac_rings;
+	int i;
+
+	pdev_cfg_ctx = pdev->wlan_cfg_ctx;
+	max_mac_rings = wlan_cfg_get_num_mac_rings(pdev_cfg_ctx);
 
+	for (i = 0; i < max_mac_rings; i++) {
+		dp_verbose_debug("pdev_id %d mac_id %d", pdev->pdev_id, i);
 		if (dp_srng_init(soc, &pdev->rx_mac_buf_ring[i],
 				 RXDMA_BUF, 1, i)) {
 			dp_init_err("%pK: failed rx mac ring setup", soc);
-
-			dp_srng_free(soc, &pdev->rx_mac_buf_ring[i]);
 			return QDF_STATUS_E_FAILURE;
 		}
 	}
 	return QDF_STATUS_SUCCESS;
 }
+
+/*
+ * dp_rxdma_ring_cleanup() - Deinit the RXDMA rings and reap timer
+ * @soc: data path SoC handle
+ * @pdev: Physical device handle
+ *
+ * Return: void
+ */
+static void dp_rxdma_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev)
+{
+	int i;
+
+	for (i = 0; i < MAX_RX_MAC_RINGS; i++)
+		dp_srng_deinit(soc, &pdev->rx_mac_buf_ring[i], RXDMA_BUF, 1);
+
+	dp_reap_timer_deinit(soc);
+}
+
+/*
+ * dp_rxdma_ring_free() - Free the RXDMA rings
+ * @pdev: Physical device handle
+ *
+ * Return: void
+ */
+static void dp_rxdma_ring_free(struct dp_pdev *pdev)
+{
+	int i;
+
+	for (i = 0; i < MAX_RX_MAC_RINGS; i++)
+		dp_srng_free(pdev->soc, &pdev->rx_mac_buf_ring[i]);
+}
+
 #else
+static int dp_rxdma_ring_alloc(struct dp_soc *soc, struct dp_pdev *pdev)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
 static int dp_rxdma_ring_setup(struct dp_soc *soc, struct dp_pdev *pdev)
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+static void dp_rxdma_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev)
+{
+	dp_reap_timer_deinit(soc);
+}
+
+static void dp_rxdma_ring_free(struct dp_pdev *pdev)
+{
+}
 #endif
 
 /**
@@ -4907,6 +5026,12 @@ static inline QDF_STATUS dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
 		goto fail2;
 	}
 
+	/* Allocate memory for pdev rxdma rings */
+	if (dp_rxdma_ring_alloc(soc, pdev)) {
+		dp_init_err("%pK: dp_rxdma_ring_alloc failed", soc);
+		goto fail3;
+	}
+
 	/* Rx specific init */
 	if (dp_rx_pdev_desc_pool_alloc(pdev)) {
 		dp_init_err("%pK: dp_rx_pdev_attach failed", soc);
@@ -4922,6 +5047,7 @@ static inline QDF_STATUS dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
 fail4:
 	dp_rx_pdev_desc_pool_free(pdev);
 fail3:
+	dp_rxdma_ring_free(pdev);
 	dp_pdev_srng_free(pdev);
 fail2:
 	wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx);
@@ -4932,35 +5058,7 @@ fail0:
 	return QDF_STATUS_E_FAILURE;
 }
 
-/*
- * dp_rxdma_ring_cleanup() - configure the RX DMA rings
- * @soc: data path SoC handle
- * @pdev: Physical device handle
- *
- * Return: void
- */
-#ifdef QCA_HOST2FW_RXBUF_RING
-static void dp_rxdma_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev)
-{
-	int i;
-
-	for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
-		dp_srng_deinit(soc, &pdev->rx_mac_buf_ring[i], RXDMA_BUF, 1);
-		dp_srng_free(soc, &pdev->rx_mac_buf_ring[i]);
-	}
 
-	dp_monitor_reap_timer_deinit(soc);
-}
-#else
-static void dp_rxdma_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev)
-{
-	if (soc->lmac_timer_init) {
-		qdf_timer_stop(&soc->lmac_reap_timer);
-		qdf_timer_free(&soc->lmac_reap_timer);
-		soc->lmac_timer_init = 0;
-	}
-}
-#endif
 
 #ifdef WLAN_DP_PENDING_MEM_FLUSH
 /**
@@ -5139,6 +5237,7 @@ static void dp_pdev_detach(struct cdp_pdev *txrx_pdev, int force)
 	dp_pdev_htt_stats_dbgfs_deinit(pdev);
 	dp_rx_pdev_desc_pool_free(pdev);
 	dp_monitor_pdev_detach(pdev);
+	dp_rxdma_ring_free(pdev);
 	dp_pdev_srng_free(pdev);
 
 	soc->pdev_count--;
@@ -5459,15 +5558,16 @@ static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
 				(pdev->wlan_cfg_ctx);
 			int lmac_id = dp_get_lmac_id_for_pdev_id(soc, 0, i);
 
-			htt_srng_setup(soc->htt_handle, 0,
+			htt_srng_setup(soc->htt_handle, i,
 				       soc->rx_refill_buf_ring[lmac_id]
 				       .hal_srng,
 				       RXDMA_BUF);
 
 			if (pdev->rx_refill_buf_ring2.hal_srng)
-				htt_srng_setup(soc->htt_handle, 0,
-					pdev->rx_refill_buf_ring2.hal_srng,
-					RXDMA_BUF);
+				htt_srng_setup(soc->htt_handle, i,
+					       pdev->rx_refill_buf_ring2
+					       .hal_srng,
+					       RXDMA_BUF);
 
 			if (soc->cdp_soc.ol_ops->
 				is_hw_dbs_2x2_capable) {
@@ -5513,10 +5613,13 @@ static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
 					 pdev->rx_mac_buf_ring[mac_id]
 						.hal_srng,
 					 RXDMA_BUF);
-				htt_srng_setup(soc->htt_handle, mac_for_pdev,
-				soc->rxdma_err_dst_ring[lmac_id]
-					.hal_srng,
-					RXDMA_DST);
+
+				if (!soc->rxdma2sw_rings_not_supported)
+					htt_srng_setup(soc->htt_handle,
+						       mac_for_pdev,
+						       soc->rxdma_err_dst_ring[lmac_id]
+						       .hal_srng,
+						       RXDMA_DST);
 
 				/* Configure monitor mode rings */
 				status = dp_monitor_htt_srng_setup(soc, pdev,
@@ -5531,12 +5634,7 @@ static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
 		}
 	}
 
-	/*
-	 * Timer to reap rxdma status rings.
-	 * Needed until we enable ppdu end interrupts
-	 */
-	dp_monitor_reap_timer_init(soc);
-	dp_monitor_vdev_timer_init(soc);
+	dp_reap_timer_init(soc);
 	return status;
 }
 #else
@@ -5575,17 +5673,7 @@ static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
 				       RXDMA_DST);
 	}
 
-	/* Configure LMAC rings in Polled mode */
-	if (soc->lmac_polled_mode) {
-		/*
-		 * Timer to reap lmac rings.
-		 */
-		qdf_timer_init(soc->osdev, &soc->lmac_reap_timer,
-			       dp_service_lmac_rings, (void *)soc,
-			       QDF_TIMER_TYPE_WAKE_APPS);
-		soc->lmac_timer_init = 1;
-		qdf_timer_mod(&soc->lmac_reap_timer, DP_INTR_POLL_TIMER_MS);
-	}
+	dp_reap_timer_init(soc);
 	return status;
 }
 #endif
@@ -14022,14 +14110,14 @@ static QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc,
 	}
 
 	if (dp_setup_ipa_rx_refill_buf_ring(soc, pdev))
-		goto fail5;
+		goto fail4;
 
 	if (dp_ipa_ring_resource_setup(soc, pdev))
-		goto fail6;
+		goto fail5;
 
 	if (dp_ipa_uc_attach(soc, pdev) != QDF_STATUS_SUCCESS) {
 		dp_init_err("%pK: dp_ipa_uc_attach failed", soc);
-		goto fail6;
+		goto fail5;
 	}
 
 	ret = dp_rx_fst_attach(soc, pdev);
@@ -14037,18 +14125,18 @@ static QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc,
 	    (ret != QDF_STATUS_E_NOSUPPORT)) {
 		dp_init_err("%pK: RX Flow Search Table attach failed: pdev %d err %d",
 			    soc, pdev_id, ret);
-		goto fail7;
+		goto fail6;
 	}
 
 	if (dp_pdev_bkp_stats_attach(pdev) != QDF_STATUS_SUCCESS) {
 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
 			  FL("dp_pdev_bkp_stats_attach failed"));
-		goto fail8;
+		goto fail7;
 	}
 
 	if (dp_monitor_pdev_init(pdev)) {
 		dp_init_err("%pK: dp_monitor_pdev_init failed\n", soc);
-		goto fail9;
+		goto fail8;
 	}
 
 	/* initialize sw rx descriptors */
@@ -14064,17 +14152,16 @@ static QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc,
 		qdf_skb_total_mem_stats_read());
 
 	return QDF_STATUS_SUCCESS;
-fail9:
-	dp_pdev_bkp_stats_detach(pdev);
 fail8:
-	dp_rx_fst_detach(soc, pdev);
+	dp_pdev_bkp_stats_detach(pdev);
 fail7:
-	dp_ipa_uc_detach(soc, pdev);
+	dp_rx_fst_detach(soc, pdev);
 fail6:
-	dp_cleanup_ipa_rx_refill_buf_ring(soc, pdev);
+	dp_ipa_uc_detach(soc, pdev);
 fail5:
-	dp_rxdma_ring_cleanup(soc, pdev);
+	dp_cleanup_ipa_rx_refill_buf_ring(soc, pdev);
 fail4:
+	dp_rxdma_ring_cleanup(soc, pdev);
 	qdf_nbuf_free(pdev->sojourn_buf);
 fail3:
 	qdf_spinlock_destroy(&pdev->tx_mutex);

+ 3 - 3
dp/wifi3.0/dp_rx.h

@@ -36,11 +36,11 @@
 #define RX_MONITOR_BUFFER_ALIGNMENT     4
 #endif /* RXDMA_OPTIMIZATION */
 
-#ifdef QCA_HOST2FW_RXBUF_RING
+#if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
 #define DP_WBM2SW_RBM(sw0_bm_id)	HAL_RX_BUF_RBM_SW1_BM(sw0_bm_id)
 /* RBM value used for re-injecting defragmented packets into REO */
 #define DP_DEFRAG_RBM(sw0_bm_id)	HAL_RX_BUF_RBM_SW3_BM(sw0_bm_id)
-#endif /* QCA_HOST2FW_RXBUF_RING */
+#endif
 
 #define RX_BUFFER_RESERVATION   0
 
@@ -2020,7 +2020,7 @@ dp_rx_is_list_ready(qdf_nbuf_t nbuf_head,
 }
 #endif
 
-#ifdef QCA_HOST2FW_RXBUF_RING
+#if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
 static inline uint8_t
 dp_rx_get_defrag_bm_id(struct dp_soc *soc)
 {

+ 3 - 2
dp/wifi3.0/li/dp_li.c

@@ -157,6 +157,7 @@ dp_rxdma_ring_sel_cfg_li(struct dp_soc *soc)
 	int i;
 	int mac_id;
 	struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
+	struct dp_srng *rx_mac_srng;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 
 	htt_tlv_filter.mpdu_start = 1;
@@ -220,9 +221,9 @@ dp_rxdma_ring_sel_cfg_li(struct dp_soc *soc)
 				dp_get_lmac_id_for_pdev_id(soc, mac_id,
 							   pdev->pdev_id);
 
+			rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
 			htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
-					    soc->rx_refill_buf_ring[lmac_id].
-					    hal_srng,
+					    rx_mac_srng->hal_srng,
 					    RXDMA_BUF, RX_DATA_BUFFER_SIZE,
 					    &htt_tlv_filter);
 		}

+ 1 - 3
dp/wifi3.0/monitor/1.0/dp_mon_1.0.c

@@ -493,9 +493,7 @@ static void dp_mon_reap_timer_handler(void *arg)
 
 	qdf_timer_mod(&mon_soc->mon_reap_timer, DP_INTR_POLL_TIMER_MS);
 }
-#endif
 
-#ifdef QCA_HOST2FW_RXBUF_RING
 static void dp_mon_reap_timer_init(struct dp_soc *soc)
 {
 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
@@ -630,7 +628,7 @@ static void dp_mon_neighbour_peer_add_ast(struct dp_pdev *pdev,
  *
  * Return: non-zero for failure, zero for success
  */
-#ifdef QCA_HOST2FW_RXBUF_RING
+#if defined(DP_CON_MON)
 static
 QDF_STATUS dp_mon_htt_srng_setup_1_0(struct dp_soc *soc,
 				     struct dp_pdev *pdev,

+ 2 - 2
wlan_cfg/cfg_dp.h

@@ -369,7 +369,7 @@
  * Allocate as many RX descriptors as buffers in the SW2RXDMA
  * ring. This value may need to be tuned later.
  */
-#if defined(QCA_HOST2FW_RXBUF_RING)
+#if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
 #define WLAN_CFG_RX_SW_DESC_WEIGHT_SIZE 1
 #define WLAN_CFG_RX_SW_DESC_WEIGHT_SIZE_MIN 1
 #define WLAN_CFG_RX_SW_DESC_WEIGHT_SIZE_MAX 1
@@ -402,7 +402,7 @@
 #define WLAN_CFG_RX_SW_DESC_NUM_SIZE 12288
 #define WLAN_CFG_RX_SW_DESC_NUM_SIZE_MIN 4096
 #define WLAN_CFG_RX_SW_DESC_NUM_SIZE_MAX 12288
-#endif //QCA_HOST2FW_RXBUF_RING
+#endif
 
 #define WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE 16384
 #define WLAN_CFG_RX_FLOW_SEARCH_TABLE_SIZE_MIN 1