git: d53d7b466016 - main - bnxt: Fix up ioctl opcodes to support IOC_VOID along with IOC_IN
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Jan 2026 10:43:12 UTC
The branch main has been updated by ssaxena:
URL: https://cgit.FreeBSD.org/src/commit/?id=d53d7b466016408229491cfd2f8bdc742ff642e3
commit d53d7b466016408229491cfd2f8bdc742ff642e3
Author: Sumit Saxena <ssaxena@FreeBSD.org>
AuthorDate: 2026-01-09 10:28:53 +0000
Commit: Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2026-01-09 10:40:18 +0000
bnxt: Fix up ioctl opcodes to support IOC_VOID along with IOC_IN
The driver and applications currently use hard-coded numeric ioctl command
opcodes. These opcodes are interpreted as having the IOC_IN direction (data
copied from the user application to the driver), regardless of the actual packet
size. Consequently, when the packet size is zero and the direction is set to
IOC_IN, the kernel fails these ioctls if COMPAT is disabled.
While the driver and applications should ideally set the direction correctly—
for example, using IOC_VOID when the packet size is zero—the driver will now
be updated to define ioctl opcodes using the _IOC macro to support both
IOC_VOID and IOC_IN. This change ensures backward compatibility with older
applications that exclusively use IOC_IN.
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D54601
MFC after: 3 days
---
sys/dev/bnxt/bnxt_en/bnxt_mgmt.c | 9 ++++++---
sys/dev/bnxt/bnxt_en/bnxt_mgmt.h | 11 ++++++++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
index bbc12b96d8c6..98ae9848c42b 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
@@ -387,15 +387,18 @@ bnxt_mgmt_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag,
int ret = 0;
switch(cmd) {
- case BNXT_MGMT_OPCODE_GET_DEV_INFO:
+ case IO_BNXT_MGMT_OPCODE_GET_DEV_INFO:
+ case IOW_BNXT_MGMT_OPCODE_GET_DEV_INFO:
ret = bnxt_mgmt_get_dev_info(dev, cmd, data, flag, td);
break;
- case BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM:
+ case IO_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM:
+ case IOW_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM:
mtx_lock(&mgmt_lock);
ret = bnxt_mgmt_process_hwrm(dev, cmd, data, flag, td);
mtx_unlock(&mgmt_lock);
break;
- case BNXT_MGMT_OPCODE_DCB_OPS:
+ case IO_BNXT_MGMT_OPCODE_DCB_OPS:
+ case IOW_BNXT_MGMT_OPCODE_DCB_OPS:
ret = bnxt_mgmt_process_dcb(dev, cmd, data, flag, td);
break;
default:
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
index 8489a223adef..5b94184b1646 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
@@ -39,9 +39,14 @@
#define DRIVER_NAME "if_bnxt"
-#define BNXT_MGMT_OPCODE_GET_DEV_INFO 0x80000000
-#define BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM 0x80000001
-#define BNXT_MGMT_OPCODE_DCB_OPS 0x80000002
+
+#define IOW_BNXT_MGMT_OPCODE_GET_DEV_INFO _IOW(0, 0, 0)
+#define IOW_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IOW(0, 1, 0)
+#define IOW_BNXT_MGMT_OPCODE_DCB_OPS _IOW(0, 2, 0)
+
+#define IO_BNXT_MGMT_OPCODE_GET_DEV_INFO _IO(0, 0)
+#define IO_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IO(0, 1)
+#define IO_BNXT_MGMT_OPCODE_DCB_OPS _IO(0, 2)
#define BNXT_MGMT_MAX_HWRM_REQ_LENGTH HWRM_MAX_REQ_LEN
#define BNXT_MGMT_MAX_HWRM_RESP_LENGTH (512)