diff mbox series

[net] net: Allow NETIF_F_HW_TLS_TX if IP_CSUM && IPV6_CSUM

Message ID 20210114151215.7061-1-tariqt@nvidia.com (mailing list archive)
State Accepted
Commit 25537d71e2d007faf42a244a75e5a2bb7c356234
Delegated to: Netdev Maintainers
Headers show
Series [net] net: Allow NETIF_F_HW_TLS_TX if IP_CSUM && IPV6_CSUM | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 10 maintainers not CCed: andriin@fb.com corbet@lwn.net ap420073@gmail.com bjorn.topel@intel.com ast@kernel.org jiri@mellanox.com linux-doc@vger.kernel.org edumazet@google.com daniel@iogearbox.net xiyou.wangcong@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 10 this patch: 10
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 10 this patch: 10
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Tariq Toukan Jan. 14, 2021, 3:12 p.m. UTC
Cited patch below blocked the TLS TX device offload unless HW_CSUM
is set. This broke devices that use IP_CSUM && IP6_CSUM.
Here we fix it.

Note that the single HW_TLS_TX feature flag indicates support for
both IPv4/6, hence it should still be disabled in case only one of
(IP_CSUM | IPV6_CSUM) is set.

Fixes: ae0b04b238e2 ("net: Disable NETIF_F_HW_TLS_TX when HW_CSUM is disabled")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reported-by: Rohit Maheshwari <rohitm@chelsio.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@mellanox.com>
---
 Documentation/networking/tls-offload.rst |  2 +-
 net/core/dev.c                           | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Jan. 14, 2021, 7:30 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Thu, 14 Jan 2021 17:12:15 +0200 you wrote:
> Cited patch below blocked the TLS TX device offload unless HW_CSUM
> is set. This broke devices that use IP_CSUM && IP6_CSUM.
> Here we fix it.
> 
> Note that the single HW_TLS_TX feature flag indicates support for
> both IPv4/6, hence it should still be disabled in case only one of
> (IP_CSUM | IPV6_CSUM) is set.
> 
> [...]

Here is the summary with links:
  - [net] net: Allow NETIF_F_HW_TLS_TX if IP_CSUM && IPV6_CSUM
    https://git.kernel.org/netdev/net/c/25537d71e2d0

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

Patch

diff --git a/Documentation/networking/tls-offload.rst b/Documentation/networking/tls-offload.rst
index 0f55c6d540f9..9af3334d9ad0 100644
--- a/Documentation/networking/tls-offload.rst
+++ b/Documentation/networking/tls-offload.rst
@@ -530,7 +530,7 @@  TLS device feature flags only control adding of new TLS connection
 offloads, old connections will remain active after flags are cleared.
 
 TLS encryption cannot be offloaded to devices without checksum calculation
-offload. Hence, TLS TX device feature flag requires NETIF_F_HW_CSUM being set.
+offload. Hence, TLS TX device feature flag requires TX csum offload being set.
 Disabling the latter implies clearing the former. Disabling TX checksum offload
 should not affect old connections, and drivers should make sure checksum
 calculation does not break for them.
diff --git a/net/core/dev.c b/net/core/dev.c
index 0071a11a6dc3..c360bb5367e2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9661,9 +9661,15 @@  static netdev_features_t netdev_fix_features(struct net_device *dev,
 		}
 	}
 
-	if ((features & NETIF_F_HW_TLS_TX) && !(features & NETIF_F_HW_CSUM)) {
-		netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n");
-		features &= ~NETIF_F_HW_TLS_TX;
+	if (features & NETIF_F_HW_TLS_TX) {
+		bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) ==
+			(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+		bool hw_csum = features & NETIF_F_HW_CSUM;
+
+		if (!ip_csum && !hw_csum) {
+			netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n");
+			features &= ~NETIF_F_HW_TLS_TX;
+		}
 	}
 
 	return features;