From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C21345710; Thu, 1 Aug 2024 12:55:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58CC5433CF; Thu, 1 Aug 2024 12:53:52 +0200 (CEST) Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010044.outbound.protection.outlook.com [52.101.69.44]) by mails.dpdk.org (Postfix) with ESMTP id E24C8433DA for ; Thu, 1 Aug 2024 12:53:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KDxVFAIm7bzVBAYBMx5stz5nBzVytvxof8yXDerNGewM/P7KoMNHl6c6I+t6UTHJxB2vUmYcVlMywbHLgSMDOxtWbQINTwK5F3LcrmLJQWEcYudiqg9XATbc8LRLmerL0iTPQYTNfRC3vvWkYGRRhReGen7Bm4GzKrr65EP3XWl/f4i9VQF6SdMjF0Iw+ccrwT6goN7PRsLX9hMllIk2Sf8o+G/QysuroaZvkVroKfmueabcChXQ3cxKePvND95BWws5ldPNLvNF3RNK62zxYpq1GPpEsZCeDVbUqAyIXhdUormwZOGqcOfTTO3vvu4O83HEt+EKHU3seVcttfZSMg== 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=uxxQHcju0/mDOAjX9HY7+URCZTWnQnAkl5nPCvVReDM=; b=YpQLnVq34A9wv3/iPPN2iXU6jcpc0nDrbkXVlslmgRZunFkbm01WIZCNIB6bTcVIf1/o7mu6uiUDQ79DCyThVmyMBt0d5XTcb4T8JU0A1KNkmCcYS+erosRut2uU6HQ/+IUim3Ru/harnkZi6TJqAjeK28a/i152U9JAEHzO+DeteBRLsJHzlafn04dd1f2AeQ6Q297rkiVwo+1YLunndIy+6hFuSVRnS3UIt87pD7HEKAxT2BBiopeviKnR1l1Fv92tGOVzgO+IcQT6pqymR6UYujwqzx6XRtWYG/4jMAzfK5hOtRmIZgv5MX3CGenFi+nwik9POJULtbeKGv6oJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uxxQHcju0/mDOAjX9HY7+URCZTWnQnAkl5nPCvVReDM=; b=F0VGXiKhFI81vN4F1eqF3nETV6SSHuEsMqWSPRVVn7S4/YFlkV5xtqURVBZaWFFKsjlJ1mFoTN1BIFgAL6pE8U84H9ZFDi2xkUoBQp6QooISEDDDgW3OcW6hDEP9zjYuEvipbcFrFCilgoI786d2AH34w2VSAt0oJ+LMrvAANtXjvWmoCSudeuMX1CGOBy/ajw8Rqdisz9dcnCuZNZzvYAx+PUNFiOcRIm48ajysBPVWXhyi/QGXoyAnoa7CHoX2bv7vDlSO0lOWdeMG/THKDuAJTjjrtC8iL4trsvHL5/8428ht2PrslKUjh5eHKwsLu9LK3aL3wBamqmEuDiUj+A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) by AS8PR04MB8433.eurprd04.prod.outlook.com (2603:10a6:20b:407::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Thu, 1 Aug 2024 10:53:46 +0000 Received: from PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87]) by PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87%3]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 10:53:46 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Vinod Pullabhatla , Rohit Raj Subject: [PATCH 13/17] net/dpaa: add Tx rate limiting DPAA PMD API Date: Thu, 1 Aug 2024 16:23:09 +0530 Message-Id: <20240801105313.630280-14-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240801105313.630280-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0026.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::13) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|AS8PR04MB8433:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ac5e262-69e9-4866-7c77-08dcb218377d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zY5M7g7djAph/Rs0RR5weOrAf6t2c9V+Y28IvO4x5GNFiNIyXvUJsQpcsS2u?= =?us-ascii?Q?GlOIV5jeSYaWS0lcNAADWGeP+zPJCvP2w+RNZi/Q3rI5zD1QSvVHPlIbgacQ?= =?us-ascii?Q?CJiKKCj7LRUD1JXzibqTr2g5ltKG+XAgrZ4+14jqD4p7pKOsK5wiOJZTIpd+?= =?us-ascii?Q?NhrjkemKzn+d+ghNse8/an+9nPCY/Hc8+UVf8cVTwl01OCTgVVG0yBiNDFfy?= =?us-ascii?Q?JYlLek0rGzQMB26ZQtqJNzADENcZkIS5ocm4ek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rSRDX1PBMnfyINhthCOmf4SVIzdrXXNdBmlclre9QDQEOgov?= =?us-ascii?Q?hpJ7TZBVjpN/q6nkuWSq0AMR2BKE5pLN6XEDm2k/22ArEaOSra0l3RaGaCmm?= =?us-ascii?Q?b+LQcrQKxz3prYTGn1XaV8Cxk4XpAZZg5gcgqh1N8IPc2jzPd90eV/rnbhAv?= =?us-ascii?Q?csWzw75UFE0u91APIu2565xc84tazsLesCTyWopzwF6l6pM/zGXfam93gqB3?= =?us-ascii?Q?LNDjlrepCJMSocRDldSmyfnUvsNP/DSUVeMzDmUFP2pncWk+2A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9328.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X7q2amUVExwg9YYSkRYRq2lF7HEFtMriPlgcvO1kw08Q9q4BHnO3KpRzbyJh?= =?us-ascii?Q?E55n2aWXWSergD+8qSZ5AQ0LP32ti6LSCn631HZ6kcs6emtiNP+c+Ac4KbT7?= =?us-ascii?Q?+LWeKaVM/jYo7Df6hKhNsuno7fq+ARjc7y+VAl4MZD4gwncKlaz38sxrXDUz?= =?us-ascii?Q?e960yS8SQAHPBLSJjPKY8eMT13WmhW+2ShVksr+O2mMOY8JitzygJlNqrkTP?= =?us-ascii?Q?XBXfk552gwYa5COaygBSMtkCYuuYg++whLraC0VoTVuaVWVO1Vcyvr++oGeU?= =?us-ascii?Q?KeXWk4MWM/Ljj1Rwv4yIXn9FsFYKRyu2LTcLjRSsKvmC/CCohJZoyUKxFe1e?= =?us-ascii?Q?imRlZF25a1ylnYRiKdSU1e6UTaQIivTQ1JdiWaaZ+HPL8GuqUAaNURCEoFb6?= =?us-ascii?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cluPBFXqFpu8MG0yWJiK?= =?us-ascii?Q?fyVDZh8ZI8q+u5pnHsRy3pvBzy4YuxmJ/zwUsSZhWZ4kacE3+IcCtq51ebiK?= =?us-ascii?Q?U6ieGqijwitMghyR0vgwj6398GcNNK6aorrNSXzbsJyprofVueP4q+YQuckQ?= =?us-ascii?Q?dTt+u0N6uT2/Va8nn2asTa5bc2TIR8W9+UWdKl7EtbocCy3PwaAXWLCcUK0k?= =?us-ascii?Q?Bon6/H0EzToQPCJHvutt1aO0p5zNMi23QqqCq1Xj8/6xsXHjS225ODDDRpJT?= =?us-ascii?Q?rcSCqBF9t3ZfplR/ICDKuei8uZ9XrYGw7djv84+Yfg8DMMSm8X58bqe9Urg7?= =?us-ascii?Q?6A=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ac5e262-69e9-4866-7c77-08dcb218377d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 10:53:46.1140 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AkOrPudgwQiZHrni7WA8S+J34URpCjBpZIQ55wd0+f0aAiGDjIRnT3m6vZ6w25IC2GTpYeJoDpOcrY56x8VttQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8433 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 From: Vinod Pullabhatla Add support to set Tx rate on DPAA platform through PMD APIs Signed-off-by: Vinod Pullabhatla Signed-off-by: Rohit Raj --- .mailmap | 1 + drivers/net/dpaa/dpaa_flow.c | 95 +++++++++++++++++++++++++--- drivers/net/dpaa/fmlib/fm_lib.c | 32 +++++++++- drivers/net/dpaa/fmlib/fm_port_ext.h | 2 +- drivers/net/dpaa/rte_pmd_dpaa.h | 25 +++++++- drivers/net/dpaa/version.map | 7 ++ 6 files changed, 151 insertions(+), 11 deletions(-) diff --git a/.mailmap b/.mailmap index 4a508bafad..cb0fd52404 100644 --- a/.mailmap +++ b/.mailmap @@ -1562,6 +1562,7 @@ Vincent Jardin Vincent Li Vincent S. Cojot Vinh Tran +Vinod Pullabhatla Vipin Padmam Ramesh Vipin Varghese Vipul Ashri diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index 082bd5d014..dfc81e4e43 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -13,6 +13,7 @@ #include #include #include +#include #define DPAA_MAX_NUM_ETH_DEV 8 @@ -29,6 +30,11 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx]; #define SCH_EXT_FULL_FLD(scheme_params, hdr_idx) \ SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field +/* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G + * ports). + */ +const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; + /* FM global info */ struct dpaa_fm_info { t_handle fman_handle; @@ -649,7 +655,7 @@ static inline int set_pcd_netenv_scheme(struct dpaa_if *dpaa_intf, } -static inline int get_port_type(struct fman_if *fif) +static inline int get_rx_port_type(struct fman_if *fif) { /* For 1G fm-mac9 and fm-mac10 ports, configure the VSP as 10G * ports so that kernel can configure correct port. @@ -668,6 +674,19 @@ static inline int get_port_type(struct fman_if *fif) return -1; } +static inline int get_tx_port_type(struct fman_if *fif) +{ + if (fif->mac_type == fman_mac_1g) + return e_FM_PORT_TYPE_TX; + else if (fif->mac_type == fman_mac_2_5g) + return e_FM_PORT_TYPE_TX_2_5G; + else if (fif->mac_type == fman_mac_10g) + return e_FM_PORT_TYPE_TX_10G; + + DPAA_PMD_ERR("MAC type unsupported"); + return -1; +} + static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf, uint64_t req_dist_set, struct fman_if *fif) @@ -676,17 +695,12 @@ static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf, ioc_fm_pcd_net_env_params_t dist_units; PMD_INIT_FUNC_TRACE(); - /* FMAN mac indexes mappings (0 is unused, - * first 8 are for 1G, next for 10G ports - */ - uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; - /* Memset FM port params */ memset(&fm_port_params, 0, sizeof(fm_port_params)); /* Set FM port params */ fm_port_params.h_fm = fm_info.fman_handle; - fm_port_params.port_type = get_port_type(fif); + fm_port_params.port_type = get_rx_port_type(fif); fm_port_params.port_id = mac_idx[fif->mac_idx]; /* FM PORT Open */ @@ -949,7 +963,6 @@ static int dpaa_port_vsp_configure(struct dpaa_if *dpaa_intf, { t_fm_vsp_params vsp_params; t_fm_buffer_prefix_content buf_prefix_cont; - uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; uint8_t idx = mac_idx[fif->mac_idx]; int ret; @@ -1079,3 +1092,69 @@ int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf, struct fman_if *fif) return E_OK; } + +int rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, uint16_t burst, + uint32_t rate) +{ + t_fm_port_rate_limit port_rate_limit; + bool port_handle_exists = true; + void *handle; + uint32_t ret; + struct rte_eth_dev *dev; + struct dpaa_if *dpaa_intf; + struct fman_if *fif; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + dpaa_intf = dev->data->dev_private; + fif = dev->process_private; + + memset(&port_rate_limit, 0, sizeof(port_rate_limit)); + port_rate_limit.max_burst_size = burst; + port_rate_limit.rate_limit = rate; + + DPAA_PMD_DEBUG("Setting Rate Limiter for port:%s Max Burst =%u Max Rate =%u\n", + dpaa_intf->name, burst, rate); + + if (!dpaa_intf->port_handle) { + t_fm_port_params fm_port_params; + + /* Memset FM port params */ + memset(&fm_port_params, 0, sizeof(fm_port_params)); + + /* Set FM port params */ + fm_port_params.h_fm = fm_open(0); + fm_port_params.port_type = get_tx_port_type(fif); + fm_port_params.port_id = mac_idx[fif->mac_idx]; + + /* FM PORT Open */ + handle = fm_port_open(&fm_port_params); + fm_close(fm_port_params.h_fm); + if (!handle) { + DPAA_PMD_ERR("Can't open handle %p\n", + fm_info.fman_handle); + return -ENODEV; + } + + port_handle_exists = false; + } else { + handle = dpaa_intf->port_handle; + } + + if (burst == 0 || rate == 0) + ret = fm_port_delete_rate_limit(handle); + else + ret = fm_port_set_rate_limit(handle, &port_rate_limit); + + if (ret) { + DPAA_PMD_ERR("Failed to set rate limit ret = %#x\n", -ret); + return -ret; + } + + DPAA_PMD_DEBUG("FM_PORT_SetRateLimit ret = %#x\n", -ret); + + if (!port_handle_exists) + fm_port_close(handle); + + return 0; +} diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c index 68b519ff8a..4b7dd38496 100644 --- a/drivers/net/dpaa/fmlib/fm_lib.c +++ b/drivers/net/dpaa/fmlib/fm_lib.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright 2008-2016 Freescale Semiconductor Inc. - * Copyright 2017-2020 NXP + * Copyright 2017-2020,2022 NXP */ #include @@ -558,3 +558,33 @@ get_device_id(t_handle h_dev) return (t_handle)p_dev->id; } + +uint32_t +fm_port_delete_rate_limit(t_handle h_fm_port) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PORT_IOC_REMOVE_RATE_LIMIT)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +uint32_t +fm_port_set_rate_limit(t_handle h_fm_port, t_fm_port_rate_limit *p_rate_limit) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PORT_IOC_SET_RATE_LIMIT, p_rate_limit)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} diff --git a/drivers/net/dpaa/fmlib/fm_port_ext.h b/drivers/net/dpaa/fmlib/fm_port_ext.h index bb2e00222e..f1cbf37de3 100644 --- a/drivers/net/dpaa/fmlib/fm_port_ext.h +++ b/drivers/net/dpaa/fmlib/fm_port_ext.h @@ -274,7 +274,7 @@ typedef struct ioc_fm_port_congestion_groups_t { * @Return 0 on success; error code otherwise. */ #define FM_PORT_IOC_SET_RATE_LIMIT \ - IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(3), ioc_fm_port_rate_limit_t) + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(3), ioc_fm_port_rate_limit_t) /* * @Function fm_port_delete_rate_limit diff --git a/drivers/net/dpaa/rte_pmd_dpaa.h b/drivers/net/dpaa/rte_pmd_dpaa.h index ec45633ba2..b48adff570 100644 --- a/drivers/net/dpaa/rte_pmd_dpaa.h +++ b/drivers/net/dpaa/rte_pmd_dpaa.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018 NXP + * Copyright 2018,2022 NXP */ #ifndef _PMD_DPAA_H_ @@ -31,4 +31,27 @@ int rte_pmd_dpaa_set_tx_loopback(uint16_t port, uint8_t on); +/** + * Set TX rate limit + * + * @param port_id + * The port identifier of the Ethernet device. + * @param burst + * Max burst size(KBytes) of the Ethernet device. + * 0 - Disable TX rate limit. + * @param rate + * Max rate(Kb/sec) of the Ethernet device. + * 0 - Disable TX rate limit. + * @return + * 0 - if successful. + * <0 - if failed, with proper error code. + * + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + */ +__rte_experimental +int +rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, uint16_t burst, + uint32_t rate); + #endif /* _PMD_DPAA_H_ */ diff --git a/drivers/net/dpaa/version.map b/drivers/net/dpaa/version.map index c06f4a56de..0662f939bf 100644 --- a/drivers/net/dpaa/version.map +++ b/drivers/net/dpaa/version.map @@ -6,6 +6,13 @@ DPDK_24 { local: *; }; +EXPERIMENTAL { + global: + + # added in 24.11 + rte_pmd_dpaa_port_set_rate_limit; +}; + INTERNAL { global: -- 2.25.1