Message ID | 20240517144607.2595798-4-niuxuewei.nxw@antgroup.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vsock/virtio: Add support for multi-devices | expand |
On Fri, May 17, 2024 at 10:46:05PM GMT, Xuewei Niu wrote: >Adds a new argument, named "cid", to let them know which `virtio_vsock` to >be selected. > >Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com> >--- > include/linux/virtio_vsock.h | 2 +- > net/vmw_vsock/virtio_transport.c | 5 ++--- > net/vmw_vsock/virtio_transport_common.c | 6 +++--- > 3 files changed, 6 insertions(+), 7 deletions(-) Every commit in linux must be working to support bisection. So these changes should be made before adding multi-device support. > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index c82089dee0c8..21bfd5e0c2e7 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -168,7 +168,7 @@ struct virtio_transport { > * extra checks and can perform zerocopy transmission by > * default. > */ >- bool (*can_msgzerocopy)(int bufs_num); >+ bool (*can_msgzerocopy)(u32 cid, int bufs_num); > }; > > ssize_t >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index 93d25aeafb83..998b22e5ce36 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -521,14 +521,13 @@ static void virtio_vsock_rx_done(struct virtqueue *vq) > queue_work(virtio_vsock_workqueue, &vsock->rx_work); > } > >-static bool virtio_transport_can_msgzerocopy(int bufs_num) >+static bool virtio_transport_can_msgzerocopy(u32 cid, int bufs_num) > { > struct virtio_vsock *vsock; > bool res = false; > > rcu_read_lock(); >- >- vsock = rcu_dereference(the_virtio_vsock); >+ vsock = virtio_transport_get_virtio_vsock(cid); > if (vsock) { > struct virtqueue *vq = vsock->vqs[VSOCK_VQ_TX]; > >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index bed75a41419e..e7315d7b9af1 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -39,7 +39,7 @@ virtio_transport_get_ops(struct vsock_sock *vsk) > > static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, > struct virtio_vsock_pkt_info *info, >- size_t pkt_len) >+ size_t pkt_len, unsigned int cid) > { > struct iov_iter *iov_iter; > >@@ -62,7 +62,7 @@ static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, > int pages_to_send = iov_iter_npages(iov_iter, MAX_SKB_FRAGS); > > /* +1 is for packet header. */ >- return t_ops->can_msgzerocopy(pages_to_send + 1); >+ return t_ops->can_msgzerocopy(cid, pages_to_send + 1); > } > > return true; >@@ -375,7 +375,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, > info->msg->msg_flags &= ~MSG_ZEROCOPY; > > if (info->msg->msg_flags & MSG_ZEROCOPY) >- can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len); >+ can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len, src_cid); > > if (can_zcopy) > max_skb_len = min_t(u32, VIRTIO_VSOCK_MAX_PKT_BUF_SIZE, >-- >2.34.1 >
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h index c82089dee0c8..21bfd5e0c2e7 100644 --- a/include/linux/virtio_vsock.h +++ b/include/linux/virtio_vsock.h @@ -168,7 +168,7 @@ struct virtio_transport { * extra checks and can perform zerocopy transmission by * default. */ - bool (*can_msgzerocopy)(int bufs_num); + bool (*can_msgzerocopy)(u32 cid, int bufs_num); }; ssize_t diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 93d25aeafb83..998b22e5ce36 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -521,14 +521,13 @@ static void virtio_vsock_rx_done(struct virtqueue *vq) queue_work(virtio_vsock_workqueue, &vsock->rx_work); } -static bool virtio_transport_can_msgzerocopy(int bufs_num) +static bool virtio_transport_can_msgzerocopy(u32 cid, int bufs_num) { struct virtio_vsock *vsock; bool res = false; rcu_read_lock(); - - vsock = rcu_dereference(the_virtio_vsock); + vsock = virtio_transport_get_virtio_vsock(cid); if (vsock) { struct virtqueue *vq = vsock->vqs[VSOCK_VQ_TX]; diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index bed75a41419e..e7315d7b9af1 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -39,7 +39,7 @@ virtio_transport_get_ops(struct vsock_sock *vsk) static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, struct virtio_vsock_pkt_info *info, - size_t pkt_len) + size_t pkt_len, unsigned int cid) { struct iov_iter *iov_iter; @@ -62,7 +62,7 @@ static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, int pages_to_send = iov_iter_npages(iov_iter, MAX_SKB_FRAGS); /* +1 is for packet header. */ - return t_ops->can_msgzerocopy(pages_to_send + 1); + return t_ops->can_msgzerocopy(cid, pages_to_send + 1); } return true; @@ -375,7 +375,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, info->msg->msg_flags &= ~MSG_ZEROCOPY; if (info->msg->msg_flags & MSG_ZEROCOPY) - can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len); + can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len, src_cid); if (can_zcopy) max_skb_len = min_t(u32, VIRTIO_VSOCK_MAX_PKT_BUF_SIZE,
Adds a new argument, named "cid", to let them know which `virtio_vsock` to be selected. Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com> --- include/linux/virtio_vsock.h | 2 +- net/vmw_vsock/virtio_transport.c | 5 ++--- net/vmw_vsock/virtio_transport_common.c | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-)