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 DC35F45843; Fri, 23 Aug 2024 09:35:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5EB89432CC; Fri, 23 Aug 2024 09:33:27 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013017.outbound.protection.outlook.com [52.101.67.17]) by mails.dpdk.org (Postfix) with ESMTP id EDFD743007 for ; Fri, 23 Aug 2024 09:33:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XNV8AQQ90UJ2isVRGbRjaygaUmXUyja4VXcrGjOgBopIOl+Fh3U1+JSwc+RBQjT/2yN1gyyLJb/lchxOGqQqJ1Me0iz6UXv0uAxS47r+lZGIfk7M+gTPGchZHZg/LMV2MCcJZcnm/xhZYqjLRXJUyTI5GZewFXNlDL+lC1sRTSh+6Beotg1fYLtgUuLcGe17gzUMfJ2nMVv4l1ycOHuddWkh2fseQ3HN0qE6Ucef4DjiaoR1LTLYXrIu/JrwzIe7jLl3UkAxI9/F3I5hhZe4NGtgFVgQXQrEm0gRwiWNsKQVOq7fZUQE65rL3mvBhhtDi28QPqOele5A1ZgVkeaUKA== 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=PYc8LNoC7osnGrIol/s/GF6PaXj01V8vQdej4k9xlME=; b=AsdtZex5nFV34n6EJ0uss6BZ+p8RpUQr8goVNsd3XM6HebZBgo4pso509loVrX0ikiSmRjwG7HplSpBecuX2Bb2WTYt3iD+o4iHC3/oJ7GYX4lJqbt6Y57/TJKqmcBbxQZQSNKW2FFRHwyIYhkND8twRRenwOMdz6rJykPOWQKUiJN3t1w+7WyR0UMa7BzoHhWg0M2LM6g8MMPOahhqttBJKF0SpiHFnNPGlfhVE5cuIJFfpk8w9J270kSLbRjUrVpBlJwSreR5F/Nh0mpR+IW0w0GcxQLipAPT7FOLyzPcuQq86WgT/iG2cfXwaeS1xJkpSbe38p0fRfXH1xcpCwA== 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=PYc8LNoC7osnGrIol/s/GF6PaXj01V8vQdej4k9xlME=; b=AdiuQpnc+OhwGQM+YR66j28tgnH5d4qWqR9yf8pljHQ8Pck9QB1hKd0fXDjPVOMbamA5Tsz5FVpH0yym9d0nRM0jx7XyPMbk0KSLKV7kPBa/BAKKFW2nOvW4sR+Edq5DCInpVcNA/e7uk0eeipvE4B79jhSCE8wdClZmf6hpsqeVeVzvorG3/hW25604pG44zFxy1TqQy6FWW29cgvKYzhXvbT7LltxkGXWsb0VxuTgwSOHy2HIFNTlmtN90T11h/O8MQPUB72XMSBWWnzhcbRn4/dB/6wTZgUGNo3PrPd5g7apdtS1RglE62XD5Wmb4EgQQswYWPHCYbacfa/uoJA== 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 DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Fri, 23 Aug 2024 07:33:18 +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.7875.019; Fri, 23 Aug 2024 07:33:18 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Vinod Pullabhatla , Rohit Raj Subject: [PATCH v2 14/18] net/dpaa: add Tx rate limiting DPAA PMD API Date: Fri, 23 Aug 2024 13:02:36 +0530 Message-Id: <20240823073240.3708320-15-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823073240.3708320-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> <20240823073240.3708320-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0028.apcprd02.prod.outlook.com (2603:1096:3:18::16) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: d0fd52da-ec16-4ad9-13e3-08dcc345db69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uZdCPsbLoKujiVG6XWgpJmo+HpapmRdDTl96epzAnyQH+OiiwSyKm1nBtdGN?= =?us-ascii?Q?vsAQR4orowV+FaCVMCmIlza8FSuaEE7i9k+J5uxDBQtjSBmQR63zWhb+9Ut8?= =?us-ascii?Q?pi/b9VEw7+L0UZV0aaA+AckNrdl8YZse5FZu/+eW3SC1skNXH9dJdiiW7Utq?= =?us-ascii?Q?+eRiqpl1k8jN/Du5ll8AdY8dqjfBNwD6pJCuoLXL42F7mAxxFgaC9KPX8+NT?= =?us-ascii?Q?PZkJk5F//5vX4vx4LterHLMCorYMsmtuwW2YYT5JSmyDRv6+Wjf42IhAag4m?= =?us-ascii?Q?xJO08CBIbd7w0KmwKdgr9YwMHpkyFYocORWYgmJrsz8hI5PMEUC5j/YTkDmM?= =?us-ascii?Q?Ff9IQcS2iI/X4W0RlPbSWqku4IREV1SL3wsfyldxQ1XD7tOOifuALcKiXZuw?= =?us-ascii?Q?ilaJtUdGVTPC3tSrVzmOsePC3o7MDjPixm23SzI3lLXctSoGt2gcvGin7tlF?= =?us-ascii?Q?VPyG8fp6AT9OTiZ9sSAqtjAJM+Wrsg1hFtTbI1pGe+ZkiYgEhnx31q9HOaBK?= =?us-ascii?Q?265H+m0DlcX19i9dswc1IPOEJ5YjpjHNVVNjfZo1cXq1d5u1JjqWhoyV6okG?= =?us-ascii?Q?SegHRjIoF9pg3VlpA4Xem5crXrvB9V3/kThSOIFiHLNGs1bvCYbq1l16EtjK?= =?us-ascii?Q?93U+OzW8AfvnVXEgNQahTXCf0bgJNuL5X9Cq1D3fNa0cJPcxUc/nv8g1Jhds?= =?us-ascii?Q?4jUXjnzH5SPa8yLb54biyrMZOhkqx5rgVo1Mj4W6/kI7KaTsWCEnUu/hUH73?= =?us-ascii?Q?P84VW+XKLMvesM1QlgZaPX4lrYnm2bfp+bM99d+mWMBGt08HSNoOoSBtkVWs?= =?us-ascii?Q?cwmSiVCOmwLqIGtaVFh2r1W/mJzYHAAEaw+/a0gmy7AtjXu3CvvJjrkrXWmP?= =?us-ascii?Q?Dsm/YKHXizfJ0LzdSGRE7ZbAWNQ7d+J9lOsvX0V9YiNv5a/XGFk3sNgxLvuW?= =?us-ascii?Q?SyzEdqjbrsahczVnCNMy1dpdwtLfdAkAgA09UArZp+I8En83PVzCrHo2nIRG?= =?us-ascii?Q?rZXE9WgbgY+kd6oTFkIAwtl767HAIRi5FHq//8p4Yp0gQYEKl9hGXzSYSlsO?= =?us-ascii?Q?Tk7FSICKjWy3jPO3oT+lOsBiVz8fGRhTtAdjj09LIHxxfOEskmOQ94PqK5/s?= =?us-ascii?Q?BWiuxaRnc9nD4rIQhzbc5l/X77NDfUaGz8UVcChqJ5GasUG0jO+4uEyy/PRb?= =?us-ascii?Q?zIkeaC99eFN6eIc2+dC43GwEu7aLdybT7rLXmvJ+QxJQX1k5hz9/CcIHzpgE?= =?us-ascii?Q?4Lvk9GhQdrj0KcXXoNo5FpQclktTFuqW2D6vjqkwZLfUU+ymgyejObbftXQM?= =?us-ascii?Q?lVN9nvMg4tnI+nUuZ3uTAclH/xukSeRe9380B/ZYgz97LvaNSluOfn5+qHH9?= =?us-ascii?Q?dHpvNZj3KUsc0d5dWjqfolUEyxCsdzZkBcrCzXy4Yy+CIMFY+A=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)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VKBqZRE65LAwTdHuiztTtv9KMSip5b4k637rTYLJsO7759uKfwSJUxnXEfkY?= =?us-ascii?Q?r74qqbB8+KR8i2Vejfaa3iGNlqJA8F/zBk8JKUlNaM6PyN0O9sN0cpbhqi5Y?= =?us-ascii?Q?TFqgyT4eygtVu7sdDEqJPsG3q8EHxdVu1+Knw+TZdKOX9uzUR9M+9ATy5/Gp?= =?us-ascii?Q?/FQj52dX0iRvBzetZBoLuYilZmcK6d+b9woosDjNcaJVqZ3DPYQ/5wahsREb?= =?us-ascii?Q?Zc5FpNHemugUWDZKgIOBNawtP2wduLSggo7Ba3TFrs49Vvg1IxREhE4Fc4SW?= =?us-ascii?Q?tg4oL2+xSgHbefeXfl0bvkmflBeRoCt6ZqHI6U6WuQ8osK/BlC4c1QDPVKfD?= =?us-ascii?Q?LsXzMdhJl2iC069iwPA2+c+6UQ2eZ5/uGjyO1SUHIbT+yjSMnuZMqHo9M6HK?= =?us-ascii?Q?ZryMq7dKWZlJZtq/apFj7eE3304PeViQSM6CEZrdlNaZIVligikqMCe549VT?= =?us-ascii?Q?WF7axcLj753cj9DM/l8N6I0cWKnSNC8xuKi9okdRLR35D4gW/75rYH43iaAK?= =?us-ascii?Q?HcP504p73jtH2tPfToT3aAPzuvdlREWut8PIXKhQEit+bt+u75XLvUxpDWoY?= =?us-ascii?Q?mDttjtwxjNEpPxeBK1VBtGXHIacMjqM7qz58ycF6jpZILGuiJtivDThnUqnn?= =?us-ascii?Q?GNJZRZc6n7UAOrLaPxH9iU9BxWjsMFY4+JRXEvzebJrmEcDKY+2hkQL6aY91?= =?us-ascii?Q?vODc6kObFHcHJl56GTAHqs5m0JuTkQ9Tm8akkUqjELZBqyM29iHRO2cZnxlF?= =?us-ascii?Q?oYOcWmhh3PBl5mcOAIapcZ6tT0RSaId5724JnzjlQia/yDcV9Zhb1nJEeqF2?= =?us-ascii?Q?WuSKBnn+B9m6m3Q0ctoGtPh5qHRvg32B5mePnnPLJaBxiODoBjUTsuThHGFk?= =?us-ascii?Q?wus6eARRJvnsLfjgBL0JV2ATEPiw3845B+jJYJCD6jeHF99gPxtdsUeKsFQ4?= =?us-ascii?Q?nAaIyOnUNB1os0r8DrxpQOAVpw2J/LeKjzvZuyyAJbFdj+IBkZbAR+3CUmF5?= =?us-ascii?Q?3pOgN3BsyJRIZUjjg4FsIi1VDBCOGAC22y9Rh5IpGDR5i88K0GEd3E3aV/p2?= =?us-ascii?Q?jsT3kECBzSS2jIwhb07mZMt319ScrfsAuF6HB6x2kP5eqJkZ5O5vre3BOQ4j?= =?us-ascii?Q?ei4bGBqdCfma97ACdt5+/WVQQ3to2z83kqCLEe/8fX7ypAcgocw1QbzICknd?= =?us-ascii?Q?YG6MZlhz5UpmiuKhJmZcL7K61fWeBISW6E1WWauvqz6+22B8zEQcPRvsJseo?= =?us-ascii?Q?vdBCAasNl/Fd0j0ZIlHWo59x6u0ehJNu8Phiy8H81GNErOPD7V35sqQtHDZ5?= =?us-ascii?Q?2sd6IO6Pt+dEI9T3QqVMz2OwN+n8ft6K5H5KzDhV/Se0kdSztor59Z3WYlz2?= =?us-ascii?Q?3U39014Nh1Ga79EF0TJRvNkN8tbRccrh4Zk7qBGy8Qh9ffRTMpgDwOQA6SFs?= =?us-ascii?Q?UqbiwlSnWJJNgtIrEoK3j1zP2MVx8f7cr0jeV4aw0jcDqzZh2Gae0m2+8u8g?= =?us-ascii?Q?UL9xmg9ihHKNSPx0LdmN6J7oezD37zIoMDgoTEhqAN+HTkXGFGdzI63yRPqb?= =?us-ascii?Q?t07nZ6BeXje2dChNTKxzTybiN9gbxxYm8SMtaz1ovYgoH9vi5LEdGRU4jQYx?= =?us-ascii?Q?YA=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0fd52da-ec16-4ad9-13e3-08dcc345db69 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:33:18.2495 (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: 6tJYcJWaVoxuO75GYjp2OJ5tSZ3y3NvapYzsQSTjkOLXuctQIfnACPE07UrgKiZltVOz3+JfLbq3abSod8HOOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 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 3fdb63caf3..24a28ce649 100644 --- a/drivers/net/dpaa/version.map +++ b/drivers/net/dpaa/version.map @@ -6,6 +6,13 @@ DPDK_25 { local: *; }; +EXPERIMENTAL { + global: + + # added in 24.11 + rte_pmd_dpaa_port_set_rate_limit; +}; + INTERNAL { global: -- 2.25.1