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

Commit 0c37f5f6 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa4: make rule_id unique across tables



To enable HW statistics rule_id needs to be unique across tables
of the same type (IPv4/IPv6/Filtering/Routing).

Change-Id: Ie1dfc6de1eb7c3a1f1cc3f4230bc6910e2e6389a
CRs-Fixed: 2069977
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 814e5c69
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -3922,14 +3922,17 @@ static void ipa3_destroy_flt_tbl_idrs(void)
	int i;
	struct ipa3_flt_tbl *flt_tbl;

	idr_destroy(&ipa3_ctx->flt_rule_ids[IPA_IP_v4]);
	idr_destroy(&ipa3_ctx->flt_rule_ids[IPA_IP_v6]);

	for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
		if (!ipa_is_ep_support_flt(i))
			continue;

		flt_tbl = &ipa3_ctx->flt_tbl[i][IPA_IP_v4];
		idr_destroy(&flt_tbl->rule_ids);
		flt_tbl->rule_ids = NULL;
		flt_tbl = &ipa3_ctx->flt_tbl[i][IPA_IP_v6];
		idr_destroy(&flt_tbl->rule_ids);
		flt_tbl->rule_ids = NULL;
	}
}

@@ -4104,6 +4107,7 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
	struct ipa3_uc_hdlrs uc_hdlrs = { 0 };
	struct ipa3_flt_tbl *flt_tbl;
	int i;
	struct idr *idr;

	if (ipa3_ctx == NULL) {
		IPADBG("IPA driver haven't initialized\n");
@@ -4127,6 +4131,11 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
	/* Assign resource limitation to each group */
	ipa3_set_resorce_groups_min_max_limits();

	idr = &(ipa3_ctx->flt_rule_ids[IPA_IP_v4]);
	idr_init(idr);
	idr = &(ipa3_ctx->flt_rule_ids[IPA_IP_v6]);
	idr_init(idr);

	for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
		if (!ipa_is_ep_support_flt(i))
			continue;
@@ -4137,7 +4146,7 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
			!ipa3_ctx->ip4_flt_tbl_hash_lcl;
		flt_tbl->in_sys[IPA_RULE_NON_HASHABLE] =
			!ipa3_ctx->ip4_flt_tbl_nhash_lcl;
		idr_init(&flt_tbl->rule_ids);
		flt_tbl->rule_ids = &ipa3_ctx->flt_rule_ids[IPA_IP_v4];

		flt_tbl = &ipa3_ctx->flt_tbl[i][IPA_IP_v6];
		INIT_LIST_HEAD(&flt_tbl->head_flt_rule_list);
@@ -4145,7 +4154,7 @@ static int ipa3_post_init(const struct ipa3_plat_drv_res *resource_p,
			!ipa3_ctx->ip6_flt_tbl_hash_lcl;
		flt_tbl->in_sys[IPA_RULE_NON_HASHABLE] =
			!ipa3_ctx->ip6_flt_tbl_nhash_lcl;
		idr_init(&flt_tbl->rule_ids);
		flt_tbl->rule_ids = &ipa3_ctx->flt_rule_ids[IPA_IP_v6];
	}

	if (!ipa3_ctx->apply_rg10_wa) {
@@ -4790,12 +4799,16 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
				hdr_proc_ctx_tbl.head_free_offset_list[i]);
	}
	INIT_LIST_HEAD(&ipa3_ctx->rt_tbl_set[IPA_IP_v4].head_rt_tbl_list);
	idr_init(&ipa3_ctx->rt_tbl_set[IPA_IP_v4].rule_ids);
	INIT_LIST_HEAD(&ipa3_ctx->rt_tbl_set[IPA_IP_v6].head_rt_tbl_list);
	idr_init(&ipa3_ctx->rt_tbl_set[IPA_IP_v6].rule_ids);

	rset = &ipa3_ctx->reap_rt_tbl_set[IPA_IP_v4];
	INIT_LIST_HEAD(&rset->head_rt_tbl_list);
	idr_init(&rset->rule_ids);
	rset = &ipa3_ctx->reap_rt_tbl_set[IPA_IP_v6];
	INIT_LIST_HEAD(&rset->head_rt_tbl_list);
	idr_init(&rset->rule_ids);

	INIT_LIST_HEAD(&ipa3_ctx->intf_list);
	INIT_LIST_HEAD(&ipa3_ctx->msg_list);
@@ -4915,6 +4928,12 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
fail_device_create:
	unregister_chrdev_region(ipa3_ctx->dev_num, 1);
fail_alloc_chrdev_region:
	rset = &ipa3_ctx->reap_rt_tbl_set[IPA_IP_v6];
	idr_destroy(&rset->rule_ids);
	rset = &ipa3_ctx->reap_rt_tbl_set[IPA_IP_v4];
	idr_destroy(&rset->rule_ids);
	idr_destroy(&ipa3_ctx->rt_tbl_set[IPA_IP_v6].rule_ids);
	idr_destroy(&ipa3_ctx->rt_tbl_set[IPA_IP_v4].rule_ids);
	ipa3_free_dma_task_for_gsi();
fail_dma_task:
	idr_destroy(&ipa3_ctx->ipa_idr);
+5 −5
Original line number Diff line number Diff line
@@ -806,7 +806,7 @@ static int __ipa_create_flt_entry(struct ipa3_flt_entry **entry,
	if (rule->rule_id) {
		id = rule->rule_id;
	} else {
		id = ipa3_alloc_rule_id(&tbl->rule_ids);
		id = ipa3_alloc_rule_id(tbl->rule_ids);
		if (id < 0) {
			IPAERR("failed to allocate rule id\n");
			WARN_ON(1);
@@ -880,7 +880,7 @@ static int __ipa_add_flt_rule(struct ipa3_flt_tbl *tbl, enum ipa_ip_type ip,
	list_del(&entry->link);
	/* if rule id was allocated from idr, remove it */
	if (!(entry->rule_id & ipahal_get_rule_id_hi_bit()))
		idr_remove(&entry->tbl->rule_ids, entry->rule_id);
		idr_remove(entry->tbl->rule_ids, entry->rule_id);
	kmem_cache_free(ipa3_ctx->flt_rule_cache, entry);

error:
@@ -927,7 +927,7 @@ static int __ipa_add_flt_rule_after(struct ipa3_flt_tbl *tbl,
	list_del(&entry->link);
	/* if rule id was allocated from idr, remove it */
	if (!(entry->rule_id & ipahal_get_rule_id_hi_bit()))
		idr_remove(&entry->tbl->rule_ids, entry->rule_id);
		idr_remove(entry->tbl->rule_ids, entry->rule_id);
	kmem_cache_free(ipa3_ctx->flt_rule_cache, entry);

error:
@@ -961,7 +961,7 @@ static int __ipa_del_flt_rule(u32 rule_hdl)
	entry->cookie = 0;
	/* if rule id was allocated from idr, remove it */
	if (!(entry->rule_id & ipahal_get_rule_id_hi_bit()))
		idr_remove(&entry->tbl->rule_ids, entry->rule_id);
		idr_remove(entry->tbl->rule_ids, entry->rule_id);

	kmem_cache_free(ipa3_ctx->flt_rule_cache, entry);

@@ -1374,7 +1374,7 @@ int ipa3_reset_flt(enum ipa_ip_type ip)
				entry->rt_tbl->ref_cnt--;
			/* if rule id was allocated from idr, remove it */
			if (!(entry->rule_id & ipahal_get_rule_id_hi_bit()))
				idr_remove(&entry->tbl->rule_ids,
				idr_remove(entry->tbl->rule_ids,
					entry->rule_id);
			entry->cookie = 0;
			id = entry->id;
+8 −4
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ struct ipa3_flt_entry {
 * @curr_mem: current routing tables block in sys memory
 * @prev_mem: previous routing table block in sys memory
 * @id: routing table id
 * @rule_ids: idr structure that holds the rule_id for each rule
 * @rule_ids: common idr structure that holds the rule_id for each rule
 */
struct ipa3_rt_tbl {
	struct list_head link;
@@ -254,7 +254,7 @@ struct ipa3_rt_tbl {
	struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
	struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
	int id;
	struct idr rule_ids;
	struct idr *rule_ids;
};

/**
@@ -376,7 +376,7 @@ struct ipa3_hdr_proc_ctx_tbl {
 * @end: the last header index
 * @curr_mem: current filter tables block in sys memory
 * @prev_mem: previous filter table block in sys memory
 * @rule_ids: idr structure that holds the rule_id for each rule
 * @rule_ids: common idr structure that holds the rule_id for each rule
 */
struct ipa3_flt_tbl {
	struct list_head head_flt_rule_list;
@@ -386,7 +386,7 @@ struct ipa3_flt_tbl {
	struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
	struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
	bool sticky_rear;
	struct idr rule_ids;
	struct idr *rule_ids;
};

/**
@@ -420,10 +420,12 @@ struct ipa3_rt_entry {
 * struct ipa3_rt_tbl_set - collection of routing tables
 * @head_rt_tbl_list: collection of routing tables
 * @tbl_cnt: number of routing tables
 * @rule_ids: idr structure that holds the rule_id for each rule
 */
struct ipa3_rt_tbl_set {
	struct list_head head_rt_tbl_list;
	u32 tbl_cnt;
	struct idr rule_ids;
};

/**
@@ -1035,6 +1037,7 @@ struct ipa_dma_task_info {
 * @ep_flt_num: End-points supporting filtering number
 * @resume_on_connect: resume ep on ipa connect
 * @flt_tbl: list of all IPA filter tables
 * @flt_rule_ids: idr structure that holds the rule_id for each rule
 * @mode: IPA operating mode
 * @mmio: iomem
 * @ipa_wrapper_base: IPA wrapper base address
@@ -1120,6 +1123,7 @@ struct ipa3_context {
	u32 ep_flt_num;
	bool resume_on_connect[IPA_CLIENT_MAX];
	struct ipa3_flt_tbl flt_tbl[IPA3_MAX_NUM_PIPES][IPA_IP_MAX];
	struct idr flt_rule_ids[IPA_IP_MAX];
	void __iomem *mmio;
	u32 ipa_wrapper_base;
	u32 ipa_wrapper_size;
+8 −8
Original line number Diff line number Diff line
@@ -801,7 +801,7 @@ static struct ipa3_rt_tbl *__ipa_add_rt_tbl(enum ipa_ip_type ip,
			!ipa3_ctx->ip4_rt_tbl_nhash_lcl :
			!ipa3_ctx->ip6_rt_tbl_nhash_lcl;
		set->tbl_cnt++;
		idr_init(&entry->rule_ids);
		entry->rule_ids = &set->rule_ids;
		list_add(&entry->link, &set->head_rt_tbl_list);

		IPADBG("add rt tbl idx=%d tbl_cnt=%d ip=%d\n", entry->idx,
@@ -820,7 +820,7 @@ static struct ipa3_rt_tbl *__ipa_add_rt_tbl(enum ipa_ip_type ip,
ipa_insert_failed:
	set->tbl_cnt--;
	list_del(&entry->link);
	idr_destroy(&entry->rule_ids);
	idr_destroy(entry->rule_ids);
fail_rt_idx_alloc:
	entry->cookie = 0;
	kmem_cache_free(ipa3_ctx->rt_tbl_cache, entry);
@@ -855,7 +855,7 @@ static int __ipa_del_rt_tbl(struct ipa3_rt_tbl *entry)

	rset = &ipa3_ctx->reap_rt_tbl_set[ip];

	idr_destroy(&entry->rule_ids);
	entry->rule_ids = NULL;
	if (entry->in_sys[IPA_RULE_HASHABLE] ||
		entry->in_sys[IPA_RULE_NON_HASHABLE]) {
		list_move(&entry->link, &rset->head_rt_tbl_list);
@@ -923,7 +923,7 @@ static int __ipa_create_rt_entry(struct ipa3_rt_entry **entry,
	(*(entry))->tbl = tbl;
	(*(entry))->hdr = hdr;
	(*(entry))->proc_ctx = proc_ctx;
	id = ipa3_alloc_rule_id(&tbl->rule_ids);
	id = ipa3_alloc_rule_id(tbl->rule_ids);
	if (id < 0) {
		IPAERR("failed to allocate rule id\n");
		WARN_ON(1);
@@ -967,7 +967,7 @@ static int __ipa_finish_rt_rule_add(struct ipa3_rt_entry *entry, u32 *rule_hdl,
		entry->hdr->ref_cnt--;
	else if (entry->proc_ctx)
		entry->proc_ctx->ref_cnt--;
	idr_remove(&tbl->rule_ids, entry->rule_id);
	idr_remove(tbl->rule_ids, entry->rule_id);
	list_del(&entry->link);
	kmem_cache_free(ipa3_ctx->rt_rule_cache, entry);
	return -EPERM;
@@ -1219,7 +1219,7 @@ int __ipa3_del_rt_rule(u32 rule_hdl)
	IPADBG("del rt rule tbl_idx=%d rule_cnt=%d rule_id=%d\n ref_cnt=%u",
		entry->tbl->idx, entry->tbl->rule_cnt,
		entry->rule_id, entry->tbl->ref_cnt);
	idr_remove(&entry->tbl->rule_ids, entry->rule_id);
	idr_remove(entry->tbl->rule_ids, entry->rule_id);
	if (entry->tbl->rule_cnt == 0 && entry->tbl->ref_cnt == 0) {
		if (__ipa_del_rt_tbl(entry->tbl))
			IPAERR("fail to del RT tbl\n");
@@ -1378,7 +1378,7 @@ int ipa3_reset_rt(enum ipa_ip_type ip)
			else if (rule->proc_ctx)
				__ipa3_release_hdr_proc_ctx(rule->proc_ctx->id);
			rule->cookie = 0;
			idr_remove(&tbl->rule_ids, rule->rule_id);
			idr_remove(tbl->rule_ids, rule->rule_id);
			id = rule->id;
			kmem_cache_free(ipa3_ctx->rt_rule_cache, rule);

@@ -1395,7 +1395,7 @@ int ipa3_reset_rt(enum ipa_ip_type ip)

		/* do not remove the "default" routing tbl which has index 0 */
		if (tbl->idx != apps_start_idx) {
			idr_destroy(&tbl->rule_ids);
			tbl->rule_ids = NULL;
			if (tbl->in_sys[IPA_RULE_HASHABLE] ||
				tbl->in_sys[IPA_RULE_NON_HASHABLE]) {
				list_move(&tbl->link, &rset->head_rt_tbl_list);