This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e7bac449a6b7bf21875921e6725300117e1381f7
Author: Yongrong Wang <[email protected]>
AuthorDate: Wed Oct 28 21:19:09 2026 +0800

    openamp: pass the endpoint priority to the transport TX ops
    
    Patch 0018 added a priority to struct rpmsg_endpoint, but nothing used
    it: the send_offchannel_raw and get_tx_payload_buffer device ops did not
    receive it, so a transport could not order or schedule its TX traffic by
    endpoint.
    
    Extend 0018 with the rest of the change: add a priority argument to both
    ops, pass ept->priority from rpmsg_send_offchannel_raw() and
    rpmsg_get_tx_payload_buffer(), and add rpmsg_set_priority(). rpmsg_port
    and rpmsg_router_edge implement these ops, so update them in the same
    commit to keep the tree building; rpmsg_router_edge forwards the
    priority to its hub device.
    
    Signed-off-by: Yongrong Wang <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rpmsg/rpmsg_port.c                         |   9 +-
 drivers/rpmsg/rpmsg_router_edge.c                  |  10 +-
 ...g-add-priority-support-for-rpmsg-endpoint.patch | 156 +++++++++++++++++++--
 3 files changed, 152 insertions(+), 23 deletions(-)

diff --git a/drivers/rpmsg/rpmsg_port.c b/drivers/rpmsg/rpmsg_port.c
index 8277e4ac263..502cdedab73 100644
--- a/drivers/rpmsg/rpmsg_port.c
+++ b/drivers/rpmsg/rpmsg_port.c
@@ -245,7 +245,8 @@ static void rpmsg_port_destroy_queues(FAR struct 
rpmsg_port_s *port)
 
 static FAR void *
 rpmsg_port_get_tx_payload_buffer(FAR struct rpmsg_device *rdev,
-                                 FAR uint32_t *len, int wait)
+                                 FAR uint32_t *len, int wait,
+                                 uint8_t priority)
 {
   FAR struct rpmsg_port_s *port =
     metal_container_of(rdev, struct rpmsg_port_s, rdev);
@@ -302,13 +303,13 @@ static int rpmsg_port_send_offchannel_nocopy(FAR struct 
rpmsg_device *rdev,
 
 static int rpmsg_port_send_offchannel_raw(FAR struct rpmsg_device *rdev,
                                           uint32_t src, uint32_t dst,
-                                          FAR const void *data,
-                                          int len, int wait)
+                                          FAR const void *data, int len,
+                                          int wait, uint8_t priority)
 {
   uint32_t buflen;
   FAR void *buf;
 
-  buf = rpmsg_port_get_tx_payload_buffer(rdev, &buflen, wait);
+  buf = rpmsg_port_get_tx_payload_buffer(rdev, &buflen, wait, priority);
   if (buf == NULL)
     {
       return RPMSG_ERR_NO_BUFF;
diff --git a/drivers/rpmsg/rpmsg_router_edge.c 
b/drivers/rpmsg/rpmsg_router_edge.c
index ddefcfd0d98..52c99f6e84d 100644
--- a/drivers/rpmsg/rpmsg_router_edge.c
+++ b/drivers/rpmsg/rpmsg_router_edge.c
@@ -110,7 +110,8 @@ static const struct rpmsg_ops_s g_rpmsg_router_edge_ops =
 
 static FAR void *
 rpmsg_router_edge_get_tx_payload_buffer(FAR struct rpmsg_device *rdev,
-                                        FAR uint32_t *len, int wait)
+                                        FAR uint32_t *len, int wait,
+                                        uint8_t priority)
 {
   FAR struct rpmsg_router_edge_s *edge = rpmsg_router_edge_from_rdev(rdev);
   FAR struct rpmsg_device *hubdev = edge->hubdev;
@@ -121,7 +122,7 @@ rpmsg_router_edge_get_tx_payload_buffer(FAR struct 
rpmsg_device *rdev,
       return NULL;
     }
 
-  buf = hubdev->ops.get_tx_payload_buffer(hubdev, len, wait);
+  buf = hubdev->ops.get_tx_payload_buffer(hubdev, len, wait, priority);
   *len = edge->tx_len;
   return buf;
 }
@@ -345,6 +346,7 @@ static void rpmsg_router_edge_release(FAR struct 
rpmsg_endpoint *ept)
  *   data - data to send
  *   len - data length
  *   wait - boolean, wait or not for buffer to become available
+ *   priority - message priority
  *
  * Returned Values:
  *   size of data sent or negative value for failure.
@@ -355,7 +357,7 @@ static int
 rpmsg_router_edge_send_offchannel_raw(FAR struct rpmsg_device *rdev,
                                       uint32_t src, uint32_t dst,
                                       FAR const void *data,
-                                      int len, int wait)
+                                      int len, int wait, uint8_t priority)
 {
   FAR struct rpmsg_router_edge_s *edge = rpmsg_router_edge_from_rdev(rdev);
   FAR struct rpmsg_ns_msg *ns_msg = (FAR struct rpmsg_ns_msg *)data;
@@ -375,7 +377,7 @@ rpmsg_router_edge_send_offchannel_raw(FAR struct 
rpmsg_device *rdev,
         }
 
       return hubdev->ops.send_offchannel_raw(hubdev, src,
-                                             dst, data, len, wait);
+                                             dst, data, len, wait, priority);
     }
 
   /* Try to get user ept firstly */
diff --git 
a/openamp/0018-lib-rpmsg-add-priority-support-for-rpmsg-endpoint.patch 
b/openamp/0018-lib-rpmsg-add-priority-support-for-rpmsg-endpoint.patch
index 36821bbc528..53f3e641fe2 100644
--- a/openamp/0018-lib-rpmsg-add-priority-support-for-rpmsg-endpoint.patch
+++ b/openamp/0018-lib-rpmsg-add-priority-support-for-rpmsg-endpoint.patch
@@ -1,26 +1,32 @@
-From 502673fc80f0cfc1454b4ea7f106ab667f337b81 Mon Sep 17 00:00:00 2001
+From 9f590ea6283f0aad4ac77d69f21f57f7f1dbc1e3 Mon Sep 17 00:00:00 2001
 From: Bowen Wang <[email protected]>
 Date: Wed, 28 Jan 2026 21:37:53 +0800
 Subject: [PATCH 18/18] lib/rpmsg: add priority support for rpmsg endpoint
 
-Add priority field to rpmsg_endpoint structure to support
-message prioritization. This allows different endpoints to
-have different priority levels for scheduling purposes.
+Add a priority to struct rpmsg_endpoint and pass it to the transport
+with every message, so a transport can order or schedule its TX traffic
+by endpoint:
 
-Changes:
-- Define priority constants (MIN=0, DEFAULT=127, MAX=255)
-- Add RPMSG_PRIO_RT alias for real-time priority
-- Add priority field to struct rpmsg_endpoint
-- Initialize priority to default value in rpmsg_register_endpoint()
+- define RPMSG_PRIO_MIN (0), RPMSG_PRIO_DEFAULT (127), RPMSG_PRIO_MAX
+  (255) and RPMSG_PRIO_RT as an alias of the maximum
+- add the priority field to struct rpmsg_endpoint, set to the default in
+  rpmsg_register_endpoint() when the caller left it at 0
+- add rpmsg_set_priority()
+- add a priority argument to the send_offchannel_raw and
+  get_tx_payload_buffer device ops; rpmsg_send_offchannel_raw() and
+  rpmsg_get_tx_payload_buffer() pass ept->priority, and rpmsg_virtio
+  accepts and ignores it
 
 Signed-off-by: Bowen Wang <[email protected]>
+Signed-off-by: Yongrong Wang <[email protected]>
 ---
- lib/include/openamp/rpmsg.h | 8 ++++++++
- lib/rpmsg/rpmsg.c           | 3 +++
- 2 files changed, 11 insertions(+)
+ lib/include/openamp/rpmsg.h | 27 +++++++++++++++++++++++++--
+ lib/rpmsg/rpmsg.c           | 18 ++++++++++++++++--
+ lib/rpmsg/rpmsg_virtio.c    | 12 ++++++++----
+ 3 files changed, 49 insertions(+), 8 deletions(-)
 
 diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
-index 5b702339aa..2d89084dc4 100644
+index 5b70233..e6409de 100644
 --- a/lib/include/openamp/rpmsg.h
 +++ open-amp/lib/include/openamp/rpmsg.h
 @@ -53,6 +53,11 @@ extern "C" {
@@ -45,11 +51,87 @@ index 5b702339aa..2d89084dc4 100644
        /** Endpoint node */
        struct metal_list node;
  
+@@ -114,7 +122,8 @@ struct rpmsg_device_ops {
+       /** Send RPMsg data */
+       int (*send_offchannel_raw)(struct rpmsg_device *rdev,
+                                  uint32_t src, uint32_t dst,
+-                                 const void *data, int len, int wait);
++                                 const void *data, int len, int wait,
++                                 uint8_t priority);
+ 
+       /** Hold RPMsg RX buffer */
+       void (*hold_rx_buffer)(struct rpmsg_device *rdev, void *rxbuf);
+@@ -124,7 +133,8 @@ struct rpmsg_device_ops {
+ 
+       /** Get RPMsg TX buffer */
+       void *(*get_tx_payload_buffer)(struct rpmsg_device *rdev,
+-                                     uint32_t *len, int wait);
++                                     uint32_t *len, int wait,
++                                     uint8_t priority);
+ 
+       /** Send RPMsg data without copy */
+       int (*send_offchannel_nocopy)(struct rpmsg_device *rdev,
+@@ -591,6 +601,19 @@ static inline int rpmsg_send_nocopy(struct rpmsg_endpoint 
*ept,
+       return RPMSG_ERR_ADDR;
+ }
+ 
++/**
++ * @brief Set the priority of the RPMsg endpoint
++ *
++ * The priority is passed to the transport with every message the endpoint
++ * sends, so a transport can order or schedule its TX traffic by it.
++ *
++ * @param ept         RPMsg endpoint pointer
++ * @param priority    Endpoint priority, RPMSG_PRIO_MIN to RPMSG_PRIO_MAX
++ *
++ * @return 0 on success, RPMSG_ERR_PARAM if ept is NULL
++ */
++int rpmsg_set_priority(struct rpmsg_endpoint *ept, uint8_t priority);
++
+ /**
+  * @brief Create rpmsg endpoint and register it to rpmsg device
+  *
 diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
-index 28a8de61b3..04953d19d1 100644
+index 28a8de6..feb69a4 100644
 --- a/lib/rpmsg/rpmsg.c
 +++ open-amp/lib/rpmsg/rpmsg.c
-@@ -318,6 +318,9 @@ void rpmsg_register_endpoint(struct rpmsg_device *rdev,
+@@ -130,7 +130,8 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, 
uint32_t src,
+ 
+       if (rdev->ops.send_offchannel_raw)
+               return rdev->ops.send_offchannel_raw(rdev, src, dst, data,
+-                                                   len, wait);
++                                                   len, wait,
++                                                   ept->priority);
+ 
+       return RPMSG_ERR_PARAM;
+ }
+@@ -204,7 +205,8 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint 
*ept,
+       rdev = ept->rdev;
+ 
+       if (rdev->ops.get_tx_payload_buffer)
+-              return rdev->ops.get_tx_payload_buffer(rdev, len, wait);
++              return rdev->ops.get_tx_payload_buffer(rdev, len, wait,
++                                                     ept->priority);
+ 
+       return NULL;
+ }
+@@ -286,6 +288,15 @@ struct rpmsg_endpoint *rpmsg_get_endpoint(struct 
rpmsg_device *rdev,
+       return NULL;
+ }
+ 
++int rpmsg_set_priority(struct rpmsg_endpoint *ept, uint8_t priority)
++{
++      if (!ept)
++              return RPMSG_ERR_PARAM;
++
++      ept->priority = priority;
++      return 0;
++}
++
+ static void rpmsg_unregister_endpoint(struct rpmsg_endpoint *ept)
+ {
+       struct rpmsg_device *rdev = ept->rdev;
+@@ -318,6 +329,9 @@ void rpmsg_register_endpoint(struct rpmsg_device *rdev,
        ept->ns_unbind_cb = ns_unbind_cb;
        ept->priv = priv;
        ept->rdev = rdev;
@@ -59,6 +141,50 @@ index 28a8de61b3..04953d19d1 100644
        metal_list_add_tail(&rdev->endpoints, &ept->node);
  }
  
+diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
+index 9913d87..758ab74 100644
+--- a/lib/rpmsg/rpmsg_virtio.c
++++ open-amp/lib/rpmsg/rpmsg_virtio.c
+@@ -354,7 +354,8 @@ static int rpmsg_virtio_notify_wait(struct 
rpmsg_virtio_device *rvdev, struct vi
+ }
+ 
+ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
+-                                              uint32_t *len, int wait)
++                                              uint32_t *len, int wait,
++                                              uint8_t priority)
+ {
+       struct rpmsg_virtio_device *rvdev;
+       struct rpmsg_hdr *rp_hdr;
+@@ -362,6 +363,8 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct 
rpmsg_device *rdev,
+       int tick_count;
+       int status;
+ 
++      metal_unused(priority);
++
+       /* Get the associated remote device for channel. */
+       rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
+ 
+@@ -500,8 +503,8 @@ static int rpmsg_virtio_release_tx_buffer(struct 
rpmsg_device *rdev, void *txbuf
+  */
+ static int rpmsg_virtio_send_offchannel_raw(struct rpmsg_device *rdev,
+                                           uint32_t src, uint32_t dst,
+-                                          const void *data,
+-                                          int len, int wait)
++                                          const void *data, int len,
++                                          int wait, uint8_t priority)
+ {
+       struct rpmsg_virtio_device *rvdev;
+       struct metal_io_region *io;
+@@ -513,7 +516,8 @@ static int rpmsg_virtio_send_offchannel_raw(struct 
rpmsg_device *rdev,
+       rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
+ 
+       /* Get the payload buffer. */
+-      buffer = rpmsg_virtio_get_tx_payload_buffer(rdev, &buff_len, wait);
++      buffer = rpmsg_virtio_get_tx_payload_buffer(rdev, &buff_len, wait,
++                                                  priority);
+       if (!buffer)
+               return RPMSG_ERR_NO_BUFF;
+ 
 -- 
 2.34.1
 

Reply via email to