Skip to content

Commit c850240

Browse files
mstarovodavem330
authored andcommitted
net: macsec: report real_dev features when HW offloading is enabled
This patch makes real_dev_feature propagation by MACSec offloaded device. Issue description: real_dev features are disabled upon macsec creation. Root cause: Features limitation (specific to SW MACSec limitation) is being applied to HW offloaded case as well. This causes 'set_features' request on the real_dev with reduced feature set due to chain propagation. Proposed solution: Report real_dev features when HW offloading is enabled. NB! MACSec offloaded device does not propagate VLAN offload features at the moment. This can potentially be added later on as a separate patch. Note: this patch requires HW offloading to be enabled by default in order to function properly. Signed-off-by: Mark Starovoytov <[email protected]> Signed-off-by: Igor Russkikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b62c362 commit c850240

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

drivers/net/macsec.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,10 @@ static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info)
26332633
goto rollback;
26342634

26352635
rtnl_unlock();
2636+
/* Force features update, since they are different for SW MACSec and
2637+
* HW offloading cases.
2638+
*/
2639+
netdev_update_features(dev);
26362640
return 0;
26372641

26382642
rollback:
@@ -3399,9 +3403,16 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
33993403
return ret;
34003404
}
34013405

3402-
#define MACSEC_FEATURES \
3406+
#define SW_MACSEC_FEATURES \
34033407
(NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST)
34043408

3409+
/* If h/w offloading is enabled, use real device features save for
3410+
* VLAN_FEATURES - they require additional ops
3411+
* HW_MACSEC - no reason to report it
3412+
*/
3413+
#define REAL_DEV_FEATURES(dev) \
3414+
((dev)->features & ~(NETIF_F_VLAN_FEATURES | NETIF_F_HW_MACSEC))
3415+
34053416
static int macsec_dev_init(struct net_device *dev)
34063417
{
34073418
struct macsec_dev *macsec = macsec_priv(dev);
@@ -3418,8 +3429,12 @@ static int macsec_dev_init(struct net_device *dev)
34183429
return err;
34193430
}
34203431

3421-
dev->features = real_dev->features & MACSEC_FEATURES;
3422-
dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE;
3432+
if (macsec_is_offloaded(macsec)) {
3433+
dev->features = REAL_DEV_FEATURES(real_dev);
3434+
} else {
3435+
dev->features = real_dev->features & SW_MACSEC_FEATURES;
3436+
dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE;
3437+
}
34233438

34243439
dev->needed_headroom = real_dev->needed_headroom +
34253440
MACSEC_NEEDED_HEADROOM;
@@ -3448,7 +3463,10 @@ static netdev_features_t macsec_fix_features(struct net_device *dev,
34483463
struct macsec_dev *macsec = macsec_priv(dev);
34493464
struct net_device *real_dev = macsec->real_dev;
34503465

3451-
features &= (real_dev->features & MACSEC_FEATURES) |
3466+
if (macsec_is_offloaded(macsec))
3467+
return REAL_DEV_FEATURES(real_dev);
3468+
3469+
features &= (real_dev->features & SW_MACSEC_FEATURES) |
34523470
NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES;
34533471
features |= NETIF_F_LLTX;
34543472

0 commit comments

Comments
 (0)