Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/nvmecontrol/power.c
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
power_set(int fd, int power_val, int workload, int perm) | power_set(int fd, int power_val, int workload, int perm) | ||||
{ | { | ||||
struct nvme_pt_command pt; | struct nvme_pt_command pt; | ||||
uint32_t p; | uint32_t p; | ||||
p = perm ? (1u << 31) : 0; | p = perm ? (1u << 31) : 0; | ||||
memset(&pt, 0, sizeof(pt)); | memset(&pt, 0, sizeof(pt)); | ||||
pt.cmd.opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_SET_FEATURES); | pt.cmd.opc = NVME_OPC_SET_FEATURES; | ||||
pt.cmd.cdw10 = htole32(NVME_FEAT_POWER_MANAGEMENT | p); | pt.cmd.cdw10 = htole32(NVME_FEAT_POWER_MANAGEMENT | p); | ||||
pt.cmd.cdw11 = htole32(power_val | (workload << 5)); | pt.cmd.cdw11 = htole32(power_val | (workload << 5)); | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "set feature power mgmt request failed"); | err(1, "set feature power mgmt request failed"); | ||||
if (nvme_completion_is_error(&pt.cpl)) | if (nvme_completion_is_error(&pt.cpl)) | ||||
errx(1, "set feature power mgmt request returned error"); | errx(1, "set feature power mgmt request returned error"); | ||||
} | } | ||||
static void | static void | ||||
power_show(int fd) | power_show(int fd) | ||||
{ | { | ||||
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_GET_FEATURES); | pt.cmd.opc = NVME_OPC_GET_FEATURES; | ||||
pt.cmd.cdw10 = htole32(NVME_FEAT_POWER_MANAGEMENT); | pt.cmd.cdw10 = htole32(NVME_FEAT_POWER_MANAGEMENT); | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "set feature power mgmt request failed"); | err(1, "set feature power mgmt request failed"); | ||||
if (nvme_completion_is_error(&pt.cpl)) | if (nvme_completion_is_error(&pt.cpl)) | ||||
errx(1, "set feature power mgmt request returned error"); | errx(1, "set feature power mgmt request returned error"); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |