From: Keith Busch Date: Wed, 3 Dec 2014 16:48:05 +0000 (-0700) Subject: NVMe: Add io-passthru support X-Git-Tag: v0.1~85 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=edba681a37f187294c9092586ac5be22aff249f7;p=users%2Fsagi%2Fnvme-cli.git NVMe: Add io-passthru support It's identical to the admin passthrough. This and others like flush and reservations are dependent on the driver commit: | commit 390a2cf648df2d9bbd43462cb2f62fb00fb612d9 | Author: Keith Busch | Date: Fri Sep 12 16:07:20 2014 -0600 | | NVMe: Passthrough IOCTL for IO commands You'll just get an error for an unknown ioctl otherwise. Signed-off-by: Keith Busch --- diff --git a/Documentation/nvme-io-passthru.txt b/Documentation/nvme-io-passthru.txt index 39c12595..ac97e866 100644 --- a/Documentation/nvme-io-passthru.txt +++ b/Documentation/nvme-io-passthru.txt @@ -1,5 +1,5 @@ -nvme-admin-passthru(1) -====================== +nvme-io-passthru(1) +=================== NAME ---- @@ -25,7 +25,7 @@ SYNOPSIS DESCRIPTION ----------- Submits an arbitrary NVMe IO command and returns the applicable -results. This may be the simply the commands result and status, or may +results. This may be the simply the command's result and status, or may also include a buffer if the command returns one. This command does no interpretation of the opcodes or options. @@ -53,7 +53,7 @@ OPTIONS -n :: --namespace-id=:: - The value for the ns-id in the command. + The value for the ns-id in the command. Defaults to '0'. --cdw[2-3,10-15]=:: Specifies the command dword value for that specified entry in diff --git a/nvme.c b/nvme.c index 1f8c9a70..783d6e36 100644 --- a/nvme.c +++ b/nvme.c @@ -1685,19 +1685,11 @@ static int sec_recv(int argc, char **argv) return err; } -static int io_passthru(int argc, char **argv) +static int nvme_passthru(int argc, char **argv, int ioctl_cmd) { - fprintf(stderr, "%s: not implemented yet\n", __func__); - return 0; -} - -static int admin_passthru(int argc, char **argv) -{ - /* We should be able to infer the data direction from the opcode, but - * some vendors don't abide by this in their vendor specific opcodes */ int r = 0, w = 0; int opt, err, raw = 0, show = 0, long_index = 0, wfd = STDIN_FILENO; - struct nvme_admin_cmd cmd; + struct nvme_passthru_cmd cmd; static struct option opts[] = { {"opcode", required_argument, 0, 'o'}, {"flags", required_argument, 0, 'f'}, @@ -1797,8 +1789,7 @@ static int admin_passthru(int argc, char **argv) printf("timeout_ms : %08x\n", cmd.timeout_ms); return 0; } - - err = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd); + err = ioctl(fd, ioctl_cmd, &cmd); if (err >= 0) { if (!raw) { printf("NVMe Status:%s Command Result:%08x\n", @@ -1812,6 +1803,16 @@ static int admin_passthru(int argc, char **argv) return err; } +static int io_passthru(int argc, char **argv) +{ + return nvme_passthru(argc, argv, NVME_IOCTL_IO_CMD); +} + +static int admin_passthru(int argc, char **argv) +{ + return nvme_passthru(argc, argv, NVME_IOCTL_ADMIN_CMD); +} + static void usage(char *cmd) { fprintf(stdout, "usage: %s [] []\n", cmd);