Skip to content

Commit 07bfcd0

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme-fabrics: add a generic NVMe over Fabrics library
The NVMe over Fabrics library provides an interface for both transports and the nvme core to handle fabrics specific commands and attributes independent of the underlying transport. In addition, the fabrics library adds a misc device interface that allow actually creating a fabrics controller, as we can't just autodiscover it like in the PCI case. The nvme-cli utility has been enhanced to use this interface to support fabric connect and discovery. Signed-off-by: Armen Baloyan <armenx.baloyan@intel.com>, Signed-off-by: Jay Freyensee <james.p.freyensee@intel.com>, Signed-off-by: Ming Lin <ming.l@ssi.samsung.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent eb793e2 commit 07bfcd0

File tree

6 files changed

+1098
-1
lines changed

6 files changed

+1098
-1
lines changed

drivers/nvme/host/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ config BLK_DEV_NVME_SCSI
2424
to say N here, unless you run a distro that abuses the SCSI
2525
emulation to provide stable device names for mount by id, like
2626
some OpenSuSE and SLES versions.
27+
28+
config NVME_FABRICS
29+
tristate

drivers/nvme/host/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
obj-$(CONFIG_NVME_CORE) += nvme-core.o
22
obj-$(CONFIG_BLK_DEV_NVME) += nvme.o
3+
obj-$(CONFIG_NVME_FABRICS) += nvme-fabrics.o
34

45
nvme-core-y := core.o
56
nvme-core-$(CONFIG_BLK_DEV_NVME_SCSI) += scsi.o
67
nvme-core-$(CONFIG_NVM) += lightnvm.o
78

89
nvme-y += pci.o
10+
11+
nvme-fabrics-y += fabrics.o

drivers/nvme/host/core.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,9 +1178,26 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
11781178
}
11791179

11801180
nvme_set_queue_limits(ctrl, ctrl->admin_q);
1181+
ctrl->sgls = le32_to_cpu(id->sgls);
1182+
1183+
if (ctrl->ops->is_fabrics) {
1184+
ctrl->icdoff = le16_to_cpu(id->icdoff);
1185+
ctrl->ioccsz = le32_to_cpu(id->ioccsz);
1186+
ctrl->iorcsz = le32_to_cpu(id->iorcsz);
1187+
ctrl->maxcmd = le16_to_cpu(id->maxcmd);
1188+
1189+
/*
1190+
* In fabrics we need to verify the cntlid matches the
1191+
* admin connect
1192+
*/
1193+
if (ctrl->cntlid != le16_to_cpu(id->cntlid))
1194+
ret = -EINVAL;
1195+
} else {
1196+
ctrl->cntlid = le16_to_cpu(id->cntlid);
1197+
}
11811198

11821199
kfree(id);
1183-
return 0;
1200+
return ret;
11841201
}
11851202
EXPORT_SYMBOL_GPL(nvme_init_identify);
11861203

0 commit comments

Comments
 (0)