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

Commit 6f6e3076 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa4: add support for statistics



Implement hardware statistics in IPA driver.

Change-Id: I4720e18627df7925311ea5a9ca1feaaa076653a8
CRs-Fixed: 2069977
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 2c470a63
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@ obj-$(CONFIG_IPA3) += ipahal/
obj-$(CONFIG_IPA3) += ipat.o
obj-$(CONFIG_IPA3) += ipat.o
ipat-y := ipa.o ipa_debugfs.o ipa_hdr.o ipa_flt.o ipa_rt.o ipa_dp.o ipa_client.o \
ipat-y := ipa.o ipa_debugfs.o ipa_hdr.o ipa_flt.o ipa_rt.o ipa_dp.o ipa_client.o \
	ipa_utils.o ipa_nat.o ipa_intf.o teth_bridge.o ipa_interrupts.o \
	ipa_utils.o ipa_nat.o ipa_intf.o teth_bridge.o ipa_interrupts.o \
	ipa_uc.o ipa_uc_wdi.o ipa_dma.o ipa_uc_mhi.o ipa_mhi.o ipa_uc_ntn.o
	ipa_uc.o ipa_uc_wdi.o ipa_dma.o ipa_uc_mhi.o ipa_mhi.o ipa_uc_ntn.o \
	ipa_hw_stats.o


obj-$(CONFIG_RMNET_IPA3) += rmnet_ipa.o ipa_qmi_service_v01.o ipa_qmi_service.o rmnet_ipa_fd_ioctl.o
obj-$(CONFIG_RMNET_IPA3) += rmnet_ipa.o ipa_qmi_service_v01.o ipa_qmi_service.o rmnet_ipa_fd_ioctl.o
+6 −0
Original line number Original line Diff line number Diff line
@@ -4239,6 +4239,12 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
	else
	else
		IPADBG(":ntn init ok\n");
		IPADBG(":ntn init ok\n");


	result = ipa_hw_stats_init();
	if (result)
		IPAERR("fail to init stats %d\n", result);
	else
		IPADBG(":stats init ok\n");

	ipa3_register_panic_hdlr();
	ipa3_register_panic_hdlr();


	ipa3_ctx->q6_proxy_clk_vote_valid = true;
	ipa3_ctx->q6_proxy_clk_vote_valid = true;
+2 −0
Original line number Original line Diff line number Diff line
@@ -2171,6 +2171,8 @@ void ipa3_debugfs_init(void)
		goto fail;
		goto fail;
	}
	}


	ipa_debugfs_init_stats(dent);

	return;
	return;


fail:
fail:
+1973 −0

File added.

Preview size limit exceeded, changes collapsed.

+167 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@
#include "ipahal/ipahal_reg.h"
#include "ipahal/ipahal_reg.h"
#include "ipahal/ipahal.h"
#include "ipahal/ipahal.h"
#include "ipahal/ipahal_fltrt.h"
#include "ipahal/ipahal_fltrt.h"
#include "ipahal/ipahal_hw_stats.h"
#include "../ipa_common_i.h"
#include "../ipa_common_i.h"
#include "ipa_uc_offload_i.h"
#include "ipa_uc_offload_i.h"


@@ -1024,6 +1025,56 @@ struct ipa_dma_task_info {
	struct ipahal_imm_cmd_pyld *cmd_pyld;
	struct ipahal_imm_cmd_pyld *cmd_pyld;
};
};


struct ipa_quota_stats {
	u64 num_ipv4_bytes;
	u64 num_ipv6_bytes;
	u32 num_ipv4_pkts;
	u32 num_ipv6_pkts;
};

struct ipa_quota_stats_all {
	struct ipa_quota_stats client[IPA_CLIENT_MAX];
};

struct ipa_drop_stats {
	u32 drop_packet_cnt;
	u32 drop_byte_cnt;
};

struct ipa_drop_stats_all {
	struct ipa_drop_stats client[IPA_CLIENT_MAX];
};

struct ipa_hw_stats_quota {
	struct ipahal_stats_init_quota init;
	struct ipa_quota_stats_all stats;
};

struct ipa_hw_stats_teth {
	struct ipahal_stats_init_tethering init;
	struct ipa_quota_stats_all prod_stats[IPA_CLIENT_MAX];
};

struct ipa_hw_stats_flt_rt {
	struct ipahal_stats_init_flt_rt flt_v4_init;
	struct ipahal_stats_init_flt_rt flt_v6_init;
	struct ipahal_stats_init_flt_rt rt_v4_init;
	struct ipahal_stats_init_flt_rt rt_v6_init;
};

struct ipa_hw_stats_drop {
	struct ipahal_stats_init_drop init;
	struct ipa_drop_stats_all stats;
};

struct ipa_hw_stats {
	bool enabled;
	struct ipa_hw_stats_quota quota;
	struct ipa_hw_stats_teth teth;
	struct ipa_hw_stats_flt_rt flt_rt;
	struct ipa_hw_stats_drop drop;
};

/**
/**
 * struct ipa3_context - IPA context
 * struct ipa3_context - IPA context
 * @class: pointer to the struct class
 * @class: pointer to the struct class
@@ -1238,6 +1289,7 @@ struct ipa3_context {
	u32 ipa_tz_unlock_reg_num;
	u32 ipa_tz_unlock_reg_num;
	struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
	struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
	struct ipa_dma_task_info dma_task_info;
	struct ipa_dma_task_info dma_task_info;
	struct ipa_hw_stats hw_stats;
};
};


struct ipa3_plat_drv_res {
struct ipa3_plat_drv_res {
@@ -1350,6 +1402,48 @@ struct ipa3_plat_drv_res {
 * +-------------------------+
 * +-------------------------+
 * |    CANARY               |
 * |    CANARY               |
 * +-------------------------+
 * +-------------------------+
 * | QUOTA STATS             |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | TETH STATS              |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | V4 FLT STATS            |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | V6 FLT STATS            |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | V4 RT STATS             |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | V6 RT STATS             |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * | DROP STATS              |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |    CANARY               |
 * +-------------------------+
 * |  MODEM MEM              |
 * |  MODEM MEM              |
 * +-------------------------+
 * +-------------------------+
 * |    CANARY               |
 * |    CANARY               |
@@ -1432,6 +1526,20 @@ struct ipa3_mem_partition {
	u32 uc_event_ring_size;
	u32 uc_event_ring_size;
	u32 pdn_config_ofst;
	u32 pdn_config_ofst;
	u32 pdn_config_size;
	u32 pdn_config_size;
	u32 stats_quota_ofst;
	u32 stats_quota_size;
	u32 stats_tethering_ofst;
	u32 stats_tethering_size;
	u32 stats_flt_v4_ofst;
	u32 stats_flt_v4_size;
	u32 stats_flt_v6_ofst;
	u32 stats_flt_v6_size;
	u32 stats_rt_v4_ofst;
	u32 stats_rt_v4_size;
	u32 stats_rt_v6_ofst;
	u32 stats_rt_v6_size;
	u32 stats_drop_ofst;
	u32 stats_drop_size;
};
};


struct ipa3_controller {
struct ipa3_controller {
@@ -1980,6 +2088,65 @@ const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
	(enum ipa_client_type client);
	(enum ipa_client_type client);
void ipa3_uc_rg10_write_reg(enum ipahal_reg_name reg, u32 n, u32 val);
void ipa3_uc_rg10_write_reg(enum ipahal_reg_name reg, u32 n, u32 val);


/* Hardware stats */

#define IPA_STATS_MAX_PIPE_BIT 32

struct ipa_teth_stats_endpoints {
	u32 prod_mask;
	u32 dst_ep_mask[IPA_STATS_MAX_PIPE_BIT];
};

struct ipa_flt_rt_stats {
	u32 num_pkts;
	u32 num_pkts_hash;
};

int ipa_hw_stats_init(void);

int ipa_debugfs_init_stats(struct dentry *parent);

int ipa_init_quota_stats(u32 pipe_bitmask);

int ipa_get_quota_stats(struct ipa_quota_stats_all *out);

int ipa_reset_quota_stats(enum ipa_client_type client);

int ipa_reset_all_quota_stats(void);

int ipa_init_drop_stats(u32 pipe_bitmask);

int ipa_get_drop_stats(struct ipa_drop_stats_all *out);

int ipa_reset_drop_stats(enum ipa_client_type client);

int ipa_reset_all_drop_stats(void);

int ipa_init_teth_stats(struct ipa_teth_stats_endpoints *in);

int ipa_get_teth_stats(enum ipa_client_type prod,
	struct ipa_quota_stats_all *out);

int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons);

int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod);

int ipa_reset_all_teth_stats(void);

int ipa_flt_rt_stats_add_rule_id(enum ipa_ip_type ip, bool filtering,
	u16 rule_id);

int ipa_flt_rt_stats_start(enum ipa_ip_type ip, bool filtering);

int ipa_flt_rt_stats_clear_rule_ids(enum ipa_ip_type ip, bool filtering);

int ipa_get_flt_rt_stats(enum ipa_ip_type ip, bool filtering, u16 rule_id,
	struct ipa_flt_rt_stats *out);

int ipa_reset_flt_rt_stats(enum ipa_ip_type ip, bool filtering, u16 rule_id);

int ipa_reset_all_flt_rt_stats(enum ipa_ip_type ip, bool filtering);

u32 ipa3_get_num_pipes(void);
u32 ipa3_get_num_pipes(void);
struct ipa_smmu_cb_ctx *ipa3_get_smmu_ctx(void);
struct ipa_smmu_cb_ctx *ipa3_get_smmu_ctx(void);
struct ipa_smmu_cb_ctx *ipa3_get_wlan_smmu_ctx(void);
struct ipa_smmu_cb_ctx *ipa3_get_wlan_smmu_ctx(void);
Loading