[v2] net/virtio: set offload flag for jumbo frames

Message ID 20190130212218.29977-1-jfreimann@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series [v2] net/virtio: set offload flag for jumbo frames |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Jens Freimann Jan. 30, 2019, 9:22 p.m. UTC
  Port configuration fails because offload flags don't match the expected
value when max-pkt-len is set to a value that should enable receive port
offloading but doesn't.

There are two cases to consider:

1. VIRTIO_NET_F_MTU is set. Then we need to check if the requested
   max-pkt-len fits into the MTU plus header. If yes we set the offload flag.
2. VIRTIO_NET_F_MTU is not set. We can set the offload flag.

Fixes: a4996bd89c42 (""ethdev: new Rx/Tx offloads API)
Cc: stable@dpdk.org

Signed-off-by: Jens Freimann <jfreimann@redhat.com>
---
v1->v2:
 * include virtnet hdr, ethernet header, vlan tag when comparing against
   max-rx-pkt-len (Maxime)

 drivers/net/virtio/virtio_ethdev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Maxime Coquelin Jan. 31, 2019, 8:34 a.m. UTC | #1
On 1/30/19 10:22 PM, Jens Freimann wrote:
> Port configuration fails because offload flags don't match the expected
> value when max-pkt-len is set to a value that should enable receive port
> offloading but doesn't.
> 
> There are two cases to consider:
> 
> 1. VIRTIO_NET_F_MTU is set. Then we need to check if the requested
>     max-pkt-len fits into the MTU plus header. If yes we set the offload flag.
> 2. VIRTIO_NET_F_MTU is not set. We can set the offload flag.
> 
> Fixes: a4996bd89c42 (""ethdev: new Rx/Tx offloads API)
> Cc:stable@dpdk.org
> 
> Signed-off-by: Jens Freimann<jfreimann@redhat.com>
> ---
> v1->v2:
>   * include virtnet hdr, ethernet header, vlan tag when comparing against
>     max-rx-pkt-len (Maxime)
> 
>   drivers/net/virtio/virtio_ethdev.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 7c4c1df00..863fbe909 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -2351,6 +2351,20 @@ 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;
> +		uint32_t ether_hdr_len = ETHER_HDR_LEN + VLAN_TAG_LEN +
> +			hw->vtnet_hdr_size;
> +		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 + ether_hdr_len))

The brackets arent necessary here I think.

Can you send v3 with this and git commit message fixed?

Thank you!
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 7c4c1df00..863fbe909 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2351,6 +2351,20 @@  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;
+		uint32_t ether_hdr_len = ETHER_HDR_LEN + VLAN_TAG_LEN +
+			hw->vtnet_hdr_size;
+		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 + ether_hdr_len))
+			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)) {