Changeset View
Changeset View
Standalone View
Standalone View
sbin/nvmecontrol/power.c
Show All 37 Lines | |||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "nvmecontrol.h" | #include "nvmecontrol.h" | ||||
_Static_assert(sizeof(struct nvme_power_state) == 256 / NBBY, | _Static_assert(sizeof(struct nvme_power_state) == 256 / NBBY, | ||||
"nvme_power_state size wrong"); | "nvme_power_state size wrong"); | ||||
#define POWER_USAGE \ | #define POWER_USAGE \ | ||||
"power [-l] [-p new-state [-w workload-hint]] <controller id>\n" | "power [-l] [-p new-state [-w workload-hint]] <controller id>\n" | ||||
#define POWER_ARGS \ | |||||
"<controller-id>" | |||||
#define POWER_DESCR \ | |||||
"Manage power states for the drive" | |||||
static void | static void | ||||
power_list_one(int i, struct nvme_power_state *nps) | power_list_one(int i, struct nvme_power_state *nps) | ||||
{ | { | ||||
int mpower, apower, ipower; | int mpower, apower, ipower; | ||||
uint8_t mps, nops, aps, apw; | uint8_t mps, nops, aps, apw; | ||||
mps = (nps->mps_nops >> NVME_PWR_ST_MPS_SHIFT) & | mps = (nps->mps_nops >> NVME_PWR_ST_MPS_SHIFT) & | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | power(const struct nvme_function *nf, int argc, char *argv[]) | ||||
} | } | ||||
power_show(fd); | power_show(fd); | ||||
out: | out: | ||||
close(fd); | close(fd); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
NVME_COMMAND(top, power, power, POWER_USAGE); | NVME_COMMAND(top, power, power, POWER_USAGE, POWER_ARGS, POWER_DESCR); |