From patchwork Tue Aug 22 15:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361032 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 F10B71D2E9 for ; Tue, 22 Aug 2023 15:04:57 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742D3126 for ; Tue, 22 Aug 2023 08:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLV1kduBLS594fj4A9uraUQlFyBTJ+f7vR0ikT4cvwEMgMPDHj0tb8mZI7OGXiDPbO67kqUmiwbkGoOrygN8dYqAP5hLX8UWGrMRf+0VSVJIWOfmetX+RPfwkuAJuxVoVy3nLw9otjc7Ma/qmu4fju08dwDbErBUNMbfozEzTqSr98BMXkUXfg1yoHXqAZ2An1d5PIIEc8yyxH1RngPqaWHI47WEwl8vZeNk+9Fs89evQhWAIK8fodvkTvp/RHUyUU8XKA4SNjqFBG4PWyMnQ59nIXBzJXbrgg7CTmY8yMuw1zPcshgXRHoISyCyU2QGeb6E0TuDfGaMivDUGrwgGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uNoWCgEwkncrOue8rFja0CKoXQtmTBjVxyiB/UV1UGc=; b=gWlaZ7J7k+C11MXOXStNpODbjqaO+aTkXZaFyawwQ0YNilydKLKVNj8fFp1oNZeWSSyUVKzZVP3XfFO7uwFZQ6VLS6fnclukTuJE+iXGTSHYxKZA+yB0VUUY0M1V+H2fLYzjEC2i69v/n7T1xhquM4FZe+UmQMCIOIaFcxNdNQQDXMI6Qu+4Rg5lAxddslPRHI82mN6pL/UVSmgqHTRdQhlIM/XelIR/QRhJ+F3Bd6bR0ZlFOnp+F5ZK3LmVqknjGdSkTLbFtkd2rB2m4zOJBj1OjKSvQJYe+qWmH7XRQWxtlXID/3BXB4Ces3DxX69h1a96APGZdDIcvqmNeR7OrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uNoWCgEwkncrOue8rFja0CKoXQtmTBjVxyiB/UV1UGc=; b=X84sj38EY5E5F/Rf6NkhPcVgqwBABPQB78LeGuX61wA7mP2RHq5UQ1e9uZjkI0FPscSDpT5thqtA+jc5lRaioZucDGblzgwgywBIUYOV4PfPXFdEHRsDGbUIGfIiqkIuj9Gj55MSJM7tIBeNpQmVsTKh+sKa8I6vunrkh8UNI/9RgNuws7bOccvaJAkFOidjtCrLtT9ZnZqQm0WBK0r6B3H25zIc80AfzNqsS/IXQRiABH0u9f/nnEJ1nUpOJ/oJk+ZX6zUP3q+5SZcdsYJKkMNTwXH2EMkJfq0Kv/ey3mCMKYj/xr+CyEW5bVw4x3wstHH5vQ4DVmP2pwrIpBkbuA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7378.namprd12.prod.outlook.com (2603:10b6:510:20d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:04:51 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:04:51 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Boris Pismenny , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 01/24] net: Introduce direct data placement tcp offload Date: Tue, 22 Aug 2023 15:04:02 +0000 Message-Id: <20230822150425.3390-2-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0255.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::18) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7378:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f167e16-e023-4708-2482-08dba32122b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SfcCyDOgDDn2WfrQuLwcseOKoZdJHJjiLFq4UGoI41de6UtvJTZfH4yxDtXsuh0HUCqpG/OZtv0/eJxp/xXpdIAyadQZeFzUk1cJh95ngYaqbdtMddShakx7v0Vud1IYPCmAmt+SRfvKKYbyNyW5FyJNjkvAQPKpY2BTEHEav81z9smq7LkDxSMe79JUwo9zybsTSMc4CI27za1djem1DYJPUgoxX4dNFCsq1jLe417rSXTkQoEng602OaSMlURVdXba7XMdU72HYRLC2aedvNwCS5lx7t2Xqf4ePWr8F8mx4/WlSgxW0mRiB71YWqvbILkKnkOWRCKAOdkKvjN+GOE1KhHvj08wgLFzSDkdgiVpy75iq9nhAhEcrseNBd+Kr6HBBFNEFmtsDrMYuG1TbjiZIF2xwLuhngpk5yDkj1p6rDanv4KzOtqzmS6Ep3ITq+DAaJiifbwcP0fu7oAFKGXBUZvTwsm4U/UnKru2aZxJrxrmlr9TtKudlvoZLdejjfLl5gSgCMi/KH8HsYpI8E1ZNfEMt0ZrXogxUlUQBWcxS8Ih/zcBzLTsb8pBrKaC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199024)(186009)(1800799009)(2906002)(30864003)(83380400001)(7416002)(6506007)(6486002)(38100700002)(5660300002)(26005)(86362001)(8676002)(8936002)(2616005)(4326008)(107886003)(316002)(6512007)(66556008)(66476007)(478600001)(66946007)(6666004)(41300700001)(36756003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q+y6LcJo/IiTsQziHJ5mVZUtPNDVEDIwQteM5af6NKMh62EkKXyvyv6H3l4wQ0WTljdwF2zphFb7gQIj+qMr6xZlcOEW/puwuf39REZyooWoZRcdilYEWapbcjw6eT/zeBe4gXalSru/ay9x099RWwX3YPDEbPQCQPTsL05r9nkwzCK5yrZueZf3wEzlZt5VuMNJohCScS7hJ0KrrvIpZjsuZoIoTQ23wkQpdcdqXQVNezRC00UqlsbjDJvGEZ6fQI64HYdxCgOviZhgHylVMhcIl49bsxNBGisE7d1C08c94anCkax3t9sYInGVWFWyOnqSX3NplDMEVEWwe4U0U8PL27ytECl+5bUr6j92RCVA/bKYSjiujMHDKBn1x2nkJkuZQXJzeGEuoMZ0jFZ8xqdNUUyEQHVM0CfXL1Jgw3iObWyrNtdHu5c5XGXT6fiIKBM9UatnL2B/rm76Yfso7t9KyFp2/q2SSI2yw/XIdsHsr5Hp6ThPCjiO1b6oUMkQ92STWK91Xq+pHRc2GYyUrIHuIEPOF9EqysrGtIGI4ZKufZT5Qo4ssc7jRrg2cJYncb4X31aeo5L6vFwf/BcPlp7JuAgpGZbz/4t9OCmvBqr1q4Qpxe/VzsJ+dwB/nXDu6rMihfxwjE/79BzASWgo2dwzH/PnIdFvKWWuopiCZEL+4XAAfzREzPIRgbLbzVbjVGImoOqCNVPxzAtjsU0y5vBaqbhMoq2lJcAoeuOTxl6aiKudOwa8Sue7+FCohYEOeYwicBkdkFPbjcJMr/iu10O7TwrDyAKE/l+VhJboEsAi3drN4n/Xh0ES+mjO2vh/rNQNhzaCo2HXmPxNqohHkAQAhzJzik8o/xpMbMcusCeHiwB+ZKSihh0hTgtqDIiBAXwa24Fkw3EG59KFLho8B7a9LvhQQTh3cdj7qydN88I2jXOQRSgTJGi1q+YrFoNv5a2DTQSlImnKtyKfNehCmceCpLWlvMEhlcThuhuWSv2Vt+3cSRi4YACthJ4jyeuSxZpIrQIO0ePF/77o++ESQV8ZjdQYs/dlFH9VjPsMTk4ePLITmW2tA1LiYh8Sq691kgT6u+fyt5WrxeoCHfU28o6z4nul+lF0ae8XArO3xnfOF3zPBANe+QcTBR4GmEjf2I36y3V9kg2pBJPR2oKe666Ar/x3dtjvu2r1B0m63BnQaZLgVWh3rhoJTJcU9I3zFy0fINdJRDLRFir1nbAxequmtfurGZJg3YDMWRKZc1dYlUjr9uWaIKVBjFSq8ikhz72knxQjUUB+aoNF25QCa78gX59luA/E9vRv8y5tjtiPUFySyDHbM/J0a6LgfC4yg+e3kRp1QENBxGhSNZDckP7PtoYLd2gCx16gfdxc3EBnIFpFWihNfAM70gyuSaeRqDu5NkIH9k+CBLNCfZsOHI22WXOWKbf+r9AE6LnBnFxCF3jOyIT62I0/tfiKOwE2/MMFCSje9fT4gUdIndNRssD1/EJdtQN12r2OKDN9Zio/NcfmZ0oCjF3AfF8uVHtHNMIeiIyosg3uMoQrba+5CVk7W3k82zniVcM1g41UzGSLtgkuDSUxuTA2TZnDm+6a X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f167e16-e023-4708-2482-08dba32122b8 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:04:51.7596 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SJ6u4fRS71HI55g0JXnXN6ITPy0FgMRGUbtygWqK+ivL2/LdRD/TC7MCN7OS6+/6618GN2PHpLaZmpxMFy0H4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7378 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Boris Pismenny This commit introduces direct data placement (DDP) offload for TCP. The motivation is saving compute resources/cycles that are spent to copy data from SKBs to the block layer buffers and CRC calculation/verification for received PDUs (Protocol Data Units). The DDP capability is accompanied by new net_device operations that configure hardware contexts. There is a context per socket, and a context per DDP operation. Additionally, a resynchronization routine is used to assist hardware handle TCP OOO, and continue the offload. Furthermore, we let the offloading driver advertise what is the max hw sectors/segments. The interface includes the following net-device ddp operations: 1. sk_add - add offload for the queue represented by socket+config pair 2. sk_del - remove the offload for the socket/queue 3. ddp_setup - request copy offload for buffers associated with an IO 4. ddp_teardown - release offload resources for that IO 5. limits - query NIC driver for quirks and limitations (e.g. max number of scatter gather entries per IO) 6. set_caps - request ULP DDP capabilities enablement 7. get_stats - query NIC driver for ULP DDP stats Using this interface, the NIC hardware will scatter TCP payload directly to the BIO pages according to the command_id. To maintain the correctness of the network stack, the driver is expected to construct SKBs that point to the BIO pages. The SKB passed to the network stack from the driver represents data as it is on the wire, while it is pointing directly to data in destination buffers. As a result, data from page frags should not be copied out to the linear part. To avoid needless copies, such as when using skb_condense, we mark the skb->ulp_ddp bit. In addition, the skb->ulp_crc will be used by the upper layers to determine if CRC re-calculation is required. The two separated skb indications are needed to avoid false positives GRO flushing events. Follow-up patches will use this interface for DDP in NVMe-TCP. Capability bits stored in net_device allow drivers to report which ULP DDP capabilities a device supports. Control over these capabilities will be exposed to userspace in later patches. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- include/linux/netdevice.h | 15 ++ include/linux/skbuff.h | 25 ++- include/net/inet_connection_sock.h | 6 + include/net/ulp_ddp.h | 262 +++++++++++++++++++++++++++++ include/net/ulp_ddp_caps.h | 35 ++++ net/Kconfig | 20 +++ net/core/Makefile | 1 + net/core/skbuff.c | 3 +- net/core/ulp_ddp.c | 70 ++++++++ net/ipv4/tcp_input.c | 13 +- net/ipv4/tcp_ipv4.c | 3 + net/ipv4/tcp_offload.c | 3 + 12 files changed, 453 insertions(+), 3 deletions(-) create mode 100644 include/net/ulp_ddp.h create mode 100644 include/net/ulp_ddp_caps.h create mode 100644 net/core/ulp_ddp.c diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0896aaa91dd7..04255823079d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -53,6 +53,10 @@ #include #include +#ifdef CONFIG_ULP_DDP +#include +#endif + struct netpoll_info; struct device; struct ethtool_ops; @@ -1406,6 +1410,8 @@ struct netdev_net_notifier { * struct kernel_hwtstamp_config *kernel_config, * struct netlink_ext_ack *extack); * Change the hardware timestamping parameters for NIC device. + * struct ulp_ddp_dev_ops *ulp_ddp_ops; + * ULP DDP operations (see include/net/ulp_ddp.h) */ struct net_device_ops { int (*ndo_init)(struct net_device *dev); @@ -1645,6 +1651,9 @@ struct net_device_ops { int (*ndo_hwtstamp_set)(struct net_device *dev, struct kernel_hwtstamp_config *kernel_config, struct netlink_ext_ack *extack); +#if IS_ENABLED(CONFIG_ULP_DDP) + const struct ulp_ddp_dev_ops *ulp_ddp_ops; +#endif }; /** @@ -1816,6 +1825,9 @@ enum netdev_ml_priv_type { * @mpls_features: Mask of features inheritable by MPLS * @gso_partial_features: value(s) from NETIF_F_GSO\* * + * @ulp_ddp_caps: Bitflags keeping track of supported and enabled + * ULP DDP capabilities. + * * @ifindex: interface index * @group: The group the device belongs to * @@ -2112,6 +2124,9 @@ struct net_device { netdev_features_t mpls_features; netdev_features_t gso_partial_features; +#ifdef CONFIG_ULP_DDP + struct ulp_ddp_netdev_caps ulp_ddp_caps; +#endif unsigned int min_mtu; unsigned int max_mtu; unsigned short type; diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 4174c4b82d13..75558f0ddde8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -810,6 +810,8 @@ typedef unsigned char *sk_buff_data_t; * delivery_time in mono clock base (i.e. EDT). Otherwise, the * skb->tstamp has the (rcv) timestamp at ingress and * delivery_time at egress. + * @ulp_ddp: DDP offloaded + * @ulp_crc: CRC offloaded * @napi_id: id of the NAPI struct this skb came from * @sender_cpu: (aka @napi_id) source CPU in XPS * @alloc_cpu: CPU which did the skb allocation. @@ -989,7 +991,10 @@ struct sk_buff { #if IS_ENABLED(CONFIG_IP_SCTP) __u8 csum_not_inet:1; #endif - +#ifdef CONFIG_ULP_DDP + __u8 ulp_ddp:1; + __u8 ulp_crc:1; +#endif #if defined(CONFIG_NET_SCHED) || defined(CONFIG_NET_XGRESS) __u16 tc_index; /* traffic control index */ #endif @@ -5063,5 +5068,23 @@ static inline void skb_mark_for_recycle(struct sk_buff *skb) ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, ssize_t maxsize, gfp_t gfp); +static inline bool skb_is_ulp_ddp(struct sk_buff *skb) +{ +#ifdef CONFIG_ULP_DDP + return skb->ulp_ddp; +#else + return 0; +#endif +} + +static inline bool skb_is_ulp_crc(struct sk_buff *skb) +{ +#ifdef CONFIG_ULP_DDP + return skb->ulp_crc; +#else + return 0; +#endif +} + #endif /* __KERNEL__ */ #endif /* _LINUX_SKBUFF_H */ diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 5d2fcc137b88..daefa3771b66 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -68,6 +68,8 @@ struct inet_connection_sock_af_ops { * @icsk_ulp_ops Pluggable ULP control hook * @icsk_ulp_data ULP private data * @icsk_clean_acked Clean acked data hook + * @icsk_ulp_ddp_ops Pluggable ULP direct data placement control hook + * @icsk_ulp_ddp_data ULP direct data placement private data * @icsk_ca_state: Congestion control state * @icsk_retransmits: Number of unrecovered [RTO] timeouts * @icsk_pending: Scheduled timer event @@ -98,6 +100,10 @@ struct inet_connection_sock { const struct tcp_ulp_ops *icsk_ulp_ops; void __rcu *icsk_ulp_data; void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq); +#ifdef CONFIG_ULP_DDP + const struct ulp_ddp_ulp_ops *icsk_ulp_ddp_ops; + void __rcu *icsk_ulp_ddp_data; +#endif unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu); __u8 icsk_ca_state:5, icsk_ca_initialized:1, diff --git a/include/net/ulp_ddp.h b/include/net/ulp_ddp.h new file mode 100644 index 000000000000..e162ac9c3d18 --- /dev/null +++ b/include/net/ulp_ddp.h @@ -0,0 +1,262 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * ulp_ddp.h + * Author: Boris Pismenny + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ +#ifndef _ULP_DDP_H +#define _ULP_DDP_H + +#include +#include +#include + +#include "ulp_ddp_caps.h" + +enum ulp_ddp_type { + ULP_DDP_NVME = 1, +}; + +/** + * struct nvme_tcp_ddp_limits - nvme tcp driver limitations + * + * @full_ccid_range: true if the driver supports the full CID range + */ +struct nvme_tcp_ddp_limits { + bool full_ccid_range; +}; + +/** + * struct ulp_ddp_limits - Generic ulp ddp limits: tcp ddp + * protocol limits. + * Add new instances of ulp_ddp_limits in the union below (nvme-tcp, etc.). + * + * @type: type of this limits struct + * @max_ddp_sgl_len: maximum sgl size supported (zero means no limit) + * @io_threshold: minimum payload size required to offload + * @tls: support for ULP over TLS + * @nvmeotcp: NVMe-TCP specific limits + */ +struct ulp_ddp_limits { + enum ulp_ddp_type type; + int max_ddp_sgl_len; + int io_threshold; + bool tls:1; + union { + struct nvme_tcp_ddp_limits nvmeotcp; + }; +}; + +/** + * struct nvme_tcp_ddp_config - nvme tcp ddp configuration for an IO queue + * + * @pfv: pdu version (e.g., NVME_TCP_PFV_1_0) + * @cpda: controller pdu data alignment (dwords, 0's based) + * @dgst: digest types enabled (header or data, see enum nvme_tcp_digest_option). + * The netdev will offload crc if it is supported. + * @queue_size: number of nvme-tcp IO queue elements + * @queue_id: queue identifier + * @io_cpu: cpu core running the IO thread for this queue + */ +struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; + int io_cpu; +}; + +/** + * struct ulp_ddp_config - Generic ulp ddp configuration + * Add new instances of ulp_ddp_config in the union below (nvme-tcp, etc.). + * + * @type: type of this config struct + * @nvmeotcp: NVMe-TCP specific config + */ +struct ulp_ddp_config { + enum ulp_ddp_type type; + union { + struct nvme_tcp_ddp_config nvmeotcp; + }; +}; + +/** + * struct ulp_ddp_io - ulp ddp configuration for an IO request. + * + * @command_id: identifier on the wire associated with these buffers + * @nents: number of entries in the sg_table + * @sg_table: describing the buffers for this IO request + * @first_sgl: first SGL in sg_table + */ +struct ulp_ddp_io { + u32 command_id; + int nents; + struct sg_table sg_table; + struct scatterlist first_sgl[SG_CHUNK_SIZE]; +}; + +struct ethtool_ulp_ddp_stats; +struct netlink_ext_ack; + +/** + * struct ulp_ddp_dev_ops - operations used by an upper layer protocol + * to configure ddp offload + * + * @limits: query ulp driver limitations and quirks. + * @sk_add: add offload for the queue represented by socket+config + * pair. this function is used to configure either copy, crc + * or both offloads. + * @sk_del: remove offload from the socket, and release any device + * related resources. + * @setup: request copy offload for buffers associated with a + * command_id in ulp_ddp_io. + * @teardown: release offload resources association between buffers + * and command_id in ulp_ddp_io. + * @resync: respond to the driver's resync_request. Called only if + * resync is successful. + * @set_caps: set device ULP DDP capabilities. + * returns a negative error code or zero. + * @get_stats: query ULP DDP statistics. + */ +struct ulp_ddp_dev_ops { + int (*limits)(struct net_device *netdev, + struct ulp_ddp_limits *limits); + int (*sk_add)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config); + void (*sk_del)(struct net_device *netdev, + struct sock *sk); + int (*setup)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io); + void (*teardown)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io, + void *ddp_ctx); + void (*resync)(struct net_device *netdev, + struct sock *sk, u32 seq); + int (*set_caps)(struct net_device *dev, unsigned long *bits, + struct netlink_ext_ack *extack); + int (*get_stats)(struct net_device *dev, + struct ethtool_ulp_ddp_stats *stats); +}; + +#define ULP_DDP_RESYNC_PENDING BIT(0) + +/** + * struct ulp_ddp_ulp_ops - Interface to register upper layer + * Direct Data Placement (DDP) TCP offload. + * @resync_request: NIC requests ulp to indicate if @seq is the start + * of a message. + * @ddp_teardown_done: NIC driver informs the ulp that teardown is done, + * used for async completions. + */ +struct ulp_ddp_ulp_ops { + bool (*resync_request)(struct sock *sk, u32 seq, u32 flags); + void (*ddp_teardown_done)(void *ddp_ctx); +}; + +/** + * struct ulp_ddp_ctx - Generic ulp ddp context + * + * @type: type of this context struct + * @buf: protocol-specific context struct + */ +struct ulp_ddp_ctx { + enum ulp_ddp_type type; + unsigned char buf[]; +}; + +static inline struct ulp_ddp_ctx *ulp_ddp_get_ctx(const struct sock *sk) +{ +#ifdef CONFIG_ULP_DDP + struct inet_connection_sock *icsk = inet_csk(sk); + + return (__force struct ulp_ddp_ctx *)icsk->icsk_ulp_ddp_data; +#else + return NULL; +#endif +} + +static inline void ulp_ddp_set_ctx(struct sock *sk, void *ctx) +{ +#ifdef CONFIG_ULP_DDP + struct inet_connection_sock *icsk = inet_csk(sk); + + rcu_assign_pointer(icsk->icsk_ulp_ddp_data, ctx); +#endif +} + +static inline int ulp_ddp_setup(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io) +{ +#ifdef CONFIG_ULP_DDP + return netdev->netdev_ops->ulp_ddp_ops->setup(netdev, sk, io); +#else + return -EOPNOTSUPP; +#endif +} + +static inline void ulp_ddp_teardown(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io, + void *ddp_ctx) +{ +#ifdef CONFIG_ULP_DDP + netdev->netdev_ops->ulp_ddp_ops->teardown(netdev, sk, io, ddp_ctx); +#endif +} + +static inline void ulp_ddp_resync(struct net_device *netdev, + struct sock *sk, + u32 seq) +{ +#ifdef CONFIG_ULP_DDP + netdev->netdev_ops->ulp_ddp_ops->resync(netdev, sk, seq); +#endif +} + +#ifdef CONFIG_ULP_DDP + +int ulp_ddp_sk_add(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config, + const struct ulp_ddp_ulp_ops *ops); + +void ulp_ddp_sk_del(struct net_device *netdev, + struct sock *sk); + +bool ulp_ddp_query_limits(struct net_device *netdev, + struct ulp_ddp_limits *limits, + enum ulp_ddp_type type, + int cap_bit_nr, + bool tls); + +#else + +static inline int ulp_ddp_sk_add(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config, + const struct ulp_ddp_ulp_ops *ops) +{ + return -EOPNOTSUPP; +} + +static inline void ulp_ddp_sk_del(struct net_device *netdev, + struct sock *sk) +{} + +static inline bool ulp_ddp_query_limits(struct net_device *netdev, + struct ulp_ddp_limits *limits, + enum ulp_ddp_type type, + int cap_bit_nr, + bool tls) +{ + return false; +} + +#endif + +#endif /* _ULP_DDP_H */ diff --git a/include/net/ulp_ddp_caps.h b/include/net/ulp_ddp_caps.h new file mode 100644 index 000000000000..8ee964a4df78 --- /dev/null +++ b/include/net/ulp_ddp_caps.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * ulp_ddp.h + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ +#ifndef _ULP_DDP_CAPS_H +#define _ULP_DDP_CAPS_H + +#include + +enum { + ULP_DDP_C_NVME_TCP_BIT, + ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + + /* add capabilities above */ + ULP_DDP_C_COUNT, +}; + +struct ulp_ddp_netdev_caps { + DECLARE_BITMAP(active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(hw, ULP_DDP_C_COUNT); +}; + +static inline bool ulp_ddp_cap_turned_on(unsigned long *old, unsigned long *new, int bit_nr) +{ + return !test_bit(bit_nr, old) && test_bit(bit_nr, new); +} + +static inline bool ulp_ddp_cap_turned_off(unsigned long *old, unsigned long *new, int bit_nr) +{ + return test_bit(bit_nr, old) && !test_bit(bit_nr, new); +} + +#endif diff --git a/net/Kconfig b/net/Kconfig index d532ec33f1fe..17ebb9b6f5b7 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -508,4 +508,24 @@ config NETDEV_ADDR_LIST_TEST default KUNIT_ALL_TESTS depends on KUNIT +config ULP_DDP + bool "ULP direct data placement offload" + help + This feature provides a generic infrastructure for Direct + Data Placement (DDP) offload for Upper Layer Protocols (ULP, + such as NVMe-TCP). + + If the ULP and NIC driver supports it, the ULP code can + request the NIC to place ULP response data directly + into application memory, avoiding a costly copy. + + This infrastructure also allows for offloading the ULP data + integrity checks (e.g. data digest) that would otherwise + require another costly pass on the data we managed to avoid + copying. + + For more information, see + . + + endif # if NET diff --git a/net/core/Makefile b/net/core/Makefile index 731db2eaa610..09da9ed3f9ff 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -18,6 +18,7 @@ obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o obj-y += net-sysfs.o +obj-$(CONFIG_ULP_DDP) += ulp_ddp.o obj-$(CONFIG_PAGE_POOL) += page_pool.o obj-$(CONFIG_PROC_FS) += net-procfs.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o diff --git a/net/core/skbuff.c b/net/core/skbuff.c index faa6c86da2a5..9fb81e6ebc29 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -6584,7 +6585,7 @@ void skb_condense(struct sk_buff *skb) { if (skb->data_len) { if (skb->data_len > skb->end - skb->tail || - skb_cloned(skb)) + skb_cloned(skb) || skb_is_ulp_ddp(skb)) return; /* Nice, we can free page frag(s) right now */ diff --git a/net/core/ulp_ddp.c b/net/core/ulp_ddp.c new file mode 100644 index 000000000000..de016d1aa5e1 --- /dev/null +++ b/net/core/ulp_ddp.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * + * ulp_ddp.h + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ + +#include + +int ulp_ddp_sk_add(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config, + const struct ulp_ddp_ulp_ops *ops) +{ + int ret; + + /* put in ulp_ddp_sk_del() */ + dev_hold(netdev); + + ret = netdev->netdev_ops->ulp_ddp_ops->sk_add(netdev, sk, config); + if (ret) { + dev_put(netdev); + return ret; + } + + inet_csk(sk)->icsk_ulp_ddp_ops = ops; + + return 0; +} +EXPORT_SYMBOL_GPL(ulp_ddp_sk_add); + +void ulp_ddp_sk_del(struct net_device *netdev, + struct sock *sk) +{ + netdev->netdev_ops->ulp_ddp_ops->sk_del(netdev, sk); + inet_csk(sk)->icsk_ulp_ddp_ops = NULL; + dev_put(netdev); +} +EXPORT_SYMBOL_GPL(ulp_ddp_sk_del); + +bool ulp_ddp_query_limits(struct net_device *netdev, + struct ulp_ddp_limits *limits, + enum ulp_ddp_type type, + int cap_bit_nr, + bool tls) +{ + int ret; + + if (!netdev->netdev_ops->ulp_ddp_ops->limits) + return false; + + limits->type = type; + ret = netdev->netdev_ops->ulp_ddp_ops->limits(netdev, limits); + if (ret == -EOPNOTSUPP || + !test_bit(cap_bit_nr, netdev->ulp_ddp_caps.active) || + (tls && !limits->tls)) { + return false; + } else if (ret) { + WARN_ONCE(ret, "ddp limits failed (ret=%d)", ret); + return false; + } + + dev_dbg_ratelimited(&netdev->dev, + "netdev %s offload limits: max_ddp_sgl_len %d\n", + netdev->name, limits->max_ddp_sgl_len); + + return true; +} +EXPORT_SYMBOL_GPL(ulp_ddp_query_limits); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 06fe1cf645d5..e7d395d02682 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4686,7 +4686,10 @@ static bool tcp_try_coalesce(struct sock *sk, if (from->decrypted != to->decrypted) return false; #endif - +#ifdef CONFIG_ULP_DDP + if (skb_is_ulp_crc(from) != skb_is_ulp_crc(to)) + return false; +#endif if (!skb_try_coalesce(to, from, fragstolen, &delta)) return false; @@ -5255,6 +5258,10 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root, memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); #ifdef CONFIG_TLS_DEVICE nskb->decrypted = skb->decrypted; +#endif +#ifdef CONFIG_ULP_DDP + nskb->ulp_ddp = skb->ulp_ddp; + nskb->ulp_crc = skb->ulp_crc; #endif TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start; if (list) @@ -5288,6 +5295,10 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root, #ifdef CONFIG_TLS_DEVICE if (skb->decrypted != nskb->decrypted) goto end; +#endif +#ifdef CONFIG_ULP_DDP + if (skb_is_ulp_crc(skb) != skb_is_ulp_crc(nskb)) + goto end; #endif } } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 2a662d5f3072..286e2988b797 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1868,6 +1868,9 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, TCP_SKB_CB(skb)->tcp_flags) & (TCPHDR_ECE | TCPHDR_CWR)) || #ifdef CONFIG_TLS_DEVICE tail->decrypted != skb->decrypted || +#endif +#ifdef CONFIG_ULP_DDP + skb_is_ulp_crc(tail) != skb_is_ulp_crc(skb) || #endif thtail->doff != th->doff || memcmp(thtail + 1, th + 1, hdrlen - sizeof(*th))) diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 8311c38267b5..56705fbe6ce4 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -268,6 +268,9 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb) #ifdef CONFIG_TLS_DEVICE flush |= p->decrypted ^ skb->decrypted; #endif +#ifdef CONFIG_ULP_DDP + flush |= skb_is_ulp_crc(p) ^ skb_is_ulp_crc(skb); +#endif if (flush || skb_gro_receive(p, skb)) { mss = 1; From patchwork Tue Aug 22 15:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361033 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 0CC371D2E9 for ; Tue, 22 Aug 2023 15:05:02 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 900E2126 for ; Tue, 22 Aug 2023 08:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ik4wjWiZULEvsfwZ/FeWHMASpoDfVzVVKXGfqmuvT3ur2MuKxW/dvI0HN+6y9sXKq6DohuvZB8rz0Aw0FruCWO5LyMZa2lx1+E3YCVpL86c4TZdtgs6ioHRXOj2Sn7aLWcSngFXUpS1qL2H7M7HvMeChPzIbvGvweBpCwD3DrlUj7dXz120VFXIIqjtkS//UbtI7RIGGh9RqOQ4Al6JtM3m6N//SpYlgROszSJFewq50jfV+usRZFm0JEfrdpI0R98jBogFU+Adue6kx1qo4mKM0hp7AoRcNHVOxZ4f5XyLOsAnJgi6sdGxv2hxVYGsIvJiGgItdLSD+E0TXyOrbrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M3Chsi96R3spsIKwfaWtP7CAblprNCPnaI1rt8GY+7E=; b=d9yV7LFXRskizrRdm2ktSFqrKz1DyymQYTFki3O3WG0virmCxhN3k/6uw+KlI4WrzqVp9G9KIT5fEhm1LQO9looF6dx6dtjGxq2F8qvKL1jQLRGatqn8bnsCu2YqBPBopJNFDmmZ58RdwKSCByLRVPeVxPcm6wzg9tlIT7TsGcMpIzqvPsclTySI0CaxZ+bJGYiEB98FgGR+I7+6NTh5ttv2nK/2MxqxEKSmDmfVSITXPmk4E67/B1t6b9hd/eJlzII2M0XJr+VJJZlDA3kUyBvIcFbvqLo67dB9Y/ChTE3QEqlthzRHXPT7GtVwGQTqtbOHynslxZPLSQQOXSkSZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M3Chsi96R3spsIKwfaWtP7CAblprNCPnaI1rt8GY+7E=; b=YAMZAWa+NrJTgOwNeGHCDprbd2AVaNxwIW+RP6qGPKF8Z8kWmb774/y5MYEN0tCB+oEq5uLI8J9SWe54Sg0SXv7KfpFWQI8zXxjIY/XATB0rfkSBK/0hBgoEqTbmT0H6+k41yy9vSpogQw1+dgwj/WH5uWyYkuVEZKtkD0IVFM11K8OhMfKHsW2ETR392yf6nnEmVrBRXUPu9zGP7riWEt648EQzGLNQzW5BEpS/xkKyoYtaOI46H7YWQ/WIwgXV2RJ0nTUZo9oIbwbXlyhDfiSCLgrzgJ+ZXgpohZVRvuarcx6lqTBVOZubujGE2FQIVVNDlVN6vMG7uGf2ROaFrQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7378.namprd12.prod.outlook.com (2603:10b6:510:20d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:04:58 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:04:58 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 02/24] net/ethtool: add new stringset ETH_SS_ULP_DDP_{CAPS,STATS} Date: Tue, 22 Aug 2023 15:04:03 +0000 Message-Id: <20230822150425.3390-3-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b3::17) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7378:EE_ X-MS-Office365-Filtering-Correlation-Id: 4360e223-4d63-4fd9-af6a-08dba32126c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1eZjVoE442ymRY6ZHy4Vbwt1rBYZuUmsr2vLSHuK4r6/4zlNq1cIBad46mMbcZYYpVTSviEVB44jOJ3RhjJBOthefg1jN/7DB2+Lx+u0Qu+YXd5uCbS2VShkbPu/xJMzH0ZPB1IdEgl9A9UFkZ46tQM48unEksMSHiwBAgo0w91GUJfczKaps+Rb7lLHP6Ml0rJYBdNeI2Vq93zQDA0vqEDXzbeJBjlHXErlJnw96nkJ33fRaDiOKYWJ710BTgUM7NCVwUhnRz2jJsOfY+jOCk8TcisZyHgLKpqYysIb4SETtnXYUh4MOAc2tLQJH1G4MspMrV/MK7067dzM8zKQ7Ig54w4AlB+mohdbHhSMsntv5seF+dFkQwb5hOoH42VFiyfoZ9/r8j3yoHepNNjvoHKMpi7Ht9YCP8xMoWIgaXwbYzu15sIpIW5N578xeJ+eMecSb3viEPSh7uAB+mi6FyJ6omDi7RVesZqrbeyLH9gGdYV8WO1WKwe22HsXxOT4q4kjDBhYqhAdEr3GzkfWESfACf2pC2rsPw9TXCmMi9P8CF49xkUTesVaKw6iFjgZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199024)(186009)(1800799009)(2906002)(83380400001)(7416002)(6506007)(6486002)(38100700002)(5660300002)(26005)(86362001)(8676002)(8936002)(2616005)(4326008)(107886003)(316002)(6512007)(66556008)(66476007)(478600001)(66946007)(6666004)(41300700001)(36756003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WSg6AK6AEBMwLxSKtUog7YJD+OELs3855OwPonmNfwGCrPHozJ/wvUjczHtZ2G4BTZON5cPnTshrSdZ4Hq+sWnkIA4V5PFNjmC/SG2rQFp9fhKnrjHaedND3dM7Mf+P5/gsfk52sPtfFHcTJbi4D+wf+spf9OKgQSAZB474Y3HghLPs+7yY7xKnpdnEZ0tW5PewQyAmvG9vvAkIr2WhzyGWkbdSQdx7lqup8x4HoXdjliDq4S8EIxilvzOSeFpjkYeo+VD1rBMf5W+L5tb8gXMyTHBsVA0PUbjCgMRBc3Oi4PceWJJhoc6NmAyKHQ8OqX+rbiaDWhjQTEKDJ9wgVYgMwz//JLOnUfkG9hGbQGU+BolLRikeWppZ7EHl98j4d/j8sTXmsgyi6fiAzgdNG+kUL4k/DSq+9fNCBPxLRtO4kN+bnHK7TeHKrXb3pFiZth8KIh4302QA6vh5JDam4zLnBDohAy+s0ekOseo/Cljid6S3OyQKg8A+33YKn1E2/bOKsh6X+fGmi5thFe4zHfOnjj1c/faCqwWXGY6CjKV6MbCIEpbcvK6/UliGe8dqaADilAi/mXMVAEhTiEGw9SQtqWad4lMLAo4uHs9QgY6njckVlD44mr6K+AmI2xDolECBYXxLhgozU4Tk5R6MW+12lTvtWVcQLBcIhfmGmhCXT5xMlyyTXCf0kMFrlzomrZ+0HQXR5f4ZQIIwRxd86ERWwuImol0An/erg4jSa0hvabo+7Xi2ctNrYfetvYBD89i2SR8qGqRn09WqnXUvdsHuG78g0cuCZwZbSDvEU9ddlyJ1O0IMkagSJWVSfgC7Yen8mpXZdV9cgdnkkf+C0fiONPo7sL7OzXD6lW/tPQXtnYGkDJz7XPrc1KIo1CZYAlUv+HrKNIxetJJZIY0rdYSoDHRvH220ZRK/BpVXqyOQMPIunrY02Z8w2sjNzydN++wUNksstVskapadw1l7+f4CxqHJnSWDTfvrF/JS7GyCz7BRylibeNua1SDUle3MISsVHGwVpns0fxyD9vgRnaOavhCCRQ86stJbSljv5geUKizViaiYS0RCWYyiZxGZc9Xi2CkG7uyq//i9ebo0rY1QBaa2Xh8Pg/S60PJoqlOJ6DbFaG6UV31LaHKZ2Nxgn62mZBSulWVfJJufmvYNUGU7DSK6XZlGNRuppeyVnJcnyDd7NDaQNXHPc8s5IbovtfMtM/tUN+xz1xRKzpw0886BEMfsKkhFfVp/DnEXzdJJlyfnY31CI1dyFswYD3NxIpqNvMrqeimZ2/pU7GI5Enpegak7qEuXk8WLqNzkZSC91zmwS6LbdhjXiD73Un+lcBsFwFiaLbUtD21bDiJxbueQEnVhpo/cKhd/uAgMUa2QhuxTpMPyVe0Fz3JI9Y7vsi9ifmqU4mFjgo4dmj2G9O4Qxn23Q4GLj0YKpszsw5Eqs2L/ZB8IlYlgCyC42p9Pno3U7N8YBDxVW8GMtiGDsO/m6Q88/txLpJ1c7g/SyksPPxSbHCHJ6qQdIcV6VjEXTR8EVw93jikJTUnEFtwPfMq9cHuQE2iVODoXwx41nG/ze/aa2U5wgWX9w2xvS8ahM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4360e223-4d63-4fd9-af6a-08dba32126c2 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:04:58.3872 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FFQ3QdGK9I2PDTgsIHjjM1O0H+Lcca1cKUPGv/oqaM0QjCpiQn9ilKm0A8LJNygG6+aTp7UJCgSi4IobclTGQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7378 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This commit exposes ULP DDP capability and statistics names to userspace via netlink. In order to support future ULP DDP capabilities and statistics without having to change the netlink protocol (and userspace ethtool) we add new string sets to let userspace dynamically fetch what the kernel supports. * ETH_SS_ULP_DDP_CAPS stores names of ULP DDP capabilities * ETH_SS_ULP_DDP_STATS stores names of ULP DDP statistics. These stringsets will be used in later commits when implementing the new ULP DDP GET/SET netlink messages. We keep the convention of strset.c of having the static_assert() right after the array declaration, despite the checkpatch warning. Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Jakub Kicinski --- include/linux/ethtool.h | 32 ++++++++++++++++++++++++++++ include/uapi/linux/ethtool.h | 4 ++++ include/uapi/linux/ethtool_netlink.h | 22 +++++++++++++++++++ net/ethtool/common.c | 23 ++++++++++++++++++++ net/ethtool/common.h | 2 ++ net/ethtool/strset.c | 11 ++++++++++ 6 files changed, 94 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 62b61527bcc4..61681e064d91 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -594,6 +594,38 @@ struct ethtool_mm_stats { u64 MACMergeHoldCount; }; +/** + * struct ethtool_ulp_ddp_stats - ULP DDP offload statistics + * @rx_nvmeotcp_sk_add: number of sockets successfully prepared for offloading. + * @rx_nvmeotcp_sk_add_fail: number of sockets that failed to be prepared for offloading. + * @rx_nvmeotcp_sk_del: number of sockets where offloading has been removed. + * @rx_nvmeotcp_ddp_setup: number of NVMeTCP PDU successfully prepared for Direct Data Placement. + * @rx_nvmeotcp_ddp_setup_fail: number of PDUs that failed DDP preparation. + * @rx_nvmeotcp_ddp_teardown: number of PDUs done with DDP. + * @rx_nvmeotcp_drop: number of PDUs dropped. + * @rx_nvmeotcp_resync: number of resync. + * @rx_nvmeotcp_packets: number of offloaded PDUs. + * @rx_nvmeotcp_bytes: number of offloaded bytes. + */ +struct ethtool_ulp_ddp_stats { + u64 rx_nvmeotcp_sk_add; + u64 rx_nvmeotcp_sk_add_fail; + u64 rx_nvmeotcp_sk_del; + u64 rx_nvmeotcp_ddp_setup; + u64 rx_nvmeotcp_ddp_setup_fail; + u64 rx_nvmeotcp_ddp_teardown; + u64 rx_nvmeotcp_drop; + u64 rx_nvmeotcp_resync; + u64 rx_nvmeotcp_packets; + u64 rx_nvmeotcp_bytes; + + /* + * add new stats at the end and keep in sync with + * - ETHTOOL_ULP_DDP_STATS_* enum in uapi + * - ulp_ddp_stats_name stringset + */ +}; + /** * struct ethtool_ops - optional netdev operations * @cap_link_lanes_supported: indicates if the driver supports lanes diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f7fba0dc87e5..8b8585b5fa56 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -681,6 +681,8 @@ enum ethtool_link_ext_substate_module { * @ETH_SS_STATS_ETH_MAC: names of IEEE 802.3 MAC statistics * @ETH_SS_STATS_ETH_CTRL: names of IEEE 802.3 MAC Control statistics * @ETH_SS_STATS_RMON: names of RMON statistics + * @ETH_SS_ULP_DDP_CAPS: names of ULP DDP capabilities + * @ETH_SS_ULP_DDP_STATS: names of ULP DDP statistics * * @ETH_SS_COUNT: number of defined string sets */ @@ -706,6 +708,8 @@ enum ethtool_stringset { ETH_SS_STATS_ETH_MAC, ETH_SS_STATS_ETH_CTRL, ETH_SS_STATS_RMON, + ETH_SS_ULP_DDP_CAPS, + ETH_SS_ULP_DDP_STATS, /* add new constants above here */ ETH_SS_COUNT diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 73e2c10dc2cc..a9aebbe420c8 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -975,6 +975,28 @@ enum { ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) }; +/* ULP DDP */ + +enum { + ETHTOOL_A_ULP_DDP_STATS_UNSPEC, + ETHTOOL_A_ULP_DDP_STATS_PAD, + + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES, + + /* add new constants above here */ + __ETHTOOL_A_ULP_DDP_STATS_CNT, + ETHTOOL_A_ULP_DDP_STATS_MAX = __ETHTOOL_A_ULP_DDP_STATS_CNT - 1 +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 diff --git a/net/ethtool/common.c b/net/ethtool/common.c index f5598c5f50de..abd396ca0068 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "common.h" @@ -465,6 +466,28 @@ const char udp_tunnel_type_names[][ETH_GSTRING_LEN] = { static_assert(ARRAY_SIZE(udp_tunnel_type_names) == __ETHTOOL_UDP_TUNNEL_TYPE_CNT); +const char ulp_ddp_caps_names[][ETH_GSTRING_LEN] = { + [ULP_DDP_C_NVME_TCP_BIT] = "nvme-tcp-ddp", + [ULP_DDP_C_NVME_TCP_DDGST_RX_BIT] = "nvme-tcp-ddgst-rx-offload", +}; +static_assert(ARRAY_SIZE(ulp_ddp_caps_names) == ULP_DDP_C_COUNT); + +const char ulp_ddp_stats_names[][ETH_GSTRING_LEN] = { + [ETHTOOL_A_ULP_DDP_STATS_UNSPEC] = "unspec", + [ETHTOOL_A_ULP_DDP_STATS_PAD] = "pad", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD] = "rx_nvmeotcp_sk_add", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL] = "rx_nvmeotcp_sk_add_fail", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL] = "rx_nvmeotcp_sk_del", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP] = "rx_nvmeotcp_ddp_setup", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL] = "rx_nvmeotcp_ddp_setup_fail", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN] = "rx_nvmeotcp_ddp_teardown", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP] = "rx_nvmeotcp_drop", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC] = "rx_nvmeotcp_resync", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS] = "rx_nvmeotcp_packets", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES] = "rx_nvmeotcp_bytes", +}; +static_assert(ARRAY_SIZE(ulp_ddp_stats_names) == __ETHTOOL_A_ULP_DDP_STATS_CNT); + /* return false if legacy contained non-0 deprecated fields * maxtxpkt/maxrxpkt. rest of ksettings always updated */ diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 28b8aaaf9bcb..ebb0abec04a3 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -36,6 +36,8 @@ extern const char sof_timestamping_names[][ETH_GSTRING_LEN]; extern const char ts_tx_type_names[][ETH_GSTRING_LEN]; extern const char ts_rx_filter_names[][ETH_GSTRING_LEN]; extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN]; +extern const char ulp_ddp_caps_names[][ETH_GSTRING_LEN]; +extern const char ulp_ddp_stats_names[][ETH_GSTRING_LEN]; int __ethtool_get_link(struct net_device *dev); diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c index c678b484a079..7ebc2f87accc 100644 --- a/net/ethtool/strset.c +++ b/net/ethtool/strset.c @@ -2,6 +2,7 @@ #include #include +#include #include "netlink.h" #include "common.h" @@ -105,6 +106,16 @@ static const struct strset_info info_template[] = { .count = __ETHTOOL_A_STATS_RMON_CNT, .strings = stats_rmon_names, }, + [ETH_SS_ULP_DDP_CAPS] = { + .per_dev = false, + .count = ULP_DDP_C_COUNT, + .strings = ulp_ddp_caps_names, + }, + [ETH_SS_ULP_DDP_STATS] = { + .per_dev = false, + .count = __ETHTOOL_A_ULP_DDP_STATS_CNT, + .strings = ulp_ddp_stats_names, + }, }; struct strset_req_info { From patchwork Tue Aug 22 15:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361034 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 1B8751FD0 for ; Tue, 22 Aug 2023 15:05:10 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E76BF126 for ; Tue, 22 Aug 2023 08:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8Qcx3S+dHDrqGbkVSJN6w48FmWYnRacnFxVozpO9Qxf5vrTnHIHkLDr+PrRAvJGjVzXwtLhXFsIn555fg/LSSrmJac8CDXCoBhxZCvbdsSc1CAxTvSvb259SP90SeI5Tns5Ftshwej6vgn3lzX0szIe9Qopy3qBFetosQIRyn1ltaBT7UdSeYRjTqT5icHdmy1v34jWHVaLQNbzMfiSVXgWTlW51xqqdoxmWZqY3A/fYpLzkLLDZ5vhYITG5KrpGFitXcm9I5tR4mW5l3lITLWo3mL4uBM1uHl+zr9q2zRMT4hS/kU44CI1yZ0u4T3Rms8G0p4lBzxyoXk9mW783g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EvexkaUZHUR7wpF3V1R1w59/7V4KSV4u9u/5ZePODX4=; b=ICLbV/YfwzlK/CG0u7jjihgzRHAUQZwVEtsHCtcOfyMPHqT/b10awSU9NPD+rNlPSlmuBHBH4bTXArJGAxB3o6wvFWYlwwebHX/f1I3GVwTYVTqAHbGFsnK9omWHzQeOs8fvbY9foCyxWnzVNAfwUPbGwsTS+W7pggVVXtY9pZVpIvaa5luNUQ9Qi7d6AlpvAd9AvYE1L8waN3ssEsEBowbgCHOVXgpYDHOF43NCxvbL+W2fVXU8NcF1LI4xZNMJCPpZeh5ur3fL9P+jdHmTg8iT5m+JhIrMIznEDpaaRbJEJX5atFgzJrthmHvtZMDvGa31QFWO0xTpPIfVjGCxsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EvexkaUZHUR7wpF3V1R1w59/7V4KSV4u9u/5ZePODX4=; b=s17ikRZ4PamXh5vsHrpVGQlGMus5BIdplrg2ApDdkfBpBpxFupz8bZ7/XJSWFymrPLAfqUeQD4wolxmEcK9a/mjQqdto6++kIezy4TJ23UxHmh5Lykvcp97HZjQ/2pUKFwiFCuinaJtqhtIfopKNUzKIl2cELGm7rXEkaVmMlu6uv+NwOrP1EbiqhOzpT38JJGOBALwR7itPO8ex1kONgoMWVZws+L6RgPzVkomX/5rYlRqDGUTr8+ocpf4ZETm29swm4UZLaWrJSeGsI36++Lh5Fe7wsxQwHUW3VC5r7k/RYNSwLqjVedNAVEpWlABEWsmbVwVAj2I1jLtJW7S/CQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7378.namprd12.prod.outlook.com (2603:10b6:510:20d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:04 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:04 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 03/24] net/ethtool: add ULP_DDP_{GET,SET} operations for caps and stats Date: Tue, 22 Aug 2023 15:04:04 +0000 Message-Id: <20230822150425.3390-4-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0203.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a5::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7378:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d012aa5-0965-42d8-fb7f-08dba3212a23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ntfWiWfaxLGbItjm1toMMuXVqPuAygEtnuzFg6C9qnXr5Qpdh+Lt5Evoqm0k+wo8q5hrLfkAoFiehTUJ3McwKdlSMjnSdY/Z+iovYfo9felaq2QnKI+phJIDzSo+JN7jXxgyPdEKSRQuVxJsGnUEtn1JTSjR2I4n6lCIC4azMhaZMn6UtNn0KcBKbm0+SKAqG/KfUo9pV7bLgIruX7bTmEnenoH2R3FEdB/QM1W10sKOASTVkE4s19kWbIF8OHALV6CnndFbFl3ANNlBseaA7NIXDbPR6joVFJoixkNQTKV/ONA1A0Fi3imGAxSbOwecV/nuu+6n6UI5i7Fn/1lTGK3ZF4E6w3FdhmCw5nTJ7h0gQgRkrIuhj7WxmM3ZIYhq7G/L/Rp7wfkconpoREyMxSzsapLGbPg2R4EUNXvg03Rca51gF560r7E0CQykPkyxDaG+vY/w7vg5EJuhsSS2wQRNo1FMr27ATdK1Yw8s3fHOwsDMwTdEenVplfptjMV9d+xsMdWdNvxE5kxJTb8zD/bTk6qV4I7x+CGLTRTdM1ofsUNYrfgDorUlpK4iNlGK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199024)(186009)(1800799009)(2906002)(30864003)(83380400001)(7416002)(6506007)(6486002)(38100700002)(5660300002)(26005)(86362001)(8676002)(8936002)(2616005)(4326008)(107886003)(316002)(6512007)(66556008)(66476007)(478600001)(66946007)(41300700001)(36756003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /bYDEdYA3cOkkj6tfcy6HYQDGwKV5+K+U3T6PSRFeAzgdkltg+QMqivg1ypSdW1LsBt6bKTbXpGKc+gqbTULs+YRrsHJvCe92UOoek3OpFztqLIrGF/fEmotOE+WTr+bzqEy3VHM1LskR6NXk4IyB2LNjYfDKC3x6Cu/jns60iQNefbK7LUmNJQI6AnhQyRHr9ToTLkg83vcwfaC+xRKNrhhIjP/Qo0BkBIRTB0idsbmeqlX6AE3/MApVm58Mt+kUgomQ4TozD4WYOCplKipnU1JdLjjQ33n8WHLz/RuoiAuz6NK/KeMJp6czdrZa4JELK7VnywfrKJtqLZ6J7VnJFQUnZj8xz11FwqKlQz9/kxPdFbFFh1KCYyX56G25jvrIePqJqLlh38ZyjSCP/u9c3bgbiEDnmxCv9rjwwHrJ1e2BpdPPDhMHAs3k8Cd3JDem7M8gQzRjyaQu2jcGeXX3sb4yUvsXpnp/hDNlgoGkBtiyQ8/qmYIGs1vTgnrngNXlwjFJX7DH7jZtBdumG+/c/sBwYO4HkInCk/QQUdQ/tAcuHglXY1FqtNkTIgBRr4RzrL53cg+HqJ3gEAW5f41lfOILHCJ1oz8IksvYYVaeKcjKnU66Atfysrr33KZOZxkdW21ya0DbgW8Sa63sJqNSgPKMRFN+qlilXskzLJGmxXKhCfxggxsZ/tLVfhNIzFKmkpXuGYvHHIFD8iLLwjO75rHOA7eHUK0OOo7Wqz6+3qITpinXGcRHzdriM8fCPNab8qPyRjyblhTuyzqNA5l3TMKVCGeGoXTfuNlxyLDgbKmLc4ZFpcIMxtgTQmE0UAB6eaSevTxM7+9qzpMIRsVvY8BKKWduq2XHsQT59GvuDkBlJXIuUu/tG0dMgF7/VOiEXhz9w+u8TttV0kXfIDCcnJmcBz45r06p//ioeukHHPtBP2175F7c40HuPeuujteRpMRInX8cHslSMbuJ+D/IQuujdbI8sI4ICz6kNn+PSkajG5rWwTLqE74f0znMcGZeL8bfSpyYzEnWqNk1swbx+bg4Jc5ZlDsg2OXtMTUBvoAg+59VpLFTJVGnVQvi9Tp5XgXugM45mquiZ+fd/TOz/ZPAYPIt102KyO5pRQPC1wvZW1/6y04bIHzF004f4JWe1mVyPCxlXVq3rkXX4GsRTNCZqVgmtXjqqcRyMEJJyCYsUDCG/e1CiI4wge5na3fUIHzG/KqN2T+4Di0UxaqsrEMwsJ03tE+lZL9mddYE6kD25sdJy5kthKUHf+/6DZbpyWfHm58XGoLlPINxJ0QBX12rI5ODY/oSvh6+Shi3Pa6KK7Pb1QBbd+SySnRLeRdZs7Ej8pukxOYBWQc/pV7SWRhHO8EAnJysztpZfAp5Eq4GV3wlKPPKoB8DJ+eqAQt96/gLAdtrHTTj1kaWFembfHb8iaR7Qv1Oz96QzfU2S1fxFZW8uXtgQLFf02fUgHrYRCrBLZRxAaOuJi9+26iLd6fKnp1cNBtDJXg1rMCvaJuNmViCkv9e2oGgstE0+KqCfs0LV8x2X/xAdT3o0cxyzOkkRI2mlPBF5HwtlCTT59fdtgv4AlLdTQQtkUocpsq X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d012aa5-0965-42d8-fb7f-08dba3212a23 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:04.1789 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w7YrDfNmK18PVegeAwYwHnJypd6wOjVU2XV3n8TrY6y7b73fN0NJRA05tH+f8KIwDiOl8qkRGT1BD4jvhNoyyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7378 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This commit adds: - 3 new netlink messages: * ULP_DDP_GET: returns a bitset of supported and active capabilities * ULP_DDP_SET: tries to activate requested bitset and returns results * ULP_DDP_NTF: notification for capabilities change Rename and export bitset_policy for use in ulp_ddp.c. ULP DDP capabilities handling is similar to netdev features handling. If a ULP_DDP_GET message has requested statistics via the ETHTOOL_FLAG_STATS header flag, then statistics are returned to userspace. ULP_DDP_GET request: (header only) ULP_DDP_GET reply: HW (bitset) ACTIVE (bitset) STATS (nest, optional) STATS_xxxx (u64) .... ULP_DDP_SET request: WANTED (bitset) ULP_DDP_SET reply: WANTED (bitset) ACTIVE (bitset) Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Acked-by: Jakub Kicinski --- include/uapi/linux/ethtool_netlink.h | 18 ++ net/ethtool/Makefile | 2 +- net/ethtool/bitset.c | 20 +- net/ethtool/netlink.c | 20 ++ net/ethtool/netlink.h | 4 + net/ethtool/ulp_ddp.c | 316 +++++++++++++++++++++++++++ 6 files changed, 369 insertions(+), 11 deletions(-) create mode 100644 net/ethtool/ulp_ddp.c diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index a9aebbe420c8..93bd5ca9bac3 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -57,6 +57,8 @@ enum { ETHTOOL_MSG_PLCA_GET_STATUS, ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET, + ETHTOOL_MSG_ULP_DDP_GET, + ETHTOOL_MSG_ULP_DDP_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -109,6 +111,9 @@ enum { ETHTOOL_MSG_PLCA_NTF, ETHTOOL_MSG_MM_GET_REPLY, ETHTOOL_MSG_MM_NTF, + ETHTOOL_MSG_ULP_DDP_GET_REPLY, + ETHTOOL_MSG_ULP_DDP_SET_REPLY, + ETHTOOL_MSG_ULP_DDP_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -977,6 +982,19 @@ enum { /* ULP DDP */ +enum { + ETHTOOL_A_ULP_DDP_UNSPEC, + ETHTOOL_A_ULP_DDP_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_ULP_DDP_HW, /* bitset */ + ETHTOOL_A_ULP_DDP_ACTIVE, /* bitset */ + ETHTOOL_A_ULP_DDP_WANTED, /* bitset */ + ETHTOOL_A_ULP_DDP_STATS, /* nest - _A_ULP_DDP_STATS_* */ + + /* add new constants above here */ + __ETHTOOL_A_ULP_DDP_CNT, + ETHTOOL_A_ULP_DDP_MAX = __ETHTOOL_A_ULP_DDP_CNT - 1 +}; + enum { ETHTOOL_A_ULP_DDP_STATS_UNSPEC, ETHTOOL_A_ULP_DDP_STATS_PAD, diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile index 504f954a1b28..a2fdc5ed7655 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile @@ -8,4 +8,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \ linkstate.o debug.o wol.o features.o privflags.o rings.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ - module.o pse-pd.o plca.o mm.o + module.o pse-pd.o plca.o ulp_ddp.o diff --git a/net/ethtool/bitset.c b/net/ethtool/bitset.c index 0515d6604b3b..1bef91fcce4b 100644 --- a/net/ethtool/bitset.c +++ b/net/ethtool/bitset.c @@ -302,7 +302,7 @@ int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val, return -EMSGSIZE; } -static const struct nla_policy bitset_policy[] = { +const struct nla_policy ethnl_bitset_policy[] = { [ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG }, [ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32, ETHNL_MAX_BITSET_SIZE), @@ -327,11 +327,11 @@ static const struct nla_policy bit_policy[] = { */ int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; int ret; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, bitset, - bitset_policy, NULL); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, bitset, + ethnl_bitset_policy, NULL); if (ret < 0) return ret; @@ -553,15 +553,15 @@ int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits, const struct nlattr *attr, ethnl_string_array_t names, struct netlink_ext_ack *extack, bool *mod) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; unsigned int change_bits; bool no_mask; int ret; if (!attr) return 0; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr, - bitset_policy, extack); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, attr, + ethnl_bitset_policy, extack); if (ret < 0) return ret; @@ -606,7 +606,7 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, ethnl_string_array_t names, struct netlink_ext_ack *extack) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; const struct nlattr *bit_attr; bool no_mask; int rem; @@ -614,8 +614,8 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, if (!attr) return 0; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr, - bitset_policy, extack); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, attr, + ethnl_bitset_policy, extack); if (ret < 0) return ret; no_mask = tb[ETHTOOL_A_BITSET_NOMASK]; diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 3bbd5afb7b31..bc94c54027f2 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -306,6 +306,8 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops, [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, + [ETHTOOL_MSG_ULP_DDP_GET] = ðnl_ulp_ddp_request_ops, + [ETHTOOL_MSG_ULP_DDP_SET] = ðnl_ulp_ddp_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -638,6 +640,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, [ETHTOOL_MSG_PLCA_NTF] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_MM_NTF] = ðnl_mm_request_ops, + [ETHTOOL_MSG_ULP_DDP_NTF] = ðnl_ulp_ddp_request_ops, }; /* default notification handler */ @@ -736,6 +739,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MM_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_ULP_DDP_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) @@ -1128,6 +1132,22 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_mm_set_policy, .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_ULP_DDP_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_ulp_ddp_get_policy, + .maxattr = ARRAY_SIZE(ethnl_ulp_ddp_get_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_ULP_DDP_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_default_set_doit, + .policy = ethnl_ulp_ddp_set_policy, + .maxattr = ARRAY_SIZE(ethnl_ulp_ddp_set_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 9a333a8d04c1..4e083f2ec55d 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -395,10 +395,12 @@ extern const struct ethnl_request_ops ethnl_rss_request_ops; extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; extern const struct ethnl_request_ops ethnl_plca_status_request_ops; extern const struct ethnl_request_ops ethnl_mm_request_ops; +extern const struct ethnl_request_ops ethnl_ulp_ddp_request_ops; extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_COUNTS_ONLY + 1]; +extern const struct nla_policy ethnl_bitset_policy[ETHTOOL_A_BITSET_MASK + 1]; extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1]; extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1]; extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_HEADER + 1]; @@ -441,6 +443,8 @@ extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1] extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; +extern const struct nla_policy ethnl_ulp_ddp_get_policy[ETHTOOL_A_ULP_DDP_HEADER + 1]; +extern const struct nla_policy ethnl_ulp_ddp_set_policy[ETHTOOL_A_ULP_DDP_WANTED + 1]; int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); diff --git a/net/ethtool/ulp_ddp.c b/net/ethtool/ulp_ddp.c new file mode 100644 index 000000000000..9d67af5cac5d --- /dev/null +++ b/net/ethtool/ulp_ddp.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * + * ulp_ddp.c + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ + +#include "netlink.h" +#include "common.h" +#include "bitset.h" +#include + +#define ETHTOOL_ULP_DDP_STATS_CNT \ + (__ETHTOOL_A_ULP_DDP_STATS_CNT - (ETHTOOL_A_ULP_DDP_STATS_PAD + 1)) + +static struct ulp_ddp_netdev_caps *netdev_ulp_ddp_caps(struct net_device *dev) +{ +#ifdef CONFIG_ULP_DDP + return &dev->ulp_ddp_caps; +#else + return NULL; +#endif +} + +static const struct ulp_ddp_dev_ops *netdev_ulp_ddp_ops(struct net_device *dev) +{ +#ifdef CONFIG_ULP_DDP + return dev->netdev_ops->ulp_ddp_ops; +#else + return NULL; +#endif +} + +/* ULP_DDP_GET */ + +struct ulp_ddp_req_info { + struct ethnl_req_info base; +}; + +struct ulp_ddp_reply_data { + struct ethnl_reply_data base; + DECLARE_BITMAP(hw, ULP_DDP_C_COUNT); + DECLARE_BITMAP(active, ULP_DDP_C_COUNT); + struct ethtool_ulp_ddp_stats stats; +}; + +#define ULP_DDP_REPDATA(__reply_base) \ + container_of(__reply_base, struct ulp_ddp_reply_data, base) + +const struct nla_policy ethnl_ulp_ddp_get_policy[] = { + [ETHTOOL_A_ULP_DDP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_stats), +}; + +static int ulp_ddp_put_stats64(struct sk_buff *skb, int attrtype, const u64 *val, + unsigned int count) +{ + unsigned int i, attr; + struct nlattr *nest; + + nest = nla_nest_start(skb, attrtype); + if (!nest) + return -EMSGSIZE; + + /* skip attributes unspec & pad */ + attr = ETHTOOL_A_ULP_DDP_STATS_PAD + 1; + for (i = 0 ; i < count; i++, attr++) + if (nla_put_u64_64bit(skb, attr, val[i], ETHTOOL_A_ULP_DDP_STATS_PAD)) + goto nla_put_failure; + + nla_nest_end(skb, nest); + return 0; + +nla_put_failure: + nla_nest_cancel(skb, nest); + return -EMSGSIZE; +} + +static int ulp_ddp_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + const struct genl_info *info) +{ + const struct ulp_ddp_dev_ops *ops = netdev_ulp_ddp_ops(reply_base->dev); + struct ulp_ddp_netdev_caps *caps = netdev_ulp_ddp_caps(reply_base->dev); + struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + + if (!caps || !ops) + return -EOPNOTSUPP; + + bitmap_copy(data->hw, caps->hw, ULP_DDP_C_COUNT); + bitmap_copy(data->active, caps->active, ULP_DDP_C_COUNT); + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + if (!ops->get_stats) + return -EOPNOTSUPP; + ops->get_stats(reply_base->dev, &data->stats); + } + return 0; +} + +static int ulp_ddp_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + unsigned int len = 0; + int ret; + + ret = ethnl_bitset_size(data->hw, NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + len += ret; + ret = ethnl_bitset_size(data->active, NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + len += ret; + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + len += nla_total_size_64bit(sizeof(u64)) * ETHTOOL_ULP_DDP_STATS_CNT; + len += nla_total_size(0); /* nest */ + } + return len; +} + +static int ulp_ddp_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + int ret; + + ret = ethnl_put_bitset(skb, ETHTOOL_A_ULP_DDP_HW, data->hw, + NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + + ret = ethnl_put_bitset(skb, ETHTOOL_A_ULP_DDP_ACTIVE, data->active, + NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + ret = ulp_ddp_put_stats64(skb, ETHTOOL_A_ULP_DDP_STATS, + (u64 *)&data->stats, + ETHTOOL_ULP_DDP_STATS_CNT); + if (ret < 0) + return ret; + } + return ret; +} + +/* ULP_DDP_SET */ + +const struct nla_policy ethnl_ulp_ddp_set_policy[] = { + [ETHTOOL_A_ULP_DDP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), + [ETHTOOL_A_ULP_DDP_WANTED] = NLA_POLICY_NESTED(ethnl_bitset_policy), +}; + +static int ulp_ddp_send_reply(struct net_device *dev, struct genl_info *info, + const unsigned long *wanted, + const unsigned long *wanted_mask, + const unsigned long *active, + const unsigned long *active_mask, bool compact) +{ + struct sk_buff *rskb; + void *reply_payload; + int reply_len = 0; + int ret; + + reply_len = ethnl_reply_header_size(); + ret = ethnl_bitset_size(wanted, wanted_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto err; + reply_len += ret; + ret = ethnl_bitset_size(active, active_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto err; + reply_len += ret; + + rskb = ethnl_reply_init(reply_len, dev, ETHTOOL_MSG_ULP_DDP_SET_REPLY, + ETHTOOL_A_ULP_DDP_HEADER, info, + &reply_payload); + if (!rskb) { + ret = -ENOMEM; + goto err; + } + + ret = ethnl_put_bitset(rskb, ETHTOOL_A_ULP_DDP_WANTED, wanted, + wanted_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto nla_put_failure; + ret = ethnl_put_bitset(rskb, ETHTOOL_A_ULP_DDP_ACTIVE, active, + active_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto nla_put_failure; + + genlmsg_end(rskb, reply_payload); + ret = genlmsg_reply(rskb, info); + return ret; + +nla_put_failure: + nlmsg_free(rskb); + WARN_ONCE(1, "calculated message payload length (%d) not sufficient\n", + reply_len); +err: + GENL_SET_ERR_MSG(info, "failed to send reply message"); + return ret; +} + +static int ulp_ddp_set_validate(struct ethnl_req_info *req_info, struct genl_info *info) +{ + const struct ulp_ddp_dev_ops *ops; + + if (GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_ULP_DDP_WANTED)) + return -EINVAL; + + ops = netdev_ulp_ddp_ops(req_info->dev); + if (!ops || !ops->set_caps || !netdev_ulp_ddp_caps(req_info->dev)) + return -EOPNOTSUPP; + + return 1; +} + +static int ulp_ddp_set(struct ethnl_req_info *req_info, struct genl_info *info) +{ + DECLARE_BITMAP(old_active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(new_active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(req_wanted, ULP_DDP_C_COUNT); + DECLARE_BITMAP(req_mask, ULP_DDP_C_COUNT); + DECLARE_BITMAP(all_bits, ULP_DDP_C_COUNT); + DECLARE_BITMAP(tmp, ULP_DDP_C_COUNT); + const struct ulp_ddp_dev_ops *ops; + struct ulp_ddp_netdev_caps *caps; + int ret; + + caps = netdev_ulp_ddp_caps(req_info->dev); + ops = netdev_ulp_ddp_ops(req_info->dev); + ret = ethnl_parse_bitset(req_wanted, req_mask, ULP_DDP_C_COUNT, + info->attrs[ETHTOOL_A_ULP_DDP_WANTED], + ulp_ddp_caps_names, info->extack); + if (ret < 0) + return ret; + + /* if (req_mask & ~all_bits) */ + bitmap_fill(all_bits, ULP_DDP_C_COUNT); + bitmap_andnot(tmp, req_mask, all_bits, ULP_DDP_C_COUNT); + if (!bitmap_empty(tmp, ULP_DDP_C_COUNT)) + return -EINVAL; + + /* new_active = (old_active & ~req_mask) | (wanted & req_mask) + * new_active &= caps_hw + */ + bitmap_copy(old_active, caps->active, ULP_DDP_C_COUNT); + bitmap_and(req_wanted, req_wanted, req_mask, ULP_DDP_C_COUNT); + bitmap_andnot(new_active, old_active, req_mask, ULP_DDP_C_COUNT); + bitmap_or(new_active, new_active, req_wanted, ULP_DDP_C_COUNT); + bitmap_and(new_active, new_active, caps->hw, ULP_DDP_C_COUNT); + if (!bitmap_equal(old_active, new_active, ULP_DDP_C_COUNT)) { + ret = ops->set_caps(req_info->dev, new_active, info->extack); + if (ret < 0) + return ret; + bitmap_copy(new_active, caps->active, ULP_DDP_C_COUNT); + } + + if (!(req_info->flags & ETHTOOL_FLAG_OMIT_REPLY)) { + bool compact = req_info->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + DECLARE_BITMAP(wanted_diff_mask, ULP_DDP_C_COUNT); + DECLARE_BITMAP(active_diff_mask, ULP_DDP_C_COUNT); + + /* wanted_diff_mask = req_wanted ^ new_active + * active_diff_mask = old_active ^ new_active -> mask of bits that have changed + * wanted_diff_mask &= req_mask -> mask of bits that have diff value than wanted + * req_wanted &= wanted_diff_mask -> bits that have diff value than wanted + * new_active &= active_diff_mask -> bits that have changed + */ + bitmap_xor(wanted_diff_mask, req_wanted, new_active, ULP_DDP_C_COUNT); + bitmap_xor(active_diff_mask, old_active, new_active, ULP_DDP_C_COUNT); + bitmap_and(wanted_diff_mask, wanted_diff_mask, req_mask, ULP_DDP_C_COUNT); + bitmap_and(req_wanted, req_wanted, wanted_diff_mask, ULP_DDP_C_COUNT); + bitmap_and(new_active, new_active, active_diff_mask, ULP_DDP_C_COUNT); + ret = ulp_ddp_send_reply(req_info->dev, info, + req_wanted, wanted_diff_mask, + new_active, active_diff_mask, + compact); + if (ret < 0) + return ret; + } + + /* return 1 to notify */ + return bitmap_equal(old_active, new_active, ULP_DDP_C_COUNT); +} + +const struct ethnl_request_ops ethnl_ulp_ddp_request_ops = { + .request_cmd = ETHTOOL_MSG_ULP_DDP_GET, + .reply_cmd = ETHTOOL_MSG_ULP_DDP_GET_REPLY, + .hdr_attr = ETHTOOL_A_ULP_DDP_HEADER, + .req_info_size = sizeof(struct ulp_ddp_req_info), + .reply_data_size = sizeof(struct ulp_ddp_reply_data), + + .prepare_data = ulp_ddp_prepare_data, + .reply_size = ulp_ddp_reply_size, + .fill_reply = ulp_ddp_fill_reply, + + .set_validate = ulp_ddp_set_validate, + .set = ulp_ddp_set, + .set_ntf_cmd = ETHTOOL_MSG_ULP_DDP_NTF, +}; From patchwork Tue Aug 22 15:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361035 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 1DDAC1FD0 for ; Tue, 22 Aug 2023 15:05:14 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91B36126 for ; Tue, 22 Aug 2023 08:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PbZwkQ9fCBw9nlbmFThviQwlL8n+g89FOCGIoLVjGWgXUf0hT4ONwJ5unDDaiIfE4QEQmVjFsDhrcDgKyyfHlgSC+N2E4ZmccTQKnpyxFCjZm/r3iiFOIfkU+L7q8m+IyhxAKWpWUtWx21b59TrfMxzSQBrutTXAP9yIPnZkQ++MugcMcq+uPjXNaFspp3W92ZiiwtFdmyUwj2raFmfZO81MgKqxlWizR4e++vhizA64u97+etOv+JSNYpR1qJkPJKTJtte2mUgfe/JG2QeYD6azJZqiZTbJvVB3SUNEfFwSLQ3zrCOixvd5RZwKM1hn0zJgVfhtc80LSx5E3QVY1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oRN3/4tDgMEgH2VK6Q2WmLGh3+mdpvWo9FKtGYdFLj8=; b=RNSp5IC66Xuu5JrugETRiDfCMY97WOsP6d+N+mhbAZWZUOMnglIje1ZzMlXsog/Gwf2x8aKPkLLmuxFTk+BsoFscietqT4lXpJDrm+zliYRM012UvHk5rDZ6lwLEM5IDnQfiDmT8+kB80w5EHD1Ov6kpFe425cP8Ar4l8UdZfmWmrxODtyUodT9uWjHqFvsaJ8n/8AXRyjaR6fb8qHWJXoGjbnOA8wEDKnqjk9aL2svMJo5Z8uWfqM0a/qXv+pzwQnJ9ZeAOwHnhY4M8/Xtz+mEfmD9XYMcgWPd4vojDwoDvxV6j7jILSPmY0cqB5ff75wp6GPWTOfc32LNQN1ipFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oRN3/4tDgMEgH2VK6Q2WmLGh3+mdpvWo9FKtGYdFLj8=; b=T9e99oVxl2bDwXyhLNsDa1ADTKwo8qUXkJvzJfknhXiFEuKUFOeewipIXSK/SkRwj48tLDmFN22Z0XqymjngSjI3Rk9dcmw+vXj/AJpC33aFa4+ixz64XH2+5BebDNhV5oqxwHV+LtL3otv6in7trHao/TkGIwpsJYmysHpQHtV7bxcqlCShWJCDsOUFUqM4izW0zdwcw1msj93kOS+y5L/4IZcVJv8pJL3OFTSOAXO14+ktnwWyUGGCIWwYosfDgjIswZYOg1jg+crHsg7iQlbmAZIHlGmKBfq5T+LlJfxxj312OasRsCXlfk5LVwSXpj0loN8l+6ZzerXnTHauSg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7378.namprd12.prod.outlook.com (2603:10b6:510:20d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:10 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:10 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 04/24] Documentation: document netlink ULP_DDP_GET/SET messages Date: Tue, 22 Aug 2023 15:04:05 +0000 Message-Id: <20230822150425.3390-5-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0208.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a5::18) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7378:EE_ X-MS-Office365-Filtering-Correlation-Id: 3430b642-37f9-46fa-3e58-08dba3212de2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MPuua4hut9izAguGJJsnjAwYmAqUBjpUK6ghQ+Apc+Oezhw2CGYRJI9sHKkB4XmFD1g5C46lO461dPi5Z0myefaCQFeI2Yj9OM7lqxI9tiwarBB67DsMWMmIaIQYQMC/Zq2OXP0l2/kEYtqIJpj3Eq21UvUnYISfTId0bW3kn3LP7sJsIiZ0ZWF5NNjw4qWGdVgzzeByaYIWMP/WB05+H4rUu+cuHKllR4eKozzWWs5TKEx+AIjrR/Tc/GDdlw29XTPR9gYGovpxvODiNBMM3Jw3gqSPshLUlyhiogBl9qrRHAI2UJctffGEoLhiMGwaMQu6zq7itdmAyQKffpiUa4lpCZTKLgw1AjAh94xbwgz9LaPLd5qnWdZwYCe83Q/xXoTW3lUxcRY9lXI2gk204Dm1xiR72noy+JS8kPGeAvkCd7/hqb01VpfJARJVx+Rk37lRrDKfGsj07+6QzMVPUVHKy7ruVaxAfI5PJ25qWYYYGoy6uNbKeGwrbdT0MYDqd6FxvIRL8NtBbX1xFrkqMiWiyeyfQYjIYs8L+nt6GiaVjXagu/gYlXVzJ0AC8rsY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199024)(186009)(1800799009)(2906002)(83380400001)(7416002)(6506007)(6486002)(38100700002)(15650500001)(5660300002)(26005)(86362001)(8676002)(8936002)(2616005)(4326008)(107886003)(316002)(6512007)(66556008)(66476007)(478600001)(66946007)(6666004)(41300700001)(36756003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xcyejfop9GYS6JpgwADtbBQUxmGW0aZ7iMOQAmLR9YHAY3EZV4VUZysZubbFhkUveSn5fC+T6dJZUFXFgAe5nMGzF/g0kJbJz1SD7dUj+PaoRv8ilnm9+UFQfDYP493ryt3s3IS5aC7cDjNaNMap7S5tsQImxLm4Hp0acmPaawg4Kg9jq560oKPgjE2Ag61Up4N1hUVR3oKY7efU8N8reTzZxvpCjwVBNs1P2p2cRsodEQEkAOPu7SDAl/LYk3KYoE9swFZUIlE1kS1LGjSfZMOj73GoGs1XAduNUT2t1FKXd/b8UCqcl6PXpUl6c7gZyF2Ozc+rJ+zrU06/nPn1Dt2NQ22OlCr8kAMfhIe7pX6S7169DHpq9FNPvIfKK/nOrSulzK/udZR0xhXTeqAxebpT3khEPpaVdcjvyDejScaMTINPZATRye3VdQgBT6F3fCrWU81dH7l0CdP7zUIfhmkmb6k8SaenjtLxN13kvcUt/KQZb55tGo+sdfnX6YXaDJrxISLjiS579Z2Kp46MVF0xo/78pC8TIbCGB5V4MWvhFnx0JHCBe9iV8UssirKDNvs0gV7nCU896yz7zIqBuabUOPX5qIGDqBGUX4l0lcNJwRxhtAE5tGpQkTOOvKV9z4UQ6vvM9ObjGI+9RciKqDPh2yZV76yRQ8b62iaDWeFFzOPxKp6VpIi7wW1vXIujW/cVKBoKte9ishfIRqP8K1zZett3Mu4sYB6kmZFZ84LtgPWkvWXEQIweZBN209Y6629XFi5a4JuOS5oyGvyqQEnKl0LXwUtIAsc89E5fcHDG/BdC26PiiXYAoF7jbtk202fC3T1/nwk2Fl2teukZxihC0qvE3NHLGAsxlXPbs2iaRaycs2Nmk3GA9LhWSeeO1NiqzWyAAyE780U8HFvJ5SrzVoCSTlqX6jhr2n+yYtlkfPn7CJkpvqrgzkgpmS/9RL+mkpnAvUEZWp6FDnSTTPCT4USNFMRGpY2FE5iW8c7r43Nu5Io4e1SBKa9zVeEHNlzF4rgAvP/Q+2TckUGRjF4Qpj7j0duH5W3mV/V/opUHZ/621vIQ5tYuQogN9xQdlPvGlQPLbD8MI2/AcmYV37jvxtLhcQgb1VkzGvU1dYDcFcw7g2aWeIf84qzL3WoN5p8WH5Rxm0bxZXwD7lGrSeNUZ0K9U8KuzrgsxABC+5DgARjkhMjZul/5r3d+IuETbf9mqc33uIrXFMyHGxqbQDWAvlHSdV0poNTPBSmq58YhNsu3alALVA03agxX3o/sn3aT16WPt6tSHEpYy4RMyoMAjmX2TuFTzfR2Ji31i3eHrmdsDuu1fEL2OPfz+G6dudDTdeL557F4HYpm1YsK1MbXiZx7BsYngUhRxd1WY32eDdQsJgetMLBUaKcfrYjTGEMK1jAhsoX0cTCL0QWUiPFzu5F2yJG356LAxxndPqpVseXNbG9B8eDjRWRyDL+GJGNOGHFOcJwaoyCbkxMGfQTFqkscN2E8lzAdReWM91XF9JL5lq6eWq2NBu/pmlKwRiKbgHvGnUxevgEMG+WncQCGSAIHbN8eK/d1Hs3COGRlk4Q50yBwZ4opg4brHHmI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3430b642-37f9-46fa-3e58-08dba3212de2 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:10.3284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dRVDtL35u2kwyAo9XAWPoVPXzQuAQo+g6w5iStHYuFLGA8p4kEbvjKLL4MWy9z418ri746VgptvletbfMJm13Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7378 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add detailed documentation about: - ETHTOOL_MSG_ULP_DDP_GET and ETHTOOL_MSG_ULP_DDP_SET netlink messages - ETH_SS_ULP_DDP_CAPS and ETH_SS_ULP_DDP_STATS stringsets ETHTOOL_MSG_ULP_DDP_GET/SET messages are used to configure ULP DDP capabilities and retrieve ULP DDP statistics. Both statistics and capabilities names can be retrieved dynamically from the kernel via string sets (no need to hardcode them and keep them in sync in ethtool). Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Acked-by: Jakub Kicinski --- Documentation/netlink/specs/ethtool.yaml | 102 +++++++++++++++++++ Documentation/networking/ethtool-netlink.rst | 92 +++++++++++++++++ Documentation/networking/statistics.rst | 1 + 3 files changed, 195 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 837b565577ca..65114e28a4ad 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -377,6 +377,67 @@ attribute-sets: name: nochange type: nest nested-attributes: bitset + - + name: ulp-ddp-stat + attributes: + - + name: pad + value: 1 + type: pad + - + name: rx-nvmeotcp-sk-add + type: u64 + - + name: rx-nvmeotcp-sk-add-fail + type: u64 + - + name: rx-nvmeotcp-sk-del + type: u64 + - + name: rx-nvmeotcp-ddp-setup + type: u64 + - + name: rx-nvmeotcp-ddp-setup-fail + type: u64 + - + name: rx-nvmeotcp-ddp-teardown + type: u64 + - + name: rx-nvmeotcp-ddp-drop + type: u64 + - + name: rx-nvmeotcp-ddp-resync + type: u64 + - + name: rx-nvmeotcp-ddp-packets + type: u64 + - + name: rx-nvmeotcp-ddp-bytes + type: u64 + - + name: ulp-ddp + attributes: + - + name: header + value: 1 + type: nest + nested-attributes: header + - + name: hw + type: nest + nested-attributes: bitset + - + name: active + type: nest + nested-attributes: bitset + - + name: wanted + type: nest + nested-attributes: bitset + - + name: stats + type: nest + nested-attributes: ulp-ddp-stat - name: channels attributes: @@ -1692,3 +1753,44 @@ operations: name: mm-ntf doc: Notification for change in MAC Merge configuration. notify: mm-get + - + name: ulp-ddp-get + doc: Get ULP DDP capabilities and stats. + + attribute-set: ulp-ddp + + do: &ulp-ddp-get-op + request: + value: 44 + attributes: + - header + reply: + value: 44 + attributes: + - header + - hw + - active + - stats + dump: *ulp-ddp-get-op + - + name: ulp-ddp-set + doc: Set ULP DDP capabilities. + + attribute-set: ulp-ddp + + do: + request: + value: 45 + attributes: + - header + - wanted + reply: + value: 45 + attributes: + - header + - hw + - active + - + name: ulp-ddp-ntf + doc: Notification for change in ULP DDP capabilities. + notify: ulp-ddp-get diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 2540c70952ff..1706634658e4 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -225,6 +225,8 @@ Userspace to kernel: ``ETHTOOL_MSG_RSS_GET`` get RSS settings ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters + ``ETHTOOL_MSG_ULP_DDP_GET`` get ULP DDP capabilities and stats + ``ETHTOOL_MSG_ULP_DDP_SET`` set ULP DDP capabilities ===================================== ================================= Kernel to userspace: @@ -268,6 +270,9 @@ Kernel to userspace: ``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status + ``ETHTOOL_MSG_ULP_DDP_GET_REPLY`` ULP DDP capabilities and stats + ``ETHTOOL_MSG_ULP_DDP_SET_REPLY`` optional reply to ULP_DDP_SET + ``ETHTOOL_MSG_ULP_DDP_NTF`` ULP DDP capabilities notification ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device @@ -1994,6 +1999,93 @@ The attributes are propagated to the driver through the following structure: .. kernel-doc:: include/linux/ethtool.h :identifiers: ethtool_mm_cfg +ULP_DDP_GET +=========== + +Get ULP DDP capabilities for the interface and optional driver-defined stats. + +Request contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested request header + ==================================== ====== ========================== + +Kernel response contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested reply header + ``ETHTOOL_A_ULP_DDP_HW`` bitset dev->ulp_ddp_caps.hw + ``ETHTOOL_A_ULP_DDP_ACTIVE`` bitset dev->ulp_ddp_caps.active + ``ETHTOOL_A_ULP_DDP_STATS`` nested ULP DDP statistics + ==================================== ====== ========================== + + +* If ``ETHTOOL_FLAG_COMPACT_BITSETS`` was set in + ``ETHTOOL_A_HEADER_FLAG``, the bitsets of the reply are in compact + form. In that form, the names for the individual bits can be retrieved + via the ``ETH_SS_ULP_DDP_CAPS`` string set. +* ``ETHTOOL_A_ULP_DDP_STATS`` contains statistics which + are only reported if ``ETHTOOL_FLAG_STATS`` was set in + ``ETHTOOL_A_HEADER_FLAGS``. + +ULP DDP statistics content: + + ====================================================== === =============== + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD`` u64 sockets successfully prepared for offloading + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL`` u64 sockets that failed to be prepared for offloading + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL`` u64 sockets where offloading has been removed + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP`` u64 PDUs successfully prepared for Direct Data Placement + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL`` u64 PDUs that failed DDP preparation + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN`` u64 PDUs done with DDP + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP`` u64 PDUs dropped + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC`` u64 resync + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS`` u64 offloaded PDUs + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES`` u64 offloaded bytes + ====================================================== === =============== + +The names of each statistics are global. They can be retrieved via the +``ETH_SS_ULP_DDP_STATS`` string set. + +ULP_DDP_SET +=========== + +Request to set ULP DDP capabilities for the interface. + +Request contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested request header + ``ETHTOOL_A_ULP_DDP_WANTED`` bitset requested capabilities + ==================================== ====== ========================== + +Kernel response contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested reply header + ``ETHTOOL_A_ULP_DDP_WANTED`` bitset diff wanted vs. results + ``ETHTOOL_A_ULP_DDP_ACTIVE`` bitset diff old vs. new active + ==================================== ====== ========================== + +Request contains only one bitset which can be either value/mask pair +(request to change specific capabilities and leave the rest) or only a +value (request to set the complete capabilities provided literally). + +Requests are subject to sanity checks by drivers so an optional kernel +reply (can be suppressed by ``ETHTOOL_FLAG_OMIT_REPLY`` flag in +request header) informs client about the actual +results. + +* ``ETHTOOL_A_ULP_DDP_WANTED`` reports the difference between client + request and actual result: mask consists of bits which differ between + requested capability and result (dev->ulp_ddp_caps.active after the + operation), value consists of values of these bits in the request + (i.e. negated values from resulting capabilities). +* ``ETHTOOL_A_ULP_DDP_ACTIVE`` reports the difference between old and + new dev->ulp_ddp_caps.active: mask consists of bits which have + changed, values are their values in new dev->ulp_ddp_caps.active + (after the operation). + + Request translation =================== diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst index 551b3cc29a41..9997c5e8d34e 100644 --- a/Documentation/networking/statistics.rst +++ b/Documentation/networking/statistics.rst @@ -172,6 +172,7 @@ statistics are supported in the following commands: - `ETHTOOL_MSG_PAUSE_GET` - `ETHTOOL_MSG_FEC_GET` - `ETHTOOL_MSG_MM_GET` + - `ETHTOOL_MSG_ULP_DDP_GET` debugfs ------- From patchwork Tue Aug 22 15:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361036 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 AF3A879D0 for ; Tue, 22 Aug 2023 15:05:20 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2075.outbound.protection.outlook.com [40.107.243.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 948E0CC7 for ; Tue, 22 Aug 2023 08:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SrgkLRbPDFkjvphXQ756C3Y78E2yf7FNkuliTFZkVILKOLcZfBLkG7/psjhY/CxeFBp1CFtoEuzJWqkNzEZ9sHbhwUIcrdqzzYEXeGiHD4yyBlw5ZL+RKRLnCyZa5v3KKR8orq93oD6ERnJ8Ntd7ZJGBvZv7l1Qc6b7AAPECYHqCoIgddNbEZRYZ+OarJALc++WgkYxyyyolmkwOR5ECxc/kVWEhQ4CcV5iIkoN8tfUQIDHkwPsOoDXNpdjC0vlE85v0rBESaMbpQwYZdsZ3YATUSssATNFW2qfi/p57Sx/OJMFlZgh4xAV6Xp6sm+c+G+KRU4hSaxdINrVUDSFs+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6t1p58Xpf8Y9RiKI2/rVWEgBeA/a6ZSFAI6MWqzpnPQ=; b=oJfv8iv1/mXyZitdaokAwpmXqqgXdRa71xwLYKcd+ecK0Dltalvu1EkqW1amTXJwaqynYdfLLr78MF43kGZHizdlFlOt8f99+5pC+2k/QJySYYoevbGFFff/5xNL8ySU7BT+uj10wt3n5GS1NU781tXdnqi5H0XnAZQYHvQCZkMa9EYXs60mtUyBMm79f1HKL+ULp8LHcB7JIzvnCUsvuibWEZZ/9sE3vHjeHLznIcPTS01hETRQL2bsvKPa+HbnjjCYKTGiEj21p4vIaAEvTSLu2Ir5Eiai5gDzjP8lrj8xuKVMHdDRIopohU0y3/FPkSgtkp0pFhxt+k8geDxDDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6t1p58Xpf8Y9RiKI2/rVWEgBeA/a6ZSFAI6MWqzpnPQ=; b=JwfzTurvzuHUBGEyQ9QOSa6WHF/DXOoVv3eAwT7DlJGI9wjpe2xMMS/azSBEK8MGTlTS41ZDhPysi9ErRzg2Hwj0TZ2zxGwR78CpikPyG19iAJDCJlxITBXRZ6Wdqb2ejMXGqxkwyiErb7B03h7fdC+IIcrL50d2pkjge9qmeQAshEBdCrQMuJi/qe2xFSZjpd1r5DwdzjlCdk1w/EjcJIUI9aOlPn+Q6gZuDQYyBw4659dafwGE6Gqg4A/j0119QlatYPFxlnsF9ZIb2H7kV/UDw6nOucb8l0xva8L0atNxU6BR9rUqs3EiFNw9lWA9aCcPOBDQHfW7vvEpRmVRGw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:17 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:16 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 05/24] iov_iter: skip copy if src == dst for direct data placement Date: Tue, 22 Aug 2023 15:04:06 +0000 Message-Id: <20230822150425.3390-6-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0192.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 9775ccc0-92ec-4a08-42c0-08dba32131c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T6ZHj9vdDPJenNdM8tk5vcCo8+ziMPCFdAHdqT54uYvbtfQlMwovA0P7aLBlDQ1l54YPe6a33gL/dDGUi0cv4cUcVIUJrGkmCnZdW2pjF4iMv3ugTPKeyc564EiY7IGpu0b+AZiEY7mlK6Tv47xzF5fsTslCZyXTx1kGMn0dW0kzIcKQJO4uzRkPIMj0kQJeNbM4FsJ3AG4gAkNxUN6SEcESNz2PCpK+26Hyqfqffrtrua69AVqyRU7lZ1vBfzjRF0g/V97WkpoUf46nliescaMYDLqzQeZHE/6hGKvZEow2fOcPjTqESBsJWvsyvZOlhpJy4EN4HRtmSIOp1fAsJIZeZ2ggOONQikwQTLquWkMf/84TkcgU68imPFQQliuO5gRNJa3kb55zqN/XCp347f1NJZP/4QVZ5nP4iekPvWIY6aPZlrvTohQt1ZQDkbLGL6sjFFcMyf8Eps77bzvXRYcriPMw4gXY0Bm4am+eZmLM433uj+W4YSOAFG0jueMfckjc2zbsf40mSBs5E1igVA8jbRy09EyBoeYmlongqEaCW/s2dNhqACAm2ZbGctCX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3k/Yu1sqU+il552wDIHzRSXBE8vlZHWjTodRnyGl/M3jmGfndTtKGkwLYTwA5Hzzcx1Ir03h/6SiJVVwq8rjD9+zRU0oHZYrC0oCUYTea8eHsuvDaPixcqffo8v4Mxoa6GN9Ua2v3XF7sEn/VH/nNhLf4TpPoCVRNkqlS4Z5ao+/UMtWLjZ8T9oFDk3wykvM6BAJ4U7E1dJ58y592djjaRwtNcTT0HXyb0C2ytaFfmL04k8B1IWNU56dnFvUloCD4fO0kd8YxP9Pp1QP7EX/kvTEvuImDtUCico8QF9eeccvXn6QEODRBUyqNeapFmh741+xjzYszEKbA90ZsG9xqISW3fDD/9A25B6Bj+f/LUcWMNHqKtAf/8Hdsco89Y9dKk/Ns1vBGysqwrvQNA4fH6+rh8AH8UNKsnhw9xQ5rw98JiP/WdjVpFP6gtS9SUyJEWwZJ2g799yQeoZhDe4ydCsNqCy7xpPV8Uo7oK3xTb1KMkJQc7UWsUmOK59N0Kp7KvhgOQTCsx4wkPi+xlDUr2NI+G9jUTw9vGYrzamR7z/RYlxyN43Pt9mL7XrdWxAkNXMVJgFsDp6IgnWOuN2lxJoh5qypBMNIDFHuhrOfg+dXdi/HQS9jTJz5BP2FZapgDupAT0squkY1/lCSIAg12purtoihMIl8XLOMgnVOy0ZXIs5XMIsWRDR0YBhWx6eqkscmJKA16OHQj177Bhj4dlqEFaDMh6LV3J5TbVb9m6+1jnhZXe+MMjZVj+cImEVUNibtG7I0v0Lsx8agLpWEkIdOmWuMuFd+K3AT93vHa287pzHZkNMm3GfcnYKRTL98XNIGoxkPhMpJsYU7D6Nz0TISATg+DzHQrmomSDee2jLQHxPNEwvri1fWwWw3h168i54AWOSKpn6hq+V+0wORhxdQHaui6Vg67c0Oftbx5V/es86s30vBrNuSRwSsOepv2JMvxkgjvLQOUyYBzczMwIOoOfBu1IJlo5y/a8q9bnx3J2X8pBVbGvFUQpAwNGxArjsU1umcIvPE2CDWLo6ZSYqJ6vPlkz4lx2hpLAR7OuvWvvPY0lgm7+5kLBXX1eEOirDaIQ4/uIqkpBZPksEKcdNjwQEkBNNtRlBlKwQ6Qg63VqNw13uO3fXqiiKKFsDW8H/6LMWjwyruWUcKNOEaIIOvdv4z1IS5bQOQ9rZJc4ligzb1af3VDs2hZIyXbp6g28VDSgUCgUE7uyQPydtCebI8HIBcxA39jTeevChasNyHSf8gwi+kEyKXL9mdamcBxJZtMhIghuCupe1gembIdedbaZzCDpkn2LSC3CQYtZR5BQ+FT20NYAnL/GvvisglKrkuwpQwpkhxIerUIEJp9zbWabvns4W2uW8rdVOFbZ3mo6KZov6y/WaRMdqEspJ9zqz0gu8ih7ithMRIMvHhOJaxcY1QFgjOXUIzlY3w7erh/jEWZky02sNMRnHmbEg677eAOmG+UYZHR9PsT8NrZTRY0PYx4ri1LV2zzqAxkFMjMs0glq7klow7PPDhsRzbZeBagjbSO5QMKzk3BbzW81C/fXytw/PMxmOpTNGF1BlSi91EnDq1xwMD7zdLxQ1c X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9775ccc0-92ec-4a08-42c0-08dba32131c4 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:16.8313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5wIELCvmOKrCvL/dN4w2hJTECgr6bVtb34UxbeGVx1rIreCV8LGoCy9nZq7BixYAlE87lO/oaPGScMdkxNH4PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Ben Ben-Ishay When using direct data placement (DDP) the NIC could write the payload directly into the destination buffer and constructs SKBs such that they point to this data. To skip copies when SKB data already resides in the destination buffer we check if (src == dst), and skip the copy when it's true. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Chaitanya Kulkarni --- lib/iov_iter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index e4dc809d1075..f01ee0e28295 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -313,9 +313,15 @@ size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) return 0; if (user_backed_iter(i)) might_fault(); + /* + * When using direct data placement (DDP) the hardware writes + * data directly to the destination buffer, and constructs + * IOVs such that they point to this data. + * Thus, when the src == dst we skip the memcpy. + */ iterate_and_advance(i, bytes, base, len, off, copyout(base, addr + off, len), - memcpy(base, addr + off, len) + (base != addr + off) && memcpy(base, addr + off, len) ) return bytes; From patchwork Tue Aug 22 15:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361037 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 75C688464 for ; Tue, 22 Aug 2023 15:05:26 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061.outbound.protection.outlook.com [40.107.243.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FDF4CC6 for ; Tue, 22 Aug 2023 08:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ui2hjMg8Ta4er69C+dmhTv5yqYOF4lTJ57xIgNBW5oOw0DRcrqNsxZpVUSWDrNTJz3j80rR5yoklgdAXHHhWKCP3uv0X+vDWeroPznXuX7oPA4ftwhNEuINGSiGRWcoXW0zMK9waIlbfe0LlWrNB+5K5SxKV/sR6ekbtcnJ1hGIWnMLC8mm8bpKj29QIs6E8PQ85Aqv3w0jSH7hLCg9BwtIdu56/MUsg5EweECgYFBoxOMK1WoqTtjj5hD03xunDXjEOt3LzXXxtADVHADujKzJBAx61JQt+oybZnIyx5COPljXIS69ObOeHDVTu9ukkybd+Um05nrc8d4M444yW6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nctS7YrZXoLux3Ty/kJxjtoU8iakB2fV8Knkky/yvW8=; b=ESRyeqey+wfoJ6zC00UDu9NLkf25n+5pYeA0TUh3JlB8E0AwJeL0SlkJcDXpHKNjFFsq9618L/D21uqyOjh5xzwLDJQakulOFkQRYlPdw6q4rDkzdgoXeTXOIVnwsmVERT/LCsp3ESZj3SbRAwae4fHKf342W1vX4xRzhrW9CEl9s0VqgNsOxj7r7vivhvMywQP3JbJ0M709Qp6cet29YAo1ZDeUR+dVQt+ZaqTvAMrFbAIlLpvYPUkUeFFaGEgBwh5TZMzA9SXgvYYkX3kSnttQXGh/tXN6Gi3WrSQdSm14ISsgb5nlTw7yMywui1QJaZBbt9GaBve88V4nOJz13A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nctS7YrZXoLux3Ty/kJxjtoU8iakB2fV8Knkky/yvW8=; b=CIzNQtllqLtgM8ifPvi6Q59p2Jl2UjLD3vuhmoLSlGV6goRhy1azOFmkic8mCmwi7wHPXGdcrRI+7lskyK09HYqC3EKIPkuyWFNCyucRzPyeE5yICPn8bszG85dZQ77tocqdwMnfVmIHww38EyG9+M7roV2dskLI6odWTdSUbbzgfwjqgDeKtU3v14eqY4hgrb/wcuJytqXBLmNuHcjZito5V1G/e8SO97DRmEdK815Uaj123Lyfms8TdSJhxa3sP3dFufKmS9rwf24lN/7DUqBy7xAmlhtglrHkIRb1qx0p3oBLKq6/ZzZuERpiXk01Ihjm1HLkciX8+BoROKXrsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:22 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:22 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 06/24] net/tls,core: export get_netdev_for_sock Date: Tue, 22 Aug 2023 15:04:07 +0000 Message-Id: <20230822150425.3390-7-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0075.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::23) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 89c79dfb-92e9-4686-cfd1-08dba32134e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W6uX/g2IMBWIOlrrbo44EbSndKJO1FYsL6qoN+pzkZ3/pTHe/eQcsOh/2/LISHfqjjRQq2ZD9S/1ySaf3eST8VqTSJpv4Nh7h7HGo7zaye8shlPf6sNomvoTN2y9MBscR13A+jTq3l5tjMsYbT+TGAOJbR+9B3LZvUhp6gzNh4zjtakKyL/2ccenAM9ThTAkMxCb9Lj2RqES2QAAGOUuMlME6wq4bDc9twGF5CeUpgVNbZrHXj3vx8hfoaDbbR488NUDFRSnrPSbHVSCPXQZCBHOdNPIP9XASZxgI+AB3K1f6bU0HIKn/wRCh7h8jY712M2pUxpD1BtuShDZCriA9N4th5oJo4yeGKcE/QzuPTAOfNaISKA8pLfcui+sG199gjrF98kuDoKkLaWao+2EpK5Il7ZDvpVER/mmZA5XO3xHsPHL1BRdeHE7iAhfM4gMcI0QChyZ/wSIlmy6kotj6xEjYSUHv1ZuqSltfFcKsqU5+rCnaPL4nbSZbdQe/SGJ3yM4MBYz9Yh3S+UM7NHkReWZknOs/tOd4gi1/A+w1m43bu2pKgnfMAcAv3kzSeVU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 89k/D0Lw1sEbGijFZkFzBrRlYHsh9PTmaz95Ynk2MVIXs2+//yLDQVbxmEsrpYUmEZQglmSN4FgJHLrrt9hnIjS1DyV7WyPkukrGJBaBJd8QOXA1CnNmQhclmYBd/flg5srPuAsBUJBUq9FBYaRuOvXM6gFlcwEvroerJE/vH+sC7zu5lMSsILNTaJNelw8RqcQsTWkLdRuBJCZ0QLx0qmy0O8uuhai3QFTtgP7/qBU71zDJD3NE1phCxWpJVY9QzMYV7qQBsa7EUwE8TXLHiTkYOpE2atVVHl/yrmrF7WS5BOEA39Gt6jSfRg4iq8cIEJoNZIkra+WFgU3RDqMw9n38qkZQrAIwOc3b/CndLOtGMw33nfb5JR0daiioXlqwZKtc8bu6Wzt26Qevlhgj59e6NomoI6ahpWQnb+HN7eyGTwBFEi342Aho2LUGfOXZmVnhttjwVke3VTNd8jeBqSmL/D3HdRK6T8/MZhubg0z9RIJ8fcwd5RRWv4HA1HFk6FM7yz68083U7aLgGe7NLyu3a4IdMR2CcanaT/7R72lm6vUvXgBgWk2e6V1PE4/yNXAzo2+bqU7FyQr0EskLVnFFUsWLKgjOdfzU+4B57MXWE9AMtvW8LqjsZsBpQxHdxWp1GVdBvrmDIdmKB+9lGnL2JEOJgyCIkdPo9qohH4N71X3TtN9MDznFyknGsRiBAMdHHFUciX3uUTaibtlGgcKsEBmonZFKsueDaFXijIzD0CHx6KXDAcpRzVvBAWT9qfyoY5rZHIeK9FLAhGc/fBVk8a6OiabXvvTPUWerlj5Mag1+KVVtrSrOKzZBGCGIFIA12ys9O7k0hgEPzdSBkPkoBniyrnPPiL1PjkkSI6gUiZJMXt4IgoeGE7ABkl7JwV50R/FJJ6k8vugdZAK3jKQzfAQOj+yJ+bFwYu7nfZlvDmgrYeAb6OC0Aaeeq26ocV4S5NUInekczqBf6xEXGR1a8j9KR63MNikNdoFACsXbfyTwH2OO+OFJWj9d/Fn6nOFpeWMb0aOi2L/ujUBhEwPWemwxNLisvoce8hsLfJn+vSXYArvYWSGge2i9VJfmbrBxTOKQL2FVJXGU8RanW5V9FYUcZoxQIwwkisSPJGnoJa9K01F8iN8kQxLiq/ecogd7WgoR6cfa0clUY0b3XK+Bdx0j+T7Hdd4+XbXVf3GyEVvye60YZL1dm5n6nLVDM9rgF1Oj5QlLOnqyhKfHqoicBfnjme8BIVg13W3PmVX3vOxqq0Y9ZoNcTWX6tGXw0L00m7KdLr5MVzWZ8qU+XNs/kCpJftRgZ4j1SgfUfOaxb1Ragwe74vXWkWKvtUhTUTcn2kE/ax2qEkftDAIe3sL/LNjlYJdbl/FDhmDzejO1IksrsklD6yUWMcSGT0/xGDQDCf0xwUgniHy65+1CBk1keoZzsdqgivsxiIWfKE916CnVOctbF0OR3tezJeGnC830EHikNdB1ooW0hV6UdX2TupSUV2DWqn27WwLL0KjhvD2FAFnN0Orptsc0koxEcCTEQ8rfcmZeh2uwCKJAgia+rPIcp0Kj8jy3MiZXR+TNrFCYJNeMdToVczqDmP7A X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89c79dfb-92e9-4686-cfd1-08dba32134e2 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:22.2291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1a7FN2Zn3GiqO7V8bVA+6CleNpgIdS8UGXlysgAqWlT24RixUErmVNQ5cc8wvfpoQ9BcIexQvGJG9lrJNx2ETg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org * remove netdev_sk_get_lowest_dev() from net/core * move get_netdev_for_sock() from net/tls to net/core get_netdev_for_sock() is a utility that is used to obtain the net_device structure from a connected socket. Later patches will use this for nvme-tcp DDP and DDP DDGST offloads. Suggested-by: Christoph Hellwig Signed-off-by: Ben Ben-Ishay Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- include/linux/netdevice.h | 3 +-- net/core/dev.c | 26 +++++++++++++------------- net/tls/tls_device.c | 16 ---------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 04255823079d..9c2ea8b5cc6b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3129,8 +3129,7 @@ int init_dummy_netdev(struct net_device *dev); struct net_device *netdev_get_xmit_slave(struct net_device *dev, struct sk_buff *skb, bool all_slaves); -struct net_device *netdev_sk_get_lowest_dev(struct net_device *dev, - struct sock *sk); +struct net_device *get_netdev_for_sock(struct sock *sk); struct net_device *dev_get_by_index(struct net *net, int ifindex); struct net_device *__dev_get_by_index(struct net *net, int ifindex); struct net_device *netdev_get_by_index(struct net *net, int ifindex, diff --git a/net/core/dev.c b/net/core/dev.c index 17e6281e408c..3c62985d9073 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8215,27 +8215,27 @@ static struct net_device *netdev_sk_get_lower_dev(struct net_device *dev, } /** - * netdev_sk_get_lowest_dev - Get the lowest device in chain given device and socket - * @dev: device + * get_netdev_for_sock - Get the lowest device in socket * @sk: the socket * - * %NULL is returned if no lower device is found. + * Assumes that the socket is already connected. + * Returns the lower device or %NULL if no lower device is found. */ - -struct net_device *netdev_sk_get_lowest_dev(struct net_device *dev, - struct sock *sk) +struct net_device *get_netdev_for_sock(struct sock *sk) { - struct net_device *lower; + struct dst_entry *dst = sk_dst_get(sk); + struct net_device *dev, *lower; - lower = netdev_sk_get_lower_dev(dev, sk); - while (lower) { + if (unlikely(!dst)) + return NULL; + dev = dst->dev; + while ((lower = netdev_sk_get_lower_dev(dev, sk))) dev = lower; - lower = netdev_sk_get_lower_dev(dev, sk); - } - + dev_hold(dev); + dst_release(dst); return dev; } -EXPORT_SYMBOL(netdev_sk_get_lowest_dev); +EXPORT_SYMBOL_GPL(get_netdev_for_sock); static void netdev_adjacent_add_links(struct net_device *dev) { diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 2392d06845aa..44fe5e37b689 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -122,22 +122,6 @@ static void tls_device_queue_ctx_destruction(struct tls_context *ctx) tls_device_free_ctx(ctx); } -/* We assume that the socket is already connected */ -static struct net_device *get_netdev_for_sock(struct sock *sk) -{ - struct dst_entry *dst = sk_dst_get(sk); - struct net_device *netdev = NULL; - - if (likely(dst)) { - netdev = netdev_sk_get_lowest_dev(dst->dev, sk); - dev_hold(netdev); - } - - dst_release(dst); - - return netdev; -} - static void destroy_record(struct tls_record_info *record) { int i; From patchwork Tue Aug 22 15:04:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361038 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 322421FD0 for ; Tue, 22 Aug 2023 15:05:34 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2076.outbound.protection.outlook.com [40.107.243.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B31A5CC7 for ; Tue, 22 Aug 2023 08:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mn4O0FHkh17twqW9Ly3hWViqrIkvf6iA5kxMHk1X/CYaXB0mw1AXpCDObudRqmaQwL1frep/wt+P19djHNai3kCmCrhNVpU+otwIShgOP/DzTFjmWkOKyGbV9Im8tlLOwL3BPOCrKiNOOY3El9i0Drpj5ZMHwa4CcmPGPCf+4ufRZe432w9/CZIPGMZtEYcHRCrTQ5k7cwx66TDpUnq6tYwUi6b1jk514/PJcPRQmYdj28kZzr/qPwcUlwdMJn8PKClS0E+xL0UNaZts80TnPlO5Pm8m3xujwWvCPUflCgA5bjc9+ehq92QBePnPU0XiCJ5sBtLEadwVA7UYRR1MsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E9pKHbZ27wkqcih/om8NwEPw4CQRXs18uzWlhmNgIEE=; b=nJ17qBdXDfQvPiHyseGBrHmmkJ9PXRsb5olj24D3DNhopbxmLPVCfIXn/KqF6gnvdXJJP3/YzSyUj+qYzH3s3jMy75tlbg6MFHpDc4FzOzNMyWv6JYLrz2OD60prl8xVJ46RF1rgBGk3KogmN6W25qCbu2Av/gsleH7aJLiPnerKbPO/aD5DEQocbbf+HngKtINy97a8sW9pD6x61XXN3yFnlEbvUQjBnUF7vpOZeVczbpitiYMycCO8am2F7r+Taahahghd/98ncw8KYJKlOJq0rOKpO63PiUmxDVjGDbQBZRwIESsjJtSk9+Yxu3i/gtPxMbyQp6qllsw3Paq8mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E9pKHbZ27wkqcih/om8NwEPw4CQRXs18uzWlhmNgIEE=; b=CXXc+1YAjE48SNhvEdq439gJziHYewsj2cdgFr1GgtV2dGH9LChdzyx8je7reLnukXWjFBr+5XWpJbB0rTPzfkC7/ci/mQ+Pq0JKRAEcJiquYEAjxBKsYp+2h49mZpiaCo9RQookL1+DsO2uHKwdsesqeRK0nXYG5dm/4NKP5cnlUC6WAJA+bd/zYvpFM5fZzaGf2V2uT172vCi4IqG/VsydMtbYxjQDMt8K2FOXvAKomdStaw2q+bH1oYk/iLTt3UJ3DF9lOnR36lrMwb+miu3NWM2QEa2SOxVEw6gauEtR8coKT+PozeIbnfFoLCoV/dzmNYzTqtu4COro6iY3cA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:28 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:28 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Boris Pismenny , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 07/24] nvme-tcp: Add DDP offload control path Date: Tue, 22 Aug 2023 15:04:08 +0000 Message-Id: <20230822150425.3390-8-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0096.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::8) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 76f0862e-d1d3-4051-ec03-08dba3213899 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWPyiBTtmdq6BSP7hdEQyz1JJcsWG1IjIGsReDhvYLeumeeSb9P39eqAtXwFv5c9rSRUq7cGlV5EfC5qHXzfILdl+EELA6cjPD4t6ICgYP83WUT0SoU3qJYUBIJiLRsauTPjd3Q3lpBdQzQpIiWaVv9KOq5N3EsB3Qeug0XqKqMMAy34s2PGXkl9PNPqJnutkneJwaLREz219Zp5U/SzUccCMtaPnykrHNKPPbm0+ZVnuqohgqI9uBDKRij/Vl1f9KFbpBpe4KuvvE3jNuKJXutjj6j5FzKUneWNsMBHEq4p2n3F+cx2R9OGdVm72ijq9NTsWDwWTMKwNEzEXWuDndfeE7fjM6/HU+vIPwVwrDeU1HdNI1HLmH16GBG+8NRTV/afpBWiM4ReYLA/cdLdLcfmwsb60w2zt45n5hDGDQFn041T/L6AwHmORSVIgQwv3FOI0713Rqf4YrYyczit30vhKa9ZOvXM54Y+woQSmuyVk/04IPoxKd0Jx8BzOaSYEUq/BmkTcwtGO1llCDPJo5KuBpMSYKqK6CjU3cyH8w8nucafSqFNtGjTIn/oNPbj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(30864003)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wKeXSXNwyO+IX8Fq3zmYRftElL+EbUDKC/HB5P79zL3uUHYvBIK4aP9fsELeTdVxf5riUwq1+Vk4HD0899YQFbOxUZchI8zBpiXjSLoy5vD/9ppCx9cV2PjGZiN56Ye/8V71LLB2yTsG0+lDF4Fa7XmXG0Nq8CBt7ySv0OuJUL97m3M1uO7cUoKyCY2xPareAU5SAALiezNR7XxP12ESvwM7o3rqCWMBSF5jv34UfHplh5YKZk8Df8xTwtvD/B8qdEfL0JJbASx61lictNBaJOnF6fAUp3m1ILvZn1Y+oEk6rqrh0jrjGvHnMWA270pJkv4+pWspSsiAua6rtNjck/zYFzjBgIQBIPopDVpZ5xv5auG8Hxt7wK9xZAja+9PxrNpZBbDQSWeqkPCeS2YW4W7VnbuDQi3GNyYpD8Q38KomAkJs0csuVvQDxcnrfkstRWusILY24sXKNQJKh+YO4b7VUl4LE00Mks2jo6uNrY/K+UVCZdF812jRcwgZSKLG9zqytBopiq4NtumCRoO6x16tg2V0nsrKhGQEzaK0kaZvXbh8B1tu1uN1booSDRDxCRjIZGCK4I8MVAcwT3623acRCMHogKWOFheMrOsqh+vaNo30EKGtsvPhyOUcrIKIzQ/fQhNnerb/R46WROWg6lI8gmphs9WfWSK8YpfOpQPeBIPENDi//WWxOqGF8WL1SXdcAfownFR6Fj85sh/l+8kcu8upd5h92vFAKJViHSyHvlHcln9k5YbUJ92IWOu/zNYIhOsn/sWI85WcP/AxY/GQ6b0AQNzbqkwtOwNeQrmYVHbbtAKFw0fhx5GKE/Q3dHfapqpH30NkefDOZh+ky/uf2hjKniatIV+DrHSZJYe4cDDlEsVVDnqiWoNS6yIhNe/qF9OkzhNgNFpsmDLKlAOdr/6BISoMjGsOd7hAqK0awCP8auOA8TQk2Ctk7U1U7TgBhMF4Y3XGspRzvJDy8AwvD5m6rZ1UjhIiDiMF1VYvfNrb70O6BpUF70jRDflQMNmzZmHRrodyrrHOSX/5RKlcEr2KZ2/RyoAHpNAqvUrNA0OEjucKYkF2p6/Dqn+JNxNnLgzyD//Q19zvIwop2P7qY0X8cSG6nCvFeZpoxO3/xoaEzQiYworlzzDV4kJBJAEISKLzZ6wEfKY6NiRJfFSyCYPxyYK392rVZJs1EhzK33SeMLkChSRi/9Z8kqFWsL7TwnMgT6hx9pVRa6nvNEgjHI4O1ZEGxS9pE1UD3pBG2n2suE8FQJXTOB08euG9WQz5OM4WGWxic/KgzAaDcS8eUGVx257Vr35T9hYCiaNATR/bVNAp8mFevEtCVfdQRXhOPH3NGh63RaVbEkmcBKAkiNDlyM8RN1JNbwH0Bu++jxYnaN5KbPmbm50WdRYAssFv4TahROwXom0siamCh7lOwRGOE6s1PlTQTLUVw4nYQDmSyJ44grwCWE0rk1OOtvzJfnIUmNfah1/LTjX3itE34qxTihFHw140ihVjEZS7bQQ5R78AOne7vyXtQFOrWADEfFnxUTdc/ayRswyq2cdlSUKW0L0vtLiW3a4Ml7BD4LxSGW9u88M50nV1tUbu X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76f0862e-d1d3-4051-ec03-08dba3213899 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:28.3624 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6R3SXt8lrOm2dPjVOJ27TjNJdguFg7YHdI+NJpJCu+jX7qpfCspu6iUEubr68vNJxzTkcBYZIDR/EjHLwoG9zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Boris Pismenny This commit introduces direct data placement offload to NVME TCP. There is a context per queue, which is established after the handshake using the sk_add/del NDOs. Additionally, a resynchronization routine is used to assist hardware recovery from TCP OOO, and continue the offload. Resynchronization operates as follows: 1. TCP OOO causes the NIC HW to stop the offload 2. NIC HW identifies a PDU header at some TCP sequence number, and asks NVMe-TCP to confirm it. This request is delivered from the NIC driver to NVMe-TCP by first finding the socket for the packet that triggered the request, and then finding the nvme_tcp_queue that is used by this routine. Finally, the request is recorded in the nvme_tcp_queue. 3. When NVMe-TCP observes the requested TCP sequence, it will compare it with the PDU header TCP sequence, and report the result to the NIC driver (resync), which will update the HW, and resume offload when all is successful. Some HW implementation such as ConnectX-7 assume linear CCID (0...N-1 for queue of size N) where the linux nvme driver uses part of the 16 bit CCID for generation counter. To address that, we use the existing quirk in the nvme layer when the HW driver advertises if the device is not supports the full 16 bit CCID range. Furthermore, we let the offloading driver advertise what is the max hw sectors/segments via ulp_ddp_limits. A follow-up patch introduces the data-path changes required for this offload. Socket operations need a netdev reference. This reference is dropped on NETDEV_GOING_DOWN events to allow the device to go down in a follow-up patch. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/tcp.c | 227 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 218 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 553efba788fb..4d530448584f 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -21,6 +21,10 @@ #include #include +#ifdef CONFIG_ULP_DDP +#include +#endif + #include "nvme.h" #include "fabrics.h" @@ -46,6 +50,16 @@ MODULE_PARM_DESC(tls_handshake_timeout, "nvme TLS handshake timeout in seconds (default 10)"); #endif +#ifdef CONFIG_ULP_DDP +/* NVMeTCP direct data placement and data digest offload will not + * happen if this parameter false (default), regardless of what the + * underlying netdev capabilities are. + */ +static bool ddp_offload; +module_param(ddp_offload, bool, 0644); +MODULE_PARM_DESC(ddp_offload, "Enable or disable NVMeTCP direct data placement support"); +#endif + #ifdef CONFIG_DEBUG_LOCK_ALLOC /* lockdep can detect a circular dependency of the form * sk_lock -> mmap_lock (page fault) -> fs locks -> sk_lock @@ -119,6 +133,7 @@ enum nvme_tcp_queue_flags { NVME_TCP_Q_ALLOCATED = 0, NVME_TCP_Q_LIVE = 1, NVME_TCP_Q_POLLING = 2, + NVME_TCP_Q_OFF_DDP = 3, }; enum nvme_tcp_recv_state { @@ -146,6 +161,18 @@ struct nvme_tcp_queue { size_t ddgst_remaining; unsigned int nr_cqe; +#ifdef CONFIG_ULP_DDP + /* + * resync_req is a speculative PDU header tcp seq number (with + * an additional flag at 32 lower bits) that the HW send to + * the SW, for the SW to verify. + * - The 32 high bits store the seq number + * - The 32 low bits are used as a flag to know if a request + * is pending (ULP_DDP_RESYNC_PENDING). + */ + atomic64_t resync_req; +#endif + /* send state */ struct nvme_tcp_request *request; @@ -188,6 +215,12 @@ struct nvme_tcp_ctrl { struct delayed_work connect_work; struct nvme_tcp_request async_req; u32 io_queues[HCTX_MAX_TYPES]; + +#ifdef CONFIG_ULP_DDP + struct net_device *ddp_netdev; + u32 ddp_threshold; + struct ulp_ddp_limits ddp_limits; +#endif }; static LIST_HEAD(nvme_tcp_ctrl_list); @@ -291,6 +324,136 @@ static inline size_t nvme_tcp_pdu_last_send(struct nvme_tcp_request *req, return nvme_tcp_pdu_data_left(req) <= len; } +#ifdef CONFIG_ULP_DDP + +static bool nvme_tcp_ddp_query_limits(struct nvme_tcp_ctrl *ctrl) +{ + return ddp_offload && + ulp_ddp_query_limits(ctrl->ddp_netdev, + &ctrl->ddp_limits, + ULP_DDP_NVME, + ULP_DDP_C_NVME_TCP_BIT, + ctrl->ctrl.opts->tls); +} + +static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags); +static const struct ulp_ddp_ulp_ops nvme_tcp_ddp_ulp_ops = { + .resync_request = nvme_tcp_resync_request, +}; + +static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) +{ + struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; + int ret; + + config.nvmeotcp.pfv = NVME_TCP_PFV_1_0; + config.nvmeotcp.cpda = 0; + config.nvmeotcp.dgst = + queue->hdr_digest ? NVME_TCP_HDR_DIGEST_ENABLE : 0; + config.nvmeotcp.dgst |= + queue->data_digest ? NVME_TCP_DATA_DIGEST_ENABLE : 0; + config.nvmeotcp.queue_size = queue->ctrl->ctrl.sqsize + 1; + config.nvmeotcp.queue_id = nvme_tcp_queue_id(queue); + config.nvmeotcp.io_cpu = queue->sock->sk->sk_incoming_cpu; + + ret = ulp_ddp_sk_add(queue->ctrl->ddp_netdev, + queue->sock->sk, + &config, + &nvme_tcp_ddp_ulp_ops); + if (ret) + return ret; + + set_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + + return 0; +} + +static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) +{ + clear_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + ulp_ddp_sk_del(queue->ctrl->ddp_netdev, queue->sock->sk); +} + +static void nvme_tcp_ddp_apply_limits(struct nvme_tcp_ctrl *ctrl) +{ + ctrl->ctrl.max_segments = ctrl->ddp_limits.max_ddp_sgl_len; + ctrl->ctrl.max_hw_sectors = + ctrl->ddp_limits.max_ddp_sgl_len << (ilog2(SZ_4K) - SECTOR_SHIFT); + ctrl->ddp_threshold = ctrl->ddp_limits.io_threshold; + + /* offloading HW doesn't support full ccid range, apply the quirk */ + ctrl->ctrl.quirks |= + ctrl->ddp_limits.nvmeotcp.full_ccid_range ? 0 : NVME_QUIRK_SKIP_CID_GEN; +} + +/* In presence of packet drops or network packet reordering, the device may lose + * synchronization between the TCP stream and the L5P framing, and require a + * resync with the kernel's TCP stack. + * + * - NIC HW identifies a PDU header at some TCP sequence number, + * and asks NVMe-TCP to confirm it. + * - When NVMe-TCP observes the requested TCP sequence, it will compare + * it with the PDU header TCP sequence, and report the result to the + * NIC driver + */ +static void nvme_tcp_resync_response(struct nvme_tcp_queue *queue, + struct sk_buff *skb, unsigned int offset) +{ + u64 pdu_seq = TCP_SKB_CB(skb)->seq + offset - queue->pdu_offset; + struct net_device *netdev = queue->ctrl->ddp_netdev; + u64 pdu_val = (pdu_seq << 32) | ULP_DDP_RESYNC_PENDING; + u64 resync_val; + u32 resync_seq; + + resync_val = atomic64_read(&queue->resync_req); + /* Lower 32 bit flags. Check validity of the request */ + if ((resync_val & ULP_DDP_RESYNC_PENDING) == 0) + return; + + /* + * Obtain and check requested sequence number: is this PDU header + * before the request? + */ + resync_seq = resync_val >> 32; + if (before(pdu_seq, resync_seq)) + return; + + /* + * The atomic operation guarantees that we don't miss any NIC driver + * resync requests submitted after the above checks. + */ + if (atomic64_cmpxchg(&queue->resync_req, pdu_val, + pdu_val & ~ULP_DDP_RESYNC_PENDING) != + atomic64_read(&queue->resync_req)) + ulp_ddp_resync(netdev, queue->sock->sk, pdu_seq); +} + +static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags) +{ + struct nvme_tcp_queue *queue = sk->sk_user_data; + + /* + * "seq" (TCP seq number) is what the HW assumes is the + * beginning of a PDU. The nvme-tcp layer needs to store the + * number along with the "flags" (ULP_DDP_RESYNC_PENDING) to + * indicate that a request is pending. + */ + atomic64_set(&queue->resync_req, (((uint64_t)seq << 32) | flags)); + + return true; +} + +#else + +static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) +{} + +static void nvme_tcp_resync_response(struct nvme_tcp_queue *queue, + struct sk_buff *skb, unsigned int offset) +{} + +#endif + static void nvme_tcp_init_iter(struct nvme_tcp_request *req, unsigned int dir) { @@ -733,6 +896,9 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb, size_t rcv_len = min_t(size_t, *len, queue->pdu_remaining); int ret; + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags)) + nvme_tcp_resync_response(queue, skb, *offset); + ret = skb_copy_bits(skb, *offset, &pdu[queue->pdu_offset], rcv_len); if (unlikely(ret)) @@ -1806,6 +1972,15 @@ static void __nvme_tcp_stop_queue(struct nvme_tcp_queue *queue) kernel_sock_shutdown(queue->sock, SHUT_RDWR); nvme_tcp_restore_sock_ops(queue); cancel_work_sync(&queue->io_work); + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags)) + nvme_tcp_unoffload_socket(queue); +#ifdef CONFIG_ULP_DDP + if (nvme_tcp_admin_queue(queue) && queue->ctrl->ddp_netdev) { + /* put back ref from get_netdev_for_sock() */ + dev_put(queue->ctrl->ddp_netdev); + queue->ctrl->ddp_netdev = NULL; + } +#endif } static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid) @@ -1848,19 +2023,53 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) nvme_tcp_init_recv_ctx(queue); nvme_tcp_setup_sock_ops(queue); - if (idx) + if (idx) { ret = nvmf_connect_io_queue(nctrl, idx); - else + if (ret) + goto err; + +#ifdef CONFIG_ULP_DDP + if (ctrl->ddp_netdev) { + ret = nvme_tcp_offload_socket(queue); + if (ret) { + dev_info(nctrl->device, + "failed to setup offload on queue %d ret=%d\n", + idx, ret); + } + } +#endif + } else { ret = nvmf_connect_admin_queue(nctrl); + if (ret) + goto err; - if (!ret) { - set_bit(NVME_TCP_Q_LIVE, &queue->flags); - } else { - if (test_bit(NVME_TCP_Q_ALLOCATED, &queue->flags)) - __nvme_tcp_stop_queue(queue); - dev_err(nctrl->device, - "failed to connect queue: %d ret=%d\n", idx, ret); +#ifdef CONFIG_ULP_DDP + /* + * Admin queue takes a netdev ref here, and puts it + * when the queue is stopped in __nvme_tcp_stop_queue(). + */ + ctrl->ddp_netdev = get_netdev_for_sock(queue->sock->sk); + if (!ctrl->ddp_netdev) { + dev_info_ratelimited(nctrl->device, "netdev not found\n"); + goto done; + } + if (nvme_tcp_ddp_query_limits(ctrl)) + nvme_tcp_ddp_apply_limits(ctrl); + else { + dev_put(ctrl->ddp_netdev); + ctrl->ddp_netdev = NULL; + } +#endif } + +done: + set_bit(NVME_TCP_Q_LIVE, &queue->flags); + return 0; +err: + if (test_bit(NVME_TCP_Q_ALLOCATED, &queue->flags)) + __nvme_tcp_stop_queue(queue); + dev_err(nctrl->device, + "failed to connect queue: %d ret=%d\n", idx, ret); return ret; } From patchwork Tue Aug 22 15:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361039 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 11C951FD0 for ; Tue, 22 Aug 2023 15:05:37 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FD9D1BE for ; Tue, 22 Aug 2023 08:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gEIv61nSqVUXzv6WS4jDsbfzGqbhAarccPb7DoXyEssJYNjXeOZl7Fc7h5LGKBLrezicNKJ8dXQVjermAYz6lcoLLGomLseP3+HzxQH5agQmgdxma65Tyns7FJwOjppg0cLbLXISCG5TpzSXHw+QQgU632PA5fx6dp/5n5ywhaJmw+TkZw2q3p1pHqxBMrrWCr9OrPci115UR+NIzMDh9aXs6KI9KRs/Oo07tSmP08mkxszxnyxKyAJgDQ93007ork0nPbj1ceubMAVhoxfLs07DhRp4xdpOSQloYCRNXO2fb92wyCd8jnoaZ2XqzQsgfmGQ7nzAruelPMqeCpepYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b+anthLxvE80SkJs+cPSd+Vf8+E2pIUvCd/ZdLArGAw=; b=U7QpthqryGf3riUA0ivC+IE7z+mOSyE9hzU4EDvupnWKFDAhu2AM8WgCw8MdTvWtgXYcx2FAdJivjK2ffiXzNydnMS8InCi6HfPBMBgcT3CB2p/NycqfCAxhHD7gwZz5xdLP0cH4g4MIFKzIOUckeRldJE4KoFpsDMJdK8EEYd79skoW4f4g7yvB2cfXpRZ+HWG23xPUZLKx/7bKdsrY9zPB1J8LLI3mMLp8/6x3b9V2/sCjmjhd7Bl1l6DkActOuEVyBxTgVXth/w9QsoElzWyOFcdpx9GoyGJ1x5jFsw5sQsDui1oygAMz234f7Up4z6XslcphMLzwtxL6Yd/C7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b+anthLxvE80SkJs+cPSd+Vf8+E2pIUvCd/ZdLArGAw=; b=VWMmt4CvWEm6Fldxbk08NLC1CREV5alOgwOwW/J1kgW8d5lhczuvNlNPnhGk9e4Rotqs8spRLRazhOpC8Pjk7D5fc1o16MBrJl7scxGQY1XIOepOSZRevbjok6bcFFnaD6n6gmLRAkwnEKocK72G/toccVK8CSy+mblv85PNxi4LQdp8HOn8wni/jVl0ZlgGquKHxe6E/31DX7uLD+1lReqdTl6vUNQDAHXAqgQNStqSzagXxlXhiSNSwsjEI8hskSBeJC0KoRU/SEHdPMiyyiqc3heShxPQjV/YiEdwlYAxxXLwJ57Ccw5NCarn8gx0en3hfsuXsw/Z7DGFhPnF7A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:33 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:33 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Boris Pismenny , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 08/24] nvme-tcp: Add DDP data-path Date: Tue, 22 Aug 2023 15:04:09 +0000 Message-Id: <20230822150425.3390-9-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0152.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b3::7) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a0169eb-3599-4e65-5543-08dba3213b92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mP+K0PWsodxfki2qlWQ7Uix/upejW12rA3BsQKNODT84jOUG8f/FLp4dhLUuxCWsGYMT/jihjaCMtgDBkOHyNoqGqyckCCIsfQDUXAMUxwh15NwhZC6F6AWG0CmbdWHEABmhR+L4sgbfCxtW3oPFT2RjVFNBkMpa45faPBfljkbiNuPx04CXfKINVSuwRRBzigfVTqC3vfYeBIXbA2MaI87K3agyhNdaj60WGRuEAaG/0CGJKDk6qeGnaoV8aoYgZYX/vNYnvYPtZifGO+N5GbXGLY9ErWSNJC61RR9E9SAikqqUar+bTR+0DK5h1mLb5zAT1TVrmJd05E2N+D/k2vQSabDXGA4uWOfjYTvXDSGpyzMkdKtPh0J2unYSCBJDDVEBVdVNgHTj/UkrwzY29uOFSj1QfuX16RSso+PACryxQ1TbvihykzfMPWbDwWb7B8iHKfESdgqpp486zSyTLRiEM6LmLqcw8zSCKeP2AW22bgpHHaixo6f40EO+92XqfItGqVfIlVwXe1afW08jxJ1zxHyLp1a3w3Us78ihJheDIwwBb6Z7pVunXShJhR7i X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gKXTR3h2pIrVA5cmEyGXGGDlIx2aNB2E5isBDPkl9hdmlracfDUT2NechiJSMPKke0MSx+GVDOyiet9CGn4+DZ3CuumjaJwiObu2mlimwtmHyfAlhl2kwtgCu2475mMqz7cFeozck4T0KehvxloLw/bL3LKkZ/WOkRW1Mm6pWV4Mg3OlhUTJvvPk5lDNAQuaIHV7gFo7A366G1sGrJbgrx/2qxCkktRcbVRLPW9hoWcP6FBBOBWDq5yYGOaetZ+KLtmp/JANpFUEAybAqwbF2RI7D4cFeOqGr//+Lv1irrk18CnuyKoEDqkBlp7VuIImKBcI9unOg2UHIpB6tF+eIO/tkTxxZ//fIIRzONARpXaj2kIyNesHIcpBdEoxmqNqgLCfdIeZNUmBhpnN8k74FZZt7Bv5lQ/qtmjAqxc/g01aFH4aztidg2c891SXtDTf3BweNaUztmodiTULrJQBhv3RyL/W+z94pGVZ/0xEMZy83TE6YinJgbgCBN57MHRJUgWGlU7Frm2I589A9sxMZzgOYZv48f0bRHJ3gVKJJf9I/woD6VNktSqyusEe4rllrU8druiStcNQYATRCNh7MFSYZTlOrsrITH2agATJIsSnFcZo3kfT2t1tS8HXRkqPUkfl99tSLp/2KpTA0hS7D6DFvmf0l1s3C762cQiZ/veve9J9qkB9I6fKYxk/XbIW3KaanBpRdrloBxkfs8q9n4loj/Opwp811zzNeOKO+gBreDOCQHBMv3Nyr+vCsj2OgF3Yak+WZuSsKDIMP3gWY3Bs4NY+w7i5uJfXrRAFz37uU2+XO2+JndUCyqlW8aeiPTQ4AQjwexIVn80ENw/qMDogEjJ22hfqKHQrcbjExjEyr5nhEvAU/x7Uw40EeLeOqVPoNmNVVpd7cbFSkf2PB+o3GBq4tk2/SWQpp5+guuBQOyM9ZWKgAlrnH5DwQHVNiqN+RxkBReErezZLYyGp+pLNgOZZMMxQULl2BKIcUMmaH9wL8vs8MpDxtf73xztVb1BxOPuxxewPmWHnuCsm7xY7aCfHC5aYl/1eFcWUqqN8NC+w/6GFZXYcSyTJLcDjur49p5wV3k0tKDzc0WxQqg+D2Smah5eM2uWt3RWjNRZ9CXh+pIG34pxuSs60CPRs7BqX+LpacYHu3HO/D4+xN5IQ2VP2R7kkgaZhsEdF4nAi0j0fFSrMgy15htc3tNCIqZ93ExbbwfzTB4RdqE2p+qS0tVXv3Q5u9ZpDqmU0/63lS6S8Ym/2XLz3kYOuwUfQE12s/jo0A8jxGU+bLxTdVrYvMfmKKneUHNFxa9O44/WXmHYm29eCxS03qOthSWAva9Xt09Cr0OAr4tvAbtnqehs7Ww0T/ah/WuSG7Bxqn2cpyK1Nft6RyIR6RZgNcsy79DANRoN3Lu5AOiQPjIIF876y8MNt/MTnGPGNA0N2ikEdYic8aAoPqJP4YK5PGtB4WH5gEF4+3U98axgA54No0KmscNKAeu+tbR2bhTBd9JSPteaF7AU3ApYVUhRu/JI7Oo33L5BjzNRG0TV+z6FSRwRgoWyGBPX7BJ88W4SVJRnL1PiuHATTht3uJ8zlktYZ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a0169eb-3599-4e65-5543-08dba3213b92 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:33.3040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BIZrpfvz3QYegEr0o6CENICVa5buI1nOS2GTgcsSX5uvGp7alE8ab0svSJe7e/tJyIAbOzsEGNiYARMT9xEIBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Boris Pismenny Introduce the NVMe-TCP DDP data-path offload. Using this interface, the NIC hardware will scatter TCP payload directly to the BIO pages according to the command_id in the PDU. To maintain the correctness of the network stack, the driver is expected to construct SKBs that point to the BIO pages. The data-path interface contains two routines: setup/teardown. The setup provides the mapping from command_id to the request buffers, while the teardown removes this mapping. For efficiency, we introduce an asynchronous nvme completion, which is split between NVMe-TCP and the NIC driver as follows: NVMe-TCP performs the specific completion, while NIC driver performs the generic mq_blk completion. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/tcp.c | 108 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 4d530448584f..63e64494e257 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -127,6 +127,13 @@ struct nvme_tcp_request { size_t offset; size_t data_sent; enum nvme_tcp_send_state state; + +#ifdef CONFIG_ULP_DDP + bool offloaded; + struct ulp_ddp_io ddp; + __le16 ddp_status; + union nvme_result result; +#endif }; enum nvme_tcp_queue_flags { @@ -337,10 +344,62 @@ static bool nvme_tcp_ddp_query_limits(struct nvme_tcp_ctrl *ctrl) } static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags); +static void nvme_tcp_ddp_teardown_done(void *ddp_ctx); static const struct ulp_ddp_ulp_ops nvme_tcp_ddp_ulp_ops = { .resync_request = nvme_tcp_resync_request, + .ddp_teardown_done = nvme_tcp_ddp_teardown_done, }; +static void nvme_tcp_teardown_ddp(struct nvme_tcp_queue *queue, + struct request *rq) +{ + struct net_device *netdev = queue->ctrl->ddp_netdev; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + ulp_ddp_teardown(netdev, queue->sock->sk, &req->ddp, rq); + sg_free_table_chained(&req->ddp.sg_table, SG_CHUNK_SIZE); +} + +static void nvme_tcp_ddp_teardown_done(void *ddp_ctx) +{ + struct request *rq = ddp_ctx; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + if (!nvme_try_complete_req(rq, req->ddp_status, req->result)) + nvme_complete_rq(rq); +} + +static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, + struct request *rq) +{ + struct net_device *netdev = queue->ctrl->ddp_netdev; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + int ret; + + if (rq_data_dir(rq) != READ || + queue->ctrl->ddp_threshold > blk_rq_payload_bytes(rq)) + return 0; + + req->ddp.command_id = nvme_cid(rq); + req->ddp.sg_table.sgl = req->ddp.first_sgl; + ret = sg_alloc_table_chained(&req->ddp.sg_table, + blk_rq_nr_phys_segments(rq), + req->ddp.sg_table.sgl, SG_CHUNK_SIZE); + if (ret) + return -ENOMEM; + req->ddp.nents = blk_rq_map_sg(rq->q, rq, req->ddp.sg_table.sgl); + + ret = ulp_ddp_setup(netdev, queue->sock->sk, &req->ddp); + if (ret) { + sg_free_table_chained(&req->ddp.sg_table, SG_CHUNK_SIZE); + return ret; + } + + /* if successful, sg table is freed in nvme_tcp_teardown_ddp() */ + req->offloaded = true; + return 0; +} + static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; @@ -445,6 +504,12 @@ static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags) #else +static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, + struct request *rq) +{ + return -EOPNOTSUPP; +} + static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) {} @@ -723,6 +788,26 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); } +static void nvme_tcp_complete_request(struct request *rq, + __le16 status, + union nvme_result result, + __u16 command_id) +{ +#ifdef CONFIG_ULP_DDP + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + if (req->offloaded) { + req->ddp_status = status; + req->result = result; + nvme_tcp_teardown_ddp(req->queue, rq); + return; + } +#endif + + if (!nvme_try_complete_req(rq, status, result)) + nvme_complete_rq(rq); +} + static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, struct nvme_completion *cqe) { @@ -742,10 +827,9 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, if (req->status == cpu_to_le16(NVME_SC_SUCCESS)) req->status = cqe->status; - if (!nvme_try_complete_req(rq, req->status, cqe->result)) - nvme_complete_rq(rq); + nvme_tcp_complete_request(rq, req->status, cqe->result, + cqe->command_id); queue->nr_cqe++; - return 0; } @@ -943,10 +1027,13 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb, static inline void nvme_tcp_end_request(struct request *rq, u16 status) { + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + struct nvme_tcp_queue *queue = req->queue; + struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu; union nvme_result res = {}; - if (!nvme_try_complete_req(rq, cpu_to_le16(status << 1), res)) - nvme_complete_rq(rq); + nvme_tcp_complete_request(rq, cpu_to_le16(status << 1), res, + pdu->command_id); } static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb, @@ -1253,6 +1340,14 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req) else msg.msg_flags |= MSG_EOR; + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags)) { + ret = nvme_tcp_setup_ddp(queue, blk_mq_rq_from_pdu(req)); + WARN_ONCE(ret, "ddp setup failed (queue 0x%x, cid 0x%x, ret=%d)", + nvme_tcp_queue_id(queue), + pdu->cmd.common.command_id, + ret); + } + if (queue->hdr_digest && !req->offset) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); @@ -2703,6 +2798,9 @@ static blk_status_t nvme_tcp_setup_cmd_pdu(struct nvme_ns *ns, if (ret) return ret; +#ifdef CONFIG_ULP_DDP + req->offloaded = false; +#endif req->state = NVME_TCP_SEND_CMD_PDU; req->status = cpu_to_le16(NVME_SC_SUCCESS); req->offset = 0; From patchwork Tue Aug 22 15:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361040 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 E6CAA1D2F4 for ; Tue, 22 Aug 2023 15:05:42 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17C719A for ; Tue, 22 Aug 2023 08:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AGFVgBu3D++eMEWE0bgQMoueMPul5W+ZUhfSZx5m05rCesfMw0jaN3ozH0KLSjnIL/jyK/8rTf01pfWBsqqhAOP4nhNXNvk8UD3vGSEiASwrTnO8VTcU74PFZlY2SMupK0SmVriCDePphkpCbZBnDTbrQYVVI9Gc+f8gGQjy1hS06vqi+VmyAzy0PDIv2FNHsSq8W1ejz3W/L0jxXpikp1oU10v/sQslWqIqyJcVaptIuq0z4zG53VDt4tgVX7u+KWiea5vJuEYAFuSs/B0REq/ARx0nG9v5nNc2/yHYQHGtItWLyhbpyqMFSkiw1R1cNhWbKjxI+khAQ1RvZdgt5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UmH3EyI/4LPkkap2U1z1YTQe7M2TWEk8INdMPSeeHWw=; b=T2yj+2ON8RQe1iRooSCWfpdqWFIA2frRUCIwpeVoqjOWp18itWF9tluN8zcYrFWJJVpnSTziHXPrbwW2KY6lFjA5D3rQYbsaVxFTzgY1NZuZASzWe+Os2D3r8GNgKcAN1MSBgMkWkLiuedjD0fSRC7WM1ncmhWNvI02txkIlc9QzvOlmAat0IqE6dK/Jy4gNAvYocLO0Pv4h7isO/+LeaHEz+cQxeXDAx8KWWJnyFHdlQSSPt/cU9xmq11catsNNVYCYT1OsbcMkYTDzMCByC7UfApyXYyqNdRfl//phB5Fheh9vUYCm6wSlxMwfrtz1hki1C4r8GhY/SsY5ZYmExw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UmH3EyI/4LPkkap2U1z1YTQe7M2TWEk8INdMPSeeHWw=; b=oyMuijwCx70Q5Xbe9Uwz/bTT19C4L8/LEIZVv5B3d0TV/ZsoYcRT0KCVXNMQ2fgtI7LalqO6mBpDq0L0PYooTzS5MduM3YbeQ8y8xfMCsT0L2G5xRrka4TLjjb8FEWQP/P3K/6mPyb9s5qA07q8aV0mIUcUqPefMS/rPaBXTsM1ueQYmK9o8FlAZdyccCSHJTryZInQY1zW1KZ9Hau2hp8YvYEs/g1zVOe+PKXCVV+0zMcTeVFQygamaKVxulgJeUerx1dIWUyipsBRAnV0dDpmYpEIcgleHuGeXBYylNaWsUlzRzV9szaPsuqMvl8IyawE6Nv4za7An+A7sFYZYKg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:39 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:39 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Yoray Zack , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 09/24] nvme-tcp: RX DDGST offload Date: Tue, 22 Aug 2023 15:04:10 +0000 Message-Id: <20230822150425.3390-10-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0194.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::18) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: b4970125-32e3-4bc5-1528-08dba3213f09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mUciKg+G9/y/AIgcyKIEYTOqhlFp5rG9KfbpH6O4KDQUY5235JSEpTwi1Rd3XqGrm1PjJLCntG7FK3t7Y5lg4BNxU2qGhBUjMZqPQDi2x0j4qcuxehgO8kEJT07ANEtmiLYNZCQVBXGHw5yOQdBURDtRRdK/vdnzx2Xtvfe9wnqzoUEDH/RHy5EPrBvS+2ms0w57beLaI6ft7+TMbypWKBgfX5koKTkCCz88N0KxI8mTZEhLeJtrMBvDKqipvCw71/QLmVHczPc1j0aNMaPIib5PhJZv62W+ZCAtLtLDJs60d5gougsM3bozZ4ucbQ/gjcOEHXG0k3AnjdXJzNI0bllGvfoRmz0ypYQfGkzUmN28UjarLRkW1XMLE6VGqcAwIGD8+vkxQOuvwf23b+6AGN81zmPx/unj5B4cx5sjx8MzG/b9o3LAMnDfAZa5dtMe01crk/ekP0AytWRSJgzJP4NEc7iKpWRot9Q6q7k3I0yOimigk32sVIFJHZM1mDhnQe2KPgb6Sakj+mqakukoq3kTl/dE2KOupsoNtujcj11uNjiMA1oJAU1c5LfY7RCk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QrUmjDjjkOKSM6+9BfF/wYcTRaN2jnA8vNtu0O+PDOR1eSnucnSaeh8V7bRgqY5Gn8GSATs0FwXtgpxa29n1EwewOpPja94EZbo1RqDQdigYROC1ll+0qOYyZfpEhekQ15cP0afI9yZHQQAsoCDB5CDtc4MexJVGWxZ/KD6CQX67gI/cySfwPKIjygLMfOr/GIWL8qneMgzZIKVGp69kuOuzWQQ9HsfjjivIjiDOhJC0/WZ9hQtOtk1ORaJvJCMxwSL2In8uSGhEG/1WqbnbxCc14YQHCU1hBcqlxYRO7ZsXFQ8c2qFkp/MD9VVZKg6CVLjUz8QxtTmG4S2BQD83FfPzZdPRR+h1r4Ry0IoQUR1+MpFmzRU5HwSY7mXFzEalsM967BbH7ZB7NkxxghsXThmccMU+hchhDOsrzK8s7HIayO6pYccpczAbI7xkMkaYV7JmWv7XLK09GWLPRh51oqhzMsb2HL9n6/j/WGdkQvYGnRWQZ1ywUI8xzBn4bpMYyf5LVzq3/Y8v0bA+kPivgu/YxjoZ/lbnRfICEWkUyZ73EMhMGVbm281IaoNOMsYCz8+H7GALX0Kl/3e78mJ7q6G0+FvFz1ADzbai1U8tqRZqzbYNsZ/CrLVNAEp/If3kS0HcbEJLtd5Q2TebYq860OtUBiFw1vTQ9uHp1Uyi7SwDXDXmu5jwdXiUAB/BhHT662czrSpQpwZgB8/E+IpVbse3WRD2MEvWLopSG6ECXiypO6qTPDLxWdvGfxMjRZEZuFn4koARyd5ZC6KEBRpXtFkqzojfMnudRNFgE0HKL581hMN9dyCgdXX/k53WB+QFTv/bouF8MHoER2xXuVv+Q0EhpjY6ZJWkKAehioo7GN7y+GXgdlVkgfeuzWdICRhS+3xLyoe0TFvhclsYjxb0mAq5/h+r+qr8aFZgY8lK+KTmajdsiOpu/20kOPEqJpBKmzAOE5yBIHMztdFzrYnkqtg6ekbcnRGs1/wLsZlesc34IpZdarXk7K/FmFqek29AsLua4ooQPzfB/YnTCG75QFMA90i+Xb52rpBrJoER1SbRfzesHjB906AgzaRC1OAxjyxS4F0PD6I1fULR+jdiQRmYmqIA/KBhTKgymrD8PoIenPNKftv1P2UoWeoUYxdWN9SlEmLBjXrZ9QKVf2lA9C7ZK1YJMgP0RzMkq+z9Q6XbGz8eTtzkqvPnPNe9qTGMn1Uh8K6W7jy1ZOcIUFuN0ZWegCAGlHp4ovEGedIHzeQUkWDB464GWvmG0pIbm1+f8D0IeeL2j7ofODS0pUHi53lsKQMnuu70sdw4GkusPHR81LbNReC4xEM5Qnu94MPCbLVbuMWVelcYU5HjbSPFssVCE4/zIHgclLroceQgeICSv6dMV8/E5WdeltgSV4eShN7MLM03T0g3No68B49DyQqabso0+Kf4mX60CaCdIlrZhgsQ8927XyDj0R9eROpUCtrnIgNxuvCcez/4czng1bzesoG++iOo6v8byGaTINFYyFbWXFX5GHmmA2P3EGvHY10tSR6uFBTRAy8KW6PD9PCYGtkqrGgXy/G1I4eS4tmxSlwIQz5KEKCXrYXcVy5m X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4970125-32e3-4bc5-1528-08dba3213f09 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:39.1352 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AvlSKO4YsknTTx7rSuEUgdBr6ZFfyvnMQ2recADxP1YRpKPUW81ZL+FGnTsb5fXdSdm5RNPXpKDemZ6E/ODXCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Yoray Zack Enable rx side of DDGST offload when supported. At the end of the capsule, check if all the skb bits are on, and if not recalculate the DDGST in SW and check it. Signed-off-by: Yoray Zack Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/tcp.c | 84 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 63e64494e257..9253cc826571 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -141,6 +141,7 @@ enum nvme_tcp_queue_flags { NVME_TCP_Q_LIVE = 1, NVME_TCP_Q_POLLING = 2, NVME_TCP_Q_OFF_DDP = 3, + NVME_TCP_Q_OFF_DDGST_RX = 4, }; enum nvme_tcp_recv_state { @@ -178,6 +179,7 @@ struct nvme_tcp_queue { * is pending (ULP_DDP_RESYNC_PENDING). */ atomic64_t resync_req; + bool ddp_ddgst_valid; #endif /* send state */ @@ -343,6 +345,33 @@ static bool nvme_tcp_ddp_query_limits(struct nvme_tcp_ctrl *ctrl) ctrl->ctrl.opts->tls); } +static inline bool nvme_tcp_ddp_ddgst_ok(struct nvme_tcp_queue *queue) +{ + return queue->ddp_ddgst_valid; +} + +static inline void nvme_tcp_ddp_ddgst_update(struct nvme_tcp_queue *queue, + struct sk_buff *skb) +{ + if (queue->ddp_ddgst_valid) + queue->ddp_ddgst_valid = skb_is_ulp_crc(skb); +} + +static void nvme_tcp_ddp_ddgst_recalc(struct ahash_request *hash, + struct request *rq, + __le32 *ddgst) +{ + struct nvme_tcp_request *req; + + if (!rq) + return; + + req = blk_mq_rq_to_pdu(rq); + ahash_request_set_crypt(hash, req->ddp.sg_table.sgl, (u8 *)ddgst, + req->data_len); + crypto_ahash_digest(hash); +} + static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags); static void nvme_tcp_ddp_teardown_done(void *ddp_ctx); static const struct ulp_ddp_ulp_ops nvme_tcp_ddp_ulp_ops = { @@ -403,6 +432,8 @@ static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; + bool offload_ddgst_rx = test_bit(ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + queue->ctrl->ddp_netdev->ulp_ddp_caps.active); int ret; config.nvmeotcp.pfv = NVME_TCP_PFV_1_0; @@ -423,6 +454,8 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) return ret; set_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + if (queue->data_digest && offload_ddgst_rx) + set_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags); return 0; } @@ -430,6 +463,7 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) { clear_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + clear_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags); ulp_ddp_sk_del(queue->ctrl->ddp_netdev, queue->sock->sk); } @@ -510,6 +544,20 @@ static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, return -EOPNOTSUPP; } +static inline bool nvme_tcp_ddp_ddgst_ok(struct nvme_tcp_queue *queue) +{ + return false; +} + +static inline void nvme_tcp_ddp_ddgst_update(struct nvme_tcp_queue *queue, + struct sk_buff *skb) +{} + +static void nvme_tcp_ddp_ddgst_recalc(struct ahash_request *hash, + struct request *rq, + __le32 *ddgst) +{} + static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) {} @@ -777,6 +825,9 @@ static void nvme_tcp_init_recv_ctx(struct nvme_tcp_queue *queue) queue->pdu_offset = 0; queue->data_remaining = -1; queue->ddgst_remaining = 0; +#ifdef CONFIG_ULP_DDP + queue->ddp_ddgst_valid = true; +#endif } static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) @@ -1044,6 +1095,10 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb, nvme_cid_to_rq(nvme_tcp_tagset(queue), pdu->command_id); struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + if (queue->data_digest && + test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) + nvme_tcp_ddp_ddgst_update(queue, skb); + while (true) { int recv_len, ret; @@ -1072,7 +1127,8 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb, recv_len = min_t(size_t, recv_len, iov_iter_count(&req->iter)); - if (queue->data_digest) + if (queue->data_digest && + !test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) ret = skb_copy_and_hash_datagram_iter(skb, *offset, &req->iter, recv_len, queue->rcv_hash); else @@ -1114,8 +1170,11 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue, char *ddgst = (char *)&queue->recv_ddgst; size_t recv_len = min_t(size_t, *len, queue->ddgst_remaining); off_t off = NVME_TCP_DIGEST_LENGTH - queue->ddgst_remaining; + struct request *rq; int ret; + if (test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) + nvme_tcp_ddp_ddgst_update(queue, skb); ret = skb_copy_bits(skb, *offset, &ddgst[off], recv_len); if (unlikely(ret)) return ret; @@ -1126,9 +1185,25 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue, if (queue->ddgst_remaining) return 0; + rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), + pdu->command_id); + + if (test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) { + /* + * If HW successfully offloaded the digest + * verification, we can skip it + */ + if (nvme_tcp_ddp_ddgst_ok(queue)) + goto out; + /* + * Otherwise we have to recalculate and verify the + * digest with the software-fallback + */ + nvme_tcp_ddp_ddgst_recalc(queue->rcv_hash, rq, + &queue->exp_ddgst); + } + if (queue->recv_ddgst != queue->exp_ddgst) { - struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), - pdu->command_id); struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); req->status = cpu_to_le16(NVME_SC_DATA_XFER_ERROR); @@ -1139,9 +1214,8 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue, le32_to_cpu(queue->exp_ddgst)); } +out: if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) { - struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), - pdu->command_id); struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); nvme_tcp_end_request(rq, le16_to_cpu(req->status)); From patchwork Tue Aug 22 15:04:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361041 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 6A10C79D0 for ; Tue, 22 Aug 2023 15:05:49 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12CA2CC6 for ; Tue, 22 Aug 2023 08:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OWQ5+vlYjyQIFkYAE+xqib9AiqUX+JpzhkyrN34L9mmmy0pRc8K/4nWMcGz2AfjnNSe+kudrRYQFgUcgncSa0DXa//oq8mBtrQYze3DS809duT8/BqKryKWDsRi7uPkDI4Gqbab0QxSAa1bgU1S5NzNAgVvBBLibdqaPqCxAXw94L7561GWFv+jYeGtkYOYh/rC6GubL3gOOFg96Jtwitoh8Re8/cyKcH5ZwTcHG6PbbCFPIzu0Bz/2/MgibzQLkwmf9JKnz/Z2zgpkmVM5eBcTZo0neyxNkOMvJxXdJJapnFnKCf5RuQe42aNyObq5jsY9hKXavveD6h69MtulFzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+YAVYYrNOzV3VJ/1kyMjLXjkap5AgYG/HNPB/prT8Ik=; b=lqFvZkFG+RWJs9BRW96+M6sZHw6lS+X/Zw/VYGLkHJUmFUnoIri/7k6AiZlwYtoFbZCSCOkqhRstKrnWsppAcJTFBclMAKRXMJmumAgXEeiaEoHD8cvQnEXGpRmayv2YLjax+Ep6zfhRGWBEmCJEZorki2pPux+/I4WlkF27/HKO5lPhy0YfTtIXQRkUxaKjC5m1tux/zi/zbjsp1CYbuMVv4kDlLXzUTfJSYTlEl/M4eyiJbtY2Dazl1Ymcum6DF9l1kpCkHrhO34KfO3L/fXCpy7DyndcSvUtZcwYirFUnSEtQ/oy4TgAVlDyPnnGgPsA8+sFVAJAe5mYn/uDF+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+YAVYYrNOzV3VJ/1kyMjLXjkap5AgYG/HNPB/prT8Ik=; b=Ju8khgWZAgkAvhKxuYK5AGVI43Fmrj5MA49asr6C2T5X088wcT6fx1nrm1rQP4rg/r2AqqmaNciZ0oQaFojluo/jolnZgRoL4lkVlJaharh21grEOwkTvN2q+a7ILB1OEIN/LI/GKw8p2Uw2uzVhst/tRrxhaHKisqEC2LmqESHbdbRzIpondtaDFhc5Nn06YJpYl9DaO9lf79hbjP1gtmkmc9Mh1KPxpXnycdJ4T4kXvO5R9VSdzQkQb46a0i3KQ3ze06PtzFaa4J3hVPZGqcnuhaoJYYFCKMt+Q3ze/Bo9pYHAHcoBUDh53y8oY14l1BXBzA3uz4hxfh1/b522Sw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:45 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:44 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Or Gerlitz , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 10/24] nvme-tcp: Deal with netdevice DOWN events Date: Tue, 22 Aug 2023 15:04:11 +0000 Message-Id: <20230822150425.3390-11-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0078.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::19) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 295e75f8-d1ff-4512-75a8-08dba321425e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gnl9VRBY47XKRq08uTSa14MhV4VbMjRM2z/50+5KH2aLk84b+66WI1M5TGbP6GzCnZYvZCJRhET9XWqBadTLITvSUCTVQp3xh1kLiqwxWr4W/1l3M3V6HG7GKVXMwdAMgmFwo3sYEB1N0SmVdwwVehaPVxCcGN7jXL9f8ux5NgWiUFoeQ1kz+MPIOuLvJ6WmZcvD1Sh6lxX+YpjlVovoK7NfTDAOHOX1U5NXMfDWtRTr0vUh6yTGxSLhY4fXX05dESmVw/9NTNY3XmAhMiXBMcjPXGyFh1vxbOxcx4vzAgdR5nf0MCF5laLIcVY+2SdXtXN2yJ9fNUHQNZd7jdiykmicXep8bRhmD5P3Hrd57QuzhY28XJiIYf20pV9GBa02Dg40r6eqTcXat1eVrmmI6bSZqRddu7p6CjBMUn6qjDaVnHuFOobaJ+gqYL9Hl/+E3NUTXtoOzUujMwFAkVvkJr+llf4Mde6egCxtYJfdLtshoQVfpFFvP3JFTseWH7PR6GVZ0CNNlRaqXEZ6UjE8f6qGok6nzNDs8L/uHyxGPGunQLb97iLgW58nyrYKlwvE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B5+bfqRehSuqbOtiVc54qxkLsi4V3I1/1JOAn5dHIz+OwBoboLEo8aqyLGiI9YrXQb208g3N6vfvT9hQg60Z+JpQ9sV0ox4Q645vcDLZobK+AhDYJwBTvk5hoEVDCjN1AtPxFGW7yB/norOMsh5ZG18CfAOJa6S/vmTL4jiaHGPteFVjGCtMlHW+BelXZx4fhzmJgRd7VHlUqBDIv+nx9X9ayDf2uZANVw9TY8atC5dvMggnwA0nig/tjzbUP99hENNl4y5OjfONX0N3kRMkTpXtcBTNmLvuLXV7WmvxoFv5xOCYHoQmZ3Vr0cbG+IMHuVjGp6x5T0NFEmeZ1zPeVvrOW/w0BDSHvmEWScUCJBoMkG0SwzduQB4CX5x9y0VtclakI8mFrxi9PNd9R55DtlMqv43sp30/LFpUl9KxGETzDEJl5N8JPjPbXl83CAGKu6qM+GnhqiwyEyRhqfOI/5pmyhVNGy01Bz67qh7tahXMpT/yz/7cw8S2VFrMNDC1Oye3eGtUn8f+qLJXhJ5DWn5jVurdbOY/xRPFAzDN6JR+TdqK3IFWKH1AIqFYTRggfZ+tfgpWr9ZiQqLcVbLAY+O6IrICI2Yac3utxHnLwUU1fcJ/MXeMSA8XFgJ+RlWbQ35c73uz5WWAT40OFs4QybWohj6K9EdLoN5CgqD22o/d2z/HfcMrNNTWO6c2hiWd1aKHYZjeMarSiS8+3q3GKbNJ6a/mhOyWwsrtH1u9AYxoL1y1Z9iTcrY5gaO3ub6kQ5e6RBLGd178HjfT9B7tlhxDdgVUE9oyVSu3mUdb46dUBft5OO2JFvh6khCMuDyEXfigf1WMOmiamBWfbOfS7wpxZ1+IiiQpLdcV5W2uH/jSdxxHZzaLw9T9KCCcvh7K1V0/Cz6Wg31F450sbyRiS8QTpqCdLg7K8VcWaapYaIWpTpzMeR38myDflQu0Qf30ydzmwLDVtNdHha8RrMK2UzTER7Yi2DaPPgwdjMqjVkT0Pp0VFMdKQvd3wLkADlaWOzXznRZYyRjF1N8MHSensOAIYczNIIERA3YHYDHsDNjNkY6Hgyd1pcPuNzIvh+0yNwhv0zuCH1ySFEFxaiCIdP56KKDleQiAfoOr/g4wfFzBQ9WSyH/czL4HMQ+vno/uPpm5XJJnrBGxq604git48qyMYKIFhMVljhwq1S5Qs3p4sfZ5X0xECMDi1kbbNIkRp3KAtNQwlUXrObOJZ8IraX33+fuVGwtdByyDEacFJIUiL9pyCeIlitKrxTLgngCoazl/846jKVZxp9C1BW+QDXS3GIxDEg+q3JvndmUW6B9M605pNBS/n5Rox9TqtuACtMt9ImbrkUijYFOvGMsvh6IxCWOaNEtbavtFBhMMdgT/zTn6v6Y+WaIPS/UU0tpsBzYWZhm24LT3tO+u0hFDZ6f0Eo0Qnc/iaHgzx5DXOzvGwfVetbUv4eBwr5lqsSze259QK+P9Sxe7+uh1HQMzQi7CGKY9f5SzKlteKpcizLlumFa5lrAwMnbLL41wI9/fpgvlyhGXS/2GdyRDklnD57WEzQj05mQBXWwPlJJXt8OePE1PgcD6BUleAgKfVYeE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 295e75f8-d1ff-4512-75a8-08dba321425e X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:44.8508 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yNcORiQMtA3ZBNUe1zqwB5TBLU74WJkIgcDLaK1B179tOHSvXftsh1cfkQhnAneea3SQBZS0aWx6PoRxkhlvjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Or Gerlitz For ddp setup/teardown and resync, the offloading logic uses HW resources at the NIC driver such as SQ and CQ. These resources are destroyed when the netdevice does down and hence we must stop using them before the NIC driver destroys them. Use netdevice notifier for that matter -- offloaded connections are stopped before the stack continues to call the NIC driver close ndo. We use the existing recovery flow which has the advantage of resuming the offload once the connection is re-set. This also buys us proper handling for the UNREGISTER event b/c our offloading starts in the UP state, and down is always there between up to unregister. Signed-off-by: Or Gerlitz Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg --- drivers/nvme/host/tcp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 9253cc826571..b187cd36e016 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -234,6 +234,7 @@ struct nvme_tcp_ctrl { static LIST_HEAD(nvme_tcp_ctrl_list); static DEFINE_MUTEX(nvme_tcp_ctrl_mutex); +static struct notifier_block nvme_tcp_netdevice_nb; static struct workqueue_struct *nvme_tcp_wq; static const struct blk_mq_ops nvme_tcp_mq_ops; static const struct blk_mq_ops nvme_tcp_admin_mq_ops; @@ -3155,6 +3156,32 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, return ERR_PTR(ret); } +static int nvme_tcp_netdev_event(struct notifier_block *this, + unsigned long event, void *ptr) +{ +#ifdef CONFIG_ULP_DDP + struct net_device *ndev = netdev_notifier_info_to_dev(ptr); + struct nvme_tcp_ctrl *ctrl; + + switch (event) { + case NETDEV_GOING_DOWN: + mutex_lock(&nvme_tcp_ctrl_mutex); + list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) { + if (ndev == ctrl->ddp_netdev) + nvme_tcp_error_recovery(&ctrl->ctrl); + } + mutex_unlock(&nvme_tcp_ctrl_mutex); + flush_workqueue(nvme_reset_wq); + /* + * The associated controllers teardown has completed, + * ddp contexts were also torn down so we should be + * safe to continue... + */ + } +#endif + return NOTIFY_DONE; +} + static struct nvmf_transport_ops nvme_tcp_transport = { .name = "tcp", .module = THIS_MODULE, @@ -3170,6 +3197,8 @@ static struct nvmf_transport_ops nvme_tcp_transport = { static int __init nvme_tcp_init_module(void) { + int ret; + BUILD_BUG_ON(sizeof(struct nvme_tcp_hdr) != 8); BUILD_BUG_ON(sizeof(struct nvme_tcp_cmd_pdu) != 72); BUILD_BUG_ON(sizeof(struct nvme_tcp_data_pdu) != 24); @@ -3184,8 +3213,19 @@ static int __init nvme_tcp_init_module(void) if (!nvme_tcp_wq) return -ENOMEM; + nvme_tcp_netdevice_nb.notifier_call = nvme_tcp_netdev_event; + ret = register_netdevice_notifier(&nvme_tcp_netdevice_nb); + if (ret) { + pr_err("failed to register netdev notifier\n"); + goto out_free_workqueue; + } + nvmf_register_transport(&nvme_tcp_transport); return 0; + +out_free_workqueue: + destroy_workqueue(nvme_tcp_wq); + return ret; } static void __exit nvme_tcp_cleanup_module(void) @@ -3193,6 +3233,7 @@ static void __exit nvme_tcp_cleanup_module(void) struct nvme_tcp_ctrl *ctrl; nvmf_unregister_transport(&nvme_tcp_transport); + unregister_netdevice_notifier(&nvme_tcp_netdevice_nb); mutex_lock(&nvme_tcp_ctrl_mutex); list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) From patchwork Tue Aug 22 15:04:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361042 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 0DFF01D2F9 for ; Tue, 22 Aug 2023 15:05:54 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2056.outbound.protection.outlook.com [40.107.93.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9128126 for ; Tue, 22 Aug 2023 08:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IhSSoq9p/Se87RjdDusCeAe7vzxzgKRVMIwJ0vEw7D4ciKQpLucqKtxyI/5Pt81F6LFu+k0lJb2qP3I3iypUQx4FfiBgjb3JAbc1ynwobeVRPSTIOg9g6c1F7+UPfUhHMMre+4z2NWCBwSjTE5t1fQtaeSUPGp6PMqyNUN5rM2wJ3gowzxhxfE8TSbQ/Yd9A7u2hrmO77ywr8TfDP+CIm5UBIFwzShjP0kvjnXbP1G3eM1p8odowETC7OmYXF9XAo4zch01uOEUG5wbtCT1+cP6yy3USBk33nbHvEce0UvXWvDUbBD5feobo77rXmINXxL19gsIYcujswAV7nDznag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LIk4/kSU3AdgLdh8dvZL/ASo4e0lhtJA7/xrF3ip2Jw=; b=Wk3QQ1wwnmn3wCxiBbw9DWUr5RAGvtDFPTeBV0LupmFDuNZqbzFVbaoqeoCJrqlLG1JTfyfRlcrQuisWUa8DfxmLbozbFf9Kxs2Y9ZsbDua+4HUphSqxxBKTwTBeET5/AALXaHmfMUlb/wUoOnOd3zpSZHKwiRKx+O6Mg3xgMmMt+Az5vKE6x1L6wQrtgZLZ6YrS08Sduc3gqt7Zoi2b3FDaVxX3WEtmgOQsJ69IvJv8Higf4EJQ5S+W4mXpP/id/blevH7anhjQM4rcASgypP+rSqYyfxWxM+aw5SrNk5zir1sjROufiDKvQLp+tTg/CqnKRv3qxOfDF6iyC1lNLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LIk4/kSU3AdgLdh8dvZL/ASo4e0lhtJA7/xrF3ip2Jw=; b=uja6EBddHYlvbLReXKJLjN959Aw9YdvLslTbl+uKlZ2+vxpN7StjsZAHyzwKeLvyzM9hOBw+Fe7WNNUQzpuRYLK+mV4r2ILCuwNOdC0lJc3DsJoZhpUm+NgtqMB0M5m+otbRR7Yg54ylgTUUi9PHRnlk1YcqLobbOiZOu8rL0O83XWJYjTfobx6cbv4JCypH/+9wGnCw2YCqbRHl+FpGTUovn+SNR6bCq+lPCBvWVeZmo9unf4FHTgvfxdACPKdrXbiSA481jW/JRmzeXy54LXMolDQ9M7Mpx4hVY9YPx3Q8xCe24qSu1TeBME20jJ5fiVVWCOIWCYOjGiiNM7ndtA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7378.namprd12.prod.outlook.com (2603:10b6:510:20d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:50 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:50 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Yoray Zack , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 11/24] Documentation: add ULP DDP offload documentation Date: Tue, 22 Aug 2023 15:04:12 +0000 Message-Id: <20230822150425.3390-12-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0096.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::8) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7378:EE_ X-MS-Office365-Filtering-Correlation-Id: 04d46e20-248b-40a5-a082-08dba321457a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qT8GPIPeFW2H/zsTogVT9hrHMMDs1YRF6oaXeedrYg2qrRQbPfnQhfL2FMTaJRCAj3NV4cLW6R77Ev5fqJpiQLhINOQNPkMJn7GuvKs4pqTsODa6HldezYLdrv0Uiuxr79DDgJxjj//WzCB4TchtEtoMDULEzuiUkix+GPohq1yk7WqMzGCFSaGhfR6tTH++RgxeQyQ+RR4x3QSpKFYiyOg15yBd5g9DUtXbVJyCKvttUDEe3nX/qRTQGatwU/CzIyA1DYRENzQTom2XjP3XqBHPGvi3CnD/66uCFxVz4QYNtbCwnsBjXBLJI+WDwew2CwylxR217rtJi8Ua4i3pLJ+LP/QIaXrouMjw5wSADMtEqItRTk1SGUjxoO3iLctz0zRrng0soOSxOjY7cRAA/mZPL00sWT1gfGK5A5rRTnKBFxAWL0saeLwUex96DOqXpBE7sjTJatk6gDib86FE31AkIdS5JHFleK4pLQ5AgvXMIwv/XaO5zldZA/fC9zXq5PagJQAOxDR5By2SmsOeaOFA12MqhNd+CFAXFFB+3kd3muIlnkk1W8arx3lbmgpe X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199024)(186009)(1800799009)(2906002)(30864003)(83380400001)(7416002)(6506007)(6486002)(38100700002)(5660300002)(26005)(86362001)(8676002)(8936002)(2616005)(4326008)(107886003)(316002)(6512007)(66556008)(66476007)(478600001)(66946007)(6666004)(41300700001)(36756003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jgTiIhX9dnMcvIjpJ6JHYmrFKOvrlKskrRYBQK6doKCts+8h7yV0SknOQ42XGEvG2MzQpyNsPV3wVsQIlcSq0j5fEiDGU99hU4wfZE6xwkt+vgAraYB4rWWHRey9Dq6Dq6hbR8MIfTNHS0+p1SANccQE9ZFFMOpBl3Eg2BgRMundxgEYgk0IBrXKfeg6zovRKL32sEJK6vGaanlMx7SN3Bh1FZl0+HkE6Y336OPRQTId4BlqGWGSm6SfC7Dwei48PrMxE7b0hxpnlfzcLBfp5TEHCPtwyBn/hlpuxHi2qj7mf5H5a0vc8rrnf5DG2Ofl8CZMcWe5mcqDNoRsZN50rDKdoYQe9CIlFnOQgbZLsAeQf1eKCR42RUA/zkM157uEJNsot95dwT9ow50ikX9FLlnlAARjt6agxLjf7Tz2wAO1KrL8F3mKnSMMHw49SHkUZIz2UcuI5T9bqdytca2eh59ldkJykkxx+++tsOt/wLPOqV+6QJrCuzftoh2qCEGtwtSr33ZQBs+/h/E+tYGZFq0tDbqK4li79kIprCsuD4y4RymkW1zfMOVF+rFzmfFrGBVqZ+ksJFz4ECQesUGtu7Uk69Vqfx08HyPP+oDF0CezgsEY2ODaW4AHtlQesZi23qpHfAfMNJWRpLEZ/gP/X9bsg7GMHlisaEik5xB233qg/PuMLFzIgeH4vLrW4dQDeXvNtaODgc1AmUuzq+sjBBKMZB56swrkgNmcaBUp1ET7xzSfwQfBNbh9NabJG3Fu9xzAvY1kKH34ZDNmFInRVz05/PatQ+RWBv01Q/Oyl7P+8t4WHZ3gUGZt34etcE3kCARi8t9cO61fWoGXO4PBS+a6ap+0JDPJBDe019dt+/hhI0IOdBrWWenB7P02AtGyBxg8i+asl9uxd3XQjoaO81GI3GVrpPTv29xQBGQadpdL22ORCh0kcb8Ceuapiu43Uj5E2h1BufmR7C7bv9ghpSW4wh5THeNTAB33IFlRK8fJAIhsvXlIkdhyRPWLsE/topRwu+MslHUBx3QrafTu3DgE24Cna231f3ud0A8twjLcXmHITTG84/OxXAS01/H0DSqGzjI6A4a+wrbm89q7olFq5tHivhGRnjsGNwauTyw5Bq25KZEwVhkC7wj+CaBbtWxEa4wp9lksYS+TZrK9nEL+Svp3ti1PXmJTbDvabHMoITAO7fcNeZVLGeaVbHykJtA3TJCXqUMDMCVl/ME0uzhgexyrWlo94trH2a0sPWF+NumyVp5iGtGrEdaB6nF2QonNkCAQc/z7KaYQlcCCRAUBU1w5sOxsRN+kTG77ezwfCSiu5RlDWIAB8phaSKzisyFa2ZE2N0/xmNqGsbFlp+BPAOqms/WA0KAHyKWs0rCT3vWsPRzaJrT1s8RAO/MayjkVIaPWUAJwt1n1iqnHh0n6o2eFNzAzrYcR6rpq5UMOKQvcplGqFwC/6jM3xvRwQ8dIhXe2VITOBwc9+zyE5/ZhiRueGSb2DaA30R7hQnLt2ATWEOGaEn78g7KdHx3TGQ4TtQh6aOIV+stufwsrk2obytJqgBq6ndMlP/FsjDCqMo7W2m5lG7S6w+BJ6tiQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04d46e20-248b-40a5-a082-08dba321457a X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:49.9480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5y/zYMvXVNU4dhvY97C4ZntCWrgWmjur8G00L54bT/P7THK+iIwpbt4FaLy5cpMouZ7vwJdyc3mSl7zGZ7vjFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7378 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yoray Zack Document the new ULP DDP API and add it under "networking". Use NVMe-TCP implementation as an example. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- Documentation/networking/index.rst | 1 + Documentation/networking/ulp-ddp-offload.rst | 378 +++++++++++++++++++ 2 files changed, 379 insertions(+) create mode 100644 Documentation/networking/ulp-ddp-offload.rst diff --git a/Documentation/networking/index.rst b/Documentation/networking/index.rst index 5b75c3f7a137..856e4b837b67 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst @@ -108,6 +108,7 @@ Contents: tc-actions-env-rules tc-queue-filters tcp-thin + ulp-ddp-offload team timestamping tipc diff --git a/Documentation/networking/ulp-ddp-offload.rst b/Documentation/networking/ulp-ddp-offload.rst new file mode 100644 index 000000000000..c996e9f48af5 --- /dev/null +++ b/Documentation/networking/ulp-ddp-offload.rst @@ -0,0 +1,378 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +================================= +ULP direct data placement offload +================================= + +Overview +======== + +The Linux kernel ULP direct data placement (DDP) offload infrastructure +provides tagged request-response protocols, such as NVMe-TCP, the ability to +place response data directly in pre-registered buffers according to header +tags. DDP is particularly useful for data-intensive pipelined protocols whose +responses may be reordered. + +For example, in NVMe-TCP numerous read requests are sent together and each +request is tagged using the PDU header CID field. Receiving servers process +requests as fast as possible and sometimes responses for smaller requests +bypasses responses to larger requests, e.g., 4KB reads bypass 1GB reads. +Thereafter, clients correlate responses to requests using PDU header CID tags. +The processing of each response requires copying data from SKBs to read +request destination buffers; The offload avoids this copy. The offload is +oblivious to destination buffers which can reside either in userspace +(O_DIRECT) or in kernel pagecache. + +Request TCP byte-stream: + +.. parsed-literal:: + + +---------------+-------+---------------+-------+---------------+-------+ + | PDU hdr CID=1 | Req 1 | PDU hdr CID=2 | Req 2 | PDU hdr CID=3 | Req 3 | + +---------------+-------+---------------+-------+---------------+-------+ + +Response TCP byte-stream: + +.. parsed-literal:: + + +---------------+--------+---------------+--------+---------------+--------+ + | PDU hdr CID=2 | Resp 2 | PDU hdr CID=3 | Resp 3 | PDU hdr CID=1 | Resp 1 | + +---------------+--------+---------------+--------+---------------+--------+ + +The driver builds SKB page fragments that point to destination buffers. +Consequently, SKBs represent the original data on the wire, which enables +*transparent* inter-operation with the network stack. To avoid copies between +SKBs and destination buffers, the layer-5 protocol (L5P) will check +``if (src == dst)`` for SKB page fragments, success indicates that data is +already placed there by NIC hardware and copy should be skipped. + +In addition, L5P might have DDGST which ensures data integrity over +the network. If not offloaded, ULP DDP might not be efficient as L5P +will need to go over the data and calculate it by itself, cancelling +out the benefits of the DDP copy skip. ULP DDP has support for Rx/Tx +DDGST offload. On the received side the NIC will verify DDGST for +received PDUs and update SKB->ulp_ddp and SKB->ulp_crc bits. If all the SKBs +making up a L5P PDU have crc on, L5P will skip on calculating and +verifying the DDGST for the corresponding PDU. On the Tx side, the NIC +will be responsible for calculating and filling the DDGST fields in +the sent PDUs. + +Offloading does require NIC hardware to track L5P protocol framing, similarly +to RX TLS offload (see Documentation/networking/tls-offload.rst). NIC hardware +will parse PDU headers, extract fields such as operation type, length, tag +identifier, etc. and only offload segments that correspond to tags registered +with the NIC, see the :ref:`buf_reg` section. + +Device configuration +==================== + +During driver initialization the driver sets the following +:c:type:`struct net_device ` properties: + +* The ULP DDP capabilities it supports + in :c:type:`struct ulp_ddp_netdev_caps ` +* The ULP DDP operations pointer in :c:type:`struct ulp_ddp_dev_ops `. + +The current list of capabilities is represented as a bitset: + +.. code-block:: c + + enum { + ULP_DDP_C_NVME_TCP_BIT, + ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + /* add capabilities above */ + ULP_DDP_C_COUNT, + }; + +The enablement of capabilities can be controlled from userspace via +netlink. See Documentation/networking/ethtool-netlink.rst for more +details. + +Later, after the L5P completes its handshake, the L5P queries the +driver for its runtime limitations via the :c:member:`limits` operation: + +.. code-block:: c + + int (*limits)(struct net_device *netdev, + struct ulp_ddp_limits *lim); + + +All L5P share a common set of limits and parameters (:c:type:`struct ulp_ddp_limits `): + +.. code-block:: c + + /** + * struct ulp_ddp_limits - Generic ulp ddp limits: tcp ddp + * protocol limits. + * Add new instances of ulp_ddp_limits in the union below (nvme-tcp, etc.). + * + * @type: type of this limits struct + * @max_ddp_sgl_len: maximum sgl size supported (zero means no limit) + * @io_threshold: minimum payload size required to offload + * @tls: support for ULP over TLS + * @nvmeotcp: NVMe-TCP specific limits + */ + struct ulp_ddp_limits { + enum ulp_ddp_type type; + int max_ddp_sgl_len; + int io_threshold; + bool tls:1; + union { + /* ... protocol-specific limits ... */ + struct nvme_tcp_ddp_limits nvmeotcp; + }; + }; + +But each L5P can also add protocol-specific limits e.g.: + +.. code-block:: c + + /** + * struct nvme_tcp_ddp_limits - nvme tcp driver limitations + * + * @full_ccid_range: true if the driver supports the full CID range + */ + struct nvme_tcp_ddp_limits { + bool full_ccid_range; + }; + +Once the L5P has made sure the device is supported the offload +operations are installed on the socket. + +If offload installation fails, then the connection is handled by software as if +offload was not attempted. + +To request offload for a socket `sk`, the L5P calls :c:member:`sk_add`: + +.. code-block:: c + + int (*sk_add)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config); + +The function return 0 for success. In case of failure, L5P software should +fallback to normal non-offloaded operations. The `config` parameter indicates +the L5P type and any metadata relevant for that protocol. For example, in +NVMe-TCP the following config is used: + +.. code-block:: c + + /** + * struct nvme_tcp_ddp_config - nvme tcp ddp configuration for an IO queue + * + * @pfv: pdu version (e.g., NVME_TCP_PFV_1_0) + * @cpda: controller pdu data alignment (dwords, 0's based) + * @dgst: digest types enabled. + * The netdev will offload crc if L5P data digest is supported. + * @queue_size: number of nvme-tcp IO queue elements + * @queue_id: queue identifier + * @cpu_io: cpu core running the IO thread for this queue + */ + struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; + int io_cpu; + }; + +When offload is not needed anymore, e.g. when the socket is being released, the L5P +calls :c:member:`sk_del` to release device contexts: + +.. code-block:: c + + void (*sk_del)(struct net_device *netdev, + struct sock *sk); + +Normal operation +================ + +At the very least, the device maintains the following state for each connection: + + * 5-tuple + * expected TCP sequence number + * mapping between tags and corresponding buffers + * current offset within PDU, PDU length, current PDU tag + +NICs should not assume any correlation between PDUs and TCP packets. +If TCP packets arrive in-order, offload will place PDU payloads +directly inside corresponding registered buffers. NIC offload should +not delay packets. If offload is not possible, than the packet is +passed as-is to software. To perform offload on incoming packets +without buffering packets in the NIC, the NIC stores some inter-packet +state, such as partial PDU headers. + +RX data-path +------------ + +After the device validates TCP checksums, it can perform DDP offload. The +packet is steered to the DDP offload context according to the 5-tuple. +Thereafter, the expected TCP sequence number is checked against the packet +TCP sequence number. If there is a match, offload is performed: the PDU payload +is DMA written to the corresponding destination buffer according to the PDU header +tag. The data should be DMAed only once, and the NIC receive ring will only +store the remaining TCP and PDU headers. + +We remark that a single TCP packet may have numerous PDUs embedded inside. NICs +can choose to offload one or more of these PDUs according to various +trade-offs. Possibly, offloading such small PDUs is of little value, and it is +better to leave it to software. + +Upon receiving a DDP offloaded packet, the driver reconstructs the original SKB +using page frags, while pointing to the destination buffers whenever possible. +This method enables seamless integration with the network stack, which can +inspect and modify packet fields transparently to the offload. + +.. _buf_reg: + +Destination buffer registration +------------------------------- + +To register the mapping between tags and destination buffers for a socket +`sk`, the L5P calls :c:member:`setup` of :c:type:`struct ulp_ddp_ops +`: + +.. code-block:: c + + int (*setup)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io); + + +The `io` provides the buffer via scatter-gather list (`sg_table`) and +corresponding tag (`command_id`): + +.. code-block:: c + + /** + * struct ulp_ddp_io - tcp ddp configuration for an IO request. + * + * @command_id: identifier on the wire associated with these buffers + * @nents: number of entries in the sg_table + * @sg_table: describing the buffers for this IO request + * @first_sgl: first SGL in sg_table + */ + struct ulp_ddp_io { + u32 command_id; + int nents; + struct sg_table sg_table; + struct scatterlist first_sgl[SG_CHUNK_SIZE]; + }; + +After the buffers have been consumed by the L5P, to release the NIC mapping of +buffers the L5P calls :c:member:`teardown` of :c:type:`struct +ulp_ddp_ops `: + +.. code-block:: c + + void (*teardown)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io, + void *ddp_ctx); + +`teardown` receives the same `io` context and an additional opaque +`ddp_ctx` that is used for asynchronous teardown, see the :ref:`async_release` +section. + +.. _async_release: + +Asynchronous teardown +--------------------- + +To teardown the association between tags and buffers and allow tag reuse NIC HW +is called by the NIC driver during `teardown`. This operation may be +performed either synchronously or asynchronously. In asynchronous teardown, +`teardown` returns immediately without unmapping NIC HW buffers. Later, +when the unmapping completes by NIC HW, the NIC driver will call up to L5P +using :c:member:`ddp_teardown_done` of :c:type:`struct ulp_ddp_ulp_ops `: + +.. code-block:: c + + void (*ddp_teardown_done)(void *ddp_ctx); + +The `ddp_ctx` parameter passed in `ddp_teardown_done` is the same on provided +in `teardown` and it is used to carry some context about the buffers +and tags that are released. + +Resync handling +=============== + +RX +-- +In presence of packet drops or network packet reordering, the device may lose +synchronization between the TCP stream and the L5P framing, and require a +resync with the kernel's TCP stack. When the device is out of sync, no offload +takes place, and packets are passed as-is to software. Resync is very similar +to TLS offload (see documentation at Documentation/networking/tls-offload.rst) + +If only packets with L5P data are lost or reordered, then resynchronization may +be avoided by NIC HW that keeps tracking PDU headers. If, however, PDU headers +are reordered, then resynchronization is necessary. + +To resynchronize hardware during traffic, we use a handshake between hardware +and software. The NIC HW searches for a sequence of bytes that identifies L5P +headers (i.e., magic pattern). For example, in NVMe-TCP, the PDU operation +type can be used for this purpose. Using the PDU header length field, the NIC +HW will continue to find and match magic patterns in subsequent PDU headers. If +the pattern is missing in an expected position, then searching for the pattern +starts anew. + +The NIC will not resume offload when the magic pattern is first identified. +Instead, it will request L5P software to confirm that indeed this is a PDU +header. To request confirmation the NIC driver calls up to L5P using +:c:member:`resync_request` of :c:type:`struct ulp_ddp_ulp_ops `: + +.. code-block:: c + + bool (*resync_request)(struct sock *sk, u32 seq, u32 flags); + +The `seq` parameter contains the TCP sequence of the last byte in the PDU header. +The `flags` parameter contains a flag (`ULP_DDP_RESYNC_PENDING`) indicating whether +a request is pending or not. +L5P software will respond to this request after observing the packet containing +TCP sequence `seq` in-order. If the PDU header is indeed there, then L5P +software calls the NIC driver using the :c:member:`resync` function of +the :c:type:`struct ulp_ddp_dev_ops ` inside the :c:type:`struct +net_device ` while passing the same `seq` to confirm it is a PDU +header. + +.. code-block:: c + + void (*resync)(struct net_device *netdev, + struct sock *sk, u32 seq); + +Statistics +========== + +Per L5P protocol, the NIC driver must report statistics for the above +netdevice operations and packets processed by offload. +These statistics are per-device and can be retrieved from userspace +via netlink (see Documentation/networking/ethtool-netlink.rst). + +For example, NVMe-TCP offload reports: + + * ``rx_nvmeotcp_sk_add`` - number of NVMe-TCP Rx offload contexts created. + * ``rx_nvmeotcp_sk_add_fail`` - number of NVMe-TCP Rx offload context creation + failures. + * ``rx_nvmeotcp_sk_del`` - number of NVMe-TCP Rx offload contexts destroyed. + * ``rx_nvmeotcp_ddp_setup`` - number of DDP buffers mapped. + * ``rx_nvmeotcp_ddp_setup_fail`` - number of DDP buffers mapping that failed. + * ``rx_nvmeotcp_ddp_teardown`` - number of DDP buffers unmapped. + * ``rx_nvmeotcp_drop`` - number of packets dropped in the driver due to fatal + errors. + * ``rx_nvmeotcp_resync`` - number of packets with resync requests. + * ``rx_nvmeotcp_packets`` - number of packets that used offload. + * ``rx_nvmeotcp_bytes`` - number of bytes placed in DDP buffers. + +NIC requirements +================ + +NIC hardware should meet the following requirements to provide this offload: + + * Offload must never buffer TCP packets. + * Offload must never modify TCP packet headers. + * Offload must never reorder TCP packets within a flow. + * Offload must never drop TCP packets. + * Offload must not depend on any TCP fields beyond the + 5-tuple and TCP sequence number. From patchwork Tue Aug 22 15:04:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361043 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 91AF91FD0 for ; Tue, 22 Aug 2023 15:06:00 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B641B9 for ; Tue, 22 Aug 2023 08:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DaiVHCYGNPEPRzKKnlers5sTB0eOt6ycXdnMCKGh2BWSd1LD78fV56V7r6u8Rs6Trj/lXvjO+pSBijPZia3aiJQxX7zgFJXOblUMz1hMcmTmZG45/LF6NuPLgJEw/XdjzSPHn7sMr1K6awwPaXKUmZdSaXG2g1xjxJ9JzzhPS0b8adh7/RtuV4hrMexYUD6kzQc1ZE1Pjb6/TpM46r+LVQKe6FnMMc/vzlmg4YFPeU+d90VGPNAsVZl8zxuj0zUjatzqdUFj1/vHlolCvT5btZbqxc8rhbbZjwC28xnpUjizKjaJz6LJuK0ogR5Rf7ebwRaCeqn9rfOtEGB2ER7PNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ueKbFETACmqZqOFsj99AxnBVLHwH+1yPYPx4ZQ9duFI=; b=ef3ev3kJq16fGOa/OmW3hWSojDj5G6JvxdggjyinOi2JOd0p4BzkA6o9VUHYQ5c7DYsuLY1Q6uWI6JGev1uDT8I8uM/a2vUEi1Qwl4zxFuPiG5vLS9bs3+xWb/7ncz2vM/pDpmSLngHdHxEOoDDWu0p4zQhxYFcnoIUx6hF3R9gewEetEueCyOexHFLJrDmTah8gKNh3lcKdZsyXNr1O3amkFhsUTJSIwt/FTyyFecdR+5nfdccPEK6M6lEZmv7mvHjRfj589E1Q8UsdtrqQdQ+DRz4WyUdE+7F4WT4p3Y7nMQR5txI4Rq4762Kd3xb18ap1w/vjAxU3fTkRfAgRCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ueKbFETACmqZqOFsj99AxnBVLHwH+1yPYPx4ZQ9duFI=; b=Z+1WODYEg5VvscAl3zV+hxQrMbY55/k9d4U7qYRQz8f7WcAJZwKTc3hoDIMNdvjIjpqxGNxyOYH0hm2py+/0oxjuJKPGKg4kVXVHBXgZhgEgX4rw1YGOWt/QiAY5IAM/cfyRMSJlvHE+AgwyctodL1u9j5S5XtMHb6cd0jfGVf6lk3SGsTo9vZCG0wYSE6gOC/wfGJsmN/zuIuLQ/sY18fYOzC7oizrBKfKTXuULdSnMQxhAe7HSwnb78yUKJYEb/uo1WcGyh5lblrFq6cIyWu5fnc2My6F9oxVK4e7k69T68+GmvVsUYBYSj6UJ3WsFj5uYU2jXFQSrElOevX71UA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:05:56 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:05:56 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Or Gerlitz , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 12/24] net/mlx5e: Rename from tls to transport static params Date: Tue, 22 Aug 2023 15:04:13 +0000 Message-Id: <20230822150425.3390-13-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0152.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b3::7) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: 1db8a5d2-dbb8-4179-4ba5-08dba32148fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9mXWICBFtqyJuFTz2R6wCAFaVbhLVT5+3lJCnnuFLJ/qHxepjhbfkdBMU9bQuQdtEZz3XawHmkwXpNnl1xe++D3mp5jsOm++64ujr0eePJmi3y4/rQJ6j8kjv5Nkv5/LhdKaIoh9Wmb7mZ0donjzDNXJJxiOiEEPfwDpcK+5V4qiyBSON43u1nx6WfHgcLjC7E9CYpN9JxCT603sUqub8uUOiwNZ2wxf0r44D4X0mTjc4HZlZjM3eZWpWRJV0oJzBVLcGC5uweTigB1NLo+NWps0l8ONCc3j6yTAcpfEvFX5+BtC6/KZ/ie2Ejw8PVDZJ0fowk9F1L0RXeDrZTMaHXjbU5DKPJzcFBBZj/LQuuFzHA++4yI5NCajlTLz1S2mYT13IaZNhSnjSSjwHWvt8oiFE1Mwr1Iwp5D4ZPN+VOsjIakmAroQp1NhUCL5S+MwEYp/2q/zpMfAFphHkpiP5oJGW6vp8BaFUcvKtUItFYHac64QPXeI7xrpTmCHVXqDQxS6ab17basZmO331Nqitg/6xF7kVC2ZzhD7VhYX2h0nErvCIqQ3Z8P7492sIG6z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(30864003)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3KTWhQ5JdMIWIrXdUYfy7vMPWVy1GcT47YNyvD0BZRrqVAZYq3UQa8RR7JdO39j7kh31Ipq8PKVd0l1Ob18PJGrZqiRJwkmtmvzRJ1DbekLae5OF5Tra28iX1hRnW5l1TvAPa4Ely5nnKOrwc0+ATs/4DfM6bAwmm6IFzwYA+QtlAi1jva9APB34qmKcRFtCao+dAWmi+C2A2T+yAp4BuyWYoT7m435oZQguwAhuKbTH/htxytWhry/Ra3gmG0Bkd8UC2qIiBEXTZGU5Y9HWHyzyHPxIcb/z8+OEUvA7c2BCwjmfgBawRjMtS6RUnonuwKrbS8U2/Bfrto6jrtuzcI0iDpO8qNAjFKRhxkBKGDoVuJzOjMQadUQxr+fkGcAoIvNI9qYinP1Bt6TFhXV0AlCbVmh32I0x8WZRtJAh1EzDUmAxESdPaXTxyWl3Ks1bqUhVWJVMONuMBUV9FWgOGz4ddnwm1fNfFIVLoaFbaEhzpcWbqnuK+h4eqL3d5S4Ob/gWCSHeh6+gp7mv0AOKD/oSmC+U6RsSYA6NkOzVN4Uak2MfrSLn5Eq5ALeHzwM6IhDaDXLs8ZrtqzlEqMvO4mJuZM7EB+6xUnnKHY95s/DO85am9Znelmbrhnc9hzf1Vk0vIKNLrxZMezrVZiPxK89zhXSLHtAWZ69ffno21lrjlBDlFKn0gbQT9+cRsBA2CvglGb+c4j/9EDIKXTwL443QXsE3b3nLtEyHnU6+jBZCu+LKzf4uu5gOxyrPNCFzclHOTU/cTl3QWFX0R5XaPKEG//fCrAbVYJkbB4cRJHElQvCmVKZLYwF9MEJWDfzDM1uDUHWvHTAGODP3nFOhmHRsOJEJP9+Uw5qXC7WzPf2DLVip+nyy6nJdJMv00Hm30IRoEsUjCqviK/BeOq5iFRzFHIf4BHtekB3Y3bz+rrVEkK+1NF3BVoDrLU9QIfZK1oQ5k7io2LwkDGa8NkYx+NeVg7aN7AdLroLIus893fvQj5prrVTfBv10Uyp0S4qUlq7DxEFybwr34DqBdC0hNpsiN6z71x9g9vJFus0p3NiJWliUJCvzquw50jGSs7ikLKhvyB2MbTl3TGx2jr72lMfEftl+0mExJKMsreh3ZSXmb6zlpUbtpB7Wy4ilyjtplN/02PHBQhBrqjt4sHrWmkMGCq4aatvsAy3axpBLoziNTxDRZdmylu4cRuh8+2ZySUZq6txJpL0pUi4GyJljNAh0tOFZOOmOmOaF0jn26BcivXr27Ai7Piau17WyZ/veEJyNNv52mXdFHgHS2Y7XXilLqlMzvCM3KnZYaOWUNixnSAxN5FikOowzgh/5BRl3rhrpDVNKxW535RVWXlLlliPUGXd0MltxTcZmON4FA6IHPG8+PTxnQl9BgF7yZ5ST9j5up9VXXLJacbM2PfR4FcXdg/jCLumOJ6zYRu9LF9SymrSqfBly9rHlBBAxJm8LDVRx7NQw1um2FeNB9OyZPRMcN8IMRx4hk5Nmxyv+r6GMWJQGnfpPszmu+icg/ShWIVdDgkwgEULu7LH8mPYrAvky6EgZbrW6er7W3FxWBCkRAzbgSMjtUqJEFwwheMEm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1db8a5d2-dbb8-4179-4ba5-08dba32148fd X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:05:55.9417 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uzIveX3rjcL0bUBcfafkMfOSKsGjPPB4L25v+7EUTfMum8dzWQi+k51nFgP3Maz4kE2sB3TBoLJKyZo0U4zUYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz The static params structure is used in TLS but also in other transports we're offloading like nvmeotcp: - Rename the relevant structures/fields - Create common file for appropriate transports - Apply changes in the TLS code No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Ben Ben-Ishay Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../mlx5/core/en_accel/common_utils.h | 32 +++++++++++++++++ .../mellanox/mlx5/core/en_accel/ktls.c | 2 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 6 ++-- .../mellanox/mlx5/core/en_accel/ktls_tx.c | 8 ++--- .../mellanox/mlx5/core/en_accel/ktls_txrx.c | 36 ++++++++----------- .../mellanox/mlx5/core/en_accel/ktls_utils.h | 17 ++------- include/linux/mlx5/device.h | 8 ++--- include/linux/mlx5/mlx5_ifc.h | 8 +++-- 8 files changed, 67 insertions(+), 50 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/common_utils.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/common_utils.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/common_utils.h new file mode 100644 index 000000000000..efdf48125848 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/common_utils.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ +#ifndef __MLX5E_COMMON_UTILS_H__ +#define __MLX5E_COMMON_UTILS_H__ + +#include "en.h" + +struct mlx5e_set_transport_static_params_wqe { + struct mlx5_wqe_ctrl_seg ctrl; + struct mlx5_wqe_umr_ctrl_seg uctrl; + struct mlx5_mkey_seg mkc; + struct mlx5_wqe_transport_static_params_seg params; +}; + +/* macros for transport_static_params handling */ +#define MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS \ + (DIV_ROUND_UP(sizeof(struct mlx5e_set_transport_static_params_wqe), MLX5_SEND_WQE_BB)) + +#define MLX5E_TRANSPORT_FETCH_SET_STATIC_PARAMS_WQE(sq, pi) \ + ((struct mlx5e_set_transport_static_params_wqe *)\ + mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_set_transport_static_params_wqe))) + +#define MLX5E_TRANSPORT_STATIC_PARAMS_WQE_SZ \ + (sizeof(struct mlx5e_set_transport_static_params_wqe)) + +#define MLX5E_TRANSPORT_STATIC_PARAMS_DS_CNT \ + (DIV_ROUND_UP(MLX5E_TRANSPORT_STATIC_PARAMS_WQE_SZ, MLX5_SEND_WQE_DS)) + +#define MLX5E_TRANSPORT_STATIC_PARAMS_OCTWORD_SIZE \ + (MLX5_ST_SZ_BYTES(transport_static_params) / MLX5_SEND_WQE_DS) + +#endif /* __MLX5E_COMMON_UTILS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c index 984fa04bd331..bab9b0c59491 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c @@ -100,7 +100,7 @@ bool mlx5e_is_ktls_rx(struct mlx5_core_dev *mdev) return false; /* Check the possibility to post the required ICOSQ WQEs. */ - if (WARN_ON_ONCE(max_sq_wqebbs < MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS)) + if (WARN_ON_ONCE(max_sq_wqebbs < MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS)) return false; if (WARN_ON_ONCE(max_sq_wqebbs < MLX5E_TLS_SET_PROGRESS_PARAMS_WQEBBS)) return false; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index 9b597cb24598..20994773056c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -136,16 +136,16 @@ static struct mlx5_wqe_ctrl_seg * post_static_params(struct mlx5e_icosq *sq, struct mlx5e_ktls_offload_context_rx *priv_rx) { - struct mlx5e_set_tls_static_params_wqe *wqe; + struct mlx5e_set_transport_static_params_wqe *wqe; struct mlx5e_icosq_wqe_info wi; u16 pi, num_wqebbs; - num_wqebbs = MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS; + num_wqebbs = MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS; if (unlikely(!mlx5e_icosq_can_post_wqe(sq, num_wqebbs))) return ERR_PTR(-ENOSPC); pi = mlx5e_icosq_get_next_pi(sq, num_wqebbs); - wqe = MLX5E_TLS_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); + wqe = MLX5E_TRANSPORT_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); mlx5e_ktls_build_static_params(wqe, sq->pc, sq->sqn, &priv_rx->crypto_info, mlx5e_tir_get_tirn(&priv_rx->tir), mlx5_crypto_dek_get_id(priv_rx->dek), diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c index d61be26a4df1..0691995470e2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c @@ -33,7 +33,7 @@ u16 mlx5e_ktls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *pa num_dumps = mlx5e_ktls_dumps_num_wqes(params, MAX_SKB_FRAGS, TLS_MAX_PAYLOAD_SIZE); - stop_room += mlx5e_stop_room_for_wqe(mdev, MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS); + stop_room += mlx5e_stop_room_for_wqe(mdev, MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS); stop_room += mlx5e_stop_room_for_wqe(mdev, MLX5E_TLS_SET_PROGRESS_PARAMS_WQEBBS); stop_room += num_dumps * mlx5e_stop_room_for_wqe(mdev, MLX5E_KTLS_DUMP_WQEBBS); stop_room += 1; /* fence nop */ @@ -550,12 +550,12 @@ post_static_params(struct mlx5e_txqsq *sq, struct mlx5e_ktls_offload_context_tx *priv_tx, bool fence) { - struct mlx5e_set_tls_static_params_wqe *wqe; + struct mlx5e_set_transport_static_params_wqe *wqe; u16 pi, num_wqebbs; - num_wqebbs = MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS; + num_wqebbs = MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS; pi = mlx5e_txqsq_get_next_pi(sq, num_wqebbs); - wqe = MLX5E_TLS_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); + wqe = MLX5E_TRANSPORT_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); mlx5e_ktls_build_static_params(wqe, sq->pc, sq->sqn, &priv_tx->crypto_info, priv_tx->tisn, mlx5_crypto_dek_get_id(priv_tx->dek), diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.c index 570a912dd6fa..8abea6fe6cd9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.c @@ -8,10 +8,6 @@ enum { MLX5E_STATIC_PARAMS_CONTEXT_TLS_1_2 = 0x2, }; -enum { - MLX5E_ENCRYPTION_STANDARD_TLS = 0x1, -}; - #define EXTRACT_INFO_FIELDS do { \ salt = info->salt; \ rec_seq = info->rec_seq; \ @@ -20,7 +16,7 @@ enum { } while (0) static void -fill_static_params(struct mlx5_wqe_tls_static_params_seg *params, +fill_static_params(struct mlx5_wqe_transport_static_params_seg *params, union mlx5e_crypto_info *crypto_info, u32 key_id, u32 resync_tcp_sn) { @@ -53,25 +49,25 @@ fill_static_params(struct mlx5_wqe_tls_static_params_seg *params, return; } - gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv); - initial_rn = MLX5_ADDR_OF(tls_static_params, ctx, initial_record_number); + gcm_iv = MLX5_ADDR_OF(transport_static_params, ctx, gcm_iv); + initial_rn = MLX5_ADDR_OF(transport_static_params, ctx, initial_record_number); memcpy(gcm_iv, salt, salt_sz); memcpy(initial_rn, rec_seq, rec_seq_sz); tls_version = MLX5E_STATIC_PARAMS_CONTEXT_TLS_1_2; - MLX5_SET(tls_static_params, ctx, tls_version, tls_version); - MLX5_SET(tls_static_params, ctx, const_1, 1); - MLX5_SET(tls_static_params, ctx, const_2, 2); - MLX5_SET(tls_static_params, ctx, encryption_standard, - MLX5E_ENCRYPTION_STANDARD_TLS); - MLX5_SET(tls_static_params, ctx, resync_tcp_sn, resync_tcp_sn); - MLX5_SET(tls_static_params, ctx, dek_index, key_id); + MLX5_SET(transport_static_params, ctx, tls_version, tls_version); + MLX5_SET(transport_static_params, ctx, const_1, 1); + MLX5_SET(transport_static_params, ctx, const_2, 2); + MLX5_SET(transport_static_params, ctx, acc_type, + MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_TLS); + MLX5_SET(transport_static_params, ctx, resync_tcp_sn, resync_tcp_sn); + MLX5_SET(transport_static_params, ctx, dek_index, key_id); } void -mlx5e_ktls_build_static_params(struct mlx5e_set_tls_static_params_wqe *wqe, +mlx5e_ktls_build_static_params(struct mlx5e_set_transport_static_params_wqe *wqe, u16 pc, u32 sqn, union mlx5e_crypto_info *crypto_info, u32 tis_tir_num, u32 key_id, u32 resync_tcp_sn, @@ -80,19 +76,17 @@ mlx5e_ktls_build_static_params(struct mlx5e_set_tls_static_params_wqe *wqe, struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl; struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; u8 opmod = direction == TLS_OFFLOAD_CTX_DIR_TX ? - MLX5_OPC_MOD_TLS_TIS_STATIC_PARAMS : - MLX5_OPC_MOD_TLS_TIR_STATIC_PARAMS; - -#define STATIC_PARAMS_DS_CNT DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS) + MLX5_OPC_MOD_TRANSPORT_TIS_STATIC_PARAMS : + MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS; cseg->opmod_idx_opcode = cpu_to_be32((pc << 8) | MLX5_OPCODE_UMR | (opmod << 24)); cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | - STATIC_PARAMS_DS_CNT); + MLX5E_TRANSPORT_STATIC_PARAMS_DS_CNT); cseg->fm_ce_se = fence ? MLX5_FENCE_MODE_INITIATOR_SMALL : 0; cseg->tis_tir_num = cpu_to_be32(tis_tir_num << 8); ucseg->flags = MLX5_UMR_INLINE; - ucseg->bsf_octowords = cpu_to_be16(MLX5_ST_SZ_BYTES(tls_static_params) / 16); + ucseg->bsf_octowords = cpu_to_be16(MLX5E_TRANSPORT_STATIC_PARAMS_OCTWORD_SIZE); fill_static_params(&wqe->params, crypto_info, key_id, resync_tcp_sn); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_utils.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_utils.h index 3d79cd379890..5e2d186778aa 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_utils.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_utils.h @@ -6,6 +6,7 @@ #include #include "en.h" +#include "en_accel/common_utils.h" enum { MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0, @@ -33,13 +34,6 @@ union mlx5e_crypto_info { struct tls12_crypto_info_aes_gcm_256 crypto_info_256; }; -struct mlx5e_set_tls_static_params_wqe { - struct mlx5_wqe_ctrl_seg ctrl; - struct mlx5_wqe_umr_ctrl_seg uctrl; - struct mlx5_mkey_seg mkc; - struct mlx5_wqe_tls_static_params_seg params; -}; - struct mlx5e_set_tls_progress_params_wqe { struct mlx5_wqe_ctrl_seg ctrl; struct mlx5_wqe_tls_progress_params_seg params; @@ -50,19 +44,12 @@ struct mlx5e_get_tls_progress_params_wqe { struct mlx5_seg_get_psv psv; }; -#define MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS \ - (DIV_ROUND_UP(sizeof(struct mlx5e_set_tls_static_params_wqe), MLX5_SEND_WQE_BB)) - #define MLX5E_TLS_SET_PROGRESS_PARAMS_WQEBBS \ (DIV_ROUND_UP(sizeof(struct mlx5e_set_tls_progress_params_wqe), MLX5_SEND_WQE_BB)) #define MLX5E_KTLS_GET_PROGRESS_WQEBBS \ (DIV_ROUND_UP(sizeof(struct mlx5e_get_tls_progress_params_wqe), MLX5_SEND_WQE_BB)) -#define MLX5E_TLS_FETCH_SET_STATIC_PARAMS_WQE(sq, pi) \ - ((struct mlx5e_set_tls_static_params_wqe *)\ - mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_set_tls_static_params_wqe))) - #define MLX5E_TLS_FETCH_SET_PROGRESS_PARAMS_WQE(sq, pi) \ ((struct mlx5e_set_tls_progress_params_wqe *)\ mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_set_tls_progress_params_wqe))) @@ -76,7 +63,7 @@ struct mlx5e_get_tls_progress_params_wqe { mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_dump_wqe))) void -mlx5e_ktls_build_static_params(struct mlx5e_set_tls_static_params_wqe *wqe, +mlx5e_ktls_build_static_params(struct mlx5e_set_transport_static_params_wqe *wqe, u16 pc, u32 sqn, union mlx5e_crypto_info *crypto_info, u32 tis_tir_num, u32 key_id, u32 resync_tcp_sn, diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 93399802ba77..3b1d15abc8d7 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -449,8 +449,8 @@ enum { }; enum { - MLX5_OPC_MOD_TLS_TIS_STATIC_PARAMS = 0x1, - MLX5_OPC_MOD_TLS_TIR_STATIC_PARAMS = 0x2, + MLX5_OPC_MOD_TRANSPORT_TIS_STATIC_PARAMS = 0x1, + MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS = 0x2, }; enum { @@ -458,8 +458,8 @@ enum { MLX5_OPC_MOD_TLS_TIR_PROGRESS_PARAMS = 0x2, }; -struct mlx5_wqe_tls_static_params_seg { - u8 ctx[MLX5_ST_SZ_BYTES(tls_static_params)]; +struct mlx5_wqe_transport_static_params_seg { + u8 ctx[MLX5_ST_SZ_BYTES(transport_static_params)]; }; struct mlx5_wqe_tls_progress_params_seg { diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index 08dcb1f43be7..d44b0795470a 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -12287,12 +12287,16 @@ enum { MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_PURPOSE_MACSEC = 0x4, }; -struct mlx5_ifc_tls_static_params_bits { +enum { + MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_TLS = 0x1, +}; + +struct mlx5_ifc_transport_static_params_bits { u8 const_2[0x2]; u8 tls_version[0x4]; u8 const_1[0x2]; u8 reserved_at_8[0x14]; - u8 encryption_standard[0x4]; + u8 acc_type[0x4]; u8 reserved_at_20[0x20]; From patchwork Tue Aug 22 15:04:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361044 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 9C4AF1D2ED for ; Tue, 22 Aug 2023 15:06:07 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 089DB198 for ; Tue, 22 Aug 2023 08:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Py7Il2wkNDbDMFkl+RaHdBMTbm9gHGb3O+WQUwRe4IMl4MOWtR802FXIYl1AA6n+C6R/dAPi7CI/8gx00KKXzuuLEzDaSRErMihdfXML1IZLFVAnUHoJbVGDLjdjakkauywoI2gNm2/RqosJOl7l4xb/3wrjeTjK3paiSNUn9NPKMjlIBWI4EUSPYNK5MWWCSE4hHQpK9qnF/hlDci8Su5X1EI6WrkGQDPUjLPAGb+lkPX7P2WIPBIrddAg0uveAQEXkGSVCiGpRVDnoqk2mzSRFYFCffTC4DXPmA1+lQAq+U2GJVQM53JvhRKsx6S/1KAqBgUo3x788Xk6z3L4spw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8wRssR8HT5wW2oyWYRZhFlB+vgZDclYP5nc+tF/bd7A=; b=N8ZiDZTMpa29R2fqVF2emTYnGWjQoU4m0UZLZ8BrEqPjdqn3EHgqtqV8t0vNby4vUcXyPnbsL+VoiJfs65XunyA34X3pL1RlLYf3UfEwgVllXNDEPwGvnrsUsJlKL5sNWclu+sGRfZ4yUTdcONrBPU3cSPZgrS7F1qFzmL7uD7IPCaWjhVjuXW2jP5Xw4x4dvSTkoGXYZWuVxVmCzOxjT36cd0fjn5QnYCNumxZKOatP6R4o6xmlllDBgMbhI8xxZNs9iFw6RHjPurclSzWfaDlpqyBm3hx8djitVDODaMIOQ1YQ+kxJNI4tiqusQPpzZPJPN/MvBO0gFkTtP7oqIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8wRssR8HT5wW2oyWYRZhFlB+vgZDclYP5nc+tF/bd7A=; b=sPqiR+CYOCSwL3uLqql9AHPGF6e6yjsVcMGJ/OGnhKw95oj/0bTqT1HsGmaJmGs6ay0o1JF9YCAveR5wezAGu6y8wrRjycgzj4JmX0EqOe1SuLCIECLKPQCi7GhPcgmAA6Rpetu7IOHSofsUId6QdbJpjGMBS6tZJsbJxmcFN4an3YekokVuN3TmCDaYR5Hm1Mni20Nd69hpzYivStfQrOeQUmO7bYuMA2ALL9LKJEN3AaRP2lgVWZ6p8EDOCcmkz88NYkGlrbUo5urvieR+iaLGVCQIcY9I0YLmTJ8NX5uSSSr+ILS73zo2IqLjuxpTzSCkL6L8EissNrIPf4NAAQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CH3PR12MB8233.namprd12.prod.outlook.com (2603:10b6:610:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:02 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:02 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Or Gerlitz , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 13/24] net/mlx5e: Refactor ico sq polling to get budget Date: Tue, 22 Aug 2023 15:04:14 +0000 Message-Id: <20230822150425.3390-14-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0187.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::17) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CH3PR12MB8233:EE_ X-MS-Office365-Filtering-Correlation-Id: 32e63fda-c10d-4992-d905-08dba3214ce8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N++SAvcxM//UK7yrPaK1mnuDexQmGVMOiDSDbEfwqjhBfw9Zy/XP1WR3jwX7P9f4USsBAKaeqU61OwbN8ZLvXsF6HuiVqiWbH6G2gNWKNp3tohD47QJV7Hv9njZv8HrYrHWwivUgSLIxLwwES/tfHZyt/jEA5ad3+GfVFQHp1eaizONJLNVd58yhZIpe4TMH5S1gG693+jQQQ2u+iFgUnHlMFn+7hHIk1PznzmVVM+59k4Wcw/p1PIREVWERTC8LWkZBjxHoeqjbh7QaflaVFlJzG7Dx98vHumUXywDvKihZen5JFH/WHZqIc9L9PjPcnOspPdTYHGmz/OeV36VqM1hCVWUlHHAaG/LLoGYIqXw4OxgLBco8MbDgyhxZHzfbBvIinbS34JdVr7cR28AtdbZfOJW7134W8kO8glnROFCSsNgUw/xCcaWGR19pIRV87uRNCTbG9Yt45PLgmHlEmpDJPIAlJRhuK/ImW8BprUOQCPsxhoQVpwdPDEQmbwsQr6qpf7G9OkrpbLzafGyvjZpxk60pzA4YLC01/nYHn63zPdJyclrlsX61CeeBCvhu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z2jEwvhpVKuGAB24Znfle1pr/XsM0oF5bbpcYvOy4G7CalLi/beKBkQPJJ8lOfW/rMZCrxeibRQwFtfpTXPoPTfcM2Sd8tYJ2XmhWEfmQ3S31iAYvmKqJ4WY+raWudWvHkAKtr+ZyUQcLdu4G0oAwQ88SCjB3XwPvIJA6Ztyys5k29VZYXwSrm1gvaLdMnCjrJol3rVt32JzF95cIadWwXzFCqkwCv0/rKt/z5LqdznMCXaPg291uLBmnv+H3feSWwPJbzRc2/iG8FnhySf4EO7eqCwqbbmI7Yj5PsN2MCHu3yVuxj+i7TemvHAw0TrWrzttc4LH+8SUsa83bWIyUSRwQU5wuaIYQqry6sAklWQZxPQk1a8VggAbMBL/rp7AuBDoOrTYid+lOZOzcQlafxnrbVAEKxHcUYkshK+cgq6z2wub30egho2itAbLwyvImbJ5juv4BPocCprFPeWsxzCJZfg5y8bXxsiqY0J07HH8BbDZxXHyYchHCNqWj+WGduSZVuvsQkpPGL0vhRKY1N+cTfHEg+lN/gtL1mShoKTXPIEHzm1TJDEhAWuO6L2KNwpFZw5RjIhhTYeuj6Z1Y1qJIPWaLPQAdQavyEIL0JX/4wmLovPyUr0J//XQWUgIkO+7mxPSFF6Mh+SPgTxFFa/oexDVHtVfU2Aojh1XHZDfp7TpOQJ/bZX/JrWoJoJY3VHxdRFmLLPUIvvIC6ZnyNXxQaxiHDjJFVwLn+RQRsdBEYe89FXxQRfqrFY/rmzjGvRQLrDOXyWLt5+bsjRPQrL4GSbUAKeoQOAwT7qS0S+osi7/D9yOsreKChwmXj30+AkV/Zs+mMwDoDcj5y0ZFMjcuZSsZWHZJzEREqoINIt3BBYmm7SR4Vcp/523E12B+fQaRIxIV9eBcQFuq8r5ixdDpi7swrgeviWkHiCjHLecXCSfQaUtCZOB+qnHuodycU/YCIG/aV70DADyCKQGvM1cKOsqcn3gNo1+GBPFsssuW3GTwGe+NbGB8qVsONjahys5W6HH8FGnJjmK3Ei3KEKzrL3t0FlBjkgTT9Sa31ACGiL+u8lqfWJFevRz3cnHAJeQekPTL9fy4UPWTE9ZSY5QB7qCxrE4Ik/8QKmE2REnuw0DQkVxtCDAChOrOO/tIPXxEI/I8mv3SrstVAt3em4oySKDnVYmBaDSGhQM2Cty+tv4shTAaDCtTmPSt+cILxYPmJMzWcr2UXpyhvSm2NObQ2KtyLdtJ8tdVuXlXkggQdSqz/RjPMDLzxEjdFp0KYY8m7v76YlFrdOvzfMpZQmctdwCiErs4Vu6yxy/G1KI7q9KMownGUwzB5+rAnOts8YKRX4NRJIsSYAPBliLaM1gEYz1zC55FxNXvIkCSP7x7iV39T5IaA0zi6NtT8QHKtxJXG2k9gG3P2G+oCRsr2ibYRxSQRfzXqn6fW5/BSn809ZDUQUDIZahi7TX1aBoNO+VVl/cphe12/nbyfOq14inyb+XDmsXjqKSy6FqqCGSh9xWD3LjntVleOjlJTE2yAt9h9PF9rOe7HOKVw9U77CLOxfSJvlQMZQvI0UDObdUe4WEqui1y44FESz2itfG X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32e63fda-c10d-4992-d905-08dba3214ce8 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:02.3726 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yUpEHAPsLqrEkr6vB0b1LCSNkIF3oYNXH4EBgAxytSKr66Ef5D7uPw/0/gFbd2HZYYKn7u7pIRXiSGSJ8iAs7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8233 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz The mlx5e driver uses ICO SQs for internal control operations which are not visible to the network stack, such as UMR mapping for striding RQ (MPWQ) and etc more cases. The upcoming nvmeotcp offload uses ico sq for umr mapping as part of the offload. As a pre-step for nvmeotcp ico sqs which have their own napi and need to comply with budget, add the budget as parameter to the polling of cqs related to ico sqs. The polling already stops after a limit is reached, so just have the caller to provide this limit as the budget. No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 879d698b6119..cdd7fbf218ae 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -62,7 +62,7 @@ void mlx5e_trigger_irq(struct mlx5e_icosq *sq); void mlx5e_completion_event(struct mlx5_core_cq *mcq, struct mlx5_eqe *eqe); void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event); int mlx5e_napi_poll(struct napi_struct *napi, int budget); -int mlx5e_poll_ico_cq(struct mlx5e_cq *cq); +int mlx5e_poll_ico_cq(struct mlx5e_cq *cq, int budget); /* RX */ INDIRECT_CALLABLE_DECLARE(bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 3fd11b0761e0..387eab498b8f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -976,7 +976,7 @@ static void mlx5e_handle_shampo_hd_umr(struct mlx5e_shampo_umr umr, shampo->ci = (shampo->ci + umr.len) & (shampo->hd_per_wq - 1); } -int mlx5e_poll_ico_cq(struct mlx5e_cq *cq) +int mlx5e_poll_ico_cq(struct mlx5e_cq *cq, int budget) { struct mlx5e_icosq *sq = container_of(cq, struct mlx5e_icosq, cq); struct mlx5_cqe64 *cqe; @@ -1051,7 +1051,7 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq) wi->wqe_type); } } while (!last_wqe); - } while ((++i < MLX5E_TX_CQ_POLL_BUDGET) && (cqe = mlx5_cqwq_get_cqe(&cq->wq))); + } while ((++i < budget) && (cqe = mlx5_cqwq_get_cqe(&cq->wq))); sq->cc = sqcc; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index a7d9b7cb4297..fd52311aada9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c @@ -178,8 +178,8 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= work_done == budget; - mlx5e_poll_ico_cq(&c->icosq.cq); - if (mlx5e_poll_ico_cq(&c->async_icosq.cq)) + mlx5e_poll_ico_cq(&c->icosq.cq, MLX5E_TX_CQ_POLL_BUDGET); + if (mlx5e_poll_ico_cq(&c->async_icosq.cq, MLX5E_TX_CQ_POLL_BUDGET)) /* Don't clear the flag if nothing was polled to prevent * queueing more WQEs and overflowing the async ICOSQ. */ From patchwork Tue Aug 22 15:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361045 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 A63451D2ED for ; Tue, 22 Aug 2023 15:06:12 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A390CC6 for ; Tue, 22 Aug 2023 08:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=alLl2NTvwI1JfAmdijREmAL8tmqJ67kFYxrrvf5H5bC12VfMG3Tg5yV1w6ENKmipYuU8VU6qMjQU1wY67YnFnmlhMc5LRrzRetb5OV/dEA7xd8/SXbIKQs9LHWPjCZ0Z5C7tExzLsojAL5A9pzzeDKs2RQM6kxLPh1geytcwChHg4fUyqaCuBKmH3t1TqIjIbZp5NYuNE8u41btl1aXvIrccI1AXeEISvFuzhQPhf1w5wSGxUlcFfIAMpda8FWOsVcvmhR7PyADAOHb/GCj5TyHAX8gLmHWmQ3KM8F0sqb6vJbOV6zn7bR5V9e/0ZPvGAiFxUc4nU7rtT3ozV43h/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+1/ZP1Dm1edYifhmRXtlLFAwAxhNQznXA5IHeqXUwFw=; b=N9go0yiLbhiyCeHe9yO1fI44JYDf9zHxF8GYJVjcrttHFlbP11xugvFSktgKZ4wxmo8aVkSF/2qYiVdF20zRo2NwZ4DRDJK+6DBe3oSSuLjWzRl4gAgKQqfoqHLd+PFwql/plLiuvX0fJu5zegm7gfwwA9SDKRnuoZKnYTowUaJwwUw1CItnHVuu1mCGYcPyV1zj/H2oqg2JVOL+XcH6cDVzFTGixbf9R6Ci1IJ2fpXmZ6mo1VinpFK6rnYf0gqX2bMeK5gwIHjWcaYcGUFblqGy0Lm3AF+Pf7OMRmCvssTf9DhBltMSKpc8Te1+wU0jJPv0mpqp4G4UzW5T3T29vA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+1/ZP1Dm1edYifhmRXtlLFAwAxhNQznXA5IHeqXUwFw=; b=IEsNC5nQFuwKgxb47VY4VY5S8mZPHRsaYQAC+9Tc2O+uEqW42OTH3taMJZrgqwqKZJ85z765rKnSpr4c+nMcVr7xSYWrCdY2m3wHl8VeJ5WI7mSfc+zbJJjUIhLWlzZjUVgFBnzK2EIUALfnMFW2UOXL3xsF9kYw39GN9MfPLS2zv5oqER5vIZiGvFZZ5AnGAcMAaoJNElREhjo/gddybfH/eZJOlcXNi2q0nWzrVEIfdeJHz4IjsH0Di1fEr/b6kFDej6By+Dksn6QMul189VGCpb92sC08quAPULC2JARXonYHByuxKwrkexsySRWLsggk/KLjUY00Kv8sWyCiUQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CH3PR12MB8233.namprd12.prod.outlook.com (2603:10b6:610:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:09 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:09 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Or Gerlitz , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 14/24] net/mlx5e: Have mdev pointer directly on the icosq structure Date: Tue, 22 Aug 2023 15:04:15 +0000 Message-Id: <20230822150425.3390-15-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0124.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::15) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CH3PR12MB8233:EE_ X-MS-Office365-Filtering-Correlation-Id: fb91f0b3-88b4-4ab7-cb93-08dba32150b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aF/ite6vXYWF1Gnt0alxLgE7oF9rHB1cT8CZLLgpOCoxdH84/6jNvRg1OkkxFMt2QOzQmRqn7tI6LehzYIliW/+zaJ2mjOWotx7D1UbCP78OY35DM/6khbbOs4HT42xKrsBuj8vwKMANR/7reg/LYAfkGCt34fHz54UMHMcY5iLBHnaxhc+S6+RSqe4egLLKO+V2RvP32jWyLJEA422oqOMQ8igoiaDDx9HZQC0e4laN2ovlwnarm90ZgYbG6G8YaZcI5hbU4oQ3M4HIhrRd8fPPYCZDmhNehZzqxUOcvvVtAno2L5hnrDn1QHGlrg9R1PHFMc4NTbBjULLO/L+F7w/zrNvCXolUEbe+kEM+D6uYHAcOKb/Q1rvEhbwjSbJWgoffYila+81Y2+3lK72IcJvGEIA3Io7v83zVO8JtDdYS37qn6exRPGNIOrd4gpP2XBQlBtfGKelRqeoULi+9xQNxNSGU0aaPFpP/yQElpHamtUvC1fIrfpKI/X02j4RoYJdiofXR1U3a7PBx3aNEvZCqXzlRHoEFtBwCst67bC+Q0nnrwXg1hzLEz+6E3rZ5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X0O2qaXFhVFf5OmOc0FOt5MAgGjGdQlbSq7acyUvlhevrWbj/IleCG3vkDhjTDp4zAl8x0qp2mZS95X38lnLx3r0Uvt6VUOj50xIHXsz/TCbUZ7kqMAf0+fCqWWZGLD3ZMbKovFCdvO1cqDNicMPdSvBO2ZR2V7uu9Ot9Vvh314+nhXqWQU1WdTXahRGahc4B8s+3xY4AUD18PTz9fuplZkHszMnWR5xLwsiLs/EGfUZa1vU1PeedBjUagBySrPP3gHEUPtUG0m3IHxNUwV0uc4ZIDFE0QT8BPY30W8dK+6QjrMRDa0NpCvjXhQy1Np4LP9sptm4OXfaI+GVMMT2BZeIWBEr8dUNMJpoB6/sIM/kuLWW0NatQGpPxAzAXOnWcZ+csVXvSGBxGPPx/ujglTGBjmuElnOgINod+86K8Laa8mfXX+XNre3DytkXGqpjnFiKkd/j54pU89pjiyFDRxnxtlbUNsxlwEte2/ssZA5vNloAOy1YiVHNavTd9mc80px1ncuh/udVXeI4N565ffC6Xo4urCe/MdwECJm+yOSSBr3MMBJzgSpmsafuGVrs15lWHAxrG1zsDy0NQidqxvZgdfLslq56R9dmjPB46COGziOPbQ76c+ZEG+PbRnfLZ9RSo6M4WXj2G79IVZnS/iTbAE5sH9dszjp2hoENMGGiOngHkr1oOTISKJudz4UAqKmHoNkvucikPulbKAb0fLGb/Fbsbv81en2dBiorp/oRYlvJ0e3rLt5h7KVB4BcKkobl0WOlr5nH0T8aIgj+SDbEbLbQjBR4Ha6/1gm2ghNSOLXH5pD7UWqewmQXVPNSdj7s8N09xA0znoaUx2rlYotL+x3WAT/vRA2JZzUW6p0vuGnEyn1cGuyGAGY0CKRgIepvFyNaK7sQUK3ndC1aE+Qnp8Jyuep0nKwvOclxsgo416X5b72AH90ux0jB2nLdj0FLVV7ivZKyc33jXj6aRcA4r/qNsE/pCPp28gn4+urGtwd/R1et8F3rfT1+ztn9Shi6oTzQ26ub9RzFEPEeQxY0gknlMKdF9JirFU5X9VFwjHcdzY+eaYEpjr7N8CcVpErDYCt76KeSb7J2Ki1+GgctxW6rEhmtd7tQ3XZahsMweh3Ndk3jdHdCxEnjV1uZZEpwkkMkFi2zv6MzSW/epxt6+AnS3dX7eeq2R7hOfXldgasPdT8BdD0sIdyuOUoPVPdhlMFdyn3cGA9/SizlQYVEPHK/LTDviAddtumtUMwn0Rtgken9oSYTmMQrrJkY/Cenx4zHcHSbjOpvGRE9vy5c9GSXryhFxdouTaj54jCJFHbLStX0wD+OVOWO95ESTt3MVKN6WdR7Fj7UQ9h66VcTKDB0wR6lpAnpYdEb8GwfgpsyqFFK3lElIwIaIezmnmtCtmgVJSHewTC0/uQ3snmtZp+advGT1keU/yMu+7ODhwvjUtwJBDnNg0ey9IIkFTN8xAyIlrTpUFRIeRHMjvkNsp3sv4Ypm4s1rZnP/RTm4+QaeSCWUoODBM79JsqHoM+LPsnZ+04FOL0YDXDQEB8JDVG3hwwUsLsoCSoCWNYOifhybD4l6aEswJL2hEy5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb91f0b3-88b4-4ab7-cb93-08dba32150b7 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:08.8489 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 33VTf92t4ZCyrIA1nTOdeax1ZYU3ZZe/sP7r4fpzf+KCPVYB5MusrLBmU6ihosDprpmHMZAXdC+vCGbLBrUNPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8233 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz This provides better separation between channels to ICO SQs for use-cases where they are not tightly coupled (such as the upcoming nvmeotcp code). No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index c1deb04ba7e8..365433c54edb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -547,6 +547,7 @@ struct mlx5e_icosq { /* control path */ struct mlx5_wq_ctrl wq_ctrl; struct mlx5e_channel *channel; + struct mlx5_core_dev *mdev; struct work_struct recover_work; } ____cacheline_aligned_in_smp; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c index e8eea9ffd5eb..1da90bda9eb0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c @@ -46,7 +46,7 @@ static int mlx5e_query_rq_state(struct mlx5_core_dev *dev, u32 rqn, u8 *state) static int mlx5e_wait_for_icosq_flush(struct mlx5e_icosq *icosq) { - struct mlx5_core_dev *dev = icosq->channel->mdev; + struct mlx5_core_dev *dev = icosq->mdev; unsigned long exp_time; exp_time = jiffies + msecs_to_jiffies(mlx5_tout_ms(dev, FLUSH_ON_ERROR)); @@ -91,7 +91,7 @@ static int mlx5e_rx_reporter_err_icosq_cqe_recover(void *ctx) rq = &icosq->channel->rq; if (test_bit(MLX5E_RQ_STATE_ENABLED, &icosq->channel->xskrq.state)) xskrq = &icosq->channel->xskrq; - mdev = icosq->channel->mdev; + mdev = icosq->mdev; dev = icosq->channel->netdev; err = mlx5_core_query_sq_state(mdev, icosq->sqn, &state); if (err) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index 20994773056c..3c6c5a4692a3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -267,7 +267,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, goto err_out; } - pdev = mlx5_core_dma_dev(sq->channel->priv->mdev); + pdev = mlx5_core_dma_dev(sq->mdev); buf->dma_addr = dma_map_single(pdev, &buf->progress, PROGRESS_PARAMS_PADDED_SIZE, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(pdev, buf->dma_addr))) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index a2ae791538ed..40277594c93a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1437,6 +1437,7 @@ static int mlx5e_alloc_icosq(struct mlx5e_channel *c, int err; sq->channel = c; + sq->mdev = mdev; sq->uar_map = mdev->mlx5e_res.hw_objs.bfreg.map; sq->reserved_room = param->stop_room; @@ -1835,11 +1836,9 @@ void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq) static void mlx5e_close_icosq(struct mlx5e_icosq *sq) { - struct mlx5e_channel *c = sq->channel; - if (sq->ktls_resync) mlx5e_ktls_rx_resync_destroy_resp_list(sq->ktls_resync); - mlx5e_destroy_sq(c->mdev, sq->sqn); + mlx5e_destroy_sq(sq->mdev, sq->sqn); mlx5e_free_icosq_descs(sq); mlx5e_free_icosq(sq); } From patchwork Tue Aug 22 15:04:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361046 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 0FA7F79D0 for ; Tue, 22 Aug 2023 15:06:22 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2085.outbound.protection.outlook.com [40.107.102.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99A7419A for ; Tue, 22 Aug 2023 08:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KNJZ/Hnt+HPusyjeebnIFlQQH3aHDCeo7Mv4jpm/+U6v/ryVI4IFC+IZ5f8BgN72Qr1aE7yRtAa0i9gN4B6c91/ujdP8wDMgMlJSTSsPCUVRGtPiOiHdfRytNMUp8iJICzL9I6o1VyDB3yPfWdn3P8NloHAbSOYIOQL/+/ngWTqfdvHvyy3YFH8zAFIW/AB8WvXBAW67/T5BdnqO/VIFxCGeb/o5KmzIS2stNuQy5GhUVj7gJjLL8BHZSltybKkyDsWN43t5W7mMk+Ha2OeQ59r+6l/oEiQaGp5zwftDn0VFbE4WRnEyAVMfWnM4qtrOdAvfMEQiEEwfC6V4eG3ySg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ukGyWnvrkYkgDK+/vOE1fE2hg2Jvy3nC0ELoNTWWmlw=; b=jrABGK9syt47ZncuVUDNbmFavG0ZgutzDQ7i7XBI+keXZaHvzwdzkYNih4YWnhufDPGyngXMMfAWEprM3sNQQ/J/wvUVAaffB/W8CQTCm/wUinI6XRaCoSXcdzpkR8YCHQb8UrG5YCKtQjZ/Ajoag81s4DQf4i08tcQKgkVs1wmO+1/nMuVIzhgLqlUVV+IHwx9dBChU7tHEsvspkXLX+ClH30BNX5YQ0P2rJ1368kI7rMV+1uOPSWdDRDAsRXur4rNDeapIoCLcgXkyXrRCOGCXyQkK80WMol+stesfWWiWTZTn+qytnw7Mk4RMgsqPb7K7e2kalMfTWOhPa44eoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ukGyWnvrkYkgDK+/vOE1fE2hg2Jvy3nC0ELoNTWWmlw=; b=jfAKscsLtlyEahq+eV/sZbWBcKtKIT7aWVBBpwRAS+7yWYOUpoP7pySAZoAdcM0cVweWX8uyBWPmIXocPqfxbxyqBo4ztiT1uUz6pFRGpLBtmz/4rfU5ve7nY0FLiG2ByJ0+gtIDOgnb/CbtzXqNTOxg0jmIYpoyEYj73JzWeJkVrAV4UG76xrCKOYuGlXBf3wFt+YUKr3IaJOwqQILRGiNImrV/pbQemtimKuxzUgylTLfdCrvTv7io2ET1kYBR4+TF4MIOeYKkfAym+swmyY+j5pDHMcS/H6Lgm+5t26YFlUpBo/mkgEVuGd5mV/2OIC15bsHH0HlywK6OI0lCoQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:15 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:14 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Or Gerlitz , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 15/24] net/mlx5e: Refactor doorbell function to allow avoiding a completion Date: Tue, 22 Aug 2023 15:04:16 +0000 Message-Id: <20230822150425.3390-16-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0076.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::6) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f40e7a5-6cf3-4b19-3b40-08dba321543f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EjJUwP3on4kRBM0PyFZbq8sCfDjVf0pFGUc7CokLMh8VsC3a+CMWUYe0Xw73B/MZUEEbOlcWT3xSumL3Oja+hiH4kKC/U2P/YEe6Km2PWraTI7H+VyVMSBVjZORC0sTu47T2HXUSmD3M/1AcKAE25zSlzZvP3pS9Z6fCHgptE8/sRyxt7N15zQLIdAyRZUO9TZJOL4HcBd9InTTHeUzZEuASVp3oCioBHU6Su26zPjf0ljQIfSYIvv7xBsJKb7xjxbiXwV/1qtNAjkMbcA8Rdy/oDtprmZCYq+lBgpRrUqzNOj61UDvhHDTDuTI2p1X1936JraMvp/d4ds+RPIZnrSwNgLIoXUsNvl+7mxuDlEmW6QajyYVLWEaaVvqEMVT7jk6ImPiuyHF9kjDkYOoheM8ASh7yVQLLKRJ5BdYjKWVQRrByW1NwoYZU1nrN6W0j0jc7hohuDUq7Nulm2+ymrFsqaiIUqDUCnXKKcZGw5mVyUbgw6CCDefNgj2Y9rn2BW8QrNWRVii0cCmffd7yBg92pJ8nspFQIkGteBYkQCH/T5CKgFSbaLyVfwCu/kEvt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nO0K3Z+9zEgE7oiIIsqGxxZk81b/M1RMyfEyJThY2aus8eK6BVF3cmrB7SePKbrZvmexgB+PCorGjLH8L/IfArcBmibVOcfeMsAjD19ZUTmBoMeHPPttjZzi5JXimp/W44lX2Fc9kaVTG7JYaV87nu8PRR5AZSn6NvTFsyqV/V4l+JfZ17TJQYgG2VMx7iRU7vhOQdQvopE9kStiCA4I7vU4z9Ycm2ikypQY3qtHGXuiMsR+aw+erZVxeQhSs6mS8LwYm8A5hcWkM4qMi0W3pTV3FgGAtpMmlUqNkBlDwqsu8/D2ZC12QHIWaTGluo7z009QOAAznUntK3jvTBgUuW4UfVtqaMX4mX6enePPk4vux+i13FC5++9t879DYjo966FioK2QIBu2oyRtQvFCoH1OqM2xN31Y5z9Sidu9gzUJQYGL43snOnMK6wJSHQMXjgQvXimIjgIzE0wWkg4ROe6z1WZGhATItvC9v/LRHSM9waEb81FdICvVX0XXO1e9CKb4XqasQkakWC9S+y5AGOgmbewDxzny3oNsHGtVx72O8Vtrk6dpihCsy99qMw6HWFA8nOz+Yy6AcGJe5ssRAvNlcqP+8PFPAYOIWu0FAw33U5+7Dt051G82Zm5dAZsFs2kxw881TdK8qZQnAI1lr99BPHyA/WZD8EtrhFgcVB4/UVPcbUvSV0aBmIndCjQ/XRg/B+8+jNO5S7c1UWELOU0b79bqxAS+fuHfG8dnyqqbUvBNMOzSJzV7xZhM8HFUhPc8/l9+VxXUDdZVpsUZX0xVNmHYVb6jz+6QlhY8ydDO6QkEO2t1deMg2CoJTecEbCOFPtlvIYfS2eCk3zccVHcYgbti/5ikJDKgHt9/UjQC9LLhEgwkzV8fkruZNyS5Csa5lXv52I7gBC07rBt7Da7gMPmMLtp7/hAd5SmnpbrZVXQ/cDszj7cfatJkaU3SUg5b5jqy2yfznDaDw+2NghzACwPBt2ux424m3hOwo3wzu7cSplOOeFPyRH6oYw3vnT/1dAdXZnDfCcTkhW/E3WthUUKocVlLNohfVUfk9iiid0HyUiJXyjQ6NUCNhapC58xuyhd+OoyK6H9pzyclu4RY17g/Wqzm22/D7Blu+JTkk6ioWyv3fRWXtGO1A66AoBovwNAxWsYY9Rya7JalKKk2R5eTJuBpbGJdD5WMOgx1E15u1wYqD5w9aLAkO7sJw8jLR5Hy/6Qnb5neUJSyOHK/yk2KXSHFInkWC3PuV0Kmsk0sXM5LHFaIENEZY/zdGjZ0+8L234XeLi3oaR6n8Psy73Wp2FZp23zirNgHRRr0PRd9TMS2hp7tZBTtG5jbbNf1p2zkoLFUp7Kfp+d7w3W7JAiQOEYcFAwKhWe17+XdyThStZRcY5r70DWb4WqoICW3YiqMNHijqZwCE7XU3bQXuMnA1PFHLF3t9OLBd/qI3gRO4kRYNNsLaKQsiElcfaEwtC56OdSrg9MtOB+yjPQkMe+dnlZOrGU9EzP0HL2fUL1XmDj2s98Eg34rFxIxCAoz3u22Z/DhrFJ3aNCqHuAeyzZbvXPM/JbmVpxB5x9gcwz2C1GEarxz3m84GR6/ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f40e7a5-6cf3-4b19-3b40-08dba321543f X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:14.6805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JhW/JgladVxsngRT4VkSNLnGDH0BkgE4sB4xzYTpgX5DPkEYseB2kS6PxwUsi7OeD8C0Rh69Q8zbInfPMFbZFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz Currently the doorbell function always asks for completion to be generated. Refactor things such that all existing call sites are untouched and no branching is added. This is done using inner function which can be invoked directly in cases completion is not desired (as done in downstream patch). No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel --- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index cdd7fbf218ae..3807536932e4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -256,10 +256,10 @@ static inline u16 mlx5e_icosq_get_next_pi(struct mlx5e_icosq *sq, u16 size) } static inline void -mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, - struct mlx5_wqe_ctrl_seg *ctrl) +__mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, + struct mlx5_wqe_ctrl_seg *ctrl, u8 cq_update) { - ctrl->fm_ce_se |= MLX5_WQE_CTRL_CQ_UPDATE; + ctrl->fm_ce_se |= cq_update; /* ensure wqe is visible to device before updating doorbell record */ dma_wmb(); @@ -273,6 +273,13 @@ mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, mlx5_write64((__be32 *)ctrl, uar_map); } +static inline void +mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, + struct mlx5_wqe_ctrl_seg *ctrl) +{ + __mlx5e_notify_hw(wq, pc, uar_map, ctrl, MLX5_WQE_CTRL_CQ_UPDATE); +} + static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) { struct mlx5_core_cq *mcq; From patchwork Tue Aug 22 15:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361047 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 2E6468464 for ; Tue, 22 Aug 2023 15:06:25 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED221B9 for ; Tue, 22 Aug 2023 08:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uzao//yDK4HqE47j88FxnQQxAlY2iJyJqeI2ZD428yK31oil0nSPyemh6uxfe4KRx1Mhz06DvithN3BE3cmE8tJNaXwKJ8Zs6+SWjUrK1xPoOtckuz6mXh2HDMPWdagY6iwO9ZMmlN2tuAZ4oAj09Med8J8OCsN38u4JtiZrDHC/2C8tO4CuQSL4Iz0xmkXAQYiRnJuvhXlZ+ypm1yTQ7K2/2U9PobciZz68k/LkW2pjYv5R34TKrZC4HWS8h09j6XWGby8WPeZfxWJC9L3aAR6OyidSo842r69/om5MX431Q6TAnBA2YEqDIR22tdoFs6gAG+X7+mQgEsNdRawq4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XRXsVQTP3O6+XKzVg6Vnp5wMvBLi+T5jKmtctXPWKnU=; b=LSr0XJg8Qc1vu02o+Xt/K4lDmmh575G7AXqs+b/XMdh/D6WMPOpzva/f0TXzX3fE2komm5lNoqqzyrBhbI1/Ea+4FHrYNtX9hjZb0APYC9+LVGgqR3/w4sniglHhIrS5OLF5MyLgspZZZgqRgVMiF9wRLBkrmsKSHZiJGojC4KYoCBcWGCd7bgk3rilJy0mcAiezed2rPHBbp3KK0+9r+15mirdLGii9N98D8x2qPoJ49A/64c4Y74A2d7mt8td77yteXNdljGIKFb6fHUDCHh/1hlY2dPD/odA07lsy4t59/Uqq65EZRNMlUwneHI3gFui8xLyfVceclZSkLVg9Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XRXsVQTP3O6+XKzVg6Vnp5wMvBLi+T5jKmtctXPWKnU=; b=OO/5bAQizZ7Ch6NywQpIb7w2Rj5W/qBM5dsXrFXgqnozD913Q4KqHjxvsBaVHNOzsNqfzA0FhJtF+OsBzTmgbpQLVc6pUqCtoMtzfNNB/IutAaLXoASnFghQmZuJ/HWakT1Vt8Crf0lszO1ayYYWazryrfEiLBld/ad8+hVlQsl7P/0pednW+2N9D4czOc3lhj/G/XtEnknDV9cQ0rXaO3B05k8beeKyehY3butw5XIvQjAkxSQjvhGmhQyl779AMkXap6NU/K71mW5Jz4ABsDC9mnOHdm7JRMO5CAxZvHhM1e4Wb5UgAws9xLLbxO9TfMjMRHneVZvRjAivD54L9A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:20 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:20 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 16/24] net/mlx5: Add NVMEoTCP caps, HW bits, 128B CQE and enumerations Date: Tue, 22 Aug 2023 15:04:17 +0000 Message-Id: <20230822150425.3390-17-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0140.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::6) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c708292-0dd8-4b9d-e91e-08dba32157a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mpI5Zj/37SelYpSD7t5IKMDXXicNoMh1nARsj1xu7ejnw5eTiUwJe+eAM3QRrBqtjbXAZvvl6SgTp7ImGLm4ekaWDPQke36zklH6538TdDBy5NRKX4+VUO9gxQVKAEB8kYsRz93jz7WHgv1vHTXHRRGPmN60mB340ZdnESNA8+WRNVTu5Wwi4wKRTOYYe6TRsr5xjWk2GjZd6eyhlSothe33EtYHL576/O+jlIKPI6pV+W22Cd2ihZH8p/NRfLiemxXvLZCUEMoQPKAJCZI4Lkouvi3ZdXkpwvj6VhIl1afVwil3IiCjTl8JCcpr41wgpLC5+mNzGj1/3uM30DkzFyPuojAzUr5DIQiEwt+FNTCl57OqXpWKupn2YE7DwT6+3dNlaBacbA+rxdt+mHesgzp283XTk/A6FTgbOvk7UFDUGxbVGpBXX6J5ZYQnF1LKONxYS4eZ24v1760/6N+6H84un6xuh66xaqYcoZ1L9v2wdRMCnEmCt+O24MuDcJXnh0T69jw9HWEUcz3Fzbz7foul/ahSbkP6gd4gr7a8PiwP7RAaYQpZsbabQG6azuP5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 120+Ydp18JnHUylMax0I3sB//sldGDulm9mqHaH2Pcw2j9EUMxBMBUbq24GD7JvY1gWkei5lvjJckIvoIhWwEB4SVaSqivBmEKPk9FbGzQvBruUyO/3agbGzSnrMYJfpmZz+o0Om4vNJHiem5hMCy/ePXgJGES1lciLUy0T5naJfCxiQpbMdd8YmlwqHBaXxHPEPV4lixbvaOczP47FZp5VPQsFOe8Yex/sudEnNkXP9lmYk9AWRo+6IyUTdattH/pju4C0Ev3M21r+mDbZaQNn/BrgkE03/L+zT3K28iTUF+biOopfxj9PipPOd4DVfyjh5V5vCiQzI3CnaeviiTnDirsOeaBgLv9OwFlf71H4aXuPByt1x9xS3TUhPionFWzdCEwpcUIoE5I+hkNtXU5sWVG6hcNUJyA6Mn1sKC4BvqGA2av22OiNnvhJrGofT5un2qGsidrkey2HmlsM+Wrs9PsOIydDFutHhTMN7+t2fltkkHpB8JDq3+fxU2TBvBQFuy/tt5ThdWjBqkHSTXU+3FEzqdfDdNmMacV8Hpf3YagH8xfmzory5g6TL6lslBJGhEJcv8vd63CfemQbHdW7tFQDtPZ6P7VX8B8xXPWybuWSobW6ruXxHauYeCjNmaXXo1CXzqlH3exvfN3ansUDBTmP0xTRzfYwPqnythdbjFc/fviYb/5tPMcCWYdKSNvJ4TaJRebAkB0WFyKvsLZDfpOugPE+Er3d/rDcVMBve36F6hM/YoVXmN7XXAFxObldAGCLPHmqmH4o/BdFdGcgbafWS4iqR503PwnKw4WkqxvPEOZC7yKtAzVK+pCOpL+UJTcidWJ/KZu4hbGVYHE/GVbnaX17nwYocwBVYsCbZWa+bKOHtd2JOLHtFFgo9yLmYVbc3zqCL2V2HIUw4UCG3+rdVJoutJNu5bVpatu79alY0/WbzSxNgsOEBdpQs+sQSJ42YJI/1OC9y4SYmK10EzTjQIFJL/qcr3ykXRgZEG5tvJtY95b0my6Ng+qo5tKBBjI018U+rOVDsmjLwgG2BP6YfCkWWBRwLtiCStC5FDu4q9ESntyVSZdcnhs7Z1Dz2cOYu5mFByRApZMWkdCamJAYTZWZBgsE8jYosal0bZPPsD4DDdrFyNkGs4tcn3GIkAgtvSe5JzMr+72Wwzr9IeTza0VBmENHRrd+zAkThOTJKLl7Aqx9TfDyXHKHFK4FuUt5tfulPG4JmjFJHCtfBGcloaJciNviNt3cxdU0llFo5Y7DOBvPQAZ8UV/0hsas2KjVTLHQ83A32umHsOgVG/EKyeyfrpIbmMpnz0k36iwrK/ESdfkv7I7hsjaXq1oeGya48q6RkIitYH93TQPfmA2fBLYzJZLaicv+zLrOFBzWLsSqXqsYUNV8NV/G21gFF8gh2HHRzPL0JoOSDJOkTMS89ACHLOh0jHTIbEu/YhsdWQt9a0pqbr2Bt5upQkOJyOW2MRLsGp3vfx3BaprtoQUCuD0N39ufGOVPf4tTW86o69nYaEWak3/suUc1oT0SCirAu+sl7ZEfw5dInU8/umRgOyo2Dn2jdGx+gb07L/uzyEM0n23mFI+aCWwwi X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c708292-0dd8-4b9d-e91e-08dba32157a2 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:20.4564 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 46zDU/ECASPtQGsQLSPw6tUK1uFRAiiRG+iZJgRUFo+YduAOdX7ALVMEHEChFtMqyWrNo7i6gcnAcWQSlKFusA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay Add the necessary infrastructure for NVMEoTCP offload: - Create mlx5_cqe128 structure for NVMEoTCP offload. The new structure consist from the regular mlx5_cqe64 + NVMEoTCP data information for offloaded packets. - Add nvmetcp field to mlx5_cqe64, this field define the type of the data that the additional NVMEoTCP part represents. - Add nvmeotcp_zero_copy_en + nvmeotcp_crc_en bit to the TIR, for identify NVMEoTCP offload flow and tag_buffer_id that will be used by the connected nvmeotcp_queues. - Add new capability to HCA_CAP that represents the NVMEoTCP offload ability. Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/fw.c | 6 ++ include/linux/mlx5/device.h | 51 ++++++++++++- include/linux/mlx5/mlx5_ifc.h | 75 ++++++++++++++++++-- include/linux/mlx5/qp.h | 1 + 4 files changed, 128 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c index 58f4c0d0fafa..f1745f69337b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c @@ -280,6 +280,12 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev) return err; } + if (MLX5_CAP_GEN(dev, nvmeotcp)) { + err = mlx5_core_get_caps(dev, MLX5_CAP_DEV_NVMEOTCP); + if (err) + return err; + } + return 0; } diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 3b1d15abc8d7..d772c07e1327 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -264,6 +264,7 @@ enum { enum { MLX5_MKEY_MASK_LEN = 1ull << 0, MLX5_MKEY_MASK_PAGE_SIZE = 1ull << 1, + MLX5_MKEY_MASK_XLT_OCT_SIZE = 1ull << 2, MLX5_MKEY_MASK_START_ADDR = 1ull << 6, MLX5_MKEY_MASK_PD = 1ull << 7, MLX5_MKEY_MASK_EN_RINVAL = 1ull << 8, @@ -793,7 +794,11 @@ struct mlx5_err_cqe { struct mlx5_cqe64 { u8 tls_outer_l3_tunneled; - u8 rsvd0; + u8 rsvd16bit:4; + u8 nvmeotcp_zc:1; + u8 nvmeotcp_ddgst:1; + u8 nvmeotcp_resync:1; + u8 rsvd23bit:1; __be16 wqe_id; union { struct { @@ -842,6 +847,19 @@ struct mlx5_cqe64 { u8 op_own; }; +struct mlx5e_cqe128 { + __be16 cclen; + __be16 hlen; + union { + __be32 resync_tcp_sn; + __be32 ccoff; + }; + __be16 ccid; + __be16 rsvd8; + u8 rsvd12[52]; + struct mlx5_cqe64 cqe64; +}; + struct mlx5_mini_cqe8 { union { __be32 rx_hash_result; @@ -877,6 +895,28 @@ enum { #define MLX5_MINI_CQE_ARRAY_SIZE 8 +static inline bool cqe_is_nvmeotcp_resync(struct mlx5_cqe64 *cqe) +{ + return cqe->nvmeotcp_resync; +} + +static inline bool cqe_is_nvmeotcp_crcvalid(struct mlx5_cqe64 *cqe) +{ + return cqe->nvmeotcp_ddgst; +} + +static inline bool cqe_is_nvmeotcp_zc(struct mlx5_cqe64 *cqe) +{ + return cqe->nvmeotcp_zc; +} + +/* check if cqe is zc or crc or resync */ +static inline bool cqe_is_nvmeotcp(struct mlx5_cqe64 *cqe) +{ + return cqe_is_nvmeotcp_zc(cqe) || cqe_is_nvmeotcp_crcvalid(cqe) || + cqe_is_nvmeotcp_resync(cqe); +} + static inline u8 mlx5_get_cqe_format(struct mlx5_cqe64 *cqe) { return (cqe->op_own >> 2) & 0x3; @@ -1217,6 +1257,7 @@ enum mlx5_cap_type { MLX5_CAP_VDPA_EMULATION = 0x13, MLX5_CAP_DEV_EVENT = 0x14, MLX5_CAP_IPSEC, + MLX5_CAP_DEV_NVMEOTCP = 0x19, MLX5_CAP_CRYPTO = 0x1a, MLX5_CAP_MACSEC = 0x1f, MLX5_CAP_GENERAL_2 = 0x20, @@ -1424,6 +1465,14 @@ enum mlx5_qcam_feature_groups { #define MLX5_CAP_MACSEC(mdev, cap)\ MLX5_GET(macsec_cap, (mdev)->caps.hca[MLX5_CAP_MACSEC]->cur, cap) +#define MLX5_CAP_DEV_NVMEOTCP(mdev, cap)\ + MLX5_GET(nvmeotcp_cap, \ + (mdev)->caps.hca[MLX5_CAP_DEV_NVMEOTCP]->cur, cap) + +#define MLX5_CAP64_DEV_NVMEOTCP(mdev, cap)\ + MLX5_GET64(nvmeotcp_cap, \ + (mdev)->caps.hca[MLX5_CAP_DEV_NVMEOTCP]->cur, cap) + enum { MLX5_CMD_STAT_OK = 0x0, MLX5_CMD_STAT_INT_ERR = 0x1, diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index d44b0795470a..d7394a409ca5 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -1453,6 +1453,20 @@ enum { MLX5_STEERING_FORMAT_CONNECTX_7 = 2, }; +struct mlx5_ifc_nvmeotcp_cap_bits { + u8 zerocopy[0x1]; + u8 crc_rx[0x1]; + u8 crc_tx[0x1]; + u8 reserved_at_3[0x15]; + u8 version[0x8]; + + u8 reserved_at_20[0x13]; + u8 log_max_nvmeotcp_tag_buffer_table[0x5]; + u8 reserved_at_38[0x3]; + u8 log_max_nvmeotcp_tag_buffer_size[0x5]; + u8 reserved_at_40[0x7c0]; +}; + struct mlx5_ifc_cmd_hca_cap_bits { u8 reserved_at_0[0x10]; u8 shared_object_to_user_object_allowed[0x1]; @@ -1477,7 +1491,9 @@ struct mlx5_ifc_cmd_hca_cap_bits { u8 event_cap[0x1]; u8 reserved_at_91[0x2]; u8 isolate_vl_tc_new[0x1]; - u8 reserved_at_94[0x4]; + u8 reserved_at_94[0x2]; + u8 nvmeotcp[0x1]; + u8 reserved_at_97[0x1]; u8 prio_tag_required[0x1]; u8 reserved_at_99[0x2]; u8 log_max_qp[0x5]; @@ -3451,6 +3467,7 @@ union mlx5_ifc_hca_cap_union_bits { struct mlx5_ifc_virtio_emulation_cap_bits virtio_emulation_cap; struct mlx5_ifc_macsec_cap_bits macsec_cap; struct mlx5_ifc_crypto_cap_bits crypto_cap; + struct mlx5_ifc_nvmeotcp_cap_bits nvmeotcp_cap; u8 reserved_at_0[0x8000]; }; @@ -3703,7 +3720,9 @@ struct mlx5_ifc_tirc_bits { u8 disp_type[0x4]; u8 tls_en[0x1]; - u8 reserved_at_25[0x1b]; + u8 nvmeotcp_zero_copy_en[0x1]; + u8 nvmeotcp_crc_en[0x1]; + u8 reserved_at_27[0x19]; u8 reserved_at_40[0x40]; @@ -3734,7 +3753,8 @@ struct mlx5_ifc_tirc_bits { struct mlx5_ifc_rx_hash_field_select_bits rx_hash_field_selector_inner; - u8 reserved_at_2c0[0x4c0]; + u8 nvmeotcp_tag_buffer_table_id[0x20]; + u8 reserved_at_2e0[0x4a0]; }; enum { @@ -11904,6 +11924,7 @@ enum { MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_ENCRYPTION_KEY = BIT_ULL(0xc), MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_IPSEC = BIT_ULL(0x13), MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_SAMPLER = BIT_ULL(0x20), + MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_NVMEOTCP_TAG_BUFFER_TABLE = BIT_ULL(0x21), MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_FLOW_METER_ASO = BIT_ULL(0x24), }; @@ -11911,6 +11932,7 @@ enum { MLX5_GENERAL_OBJECT_TYPES_ENCRYPTION_KEY = 0xc, MLX5_GENERAL_OBJECT_TYPES_IPSEC = 0x13, MLX5_GENERAL_OBJECT_TYPES_SAMPLER = 0x20, + MLX5_GENERAL_OBJECT_TYPES_NVMEOTCP_TAG_BUFFER_TABLE = 0x21, MLX5_GENERAL_OBJECT_TYPES_FLOW_METER_ASO = 0x24, MLX5_GENERAL_OBJECT_TYPES_MACSEC = 0x27, MLX5_GENERAL_OBJECT_TYPES_INT_KEK = 0x47, @@ -12276,6 +12298,20 @@ struct mlx5_ifc_query_sampler_obj_out_bits { struct mlx5_ifc_sampler_obj_bits sampler_object; }; +struct mlx5_ifc_nvmeotcp_tag_buf_table_obj_bits { + u8 modify_field_select[0x40]; + + u8 reserved_at_40[0x20]; + + u8 reserved_at_60[0x1b]; + u8 log_tag_buffer_table_size[0x5]; +}; + +struct mlx5_ifc_create_nvmeotcp_tag_buf_table_in_bits { + struct mlx5_ifc_general_obj_in_cmd_hdr_bits general_obj_in_cmd_hdr; + struct mlx5_ifc_nvmeotcp_tag_buf_table_obj_bits nvmeotcp_tag_buf_table_obj; +}; + enum { MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_KEY_SIZE_128 = 0x0, MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_KEY_SIZE_256 = 0x1, @@ -12289,6 +12325,13 @@ enum { enum { MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_TLS = 0x1, + MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_NVMETCP = 0x2, + MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_NVMETCP_WITH_TLS = 0x3, +}; + +enum { + MLX5_TRANSPORT_STATIC_PARAMS_TI_INITIATOR = 0x0, + MLX5_TRANSPORT_STATIC_PARAMS_TI_TARGET = 0x1, }; struct mlx5_ifc_transport_static_params_bits { @@ -12311,7 +12354,20 @@ struct mlx5_ifc_transport_static_params_bits { u8 reserved_at_100[0x8]; u8 dek_index[0x18]; - u8 reserved_at_120[0xe0]; + u8 reserved_at_120[0x14]; + + u8 cccid_ttag[0x1]; + u8 ti[0x1]; + u8 zero_copy_en[0x1]; + u8 ddgst_offload_en[0x1]; + u8 hdgst_offload_en[0x1]; + u8 ddgst_en[0x1]; + u8 hddgst_en[0x1]; + u8 pda[0x5]; + + u8 nvme_resync_tcp_sn[0x20]; + + u8 reserved_at_160[0xa0]; }; struct mlx5_ifc_tls_progress_params_bits { @@ -12550,4 +12606,15 @@ struct mlx5_ifc_modify_page_track_obj_in_bits { struct mlx5_ifc_page_track_bits obj_context; }; +struct mlx5_ifc_nvmeotcp_progress_params_bits { + u8 next_pdu_tcp_sn[0x20]; + + u8 hw_resync_tcp_sn[0x20]; + + u8 pdu_tracker_state[0x2]; + u8 offloading_state[0x2]; + u8 reserved_at_44[0xc]; + u8 cccid_ttag[0x10]; +}; + #endif /* MLX5_IFC_H */ diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h index bd53cf4be7bd..b72f08efe6de 100644 --- a/include/linux/mlx5/qp.h +++ b/include/linux/mlx5/qp.h @@ -227,6 +227,7 @@ struct mlx5_wqe_ctrl_seg { #define MLX5_WQE_CTRL_OPCODE_MASK 0xff #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00 #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8 +#define MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT 8 enum { MLX5_ETH_WQE_L3_INNER_CSUM = 1 << 4, From patchwork Tue Aug 22 15:04:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361048 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 5C8ED1FD0 for ; Tue, 22 Aug 2023 15:06:33 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD97198 for ; Tue, 22 Aug 2023 08:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aJT9Xj/blxvOHWmvFHHihg1t6Orvp9oLjNPgACbV4dzQFXTQZKRfg7c2f3CLUFuUqEN/5Bj9iYIM7/ubVZKUzc7u63DL1yJx+HIT361JoQ6JQ64uwTGRkm8NvYJPzYSVeXCXuf6uKrr79TFtWhfxIEnuasOUiYxogksHTX31hfFmDV2b3h03cCAhEBqocmCvEBpvfRhcWW8PYgBrkRBx9tcu3Z/6wMCJlWJ7uX99q3MYpR2BAXn2Mbe38uXeCNENEGGF0kc046vnOJ8VKflEFYbdArMp6t4MKNluZxeCUdPTPGjMvMkrJcHcNfHkUUEGAxnNqcPQvniTO1ZxXVfl0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xko18i7vSC2+kECQf3JSVzIHUFF09gPOBmRgaXfQCOA=; b=SXa97dYICqP7bexgGfpPdsdsQMuy9zEVtzNr2I8Hbx5HO7gw3y4Qx8sCm58Ex9A6Ln2+tZQq9ScPm3r7THFYEC5qf03eslm6K8zKV2BvK68ZE1XdROccdRE7psXQNd9xxpV8HHppq1CflH7N6WFVoMtXLGcI+oiEdzq+KqrdaA5hbLeuOCSwOivKuDB6F5tczVY6/ymksdVBTc5jCuilt62sOwOv/RB/zd24GPsag9wKldCcPJUPdZeBIqPVgMblRUEZqMlD9lg/1a4un7VQ+woVyNqdzsmloHTJJFCIhpClOvuE+jRSge7UeNo6UhZ9c8cat9cjsN0IEfHHF88JwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xko18i7vSC2+kECQf3JSVzIHUFF09gPOBmRgaXfQCOA=; b=PCn+wiYajv7eeZq3pNW0RYusc9sRbrMnLsFbAt/x1bfsopNO6H2VlwFrZHplz0hdyQdy/6GFt4K/R0RPIP/IGLWPp7cocge9o8OZYH9TTFM2+BCHvVIf+t64DN02OqfRcI+MHmITglXmzXV/NqzGdH+TiYUDmupwdHLa5PqsUIsn0ftQkTuo0v+638ty1woc3VH/433HZ7cc517jC7eV/n+9aWbXD4/HXLSEBMNT8pO7aaQ5jsQ8EKmmAqw6qWTRkNnYVNRDfD87MdMTbNZ4y0ODj//lrbHrNSeYDQi9RO3OXjM0D+Eg0eMbknyvbp4j8p7lqcA4JtTLADezy1j84Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:26 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:26 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 17/24] net/mlx5e: NVMEoTCP, offload initialization Date: Tue, 22 Aug 2023 15:04:18 +0000 Message-Id: <20230822150425.3390-18-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0248.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::7) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 17c32d0c-dd89-4304-58af-08dba3215b2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZSX/ZOBU2uzvhgcdUKLwgePfSTxpST6oxeI+iiOseSR7WGT9JXXjJWje1+D1C9aEqiknEBj5GOr4Omc5m9x2Och0HuT7Q8M6wfYztEu9qc7KZ29Yql1vujdMpA41ehDm4OKFgb9ueW7OAluST0wKlwHRNzVkZgRx1/Eg5NKIBS6EO1rpDwzpojWQAjnwDeLM1bA1yW/55LhHVL/XyFFZHAtqOgRh6mtSuJtQqDvSOqZMdtOhcwa7eazqYGeiWVABusOsfDaF7lxJbkBbT3f1m0mJDCj2bzgTxSmmv6cuY6Ji2JD8KLcSkdG8u2SL1GJq4jy5N7yml3OlvPNcJQ6SKW1NGgn8kpt5xC2Dq1KLS8kSNB4lAowait/TYWnOoyy/Dg2JZ0xA70kuuSSqAdwRjpFB1QQspKZH5XcdyEkk5YZk6AL6DdnaKMq7KY7TEXjevfnfK+bMBEPc0qbA3CIfmarqKa7qGcR9ETynpy8rtpSd479uODnOIjV0svc5p3WOwelFjM2AUvRcQeLvXxx0mPzwoSi+fMFv0eTqEej5XgxCw+TUUAJBNDUvKRX2bWc2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(66899024)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(30864003)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DGO0fbvgOhMxlFNg8x9JG2CzEJh8o7x1p0uxRpnK1qatmQQZMJAYPvym4xx50vRhaiosEKMB6sM0klPoVyJjkTTorASUveNKC0PBlkxMyNTzza/PWyQNiT4obPXj2rIFR8NMXx2K/397F+45dFjvsxemNkJdcKXAwh33ZUXxqCye8dHGxtgPY7xCbJlIIQZu0+bkt2XSJxoI3jEYwomFHp6P6AGFSNbgX5Ua3d/JeESpXKnoJ+zCNovkz01A6jbKkK4W0Jc0zU/fS3GFp8CGfbRA31B6IwRFTVHs5q6uEpj3Nm9yts9RXHwyRgWAZ8yq3cqCq4X8l6s4hn6LNmYGqwzlgqnKq+FtesKwHAvjSBIkng7fhf0ap/FKAyFM9RmojO/5ajs/KWEo/YDFBT7da1Uit8FxYD5W21iA43ZcEKiUS2s2116eKtERhtg56gEUKjGiqC7JZaYWUJWmVW1k6O0Q8uavGHunyet0fwiGuTx3BtZuQIVO0RoxqC/B0wm2azaalMYzxCS/+uZpwwfE8e/Xdoi2pXscc6ih+Se+u0vwPfN6B1NNBO3Q5tBLJdBaM9WZwWC8RxYPBfpMaht7Yw93Im8NMmLOEretPWk6Z69X2+tIhnAIWFVBpwSU/d9zNFJMC1aNaI5F+cSWvBigtAf0Anr2g3+L8eXVC96J2zcIBHTWaXdo+eLR1dWmDX8zzk/kUwmYqYu4Afc2bTxs07uXkb0hXM0kTXFX6o4CZk4K16nMskzxl8DMHXLBzMaVB4Z+EPK0TpTUnzoln9mErmV08xELO331bcxp2WAU0LRo4Qh1lg3ixkMJro00AxBohHXeHPA0+wKS9t3aFhwNvyTcHsTHwO5+kyU/+tP+lrbfFPX41ob5Jmjn+71cgeD5POVyDKuSdTpxGcJ8WYm+OlhkHFdpbrM+XzS1KegV03tYKu3/OxnnCvm4v6M7Gd04K40SpoyOquLE4x41v2Ghs+wcyv6IsSJ/1DQq5kEbFEA2iRdt4hHoRdnLHrbVvYrrI3HujtB1Md99OFcibdqusTgEuq+6ecyLm0iyOjEFokcco29n7oqGVqytQVNLCn+mngxeya/WM+rbavB4MsJcvOjnXxz/tONnedt97JoX6/FQRqwW0nLxu1ODepLtu9CRMffp9QBm3ajpeq2V5buP3l9r+Ct6I+tdBoWSO1c/kzobI8CsvRxlL9DTSfyiBDTYY5WLsrs6EjQloZpmfrT2gfDL9se3M755TqmGnsQCj1lUTi68f1eLRZ2dFKLdtNCxsCG4XW33tM7E6eH8JxZkMqSxlh/QzmRVBT+OeXK8OA7esKSlGupidcnMwsYIEoa23ZJOxBPzdJSGiBOh5ANEqNfzPc7jlH777qhp+WWTFpJCsyfZJ9n0q+BWZkC+JkXA0g0+PMgs+tyrUOMhwRkyZDNHK5N5ZvAtEdSTjG8n+7Vg9X2U3N/syMYbh8RU64DuiIDqW5ZCtGTy52vDPAsVQMgYXlvB/mBMAgsA3UdEvoQVheU1UxswrXvtxxRZBYKWKrLU8z7asO2LkzKz7/yBiuLWUFQzTj/jdXVi8pchyDs5VMEbiFMtY9LvxAlPcDv5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17c32d0c-dd89-4304-58af-08dba3215b2a X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:26.4587 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4hgoZhwkXUjlDMRqSbvEVAFBcD6Qa9aEIkkG8rpB5cDRLoH2n5VD8IioQ7ZbZQ5hrWai9u0XmjH5PuIF2XwkmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay This commit introduces the driver structures and initialization blocks for NVMEoTCP offload. The mlx5 nvmeotcp structures are: - queue (mlx5e_nvmeotcp_queue) - pairs 1:1 with nvmeotcp driver queues and deals with the offloading parts. The mlx5e queue is accessed in the ddp ops: initialized on sk_add, used in ddp setup,teardown,resync and in the fast path when dealing with packets, destroyed in the sk_del op. - queue entry (nvmeotcp_queue_entry) - pairs 1:1 with offloaded IO from that queue. Keeps pointers to the SG elements describing the buffers used for the IO and the ddp context of it. - queue handler (mlx5e_nvmeotcp_queue_handler) - we use icosq per NVME-TCP queue for UMR mapping as part of the ddp offload. Those dedicated SQs are unique in the sense that they are driven directly by the NVME-TCP layer to submit and invalidate ddp requests. Since the life-cycle of these icosqs is not tied to the channels, we create dedicated napi contexts for polling them such that channels can be re-created during offloading. The queue handler has pointer to the cq associated with the queue's sq and napi context. - main offload context (mlx5e_nvmeotcp) - has ida and hash table instances. Each offloaded queue gets an ID from the ida instance and the pairs are kept in the hash table. The id is programmed as flow tag to be set by HW on the completion (cqe) of all packets related to this queue (by 5-tuple steering). The fast path which deals with packets uses the flow tag to access the hash table and retrieve the queue for the processing. We query nvmeotcp capabilities to see if the offload can be supported and use 128B CQEs when this happens. By default, the offload is off but can be enabled with `ethtool --ulp-ddp nvme-tcp-ddp on`. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/Kconfig | 11 + .../net/ethernet/mellanox/mlx5/core/Makefile | 2 + drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 + .../net/ethernet/mellanox/mlx5/core/en/fs.h | 4 +- .../ethernet/mellanox/mlx5/core/en/params.c | 12 +- .../ethernet/mellanox/mlx5/core/en/params.h | 3 + .../mellanox/mlx5/core/en_accel/en_accel.h | 3 + .../mellanox/mlx5/core/en_accel/fs_tcp.h | 2 +- .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 216 ++++++++++++++++++ .../mellanox/mlx5/core/en_accel/nvmeotcp.h | 121 ++++++++++ .../ethernet/mellanox/mlx5/core/en_ethtool.c | 6 + .../net/ethernet/mellanox/mlx5/core/en_fs.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 17 ++ .../net/ethernet/mellanox/mlx5/core/main.c | 1 + 14 files changed, 397 insertions(+), 9 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig index d537d517cabe..a6fa867b5552 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig +++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig @@ -164,6 +164,17 @@ config MLX5_EN_TLS help Build support for TLS cryptography-offload acceleration in the NIC. +config MLX5_EN_NVMEOTCP + bool "NVMEoTCP acceleration" + depends on ULP_DDP + depends on MLX5_CORE_EN + default y + help + Build support for NVMEoTCP acceleration in the NIC. + This includes Direct Data Placement and CRC offload. + Note: Support for hardware with this capability needs to be selected + for this option to become available. + config MLX5_SW_STEERING bool "Mellanox Technologies software-managed steering" depends on MLX5_CORE_EN && MLX5_ESWITCH diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile index 946310390659..3470d80ab4dd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -109,6 +109,8 @@ mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/ktls_stats.o \ en_accel/fs_tcp.o en_accel/ktls.o en_accel/ktls_txrx.o \ en_accel/ktls_tx.o en_accel/ktls_rx.o +mlx5_core-$(CONFIG_MLX5_EN_NVMEOTCP) += en_accel/fs_tcp.o en_accel/nvmeotcp.o + mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \ steering/dr_matcher.o steering/dr_rule.o \ steering/dr_icm_pool.o steering/dr_buddy.o \ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 365433c54edb..819727652f5b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -319,6 +319,7 @@ struct mlx5e_params { int hard_mtu; bool ptp_rx; __be32 terminate_lkey_be; + bool nvmeotcp; }; static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params) @@ -926,6 +927,9 @@ struct mlx5e_priv { #endif #ifdef CONFIG_MLX5_EN_TLS struct mlx5e_tls *tls; +#endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + struct mlx5e_nvmeotcp *nvmeotcp; #endif struct devlink_health_reporter *tx_reporter; struct devlink_health_reporter *rx_reporter; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h index e5a44b0b9616..c817308c6102 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h @@ -77,7 +77,7 @@ enum { MLX5E_INNER_TTC_FT_LEVEL, MLX5E_FS_TT_UDP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1, MLX5E_FS_TT_ANY_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1, -#ifdef CONFIG_MLX5_EN_TLS +#if defined(CONFIG_MLX5_EN_TLS) || defined(CONFIG_MLX5_EN_NVMEOTCP) MLX5E_ACCEL_FS_TCP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1, #endif #ifdef CONFIG_MLX5_EN_ARFS @@ -170,7 +170,7 @@ struct mlx5e_fs_any *mlx5e_fs_get_any(struct mlx5e_flow_steering *fs); void mlx5e_fs_set_any(struct mlx5e_flow_steering *fs, struct mlx5e_fs_any *any); struct mlx5e_fs_udp *mlx5e_fs_get_udp(struct mlx5e_flow_steering *fs); void mlx5e_fs_set_udp(struct mlx5e_flow_steering *fs, struct mlx5e_fs_udp *udp); -#ifdef CONFIG_MLX5_EN_TLS +#if defined(CONFIG_MLX5_EN_TLS) || defined(CONFIG_MLX5_EN_NVMEOTCP) struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp(struct mlx5e_flow_steering *fs); void mlx5e_fs_set_accel_tcp(struct mlx5e_flow_steering *fs, struct mlx5e_accel_fs_tcp *accel_tcp); #endif diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/params.c b/drivers/net/ethernet/mellanox/mlx5/core/en/params.c index e097f336e1c4..21b7d8628dd3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/params.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/params.c @@ -873,7 +873,8 @@ static void mlx5e_build_common_cq_param(struct mlx5_core_dev *mdev, void *cqc = param->cqc; MLX5_SET(cqc, cqc, uar_page, mdev->priv.uar->index); - if (MLX5_CAP_GEN(mdev, cqe_128_always) && cache_line_size() >= 128) + if (MLX5_CAP_GEN(mdev, cqe_128_always) && + (cache_line_size() >= 128 || param->force_cqe128)) MLX5_SET(cqc, cqc, cqe_sz, CQE_STRIDE_128_PAD); } @@ -903,6 +904,9 @@ static void mlx5e_build_rx_cq_param(struct mlx5_core_dev *mdev, void *cqc = param->cqc; u8 log_cq_size; + /* nvme-tcp offload mandates 128 byte cqes */ + param->force_cqe128 |= IS_ENABLED(CONFIG_MLX5_EN_NVMEOTCP) && params->nvmeotcp; + switch (params->rq_wq_type) { case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: hw_stridx = MLX5_CAP_GEN(mdev, mini_cqe_resp_stride_index); @@ -1242,9 +1246,9 @@ static u8 mlx5e_build_async_icosq_log_wq_sz(struct mlx5_core_dev *mdev) return MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE; } -static void mlx5e_build_icosq_param(struct mlx5_core_dev *mdev, - u8 log_wq_size, - struct mlx5e_sq_param *param) +void mlx5e_build_icosq_param(struct mlx5_core_dev *mdev, + u8 log_wq_size, + struct mlx5e_sq_param *param) { void *sqc = param->sqc; void *wq = MLX5_ADDR_OF(sqc, sqc, wq); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/params.h b/drivers/net/ethernet/mellanox/mlx5/core/en/params.h index 6800949dafbc..f5a4d6f5d5bf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/params.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/params.h @@ -17,6 +17,7 @@ struct mlx5e_cq_param { struct mlx5_wq_param wq; u16 eq_ix; u8 cq_period_mode; + bool force_cqe128; }; struct mlx5e_rq_param { @@ -147,6 +148,8 @@ void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev, struct mlx5e_params *params, struct mlx5e_xsk_param *xsk, struct mlx5e_sq_param *param); +void mlx5e_build_icosq_param(struct mlx5_core_dev *mdev, + u8 log_wq_size, struct mlx5e_sq_param *param); int mlx5e_build_channel_param(struct mlx5_core_dev *mdev, struct mlx5e_params *params, u16 q_counter, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h index bac4717548c6..39510370847d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h @@ -40,6 +40,7 @@ #include "en_accel/ktls.h" #include "en_accel/ktls_txrx.h" #include +#include "en_accel/nvmeotcp.h" #include "en.h" #include "en/txrx.h" @@ -202,11 +203,13 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq, static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv) { + mlx5e_nvmeotcp_init_rx(priv); return mlx5e_ktls_init_rx(priv); } static inline void mlx5e_accel_cleanup_rx(struct mlx5e_priv *priv) { + mlx5e_nvmeotcp_cleanup_rx(priv); mlx5e_ktls_cleanup_rx(priv); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h index a032bff482a6..d907e352ffae 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h @@ -6,7 +6,7 @@ #include "en/fs.h" -#ifdef CONFIG_MLX5_EN_TLS +#if defined(CONFIG_MLX5_EN_TLS) || defined(CONFIG_MLX5_EN_NVMEOTCP) int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs); void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs); struct mlx5_flow_handle *mlx5e_accel_fs_add_sk(struct mlx5e_flow_steering *fs, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c new file mode 100644 index 000000000000..9ddee04a1327 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + +#include +#include +#include "en_accel/nvmeotcp.h" +#include "en_accel/fs_tcp.h" +#include "en/txrx.h" + +#define MAX_NUM_NVMEOTCP_QUEUES (4000) +#define MIN_NUM_NVMEOTCP_QUEUES (1) + +static const struct rhashtable_params rhash_queues = { + .key_len = sizeof(int), + .key_offset = offsetof(struct mlx5e_nvmeotcp_queue, id), + .head_offset = offsetof(struct mlx5e_nvmeotcp_queue, hash), + .automatic_shrinking = true, + .min_size = MIN_NUM_NVMEOTCP_QUEUES, + .max_size = MAX_NUM_NVMEOTCP_QUEUES, +}; + +static int +mlx5e_nvmeotcp_offload_limits(struct net_device *netdev, + struct ulp_ddp_limits *limits) +{ + return 0; +} + +static int +mlx5e_nvmeotcp_queue_init(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *tconfig) +{ + return 0; +} + +static void +mlx5e_nvmeotcp_queue_teardown(struct net_device *netdev, + struct sock *sk) +{ +} + +static int +mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *ddp) +{ + return 0; +} + +static void +mlx5e_nvmeotcp_ddp_teardown(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *ddp, + void *ddp_ctx) +{ +} + +static void +mlx5e_nvmeotcp_ddp_resync(struct net_device *netdev, + struct sock *sk, u32 seq) +{ +} + +int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable) +{ + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_params new_params; + int err = 0; + + /* There may be offloaded queues when an ethtool callback to disable the feature is made. + * Hence, we can't destroy the tcp flow-table since it may be referenced by the offload + * related flows and we'll keep the 128B CQEs on the channel RQs. Also, since we don't + * deref/destroy the fs tcp table when the feature is disabled, we don't ref it again + * if the feature is enabled multiple times. + */ + if (!enable || priv->nvmeotcp->enabled) + return 0; + + err = mlx5e_accel_fs_tcp_create(priv->fs); + if (err) + return err; + + new_params = priv->channels.params; + new_params.nvmeotcp = enable; + err = mlx5e_safe_switch_params(priv, &new_params, NULL, NULL, true); + if (err) + goto fs_tcp_destroy; + + priv->nvmeotcp->enabled = true; + return 0; + +fs_tcp_destroy: + mlx5e_accel_fs_tcp_destroy(priv->fs); + return err; +} + +static int mlx5e_ulp_ddp_set_caps(struct net_device *netdev, unsigned long *new_caps, + struct netlink_ext_ack *extack) +{ + struct mlx5e_priv *priv = netdev_priv(netdev); + DECLARE_BITMAP(old_caps, ULP_DDP_C_COUNT); + struct mlx5e_params *params; + int ret = 0; + int nvme = -1; + + mutex_lock(&priv->state_lock); + params = &priv->channels.params; + bitmap_copy(old_caps, netdev->ulp_ddp_caps.active, ULP_DDP_C_COUNT); + + /* always handle nvme-tcp-ddp and nvme-tcp-ddgst-rx together (all or nothing) */ + + if (ulp_ddp_cap_turned_on(old_caps, new_caps, ULP_DDP_C_NVME_TCP_BIT) && + ulp_ddp_cap_turned_on(old_caps, new_caps, ULP_DDP_C_NVME_TCP_DDGST_RX_BIT)) { + if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)) { + NL_SET_ERR_MSG_MOD(extack, + "NVMe-TCP offload not supported when CQE compress is active. Disable rx_cqe_compress ethtool private flag first\n"); + goto out; + } + + if (netdev->features & (NETIF_F_LRO | NETIF_F_GRO_HW)) { + NL_SET_ERR_MSG_MOD(extack, + "NVMe-TCP offload not supported when HW_GRO/LRO is active. Disable rx-gro-hw ethtool feature first\n"); + goto out; + } + nvme = 1; + } else if (ulp_ddp_cap_turned_off(old_caps, new_caps, ULP_DDP_C_NVME_TCP_BIT) && + ulp_ddp_cap_turned_off(old_caps, new_caps, ULP_DDP_C_NVME_TCP_DDGST_RX_BIT)) { + nvme = 0; + } + + if (nvme >= 0) { + ret = set_ulp_ddp_nvme_tcp(netdev, nvme); + if (ret) + goto out; + change_bit(ULP_DDP_C_NVME_TCP_BIT, netdev->ulp_ddp_caps.active); + change_bit(ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, netdev->ulp_ddp_caps.active); + } + +out: + mutex_unlock(&priv->state_lock); + return ret; +} + +const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops = { + .limits = mlx5e_nvmeotcp_offload_limits, + .sk_add = mlx5e_nvmeotcp_queue_init, + .sk_del = mlx5e_nvmeotcp_queue_teardown, + .setup = mlx5e_nvmeotcp_ddp_setup, + .teardown = mlx5e_nvmeotcp_ddp_teardown, + .resync = mlx5e_nvmeotcp_ddp_resync, + .set_caps = mlx5e_ulp_ddp_set_caps, +}; + +void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv) +{ + struct net_device *netdev = priv->netdev; + struct mlx5_core_dev *mdev = priv->mdev; + + if (!(MLX5_CAP_GEN(mdev, nvmeotcp) && + MLX5_CAP_DEV_NVMEOTCP(mdev, zerocopy) && + MLX5_CAP_DEV_NVMEOTCP(mdev, crc_rx) && MLX5_CAP_GEN(mdev, cqe_128_always))) + return; + + /* report ULP DPP as supported, but don't enable it by default */ + set_bit(ULP_DDP_C_NVME_TCP_BIT, netdev->ulp_ddp_caps.hw); + set_bit(ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, netdev->ulp_ddp_caps.hw); +} + +void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv) +{ + if (priv->nvmeotcp && priv->nvmeotcp->enabled) + mlx5e_accel_fs_tcp_destroy(priv->fs); +} + +int mlx5e_nvmeotcp_init(struct mlx5e_priv *priv) +{ + struct mlx5e_nvmeotcp *nvmeotcp = NULL; + int ret = 0; + + if (!MLX5_CAP_GEN(priv->mdev, nvmeotcp)) + return 0; + + nvmeotcp = kzalloc(sizeof(*nvmeotcp), GFP_KERNEL); + + if (!nvmeotcp) + return -ENOMEM; + + ida_init(&nvmeotcp->queue_ids); + ret = rhashtable_init(&nvmeotcp->queue_hash, &rhash_queues); + if (ret) + goto err_ida; + + nvmeotcp->enabled = false; + + priv->nvmeotcp = nvmeotcp; + return 0; + +err_ida: + ida_destroy(&nvmeotcp->queue_ids); + kfree(nvmeotcp); + return ret; +} + +void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv) +{ + struct mlx5e_nvmeotcp *nvmeotcp = priv->nvmeotcp; + + if (!nvmeotcp) + return; + + rhashtable_destroy(&nvmeotcp->queue_hash); + ida_destroy(&nvmeotcp->queue_ids); + kfree(nvmeotcp); + priv->nvmeotcp = NULL; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h new file mode 100644 index 000000000000..a665b7a72bc2 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ +#ifndef __MLX5E_NVMEOTCP_H__ +#define __MLX5E_NVMEOTCP_H__ + +#ifdef CONFIG_MLX5_EN_NVMEOTCP + +#include +#include "en.h" +#include "en/params.h" + +struct mlx5e_nvmeotcp_queue_entry { + struct mlx5e_nvmeotcp_queue *queue; + u32 sgl_length; + u32 klm_mkey; + struct scatterlist *sgl; + u32 ccid_gen; + u64 size; + + /* for the ddp invalidate done callback */ + void *ddp_ctx; + struct ulp_ddp_io *ddp; +}; + +struct mlx5e_nvmeotcp_queue_handler { + struct napi_struct napi; + struct mlx5e_cq *cq; +}; + +/** + * struct mlx5e_nvmeotcp_queue - mlx5 metadata for NVMEoTCP queue + * @ulp_ddp_ctx: Generic ulp ddp context + * @tir: Destination TIR created for NVMEoTCP offload + * @fh: Flow handle representing the 5-tuple steering for this flow + * @id: Flow tag ID used to identify this queue + * @size: NVMEoTCP queue depth + * @ccid_gen: Generation ID for the CCID, used to avoid conflicts in DDP + * @max_klms_per_wqe: Number of KLMs per DDP operation + * @hash: Hash table of queues mapped by @id + * @pda: Padding alignment + * @tag_buf_table_id: Tag buffer table for CCIDs + * @dgst: Digest supported (header and/or data) + * @sq: Send queue used for posting umrs + * @ref_count: Reference count for this structure + * @after_resync_cqe: Indicate if resync occurred + * @ccid_table: Table holding metadata for each CC (Command Capsule) + * @ccid: ID of the current CC + * @ccsglidx: Index within the scatter-gather list (SGL) of the current CC + * @ccoff: Offset within the current CC + * @ccoff_inner: Current offset within the @ccsglidx element + * @channel_ix: Channel IX for this nvmeotcp_queue + * @sk: The socket used by the NVMe-TCP queue + * @crc_rx: CRC Rx offload indication for this queue + * @priv: mlx5e netdev priv + * @static_params_done: Async completion structure for the initial umr mapping + * synchronization + * @sq_lock: Spin lock for the icosq + * @qh: Completion queue handler for processing umr completions + */ +struct mlx5e_nvmeotcp_queue { + struct ulp_ddp_ctx ulp_ddp_ctx; + struct mlx5e_tir tir; + struct mlx5_flow_handle *fh; + int id; + u32 size; + /* needed when the upper layer immediately reuses CCID + some packet loss happens */ + u32 ccid_gen; + u32 max_klms_per_wqe; + struct rhash_head hash; + int pda; + u32 tag_buf_table_id; + u8 dgst; + struct mlx5e_icosq sq; + + /* data-path section cache aligned */ + refcount_t ref_count; + /* for MASK HW resync cqe */ + bool after_resync_cqe; + struct mlx5e_nvmeotcp_queue_entry *ccid_table; + /* current ccid fields */ + int ccid; + int ccsglidx; + off_t ccoff; + int ccoff_inner; + + u32 channel_ix; + struct sock *sk; + u8 crc_rx:1; + /* for ddp invalidate flow */ + struct mlx5e_priv *priv; + /* end of data-path section */ + + struct completion static_params_done; + /* spin lock for the ico sq, ULP can issue requests from multiple contexts */ + spinlock_t sq_lock; + struct mlx5e_nvmeotcp_queue_handler qh; +}; + +struct mlx5e_nvmeotcp { + struct ida queue_ids; + struct rhashtable queue_hash; + bool enabled; +}; + +void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv); +int mlx5e_nvmeotcp_init(struct mlx5e_priv *priv); +int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable); +void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv); +static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} +void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv); +extern const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops; +#else + +static inline void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv) {} +static inline int mlx5e_nvmeotcp_init(struct mlx5e_priv *priv) { return 0; } +static inline void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv) {} +static inline int set_ulp_ddp_nvme_tcp(struct net_device *dev, bool en) { return -EOPNOTSUPP; } +static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} +static inline void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv) {} +#endif +#endif /* __MLX5E_NVMEOTCP_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index dff02434ff45..2f26ad83f218 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -38,6 +38,7 @@ #include "en/ptp.h" #include "lib/clock.h" #include "en/fs_ethtool.h" +#include "en_accel/nvmeotcp.h" void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv, struct ethtool_drvinfo *drvinfo) @@ -1929,6 +1930,11 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val return -EINVAL; } + if (priv->channels.params.nvmeotcp) { + netdev_warn(priv->netdev, "Can't set CQE compression after ULP DDP NVMe-TCP offload\n"); + return -EINVAL; + } + new_params = priv->channels.params; MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_RX_CQE_COMPRESS, new_val); if (rx_filter) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index 934b0d5ce1b3..37492af5b038 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c @@ -62,7 +62,7 @@ struct mlx5e_flow_steering { #ifdef CONFIG_MLX5_EN_ARFS struct mlx5e_arfs_tables *arfs; #endif -#ifdef CONFIG_MLX5_EN_TLS +#if defined(CONFIG_MLX5_EN_TLS) || defined(CONFIG_MLX5_EN_NVMEOTCP) struct mlx5e_accel_fs_tcp *accel_tcp; #endif struct mlx5e_fs_udp *udp; @@ -1561,7 +1561,7 @@ void mlx5e_fs_set_any(struct mlx5e_flow_steering *fs, struct mlx5e_fs_any *any) fs->any = any; } -#ifdef CONFIG_MLX5_EN_TLS +#if defined(CONFIG_MLX5_EN_TLS) || defined(CONFIG_MLX5_EN_NVMEOTCP) struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp(struct mlx5e_flow_steering *fs) { return fs->accel_tcp; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 40277594c93a..fd0e6f4f1ae6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -50,6 +50,7 @@ #include "en_accel/macsec.h" #include "en_accel/en_accel.h" #include "en_accel/ktls.h" +#include "en_accel/nvmeotcp.h" #include "lib/vxlan.h" #include "lib/clock.h" #include "en/port.h" @@ -4199,6 +4200,13 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, features &= ~NETIF_F_NETNS_LOCAL; } + if (features & (NETIF_F_LRO | NETIF_F_GRO_HW)) { + if (params->nvmeotcp) { + netdev_warn(netdev, "Disabling HW-GRO/LRO, not supported after ULP DDP NVMe-TCP offload\n"); + features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); + } + } + mutex_unlock(&priv->state_lock); return features; @@ -4952,6 +4960,9 @@ const struct net_device_ops mlx5e_netdev_ops = { .ndo_has_offload_stats = mlx5e_has_offload_stats, .ndo_get_offload_stats = mlx5e_get_offload_stats, #endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + .ulp_ddp_ops = &mlx5e_nvmeotcp_ops, +#endif }; static u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout) @@ -5221,6 +5232,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) mlx5e_macsec_build_netdev(priv); mlx5e_ipsec_build_netdev(priv); mlx5e_ktls_build_netdev(priv); + mlx5e_nvmeotcp_build_netdev(priv); } void mlx5e_create_q_counters(struct mlx5e_priv *priv) @@ -5292,6 +5304,10 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev, if (err) mlx5_core_err(mdev, "TLS initialization failed, %d\n", err); + err = mlx5e_nvmeotcp_init(priv); + if (err) + mlx5_core_err(mdev, "NVMEoTCP initialization failed, %d\n", err); + mlx5e_health_create_reporters(priv); /* If netdev is already registered (e.g. move from uplink to nic profile), @@ -5312,6 +5328,7 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev, static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) { mlx5e_health_destroy_reporters(priv); + mlx5e_nvmeotcp_cleanup(priv); mlx5e_ktls_cleanup(priv); mlx5e_fs_cleanup(priv->fs); debugfs_remove_recursive(priv->dfs_root); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 15561965d2af..6cd1f3660340 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1727,6 +1727,7 @@ static const int types[] = { MLX5_CAP_MACSEC, MLX5_CAP_ADV_VIRTUALIZATION, MLX5_CAP_CRYPTO, + MLX5_CAP_DEV_NVMEOTCP, }; static void mlx5_hca_caps_free(struct mlx5_core_dev *dev) From patchwork Tue Aug 22 15:04:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361049 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 49EDB1D2F3 for ; Tue, 22 Aug 2023 15:06:44 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE37198 for ; Tue, 22 Aug 2023 08:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+lL2fT73N+u43I14gH+cOJQ2+J9zjjo2+iaFEdCvJHdHHujbv8rDaQuu7YGnXDxakkWvsupmBWoeDnZsRICdYQaiVBR5JXMmr/DtAuPe9mTFoFMXoKEXHdUfKY8MP0ylqn4BbW7j2olYS+weOE/Lfz4Y8XiQ39z/DQi9JKHJZKukVP+fIa/lEKvHF3idp82OAIEYf0HIBs3aliCbB1RC+KzymA/+FrfPJilaAFAaspGRyXXi+ElnX/UQyAyGAw1iP91oxYFfNbfJn4NPV/h365ouLTNJ+oDltzmeesz4V9bKHfa5CUBpl6oAjCtDD6QlfEbdf+g8gxjqWtkuzHl3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pa3K+d+tGObk4y9Zv/bhOSlIarCrDmSWoYqxxmm8F3I=; b=er1elkbXMmpqATE5iwJEJ2U3GGqfor9ZIIbc/6d8xySPkrjZljneoD17iNUnvJm32eeKgcXkTpTRy9gbxXPnu07/NZrmfWNMVzi2kvVWg1ZPDV+BYOokxvfsOFqcYRh8K3aOX9/pFBkKMN8mQoDx2XS8SlseMvpEo/r9qaagVtW7RTKtLlqI+ABf7F5YXRyFNjzMoPjckHlxKXTLHWqPNQEZEHD2+7OI5r6pMIO8Vq/F9eFzJJLXQON+VBMWKDvmXhgjncKB0Q1JMR/qB9dVJ8JG9JVK6ohJoFqbY68xO/NKAdJKHbfzYRBNwvbQD+OhIG3EAZ/OCAqxsOOu+ov/Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pa3K+d+tGObk4y9Zv/bhOSlIarCrDmSWoYqxxmm8F3I=; b=Z7ieHCaB3r/oNGFfjfRuSHyeDKskilZR6h9JfDwj3mhw0/dfbfKslk+lr5kDXpn/WnPb2OcQICqflGIleNHboVUOog+BdXo7Gt8Vxwhh6dcQFBx8WP+K8VP10okuyhVY94o75UQw0QAoi72BOXnokyZu4Hg0IJtZwXGH/K6x0PIJWRL4HVKOKvwK7WLz4bmOJL5abJYeDzPBes5rJ+AC/hJhlgg6WgSYRdWu1hAMI6Pa4ds2IlDvKrsZ2ihDweQCuzxFTI45mXw39R0BOUH8typkItz1ZRpTbcQ9JAz0viCNtGyZu4vbJFzv9xm+9+mZueDpkjniQ5grQKlrRo6QZw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:38 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:38 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Boris Pismenny , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 18/24] net/mlx5e: TCP flow steering for nvme-tcp acceleration Date: Tue, 22 Aug 2023 15:04:19 +0000 Message-Id: <20230822150425.3390-19-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0148.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::7) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: f0f54ee1-fb4a-424e-cfae-08dba3216274 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QdnbHol/FINXYUtfMLqzmub0xQCG2hjixDc84rtLfgCp4b3doqN0+1McI2T+8gCr3frDH6q2dlrhOTVGDUeBF1JpJTa9SVeMW9yuYTFm1Xm07G1J9x6h0+HXnOgVJaS9vN/LZ6geixnIsdZg6WKqFASLcXyFLd/U4+Hsa+RuHkjyr9qD3vZl0GA0dlsXlV3ieBpLm9YAI30gYnLLkY2mLeoRCHh1QKZiCVRRod2cUqDMDkP3tUU7RhDu3ODuUe7NVyj+Shypdx7klq+/jEm2OY2zQaN/38p/kKlPddDmxXOXhNSswWFBa9mJuXX/gdCvvDjCw3e7X5pan5ExDj7nw+jfLu3ECHJHJ07Q1Qo18EYqLhr+qg/LJzulU8pcuNbQ8eo4gdF/S93ixpcDOseXSA7nhgUXUvULBzPdU7am2GpiskMHMjTr8I1p5Fxw6/uCjfrx7GW0Ti0jJnalHKDEOftiw/JRu4r+URpwqBOkxNqSbA1vNF6Snl8mNBIqes1j2RzKzRLL7DC9wIhV7q4Il6i/UltDIyklfgvU/LScTwF0iYRBosxNDpOW6GZPhVV9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WX7FHxSaPSBIqtcAZQWUJc/Sf4nedNDSr3DJOjkFACgddY89n/SKpEo2RrROn/Tlj5F8OoNkKFuNnc1L6rNzS6rUPzr8/n/t3Ah1hgFRPwE289T8lwVj0jlf+vXadw/LtIu8na7ZeZQw0Ugim9v3/0c+AYMFnZjAyoLUGQr8HI4nLm7RxY6GXmA2LPrmhQdwGs13ikpa3gMV51cOobbCwnah4yDVKUcZDaZi5J7c5Mdupo+c3Zby9knjfNGiEyR6rHBcLS49Oq6uKCDrDPXWiTBMY8Ss0+ROimBpSOJ7NbvIyOOXdKIJKtHmpRF1cpOXl4bOkbS1hOBkz0+QTdg9DBuDb2dCq9QoUaNctxUKSXb75Nx9ol7Y4nH3k3gzaun3J5tJhJN7VnkFgxLj+L4E04nQ/cChT0tM2zEVU3GzI02ZmNTFoRl3j3cRFCu6Y2+qizmP6P+PGBCMtIV2n5LhcbxAlUSsx9XU9L3v8iwuaYmrp6FpH2RZNj7W7GE8IlDh9FQ895IOJJLUFMgDbaKtRUuSdwd3ZoY+M16LidtdMRl3xR7MuY7VH+7rf8UjPephD10qQoqpE+sKIVmS8vLM5fty/KalKh8XBZcey2/kjBIOEHPXIowJ6V/DtpNYafc/tWFpEhtCgubl1WqJ1gCCbzn/piSCwkzNptGnS+WAMrKmaLY50X7LsrA/d3mStRNk2r8+2A67mevfo2/2BbDxDuIjkqnzgMgHeWDCP6YBAwWCo8OuP64F7oGZh0adcXNM7Xfwbz3NU2yGqDmgM5gZPlWSC63nSGXu5ccsjR3vr7B9cXYJ91/VLXV1LmOSbE/f814Xa1f9lWYicm3jZvY76CtJv1gQWvMzyMx65eAJ9/40+j7MborSLwxLSOFe9RgMy0aUHf3TsSXFORmkNpzdTKVL3seYIRAaOLs8njAxKDanZPGDMl1zQrX0LDU28TU94FO6ejO9SCyeQEaehrnlywzZIKArqgSU9PObY7zy+5jU1s8mSpOm4EjHNE/+nT5LxSONRYT/+rLJZ667UD3WEvUqN6PAXItfHgd7TEU/2tt8Yt0Kl64Uy8OjLaxVhpykJO+fS2Fj0Wjgdbd6f96h0awzWdIql3/pZ/dqYbIXVedn+TsMmkeMqiUTMfh7OpBiDVc4LbOAA+oEGMywfqeT1CPX4RbVZj9YzGM8eJtDsugwWdgITa8BQrytJk1af7Ra+C9d2EK1WXCdOsT6Ba+WYjpOIae1nAVlq3P33+YtUUl/ajNwedTF84VFtxXqXdB1aDXcXFeY3lHOd9J+aA3XufnQoXkcNmIlXwZePvPFgjM48NzcxpVN5+ba9l/8PkkeAYKyU6JL4BXsydMlk9GqmuZsPCifbVvXJc/pekIZ5Xamy5VmQE2TnFgNjrOYmnyyGYrXyTC2tu5+9YAPQFMHUl1WofasbF2Af/qfcHmjePCjuiY8z55OfCbNRyXnMAi1BIiEJfD8ZlZ1kWLY2bTpZ1RM90tmSQd5LUqaIlH40Tamo3r12YWRSAVAoVIXhwWqpgmo70OX3pTbbUBxlPQ01C42c5WjZjMuSTCXemsfCSKMIKoWuJBSSxDLKsMxAte0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0f54ee1-fb4a-424e-cfae-08dba3216274 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:38.5778 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rjCcWKcyVjkW+MejkeskjxlEfSbJ9jBBRyrLgzVpDwyJQPgC4UNCuZofIQoOEaL1wf5BH4OTT7jns7IGCB3V6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Boris Pismenny Both nvme-tcp and tls acceleration require tcp flow steering. Add reference counter to share TCP flow steering structure. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c index c7d191f66ad1..82a9e2a4f58b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c @@ -14,6 +14,7 @@ enum accel_fs_tcp_type { struct mlx5e_accel_fs_tcp { struct mlx5e_flow_table tables[ACCEL_FS_TCP_NUM_TYPES]; struct mlx5_flow_handle *default_rules[ACCEL_FS_TCP_NUM_TYPES]; + refcount_t user_count; }; static enum mlx5_traffic_types fs_accel2tt(enum accel_fs_tcp_type i) @@ -361,6 +362,9 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs) if (!accel_tcp) return; + if (!refcount_dec_and_test(&accel_tcp->user_count)) + return; + accel_fs_tcp_disable(fs); for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++) @@ -372,12 +376,17 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs) int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs) { - struct mlx5e_accel_fs_tcp *accel_tcp; + struct mlx5e_accel_fs_tcp *accel_tcp = mlx5e_fs_get_accel_tcp(fs); int i, err; if (!MLX5_CAP_FLOWTABLE_NIC_RX(mlx5e_fs_get_mdev(fs), ft_field_support.outer_ip_version)) return -EOPNOTSUPP; + if (accel_tcp) { + refcount_inc(&accel_tcp->user_count); + return 0; + } + accel_tcp = kzalloc(sizeof(*accel_tcp), GFP_KERNEL); if (!accel_tcp) return -ENOMEM; @@ -393,6 +402,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs) if (err) goto err_destroy_tables; + refcount_set(&accel_tcp->user_count, 1); return 0; err_destroy_tables: From patchwork Tue Aug 22 15:04:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361050 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 BE2C079D0 for ; Tue, 22 Aug 2023 15:06:48 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF64419A for ; Tue, 22 Aug 2023 08:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ROaCjoqzHBhTNJDV5LspT7y0WYjdPfttvrsmfV/S7UZDgQvQ/43XNqpeW6qcpDk6rSFvNbMIVFX9h55/vFQSYBvq3y1ENQvnC+i0Pg0pcYnKmpZ8nd1GQXuw7jbCBM23F18q2jNuZ676ERnXUcFGreg/+3T9G31xcuaDRhigCPA91f6ijGOOIOkQG8N+EEGm27vQnEPA6Sno5LGHEXk70fC8AsLV5vx2PBmhtB4+B6fxNFn8W772f2p+W9oZVDZXQ8xvQbgX8asFhK4Hh35SDnaozLoLheNiGhTAXgyBZvifBUxip5C5/HC76VUBJm9C4GRgy8cXhJeaWCBOBnwQtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g/N2+aWpEKoJHIpzPz4HX4AsFWpvq0dqa3uSNRJEvmE=; b=of6ZrjjzBLI7ag/uWNkdpHGiWl8JWZ7dXy/oZNyPnJdX4N0aecoLFSMOyIjORWnRXRHSiSum+exhsrRGw79VgL5GnT2sZzJdJ0p+i4UeXkP8ulFGzG9W719IQheWYF6jpY/c5P+g3ASt2+tPkN5jq0FEVwnWTh0iH9BQ4GUw0RsuVRPzzU6ImIQmsPDZ+LRAaI0CB6OUqPhr/PD7hdbtBHoWuc0DN6qZ+xgd/zBVH12Hk6M63L9rfclIXqbJX2vQpRDefs9zT9j7sXEIDDVzbiDlzRGffHWER9FegikANuabAYxDxeS/GPwBKQRa1/hcA6BRx+1FzYvs1ynlS6EFGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g/N2+aWpEKoJHIpzPz4HX4AsFWpvq0dqa3uSNRJEvmE=; b=CcNtQ+ZCwD3Y9puYGTwIFUJolTeyaCBMPURMmk6+/Yueg2gp3GOM2mgqY7OH48ztlCpB07hKT+DjLAtt1hpceBJhZOvgDdf1dbKuQStdejDAeAeHfld8e8UYN5/Ybb71Z9YLRnWO0xJL19aW2R/4s2yFjFuU7SUFEArONR+DBIFfZpO72ZSOCPWwJnaaOYVRKHoyrGe3GkwwMEQatocClLbNLV6pGKmf+Qd98t3/P6NgZ8QpwoVQTxYw7yLWq/1JNznqmdeBo8YW9KE34WVjOqYSE87UVGrPopLK9khtvc5Ku3AL/UmcpS1zMHBmAnOiM5koVRXSEo2EFiu1/zh9zQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:44 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:44 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 19/24] net/mlx5e: NVMEoTCP, use KLM UMRs for buffer registration Date: Tue, 22 Aug 2023 15:04:20 +0000 Message-Id: <20230822150425.3390-20-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0096.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::8) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 5657f1b9-f51f-4823-0597-08dba3216601 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HWznhNUqiI9enjz2enQEI3/i5lX+c/s/8KO88/OEFlnUuce7agEoxzBX+bfuyTKdW/zWrcb47QHNUHxo9Ulun3zRrmQChGzdhLRRVGZznL333AdJ6zZ32m4sQw2BtJFe9E9MSv0g0mUCO721EcbNgCS5ox/s7Te+FyvQrEZ4AZkVW75IKTPXSbCofTb5EItSQO36x3kg47qz5BRSOQ9VTLOt4ltWnZExjcF2JBCudEBW6x549E9Ud+LD/pyk1Cj3mBBxhX+M37jzuoGG3qXF4+PZ7Ben34RwW3nWh7y6yRKwh1PnISNqGs6QGfdAaWh1/rP4dEUATrCRYEeh9Sn2QS+fOIn04Xk8IiLy11bblauNU36mBBcaRqmRlV+/zHN84lKbTjdMlgNsulKtrGJdtHL9DxcpqaSDVV81o7txrgXTOM9tHJToAJhVLFHhMeTByZsHNJHm0C+8yamBPpONLQSjHtrXD8UxQVwKskD1IDS3kCIo3Rp4j2CGzEQOOIHKfrNkdjBjRBUxmIJBSlhCNQwNKuZl3SsnbdSKz3X4ZqXOqwKtyokwqxMH3Ixk4bob X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(2906002)(7416002)(5660300002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Hv2t4VBh/fTekNrCCxEbhnwN5xwXpXnFtWWfiHCUav6uOcsQVzX6KqCfaQonsANhzEV++NmqlHjWt7Dig6VexTCBZ0EaaEXccJJ35D+6xMAI6xxhXFvqrACL7tNbsIr7nEmTbUiu+fQTX9vmHcWvwZn7oackQNMNxzgQlTxpfCAw57jBe8QT25YPm4M5ZnmZEiQVvNS4lRGeo7cx0lNOTaOA72qM83kfn538wP9GrtM2Mm5sdpCKqMZVLynGlH0DaNbqVKrPEhb+jXc4YY2/o4aRmWLIIceUm3DxmWVaF3zEfHc/KXgULD6bd4dzs2kvObKrJbz59hseq3ganc8D/GpZcnn0b8hoFf6+oozxcgvCgEdtLneJ/8acY+Ua3ppolPYYGlSRlpk9pE5AQO4DDkA++CSIQtoHah5WqJa4vo/IplZJOT0vMpE/B3r6UwGMpp44z47RnrTckLpHBWZLY8mX7s2cO2SNeJ1eKh7pEcSdDVNDwwTzuQE1c+IS794T2gOevDoirJo+SQlGEZwQC6G6F7vcd6D4Pltg/FqsONdiw130Ijc9xGsmfx4WOwStMR7VHX2imyKGL7f1GBgioWNTHleOpVeh4yYVa2xsw00QBcLmficuUt7JExOxs0ZQLyLWSkBxxE7eZFLJ6ynVBjh/3ETqoPFCCAS2VLQGTIQShzrkD+HVFGTJHWHBBlwUl5d0omZ+biPzJSSMVx8gaGUmVCH0ZCiSHmze2dJyiXsakq+bKTwa88wtMu29InhB/lmFHPtsP9ItE0Dd6cij6UOrtcJxNII6+irQ6s0SdjOZ0LeH6NMyPZR9jftQLsXwraNyJyBPoQeTf3Xzytfo3vnR9EOwsre4mdfbX9/rFHqXn17snqkbFnZdAfSVIiIgzVG+dRhObFnq5uQRyZI0Dfc1k5X/qsU2I9ynVcPCtyc55JIbJGiCI+MIb81asaYs8AuL9z/4kCh6KuHHy8dPAVHu/OoKh1RFGwwy0ES5ZAwM0Lsp+97DY6AxRJUr6hF4Y7xDWAtlle7vN7QvKsJ0k6T+9s0D0SvKl5HUT+csDnJW6d9xFbDQhWA0En/JuK8rNSDtm65GixWejljioqY2MulD9ZsgLYwwXEflxp3PzQmdpf8l1/mH9iR8eU++IHCXBsrP4LJPr/sQIgwV2RqvfmQOjyy3joutJf2eU3n6z9vcLcI21cELCoNgCoDGAayKHZncvfN5yuyhbIh8SS+qbUCnQ3RwT9jwVrgYxq1abhiWqPK0DdrKNOl9LwKKa9X9rjo3pHP+hyXJg8/5wa0Iw7rTuCj/ji1ap6pE4X+26nN6FhAIPrpJZO4Lw05gkPZZGiLlj66oGjQT8B5th04mTXBTIUBTR3tzJH+BE/W9kSzJR19hUUWOoUXQlyu8uxU2o1F2PvOi5n3BjkZrVi1tKSExul9maTKCJJaskH20t2gyp6G40aSoZbgdujC6hExLg9pSnmLJHbxp7YpZn8LqgTNJAXQK+bzJw0Z9rLsZ+1qWwORagpH8rqAneuwu8ESdNlEdpbB5xdIPbY4Ot60opMPWJvgo7HXBzhdbLQrhgagb8tHt+KVHOShJmscRY1cL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5657f1b9-f51f-4823-0597-08dba3216601 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:44.4937 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p2S1M7YZxpVEMVB+5sVWwdZ/pDRDGlgoBgnlLB63gI9Ye4Y7NNrp2nI0YMRwzaOWBo9kooaAIHN1/F7ZIoOJDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay NVMEoTCP offload uses buffer registration for ddp operation. Every request comprises from SG list that might consist from elements with multiple combination sizes, thus the appropriate way to perform buffer registration is with KLM UMRs. UMR stands for user-mode memory registration, it is a mechanism to alter address translation properties of MKEY by posting WorkQueueElement aka WQE on send queue. MKEY stands for memory key, MKEY are used to describe a region in memory that can be later used by HW. KLM stands for {Key, Length, MemVa}, KLM_MKEY is indirect MKEY that enables to map multiple memory spaces with different sizes in unified MKEY. KLM UMR is a UMR that use to update a KLM_MKEY. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 3 + .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 123 ++++++++++++++++++ .../mlx5/core/en_accel/nvmeotcp_utils.h | 25 ++++ .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 + 4 files changed, 155 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 3807536932e4..294fdcdb0f6c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -50,6 +50,9 @@ enum mlx5e_icosq_wqe_type { MLX5E_ICOSQ_WQE_SET_PSV_TLS, MLX5E_ICOSQ_WQE_GET_PSV_TLS, #endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + MLX5E_ICOSQ_WQE_UMR_NVMEOTCP, +#endif }; /* General */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index 9ddee04a1327..0fba80b1bb4c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -4,6 +4,7 @@ #include #include #include "en_accel/nvmeotcp.h" +#include "en_accel/nvmeotcp_utils.h" #include "en_accel/fs_tcp.h" #include "en/txrx.h" @@ -19,6 +20,120 @@ static const struct rhashtable_params rhash_queues = { .max_size = MAX_NUM_NVMEOTCP_QUEUES, }; +static void +fill_nvmeotcp_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, u16 ccid, + u32 klm_entries, u16 klm_offset) +{ + struct scatterlist *sgl_mkey; + u32 lkey, i; + + lkey = queue->priv->mdev->mlx5e_res.hw_objs.mkey; + for (i = 0; i < klm_entries; i++) { + sgl_mkey = &queue->ccid_table[ccid].sgl[i + klm_offset]; + wqe->inline_klms[i].bcount = cpu_to_be32(sg_dma_len(sgl_mkey)); + wqe->inline_klms[i].key = cpu_to_be32(lkey); + wqe->inline_klms[i].va = cpu_to_be64(sgl_mkey->dma_address); + } + + for (; i < ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT); i++) { + wqe->inline_klms[i].bcount = 0; + wqe->inline_klms[i].key = 0; + wqe->inline_klms[i].va = 0; + } +} + +static void +build_nvmeotcp_klm_umr(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, + u16 ccid, int klm_entries, u32 klm_offset, u32 len, + enum wqe_type klm_type) +{ + u32 id = (klm_type == KLM_UMR) ? queue->ccid_table[ccid].klm_mkey : + (mlx5e_tir_get_tirn(&queue->tir) << MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT); + u8 opc_mod = (klm_type == KLM_UMR) ? MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR : + MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS; + u32 ds_cnt = MLX5E_KLM_UMR_DS_CNT(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl; + struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; + struct mlx5_mkey_seg *mkc = &wqe->mkc; + u32 sqn = queue->sq.sqn; + u16 pc = queue->sq.pc; + + cseg->opmod_idx_opcode = cpu_to_be32((pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) | + MLX5_OPCODE_UMR | (opc_mod) << 24); + cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | ds_cnt); + cseg->general_id = cpu_to_be32(id); + + if (klm_type == KLM_UMR && !klm_offset) { + ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_XLT_OCT_SIZE | + MLX5_MKEY_MASK_LEN | MLX5_MKEY_MASK_FREE); + mkc->xlt_oct_size = cpu_to_be32(ALIGN(len, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + mkc->len = cpu_to_be64(queue->ccid_table[ccid].size); + } + + ucseg->flags = MLX5_UMR_INLINE | MLX5_UMR_TRANSLATION_OFFSET_EN; + ucseg->xlt_octowords = cpu_to_be16(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + ucseg->xlt_offset = cpu_to_be16(klm_offset); + fill_nvmeotcp_klm_wqe(queue, wqe, ccid, klm_entries, klm_offset); +} + +static void +mlx5e_nvmeotcp_fill_wi(struct mlx5e_icosq *sq, u32 wqebbs, u16 pi) +{ + struct mlx5e_icosq_wqe_info *wi = &sq->db.wqe_info[pi]; + + memset(wi, 0, sizeof(*wi)); + + wi->num_wqebbs = wqebbs; + wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP; +} + +static u32 +post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, + enum wqe_type wqe_type, + u16 ccid, + u32 klm_length, + u32 klm_offset) +{ + struct mlx5e_icosq *sq = &queue->sq; + u32 wqebbs, cur_klm_entries; + struct mlx5e_umr_wqe *wqe; + u16 pi, wqe_sz; + + cur_klm_entries = min_t(int, queue->max_klms_per_wqe, klm_length - klm_offset); + wqe_sz = MLX5E_KLM_UMR_WQE_SZ(ALIGN(cur_klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + wqebbs = DIV_ROUND_UP(wqe_sz, MLX5_SEND_WQE_BB); + pi = mlx5e_icosq_get_next_pi(sq, wqebbs); + wqe = MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi); + mlx5e_nvmeotcp_fill_wi(sq, wqebbs, pi); + build_nvmeotcp_klm_umr(queue, wqe, ccid, cur_klm_entries, klm_offset, + klm_length, wqe_type); + sq->pc += wqebbs; + sq->doorbell_cseg = &wqe->ctrl; + return cur_klm_entries; +} + +static void +mlx5e_nvmeotcp_post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, enum wqe_type wqe_type, + u16 ccid, u32 klm_length) +{ + struct mlx5e_icosq *sq = &queue->sq; + u32 klm_offset = 0, wqes, i; + + wqes = DIV_ROUND_UP(klm_length, queue->max_klms_per_wqe); + + spin_lock_bh(&queue->sq_lock); + + for (i = 0; i < wqes; i++) + klm_offset += post_klm_wqe(queue, wqe_type, ccid, klm_length, klm_offset); + + if (wqe_type == KLM_UMR) /* not asking for completion on ddp_setup UMRs */ + __mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, sq->doorbell_cseg, 0); + else + mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, sq->doorbell_cseg); + + spin_unlock_bh(&queue->sq_lock); +} + static int mlx5e_nvmeotcp_offload_limits(struct net_device *netdev, struct ulp_ddp_limits *limits) @@ -45,6 +160,14 @@ mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, struct sock *sk, struct ulp_ddp_io *ddp) { + struct mlx5e_nvmeotcp_queue *queue; + + queue = container_of(ulp_ddp_get_ctx(sk), + struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + + /* Placeholder - map_sg and initializing the count */ + + mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_UMR, ddp->command_id, 0); return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h new file mode 100644 index 000000000000..6ef92679c5d0 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ +#ifndef __MLX5E_NVMEOTCP_UTILS_H__ +#define __MLX5E_NVMEOTCP_UTILS_H__ + +#include "en.h" + +#define MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi) \ + ((struct mlx5e_umr_wqe *)\ + mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_umr_wqe))) + +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_NVMEOTCP_TIR_PROGRESS_PARAMS 0x4 + +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_TIR_PARAMS 0x2 +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR 0x0 + +enum wqe_type { + KLM_UMR, + BSF_KLM_UMR, + SET_PSV_UMR, + BSF_UMR, + KLM_INV_UMR, +}; + +#endif /* __MLX5E_NVMEOTCP_UTILS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 387eab498b8f..48a9b44752ed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -1044,6 +1044,10 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq, int budget) case MLX5E_ICOSQ_WQE_GET_PSV_TLS: mlx5e_ktls_handle_get_psv_completion(wi, sq); break; +#endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + case MLX5E_ICOSQ_WQE_UMR_NVMEOTCP: + break; #endif default: netdev_WARN_ONCE(cq->netdev, From patchwork Tue Aug 22 15:04:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361052 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 961AC1FD0 for ; Tue, 22 Aug 2023 15:06:57 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4141A19A for ; Tue, 22 Aug 2023 08:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMLyE4JHaId7ykwKtCiNsJamx0eCgLAvMR4pnJ1AuihnL1+Sn2rNJporZELggLXLW20EvgECMIVZk4YvabSCEHd81vWKd68g8YIeiyY9aOPQR5xMQdXdLwxgKHC599CQRq74g8r1RmJsxnetD4qSE0Lcf0R2HZEnzphzpXwg55eCOm4WB3FnDmjyXjuaMGLLQC/uySzV7bX/pPh+41JvHpV0mqIR8HW07gW8cHkM7rnm1ftV4aUMnwSh9MVG6f8mQL6wEAML6fO0Fet/iAO3lSBRMghKnZtwe980jYzdycyVFKw4z1SzDO1ZPRo+MaIJKSq0fq37J5tQmPvHhmyvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fs4EN5FdUYD/fvHZynBI32WoP/4QQ+J5C2Bi38HD5OA=; b=dKZAvG4LmG0PcdEcrfEOhxEVnIFqWUJqDg7YVsYo0QDNU6XXRDUxYxIY4qNcdTrUcUKVnaDOtgjoRKrDJ9ufICxp4xt/BBF79VguCAvT+m535CvBWGvbtUBOhYGt34rTefCj7Xau4PqMCAxfYuoW3rFGQj8lmwT1CPYr/bRj+RPzecVI8dCwvG27esums1zevwIzqlE1NGjAgVlXhshrBMgKDZJS786wB2eKayUQwInJ2Hmz+dJHyTNjnlfUdE0b+ScrPVPt/8+3c6hA30I5wmvvt0640CeMu5P0e8Y6Xo0ihjZLOh9cr0GylwYz7Mi85AbilcDCSiRQwdi8TRB+gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fs4EN5FdUYD/fvHZynBI32WoP/4QQ+J5C2Bi38HD5OA=; b=nPp+0/bQacUT7+Me7kKVIA/Qj+6O57BSBcwaHj3C5sRsf1AQ7phMUN+lo5KGVGZsd4K9S1+qefn+B9MiXA6G4/4Xdr/VuTkkeo5gFbGbhx+Y65Are477Bmu4T66tDOj+GR4HIcJQ8lTD/NOAnKlt0WWIdmjMC5QIuojzP7Exq0M+bUHGki7nNZkzSzYqacclSgRabuvLlqRnp+CXE9Qa5Kn1Xt6H3KRvIWC7VTS+3FSzmeWAXso2fEN+9NBMpaoYfseJvQW+puvu3QNjXivaGA0vfQxU+zeJG5zkVBSqpTGa9amt3gTEEiMvwjNaJr8FFFv5Y4Kq5AjRw5BWERw4+Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:51 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:51 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 20/24] net/mlx5e: NVMEoTCP, queue init/teardown Date: Tue, 22 Aug 2023 15:04:21 +0000 Message-Id: <20230822150425.3390-21-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0127.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::13) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 2267f256-3ab6-4ebe-f383-08dba32169ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UdvJC7RL28Eq0Y0bg//R9s0ouKkZ6JLlaANGSlcQh8ubryBDxIoi9uMKsfUSIK/uNZQyVGpwdgJH5jkrANCWpn0/pD6p8OP670qsy6Etqq8blcQasgNkRVOH7wzn41rlJb77yyKaLdzlO4DbGKhCRs+QK4wmzqgJS8W14WyFgIrSR0uM3q4vqWgKkkqmaPcQKELa77nzB6g6BIbc8c7Y2v/eUHj50Q3csGgi0i/B93xAb4yCwAeaMfwfm6HKpUozMm/MV8DLT7gWP/k/Iv7Xyf+ueQjC9E0fksPjGhUmhhLJEw8DuqmnwdvFI1qlYxXHS6YY2B8sIGObroEOWLDnT820hQPnZYZ5kdmk05MJEUcZmjUjjFVS8KCfLzAneJLRqegCcjFNj1ED/AjboktMLkuWDdbEhRbdS7Muuuk/Py4uqciBmhRYcwnYu7MRUYYzBrI7W9Snyo371fC3dbN4fO7cRAPx8NJQ2AfqaSV458u0e1KMa4sCubM+oPjfJwVhVHpbx7qHPjzioYRB2cjahvY5t5mboQalilpbF9FiM0gZhf+468HtK9IsEVDVj2opDI/Whn5dtgxCe6XW1f+iJhZePP0i2fjhQViIphXBFvEE6ucEIwxaKwGIz/XBKMDY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(186009)(1800799009)(451199024)(66556008)(66476007)(6512007)(316002)(66899024)(2616005)(8676002)(8936002)(4326008)(107886003)(41300700001)(36756003)(1076003)(478600001)(6666004)(66946007)(38100700002)(6506007)(6486002)(83380400001)(30864003)(2906002)(7416002)(5660300002)(86362001)(26005)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZGZGDVbhQKyp0qMGQMnBzk8mFUggiJweAQYGpMosLFTZga+Htk7RWfjEjy2DCETxr90JWca5EFEpxMcYSvHKSu9D+oIUEfE4RgnOsziRqS1DvhU3sH3lz3L+ustxTO6VrTDC4cRIbpDkrhbsi82VdBMVh367QHBnaHTX3U9q5nK5AkquhkSV+pC0A1zSCSKpBWU4KIerGgpVzwU3Oh0oAAT3v6WhB6sk3UXZImPlTLATq0qplqWyz4RR0cE42ZAq5ASZqggSu+6OXYKs09RFugateJJqYBmK7ZKHXIkgXmUduDqpsgxHXYricNYvglh0hRbvqRbanZLSksfvtw5L3QHRe6Hb+qliSTQu4HohYd+35YqL11dvPHaBaYHavzldFZBmnijQua2snOslrqchM8BrDaLss2ine1aeqn0lReP5i4K4NtynCS8jOLdKjSu7Lq06mfJfGoQEWqSy9enA0u41SfNNnmkvzMWPmtZQrAPakw37Dex44AcgXyLMjwq3wLZKiiabE17IPovblbF9kQGQOOlPRTbe667mfBDGm2gFk9M0ujGH3qqgAWRYRwNyA6MuWNmwQyFqipawssUBOZHJVcef7ae/c5iQ3uj5/ulZtJp7PMvZ4ZcaTPvJZk310JG9FtVkAEH0Gw7KrTiJdS83kMuanWge9n1dMnOksirI9Szd7mq7sNf26Iu5/3p7W47HqbA5eBY6TW6cQVuY4wjQ8xI0wMo1zwqHptZAbQ3gsu65dByKO/T23/buf4lzqYq9tyxOo3UXEMLr99Nu3VZCgWsXpZ37Tp60oYemgbUFTLKxpa5/HLkmqXjxYhLYFCfXXQ4JgIxrhLrEA9q22G9Zwk3yP6wTl7a8tIjsH3a6MnB67st1PRGu4NfxJYK1u4INUL61wRnyEAM1gngv3nprVruWmlVjGDrGmVPddCw+1GolaL4aahWeWKEigJOPz2DKdN1N6K2YjE2/5M68+wIfpCZeExcE9rHDdIqNDjr+8zAPGIlGJIcwleGXppOpNpxFeMS+5GKjHLieZqUSuwN8dsWgJMinvxGgtND9/ULUrc0SvmVJPHU/g9D4Ww+fsgvwmhtsfXSW+Oo/wk57twmAW+/geF9JKKeoUmp0CPCSSOC36LC5u1mi6o4Iv6DlqUrbcLMVLhb4loxqRI1W3UV/JjwLs/O+0xaysvFhw/a2chJNO/Kfoie+B/p0j6YlPDFphD4uXNThmqr+iF5keVvZ3KZfJHkFV5iQ0qZxicYnEpclqVZggq6XlAjVQUfE7pnegXcDHuqvwQWfyKEd2wChHSDGFRSgt46XHmqIa9q2Lci+czC5U8qiOYmROtC5+ChrsB+BdVOuhoDTqDyOJFlFbejkM0+1HdL0bGSmC/DMpQk734GKZxeI9RNj/vWvxJAAj09OBaHqEKp4B3crMLzFmDypUmZpHEpl0f+mq4IaH9wKvSuR/5BzpRBiYh7UtJbf/eh6CEJdHN5m7NgxLkNnrOz+GkDKUQCtVk58tLld5hVmB0emnHRx3bXhUE8bLPRoLKHN1kRCHnzwxlS/6hoNaLJEhCtfzTjW4jDpgMxt3kPc4LK0LfjIscVDlMXH X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2267f256-3ab6-4ebe-f383-08dba32169ee X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:51.2218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wrqWfas1X57r/vIK3wKjkR00QP9wV1iUFL75DgpITpWbTVSDVueWkEqW7OfnhGpo36CTkRTHOIMkq1yu/Qf4yw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay Adds the ddp ops of sk_add, sk_del and offload limits. When nvme-tcp establishes new queue/connection, the sk_add op is called. We allocate a hardware context to offload operations for this queue: - use a steering rule based on the connection 5-tuple to mark packets of this queue/connection with a flow-tag in their completion (cqe) - use a dedicated TIR to identify the queue and maintain the HW context - use a dedicated ICOSQ to maintain the HW context by UMR postings - use a dedicated tag buffer for buffer registration - maintain static and progress HW contexts by posting the proper WQEs. When nvme-tcp teardowns a queue/connection, the sk_del op is called. We teardown the queue and free the corresponding contexts. The offload limits we advertise deal with the max SG supported. [Re-enabled calling open/close icosq out of en_main.c] Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 + .../ethernet/mellanox/mlx5/core/en/rx_res.c | 28 + .../ethernet/mellanox/mlx5/core/en/rx_res.h | 4 + .../net/ethernet/mellanox/mlx5/core/en/tir.c | 15 + .../net/ethernet/mellanox/mlx5/core/en/tir.h | 2 + .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 6 + .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 563 +++++++++++++++++- .../mellanox/mlx5/core/en_accel/nvmeotcp.h | 4 + .../mlx5/core/en_accel/nvmeotcp_utils.h | 41 ++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 8 +- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 15 +- 11 files changed, 680 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 819727652f5b..cb537875f332 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -1026,6 +1026,10 @@ int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param); void mlx5e_destroy_rq(struct mlx5e_rq *rq); struct mlx5e_sq_param; +int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *params, + struct mlx5e_sq_param *param, struct mlx5e_icosq *sq, + work_func_t recover_work_func); +void mlx5e_close_icosq(struct mlx5e_icosq *sq); int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params, struct mlx5e_sq_param *param, struct xsk_buff_pool *xsk_pool, struct mlx5e_xdpsq *sq, bool is_redirect); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c index 56e6b8c7501f..ff79e67cffe5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c @@ -626,6 +626,34 @@ struct mlx5e_rss_params_hash mlx5e_rx_res_get_current_hash(struct mlx5e_rx_res * return mlx5e_rss_get_hash(res->rss[0]); } +int mlx5e_rx_res_nvmeotcp_tir_create(struct mlx5e_rx_res *res, unsigned int rxq, bool crc_rx, + u32 tag_buf_id, struct mlx5e_tir *tir) +{ + bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT; + struct mlx5e_tir_builder *builder; + u32 rqtn; + int err; + + builder = mlx5e_tir_builder_alloc(false); + if (!builder) + return -ENOMEM; + + rqtn = mlx5e_rx_res_get_rqtn_direct(res, rxq); + + mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn, rqtn, + inner_ft_support); + mlx5e_tir_builder_build_direct(builder); + mlx5e_tir_builder_build_nvmeotcp(builder, crc_rx, tag_buf_id); + down_read(&res->pkt_merge_param_sem); + mlx5e_tir_builder_build_packet_merge(builder, &res->pkt_merge_param); + err = mlx5e_tir_init(tir, builder, res->mdev, false); + up_read(&res->pkt_merge_param_sem); + + mlx5e_tir_builder_free(builder); + + return err; +} + int mlx5e_rx_res_tls_tir_create(struct mlx5e_rx_res *res, unsigned int rxq, struct mlx5e_tir *tir) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h index 580fe8bc3cd2..19c158346e13 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h @@ -67,4 +67,8 @@ struct mlx5e_rss_params_hash mlx5e_rx_res_get_current_hash(struct mlx5e_rx_res * /* Accel TIRs */ int mlx5e_rx_res_tls_tir_create(struct mlx5e_rx_res *res, unsigned int rxq, struct mlx5e_tir *tir); + +int mlx5e_rx_res_nvmeotcp_tir_create(struct mlx5e_rx_res *res, unsigned int rxq, bool crc_rx, + u32 tag_buf_id, struct mlx5e_tir *tir); + #endif /* __MLX5_EN_RX_RES_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c index d4239e3b3c88..8bdf74cbd8cd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c @@ -143,6 +143,21 @@ void mlx5e_tir_builder_build_direct(struct mlx5e_tir_builder *builder) MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8); } +void mlx5e_tir_builder_build_nvmeotcp(struct mlx5e_tir_builder *builder, bool crc_rx, + u32 tag_buf_id) +{ + void *tirc = mlx5e_tir_builder_get_tirc(builder); + + WARN_ON(builder->modify); + + MLX5_SET(tirc, tirc, nvmeotcp_zero_copy_en, 1); + MLX5_SET(tirc, tirc, nvmeotcp_tag_buffer_table_id, tag_buf_id); + MLX5_SET(tirc, tirc, nvmeotcp_crc_en, !!crc_rx); + MLX5_SET(tirc, tirc, self_lb_block, + MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST | + MLX5_TIRC_SELF_LB_BLOCK_BLOCK_MULTICAST); +} + void mlx5e_tir_builder_build_tls(struct mlx5e_tir_builder *builder) { void *tirc = mlx5e_tir_builder_get_tirc(builder); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h index 857a84bcd53a..bdec6931444b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h @@ -35,6 +35,8 @@ void mlx5e_tir_builder_build_rss(struct mlx5e_tir_builder *builder, bool inner); void mlx5e_tir_builder_build_direct(struct mlx5e_tir_builder *builder); void mlx5e_tir_builder_build_tls(struct mlx5e_tir_builder *builder); +void mlx5e_tir_builder_build_nvmeotcp(struct mlx5e_tir_builder *builder, bool crc_rx, + u32 tag_buf_id); struct mlx5_core_dev; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 294fdcdb0f6c..c87dca17d5c8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -52,6 +52,7 @@ enum mlx5e_icosq_wqe_type { #endif #ifdef CONFIG_MLX5_EN_NVMEOTCP MLX5E_ICOSQ_WQE_UMR_NVMEOTCP, + MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP, #endif }; @@ -224,6 +225,11 @@ struct mlx5e_icosq_wqe_info { struct { struct mlx5e_ktls_rx_resync_buf *buf; } tls_get_params; +#endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + struct { + struct mlx5e_nvmeotcp_queue *queue; + } nvmeotcp_q; #endif }; }; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index 0fba80b1bb4c..770d3f2878bf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -3,6 +3,7 @@ #include #include +#include #include "en_accel/nvmeotcp.h" #include "en_accel/nvmeotcp_utils.h" #include "en_accel/fs_tcp.h" @@ -11,6 +12,11 @@ #define MAX_NUM_NVMEOTCP_QUEUES (4000) #define MIN_NUM_NVMEOTCP_QUEUES (1) +/* Max PDU data will be 512K */ +#define MLX5E_NVMEOTCP_MAX_SEGMENTS (128) +#define MLX5E_NVMEOTCP_IO_THRESHOLD (32 * 1024) +#define MLX5E_NVMEOTCP_FULL_CCID_RANGE (0) + static const struct rhashtable_params rhash_queues = { .key_len = sizeof(int), .key_offset = offsetof(struct mlx5e_nvmeotcp_queue, id), @@ -20,6 +26,95 @@ static const struct rhashtable_params rhash_queues = { .max_size = MAX_NUM_NVMEOTCP_QUEUES, }; +static u32 mlx5e_get_max_sgl(struct mlx5_core_dev *mdev) +{ + return min_t(u32, + MLX5E_NVMEOTCP_MAX_SEGMENTS, + 1 << MLX5_CAP_GEN(mdev, log_max_klm_list_size)); +} + +static u32 +mlx5e_get_channel_ix_from_io_cpu(struct mlx5e_params *params, u32 io_cpu) +{ + int num_channels = params->num_channels; + u32 channel_ix = io_cpu; + + if (channel_ix >= num_channels) + channel_ix = channel_ix % num_channels; + + return channel_ix; +} + +static +int mlx5e_create_nvmeotcp_tag_buf_table(struct mlx5_core_dev *mdev, + struct mlx5e_nvmeotcp_queue *queue, + u8 log_table_size) +{ + u32 in[MLX5_ST_SZ_DW(create_nvmeotcp_tag_buf_table_in)] = {}; + u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; + u64 general_obj_types; + void *obj; + int err; + + obj = MLX5_ADDR_OF(create_nvmeotcp_tag_buf_table_in, in, + nvmeotcp_tag_buf_table_obj); + + general_obj_types = MLX5_CAP_GEN_64(mdev, general_obj_types); + if (!(general_obj_types & + MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_NVMEOTCP_TAG_BUFFER_TABLE)) + return -EINVAL; + + MLX5_SET(general_obj_in_cmd_hdr, in, opcode, + MLX5_CMD_OP_CREATE_GENERAL_OBJECT); + MLX5_SET(general_obj_in_cmd_hdr, in, obj_type, + MLX5_GENERAL_OBJECT_TYPES_NVMEOTCP_TAG_BUFFER_TABLE); + MLX5_SET(nvmeotcp_tag_buf_table_obj, obj, + log_tag_buffer_table_size, log_table_size); + + err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); + if (!err) + queue->tag_buf_table_id = MLX5_GET(general_obj_out_cmd_hdr, + out, obj_id); + return err; +} + +static +void mlx5_destroy_nvmeotcp_tag_buf_table(struct mlx5_core_dev *mdev, u32 uid) +{ + u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {}; + u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; + + MLX5_SET(general_obj_in_cmd_hdr, in, opcode, + MLX5_CMD_OP_DESTROY_GENERAL_OBJECT); + MLX5_SET(general_obj_in_cmd_hdr, in, obj_type, + MLX5_GENERAL_OBJECT_TYPES_NVMEOTCP_TAG_BUFFER_TABLE); + MLX5_SET(general_obj_in_cmd_hdr, in, obj_id, uid); + + mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); +} + +static void +fill_nvmeotcp_bsf_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, + u16 ccid, u32 klm_entries, u16 klm_offset) +{ + u32 i; + + /* BSF_KLM_UMR is used to update the tag_buffer. To spare the + * need to update both mkc.length and tag_buffer[i].len in two + * different UMRs we initialize the tag_buffer[*].len to the + * maximum size of an entry so the HW check will pass and the + * validity of the MKEY len will be checked against the + * updated mkey context field. + */ + for (i = 0; i < klm_entries; i++) { + u32 lkey = queue->ccid_table[i + klm_offset].klm_mkey; + + wqe->inline_klms[i].bcount = cpu_to_be32(U32_MAX); + wqe->inline_klms[i].key = cpu_to_be32(lkey); + wqe->inline_klms[i].va = 0; + } +} + static void fill_nvmeotcp_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, u16 ccid, u32 klm_entries, u16 klm_offset) @@ -73,18 +168,149 @@ build_nvmeotcp_klm_umr(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe ucseg->flags = MLX5_UMR_INLINE | MLX5_UMR_TRANSLATION_OFFSET_EN; ucseg->xlt_octowords = cpu_to_be16(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); ucseg->xlt_offset = cpu_to_be16(klm_offset); - fill_nvmeotcp_klm_wqe(queue, wqe, ccid, klm_entries, klm_offset); + if (klm_type == BSF_KLM_UMR) + fill_nvmeotcp_bsf_klm_wqe(queue, wqe, ccid, klm_entries, klm_offset); + else + fill_nvmeotcp_klm_wqe(queue, wqe, ccid, klm_entries, klm_offset); +} + +static void +fill_nvmeotcp_progress_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5_seg_nvmeotcp_progress_params *params, + u32 seq) +{ + void *ctx = params->ctx; + + params->tir_num = cpu_to_be32(mlx5e_tir_get_tirn(&queue->tir)); + + MLX5_SET(nvmeotcp_progress_params, ctx, next_pdu_tcp_sn, seq); + MLX5_SET(nvmeotcp_progress_params, ctx, pdu_tracker_state, + MLX5E_NVMEOTCP_PROGRESS_PARAMS_PDU_TRACKER_STATE_START); +} + +void +build_nvmeotcp_progress_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_set_nvmeotcp_progress_params_wqe *wqe, + u32 seq) +{ + struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; + u32 sqn = queue->sq.sqn; + u16 pc = queue->sq.pc; + u8 opc_mod; + + memset(wqe, 0, MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQE_SZ); + opc_mod = MLX5_CTRL_SEGMENT_OPC_MOD_UMR_NVMEOTCP_TIR_PROGRESS_PARAMS; + cseg->opmod_idx_opcode = cpu_to_be32((pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) | + MLX5_OPCODE_SET_PSV | (opc_mod << 24)); + cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | + PROGRESS_PARAMS_DS_CNT); + fill_nvmeotcp_progress_params(queue, &wqe->params, seq); +} + +static void +fill_nvmeotcp_static_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5_wqe_transport_static_params_seg *params, + u32 resync_seq, bool ddgst_offload_en) +{ + void *ctx = params->ctx; + + MLX5_SET(transport_static_params, ctx, const_1, 1); + MLX5_SET(transport_static_params, ctx, const_2, 2); + MLX5_SET(transport_static_params, ctx, acc_type, + MLX5_TRANSPORT_STATIC_PARAMS_ACC_TYPE_NVMETCP); + MLX5_SET(transport_static_params, ctx, nvme_resync_tcp_sn, resync_seq); + MLX5_SET(transport_static_params, ctx, pda, queue->pda); + MLX5_SET(transport_static_params, ctx, ddgst_en, + !!(queue->dgst & NVME_TCP_DATA_DIGEST_ENABLE)); + MLX5_SET(transport_static_params, ctx, ddgst_offload_en, ddgst_offload_en); + MLX5_SET(transport_static_params, ctx, hddgst_en, + !!(queue->dgst & NVME_TCP_HDR_DIGEST_ENABLE)); + MLX5_SET(transport_static_params, ctx, hdgst_offload_en, 0); + MLX5_SET(transport_static_params, ctx, ti, + MLX5_TRANSPORT_STATIC_PARAMS_TI_INITIATOR); + MLX5_SET(transport_static_params, ctx, cccid_ttag, 1); + MLX5_SET(transport_static_params, ctx, zero_copy_en, 1); +} + +void +build_nvmeotcp_static_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_set_transport_static_params_wqe *wqe, + u32 resync_seq, bool crc_rx) +{ + u8 opc_mod = MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS; + struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl; + struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; + u32 sqn = queue->sq.sqn; + u16 pc = queue->sq.pc; + + memset(wqe, 0, MLX5E_TRANSPORT_STATIC_PARAMS_WQE_SZ); + + cseg->opmod_idx_opcode = cpu_to_be32((pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) | + MLX5_OPCODE_UMR | (opc_mod) << 24); + cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | + MLX5E_TRANSPORT_STATIC_PARAMS_DS_CNT); + cseg->imm = cpu_to_be32(mlx5e_tir_get_tirn(&queue->tir) + << MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT); + + ucseg->flags = MLX5_UMR_INLINE; + ucseg->bsf_octowords = cpu_to_be16(MLX5E_TRANSPORT_STATIC_PARAMS_OCTWORD_SIZE); + fill_nvmeotcp_static_params(queue, &wqe->params, resync_seq, crc_rx); } static void -mlx5e_nvmeotcp_fill_wi(struct mlx5e_icosq *sq, u32 wqebbs, u16 pi) +mlx5e_nvmeotcp_fill_wi(struct mlx5e_nvmeotcp_queue *nvmeotcp_queue, + struct mlx5e_icosq *sq, u32 wqebbs, u16 pi, + enum wqe_type type) { struct mlx5e_icosq_wqe_info *wi = &sq->db.wqe_info[pi]; memset(wi, 0, sizeof(*wi)); wi->num_wqebbs = wqebbs; - wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP; + switch (type) { + case SET_PSV_UMR: + wi->wqe_type = MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP; + wi->nvmeotcp_q.queue = nvmeotcp_queue; + break; + default: + /* cases where no further action is required upon completion, such as ddp setup */ + wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP; + break; + } +} + +static void +mlx5e_nvmeotcp_rx_post_static_params_wqe(struct mlx5e_nvmeotcp_queue *queue, u32 resync_seq) +{ + struct mlx5e_set_transport_static_params_wqe *wqe; + struct mlx5e_icosq *sq = &queue->sq; + u16 pi, wqebbs; + + spin_lock_bh(&queue->sq_lock); + wqebbs = MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS; + pi = mlx5e_icosq_get_next_pi(sq, wqebbs); + wqe = MLX5E_TRANSPORT_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); + mlx5e_nvmeotcp_fill_wi(NULL, sq, wqebbs, pi, BSF_UMR); + build_nvmeotcp_static_params(queue, wqe, resync_seq, queue->crc_rx); + sq->pc += wqebbs; + mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &wqe->ctrl); + spin_unlock_bh(&queue->sq_lock); +} + +static void +mlx5e_nvmeotcp_rx_post_progress_params_wqe(struct mlx5e_nvmeotcp_queue *queue, u32 seq) +{ + struct mlx5e_set_nvmeotcp_progress_params_wqe *wqe; + struct mlx5e_icosq *sq = &queue->sq; + u16 pi, wqebbs; + + wqebbs = MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQEBBS; + pi = mlx5e_icosq_get_next_pi(sq, wqebbs); + wqe = MLX5E_NVMEOTCP_FETCH_PROGRESS_PARAMS_WQE(sq, pi); + mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, SET_PSV_UMR); + build_nvmeotcp_progress_params(queue, wqe, seq); + sq->pc += wqebbs; + mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &wqe->ctrl); } static u32 @@ -104,7 +330,7 @@ post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, wqebbs = DIV_ROUND_UP(wqe_sz, MLX5_SEND_WQE_BB); pi = mlx5e_icosq_get_next_pi(sq, wqebbs); wqe = MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi); - mlx5e_nvmeotcp_fill_wi(sq, wqebbs, pi); + mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, wqe_type); build_nvmeotcp_klm_umr(queue, wqe, ccid, cur_klm_entries, klm_offset, klm_length, wqe_type); sq->pc += wqebbs; @@ -134,25 +360,327 @@ mlx5e_nvmeotcp_post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, enum wqe_type wq spin_unlock_bh(&queue->sq_lock); } +static int mlx5e_create_nvmeotcp_mkey(struct mlx5_core_dev *mdev, u8 access_mode, + u32 translation_octword_size, u32 *mkey) +{ + int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); + void *mkc; + u32 *in; + int err; + + in = kvzalloc(inlen, GFP_KERNEL); + if (!in) + return -ENOMEM; + + mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry); + MLX5_SET(mkc, mkc, free, 1); + MLX5_SET(mkc, mkc, translations_octword_size, translation_octword_size); + MLX5_SET(mkc, mkc, umr_en, 1); + MLX5_SET(mkc, mkc, lw, 1); + MLX5_SET(mkc, mkc, lr, 1); + MLX5_SET(mkc, mkc, access_mode_1_0, access_mode); + + MLX5_SET(mkc, mkc, qpn, 0xffffff); + MLX5_SET(mkc, mkc, pd, mdev->mlx5e_res.hw_objs.pdn); + + err = mlx5_core_create_mkey(mdev, mkey, in, inlen); + + kvfree(in); + return err; +} + static int mlx5e_nvmeotcp_offload_limits(struct net_device *netdev, struct ulp_ddp_limits *limits) { + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + + if (limits->type != ULP_DDP_NVME) + return -EOPNOTSUPP; + + limits->max_ddp_sgl_len = mlx5e_get_max_sgl(mdev); + limits->io_threshold = MLX5E_NVMEOTCP_IO_THRESHOLD; + limits->tls = false; + limits->nvmeotcp.full_ccid_range = MLX5E_NVMEOTCP_FULL_CCID_RANGE; return 0; } +static int mlx5e_nvmeotcp_queue_handler_poll(struct napi_struct *napi, int budget) +{ + struct mlx5e_nvmeotcp_queue_handler *qh; + int work_done; + + qh = container_of(napi, struct mlx5e_nvmeotcp_queue_handler, napi); + + work_done = mlx5e_poll_ico_cq(qh->cq, budget); + + if (work_done == budget || !napi_complete_done(napi, work_done)) + goto out; + + mlx5e_cq_arm(qh->cq); + +out: + return work_done; +} + +static void +mlx5e_nvmeotcp_destroy_icosq(struct mlx5e_icosq *sq) +{ + mlx5e_close_icosq(sq); + mlx5e_close_cq(&sq->cq); +} + +static void mlx5e_nvmeotcp_icosq_err_cqe_work(struct work_struct *recover_work) +{ + struct mlx5e_icosq *sq = container_of(recover_work, struct mlx5e_icosq, recover_work); + + /* Not implemented yet. */ + + netdev_warn(sq->channel->netdev, "nvmeotcp icosq recovery is not implemented\n"); +} + +static int +mlx5e_nvmeotcp_build_icosq(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_priv *priv, int io_cpu) +{ + u16 max_sgl, max_klm_per_wqe, max_umr_per_ccid, sgl_rest, wqebbs_rest; + struct mlx5e_channel *c = priv->channels.c[queue->channel_ix]; + struct mlx5e_sq_param icosq_param = {}; + struct mlx5e_create_cq_param ccp = {}; + struct dim_cq_moder icocq_moder = {}; + struct mlx5e_icosq *icosq; + int err = -ENOMEM; + u16 log_icosq_sz; + u32 max_wqebbs; + + icosq = &queue->sq; + max_sgl = mlx5e_get_max_sgl(priv->mdev); + max_klm_per_wqe = queue->max_klms_per_wqe; + max_umr_per_ccid = max_sgl / max_klm_per_wqe; + sgl_rest = max_sgl % max_klm_per_wqe; + wqebbs_rest = sgl_rest ? MLX5E_KLM_UMR_WQEBBS(sgl_rest) : 0; + max_wqebbs = (MLX5E_KLM_UMR_WQEBBS(max_klm_per_wqe) * + max_umr_per_ccid + wqebbs_rest) * queue->size; + log_icosq_sz = order_base_2(max_wqebbs); + + mlx5e_build_icosq_param(priv->mdev, log_icosq_sz, &icosq_param); + ccp.napi = &queue->qh.napi; + ccp.ch_stats = &priv->channel_stats[queue->channel_ix]->ch; + ccp.node = cpu_to_node(io_cpu); + ccp.ix = queue->channel_ix; + + err = mlx5e_open_cq(priv, icocq_moder, &icosq_param.cqp, &ccp, &icosq->cq); + if (err) + goto err_nvmeotcp_sq; + err = mlx5e_open_icosq(c, &priv->channels.params, &icosq_param, icosq, + mlx5e_nvmeotcp_icosq_err_cqe_work); + if (err) + goto close_cq; + + spin_lock_init(&queue->sq_lock); + return 0; + +close_cq: + mlx5e_close_cq(&icosq->cq); +err_nvmeotcp_sq: + return err; +} + +static void +mlx5e_nvmeotcp_destroy_rx(struct mlx5e_priv *priv, struct mlx5e_nvmeotcp_queue *queue, + struct mlx5_core_dev *mdev) +{ + int i; + + mlx5e_accel_fs_del_sk(queue->fh); + + for (i = 0; i < queue->size; i++) + mlx5_core_destroy_mkey(mdev, queue->ccid_table[i].klm_mkey); + + mlx5e_tir_destroy(&queue->tir); + mlx5_destroy_nvmeotcp_tag_buf_table(mdev, queue->tag_buf_table_id); + + mlx5e_deactivate_icosq(&queue->sq); + napi_disable(&queue->qh.napi); + mlx5e_nvmeotcp_destroy_icosq(&queue->sq); + netif_napi_del(&queue->qh.napi); +} + +static int +mlx5e_nvmeotcp_queue_rx_init(struct mlx5e_nvmeotcp_queue *queue, + struct nvme_tcp_ddp_config *config, + struct net_device *netdev) +{ + u8 log_queue_size = order_base_2(config->queue_size); + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct sock *sk = queue->sk; + int err, max_sgls, i; + + if (config->queue_size > + BIT(MLX5_CAP_DEV_NVMEOTCP(mdev, log_max_nvmeotcp_tag_buffer_size))) + return -EINVAL; + + err = mlx5e_create_nvmeotcp_tag_buf_table(mdev, queue, log_queue_size); + if (err) + return err; + + queue->qh.cq = &queue->sq.cq; + netif_napi_add(priv->netdev, &queue->qh.napi, mlx5e_nvmeotcp_queue_handler_poll); + + mutex_lock(&priv->state_lock); + err = mlx5e_nvmeotcp_build_icosq(queue, priv, config->io_cpu); + mutex_unlock(&priv->state_lock); + if (err) + goto del_napi; + + napi_enable(&queue->qh.napi); + mlx5e_activate_icosq(&queue->sq); + + /* initializes queue->tir */ + err = mlx5e_rx_res_nvmeotcp_tir_create(priv->rx_res, queue->channel_ix, queue->crc_rx, + queue->tag_buf_table_id, &queue->tir); + if (err) + goto destroy_icosq; + + mlx5e_nvmeotcp_rx_post_static_params_wqe(queue, 0); + mlx5e_nvmeotcp_rx_post_progress_params_wqe(queue, tcp_sk(sk)->copied_seq); + + queue->ccid_table = kcalloc(queue->size, sizeof(struct mlx5e_nvmeotcp_queue_entry), + GFP_KERNEL); + if (!queue->ccid_table) { + err = -ENOMEM; + goto destroy_tir; + } + + max_sgls = mlx5e_get_max_sgl(mdev); + for (i = 0; i < queue->size; i++) { + err = mlx5e_create_nvmeotcp_mkey(mdev, MLX5_MKC_ACCESS_MODE_KLMS, max_sgls, + &queue->ccid_table[i].klm_mkey); + if (err) + goto free_ccid_table; + } + + mlx5e_nvmeotcp_post_klm_wqe(queue, BSF_KLM_UMR, 0, queue->size); + + if (!(WARN_ON(!wait_for_completion_timeout(&queue->static_params_done, + msecs_to_jiffies(3000))))) + queue->fh = mlx5e_accel_fs_add_sk(priv->fs, sk, mlx5e_tir_get_tirn(&queue->tir), + queue->id); + + if (IS_ERR_OR_NULL(queue->fh)) { + err = -EINVAL; + goto destroy_mkeys; + } + + return 0; + +destroy_mkeys: + while ((i--)) + mlx5_core_destroy_mkey(mdev, queue->ccid_table[i].klm_mkey); +free_ccid_table: + kfree(queue->ccid_table); +destroy_tir: + mlx5e_tir_destroy(&queue->tir); +destroy_icosq: + mlx5e_deactivate_icosq(&queue->sq); + napi_disable(&queue->qh.napi); + mlx5e_nvmeotcp_destroy_icosq(&queue->sq); +del_napi: + netif_napi_del(&queue->qh.napi); + mlx5_destroy_nvmeotcp_tag_buf_table(mdev, queue->tag_buf_table_id); + + return err; +} + static int mlx5e_nvmeotcp_queue_init(struct net_device *netdev, struct sock *sk, struct ulp_ddp_config *tconfig) { + struct nvme_tcp_ddp_config *config = &tconfig->nvmeotcp; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct mlx5e_nvmeotcp_queue *queue; + int queue_id, err; + + if (tconfig->type != ULP_DDP_NVME) { + err = -EOPNOTSUPP; + goto out; + } + + queue = kzalloc(sizeof(*queue), GFP_KERNEL); + if (!queue) { + err = -ENOMEM; + goto out; + } + + queue_id = ida_simple_get(&priv->nvmeotcp->queue_ids, + MIN_NUM_NVMEOTCP_QUEUES, MAX_NUM_NVMEOTCP_QUEUES, + GFP_KERNEL); + if (queue_id < 0) { + err = -ENOSPC; + goto free_queue; + } + + queue->crc_rx = !!(config->dgst & NVME_TCP_DATA_DIGEST_ENABLE); + queue->ulp_ddp_ctx.type = ULP_DDP_NVME; + queue->sk = sk; + queue->id = queue_id; + queue->dgst = config->dgst; + queue->pda = config->cpda; + queue->channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, + config->io_cpu); + queue->size = config->queue_size; + queue->max_klms_per_wqe = MLX5E_MAX_KLM_PER_WQE(mdev); + queue->priv = priv; + init_completion(&queue->static_params_done); + + err = mlx5e_nvmeotcp_queue_rx_init(queue, config, netdev); + if (err) + goto remove_queue_id; + + err = rhashtable_insert_fast(&priv->nvmeotcp->queue_hash, &queue->hash, + rhash_queues); + if (err) + goto destroy_rx; + + write_lock_bh(&sk->sk_callback_lock); + ulp_ddp_set_ctx(sk, queue); + write_unlock_bh(&sk->sk_callback_lock); + refcount_set(&queue->ref_count, 1); return 0; + +destroy_rx: + mlx5e_nvmeotcp_destroy_rx(priv, queue, mdev); +remove_queue_id: + ida_simple_remove(&priv->nvmeotcp->queue_ids, queue_id); +free_queue: + kfree(queue); +out: + return err; } static void mlx5e_nvmeotcp_queue_teardown(struct net_device *netdev, struct sock *sk) { + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct mlx5e_nvmeotcp_queue *queue; + + queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + + WARN_ON(refcount_read(&queue->ref_count) != 1); + mlx5e_nvmeotcp_destroy_rx(priv, queue, mdev); + + rhashtable_remove_fast(&priv->nvmeotcp->queue_hash, &queue->hash, + rhash_queues); + ida_simple_remove(&priv->nvmeotcp->queue_ids, queue->id); + write_lock_bh(&sk->sk_callback_lock); + ulp_ddp_set_ctx(sk, NULL); + write_unlock_bh(&sk->sk_callback_lock); + mlx5e_nvmeotcp_put_queue(queue); } static int @@ -171,6 +699,13 @@ mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, return 0; } +void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi) +{ + struct mlx5e_nvmeotcp_queue *queue = wi->nvmeotcp_q.queue; + + complete(&queue->static_params_done); +} + static void mlx5e_nvmeotcp_ddp_teardown(struct net_device *netdev, struct sock *sk, @@ -185,6 +720,26 @@ mlx5e_nvmeotcp_ddp_resync(struct net_device *netdev, { } +struct mlx5e_nvmeotcp_queue * +mlx5e_nvmeotcp_get_queue(struct mlx5e_nvmeotcp *nvmeotcp, int id) +{ + struct mlx5e_nvmeotcp_queue *queue; + + queue = rhashtable_lookup_fast(&nvmeotcp->queue_hash, + &id, rhash_queues); + if (!IS_ERR_OR_NULL(queue)) + refcount_inc(&queue->ref_count); + return queue; +} + +void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue) +{ + if (refcount_dec_and_test(&queue->ref_count)) { + kfree(queue->ccid_table); + kfree(queue); + } +} + int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable) { struct mlx5e_priv *priv = netdev_priv(netdev); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h index a665b7a72bc2..555f3ed7e2e2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h @@ -106,6 +106,10 @@ void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv); int mlx5e_nvmeotcp_init(struct mlx5e_priv *priv); int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable); void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv); +struct mlx5e_nvmeotcp_queue * +mlx5e_nvmeotcp_get_queue(struct mlx5e_nvmeotcp *nvmeotcp, int id); +void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue); +void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi); static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv); extern const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h index 6ef92679c5d0..fdb194c30e3b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h @@ -4,6 +4,35 @@ #define __MLX5E_NVMEOTCP_UTILS_H__ #include "en.h" +#include "en_accel/nvmeotcp.h" +#include "en_accel/common_utils.h" + +enum { + MLX5E_NVMEOTCP_PROGRESS_PARAMS_PDU_TRACKER_STATE_START = 0, + MLX5E_NVMEOTCP_PROGRESS_PARAMS_PDU_TRACKER_STATE_TRACKING = 1, + MLX5E_NVMEOTCP_PROGRESS_PARAMS_PDU_TRACKER_STATE_SEARCHING = 2, +}; + +struct mlx5_seg_nvmeotcp_progress_params { + __be32 tir_num; + u8 ctx[MLX5_ST_SZ_BYTES(nvmeotcp_progress_params)]; +}; + +struct mlx5e_set_nvmeotcp_progress_params_wqe { + struct mlx5_wqe_ctrl_seg ctrl; + struct mlx5_seg_nvmeotcp_progress_params params; +}; + +/* macros for wqe handling */ +#define MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQE_SZ \ + (sizeof(struct mlx5e_set_nvmeotcp_progress_params_wqe)) + +#define MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQEBBS \ + (DIV_ROUND_UP(MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQE_SZ, MLX5_SEND_WQE_BB)) + +#define MLX5E_NVMEOTCP_FETCH_PROGRESS_PARAMS_WQE(sq, pi) \ + ((struct mlx5e_set_nvmeotcp_progress_params_wqe *)\ + mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_set_nvmeotcp_progress_params_wqe))) #define MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi) \ ((struct mlx5e_umr_wqe *)\ @@ -14,6 +43,9 @@ #define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_TIR_PARAMS 0x2 #define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR 0x0 +#define PROGRESS_PARAMS_DS_CNT \ + DIV_ROUND_UP(MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQE_SZ, MLX5_SEND_WQE_DS) + enum wqe_type { KLM_UMR, BSF_KLM_UMR, @@ -22,4 +54,13 @@ enum wqe_type { KLM_INV_UMR, }; +void +build_nvmeotcp_progress_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_set_nvmeotcp_progress_params_wqe *wqe, u32 seq); + +void +build_nvmeotcp_static_params(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_set_transport_static_params_wqe *wqe, + u32 resync_seq, bool crc_rx); + #endif /* __MLX5E_NVMEOTCP_UTILS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index fd0e6f4f1ae6..bd930940e6a9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1789,9 +1789,9 @@ void mlx5e_tx_err_cqe_work(struct work_struct *recover_work) mlx5e_reporter_tx_err_cqe(sq); } -static int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *params, - struct mlx5e_sq_param *param, struct mlx5e_icosq *sq, - work_func_t recover_work_func) +int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *params, + struct mlx5e_sq_param *param, struct mlx5e_icosq *sq, + work_func_t recover_work_func) { struct mlx5e_create_sq_param csp = {}; int err; @@ -1835,7 +1835,7 @@ void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq) synchronize_net(); /* Sync with NAPI. */ } -static void mlx5e_close_icosq(struct mlx5e_icosq *sq) +void mlx5e_close_icosq(struct mlx5e_icosq *sq) { if (sq->ktls_resync) mlx5e_ktls_rx_resync_destroy_resp_list(sq->ktls_resync); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 48a9b44752ed..87ad443e73f8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -53,6 +53,7 @@ #include "en_accel/macsec.h" #include "en_accel/ipsec_rxtx.h" #include "en_accel/ktls_txrx.h" +#include "en_accel/nvmeotcp.h" #include "en/xdp.h" #include "en/xsk/rx.h" #include "en/health.h" @@ -940,16 +941,23 @@ void mlx5e_free_icosq_descs(struct mlx5e_icosq *sq) ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sqcc); wi = &sq->db.wqe_info[ci]; sqcc += wi->num_wqebbs; -#ifdef CONFIG_MLX5_EN_TLS switch (wi->wqe_type) { +#ifdef CONFIG_MLX5_EN_TLS case MLX5E_ICOSQ_WQE_SET_PSV_TLS: mlx5e_ktls_handle_ctx_completion(wi); break; case MLX5E_ICOSQ_WQE_GET_PSV_TLS: mlx5e_ktls_handle_get_psv_completion(wi, sq); break; - } #endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + case MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP: + mlx5e_nvmeotcp_ctx_complete(wi); + break; +#endif + default: + break; + } } sq->cc = sqcc; } @@ -1048,6 +1056,9 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq, int budget) #ifdef CONFIG_MLX5_EN_NVMEOTCP case MLX5E_ICOSQ_WQE_UMR_NVMEOTCP: break; + case MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP: + mlx5e_nvmeotcp_ctx_complete(wi); + break; #endif default: netdev_WARN_ONCE(cq->netdev, From patchwork Tue Aug 22 15:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361053 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 DD7141FD0 for ; Tue, 22 Aug 2023 15:07:02 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E6619A for ; Tue, 22 Aug 2023 08:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k61ELey94anSkCy9ipk3AahlOj8nQfr+LjuDTDmuOBLoTVprNV5sKGm0Tev8oTbI371DhclxddFOi5IRMnmMM4dLLgRt1OOak0Iy//lrnIUVk28SwNO5m6u8XEJGOuFCmaFg4fKAliz/u7UQ3oqL09EV+HFnpKVFXejm7Be8a+HWDNshON8oY2ewL2F6E6Hjt+eociRGAy/9SrtrM4yGJaxyRIowptIfe+W+W9zGn0Yr03tZqsmpa5O9mZHY9GH7rNYSRMQP6/2RYh7gG7QQ2Wr2ZEYNDRuYjtWIMxvabwn95WwF67oYu3ZypVYHHvWji3bkR1m4P3YcHk4UbVmm4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xPtZQbSkiI1HYDJVJf0Fl/rVAs+l6vYqpxRJ+jbxOw0=; b=a/Jm9aQKkERuh2vpHGJNEisLgJu8bYu0+0rSf+lSYZ1TwSazZzUUTqm4SPav4BzLHhIiO1DVXUiQ460yCYcOC41FChYgIwPvHtX58VNghIkv3kDXLsAOlUkUS+vXZokai9GS5Y24+XA4p5Q1TefvaB6xqShJ5L3JCD+ICvLAP+XehC3YOurqCVfUJFuo3rranjS8kiKD2oyuAj8q7va1E7L3oZPcJYS2LY6lt5SiXWN4poJRNVeAuu9Nd3QK1WV0RMohjDSCOoFe7N3Kpv4NY7sNzjvdqyjh/b39tFlJRglxghvmCxWyI83jphy3ZVRjRZmg21BW2HIV8Hsk2ELGGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xPtZQbSkiI1HYDJVJf0Fl/rVAs+l6vYqpxRJ+jbxOw0=; b=eCV9vXb9rw2J9ANPQTHJyRibsutoafHsStunmCukSFgcUgbJvnEoG/RDGOvt4fnAvSgHhsS0KYa9eElS7PoloFF6akAQz68eqThxWdXWB8t2kBa0RtDlpXHhHgl2DaIVPnrFnV8NmPXD+PvwUMrAem0c/EdQYQy195LL2lw+cK4+Nft+GK9UiD4OSU8IbOetzMkrFIsJXfcLS2tom4zAkxgj3cWS5D+aiUWdTBtF4vbUci74dKknNiJV3WFoX74JDy6V3TXviww3xTSur/ZKteSJeLZzjOZYm3Z0WoDEufvzduknhfv5mYzHfl4Pi3vItSysMA/T/r5NMmXCLSU4dw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CH3PR12MB8233.namprd12.prod.outlook.com (2603:10b6:610:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:06:56 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:06:56 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 21/24] net/mlx5e: NVMEoTCP, ddp setup and resync Date: Tue, 22 Aug 2023 15:04:22 +0000 Message-Id: <20230822150425.3390-22-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0244.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::13) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CH3PR12MB8233:EE_ X-MS-Office365-Filtering-Correlation-Id: df20cfe3-1882-4aff-80a7-08dba3216d0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcynLn+VTnWWZEYRqZKDB2IVTRQxfWZsp7JqilSoythccH2Qn282i/HwSLjwy3j6+bvYE2vtncNfErLsRVB/ta31PAjrJa7kMA7nDOxCR1WRTbV/UumQaakcwfXKblWHoG7RX+yS6lx/zVoikewyN4DYtKHcIW+Y0OA8CV0/7ypOdRwTWeVeGrsOZ8XgWFhfOzxW3p6RjN7wQqXh8l+tsjFThjaMl8UkV/mne7f/5aTgvXx3Tp01vPbxC30vq0t9A2UlQgOAJe9PIRx77nS2/qGAiBf+Ko406ho575nx/aSNqZUAc7YeLxTOApeYo1s+eojQsGyt14oxcPC8x92o0dMsE9QxOaDiunydnXLZWPy5W4zcdkg1QY1zJtNcT9LKVCfhmu/pvG9n0HI4pMypTZwxSIBXZwEaJ3YBWCVy+nP9PIJptN3B4FEKwgAgyLfFuJrmqUGDT0L8TqGpw2EaYssRc5syRLnf+Vuw+YUF7FUNKXQTVsYxKpoB6eNyRlZekt+Fc85fC08TjXVm9qRE0PAAnKoCIiC9cn+7VH9ORy8bW0UUJ3E/WSL5cLvdR7m2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: voPjTLknWxwWKdT0qG9xUgmXv2ZzFAG2VQIYC7BJbykE66/b4zOauMeNMfIemGKqhroQN9lFTQD//CaT9YH4zsSUECa+eGW+SrhTZy0HVDc9ti5Wox131BwvPrrq5aSOEHb/LpPVL4+/mQQjI0Sya+RZpAoe5ZopZlVgPHxkfEw7+/3ef+RCq/etWVjbKW7+i0DHQOdQbgOCVxXDLOcJl8R0tQdmNqjj6XfSRuAj8oWgJMJ5s6g/gdX+FyNf2tQ4AGBIudd6BBw7xnqt+Nt7MmRPvm5dd9br50/5iAui1KgZYKv+7zevbLR5z6yjR7iOoHR4iZ3lef9yChYNW+FLQ2H+mp3ioDbRdgIVVO1NB7/WEdPohXWjXSdhrfFZ01iHjiYD3N20I8iVA+BihReGlFTxdACzuoFmkCeBW7/k9ta/7Ft8wgCJxGn/Lz5O56z77ufdC8nvEKd4+pTuOhRyKJibuZrxPuOXR9uvb4t/3idWTXHKQV6SLh//Z8FAMFj+CyVU3m1GsU+p71bUBGIHNtPNeA86nk13RjlFztKxRBrOvCcO4cNLhb1/TznjGQYE64EtL51qUFBNWu813RQYcmTJMt+bEIN0NTF+0dAYWDjeH2snr14JuJoba2PrAA86/qZQ29TBXcV7ok4WUF17MLF78SKALYCLP9A6RxkkJT98tqzA6PQmBvZc4hog8OsKBbokjM+sdUfUrGd8w2emJwDwVHNz4eGWRVQO/MyfEhxQKVjKypEtrwdHhs31egxzRlxejVtmQvSzKcbaIK0g6y3qoqtCYhPIDLsXfPTGmlqHYe/dVDEDZTcI1WIjjUSGGRCSVwCqvxEwfr+NgveQnv4yt9aPy2uJCRolPNOEJBUqB7qVkBNVZkvAGwOoYfI1cIU+Q07Be4Q6nrPrmuhojfIr/kuWyl5DWWMh1XWZoxsgHBHvDlqSpZGzmQGywP8tnLwY8lviPof9ua6nivYCKJd5m8g+ZwQEBFpIJ1ToUvD27MFE86WAYJzyOcFk3BEsKPxMwv4MSqKJ55j0eGH+b09LfD4ns+24oWYeSWEyohF5dNmMaHs3866WzoztTSX0qfi0SXJ1Ax2zLz2op91ZOlD//AL5HMsSuZAioAyDkB38Lk8z2GRrACr9RF3Bgof0oP9T/6aUqTQmvizED2c0gz5Gw5nb7G20gUB7wODsK5HZSmtoWYVAUa+zXGjWK4LGDTUQD8+GBvPYmr8bhk4VBD13lZT6ORX0o8svPLPUP9+78W4tTMJW8V+CVfGbWc5bwl5SdCzz7BvFwHucST5qQBV2vCUA2+Ky120TNIKDj9SD53IouInUtmb18AStYNqLe7FnEMt8FQV+Opb9bTYYrmztWPbxgvdI9948OSrhF6ixbhSvKWrxvG2gZm/xpv7huRvs5arNDDOtHn6OaYdxmVY9Pc7fW9fStZbgWqv0hGdGUF70xPPvZIKh8Y6I/XY9RMFl2rXDMddhYajbWa5aoOpycCOYioFbWL9BmSspL4o8jZmB8MwjkP+o0d8oHjLNnkqluejpWjDdMX/7jdjV84Qfeo5MofpT54Jh84e7myi0dlhgjHjl9mwsTn3RI6L1 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: df20cfe3-1882-4aff-80a7-08dba3216d0d X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:06:56.3173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KEfFQCYOv0ukh9AZjMmHchbHW4inz8hwwqvqX6AnwfTTD/36ZO2nGGtirUrOlpHBZ10HAfQv/7DoKoPUcBcmxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8233 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay NVMEoTCP offload uses buffer registration for every NVME request to perform direct data placement. This is achieved by creating a NIC HW mapping between the CCID (command capsule ID) to the set of buffers that compose the request. The registration is implemented via MKEY for which we do fast/async mapping using KLM UMR WQE. The buffer registration takes place when the ULP calls the ddp_setup op which is done before they send their corresponding request to the other side (e.g nvmf target). We don't wait for the completion of the registration before returning back to the ulp. The reason being that the HW mapping should be in place fast enough vs the RTT it would take for the request to be responded. If this doesn't happen, some IO may not be ddp-offloaded, but that doesn't stop the overall offloading session. When the offloading HW gets out of sync with the protocol session, a hardware/software handshake takes place to resync. The ddp_resync op is the part of the handshake where the SW confirms to the HW that a indeed they identified correctly a PDU header at a certain TCP sequence number. This allows the HW to resume the offload. The 1st part of the handshake is when the HW identifies such sequence number in an arriving packet. A special mark is made on the completion (cqe) and then the mlx5 driver invokes the ddp resync_request callback advertised by the ULP in the ddp context - this is in downstream patch. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 146 +++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index 770d3f2878bf..8f9af0f2fb1f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -683,19 +683,156 @@ mlx5e_nvmeotcp_queue_teardown(struct net_device *netdev, mlx5e_nvmeotcp_put_queue(queue); } +static bool +mlx5e_nvmeotcp_validate_small_sgl_suffix(struct scatterlist *sg, int sg_len, int mtu) +{ + int i, hole_size, hole_len, chunk_size = 0; + + for (i = 1; i < sg_len; i++) + chunk_size += sg_dma_len(&sg[i]); + + if (chunk_size >= mtu) + return true; + + hole_size = mtu - chunk_size - 1; + hole_len = DIV_ROUND_UP(hole_size, PAGE_SIZE); + + if (sg_len + hole_len > MAX_SKB_FRAGS) + return false; + + return true; +} + +static bool +mlx5e_nvmeotcp_validate_big_sgl_suffix(struct scatterlist *sg, int sg_len, int mtu) +{ + int i, j, last_elem, window_idx, window_size = MAX_SKB_FRAGS - 1; + int chunk_size = 0; + + last_elem = sg_len - window_size; + window_idx = window_size; + + for (j = 1; j < window_size; j++) + chunk_size += sg_dma_len(&sg[j]); + + for (i = 1; i <= last_elem; i++, window_idx++) { + chunk_size += sg_dma_len(&sg[window_idx]); + if (chunk_size < mtu - 1) + return false; + + chunk_size -= sg_dma_len(&sg[i]); + } + + return true; +} + +/* This function makes sure that the middle/suffix of a PDU SGL meets the + * restriction of MAX_SKB_FRAGS. There are two cases here: + * 1. sg_len < MAX_SKB_FRAGS - the extreme case here is a packet that consists + * of one byte from the first SG element + the rest of the SGL and the remaining + * space of the packet will be scattered to the WQE and will be pointed by + * SKB frags. + * 2. sg_len => MAX_SKB_FRAGS - the extreme case here is a packet that consists + * of one byte from middle SG element + 15 continuous SG elements + one byte + * from a sequential SG element or the rest of the packet. + */ +static bool +mlx5e_nvmeotcp_validate_sgl_suffix(struct scatterlist *sg, int sg_len, int mtu) +{ + int ret; + + if (sg_len < MAX_SKB_FRAGS) + ret = mlx5e_nvmeotcp_validate_small_sgl_suffix(sg, sg_len, mtu); + else + ret = mlx5e_nvmeotcp_validate_big_sgl_suffix(sg, sg_len, mtu); + + return ret; +} + +static bool +mlx5e_nvmeotcp_validate_sgl_prefix(struct scatterlist *sg, int sg_len, int mtu) +{ + int i, hole_size, hole_len, tmp_len, chunk_size = 0; + + tmp_len = min_t(int, sg_len, MAX_SKB_FRAGS); + + for (i = 0; i < tmp_len; i++) + chunk_size += sg_dma_len(&sg[i]); + + if (chunk_size >= mtu) + return true; + + hole_size = mtu - chunk_size; + hole_len = DIV_ROUND_UP(hole_size, PAGE_SIZE); + + if (tmp_len + hole_len > MAX_SKB_FRAGS) + return false; + + return true; +} + +/* This function is responsible to ensure that a PDU could be offloaded. + * PDU is offloaded by building a non-linear SKB such that each SGL element is + * placed in frag, thus this function should ensure that all packets that + * represent part of the PDU won't exaggerate from MAX_SKB_FRAGS SGL. + * In addition NVMEoTCP offload has one PDU offload for packet restriction. + * Packet could start with a new PDU and then we should check that the prefix + * of the PDU meets the requirement or a packet can start in the middle of SG + * element and then we should check that the suffix of PDU meets the requirement. + */ +static bool +mlx5e_nvmeotcp_validate_sgl(struct scatterlist *sg, int sg_len, int mtu) +{ + int max_hole_frags; + + max_hole_frags = DIV_ROUND_UP(mtu, PAGE_SIZE); + if (sg_len + max_hole_frags <= MAX_SKB_FRAGS) + return true; + + if (!mlx5e_nvmeotcp_validate_sgl_prefix(sg, sg_len, mtu) || + !mlx5e_nvmeotcp_validate_sgl_suffix(sg, sg_len, mtu)) + return false; + + return true; +} + static int mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, struct sock *sk, struct ulp_ddp_io *ddp) { + struct scatterlist *sg = ddp->sg_table.sgl; + struct mlx5e_nvmeotcp_queue_entry *nvqt; struct mlx5e_nvmeotcp_queue *queue; + struct mlx5_core_dev *mdev; + int i, size = 0, count = 0; queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + mdev = queue->priv->mdev; + count = dma_map_sg(mdev->device, ddp->sg_table.sgl, ddp->nents, + DMA_FROM_DEVICE); + + if (count <= 0) + return -EINVAL; - /* Placeholder - map_sg and initializing the count */ + if (WARN_ON(count > mlx5e_get_max_sgl(mdev))) + return -ENOSPC; + + if (!mlx5e_nvmeotcp_validate_sgl(sg, count, READ_ONCE(netdev->mtu))) + return -EOPNOTSUPP; + + for (i = 0; i < count; i++) + size += sg_dma_len(&sg[i]); + + nvqt = &queue->ccid_table[ddp->command_id]; + nvqt->size = size; + nvqt->ddp = ddp; + nvqt->sgl = sg; + nvqt->ccid_gen++; + nvqt->sgl_length = count; + mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_UMR, ddp->command_id, count); - mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_UMR, ddp->command_id, 0); return 0; } @@ -718,6 +855,11 @@ static void mlx5e_nvmeotcp_ddp_resync(struct net_device *netdev, struct sock *sk, u32 seq) { + struct mlx5e_nvmeotcp_queue *queue = + container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + + queue->after_resync_cqe = 1; + mlx5e_nvmeotcp_rx_post_static_params_wqe(queue, seq); } struct mlx5e_nvmeotcp_queue * From patchwork Tue Aug 22 15:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361054 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 9528F1DA25 for ; Tue, 22 Aug 2023 15:07:07 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23084126 for ; Tue, 22 Aug 2023 08:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bn1RsRnNL6l5kjIb5sX9vghFBfWOBmtaquN7lmZAMxljL9U3zhl1MrFKyA2DRNzb+iQgAKaPX+9gL7PHFXFNjMzExqtBewK/p4sUyutDpKkqRFD+XJPp5f4Lpldd+V6RryaJZHmDYp7r5b55N5FbqIb2xS6g7C/99qZscJ3WyCvGDsJBceLyVKdUjw70BnChkWuBW/yTjaCoWNiHnzjZNdqgF0UVNyN7j47AE9tv6qV6WTShEdcscOBeKvh1AO6NabjaXMPaKHq/g4bZgTEdBFDv9VTLG8vuzTBVsf8brt/RVffjwKp9YHZD8NdTRGtbPH9yIHi325Qw8IvJ5HPTqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/aviAbnfTC1zJEeH5GytM4MKZjJ/MmS2ecBDSMux3OE=; b=dUZL9F6gXVnQmojh+d/psCEYDe6udII9ODkpe2z3AG5OWMhh+nR/C3+4Brt5hZG5B8Kjjggg7KvoaVFdJYiIBiPfA1F4Se5y/kp8rd+S4RYxHma6i1glTbuQdBKbcAk+kIPmYVAhMLY6LRnFl1pneMx+4Av0GfFXaeqq0rOFvk8x28fJtIGQVRrUPDqmFYeeRLWuhgeLOy0lufFZMI5jbwvvkN5z4NERWHs4QVyBcMwa/gYj3noSubxDmQfZvMebk5S8uExPWdouTFWnkUwlodXDpcFe85ajaq/FikSgMH9eEHn0BC1bbKbNKDY5LsMtiC3PHhxtYj4gk54UBX7J5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/aviAbnfTC1zJEeH5GytM4MKZjJ/MmS2ecBDSMux3OE=; b=HoMY24ygRgzeVQ3+vCJXF0OOcWCdgdEfuQ9IkJLvhx4dtzeo76Cp46bg5xvSdqxjdDeQktCjkHUsRErcMzmCrjlUpJySUqkxEUJE6PjML1C3CXzS5VGrXzWZ/KUNeRLSyN8DV+3Xhl9Ygpw9RxKhuK6RhepNSFRhUxczOlcfVM1ZbAQO312nw7RyC5W1Z1w7Yq9PFmpFSaRfBm2r1JlToYAI1qmO5QRTNaJwG+qgYBSsOE0hasLNvgX6se++aE2RE1LQ3XZa1ZmraToQ9A18Pba6uRgmePpQN1zKaWoel4Rs6UK/4/dlMVnBOxGPSZ7k0R23eHfyME2A0zOBbHp9MQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:07:04 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:07:03 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 22/24] net/mlx5e: NVMEoTCP, async ddp invalidation Date: Tue, 22 Aug 2023 15:04:23 +0000 Message-Id: <20230822150425.3390-23-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0137.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: d7461b85-e927-4cda-64b5-08dba3217177 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oq3E1Ghwr/J3UID1+fkQTxDL/4F1o89sAXvoGgmdFc29YSL1CeVe16bUjfrPkgT0FpRBbg3qolZrwPeLJ+g97xuUGkLGoLrMY9Eitinbg4uw3mqCT1CH7uBNV3hP69//dSmCdAa33GsliqpcOp2UiN/V6csPRxWnmYb1pErIhFIA+kUGsMIOmEYIWt11KCqVtvPrtaXuVvMeQVXlc4JgEF8P/S/Oxuf2mkhuKPshAYZWjj2NP+jtYS/WUjaZO+t9ncBJyiKCnUzpcDnP7uWqnz7WKluuSvtYJZPPSxrLUGlbRIccjetmokd9HrsK0o8f8FbMFcfhrEfT1foN5/lmttkDkRFuhVsLr9EaflN4hCVzAUv7zVtcq1Dgq4GJn93T4Qgf2o1DAtMJdQGGRLFhPaGbjWVNpKhNEWW+b9DzPYynHZ4xxedCuVr0g6LYRy1DBi0fYuoZWPimI+Wm9YtMLvq+40ibaTH3x6v6e+EcYuF/QpZz+rfjzx6Rc7nyp4S4nDgjc6BEGjuL5ItH42y0STk9at4qGkUvFf0dlNFtDrKqQv/i7eOi+mML1Jic8Lbm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xXxTk8tFWlsHUcV1AmJY/4bo2owzG8eDDYzCXr+LJV9iHa0RXoIPVo87a/UVA1v8P0kgcpMx9LHf9bcwrqEOGX6RwkxE8/pxUmDQ1BO8xWKpP8ZTZHmXZb6NJkNIDubtGyjoAMDez34N688rTq17MPqxqtDZu9r0b7Dp35VwLLHxxTIWhtOqxfwr+yDdFzC/sz4BkqqAvLO6RKAgzGi0LSjHGAXcSSP4d0Do3PbhaomHC5oYMnQzptsEFL4ViUrUAc1oOHFtlZixQ7rUrNTilcXS6fwehb3S9UD+XsZEYOeLZ0CN4+c+Xu9vFGhqPwxN4YzPWXw0GjrYFnZEaWFk+LIh6fUKc4WkRvoQEqlngIyssbUWNjlpE7Cb+DgBdke+/MiChPkTnUTdoOiLvBMYb/1Wr97SiplrKtUi2TMHfVaLRBqUdPnNK7mMOwpObf/ltvnUeU1AX7wdDFIDThTxJLKAAjYcRGM1KMg+JTjYosKwa7H/PguT3nRGi430qDT31tVg3VpRpyQ7evVP5JfoT4+EwgE88Tf+UtzP1OXKlwWkkbdFXxOCj0SomLpsCIywg5+i9D8bfZ1BgivPtnikB+KgzMBKQ2eN3S1660giqRu104iliNT33ZdnEVrlIobJ8YQ6YMLrTcgFNvj7r7SrVUkuL7TgsCQKJ6hT9mNiTxv2uVQ28H3QO6cNAe8miiit1sUt2l/1v7oas9NDUljb+YzBlPlT/KjkCtiVlkKqJZkAGl2Dl1YGC6ZAcKYl4NlytQTLoa+FlwYx6wzWmgdSBL+M7qXZxK0zdq45aq8yWtX6TMae9MBoA9pwdxMY9j02Ikaq25A+t81HXXaF/NpQAYYo0P5PzGtd4TiO4cUVnrqBmGqKtClcaRLaV1TB20GFF6PFQkYOkWbrSgo1mcdXMgirV5Etsmj/V8nrimN7yKFu/UGKnfrODZLTB95CC/focKuFHRueRjzg4KP0hYgGcC6WTZ875l+zscaIekGqSvO5nZoa5KNkAJa9lvNI9bxDqSRW2+80DJvsMkwgt7zdxBUOmMLtfBaIHTbM4nCBWtCa5utu4FC/AlvTZQZemoXpiv+d5tyWaaEk+eYAXGN6GSdBIVk46oroLJvuDNaVLIcZTR08S9znR/l+iQtLV+XMWvB/b5wf7uaTeRrJ4+Cr8tPI/60s+1/g3Ypb8AEA84S514+ueAu39sLlIcalt5Dm9HxzXNZwn+UQNRzJuiA7dZSdPRHWzktpS5ZNWnodMp/Fy7r46CfDfaSdrIICal0P9CELMm6iELENK2lTh3FCjYvfw4Hx9VFOqtp0vpMKsbPn/BFqfLGnv5lMup0HPDmtFrj1kVbb8UOMbwx3LiZ559tfyDT82SKAEbRAdKPNelHTpaTytcNTx0DutDuBm7vD8KHXsukf3xzKJ2yfzNIIW+Vg09Z7KGEBgLD82dk5i1os9U2ZeE3BfHV8gzhocec/Z7OwpSDsBVgi9g2Bfcoi9P5JXXB6T1LjQQGCg6EsEzzI/AJnQyEMYfikDsPTBjZz59XYZBYfU+lUdTeAGWNEiPBzwh5azy1wYuHUrJqWUBWSZMn2J93og0lte3mcEqWF X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7461b85-e927-4cda-64b5-08dba3217177 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:07:03.8346 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6r6Y4L1dDb9FnYRHvKXUS9YtrE89p6iPHBWSehRWlrN5Bhl8NsZYIkZIj2TqiSUFNrWsrCizWBK9tsKfl5kGKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay After the ULP consumed the buffers of the offloaded request, it calls the ddp_teardown op to release the NIC mapping for them and allow the NIC to reuse the HW contexts associated with offloading this IO. We do a fast/async un-mapping via UMR WQE. In this case, the ULP does holds off with completing the request towards the upper/application layers until the HW unmapping is done. When the corresponding CQE is received, a notification is done via the the teardown_done ddp callback advertised by the ULP in the ddp context. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 4 ++ .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 66 ++++++++++++++++--- .../mellanox/mlx5/core/en_accel/nvmeotcp.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_rx.c | 6 ++ 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index c87dca17d5c8..3c124f708afc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -52,6 +52,7 @@ enum mlx5e_icosq_wqe_type { #endif #ifdef CONFIG_MLX5_EN_NVMEOTCP MLX5E_ICOSQ_WQE_UMR_NVMEOTCP, + MLX5E_ICOSQ_WQE_UMR_NVMEOTCP_INVALIDATE, MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP, #endif }; @@ -230,6 +231,9 @@ struct mlx5e_icosq_wqe_info { struct { struct mlx5e_nvmeotcp_queue *queue; } nvmeotcp_q; + struct { + struct mlx5e_nvmeotcp_queue_entry *entry; + } nvmeotcp_qe; #endif }; }; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index 8f9af0f2fb1f..c5bfc1578ddf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -142,10 +142,11 @@ build_nvmeotcp_klm_umr(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe u16 ccid, int klm_entries, u32 klm_offset, u32 len, enum wqe_type klm_type) { - u32 id = (klm_type == KLM_UMR) ? queue->ccid_table[ccid].klm_mkey : - (mlx5e_tir_get_tirn(&queue->tir) << MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT); - u8 opc_mod = (klm_type == KLM_UMR) ? MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR : - MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS; + u32 id = (klm_type == BSF_KLM_UMR) ? + (mlx5e_tir_get_tirn(&queue->tir) << MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT) : + queue->ccid_table[ccid].klm_mkey; + u8 opc_mod = (klm_type == BSF_KLM_UMR) ? MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS : + MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR; u32 ds_cnt = MLX5E_KLM_UMR_DS_CNT(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl; struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; @@ -158,6 +159,13 @@ build_nvmeotcp_klm_umr(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | ds_cnt); cseg->general_id = cpu_to_be32(id); + if (!klm_entries) { /* this is invalidate */ + ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); + ucseg->flags = MLX5_UMR_INLINE; + mkc->status = MLX5_MKEY_STATUS_FREE; + return; + } + if (klm_type == KLM_UMR && !klm_offset) { ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_XLT_OCT_SIZE | MLX5_MKEY_MASK_LEN | MLX5_MKEY_MASK_FREE); @@ -259,8 +267,8 @@ build_nvmeotcp_static_params(struct mlx5e_nvmeotcp_queue *queue, static void mlx5e_nvmeotcp_fill_wi(struct mlx5e_nvmeotcp_queue *nvmeotcp_queue, - struct mlx5e_icosq *sq, u32 wqebbs, u16 pi, - enum wqe_type type) + struct mlx5e_icosq *sq, u32 wqebbs, + u16 pi, u16 ccid, enum wqe_type type) { struct mlx5e_icosq_wqe_info *wi = &sq->db.wqe_info[pi]; @@ -272,6 +280,10 @@ mlx5e_nvmeotcp_fill_wi(struct mlx5e_nvmeotcp_queue *nvmeotcp_queue, wi->wqe_type = MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP; wi->nvmeotcp_q.queue = nvmeotcp_queue; break; + case KLM_INV_UMR: + wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP_INVALIDATE; + wi->nvmeotcp_qe.entry = &nvmeotcp_queue->ccid_table[ccid]; + break; default: /* cases where no further action is required upon completion, such as ddp setup */ wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP; @@ -290,7 +302,7 @@ mlx5e_nvmeotcp_rx_post_static_params_wqe(struct mlx5e_nvmeotcp_queue *queue, u32 wqebbs = MLX5E_TRANSPORT_SET_STATIC_PARAMS_WQEBBS; pi = mlx5e_icosq_get_next_pi(sq, wqebbs); wqe = MLX5E_TRANSPORT_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); - mlx5e_nvmeotcp_fill_wi(NULL, sq, wqebbs, pi, BSF_UMR); + mlx5e_nvmeotcp_fill_wi(NULL, sq, wqebbs, pi, 0, BSF_UMR); build_nvmeotcp_static_params(queue, wqe, resync_seq, queue->crc_rx); sq->pc += wqebbs; mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &wqe->ctrl); @@ -307,7 +319,7 @@ mlx5e_nvmeotcp_rx_post_progress_params_wqe(struct mlx5e_nvmeotcp_queue *queue, u wqebbs = MLX5E_NVMEOTCP_PROGRESS_PARAMS_WQEBBS; pi = mlx5e_icosq_get_next_pi(sq, wqebbs); wqe = MLX5E_NVMEOTCP_FETCH_PROGRESS_PARAMS_WQE(sq, pi); - mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, SET_PSV_UMR); + mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, 0, SET_PSV_UMR); build_nvmeotcp_progress_params(queue, wqe, seq); sq->pc += wqebbs; mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &wqe->ctrl); @@ -330,7 +342,7 @@ post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, wqebbs = DIV_ROUND_UP(wqe_sz, MLX5_SEND_WQE_BB); pi = mlx5e_icosq_get_next_pi(sq, wqebbs); wqe = MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi); - mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, wqe_type); + mlx5e_nvmeotcp_fill_wi(queue, sq, wqebbs, pi, ccid, wqe_type); build_nvmeotcp_klm_umr(queue, wqe, ccid, cur_klm_entries, klm_offset, klm_length, wqe_type); sq->pc += wqebbs; @@ -345,7 +357,10 @@ mlx5e_nvmeotcp_post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, enum wqe_type wq struct mlx5e_icosq *sq = &queue->sq; u32 klm_offset = 0, wqes, i; - wqes = DIV_ROUND_UP(klm_length, queue->max_klms_per_wqe); + if (wqe_type == KLM_INV_UMR) + wqes = 1; + else + wqes = DIV_ROUND_UP(klm_length, queue->max_klms_per_wqe); spin_lock_bh(&queue->sq_lock); @@ -843,12 +858,43 @@ void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi) complete(&queue->static_params_done); } +void mlx5e_nvmeotcp_ddp_inv_done(struct mlx5e_icosq_wqe_info *wi) +{ + struct mlx5e_nvmeotcp_queue_entry *q_entry = wi->nvmeotcp_qe.entry; + struct mlx5e_nvmeotcp_queue *queue = q_entry->queue; + struct mlx5_core_dev *mdev = queue->priv->mdev; + struct ulp_ddp_io *ddp = q_entry->ddp; + const struct ulp_ddp_ulp_ops *ulp_ops; + + dma_unmap_sg(mdev->device, ddp->sg_table.sgl, + q_entry->sgl_length, DMA_FROM_DEVICE); + + q_entry->sgl_length = 0; + + ulp_ops = inet_csk(queue->sk)->icsk_ulp_ddp_ops; + if (ulp_ops && ulp_ops->ddp_teardown_done) + ulp_ops->ddp_teardown_done(q_entry->ddp_ctx); +} + static void mlx5e_nvmeotcp_ddp_teardown(struct net_device *netdev, struct sock *sk, struct ulp_ddp_io *ddp, void *ddp_ctx) { + struct mlx5e_nvmeotcp_queue_entry *q_entry; + struct mlx5e_nvmeotcp_queue *queue; + + queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + q_entry = &queue->ccid_table[ddp->command_id]; + WARN_ONCE(q_entry->sgl_length == 0, + "Invalidation of empty sgl (CID 0x%x, queue 0x%x)\n", + ddp->command_id, queue->id); + + q_entry->ddp_ctx = ddp_ctx; + q_entry->queue = queue; + + mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_INV_UMR, ddp->command_id, 0); } static void diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h index 555f3ed7e2e2..a5cfd9e31be7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h @@ -109,6 +109,7 @@ void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv); struct mlx5e_nvmeotcp_queue * mlx5e_nvmeotcp_get_queue(struct mlx5e_nvmeotcp *nvmeotcp, int id); void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue); +void mlx5e_nvmeotcp_ddp_inv_done(struct mlx5e_icosq_wqe_info *wi); void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi); static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 87ad443e73f8..e1f8a87de638 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -951,6 +951,9 @@ void mlx5e_free_icosq_descs(struct mlx5e_icosq *sq) break; #endif #ifdef CONFIG_MLX5_EN_NVMEOTCP + case MLX5E_ICOSQ_WQE_UMR_NVMEOTCP_INVALIDATE: + mlx5e_nvmeotcp_ddp_inv_done(wi); + break; case MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP: mlx5e_nvmeotcp_ctx_complete(wi); break; @@ -1056,6 +1059,9 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq, int budget) #ifdef CONFIG_MLX5_EN_NVMEOTCP case MLX5E_ICOSQ_WQE_UMR_NVMEOTCP: break; + case MLX5E_ICOSQ_WQE_UMR_NVMEOTCP_INVALIDATE: + mlx5e_nvmeotcp_ddp_inv_done(wi); + break; case MLX5E_ICOSQ_WQE_SET_PSV_NVMEOTCP: mlx5e_nvmeotcp_ctx_complete(wi); break; From patchwork Tue Aug 22 15:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361055 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 0D2DB79D0 for ; Tue, 22 Aug 2023 15:07:14 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6B919A for ; Tue, 22 Aug 2023 08:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=csayw0g26NWz5PgH+wmRz6b+0M/maEW15SQnFupcxdQskZygJyDoArJP/uPjFIuE3DX9tGE6086joTWRbSX0lJmZ5h81L7BS7Q3ZsZmvKJDiOM14tDcIhMuN2w4owd9bCAwxlBZrYvvmBniO3uNxhkmh7sUKzGszZ9PJkS/o1kLy7Uz1sULlRdnpQiQU8l5XU8dSCLyhafMSFA6GpmXYf0tOnKPegVw9Nh/soxjlEVt+HVKUvzYXD+U5/PWCW55wHrpHYytFewGHCtyQC663sRTHsn4pymCv5F1rZ7sSeGzIm0c+WVXaFN4Ix7QMjTsz66OZLLWYoVzi+TxBayvOVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kifYnhZsB3ZTAe6GG7bWKJyRiwkH+A0A28Z3uJAIyb4=; b=AQuAwA7/op91f0ZQ641irv2AOTkYFWXAuSaVxkZwRInYpJxOvImP+t6wkWY6nJvpw1EMBIeEEXEH04L06Ra+4+hi2RLuLy5Q0b9xDsmtLhrZU8u3q8VYJi27iQsEel1tjsfxQZfq5/rwb2OvD/p8dwsktkJznUzerisHIVjoH4rjSJRnZlM8Kmbrf5MKq14Z7BONLQK6FQbVP4WQk7lNGI5EP5PJ2PZsIDzTUG7LEduCayk7q9huyxvzYipXd4f34xkGW9Okd+wENWzZPfXJHzYEU09SrogRc4un0rdBCGs2c2UoWH6M10108r7U+wglFEDMjCbaa1Y7aUsK4HXWpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kifYnhZsB3ZTAe6GG7bWKJyRiwkH+A0A28Z3uJAIyb4=; b=EBcu2z7ZL6xSe2vNlUpYQkO9V+yfGNLhXk82+yblle6fXW59bY8IUFEXklhFSHNKaxcdg7CfysB+6S4wq5r/SIpNfvKwco1ZVh8/an7evqLIqUuukwi3YqkEDWoQhE5U1KK6Z3pEYDnbzvm8lrmUx5th9FGqJnt3QM5+A3ZM2TSbtzHi3+J7Mbapj2Q7majulgnhh+XpKVSv1LsCQNKz5jCEMfOtK107/DjLPrYsflwnEj1E42dijEhLx9DP+1gKNCRb9NG3OBXFlj9PdK86TRfp/YzoUZe1wjbN59dZ3W2LDSGZRwhCRnDRlAPaEny3RZqRlBx7jHYm78cMJpFCPg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:07:09 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:07:09 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Ben Ben-Ishay , aaptel@nvidia.com, aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 23/24] net/mlx5e: NVMEoTCP, data-path for DDP+DDGST offload Date: Tue, 22 Aug 2023 15:04:24 +0000 Message-Id: <20230822150425.3390-24-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0095.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::7) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: a6ba5602-2e6a-4e63-dd12-08dba32174a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AjrC363a/LKxB0mpC+F1DNagIvSi5u3IBbDEJ3ci67cWQFSpLc0ItPK7Duvgev7yQUD+DXkqrEKuyWuZKnSmIq9ceMMJs5W3HRlIXS4KiRbbTroRL+TK/8vSap7YNaXk2F0gBGkDdXJCN5vRBGgW5OlhTZFirOag1KJ3VRQXQnoSXLjVI5RHrV2BspnxAlrKmqcYIfAAdzlvAzm+m9T7OOwF/Pi2pmzBwV3QMg9Gkr94Y9wgYN+Hcl+Bdiy7KXmSLWCdFhB4mpnodk0i6nKJdztWMEAcx5wbd5753gtCk5LzcTHWH4bVgE5fTo0bQ+WjVaks5W0BTXHolBwFc65DdkdGLY3SiqWlwEGDi2FrDQDxQfImfltwoQyx4x/CjTOaite1qzJRTl0JvK28Rud0UtBLX7NzLGLpLVnzyWlbWdl6rLYeeXGR+j8fuBwR9ATU/oL5Gqbhz3xEzERdKImFzO87qfsIF8BnY2cwTA+I9XdcdCjwavy2fhNoKGyAg0hCR+ch0BsoPCG1aw4ow+Ja8/D9SzLHUlTqzKwk4E7w4auI9r5oHPBgoE98ED65QDpt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(30864003)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QC+FCm2GRkt1mYevLS27v2NKs7+ZBqOPdf3W0dpdSivm8Uy5wzzlNmsHqIOg/Qtfwba9bbl9fz1sLcCelk7AKx9jWDXS6MyWrOspJnK3Ewunvc+/5KHy9HmkWyg5eB/1PozAiePAZ0P4Zig9gbLqJwiA8/OqipeI9k5oXC9vroQL8ur5RF9mh1n8HS3I44EztKuZCbk2ioBRkTY9SIYSS5udeamLZLi03hSpcMXM8btmP2EKsfc/i2j3h16bt5fc+crC+a9bzx5pNs8erzZC5Ei6vFQ8sqKTG/JbDAyihHqZEYwIKksIBKDxCZAqLFDtBLBbae93hHWFlQzpVBDS3bU//I6mc/IxX/nLnwX/eMiFX9Qp+kD/chc12/AafAQzq5sI+/b4sNZXCFGBrILGhX8rNgqtbAOqR2i55arMxkRLubwQfMBCDeI4ax8n9ANGF8xyVN2gKefovGlwzT72LlxuE+trvj7NBn+qKcRObB3HlabpxLNB3UPjHdunDxqyKqI0SIaYKQ2F5JZQDgqyD3W0d2TmMuOPDFy9PNl1/yIH3KIilzzVN6rUOCpffvea8MpE0/foQCQLggmJ5Z7n6WwOKLrmqSxjNUY8qADfiXZnLoAaUlIHn+wl5q4f0RdoQTmUhlu+NcQYDZB7WLGqpTTuJYEkK/roI4RdvIfqidj6S7nkgRuiqTMbyn1RdcKSBO73365FnEyLPp7AFrFV+anO8FgdbD55gWKVZKZVbjjeqqk30/aZ8Plo8GbD2yGEPbDCwjOqOGZs6/Ta+dE+kc8CCRhPDkE9gW6J2R1wPM3nIWiwILqUp/5oGwsDoiULxxMbjT0K4ysvw5eqimKuqSMQm1POgTk9BPRA2SI2AUFMYm28Gs3htxZi8nCmXWhN8yv4HcxGVq7jzJQOzNjONWiFDR4oDrV7vhtvmqOjkBkgmBX7jGXu5NbYl8Ky1eTr5ORANdOc0LZ0UKchLoxQY5OEtj7+7AVeaIb+bJF/IgGZkGdOp7r8ViR1UZVicQjMUlm4bzuQxyxZAwTeCvI2M6locSzfPGGKNkcK5HRyJHKllSegjl/xjThEUZGZWasH48i7VJGeNYYYK74HmYizTPq+mas8vqgFI72fc0nOgPAlsDsLUOhS58pHBObf4jp6wbnqHu3DFavkPzVO41+DI//2Y9oBwGpajTbAqVCjwAJyHyXRjapu5pMTdrywIKQs9npxk9Js77clmGb4afYkL88N7011fxu+yTOT2CkxU996anX3+cYLnWDo1u0fEFW+AhV1q36dr5gj7FnKh9MeUZ2ldfntbaFx6MxH8LVFnAhnwu+h5PXBzKAJo0Ot9zsXtKFAfG8jyMIdrY4jI0q+J5bsLWSenQTbLYj4eLBfO7Rg+dQQ4BN/ewsAOzOCkh3BCxqSaeZhuuSTEAF0nyT2JoBnVHDV3yirfM4yRDRRCMvLn8KMuqamHF/T18C8j0nloXEuroY5MmF5oLG3rlnommsDIX9thxq2f0TKqbLyTLaIT69rMo8sbyWauMjQSSOyoO8FCspzxl4XdcU8hs5Motq8bWTZxtPjQgvHX4SbSGt+pR7CIB/JDaJftkNTEzx0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6ba5602-2e6a-4e63-dd12-08dba32174a1 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:07:09.0345 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ha//Yvq9+ecEsLjPBMTaG9HKPXptneviPhjiGN+Tm5DaCLWFWq79SVs1BhyODDzg9+YAKkG8JJcd0dUnEzhQMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay This patch implements the data-path for direct data placement (DDP) and DDGST offloads. NVMEoTCP DDP constructs an SKB from each CQE, while pointing at NVME destination buffers. In turn, this enables the offload, as the NVMe-TCP layer will skip the copy when src == dst. Additionally, this patch adds support for DDGST (CRC32) offload. HW will report DDGST offload only if it has not encountered an error in the received packet. We pass this indication in skb->ulp_crc up the stack to NVMe-TCP to skip computing the DDGST if all corresponding SKBs were verified by HW. This patch also handles context resynchronization requests made by NIC HW. The resync request is passed to the NVMe-TCP layer to be handled at a later point in time. Finally, we also use the skb->ulp_ddp bit to avoid skb_condense. This is critical as every SKB that uses DDP has a hole that fits perfectly with skb_condense's policy, but filling this hole is counter-productive as the data there already resides in its destination buffer. This work has been done on pre-silicon functional simulator, and hence data-path performance numbers are not provided. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 6 + .../mlx5/core/en_accel/nvmeotcp_rxtx.c | 345 ++++++++++++++++++ .../mlx5/core/en_accel/nvmeotcp_rxtx.h | 37 ++ .../net/ethernet/mellanox/mlx5/core/en_rx.c | 44 ++- 5 files changed, 419 insertions(+), 15 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile index 3470d80ab4dd..feff577e4006 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -109,7 +109,7 @@ mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/ktls_stats.o \ en_accel/fs_tcp.o en_accel/ktls.o en_accel/ktls_txrx.o \ en_accel/ktls_tx.o en_accel/ktls_rx.o -mlx5_core-$(CONFIG_MLX5_EN_NVMEOTCP) += en_accel/fs_tcp.o en_accel/nvmeotcp.o +mlx5_core-$(CONFIG_MLX5_EN_NVMEOTCP) += en_accel/fs_tcp.o en_accel/nvmeotcp.o en_accel/nvmeotcp_rxtx.o mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \ steering/dr_matcher.o steering/dr_rule.o \ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 3c124f708afc..516054e480d9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -526,4 +526,10 @@ static inline struct mlx5e_mpw_info *mlx5e_get_mpw_info(struct mlx5e_rq *rq, int return (struct mlx5e_mpw_info *)((char *)rq->mpwqe.info + array_size(i, isz)); } + +static inline struct mlx5e_wqe_frag_info *get_frag(struct mlx5e_rq *rq, u16 ix) +{ + return &rq->wqe.frags[ix << rq->wqe.info.log_num_frags]; +} + #endif diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c new file mode 100644 index 000000000000..53a67ec72f0f --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c @@ -0,0 +1,345 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + +#include "en_accel/nvmeotcp_rxtx.h" +#include +#include "en/txrx.h" + +#define MLX5E_TC_FLOW_ID_MASK 0x00ffffff + +static struct mlx5e_frag_page *mlx5e_get_frag(struct mlx5e_rq *rq, + struct mlx5_cqe64 *cqe) +{ + struct mlx5e_frag_page *fp; + + if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) { + u16 wqe_id = be16_to_cpu(cqe->wqe_id); + u16 stride_ix = mpwrq_get_cqe_stride_index(cqe); + u32 wqe_offset = stride_ix << rq->mpwqe.log_stride_sz; + u32 page_idx = wqe_offset >> rq->mpwqe.page_shift; + struct mlx5e_mpw_info *wi = mlx5e_get_mpw_info(rq, wqe_id); + union mlx5e_alloc_units *au = &wi->alloc_units; + + fp = &au->frag_pages[page_idx]; + } else { + /* Legacy */ + struct mlx5_wq_cyc *wq = &rq->wqe.wq; + u16 ci = mlx5_wq_cyc_ctr2ix(wq, be16_to_cpu(cqe->wqe_counter)); + struct mlx5e_wqe_frag_info *wi = get_frag(rq, ci); + + fp = wi->frag_page; + } + + return fp; +} + +static void nvmeotcp_update_resync(struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_cqe128 *cqe128) +{ + const struct ulp_ddp_ulp_ops *ulp_ops; + u32 seq; + + seq = be32_to_cpu(cqe128->resync_tcp_sn); + ulp_ops = inet_csk(queue->sk)->icsk_ulp_ddp_ops; + if (ulp_ops && ulp_ops->resync_request) + ulp_ops->resync_request(queue->sk, seq, ULP_DDP_RESYNC_PENDING); +} + +static void mlx5e_nvmeotcp_advance_sgl_iter(struct mlx5e_nvmeotcp_queue *queue) +{ + struct mlx5e_nvmeotcp_queue_entry *nqe = &queue->ccid_table[queue->ccid]; + + queue->ccoff += nqe->sgl[queue->ccsglidx].length; + queue->ccoff_inner = 0; + queue->ccsglidx++; +} + +static inline void +mlx5e_nvmeotcp_add_skb_frag(struct net_device *netdev, struct sk_buff *skb, + struct mlx5e_nvmeotcp_queue *queue, + struct mlx5e_nvmeotcp_queue_entry *nqe, u32 fragsz) +{ + dma_sync_single_for_cpu(&netdev->dev, + nqe->sgl[queue->ccsglidx].offset + queue->ccoff_inner, + fragsz, DMA_FROM_DEVICE); + + page_ref_inc(compound_head(sg_page(&nqe->sgl[queue->ccsglidx]))); + + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, + sg_page(&nqe->sgl[queue->ccsglidx]), + nqe->sgl[queue->ccsglidx].offset + queue->ccoff_inner, + fragsz, + fragsz); +} + +static inline void +mlx5_nvmeotcp_add_tail_nonlinear(struct sk_buff *skb, skb_frag_t *org_frags, + int org_nr_frags, int frag_index) +{ + while (org_nr_frags != frag_index) { + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, + skb_frag_page(&org_frags[frag_index]), + skb_frag_off(&org_frags[frag_index]), + skb_frag_size(&org_frags[frag_index]), + skb_frag_size(&org_frags[frag_index])); + frag_index++; + } +} + +static void +mlx5_nvmeotcp_add_tail(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, + struct mlx5e_nvmeotcp_queue *queue, struct sk_buff *skb, + int offset, int len) +{ + struct mlx5e_frag_page *frag_page = mlx5e_get_frag(rq, cqe); + + frag_page->frags++; + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, + virt_to_page(skb->data), offset, len, len); +} + +static void mlx5_nvmeotcp_trim_nonlinear(struct sk_buff *skb, skb_frag_t *org_frags, + int *frag_index, int remaining) +{ + unsigned int frag_size; + int nr_frags; + + /* skip @remaining bytes in frags */ + *frag_index = 0; + while (remaining) { + frag_size = skb_frag_size(&skb_shinfo(skb)->frags[*frag_index]); + if (frag_size > remaining) { + skb_frag_off_add(&skb_shinfo(skb)->frags[*frag_index], + remaining); + skb_frag_size_sub(&skb_shinfo(skb)->frags[*frag_index], + remaining); + remaining = 0; + } else { + remaining -= frag_size; + skb_frag_unref(skb, *frag_index); + *frag_index += 1; + } + } + + /* save original frags for the tail and unref */ + nr_frags = skb_shinfo(skb)->nr_frags; + memcpy(&org_frags[*frag_index], &skb_shinfo(skb)->frags[*frag_index], + (nr_frags - *frag_index) * sizeof(skb_frag_t)); + + /* remove frags from skb */ + skb_shinfo(skb)->nr_frags = 0; + skb->len -= skb->data_len; + skb->truesize -= skb->data_len; + skb->data_len = 0; +} + +static bool +mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; + struct net_device *netdev = rq->netdev; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_queue_entry *nqe; + skb_frag_t org_frags[MAX_SKB_FRAGS]; + struct mlx5e_nvmeotcp_queue *queue; + int org_nr_frags, frag_index; + struct mlx5e_cqe128 *cqe128; + u32 queue_id; + + queue_id = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK); + queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); + if (unlikely(!queue)) { + dev_kfree_skb_any(skb); + return false; + } + + cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); + if (cqe_is_nvmeotcp_resync(cqe)) { + nvmeotcp_update_resync(queue, cqe128); + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* If a resync occurred in the previous cqe, + * the current cqe.crcvalid bit may not be valid, + * so we will treat it as 0 + */ + if (unlikely(queue->after_resync_cqe) && cqe_is_nvmeotcp_crcvalid(cqe)) { + skb->ulp_crc = 0; + queue->after_resync_cqe = 0; + } else { + if (queue->crc_rx) + skb->ulp_crc = cqe_is_nvmeotcp_crcvalid(cqe); + } + + skb->ulp_ddp = cqe_is_nvmeotcp_zc(cqe); + if (!cqe_is_nvmeotcp_zc(cqe)) { + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* cc ddp from cqe */ + ccid = be16_to_cpu(cqe128->ccid); + ccoff = be32_to_cpu(cqe128->ccoff); + cclen = be16_to_cpu(cqe128->cclen); + hlen = be16_to_cpu(cqe128->hlen); + + /* carve a hole in the skb for DDP data */ + org_nr_frags = skb_shinfo(skb)->nr_frags; + mlx5_nvmeotcp_trim_nonlinear(skb, org_frags, &frag_index, cclen); + nqe = &queue->ccid_table[ccid]; + + /* packet starts new ccid? */ + if (queue->ccid != ccid || queue->ccid_gen != nqe->ccid_gen) { + queue->ccid = ccid; + queue->ccoff = 0; + queue->ccoff_inner = 0; + queue->ccsglidx = 0; + queue->ccid_gen = nqe->ccid_gen; + } + + /* skip inside cc until the ccoff in the cqe */ + while (queue->ccoff + queue->ccoff_inner < ccoff) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(off_t, remaining, + ccoff - (queue->ccoff + queue->ccoff_inner)); + + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + /* adjust the skb according to the cqe cc */ + while (to_copy < cclen) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(int, remaining, cclen - to_copy); + + mlx5e_nvmeotcp_add_skb_frag(netdev, skb, queue, nqe, fragsz); + to_copy += fragsz; + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + if (cqe_bcnt > hlen + cclen) { + remaining = cqe_bcnt - hlen - cclen; + mlx5_nvmeotcp_add_tail_nonlinear(skb, org_frags, + org_nr_frags, + frag_index); + } + + mlx5e_nvmeotcp_put_queue(queue); + return true; +} + +static bool +mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; + struct net_device *netdev = rq->netdev; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_queue_entry *nqe; + struct mlx5e_nvmeotcp_queue *queue; + struct mlx5e_cqe128 *cqe128; + u32 queue_id; + + queue_id = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK); + queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); + if (unlikely(!queue)) { + dev_kfree_skb_any(skb); + return false; + } + + cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); + if (cqe_is_nvmeotcp_resync(cqe)) { + nvmeotcp_update_resync(queue, cqe128); + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* If a resync occurred in the previous cqe, + * the current cqe.crcvalid bit may not be valid, + * so we will treat it as 0 + */ + if (unlikely(queue->after_resync_cqe) && cqe_is_nvmeotcp_crcvalid(cqe)) { + skb->ulp_crc = 0; + queue->after_resync_cqe = 0; + } else { + if (queue->crc_rx) + skb->ulp_crc = cqe_is_nvmeotcp_crcvalid(cqe); + } + + skb->ulp_ddp = cqe_is_nvmeotcp_zc(cqe); + if (!cqe_is_nvmeotcp_zc(cqe)) { + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* cc ddp from cqe */ + ccid = be16_to_cpu(cqe128->ccid); + ccoff = be32_to_cpu(cqe128->ccoff); + cclen = be16_to_cpu(cqe128->cclen); + hlen = be16_to_cpu(cqe128->hlen); + + /* carve a hole in the skb for DDP data */ + skb_trim(skb, hlen); + nqe = &queue->ccid_table[ccid]; + + /* packet starts new ccid? */ + if (queue->ccid != ccid || queue->ccid_gen != nqe->ccid_gen) { + queue->ccid = ccid; + queue->ccoff = 0; + queue->ccoff_inner = 0; + queue->ccsglidx = 0; + queue->ccid_gen = nqe->ccid_gen; + } + + /* skip inside cc until the ccoff in the cqe */ + while (queue->ccoff + queue->ccoff_inner < ccoff) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(off_t, remaining, + ccoff - (queue->ccoff + queue->ccoff_inner)); + + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + /* adjust the skb according to the cqe cc */ + while (to_copy < cclen) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(int, remaining, cclen - to_copy); + + mlx5e_nvmeotcp_add_skb_frag(netdev, skb, queue, nqe, fragsz); + to_copy += fragsz; + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + if (cqe_bcnt > hlen + cclen) { + remaining = cqe_bcnt - hlen - cclen; + mlx5_nvmeotcp_add_tail(rq, cqe, queue, skb, + offset_in_page(skb->data) + + hlen + cclen, remaining); + } + + mlx5e_nvmeotcp_put_queue(queue); + return true; +} + +bool +mlx5e_nvmeotcp_rebuild_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + if (skb->data_len) + return mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(rq, skb, cqe, cqe_bcnt); + else + return mlx5e_nvmeotcp_rebuild_rx_skb_linear(rq, skb, cqe, cqe_bcnt); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.h new file mode 100644 index 000000000000..a8ca8a53bac6 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ +#ifndef __MLX5E_NVMEOTCP_RXTX_H__ +#define __MLX5E_NVMEOTCP_RXTX_H__ + +#ifdef CONFIG_MLX5_EN_NVMEOTCP + +#include +#include "en_accel/nvmeotcp.h" + +bool +mlx5e_nvmeotcp_rebuild_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt); + +static inline int mlx5_nvmeotcp_get_headlen(struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + struct mlx5e_cqe128 *cqe128; + + if (!cqe_is_nvmeotcp_zc(cqe)) + return cqe_bcnt; + + cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); + return be16_to_cpu(cqe128->hlen); +} + +#else + +static inline bool +mlx5e_nvmeotcp_rebuild_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ return true; } + +static inline int mlx5_nvmeotcp_get_headlen(struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ return cqe_bcnt; } + +#endif /* CONFIG_MLX5_EN_NVMEOTCP */ +#endif /* __MLX5E_NVMEOTCP_RXTX_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index e1f8a87de638..ccb5b3d90861 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -53,7 +53,7 @@ #include "en_accel/macsec.h" #include "en_accel/ipsec_rxtx.h" #include "en_accel/ktls_txrx.h" -#include "en_accel/nvmeotcp.h" +#include "en_accel/nvmeotcp_rxtx.h" #include "en/xdp.h" #include "en/xsk/rx.h" #include "en/health.h" @@ -336,10 +336,6 @@ static inline void mlx5e_put_rx_frag(struct mlx5e_rq *rq, mlx5e_page_release_fragmented(rq, frag->frag_page); } -static inline struct mlx5e_wqe_frag_info *get_frag(struct mlx5e_rq *rq, u16 ix) -{ - return &rq->wqe.frags[ix << rq->wqe.info.log_num_frags]; -} static int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe_cyc *wqe, u16 ix) @@ -1549,7 +1545,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, #define MLX5E_CE_BIT_MASK 0x80 -static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, +static inline bool mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, u32 cqe_bcnt, struct mlx5e_rq *rq, struct sk_buff *skb) @@ -1560,6 +1556,13 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, skb->mac_len = ETH_HLEN; + if (IS_ENABLED(CONFIG_MLX5_EN_NVMEOTCP) && cqe_is_nvmeotcp(cqe)) { + bool ret = mlx5e_nvmeotcp_rebuild_rx_skb(rq, skb, cqe, cqe_bcnt); + + if (unlikely(!ret)) + return ret; + } + if (unlikely(get_cqe_tls_offload(cqe))) mlx5e_ktls_handle_rx_skb(rq, skb, cqe, &cqe_bcnt); @@ -1606,6 +1609,8 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, if (unlikely(mlx5e_skb_is_multicast(skb))) stats->mcast_packets++; + + return true; } static void mlx5e_shampo_complete_rx_cqe(struct mlx5e_rq *rq, @@ -1629,7 +1634,7 @@ static void mlx5e_shampo_complete_rx_cqe(struct mlx5e_rq *rq, } } -static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq, +static inline bool mlx5e_complete_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, u32 cqe_bcnt, struct sk_buff *skb) @@ -1638,7 +1643,7 @@ static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq, stats->packets++; stats->bytes += cqe_bcnt; - mlx5e_build_rx_skb(cqe, cqe_bcnt, rq, skb); + return mlx5e_build_rx_skb(cqe, cqe_bcnt, rq, skb); } static inline @@ -1852,7 +1857,8 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) goto wq_cyc_pop; } - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto wq_cyc_pop; if (mlx5e_cqe_regb_chain(cqe)) if (!mlx5e_tc_update_skb_nic(cqe, skb)) { @@ -1899,7 +1905,8 @@ static void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) goto wq_cyc_pop; } - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto wq_cyc_pop; if (rep->vlan && skb_vlan_tag_present(skb)) skb_vlan_pop(skb); @@ -1948,7 +1955,8 @@ static void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 if (!skb) goto mpwrq_cqe_out; - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto mpwrq_cqe_out; mlx5e_rep_tc_receive(cqe, rq, skb); @@ -1994,13 +2002,18 @@ mlx5e_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq, } } +static inline u16 mlx5e_get_headlen_hint(struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + return min_t(u32, MLX5E_RX_MAX_HEAD, mlx5_nvmeotcp_get_headlen(cqe, cqe_bcnt)); +} + static struct sk_buff * mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi, struct mlx5_cqe64 *cqe, u16 cqe_bcnt, u32 head_offset, u32 page_idx) { struct mlx5e_frag_page *frag_page = &wi->alloc_units.frag_pages[page_idx]; - u16 headlen = min_t(u16, MLX5E_RX_MAX_HEAD, cqe_bcnt); + u16 headlen = mlx5e_get_headlen_hint(cqe, cqe_bcnt); struct mlx5e_frag_page *head_page = frag_page; u32 frag_offset = head_offset; u32 byte_cnt = cqe_bcnt; @@ -2423,7 +2436,8 @@ static void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cq if (!skb) goto mpwrq_cqe_out; - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto mpwrq_cqe_out; if (mlx5e_cqe_regb_chain(cqe)) if (!mlx5e_tc_update_skb_nic(cqe, skb)) { @@ -2756,7 +2770,9 @@ static void mlx5e_trap_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe if (!skb) goto wq_cyc_pop; - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto wq_cyc_pop; + skb_push(skb, ETH_HLEN); mlx5_devlink_trap_report(rq->mdev, trap_id, skb, From patchwork Tue Aug 22 15:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13361056 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 669E71D31D for ; Tue, 22 Aug 2023 15:07:19 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C14126 for ; Tue, 22 Aug 2023 08:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YmLOdXroKzQXg47hGcGWIZmt5KhuQmEpeUsMnj20axputAqXttMtKVff3++kgIgl7N79ug2P1dLBoVGsKt7PC9PZQeZzQKQlwh9EAnoOvET8+TRymSMtvdBj2BrpJAvNBodXhy8vUHJ0rXovm4UluAYTZ0AQvHZ0f6p3WOAVLHqbyNXpRIlAOuHPu1nwuLMUPTG6hLQQk/iA0ARbxLshLUPugjYxmLtPS/+RQEq9RWN+mAMtTeCziuGs2dt6E+5eeq3RKs62y2df6vZsJ9xKJH71iwDnR6Ma/iAky9TRiqG8pcwCKYFdhAjHkw02PdTELBxgwuMxKhTGw9lVUd4jPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A5UMsq+PeivF9IlFvx9u8vCcbgoy76rjeBbH6/J/kiU=; b=hpcMiXcpdcH8YH9SkZXHNSvtmTMjsGlmZvMIhihFsTXCtAmB/rJCcnZMTXaCQJ1bCqCuj+proPB30z6n+nrgr+YE4F9fpFDuBlU0EBWM94ecZVHRuxNEpLMuahH+vv7Ityum5SJNwGI/5i6nrdjBxwrLukgC/p9Yrpd8XoUK3gZ3sHKYsgtr70OO73DSNIj/lfKx633Q/j9u+WN9w3KB3db+6jXONbzp2GkpsO/7A+Tkszhw0LM4+LQf3mIOatPwIZL6Sz+gk4MXHpYhajhyGuNajPrmPqC95TljEPYTF1t988XifVRToUtQ3s7lPuyiMwjYGA0BNOvWhryaqEQ5eA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A5UMsq+PeivF9IlFvx9u8vCcbgoy76rjeBbH6/J/kiU=; b=eKVXTlnl5wg8/AEVMBL1lhsXRfM0LAf3At16y+MdBA4j/pJWyGUyseUR2MvmlZ6DzxDrVMvd8T7OzXYrjATTNDp8sk/k3gL843WSRzIyNa4jWv3I62K8fsTaPcp1kW3Pm3itnYYJgo6S7ZpMymGGw72nseJ6HNNJYLJvqt8R0Ieuhd66Z1jOqJp3orNaFq5eh8jfBnkVsTB1+hwhsMMw49gkkBVpJF2G7zcPdg1pvETClxe78DnFs7gAVcMyqZiBf+XOGqiwYeW6B6SQQX/UzdNzdfLIQjTRHUvJ6kMTX6CFeMP11+B325BNiuf8rg1GdDke8kZhr34KJGW5LyQ0wQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 15:07:14 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::968e:999a:9134:766b%7]) with mapi id 15.20.6699.020; Tue, 22 Aug 2023 15:07:14 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com, galshalom@nvidia.com, mgurtovoy@nvidia.com Subject: [PATCH v13 24/24] net/mlx5e: NVMEoTCP, statistics Date: Tue, 22 Aug 2023 15:04:25 +0000 Message-Id: <20230822150425.3390-25-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822150425.3390-1-aaptel@nvidia.com> References: <20230822150425.3390-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0250.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::20) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a329222-87da-4111-2be4-08dba32177e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jCsY9zAECyqvvyb/OEWRAW8phw8LyWf5ZFCE1TQy/JIkPr2RGEyA4O/6mB1JoFmS774tlenwrieHz6EnZTOv5s44XjF3uMqXdWFYOgPVtDD/f7o63fBk8VgnGQQC80m88rP5QBJh7KU5wzI4mlobm1mIOdo/3dhoFd6U3gTnv8s4z8fY7kI3TlFEUHQj7ylT7yE3/Be9JS/JpvCW3lvffu3qW9CfnfpMnhaBS3CILpl2cxvnWVH++fkAT7S/7ODkQ4RvjDoYE8Xp0fK0I0QvAknOHh8N4a8Xki5FWYTuTU8RTCL9AHy7nPFubRs6g7tSz534oQhQpDCeUlvYOULrTiCUNjOUtx8a47YZmSvmoJRRwDfUAbEw2mlkoMazJnZweuSijMNIBJUyrgJM4AnaSahX9zQsBSpPyyvMTcijd4+uYtQHiW18q818K4F4RgVFxEQM++1ot30QcYl6ZO/0zy2QavSA5+9m45rv/OhZ5PUMqfe9c2J9pdO5/Q7IwYIsLEUovxsTGKWAp0nTDcQ/9p+S6gme1SWxwBCXinKmcc6LaQH/3dwP9BQP/HYvtbsr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ1PR12MB6075.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(39860400002)(346002)(366004)(1800799009)(186009)(451199024)(66476007)(66556008)(6512007)(316002)(66946007)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(41300700001)(1076003)(478600001)(6666004)(38100700002)(6486002)(6506007)(83380400001)(30864003)(2906002)(7416002)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CVp1NbLeRZYpoPXhBx6TPuMLL7VmFzvV//gzMlKaWMA/UrCxcz2jlDVku1/xyizf/S8OmqzeEWOi95OtN7TT9RWuQEcO/O0YanOJS5OFixhesjTWKrN7g0fDAXyGl9+/JtLbBt+CttvPoz9qtqc7KmwlzIyO53VZmttX9C6hyvbfJeSWcB8TR7RMSeRFhfLguKPyLYYI2LnfMFnan4+nLZh6QynAuIKZD77nJG+YdW1H2GLKDKBHp6WJGotA4NmpQ9BMi0Ajy/HfqsZeARDEgdpTze3i92Zf+3aUMPIh7+AckhBz6rhO1jS0rsoZJjilbpqpBKO1XV+q7EWKSsX34tGKxN54Z95MXYp4wXUPcwhm0I6Houbvra/t9zwlhOeDFMhCVrVmOxhRE+tvmvLUaAcBCgcF5rGVcO1aoFG+05U9uAYYhxhbVAp1OeCnM/s1UQoRA6Rzwek1n0JjEvmNwGi8snj+CUHb6Q78C5hDPcmImt3xoQpNu4XOw6GIAMUZ42FTj/lnBoNxfAigGcJt7EcBNI39dq5P67dc0gx5nVdDsjygf2TYL5ZATk2cG5o7eyxLA4fsTb35FdXHQoMQFLRnt7liVMAPFqy1qEVPGywQsKtKAMQt1B+IvLHIldFxYPgaN7CFp+Na8cLHDzfugooXWXLxh2QWfnRtIc1nxM0EwbBRooHbF9XxWcx8bMgx5fMhlWeRZnowfR6cAUZtgAzozo0LFylyAsbAjvftYJJEJnvdEC6hI0FrT7wbwUXOkxCEYrlixV3z9Ec22/ga2tUU3jqB5wTPbzHdGg1GrpMb7yyDjnHnVAU3mga3z1jqPqQgaMWj+lBX5ahgNsZr+PvQH8+n7ipoFI4Ua+n04nf2HiU3PhVLbq1Q9c/0Z8c/uyAWC//0CSVys5lNTN8pEqROouND4j8wICgCuxFSgl+mHTA3u7AMM9S/V+CCLkTB8MTE9SbEoBaQxGNeTHxZ+1+PnKeibYr7XpCL2BytLMgap8B2Syw46JGzOJK4EhTrV74EjDtcldUEynWKagVzy35yW45FrWxKydWALM4Vpgg7OkJ0eczBAzu4qC/at3yMYvHe9Q0Chc5sAQxgJf3TyayD/gBxmL5dLQ4IqfKH62DvALMvDAntFuGErMVEI2gs0RU94QgD6UcKRA9jHfcFzfM4R4bKxLyLoLJJya0bNKLKYTQtny0tYOj5FXIzDToUWD6Q278CCgyy0WLO92PXHvFCgD5P1q3liq5qC3G7MGEHWFY1xRnts54w2Wzwwbc8uUZO/bgFmthWo9mZlymowj/xl5ZaSPpq+k+kfqzGTUTy0lO7tcy6024fMXM8svzesEDhy8TtnkfIjucDFeHMI+K0IYh+nCWjXWEWzcPZIf7nAxfoh9p1qIHtOcRysQHPJrfgNh+Ph2hBJ91Kk8h+gMJKwpThbeojDfhIkAnhpwzkroA45pnpd6xF84Ltysbt5fGwB6aBxq3FwOflRieDbPIxtV3u021shK34l0AgAWZecUiKLpa6YEyGJCJCp6Sbkc3lzJUg0xsRd3o1ZLCEDgt2oAkZA3Ic6BmaM3d3deTu/K0v/672dWPjs68MyIsr X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a329222-87da-4111-2be4-08dba32177e4 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 15:07:14.5234 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qKDdz0MqZZED7nyf6u8WdHfJDlWu1VcNF+mgGwohq/AjMbHA2Eam15beXJbRNnPQlEqRn0ASbKg58haz589O8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org NVMEoTCP offload statistics include both control and data path statistic: counters for the netdev ddp ops, offloaded packets/bytes, resync and dropped packets. Expose the statistics using ulp_ddp_ops->get_stats() instead of the regular statistics flow. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 53 ++++++++++++--- .../mellanox/mlx5/core/en_accel/nvmeotcp.h | 16 +++++ .../mlx5/core/en_accel/nvmeotcp_rxtx.c | 11 +++- .../mlx5/core/en_accel/nvmeotcp_stats.c | 66 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en_stats.h | 7 ++ 6 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile index feff577e4006..835ffd0aa047 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -109,7 +109,8 @@ mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/ktls_stats.o \ en_accel/fs_tcp.o en_accel/ktls.o en_accel/ktls_txrx.o \ en_accel/ktls_tx.o en_accel/ktls_rx.o -mlx5_core-$(CONFIG_MLX5_EN_NVMEOTCP) += en_accel/fs_tcp.o en_accel/nvmeotcp.o en_accel/nvmeotcp_rxtx.o +mlx5_core-$(CONFIG_MLX5_EN_NVMEOTCP) += en_accel/fs_tcp.o en_accel/nvmeotcp.o \ + en_accel/nvmeotcp_rxtx.o en_accel/nvmeotcp_stats.o mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \ steering/dr_matcher.o steering/dr_rule.o \ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index c5bfc1578ddf..86637269c76d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "en_accel/nvmeotcp.h" #include "en_accel/nvmeotcp_utils.h" #include "en_accel/fs_tcp.h" @@ -615,9 +616,15 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, { struct nvme_tcp_ddp_config *config = &tconfig->nvmeotcp; struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_sw_stats *sw_stats; struct mlx5_core_dev *mdev = priv->mdev; struct mlx5e_nvmeotcp_queue *queue; int queue_id, err; + u32 channel_ix; + + channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, + config->io_cpu); + sw_stats = &priv->nvmeotcp->sw_stats; if (tconfig->type != ULP_DDP_NVME) { err = -EOPNOTSUPP; @@ -644,11 +651,11 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, queue->id = queue_id; queue->dgst = config->dgst; queue->pda = config->cpda; - queue->channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, - config->io_cpu); + queue->channel_ix = channel_ix; queue->size = config->queue_size; queue->max_klms_per_wqe = MLX5E_MAX_KLM_PER_WQE(mdev); queue->priv = priv; + queue->sw_stats = sw_stats; init_completion(&queue->static_params_done); err = mlx5e_nvmeotcp_queue_rx_init(queue, config, netdev); @@ -660,6 +667,7 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, if (err) goto destroy_rx; + atomic64_inc(&sw_stats->rx_nvmeotcp_sk_add); write_lock_bh(&sk->sk_callback_lock); ulp_ddp_set_ctx(sk, queue); write_unlock_bh(&sk->sk_callback_lock); @@ -673,6 +681,7 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, free_queue: kfree(queue); out: + atomic64_inc(&sw_stats->rx_nvmeotcp_sk_add_fail); return err; } @@ -686,6 +695,8 @@ mlx5e_nvmeotcp_queue_teardown(struct net_device *netdev, queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + atomic64_inc(&queue->sw_stats->rx_nvmeotcp_sk_del); + WARN_ON(refcount_read(&queue->ref_count) != 1); mlx5e_nvmeotcp_destroy_rx(priv, queue, mdev); @@ -817,25 +828,34 @@ mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, struct ulp_ddp_io *ddp) { struct scatterlist *sg = ddp->sg_table.sgl; + struct mlx5e_nvmeotcp_sw_stats *sw_stats; struct mlx5e_nvmeotcp_queue_entry *nvqt; struct mlx5e_nvmeotcp_queue *queue; struct mlx5_core_dev *mdev; int i, size = 0, count = 0; + int ret = 0; queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + sw_stats = queue->sw_stats; mdev = queue->priv->mdev; count = dma_map_sg(mdev->device, ddp->sg_table.sgl, ddp->nents, DMA_FROM_DEVICE); - if (count <= 0) - return -EINVAL; + if (count <= 0) { + ret = -EINVAL; + goto ddp_setup_fail; + } - if (WARN_ON(count > mlx5e_get_max_sgl(mdev))) - return -ENOSPC; + if (WARN_ON(count > mlx5e_get_max_sgl(mdev))) { + ret = -ENOSPC; + goto ddp_setup_fail; + } - if (!mlx5e_nvmeotcp_validate_sgl(sg, count, READ_ONCE(netdev->mtu))) - return -EOPNOTSUPP; + if (!mlx5e_nvmeotcp_validate_sgl(sg, count, READ_ONCE(netdev->mtu))) { + ret = -EOPNOTSUPP; + goto ddp_setup_fail; + } for (i = 0; i < count; i++) size += sg_dma_len(&sg[i]); @@ -847,8 +867,13 @@ mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, nvqt->ccid_gen++; nvqt->sgl_length = count; mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_UMR, ddp->command_id, count); - + atomic64_inc(&sw_stats->rx_nvmeotcp_ddp_setup); return 0; + +ddp_setup_fail: + dma_unmap_sg(mdev->device, ddp->sg_table.sgl, count, DMA_FROM_DEVICE); + atomic64_inc(&sw_stats->rx_nvmeotcp_ddp_setup_fail); + return ret; } void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi) @@ -895,6 +920,7 @@ mlx5e_nvmeotcp_ddp_teardown(struct net_device *netdev, q_entry->queue = queue; mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_INV_UMR, ddp->command_id, 0); + atomic64_inc(&queue->sw_stats->rx_nvmeotcp_ddp_teardown); } static void @@ -928,6 +954,14 @@ void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue) } } +static int mlx5e_ulp_ddp_get_stats(struct net_device *dev, + struct ethtool_ulp_ddp_stats *stats) +{ + struct mlx5e_priv *priv = netdev_priv(dev); + + return mlx5e_nvmeotcp_get_stats(priv, stats); +} + int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable) { struct mlx5e_priv *priv = netdev_priv(netdev); @@ -1016,6 +1050,7 @@ const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops = { .teardown = mlx5e_nvmeotcp_ddp_teardown, .resync = mlx5e_nvmeotcp_ddp_resync, .set_caps = mlx5e_ulp_ddp_set_caps, + .get_stats = mlx5e_ulp_ddp_get_stats, }; void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h index a5cfd9e31be7..f2a7f3cc945d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h @@ -9,6 +9,15 @@ #include "en.h" #include "en/params.h" +struct mlx5e_nvmeotcp_sw_stats { + atomic64_t rx_nvmeotcp_sk_add; + atomic64_t rx_nvmeotcp_sk_add_fail; + atomic64_t rx_nvmeotcp_sk_del; + atomic64_t rx_nvmeotcp_ddp_setup; + atomic64_t rx_nvmeotcp_ddp_setup_fail; + atomic64_t rx_nvmeotcp_ddp_teardown; +}; + struct mlx5e_nvmeotcp_queue_entry { struct mlx5e_nvmeotcp_queue *queue; u32 sgl_length; @@ -52,6 +61,7 @@ struct mlx5e_nvmeotcp_queue_handler { * @sk: The socket used by the NVMe-TCP queue * @crc_rx: CRC Rx offload indication for this queue * @priv: mlx5e netdev priv + * @sw_stats: Global software statistics for nvmeotcp offload * @static_params_done: Async completion structure for the initial umr mapping * synchronization * @sq_lock: Spin lock for the icosq @@ -88,6 +98,7 @@ struct mlx5e_nvmeotcp_queue { u8 crc_rx:1; /* for ddp invalidate flow */ struct mlx5e_priv *priv; + struct mlx5e_nvmeotcp_sw_stats *sw_stats; /* end of data-path section */ struct completion static_params_done; @@ -97,6 +108,7 @@ struct mlx5e_nvmeotcp_queue { }; struct mlx5e_nvmeotcp { + struct mlx5e_nvmeotcp_sw_stats sw_stats; struct ida queue_ids; struct rhashtable queue_hash; bool enabled; @@ -113,6 +125,7 @@ void mlx5e_nvmeotcp_ddp_inv_done(struct mlx5e_icosq_wqe_info *wi); void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi); static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv); +int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats); extern const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops; #else @@ -122,5 +135,8 @@ static inline void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv) {} static inline int set_ulp_ddp_nvme_tcp(struct net_device *dev, bool en) { return -EOPNOTSUPP; } static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} static inline void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv) {} +static inline int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, + struct ethtool_ulp_ddp_stats *stats) +{ return 0; } #endif #endif /* __MLX5E_NVMEOTCP_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c index 53a67ec72f0f..5c146de89905 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c @@ -140,6 +140,7 @@ mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(struct mlx5e_rq *rq, struct sk_buff *skb int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; struct net_device *netdev = rq->netdev; struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_rq_stats *stats = rq->stats; struct mlx5e_nvmeotcp_queue_entry *nqe; skb_frag_t org_frags[MAX_SKB_FRAGS]; struct mlx5e_nvmeotcp_queue *queue; @@ -151,12 +152,14 @@ mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(struct mlx5e_rq *rq, struct sk_buff *skb queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); if (unlikely(!queue)) { dev_kfree_skb_any(skb); + stats->nvmeotcp_drop++; return false; } cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); if (cqe_is_nvmeotcp_resync(cqe)) { nvmeotcp_update_resync(queue, cqe128); + stats->nvmeotcp_resync++; mlx5e_nvmeotcp_put_queue(queue); return true; } @@ -230,7 +233,8 @@ mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(struct mlx5e_rq *rq, struct sk_buff *skb org_nr_frags, frag_index); } - + stats->nvmeotcp_packets++; + stats->nvmeotcp_bytes += cclen; mlx5e_nvmeotcp_put_queue(queue); return true; } @@ -242,6 +246,7 @@ mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; struct net_device *netdev = rq->netdev; struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_rq_stats *stats = rq->stats; struct mlx5e_nvmeotcp_queue_entry *nqe; struct mlx5e_nvmeotcp_queue *queue; struct mlx5e_cqe128 *cqe128; @@ -251,12 +256,14 @@ mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); if (unlikely(!queue)) { dev_kfree_skb_any(skb); + stats->nvmeotcp_drop++; return false; } cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); if (cqe_is_nvmeotcp_resync(cqe)) { nvmeotcp_update_resync(queue, cqe128); + stats->nvmeotcp_resync++; mlx5e_nvmeotcp_put_queue(queue); return true; } @@ -330,6 +337,8 @@ mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, hlen + cclen, remaining); } + stats->nvmeotcp_packets++; + stats->nvmeotcp_bytes += cclen; mlx5e_nvmeotcp_put_queue(queue); return true; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c new file mode 100644 index 000000000000..21b0ac17f1b2 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + +#include "en_accel/nvmeotcp.h" + +struct ethtool_counter_map { + size_t eth_offset; + size_t mlx_offset; +}; + +#define DECLARE_ULP_SW_STAT(fld) \ + { offsetof(struct ethtool_ulp_ddp_stats, fld), \ + offsetof(struct mlx5e_nvmeotcp_sw_stats, fld) } + +#define DECLARE_ULP_RQ_STAT(fld) \ + { offsetof(struct ethtool_ulp_ddp_stats, rx_ ## fld), \ + offsetof(struct mlx5e_rq_stats, fld) } + +#define READ_CTR_ATOMIC64(ptr, dsc, i) \ + atomic64_read((atomic64_t *)((char *)(ptr) + (dsc)[i].mlx_offset)) + +#define READ_CTR(ptr, desc, i) \ + (*((u64 *)((char *)(ptr) + (desc)[i].mlx_offset))) + +#define SET_ULP_STAT(ptr, desc, i, val) \ + (*(u64 *)((char *)(ptr) + (desc)[i].eth_offset) = (val)) + +/* Global counters */ +static const struct ethtool_counter_map sw_stats_desc[] = { + DECLARE_ULP_SW_STAT(rx_nvmeotcp_sk_add), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_sk_del), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_setup), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_setup_fail), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_teardown), +}; + +/* Per-rx-queue counters */ +static const struct ethtool_counter_map rq_stats_desc[] = { + DECLARE_ULP_RQ_STAT(nvmeotcp_drop), + DECLARE_ULP_RQ_STAT(nvmeotcp_resync), + DECLARE_ULP_RQ_STAT(nvmeotcp_packets), + DECLARE_ULP_RQ_STAT(nvmeotcp_bytes), +}; + +int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats) +{ + unsigned int i, ch, n = 0; + + if (!priv->nvmeotcp) + return 0; + + for (i = 0; i < ARRAY_SIZE(sw_stats_desc); i++, n++) + SET_ULP_STAT(stats, sw_stats_desc, i, + READ_CTR_ATOMIC64(&priv->nvmeotcp->sw_stats, sw_stats_desc, i)); + + for (i = 0; i < ARRAY_SIZE(rq_stats_desc); i++, n++) { + u64 sum = 0; + + for (ch = 0; ch < priv->stats_nch; ch++) + sum += READ_CTR(&priv->channel_stats[ch]->rq, rq_stats_desc, i); + + SET_ULP_STAT(stats, rq_stats_desc, i, sum); + } + + return n; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h index 409e9a47e433..48e52509a221 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h @@ -128,6 +128,7 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, const struct ethtool_rmon_hist_range **ranges); void mlx5e_get_link_ext_stats(struct net_device *dev, struct ethtool_link_ext_stats *stats); +void mlx5e_stats_ulp_ddp_get(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats); /* Concrete NIC Stats */ @@ -385,6 +386,12 @@ struct mlx5e_rq_stats { u64 tls_resync_res_skip; u64 tls_err; #endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + u64 nvmeotcp_drop; + u64 nvmeotcp_resync; + u64 nvmeotcp_packets; + u64 nvmeotcp_bytes; +#endif }; struct mlx5e_sq_stats {