[PATCH 13/18] nvmet: make TCP sectype settable via configfs

Sagi Grimberg sagi at grimberg.me
Mon Apr 3 05:31:02 PDT 2023


>>> Add a new configfs attribute 'addr_tsas' to make the TCP sectype
>>> settable via configfs.
>>>
>>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>>> ---
>>>   drivers/nvme/target/configfs.c | 67 ++++++++++++++++++++++++++++++++++
>>>   1 file changed, 67 insertions(+)
>>>
>>> diff --git a/drivers/nvme/target/configfs.c 
>>> b/drivers/nvme/target/configfs.c
>>> index 907143870da5..ca66ee6dc153 100644
>>> --- a/drivers/nvme/target/configfs.c
>>> +++ b/drivers/nvme/target/configfs.c
>>> @@ -303,6 +303,11 @@ static void nvmet_port_init_tsas_rdma(struct 
>>> nvmet_port *port)
>>>       port->disc_addr.tsas.rdma.cms = NVMF_RDMA_CMS_RDMA_CM;
>>>   }
>>> +static void nvmet_port_init_tsas_tcp(struct nvmet_port *port, int 
>>> sectype)
>>> +{
>>> +    port->disc_addr.tsas.tcp.sectype = sectype;
>>> +}
>>> +
>>>   static ssize_t nvmet_addr_trtype_store(struct config_item *item,
>>>           const char *page, size_t count)
>>>   {
>>> @@ -325,11 +330,72 @@ static ssize_t nvmet_addr_trtype_store(struct 
>>> config_item *item,
>>>       port->disc_addr.trtype = nvmet_transport[i].type;
>>>       if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA)
>>>           nvmet_port_init_tsas_rdma(port);
>>> +    else if (port->disc_addr.trtype == NVMF_TRTYPE_TCP)
>>> +        nvmet_port_init_tsas_tcp(port, NVMF_TCP_SECTYPE_NONE);
>>>       return count;
>>>   }
>>>   CONFIGFS_ATTR(nvmet_, addr_trtype);
>>> +static const struct nvmet_type_name_map nvmet_addr_tsas_tcp[] = {
>>> +    { NVMF_TCP_SECTYPE_NONE,    "none" },
>>> +    { NVMF_TCP_SECTYPE_TLS13,    "tls1.3" },
>>> +};
>>> +
>>> +static const struct nvmet_type_name_map nvmet_addr_tsas_rdma[] = {
>>> +    { NVMF_RDMA_QPTYPE_CONNECTED,    "connected" },
>>> +    { NVMF_RDMA_QPTYPE_DATAGRAM,    "datagram"  },
>>> +};
>>> +
>>> +static ssize_t nvmet_addr_tsas_show(struct config_item *item,
>>> +        char *page)
>>> +{
>>> +    struct nvmet_port *port = to_nvmet_port(item);
>>> +    int i;
>>> +
>>> +    if (port->disc_addr.trtype == NVMF_TRTYPE_TCP) {
>>> +        for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
>>> +            if (port->disc_addr.tsas.tcp.sectype == 
>>> nvmet_addr_tsas_tcp[i].type)
>>> +                return sprintf(page, "%s\n", 
>>> nvmet_addr_tsas_tcp[i].name);
>>> +        }
>>> +        return sprintf(page, "reserved\n");
>>
>> What is reserved?
>>
> All other values?

Yes, you should just consolidate it outside the if-else instead of "not
required" (which is a treq value iirc).



More information about the Linux-nvme mailing list