git: f16b81e620c6 - stable/14 - mlx5en: only enable to toggle offload caps if they are supported

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 03 Dec 2024 00:51:32 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f16b81e620c613f509ed5bf66b7f96f87928bb1c

commit f16b81e620c613f509ed5bf66b7f96f87928bb1c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-11-21 06:06:01 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-12-03 00:39:23 +0000

    mlx5en: only enable to toggle offload caps if they are supported
    
    (cherry picked from commit 4cc5d081d8c23020130c5f30ed31f79fa105de74)
---
 sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 58d305dd43f3..0e1de4d304a9 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -3537,6 +3537,20 @@ mlx5e_ioctl(if_t ifp, u_long command, caddr_t data)
 		drv_ioctl_data = (struct siocsifcapnv_driver_data *)data;
 		PRIV_LOCK(priv);
 siocsifcap_driver:
+		if (!mlx5e_is_tlstx_capable(priv->mdev)) {
+			drv_ioctl_data->reqcap &= ~(IFCAP_TXTLS4 |
+			    IFCAP_TXTLS6);
+		}
+		if (!mlx5e_is_tlsrx_capable(priv->mdev)) {
+		        drv_ioctl_data->reqcap &= ~(
+			    IFCAP2_BIT(IFCAP2_RXTLS4) |
+			    IFCAP2_BIT(IFCAP2_RXTLS6));
+		}
+		if (!mlx5e_is_ratelimit_capable(priv->mdev)) {
+			drv_ioctl_data->reqcap &= ~(IFCAP_TXTLS_RTLMT |
+			    IFCAP_TXRTLMT);
+		}
+
 		mask = drv_ioctl_data->reqcap ^ if_getcapenable(ifp);
 
 		if (mask & IFCAP_TXCSUM) {