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

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