public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* Question about ioctl interface - IO passthru
@ 2019-01-31 14:09 Eyal BenDavid
  2019-01-31 14:55 ` Keith Busch
  0 siblings, 1 reply; 6+ messages in thread
From: Eyal BenDavid @ 2019-01-31 14:09 UTC (permalink / raw)


Hi,

I wrote a small program to perform IOs based on the ioctl interface
from linux_ioctl.h and code from nvme-cli.

Specifically I wrote this function for write zero (code is used in
stress and verification testing).
Note that this is C++ (only difference is the default values for
function arguments)

====
int nvme_io_passthru(int      fd,
                     uint32_t nsid,
                     uint8_t  opcode,
                     uint64_t slba,
                     uint16_t nblocks,
                     void*    data = NULL,
                     uint32_t dlen = 0,
                     uint8_t  flags = 0,
                     uint32_t timeout = 30000,
                     uint16_t control = 0,
                     uint32_t reftag = 0,
                     uint16_t apptag = 0,
                     uint16_t appmask = 0)
{
    struct nvme_passthru_cmd cmd;
    memset(&cmd, 0, sizeof(cmd));

    cmd.opcode     = opcode;
    cmd.flags      = flags;
    cmd.nsid       = nsid;
    cmd.addr       = (uint64_t)(uintptr_t) data;
    cmd.data_len   = dlen;
    cmd.cdw10      = (slba & 0xffffffff);
    cmd.cdw11      = (slba >> 32);
    cmd.cdw12      = (nblocks | (control << 16));
    cmd.cdw14      = reftag;
    cmd.cdw15      = (apptag | (appmask << 16));
    cmd.timeout_ms = timeout;

    return ioctl(fd, NVME_IOCTL_IO_CMD, &cmd);
}
====

To my surprise the function worked fine not only with write zero but
with other IO opcodes (read, write, compare)
The advantage is now I control the timeout value in IO commands!

What is the difference from using "nvme_user_io" structure?
Is it safe to use this version of IO commands?

Thanks!
Eyal BD.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
@ 2019-01-31 13:59 Eyal BenDavid
  0 siblings, 0 replies; 6+ messages in thread
From: Eyal BenDavid @ 2019-01-31 13:59 UTC (permalink / raw)


Hi,

I wrote a small program to perform IOs based on the ioctl interface
from linux_ioctl.h and code from nvme-cli.

Specifically

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-01-31 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 14:09 Question about ioctl interface - IO passthru Eyal BenDavid
2019-01-31 14:55 ` Keith Busch
2019-01-31 18:08   ` Eyal BenDavid
2019-01-31 18:39     ` Chaitanya Kulkarni
2019-01-31 19:05       ` Keith Busch
  -- strict thread matches above, loose matches on Subject: below --
2019-01-31 13:59 Eyal BenDavid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox