Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macsec: add some of the lower device's features when offloading

This commit extends the set of netdevice features supported by macsec
devices when offload is enabled, which increases performance
significantly (for a single TCP stream: 17.5Gbps to 38.5Gbps on my
test machines).

Commit c850240b6c41 ("net: macsec: report real_dev features when HW
offloading is enabled") previously attempted something similar, but
had to be reverted (commit 8bcd560ae878 ("Revert "net: macsec: report
real_dev features when HW offloading is enabled"")) because the set of
features it exposed was too large.

During initialization, all features are set, and they're then removed
via ndo_fix_features (macsec_fix_features). This allows the
offloadable features to be automatically enabled if offloading is
turned on after device creation.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/8b32c3011d269d6f149724e80c1ffe67c9534067.1730929545.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sabrina Dubroca and committed by
Jakub Kicinski
bd97c29f 01892701

+15 -2
+15 -2
drivers/net/macsec.c
··· 2666 2666 macsec_set_head_tail_room(dev); 2667 2667 macsec->insert_tx_tag = macsec_needs_tx_tag(macsec, ops); 2668 2668 2669 + netdev_update_features(dev); 2670 + 2669 2671 return ret; 2670 2672 } 2671 2673 ··· 3523 3521 #define MACSEC_FEATURES \ 3524 3522 (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST) 3525 3523 3524 + #define MACSEC_OFFLOAD_FEATURES \ 3525 + (MACSEC_FEATURES | NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES | \ 3526 + NETIF_F_LRO | NETIF_F_RXHASH | NETIF_F_CSUM_MASK | NETIF_F_RXCSUM) 3527 + 3526 3528 static int macsec_dev_init(struct net_device *dev) 3527 3529 { 3528 3530 struct macsec_dev *macsec = macsec_priv(dev); ··· 3537 3531 if (err) 3538 3532 return err; 3539 3533 3540 - dev->features = real_dev->features & MACSEC_FEATURES; 3534 + dev->hw_features = real_dev->hw_features & MACSEC_OFFLOAD_FEATURES; 3535 + dev->hw_features |= NETIF_F_GSO_SOFTWARE; 3536 + 3537 + dev->features = real_dev->features & MACSEC_OFFLOAD_FEATURES; 3541 3538 dev->features |= NETIF_F_GSO_SOFTWARE; 3542 3539 dev->lltx = true; 3543 3540 dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; ··· 3570 3561 { 3571 3562 struct macsec_dev *macsec = macsec_priv(dev); 3572 3563 struct net_device *real_dev = macsec->real_dev; 3564 + netdev_features_t mask; 3573 3565 3574 - features &= (real_dev->features & MACSEC_FEATURES) | 3566 + mask = macsec_is_offloaded(macsec) ? MACSEC_OFFLOAD_FEATURES 3567 + : MACSEC_FEATURES; 3568 + 3569 + features &= (real_dev->features & mask) | 3575 3570 NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES; 3576 3571 3577 3572 return features;