Commit ca8f4fb2 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by David S. Miller

skbuff: struct ubuf_info callback type safety

The skb struct ubuf_info callback gets passed struct ubuf_info
itself, not the arg value as the field name and the function signature
seem to imply. Rename the arg field to ctx to match usage,
add documentation and change the callback argument type
to make usage clear and to have compiler check correctness.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a5d2bd9
...@@ -238,7 +238,7 @@ static void handle_tx(struct vhost_net *net) ...@@ -238,7 +238,7 @@ static void handle_tx(struct vhost_net *net)
vq->heads[vq->upend_idx].len = len; vq->heads[vq->upend_idx].len = len;
ubuf->callback = vhost_zerocopy_callback; ubuf->callback = vhost_zerocopy_callback;
ubuf->arg = vq->ubufs; ubuf->ctx = vq->ubufs;
ubuf->desc = vq->upend_idx; ubuf->desc = vq->upend_idx;
msg.msg_control = ubuf; msg.msg_control = ubuf;
msg.msg_controllen = sizeof(ubuf); msg.msg_controllen = sizeof(ubuf);
......
...@@ -1598,10 +1598,9 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs) ...@@ -1598,10 +1598,9 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
kfree(ubufs); kfree(ubufs);
} }
void vhost_zerocopy_callback(void *arg) void vhost_zerocopy_callback(struct ubuf_info *ubuf)
{ {
struct ubuf_info *ubuf = arg; struct vhost_ubuf_ref *ubufs = ubuf->ctx;
struct vhost_ubuf_ref *ubufs = ubuf->arg;
struct vhost_virtqueue *vq = ubufs->vq; struct vhost_virtqueue *vq = ubufs->vq;
/* set len = 1 to mark this desc buffers done DMA */ /* set len = 1 to mark this desc buffers done DMA */
......
...@@ -188,7 +188,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *); ...@@ -188,7 +188,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
unsigned int log_num, u64 len); unsigned int log_num, u64 len);
void vhost_zerocopy_callback(void *arg); void vhost_zerocopy_callback(struct ubuf_info *);
int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq); int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq);
#define vq_err(vq, fmt, ...) do { \ #define vq_err(vq, fmt, ...) do { \
......
...@@ -238,11 +238,12 @@ enum { ...@@ -238,11 +238,12 @@ enum {
/* /*
* The callback notifies userspace to release buffers when skb DMA is done in * The callback notifies userspace to release buffers when skb DMA is done in
* lower device, the skb last reference should be 0 when calling this. * lower device, the skb last reference should be 0 when calling this.
* The desc is used to track userspace buffer index. * The ctx field is used to track device context.
* The desc field is used to track userspace buffer index.
*/ */
struct ubuf_info { struct ubuf_info {
void (*callback)(void *); void (*callback)(struct ubuf_info *);
void *arg; void *ctx;
unsigned long desc; unsigned long desc;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment