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

Commit 7ce5b5ba authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Update remote address for each CNTL packet"

parents f79144bf 2bfc79c1
Loading
Loading
Loading
Loading
+57 −32
Original line number Diff line number Diff line
@@ -243,7 +243,6 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
		return NOTIFY_DONE;
	}

	mutex_lock(&driver->diag_notifier_mutex);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"%s: ssr for processor %d ('%s')\n",
		__func__, notifier->processor, notifier->name);
@@ -253,7 +252,12 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
	case SUBSYS_BEFORE_SHUTDOWN:
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: %s: SUBSYS_BEFORE_SHUTDOWN\n", __func__);
		bootup_req[notifier->processor] = PEPIPHERAL_SSR_DOWN;
		mutex_lock(&driver->diag_notifier_mutex);
		bootup_req[notifier->processor] = PERIPHERAL_SSR_DOWN;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: bootup_req[%s] = %d\n",
		notifier->name, (int)bootup_req[notifier->processor]);
		mutex_unlock(&driver->diag_notifier_mutex);
		break;

	case SUBSYS_AFTER_SHUTDOWN:
@@ -269,11 +273,20 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
	case SUBSYS_AFTER_POWERUP:
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: %s: SUBSYS_AFTER_POWERUP\n", __func__);
		mutex_lock(&driver->diag_notifier_mutex);
		if (!bootup_req[notifier->processor]) {
			bootup_req[notifier->processor] = PEPIPHERAL_SSR_DOWN;
			bootup_req[notifier->processor] = PERIPHERAL_SSR_DOWN;
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: bootup_req[%s] = %d\n",
			notifier->name, (int)bootup_req[notifier->processor]);
			mutex_unlock(&driver->diag_notifier_mutex);
			break;
		}
		bootup_req[notifier->processor] = PEPIPHERAL_SSR_UP;
		bootup_req[notifier->processor] = PERIPHERAL_SSR_UP;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: bootup_req[%s] = %d\n",
		notifier->name, (int)bootup_req[notifier->processor]);
		mutex_unlock(&driver->diag_notifier_mutex);
		break;

	default:
@@ -281,11 +294,6 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
			"diag: code: %lu\n", code);
		break;
	}
	mutex_unlock(&driver->diag_notifier_mutex);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: bootup_req[%s] = %d\n",
		notifier->name, (int)bootup_req[notifier->processor]);

	return NOTIFY_DONE;
}

@@ -497,13 +505,6 @@ static void __socket_close_channel(struct diag_socket_info *info)
	if (!info || !info->hdl)
		return;

	if (bootup_req[info->peripheral] == PEPIPHERAL_SSR_UP) {
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: %s is up, stopping cleanup: bootup_req = %d\n",
			info->name, (int)bootup_req[info->peripheral]);
		return;
	}

	memset(&info->remote_addr, 0, sizeof(info->remote_addr));
	diagfwd_channel_close(info->fwd_ctxt);

@@ -621,8 +622,15 @@ static void handle_ctrl_pkt(struct diag_socket_info *info, void *buf, int len)
				 info->name);

			mutex_lock(&driver->diag_notifier_mutex);
			socket_close_channel(info);
			if (bootup_req[info->peripheral] == PERIPHERAL_SSR_UP) {
				DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				"diag: %s is up, stopping cleanup: bootup_req = %d\n",
				info->name, (int)bootup_req[info->peripheral]);
				mutex_unlock(&driver->diag_notifier_mutex);
				break;
			}
			mutex_unlock(&driver->diag_notifier_mutex);
			socket_close_channel(info);
		}
		break;
	case QRTR_TYPE_DEL_CLIENT:
@@ -635,8 +643,15 @@ static void handle_ctrl_pkt(struct diag_socket_info *info, void *buf, int len)
				 info->name);

			mutex_lock(&driver->diag_notifier_mutex);
			socket_close_channel(info);
			if (bootup_req[info->peripheral] == PERIPHERAL_SSR_UP) {
				DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				"diag: %s is up, stopping cleanup: bootup_req = %d\n",
				info->name, (int)bootup_req[info->peripheral]);
				mutex_unlock(&driver->diag_notifier_mutex);
				break;
			}
			mutex_unlock(&driver->diag_notifier_mutex);
			socket_close_channel(info);
		}
		break;
	}
@@ -741,17 +756,26 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
			qrtr_ctrl_recd += read_len;
			continue;
		}
		if (info->type == TYPE_CNTL) {
			memcpy(&info->remote_addr, &src_addr, sizeof(src_addr));
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				"%s client node:port::[0x%x]:[0x%x]\n",
				info->name, src_addr.sq_node, src_addr.sq_port);

			if (!atomic_read(&info->opened))
				__socket_open_channel(info);
		} else {
			if (!atomic_read(&info->opened) &&
			    info->port_type == PORT_TYPE_SERVER) {
				/*
			 * This is the first packet from the client. Copy its
			 * address to the connection object. Consider this
			 * channel open for communication.
				 * This is the first packet from the client.
				 * Copy its address to the connection object.
				 * Consider this channel open for communication.
				 */
			memcpy(&info->remote_addr, &src_addr, sizeof(src_addr));
				memcpy(&info->remote_addr, &src_addr,
					sizeof(src_addr));
				DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				 "%s first client [0x%x:0x%x]\n",
					 "%s client node:port::[0x%x]:[0x%x]\n",
					 info->name, src_addr.sq_node,
					 src_addr.sq_port);

@@ -760,6 +784,7 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
				else
					__socket_open_channel(info);
			}
		}
		temp += read_len;
		total_recd += read_len;
		bytes_remaining -= read_len;
+4 −4
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, 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
@@ -21,9 +21,9 @@
#define PORT_TYPE_SERVER		0
#define PORT_TYPE_CLIENT		1

#define PEPIPHERAL_AFTER_BOOT		0
#define PEPIPHERAL_SSR_DOWN		1
#define PEPIPHERAL_SSR_UP		2
#define PERIPHERAL_AFTER_BOOT		0
#define PERIPHERAL_SSR_DOWN		1
#define PERIPHERAL_SSR_UP		2

enum {
	SOCKET_MODEM,