Skip to content

Commit 200adac

Browse files
damien-lemoalkeithbusch
authored andcommitted
nvme: Add PCI transport type
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Rick Wertenbroek <[email protected]> Tested-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 35c593e commit 200adac

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

drivers/nvme/target/configfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static struct nvmet_type_name_map nvmet_transport[] = {
3737
{ NVMF_TRTYPE_RDMA, "rdma" },
3838
{ NVMF_TRTYPE_FC, "fc" },
3939
{ NVMF_TRTYPE_TCP, "tcp" },
40+
{ NVMF_TRTYPE_PCI, "pci" },
4041
{ NVMF_TRTYPE_LOOP, "loop" },
4142
};
4243

@@ -46,6 +47,7 @@ static const struct nvmet_type_name_map nvmet_addr_family[] = {
4647
{ NVMF_ADDR_FAMILY_IP6, "ipv6" },
4748
{ NVMF_ADDR_FAMILY_IB, "ib" },
4849
{ NVMF_ADDR_FAMILY_FC, "fc" },
50+
{ NVMF_ADDR_FAMILY_PCI, "pci" },
4951
{ NVMF_ADDR_FAMILY_LOOP, "loop" },
5052
};
5153

@@ -1839,6 +1841,7 @@ static struct config_group *nvmet_referral_make(
18391841
return ERR_PTR(-ENOMEM);
18401842

18411843
INIT_LIST_HEAD(&port->entry);
1844+
port->disc_addr.trtype = NVMF_TRTYPE_MAX;
18421845
config_group_init_type_name(&port->group, name, &nvmet_referral_type);
18431846

18441847
return &port->group;
@@ -2064,6 +2067,7 @@ static struct config_group *nvmet_ports_make(struct config_group *group,
20642067
port->inline_data_size = -1; /* < 0 == let the transport choose */
20652068
port->max_queue_size = -1; /* < 0 == let the transport choose */
20662069

2070+
port->disc_addr.trtype = NVMF_TRTYPE_MAX;
20672071
port->disc_addr.portid = cpu_to_le16(portid);
20682072
port->disc_addr.adrfam = NVMF_ADDR_FAMILY_MAX;
20692073
port->disc_addr.treq = NVMF_TREQ_DISABLE_SQFLOW;

drivers/nvme/target/discovery.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
224224
}
225225

226226
list_for_each_entry(r, &req->port->referrals, entry) {
227+
if (r->disc_addr.trtype == NVMF_TRTYPE_PCI)
228+
continue;
229+
227230
nvmet_format_discovery_entry(hdr, r,
228231
NVME_DISC_SUBSYS_NAME,
229232
r->disc_addr.traddr,

drivers/nvme/target/nvmet.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,11 @@ static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys)
693693
return subsys->type != NVME_NQN_NVME;
694694
}
695695

696+
static inline bool nvmet_is_pci_ctrl(struct nvmet_ctrl *ctrl)
697+
{
698+
return ctrl->port->disc_addr.trtype == NVMF_TRTYPE_PCI;
699+
}
700+
696701
#ifdef CONFIG_NVME_TARGET_PASSTHRU
697702
void nvmet_passthru_subsys_free(struct nvmet_subsys *subsys);
698703
int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys);

include/linux/nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum {
6464

6565
/* Transport Type codes for Discovery Log Page entry TRTYPE field */
6666
enum {
67+
NVMF_TRTYPE_PCI = 0, /* PCI */
6768
NVMF_TRTYPE_RDMA = 1, /* RDMA */
6869
NVMF_TRTYPE_FC = 2, /* Fibre Channel */
6970
NVMF_TRTYPE_TCP = 3, /* TCP/IP */

0 commit comments

Comments
 (0)