From patchwork Mon Sep 19 16:37:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 116439 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 795DEA00C3; Mon, 19 Sep 2022 18:39:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 669A541148; Mon, 19 Sep 2022 18:39:02 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) by mails.dpdk.org (Postfix) with ESMTP id 6BC5A41145 for ; Mon, 19 Sep 2022 18:39:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VStP0fe6J6Qt9ie+UkY/1KFumNZniTb5dZCMj9thn9bqe9xN4SUb9gcnJOjPWbG1yACOUeF5zs0W9bEP/rdDpWZIy9qOwhi0z+XOxRuQf1kbBFeSZ53K2dvhVLY20ZZ+UaBL6/aUKK6Co6xBhdXX1eSmwK4M3H+x8gWh1b1RFRC1tYFv1KYgit84CuQ31PDCjxbDha9jI8H8PVhRVMStqHPqPEqigF8W1zbCdn/PuAUznAaiq5DjUbUHuSeKdPcYL12PVab7EPoptwoMLefeNCIM1ICJkTL43UIYDY3Xv9GN45PgQmYeNZDqdAdvBzBwCVxJGA1cn+3eEFzyc1qBcw== 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=ZOKW75G1mlOoqHfLqcR1ZUrGUmxAFrzD1qmndRJOimw=; b=Qgl9xa8PzjGs9PHq5QFBunWYxijg0pcp34gBMx++BHjqB800Wl4Z0d6jQ+mcyPZYtMYkgism1e+fgWhfszGuwKaczhyFsw5/C5l0JLDYRWTOsGHVVdR2Ndc2wJsgu+lPP/eIms1GIqWhjsj6XVxEZd4baXBL3X43UGwKaKrqOx12FqR5p9iaKwz89OYj0dHdmtqhAfZkFbtIxRaaithv3ATuEr8llHafG3g8n9KOrmbOwgDDtwSze7FdfBY4NCliXpKrn/fgFDoYhHwFzX1D6bqmTxU3K8aFn7tWMwwh7qBusUzkGDxc3MosZNvYHETKyswtooaXbCjV0r4t4EtxrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=ZOKW75G1mlOoqHfLqcR1ZUrGUmxAFrzD1qmndRJOimw=; b=myV1HpwpejOkqYvgQao6IshJkCuIBdayvOOH2OZLBJ+axEzQsRqVdkuzPPEUH7PxK1HSdChyLj7rljpzIMko13+/KLj64Ydz3LorwrFNFqy7idOAYS6/81AVxNnQaRXuv0oMiDungLgK8MzS7cdmzHSTsTzeF0sUYhVI7KF+i0cG8kdwEpz5Fabse1QSJ640KL4ZZLtyu0351h7SReNLozIc0RN67Ccg14hMNke60yxkwOi2T2hOxy1ot2BHgA2nwBkcGkC7ba4wvpoxWR++Kf0Q/q+pwU1YCMMFH317beOqryNSEyp7ydGr7WEeYtwbMM6Rmjx60pFZrweCoxXuFA== Received: from DM6PR03CA0031.namprd03.prod.outlook.com (2603:10b6:5:40::44) by PH8PR12MB7027.namprd12.prod.outlook.com (2603:10b6:510:1be::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Mon, 19 Sep 2022 16:38:59 +0000 Received: from DM6NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40:cafe::c1) by DM6PR03CA0031.outlook.office365.com (2603:10b6:5:40::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Mon, 19 Sep 2022 16:38:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT093.mail.protection.outlook.com (10.13.172.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Mon, 19 Sep 2022 16:38:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 19 Sep 2022 09:38:47 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 19 Sep 2022 09:38:45 -0700 From: Dariusz Sosnowski To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: Subject: [PATCH 1/7] ethdev: introduce hairpin memory capabilities Date: Mon, 19 Sep 2022 16:37:24 +0000 Message-ID: <20220919163731.1540454-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220919163731.1540454-1-dsosnowski@nvidia.com> References: <20220919163731.1540454-1-dsosnowski@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT093:EE_|PH8PR12MB7027:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ec2470a-e5a1-4890-2082-08da9a5d737a X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: etKxYgXKdg3wMlt0x1ZtA/bA80fBOOSmtpG2ciSrU3lljAOS+wfygvArPGoBNUnU4SHRAk5BAwJK3o/8zdWvYAtE51kJ87PVH+P1gFX9Hr7CYbf4VtA8+saSFgyyp48MUKGWKPxczvkx5m+ycn/HolEfAiaGTeIazvEi2pV22EJTd4Bj/BZyUgVh8FUgRGzSLmEvtdnkOjpnh8bML21SKDrhWVF+ChlGuDgEgfoMVyUKWOvTBLuJwLbXunU+NH8HmoVTWT2xhhvO+hY52xwRJ5QhbrSqb7RJwvjq/yqLaD/SXrlvm4qtV3u6mCoFpkRZKmEOLukOJqaWb/OhZcJmp+d6gKuyhdDKrmnuEM575+zDk8P9TIdoU6NSFYq0/qBnPPkVhyGIiBhfhQNBi60NyhWAJkZJ4EuAgastI18FThgLRaaw3oriLSGhYAGntoS4YKzyitNdNZeUsPjE+Tut9dwNfvtdBgG8g4j1+74ywpnEb2cTemF250j5O7TY81VrkUIInr+9Q67uXKeNIknPCCeLN+OLSObryUqX62jZpU6Nc2IaxQLqM3PaJs4sdC/LcbWYqd4+soU/F8dIPCOq5dvUP3pGp55XEEQR8u4YUsOinnqgxghw1+/obyv3m1dl/LQUTHbp0Ce58+wmCxPk2zq7q+0Uq24Xp10CnnMyDHKfvr0NOqUV8u2BuWdKxhGySn58ZYDTzeX1HT0oWFndaidu7J0ZGBiz7NSofeCB+Uv0jY5NZ0cJgWg91kU+I8BnOYzc7rHm0unjJ1Ff9woA1IgALzY/FwXDJ1+3c9Ouj0fXRl3OQXyOqOe+YUyeCwfw X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199015)(40470700004)(36840700001)(46966006)(2906002)(8936002)(36756003)(7636003)(356005)(82740400003)(47076005)(86362001)(36860700001)(82310400005)(83380400001)(7696005)(6286002)(6666004)(55016003)(426003)(1076003)(2616005)(26005)(186003)(40460700003)(16526019)(336012)(70586007)(110136005)(5660300002)(4326008)(478600001)(70206006)(8676002)(316002)(40480700001)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 16:38:58.4803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ec2470a-e5a1-4890-2082-08da9a5d737a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7027 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch introduces new hairpin queue configuration options through rte_eth_hairpin_conf struct, allowing to tune Rx and Tx hairpin queues memory configuration. Hairpin configuration is extended with the following fields: - use_locked_device_memory - If set, PMD will use specialized on-device memory to store RX or TX hairpin queue data. - use_rte_memory - If set, PMD will use DPDK-managed memory to store RX or TX hairpin queue data. - force_memory - If set, PMD will be forced to use provided memory settings. If no appropriate resources are available, then device start will fail. If unset and no resources are available, PMD will fallback to using default type of resource for given queue. Hairpin capabilities are also extended, to allow verification of support of given hairpin memory configurations. Struct rte_eth_hairpin_cap is extended with two additional fields of type rte_eth_hairpin_queue_cap: - rx_cap - memory capabilities of hairpin RX queues. - tx_cap - memory capabilities of hairpin TX queues. Struct rte_eth_hairpin_queue_cap exposes whether given queue type supports use_locked_device_memory and use_rte_memory flags. Signed-off-by: Dariusz Sosnowski --- lib/ethdev/rte_ethdev.c | 44 ++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 65 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 1979dc0850..edcec08231 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1945,6 +1945,28 @@ rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t rx_queue_id, conf->peer_count, cap.max_rx_2_tx); return -EINVAL; } + if (conf->use_locked_device_memory && !cap.rx_cap.locked_device_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use locked device memory for Rx queue, which is not supported"); + return -EINVAL; + } + if (conf->use_rte_memory && !cap.rx_cap.rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use DPDK memory for Rx queue, which is not supported"); + return -EINVAL; + } + if (conf->use_locked_device_memory && conf->use_rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use mutually exclusive memory settings for Rx queue"); + return -EINVAL; + } + if (conf->force_memory && + !conf->use_locked_device_memory && + !conf->use_rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to force Rx queue memory settings, but none is set"); + return -EINVAL; + } if (conf->peer_count == 0) { RTE_ETHDEV_LOG(ERR, "Invalid value for number of peers for Rx queue(=%u), should be: > 0", @@ -2111,6 +2133,28 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, conf->peer_count, cap.max_tx_2_rx); return -EINVAL; } + if (conf->use_locked_device_memory && !cap.tx_cap.locked_device_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use locked device memory for Tx queue, which is not supported"); + return -EINVAL; + } + if (conf->use_rte_memory && !cap.tx_cap.rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use DPDK memory for Tx queue, which is not supported"); + return -EINVAL; + } + if (conf->use_locked_device_memory && conf->use_rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to use mutually exclusive memory settings for Tx queue"); + return -EINVAL; + } + if (conf->force_memory && + !conf->use_locked_device_memory && + !conf->use_rte_memory) { + RTE_ETHDEV_LOG(ERR, + "Attempt to force Tx queue memory settings, but none is set"); + return -EINVAL; + } if (conf->peer_count == 0) { RTE_ETHDEV_LOG(ERR, "Invalid value for number of peers for Tx queue(=%u), should be: > 0", diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index de9e970d4d..e179b0e79b 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1273,6 +1273,28 @@ struct rte_eth_txconf { void *reserved_ptrs[2]; /**< Reserved for future fields */ }; +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * A structure used to return the Tx or Rx hairpin queue capabilities that are supported. + */ +struct rte_eth_hairpin_queue_cap { + /** + * When set, a specialized on-device memory type can be used as a backing + * storage for a given hairpin queue type. + */ + uint32_t locked_device_memory:1; + + /** + * When set, memory managed by DPDK can be used as a backing storage + * for a given hairpin queue type. + */ + uint32_t rte_memory:1; + + uint32_t reserved:30; /**< Reserved for future fields */ +}; + /** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice @@ -1287,6 +1309,8 @@ struct rte_eth_hairpin_cap { /** Max number of Tx queues to be connected to one Rx queue. */ uint16_t max_tx_2_rx; uint16_t max_nb_desc; /**< The max num of descriptors. */ + struct rte_eth_hairpin_queue_cap rx_cap; /**< Rx hairpin queue capabilities. */ + struct rte_eth_hairpin_queue_cap tx_cap; /**< Tx hairpin queue capabilities. */ }; #define RTE_ETH_MAX_HAIRPIN_PEERS 32 @@ -1334,7 +1358,46 @@ struct rte_eth_hairpin_conf { * configured automatically during port start. */ uint32_t manual_bind:1; - uint32_t reserved:14; /**< Reserved bits. */ + + /** + * Use locked device memory as a backing storage. + * + * - When set, PMD will attempt to use on-device memory as a backing storage for descriptors + * and/or data in hairpin queue. + * - When set, PMD will use detault memory type as a backing storage. Please refer to PMD + * documentation for details. + * + * API user should check if PMD supports this configuration flag using + * @see rte_eth_dev_hairpin_capability_get. + */ + uint32_t use_locked_device_memory:1; + + /** + * Use DPDK memory as backing storage. + * + * - When set, PMD will attempt to use memory managed by DPDK as a backing storage + * for descriptors and/or data in hairpin queue. + * - When clear, PMD will use default memory type as a backing storage. Please refer + * to PMD documentation for details. + * + * API user should check if PMD supports this configuration flag using + * @see rte_eth_dev_hairpin_capability_get. + */ + uint32_t use_rte_memory:1; + + /** + * Force usage of hairpin memory configuration. + * + * - When set, PMD will attempt to use specified memory settings and + * if resource allocation fails, then hairpin queue setup will result in an + * error. + * - When clear, PMD will attempt to use specified memory settings and + * if resource allocation fails, then PMD will retry allocation with default + * configuration. + */ + uint32_t force_memory:1; + + uint32_t reserved:11; /**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS]; };