From patchwork Thu Sep 28 15:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403217 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 BF9B84BDD8 for ; Thu, 28 Sep 2023 15:10:17 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24D8F9 for ; Thu, 28 Sep 2023 08:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ur2a+BIjEj3GiN93Wa6FXFeoelx9oMRPU+ONQ+cw5C07nQTQAbUsdJ+Sa1A4Uv5VBNc6pUayFwx+pQEkL3BH5hJDwPQv5KI27jnhPPK3+UCKJuLURhDYrO1jRxI6wbLm1dMD0+WXnS7eBG48dy1/xJGECVgnoA4Gwu9KTNca8+p2Eo8A5hNU462AVhpV3Y1YZCIjcpgEC2oKoQmXnVYq58WlXOJemxlQ801V+7JrmTIA30ayOWNYyAjnRQwDap0MOZgropaBOpZ+buEneDPbURQbsiL0bj+SHeX0KCP8WDndOlsh0iBaZsK8esXXP3gO9K4fCCq5ecRjybp1vrLiqA== 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=bPBkWtHhL4JxqndJd7mnXs0w2/zR7npCoTnp2rHL0Ls=; b=E0qQAxFhIuoXd8XEVq0VKMr164aYmcHRTJF0dRaYbYyKTjF/Tped+g1bpD48JLvph98wVjLgGkrTpY9/rHJ3lpGwbarQ9Ij7huIFPC9MP1Knn5vYVmfy9cFV25uMm7A5V0uIRjTwki2CbnYvVokqptIH+MCH51zbYoPwLf0VzUMGp/YDKpj4liNHV0xrRnMoEBQ7Fulzd6/TDW1ym9/z329+L7wdmsAiLDgMjTaI/s8AfxcpqH0isNLmajO1GYcTkO/McZGM81+Tl1Ib4CT8usj6kY0Dwah9aoLNr7ZMOqlMicdqHimUg8p9lLpNpgCTR7gcQj3wWaoR4ePp952XTg== 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=bPBkWtHhL4JxqndJd7mnXs0w2/zR7npCoTnp2rHL0Ls=; b=c5ZVWCRdwwcFVXYbLGNn0Gq3WZGCR2ZJa9r5c56ztMzyFIu40vVLQUsSGKIFt256KusqnIeAxEycWzA6/JVCkRll93CAz7mNKUUIeVQ5dhFwzWo3QOwp1w2rQGcDQ3WOXcYeNTqIcaeRu6+6c0/Hs63Tc/lYeonIxKsrWbrO43ciyIiIoGQYhVQlY+xqBGBBLjlhlZKq8IrcVj/SsvjY7Rp3tvzt3EJz6BcQfRwZ0wQ/l40xRKakdA0y+YBgDXeljszujjQ/ID4y4ZL5c+WfEEEKp4x2ACLU2uZW7d/jBeKWq8IiFoZh7IZsqemPEXhGgxoA8hQ0ZjWkFe4HTqePxw== 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 DM4PR12MB5359.namprd12.prod.outlook.com (2603:10b6:5:39e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 15:10:12 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10:12 +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, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, imagedong@tencent.com Subject: [PATCH v16 01/20] net: Introduce direct data placement tcp offload Date: Thu, 28 Sep 2023 15:09:35 +0000 Message-Id: <20230928150954.1684-2-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR2P281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::16) 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_|DM4PR12MB5359:EE_ X-MS-Office365-Filtering-Correlation-Id: 46f23f95-fa76-4e81-1b42-08dbc03502d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0KHWWjMaq61dS/34KI7PxJjoXiy4eOTo81fv7aNa1RnnhnPpJGiaVhNbgIHkTPrnm891OGCdOQkNLqd23aHXVcEmdAPCrIGOtxgpEPSCXCDo+DMlzqeDuc+/SoWjwhHcU4XnRmYvgPFo0uXsBdaTeOwPgyOXy8toYgjmhINTjZg7/4UCoBmSgWjTYJx0I1pW37E/PnayRQZw44zo+QcBWKuJAwiMJxhJCbpNcEm42Y35q4+D3eMajLVYrdCMb6Bmwi1tQppY2pNPUyeUb/yUpgDQUDy7HkuVciQ8l6Emp3x8bYt/keoT4XntiMyjoW5wpnGrKH3TCwaqP0Ad8ulWkmVeAGyAKw4I51U5jpsotHPhUAI4NRkU3sa+tC4Vb0KRqsXNMhQnXCQhubJxh7LUQkKIC5UJzx+zfHlVtdivbhs03e7TNf74lepwNbDn2dvRiZYfOL7lNfPfq0Q/yuXlIC50aHm0RqiBKfuXjc3u9ZHeFJmo4BhbX7cM/oFDJ11rKx4CBtMjztIqynvda2pH14JIgMSUq/2PaBJhYHV8XLQ= 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)(39860400002)(346002)(376002)(396003)(366004)(136003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2906002)(86362001)(30864003)(6512007)(1076003)(2616005)(36756003)(478600001)(6666004)(6486002)(6506007)(38100700002)(83380400001)(26005)(7416002)(8676002)(8936002)(4326008)(5660300002)(66476007)(41300700001)(66556008)(66946007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7X59IKuPIAm1HvszT9W4vx7RmFCg2r+6qqjTOM9OJZ1lBBKh2WAV8GIYTDgoQGJOkUh9n2XiW4ZQ3U2G6eDYiT0nXIDY1r7+6l0HmNlq2I30/jvPB5qwpyTFNQ5qeff+BpRT1WYR+kvuugio0kS5spcN0Ruow8mMmS30qMETjMMUqsg5Pl/kUz4Y2hPcBuCqmqYnxcK66Atcs0OrA96Nv64FR6GcfoHY+T/vMKFNprRuPrBvJHzBwhr5wRU7n0yeAQrLGTCTYw9IPuXhjsUkFgntlOCDBkfj7ZjlSSp7k5KDYE0oiqPjh3GX8SJd5UxrkgC7d46Vpz1ynjgWxVO0AlfWK3/aPXtZ87Rgsa7moYVrKh6KnleqOegb8ddjQJN6/XWQYU8ISxG86mZOT6StV0n5DqAF0EXqaKlyCgzWVAPo6UwDz7HKO9gw/vrH2bTlOHKJBwGMppvjJFgDa+5vR8gmI2aqQgQBFvoqt/ITG0BdTKYRYh/0cg2OdnKy+VG8tJFmdPJWcCeW0XgYDyZprJxZ8uUvlp0gUg2hQXvD0P2eTn3TPyW8CZDu2GoXVZqqoFxRV+D2WD7V8ObVc1rJS1YpPxWx6GJAmKMGBV8lnnQ4evQyUca+SrIwF7cPJuDR00uOEQpWkekWGh0cDkhYZBN7KhvJRJIDnh6eEkU7pdu5KCofRY91LCuudCF1l021oOHloUEqtTCyy4LCQqn5VnvmEwKIBkUXiwh4ulE0nWpkM9v3LEreXrjtu8EU0o+iQHSXs1NWRUub/FkwWZqAxkJWuTrQGbnogSBXbPXHmYyQEBwm/LIngpqW1dLfvZoHCRjhiQZMDk4U+8KYgWGYL0w87ck+VWEeYKRqBtJsDir7TrPTDYiLy0K2woEF88V8IxMFbtcBNyQ8MSM65BMX2jlyARAa3U6u3w7XjJDSs+mYN68A0JV2hsCq5Dpf6/FMECS4OfQoPiUHb1w5Jk6puhcfMHneNs59Ao4CjohJU5DEt2GfUwRLDPCesR6B3ckrwBUoaDiemafjAgNFHlt/KY61ndb1XPD1808ONxja9M15sjDiBmL/XQQjdku+azungI0razSrKo/o3iTlDUY2bXKAsYssOSDHUly8M7jUvs/KlI/0WLCAQKjNIw8KWJfDPEUp3eC3Jkn1ARaJ1m8ZMc6u7nLFbvclQVYhudeaBR0A2QWCQVHJilGbcS3GxKURW4NAz3K6K4O+ZPIcOg4PDeZ380sFrRI32BX1hdAULiwsmSPMQ/xfaTTD2mQQR/1l+4MQnluXqEGL61S6zIubmreFiwC8zw4kx8NtrBvG0evoGsHtvM53BhZuIPobsBhea+L78EcCUBaMbUtmAxF/CZYjkEI5FRy4KltbqNDR5/OL6o9ml25Py+WfDPD37jjYkbfYMWf1YXCIsGBEXly3UmhRS79zGr9pN1vtDGs7ijuEuTw04iLo7lnYoHEvORf2xtcInu04+ZgNOS2IDny2m1zCzvSS/vGX2SoK35qyTRVU+GbwGDaPelVPNtr0nnEL2DHyZIb9K4dgfiBDfC0SGGdvbhaRA8Trx1nPOokO4k+GCvUtvO7d5NfT7pZF3HGa X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46f23f95-fa76-4e81-1b42-08dbc03502d1 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:11.9161 (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: 0BQ1Oe/YORomTUOoxisF0vYB3UcSJ+FSFOjxe6aOcvQkJtW/PLMGfeJ5TpP2cNVfkcYmsIbfGGb2M7SttjRZsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5359 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 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->no_condense 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 | 295 +++++++++++++++++++++++++++++ include/net/ulp_ddp_caps.h | 42 ++++ net/Kconfig | 20 ++ net/core/Makefile | 1 + net/core/skbuff.c | 3 +- net/core/ulp_ddp.c | 71 +++++++ net/ipv4/tcp_input.c | 13 +- net/ipv4/tcp_ipv4.c | 3 + net/ipv4/tcp_offload.c | 3 + 12 files changed, 494 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 7e520c14eb8c..c4b79629af2a 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; @@ -1409,6 +1413,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); @@ -1648,6 +1654,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 }; /** @@ -1819,6 +1828,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 * @@ -2118,6 +2130,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..700b2096d0d9 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. + * @no_condense: When set, don't condense fragments (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 no_condense: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_no_condense(struct sk_buff *skb) +{ +#ifdef CONFIG_ULP_DDP + return skb->no_condense; +#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..68a849727ccf --- /dev/null +++ b/include/net/ulp_ddp.h @@ -0,0 +1,295 @@ +/* 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 + */ +struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; +}; + +/** + * 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 + * @io_cpu: cpu core running the IO thread for this socket + */ +struct ulp_ddp_config { + enum ulp_ddp_type type; + int io_cpu; + 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 netlink_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 netlink_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 + * Documentation/netlink/specs/ulp_ddp.yaml + */ +}; + +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 netlink_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..a41200cf6664 --- /dev/null +++ b/include/net/ulp_ddp_caps.h @@ -0,0 +1,42 @@ +/* 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 and keep in sync with + * Documentation/netlink/specs/ulp_ddp.yaml + */ + 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 2198979470ec..e7d568a4f57c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -6592,7 +6593,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_no_condense(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..61bc3e73c1dd --- /dev/null +++ b/net/core/ulp_ddp.c @@ -0,0 +1,71 @@ +// 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); + + config->io_cpu = sk->sk_incoming_cpu; + 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 584825ddd0a0..3bf1daff2c80 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4700,7 +4700,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; @@ -5269,6 +5272,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->no_condense = skb->no_condense; + nskb->ulp_crc = skb->ulp_crc; #endif TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start; if (list) @@ -5302,6 +5309,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 f13eb7e23d03..fb6ce5c7d073 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 Thu Sep 28 15:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403218 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 CA9DC4BDD8 for ; Thu, 28 Sep 2023 15:10:24 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5929119D for ; Thu, 28 Sep 2023 08:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pd85EszZrqIgfQwETiiGkJdV3mBq4wd8bNAcTSr0zbYHdpCTOoqnViHk6BIHG9lE92px4wzW9uN76IsezHzdMbUn8SVo+zl5Arbal/ep+DzcxspMAi01nOVQELio/YZ5bAAbLSSJ1peXplcClzPZ4u4Ml14xct4qvlw/PzmQl5kX+UVZTUkfQ/6kddMDAOR3C8GjF5uUs//YXIh28Ao4Ostk8ezqIPJun8hGpkDP8kIh3Y6IaKaBtuUkgCZ0QEVntHvnAIe4I88DkdVbpKYR7PWKNf8j7VTOPTweutZ3/ER5HESQpkGxgocOv9knsHojoecqmBtYwVR23JaIxDHKyw== 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=vqzcmgjxRU62Ume557natbjSfWWgXgIAVlI4dkGhZvc=; b=GWlcJxkAV2La6okVLy0hySOvK3LlMy+GtbLEJOGKpoUA+0IDln3GT8orN2IFCoiggxkpAe+gwakqbW1Dv3+tFyNZZYzrh/HfYNPQ722btExgsyfKEkmO8IdiqbLujwcAN35Yz5/AEf4M5NkkJ130nQ6i+55eWvfz7ankpu3Snb4gkzalzqwXHqHr4oayuh4m3vOyAnLG/9ky/tgFr4MIqHY3OBfR30sRivO1vdz7IHKc/4JWRpiIkCMn+8lrZg6FXhrORSL+jby606VqTDkG3NppdAdtRkmoy3/No9c4sYWmWgI2XR4g94vHK7ip57kcG9ZPlhV4aL67KHRSquzHuw== 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=vqzcmgjxRU62Ume557natbjSfWWgXgIAVlI4dkGhZvc=; b=IbekDovpHNqeIaUfUBXN6O5hn9SDKJ4HGqLQd32AzozcBBR4CJ+6GuZWtIpnJY3GsZHew3hVllTr04rENi7SWJrIEBQql0GJEp03kXFF2qoQ2ORzpjZSXQIbiSAb6CTsbJ9ckaC8/iDqF/jkJAycXcdXxZaftibM2e2dtFun9YHJl5pAP5VLVcYxeZTUDi0qMOzJm5s3+zoKyakQX/QeRH6r6dbgQ5xYpT6tLkdkv5N4KyL4HEXi/CQ7hSTHieQU3IuVtb/SObqqkaaC4i57Iu3LYrOPDuXOGN0mmuS9Cmqh4jCGg0OnJP1zniZu1tBXsXCzNG+5djZgOWPuZL9dpg== 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 DM4PR12MB5359.namprd12.prod.outlook.com (2603:10b6:5:39e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 15:10:18 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10:18 +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, edumazet@google.com, pabeni@redhat.com, imagedong@tencent.com Subject: [PATCH v16 02/20] netlink: add new family to manage ULP_DDP enablement and stats Date: Thu, 28 Sep 2023 15:09:36 +0000 Message-Id: <20230928150954.1684-3-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0191.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ca::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_|DM4PR12MB5359:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a1866e4-bc6e-44ed-6a35-08dbc03506e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ASc4cY64AR5l3fmcrquufrMQTiBY7UJATDxUZ9/esSvSrVdll25tKJknlIYJ9e9B+I5X1yihqeDP6h89Oljz5Ch/w18tPL36roobW2JH33V/ZJ54prZHHVaTUIywURE2RMDLRAu18oVFG4lT1ILzKjRGzdsARUlw2jtxE6JwmjXNGKj5eBBk668CB75cl8mmst01/vSK4HHM5sldyXHReF4JZfEahfAuN6R9LeVpT8j00J/ZSHXLNjuba4hrPIlhVoIrjJKotCwo7xlgSuNqYYsaG5jYD3VIFtZEmj66yYPMVnPAcfdxIQODzbi4mzGA+WFVE7p+EjOHXhzBY8yAJfJfhlLYvWtPY2dr4yr0MEMr22/qasrmBfu6X3A8mVQy2IjqLkk4iNi4FZOrz3uWSujb7CPTCF3eqYkWemgenZTHO5H+U1eEKuEUwK75y6MH2u4+8rEAzuxnQeC+WXQrpEqFkdVYYiwIuQwMO+9Ctt+m/05VvRw/p7R6fPgy+anxw9Z9j1FCkVmyZs/185sJS2JMDSLu/T+woP51xeAeybPpyh+baZ2IqFEc7gOch+sLBMdJ2L4XhbqcltxUbJu/Dw6YudVOBe7d+YnVTer/sJ8= 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)(39860400002)(346002)(376002)(396003)(366004)(136003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2906002)(86362001)(30864003)(6512007)(1076003)(2616005)(36756003)(478600001)(6666004)(6486002)(6506007)(38100700002)(83380400001)(26005)(7416002)(8676002)(8936002)(4326008)(5660300002)(66476007)(41300700001)(66556008)(66946007)(316002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AA2h2C+R2jN0k6SeE7ddDT3XAx+fjp+5QAkZTQQ/NoG5wFkQoxhm4+U7XLe77IzT4/CqVFaDgMhmrebe2tlBsIEjcr1FPWYeFiTzcl6HWpWgt9FpvLLV1rXlsgXLvqQYx6qhtk8XEVZSA5r3m6pRhDJwpW9ZKO4JLqEowTBD9owTL6S/ZkNtV2wzgBi9gCdxLBsmcsIxl253ZuBffDMOzPEazyO8pjqWhxSi3M3Sz1K5XFvH54SWnp1noIb3PqKNqcZTpmJqcyJp+NFVOLlZOJnh7f/3hTQOQ0Tm2NSdQGK4HFLYLqnulTBdCOtalZlPQC1TvOWOcxy6ncWEVbFiSxpM8jhQ+S/tD0/DuLjqkpVGZBKMswpbfcxefAsCoDG9ip9y/qjRKfErW0AdJz4OMglnPxn9tYG0c7kSWIXvgb+WvaeTj09zTbtBTXtyShwsdcN3zllZEBC1rdi8m1vn9pItA5yaAWtijAnwx0FQDhjAFZh6nZmmEh/flX7k8ClhpEM+QjlWYqs7ED6HOTGa0N22rGAaosP85Ru1arXdjgN8NgKdy+zxwZtYlQEqBPv2GT2WRIYxDDy6Sl94pUBzwBsfrAi4yIdNXFPd+AsJw1gLRnAZk+t2W4vzdYx4+KQNoUZjziM/RIVZrn/Ahr4UEclxhcJUkDxKxW8p+Dl72jOv1YNSPcWYIJiEj6D7fU/yp0saWv9oMPbpc6zT6fGwtbFljQ80+Oqu3ws3MOGkRieZbBy2rRBFu5sOvzGmOOMffUo7KgRq2Mc8NNaU+QTB59D4UvS8DCvLPTsdcVlQGWl/ZufncDkTNIYArvwp54NSJ38q0zQ/7LJQM1R5CYlUL5XTcHJT9Vfd9d4qea+faT0lcK0ZcBTAI23FK1W4R+imILOPMrf7i9DXXUiOEAPxtLo192LcYurK+8JrOCs68a5AR5tW135FVGRoxA/XWi18KcHHq0TvdrWNY6Xo7n8AXlky8K38/RoopvCKOlPTaiPjZN9Z8Ci26GomuwgRIaI1lOVs9+IngoMQVOmDPwPiDZH19jWIU6+FzhnvxGE88G2yNjNZddQPhjg+qN8zsZV5qZ5j9Oj1l7uHkK3+4eMogdisPQSytFLEfA+VruNBxsI77QEq6uREXk2C9wy4LwKZssOpjZXhpSH8qGaB9l0fyfnqqFFuqLGuzlfBA7QHPxRH5iAW8me4L3RIRDi38K7crvlwALYDyY5qL9AG2DFT1w6BBgnGM4UOyw6XuHlEvRH8Hg/yIBkmxu65nRrQ20DCeH4dD07mVjmmf2CLwDFN7CCMHOEfRF7frspxlP36drtnlsf+ZzWY5i09zHGDfk1YJgd7F6LUzKxV4M3eV0mbWRs4RTGIYhKhLJ0GhwgGpQT5mlIePBP/PPr6kL+3j89Ba17wqlsJ28Hf7jp/wZPqKpCjUYA2t+5UbinZDzsgAMvLft9QWMnrbO4Z/OH6z3+NyFtbbq8c/QpZO5U5bfRqORltaatOEPZy0cDX7kUqMADkRTuAdF9IQEXHSqFswJ+m7Ye05BrAeo9BljJFuRIi5sLrk0UsoXftzajY12dWz91nJXakCxG9tEVm8Cv6U5tm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1866e4-bc6e-44ed-6a35-08dbc03506e0 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:18.7734 (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: xh2dmAfDs2qN9PoFSKCjuPahvgv6TxDT3iusJeBgRqRORxBkH1p3JzHq+TGf69WDY9FCT2g/mZ2CUY47lkP7tA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5359 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 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 a new netlink family to get/set ULP DDP capabilities on a network device and to retrieve statistics. The messages use the genetlink infrastructure and are specified in a YAML file which was used to generate some of the files in this commit: ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --header \ -o net/core/ulp_ddp_gen_nl.h ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --source \ -o net/core/ulp_ddp_gen_nl.c ./tools/net/ynl/ynl-gen-c.py --mode uapi \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --header \ > include/uapi/linux/ulp_ddp_nl.h Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- Documentation/netlink/specs/ulp_ddp.yaml | 183 +++++++++++ include/uapi/linux/ulp_ddp_nl.h | 59 ++++ net/core/Makefile | 2 +- net/core/ulp_ddp_gen_nl.c | 85 +++++ net/core/ulp_ddp_gen_nl.h | 32 ++ net/core/ulp_ddp_nl.c | 388 +++++++++++++++++++++++ 6 files changed, 748 insertions(+), 1 deletion(-) create mode 100644 Documentation/netlink/specs/ulp_ddp.yaml create mode 100644 include/uapi/linux/ulp_ddp_nl.h create mode 100644 net/core/ulp_ddp_gen_nl.c create mode 100644 net/core/ulp_ddp_gen_nl.h create mode 100644 net/core/ulp_ddp_nl.c diff --git a/Documentation/netlink/specs/ulp_ddp.yaml b/Documentation/netlink/specs/ulp_ddp.yaml new file mode 100644 index 000000000000..882aa4e52992 --- /dev/null +++ b/Documentation/netlink/specs/ulp_ddp.yaml @@ -0,0 +1,183 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +# +# Author: Aurelien Aptel +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# + +name: ulp_ddp + +protocol: genetlink + +doc: Netlink protocol to manage ULP DPP on network devices. + +definitions: + - + type: enum + name: cap + entries: + - nvme-tcp + - nvme-tcp-ddgst-rx + +uapi-header: linux/ulp_ddp_nl.h + +attribute-sets: + - + name: stat + attributes: + - + name: ifindex + doc: interface index of the net device. + type: u32 + - + name: pad + type: pad + - + name: rx-nvmeotcp-sk-add + doc: Sockets successfully configured for NVMeTCP offloading. + type: u64 + - + name: rx-nvmeotcp-sk-add-fail + doc: Sockets failed to be configured for NVMeTCP offloading. + type: u64 + - + name: rx-nvmeotcp-sk-del + doc: Sockets with NVMeTCP offloading configuration removed. + type: u64 + - + name: rx-nvmeotcp-setup + doc: NVMe-TCP IOs successfully configured for Rx Direct Data Placement. + type: u64 + - + name: rx-nvmeotcp-setup-fail + doc: NVMe-TCP IOs failed to be configured for Rx Direct Data Placement. + type: u64 + - + name: rx-nvmeotcp-teardown + doc: NVMe-TCP IOs with Rx Direct Data Placement configuration removed. + type: u64 + - + name: rx-nvmeotcp-drop + doc: Packets failed the NVMeTCP offload validation. + type: u64 + - + name: rx-nvmeotcp-resync + doc: > + NVMe-TCP resync operations were processed due to Rx TCP packets + re-ordering. + type: u64 + - + name: rx-nvmeotcp-packets + doc: TCP packets successfully processed by the NVMeTCP offload. + type: u64 + - + name: rx-nvmeotcp-bytes + doc: Bytes were successfully processed by the NVMeTCP offload. + type: u64 + - + name: dev + attributes: + - + name: ifindex + doc: interface index of the net device. + type: u32 + - + name: hw + doc: bitmask of the capabilities supported by the device. + type: u64 + enum: cap + enum-as-flags: true + - + name: active + doc: bitmask of the capabilities currently enabled on the device. + type: u64 + enum: cap + enum-as-flags: true + - + name: wanted + doc: > + new active bit values of the capabilities we want to set on the + device. + type: u64 + enum: cap + enum-as-flags: true + - + name: wanted_mask + doc: bitmask of the meaningful bits in the wanted field. + type: u64 + enum: cap + enum-as-flags: true + - + name: pad + type: pad + +operations: + list: + - + name: get + doc: Get ULP DDP capabilities. + attribute-set: dev + do: + request: + attributes: + - ifindex + reply: &dev-all + attributes: + - ifindex + - hw + - active + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + dump: + reply: *dev-all + - + name: stats + doc: Get ULP DDP stats. + attribute-set: stat + do: + request: + attributes: + - ifindex + reply: &stats-all + attributes: + - ifindex + - rx-nvmeotcp-sk-add + - rx-nvmeotcp-sk-add-fail + - rx-nvmeotcp-sk-del + - rx-nvmeotcp-setup + - rx-nvmeotcp-setup-fail + - rx-nvmeotcp-teardown + - rx-nvmeotcp-drop + - rx-nvmeotcp-resync + - rx-nvmeotcp-packets + - rx-nvmeotcp-bytes + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + dump: + reply: *stats-all + - + name: set + doc: Set ULP DDP capabilities. + attribute-set: dev + do: + request: + attributes: + - ifindex + - wanted + - wanted_mask + reply: + attributes: + - ifindex + - hw + - active + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + - + name: set-ntf + doc: Notification for change in ULP DDP capabilities. + notify: get + +mcast-groups: + list: + - + name: mgmt diff --git a/include/uapi/linux/ulp_ddp_nl.h b/include/uapi/linux/ulp_ddp_nl.h new file mode 100644 index 000000000000..fc63749c9251 --- /dev/null +++ b/include/uapi/linux/ulp_ddp_nl.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_ULP_DDP_H +#define _UAPI_LINUX_ULP_DDP_H + +#define ULP_DDP_FAMILY_NAME "ulp_ddp" +#define ULP_DDP_FAMILY_VERSION 1 + +enum ulp_ddp_cap { + ULP_DDP_CAP_NVME_TCP, + ULP_DDP_CAP_NVME_TCP_DDGST_RX, +}; + +enum { + ULP_DDP_A_STAT_IFINDEX = 1, + ULP_DDP_A_STAT_PAD, + ULP_DDP_A_STAT_RX_NVMEOTCP_SK_ADD, + ULP_DDP_A_STAT_RX_NVMEOTCP_SK_ADD_FAIL, + ULP_DDP_A_STAT_RX_NVMEOTCP_SK_DEL, + ULP_DDP_A_STAT_RX_NVMEOTCP_SETUP, + ULP_DDP_A_STAT_RX_NVMEOTCP_SETUP_FAIL, + ULP_DDP_A_STAT_RX_NVMEOTCP_TEARDOWN, + ULP_DDP_A_STAT_RX_NVMEOTCP_DROP, + ULP_DDP_A_STAT_RX_NVMEOTCP_RESYNC, + ULP_DDP_A_STAT_RX_NVMEOTCP_PACKETS, + ULP_DDP_A_STAT_RX_NVMEOTCP_BYTES, + + __ULP_DDP_A_STAT_MAX, + ULP_DDP_A_STAT_MAX = (__ULP_DDP_A_STAT_MAX - 1) +}; + +enum { + ULP_DDP_A_DEV_IFINDEX = 1, + ULP_DDP_A_DEV_HW, + ULP_DDP_A_DEV_ACTIVE, + ULP_DDP_A_DEV_WANTED, + ULP_DDP_A_DEV_WANTED_MASK, + ULP_DDP_A_DEV_PAD, + + __ULP_DDP_A_DEV_MAX, + ULP_DDP_A_DEV_MAX = (__ULP_DDP_A_DEV_MAX - 1) +}; + +enum { + ULP_DDP_CMD_GET = 1, + ULP_DDP_CMD_STATS, + ULP_DDP_CMD_SET, + ULP_DDP_CMD_SET_NTF, + + __ULP_DDP_CMD_MAX, + ULP_DDP_CMD_MAX = (__ULP_DDP_CMD_MAX - 1) +}; + +#define ULP_DDP_MCGRP_MGMT "mgmt" + +#endif /* _UAPI_LINUX_ULP_DDP_H */ diff --git a/net/core/Makefile b/net/core/Makefile index 09da9ed3f9ff..35a882e7276d 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -18,7 +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_ULP_DDP) += ulp_ddp.o ulp_ddp_nl.o ulp_ddp_gen_nl.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/ulp_ddp_gen_nl.c b/net/core/ulp_ddp_gen_nl.c new file mode 100644 index 000000000000..505bdc69b215 --- /dev/null +++ b/net/core/ulp_ddp_gen_nl.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "ulp_ddp_gen_nl.h" + +#include + +/* ULP_DDP_CMD_GET - do */ +static const struct nla_policy ulp_ddp_get_nl_policy[ULP_DDP_A_DEV_IFINDEX + 1] = { + [ULP_DDP_A_DEV_IFINDEX] = { .type = NLA_U32, }, +}; + +/* ULP_DDP_CMD_STATS - do */ +static const struct nla_policy ulp_ddp_stats_nl_policy[ULP_DDP_A_STAT_IFINDEX + 1] = { + [ULP_DDP_A_STAT_IFINDEX] = { .type = NLA_U32, }, +}; + +/* ULP_DDP_CMD_SET - do */ +static const struct nla_policy ulp_ddp_set_nl_policy[ULP_DDP_A_DEV_WANTED_MASK + 1] = { + [ULP_DDP_A_DEV_IFINDEX] = { .type = NLA_U32, }, + [ULP_DDP_A_DEV_WANTED] = NLA_POLICY_MASK(NLA_U64, 0x3), + [ULP_DDP_A_DEV_WANTED_MASK] = NLA_POLICY_MASK(NLA_U64, 0x3), +}; + +/* Ops table for ulp_ddp */ +static const struct genl_split_ops ulp_ddp_nl_ops[] = { + { + .cmd = ULP_DDP_CMD_GET, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_get_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_get_nl_policy, + .maxattr = ULP_DDP_A_DEV_IFINDEX, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = ULP_DDP_CMD_GET, + .dumpit = ulp_ddp_nl_get_dumpit, + .flags = GENL_CMD_CAP_DUMP, + }, + { + .cmd = ULP_DDP_CMD_STATS, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_stats_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_stats_nl_policy, + .maxattr = ULP_DDP_A_STAT_IFINDEX, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = ULP_DDP_CMD_STATS, + .dumpit = ulp_ddp_nl_stats_dumpit, + .flags = GENL_CMD_CAP_DUMP, + }, + { + .cmd = ULP_DDP_CMD_SET, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_set_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_set_nl_policy, + .maxattr = ULP_DDP_A_DEV_WANTED_MASK, + .flags = GENL_CMD_CAP_DO, + }, +}; + +static const struct genl_multicast_group ulp_ddp_nl_mcgrps[] = { + [ULP_DDP_NLGRP_MGMT] = { "mgmt", }, +}; + +struct genl_family ulp_ddp_nl_family __ro_after_init = { + .name = ULP_DDP_FAMILY_NAME, + .version = ULP_DDP_FAMILY_VERSION, + .netnsok = true, + .parallel_ops = true, + .module = THIS_MODULE, + .split_ops = ulp_ddp_nl_ops, + .n_split_ops = ARRAY_SIZE(ulp_ddp_nl_ops), + .mcgrps = ulp_ddp_nl_mcgrps, + .n_mcgrps = ARRAY_SIZE(ulp_ddp_nl_mcgrps), +}; diff --git a/net/core/ulp_ddp_gen_nl.h b/net/core/ulp_ddp_gen_nl.h new file mode 100644 index 000000000000..277fb9dbfdcd --- /dev/null +++ b/net/core/ulp_ddp_gen_nl.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_ULP_DDP_GEN_H +#define _LINUX_ULP_DDP_GEN_H + +#include +#include + +#include + +int ulp_ddp_get_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); +void +ulp_ddp_put_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); + +int ulp_ddp_nl_get_doit(struct sk_buff *skb, struct genl_info *info); +int ulp_ddp_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); +int ulp_ddp_nl_stats_doit(struct sk_buff *skb, struct genl_info *info); +int ulp_ddp_nl_stats_dumpit(struct sk_buff *skb, struct netlink_callback *cb); +int ulp_ddp_nl_set_doit(struct sk_buff *skb, struct genl_info *info); + +enum { + ULP_DDP_NLGRP_MGMT, +}; + +extern struct genl_family ulp_ddp_nl_family; + +#endif /* _LINUX_ULP_DDP_GEN_H */ diff --git a/net/core/ulp_ddp_nl.c b/net/core/ulp_ddp_nl.c new file mode 100644 index 000000000000..55e5c51b6d88 --- /dev/null +++ b/net/core/ulp_ddp_nl.c @@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ulp_ddp.c + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ +#include +#include "ulp_ddp_gen_nl.h" + +#define ULP_DDP_STATS_CNT (sizeof(struct netlink_ulp_ddp_stats) / sizeof(u64)) + +struct reply_data { + struct net_device *dev; + netdevice_tracker tracker; + void *hdr; + u32 ifindex; + DECLARE_BITMAP(hw, ULP_DDP_C_COUNT); + DECLARE_BITMAP(active, ULP_DDP_C_COUNT); + struct netlink_ulp_ddp_stats stats; +}; + +static size_t reply_size(int cmd) +{ + size_t len = 0; + + BUILD_BUG_ON(ULP_DDP_C_COUNT > 64); + + /* ifindex */ + len += nla_total_size(sizeof(u32)); + + switch (cmd) { + case ULP_DDP_CMD_GET: + case ULP_DDP_CMD_SET: + case ULP_DDP_CMD_SET_NTF: + /* hw */ + len += nla_total_size_64bit(sizeof(u64)); + + /* active */ + len += nla_total_size_64bit(sizeof(u64)); + break; + case ULP_DDP_CMD_STATS: + /* stats */ + len += nla_total_size_64bit(sizeof(u64)) * ULP_DDP_STATS_CNT; + break; + } + + return len; +} + +/* pre_doit */ +int ulp_ddp_get_netdev(const struct genl_split_ops *ops, + struct sk_buff *skb, struct genl_info *info) +{ + struct reply_data *data; + + if (GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_DEV_IFINDEX)) + return -EINVAL; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->ifindex = nla_get_u32(info->attrs[ULP_DDP_A_DEV_IFINDEX]); + data->dev = netdev_get_by_index(genl_info_net(info), + data->ifindex, + &data->tracker, + GFP_KERNEL); + if (!data->dev) { + kfree(data); + NL_SET_BAD_ATTR(info->extack, + info->attrs[ULP_DDP_A_DEV_IFINDEX]); + return -ENOENT; + } + + info->user_ptr[0] = data; + return 0; +} + +/* post_doit */ +void ulp_ddp_put_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info) +{ + struct reply_data *data = info->user_ptr[0]; + + if (data) { + if (data->dev) + netdev_put(data->dev, &data->tracker); + kfree(data); + } +} + +static int prepare_data(struct reply_data *data, int cmd) +{ + const struct ulp_ddp_dev_ops *ops = data->dev->netdev_ops->ulp_ddp_ops; + struct ulp_ddp_netdev_caps *caps = &data->dev->ulp_ddp_caps; + + if (!ops) + return -EOPNOTSUPP; + + switch (cmd) { + case ULP_DDP_CMD_GET: + case ULP_DDP_CMD_SET: + case ULP_DDP_CMD_SET_NTF: + bitmap_copy(data->hw, caps->hw, ULP_DDP_C_COUNT); + bitmap_copy(data->active, caps->active, ULP_DDP_C_COUNT); + break; + case ULP_DDP_CMD_STATS: + ops->get_stats(data->dev, &data->stats); + break; + } + + return 0; +} + +static int fill_data(struct sk_buff *rsp, struct reply_data *data, int cmd, + const struct genl_info *info) +{ + u64 *val = (u64 *)&data->stats; + int attr, i; + + data->hdr = genlmsg_iput(rsp, info); + if (!data->hdr) + return -EMSGSIZE; + + switch (cmd) { + case ULP_DDP_CMD_GET: + case ULP_DDP_CMD_SET: + case ULP_DDP_CMD_SET_NTF: + if (nla_put_u32(rsp, ULP_DDP_A_DEV_IFINDEX, data->ifindex) || + nla_put_u64_64bit(rsp, ULP_DDP_A_DEV_HW, + data->hw[0], ULP_DDP_A_DEV_PAD) || + nla_put_u64_64bit(rsp, ULP_DDP_A_DEV_ACTIVE, + data->active[0], ULP_DDP_A_DEV_PAD)) + goto err_cancel_msg; + break; + case ULP_DDP_CMD_STATS: + if (nla_put_u32(rsp, ULP_DDP_A_STAT_IFINDEX, data->ifindex)) + goto err_cancel_msg; + + attr = ULP_DDP_A_STAT_PAD + 1; + for (i = 0; i < ULP_DDP_STATS_CNT; i++, attr++) + if (nla_put_u64_64bit(rsp, attr, val[i], + ULP_DDP_A_STAT_PAD)) + goto err_cancel_msg; + } + genlmsg_end(rsp, data->hdr); + + return 0; + +err_cancel_msg: + genlmsg_cancel(rsp, data->hdr); + + return -EMSGSIZE; +} + +int ulp_ddp_nl_get_doit(struct sk_buff *req, struct genl_info *info) +{ + struct reply_data *data = info->user_ptr[0]; + struct sk_buff *rsp; + int ret = 0; + + ret = prepare_data(data, ULP_DDP_CMD_GET); + if (ret) + return ret; + + rsp = genlmsg_new(reply_size(ULP_DDP_CMD_GET), GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + ret = fill_data(rsp, data, ULP_DDP_CMD_GET, info); + if (ret < 0) + goto err_rsp; + + return genlmsg_reply(rsp, info); + +err_rsp: + nlmsg_free(rsp); + return ret; +} + +static void ulp_ddp_nl_notify_dev(struct reply_data *data) +{ + struct genl_info info; + struct sk_buff *ntf; + + if (!genl_has_listeners(&ulp_ddp_nl_family, dev_net(data->dev), + ULP_DDP_NLGRP_MGMT)) + return; + + genl_info_init_ntf(&info, &ulp_ddp_nl_family, ULP_DDP_CMD_SET_NTF); + ntf = genlmsg_new(reply_size(ULP_DDP_CMD_GET), GFP_KERNEL); + if (!ntf) + return; + + if (fill_data(ntf, data, ULP_DDP_CMD_SET_NTF, &info)) { + nlmsg_free(ntf); + return; + } + + genlmsg_multicast_netns(&ulp_ddp_nl_family, dev_net(data->dev), ntf, + 0, ULP_DDP_NLGRP_MGMT, GFP_KERNEL); +} + +static int apply_bits(struct reply_data *data, + unsigned long *req_wanted, + unsigned long *req_mask, + struct netlink_ext_ack *extack) +{ + DECLARE_BITMAP(old_active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(new_active, 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 = &data->dev->ulp_ddp_caps; + ops = data->dev->netdev_ops->ulp_ddp_ops; + + if (!ops) + return -EOPNOTSUPP; + + /* 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(data->dev, new_active, extack); + if (ret < 0) + return ret; + bitmap_copy(new_active, caps->active, ULP_DDP_C_COUNT); + } + + /* return 1 to notify */ + return !bitmap_equal(old_active, new_active, ULP_DDP_C_COUNT); +} + +int ulp_ddp_nl_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct reply_data *data = info->user_ptr[0]; + unsigned long wanted, wanted_mask; + struct sk_buff *rsp; + bool notify; + int ret; + + if (GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_DEV_WANTED) || + GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_DEV_WANTED_MASK)) + return -EINVAL; + + rsp = genlmsg_new(reply_size(ULP_DDP_CMD_STATS), GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + wanted = nla_get_u64(info->attrs[ULP_DDP_A_DEV_WANTED]); + wanted_mask = nla_get_u64(info->attrs[ULP_DDP_A_DEV_WANTED_MASK]); + + ret = apply_bits(data, &wanted, &wanted_mask, info->extack); + if (ret < 0) + goto err_rsp; + + notify = !!ret; + ret = prepare_data(data, ULP_DDP_CMD_SET); + if (ret) + goto err_rsp; + + ret = fill_data(rsp, data, ULP_DDP_CMD_SET, info); + if (ret < 0) + goto err_rsp; + + ret = genlmsg_reply(rsp, info); + if (notify) + ulp_ddp_nl_notify_dev(data); + + return ret; + +err_rsp: + nlmsg_free(rsp); + + return ret; +} + +int ulp_ddp_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct net *net = sock_net(skb->sk); + struct net_device *netdev; + struct reply_data data; + int err = 0; + + rtnl_lock(); + for_each_netdev_dump(net, netdev, cb->args[0]) { + memset(&data, 0, sizeof(data)); + data.dev = netdev; + data.ifindex = netdev->ifindex; + + err = prepare_data(&data, ULP_DDP_CMD_GET); + if (err) + continue; + + err = fill_data(skb, &data, ULP_DDP_CMD_GET, + genl_info_dump(cb)); + if (err < 0) + break; + } + rtnl_unlock(); + + if (err != -EMSGSIZE) + return err; + + return skb->len; +} + +int ulp_ddp_nl_stats_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct reply_data *data = info->user_ptr[0]; + struct sk_buff *rsp; + int ret = 0; + + ret = prepare_data(data, ULP_DDP_CMD_STATS); + if (ret) + return ret; + + rsp = genlmsg_new(reply_size(ULP_DDP_CMD_STATS), GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + ret = fill_data(rsp, data, ULP_DDP_CMD_STATS, info); + if (ret < 0) + goto err_rsp; + + return genlmsg_reply(rsp, info); + +err_rsp: + nlmsg_free(rsp); + return ret; +} + +int ulp_ddp_nl_stats_dumpit(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct net *net = sock_net(skb->sk); + struct net_device *netdev; + struct reply_data data; + int err = 0; + + rtnl_lock(); + for_each_netdev_dump(net, netdev, cb->args[0]) { + memset(&data, 0, sizeof(data)); + data.dev = netdev; + data.ifindex = netdev->ifindex; + + err = prepare_data(&data, ULP_DDP_CMD_STATS); + if (err) + continue; + + err = fill_data(skb, &data, ULP_DDP_CMD_STATS, + genl_info_dump(cb)); + if (err < 0) + break; + } + rtnl_unlock(); + + if (err != -EMSGSIZE) + return err; + + return skb->len; +} + +static int __init ulp_ddp_init(void) +{ + int err; + + err = genl_register_family(&ulp_ddp_nl_family); + if (err) + return err; + + return 0; +} + +subsys_initcall(ulp_ddp_init); From patchwork Thu Sep 28 15:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403219 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 EAE684C853 for ; Thu, 28 Sep 2023 15:10:29 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92FE11A3 for ; Thu, 28 Sep 2023 08:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcABmG5cnpz4o60+10eQrHX0PxKaAR4cp/4aUlR2hZOjlooxoT+mJv0aFNTnLAulQHuBafJGWAWc3yVdrj86DAetiLV7kXiuU0/Jibj9uDgyOPAQwXTxbzRFpJs6tJfNcLSgvAvAxsT4Ys1SQveT8xSzq5wbpe2apaorMzYsbBR7rnxOc4YuoRr3bPVlJ4Nd54zMztqOBL0kxYkyU8H9Z16CO9BQ37nf0A8Yl1Uily7bSR9V4b9cRqAWRVPl7izh95dby9l/2DsLreUX9JOmuLPXX2N/4NUs2Gogr25LZSiVAdVKs+m1R1r0e+7fa0fVJxIrmUVhvv4+rZdtxFzmew== 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=jVhYgmoQQgwNGg70Yd/OYeT/fhog1Ihoa6b4xYGf9ms=; b=QdX7FKMBLoDDgbNCsl5Or5rOreuu3RKC5T5YnDsFoBH69HaTxpEyKPr24yYV3PsV09I9DEeAeEgdEbx9daU/eWETSj5wztImosNxfzlQtpASyjQMpvezx+BBiLFiA2BwzIuQmj97zJDuXsgeHCBeGHOKSesqnoFadfPQVI0vGgOcd35XhQ6MaEKKvm5h57midcwvt+qGq3gmoGCXGO5gVUQzJGoBLBONXA4OrmO03Gy/Lx6orMITaUcaAZUvqMiApKhVsMdu2rcArlrU4Y3biICykdo9CkhV7W6pVVyDAZqcU1Cb6itrxuj5oYdrGnwPfaXRz8Wt9I+7/jh8SRw/5Q== 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=jVhYgmoQQgwNGg70Yd/OYeT/fhog1Ihoa6b4xYGf9ms=; b=BNHF/DK1hy0znzxOMf16s56TYmVbiBStOwYtRaIN5BSMC5jcK/W7flR+NU88lbeGdBovgyEXzIjTfG43EI1YXnKyiqqAsgGGNKZUYDM6CAr8YWnkdch3ivbh2kWvEnngRLOBVlpEAD4Qok2gmF6nyDH/GYcC8uL1UV2GbasQCaiY4j5aMEk6aC2zv9mpabtKfyMGlvDkgfipAkcOfShFRGZbZTtzSbrzOYMJNluihqX8A4fz1rRxIKFT56/kyrkv2yyOzlmpRD4MMr2CRzZpSSROgiAapzGQU7qzoaGXDcHIkTQIFM0XPzk7lYAOyBZvxvumsd5LIPYvjE5oN3PKFg== 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 DM4PR12MB5359.namprd12.prod.outlook.com (2603:10b6:5:39e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 15:10:26 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10: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, viro@zeniv.linux.org.uk Subject: [PATCH v16 03/20] iov_iter: skip copy if src == dst for direct data placement Date: Thu, 28 Sep 2023 15:09:37 +0000 Message-Id: <20230928150954.1684-4-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0089.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cd::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_|DM4PR12MB5359:EE_ X-MS-Office365-Filtering-Correlation-Id: f7d58545-5315-4f2f-44da-08dbc0350ada X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kn5lxethGYXgGHes7SVCmT3ikANScgwgCpfoQx+h3Y1yh2vTtzmhykFHR8iOvy7uObRtQGCwJwiuFznnJukxe7y2AKimaEcbHqE6UQL7UdWbat81jySTeqaU1mZBhju0PUyKeGR0rAkb1/gdiMTv14tdAsn3/LT3qURZ6Tfyggs4v/uqfD2RKKp5B7002esnMLFkBwjooSVkVOrd7mFIkT1mw6EYGCU7YZc+LjX7RTVeuPdIs6FnLXENpXFrixAkW1a5fcqOKCRZ0laY4rXinTC5bFatfvormMwIgv5yei88Xjy4K9H7+5RWoi1uL4YAaKzhV9JZLZV5MIM0blvCLZGBJpaRl3z5czGV35f31qbhQ6OZ/BH6aok08rXzGFu+rozXeDZV9tIviX8vgI5Pj7E5cvJn/NHIjRpZWgBF0YlC6JTHRqgscY8J50ISAfGPaHKMTHh0YRxHZGJ4tV7JdaZxu+zjQPkDbiVUHcP56jXKyy8Ce13Gu1HoZHOu84HvPDHhv4m3HcY5BMHXMYYhQTQcwMrZnog6CQFX4XdbVl6PEOT5Dt82Gt9ZeOvJV9XY 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)(39860400002)(346002)(376002)(396003)(366004)(136003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2906002)(86362001)(6512007)(1076003)(2616005)(36756003)(478600001)(6666004)(6486002)(6506007)(38100700002)(83380400001)(26005)(7416002)(8676002)(8936002)(4326008)(5660300002)(66476007)(41300700001)(66556008)(66946007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G30Xw7S6iAimRKFSB6Fx+5gqHwil4qxZkHdkPaJeZkd0QinXJrmw7Jh4/WzRJD4u0xV5cGbH/Y+EQ+aOrIYLJMFQBBhaCiUzAajgFLeQ6YuxQsvePvRiy4RzBFAGorqydAtJPWb+ZdmPwSAI4nRQH58qt11xsDSC9xCVqvF/VNnR/+fFcNwb/DH881uKEGyxb1UaZ9yqEh971vnc9diV/cH1ZQSHbGBBG/mq9BVpPXngE2OKIHMhZBse6LMOGDP+RnAEjaCi2+4uASLvg6tImmNlTIXLFKYMoSCb6DNeEQX3z5a/rl/HmeLRTtZdTbm4KKVQQ2doJZfxkthVp2/fHU7LLoodeTSlSXYuvnrhA+CpZYASgYnWFvZN8LXgDK1tbfC9c/WvWU+W5jV4C6/eerwPN2oc54kZcjwcV+CrbVVDU/kjqKnzhgwHxhdsMI76IRO3kVp8d1R95pxz0E3h0NSY0YBoe9F2O2Hw3yUvq+jOZGlJJVWgBs0shscDltNO7//zL7nrCa46CzdGEFgv/SQV7/OB1JKYiSYGmtr791GUhMBV4AK2vJHhHhop9xEL8frCvi7NWRqlmbpLMCwHPgsXJJPIaGgx2zqDen7nzPsMn7kA3HswwviiDUqRgR2opVTjakIktEWqnRIUl51NI0vJqUm2OPVHG70z9dEWIbwznmNADBT7m/gjg+aIFArLgOnvx+mcsovlJtiGoEO0e5lNim26r7Uen7aEoFJvUtTfmxMK+/i2uxHIzkn+kfDG4V2aA0xLZ/zomTxpYjXShShdLRDFRe0c/f6EMx9JALZiS5NAxaPKcvErNxKuQh4g/XaUCvSp+qWxw2GNj3cF+xfwnU1j0UfOLAyu4qpom4ZlmKi0Rzl2zUIPeXV4/0YJPFzybIxoTsvTiVCPThzF9A7KOYKMnsFA5vhrVMCC1Iaq7vl5n9pQoBUtWsr2bgtWVi5PgcL8iPKDf+kq4GtBtitcX+t0ra6Qj/pLCiyilANe7w1GcpTAB6ZMQ7KKVtAsXdCDkhce/U/xZC+c70TlWKwRmKREVMJgxPO/xLDNkW5Iv84FT/FRr0LvLU2am0dzDyu5XTPZjsHWzYXs1LzkIzbm2OLEOMfPxtTlOZl8uKvZCxvuUh8WnRTweyEmTNnn00VV9ITAfPnsqdpx5ULhTbhcD5OJMXIyBY4KKHPF7WYau5/HEuzzuYqZR8wGZ3XUUwP1eqabnw10YyqRNVXIp3JrQ20fKwfijvQIaICpOa1aV4CD1BEph3dkvzmLhP1iwXB1raCD15TmqU9UMDjqYTAIdMgIoCjmMz3b6+BDbEldTUX1LZg6scBrRa1p0tKeNVkzfOAzlBcDXRndTP0vQcO54LC77suSPPaElTfShuOCGC15VvyKJ3WCKLaNYe6QRx6sVisVSUHiPAzcReFPQwM1FdRuPn+JJ23fhgVFv44rHvtfWXVo/qbO5my7qY/dF26GKgS5Rq12sDGqpqvVBYRx82zSVb6Hm1zcKCR6zLoiGBtkcWL7usvQGJtqImKAJ5/Vyzv1J+sAnUaq+Up5rJCRgryCk5dd7QE9GqylqbUJJ6SQX+ohtEJrWErVh21w X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7d58545-5315-4f2f-44da-08dbc0350ada X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:25.3882 (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: kSn6Y4J5S6ZaOhurj837LBGpZCPjq3kseuhD7k1ps6RdrL/X/E+YzQn0TK2p0nZEXq9TWPCgN9pEsLwbKR5rqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5359 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 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 27234a820eeb..279b2c5b1936 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 Thu Sep 28 15:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403220 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 448364CFC5 for ; Thu, 28 Sep 2023 15:10:35 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2070.outbound.protection.outlook.com [40.107.100.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98ECA1AC for ; Thu, 28 Sep 2023 08:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSJmWdF42TOErErH/4d/4B/PcJ4HPjpF1mrhSSFN+Iqa1OBqnr0DL5pqdPtbWksGd8opI1gh9OwJNWEVO0KLHN9Np8PoPaFuTsfRsvGJ2vZTDqUYtEyZd9+xELefwfT7rdGVUaVjGzJEVMSxzS0oNYEDD6VkwLE8jxTWLR0T9epoXnb0y73akedL2A+EHD6n28z43y1XEJGmSBW3tUyc4HnN37fj+Hr+QOem8MPO8FkddTbpyDDe8nLQ2voPpatyFohVnkCx2vOiXh1WCdjxzhM2Z0mmozMEoyyk1JnzRmzdyZ1ZW92WBUFDpJOhVVJ+Ic1UKTsZH2dSV2Qf59p5GQ== 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=Cc63BLB8ji7oOQLjQljJsvY1bnTLFPjRcF332owtG4I=; b=nH86gv6YvKjzhRcOFX3ccrCTeGN8hZpEHxZxsfigF5o+9UVd+fborJ16mjS/btgcb3GA4vWsBM/XnH/Rgd+EnrJXCgZTh3qe8KEaZQsMAKWs15MvvXzoKUPcjTjg2Y70hfVbZZu9qN/Ja2Vws5st4JAqRdI8qP5amZoMfoCC9knic+uOQd2X8ix9QJ6ygsOXy1+AQsuJIXEUkuyWSswTuIo9owjkYvAxnCclO6OMdRV2Xj464RYJj4FPsS4q8eAIEiI0gNFCEAYBND1TIwa4b07OPoPtx9mJTuxB2rdM+bZhPzY9zXF+W8f46slQ5BBh6spd22d6zyiDqNv/w3uOHw== 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=Cc63BLB8ji7oOQLjQljJsvY1bnTLFPjRcF332owtG4I=; b=Vpya9ATsBNQwXHUKNT82UcseRTweL8TCzXUJnvGdwZ8HtxomcYCe2ljoP/Ij5v+fvAsStJ+CFly35wx8MWWu3jO5oB7SfjsAypzoiRGnQ6ONJGXvnem1bVe06kDXgWfoED2f2j5d1HH4cq6Pb/Irny5tacGYwjggoPyXf/U50CuwX5+4kknONVwdqt2G/eFgzG7Hn9De5fQg32LhGExR0x8JqyViuuiHr3xpig8V23uEkc/UPnaUzZuC6MIHS+zK42mdyMg5m/UkdiPXfKuGrPvCQuLCdSilUAB7G27IHLlNeyCkJ9KPOBlpXmBCDEUi1nJbyXGNpeVLQlF9u+ABsg== 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 BN9PR12MB5067.namprd12.prod.outlook.com (2603:10b6:408:134::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.23; Thu, 28 Sep 2023 15:10:31 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10:31 +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, edumazet@google.com, pabeni@redhat.com, john.fastabend@gmail.com, daniel@iogearbox.net Subject: [PATCH v16 04/20] net/tls,core: export get_netdev_for_sock Date: Thu, 28 Sep 2023 15:09:38 +0000 Message-Id: <20230928150954.1684-5-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR2P281CA0087.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9b::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_|BN9PR12MB5067:EE_ X-MS-Office365-Filtering-Correlation-Id: 638fe4dd-9309-46b7-c336-08dbc0350e93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AHhPIC8KiJ7qdVP7IknIGVuos1OAugD+Rr0+tG8Nqm/VJugeIu/qy8uhZOlBpm/ApNGf7QhWweQebJUe+P0JOiJlsQv+cuXdpWbW04ZpsXfhIc0piFrm8coI1y9pLhO16hvqszob7onexMgmdPonuSORnk6M5BxWbJePxnD6hs/C//JemcRTEAMlBJc88c4KiAKGSwXnPqUIL6vs7ZR/VInMExd7vmuD3veP9CHUMeZ3DNArkfSXBd3UVlk3D5F/xlUZRlkMPTZMaGjgfyerUxVMoAddATjifHseozjjKWb7Wgkb6cfuCO/rwREwuoqZ+CUFp3Ofla2+s3RiC+9TZiHSrUyg0jqw+kpd9s3d8CnqYjeKx7e+Irprg28gODis2kRLrkQbPIeaHlznB4wmKKyKKTP8yadAz7/+BwgFN2SNjTOdHYWGZ8suPK2bRqnFGwUrs+W6iksDssPvBL0/gvaU+1iOYRGDiojRq+VkCP7j/J/1TO6hVptMnDeVFbnYvhgGYG5oxUEpv5CbYVLA8KKCOvVNxS7Y32YMrlWwRZe3gvGDZ6U8ovsVDMw6beat 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)(376002)(136003)(396003)(366004)(346002)(39860400002)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(7416002)(1076003)(6506007)(26005)(5660300002)(36756003)(316002)(66556008)(41300700001)(8936002)(4326008)(6512007)(2906002)(8676002)(83380400001)(66946007)(2616005)(6486002)(478600001)(66476007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xcPv2w+x3u8JBqyb7HEd3Z8roErZzVelZ75xri9eRaFN9aSTlvMUW2hwUdmBrC5xxk3czeWAx/qtA52yTgUM8hJhVe3TxmMkyfrCpmDDeI/NmQ/7zOFqSlz7QXtBPO9/LA9zMjkfhUI0reiao4PxYNtGPpX0rpBFRuxfcRAqVt5klirXRWqOA5765I6Jo4Qf8pu3nLlAUz63G7hYYlwKj+TZEhdjoWuU4GjpckovSHnSvWMgdy0io/w9/fioyNixW2l9j/XGnl5LPOa/EGENja1MPzUUJ8CXk54bgUiO9QFlRDC7gIMZjMM+YPJsmbff1AfR2UdgzwYX3WW14Uaf3JAbMG0PrCO2Zo3ATL5kLXI9vAVrmVh0luotsRRaNSIndB6l/9Ji5Sr5MIjedCMP8X3smqXc+IfV9c39fB7whAX6MJ6l8nVUY/FQJP9cdJLij8rlUaTuoYLjPMmKmcjbf/3HOHP5U/5jibO6TjOSCKr5SWDJgHOHD/6A8/ZzZIQLh83iP4QR+fVEEI0z0S8wtaQOCheyOEHl1OVKeBAynTkSiMw88VoqeWC1RfWH964ziFQfnS/CHFXvvU+BpTR18r28XdAvLzhXExp/gMxAxEB8qGnFjCdU0zrVDoaUnun/ndDmwFi4kVsSNbcamTeCDlpzcemrXlBDe7LXIIZDTUH1qscwd9dqwxfGcJRbi0vtDVT8sV+xeKshTcy1ydz9UzAVkyc+mXi+hS7hlPqLhLN1DGL6Uy7tHyLNq4+3AubnH7DuvhEJ7jidbidXTiFTbArXFsQqVSN2fJiUoMmacfDba9XGeFJEL5eoDop5yWoDxMBJlyAYgOtQ1Jd1SbXcNmbffOJJOg7XfU7Vdg7ZvQC3i2ozG59fDM7sl+QXrMcZwT2kNHJvpLpL+qrDAI5I2hwfWjKyDxOZ15ew1936TklXHTltNptSvzwmiDgJIbpshRSMLWu+EUt/U+UbKtmWtjXePTcK3A6w/9H2AZoWvrPIKgN1vlVVzqQUHkuPfy07+Tns5ZRYht6WmC+d+zBX2Zdir+V4PC2KwK+pplRJRaD0NJ8ITG003ZM8mm41ptCekFi7R1xzCZn1LR6SRvBKImTq4jQGxbKDlldTa17K40BHysgtwTXi4x9XSHcbyRFXlQSKG/TKsLzwxewWTS/4zycRYi3PtuY+wxjQcIh75m3J5Hil+9rQiBv6b6Z460GCI+O7mR1eDkM+MK2ieH1ZLZ6Gl+J9ZO9cBXGAFNDAYCrL3vxvLlDY34jT7gCGXVrw/3DniUvywmq7ABMV3Qbhf4+3uPuWiqhoeZFRMWS+hYTnVjc+mCohAvlsyP4ZkMjlLwifuO3OwXN9+tC+/0hYVGys4s7RuV+AplHp5Znb27tO5z8dQgigAoUgtBmFAV88loKtZX5Kf2XNdT1vZZkawBdkfgY/i94q26V13RwRrJ2TtV85h3YLr7S3B7415aiH9r5GbhmejVCbKTYyVAtbgaJYA23rP8ZsM4H9bwxik9Dp4nCJx+RsHjfjewbvONJgzYjVvOGeGG9qbFlj3YAjoBoj4riGx+4M+w2neGlZT25sv5pT7euVfP0Hd7OrNENQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 638fe4dd-9309-46b7-c336-08dbc0350e93 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:31.4766 (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: Dn+KN412R/H5gNjwlWXy+7j66nuu8JsxGitbG6Ufm8+zz3hTW6ISGSN9eJdrxmP5drGCHg/CcG+W6twd6KMGQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5067 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 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 c4b79629af2a..76432daad334 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3139,8 +3139,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 606a366cc209..325b3db4f420 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8218,27 +8218,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 8c94c926606a..ae0fde3e6ea7 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 Thu Sep 28 15:09:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403221 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 EA1CC4CFBA for ; Thu, 28 Sep 2023 15:10:45 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2065.outbound.protection.outlook.com [40.107.100.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158471A7 for ; Thu, 28 Sep 2023 08:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mEm4spMGRhTScczaQ1V0OJHw0Oyi9mMqMSCeXBHreju+hyUU7ONxzqoD8Hx+z9RPUS1BarNugJ7NWMNH2L5rWx6DW62AI48LTFSvbQQ4DDc4IF+Ujn0jXFgXWVULkJ94HOrbIN6bfE9WplE6USZIbRKf+KFwPzEmXDp3n/tz1Pe85qDq8BpP1mNMf5S4NsMuu4JmTBWRC6N0fFzW/UZa6TcaLso3LlaQudeSmHT9VqYo34iPRjPjfmDNbIGKvivcVXB0mXbNYAUCpY9+A4cCZstHMVAC2E3Ih7YKDQa+yBUY+YgXWRdSLqbim8Mx8lJkHger5qFtCI/DltKQaiklbQ== 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=oU1MvVy/y+QR92ZMPAuEao+B/PhhbXCPrKjS0LDEzhs=; b=fPBcVcS/nInN93TV3O5Voij79BENLK14NZabo7YfNixHLWDOoUgjV0CgUFjYSjuIZPqF8dvtR3DuLcibT7OTyjDrjivOsug22P/9HwQWa9/b5bGhnGdXhUoRD6W07R87OOchG7IR5aph8cWnBKOuani2G3TTAPl3rT1YDkwpu79kY3XHa9DN0ZLP+ejg0MpUUpMzQXGddDYrytibjKIzHGpeVUn1Dq97iGYiUozeAoiJlgRUGS97+P0EYpRCSf3qLlixPPMUjKtLPs7W5dcu8LeQuGZX/selLMtuxUH367q1AsgV48LPLccbXFfylVYsWocF0P7EpFNNSUqzI3gJRQ== 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=oU1MvVy/y+QR92ZMPAuEao+B/PhhbXCPrKjS0LDEzhs=; b=YYSrS2+EAxxn5jpdQJfxbo4jEuddCJvHmuUEnexo4VG2cDgfNCbHl0HvMMc+S998ug3wOyBdzPgatPXvdDG92rettmrsQsvw4yZs5sitE7BEvlz7rDS6o85Zmkhy5m3lcSnzogg4jYoZK5jxYrktyoRbhWIfUwpVr+F1HvCPaFVnTHsFGWrgEUvL2slOXCCbauhNU76qtLP5cCYtRI9XieBOE2s5r8cVUKxzfuBWi1yMFTY/Nfa+OeNt9foQ2ViAUHT4n3D8iSIasnR/xoMWmlhGKM5Ss+Xi5GGIQyTwKpidCdqwv/9JRbyemmzAkOKkPkZRNqF5gNbMsPXfa3nC/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 BN9PR12MB5067.namprd12.prod.outlook.com (2603:10b6:408:134::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.23; Thu, 28 Sep 2023 15:10:37 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10:37 +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 v16 05/20] nvme-tcp: Add DDP offload control path Date: Thu, 28 Sep 2023 15:09:39 +0000 Message-Id: <20230928150954.1684-6-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0047.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cc::14) 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_|BN9PR12MB5067:EE_ X-MS-Office365-Filtering-Correlation-Id: a1ae1aba-fb01-4bbd-4481-08dbc035122e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dQ9A3/HE+LLYfo1n3Uq7MVVMUwzpQf3hyxg7HG5IHPdJzSafo2NeQeAJzNVsYG3VhVQ3Lbe9Axwj6UY9ZCVeVxwOtA3gsFp9Y8MauewJMq9+l78BML4SuUC7LnA0M1N6PugVWWQO6ovolpzqOL3Z3vvW2hIyGEC6VGP9A3odHRuPnZYtNkJv86NrP9fq1vwKqeIJCqrZGiLBIWdarMACb8IepbUxAWragsb+dVc+923E+Ud34a98d5eKSdzCC8DJU+cIKPiC1ziom2Xx09XbesHKhdGbv5OUSrcSh+CBJml8a2ReMQUg4js3R9ChxlZ6Zyv+KWWG+KNFCS1hia+HIpWS82bE8VgbVak9AmfSCMxt8p79Oh+vWQllBCrVHnj6W8u8Dkxn6CjqFQbUPO0KE4SlrcNHYn+RT9cRz6uTAOWxfYRJjdpFZwjlGeGN/VKiT8ATQsNAR4rH++GQI+8ETYLkaAg/suPhxrgfK7PZCTJ16I55Vb2s9o5vLN8dstkEvI3Tmf0Nj9JVgb7lAwybqW2xFb0k/v5AGVmds0qhgRu0yi/jtyOr/nElPX7ZhZJE 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)(376002)(136003)(396003)(366004)(346002)(39860400002)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(30864003)(7416002)(107886003)(1076003)(6506007)(26005)(5660300002)(36756003)(316002)(66556008)(41300700001)(8936002)(4326008)(6512007)(2906002)(8676002)(83380400001)(66946007)(2616005)(6486002)(478600001)(66476007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pg9qqay3ehfLHGau63XyywdYje7tEUH9uKGt7R5OB8m7TCWHdaU/4JeBcwC+hCMgiWWsMt+YTxxEKdO6EAehNDEDItcw0K78u2kGebU1HuFi91IW0DvX0YyYi7WICSu/IVhRnfWDGPrJmwYQ81hEmhr1iqzKYNe3Q5ZAkrUAP1kNq4xglcSF9Rm8p1rodT89Aato3B7sBlq6bERJxjJnWXz8MKXpNJvqu2B/7not/v2X+INqO10YmpszxoI5ulW7A153SL50lgsLJCNU85Kuf/kRV2gk2tkX4NeCXD7FRd2eaG/Uf8N0InwvDkIVibwKDFzcgc60nrfRVKszaauTrkjmEIXLd1p9HNuQSTxrpEmrZidgrAJUQh6u2WGb5IQYc0tKvLCM5UQJvOpzR0nQiofeSXxDoXwYjTNMrCZYdDWvKS4DeOiK7rAD8zUJBt2gNzRYpLdBcBYfK8l9FDd693mbQZXXOCtUv/gMiXGBjoTvmIHutqY/LeG81C7JKN4P1+wwYsrR9huPCVeVnZtQWXpnmTHuOOJZm0YVRpsBRuVGzhjYT16KyZNpNQyQwE/3qgvoncVZY3tMersbsf+GOguVDWjqFqb61ZTBn2Sdj+XB+8YLqMvmI2NwrlAo91mtmHbBhXWYQ7Z37FrI+jU3alfN76YCzp/MrKr69Cq3AUOuZWr2uzwK+U/YBIov7oTJbozWaJO2avfl0OK6UxReLVq1hq8lduo+Z1LcewuYi+eucDg4dBfixvy2F5/qf/18EmnU5hIlNFGNkYRhFLbDY2laoJS0J/TO9dC+jdeCLCu9i1nA4YpCc1YO01p50DYgw5dT5YWE+vUzUCxFcVwdipk7t8rM2n6wa4/fV2d14k1FplCsvs8iHq8POTAKXMElALqOe6BX8s0FaFK6jmvUIGul3zjPC/D7anpkY/xtYZvp01tE2jHk4vhrc5mMc/J4f0eedoMR2D6PrPmJBZmBLLIHIA6np6Ou//gr4KTz+gPZ0ja3m4QdC++fL0lQWBhKDQ+iA0M4FrJZWj90H8/SL3htavO1EEEbRAIRRK6pIDfDIQwsjobGHN2mE6ps382kPqfwFDtHDA4G21tn352ZUjyUURl8ub5WPdo+6bmYNxKzzc2bnatBV9o743Pol++PwjKgrzI8h987HVqQyrlTDt/WLvKT5sAPu84nT1hsMHADd3nEjxczESO8iUjE438SWU6Bo+cGbKy6s2arkNqyi7XczOHDjaQ9SfU0QjJUiAwEiefo8T0BYbRVqPrErz3Smwm+HS2odnU/V+ex3lN48koaW0oQD3wEldbHBb5qhDu52fN0zsl6qTQVY6kvNsG34iBLzZWjI5xDpddcv0hygpVE0pjoG/wQRiEBBMFjAE/1yNZ4JTnIv+PoTxLPI+KN8V+AD8jF2+75kkKP75F24musb50g2f9reiqq7hU5up8jsRfT0VVV5uwusHqKDRHunbnigBZHhq+NCOCJ8xsyqOXf/O9Q+vHCbixvNNKejm7usBnqwWCulpndpAXudtmiYXI96ufMiKld2L2skWBlZHt+h141v56G7PQ3oc4WPpS9CppYlRnFrJT3nyhdU4cz X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1ae1aba-fb01-4bbd-4481-08dbc035122e X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:37.7093 (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: yDgWzfwun67+RBhEnWYzeoKzYI0YcKjIfaiPyHLbB+1Bve1qAfLWrPmez9O7B33beWP6UhiypWxkJA8H8uaR6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5067 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 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 | 261 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 247 insertions(+), 14 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 5b332d9f87fc..604649c29838 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -16,6 +16,10 @@ #include #include +#ifdef CONFIG_ULP_DDP +#include +#endif + #include "nvme.h" #include "fabrics.h" @@ -31,6 +35,16 @@ static int so_priority; module_param(so_priority, int, 0644); MODULE_PARM_DESC(so_priority, "nvme tcp socket optimize priority"); +#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 @@ -104,6 +118,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 { @@ -131,6 +146,18 @@ struct nvme_tcp_queue { size_t ddgst_remaining; unsigned int nr_cqe; +#ifdef CONFIG_ULP_DDP + /* + * resync_tcp_seq is a speculative PDU header tcp seq number (with + * an additional flag in the lower 32 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_tcp_seq; +#endif + /* send state */ struct nvme_tcp_request *request; @@ -170,6 +197,12 @@ struct nvme_tcp_ctrl { struct delayed_work connect_work; struct nvme_tcp_request async_req; u32 io_queues[HCTX_MAX_TYPES]; + + struct net_device *ddp_netdev; + u32 ddp_threshold; +#ifdef CONFIG_ULP_DDP + struct ulp_ddp_limits ddp_limits; +#endif }; static LIST_HEAD(nvme_tcp_ctrl_list); @@ -273,6 +306,166 @@ 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 struct net_device *nvme_tcp_get_ddp_netdev_with_limits( + struct nvme_tcp_ctrl *ctrl) +{ + struct net_device *netdev; + bool ok; + + if (!ddp_offload) + return NULL; + + /* netdev ref is put in nvme_tcp_stop_admin_queue() */ + netdev = get_netdev_for_sock(ctrl->queues[0].sock->sk); + if (!netdev) { + dev_dbg(ctrl->ctrl.device, "netdev not found\n"); + return NULL; + } + + ok = ulp_ddp_query_limits(netdev, &ctrl->ddp_limits, + ULP_DDP_NVME, ULP_DDP_C_NVME_TCP_BIT, + false /* tls */); + if (!ok) { + dev_put(netdev); + return NULL; + } + + return netdev; +} + +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); + + 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_tcp_seq); + /* 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_tcp_seq, pdu_val, + pdu_val & ~ULP_DDP_RESYNC_PENDING) != + atomic64_read(&queue->resync_tcp_seq)) + 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_tcp_seq, (((uint64_t)seq << 32) | flags)); + + return true; +} + +#else + +static struct net_device *nvme_tcp_get_ddp_netdev_with_limits( + struct nvme_tcp_ctrl *ctrl) +{ + return NULL; +} + +static void nvme_tcp_ddp_apply_limits(struct nvme_tcp_ctrl *ctrl) +{} + +static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) +{ + return 0; +} + +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) { @@ -715,6 +908,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)) @@ -1665,6 +1861,8 @@ 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); } static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid) @@ -1681,6 +1879,20 @@ static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid) mutex_unlock(&queue->queue_lock); } +static void nvme_tcp_stop_admin_queue(struct nvme_ctrl *nctrl) +{ + struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); + + nvme_tcp_stop_queue(nctrl, 0); + + /* + * We are called twice by nvme_tcp_teardown_admin_queue() + * Set ddp_netdev to NULL to avoid putting it twice + */ + dev_put(ctrl->ddp_netdev); + ctrl->ddp_netdev = NULL; +} + static void nvme_tcp_setup_sock_ops(struct nvme_tcp_queue *queue) { write_lock_bh(&queue->sock->sk->sk_callback_lock); @@ -1707,19 +1919,37 @@ 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; + + 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); + } + } + } else { ret = nvmf_connect_admin_queue(nctrl); + if (ret) + goto err; + + ctrl->ddp_netdev = nvme_tcp_get_ddp_netdev_with_limits(ctrl); + if (ctrl->ddp_netdev) + nvme_tcp_ddp_apply_limits(ctrl); - 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); } + + 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; } @@ -1911,7 +2141,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove) { - nvme_tcp_stop_queue(ctrl, 0); + nvme_tcp_stop_admin_queue(ctrl); if (remove) nvme_remove_admin_tag_set(ctrl); nvme_tcp_free_admin_queue(ctrl); @@ -1954,7 +2184,7 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) nvme_quiesce_admin_queue(ctrl); blk_sync_queue(ctrl->admin_q); out_stop_queue: - nvme_tcp_stop_queue(ctrl, 0); + nvme_tcp_stop_admin_queue(ctrl); nvme_cancel_admin_tagset(ctrl); out_cleanup_tagset: if (new) @@ -1969,7 +2199,7 @@ static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl, { nvme_quiesce_admin_queue(ctrl); blk_sync_queue(ctrl->admin_q); - nvme_tcp_stop_queue(ctrl, 0); + nvme_tcp_stop_admin_queue(ctrl); nvme_cancel_admin_tagset(ctrl); if (remove) nvme_unquiesce_admin_queue(ctrl); @@ -2077,7 +2307,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) destroy_admin: nvme_quiesce_admin_queue(ctrl); blk_sync_queue(ctrl->admin_q); - nvme_tcp_stop_queue(ctrl, 0); + nvme_tcp_stop_admin_queue(ctrl); nvme_cancel_admin_tagset(ctrl); nvme_tcp_destroy_admin_queue(ctrl, new); return ret; @@ -2257,7 +2487,10 @@ static void nvme_tcp_complete_timed_out(struct request *rq) struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; - nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); + if (nvme_tcp_admin_queue(req->queue)) + nvme_tcp_stop_admin_queue(ctrl); + else + nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); nvmf_complete_timed_out_request(rq); } From patchwork Thu Sep 28 15:09:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403222 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 245144CFCB for ; Thu, 28 Sep 2023 15:10:50 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E0021A1 for ; Thu, 28 Sep 2023 08:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=giszrx1hzB8VRaZqZOkTM+359ek5IWqPk6BTSPFGUKX3aLt5Jlo6ZXkAPwIttHwbaoCHtMCuDmu9RwarNWoZcdJgKfje+r7WpwJySxIbyFAI9ex92OLVcjGk4rhlMVFrfP0FvjMKgHl3+dKrMjGExefF3VvXa7kH0JQVFM3WydTsBhyKFMnHNweC1/GMER75jpUXoDYdpKyA785KSQ9T/ylWxXkzhRV8Aopb8bB14ih2++RxyFStZZFSJAe/lwetG0w768qbiXW3RRRm3dl2ZGcQorvMaVYrmcqGwrqh0VmXsmMIFfiKhZroVm+ADy0tPoVDYpp9YqkovyLrdoa8MQ== 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=kb+JC9muH3kFhCfV/0Ao2pYydNUjg+JOFsILFFJL5sQ=; b=PTQek/KElJZYLEhCnLLVirzu2/W++9s7m7EwHYgqkmQI6bjmiUFGoS/s0hj5GXOvvw1PMEoAZeZhTHtS42yKONW2yE1RZunBSIIDcAtnFmkHJdqtPRX25tuo3V88g+seCmhzsvc8lDQoRl/FwfWIv6sPXtc/xgrPcalCyKfRK2CMUGYLrsZN3/4gIL3SHd5Y9taPLNJRQ4J3dEcr+MQ2bSvk0WNAPP6oufp3MWzqgnz5hCAl4iDKPbjvcAoiV77pVTsE+r1/iieQcvmOY2BA4X3LQYyaplvpQTBXXCkUZrN4tWSp8iiFCRrKn08psVhHx7VTfQkknhZ7HrJnyL6iFQ== 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=kb+JC9muH3kFhCfV/0Ao2pYydNUjg+JOFsILFFJL5sQ=; b=ElwAyR1WSoiAjLnW3lfSAnzPIs8IDxeV4lenHWt0keZsOxiVHOE8C4TO+yI/HXFds28MEQY0vr34CxK2BhecshEQE+/sRhzk/puDfMdCIFOY37skSKj74kBrs+7Lw8p42P1fITvjmRcXCyK4ISPXGlOEBAYNCtHnJOM0HCSNfHa23OTY08aaqMPMXKFZQ12a6tKc+TRlftSDyBN2DMpHKWjOjrNhTohfRGm6xjzreTLXCAJBAzQtOp5SmfSsjTzrLwUcJ4UEGDTIM4c34G9vtm4JPHCx/7Xb7cRR/vLXtFcRnmiZaLDozqw5glX/Wvh/qFyYb6WqxKIUHcgsgLdeXQ== 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 DM4PR12MB5359.namprd12.prod.outlook.com (2603:10b6:5:39e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 15:10:44 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10: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: 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 v16 06/20] nvme-tcp: Add DDP data-path Date: Thu, 28 Sep 2023 15:09:40 +0000 Message-Id: <20230928150954.1684-7-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0081.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cd::14) 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_|DM4PR12MB5359:EE_ X-MS-Office365-Filtering-Correlation-Id: fcf8f90c-d53e-4fab-ddd1-08dbc035166a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RmBJS6GNsB9OCODPrMZOIpDlbDevGOkhRXCjwUOnnkV5okI34A+ooosWwLUAUKiDiyExRf7gDbNzD+0yV4oKryqjfE8U+dP3e1ihpl2I2jr+mlfmpUXIhOv7gBg8dbxsLnFysy50HqORokOrUldiu3viihDiWoI9y2eITBMA0b04sOyS0Sci43ZWA3n6Epp5DEpc2pUyIXlGF8FcktjZeWsb1YwSrLokMSdOrRlc21JexnIac/LN911EZ1/1byJqk49ywhTZ6Rz7OkH7lZELqeuqlNS0HdYAAi+Epy+WoQISff5c1/CiGobzpWyOWmckcaD9WG6NK3b3fL3iQ8tmyG3f2JX4EeybcqVztm6dhYGfwF/2U41+YclOhsGT/L+cfrTkKtzy8BiDry2a0UlWiGwS0kYNWsG3bwxIW5xaUcJqH8XXnkNBuDInTEXBnvF+rDS9BnxOqzU7b47tt1gdoqM/Eabjk3iI/+X16WQ1gf+WJP8NgqtPbXTgJzcbXfXi33HfxTL1UeDr5Vqh2ToYI+DjTKadZkKtc62aQeF+QBZvTcZhO4r6oxhwY2zrtdBM 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)(39860400002)(346002)(376002)(396003)(366004)(136003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2906002)(86362001)(107886003)(6512007)(1076003)(2616005)(36756003)(478600001)(6666004)(6486002)(6506007)(38100700002)(83380400001)(26005)(7416002)(8676002)(8936002)(4326008)(5660300002)(66476007)(41300700001)(66556008)(66946007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ekIWLgxWZNiD/Jd4UB/770Wdmz8n7pwuH1nK7j/MciXKMY+cNmBaOmKPdxN03lO31S4ssyYlpm4Oy3rk4wJ6GI3tQV/Jgk3TCGWg4iMfl6Z+FHIiEdHvRcKpzrhqNUNNITcxC9qjAQoyJrRRL2lFRSqU7JJIHFYTy/jwBvnM6nPg1JnuylXnumgEGlOShRvpGAWRlD0mIVYa8qqLRAfQDp8qBEsucV2DWifwqlhS8E28l6TKyLZuim2spQ0V5oEhjY1k29RKHrFCVZH7yhE5jYCE0unBXuPj9E56wTbsSXnsqkJ+wrwWb5byH1NZFKMppzevtqxPm5PRAaHPfZL6wim05eehwos4ckci4/tmp3webJsj2xlQK4id2GgGS7nTj2OziknZPa3V43kcCQToeGuon8Xwrd0oC/64Ep/oOgvbrkF5P2ky3RnXmXZFpFpEfWvyTRAqJYPKdZ4+PL3GFChXzuiNQJsUsnMG6twlLUd/ITqB+j76J/4Jt7lWrdXPVBeUBeL9TvpLJEkAPeneXs+Phqj7Zy89GkITO75FIqklplzwycyXl+JKRJopl5MJxKwMFo2xP5PQy6NzQjzzm+9v+60rdG72HWTMyZuidWeqI21AdcqOO12CX0PU9vTRG0e2lXKwhmCuqkqEDeI8YQvlR7gbR5ILF7F41CzQUxisaRB39NkS/qMtvOhHe3PlRKUKmq+jRFZywyJ+PshowBC96APatLnlqeZYvlFeJpzEQByAOcawzo9isIuZcgxscd8Tcmg4Qd4w6SR3/WsXwquSzUVGCw94+esUzSm9ZF/5hny9HRsNamjX0FG7JWIQeroYs+oD+XmX1OsHhcykPrwrvY+AE0XypH6WJwqRB5P6Acx4MYotnaVUMEGXHathe1lL411vS0ynBJ27eXVa8DD1diXWwGvYmNiYWAGl9AEsilcLzSNAhLhz8iEMw4o/LGhJ656OWOUOT1txSugXieZ7rzq3rUJFkIx8UsZfpPTj3QjH5IXxwXNYYc0uAQMPL7v6uGjXmVKduOrNYtg+T8xTIGynxsoT4xw9D4CZ7y7DzAgyoxfal7J8zP9GsWKaalLfYURStxB0JMxnU5EcIzXvpX+HG741lUtVjAY6/S7gXVh7lKJfJ0SLXxMPNPbZmosDS2GZn0Z9Wv2vPvAq0TtAXyVPpdIJNOpBmI7CWwMirVFq5tOdigrhQRSwJfqxKKzrHvfD/NN+SN99ewMak9tUxE9cf4cbzKMF983gSgKkU6pxpoN9ePpORcSNkP7wwA/3JTiUAfYd7In/G6Etcgeg/+S38GI2KXRM3v5xsWP2quAiVpXfkoE/mZ22eARbTIkxse/tDtHXBgdffDn9KHMQ7iBognspVbvw+ET3eZ8A7nUPngSQMIMu/dwSDClVcy31fjXcu2ze3cmRJKkNfeF10zAcaaGie1MHZ6mbI2Pnd4Tjcr/Kblvt5WM47pf5UVu5Dv4tJyqFl/d0uqaYF7UP5OvkDoo1L86Wd7ymbKhCsRWRmPAHkmIvI5aHnELWliWUjUeZYtK86F6OSOQY3h6DEjj++4r5Liw7UWqhRNQW55LtN3GgCkb/4ochUJsI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcf8f90c-d53e-4fab-ddd1-08dbc035166a X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:44.6930 (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: Xen6lJ5zHdU5Wb8eulFFIabO9rsSGpnZDGTLY7CVmgXT/xVI0C+s8eUwIpiCH8GNqegVXDsBGZEX0k9XRG2k7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5359 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 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 | 111 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 604649c29838..655f73dacc09 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -112,6 +112,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 { @@ -336,10 +343,72 @@ static struct net_device *nvme_tcp_get_ddp_netdev_with_limits( } 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 void 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; + + /* + * DDP offload is best-effort, errors are ignored. + */ + + 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) + goto err; + 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); + goto err; + } + + /* if successful, sg table is freed in nvme_tcp_teardown_ddp() */ + req->offloaded = true; + + return; +err: + WARN_ONCE(ret, "ddp setup failed (queue 0x%x, cid 0x%x, ret=%d)", + nvme_tcp_queue_id(queue), + nvme_cid(rq), + ret); +} + static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; @@ -460,6 +529,10 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) {} +static void nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, + struct request *rq) +{} + static void nvme_tcp_resync_response(struct nvme_tcp_queue *queue, struct sk_buff *skb, unsigned int offset) {} @@ -735,6 +808,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) { @@ -754,10 +847,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; } @@ -955,10 +1047,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, @@ -1265,6 +1360,9 @@ 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)) + nvme_tcp_setup_ddp(queue, blk_mq_rq_from_pdu(req)); + if (queue->hdr_digest && !req->offset) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); @@ -2566,6 +2664,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 Thu Sep 28 15:09:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403223 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 0E2B34CFA5 for ; Thu, 28 Sep 2023 15:10:57 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2071.outbound.protection.outlook.com [40.107.100.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B688F194 for ; Thu, 28 Sep 2023 08:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dXRWHBYIpQh6HdSZEUVdcCO/4P9WfCY4vXkPsOf/5SZ3rtltCXv7MOjOVRrJZoUnnwJHRnuAwAy9/kjEay8VNXP03IEUDA6uVRXcAWSn1C8yxPfqjD4pSnrSRsn1Cw3BHE7AYyaNJ20WCKCen2XR41Fi4reGCUR753BCBMzKrO2rqN9311A+6RZ3Y+mEsDqzcQKt+nGlVZXtsDAt2uApDwpNA9fzxnB/jmQqLptIksfOFgcevlQvbvR76CpDUzzFV986MrHmTC9m5Zf7Oq4x155q28d3S5lx2VdE2ZnWtevr8pYQkqw4oOIcz/f1E0n9y+cupH07XOG0UmxzpVQTsw== 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=Cbwb8lRKkaBKWj9HC+/vTjnwIw+2U7k3+lRzIjTCWM4=; b=H0ROfkW2A8jnL2dM5w+jOQsCvJHrMHw5go6wDUaPErVAbaSzffPBBClzSWmI0bkXT9JQs0goQyd8HqLp7FCi4C5T6xj9FyeFjkvk4MOWjvfITvFeyK7pwPZFFuWKrzywlgTl1R+a4CRSdQhHm53a5q2KFBq0MIJfKNGklnRynhPnCLoIOj0rbvdOMfcWoRUKYAsVPGG28wyzeM89+x84MAB+poHPHHVtmNc8+ZrEf33vRQBTxfHXbFHX9/Y7kP8AHcUUOWOgYuHToCapSml725et54K4W96zPxrAQ5uJa/ekWywDL9Hf69frly3X8YDECDqPuqUtrIP7ATcR7LJTAQ== 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=Cbwb8lRKkaBKWj9HC+/vTjnwIw+2U7k3+lRzIjTCWM4=; b=IFvnJgjWuZI8pWbx+fLXd2sZiXmntli9YecUZdEmqMwaMQIJIcXWp70k7EYNSwpjKXQE8dyPIEyKs05zQsiPaB6KXwgzkUlcUChgsbOaJ0kiCj4c4Cp31juq9TKJbWnq/PFbfOirvbO8QTdIVrI26zvJ79rPh0Cay473JKKQNycgzBMchwtTM9vmnUHqR0Cqxxlpd7eW/7tAr70MbKJ6ds0W3hJhoZjh2LNMXk1Ijcp4I8pXop/BeOsS7+eG/qsx037HjNe4QpVAOI8K285T8GkoeXZ/w3YrdrQqaAeLXwdG3iAFRr2dp9Jv9CejRPA73FOYfryM3u0/rpzq95II+g== 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 PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.24; Thu, 28 Sep 2023 15:10:51 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10: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: 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 v16 07/20] nvme-tcp: RX DDGST offload Date: Thu, 28 Sep 2023 15:09:41 +0000 Message-Id: <20230928150954.1684-8-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR2P281CA0094.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9b::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_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: d782b6cc-9efd-4883-be69-08dbc0351a26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ByNUCkN/WPRRvYFlVzAf/blw3ZWEqdk9T1yHPZxRC0kM3bS9WaLACp1aI0L3A93h2XrLvensYOnhVMvFgx7LPl5kM0+aH8kMmwk/Ygpd5U6RdCUxbIKuG+AMN4am3wc7SuOVpzETtG8qtFGtRpUJ7wcX32eBbffouDh3F++AZ73wdjnmoB3nfYueIm4/pr2BDRvEDymqjZ20kg1lGzW6l2/pd2aDDu9vD3Iw11HxQsTnlVubzVhlZZkOJbM+I9mwhRLjzheSlIVrV9kJT0sIfL7sYBz4Cs7x9oljM8zee31M8BOiIU2C9pmcc9/iJsw9uz6PwCD2dpIDNQ+jQMGRqFVyQNC6QR2CTjngP1a32Drk9btC47jp+H4bdvNrNEU8UDC14OUvzY/f9kDDxUIQd8LOCSMpbnEMo75z7mdGkgW6HrxLZGGnMN3IQT1dVfmRKi0Xp4vWAcRAjphgUM+esqNAr8C5ibgb4Y8SPL+CaKv4AdgciPdD7/YUYHOdVy9JMiGxtryBu1jsOk1Lc9MMezEewIP6rvPJetN6+6CquByTwynbJ9Z/s2nCQeXOSm/N 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)(346002)(136003)(376002)(39860400002)(366004)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(6666004)(38100700002)(478600001)(66556008)(316002)(66476007)(66946007)(6512007)(107886003)(2616005)(1076003)(6486002)(26005)(6506007)(8676002)(36756003)(7416002)(8936002)(41300700001)(2906002)(4326008)(5660300002)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zzrrwNv8EXhMFingNJ0l8KwK7AoXweVvx7SuHHA0r+x1y//C+qsuRlechMzGwQq/irNmU1lYSmXxY3QyAz4KKugtlfLekMHRa1q+TqB9o2gKAoTBu7dV74P0RWjVtO54iQuZAOnUb2eYy03wlu+vwGXJ6mD77HrGeY2p4KAD7l6ZsINsWuEsP+C3QbOoWoKEPks3eWWsbzhdZMN2um4PXICfLJAYB2ezaD9StDD1tlyRQOKOzFrPO2y7Z3FsWagZiI1m6uGsEi8XJZ0PTJKkbbwGL3kw44mge1ACTAN2vHn12VSbHqQZ9TyOaqYcmkFF9TaUlehPo3S+f05DS3hqK8fCt2O+1hD0KA3PoP6SHJGklrd1V/BuquFF7LNViMfqOV6BXCjiJDr9Nw8CW+a6ZhzqwKr+l6kkNeVeYx3H72+u0TwyQAA/zkSB96vTbmoXW3+kc6q1xZYSYbz0RHA+2ch+4vSy0wdzCfnVHXFVHhDEFD9tlLAf1s5eB9zzcstKChPhhcv3TjpOvp48gm8G8ms7xSn2OmQISkN4ls6r8KyGIXblxQKkdqIip54REfWa9Y+hm2ELzKW8J1aKgR+jxPkbPECaxaiIg+OD5k8C5bXdSzOnOvohsieKhfxvlCNtxhh+TcI5Ur5PJWVkOr6oNDROEPSssOeFkKLZVW0Y2oVDFBVKSzA6tdQT5xV+7TCapgagH/IO73v11gIrJ23UCX8+TzeYEojdaJTMVaTg2u9hUG24khRy+WovMkOSK6HCOHexf2Xh78hROJ6zxHw5mScMfY0DFjYMTbEgRi+lSz19LTybEbsJ41wtI8kLCXpGlhiRcFJCNpz+NivyT/FZs7QSqV4TK3A2YrbgiA9P3qrahonz7shIt2Nj31sMsEBxxvlDC+EtoKwUc+G0wGwoSIC0i6VPc7fotpmLexhcpXNYxZulV/ZlJY8O3a8NQh0PvEwRllaB0UgOEbXGIZm8EtsTcaHawrs+QxI9auFAYvjUFYCXn8mavwtv9C67kT1JPJs/yEJlaX1VaMEArqMg+5JVBOuhHYCOelGxh2N0L8WV3RLLpohxumJjv8zFO15I2h34ZrXPK8h1KiFFik9/WYxkx0VYyA2negggT9kkpxbXlsvLnYX19mjrxfM9K+DP3kftP0QXDyZ7vVRYvBVkiPRdZpcV5HD0YpvOcuo/fsKdCA4qNl4rRt4Plg4MO/PTJVKZuTKIMrf1FqnqEHKAALSyciMqAwNrKSpRohH6njphicQMM2yGa94KQcfa+MjEGr36bouSLD1kw0j+ys8H1FhwN4eyGiRGamOpYvwgz9hxNeCP7s9Xc0HwmfR1DdQLInw0YujKBY7ciYUGyTn+KQiL3oc8nn6ixO3cDGqG8lJPjGV1wMagPNhqlaYb7z2mYdZYraa3XJCNneJnaNVCUPEYZ/fT0eqozOvxKCdoFgwDMlqzFcpFR+lCXuRBeNR295G8k5AeRiVicmzFOYka6g/yHHbS6aC1FuDnlB2a7tuf+5BbDuEjsfLUU8QrOEQQ1MHkkKwuYTsmoX90SIlsiqgqHWi/xuslHanLeLtVMrEDR3IJc7vmcT4el+S5rBAq X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d782b6cc-9efd-4883-be69-08dbc0351a26 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:50.9044 (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: v8t4aKMwVcDWVM7No6jb2jdk2aJWXQdxleQJ3MyxRWpBhSqhUTKXI4KVtiJipm/ucdGfbpQipRP8AqJhABhceg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 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 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 655f73dacc09..49975e8e7cde 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -126,6 +126,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 { @@ -163,6 +164,7 @@ struct nvme_tcp_queue { * is pending (ULP_DDP_RESYNC_PENDING). */ atomic64_t resync_tcp_seq; + bool ddp_ddgst_valid; #endif /* send state */ @@ -342,6 +344,33 @@ static struct net_device *nvme_tcp_get_ddp_netdev_with_limits( return netdev; } +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 = { @@ -412,6 +441,8 @@ static void 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; @@ -431,6 +462,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; } @@ -438,6 +471,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); } @@ -537,6 +571,20 @@ static void nvme_tcp_resync_response(struct nvme_tcp_queue *queue, struct sk_buff *skb, unsigned int offset) {} +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) +{} + #endif static void nvme_tcp_init_iter(struct nvme_tcp_request *req, @@ -797,6 +845,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) @@ -1064,6 +1115,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; @@ -1092,7 +1147,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 @@ -1134,8 +1190,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; @@ -1146,9 +1205,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); @@ -1159,9 +1234,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 Thu Sep 28 15:09:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403224 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 D70EF4D8E6 for ; Thu, 28 Sep 2023 15:11:03 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D131B6 for ; Thu, 28 Sep 2023 08:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JazB6uGpU/upxliqdI9pelY+dhxeg/hHKJW2OWLGF4VohTdKNTEJ44Ra7Cu0CZZ1Q1Giyhxv+hmT5nOBfTY6Ja3EB4O5X9XBqph1q5gN5A6YLxUtVT6C+6c7ptj6tc7NluROjAcuCRKUb7Umn+82bfH1qYr/fyjSyy/U7hLsRdryPVngKzOBFvM/gf6byb2vfsXwyKIhqzD0I47rbuaPL3MOqAA6/RKWJT+v0XpE1hREV5tfRnvt9rBAo4ilo2+y5+Z8FJOSdPq4mXrSEqCxgFek7wFuEtRZlYSRcPJd2BEwEBTgmeD+O0SAT85TksJ03g0jU77+/2GDDuDiBiHrQQ== 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=EwL0zXrEmgJTQEZs5C2U6XlTUfZvvLmWNNYhiSz9ozg=; b=CKgc7bZyXmdqXNpJY/a/8M4xvR20ilinEIvtLWuxB9qRIXj7fN2ppLAr1gaoK0oXRGnnx3FaBJNIWQBpUbs75fjM2JHBvLqTcz8gjVy7SImBFCbBVghcGi1zs7inwlaaoRjslKoxKUS3T32nqsRlT+2ginDWSkqxyEd3F3xtljWFDEyHrPHI90FNqLNUCw4cQClvN85uX0J/O2azeTLbTvVfCZC/YYcz2chrByut4hGm2dfE3BxUTxNLhHqQoS/8PACuSlgJropR6Lfz5TCa1KKsyQ+MUJuUvVhloA3StCt47M7bx7JapQrfz1/1mtqX410cH8dxLAY4lYBESkbxJw== 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=EwL0zXrEmgJTQEZs5C2U6XlTUfZvvLmWNNYhiSz9ozg=; b=G5rGzo/H/kppZUckvXputQmuHb4aUPGsMknaOhktxsliOaqoDWLUoBx6t0omUJqmiOJnWw4o0TRWZ/0VsGdJAzKxc2+J9rafLls9e4Gj5uaAzi/m+E9q5aBWFuMg+P5Rr4rgZ30EQKGnVZlai9rVJ4hyMBgL5VQUOXB+IRulxOCDipUC5YtlMF0cpFd7MpB2zapfwLc4g0zNTj1xPXDx6r1FgalWmUVXa3clXEaRVycNOpwVo/0ThAgvFUz5TPT5SpnCTUtz0J+KX4zdR65v9tj7gX0auoe1sAwbcL4EoDCYtRimYtovWvx4rCBTQaMUDAy3R9dAHnev6qt5Sa3+3Q== 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 PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.24; Thu, 28 Sep 2023 15:10:57 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:10:57 +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 v16 08/20] nvme-tcp: Deal with netdevice DOWN events Date: Thu, 28 Sep 2023 15:09:42 +0000 Message-Id: <20230928150954.1684-9-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0046.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cc::9) 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_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fab989e-1a6a-42a0-6f8a-08dbc0351e38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GPRq/+XtBKccP6POyKqT2G1GrhxVS7K0YDFL28WuPzZNWQUZx4pDIvNBOIhvaEVfGX0sr1cvC53jBewOH87KVSs1Nqz8yh2vTUFxcBTvkkdhmba1aVTuz0Gc8yh7pkt65RSAiYeh4OEWLa3GyNMA6pHXZgN7Q66UUNj6kGUvNSRGFOWfU+UHTHp/5Kabnnga92/WeDthPcd1TaTHGNDWfJMBRetfxq5crGhNh45rLdbktc6GSQVo6bAhnq3JXGKVZUE/wdks9uSxS3BNv8NXaMc3cT+chPcqRpblszCoJmhK6pfnmfbm+DNB3biFz+T9yJhiBnG07EyxXBfQMcwIJZFZdxxx9ZshwIXkyaUqc2nDEfIuVErNQCbf3YJRakL1tATSm5AMc/8nb7QPfvE/qMRVqwnFdsAd+bxSQJnNhmHIBefVfBuO0Zyu51vDQuHIwjtxB+ou5VIMl9SjnFCSFm0OOWeAZd5z4TeiU4kNArBxpcU/r74F2VZmnDKIEqBDf+GEEYX42oWVOcfCVQqSd7ZTLrTwmRhJfV21x1rYUJd7ruA79nZLOWE1DU4V56yx 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)(346002)(136003)(376002)(39860400002)(366004)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(6666004)(38100700002)(478600001)(66556008)(316002)(66476007)(66946007)(6512007)(107886003)(2616005)(1076003)(6486002)(26005)(6506007)(8676002)(36756003)(7416002)(8936002)(41300700001)(2906002)(4326008)(5660300002)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zPUfgX8rg+Cd86/H4hiZBJf2m99LzR6gyDRT5IghkRShthbnaMEzjc0v1b18iKa1MY4f5ygIQQeQ441p/yFnELtn+2WCtn6YRG1KsFfDwBtNVPBp9Z94j09rMRoPoSdpLsuCeldgWg52bd35iGG1frZ55okTmf5yeWMyBchQpz7EiTpJpFM19orjVcVKZLjl13L6lxOZ6Wvah5rLPtVssbq8h225NdMigpsuNHZIIHdjkFjMYJQHqugb/kzkRmMJVDLtjoZGk+otPKivJJYur/VKyIE91i2X7B3wSqaXvOZWv6Lc6KpqkwZDqzKTEu9JvvieIeKNNUFWNp97tUd2cAbOpk2bF61+cJiXalrXwwytsoHUm4r3O3+NsqJwCdiV7YzRpcjCTlK2PYY5E/38NNTg9B1tIYYGbcFBzOqZRVU3yu78yZwDUEXbNEIAjIuaM5idwIYVigGq/DL1g+rIQIbWRKB2XS8GRsCLOfuzlla0hfDZp4+px40NoZgO0UPmf/hYeMZrrDDl4TIXX3UB3guOAWG3YCBMjjIdpCYXHXXpdx6b8jIpk5UHc6c2kUhI7RIDFmEMtl5PFWCekVKFv36ZF/yRAN1bqCHnzvBoBJoRE8FR/xiWjFz8VyWJz0RKiXaAgLxy9UWn96jfFmo4nPAtvobg+6abcpINXTEqftmm99P1WpO4HV8dTMwZtrDO4xmckepSKnYd2XFvme+/ll031BYN3LbKPicJvec5oYJp3kW3CE/7hwhr0NS4Mjis1Yplh1/MwbvD7I8weEFM1vUnUHfkezqxE5npgLVgvtPnuZMlEAzjyM7AyRtGm+1adzk+RXLy5LxN04bZwzRcCEa+QN3sX2mXEeHQyl4TAesn9Uyqpq7T11BEEO6UduhHW90gvLSOReDl7a66LJEQ3tLR7k/UCp9w9h7jy694JLETLWBG7N2Hn6iKtMQrD0/2M0saBpzKxoGHfman1dr7t46XJMQOxfJadTIkfxHMapBvRPCJGDJGVmArxOtp0EyoUNACd0EjVe5hI0qjlYfZzzugzRC0SkAey3avsh8+b2elq6tlwtFIif6+cE9kdb8EaT3pvwZWMiWxyJ94kafpreYNXO30wumxPXtNhUXqoXUYi9H9t4WtmXEaoB/Znia1d2MlU4qNBInQxuq9aOpQJgx/mLxt+xax0WfKoQKfyG9Hhe3YH4D5JsGoWt21yyNXbjuPU6MkzV7qyLAVUMGmCWlCx/UPGdbuw72SuPPM/PZgJqPskOlqocit4kx6iCj647swYTR/9zppBtM6Q6jR1ofdGNqBpmnBiiZRVrfgCMk1Iu6R21+1OKJVrSS6TN2wAVVr+8gAEfImfJmq+b9Xdp+4t1L7tdHtdpWlsdWIabgng1d74EfAMCfsfW/d37dMKNd2EZvPb4Fj+tOq6k0ZlmiKesNh1cxWJopEL7qAFzSki8ZIUXFNuXbBnU9foszPmIrzmfYCzNVW2R80kNR8udw7k4vC7eqADZy8R+DrTiSls0DqwnxmW1K/kT5+57DJ8aRkzO18TwwzHrdIu3Gw0W1gKcGRH7IPHjLEG0cow3sq1Q3ZFM70otaFJzicKjN9 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fab989e-1a6a-42a0-6f8a-08dbc0351e38 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:10:57.7218 (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: QnajaTjKdlX33mrEGx1VEo+vWIuiEVXU3e9iYroJAceJ++mvq3pXa6AW1EOSpSJ63wGVoErasleYYtPJQBw+Ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 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 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 49975e8e7cde..783e51b0e178 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -216,6 +216,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; @@ -3021,6 +3022,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, @@ -3035,6 +3062,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); @@ -3049,8 +3078,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) @@ -3058,6 +3098,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 Thu Sep 28 15:09:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403225 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 C6C824CFDA for ; Thu, 28 Sep 2023 15:11:09 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2057.outbound.protection.outlook.com [40.107.93.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D230194; Thu, 28 Sep 2023 08:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M7uuvqKeeIMwC91uxLiNq2IZTJQX5o+VImqrdCvbip7AvFKo9U/RHvSyz/f5oh2Xwu9kbc2kynVcF5fYHwhgqDx+LzyiO1IP4Yyus+zcuyFJDxYgvZK20sS1Sx9xb4Kunh+2FbAtBv3TVb6iUZzKQy2Pa7DvZ+RzM25/C+ALW6Rze4cVUNt7It48vRSPXoB9uj2bX46ISAh24KnN3QdPUBhwfg9q0Zp9DV8NFa94kfhFeXi+wIBX8O5OR0oK7g2KydSjQNC2gl9r7MIARS6fQQGsJ0c7NS+Nx4wPSv3s0t7M/J7SRJvkbkkd1/uIeTgp/IGl2eT1tDSGGGBrasKOPg== 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=C6kWaOq2AA5bU8mKdYgkuFxRTYeDy/QUO12WKeAWDjY=; b=QxJ/EGoXgcxcBsS6NhndZQVsP7A/iU4FJFkvIt0kDdziza2o8zfLXKcR5O2xsZTwHGX1TH1nm7iZDcxc/GtV3GRNKt/3O7TxlLWjyHlCfUx/Ss7QlRjfXjTjbK3joc8Te4308DIOs5C1AwpJuu0DbDpIcuCGCoLJ6W623yIF4Ct4McDEJeI9wBJPaDog5KUWBqAHHtjh8tqev6T4lkxTWKXPVf6ev7wOW/4fTwvTrjS3E4Ly1VueEFwljRMzt90JkA18seFHeCMBKjFFYe/s6B97gpZIBQIeO/ACPUZiMvsfCNZxzBzYDINJhYGNaRPCYhFlGbxMqTtnXs4nkh1nEQ== 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=C6kWaOq2AA5bU8mKdYgkuFxRTYeDy/QUO12WKeAWDjY=; b=nTIPJdUD+3IUP6yUj+IclenwrMxsqvaBMpnDIm8MK15cBwAotlAKL/1sAR+Vo3Our0430ByZyGvheFGB0sezSWzWhdJQClpw0h+hWyCp7hjMEHqYa2lz7aio5Kg7zNAb1l95OkQiXmfXVUszjsbfg7bVD9zAylqHw8uHHBF10wMTBB39+MK5JyKfQCMK23UI/D73HFcY/2h9MuvLu+7lHhEDp8c99JoGqCTRQo9/5v2BjUqnkiBSZ9fdYviX7iYqbOBFPJeiKH6OazxPPwgyO/Bt3HXi/2I7p0bPBlfH6+uFiFl4/1Bm8s14lFdi3Vmabc1GeLnjl+3xjruE74OGEA== 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 PH0PR12MB7095.namprd12.prod.outlook.com (2603:10b6:510:21d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 28 Sep 2023 15:11:04 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11: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: 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, linux-doc@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, corbet@lwn.net Subject: [PATCH v16 09/20] Documentation: add ULP DDP offload documentation Date: Thu, 28 Sep 2023 15:09:43 +0000 Message-Id: <20230928150954.1684-10-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0132.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b9::10) 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_|PH0PR12MB7095:EE_ X-MS-Office365-Filtering-Correlation-Id: 9484badf-61be-40ee-f9cc-08dbc0352242 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4r16ZQP9jIkbfXvH3cfrzRMODhtlM8oVjSNpudEf1FFSEGOc/i9ASDW1ZvStMUDGKPpH7tML1B0+KrZ+f1Gnqb5g0tm1Gh6S+Gx9Mj9TEtzsFSGt6m6/nZcCYemkIS2d8qzkJC8LFUvuWAh/b/9jZIETlhv0He2gCad76f6Uf9q779hPWFuojDItpZjSV20kthto30/jYEgupwUG1uAdbqIXnj48uaeLDNKLr4NG27zUWXDjY9jP2x1UDDzDkqfKIFMnE0VZv8MdMXyBaLxiplYhOHv0rztM2xtH2MNjBH6LM20UD+5+9DoJQ/acfDlF6lBnzFy2gscHEfUXC0q9uTo/OZtLL+gWAVB/qPX+PIMME15Fee9StrqEQym8RPSGgtgyr6qKTI2ovpdMrhuTrmDc+qzjG1pMEXyj8sp2ca1TBsZQIXL5GDn8DkP+qk4GywUnNTVreBREjM6WhnMgFNRwnzaIJ97XPMQH5JegzYEUXRsoDYm1HQrOj1xqCGHT1/AizGa6pT/IIfVftN53LY9gdP+SQbcTxuU59jWUbMLmsHXnoXX1NdNXNgbutu2 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)(366004)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2906002)(6512007)(6666004)(6506007)(1076003)(38100700002)(2616005)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(83380400001)(26005)(30864003)(36756003)(5660300002)(7416002)(316002)(41300700001)(4326008)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hNmvPahXN3JganbvQ+yB/d2xPrkOYaUdl7hRsbpQ/wwPHo+GbdnPQu4TOZLWtLRQJNEVsfO+MMzX1tgocNR76E2W071zxUzQF9XxQpKd0TfI7JJfci3uqHJOm3L242/nrgRi2U1QQb+4TeqTRwqec2ldetbu6/xAfxCh/GihgZZIDCuQrSV3En5eY1g9L95a5KXfZlOInjWXdKs11NBdEw4+dCCRV6Ij/jIJhLMl0XZ93dL2xrcwCSG/P1ddO1TGp6MJWtROOEczp0Lh+PD0pklTQIp8SwZnX7hiilB0Zu+Uyuz/IGm+5QUC55QUVgr+yoChwD2CSGUsvruOk5w+fY7jsyn76H3UQvepoe1mY17OtqfXedHThmSgY91uZqj2H2459O0TOqRHYWcyfJDk0EGhVKA3JEtr+jgluQPCGkywY6pjPuWLoSlvj6T+K+mFlKbFvxPshSELhuMMigGyZjKL1ki8uOIbpcx/Pg03ybogi7CfXpkDzx0HlTgBMY/oy58icwl4wxVE0hDF1Z4U0wwUZeW7xJOc+vOawKO+rD/YjYMXaQFAoTkCX+7ppxpbBWm7H0uwX4FbbwTmvCX+zhj3hIf1t3Iihp6FnNryCBD8YypKfpT2gny9K/oLbNY++ke5d3oj/dhtlkIhTnLkXt3GS8O7QUQAPWWouPaXXv9sR9ePCxRRSS+BI9h9QAGu8FqoBLFAjpnovn78G7aYVgEK6+2pgZm4Nv0Y+CT/Em3pkuZBuBi0XpnczLxB8CkMKGrQvJn00lexJmCYlNzYcSm/VCcRRPmZzPuuQcQKBYvweX0aY28OMKeuMJ7NaBCKql06hbBo40foQfPO+iggUSaDke5BR6VoXnwO4d9OzwAnZ63pIj4smUCZbszZuWgtUx5G5e6tjOPU904MH8rPivIUZrhpeoxKu7dlATOLxWPBB1r8JSOXmYjC9i3PxFkY4GiknQ0k51p7gaXqWK1anJRLTmRc9DlhM+NUAkBODtI8ULnF95O0a/2MAT+CFxB/NwIWGX8DGvNp87AyK6/efpg0xHl0LuH+NG4rM1jwu3g4+DB0mGkAB2fw4RHTqlBQz0vq6T3rdY2d9j1kGWhLw5Qv8KX3w7w2rQBon2SqDkH1G93FLq+DD8SNlkSAxNkZERxZJHztIvexgu4/zlKh4Z/KzI8JBTCVA+gY2dbh3brM80BSMvAwmoqcj+Dn77GZZVkHEPHW4Htw2crOARPTWjhBToCUobRkrsXBmXy0fEEyYBfH0SpD/7b6jGlpydS7JhYu9W0Ww9blBwAHwlQSavWVfCjjDUA7fdkcPfU8KXiCDYjQTRxbHc51PMJ4nYYHgXUDldFImqAzytOVuBrJJgy4aQ6/TLeApueRNCvSj+Hekozffa8mjRe0zev+CcURmsl+XmvsD+03RdOPIsYQZ/H3PtLoewOsKMTA58D0q1AwJGEmTlAMrihLOhIFPvdvtXjo2lRPmV1FPZLhKlLt7teZZwB0UiE0DMRWStjGlrXwBBBDgKgUVLPENd3seuawmAiiCIqe57zlgtfWrpDVlsZcsOKREPFQyYK+0bU7x856pudW4Gd0AE074Cm8SyQ7 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9484badf-61be-40ee-f9cc-08dbc0352242 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:04.5756 (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: VhrL9rpKI7faS3cG1juNqYI01cURArNzt63lFKY5u44d1UZqmRyNj/j7+l2fOtlCk9Tt9fhZvwEi6KIibkZI2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7095 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 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 | 376 +++++++++++++++++++ 2 files changed, 377 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..31b7edf38647 --- /dev/null +++ b/Documentation/networking/ulp-ddp-offload.rst @@ -0,0 +1,376 @@ +.. 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/netlink/specs/ulp_ddp.yaml 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 + */ + struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; + }; + +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/netlink/specs/ulp_ddp.yaml). + +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 Thu Sep 28 15:09:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403226 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 20A9F4CFCB for ; Thu, 28 Sep 2023 15:11:16 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BE6A1AD for ; Thu, 28 Sep 2023 08:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1ctteyqbMeV/Q71K0ZXNPYFJqhLDNKIz3Lyzx3bwc0u7gx73Ity/pRLNGQDLs7jab/o7v+Pce12w/oLBzjoM9KHHZV4WVRVUD2geQOz/F+dYVzxQfYzwaDWVY9YrXXOalI9rFBa0b97deQRz1A/hxbEBV9LPMQSkI0N2iig2DVhhVIm7FtleUTGotGuYhnSVCRhOrY78+QPCof2Prt9OALCujRVYBsW49eklPwcHU1+1BaQ3CAqIP0Kh1jXejMbHC0P6wDAMdNhn1GLahTXTlWoKipK1JyL4CAYvpqeODN2c/ARe4IDG7z2yeJ5wSzy7hnpLJRdcl+WtRO4Ar9RdQ== 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=Rzca/FglOu4Bjpohem8tE8sEYfE46WYcB1chwK+dT1s=; b=mAjaWv4pQzgl4/QyPY366zXMjuH+BWw9wpjovmgG98/HIE6FNuYCN/X1U/P1cWR9W1/KB8LaW3n/2/8pKSVVk5RBMO4Rx5gw2TB78x7AF0sXigpvNp6zFejTSoi2UQBs6/hsjKwyuUow+WWQ6G616rBXa1mxlpTTHdgQQvP3G7YdMZX6DsWDbM2Vv6BHd0Am+a1J6+xA0wXw6TTkxtlzH98eH8ZuHqCj1tRRmEtd3TINNNXZdO4D4W8IyjiMqaZJnT+n/KH5R60Snvou+hWUpksqyzgyObx0lhJ1PXxh+CUTR/lddB5f3THT/7ABbLwfLkSXWmckKPWC8z2Gl1oj4Q== 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=Rzca/FglOu4Bjpohem8tE8sEYfE46WYcB1chwK+dT1s=; b=Agnaj+r+3NMnlbyWk1NKeLLjRqHIdJyJ23lfZoCGciaZ2w58y08wbiLPkV5SDkyRMM9XmhPWqjHxOk+joB5yzRUIHMkGU1t4K5UTs5GV1121ygqiAYRnNMFeHMT0pXQ3U3d6oVsjywnaEwb1TQXsmfrCtdUyajO6k+1CmrGLGFIXkMk9Ax/FkyuR1Kiph7K8YNlgcU3nAlvyrjLXjiT5IF6LvLTmu6d6qSyxNVSJkoKHl2kVEKvoBdTmFRpCItZQv6E3L9nR07QZ8qArC2kc87yWnOFd4yqxeyExIVdzhPxZ8XdHmxajHppFT4VfstDBbekD3LeIx+cdNUhqUOenxQ== 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 PH0PR12MB7095.namprd12.prod.outlook.com (2603:10b6:510:21d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 28 Sep 2023 15:11:11 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:11 +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 v16 10/20] net/mlx5e: Rename from tls to transport static params Date: Thu, 28 Sep 2023 15:09:44 +0000 Message-Id: <20230928150954.1684-11-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0175.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b4::9) 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_|PH0PR12MB7095:EE_ X-MS-Office365-Filtering-Correlation-Id: 2444368b-27aa-4a46-607d-08dbc0352627 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F0LnV1ImOYCRnzRvAuOTZUEb2t91KGsQEt6BUDY6h74A8zLIb8/rwECjLu9TknGZBPeDl4lOVYghDfQg5y6uQWEYxaY8l53E4W9n1sRrnQ6tq1q7eQlXGPPTEMsfD+QgWfAL9DeHE+PDeeAPVQmc1repDhptQWPSRiBKYzJgZkotiZdNvYs8pk+UjmQ76o9GEfuuD71GxQpntAZ3p2vmxr0YE2BfVqno8IaZGgjCaaAVr8UTiYH30T7SpAuQ5Ac2HSYM/bM7aIMnnJcHrgCfwBYAvknynw0YCE85urgWF6PKxo8srkMzSQn8pWrSIH6cgBRbS6J+wdU7cCaYhdJEAVxNvB0AOB94YXpKY6N311Q1iCe6UntSXvRlSk4UW6V4T2aXCXp+PNMi7r5LNr35EIhPVBRGxr14+B/TcGsHZQj4gBSAh09up/t7+0IGSfzobPr+deWNio+ga3RR3uEXo3DoE2nUCZL6la1kVUJH5qHg/a3L1F6/lIifwISPfEeh4Qi3l8oIqe5KGzMJA1jbGJ+e+JvCuPb9Q7RpX96+MZpYG5hJj7gp76fCi8IDAy33 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)(366004)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2906002)(6512007)(6666004)(6506007)(1076003)(38100700002)(107886003)(2616005)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(83380400001)(26005)(30864003)(36756003)(5660300002)(7416002)(316002)(41300700001)(4326008)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FPkB4dxacLGcctISB2kjgsAS0uJg+ZU0jOAZuslWMOaku6mvnT8m/fftm/kldg8xIfvMB+5U1R69RFcBEBGtNt+26lq+rFS+siXFUGyTnW2zYLJ5Hyl7h+Sa6PvQeStpinSYGjf1AQT0maeAKzNvy8ZLgSCKCWxR0S1jMfngoNDYhtMli7o+y38dyUzUYW0Ya062DhjFjhIrApgm1Y0KPfyYp8FSYIrMYLsiVVSUhdDRlU5iSuixLVgI8NI+XcaeKuGIzX+94NmtV+Ju8+DItK0CVKh5LlBd9vKAoQB0/hKTX+LJIyTBEyeOB4VDMSisByzU//DYHKQr8obnjqfWlks2IRKhtan9n0dFVGwskH78M8WIez/r/ZZdIyPMKwHW/k/QHVN3v2mu49R9WPmuCiqsMmuR3kT1GLW00FLX3/AGDUgstrrEd7GB+I+CQJWULQKE5b5PUVtsD35f/R5TP8x+xlFc1ZguLUTixX/a2Kt9A97jLqXzvj3knkdyw8hI1JOs9ISGhhtNlAcMup8aeul1QHEy9uoWIYznxLb209wQaccE4lOIUIVXZt1U5qSavtuuLX+MnBnLlokX6GaExWtFEr/VqIZ8q0Aeg29px7HTVOsMHWmMKgQ958I20yIODTZQ17s5xDPVPl75MVvnOjCmxt2z91LgBjCOaTVi0BNittRoqPTeQICQRUsXwv6HNt+NshOt3DtWvQZY6mnDq5atGJsuYA5cxdaN78y+Yu2Fknw2YAbRsSMtv2XII4Y5kr5K6CgV80IKxZ/Xsejcuz/NS98BdJsQc+JJXeVLiBc33DQB7SAlO+6UxrnJJL/jc7KiV3xRGNpZ2BLTxZw4ntjXeuG89uunnB7twxE4H5BoCvSmRzULB8hO3jUWZQ72PmavetiWByO3ViX9RfF+M3G0UHcjJoTmZdDU7zWiM5Z2XmT+DQsPWWzxyrPI75kskJylGBk+W3J87uR9lZrfnpKtXG4kIq5mn7PiSFWM0FRWBcn0GwvC+LUfNd9oBpnslatR0NgOI1GDehGaygBcvNJUYV9Pf8AWJQDBqzk8I0r39XYgPus7D51TxicG80W64e74ZWQcx2ej6sBZinvwc/npEzYI4k7Lme4EF+XvuaEOL3CTqC777exDj4P4sCqucgHu7PmqJeB7RuPEA4XYxp3CYQih5DXMUc7OtVbpWne0AYKIGfWx6iFgit2A9RU3VEuH99qyWIXW6QYW5cYwYjNSX49Iz7g40kkdpE8QCNzwJDpZOa6NhGkspzPVXU3vuVrs+p83FsT/iWh++HXd9jMmfP2D7fwwWyyk1/SKZRv/RU2HPf+J3R8pn6VIKnEBIyK8CK96MdxMfd6p6hhGu55eAlem5x3KreLZBSK+rCeLKMAEEKDgCB1COcuXWHSYQ+l1eI0tyX5Avc3U8vdAXGaudWHzTiISEcbJOVaz8zc9AT8FU0O4BkxSWq5UqCuutxYPyO+Qf4VTLRZV3CiVgD9EzXr0BdC4KhEWQBBRT25hEUwqcXDltSxPlsKG1Eaj1bfBsLJbRfFsMMWntdUTqju6oOrLK0SPMM16d9/Ukl2bhU0YEx/boQznPcUvmbhK X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2444368b-27aa-4a46-607d-08dbc0352627 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:11.1340 (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: 30AVjUEiLsaaPJN4/+c8wgr3KZfM+jVCt43MZz3IFpf0xfOqkPGTgQioNJvEHdTrMdhrnfYW8OgbthQ8jTPDEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7095 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 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 8fbe22de16ef..7ed01daf8a1d 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -452,8 +452,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 { @@ -461,8 +461,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 dd8421d021cf..ce317b4cdfeb 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -12292,12 +12292,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 Thu Sep 28 15:09:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403227 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 B5C0D4CFC4 for ; Thu, 28 Sep 2023 15:11:22 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FAEE1B2 for ; Thu, 28 Sep 2023 08:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HisLvv2UgrcS5B9vVdFTOiM6d4UlfOco2a+7NnPNLoGbzsjnTLmkR0wwI5BsctLp5zQwsdvWs+LUzOa5go42Q2pO52mqY1hWYYDU8/k0oQkpHovBFkjgrCekU3Ht2kGn2MDzEL7U37zNKwPkoEHglKF4MWhzkj31/LoXR3JRIyZye2j7Yhact6Mr4vpXe0jCn4KZbD9ysqI6vtIa19pKuSV2bOj11TIDm6y2SEVKPheir54RstSAYjFez0aQbNAlbmLwUDjLCfjKnoekx6xQ8AG4x1zAEO6K4SmFz5dffDa+iUamYTxgqI5TceX+p4xi16kj4cSS3kyDbAJld8RgNQ== 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=smKil+QXC/4BIgbF9/VFLOo8KkrTKoyfafMBSFa8F6M=; b=CbszyEYV8AzGj6KQbO0hl8R3JgjEuCthZ1ggUrwvxrsPdcRGCgDy8ZYHlezHcdpthfZLpbH+3wcU6/8clqbOeLiS2t1/DjFXNmFy3awZeM+DeoZETawAa6Iw9VZveyZJrsIHNlI7cQN6hJKNnzSlmgy2zp1hjNusEgG5a99wVdY/z+FMDfL3csiR4iIbw8cpSfD+0yyoEBZb/M26aD8utkom8/cwRlfbNbVaS8Q5/m2xqw7g8DyfkDyrFl5YhNdueo5klWOZDIy5AhmdnRhLB+8GgxmeSAM1qbLYihgUi4vrpimk2LOTzsGR9dvQFI0FVjhMeH5P+Y3w+ruD5Ow9NQ== 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=smKil+QXC/4BIgbF9/VFLOo8KkrTKoyfafMBSFa8F6M=; b=neJhtjaRahoe7MtYLBUvjukCJvY4Hbt+ugHL4LARxZNxsXmi6+2HroBTRgoJk6nsVpxJX+CU4IYBwfUDHdqcNVaebIDGpAmp8ZPFALyfXYYVMYsxiKtDAltwIrQ2by3EFM+yyG0JrPa1Qv9fSZbDuxTacztpbFYfxzNvI6Y3yr2glGPQd3U/5dBYP6mESFV1xbTX4InMrmmrDWxa6T2NZ/gnxXPigweqaxEC8YV3hYyY2HaWptiGulCLfmmHIa01buOsIt/hqvHmZb5+q+iaiahu8hWmt4QFbVLtwyez0iRedXWf73XT/5qvY7MYFEHqV2VT56+onwHdETTQZmjfog== 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 PH0PR12MB7095.namprd12.prod.outlook.com (2603:10b6:510:21d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 28 Sep 2023 15:11:17 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:17 +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 v16 11/20] net/mlx5e: Refactor ico sq polling to get budget Date: Thu, 28 Sep 2023 15:09:45 +0000 Message-Id: <20230928150954.1684-12-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0109.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::9) 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_|PH0PR12MB7095:EE_ X-MS-Office365-Filtering-Correlation-Id: 11c8f25b-89aa-4320-ccef-08dbc03529cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1kkVuwjUQj+/UY8CqudTGzERrWW2cKvcDg5mYppJp46zYZcGxYnBQ9HRpuftkrrss0dPhbyrGEhM6b5/OEuOHYSvl52R5rzEGW2iu/le1XO1bqs7IhVjZJmdY91y1nl1ADh3TnbBEZ4aOhmSpIVexO5yJ+zIi+mzAXbCqfamxX3nUhP14tgRjcAXyU+GYgi+WRmyeOMZO9fDXaD8ITEPWDsmfRkRYTCj16ZHILA8Vkub8Sv0Gh4h+h/zbd4RFqSfqrxKVYfxbk0A0SQKzdgWQpjYHdN+59s+s+d8UqiyvHEaZSxQT2SWsvTCbYVIizxBSjwqSU24/GTIiUZaXGIc47K9UWOASSXIyeGPN9AZDgXJ1J/SJ3Yj4BqBLhqJoJp1q7SxcFCAiJp1iHYIvAdtAcXmyD9ZbKXZZOQknRUy/orf2/4mJSXynjMVnU+Fea91rafvwE+0Q+p0PNi7AuDnQt61Bxlo7Nhkp9qzPO56Ghq3EdsDwH0FBHdkzQ1h0clB2pLinNkGsErnWN3qjjwvGBSRi3SL5GeeyQ1GcSlGppTzMPKloP6YSqLynO8V9T2r 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)(366004)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2906002)(6512007)(6666004)(6506007)(1076003)(38100700002)(107886003)(2616005)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(83380400001)(26005)(36756003)(5660300002)(7416002)(316002)(41300700001)(4326008)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /x8mT2h+mMSX+a3+KMIMRCTaLxh0oVokp0GhqCgoudqtCLsRym3y9yS8ZfRn95reEcVwKvjJgBTrNR25jj2ERGCjJYXYbImEnVTzH5JQKagXmWEe+fp/B3kZOj0o2yahuF3knt0lRFvx9w2aJSwFOQaRFTHzVpI/skuzyYdN3iDWSl40Vt8BBL+DH3El5kv4vsNXdUx7BSsOBpSBOlrdZe8yzzd6cSRBiyAnOfPpzoe7K881gBvH8KbsZO9Uu+3kFp3T8O6h5dJSmjXw1wl4aH80W3LogiqkUijF5C1ivcIrH714IMkQZqqIppFVtzoRocwzxziQZLSGPyb0DwqM4I2k3EAlbNhCpyrTTd5/6QX3pbJjncPgvzBAAUWCqF+JEVoD1KqGKA1WiH2WrfHmeZYn43BwjREAdjEq0y41sRqmBT2Iy2U+DSYt/PMtcVA6HJkM/Wy5a57bY6cF5YAWo+ewkU9gyMJUVyiCGNxfJBno5Piyx9N3nEJpmTkKKk6lDQuONEkTepMDpHZcYLhj0FW4+sMioavLmhyBNJ/dkZsZU6Jgeb1NoN2qTwuzqaS+Eq75r+FON70HlgJ+0jX3xJSMKz59UJGRlV3jB1RfpXW5J7wxFw5uk9DYV9AfAfklVC5FuAx54V5KqK+2zZqop7XV/YXd/+MlHSQe37J6Us+3K2FLRy8kCjXJKq4uyqjaZv+oW7iKaVoVEj8Mug+MY8lzCz01HPd5JSpkTS1r5YeBjxZB/1Ry34w2n8rYETA6yndcqsBNaHbDkddvken2a+C/sSGEbKijEb+7MFNHsvFm9CYhZ4nwg47a4gGsc8g7nVNcYKAWa/0OI8TL9pI5fnRIp7G05oKa7jsH5ylxXEJ5VymIn4lfpwOZMkfCNCNLSqLfR9aKFHjGDp+trdfX97+NQe0IBKMzsHzR9JB+XTxLpsH+yg1IobiFtdkKyHxkB2r1JvurRyLt32yr8TeNmG/Zj0UpZ0wKg8L9aHIO3stOwoySElUiX/QMuBbnhRdR/wjxtFJwh3ZbSGJ4e8HmulGx7U9wj2pr/p/zM0ZJJpevByMjiC6S5RNBSXpl8XMxgNo6D4DeHxQwd1cu+X8FllNpCoXhqzkJT/pljm9eolp3S6GkLjto4i75eTiAi4ehBO7SDgYjqr2qMfOSPGLs+kGUj7S2LfkwnEzEKPCtL3EssDKI+BT13jul7aN3MRScbZmNJ4XtWqpQ69X00Ac/NHLTUcp4HwjB3kac848p97eVp8w3QByyVewAnzUXsfWeWcuz0EAbFrVFgq6lF6TCfY/f+5OPrI5MM4WYBlRwSR7hxOqDGk7vcM8CQbhMKaLz+S47gQlVq/zsBw4jLmUtXw2sc87xsdlnkCjotIBJT3rAzsNRK/PVa1ErJV2oJOqyOlnvTDdbutihydSQRG7/jTq5bOcUy1YEd6yrE7kkNkk5byvmaBHqMsTI3bffTWWe8D8L/RaxCnXwYyyYg5HotDoP5PkUWsMWghHmP4ZUCMC/wccjQcMW7D9JQAP+SjRxbJunCIUhI14c0P8rkZBWYzAT93J3w+BGkNQGmt+FSvICVYUA9qZcaAljQSj8I6yI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11c8f25b-89aa-4320-ccef-08dbc03529cd X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:17.1741 (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: Yeqqy/dOt4QHU7Ji8PB27yPa/W4BzsdDcjwXjJgQoO3XK5DUd0TAe52X1C6u5o1qzVIqCPxLGmvBjBdHGzjb5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7095 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 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. Additionnaly, we move the mdev pointer directly on the icosq structure. 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/txrx.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 86f2690c5e01..d3982baefab6 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/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_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); } 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 Thu Sep 28 15:09:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403228 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 A86744CFD3 for ; Thu, 28 Sep 2023 15:11:27 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2089.outbound.protection.outlook.com [40.107.93.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 953DF1A4 for ; Thu, 28 Sep 2023 08:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBuHd6+kbZpUOlc06IIRs0oWZ1O3bJ+MgROZxzOtRPLY0N4GAthjkRdiEKKo0vUxf/yMSrbFl9OaQmWY0rXoWxW/svrjR03bKFzz39SrB+dMKKJw8f1w+lYHYZskyWDqortT5O/s0i7et9y4ugfmeOaGezxnU644xu4xYQkMN+L4xbRZL43eN/Si8Bbwbc2chNVDdIjEsXkWo2xwE3q6BMcigSzpaAF78waVrV/f6tVVOyXSWz4YpwX1IG2q49UWwtYcOnrQuZRHAf+UetwrFW3ChadbnTHrxFuYvh7zcQnBThYLc3gkCO7ntWBYVmLgPO0MTrLhH9kJwh0Vj6LIpg== 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=hCW52u+tBc46A5Q40B4wUAdQxT8ZaBWBmiCBr+q8NVU=; b=m8YT7Iylpu/TwL5bc20e0uokEQ/ngP9QUzLXr3CMjB9tt9A+YX0BzyDwEpAF0g/0u0FeGwBgbaS7GNKhUtO7eYzlYWt+NQ5r0nlEXbMwpRaY2pQk2xEEJeLWufPmr6xubnwpdIeqggF3Vp+uBYM20T/yrV72gitBwz3GKqIobgnclT4d6QhEatCAKgooDISU5FW1aVbJpPSQNkJcrko9RKxl818tCbbWzDeVA0Nlo/NX2GVCxNFCsJa9dUVK2xYbYdg6ZALygJU+gJ5u+WJFpTUXI+hi+V48S28g7IM7zdxBK0ERcC4e+P6WC0OcFTlnFtpEKmZJSVjhricWnzNpsQ== 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=hCW52u+tBc46A5Q40B4wUAdQxT8ZaBWBmiCBr+q8NVU=; b=EvT4JYLTM5N94Gt9kcGjdz/jfM6Ua0C5xWOguPEYIDw9SZj16mOlebCg/PVFXQvTH5gJRqAno+xs0L5DBrY94DfM9UZ0GZo5IknlSZiyOFXbmHplyY2bcAL3ccf4FDtmil9bLVhSXqjkeIIo8N6g3NAl8X+ZCrx+6iM/cH/uImLWvYvJ5ApqFsdnCYxTRZH4sDpvOsZ0SZ8Es4YpBR7wi//D/OGqaR79PEe+xEB4nRMEK7IND5R8FQdK2py9jkJvzQ28EXAIkdnjedhqr1LP2o0U/per6w/VK7mWivrjy3YStdaAtiCJXVTi9E+tJjkYI5fF+vuaXhrjhe6AxQHl8Q== 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 PH0PR12MB7095.namprd12.prod.outlook.com (2603:10b6:510:21d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 28 Sep 2023 15:11:23 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:23 +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 v16 12/20] net/mlx5: Add NVMEoTCP caps, HW bits, 128B CQE and enumerations Date: Thu, 28 Sep 2023 15:09:46 +0000 Message-Id: <20230928150954.1684-13-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR4P281CA0133.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b9::14) 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_|PH0PR12MB7095:EE_ X-MS-Office365-Filtering-Correlation-Id: cbbd7d82-c8c4-4cf2-c24a-08dbc0352d7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ph0u5G8CU4hHrZ5a8dob+GAo20vKnN4tLMaC2K//zrEGTIUSKjNniuqFz9S5kL4peNrpXEyR0Fze50QkoPb+Fb7tBcnRbyJ/hVDo+z0JGoFpjUaGtCc/tTBHOTzCHLgcF4x5PvX692gwx6MU8PJi+FdDGp4v67vTuGljpXCyVEQfyfJyVNLW/SJoU+noBP6mmiokEs/wEcYiq9d7ZtGoeRQrYfSvqpxhVWSapjAy7sfJVSIvGjYFJ8sa9YPKGnX897OZX+ckaYKJBVNTQXlCsqGX3BG1rL4+A474hoAx3v6/js6UZ8+lZ1xY52vInZNplDPV58v4F0mjg4P6RPXmscCah6IM8/2XTdzuZ1G18QuwosS/U32r2GHG11vq/6+0Szh/m6WTOyF70/EjY0vzWqfy33E1Hvt4zQ2ufkrAnYfhAEJUNM8zNFRVoV5jv9nIPHKccMj9vnGBM/ZgfIh4aYD/hOpcbmfnjvL4omg+2YG+OzBubdzZTD/E8D8a2OWD4JOaYBzhP28jVOzl8Y0As4mMGlZlmuJa7oGsDbUE6qBnHTEiFM6ZPmZtaAmRV0OZ 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)(366004)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2906002)(6512007)(6666004)(6506007)(1076003)(38100700002)(107886003)(2616005)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(83380400001)(26005)(36756003)(5660300002)(7416002)(316002)(41300700001)(4326008)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VGm9D7UDZBpUz+dE8Qu3o8FH7Odrpa9ikgS7mJxlqB7gethpBCwzR5tK0EXpWXyrCri08HVPyaltU4Arnf81AfkxlIP4+Ks2YGjkiPBuB9/Bpa8j/RuXlCa3sXBGWs0FaY+nthH/MVoFhvbCN20TSsiAvVM7joXzSU59ccqgFv/eRHWp1OOal4Q+V6UHBYFpsfj5EMwjdjwqiOT3cbYNSq47cQ132JmyrmumwvQVDo2mvZV255u2Q1lxJOeLgT6u47RdIn2KAeyNl5xU1wQHDAc1QZcuqWOxxhq8g6yPBaI6mKri032TS2fIJEN8vMKcNAGeymrVohGHAR9EWsTRMOSPqOon5k3QOj2npCvLMoAoStNffJrgFJfTF0WttWySl9NaNZaL2CeUndMSict6NuUaKmDmsVILraYlVpTG1KDYta1GVd7b6nts87lrA5rdOj6eqbuFVq4jD7tSeDEpTy2Yz3hk1gl+r1dmQk9LCf3dzDO0owV2D/nrzQ0yNnn7TzXaXa1NrIEetzhhSR1MSqZYUqEglbfVMKMlLRhfATeKgSOK6gb84Uv8GnDO1fITdKzANwYKYhFF22fcc7dLL5Htq/6H+7QKYiaPCaVC3wafLJL2g7euC1r2XcJ6WeM/yy+jK6EJEVlWqdAm5IdCi8dYHXUXuK4ZKCLw+yZw8It0VDDiTVSo2ElJSQuyfXjDPb2rb8He+yH4pJiQF4psVFk8gPVd9opGQnJOT4U0sSDW4sEuqXZRimAr5/plB230bC26+9M+LwrUqComcSlHC8ZeDj2CjwUNmPMF7ndFYzFkEnd7l23tIVjmDD7FxRVggTzuH0ZvOkfI308lCjnOSraRezSirGZ52fNQQSxM4htE8ZoGKo3MG1ZyxosBH8pF3pIRlBVO5h9yD4J38crLUbStltpus4DD9SU+noIxXqrBchEf7ijoYumqXnOacVzQjNwR4+Z6DcaDjY5WvQxZTmtzu5qmvMvjxb22mdqMB/X2iVS3ExMhVUHyHRxrkkx7Z+giq87MEzfnDTHxUopIb9T8TgK5HySHvkKDR3MSDV0Lw1UMB6hKaclVo9an/eOhk0ZN9zDGtCvb3EaHaF5vAa0q5+JfOmb/s8h6Uj48gWc6HVm0mELYP7yBGO/Hj0H3f08kWxSuCAQ0uwPl6XZAlscRhORrjTpWJJZfHcNET91yUpgVNsRw1kYzQvkzLk3ZmgKT3loT03Qf7LvOqbZUpvAlQobusFH6ivJ/04dWdpSd3OLEAxZO5/7pnNWY1O4H5Yw2g8qMHOlMDM3RJyKNoiGlCvMLONsNmdc0chqUwiAe5fJ260V9SeZQcwVMXvGaAcy+Iey0/XqrJmGs0MR7iB/2YpOgVYyvDhxy8id4mHr4YwfbRwaxQZwi2Eq43zrUFhRxEzHTY7EF3OzejDMCexOkSN0KCtlMtCuHCHCrBYJLdcyZ/gAeWu22kN8OJjV5DGhRQrEGBDtRt5I+FieukbwnsVOENGX24VpPH8cASSbZyCx3FtNUkRWkUvvc4gnKBHNlfl/byla7GRMhQkotU3BVEWykEER1VMHdE2igsJsxMVsmFts/NPgeyOxAQom7 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbbd7d82-c8c4-4cf2-c24a-08dbc0352d7d X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:23.4170 (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: 9eYmFozCd8BGZ6YFhBY9sUwPVsphX2dYiA0Bsq7QPShSAV+Fd62dZhhDjo9XEI1RAoACOhMpvGxBZIZVXirfjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7095 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 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 7ed01daf8a1d..ffac40b5fa3c 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, @@ -796,7 +797,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 { @@ -845,6 +850,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; @@ -880,6 +898,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; @@ -1220,6 +1260,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, @@ -1427,6 +1468,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 ce317b4cdfeb..3b149c043272 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -1455,6 +1455,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]; @@ -1479,7 +1493,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]; @@ -3454,6 +3470,7 @@ union mlx5_ifc_hca_cap_union_bits { struct mlx5_ifc_macsec_cap_bits macsec_cap; struct mlx5_ifc_crypto_cap_bits crypto_cap; struct mlx5_ifc_ipsec_cap_bits ipsec_cap; + struct mlx5_ifc_nvmeotcp_cap_bits nvmeotcp_cap; u8 reserved_at_0[0x8000]; }; @@ -3706,7 +3723,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]; @@ -3737,7 +3756,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 { @@ -11909,6 +11929,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), }; @@ -11916,6 +11937,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, @@ -12281,6 +12303,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, @@ -12294,6 +12330,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 { @@ -12316,7 +12359,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 { @@ -12610,4 +12666,15 @@ struct mlx5_ifc_msees_reg_bits { u8 reserved_at_80[0x180]; }; +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 Thu Sep 28 15:09:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403229 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 644CD4CFCB for ; Thu, 28 Sep 2023 15:11:36 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2066.outbound.protection.outlook.com [40.107.93.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE711AC for ; Thu, 28 Sep 2023 08:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ui3AXWHlhrvs1/h3wtZBPsbd/mYeIOHfZM3EGmF8klitLQeKFKXsT1h6TeNl9edX8pkdZt3H2mfLbJKscTPsHJR33YfwY0go7PhNt1XV0fNzpirVQAEmTAuVTF7w6HsUhwb7LgolJqrdzX5CS9y0TfOybZOtNMNRnEBqHzc7IjPnWz/COb1d+mTQXpVY1KqasS3pYjdJLDHFWbDBNQbDLzAHVys8dJtXi/O4HqvJzdvIKMLPtpX0GkVhNN4Ak3I2KPjALgWWkLch1hXKzWsDG/7BKLLyFmTnJ9j31TgQ9cp99TqYOXfuNwP70Ww1R/91IkC1NDw0Tx8nTLyzdxrpbw== 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=mWIARN8gi/QqaruISYsKd2FYM2pKZJ/k+QwGvUWbCw8=; b=ePNCR32XN6rYV64yWB6xe1JgWAYpbFQtX6DhRi14JX4MmaYAUaGEwF0uJOKQOwLr+JV2PoCXuevFb3iI6yJwnaw/lMZbyLFsf4M3MtBy4cbbZXZ33LFhwI89VTV85TKNnGzZH1A4sdVdPFqpz4J1yy3k+f7kwJJqCG59BjDUuVsH9QPFjlKXcBY2TMkI/Qb91VUcEZfeZ4JjRCgBGTRT0iigTKAG4ZDvEypRFrX8zLlULr2bROChzHhwE9t8DvlLx3JG6sAS8kUAbgHPvL0zUpexZzcRVIiYJ7N0dyTpZolhji7Xc4g1BtZlx/vh/WCOwwI8eETYattzyxTakBWPCg== 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=mWIARN8gi/QqaruISYsKd2FYM2pKZJ/k+QwGvUWbCw8=; b=cVHSv9QJQIRvN0DQYjeRWMCrRmle1XvYS7wVh1KaSuK/tVjBZm1df6n+9H70G6nulGhV3NShgwBdvetH4emqS2XCKvD2zvcZl9GdL+HGRU9HB64OE/6/NC40lpi4Geud5/xUcoLQFVhavn+PpqkPpo9sWfnWCsZx5eoYIG4AhdJ1XALiWU7xCv4CkMmluKJgywGDuxaisxe8OCB8IH6enDYzDOl5zB2WYFqiADmXf5U9NRwLug98mrDgfRwr/o6twPNKUQIBfxmeQVtaBDNNAlojMrvLS+H6f8iE10NPoP+gLBuN43oOIlaUV2bj5nmUjl5cXelGJCLvGQqJTTV4Qg== 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 PH0PR12MB7095.namprd12.prod.outlook.com (2603:10b6:510:21d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 28 Sep 2023 15:11:30 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:30 +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 v16 13/20] net/mlx5e: NVMEoTCP, offload initialization Date: Thu, 28 Sep 2023 15:09:47 +0000 Message-Id: <20230928150954.1684-14-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::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_|PH0PR12MB7095:EE_ X-MS-Office365-Filtering-Correlation-Id: e80c657b-9f40-48d8-b4b0-08dbc035314c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: moKiSx/Qv1nx2hd0tipXBGSEZI1eYySxEajZZ7Q9Ajvd/bbx3z0c6BsQjDzjBEuEqRVXrxKnXtuKpELuiF4WzrJM0qRUdotuR2gJdQZzyJc24+eZKAS0U5qlrD7npKx+0wjLn2Gscz2ECJQ4XM6oHVD2FAdm+sokR8jxabaAbXZ05Y5YjVeS7DvRV5CYtHUJ0Rv3HZ3oOkirNEU2ePjYCwM3gmYLTDIvcTA3TxjqTjz0VA8Ng9OpVTy+rqKHkfhhAp9dCUA5s9DhRzPSL6tmetnpaULoY2EYC/IzFi1Tb2VpKof+pAFbdSAvoTcsw+aDMytON6cLLNtB+rncLTA/w2ek/boHhodDDMyxv4xf67uBB5ph37+kORU5WIQozsz7gV63oHOxHwPXgV5Et3eToH1T92x/Iq9nHQ1shwZwCSzQ4oVH4DbX9gamCy4FmV99ZeKm5PcnWp6lYFGI+ZxBd3K845aQBWeh2bmMCqWITp8PUwLN9LtGqTd5kCpAsHRZB8sx+dEv972rCIK67cjb7V/6arrRyhxD8QmcLhOFazmcIZ1PIYncSygmH5OpQ11S 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)(366004)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2906002)(6512007)(6666004)(6506007)(1076003)(38100700002)(107886003)(2616005)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(83380400001)(26005)(30864003)(36756003)(5660300002)(7416002)(316002)(41300700001)(4326008)(8676002)(8936002)(66899024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MoDRuU/vT58yEOZEJ0gTpvc4yFM2RlhZUhn+eKStmv7RvcyEelF6m7M7qw7kBaSSHG0VVsPDRNRXmJax1znncSprLX1DtJKiwrLRfFTNDkJrLwez3IAoYB613oQiT3jGGwoI2RhZP8PF87jYfoH3NE7LAWU8kkjz/5hncqj8uYyoShWyGZqCy9c6AYYPpqCc0F04au56nB2333EkLpXpgIyGvw9R4RFOISm3t8yNKs78vJJ08po/NuQFLejR7+3lWPTrrOcM1gbts9jCIQreTdGGJMBBYc3PHNiQ0D9PuIPqx3NORF3o31owyJjjl65gG9llk/EkkJsXkBu7kB0Y5cncWowhmckFm9sLgGeQdADQ/AI+2ow50eZq5NgWZ4i+1jDJ3Cw9wupwm0LqQnjYjgVqsFyQwb0MJhg5jdMfDndHnYTTXXVkl68yxB0O0Zuo3fKhSkPlidMdXThE9BHASkOoEhRviV6Nhy1oDw1rIK+zuS2f+8EShgGWG1zvapSpda/vhuLwpBVkPGkq3bGH+BxpHy3T8rqYzPuagvkDEYSWb0pBIgQJyi1hIl4EHdHCZd0OYIJIyyL6w/QNn0hXwxJhkL2ikEti/iXfYD6JatFPqAabOcKIJy0xnCCIfoeO0MbK0cqHGRV2SeJiQQ+34AtL6qMCTLWgeeArtk4VyIYHpy5kITDH+wq4qiWg8OX3ox5yXB5Dml3jvy0ZijyZkj/tlSH+TZ8JY4239A4OrwseyiZbEyOXXem7nun+SyhQ1xVi4uCPsuz3BVVcPp8ouaNeJODYr8x+HVIR8jnUGv+2YyGtoJduU9vq7yl4w++Ql3+KmVz30OuckExBdHS5PSnK29pBUarpdAfV6iv8A7LOXVbkQzYwHPqmhN6TxVpD+wHplE2aj++hMSIxhrgTc/PPNpke9zWav6VMIKg7RhLRYMhLR82hJIxAPYfjSOnDo+RJbprDWgVPGBx0sbqtlGX+O+FcMiRS5a0nG1y3UM5OM2UEILlH+nrO1G1Zya616ivzAFtFIMfjpuktK1hWcR6rLUJEchoQTpbwSlmtHUTNqbbPoVudpACtRg783XuQ6UOZKpiuedD0uHfbqSzc2xxNe7J9ATMS3g4gvkMI8Tc01p1pn6Vx6Kw/fJdCdRTcQxg7rssW7TiUeft6JppbG69NFrWBtZbZKYnnq8YmuCWYFJhStBPMfxH7zZ2DuPlumAvkbnPY61VKUz4TAvyGdWgACih49jYGxPs3ZUtFLtabS0fbgC4drLLu5a0OQt0ZP5yXq9YgUmNQ7hdgppdaULeC5+q2Jx7tFY3sAZ4Og/EH7J/gIqFnbCkI0iOzfeDdzXLqIqxTGJYXoCd13qcUi7aNfKhXGmsrqGNzvb1/rZxJpV3CMGvsbUvUrXHk+G6CK7AnySVufdtr6hjcv15rvar3Uij+Ayn8BOxSnoi8+rnivalhUf3PWXLdMQYI8NbmzMt7g4NS5hf8x6r/LzGSyrnmLVj9QeTYE9NyIFeo2A6ObUVdsEXMFzMwdD87ygkF2Pn0BMsGbDHnESPAzazVTUkOLgo8OfeJ93k2g7qK7Kjxo7qWCKzQKD9hMH7GRVr3 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e80c657b-9f40-48d8-b4b0-08dbc035314c X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:29.9685 (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: UO9DFyig0tjcJt+TZHQ73q/thHCuk7xf9wMqd7QaMIvH4lO+wtxAhe4xPm9a2ZN/3zvUre87sX3jkYy0LDGm/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7095 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 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 685335832a93..5935c2cdefec 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 c44870b175f9..f397e2eb0cdc 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 d3982baefab6..770f0cf0414c 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 caa34b9c161e..070dabb03bd4 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 d17c9c31b165..4c5008e94a68 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 Thu Sep 28 15:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403230 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 DB3274CFCB for ; Thu, 28 Sep 2023 15:11:42 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2047.outbound.protection.outlook.com [40.107.100.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD2A7195 for ; Thu, 28 Sep 2023 08:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kdn9/A6WQ2bWrRD4nhhF5VOY7h1CTFWIfZ/4DZrvVCVEIEQmg9R0pkgAHYMHuEKyIx0+UjVgqapiZEp46Z5JhSYDh7CMg8TvPhCokyPkHE4Lc9gde2kUHxGjwcO88wpEprhiC+kxdjNaZwvDF+P1IAhdOqO4sLUi/vGf33yixDECd53yYdIf9XE36TA/Qtfd0GrVVwBQT3Yo+4Y5+VmKpdir0phTi8qvQWPCMLTkhabFMjI6mkCuNNd7lJUQBmBYWZCEResE5Ju4tR/B/X7dFc8NqRMp0i79mggTp5QQivQ/gK6AaAWPhuYzMqvcrQYHqQRdACUsF5dfDskjqtqhvg== 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=duDai/qVl+ErMjCUcstTZ4hACZESydPOK9hdCsCH1NwWPn2GWjj2fxWkD7uz7ncijoqiNRZr4/2WRyAD2S90xdYeoBJik7ztm523QrLcD9J374JchrJAxLlOGArD/932TNgfxZJR22y9oG7mg3JYwfBgz/A/bp8TGCbkQhvWFLxL4xmxtX4H3DfdUzYGPOWXZVpIqa7+O1opYYXEOQ5Q0vd2UxQtWORryK+VTRPlbynwIj/6Si/wLmjpXGSEuFVk3w3NBAOVYTmx0ZUx+f7jEai2XigTjL/ggQ0CvbVEHS+seqhNU20drTDbmp7TUMCA+Tnvq65039SedlN2guCHVw== 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=jMbnM/+WZUBdEUmdOE7TyoVLhooyOa3ca3DwWMHH15Gz25IFBRfOBJ2TEIwwzE2vt6Uuuqy/ODtgaxnkS1sEsB5TFRhI1pUOdRnQo+Y1Wv5sl5r2u+BaO2ICxEdtHsPTZTFAZH/Zlu1ALmIkKnVVh9gT88SAvDlEtZIw6XYTgIqhoZDKOolHJcWztBIVjfBDIdCF0a54erOIZwHUUW7pxhcb7rkpI9tjTQXRjocQVHX68LAL5Wd5Xc9MIeDrbxLvTT1KeKi3Q4icrSnUvVNl3nROtrr5NZg/TKialUZZCHnEPJ6PLckv+tU5gZS7GNtsAd9Q+OUKwffU0l1c8hLn9g== 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 SJ0PR12MB8616.namprd12.prod.outlook.com (2603:10b6:a03:485::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Thu, 28 Sep 2023 15:11:36 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:36 +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 v16 14/20] net/mlx5e: TCP flow steering for nvme-tcp acceleration Date: Thu, 28 Sep 2023 15:09:48 +0000 Message-Id: <20230928150954.1684-15-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0053.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::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_|SJ0PR12MB8616:EE_ X-MS-Office365-Filtering-Correlation-Id: 71eda78d-d312-4377-1e3b-08dbc0353512 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VldNr8AVMaApOzaEgjCMfj3KdTqSjg6a6mA/7cGBJ/I/eFTaqyBUYO1aCKCCUC8GAooVoVptYL75hwUUIyCNYTKPbUpxQ9JNNlAKjR86+nJIeVKcFqVKMxJX+QhB8DL4pywkLP72f4E2oGO4NXooFpSLL89i2IFA/GC0HE/avwsIBeP6HeYLQpf0872tHYvUibyvhhlGQWdQeiTn0VESx+JaA7rQ1VMrNAb0CqgQeChpRiYvvfk3DWykSaJqs9XCXUIqZ+wuK1a4DcnPaqIOoZwVPB6sxv5RxkgnuzLlSG5GR/kMS9y+Img5oKPokO+cxFI1UXQQrUBacWdijna/kLSsRGl+4pFQ0g4Nja4ujxGQDl07K/YIzBKQU4gYRI5mqv+5Sy7pEPbVGtM/uShSWhNIfsyRgAJupY285ftzBvExqMOY9ctY/707+c3tItcbfNFFbHB91wAD8qmvJSu0KCD9WNSihHTEET1Q0Ga0wz9jEQ50ci0zhJAg0ziJd5wOtWpaUl9QACpdkClEkFGdCV9jLcV1gfCqYvWdybM53QzCdQbikzeRRXBXcgomzAL1 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)(376002)(39860400002)(346002)(136003)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(478600001)(36756003)(6506007)(6666004)(66946007)(38100700002)(86362001)(107886003)(1076003)(7416002)(316002)(83380400001)(41300700001)(6486002)(2906002)(2616005)(6512007)(66556008)(5660300002)(66476007)(4326008)(8936002)(26005)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kie9gZTg2ysa7AevkVpjheB5upuD157yw1pHwoYJj39ePWVmEVKIcJSBsuedWgi2Ck/8OLa15tWKL5MvggrYxkP0yddtH/TYfs6D+mq6n6OOC1nMa8AxEtGzmHsJ0dyAXfq6FlgzgeczlWd26jLCHiP2o9/U6876UidTco+yDA2LGhMBtp+JQgmfAYqQFl+KcP1KBBRZasdIHXpQHJzJ9bd3HMmmnrmIaW0E/a3utoJdK7vGy2scdu/tRU606kExBP49GmlaMuvyz5ZhY4DlmaW9NKJQTrufLKheEV4S6kDi0XRUIvh8CgTdHU2JDSPc217fX1Hm4yyfkECxStRBhhQi+aKH4QaxRZTy+rx5H9IUa5MBpqMDI0LiBvTjkGqbKfVEFTQSui8UJod+UAO1JxWDb6/HVzDIzIqxJWBIzM/mL2FTka9ChTE0CwI2RFgPWKyt/ADc9I9BktHvXc1w8GPbgfWTQOJvL1ohmHHTYZhRz+Fbwy+oMEqpHPToHHuz+5ZaBkMG9Pc2Wnqpb4RJgUt992a8qiEvBFvP3bpM2EnGOpQOEjNLj0TQoAE1OMQwVgOa9hEyJL3fHb16RPXewlIo7g20hfBXNyPp3/uhWY+Ginu1ukrj64EKKrsoGixnEV71mXFfGcDF1U3EaYa7RbR5FtlVfWR+l3/JnuGQ6eGE/wFtT44rLpB6BD7UyjwDUK98pxkJkSDQVyj2eMuG8w+cn+IvX/t6PeawjKNaDFibBqYDUsvF667sKbvtZsF1iGXXhHRPsEOEM9jY+6MhsTMJIACVumb/jZFsKruRJtgBxRY24QSW9MgT0qcTcJ4fmwfuk/eJdpRURLkU/1zqKfC3m6bNJMqoQRKQo1OAOg5dhIsgAiAJ5SJ3J+6ldqo5cl1kWvdqyHjTz5RkzhD6cKUX7AFRHa2Cdchxr+BPJaXLCp9uZ82Y6w/6sLu0yw1IiN1zVbL7xVe8Oc4QziL2Y7pwOcqLVCx2a58u705ptKCAf43mBxSz8Mx7ydSTFg+aSZ9PSTd7UbESC+gf77KdjCUG3uHoBkc9GTccxybGLVp6DMM7G4luIim2R1PKQDuFaquBjGNoUDBUP4OQID2g3XnbEom1Gw6Sh1QQ/3Oi49hr4Ay0iveUFfoO3853dB/aRnesqIJWxsn8fobiFqq4SMRm3QR3l++VrXUECAaMhyYkak5deT8wFaZrkZIMW1fGY/vycgV6t8mzwRB0ETnvTqBC++6HHpq3/ZJ4daZdRU0WJxrTze6rVJiKwJcxc1kFTJ1/RiXLaHuOOD59t8Z32rsd6Sx8pCniMC78tbmexW2Y9OnFX7o6fLTmgDHFKTtqzBUAzvgFzZg7FiMKJ2dl9yOK348ckKg5Qni3sDboedtzsERjDsNqrwH7qxJhL03bm9Tjyf64VnCU21iStW4z9JgxuSe5ghO+ylMzmZaJXRCQK+a6WNEPzkyLu5hithQ1mra+GEWubq2peJfZSh5qXwceI2AV0+FmaBNuKcRuVzOO3ldEE2OG20oFNuz1+a93Rw/yHhXf7gFmQCNpTuVupmq3fuHneppYbJQJjKiYnScMUny3jbIlm+kiV7aH8QMd X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71eda78d-d312-4377-1e3b-08dbc0353512 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:36.0606 (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: azjzgapucc/aatsKZVCs+zRTQZNrY4k4PPFtYogyU4aWUYf4fXg3rbj3yjCTnsEx/riKczQCImANQSUt8brIsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8616 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 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 Thu Sep 28 15:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403231 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 74DF74CFC0 for ; Thu, 28 Sep 2023 15:11:48 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2080.outbound.protection.outlook.com [40.107.244.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B65AE194 for ; Thu, 28 Sep 2023 08:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WoCr5BmOBoFcV0vrY7PpNPKdC9UKfG/IZY/xKA12qQGdC582JhnTWAtdL+MISpe7UJ5SQvVddhlT+0/j/94GkA+h6mTx/q2OEdoIkVBpDImcQj/cuJpdYZUvWs1+CiAgCPBmottLbHNo09Gn9tuIkmgrtF+SnkMmr7xsCE0M4IvMqKJcA+74gxopO1Pd6OaYq9hNF2ErwYfPQzCeJ4MhTqylfvf1oazdUgeDTUOAhsVFXDB2bkB7A6a/nZcJF398sOlz+hiVRZbOOfavZWgSgFSexfdl0t+CUhrMmIwE8q5aG31rSSDoCVfSAkJBjxfRYM3Nq9sJde4ZC70LqaThXA== 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=2FJ6swElhY/KLgASUCSQfvh1NeOvyOaxqsmIatDJKq0=; b=jkHzEgip8EDRlzEuLKf+6dF5b0M8Yp8tcLkIbxXtcOqpFGXO9q+qtAPsiWHRRo4yad246W0xqJ8j21AEdTsV6KIElWZY6nCZ916oEtDOkDNHmMtu6OrBt5bb84q97lOh+vt8soRswh/7M9XqswE/owh08xOFUUIr7r1lk4T3a9Srena5LOHb1ItnZUauBQJaEZPxQ4oGzMMxcO96Lm9R5sLMTi/C4sudsKzFzBh+PpcJE5WiqLNuqeo4+tLNL+OfE77B7TjAb1kMJGQMqCEf6eoCgqaaXpSaMighd6cXzZlZ2SZBv8b9S4/1B46itp1nXUBTxV8SSJCkUkVkaFFscw== 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=2FJ6swElhY/KLgASUCSQfvh1NeOvyOaxqsmIatDJKq0=; b=QoBn2vFEOQ8AeE1d8vew9KjdoXS9ttk92sGE1cgpZIuGWIXvpq9soKeCkvuXzbnayunXwl9vN2r95mGLbe9rP3bfbtGwcX+17Vd+TFdBASpFoxsQMKIktci5zrljxUkq2mErw1U8LXjvhZEOQQl4mldwOvOdsjEK3TUu/qkD8PLrsnaPwUH6rLaejzLUrhJb2TMkzP4FGG5HS+rr/wJF7MpBVc8bMLofbYAzozy2fCP/E18NzNr5jEmIIHrFUdiQA+9hrjWK4iqn5l1QTK4z+OOxop6K1de+ocu9Hr/5K7hWydk4jdJSQ1DRYkdrMPdEJJOazK14IVTnK8ukxs9pPw== 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 BY5PR12MB4952.namprd12.prod.outlook.com (2603:10b6:a03:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21; Thu, 28 Sep 2023 15:11:43 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:42 +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 v16 15/20] net/mlx5e: NVMEoTCP, use KLM UMRs for buffer registration Date: Thu, 28 Sep 2023 15:09:49 +0000 Message-Id: <20230928150954.1684-16-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0049.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::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_|BY5PR12MB4952:EE_ X-MS-Office365-Filtering-Correlation-Id: adb7a85e-35a8-40ad-2286-08dbc03538f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2UbW4xH/89CbEnP8BSlk9pGNrHEx46BymSXxuh7AVzWJibdxJznZnwXgp7Xvn4ifiZi/OnWx5yP/n+D/rMFrrMWHv1a/TxlZIo5froZIGqNU/aoJHtzlaQi69T2RaHPJzBt7qMmNP7fbyR062uu5N8UVY1Xnl9Zqv0PMEPaTyHwHK3H2rbWf78ks1ikpRzW8tWyXpvlAIjx71wnkHAsWggCRWly2gfo5/d1gnMgLqvLRi215T+qc16Dv0IKJEIbq9Mlvgwik30tuwNP8UHI29KdRFj1bgP3qfSPmgYS32wKe1XkJoz6LQTg/Ny64+Q74UAP+N4S9ma37XYMWWGaSBgBRfEiaPab2FtP5yxSiZjyP6PP1IX1rSVoMV2KJ/+lTMS6P5WWSdbqHs/OZG0lN4qwevMNZSSnM0/UuY7jPH7XNEYiU6+RxV8YTSiKj8GlsrMnP3MBMUKPkBp4dg6MExYAZbzrG4EE0TT8uSpwf2sT9uwwxGpEZ0HY5aIJ7entpAbMeMyX24Wg3CKC3LjPHAWgLCWfBMWVoaC8FCuybU5IrbkXEsKgokJAogDFWAlRf 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)(346002)(136003)(396003)(366004)(376002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(316002)(66476007)(66946007)(66556008)(41300700001)(478600001)(7416002)(86362001)(38100700002)(2906002)(36756003)(8936002)(5660300002)(8676002)(107886003)(26005)(83380400001)(4326008)(2616005)(1076003)(6486002)(6506007)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 04zQIjtHc3CeXJRCvKaB9Qt4QjmwIe9mSAWoeHkrd13tI44T7AlENHqDsz92lLgMk0aO7p/N24DcB2wjcpnKAm7juwOtd4CijcyxrUG/2Ej21dkC75StPb2vaMhzIkiejEN25PKiOpYIHJEzX8PhT/qrO/eGw6LoOZe/2Y5XPPYZVTcj4u11Wv3FVIu4A2K+5c8oigBdE4rxcEv5Rqd8gXVG7O+nuPWys5HMLPst+/E0vaXiQsx0LF6+u9av3T/1lmizy7in6cIFnoC4ZXcDT/fiiN/krKDZpVD0zNVz2hFTFlskU1wF8rEQCcNGfexU1PrYctUMR5nMRFrAqveYtlR/tSPzHoCRasfuETWfOBMOOr6iXqXlqK+CYiDkEGOh28z+mbEqN4Rt4LUxmhwdOvNUJ7Lj7RNH5gmeVGjyPYnK8kIs00w9/WPLjb9TGFWGzThb38W6rRLdTI0lXxN32s/T72HfUV+C+skTT70t04TkpLh4Rtrd5uVjFsUnxYJcYH23MWoNFmVOwhXHtb4An1kPwedXWDxFCSdF2+eJSDaidx6VagPf8LiyHqrdgVizZeqUf6R7L2EIJU5OFKsdYxfXCs+OTYU2JCzCNx8e0kc6Wv2p70Dsn+0lBvrrhQTzn+uffXgH5AUe6brYCit96vdytqdtfXkpZYCstowLsMkyQklCzARibk/si4CZ8ZRn/StCDULHkRaLW0Cs/ZqbssfWZGFy+W0F0QFPcryYABA6IJbGpCODoOrHnJHcyjFv25K2YrRddbOA0aBi9DB8stn7lYAYjPtr15EWk9g863EDRppm13hDSHbtlPo6cHXLuFQ3uPmt2XYb/Owl6wkXGdJgEVaj5YODO7f2/jwOEXRa4F2bOO5a7clWXA+wmGjitbEcFkV34trqU59e18idZ2tgUspWoktBR5vZZqiHYMcaSQyo3lOErhvBBL1pheUhl7MPfh2CTKeRj9EDRyn5USD/Q/VsUarKZQhM1Htqnw0Y8aid/mJQxTs3bjupO9undCwRNA4LCNARZO1RRif4bp5UNw5+bFOB1nm69Q1fH8E+P4Z2NYgnznhYkeOHOznHJiO6eHzUs1ffEUQrVRX2+8hVzh2JHa9C65ra2q8ih38tpaYzL+KhpFcrdK1JSWlptlMzW4jZfReeU2Gw7DgRsFZjVGSTo0iZNo1g0zSAdQju6qCpxEOtbY/XFfpMmOXkVXiEPO1Pptn1GLBZ9pc58dtZfaZy007C1TfoSlk843uDEdhak0Jrl75cj7cuHICtqiPf6yBynWTxxio8dOJB42Rg+wDdsBVg8lF82eFtxrOuhKuLImthkIIEblRUfKR3TNAcOQGsJcuOvrVKz6xgibHWy+vICxmkeJ2zTqeZjRCQQBijFzgBNKKvhRoLYjNNanshu2ZA+PsDycfNOm3Icvbh38F9rqUQNItdV+xQ+puatfdXscgyJPVpmtiy+kCeXsKMdj6jwbZg4vGzKTP5euKiXxjswFocH2QyOYIPdpRx1RgceTefiZ+kloCF4upzcGnCf3xyc96gP9tMHcLmOapp8nvTeFG+ET9OyeLyQ84M6+A5+ievVmR6td9tCjHW X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: adb7a85e-35a8-40ad-2286-08dbc03538f4 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:42.6480 (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: tsheTDr8AuJJBtzp3w2aYJU8mRU17nNYB7nksBBxCoXsL9cha3o2VuwxeR50kCcElVsFGhDTGWiapLJgZheymQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4952 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 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. Nothing needs to be done on memory registration completion and this notification is expensive so we add a wrapper to be able to ring the doorbell without generating any. 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 | 16 ++- .../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, 165 insertions(+), 3 deletions(-) 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 cdd7fbf218ae..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 */ @@ -256,10 +259,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 +276,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; 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 Thu Sep 28 15:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403232 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 9676B2E652 for ; Thu, 28 Sep 2023 15:11:56 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2077.outbound.protection.outlook.com [40.107.244.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585ECF9 for ; Thu, 28 Sep 2023 08:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YojOVsy1r/cQmVkMeSdRzcKF9Jmb5oK1hv4uK3ancrV/GORm3VGDMJ7iqRlNx+fRpVtyzfBDUGRmuT3zFHpR/SbVbru+buKwN58saxIVuy4AI/hZmtkdfFNT4NYy/HSrtKPQdOc0+Rr0L8KiM9LO/som9JKrlnt5hY1+sb1GmwQxR+LzfDAKACrjriCjNyhq2UY01FdslTR7ehfwD2qeQX201otJ84aKjNDvS1RvSxTl865S5oWljB9aWKcKhRSS7EtHGaoQuYmNwF6GaBNuVHfOIjAm69RnNoZMx0Ska8+DVE2cPPSLVqy5h8Xfq+yghhi5bnG49yZ7ynD5HxKPpg== 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=/2/m2jadlRmV9/q1zK7waFgToLCtJ4I6AMxThX4/HJc=; b=fKF2gHWSERfk0PZd76HlEEd3RVQhVDhKz2oI/1bWCaVsbVC9SMGnBPpz9HJtFaTJkKDbgv+3Lan4tyfqUpsPkIRID057xhNoRhfGCIFg8MjFsZNq4C4TDawQilubFIO/m2Ma/RpgYstKROMcUN/xyrkzPYaLxS0gYotXyYHvM/a8iZW2L38DDrKh2O7MHYGYaLOsAIdOF0VcCBRc0MQ3Sbk7EMZsN/GcHknN9tel2hm3Clc6lVj3aLIl6z2pbX7DF6XiVrCM2Ldr4E0vfYKCSpFD3cqYS6QtTugsRbfmwR4/sKbdzn2LeAuqAgAz0FFbrrVw3laDto9ZzI3qk47d9Q== 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=/2/m2jadlRmV9/q1zK7waFgToLCtJ4I6AMxThX4/HJc=; b=ZFXKBIbZRDdLxhKyW0/htKMpSeAEdMzuyUPwrvrEBkF2hd9gwdz6cc0pxgKhqGyBHTLAY9vDoEfcekATJVX3maxeJnATye2Ch+j4UgY5ZFE+lMC901puO/WVmL8U+nWdh98K8j6TdamoZla10UbkXesDJatSA+BHm9qraNw2mNUVQcpRX6OLR16USUI8gBT/WUWMFZHtyNoZpzzQ/neofFOmFHV9NLNGK/1o2kaJX1xD1M6Fu7jxN3dxTv1QMLIwS0ncOjOKwedQih9E5HD68z0d9SoNOxYnQSSFDdPpV5OJEMybGr+UB6YfT7fT9b8yBJCf1LWveW5LQztUIaL3+w== 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 BY5PR12MB4952.namprd12.prod.outlook.com (2603:10b6:a03:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21; Thu, 28 Sep 2023 15:11:49 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:49 +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 v16 16/20] net/mlx5e: NVMEoTCP, queue init/teardown Date: Thu, 28 Sep 2023 15:09:50 +0000 Message-Id: <20230928150954.1684-17-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0114.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::16) 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_|BY5PR12MB4952:EE_ X-MS-Office365-Filtering-Correlation-Id: 30274fe1-3690-45c6-8c01-08dbc0353cb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3tNQjFtYIH5BzA2JYNuXtfw0n/ZLWkg82ZXrF8mNWxBEDNjGWIae2gT8803/PeHLnNB0LKPHeN/BhJXgoK/MUXiHb5rFKZ4E6ksVJ0seasNLDMBNDSzkayNykoHaqiOD9bWV2CpIhcmHfIXLec8B1kF2neYhwT0FYMjw7JvBR+3o0qOCnzZTfAW3EgKpyMSXyXsoLRMP8nHFNsCEyniBs8/AGYaudhz0NwRbb4RboGPPnUnXku8m4Vb4/KTR8/FwhYW8e6tHO/GUJFvgu1FtMfU1YyZIsZGfCLLHU1xmq43EEk11gA5bTYFvccMBfZV4D1zs+jLA31CS3TirZkegUmTLBG4SdB/dAcq8Ri26sz5wsRtIAQvxXW5VTAMj3RvkIEtn+YMtqr7c4O56LKaJCgh+t3JUewMmnxIrd38qbEKSI+2ERN7XAfc5X9tdLJicdaw3r1yRVW3OYBirhv04KG2D1a+oas8Srat1Q38JdsGP2mHn0Rc8PmYryZBzjpAWlPvB69LwOiq4Kh+BdrYz5AlN38lUYEwRx9b4+egGiLsTbb5LBwMBCc8ps6RTw3dDVS5tGwAaZ5yMDIC/rNspCaC21qVZoOKrIMyLWACsgdLuwMgvBe/FEI3pboJ3Aq7p 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)(346002)(136003)(396003)(366004)(376002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(316002)(66476007)(66946007)(66556008)(66899024)(41300700001)(478600001)(6666004)(7416002)(86362001)(38100700002)(2906002)(30864003)(36756003)(8936002)(5660300002)(8676002)(107886003)(26005)(83380400001)(4326008)(2616005)(1076003)(6486002)(6506007)(6512007)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rdp10Pl/Jpbt1243KOzOK1vyKYiEE89nfJbKysuJklLEwYzBFfpZ3VhoeZ8aRgcz0E43RRB4tGn8pdwlcWmxAziIRJWeCuAb7JlTundCZV/+OjZ3tp8gkKWKXBSYk3zPXnPgXKtUQ9KXisNOW4rCfNOzHjGtUy2V5+ERCruWM2NgFqkNYfzCwJZPCEOf25CN0e1HOQE/SElj8XEVZ6qBoLrP8IaHDfkHB4Wi5ZlAApQ/3Cn3nc8w6HgGtAZPXIe1iVAKQImrEzINkdlovGOougETpbB2sRcSkkc41vTXc5k3/raMP2EIUdDClMGSAourz9bnxr+D4lCoo23HRnRl2wg1m3SkC1mY2nyBkR0dtTttYg8p/YTGwOyRzanTmUxXFepPH8Q2zfaaQI5nANP9bFYHRqsHnsxBMtwx0vYORsdZdYLYAlTY5lSiD7jY0/cUbtI3Iufewy0BA7T65RznPBPhBAtfSAVn8aNRKkKE9dap5v9r9vc9iwqujqvb9DwVoe+XmLek7ewFDvgrSdiLxOiZIsQbmuJvxeqkmHzn2awAbzSmyw/cTJW8e7HywpmS/4lzfAwMMrNICW1X3k/io5laGfC4S7MOTjhWc+lvBcbX4b1IFmpUAZ6lt+7Cxn3GPX8k47yO8h42k11JFSGv1CYXuH/1e2+nw4XzcppbtyUXVCTLsNkTsMOlCc2qpvXWT3uwJ2PTQjRkK644R7U1uPTwFs/n07d0mnB9DqCsImJ7NlVj+34ItxjoM6/Nk4FipazxjBnlAgq9E5F3XpJ0YmkCmXqf3Zt/HcRB87VVB58VopZ52NUPMJkJ7yWYhSmvBBmd+7eBBlo/22yZUsIy9q8hy+zHUFK6fp5LIYx5Fja7XOV1xTr+IubZmHMqBN8lItSWTAhZuMDQtYOGbLDKQEc06+2PiZyQx4tJ+Kih0DNslAV7mcw/tNl8pGkkPv5lgTCQrlL1QOXpJGbJ/XETGuiHFXsacHH1JK+32chEwNHgDIjA86DASQppzZM3s+++6jdX7LcnOf7mcv63LLrPnIt86K5E2+MkDEOSOdX/1DwPqICRFUMsx3Xqi9W+8E7FgXzvTkTNMYgybeT/0LF5s4EG16sSZ0RWRhqR9CoID0jced50kEQhAHRU6P5FubQYimoA1x6w3mz1qCQb1p0Rbo3RBqikT4/d0Y60GotB/D5X3jtyBjE8c8LtQWkTu86BKMG8zUC6MGjb3iV8wHQiIE1l6NsZ2F/CQ1RZifUNvlrGKuy8ra5EcRKGORXmzY4RTPSR8eZFBqYwqX//8Ldo1mYSokhZPBopsqTDxnf9i6zYKd/jaYMs7fgngcoo5bTEFA/dh4vZVDQZSkXDbX8U2HMC9nl2zDixRLEHXsOysLMG17W1S8fyTCqN2XyzhDXhWb05x8pYwhU8o4vYGoKOerDmKbod6FgGDR5XUYuBgpRO9v4X/N7qSY87/0EJ2Ngsv6Mw45QurlC+i4qsDYDwaeYnZlOv6wl4gTmBkLit09/cvcOKqBmS9+UA8Evo9XkoP+3c9Q9on83yCD486WHPdg7pO/JTO9x4+5/p//NexyWMpkDtqSry9yMuaJfcjDp2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30274fe1-3690-45c6-8c01-08dbc0353cb9 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:49.1347 (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: 8UT44FBQZKhG3KXpWZd/VDqEl/fyxufRw++hNHd3p/odio28i/uTzB8FhELl3hFZ/NlZ9vicZ+4E32M7MLxLEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4952 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 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 | 566 +++++++++++++++++- .../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, 682 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 770f0cf0414c..f0e4a2744a07 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..f419ec6ae3aa 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,328 @@ 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 ulp_ddp_config *config, + struct net_device *netdev) +{ + struct nvme_tcp_ddp_config *nvme_config = &config->nvmeotcp; + u8 log_queue_size = order_base_2(nvme_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 (nvme_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 ulp_ddp_config *config) { + struct nvme_tcp_ddp_config *nvme_config = &config->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 (config->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 = !!(nvme_config->dgst & NVME_TCP_DATA_DIGEST_ENABLE); + queue->ulp_ddp_ctx.type = ULP_DDP_NVME; + queue->sk = sk; + queue->id = queue_id; + queue->dgst = nvme_config->dgst; + queue->pda = nvme_config->cpda; + queue->channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, + config->io_cpu); + queue->size = nvme_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 +700,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 +721,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 Thu Sep 28 15:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403233 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 5E31E4CFC7 for ; Thu, 28 Sep 2023 15:11:59 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2050.outbound.protection.outlook.com [40.107.212.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FCF71A8 for ; Thu, 28 Sep 2023 08:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CDJ6ppMIL96WF9TUqzlF0r5UFoBfjKuj6sDwPYwPc3hqPsgHVZXkBuNwXh3mAN9/ibTAVpkr1VOGL+3udDvFOBDoGyp7Kie0DM3Sk+/V3XF0kCRxlqw6kGmxPzm/fefn22AXNG7pThEyH0XOZj3833NHtLPfoHJFdQ+eC6HQekdr7TaPMJzta/gG0/PLv/Jlh0s3PuTeR7n2dC7klaERHD9j+FY8FfXbKv8xrCVg1Wg6SRi05UhTlYl7kiQ9lScUwSA3e4SarZ4fGh7P+z5uvQ2V5h+k6q3iHu23b15/Nd/Lh7wQQu90PRAm3xp8xapm3rhIhsg/a7l28tA70bsQ1Q== 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=u7Q8CxWOyVaJjWFz5HSpLU+DiSVUzXdmyFq5NQ8Lios=; b=i9szcnftn9rrmQQB3R985zzwDy+oeEQojLS3+5M8M3kKeJudVTX+jdu5ewAo2YyyS1RQL/3tD6ccRCEkl2CA3tmcPqSdA9/Aqe5viLcLsamd7xg7rplPjykWaai4rL9zpCWbN9dWBRthT2jdk0aOCkKXQUzW1d13BpUJPr2SUO49J2aImtyRmpHcicdPIRfq+nq5s2QOL6Jw7GCudWD3YWGk16T+WNXaooKIpUApzRj8wr4lGTjZhvHcSi2cu0k2d7NpN5ClTvrkjT/5Fdwy6fhEiPiWMK5GppsNRA3/ZX2JVAU14MhmTaZqn6Kq4MA9axs2V3Kk+aYfkou6NF1/EA== 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=u7Q8CxWOyVaJjWFz5HSpLU+DiSVUzXdmyFq5NQ8Lios=; b=dUjGG54Bd92lIRhCU89U0otfbIFRa74W6yz5mGgKdjigbkAgtcyovut/Hj/PITC4iVv/br6nMWzA+N5f61I6Ki9oiLFJ7tUvIaEJV96XciuxGnp6GdJu78Jf+fh5iyj1JzEocx2wJ7IZcWR8PmoOUYVx132ceQop9heqQfhdPzCWmgktyH3Y0nfsXBtLP7UhQ2qRXGZCun7uhr4z5ZpDzV+xyBosiKy7Py6dmghufGAcM781Q9JNGwkEyFGGxqAOQ6C9Z8nOtiIS8ldQOaqEZ+0uegRQJsO765WeoVfy2p7GQEs0SXFoKUb30fG30BN22qahDOCHobL04c+03WDnAw== 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 SJ2PR12MB9162.namprd12.prod.outlook.com (2603:10b6:a03:555::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.32; Thu, 28 Sep 2023 15:11:55 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:11:54 +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 v16 17/20] net/mlx5e: NVMEoTCP, ddp setup and resync Date: Thu, 28 Sep 2023 15:09:51 +0000 Message-Id: <20230928150954.1684-18-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::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_|SJ2PR12MB9162:EE_ X-MS-Office365-Filtering-Correlation-Id: f721feb7-5778-4cb6-39cd-08dbc035401d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7/MMjZmL8i448bHs37RFWiHM6ydPED5Q8Ro6wlfanj+/bLkh3MAH9pF7WCNLGVN7txi9dxyEPfOZpI8QLwdWKZk4fgwDPX5QeY6Z/ynyZdQ7137+Pcp1gzYpxOdnHoP6Jp4L8/plZXBsX0bPAtzrZgVE6AYkXG2XvX62AcE3kZJF5KM2fiJOtYF5e3ukinmX/csiXVtc97/mtCrIRhPvSnfbbMlV95am9cSwKlv0HPrZt5Pgr6yMlQYrzdRvNAP4554cD34rsiudV6ugHNtAS0R8rrM+syeA2fUkS7DaKCfhUEEd4jUu8zdMmlYcWyxgnXZwIETiP0RCFRTHDhI2kZ1FLmvnEhgFU6IRH+G9VvCVj9TjYs/GCLWEqHzlDul8quHliOjexlJwagkW217g/xI53mVL78/LM2ebgmcD6jZMgbl2CqtmOelLsXJkZO3uYuFJeXIsdf3lk5EwDLDr9ZPt9w4HVaxIbH8VRxVY1kufNtur0x1eI1G5Gmup9BHqLgFchlHy8Gpgz8zJvk/X/H2MJHzxcSfO/imVZbzonWH0r43HwNK2gEm7mcQLDaVg 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(4326008)(7416002)(1076003)(66556008)(66476007)(66946007)(26005)(8676002)(5660300002)(8936002)(41300700001)(2906002)(316002)(6512007)(478600001)(6666004)(38100700002)(36756003)(6486002)(6506007)(2616005)(83380400001)(107886003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W20IKk2NKBeI4xAd+9PSig8Qogze3EQfl0M6hSx+NsqfLwffeNM8UYuJKLoLLYxtKGlmaB+09L1Guyx+nFR57YVEXkh10RT97EfSPSytQtsKdq4kzKH7RuBT9g2IiLcmCkWhGXLNwCyhNqakC3mjAh3o+Y6MqdcJeo+0Ofms+8MSxzd/mCNmEsMgua+EnKkXDjRe0W+N+Tnxa27DbQVGhpA5DRW/btjNnhB3O0GbTTE1+2cNB93BGekjiyYBjRG0P/b3XRmEViBcFv8VWLrkWNctR7gHFpyxeaGxC+R03g59XzewpTKpT2s/sdnIma77fGSQ4XepzrzgkTdxRSU1yuyJaiH2cKu006nq1bQnrSF3SUVK5LId6cDk/LZz/+F4QwG6OGlHMhHgLetHalXTgkbfvHY2cL2o//TK5VT/veZ+iu+68iYN90fDWQHVK9JGTjwhNdroM197ZQqk9YQFOy2sDOSBFoDg7Dt3XQl9Rm9/s7rU4T7N6VDCTfoe+Kyc+cUn/shnruJB7ApTMW4wn3+oAn4cg9hVJ2fqzzNaQ4JDiAFtuTjk7962MIJ1mBWDODwcmn18VRfEAlh88Zt3mdrzhd4dxwGg0vCZb24c8HLhi57/YFIoQ/zS/ZU5wly3qRgSZA5lEr/qIXIU6wRrDI3Sgpeh/sTNh+k1GucyW4XjF2kj5s+cbHpORMSOLWNKbToKbyGPaXrJ6UHjw3VrwqB4O3dEDjoBORBrHjBZoWhghi/otLlzcIHD//RTwu1xpIp2qvJMWMwsB33+Fa7abi/1fyucEHORqdmPIG5Igmfxjib9g+167UQZcvB4VAk6cLZY+dhBo/3GzLKrXv0zzSj1D/g8xCfpgg3mw6Ce4ZIO4E3ebIsgU9RoJTJ1lZcGq5JcFCufYlJ5O+44Ki7Lpxy0JOZW8wRrm91GxOdp3u4aD8GzRBGNXtNfTrGrRIOvlmxepnA5cvxrLpIut0ZXbNciI+7A2SHtYDS5YcHzuKUxbfgydpR57T+TNHL/yAdHmgV5yyYDFbcOVQxdJAFPF8nwaE8DMX9F6oV8BdQKN5wHyAwE1CJYh6NjIvQ+fHp6JLP8kIeC34MahBEqmrYnXUjgeYcLmO3Ohv2xLHnZlM7g5bj+vQg6UDziyLJbrJB/A7zfvChm0AEffMyD9DjEPPLQQg6Eem4FqTCoEvCIQUYj2fhV54KywZZR6e2Ag3adDjkZcvaJWLCTrNrN1svEqkRnEYDUMKhXeWCzKRV5rdWCjt04Q8FhLpNK/jsIsQ4kB16RBUFA8XWu4mylL2AjqR2PoQPOWMSofE0OGERtTEzysKfJo3aimJ+/9MlyJV/IGtHVoSr2BmzLC6jqJmsMB80SgM90Iy+0a40OlKz+kjiNn3ElY6jN3QzR8bEcmStIhD1C5x17+4q+ROXCc/8SzI3utZYJ9jEUU4jgwtYsTpUdnjlscHs+KRlaIiQ0qjpMRK7ZyomTeFGlPeI9FkfSUSzJnEzLapQ9KbH3OTXlYh8XKkTcFYJ74r8+41gt9j2YFxX6vVEoGUjvlzSY/bke4PlPFnb/sEp04NIEi6TG87vgBKtJvq8qWZy7KKChD69M X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f721feb7-5778-4cb6-39cd-08dbc035401d X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:11:54.7379 (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: hmRzpGFRhoTVX22KeWKdIlVf19DzcYbu0l91lSeQuOJB1xFQaobSrmJ0cDqsZH+qszvbvziyZM4yn34Jjtaa6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9162 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 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 f419ec6ae3aa..ea7e4cc1bbed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -684,19 +684,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; } @@ -719,6 +856,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 Thu Sep 28 15:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403234 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 174C24C87C for ; Thu, 28 Sep 2023 15:12:08 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2057.outbound.protection.outlook.com [40.107.102.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4525194 for ; Thu, 28 Sep 2023 08:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jtxQjYCQ3+8xHmk+0woqBP18DP64gkpUfaWzIVBJoSS18Punjf0xnKWSz+p3WzrI3jr4X7iWVh5w+SqCVgksj5B+aWR5QR4QcRjMm/lEKmgYTPJ6XXHmDOLBkrgK65ZLI/jd97InLFm8OSQHOMiUjE81BjW0lpb7tXrB29qNgNQnCL3AUXra/DU0LTzO3kTt0mvvEHjg9xUc5W+yPvrkbJGECymhwkWFW3el4RfMD9Ob2VrcZvamDLoDkEJqDcoSnbKWAB4FmwwlEripWtEgYTxF96zGfVdfshhrQ5XEe7OSwexwZe9L7+NWa8acQJ6sqFie9ImH7iuzt8t3SBUp3A== 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=qcnZg2gtJsthAnjTyRQ0LeRc9xbcJ7vnvj6m+/1hfqM=; b=Y2KwOtuUIEztHgfwFiY1imZbEjk5EoX0HTLUvMBmZV5AYdKGlTDYZEdhEERmvXWXAdQVhNmOdMoHtKJh08A8JIQP5zpjrs+qsTOmvMqirr1c2y5zczJb6o9YwTMfarXOMMRkk44DfpLNRRLv9TpKHSYbakG4Gv5jB2ZOWL4OhNl0R8HADLNedxiersycWoXqSJQHQz/kFbLbREpGZb9O3rfiCVQ1iJU3l9ZWNruq+DOSvmC1cCUO5ihK9n1IZ8hCYvYvJPB88lsseWklgdD078Qe75UiUf5O/GQqpO39FyOnKjn4q1e/Z0ZpgJXwQkgosbYdYpIkDWUdONrrtSqseg== 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=qcnZg2gtJsthAnjTyRQ0LeRc9xbcJ7vnvj6m+/1hfqM=; b=dZZEEI3KzC8tAatJQ341IW8J+k+8PRDxDfWorn5wK4edaugX1xJN6pximS/4LGSrTk48oixCXWuKwoo517A4WEXJ6qSo1+hAYTbu1p9fX6retgMzPj6Ms1lrr5Tn8Mx1AxxRVdNRGheK/Zp7mcUAChnXAlrA3BgCIvwX2sXGNGO7IRYswqtFRT+pY4cNz3vwscZYIdIK5BhmHiBQlHvX6pRlQSFbB1OUM4UA7nuyWhwHiuQx4Hn0RYyq2OWr5DralFInrdPC5ynKLRkpLY//o+osvAM7X8h8HKbr2VdC4uuwDbFPWwhk2vtioI7JOeLWbUC4pQqzcqjZgcMzRImuiw== 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 SJ2PR12MB9162.namprd12.prod.outlook.com (2603:10b6:a03:555::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.32; Thu, 28 Sep 2023 15:12:01 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:12:01 +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 v16 18/20] net/mlx5e: NVMEoTCP, async ddp invalidation Date: Thu, 28 Sep 2023 15:09:52 +0000 Message-Id: <20230928150954.1684-19-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR2P281CA0116.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9d::9) 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_|SJ2PR12MB9162:EE_ X-MS-Office365-Filtering-Correlation-Id: f7a5ab84-0ffb-4fc4-8b83-08dbc035440d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kFzTAQalHbaxyszGzfQbwdMJhOBHJZBsBnvselJ0hkb1CkEz5AM1ryVgcqS+yIKr+UyJTCZRwRMKd4p7gdslRhqX/VgFJXefuOkjirX2xETLEC7e5twu8V20IIRIiKNWphFtqZi/AwZM4nd6Guxg73DfOKg2aUZI+qdMJzmXusO2kDaVqwz+UO/NkqzOwcYf+K4guiFbnIocLo8NETDRGuRMNEAdoEnAD0PeojRkCl8rGoJz6JxDdJbzG6/mTLarXh8VVIj6fjwOl/k3IWd/YV4SFuqTodXEc3CQLp0DcByM4UwN25o6J3pad9gvI/P5Zga4hfFwp2LPAcZ6SdwcpA4k4LhgBWj5fvqdHS3IxrRSgqVJrm7nWwmcYWUHLiaiWlTTwp11XXHjC4i1sDLdPcDgencpfofTxRziy6GSDNJ/Fv0TmnMOYEWWvc5PsU6zt9b4IZFe/OJ/HB3TchXbZTXeFmcJQKqmrAiDmXNgwXEYgv4Cymfm+UIK+uNj4RBZNe11E8Xr/slW6BlopElcJ65zDlNZ+AwZcI83CQbAFe+/II3DEpNOUbVBAa3mtxvU 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(4326008)(7416002)(1076003)(66556008)(66476007)(66946007)(26005)(8676002)(5660300002)(8936002)(41300700001)(2906002)(316002)(6512007)(478600001)(6666004)(38100700002)(36756003)(6486002)(6506007)(2616005)(83380400001)(107886003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rFI6jbqDvJTfo/KJJX4aEmDicOtuPQW+Dp8XytIcI0lDck7CMLuQmqna3dA+xPSXDiEepHj5RKlgQ939yFGKsyC8phzaGKoNzKELSg4CKagpC4LYOICDOW6OV7mkQZc+HUg2LWThiZVN0ewQpomyIPgWDZweT3zO3eb4VQ4OZpEvFFHJkY6GmcF4E4zkmFLg9tt9v5lVHjIK5SYNi4p2hPUTuYWcP+4VZLv2/puXheeoR9qp1cDYgSJIyoGqSzOZdIayAbxQkLzt2r0AS9NBb+czL37865k70aUWX51stu+ZOdFnANtaofWcJxBCYRTOmxHBkhHZFzJcDavQafmUx+5UzjcJtkRjcy4NxREqQdDA4idxovLF6xDv4o1vdWoDMYWLSFjgJj0bkKGEc6/KUIy0qmlJLGtzctfNz5StZfCHbA9G2hwmRaCjrq2DVWnG0uEo2KvIqIF91XkgfPIx+543ds6YVBVPkwfN6kntkjBBDHXF3XENlREnbd08y5qGRnGka9+XzeS9/LR5bnDSRvLOyEDO8TPVSxyjMbvR+RTzM7SFSxV0gC4k7e5QYSc5gpOfHHdFBfS7jtptpe/sNMQ8Bdv92zNY5k5fnbHaLYmfWufQD8A7WEURNhzCF/Cv6b7mRHPp9/ZZ53xz1qUZ+VgVZ/Pb+4iI1ez97wyZTuPKaE34jnDqkeJFOtkfGES6YjLgJS9p0W3fyc6PZm6i8NVwcIJis5AhAMfKcqaxPtmuJ+GjlrkUdZrrzAh95xNaiqgwG+uyH0Cf1BleZ9WP9wWh4en3QB2UOJrQRpK3n/QRvqdIkH2mRIv67B3jD7fxrV7MmpB/y4++/noeTfFsb72BsEGjNoctPCILVID6Qo8W8rd0Tzvt6GZAxnBDgpjgbWpqDCWpcAFLIrrsTF3kV3dHjNodTyVKJhokl08Bt3NG6dWTcFLqyfJmTg8E9ezjsoRyfjj+pDU+Y7kA19DXG2Vs4vfQePi5inkO/ReQw9Z8BUgDT0GfPn3CVYs9POTTPLZF3Zzr9r5rjagUP6V5QG6GrK4x7lrcbK5eXaSap2gTQDz/SVospwJXvzZRwmeBt61F93wsNwL2Oi4qxIyQnPp7pEPxsSJZsxrPjDRdp2cYHBkjypL7OoltcGRPukeopWTsfDJE4x2yPYcpbxmN5URXzyDJ004nFSh6FdfjGKl0XFdRGbo76y1OoMCK6Pc53CgVI6rUee+KDLjtZPHbLhXPoP66PoVBgTLE46m0B/wJ9eKkGK0KNh//9eE99xJq8b3fZ1Z6QhVuAktXbv+4flLLQE5a3vAhUJVd56P4luKfG8TcZt3HKavbCndyH/+h/VLmOX5uuJ+FUUtbFwklpyi/dvNIwlbtNNiZ1MAAXBf6oemqOam9BUGM/u8Re+EQNCcREDdseTcA/vyR6mqUueB0WF4xwNTIIMeBvyldimuhDodpSr2OAfuVd1Tg0J1swvBEYI7D7XmSKCh6G2YJU1gcU47if257gj3zT3RRF95vUwr2pHEchi77p3TWkHYUwD5jMvDgHxZJabdvrO3kENdtPQ36LzhYyedwxTKF0Pc7MfYtupgGELeKFrJfkJxE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7a5ab84-0ffb-4fc4-8b83-08dbc035440d X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:12:01.3197 (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: Gw1DaodyPNF3i3aazOKXUVVeBwkQeQAG72xq4F4lmheb97686S9ESlRyTmBBA5cbU0fwZT1+r9uyfYBWKNvg7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9162 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 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 ea7e4cc1bbed..fb38d1dee03f 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); @@ -844,12 +859,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 Thu Sep 28 15:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403235 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 C97844C87C for ; Thu, 28 Sep 2023 15:12:15 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2079.outbound.protection.outlook.com [40.107.102.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8693DF9 for ; Thu, 28 Sep 2023 08:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mfFSFK4i5k/sUuI/D+KaRGqNn/if4HgjEYfiF5VETeil8fB6JZXN8/o1VjRUe2BSAcIEyWH0Y5coBGy7y1SD8ES3ooVhQ+CVisUUoFERPFeeB2tVNBVMBxo3m3m0xgDan9ULI+BhxlbakqYHkCDZCiNWuSjLdEMM61mlBDHg/lDNAplEaZ6BdnJBFPfCBLuHpP5SalE2JXKTNZDx3hDIVdGufbBuHP0G7HUdt3LdwErzAcXPKiuVNSznCfu7iAGCnJVl9GTA/5HKLac5ZcLEgP8ltf8o5sMqymjEoefz12nLNBpElOAoEpLwsh7LfpjBc8RgtXigiOr7D9rmmwE/tg== 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=2lKYR6sxRtp8WrEh1hQ+26pN3lea6RQuJsbnzcHa/Qg=; b=aC75lltYg7/XiC0WszSYYwWR8KcAWFpRMVccfJfNaQU7tkmIUzy/rJqC1PX2jagXpUT8LCeyS7Shn5P0rR6FALypxx/UUYfOkWImqOEOEv7EIeUwMnq3+YSPJ3w+mu6tkKc5GruzmmQSkPnGijV1/FFqD1dCfh7qe4G9Q5T+mu5BPLF+mc2Z0+7Q6+jnhoeHXPmOQJxw+rnFOw4JlAA9j0jop1o7ckK4Qx8kqolfYHytD0dox6bD03WB437yTxIIQXNSFYAkZNerrIMW9mEBgYAvkB7vNPD5/prHt8b1gQlFxnwhzRpEJrKZiFPHMN6bGGBf5Lfit/wDtsOxu4cudw== 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=2lKYR6sxRtp8WrEh1hQ+26pN3lea6RQuJsbnzcHa/Qg=; b=AGFkjMUhCzX14IFmDjm0Gy4BStsRsTK4l2sfQHDlMCXceqaUT3Ky/3pkbQX/h0SHZa2hxjbh5sOJHyZIhuEj7XbUCVxNHe10aVaYMSn1W2ieOa4rfZnj2XCT8HWK/QEO3T+oq0SwqiuSVCsfYOeD9L1QDBy+jNU0a250GOMqobB/9mjoEpoDQPUzkzccY2pdmmL4+PK8FXUSOYAFRwP2q8AQvK/4eNltC4oC57/IaMQJfzNm7aUph24DbPXqYtLBE4Mdx62YUmVPm8XsIqYZ5B8LO45S8rLxYlP6ru4oNaKmwqmVzHzSg8HcD3/NE9IHBbNd/AWSfESZ2LuL2bBXiA== 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 SJ2PR12MB9162.namprd12.prod.outlook.com (2603:10b6:a03:555::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.32; Thu, 28 Sep 2023 15:12:09 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:12: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 v16 19/20] net/mlx5e: NVMEoTCP, data-path for DDP+DDGST offload Date: Thu, 28 Sep 2023 15:09:53 +0000 Message-Id: <20230928150954.1684-20-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0045.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::16) 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_|SJ2PR12MB9162:EE_ X-MS-Office365-Filtering-Correlation-Id: 48cb04aa-c1fc-4311-071f-08dbc03548b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qb6gqX1ty72xrnCwwWSkKuFvu3FFgWZjNymZJsrK67WesZJLRNY921TOm+u7PVdjaC2I5/fVhjAKaja7zRRDCGy/KVGzYpB9tzHZpHGsAubaqsJ4nSEQCNOADtKa58aFrMc5TTYuXkjWSj+76MmfNkXhVyZ9IzoFQ9A0kCG2BQBCCZw9S4LqHOdfj9VwlJcQ8966r0MoOYabvlDwVeMUecnbb78RSWTlGSC9jbMACFitQ/e15PbDDIAw8PRZXbP+lhCfMuVwuNuVfnXiGULlgAK0xT0UBkgekVXGJapttZHOA67oI0aG59z983mzFXfkT2PWKhXxfj7t2jBNC1EQBvVdbr/uagHamGatnA7mPfu4cbDnW/72GPmUfGa34TRBWbfG1MP2B0vIJVXxDRpXAgHpHCSTQfOdwG/3pFPx0H6g/PBb6mj4K79o3+IvpEUfLCvNAVCaBXjcXkxc2SX9gnm/zqk7bZTGGGpkENS0p3Z7MdsyABIDiPnvUTBT9rvfVa0bKJO96cAWC7ImV7IwhaSxm3F8HJSs6eTdt1dBGlkjtxp7IWESHDprg9yXscab 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(4326008)(7416002)(1076003)(66556008)(66476007)(66946007)(30864003)(26005)(8676002)(5660300002)(8936002)(41300700001)(2906002)(316002)(6512007)(478600001)(6666004)(38100700002)(36756003)(6486002)(6506007)(2616005)(83380400001)(107886003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XcW6+qkvnEqDjNsUuFnWgwoSHo3u3Kij+H665vifRPgz/agDxwK+84QKF9oGhGrK0mFuZZihz3l9xfX2upDNa9krN0mSwvQzcxaVN0Bcc1SqW8Av3Gz5SU5IcWtVPmUVNYezUG246xCauJ+ReXVYUWhCSwnMndVzdZVDvsPZlHUALS5jWo9I/wJcF9WbhxCzESJlEuGZrdsBjjmEGjyxs+/J4OmxdEXqz+O5dg6Ir5GUqwAktTeLuH+r4wSoSy+B9lg2w64kMuhRn5UVjsrwqzw9mht5DqyhNIxjxp7wBOyy7DWPZ0eKeVcRU7ssyEBG1U+5FpGd0u7rKWU049Tg35t/9/MmBqOH3rXHnHZ+QC9bM98cGqmYfd1oZFzdegPau1Go+fQTapL0092B2f/UujMWEC9Z9Otz6ndRmlind4p/Z1Vjp5N9m///uM0H21fY0RJUV0Qx8wANvBOGCP7m8KoAk/l37KH/K1LobaLm2UnJYM6/pfKRzbQ3JduLz+esd/ibvSOC1zSdrn/ieyVve1iInado1FQNSrLRkBedxZ81sKBVwOccjDYbMowr9Xpn/TytDJ3pJs1pgYjT/8eRbxeVZIIt4Nu/Ff91H7vINvhOQ+gktzdfyHhvyh17vqDxUE3DVTv40quG86u6Hri4WaDm0QFxjdiuVx5Libe/4+1c+qozCZkU2S/Vxmz0ZJdq9hyHwC91TP1m1XfHVfHy0IYL2wR9WFXvhRgMvxNYT7UdLOff8Ta4vAolevUkWDnK6KDkr97Nc0EfjHXSGOep2UuFtOXfTusIJnLpRF+OAF0goX12gt1EBaKFm9v8CodgfGn3jbn+NSeR3A/37ba6hnAe+YDeC+uxmPosOTG/hZoygaUbGI9aSDstJFw1vS9J5I47Z+BEdehkEwPDw1DJgJNXxHL3GIF7wpEW5S+yO8Brd89yCFUiqbxQ3HSlerrDlgDTSHH5aYF0UZPxIMdu0hB2rL+Enw1rDaNPvpK0g6fKy8n0itOZajbJ0SE4mR4txBlSTEzyboii4Arn3qr/S4UYd8UGT71d1+G2tk/ADZAGAVbKLFJl5t7ensCC0TBO85jH/nj+oU7NIDk4oPJ4rMPatIXTeQr0LKf/oNFBY2T8yDQRUZaxeVOTdzDxEIsRKUTIpwxcLErXr7gCpv+jGJ1kpjMK1yD5FDVmMcaOGujMABqt7JMzQKhBsmSH8x2UC7O/PCfWPpX4Jq3TTVxtUK4edfIbtiNt9HWpXck8sAqqgg9NfbKBZfxg7lf+QOeh7t9Xj+3jW036TGkmGLTjofdK0ziyZo4Xqj5PDEBsw7zZL7bdhO3+Qm+9hnXUwQ4eIjVzCXH2Ly1f3HGRIawryQq0NksAzXmT6gvIZ1pIhMAeWc2w8kqprPt7miJiPTrPgXeRiE4/D47pxOoIkmsgV+Lp7+nLv6aSssHsrnf8h3A0t0EPTIiO7SnBmzY07op0yueQbRP53UGO8r5UvduPe8ISIyXAYdp3+fgbj4+qnlAK+jkko/KTBIYZJ2VAGpOevGF3TgA5Wrv6BdEJM5zJbe9lZMrKUwXuwWjHMouP2e8/2HxXCkqBzoiObG/NruFS X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48cb04aa-c1fc-4311-071f-08dbc03548b3 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:12:09.0751 (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: gUftGt2Wn4z5zeakHyu7zQRUScrL4HmU0EDqnwoene/e58i6MX+TL804N4yNxUbuwQriGgbSvx9qoZy5Ib8fxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9162 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 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->no_condense 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. 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 f397e2eb0cdc..2db0bd83d517 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..269d8075f3c2 --- /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->no_condense = 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->no_condense = 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 Thu Sep 28 15:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13403236 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 1E6854E269 for ; Thu, 28 Sep 2023 15:12:21 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2089.outbound.protection.outlook.com [40.107.102.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD17419E for ; Thu, 28 Sep 2023 08:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7h39zek200eAB2NhcB/AnDb2PJMScWbHwA1b1VLBgjAd036p52yWlOoCCXc+3Lyx698/tmaLSrdhXpivwoXyWi6CRGBXtbYVikTNIUvFy11hxcsqp156AzppL2DqquRN9MAcZTqWSbvxg91hdwWxVVjut6BWceK5fBqJGGOwWQH+46IU8xUxxMLL2oGdkVacQItfvQAwHFTFfCk6hKidWzUHnkMJL/Lkj7NwrUdWABGk4w/ZsEdJYA5RW4hLX63U+04FdrKWNk78kGcLuDeM03PxTu9ezXb3bAIetorTESi5StGYTdbVcpjgaFXGfXShf6vLKJ3jKFrsfY9mNhcRg== 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=BeLLWBed68gGJ9Vq/aW24elLk6SwgpBOemoFVePk4Ck=; b=OhYSkGCbMHx9XnkwiSpGc4SaYAchTSbZczHT37L1Shw+oMzFLOgro52mLouv8ZeZr12wHzIf2hRo9qbdNY/sS3RmOxhl96FBd8/AGK5Fnm5urD3xfS95dSgFu2LFzWLJ1dO2v7ll1QXVKaEGFPPTIrivyEOiuyCt2XM0kYHPFx0JwIrrGlMqq5G/abBstw5Bh0B7h/3R6LordBZeOptFkIVAwnLj1raax7ZOKQVd+4goI5afqOj2D2Z2FaFTk3ofCww44dBh1TpB7hbO67Q7VsghmBa4Ds1ihJXdBMWCnC+jNucpWoLi7DR8F/j1GNNUYCpwbvhZtQfvawdMrAhtvg== 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=BeLLWBed68gGJ9Vq/aW24elLk6SwgpBOemoFVePk4Ck=; b=po/BtIxSWhQHvhC1eMPFpdTOHZ9hMixL/LVC9IyfsSqV7ohTudoeC8t8Bwwlr6df1HFMMzHKLWV4Dy9d+LpuaUtee2YNu+Kxq/f/cvfWTnW8CosjjAUsyNwjqPTVo5Gbsmf+/4zS3ISipT+/nXMGLyYEBs3cEvIOvouLMpEWb0p5nnMLL4sT0JQ3oPmcSz2AtMwKnRIXHXz2e6D9CKuT3YGcFBtY2eWcVnJobjkrn+21SB5Ey+SqAcJWzcaGM22kcvgLk11VxMqyNPUob7wCv41EgVMJWEIb95VeoIZNhK7GP02wovAQFxSsiPlw8hE5E83CTr1TwIRyINF0hHMkaQ== 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 SJ2PR12MB9162.namprd12.prod.outlook.com (2603:10b6:a03:555::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.32; Thu, 28 Sep 2023 15:12:15 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::54a7:525f:1e2a:85b1%4]) with mapi id 15.20.6838.016; Thu, 28 Sep 2023 15:12:15 +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 v16 20/20] net/mlx5e: NVMEoTCP, statistics Date: Thu, 28 Sep 2023 15:09:54 +0000 Message-Id: <20230928150954.1684-21-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928150954.1684-1-aaptel@nvidia.com> References: <20230928150954.1684-1-aaptel@nvidia.com> X-ClientProxiedBy: AS4P195CA0005.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5e2::14) 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_|SJ2PR12MB9162:EE_ X-MS-Office365-Filtering-Correlation-Id: 12a2ab39-f092-4980-0b6b-08dbc0354c95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FhdRq75B6O9umBXtAQjSpwvOMCFYNs7J2+gF5AagNjZDyR6u0YZQFNaFb9znKcTX32N1Om0M1ke6cmknmilHyZKL83MaH3sltuGqd0oOw6FQVbJ1+R3An0Ac7ZK6ABYGDBNQjDIBjk+Czgq1lZHkCdSYEagCc3wgrz/4oRE+TL5UC1RsMmK3kFYqOQWW85bUU/dtmr6ns43vnuS0f6ylO67ZPePX7CeOXCQhBdLToNTAW/vuj7oN/Ugwfyp9hkGGddkUmoHzUHgJvWX14KVMrB6TuP/ecGclk/wgTYDnnKU+IqJ1Cp6N+cO/gWn+Q+enYizLGLddMlHI/+auqaCd8XyuB5Jw+0W3St3NhPHugT+d62AGGmcaqr3m1c6Tbb2etoUVEKClF/LEp+m47x5bPzclLrJk01DeZva0RAGYAon7LJ1VVquNM62sakHsxZEvgQComXRhE9wlJtXx/lwh5ps+4n57Hv6OHVmz7Tb0uN9CGpWbIRkSt2MtvRKBmhYSZ1/AaiW16abl8U+S2SgO0yci8Wil0D9XTLX3LkaAZBo8NUbldSFHXS8f6aGvbDxZ 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)(346002)(366004)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(4326008)(7416002)(1076003)(66556008)(66476007)(66946007)(30864003)(26005)(8676002)(5660300002)(8936002)(41300700001)(2906002)(316002)(6512007)(478600001)(6666004)(38100700002)(36756003)(6486002)(6506007)(2616005)(83380400001)(107886003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XA+SuNnjvlet4kZZEXZXVc9RQXZ4gbwEkB+x97CFi1DgNvrIlPOWGMMSbOzKPrRh1nhERzVJhpt7papN9Tw6STmuNGT8HNhVIalBBWT5vriHBcYvKPYoLkkEHoqhLdD5qTib6M05ASBhxwWydEPVtcZnaVaiCn0PsXTsTxqgDkmlWGey2leNU69woT2oTvNWlEnucTEW8jRZYfVJBnYwIIaLlhBkBWcIdO/NC1FsuxDE2VGjW9saoFNu5REjQWldWoiczZOSyVd7fr+OwQjE00m3dWMNyhBVEhwQRzoW1wax3LPvMYF40iVczLeGGBpDQhBPmkzff6udbNJwfox8EfPCrf90B+/MR5fICrF19SGegognD+d+hsJ022ARyLTFX3ufuv057cyA2m23NXmncYyJVcGuuaxjgwm7oURNlTdVyCKCvt2XPtCMSF/J1ARYQ/cIv0cBZZ2ziXKY+I/Cj+PiQR5jY/BE8AhzWGKm/JZG4YffoHv35fbjA+4jQdVKl0sdzUIxg4pgmOTGQ2f9WS2IqBol26pbXaNH1Q6vzt07aQsNAfPo9ONNNeelwkEbt2TwXGTenOH6Tca3ZLCO85RumBXpW4j04qs5DiuxvEwybcMjhEiexQYSubL263hcRzLD7dPIu9edl8nHGrrBhcEy94910IGmST/jmxJllSvlH+Ac9w9u1uZxn4uryR5tXgP4W0j3OzY8JwiHnrQVCzpsZboXzCPkBMsauAuS7k3P6+kydCuUxR/toIh/oF9nbqgOti2U4TUKmLMuVL92Zt8IQnuRHdZfOo8psD50fi1hZSvvCULZyY4IjdKnfUBoOFES7bw+x9KbSlzGjmc3Krb91n/8qAhb9cBlY4fykkPcTxtD8nrRkpZE/jf9JxfRyaImrLAAAcmlj03Pw+RrwkxCymSGD0AIB4JhFHt94LCwogSyZiNcudR+6tvnA/sdsdO4TuU4RDnBYaiDAqX9pW39Gjg0YK0AESi0wWPfibEobd9nfwpQCri+r3DXbhENfDJHrVt296CKRwa6wY94Mo8cjx3HkhM4BWMv/KsywOj4sMkNo3oHwvmzI5z8qR55wGEBXZ1cB7SnB1xpRbB9EShqv/JKJZ6H8B5MX7qQe3AIpFEsOYEpdtD3zr7++Y/pLkl6UO1SaVFQIUGlzoOOWjbVP1ygMu9Ii8Gkjo96zBByFahkLM3nojjct/aY/Z8t54JT12Qqx+D78nqXDZs/V9N/Bs3/NuQ+nqp2rqi50znXtBI5awL8aTitm2aS1TqW+DhpWCvq7QU3Qpw0bp0JUb99V+OzyAP7fMhYPIPBt4o7MI8JcdSW8RPD7ju9y04McYwmLzsIBHtYIMUK+w0wwkaHGqU959MXXPcquEQfFeigp1mj5XigaJ55DG4ZdATLsuapXQ0k/ByLjIkkHl2ummkzzwcw63t7DoZB48hqQ8r03z6HigVdKD0PN5hM4zD0yWn5JmZ0iWKpKZu4xMRsqdKour5m3la3bqiACl8Kc8sDgshucllwi/ozdDY0rTtdUwBvcw42gqTbtJzd3/5pzFij+nLwjs29s4z1AkjUbZlnHvejrO8UuQPFfEDrKecM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12a2ab39-f092-4980-0b6b-08dbc0354c95 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 15:12:15.6383 (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: pdkjBE+/rSkViQx1uKo31K14rFQ9bbY1g/bW6T981ZIzFJ31B3AmlaGzj04y5M12knrvcZCl+zFZcrA36btcyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9162 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 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 | 54 ++++++++++++--- .../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 | 8 +++ 6 files changed, 146 insertions(+), 12 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 2db0bd83d517..3c4e9a242131 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 fb38d1dee03f..b961fd8dfacd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -616,9 +616,15 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, { struct nvme_tcp_ddp_config *nvme_config = &config->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 (config->type != ULP_DDP_NVME) { err = -EOPNOTSUPP; @@ -645,11 +651,11 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, queue->id = queue_id; queue->dgst = nvme_config->dgst; queue->pda = nvme_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 = nvme_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); @@ -661,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); @@ -674,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; } @@ -687,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); @@ -818,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]); @@ -848,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) @@ -896,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 @@ -929,13 +954,21 @@ void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue) } } +static int mlx5e_ulp_ddp_get_stats(struct net_device *dev, + struct netlink_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); struct mlx5e_params new_params; int err = 0; - /* There may be offloaded queues when an ethtool callback to disable the feature is made. + /* There may be offloaded queues when an netlink 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 @@ -1017,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..527f2a33e343 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 netlink_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 netlink_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 269d8075f3c2..6ed9acdec376 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..a5f921447aab --- /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 netlink_counter_map { + size_t eth_offset; + size_t mlx_offset; +}; + +#define DECLARE_ULP_SW_STAT(fld) \ + { offsetof(struct netlink_ulp_ddp_stats, fld), \ + offsetof(struct mlx5e_nvmeotcp_sw_stats, fld) } + +#define DECLARE_ULP_RQ_STAT(fld) \ + { offsetof(struct netlink_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 netlink_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 netlink_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 netlink_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 176fa5976259..b8e0a36b382c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h @@ -128,6 +128,8 @@ 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); +struct netlink_ulp_ddp_stats; +void mlx5e_stats_ulp_ddp_get(struct mlx5e_priv *priv, struct netlink_ulp_ddp_stats *stats); /* Concrete NIC Stats */ @@ -396,6 +398,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 {