From nobody Mon Apr 6 10:46:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B93B622A817 for ; Mon, 30 Mar 2026 09:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774863943; cv=none; b=e9dQY5wOCEtY6J8GwLYqNQqcJ0xQfzdPXvtEd1r2INOGXem7OQqUuzxDhfleWFqz87X3ZJXG5+8SGAtkfjo/qG+RQ2zwyPTL6NPYfJAnFQrP9StanTW4jBf9ky9Z1KHtwGbVYqz2LD9BYHuCQ9DmgqfuSTS9LAzpWV1pZytqG1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774863943; c=relaxed/simple; bh=bs1rj6uG8YvY3RO9LCkFOtUtGS5WwGiSa2YD/dQ3BBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c8z66SJn2zdtIYfNF0MEVCPf87PPddgUtPtSt3cIlVhxtD3pAeJXcGLupghs2CSQLUNYfZBwZVBWadO33+oHp1PZiJY1knTwMFwo+lB+4RB5PFSAEgJI3L58n50dO/EhtNS6u6vvPfhdnfJ1rLx4UiSp/OyVpK66UkyACdGdGII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=apyVr9PA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="apyVr9PA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFCAFC4CEF7; Mon, 30 Mar 2026 09:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774863943; bh=bs1rj6uG8YvY3RO9LCkFOtUtGS5WwGiSa2YD/dQ3BBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=apyVr9PAIemwrZBdqrOx+PqD7xYL7EYV7w88lOsq7/MWi1qevnwZaHa9N3rDVL05g 9d/SD3Gw/vSs3AsQq+PWyQtH+dNMAgdyZ6lGqZqRK9K5OULUBHG5Yyk85lY3MD4i+x tDl2A9Y8ruh/oN2+GkQvoqWMsI4QKyT73D1TWLhvSHQ9Mr/qvAra79cCzvkkncLxIz srvzdBE46P6nrRf0uAvj0selQnlUXBoagy64FdIQvRMdBLSYEpR2ylTlFZKbeaB2Kw lj13/uotk/Qwn57Ke0n48DWzw1AyQTNQLiHmouIubArbXzQsm+RlTzUosKU3/e57Yp qCj9zOJImbBpg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , Hannes Reinecke , zhenwei pi , Hui Zhu , Gang Yan Subject: [RFC mptcp-next v6 3/7] nvmet-tcp: register target mptcp transport Date: Mon, 30 Mar 2026 17:43:28 +0800 Message-ID: <6fa7a16a2c7e74a43dbe8e6ed38211f955e67fef.1774862875.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch defines a new nvmet_fabrics_ops named nvmet_mptcp_ops, which is almost identical to nvmet_tcp_ops except for the .type field. It is registered in nvmet_tcp_init() and unregistered in nvmet_tcp_exit(). This new nvmet_fabrics_ops is selected in nvmet_tcp_done_recv_pdu() based on the protocol type. A MODULE_ALIAS for "nvmet-transport-4" is also added. v2: - use trtype instead of tsas (Hannes). v3: - check mptcp protocol from disc_addr.trtype instead of passing a parameter (Hannes). v4: - check CONFIG_MPTCP. Cc: Hannes Reinecke Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/configfs.c | 1 + drivers/nvme/target/tcp.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index 3088e044dbcb..4b7498ffb102 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -38,6 +38,7 @@ static struct nvmet_type_name_map nvmet_transport[] =3D { { 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 03f876440f6d..86ff4ed0f753 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -222,6 +222,7 @@ static DEFINE_MUTEX(nvmet_tcp_queue_mutex); =20 static struct workqueue_struct *nvmet_tcp_wq; static const struct nvmet_fabrics_ops nvmet_tcp_ops; +static const struct nvmet_fabrics_ops nvmet_mptcp_ops; static void nvmet_tcp_free_cmd(struct nvmet_tcp_cmd *c); static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd); =20 @@ -1077,7 +1078,9 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_q= ueue *queue) req =3D &queue->cmd->req; memcpy(req->cmd, nvme_cmd, sizeof(*nvme_cmd)); =20 - if (unlikely(!nvmet_req_init(req, &queue->nvme_sq, &nvmet_tcp_ops))) { + if (unlikely(!nvmet_req_init(req, &queue->nvme_sq, + sk_is_tcp(queue->sock->sk) ? + &nvmet_tcp_ops : &nvmet_mptcp_ops))) { pr_err("failed cmd %p id %d opcode %d, data_len: %d, status: %04x\n", req->cmd, req->cmd->common.command_id, req->cmd->common.opcode, @@ -2259,6 +2262,19 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = =3D { .host_traddr =3D nvmet_tcp_host_port_addr, }; =20 +static const struct nvmet_fabrics_ops nvmet_mptcp_ops =3D { + .owner =3D THIS_MODULE, + .type =3D NVMF_TRTYPE_MPTCP, + .msdbd =3D 1, + .add_port =3D nvmet_tcp_add_port, + .remove_port =3D nvmet_tcp_remove_port, + .queue_response =3D nvmet_tcp_queue_response, + .delete_ctrl =3D nvmet_tcp_delete_ctrl, + .install_queue =3D nvmet_tcp_install_queue, + .disc_traddr =3D nvmet_tcp_disc_port_addr, + .host_traddr =3D nvmet_tcp_host_port_addr, +}; + static int __init nvmet_tcp_init(void) { int ret; @@ -2272,6 +2288,12 @@ static int __init nvmet_tcp_init(void) if (ret) goto err; =20 + ret =3D nvmet_register_transport(&nvmet_mptcp_ops); + if (ret) { + nvmet_unregister_transport(&nvmet_tcp_ops); + goto err; + } + return 0; err: destroy_workqueue(nvmet_tcp_wq); @@ -2282,6 +2304,7 @@ static void __exit nvmet_tcp_exit(void) { struct nvmet_tcp_queue *queue; =20 + nvmet_unregister_transport(&nvmet_mptcp_ops); nvmet_unregister_transport(&nvmet_tcp_ops); =20 flush_workqueue(nvmet_wq); @@ -2301,3 +2324,4 @@ module_exit(nvmet_tcp_exit); MODULE_DESCRIPTION("NVMe target TCP transport driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("nvmet-transport-3"); /* 3 =3D=3D NVMF_TRTYPE_TCP */ +MODULE_ALIAS("nvmet-transport-4"); /* 4 =3D=3D NVMF_TRTYPE_MPTCP */ --=20 2.51.0