net/socket_rpmsg: add net socket rpmsg support
Change-Id: Ie23ee4c0052cf2fc66972ea9bc5f11c070fbcf8a Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
24cc83e46f
commit
70442d1f9d
12 changed files with 1371 additions and 1 deletions
|
@ -13,7 +13,9 @@ CONFIG_ARCH_CHIP="sim"
|
|||
CONFIG_ARCH_SIM=y
|
||||
CONFIG_BOARDCTL_POWEROFF=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEV_SIMPLE_ADDRENV=y
|
||||
CONFIG_EXAMPLES_RPMSGSOCKET=y
|
||||
CONFIG_FS_HOSTFS=y
|
||||
CONFIG_FS_HOSTFS_RPMSG=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
|
@ -26,6 +28,7 @@ CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3
|
|||
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d
|
||||
CONFIG_NETUTILS_USRSOCK_RPMSG=y
|
||||
CONFIG_NET_ICMP_NO_STACK=y
|
||||
CONFIG_NET_RPMSG=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_TCP_NO_STACK=y
|
||||
CONFIG_NET_UDP_NO_STACK=y
|
||||
|
|
|
@ -12,7 +12,9 @@ CONFIG_ARCH_CHIP="sim"
|
|||
CONFIG_ARCH_SIM=y
|
||||
CONFIG_BOARDCTL_POWEROFF=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEV_SIMPLE_ADDRENV=y
|
||||
CONFIG_EXAMPLES_RPMSGSOCKET=y
|
||||
CONFIG_FS_HOSTFS=y
|
||||
CONFIG_FS_HOSTFS_RPMSG_SERVER=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
|
@ -34,6 +36,7 @@ CONFIG_NET_BROADCAST=y
|
|||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_LOOPBACK=y
|
||||
CONFIG_NET_RPMSG=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
|
@ -55,6 +58,7 @@ CONFIG_SCHED_CHILD_STATUS=y
|
|||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_SIM_M32=y
|
||||
CONFIG_SIM_NET_BRIDGE=y
|
||||
CONFIG_SIM_RPTUN_MASTER=y
|
||||
|
@ -67,5 +71,6 @@ CONFIG_SYSTEM_CUTERM=y
|
|||
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE="/dev/ttyproxy"
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_USERMAIN_STACKSIZE=4096
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
42
include/netpacket/rpmsg.h
Normal file
42
include/netpacket/rpmsg.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/****************************************************************************
|
||||
* include/netpacket/rpmsg.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NETPACKET_RPMSG_H
|
||||
#define __INCLUDE_NETPACKET_RPMSG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define RPMSG_SOCKET_CPU_SIZE 16
|
||||
#define RPMSG_SOCKET_NAME_SIZE 32
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct sockaddr_rpmsg
|
||||
{
|
||||
sa_family_t rp_family;
|
||||
char rp_cpu[RPMSG_SOCKET_CPU_SIZE];
|
||||
char rp_name[RPMSG_SOCKET_NAME_SIZE];
|
||||
};
|
||||
|
||||
#endif /* __INCLUDE_NETPACKET_RPMSG_H */
|
|
@ -50,6 +50,7 @@
|
|||
#define PF_BLUETOOTH 31 /* Bluetooth sockets */
|
||||
#define PF_IEEE802154 36 /* Low level IEEE 802.15.4 radio frame interface */
|
||||
#define PF_PKTRADIO 64 /* Low level packet radio interface */
|
||||
#define PF_RPMSG 65 /* Remote core communication */
|
||||
|
||||
/* Supported Address Families. Opengroup.org requires only AF_UNSPEC,
|
||||
* AF_UNIX, AF_INET and AF_INET6.
|
||||
|
@ -67,6 +68,7 @@
|
|||
#define AF_BLUETOOTH PF_BLUETOOTH
|
||||
#define AF_IEEE802154 PF_IEEE802154
|
||||
#define AF_PKTRADIO PF_PKTRADIO
|
||||
#define AF_RPMSG PF_RPMSG
|
||||
|
||||
/* The socket created by socket() has the indicated type, which specifies
|
||||
* the communication semantics.
|
||||
|
|
|
@ -303,6 +303,7 @@ source "net/socket/Kconfig"
|
|||
source "net/inet/Kconfig"
|
||||
source "net/pkt/Kconfig"
|
||||
source "net/local/Kconfig"
|
||||
source "net/rpmsg/Kconfig"
|
||||
source "net/can/Kconfig"
|
||||
source "net/netlink/Kconfig"
|
||||
source "net/tcp/Kconfig"
|
||||
|
|
|
@ -36,6 +36,7 @@ include neighbor/Make.defs
|
|||
include igmp/Make.defs
|
||||
include pkt/Make.defs
|
||||
include local/Make.defs
|
||||
include rpmsg/Make.defs
|
||||
include mld/Make.defs
|
||||
include can/Make.defs
|
||||
include netlink/Make.defs
|
||||
|
|
32
net/rpmsg/Kconfig
Normal file
32
net/rpmsg/Kconfig
Normal file
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menu "Rpmsg Socket Support"
|
||||
depends on NET
|
||||
|
||||
config NET_RPMSG
|
||||
bool "Rpmsg domain (remote) sockets"
|
||||
select MM_CIRCBUF
|
||||
default n
|
||||
---help---
|
||||
Enable or disable Rpmsg (aka remote) sockets.
|
||||
|
||||
if NET_RPMSG
|
||||
|
||||
config NET_RPMSG_RXBUF_SIZE
|
||||
int "Rpmsg socket rx buffer size"
|
||||
default 1024
|
||||
---help---
|
||||
Socket rpmsg rx buffer size, for recv slowly
|
||||
|
||||
config NET_RPMSG_NPOLLWAITERS
|
||||
int "Rpmsg socket number of poll waiters"
|
||||
default 4
|
||||
---help---
|
||||
Socket rpmsg number of poll waiters
|
||||
|
||||
endif # NET_RPMSG
|
||||
|
||||
endmenu # Rpmsg Domain Sockets
|
32
net/rpmsg/Make.defs
Normal file
32
net/rpmsg/Make.defs
Normal file
|
@ -0,0 +1,32 @@
|
|||
############################################################################
|
||||
# net/rpmsg/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Rpmsg domain socket source files
|
||||
|
||||
ifeq ($(CONFIG_NET_RPMSG),y)
|
||||
|
||||
NET_CSRCS += rpmsg_sockif.c
|
||||
|
||||
# Include rpmsg domain socket build support
|
||||
|
||||
DEPPATH += --dep-path rpmsg
|
||||
VPATH += :rpmsg
|
||||
|
||||
endif # CONFIG_NET_RPMSG
|
53
net/rpmsg/rpmsg.h
Normal file
53
net/rpmsg/rpmsg.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/****************************************************************************
|
||||
* net/rpmsg/rpmsg.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_RPMSG_RPMSG_H
|
||||
#define __NET_RPMSG_RPMSG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#ifdef CONFIG_NET_RPMSG
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN const struct sock_intf_s g_rpmsg_sockif;
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET_RPMSG */
|
||||
#endif /* __NET_RPMSG_RPMSG_H */
|
1192
net/rpmsg/rpmsg_sockif.c
Normal file
1192
net/rpmsg/rpmsg_sockif.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "inet/inet.h"
|
||||
#include "local/local.h"
|
||||
#include "rpmsg/rpmsg.h"
|
||||
#include "can/can.h"
|
||||
#include "netlink/netlink.h"
|
||||
#include "pkt/pkt.h"
|
||||
|
@ -120,6 +121,12 @@ net_sockif(sa_family_t family, int type, int protocol)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_RPMSG
|
||||
case PF_RPMSG:
|
||||
sockif = &g_rpmsg_sockif;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
nerr("ERROR: Address family unsupported: %d\n", family);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ int psock_socket(int domain, int type, int protocol,
|
|||
psock->s_type = type;
|
||||
|
||||
#ifdef CONFIG_NET_USRSOCK
|
||||
if (domain != PF_LOCAL && domain != PF_UNSPEC)
|
||||
if (domain != PF_LOCAL && domain != PF_UNSPEC && domain != PF_RPMSG)
|
||||
{
|
||||
/* Handle special setup for USRSOCK sockets (user-space networking
|
||||
* stack).
|
||||
|
|
Loading…
Reference in a new issue