Bladeren bron

msm: ipa3: Changes to reduce the ipa hw stats structure size

Due to ipa hw stats structre size was high in lower value tier targets
1MB memory was getting allocated, it was impacting bootup allocations.
So making changes to reduce the ipa hw stats structure size.

Change-Id: I7d4863bf971a70ba736e78bbfadaa38b572bad74
Ashok Vuyyuru 2 jaren geleden
bovenliggende
commit
69a0a201ec

+ 33 - 23
drivers/platform/msm/ipa/ipa_v3/ipa_hw_stats.c

@@ -780,13 +780,13 @@ int ipa_get_quota_stats(struct ipa_quota_stats_all *out)
 		if (ipa3_ctx->ep[ep_idx].client != i)
 			continue;
 
-		ipa3_ctx->hw_stats->quota.stats.client[i].num_ipv4_bytes +=
+		ipa3_ctx->hw_stats->quota.stats.client[ep_idx].num_ipv4_bytes +=
 			stats->stats[ep_idx].num_ipv4_bytes;
-		ipa3_ctx->hw_stats->quota.stats.client[i].num_ipv4_pkts +=
+		ipa3_ctx->hw_stats->quota.stats.client[ep_idx].num_ipv4_pkts +=
 			stats->stats[ep_idx].num_ipv4_pkts;
-		ipa3_ctx->hw_stats->quota.stats.client[i].num_ipv6_bytes +=
+		ipa3_ctx->hw_stats->quota.stats.client[ep_idx].num_ipv6_bytes +=
 			stats->stats[ep_idx].num_ipv6_bytes;
-		ipa3_ctx->hw_stats->quota.stats.client[i].num_ipv6_pkts +=
+		ipa3_ctx->hw_stats->quota.stats.client[ep_idx].num_ipv6_pkts +=
 			stats->stats[ep_idx].num_ipv6_pkts;
 	}
 
@@ -809,6 +809,7 @@ int ipa_reset_quota_stats(enum ipa_client_type client)
 {
 	int ret;
 	struct ipa_quota_stats *stats;
+	int ep_idx;
 
 	if (!(ipa3_ctx->hw_stats && ipa3_ctx->hw_stats->enabled))
 		return 0;
@@ -825,8 +826,9 @@ int ipa_reset_quota_stats(enum ipa_client_type client)
 		return ret;
 	}
 
+	ep_idx = ipa_get_ep_mapping(client);
 	/* reset driver's cache */
-	stats = &ipa3_ctx->hw_stats->quota.stats.client[client];
+	stats = &ipa3_ctx->hw_stats->quota.stats.client[ep_idx];
 	memset(stats, 0, sizeof(*stats));
 	return 0;
 }
@@ -903,7 +905,7 @@ int ipa_init_teth_stats(struct ipa_teth_stats_endpoints *in)
 	/* reset driver's cache */
 	memset(&ipa3_ctx->hw_stats->teth.init, 0,
 		sizeof(ipa3_ctx->hw_stats->teth.init));
-	for (i = 0; i < IPA_CLIENT_MAX; i++) {
+	for (i = 0; i < IPA5_PIPES_NUM; i++) {
 		memset(&ipa3_ctx->hw_stats->teth.prod_stats_sum[i], 0,
 			sizeof(ipa3_ctx->hw_stats->teth.prod_stats_sum[i]));
 		memset(&ipa3_ctx->hw_stats->teth.prod_stats[i], 0,
@@ -1176,7 +1178,7 @@ int ipa_get_teth_stats(void)
 	}
 
 	/* reset prod_stats cache */
-	for (i = 0; i < IPA_CLIENT_MAX; i++) {
+	for (i = 0; i < IPA5_PIPES_NUM; i++) {
 		memset(&ipa3_ctx->hw_stats->teth.prod_stats[i], 0,
 			sizeof(ipa3_ctx->hw_stats->teth.prod_stats[i]));
 	}
@@ -1221,7 +1223,7 @@ int ipa_get_teth_stats(void)
 
 				/* update stats*/
 				quota_stats =
-					&sw_stats->prod_stats[i].client[j];
+					&sw_stats->prod_stats[prod_idx].client[cons_idx];
 				quota_stats->num_ipv4_bytes =
 					stats->num_ipv4_bytes;
 				quota_stats->num_ipv4_pkts =
@@ -1233,7 +1235,7 @@ int ipa_get_teth_stats(void)
 
 				/* Accumulated stats */
 				quota_stats =
-					&sw_stats->prod_stats_sum[i].client[j];
+					&sw_stats->prod_stats_sum[prod_idx].client[cons_idx];
 				quota_stats->num_ipv4_bytes +=
 					stats->num_ipv4_bytes;
 				quota_stats->num_ipv4_pkts +=
@@ -1262,6 +1264,8 @@ free_dma_mem:
 int ipa_query_teth_stats(enum ipa_client_type prod,
 	struct ipa_quota_stats_all *out, bool reset)
 {
+	int ipa_ep_idx;
+
 	if (!(ipa3_ctx->hw_stats && ipa3_ctx->hw_stats->enabled &&
 		ipa3_ctx->hw_stats->teth_stats_enabled))
 		return 0;
@@ -1271,11 +1275,12 @@ int ipa_query_teth_stats(enum ipa_client_type prod,
 		return -EINVAL;
 	}
 
+	ipa_ep_idx = ipa_get_ep_mapping(prod);
 	/* copy results to out parameter */
 	if (reset)
-		*out = ipa3_ctx->hw_stats->teth.prod_stats[prod];
+		*out = ipa3_ctx->hw_stats->teth.prod_stats[ipa_ep_idx];
 	else
-		*out = ipa3_ctx->hw_stats->teth.prod_stats_sum[prod];
+		*out = ipa3_ctx->hw_stats->teth.prod_stats_sum[ipa_ep_idx];
 	return 0;
 }
 
@@ -1283,6 +1288,7 @@ int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons)
 {
 	int ret;
 	struct ipa_quota_stats *stats;
+	int prod_ep_idx, cons_ep_idx;
 
 	if (!(ipa3_ctx->hw_stats && ipa3_ctx->hw_stats->enabled &&
 		ipa3_ctx->hw_stats->teth_stats_enabled))
@@ -1293,6 +1299,8 @@ int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons)
 		return -EINVAL;
 	}
 
+	prod_ep_idx = ipa_get_ep_mapping(prod);
+	cons_ep_idx = ipa_get_ep_mapping(cons);
 	/* reading stats will reset them in hardware */
 	ret = ipa_get_teth_stats();
 	if (ret) {
@@ -1301,7 +1309,7 @@ int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons)
 	}
 
 	/* reset driver's cache */
-	stats = &ipa3_ctx->hw_stats->teth.prod_stats_sum[prod].client[cons];
+	stats = &ipa3_ctx->hw_stats->teth.prod_stats_sum[prod_ep_idx].client[cons_ep_idx];
 	memset(stats, 0, sizeof(*stats));
 	return 0;
 }
@@ -1311,6 +1319,7 @@ int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod)
 	int ret;
 	int i;
 	struct ipa_quota_stats *stats;
+	int ipa_ep_idx;
 
 	if (!(ipa3_ctx->hw_stats && ipa3_ctx->hw_stats->enabled &&
 		ipa3_ctx->hw_stats->teth_stats_enabled))
@@ -1321,6 +1330,7 @@ int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod)
 		return -EINVAL;
 	}
 
+	ipa_ep_idx = ipa_get_ep_mapping(prod);
 	/* reading stats will reset them in hardware */
 	ret = ipa_get_teth_stats();
 	if (ret) {
@@ -1329,8 +1339,8 @@ int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod)
 	}
 
 	/* reset driver's cache */
-	for (i = 0; i < IPA_CLIENT_MAX; i++) {
-		stats = &ipa3_ctx->hw_stats->teth.prod_stats_sum[prod].client[i];
+	for (i = 0; i < IPA5_PIPES_NUM; i++) {
+		stats = &ipa3_ctx->hw_stats->teth.prod_stats_sum[ipa_ep_idx].client[i];
 		memset(stats, 0, sizeof(*stats));
 	}
 
@@ -1361,7 +1371,7 @@ int ipa_reset_all_teth_stats(void)
 	}
 
 	/* reset driver's cache */
-	for (i = 0; i < IPA_CLIENT_MAX; i++) {
+	for (i = 0; i < IPA5_PIPES_NUM; i++) {
 		stats = &ipa3_ctx->hw_stats->teth.prod_stats_sum[i];
 		memset(stats, 0, sizeof(*stats));
 	}
@@ -2353,19 +2363,19 @@ static ssize_t ipa_debugfs_print_quota_stats(struct file *file,
 		nbytes += scnprintf(dbg_buff + nbytes,
 			IPA_MAX_MSG_LEN - nbytes,
 			"num_ipv4_bytes=%llu\n",
-			out->client[i].num_ipv4_bytes);
+			out->client[ep_idx].num_ipv4_bytes);
 		nbytes += scnprintf(dbg_buff + nbytes,
 			IPA_MAX_MSG_LEN - nbytes,
 			"num_ipv6_bytes=%llu\n",
-			out->client[i].num_ipv6_bytes);
+			out->client[ep_idx].num_ipv6_bytes);
 		nbytes += scnprintf(dbg_buff + nbytes,
 			IPA_MAX_MSG_LEN - nbytes,
 			"num_ipv4_pkts=%u\n",
-			out->client[i].num_ipv4_pkts);
+			out->client[ep_idx].num_ipv4_pkts);
 		nbytes += scnprintf(dbg_buff + nbytes,
 			IPA_MAX_MSG_LEN - nbytes,
 			"num_ipv6_pkts=%u\n",
-			out->client[i].num_ipv6_pkts);
+			out->client[ep_idx].num_ipv6_pkts);
 		nbytes += scnprintf(dbg_buff + nbytes,
 			IPA_MAX_MSG_LEN - nbytes,
 			"\n");
@@ -2472,19 +2482,19 @@ static ssize_t ipa_debugfs_print_tethering_stats(struct file *file,
 			nbytes += scnprintf(dbg_buff + nbytes,
 				IPA_MAX_MSG_LEN - nbytes,
 				"num_ipv4_bytes=%llu\n",
-				out->client[j].num_ipv4_bytes);
+				out->client[cons_idx].num_ipv4_bytes);
 			nbytes += scnprintf(dbg_buff + nbytes,
 				IPA_MAX_MSG_LEN - nbytes,
 				"num_ipv6_bytes=%llu\n",
-				out->client[j].num_ipv6_bytes);
+				out->client[cons_idx].num_ipv6_bytes);
 			nbytes += scnprintf(dbg_buff + nbytes,
 				IPA_MAX_MSG_LEN - nbytes,
 				"num_ipv4_pkts=%u\n",
-				out->client[j].num_ipv4_pkts);
+				out->client[cons_idx].num_ipv4_pkts);
 			nbytes += scnprintf(dbg_buff + nbytes,
 				IPA_MAX_MSG_LEN - nbytes,
 				"num_ipv6_pkts=%u\n",
-				out->client[j].num_ipv6_pkts);
+				out->client[cons_idx].num_ipv6_pkts);
 			nbytes += scnprintf(dbg_buff + nbytes,
 				IPA_MAX_MSG_LEN - nbytes,
 				"\n");

+ 3 - 3
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -1931,7 +1931,7 @@ struct ipa_quota_stats {
 };
 
 struct ipa_quota_stats_all {
-	struct ipa_quota_stats client[IPA_CLIENT_MAX];
+	struct ipa_quota_stats client[IPA5_PIPES_NUM];
 };
 
 struct ipa_drop_stats {
@@ -1950,8 +1950,8 @@ struct ipa_hw_stats_quota {
 
 struct ipa_hw_stats_teth {
 	struct ipahal_stats_init_tethering init;
-	struct ipa_quota_stats_all prod_stats_sum[IPA_CLIENT_MAX];
-	struct ipa_quota_stats_all prod_stats[IPA_CLIENT_MAX];
+	struct ipa_quota_stats_all prod_stats_sum[IPA5_PIPES_NUM];
+	struct ipa_quota_stats_all prod_stats[IPA5_PIPES_NUM];
 };
 
 struct ipa_hw_stats_flt_rt {

+ 190 - 112
drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c

@@ -4840,6 +4840,7 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 	int rc = 0, index = 0, i = 0;
 	struct ipa_quota_stats_all *con_stats;
 	enum ipa_client_type wlan_client;
+	int ep_idx,wlan_ep_idx,usb_ep_idx;
 
 	/* qet HW-stats */
 	rc = ipa_get_teth_stats();
@@ -4879,18 +4880,29 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 	else
 		wlan_client = IPA_CLIENT_WLAN1_CONS;
 
+	wlan_ep_idx = ipa_get_ep_mapping( wlan_client );
+
+	if (wlan_ep_idx == -1 || wlan_ep_idx >= ipa3_get_max_num_pipes())
+		return wlan_ep_idx ;
+
 	IPAWANDBG("wlan: v4_rx_p-b(%d,%lld) v6_rx_p-b(%d,%lld),client(%d)\n",
-	con_stats->client[wlan_client].num_ipv4_pkts,
-	con_stats->client[wlan_client].num_ipv4_bytes,
-	con_stats->client[wlan_client].num_ipv6_pkts,
-	con_stats->client[wlan_client].num_ipv6_bytes,
+	con_stats->client[wlan_ep_idx].num_ipv4_pkts,
+	con_stats->client[wlan_ep_idx].num_ipv4_bytes,
+	con_stats->client[wlan_ep_idx].num_ipv6_pkts,
+	con_stats->client[wlan_ep_idx].num_ipv6_bytes,
 	wlan_client);
 
+
+	usb_ep_idx = ipa_get_ep_mapping( IPA_CLIENT_USB_CONS );
+
+	if (usb_ep_idx == -1 || usb_ep_idx >= ipa3_get_max_num_pipes())
+		return usb_ep_idx ;
+
 	IPAWANDBG("usb: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
-	con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts,
-	con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes,
-	con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts,
-	con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes);
+	con_stats->client[usb_ep_idx].num_ipv4_pkts,
+	con_stats->client[usb_ep_idx].num_ipv4_bytes,
+	con_stats->client[usb_ep_idx].num_ipv6_pkts,
+	con_stats->client[usb_ep_idx].num_ipv6_bytes);
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
 		enum ipa_client_type wigig_client =
@@ -4899,27 +4911,33 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
 
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
+
 		IPAWANDBG("wigig%d: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
 			i + 1,
-			con_stats->client[wigig_client].num_ipv4_pkts,
-			con_stats->client[wigig_client].num_ipv4_bytes,
-			con_stats->client[wigig_client].num_ipv6_pkts,
-			con_stats->client[wigig_client].num_ipv6_bytes);
+			con_stats->client[ep_idx].num_ipv4_pkts,
+			con_stats->client[ep_idx].num_ipv4_bytes,
+			con_stats->client[ep_idx].num_ipv6_pkts,
+			con_stats->client[ep_idx].num_ipv6_bytes);
 	}
 
 	/* update the DL stats */
 	data->ipv4_rx_packets =
-		con_stats->client[wlan_client].num_ipv4_pkts +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts;
+		con_stats->client[wlan_ep_idx].num_ipv4_pkts +
+			con_stats->client[usb_ep_idx].num_ipv4_pkts;
 	data->ipv6_rx_packets =
-		con_stats->client[wlan_client].num_ipv6_pkts +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts;
+		con_stats->client[wlan_ep_idx].num_ipv6_pkts +
+			con_stats->client[usb_ep_idx].num_ipv6_pkts;
 	data->ipv4_rx_bytes =
-		con_stats->client[wlan_client].num_ipv4_bytes +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes;
+		con_stats->client[wlan_ep_idx].num_ipv4_bytes +
+			con_stats->client[usb_ep_idx].num_ipv4_bytes;
 	data->ipv6_rx_bytes =
-		con_stats->client[wlan_client].num_ipv6_bytes +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes;
+		con_stats->client[wlan_ep_idx].num_ipv6_bytes +
+			con_stats->client[usb_ep_idx].num_ipv6_bytes;
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
 		enum ipa_client_type wigig_client =
@@ -4928,14 +4946,19 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
 
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
 		data->ipv4_rx_packets +=
-			con_stats->client[wigig_client].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_rx_packets +=
-			con_stats->client[wigig_client].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 	}
 
 	IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
@@ -4962,18 +4985,23 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 	else
 		wlan_client = IPA_CLIENT_WLAN1_CONS;
 
+	wlan_ep_idx = ipa_get_ep_mapping( wlan_client );
+
+	if (wlan_ep_idx == -1 || wlan_ep_idx >= ipa3_get_max_num_pipes())
+		return wlan_ep_idx ;
+
 	IPAWANDBG("wlan: v4_rx_p-b(%d,%lld) v6_rx_p-b(%d,%lld),client(%d)\n",
-		con_stats->client[wlan_client].num_ipv4_pkts,
-		con_stats->client[wlan_client].num_ipv4_bytes,
-		con_stats->client[wlan_client].num_ipv6_pkts,
-		con_stats->client[wlan_client].num_ipv6_bytes,
+		con_stats->client[wlan_ep_idx].num_ipv4_pkts,
+		con_stats->client[wlan_ep_idx].num_ipv4_bytes,
+		con_stats->client[wlan_ep_idx].num_ipv6_pkts,
+		con_stats->client[wlan_ep_idx].num_ipv6_bytes,
 		wlan_client);
 
 	IPAWANDBG("usb: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes);
+		con_stats->client[usb_ep_idx].num_ipv4_pkts,
+		con_stats->client[usb_ep_idx].num_ipv4_bytes,
+		con_stats->client[usb_ep_idx].num_ipv6_pkts,
+		con_stats->client[usb_ep_idx].num_ipv6_bytes);
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
 		enum ipa_client_type wigig_client =
@@ -4981,28 +5009,32 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
 
 		IPAWANDBG("wigig%d: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
 			i + 1,
-			con_stats->client[wigig_client].num_ipv4_pkts,
-			con_stats->client[wigig_client].num_ipv4_bytes,
-			con_stats->client[wigig_client].num_ipv6_pkts,
-			con_stats->client[wigig_client].num_ipv6_bytes);
+			con_stats->client[ep_idx].num_ipv4_pkts,
+			con_stats->client[ep_idx].num_ipv4_bytes,
+			con_stats->client[ep_idx].num_ipv6_pkts,
+			con_stats->client[ep_idx].num_ipv6_bytes);
 	}
 
 	/* update the DL stats */
 	data->ipv4_rx_packets +=
-		con_stats->client[wlan_client].num_ipv4_pkts +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts;
+		con_stats->client[wlan_ep_idx].num_ipv4_pkts +
+			con_stats->client[usb_ep_idx].num_ipv4_pkts;
 	data->ipv6_rx_packets +=
-		con_stats->client[wlan_client].num_ipv6_pkts +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts;
+		con_stats->client[wlan_ep_idx].num_ipv6_pkts +
+			con_stats->client[usb_ep_idx].num_ipv6_pkts;
 	data->ipv4_rx_bytes +=
-		con_stats->client[wlan_client].num_ipv4_bytes +
-			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes;
+		con_stats->client[wlan_ep_idx].num_ipv4_bytes +
+			con_stats->client[usb_ep_idx].num_ipv4_bytes;
 	data->ipv6_rx_bytes +=
-		con_stats->client[wlan_client].num_ipv6_bytes +
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes;
+		con_stats->client[wlan_ep_idx].num_ipv6_bytes +
+		con_stats->client[usb_ep_idx].num_ipv6_bytes;
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
 		enum ipa_client_type wigig_client =
@@ -5011,14 +5043,19 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
 
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
 		data->ipv4_rx_packets +=
-			con_stats->client[wigig_client].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_rx_packets +=
-			con_stats->client[wigig_client].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 	}
 
 	IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
@@ -5044,18 +5081,23 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 	else
 		wlan_client = IPA_CLIENT_WLAN1_CONS;
 
+	wlan_ep_idx = ipa_get_ep_mapping( wlan_client );
+
+	if (wlan_ep_idx == -1 || wlan_ep_idx >= ipa3_get_max_num_pipes())
+		return wlan_ep_idx ;
+
 	IPAWANDBG("wlan: v4_rx_p-b(%d,%lld) v6_rx_p-b(%d,%lld),client(%d)\n",
-		con_stats->client[wlan_client].num_ipv4_pkts,
-		con_stats->client[wlan_client].num_ipv4_bytes,
-		con_stats->client[wlan_client].num_ipv6_pkts,
-		con_stats->client[wlan_client].num_ipv6_bytes,
+		con_stats->client[wlan_ep_idx].num_ipv4_pkts,
+		con_stats->client[wlan_ep_idx].num_ipv4_bytes,
+		con_stats->client[wlan_ep_idx].num_ipv6_pkts,
+		con_stats->client[wlan_ep_idx].num_ipv6_bytes,
 		wlan_client);
 
 	IPAWANDBG("usb: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts,
-		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes);
+		con_stats->client[usb_ep_idx].num_ipv4_pkts,
+		con_stats->client[usb_ep_idx].num_ipv4_bytes,
+		con_stats->client[usb_ep_idx].num_ipv6_pkts,
+		con_stats->client[usb_ep_idx].num_ipv6_bytes);
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
 		enum ipa_client_type wigig_client =
@@ -5064,26 +5106,31 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
 
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
 		IPAWANDBG("wigig%d: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
 			i + 1,
-			con_stats->client[wigig_client].num_ipv4_pkts,
-			con_stats->client[wigig_client].num_ipv4_bytes,
-			con_stats->client[wigig_client].num_ipv6_pkts,
-			con_stats->client[wigig_client].num_ipv6_bytes);
+			con_stats->client[ep_idx].num_ipv4_pkts,
+			con_stats->client[ep_idx].num_ipv4_bytes,
+			con_stats->client[ep_idx].num_ipv6_pkts,
+			con_stats->client[ep_idx].num_ipv6_bytes);
 	}
 
 	/* update the DL stats */
 	data->ipv4_rx_packets +=
-		con_stats->client[wlan_client].num_ipv4_pkts +
+		con_stats->client[wlan_ep_idx].num_ipv4_pkts +
 			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts;
 	data->ipv6_rx_packets +=
-		con_stats->client[wlan_client].num_ipv6_pkts +
+		con_stats->client[wlan_ep_idx].num_ipv6_pkts +
 			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts;
 	data->ipv4_rx_bytes +=
-		con_stats->client[wlan_client].num_ipv4_bytes +
+		con_stats->client[wlan_ep_idx].num_ipv4_bytes +
 			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes;
 	data->ipv6_rx_bytes +=
-		con_stats->client[wlan_client].num_ipv6_bytes +
+		con_stats->client[wlan_ep_idx].num_ipv6_bytes +
 		con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes;
 
 	for (i = 0; i < MAX_WIGIG_CLIENTS; i++) {
@@ -5093,14 +5140,18 @@ static int rmnet_ipa3_query_tethering_stats_hw(
 		if (wigig_client > IPA_CLIENT_WIGIG4_CONS)
 			break;
 
+		ep_idx = ipa_get_ep_mapping( wigig_client );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
 		data->ipv4_rx_packets +=
-			con_stats->client[wigig_client].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_rx_packets +=
-			con_stats->client[wigig_client].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_rx_bytes +=
-			con_stats->client[wigig_client].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 	}
 
 	IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
@@ -5123,43 +5174,52 @@ skip_nlo_stats:
 		index = IPA_CLIENT_MHI_PRIME_TETH_CONS;
 	else
 		index = IPA_CLIENT_Q6_WAN_CONS;
+	ep_idx = ipa_get_ep_mapping( index );
+
+	if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+		return ep_idx ;
 
 	IPAWANDBG("usb: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
-	con_stats->client[index].num_ipv4_pkts,
-	con_stats->client[index].num_ipv4_bytes,
-	con_stats->client[index].num_ipv6_pkts,
-	con_stats->client[index].num_ipv6_bytes);
+	con_stats->client[ep_idx].num_ipv4_pkts,
+	con_stats->client[ep_idx].num_ipv4_bytes,
+	con_stats->client[ep_idx].num_ipv6_pkts,
+	con_stats->client[ep_idx].num_ipv6_bytes);
 
 	/* update the USB UL stats */
 	data->ipv4_tx_packets =
-		con_stats->client[index].num_ipv4_pkts;
+		con_stats->client[ep_idx].num_ipv4_pkts;
 	data->ipv6_tx_packets =
-		con_stats->client[index].num_ipv6_pkts;
+		con_stats->client[ep_idx].num_ipv6_pkts;
 	data->ipv4_tx_bytes =
-		con_stats->client[index].num_ipv4_bytes;
+		con_stats->client[ep_idx].num_ipv4_bytes;
 	data->ipv6_tx_bytes =
-		con_stats->client[index].num_ipv6_bytes;
+		con_stats->client[ep_idx].num_ipv6_bytes;
 
 	if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5 &&
 		ipa3_ctx->platform_type == IPA_PLAT_TYPE_MSM) {
 
 		index = IPA_CLIENT_Q6_UL_NLO_DATA_CONS;
 
+		ep_idx = ipa_get_ep_mapping( index );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
 		IPAWANDBG("usb: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
-				con_stats->client[index].num_ipv4_pkts,
-				con_stats->client[index].num_ipv4_bytes,
-				con_stats->client[index].num_ipv6_pkts,
-				con_stats->client[index].num_ipv6_bytes);
+				con_stats->client[ep_idx].num_ipv4_pkts,
+				con_stats->client[ep_idx].num_ipv4_bytes,
+				con_stats->client[ep_idx].num_ipv6_pkts,
+				con_stats->client[ep_idx].num_ipv6_bytes);
 
 		/* update the USB UL stats */
 		data->ipv4_tx_packets +=
-			con_stats->client[index].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_tx_packets +=
-			con_stats->client[index].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_tx_bytes +=
-			con_stats->client[index].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_tx_bytes +=
-			con_stats->client[index].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 	}
 	/* query WLAN UL stats */
 	memset(con_stats, 0, sizeof(struct ipa_quota_stats_all));
@@ -5182,40 +5242,49 @@ skip_nlo_stats:
 	else
 		index = IPA_CLIENT_Q6_WAN_CONS;
 
+	ep_idx = ipa_get_ep_mapping( index );
+
+	if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+		return ep_idx ;
+
 	IPAWANDBG("wlan1: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
-	con_stats->client[index].num_ipv4_pkts,
-	con_stats->client[index].num_ipv4_bytes,
-	con_stats->client[index].num_ipv6_pkts,
-	con_stats->client[index].num_ipv6_bytes);
+	con_stats->client[ep_idx].num_ipv4_pkts,
+	con_stats->client[ep_idx].num_ipv4_bytes,
+	con_stats->client[ep_idx].num_ipv6_pkts,
+	con_stats->client[ep_idx].num_ipv6_bytes);
 
 	/* update the wlan UL stats */
 	data->ipv4_tx_packets +=
-		con_stats->client[index].num_ipv4_pkts;
+		con_stats->client[ep_idx].num_ipv4_pkts;
 	data->ipv6_tx_packets +=
-		con_stats->client[index].num_ipv6_pkts;
+		con_stats->client[ep_idx].num_ipv6_pkts;
 	data->ipv4_tx_bytes +=
-		con_stats->client[index].num_ipv4_bytes;
+		con_stats->client[ep_idx].num_ipv4_bytes;
 	data->ipv6_tx_bytes +=
-		con_stats->client[index].num_ipv6_bytes;
+		con_stats->client[ep_idx].num_ipv6_bytes;
 	if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5 &&
 		ipa3_ctx->platform_type == IPA_PLAT_TYPE_MSM) {
 		index = IPA_CLIENT_Q6_UL_NLO_DATA_CONS;
 
+		ep_idx = ipa_get_ep_mapping( index );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
 		IPAWANDBG("wlan1: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
-				con_stats->client[index].num_ipv4_pkts,
-				con_stats->client[index].num_ipv4_bytes,
-				con_stats->client[index].num_ipv6_pkts,
-				con_stats->client[index].num_ipv6_bytes);
+				con_stats->client[ep_idx].num_ipv4_pkts,
+				con_stats->client[ep_idx].num_ipv4_bytes,
+				con_stats->client[ep_idx].num_ipv6_pkts,
+				con_stats->client[ep_idx].num_ipv6_bytes);
 
 		/* update the USB UL stats */
 		data->ipv4_tx_packets +=
-			con_stats->client[index].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_tx_packets +=
-			con_stats->client[index].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_tx_bytes +=
-			con_stats->client[index].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_tx_bytes +=
-			con_stats->client[index].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 	}
 
 	if (ipa_get_ep_mapping(IPA_CLIENT_WIGIG_PROD) !=
@@ -5235,35 +5304,44 @@ skip_nlo_stats:
 		else
 			index = IPA_CLIENT_Q6_WAN_CONS;
 
+		ep_idx = ipa_get_ep_mapping( index );
+
+		if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+			return ep_idx ;
+
 		IPAWANDBG("wigig: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
-				con_stats->client[index].num_ipv4_pkts,
-				con_stats->client[index].num_ipv4_bytes,
-				con_stats->client[index].num_ipv6_pkts,
-				con_stats->client[index].num_ipv6_bytes);
+				con_stats->client[ep_idx].num_ipv4_pkts,
+				con_stats->client[ep_idx].num_ipv4_bytes,
+				con_stats->client[ep_idx].num_ipv6_pkts,
+				con_stats->client[ep_idx].num_ipv6_bytes);
 
 		/* update the WIGIG UL stats */
 		data->ipv4_tx_packets +=
-			con_stats->client[index].num_ipv4_pkts;
+			con_stats->client[ep_idx].num_ipv4_pkts;
 		data->ipv6_tx_packets +=
-			con_stats->client[index].num_ipv6_pkts;
+			con_stats->client[ep_idx].num_ipv6_pkts;
 		data->ipv4_tx_bytes +=
-			con_stats->client[index].num_ipv4_bytes;
+			con_stats->client[ep_idx].num_ipv4_bytes;
 		data->ipv6_tx_bytes +=
-			con_stats->client[index].num_ipv6_bytes;
+			con_stats->client[ep_idx].num_ipv6_bytes;
 
 		if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5 &&
 				ipa3_ctx->platform_type == IPA_PLAT_TYPE_MSM) {
 			index = IPA_CLIENT_Q6_UL_NLO_DATA_CONS;
 
+			ep_idx = ipa_get_ep_mapping( index );
+
+			if (ep_idx == -1 || ep_idx >= ipa3_get_max_num_pipes())
+				return ep_idx ;
 			/* update the WIGIG UL stats */
 			data->ipv4_tx_packets +=
-				con_stats->client[index].num_ipv4_pkts;
+				con_stats->client[ep_idx].num_ipv4_pkts;
 			data->ipv6_tx_packets +=
-				con_stats->client[index].num_ipv6_pkts;
+				con_stats->client[ep_idx].num_ipv6_pkts;
 			data->ipv4_tx_bytes +=
-				con_stats->client[index].num_ipv4_bytes;
+				con_stats->client[ep_idx].num_ipv4_bytes;
 			data->ipv6_tx_bytes +=
-				con_stats->client[index].num_ipv6_bytes;
+				con_stats->client[ep_idx].num_ipv6_bytes;
 		}
 
 	} else {