Browse Source

Merge "msm: ipa: Add API to set IPA client filtering table SRAM priority high"

qctecmdr 3 years ago
parent
commit
2c6c923133

+ 7 - 1
drivers/platform/msm/ipa/ipa_v3/ipa.c

@@ -3999,7 +3999,13 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		}
 
 		break;
-
+#ifdef IPA_IOC_FLT_MEM_PERIPHERAL_SET_PRIO_HIGH
+	case IPA_IOC_FLT_MEM_PERIPHERAL_SET_PRIO_HIGH:
+		retval = ipa_flt_sram_set_client_prio_high((enum ipa_client_type) arg);
+		if (retval)
+			IPAERR("ipa_flt_sram_set_client_prio_high failed! retval=%d\n", retval);
+		break;
+#endif
 	default:
 		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
 		return -ENOTTY;

+ 39 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_flt.c

@@ -2217,3 +2217,42 @@ bail:
 	iounmap(ipa_sram_mmio);
 	return 0;
 }
+
+int ipa_flt_sram_set_client_prio_high(enum ipa_client_type client)
+{
+	int ipa_ep_idx = IPA_EP_NOT_ALLOCATED;
+	enum ipa_ip_type ip;
+
+	/* allow setting high priority only to ETH clients */
+	if (!IPA_CLIENT_IS_ETH_PROD(client)) {
+		IPAERR("Operation not permitted for non ETH clients\n");
+		return -EINVAL;
+	}
+
+	ipa_ep_idx = ipa_get_ep_mapping(client);
+	if (ipa_ep_idx == IPA_EP_NOT_ALLOCATED)
+		return -EINVAL;
+
+	if (!ipa_is_ep_support_flt(ipa_ep_idx))
+		return -EINVAL;
+
+	mutex_lock(&ipa3_ctx->lock);
+	for (ip = IPA_IP_v4; ip < IPA_IP_MAX; ip++) {
+		struct ipa3_flt_tbl_nhash_lcl *lcl_tbl, *tmp;
+		struct ipa3_flt_tbl *flt_tbl = &ipa3_ctx->flt_tbl[ipa_ep_idx][ip];
+		/* Position filtering table last in the list so, it will have first SRAM priority */
+		list_for_each_entry_safe(
+			lcl_tbl, tmp, &ipa3_ctx->flt_tbl_nhash_lcl_list[ip], link) {
+			if (lcl_tbl->tbl == flt_tbl) {
+				list_del(&lcl_tbl->link);
+				list_add_tail(&lcl_tbl->link,
+					&ipa3_ctx->flt_tbl_nhash_lcl_list[ip]);
+				break;
+			}
+		}
+	}
+	mutex_unlock(&ipa3_ctx->lock);
+
+	return 0;
+}
+

+ 2 - 1
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -891,7 +891,6 @@ struct ipa3_hdr_proc_ctx_tbl {
  * @rule_cnt: number of filter rules
  * @in_sys: flag indicating if filter table is located in system memory
  * @sz: the size of the filter tables
- * @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: common idr structure that holds the rule_id for each rule
@@ -2866,6 +2865,8 @@ int ipa3_commit_flt(enum ipa_ip_type ip);
 
 int ipa3_reset_flt(enum ipa_ip_type ip, bool user_only);
 
+int ipa_flt_sram_set_client_prio_high(enum ipa_client_type client);
+
 /*
  * NAT
  */