From 50ab6977297ce35b98cfadd46cc77f1c1c91d712 Mon Sep 17 00:00:00 2001 From: Steven Seungcheol Lee Date: Wed, 5 Apr 2023 13:10:42 +0900 Subject: [PATCH] nvme: Add zns specfic field for create ns nvme_ns_mgmt_host_sw_specified_zns from TP4115 ZNS Namespace Management Enhancements 2022.03.15 Ratified Signed-off-by: Steven Seungcheol Lee --- Documentation/nvme-create-ns.txt | 26 ++++++++++++++++++++++++ completions/bash-nvme-completion.sh | 3 ++- nvme.c | 31 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/Documentation/nvme-create-ns.txt b/Documentation/nvme-create-ns.txt index e13aabdf..5d1355d2 100644 --- a/Documentation/nvme-create-ns.txt +++ b/Documentation/nvme-create-ns.txt @@ -22,6 +22,10 @@ SYNOPSIS [--timeout= | -t ] [--nsze-si= | -S ] [--ncap-si= | -C ] + [--azr | -z] + [--rar= | -r ] + [--ror= | -o ] + [--rnumzrwa= | -u ] [--phndls= | -p ] DESCRIPTION @@ -98,6 +102,28 @@ OPTIONS The value SI suffixed is divided by the namespace LBA size to set as NCAP. If the value not suffixed it is set as same with the ncap option. +-z:: +--azr:: + Allocate ZRWA Resources. + If set to 1, then the namespace is to be created with the number of ZRWA + resource specified in the RNUMZRWA field of this data structure. If cleared + to 0, then no ZRWA resources are allocated to the namespace to be created. + +-r :: +--rar=:: + Requested Active Resources. This field specifies the number of active + resources to be allocated to the created namespace. + +-o :: +--ror=:: + Requested Open Resources. This field specifies the number of open resources + to be allocated to the created namespace. + +-u :: +--rnumzrwa=:: + Requested Number of ZRWA Resources. This field specifies the number of ZRWA + resources to be allocated to the created namespace. + -p :: --phndls=:: The comma separated list of Reclaim Unit Handle Identifier to be associated diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index e7440185..f39ec6b2 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -94,7 +94,8 @@ nvme_list_opts () { opts+=" --nsze= -s --ncap= -c --flbas= -f \ --dps= -d --nmic= -m --anagrp-id= -a --nvmset-id= -i \ --block-size= -b --timeout= -t --csi= -y --lbstm= -l \ - --nphndls= -n --nsze-si= -S --ncap-si= -C --phndls= -p" + --nphndls= -n --nsze-si= -S --ncap-si= -C --azr -z --rar= -r \ + --ror= -o --rnumzrwa= -u --phndls= -p" ;; "delete-ns") opts+=" -namespace-id= -n --timeout= -t" diff --git a/nvme.c b/nvme.c index 10f7d189..928cfce9 100644 --- a/nvme.c +++ b/nvme.c @@ -2998,6 +2998,14 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * "value not entered"; const char *nsze_si = "size of ns (NSZE) in standard SI units"; const char *ncap_si = "capacity of ns (NCAP) in standard SI units"; + const char *azr = "Allocate ZRWA Resources (AZR) for "\ + "Zoned Namespace Command Set"; + const char *rar = "Requested Active Resources (RAR) for "\ + "Zoned Namespace Command Set"; + const char *ror = "Requested Open Resources (ROR) for "\ + "Zoned Namespace Command Set"; + const char *rnumzrwa = "Requested Number of ZRWA Resources (RNUMZRWA) for "\ + "Zoned Namespace Command Set"; const char *phndls = "Comma separated list of Placement Handle "\ "Associated RUH"; @@ -3023,6 +3031,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * __u16 nphndls; char *nsze_si; char *ncap_si; + bool azr; + __u32 rar; + __u32 ror; + __u32 rnumzrwa; char *phndls; }; @@ -3041,6 +3053,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * .nphndls = 0, .nsze_si = NULL, .ncap_si = NULL, + .azr = false, + .rar = 0, + .ror = 0, + .rnumzrwa = 0, .phndls = "", }; @@ -3059,6 +3075,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * OPT_SHRT("nphndls", 'n', &cfg.nphndls, nphndls), OPT_STR("nsze-si", 'S', &cfg.nsze_si, nsze_si), OPT_STR("ncap-si", 'C', &cfg.ncap_si, ncap_si), + OPT_FLAG("azr", 'z', &cfg.azr, azr), + OPT_UINT("rar", 'r', &cfg.rar, rar), + OPT_UINT("ror", 'o', &cfg.ror, ror), + OPT_UINT("rnumzrwa", 'u', &cfg.rnumzrwa, rnumzrwa), OPT_LIST("phndls", 'p', &cfg.phndls, phndls), OPT_END() }; @@ -3119,6 +3139,13 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * if (err) goto close_dev; + if (cfg.csi != NVME_CSI_ZNS && + (cfg.azr || cfg.rar || cfg.ror|| cfg.rnumzrwa)) { + fprintf(stderr, "Invaild ZNS argument is given (CSI:%#x)\n", cfg.csi); + err = -EINVAL; + goto close_dev; + } + struct nvme_ns_mgmt_host_sw_specified data = { .nsze = cpu_to_le64(cfg.nsze), .ncap = cpu_to_le64(cfg.ncap), @@ -3128,6 +3155,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * .anagrpid = cpu_to_le32(cfg.anagrpid), .nvmsetid = cpu_to_le16(cfg.nvmsetid), .lbstm = cpu_to_le64(cfg.lbstm), + .zns.znsco = cfg.azr, + .zns.rar = cpu_to_le32(cfg.rar), + .zns.ror = cpu_to_le32(cfg.ror), + .zns.rnumzrwa = cpu_to_le32(cfg.rnumzrwa), .nphndls = cpu_to_le16(cfg.nphndls), }; -- 2.50.1