1 | /* $NetBSD: nvmeio.h,v 1.1 2016/06/04 16:11:51 nonaka Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (C) 2012-2013 Intel Corporation |
5 | * All rights reserved. |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions |
9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. |
15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. |
27 | * |
28 | * $FreeBSD: head/sys/dev/nvme/nvme.h 296617 2016-03-10 17:13:10Z mav $ |
29 | */ |
30 | |
31 | #ifndef __NVMEIO_H__ |
32 | #define __NVMEIO_H__ |
33 | |
34 | #include <sys/ioccom.h> |
35 | #include <dev/ic/nvmereg.h> |
36 | |
37 | #define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command) |
38 | |
39 | #define nvme_completion_is_error(cpl) \ |
40 | ((NVME_CQE_SC((cpl)->flags) != NVME_CQE_SC_SUCCESS) \ |
41 | || (NVME_CQE_SCT((cpl)->flags) != NVME_CQE_SCT_GENERIC)) |
42 | |
43 | struct nvme_pt_command { |
44 | |
45 | /* |
46 | * cmd is used to specify a passthrough command to a controller or |
47 | * namespace. |
48 | * |
49 | * The following fields from cmd may be specified by the caller: |
50 | * * opcode |
51 | * * nsid (namespace id) - for admin commands only |
52 | * * cdw10-cdw15 |
53 | * |
54 | * Remaining fields must be set to 0 by the caller. |
55 | */ |
56 | struct nvme_sqe cmd; |
57 | |
58 | /* |
59 | * cpl returns completion status for the passthrough command |
60 | * specified by cmd. |
61 | * |
62 | * The following fields will be filled out by the driver, for |
63 | * consumption by the caller: |
64 | * * cdw0 |
65 | * * flags (except for phase) |
66 | * |
67 | * Remaining fields will be set to 0 by the driver. |
68 | */ |
69 | struct nvme_cqe cpl; |
70 | |
71 | /* buf is the data buffer associated with this passthrough command. */ |
72 | void *buf; |
73 | |
74 | /* |
75 | * len is the length of the data buffer associated with this |
76 | * passthrough command. |
77 | */ |
78 | uint32_t len; |
79 | |
80 | /* |
81 | * is_read = 1 if the passthrough command will read data into the |
82 | * supplied buffer from the controller. |
83 | * |
84 | * is_read = 0 if the passthrough command will write data from the |
85 | * supplied buffer to the controller. |
86 | */ |
87 | uint32_t is_read; |
88 | |
89 | /* |
90 | * timeout (unit: ms) |
91 | * |
92 | * 0: use default timeout value |
93 | */ |
94 | uint32_t timeout; |
95 | }; |
96 | |
97 | #endif /* __NVMEIO_H__ */ |
98 | |