Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/rpmsg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Returns 0 on success and an appropriate error value on failure.

struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rpdev,
void (*cb)(struct rpmsg_channel *, void *, int, void *, u32),
void *priv, u32 addr);
void *priv, struct rpmsg_channel_info chinfo);

every rpmsg address in the system is bound to an rx callback (so when
inbound messages arrive, they are dispatched by the rpmsg bus using the
Expand Down
79 changes: 3 additions & 76 deletions drivers/rpmsg/virtio_rpmsg_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <linux/virtio.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
#include <linux/virtio_rpmsg.h>
#include <linux/wait.h>
#include <uapi/linux/rpmsg.h>

#include "rpmsg_internal.h"

Expand Down Expand Up @@ -69,58 +71,6 @@ struct virtproc_info {
struct rpmsg_endpoint *ns_ept;
};

/* The feature bitmap for virtio rpmsg */
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */

/**
* struct rpmsg_hdr - common header for all rpmsg messages
* @src: source address
* @dst: destination address
* @reserved: reserved for future use
* @len: length of payload (in bytes)
* @flags: message flags
* @data: @len bytes of message payload data
*
* Every message sent(/received) on the rpmsg bus begins with this header.
*/
struct rpmsg_hdr {
u32 src;
u32 dst;
u32 reserved;
u16 len;
u16 flags;
u8 data[0];
} __packed;

/**
* struct rpmsg_ns_msg - dynamic name service announcement message
* @name: name of remote service that is published
* @addr: address of remote service that is published
* @flags: indicates whether service is created or destroyed
*
* This message is sent across to publish a new service, or announce
* about its removal. When we receive these messages, an appropriate
* rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
* or ->remove() handler of the appropriate rpmsg driver will be invoked
* (if/as-soon-as one is registered).
*/
struct rpmsg_ns_msg {
char name[RPMSG_NAME_SIZE];
u32 addr;
u32 flags;
} __packed;

/**
* enum rpmsg_ns_flags - dynamic name service announcement flags
*
* @RPMSG_NS_CREATE: a new remote service was just created
* @RPMSG_NS_DESTROY: a known remote service was just destroyed
*/
enum rpmsg_ns_flags {
RPMSG_NS_CREATE = 0,
RPMSG_NS_DESTROY = 1,
};

/**
* @vrp: the remote processor this channel belongs to
*/
Expand All @@ -133,37 +83,13 @@ struct virtio_rpmsg_channel {
#define to_virtio_rpmsg_channel(_rpdev) \
container_of(_rpdev, struct virtio_rpmsg_channel, rpdev)

/*
* We're allocating buffers of 512 bytes each for communications. The
* number of buffers will be computed from the number of buffers supported
* by the vring, upto a maximum of 512 buffers (256 in each direction).
*
* Each buffer will have 16 bytes for the msg header and 496 bytes for
* the payload.
*
* This will utilize a maximum total space of 256KB for the buffers.
*
* We might also want to add support for user-provided buffers in time.
* This will allow bigger buffer size flexibility, and can also be used
* to achieve zero-copy messaging.
*
* Note that these numbers are purely a decision of this driver - we
* can change this without changing anything in the firmware of the remote
* processor.
*/
#define MAX_RPMSG_NUM_BUFS (512)
#define MAX_RPMSG_BUF_SIZE (512)

/*
* Local addresses are dynamically allocated on-demand.
* We do not dynamically assign addresses from the low 1024 range,
* in order to reserve that address range for predefined services.
*/
#define RPMSG_RESERVED_ADDRESSES (1024)

/* Address 53 is reserved for advertising remote services */
#define RPMSG_NS_ADDR (53)

static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,
Expand Down Expand Up @@ -1023,6 +949,7 @@ static void rpmsg_remove(struct virtio_device *vdev)

static struct virtio_device_id id_table[] = {
{ VIRTIO_ID_RPMSG, VIRTIO_DEV_ANY_ID },
{ VIRTIO_ID_ADSP, VIRTIO_DEV_ANY_ID },
{ 0 },
};

Expand Down
17 changes: 17 additions & 0 deletions drivers/vhost/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ config VHOST_NET
To compile this driver as a module, choose M here: the module will
be called vhost_net.

config VHOST_RPMSG
tristate
depends on VHOST
---help---
Vhost RPMsg API allows vhost drivers to communicate with VirtIO
drivers, using the RPMsg over VirtIO protocol.

config VHOST_SCSI
tristate "VHOST_SCSI TCM fabric driver"
depends on TARGET_CORE && EVENTFD && VHOST_DPN
Expand All @@ -56,6 +63,16 @@ config VHOST_SCSI
Say M here to enable the vhost_scsi TCM fabric module
for use with virtio-scsi guests

config VHOST_SOF
tristate "Vhost SOF driver"
depends on SND_SOC_SOF
select VHOST
select VHOST_RPMSG
default n
---help---
SOF vhost VirtIO driver. It exports the same IPC interface, as the
one, used for Audio DSP communication, to Linux VirtIO guests.

config VHOST_VSOCK
tristate "vhost virtio-vsock driver"
depends on VSOCKETS && EVENTFD && VHOST_DPN
Expand Down
6 changes: 6 additions & 0 deletions drivers/vhost/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
obj-$(CONFIG_VHOST_NET) += vhost_net.o
vhost_net-y := net.o

obj-$(CONFIG_VHOST_RPMSG) += vhost_rpmsg.o
vhost_rpmsg-y := rpmsg.o

obj-$(CONFIG_VHOST_SCSI) += vhost_scsi.o
vhost_scsi-y := scsi.o

obj-$(CONFIG_VHOST_SOF) += vhost_sof.o
vhost_sof-y := adsp.o

obj-$(CONFIG_VHOST_VSOCK) += vhost_vsock.o
vhost_vsock-y := vsock.o

Expand Down
Loading