forked from nuttx/nuttx-update
rpmsg_port:add rpmsg_port_queue_nused api
Add nused api for lower layer to get the used buffer number Signed-off-by: liaoao <liaoao@xiaomi.com>
This commit is contained in:
parent
6d604ec487
commit
3d6abb1d86
2 changed files with 36 additions and 14 deletions
|
@ -27,7 +27,6 @@
|
|||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <metal/atomic.h>
|
||||
#include <metal/mutex.h>
|
||||
|
||||
#include <rpmsg/rpmsg_internal.h>
|
||||
|
@ -282,7 +281,7 @@ static int rpmsg_port_send_offchannel_nocopy(FAR struct rpmsg_device *rdev,
|
|||
sizeof(struct rpmsg_hdr) + len;
|
||||
|
||||
rpmsg_port_queue_add_buffer(&port->txq, hdr);
|
||||
port->ops->kick(port);
|
||||
port->ops->notify_tx_ready(port);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -341,6 +340,7 @@ static void rpmsg_port_release_rx_buffer(FAR struct rpmsg_device *rdev,
|
|||
if ((reserved & RPMSG_BUF_HELD_MASK) == (1 << RPMSG_BUF_HELD_SHIFT))
|
||||
{
|
||||
rpmsg_port_queue_return_buffer(&port->rxq, hdr);
|
||||
port->ops->notify_rx_free(port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,15 +699,6 @@ void rpmsg_port_queue_add_buffer(FAR struct rpmsg_port_queue_s *queue,
|
|||
rpmsg_port_post(&queue->ready.sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_queue_navail
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t rpmsg_port_queue_navail(FAR struct rpmsg_port_queue_s *queue)
|
||||
{
|
||||
return atomic_load(&queue->free.num);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_register
|
||||
****************************************************************************/
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <metal/atomic.h>
|
||||
|
||||
#include <nuttx/list.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
|
@ -90,9 +93,13 @@ typedef void (*rpmsg_port_rx_cb_t)(FAR struct rpmsg_port_s *port,
|
|||
|
||||
struct rpmsg_port_ops_s
|
||||
{
|
||||
/* Kick driver there is buffer to be sent of the tx queue */
|
||||
/* Notify driver there is buffer to be sent of the tx queue */
|
||||
|
||||
CODE void (*kick)(FAR struct rpmsg_port_s *port);
|
||||
CODE void (*notify_tx_ready)(FAR struct rpmsg_port_s *port);
|
||||
|
||||
/* Notify driver there is a buffer in rx queue is freed */
|
||||
|
||||
CODE void (*notify_rx_free)(FAR struct rpmsg_port_s *port);
|
||||
|
||||
/* Register callback function which should be invoked when there is
|
||||
* date received to the rx queue by driver
|
||||
|
@ -224,7 +231,31 @@ void rpmsg_port_queue_add_buffer(FAR struct rpmsg_port_queue_s *queue,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t rpmsg_port_queue_navail(FAR struct rpmsg_port_queue_s *queue);
|
||||
static inline_function
|
||||
uint32_t rpmsg_port_queue_navail(FAR struct rpmsg_port_queue_s *queue)
|
||||
{
|
||||
return atomic_load(&queue->free.num);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_queue_nused
|
||||
*
|
||||
* Description:
|
||||
* Get used buffer number of ready list of the queue.
|
||||
*
|
||||
* Input Parameters:
|
||||
* queue - The queue is to be calculated.
|
||||
*
|
||||
* Returned Value:
|
||||
* Number of used buffers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline_function
|
||||
uint32_t rpmsg_port_queue_nused(FAR struct rpmsg_port_queue_s *queue)
|
||||
{
|
||||
return atomic_load(&queue->ready.num);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_initialize
|
||||
|
|
Loading…
Reference in a new issue