Skip to content

Commit ca4a80e

Browse files
ihuguetkuba-moo
authored andcommitted
sfc: ef10: don't overwrite offload features at NIC reset
At NIC reset, some offload features related to encapsulated traffic might have changed (this mainly happens if the firmware-variant is changed with the sfboot userspace tool). Because of this, features are checked and set again at reset time. However, this was not done right, and some features were improperly overwritten at NIC reset: - Tunneled IPv6 segmentation was always disabled - Features disabled with ethtool were reenabled - Features that becomes unsupported after the reset were not disabled Also, checking if the device supports IPV6_CSUM to enable TSO6 is no longer necessary because all currently supported devices support it. Additionally, move the assignment of some other features to the EF10_OFFLOAD_FEATURES macro, like it is done in ef100, leaving the selection of features in efx_pci_probe_post_io a bit cleaner. Fixes: ffffd24 ("sfc: correctly advertise tunneled IPv6 segmentation") Fixes: 24b2c37 ("sfc: advertise encapsulated offloads on EF10") Reported-by: Tianhao Zhao <[email protected]> Suggested-by: Jonathan Cooper <[email protected]> Tested-by: Jonathan Cooper <[email protected]> Signed-off-by: Íñigo Huguet <[email protected]> Acked-by: Edward Cree <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5951371 commit ca4a80e

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,8 @@ static void efx_ef10_fini_nic(struct efx_nic *efx)
13041304
static int efx_ef10_init_nic(struct efx_nic *efx)
13051305
{
13061306
struct efx_ef10_nic_data *nic_data = efx->nic_data;
1307-
netdev_features_t hw_enc_features = 0;
1307+
struct net_device *net_dev = efx->net_dev;
1308+
netdev_features_t tun_feats, tso_feats;
13081309
int rc;
13091310

13101311
if (nic_data->must_check_datapath_caps) {
@@ -1349,20 +1350,30 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
13491350
nic_data->must_restore_piobufs = false;
13501351
}
13511352

1352-
/* add encapsulated checksum offload features */
1353+
/* encap features might change during reset if fw variant changed */
13531354
if (efx_has_cap(efx, VXLAN_NVGRE) && !efx_ef10_is_vf(efx))
1354-
hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1355-
/* add encapsulated TSO features */
1356-
if (efx_has_cap(efx, TX_TSO_V2_ENCAP)) {
1357-
netdev_features_t encap_tso_features;
1355+
net_dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1356+
else
1357+
net_dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
13581358

1359-
encap_tso_features = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
1360-
NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM;
1359+
tun_feats = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
1360+
NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM;
1361+
tso_feats = NETIF_F_TSO | NETIF_F_TSO6;
13611362

1362-
hw_enc_features |= encap_tso_features | NETIF_F_TSO;
1363-
efx->net_dev->features |= encap_tso_features;
1363+
if (efx_has_cap(efx, TX_TSO_V2_ENCAP)) {
1364+
/* If this is first nic_init, or if it is a reset and a new fw
1365+
* variant has added new features, enable them by default.
1366+
* If the features are not new, maintain their current value.
1367+
*/
1368+
if (!(net_dev->hw_features & tun_feats))
1369+
net_dev->features |= tun_feats;
1370+
net_dev->hw_enc_features |= tun_feats | tso_feats;
1371+
net_dev->hw_features |= tun_feats;
1372+
} else {
1373+
net_dev->hw_enc_features &= ~(tun_feats | tso_feats);
1374+
net_dev->hw_features &= ~tun_feats;
1375+
net_dev->features &= ~tun_feats;
13641376
}
1365-
efx->net_dev->hw_enc_features = hw_enc_features;
13661377

13671378
/* don't fail init if RSS setup doesn't work */
13681379
rc = efx->type->rx_push_rss_config(efx, false,
@@ -4021,7 +4032,10 @@ static unsigned int efx_ef10_recycle_ring_size(const struct efx_nic *efx)
40214032
NETIF_F_HW_VLAN_CTAG_FILTER | \
40224033
NETIF_F_IPV6_CSUM | \
40234034
NETIF_F_RXHASH | \
4024-
NETIF_F_NTUPLE)
4035+
NETIF_F_NTUPLE | \
4036+
NETIF_F_SG | \
4037+
NETIF_F_RXCSUM | \
4038+
NETIF_F_RXALL)
40254039

40264040
const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
40274041
.is_vf = true,

drivers/net/ethernet/sfc/efx.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,21 +1001,18 @@ static int efx_pci_probe_post_io(struct efx_nic *efx)
10011001
}
10021002

10031003
/* Determine netdevice features */
1004-
net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
1005-
NETIF_F_TSO | NETIF_F_RXCSUM | NETIF_F_RXALL);
1006-
if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM)) {
1007-
net_dev->features |= NETIF_F_TSO6;
1008-
if (efx_has_cap(efx, TX_TSO_V2_ENCAP))
1009-
net_dev->hw_enc_features |= NETIF_F_TSO6;
1010-
}
1011-
/* Check whether device supports TSO */
1012-
if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
1013-
net_dev->features &= ~NETIF_F_ALL_TSO;
1004+
net_dev->features |= efx->type->offload_features;
1005+
1006+
/* Add TSO features */
1007+
if (efx->type->tso_versions && efx->type->tso_versions(efx))
1008+
net_dev->features |= NETIF_F_TSO | NETIF_F_TSO6;
1009+
10141010
/* Mask for features that also apply to VLAN devices */
10151011
net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
10161012
NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
10171013
NETIF_F_RXCSUM);
10181014

1015+
/* Determine user configurable features */
10191016
net_dev->hw_features |= net_dev->features & ~efx->fixed_features;
10201017

10211018
/* Disable receiving frames with bad FCS, by default. */

0 commit comments

Comments
 (0)