From patchwork Fri Feb 3 13:26: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: 13127514 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1DAC61DA4 for ; Fri, 3 Feb 2023 13:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbjBCN1g (ORCPT ); Fri, 3 Feb 2023 08:27:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjBCN1Y (ORCPT ); Fri, 3 Feb 2023 08:27:24 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95082941A for ; Fri, 3 Feb 2023 05:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=isLgTTslCAIDUbywg1+qW8pckWdhNhl34a4JAXBYzH2n+i1OOLVERNJuXXpx8yyp6ON0jCIO6ph12ooNHvhpHEByrgWLztR2MuZ+oAVmqwrX+UYA7ISbxvGSRCfoDhU9TQMHgel9KYvobrA/U7h12jq9MTjfocLbHfebrW4vYdGRQD7wsgJhjFcO9PWn5LNXTCV+BJ4jVC89lD4i0oNoGwyN8zO3dfoAzgRAoO4r+u0Zsxm9LLpw6W0kf6qcx1app/yEB4aNCIUSYd+L9tAZ+unlI4ySTGI816HwLKtl9ul//9ehtZ/Q3o2Ejc4JBxd3tdgBGI5tEkAWETuZi2uQLA== 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=5U0kbYdPBsv6pS+iWpMunurO2s7ECZEJkXnZ0xs8ZZM=; b=UzIDt7lGKAipKqeLVmHDVx3XJuD3UA2Zrbu4cdbTCYNBJx8USsFI4MenTYNOu/Vma4DBYkITYsjT2nR54UomBuV4urECWgYXhhvsV8a9H+sNmQt1rEYFcRpjSb1iLO0y3oRoHMl5JPIJnOaADgCEW1BxrPbatNpqwYPZq9gBe4rBzGSiCJ8KAGegL+M9MDblmrS3phwCaajBxqakgFB+1+ReYQMaJWVhDSjBs6zD1K5um57FmFnxt2AffuxmGWtG2WtxJJRR+Ot84kBFjRFSevYS2O6By5p/PvQyTkJdaI3D6vRK/VgxgZL5AE7JYJWXJH/V7/rEemWqpx3YC6L+6g== 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=5U0kbYdPBsv6pS+iWpMunurO2s7ECZEJkXnZ0xs8ZZM=; b=mWBGBPIPhk00rpAyFe79hM+uwxtoZKAsx2PhU11V1vhayLM4KrNqTw3H5AkabRvYCyqtBzuUMyKVWj6cBictPnLh/qdfsa0kzyHHV8HbqHqkvV92JWRtGecWRjFpgNkvLkpWf57LhnLfY1S9t0p99qO6a4mC1vVMNiGwDidtrBztxGOjvEvawu3amhRtfZXo8bXTFYcqMaJUyqxxdqKR9/Lj+0Cf0BC6j6Lrqi6qlsuXLk1mOb6boy5H+akl1z4EdlbHiLD5GLVuCQY9OyWr15lgen7cXQcMBzhbswQbLHs/prPQrauMUHD+FDqjczCus8RWYSmo3g9MnMep/wRm8A== 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 SN7PR12MB6930.namprd12.prod.outlook.com (2603:10b6:806:262::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 13:27:20 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27:20 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org, Paolo Abeni Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 01/25] net: Introduce direct data placement tcp offload Date: Fri, 3 Feb 2023 15:26:41 +0200 Message-Id: <20230203132705.627232-2-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P265CA0064.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::28) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|SN7PR12MB6930:EE_ X-MS-Office365-Filtering-Correlation-Id: c81f69dd-6e0e-426e-7b51-08db05ea6040 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VBVXz8QAhlKXmu395HMVF1wreJgeJUAp92JDbxjqGM7OV/cNYwo//9FLFut11JMEkaYbIpvmn9OwH5ZPXRqSIYbe/uSUyf39UzavbzMhwA9uc+uzqjpbaeyYm5Ggad2O3rwrWuscbbf9mJTsxzkBwp5ZBuZakI9vkhA3mC/cBfssVmtPw4eGf6v1JIwrNd2Q9XE5gfuZIp7gOlds1RRiQQ6BtejA+poICTdmuJvOe7WhZ0YSZWucRsRCFwtNYKEJi8mH9IXBEgYssaG2ZcR+UhyNM+iOLA+270QzuTRc8vXKictqaXQL1FprhL6fQ9DD/M+4hQVrDl5Gob61HVgPrNLTXg4Bonk1jpQBXi6bCtfkL1+qyFg48LHUQy+imzeHlGe8MLOBbuipnvqscnPC7MTNEv2uaWQTVJfCawMRaQoRI7t7bxRunjYGIOaEKCl7Wxj7Vobpu45+zYocq7fPXPD2b9oqHJE2k6RX6RgYfQNrs5YprzKLOz8WbhclMZuJ0bUT524stjvocKL+hdrC/TyQMxHsi/d8331eB8/t9p4AuHYM24NAsgpTTObQJskdKdvvYQWK0UuDS5uIWT23JtVEXTAeMibwfQzq9lG2Wx63ueaEQFnS7aiQpmGZNIVuXTiiRrj7TnJTqHt0mjpZ63GSAPxhwHHFvnkHuFo55zP9ehP8UKp0lETL5Dw08RmM 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:(13230025)(4636009)(376002)(396003)(39860400002)(136003)(366004)(346002)(451199018)(7416002)(5660300002)(30864003)(2906002)(2616005)(86362001)(921005)(38100700002)(1076003)(6506007)(6512007)(26005)(186003)(83380400001)(478600001)(6486002)(36756003)(6666004)(107886003)(66946007)(66476007)(316002)(66556008)(41300700001)(6916009)(8676002)(8936002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pcU+5JXbtx8vT6SpRQY4NS98Y1t1qpRCHEmbwXR8fLtWlICwrV0rG8xcmRxj1I5EgeWFRXBCtNkgjS6usMfzfYeZu+2P97HNGKsDw7RuslJ5Rr7PTkWPPbmS/7ergHmVWeLTri2c1PGkhS8RpYdn4jodtm+/BumYHx2fuCkecdLWGHFvAiau8YbdjVZoD+I9hBDOz3WKT17dpEH0YcjKC5NHEsLJI64ksgkQdsZxam5cAyjuUXqakgvIPbIhfE62iE8IXLQLwoC8XT6KQnklUBP1Yhq4Mo9Jxr1MosyvWaq/79QppOH3X15krjQE1+cgTyOXew9J1dFpphpSzLDasY1Da7WPkwmmP6coOaFoDgCt+42CfUomeWFKnsHS78hYUJXXExNn5Bh5dkaMVLKTSS7c2GPVzTBuB4Urj041Yxnx5hNwB4vvWKXA3CUd1tMTpV8DVE22U//fuP+qIQzAK9XKN+Wh3RUBktIJy+na8grAinCDp9L4Rzp8N3dcynUS3HmmcebprrTZH7pP8T80uy+Aumy7c0OshpQ9UMb087VnCLYcEZsHTO40ZMO/NY21Erqz+6SvM/SAEjyncM3vd4WE3rx7EupzcVE2QbtY5qXMqzP8ZlJIWp+RQFLGoT3Zj7hGe3LyPiag+LR3KEeo+ur2aQMvFUtmb3hHDuImL8W4BkXZVt2jqmq70ZAlCtUnez91vITO1exc4Z4nzLKQhZYTnsZnTTXSkFwPWV+vv711Usk7lu9E76I99zg4ZOkwrMdE8unpO8ec3K/5hyKYBMta/s1vy18d1Fak5BOR5znb4khiB/yr+M/m/okamVjm+w5ZQkpR6SispOrdWePC91EdKH6IlWfQ5MoBmuXWHleyxRL54WBj1F9jmc9j1gWsxxImbOIGZP/zWlSMk+zzPfsQLs87slbjJWUByiRUrfqVAZBoOQsH5Fo1f1XEbiDnauRyviV8SVbSWoCeBE+v8rclo440gTHPpGKsUOjyDiQ/b6fZw2R6v/MJuaTwrRwvMpOuu247dclhdgsf5ELul+LF37gFh5R/zVxLRB/PIIDmeoc1PrHX0IxZ8xZhUBxyiS7uFHcWWUU5QEtZzw0FWMYJFvoTNjEC09zJC14ApOxIeJyYyzz4lAe9zS2Oghx7uy6NRe9B3hLyRHDTS89L9yFljj/ZdFjWly9IChtjAoVm17Ags/bj5piVN3MpbaG99kU+PN0/4qldD+nZPZbzq1uV2XWABgSKhi/4Cs/F1QY3Sd5eVb8CfcZ6ok8zf1UOF3NViwsJXlyhUT5ArVmfEIe5rMENMeRNeE2m/K86WX0dFXKYPmTlJITV3U8KG6eIoDJhnCdz3hcDK/lNEyf9agQLpODrdxAlVs3mgr/qDrgSfZ2oAZzDNZ4bHdQBCVWiA0n1VgzfpSHGWjArD8FWbRPpD0PG3jAF+CCM0fepCHBWJuuT5Eb9nHkvZltIInXN19/oeLz5y3tPxsexfTx/I0HBJe7/uHeJ5qA4ry+mFehZg4HP5ulnStB9bOuuNIdQLf650i81k2AXiotvhlVdgsrIbEP5hklefLhgn/fXRPi4gI/o5DBoTES7SiJ4Idgo X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c81f69dd-6e0e-426e-7b51-08db05ea6040 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:20.0881 (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: FZh/+gBxp+OK+a1ISEIf4s9veOuIkDN6DxDyE5wJ5Eudxro/2CqMXS2iwwjeLQFlUC3v3/RQEtQaTtahsTGrMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6930 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Boris Pismenny This commit introduces direct data placement (DDP) offload for TCP. The motivation is saving compute resources/cycles that are spent to copy data from SKBs to the block layer buffers and CRC calculation/verification for received PDUs (Protocol Data Units). The DDP capability is accompanied by new net_device operations that configure hardware contexts. There is a context per socket, and a context per DDP operation. Additionally, a resynchronization routine is used to assist hardware handle TCP OOO, and continue the offload. Furthermore, we let the offloading driver advertise what is the max hw sectors/segments. The interface includes the following net-device ddp operations: 1. sk_add - add offload for the queue represented by socket+config pair 2. sk_del - remove the offload for the socket/queue 3. ddp_setup - request copy offload for buffers associated with an IO 4. ddp_teardown - release offload resources for that IO 5. limits - query NIC driver for quirks and limitations (e.g. max number of scatter gather entries per IO) 6. set_caps - request ULP DDP capabilities enablement 7. get_stats - query NIC driver for ULP DDP stats Using this interface, the NIC hardware will scatter TCP payload directly to the BIO pages according to the command_id. To maintain the correctness of the network stack, the driver is expected to construct SKBs that point to the BIO pages. The SKB passed to the network stack from the driver represents data as it is on the wire, while it is pointing directly to data in destination buffers. As a result, data from page frags should not be copied out to the linear part. To avoid needless copies, such as when using skb_condense, we mark the skb->ulp_ddp bit. In addition, the skb->ulp_crc will be used by the upper layers to determine if CRC re-calculation is required. The two separated skb indications are needed to avoid false positives GRO flushing events. Follow-up patches will use this interface for DDP in NVMe-TCP. Capability bits stored in net_device allow drivers to report which ULP DDP capabilities a device supports. Control over these capabilities will be exposed to userspace in later patches. Signed-off-by: Boris Pismenny Signed-off-by: Ben Ben-Ishay Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- include/linux/netdevice.h | 15 +++ include/linux/skbuff.h | 24 ++++ include/net/inet_connection_sock.h | 6 + include/net/ulp_ddp.h | 189 +++++++++++++++++++++++++++++ include/net/ulp_ddp_caps.h | 35 ++++++ net/Kconfig | 20 +++ net/core/skbuff.c | 3 +- net/ipv4/tcp_input.c | 13 +- net/ipv4/tcp_ipv4.c | 3 + net/ipv4/tcp_offload.c | 3 + 10 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 include/net/ulp_ddp.h create mode 100644 include/net/ulp_ddp_caps.h diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d5ef4c1fedd2..8861a2f04e00 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -52,6 +52,10 @@ #include #include +#ifdef CONFIG_ULP_DDP +#include +#endif + struct netpoll_info; struct device; struct ethtool_ops; @@ -1393,6 +1397,8 @@ struct netdev_net_notifier { * Get hardware timestamp based on normal/adjustable time or free running * cycle counter. This function is required if physical clock supports a * free running cycle counter. + * 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); @@ -1617,6 +1623,9 @@ struct net_device_ops { ktime_t (*ndo_get_tstamp)(struct net_device *dev, const struct skb_shared_hwtstamps *hwtstamps, bool cycles); +#if IS_ENABLED(CONFIG_ULP_DDP) + const struct ulp_ddp_dev_ops *ulp_ddp_ops; +#endif }; struct xdp_metadata_ops { @@ -1789,6 +1798,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 * @@ -2083,6 +2095,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 5ba12185f43e..9d1c35b04e80 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -806,6 +806,8 @@ typedef unsigned char *sk_buff_data_t; * delivery_time in mono clock base (i.e. EDT). Otherwise, the * skb->tstamp has the (rcv) timestamp at ingress and * delivery_time at egress. + * @ulp_ddp: DDP offloaded + * @ulp_crc: CRC offloaded * @napi_id: id of the NAPI struct this skb came from * @sender_cpu: (aka @napi_id) source CPU in XPS * @alloc_cpu: CPU which did the skb allocation. @@ -978,6 +980,10 @@ struct sk_buff { __u8 slow_gro:1; __u8 csum_not_inet:1; __u8 scm_io_uring:1; +#ifdef CONFIG_ULP_DDP + __u8 ulp_ddp:1; + __u8 ulp_crc:1; +#endif #ifdef CONFIG_NET_SCHED __u16 tc_index; /* traffic control index */ @@ -5048,5 +5054,23 @@ static inline void skb_mark_for_recycle(struct sk_buff *skb) } #endif +static inline bool skb_is_ulp_ddp(struct sk_buff *skb) +{ +#ifdef CONFIG_ULP_DDP + return skb->ulp_ddp; +#else + return 0; +#endif +} + +static inline bool skb_is_ulp_crc(struct sk_buff *skb) +{ +#ifdef CONFIG_ULP_DDP + return skb->ulp_crc; +#else + return 0; +#endif +} + #endif /* __KERNEL__ */ #endif /* _LINUX_SKBUFF_H */ diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index c2b15f7e5516..b11fbbc95541 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..11220c72f276 --- /dev/null +++ b/include/net/ulp_ddp.h @@ -0,0 +1,189 @@ +/* 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 + * @nvmeotcp: NVMe-TCP specific limits + */ +struct ulp_ddp_limits { + enum ulp_ddp_type type; + int max_ddp_sgl_len; + int io_threshold; + union { + struct nvme_tcp_ddp_limits nvmeotcp; + }; +}; + +/** + * struct nvme_tcp_ddp_config - nvme tcp ddp configuration for an IO queue + * + * @pfv: pdu version (e.g., NVME_TCP_PFV_1_0) + * @cpda: controller pdu data alignment (dwords, 0's based) + * @dgst: digest types enabled (header or data, see enum nvme_tcp_digest_option). + * The netdev will offload crc if it is supported. + * @queue_size: number of nvme-tcp IO queue elements + * @queue_id: queue identifier + * @io_cpu: cpu core running the IO thread for this queue + */ +struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; + int io_cpu; +}; + +/** + * struct ulp_ddp_config - Generic ulp ddp configuration + * Add new instances of ulp_ddp_config in the union below (nvme-tcp, etc.). + * + * @type: type of this config struct + * @nvmeotcp: NVMe-TCP specific config + */ +struct ulp_ddp_config { + enum ulp_ddp_type type; + union { + struct nvme_tcp_ddp_config nvmeotcp; + }; +}; + +/** + * struct ulp_ddp_io - ulp ddp configuration for an IO request. + * + * @command_id: identifier on the wire associated with these buffers + * @nents: number of entries in the sg_table + * @sg_table: describing the buffers for this IO request + * @first_sgl: first SGL in sg_table + */ +struct ulp_ddp_io { + u32 command_id; + int nents; + struct sg_table sg_table; + struct scatterlist first_sgl[SG_CHUNK_SIZE]; +}; + +struct ethtool_ulp_ddp_stats; +struct netlink_ext_ack; + +/** + * struct ulp_ddp_dev_ops - operations used by an upper layer protocol + * to configure ddp offload + * + * @limits: query ulp driver limitations and quirks. + * @sk_add: add offload for the queue represented by socket+config + * pair. this function is used to configure either copy, crc + * or both offloads. + * @sk_del: remove offload from the socket, and release any device + * related resources. + * @setup: request copy offload for buffers associated with a + * command_id in ulp_ddp_io. + * @teardown: release offload resources association between buffers + * and command_id in ulp_ddp_io. + * @resync: respond to the driver's resync_request. Called only if + * resync is successful. + * @set_caps: set device ULP DDP capabilities. + * returns a negative error code or zero. + * @get_stats: query ULP DDP statistics. + */ +struct ulp_ddp_dev_ops { + int (*limits)(struct net_device *netdev, + struct ulp_ddp_limits *limits); + int (*sk_add)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config); + void (*sk_del)(struct net_device *netdev, + struct sock *sk); + int (*setup)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io); + void (*teardown)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io, + void *ddp_ctx); + void (*resync)(struct net_device *netdev, + struct sock *sk, u32 seq); + int (*set_caps)(struct net_device *dev, unsigned long *bits, + struct netlink_ext_ack *extack); + int (*get_stats)(struct net_device *dev, + struct ethtool_ulp_ddp_stats *stats); +}; + +#define ULP_DDP_RESYNC_PENDING BIT(0) + +/** + * struct ulp_ddp_ulp_ops - Interface to register upper layer + * Direct Data Placement (DDP) TCP offload. + * @resync_request: NIC requests ulp to indicate if @seq is the start + * of a message. + * @ddp_teardown_done: NIC driver informs the ulp that teardown is done, + * used for async completions. + */ +struct ulp_ddp_ulp_ops { + bool (*resync_request)(struct sock *sk, u32 seq, u32 flags); + void (*ddp_teardown_done)(void *ddp_ctx); +}; + +/** + * struct ulp_ddp_ctx - Generic ulp ddp context + * + * @type: type of this context struct + * @buf: protocol-specific context struct + */ +struct ulp_ddp_ctx { + enum ulp_ddp_type type; + unsigned char buf[]; +}; + +static inline struct ulp_ddp_ctx *ulp_ddp_get_ctx(const struct sock *sk) +{ +#ifdef CONFIG_ULP_DDP + struct inet_connection_sock *icsk = inet_csk(sk); + + return (__force struct ulp_ddp_ctx *)icsk->icsk_ulp_ddp_data; +#else + return NULL; +#endif +} + +static inline void ulp_ddp_set_ctx(struct sock *sk, void *ctx) +{ +#ifdef CONFIG_ULP_DDP + struct inet_connection_sock *icsk = inet_csk(sk); + + rcu_assign_pointer(icsk->icsk_ulp_ddp_data, ctx); +#endif +} + +#endif /* _ULP_DDP_H */ diff --git a/include/net/ulp_ddp_caps.h b/include/net/ulp_ddp_caps.h new file mode 100644 index 000000000000..8ee964a4df78 --- /dev/null +++ b/include/net/ulp_ddp_caps.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * ulp_ddp.h + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ +#ifndef _ULP_DDP_CAPS_H +#define _ULP_DDP_CAPS_H + +#include + +enum { + ULP_DDP_C_NVME_TCP_BIT, + ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + + /* add capabilities above */ + ULP_DDP_C_COUNT, +}; + +struct ulp_ddp_netdev_caps { + DECLARE_BITMAP(active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(hw, ULP_DDP_C_COUNT); +}; + +static inline bool ulp_ddp_cap_turned_on(unsigned long *old, unsigned long *new, int bit_nr) +{ + return !test_bit(bit_nr, old) && test_bit(bit_nr, new); +} + +static inline bool ulp_ddp_cap_turned_off(unsigned long *old, unsigned long *new, int bit_nr) +{ + return test_bit(bit_nr, old) && !test_bit(bit_nr, new); +} + +#endif diff --git a/net/Kconfig b/net/Kconfig index 48c33c222199..3c59eba4a438 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -471,4 +471,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/skbuff.c b/net/core/skbuff.c index 44a19805c355..d6e12b8cc46c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include @@ -6520,7 +6521,7 @@ void skb_condense(struct sk_buff *skb) { if (skb->data_len) { if (skb->data_len > skb->end - skb->tail || - skb_cloned(skb)) + skb_cloned(skb) || skb_is_ulp_ddp(skb)) return; /* Nice, we can free page frag(s) right now */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index cc072d2cfcd8..4a7edad5b2b7 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4671,7 +4671,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; @@ -5234,6 +5237,10 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root, memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); #ifdef CONFIG_TLS_DEVICE nskb->decrypted = skb->decrypted; +#endif +#ifdef CONFIG_ULP_DDP + nskb->ulp_ddp = skb->ulp_ddp; + nskb->ulp_crc = skb->ulp_crc; #endif TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start; if (list) @@ -5267,6 +5274,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 ea370afa70ed..5d57aa9f9abd 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1861,6 +1861,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 45dda7889387..2e62f18e85c0 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 Fri Feb 3 13:26: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: 13127515 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59E2BC636D4 for ; Fri, 3 Feb 2023 13:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbjBCN1h (ORCPT ); Fri, 3 Feb 2023 08:27:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbjBCN1a (ORCPT ); Fri, 3 Feb 2023 08:27:30 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B6792EED for ; Fri, 3 Feb 2023 05:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RA4ET3HggWNDpSkEeD9uzTZj3cFhrtVPk6z/J0owqb+GLGFYWYPI3i2/gDkJc/74DKLhjwPXQn1Z9Cxj9vChH5SqJJ50UdM6EA7Q8pyMutX/ROpQgvxGB6rtvkuoSdEVZaGPy2+jtOcC5JdVFgj82aZiqHB9wr/IHkI4gniSZ800IBA0aiRg2X/CaFkXW95j3P+oyj80f/EfwPZqZwJ0t1Tyzz/VOZsfWoW4zx1xL7epav54q/0FZhiN/aG0J+Jd9cTscLrUQeC1AMXywnru6nEl6mS4RCWr5Z0qBdqNLj9KOoohvqE6u1we7UWlE2MjOS0Ldlyj+em134ngCtyszQ== 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=S8/No3axzKUhsGFPUO61Pfphbx5WUJkQ4WQPvJ/aelA=; b=Oh/L47SIldDvl8oL2ob9tly6FnzYpgFbhtb+crj1J9TD2lENBMh7mmv97JX68g+P4lBORYO/RXRelnsKRYN3Fo63vNP8CIcQJ2Wd5W7KqR8wSRA5MDtdm8IDu1WQjIgEIwxaWCfLxYdME92B1XUuYYyWoUYGwno2JXghY/cyXOHBZyisZkvlDvf+IUeVYN9lpl7aqSljb0BRNXjqgEk1G88QM32OaqZmiuF5jQrtQxhW0el8CkwqdqTwTZHcTUq4uR4RPbRUPkRAzVZozji1Y+m5GaHnAMtjCJ9BEGB9VxhACr/rhNgc9oyEA7YaU9ui6FVMl/mY6fq9roGZlD5BAA== 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=S8/No3axzKUhsGFPUO61Pfphbx5WUJkQ4WQPvJ/aelA=; b=Lq4byY11KyHK+KLuJ83YPGYEmmp2JRki0Gxk1WiBL+0HkEqEPrxk7G+G/sr0lNR914dP8YIf5R1fpCWA4u5yPGDmVi2DQkejviY2Mh+7gJNektvzHrgM9OfntR3gSVW1q1u9CHrDE4r8MNW3LIziTdmU5rjqpz+OBN/SC1l4UXGZyZ2Z/Q6glcNoLVinQPREEtPYHzQxAEqeRuA+1N1CrlVqLBNCQW3POuxmAufDsSjfcZk7z8htBlMCTlx3hJnRPNx58Z5o76VpsatV6eiDlUxO1BOoDnnr3g9cTDHZ2GAZ7GoX3YzOa+KqGdDB5qDpx8uorEDiqZdq+n/zRLTzwQ== 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 SN7PR12MB6930.namprd12.prod.outlook.com (2603:10b6:806:262::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 13:27:26 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27: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: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 02/25] net/ethtool: add new stringset ETH_SS_ULP_DDP_{CAPS,STATS} Date: Fri, 3 Feb 2023 15:26:42 +0200 Message-Id: <20230203132705.627232-3-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0081.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|SN7PR12MB6930:EE_ X-MS-Office365-Filtering-Correlation-Id: 36be2440-2d0c-4727-6b5f-08db05ea6430 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9Bn/SYNuc4WHcxBrysuNWvyY0MURY8yNdKidZciy0eVyObc0lNYbCTTAGZziTKicCWAZm3+LSq+uFY1w/WTP9bDyv7v63yGbEvFhGu0aTQQAti+chWlRSPAjKUkkpRuKqemODwlvBkm2EULI8wzxUAdyluQwUMdU4ohkVf4BZKISKjKItENcsfiDeTMFhNWpbitlkg0WPZQ0g9DI1HVTJnok3zsNSNRN7jKTsa/fryI2xuqOYHwzPf2VwV4txol/czvPqpvna6l62Lla2EPdXRTE5UFFIJcJaRddjGEW4x8l4y5rjyTTQ2qohLbbRpSK4BYFGiVxwvC4TMtIdaDNpXuFYAw5XbIpI4bXc9h+6Upr7p3D2OpFyc01+hRAwkDenzQ8gIJOZ9Bkfu213iyL9+yyTevr2Ha/qXnS4tx+5D+3IGMPnnXY9ywVifHxNHaTpnvAkx57apvG/Vj4djPWwfiG2lwQOTmtwiWjSue1iQDQ/LuOu0fi6qYwmKeCuFZEqD6ATuSFCtosvHgEXveIhA7yoaTEuBATfA4S7ObMbblxsX8h2TQTmPXfO+Pn59+LK7OOE8SgDsrQbJGifVXeuuRbt+IGaqNlQBGR5Kwb6P6HJvejRI6dOf2hv9aPllSsxX+tVePB/Rptsl3LkeilVw== 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:(13230025)(4636009)(376002)(396003)(39860400002)(136003)(366004)(346002)(451199018)(7416002)(5660300002)(2906002)(2616005)(86362001)(38100700002)(1076003)(6506007)(6512007)(26005)(186003)(83380400001)(478600001)(6486002)(36756003)(6666004)(107886003)(66946007)(66476007)(316002)(66556008)(41300700001)(8676002)(8936002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vx8We4DdTJzms7eALn/9f+Z71Brlmow0jOG94W5F+tUoqBDuhcNtd4+RV0CEiw0VPUKKsl40xgNNXESK3oZTWPfF+phVAw/Di9Oet2KkdEvqx2AcPv5kasVnZH3/ZdUTnYrN5nEqDmq+qRHFaVxb8Jb5vQ9OHkJMNL7cRsiD4hTwyStyl8L0QyEVql6useTxbZnFHTuF9Wz9qMH5vVsyJULsqFV/FcMq5ZT0rB/CuB0isfUo4jPElR2zXlejPOkMiWlBVfPdrAsZBkHNJfmXcDPh/F/U/MjCjwlXTm9EVDq02ukfEQzCpveu1srYK2qVjG99H3O6LEny5+kwiRU+86F8/PheYCygsDsdVZgQgjGsUaH51tdu/smRd1cqUb6cnfSPAfdfxzCgmwU1E4Mgbe582QYckFudeqIVb2foN2R4sB/nRJz/Ks1uyntFUXr8xR9ND/NOvD+C3Y1/r6e5niJsVTnpEiz27DLGwnyMn7QnsbVbJOzUfqPxq4A4mNgqq+2xfPTEPl+arSzEb7lfPgJmuY/oI6PH0Fg8A3jaeSN6ZwYJ8YkP4A/SHWct8QxCUsxLxx2NvXqXvn4FUnELlz40Wat8rIQVtfA+FAtPLzUZ2+c6POOInFC6zCjl92hEm1A+RYr6pD12BTUkzzgkGUpv7Aqam+XTt2W/cU72RsQ6HcQZ6ZpLNjrf4Es/Qj+Xqqby/y4OBdMB4Hwlx+ptV4Px3oVZ5duuW6r0COfgwRJMXCUCyV2SWFKIDo/3A4Bp2T/WCZgFLN021PmZcv8QNI0lXKMYs75Z62juDSyvVOpxyb8B1l1bdcOWt7qTcWo8FMbuET0FyNwqeJjYu1igshlIspVwoxi2OiJfBV87KXu2vyEKhIAz5EXXNEMf3xK1Lt7dL5jOSi9vOtMRcfBWCKyMFhh7eeuJzSh869WopIZR7rcG+Ecsq0SPLuQ/A7lMMmAoc/H3v2x+TGRG6ItDHa6ljjTOjO+hB4EciOxVrK6+cslSThcZHG5WMSWe1R3P0cKpf/aQM1AnD8k46/BvUoS14RGydTdP3v4nCg48AO/8f9VmjZQcz+Bce24EQpBQW4/0RuPfHCiO2Fc85QBWvR+qNU19e+5Oz+jJbchaM7i6Yub42LPMKcEbM7M37sbsq8+4/iMPzFe010nkFXvNZMHn0Qy/5DWgFDFfTJXoHMZS3oNrMqhAUo9+Tay083Yo6k2T1729juyC2DpFEe287k3ryUeX5ISnDjA86lU7xFwkyiYuEUGkGpefiN/dNFpi18vK7xuvYfdTP9jwADCsohLcpKFT0hf5bVfWy/rWxbBvfIBvp6rU4EXYdshOXD9slB+/JHIrpYd6KWu4HZUmPxjE8TbxKukCOuCVUwkHff/s3TtmhP0wtlEACZ0Le+f0CBsnLkvCUBDGX+67LYZhHYHKxvXsyXSLw+LElmC5TnYwpy+6uZK9vzfa3c92DrZSn+wqaDzA0/ICMf0FHtPSy+V6nvCiS6kQYSN38OKuM3E6kh3ShIFfLogEykogBvg3ub0pfhHhx9jYcdPVksFjJkwM+MKyCHVBl4znVFlunEbPpK9DRdOnt2XgNZEuYyUg X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36be2440-2d0c-4727-6b5f-08db05ea6430 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:26.5856 (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: 6epE256LTSqJrq2/xUVgbO+dlyZmu2uxtT2vjb7HzDsXCHG/kEsHk1knzL7Ug03ZjBuvZlnLNCNT2RY2ITxsvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6930 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This commit exposes ULP DDP capability and statistics names to userspace via netlink. In order to support future ULP DDP capabilities and statistics without having to change the netlink protocol (and userspace ethtool) we add new string sets to let userspace dynamically fetch what the kernel supports. * ETH_SS_ULP_DDP_CAPS stores names of ULP DDP capabilities * ETH_SS_ULP_DDP_STATS stores names of ULP DDP statistics. These stringsets will be used in later commits when implementing the new ULP DDP GET/SET netlink messages. We keep the convention of strset.c of having the static_assert() right after the array declaration, despite the checkpatch warning. Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Jakub Kicinski --- include/linux/ethtool.h | 32 ++++++++++++++++++++++++++++ include/uapi/linux/ethtool.h | 4 ++++ include/uapi/linux/ethtool_netlink.h | 22 +++++++++++++++++++ net/ethtool/common.c | 23 ++++++++++++++++++++ net/ethtool/common.h | 2 ++ net/ethtool/strset.c | 11 ++++++++++ 6 files changed, 94 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 515c78d8eb7c..6b55db2b8287 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -584,6 +584,38 @@ struct ethtool_mm_stats { u64 MACMergeHoldCount; }; +/** + * struct ethtool_ulp_ddp_stats - ULP DDP offload statistics + * @rx_nvmeotcp_sk_add: number of sockets successfully prepared for offloading. + * @rx_nvmeotcp_sk_add_fail: number of sockets that failed to be prepared for offloading. + * @rx_nvmeotcp_sk_del: number of sockets where offloading has been removed. + * @rx_nvmeotcp_ddp_setup: number of NVMeTCP PDU successfully prepared for Direct Data Placement. + * @rx_nvmeotcp_ddp_setup_fail: number of PDUs that failed DDP preparation. + * @rx_nvmeotcp_ddp_teardown: number of PDUs done with DDP. + * @rx_nvmeotcp_drop: number of PDUs dropped. + * @rx_nvmeotcp_resync: number of resync. + * @rx_nvmeotcp_packets: number of offloaded PDUs. + * @rx_nvmeotcp_bytes: number of offloaded bytes. + */ +struct ethtool_ulp_ddp_stats { + u64 rx_nvmeotcp_sk_add; + u64 rx_nvmeotcp_sk_add_fail; + u64 rx_nvmeotcp_sk_del; + u64 rx_nvmeotcp_ddp_setup; + u64 rx_nvmeotcp_ddp_setup_fail; + u64 rx_nvmeotcp_ddp_teardown; + u64 rx_nvmeotcp_drop; + u64 rx_nvmeotcp_resync; + u64 rx_nvmeotcp_packets; + u64 rx_nvmeotcp_bytes; + + /* + * add new stats at the end and keep in sync with + * - ETHTOOL_ULP_DDP_STATS_* enum in uapi + * - ulp_ddp_stats_name stringset + */ +}; + /** * struct ethtool_ops - optional netdev operations * @cap_link_lanes_supported: indicates if the driver supports lanes diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f7fba0dc87e5..8b8585b5fa56 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -681,6 +681,8 @@ enum ethtool_link_ext_substate_module { * @ETH_SS_STATS_ETH_MAC: names of IEEE 802.3 MAC statistics * @ETH_SS_STATS_ETH_CTRL: names of IEEE 802.3 MAC Control statistics * @ETH_SS_STATS_RMON: names of RMON statistics + * @ETH_SS_ULP_DDP_CAPS: names of ULP DDP capabilities + * @ETH_SS_ULP_DDP_STATS: names of ULP DDP statistics * * @ETH_SS_COUNT: number of defined string sets */ @@ -706,6 +708,8 @@ enum ethtool_stringset { ETH_SS_STATS_ETH_MAC, ETH_SS_STATS_ETH_CTRL, ETH_SS_STATS_RMON, + ETH_SS_ULP_DDP_CAPS, + ETH_SS_ULP_DDP_STATS, /* add new constants above here */ ETH_SS_COUNT diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index ffb073c0dbb4..1722581b2db6 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -972,6 +972,28 @@ enum { ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) }; +/* ULP DDP */ + +enum { + ETHTOOL_A_ULP_DDP_STATS_UNSPEC, + ETHTOOL_A_ULP_DDP_STATS_PAD, + + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS, + ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES, + + /* add new constants above here */ + __ETHTOOL_A_ULP_DDP_STATS_CNT, + ETHTOOL_A_ULP_DDP_STATS_MAX = __ETHTOOL_A_ULP_DDP_STATS_CNT - 1 +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 5fb19050991e..751017dca228 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "common.h" @@ -465,6 +466,28 @@ const char udp_tunnel_type_names[][ETH_GSTRING_LEN] = { static_assert(ARRAY_SIZE(udp_tunnel_type_names) == __ETHTOOL_UDP_TUNNEL_TYPE_CNT); +const char ulp_ddp_caps_names[][ETH_GSTRING_LEN] = { + [ULP_DDP_C_NVME_TCP_BIT] = "nvme-tcp-ddp", + [ULP_DDP_C_NVME_TCP_DDGST_RX_BIT] = "nvme-tcp-ddgst-rx-offload", +}; +static_assert(ARRAY_SIZE(ulp_ddp_caps_names) == ULP_DDP_C_COUNT); + +const char ulp_ddp_stats_names[][ETH_GSTRING_LEN] = { + [ETHTOOL_A_ULP_DDP_STATS_UNSPEC] = "unspec", + [ETHTOOL_A_ULP_DDP_STATS_PAD] = "pad", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD] = "rx_nvmeotcp_sk_add", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL] = "rx_nvmeotcp_sk_add_fail", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL] = "rx_nvmeotcp_sk_del", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP] = "rx_nvmeotcp_ddp_setup", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL] = "rx_nvmeotcp_ddp_setup_fail", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN] = "rx_nvmeotcp_ddp_teardown", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP] = "rx_nvmeotcp_drop", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC] = "rx_nvmeotcp_resync", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS] = "rx_nvmeotcp_packets", + [ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES] = "rx_nvmeotcp_bytes", +}; +static_assert(ARRAY_SIZE(ulp_ddp_stats_names) == __ETHTOOL_A_ULP_DDP_STATS_CNT); + /* return false if legacy contained non-0 deprecated fields * maxtxpkt/maxrxpkt. rest of ksettings always updated */ diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 28b8aaaf9bcb..ebb0abec04a3 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -36,6 +36,8 @@ extern const char sof_timestamping_names[][ETH_GSTRING_LEN]; extern const char ts_tx_type_names[][ETH_GSTRING_LEN]; extern const char ts_rx_filter_names[][ETH_GSTRING_LEN]; extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN]; +extern const char ulp_ddp_caps_names[][ETH_GSTRING_LEN]; +extern const char ulp_ddp_stats_names[][ETH_GSTRING_LEN]; int __ethtool_get_link(struct net_device *dev); diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c index 3f7de54d85fb..959a1b61e8e7 100644 --- a/net/ethtool/strset.c +++ b/net/ethtool/strset.c @@ -2,6 +2,7 @@ #include #include +#include #include "netlink.h" #include "common.h" @@ -105,6 +106,16 @@ static const struct strset_info info_template[] = { .count = __ETHTOOL_A_STATS_RMON_CNT, .strings = stats_rmon_names, }, + [ETH_SS_ULP_DDP_CAPS] = { + .per_dev = false, + .count = ULP_DDP_C_COUNT, + .strings = ulp_ddp_caps_names, + }, + [ETH_SS_ULP_DDP_STATS] = { + .per_dev = false, + .count = __ETHTOOL_A_ULP_DDP_STATS_CNT, + .strings = ulp_ddp_stats_names, + }, }; struct strset_req_info { From patchwork Fri Feb 3 13:26: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: 13127516 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451B9C05027 for ; Fri, 3 Feb 2023 13:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232645AbjBCN1v (ORCPT ); Fri, 3 Feb 2023 08:27:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjBCN1k (ORCPT ); Fri, 3 Feb 2023 08:27:40 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2048.outbound.protection.outlook.com [40.107.101.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00C38E079 for ; Fri, 3 Feb 2023 05:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EzDdhxTvHCRsO8ikE/tCX1ZVgpRL7KV0925C6I1kt2F4hZ3nhQgXblkmM9xqgJDP/eROKTJjWifYOvabxyb39rMxl+hejGzaJIY4g36jpiFEhAovpHfQL60ywDPgbUeCCMB4xmGk1ODODPEVLDNbEreyAR5TXtzOn5PREHm+98AcqNaOWEQHl9VrFfXtIXYY4PVHkmoAzcKJoiJxIHxfsVmdLP3GGjYGgagoHp2hG7obykzaO/d+5EBk11L6+6YaDYo0xyt6mnf2V3FCaqGy1o4Rv6SAFw2vMamyTu39YpPaZcC2lVTeTxJOKpQSS34Ja0KusLmm78zwV8LbNE2u+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fwRRsayFrS3yenR8XvXUFZCiV/4l2ag6XJS/D31XDb8=; b=Ca9putXjptaFJWnlpb586dYuq3Z0CwUAyXp7NnMobT/oyFu0dgH5jGfW1BAsdqcNg49t5jd/BIvza/qCyczBMM5zZY0cw+f2lRwXlAZ7j/7ULHg1gmKMd/9j3UYVwSQTeZ3uYWfxiPV2usefIdyV+cRkxPFB+QA5grYwb3u/XQ7xPGn6JUtQN+R4tNGkPOKdy9xRf3Mx16uOUPILCBUdVK8tTy3OQG9FLdWFM1TCfWxfd6WSy9kzn8NGx/AxVCYmsUP1E4y72l7/23gcUyep+sd3a55QGGZpNmY1I7Uun231/po7y8oEQOv6J+wb+IEOAd9rr+b//sUdlSRz9aXDNg== 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=fwRRsayFrS3yenR8XvXUFZCiV/4l2ag6XJS/D31XDb8=; b=fipk2Cw/rIqePh4r/bBL02zqo1zNdFnV8MBDQ+R/YNRqxSM23aR58EARx5FpLIsbC7IgpRdKOxnMFCo6G55PT/U8obJo6x0Z3n2sT4rK4ukOkcxltNL6w+S+f/Sfogx1jnoOvxbcXWdutWVTlioTEXZVjd4M7GpPQei2lI3OvDiBG6TL8r7Y9I+ghCrIHPB9tlDDBZf9cUsSapkkU3o1pBHwIR3f5igwzfnRc6fvVHuV0s7YTwisrF4FOqpgbq4tCTlejGUkUb3icTcZWfXMXTOXUulrM3adXe+f+zd6cUJD8rJxFzQomZJzCu4q2mmcbA5y71LQ8G5YY897zo1iJQ== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:27:33 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27:33 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 03/25] net/ethtool: add ULP_DDP_{GET,SET} operations for caps and stats Date: Fri, 3 Feb 2023 15:26:43 +0200 Message-Id: <20230203132705.627232-4-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0075.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::23) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: 7acdb766-2bea-4aa6-fd99-08db05ea6827 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 58H6pnCYyz8pwXgCw1sHPbUvThGuYxPCJhZQVwXF9kR0bpu/mgvwVQ04joAjrm08kgozyxuzhu+zcrFU9R44HYWfaAmnblmFQsv/TOPIknAtX14uZMSjWL4Fb3r3KhspMihzTmiCHOXCaWc2FORUAnVzbjGjdR0DJ/pGspSMwnM5n3w9L3h6UXSV3HQha9SI9mrAhBFpTljCMNwo05RB2LFIQQMRykTO/oVWmIY/ZW6QO0rco976UFqa7uccBE+6QkXQcRNMhFIL7MNKjzGwP5xg87g+CKyrL3KkcWfPINdS+OkgMlpsrAG18SKmXBfTYgivMn75Tqpa9Z+GshC87Fqk3vdzAGeepx79nHFSxIJAw4jd66qmmDNM8LbjfjonDoJWWmyN8aGpO5Vht27jbwbvZozUPUjGlonXCzSfC1pYRjVApuio5nqKjMQYnKsQh2w2VQAfIJWNOiKtiCr3nDwoCq7PmTaNWjgYiukDaM5AK1M/UQqx8rpICWRisrK2AeLHkK0hjPTCyhqfPOPZ/Vky0Buktlsehr2m4VI51xzX+oVXOqc50dW1oRtLCMtF+cxLWofnLg4skJtnTclp1iTbV7a9789bUkzoEttOcSEBqJeYlXrlFGYYzFL9Sp5eFEgstAjM/kKshbbVF2apAA== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(30864003)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oSyZGIZyZN8RJHRkluEuC9uIsieS7Q72G9N6krYnq1zqU0e9TvpiA/AIbZYN2P3Bij9BfxKxMwcIVRTNEH2QcNjazMFDtxWR9nLJbeGF1ev8lZ+fv95JzjqDa7QXj134XS0nS2ofV57A8f5qRKiffi9nR1Tv5lXhndKh0QyWzbKuImXDtwb7Hy2sKyz2cQY3Nz4D8VvyGD21M4RH+wAtBm9JTHTFECvPM33/HOBOXEwMN1fnsUvZrdunoQhM8bTEQqfUJJ/9eI/nLF1dZYiR821GbTxcj0ZF4nuPAfK15mnHW+LAxKIL5gemqxF7jyfZ7ypZicSazxd5kPO/1z4lMyKz5m2/+ZBCjE+bhCw107Np3ksW8qDUrIv+5oKvVz8CxY2dNNwVo1H/rUsz046TYbF9CpdUaXqSKUvWjMF/XWJke3/DUJE4XNX32uJVjmhp2hAbuNaGioNIWXj9cXkcl6S2oBXLflYoBkXTVATII5aoGTIHg58bZrUM5L7FcTEvuLFXirrNMWkx0YhhKGjLaHVF+T1fgmxrAPX9a1JudQAqUvW2xx2YHnmLefmGGtDUxVyap6tnO+I6Z7MOE8hKNMobLvRoyelpU94yY10AD++Gtg7tD0pqQ6aWdsgVBbWVljyfk8Vuc3AB+q/C5v5iRIKm18plTVeZ6zdZN3euaEnlYXJ2by+IRPlgXBp/2OedP9+Q15imfi4d9c0cC7//0DS1rRJmTMsWI4Nmgei5O7zJHKVQcnYKuLrk9kUD+NhhxL8BEfgkLuvA7lKpgG5J3n11YDRX00iy0Zcm67L/pl4PHtF7R5aIwPXQVaNU8BfRjwkdDsbgsIxS3QQEr7VXuj2roW/1Qd8nVmiLyJR17VGSq4Cyfqf1R8872MyS3uBVGo8pFZfeH0ez85pGYPI0v4domO0yEIKa3E2RuIcWb6HZ0swFQSAM+P4sTaIxjHXHpCgqSalAOxU3iPRkKTR6F02V0oB2OQtIFCKbOXwGNvwPlUlaEegOZZhHElfHIzORE9pHBJpW9OauBB1JSfbkvQ09LFPAy0tjmSJ/yMEwx4SJ0NRYSQJIuPnZZ0K2mAswbbnzXlm8dbObCKS8UzOl/TrNx59GVoTh1rzIIObUp5rjYlklk/iYSS/iVgoC5wKxY78V5fhHMmujigkz2Iso7/rOfeGZovfODL0/ToCEDF0KVCp2z3VR1SDLBfP+MGJqBuU0LO5pE5pd5lFlCDFO+gkrTw5Ji/Odpi/XmvNSyw9Ry6zzoB4/tAYbQhjYXYdZnvYlVeNzQSm42DEVoWZbpsWjHWn9W+HCIU+FEZgCp4xMDnwHS+/9SNwYlHHbBF+pC4VOs3b/LC+DAuI8gRYNhqQ+PwbZ993yWEqlPzNMSPZgGlo9bDaxsREGWXCALrd65ub2eKSOWAOCj8uRDT+Q1FW8oCcim/ebXxPtwBevKgLDZHvjqKjX0axumg0oKmezjcG2GvP8bl8eM1pwlAAsyq7T/yQxOf3HKQHpVObuGueQcGOGAz7XxZ9YTLjmGZIGF66369098WQUndh9wi7ZGQvNAs3BArjEZNo7aSXQSa7UI+ZyFnwIY3PEztfgC+hC X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7acdb766-2bea-4aa6-fd99-08db05ea6827 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:33.2400 (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: aXDPiYWiC0tPO0QgEh4lendhAqS4Dz1l2xL9B8V8FCJU9eqrzJeQLSAdDt3uO1fYP43kIiuaGA/sqiLxXWxfsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This commit adds: - 3 new netlink messages: * ULP_DDP_GET: returns a bitset of supported and active capabilities * ULP_DDP_SET: tries to activate requested bitset and returns results * ULP_DDP_NTF: notification for capabilities change Rename and export bitset_policy for use in ulp_ddp.c. ULP DDP capabilities handling is similar to netdev features handling. If a ULP_DDP_GET message has requested statistics via the ETHTOOL_FLAG_STATS header flag, then statistics are returned to userspace. ULP_DDP_GET request: (header only) ULP_DDP_GET reply: HW (bitset) ACTIVE (bitset) STATS (nest, optional) STATS_xxxx (u64) .... ULP_DDP_SET request: WANTED (bitset) ULP_DDP_SET reply: WANTED (bitset) ACTIVE (bitset) Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Acked-by: Jakub Kicinski --- include/uapi/linux/ethtool_netlink.h | 18 ++ net/ethtool/Makefile | 2 +- net/ethtool/bitset.c | 20 +- net/ethtool/netlink.c | 20 ++ net/ethtool/netlink.h | 4 + net/ethtool/ulp_ddp.c | 316 +++++++++++++++++++++++++++ 6 files changed, 369 insertions(+), 11 deletions(-) create mode 100644 net/ethtool/ulp_ddp.c diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 1722581b2db6..f6bac0ae15f6 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -57,6 +57,8 @@ enum { ETHTOOL_MSG_PLCA_GET_STATUS, ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET, + ETHTOOL_MSG_ULP_DDP_GET, + ETHTOOL_MSG_ULP_DDP_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -109,6 +111,9 @@ enum { ETHTOOL_MSG_PLCA_NTF, ETHTOOL_MSG_MM_GET_REPLY, ETHTOOL_MSG_MM_NTF, + ETHTOOL_MSG_ULP_DDP_GET_REPLY, + ETHTOOL_MSG_ULP_DDP_SET_REPLY, + ETHTOOL_MSG_ULP_DDP_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -974,6 +979,19 @@ enum { /* ULP DDP */ +enum { + ETHTOOL_A_ULP_DDP_UNSPEC, + ETHTOOL_A_ULP_DDP_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_ULP_DDP_HW, /* bitset */ + ETHTOOL_A_ULP_DDP_ACTIVE, /* bitset */ + ETHTOOL_A_ULP_DDP_WANTED, /* bitset */ + ETHTOOL_A_ULP_DDP_STATS, /* nest - _A_ULP_DDP_STATS_* */ + + /* add new constants above here */ + __ETHTOOL_A_ULP_DDP_CNT, + ETHTOOL_A_ULP_DDP_MAX = __ETHTOOL_A_ULP_DDP_CNT - 1 +}; + enum { ETHTOOL_A_ULP_DDP_STATS_UNSPEC, ETHTOOL_A_ULP_DDP_STATS_PAD, diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile index 504f954a1b28..a2fdc5ed7655 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile @@ -8,4 +8,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \ linkstate.o debug.o wol.o features.o privflags.o rings.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ - module.o pse-pd.o plca.o mm.o + module.o pse-pd.o plca.o ulp_ddp.o diff --git a/net/ethtool/bitset.c b/net/ethtool/bitset.c index 0515d6604b3b..1bef91fcce4b 100644 --- a/net/ethtool/bitset.c +++ b/net/ethtool/bitset.c @@ -302,7 +302,7 @@ int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val, return -EMSGSIZE; } -static const struct nla_policy bitset_policy[] = { +const struct nla_policy ethnl_bitset_policy[] = { [ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG }, [ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32, ETHNL_MAX_BITSET_SIZE), @@ -327,11 +327,11 @@ static const struct nla_policy bit_policy[] = { */ int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; int ret; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, bitset, - bitset_policy, NULL); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, bitset, + ethnl_bitset_policy, NULL); if (ret < 0) return ret; @@ -553,15 +553,15 @@ int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits, const struct nlattr *attr, ethnl_string_array_t names, struct netlink_ext_ack *extack, bool *mod) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; unsigned int change_bits; bool no_mask; int ret; if (!attr) return 0; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr, - bitset_policy, extack); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, attr, + ethnl_bitset_policy, extack); if (ret < 0) return ret; @@ -606,7 +606,7 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, ethnl_string_array_t names, struct netlink_ext_ack *extack) { - struct nlattr *tb[ARRAY_SIZE(bitset_policy)]; + struct nlattr *tb[ARRAY_SIZE(ethnl_bitset_policy)]; const struct nlattr *bit_attr; bool no_mask; int rem; @@ -614,8 +614,8 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, if (!attr) return 0; - ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr, - bitset_policy, extack); + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_bitset_policy) - 1, attr, + ethnl_bitset_policy, extack); if (ret < 0) return ret; no_mask = tb[ETHTOOL_A_BITSET_NOMASK]; diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 08120095cc68..33f1b0992383 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -306,6 +306,8 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops, [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, + [ETHTOOL_MSG_ULP_DDP_GET] = ðnl_ulp_ddp_request_ops, + [ETHTOOL_MSG_ULP_DDP_SET] = ðnl_ulp_ddp_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -669,6 +671,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, [ETHTOOL_MSG_PLCA_NTF] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_MM_NTF] = ðnl_mm_request_ops, + [ETHTOOL_MSG_ULP_DDP_NTF] = ðnl_ulp_ddp_request_ops, }; /* default notification handler */ @@ -764,6 +767,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MM_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_ULP_DDP_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) @@ -1156,6 +1160,22 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_mm_set_policy, .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_ULP_DDP_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_ulp_ddp_get_policy, + .maxattr = ARRAY_SIZE(ethnl_ulp_ddp_get_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_ULP_DDP_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_default_set_doit, + .policy = ethnl_ulp_ddp_set_policy, + .maxattr = ARRAY_SIZE(ethnl_ulp_ddp_set_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index ae0732460e88..4852f567c0be 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -395,10 +395,12 @@ extern const struct ethnl_request_ops ethnl_rss_request_ops; extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; extern const struct ethnl_request_ops ethnl_plca_status_request_ops; extern const struct ethnl_request_ops ethnl_mm_request_ops; +extern const struct ethnl_request_ops ethnl_ulp_ddp_request_ops; extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_COUNTS_ONLY + 1]; +extern const struct nla_policy ethnl_bitset_policy[ETHTOOL_A_BITSET_MASK + 1]; extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1]; extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1]; extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_HEADER + 1]; @@ -441,6 +443,8 @@ extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1] extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; +extern const struct nla_policy ethnl_ulp_ddp_get_policy[ETHTOOL_A_ULP_DDP_HEADER + 1]; +extern const struct nla_policy ethnl_ulp_ddp_set_policy[ETHTOOL_A_ULP_DDP_WANTED + 1]; int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); diff --git a/net/ethtool/ulp_ddp.c b/net/ethtool/ulp_ddp.c new file mode 100644 index 000000000000..e5451689fef9 --- /dev/null +++ b/net/ethtool/ulp_ddp.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * + * ulp_ddp.c + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ + +#include "netlink.h" +#include "common.h" +#include "bitset.h" +#include + +#define ETHTOOL_ULP_DDP_STATS_CNT \ + (__ETHTOOL_A_ULP_DDP_STATS_CNT - (ETHTOOL_A_ULP_DDP_STATS_PAD + 1)) + +static struct ulp_ddp_netdev_caps *netdev_ulp_ddp_caps(struct net_device *dev) +{ +#ifdef CONFIG_ULP_DDP + return &dev->ulp_ddp_caps; +#else + return NULL; +#endif +} + +static const struct ulp_ddp_dev_ops *netdev_ulp_ddp_ops(struct net_device *dev) +{ +#ifdef CONFIG_ULP_DDP + return dev->netdev_ops->ulp_ddp_ops; +#else + return NULL; +#endif +} + +/* ULP_DDP_GET */ + +struct ulp_ddp_req_info { + struct ethnl_req_info base; +}; + +struct ulp_ddp_reply_data { + struct ethnl_reply_data base; + DECLARE_BITMAP(hw, ULP_DDP_C_COUNT); + DECLARE_BITMAP(active, ULP_DDP_C_COUNT); + struct ethtool_ulp_ddp_stats stats; +}; + +#define ULP_DDP_REPDATA(__reply_base) \ + container_of(__reply_base, struct ulp_ddp_reply_data, base) + +const struct nla_policy ethnl_ulp_ddp_get_policy[] = { + [ETHTOOL_A_ULP_DDP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_stats), +}; + +static int ulp_ddp_put_stats64(struct sk_buff *skb, int attrtype, const u64 *val, + unsigned int count) +{ + struct nlattr *nest; + unsigned int i, attr; + + nest = nla_nest_start(skb, attrtype); + if (!nest) + return -EMSGSIZE; + + /* skip attributes unspec & pad */ + attr = ETHTOOL_A_ULP_DDP_STATS_PAD + 1; + for (i = 0 ; i < count; i++, attr++) + if (nla_put_u64_64bit(skb, attr, val[i], ETHTOOL_A_ULP_DDP_STATS_PAD)) + goto nla_put_failure; + + nla_nest_end(skb, nest); + return 0; + +nla_put_failure: + nla_nest_cancel(skb, nest); + return -EMSGSIZE; +} + +static int ulp_ddp_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + struct genl_info *info) +{ + const struct ulp_ddp_dev_ops *ops = netdev_ulp_ddp_ops(reply_base->dev); + struct ulp_ddp_netdev_caps *caps = netdev_ulp_ddp_caps(reply_base->dev); + struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + + if (!caps || !ops) + return -EOPNOTSUPP; + + bitmap_copy(data->hw, caps->hw, ULP_DDP_C_COUNT); + bitmap_copy(data->active, caps->active, ULP_DDP_C_COUNT); + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + if (!ops->get_stats) + return -EOPNOTSUPP; + ops->get_stats(reply_base->dev, &data->stats); + } + return 0; +} + +static int ulp_ddp_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + unsigned int len = 0; + int ret; + + ret = ethnl_bitset_size(data->hw, NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + len += ret; + ret = ethnl_bitset_size(data->active, NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + len += ret; + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + len += nla_total_size_64bit(sizeof(u64)) * ETHTOOL_ULP_DDP_STATS_CNT; + len += nla_total_size(0); /* nest */ + } + return len; +} + +static int ulp_ddp_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct ulp_ddp_reply_data *data = ULP_DDP_REPDATA(reply_base); + bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + int ret; + + ret = ethnl_put_bitset(skb, ETHTOOL_A_ULP_DDP_HW, data->hw, + NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + + ret = ethnl_put_bitset(skb, ETHTOOL_A_ULP_DDP_ACTIVE, data->active, + NULL, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + return ret; + + if (req_base->flags & ETHTOOL_FLAG_STATS) { + ret = ulp_ddp_put_stats64(skb, ETHTOOL_A_ULP_DDP_STATS, + (u64 *)&data->stats, + ETHTOOL_ULP_DDP_STATS_CNT); + if (ret < 0) + return ret; + } + return ret; +} + +/* ULP_DDP_SET */ + +const struct nla_policy ethnl_ulp_ddp_set_policy[] = { + [ETHTOOL_A_ULP_DDP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), + [ETHTOOL_A_ULP_DDP_WANTED] = NLA_POLICY_NESTED(ethnl_bitset_policy), +}; + +static int ulp_ddp_send_reply(struct net_device *dev, struct genl_info *info, + const unsigned long *wanted, + const unsigned long *wanted_mask, + const unsigned long *active, + const unsigned long *active_mask, bool compact) +{ + struct sk_buff *rskb; + void *reply_payload; + int reply_len = 0; + int ret; + + reply_len = ethnl_reply_header_size(); + ret = ethnl_bitset_size(wanted, wanted_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto err; + reply_len += ret; + ret = ethnl_bitset_size(active, active_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto err; + reply_len += ret; + + rskb = ethnl_reply_init(reply_len, dev, ETHTOOL_MSG_ULP_DDP_SET_REPLY, + ETHTOOL_A_ULP_DDP_HEADER, info, + &reply_payload); + if (!rskb) { + ret = -ENOMEM; + goto err; + } + + ret = ethnl_put_bitset(rskb, ETHTOOL_A_ULP_DDP_WANTED, wanted, + wanted_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto nla_put_failure; + ret = ethnl_put_bitset(rskb, ETHTOOL_A_ULP_DDP_ACTIVE, active, + active_mask, ULP_DDP_C_COUNT, + ulp_ddp_caps_names, compact); + if (ret < 0) + goto nla_put_failure; + + genlmsg_end(rskb, reply_payload); + ret = genlmsg_reply(rskb, info); + return ret; + +nla_put_failure: + nlmsg_free(rskb); + WARN_ONCE(1, "calculated message payload length (%d) not sufficient\n", + reply_len); +err: + GENL_SET_ERR_MSG(info, "failed to send reply message"); + return ret; +} + +static int ulp_ddp_set_validate(struct ethnl_req_info *req_info, struct genl_info *info) +{ + const struct ulp_ddp_dev_ops *ops; + + if (GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_ULP_DDP_WANTED)) + return -EINVAL; + + ops = netdev_ulp_ddp_ops(req_info->dev); + if (!ops || !ops->set_caps || !netdev_ulp_ddp_caps(req_info->dev)) + return -EOPNOTSUPP; + + return 1; +} + +static int ulp_ddp_set(struct ethnl_req_info *req_info, struct genl_info *info) +{ + DECLARE_BITMAP(old_active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(new_active, ULP_DDP_C_COUNT); + DECLARE_BITMAP(req_wanted, ULP_DDP_C_COUNT); + DECLARE_BITMAP(req_mask, ULP_DDP_C_COUNT); + DECLARE_BITMAP(all_bits, ULP_DDP_C_COUNT); + DECLARE_BITMAP(tmp, ULP_DDP_C_COUNT); + const struct ulp_ddp_dev_ops *ops; + struct ulp_ddp_netdev_caps *caps; + int ret; + + caps = netdev_ulp_ddp_caps(req_info->dev); + ops = netdev_ulp_ddp_ops(req_info->dev); + ret = ethnl_parse_bitset(req_wanted, req_mask, ULP_DDP_C_COUNT, + info->attrs[ETHTOOL_A_ULP_DDP_WANTED], + ulp_ddp_caps_names, info->extack); + if (ret < 0) + return ret; + + /* if (req_mask & ~all_bits) */ + bitmap_fill(all_bits, ULP_DDP_C_COUNT); + bitmap_andnot(tmp, req_mask, all_bits, ULP_DDP_C_COUNT); + if (!bitmap_empty(tmp, ULP_DDP_C_COUNT)) + return -EINVAL; + + /* new_active = (old_active & ~req_mask) | (wanted & req_mask) + * new_active &= caps_hw + */ + bitmap_copy(old_active, caps->active, ULP_DDP_C_COUNT); + bitmap_and(req_wanted, req_wanted, req_mask, ULP_DDP_C_COUNT); + bitmap_andnot(new_active, old_active, req_mask, ULP_DDP_C_COUNT); + bitmap_or(new_active, new_active, req_wanted, ULP_DDP_C_COUNT); + bitmap_and(new_active, new_active, caps->hw, ULP_DDP_C_COUNT); + if (!bitmap_equal(old_active, new_active, ULP_DDP_C_COUNT)) { + ret = ops->set_caps(req_info->dev, new_active, info->extack); + if (ret < 0) + return ret; + bitmap_copy(new_active, caps->active, ULP_DDP_C_COUNT); + } + + if (!(req_info->flags & ETHTOOL_FLAG_OMIT_REPLY)) { + bool compact = req_info->flags & ETHTOOL_FLAG_COMPACT_BITSETS; + DECLARE_BITMAP(wanted_diff_mask, ULP_DDP_C_COUNT); + DECLARE_BITMAP(active_diff_mask, ULP_DDP_C_COUNT); + + /* wanted_diff_mask = req_wanted ^ new_active + * active_diff_mask = old_active ^ new_active -> mask of bits that have changed + * wanted_diff_mask &= req_mask -> mask of bits that have diff value than wanted + * req_wanted &= wanted_diff_mask -> bits that have diff value than wanted + * new_active &= active_diff_mask -> bits that have changed + */ + bitmap_xor(wanted_diff_mask, req_wanted, new_active, ULP_DDP_C_COUNT); + bitmap_xor(active_diff_mask, old_active, new_active, ULP_DDP_C_COUNT); + bitmap_and(wanted_diff_mask, wanted_diff_mask, req_mask, ULP_DDP_C_COUNT); + bitmap_and(req_wanted, req_wanted, wanted_diff_mask, ULP_DDP_C_COUNT); + bitmap_and(new_active, new_active, active_diff_mask, ULP_DDP_C_COUNT); + ret = ulp_ddp_send_reply(req_info->dev, info, + req_wanted, wanted_diff_mask, + new_active, active_diff_mask, + compact); + if (ret < 0) + return ret; + } + + /* return 1 to notify */ + return bitmap_equal(old_active, new_active, ULP_DDP_C_COUNT); +} + +const struct ethnl_request_ops ethnl_ulp_ddp_request_ops = { + .request_cmd = ETHTOOL_MSG_ULP_DDP_GET, + .reply_cmd = ETHTOOL_MSG_ULP_DDP_GET_REPLY, + .hdr_attr = ETHTOOL_A_ULP_DDP_HEADER, + .req_info_size = sizeof(struct ulp_ddp_req_info), + .reply_data_size = sizeof(struct ulp_ddp_reply_data), + + .prepare_data = ulp_ddp_prepare_data, + .reply_size = ulp_ddp_reply_size, + .fill_reply = ulp_ddp_fill_reply, + + .set_validate = ulp_ddp_set_validate, + .set = ulp_ddp_set, + .set_ntf_cmd = ETHTOOL_MSG_ULP_DDP_NTF, +}; From patchwork Fri Feb 3 13:26: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: 13127517 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EACFC05027 for ; Fri, 3 Feb 2023 13:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbjBCN2B (ORCPT ); Fri, 3 Feb 2023 08:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjBCN1w (ORCPT ); Fri, 3 Feb 2023 08:27:52 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4B895D2D for ; Fri, 3 Feb 2023 05:27:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sassqy6BAVd3t+oc3EoxRDJUsetuFPNQcUi0eEyWrUG+UcxhtOmpe2h1eq069WAE9xlZVF3UzsPjqydVphuzubzCeKhchqyjEITugLbXVG6Y2yT/BNA03QuSLUs3BRpDOvvGne27KwW3BR9tm/NYPpEtCvtkN9tvxufJIq0tSj7w6sXeNPicVapFRNYrSTi+aOmIyC+iX/Czp7CvzDjen0oC/k5kw/T1GaCzyPEFZnCjpqpJ4J1b85HMuONoqwrUJVCXG6+F5Cnzppbaz33fSpaw1Y4R7qcPNs0Y1Z4QeWrWla3T6zaDgW0fDlTqVt7wWqqr3Q5aKR91E4FFeCwEWA== 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=rD4XJY90UfXokc+MvVFaAmKoINQuVQA3I8EhIryF778=; b=WvGXNmfnwSj8ZDeIFPHDwqEEMLKr861L4jnOOce30lYmwOaR1oSy9K8oob06lLRf/sm41iDhFep528vgkxA7hr3SDIH7pr0zllrIFg+LlWxxUS8k6hrc/ZM0DtOoeJL64v3xiesmiI04oA43bdGCmibrVrhBaApBZL7uOYnILI0DiBrvlh7JDZBzRyzlI51fTgfupA/ESPoR30EpWH86Fd+3x4mcKvTWb/MrOLxzW3706RpednVnoRxElsEzbCQcl6CbigUs7KK43lZcJtVDTTjGA2AgI1MoJuKUnznn1bjVH6PV4q831UIngMSyweJL5Ig2I42G3bQROpfJogK25g== 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=rD4XJY90UfXokc+MvVFaAmKoINQuVQA3I8EhIryF778=; b=RTWpzHL4Mcs2oWjKLxBipcmufU8ZjAjcBFn09DMwjZlkPC4Y8WicchHJe1rlB/FhbajxEGh892qNRVEgErrg8bqOdIbmnkZIRUTkkicdSsrOQHnIt6lpqa+xCJSNYLe70XvvlqCt3cFh+90a4CnQXezc8Qt2ez4NVypT9DX4zBCb7L8WdZeP8UqFKXKYDgixG0rrvYQjvp/+Vak6dhJ8BjlgogELMKF5oK2ciANs9QtpW0nwLnoDwVswj6t+kYPANFRTCvYnIyeeKj40vbL68plF0YRxTuGxGPQjpNDgNdUaFRFUXLe2b5ETwooauhN9Boml6p4xnAFoiO2MbtvdlQ== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:27:44 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27:43 +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 Subject: [PATCH v11 04/25] Documentation: document netlink ULP_DDP_GET/SET messages Date: Fri, 3 Feb 2023 15:26:44 +0200 Message-Id: <20230203132705.627232-5-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P123CA0105.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::20) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: d214b4b5-8226-44ce-d1ea-08db05ea6e6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8o5WHXI2xgu0CEcnLKI1swhFVgtR44zLUtEWL/5jvvULdtx/AEwTTcwiAfv65JmLnsDnWxZyVFpTYdWrL54B2Qk3a/JOC3hOESgIE7NvPgSY4Wlc/EGeFtvQA1sBsGc1/cKCg1co9Ja/vgDV7c96LyGD98PiLxezYoYZR+CwatffBE/hbuxhtu2LFlSCH4BdbxXwQyQON2OPC9/nXwDChKVVZJpV2RsTCzQodniyUY3vkzivYhGjnRTHgegGw+hkM5XyccHeCpt+WR+y4ZvasIoxhk7xZmUnRgLOA2UEYP5gy+9TeWlgEVwia9/lfDAvLD0qmDb1DOrf1HwTCWhZFvKZc0FEuKi0S6jknteVN3SpKAtxJLCdThb4aMxlLLtdv6rbQul8lKDkw41H+ireBFzkNtW37BPTqDP4TSjexZwDHPkfnMGdjTS30q3u5wp96sqRSGqWAhS55zFzKlCKOYwOszgg4gtj2Jz8Sx1dZ8jvaD03Y9y0ZBQl6Du/WYEDi/bdMwgHHo4qmrI9dqLNuoDonXAGu5KtB0olnBBVn7VIFj5kb2FVT47pJNBekRz6Q2/wURDYr2bqnAxU62FP5syDtaPsEkGkrHa+zotGCBLQ4vQfz6Vi7JzodbV0UtxQdTye+l+uBTkMhWkY59chcw== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(15650500001)(36756003)(83380400001)(2616005)(316002)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u/dbFfvA+o/6h+ymM5MTeHaGNIdnDYI6bVqxLpyD+nt5XrBu8+dOpQ/ROT+Exp0tWxNQSJD6S4Duxx+xIDDarVlI1pi/AJl/oCB5hAfU5Oh9dnD2LyAM2fXyx2PKwMrxZMLbEXr7fADKOtqCghggnN+ZWe+CuOODHObHrbwparXfzenHURbflXJPLnMBQ9K4uu/vGtDVDpCHG/Yz120PYru73XUWZf0Y7vNxjzJf7/pRsfEhWDj3++RQnGF1mUyB0zib9Bclqe0pkRYk9n7qDoKqr8yFAcTvX4qlNFTk2epqbpjor/boLt3B+JzdywvwsTF59xNHeHzrsn6CmzOOBdQO+CuHVVkLNXuC+IwDi9vXnxi30Z3fGvoC0bsbj+UVFeaDKPcx84KeXbv7pNT3mrzxnedwD93zub7Mts2JVkpjCvcxFwEyDYytNFQYW41aLZd0iP1Zoqo6j1sb2eMh/b5eh05oEG+oOjnMIGXxKjDd1cddYwiGIo6i2y5NpZGOCi6cerQkuDpcoxQaJFsKceezQ66Zehe0amJDQseperEWah5X9C2Sh75vDCgXctb9YBQMPA6OBqDNQrn50/P/1v/KjWfNXHdqCnejZPMahJbidFS4qNdOpM7nXcameDC2dpy0PO56U3PkuAjPriUYtwHUjC80j1A9a5HSHxnZ09rDmtuYByGLe8huly6Ptwa7mbYaEx3qouL5D2ULFzWq8o0UBIsmHPxlfykAO98We8lrU1TkiApVlm/XyX7dKHU+q6L+L8UnmdcS6ud3pKeE7+AJZYdLHe2nTDDNdabHg/i7bqnP3dhnI5TZ74Ij007swbvYVF2rnZ+3Vvw2xfFNoW/lg5vVtxqWEJmwVkcaQIoY8Pf7GLqwtaH5ttPnMer7qvjvo/hucSUgCDb3kLzMmYvh99aDC2CMcmGyypZqjogER4wP77szoOzhgEYEIs0lW0l2F9Rhpxv0Un3/UsaKFuO7h3HQ/YqjL/YiKI5y5PeyX0jyfZAAEehFR/NPBndzpjFEY+hdGPTdfAsQv00j+uGSw8Z7b6zVPoGKGoFpaWWg9J4xSVtgeu60Nv2Kl/g4LECny6sSwDJ0KcxgLYSaAS397q7+qC59bAl9gNr/NrJF9aAQhCstyH+BVKKIjlQWQYEWusCyj05GpV1EkrRPNex9JD0GARhhqnPVtmlcwLrdfPARZLxhWEpfDDFcSHyHqPTgaAy6VJQ+fAv9KSUP/37WiGsXLumNBA5zkZ8/F5u9aPElc0Ippj+GTm8tjLZcOI2GYGHuYQwH/W9oM8TSOlQKg7TTklr6vIsvUyXYH1jJfTlq6DrmbiQnMWLgQnpUnrsvwP+7Z9xU/aRI+8N3X51F2ZMXEogWatM1UGbuofB7bxp1GeZ+fJOHxY/+Th4cfsjwnOGwL0VjyGfAzdIDRhCLISWxX5S6l1v2fCr/QdDXgf5pGvEY3z/fQ8laOMkltTT4Qjz3inapK4TUNQbPaGQ9PYiWd2WWFkjIpS5VUA28U2Rtx4HOIq6ReCe9TQgm7VgDKNP5N9nC9jVlOdL3jCNwb5adHoQs1JRsUMb0sy6CpnlvMHOW9fnpiP9/ef3G X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d214b4b5-8226-44ce-d1ea-08db05ea6e6c X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:43.7574 (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: 9nN0xUoNjWjcLWp042SUn6SJcWLVi1YjevfNJ+4vnT8WI0Rzsx4/eib3EtgxVBiPjj9KquOz/aajBcNQHfCdsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add detailed documentation about: - ETHTOOL_MSG_ULP_DDP_GET and ETHTOOL_MSG_ULP_DDP_SET netlink messages - ETH_SS_ULP_DDP_CAPS and ETH_SS_ULP_DDP_STATS stringsets ETHTOOL_MSG_ULP_DDP_GET/SET messages are used to configure ULP DDP capabilities and retrieve ULP DDP statistics. Both statistics and capabilities names can be retrieved dynamically from the kernel via string sets (no need to hardcode them and keep them in sync in ethtool). Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Acked-by: Jakub Kicinski --- Documentation/netlink/specs/ethtool.yaml | 102 +++++++++++++++++++ Documentation/networking/ethtool-netlink.rst | 92 +++++++++++++++++ Documentation/networking/statistics.rst | 1 + 3 files changed, 195 insertions(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 82f4e6f8ddd3..8932cf310f1a 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -236,6 +236,67 @@ attribute-sets: name: stats type: nest nested-attributes: mm-stat + - + name: ulp-ddp-stat + attributes: + - + name: pad + value: 1 + type: pad + - + name: rx-nvmeotcp-sk-add + type: u64 + - + name: rx-nvmeotcp-sk-add-fail + type: u64 + - + name: rx-nvmeotcp-sk-del + type: u64 + - + name: rx-nvmeotcp-ddp-setup + type: u64 + - + name: rx-nvmeotcp-ddp-setup-fail + type: u64 + - + name: rx-nvmeotcp-ddp-teardown + type: u64 + - + name: rx-nvmeotcp-ddp-drop + type: u64 + - + name: rx-nvmeotcp-ddp-resync + type: u64 + - + name: rx-nvmeotcp-ddp-packets + type: u64 + - + name: rx-nvmeotcp-ddp-bytes + type: u64 + - + name: ulp-ddp + attributes: + - + name: header + value: 1 + type: nest + nested-attributes: header + - + name: hw + type: nest + nested-attributes: bitset + - + name: active + type: nest + nested-attributes: bitset + - + name: wanted + type: nest + nested-attributes: bitset + - + name: stats + type: nest + nested-attributes: ulp-ddp-stat operations: enum-model: directional @@ -390,3 +451,44 @@ operations: name: mm-ntf doc: Notification for change in MAC Merge configuration. notify: mm-get + - + name: ulp-ddp-get + doc: Get ULP DDP capabilities and stats + + attribute-set: ulp-ddp + + do: &ulp-ddp-get-op + request: + value: 44 + attributes: + - header + reply: + value: 44 + attributes: + - header + - hw + - active + - stats + dump: *ulp-ddp-get-op + - + name: ulp-ddp-set + doc: Set ULP DDP capabilities + + attribute-set: ulp-ddp + + do: + request: + value: 45 + attributes: + - header + - wanted + reply: + value: 45 + attributes: + - header + - hw + - active + - + name: ulp-ddp-ntf + doc: Notification for change in ULP DDP capabilities + notify: ulp-ddp-get diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index d144e890961d..8390230ca5b5 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -225,6 +225,8 @@ Userspace to kernel: ``ETHTOOL_MSG_RSS_GET`` get RSS settings ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters + ``ETHTOOL_MSG_ULP_DDP_GET`` get ULP DDP capabilities and stats + ``ETHTOOL_MSG_ULP_DDP_SET`` set ULP DDP capabilities ===================================== ================================= Kernel to userspace: @@ -268,6 +270,9 @@ Kernel to userspace: ``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status + ``ETHTOOL_MSG_ULP_DDP_GET_REPLY`` ULP DDP capabilities and stats + ``ETHTOOL_MSG_ULP_DDP_SET_REPLY`` optional reply to ULP_DDP_SET + ``ETHTOOL_MSG_ULP_DDP_NTF`` ULP DDP capabilities notification ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device @@ -1973,6 +1978,93 @@ The attributes are propagated to the driver through the following structure: .. kernel-doc:: include/linux/ethtool.h :identifiers: ethtool_mm_cfg +ULP_DDP_GET +=========== + +Get ULP DDP capabilities for the interface and optional driver-defined stats. + +Request contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested request header + ==================================== ====== ========================== + +Kernel response contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested reply header + ``ETHTOOL_A_ULP_DDP_HW`` bitset dev->ulp_ddp_caps.hw + ``ETHTOOL_A_ULP_DDP_ACTIVE`` bitset dev->ulp_ddp_caps.active + ``ETHTOOL_A_ULP_DDP_STATS`` nested ULP DDP statistics + ==================================== ====== ========================== + + +* If ``ETHTOOL_FLAG_COMPACT_BITSETS`` was set in + ``ETHTOOL_A_HEADER_FLAG``, the bitsets of the reply are in compact + form. In that form, the names for the individual bits can be retrieved + via the ``ETH_SS_ULP_DDP_CAPS`` string set. +* ``ETHTOOL_A_ULP_DDP_STATS`` contains statistics which + are only reported if ``ETHTOOL_FLAG_STATS`` was set in + ``ETHTOOL_A_HEADER_FLAGS``. + +ULP DDP statistics content: + + ===================================================== === =============== + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD`` u64 sockets successfully prepared for offloading + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_ADD_FAIL`` u64 sockets that failed to be prepared for offloading + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_SK_DEL`` u64 sockets where offloading has been removed + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP`` u64 PDUs successfully prepared for Direct Data Placement + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_SETUP_FAIL`` u64 PDUs that failed DDP preparation + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DDP_TEARDOWN`` u64 PDUs done with DDP + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_DROP`` u64 PDUs dropped + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_RESYNC`` u64 resync + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_PACKETS`` u64 offloaded PDUs + ``ETHTOOL_A_ULP_DDP_STATS_RX_NVMEOTCP_BYTES`` u64 offloaded bytes + ===================================================== === =============== + +The names of each statistics are global. They can be retrieved via the +``ETH_SS_ULP_DDP_STATS`` string set. + +ULP_DDP_SET +=========== + +Request to set ULP DDP capabilities for the interface. + +Request contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested request header + ``ETHTOOL_A_ULP_DDP_WANTED`` bitset requested capabilities + ==================================== ====== ========================== + +Kernel response contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_ULP_DDP_HEADER`` nested reply header + ``ETHTOOL_A_ULP_DDP_WANTED`` bitset diff wanted vs. results + ``ETHTOOL_A_ULP_DDP_ACTIVE`` bitset diff old vs. new active + ==================================== ====== ========================== + +Request contains only one bitset which can be either value/mask pair +(request to change specific capabilities and leave the rest) or only a +value (request to set the complete capabilities provided literally). + +Requests are subject to sanity checks by drivers so an optional kernel +reply (can be suppressed by ``ETHTOOL_FLAG_OMIT_REPLY`` flag in +request header) informs client about the actual +results. + +* ``ETHTOOL_A_ULP_DDP_WANTED`` reports the difference between client + request and actual result: mask consists of bits which differ between + requested capability and result (dev->ulp_ddp_caps.active after the + operation), value consists of values of these bits in the request + (i.e. negated values from resulting capabilities). +* ``ETHTOOL_A_ULP_DDP_ACTIVE`` reports the difference between old and + new dev->ulp_ddp_caps.active: mask consists of bits which have + changed, values are their values in new dev->ulp_ddp_caps.active + (after the operation). + + Request translation =================== diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst index 551b3cc29a41..9997c5e8d34e 100644 --- a/Documentation/networking/statistics.rst +++ b/Documentation/networking/statistics.rst @@ -172,6 +172,7 @@ statistics are supported in the following commands: - `ETHTOOL_MSG_PAUSE_GET` - `ETHTOOL_MSG_FEC_GET` - `ETHTOOL_MSG_MM_GET` + - `ETHTOOL_MSG_ULP_DDP_GET` debugfs ------- From patchwork Fri Feb 3 13:26: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: 13127518 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A90A5C05027 for ; Fri, 3 Feb 2023 13:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232632AbjBCN2K (ORCPT ); Fri, 3 Feb 2023 08:28:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbjBCN2D (ORCPT ); Fri, 3 Feb 2023 08:28:03 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3028B7FC for ; Fri, 3 Feb 2023 05:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cv7p1LPoWSxxy48lvy4ibWOSNIATJTUm6nPbLmG6QLUysJG4ktEZ4v7T1Xxfr0MQlC0TOxMfj7kDEQDS6+yVEBbxzDQN3Cs1TQMSkIU/AEPKWkc7q4mbIB0gmbJTtBUC1IZ9kBjVCIanT9ZT3nM75FcNu2bI6bPG3Ryh3Y4JkLdHHHRuYNoCiBZ1ndIQqBQYTcNfHT+Rewb6kK9uI884IcqCYGFuGf850EkRmuj5wPrNgDFIMZ0Xea5SJiF9TZpuxv0mUyJ3X2PmwuEpApQhGmTt6YOqXvJCcSrvnW1qHVhnbSqxXriSBKYa3zpLUIksupkf9i8mGuHl8Zq6FkqTLA== 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=w0J4LimSn8ZUbTM5j1NedghnIFosV0mMEZMKi+xnnuo=; b=BfGbUCzHcCkiTXvQL1JgnQrs7z9eJXcM5HEz8mVrgT+X4LTYkZIw4h2DI6vF05tc4/iFqpn6D6olowF0HhEHpEXJo+ftOI0WO31mZ0ykbkSPconC5xzAXihML8uHrMN7HUpMkzwKKAY2sSf+Y/z1LCy7YMzQqCvWpOwIgZ4fb4rnb61ZdRvzuSJGmYWUhPmmCDsK1RKNfmFxsgRkc0uipJotsKZGIftNsbGQK5C1LRyLQvYyDyOs893B5AkyRewJ4nYXS4W88Bi+hfUmy6vrZiqfbbAx4Q0tINMulWUgY50JMRfTLF+k5rQr1YPOU1POAp3smZ0qjcE+A21n0xJjSA== 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=w0J4LimSn8ZUbTM5j1NedghnIFosV0mMEZMKi+xnnuo=; b=hn0A2jeARREAfSCFIjnds26mGYVUpiBIPo/hxae9WBuVdKt7sMGUg1RUmY/jDGbl70WfUpzXF5LV8reRq91i9kIbSTOCixBAqm9tchgHm9uEnx6+VQvrMeZ2cNwlyF7Rmc788E9XwYUPosI/14U333R6GjFzCKW1JgVM/aMI4QTk+2o+eMXa4yzUOtrcyZwxtoY96mjMB0JnL0mtFMbQTonJDaVDfcB5BkLm7HPBC145EcD/s0aIT0RDguJ0XqQAQFUmAIGOBirpYYj8P4JTCyOr8cJef64msixl9MHXzWe+JykYJwZsJfrKCmPqU6a3QkUDkb4fLWL+7Er12LO5OA== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:27:50 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27:50 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org, Alexander Viro Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 05/25] iov_iter: skip copy if src == dst for direct data placement Date: Fri, 3 Feb 2023 15:26:45 +0200 Message-Id: <20230203132705.627232-6-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0021.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e6d30ed-3983-4fdf-149d-08db05ea7267 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JN3I/AfLboTAXlFa2nKPUNETg56GqSBs+asg0ZJG5wIR2bHyEMsVrTbfVINybM7hYLOJEEyohIxc0aDGC6Gm0BMhxpA2UmxU8KS5e+FWHmCmt3Bx9tcbVXZyxzXh0ZCUX8tFtiHGPOiuzFFrUrEnSfFgrU/y0B/OlKXF6jixBQQnU0F+871ypEKB2umDMMtH5GkIr7LdElZtBhDAK4+M14Y4WI+grrDwKcchlBcwgJ1+kkNejEeQdY/J2CuhkIhI5T7Nj0gq0n+zzFDq9k1qjsgrHpgMVdZ73XpLhzbIhyaNPYWaMLJ74aBnCGD/unH9m6m64jR/RorzUHvQ2wPLDjxcA+jNE8KeS7q2pLQ55BbdXXPG37LqdU0KUlorF/6RXR78rTn/wM0SNzfPFPn9IIWDbuFvXECoSOtJBze2ixunL8abvl9NfqhHhQbYn91vif70GdD15PYkAmTuOIbQMovESKkrSlSPLtbUduXb5w41TcQ+9pyNCN55Mm/cUcop1CEyLj2hu4PbpnZE43ogdJtH+S6JRq1RVePu1abFm0yTnSxo5AjdoN2RThoK/07J3FvXOFIimpfR3T0cf+txDE/JYxA2PF9otS7VnDgJebbOziZtBjJsxblDygV8Dw6DkRnJ6HReZCBi+89hHxIKsMgNYrkmlYGpUa8XARzJrx0JH1usuVPNR2uTpZcQ+mr8 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(6916009)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(921005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bCKsyOB5dvSTmvU1vg1FXPIFjUTB3fISFj6p/YecRhjwFb/wR2e2U5o1aeKec7OoOT4gDZoNewZSexpFo3UHfDAojBwK0nnGXjUx/Zvnfmk/SbziagLu30HdKhE6XYyNrHHBndMXnC15HhhGabFb2qlihGBld/b8YK21hLh/ktGdpwonxpCvS0RU/eN7PJUlchsouh8waCZh31acakucWWI3yWTQY3mRRyDLZV3HUFUL75BN4Sqcfg4pWemZg0A8waRimFH8B2Qwod77OCOXcg5qlO0TVUmhqVrHUxPkN/azsCAPSyLcXi1wTeNXm66Q679Tmfzf8CuKj13PSDatBSqV7eXCEXLl/Y8dEJM5NmfiHzS+gu2yNecPSjeOaFjYUDDaowOPNaRerBH+VJEqRtQcLpvEeoWcYQH0lyxJGl5ocB6/jirmsMWdWnXjxy9KqixCxGdrBqF35cSsX7mBtEYEaqJ/DDhImvYuTYak84UWiMAQiTxmGtYkdlGWSJsEAKZfYTwGnuDfe0kJTZS8S303jYgZJTPezZ8dcLEEC3w8cDoMV0H3LBB5NL5lBnbCCkh2nvywwNyOQwC+Xqu1Z42vzX3cGQpJg1sODnUym4o44WzuuB/poWcAIsOzAVQerkpCt6gBKV9kxb011xHt1nTfzbWoXV3Mlx0hLOCfOTdqSULohvXf+QE+sLhDo5Dvj1wWAkBra+ie0/yN5LvyXz4RIi6uotvS0mQegGp0qXIZvM16XSL4qp9WuBn+74AuN+CM0CqF+dqE5qp6Lh8OPK2QOHO7I0wMm4y8zXQHerNBe7reiYtLo42jtQYyZsIs0Xh7ezjhIjTZoOiUHuqE45Z9TzapXgomEUugesXXIXPeRQXjFGcABPOxHpYevrF19MvUgQdqNhs7BhACg5MNZJHNhsdlHdCODogpPe1n5FKHH2ztL+etWW+Me3NUN4Ps7dQEQrjaaY02AK39TOlfA0JmLF5hb0Z3d+4McY/OcyBk4y/NcBhIY3jebp5yp4AOfzQ91KZP+YLuPjL+XmajpkA+eWIKeJAPPlAmVUqkx3qFcMonyb8mRDiQTXaeQXF69tlEF/2KQiIi2c2bvW/Jzw78GiUavYZYVTuq+ivUA7gQAWF6paWml3vJW5HLVlJ+sB08BWDOszH431u4xulCkIhRRh8DTvITbLX8Y5vSkC3SkqLolQCYp+SXVF7KMzoHTcwg9wR9GwCbrk2142RaAdDwu9mYjIDXpbfHTFP9zeUdXKbiiCnC8TjhuZ3q1qFZWdPmWyEMtzvTkrmEo4jcJG9en/P+KCbMDMlJmEsnyQ6MUA3Isar/8dMyip7NDLF/SCxtISIdF0Y/ZFJSVG/GV1e7w01GOYYUevDlShDJ3lWcf1jo+ux1m6xqVKAJ6jNvvYXvA6EA7keC0wQW1PlWO2e5to2I7ch+NRztPfQdnp/TAH6EJKdZdJljbw1Y5HL9J0nRMZN0UPznI4Mekwn7s4UQce5pfmC3FIxOytILyJetoMek9KC4MB3x0pYXGEeLa+Mk8Q6a88mABXrkjwx2ojSS5KI+ZUoTHNCLxNR+tPjEc56KBLiNMr8yLPBy53fI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e6d30ed-3983-4fdf-149d-08db05ea7267 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:50.4151 (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: G1fiY2Wq/s18lcsUlp6Rmk/Dk5b2yemQ/AE4c+usyFoGM5stCN+44pp3BBrqwEsjODJn2HBGoKizzDE4DB0s2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 f9a3ff37ecd1..2df634bb6d27 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -526,9 +526,15 @@ size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) return copy_pipe_to_iter(addr, bytes, i); 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 Fri Feb 3 13:26: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: 13127519 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03FBFC05027 for ; Fri, 3 Feb 2023 13:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbjBCN2W (ORCPT ); Fri, 3 Feb 2023 08:28:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232603AbjBCN2Q (ORCPT ); Fri, 3 Feb 2023 08:28:16 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A35D572B4 for ; Fri, 3 Feb 2023 05:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SoeZwSj9DGxjOGFmoHddNWDv/TLam3wlnOVBRMWzdljSMffj522+3lUYnGF7oO6FxGREsGuqJ+kLQ25V4FEJtv0w7isppuIspg/0rQNiTzAWd7L1vvKl1SvtlRidmldF5riy7Tkhx4g6HLTJeVXevJOfvihdTiIYciZpkqgcus7uHBRP5yLeL2/UeVFTWqgkvhCTTCwZxOhNT51sh2PVpsPlgO96NaZ1/BdMLDwbpgq8oqXt01LP+2j8e0LRFD/4KPSsbH7m/HVc0XeM+fyWIzQatp974F6OuzCMicCh7jnDcVh3WhBVEVUx4BJQi8Jvt7g8W4FBJj/qibPdFXqW4g== 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=8FrsDo8NfvwL+9EU4nc34cZYG3UsMNfdMkg1y0h85BU=; b=gOeiV97xCjZItWCyx6G+RUbhdCBgFGxdox9A5i1DUCuw4alNLrUmf38qdFrr70AZCxFzNpDBm6tJTAcsMEo7fSGJUygaLjv/5hvMIeYkUAaCNTmUfHzPUWMMsOxQHFqq1+DudkVP+R1eS5MxSacyAMpl8n6Th6rCAf7V2CM52aFwX9+DtJVYHwfLWN2GxUqPB+c3BiXuxhM78TUuXPjOoCe11jrHW/UVHzwe1sAqK7o4S7y45GqskLfQdk2Tvt0u+J5JuJuCHNQEmzfJ4QwNn+4p2Q5Zki1EAee/NluGV65ijbM4nqzGk5XLOfb9vmjjUTXSKnubeifDiUOmggK/aw== 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=8FrsDo8NfvwL+9EU4nc34cZYG3UsMNfdMkg1y0h85BU=; b=RF+DQj0o+HSXuKAEZqJU5cslT3HcJtbBx4JEr5AIBKwFmfUPpKer9gY6wAOiGTLx0KIjLgO7fgIMJVSlmC5L9ZbKSTr4gvOO3fqSupEYEhXrAoNvIagJIg9iasXIfA+YRtSL4xiwWwwiUP6ERhzuhnVus/Kt3gsJApS7XGLqYaBuNDBD4l3e/p1RosxwGn37p9QPShGQ2XkU7fh2Kx7+/L5hr9SOFBN1gt47Sfp/1kzqCLQOEChuwKnMFOKBl4Tm0y+QPFQ/x69glDDPcDR3AkOcCsVKmgn6iLMYYVtlZbqJwMhAV93u7FMKjM13F6Rn9VWCKYdEVa7mhV+AnVX4+A== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:27:56 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:27:56 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 06/25] net/tls,core: export get_netdev_for_sock Date: Fri, 3 Feb 2023 15:26:46 +0200 Message-Id: <20230203132705.627232-7-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0072.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::9) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: 068f66c5-717e-4478-5cea-08db05ea7634 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RV46eg7Xw6II8mK7WZNrcMotx3Dk/1qz7WsxCdikDqDoqHqLoe19GuRgKlI72Sta5RhqVPnLeCw5VcfNhcUhLLEA+27pM6CwZka0Dfh36UFa1UhUbpm2onDg3OjMzo2AVpYq2yfuv19xYP1495W4puNflQqSwWnR1Z/VX5Ldd4OppF5bXRJ2VFFDgSD1JbFfGZgkjyjnFGUFNnLp9s+eAtCzjdLS24xyROEIwaWwMX0cjOhhsmEDVxo9LZnVi7ZUzrpVAZEpEY2aO84fuO9gX65VBwPotnf2p142Xo/5tisT0Zs8ZHKyEn2xamets6ygFXDRfpE771ixuczrPYMeL1pWCPWkoLSM4YmFuHAQKvA9hvb8v1e8A559HfDXlMVVusP+OYGgrfhEqC1AbcSUSaWFm3fhkp4IdsHQDljZ+6MATvViMJJNWnfoHMSlY2Wqv/frN+SmIubpjQHch/oE/cvpt6+YjPB/T2cQz+HPdAOnO1RPFpsvQz7YOH/opM2afD1xL3FkwDSB8sm7SHBErfrIamjVkULZSkC7U188VPbqrGiFD1XUzWkE6YzluASNeKfVmDwOVFalYrxrY9cNhR5NQ8WOyzip3Tkqqh1gbB0qh2MK8s+2Q8XTOx2J5kEKS64Thgc6HVAPhyCq9bf1Eg== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vllAiGQQzQkS0A19ME8l89xwofuIUTOr6fSksicJ9niFbbCrlfZIsX0RBH4rRwiEzyIJcDvc+InF7wcTe8Y/T9Oo1KvjzuOoYwF//W6HJYAn68siNGwVQgyyjib9pph/1HAP7hxjLOFD4zSIho+LfA2ZdfAwrdl03z/PAbMdM0tgKMCBaqnFR6ZcpRgaUOd58GCOEPuNTI8ht2JcCKCRt+XeW8Jo9OQa0cf/+Fp1tO4TyPLbq7Rgfjf0tBBlwL6KTbshtR7vjYJne968/bhLIQPuXaaWJeiGmdnGmRwEkimBDk1/pAjbcIv1vP7hj9H7Os06Db2sn7QjriPa6CNpHymttm6bgTNyznXemsGXJsd+bbsk/8/M4uswh7j8Vtjd8ya3IrSEDJKau67LlvX1gu8cHBXbP5s47QEhJ1JYd0z3uPopwKtEQDC55TT00rmOeSwqYSWv45NAeQRho7LENv6inEjnZ/Mst3ATM9/Il1yr3SkRvNuWM9xLEPBN3R0dDeCm98liZo9GLJE/ZS4p7SEeMXJAd4O8LXBWNL2esZeLweHipVa6OTfQ2NE4EASj4QXUxFwJETL5SBb+GPNYktntLrM3EbRyhF57CRA/8dCKobQZpuDg98fzZf9P6DseTmqeXlG6dO2NueR9jj1zsnE0Chq9lzvfYz3ZLVZN78HYkFqKjQpoSK9oyBjuX6Yq9rf8VqvHRRD9Aj05JWsCtd+Y307s6OUAZRzFOuumrqPX/fB6X4lSW8ZfEWd/sKAPKSDxjnjrpbqZ070roNHz7ZlMKWQuSvMScyvML1cZ09ATj+A88Vj6bKc84CGE9UoknI6wvJlRbCtCIp+R5WKdlFocR6ILyfadOQ/g+vhmg8hWg/EiDkQK61EjvA184zkEaP7B4YJOPhRqZdW37Vf0pWDoHHVuc8Ws5mOhuTnsAkX0UVQITUGiu66BQed9EFyoee7ibjuoN+StAt+Hpeww82GJfhoSzX0zDQzDjNlsohbhHKC7mP0mp2O82/LrU9AbaGBo+CkCMKpaJR3Buakw36fMoxlL7zIWndH+Z2Y1daNvSKE9Tis045WR421vThiluCxZezzzm6vhOknUWul40LwNoAE57UMQA9JEPVRTaIWdb0CBYS2+86IpROzRLCohZHwWaa7/bBf8tHst0X/rBiOL6yaWYRhRgFTG4MtTjO4LZkr3YyjzHZ+j5130QHqW5mF5/254r3zEWqzNbasufnAbky6v+9YzJpKAcO2bNtAuCwISd5S6a0vvv9VwKUcCiEWUFEnTWIBEhxyHeb8vNGwGXHnUhQ0jnB3hzghCSMFPclJ/Es9KJBECd/zfnkw372TNO1i59ekJZB482cAITUbcJ9E4PTlwD/DtOBtK9JBQcadnNju+ZjlSsTABDrYcZLECA2sQuWqgK+M44d8MG03KhER0IHNXGAf0POm9481K6fO/6po+gucD7JymPCvVIMjd/xNf146+BEFjp5PZhtOo8uebGN9e+Uufs+LWbmIHGuXXHL3KNO5vfdt/l7VNqXm9V1FVjbpNRCcH+Tzq/58Lh6MyhXVRExNsevk5p/LoW1y7ME6rKhySNou2DMaM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 068f66c5-717e-4478-5cea-08db05ea7634 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:27:56.8248 (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: t0yf8ocQMyceeddajfGC/+YiMdwPnWINWToQeOtD4DcSgVG/WYyANjjHl2l+v91+s7xgYuLlCr1BCHgMONqw9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 8861a2f04e00..25a868281594 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3096,8 +3096,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 *dev_get_by_index_rcu(struct net *net, int ifindex); diff --git a/net/core/dev.c b/net/core/dev.c index bb42150a38ec..2360b70ea0b1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8153,27 +8153,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 6c593788dc25..3c298dfb77cb 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -120,22 +120,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 Fri Feb 3 13:26: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: 13127520 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40A20C61DA4 for ; Fri, 3 Feb 2023 13:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232605AbjBCN2g (ORCPT ); Fri, 3 Feb 2023 08:28:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbjBCN23 (ORCPT ); Fri, 3 Feb 2023 08:28:29 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EAB0646A9 for ; Fri, 3 Feb 2023 05:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JlH2/2ssNKmOVneId5JzIgHZvggBZfB4k6+xpX+EeCFNVpNKbJSFFicpnUBzPS+vv1PGlTmhPvOs1BAJGDt2BxjX6UM2YxZJrgj+1dynFRHStnraKL1WYtNSHGpWWxUP8G0GB0bewV6VAF+lTCVgRGL95Lqu6jaSZq/w77+ufRmIxRCJuJuJpJL6h64fGMBodnSaTLeq8Y5GFLvI0QhySQu6eHWj6Rd7ZwS9Sb4LJLuABdAKS1G8VtHgPWkagi+bvZ69kEAZMGQUNDnWwfvR4UOJBcZV86/dSlEqN/nuuUC+DK290jMFy4dfnJTp1wVD65uNZwdJhpNVXtHvRg3IJQ== 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=3X1xxnLcvqublCNEtqddms2kV7RobqmXHXqnP41Cp6E=; b=Hl6Y5Q2tIdVrWb+boo77lkPttR/XgKflYComxD/cni86pmSX0OIJWIuPNbC5Aj92ZFqr9SY+w2zsakUPEB+gz70xZM3h6tLTvi0HCSKmsmtY9MS6aNqlpay9SRjcIsDSrsfOMxOtZ+GsKJfDDvCtmGQDvn5JhpG5qhjyUHu+A9oyz02WqVGUQ4stvpv+uoISuwbwJbNYwzUyGkmyrU4g24pCk0/4xBLzdA2OWd1JNLcK09W5po7UiNjwvH8tOQR1fDX5kfs6QKAup4zxj3tHzOYdzMV1aBv3nAdWmh0aIAezlXtRgWoJv0LtkLBU9Qe9YhHFcilKiqKX8vdj6agH5Q== 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=3X1xxnLcvqublCNEtqddms2kV7RobqmXHXqnP41Cp6E=; b=Yw621Cj1OZA80+gKHgWaIObV/zpyQ78UvwO9zEs2dk0vhyJ/IXWho6VfJ9KwIUNOLi4Y3dD4SQ6S40PP+XlrWIyRFMTV9gXijjInYA5r7thP24+h0zuAJqZV6aEmvs6loM3cJcMMh4ezKEQtBg3snET/7L2juasgmm39ACQOvmh0vsMgKZ8D0KJkydeGyhfXXab7vlBQwruwxliI+yLVmzH4bmkXRyktcBWspNHco3ympjgKcsBXIwEmnIAqqERyazw2qfSASxq7wy0ORvu7OZofZ7c9/jF1p6KD8DIGNhBM3Pkvnj/MjB74A9LenXyREZR7Isz85bXpwOVZVputpw== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:28:03 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:03 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 07/25] nvme-tcp: Add DDP offload control path Date: Fri, 3 Feb 2023 15:26:47 +0200 Message-Id: <20230203132705.627232-8-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0068.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::15) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: 13ecc40f-8073-437c-ee55-08db05ea7a13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zdObScBRd1F2xPL6L+m3IK9bflXgausyjqRXxcxobZ3pVFaltjsD7MJucvHeIfv2fBRwly0/c/9ouhSaRXgu3DfaaBZRhRf4oEGdxraFo1baoRHVwsJw6wCxFiZfTnMf2tHKjJbuxGbEx+sxIGNLRBRBp8kRzwvKJny+NLb60RRNj/Ic7Go8DHYCGIU3NaKapFgdHfyfG5LJ2eD+R9SKaUWWr1Mez5bjRvItr42qZy2ISH1lUjppE1j/K/OF+9sXc6h2L9vsUTYqMZMmWJF+pzatIo/Zt5iSice7TCVEs4wh8X24FU17U0dB5DWegHXcjZU8wS9274GF4xSl/NPJR8tC+7v+xYPY0tq8Y7AfnZP5047+aWiIeqmThfS3j7tXTrIuygLlSXd9SlgYyTiUDXl8XokGgTeOqEmUJ7xFkVpvmUmPfwi6F0AepdQczaIRqgBw6X5x5EVOu5NORe/V5b2kq8B4zIAvvqEVc9S59lhlfqUMPIvds/heitPBWdklWHmxvaegsjfTIRfcLcnuAVXr8TTZOaq9uqKlfBGxfmQ6oV+g0bH5Jg6uw47N9A9Gv6QUZWu0SM6XNOTvMDwUiGBcNuXaXvUHdIGnCq4Tk1jPBuSEnWcLPmBq9lLbrYPTLpUIplpuk3g6P7p0mbIg1w== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(30864003)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NAlhri7kMeaE7d31ye16sSdDujpEIZF42uQTPk/LJ7uBZj7hGQd6YJouCtPQsEIKLvWuqf8doNDMRcshcRp0YYpWbSakXDVuCkHSEpMd5jSXmlF1sR2+X/JGvuWRcz3EOWl8b6TQ3kMPiv1n+O8VwQ+RpiReKpOzrPWoATB34+pJIMHoIceYEHeL7JMxJC+ri+jWq7wyljyF26LGS+clXW+vcTwgGrWolCm/898mN+EVZEUVQe9PVFEi7bK/zwztjJRnxIAk1BcbhzxPmeyzDGQj8Mtq7nAtKrdQwVtX8bhwKrL0/rfhI4DOgYJfroj6Z7Xjs8uWThcN+7i3MxsKZ8+XRrPPQAf/NDMNPeUE19Ao1xdkjpNYgaatSoOtQrErxc0kt5i8s4UDiR3P9gSNuiJgKKnNGr74rq/0I98ucEXaa+GpK+iXEyXrtLaCA30Mfp0JgdDVlzbHDAqNOnmFJ2HaDrcnXV2vMUIdOGzxMeMqzCRZ/rWUGFlb+dG15Tqsj080Vzg2vNLN20K+WIIviVoGAxaySqHx6yG1OG/cvR9gBzsAd3iXymSD3VkAHmHqWtlXQobyCf8LaiubGl5gh82/wfSTdJb8WCAmGrwyR/qnoeJn3n+27lkWZc5LK4v5Sb1P+SrjWz9TSmZUtmR65URLPtbJbEWGMxATGki+aAlzOufeeCTr1v5Wvh/BJwWmdKYrZhaK+cyJP8jcuP/egrZKs4wMFPypn/wClM9Xv2cTjofm6Mzej9ETYuu+a3Jkh+/aSUKGLYMlDdBVkneVMw+SQdDO6qYBDNDxua9zsWywM4pZOXuOX2Lu0kNH2KEtoWMQkB1LvWpfZwqkuHZxcCYBzaUKR1xckmSB4VjmDAMSgIBDcW4fueS989xxjcdahFJPECU1L+wMJ7sfoXZLyHQ3crmbpp1S4dnYeLLz0yfwgc3rsilz4BTPzXpk6sONDsyd8b/VqNCp6uRiIideeFJMV9MCRM4kOF8+wCqM7iOKzSN5dgRn6W72EWgfOSbYFcqL/qRk6w/mfjANKSGQZC5dLrQ+Uh5uJMLuScwcpzRjp0XBbuHPDY6+d/vDE6F71prbY/pPXEOQGN0VcOMdJI+nT//UuqMvFxoAOntkSTrF9bp4ZoJnHg9yU4L4Wv0c+4PAK1n85S/cqK+9hHj6mmD0BZtyvRa5WTY7vjSak2mKmh6Qj6TVQVFWIqs51EQ/7mByrGUbwmn8hR77ZTLjE60nl0b37+bdbWB6rLlj7TIYKUb04OAg+xW8GXuyp2oFidZDLzZc1AG1wPExJvRbc/3TAP9HgcTUglKeGaXkndQexkWgO897DtEIGjXqwhx1IbH4Nk5Mr/vNh2NJduqBEAUCigA9DdzdLoVi2DUcBTuHfDwy69TXGS1bQleL6WttUB20KhJSOZU9aaf6wY2DT4zM+RG4CEtOKdtPyrwAqiM1L70AyboC/LkbBpC0Thkwy86fFV8jjmNCKV1w6uU/7EuohvO/Oxc29UgUMEOa72YEpdBFZbR7e6MLQ9Vv2iC7oJUkAVYJl4V3JpJtj3c8gPgcPInhZKrZykpH5iNSC370ayBFknr2Oy/FH4uf7CGy X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13ecc40f-8073-437c-ee55-08db05ea7a13 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:03.4169 (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: B+nr+ysbAfebtkzRk+rSJduZKBcqiYtWdsOaGmOH+uBuzeZB+FV4U+qv1J8vJKiSqQ9UgWTiWnY/ilN24OSuUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 263 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 254 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 70e273b565de..b350250bf8fb 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" @@ -104,6 +108,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 +136,16 @@ struct nvme_tcp_queue { size_t ddgst_remaining; unsigned int nr_cqe; + /* + * resync_req is a speculative PDU header tcp seq number (with + * an additional flag at 32 lower bits) that the HW send to + * the SW, for the SW to verify. + * - The 32 high bits store the seq number + * - The 32 low bits are used as a flag to know if a request + * is pending (ULP_DDP_RESYNC_PENDING). + */ + atomic64_t resync_req; + /* send state */ struct nvme_tcp_request *request; @@ -170,6 +185,9 @@ struct nvme_tcp_ctrl { struct delayed_work connect_work; struct nvme_tcp_request async_req; u32 io_queues[HCTX_MAX_TYPES]; + + struct net_device *offloading_netdev; + u32 offload_io_threshold; }; static LIST_HEAD(nvme_tcp_ctrl_list); @@ -261,6 +279,198 @@ 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 inline bool is_netdev_ulp_offload_active(struct net_device *netdev) +{ + return test_bit(ULP_DDP_C_NVME_TCP_BIT, netdev->ulp_ddp_caps.active); +} + +static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, + struct ulp_ddp_limits *limits) +{ + int ret; + + if (!netdev || !is_netdev_ulp_offload_active(netdev) || + !netdev->netdev_ops->ulp_ddp_ops->limits) + return false; + + limits->type = ULP_DDP_NVME; + ret = netdev->netdev_ops->ulp_ddp_ops->limits(netdev, limits); + if (ret == -EOPNOTSUPP) { + return false; + } else if (ret) { + WARN_ONCE(ret, "ddp limits failed (ret=%d)", ret); + return false; + } + + return true; +} + +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 net_device *netdev = queue->ctrl->offloading_netdev; + struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; + int ret; + + config.nvmeotcp.pfv = NVME_TCP_PFV_1_0; + config.nvmeotcp.cpda = 0; + config.nvmeotcp.dgst = + queue->hdr_digest ? NVME_TCP_HDR_DIGEST_ENABLE : 0; + config.nvmeotcp.dgst |= + queue->data_digest ? NVME_TCP_DATA_DIGEST_ENABLE : 0; + config.nvmeotcp.queue_size = queue->ctrl->ctrl.sqsize + 1; + config.nvmeotcp.queue_id = nvme_tcp_queue_id(queue); + config.nvmeotcp.io_cpu = queue->io_cpu; + + /* Socket ops keep a netdev reference. It is put in + * nvme_tcp_unoffload_socket(). This ref is dropped on + * NETDEV_GOING_DOWN events to allow the device to go down + */ + dev_hold(netdev); + ret = netdev->netdev_ops->ulp_ddp_ops->sk_add(netdev, + queue->sock->sk, + &config); + if (ret) { + dev_put(netdev); + return ret; + } + + inet_csk(queue->sock->sk)->icsk_ulp_ddp_ops = &nvme_tcp_ddp_ulp_ops; + set_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + return 0; +} + +static void nvme_tcp_unoffload_socket(struct nvme_tcp_queue *queue) +{ + struct net_device *netdev = queue->ctrl->offloading_netdev; + + if (!netdev) { + dev_info_ratelimited(queue->ctrl->ctrl.device, "netdev not found\n"); + return; + } + + clear_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + + netdev->netdev_ops->ulp_ddp_ops->sk_del(netdev, queue->sock->sk); + + inet_csk(queue->sock->sk)->icsk_ulp_ddp_ops = NULL; + dev_put(netdev); /* held by offload_socket */ +} + +static void nvme_tcp_offload_limits(struct nvme_tcp_queue *queue, + struct net_device *netdev) +{ + struct ulp_ddp_limits limits = {.type = ULP_DDP_NVME }; + + if (!nvme_tcp_ddp_query_limits(netdev, &limits)) { + queue->ctrl->offloading_netdev = NULL; + return; + } + + queue->ctrl->offloading_netdev = netdev; + dev_dbg_ratelimited(queue->ctrl->ctrl.device, + "netdev %s offload limits: max_ddp_sgl_len %d\n", + netdev->name, limits.max_ddp_sgl_len); + queue->ctrl->ctrl.max_segments = limits.max_ddp_sgl_len; + queue->ctrl->ctrl.max_hw_sectors = + limits.max_ddp_sgl_len << (ilog2(SZ_4K) - 9); + queue->ctrl->offload_io_threshold = limits.io_threshold; + + /* offloading HW doesn't support full ccid range, apply the quirk */ + queue->ctrl->ctrl.quirks |= + 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->offloading_netdev; + u64 pdu_val = (pdu_seq << 32) | ULP_DDP_RESYNC_PENDING; + u64 resync_val; + u32 resync_seq; + + resync_val = atomic64_read(&queue->resync_req); + /* Lower 32 bit flags. Check validity of the request */ + if ((resync_val & ULP_DDP_RESYNC_PENDING) == 0) + return; + + /* + * Obtain and check requested sequence number: is this PDU header + * before the request? + */ + resync_seq = resync_val >> 32; + if (before(pdu_seq, resync_seq)) + return; + + /* + * The atomic operation guarantees that we don't miss any NIC driver + * resync requests submitted after the above checks. + */ + if (atomic64_cmpxchg(&queue->resync_req, pdu_val, + pdu_val & ~ULP_DDP_RESYNC_PENDING) != + atomic64_read(&queue->resync_req)) + netdev->netdev_ops->ulp_ddp_ops->resync(netdev, + queue->sock->sk, + pdu_seq); +} + +static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags) +{ + struct nvme_tcp_queue *queue = sk->sk_user_data; + + /* + * "seq" (TCP seq number) is what the HW assumes is the + * beginning of a PDU. The nvme-tcp layer needs to store the + * number along with the "flags" (ULP_DDP_RESYNC_PENDING) to + * indicate that a request is pending. + */ + atomic64_set(&queue->resync_req, (((uint64_t)seq << 32) | flags)); + + return true; +} + +#else + +static inline bool is_netdev_ulp_offload_active(struct net_device *netdev) +{ + return false; +} + +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_offload_limits(struct nvme_tcp_queue *queue, + struct net_device *netdev) +{} + +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) { @@ -703,6 +913,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)) @@ -1660,6 +1873,8 @@ static void __nvme_tcp_stop_queue(struct nvme_tcp_queue *queue) kernel_sock_shutdown(queue->sock, SHUT_RDWR); nvme_tcp_restore_sock_calls(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) @@ -1679,21 +1894,51 @@ static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid) static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) { struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); + struct net_device *netdev; int ret; - if (idx) + if (idx) { ret = nvmf_connect_io_queue(nctrl, idx); - else + if (ret) + goto err; + + netdev = ctrl->queues[idx].ctrl->offloading_netdev; + if (netdev && is_netdev_ulp_offload_active(netdev)) { + ret = nvme_tcp_offload_socket(&ctrl->queues[idx]); + if (ret) { + dev_err(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; - if (!ret) { - set_bit(NVME_TCP_Q_LIVE, &ctrl->queues[idx].flags); - } else { - if (test_bit(NVME_TCP_Q_ALLOCATED, &ctrl->queues[idx].flags)) - __nvme_tcp_stop_queue(&ctrl->queues[idx]); - dev_err(nctrl->device, - "failed to connect queue: %d ret=%d\n", idx, ret); + netdev = get_netdev_for_sock(ctrl->queues[idx].sock->sk); + if (!netdev) { + dev_info_ratelimited(ctrl->ctrl.device, "netdev not found\n"); + ctrl->offloading_netdev = NULL; + goto done; + } + if (is_netdev_ulp_offload_active(netdev)) + nvme_tcp_offload_limits(&ctrl->queues[idx], netdev); + /* + * release the device as no offload context is + * established yet. + */ + dev_put(netdev); } + +done: + set_bit(NVME_TCP_Q_LIVE, &ctrl->queues[idx].flags); + return 0; +err: + if (test_bit(NVME_TCP_Q_ALLOCATED, &ctrl->queues[idx].flags)) + __nvme_tcp_stop_queue(&ctrl->queues[idx]); + dev_err(nctrl->device, + "failed to connect queue: %d ret=%d\n", idx, ret); return ret; } From patchwork Fri Feb 3 13:26: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: 13127522 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F414C61DA4 for ; Fri, 3 Feb 2023 13:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231994AbjBCN24 (ORCPT ); Fri, 3 Feb 2023 08:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjBCN2v (ORCPT ); Fri, 3 Feb 2023 08:28:51 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6EFA457C4 for ; Fri, 3 Feb 2023 05:28:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XQgr2vt8zfgRSYY21T3d8uNK7XfNLrlKhzTD4PmiuJ8kfeXFy22jKb1/1oGw9viZiRecMFOAAm9fE3rJzl6aosTy3YIXvsPMsHwUBsgeOwcmpqTuF2iGCtpd30tOmtbvdr5j3gZJtA48hgKBw5PdiCFL7e1CYkxDwT62sCFibGPM5eUIknIkrp0wDn/Uea9pJLaduG1TwGFnBsZw4R88qBIfSYqo++PivdyYMBT1XrOs6RwKwStRfXp8KHN/O5vubrEXZzk+1zZvW0jczaTekH71J/GnJFUloXtD7qxR+cM2itQcrIvRP7WMTW+QTLaefGsqX023Mqf4mRKFoiLK4w== 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=tQD7FaT+PBqXhv4KW+daaBG/CJCSnqhsVJIb6lvnYfc=; b=Y+FSQMbWmF9ja8CCx8PTLfwvvzuZ81k6Lh0OodE6dVP7q03PDbNqgWJDcwGiyRkC95mc30A+R3xzr+z+9+tNE1FtuQUygfOWQ8dhNDNNfUfWEWbtk9KnncU99IALZj5Q5fk4XDLqzImckIl5KkOFu7ElM6os/TFEqaoYXg6dAb7x8aoGSVxnFEeiFlGQR+faO1X+9Pi5516X8u4EgG311mB+16F6aajUugqzvrnAhRZejJ7Bb+ol4wUeyBsBbm9H7Ca8Xm0KTeT41NIg/SBk1/oBP3GEroq2dX7iByZ/26tCa9J7hxBiEzKqVEptOVx/SwQ2lTfRvgSkbN9Ow6L38w== 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=tQD7FaT+PBqXhv4KW+daaBG/CJCSnqhsVJIb6lvnYfc=; b=OkAGtIX5QbJ08THCsgUzIMh4jfYs4D8nQA54B3nrT1GkKrokwQHhUt7zTkIFDW5tWC1jMuLACUpuO+aUKuiuQke7nedxx+rG5p5wdlR1sDNGDdlaTWgdQ+KY2u70hFYgs2s0ATWHBWHddoJdJgR8OZtjUuw+Hsqytt808AnbVhYlYlv5MGIp6wsXvry6VAzUhonZwpaaCabLQcTNpPmBRpx9/HaY22shHfbVuiJ+XO/MxmalStHkl4hkpypsgqXRWZwSlSjdbUN8xWCGz9e+OCffTk50E0e8gIrFQYzIZwsQwgBOEDBCTe9dKlav0m3WGg9vmWRh2HMpKWXXL4GI2Q== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:28:14 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:14 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 08/25] nvme-tcp: Add DDP data-path Date: Fri, 3 Feb 2023 15:26:48 +0200 Message-Id: <20230203132705.627232-9-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0039.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::11) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: a92d354a-33e0-43fb-4b9f-08db05ea806e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4JMEmQ1fbvnw6J3N7XbJ7gmYEs1mbWcnVp0JyM8I6ekcffgchJa5IyZJ5ziFDehBBszKUihyzRNgNN85Qz6hq95gdu+BRjwmFf1Y0f97IB/qOyndB4S73tdWpY5EBtrpDu+cun1ihoIPyudF36mTelO1dqEfF3BrguCdIGBdzJWlN5vgoa8aaRsrAhX6HkKBJ5+Deq4eXhKID5K4zk6n6jobkAEb2Pj+avaKBnQk/HqKGgs74JX9rMeIrODEdJOBk32cTvPMgY6WviXRlfemhlf6UOJoLT8PBa/j1rkMM//ZQa2rAWhiUW1419boNYxnQ6v/M7EimDImjrt92wgcXJASkAor3wCP03PutraR3fYpNHhls+nY68UwvWp3nEqww5Jwy/QV7z2vBzp5nUwFq6bLxQwFf1jidqYFm35jzWgfQOw4jlkcUMi2drqKBJSt5SRuSFkUHhaKSfKDYQVeq70s97MySLeQXvtCNqwYdHaCRQxMZtvb6fbmVyNjLtsEG+elcdiyrFXVZpgIPPIL/wzEgxItLLFwE2gwBoRybE4YuANqJhXvGKlkRk6K5wdCOXxTlBnBpy0Jn0p/dC8Q39xMhEDVdLif1jPbVPSy/YTHvNkDadNeM9p4h0Q7Ma1j9K4S+5//fomjrDGybpdGkQ== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uQSVF6jTWL0J/wqQ8svXX5/72P8NbOxiZABTuePQl5+YQHzk6MuwfAT+zp/KHuSrofjjGOx5vU18a/qr/+Wkjjg9v7L9s5IvcymFa9D0iaMk9Iwk7VLzuCxq0JaKx2fdZyma0IgBnDahWIBzP6bnlOKahffOXZmVxeBfnF10okTM+DG6lwA0ubkXLhX0/Orse/2LKc96xcH+36hOZBAKPnAQ3BJzzBgo+CRH6oGA532fw19B81zXnck8jFa6UfopKSWaiZhkSr43/jUKyz/R6u3paIFeX0amRJvELdKy1m7hgOizOc+tnNsSU8sxwWA68LgRzr1HBmDiurdBR8IFAnrGmh8IEHhqhKx9I5ff6iA6y05Iou6LqyKQvRZAtNtaDMFzTUCJsh3K+1C1NQfKx13vj8sh8JzjFHimvrBL+jo5GTwOJr5zHAzfn7NkPq4RmtDMN6N/KvNDWHQqWjB/BLlc3ES3KkJ5f0zfBiO7ofcVggYVuv33CwrW+RV+oRyKiThN8H3wWxW2NVEEPddHOaX1cuYf/cHlVo2lRWqK3MAotgrpopiJ+ZANAZYJCjLGvU5c4A3GB9qVZZBP36rmJDp7aPiex7U7zxJ0c7kFlULsKZ6vVTzZ1vCBmunYjdShwHipj5HDMMtK0o3e2o6nZ3NmxQR7dnd866XzeQ96Ogzpg2Eu8J563IzJRc1pdbE4X1xZ/E+hKVymiGk1tNCMZWZ5jYvXVDZ+RbJqlMAzQVwYBEgu2bVhRXhuAW09bd+FI63TuYGj+oVo60L3EhIwllpjuga2eJiBHsE8hx33l0ZMaCByoqWf1Cisu1ODTRBcoGzdi1vc2jO1r3ts+k6kBZUDxWnoJgkimsPWWPRbVTxsyrlcSBWHLtAnzjSUeRCE4hva+tQjVRvPxzHNOFd6Sive6SDyXj/Ii1lLUsp9zVyWMjfurpe3Nttv4lpJ3Y86JR9STbrizdeW3GW713PqNIQ7WbF4KALJjd2XyIGeS0ws9HVGh14MHfCAdh1Mh95h+Men7Gk3K/v/6cPrVMtxb0r5r37SrgHHw+DVTceGRwUgEDceYhKP9Un9kM4AZgbtRgymDDTTsFEb8Dxn0KoU/d185i1ufTqxP/8D/3qvMGQeALPoz/jFfAHeDzwVOi8gRe2z2mQHByL43LVwKJSas5AWhRxwivlNnoQntZQq80HcMxsfvlvxk8pMcDidyYDGKHGgk8AysRsccELrnsFSnlBCgrp8vaGhJILoE19X+aDizUv1zRxAcTl6OvDOPuJiQD2OMVJ0P3jJ6KI1PM0i1CH715HrpFqKtvQ9DEijXw7tDTRDssntRtkC69YiTBivJjkZQMHP9aeFGTU60yc5SZA3m6XN56wiTrulBLqJqpLGxBZ/uyGE+WBKJ7grmzUxUNhMREyfJlI5vBTzffbLh8s255ygMHmZbGsN+XmO+bJ3DGy0weQsCPSzvbdr9UBtKQw9jS5S6iJuUfook2aAVXXI9Dx2IEpITnhhqsnZmjdThVq61cUmr4CDTYVIxTi3gSXxvKduwVP4URhkd0X2gxmVv5rsPoJRRNGjvNduXKi8Xv7y4awcCS+dkKfPULGn X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a92d354a-33e0-43fb-4b9f-08db05ea806e X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:14.0598 (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: cNyFazB2C44grJwK98sKyvM7AL6+MUXybB/JGeV707YNt7CS2FtOZ7VWJaam+gQloTleb6ccAGA2IWfGEy5R9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 121 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index b350250bf8fb..533177971777 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -102,6 +102,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 { @@ -307,11 +314,75 @@ static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, return true; } +static int nvme_tcp_req_map_sg(struct nvme_tcp_request *req, struct request *rq) +{ + int ret; + + req->ddp.sg_table.sgl = req->ddp.first_sgl; + ret = sg_alloc_table_chained(&req->ddp.sg_table, + blk_rq_nr_phys_segments(rq), + req->ddp.sg_table.sgl, SG_CHUNK_SIZE); + if (ret) + return -ENOMEM; + req->ddp.nents = blk_rq_map_sg(rq->q, rq, req->ddp.sg_table.sgl); + return 0; +} + 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->offloading_netdev; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + netdev->netdev_ops->ulp_ddp_ops->teardown(netdev, queue->sock->sk, + &req->ddp, rq); + sg_free_table_chained(&req->ddp.sg_table, SG_CHUNK_SIZE); +} + +static void nvme_tcp_ddp_teardown_done(void *ddp_ctx) +{ + struct request *rq = ddp_ctx; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + if (!nvme_try_complete_req(rq, req->ddp_status, req->result)) + nvme_complete_rq(rq); +} + +static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, u16 command_id, + struct request *rq) +{ + struct net_device *netdev = queue->ctrl->offloading_netdev; + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + int ret; + + if (!(rq_data_dir(rq) == READ) || + queue->ctrl->offload_io_threshold > blk_rq_payload_bytes(rq)) + return 0; + + req->ddp.command_id = command_id; + ret = nvme_tcp_req_map_sg(req, rq); + if (ret) + return -ENOMEM; + + ret = netdev->netdev_ops->ulp_ddp_ops->setup(netdev, queue->sock->sk, + &req->ddp); + if (ret) { + sg_free_table_chained(&req->ddp.sg_table, SG_CHUNK_SIZE); + return ret; + } + + /* if successful, sg table is freed in nvme_tcp_teardown_ddp() */ + req->offloaded = true; + return 0; +} + static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { struct net_device *netdev = queue->ctrl->offloading_netdev; @@ -453,6 +524,12 @@ static inline bool is_netdev_ulp_offload_active(struct net_device *netdev) return false; } +static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, u16 command_id, + struct request *rq) +{ + return 0; +} + static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { return 0; @@ -740,6 +817,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) { @@ -759,10 +856,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; } @@ -960,10 +1056,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, @@ -1263,6 +1362,15 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req) else flags |= MSG_EOR; + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags)) { + ret = nvme_tcp_setup_ddp(queue, pdu->cmd.common.command_id, + blk_mq_rq_from_pdu(req)); + WARN_ONCE(ret, "ddp setup failed (queue 0x%x, cid 0x%x, ret=%d)", + nvme_tcp_queue_id(queue), + pdu->cmd.common.command_id, + ret); + } + if (queue->hdr_digest && !req->offset) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); @@ -2594,6 +2702,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 Fri Feb 3 13:26: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: 13127521 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E83A2C05027 for ; Fri, 3 Feb 2023 13:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232573AbjBCN2j (ORCPT ); Fri, 3 Feb 2023 08:28:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjBCN2h (ORCPT ); Fri, 3 Feb 2023 08:28:37 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489264686 for ; Fri, 3 Feb 2023 05:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DT+se6EtQKO1IsuwOLt5EUYdiAobAsu2qxIiEjHfe7qltNUnFv3BrAYMHF3H/a8b8IsERd6vgRpxQnC/4tHeGIrb2l798dB5TzI+8iTtOWR+ixZShTTwjUgbQqEubRWBogsXMwvqjCop/OvOghypPsqVh8CueXBYN6MflcVIFOATWwivMCXlSp+M3iDw3M9n81Mi4IbJ0sDsQ0P/x5kH3/YLFr9Gfw+SAi/kesJ38DUT1wWDj7NbIH71ON/5G7TLVZSQydjZg4CliVhn907c6nU4XLcp/uRx5AkAQYR96wnbYO0nF30dxoXRrU+tQ55vhs6KbTRhReLDF9dAiJZbhQ== 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=Ba2Kq7e/xGwQoLYr5mKtQYFkhXZhqoRlrhkbFD6WVwg=; b=aVnhiP4m0BuwSbXHcZbvJdIAvvQd2497oVAattDl0rHyUXkykDXx9pEapngXr/ib5NU+CJ2RwOQv8m/0oMcLImrOkr1TqWCmkPLqkIGuwvK9doyWL08XQwVrFk2hSj9yLYTDSBIuq0wzkO6/tnwq39PpNWx7o8wvz1GDuNmT7iTgHkT9Hhibq23w0tLyGsfpFuWt3Au2SoZPsZPTBzV6V9ojPahT7pF7HWTT5Aoj1FSRI8wctyIiTMZ8wwDyyheLOk+rdzyrTKZxvEu4JENkdOn2WrDbJD2O1+iAgOWx4O6o9E8Ckh/0XhqLf5/62ckn7XqwZ74gFKEzh6rPNSMDPQ== 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=Ba2Kq7e/xGwQoLYr5mKtQYFkhXZhqoRlrhkbFD6WVwg=; b=oHJYC+IrC4RqTwwAvO4aavRlQXCnji8zb4WqmLZR7qCDeRv4f4oPWmBTWudRMMgFhOqBlbgcElMZcm8lFjqI4zeNYCJLU4d4gjXclrBA75L/viEgJaFom6HttIWDtgxt/ck6X9mF59460b0iRMKgp2rPA/LXpm/FFAVxI+qoXYW3rMwanokean9jd79VpQgRaCoXHdfIjMpttsfcoZxAQvlpey8ESzWZQ4Q4YeNcpyNmxu+qBxBpNJ8sQC4DosEOLKzWGqqYdW+NleA/869e4+78BnWR4SA8Z2mcn0EDTTZ9ID9ZE7H3lSfkJv+ahuNUJQTxcEgsIQ6cs3UwLrzaIg== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:21 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:21 +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 Subject: [PATCH v11 09/25] nvme-tcp: RX DDGST offload Date: Fri, 3 Feb 2023 15:26:49 +0200 Message-Id: <20230203132705.627232-10-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0078.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::17) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: cea5c3bc-a12e-4f99-6d93-08db05ea84ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 09S4SLc5mLPSwCW/PyDtmFi+HOey/3olqFW3yisIAVoB7slTnA0ob42WxSkXqkUMnsUjnGTQNfbNj/B77BfiM1UevIq3YGmvivrWkq/VSnXxuKa0vu/O7bDwGM90sEV4xlJrchoFyWqf1K7FH9zcLBYI5Ku77A/fnYLyeagXb7pv+UT+kj9tl8kqW6SbY5fhFwyfgKgl4jZv+tSxeGxP+D/FgEUvSWaKfQOI6t+OgYChW2bQSvBgX7NvgC+ULYQ+GAXwZk+sTDNshPL7RLEsPCFAJKj4TC4Vs0qpgeOwYq8KvZOq6MZQKSq2K6RRZUKFgUfas3N3yIUDVu/YVpUzlmbKRs5WM966qjYu2p3NeLCQDWoSHVRevM3x3HaqDdfZ+oWJ4IBVMHWR5ezvTp2T7X86KjEl5VIewkkKlbh4bo8iiSa2sd+ijyvgc7MUno3mj1wSIrx7FiRjqJBRiRg09hCbTR5N2f8CTRq3RMRKDzmlPmdrcF5QFnlPRGFo85bU9xWWF+NviQX6inwpQF945LTmSpS5aXUJ+AtO1NWgC0/A0UAK6NQIyxr96ai+f/Vo0HahfpAzGNb6KrF+1c2fj0YWd8dpwO5P1uBQ/We0T4Bq+s3GVJfScokhVVA08wpfRgL7NVW2VHqvqyVsx3Z98w== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7PpVl+66p9cbNOKIT/ikBEeqWBrJ+6tpaZjMzit2ppLlFwXVTFebBiKWjcz3Bg1DuJ/RVM5WjdPcxNyrjBGaa5vhcXlq5tKdfyR3G0TDjYZm7gCETTHo8jceXyxaPvv0+xUh6DSZEFavs6yfcVZXCrZ7GGDesJ0ZtZOAh+iAV/MnddQGj599oMsEeiJGaDWRHHbkHvruh9Dsp8Mt53FMmA9cfYWK6eeyKWILeTwgHZtQqHXTLEDq5tHX0Kax/jZR6dn89GqxqC78cfmqDmngYIO1Mf6lYu/KNAqES24PRxSgxCxpocz9l61k36HD1K6gJkl5K0AHJHlP3THogWohlcWxGiYWtE3PFz95+seH/grocVcXdMxiZUAV9pYkMdCP5GkK2VAl2sHxxUUh/bVbAm65Veixtf6yw3U78+u1/G19S8z5Si217tKL8M2/H3B8X2JyfTbVGX7bNpYrqMACMvp9gZEKye3Z9TBFuMhI/Lg5F102cpi2RqClhDhi3mOJPzHUi2PdXLY5hidSWi/DNoVPjQXfn0XVEsP3PllXztmqB6+w8zOECklxIdUS/uw8N+VEHYHh6NvVqR0WQ6w13vVBcje129XytlZbHs9B18JJh3zjxl+oew83XLgsW0pvp3xtJjwx1PWwBt2J73YYm4TMfwP0Z1QnjWJfnjtuBTwq2Br1+73YPmHaJq/mUq86idabWU+lmHVYvhH9bXKtQVZbRXLVr5ZQQjHTebrMgOfvVbVfkphmpOVEi97RYgevMlXe11FzrYMnvRH82GijKwg4jVYNy9DDpsqBxh/w2BJVxd4tzUTguaDRMbRWOxXobno9O1duImOKu7hGpJaavEBXZrLGL8/mtkG78QFpsW8JyJKxC/wo9ND0Z/WYhW4yemJyAExuEsuLbpgaJ3+Lxt/RBHftKREvW81RVwcBJM6bUE3CvnctgBJbweZlgLA0GtQvE4OUDUNDt0j63EckIxqjD5JAO2zLRZVByVE5fWIncBarzjyq/I2MPxhiBdE5cJi8eXgXfYch5aGUFOLLtPYTXWP+2X8qamwoVcrpzSu/iMw3wdp5smWPHBcRJbmY16rX8tdhwJ/HNmpEpwIYfUFawyvCM2c7FMNTMzOugnkSOmF43gOj2hc0d+/3F3pFw6ay++Hjau8IY4RT262y45EIxH+2lZhoC/vByiAfUpgV3jqhC/ZUCeNN50JXbT+y27h78IDBaMHMXgqaHKOim53FsuaACU4+Jnv7wcQhW9YgOx+lYImVvkesI2MuQMDNskTw5DAg5fqC1mQ6EKcIBhFr7PPuPwvVHADhf2HWEoJyYwsjZ2XccjT2VW+30UxB1ZyDFRxwpbA3Ez0O9doXjgPMp/CmWebY62y9Cs1gEt8mmEBZEeD9CdbmFrfGWh0Vm71/cF96/M4rOtPKBnXes8Fqxy81LUmmbx9HDsjxNSm9fhGVpVwtD1vELwwHjoGILHeWdB6AwMbJXcpFnOSDYkIAn+BFwTvd+QWDmk2Gua4cjxkieFyJQJVBWWPqmfX8SyhSVCtvhGOY1+ErCp6VXCjx2xhgsSiO5/q/xzZ/UBqqp9Vg/foCQ70DnyYJd6dW X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cea5c3bc-a12e-4f99-6d93-08db05ea84ab X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:21.1245 (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: dwELrmrfC7xwn02HwnCBOlXCadzja0ma3QgrQJu3/tPnUe+uStb0eNMrnyE2zh5W/VMI7YA5Q6boZpjl7MeCCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 142 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 128 insertions(+), 14 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 533177971777..7e3feb694e46 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -116,6 +116,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 { @@ -143,6 +144,9 @@ struct nvme_tcp_queue { size_t ddgst_remaining; unsigned int nr_cqe; +#ifdef CONFIG_ULP_DDP + bool ddp_ddgst_valid; + /* * resync_req is a speculative PDU header tcp seq number (with * an additional flag at 32 lower bits) that the HW send to @@ -152,6 +156,7 @@ struct nvme_tcp_queue { * is pending (ULP_DDP_RESYNC_PENDING). */ atomic64_t resync_req; +#endif /* send state */ struct nvme_tcp_request *request; @@ -288,9 +293,22 @@ static inline size_t nvme_tcp_pdu_last_send(struct nvme_tcp_request *req, #ifdef CONFIG_ULP_DDP -static inline bool is_netdev_ulp_offload_active(struct net_device *netdev) +static inline bool is_netdev_ulp_offload_active(struct net_device *netdev, + struct nvme_tcp_queue *queue) { - return test_bit(ULP_DDP_C_NVME_TCP_BIT, netdev->ulp_ddp_caps.active); + bool ddgst_offload; + + if (test_bit(ULP_DDP_C_NVME_TCP_BIT, netdev->ulp_ddp_caps.active)) + return true; + + ddgst_offload = test_bit(ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + netdev->ulp_ddp_caps.active); + if (!queue && ddgst_offload) + return true; + if (queue && queue->data_digest && ddgst_offload) + return true; + + return false; } static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, @@ -298,7 +316,7 @@ static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, { int ret; - if (!netdev || !is_netdev_ulp_offload_active(netdev) || + if (!netdev || !is_netdev_ulp_offload_active(netdev, NULL) || !netdev->netdev_ops->ulp_ddp_ops->limits) return false; @@ -314,6 +332,18 @@ static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, return true; } +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 int nvme_tcp_req_map_sg(struct nvme_tcp_request *req, struct request *rq) { int ret; @@ -328,6 +358,38 @@ static int nvme_tcp_req_map_sg(struct nvme_tcp_request *req, struct request *rq) return 0; } +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); + + if (!req->offloaded) { + /* if we have DDGST_RX offload without DDP the request + * wasn't mapped, so we need to map it here + */ + if (nvme_tcp_req_map_sg(req, rq)) + return; + } + + req->ddp.sg_table.sgl = req->ddp.first_sgl; + ahash_request_set_crypt(hash, req->ddp.sg_table.sgl, (u8 *)ddgst, + req->data_len); + crypto_ahash_digest(hash); + + if (!req->offloaded) { + /* without DDP, ddp_teardown() won't be called, so + * free the table here + */ + sg_free_table_chained(&req->ddp.sg_table, SG_CHUNK_SIZE); + } +} + 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 = { @@ -387,6 +449,10 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) { struct net_device *netdev = queue->ctrl->offloading_netdev; struct ulp_ddp_config config = {.type = ULP_DDP_NVME}; + bool offload_ddp = test_bit(ULP_DDP_C_NVME_TCP_BIT, + netdev->ulp_ddp_caps.active); + bool offload_ddgst_rx = test_bit(ULP_DDP_C_NVME_TCP_DDGST_RX_BIT, + netdev->ulp_ddp_caps.active); int ret; config.nvmeotcp.pfv = NVME_TCP_PFV_1_0; @@ -413,7 +479,10 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) } inet_csk(queue->sock->sk)->icsk_ulp_ddp_ops = &nvme_tcp_ddp_ulp_ops; - set_bit(NVME_TCP_Q_OFF_DDP, &queue->flags); + if (offload_ddp) + 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; } @@ -427,6 +496,7 @@ 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); netdev->netdev_ops->ulp_ddp_ops->sk_del(netdev, queue->sock->sk); @@ -519,11 +589,26 @@ static bool nvme_tcp_resync_request(struct sock *sk, u32 seq, u32 flags) #else -static inline bool is_netdev_ulp_offload_active(struct net_device *netdev) +static inline bool is_netdev_ulp_offload_active(struct net_device *netdev, + struct nvme_tcp_queue *queue) { return false; } +static inline bool nvme_tcp_ddp_ddgst_ok(struct nvme_tcp_queue *queue) +{ + return true; +} + +static inline void nvme_tcp_ddp_ddgst_update(struct nvme_tcp_queue *queue, + struct sk_buff *skb) +{} + +static void nvme_tcp_ddp_ddgst_recalc(struct ahash_request *hash, + struct request *rq, + __le32 *ddgst) +{} + static int nvme_tcp_setup_ddp(struct nvme_tcp_queue *queue, u16 command_id, struct request *rq) { @@ -806,6 +891,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) @@ -1009,7 +1097,8 @@ 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)) + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags) || + test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) nvme_tcp_resync_response(queue, skb, *offset); ret = skb_copy_bits(skb, *offset, @@ -1073,6 +1162,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; @@ -1101,7 +1194,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 @@ -1143,8 +1237,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; @@ -1155,9 +1252,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); @@ -1168,9 +1281,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)); @@ -1981,7 +2093,8 @@ static void __nvme_tcp_stop_queue(struct nvme_tcp_queue *queue) kernel_sock_shutdown(queue->sock, SHUT_RDWR); nvme_tcp_restore_sock_calls(queue); cancel_work_sync(&queue->io_work); - if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags)) + if (test_bit(NVME_TCP_Q_OFF_DDP, &queue->flags) || + test_bit(NVME_TCP_Q_OFF_DDGST_RX, &queue->flags)) nvme_tcp_unoffload_socket(queue); } @@ -2011,7 +2124,8 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) goto err; netdev = ctrl->queues[idx].ctrl->offloading_netdev; - if (netdev && is_netdev_ulp_offload_active(netdev)) { + if (netdev && + is_netdev_ulp_offload_active(netdev, &ctrl->queues[idx])) { ret = nvme_tcp_offload_socket(&ctrl->queues[idx]); if (ret) { dev_err(nctrl->device, @@ -2030,7 +2144,7 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) ctrl->offloading_netdev = NULL; goto done; } - if (is_netdev_ulp_offload_active(netdev)) + if (is_netdev_ulp_offload_active(netdev, &ctrl->queues[idx])) nvme_tcp_offload_limits(&ctrl->queues[idx], netdev); /* * release the device as no offload context is From patchwork Fri Feb 3 13:26: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: 13127523 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62E50C61DA4 for ; Fri, 3 Feb 2023 13:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232640AbjBCN3E (ORCPT ); Fri, 3 Feb 2023 08:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjBCN27 (ORCPT ); Fri, 3 Feb 2023 08:28:59 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D057818AB9 for ; Fri, 3 Feb 2023 05:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KI0u7NiHJD8NOsks3pHW9WDI8J+DcEs7snSbanKh5J3hV6TpDYDz7OtzBwkWcx/D/ujcWY7GV+M4Vq/LM8ejlJY6EX+HcrML2fDlfmr8wnatycFDgmgp1nbbgKp7wJYFTdBG7HkW4FkqdrVLNmUNX+fGitHmb0UQ9ezcvEBeu2lLp5lVyMVXNcVIQlKePZTp90z/2PBGtO7pnR9KuJ0ky1qI3TiiXQ5fB/EZLYI3UEqEr49PDhnzmRfflpi61Tts7z0ug1dah0576C3SQRH8CNzd9ilkb6ResRjv3TQnqAZf7ehpQWmPEKIYCG24mK/30WKTVWUkMxOPr1O54bbvWQ== 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=u8hQlm38ob57LZCfpyEknEa7+Pk/gayTbza+DuQqxvA=; b=T+x+X6fuKJrayLWRGlIwTWtP9j1uQXetJ7lAIulE8A6403ObY6dSa9zo/I6am972g5LDlVVc5Plm4Uvv1DPSsEx61sVp9cl8mWSYvjVqUIl86c6xsb8IqDrznRfJXztt7MReX4HFLkEhTJlI8NTJvk5txZ9LeWbL1dnAJQH3xz56Hv0t+lmQXYpEP/LE71Us6Xp7F+8mcalgSU/XYzLjXEWk65NKo1gwx+CZFSuAYH3zCX7oTlFXUwNK/J290a/gcqEPugPouHjKNgH9Re1ZM2v8XOVCJPWKNmcxieiOSDGcHEegtrQsXtAKBVq23kMXSHOAADn4DAqfn7Ll5Hj+ow== 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=u8hQlm38ob57LZCfpyEknEa7+Pk/gayTbza+DuQqxvA=; b=UmdLWUmwOJ0dSD9Td68mCjsAJyA8IErX0URogifIxEt/KtlR0DmUwEqKLxpn02G6Hcyj9tIkMDjHoCypAEd9JaqlaEvZ4CPWnDSdaKmeueCTkSe2oGZrQwmXQpblQKbSYu9vV2aLjn3HfBrxMcA+h1aRzu3f3vDydxnOE6V6h6Im8lZJYzeHoJTZt34JpFnIsO7UXlwL5oJiLr/TD/FvJIK6lSxgr9Chv9P6Yq6PD4uXE1TEtDF66HENeFLUpk/7I2JxgK1RhMyuQYmuBMSNiWon0e47b8yaGE45hpcqDXcwU3ydynR/hGFPteQjJic+e7Pa5ZrpLfLxN6SwWEvQZA== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:27 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:27 +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 Subject: [PATCH v11 10/25] nvme-tcp: Deal with netdevice DOWN events Date: Fri, 3 Feb 2023 15:26:50 +0200 Message-Id: <20230203132705.627232-11-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P265CA0379.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::31) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 68c2161e-3a52-4098-4b2d-08db05ea889c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kVfXP8gw3sqCvXzmg96Mq5RxshWSvGo3eEjAS87Hgn6agWt7FjNt9Ug8041a37gaG4F9kzboQlK1P6zNqlPSO/9gZclIPLwnInBgjna+XsL7TszROe+HdZnnszEGcm0HwoURNtQH59HGgYwVr8ivNwN/CfZ2wk6qfPrYhOm8HWPy8qg6e6oGD1aIN8qKghjdmL4CYBixcFOtoVVAr9Oxc0EyyUGOGzUtmMbPcvjHS8yearHsyClQShvw+7+EIZvitqvu+AZ1UXDdmUopk0uw4AFLXDT8FdmLpSHffoBsCE9UAWt0X33BBSlu4POqORrpqjc5Hq1vi+4MsQ91kxUr32YP481/+TI37fBH+roBj+KRUEWKS7nFH0GtEebVY47NjxcVSjr2sIkyMOYJu6GgFOu5P1UzyQkPjBKkHkPjyUnaIbmYFtLWlC2ihF/qFWf7VeJc2fE4nvOFkUi5Kun4sxJxX0loXsobh0yqkVdJq9b6Pi2ipe7xqPTmQ8FYZlN/BUllHu2/p97DZQJQt/dBn571fhB3GTyFgP0g4IFD8uPAAzel7bbllE7eSthgPYk15PZ/Z7iWaTe1lTMQ/0/IlEBcLd4xDr7GLv51G5H8KfEVExqRAFIiI9zcRqjMcjEHoLsOgR59or5CinsQlWYSQQ== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AlVH2UMGDVig7KAdr2Iol43y4VAx8rUPYe6UhCeAjYJYkaAL2Pggyw+wu9iLlcfF1x94rx23jGjiKVs3s0tG2CtQ4syfTaXJz3ss0x6gZCzofyHQt61SzJpQOLujcHPuuM032JHiycjjDUxNJkvTlXaJam7BhhG8XoUtn7tTmMAyFsrZdQnwt+dQMMxsd38+LNXRq3tAQZZq1iVrwpbyvrP8uwECx3C+OCDBFkeP6tsq7w7yFJ2a8CMX4ACMHM3EkFZ3GP6Ik1kqnlMae0P+n/xU7Jf4OEtxCH1HLPFc3mh2Nl+saexHo7VRqN0K4ib9oVeauA4EHAUEetLPZ6iMD+mBftcykxhZGUFF+IdV7FRLrIOJlGVmsDnQy3FzjatsHRGdZmUM7gnyxiWFB6YD7ZxlQIuqsgjy+ohQRRUKknqlP6RLGD0EgCJHJQjdPIhruGHKNwp+VTukwGsDgE3t/BhSpPI60nUcMw1KneQ4GQfvcslNT92SEaOBPgjn7UkOXN6flH7rQwkuSPLTtK2IqspXJUyt3iHH7fgLMa3sRmrA+C0YNMU6eZ6vDFwL8o/KwjlUslTBhgWzr9m0LG//0e7SbCe2Mewbc8G5idBn6bCgMcSL0IKhBwMqgX287U5JOXSLhdbJnOq5Xw0uhYtl/Ej3tiUUIQoUxjUOcQkHjwvwlys7lQceRaug21n4d2rhtj6fHJo3lS+buAe9bqca02k0kwZIGFvQ5IW46qQodeBbHpkEnTB0rlrhV1qV6sGXjSmL+Qv+QjBQYvsDFyXFhL11yeVp1HXSfu0VTaZD9GHc9bYppZw9pYr81vknEh/ek2iaFHJXyiazwJAy7zQQ5KYM5M47S/2RqMUJm9z64rbpzTHRbrOmfHzSVS4KX2NMJd9oRJPvwXTOdFaG8T24AfM/wnrQS4DHZ2kAlGUZlUcrEMY+sSp2NmQvyoFbsPx8Itnrp8C+KwWh4geCt0c7ztuo96j5FrqIAm1ACfxYVX+QZgBiJiKVYz9t4iKd2XhbMUbnj88FAkXG/ShuPcUm0sQAyYXhN+4ioEl2Q1nhApW7IwhfnNuy3UwYaZbJ/pJfcx2PIP+4pwjAtjbqcXBYj4vWlE9HKmoxotxr8GAabK7jdihdXAADW+L6T2EV2h/ZdFOk5qtIIu1Sc5gREa+8b9io7etxzhRDqaNBbtXoKWVrWIZpbyX5z4tBBbeI5WgPsEEhG3zCY9rrGRBcDcAyA5b+7IFTVPFPtNKZN5Vaq3nllY9rfDIJiMc5PQ4xVS34/0zreTOM5o/PykG18UkB+ie8OX8t3BwmWlhd5M1dgetTA637siXap2P/fGUFk4S55xKJ87EjRpXL9Z7IoszmoXZpQODT5uBZKg/pjLn4eZwqZYcpf+k6L+KT7PwFm5gNMqQMTafmt7fDE802ZZCqtLbD5xViyLZezWmRuyHQdpbGJSSNgXf8BiXraHtP5avhzjgM93mX8bRGa3p4ayp2XN4yvC7GfLgk3NUhzb6dgRdTnahg7vb89clG/RGBdAbfHAuW0vxApwkSZExkQyY6+L3NBruXv9t1yUAOMOet72Y5pvMUux0GJ8BcB5+1Ly0C X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68c2161e-3a52-4098-4b2d-08db05ea889c X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:27.6737 (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: 2FW/FXjvcxMxij4vZZTOkHe/aI7My6h2Rtne6YPtYHMoUOcWWkGV4Mw8TxkLGH49qxOG99NFC3z6o0hYLcl1nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/nvme/host/tcp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 7e3feb694e46..732f7636a6fc 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -204,6 +204,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; @@ -3129,6 +3130,31 @@ 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) +{ + 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->offloading_netdev) + continue; + 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... + */ + } + return NOTIFY_DONE; +} + static struct nvmf_transport_ops nvme_tcp_transport = { .name = "tcp", .module = THIS_MODULE, @@ -3143,13 +3169,26 @@ static struct nvmf_transport_ops nvme_tcp_transport = { static int __init nvme_tcp_init_module(void) { + int ret; + nvme_tcp_wq = alloc_workqueue("nvme_tcp_wq", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); 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) @@ -3157,6 +3196,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 Fri Feb 3 13:26: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: 13127524 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA9BAC05027 for ; Fri, 3 Feb 2023 13:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbjBCN3d (ORCPT ); Fri, 3 Feb 2023 08:29:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjBCN3b (ORCPT ); Fri, 3 Feb 2023 08:29:31 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30AC39DCA4 for ; Fri, 3 Feb 2023 05:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lCoVFzsyPQUgWMsIRSaKB1aIslRc4NeLTPyzP4+eax/RLbpUGTjKQJLbzU7YJ5A3lINRx4gkAfqF89poKr32MhFfVfsrf+39t8icFG/+38D5Qufd53dvfKYfvdpTBEDigXw0quKQdmS0kuP71+Wd00ifrciU2FmzBqCkM9CKyMoimZPXuCf9Qr0F/FkYrP3ccwQLQmJkqC6mobV9ngfXpv/ttj30/GaqHIiusZq8F8FoLpUycsMy9dHq+PvY0q0I6HG037UOUaHvpaohtX7VNnEJNcFJIlxbGQQmrIjj/QnZfQnR4A+fFzOqGQY7YOyXDDWbVnzL1d/1kLdmn6hKdw== 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=jCiauWn99ADUgnt49BHQiM1fFhjd6SAs013ftypHSBs=; b=E8l19AK9Rxu3LTSq9qYgLqz9+OCE/qOf2oSw+UmuSlzNJB9zpVkdx1OLhbMvqEGud9vBY3+Szjjugw3tMTmgYZqUdrYLKlm9Spo2/ni8aMWyU6yZADvFw4HJAkXZTOkYTQqIwOpouIusLt6No64K8l2mc9NMJMmdQtbHMCjeWPWneiqGe6vhqjpfutcJj5fUxUhNUZkN/MdhqqZT6DRn0TaxTOO20ZUXbudO6ZTeIFBcw7dkzkin3V8GRBMoEZAhSwd8RVEZp+UPFbIrYIYLrYIGbR9SUW4jQuLKnrgr042NGHvvnD5qnk1+ZwmX9nopB10I+5+yxzvs+1PqS2gVFg== 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=jCiauWn99ADUgnt49BHQiM1fFhjd6SAs013ftypHSBs=; b=irp4UPwtAZmxUr7k8KC0jYfY/qjWpNoChl6ndhKxbze+Lf6JtenDQs6rEG9y/ps/INaCOrKZZYeHmX5U5RRu5MHiF12ck1XxohbmExuhyVQwS5qK/VzCWS/jiyPjtwHZcpE5sDKptE2UAd8lXbIl+zGpC6ikhKBOe79K/TwHalpuSjl7pYFiC1x8wqswMwpzr2bLElHFqAx70h0VmiZkKOg1lnATdBFRkB23sQLWpRi5Cn6bY+h3gXxm0Wm5dZTak6wkbMbZsk+tm3EAZJpgXci0FZWS3AvLzXMadUGL1wd3i9O87Tg9dilDpS2DhKkgXFlAjttBnE4g6ZfarEJmtg== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:34 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:34 +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 Subject: [PATCH v11 11/25] nvme-tcp: Add modparam to control the ULP offload enablement Date: Fri, 3 Feb 2023 15:26:51 +0200 Message-Id: <20230203132705.627232-12-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P265CA0376.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::28) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 533f6cba-383f-446f-80ce-08db05ea8cb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F5G45g1zzBD3sV2Mktkctp88tiWFn24PhC2vOKBVQ9Ja/QPJV7D1Ljz69xYvi1zIAI8ncnIgUWPEkLM9LOB5+SAuJQjIguc+5MZb2oSfIPHQoi9U7jrYeTdJLT5q0+kfz0vsmVki58L+1LvpQ13q7YSivbVk6bIF+w9JWES+2QXB1DWLikYgTnl0nVoHAvdAHWEf01wSXWqFnXY1gXe45TME3d975+wp5qSuB2EbYZc6rrYKy2TjJO5TEIC1yBHg6BeZVtc6DCY2D0eb0q03NTsUl5srIAeTWLcj8jVDhY9O5ScsEWTmGSP3C76e4vgMq9hsJtISOQQ4SzwkeUdGE7p4cqKGjk7dvsAMZhD0COTcmrDD5NAAA306Pfl7P0h5OWIv6BaGiRRHetst3jA/auoaeD6WfihbtDlYvQ6MTZbRaaVJbuH4/gKm531OoGY7B6RIyHjDciMNnGXdLTPjzdo73mGRR/pXgQUceSoPubH8l7wA9pDEmg+ADW7CNmqSYl0kGOpsE/8WLvFLMUsecHV4bbcV7ppCf0fBAzzAwiKeapN5rz3OyIB+oaBy6F34Yo489nLhQ4ZugAu11gI0i5PBUeKCy8hh/CbQ7EjlcwmHihASJyJIyJjPBnO5lwMvhcCABmbnnAw6x2nmI/8vJg== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eMVP/+iR+y6mnYIoIQNZo+x8xmTIDY94n8BUDNeDnr0Os0AG2yErHFr8T55veeARD4bIBVT2v2MIX93RLGxAUnzWrRdKuGv9cz2bfPs2U4Bpu9oWQo3zgt7V7asygY8D8cDR0od9fg+m41ulw08mVtBe/JmwyA6hXiYmd2jhYeSbOfXWdRFDzY6C18TIg0CrQwKRQe6N/NMKDgwjZQvfHiX+StsbQHaK476WtHmV78jOuj5fVOyzXmvi9+vcDb9bBXXHr+jlWvfyoo1y+nU7BScs5oKKBz3Sl6ZfO4nlp6l8i/pYP7PFfGc0q77+UzNFwuMKrU+hf/4Creh0CCnTkveoHrDwJXy+ftbe1BCl6JMfkUNKfHcoQdKwTIDgAzerqEKL1kIEYhTB4E3XbEVlO/ldogdmSWhem10P5qL19I1KuRKMXGyFS2IdSQDy+jjtqWt4lfK4ij2m7yBO8yf9GhtrKuqjGz6A7vmBEKIDhErMXND/3KwjS9TgDH2ftaCN+nmVZGDIhLCArV9Bq1TY3JCQb4+xb6LDfpBH96i8jgNDYyAbEhS7MflStKqDG3gvGQHe0KSCxPAufRWDAUm8DjNMRS7c+twm0ij8SJ/hpS8kQRNN4PlIwYpHtC7eHlMWEmUmu7ZCOZFFgSYBdIhnmA7e2bVBHQB1q4ihCBaD5w+b945wdaN3zSYwXnNAwEP9JwP+X8iqbZqlGGicQ1bhrwhpDPKerf0cjGP4P8/GYQQaUbvxUwIqfaflWtT73f3nHZTCsK5KDcpvk5oe090lAj9GEnNT28uotjIws0v/D6WICLuUs3hqP3JR9DUSyLAxp6GsRD2jWpVLJkpGs6+MPBZhhCkWgGZzIZDHKePLxKS4aU/k5RlDrDDLSjEX31xewG690MsihdzhoMYMTypcbrQ4F0hzjCzN9GDUvMaU0uwftsto+vav2i9Se87op88Ff9qtM0qB4M/Wf0nJvAS3Xr0oi7mKnEmFW9aZGwOz4IouALbY/nGAZ1f16vdtM5aKOjwJqXgKGa5+Hty+YZEmV7AbJ6pMh6/AxBH/yxAXLiFiNnMIfR9+kTdcWHCU1ZACe4XyEBoTtpVkVgGsZllz3nEyR+XWW4Bd1gTDWEydWHeQTFq/ofJuGawBoMwdplFFyZq2ifQwvtub+CrXjLgC6byFzyE7G2VXzQEu2XRgazyRCmASyqzE6cVfWN8JeDAPt9z53CF0+qr6nL79Gyxk8GOksWS/wf0y6Lu8pJYYqUWFzlsJnjhSRmkeYUaEo+Jg2ljA2XVsWe1tan6V0CS2u7u6w3dAiSerJh4Xo5oSS1IBEp0cgU/qz4ispmYeCd4I62xOIbWaWVBR/v62T+gAJrN3IgL9bSCFu9vAfMTeSNMswXKvVhh9joAgmD+zEbpOnqMHiCI3lma/W76KV8cATm71q8VHx3L3YdkOjzVNusaeiAQt+j9A4ICvJR4jXDbtEb76JPCQdnca698e9x3oqCZ76RJDpqki4wZy3hoIJHtHHXtj2nPaM+mq1qRoBq+E8QRUhkNC2kHE0qeTLVNeqthA+siFc31Dj93nWcnzUWNcJeBgMJ2NvQjJ+KANKefy X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 533f6cba-383f-446f-80ce-08db05ea8cb0 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:34.5170 (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: E3EWpE2VI7QIZdpHAhcNY2kNfi1GiG/Ni3fSEWF9OnGxbqYVYrTSx53vnQ7k8y5Ab/DA6fE/LhtOrFyG1oOJPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add ulp_offload module parameter to the nvme-tcp module to control ULP offload at the NVMe-TCP layer. Turn ULP offload off be default, regardless of the NIC driver support. Overall, in order to enable ULP offload: - nvme-tcp ulp_offload modparam must be set to 1 - netdev->ulp_ddp_caps.active must have ULP_DDP_C_NVME_TCP and/or ULP_DDP_C_NVME_TCP_DDGST_RX capabilities flag set. Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel --- drivers/nvme/host/tcp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 732f7636a6fc..77422f49fc76 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -35,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 ulp_offload; +module_param(ulp_offload, bool, 0644); +MODULE_PARM_DESC(ulp_offload, "Enable or disable NVMeTCP ULP 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 @@ -317,6 +327,9 @@ static bool nvme_tcp_ddp_query_limits(struct net_device *netdev, { int ret; + if (!ulp_offload) + return false; + if (!netdev || !is_netdev_ulp_offload_active(netdev, NULL) || !netdev->netdev_ops->ulp_ddp_ops->limits) return false; @@ -456,6 +469,9 @@ static int nvme_tcp_offload_socket(struct nvme_tcp_queue *queue) netdev->ulp_ddp_caps.active); int ret; + if (!ulp_offload) + return 0; + config.nvmeotcp.pfv = NVME_TCP_PFV_1_0; config.nvmeotcp.cpda = 0; config.nvmeotcp.dgst = @@ -510,6 +526,9 @@ static void nvme_tcp_offload_limits(struct nvme_tcp_queue *queue, { struct ulp_ddp_limits limits = {.type = ULP_DDP_NVME }; + if (!ulp_offload) + return; + if (!nvme_tcp_ddp_query_limits(netdev, &limits)) { queue->ctrl->offloading_netdev = NULL; return; From patchwork Fri Feb 3 13:26: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: 13127525 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74ACBC61DA4 for ; Fri, 3 Feb 2023 13:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbjBCN34 (ORCPT ); Fri, 3 Feb 2023 08:29:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbjBCN3x (ORCPT ); Fri, 3 Feb 2023 08:29:53 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6272F9EE00 for ; Fri, 3 Feb 2023 05:29:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDVPtPQqhm6Mf+iOZhSJvh70xc2JdaLflO29lG0coG2fHgF+sdTkxTLqXQlopheIsgNEg0JGtbreIyVlv7kFk2ceLbkceCSJYI0H0SjNDuwAC9qX1ydkxLi2NA1/kCjAlI3qdOeRIM5YVcGD8iszWBg3hgBpK91QILMTpC3zGkLLLlcJdHAFAr98hxkJhhJXEx4982R90/DJ3VrIAT06yGuR+tncirkrs+GCOkltRvfNMa22o7sPXjUlHbFSzDIx6RRCNNqtpl6EnJHDTw7XlMALuFZocFlXiZgkszEPCsFQ6Hb3LzkS3vtCwXRNNEzLNl3fo1BJ1DuMOpCsfELPdw== 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=teW2JbBgJXrz4HucoJDEr5lmCWcj2nsyjuySIXnXxMU=; b=R4LdB0SCWSvcpbX5d+p3b/a86r8PT54nXbHKeON6on+3o4qYttOx/tI85SwnutGucMjgFqr7IgKZoV3qPRELEptY0Pn1szcsPkhH2fIZuuh3DwLQtfaWW1uvm4h4EkV/I/DW/6kguZvW2SYI2qm3jA4mTqANBcSEymmtu9XtMC2sYh0A1VfJTmw9zK4mHYSLKgpfgVY6N/OeXffQTsBAz2ZE6SRLJZ/hmLNHXompQt8SUodBmw5RXASo89tVKxDsGq8q6EW18TtU5duCg6HQNkHB698+gZdhr9KC7TyDWbg7qQlI6vZCR8ikQWPJWTgWbL1tMljUKbPOSiuscAzxAg== 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=teW2JbBgJXrz4HucoJDEr5lmCWcj2nsyjuySIXnXxMU=; b=ct0RybluXqcUF3TKv/oN6+e1zbFBOCEILSa56UKaX95XtFfiO6xD/wNr8oXWQ4BBSKgoWM+Sr71zwmPjXueVFNcmGiMOiUD6h1Q+tNGU8NJoeDSWuCiWdNYjvrBEqNcWt/ZsBTroDludeo3DDsNWQ19XSTe4JqjI9pqeCQTVMbQJosT59QeBRy3Wr54Eca/0eYRf/nK+lGAkcXwuT9fL6MjLo8EdgINIA4ElWPsjEuGtvFi6zQVahm0Iq4sW1IQuysvb36M8/UR2PKsLgTIdLIz44CKRd+nfUk3UoZ5+etL2Qu9SXR8/O/bEx+lt5EuenRyw3IRPIgkyuy8o6G5VbA== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:40 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:40 +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 Subject: [PATCH v11 12/25] Documentation: add ULP DDP offload documentation Date: Fri, 3 Feb 2023 15:26:52 +0200 Message-Id: <20230203132705.627232-13-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO4P123CA0116.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::13) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 20fe1bc8-6188-4909-2002-08db05ea9025 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NSStg48HwCm/HhaPtWZ/F5Ud/IsII4d7bkbX2h4eT44/rVF3dVpsufG/uAVbfb4+0BeptTMa+xBaxybeywEwDYWoxeHzRI2VS0RUOj0kXoeeBQGjSg1nkeYNrGQ/xeEKQEIQH4Bx214pbxM/V0+rUa63N5jfjpztWgbkf530ZEePZKeFLy1wXHSTwJNqk5ba13EDmoWrZVbFAGzhJeW4qzaN2tiDKuTs80DmukIHtrltEZZ4sX+9HXHPyk4snMZSs90jXiLA2t+Lip6jNFrgnpQvqO2fY38LNQbCj1OjObtrhz/n+TLTFJIgge/l+siZUmW5QGl8/ECojnRihe15jbxaMrWAFukNcQU2+y+YXfbooADtPonmgpX+pBJT1ovY7Gifw36SGtQlEMBr42Cj2vDuWVwhmWoR6lFbVT1DWGpHFOrWHfVx0hR9O/UbDS0vJa4VurHf4ZtH7mGUhTx40WgEtINXSGwMgi6oetyWkLLrAKQfq5VCZxGM2LMePdfH8v2w/DiMxoK7PdNPbqMdPj/RSZFwFLIvUreRdUrB3yjrl1r9n0aYtbaYXFZmefQGKpDxvx6iKu7/ovGNfZn62sSrasfV/SjxSXQZuWRsSL/KD9JjYiqq6a/xnKNkw5r1G6v1hoOihYZVb9MqrYwlGw== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(30864003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5Sdy1WhwKhTq75fPLmrtnuB9oM1uGVwP/i4D3WIBM/ZDJlwp1t1AaFqieuan9vY6IY76xQTvOy/fwfTwPh6dJDgCbz4AUbgMN+IOrh9RYEWSWKecv4qBcNZqRFB1qrE0PwSt/Je3Gb78/ERewWoj4v1LM7mjdnLo4D+FgCpCytVnfokjhs5fUoR2JGADeyin9oMzZom+ETYocGBt0udY/zl7pC8ZWS5A7PdQ+/LF9qfzZKkbQUf5xiRKT24YDiFpuBrqcY6IrHjJywxwLUbuU80+oduibbBNJxl+n1x3wNzFd7tuw39iBw028yFlQi/kOjENOOypQJh9f8r/eHz9vrAxSGvUuAxLZdVBB/ptRbGtXXm/+LX+0O7IeACY9YW8RB2kRukaFDp/+tLTO/vv7SORUJHmrFy2cMHoHKXTu9ed0aTcfiJlCvc9KZ0oD8+G7PyZqnvIXQdALE60/1QNRoFbcAq1DNAQOxPE3iWIqu79k0X9bzmLpzf7vJixRx95yWnygzfoPbfJZSklv39wvJsKIHFQedUgL/+oZ3AieI6mhsU8crep6DJ+POyaPZpc72SbbIxUkf3QNd+6j+GQCU74w4G6u/OIBm0ql3GYys7W19VffZJ/gm7dfGxFbOkkm2+ZViphKWXNKvTr4MtJalw5ic/hgB4+wpc/Jfy9/wU709MYD3U94Pqs99N/ZmlChLb1r16WcWP07Ujiluzjd8n/0OPt8UNHJXjnePn0yUVWnmXkpyDfpc/6YO7H2Lm9Bt/wTmH1oEAiHDxhlxBd+dk5Qu/VEx/lREh6cCXuJMmToWM0QJ+lUmLMhXIzDdYZD1oaMDo3XEJ/OUpaUR1jRHj1Tp2sXr5IOcW31imruNf4Wcz9G9ycokhvvjs79V9F1fHKwKfZ69lb5fwOSe8g3/DBeo11RjgLD09MX1s5fJlRcr42a2VX6w90uZSTszCdJeLaO6rM5YmyrT48oiYr2Wi+2wWTeHc248/RfnnGL1S6oHcG53orohWVx8iyu1SATFpyFmVNn37691Otn/2jSGnodZG99Jrk2HifZ1AUayf7b3/P10sotG9wlDCsBNsJoKt1+AKi1RliRXSA4MyRjm/cC9tXG0ffLnUYv8R2AyNCUAFbTlbfmK7DbqZHnbnMr6fv62W9bC8RkLrKQ3wrDYaBJiJKJmJLcIFtFw8Eg787CldiDydZLCDF21ih6EVuGyTiHPXN+FFc31zWGzn1RfKPw9QMQblsqjo5tvJEoDptCSEP0JKeeVX8Vb/ZsVzFIhHhY5SlzyOyQNEeL6nMjachjRtpMea9ykTLR/tAjMju8jaZXgy42CQebKs0lOLZvXe+Z8DQDkKWXb3TZPl4u+gqB+hgt2Jb0OTD9pF20RPlr5j8GdD8ClgZ03BbYPESZqAO99JuEqNQP0YeUVMXEN0SO3a521kMGemvu//YrkLJof1SVxaHMdE2J+qEvDmqxEvND4WUufEhjoQ229VecNuy+kkRzFlNS8pL+q8ODaMtYnU47CvgVhvVVbMJpeegQM4d1zHy8txbillPDESVWWUMOk8reP35AmybT+5DfoydrhVnF5cVZ9mFfW/NKD/o X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20fe1bc8-6188-4909-2002-08db05ea9025 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:40.3457 (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: 8r6dbDixVsnmG8Bs8GjTZ00YF4EI45K7IDELHgHsuRMWy0mVudylbBiShwC5vU3dKx0gWgqAzxHx94iWDM2btA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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/netlink/specs/ethtool.yaml | 6 +- Documentation/networking/index.rst | 1 + Documentation/networking/ulp-ddp-offload.rst | 376 +++++++++++++++++++ 3 files changed, 380 insertions(+), 3 deletions(-) create mode 100644 Documentation/networking/ulp-ddp-offload.rst diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 8932cf310f1a..6c3b32572028 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -453,7 +453,7 @@ operations: notify: mm-get - name: ulp-ddp-get - doc: Get ULP DDP capabilities and stats + doc: Get ULP DDP capabilities and stats. attribute-set: ulp-ddp @@ -472,7 +472,7 @@ operations: dump: *ulp-ddp-get-op - name: ulp-ddp-set - doc: Set ULP DDP capabilities + doc: Set ULP DDP capabilities. attribute-set: ulp-ddp @@ -490,5 +490,5 @@ operations: - active - name: ulp-ddp-ntf - doc: Notification for change in ULP DDP capabilities + doc: Notification for change in ULP DDP capabilities. notify: ulp-ddp-get diff --git a/Documentation/networking/index.rst b/Documentation/networking/index.rst index 4ddcae33c336..bfb57df4b583 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst @@ -106,6 +106,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..285c9ad5bb8b --- /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/networking/ethtool-netlink.rst for more +details. + +Later, after the L5P completes its handshake, the L5P queries the +driver for its runtime limitations via the :c:member:`limits` operation: + +.. code-block:: c + + int (*limits)(struct net_device *netdev, + struct ulp_ddp_limits *lim); + + +All L5P share a common set of limits and parameters (:c:type:`struct ulp_ddp_limits`): + +.. code-block:: c + + /** + * struct ulp_ddp_limits - Generic ulp ddp limits: tcp ddp + * protocol limits. + * Add new instances of ulp_ddp_limits in the union below (nvme-tcp, etc.). + * + * @type: type of this limits struct + * @max_ddp_sgl_len: maximum sgl size supported (zero means no limit) + * @io_threshold: minimum payload size required to offload + * @nvmeotcp: NVMe-TCP specific limits + */ + struct ulp_ddp_limits { + enum ulp_ddp_type type; + int max_ddp_sgl_len; + int io_threshold; + union { + /* ... protocol-specific limits ... */ + struct nvme_tcp_ddp_limits nvmeotcp; + }; + }; + +But each L5P can also add protocol-specific limits e.g.: + +.. code-block:: c + + /** + * struct nvme_tcp_ddp_limits - nvme tcp driver limitations + * + * @full_ccid_range: true if the driver supports the full CID range + */ + struct nvme_tcp_ddp_limits { + bool full_ccid_range; + }; + +Once the L5P has made sure the device is supported the offload +operations are installed on the socket. + +If offload installation fails, then the connection is handled by software as if +offload was not attempted. + +To request offload for a socket `sk`, the L5P calls :c:member:`sk_add`: + +.. code-block:: c + + int (*sk_add)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_config *config); + +The function return 0 for success. In case of failure, L5P software should +fallback to normal non-offloaded operations. The `config` parameter indicates +the L5P type and any metadata relevant for that protocol. For example, in +NVMe-TCP the following config is used: + +.. code-block:: c + + /** + * struct nvme_tcp_ddp_config - nvme tcp ddp configuration for an IO queue + * + * @pfv: pdu version (e.g., NVME_TCP_PFV_1_0) + * @cpda: controller pdu data alignment (dwords, 0's based) + * @dgst: digest types enabled. + * The netdev will offload crc if L5P data digest is supported. + * @queue_size: number of nvme-tcp IO queue elements + * @queue_id: queue identifier + * @cpu_io: cpu core running the IO thread for this queue + */ + struct nvme_tcp_ddp_config { + u16 pfv; + u8 cpda; + u8 dgst; + int queue_size; + int queue_id; + int io_cpu; + }; + +When offload is not needed anymore, e.g. when the socket is being released, the L5P +calls :c:member:`sk_del` to release device contexts: + +.. code-block:: c + + void (*sk_del)(struct net_device *netdev, + struct sock *sk); + +Normal operation +================ + +At the very least, the device maintains the following state for each connection: + + * 5-tuple + * expected TCP sequence number + * mapping between tags and corresponding buffers + * current offset within PDU, PDU length, current PDU tag + +NICs should not assume any correlation between PDUs and TCP packets. +If TCP packets arrive in-order, offload will place PDU payloads +directly inside corresponding registered buffers. NIC offload should +not delay packets. If offload is not possible, than the packet is +passed as-is to software. To perform offload on incoming packets +without buffering packets in the NIC, the NIC stores some inter-packet +state, such as partial PDU headers. + +RX data-path +------------ + +After the device validates TCP checksums, it can perform DDP offload. The +packet is steered to the DDP offload context according to the 5-tuple. +Thereafter, the expected TCP sequence number is checked against the packet +TCP sequence number. If there is a match, offload is performed: the PDU payload +is DMA written to the corresponding destination buffer according to the PDU header +tag. The data should be DMAed only once, and the NIC receive ring will only +store the remaining TCP and PDU headers. + +We remark that a single TCP packet may have numerous PDUs embedded inside. NICs +can choose to offload one or more of these PDUs according to various +trade-offs. Possibly, offloading such small PDUs is of little value, and it is +better to leave it to software. + +Upon receiving a DDP offloaded packet, the driver reconstructs the original SKB +using page frags, while pointing to the destination buffers whenever possible. +This method enables seamless integration with the network stack, which can +inspect and modify packet fields transparently to the offload. + +.. _buf_reg: + +Destination buffer registration +------------------------------- + +To register the mapping between tags and destination buffers for a socket +`sk`, the L5P calls :c:member:`setup` of :c:type:`struct ulp_ddp_ops +`: + +.. code-block:: c + + int (*setup)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io); + + +The `io` provides the buffer via scatter-gather list (`sg_table`) and +corresponding tag (`command_id`): + +.. code-block:: c + + /** + * struct ulp_ddp_io - tcp ddp configuration for an IO request. + * + * @command_id: identifier on the wire associated with these buffers + * @nents: number of entries in the sg_table + * @sg_table: describing the buffers for this IO request + * @first_sgl: first SGL in sg_table + */ + struct ulp_ddp_io { + u32 command_id; + int nents; + struct sg_table sg_table; + struct scatterlist first_sgl[SG_CHUNK_SIZE]; + }; + +After the buffers have been consumed by the L5P, to release the NIC mapping of +buffers the L5P calls :c:member:`teardown` of :c:type:`struct +ulp_ddp_ops `: + +.. code-block:: c + + void (*teardown)(struct net_device *netdev, + struct sock *sk, + struct ulp_ddp_io *io, + void *ddp_ctx); + +`teardown` receives the same `io` context and an additional opaque +`ddp_ctx` that is used for asynchronous teardown, see the :ref:`async_release` +section. + +.. _async_release: + +Asynchronous teardown +--------------------- + +To teardown the association between tags and buffers and allow tag reuse NIC HW +is called by the NIC driver during `teardown`. This operation may be +performed either synchronously or asynchronously. In asynchronous teardown, +`teardown` returns immediately without unmapping NIC HW buffers. Later, +when the unmapping completes by NIC HW, the NIC driver will call up to L5P +using :c:member:`ddp_teardown_done` of :c:type:`struct ulp_ddp_ulp_ops`: + +.. code-block:: c + + void (*ddp_teardown_done)(void *ddp_ctx); + +The `ddp_ctx` parameter passed in `ddp_teardown_done` is the same on provided +in `teardown` and it is used to carry some context about the buffers +and tags that are released. + +Resync handling +=============== + +RX +-- +In presence of packet drops or network packet reordering, the device may lose +synchronization between the TCP stream and the L5P framing, and require a +resync with the kernel's TCP stack. When the device is out of sync, no offload +takes place, and packets are passed as-is to software. Resync is very similar +to TLS offload (see documentation at Documentation/networking/tls-offload.rst) + +If only packets with L5P data are lost or reordered, then resynchronization may +be avoided by NIC HW that keeps tracking PDU headers. If, however, PDU headers +are reordered, then resynchronization is necessary. + +To resynchronize hardware during traffic, we use a handshake between hardware +and software. The NIC HW searches for a sequence of bytes that identifies L5P +headers (i.e., magic pattern). For example, in NVMe-TCP, the PDU operation +type can be used for this purpose. Using the PDU header length field, the NIC +HW will continue to find and match magic patterns in subsequent PDU headers. If +the pattern is missing in an expected position, then searching for the pattern +starts anew. + +The NIC will not resume offload when the magic pattern is first identified. +Instead, it will request L5P software to confirm that indeed this is a PDU +header. To request confirmation the NIC driver calls up to L5P using +:c:member:`*resync_request` of :c:type:`struct ulp_ddp_ulp_ops`: + +.. code-block:: c + + bool (*resync_request)(struct sock *sk, u32 seq, u32 flags); + +The `seq` parameter contains the TCP sequence of the last byte in the PDU header. +The `flags` parameter contains a flag (`ULP_DDP_RESYNC_PENDING`) indicating whether +a request is pending or not. +L5P software will respond to this request after observing the packet containing +TCP sequence `seq` in-order. If the PDU header is indeed there, then L5P +software calls the NIC driver using the :c:member:`resync` function of +the :c:type:`struct ulp_ddp_dev_ops ` inside the :c:type:`struct +net_device ` while passing the same `seq` to confirm it is a PDU +header. + +.. code-block:: c + + void (*resync)(struct net_device *netdev, + struct sock *sk, u32 seq); + +Statistics +========== + +Per L5P protocol, the NIC driver must report statistics for the above +netdevice operations and packets processed by offload. +These statistics are per-device and can be retrieved from userspace +via netlink (see Documentation/networking/ethtool-netlink.rst). + +For example, NVMe-TCP offload reports: + + * ``rx_nvmeotcp_sk_add`` - number of NVMe-TCP Rx offload contexts created. + * ``rx_nvmeotcp_sk_add_fail`` - number of NVMe-TCP Rx offload context creation + failures. + * ``rx_nvmeotcp_sk_del`` - number of NVMe-TCP Rx offload contexts destroyed. + * ``rx_nvmeotcp_ddp_setup`` - number of DDP buffers mapped. + * ``rx_nvmeotcp_ddp_setup_fail`` - number of DDP buffers mapping that failed. + * ``rx_nvmeotcp_ddp_teardown`` - number of DDP buffers unmapped. + * ``rx_nvmeotcp_drop`` - number of packets dropped in the driver due to fatal + errors. + * ``rx_nvmeotcp_resync`` - number of packets with resync requests. + * ``rx_nvmeotcp_packets`` - number of packets that used offload. + * ``rx_nvmeotcp_bytes`` - number of bytes placed in DDP buffers. + +NIC requirements +================ + +NIC hardware should meet the following requirements to provide this offload: + + * Offload must never buffer TCP packets. + * Offload must never modify TCP packet headers. + * Offload must never reorder TCP packets within a flow. + * Offload must never drop TCP packets. + * Offload must not depend on any TCP fields beyond the + 5-tuple and TCP sequence number. From patchwork Fri Feb 3 13:26: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: 13127526 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F7AC61DA4 for ; Fri, 3 Feb 2023 13:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232749AbjBCNaJ (ORCPT ); Fri, 3 Feb 2023 08:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbjBCNaF (ORCPT ); Fri, 3 Feb 2023 08:30:05 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C2F9DC87 for ; Fri, 3 Feb 2023 05:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ho6cuXnRHuuiWRGGXxoLGwDV6ONFxLCRNl8GTKs0bqFV0LiUUHK7HwitrsSclO9RdYznyrGKs0BxLNiojk5lrD6yJ+yk6avKfww4C41aFXfoG7RpvqXelDvR7MIFRCCyICWoU42dmoNZSK9BzZGIZOyrf5NnB/lx76VUPpMcs8Ymdm4RFKQucZhDb5BwERZJ0bJubKqwMNp7I9mt+JAqbb21eTPHOBf0iOu4nmN/EyMNokkUL6qHw2m3d9C7QZYmCZ9UMPVTpj4Z/l5kvUIljyUvGYiNMgn6tr7pf9nuJYsGi/VaXi1sNAnCel0BcxUzQyfmBRb9C6Vz2SH1CBBnYA== 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=f8TuZSLFGGm/nKW8bd7nNtiaPetcgGfPTgMpKfOuVWs=; b=Bu8HnUIiBibsGIbMYqCDO/jtETUZ6VZr5UxU2eyO85hOrRRkkCbrLINmGi64Xo3O68iPpTuer3ALL6JZ1+LbTfzOE+HyIlknW0lSnu9h0Zlik95jyJEWe8a/BzSh4KNLcphUMVVzJdcDL2mJfRhs5XF/O68Mjc6FKkbMuwfvWKA00e1+mPrYvy6TdWNXs5Vxzcug1DzWQvbA79vBUiWj2E9tRywjm/ZIihmc/acVfDQt3XZaXlpaSRT3utnzhfWdl0l37z5216PEewyM/YdP0pWhwYRr/wipJUxkjCTx3sPSzvZ66kiC0n2l6Qp/Ex2CEHAYS5MITsDothE+QURKrA== 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=f8TuZSLFGGm/nKW8bd7nNtiaPetcgGfPTgMpKfOuVWs=; b=N5Xi1J+pr16pzc5P3NhZqT++2KaAjWTQ30CyRBAx+yUtnx3dJ3uxrxCVvTGaXPpw8HnTmYpZjc6d6CxNynC4nB9KCuWSvaEzp4DbLTYj2kxjImrwOhjYPfRxwNnOEXhfjUqDsI0wmtUolBdBKfaOh1pyVMYZbh6Nr+8n8fYeYw/WekAf7Ua/6PEIBnRKQlqWX3gxPXQc8JhUxppSyPuKROSJNMPO2RYF9IEeJYZ3zGj5hhNl6g3MuNakGpAyQH+FsNmKuV+aoLB4VQrUvBI17SI8iC1A6wDzvg96pB8uZF94qXtnfBsrYAF+hEZzIuHG1OD1tGzLV3f/WO5Fl4nAEA== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:48 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:48 +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 Subject: [PATCH v11 13/25] net/mlx5e: Rename from tls to transport static params Date: Fri, 3 Feb 2023 15:26:53 +0200 Message-Id: <20230203132705.627232-14-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO4P123CA0119.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::16) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: ce74ed76-dd97-4d5e-e5ac-08db05ea9391 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s9/tXMAH6JYy8g2YYfrhpGJaa4kPobu8RIAgKKgIO+n7rr/GDkoKK5tZt5fsDK6ViXQ5Dcw34/MmSFm7J0UwQh7XMmH20eQFcYmWXzphof4D5WbtxcswNJn/zJwS0xRajXy+D+BCzdcfvBCVhcbm/AjgLtd2HPDoyqIJLAmZioLzxJlaoOAHEFIrsy0MUrJYA/A61bEY6DaA79/3qnSy+UMdwoLsYBTai9wD2xcg594YQtdUuWM+8e+rWDeTqX7ip1/R4rvBBohS2OjOQj9CtWCPkPfg2RmQKiG9+5U8LkuZHvu11GSU25U3D9aAEeH01vIETs4OzmIQA/+Uh3TKHmwAtoM41BtIWXfmAPwBIf5jHCj+L5Epup4VMufNRLkD32fxQlvg9UZZPOfHROa0/3+I+ZJGaCsnlgh4Az8g94WGM9rrHzloZK4iawEUrsMZTKXHyISvlc7jxeXhah5yooV3EoEYOc1O8XdtuYmiJYsk8s55dcS0TBEPENAq75c7cGjlvj+lFKu96ayUWe+aM5XJRnoiVDVR7MIqx3pxNNN5MjfCsHW9MZTzHFGq7bGcNwby3zYNnokjIzGZ/WyzGzYXTGXStOQAVvJutzo1cs8chW/uECquXm68IsSfeB0H/2Wu0k3CkT4BiU94XNHk1w== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(30864003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Ct6bixPPHHi4Ox04J83RSSnu2BM+1Sqjk9neqU2HaSt2WqpWy3FLAIboOEMdFREPZ7XWA4J27tzqpXZZB3yRXj22cnUSYWlSAsrl+xNHZRwZynQihGVbR88vci6ftvKpSQ4qetcZ/2XNvNCtaX7A9AxzxvzcKMWgKqNWiTJ/GBRZsks7s7ro04qsxyZ2foHtqbcTuirDGA9ozXTVniDD27HqSFoo+EF4FyaU0DCFh6WFYrHWxUwFLH7IKJBQt2/MC267xGGMnXD18DzAC8aFvxtfAKWOa7VgAUnsPCbpYwLTdDuhLRYpiUfj7bLSDedlkecJfUhPoWy8if48sDzx9rDGX3mTAGiEM9VyL7HLx8js5jorgm9CB6Lzb1WgQ4ruBS+xa4tWHIRWmH2Z5wtbN4cuqbaXZ1jy5lu6WWWMyEixQ8PFWw+P9VrUepD09fng7/P/7Edgkgf1/umb+bbTDAsWFcLrbYVQeu8+h+ZDeDK5I13Z7RDCM7/48kLAFCqy3vYdOsd5oTQuFlyl0oMhucGooUF2dO2Sk+E1JgIGWE3gBRrJ8btUqowIITTYqE2nRnzoB9V1/xySR+axKZWbvzgTL/w7xCo+MhPehrOcHCgR/jy/8T+mTliMU9icCqSnzzCvrVBAMVhl9L0LxhEFF03tExh5d9zLQbWoGk2KE5Iv/reRzWbOg8sa+15bk1IMHVib86IjtmjCuL7jLn2tMaoLJ/YT1rBa8d9dV3Pctb79Nc9jeRIY1VAyFdqvvtKoulTa+nuSvc07nSN6KE8yq9ey323mT5utNqYJzB8tUi/uwhKyTyuTteqTptQA1kuZLEEHPp5abH9fooHxVEjAKCfbIAFHUgH2Sirl6CbN56eKlpHgqcX4ohzrhv1PM+4vKngzJZ3T6RBK85+J6rwhMBza9gb7HwM4K5ZUdgFLpX1Grb3vqB3paT6DnBRZ0LVlc1Ohtsxnu1oXgr6NOJ8FF+hiCmMtj26ELwJLZPKPFFq1eiv1/r4yPskcMmzV4/EaGN6QeSo5g8v+7W7klDSwMCMmsKSxJWkCsJnWQ/k894it7dTwh8HMQmBMGKP/wjCrbbEPIlZRocOvmbqJIgJJXuUEYgPvzJ7xLHluRBetfgfyHWS5OCE3MSl38jCAgoI+k3ckIF5vOq2MBfavWm9h5Nnpq4Z55rtY+01JbnU/eTAXHbkW3gfAs94kZIUfTHTWY5wMCLEMGqHMEOVWzLqVfoqNBEYoTQtwitAQqWNje9yIAt2zeBTEswlzkXTOIQtYXbaMlOyf0PSG9mM9YrKXimQSqRW09jQRb0SzftBiQZ8ZaJjcyEVoQRK3zencqCDteRuP8CNr7xEDkjrEQ7jnKAf2+drhDImlThHunqe3oVxeU9SLZZPy9DNUQNAjy/Qukh3XFFBA55B0/8yQlw3X4xVab4MjbQ9eRbqmmzLpQ+oDo0aPPgK2lZ+xxHYb5mW5GpSK5OPkWgCB6ehOOtJQPPBcZeh0SeM2MOq5AdwhcUy4y2Db7rNeHY2aXGim04h/+YP6soUjQlNvDbm6N5z3OwPFpaRDBlXneyCqaZLBFLqQta0G7tH5XLp3DMchYJM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce74ed76-dd97-4d5e-e5ac-08db05ea9391 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:48.1377 (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: 5VdGbmG8BJWk/p9F630vm6BdlK6EQECMenbYgxIUSNo2qkEkr8tJzGMP2aj4fgOzvMwXqqAUi8+xD/l0b4ZqlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 cf704f106b7c..f80fdc7a7a5a 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 4be770443b0c..f4c8f71cbcaa 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 e80b43b7aac9..8e7ebc9d7ed4 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 */ @@ -548,12 +548,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 bc531bd9804f..9e1671506067 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -444,8 +444,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 { @@ -453,8 +453,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 1b6201bb04c1..170df4fd60de 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -12140,12 +12140,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 Fri Feb 3 13:26: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: 13127528 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E75E6C61DA4 for ; Fri, 3 Feb 2023 13:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbjBCNah (ORCPT ); Fri, 3 Feb 2023 08:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjBCNa0 (ORCPT ); Fri, 3 Feb 2023 08:30:26 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AE0619B for ; Fri, 3 Feb 2023 05:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RGETHERM2JuqMcd7Cki2AhJegnpo3om6u1TQjkwNtr5Rt6rvN7ahptI66pjaPj1jaslF3OU9vcQLpVWSrTt3GXdRAwfnqREEPOadHfwnPnRhC6+sBsGz3NLZXtHIyzelSzi/SrO+fZINrHJsNz3/vUprspF1VvQ3iwk157tY5oaqU5tx0qjMBzPPUvouF2Xd1pefdi5O4b8RpeQkKgsAStOQKOGCI1XAg5QJRwiYa6HZr4kRXOsrUG7BF+c9H7c6rTcAf36QnnSkQqhL4EirOXySMGUeaGdQkvJyyVsmdOhrE9E5YFJAcwYCzruQtr6HAJ4DwJL7zkiPzG2J4RcOdw== 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=0C6GkE3Lz0IqQ+uCV6ZVObWbeoChvn99JVeLgHMwcDw=; b=bifJfU8SIBPBZgtMnL2rU/9KIyGkZFLZt+t+/nhG4M9dcyShlP5IbYNJBtnp4naSoFmpg0EvdpcI7VWdk4EJH7XXFsMTz3Pz49XdSFL9Lh5Q8KsCEYqsI3Y/hjXzdMZKg5j+ap0/mKowGOumPFbmPCWphkSeoiAdiXZxsafeTgddDHb28oqz41sDaYxHGakQ1bBOKkQKlyMcH9RajjFGIH2X+h3xHNYaJEPxEFm8fCRavJgSMmagMrK9nAc9GTByw0XJu48pAXMKxon9oaBhZ8fcu6v+3+UponqkliqHdsHCr4HXDq76TEg6Wss8MJJ/VDmnZhezMK17DKL67sD4Fg== 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=0C6GkE3Lz0IqQ+uCV6ZVObWbeoChvn99JVeLgHMwcDw=; b=Lx9ACCL/coN20LJ1xVHcOj0h6oEyoSZ7PYbb/4+jW2QeplQI/7xHsnfUX8Ztlbo9jnsMopCLqAN3HEmQS+H3pdCapaoCj551peri5NybNDjNJSiJk8oncgd860I0OBYNLzX5AdO2paeE5Fg30njLtPM0TWj9V8qD+HPxWIC50nKZ2FlTHYvm9cUISGmNcGBTu2U7HzuYadO3YVGBhkTgaZsQ0E43ocldWbAN7bnZuo6/r0IxIczTfIDicDlh4nAovRnpjGBEEKGPytF2C2ljx96+nvMqvYE36URux50Y3YifXHgse3aZFY6Oi8gZIA7ZI49C+Tm/tT+3i8HHhSfxCw== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:28:55 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:28:55 +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 Subject: [PATCH v11 14/25] net/mlx5e: Refactor ico sq polling to get budget Date: Fri, 3 Feb 2023 15:26:54 +0200 Message-Id: <20230203132705.627232-15-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: AM6PR05CA0010.eurprd05.prod.outlook.com (2603:10a6:20b:2e::23) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 35f472dd-1178-430b-188b-08db05ea9954 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NHcK/rdzfw+0nTRE4l+FQ8C1j9P/owffDUrfIg7LRq+novis1IcdRfhKRFd+USA1TPH9+JWSdHeq7pNTZ0e/W9lMw1IyERB51+oueFan6Gy2MYzI2lgA3KZz+rUWruo1uOBmAVS2aoC/j8FzCFIkklQvURm4GSOWdFvm7Eq8Fh2Cs4+/GcxR5y0lN973Pr39QcJGc+2ZE06dMMGOyiCE7xWF5frC+SlPX3hdfCGEsSCJYSplZPpaAtDk+QZ4rGC7b/gMqFB320a493F1rQOd0aXAitVCib6RKbn72Ksv5v9okBKPuuXXTyReTiRg4qlBWtowfYrgUBl1+g1sXJRfs7pZZ7WxkhOddrQzUKw2mFKrk72zIHFZw2IJFJHw+mTUxtYvGUrCIyJi2HnGZO2KvlFrNOZssB/1fIo0JfGyB775yUZvkE0mWtxYMI8WbTQDIh2YQ96lHOmBBjW79+ijSfibtqTpQEUxSVpAgCB4TpRXk6bXbduRwJSQoy9W5d6r5QdJ52xKHMeLyw4fXE76B2FNg4zL+VXKQHcaKgz1AmPy7WqcW/2b3+2jnwI640aB9Dj4iMAuPRo5GCOF8mTZHdy+Cn312iLWJ+QfSdlfh20/zFeLpJnvtrSmm3xQLaiMVqVK/0SwUjGq0HyUWbtb3Q== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sXrKhZ6CrMM2/5Wxt+9MuuObkp7PQSCxjxlO+3cW4vPl8gE5BXcw3PylYsBI5bcmiboqzQJRBHh9CJ7nkoslZdboR/JI0cEGiiCp+clie8MdIm2MgG8ctgpkSX9VzoAzstd6IvbC02mRxxyBL4ajFLMU+j9BxiBV2OtX0B7J/WRHAd566MkmFwwycxcvX/jRf6bEfLKFsgVOwL/PZCLEXl4v6IE31gcMkve5pAVU+k8wflz71+3qEHdA+L+tnfFolWlVdqvZiZwwRysgif2DsSz7op1bNHnGju/boXPgnnK3IzaD8KbB/sBklfuaDR/o6+ctfIkA7OrR2rqtbobhxZI8wDefVSutT92KZnlTZWnsXJpe3/v3ZuRwQ9cQBmur8vSHypUmz+5nez24ETTsMuQG6MX2YXBGE0Ze4faJoHHwAyw14aDQHLYRgbY/QJJR3s3rPi9kFEI4EZyzspNOG7qweeh4zvnWedUKwrmqFmuJA9fwpfkhN31H9QoYTG1wn4ljephLoZ8sjFaBWdvXQfRRVy2aVhrny67k8qtxxQkT3VLG3Zyl6nXbzaMBonBUFYLhS89kq0LdpBvvTWukplYrwfEhUStLZH275EkTj/JgzFISAD8CLGcRg+SK+tTuFqxXMh6uLp81VfQISbkvkdqHLLAuSWE2I6+2mFOCLCEf/n0nFx+ZJUMm/pzAIpKMD7LoIDWGvVYfWsmmUx5T5q6JheuuwoB6jkd9jsHYwtSDKIaYu27np2Ns27iejyN2p9I91ERmTU23VOrk7xZdSeekrFAqT7SUmbSf/6GuBzBw3Gc/8W/LYMxwyZCer61f9f1uhNNy3zWb7BO4i8FTJI4MVK9GUaIITJx0Mq50KfFGFqeoRwgzas8TMF5jEn0FBBveaNKLxd623OlC4ZPLgLTocUXoseCzxt53okwSld7eZ4w0BSP2QOBIDRWmwNhCFmDNkXEOIj+d9VP9K4GQQQAdQ6sZBcPZyPQTg3/Q/TyrdmyKBI2JJc5DYs/9ofyhN7/uAPLBGxlWM3hJXgoBVaRSbaFSEPpV1As1SsAZBbPOmV7Xzz9yO6mXkOxITHdVzU9aPimXPU5+nsdR9NPak0I1AeAh9ePtq+k64IeQkSOFiVX/7KYLCOPXukHdfbFjZrGnCHjs1EMA6cz030s2s0WtnO5bK4mD5Op11XrP76yyXhgI3IFAYD87DTvS8uvnfJhxnKsbZf4iALguSw/37RbFnvXYeEeWIe2wgrt96k94y8+ea2gnF36CyH+mS6E5Y+FQ8kHE5qv3Lb2arQo0lGN7YC7xLw804jnnGyUvzwkp7Gl33Mwd/wE9Bk869si9cEpiwraKN5SlANoTOMkHJhfO2mRNsuPytrwlUDDVjLtDMrZ6RLAfuWjAJh2UBXmZo1bvhwY0HUOuGus5PQGEIQm7EDN0SZIpGjdbvPSplC0DdhYjaqQB4YVQFD2ce1B5Eo8K4XlNwA5sHJ8UmizpauXu7wSc/KFrxrbMV+1KMc4tUL1ornwW6EUw+JGIrOpK8kgTPt5fnN4JWQZ3qWPfp7G6F2uTpS4aAMQ3t5a+8FF8O85JaQKz4U0qEGmLGhUc X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35f472dd-1178-430b-188b-08db05ea9954 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:28:55.7374 (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: ssbc769OShu1MP73pEEoY+apUkdN7Y0c2HfgyCqXCCRDlifAZWb0WyQXzvfbacq/8BGECkgPXukaAIYlJ2XpvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz The mlx5e driver uses ICO SQs for internal control operations which are not visible to the network stack, such as UMR mapping for striding RQ (MPWQ) and etc more cases. The upcoming nvmeotcp offload uses ico sq for umr mapping as part of the offload. As a pre-step for nvmeotcp ico sqs which have their own napi and need to comply with budget, add the budget as parameter to the polling of cqs related to ico sqs. The polling already stops after a limit is reached, so just have the caller to provide this limit as the budget. No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index c10c6ab2e7bc..92a71d1a7605 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 */ void mlx5e_page_dma_unmap(struct mlx5e_rq *rq, struct page *page); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index a9473a51edc1..d3fc3724a39f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -913,7 +913,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; @@ -988,7 +988,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 9a458a5d9853..9ddacb5e1bf4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c @@ -176,8 +176,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 Fri Feb 3 13:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127529 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 776D0C61DA4 for ; Fri, 3 Feb 2023 13:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbjBCNak (ORCPT ); Fri, 3 Feb 2023 08:30:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbjBCNa2 (ORCPT ); Fri, 3 Feb 2023 08:30:28 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2581CA0027 for ; Fri, 3 Feb 2023 05:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FhBPhCRE+HzBE8CAmHjFlDLtDTcIPuol3/Qdz+8fG8rpqb6Ecc9YA+L1CmBYghDRWUM+G42OtQTDD32lsHppYrEGpbFlPAHyE46LjH9fs/tVV8PKDVFOpsY69EbrojNS5GDHKv4ryg3JaMWhYU1t/i9q02TtYUpd7qEGRHVXLMb5hvfJa/e3ZVEcjWeUt96ggjp7PEBvjHT3u+DOdez2F4mgRju7kU5sfmdEK9rKeJYylXq+WqAI5OZxm88djYjLyaeyENnqTkkdjPAyWB2nXVn/OcWRMmSZEB6qJRVr/iyzgM6pKoX1yxM93MRZBK6yIHloa0ic1El2UN0IyOFJaw== 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=Zm1GT7vnY8VyrNlHCQs82xJh4AYZtbgYa5ZJ1W7jA8k=; b=VX6yRllw0Xv1uss2H6FqEyUSxPAD3bdj2D6unwli7+ACjmSusg6fbIZ3pIWly8dVc/0RZ5wFyYlqaZmCZqmGb7jHYPjCV2tux0fe5bWZKQwiX5aAPgjSPdB3w1X6lddQos9WNo/Rf/03K935lci7OJhWzIKw1Li5qYVM3a+l7LyigaYUCZzvLVA6FCcGRCNYDYPDIGC9PpABsO7NE0AYb02IEQny422L9lZaZ3DOdM+2+5SIVqoJauvoDCMvevvo0t7c3R1yeXlkBbOhfTb9dV7oXSwD49mc9+5tQi680bv1UwudFP+DyYa3sgR1DJWOLWqg/dVnxnzZir0EoSaa8w== 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=Zm1GT7vnY8VyrNlHCQs82xJh4AYZtbgYa5ZJ1W7jA8k=; b=Jo2pCwOTlkJF8B/0CaLSsgQ+b5HFZDbqWtQi8hmWrEx90WK0qWNlk4OevDWulu9imPrJNoDU2D8V2ei2ANlzL8gCpZNoOOrBraxJ6bZkzqJ0YkS7x1XAYb+keGVeXnh1e49X1OzUR3IzH/28gt3nBVeZr57Y+OxqHby5fdPWvAV3NgNftcuj93ab7YiLF9IFNpPzVeojpeN9+zR3ykVo+g5i6Y1ECm8NwPB4JijG0dOJpUhkmuxv1ODQY3qiUfZ0vhTxXqZGhBVe+u+1cpuSBYTxuqJHdk5+HiPAFCLn31qG8bJqDBo6vHNhyGpgPiqNl1W6PuywzVCLLhDMcwBHyA== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:03 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:03 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 15/25] net/mlx5e: Have mdev pointer directly on the icosq structure Date: Fri, 3 Feb 2023 15:26:55 +0200 Message-Id: <20230203132705.627232-16-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dbe3e30-ddae-4978-b721-08db05ea9dc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k/2nM2Pl/fBdecXLpm9L6nxRv6ssdmPy5uF8zPHrHmy6dq9/h0qG4usnPKf2Rm2SToraJCwjMV104WPCobLreGblcMXbK0qwpU+FMF8OErNR8zWOoLqyuW27EmPIsvqm1Y4N6RDu+sNUjOvqGLp0/jsF8fQBAKHQPK7evR+HwosTNR8CwE9D7noTV+ja/E1ZPel6rp2k29GqUsLHVpOle3RXXKOSVk0tN0WEwKd7Ob8M4zJ+U8MD93Z2wssAKZ7yfXFz+TpBrvnj1wHxy5Sp1r2iD+tePoJkcQsgLBXxLfTdbXoNzrsEsiVENtXAqcYjCrSL9kjUeuOYPOC6YIG9vDMgZfPGdBM1ZN6K4NfFd1SwJJBgKiEQM1m0wUJ66XEXB9qDK15lwdtp90AlIO4HbRMA5Ykmyn2SK5xVeApcu9C3xktG0M4WDM1lttH1g1WlFO02WpuQkmAgti1hZjFhymRiRFLltuozoOjptb4xUHc1FrtVPFbf6+FBM5UWGpwj8Z3nAF7u+xHI0hfbS8YtrZ4PrfZy+cddrKQ6qhBS2DzfK+1ry5LcTtZXxAM3yB/h4kuuanZXr0q8CkAcQbnEMyqVDiaq/PcYPJFrGFZfPEZt4pJe/wJ6dvn/RWXKJpnVAS6gxyqvGqjQ1dDlPn4M0A== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +5CuGw/OtiRsbRBWDwZyvcYDPsojT0sFVwmuUd02I3raINYsjndMT6jsFLCjZfv7QncAI1wd4Tc0hvMm/WPOD2/d1HhBxmdyiY/CE2kf4ukvw9iMjvWGggAwIRh1HYu7lpWVi1E0IUBxau6F/nGPczrv3KiaSzDrja9/IDJjISrkAAqPY6CqgnVfaFUr7diZaJQ8mCTSJhKj9GVmIf0FWjD9oKVixq8oHjzfGCchpaMEri/ruVXtEYBwGzlgwwrsFnsW09oYrD13yLRpDzY5EfbtF665rHGaaegSJ+Jx7u4ZcmJabWeYrxpJfvuTghv/0HPesxlzjTYiUDBe4X94jA0Ffm6dd3kbdtJOwrv02Ph1v4NujIxrVMtCsCURAskM1ejJ03eKu67c11HatOkVXAH5srTJRJbKul1KgmEeS1Tkr4iLLORsXTGhkCgTke80+GlIRuWPbKKa6WBWlIdmUN7kSm49+WYx8mbXMGX0LlG2zUf8WEbyLKXEnswfYR7UPZoeMX+uzwsa90Fi1jhG28kCNownXJ9/2pd3PJDNUUOaJRel2p3eR4+6s4D9inTceVIWEPG6EKPSkf98Si3to8iUWUX01OLXxqV7WNj+aGDWfqKpkpe/hdpRiuKKc8MACVSFPO4vmvrvBItQ1tQtZfiVQd/6YHCUGbc7lpeYRyjJYrUM6NHigH62QpMWvBGJcCQYkfLA5pEP5FEZuQJXGVqIENUqYgYWDZtawSXiWG/3EJZMM+OHdFnB/4+Ya7UPl7QUkc8z5c2QVvjDGd6fAiUgl/593E3OzkbgvLBMlX9IoFLYl4U/Gh55XWWHgutfUHRh1nKh3YdgHvI5jVEkNDViz+9B79kAh8bZneyhSE9AmjEZtB4vkiBje/KiExyDYy9bSsCwlqLr0doikoEE9AhYVyfvA/wTXnmHC9ZcH9zAioNpFzVFn/CD4isRrKNdSnHX3RRo5C6uAJSG8d+akxaPjh8Y2HbIIpFNRJn3PVpHQgm6AR5P/3hNSw3y620WIk8Xm8r2s38/COIanHQQijhIxW0K8UpKa9sLatvYvpHnuZgqHULBZVZFwLTBI7UNI/s+85cNvFcJdgOW2bXDyesmMuxOxxGeUBa0id5HJTIBAc2mjsW9XAbHVNVLGLdKSDcuyu2McfFGcBiSYEUdYwNQswy+gdR5eFuTmsrxzhzGKI2la1GkebvP5smq7h9GLbqefE35uf1Mjg8mD9buiIfSksqdLakk+LUuGp0q8buDLDd9n1qbXtqM70iVl+VvRmwC4NKBahLvQ/RjrN8z+FrtEUiWyQjkvXn+ag6l6jgM3viI74Akvj9cJ1Epf8NwFcqxDxhDJRFn3mBA+5aF9sL/BWsNBc/MfVfkEGG17oLeYvSVAbwzAB6p/oz9omNCpnSwLAj0a4H//iCmBoe/Yk14CqrQiuN+otAhAyUxpg2Ci735JTfPas4ECIS04jyrUqN1tZuRu30lszA7rgm2b9B7UnBjRPoEvz8XGUKYQjwRKLjQakbNLt93FFaMejnvhyhwbalumtHBti6GY93xcwew3963GvOP/pxVTkkju/eWVl+5mHZckG3VrHr+YEq1 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9dbe3e30-ddae-4978-b721-08db05ea9dc7 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:03.1904 (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: /97C/DKlqamThYUnJqjikVx9AHaYkze93XDp0YR/awYEYPP0m8kNw2n3Z3a4YxGEPJiMLZfgZ+uXgdpnVr0ZZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz This provides better separation between channels to ICO SQs for use-cases where they are not tightly coupled (such as the upcoming nvmeotcp code). No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 6f8723cc6874..dd68f373516b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -592,6 +592,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 95edab4a1732..bfac3f09f964 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c @@ -33,7 +33,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)); @@ -78,7 +78,7 @@ static int mlx5e_rx_reporter_err_icosq_cqe_recover(void *ctx) rq = &icosq->channel->rq; if (test_bit(MLX5E_RQ_STATE_ENABLED, &icosq->channel->xskrq.state)) xskrq = &icosq->channel->xskrq; - mdev = icosq->channel->mdev; + mdev = icosq->mdev; dev = icosq->channel->netdev; err = mlx5_core_query_sq_state(mdev, icosq->sqn, &state); if (err) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index f4c8f71cbcaa..e7866e88c599 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 0e87432ec6f1..43a3ff2d2d90 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1389,6 +1389,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; @@ -1786,11 +1787,9 @@ void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq) static void mlx5e_close_icosq(struct mlx5e_icosq *sq) { - struct mlx5e_channel *c = sq->channel; - if (sq->ktls_resync) mlx5e_ktls_rx_resync_destroy_resp_list(sq->ktls_resync); - mlx5e_destroy_sq(c->mdev, sq->sqn); + mlx5e_destroy_sq(sq->mdev, sq->sqn); mlx5e_free_icosq_descs(sq); mlx5e_free_icosq(sq); } From patchwork Fri Feb 3 13:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127532 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39615C61DA4 for ; Fri, 3 Feb 2023 13:31:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232838AbjBCNbN (ORCPT ); Fri, 3 Feb 2023 08:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232840AbjBCNax (ORCPT ); Fri, 3 Feb 2023 08:30:53 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27317A0E96 for ; Fri, 3 Feb 2023 05:30:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e2b9GWda/2lHNb6Ke7m+xVbnjkJs+BPti3w2vVmzGTIwdPenpLDadU0r0h0XFhjznxnm1eFk10UqfHv0EmcOI72BiNEExa+EmtHG08MB7ioK5/HCeW2gqIAepktTFNZh6umVKiPkh+v+vGoAkf+YXSBfqlW9J8ZEfHR2Gt9+tR9oqLwPIHEYEN/x9cerCh0qvUCbQS7wkAeIcNUaYJnapv/9TMtGjJILG0NGVPDMXMqWWhW0u+tna7ts2mw2pENh43uw2gCgg/PGv5MStRYs9UKUzSzacSwMPlAa2uuo1+VPtdz3crVN8611PbHf6j+haIjH2YTIdUIjKSaPpozBpA== 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=f/Hi4/D8f4Vy+rOokNSx3pMlHTuX9HP9iTOZ5ZFRWFQ=; b=RqoNo9EVIixTH1zVN3WSSNiUztTlEkrxNE6w+KebpympE5JWijCKRvfcqmeGDsV0QZEJ7PmCaNB3N/EPlv/ibsE0nx+YHnLogdJseBAMTf3hR6FtCGb6wRb0xVhYALvBG8qrVuXcwiBA/lEeRJHhi+z7z3Prer6qeeU9Zz25QFlgg7W0JgveJqFgUxY7vmaN4LkkCTAcGZBcU/sRM7hWAEEWofJfsYriCBV8EWbcczyPC2oDsKf/+K5m2evRWtilZ5hEm9r1NkeRkuplTm+VnTgG6Hilxzt/lMc1gnDhRdlMMaPtEq+YFXCjTY/s7JK+0+jmn5yBzH/cOLAK1cDyYg== 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=f/Hi4/D8f4Vy+rOokNSx3pMlHTuX9HP9iTOZ5ZFRWFQ=; b=oQVvoemNi2bJgbtKMkurutcEeWjdEGYT1OX0mx4Y76a3wm+HtGGE0IxF+esYSOMwUiCiZcJxChpQY37PfLuWEzTeM6JnQBhmbIpsWayssG5yHNNTCCZAcr/gFd9P1DrWYeQQuiAs6JuICF2FOMKbLlC7hVXdg8H7mwZ6xirYWOp1QZO1mkMeudy6rztwVo4nfzgmkUXuksh3N6l6h/5Zqfn6556WxSE1bPhNdtVc8fYplgCXtIZqd0PCRKwHTlyoAbjluTKJAYFs/ofNkVPk96HUqnurZ8c9zmEKW/IkoUbeFUQ2ZtZHGR9l/S6MQacaAfZ7NdbnKV3xsmd099WMUQ== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:09 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29: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: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 16/25] net/mlx5e: Refactor doorbell function to allow avoiding a completion Date: Fri, 3 Feb 2023 15:26:56 +0200 Message-Id: <20230203132705.627232-17-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0142.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::15) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 09663308-05f0-4fcc-62a7-08db05eaa154 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ehkcPsFCxWIsRWpZ0TEqeCqhtlI+4CxvbsDf1CTYsugrSZLOHCxifzh2/ma1A8wM6rIuDezdnW4xsHxj0vR0PT5TuJwRMlkbz5hJ+aT6WGXmjZ0U/uwT/CopfsyJjUQHhM0kGdU6qGpuhroCIcYtW1kANkn6RjLjUMo5k9UKl7/Q3mxXHXgaj+A2x8kqaSqns7elkkCUPKpeWtnVzyPqSurLE5pP22s0oVtcTKPff4P2NytWuJVIThnagn2e29QIyX8LMrk6YZVvEDJ9RuX2zWKlvvTHl5w8cudJAw1ky1xvh9W7aWSZl6C/K62X/Doo66fnfQHO1prZKLDQ7+Db209BNuaZQ/PPALZUSioTm8ohhpGaxJNIvt7ArVWTNLwnMBSvejvRqplB3WEPeS5H5l2ut41f8I4XAnEQv9DKX/2LNXB77GNqZw5cdHuJcJY/6uVvJTSM5vgZbjInEEKiJSh+xGe/0fY94746PHQ6oIyXT15qTbwTzWOpNcZXbZB8Jj6IZXOopt9TR4yzPdEjKLrFoEwdeSkWrC0oOpi2uClkji6gjUV7BXiJCmAl+YiyMiBoO6WUflAOgMWga4Z5HOV13kwjuvvozPRsKyscbph788PjBtlydxQOEWfb3PBPfj559m9C6/Yv7YtJaczdkg== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VuJZ6//VvOcVHW1SgsXslElxdoC0mAlGTuET/MU5+n77gw2wZX8AEcQSsfbpJX+amq6wHhErTJQ+Fwu2dB/mAjB5+H3RI5tT0oJ3teOKiNd+vQzqQK0NOjCNleSgNi2EXhbo6Pcs04sjyU2eA5P86OZ0LGwsvwQXC/7VppyU7HHCRf1sk4nuSmrcTsaPAJXF1Nf6txyLAG1zv6T6X2FSI3nLn2ixJoEAxD8MwQoX+0Tmsa5dF63eS0jHuw5g50Xfrq6MzG3tuUfop4UkSZD/9FJMynN0RsCl6Vg3T2sQi7TU+AXsENl5inzvvzaflgZIQaDD3YLZ4UhEk6MFfJZvZ4WY2ef0BsFzo2Nh7BVK1sdAns5BNAEMM0Rg8tQAk1uv1h+Wh7F+7lek2xYqmrUw4hiF5TWimZ7i7S/oGIQlxbAl53CXvWTNvcbVXgflKDocrZ3xqZc2KnlhHsImmySEoxIr0dq3EqPGp7JnD6vufF7NlHxdn+/Q5UbWmzz3GgZl54vAxqn5yav6qTrMTNJiRF1lPC5nc/1aj9leArzF90+yPvmq0Fn17/3kgKx9Fas4p0RtVwHmdp4Z1uLLWh43WsmzRCjlfEAFSfcxQVedt2VbXMSdPYJNFHFb+IPxrnzbWX32yVVROm6bcS/F7eq6h/OfpkgVOFJQ81+bn2JtTim2/z54nAmXZb17a6chLh//AXIwuolwoWp9PEvzqNwx7P237Q18/kKvswG1ubL3OY2ZZ+iQwzxg8jC50O6vRlWPbJYLfwKgNrq3o3vWFtJhID/8uON4Wa0A7/vgJ58kY52N3kSv8ZjG38Uc3GUov/IRA/inuNOu/GQG0djaLGRp9t40RmA2l3QSbZ4+CxztFqLXJ0jncUNcSDCVmRfIpgdnY9a6wgPMxM0+CdFo3/qSCWzgke3232kdyluGETW3Xw9WsCtYOTuMAstAwIVZ7cGpEIxpRMpDuwmxxuZJIbDVGQU7P8EHyASv1py6Dljjv5ae1rpf9yLClIAXcZMaq4o4u27gSsSCw328mTY3DidBfCOKo2Yw9NLLdnOfs5m15asMNM28yh9sdOVCUDBvKHbZMS1Ssxzn3TkL/BsodqUvQGDgXD3F0Cjj7VmPh80JlzEMpdG7Coy9MEIZRYN9DajyufPbqOiebsvwH7V9+Jrb7yyeoEoQknwGiiOYQLjSWyoMOUzKda8G/VqVigwK6LAPVXNv0qwIsQT9t8Z7mMdCGv5S+0sF+BvU+/P3YNvCNmQmwLR9VPYAddeSVxVu1Kq5qcxSL/ijdvWZUQNsbG2MfeWRPQG3J05EnIlXZrN4u9SaY5ogBwoF/Kul2tfYRwn/OqvW62yMysD+pID43vGsh3Kx2gv0FjxwNt7Lpb5QHikeEzzmApA7a5/OSDH1kLXS9FmvIuWiaUav9tXcUvSvitKeEV0vUUAR0R9zo+QKjzf8oXBwgMKOUjHB3SZOWM3MkoPwTR/nkA6MONtrkJFGjZh4cdEMghDorluPsI31WIuEzMq/34tEzbvFN7U+bGhnDKPst/4cRnU+5oZhtw3oU78c47q/BIGSDHnNh1i2XzitQKfy7+nhPGNmkoDB5ik+ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09663308-05f0-4fcc-62a7-08db05eaa154 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:09.1767 (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: 9H+yt0G2UQUHnZHk/XaYN9E5ZUTV1CdBYq09zxWObZal6DtPv5oRfv0hICNg87Sp9Mb/PStrzZ72tSU0g8G7Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Or Gerlitz Currently the doorbell function always asks for completion to be generated. Refactor things such that all existing call sites are untouched and no branching is added. This is done using inner function which can be invoked directly in cases completion is not desired (as done in downstream patch). No functional change here. Signed-off-by: Or Gerlitz Signed-off-by: Aurelien Aptel --- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 92a71d1a7605..37217e4cc118 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -243,10 +243,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(); @@ -260,6 +260,13 @@ mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, mlx5_write64((__be32 *)ctrl, uar_map); } +static inline void +mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map, + struct mlx5_wqe_ctrl_seg *ctrl) +{ + __mlx5e_notify_hw(wq, pc, uar_map, ctrl, MLX5_WQE_CTRL_CQ_UPDATE); +} + static inline void mlx5e_cq_arm(struct mlx5e_cq *cq) { struct mlx5_core_cq *mcq; From patchwork Fri Feb 3 13:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127533 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DB44C05027 for ; Fri, 3 Feb 2023 13:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232776AbjBCNbV (ORCPT ); Fri, 3 Feb 2023 08:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbjBCNbF (ORCPT ); Fri, 3 Feb 2023 08:31:05 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4888D9DC95 for ; Fri, 3 Feb 2023 05:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjbI3taaNv6+wVpellEX6x0fu17hPcrHYglS2McZATaj7EXGncAOkwR8MJLTgnYnqaO8awx6CFd2M3ia18O9DJ6aTB+YWkTgGPOeJK7rXi8BDOGoxILQVEtPQ9LyOy4Fzr6EuvM/6UCAzbHnk9qTDlQ6Iy4Jwu8vQ4AZHa1Bu4Bfe2oNOgrNs5/bzpVQ966FEEt29Jrbhv1yUyS38REHAH1qjvU6Rj5UE0NoZ7k8ss1PCUHia6Gdm51JbfGEKGuvIrMqKy8pYejTYWY/p4NM5c9UCgjO5FkjA34zwzOAM37AMjrXNF6CJYlFXRGKJn86y4Hjil0LCjLrmNbbP3Eh1Q== 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=OV8KmX6Su6tvPv9+V/mbQzcgWjgrjQXmIj2QdZkUjJ0=; b=IdT+1Kp0AAZm44HPpUSNF+FFf0E/1hquwLI1J5arUdAU/eiELQfCGKlsZYfbqfalosbojk04xdDdUSYwpniJq+FlNxRkVcpuPFulfAqzNfKgeWiRO4g2C0cQbyXU21racvzgBo8sUFDKkYSEU+cQDzE3BcDiXwCc9J6h31q115hcZfE6urSz+JbehuektVaFZgzT0l/U+Rpc3gldLH1CsK0dGhvoqw03wawd85TkIL5vYSHHrjCBXOVkJkDIMogoFykDbSJMuUQCPeDnF5/9REPbcUwwb8u/ISWCkFakHWejzP3yRLx64/u3pI2Sa9fv352l3A4zxfImBZFU9xymnA== 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=OV8KmX6Su6tvPv9+V/mbQzcgWjgrjQXmIj2QdZkUjJ0=; b=DKn3cNfZaK9F05uuO76Db0Nwvl4FoBsCiV1aUoOqRZ0lYi+RjdyhUAwNPZRd2VAkko1H9IbFoY/gjcl3IwrAGS0tjAixfB5RQvxVzHf9f9B7tIGYcJfMBSyqENF9VgQoPkNu6kIfYJd0btDYr8X39+kjJLy0gwI8Ke/dIzhajtScAkIp5Yoix+aZlNwKApU+y2fTidGOlPu+wS8U702PeFobaugKcc2niYiuaVwLW8aJ9nQM4CWTmADTPH4ZIXMszRO9+/vDTRCSjnOuCEUN/1BW0WsIodq3V/Wgrv6lYnFPOU4jPM0VA22hHmnCaU9kwQAlOv/PrQARQ1jwgc06/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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:15 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29: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 Subject: [PATCH v11 17/25] net/mlx5: Add NVMEoTCP caps, HW bits, 128B CQE and enumerations Date: Fri, 3 Feb 2023 15:26:57 +0200 Message-Id: <20230203132705.627232-18-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR0P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::18) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e770a72-8461-4ead-37c9-08db05eaa4ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tRY70p6znk/skEvnq6EmpFBTE9hGQcV50DLomeO3QofBXbvh3L1m/3aFQugDjQgrmB9RMfvRY2iDWO4s9Pi6sk++BB6NKqveDrxU4GE2V2sgC1gkwOzogVvRFsGGQRylt8s0TNaJyz07TwvcUoK/AYD0YvMyw87UEXg2DkguaEACs6PrlhzIbmaORUK6nBUONFJtAFXzIrrEk5/lM4PM6vY6WR/bOrkwr6rYXlw//8ca+nrrlqzMuz+bBu3ff78BqOabtYTwFtyJ5bkufhe5K+xw7M+FARj3iEBxiQoWIBcGpbF9SpjIDlapq8wqPTcJXrkBpbia8AJY7EsGgAXzhUPMkiAoAQFBMnG4YLc6fRpk+q/YlZEIw1aW65gJxroGvfbQxmStvQOZAFNyhKC4oIbaaYrsm3byFGhu3R0TrvDTbkP7lXzb7Xic7fXsAevsiWIPwSSokJD4VqS1fgzLHtPHRt3jHkizZzjsBR+w63y0PLlbmdmRZNPRFRtUtE4lVXNfO7bLm3iv7qlQJ2rPCFZsvBKNHOrxBJIbSc4sp1fOqaaoPRYzNtyZSnUnzVGK1gtknrUBkRDdNmFt5kHMZqvOuBMJ/I9BIRwm/jLYi/6Pf9QKavRVBsFrLQZ9YOef3+g3ML0CokfLC53A4LNybQ== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TDXhzgELyt4c8iytKyRQwaJB3z//0t4ZzxijvXflFPaYQ2omMkbixe3g4Fk/MJFsiELWPv5jOlaWsp0uQMkNo5VTmbrtGzdpwXel7fIjHyQsLiGs/2axhm+0Ew5XHkP3w+0lmtgBEiGP7p79gIWbHXi4Fhf6iGi0q+yM14EeKw0LyXKZEHJ1X69FhUkSEB/yMiLKNiJSrcN5FbkqDRWyWRR685gIoZ8G0xNkPclXtrK8EelKU5C9YYzX+JsB+yU/eV2WJ6GlpY/xyydjzmcKazkvA9g4ahwVjhJotbkUiT6GwfJEPEtpXmcdyG+K5npUtLV9TrSXa6BvquuZMuU0O8bWM1QVJjH+xMD6T6ws8Ud+Y1OERDrxPkF8i9EYZwdWozb9cw/LTDK2axW0kS4mV2FTgno3XEjqM9tuQyFiVMm6EfzoFQ0SMcSXNYLFF+KJ5LONInwnbGz20QnVRRZsKgFW6xMa3/lyYQEon/bNj06e86NaRuLNI28coMep9SuWILSLZ9IX/u0kAnN+GAb/ibXOumAYoEWomf4C+PIWpujj7zNATw4MhD2ejQ3MPj5FL2xH4LigxL8N4VW05m6RhK8XB1981gKnBI0fE6mWPSSWaYtvGkBCqx83InHfZyTb9PHnlWWI6Dv6qZP+bEvcq7fl+4AICPCpyFKC0kx/7HiJLUBz+Y8hAuPjtdrTi0HTQ+KYLdibcCGNwJWSzl75nWAqqQFqRjsykP04r13L+FnDkAM184votdxkqTAV7zu3yiSBDMgNYTSdNycAXGQLcktne2sPCyOe0e71826u7a7NgqkRXylIlWUoDKWhkHMHIoTAvqJlr1MWAcRv1PxaydfGju6AUiIAM37T3mTYBjG5WfDCuligKMdKVL0jHni/GwIUMdIMOn8knQEEZM8TcXgRvEdV0pzLpMIpu4OVyRefV9u0Ra6W/tjEzta+cuFRKqVYAp80H0ajHgymHVNUePdiuMm0o3T8dLlBWuHC4lzA915xTXpj62ttNklHavx2hyjz2C0HfFo8gI8jt1R4uHE72sUMa8I0cAvo3sU+2Ey6zdMWwMp1mLRkRvksvS+GI2onwydQe1O351W7Q+1Er+fpJWV7rowsV5GCGUeq/ZRkowbnaMR3WFRHHzpfk63+7k9pJuHVm4+tHabsAvufQWFmPv+rRw7gb3M20rFCmjAuHa/2uj5nWi0SxSNK/AKV59b1eJ3scCZgo7hOtxSqjYheGZNpsp8bTDp7877UbtHwQmFM9s0fwv5qZlzApyI0QbjyAWZfH8wj7XYeRIKxFOrBQIvjbHtcVoFdrTJxsGfbv4XYOlIEC78zQhlIotyIM484Q0NfViDwceu4y0QZf1CB1CDFuE9I74oX4pYTitExWibC3ROy93t6tdROoI9v8h4lWC4hwqzq2YobJPFcEZQCgimZb2Mb/pfrnmZ71vbGph9r6LK6ze8n82QsiTA2d2Jll5l+YvEJYdymq9Cc6P2oED7oxHLSXolROU57qAeZBLIMfGhKIQn9a2DRrMTsmjR+yaof80ikuBFVxRzqj20CJceJvRkTh0atulzbuxQa2yC7R9dgztO3aeEggyVJ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e770a72-8461-4ead-37c9-08db05eaa4ed X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:15.1958 (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: /8AtTxbUUr4RZLPeHsUTWIKnduOWal4AARc1ZRCsV+1htH2RG/lLnQvY/X1mpGNAVb0PTsQPPSo4IiMat9GWCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 74 ++++++++++++++++++-- include/linux/mlx5/qp.h | 1 + 4 files changed, 127 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c index 7bb7be01225a..5f87f5c82485 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c @@ -292,6 +292,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 9e1671506067..0a6127e82112 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -263,6 +263,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, @@ -787,7 +788,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 { @@ -836,6 +841,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; @@ -871,6 +889,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; @@ -1204,6 +1244,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_DEV_SHAMPO = 0x1d, MLX5_CAP_MACSEC = 0x1f, @@ -1470,6 +1511,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 170df4fd60de..e28124ebbaba 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -1474,7 +1474,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]; @@ -3373,7 +3375,20 @@ struct mlx5_ifc_shampo_cap_bits { u8 reserved_at_20[0x3]; u8 shampo_max_log_headers_entry_size[0x5]; u8 reserved_at_28[0x18]; + u8 reserved_at_40[0x7c0]; +}; + +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]; }; @@ -3422,6 +3437,7 @@ union mlx5_ifc_hca_cap_union_bits { struct mlx5_ifc_shampo_cap_bits shampo_cap; struct mlx5_ifc_macsec_cap_bits macsec_cap; struct mlx5_ifc_crypto_cap_bits crypto_cap; + struct mlx5_ifc_nvmeotcp_cap_bits nvmeotcp_cap; u8 reserved_at_0[0x8000]; }; @@ -3668,7 +3684,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]; @@ -3699,7 +3717,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 { @@ -11757,6 +11776,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), }; @@ -11764,6 +11784,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, @@ -12129,6 +12150,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, @@ -12142,6 +12177,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 { @@ -12164,7 +12206,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 { @@ -12403,4 +12458,15 @@ struct mlx5_ifc_modify_page_track_obj_in_bits { struct mlx5_ifc_page_track_bits obj_context; }; +struct mlx5_ifc_nvmeotcp_progress_params_bits { + u8 next_pdu_tcp_sn[0x20]; + + u8 hw_resync_tcp_sn[0x20]; + + u8 pdu_tracker_state[0x2]; + u8 offloading_state[0x2]; + u8 reserved_at_44[0xc]; + u8 cccid_ttag[0x10]; +}; + #endif /* MLX5_IFC_H */ diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h index 4657d5c54abe..bda53b241d71 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 Fri Feb 3 13:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127536 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED112C61DA4 for ; Fri, 3 Feb 2023 13:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232807AbjBCNbr (ORCPT ); Fri, 3 Feb 2023 08:31:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232871AbjBCNb1 (ORCPT ); Fri, 3 Feb 2023 08:31:27 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EDB39DC87 for ; Fri, 3 Feb 2023 05:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMKm8WP9KGQdPh3Cht8btvVrkiMh1g4if2D40teoPCMOp7Z/WMKEwhCm7ziSFHh1bupg+L3kKIoy3BhPo+KwzDARKfGnqLNu1YIA1o+Sw0bQytOtuUgyGc7bRabiNSP3ui3T+2Le3O5fPgLyqE2UNo761TGqdSShT5ycTBgTunLup0nlPeYNvHbZcptA4Jccwf9QkH6sPioIeZAl2G6hiwnTskBu7VPIb/eYBwjNaE6hxo85BXzYh7BdbzhLsPmmBJXxt5K/AxLa92EOM1RKmNs2+kiFvKg9C6QQpKcGYkJXKdVGrzAjyL+7q5tn0dn+C0ABbnrp6PdN9bCAQQmJhg== 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=4lMKhkx9Yupe1waDAXfDYtlfBrSmIA9l1obKx383vN0=; b=EN7pte30dAQTi0m0cBqsBOOQu6myPRyEhQcelKngPc6eN87rPIFddRu+MVFjal62N5fxO14Uce1tv1sGPzViOAaiQ6f2oJj3kdLhoNcKaanYT4eqjL4zb9Q1IXUDym2E+56J3YdudMqXGQcrlvt7u5FMpk4sNjAuZut2DWvMGPycwofEZDNhKqjAVj/V7IFB6gp+t09FDTvgasv1BaNzLoOgqUzQKvPaosIai41beHQOe5MJpxtxzZlAPtu2HKB43Zt5yWVev6mTD/swL9Xqp/jX21Q9fcqreq7ekeVjEr9vv0fgGIpDyDtRLxQ5/Zta5HAAZ3v302jv/ls0n0Uh2w== 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=4lMKhkx9Yupe1waDAXfDYtlfBrSmIA9l1obKx383vN0=; b=BeTKbS/zcfaorsoNOyNT9A4Iic4dhdq2VdWQ78m6H9WphChgdXwOhMHUilaAUzGIDP/bO/fHbDf9Bt/cgURrRtx68mUaQaelQGZaWOnF+XZ6Doo7fj/OIKKxULY7j4k6d7Wq5kVVWKfS51nUKf6vvWyQ5e7EoSqRDSzxD4/pp3geZyZrWr+QQ2pDQ1v+zVvIuAKbGSpZMgcOcNt3MKSlI891FXwAhzq04LueZ1+gSCf2nOICJt4NiaEh93H9kncccpKJPBMhwgsxVrls1k0UnpXsR89EuLpTOLW8R/dtM8EChF8Mr76A2EsULgUWEu4IoCfkyKxkkH20NHLqf/QGaQ== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:22 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:22 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 18/25] net/mlx5e: NVMEoTCP, offload initialization Date: Fri, 3 Feb 2023 15:26:58 +0200 Message-Id: <20230203132705.627232-19-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0126.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::16) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e714bf5-8da1-4291-2fd4-08db05eaa8e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y+Qx3cI7i1pcDfMqi6Ce1GzJ4PkgOGb7KmXaowiZ4DVmk9pXzB1bqB8oeJRhSvIKk9p7a0CWm2lXbY3/joVIf7LAAz75+MrVryuVMtD+uCzsYRKNdA7q6F+IjWrsxlYBryZRzCvoxDuMdgfZAXh8Hfv66aZM5F12cBcJxo5IJ4p81n6jR8qhEfpS4amdGDjFmFhMILBT3fRKCoDP+U4JvtvAhXyCo7HPqzzsqmM7GcIwGIOTRX1HW1GZfAC37dPaw/uoukhmzgv0d1zqZzQgnRozsyuGlhW7ltPvUKxPG7gY0bDCJzgqt3LHoBvlJpaGZE3EaH/dA3tAg+b+Xu+ps8CwlEW/JBTbmGSGYvX4tjJEv4BfrklgdPZi69cGLaVDopB5KCz6MA1y64yyU2rYTS17OuF8jRI3b+SRo1dXmUKwbyWk4A58dlqb8cK1kvISKyWARHq32aO424Uo6l/02RR/whGeC+WGbnfrJeAZwmKI5nU24VHQdpN1dxeV2Unvf4ByIYx0+DzfqXX3VnlSh4UQU3LjPPDUtzCNj6WL+7b/KMiHi/6nN7qnxjOz6Ety46DdhA/rJuKwamnPrQCE0tFYcKlFq01sMOufcY2L6ZamAMTIPbIA+L5kiIg3pIjZqfxd8J1haoumGsZ1bUflBg== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(30864003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(66899018)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2lsltEanm3zC/RdrvEynBvcy+a8SGYFdAzsXweinjPINFMmAE7iIUdQ/H05oOaI45BhzfOxkLXK+hPuWp/AFiPgAyyiNcT3TuTP3aqypiKHvRXiu22VL/UmdX9l8tY2N2wYgPXDn1qZLLXzRM3bmrz4xScthwNHNo0h6bERAXyZGlh2TEvoiJITrTv/Nq8rw5S7whUwH53HmN49Ews6nG9diP1eyVRDVgrjq2lyq4Tvf02VTfg5mXVWJYrOkHQgeDdkwbvqtVHi5sgpw6Bzl255+2SSQ79YDwnTYufWK1ChVyZGdH7Z/t6o1fdsLKs7fl8gm5ugvXDR3SFV49wS2zKPXpMoemK6uIZdeIRM2Fshu+tpO43iEaAHuCROVqvkdjt47TyDs3kIxEJdZHk0ruz1CnAcuHGYZquYVa+BpmUCl1CCukmRECA1EezfxSewC4DbVsBU+vJ4it0mbFmKEHgMHr9YJiG4RH5PRyJr4CtepfZk5pC7227Xy/XMdkiCBg1iJOGshmS+qL/cTsf0oeZ8GqPrQS7fNvDPoUisa+nwhfNgqvJaTFpwDSDwosQe8YKXkdFSfO13PsixXHmI2C4ahb+q6Z/0T/jtSQGSvR9W6ytOdlY6pyonu2c5RTIxk/C+cX86nevPdVhtsKq6QYNtGFi86rR5iRu7enc+ukiqdnJjN+wmEByaP+DrZQfTkMCyLwq/m3NruBRyZcUbt9Ofw8u57NaOky1afqtGcQkaWjJx+5SweAU9soaisqdoWKL3qX8zuzr8L4RpChOvgML7Gcajm64vsdzGAaXj8D7saW3dc9ex6yvzwNE123oeVcRvXTr186fx7GDGxqEZk1a9hPEU7fd0KeM32b8Fsbfa2qmuOINJNbM8u7wja0cVzSKQkrWytb8B7InqzFOq3P1gembOd58vN6zXae4Si0OP97ZnlwWMAC73dvSfvo41vcsRbCkmJc83koFZ+pjRaL7NTSB9EW8a3RfJAH6ofEuOYIQOS19sCrDzwJueCeVbQtYj7TA1hpnZRm2zn0N6LYTFWQnrEw60OVw/MqcU6ca8Iq4e3QjA0YPo8zntw4IVeL7UVfHg/EPy0asey96jGG9xsNjz7L6yAGkg5chKohzuFrD7dgAWxK+8GkQFPvpNioC/tTEupsiYtJkzYv37bbuTZZbJnvO9sqWxduryctSab5/iBsGOtYvFFnOzMlVFgICQ47697wIraPZwxh9LBAnPtut2TNVarR40LAX/O3nG1QGkgkqge0ctTgpglhoivcDo/nh6PoFg83CCXGobDrVp9ZpnJ9D+OOxKFbskBT+ydbwPXCkhxuLtnClCT21yPMIu6Fx4de49qucDDlc1jTYt3iwbEhWtw/mo/HUAYljNNF4mZ9PQ5H3WgQ98IQsFk4jpDgi0PKT7zTmLYrGWLOKSKPHIid2+1QzMS3x0yby31nWQlIJX0agErF4nKH2uY2rKUrQcvSlkjyavTCwsde3yPlWTp8spb8nZVq2lIDFy5tBFekRAnwui73bEDl0YQNhG8V2XGK2w1AYVMX9CgIpWSsarJ3nrfnEI5TwZxvvDKEPVedzLS69Pl/yQyAtRo X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e714bf5-8da1-4291-2fd4-08db05eaa8e5 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:22.0103 (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: X84U9YPK/DBsrs369MpEGTZq56ZFb0Hg0Ls/oRWDY8AqQRrQzq9/L9dhQH1dOqecczF4kFCi42dDZeDKs9apqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 18 ++ .../net/ethernet/mellanox/mlx5/core/main.c | 1 + 14 files changed, 398 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 26685fd0fdaa..0c790952fdf7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig +++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig @@ -163,6 +163,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 cd4a1ab0ea78..9df9999047d1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -103,6 +103,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 dd68f373516b..1f8cf297464d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -328,6 +328,7 @@ struct mlx5e_params { unsigned int sw_mtu; int hard_mtu; bool ptp_rx; + bool nvmeotcp; }; static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params) @@ -960,6 +961,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 5233d4daca41..c3598c2e05d7 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 @@ -169,7 +169,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 a21bd1179477..b34518eaaa1b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/params.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/params.c @@ -806,7 +806,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); } @@ -836,6 +837,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); @@ -1175,9 +1179,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 c9be6eb88012..d5b3455c4875 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 { @@ -146,6 +147,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 07187028f0d3..e38656229399 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 7708acc9b2ab..cb323a400e6e 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) @@ -1939,6 +1940,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 7298fe782e9e..63df22d9ad99 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; @@ -1560,7 +1560,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 43a3ff2d2d90..e582e97e7c44 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -49,6 +49,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" @@ -4146,6 +4147,13 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, } } + 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); + } + } + if (mlx5e_is_uplink_rep(priv)) features = mlx5e_fix_uplink_rep_features(netdev, features); @@ -4914,6 +4922,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) @@ -5181,6 +5192,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) @@ -5247,13 +5259,19 @@ 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); + return 0; } 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); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 9441588ac524..10df78b4f35c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1556,6 +1556,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 Fri Feb 3 13:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127537 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C947C05027 for ; Fri, 3 Feb 2023 13:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232922AbjBCNbu (ORCPT ); Fri, 3 Feb 2023 08:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232924AbjBCNba (ORCPT ); Fri, 3 Feb 2023 08:31:30 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22BBC457F3 for ; Fri, 3 Feb 2023 05:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXbLd3FcbBGCotp4LcustFtJiAfDQNV6gQSyR8rvz2Uobf+qiZLRnIfTladxRd+anXlLcg7+OZivW3cqmSU0a//ARhG+IuFcdc6wZAwsL9yaJv6e9/2XkuRZI8e6wNVJbTT2Hnxgd89UFLb2rl5Hu2yni0ZU9Bpei2kvKXRVz1SMNubarQ/cgIPPQg39gofMzcd25NqB6e3wBPX0fW4jQFn0mV11FRxMJNpBPLLgEygUwos0v1f14VQemhrmFe3z/R/avIV8n+hW9quRf1wKSb+YWNVAq77kDLc1aF+l8iESSZ6gI8yvrJ6r880fm+07B8Ao+tqArdCbqh2lxU1HRQ== 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=frZ8+7cWKtArgmDeA3M3gyIsxjFNZwS0sSpJ1ht1F0k=; b=HhwAhREZLTxO+EasWxGFx2yWb+l/usbOu4ZYP//2aim7W74zHJ4pdOu4yvxvNqYSw2NTWxRoz+n6d3nCuyxH5MszxwcAlaMJpqlelW0rmhPvOsJ68KWQcXXlS3j5E8uHMp+QtOtJC078G51vQvy+lRn1lD8koyK3f9i05j3f1aFAObSTqLZLd6fXh9szt3Fvlw/L+oojacizxbsBcnXCAebTi4qbetqcBqcyW5g6uSnvOVJM+XB0GIcZzrFybPYhVcqGTxqh5ZTGLrBDPwhAu1Tam3L9pjAlpQoDjf+gaxoAqk/8/kTf6SWHigsWG4ltPyENBEMeZkZWfpfrfFNIOg== 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=frZ8+7cWKtArgmDeA3M3gyIsxjFNZwS0sSpJ1ht1F0k=; b=ow2IpamHVqbkgzvz0eg8yHNy5bCgJ3lFlgea7eW6fg8XizL2oIEJLCoaC4JzQwdrw9/WB4elEhHEFEL8+MpmBAZDcsgFBrnlaSxa+yagKkMI5xxWPvSV1CZBeIfKGvL6+DvXk4u/okkH1bEE9EzmXTE6fom3+NNS9aNlMNzi67c/ULU4G+TzODCf2bfrVKTmf1L1z/cvJWCB9UvE45JkRpeNOYL6CYfrxuviGnTFvF6xoisQxRFkzXXf9X5j1c0fGGyZCXWJzbFdzTU42KZ7SMcLCFL/CFydcE3X62cgai7qNudJpjrwHCPNqiXVmUe7A1TIELH2dQN34ynyMame2Q== 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 MW3PR12MB4476.namprd12.prod.outlook.com (2603:10b6:303:2d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:27 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:27 +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 Subject: [PATCH v11 19/25] net/mlx5e: TCP flow steering for nvme-tcp acceleration Date: Fri, 3 Feb 2023 15:26:59 +0200 Message-Id: <20230203132705.627232-20-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::10) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|MW3PR12MB4476:EE_ X-MS-Office365-Filtering-Correlation-Id: 585adfb0-f142-4302-a29e-08db05eaac19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s1kCtDt0uDn0dvHqzOGPiD3b6HMO4SXI2vg9EQAnH6htFXyksqQfZQm9F5HcSVzFvQJQhjH45M9I3qVAfxwfPsidIp6y7f89ii/9Fy9l+mnAlTZG7MhQ/sxU1pVuOfqRXwcLVElt4Wn+GJc27zYFgXqVS6UhSBVFtlmlyYQkrPJQtQcG3kEiHrLGIEsUUo807i5QoiwFfvl3M4ZKksFYRXORFOSb/qLKo62+tKXLvS7BdiKBis0QEmpJKCbsL6K17bpbo338svlSWYOI+FwKsEb/wwBmV7bFouARDw4lEzKnaOykU8kSztQJT30IkdDkGPRXry6otuFfhCgm41tntlZGz273f+L9ApZ5OFsWIE6OsGBEeSfaRppNrNZrsi1hTrEMZEeAc8FWdGMBAtSv+xI1+yNB1ARow9sS6AVJ3u0ZJEMDzVpEHHmQfyyMDs6jPYdZpURO1x+24SoAinsGGdij6Xvl8a1yCjY/3cdhR9XwQctx/Opp/Cje4T6BUsCTcy1FsA/Fur//YpQoqve6YGZWDKKr8yLkaE/aJeYNOmM69lM6DWWIpqDCG7NWNN9HP3RoFxI1qlgWmkJA/WWFEZ34me4zJYUG4cv4ZT3QpjRjvZsHWuYwU+rdUjOfkEsas/Ft2my41lgiLnzlV0BsMg== 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:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199018)(186003)(6512007)(38100700002)(1076003)(6506007)(83380400001)(36756003)(2906002)(26005)(7416002)(478600001)(6666004)(6486002)(107886003)(86362001)(41300700001)(66476007)(66556008)(8676002)(2616005)(316002)(4326008)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mKLUxBEYfQqM+SGoZCVqTqIk474CqWIyms8RnWH4GbL/t/vCNOWOX4SkK7d8HtCcbTS3yUGJzGoYmwrKkHGUlMpeeiZlVlGHIQNtdfFf4P3uKvoXvYuWZsAMaQEvNU0MONndHS25Ih4pg/Y3daHHxR2N8FceIxKL0WaWyLOeDCrZwzvhMoosjYbdDz4MEPbA6gh5N2U7cAE0+AywCrxOIsCrUs+r+P/KksxR1y3CE1JL2YHYil5eXC7k/oVNeCaIMNxE21i/RbmSHi3z05X+J73SoPvCMdBGQqt3ABZOvwESFoQ/IILVg1RPwDlI1hfGT8Qhrt6N/VD+NXOdd+CdIg4YifKjac7zp6j/dQzj2x7zvrrrRnGPqAgu76ohQTveuBFREJ9pXPcYtJkmj85oq5NXmFS37jroXI1ASJujwDyrXzhuxpUVm7bAAL7lSkrJ0dNnh1/6Y9mfpsN4fAMkdrx0l9hmqgNYc9QQCjCK19SVHfmmtds1Pp+GJkMNn60GSs2B8JjKy+rNztK6O+IhfY1s4GWD45nPUmeNcu30soBEpxhCCXd6dynr4gxh/bC/olhcwgHFlKqgQNKiux49EvWxrnA2DVVkYG4/GfV9geVX5KZoHCXH8wuRq0RaiBvwbaflDA+5myUj5u4trzqqQJXKKL9LNzB9JTbqu2H/UHtDfKRwazOTxSN+Hn9GNur7+x11GOcSDndGNI9L/ceZe5dttf/jqu18G2xzsNtc3VVzgqdnFwApYNdS8SSHAcEQ9Hx9rZFGmm5JSPyDYxwSkKsclsgkOuWeSZ4pi5CHjPrZsF4lvWrN2x+bbfbxoMDyEkZNOe2p0wmEc9+ytagbN+gREHIm7wDf9oCPXcY/+SWOUnqvb9CjGp0F1SE4qU4F2CalDTK2AukIjWr67gKUPZaUNxkaGbd2bQgEHGzPfQEP3k8pYgJ4O44cPijheuiLM4vXXdnkBJiX1ZBwyr757Ds3gxQod/BAM5leswFBnEO6jSvHyoeMi6QgMiiJexE7Yr1tsg+dR0c+UBlebziiAh3WZ3S0K2TMG2c/NkDy/WxoA5knBr5vDGLprU+tC1EzmkmwEVWDi/Eo1MK6oA2fuWDXXpU5ofAi22+BFkdxarTAtfATWlNvMjmkqvz5pCvEwGg+LSTSIy9wz4HWOlSC1g5aFiFRbUFpJJbNdhrmW38z/UdcWhxzETmp0zc9GGI5RVs4vnMglVkCZYH63In+pm/ghnVQJDOsEXWRTCVprVNZW4d9gTMuXVV/hiPc4U/eM6JxPVLse7l9R8k2k91xubChJiP1/Ffk517QaRBYazmYV70Ao5Ar+cL57mGV5Vk8SSH9eX1Le95zKi319jMwa/pdzgjQbQptHH9+LK0X8Qg+CokINzCNeZm9dTT8raj/zjvvMTtyJdVJQTvz97xG8aIRDtTI9oYJ0d8VwkjKd0mbYlUIU/EXupAQAHKAtO1ZlqcAJBjJZM1ZiGfWpE2xApXqgeDQyW4bty2XtHev7v4Cv08E5n2juq3i9qzY27MArcYUZQ4ndrdOoB2x/Vp5+ii3EeLQevaDm6HOLiv6UJtvvC5XWjEHA/b7GO2At49+ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 585adfb0-f142-4302-a29e-08db05eaac19 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:27.1997 (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: hgipnLIWwwIed52uE3DO7TKYH9czzZkVPViuMNWupO/4CIMnPwLp9oywmQwNLoZ+32A0jyUlIAV8exD9jPRAGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4476 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 88a5aed9d678..29152d6e80d2 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) @@ -360,6 +361,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++) @@ -371,12 +375,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; @@ -392,6 +401,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 Fri Feb 3 13:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127527 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 781F2C636D4 for ; Fri, 3 Feb 2023 13:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232790AbjBCNaM (ORCPT ); Fri, 3 Feb 2023 08:30:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbjBCNaF (ORCPT ); Fri, 3 Feb 2023 08:30:05 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F9AA0022 for ; Fri, 3 Feb 2023 05:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YkKQGK+m34strvNazznljEbWmxjqIhglYcgYhWTaexr8JuXMa2t6fOI4MtmXMTpgTJ3i2+rV0t5fjDg8fPbCwTU3UMSvaeC6UfJJNUPvhH/hsaMiTtG5SypjAAlVNBA5BMNSSZBFeiGqY69jgNeMYeft5H7h+oVwXJ7eikpAwKvQb2bAyTbt29A+1kJzcK6ikcNhb5qQICEwokwHkgRAwLUW0UBT4U3pKxbVdhZwnabLK8ciIRcJ+loZsxKtJvc2cp5DOtaHFk32EUVqQHDMnTZ+VxTlL8rlcZNvXhNZdf+hMFjq0whgZkBq/J2Ys/kvaMD/lhrSmO0SrYNpXwUjdA== 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=ZShbLT1nkELVnUDy0KBZCG97NNC9dw3T07up4Iph3QM=; b=TDVaTHJ1gvl8hGpeBvzipvRfxk/3tc1ih87suaypCwy5lrBsK79h6ng1n1VgOPIMS/On8U0a1LwTNR4tuGBPDWmANUqCttJiE1QA48sRBQdF/oesrBMmrSX0aTM0Zj5wY85U0o4yolTzJHISdQgq0WBwglwLPZyt9G7vJOtcB1rtnbsrmcUB1j9ELqHXcyyw4QLV/bmSd0hfzejPOUa4AI0WXUaGCv5EMx9hSwO6J1kym/k6E8DiuSuXly9cMMdcNNBf0pXXfrxi28Pmi59Xc9YB5/RAVpY6X3+mSUAURTOY0z0qNbwewM0GUEbDuVOfPioVH4rzxbkcI3LsJEZQpw== 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=ZShbLT1nkELVnUDy0KBZCG97NNC9dw3T07up4Iph3QM=; b=NfeDN3G1ORF8bRt9Lmt44A/8TpN2P4VZzqb3iC6bMLz+iw4UOKQ2beaEXHI7lC1PgujXvJjVpxUutuoTcW4GdO9nIIgi/hgNv2Yg3jjpSxBw0y5Hy2aGUjQct3R6tWfgaBVjkvYrxw18eGaRgBnrzxRMVBs+ZK4oSnQkEtRFcYBYEIXQqfDeuWRCriMoL8qxdOirOrIj1mzp2hCYCBR3mV+Iqi1enuYDALUiuwe30mpFwyVmMFa9ra6flDfmlpnlbtECMFnkrEf6UXvXw7L8tDGRrfM1Jfx5rDRNhGSzmt2ynKmoINEpJOToO1bisn+wUxra3TOgVxA24SDno8DHRA== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:29:33 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:33 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 20/25] net/mlx5e: NVMEoTCP, use KLM UMRs for buffer registration Date: Fri, 3 Feb 2023 15:27:00 +0200 Message-Id: <20230203132705.627232-21-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0059.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::21) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: 27b4e2ec-8d47-415a-4d30-08db05eaaf9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j9PPlfV/7e+yQwmO8admxLHtjqTKUyONDS7q+9ED5SRqGGr77EBggOHWlLzDXQC52W275sVnfYvbHRicFzOYb4hD/S1kmfWTaJUVziKrPzyPqrkS6m3XBu5Oht0IOHk/YdfvYW+6oK/0Pq22S1NIS9E3Ro+NWgB3hykAme9b1lsk37krI4zt6Xv4Y/0KyoFMM6ZegwAwido85VQaPSgKYrjXBxB28wgJ3Vu/xXG/2B2Ml/8ZCwRfSximyUYGPjr2LP041Bd5Wx/WAHmowyR/XQSeKvExKPwKbRQ0nXlBdJpt8ArkJIpWZNhhBHFl9x0t7pOdc2dyETaBLyyiGfNKt7Xc9A5Tt0Y9epr4Ul3iguo0XHiTJuG6Iiv7lyYl0LcMgKB2k92OV6Pmb/HdtHYMOWRY+z0UtGolGFMzk7MjPg1gX4dmfnapSQqLBYa7/3cMye3dzxAfIgMegosdq8tfrVCReOXiPRRgec50VvI/dlabNXvsXGMHoILLZfG+c2bfeZWQKya2yzWoT8DiKdK89CUlDGHmAYbXLeUxu7VeE492atVDnJJ5jgdjX63i6tdXBESR9nwjL449HhqUn4q5WSgX3VRULopIKPc+uNqbPnwXJUK9daBQ3ywWAxXGAzCq4CP7Do0eI5Qtbj4MtL1Pvw== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V9gWmKpLleLTfz2m+ixeR8yD8oQJ7OzubTCI5cUG5ghCfub1kIQRkgBJe45RMjX9gKf45D69GcdF970N42C2Yh6bdo+nAkWciLQAroOb8jKWTYvI9wGpd9v6a3E1QZNhsF1ikA1HrpVWOChSfqwAuxXaeyv//1zV+KRWLDfw+8fZ7RKL8jgDL0PglC+X4bvTlCfWywDnLpieRFIDjd4s7w8+8JjbsLG5AT7N9MW/FpN83+oB3go+tOIV1rycNBIcraM4OrY6nM3M+kZA43SNftHO12ZwUnWe/h1m8XfXkbLDnkReiMoDLHGj0BC1lXtAgmmQIDtv27eHw5vKrzAxklSoSRKf3HhclzIzn0jZ2tWxi/I94UzbAhcUwzmkTtYVcuCYOmleUw7mR8LpS8lu8CU0REOtq3MQA3AQsEtJT4Hf5iUoMN8JTAsOZoZxBQwzYSGVTXmWtEM42B0GJvlC8edl7qND+SZ7uscu9/AAmizjWRYbfluOomFiF9wxatETsOsNnVr1w12+M4pHxrGN592BgTKVWQyYnWOcb7PiO9hW1iREF4TcFLE6ksqRkHwXhkQjhJM8FNJYV+qlLTn/VVddog2FIzZbEB1DJQ2FbsvKRDZHXfqbNVej93+AXOhP8krygPzhS7FzInAbvuUcZi/huJ58A8L8YFZrPtwUo4qh/8FxjZvn/PzUb5an6zaZApPHBLhMSAv83FYsH/IEw7mHXBASjMKeIBX6U7/B7db4fSn1Kj3ABO/UtUsaSxvE+VXcblvQ2WkBWM6kXexyQEhkpUnGs0FCfe8H0YJ6QvI4xOOtU5rkx+KFzxtp+ETnBfPqGjc7stfTPLY5Tqux9tLskzdcrdbPXgBilt2eZbwBis4+3ZT0AkzIIzlPAB0ovcYAekh/bS86u0G/Jr+1ZYusGDlZp+mLvgYFYZKLoQp+VYyuc9sm3liRrdq43tt/KfqI4g9s+LZQBpJkcj3qrraGj35lXjmmL229DgYo9wC/AbpniB+h87pcYbIDE2S2WBfo8DiunW5Ogx0zWPWeH643vYa8DLL8d72/Wnam9J646g8QGtJ3ZrrclCu06ANQgiI7GmM6hVtlMh5RAU0XHmVOoknW8F3BNAK/jl9PV7wAC61feeT4NOkwrXy3IIHsbOJOatgucfQ1RxYJar5knr++T++oDg94GsGI8Zu8QqV9+JroPgsIdkLRW0rAstBPRcgPkRyzEST9Eax4s9gp2/Vpw74bKZvm8EirZywlbAVp3bmes2bUcOnInByyzlc4IaGIy2sbFu2R9S7m91TG5y5RddsBgY+/5YtozSuAaPAqUUJMtXSb4edWfGSjqLQx3z39qzMdRtOr4XgiVPCQs53cbl9qB8tvEud8/MR8BfW6rsp3E4RiZ180H0DAcBveeUCzcoJw2swoWIr+FLs8AuxN0x5A4I53b4u21xi6jD4FV38g0OBqnvgdK8FO14SniAVNr1+U06hEeA8zHPf63YJvL+AYhfZWLpsqFtyHTGm7icJhzqKcWEOiTn4AV0LUOey3FGWrA6okdtzt9tFSTXWy6FpemwfixxDy3uOiUIha6CLwdFVeACwIiJUmQ1Rm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27b4e2ec-8d47-415a-4d30-08db05eaaf9c X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:33.1049 (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: XzfUnhhIacFEzC+NB3QMTuuo9cNFoEDCLbZq+GRMs3lqUNfFw2YQCZZBgVQsAhSmeYcwlMN1EjQxcDM6nMzObA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay NVMEoTCP offload uses buffer registration for ddp operation. Every request comprises from SG list that might consist from elements with multiple combination sizes, thus the appropriate way to perform buffer registration is with KLM UMRs. UMR stands for user-mode memory registration, it is a mechanism to alter address translation properties of MKEY by posting WorkQueueElement aka WQE on send queue. MKEY stands for memory key, MKEY are used to describe a region in memory that can be later used by HW. KLM stands for {Key, Length, MemVa}, KLM_MKEY is indirect MKEY that enables to map multiple memory spaces with different sizes in unified MKEY. KLM UMR is a UMR that use to update a KLM_MKEY. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 3 + .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 123 ++++++++++++++++++ .../mlx5/core/en_accel/nvmeotcp_utils.h | 25 ++++ .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 + 4 files changed, 155 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index 37217e4cc118..58be28376ca5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -50,6 +50,9 @@ enum mlx5e_icosq_wqe_type { MLX5E_ICOSQ_WQE_SET_PSV_TLS, MLX5E_ICOSQ_WQE_GET_PSV_TLS, #endif +#ifdef CONFIG_MLX5_EN_NVMEOTCP + MLX5E_ICOSQ_WQE_UMR_NVMEOTCP, +#endif }; /* General */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c index 9ddee04a1327..0fba80b1bb4c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -4,6 +4,7 @@ #include #include #include "en_accel/nvmeotcp.h" +#include "en_accel/nvmeotcp_utils.h" #include "en_accel/fs_tcp.h" #include "en/txrx.h" @@ -19,6 +20,120 @@ static const struct rhashtable_params rhash_queues = { .max_size = MAX_NUM_NVMEOTCP_QUEUES, }; +static void +fill_nvmeotcp_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, u16 ccid, + u32 klm_entries, u16 klm_offset) +{ + struct scatterlist *sgl_mkey; + u32 lkey, i; + + lkey = queue->priv->mdev->mlx5e_res.hw_objs.mkey; + for (i = 0; i < klm_entries; i++) { + sgl_mkey = &queue->ccid_table[ccid].sgl[i + klm_offset]; + wqe->inline_klms[i].bcount = cpu_to_be32(sg_dma_len(sgl_mkey)); + wqe->inline_klms[i].key = cpu_to_be32(lkey); + wqe->inline_klms[i].va = cpu_to_be64(sgl_mkey->dma_address); + } + + for (; i < ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT); i++) { + wqe->inline_klms[i].bcount = 0; + wqe->inline_klms[i].key = 0; + wqe->inline_klms[i].va = 0; + } +} + +static void +build_nvmeotcp_klm_umr(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_umr_wqe *wqe, + u16 ccid, int klm_entries, u32 klm_offset, u32 len, + enum wqe_type klm_type) +{ + u32 id = (klm_type == KLM_UMR) ? queue->ccid_table[ccid].klm_mkey : + (mlx5e_tir_get_tirn(&queue->tir) << MLX5_WQE_CTRL_TIR_TIS_INDEX_SHIFT); + u8 opc_mod = (klm_type == KLM_UMR) ? MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR : + MLX5_OPC_MOD_TRANSPORT_TIR_STATIC_PARAMS; + u32 ds_cnt = MLX5E_KLM_UMR_DS_CNT(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl; + struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl; + struct mlx5_mkey_seg *mkc = &wqe->mkc; + u32 sqn = queue->sq.sqn; + u16 pc = queue->sq.pc; + + cseg->opmod_idx_opcode = cpu_to_be32((pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) | + MLX5_OPCODE_UMR | (opc_mod) << 24); + cseg->qpn_ds = cpu_to_be32((sqn << MLX5_WQE_CTRL_QPN_SHIFT) | ds_cnt); + cseg->general_id = cpu_to_be32(id); + + if (klm_type == KLM_UMR && !klm_offset) { + ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_XLT_OCT_SIZE | + MLX5_MKEY_MASK_LEN | MLX5_MKEY_MASK_FREE); + mkc->xlt_oct_size = cpu_to_be32(ALIGN(len, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + mkc->len = cpu_to_be64(queue->ccid_table[ccid].size); + } + + ucseg->flags = MLX5_UMR_INLINE | MLX5_UMR_TRANSLATION_OFFSET_EN; + ucseg->xlt_octowords = cpu_to_be16(ALIGN(klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + ucseg->xlt_offset = cpu_to_be16(klm_offset); + fill_nvmeotcp_klm_wqe(queue, wqe, ccid, klm_entries, klm_offset); +} + +static void +mlx5e_nvmeotcp_fill_wi(struct mlx5e_icosq *sq, u32 wqebbs, u16 pi) +{ + struct mlx5e_icosq_wqe_info *wi = &sq->db.wqe_info[pi]; + + memset(wi, 0, sizeof(*wi)); + + wi->num_wqebbs = wqebbs; + wi->wqe_type = MLX5E_ICOSQ_WQE_UMR_NVMEOTCP; +} + +static u32 +post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, + enum wqe_type wqe_type, + u16 ccid, + u32 klm_length, + u32 klm_offset) +{ + struct mlx5e_icosq *sq = &queue->sq; + u32 wqebbs, cur_klm_entries; + struct mlx5e_umr_wqe *wqe; + u16 pi, wqe_sz; + + cur_klm_entries = min_t(int, queue->max_klms_per_wqe, klm_length - klm_offset); + wqe_sz = MLX5E_KLM_UMR_WQE_SZ(ALIGN(cur_klm_entries, MLX5_UMR_KLM_NUM_ENTRIES_ALIGNMENT)); + wqebbs = DIV_ROUND_UP(wqe_sz, MLX5_SEND_WQE_BB); + pi = mlx5e_icosq_get_next_pi(sq, wqebbs); + wqe = MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi); + mlx5e_nvmeotcp_fill_wi(sq, wqebbs, pi); + build_nvmeotcp_klm_umr(queue, wqe, ccid, cur_klm_entries, klm_offset, + klm_length, wqe_type); + sq->pc += wqebbs; + sq->doorbell_cseg = &wqe->ctrl; + return cur_klm_entries; +} + +static void +mlx5e_nvmeotcp_post_klm_wqe(struct mlx5e_nvmeotcp_queue *queue, enum wqe_type wqe_type, + u16 ccid, u32 klm_length) +{ + struct mlx5e_icosq *sq = &queue->sq; + u32 klm_offset = 0, wqes, i; + + wqes = DIV_ROUND_UP(klm_length, queue->max_klms_per_wqe); + + spin_lock_bh(&queue->sq_lock); + + for (i = 0; i < wqes; i++) + klm_offset += post_klm_wqe(queue, wqe_type, ccid, klm_length, klm_offset); + + if (wqe_type == KLM_UMR) /* not asking for completion on ddp_setup UMRs */ + __mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, sq->doorbell_cseg, 0); + else + mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, sq->doorbell_cseg); + + spin_unlock_bh(&queue->sq_lock); +} + static int mlx5e_nvmeotcp_offload_limits(struct net_device *netdev, struct ulp_ddp_limits *limits) @@ -45,6 +160,14 @@ mlx5e_nvmeotcp_ddp_setup(struct net_device *netdev, struct sock *sk, struct ulp_ddp_io *ddp) { + struct mlx5e_nvmeotcp_queue *queue; + + queue = container_of(ulp_ddp_get_ctx(sk), + struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + + /* Placeholder - map_sg and initializing the count */ + + mlx5e_nvmeotcp_post_klm_wqe(queue, KLM_UMR, ddp->command_id, 0); return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h new file mode 100644 index 000000000000..6ef92679c5d0 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_utils.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ +#ifndef __MLX5E_NVMEOTCP_UTILS_H__ +#define __MLX5E_NVMEOTCP_UTILS_H__ + +#include "en.h" + +#define MLX5E_NVMEOTCP_FETCH_KLM_WQE(sq, pi) \ + ((struct mlx5e_umr_wqe *)\ + mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5e_umr_wqe))) + +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_NVMEOTCP_TIR_PROGRESS_PARAMS 0x4 + +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_TIR_PARAMS 0x2 +#define MLX5_CTRL_SEGMENT_OPC_MOD_UMR_UMR 0x0 + +enum wqe_type { + KLM_UMR, + BSF_KLM_UMR, + SET_PSV_UMR, + BSF_UMR, + KLM_INV_UMR, +}; + +#endif /* __MLX5E_NVMEOTCP_UTILS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index d3fc3724a39f..3ae2c3f09476 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -981,6 +981,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 Fri Feb 3 13:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127531 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DFB4C05027 for ; Fri, 3 Feb 2023 13:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbjBCNat (ORCPT ); Fri, 3 Feb 2023 08:30:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbjBCNaa (ORCPT ); Fri, 3 Feb 2023 08:30:30 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6DB19E9C0 for ; Fri, 3 Feb 2023 05:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AN0GEZTkBGZqt9FtUJ4n8pD9y3sSGe9F76Ju7wDOEJHQp9GfTkvtdxURr82FfDZC7bhQh1e0SpDcDnkOk1XM3tOAENpWKpD7kUTST4oZsVQ6suRBHvja19NmSzrnkZeLWGLhHFxpMhzzGrB2skCCDf4KcC8WRf05ustRki6sGWS4kLAhUgnorusj7SbmeWq1hq/VEW7JGOfjslkqLgL7sJ7PH93BYAUVPy6tXz5dcpIll1wNn8Yahmh2iKRgQ1uCDavPU0MP5TK5vqc+C3ZQnUveJRM6356CFlyGAjE4J93ypREg/qsqIVHIYbAiIvUM++ZsrpCnsPoPNRNQxv2UQw== 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=HNQnwRadzSAwbX+oRiHI+I721k2xUGlv7TKdl7fb0XA=; b=kgHMLMBcN7IailkTF7So1dizWin3NQi149iZD5c7k0g6A8RNOJA9uOK5XE+W9RG/OLGv1QDk9OX0FOFngidZai5lG4pzBYCE6Xpmb2dG+gkr4K5NLJpDJjLQWQheMpd0Zpqd4TPvcgN8lS2JZInUM8MjNT9kCG4ucQJofllS7tRPzxtEqzOhQ1jKDXwamvBXg9oqmCJfjCvntdwtPTKSl+JTRE0nTN1BMFMGM+0yZ/7BS2gR2kw2vEKVhvVluh4A2NlB7aD5tDF+jZnK5v3jLlWzdsKyEC6iQxksZMLYoPVEn75LhzBQ8RYI555PtH7x6xG5r00aRJDTGgJ5j39udg== 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=HNQnwRadzSAwbX+oRiHI+I721k2xUGlv7TKdl7fb0XA=; b=X+C5mitJzDbFlo34ufSILJx00qNa0P373lDVy024UqHoIq7PL1prJ5+y3JOB/KIbmNoubjFcHR5KqVU5MmziOvureoD9M5g8LtX842wqKujwRg+HfxkBhXfh83Dt4nbT+YP08PJbRSeN26HS925TbOgwYflMn6G17Jwwym2L3gJ2cOdCQglv98PSpibT290lCGMZmJPbGscrXts+w8zChCiO9NfcEW5/J0/7yqqMkqCyVvnRA5PZt1kkC429K21gyLo33D9Uz5oYWFi3sdFOTmzCSQAJIDlzWPBbbIXYLNx70IHswWEd03+vlo91X9P+i7K8MveAlFIAfXjubHsxAw== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:29:39 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:39 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 21/25] net/mlx5e: NVMEoTCP, queue init/teardown Date: Fri, 3 Feb 2023 15:27:01 +0200 Message-Id: <20230203132705.627232-22-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P265CA0022.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::34) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: ecbe232f-03fa-4430-5f73-08db05eab36e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cQaDMVx60QCRBBLdJAW2S7cjxb4jeR6TGo5skuYBEIevTfIRtkRUcIlytVfZU9TM4f3A3Dd8PbC282Mdi2y7SwDKxLuSBUdrnZsVfX/EXDTgut8v9XQXDuZowqbEJMgylMeZgnO9RNCmoRTrUsVCPIC//XKOABhbTfjDYrG/u0m92J599SWL1/XGE+aopig1DNTz6RXYd84VjOnbvh9gnfXvlTk8RJ4bQbpYuRuRkgINCzU4q7wzymgiN+O/mpLvyswfdGXlHm8cB66Kcsg5si3//ohQ9ZwFBjeCyZTq75HpQTUt8wntyaIbBh/cPtOoA80PbnzFlKTdwCvToOnRJ68aV17Svxu3ru7CZ9eXKBnN0mGXyIlBOc724pikOX0QHzPusetfk4Af5j1KnSrWG60ASQVfG8gv4JrOKW9Vreocpv+n+cN+DImvjTn0HYbyyNpzUc4gZRpA7QXzVzcc/eUptL+wibtGPaB+4KHfr9QsHGcPfMXBpgICohkhhRyoOTNN3FrpKjVIMXKZvkDzfmMdSKsMVfAycTGlsiZdrjSgNO80+DVu8c/ifRqufUT5U2IYxcMt6mOZSNlkrIm16nUoY0aB/IvgYWKNYBlBTQ+RJORdTsDktpqrikIWKsD60Qn2bVs6/zzznBRVrucZXo+Vx6m69Ho0TDXJXq1RGv0oS0MlT4r6jmt94wNFo9YZ 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(30864003)(1076003)(86362001)(4326008)(38100700002)(66899018)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RmnRrjecnY5Gi+IN9/LyWAEwgYqLNAKQhjJt4mrY8ULlO2egdvOy51EsJREx8UstrP+6IEnCAvN+/SNiD/F+TfNUVZ/pUXcVr43biT28rzgbaS3hB92b38eXJy7v6BlntFmx5UpYo7lFXDDSZIiUYghdQUVUMiRB8N46mGq5/6j4pl5yomfZxT8CvYJevcUZS09QVNs2y0JvDFOYs84bf4aNMqLmXiZVzR4Odh2bwFKfTJPlBluFMlRc0b+M6OGLDS93nBsEqoZ5+9pybzYp8y3UUHzC4jzNL7ZFN1bLC8Mj5alLjgjo8US0D+vdjj8jHXf24PJaOXzVtXAh8KBDab4SuirsOSWfeqO75BGYgDOdCs4+JN19zojP4Zjmjx7RCxagZm9RFtNFoyZJJQUTjziimnrsqw7mNnCcYmptuYcLPZTyuNACJnW25bLR5gHuXEMEseDYtzCGiRMupp7BK0OSLTdYOEgiXuVkTax+Ue+AUA/WNAEnsvs1LIW49L3vnv2D0HyH8hycZ7/rcywog0zUykD45NGK2H7oDHoFyXBJ9E3yb0XwPbcIsJhwkewhqQkBUMysudthXVJujEEU+gQEAmb0ze4BJeJtaTeJeWjtaOZwLCrudrmvxjxgqomQAciChVdi7vMhStXY9PMEBMTzk4MXmOnOO0JutiEu9y2gVKM7VmyHU5OXcp1js7M75I6hPBAmK9pt5sbxJZJO7rQDyx6P23FKCTQIul/By5ad1Onl4EFa7+enMh54ptN2Eg8rga6qv3AOGcGd+Z5BZ1o1g1sORNQ0depJ7tGMAPes87tXLX+EwvASQApfU0qaRrbCCz0oetvS+2F2vJZxtlSraQDH9jn3f2iiLrbSqnB4gjWuzNnhNXRNZDIGym2BzkTS73e46qFb61flYlHgMPmG2B04vEaxpf2Zd7WVw7mmtEu1zcEybrXZfx5rH/DUH+sDcCaPMNjUk6f3fo0MWj0Hqq1ZR6MWC8qCMRvTUwE00hjgsu2qRVXZhxzxlOuC3Oa9bSz5e0oZs9ZJi5+KG90peL2v83v+AlSyIn7PqJqDVhVz9D4/yYMGbP0M4r6lWTzO3u/ooduOXNSHI6IaTNCvw2KmZxDR7hMODWZIIS2rXUoqc6SdhZfpznU5lbnbdQr/Hv14V0YjTaHjEY8QFlVLo/XbOgYqb9aJlh8UKwtaNcVVkRkxUiUZYHmSNlcpqCFFPsOAZPxSOOEntrw4fwe90Buey5tX1kQXgpOZJjgwT/YjURVRL5z9Abgmmv8B3WTjG1x0u9bR4jA+q1N14RDFEUjkGKmrodiFGFUtrhqlzaf7VbuGZ45S2CbEGOrfbFVzrIpqySO7hwp1rBOhL5932xtTQkWxCO3oUbaKZES7HvHciXB3q6ER+EqkjmO+CkhxLhQrcPuZ6L2gciX8RvegzD3aT+1SlkjUO8OiqwNIIDZaJjrQYQ6o7StuNmx1k4uIxmASVaOzgjL+tnMw+nicCoj9hwdSx77OiSPVDHAxQJI4BbyoQshwEskYWCmpRSUOdUvyzOmo9QJSksZ6yqupexIy6MtfhGWgM8DGpvnmAe6mcwhjoGNt2520S4Vc X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecbe232f-03fa-4430-5f73-08db05eab36e X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:39.7178 (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: IDjzjH3CLxKgWzQ0ejJBOULJg7qDzo6amQUVbbI95tjnvrPZHMiiJtW8LjVz++LuA+umVOpBgbgIhuycyfhBUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 562 +++++++++++++++++- .../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, 679 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 1f8cf297464d..46bdea1a9b0a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -1059,6 +1059,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 e1095bc36543..4a88b675a02c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c @@ -611,6 +611,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 5d5f64fab60f..59c22cac9ef4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h @@ -66,4 +66,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 58be28376ca5..31e240610e48 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 }; @@ -211,6 +212,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..64e4b3d2936a 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,326 @@ 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->nvmeotcp.full_ccid_range = MLX5E_NVMEOTCP_FULL_CCID_RANGE; return 0; } +static int mlx5e_nvmeotcp_queue_handler_poll(struct napi_struct *napi, int budget) +{ + struct mlx5e_nvmeotcp_queue_handler *qh; + int work_done; + + qh = container_of(napi, struct mlx5e_nvmeotcp_queue_handler, napi); + + work_done = mlx5e_poll_ico_cq(qh->cq, budget); + + if (work_done == budget || !napi_complete_done(napi, work_done)) + goto out; + + mlx5e_cq_arm(qh->cq); + +out: + return work_done; +} + +static void +mlx5e_nvmeotcp_destroy_icosq(struct mlx5e_icosq *sq) +{ + mlx5e_close_icosq(sq); + mlx5e_close_cq(&sq->cq); +} + +static void mlx5e_nvmeotcp_icosq_err_cqe_work(struct work_struct *recover_work) +{ + struct mlx5e_icosq *sq = container_of(recover_work, struct mlx5e_icosq, recover_work); + + /* Not implemented yet. */ + + netdev_warn(sq->channel->netdev, "nvmeotcp icosq recovery is not implemented\n"); +} + +static int +mlx5e_nvmeotcp_build_icosq(struct mlx5e_nvmeotcp_queue *queue, struct mlx5e_priv *priv, int io_cpu) +{ + u16 max_sgl, max_klm_per_wqe, max_umr_per_ccid, sgl_rest, wqebbs_rest; + struct mlx5e_channel *c = priv->channels.c[queue->channel_ix]; + struct mlx5e_sq_param icosq_param = {}; + struct mlx5e_create_cq_param ccp = {}; + struct dim_cq_moder icocq_moder = {}; + struct mlx5e_icosq *icosq; + int err = -ENOMEM; + u16 log_icosq_sz; + u32 max_wqebbs; + + icosq = &queue->sq; + max_sgl = mlx5e_get_max_sgl(priv->mdev); + max_klm_per_wqe = queue->max_klms_per_wqe; + max_umr_per_ccid = max_sgl / max_klm_per_wqe; + sgl_rest = max_sgl % max_klm_per_wqe; + wqebbs_rest = sgl_rest ? MLX5E_KLM_UMR_WQEBBS(sgl_rest) : 0; + max_wqebbs = (MLX5E_KLM_UMR_WQEBBS(max_klm_per_wqe) * + max_umr_per_ccid + wqebbs_rest) * queue->size; + log_icosq_sz = order_base_2(max_wqebbs); + + mlx5e_build_icosq_param(priv->mdev, log_icosq_sz, &icosq_param); + ccp.napi = &queue->qh.napi; + ccp.ch_stats = &priv->channel_stats[queue->channel_ix]->ch; + ccp.node = cpu_to_node(io_cpu); + ccp.ix = queue->channel_ix; + + err = mlx5e_open_cq(priv, icocq_moder, &icosq_param.cqp, &ccp, &icosq->cq); + if (err) + goto err_nvmeotcp_sq; + err = mlx5e_open_icosq(c, &priv->channels.params, &icosq_param, icosq, + mlx5e_nvmeotcp_icosq_err_cqe_work); + if (err) + goto close_cq; + + spin_lock_init(&queue->sq_lock); + return 0; + +close_cq: + mlx5e_close_cq(&icosq->cq); +err_nvmeotcp_sq: + return err; +} + +static void +mlx5e_nvmeotcp_destroy_rx(struct mlx5e_priv *priv, struct mlx5e_nvmeotcp_queue *queue, + struct mlx5_core_dev *mdev) +{ + int i; + + mlx5e_accel_fs_del_sk(queue->fh); + + for (i = 0; i < queue->size; i++) + mlx5_core_destroy_mkey(mdev, queue->ccid_table[i].klm_mkey); + + mlx5e_tir_destroy(&queue->tir); + mlx5_destroy_nvmeotcp_tag_buf_table(mdev, queue->tag_buf_table_id); + + mlx5e_deactivate_icosq(&queue->sq); + napi_disable(&queue->qh.napi); + mlx5e_nvmeotcp_destroy_icosq(&queue->sq); + netif_napi_del(&queue->qh.napi); +} + +static int +mlx5e_nvmeotcp_queue_rx_init(struct mlx5e_nvmeotcp_queue *queue, + struct nvme_tcp_ddp_config *config, + struct net_device *netdev) +{ + u8 log_queue_size = order_base_2(config->queue_size); + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct sock *sk = queue->sk; + int err, max_sgls, i; + + if (config->queue_size > + BIT(MLX5_CAP_DEV_NVMEOTCP(mdev, log_max_nvmeotcp_tag_buffer_size))) + return -EINVAL; + + err = mlx5e_create_nvmeotcp_tag_buf_table(mdev, queue, log_queue_size); + if (err) + return err; + + queue->qh.cq = &queue->sq.cq; + netif_napi_add(priv->netdev, &queue->qh.napi, mlx5e_nvmeotcp_queue_handler_poll); + + mutex_lock(&priv->state_lock); + err = mlx5e_nvmeotcp_build_icosq(queue, priv, config->io_cpu); + mutex_unlock(&priv->state_lock); + if (err) + goto del_napi; + + napi_enable(&queue->qh.napi); + mlx5e_activate_icosq(&queue->sq); + + /* initializes queue->tir */ + err = mlx5e_rx_res_nvmeotcp_tir_create(priv->rx_res, queue->channel_ix, queue->crc_rx, + queue->tag_buf_table_id, &queue->tir); + if (err) + goto destroy_icosq; + + mlx5e_nvmeotcp_rx_post_static_params_wqe(queue, 0); + mlx5e_nvmeotcp_rx_post_progress_params_wqe(queue, tcp_sk(sk)->copied_seq); + + queue->ccid_table = kcalloc(queue->size, sizeof(struct mlx5e_nvmeotcp_queue_entry), + GFP_KERNEL); + if (!queue->ccid_table) { + err = -ENOMEM; + goto destroy_tir; + } + + max_sgls = mlx5e_get_max_sgl(mdev); + for (i = 0; i < queue->size; i++) { + err = mlx5e_create_nvmeotcp_mkey(mdev, MLX5_MKC_ACCESS_MODE_KLMS, max_sgls, + &queue->ccid_table[i].klm_mkey); + if (err) + goto free_ccid_table; + } + + mlx5e_nvmeotcp_post_klm_wqe(queue, BSF_KLM_UMR, 0, queue->size); + + if (!(WARN_ON(!wait_for_completion_timeout(&queue->static_params_done, + msecs_to_jiffies(3000))))) + queue->fh = mlx5e_accel_fs_add_sk(priv->fs, sk, mlx5e_tir_get_tirn(&queue->tir), + queue->id); + + if (IS_ERR_OR_NULL(queue->fh)) { + err = -EINVAL; + goto destroy_mkeys; + } + + return 0; + +destroy_mkeys: + while ((i--)) + mlx5_core_destroy_mkey(mdev, queue->ccid_table[i].klm_mkey); +free_ccid_table: + kfree(queue->ccid_table); +destroy_tir: + mlx5e_tir_destroy(&queue->tir); +destroy_icosq: + mlx5e_deactivate_icosq(&queue->sq); + napi_disable(&queue->qh.napi); + mlx5e_nvmeotcp_destroy_icosq(&queue->sq); +del_napi: + netif_napi_del(&queue->qh.napi); + mlx5_destroy_nvmeotcp_tag_buf_table(mdev, queue->tag_buf_table_id); + + return err; +} + static int mlx5e_nvmeotcp_queue_init(struct net_device *netdev, struct sock *sk, struct ulp_ddp_config *tconfig) { + struct nvme_tcp_ddp_config *config = &tconfig->nvmeotcp; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct mlx5e_nvmeotcp_queue *queue; + int queue_id, err; + + if (tconfig->type != ULP_DDP_NVME) { + err = -EOPNOTSUPP; + goto out; + } + + queue = kzalloc(sizeof(*queue), GFP_KERNEL); + if (!queue) { + err = -ENOMEM; + goto out; + } + + queue_id = ida_simple_get(&priv->nvmeotcp->queue_ids, + MIN_NUM_NVMEOTCP_QUEUES, MAX_NUM_NVMEOTCP_QUEUES, + GFP_KERNEL); + if (queue_id < 0) { + err = -ENOSPC; + goto free_queue; + } + + queue->crc_rx = !!(config->dgst & NVME_TCP_DATA_DIGEST_ENABLE); + queue->ulp_ddp_ctx.type = ULP_DDP_NVME; + queue->sk = sk; + queue->id = queue_id; + queue->dgst = config->dgst; + queue->pda = config->cpda; + queue->channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, + config->io_cpu); + queue->size = config->queue_size; + queue->max_klms_per_wqe = MLX5E_MAX_KLM_PER_WQE(mdev); + queue->priv = priv; + init_completion(&queue->static_params_done); + + err = mlx5e_nvmeotcp_queue_rx_init(queue, config, netdev); + if (err) + goto remove_queue_id; + + err = rhashtable_insert_fast(&priv->nvmeotcp->queue_hash, &queue->hash, + rhash_queues); + if (err) + goto destroy_rx; + + write_lock_bh(&sk->sk_callback_lock); + ulp_ddp_set_ctx(sk, queue); + write_unlock_bh(&sk->sk_callback_lock); + refcount_set(&queue->ref_count, 1); return 0; + +destroy_rx: + mlx5e_nvmeotcp_destroy_rx(priv, queue, mdev); +remove_queue_id: + ida_simple_remove(&priv->nvmeotcp->queue_ids, queue_id); +free_queue: + kfree(queue); +out: + return err; } static void mlx5e_nvmeotcp_queue_teardown(struct net_device *netdev, struct sock *sk) { + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5_core_dev *mdev = priv->mdev; + struct mlx5e_nvmeotcp_queue *queue; + + queue = container_of(ulp_ddp_get_ctx(sk), struct mlx5e_nvmeotcp_queue, ulp_ddp_ctx); + + WARN_ON(refcount_read(&queue->ref_count) != 1); + mlx5e_nvmeotcp_destroy_rx(priv, queue, mdev); + + rhashtable_remove_fast(&priv->nvmeotcp->queue_hash, &queue->hash, + rhash_queues); + ida_simple_remove(&priv->nvmeotcp->queue_ids, queue->id); + write_lock_bh(&sk->sk_callback_lock); + ulp_ddp_set_ctx(sk, NULL); + write_unlock_bh(&sk->sk_callback_lock); + mlx5e_nvmeotcp_put_queue(queue); } static int @@ -171,6 +698,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 +719,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 e582e97e7c44..f227dd9f85ac 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1740,9 +1740,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; @@ -1786,7 +1786,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 3ae2c3f09476..253aa3f59f20 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" @@ -877,16 +878,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; } @@ -985,6 +993,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 Fri Feb 3 13:27:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127535 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD53DC636D4 for ; Fri, 3 Feb 2023 13:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232858AbjBCNbZ (ORCPT ); Fri, 3 Feb 2023 08:31:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjBCNbJ (ORCPT ); Fri, 3 Feb 2023 08:31:09 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124DB712D9 for ; Fri, 3 Feb 2023 05:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mSxhkoM353ZwIf3z0uxNi07TXMIiDoYavO1dsx9wgtNwIp/pXkMfblqf6/cO6/O6wg3/KA1hG5R13yKB3Exd40Z6/giPk/0fmvPp/JvlkjrGj8z1WEmK1DwyxyaR2yVyMcF1P0f+VDKM+4Ortv6s1jH4dXZ8NgKx/QsZ7O+qZYP5B0uHD+7XsqmoKH3rYzWt5iTzoFXV3oWT1mmSxIO+Rd2KxVT2DVkAeA+AjwNbYOTwyZfMWOGtOnSNljlDmJKV+hrKxgNHzaP6eZ1BfHDL88R9vGXHxPRpBMXbLH2TdljYF9TkToK0a9goWbBrXXoZ+b+ndlD4bfNKsfU/uAVCAA== 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=/sgXDq5fVOrRTevlXaKXK2aN1JJJUv+K1awlIOA72yk=; b=UgWyp/Y6qh2dngOXr6l3PFE4E5SsDX7YxtY3rVEldGs3F3DRw3LzhEjVXzfj18Wm3wiUJdJFHzwxj5BiRhvQMjy/GXYHJZQG7nTrWJisia4XQa6bDzBnGpSukURGpgl/cog/wohT/uDS7FciH2kF6y1/0xGrAaCdi6XX1G8q1gbutO13u1J9pman1+vrk2okBFhc7sPG+B+OR5nJMo06eIHBUwxmOBFgwtms26azVcNVHwjHL2SR0IJjl8Fy+G/aLryJEFtGPJA3CHB2EOwjH7LmUSSb9dEuN+Inz+GvdOBhhfBibNie3O/E6HtibHWAHwtDQl2uVyPDiBAuwbIwww== 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=/sgXDq5fVOrRTevlXaKXK2aN1JJJUv+K1awlIOA72yk=; b=Py1BDAGC1Wyg+vK2fgvQd0z5Gzcmx9Z2ae0GlM8BaoRvr3Q2u6GV3Btl94gmeyuwf0KqEvECVreWugyuAgxRMVseu7d15BUUJyDnel+yD0lzX1FN3/piLxyJrG8Xy6ckcD/dLDomWaQzyEUOUBhUeg3MBcUFlrcGbdTkXiHzOL4higb7yzO+N3aj02t1wVw5Mmefan3BLm5cuDuBbbxfQl8UsniYZvbNm7v21uvpeQOPPP7orYgzIKAUUHdiFtnnOK0cQRtVS/VqYaIpEAnpXLBDROuYeYh0Gld2LfaRCxX+vdUzvMZfZwzBM87/3qmP8RMQVXq5+IIodDiDLecRGw== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:29:46 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29:45 +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 Subject: [PATCH v11 22/25] net/mlx5e: NVMEoTCP, ddp setup and resync Date: Fri, 3 Feb 2023 15:27:02 +0200 Message-Id: <20230203132705.627232-23-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO2P265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::35) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: f7e9244c-27af-4e00-79e5-08db05eab72f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NtbigJfjYiy6xb6JAWauNmLnpQpWwAjqCXlB+VvlphhJdW9OB9n3e+7u+6ZFBpIIfKj7O8j69bhoYJ33BcNz2fFCdslwael1pVrllVDatXRUhBVUpkwAiA0AgqXfSEsQTdEZrCJ9QJXvuznFw/VJsYWhOoNEWf2w769vRW/WQ9RpP0LuaE91wUEPtdgAaNZ5nuyKakb7PtRbu2xEbaHalCsetQLlPoBZjKzsqm94TnTRT+Zwc6mOgNtjMn1GRYe4s/6YpgSixYp9MW60olchWBgStcz5spKk/jMX1CL8ZHyhUl6e3rbSf+Mtl+4BOjVRD0RMxOmgw/gmsu1qaRmPGBICUeU1PsyKRUK/AAX1H3p59sJjlCRcGVfsuAKJFF/YzSmu8OW6Yho11x0m/3qAVSeaGuIjUzq8G44d1I12jbrtYacd/qzWuvYKqYlBIDPrprYIf6pybz+0Pe6b8+MXySGWZjqPPEYA4WRq3c7fAiV+qxuCNFq1CBPamh7KRqN6czWeC9/T69IcqNqOhLL+RdyvJPx0JnUp1TGizMjZh3t+T5sRENV4ffXfZxatJkHiszaxc44y/9v/esDfvnFRneFWXTuJWloBdHOxvcZfonId/r0xYDBO2N6lkdPe8H3Y5UYF9T78lDtkWEEebVgh9Q== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bYMuJTyeJ8DeUc4Z41gPLxRF2B+7+EFmmYw0fvfLFned10uS9D3RauUZmj+7RDbHJCMa7MZwfOgbIDv0F4WyQCn1WSFxWSeappON1VjWTrm6dfDP0RvK/LILcu5CFF7EJsWyLP9Ql7Ziv86WhMFmLPicQCh5tOgtA6TPWGX8KGd2/Ml2pzestxFGP3TJtv9RZo4aECatunZzsmorUUenFC+s0/0rJyhwwqqD4+5VxfTFwvKb69aX8qkSKp8C/zuKpo2KWllfqBAvQsjlMBWH3JZvOhFcI0lqvoRPBLXMYV0PQ+77nf5z/liOtr/ibPh8lCa4EtStvMa9CJXp9jgZnCHCInb50bojDQfgvZAtEByqP2DAbn2LYDHTosORcATu369zbVC5MeAJaOvAz63RBYZHj0mxWkZDVOvx4IvmVwGPOzIO6xpazDzZ8ZDArY9y4vXzLWjm6R+v2AaJSR2fJtP1LDtrMPq4Z5J6xkS/0hSDqyvF3LWLa/psZSinFOb0i4NjcFBoLJDmbXOAmpIF991BF1AbFcQY84LA7ZXlMT3pWyyExI7APMQEnZBVELeC99K0qlgBLdaWiCPw+1vd8JqJAO65gVzJ92ArXCFell2ErRlOXuoubY7XKrmwCiAC+/XGpkcIf2brL3AmYC4WJEMXmYDxEABhVIOuwZZxgZ7fcD+lSdIjWpskQ+O0YNk7MS7tGuQ23gLqWX0ZlRcQ7PfjZ9Idr+qHJOkyLkkHMC6WAULDBvfUKiKynLatN3RKNy0Tmgcr1MHlJDBWXvZicP1/QfXEp0FPpgvVZbxxJi7eA0fKricXtD1lO7bdidm6Z5oy+JY0eALFFPRcx/YiodqWTVR65U6UrOu6zIgpDgSmyCALDxMtiGuEPwv5XszSGhguJlN5H1m+uPkWsRPQq1YaLnekfvQBk+CeC0XhU4YkozDeohfFUbsHjl2NuMTnnwK6NKmZ5eD60zBe+gwc4o1dlacVla6tYlNYCyy44xFlW57se/hB2Ld2aADHYFgXGCcbMRfUWJegBdCAZuYahGOmmmVH8jp1u4j4Jfuyqm9CjtEUZfUBoFuNwW7+0/8S/OlGmbL2KF17Yo+E53hD4ATdUEiA5mNQFlkjqsEdD3kEReddq0juzkLqPMowV8MmjpVC2sieejS35LMrRm24NwIHBOD34bFD7m7kpPJEzs2EDngYxce75VLhcPBWJY/X4zrXCKubcXXl54OzXXYIZZGZmlz2GtOQzFmMjUs7pTjgj/lDPsJfGFTOCSjdHxmaVRCZlinFHGP9M3Prv/vgeg70tPuJCHaqsEHJCym/VPqVztNPx78TN9Txfmo3BmI1+mUKTQWX6k7OoSYruBz0FIchDFUMT1TjkYNBPwmK58Fhz06u0vnAv7sZa4oTTonPSjSMQbrGGS3GhSXpWRkLKc4hDi/U83hGwW8Po5RHIN8tjXqfDfMhbJl02LgL2IjyPaxxfq6sNF0AfMf4byHNpYhfjk8F/95dK2xjy9bQp32TvBEufJp32mN1IE8aw7ALh72DSHwPaDOiSyiAYg+kwtQJ9VzgXdT4finwqOIlhXl0wtkr+NU8KgzqFdHTQAZx X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7e9244c-27af-4e00-79e5-08db05eab72f X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:45.8134 (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: ziA9O5PSo48ZC5Ktb/mYF5EssWbPchHbrPOLyaXKrFnEIoDYRwfeKm2NIj1b4FkNVPbVMVH/wigU2H6u4QyUpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 64e4b3d2936a..2b9d69254ead 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -682,19 +682,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; } @@ -717,6 +854,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 Fri Feb 3 13:27:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127538 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65384C636D6 for ; Fri, 3 Feb 2023 13:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232990AbjBCNbu (ORCPT ); Fri, 3 Feb 2023 08:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232931AbjBCNbb (ORCPT ); Fri, 3 Feb 2023 08:31:31 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2045.outbound.protection.outlook.com [40.107.101.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFB356ED8 for ; Fri, 3 Feb 2023 05:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/xBXKN5Svkx5jcmFzCVxUErFYH6P8SoeFCqYryBvrqSMjT7CCLfcX5UxiSQ07ogdxBrJ80Cc4iMm1dpZgn/ehxvr/SJh6a4FxBdKyV3TJhWAutMrov84LvjGMYS+hWkgnQQTpkk2Rr2OG/SLFciV8pP9QSnqBg1iqBNTZ8/3W40WYDCLr4qxya505DrNrUhA0fnGTvI161are1uZYdK53vGtvZvifOyOvISiVr4b1VftwRIROjE8SeAP3pZfKspMvIDUnKf7TZv2rF2G9IE/1YtD+5oLJqRArUmDu9aJHhgzyM3q4uiQ4cdy0eDct7cnF9qcielHK7/XQqEgxzT/w== 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=eOXFX2hzWP8WohaKXqdxrePl9t+/u1L3xWYLBL/oj24=; b=m1CSM92h9Qd/j3in9Cr4V2GWhvm3NjuDsBh/hpXYVhMzZYBqMlOwpw1C6Z7zUeaSv8oOLxbwOPrdVIIZkK/HkEPneek5xvqqMaRFxDsmkGG2j03ovadIld0bc6a5qAe3a/C6sRNqhVHCU1YJuuQyC+C/61FwBTIfDbjcIZYu1j7LmC5F1MqFic+eNqulLahSFJlcyWqkxghA9/P3KXs/at2AVW0KEMHIrzw8566lffsS6YFaZVFpQtyNyz7NZk/zX7JTxKLUNE199uy7wlsKuQpIUAtWn1z7tZ+ZA7y5txxuX/l85y8v/43aA1UaxcBrmuUVZB9W9Ee5pmT3hO0BeQ== 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=eOXFX2hzWP8WohaKXqdxrePl9t+/u1L3xWYLBL/oj24=; b=LFEshJKcV+aiWhJqv6b2txQm/hstJRVIUxDgeeaZMVvST3wcABwc4PuPxs9BM3/oXIjbR8gR+SekxEo4er53gkVlV9iyZtDfLdG13RiHEzfxm4XuJSJfeW4CB4lTGmNvfbFYVXq8xvhC0w+SLG5czHF+uDYYSf1RvQNVX9G46vtUdYMtHJDOQ2n/CwBpE5WdPLuwsJkwlGn2Su6+AK64nHWQxhTR3jkDPZ7td38YQtSHJ+X8A+za0DJ6WOtYRGtr1CYtarO4xPHqowYW+TkiB0K/ocWDm3HIqrSb6gHBTJyvGzMWcHpF1NurDwMSJEPV7BhLeygormDD6yBMZJRgmQ== 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 IA1PR12MB6577.namprd12.prod.outlook.com (2603:10b6:208:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Fri, 3 Feb 2023 13:29:51 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29: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: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 23/25] net/mlx5e: NVMEoTCP, async ddp invalidation Date: Fri, 3 Feb 2023 15:27:03 +0200 Message-Id: <20230203132705.627232-24-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: FR3P281CA0024.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::15) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|IA1PR12MB6577:EE_ X-MS-Office365-Filtering-Correlation-Id: df5babf4-85ce-4a35-9138-08db05eaba9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7HXLN6x1KxckotlmXxlpEL/nqxSE6u/Mg16G2b37ECpwPJ0ISiEAISsRZ8CwdN2z95lD9z8M0Tm5gYt3vVWASOqmlsOtgNG58PVhUjZ9+dXwdWYR5sM47Ezne37KLB/n/FEraGdoWN3b9BN6L2Bpl2yKTPrRueCbiISJ8mKo2J4qTdQcXGmOcNmOP392QdWkH+ReAB8MCCDLVLth5BRQ7jcAokzLWeoD9slBAV0Gos0XZjtsw7m69LnjqEfIEYCCAkreK3uerNT0jgxt16W5a5DKPpQzYK1kSE+73TgSwxDB7+Po/H7nj/BFGnDRZfPAiZR/JdVffLZ+HRSr3JIjiUM75CmGQYL6bZ+SgugNcjponYrcbnFr5eU0pC7wjwWqkTiVE/i+ANZjUJ9MlTSbm1C1awf1yjR/8sZmoBdFd2nIbXoNHISrcxkKiA2xH7InSH5no3lwqc2WUJkne+ebmtR0leDAi+l1j95mhu4tw82NQAnhPsvoX/kO24o+TI0bw4vHCkSpxFAkLzGgrQEBWO8LKfGjpTuewYa5+tow9vKEOWbaoFmnTZiayprEQJ3Lly7pf4kMwcDqqD/qucZHlEX1hRFR99OZ0Nhj6nf9rQO2cbX5J5zTm4vjFcBr/6Cep7InDHBFD2ReB2Vm7Y1hng== 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:(13230025)(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(451199018)(2906002)(36756003)(83380400001)(2616005)(316002)(6666004)(107886003)(6486002)(186003)(478600001)(8936002)(8676002)(66556008)(66946007)(6506007)(66476007)(6512007)(26005)(5660300002)(41300700001)(7416002)(1076003)(86362001)(4326008)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pLM82vsCgYb4OWrKV6WToZxN/pyl/A3sbwaewDsUgDgBIzRSQXPMYC0vdkM7dffLHXcDkytaTKsyLAcO1/PqvwRqP6IRHNwk91bWxMmMLCIrhqNLptmVDsvVGerGKaayIi2lT++9mXxGNgshEpB5B8N2SN+VssQZpZ6sHiPqin15QtPyzWmC5za0J0hEy6z66zy/A6m9L1hFWPynVbqHzNDMBeiIVkvshi3oZyKEp2De8DMG4GLCWmiqesgAFRq8TOKfK1sok2FVptbSVr9uCoDvOzQpY37txkgvKwerysIZEvhtJRHQ+IlAf/Im5sM15c4q8D2TjJeYyiJ++mKopdm000Ty+SJlAoB3hzlaJNdwsrL9b7Gw/KXjfHqtU0/HyPoPbVYuBFTHATWAvdGydt4rk36St62qvpV4h055pmZzmdK7l2PApKVF7wjieeC4XBlGo3OwOOfJY0ooQOJ4cb4KJEUchrjWhX4PTynhZafMT/J+KimgfK97mgJMlsbcARar4SQEXMEHAyjcp+bRlZQgQbkEh9dL1Qw37by84qLQ/LOHI7mGEeqhjLL/ABHb5YRlEC7R2RSJ+v1TvcvzhbYJx77DdDDmrKBj+aweSU40TIKzCLtWFQBL1mHXn7sHv03i1TV9vIcDfebHGRcfxXffv2UUawgSpwfmiGvm3YRLtT2W72KSDVmVTrOk/6Yzy2h4IH2c73z3Gry+fVpkFgd6EVDJgScZB81rmpKHDFnLTe7EhflQI7aictBEL9KaK+hz7sG1coQs6Z2lVPFXdTcJWws5tqHt647kKZRZNNHEv0FlN4smXXW5e/3+Kpc1IZVJ8q/6fL6tDZMkYztHlZY+k4PVYsITCVi1DQ3JSmIg2cLZIAEDRQgsdVkerQzBKZ6kLsM+lCvYA4KP0VbMOf3nKOEgYVmuDK4nz1FVDb9VWch/6rBoeWAcBm8G7c+Y+n/siRLJZrxmH1HUBvFBODygCn86hdd+rpa+PNbHgtwC3C/PUcjyEhBTyENTfBqbh8AVJR4r33xhpRcHUv/iT9KIi+KB28Akigd5K4ZV/fEqz5Ak62lHZ1gWP7Jr8o8enuEL4vXq2Yy6Qpiy//7D2VgVv9MW7mF0QhqVwcypSEp71zm6JcmZg1753E0aif+iiuWu70wyhclK3gOlBsWTLnfii224+A7XNFnG/PCR03ffCAP4lgQSMXhQ22rM51rnagD8v+Id/0OQCwSAgd3eF6XEPTAAj8rJDImcGVoMOG6d3CgxkMd+J8IJdLXCloKBZFzBYB/th/aXZPsxp3eB1DrKzYY6yAE7i/6VmtExfc1pyrRcvfEm8qplp5nUReNnyb4S2l402y5dFpL0hHcf5z/U2pvdBEjhDgZVu1n7gm2FNNmZWfqJHoKvYgkwhDQCkV2tcYAG0Dlg9duA4exA4/YnWHDSfYpuuQdnYkKMt/X9BLFxAQOdHkq9ScWfkVHnO22rendDt2KX6PxuQYktziZ81Sc0nIa+K73+H8CDZkrHU1MslWw8Bz7Fb3N4QMXX/iUbacIJE9RZWl5WGBsbj2sL/YI/6m3/MylU7A02xDlA9Ead6/h+phAaHy/Zq7sk X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: df5babf4-85ce-4a35-9138-08db05eaba9a X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:51.6734 (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: HRmwKvGP3SYBHxd02Xr4LPaOpRsCjpoPSsZt4J0qhew5oVyDDOThunngfcHEbmew0A47SE4SmyaZ8lRrjVZ4ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6577 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 31e240610e48..0bec8c535dc4 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 }; @@ -217,6 +218,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 2b9d69254ead..3fb082cfc632 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); @@ -842,12 +857,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 253aa3f59f20..71f73cd5d36e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -888,6 +888,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; @@ -993,6 +996,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 Fri Feb 3 13:27:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127530 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F5C1C636D4 for ; Fri, 3 Feb 2023 13:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232917AbjBCNar (ORCPT ); Fri, 3 Feb 2023 08:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbjBCNaa (ORCPT ); Fri, 3 Feb 2023 08:30:30 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::608]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344A6A002A for ; Fri, 3 Feb 2023 05:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SCLkfvq9o9RfzW2N3H9NBX8rbi4en1aIqgGVxHBS7WHvImV/apB7VRngbSOR09l8MW2dWt1cdJrthIO5vSeNywd5BbkL8n4xY34ooWees3ZGkhKqWU3ygQAe4ve2w8pa3v7F3SWLq1yl/R7hj9vVK61Jz8QniKoL0KLF4W68mv281acwRFz0r1PxdFU+4yPokVbak7xxXSnlksNd3oIkeqkS8UtwTg9KM6wazXaKj/L1Roagf5eTBAktGFBymMzFLDsppkiQh3D4dUWm4WoFjzApKvnkTXMggIu5dzrLfLnwglnC/64AQ43l09UZfaeRWhULo/BYxNAIMTH7i6ATwA== 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=YjxcR4c5pkldIX0nqOl2bPYOQtxAeQHdp+jUFNfXVlM=; b=eOe32X0Vvo+bJDQhk1RbtISySfm2xDwhUbtie5fsvWaz+t4vGrnJUMQ3vgm8q+GvKTLjBs+kp11Mzv8qAkE2Z4QCBjsKGVja29PtlrHPZY2wvjG0IF2qGXEHr0QLs0nDd+uE7i5wHT/xWfRbgecMpRSIxSBE0jQTTyGWpbcU345xIaW9ZJOQTJ2SjbtX5HZv/W5lsIlV5wQZaAMxNWkNCQojoI/3N2mS01mORU4myC3mC3jpWFngyf3uwVpDYFnvweLeilodQYybEAbmthUWtqX+kaU+4XaD8RIVrwzzKShoaNoJ4hUvKX9JUKL7NV/tm//haOpceVVxWyEG6U9mbA== 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=YjxcR4c5pkldIX0nqOl2bPYOQtxAeQHdp+jUFNfXVlM=; b=pNyl5+vVJfxjUTiBDEh/lQAQVGClN3F+G54VKAzbdzgxWK6x+c0dmR+uiVXdkqeoZEwvKFeqEkI997TT8yCr/KceOkzx1HiBGdFoSe3IoS460EBwGNrOXb21qPlt2n132Jr7F56JR6CYgWPlN4sXIax5/b2YN9cqrlVl80xgbxlxKZ3v51SjL/wkgrCXEMX3SoqE+stqgzTlkjbbnkFqHLFrMze4YA0ugeWcsKs+PeL3+9iJPIV6ggtNuaic2WPdLc4NrRX2zNLrFTtZiiFyKVIsqBf+lRvKN6LJnOBE461MvrNt3FcwXMY1wubH/4pFcRTJyEMYfLUmvOQwqEzrAw== 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 PH0PR12MB7929.namprd12.prod.outlook.com (2603:10b6:510:284::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:29:58 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:29: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: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 24/25] net/mlx5e: NVMEoTCP, data-path for DDP+DDGST offload Date: Fri, 3 Feb 2023 15:27:04 +0200 Message-Id: <20230203132705.627232-25-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO4P123CA0501.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::20) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH0PR12MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: be4f21eb-ca2b-4d10-cb01-08db05eabe35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7DVOp6qlsKp4IDrx8hk1P1iJco+rDmdWcsYxMSRa0UiIh4YZ4CiJ2GAA+uaP6oxvTCaDyrPcVLnL3OJuNkSstY4l1whRAqmXgrmlZA6o1mT+yiU7zQQn6JOKOgVVmC8OG3BsRa0bfKF9eba2PPfj96V7IjZgaq7yMwiVezsB/asjigb99IxbJpmWfbYUcJjz/Wp4hMx/2rY34FKKKcYTaBvWXGC9wlczsIu32ywtKaFsB217SMpPPU0SDsk/yr17ITkVKkn5MWnkjo0feykBrh+aZG4b89Hn4x0KyxbyRaaCZ0Ubv0Zv+vt6aGTPVst3t7Qf6u76GXLD7FBBdobTtMrNs+HYiaqY5BW95FDwjCdEi3hkV4PGHku8COxofOcwrHuagk1vfClMYk8mdOeNeNA4PFgedIiazC0Xwe6QhEj/I/uPzDz91iY3OnAw/OL7YygUtErt7JBGpWwflYQ2LPrqpfPvQxa0MbP0Spnuk0kT/mDhMR4mMTU4S7oetI6Z5jJvjjp/BYukDqGUqzLa9An3qrQfuRR1XC7nrnsludd7JMi9DX/wzyd4jDYG6082SJ0OVfyVEy57iV15xO5PqJ7qhhdx5AmKNFv0r37r2vDrpX3E2FXqlvxUhrUWiW0nf2tAZcX/ovIBDcpxaXVlTg== 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:(13230025)(4636009)(366004)(376002)(39860400002)(346002)(136003)(396003)(451199018)(2906002)(86362001)(41300700001)(478600001)(36756003)(30864003)(7416002)(107886003)(6512007)(6506007)(26005)(6666004)(186003)(6486002)(2616005)(8936002)(5660300002)(1076003)(38100700002)(8676002)(66946007)(66556008)(4326008)(66476007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DG7k9a8ZQx7WeIQNpsNOO3T1MWaJUlRCyb9zcWmNG427FJks2cncQupOFiW/Bdb+UXMSQ1cRhMsM12yJK1Zm+Rwn5H0f2BQjaCA8LWK5GS0x30x2YKx8feWTJo7Oqc1fpU7UvwBFRnysieLr9Y8KCqb/+NAsqcbTtRv/+bRC++wAy49QIxzOuxZDspLuIdMvgKQey9sglyIuujzfPfYNG6ziIEhVn+NSosfmNHLstohAE2Z2UwRpe3jz1Q7Hcuyv85zSVedtGAqiF7SZpyvyYVkuq6RpgeBfJGHz84n81HJZoMQRWaBeR5kgs5Jl/V0ZJnZBZZ3kawJpkUTepbZSE4vTjWUTl2ijFUV9CebHJLUOxOSYBAvM+Q7kpncFZyw9pwu7njMmxHFRoDo0rfdL+Fvv/PJu46wdh9hkq80q6H/jvDlLtWToZ419zveNHjQ++azbT+JmsfcgsTS3vec5UULdds7XtdUARXctKeiAbZmwFoePppnkf4el6RBCDWy/5EZ38VteReLscbC1tkGt2CXOnl6NM4+kML5CKVJS1QHNjYuJ8/NEpK7adQlHw5w/hJ7QaHsw7xYm3/WRAK89VaxHlqOA9oy+mL2vJntURwdeDcvHfxL1oAfVMsWLTtywAuIaxmEwR1mBRoip2+amodC/SmoH2w7fAxveEvFmVq3SdyKIofOujvoTr5TLW5xU8tG4vwjP/02h8Wb5oZFwxt3/sytBkIgJ5p5Yn0OD7HwJCSXmT0Qgny/CymYvViHBwwMXxfyzMsuhWjn0fI1TCMpIH8t6Tbt2r+asuTMtFNpLEp944hfqGwvTMvSiWWExcPGslVvnJ2+dZPLoT2BDLCumCpK38PB05xKVkeSNtXEli/388Vm/BQ3D3Th5gZJb8CTZEfwFCDzSJ9aSKwXOJkPNOBu/scuvWQhsNV9iBo4TdgrD2zmMEYdhqQs5sUvDmls7hK4aahupyOoPX7Wzv75wex5qLgk0vTRc3hT1V/+MeC6Mq0HGlj19ZxSV6+dsKypD98+SXrw1wurCAXMLg0OonjOYTPpKkK/ddKNpAspQvWigAxxcPIlLu388lRmITssmqEMliA2SE5Nu2wkFmauOhnFoq3epouEoQ+s4byoM0F0ymi2fq+xiPbZ3w4K2psBfx0Aglg6wYNsAFpKdxfV/Gdhz+Z0BNp7HhtRvMwIms+iywPHur+Qa9CbwXIO/QxIduC59AfyBvHOHYI4MnWq/aFY8bYUUNoUIxPti5A/qHxPnbODdr/aG6vaOs62WmiILRFc83BpPrMvJfBAG9OlTUtG7wptqRj3KAiwlto1Ove4+GwULm4XsYEykPsuE4P6pzDT9w+iHU/g1Id8pNURRJKSwn0pSXYF7DXVNxkFCnLtxniZlxK8KhE3Jy7I6mWctkZro836GAtKMgGyFknoNt0pcVgH18LYeceDce9PEYkQffCsQwy/i3H2Y1V3e3iOsJ7jObGuqFNSuw8TnQONndVgos9CmY7tsZxHH/a+o+6bevGq1O8LRe/LaU2M+UEvIm3ZTEtMGVHyUpRGnjuQt9mOfrXMQWHE9A3/hdLGhs4ntXURb2CqAkQwLifnY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: be4f21eb-ca2b-4d10-cb01-08db05eabe35 X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:29:57.6146 (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: yityFkEKmA5tAdNbDQ1kW5vnoMrhMFbmQYulr3nSY3Lj/v5gUojiNQQxccEXzWBghhjlcrRj4d6RMZaq0+77iQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7929 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ben Ben-Ishay This patch implements the data-path for direct data placement (DDP) and DDGST offloads. NVMEoTCP DDP constructs an SKB from each CQE, while pointing at NVME destination buffers. In turn, this enables the offload, as the NVMe-TCP layer will skip the copy when src == dst. Additionally, this patch adds support for DDGST (CRC32) offload. HW will report DDGST offload only if it has not encountered an error in the received packet. We pass this indication in skb->ulp_crc up the stack to NVMe-TCP to skip computing the DDGST if all corresponding SKBs were verified by HW. This patch also handles context resynchronization requests made by NIC HW. The resync request is passed to the NVMe-TCP layer to be handled at a later point in time. Finally, we also use the skb->ulp_ddp bit to avoid skb_condense. This is critical as every SKB that uses DDP has a hole that fits perfectly with skb_condense's policy, but filling this hole is counter-productive as the data there already resides in its destination buffer. This work has been done on pre-silicon functional simulator, and hence data-path performance numbers are not provided. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mlx5/core/en_accel/nvmeotcp_rxtx.c | 316 ++++++++++++++++++ .../mlx5/core/en_accel/nvmeotcp_rxtx.h | 37 ++ .../net/ethernet/mellanox/mlx5/core/en_rx.c | 40 ++- 4 files changed, 384 insertions(+), 11 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 9df9999047d1..9804bd086bf4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -103,7 +103,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_accel/nvmeotcp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c new file mode 100644 index 000000000000..4c7dab28ef56 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + +#include "en_accel/nvmeotcp_rxtx.h" +#include + +#define MLX5E_TC_FLOW_ID_MASK 0x00ffffff +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 mlx5e_nvmeotcp_queue *queue, + 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])); + page_ref_inc(skb_frag_page(&org_frags[frag_index])); + frag_index++; + } +} + +static void +mlx5_nvmeotcp_add_tail(struct mlx5e_nvmeotcp_queue *queue, struct sk_buff *skb, + int offset, int len) +{ + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, virt_to_page(skb->data), offset, len, + len); + page_ref_inc(virt_to_page(skb->data)); +} + +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)); + while (--nr_frags >= *frag_index) + skb_frag_unref(skb, nr_frags); + + /* remove frags from skb */ + skb_shinfo(skb)->nr_frags = 0; + skb->len -= skb->data_len; + skb->truesize -= skb->data_len; + skb->data_len = 0; +} + +static bool +mlx5e_nvmeotcp_rebuild_rx_skb_nonlinear(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; + struct net_device *netdev = rq->netdev; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_queue_entry *nqe; + skb_frag_t org_frags[MAX_SKB_FRAGS]; + struct mlx5e_nvmeotcp_queue *queue; + int org_nr_frags, frag_index; + struct mlx5e_cqe128 *cqe128; + u32 queue_id; + + queue_id = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK); + queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); + if (unlikely(!queue)) { + dev_kfree_skb_any(skb); + return false; + } + + cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); + if (cqe_is_nvmeotcp_resync(cqe)) { + nvmeotcp_update_resync(queue, cqe128); + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* If a resync occurred in the previous cqe, + * the current cqe.crcvalid bit may not be valid, + * so we will treat it as 0 + */ + if (unlikely(queue->after_resync_cqe) && cqe_is_nvmeotcp_crcvalid(cqe)) { + skb->ulp_crc = 0; + queue->after_resync_cqe = 0; + } else { + if (queue->crc_rx) + skb->ulp_crc = cqe_is_nvmeotcp_crcvalid(cqe); + } + + skb->ulp_ddp = cqe_is_nvmeotcp_zc(cqe); + if (!cqe_is_nvmeotcp_zc(cqe)) { + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* cc ddp from cqe */ + ccid = be16_to_cpu(cqe128->ccid); + ccoff = be32_to_cpu(cqe128->ccoff); + cclen = be16_to_cpu(cqe128->cclen); + hlen = be16_to_cpu(cqe128->hlen); + + /* carve a hole in the skb for DDP data */ + org_nr_frags = skb_shinfo(skb)->nr_frags; + mlx5_nvmeotcp_trim_nonlinear(skb, org_frags, &frag_index, cclen); + nqe = &queue->ccid_table[ccid]; + + /* packet starts new ccid? */ + if (queue->ccid != ccid || queue->ccid_gen != nqe->ccid_gen) { + queue->ccid = ccid; + queue->ccoff = 0; + queue->ccoff_inner = 0; + queue->ccsglidx = 0; + queue->ccid_gen = nqe->ccid_gen; + } + + /* skip inside cc until the ccoff in the cqe */ + while (queue->ccoff + queue->ccoff_inner < ccoff) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(off_t, remaining, + ccoff - (queue->ccoff + queue->ccoff_inner)); + + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + /* adjust the skb according to the cqe cc */ + while (to_copy < cclen) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(int, remaining, cclen - to_copy); + + mlx5e_nvmeotcp_add_skb_frag(netdev, skb, queue, nqe, fragsz); + to_copy += fragsz; + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + if (cqe_bcnt > hlen + cclen) { + remaining = cqe_bcnt - hlen - cclen; + mlx5_nvmeotcp_add_tail_nonlinear(queue, skb, org_frags, + org_nr_frags, + frag_index); + } + + mlx5e_nvmeotcp_put_queue(queue); + return true; +} + +static bool +mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, + struct mlx5_cqe64 *cqe, u32 cqe_bcnt) +{ + int ccoff, cclen, hlen, ccid, remaining, fragsz, to_copy = 0; + struct net_device *netdev = rq->netdev; + struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_queue_entry *nqe; + struct mlx5e_nvmeotcp_queue *queue; + struct mlx5e_cqe128 *cqe128; + u32 queue_id; + + queue_id = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK); + queue = mlx5e_nvmeotcp_get_queue(priv->nvmeotcp, queue_id); + if (unlikely(!queue)) { + dev_kfree_skb_any(skb); + return false; + } + + cqe128 = container_of(cqe, struct mlx5e_cqe128, cqe64); + if (cqe_is_nvmeotcp_resync(cqe)) { + nvmeotcp_update_resync(queue, cqe128); + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* If a resync occurred in the previous cqe, + * the current cqe.crcvalid bit may not be valid, + * so we will treat it as 0 + */ + if (unlikely(queue->after_resync_cqe) && cqe_is_nvmeotcp_crcvalid(cqe)) { + skb->ulp_crc = 0; + queue->after_resync_cqe = 0; + } else { + if (queue->crc_rx) + skb->ulp_crc = cqe_is_nvmeotcp_crcvalid(cqe); + } + + skb->ulp_ddp = cqe_is_nvmeotcp_zc(cqe); + if (!cqe_is_nvmeotcp_zc(cqe)) { + mlx5e_nvmeotcp_put_queue(queue); + return true; + } + + /* cc ddp from cqe */ + ccid = be16_to_cpu(cqe128->ccid); + ccoff = be32_to_cpu(cqe128->ccoff); + cclen = be16_to_cpu(cqe128->cclen); + hlen = be16_to_cpu(cqe128->hlen); + + /* carve a hole in the skb for DDP data */ + skb_trim(skb, hlen); + nqe = &queue->ccid_table[ccid]; + + /* packet starts new ccid? */ + if (queue->ccid != ccid || queue->ccid_gen != nqe->ccid_gen) { + queue->ccid = ccid; + queue->ccoff = 0; + queue->ccoff_inner = 0; + queue->ccsglidx = 0; + queue->ccid_gen = nqe->ccid_gen; + } + + /* skip inside cc until the ccoff in the cqe */ + while (queue->ccoff + queue->ccoff_inner < ccoff) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(off_t, remaining, + ccoff - (queue->ccoff + queue->ccoff_inner)); + + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + /* adjust the skb according to the cqe cc */ + while (to_copy < cclen) { + remaining = nqe->sgl[queue->ccsglidx].length - queue->ccoff_inner; + fragsz = min_t(int, remaining, cclen - to_copy); + + mlx5e_nvmeotcp_add_skb_frag(netdev, skb, queue, nqe, fragsz); + to_copy += fragsz; + if (fragsz == remaining) + mlx5e_nvmeotcp_advance_sgl_iter(queue); + else + queue->ccoff_inner += fragsz; + } + + if (cqe_bcnt > hlen + cclen) { + remaining = cqe_bcnt - hlen - cclen; + mlx5_nvmeotcp_add_tail(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 71f73cd5d36e..1a6786448d75 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" @@ -1481,7 +1481,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) @@ -1492,6 +1492,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); @@ -1537,6 +1544,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, @@ -1560,7 +1569,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) @@ -1569,7 +1578,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 @@ -1810,7 +1819,8 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) goto free_wqe; } - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto free_wqe; if (mlx5e_cqe_regb_chain(cqe)) if (!mlx5e_tc_update_skb(cqe, skb)) { @@ -1863,7 +1873,8 @@ static void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) goto free_wqe; } - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto free_wqe; if (rep->vlan && skb_vlan_tag_present(skb)) skb_vlan_pop(skb); @@ -1914,7 +1925,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); @@ -1959,13 +1971,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) { union mlx5e_alloc_unit *au = &wi->alloc_units[page_idx]; - u16 headlen = min_t(u16, MLX5E_RX_MAX_HEAD, cqe_bcnt); + u16 headlen = mlx5e_get_headlen_hint(cqe, cqe_bcnt); u32 frag_offset = head_offset + headlen; u32 byte_cnt = cqe_bcnt - headlen; union mlx5e_alloc_unit *head_au = au; @@ -2277,7 +2294,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(cqe, skb)) { @@ -2614,7 +2632,9 @@ static void mlx5e_trap_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe if (!skb) goto free_wqe; - mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); + if (unlikely(!mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb))) + goto free_wqe; + skb_push(skb, ETH_HLEN); dl_port = mlx5e_devlink_get_dl_port(priv); From patchwork Fri Feb 3 13:27:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Aptel X-Patchwork-Id: 13127534 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABC5C636D6 for ; Fri, 3 Feb 2023 13:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232792AbjBCNbX (ORCPT ); Fri, 3 Feb 2023 08:31:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbjBCNbI (ORCPT ); Fri, 3 Feb 2023 08:31:08 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::608]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F4255BE for ; Fri, 3 Feb 2023 05:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpeKX5RU85D71yXrNxQnHfxWsNmO0EBz/DIQecMYPG5uxrX3X4/U/bS4OQFu1R95DJSrZW+RR68MZb2y2+9N19AZPCglMDNkbxGCEhGm/A5qpI/STA4BF+Akfr+p8zTo9Z1PAagtYbX+veQr8/o6wvGEFv7p+DSnHg8Xx0EmVGj/zJmkumScFcxfDUYYNqf4TYvozVFLVSRcDggmlNAZ9EGsnSm0m6tzLDujKR9gZD+j+D/6M8uMKUh/L2aniKu/RXnXhARg5VoLYjdPct4DzQRRTwKezxwgg4CYfKPNys3GaASe9avL9xkwdKiDWtZJIvVyjdHXrUBRJnuwDfom2Q== 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=Cnh5x9bCBLaBW6IkwQgHvbk1H2B7LLi8Lq6VUgpmidY=; b=VS2IuBPtggnabpIRoB4yQxKyHiK4stfaW93UojkZ5B4g6TqXJ34rNvqLtWXTxKEbDvsRUOa9FWoDsHea5LGBSsWkFOEeqnNFxOn+zFYzS0HrDcOwHzTHTRD/O7EeeWUPJexC4ID7TCx3RVqcghjvnG4Jn7WRbUUaFudFKkPquiQee6QeQaVS1O29g18iF5PD5z3dMZp4sSjatBAvHjIYOkBqb2yCPlCjeAa3cR508J/I1PaHNt9ur+98nxr70q1R94eDc2/QGeYYw1pcAMevfjzBwHA7n4Y//RdC4J+qKIzbHf8Q9oRAtKFGxu274KyifoHgDw/DkU7NOyS4xKnYMA== 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=Cnh5x9bCBLaBW6IkwQgHvbk1H2B7LLi8Lq6VUgpmidY=; b=UBn6XpjxvkdzDvMYLK13UiooFAMBKr7HCeiCupnAOvVjWK9N0qhsJd78FruXegDaDCka5VO4u+AIEJb/K7Bpolac74nhZb9miFM8YLKDSpxLWjWkyePoOHonoU1ua3weTsvmBXAayZmyrZEZ7D2cpgXYjqNZT2f32g4AE2hCc0DtMmuBURlEraPDFkMwvF8gIpeUAQZjTsf6ObRCPhMzcURqeX8LLBMYQTxnf62tXS1mcBLRW7BO1BGztkhAr40NjCDTxnrS1h33mvfVGjfU05JHf7m2UhmWw+rViS4wjH8RiRcYI2vGvYWtBB6jzv5yeM+ZvX2vprBr2oBsEWaCDQ== 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 PH0PR12MB7929.namprd12.prod.outlook.com (2603:10b6:510:284::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:30:04 +0000 Received: from SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84]) by SJ1PR12MB6075.namprd12.prod.outlook.com ([fe80::9fd9:dadc:4d8a:2d84%4]) with mapi id 15.20.6064.027; Fri, 3 Feb 2023 13:30:04 +0000 From: Aurelien Aptel To: linux-nvme@lists.infradead.org, netdev@vger.kernel.org, sagi@grimberg.me, hch@lst.de, kbusch@kernel.org, axboe@fb.com, chaitanyak@nvidia.com, davem@davemloft.net, kuba@kernel.org Cc: Aurelien Aptel , aurelien.aptel@gmail.com, smalin@nvidia.com, malin1024@gmail.com, ogerlitz@nvidia.com, yorayz@nvidia.com, borisp@nvidia.com Subject: [PATCH v11 25/25] net/mlx5e: NVMEoTCP, statistics Date: Fri, 3 Feb 2023 15:27:05 +0200 Message-Id: <20230203132705.627232-26-aaptel@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203132705.627232-1-aaptel@nvidia.com> References: <20230203132705.627232-1-aaptel@nvidia.com> X-ClientProxiedBy: LO4P123CA0498.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::17) To SJ1PR12MB6075.namprd12.prod.outlook.com (2603:10b6:a03:45e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6075:EE_|PH0PR12MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: 47bc9671-4d8c-4099-1ca7-08db05eac20c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 05CpOPwwBw73KuNjdi+elg7AhXkrddDUaG5R35g1oVm7esMGlFYL8Coj0Ip3D3eZm10/kOHxs94B6JZceiZc4SqSiQGgXgXRnzCc31dbQWzcDGB74ejV9bqSFa5t/vc+kQYoYF3JwUYJzW9pNWjDI2jxOS6WIeaEEeojPdhPMYNsLnv0f23pUSYlz9bpjrf2KHLVGb366oi0oypsni3/C8DVGbDdB+curznyy1naQvpgqQ9Z+6r0oWueB6/GT/kRRqrWz47KGVCzRnQOQQjCckbUa2aSR7wG4MZbOu69QR+glVX0Qqji1EXQuNNULWgj1RLTcvFlDBIOvkfBsIODPxuNwSYYzKEm4h5aXefgEN8OCuhXRXhsSvkkiWpzH2rM+sg4Hia57V5VDFtDyi1Cub3t0UbWXCnCzWQJWuTyvQyOvEEybbbozG5PXUKdRhki6NFa60yS7CwWne37Y9JxkG3fyrraHBKzccWl8aHpX3aYlK1rtLladdE2zXF2fdwpvQ1nsqlayEKhQWgJZIMYKQ7Ww4xa0nndagiSRYXVwKrUpFfrRZ0ju0eVFAvm3qSKddkkFZBtPlt2hO3vdBTxzHHm3ZuWCm1kCJJjOQERF2ybwSeFDrAHtKQKDmyU4sut6dRiqF/VQIMCZ52s5CRIwg== 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:(13230025)(4636009)(366004)(376002)(39860400002)(346002)(136003)(396003)(451199018)(2906002)(86362001)(41300700001)(478600001)(36756003)(30864003)(7416002)(107886003)(6512007)(6506007)(26005)(186003)(6486002)(2616005)(8936002)(5660300002)(1076003)(38100700002)(8676002)(66946007)(66556008)(4326008)(66476007)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kj7Hr3Diev2210zTZCoUh42OW98Pf1liOPkEdydAp1f5+dmXZAdxWUDFRgq39fnoJO1e1hfJsTSsDBZN2XeOERZS6mLKsPAzUCE18b4lBfiafX7r0R03bc5+QxjkCAay85UELdn9eiXZTef+teHjH/9e+XjufVHSdLb5IIK0/d2JjbFs0Rc/i/8Lgna7YyCi2gMsgqD1lUU1tefDpUoGy4NoS9sHH+bdnHBWOkbPmcLhuglQ1DIPwvxPx6ByTk6yOn82zNzipwqYSAfvi+KBii2Ex7RCI8scNka5zpN5Gq/Eqir4QEwYEtbxfRIA3fCsjBsDfwu3WB2BRiPg0UjoRxEbxO3ZgRa1oI0Kvgk73f4pvC7XxyZHMj8WDyr0QspYUfx9sbF0z+876xJ1O9AfKT3jldsmdqluDuuEhm/vfKJIA8nfMViEw8MEMxu20xJqD0esuE0HctFrnSoNdm7HDZsldgqrA1hHepsx3RhfEYFiGoc5r3MCBEkWGm0b6aXY93QVcBHkrdHMETKJL9sLfckz5SaNtp4fpI1V8SEFHeVeX8ApZqE0YRGih9R7oTLnJJiDT4mgx7wJDcBHSiqn9PCXVxhlUxCSbWHW+Td38Ud7uEi6O+opBKrA9a6FPB0nfB4Er1vgnwHcfBwwQ1duuhQAYNYJToNR/ErIN9y4bVdLzD1cTjktC3NTHw5/hO4ayXhf5+X/PHp/pFxDrvRwmBrPgVw7p1bUZ4eFIEfIntiFAMMmL5DlOIW64lhyKp2HwCak1aiDzVAtmEIbHcp2LjxpZ/gHMMPBm3v+d5DB5niKNTQ4UgGtQXixNVyC6grPuq6xwPzgIuDohlb9BmrbFqQshQDt7jGtGZe0hFSY5douCEIvbE+XQxSykhAF7ySmqdhBQrMpjyUbfBEFHFeTWs7CjMpv1lcTUmRSGwaFkBjM6W+P8DLGcGMWH3lwsA5E0RhoCXicV1S/RlNyE8CrR7wUDqQittNKED55045kkpsEeuZ4apSZrUvjW7GNxnkz4mBOm9yyRW8Ido+0I49AYxrPzqNtemYusNX3cSzF3dBRRP6LnK5vmG8ge7tfBHWJgLsQ3LZrl8w9yn8ZhJlc0spxk9unhEl3gBhTvFMQv8osEZMFJg6L0TSGAmxsVCW2V5t79tLdd6OhiC/av+Yh+Ih1HMlYE2mbHWl08PgKa3YSLZHp6RONh0M5RCbhYe6gUcjtDK4Og7zVDv4Zbk9lOoUn4sbDaDTKlDJuMDM//7EOz/WH2zFdoDTlx1n1IytRzDY6w9kLvtWA/3QfbgGFVT7KC7WGyVCYCBOxScP7tQ+mavxNh+LhquWlO54Rrm5EkfZCM8rqTbprhUJ6OwNcy4oDtRTvsq2ELUo4oZJBgxuc53fFml7qbBPHskxIqIaniUNkqvIgybi4sp0wqGA2Z5b9IhtzSoFcIbuRBpNiBSmcve9io+sDWJ9hCWy2TH1RI2iDyhCJk2kpNdM/b15Sse1Se5xE27KOwRwXlUiKx267wMhI3Gq27iwo/fcu3Vpf18FSrPjV2gZtUFGui1HfgmFDro5MbsLxzovjfUrCAFupJiXl6ZbYkEJVpxKrqV2P X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47bc9671-4d8c-4099-1ca7-08db05eac20c X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6075.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:30:04.0522 (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: bfWkuhtWxc9GOfBLVLdZD0mwVHDqKSXZZ6fDt851ig+s6Kg24a99K3Y+Jf8xijBBigPF204hqX7aOV2g02XWiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7929 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org NVMEoTCP offload statistics include both control and data path statistic: counters for the netdev ddp ops, offloaded packets/bytes, resync and dropped packets. Expose the statistics using ulp_ddp_ops->get_stats() instead of the regular statistics flow. Signed-off-by: Ben Ben-Ishay Signed-off-by: Boris Pismenny Signed-off-by: Or Gerlitz Signed-off-by: Yoray Zack Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en_accel/nvmeotcp.c | 53 ++++++++++++--- .../mellanox/mlx5/core/en_accel/nvmeotcp.h | 16 +++++ .../mlx5/core/en_accel/nvmeotcp_rxtx.c | 11 +++- .../mlx5/core/en_accel/nvmeotcp_stats.c | 66 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en_stats.h | 7 ++ 6 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile index 9804bd086bf4..d48bde4ca8de 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -103,7 +103,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 3fb082cfc632..af8635a3d7b3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "en_accel/nvmeotcp.h" #include "en_accel/nvmeotcp_utils.h" #include "en_accel/fs_tcp.h" @@ -614,9 +615,15 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, { struct nvme_tcp_ddp_config *config = &tconfig->nvmeotcp; struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_nvmeotcp_sw_stats *sw_stats; struct mlx5_core_dev *mdev = priv->mdev; struct mlx5e_nvmeotcp_queue *queue; int queue_id, err; + u32 channel_ix; + + channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, + config->io_cpu); + sw_stats = &priv->nvmeotcp->sw_stats; if (tconfig->type != ULP_DDP_NVME) { err = -EOPNOTSUPP; @@ -643,11 +650,11 @@ mlx5e_nvmeotcp_queue_init(struct net_device *netdev, queue->id = queue_id; queue->dgst = config->dgst; queue->pda = config->cpda; - queue->channel_ix = mlx5e_get_channel_ix_from_io_cpu(&priv->channels.params, - config->io_cpu); + queue->channel_ix = channel_ix; queue->size = config->queue_size; queue->max_klms_per_wqe = MLX5E_MAX_KLM_PER_WQE(mdev); queue->priv = priv; + queue->sw_stats = sw_stats; init_completion(&queue->static_params_done); err = mlx5e_nvmeotcp_queue_rx_init(queue, config, netdev); @@ -659,6 +666,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); @@ -672,6 +680,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; } @@ -685,6 +694,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); @@ -816,25 +827,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]); @@ -846,8 +866,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) @@ -894,6 +919,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 @@ -927,6 +953,14 @@ void mlx5e_nvmeotcp_put_queue(struct mlx5e_nvmeotcp_queue *queue) } } +static int mlx5e_ulp_ddp_get_stats(struct net_device *dev, + struct ethtool_ulp_ddp_stats *stats) +{ + struct mlx5e_priv *priv = netdev_priv(dev); + + return mlx5e_nvmeotcp_get_stats(priv, stats); +} + int set_ulp_ddp_nvme_tcp(struct net_device *netdev, bool enable) { struct mlx5e_priv *priv = netdev_priv(netdev); @@ -1015,6 +1049,7 @@ const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops = { .teardown = mlx5e_nvmeotcp_ddp_teardown, .resync = mlx5e_nvmeotcp_ddp_resync, .set_caps = mlx5e_ulp_ddp_set_caps, + .get_stats = mlx5e_ulp_ddp_get_stats, }; void mlx5e_nvmeotcp_build_netdev(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h index a5cfd9e31be7..f2a7f3cc945d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp.h @@ -9,6 +9,15 @@ #include "en.h" #include "en/params.h" +struct mlx5e_nvmeotcp_sw_stats { + atomic64_t rx_nvmeotcp_sk_add; + atomic64_t rx_nvmeotcp_sk_add_fail; + atomic64_t rx_nvmeotcp_sk_del; + atomic64_t rx_nvmeotcp_ddp_setup; + atomic64_t rx_nvmeotcp_ddp_setup_fail; + atomic64_t rx_nvmeotcp_ddp_teardown; +}; + struct mlx5e_nvmeotcp_queue_entry { struct mlx5e_nvmeotcp_queue *queue; u32 sgl_length; @@ -52,6 +61,7 @@ struct mlx5e_nvmeotcp_queue_handler { * @sk: The socket used by the NVMe-TCP queue * @crc_rx: CRC Rx offload indication for this queue * @priv: mlx5e netdev priv + * @sw_stats: Global software statistics for nvmeotcp offload * @static_params_done: Async completion structure for the initial umr mapping * synchronization * @sq_lock: Spin lock for the icosq @@ -88,6 +98,7 @@ struct mlx5e_nvmeotcp_queue { u8 crc_rx:1; /* for ddp invalidate flow */ struct mlx5e_priv *priv; + struct mlx5e_nvmeotcp_sw_stats *sw_stats; /* end of data-path section */ struct completion static_params_done; @@ -97,6 +108,7 @@ struct mlx5e_nvmeotcp_queue { }; struct mlx5e_nvmeotcp { + struct mlx5e_nvmeotcp_sw_stats sw_stats; struct ida queue_ids; struct rhashtable queue_hash; bool enabled; @@ -113,6 +125,7 @@ void mlx5e_nvmeotcp_ddp_inv_done(struct mlx5e_icosq_wqe_info *wi); void mlx5e_nvmeotcp_ctx_complete(struct mlx5e_icosq_wqe_info *wi); static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv); +int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats); extern const struct ulp_ddp_dev_ops mlx5e_nvmeotcp_ops; #else @@ -122,5 +135,8 @@ static inline void mlx5e_nvmeotcp_cleanup(struct mlx5e_priv *priv) {} static inline int set_ulp_ddp_nvme_tcp(struct net_device *dev, bool en) { return -EOPNOTSUPP; } static inline void mlx5e_nvmeotcp_init_rx(struct mlx5e_priv *priv) {} static inline void mlx5e_nvmeotcp_cleanup_rx(struct mlx5e_priv *priv) {} +static inline int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, + struct ethtool_ulp_ddp_stats *stats) +{ return 0; } #endif #endif /* __MLX5E_NVMEOTCP_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_rxtx.c index 4c7dab28ef56..d703ca3f0155 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 @@ -111,6 +111,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; @@ -122,12 +123,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; } @@ -201,7 +204,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; } @@ -213,6 +217,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; @@ -222,12 +227,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; } @@ -301,6 +308,8 @@ mlx5e_nvmeotcp_rebuild_rx_skb_linear(struct mlx5e_rq *rq, struct sk_buff *skb, hlen + cclen, remaining); } + stats->nvmeotcp_packets++; + stats->nvmeotcp_bytes += cclen; mlx5e_nvmeotcp_put_queue(queue); return true; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c new file mode 100644 index 000000000000..21b0ac17f1b2 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/nvmeotcp_stats.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + +#include "en_accel/nvmeotcp.h" + +struct ethtool_counter_map { + size_t eth_offset; + size_t mlx_offset; +}; + +#define DECLARE_ULP_SW_STAT(fld) \ + { offsetof(struct ethtool_ulp_ddp_stats, fld), \ + offsetof(struct mlx5e_nvmeotcp_sw_stats, fld) } + +#define DECLARE_ULP_RQ_STAT(fld) \ + { offsetof(struct ethtool_ulp_ddp_stats, rx_ ## fld), \ + offsetof(struct mlx5e_rq_stats, fld) } + +#define READ_CTR_ATOMIC64(ptr, dsc, i) \ + atomic64_read((atomic64_t *)((char *)(ptr) + (dsc)[i].mlx_offset)) + +#define READ_CTR(ptr, desc, i) \ + (*((u64 *)((char *)(ptr) + (desc)[i].mlx_offset))) + +#define SET_ULP_STAT(ptr, desc, i, val) \ + (*(u64 *)((char *)(ptr) + (desc)[i].eth_offset) = (val)) + +/* Global counters */ +static const struct ethtool_counter_map sw_stats_desc[] = { + DECLARE_ULP_SW_STAT(rx_nvmeotcp_sk_add), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_sk_del), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_setup), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_setup_fail), + DECLARE_ULP_SW_STAT(rx_nvmeotcp_ddp_teardown), +}; + +/* Per-rx-queue counters */ +static const struct ethtool_counter_map rq_stats_desc[] = { + DECLARE_ULP_RQ_STAT(nvmeotcp_drop), + DECLARE_ULP_RQ_STAT(nvmeotcp_resync), + DECLARE_ULP_RQ_STAT(nvmeotcp_packets), + DECLARE_ULP_RQ_STAT(nvmeotcp_bytes), +}; + +int mlx5e_nvmeotcp_get_stats(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats) +{ + unsigned int i, ch, n = 0; + + if (!priv->nvmeotcp) + return 0; + + for (i = 0; i < ARRAY_SIZE(sw_stats_desc); i++, n++) + SET_ULP_STAT(stats, sw_stats_desc, i, + READ_CTR_ATOMIC64(&priv->nvmeotcp->sw_stats, sw_stats_desc, i)); + + for (i = 0; i < ARRAY_SIZE(rq_stats_desc); i++, n++) { + u64 sum = 0; + + for (ch = 0; ch < priv->stats_nch; ch++) + sum += READ_CTR(&priv->channel_stats[ch]->rq, rq_stats_desc, i); + + SET_ULP_STAT(stats, rq_stats_desc, i, sum); + } + + return n; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h index 375752d6546d..8b3d43518d05 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h @@ -128,6 +128,7 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, const struct ethtool_rmon_hist_range **ranges); void mlx5e_get_link_ext_stats(struct net_device *dev, struct ethtool_link_ext_stats *stats); +void mlx5e_stats_ulp_ddp_get(struct mlx5e_priv *priv, struct ethtool_ulp_ddp_stats *stats); /* Concrete NIC Stats */ @@ -395,6 +396,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 {