Blame SOURCES/0004-net-virtio-set-offload-flag-for-jumbo-frames.patch

caa5b4
From a4b153795f55b303741ef4a2dd2205291ef2a79e Mon Sep 17 00:00:00 2001
caa5b4
From: Jens Freimann <jfreimann@redhat.com>
caa5b4
Date: Wed, 30 Jan 2019 08:19:32 -0500
caa5b4
Subject: [PATCH] net/virtio: set offload flag for jumbo frames
caa5b4
caa5b4
[ upstream commit 8b90e4358112b9e41f8eaa1ba14c783570307fea ]
caa5b4
caa5b4
Port configuration fails because offload flags don't match the expected
caa5b4
value when max-pkt-len is set to a value that should enable receive port
caa5b4
offloading but doesn't.
caa5b4
caa5b4
The .dev_infos_get callback can be called before the configure callback.
caa5b4
At that time we don't know the maximum packet size yet because it is
caa5b4
only set up when ports are started. So in virtio_dev_info_get() just
caa5b4
always set the jumbo packet offload flag.
caa5b4
caa5b4
Check the maximum packet length at device configure time, because then we
caa5b4
have access to the max-pkt-len value provided by the user. If the
caa5b4
max-pkt-len exceeds the maximum MTU supported by the device we remove
caa5b4
the VIRTIO_NET_F_MTU flag from requested features.
caa5b4
caa5b4
Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API")
caa5b4
Cc: stable@dpdk.org
caa5b4
caa5b4
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
caa5b4
---
caa5b4
 drivers/net/virtio/virtio_ethdev.c | 6 ++++++
caa5b4
 1 file changed, 6 insertions(+)
caa5b4
caa5b4
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
caa5b4
index 7c4c1df00..7c2fe76f3 100644
caa5b4
--- a/drivers/net/virtio/virtio_ethdev.c
caa5b4
+++ b/drivers/net/virtio/virtio_ethdev.c
caa5b4
@@ -1972,6 +1972,8 @@ virtio_dev_configure(struct rte_eth_dev *dev)
caa5b4
 	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
caa5b4
 	const struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode;
caa5b4
 	struct virtio_hw *hw = dev->data->dev_private;
caa5b4
+	uint32_t ether_hdr_len = ETHER_HDR_LEN + VLAN_TAG_LEN +
caa5b4
+		hw->vtnet_hdr_size;
caa5b4
 	uint64_t rx_offloads = rxmode->offloads;
caa5b4
 	uint64_t tx_offloads = txmode->offloads;
caa5b4
 	uint64_t req_features;
caa5b4
@@ -1986,6 +1988,9 @@ virtio_dev_configure(struct rte_eth_dev *dev)
caa5b4
 			return ret;
caa5b4
 	}
caa5b4
 
caa5b4
+	if (rxmode->max_rx_pkt_len > hw->max_mtu + ether_hdr_len)
caa5b4
+		req_features &= ~(1ULL << VIRTIO_NET_F_MTU);
caa5b4
+
caa5b4
 	if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM |
caa5b4
 			   DEV_RX_OFFLOAD_TCP_CKSUM))
caa5b4
 		req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
caa5b4
@@ -2339,6 +2344,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
caa5b4
 
caa5b4
 	host_features = VTPCI_OPS(hw)->get_features(hw);
caa5b4
 	dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;
caa5b4
+	dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
caa5b4
 	if (host_features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {
caa5b4
 		dev_info->rx_offload_capa |=
caa5b4
 			DEV_RX_OFFLOAD_TCP_CKSUM |
caa5b4
-- 
caa5b4
2.20.1
caa5b4