add -s option for 'power' command, this instructs the controller to save
the value so it persists resets/whatnot; the NVMe specification lists this as optional, so this only works if the controller supports it
This commit is contained in:
parent
228b243e5a
commit
6eddb6bb08
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: nvmectl.8,v 1.5 2018/04/18 10:17:54 nonaka Exp $
|
.\" $NetBSD: nvmectl.8,v 1.6 2020/09/27 18:17:35 jdolecek Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2012 Intel Corporation
|
.\" Copyright (c) 2012 Intel Corporation
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@ -34,7 +34,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD: head/sbin/nvmecontrol/nvmecontrol.8 314230 2017-02-25 00:09:16Z imp $
|
.\" $FreeBSD: head/sbin/nvmecontrol/nvmecontrol.8 314230 2017-02-25 00:09:16Z imp $
|
||||||
.\"
|
.\"
|
||||||
.Dd May 19, 2016
|
.Dd September 27, 2020
|
||||||
.Dt NVMECTL 8
|
.Dt NVMECTL 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -74,6 +74,7 @@
|
|||||||
.Nm
|
.Nm
|
||||||
.Ic power
|
.Ic power
|
||||||
.Op Fl l
|
.Op Fl l
|
||||||
|
.Op Fl s
|
||||||
.Op Fl p Ar power_state
|
.Op Fl p Ar power_state
|
||||||
.Op Fl w Ar workload_hint
|
.Op Fl w Ar workload_hint
|
||||||
.Ar device_id
|
.Ar device_id
|
||||||
@ -84,6 +85,19 @@
|
|||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
NVM Express (NVMe) is a storage protocol standard, for SSDs and other
|
NVM Express (NVMe) is a storage protocol standard, for SSDs and other
|
||||||
high-speed storage devices over PCI Express.
|
high-speed storage devices over PCI Express.
|
||||||
|
.Ss power
|
||||||
|
The power command controls the supported power states.
|
||||||
|
.Fl l
|
||||||
|
will list supported power states.
|
||||||
|
.Fl p
|
||||||
|
will set the power state to specified value.
|
||||||
|
.Fl w
|
||||||
|
will set workload value.
|
||||||
|
With
|
||||||
|
.Fl s ,
|
||||||
|
the specified power state and workload value is saved,
|
||||||
|
so it persists any autonomous transitions and resets.
|
||||||
|
Support for saving the values is optional, and depends on the controller.
|
||||||
.Ss logpage
|
.Ss logpage
|
||||||
The logpage command knows how to print log pages of various types.
|
The logpage command knows how to print log pages of various types.
|
||||||
It also knows about vendor specific log pages from hgst/wdc and intel.
|
It also knows about vendor specific log pages from hgst/wdc and intel.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: nvmectl.h,v 1.8 2018/04/18 10:16:22 nonaka Exp $ */
|
/* $NetBSD: nvmectl.h,v 1.9 2020/09/27 18:17:35 jdolecek Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
@ -78,7 +78,7 @@ struct nvme_function {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define POWER_USAGE \
|
#define POWER_USAGE \
|
||||||
"power [-l] [-p new-state [-w workload-hint]] <controller_id>\n"
|
"power [-l] [[-s] -p new-state [-w workload-hint]] <controller_id>\n"
|
||||||
|
|
||||||
#define WDC_USAGE \
|
#define WDC_USAGE \
|
||||||
"wdc cap-diag [-o path-templete]\n"
|
"wdc cap-diag [-o path-templete]\n"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: power.c,v 1.5 2020/09/27 17:27:07 jdolecek Exp $ */
|
/* $NetBSD: power.c,v 1.6 2020/09/27 18:17:35 jdolecek Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2016 Netflix, Inc
|
* Copyright (c) 2016 Netflix, Inc
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: power.c,v 1.5 2020/09/27 17:27:07 jdolecek Exp $");
|
__RCSID("$NetBSD: power.c,v 1.6 2020/09/27 18:17:35 jdolecek Exp $");
|
||||||
#if 0
|
#if 0
|
||||||
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/power.c 329824 2018-02-22 13:32:31Z wma $");
|
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/power.c 329824 2018-02-22 13:32:31Z wma $");
|
||||||
#endif
|
#endif
|
||||||
@ -96,15 +96,14 @@ power_list(struct nvm_identify_controller *cdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 saveflag)
|
||||||
{
|
{
|
||||||
struct nvme_pt_command pt;
|
struct nvme_pt_command pt;
|
||||||
uint32_t p;
|
|
||||||
|
|
||||||
p = perm ? (1u << 31) : 0;
|
|
||||||
memset(&pt, 0, sizeof(pt));
|
memset(&pt, 0, sizeof(pt));
|
||||||
pt.cmd.opcode = NVM_ADMIN_SET_FEATURES;
|
pt.cmd.opcode = NVM_ADMIN_SET_FEATURES;
|
||||||
pt.cmd.cdw10 = NVM_FEAT_POWER_MANAGEMENT | p;
|
pt.cmd.cdw10 = NVM_FEAT_POWER_MANAGEMENT
|
||||||
|
| (saveflag ? NVM_SET_FEATURES_SV : 0);
|
||||||
pt.cmd.cdw11 = power_val | (workload << 5);
|
pt.cmd.cdw11 = power_val | (workload << 5);
|
||||||
|
|
||||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||||
@ -138,15 +137,18 @@ void
|
|||||||
power(int argc, char *argv[])
|
power(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct nvm_identify_controller cdata;
|
struct nvm_identify_controller cdata;
|
||||||
int ch, listflag = 0, powerflag = 0, power_val = 0, fd;
|
int ch, listflag = 0, powerflag = 0, power_val = 0, fd, saveflag = 0;
|
||||||
int workload = 0;
|
int workload = 0;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "lp:w:")) != -1) {
|
while ((ch = getopt(argc, argv, "lsp:w:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'l':
|
case 'l':
|
||||||
listflag = 1;
|
listflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
saveflag = 1;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
powerflag = 1;
|
powerflag = 1;
|
||||||
power_val = strtol(optarg, &end, 0);
|
power_val = strtol(optarg, &end, 0);
|
||||||
@ -185,7 +187,7 @@ power(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (powerflag) {
|
if (powerflag) {
|
||||||
power_set(fd, power_val, workload, 0);
|
power_set(fd, power_val, workload, saveflag);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
power_show(fd);
|
power_show(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user