search for: skb_to_sgvec

Displaying 20 results from an estimated 144 matches for "skb_to_sgvec".

2014 Sep 05
2
[PATCH 1/3] virtio_net: pass well-formed sgs to virtqueue_add_*()
Il 03/09/2014 06:29, Rusty Russell ha scritto: > + sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); I think 2 is enough here. That said... > sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr); > - > skb_to_sgvec(skb, rq->sg + 1, 0, skb->len); > > err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp); ... skb_to_sgvec will already make the sg well formed, so the sg_init_table is _almost_ redundant; it is only there to remove intermediate end marks. The block layer takes care to remo...
2014 Sep 05
2
[PATCH 1/3] virtio_net: pass well-formed sgs to virtqueue_add_*()
Il 03/09/2014 06:29, Rusty Russell ha scritto: > + sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); I think 2 is enough here. That said... > sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr); > - > skb_to_sgvec(skb, rq->sg + 1, 0, skb->len); > > err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp); ... skb_to_sgvec will already make the sg well formed, so the sg_init_table is _almost_ redundant; it is only there to remove intermediate end marks. The block layer takes care to remo...
2014 Sep 07
0
[PATCH 1/3] virtio_net: pass well-formed sgs to virtqueue_add_*()
...:40:50PM +0200, Paolo Bonzini wrote: > Il 03/09/2014 06:29, Rusty Russell ha scritto: > > + sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); > > I think 2 is enough here. That said... > > > sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr); > > - > > skb_to_sgvec(skb, rq->sg + 1, 0, skb->len); > > > > err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp); > > ... skb_to_sgvec will already make the sg well formed, so the > sg_init_table is _almost_ redundant; it is only there to remove > intermediate end marks. The...
2015 Aug 05
4
[PATCH net V2] virtio-net: drop NETIF_F_FRAGLIST
virtio declares support for NETIF_F_FRAGLIST, but assumes that there are at most MAX_SKB_FRAGS + 2 fragments which isn't always true with a fraglist. A longer fraglist in the skb will make the call to skb_to_sgvec overflow the sg array, leading to memory corruption. Drop NETIF_F_FRAGLIST so we only get what we can handle. Cc: Michael S. Tsirkin <mst at redhat.com> Signed-off-by: Jason Wang <jasowang at redhat.com> --- - Change from V1: coding style fixes. - The patch is needed for stable. ---...
2015 Aug 05
4
[PATCH net V2] virtio-net: drop NETIF_F_FRAGLIST
virtio declares support for NETIF_F_FRAGLIST, but assumes that there are at most MAX_SKB_FRAGS + 2 fragments which isn't always true with a fraglist. A longer fraglist in the skb will make the call to skb_to_sgvec overflow the sg array, leading to memory corruption. Drop NETIF_F_FRAGLIST so we only get what we can handle. Cc: Michael S. Tsirkin <mst at redhat.com> Signed-off-by: Jason Wang <jasowang at redhat.com> --- - Change from V1: coding style fixes. - The patch is needed for stable. ---...
2013 Jun 06
4
[PATCH] virtio-net: put virtio net header inline with data
...0; } - hdr->mhdr.num_buffers = 0; - - /* Encode metadata header at front. */ if (vi->mergeable_rx_bufs) - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); - else - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); + hdr->mhdr.num_buffers = 0; - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_...
2013 Jun 06
4
[PATCH] virtio-net: put virtio net header inline with data
...0; } - hdr->mhdr.num_buffers = 0; - - /* Encode metadata header at front. */ if (vi->mergeable_rx_bufs) - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); - else - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); + hdr->mhdr.num_buffers = 0; - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_...
2015 Aug 04
3
[PATCH net] virtio-net: drop NETIF_F_FRAGLIST
virtio declares support for NETIF_F_FRAGLIST, but assumes that there are at most MAX_SKB_FRAGS + 2 fragments which isn't always true with a fraglist. A longer fraglist in the skb will make the call to skb_to_sgvec overflow the sg array, leading to memory corruption. Drop NETIF_F_FRAGLIST so we only get what we can handle. Cc: Michael S. Tsirkin <mst at redhat.com> Signed-off-by: Jason Wang <jasowang at redhat.com> --- The patch is needed for stable. --- drivers/net/virtio_net.c | 4 ++-- 1 fil...
2015 Aug 04
3
[PATCH net] virtio-net: drop NETIF_F_FRAGLIST
virtio declares support for NETIF_F_FRAGLIST, but assumes that there are at most MAX_SKB_FRAGS + 2 fragments which isn't always true with a fraglist. A longer fraglist in the skb will make the call to skb_to_sgvec overflow the sg array, leading to memory corruption. Drop NETIF_F_FRAGLIST so we only get what we can handle. Cc: Michael S. Tsirkin <mst at redhat.com> Signed-off-by: Jason Wang <jasowang at redhat.com> --- The patch is needed for stable. --- drivers/net/virtio_net.c | 4 ++-- 1 fil...
2007 Jul 24
0
[PATCH] virtio_net.c gso & feature support
...c void try_fill_recv(struct virtnet_info *vi) { struct sk_buff *skb; - struct scatterlist sg[MAX_SKB_FRAGS]; + struct scatterlist sg[1+MAX_SKB_FRAGS]; int num, err; for (;;) { @@ -81,7 +153,8 @@ static void try_fill_recv(struct virtnet break; skb_put(skb, MAX_PACKET_LEN); - num = skb_to_sgvec(skb, sg, 0, skb->len); + vnet_hdr_to_sg(sg, skb); + num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; skb_queue_head(&vi->recv, skb); err = vi->vq_recv->ops->add_buf(vi->vq_recv, sg, 0, num, skb); @@ -161,7 +234,8 @@ static int start_xmit(struct sk_buff *sk { str...
2007 Jul 24
0
[PATCH] virtio_net.c gso & feature support
...c void try_fill_recv(struct virtnet_info *vi) { struct sk_buff *skb; - struct scatterlist sg[MAX_SKB_FRAGS]; + struct scatterlist sg[1+MAX_SKB_FRAGS]; int num, err; for (;;) { @@ -81,7 +153,8 @@ static void try_fill_recv(struct virtnet break; skb_put(skb, MAX_PACKET_LEN); - num = skb_to_sgvec(skb, sg, 0, skb->len); + vnet_hdr_to_sg(sg, skb); + num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; skb_queue_head(&vi->recv, skb); err = vi->vq_recv->ops->add_buf(vi->vq_recv, sg, 0, num, skb); @@ -161,7 +234,8 @@ static int start_xmit(struct sk_buff *sk { str...
2013 Jul 15
0
[PATCH] virtio-net: put virtio net header inline with data
...0; } - hdr->mhdr.num_buffers = 0; - - /* Encode metadata header at front. */ if (vi->mergeable_rx_bufs) - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); - else - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); + hdr->mhdr.num_buffers = 0; - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_...
2013 Jul 10
2
[PATCH] virtio-net: put virtio net header inline with data
From: Rusty Russell <rusty at rustcorp.com.au> Date: Tue, 09 Jul 2013 17:38:51 +0930 > If you convince DaveM, I won't object :) Simplifications are great, but not when the merge window opens up. Sorry, this isn't appropriate now.
2013 Jul 10
2
[PATCH] virtio-net: put virtio net header inline with data
From: Rusty Russell <rusty at rustcorp.com.au> Date: Tue, 09 Jul 2013 17:38:51 +0930 > If you convince DaveM, I won't object :) Simplifications are great, but not when the merge window opens up. Sorry, this isn't appropriate now.
2013 Jun 07
0
[PATCH] virtio-net: put virtio net header inline with data
...; - > - /* Encode metadata header at front. */ > if (vi->mergeable_rx_bufs) > - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); > - else > - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); > + hdr->mhdr.num_buffers = 0; > > - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; > + if (can_push) { > + __skb_push(skb, hdr_len); > + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); > + /* Pull header back to avoid skew in tx bytes calculations. */ > + __skb_pull(skb, hdr_len); > + } else { > + sg_set_bu...
2014 Sep 03
0
[PATCH 1/3] virtio_net: pass well-formed sgs to virtqueue_add_*()
..._net.c +++ b/drivers/net/virtio_net.c @@ -546,8 +546,8 @@ static int add_recvbuf_small(struct receive_queue *rq, gfp_t gfp) skb_put(skb, GOOD_PACKET_LEN); hdr = skb_vnet_hdr(skb); + sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); sg_set_buf(rq->sg, &hdr->hdr, sizeof hdr->hdr); - skb_to_sgvec(skb, rq->sg + 1, 0, skb->len); err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp); @@ -563,6 +563,8 @@ static int add_recvbuf_big(struct receive_queue *rq, gfp_t gfp) char *p; int i, err, offset; + sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); + /* page in rq->sg[MAX_S...
2013 Jul 08
3
[PATCH] virtio-net: put virtio net header inline with data
...0; } - hdr->mhdr.num_buffers = 0; - - /* Encode metadata header at front. */ if (vi->mergeable_rx_bufs) - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); - else - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); + hdr->mhdr.num_buffers = 0; - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_...
2013 Jul 08
3
[PATCH] virtio-net: put virtio net header inline with data
...0; } - hdr->mhdr.num_buffers = 0; - - /* Encode metadata header at front. */ if (vi->mergeable_rx_bufs) - sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr); - else - sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr); + hdr->mhdr.num_buffers = 0; - num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_...
2012 Sep 28
6
[PATCH 0/3] virtio-net: inline header support
Thinking about Sasha's patches, we can reduce ring usage for virtio net small packets dramatically if we put virtio net header inline with the data. This can be done for free in case guest net stack allocated extra head room for the packet, and I don't see why would this have any downsides. Even though with my recent patches qemu no longer requires header to be the first s/g element, we
2012 Sep 28
6
[PATCH 0/3] virtio-net: inline header support
Thinking about Sasha's patches, we can reduce ring usage for virtio net small packets dramatically if we put virtio net header inline with the data. This can be done for free in case guest net stack allocated extra head room for the packet, and I don't see why would this have any downsides. Even though with my recent patches qemu no longer requires header to be the first s/g element, we