Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/nvmecontrol/nvmecontrol.c
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
read_controller_data(int fd, struct nvme_controller_data *cdata) | read_controller_data(int fd, struct nvme_controller_data *cdata) | ||||
{ | { | ||||
struct nvme_pt_command pt; | struct nvme_pt_command pt; | ||||
memset(&pt, 0, sizeof(pt)); | memset(&pt, 0, sizeof(pt)); | ||||
pt.cmd.opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_IDENTIFY); | pt.cmd.opc = NVME_OPC_IDENTIFY; | ||||
pt.cmd.cdw10 = htole32(1); | pt.cmd.cdw10 = htole32(1); | ||||
pt.buf = cdata; | pt.buf = cdata; | ||||
pt.len = sizeof(*cdata); | pt.len = sizeof(*cdata); | ||||
pt.is_read = 1; | pt.is_read = 1; | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "identify request failed"); | err(1, "identify request failed"); | ||||
/* Convert data to host endian */ | /* Convert data to host endian */ | ||||
nvme_controller_data_swapbytes(cdata); | nvme_controller_data_swapbytes(cdata); | ||||
if (nvme_completion_is_error(&pt.cpl)) | if (nvme_completion_is_error(&pt.cpl)) | ||||
errx(1, "identify request returned error"); | errx(1, "identify request returned error"); | ||||
} | } | ||||
void | void | ||||
read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata) | read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata) | ||||
{ | { | ||||
struct nvme_pt_command pt; | struct nvme_pt_command pt; | ||||
memset(&pt, 0, sizeof(pt)); | memset(&pt, 0, sizeof(pt)); | ||||
pt.cmd.opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_IDENTIFY); | pt.cmd.opc = NVME_OPC_IDENTIFY; | ||||
pt.cmd.nsid = htole32(nsid); | pt.cmd.nsid = htole32(nsid); | ||||
pt.buf = nsdata; | pt.buf = nsdata; | ||||
pt.len = sizeof(*nsdata); | pt.len = sizeof(*nsdata); | ||||
pt.is_read = 1; | pt.is_read = 1; | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "identify request failed"); | err(1, "identify request failed"); | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |