Page MenuHomeFreeBSD

nvme: Add Linux copatible ioctls
ClosedPublic

Authored by imp on May 30 2024, 6:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 29, 9:16 PM
Unknown Object (File)
Fri, Jun 14, 11:06 PM
Unknown Object (File)
May 31 2024, 6:36 PM
Subscribers

Details

Summary

Add the NVME_IOCTL_ID, NVME_IOCTL_ADMIN_CMD, and NVME_IOCTL_IO_CMD Linux
compatible ioctls. These may be run on either an I/O (ns) dev or a nvme
(admin) dev. Linux allows both on either device, and programs use this
and aren't careful about having the right device open. Emulate this
feature, and implement these ioctls. The data is passed in into the
kernel in host byte order (not converted to le). Results are returned in
host order.

The timeout field is ignore, and the metadata and metadata_len fields
must be zero.

The addr field can be null, even when the data_len is non zero (FreeBSD's
ioctl interface prohibits this, Linux's just ignores the inconsistency).

Only the cdw10 is returned from the command: the status is not returned
in 'result' field. XXX need to verify that this is what Linux does on an
error signaled from the drive.

No external include file is yet available for this: most programs that
call this interface either use a linux-specific path <linux/nvme.h> or
have their own private copy of the data. It's unclear the best thing to
do.

Also, create a /dev/nvmeXnY as an alias for /dev/nvmeXnsY.

These changes allow a native build of nvme-cli to work for everything
that doesn't depend on sysfs entries in /sys, calls that use metadata,
send / receive drive data and sed functionality not in our nvme driver.

Sponsored by: Netflix
Co-Authored-by: Chuck Tuffli <chuck@freebsd.org>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.May 30 2024, 6:30 PM

Testing with an unmodified Linux nvme-cli looks good using this patch rebased on top of my device alias changes.

This revision is now accepted and ready to land.Sun, Jun 9, 5:25 PM

Rebase on top of Chuck's device name changes.

This revision now requires review to proceed.Fri, Jun 14, 9:15 PM
This revision was not accepted when it landed; it landed in state Needs Review.Fri, Jun 14, 10:40 PM
This revision was automatically updated to reflect the committed changes.