Skip to content

Commit da26658

Browse files
dcuidavem330
authored andcommitted
hv_netvsc: Cache the current data path to avoid duplicate call and message
The previous change "hv_netvsc: Switch the data path at the right time during hibernation" adds the call of netvsc_vf_changed() upon NETDEV_CHANGE, so it's necessary to avoid the duplicate call and message when the VF is brought UP or DOWN. Signed-off-by: Dexuan Cui <decui@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de214e5 commit da26658

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎drivers/net/hyperv/hyperv_net.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ struct net_device_context {
974974
/* Serial number of the VF to team with */
975975
u32 vf_serial;
976976

977+
/* Is the current data path through the VF NIC? */
978+
bool data_path_is_vf;
979+
977980
/* Used to temporarily save the config info across hibernation */
978981
struct netvsc_device_info *saved_netvsc_dev_info;
979982
};

‎drivers/net/hyperv/netvsc_drv.c‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,16 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
23662366
return NOTIFY_OK;
23672367
}
23682368

2369-
/* VF up/down change detected, schedule to change data path */
2369+
/* Change the data path when VF UP/DOWN/CHANGE are detected.
2370+
*
2371+
* Typically a UP or DOWN event is followed by a CHANGE event, so
2372+
* net_device_ctx->data_path_is_vf is used to cache the current data path
2373+
* to avoid the duplicate call of netvsc_switch_datapath() and the duplicate
2374+
* message.
2375+
*
2376+
* During hibernation, if a VF NIC driver (e.g. mlx5) preserves the network
2377+
* interface, there is only the CHANGE event and no UP or DOWN event.
2378+
*/
23702379
static int netvsc_vf_changed(struct net_device *vf_netdev)
23712380
{
23722381
struct net_device_context *net_device_ctx;
@@ -2383,6 +2392,10 @@ static int netvsc_vf_changed(struct net_device *vf_netdev)
23832392
if (!netvsc_dev)
23842393
return NOTIFY_DONE;
23852394

2395+
if (net_device_ctx->data_path_is_vf == vf_is_up)
2396+
return NOTIFY_OK;
2397+
net_device_ctx->data_path_is_vf = vf_is_up;
2398+
23862399
netvsc_switch_datapath(ndev, vf_is_up);
23872400
netdev_info(ndev, "Data path switched %s VF: %s\n",
23882401
vf_is_up ? "to" : "from", vf_netdev->name);
@@ -2624,6 +2637,12 @@ static int netvsc_resume(struct hv_device *dev)
26242637
rtnl_lock();
26252638

26262639
net_device_ctx = netdev_priv(net);
2640+
2641+
/* Reset the data path to the netvsc NIC before re-opening the vmbus
2642+
* channel. Later netvsc_netdev_event() will switch the data path to
2643+
* the VF upon the UP or CHANGE event.
2644+
*/
2645+
net_device_ctx->data_path_is_vf = false;
26272646
device_info = net_device_ctx->saved_netvsc_dev_info;
26282647

26292648
ret = netvsc_attach(net, device_info);

0 commit comments

Comments
 (0)