mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
0a26f09c6b
1. add cpuname config for the rpmsg virtio devices, so the rpmsg virtio driver can get the local and remote cpuname from the virtio config space, and we can distinguish the differnt channel when there are two rpmsg virtio devices in the same resource table; 2. optimize the remoteproc virtio transport layer to make it can work with all the virtio devices instead only work with rpmsg virtio devices; Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
134 lines
4.7 KiB
Diff
134 lines
4.7 KiB
Diff
From a4f6ac1cb1545fdadf7f80cf34f1d31b15d543f7 Mon Sep 17 00:00:00 2001
|
|
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
Date: Mon, 7 Jan 2019 02:15:42 +0800
|
|
Subject: [PATCH 01/12] ns: acknowledge the received creation message
|
|
|
|
the two phase handshake make the client could initiate the transfer
|
|
immediately without the server side send any dummy message first.
|
|
|
|
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
|
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
|
---
|
|
lib/include/openamp/rpmsg.h | 3 +++
|
|
lib/include/openamp/rpmsg_virtio.h | 1 +
|
|
lib/rpmsg/rpmsg.c | 5 ++++-
|
|
lib/rpmsg/rpmsg_internal.h | 2 ++
|
|
lib/rpmsg/rpmsg_virtio.c | 14 +++++++++++---
|
|
5 files changed, 21 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
|
index 8871cfef88..0a4b47bae9 100644
|
|
--- a/lib/include/openamp/rpmsg.h
|
|
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
@@ -155,6 +155,9 @@ struct rpmsg_device {
|
|
|
|
/** Create/destroy namespace message */
|
|
bool support_ns;
|
|
+
|
|
+ /** Ack namespace message */
|
|
+ bool support_ack;
|
|
};
|
|
|
|
/**
|
|
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
|
index dbbbbfd245..b738e618cf 100644
|
|
--- a/lib/include/openamp/rpmsg_virtio.h
|
|
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
|
@@ -29,6 +29,7 @@ extern "C" {
|
|
|
|
/* The feature bitmap for virtio rpmsg */
|
|
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
|
|
+#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */
|
|
|
|
#if defined(VIRTIO_USE_DCACHE)
|
|
#define BUFFER_FLUSH(x, s) metal_cache_flush(x, s)
|
|
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
|
index b13e25fd23..28a8de61b3 100644
|
|
--- a/lib/rpmsg/rpmsg.c
|
|
+++ open-amp/lib/rpmsg/rpmsg.c
|
|
@@ -362,10 +362,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
|
rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb, ept->priv);
|
|
metal_mutex_release(&rdev->lock);
|
|
|
|
- /* Send NS announcement to remote processor */
|
|
+ /* Send NS announcement/acknowledge to remote processor */
|
|
if (ept->name[0] && rdev->support_ns &&
|
|
ept->dest_addr == RPMSG_ADDR_ANY)
|
|
status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
|
|
+ else if (ept->name[0] && rdev->support_ack &&
|
|
+ ept->dest_addr != RPMSG_ADDR_ANY)
|
|
+ status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE_ACK);
|
|
|
|
if (status)
|
|
rpmsg_unregister_endpoint(ept);
|
|
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
|
index 27b0f0d1b0..3e9ff02cb3 100644
|
|
--- a/lib/rpmsg/rpmsg_internal.h
|
|
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
|
@@ -44,6 +44,8 @@ enum rpmsg_ns_flags {
|
|
RPMSG_NS_CREATE = 0,
|
|
/** A known remote service was just destroyed */
|
|
RPMSG_NS_DESTROY = 1,
|
|
+ /** Acknowledge the previous creation message*/
|
|
+ RPMSG_NS_CREATE_ACK = 2,
|
|
};
|
|
|
|
/**
|
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
index ed3f4920c9..d59bad5d79 100644
|
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
|
@@ -668,7 +668,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
|
*/
|
|
ept_to_release = _ept && _ept->release_cb;
|
|
|
|
- if (ns_msg->flags & RPMSG_NS_DESTROY) {
|
|
+ if (ns_msg->flags == RPMSG_NS_DESTROY) {
|
|
if (_ept)
|
|
_ept->dest_addr = RPMSG_ADDR_ANY;
|
|
if (ept_to_release)
|
|
@@ -683,7 +683,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
|
rpmsg_ept_decref(_ept);
|
|
metal_mutex_release(&rdev->lock);
|
|
}
|
|
- } else {
|
|
+ } else if (ns_msg->flags == RPMSG_NS_CREATE) {
|
|
if (!_ept) {
|
|
/*
|
|
* send callback to application, that can
|
|
@@ -697,7 +697,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
|
} else {
|
|
_ept->dest_addr = dest;
|
|
metal_mutex_release(&rdev->lock);
|
|
+ if (_ept->name[0] && rdev->support_ack)
|
|
+ rpmsg_send_ns_message(_ept, RPMSG_NS_CREATE_ACK);
|
|
}
|
|
+ } else { /* RPMSG_NS_CREATE_ACK */
|
|
+ /* save the received destination address */
|
|
+ if (_ept)
|
|
+ _ept->dest_addr = dest;
|
|
+ metal_mutex_release(&rdev->lock);
|
|
}
|
|
|
|
return RPMSG_SUCCESS;
|
|
@@ -840,6 +847,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
|
if (status)
|
|
return status;
|
|
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));
|
|
+ rdev->support_ack = !!(features & (1 << VIRTIO_RPMSG_F_ACK));
|
|
|
|
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
|
|
/*
|
|
@@ -938,7 +946,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
|
* Create name service announcement endpoint if device supports name
|
|
* service announcement feature.
|
|
*/
|
|
- if (rdev->support_ns) {
|
|
+ if (rdev->support_ns || rdev->support_ack) {
|
|
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS",
|
|
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
|
|
rpmsg_virtio_ns_callback, NULL, rvdev);
|
|
--
|
|
2.34.1
|
|
|