Skip to contentSkip to conversation

net/virtio: set offload flag for jumbo frames

PATCH Superseded Jens Freimann 2 participants 3 messages Jan 30, 2019 Network drivers

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: set offload flag for jumbo frames

Port configuration fails when offload flags don't match the expected value, e.g. when max-pkt-len is set to a value that should enable receive port offloading but doesn't.

This can be triggered by running testpmd e.g. with --max-pkt-len=2000. It will fail with "Ethdev port_id=0 requested Rx offloads 0x800 doesn't match Rx offloads capabilities 0x20d in rte_eth_dev_configure()"

To fix this there are two cases to consider:

1. VIRTIO_NET_F_MTU is negotiated. Then we need to check if the requested max. packet length fits into the MTU. If yes we set the offload flag.
2. VIRTIO_NET_F_MTU is not negotiated. We can set the offload flag.

---
 drivers/net/virtio/virtio_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/virtio/virtio_ethdev.c +11 -0
index 7c4c1df00..e0d6542d4 100644
@@ -2351,6 +2351,17 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	if ((host_features & tso_mask) == tso_mask)
 		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
 
+	if (host_features & (1ULL << VIRTIO_NET_F_MTU)) {
+		struct virtio_net_config config;
+		vtpci_read_dev_config(hw,
+				offsetof(struct virtio_net_config, mtu),
+				&config.mtu, sizeof(config.mtu));
+		if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= config.mtu)
+			dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	} else {
+		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	}
+
 	dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS |
 				    DEV_TX_OFFLOAD_VLAN_INSERT;
 	if (host_features & (1ULL << VIRTIO_NET_F_CSUM)) {
Signature · 1 line
2.17.2
#1 lore raw
Quoted 8 lines · Jens Freimann

Port configuration fails when offload flags don't match the expected value, e.g. when max-pkt-len is set to a value that should enable receive port offloading but doesn't.

This can be triggered by running testpmd e.g. with --max-pkt-len=2000. It will fail with "Ethdev port_id=0 requested Rx offloads 0x800 doesn't match Rx offloads capabilities 0x20d in rte_eth_dev_configure()"

Quoted 6 lines

To fix this there are two cases to consider:

1. VIRTIO_NET_F_MTU is negotiated. Then we need to check if the requested max. packet length fits into the MTU. If yes we set the offload flag.
2. VIRTIO_NET_F_MTU is not negotiated. We can set the offload flag.

I think we need to Cc: stable and point to the commit introducing the regression. I think it is the one introducing the use of DEV_RX_OFFLOAD_JUMBO_FRAME in Virtio PMD.

Quoted 11 lines
---
  drivers/net/virtio/virtio_ethdev.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 7c4c1df00..e0d6542d4 100644

drivers/net/virtio/virtio_ethdev.c virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 2359

Quoted 9 lines
drivers/net/virtio/virtio_ethdev.c +6 -0
@@ -2351,6 +2351,17 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
  	if ((host_features & tso_mask) == tso_mask)
  		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
 
+	if (host_features & (1ULL << VIRTIO_NET_F_MTU)) {
+		struct virtio_net_config config;
+		vtpci_read_dev_config(hw,
+				offsetof(struct virtio_net_config, mtu),
+				&config.mtu, sizeof(config.mtu));
+		if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= config.mtu)

That is not exactly right, MTU does not take into account the Ethernet header, the VLAN tag and the virtio-net header.

See virtio_mtu_set() for example.

Quoted 9 lines
drivers/net/virtio/virtio_ethdev.c +5 -0
+			dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	} else {
+		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	}
+
  	dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS |
  				    DEV_TX_OFFLOAD_VLAN_INSERT;
  	if (host_features & (1ULL << VIRTIO_NET_F_CSUM)) {
#2 lore raw
Quoted 13 lines · Maxime Coquelin
Quoted 10 lines · Jens Freimann

Port configuration fails when offload flags don't match the expected value, e.g. when max-pkt-len is set to a value that should enable receive port offloading but doesn't.

This can be triggered by running testpmd e.g. with --max-pkt-len=2000. It will fail with "Ethdev port_id=0 requested Rx offloads 0x800 doesn't match Rx offloads capabilities 0x20d in rte_eth_dev_configure()"

To fix this there are two cases to consider:

Quoted 8 lines
Quoted 4 lines

1. VIRTIO_NET_F_MTU is negotiated. Then we need to check if the requested max. packet length fits into the MTU. If yes we set the offload flag.
2. VIRTIO_NET_F_MTU is not negotiated. We can set the offload flag.

I think we need to Cc: stable and point to the commit introducing the regression. I think it is the one introducing the use of DEV_RX_OFFLOAD_JUMBO_FRAME in Virtio PMD.

ok

Quoted 23 lines
Quoted 11 lines
---
 drivers/net/virtio/virtio_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 7c4c1df00..e0d6542d4 100644

drivers/net/virtio/virtio_ethdev.c virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 2358

Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +6 -0
@@ -2351,6 +2351,17 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	if ((host_features & tso_mask) == tso_mask)
 		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
+	if (host_features & (1ULL << VIRTIO_NET_F_MTU)) {
+		struct virtio_net_config config;
+		vtpci_read_dev_config(hw,
+				offsetof(struct virtio_net_config, mtu),
+				&config.mtu, sizeof(config.mtu));
+		if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= config.mtu)

That is not exactly right, MTU does not take into account the Ethernet header, the VLAN tag and the virtio-net header.

Quoted 1 line

See virtio_mtu_set() for example.

I wasn't sure about it, will send a v2. Thanks for the review!

regards,
Jens