]> www.infradead.org Git - nvme.git/commitdiff
nvme: Add PCI transport type
authorDamien Le Moal <dlemoal@kernel.org>
Sat, 4 Jan 2025 04:59:39 +0000 (13:59 +0900)
committerKeith Busch <kbusch@kernel.org>
Sat, 11 Jan 2025 03:30:47 +0000 (19:30 -0800)
Define the transport type NVMF_TRTYPE_PCI for PCI endpoint targets.
This transport type is defined using the value 0 which is reserved in
the NVMe base specifications v2.1 (Figure 294). Given that struct
nvmet_port are zeroed out on creation, to avoid having this transsport
type becoming the new default, nvmet_referral_make() and
nvmet_ports_make() are modified to initialize a port discovery address
transport type field (disc_addr.trtype) to NVMF_TRTYPE_MAX.

Any port using this transport type is also skipped and not reported in
the discovery log page (nvmet_execute_disc_get_log_page()).

The helper function nvmet_is_pci_ctrl() is also introduced to check if
a target controller uses the PCI transport.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
Tested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/configfs.c
drivers/nvme/target/discovery.c
drivers/nvme/target/nvmet.h
include/linux/nvme.h

index 4b2b8e7d96f566bf23247b6eba994c84a23e84d4..20cad722c060a5594cc775c5343f23dd73f1c07b 100644 (file)
@@ -37,6 +37,7 @@ static struct nvmet_type_name_map nvmet_transport[] = {
        { NVMF_TRTYPE_RDMA,     "rdma" },
        { NVMF_TRTYPE_FC,       "fc" },
        { NVMF_TRTYPE_TCP,      "tcp" },
+       { NVMF_TRTYPE_PCI,      "pci" },
        { NVMF_TRTYPE_LOOP,     "loop" },
 };
 
@@ -46,6 +47,7 @@ static const struct nvmet_type_name_map nvmet_addr_family[] = {
        { NVMF_ADDR_FAMILY_IP6,         "ipv6" },
        { NVMF_ADDR_FAMILY_IB,          "ib" },
        { NVMF_ADDR_FAMILY_FC,          "fc" },
+       { NVMF_ADDR_FAMILY_PCI,         "pci" },
        { NVMF_ADDR_FAMILY_LOOP,        "loop" },
 };
 
@@ -1839,6 +1841,7 @@ static struct config_group *nvmet_referral_make(
                return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&port->entry);
+       port->disc_addr.trtype = NVMF_TRTYPE_MAX;
        config_group_init_type_name(&port->group, name, &nvmet_referral_type);
 
        return &port->group;
@@ -2064,6 +2067,7 @@ static struct config_group *nvmet_ports_make(struct config_group *group,
        port->inline_data_size = -1;    /* < 0 == let the transport choose */
        port->max_queue_size = -1;      /* < 0 == let the transport choose */
 
+       port->disc_addr.trtype = NVMF_TRTYPE_MAX;
        port->disc_addr.portid = cpu_to_le16(portid);
        port->disc_addr.adrfam = NVMF_ADDR_FAMILY_MAX;
        port->disc_addr.treq = NVMF_TREQ_DISABLE_SQFLOW;
index 28843df5fa7c779b0122b2f5a0d57525958267a1..7a13f8e8d33de10abfb075790ed1ce94ba761e37 100644 (file)
@@ -224,6 +224,9 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
        }
 
        list_for_each_entry(r, &req->port->referrals, entry) {
+               if (r->disc_addr.trtype == NVMF_TRTYPE_PCI)
+                       continue;
+
                nvmet_format_discovery_entry(hdr, r,
                                NVME_DISC_SUBSYS_NAME,
                                r->disc_addr.traddr,
index abcc1f3828b7992a29eb319cd16db781c7eefb44..4dad413e5fef04881f2177abb5adb96bdcc08028 100644 (file)
@@ -693,6 +693,11 @@ static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys)
     return subsys->type != NVME_NQN_NVME;
 }
 
+static inline bool nvmet_is_pci_ctrl(struct nvmet_ctrl *ctrl)
+{
+       return ctrl->port->disc_addr.trtype == NVMF_TRTYPE_PCI;
+}
+
 #ifdef CONFIG_NVME_TARGET_PASSTHRU
 void nvmet_passthru_subsys_free(struct nvmet_subsys *subsys);
 int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys);
index a5a4ee56efcff25c7374d48d624f80a0c35aae3b..42fc00dc494e81e8ab1935157e444ef03a897cf5 100644 (file)
@@ -64,6 +64,7 @@ enum {
 
 /* Transport Type codes for Discovery Log Page entry TRTYPE field */
 enum {
+       NVMF_TRTYPE_PCI         = 0,    /* PCI */
        NVMF_TRTYPE_RDMA        = 1,    /* RDMA */
        NVMF_TRTYPE_FC          = 2,    /* Fibre Channel */
        NVMF_TRTYPE_TCP         = 3,    /* TCP/IP */