nvme-fabrics: make cntlid settable
PATCH 1/1 nvme-fabrics: make cntlid settable
As per spec the controller ID can be set if a subsystem implements the the static controller model, so add a 'cntlid' option to the connect string.
Signed-off-by Hannes Reinecke <[email protected]>
--- drivers/nvme/host/fabrics.c | 19 ++++++++++++++++++- drivers/nvme/host/fabrics.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +18 -1
@@ -115,6 +115,9 @@ int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size)if (ctrl->opts->mask &NVMF_OPT_HOST_IFACE ) len +=scnprintf (buf + len, size - len,"%shost_iface=%s" , (len) ?"," :"" , ctrl->opts->host_iface); +if (ctrl->opts->mask &NVMF_OPT_CNTLID ) + len +=scnprintf (buf + len, size - len,"%scntlid=%d" , + (len) ?"," :"" , ctrl->opts->cntlid); len +=scnprintf (buf + len, size - len,"\n" );return len;
@@ -385,7 +388,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)return -ENOMEM ;uuid_copy (&data->hostid, &ctrl->opts->host->id); - data->cntlid =cpu_to_le16 (0xffff ); + data->cntlid =cpu_to_le16 (ctrl->opts->cntlid);strncpy (data->subsysnqn, ctrl->opts->subsysnqn,NVMF_NQN_SIZE );strncpy (data->hostnqn, ctrl->opts->host->nqn,NVMF_NQN_SIZE );
@@ -541,6 +544,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_HOST_TRADDR, "host_traddr=%s" }, { NVMF_OPT_HOST_IFACE, "host_iface=%s" }, { NVMF_OPT_HOST_ID, "hostid=%s" }, + { NVMF_OPT_CNTLID, "cntlid=%d" }, { NVMF_OPT_DUP_CONNECT, "duplicate_connect" }, { NVMF_OPT_DISABLE_SQFLOW, "disable_sqflow" }, { NVMF_OPT_HDR_DIGEST, "hdr_digest" },
@@ -572,6 +576,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->hdr_digest = false; opts->data_digest = false; opts->tos =-1 ;/* < 0 == use transport default */ + opts->cntlid =0xffff ; options = o =kstrdup (buf,GFP_KERNEL );if (!options)
@@ -773,6 +778,18 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, }kfree (p);break ; +case NVMF_OPT_CNTLID : +if (match_int (args, &token)) { + ret = -EINVAL ; + goto out; + } +if (token <0 || token >0xffff ) { +pr_err ("Invalid controller id %d\n" , token); + ret = -EINVAL ; + goto out; + } + opts->cntlid = token; +break ;case NVMF_OPT_DUP_CONNECT : opts->duplicate_connect = true;break ;
drivers/nvme/host/fabrics.h +2 -0
@@ -67,6 +67,7 @@ enum {NVMF_OPT_TOS =1 <<19 ,NVMF_OPT_FAIL_FAST_TMO =1 <<20 ,NVMF_OPT_HOST_IFACE =1 <<21 , + NVMF_OPT_CNTLID = 1 << 22, };/**
@@ -112,6 +113,7 @@ struct nvmf_ctrl_options {char *trsvcid;char *host_traddr;char *host_iface; +unsigned int cntlid;size_t queue_size;unsigned int nr_io_queues;unsigned int reconnect_delay;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 3 lines · Hannes Reinecke
As per spec the controller ID can be set if a subsystem implements the the static controller model, so add a 'cntlid' option to the connect string.
Not supporting the cntlid is a deliberate decision from day 0 as the model where the host picks the specific controller is completely broken.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme