Message ID | 20240819075334.236334-3-liuhangbin@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Bonding: support new xfrm state offload functions | expand |
On 19/08/2024 10:53, Hangbin Liu wrote: > Currently, users can see that bonding supports IPSec HW offload via ethtool. > However, this functionality does not work with NICs like Mellanox cards when > ESN (Extended Sequence Numbers) is enabled, as ESN functions are not yet > supported. This patch adds ESN support to the bonding IPSec device offload, > ensuring proper functionality with NICs that support ESN. > > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> > --- > drivers/net/bonding/bond_main.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 250a2717b4e9..3c04bdba17d4 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -646,10 +646,35 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) > return err; > } > > +/** > + * bond_advance_esn_state - ESN support for IPSec HW offload > + * @xs: pointer to transformer state struct > + **/ > +static void bond_advance_esn_state(struct xfrm_state *xs) > +{ > + struct net_device *real_dev; > + > + rcu_read_lock(); > + real_dev = bond_ipsec_dev(xs); > + if (!real_dev) > + goto out; > + > + if (!real_dev->xfrmdev_ops || > + !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { > + pr_warn("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); > + goto out; > + } > + > + rhel_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); > +out: > + rcu_read_unlock(); > +} > + > static const struct xfrmdev_ops bond_xfrmdev_ops = { > .xdo_dev_state_add = bond_ipsec_add_sa, > .xdo_dev_state_delete = bond_ipsec_del_sa, > .xdo_dev_offload_ok = bond_ipsec_offload_ok, > + .xdo_dev_state_advance_esn = bond_advance_esn_state, > }; > #endif /* CONFIG_XFRM_OFFLOAD */ > Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Hi Hangbin, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Hangbin-Liu/bonding-add-common-function-to-check-ipsec-device/20240819-195504 base: net-next/main patch link: https://lore.kernel.org/r/20240819075334.236334-3-liuhangbin%40gmail.com patch subject: [PATCHv2 net-next 2/3] bonding: Add ESN support to IPSec HW offload config: x86_64-buildonly-randconfig-001-20240820 (https://download.01.org/0day-ci/archive/20240820/202408200431.wjjkEZ2m-lkp@intel.com/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408200431.wjjkEZ2m-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202408200431.wjjkEZ2m-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/net/bonding/bond_main.c:434:10: error: returning 'void *' from a function with incompatible result type 'struct net_device' 434 | return NULL; | ^~~~ include/linux/stddef.h:8:14: note: expanded from macro 'NULL' 8 | #define NULL ((void *)0) | ^~~~~~~~~~~ drivers/net/bonding/bond_main.c:442:10: error: returning 'void *' from a function with incompatible result type 'struct net_device' 442 | return NULL; | ^~~~ include/linux/stddef.h:8:14: note: expanded from macro 'NULL' 8 | #define NULL ((void *)0) | ^~~~~~~~~~~ drivers/net/bonding/bond_main.c:446:9: error: returning 'struct net_device *' from a function with incompatible result type 'struct net_device'; dereference with * 446 | return real_dev; | ^~~~~~~~ | * drivers/net/bonding/bond_main.c:630:11: error: assigning to 'struct net_device *' from incompatible type 'struct net_device' 630 | real_dev = bond_ipsec_dev(xs); | ^ ~~~~~~~~~~~~~~~~~~ drivers/net/bonding/bond_main.c:658:11: error: assigning to 'struct net_device *' from incompatible type 'struct net_device' 658 | real_dev = bond_ipsec_dev(xs); | ^ ~~~~~~~~~~~~~~~~~~ >> drivers/net/bonding/bond_main.c:668:2: error: use of undeclared identifier 'rhel_dev'; did you mean 'real_dev'? 668 | rhel_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); | ^~~~~~~~ | real_dev drivers/net/bonding/bond_main.c:655:21: note: 'real_dev' declared here 655 | struct net_device *real_dev; | ^ 6 errors generated. vim +668 drivers/net/bonding/bond_main.c 648 649 /** 650 * bond_advance_esn_state - ESN support for IPSec HW offload 651 * @xs: pointer to transformer state struct 652 **/ 653 static void bond_advance_esn_state(struct xfrm_state *xs) 654 { 655 struct net_device *real_dev; 656 657 rcu_read_lock(); 658 real_dev = bond_ipsec_dev(xs); 659 if (!real_dev) 660 goto out; 661 662 if (!real_dev->xfrmdev_ops || 663 !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { 664 pr_warn("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); 665 goto out; 666 } 667 > 668 rhel_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); 669 out: 670 rcu_read_unlock(); 671 } 672
On Tue, Aug 20, 2024 at 05:17:52AM +0800, kernel test robot wrote: > Hi Hangbin, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on net-next/main] > > url: https://github.com/intel-lab-lkp/linux/commits/Hangbin-Liu/bonding-add-common-function-to-check-ipsec-device/20240819-195504 > base: net-next/main > patch link: https://lore.kernel.org/r/20240819075334.236334-3-liuhangbin%40gmail.com > patch subject: [PATCHv2 net-next 2/3] bonding: Add ESN support to IPSec HW offload > config: x86_64-buildonly-randconfig-001-20240820 (https://download.01.org/0day-ci/archive/20240820/202408200431.wjjkEZ2m-lkp@intel.com/config) > compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408200431.wjjkEZ2m-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202408200431.wjjkEZ2m-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > drivers/net/bonding/bond_main.c:434:10: error: returning 'void *' from a function with incompatible result type 'struct net_device' > 434 | return NULL; > | ^~~~ > include/linux/stddef.h:8:14: note: expanded from macro 'NULL' > 8 | #define NULL ((void *)0) > | ^~~~~~~~~~~ > drivers/net/bonding/bond_main.c:442:10: error: returning 'void *' from a function with incompatible result type 'struct net_device' > 442 | return NULL; > | ^~~~ > include/linux/stddef.h:8:14: note: expanded from macro 'NULL' > 8 | #define NULL ((void *)0) > | ^~~~~~~~~~~ > drivers/net/bonding/bond_main.c:446:9: error: returning 'struct net_device *' from a function with incompatible result type 'struct net_device'; dereference with * > 446 | return real_dev; > | ^~~~~~~~ > | * > drivers/net/bonding/bond_main.c:630:11: error: assigning to 'struct net_device *' from incompatible type 'struct net_device' > 630 | real_dev = bond_ipsec_dev(xs); > | ^ ~~~~~~~~~~~~~~~~~~ > drivers/net/bonding/bond_main.c:658:11: error: assigning to 'struct net_device *' from incompatible type 'struct net_device' > 658 | real_dev = bond_ipsec_dev(xs); > | ^ ~~~~~~~~~~~~~~~~~~ > >> drivers/net/bonding/bond_main.c:668:2: error: use of undeclared identifier 'rhel_dev'; did you mean 'real_dev'? Hmm, weird... I tried to build the patch via `vng` before post, with CONFIG_XFRM_OFFLOAD=y in tools/testing/selftests/drivers/net/bonding/config. But looks it's not build in. Next time I need to double check.. Thanks Hangbin
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 250a2717b4e9..3c04bdba17d4 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -646,10 +646,35 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) return err; } +/** + * bond_advance_esn_state - ESN support for IPSec HW offload + * @xs: pointer to transformer state struct + **/ +static void bond_advance_esn_state(struct xfrm_state *xs) +{ + struct net_device *real_dev; + + rcu_read_lock(); + real_dev = bond_ipsec_dev(xs); + if (!real_dev) + goto out; + + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { + pr_warn("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); + goto out; + } + + rhel_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); +out: + rcu_read_unlock(); +} + static const struct xfrmdev_ops bond_xfrmdev_ops = { .xdo_dev_state_add = bond_ipsec_add_sa, .xdo_dev_state_delete = bond_ipsec_del_sa, .xdo_dev_offload_ok = bond_ipsec_offload_ok, + .xdo_dev_state_advance_esn = bond_advance_esn_state, }; #endif /* CONFIG_XFRM_OFFLOAD */
Currently, users can see that bonding supports IPSec HW offload via ethtool. However, this functionality does not work with NICs like Mellanox cards when ESN (Extended Sequence Numbers) is enabled, as ESN functions are not yet supported. This patch adds ESN support to the bonding IPSec device offload, ensuring proper functionality with NICs that support ESN. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> --- drivers/net/bonding/bond_main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)