Skip to content

Commit c1ddc42

Browse files
AndrewAtDaynixmstsirkin
authored andcommitted
drivers/net/virtio_net: Fixed padded vheader to use v1 with hash.
The header v1 provides additional info about RSS. Added changes to computing proper header length. In the next patches, the header may contain RSS hash info for the hash population. Signed-off-by: Andrew Melnychenko <andrew@daynix.com> Link: https://lore.kernel.org/r/20220328175336.10802-2-andrew@daynix.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 8d65bc9 commit c1ddc42

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/net/virtio_net.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ struct virtnet_info {
242242
};
243243

244244
struct padded_vnet_hdr {
245-
struct virtio_net_hdr_mrg_rxbuf hdr;
245+
struct virtio_net_hdr_v1_hash hdr;
246246
/*
247247
* hdr is in a separate sg buffer, and data sg buffer shares same page
248248
* with this header sg. This padding makes next sg 16 byte aligned
249249
* after the header.
250250
*/
251-
char padding[4];
251+
char padding[12];
252252
};
253253

254254
static bool is_xdp_frame(void *ptr)
@@ -396,7 +396,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
396396

397397
hdr_len = vi->hdr_len;
398398
if (vi->mergeable_rx_bufs)
399-
hdr_padded_len = sizeof(*hdr);
399+
hdr_padded_len = hdr_len;
400400
else
401401
hdr_padded_len = sizeof(struct padded_vnet_hdr);
402402

@@ -1266,7 +1266,8 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
12661266
struct ewma_pkt_len *avg_pkt_len,
12671267
unsigned int room)
12681268
{
1269-
const size_t hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
1269+
struct virtnet_info *vi = rq->vq->vdev->priv;
1270+
const size_t hdr_len = vi->hdr_len;
12701271
unsigned int len;
12711272

12721273
if (room)
@@ -2851,7 +2852,7 @@ static void virtnet_del_vqs(struct virtnet_info *vi)
28512852
*/
28522853
static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqueue *vq)
28532854
{
2854-
const unsigned int hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
2855+
const unsigned int hdr_len = vi->hdr_len;
28552856
unsigned int rq_size = virtqueue_get_vring_size(vq);
28562857
unsigned int packet_len = vi->big_packets ? IP_MAX_MTU : vi->dev->max_mtu;
28572858
unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;

0 commit comments

Comments
 (0)