nvme: add helper to compare options to controller
authorJames Smart <jsmart2021@gmail.com>
Fri, 20 Oct 2017 23:17:07 +0000 (16:17 -0700)
committerChristoph Hellwig <hch@lst.de>
Fri, 27 Oct 2017 06:25:28 +0000 (09:25 +0300)
Adds a helper function that compares the host and subsytem
specified in a connect options list vs a controller.

Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fabrics.h

index a7590cc59ba26f76ebb30f77a78c535b338f0567..42232e731f19f71d31e5808af8513ed73bbf7ee8 100644 (file)
@@ -133,6 +133,18 @@ struct nvmf_transport_ops {
                                        struct nvmf_ctrl_options *opts);
 };
 
+static inline bool
+nvmf_ctlr_matches_baseopts(struct nvme_ctrl *ctrl,
+                       struct nvmf_ctrl_options *opts)
+{
+       if (strcmp(opts->subsysnqn, ctrl->opts->subsysnqn) ||
+           strcmp(opts->host->nqn, ctrl->opts->host->nqn) ||
+           memcmp(&opts->host->id, &ctrl->opts->host->id, sizeof(uuid_t)))
+               return false;
+
+       return true;
+}
+
 int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val);
 int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val);
 int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val);