hv_netvsc: Use VF's tso_max_size value when data path is VF
authorShradha Gupta <shradhagupta@linux.microsoft.com>
Mon, 17 Feb 2025 03:42:42 +0000 (19:42 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Feb 2025 09:42:52 +0000 (09:42 +0000)
On Azure, increasing VF's gso/gro packet size to up-to GSO_MAX_SIZE
is not possible without allowing the same for netvsc NIC
(as the NICs are bonded together). For bonded NICs, the min of the max
aggregated pkt size of the members is propagated in the stack.

Therefore, we use netif_set_tso_max_size() to set max aggregated pkt size
to VF's packet size for netvsc too, when the data path is switched over
to the VF
Tested on azure env with Accelerated Networking enabled and disabled.

Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc_drv.c
drivers/net/hyperv/rndis_filter.c

index 234db693cefa4cf1995e2a186a278fdad8093e96..70f7cb383228eaf7a2e17454415bbf9151c8ec3a 100644 (file)
@@ -1166,6 +1166,8 @@ struct netvsc_device {
        u32 max_chn;
        u32 num_chn;
 
+       u32 netvsc_gso_max_size;
+
        atomic_t open_chn;
        struct work_struct subchan_work;
        wait_queue_head_t subchan_open;
index d6c4abfc3a28b0f52cafb4c13ee419c0068fa5ea..9c6501bf27bde448e28fcc4c3f6cfdc81ddc3f2b 100644 (file)
@@ -2461,6 +2461,21 @@ static int netvsc_vf_changed(struct net_device *vf_netdev, unsigned long event)
        } else {
                netdev_info(ndev, "Data path switched %s VF: %s\n",
                            vf_is_up ? "to" : "from", vf_netdev->name);
+
+               /* In Azure, when accelerated networking in enabled, other NICs
+                * like MANA, MLX, are configured as a bonded nic with
+                * Netvsc(failover) NIC. For bonded NICs, the min of the max
+                * pkt aggregate size of the members is propagated in the stack.
+                * In order to allow these NICs (MANA/MLX) to use up to
+                * GSO_MAX_SIZE gso packet size, we need to allow Netvsc NIC to
+                * also support this in the guest.
+                * This value is only increased for netvsc NIC when datapath is
+                * switched over to the VF
+                */
+               if (vf_is_up)
+                       netif_set_tso_max_size(ndev, vf_netdev->tso_max_size);
+               else
+                       netif_set_tso_max_size(ndev, netvsc_dev->netvsc_gso_max_size);
        }
 
        return NOTIFY_OK;
index c0ceeef4fcd810693e608b9f3406b0554fedcd4f..82747dfacd70f0905ea937bb6d091fc7f9e45699 100644 (file)
@@ -1356,9 +1356,10 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device,
        struct net_device_context *net_device_ctx = netdev_priv(net);
        struct ndis_offload hwcaps;
        struct ndis_offload_params offloads;
-       unsigned int gso_max_size = GSO_LEGACY_MAX_SIZE;
        int ret;
 
+       nvdev->netvsc_gso_max_size = GSO_LEGACY_MAX_SIZE;
+
        /* Find HW offload capabilities */
        ret = rndis_query_hwcaps(rndis_device, nvdev, &hwcaps);
        if (ret != 0)
@@ -1390,8 +1391,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device,
                        offloads.lso_v2_ipv4 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
                        net->hw_features |= NETIF_F_TSO;
 
-                       if (hwcaps.lsov2.ip4_maxsz < gso_max_size)
-                               gso_max_size = hwcaps.lsov2.ip4_maxsz;
+                       if (hwcaps.lsov2.ip4_maxsz < nvdev->netvsc_gso_max_size)
+                               nvdev->netvsc_gso_max_size = hwcaps.lsov2.ip4_maxsz;
                }
 
                if (hwcaps.csum.ip4_txcsum & NDIS_TXCSUM_CAP_UDP4) {
@@ -1411,8 +1412,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device,
                        offloads.lso_v2_ipv6 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
                        net->hw_features |= NETIF_F_TSO6;
 
-                       if (hwcaps.lsov2.ip6_maxsz < gso_max_size)
-                               gso_max_size = hwcaps.lsov2.ip6_maxsz;
+                       if (hwcaps.lsov2.ip6_maxsz < nvdev->netvsc_gso_max_size)
+                               nvdev->netvsc_gso_max_size = hwcaps.lsov2.ip6_maxsz;
                }
 
                if (hwcaps.csum.ip6_txcsum & NDIS_TXCSUM_CAP_UDP6) {
@@ -1438,7 +1439,7 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device,
         */
        net->features &= ~NETVSC_SUPPORTED_HW_FEATURES | net->hw_features;
 
-       netif_set_tso_max_size(net, gso_max_size);
+       netif_set_tso_max_size(net, nvdev->netvsc_gso_max_size);
 
        ret = rndis_filter_set_offload_params(net, nvdev, &offloads);