bnxt: Fix up ioctl opcodes to support IOC_VOID along with IOC_IN
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run

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
This commit is contained in:
Sumit Saxena 2026-01-09 10:28:53 +00:00
parent a556feb997
commit d53d7b4660
2 changed files with 14 additions and 6 deletions

View file

@ -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:

View file

@ -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)