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

Commit 91c5b834 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: Add support for UL Firewall"

parents 1f3310b9 97feddb0
Loading
Loading
Loading
Loading
+88 −0
Original line number Diff line number Diff line
@@ -690,6 +690,63 @@ int ipa3_qmi_filter_request_ex_send(
		resp.resp.error, "ipa_install_filter");
}

/* sending ul-filter-install-request to modem*/
int ipa3_qmi_ul_filter_request_send(
	struct ipa_configure_ul_firewall_rules_req_msg_v01 *req)
{
	struct ipa_configure_ul_firewall_rules_resp_msg_v01 resp;
	struct msg_desc req_desc, resp_desc;
	int rc;

	/* check if the filter rules from IPACM is valid */
	if (req->firewall_rules_list_len < 0) {
		IPAWANERR("Ul filter rules are not valid\n");
		return -EINVAL;
	}

	IPAWANDBG("IPACM pass %u rules to Q6\n",
		req->firewall_rules_list_len);

	mutex_lock(&ipa3_qmi_lock);
	if (ipa3_qmi_ctx != NULL) {
		/* cache the qmi_filter_request */
		memcpy(
		&(ipa3_qmi_ctx->ipa_configure_ul_firewall_rules_req_msg_cache[
		ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg]),
		req,
		sizeof(struct
		ipa_configure_ul_firewall_rules_req_msg_v01));
		ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg++;
		ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg %=
			MAX_NUM_QMI_RULE_CACHE;
	}
	mutex_unlock(&ipa3_qmi_lock);

	req_desc.max_msg_len =
		QMI_IPA_INSTALL_UL_FIREWALL_RULES_REQ_MAX_MSG_LEN_V01;
	req_desc.msg_id = QMI_IPA_INSTALL_UL_FIREWALL_RULES_REQ_V01;
	req_desc.ei_array =
		ipa3_configure_ul_firewall_rules_req_msg_data_v01_ei;

	memset(&resp, 0,
		sizeof(struct ipa_configure_ul_firewall_rules_resp_msg_v01));
	resp_desc.max_msg_len =
		QMI_IPA_INSTALL_UL_FIREWALL_RULES_RESP_MAX_MSG_LEN_V01;
	resp_desc.msg_id = QMI_IPA_INSTALL_UL_FIREWALL_RULES_RESP_V01;
	resp_desc.ei_array =
		ipa3_configure_ul_firewall_rules_resp_msg_data_v01_ei;

	rc = qmi_send_req_wait(ipa_q6_clnt, &req_desc,
		req,
		sizeof(
		struct ipa_configure_ul_firewall_rules_req_msg_v01),
		&resp_desc, &resp, sizeof(resp),
		QMI_SEND_REQ_TIMEOUT_MS);
	return ipa3_check_qmi_response(rc,
		QMI_IPA_INSTALL_UL_FIREWALL_RULES_REQ_V01, resp.resp.result,
		resp.resp.error, "ipa_received_ul_firewall_filter");
}

int ipa3_qmi_enable_force_clear_datapath_send(
	struct ipa_enable_force_clear_datapath_req_msg_v01 *req)
{
@@ -864,6 +921,7 @@ static void ipa3_q6_clnt_ind_cb(struct qmi_handle *handle, unsigned int msg_id,
			       void *ind_cb_priv)
{
	struct ipa_data_usage_quota_reached_ind_msg_v01 qmi_ind;
	struct ipa_configure_ul_firewall_rules_ind_msg_v01 qmi_ul_firewall_ind;
	struct msg_desc qmi_ind_desc;
	int rc = 0;

@@ -891,6 +949,36 @@ static void ipa3_q6_clnt_ind_cb(struct qmi_handle *handle, unsigned int msg_id,
			  (unsigned long int) qmi_ind.apn.num_Mbytes);
		ipa3_broadcast_quota_reach_ind(qmi_ind.apn.mux_id);
	}

	if (QMI_IPA_INSTALL_UL_FIREWALL_RULES_IND_V01 == msg_id) {
		memset(&qmi_ul_firewall_ind, 0, sizeof(
			struct ipa_configure_ul_firewall_rules_ind_msg_v01));
		qmi_ind_desc.max_msg_len =
			QMI_IPA_INSTALL_UL_FIREWALL_RULES_IND_MAX_MSG_LEN_V01;
		qmi_ind_desc.msg_id = QMI_IPA_INSTALL_UL_FIREWALL_RULES_IND_V01;
		qmi_ind_desc.ei_array =
			ipa3_configure_ul_firewall_rules_ind_msg_data_v01_ei;

		rc = qmi_kernel_decode(
			&qmi_ind_desc, &qmi_ul_firewall_ind, msg, msg_len);
		if (rc < 0) {
			IPAWANERR("Error decoding msg_id %d\n", msg_id);
			return;
		}

		IPAWANDBG("UL firewall rules install indication on Q6");
		if (qmi_ul_firewall_ind.result.is_success ==
				QMI_IPA_UL_FIREWALL_STATUS_SUCCESS_V01) {
			IPAWANDBG(" : Success\n");
			IPAWANDBG
			("Mux ID : %d\n", qmi_ul_firewall_ind.result.mux_id);
		} else if (qmi_ul_firewall_ind.result.is_success ==
				QMI_IPA_UL_FIREWALL_STATUS_FAILURE_V01){
			IPAWANERR(": Failure\n");
		} else {
			IPAWANERR(": Unexpected Result");
		}
	}
}

static void ipa3_q6_clnt_svc_arrive(struct work_struct *work)
+17 −0
Original line number Diff line number Diff line
@@ -79,6 +79,9 @@ struct ipa_install_fltr_rule_req_ex_msg_v01
int num_ipa_fltr_installed_notif_req_msg;
struct ipa_fltr_installed_notif_req_msg_v01
		ipa_fltr_installed_notif_req_msg_cache[MAX_NUM_QMI_RULE_CACHE];
int num_ipa_configure_ul_firewall_rules_req_msg;
struct ipa_configure_ul_firewall_rules_req_msg_v01
ipa_configure_ul_firewall_rules_req_msg_cache[MAX_NUM_QMI_RULE_CACHE];
bool modem_cfg_emb_pipe_flt;
};

@@ -120,6 +123,11 @@ extern struct elem_info ipa3_init_modem_driver_cmplt_req_msg_data_v01_ei[];
extern struct elem_info ipa3_init_modem_driver_cmplt_resp_msg_data_v01_ei[];
extern struct elem_info ipa3_install_fltr_rule_req_ex_msg_data_v01_ei[];
extern struct elem_info ipa3_install_fltr_rule_resp_ex_msg_data_v01_ei[];
extern struct elem_info ipa3_ul_firewall_rule_type_data_v01_ei[];
extern struct elem_info ipa3_ul_firewall_config_result_type_data_v01_ei[];
extern struct elem_info ipa3_configure_ul_firewall_rules_req_msg_data_v01_ei[];
extern struct elem_info ipa3_configure_ul_firewall_rules_resp_msg_data_v01_ei[];
extern struct elem_info ipa3_configure_ul_firewall_rules_ind_msg_data_v01_ei[];

/**
 * struct ipa3_rmnet_context - IPA rmnet context
@@ -148,6 +156,9 @@ int ipa3_qmi_filter_request_send(
int ipa3_qmi_filter_request_ex_send(
	struct ipa_install_fltr_rule_req_ex_msg_v01 *req);

int ipa3_qmi_ul_filter_request_send(
	struct ipa_configure_ul_firewall_rules_req_msg_v01 *req);

/* sending filter-installed-notify-request to modem*/
int ipa3_qmi_filter_notify_send(struct ipa_fltr_installed_notif_req_msg_v01
		*req);
@@ -221,6 +232,12 @@ static inline int ipa3_qmi_filter_request_send(
	return -EPERM;
}

static inline int ipa3_qmi_ul_filter_request_send(
	struct ipa_configure_ul_firewall_rules_req_msg_v01 *req)
{
	return -EPERM;
}

static inline int ipa3_qmi_filter_request_ex_send(
	struct ipa_install_fltr_rule_req_ex_msg_v01 *req)
{
+28 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -122,6 +122,33 @@ static long ipa3_wan_ioctl(struct file *filp,
		}
		break;

		case WAN_IOC_ADD_UL_FLT_RULE:
		IPAWANDBG("device %s got WAN_IOC_UL_ADD_FLT_RULE :>>>\n",
		DRIVER_NAME);
		pyld_sz =
		sizeof(struct ipa_configure_ul_firewall_rules_req_msg_v01);
		param = kzalloc(pyld_sz, GFP_KERNEL);
		if (!param) {
			retval = -ENOMEM;
			break;
		}
		if (copy_from_user(param, (u8 *)arg, pyld_sz)) {
			retval = -EFAULT;
			break;
		}
		if (ipa3_qmi_ul_filter_request_send(
			(struct ipa_configure_ul_firewall_rules_req_msg_v01 *)
			param)) {
			IPAWANDBG("IPACM->Q6 add ul filter rule failed\n");
			retval = -EFAULT;
			break;
		}
		if (copy_to_user((u8 *)arg, param, pyld_sz)) {
			retval = -EFAULT;
			break;
		}
		break;

	case WAN_IOC_ADD_FLT_RULE_INDEX:
		IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_INDEX :>>>\n",
		DRIVER_NAME);
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -32,6 +32,7 @@
#define WAN_IOCTL_RESET_TETHER_STATS     7
#define WAN_IOCTL_QUERY_DL_FILTER_STATS  8
#define WAN_IOCTL_ADD_FLT_RULE_EX        9
#define WAN_IOCTL_ADD_UL_FLT_RULE          13

/* User space may not have this defined. */
#ifndef IFNAMSIZ
@@ -155,4 +156,7 @@ struct wan_ioctl_query_dl_filter_stats {
		WAN_IOCTL_ADD_FLT_RULE_EX, \
		struct ipa_install_fltr_rule_req_ex_msg_v01 *)

#define WAN_IOC_ADD_UL_FLT_RULE _IOWR(WAN_IOC_MAGIC, \
		WAN_IOCTL_ADD_UL_FLT_RULE, \
		struct ipa_configure_ul_firewall_rules_req_msg_v01 *)
#endif /* _RMNET_IPA_FD_IOCTL_H */