[PATCH mptcp-next v4 08/10] nvme-fabrics: add IPv6 traffic class option
Geliang Tang <[email protected]> Thu, 30 Jul 2026 10:54:01 +0800
| Newsgroups | dev.linux.lists.mptcp |
|---|---|
| Message-ID | <7bdbc9a0e60a3688ca9c7ce2eab7396c82679a93.1785378180.git.tanggeliang@kylinos.cn> |
From: Geliang Tang <[email protected]> The NVMe/TCP transport needs to configure the IPv6 traffic class on its queue sockets, but the fabrics option parser currently has no corresponding option. Add the tclass option to the fabrics parser and store the validated value in struct nvmf_ctrl_options. Negative values are rejected, while values greater than 255 are clamped to 255, matching the valid range of the IPv6 traffic class field. Keep -1 as the default value to let the transport use its default traffic class. Signed-off-by: Geliang Tang <[email protected]> --- drivers/nvme/host/fabrics.c | 18 ++++++++++++++++++ drivers/nvme/host/fabrics.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index ac3d4f400601..643c03dc7bcb 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -695,6 +695,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_TCLASS, "tclass=%d" }, #ifdef CONFIG_NVME_TCP_TLS { NVMF_OPT_KEYRING, "keyring=%d" }, { NVMF_OPT_TLS_KEY, "tls_key=%d" }, @@ -734,6 +735,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->hdr_digest = false; opts->data_digest = false; opts->tos = -1; /* < 0 == use transport default */ + opts->tclass = -1; /* < 0 == use transport default */ opts->tls = false; opts->tls_key = NULL; opts->keyring = NULL; @@ -991,6 +993,22 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tos = token; break; + case NVMF_OPT_TCLASS: + if (match_int(args, &token)) { + ret = -EINVAL; + goto out; + } + if (token < 0) { + pr_err("Invalid traffic class %d\n", token); + ret = -EINVAL; + goto out; + } + if (token > 255) { + pr_warn("Clamping traffic class to 255\n"); + token = 255; + } + opts->tclass = token; + break; case NVMF_OPT_KEYRING: if (match_int(args, &key_id) || key_id <= 0) { ret = -EINVAL; diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index caf5503d0833..3dfd40bd8960 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -67,6 +67,7 @@ enum { NVMF_OPT_KEYRING = 1 << 26, NVMF_OPT_TLS_KEY = 1 << 27, NVMF_OPT_CONCAT = 1 << 28, + NVMF_OPT_TCLASS = 1 << 29, }; /** @@ -109,6 +110,7 @@ enum { * @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service + * @tclass: IPv6 traffic class * @fast_io_fail_tmo: Fast I/O fail timeout in seconds */ struct nvmf_ctrl_options { @@ -139,6 +141,7 @@ struct nvmf_ctrl_options { unsigned int nr_write_queues; unsigned int nr_poll_queues; int tos; + int tclass; int fast_io_fail_tmo; }; -- 2.53.0