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

Commit f99191db authored by Arun Kumar Neelakantam's avatar Arun Kumar Neelakantam
Browse files

net: ipc_router: Send HELLO message after transport UP



Send HELLO message after transport up notification, instead of
waiting for the remote to send the HELLO message and process it.

CRs-Fixed: 2263332
Change-Id: Ib39eb5bc90887e47a75d6726cc84d10a8f5eecf4
Signed-off-by: default avatarArun Kumar Neelakantam <aneela@codeaurora.org>
parent 63098a4e
Loading
Loading
Loading
Loading
+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;
}