Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef LINUX_VIRTIO_H
0003 #define LINUX_VIRTIO_H
0004 #include <linux/scatterlist.h>
0005 #include <linux/kernel.h>
0006 #include <linux/spinlock.h>
0007 
0008 struct device {
0009     void *parent;
0010 };
0011 
0012 struct virtio_device {
0013     struct device dev;
0014     u64 features;
0015     struct list_head vqs;
0016     spinlock_t vqs_list_lock;
0017     const struct virtio_config_ops *config;
0018 };
0019 
0020 struct virtqueue {
0021     struct list_head list;
0022     void (*callback)(struct virtqueue *vq);
0023     const char *name;
0024     struct virtio_device *vdev;
0025         unsigned int index;
0026         unsigned int num_free;
0027     unsigned int num_max;
0028     void *priv;
0029     bool reset;
0030 };
0031 
0032 /* Interfaces exported by virtio_ring. */
0033 int virtqueue_add_sgs(struct virtqueue *vq,
0034               struct scatterlist *sgs[],
0035               unsigned int out_sgs,
0036               unsigned int in_sgs,
0037               void *data,
0038               gfp_t gfp);
0039 
0040 int virtqueue_add_outbuf(struct virtqueue *vq,
0041              struct scatterlist sg[], unsigned int num,
0042              void *data,
0043              gfp_t gfp);
0044 
0045 int virtqueue_add_inbuf(struct virtqueue *vq,
0046             struct scatterlist sg[], unsigned int num,
0047             void *data,
0048             gfp_t gfp);
0049 
0050 bool virtqueue_kick(struct virtqueue *vq);
0051 
0052 void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
0053 
0054 void virtqueue_disable_cb(struct virtqueue *vq);
0055 
0056 bool virtqueue_enable_cb(struct virtqueue *vq);
0057 bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
0058 
0059 void *virtqueue_detach_unused_buf(struct virtqueue *vq);
0060 struct virtqueue *vring_new_virtqueue(unsigned int index,
0061                       unsigned int num,
0062                       unsigned int vring_align,
0063                       struct virtio_device *vdev,
0064                       bool weak_barriers,
0065                       bool ctx,
0066                       void *pages,
0067                       bool (*notify)(struct virtqueue *vq),
0068                       void (*callback)(struct virtqueue *vq),
0069                       const char *name);
0070 void vring_del_virtqueue(struct virtqueue *vq);
0071 
0072 #endif