smartmontools SVN Rev 5640
Utility to control and monitor storage systems with "S.M.A.R.T."
openbsd_nvme_ioctl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Kenneth R Westerback <krw@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_cmd)
18
23#define NVME_CQE_SCT(_f) ((_f) & (0x07 << 9))
24#define NVME_CQE_SCT_GENERIC (0x00 << 9)
25#define NVME_CQE_SC(_f) ((_f) & (0xff << 1))
26#define NVME_CQE_SC_SUCCESS (0x00 << 1)
27 uint32_t ps_csts;
28 uint32_t ps_cc;
29};
30
31#define BIO_MSG_COUNT 5
32#define BIO_MSG_LEN 128
33
34struct bio_msg {
37};
38
39struct bio_status {
40 char bs_controller[16];
44};
45
46struct bio {
49};
50
52 /* Commands may arrive via /dev/bio. */
53 struct bio pt_bio;
54
55 /* The sqe fields that the caller may specify. */
56 uint8_t pt_opcode;
57 uint32_t pt_nsid;
58 uint32_t pt_cdw10;
59 uint32_t pt_cdw11;
60 uint32_t pt_cdw12;
61 uint32_t pt_cdw13;
62 uint32_t pt_cdw14;
63 uint32_t pt_cdw15;
64
65 caddr_t pt_status;
66 uint32_t pt_statuslen;
67
68 caddr_t pt_databuf; /* User space address. */
69 uint32_t pt_databuflen; /* Length of buffer. */
70};
71
72#define nvme_completion_is_error(_flags) \
73 ((NVME_CQE_SC(_flags) != NVME_CQE_SC_SUCCESS) \
74 || (NVME_CQE_SCT(_flags) != NVME_CQE_SCT_GENERIC))
75
#define BIO_MSG_COUNT
#define BIO_MSG_LEN
char bm_msg[BIO_MSG_LEN]
char bs_controller[16]
struct bio_msg bs_msgs[BIO_MSG_COUNT]
void * bio_cookie
struct bio pt_bio
uint32_t pt_databuflen
uint32_t pt_statuslen