12 #ifndef _RPMSG_VIRTIO_H_
13 #define _RPMSG_VIRTIO_H_
16 #include <metal/mutex.h>
17 #include <metal/cache.h>
21 #if defined __cplusplus
26 #ifndef RPMSG_BUFFER_SIZE
27 #define RPMSG_BUFFER_SIZE (512)
31 #define VIRTIO_RPMSG_F_NS 0
33 #if defined(VIRTIO_USE_DCACHE)
34 #define BUFFER_FLUSH(x, s) metal_cache_flush(x, s)
35 #define BUFFER_INVALIDATE(x, s) metal_cache_invalidate(x, s)
37 #define BUFFER_FLUSH(x, s) do { } while (0)
38 #define BUFFER_INVALIDATE(x, s) do { } while (0)
109 #define RPMSG_REMOTE VIRTIO_DEV_DEVICE
110 #define RPMSG_HOST VIRTIO_DEV_DRIVER
131 static inline unsigned int
177 static inline uint32_t
196 uint32_t offset,
void *dst,
int length)
216 uint32_t offset,
void *src,
int length)
237 int flags,
unsigned int nvqs,
318 struct metal_io_region *shm_io,
356 struct metal_io_region *shm_io,
380 void *shbuf,
size_t size);
415 #if defined __cplusplus
void(* rpmsg_ns_bind_cb)(struct rpmsg_device *rdev, const char *name, uint32_t dest)
Definition: rpmsg.h:56
static __deprecated void rpmsg_virtio_write_config(struct rpmsg_virtio_device *rvdev, uint32_t offset, void *src, int length)
Write configuration data to the rpmsg virtio device.
Definition: rpmsg_virtio.h:215
static __deprecated uint8_t rpmsg_virtio_get_status(struct rpmsg_virtio_device *rvdev)
Retrieve rpmsg virtio device status.
Definition: rpmsg_virtio.h:162
int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, struct virtio_device *vdev, rpmsg_ns_bind_cb ns_bind_cb, struct metal_io_region *shm_io, struct rpmsg_virtio_shm_pool *shpool, const struct rpmsg_virtio_config *config)
Initialize rpmsg virtio device with config.
Definition: rpmsg_virtio.c:788
metal_weak void * rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool, size_t size)
Get buffer in the shared memory pool.
static __deprecated int rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev, int flags, unsigned int nvqs, const char *names[], vq_callback *callbacks)
Create the rpmsg virtio device virtqueue.
Definition: rpmsg_virtio.h:236
static struct rpmsg_device * rpmsg_virtio_get_rpmsg_device(struct rpmsg_virtio_device *rvdev)
Get RPMsg device from RPMsg virtio device.
Definition: rpmsg_virtio.h:390
static void rpmsg_virtio_set_wait_cb(struct rpmsg_virtio_device *rvdev, rpmsg_virtio_notify_wait_cb notify_wait_cb)
Set the virtio callback to manage the wait for TX buffer availability.
Definition: rpmsg_virtio.h:118
static __deprecated void rpmsg_virtio_delete_virtqueues(struct rpmsg_virtio_device *rvdev)
Delete the virtqueues created in rpmsg_virtio_create_virtqueues()
Definition: rpmsg_virtio.h:254
static unsigned int rpmsg_virtio_get_role(struct rpmsg_virtio_device *rvdev)
Get rpmsg virtio device role.
Definition: rpmsg_virtio.h:132
int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio buffer size.
Definition: rpmsg_virtio.c:706
static __deprecated void rpmsg_virtio_read_config(struct rpmsg_virtio_device *rvdev, uint32_t offset, void *dst, int length)
Retrieve configuration data from the rpmsg virtio device.
Definition: rpmsg_virtio.h:195
int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio Rx buffer size.
Definition: rpmsg_virtio.c:742
static __deprecated void rpmsg_virtio_set_status(struct rpmsg_virtio_device *rvdev, uint8_t status)
Set rpmsg virtio device status.
Definition: rpmsg_virtio.h:146
static __deprecated uint32_t rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
Get the rpmsg virtio device features.
Definition: rpmsg_virtio.h:178
void rpmsg_virtio_init_shm_pool(struct rpmsg_virtio_shm_pool *shpool, void *shbuf, size_t size)
Initialize default shared buffers pool.
Definition: rpmsg_virtio.c:89
void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev)
Deinitialize rpmsg virtio device.
Definition: rpmsg_virtio.c:960
static int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio Tx buffer size.
Definition: rpmsg_virtio.h:287
int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, struct virtio_device *vdev, rpmsg_ns_bind_cb ns_bind_cb, struct metal_io_region *shm_io, struct rpmsg_virtio_shm_pool *shpool)
Initialize rpmsg virtio device.
Definition: rpmsg_virtio.c:778
int(* rpmsg_virtio_notify_wait_cb)(struct rpmsg_device *rdev, uint32_t id)
Definition: rpmsg_virtio.h:42
Representation of a RPMsg device.
Definition: rpmsg.h:133
Configuration of RPMsg device based on virtio.
Definition: rpmsg_virtio.h:62
bool split_shpool
The flag for splitting shared memory pool to TX and RX.
Definition: rpmsg_virtio.h:70
uint32_t h2r_buf_size
The size of the buffer used to send data from host to remote.
Definition: rpmsg_virtio.h:64
uint32_t r2h_buf_size
The size of the buffer used to send data from remote to host.
Definition: rpmsg_virtio.h:67
Representation of a RPMsg device based on virtio.
Definition: rpmsg_virtio.h:74
struct virtio_device * vdev
Pointer to the virtio device.
Definition: rpmsg_virtio.h:82
rpmsg_virtio_notify_wait_cb notify_wait_cb
Callback handler for rpmsg virtio service, called when service can't get tx buffer.
Definition: rpmsg_virtio.h:106
struct metal_io_region * shbuf_io
Pointer to the shared buffer I/O region.
Definition: rpmsg_virtio.h:91
struct rpmsg_virtio_shm_pool * shpool
Pointer to the shared buffers pool.
Definition: rpmsg_virtio.h:94
struct virtqueue * rvq
Pointer to receive virtqueue.
Definition: rpmsg_virtio.h:85
struct virtqueue * svq
Pointer to send virtqueue.
Definition: rpmsg_virtio.h:88
struct rpmsg_device rdev
RPMsg device.
Definition: rpmsg_virtio.h:76
struct rpmsg_virtio_config config
Structure containing virtio configuration.
Definition: rpmsg_virtio.h:79
struct metal_list reclaimer
RPMsg buffer reclaimer that contains buffers released by the rpmsg_virtio_release_tx_buffer function.
Definition: rpmsg_virtio.h:100
Shared memory pool used for RPMsg buffers.
Definition: rpmsg_virtio.h:45
size_t size
Total pool size.
Definition: rpmsg_virtio.h:53
size_t avail
Available memory size.
Definition: rpmsg_virtio.h:50
void * base
Base address of the memory pool.
Definition: rpmsg_virtio.h:47
Structure definition for virtio devices for use by the applications/drivers.
Definition: virtio.h:188
unsigned int role
If it is virtio backend or front end.
Definition: virtio.h:199
const struct virtio_dispatch * func
Virtio dispatch table.
Definition: virtio.h:205
void(* read_config)(struct virtio_device *dev, uint32_t offset, void *dst, int length)
Read a variable amount from the device specific (ie, network) configuration region.
Definition: virtio.h:265
uint8_t(* get_status)(struct virtio_device *dev)
Get the status of the virtio device.
Definition: virtio.h:243
uint32_t(* get_features)(struct virtio_device *dev)
Get the feature exposed by the virtio device.
Definition: virtio.h:249
void(* set_status)(struct virtio_device *dev, uint8_t status)
Set the status of the virtio device.
Definition: virtio.h:246
void(* write_config)(struct virtio_device *dev, uint32_t offset, void *src, int length)
Write a variable amount from the device specific (ie, network) configuration region.
Definition: virtio.h:272
Local virtio queue to manage a virtio ring for sending or receiving.
Definition: virtqueue.h:78
static void virtio_delete_virtqueues(struct virtio_device *vdev)
Delete the virtio device virtqueue.
Definition: virtio.h:312
int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags, unsigned int nvqs, const char *names[], vq_callback callbacks[], void *callback_args[])
Create the virtio device virtqueue.
Definition: virtio.c:53
void(* vq_callback)(struct virtqueue *)
Definition: virtqueue.h:154