···296296}297297298298/**299299- * virtqueue_add_buf - expose buffer to other end300300- * @vq: the struct virtqueue we're talking about.301301- * @sg: the description of the buffer(s).302302- * @out_num: the number of sg readable by other side303303- * @in_num: the number of sg which are writable (after readable ones)304304- * @data: the token identifying the buffer.305305- * @gfp: how to do memory allocations (if necessary).306306- *307307- * Caller must ensure we don't call this with other virtqueue operations308308- * at the same time (except where noted).309309- *310310- * Returns zero or a negative error (ie. ENOSPC, ENOMEM).311311- */312312-int virtqueue_add_buf(struct virtqueue *_vq,313313- struct scatterlist sg[],314314- unsigned int out,315315- unsigned int in,316316- void *data,317317- gfp_t gfp)318318-{319319- struct scatterlist *sgs[2];320320-321321- sgs[0] = sg;322322- sgs[1] = sg + out;323323-324324- return virtqueue_add(_vq, sgs, sg_next_arr,325325- out, in, out ? 1 : 0, in ? 1 : 0, data, gfp);326326-}327327-EXPORT_SYMBOL_GPL(virtqueue_add_buf);328328-329329-/**330299 * virtqueue_add_sgs - expose buffers to other end331300 * @vq: the struct virtqueue we're talking about.332301 * @sgs: array of terminated scatterlists.···442473 * virtqueue_kick - update after add_buf443474 * @vq: the struct virtqueue444475 *445445- * After one or more virtqueue_add_buf calls, invoke this to kick476476+ * After one or more virtqueue_add_* calls, invoke this to kick446477 * the other side.447478 *448479 * Caller must ensure we don't call this with other virtqueue···499530 * operations at the same time (except where noted).500531 *501532 * Returns NULL if there are no used buffers, or the "data" token502502- * handed to virtqueue_add_buf().533533+ * handed to virtqueue_add_*().503534 */504535void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)505536{···654685 * virtqueue_detach_unused_buf - detach first unused buffer655686 * @vq: the struct virtqueue we're talking about.656687 *657657- * Returns NULL or the "data" token handed to virtqueue_add_buf().688688+ * Returns NULL or the "data" token handed to virtqueue_add_*().658689 * This is not valid on an active queue; it is useful only for device659690 * shutdown.660691 */
-7
include/linux/virtio.h
···3434 void *priv;3535};36363737-int virtqueue_add_buf(struct virtqueue *vq,3838- struct scatterlist sg[],3939- unsigned int out_num,4040- unsigned int in_num,4141- void *data,4242- gfp_t gfp);4343-4437int virtqueue_add_outbuf(struct virtqueue *vq,4538 struct scatterlist sg[], unsigned int num,4639 void *data,