]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - freebsd_nvme_ioctl.h
2 * Copyright (C) 2012-2013 Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/param.h>
32 #define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command)
37 uint16_t opc
: 8; /* opcode */
38 uint16_t fuse
: 2; /* fused operation */
40 uint16_t cid
; /* command identifier */
43 uint32_t nsid
; /* namespace identifier */
50 uint64_t mptr
; /* metadata pointer */
53 uint64_t prp1
; /* prp entry 1 */
56 uint64_t prp2
; /* prp entry 2 */
59 uint32_t cdw10
; /* command-specific */
60 uint32_t cdw11
; /* command-specific */
61 uint32_t cdw12
; /* command-specific */
62 uint32_t cdw13
; /* command-specific */
63 uint32_t cdw14
; /* command-specific */
64 uint32_t cdw15
; /* command-specific */
69 uint16_t p
: 1; /* phase tag */
70 uint16_t sc
: 8; /* status code */
71 uint16_t sct
: 3; /* status code type */
73 uint16_t m
: 1; /* more */
74 uint16_t dnr
: 1; /* do not retry */
77 struct nvme_completion
{
80 uint32_t cdw0
; /* command-specific */
86 uint16_t sqhd
; /* submission queue head pointer */
87 uint16_t sqid
; /* submission queue identifier */
90 uint16_t cid
; /* command identifier */
91 struct nvme_status status
;
94 struct nvme_pt_command
{
97 * cmd is used to specify a passthrough command to a controller or
100 * The following fields from cmd may be specified by the caller:
102 * * nsid (namespace id) - for admin commands only
105 * Remaining fields must be set to 0 by the caller.
107 struct nvme_command cmd
;
110 * cpl returns completion status for the passthrough command
113 * The following fields will be filled out by the driver, for
114 * consumption by the caller:
116 * * status (except for phase)
118 * Remaining fields will be set to 0 by the driver.
120 struct nvme_completion cpl
;
122 /* buf is the data buffer associated with this passthrough command. */
126 * len is the length of the data buffer associated with this
127 * passthrough command.
132 * is_read = 1 if the passthrough command will read data into the
133 * supplied buffer from the controller.
135 * is_read = 0 if the passthrough command will write data from the
136 * supplied buffer to the controller.
141 * driver_lock is used by the driver only. It must be set to 0
144 struct mtx
* driver_lock
;
147 #define nvme_completion_is_error(cpl) \
148 ((cpl)->status.sc != 0 || (cpl)->status.sct != 0)
150 #define NVME_CTRLR_PREFIX "/dev/nvme"
151 #define NVME_NS_PREFIX "ns"