Skip to content

Commit

Permalink
rpmsg: Add API for retrieving message buffer sizes
Browse files Browse the repository at this point in the history
Add an RPMsg API to get the buffer sizes supported by the backing
transport layer. Add hooks so that transport layers can register
functions to provide this data.

Signed-off-by: Andrew Davis <[email protected]>
  • Loading branch information
glneo committed Mar 15, 2024
1 parent 79b795e commit 78e7e58
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ struct rpmsg_device_ops {

/** Release RPMsg TX buffer */
int (*release_tx_buffer)(struct rpmsg_device *rdev, void *txbuf);

/** Get RPMsg RX buffer size */
int (*get_rx_buffer_size)(struct rpmsg_device *rdev);

/** Get RPMsg TX buffer size */
int (*get_tx_buffer_size)(struct rpmsg_device *rdev);
};

/** @brief Representation of a RPMsg device */
Expand Down Expand Up @@ -404,6 +410,24 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
*/
int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf);

/**
* @brief Get RPMsg Tx buffer size
*
* @param ept The rpmsg endpoint
*
* @return Next available Tx buffer size, 0 for failure
*/
int rpmsg_get_tx_buffer_size(struct rpmsg_endpoint *ept);

/**
* @brief Get RPMsg Rx buffer size
*
* @param ept The rpmsg endpoint
*
* @return Next available Rx buffer size, 0 for failure
*/
int rpmsg_get_rx_buffer_size(struct rpmsg_endpoint *ept);

/**
* @brief Send a message in tx buffer reserved by
* rpmsg_get_tx_payload_buffer() across to the remote processor.
Expand Down
30 changes: 30 additions & 0 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,36 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
return NULL;
}

int rpmsg_get_tx_buffer_size(struct rpmsg_endpoint *ept)
{
struct rpmsg_device *rdev;

if (!ept || !ept->rdev)
return 0;

rdev = ept->rdev;

if (rdev->ops.get_tx_buffer_size)
return rdev->ops.get_tx_buffer_size(rdev);

return 0;
}

int rpmsg_get_rx_buffer_size(struct rpmsg_endpoint *ept)
{
struct rpmsg_device *rdev;

if (!ept || !ept->rdev)
return 0;

rdev = ept->rdev;

if (rdev->ops.get_rx_buffer_size)
return rdev->ops.get_rx_buffer_size(rdev);

return 0;
}

int rpmsg_send_offchannel_nocopy(struct rpmsg_endpoint *ept, uint32_t src,
uint32_t dst, const void *data, int len)
{
Expand Down

0 comments on commit 78e7e58

Please sign in to comment.