Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2026 17:20:23 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 87ca74de89e0 - main - mlx5: convert GET_TRUNK_IF() to function
Message-ID:  <699f2f57.37432.4a747006@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kib:

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

commit 87ca74de89e0ae96774674f7ae14d303fad5b780
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-01-29 00:25:01 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-25 17:19:36 +0000

    mlx5: convert GET_TRUNK_IF() to function
    
    Reviewed by:    slavash
    Tested by:      Wafa Hamzah <wafah@nvidia.com>
    Sponsored by:   Nvidia networking
    MFC after:      1 week
---
 sys/dev/mlx5/mlx5_accel/mlx5_ipsec.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_accel/mlx5_ipsec.c b/sys/dev/mlx5/mlx5_accel/mlx5_ipsec.c
index bdbad6a084d9..325c70969306 100644
--- a/sys/dev/mlx5/mlx5_accel/mlx5_ipsec.c
+++ b/sys/dev/mlx5/mlx5_accel/mlx5_ipsec.c
@@ -418,24 +418,30 @@ err_xfrm:
 	return err;
 }
 
-#define GET_TRUNK_IF(vifp, ifp, ept)          \
-	if (if_gettype(vifp) == IFT_L2VLAN) { \
-		NET_EPOCH_ENTER(ept);         \
-		ifp = VLAN_TRUNKDEV(vifp);    \
-		NET_EPOCH_EXIT(ept);          \
-	} else {                              \
-		ifp = vifp;                   \
+static struct ifnet *
+mlx5_get_trunk_if(struct ifnet *vifp)
+{
+	struct epoch_tracker et;
+	struct ifnet *res;
+
+	if (if_gettype(vifp) == IFT_L2VLAN) {
+		NET_EPOCH_ENTER(et);
+		res = VLAN_TRUNKDEV(vifp);
+		NET_EPOCH_EXIT(et);
+	} else {
+		res = vifp;
 	}
+	return (res);
+}
 
 static int
 mlx5e_if_sa_newkey(struct ifnet *ifpo, void *sav, u_int dev_spi, void **privp)
 {
 	struct mlx5e_ipsec_priv_bothdir *pb;
-	struct epoch_tracker et;
 	struct ifnet *ifp;
 	int error;
 
-	GET_TRUNK_IF(ifpo, ifp, et);
+	ifp = mlx5_get_trunk_if(ifpo);
 
 	pb = malloc(sizeof(struct mlx5e_ipsec_priv_bothdir), M_DEVBUF,
 	    M_WAITOK | M_ZERO);
@@ -478,10 +484,9 @@ static int
 mlx5e_if_sa_deinstall(struct ifnet *ifpo, u_int dev_spi, void *priv)
 {
 	struct mlx5e_ipsec_priv_bothdir pb, *pbp;
-	struct epoch_tracker et;
 	struct ifnet *ifp;
 
-	GET_TRUNK_IF(ifpo, ifp, et);
+	ifp = mlx5_get_trunk_if(ifpo);
 
 	pbp = priv;
 	pb = *(struct mlx5e_ipsec_priv_bothdir *)priv;
@@ -516,10 +521,9 @@ mlx5e_if_sa_cnt(struct ifnet *ifpo, void *sa, uint32_t drv_spi, void *priv,
 	struct mlx5e_ipsec_priv_bothdir *pb;
 	u64 packets_in, packets_out;
 	u64 bytes_in, bytes_out;
-	struct epoch_tracker et;
 	struct ifnet *ifp;
 
-	GET_TRUNK_IF(ifpo, ifp, et);
+	ifp = mlx5_get_trunk_if(ifpo);
 
 	pb = priv;
 	mlx5e_if_sa_cnt_one(ifp, sa, drv_spi, pb->priv_in,
@@ -652,12 +656,11 @@ mlx5e_if_spd_install(struct ifnet *ifpo, void *sp, void *inp1, void **ifdatap)
 {
 	struct mlx5e_ipsec_pol_entry *pol_entry;
 	struct mlx5e_priv *priv;
-	struct epoch_tracker et;
 	u16 vid = VLAN_NONE;
 	struct ifnet *ifp;
 	int err;
 
-	GET_TRUNK_IF(ifpo, ifp, et);
+	ifp = mlx5_get_trunk_if(ifpo);
 	if (if_gettype(ifpo) == IFT_L2VLAN)
 		VLAN_TAG(ifpo, &vid);
 	priv = if_getsoftc(ifp);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?699f2f57.37432.4a747006>