* [PATCHv2 0/3] nvmet: discovery controller discovery support @ 2021-10-18 15:21 Hannes Reinecke 2021-10-18 15:21 ` [PATCH 1/3] nvmet: switch check for subsystem type Hannes Reinecke ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Hannes Reinecke @ 2021-10-18 15:21 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke TPAR 8014 (discovery controller discovery) adds a new discovery log page entry type '3' to describe the current discovery controller. This patchset adds support for this to the nvme target. As usual, comments and reviews are welcome. Changes to v1: - Rebased to nvme-5.16 Hannes Reinecke (3): nvmet: switch check for subsystem type nvme: add new discovery log page entry definitions nvmet: register discovery subsystem as 'current' drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/discovery.c | 13 ++++++++----- drivers/nvme/target/nvmet.h | 2 +- include/linux/nvme.h | 12 ++++++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) -- 2.29.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] nvmet: switch check for subsystem type 2021-10-18 15:21 [PATCHv2 0/3] nvmet: discovery controller discovery support Hannes Reinecke @ 2021-10-18 15:21 ` Hannes Reinecke 2021-10-19 6:37 ` Chaitanya Kulkarni 2021-10-18 15:21 ` [PATCH 2/3] nvme: add new discovery log page entry definitions Hannes Reinecke ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: Hannes Reinecke @ 2021-10-18 15:21 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke Invert the check for discovery subsystem type to allow for additional discovery subsystem types. Signed-off-by: Hannes Reinecke <hare@suse.de> --- drivers/nvme/target/nvmet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index f31dcc4fb1a2..af193423c10b 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req) static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys) { - return subsys->type == NVME_NQN_DISC; + return subsys->type != NVME_NQN_NVME; } #ifdef CONFIG_NVME_TARGET_PASSTHRU -- 2.29.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] nvmet: switch check for subsystem type 2021-10-18 15:21 ` [PATCH 1/3] nvmet: switch check for subsystem type Hannes Reinecke @ 2021-10-19 6:37 ` Chaitanya Kulkarni 2021-10-19 13:50 ` Hannes Reinecke 0 siblings, 1 reply; 7+ messages in thread From: Chaitanya Kulkarni @ 2021-10-19 6:37 UTC (permalink / raw) To: linux-nvme On 10/18/2021 8:21 AM, Hannes Reinecke wrote: > Invert the check for discovery subsystem type to allow for additional > discovery subsystem types. > > Signed-off-by: Hannes Reinecke <hare@suse.de> > --- > drivers/nvme/target/nvmet.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h > index f31dcc4fb1a2..af193423c10b 100644 > --- a/drivers/nvme/target/nvmet.h > +++ b/drivers/nvme/target/nvmet.h > @@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req) > > static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys) > { > - return subsys->type == NVME_NQN_DISC; > + return subsys->type != NVME_NQN_NVME; shouldn't we use switch and make code more readable for allowed subsys->type values ? unless there is a reason .. > } > > #ifdef CONFIG_NVME_TARGET_PASSTHRU > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] nvmet: switch check for subsystem type 2021-10-19 6:37 ` Chaitanya Kulkarni @ 2021-10-19 13:50 ` Hannes Reinecke 0 siblings, 0 replies; 7+ messages in thread From: Hannes Reinecke @ 2021-10-19 13:50 UTC (permalink / raw) To: Chaitanya Kulkarni, linux-nvme On 10/19/21 8:37 AM, Chaitanya Kulkarni wrote: > On 10/18/2021 8:21 AM, Hannes Reinecke wrote: >> Invert the check for discovery subsystem type to allow for additional >> discovery subsystem types. >> >> Signed-off-by: Hannes Reinecke <hare@suse.de> >> --- >> drivers/nvme/target/nvmet.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h >> index f31dcc4fb1a2..af193423c10b 100644 >> --- a/drivers/nvme/target/nvmet.h >> +++ b/drivers/nvme/target/nvmet.h >> @@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req) >> >> static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys) >> { >> - return subsys->type == NVME_NQN_DISC; >> + return subsys->type != NVME_NQN_NVME; > > shouldn't we use switch and make code more readable for allowed > subsys->type values ? unless there is a reason .. > Well, with this patch we still have only two values; introducing a switch for this feels a bit silly. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] nvme: add new discovery log page entry definitions 2021-10-18 15:21 [PATCHv2 0/3] nvmet: discovery controller discovery support Hannes Reinecke 2021-10-18 15:21 ` [PATCH 1/3] nvmet: switch check for subsystem type Hannes Reinecke @ 2021-10-18 15:21 ` Hannes Reinecke 2021-10-18 15:21 ` [PATCH 3/3] nvmet: register discovery subsystem as 'current' Hannes Reinecke 2021-10-27 6:07 ` [PATCHv2 0/3] nvmet: discovery controller discovery support Christoph Hellwig 3 siblings, 0 replies; 7+ messages in thread From: Hannes Reinecke @ 2021-10-18 15:21 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke TP8014 adds a new SUBTYPE value and a new field EFLAGS for the discovery log page entry. Signed-off-by: Hannes Reinecke <hare@suse.de> --- include/linux/nvme.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 357482dedb59..4bd1c30715f9 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -27,8 +27,9 @@ #define NVME_NSID_ALL 0xffffffff enum nvme_subsys_type { - NVME_NQN_DISC = 1, /* Discovery type target subsystem */ + NVME_NQN_DISC = 1, /* Referral to another discovery type target subsystem */ NVME_NQN_NVME = 2, /* NVME type target subsystem */ + NVME_NQN_CURR = 3, /* Current discovery type target subsystem */ }; enum nvme_ctrl_type { @@ -1312,6 +1313,12 @@ struct nvmf_common_command { #define MAX_DISC_LOGS 255 +/* Discovery log page entry flags (EFLAGS): */ +enum { + NVME_DISC_EFLAGS_EPCSD = (1 << 1), + NVME_DISC_EFLAGS_DUPRETINFO = (1 << 0), +}; + /* Discovery log page entry */ struct nvmf_disc_rsp_page_entry { __u8 trtype; @@ -1321,7 +1328,8 @@ struct nvmf_disc_rsp_page_entry { __le16 portid; __le16 cntlid; __le16 asqsz; - __u8 resv8[22]; + __le16 eflags; + __u8 resv10[20]; char trsvcid[NVMF_TRSVCID_SIZE]; __u8 resv64[192]; char subnqn[NVMF_NQN_FIELD_LEN]; -- 2.29.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] nvmet: register discovery subsystem as 'current' 2021-10-18 15:21 [PATCHv2 0/3] nvmet: discovery controller discovery support Hannes Reinecke 2021-10-18 15:21 ` [PATCH 1/3] nvmet: switch check for subsystem type Hannes Reinecke 2021-10-18 15:21 ` [PATCH 2/3] nvme: add new discovery log page entry definitions Hannes Reinecke @ 2021-10-18 15:21 ` Hannes Reinecke 2021-10-27 6:07 ` [PATCHv2 0/3] nvmet: discovery controller discovery support Christoph Hellwig 3 siblings, 0 replies; 7+ messages in thread From: Hannes Reinecke @ 2021-10-18 15:21 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Hannes Reinecke Register the discovery subsystem as the 'current' discovery subsystem, and add a new discovery log page entry for it. Signed-off-by: Hannes Reinecke <hare@suse.de> --- drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/discovery.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index d844fb9ef2eb..fd3d01b4b3d1 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1541,6 +1541,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn, subsys->max_qid = NVMET_NR_QUEUES; break; case NVME_NQN_DISC: + fallthrough; + case NVME_NQN_CURR: subsys->max_qid = 0; break; default: diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c index 7b360f8d07e9..a2f08c49f07c 100644 --- a/drivers/nvme/target/discovery.c +++ b/drivers/nvme/target/discovery.c @@ -146,7 +146,7 @@ static size_t discovery_log_entries(struct nvmet_req *req) struct nvmet_ctrl *ctrl = req->sq->ctrl; struct nvmet_subsys_link *p; struct nvmet_port *r; - size_t entries = 0; + size_t entries = 1; list_for_each_entry(p, &req->port->subsystems, entry) { if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) @@ -171,6 +171,7 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req) u32 numrec = 0; u16 status = 0; void *buffer; + char traddr[NVMF_TRADDR_SIZE]; if (!nvmet_check_transfer_len(req, data_len)) return; @@ -204,14 +205,16 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req) goto out; } + nvmet_set_disc_traddr(req, req->port, traddr); hdr = buffer; + nvmet_format_discovery_entry(hdr, req->port, + nvmet_disc_subsys->subsysnqn, + traddr, NVME_NQN_CURR, numrec); + numrec++; list_for_each_entry(p, &req->port->subsystems, entry) { - char traddr[NVMF_TRADDR_SIZE]; - if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) continue; - nvmet_set_disc_traddr(req, req->port, traddr); nvmet_format_discovery_entry(hdr, req->port, p->subsys->subsysnqn, traddr, NVME_NQN_NVME, numrec); @@ -389,7 +392,7 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req) int __init nvmet_init_discovery(void) { nvmet_disc_subsys = - nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_DISC); + nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_CURR); return PTR_ERR_OR_ZERO(nvmet_disc_subsys); } -- 2.29.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCHv2 0/3] nvmet: discovery controller discovery support 2021-10-18 15:21 [PATCHv2 0/3] nvmet: discovery controller discovery support Hannes Reinecke ` (2 preceding siblings ...) 2021-10-18 15:21 ` [PATCH 3/3] nvmet: register discovery subsystem as 'current' Hannes Reinecke @ 2021-10-27 6:07 ` Christoph Hellwig 3 siblings, 0 replies; 7+ messages in thread From: Christoph Hellwig @ 2021-10-27 6:07 UTC (permalink / raw) To: Hannes Reinecke; +Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch, linux-nvme Thanks, applied to nvme-5.16 with a few cosmetic tweaks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-10-27 6:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-18 15:21 [PATCHv2 0/3] nvmet: discovery controller discovery support Hannes Reinecke 2021-10-18 15:21 ` [PATCH 1/3] nvmet: switch check for subsystem type Hannes Reinecke 2021-10-19 6:37 ` Chaitanya Kulkarni 2021-10-19 13:50 ` Hannes Reinecke 2021-10-18 15:21 ` [PATCH 2/3] nvme: add new discovery log page entry definitions Hannes Reinecke 2021-10-18 15:21 ` [PATCH 3/3] nvmet: register discovery subsystem as 'current' Hannes Reinecke 2021-10-27 6:07 ` [PATCHv2 0/3] nvmet: discovery controller discovery support Christoph Hellwig
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.