nvmet: make TCP sectype settable via configfs
Add a new configfs attribute 'addr_tsas' to make the TCP sectype settable via configfs. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
adf22c520b
commit
3f123494db
1 changed files with 74 additions and 1 deletions
|
@ -159,6 +159,11 @@ static const struct nvmet_type_name_map nvmet_addr_treq[] = {
|
||||||
{ NVMF_TREQ_NOT_REQUIRED, "not required" },
|
{ NVMF_TREQ_NOT_REQUIRED, "not required" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline u8 nvmet_port_disc_addr_treq_mask(struct nvmet_port *port)
|
||||||
|
{
|
||||||
|
return (port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t nvmet_addr_treq_show(struct config_item *item, char *page)
|
static ssize_t nvmet_addr_treq_show(struct config_item *item, char *page)
|
||||||
{
|
{
|
||||||
u8 treq = to_nvmet_port(item)->disc_addr.treq &
|
u8 treq = to_nvmet_port(item)->disc_addr.treq &
|
||||||
|
@ -178,7 +183,7 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item,
|
||||||
const char *page, size_t count)
|
const char *page, size_t count)
|
||||||
{
|
{
|
||||||
struct nvmet_port *port = to_nvmet_port(item);
|
struct nvmet_port *port = to_nvmet_port(item);
|
||||||
u8 treq = port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK;
|
u8 treq = nvmet_port_disc_addr_treq_mask(port);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (nvmet_is_port_enabled(port, __func__))
|
if (nvmet_is_port_enabled(port, __func__))
|
||||||
|
@ -303,6 +308,11 @@ static void nvmet_port_init_tsas_rdma(struct nvmet_port *port)
|
||||||
port->disc_addr.tsas.rdma.cms = NVMF_RDMA_CMS_RDMA_CM;
|
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,
|
static ssize_t nvmet_addr_trtype_store(struct config_item *item,
|
||||||
const char *page, size_t count)
|
const char *page, size_t count)
|
||||||
{
|
{
|
||||||
|
@ -325,11 +335,73 @@ found:
|
||||||
port->disc_addr.trtype = nvmet_transport[i].type;
|
port->disc_addr.trtype = nvmet_transport[i].type;
|
||||||
if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA)
|
if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA)
|
||||||
nvmet_port_init_tsas_rdma(port);
|
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;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR(nvmet_, addr_trtype);
|
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);
|
||||||
|
}
|
||||||
|
} else if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA) {
|
||||||
|
for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_rdma); i++) {
|
||||||
|
if (port->disc_addr.tsas.rdma.qptype == nvmet_addr_tsas_rdma[i].type)
|
||||||
|
return sprintf(page, "%s\n", nvmet_addr_tsas_rdma[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sprintf(page, "reserved\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t nvmet_addr_tsas_store(struct config_item *item,
|
||||||
|
const char *page, size_t count)
|
||||||
|
{
|
||||||
|
struct nvmet_port *port = to_nvmet_port(item);
|
||||||
|
u8 sectype;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (nvmet_is_port_enabled(port, __func__))
|
||||||
|
return -EACCES;
|
||||||
|
|
||||||
|
if (port->disc_addr.trtype != NVMF_TRTYPE_TCP)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
|
||||||
|
if (sysfs_streq(page, nvmet_addr_tsas_tcp[i].name)) {
|
||||||
|
sectype = nvmet_addr_tsas_tcp[i].type;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_err("Invalid value '%s' for tsas\n", page);
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
found:
|
||||||
|
nvmet_port_init_tsas_tcp(port, sectype);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
CONFIGFS_ATTR(nvmet_, addr_tsas);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Namespace structures & file operation functions below
|
* Namespace structures & file operation functions below
|
||||||
*/
|
*/
|
||||||
|
@ -1741,6 +1813,7 @@ static struct configfs_attribute *nvmet_port_attrs[] = {
|
||||||
&nvmet_attr_addr_traddr,
|
&nvmet_attr_addr_traddr,
|
||||||
&nvmet_attr_addr_trsvcid,
|
&nvmet_attr_addr_trsvcid,
|
||||||
&nvmet_attr_addr_trtype,
|
&nvmet_attr_addr_trtype,
|
||||||
|
&nvmet_attr_addr_tsas,
|
||||||
&nvmet_attr_param_inline_data_size,
|
&nvmet_attr_param_inline_data_size,
|
||||||
#ifdef CONFIG_BLK_DEV_INTEGRITY
|
#ifdef CONFIG_BLK_DEV_INTEGRITY
|
||||||
&nvmet_attr_param_pi_enable,
|
&nvmet_attr_param_pi_enable,
|
||||||
|
|
Loading…
Add table
Reference in a new issue