Browse Source

msm: ipa: optimising the memory for qmi_context

removing the unused memory for qmi_context

Change-Id: Id32f0a657ce459920972fb465d9d2ed0a24a2368
Signed-off-by: Veerendra Kumar Kamsali <[email protected]>
Veerendra Kumar Kamsali 2 years ago
parent
commit
213523bb85

+ 11 - 28
drivers/platform/msm/ipa/ipa_v3/ipa.c

@@ -791,38 +791,21 @@ int ipa3_active_clients_log_print_table(char *buf, int size)
 
 static int ipa3_clean_modem_rule(void)
 {
-	struct ipa_install_fltr_rule_req_msg_v01 *req;
 	struct ipa_install_fltr_rule_req_ex_msg_v01 *req_ex;
 	int val = 0;
 
-	if (ipa3_ctx->ipa_hw_type < IPA_HW_v3_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 = ipa3_qmi_filter_request_send(req);
-		kfree(req);
-	} else {
-		req_ex = kzalloc(
-			sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01),
-			GFP_KERNEL);
-		if (!req_ex) {
-			IPAERR("mem allocated failed!\n");
-			return -ENOMEM;
-		}
-		req_ex->filter_spec_ex_list_valid = false;
-		req_ex->filter_spec_ex_list_len = 0;
-		req_ex->source_pipe_index_valid = 0;
-		val = ipa3_qmi_filter_request_ex_send(req_ex);
-		kfree(req_ex);
+	req_ex = kzalloc(
+		sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01),
+		GFP_KERNEL);
+	if (!req_ex) {
+		IPAERR("mem allocated failed!\n");
+		return -ENOMEM;
 	}
-
+	req_ex->filter_spec_ex_list_valid = false;
+	req_ex->filter_spec_ex_list_len = 0;
+	req_ex->source_pipe_index_valid = 0;
+	val = ipa3_qmi_filter_request_ex_send(req_ex);
+	kfree(req_ex);
 	return val;
 }
 

+ 20 - 99
drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c

@@ -794,103 +794,6 @@ static int ipa3_qmi_init_modem_send_sync_msg(void)
 		resp.resp.error, "ipa_init_modem_driver_resp_msg_v01");
 }
 
-/* sending filter-install-request to modem*/
-int ipa3_qmi_filter_request_send(struct ipa_install_fltr_rule_req_msg_v01 *req)
-{
-	struct ipa_install_fltr_rule_resp_msg_v01 resp;
-	struct ipa_msg_desc req_desc, resp_desc;
-	int rc;
-	int i;
-
-	/* check if modem up */
-	if (!ipa3_qmi_indication_fin ||
-		!ipa3_qmi_modem_init_fin ||
-		!ipa_q6_clnt) {
-		IPAWANDBG("modem QMI haven't up yet\n");
-		return -EINVAL;
-	}
-
-	/* check if the filter rules from IPACM is valid */
-	if (req->filter_spec_list_len == 0) {
-		IPAWANDBG("IPACM pass zero rules to Q6\n");
-	} else {
-		IPAWANDBG("IPACM pass %u rules to Q6\n",
-		req->filter_spec_list_len);
-	}
-
-	if (req->filter_spec_list_len >= QMI_IPA_MAX_FILTERS_V01) {
-		IPAWANDBG(
-		"IPACM passes the number of filtering rules exceed limit\n");
-		return -EINVAL;
-	} else if (req->source_pipe_index_valid != 0) {
-		IPAWANDBG(
-		"IPACM passes source_pipe_index_valid not zero 0 != %d\n",
-			req->source_pipe_index_valid);
-		return -EINVAL;
-	} else if (req->source_pipe_index >= ipa3_ctx_get_num_pipes()) {
-		IPAWANDBG(
-		"IPACM passes source pipe index not valid ID = %d\n",
-		req->source_pipe_index);
-		return -EINVAL;
-	}
-	for (i = 0; i < req->filter_spec_list_len; i++) {
-		if ((req->filter_spec_list[i].ip_type !=
-			QMI_IPA_IP_TYPE_V4_V01) &&
-			(req->filter_spec_list[i].ip_type !=
-			QMI_IPA_IP_TYPE_V6_V01))
-			return -EINVAL;
-		if (req->filter_spec_list[i].is_mux_id_valid == false)
-			return -EINVAL;
-		if (req->filter_spec_list[i].is_routing_table_index_valid
-			== false)
-			return -EINVAL;
-		if ((req->filter_spec_list[i].filter_action <=
-			QMI_IPA_FILTER_ACTION_INVALID_V01) ||
-			(req->filter_spec_list[i].filter_action >
-			QMI_IPA_FILTER_ACTION_EXCEPTION_V01))
-			return -EINVAL;
-	}
-
-	mutex_lock(&ipa3_qmi_lock);
-	if (ipa3_qmi_ctx != NULL) {
-		/* cache the qmi_filter_request */
-		memcpy(&(ipa3_qmi_ctx->ipa_install_fltr_rule_req_msg_cache[
-			ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_msg]),
-			req,
-			sizeof(struct ipa_install_fltr_rule_req_msg_v01));
-		ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_msg++;
-		ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_msg %= 10;
-	}
-	mutex_unlock(&ipa3_qmi_lock);
-
-	req_desc.max_msg_len = QMI_IPA_INSTALL_FILTER_RULE_REQ_MAX_MSG_LEN_V01;
-	req_desc.msg_id = QMI_IPA_INSTALL_FILTER_RULE_REQ_V01;
-	req_desc.ei_array = ipa3_install_fltr_rule_req_msg_data_v01_ei;
-
-	memset(&resp, 0, sizeof(struct ipa_install_fltr_rule_resp_msg_v01));
-	resp_desc.max_msg_len =
-		QMI_IPA_INSTALL_FILTER_RULE_RESP_MAX_MSG_LEN_V01;
-	resp_desc.msg_id = QMI_IPA_INSTALL_FILTER_RULE_RESP_V01;
-	resp_desc.ei_array = ipa3_install_fltr_rule_resp_msg_data_v01_ei;
-
-	if (unlikely(!ipa_q6_clnt))
-		return -ETIMEDOUT;
-	rc = ipa3_qmi_send_req_wait(ipa_q6_clnt,
-		&req_desc, req,
-		&resp_desc, &resp,
-		QMI_SEND_REQ_TIMEOUT_MS);
-
-	if (rc < 0) {
-		IPAWANERR("QMI send Req %d failed, rc= %d\n",
-			QMI_IPA_INSTALL_FILTER_RULE_REQ_V01,
-			rc);
-		return rc;
-	}
-
-	return ipa3_check_qmi_response(rc,
-		QMI_IPA_INSTALL_FILTER_RULE_REQ_V01, resp.resp.result,
-		resp.resp.error, "ipa_install_filter");
-}
 
 static int ipa3_qmi_filter_request_ex_calc_length(
 	struct ipa_install_fltr_rule_req_ex_msg_v01 *req)
@@ -938,6 +841,7 @@ int ipa3_qmi_filter_request_ex_send(
 	struct ipa_msg_desc req_desc, resp_desc;
 	int rc;
 	int i;
+	static bool cache_filter_max_flag = false;
 
 	/* check if modem up */
 	if (!ipa3_qmi_indication_fin ||
@@ -1002,11 +906,19 @@ int ipa3_qmi_filter_request_ex_send(
 	mutex_lock(&ipa3_qmi_lock);
 	if (ipa3_qmi_ctx != NULL) {
 		/* cache the qmi_filter_request */
-		memcpy(&(ipa3_qmi_ctx->ipa_install_fltr_rule_req_ex_msg_cache[
+		if( cache_filter_max_flag != true ) {
+			ipa3_qmi_ctx->ipa_install_fltr_rule_req_ex_msg_cache_ptr
+				[ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_ex_msg]
+				= vmalloc(
+				  sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01));
+		}
+		memcpy((ipa3_qmi_ctx->ipa_install_fltr_rule_req_ex_msg_cache_ptr[
 			ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_ex_msg]),
 			req,
 			sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01));
 		ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_ex_msg++;
+		if ( ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_ex_msg == MAX_NUM_QMI_RULE_CACHE )
+		       cache_filter_max_flag = true;
 		ipa3_qmi_ctx->num_ipa_install_fltr_rule_req_ex_msg %= 10;
 	}
 	mutex_unlock(&ipa3_qmi_lock);
@@ -1305,6 +1217,7 @@ int ipa3_qmi_ul_filter_request_send(
 	struct ipa_configure_ul_firewall_rules_resp_msg_v01 resp;
 	struct ipa_msg_desc req_desc, resp_desc;
 	int rc, i;
+	static bool cache_max_flag = false;
 
 	IPAWANDBG("IPACM pass %u rules to Q6\n",
 		req->firewall_rules_list_len);
@@ -1312,13 +1225,21 @@ int ipa3_qmi_ul_filter_request_send(
 	mutex_lock(&ipa3_qmi_lock);
 	if (ipa3_qmi_ctx != NULL) {
 		/* cache the qmi_filter_request */
+		if( cache_max_flag != true ) {
+			ipa3_qmi_ctx->ipa_configure_ul_firewall_rules_req_msg_cache_ptr
+			[ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg]
+				= vmalloc(
+				sizeof(struct ipa_configure_ul_firewall_rules_req_msg_v01));
+		}
 		memcpy(
-		&(ipa3_qmi_ctx->ipa_configure_ul_firewall_rules_req_msg_cache[
+		(ipa3_qmi_ctx->ipa_configure_ul_firewall_rules_req_msg_cache_ptr[
 		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++;
+		if( ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg == MAX_NUM_QMI_RULE_CACHE )
+			cache_max_flag = true;
 		ipa3_qmi_ctx->num_ipa_configure_ul_firewall_rules_req_msg %=
 			MAX_NUM_QMI_RULE_CACHE;
 	}

+ 4 - 6
drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h

@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef IPA_QMI_SERVICE_H
@@ -91,19 +93,15 @@ struct ipa_offload_connection_val {
 struct ipa3_qmi_context {
 	struct ipa_ioc_ext_intf_prop q6_ul_filter_rule[MAX_NUM_Q6_RULE];
 	u32 q6_ul_filter_rule_hdl[MAX_NUM_Q6_RULE];
-	int num_ipa_install_fltr_rule_req_msg;
-	struct ipa_install_fltr_rule_req_msg_v01
-		ipa_install_fltr_rule_req_msg_cache[MAX_NUM_QMI_RULE_CACHE];
 	int num_ipa_install_fltr_rule_req_ex_msg;
 	struct ipa_install_fltr_rule_req_ex_msg_v01
-		ipa_install_fltr_rule_req_ex_msg_cache[MAX_NUM_QMI_RULE_CACHE];
+		*ipa_install_fltr_rule_req_ex_msg_cache_ptr[MAX_NUM_QMI_RULE_CACHE];
 	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];
+		*ipa_configure_ul_firewall_rules_req_msg_cache_ptr[MAX_NUM_QMI_RULE_CACHE];
 	struct ipa_mhi_prime_aggr_info_req_msg_v01
 		ipa_mhi_prime_aggr_info_req_msg_cache
 			[MAX_NUM_QMI_MPM_AGGR_CACHE];

+ 2 - 22
drivers/platform/msm/ipa/ipa_v3/rmnet_ipa_fd_ioctl.c

@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/init.h>
@@ -93,28 +95,6 @@ static long ipa3_wan_ioctl(struct file *filp,
 	}
 
 	switch (cmd) {
-	case WAN_IOC_ADD_FLT_RULE:
-		IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE :>>>\n",
-			DRIVER_NAME);
-		pyld_sz = sizeof(struct ipa_install_fltr_rule_req_msg_v01);
-		param = vmemdup_user((const void __user *)arg, pyld_sz);
-
-		if (IS_ERR(param)) {
-			retval = PTR_ERR(param);
-			break;
-		}
-		if (ipa3_qmi_filter_request_send(
-			(struct ipa_install_fltr_rule_req_msg_v01 *)param)) {
-			IPAWANDBG("IPACM->Q6 add 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_EX:
 		IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_EX :>>>\n",
 			DRIVER_NAME);