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

Commit f70a2efc authored by Arun Kumar Neelakantam's avatar Arun Kumar Neelakantam Committed by Gustavo Solaira
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.
This is needed for exports that do not initialize until a hello
message is received.

CRs-Fixed: 2263332
Change-Id: Ib39eb5bc90887e47a75d6726cc84d10a8f5eecf4
Signed-off-by: default avatarArun Kumar Neelakantam <aneela@codeaurora.org>
parent 38bc3d98
Loading
Loading
Loading
Loading
+32 −13
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ struct msm_ipc_router_xprt_info {
	struct msm_ipc_router_xprt *xprt;
	uint32_t remote_node_id;
	uint32_t initialized;
	uint32_t hello_sent;
	struct list_head pkt_list;
	struct wakeup_source ws;
	struct mutex rx_lock_lhb2;
@@ -2485,12 +2486,37 @@ 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)
		return 0;

	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)
@@ -2505,19 +2531,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 = (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) {
		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
@@ -4074,6 +4091,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);
@@ -4113,6 +4131,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;
}