developer | 7e32f7e | 2022-05-18 21:10:08 +0800 | [diff] [blame] | 1 | From c850240b6c4132574a00f2da439277ab94265b66 Mon Sep 17 00:00:00 2001 |
| 2 | From: Mark Starovoytov <mstarovoitov@marvell.com> |
| 3 | Date: Wed, 25 Mar 2020 15:52:38 +0300 |
| 4 | Subject: net: macsec: report real_dev features when HW offloading is enabled |
| 5 | |
| 6 | This patch makes real_dev_feature propagation by MACSec offloaded device. |
| 7 | |
| 8 | Issue description: |
| 9 | real_dev features are disabled upon macsec creation. |
| 10 | |
| 11 | Root cause: |
| 12 | Features limitation (specific to SW MACSec limitation) is being applied |
| 13 | to HW offloaded case as well. |
| 14 | This causes 'set_features' request on the real_dev with reduced feature |
| 15 | set due to chain propagation. |
| 16 | |
| 17 | Proposed solution: |
| 18 | Report real_dev features when HW offloading is enabled. |
| 19 | NB! MACSec offloaded device does not propagate VLAN offload features at |
| 20 | the moment. This can potentially be added later on as a separate patch. |
| 21 | |
| 22 | Note: this patch requires HW offloading to be enabled by default in order |
| 23 | to function properly. |
| 24 | |
| 25 | Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com> |
| 26 | Signed-off-by: Igor Russkikh <irusskikh@marvell.com> |
| 27 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 28 | --- |
| 29 | drivers/net/macsec.c | 26 ++++++++++++++++++++++---- |
| 30 | 1 file changed, 22 insertions(+), 4 deletions(-) |
| 31 | |
| 32 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
| 33 | index b00a078d13ffe..2dad91cba459c 100644 |
| 34 | --- a/drivers/net/macsec.c |
| 35 | +++ b/drivers/net/macsec.c |
| 36 | @@ -2633,6 +2633,10 @@ static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info) |
| 37 | goto rollback; |
| 38 | |
| 39 | rtnl_unlock(); |
| 40 | + /* Force features update, since they are different for SW MACSec and |
| 41 | + * HW offloading cases. |
| 42 | + */ |
| 43 | + netdev_update_features(dev); |
| 44 | return 0; |
| 45 | |
| 46 | rollback: |
| 47 | @@ -3399,9 +3403,16 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, |
| 48 | return ret; |
| 49 | } |
| 50 | |
| 51 | -#define MACSEC_FEATURES \ |
| 52 | +#define SW_MACSEC_FEATURES \ |
| 53 | (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST) |
| 54 | |
| 55 | +/* If h/w offloading is enabled, use real device features save for |
| 56 | + * VLAN_FEATURES - they require additional ops |
| 57 | + * HW_MACSEC - no reason to report it |
| 58 | + */ |
| 59 | +#define REAL_DEV_FEATURES(dev) \ |
| 60 | + ((dev)->features & ~(NETIF_F_VLAN_FEATURES | NETIF_F_HW_MACSEC)) |
| 61 | + |
| 62 | static int macsec_dev_init(struct net_device *dev) |
| 63 | { |
| 64 | struct macsec_dev *macsec = macsec_priv(dev); |
| 65 | @@ -3418,8 +3429,12 @@ static int macsec_dev_init(struct net_device *dev) |
| 66 | return err; |
| 67 | } |
| 68 | |
| 69 | - dev->features = real_dev->features & MACSEC_FEATURES; |
| 70 | - dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE; |
| 71 | + if (macsec_is_offloaded(macsec)) { |
| 72 | + dev->features = REAL_DEV_FEATURES(real_dev); |
| 73 | + } else { |
| 74 | + dev->features = real_dev->features & SW_MACSEC_FEATURES; |
| 75 | + dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE; |
| 76 | + } |
| 77 | |
| 78 | dev->needed_headroom = real_dev->needed_headroom + |
| 79 | MACSEC_NEEDED_HEADROOM; |
| 80 | @@ -3448,7 +3463,10 @@ static netdev_features_t macsec_fix_features(struct net_device *dev, |
| 81 | struct macsec_dev *macsec = macsec_priv(dev); |
| 82 | struct net_device *real_dev = macsec->real_dev; |
| 83 | |
| 84 | - features &= (real_dev->features & MACSEC_FEATURES) | |
| 85 | + if (macsec_is_offloaded(macsec)) |
| 86 | + return REAL_DEV_FEATURES(real_dev); |
| 87 | + |
| 88 | + features &= (real_dev->features & SW_MACSEC_FEATURES) | |
| 89 | NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES; |
| 90 | features |= NETIF_F_LLTX; |
| 91 | |
| 92 | -- |
| 93 | cgit 1.2.3-1.el7 |
| 94 | |