@@ -410,8 +410,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
410
410
clear_bit (ICE_VSI_PROMISC_CHANGED , vsi -> state );
411
411
if (vsi -> current_netdev_flags & IFF_PROMISC ) {
412
412
/* Apply Rx filter rule to get traffic from wire */
413
- if (!ice_is_dflt_vsi_in_use (pf -> first_sw )) {
414
- err = ice_set_dflt_vsi (pf -> first_sw , vsi );
413
+ if (!ice_is_dflt_vsi_in_use (vsi -> port_info )) {
414
+ err = ice_set_dflt_vsi (vsi );
415
415
if (err && err != - EEXIST ) {
416
416
netdev_err (netdev , "Error %d setting default VSI %i Rx rule\n" ,
417
417
err , vsi -> vsi_num );
@@ -424,8 +424,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
424
424
}
425
425
} else {
426
426
/* Clear Rx filter to remove traffic from wire */
427
- if (ice_is_vsi_dflt_vsi (pf -> first_sw , vsi )) {
428
- err = ice_clear_dflt_vsi (pf -> first_sw );
427
+ if (ice_is_vsi_dflt_vsi (vsi )) {
428
+ err = ice_clear_dflt_vsi (vsi );
429
429
if (err ) {
430
430
netdev_err (netdev , "Error %d clearing default VSI %i Rx rule\n" ,
431
431
err , vsi -> vsi_num );
@@ -3358,6 +3358,7 @@ static void ice_set_netdev_features(struct net_device *netdev)
3358
3358
netdev -> features |= netdev -> hw_features ;
3359
3359
3360
3360
netdev -> hw_features |= NETIF_F_HW_TC ;
3361
+ netdev -> hw_features |= NETIF_F_LOOPBACK ;
3361
3362
3362
3363
/* encap and VLAN devices inherit default, csumo and tso features */
3363
3364
netdev -> hw_enc_features |= dflt_features | csumo_features |
@@ -5912,6 +5913,32 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
5912
5913
return 0 ;
5913
5914
}
5914
5915
5916
+ /**
5917
+ * ice_set_loopback - turn on/off loopback mode on underlying PF
5918
+ * @vsi: ptr to VSI
5919
+ * @ena: flag to indicate the on/off setting
5920
+ */
5921
+ static int ice_set_loopback (struct ice_vsi * vsi , bool ena )
5922
+ {
5923
+ bool if_running = netif_running (vsi -> netdev );
5924
+ int ret ;
5925
+
5926
+ if (if_running && !test_and_set_bit (ICE_VSI_DOWN , vsi -> state )) {
5927
+ ret = ice_down (vsi );
5928
+ if (ret ) {
5929
+ netdev_err (vsi -> netdev , "Preparing device to toggle loopback failed\n" );
5930
+ return ret ;
5931
+ }
5932
+ }
5933
+ ret = ice_aq_set_mac_loopback (& vsi -> back -> hw , ena , NULL );
5934
+ if (ret )
5935
+ netdev_err (vsi -> netdev , "Failed to toggle loopback state\n" );
5936
+ if (if_running )
5937
+ ret = ice_up (vsi );
5938
+
5939
+ return ret ;
5940
+ }
5941
+
5915
5942
/**
5916
5943
* ice_set_features - set the netdev feature flags
5917
5944
* @netdev: ptr to the netdev being adjusted
@@ -5920,44 +5947,41 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
5920
5947
static int
5921
5948
ice_set_features (struct net_device * netdev , netdev_features_t features )
5922
5949
{
5950
+ netdev_features_t changed = netdev -> features ^ features ;
5923
5951
struct ice_netdev_priv * np = netdev_priv (netdev );
5924
5952
struct ice_vsi * vsi = np -> vsi ;
5925
5953
struct ice_pf * pf = vsi -> back ;
5926
5954
int ret = 0 ;
5927
5955
5928
5956
/* Don't set any netdev advanced features with device in Safe Mode */
5929
- if (ice_is_safe_mode (vsi -> back )) {
5930
- dev_err (ice_pf_to_dev (vsi -> back ), "Device is in Safe Mode - not enabling advanced netdev features\n" );
5957
+ if (ice_is_safe_mode (pf )) {
5958
+ dev_err (ice_pf_to_dev (pf ),
5959
+ "Device is in Safe Mode - not enabling advanced netdev features\n" );
5931
5960
return ret ;
5932
5961
}
5933
5962
5934
5963
/* Do not change setting during reset */
5935
5964
if (ice_is_reset_in_progress (pf -> state )) {
5936
- dev_err (ice_pf_to_dev (vsi -> back ), "Device is resetting, changing advanced netdev features temporarily unavailable.\n" );
5965
+ dev_err (ice_pf_to_dev (pf ),
5966
+ "Device is resetting, changing advanced netdev features temporarily unavailable.\n" );
5937
5967
return - EBUSY ;
5938
5968
}
5939
5969
5940
5970
/* Multiple features can be changed in one call so keep features in
5941
5971
* separate if/else statements to guarantee each feature is checked
5942
5972
*/
5943
- if (features & NETIF_F_RXHASH && !(netdev -> features & NETIF_F_RXHASH ))
5944
- ice_vsi_manage_rss_lut (vsi , true);
5945
- else if (!(features & NETIF_F_RXHASH ) &&
5946
- netdev -> features & NETIF_F_RXHASH )
5947
- ice_vsi_manage_rss_lut (vsi , false);
5973
+ if (changed & NETIF_F_RXHASH )
5974
+ ice_vsi_manage_rss_lut (vsi , !!(features & NETIF_F_RXHASH ));
5948
5975
5949
5976
ret = ice_set_vlan_features (netdev , features );
5950
5977
if (ret )
5951
5978
return ret ;
5952
5979
5953
- if ((features & NETIF_F_NTUPLE ) &&
5954
- !(netdev -> features & NETIF_F_NTUPLE )) {
5955
- ice_vsi_manage_fdir (vsi , true);
5956
- ice_init_arfs (vsi );
5957
- } else if (!(features & NETIF_F_NTUPLE ) &&
5958
- (netdev -> features & NETIF_F_NTUPLE )) {
5959
- ice_vsi_manage_fdir (vsi , false);
5960
- ice_clear_arfs (vsi );
5980
+ if (changed & NETIF_F_NTUPLE ) {
5981
+ bool ena = !!(features & NETIF_F_NTUPLE );
5982
+
5983
+ ice_vsi_manage_fdir (vsi , ena );
5984
+ ena ? ice_init_arfs (vsi ) : ice_clear_arfs (vsi );
5961
5985
}
5962
5986
5963
5987
/* don't turn off hw_tc_offload when ADQ is already enabled */
@@ -5966,13 +5990,17 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
5966
5990
return - EACCES ;
5967
5991
}
5968
5992
5969
- if ((features & NETIF_F_HW_TC ) &&
5970
- !(netdev -> features & NETIF_F_HW_TC ))
5971
- set_bit (ICE_FLAG_CLS_FLOWER , pf -> flags );
5972
- else
5973
- clear_bit (ICE_FLAG_CLS_FLOWER , pf -> flags );
5993
+ if (changed & NETIF_F_HW_TC ) {
5994
+ bool ena = !!(features & NETIF_F_HW_TC );
5974
5995
5975
- return 0 ;
5996
+ ena ? set_bit (ICE_FLAG_CLS_FLOWER , pf -> flags ) :
5997
+ clear_bit (ICE_FLAG_CLS_FLOWER , pf -> flags );
5998
+ }
5999
+
6000
+ if (changed & NETIF_F_LOOPBACK )
6001
+ ret = ice_set_loopback (vsi , !!(features & NETIF_F_LOOPBACK ));
6002
+
6003
+ return ret ;
5976
6004
}
5977
6005
5978
6006
/**
@@ -6994,12 +7022,6 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
6994
7022
goto err_init_ctrlq ;
6995
7023
}
6996
7024
6997
- if (pf -> first_sw -> dflt_vsi_ena )
6998
- dev_info (dev , "Clearing default VSI, re-enable after reset completes\n" );
6999
- /* clear the default VSI configuration if it exists */
7000
- pf -> first_sw -> dflt_vsi = NULL ;
7001
- pf -> first_sw -> dflt_vsi_ena = false;
7002
-
7003
7025
ice_clear_pxe_mode (hw );
7004
7026
7005
7027
err = ice_init_nvm (hw );
0 commit comments