From: Geliang Tang <[email protected]>

This patch adds a new nvme target transport type NVMF_TRTYPE_MPTCP for
MPTCP. And defines a new nvmet_fabrics_ops named nvmet_mptcp_ops, which
is almost the same as nvmet_tcp_ops except .type. It is registered in
nvmet_tcp_init() and unregistered in nvmet_tcp_exit().

A MODULE_ALIAS for "nvmet-transport-4" is also added.

Note: NVMF_TRTYPE_MPTCP is temporarily assigned 4, a value currently
reserved in the NVMe over Fabrics specification. During "NVMe over
MPTCP" discussion at the LSF/MM/BPF 2026 conference, it was concluded
that MPTCP should be treated as a new transport type, rather than a
TCP variant. A request will be submitted to the NVMe working group to
officially allocate this value for MPTCP.

Cc: Hannes Reinecke <[email protected]>
Cc: John Meneghini <[email protected]>
Cc: Randy Jennings <[email protected]>
Cc: Nilay Shroff <[email protected]>
Co-developed-by: zhenwei pi <[email protected]>
Signed-off-by: zhenwei pi <[email protected]>
Co-developed-by: Hui Zhu <[email protected]>
Signed-off-by: Hui Zhu <[email protected]>
Co-developed-by: Gang Yan <[email protected]>
Signed-off-by: Gang Yan <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
---
 drivers/nvme/target/configfs.c |  1 +
 drivers/nvme/target/tcp.c      | 29 +++++++++++++++++++++++++++++
 include/linux/nvme.h           |  1 +
 3 files changed, 31 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index b88f897f06e2..51fc0f4d0c32 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -37,6 +37,7 @@ static struct nvmet_type_name_map nvmet_transport[] = {
        { NVMF_TRTYPE_RDMA,     "rdma" },
        { NVMF_TRTYPE_FC,       "fc" },
        { NVMF_TRTYPE_TCP,      "tcp" },
+       { NVMF_TRTYPE_MPTCP,    "mptcp" },
        { NVMF_TRTYPE_PCI,      "pci" },
        { NVMF_TRTYPE_LOOP,     "loop" },
 };
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 83fe001fc619..e2f3de364c2b 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -2299,6 +2299,23 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
        .host_traddr            = nvmet_tcp_host_port_addr,
 };
 
+#ifdef CONFIG_MPTCP
+static bool nvmet_mptcp_registered;
+
+static const struct nvmet_fabrics_ops nvmet_mptcp_ops = {
+       .owner                  = THIS_MODULE,
+       .type                   = NVMF_TRTYPE_MPTCP,
+       .msdbd                  = 1,
+       .add_port               = nvmet_tcp_add_port,
+       .remove_port            = nvmet_tcp_remove_port,
+       .queue_response         = nvmet_tcp_queue_response,
+       .delete_ctrl            = nvmet_tcp_delete_ctrl,
+       .install_queue          = nvmet_tcp_install_queue,
+       .disc_traddr            = nvmet_tcp_disc_port_addr,
+       .host_traddr            = nvmet_tcp_host_port_addr,
+};
+#endif
+
 static int __init nvmet_tcp_init(void)
 {
        int ret;
@@ -2312,6 +2329,11 @@ static int __init nvmet_tcp_init(void)
        if (ret)
                goto err;
 
+#ifdef CONFIG_MPTCP
+       if (!nvmet_register_transport(&nvmet_mptcp_ops))
+               nvmet_mptcp_registered = true;
+#endif
+
        return 0;
 err:
        destroy_workqueue(nvmet_tcp_wq);
@@ -2322,6 +2344,10 @@ static void __exit nvmet_tcp_exit(void)
 {
        struct nvmet_tcp_queue *queue;
 
+#ifdef CONFIG_MPTCP
+       if (nvmet_mptcp_registered)
+               nvmet_unregister_transport(&nvmet_mptcp_ops);
+#endif
        nvmet_unregister_transport(&nvmet_tcp_ops);
 
        flush_workqueue(nvmet_wq);
@@ -2341,3 +2367,6 @@ module_exit(nvmet_tcp_exit);
 MODULE_DESCRIPTION("NVMe target TCP transport driver");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("nvmet-transport-3"); /* 3 == NVMF_TRTYPE_TCP */
+#ifdef CONFIG_MPTCP
+MODULE_ALIAS("nvmet-transport-4"); /* 4 == NVMF_TRTYPE_MPTCP */
+#endif
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 041f30931a90..0eada1e0c652 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -68,6 +68,7 @@ enum {
        NVMF_TRTYPE_RDMA        = 1,    /* RDMA */
        NVMF_TRTYPE_FC          = 2,    /* Fibre Channel */
        NVMF_TRTYPE_TCP         = 3,    /* TCP/IP */
+       NVMF_TRTYPE_MPTCP       = 4,    /* Multipath TCP */
        NVMF_TRTYPE_LOOP        = 254,  /* Reserved for host usage */
        NVMF_TRTYPE_MAX,
 };
-- 
2.53.0


Reply via email to