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

Commit 65f462d6 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: Create remote port information for local connection"

parents 9d86a549 6708b21b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ struct msm_ipc_port {
	spinlock_t restart_lock;
	wait_queue_head_t restart_wait;

	void *rport_info;
	void *endpoint;
	void (*notify)(unsigned event, void *oob_data,
		       size_t oob_data_len, void *priv);
+53 −30
Original line number Diff line number Diff line
@@ -200,6 +200,9 @@ static uint32_t next_port_id;
static DEFINE_MUTEX(next_port_id_lock_lhc1);
static struct workqueue_struct *msm_ipc_router_workqueue;

static int process_resume_tx_msg(union rr_control_msg *msg,
				 struct rr_packet *pkt);

enum {
	DOWN,
	UP,
@@ -1591,6 +1594,9 @@ static int ipc_router_send_ctl_msg(
	if (dst_node_id == IPC_ROUTER_NID_LOCAL &&
	    msg->cmd != IPC_ROUTER_CTRL_CMD_RESUME_TX) {
		ret = post_control_ports(pkt);
	} else if (dst_node_id == IPC_ROUTER_NID_LOCAL &&
		   msg->cmd == IPC_ROUTER_CTRL_CMD_RESUME_TX) {
		ret = process_resume_tx_msg(msg, pkt);
	} else if (xprt_info && (msg->cmd == IPC_ROUTER_CTRL_CMD_HELLO ||
		   xprt_info->initialized)) {
		mutex_lock(&xprt_info->tx_lock_lhb2);
@@ -2353,6 +2359,7 @@ int msm_ipc_router_register_server(struct msm_ipc_port *port_ptr,
{
	struct msm_ipc_server *server;
	union rr_control_msg ctl;
	struct msm_ipc_router_remote_port *rport_ptr;

	if (!port_ptr || !name)
		return -EINVAL;
@@ -2370,6 +2377,17 @@ int msm_ipc_router_register_server(struct msm_ipc_port *port_ptr,
		return -ENOMEM;
	}

	rport_ptr = ipc_router_create_rport(IPC_ROUTER_NID_LOCAL,
			port_ptr->this_port.port_id, NULL);
	if (!rport_ptr) {
		IPC_RTR_ERR("%s: RPort Creation failed\n", __func__);
		kref_put(&server->ref, ipc_router_release_server);
		ipc_router_destroy_server(server,
					IPC_ROUTER_NID_LOCAL,
					port_ptr->this_port.port_id);
		return -ENOMEM;
	}

	memset(&ctl, 0, sizeof(ctl));
	ctl.cmd = IPC_ROUTER_CTRL_CMD_NEW_SERVER;
	ctl.srv.service = server->name.service;
@@ -2382,7 +2400,9 @@ int msm_ipc_router_register_server(struct msm_ipc_port *port_ptr,
	port_ptr->mode_info.mode = MULTI_LINK_MODE;
	port_ptr->port_name.service = server->name.service;
	port_ptr->port_name.instance = server->name.instance;
	port_ptr->rport_info = rport_ptr;
	mutex_unlock(&port_ptr->port_lock_lhc3);
	kref_put(&rport_ptr->ref, ipc_router_release_rport);
	kref_put(&server->ref, ipc_router_release_server);
	return 0;
}
@@ -2435,35 +2455,17 @@ int msm_ipc_router_unregister_server(struct msm_ipc_port *port_ptr)

static int loopback_data(struct msm_ipc_port *src,
			uint32_t port_id,
			struct sk_buff_head *data)
			struct rr_packet *pkt)
{
	struct rr_header_v1 *hdr;
	struct msm_ipc_port *port_ptr;
	struct rr_packet *pkt;
	int ret_len;
	struct sk_buff *temp_skb;
	int align_size;

	if (!data) {
	if (!pkt) {
		IPC_RTR_ERR("%s: Invalid pkt pointer\n", __func__);
		return -EINVAL;
	}

	pkt = create_pkt(data);
	if (!pkt) {
		IPC_RTR_ERR("%s: New pkt create failed\n", __func__);
		return -ENOMEM;
	}
	hdr = &(pkt->hdr);
	hdr->version = IPC_ROUTER_V1;
	hdr->type = IPC_ROUTER_CTRL_CMD_DATA;
	hdr->src_node_id = src->this_port.node_id;
	hdr->src_port_id = src->this_port.port_id;
	hdr->size = pkt->length;
	hdr->control_flag = 0;
	hdr->dst_node_id = IPC_ROUTER_NID_LOCAL;
	hdr->dst_port_id = port_id;

	temp_skb = skb_peek_tail(pkt->pkt_fragment_q);
	align_size = ALIGN_SIZE(pkt->length);
	skb_put(temp_skb, align_size);
@@ -2473,17 +2475,13 @@ static int loopback_data(struct msm_ipc_port *src,
	if (!port_ptr) {
		IPC_RTR_ERR("%s: Local port %d not present\n",
						__func__, port_id);
		pkt->pkt_fragment_q = NULL;
		release_pkt(pkt);
		return -ENODEV;
	}

	ret_len = hdr->size;
	post_pkt_to_port(port_ptr, pkt, 0);
	post_pkt_to_port(port_ptr, pkt, 1);
	update_comm_mode_info(&src->mode_info, NULL);
	kref_put(&port_ptr->ref, ipc_router_release_port);

	return ret_len;
	return pkt->hdr.size;
}

static int msm_ipc_router_write_pkt(struct msm_ipc_port *src,
@@ -2503,6 +2501,7 @@ static int msm_ipc_router_write_pkt(struct msm_ipc_port *src,
		return -EINVAL;

	hdr = &(pkt->hdr);
	hdr->version = IPC_ROUTER_V1;
	hdr->type = IPC_ROUTER_CTRL_CMD_DATA;
	hdr->src_node_id = src->this_port.node_id;
	hdr->src_port_id = src->this_port.port_id;
@@ -2540,6 +2539,11 @@ static int msm_ipc_router_write_pkt(struct msm_ipc_port *src,
		hdr->control_flag |= CONTROL_FLAG_CONFIRM_RX;
	mutex_unlock(&rport_ptr->rport_lock_lhb2);

	if (hdr->dst_node_id == IPC_ROUTER_NID_LOCAL) {
		ret = loopback_data(src, hdr->dst_port_id, pkt);
		return ret;
	}

	rt_entry = ipc_router_get_rtentry_ref(hdr->dst_node_id);
	if (!rt_entry) {
		IPC_RTR_ERR("%s: Remote node %d not up\n",
@@ -2607,6 +2611,7 @@ int msm_ipc_router_send_to(struct msm_ipc_port *src,
	struct msm_ipc_server *server;
	struct msm_ipc_server_port *server_port;
	struct msm_ipc_router_remote_port *rport_ptr = NULL;
	struct msm_ipc_router_remote_port *src_rport_ptr = NULL;
	struct rr_packet *pkt;
	int ret;

@@ -2636,10 +2641,6 @@ int msm_ipc_router_send_to(struct msm_ipc_port *src,
		dst_port_id = server_port->server_addr.port_id;
		kref_put(&server->ref, ipc_router_release_server);
	}
	if (dst_node_id == IPC_ROUTER_NID_LOCAL) {
		ret = loopback_data(src, dst_port_id, data);
		return ret;
	}

	rport_ptr = ipc_router_get_rport_ref(dst_node_id, dst_port_id);
	if (!rport_ptr) {
@@ -2657,6 +2658,20 @@ int msm_ipc_router_send_to(struct msm_ipc_port *src,
		}
	}

	if (dst_node_id == IPC_ROUTER_NID_LOCAL && !src->rport_info) {
		src_rport_ptr = ipc_router_create_rport(IPC_ROUTER_NID_LOCAL,
					src->this_port.port_id, NULL);
		if (!src_rport_ptr) {
			kref_put(&rport_ptr->ref, ipc_router_release_rport);
			IPC_RTR_ERR("%s: RPort creation failed\n", __func__);
			return -ENOMEM;
		}
		mutex_lock(&src->port_lock_lhc3);
		src->rport_info = src_rport_ptr;
		mutex_unlock(&src->port_lock_lhc3);
		kref_put(&src_rport_ptr->ref, ipc_router_release_rport);
	}

	pkt = create_pkt(data);
	if (!pkt) {
		kref_put(&rport_ptr->ref, ipc_router_release_rport);
@@ -2943,6 +2958,7 @@ int msm_ipc_router_close_port(struct msm_ipc_port *port_ptr)
{
	union rr_control_msg msg;
	struct msm_ipc_server *server;
	struct msm_ipc_router_remote_port *rport_ptr;

	if (!port_ptr)
		return -EINVAL;
@@ -2998,6 +3014,13 @@ int msm_ipc_router_close_port(struct msm_ipc_port *port_ptr)
		}
	}

	mutex_lock(&port_ptr->port_lock_lhc3);
	rport_ptr = (struct msm_ipc_router_remote_port *)port_ptr->rport_info;
	port_ptr->rport_info = NULL;
	mutex_unlock(&port_ptr->port_lock_lhc3);
	if (rport_ptr)
		ipc_router_destroy_rport(rport_ptr);

	kref_put(&port_ptr->ref, ipc_router_release_port);
	return 0;
}