Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 761ebda6 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa: add IPA hw stats for PCIE modem



Add the IPA hw counter support for getting
stats on PCIE modem.

Change-Id: I090249d57cc1af3e09277004675703dcc189a54a
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 679dfb32
Loading
Loading
Loading
Loading
+74 −16
Original line number Diff line number Diff line
@@ -32,10 +32,32 @@ int ipa_hw_stats_init(void)
		return -ENOMEM;
	}
	/* enable prod mask */
	if (ipa3_ctx->platform_type == IPA_PLAT_TYPE_APQ) {
		teth_stats_init->prod_mask = (
			IPA_CLIENT_BIT_32(IPA_CLIENT_MHI_PRIME_TETH_PROD) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_USB_PROD) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN1_PROD) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN2_PROD));

		if (IPA_CLIENT_BIT_32(IPA_CLIENT_MHI_PRIME_TETH_PROD)) {
			ep_index = ipa3_get_ep_mapping(
				IPA_CLIENT_MHI_PRIME_TETH_PROD);
			if (ep_index == -1) {
				IPAERR("Invalid client.\n");
				kfree(teth_stats_init);
				return -EINVAL;
			}
			teth_stats_init->dst_ep_mask[ep_index] =
				(IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN1_CONS) |
				IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN2_CONS) |
				IPA_CLIENT_BIT_32(IPA_CLIENT_USB_CONS));
		}
	} else {
		teth_stats_init->prod_mask = (
			IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_PROD) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_USB_PROD) |
		IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN1_PROD));
			IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN1_PROD) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN2_PROD));

		if (IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_PROD)) {
			ep_index = ipa3_get_ep_mapping(IPA_CLIENT_Q6_WAN_PROD);
@@ -46,8 +68,10 @@ int ipa_hw_stats_init(void)
			}
			teth_stats_init->dst_ep_mask[ep_index] =
			(IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN1_CONS) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN2_CONS) |
			IPA_CLIENT_BIT_32(IPA_CLIENT_USB_CONS));
		}
	}

	if (IPA_CLIENT_BIT_32(IPA_CLIENT_USB_PROD)) {
		ep_index = ipa3_get_ep_mapping(IPA_CLIENT_USB_PROD);
@@ -56,6 +80,14 @@ int ipa_hw_stats_init(void)
			kfree(teth_stats_init);
			return -EINVAL;
		}
		/* enable addtional pipe monitoring for pcie modem */
		if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_1)
			teth_stats_init->dst_ep_mask[ep_index] =
				(IPA_CLIENT_BIT_32(
					IPA_CLIENT_Q6_WAN_CONS) |
				IPA_CLIENT_BIT_32(
					IPA_CLIENT_MHI_PRIME_TETH_CONS));
		else
			teth_stats_init->dst_ep_mask[ep_index] =
				IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_CONS);
	}
@@ -67,10 +99,36 @@ int ipa_hw_stats_init(void)
			kfree(teth_stats_init);
			return -EINVAL;
		}
		/* enable addtional pipe monitoring for pcie modem*/
		if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_1)
			teth_stats_init->dst_ep_mask[ep_index] =
				(IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_CONS) |
				IPA_CLIENT_BIT_32(
					IPA_CLIENT_MHI_PRIME_TETH_CONS));
		else
			teth_stats_init->dst_ep_mask[ep_index] =
				IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_CONS);
	}

	if (IPA_CLIENT_BIT_32(IPA_CLIENT_WLAN2_PROD)) {
		ep_index = ipa3_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
		if (ep_index == -1) {
			IPAERR("Invalid client.\n");
			kfree(teth_stats_init);
			return -EINVAL;
		}
		/* enable addtional pipe monitoring for pcie modem*/
		if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_1)
			teth_stats_init->dst_ep_mask[ep_index] =
				(IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_CONS) |
				IPA_CLIENT_BIT_32(
					IPA_CLIENT_MHI_PRIME_TETH_CONS));
		else
			teth_stats_init->dst_ep_mask[ep_index] =
				IPA_CLIENT_BIT_32(IPA_CLIENT_Q6_WAN_CONS);
	}


	ret = ipa_init_teth_stats(teth_stats_init);
	if (ret != 0)
		IPAERR("init teth stats fails\n");
+79 −23
Original line number Diff line number Diff line
@@ -3609,7 +3609,7 @@ static int rmnet_ipa3_query_tethering_stats_modem(
static int rmnet_ipa3_query_tethering_stats_hw(
	struct wan_ioctl_query_tether_stats *data, bool reset)
{
	int rc = 0;
	int rc = 0, index = 0;
	struct ipa_quota_stats_all *con_stats;

	/* qet HW-stats */
@@ -3626,12 +3626,24 @@ static int rmnet_ipa3_query_tethering_stats_hw(
		IPAWANERR("no memory\n");
		return -ENOMEM;
	}
	rc = ipa_query_teth_stats(IPA_CLIENT_Q6_WAN_PROD, con_stats, reset);

	if (rmnet_ipa3_ctx->ipa_config_is_apq) {
		rc = ipa_query_teth_stats(IPA_CLIENT_MHI_PRIME_TETH_PROD,
			con_stats, reset);
		if (rc) {
			IPAERR("MHI_PRIME_TETH_PROD query failed %d,\n", rc);
			kfree(con_stats);
			return rc;
		}
	} else {
		rc = ipa_query_teth_stats(IPA_CLIENT_Q6_WAN_PROD,
			con_stats, reset);
		if (rc) {
			IPAERR("IPA_CLIENT_Q6_WAN_PROD query failed %d,\n", rc);
			kfree(con_stats);
			return rc;
		}
	}
	IPAWANDBG("wlan: v4_rx_p(%d) b(%lld) v6_rx_p(%d) b(%lld)\n",
	con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv4_pkts,
	con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv4_bytes,
@@ -3647,15 +3659,19 @@ static int rmnet_ipa3_query_tethering_stats_hw(
	/* update the DL stats */
	data->ipv4_rx_packets =
		con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv4_pkts +
		con_stats->client[IPA_CLIENT_WLAN2_CONS].num_ipv4_pkts +
			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_pkts;
	data->ipv6_rx_packets =
		con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv6_pkts +
		con_stats->client[IPA_CLIENT_WLAN2_CONS].num_ipv6_pkts +
			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_pkts;
	data->ipv4_rx_bytes =
		con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv4_bytes +
		con_stats->client[IPA_CLIENT_WLAN2_CONS].num_ipv4_bytes +
			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv4_bytes;
	data->ipv6_rx_bytes =
		con_stats->client[IPA_CLIENT_WLAN1_CONS].num_ipv6_bytes +
		con_stats->client[IPA_CLIENT_WLAN2_CONS].num_ipv6_bytes +
			con_stats->client[IPA_CLIENT_USB_CONS].num_ipv6_bytes;

	IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
@@ -3673,21 +3689,26 @@ static int rmnet_ipa3_query_tethering_stats_hw(
		return rc;
	}

	if (rmnet_ipa3_ctx->ipa_config_is_apq)
		index = IPA_CLIENT_MHI_PRIME_TETH_CONS;
	else
		index = IPA_CLIENT_Q6_WAN_CONS;

	IPAWANDBG("usb: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_pkts,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_bytes,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_pkts,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_bytes);
	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);

	/* update the USB UL stats */
	data->ipv4_tx_packets =
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_pkts;
		con_stats->client[index].num_ipv4_pkts;
	data->ipv6_tx_packets =
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_pkts;
		con_stats->client[index].num_ipv6_pkts;
	data->ipv4_tx_bytes =
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_bytes;
		con_stats->client[index].num_ipv4_bytes;
	data->ipv6_tx_bytes =
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_bytes;
		con_stats->client[index].num_ipv6_bytes;

	/* query WLAN UL stats */
	memset(con_stats, 0, sizeof(struct ipa_quota_stats_all));
@@ -3698,21 +3719,56 @@ static int rmnet_ipa3_query_tethering_stats_hw(
		return rc;
	}

	IPAWANDBG("wlan: v4_tx_p(%d) b(%lld) v6_tx_p(%d) b(%lld)\n",
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_pkts,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_bytes,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_pkts,
	con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_bytes);
	if (rmnet_ipa3_ctx->ipa_config_is_apq)
		index = IPA_CLIENT_MHI_PRIME_TETH_CONS;
	else
		index = IPA_CLIENT_Q6_WAN_CONS;

	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);

	/* update the wlan UL stats */
	data->ipv4_tx_packets +=
		con_stats->client[index].num_ipv4_pkts;
	data->ipv6_tx_packets +=
		con_stats->client[index].num_ipv6_pkts;
	data->ipv4_tx_bytes +=
		con_stats->client[index].num_ipv4_bytes;
	data->ipv6_tx_bytes +=
		con_stats->client[index].num_ipv6_bytes;

	/* query WLAN2 UL stats */
	memset(con_stats, 0, sizeof(struct ipa_quota_stats_all));
	rc = ipa_query_teth_stats(IPA_CLIENT_WLAN2_PROD, con_stats, reset);
	if (rc) {
		IPAERR("IPA_CLIENT_WLAN2_PROD query failed %d\n", rc);
		kfree(con_stats);
		return rc;
	}

	if (rmnet_ipa3_ctx->ipa_config_is_apq)
		index = IPA_CLIENT_MHI_PRIME_TETH_CONS;
	else
		index = IPA_CLIENT_Q6_WAN_CONS;

	IPAWANDBG("wlan2: 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);

	/* update the wlan UL stats */
	data->ipv4_tx_packets +=
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_pkts;
		con_stats->client[index].num_ipv4_pkts;
	data->ipv6_tx_packets +=
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_pkts;
		con_stats->client[index].num_ipv6_pkts;
	data->ipv4_tx_bytes +=
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv4_bytes;
		con_stats->client[index].num_ipv4_bytes;
	data->ipv6_tx_bytes +=
		con_stats->client[IPA_CLIENT_Q6_WAN_CONS].num_ipv6_bytes;
		con_stats->client[index].num_ipv6_bytes;

	IPAWANDBG("v4_tx_p(%lu) v6_tx_p(%lu) v4_tx_b(%lu) v6_tx_b(%lu)\n",
		(unsigned long) data->ipv4_tx_packets,