Skip to contentSkip to conversation

net: msm_ipc: Add user-space support for MSM_IPC Router

PATCH In review Karthikeyan Ramasubramanian 4 participants 6 messages Jun 8, 2011 – Jun 9, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 net: msm_ipc: Add user-space support for MSM_IPC Router

MSM_IPC Router exports socket interface to the user-space processes to communicate with the processes in the remote processors

Change-Id I2d4039dd1825117c125d6975b22aa7f144659643
---
 include/linux/msm_ipc.h      |   47 ++++
 include/linux/socket.h       |    5 +-
 net/msm_ipc/Makefile         |    2 +-
 net/msm_ipc/msm_ipc_router.c |    7 +-
 net/msm_ipc/msm_ipc_router.h |    8 +
 net/msm_ipc/msm_ipc_socket.c |  520 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 585 insertions(+), 4 deletions(-)
 create mode 100644 net/msm_ipc/msm_ipc_socket.c
include/linux/msm_ipc.h +47 -0
index 47d678c..2db5d6f 100644
@@ -24,4 +24,51 @@ struct msm_ipc_addr {
 	} addr;
 };
 
+#define MSM_IPC_WAIT_FOREVER	(~0)
+
+/*
+ * Socket API
+ */
+
+#ifndef AF_MSM_IPC
+#define AF_MSM_IPC		39
+#endif
+
+#ifndef PF_MSM_IPC
+#define PF_MSM_IPC		AF_MSM_IPC
+#endif
+
+#define MSM_IPC_ADDR_NAME		1
+#define MSM_IPC_ADDR_ID			2
+
+struct sockaddr_msm_ipc {
+	unsigned short family;
+	struct msm_ipc_addr address;
+	unsigned char reserved;
+};
+
+#define IPC_ROUTER_IOCTL_MAGIC (0xC3)
+
+#define IPC_ROUTER_IOCTL_GET_VERSION \
+	_IOR(IPC_ROUTER_IOCTL_MAGIC, 0, unsigned int)
+
+#define IPC_ROUTER_IOCTL_GET_MTU \
+	_IOR(IPC_ROUTER_IOCTL_MAGIC, 1, unsigned int)
+
+#define IPC_ROUTER_IOCTL_LOOKUP_SERVER \
+	_IOWR(IPC_ROUTER_IOCTL_MAGIC, 2, struct sockaddr_msm_ipc)
+
+#define IPC_ROUTER_IOCTL_GET_CURR_PKT_SIZE \
+	_IOR(IPC_ROUTER_IOCTL_MAGIC, 3, unsigned int)
+
+#define IPC_ROUTER_IOCTL_BIND_CONTROL_PORT \
+	_IOR(IPC_ROUTER_IOCTL_MAGIC, 4, unsigned int)
+
+struct server_lookup_args {
+	struct msm_ipc_port_name port_name;
+	int num_entries_in_array;
+	int num_entries_found;
+	struct msm_ipc_port_addr port_addr[0];
+};
+
 #endif
include/linux/socket.h +4 -1
index d2b5e98..a23198e 100644
@@ -192,7 +192,8 @@ struct ucred {
 #define AF_IEEE802154	36	/* IEEE802154 sockets		*/
 #define AF_CAIF		37	/* CAIF sockets			*/
 #define AF_ALG		38	/* Algorithm sockets		*/
-#define AF_MAX		39	/* For now.. */
+#define AF_MSM_IPC	39	/* MSM_IPC sockets		*/
+#define AF_MAX		40	/* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC	AF_UNSPEC
@@ -234,6 +235,7 @@ struct ucred {
 #define PF_IEEE802154	AF_IEEE802154
 #define PF_CAIF		AF_CAIF
 #define PF_ALG		AF_ALG
+#define PF_MSM_IPC	AF_MSM_IPC
 #define PF_MAX		AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
@@ -308,6 +310,7 @@ struct ucred {
 #define SOL_IUCV	277
 #define SOL_CAIF	278
 #define SOL_ALG		279
+#define SOL_MSM_IPC	280
 
 /* IPX options */
 #define IPX_TYPE	1
net/msm_ipc/Makefile +1 -1
index 461c510..b9a0dfb 100644
@@ -1,3 +1,3 @@
 obj-$(CONFIG_MSM_IPC) := msm_ipc.o
 
-msm_ipc-y += msm_ipc_router.o
+msm_ipc-y += msm_ipc_router.o msm_ipc_socket.o
net/msm_ipc/msm_ipc_router.c +5 -2
index 76deacb..0cd0a02 100644
@@ -1638,7 +1638,7 @@ int msm_ipc_router_close(void)
 
 static int __init msm_ipc_router_init(void)
 {
-	int i;
+	int i, ret;
 	struct msm_ipc_routing_table_entry *rt_entry;
 #if !defined(CONFIG_MSM_IPC_ROUTER_SMD_XPRT)
 	struct work_struct dummy_work;
@@ -1662,8 +1662,11 @@ static int __init msm_ipc_router_init(void)
 	mutex_unlock(&routing_table_lock);
 
 	init_waitqueue_head(&newserver_wait);
+	ret = msm_ipc_router_init_sockets();
+	if (ret < 0)
+		pr_err("%s: Init sockets failed\n", __func__);
 
-	return 0;
+	return ret;
 }
 
 module_init(msm_ipc_router_init);
net/msm_ipc/msm_ipc_router.h +8 -0
index 4d30c8f..ef47f11 100644
@@ -132,6 +132,11 @@ struct msm_ipc_port {
 	void *priv;
 };
 
+struct msm_ipc_sock {
+	struct sock sk;
+	struct msm_ipc_port *port;
+};
+
 struct msm_ipc_router_xprt {
 	char *name;
 	uint32_t link_id;
@@ -184,4 +189,7 @@ int msm_ipc_router_register_server(struct msm_ipc_port *server_port,
 			    struct msm_ipc_addr *name);
 int msm_ipc_router_unregister_server(struct msm_ipc_port *server_port);
 
+int msm_ipc_router_init_sockets(void);
+void msm_ipc_router_exit_sockets(void);
+
 #endif
net/msm_ipc/msm_ipc_socket.c new file +520 -0

520 lines not on this page · raw message

Signature · 4 lines
1.7.3.3

Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
maintainer
#1 lore raw

There is no reason to create a whole new socket address family, use genetlink instead.

#2 lore raw
Quoted 7 lines · David Miller

There is no reason to create a whole new socket address family, use genetlink instead.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

The prospect of using NETLINK sockets was investigated and it seems to be supporting the communication between user-space and kernel-space processes.

One of the requirements/goals for this MSM_IPC Router is to enable the communication between the processes running on different processors & OSes, and the addressing mechanism of NETLINK sockets is insufficient to address the processes running in different processors and OSes.

We also have the requirements of built-in name service, remote process's status detection, location transparency etc. That is the reason for this home-grown solution with a requirement for new socket address family.

Please let me know if you need any other information.

Thanks and Regards,
Karthik.

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
maintainer
#3 lore raw

From: Karthikeyan Ramasubramanian <[email protected]>
Date: Thu, 09 Jun 2011 11:06:18 -0600

Quoted 1 line

Please let me know if you need any other information.

I don't agree with creating all of this non-trivial infrastructure for what seems to be an obscure protocol stack.

You can do all of this in userspace, it seems.

#4 lore raw
Quoted 9 lines · On Thursday 09 June 2011 21:35:53 David Miller wrote:

From: Karthikeyan Ramasubramanian <[email protected]>
Date: Thu, 09 Jun 2011 11:06:18 -0600

Quoted 1 line

Please let me know if you need any other information.

I don't agree with creating all of this non-trivial infrastructure for what seems to be an obscure protocol stack.

You can do all of this in userspace, it seems.

I can see some good use cases for having a socket to do IPC between OS images that have a shared memory interconnect. What I see as most problematic is to have it defined in a way that is tightly connected to specific hardware from one vendor. If the protocol was defined in a way that is useful for communication between virtual machines (e.g. on top of virtio) and tranparent PCI bridges, it would probably be much more acceptable.

Arnd

#5 lore raw
Quoted 9 lines · Arnd Bergmann

I can see some good use cases for having a socket to do IPC between OS images that have a shared memory interconnect. What I see as most problematic is to have it defined in a way that is tightly connected to specific hardware from one vendor. If the protocol was defined in a way that is useful for communication between virtual machines (e.g. on top of virtio) and tranparent PCI bridges, it would probably be much more acceptable.

Arnd

Yeah, we're trying to figure out the best way to do socket-based communication between various images within a SoC. I was thinking that some kind of registration scheme would be necessary for the new AF to support different SoCs and communication mechanisms. We'll take a look at ways to have a generic implementation. Thanks.

- Bryan

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.