From patchwork Thu Aug 11 12:05:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 114840 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 5B1F8A0548; Thu, 11 Aug 2022 14:06:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00667427F2; Thu, 11 Aug 2022 14:06:46 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by mails.dpdk.org (Postfix) with ESMTP id 5EC87410FC for ; Thu, 11 Aug 2022 14:06:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CU0IvgR9EItkZYtTz7ocMC6jplpuM5c2F5Zqbx78j63olkQ+bzKpNwvGXJ2KmzqgOZT7MmNGCIk4d/zev+R/b6v76O5cTY1pf0zbvXAeKIzvoAgOss7ArUu2DnHNdlE+lSULc9MXzP1XAp5tSWMQ/OpZJdn88Ri/vwoysG5ichkiJjXMHcWthPSsGF2BwmSIUQhkGsdxkCoRrZqWO2phJ5dbxMdLbP8Mw6lkT53+5aej4xSWnp0GY9qFWo0W1Mw5UuagGJp+bb8xu8d86iDyc6oJtWAo0Cm6CI0mOHv2P5A4KrgK2/nJHiA0P247Ued/VnFmj/ptIVxi2hJCd5R8XQ== 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=5vehRtLWz3BgsKanBqK4OOdLjCRVeHsDx/l616WAKWI=; b=cLahOg/Z3NiOcBPUw3652g5z3boxxzqRHnbVciI8eOHrEiOjQlk15Py1HElGW4/BiHbPEJj5hlnCpXNJGDjl7SJa1/mhF1MW2XUAtY5PywEV+RXoHlKhmEpux/bCylz5ot+xYXNbrRCwQ/oQzv5+R2VRLwlfYXEo/dahlW6MmxwIfFFMpbleIGf1nrJ158G4kE1CzK4lZXur3zFcs3Vdi2kwX3/3JhaffVf2ftTPITMThp53om7MRh68eh6LO1w0rc3dGoHe1bigCA1STTaRuhIZBwm/yfHKry+yW6G924NkZrXoO94n0qZRB4I+RqqIXrLKoQo4yVm7m6qgTJQKEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=oktetlabs.ru 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=5vehRtLWz3BgsKanBqK4OOdLjCRVeHsDx/l616WAKWI=; b=CIKlgdRhsYS7vA/tUwlAiWiWOlFvoUOGG2taSs70INvDyca1AyAIfE9vTgwwLqlSoTT7SbooxnO7wpR76wzqZg5y1oOjj6shTow4XlwkV3drEJqbetF8hYwfFS/1Cqf1YQ1MgpGlszMWN2zrk+jXow01vuI5/Wbs0tD/d7zYwl7IfcmFOYlJOia0MBYkvqejcvWwWxYa9yarfI/vHng5L6rfPlbSzgdBvC/cidSuApyTjvgHrgs/+JjSPWGKLpbFI804ILR8jAk19mD0Zk2+sOmYUs447Qhhoc+CClePK9ARAkOle+aHqgojxQBE3oz9V1FjHV+2JR37+lVujv9ijA== Received: from DM5PR06CA0093.namprd06.prod.outlook.com (2603:10b6:3:4::31) by BN6PR1201MB0002.namprd12.prod.outlook.com (2603:10b6:404:ae::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Thu, 11 Aug 2022 12:06:38 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::61) by DM5PR06CA0093.outlook.office365.com (2603:10b6:3:4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.12 via Frontend Transport; Thu, 11 Aug 2022 12:06:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5525.11 via Frontend Transport; Thu, 11 Aug 2022 12:06:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 11 Aug 2022 12:06:36 +0000 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; Thu, 11 Aug 2022 05:06:34 -0700 From: Dariusz Sosnowski To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: Viacheslav Ovsiienko , Matan Azrad , Ori Kam , Subject: [RFC] ethdev: introduce hairpin memory capabilities Date: Thu, 11 Aug 2022 12:05:30 +0000 Message-ID: <20220811120530.191683-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb98d943-f121-48de-3ff6-08da7b91f143 X-MS-TrafficTypeDiagnostic: BN6PR1201MB0002:EE_ 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: bogMioeslYJSHhSsIKBiQ577xUfWHEecmwxenqyQ8wf0KX4H+8d+ptMPPl2C1Muyb7eduj++jqaH+LWzenXGTX4Cuy041oo4hg6WxyYUV5npuY/hi2+9PNZAGkLjOIzC+Hawc7BiY9gO4dzamOGVm01Rj93Zmv6Exw+kZT1/I06Ntz24NFxxOyhc5G7t5dUs/1EuIjaLJm+VF2ToEztfpskKZJqgzOVAemSEgTHlS0eraH4G2Xb4i3/fxtbqaiMPcJf2MPqE8MF60yg8qbexQ7xrfnoPPxwCoUjByLFtMc9Z/KO142gaYwqtQff8yPqudPXg7L/YkRCN3ghtaoFW2He7IA7QSKtrJaIf7rb82io/YgDOd26Ux+Gv3PSReIhMIXwoZ68io7R+UpjHbcuy2eUNcllrh/CfEDgUfTi7Y9AzleaYjBnjYhoR5bqIxBsRiCq2r0lDomVPQrFP29JPkVk7Il/hGH6Ftfw1XywVEIXZzOeT63LdVuCUxL/A2MJc/VAo3ty8cEjbCvEx3ly5bowamAQHJCF9FsD9ayiUk94Gye31rObHQp15xF5GIdRGKS0F//vDSAP+225oJIf4Z1VucdnktBSu8w2TARyThE/klt/bU+/g41lzB+Pmc+OBaLoDNGHE9tmO1pQxEc2CUcqHXlez93bcbu+dEuWRSK92+GGtFQJWKI9S6wdPrVjWXJ1aN//3gi8M8gIDQHbeFqJs/Sq4X+konr/VM8LfnHzlQsrwhL275y43WJJujO7240AOLPY+62dpTuf8GYh+Dr50X1WNuJkCjKBIuRPF448nC8wF1xobxogWMGJAZz3NP7VGTmzEZ7+HiiA06RBuHw== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(136003)(346002)(396003)(39860400002)(376002)(36840700001)(40470700004)(46966006)(36756003)(82740400003)(316002)(86362001)(356005)(4326008)(81166007)(8676002)(70206006)(8936002)(5660300002)(70586007)(55016003)(40480700001)(47076005)(426003)(336012)(83380400001)(478600001)(7696005)(6286002)(26005)(6666004)(41300700001)(16526019)(2616005)(186003)(1076003)(36860700001)(82310400005)(54906003)(110136005)(40460700003)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 12:06:37.3287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb98d943-f121-48de-3ff6-08da7b91f143 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0002 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 RFC 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]; };