smartmontools
SVN Rev 5640
Utility to control and monitor storage systems with "S.M.A.R.T."
freebsd_nvme_ioctl.h
Go to the documentation of this file.
1
/*-
2
* Copyright (C) 2012-2013 Intel Corporation
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
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.
13
*
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
24
* SUCH DAMAGE.
25
*
26
* $FreeBSD$
27
*/
28
29
30
#include <sys/param.h>
31
32
#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command)
33
34
#if __FreeBSD_version < 1100110
35
struct
nvme_command
36
{
37
/* dword 0 */
38
uint16_t
opc
: 8;
/* opcode */
39
uint16_t
fuse
: 2;
/* fused operation */
40
uint16_t
rsvd1
: 6;
41
uint16_t
cid
;
/* command identifier */
42
43
/* dword 1 */
44
uint32_t
nsid
;
/* namespace identifier */
45
46
/* dword 2-3 */
47
uint32_t
rsvd2
;
48
uint32_t
rsvd3
;
49
50
/* dword 4-5 */
51
uint64_t
mptr
;
/* metadata pointer */
52
53
/* dword 6-7 */
54
uint64_t
prp1
;
/* prp entry 1 */
55
56
/* dword 8-9 */
57
uint64_t
prp2
;
/* prp entry 2 */
58
59
/* dword 10-15 */
60
uint32_t
cdw10
;
/* command-specific */
61
uint32_t
cdw11
;
/* command-specific */
62
uint32_t
cdw12
;
/* command-specific */
63
uint32_t
cdw13
;
/* command-specific */
64
uint32_t
cdw14
;
/* command-specific */
65
uint32_t
cdw15
;
/* command-specific */
66
}
__packed
;
67
68
struct
nvme_status
{
69
70
uint16_t
p
: 1;
/* phase tag */
71
uint16_t
sc
: 8;
/* status code */
72
uint16_t
sct
: 3;
/* status code type */
73
uint16_t
rsvd2
: 2;
74
uint16_t
m
: 1;
/* more */
75
uint16_t
dnr
: 1;
/* do not retry */
76
}
__packed
;
77
78
struct
nvme_completion
{
79
80
/* dword 0 */
81
uint32_t
cdw0
;
/* command-specific */
82
83
/* dword 1 */
84
uint32_t
rsvd1
;
85
86
/* dword 2 */
87
uint16_t
sqhd
;
/* submission queue head pointer */
88
uint16_t
sqid
;
/* submission queue identifier */
89
90
/* dword 3 */
91
uint16_t
cid
;
/* command identifier */
92
struct
nvme_status
status
;
93
}
__packed
;
94
95
struct
nvme_pt_command
{
96
97
/*
98
* cmd is used to specify a passthrough command to a controller or
99
* namespace.
100
*
101
* The following fields from cmd may be specified by the caller:
102
* * opc (opcode)
103
* * nsid (namespace id) - for admin commands only
104
* * cdw10-cdw15
105
*
106
* Remaining fields must be set to 0 by the caller.
107
*/
108
struct
nvme_command
cmd
;
109
110
/*
111
* cpl returns completion status for the passthrough command
112
* specified by cmd.
113
*
114
* The following fields will be filled out by the driver, for
115
* consumption by the caller:
116
* * cdw0
117
* * status (except for phase)
118
*
119
* Remaining fields will be set to 0 by the driver.
120
*/
121
struct
nvme_completion
cpl
;
122
123
/* buf is the data buffer associated with this passthrough command. */
124
void
*
buf
;
125
126
/*
127
* len is the length of the data buffer associated with this
128
* passthrough command.
129
*/
130
uint32_t
len
;
131
132
/*
133
* is_read = 1 if the passthrough command will read data into the
134
* supplied buffer from the controller.
135
*
136
* is_read = 0 if the passthrough command will write data from the
137
* supplied buffer to the controller.
138
*/
139
uint32_t
is_read
;
140
141
/*
142
* driver_lock is used by the driver only. It must be set to 0
143
* by the caller.
144
*/
145
struct
mtx *
driver_lock
;
146
};
147
#else
148
#include <dev/nvme/nvme.h>
149
#endif
150
151
#if __FreeBSD_version < 1200058
152
#define nvme_completion_is_error(cpl) \
153
((cpl)->status.sc != 0 || (cpl)->status.sct != 0)
154
#endif
155
156
#define NVME_CTRLR_PREFIX "/dev/nvme"
157
#define NVME_NS_PREFIX "ns"
__packed
struct nvme_command __packed
nvme_command
Definition:
freebsd_nvme_ioctl.h:36
nvme_command::cdw13
uint32_t cdw13
Definition:
freebsd_nvme_ioctl.h:63
nvme_command::prp1
uint64_t prp1
Definition:
freebsd_nvme_ioctl.h:54
nvme_command::rsvd1
uint16_t rsvd1
Definition:
freebsd_nvme_ioctl.h:40
nvme_command::cid
uint16_t cid
Definition:
freebsd_nvme_ioctl.h:41
nvme_command::cdw12
uint32_t cdw12
Definition:
freebsd_nvme_ioctl.h:62
nvme_command::fuse
uint16_t fuse
Definition:
freebsd_nvme_ioctl.h:39
nvme_command::cdw14
uint32_t cdw14
Definition:
freebsd_nvme_ioctl.h:64
nvme_command::rsvd2
uint32_t rsvd2
Definition:
freebsd_nvme_ioctl.h:47
nvme_command::cdw10
uint32_t cdw10
Definition:
freebsd_nvme_ioctl.h:60
nvme_command::prp2
uint64_t prp2
Definition:
freebsd_nvme_ioctl.h:57
nvme_command::opc
uint16_t opc
Definition:
freebsd_nvme_ioctl.h:38
nvme_command::cdw11
uint32_t cdw11
Definition:
freebsd_nvme_ioctl.h:61
nvme_command::rsvd3
uint32_t rsvd3
Definition:
freebsd_nvme_ioctl.h:48
nvme_command::cdw15
uint32_t cdw15
Definition:
freebsd_nvme_ioctl.h:65
nvme_command::mptr
uint64_t mptr
Definition:
freebsd_nvme_ioctl.h:51
nvme_command::nsid
uint32_t nsid
Definition:
freebsd_nvme_ioctl.h:44
nvme_completion
Definition:
freebsd_nvme_ioctl.h:78
nvme_completion::cid
uint16_t cid
Definition:
freebsd_nvme_ioctl.h:91
nvme_completion::sqhd
uint16_t sqhd
Definition:
freebsd_nvme_ioctl.h:87
nvme_completion::status
struct nvme_status status
Definition:
freebsd_nvme_ioctl.h:92
nvme_completion::sqid
uint16_t sqid
Definition:
freebsd_nvme_ioctl.h:88
nvme_completion::cdw0
uint32_t cdw0
Definition:
freebsd_nvme_ioctl.h:81
nvme_completion::rsvd1
uint32_t rsvd1
Definition:
freebsd_nvme_ioctl.h:84
nvme_pt_command
Definition:
freebsd_nvme_ioctl.h:95
nvme_pt_command::cmd
struct nvme_command cmd
Definition:
freebsd_nvme_ioctl.h:108
nvme_pt_command::buf
void * buf
Definition:
freebsd_nvme_ioctl.h:124
nvme_pt_command::driver_lock
struct mtx * driver_lock
Definition:
freebsd_nvme_ioctl.h:145
nvme_pt_command::is_read
uint32_t is_read
Definition:
freebsd_nvme_ioctl.h:139
nvme_pt_command::cpl
struct nvme_completion cpl
Definition:
freebsd_nvme_ioctl.h:121
nvme_pt_command::len
uint32_t len
Definition:
freebsd_nvme_ioctl.h:130
nvme_status
Definition:
freebsd_nvme_ioctl.h:68
nvme_status::m
uint16_t m
Definition:
freebsd_nvme_ioctl.h:74
nvme_status::rsvd2
uint16_t rsvd2
Definition:
freebsd_nvme_ioctl.h:73
nvme_status::p
uint16_t p
Definition:
freebsd_nvme_ioctl.h:70
nvme_status::sct
uint16_t sct
Definition:
freebsd_nvme_ioctl.h:72
nvme_status::dnr
uint16_t dnr
Definition:
freebsd_nvme_ioctl.h:75
nvme_status::sc
uint16_t sc
Definition:
freebsd_nvme_ioctl.h:71
Generated on Wed Nov 20 2024 22:05:02 for smartmontools by
1.9.6