From: Vladislav Yasevich <vyasevich@gmail.com>
To: netdev@vger.kernel.org
Cc: virtio-dev@lists.oasis-open.org, mst@redhat.com,
virtualization@lists.linux-foundation.org,
maxime.coquelin@redhat.com
Subject: [PATCH RFC (resend) net-next 1/6] virtio-net: Remove the use the padded vnet_header structure
Date: Sat, 15 Apr 2017 12:38:13 -0400 [thread overview]
Message-ID: <1492274298-17362-2-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1492274298-17362-1-git-send-email-vyasevic@redhat.com>
We can replace the structure with a properly aligned size instead.
The current structure attempts to align on a 16 byte boundary, so
preserve it.
Signed-off-by: Vlad Yaseivch <vyasevic@redhat.com>
---
drivers/net/virtio_net.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b0d241d..2937a98 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -174,15 +174,20 @@ struct virtnet_info {
u32 speed;
};
-struct padded_vnet_hdr {
- struct virtio_net_hdr_mrg_rxbuf hdr;
+static inline u8 padded_vnet_hdr(struct virtnet_info *vi)
+{
+ u8 hdr_len = vi->hdr_len;
+
/*
* hdr is in a separate sg buffer, and data sg buffer shares same page
* with this header sg. This padding makes next sg 16 byte aligned
* after the header.
*/
- char padding[4];
-};
+ if (!vi->mergeable_rx_bufs)
+ hdr_len = __ALIGN_KERNEL_MASK(hdr_len, 15);
+
+ return hdr_len;
+}
/* Converting between virtqueue no. and kernel tx/rx queue no.
* 0:rx0 1:tx0 2:rx1 3:tx1 ... 2N:rxN 2N+1:txN 2N+2:cvq
@@ -289,10 +294,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
hdr = skb_vnet_hdr(skb);
hdr_len = vi->hdr_len;
- if (vi->mergeable_rx_bufs)
- hdr_padded_len = sizeof *hdr;
- else
- hdr_padded_len = sizeof(struct padded_vnet_hdr);
+ hdr_padded_len = padded_vnet_hdr(vi);
memcpy(hdr, p, hdr_len);
@@ -840,7 +842,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, struct receive_queue *rq,
sg_set_buf(&rq->sg[0], p, vi->hdr_len);
/* rq->sg[1] for data packet, from offset */
- offset = sizeof(struct padded_vnet_hdr);
+ offset = padded_vnet_hdr(vi);
sg_set_buf(&rq->sg[1], p + offset, PAGE_SIZE - offset);
/* chain first in list head */
@@ -1790,8 +1792,8 @@ static int virtnet_reset(struct virtnet_info *vi, int curr_qp, int xdp_qp)
static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
{
- unsigned long int max_sz = PAGE_SIZE - sizeof(struct padded_vnet_hdr);
struct virtnet_info *vi = netdev_priv(dev);
+ unsigned long int max_sz = PAGE_SIZE - padded_vnet_hdr(vi);
struct bpf_prog *old_prog;
u16 xdp_qp = 0, curr_qp;
int i, err;
--
2.7.4
next prev parent reply other threads:[~2017-04-15 16:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-15 16:38 [PATCH RFC (resend) net-next 0/6] virtio-net: Add support for virtio-net header extensions Vladislav Yasevich
2017-04-15 16:38 ` Vladislav Yasevich [this message]
2017-04-15 16:38 ` [PATCH RFC (resend) net-next 2/6] virtio-net: make header length handling uniform Vladislav Yasevich
2017-04-15 16:38 ` [PATCH RFC (resend) net-next 3/6] virtio_net: Add basic skeleton for handling vnet header extensions Vladislav Yasevich
2017-04-18 2:52 ` Jason Wang
2017-04-15 16:38 ` [PATCH RFC (resend) net-next 4/6] virtio-net: Add support for IPv6 fragment id vnet header extension Vladislav Yasevich
2017-04-15 16:38 ` [PATCH RFC (resend) net-next 5/6] virtio-net: Add support for vlan acceleration " Vladislav Yasevich
2017-04-16 0:28 ` Michael S. Tsirkin
2017-04-18 2:54 ` Jason Wang
2017-04-15 16:38 ` [PATCH RFC (resend) net-next 6/6] virtio: Add support for UDP tunnel offload and extension Vladislav Yasevich
2017-04-18 3:01 ` [PATCH RFC (resend) net-next 0/6] virtio-net: Add support for virtio-net header extensions Jason Wang
2017-04-20 15:34 ` Vlad Yasevich
2017-04-21 4:05 ` Jason Wang
2017-04-21 13:08 ` Vlad Yasevich
2017-04-24 3:22 ` Jason Wang
2017-04-24 17:04 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492274298-17362-2-git-send-email-vyasevic@redhat.com \
--to=vyasevich@gmail.com \
--cc=maxime.coquelin@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).