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

Commit d300d690 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa: support ipacm cleanup"

parents 8e233175 68c37d88
Loading
Loading
Loading
Loading
+171 −105
Original line number Original line Diff line number Diff line
@@ -739,6 +739,26 @@ int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs)
}
}
EXPORT_SYMBOL(ipa_add_hdr);
EXPORT_SYMBOL(ipa_add_hdr);


/**
 * ipa_add_hdr_usr() - add the specified headers to SW and optionally
 * commit them to IPA HW
 * @hdrs:		[inout] set of headers to add
 * @user_only:	[in] indicate rules installed by userspace
 *
 * Returns:	0 on success, negative on failure
 *
 * Note:	Should not be called from atomic context
 */
int ipa_add_hdr_usr(struct ipa_ioc_add_hdr *hdrs, bool user_only)
{
	int ret;

	IPA_API_DISPATCH_RETURN(ipa_add_hdr_usr, hdrs, user_only);

	return ret;
}
EXPORT_SYMBOL(ipa_add_hdr_usr);

/**
/**
 * ipa_del_hdr() - Remove the specified headers from SW and optionally
 * ipa_del_hdr() - Remove the specified headers from SW and optionally
 * commit them to IPA HW
 * commit them to IPA HW
@@ -779,15 +799,16 @@ EXPORT_SYMBOL(ipa_commit_hdr);
 * ipa_reset_hdr() - reset the current header table in SW (does not commit to
 * ipa_reset_hdr() - reset the current header table in SW (does not commit to
 * HW)
 * HW)
 *
 *
 * @user_only:	[in] indicate delete rules installed by userspace
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa_reset_hdr(void)
int ipa_reset_hdr(bool user_only)
{
{
	int ret;
	int ret;


	IPA_API_DISPATCH_RETURN(ipa_reset_hdr);
	IPA_API_DISPATCH_RETURN(ipa_reset_hdr, user_only);


	return ret;
	return ret;
}
}
@@ -857,16 +878,18 @@ EXPORT_SYMBOL(ipa_copy_hdr);
 * ipa_add_hdr_proc_ctx() - add the specified headers to SW
 * ipa_add_hdr_proc_ctx() - add the specified headers to SW
 * and optionally commit them to IPA HW
 * and optionally commit them to IPA HW
 * @proc_ctxs:	[inout] set of processing context headers to add
 * @proc_ctxs:	[inout] set of processing context headers to add
 * @user_only:	[in] indicate rules installed by userspace
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs)
int ipa_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
							bool user_only)
{
{
	int ret;
	int ret;


	IPA_API_DISPATCH_RETURN(ipa_add_hdr_proc_ctx, proc_ctxs);
	IPA_API_DISPATCH_RETURN(ipa_add_hdr_proc_ctx, proc_ctxs, user_only);


	return ret;
	return ret;
}
}
@@ -911,6 +934,26 @@ int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
}
}
EXPORT_SYMBOL(ipa_add_rt_rule);
EXPORT_SYMBOL(ipa_add_rt_rule);


/**
 * ipa_add_rt_rule_usr() - Add the specified routing rules to SW and optionally
 * commit to IPA HW
 * @rules:	[inout] set of routing rules to add
 * @user_only:	[in] indicate rules installed by userspace
 *
 * Returns:	0 on success, negative on failure
 *
 * Note:	Should not be called from atomic context
 */
int ipa_add_rt_rule_usr(struct ipa_ioc_add_rt_rule *rules, bool user_only)
{
	int ret;

	IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_usr, rules, user_only);

	return ret;
}
EXPORT_SYMBOL(ipa_add_rt_rule_usr);

/**
/**
 * ipa_del_rt_rule() - Remove the specified routing rules to SW and optionally
 * ipa_del_rt_rule() - Remove the specified routing rules to SW and optionally
 * commit to IPA HW
 * commit to IPA HW
@@ -953,16 +996,17 @@ EXPORT_SYMBOL(ipa_commit_rt);
 * ipa_reset_rt() - reset the current SW routing table of specified type
 * ipa_reset_rt() - reset the current SW routing table of specified type
 * (does not commit to HW)
 * (does not commit to HW)
 * @ip:	The family of routing tables
 * @ip:	The family of routing tables
 * @user_only:	[in] indicate delete rules installed by userspace
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa_reset_rt(enum ipa_ip_type ip)
int ipa_reset_rt(enum ipa_ip_type ip, bool user_only)
{
{
	int ret;
	int ret;


	IPA_API_DISPATCH_RETURN(ipa_reset_rt, ip);
	IPA_API_DISPATCH_RETURN(ipa_reset_rt, ip, user_only);


	return ret;
	return ret;
}
}
@@ -1045,6 +1089,7 @@ EXPORT_SYMBOL(ipa_mdfy_rt_rule);
/**
/**
 * ipa_add_flt_rule() - Add the specified filtering rules to SW and optionally
 * ipa_add_flt_rule() - Add the specified filtering rules to SW and optionally
 * commit to IPA HW
 * commit to IPA HW
 * @rules:	[inout] set of filtering rules to add
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
@@ -1060,6 +1105,26 @@ int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
}
}
EXPORT_SYMBOL(ipa_add_flt_rule);
EXPORT_SYMBOL(ipa_add_flt_rule);


/**
 * ipa_add_flt_rule_usr() - Add the specified filtering rules to
 * SW and optionally commit to IPA HW
 * @rules:		[inout] set of filtering rules to add
 * @user_only:	[in] indicate rules installed by userspace
 *
 * Returns:	0 on success, negative on failure
 *
 * Note:	Should not be called from atomic context
 */
int ipa_add_flt_rule_usr(struct ipa_ioc_add_flt_rule *rules, bool user_only)
{
	int ret;

	IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_usr, rules, user_only);

	return ret;
}
EXPORT_SYMBOL(ipa_add_flt_rule_usr);

/**
/**
 * ipa_del_flt_rule() - Remove the specified filtering rules from SW and
 * ipa_del_flt_rule() - Remove the specified filtering rules from SW and
 * optionally commit to IPA HW
 * optionally commit to IPA HW
@@ -1119,16 +1184,17 @@ EXPORT_SYMBOL(ipa_commit_flt);
 * ipa_reset_flt() - Reset the current SW filtering table of specified type
 * ipa_reset_flt() - Reset the current SW filtering table of specified type
 * (does not commit to HW)
 * (does not commit to HW)
 * @ip:			[in] the family of routing tables
 * @ip:			[in] the family of routing tables
 * @user_only:	[in] indicate delete rules installed by userspace
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa_reset_flt(enum ipa_ip_type ip)
int ipa_reset_flt(enum ipa_ip_type ip, bool user_only)
{
{
	int ret;
	int ret;


	IPA_API_DISPATCH_RETURN(ipa_reset_flt, ip);
	IPA_API_DISPATCH_RETURN(ipa_reset_flt, ip, user_only);


	return ret;
	return ret;
}
}
@@ -2854,7 +2920,7 @@ static int ipa_generic_plat_drv_probe(struct platform_device *pdev_p)
{
{
	int result;
	int result;


	/*
/**
 * IPA probe function can be called for multiple times as the same probe
 * IPA probe function can be called for multiple times as the same probe
 * function handles multiple compatibilities
 * function handles multiple compatibilities
 */
 */
+13 −4
Original line number Original line Diff line number Diff line
@@ -73,11 +73,13 @@ struct ipa_api_controller {


	int (*ipa_add_hdr)(struct ipa_ioc_add_hdr *hdrs);
	int (*ipa_add_hdr)(struct ipa_ioc_add_hdr *hdrs);


	int (*ipa_add_hdr_usr)(struct ipa_ioc_add_hdr *hdrs, bool user_only);

	int (*ipa_del_hdr)(struct ipa_ioc_del_hdr *hdls);
	int (*ipa_del_hdr)(struct ipa_ioc_del_hdr *hdls);


	int (*ipa_commit_hdr)(void);
	int (*ipa_commit_hdr)(void);


	int (*ipa_reset_hdr)(void);
	int (*ipa_reset_hdr)(bool user_only);


	int (*ipa_get_hdr)(struct ipa_ioc_get_hdr *lookup);
	int (*ipa_get_hdr)(struct ipa_ioc_get_hdr *lookup);


@@ -85,17 +87,21 @@ struct ipa_api_controller {


	int (*ipa_copy_hdr)(struct ipa_ioc_copy_hdr *copy);
	int (*ipa_copy_hdr)(struct ipa_ioc_copy_hdr *copy);


	int (*ipa_add_hdr_proc_ctx)(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs);
	int (*ipa_add_hdr_proc_ctx)(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
								bool user_only);


	int (*ipa_del_hdr_proc_ctx)(struct ipa_ioc_del_hdr_proc_ctx *hdls);
	int (*ipa_del_hdr_proc_ctx)(struct ipa_ioc_del_hdr_proc_ctx *hdls);


	int (*ipa_add_rt_rule)(struct ipa_ioc_add_rt_rule *rules);
	int (*ipa_add_rt_rule)(struct ipa_ioc_add_rt_rule *rules);


	int (*ipa_add_rt_rule_usr)(struct ipa_ioc_add_rt_rule *rules,
							bool user_only);

	int (*ipa_del_rt_rule)(struct ipa_ioc_del_rt_rule *hdls);
	int (*ipa_del_rt_rule)(struct ipa_ioc_del_rt_rule *hdls);


	int (*ipa_commit_rt)(enum ipa_ip_type ip);
	int (*ipa_commit_rt)(enum ipa_ip_type ip);


	int (*ipa_reset_rt)(enum ipa_ip_type ip);
	int (*ipa_reset_rt)(enum ipa_ip_type ip, bool user_only);


	int (*ipa_get_rt_tbl)(struct ipa_ioc_get_rt_tbl *lookup);
	int (*ipa_get_rt_tbl)(struct ipa_ioc_get_rt_tbl *lookup);


@@ -107,13 +113,16 @@ struct ipa_api_controller {


	int (*ipa_add_flt_rule)(struct ipa_ioc_add_flt_rule *rules);
	int (*ipa_add_flt_rule)(struct ipa_ioc_add_flt_rule *rules);


	int (*ipa_add_flt_rule_usr)(struct ipa_ioc_add_flt_rule *rules,
								bool user_only);

	int (*ipa_del_flt_rule)(struct ipa_ioc_del_flt_rule *hdls);
	int (*ipa_del_flt_rule)(struct ipa_ioc_del_flt_rule *hdls);


	int (*ipa_mdfy_flt_rule)(struct ipa_ioc_mdfy_flt_rule *rules);
	int (*ipa_mdfy_flt_rule)(struct ipa_ioc_mdfy_flt_rule *rules);


	int (*ipa_commit_flt)(enum ipa_ip_type ip);
	int (*ipa_commit_flt)(enum ipa_ip_type ip);


	int (*ipa_reset_flt)(enum ipa_ip_type ip);
	int (*ipa_reset_flt)(enum ipa_ip_type ip, bool user_only);


	int (*ipa_allocate_nat_device)(struct ipa_ioc_nat_alloc_mem *mem);
	int (*ipa_allocate_nat_device)(struct ipa_ioc_nat_alloc_mem *mem);


+2 −0
Original line number Original line Diff line number Diff line
@@ -333,11 +333,13 @@ struct ipa_mhi_connect_params_internal {
 * @link: entry's link in global header offset entries list
 * @link: entry's link in global header offset entries list
 * @offset: the offset
 * @offset: the offset
 * @bin: bin
 * @bin: bin
 * @ipacm_installed: indicate if installed by ipacm
 */
 */
struct ipa_hdr_offset_entry {
struct ipa_hdr_offset_entry {
	struct list_head link;
	struct list_head link;
	u32 offset;
	u32 offset;
	u32 bin;
	u32 bin;
	bool ipacm_installed;
};
};


extern const char *ipa_clients_strings[];
extern const char *ipa_clients_strings[];
+53 −8
Original line number Original line Diff line number Diff line
@@ -278,6 +278,28 @@ int ipa2_active_clients_log_print_table(char *buf, int size)
	return cnt;
	return cnt;
}
}



static int ipa2_clean_modem_rule(void)
{
	struct ipa_install_fltr_rule_req_msg_v01 *req;
	int val = 0;

	req = kzalloc(
		sizeof(struct ipa_install_fltr_rule_req_msg_v01),
		GFP_KERNEL);
	if (!req) {
		IPAERR("mem allocated failed!\n");
		return -ENOMEM;
	}
	req->filter_spec_list_valid = false;
	req->filter_spec_list_len = 0;
	req->source_pipe_index_valid = 0;
	val = qmi_filter_request_send(req);
	kfree(req);

	return val;
}

static int ipa2_active_clients_panic_notifier(struct notifier_block *this,
static int ipa2_active_clients_panic_notifier(struct notifier_block *this,
		unsigned long event, void *ptr)
		unsigned long event, void *ptr)
{
{
@@ -532,7 +554,8 @@ static void ipa_wan_msg_free_cb(void *buff, u32 len, u32 type)
	kfree(buff);
	kfree(buff);
}
}


static int ipa_send_wan_msg(unsigned long usr_param, uint8_t msg_type, bool is_cache)
static int ipa_send_wan_msg(unsigned long usr_param, uint8_t msg_type,
	bool is_cache)
{
{
	int retval;
	int retval;
	struct ipa_wan_msg *wan_msg;
	struct ipa_wan_msg *wan_msg;
@@ -715,7 +738,8 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
		if (ipa2_add_hdr((struct ipa_ioc_add_hdr *)param)) {
		if (ipa2_add_hdr_usr((struct ipa_ioc_add_hdr *)param,
			true)) {
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
@@ -795,7 +819,8 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
		if (ipa2_add_rt_rule((struct ipa_ioc_add_rt_rule *)param)) {
		if (ipa2_add_rt_rule_usr((struct ipa_ioc_add_rt_rule *)param,
				true)) {
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
@@ -914,7 +939,8 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
		if (ipa2_add_flt_rule((struct ipa_ioc_add_flt_rule *)param)) {
		if (ipa2_add_flt_rule_usr((struct ipa_ioc_add_flt_rule *)param,
				true)) {
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
@@ -1008,19 +1034,19 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
		retval = ipa2_commit_hdr();
		retval = ipa2_commit_hdr();
		break;
		break;
	case IPA_IOC_RESET_HDR:
	case IPA_IOC_RESET_HDR:
		retval = ipa2_reset_hdr();
		retval = ipa2_reset_hdr(false);
		break;
		break;
	case IPA_IOC_COMMIT_RT:
	case IPA_IOC_COMMIT_RT:
		retval = ipa2_commit_rt(arg);
		retval = ipa2_commit_rt(arg);
		break;
		break;
	case IPA_IOC_RESET_RT:
	case IPA_IOC_RESET_RT:
		retval = ipa2_reset_rt(arg);
		retval = ipa2_reset_rt(arg, false);
		break;
		break;
	case IPA_IOC_COMMIT_FLT:
	case IPA_IOC_COMMIT_FLT:
		retval = ipa2_commit_flt(arg);
		retval = ipa2_commit_flt(arg);
		break;
		break;
	case IPA_IOC_RESET_FLT:
	case IPA_IOC_RESET_FLT:
		retval = ipa2_reset_flt(arg);
		retval = ipa2_reset_flt(arg, false);
		break;
		break;
	case IPA_IOC_GET_RT_TBL:
	case IPA_IOC_GET_RT_TBL:
		if (copy_from_user(header, (u8 *)arg,
		if (copy_from_user(header, (u8 *)arg,
@@ -1400,7 +1426,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			break;
			break;
		}
		}
		if (ipa2_add_hdr_proc_ctx(
		if (ipa2_add_hdr_proc_ctx(
			(struct ipa_ioc_add_hdr_proc_ctx *)param)) {
			(struct ipa_ioc_add_hdr_proc_ctx *)param, true)) {
			retval = -EFAULT;
			retval = -EFAULT;
			break;
			break;
		}
		}
@@ -1464,6 +1490,21 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
		}
		}
		break;
		break;


	case IPA_IOC_CLEANUP:
		/*Route and filter rules will also be clean*/
		IPADBG("Got IPA_IOC_CLEANUP\n");
		retval = ipa2_reset_hdr(true);
		memset(&nat_del, 0, sizeof(nat_del));
		nat_del.table_index = 0;
		retval = ipa2_nat_del_cmd(&nat_del);
		retval = ipa2_clean_modem_rule();
		break;

	case IPA_IOC_QUERY_WLAN_CLIENT:
		IPADBG("Got IPA_IOC_QUERY_WLAN_CLIENT\n");
		retval = ipa2_resend_wlan_msg();
		break;

	default:
	default:
		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
		return -ENOTTY;
		return -ENOTTY;
@@ -4206,6 +4247,10 @@ static int ipa_init(const struct ipa_plat_drv_res *resource_p,
	init_waitqueue_head(&ipa_ctx->msg_waitq);
	init_waitqueue_head(&ipa_ctx->msg_waitq);
	mutex_init(&ipa_ctx->msg_lock);
	mutex_init(&ipa_ctx->msg_lock);


	/* store wlan client-connect-msg-list */
	INIT_LIST_HEAD(&ipa_ctx->msg_wlan_client_list);
	mutex_init(&ipa_ctx->msg_wlan_client_lock);

	mutex_init(&ipa_ctx->lock);
	mutex_init(&ipa_ctx->lock);
	mutex_init(&ipa_ctx->nat_mem.lock);
	mutex_init(&ipa_ctx->nat_mem.lock);
	mutex_init(&ipa_ctx->ipa_cne_evt_lock);
	mutex_init(&ipa_ctx->ipa_cne_evt_lock);
+55 −28
Original line number Original line Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -1008,7 +1008,7 @@ int __ipa_commit_flt_v2(enum ipa_ip_type ip)


static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
			      const struct ipa_flt_rule *rule, u8 add_rear,
			      const struct ipa_flt_rule *rule, u8 add_rear,
			      u32 *rule_hdl)
			      u32 *rule_hdl, bool user)
{
{
	struct ipa_flt_entry *entry;
	struct ipa_flt_entry *entry;
	struct ipa_rt_tbl *rt_tbl = NULL;
	struct ipa_rt_tbl *rt_tbl = NULL;
@@ -1076,6 +1076,7 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
	}
	}
	*rule_hdl = id;
	*rule_hdl = id;
	entry->id = id;
	entry->id = id;
	entry->ipacm_installed = user;
	IPADBG_LOW("add flt rule rule_cnt=%d\n", tbl->rule_cnt);
	IPADBG_LOW("add flt rule rule_cnt=%d\n", tbl->rule_cnt);


	return 0;
	return 0;
@@ -1198,12 +1199,12 @@ static int __ipa_add_global_flt_rule(enum ipa_ip_type ip,
	tbl = &ipa_ctx->glob_flt_tbl[ip];
	tbl = &ipa_ctx->glob_flt_tbl[ip];
	IPADBG_LOW("add global flt rule ip=%d\n", ip);
	IPADBG_LOW("add global flt rule ip=%d\n", ip);


	return __ipa_add_flt_rule(tbl, ip, rule, add_rear, rule_hdl);
	return __ipa_add_flt_rule(tbl, ip, rule, add_rear, rule_hdl, false);
}
}


static int __ipa_add_ep_flt_rule(enum ipa_ip_type ip, enum ipa_client_type ep,
static int __ipa_add_ep_flt_rule(enum ipa_ip_type ip, enum ipa_client_type ep,
				 const struct ipa_flt_rule *rule, u8 add_rear,
				 const struct ipa_flt_rule *rule, u8 add_rear,
				 u32 *rule_hdl)
				 u32 *rule_hdl, bool user)
{
{
	struct ipa_flt_tbl *tbl;
	struct ipa_flt_tbl *tbl;
	int ipa_ep_idx;
	int ipa_ep_idx;
@@ -1225,18 +1226,34 @@ static int __ipa_add_ep_flt_rule(enum ipa_ip_type ip, enum ipa_client_type ep,
	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][ip];
	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][ip];
	IPADBG_LOW("add ep flt rule ip=%d ep=%d\n", ip, ep);
	IPADBG_LOW("add ep flt rule ip=%d ep=%d\n", ip, ep);


	return __ipa_add_flt_rule(tbl, ip, rule, add_rear, rule_hdl);
	return __ipa_add_flt_rule(tbl, ip, rule, add_rear, rule_hdl, user);
}
}


/**
/**
 * ipa2_add_flt_rule() - Add the specified filtering rules to SW and optionally
 * ipa2_add_flt_rule() - Add the specified filtering rules to SW and optionally
 * commit to IPA HW
 * commit to IPA HW
 * @rules:	[inout] set of filtering rules to add
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
{
	return ipa2_add_flt_rule_usr(rules, false);
}

/**
 * ipa2_add_flt_rule_usr() - Add the specified filtering rules
 * to SW and optionally commit to IPA HW
 * @rules:	[inout] set of filtering rules to add
 * @user_only:	[in] indicate rules installed by userspace
 *
 * Returns:	0 on success, negative on failure
 *
 * Note:	Should not be called from atomic context
 */
int ipa2_add_flt_rule_usr(struct ipa_ioc_add_flt_rule *rules, bool user_only)
{
{
	int i;
	int i;
	int result;
	int result;
@@ -1259,7 +1276,8 @@ int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
			result = __ipa_add_ep_flt_rule(rules->ip, rules->ep,
			result = __ipa_add_ep_flt_rule(rules->ip, rules->ep,
					&rules->rules[i].rule,
					&rules->rules[i].rule,
					rules->rules[i].at_rear,
					rules->rules[i].at_rear,
					&rules->rules[i].flt_rule_hdl);
					&rules->rules[i].flt_rule_hdl,
					user_only);
		if (result) {
		if (result) {
			IPAERR_RL("failed to add flt rule %d\n", i);
			IPAERR_RL("failed to add flt rule %d\n", i);
			rules->rules[i].status = IPA_FLT_STATUS_OF_ADD_FAILED;
			rules->rules[i].status = IPA_FLT_STATUS_OF_ADD_FAILED;
@@ -1397,12 +1415,13 @@ int ipa2_commit_flt(enum ipa_ip_type ip)
 * ipa2_reset_flt() - Reset the current SW filtering table of specified type
 * ipa2_reset_flt() - Reset the current SW filtering table of specified type
 * (does not commit to HW)
 * (does not commit to HW)
 * @ip:			[in] the family of routing tables
 * @ip:			[in] the family of routing tables
 * @user_only:	[in] indicate rules deleted by userspace
 *
 *
 * Returns:	0 on success, negative on failure
 * Returns:	0 on success, negative on failure
 *
 *
 * Note:	Should not be called from atomic context
 * Note:	Should not be called from atomic context
 */
 */
int ipa2_reset_flt(enum ipa_ip_type ip)
int ipa2_reset_flt(enum ipa_ip_type ip, bool user_only)
{
{
	struct ipa_flt_tbl *tbl;
	struct ipa_flt_tbl *tbl;
	struct ipa_flt_entry *entry;
	struct ipa_flt_entry *entry;
@@ -1435,6 +1454,8 @@ int ipa2_reset_flt(enum ipa_ip_type ip)
		      IPA_INVALID_L4_PROTOCOL))
		      IPA_INVALID_L4_PROTOCOL))
			continue;
			continue;


		if (!user_only ||
				entry->ipacm_installed) {
			list_del(&entry->link);
			list_del(&entry->link);
			entry->tbl->rule_cnt--;
			entry->tbl->rule_cnt--;
			if (entry->rt_tbl)
			if (entry->rt_tbl)
@@ -1446,6 +1467,7 @@ int ipa2_reset_flt(enum ipa_ip_type ip)
			/* remove the handle from the database */
			/* remove the handle from the database */
			ipa_id_remove(id);
			ipa_id_remove(id);
		}
		}
	}


	for (i = 0; i < ipa_ctx->ipa_num_pipes; i++) {
	for (i = 0; i < ipa_ctx->ipa_num_pipes; i++) {
		tbl = &ipa_ctx->flt_tbl[i][ip];
		tbl = &ipa_ctx->flt_tbl[i][ip];
@@ -1456,18 +1478,23 @@ int ipa2_reset_flt(enum ipa_ip_type ip)
				mutex_unlock(&ipa_ctx->lock);
				mutex_unlock(&ipa_ctx->lock);
				return -EFAULT;
				return -EFAULT;
			}
			}

			if (!user_only ||
				entry->ipacm_installed) {
				list_del(&entry->link);
				list_del(&entry->link);
				entry->tbl->rule_cnt--;
				entry->tbl->rule_cnt--;
				if (entry->rt_tbl)
				if (entry->rt_tbl)
					entry->rt_tbl->ref_cnt--;
					entry->rt_tbl->ref_cnt--;
				entry->cookie = 0;
				entry->cookie = 0;
				id = entry->id;
				id = entry->id;
			kmem_cache_free(ipa_ctx->flt_rule_cache, entry);
				kmem_cache_free(ipa_ctx->flt_rule_cache,
					entry);


				/* remove the handle from the database */
				/* remove the handle from the database */
				ipa_id_remove(id);
				ipa_id_remove(id);
			}
			}
		}
		}
	}
	mutex_unlock(&ipa_ctx->lock);
	mutex_unlock(&ipa_ctx->lock);


	return 0;
	return 0;
@@ -1485,14 +1512,14 @@ void ipa_install_dflt_flt_rules(u32 ipa_ep_idx)
	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][IPA_IP_v4];
	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][IPA_IP_v4];
	rule.action = IPA_PASS_TO_EXCEPTION;
	rule.action = IPA_PASS_TO_EXCEPTION;
	__ipa_add_flt_rule(tbl, IPA_IP_v4, &rule, true,
	__ipa_add_flt_rule(tbl, IPA_IP_v4, &rule, true,
			&ep->dflt_flt4_rule_hdl);
			&ep->dflt_flt4_rule_hdl, false);
	ipa_ctx->ctrl->ipa_commit_flt(IPA_IP_v4);
	ipa_ctx->ctrl->ipa_commit_flt(IPA_IP_v4);
	tbl->sticky_rear = true;
	tbl->sticky_rear = true;


	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][IPA_IP_v6];
	tbl = &ipa_ctx->flt_tbl[ipa_ep_idx][IPA_IP_v6];
	rule.action = IPA_PASS_TO_EXCEPTION;
	rule.action = IPA_PASS_TO_EXCEPTION;
	__ipa_add_flt_rule(tbl, IPA_IP_v6, &rule, true,
	__ipa_add_flt_rule(tbl, IPA_IP_v6, &rule, true,
			&ep->dflt_flt6_rule_hdl);
			&ep->dflt_flt6_rule_hdl, false);
	ipa_ctx->ctrl->ipa_commit_flt(IPA_IP_v6);
	ipa_ctx->ctrl->ipa_commit_flt(IPA_IP_v6);
	tbl->sticky_rear = true;
	tbl->sticky_rear = true;
	mutex_unlock(&ipa_ctx->lock);
	mutex_unlock(&ipa_ctx->lock);
Loading