netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] bonding: Correctly support GSO ESP offload
@ 2025-01-27 10:41 Cosmin Ratiu
  2025-01-27 10:45 ` Cosmin Ratiu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Cosmin Ratiu @ 2025-01-27 10:41 UTC (permalink / raw)
  To: netdev
  Cc: Jay Vosburgh, Nikolay Aleksandrov, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jianbo Liu,
	Boris Pismenny, Tariq Toukan, linux-kselftest, Hangbin Liu,
	Liang Li, Cosmin Ratiu

The referenced fix is incomplete. It correctly computes
bond_dev->gso_partial_features across slaves, but unfortunately
netdev_fix_features discards gso_partial_features from the feature set
if NETIF_F_GSO_PARTIAL isn't set in bond_dev->features.

This is visible with ethtool -k bond0 | grep esp:
tx-esp-segmentation: off [requested on]
esp-hw-offload: on
esp-tx-csum-hw-offload: on

This patch reworks the bonding GSO offload support by:
- making aggregating gso_partial_features across slaves similar to the
  other feature sets (this part is a no-op).
- advertising the default partial gso features on empty bond devs, same
  as with other feature sets (also a no-op).
- adding NETIF_F_GSO_PARTIAL to hw_enc_features filtered across slaves.
- adding NETIF_F_GSO_PARTIAL to features in bond_setup()

With all of these, 'ethtool -k bond0 | grep esp' now reports:
tx-esp-segmentation: on
esp-hw-offload: on
esp-tx-csum-hw-offload: on

Fixes: 4861333b4217 ("bonding: add ESP offload features when slaves support")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
---
 drivers/net/bonding/bond_main.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7b78c2bada81..e45bba240cbc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1538,17 +1538,20 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
 				 NETIF_F_HIGHDMA | NETIF_F_LRO)
 
 #define BOND_ENC_FEATURES	(NETIF_F_HW_CSUM | NETIF_F_SG | \
-				 NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE)
+				 NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE | \
+				 NETIF_F_GSO_PARTIAL)
 
 #define BOND_MPLS_FEATURES	(NETIF_F_HW_CSUM | NETIF_F_SG | \
 				 NETIF_F_GSO_SOFTWARE)
 
+#define BOND_GSO_PARTIAL_FEATURES (NETIF_F_GSO_ESP)
+
 
 static void bond_compute_features(struct bonding *bond)
 {
+	netdev_features_t gso_partial_features = BOND_GSO_PARTIAL_FEATURES;
 	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
 					IFF_XMIT_DST_RELEASE_PERM;
-	netdev_features_t gso_partial_features = NETIF_F_GSO_ESP;
 	netdev_features_t vlan_features = BOND_VLAN_FEATURES;
 	netdev_features_t enc_features  = BOND_ENC_FEATURES;
 #ifdef CONFIG_XFRM_OFFLOAD
@@ -1582,8 +1585,9 @@ static void bond_compute_features(struct bonding *bond)
 							  BOND_XFRM_FEATURES);
 #endif /* CONFIG_XFRM_OFFLOAD */
 
-		if (slave->dev->hw_enc_features & NETIF_F_GSO_PARTIAL)
-			gso_partial_features &= slave->dev->gso_partial_features;
+		gso_partial_features = netdev_increment_features(gso_partial_features,
+								 slave->dev->gso_partial_features,
+								 BOND_GSO_PARTIAL_FEATURES);
 
 		mpls_features = netdev_increment_features(mpls_features,
 							  slave->dev->mpls_features,
@@ -1598,12 +1602,8 @@ static void bond_compute_features(struct bonding *bond)
 	}
 	bond_dev->hard_header_len = max_hard_header_len;
 
-	if (gso_partial_features & NETIF_F_GSO_ESP)
-		bond_dev->gso_partial_features |= NETIF_F_GSO_ESP;
-	else
-		bond_dev->gso_partial_features &= ~NETIF_F_GSO_ESP;
-
 done:
+	bond_dev->gso_partial_features = gso_partial_features;
 	bond_dev->vlan_features = vlan_features;
 	bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
 				    NETIF_F_HW_VLAN_CTAG_TX |
@@ -6046,6 +6046,7 @@ void bond_setup(struct net_device *bond_dev)
 	bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
 	bond_dev->features |= bond_dev->hw_features;
 	bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
+	bond_dev->features |= NETIF_F_GSO_PARTIAL;
 #ifdef CONFIG_XFRM_OFFLOAD
 	bond_dev->hw_features |= BOND_XFRM_FEATURES;
 	/* Only enable XFRM features if this is an active-backup config */
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3] bonding: Correctly support GSO ESP offload
  2025-01-27 10:41 [PATCH net v3] bonding: Correctly support GSO ESP offload Cosmin Ratiu
@ 2025-01-27 10:45 ` Cosmin Ratiu
  2025-01-27 13:27   ` Hangbin Liu
  2025-01-27 23:25 ` Jay Vosburgh
  2025-01-28 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Cosmin Ratiu @ 2025-01-27 10:45 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: liuhangbin@gmail.com, razor@blackwall.org, davem@davemloft.net,
	Tariq Toukan, linux-kselftest@vger.kernel.org, liali@redhat.com,
	jv@jvosburgh.net, pabeni@redhat.com, horms@kernel.org, Jianbo Liu,
	edumazet@google.com, Boris Pismenny, kuba@kernel.org

Same as v2, but I added Hangbin to 'Signed-off-by'.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3] bonding: Correctly support GSO ESP offload
  2025-01-27 10:45 ` Cosmin Ratiu
@ 2025-01-27 13:27   ` Hangbin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Hangbin Liu @ 2025-01-27 13:27 UTC (permalink / raw)
  To: Cosmin Ratiu
  Cc: netdev@vger.kernel.org, razor@blackwall.org, davem@davemloft.net,
	Tariq Toukan, linux-kselftest@vger.kernel.org, liali@redhat.com,
	jv@jvosburgh.net, pabeni@redhat.com, horms@kernel.org, Jianbo Liu,
	edumazet@google.com, Boris Pismenny, kuba@kernel.org

On Mon, Jan 27, 2025 at 10:45:21AM +0000, Cosmin Ratiu wrote:
> Same as v2, but I added Hangbin to 'Signed-off-by'.
> 

Thanks for adding me to 'Signed-off-by'. Next time you can add the change
log in the patch directly. e.g.

Commit description
---
v3 changes
v2 changes
---

Codes ...


Thanks
Hangbin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3] bonding: Correctly support GSO ESP offload
  2025-01-27 10:41 [PATCH net v3] bonding: Correctly support GSO ESP offload Cosmin Ratiu
  2025-01-27 10:45 ` Cosmin Ratiu
@ 2025-01-27 23:25 ` Jay Vosburgh
  2025-01-28 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Jay Vosburgh @ 2025-01-27 23:25 UTC (permalink / raw)
  To: Cosmin Ratiu
  Cc: netdev, Nikolay Aleksandrov, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jianbo Liu,
	Boris Pismenny, Tariq Toukan, linux-kselftest, Hangbin Liu,
	Liang Li

Cosmin Ratiu <cratiu@nvidia.com> wrote:

>The referenced fix is incomplete. It correctly computes
>bond_dev->gso_partial_features across slaves, but unfortunately
>netdev_fix_features discards gso_partial_features from the feature set
>if NETIF_F_GSO_PARTIAL isn't set in bond_dev->features.
>
>This is visible with ethtool -k bond0 | grep esp:
>tx-esp-segmentation: off [requested on]
>esp-hw-offload: on
>esp-tx-csum-hw-offload: on
>
>This patch reworks the bonding GSO offload support by:
>- making aggregating gso_partial_features across slaves similar to the
>  other feature sets (this part is a no-op).
>- advertising the default partial gso features on empty bond devs, same
>  as with other feature sets (also a no-op).
>- adding NETIF_F_GSO_PARTIAL to hw_enc_features filtered across slaves.
>- adding NETIF_F_GSO_PARTIAL to features in bond_setup()
>
>With all of these, 'ethtool -k bond0 | grep esp' now reports:
>tx-esp-segmentation: on
>esp-hw-offload: on
>esp-tx-csum-hw-offload: on
>
>Fixes: 4861333b4217 ("bonding: add ESP offload features when slaves support")
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
>Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>

Acked-by: Jay Vosburgh <jv@jvosburgh.net>


>---
> drivers/net/bonding/bond_main.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 7b78c2bada81..e45bba240cbc 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -1538,17 +1538,20 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
> 				 NETIF_F_HIGHDMA | NETIF_F_LRO)
> 
> #define BOND_ENC_FEATURES	(NETIF_F_HW_CSUM | NETIF_F_SG | \
>-				 NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE)
>+				 NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE | \
>+				 NETIF_F_GSO_PARTIAL)
> 
> #define BOND_MPLS_FEATURES	(NETIF_F_HW_CSUM | NETIF_F_SG | \
> 				 NETIF_F_GSO_SOFTWARE)
> 
>+#define BOND_GSO_PARTIAL_FEATURES (NETIF_F_GSO_ESP)
>+
> 
> static void bond_compute_features(struct bonding *bond)
> {
>+	netdev_features_t gso_partial_features = BOND_GSO_PARTIAL_FEATURES;
> 	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
> 					IFF_XMIT_DST_RELEASE_PERM;
>-	netdev_features_t gso_partial_features = NETIF_F_GSO_ESP;
> 	netdev_features_t vlan_features = BOND_VLAN_FEATURES;
> 	netdev_features_t enc_features  = BOND_ENC_FEATURES;
> #ifdef CONFIG_XFRM_OFFLOAD
>@@ -1582,8 +1585,9 @@ static void bond_compute_features(struct bonding *bond)
> 							  BOND_XFRM_FEATURES);
> #endif /* CONFIG_XFRM_OFFLOAD */
> 
>-		if (slave->dev->hw_enc_features & NETIF_F_GSO_PARTIAL)
>-			gso_partial_features &= slave->dev->gso_partial_features;
>+		gso_partial_features = netdev_increment_features(gso_partial_features,
>+								 slave->dev->gso_partial_features,
>+								 BOND_GSO_PARTIAL_FEATURES);
> 
> 		mpls_features = netdev_increment_features(mpls_features,
> 							  slave->dev->mpls_features,
>@@ -1598,12 +1602,8 @@ static void bond_compute_features(struct bonding *bond)
> 	}
> 	bond_dev->hard_header_len = max_hard_header_len;
> 
>-	if (gso_partial_features & NETIF_F_GSO_ESP)
>-		bond_dev->gso_partial_features |= NETIF_F_GSO_ESP;
>-	else
>-		bond_dev->gso_partial_features &= ~NETIF_F_GSO_ESP;
>-
> done:
>+	bond_dev->gso_partial_features = gso_partial_features;
> 	bond_dev->vlan_features = vlan_features;
> 	bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
> 				    NETIF_F_HW_VLAN_CTAG_TX |
>@@ -6046,6 +6046,7 @@ void bond_setup(struct net_device *bond_dev)
> 	bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
> 	bond_dev->features |= bond_dev->hw_features;
> 	bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
>+	bond_dev->features |= NETIF_F_GSO_PARTIAL;
> #ifdef CONFIG_XFRM_OFFLOAD
> 	bond_dev->hw_features |= BOND_XFRM_FEATURES;
> 	/* Only enable XFRM features if this is an active-backup config */
>-- 
>2.45.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3] bonding: Correctly support GSO ESP offload
  2025-01-27 10:41 [PATCH net v3] bonding: Correctly support GSO ESP offload Cosmin Ratiu
  2025-01-27 10:45 ` Cosmin Ratiu
  2025-01-27 23:25 ` Jay Vosburgh
@ 2025-01-28 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-28 12:30 UTC (permalink / raw)
  To: Cosmin Ratiu
  Cc: netdev, jv, razor, davem, edumazet, kuba, pabeni, horms, jianbol,
	borisp, tariqt, linux-kselftest, liuhangbin, liali

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 27 Jan 2025 12:41:47 +0200 you wrote:
> The referenced fix is incomplete. It correctly computes
> bond_dev->gso_partial_features across slaves, but unfortunately
> netdev_fix_features discards gso_partial_features from the feature set
> if NETIF_F_GSO_PARTIAL isn't set in bond_dev->features.
> 
> This is visible with ethtool -k bond0 | grep esp:
> tx-esp-segmentation: off [requested on]
> esp-hw-offload: on
> esp-tx-csum-hw-offload: on
> 
> [...]

Here is the summary with links:
  - [net,v3] bonding: Correctly support GSO ESP offload
    https://git.kernel.org/netdev/net/c/9e6c4e6b605c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-28 12:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 10:41 [PATCH net v3] bonding: Correctly support GSO ESP offload Cosmin Ratiu
2025-01-27 10:45 ` Cosmin Ratiu
2025-01-27 13:27   ` Hangbin Liu
2025-01-27 23:25 ` Jay Vosburgh
2025-01-28 12:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).