Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmet: align addrfam list to spec

With reference to the NVMeOF Specification (page 44, Figure 38)
discovery log page entry provides address family field. We do set the
transport type field but the adrfam field is not set when using loop
transport and also it doesn't have support in the nvme-cli. So when
reading discovery log page with a loop transport it leads to confusing
output.

As per the spec for adrfam value 254 is reserved for Intra Host
Transport i.e. loopback), we add a required macro in the protocol
header file, set default port disc addr entry's adrfam to
NVMF_ADDR_FAMILY_MAX, and update nvmet_addr_family configfs array for
show/store attribute.

Without this patch, setting adrfam to (ipv4/ipv6/ib/fc/loop/" ") we get
following output for nvme discover command from nvme-cli which is
confusing.
trtype: loop
adrfam: ipv4
trtype: loop
adrfam: ipv6
trtype: loop
adrfam: infiniband
trtype: loop
adrfam: fibre-channel
trtype: loop # ${CFGFS_HOME}/nvmet/ports/1/addr_adrfam = loop
adrfam: pci # <----- pci for loop
trtype: loop # ${CFGFS_HOME}/nvmet/ports/1/addr_adrfam = " "
adrfam: pci # <----- pci for unrecognized

This patch fixes above output :-
trtype: loop
adrfam: ipv4
trtype: loop
adrfam: ipv6
trtype: loop
adrfam: infiniband
trtype: loop
adrfam: fibre-channel
trtype: loop # ${CFGFS_HOME}/nvmet/ports/1/addr_adrfam = loop
adrfam: loop # <----- loop for loop
trtype: loop # ${CFGFS_HOME}/config/nvmet/ports/adrfam = " "
adrfam: unrecognized # <----- unrecognized when invalid value

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Chaitanya Kulkarni and committed by
Jens Axboe
d02abd19 3ecb5faa

+10 -6
+8 -6
drivers/nvme/target/configfs.c
··· 33 33 }; 34 34 35 35 static const struct nvmet_type_name_map nvmet_addr_family[] = { 36 - { NVMF_ADDR_FAMILY_PCI, "pcie" }, 37 - { NVMF_ADDR_FAMILY_IP4, "ipv4" }, 38 - { NVMF_ADDR_FAMILY_IP6, "ipv6" }, 39 - { NVMF_ADDR_FAMILY_IB, "ib" }, 40 - { NVMF_ADDR_FAMILY_FC, "fc" }, 36 + { NVMF_ADDR_FAMILY_PCI, "pcie" }, 37 + { NVMF_ADDR_FAMILY_IP4, "ipv4" }, 38 + { NVMF_ADDR_FAMILY_IP6, "ipv6" }, 39 + { NVMF_ADDR_FAMILY_IB, "ib" }, 40 + { NVMF_ADDR_FAMILY_FC, "fc" }, 41 + { NVMF_ADDR_FAMILY_LOOP, "loop" }, 41 42 }; 42 43 43 44 static bool nvmet_is_port_enabled(struct nvmet_port *p, const char *caller) ··· 84 83 return -EINVAL; 85 84 86 85 found: 87 - port->disc_addr.adrfam = i; 86 + port->disc_addr.adrfam = nvmet_addr_family[i].type; 88 87 return count; 89 88 } 90 89 ··· 1339 1338 port->inline_data_size = -1; /* < 0 == let the transport choose */ 1340 1339 1341 1340 port->disc_addr.portid = cpu_to_le16(portid); 1341 + port->disc_addr.adrfam = NVMF_ADDR_FAMILY_MAX; 1342 1342 port->disc_addr.treq = NVMF_TREQ_DISABLE_SQFLOW; 1343 1343 config_group_init_type_name(&port->group, name, &nvmet_port_type); 1344 1344
+2
include/linux/nvme.h
··· 38 38 NVMF_ADDR_FAMILY_IP6 = 2, /* IP6 */ 39 39 NVMF_ADDR_FAMILY_IB = 3, /* InfiniBand */ 40 40 NVMF_ADDR_FAMILY_FC = 4, /* Fibre Channel */ 41 + NVMF_ADDR_FAMILY_LOOP = 254, /* Reserved for host usage */ 42 + NVMF_ADDR_FAMILY_MAX, 41 43 }; 42 44 43 45 /* Transport Type codes for Discovery Log Page entry TRTYPE field */