You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/01/30 12:09:05 UTC
(nuttx) 01/02: rptun_ping: Strip rptun_ping out of rptun and rename to rpmsg_ping
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ce832c6377594c94c40a7547ed340d47c474eefa
Author: wangyongrong <wa...@xiaomi.com>
AuthorDate: Fri Dec 22 16:09:24 2023 +0800
rptun_ping: Strip rptun_ping out of rptun and rename to rpmsg_ping
It should be possible to use ping without rptun being enabled, so striped rptun_ping out of rptun and rename to rpmsg_ping.
Signed-off-by: wangyongrong <wa...@xiaomi.com>
---
drivers/rpmsg/CMakeLists.txt | 4 +
drivers/rpmsg/Kconfig | 11 +++
drivers/rpmsg/Make.defs | 4 +
drivers/rpmsg/rpmsg.c | 34 +++++++-
drivers/{rptun/rptun_ping.c => rpmsg/rpmsg_ping.c} | 95 +++++++++++-----------
drivers/{rptun/rptun_ping.h => rpmsg/rpmsg_ping.h} | 23 +++---
drivers/rptun/CMakeLists.txt | 4 -
drivers/rptun/Kconfig | 7 --
drivers/rptun/Make.defs | 4 -
drivers/rptun/rptun.c | 35 +++-----
drivers/rptun/rptun.h | 3 -
include/nuttx/fs/ioctl.h | 8 +-
include/nuttx/rpmsg/rpmsg.h | 16 ++++
.../{rptun/rptun_ping.h => rpmsg/rpmsg_ping.h} | 14 ++--
include/nuttx/rptun/rptun.h | 14 ++--
15 files changed, 155 insertions(+), 121 deletions(-)
diff --git a/drivers/rpmsg/CMakeLists.txt b/drivers/rpmsg/CMakeLists.txt
index fd6ec42d4b..02d54ca413 100644
--- a/drivers/rpmsg/CMakeLists.txt
+++ b/drivers/rpmsg/CMakeLists.txt
@@ -23,5 +23,9 @@ if(CONFIG_RPMSG)
list(APPEND SRCS rpmsg.c)
+ if(CONFIG_RPMSG_PING)
+ list(APPEND SRCS rpmsg_ping.c)
+ endif()
+
target_sources(drivers PRIVATE ${SRCS})
endif()
diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index 1a7a073c8e..11021524e7 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -7,3 +7,14 @@ config RPMSG
bool
default n
select OPENAMP
+
+if RPMSG
+
+config RPMSG_PING
+ bool "rpmsg ping support"
+ default n
+ ---help---
+ This is for debugging & profiling, create ping rpmsg
+ channel, user can use it to get send/recv speed & latency.
+
+endif # RPMSG
diff --git a/drivers/rpmsg/Make.defs b/drivers/rpmsg/Make.defs
index 1c9a7ae4a0..1d5a52e874 100644
--- a/drivers/rpmsg/Make.defs
+++ b/drivers/rpmsg/Make.defs
@@ -24,6 +24,10 @@ ifeq ($(CONFIG_RPMSG),y)
CSRCS += rpmsg.c
+ifeq ($(CONFIG_RPMSG_PING),y)
+CSRCS += rpmsg_ping.c
+endif
+
DEPPATH += --dep-path rpmsg
VPATH += :rpmsg
diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c
index 083ce38db5..8f8008e23a 100644
--- a/drivers/rpmsg/rpmsg.c
+++ b/drivers/rpmsg/rpmsg.c
@@ -29,6 +29,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/rpmsg/rpmsg.h>
+#include "rpmsg_ping.h"
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -91,12 +93,32 @@ rpmsg_get_by_rdev(FAR struct rpmsg_device *rdev)
return metal_container_of(rdev, struct rpmsg_s, rdev);
}
+static int rpmsg_dev_ioctl_(FAR struct rpmsg_s *rpmsg, int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ switch (cmd)
+ {
+#ifdef CONFIG_RPMSG_PING
+ case RPMSGIOC_PING:
+ ret = rpmsg_ping(&rpmsg->ping, (FAR const struct rpmsg_ping_s *)arg);
+ break;
+#endif
+ default:
+ ret = rpmsg->ops->ioctl(rpmsg, cmd, arg);
+ break;
+ }
+
+ return ret;
+}
+
static int rpmsg_dev_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
{
FAR struct rpmsg_s *rpmsg = filep->f_inode->i_private;
- return rpmsg->ops->ioctl(rpmsg, cmd, arg);
+ return rpmsg_dev_ioctl_(rpmsg, cmd, arg);
}
/****************************************************************************
@@ -379,6 +401,10 @@ void rpmsg_device_created(FAR struct rpmsg_s *rpmsg)
}
nxrmutex_unlock(&g_rpmsg_lock);
+
+#ifdef CONFIG_RPMSG_PING
+ rpmsg_ping_init(rpmsg->rdev, &rpmsg->ping);
+#endif
}
void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg)
@@ -387,6 +413,10 @@ void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg)
FAR struct metal_list *node;
FAR struct metal_list *tmp;
+#ifdef CONFIG_RPMSG_PING
+ rpmsg_ping_deinit(&rpmsg->ping);
+#endif
+
nxrmutex_lock(&rpmsg->lock);
metal_list_for_each_safe(&rpmsg->bind, node, tmp)
@@ -466,7 +496,7 @@ int rpmsg_ioctl(FAR const char *cpuname, int cmd, unsigned long arg)
if (!cpuname || !strcmp(rpmsg_get_cpuname(rpmsg->rdev), cpuname))
{
- ret = rpmsg->ops->ioctl(rpmsg, cmd, arg);
+ ret = rpmsg_dev_ioctl_(rpmsg, cmd, arg);
if (ret < 0)
{
break;
diff --git a/drivers/rptun/rptun_ping.c b/drivers/rpmsg/rpmsg_ping.c
similarity index 67%
rename from drivers/rptun/rptun_ping.c
rename to drivers/rpmsg/rpmsg_ping.c
index 5534e2957f..4b434a8b5b 100644
--- a/drivers/rptun/rptun_ping.c
+++ b/drivers/rpmsg/rpmsg_ping.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * drivers/rptun/rptun_ping.c
+ * drivers/rpmsg/rpmsg_ping.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -24,30 +24,32 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
+#include <nuttx/signal.h>
#include <inttypes.h>
#include <string.h>
#include <sys/param.h>
#include <time.h>
-#include <nuttx/signal.h>
+#include <syslog.h>
+
+#include "rpmsg_ping.h"
-#include "rptun_ping.h"
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
-#define RPTUN_PING_EPT_NAME "rpmsg-ping"
-#define RPTUN_PING_SEND 1
-#define RPTUN_PING_SEND_CHECK 2
-#define RPTUN_PING_SEND_NOACK 3
-#define RPTUN_PING_ACK 4
-#define RPTUN_PING_CHECK_DATA 0xee
+#define RPMSG_PING_EPT_NAME "rpmsg-ping"
+#define RPMSG_PING_SEND 1
+#define RPMSG_PING_SEND_CHECK 2
+#define RPMSG_PING_SEND_NOACK 3
+#define RPMSG_PING_ACK 4
+#define RPMSG_PING_CHECK_DATA 0xee
/****************************************************************************
* Private Types
****************************************************************************/
-begin_packed_struct struct rptun_ping_msg_s
+begin_packed_struct struct rpmsg_ping_msg_s
{
uint32_t cmd;
uint32_t len;
@@ -59,27 +61,27 @@ begin_packed_struct struct rptun_ping_msg_s
* Private Functions
****************************************************************************/
-static int rptun_ping_ept_cb(FAR struct rpmsg_endpoint *ept,
+static int rpmsg_ping_ept_cb(FAR struct rpmsg_endpoint *ept,
FAR void *data, size_t len, uint32_t src,
FAR void *priv)
{
- FAR struct rptun_ping_msg_s *msg = data;
+ FAR struct rpmsg_ping_msg_s *msg = data;
FAR sem_t *sem = (FAR sem_t *)(uintptr_t)msg->cookie;
- if (msg->cmd == RPTUN_PING_SEND)
+ if (msg->cmd == RPMSG_PING_SEND)
{
- msg->cmd = RPTUN_PING_ACK;
+ msg->cmd = RPMSG_PING_ACK;
rpmsg_send(ept, msg, len);
}
- else if (msg->cmd == RPTUN_PING_SEND_CHECK)
+ else if (msg->cmd == RPMSG_PING_SEND_CHECK)
{
size_t data_len;
size_t i;
- data_len = msg->len - sizeof(struct rptun_ping_msg_s) + 1;
+ data_len = msg->len - sizeof(struct rpmsg_ping_msg_s) + 1;
for (i = 0; i < data_len; i++)
{
- if (msg->data[i] != RPTUN_PING_CHECK_DATA)
+ if (msg->data[i] != RPMSG_PING_CHECK_DATA)
{
syslog(LOG_ERR, "rptun ping remote receive data error!\n");
break;
@@ -88,10 +90,10 @@ static int rptun_ping_ept_cb(FAR struct rpmsg_endpoint *ept,
msg->data[i] = 0;
}
- msg->cmd = RPTUN_PING_ACK;
+ msg->cmd = RPMSG_PING_ACK;
rpmsg_send(ept, msg, len);
}
- else if (msg->cmd == RPTUN_PING_ACK)
+ else if (msg->cmd == RPMSG_PING_ACK)
{
nxsem_post(sem);
}
@@ -99,21 +101,20 @@ static int rptun_ping_ept_cb(FAR struct rpmsg_endpoint *ept,
return 0;
}
-static int rptun_ping_once(FAR struct rpmsg_endpoint *ept,
- int len, int ack)
+static int rpmsg_ping_once(FAR struct rpmsg_endpoint *ept,
+ int len, int ack, uint32_t *buf_len)
{
- FAR struct rptun_ping_msg_s *msg;
- uint32_t space;
+ FAR struct rpmsg_ping_msg_s *msg;
int ret;
- msg = rpmsg_get_tx_payload_buffer(ept, &space, true);
+ msg = rpmsg_get_tx_payload_buffer(ept, buf_len, true);
if (!msg)
{
return -ENOMEM;
}
- len = MAX(len, sizeof(struct rptun_ping_msg_s));
- len = MIN(len, space);
+ len = MAX(len, sizeof(struct rpmsg_ping_msg_s));
+ len = MIN(len, *buf_len);
memset(msg, 0, len);
@@ -121,14 +122,14 @@ static int rptun_ping_once(FAR struct rpmsg_endpoint *ept,
{
sem_t sem;
- msg->cmd = (ack == 1)? RPTUN_PING_SEND : RPTUN_PING_SEND_CHECK;
+ msg->cmd = (ack == 1)? RPMSG_PING_SEND : RPMSG_PING_SEND_CHECK;
msg->len = len;
msg->cookie = (uintptr_t)&sem;
- if (msg->cmd == RPTUN_PING_SEND_CHECK)
+ if (msg->cmd == RPMSG_PING_SEND_CHECK)
{
- memset(msg->data, RPTUN_PING_CHECK_DATA,
- len - sizeof(struct rptun_ping_msg_s) + 1);
+ memset(msg->data, RPMSG_PING_CHECK_DATA,
+ len - sizeof(struct rpmsg_ping_msg_s) + 1);
}
nxsem_init(&sem, 0, 0);
@@ -143,7 +144,7 @@ static int rptun_ping_once(FAR struct rpmsg_endpoint *ept,
}
else
{
- msg->cmd = RPTUN_PING_SEND_NOACK;
+ msg->cmd = RPMSG_PING_SEND_NOACK;
msg->len = len;
ret = rpmsg_send_nocopy(ept, msg, len);
}
@@ -151,7 +152,7 @@ static int rptun_ping_once(FAR struct rpmsg_endpoint *ept,
return ret;
}
-static void rptun_ping_logout(FAR const char *s, clock_t value)
+static void rpmsg_ping_logout(FAR const char *s, clock_t value)
{
struct timespec ts;
@@ -164,7 +165,7 @@ static void rptun_ping_logout(FAR const char *s, clock_t value)
#endif
}
-static void rptun_ping_logout_rate(uint64_t len, clock_t avg)
+static void rpmsg_ping_logout_rate(uint64_t len, clock_t avg)
{
struct timespec ts;
size_t ratebits;
@@ -184,12 +185,14 @@ static void rptun_ping_logout_rate(uint64_t len, clock_t avg)
* Public Functions
****************************************************************************/
-int rptun_ping(FAR struct rpmsg_endpoint *ept,
- FAR const struct rptun_ping_s *ping)
+int rpmsg_ping(FAR struct rpmsg_endpoint *ept,
+ FAR const struct rpmsg_ping_s *ping)
{
clock_t min = ULONG_MAX;
clock_t max = 0;
uint64_t total = 0;
+ uint32_t buf_len = 0;
+ int send_len;
int i;
if (!ept || !ping || ping->times <= 0)
@@ -201,10 +204,10 @@ int rptun_ping(FAR struct rpmsg_endpoint *ept,
{
clock_t tm = perf_gettime();
- int ret = rptun_ping_once(ept, ping->len, ping->ack);
- if (ret < 0)
+ send_len = rpmsg_ping_once(ept, ping->len, ping->ack, &buf_len);
+ if (send_len < 0)
{
- return ret;
+ return send_len;
}
tm = perf_gettime() - tm;
@@ -217,23 +220,23 @@ int rptun_ping(FAR struct rpmsg_endpoint *ept,
syslog(LOG_INFO, "ping times: %d\n", ping->times);
- rptun_ping_logout("avg", total / ping->times);
- rptun_ping_logout("min", min);
- rptun_ping_logout("max", max);
- rptun_ping_logout_rate(ping->len, total / ping->times);
+ rpmsg_ping_logout("avg", total / ping->times);
+ rpmsg_ping_logout("min", min);
+ rpmsg_ping_logout("max", max);
+ rpmsg_ping_logout_rate(send_len, total / ping->times);
return 0;
}
-int rptun_ping_init(FAR struct rpmsg_device *rdev,
+int rpmsg_ping_init(FAR struct rpmsg_device *rdev,
FAR struct rpmsg_endpoint *ept)
{
- return rpmsg_create_ept(ept, rdev, RPTUN_PING_EPT_NAME,
+ return rpmsg_create_ept(ept, rdev, RPMSG_PING_EPT_NAME,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
- rptun_ping_ept_cb, NULL);
+ rpmsg_ping_ept_cb, NULL);
}
-void rptun_ping_deinit(FAR struct rpmsg_endpoint *ept)
+void rpmsg_ping_deinit(FAR struct rpmsg_endpoint *ept)
{
rpmsg_destroy_ept(ept);
}
diff --git a/drivers/rptun/rptun_ping.h b/drivers/rpmsg/rpmsg_ping.h
similarity index 74%
rename from drivers/rptun/rptun_ping.h
rename to drivers/rpmsg/rpmsg_ping.h
index 9e17ee3dd3..dc85939142 100644
--- a/drivers/rptun/rptun_ping.h
+++ b/drivers/rpmsg/rpmsg_ping.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * drivers/rptun/rptun_ping.h
+ * drivers/rpmsg/rpmsg_ping.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,27 +18,26 @@
*
****************************************************************************/
-#ifndef __DRIVERS_RPTUN_RPTUN_PING_H
-#define __DRIVERS_RPTUN_RPTUN_PING_H
+#ifndef __DRIVERS_RPMSG_RPMSG_PING_H
+#define __DRIVERS_RPMSG_RPMSG_PING_H
/****************************************************************************
* Included Files
****************************************************************************/
-#include <nuttx/rptun/rptun_ping.h>
-#include <openamp/open_amp.h>
+#include <nuttx/rpmsg/rpmsg.h>
-#ifdef CONFIG_RPTUN_PING
+#ifdef CONFIG_RPMSG_PING
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
-int rptun_ping_init(FAR struct rpmsg_device *rvdev,
+int rpmsg_ping_init(FAR struct rpmsg_device *rdev,
FAR struct rpmsg_endpoint *ept);
-void rptun_ping_deinit(FAR struct rpmsg_endpoint *ept);
-int rptun_ping(FAR struct rpmsg_endpoint *ept,
- FAR const struct rptun_ping_s *ping);
+void rpmsg_ping_deinit(FAR struct rpmsg_endpoint *ept);
+int rpmsg_ping(FAR struct rpmsg_endpoint *ept,
+ FAR const struct rpmsg_ping_s *ping);
-#endif /* CONFIG_RPTUN_PING */
-#endif /* __DRIVERS_RPTUN_RPTUN_PING_H */
+#endif /* CONFIG_RPMSG_PING */
+#endif /* __DRIVERS_RPMSG_RPMSG_PING_H */
diff --git a/drivers/rptun/CMakeLists.txt b/drivers/rptun/CMakeLists.txt
index e4b81d83f9..bab4f294bf 100644
--- a/drivers/rptun/CMakeLists.txt
+++ b/drivers/rptun/CMakeLists.txt
@@ -22,10 +22,6 @@ if(CONFIG_RPTUN)
list(APPEND SRCS rptun.c rptun_dump.c)
- if(CONFIG_RPTUN_PING)
- list(APPEND SRCS rptun_ping.c)
- endif()
-
target_include_directories(drivers PRIVATE ${NUTTX_DIR}/openamp/open-amp/lib)
target_sources(drivers PRIVATE ${SRCS})
endif()
diff --git a/drivers/rptun/Kconfig b/drivers/rptun/Kconfig
index 9e289de049..db2cf2cbea 100644
--- a/drivers/rptun/Kconfig
+++ b/drivers/rptun/Kconfig
@@ -10,13 +10,6 @@ menuconfig RPTUN
---help---
RPTUN driver is used for multi-cores' communication.
-config RPTUN_PING
- bool "rptun ping support"
- default n
- ---help---
- This is for debugging & profiling, create ping rpmsg
- channel, user can use it to get send/recv speed & latency.
-
if RPTUN
config RPTUN_PRIORITY
diff --git a/drivers/rptun/Make.defs b/drivers/rptun/Make.defs
index a3fcfdbb2f..e78aab215a 100644
--- a/drivers/rptun/Make.defs
+++ b/drivers/rptun/Make.defs
@@ -24,10 +24,6 @@ ifeq ($(CONFIG_RPTUN),y)
CSRCS += rptun.c rptun_dump.c
-ifeq ($(CONFIG_RPTUN_PING),y)
-CSRCS += rptun_ping.c
-endif
-
DEPPATH += --dep-path rptun
VPATH += :rptun
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)drivers$(DELIM)rptun
diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index dabe5b5934..16664df123 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -71,9 +71,6 @@ struct rptun_priv_s
#ifdef CONFIG_RPTUN_PM
bool stay;
#endif
-#ifdef CONFIG_RPTUN_PING
- struct rpmsg_endpoint ping;
-#endif
};
struct rptun_store_s
@@ -461,7 +458,7 @@ static int rptun_ioctl(FAR struct rpmsg_s *rpmsg, int cmd, unsigned long arg)
switch (cmd)
{
- case RPTUNIOC_START:
+ case RPMSGIOC_START:
if (priv->rproc.state == RPROC_OFFLINE)
{
ret = rptun_dev_start(&priv->rproc);
@@ -475,26 +472,21 @@ static int rptun_ioctl(FAR struct rpmsg_s *rpmsg, int cmd, unsigned long arg)
}
}
break;
- case RPTUNIOC_STOP:
+ case RPMSGIOC_STOP:
ret = rptun_dev_stop(&priv->rproc, true);
break;
- case RPTUNIOC_RESET:
+ case RPMSGIOC_RESET:
RPTUN_RESET(priv->dev, arg);
break;
- case RPTUNIOC_PANIC:
+ case RPMSGIOC_PANIC:
RPTUN_PANIC(priv->dev);
break;
- case RPTUNIOC_DUMP:
+ case RPMSGIOC_DUMP:
rptun_dump(&priv->rvdev);
#ifdef CONFIG_RPTUN_PM
metal_log(METAL_LOG_EMERGENCY, "rptun headrx %d\n", priv->headrx);
#endif
break;
-#ifdef CONFIG_RPTUN_PING
- case RPTUNIOC_PING:
- rptun_ping(&priv->ping, (FAR const struct rptun_ping_s *)arg);
- break;
-#endif
default:
ret = -ENOTTY;
break;
@@ -696,9 +688,6 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
virtqueue_enable_cb(priv->rvdev.svq);
-#ifdef CONFIG_RPTUN_PING
- rptun_ping_init(&priv->rvdev.rdev, &priv->ping);
-#endif
return 0;
}
@@ -719,10 +708,6 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc, bool stop_ns)
rdev->support_ns = stop_ns;
-#ifdef CONFIG_RPTUN_PING
- rptun_ping_deinit(&priv->ping);
-#endif
-
/* Unregister callback from mbox */
RPTUN_UNREGISTER_CALLBACK(priv->dev);
@@ -932,22 +917,22 @@ err_mem:
int rptun_boot(FAR const char *cpuname)
{
- return rpmsg_ioctl(cpuname, RPTUNIOC_START, 0);
+ return rpmsg_ioctl(cpuname, RPMSGIOC_START, 0);
}
int rptun_poweroff(FAR const char *cpuname)
{
- return rpmsg_ioctl(cpuname, RPTUNIOC_STOP, 0);
+ return rpmsg_ioctl(cpuname, RPMSGIOC_STOP, 0);
}
int rptun_reset(FAR const char *cpuname, int value)
{
- return rpmsg_ioctl(cpuname, RPTUNIOC_RESET, value);
+ return rpmsg_ioctl(cpuname, RPMSGIOC_RESET, value);
}
int rptun_panic(FAR const char *cpuname)
{
- return rpmsg_ioctl(cpuname, RPTUNIOC_PANIC, 0);
+ return rpmsg_ioctl(cpuname, RPMSGIOC_PANIC, 0);
}
int rptun_buffer_nused(FAR struct rpmsg_virtio_device *rvdev, bool rx)
@@ -967,5 +952,5 @@ int rptun_buffer_nused(FAR struct rpmsg_virtio_device *rvdev, bool rx)
void rptun_dump_all(void)
{
- rpmsg_ioctl(NULL, RPTUNIOC_DUMP, 0);
+ rpmsg_ioctl(NULL, RPMSGIOC_DUMP, 0);
}
diff --git a/drivers/rptun/rptun.h b/drivers/rptun/rptun.h
index c19ddb4c3e..25227d1902 100644
--- a/drivers/rptun/rptun.h
+++ b/drivers/rptun/rptun.h
@@ -26,9 +26,6 @@
****************************************************************************/
#include <nuttx/rptun/rptun.h>
-#include <nuttx/rpmsg/rpmsg.h>
-
-#include "rptun_ping.h"
/****************************************************************************
* Public Function Prototypes
diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h
index b4aaca0b26..48c1ea1a98 100644
--- a/include/nuttx/fs/ioctl.h
+++ b/include/nuttx/fs/ioctl.h
@@ -81,7 +81,7 @@
#define _FBIOCBASE (0x2800) /* Frame buffer character driver ioctl commands */
#define _NXTERMBASE (0x2900) /* NxTerm character driver ioctl commands */
#define _RFIOCBASE (0x2a00) /* RF devices ioctl commands */
-#define _RPTUNBASE (0x2b00) /* Remote processor tunnel ioctl commands */
+#define _RPMSGBASE (0x2b00) /* Remote processor tunnel ioctl commands */
#define _NOTECTLBASE (0x2c00) /* Note filter control ioctl commands*/
#define _NOTERAMBASE (0x2d00) /* Noteram device ioctl commands*/
#define _RCIOCBASE (0x2e00) /* Remote Control device ioctl commands */
@@ -578,10 +578,10 @@
#define _RFIOCVALID(c) (_IOC_TYPE(c)==_RFIOCBASE)
#define _RFIOC(nr) _IOC(_RFIOCBASE,nr)
-/* Rptun drivers ************************************************************/
+/* Rpmsg drivers ************************************************************/
-#define _RPTUNIOCVALID(c) (_IOC_TYPE(c)==_RPTUNBASE)
-#define _RPTUNIOC(nr) _IOC(_RPTUNBASE,nr)
+#define _RPMSGIOCVALID(c) (_IOC_TYPE(c)==_RPMSGBASE)
+#define _RPMSGIOC(nr) _IOC(_RPMSGBASE,nr)
/* Notectl drivers **********************************************************/
diff --git a/include/nuttx/rpmsg/rpmsg.h b/include/nuttx/rpmsg/rpmsg.h
index f434e95e52..54c5e031bc 100644
--- a/include/nuttx/rpmsg/rpmsg.h
+++ b/include/nuttx/rpmsg/rpmsg.h
@@ -29,8 +29,21 @@
#ifdef CONFIG_RPMSG
+#include <nuttx/fs/ioctl.h>
+#include <nuttx/rpmsg/rpmsg_ping.h>
#include <openamp/rpmsg.h>
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define RPMSGIOC_START _RPMSGIOC(1)
+#define RPMSGIOC_STOP _RPMSGIOC(2)
+#define RPMSGIOC_RESET _RPMSGIOC(3)
+#define RPMSGIOC_PANIC _RPMSGIOC(4)
+#define RPMSGIOC_DUMP _RPMSGIOC(5)
+#define RPMSGIOC_PING _RPMSGIOC(6)
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -41,6 +54,9 @@ struct rpmsg_s
rmutex_t lock;
struct metal_list node;
FAR const struct rpmsg_ops_s *ops;
+#ifdef CONFIG_RPMSG_PING
+ struct rpmsg_endpoint ping;
+#endif
struct rpmsg_device rdev[0];
};
diff --git a/include/nuttx/rptun/rptun_ping.h b/include/nuttx/rpmsg/rpmsg_ping.h
similarity index 85%
rename from include/nuttx/rptun/rptun_ping.h
rename to include/nuttx/rpmsg/rpmsg_ping.h
index a47440bde3..68ac56c0e7 100644
--- a/include/nuttx/rptun/rptun_ping.h
+++ b/include/nuttx/rpmsg/rpmsg_ping.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * include/nuttx/rptun/rptun_ping.h
+ * include/nuttx/rpmsg/rpmsg_ping.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __INCLUDE_NUTTX_RPTUN_RPTUN_PING_H
-#define __INCLUDE_NUTTX_RPTUN_RPTUN_PING_H
+#ifndef __INCLUDE_NUTTX_RPMSG_RPMSG_PING_H
+#define __INCLUDE_NUTTX_RPMSG_RPMSG_PING_H
/****************************************************************************
* Included Files
@@ -27,7 +27,7 @@
#include <nuttx/config.h>
-#ifdef CONFIG_RPTUN_PING
+#ifdef CONFIG_RPMSG_PING
/****************************************************************************
* Public Function Prototypes
@@ -35,7 +35,7 @@
/* used for ioctl RPTUNIOC_PING */
-struct rptun_ping_s
+struct rpmsg_ping_s
{
int times;
int len;
@@ -43,5 +43,5 @@ struct rptun_ping_s
int sleep; /* unit: ms */
};
-#endif /* CONFIG_RPTUN_PING */
-#endif /* __INCLUDE_NUTTX_RPTUN_RPTUN_PING_H */
+#endif /* CONFIG_RPMSG_PING */
+#endif /* __INCLUDE_NUTTX_RPMSG_RPMSG_PING_H */
diff --git a/include/nuttx/rptun/rptun.h b/include/nuttx/rptun/rptun.h
index 972b78350d..2193ee19cd 100644
--- a/include/nuttx/rptun/rptun.h
+++ b/include/nuttx/rptun/rptun.h
@@ -30,7 +30,7 @@
#ifdef CONFIG_RPTUN
#include <nuttx/fs/ioctl.h>
-#include <nuttx/rptun/rptun_ping.h>
+#include <nuttx/rpmsg/rpmsg.h>
#include <openamp/remoteproc.h>
#include <openamp/rpmsg_virtio.h>
@@ -38,12 +38,12 @@
* Pre-processor Definitions
****************************************************************************/
-#define RPTUNIOC_START _RPTUNIOC(1)
-#define RPTUNIOC_STOP _RPTUNIOC(2)
-#define RPTUNIOC_RESET _RPTUNIOC(3)
-#define RPTUNIOC_PANIC _RPTUNIOC(4)
-#define RPTUNIOC_DUMP _RPTUNIOC(5)
-#define RPTUNIOC_PING _RPTUNIOC(6)
+#define RPTUNIOC_START _RPMSGIOC(1)
+#define RPTUNIOC_STOP _RPMSGIOC(2)
+#define RPTUNIOC_RESET _RPMSGIOC(3)
+#define RPTUNIOC_PANIC _RPMSGIOC(4)
+#define RPTUNIOC_DUMP _RPMSGIOC(5)
+#define RPTUNIOC_PING _RPMSGIOC(6)
#define RPTUN_NOTIFY_ALL (UINT32_MAX - 0)