Prechádzať zdrojové kódy

msm:ipa: add debugfs nat table move capability

Enable moving the NAT table to DDR\SRAM and vice versa
by debugfs.

Change-Id: I4818e790db7703d9c71ed8b0eb98564a918e86db
Signed-off-by: Amir Levy <[email protected]>
Amir Levy 3 rokov pred
rodič
commit
8ff9623252

+ 69 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c

@@ -2958,6 +2958,71 @@ static ssize_t ipa3_write_page_poll_threshold(struct file *file,
 	return count;
 }
 
+static void ipa3_nat_move_free_cb(void *buff, u32 len, u32 type)
+{
+	kfree(buff);
+}
+
+static ssize_t ipa3_write_nat_table_move(struct file *file,
+	const char __user *buf, size_t count, loff_t *ppos)
+{
+	u32 direction;
+	unsigned long missing;
+	char *sptr, *token;
+	struct ipa_move_nat_req_msg_v01 *req_data;
+	struct ipa_msg_meta msg_meta;
+
+	if (count >= sizeof(dbg_buff))
+		return -EFAULT;
+
+	missing = copy_from_user(dbg_buff, buf, count);
+	if (missing)
+		return -EFAULT;
+
+	dbg_buff[count] = '\0';
+
+	sptr = dbg_buff;
+
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou32(token, 0, &direction))
+		return -EINVAL;
+
+	if (direction) {
+		pr_err("moving to DDR\n");
+		direction = QMI_IPA_MOVE_NAT_TO_DDR_V01;
+	} else {
+		pr_err("moving to SRAM\n");
+		direction = QMI_IPA_MOVE_NAT_TO_SRAM_V01;
+	}
+
+	req_data = kzalloc(sizeof(struct ipa_move_nat_req_msg_v01),
+		GFP_KERNEL);
+	if (!req_data) {
+		pr_err("allocation failed\n");
+		return EFAULT;
+	}
+
+	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
+	msg_meta.msg_type = IPA_MOVE_NAT_TABLE;
+	msg_meta.msg_len = sizeof(struct ipa_move_nat_req_msg_v01);
+
+	req_data->nat_move_direction = direction;
+
+	ipa3_disable_move_nat_resp();
+	pr_err("disabled QMI\n");
+	/* make sure QMI is disabled before message sent to IPACM */
+	wmb();
+	if (ipa_send_msg(&msg_meta, req_data, ipa3_nat_move_free_cb)) {
+		pr_err("ipa_send_msg failed\nn");
+	}
+	pr_err("message sent\n");
+
+	return count;
+}
+
+
 static const struct ipa3_debugfs_file debugfs_files[] = {
 	{
 		"gen_reg", IPA_READ_ONLY_MODE, NULL, {
@@ -3140,6 +3205,10 @@ static const struct ipa3_debugfs_file debugfs_files[] = {
 			.read = ipa3_read_page_poll_threshold,
 			.write = ipa3_write_page_poll_threshold,
 		}
+	}, {
+		"move_nat_table_to_ddr", IPA_WRITE_ONLY_MODE, NULL,{
+			.write = ipa3_write_nat_table_move,
+		}
 	},
 };
 

+ 21 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c

@@ -42,6 +42,7 @@ static bool workqueues_stopped;
 static bool ipa3_modem_init_cmplt;
 static bool first_time_handshake;
 static bool send_qmi_init_q6;
+static bool nat_move_qmi_disabled;
 struct mutex ipa3_qmi_lock;
 struct ipa_msg_desc {
 	uint16_t msg_id;
@@ -422,6 +423,11 @@ static void ipa3_qmi_msg_free_cb(void *buff, u32 len, u32 type)
 	kfree(buff);
 }
 
+void ipa3_disable_move_nat_resp(void)
+{
+	nat_move_qmi_disabled = true;
+}
+
 static void ipa3_handle_move_nat_req(struct qmi_handle *qmi_handle,
 	struct sockaddr_qrtr *sq,
 	struct qmi_txn *txn,
@@ -455,6 +461,14 @@ static void ipa3_handle_move_nat_req(struct qmi_handle *qmi_handle,
 
 	req_data->nat_move_direction = move_req->nat_move_direction;
 
+	nat_move_qmi_disabled = false;
+	/*
+	 * make sure QMI is enabled before message sent to IPACM.
+	 * real QMI coming from modem takes us out of debug mode and re enables
+	 * the QMI indication send
+	 */
+	wmb();
+
 	rc = ipa_send_msg(&msg_meta, req_data, ipa3_qmi_msg_free_cb);
 	if (rc) {
 		IPAWANERR("ipa_send_msg failed: %d, notify Q6\n", rc);
@@ -1521,6 +1535,13 @@ int rmnet_ipa3_notify_nat_move_res(bool failure)
 
 	IPAWANDBG("send nat table move indication to modem (%d)\n",
 		failure);
+
+	if (nat_move_qmi_disabled) {
+		IPAWANDBG(
+			"not sending nat table move indication, nat_move_qmi_disabled is true"
+		);
+		return 0;
+	}
 	memset(&ind, 0, sizeof(struct
 		ipa_move_nat_table_complt_ind_msg_v01));
 	if (!failure)

+ 7 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h

@@ -375,6 +375,8 @@ int ipa3_wwan_init(void);
 
 void ipa3_wwan_cleanup(void);
 
+void ipa3_disable_move_nat_resp(void);
+
 #else /* IS_ENABLED(CONFIG_RMNET_IPA3) */
 
 static inline int ipa3_qmi_service_init(uint32_t wan_platform_type)
@@ -567,6 +569,11 @@ static inline void ipa3_qmi_cleanup(void)
 
 }
 
+static void ipa3_disable_move_nat_resp(void)
+{
+
+}
+
 static inline int ipa3_wwan_platform_driver_register(void)
 {
 	return -EPERM;