git: 42988358a921 - main - if_bnxt: add bnxt_compat.h version-compat shim
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Oct 2026 10:12:39 UTC
The branch main has been updated by ssaxena:
URL: https://cgit.FreeBSD.org/src/commit/?id=42988358a9210ccf7ff500895785b49fe5615567
commit 42988358a9210ccf7ff500895785b49fe5615567
Author: Sumit Saxena <sumit.saxena@broadcom.com>
AuthorDate: 2026-07-29 12:13:39 +0000
Commit: Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2026-10-09 08:24:43 +0000
if_bnxt: add bnxt_compat.h version-compat shim
Add bnxt_compat.h, a small __FreeBSD_version-gated compatibility
shim: if_getmtu()/if_name()/if_getsoftc()/if_getflags() fallbacks for
pre-1500000, and a config-task vs. config-gtask abstraction over the
iflib API split at 1403000. On this branch's FreeBSD version it also
unconditionally enables KTLS_IFLIB_SUPPORT/KTLS_REC_SEQ_NUMBER, which
the upcoming kTLS patch depends on.
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D58604
---
sys/dev/bnxt/bnxt_en/bnxt.h | 1 +
sys/dev/bnxt/bnxt_en/bnxt_compat.h | 87 ++++++++++++++++++++++++++++++++++++++
sys/modules/bnxt/bnxt_en/Makefile | 1 +
3 files changed, 89 insertions(+)
diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h
index 1de100915f97..04f0f0bf20ec 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt.h
@@ -45,6 +45,7 @@
#include <net/iflib.h>
#include <linux/types.h>
+#include "bnxt_compat.h"
#include "hsi_struct_def.h"
#include "bnxt_dcb.h"
#include "bnxt_auxbus_compat.h"
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_compat.h b/sys/dev/bnxt/bnxt_en/bnxt_compat.h
new file mode 100644
index 000000000000..0a1c47b6cd92
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_compat.h
@@ -0,0 +1,87 @@
+/*
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifndef BNXT_COMPAT_H
+#define BNXT_COMPAT_H
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/taskqueue.h>
+#include <sys/bitstring.h>
+
+#include <machine/bus.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/iflib.h>
+#include <linux/types.h>
+
+
+#if (__FreeBSD_version < 1500000)
+
+#define if_getmtu(ifp) (ifp)->if_mtu
+#ifndef if_name
+#define if_name(ifp) (ifp)->if_xname
+#endif
+#define if_getsoftc(ifp) (ifp)->if_softc
+#define if_getflags(ifp) (ifp)->if_flags
+
+#endif
+
+
+#if (__FreeBSD_version >= 1403000)
+
+#define BNXT_CP_TASK_TYPE struct task
+#define BNXT_CP_TASK_FUNC(name) void name(void *context, int pending)
+#define BNXT_CP_TASK_INIT(ctx, task, func) \
+ iflib_config_task_init(ctx, task, func)
+#define BNXT_CP_TASK_ENQUEUE(ctx, task) \
+ iflib_config_task_enqueue(ctx, task)
+
+#else
+
+#define BNXT_CP_TASK_TYPE struct grouptask
+#define BNXT_CP_TASK_FUNC(name) void name(void *context)
+#define BNXT_CP_TASK_INIT(ctx, task, func) \
+ iflib_config_gtask_init(ctx, task, func, "dflt_cp")
+#define BNXT_CP_TASK_ENQUEUE(ctx, task) \
+ GROUPTASK_ENQUEUE(task)
+
+#endif
+
+#if (__FreeBSD_version >= 1600007)
+#define KTLS_IFLIB_SUPPORT
+#define KTLS_REC_SEQ_NUMBER
+#endif
+
+#endif /* BNXT_COMPAT_H */
diff --git a/sys/modules/bnxt/bnxt_en/Makefile b/sys/modules/bnxt/bnxt_en/Makefile
index e0d371c264de..57958d0c5922 100644
--- a/sys/modules/bnxt/bnxt_en/Makefile
+++ b/sys/modules/bnxt/bnxt_en/Makefile
@@ -16,6 +16,7 @@ SRCS += bnxt_log_data.c bnxt_log_data.h
SRCS += bnxt_coredump.c bnxt_coredump.h
SRCS += bnxt_ptp.c bnxt_ptp.h
SRCS += bnxt_mpc.c bnxt_mpc.h
+SRCS += bnxt_compat.h
SRCS += ${LINUXKPI_GENSRCS}
CFLAGS+= -DIFLIB