git: 01143ba1189b - main - ifcapnv: fix IFCAP2 usage
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Jan 2023 09:58:47 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=01143ba1189b5a2cbbe58cd3eea4c2eb22e04e57
commit 01143ba1189b5a2cbbe58cd3eea4c2eb22e04e57
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-12-23 17:30:11 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-03 09:48:16 +0000
ifcapnv: fix IFCAP2 usage
IFCAP2_XXX constants are integers, they do not need shift for the
definition. But their usage as bitmask for if_capenable2 does require
shift. Add convenience macro IFCAP2_BIT() for consumers.
Fix the only existing consumer, mlx5(4) RXTLS enable bits.
Reported by: jhb
Reviewed by: jhb, jhibbits, hselasky
Coverity CID: 1501659
Sponsored by: NVIDIA networking
Differential revision: https://reviews.freebsd.org/D37862
---
sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 11 ++++++-----
sys/net/if.h | 7 ++++---
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 47bf627ed7af..04e3c302005b 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -3664,10 +3664,10 @@ siocsifcap_driver:
}
}
mask = drv_ioctl_data->reqcap2 ^ ifp->if_capenable2;
- if (mask & IFCAP2_RXTLS4)
- ifp->if_capenable2 ^= IFCAP2_RXTLS4;
- if (mask & IFCAP2_RXTLS6)
- ifp->if_capenable2 ^= IFCAP2_RXTLS6;
+ if ((mask & IFCAP2_BIT(IFCAP2_RXTLS4)) != 0)
+ ifp->if_capenable2 ^= IFCAP2_BIT(IFCAP2_RXTLS4);
+ if ((mask & IFCAP2_BIT(IFCAP2_RXTLS6)) != 0)
+ ifp->if_capenable2 ^= IFCAP2_BIT(IFCAP2_RXTLS6);
out:
PRIV_UNLOCK(priv);
break;
@@ -4550,7 +4550,8 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
ifp->if_capabilities |= IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT;
#endif
ifp->if_capabilities |= IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO;
- ifp->if_capabilities2 |= IFCAP2_RXTLS4 | IFCAP2_RXTLS6;
+ ifp->if_capabilities2 |= IFCAP2_BIT(IFCAP2_RXTLS4) |
+ IFCAP2_BIT(IFCAP2_RXTLS6);
ifp->if_snd_tag_alloc = mlx5e_snd_tag_alloc;
#ifdef RATELIMIT
ifp->if_ratelimit_query = mlx5e_ratelimit_query;
diff --git a/sys/net/if.h b/sys/net/if.h
index 0faf159ff1aa..b39eb933993c 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -255,8 +255,10 @@ struct if_data {
#define IFCAP_TXTLS_RTLMT 0x80000000 /* can do TLS with rate limiting */
/* IFCAP2_* are integers, not bits. */
-#define IFCAP2_RXTLS4 (0x00001ULL << 32)
-#define IFCAP2_RXTLS6 (0x00002ULL << 32)
+#define IFCAP2_RXTLS4 0
+#define IFCAP2_RXTLS6 1
+
+#define IFCAP2_BIT(x) (1UL << (x))
#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
@@ -265,7 +267,6 @@ struct if_data {
#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
#define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6)
#define IFCAP_TXTLS (IFCAP_TXTLS4 | IFCAP_TXTLS6)
-#define IFCAP2_RXTLS (IFCAP2_RXTLS4 | IFCAP2_RXTLS6)
#define IFCAP_CANTCHANGE (IFCAP_NETMAP | IFCAP_NV)
#define IFCAP_ALLCAPS 0xffffffff