Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC6828B7E5 for ; Mon, 30 Jun 2025 14:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.81 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751292484; cv=fail; b=EYx2N4XyrcRBXUWc+7sxH6AaYkSCnSWHkGJouQCCfJCkHVJBfrxvoFt3aRgJh+tCFbhG7R0UqsmLI+py1OftL1Yk4Nhpc0/2If7ocpYvJdYOmlExzCm6rOTQ5wwWQiZdzIvP8hnBtffMDytZqVXrY3wXvstj6QxmzCTlcowkOIA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751292484; c=relaxed/simple; bh=96gYVkJqyu8iOITXQFHPtcwAq/2XewakN/1U0zoxH2Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Lkp4Px8r1TctkTbU2NVoU+7gYCYLX3xwyn6Yo9S0rzZDq6LE/z4lc+ovIGS4oV8gwmMmIapI1hpQwBJTDBxtwzUdo3WedhR55dbqp/uuQ1bqRruDjo9CkqAiFkIvbH5xU9dC2JQoTbWhn8bUk7J2d4CwsYci+ElH8X+68UkQ7zo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=rmGOc/Xi; arc=fail smtp.client-ip=40.107.92.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="rmGOc/Xi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j0gqcginDLnA65SxsGDBFNOdQ0yqiLd8oq7Bo8FopEe0nc3yCeONU0K1OWCC25nA+nBNhXjreGtjk+qqWVd69ZNUqTG4okz9t1rdUvyl6x1CWx97i5O3dJZC6DQQv8cC+mGjFJuvzSAt4Ftj8oLqn1znA/BljmUlxRaTSvlJ7mA+GqBjgWbzgmPo8Cnn3ppIxY64bLpkM778Iuex3FN0lHSL7lnWmD9YdHpR3FEflmSYbQCtghwGcjcbQHORvTJETKmp2dM789rDGZgPnmwkUtGgZYf93CDc+iOHLZogJheQ7WTTL89jAnhn9DpHu8GZvfdbqzRZxQN7EtxayFxmtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5zC3EB6AA1fiX3HeLeU1Jcs32JmQMfUqPfMsqrbOC/U=; b=yoT4OnYmTzSENLLfug8b2fPsMnCfNhvICXlzSpoDtAcTUxtxlee5YhRc0zTICV9za9Y1YyhtzWgNZy7DDpvkEpZ4smVMQy2QPxn7cNFs1Xlfsaf5uHN5RBGRcgZyjoq+zC9Uy6JtmEpwtTyZO41d693sVxf43nowh6ZMPL/+IZTo/MXQJquOwJcjlOQfu6rkKkYXPJ3CtTC+T7miH/rrOa6YBJt1zRi/RHZ6nVlmeYNanQIHEKGZ9cOGJ3BGBgVtsXnpMWPo7TN6dst1BNOh/MYSLeQwbbmLrZPBl8GVsQaNx4LtZP5uxfoDBzpoIiHGLsnDtS+lorFy3T8HJlJUyw== 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=5zC3EB6AA1fiX3HeLeU1Jcs32JmQMfUqPfMsqrbOC/U=; b=rmGOc/XivDhBflS1kNBJVovNee2kzNscA/hIKfs1etH2q5O9FDfN4K6184YMGxl8Bfo6BTZ41l4lvJhyEm83D3FbEvO2clvV369caSQ3ZMBlE+hqDaecfpE0jA+LQYPkxPD1ItIXqiqx0ynhVCc7x18IT2wfZPAi+Ir/S6xq8hyAUPcjRWTCRXzRB9Wijxn9fahhhJLNKGxsgZ/eg0cQrJ/pl+8rpyM/wpQhZfAsmRpx4OX8rpS24I01JJiykjaV0FCTGD3yKjwDTFM9KyKx/AlF2pQLSdh9Xjw/2wcSfN41FxccO6mK9Q8hrgZI7mHNxIB2exTAxDmiwlO1grJ1Sw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ2PR12MB8943.namprd12.prod.outlook.com (2603:10b6:a03:547::17) by IA1PR12MB6090.namprd12.prod.outlook.com (2603:10b6:208:3ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.31; Mon, 30 Jun 2025 14:07:55 +0000 Received: from SJ2PR12MB8943.namprd12.prod.outlook.com ([fe80::7577:f32f:798c:87cc]) by SJ2PR12MB8943.namprd12.prod.outlook.com ([fe80::7577:f32f:798c:87cc%4]) with mapi id 15.20.8880.026; Mon, 30 Jun 2025 14:07: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, galshalom@nvidia.com, mgurtovoy@nvidia.com, tariqt@nvidia.com, gus@collabora.com, edumazet@google.com, pabeni@redhat.com Subject: [PATCH v29 02/20] netlink: add new family to manage ULP_DDP enablement and stats Date: Mon, 30 Jun 2025 14:07:19 +0000 Message-Id: <20250630140737.28662-3-aaptel@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250630140737.28662-1-aaptel@nvidia.com> References: <20250630140737.28662-1-aaptel@nvidia.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TLZP290CA0008.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:9::20) To SJ2PR12MB8943.namprd12.prod.outlook.com (2603:10b6:a03:547::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR12MB8943:EE_|IA1PR12MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: af613eb6-d31c-4891-b50b-08ddb7df825c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LfBfFt/eHKGmuYzjb1V3/+JCACzenoWXzPCZdAvEbiMCXSNhXHD87OuxNOHE?= =?us-ascii?Q?7KOHqnoFvBvxlr4uBOHwwHZ2zP/9eusATUWdGHACzi1ZeowecR6mgwlTvClG?= =?us-ascii?Q?NR4/XvBxuNjGzUgXU0skgN8fS2Al5kAjn/O0PaJ1Ee6weGCfhV5rUgcoY3KF?= =?us-ascii?Q?Nf+nP48tfx5Ni3SqQICzeyU4uEsAH8TQLtCL/BVZC9k1ondXDwHJibmxEVqx?= =?us-ascii?Q?eX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HXyyjwXAcsv3Q?= =?us-ascii?Q?BQYC2qE3ef7lk6WxGvIsOhqOzqRKYn5CkzcjKM/ku4OwPZDA7FA9eHdGF3w2?= =?us-ascii?Q?7igou2rkkpB0r9KIQOf8dcedZcng9NmNm8gsCSeEl+cPmSw3qHyWcdrsyMNT?= =?us-ascii?Q?E6H3W86Uq5o3EXEZrfcQ8d5M/TpOVyu6PYfoYkBY1sDQcnUTkyVH8oVBbsQD?= =?us-ascii?Q?vG0JC9b0DptcK6H2UBNV80g4+bpBWlbomELZVgAwXzV7ji9lUQoLhJfDmfEz?= =?us-ascii?Q?XwKRvNWvTbSGfDUjE72OMcmcn8thD9cqrzPSLsbN/LjLwdn+8w=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR12MB8943.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Dp1LnIZGVPt2CsbplyXbT1OhXKMUhHtk5wISPLId234JL0Ubdpzfibr60eNp?= =?us-ascii?Q?fPZODpugq9GQbqI/BXUU4VhlYj6UJ1+gquRgXCiyoJeLehIFhU45dx7BjRxu?= =?us-ascii?Q?ZPdSMYimCe/JF6zm8UXhH809KJCfqMiT4B0WTFrRcFKpDsk/gYSmtmvaFp95?= =?us-ascii?Q?5IZVZ/g47FJmv1YvGccGa91Yl/qlrViDxQkNp3rC5motmr8laJbpeLpozR3O?= =?us-ascii?Q?7ecJnsGOVDZxuOIdUQASz5+Qn8nIp7aGm/AWalt6KvgxtbzP2vYf2Jg1HsoE?= =?us-ascii?Q?ZTI+VdCyqViaT0TtD9q6gsj1bUh9HShWMeKSsq27q/U5LI1MQe5/H++Yi4Bm?= =?us-ascii?Q?SYz5WxMLPFpw9C2fHx1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ascii?Q?ybwVPgMEzxbzzb2vb5kLvux0iwC4gJ6itNhkvvm13NXnY7bVkRD2ndzWO7v4?= =?us-ascii?Q?4LkjTs0grNX/KrjnzR0hqbJzo0cfgM3PvYHhiB4173liVbQgrp3+sH0i7Cii?= =?us-ascii?Q?ba4wijmfG/H7PYFkyol2uUEpOdwITh9ETaUagTh4ycQmUL2FqREO0XIPg4p4?= =?us-ascii?Q?2WQd+jWg5b1CiW06X0pPai9j/4oYVH0iQs+g8Yvi9sd2RuZW1qbHm9LRryQM?= =?us-ascii?Q?H+76/yBB1P0OWNvaEc6BO0zViKLiTKyjWVlqeKPga/zL42IVAzcH8Mm8oVOu?= =?us-ascii?Q?KDCp1jBMyuuYxhh8ogqalCDyGZOUdWR43Zkbzc0/?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: af613eb6-d31c-4891-b50b-08ddb7df825c X-MS-Exchange-CrossTenant-AuthSource: SJ2PR12MB8943.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2025 14:07:55.3204 (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: q6/Uy47PCEsdZJ+J1Bn4oNm3cWRdsNTusDzlnNbTYIC4QF6Xp5Hp2YjsUngicv2ZV4d5woDnAgkvULctLUw2cQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6090 Add a new netlink family to get/set ULP DDP capabilities on a network device and to retrieve statistics. The messages use the genetlink infrastructure and are specified in a YAML file which was used to generate some of the files in this commit: ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --header \ -o net/core/ulp_ddp_gen_nl.h ./tools/net/ynl/ynl-gen-c.py --mode kernel \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --source \ -o net/core/ulp_ddp_gen_nl.c ./tools/net/ynl/ynl-gen-c.py --mode uapi \ --spec ./Documentation/netlink/specs/ulp_ddp.yaml --header \ > include/uapi/linux/ulp_ddp.h Signed-off-by: Shai Malin Signed-off-by: Aurelien Aptel Reviewed-by: Jiri Pirko --- Documentation/netlink/specs/ulp_ddp.yaml | 172 +++++++++++ include/net/ulp_ddp.h | 3 +- include/uapi/linux/ulp_ddp.h | 61 ++++ net/core/Makefile | 2 +- net/core/ulp_ddp_gen_nl.c | 75 +++++ net/core/ulp_ddp_gen_nl.h | 30 ++ net/core/ulp_ddp_nl.c | 348 +++++++++++++++++++++++ 7 files changed, 689 insertions(+), 2 deletions(-) create mode 100644 Documentation/netlink/specs/ulp_ddp.yaml create mode 100644 include/uapi/linux/ulp_ddp.h create mode 100644 net/core/ulp_ddp_gen_nl.c create mode 100644 net/core/ulp_ddp_gen_nl.h create mode 100644 net/core/ulp_ddp_nl.c diff --git a/Documentation/netlink/specs/ulp_ddp.yaml b/Documentation/netlink/specs/ulp_ddp.yaml new file mode 100644 index 000000000000..27a0b905ec28 --- /dev/null +++ b/Documentation/netlink/specs/ulp_ddp.yaml @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +# +# Author: Aurelien Aptel +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# + +name: ulp_ddp + +protocol: genetlink + +doc: Netlink protocol to manage ULP DPP on network devices. + +definitions: + - + type: enum + name: cap + render-max: true + entries: + - nvme-tcp + - nvme-tcp-ddgst-rx + +attribute-sets: + - + name: stats + attributes: + - + name: ifindex + doc: Interface index of the net device. + type: u32 + - + name: rx-nvme-tcp-sk-add + doc: Sockets successfully configured for NVMeTCP offloading. + type: uint + - + name: rx-nvme-tcp-sk-add-fail + doc: Sockets failed to be configured for NVMeTCP offloading. + type: uint + - + name: rx-nvme-tcp-sk-del + doc: Sockets with NVMeTCP offloading configuration removed. + type: uint + - + name: rx-nvme-tcp-setup + doc: NVMe-TCP IOs successfully configured for Rx Direct Data Placement. + type: uint + - + name: rx-nvme-tcp-setup-fail + doc: NVMe-TCP IOs failed to be configured for Rx Direct Data Placement. + type: uint + - + name: rx-nvme-tcp-teardown + doc: NVMe-TCP IOs with Rx Direct Data Placement configuration removed. + type: uint + - + name: rx-nvme-tcp-drop + doc: Packets failed the NVMeTCP offload validation. + type: uint + - + name: rx-nvme-tcp-resync + doc: > + NVMe-TCP resync operations were processed due to Rx TCP packets + re-ordering. + type: uint + - + name: rx-nvme-tcp-packets + doc: TCP packets successfully processed by the NVMeTCP offload. + type: uint + - + name: rx-nvme-tcp-bytes + doc: Bytes were successfully processed by the NVMeTCP offload. + type: uint + - + name: caps + attributes: + - + name: ifindex + doc: Interface index of the net device. + type: u32 + - + name: hw + doc: Bitmask of the capabilities supported by the device. + type: uint + enum: cap + enum-as-flags: true + - + name: active + doc: Bitmask of the capabilities currently enabled on the device. + type: uint + enum: cap + enum-as-flags: true + - + name: wanted + doc: > + New active bit values of the capabilities we want to set on the + device. + type: uint + enum: cap + enum-as-flags: true + - + name: wanted_mask + doc: Bitmask of the meaningful bits in the wanted field. + type: uint + enum: cap + enum-as-flags: true + +operations: + list: + - + name: caps-get + doc: Get ULP DDP capabilities. + attribute-set: caps + do: + request: + attributes: + - ifindex + reply: + attributes: + - ifindex + - hw + - active + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + - + name: stats-get + doc: Get ULP DDP stats. + attribute-set: stats + do: + request: + attributes: + - ifindex + reply: + attributes: + - ifindex + - rx-nvme-tcp-sk-add + - rx-nvme-tcp-sk-add-fail + - rx-nvme-tcp-sk-del + - rx-nvme-tcp-setup + - rx-nvme-tcp-setup-fail + - rx-nvme-tcp-teardown + - rx-nvme-tcp-drop + - rx-nvme-tcp-resync + - rx-nvme-tcp-packets + - rx-nvme-tcp-bytes + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + - + name: caps-set + doc: Set ULP DDP capabilities. + attribute-set: caps + do: + request: + attributes: + - ifindex + - wanted + - wanted_mask + reply: + attributes: + - ifindex + - hw + - active + pre: ulp_ddp_get_netdev + post: ulp_ddp_put_netdev + - + name: caps-set-ntf + doc: Notification for change in ULP DDP capabilities. + notify: caps-get + +mcast-groups: + list: + - + name: mgmt diff --git a/include/net/ulp_ddp.h b/include/net/ulp_ddp.h index 7b32bb9e2a08..2e54d19c22f6 100644 --- a/include/net/ulp_ddp.h +++ b/include/net/ulp_ddp.h @@ -10,6 +10,7 @@ #include #include #include +#include enum ulp_ddp_type { ULP_DDP_NVME = 1, @@ -126,7 +127,7 @@ struct ulp_ddp_stats { */ }; -#define ULP_DDP_CAP_COUNT 1 +#define ULP_DDP_CAP_COUNT (ULP_DDP_CAP_MAX + 1) struct ulp_ddp_dev_caps { DECLARE_BITMAP(active, ULP_DDP_CAP_COUNT); diff --git a/include/uapi/linux/ulp_ddp.h b/include/uapi/linux/ulp_ddp.h new file mode 100644 index 000000000000..dbf6399d3aef --- /dev/null +++ b/include/uapi/linux/ulp_ddp.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_ULP_DDP_H +#define _UAPI_LINUX_ULP_DDP_H + +#define ULP_DDP_FAMILY_NAME "ulp_ddp" +#define ULP_DDP_FAMILY_VERSION 1 + +enum ulp_ddp_cap { + ULP_DDP_CAP_NVME_TCP, + ULP_DDP_CAP_NVME_TCP_DDGST_RX, + + /* private: */ + __ULP_DDP_CAP_MAX, + ULP_DDP_CAP_MAX = (__ULP_DDP_CAP_MAX - 1) +}; + +enum { + ULP_DDP_A_STATS_IFINDEX = 1, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD_FAIL, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_DEL, + ULP_DDP_A_STATS_RX_NVME_TCP_SETUP, + ULP_DDP_A_STATS_RX_NVME_TCP_SETUP_FAIL, + ULP_DDP_A_STATS_RX_NVME_TCP_TEARDOWN, + ULP_DDP_A_STATS_RX_NVME_TCP_DROP, + ULP_DDP_A_STATS_RX_NVME_TCP_RESYNC, + ULP_DDP_A_STATS_RX_NVME_TCP_PACKETS, + ULP_DDP_A_STATS_RX_NVME_TCP_BYTES, + + __ULP_DDP_A_STATS_MAX, + ULP_DDP_A_STATS_MAX = (__ULP_DDP_A_STATS_MAX - 1) +}; + +enum { + ULP_DDP_A_CAPS_IFINDEX = 1, + ULP_DDP_A_CAPS_HW, + ULP_DDP_A_CAPS_ACTIVE, + ULP_DDP_A_CAPS_WANTED, + ULP_DDP_A_CAPS_WANTED_MASK, + + __ULP_DDP_A_CAPS_MAX, + ULP_DDP_A_CAPS_MAX = (__ULP_DDP_A_CAPS_MAX - 1) +}; + +enum { + ULP_DDP_CMD_CAPS_GET = 1, + ULP_DDP_CMD_STATS_GET, + ULP_DDP_CMD_CAPS_SET, + ULP_DDP_CMD_CAPS_SET_NTF, + + __ULP_DDP_CMD_MAX, + ULP_DDP_CMD_MAX = (__ULP_DDP_CMD_MAX - 1) +}; + +#define ULP_DDP_MCGRP_MGMT "mgmt" + +#endif /* _UAPI_LINUX_ULP_DDP_H */ diff --git a/net/core/Makefile b/net/core/Makefile index 6d817870d7c3..128133dd2a4d 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -20,7 +20,7 @@ obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o obj-y += net-sysfs.o obj-y += hotdata.o obj-y += netdev_rx_queue.o -obj-$(CONFIG_ULP_DDP) += ulp_ddp.o +obj-$(CONFIG_ULP_DDP) += ulp_ddp.o ulp_ddp_nl.o ulp_ddp_gen_nl.o obj-$(CONFIG_PAGE_POOL) += page_pool.o page_pool_user.o obj-$(CONFIG_PROC_FS) += net-procfs.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o diff --git a/net/core/ulp_ddp_gen_nl.c b/net/core/ulp_ddp_gen_nl.c new file mode 100644 index 000000000000..5675193ad8ca --- /dev/null +++ b/net/core/ulp_ddp_gen_nl.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "ulp_ddp_gen_nl.h" + +#include + +/* ULP_DDP_CMD_CAPS_GET - do */ +static const struct nla_policy ulp_ddp_caps_get_nl_policy[ULP_DDP_A_CAPS_IFINDEX + 1] = { + [ULP_DDP_A_CAPS_IFINDEX] = { .type = NLA_U32, }, +}; + +/* ULP_DDP_CMD_STATS_GET - do */ +static const struct nla_policy ulp_ddp_stats_get_nl_policy[ULP_DDP_A_STATS_IFINDEX + 1] = { + [ULP_DDP_A_STATS_IFINDEX] = { .type = NLA_U32, }, +}; + +/* ULP_DDP_CMD_CAPS_SET - do */ +static const struct nla_policy ulp_ddp_caps_set_nl_policy[ULP_DDP_A_CAPS_WANTED_MASK + 1] = { + [ULP_DDP_A_CAPS_IFINDEX] = { .type = NLA_U32, }, + [ULP_DDP_A_CAPS_WANTED] = NLA_POLICY_MASK(NLA_UINT, 0x3), + [ULP_DDP_A_CAPS_WANTED_MASK] = NLA_POLICY_MASK(NLA_UINT, 0x3), +}; + +/* Ops table for ulp_ddp */ +static const struct genl_split_ops ulp_ddp_nl_ops[] = { + { + .cmd = ULP_DDP_CMD_CAPS_GET, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_caps_get_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_caps_get_nl_policy, + .maxattr = ULP_DDP_A_CAPS_IFINDEX, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = ULP_DDP_CMD_STATS_GET, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_stats_get_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_stats_get_nl_policy, + .maxattr = ULP_DDP_A_STATS_IFINDEX, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = ULP_DDP_CMD_CAPS_SET, + .pre_doit = ulp_ddp_get_netdev, + .doit = ulp_ddp_nl_caps_set_doit, + .post_doit = ulp_ddp_put_netdev, + .policy = ulp_ddp_caps_set_nl_policy, + .maxattr = ULP_DDP_A_CAPS_WANTED_MASK, + .flags = GENL_CMD_CAP_DO, + }, +}; + +static const struct genl_multicast_group ulp_ddp_nl_mcgrps[] = { + [ULP_DDP_NLGRP_MGMT] = { "mgmt", }, +}; + +struct genl_family ulp_ddp_nl_family __ro_after_init = { + .name = ULP_DDP_FAMILY_NAME, + .version = ULP_DDP_FAMILY_VERSION, + .netnsok = true, + .parallel_ops = true, + .module = THIS_MODULE, + .split_ops = ulp_ddp_nl_ops, + .n_split_ops = ARRAY_SIZE(ulp_ddp_nl_ops), + .mcgrps = ulp_ddp_nl_mcgrps, + .n_mcgrps = ARRAY_SIZE(ulp_ddp_nl_mcgrps), +}; diff --git a/net/core/ulp_ddp_gen_nl.h b/net/core/ulp_ddp_gen_nl.h new file mode 100644 index 000000000000..368433cfa867 --- /dev/null +++ b/net/core/ulp_ddp_gen_nl.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_ULP_DDP_GEN_H +#define _LINUX_ULP_DDP_GEN_H + +#include +#include + +#include + +int ulp_ddp_get_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); +void +ulp_ddp_put_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); + +int ulp_ddp_nl_caps_get_doit(struct sk_buff *skb, struct genl_info *info); +int ulp_ddp_nl_stats_get_doit(struct sk_buff *skb, struct genl_info *info); +int ulp_ddp_nl_caps_set_doit(struct sk_buff *skb, struct genl_info *info); + +enum { + ULP_DDP_NLGRP_MGMT, +}; + +extern struct genl_family ulp_ddp_nl_family; + +#endif /* _LINUX_ULP_DDP_GEN_H */ diff --git a/net/core/ulp_ddp_nl.c b/net/core/ulp_ddp_nl.c new file mode 100644 index 000000000000..aaf498453d68 --- /dev/null +++ b/net/core/ulp_ddp_nl.c @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ulp_ddp_nl.c + * Author: Aurelien Aptel + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ +#include +#include "ulp_ddp_gen_nl.h" + +#define ULP_DDP_STATS_CNT (sizeof(struct ulp_ddp_stats) / sizeof(u64)) + +struct ulp_ddp_reply_context { + struct net_device *dev; + netdevice_tracker tracker; + struct ulp_ddp_dev_caps caps; + struct ulp_ddp_stats stats; +}; + +static size_t ulp_ddp_reply_size(int cmd) +{ + size_t len = 0; + + BUILD_BUG_ON(ULP_DDP_CAP_COUNT > 64); + + /* ifindex */ + len += nla_total_size(sizeof(u32)); + + switch (cmd) { + case ULP_DDP_CMD_CAPS_GET: + case ULP_DDP_CMD_CAPS_SET: + case ULP_DDP_CMD_CAPS_SET_NTF: + /* hw */ + len += nla_total_size_64bit(sizeof(u64)); + + /* active */ + len += nla_total_size_64bit(sizeof(u64)); + break; + case ULP_DDP_CMD_STATS_GET: + /* stats */ + len += nla_total_size_64bit(sizeof(u64)) * ULP_DDP_STATS_CNT; + break; + } + + return len; +} + +/* pre_doit */ +int ulp_ddp_get_netdev(const struct genl_split_ops *ops, + struct sk_buff *skb, struct genl_info *info) +{ + struct ulp_ddp_reply_context *ctx; + u32 ifindex; + + if (GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_CAPS_IFINDEX)) + return -EINVAL; + + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ifindex = nla_get_u32(info->attrs[ULP_DDP_A_CAPS_IFINDEX]); + ctx->dev = netdev_get_by_index(genl_info_net(info), + ifindex, + &ctx->tracker, + GFP_KERNEL); + if (!ctx->dev) { + kfree(ctx); + NL_SET_ERR_MSG_ATTR(info->extack, + info->attrs[ULP_DDP_A_CAPS_IFINDEX], + "Network interface does not exist"); + return -ENODEV; + } + + if (!ctx->dev->netdev_ops->ulp_ddp_ops) { + netdev_put(ctx->dev, &ctx->tracker); + kfree(ctx); + NL_SET_ERR_MSG_ATTR(info->extack, + info->attrs[ULP_DDP_A_CAPS_IFINDEX], + "Network interface does not support ULP DDP"); + return -EOPNOTSUPP; + } + + info->user_ptr[0] = ctx; + return 0; +} + +/* post_doit */ +void ulp_ddp_put_netdev(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info) +{ + struct ulp_ddp_reply_context *ctx = info->user_ptr[0]; + + netdev_put(ctx->dev, &ctx->tracker); + kfree(ctx); +} + +static int ulp_ddp_prepare_context(struct ulp_ddp_reply_context *ctx, int cmd) +{ + const struct ulp_ddp_dev_ops *ops = ctx->dev->netdev_ops->ulp_ddp_ops; + + switch (cmd) { + case ULP_DDP_CMD_CAPS_GET: + case ULP_DDP_CMD_CAPS_SET: + case ULP_DDP_CMD_CAPS_SET_NTF: + ops->get_caps(ctx->dev, &ctx->caps); + break; + case ULP_DDP_CMD_STATS_GET: + ops->get_stats(ctx->dev, &ctx->stats); + break; + } + + return 0; +} + +static int ulp_ddp_write_reply(struct sk_buff *rsp, + struct ulp_ddp_reply_context *ctx, + int cmd, + const struct genl_info *info) +{ + void *hdr; + + hdr = genlmsg_iput(rsp, info); + if (!hdr) + return -EMSGSIZE; + + switch (cmd) { + case ULP_DDP_CMD_CAPS_GET: + case ULP_DDP_CMD_CAPS_SET: + case ULP_DDP_CMD_CAPS_SET_NTF: + if (nla_put_u32(rsp, ULP_DDP_A_CAPS_IFINDEX, + ctx->dev->ifindex) || + nla_put_uint(rsp, ULP_DDP_A_CAPS_HW, ctx->caps.hw[0]) || + nla_put_uint(rsp, ULP_DDP_A_CAPS_ACTIVE, + ctx->caps.active[0])) + goto err_cancel_msg; + break; + case ULP_DDP_CMD_STATS_GET: + if (nla_put_u32(rsp, ULP_DDP_A_STATS_IFINDEX, + ctx->dev->ifindex) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD, + ctx->stats.rx_nvmeotcp_sk_add) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD_FAIL, + ctx->stats.rx_nvmeotcp_sk_add_fail) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_SK_DEL, + ctx->stats.rx_nvmeotcp_sk_del) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_SETUP, + ctx->stats.rx_nvmeotcp_ddp_setup) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_SETUP_FAIL, + ctx->stats.rx_nvmeotcp_ddp_setup_fail) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_TEARDOWN, + ctx->stats.rx_nvmeotcp_ddp_teardown) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_DROP, + ctx->stats.rx_nvmeotcp_drop) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_RESYNC, + ctx->stats.rx_nvmeotcp_resync) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_PACKETS, + ctx->stats.rx_nvmeotcp_packets) || + nla_put_uint(rsp, + ULP_DDP_A_STATS_RX_NVME_TCP_BYTES, + ctx->stats.rx_nvmeotcp_bytes)) + goto err_cancel_msg; + } + genlmsg_end(rsp, hdr); + + return 0; + +err_cancel_msg: + genlmsg_cancel(rsp, hdr); + + return -EMSGSIZE; +} + +int ulp_ddp_nl_caps_get_doit(struct sk_buff *req, struct genl_info *info) +{ + struct ulp_ddp_reply_context *ctx = info->user_ptr[0]; + struct sk_buff *rsp; + int ret = 0; + + ret = ulp_ddp_prepare_context(ctx, ULP_DDP_CMD_CAPS_GET); + if (ret) + return ret; + + rsp = genlmsg_new(ulp_ddp_reply_size(ULP_DDP_CMD_CAPS_GET), GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + ret = ulp_ddp_write_reply(rsp, ctx, ULP_DDP_CMD_CAPS_GET, info); + if (ret) + goto err_rsp; + + return genlmsg_reply(rsp, info); + +err_rsp: + nlmsg_free(rsp); + return ret; +} + +static void ulp_ddp_nl_notify_dev(struct ulp_ddp_reply_context *ctx) +{ + struct genl_info info; + struct sk_buff *ntf; + int ret; + + if (!genl_has_listeners(&ulp_ddp_nl_family, dev_net(ctx->dev), + ULP_DDP_NLGRP_MGMT)) + return; + + genl_info_init_ntf(&info, &ulp_ddp_nl_family, ULP_DDP_CMD_CAPS_SET_NTF); + ntf = genlmsg_new(ulp_ddp_reply_size(ULP_DDP_CMD_CAPS_SET_NTF), + GFP_KERNEL); + if (!ntf) + return; + + ret = ulp_ddp_write_reply(ntf, ctx, ULP_DDP_CMD_CAPS_SET_NTF, &info); + if (ret) { + nlmsg_free(ntf); + return; + } + + genlmsg_multicast_netns(&ulp_ddp_nl_family, dev_net(ctx->dev), ntf, + 0, ULP_DDP_NLGRP_MGMT, GFP_KERNEL); +} + +static int ulp_ddp_apply_bits(struct ulp_ddp_reply_context *ctx, + unsigned long *req_wanted, + unsigned long *req_mask, + struct genl_info *info, + bool *notify) +{ + DECLARE_BITMAP(old_active, ULP_DDP_CAP_COUNT); + DECLARE_BITMAP(new_active, ULP_DDP_CAP_COUNT); + const struct ulp_ddp_dev_ops *ops; + struct ulp_ddp_dev_caps caps; + int ret; + + ops = ctx->dev->netdev_ops->ulp_ddp_ops; + ops->get_caps(ctx->dev, &caps); + + /* new_active = (old_active & ~req_mask) | (wanted & req_mask) + * new_active &= caps_hw + */ + bitmap_copy(old_active, caps.active, ULP_DDP_CAP_COUNT); + bitmap_and(req_wanted, req_wanted, req_mask, ULP_DDP_CAP_COUNT); + bitmap_andnot(new_active, old_active, req_mask, ULP_DDP_CAP_COUNT); + bitmap_or(new_active, new_active, req_wanted, ULP_DDP_CAP_COUNT); + bitmap_and(new_active, new_active, caps.hw, ULP_DDP_CAP_COUNT); + if (!bitmap_equal(old_active, new_active, ULP_DDP_CAP_COUNT)) { + ret = ops->set_caps(ctx->dev, new_active, info->extack); + if (ret) + return ret; + ops->get_caps(ctx->dev, &caps); + bitmap_copy(new_active, caps.active, ULP_DDP_CAP_COUNT); + } + + /* notify if capabilities were changed */ + *notify = !bitmap_equal(old_active, new_active, ULP_DDP_CAP_COUNT); + + return 0; +} + +int ulp_ddp_nl_caps_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct ulp_ddp_reply_context *ctx = info->user_ptr[0]; + unsigned long wanted, wanted_mask; + struct sk_buff *rsp; + bool notify = false; + int ret; + + if (GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_CAPS_WANTED) || + GENL_REQ_ATTR_CHECK(info, ULP_DDP_A_CAPS_WANTED_MASK)) + return -EINVAL; + + rsp = genlmsg_new(ulp_ddp_reply_size(ULP_DDP_CMD_CAPS_SET), GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + wanted = nla_get_uint(info->attrs[ULP_DDP_A_CAPS_WANTED]); + wanted_mask = nla_get_uint(info->attrs[ULP_DDP_A_CAPS_WANTED_MASK]); + + rtnl_lock(); + netdev_lock(ctx->dev); + ret = ulp_ddp_apply_bits(ctx, &wanted, &wanted_mask, info, ¬ify); + netdev_unlock(ctx->dev); + rtnl_unlock(); + if (ret) + goto err_rsp; + + ret = ulp_ddp_prepare_context(ctx, ULP_DDP_CMD_CAPS_SET); + if (ret) + goto err_rsp; + + ret = ulp_ddp_write_reply(rsp, ctx, ULP_DDP_CMD_CAPS_SET, info); + if (ret) + goto err_rsp; + + ret = genlmsg_reply(rsp, info); + if (notify) + ulp_ddp_nl_notify_dev(ctx); + + return ret; + +err_rsp: + nlmsg_free(rsp); + + return ret; +} + +int ulp_ddp_nl_stats_get_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct ulp_ddp_reply_context *ctx = info->user_ptr[0]; + struct sk_buff *rsp; + int ret = 0; + + ret = ulp_ddp_prepare_context(ctx, ULP_DDP_CMD_STATS_GET); + if (ret) + return ret; + + rsp = genlmsg_new(ulp_ddp_reply_size(ULP_DDP_CMD_STATS_GET), + GFP_KERNEL); + if (!rsp) + return -EMSGSIZE; + + ret = ulp_ddp_write_reply(rsp, ctx, ULP_DDP_CMD_STATS_GET, info); + if (ret) + goto err_rsp; + + return genlmsg_reply(rsp, info); + +err_rsp: + nlmsg_free(rsp); + return ret; +} + +static int __init ulp_ddp_init(void) +{ + return genl_register_family(&ulp_ddp_nl_family); +} + +subsys_initcall(ulp_ddp_init); -- 2.34.1