From patchwork Fri Mar 11 10:34:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mingbao Sun X-Patchwork-Id: 12777767 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D931C433EF for ; Fri, 11 Mar 2022 10:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348029AbiCKKgi (ORCPT ); Fri, 11 Mar 2022 05:36:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348023AbiCKKgg (ORCPT ); Fri, 11 Mar 2022 05:36:36 -0500 Received: from smtp.tom.com (smtprz01.163.net [106.3.154.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2106F120F46 for ; Fri, 11 Mar 2022 02:35:29 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by vip-app02.163.net (Postfix) with ESMTP id 78527440165 for ; Fri, 11 Mar 2022 18:35:28 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994928; bh=R3j49KALSMnjuQeiVsymhqxJED/9xKOwSzuBBzckNSQ=; h=From:To:Cc:Subject:Date:From; b=cIxeJUWkDpEfQay55q1OipyMmLqQHo7DQl5MqLx0JGNH+Udw2XOuCcrsAEgWPMyjp HrixmJmWEdlm7wzbidMAfucbRiEMN61g2btZCgfmmJkIkO0IrVo1fKqaVWeUQ/6MWz dz5ozeAiKablIyHN4QzyIUtgy26Bp9A/Wd6GRi9s= Received: from localhost (HELO smtp.tom.com) ([127.0.0.1]) by localhost (TOM SMTP Server) with SMTP ID -1566189972 for ; Fri, 11 Mar 2022 18:35:28 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at mxtest.tom.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994928; bh=R3j49KALSMnjuQeiVsymhqxJED/9xKOwSzuBBzckNSQ=; h=From:To:Cc:Subject:Date:From; b=cIxeJUWkDpEfQay55q1OipyMmLqQHo7DQl5MqLx0JGNH+Udw2XOuCcrsAEgWPMyjp HrixmJmWEdlm7wzbidMAfucbRiEMN61g2btZCgfmmJkIkO0IrVo1fKqaVWeUQ/6MWz dz5ozeAiKablIyHN4QzyIUtgy26Bp9A/Wd6GRi9s= Received: from localhost.localdomain (unknown [101.93.196.13]) by antispamvip.163.net (Postfix) with ESMTPA id 1DF371541564; Fri, 11 Mar 2022 18:35:23 +0800 (CST) From: Mingbao Sun To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Dumazet , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , netdev@vger.kernel.org Cc: sunmingbao@tom.com, tyler.sun@dell.com, ping.gan@dell.com, yanxiu.cai@dell.com, libin.zhang@dell.com, ao.sun@dell.com Subject: [PATCH v2 1/3] tcp: export symbol tcp_set_congestion_control Date: Fri, 11 Mar 2022 18:34:12 +0800 Message-Id: <20220311103414.8255-1-sunmingbao@tom.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Mingbao Sun congestion-control could have a noticeable impaction on the performance of TCP-based communications. This is of course true to NVMe/TCP in the kernel. Different congestion-controls (e.g., cubic, dctcp) are suitable for different scenarios. Proper adoption of congestion control would benefit the performance. On the contrary, the performance could be destroyed. So to gain excellent performance against different network environments, NVMe/TCP tends to support specifying the congestion-control. This means NVMe/TCP (a kernel user) needs to set the congestion-control of its TCP sockets. Since the kernel API 'kernel_setsockopt' was removed, and since the function ‘tcp_set_congestion_control’ is just the real underlying guy handling this job, so it makes sense to get it exported. Signed-off-by: Mingbao Sun --- net/ipv4/tcp_cong.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index db5831e6c136..1d6a23e42f7d 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -344,10 +344,20 @@ int tcp_set_allowed_congestion_control(char *val) return ret; } -/* Change congestion control for socket. If load is false, then it is the - * responsibility of the caller to call tcp_init_congestion_control or - * tcp_reinit_congestion_control (if the current congestion control was - * already initialized. +/** + * tcp_set_congestion_control - set a sock's congestion control + * @sk: the sock. + * @name: the desired congestion control. + * @load: whether to load the required module in case not loaded. + * @cap_net_admin: indicating if the caller have the CAP_NET_ADMIN. + * + * Returns 0 or an error. + * + * Must be called on a locked sock. + * + * If load is false, then it is the responsibility of the caller to call + * tcp_init_congestion_control or tcp_reinit_congestion_control (if the + * current congestion control was already initialized). */ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, bool cap_net_admin) @@ -383,6 +393,7 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, rcu_read_unlock(); return err; } +EXPORT_SYMBOL_GPL(tcp_set_congestion_control); /* Slow start is used when congestion window is no greater than the slow start * threshold. We base on RFC2581 and also handle stretch ACKs properly. From patchwork Fri Mar 11 10:34:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingbao Sun X-Patchwork-Id: 12777768 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37747C433F5 for ; Fri, 11 Mar 2022 10:35:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348048AbiCKKgv (ORCPT ); Fri, 11 Mar 2022 05:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348053AbiCKKgt (ORCPT ); Fri, 11 Mar 2022 05:36:49 -0500 Received: from smtp.tom.com (smtprz02.163.net [106.3.154.235]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B3151BD064 for ; Fri, 11 Mar 2022 02:35:35 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by vip-app02.163.net (Postfix) with ESMTP id 41DBD44017A for ; Fri, 11 Mar 2022 18:35:35 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994935; bh=93JeBi/0/ADhIZMBBUs1HqDG4uLkWcGGpcH0lW56i4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQKynntHrs+TQClSMNr5YAJh1fgg8wk6b77ONBQPN81i7cuXBWZ9lOmag7DjDIWNS hBaBux2jPCfxgoIIvPRvOaKGNz9QZqS4XfQytZ/FBnejMoaMLs04RabOEl13yRix8j VxLYYJ71vfMrbOp5fmDWXxgSQKegy5MhBFslLMF4= Received: from localhost (HELO smtp.tom.com) ([127.0.0.1]) by localhost (TOM SMTP Server) with SMTP ID -301430619 for ; Fri, 11 Mar 2022 18:35:35 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at mxtest.tom.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994935; bh=93JeBi/0/ADhIZMBBUs1HqDG4uLkWcGGpcH0lW56i4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQKynntHrs+TQClSMNr5YAJh1fgg8wk6b77ONBQPN81i7cuXBWZ9lOmag7DjDIWNS hBaBux2jPCfxgoIIvPRvOaKGNz9QZqS4XfQytZ/FBnejMoaMLs04RabOEl13yRix8j VxLYYJ71vfMrbOp5fmDWXxgSQKegy5MhBFslLMF4= Received: from localhost.localdomain (unknown [101.93.196.13]) by antispamvip.163.net (Postfix) with ESMTPA id 56B381541576; Fri, 11 Mar 2022 18:35:31 +0800 (CST) From: Mingbao Sun To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Dumazet , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , netdev@vger.kernel.org Cc: sunmingbao@tom.com, tyler.sun@dell.com, ping.gan@dell.com, yanxiu.cai@dell.com, libin.zhang@dell.com, ao.sun@dell.com Subject: [PATCH v2 2/3] nvme-tcp: support specifying the congestion-control Date: Fri, 11 Mar 2022 18:34:13 +0800 Message-Id: <20220311103414.8255-2-sunmingbao@tom.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220311103414.8255-1-sunmingbao@tom.com> References: <20220311103414.8255-1-sunmingbao@tom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mingbao Sun congestion-control could have a noticeable impaction on the performance of TCP-based communications. This is of course true to NVMe_over_TCP. Different congestion-controls (e.g., cubic, dctcp) are suitable for different scenarios. Proper adoption of congestion control would benefit the performance. On the contrary, the performance could be destroyed. Though we can specify the congestion-control of NVMe_over_TCP via writing '/proc/sys/net/ipv4/tcp_congestion_control', but this also changes the congestion-control of all the future TCP sockets that have not been explicitly assigned the congestion-control, thus bringing potential impaction on their performance. So it makes sense to make NVMe_over_TCP support specifying the congestion-control. And this commit addresses the host side. Implementation approach: a new option called 'tcp_congestion' was created in fabrics opt_tokens for 'nvme connect' command to passed in the congestion-control specified by the user. Then later in nvme_tcp_alloc_queue, the specified congestion-control would be applied to the relevant sockets of the host side. Signed-off-by: Mingbao Sun --- drivers/nvme/host/fabrics.c | 18 ++++++++++++++++++ drivers/nvme/host/fabrics.h | 2 ++ drivers/nvme/host/tcp.c | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index ee79a6d639b4..ecd1ec4e473a 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "nvme.h" #include "fabrics.h" @@ -548,6 +549,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_TOS, "tos=%d" }, { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, { NVMF_OPT_DISCOVERY, "discovery" }, + { NVMF_OPT_TCP_CONGESTION, "tcp_congestion=%s" }, { NVMF_OPT_ERR, NULL } }; @@ -829,6 +831,21 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, case NVMF_OPT_DISCOVERY: opts->discovery_nqn = true; break; + case NVMF_OPT_TCP_CONGESTION: + p = match_strdup(args); + if (!p) { + ret = -ENOMEM; + goto out; + } + if (strlen(p) >= TCP_CA_NAME_MAX) { + ret = -EINVAL; + kfree(p); + goto out; + } + + kfree(opts->tcp_congestion); + opts->tcp_congestion = p; + break; default: pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p); @@ -947,6 +964,7 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts) kfree(opts->subsysnqn); kfree(opts->host_traddr); kfree(opts->host_iface); + kfree(opts->tcp_congestion); kfree(opts); } EXPORT_SYMBOL_GPL(nvmf_free_options); diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index c3203ff1c654..25fdc169949d 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -68,6 +68,7 @@ enum { NVMF_OPT_FAIL_FAST_TMO = 1 << 20, NVMF_OPT_HOST_IFACE = 1 << 21, NVMF_OPT_DISCOVERY = 1 << 22, + NVMF_OPT_TCP_CONGESTION = 1 << 23, }; /** @@ -117,6 +118,7 @@ struct nvmf_ctrl_options { unsigned int nr_io_queues; unsigned int reconnect_delay; bool discovery_nqn; + const char *tcp_congestion; bool duplicate_connect; unsigned int kato; struct nvmf_host *host; diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 10fc45d95b86..8491f96a39e5 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1487,6 +1487,20 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, if (nctrl->opts->tos >= 0) ip_sock_set_tos(queue->sock->sk, nctrl->opts->tos); + if (nctrl->opts->mask & NVMF_OPT_TCP_CONGESTION) { + lock_sock(queue->sock->sk); + ret = tcp_set_congestion_control(queue->sock->sk, + nctrl->opts->tcp_congestion, + true, true); + release_sock(queue->sock->sk); + if (ret) { + dev_err(nctrl->device, + "failed to set TCP congestion to %s: %d\n", + nctrl->opts->tcp_congestion, ret); + goto err_sock; + } + } + /* Set 10 seconds timeout for icresp recvmsg */ queue->sock->sk->sk_rcvtimeo = 10 * HZ; @@ -2650,7 +2664,8 @@ static struct nvmf_transport_ops nvme_tcp_transport = { NVMF_OPT_HOST_TRADDR | NVMF_OPT_CTRL_LOSS_TMO | NVMF_OPT_HDR_DIGEST | NVMF_OPT_DATA_DIGEST | NVMF_OPT_NR_WRITE_QUEUES | NVMF_OPT_NR_POLL_QUEUES | - NVMF_OPT_TOS | NVMF_OPT_HOST_IFACE, + NVMF_OPT_TOS | NVMF_OPT_HOST_IFACE | + NVMF_OPT_TCP_CONGESTION, .create_ctrl = nvme_tcp_create_ctrl, }; From patchwork Fri Mar 11 10:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingbao Sun X-Patchwork-Id: 12777769 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98CEAC433EF for ; Fri, 11 Mar 2022 10:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348099AbiCKKhD (ORCPT ); Fri, 11 Mar 2022 05:37:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241302AbiCKKgu (ORCPT ); Fri, 11 Mar 2022 05:36:50 -0500 Received: from smtp.tom.com (smtprz02.163.net [106.3.154.235]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDA491C2338 for ; Fri, 11 Mar 2022 02:35:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by vip-app02.163.net (Postfix) with ESMTP id 1860D440185 for ; Fri, 11 Mar 2022 18:35:42 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994942; bh=F3vKEGSv90LjLhaBsvzJwFCV62L0vSG/lnPB+DbenZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JN3viEXGYMdqsBb7GCEVZYHXnACBZGp2PWwLLDXY9ftDkuByr+gFlTrQQsF9vzNqf p4iQv680G/+03MkmldVcFeRf6SkYM95cRXGkBiXHRbeo65yPBZmpqxMiL6HVfDF0Qn mmrpDYYtB5ADBJ6teGmrE6XevGgqoEh9vTOiJCsE= Received: from localhost (HELO smtp.tom.com) ([127.0.0.1]) by localhost (TOM SMTP Server) with SMTP ID -1402247074 for ; Fri, 11 Mar 2022 18:35:42 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at mxtest.tom.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=mail; t=1646994942; bh=F3vKEGSv90LjLhaBsvzJwFCV62L0vSG/lnPB+DbenZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JN3viEXGYMdqsBb7GCEVZYHXnACBZGp2PWwLLDXY9ftDkuByr+gFlTrQQsF9vzNqf p4iQv680G/+03MkmldVcFeRf6SkYM95cRXGkBiXHRbeo65yPBZmpqxMiL6HVfDF0Qn mmrpDYYtB5ADBJ6teGmrE6XevGgqoEh9vTOiJCsE= Received: from localhost.localdomain (unknown [101.93.196.13]) by antispamvip.163.net (Postfix) with ESMTPA id EDA1C1541564; Fri, 11 Mar 2022 18:35:37 +0800 (CST) From: Mingbao Sun To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Dumazet , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , netdev@vger.kernel.org Cc: sunmingbao@tom.com, tyler.sun@dell.com, ping.gan@dell.com, yanxiu.cai@dell.com, libin.zhang@dell.com, ao.sun@dell.com Subject: [PATCH v2 3/3] nvmet-tcp: support specifying the congestion-control Date: Fri, 11 Mar 2022 18:34:14 +0800 Message-Id: <20220311103414.8255-3-sunmingbao@tom.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220311103414.8255-1-sunmingbao@tom.com> References: <20220311103414.8255-1-sunmingbao@tom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mingbao Sun congestion-control could have a noticeable impaction on the performance of TCP-based communications. This is of course true to NVMe_over_TCP. Different congestion-controls (e.g., cubic, dctcp) are suitable for different scenarios. Proper adoption of congestion control would benefit the performance. On the contrary, the performance could be destroyed. Though we can specify the congestion-control of NVMe_over_TCP via writing '/proc/sys/net/ipv4/tcp_congestion_control', but this also changes the congestion-control of all the future TCP sockets that have not been explicitly assigned the congestion-control, thus bringing potential impaction on their performance. So it makes sense to make NVMe_over_TCP support specifying the congestion-control. And this commit addresses the target side. Implementation approach: the following new file entry was created for user to specify the congestion-control of each nvmet port. '/sys/kernel/config/nvmet/ports/X/tcp_congestion' Then later in nvmet_tcp_add_port, the specified congestion-control would be applied to the listening socket of the nvmet port. Signed-off-by: Mingbao Sun --- drivers/nvme/target/configfs.c | 42 ++++++++++++++++++++++++++++++++++ drivers/nvme/target/nvmet.h | 1 + drivers/nvme/target/tcp.c | 13 +++++++++++ 3 files changed, 56 insertions(+) diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index 091a0ca16361..7b7d95f6f582 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "nvmet.h" @@ -222,6 +223,45 @@ static ssize_t nvmet_addr_trsvcid_store(struct config_item *item, CONFIGFS_ATTR(nvmet_, addr_trsvcid); +static ssize_t nvmet_tcp_congestion_show(struct config_item *item, + char *page) +{ + struct nvmet_port *port = to_nvmet_port(item); + + return snprintf(page, PAGE_SIZE, "%s\n", + port->tcp_congestion ? port->tcp_congestion : ""); +} + +static ssize_t nvmet_tcp_congestion_store(struct config_item *item, + const char *page, size_t count) +{ + struct nvmet_port *port = to_nvmet_port(item); + int len; + char *buf; + + len = strcspn(page, "\n"); + if (!len) + return -EINVAL; + + if (nvmet_is_port_enabled(port, __func__)) + return -EACCES; + + buf = kmemdup_nul(page, len, GFP_KERNEL); + if (!buf) + return -ENOMEM; + if (strlen(buf) >= TCP_CA_NAME_MAX) { + kfree(buf); + return -EINVAL; + } + + kfree(port->tcp_congestion); + port->tcp_congestion = buf; + + return count; +} + +CONFIGFS_ATTR(nvmet_, tcp_congestion); + static ssize_t nvmet_param_inline_data_size_show(struct config_item *item, char *page) { @@ -1597,6 +1637,7 @@ static void nvmet_port_release(struct config_item *item) list_del(&port->global_entry); kfree(port->ana_state); + kfree(port->tcp_congestion); kfree(port); } @@ -1605,6 +1646,7 @@ static struct configfs_attribute *nvmet_port_attrs[] = { &nvmet_attr_addr_treq, &nvmet_attr_addr_traddr, &nvmet_attr_addr_trsvcid, + &nvmet_attr_tcp_congestion, &nvmet_attr_addr_trtype, &nvmet_attr_param_inline_data_size, #ifdef CONFIG_BLK_DEV_INTEGRITY diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 69637bf8f8e1..76a57c4c3456 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -145,6 +145,7 @@ struct nvmet_port { struct config_group ana_groups_group; struct nvmet_ana_group ana_default_group; enum nvme_ana_state *ana_state; + const char *tcp_congestion; void *priv; bool enabled; int inline_data_size; diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 83ca577f72be..311383c6d7da 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1741,6 +1741,19 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) if (so_priority > 0) sock_set_priority(port->sock->sk, so_priority); + if (nport->tcp_congestion) { + lock_sock(port->sock->sk); + ret = tcp_set_congestion_control(port->sock->sk, + nport->tcp_congestion, + true, true); + release_sock(port->sock->sk); + if (ret) { + pr_err("failed to set port socket's congestion to %s: %d\n", + nport->tcp_congestion, ret); + goto err_sock; + } + } + ret = kernel_bind(port->sock, (struct sockaddr *)&port->addr, sizeof(port->addr)); if (ret) {