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

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

Merge "net: ipc_router: Configure the IPC router NODE ID"

parents 7c0cacc6 3a655400
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -23,3 +23,13 @@ config IPC_ROUTER_SECURITY
	  once configured with the security rules will ensure that the
	  sender of the message to a service belongs to the relevant
	  Linux group as configured by the security script.

config IPC_ROUTER_NODE_ID
	depends on IPC_ROUTER
	int "IPC router local NODE ID"
	default 1
	help
	  This option allows to configure the IPC Router NODE ID dynamically.
	  The NODE defined here is used as the local NODE ID by IPC Router
	  core and publish the same NODE ID to other NODES present in the
	  network.
+31 −13
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ struct msm_ipc_router_xprt_info {
	struct msm_ipc_router_xprt *xprt;
	u32 remote_node_id;
	u32 initialized;
	u32 hello_sent;
	struct list_head pkt_list;
	struct wakeup_source ws;
	struct mutex rx_lock_lhb2; /* lock for xprt rx operations */
@@ -2494,12 +2495,36 @@ static void do_version_negotiation(struct msm_ipc_router_xprt_info *xprt_info,
	}
}

static int send_hello_msg(struct msm_ipc_router_xprt_info *xprt_info)
{
	int rc = 0;
	union rr_control_msg ctl;

	if (!xprt_info->hello_sent) {
		xprt_info->hello_sent = 1;
		/* Send a HELLO message */
		memset(&ctl, 0, sizeof(ctl));
		ctl.hello.cmd = IPC_ROUTER_CTRL_CMD_HELLO;
		ctl.hello.checksum = IPC_ROUTER_HELLO_MAGIC;
		ctl.hello.versions = (uint32_t)IPC_ROUTER_VER_BITMASK;
		ctl.hello.checksum = ipc_router_calc_checksum(&ctl);
		rc = ipc_router_send_ctl_msg(xprt_info, &ctl,
					     IPC_ROUTER_DUMMY_DEST_NODE);
		if (rc < 0) {
			xprt_info->hello_sent = 0;
			IPC_RTR_ERR("%s: Error sending HELLO message\n",
				    __func__);
			return rc;
		}
	}
	return rc;
}

static int process_hello_msg(struct msm_ipc_router_xprt_info *xprt_info,
			     union rr_control_msg *msg,
			     struct rr_header_v1 *hdr)
{
	int i, rc = 0;
	union rr_control_msg ctl;
	struct msm_ipc_routing_table_entry *rt_entry;

	if (!hdr)
@@ -2514,19 +2539,10 @@ static int process_hello_msg(struct msm_ipc_router_xprt_info *xprt_info,
	kref_put(&rt_entry->ref, ipc_router_release_rtentry);

	do_version_negotiation(xprt_info, msg);
	/* Send a reply HELLO message */
	memset(&ctl, 0, sizeof(ctl));
	ctl.hello.cmd = IPC_ROUTER_CTRL_CMD_HELLO;
	ctl.hello.checksum = IPC_ROUTER_HELLO_MAGIC;
	ctl.hello.versions = (u32)IPC_ROUTER_VER_BITMASK;
	ctl.hello.checksum = ipc_router_calc_checksum(&ctl);
	rc = ipc_router_send_ctl_msg(xprt_info, &ctl,
				     IPC_ROUTER_DUMMY_DEST_NODE);
	if (rc < 0) {
		IPC_RTR_ERR("%s: Error sending reply HELLO message\n",
			    __func__);
	rc = send_hello_msg(xprt_info);
	if (rc < 0)
		return rc;
	}

	xprt_info->initialized = 1;

	/* Send list of servers from the local node and from nodes
@@ -4068,6 +4084,7 @@ static int msm_ipc_router_add_xprt(struct msm_ipc_router_xprt *xprt)

	xprt_info->xprt = xprt;
	xprt_info->initialized = 0;
	xprt_info->hello_sent = 0;
	xprt_info->remote_node_id = -1;
	INIT_LIST_HEAD(&xprt_info->pkt_list);
	mutex_init(&xprt_info->rx_lock_lhb2);
@@ -4109,6 +4126,7 @@ static int msm_ipc_router_add_xprt(struct msm_ipc_router_xprt *xprt)
	up_write(&routing_table_lock_lha3);

	xprt->priv = xprt_info;
	send_hello_msg(xprt_info);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2016, 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
@@ -37,7 +37,7 @@

#define IPC_ROUTER_ADDRESS			0x0000FFFF

#define IPC_ROUTER_NID_LOCAL			1
#define IPC_ROUTER_NID_LOCAL	CONFIG_IPC_ROUTER_NODE_ID
#define MAX_IPC_PKT_SIZE 66000

#define IPC_ROUTER_LOW_RX_QUOTA		5