Jelajahi Sumber

qcacmn: HOST Memory Optimizations (in NSS offload mode)

Number of DP rings used in HOST mode and NSS offload mode differ
and in current scenario the rings are allocated unconditionally.

Allocate only required number of rings based on the HOST mode and
NSS Wi-Fi offload mode and based on the number of radios supported
per SOC.

CRs-Fixed: 2790504
Change-Id: I20ce1908da47c197ea3b406f8704b964f3d8f7d1
phadiman 4 tahun lalu
induk
melakukan
95b9a6e63a
5 mengubah file dengan 126 tambahan dan 48 penghapusan
  1. 57 45
      dp/wifi3.0/dp_main.c
  2. 2 0
      dp/wifi3.0/dp_types.h
  3. 24 0
      wlan_cfg/cfg_dp.h
  4. 23 1
      wlan_cfg/wlan_cfg.c
  5. 20 2
      wlan_cfg/wlan_cfg.h

+ 57 - 45
dp/wifi3.0/dp_main.c

@@ -3164,7 +3164,7 @@ static void dp_soc_reset_intr_mask(struct dp_soc *soc)
 	int group_number, mask, num_ring;
 
 	/* number of tx ring */
-	num_ring = wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
+	num_ring = soc->num_tcl_data_rings;
 
 	/*
 	 * group mask for tx completion  ring.
@@ -3199,7 +3199,7 @@ static void dp_soc_reset_intr_mask(struct dp_soc *soc)
 	}
 
 	/* number of rx rings */
-	num_ring = wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
+	num_ring = soc->num_reo_dest_rings;
 
 	/*
 	 * group mask for reo destination ring.
@@ -13040,14 +13040,15 @@ static void dp_soc_srng_deinit(struct dp_soc *soc)
 		dp_deinit_tx_pair_by_index(soc, i);
 
 	/* TCL command and status rings */
-	wlan_minidump_remove(soc->tcl_cmd_credit_ring.base_vaddr_unaligned);
-	dp_srng_deinit(soc, &soc->tcl_cmd_credit_ring, TCL_CMD_CREDIT, 0);
+	if (soc->init_tcl_cmd_cred_ring) {
+		wlan_minidump_remove(soc->tcl_cmd_credit_ring.base_vaddr_unaligned);
+		dp_srng_deinit(soc, &soc->tcl_cmd_credit_ring,
+			       TCL_CMD_CREDIT, 0);
+	}
+
 	wlan_minidump_remove(soc->tcl_status_ring.base_vaddr_unaligned);
 	dp_srng_deinit(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
 
-	/* Rx data rings */
-	soc->num_reo_dest_rings =
-			wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
 	for (i = 0; i < soc->num_reo_dest_rings; i++) {
 		/* TODO: Get number of rings and ring sizes
 		 * from wlan_cfg
@@ -13088,7 +13089,6 @@ static void dp_soc_srng_deinit(struct dp_soc *soc)
 static QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
 {
 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
-	uint32_t num_tcl_data_rings, num_reo_dest_rings;
 	uint8_t i;
 
 	soc_cfg_ctx = soc->wlan_cfg_ctx;
@@ -13108,19 +13108,21 @@ static QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
 			  WLAN_MD_DP_SRNG_WBM_DESC_REL,
 			  "wbm_desc_rel_ring");
 
-	/* TCL command and status rings */
-	if (dp_srng_init(soc, &soc->tcl_cmd_credit_ring,
-			 TCL_CMD_CREDIT, 0, 0)) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			  FL("dp_srng_init failed for tcl_cmd_ring"));
-		goto fail1;
-	}
+	if (soc->init_tcl_cmd_cred_ring) {
+		/* TCL command and status rings */
+		if (dp_srng_init(soc, &soc->tcl_cmd_credit_ring,
+				 TCL_CMD_CREDIT, 0, 0)) {
+			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
+				  FL("dp_srng_init failed for tcl_cmd_ring"));
+			goto fail1;
+		}
 
-	wlan_minidump_log(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
-			  soc->tcl_cmd_credit_ring.alloc_size,
-			  soc->ctrl_psoc,
-			  WLAN_MD_DP_SRNG_TCL_CMD,
-			  "wbm_desc_rel_ring");
+		wlan_minidump_log(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
+				  soc->tcl_cmd_credit_ring.alloc_size,
+				  soc->ctrl_psoc,
+				  WLAN_MD_DP_SRNG_TCL_CMD,
+				  "wbm_desc_rel_ring");
+	}
 
 	if (dp_srng_init(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0)) {
 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
@@ -13161,10 +13163,10 @@ static QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
 			  "reo_release_ring");
 
 	/* Rx exception ring */
-	if (dp_srng_init(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0,
-			 MAX_REO_DEST_RINGS)) {
+	if (dp_srng_init(soc, &soc->reo_exception_ring,
+			 REO_EXCEPTION, 0, MAX_REO_DEST_RINGS)) {
 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			  FL("dp_srng_init failed for reo_exception_ring"));
+			  FL("dp_srng_init failed - reo_exception"));
 		goto fail1;
 	}
 
@@ -13203,17 +13205,14 @@ static QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
 			  WLAN_MD_DP_SRNG_REO_STATUS,
 			  "reo_status_ring");
 
-	num_tcl_data_rings = wlan_cfg_num_tcl_data_rings(soc_cfg_ctx);
-	num_reo_dest_rings = wlan_cfg_num_reo_dest_rings(soc_cfg_ctx);
-
-	for (i = 0; i < num_tcl_data_rings; i++) {
+	for (i = 0; i < soc->num_tcl_data_rings; i++) {
 		if (dp_init_tx_ring_pair_by_index(soc, i))
 			goto fail1;
 	}
 
 	dp_create_ext_stats_event(soc);
 
-	for (i = 0; i < num_reo_dest_rings; i++) {
+	for (i = 0; i < soc->num_reo_dest_rings; i++) {
 		/* Initialize REO destination ring */
 		if (dp_srng_init(soc, &soc->reo_dest_ring[i], REO_DST, i, 0)) {
 			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
@@ -13252,7 +13251,9 @@ static void dp_soc_srng_free(struct dp_soc *soc)
 	for (i = 0; i < soc->num_tcl_data_rings; i++)
 		dp_free_tx_ring_pair_by_index(soc, i);
 
-	dp_srng_free(soc, &soc->tcl_cmd_credit_ring);
+	if (soc->init_tcl_cmd_cred_ring)
+		dp_srng_free(soc, &soc->tcl_cmd_credit_ring);
+
 	dp_srng_free(soc, &soc->tcl_status_ring);
 
 	for (i = 0; i < soc->num_reo_dest_rings; i++)
@@ -13260,7 +13261,9 @@ static void dp_soc_srng_free(struct dp_soc *soc)
 
 	dp_srng_free(soc, &soc->reo_reinject_ring);
 	dp_srng_free(soc, &soc->rx_rel_ring);
+
 	dp_srng_free(soc, &soc->reo_exception_ring);
+
 	dp_srng_free(soc, &soc->reo_cmd_ring);
 	dp_srng_free(soc, &soc->reo_status_ring);
 }
@@ -13277,7 +13280,6 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 	uint32_t entries;
 	uint32_t i;
 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
-	uint32_t num_tcl_data_rings, num_reo_dest_rings;
 	uint32_t cached = WLAN_CFG_DST_RING_CACHED_DESC;
 	uint32_t tx_comp_ring_size, tx_ring_size, reo_dst_ring_size;
 
@@ -13294,11 +13296,13 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 
 	entries = wlan_cfg_get_dp_soc_tcl_cmd_credit_ring_size(soc_cfg_ctx);
 	/* TCL command and status rings */
-	if (dp_srng_alloc(soc, &soc->tcl_cmd_credit_ring, TCL_CMD_CREDIT,
-			  entries, 0)) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			  FL("dp_srng_alloc failed for tcl_cmd_ring"));
-		goto fail1;
+	if (soc->init_tcl_cmd_cred_ring) {
+		if (dp_srng_alloc(soc, &soc->tcl_cmd_credit_ring,
+				  TCL_CMD_CREDIT, entries, 0)) {
+			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
+				  FL("dp_srng_alloc failed for tcl_cmd_ring"));
+			goto fail1;
+		}
 	}
 
 	entries = wlan_cfg_get_dp_soc_tcl_status_ring_size(soc_cfg_ctx);
@@ -13332,7 +13336,7 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 	if (dp_srng_alloc(soc, &soc->reo_exception_ring, REO_EXCEPTION,
 			  entries, 0)) {
 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			  FL("dp_srng_alloc failed for reo_exception_ring"));
+			  FL("dp_srng_alloc failed - reo_exception"));
 		goto fail1;
 	}
 
@@ -13352,8 +13356,6 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 		goto fail1;
 	}
 
-	num_tcl_data_rings = wlan_cfg_num_tcl_data_rings(soc_cfg_ctx);
-	num_reo_dest_rings = wlan_cfg_num_reo_dest_rings(soc_cfg_ctx);
 	tx_comp_ring_size = wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
 	tx_ring_size = wlan_cfg_tx_ring_size(soc_cfg_ctx);
 	reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc_cfg_ctx);
@@ -13362,14 +13364,12 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 	if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
 		cached = 0;
 
-	for (i = 0; i < num_tcl_data_rings; i++) {
+	for (i = 0; i < soc->num_tcl_data_rings; i++) {
 		if (dp_alloc_tx_ring_pair_by_index(soc, i))
 			goto fail1;
 	}
 
-	soc->num_tcl_data_rings = num_tcl_data_rings;
-
-	for (i = 0; i < num_reo_dest_rings; i++) {
+	for (i = 0; i < soc->num_reo_dest_rings; i++) {
 		/* Setup REO destination ring */
 		if (dp_srng_alloc(soc, &soc->reo_dest_ring[i], REO_DST,
 				  reo_dst_ring_size, cached)) {
@@ -13378,7 +13378,6 @@ static QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
 			goto fail1;
 		}
 	}
-	soc->num_reo_dest_rings = num_reo_dest_rings;
 
 	return QDF_STATUS_SUCCESS;
 
@@ -13542,6 +13541,18 @@ static void dp_soc_cfg_attach(struct dp_soc *soc)
 		wlan_cfg_set_num_tx_ext_desc_pool(soc->wlan_cfg_ctx, 0);
 		wlan_cfg_set_num_tx_desc(soc->wlan_cfg_ctx, 0);
 		wlan_cfg_set_num_tx_ext_desc(soc->wlan_cfg_ctx, 0);
+		soc->init_tcl_cmd_cred_ring = false;
+		soc->num_tcl_data_rings =
+			wlan_cfg_num_nss_tcl_data_rings(soc->wlan_cfg_ctx);
+		soc->num_reo_dest_rings =
+			wlan_cfg_num_nss_reo_dest_rings(soc->wlan_cfg_ctx);
+
+	} else {
+		soc->init_tcl_cmd_cred_ring = true;
+		soc->num_tcl_data_rings =
+			wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
+		soc->num_reo_dest_rings =
+			wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
 	}
 }
 
@@ -13624,8 +13635,9 @@ static inline QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc,
 	 * Initialize command/credit ring descriptor
 	 * Command/CREDIT ring also used for sending DATA cmds
 	 */
-	hal_tx_init_cmd_credit_ring(soc->hal_soc,
-				    soc->tcl_cmd_credit_ring.hal_srng);
+	if (soc->init_tcl_cmd_cred_ring)
+		hal_tx_init_cmd_credit_ring(soc->hal_soc,
+					    soc->tcl_cmd_credit_ring.hal_srng);
 
 	dp_tx_pdev_init(pdev);
 	/*

+ 2 - 0
dp/wifi3.0/dp_types.h

@@ -1402,6 +1402,8 @@ struct dp_soc {
 	uint8_t num_tcl_data_rings;
 
 	/* TCL CMD_CREDIT ring */
+	bool init_tcl_cmd_cred_ring;
+
 	/* It is used as credit based ring on QCN9000 else command ring */
 	struct dp_srng tcl_cmd_credit_ring;
 

+ 24 - 0
wlan_cfg/cfg_dp.h

@@ -218,6 +218,14 @@
 #define WLAN_CFG_NUM_REO_DEST_RING_MIN 4
 #define WLAN_CFG_NUM_REO_DEST_RING_MAX 4
 
+#define WLAN_CFG_NSS_NUM_TCL_DATA_RINGS 2
+#define WLAN_CFG_NSS_NUM_TCL_DATA_RINGS_MIN 1
+#define WLAN_CFG_NSS_NUM_TCL_DATA_RINGS_MAX 3
+
+#define WLAN_CFG_NSS_NUM_REO_DEST_RING 2
+#define WLAN_CFG_NSS_NUM_REO_DEST_RING_MIN 1
+#define WLAN_CFG_NSS_NUM_REO_DEST_RING_MAX 3
+
 #define WLAN_CFG_WBM_RELEASE_RING_SIZE 1024
 #define WLAN_CFG_WBM_RELEASE_RING_SIZE_MIN 64
 #define WLAN_CFG_WBM_RELEASE_RING_SIZE_MAX 1024
@@ -473,6 +481,20 @@
 		WLAN_CFG_NUM_TCL_DATA_RINGS, \
 		CFG_VALUE_OR_DEFAULT, "DP TCL Data Rings")
 
+#define CFG_DP_NSS_REO_DEST_RINGS \
+		CFG_INI_UINT("dp_nss_reo_dest_rings", \
+		WLAN_CFG_NSS_NUM_REO_DEST_RING_MIN, \
+		WLAN_CFG_NSS_NUM_REO_DEST_RING_MAX, \
+		WLAN_CFG_NSS_NUM_REO_DEST_RING, \
+		CFG_VALUE_OR_DEFAULT, "DP NSS REO Destination Rings")
+
+#define CFG_DP_NSS_TCL_DATA_RINGS \
+		CFG_INI_UINT("dp_nss_tcl_data_rings", \
+		WLAN_CFG_NSS_NUM_TCL_DATA_RINGS_MIN, \
+		WLAN_CFG_NSS_NUM_TCL_DATA_RINGS_MAX, \
+		WLAN_CFG_NSS_NUM_TCL_DATA_RINGS, \
+		CFG_VALUE_OR_DEFAULT, "DP NSS TCL Data Rings")
+
 #define CFG_DP_TX_DESC \
 		CFG_INI_UINT("dp_tx_desc", \
 		WLAN_CFG_NUM_TX_DESC_MIN, \
@@ -1105,6 +1127,8 @@
 		CFG(CFG_DP_MAX_PEER_ID) \
 		CFG(CFG_DP_REO_DEST_RINGS) \
 		CFG(CFG_DP_TCL_DATA_RINGS) \
+		CFG(CFG_DP_NSS_REO_DEST_RINGS) \
+		CFG(CFG_DP_NSS_TCL_DATA_RINGS) \
 		CFG(CFG_DP_TX_DESC) \
 		CFG(CFG_DP_TX_EXT_DESC) \
 		CFG(CFG_DP_TX_EXT_DESC_POOLS) \

+ 23 - 1
wlan_cfg/wlan_cfg.c

@@ -485,10 +485,14 @@ wlan_cfg_soc_attach(struct cdp_ctrl_objmgr_psoc *psoc)
 	wlan_cfg_ctx->max_clients = cfg_get(psoc, CFG_DP_MAX_CLIENTS);
 	wlan_cfg_ctx->max_alloc_size = cfg_get(psoc, CFG_DP_MAX_ALLOC_SIZE);
 	wlan_cfg_ctx->per_pdev_tx_ring = cfg_get(psoc, CFG_DP_PDEV_TX_RING);
+	wlan_cfg_ctx->num_reo_dest_rings = cfg_get(psoc, CFG_DP_REO_DEST_RINGS);
 	wlan_cfg_ctx->num_tcl_data_rings = cfg_get(psoc, CFG_DP_TCL_DATA_RINGS);
+	wlan_cfg_ctx->num_nss_reo_dest_rings =
+				cfg_get(psoc, CFG_DP_NSS_REO_DEST_RINGS);
+	wlan_cfg_ctx->num_nss_tcl_data_rings =
+				cfg_get(psoc, CFG_DP_NSS_TCL_DATA_RINGS);
 	wlan_cfg_ctx->per_pdev_rx_ring = cfg_get(psoc, CFG_DP_PDEV_RX_RING);
 	wlan_cfg_ctx->per_pdev_lmac_ring = cfg_get(psoc, CFG_DP_PDEV_LMAC_RING);
-	wlan_cfg_ctx->num_reo_dest_rings = cfg_get(psoc, CFG_DP_REO_DEST_RINGS);
 	wlan_cfg_ctx->num_tx_desc_pool = MAX_TXDESC_POOLS;
 	wlan_cfg_ctx->num_tx_ext_desc_pool = cfg_get(psoc,
 						     CFG_DP_TX_EXT_DESC_POOLS);
@@ -927,11 +931,24 @@ int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
 {
 	return 1;
 }
+
+int wlan_cfg_num_nss_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return 1;
+}
+
 #else
+
 int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
 {
 	return cfg->num_tcl_data_rings;
 }
+
+int wlan_cfg_num_nss_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->num_nss_tcl_data_rings;
+}
+
 #endif
 
 int wlan_cfg_tx_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
@@ -954,6 +971,11 @@ int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
 	return cfg->num_reo_dest_rings;
 }
 
+int wlan_cfg_num_nss_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
+{
+	return cfg->num_nss_reo_dest_rings;
+}
+
 int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
 {
 	return cfg->htt_packet_type;            /*htt_pkt_type_ethernet*/

+ 20 - 2
wlan_cfg/wlan_cfg.h

@@ -201,9 +201,11 @@ struct wlan_cfg_dp_soc_ctxt {
 	int max_alloc_size;
 	int per_pdev_tx_ring;
 	int num_tcl_data_rings;
+	int num_nss_tcl_data_rings;
 	int per_pdev_rx_ring;
 	int per_pdev_lmac_ring;
 	int num_reo_dest_rings;
+	int num_nss_reo_dest_rings;
 	int num_tx_desc_pool;
 	int num_tx_ext_desc_pool;
 	int num_tx_desc;
@@ -679,13 +681,21 @@ uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 
 /*
- * wlan_cfg_num_tcl_data_rings() - Number of TCL Data rings supported by device
+ * wlan_cfg_num_tcl_data_rings() - Number of TCL Data rings (HOST mode)
  * @wlan_cfg_ctx
  *
  * Return: num_tcl_data_rings
  */
 int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 
+/*
+ * wlan_cfg_num_nss_tcl_data_rings() - Number of TCL Data rings (NSS offload)
+ * @wlan_cfg_ctx
+ *
+ * Return: num_tcl_data_rings
+ */
+int wlan_cfg_num_nss_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
+
 /*
  * wlan_cfg_per_pdev_rx_ring() - Return true if Rx rings are mapped as
  *                              one per radio
@@ -705,13 +715,21 @@ int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 int wlan_cfg_per_pdev_lmac_ring(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 
 /*
- * wlan_cfg_num_reo_dest_rings() - Number of REO Data rings supported by device
+ * wlan_cfg_num_reo_dest_rings() - Number of REO Data rings (HOST mode)
  * @wlan_cfg_ctx - Configuration Handle
  *
  * Return: num_reo_dest_rings
  */
 int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
 
+/*
+ * wlan_cfg_num_nss_reo_dest_rings() - Number of REO Data rings (NSS offload)
+ * @wlan_cfg_ctx - Configuration Handle
+ *
+ * Return: num_reo_dest_rings
+ */
+int wlan_cfg_num_nss_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx);
+
 /*
  * wlan_cfg_pkt_type() - Default 802.11 encapsulation type
  * @wlan_cfg_ctx - Configuration Handle