Skip to content

Commit 44ece4e

Browse files
mfijalkoanguy11
authored andcommitted
ice: allow toggling loopback mode via ndo_set_features callback
Add support for NETIF_F_LOOPBACK. This feature can be set via: $ ethtool -K eth0 loopback <on|off> Feature can be useful for local data path tests. Acked-by: Jakub Kicinski <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: Maciej Fijalkowski <[email protected]> Tested-by: George Kuruvinakunnel <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c67672f commit 44ece4e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,7 @@ static void ice_set_netdev_features(struct net_device *netdev)
33583358
netdev->features |= netdev->hw_features;
33593359

33603360
netdev->hw_features |= NETIF_F_HW_TC;
3361+
netdev->hw_features |= NETIF_F_LOOPBACK;
33613362

33623363
/* encap and VLAN devices inherit default, csumo and tso features */
33633364
netdev->hw_enc_features |= dflt_features | csumo_features |
@@ -5910,6 +5911,32 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
59105911
return 0;
59115912
}
59125913

5914+
/**
5915+
* ice_set_loopback - turn on/off loopback mode on underlying PF
5916+
* @vsi: ptr to VSI
5917+
* @ena: flag to indicate the on/off setting
5918+
*/
5919+
static int ice_set_loopback(struct ice_vsi *vsi, bool ena)
5920+
{
5921+
bool if_running = netif_running(vsi->netdev);
5922+
int ret;
5923+
5924+
if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
5925+
ret = ice_down(vsi);
5926+
if (ret) {
5927+
netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n");
5928+
return ret;
5929+
}
5930+
}
5931+
ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL);
5932+
if (ret)
5933+
netdev_err(vsi->netdev, "Failed to toggle loopback state\n");
5934+
if (if_running)
5935+
ret = ice_up(vsi);
5936+
5937+
return ret;
5938+
}
5939+
59135940
/**
59145941
* ice_set_features - set the netdev feature flags
59155942
* @netdev: ptr to the netdev being adjusted
@@ -5968,7 +5995,10 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
59685995
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
59695996
}
59705997

5971-
return 0;
5998+
if (changed & NETIF_F_LOOPBACK)
5999+
ret = ice_set_loopback(vsi, !!(features & NETIF_F_LOOPBACK));
6000+
6001+
return ret;
59726002
}
59736003

59746004
/**

0 commit comments

Comments
 (0)