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

Commit 3cf6a96d authored by Amir Levy's avatar Amir Levy
Browse files

msm: ipa3: allow filter rule id from client



Add a parameter to add_flt_rule() API for specifying a rule_id.
The rule_id must not be in the range of auto generated rule_id
by the driver.

Change-Id: I05e5d577e9d7c2c998e35c92d8a4ce6d56a3d0cd
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
Signed-off-by: default avatarAmir Levy <alevy@codeaurora.org>
parent 02c8579d
Loading
Loading
Loading
Loading
+30 −7
Original line number Diff line number Diff line
@@ -1068,6 +1068,18 @@ static int __ipa_validate_flt_rule(const struct ipa_flt_rule *rule,
		}
	}

	if (rule->rule_id) {
		if (rule->rule_id >= IPA_RULE_ID_MIN_VAL &&
		    rule->rule_id <= IPA_RULE_ID_MAX_VAL) {
			IPAERR("invalid rule_id provided 0x%x\n"
				"rule_id 0x%x - 0x%x  are auto generated\n",
				rule->rule_id,
				IPA_RULE_ID_MIN_VAL,
				IPA_RULE_ID_MAX_VAL);
			goto error;
		}
	}

	return 0;

error:
@@ -1090,12 +1102,16 @@ static int __ipa_create_flt_entry(struct ipa3_flt_entry **entry,
	(*entry)->cookie = IPA_COOKIE;
	(*entry)->rt_tbl = rt_tbl;
	(*entry)->tbl = tbl;
	if (rule->rule_id) {
		id = rule->rule_id;
	} else {
		id = ipa3_alloc_rule_id(&tbl->rule_ids);
		if (id < 0) {
			IPAERR("failed to allocate rule id\n");
			WARN_ON(1);
			goto rule_id_fail;
		}
	}
	(*entry)->rule_id = id;

	return 0;
@@ -1221,6 +1237,9 @@ static int __ipa_del_flt_rule(u32 rule_hdl)
	IPADBG("del flt rule rule_cnt=%d rule_id=%d\n",
		entry->tbl->rule_cnt, entry->rule_id);
	entry->cookie = 0;
	/* if rule id was allocated from idr, remove it */
	if (entry->rule_id >= IPA_RULE_ID_MIN_VAL &&
	    entry->rule_id <= IPA_RULE_ID_MAX_VAL)
		idr_remove(&entry->tbl->rule_ids, entry->rule_id);
	kmem_cache_free(ipa3_ctx->flt_rule_cache, entry);

@@ -1632,7 +1651,11 @@ int ipa3_reset_flt(enum ipa_ip_type ip)
			entry->tbl->rule_cnt--;
			if (entry->rt_tbl)
				entry->rt_tbl->ref_cnt--;
			idr_remove(&entry->tbl->rule_ids, entry->rule_id);
			/* if rule id was allocated from idr, remove it */
			if (entry->rule_id >= IPA_RULE_ID_MIN_VAL &&
			    entry->rule_id <= IPA_RULE_ID_MAX_VAL)
				idr_remove(&entry->tbl->rule_ids,
						entry->rule_id);
			entry->cookie = 0;
			id = entry->id;
			kmem_cache_free(ipa3_ctx->flt_rule_cache, entry);
+3 −3
Original line number Diff line number Diff line
@@ -155,8 +155,8 @@
#define IPA_RULE_MAX_PRIORITY (0)
#define IPA_RULE_MIN_PRIORITY (1023)

#define IPA_RULE_ID_MIN_VAL (0)
#define IPA_RULE_ID_MAX_VAL (1022)
#define IPA_RULE_ID_MIN_VAL (0x01)
#define IPA_RULE_ID_MAX_VAL (0x1FF)
#define IPA_RULE_ID_RULE_MISS (0x3FF)

#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
@@ -208,7 +208,7 @@ struct ipa3_mem_buffer {
 * @tbl: filter table
 * @rt_tbl: routing table
 * @hw_len: entry's size
 * @id: rule handle - globaly unique
 * @id: rule handle - globally unique
 * @prio: rule 10bit priority which defines the order of the rule
 *  among other rules at the same integrated table
 * @rule_id: rule 10bit ID to be returned in packet status
+3 −0
Original line number Diff line number Diff line
@@ -598,6 +598,8 @@ struct ipa_ipfltri_rule_eq {
 * @hashable: bool switch. is this rule hashable or not?
 *  ipa uses hashable rules to cache their hit results to be used in
 *  consecutive packets
 * @rule_id: rule_id to be assigned to the filter rule. In case client specifies
 *  rule_id as 0 the driver will assign a new rule_id
 */
struct ipa_flt_rule {
	uint8_t retain_hdr;
@@ -610,6 +612,7 @@ struct ipa_flt_rule {
	uint8_t eq_attrib_type;
	uint8_t max_prio;
	uint8_t hashable;
	uint16_t rule_id;
};

/**