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 3EAE6454B8; Mon, 24 Jun 2024 03:59:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CDF840B91; Mon, 24 Jun 2024 03:58:05 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2093.outbound.protection.outlook.com [40.107.244.93]) by mails.dpdk.org (Postfix) with ESMTP id 48F4840678 for ; Mon, 24 Jun 2024 03:58:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DLcokwvFtGOwdR10RLYATdg2zS8BzdbQ8wsTyiIGA38yz09m/7Z1UVQOQoQ2O0he8QbA/5BFa/Ckj8dGMVk7fIETB5QK4kT4mEz0no7yX5vF3TUQXNap4pbzatS0Cudc6kFuU2JXURFBnCiOXd7hv1NArpm0ZFT2unAR3vy1FbE4yNuVE/ZAwlLDyPyfWQ0DMGGPL65aAw6MiOhDYwwQm4OF4dkwH/Kv7aosDTAY0AVOqjyBfAkvLlVcuk+wV6UJGx8ORo7qkZHywYECi+SLjjITqjeVPOpxOS102drrqBMKA0Jto+BbTiTxXEz0jEMoomWP1K9/FvF+VBB6DcPAoA== 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=zdwRC+SytPAqhFunhPpoZjbmRFTNjMaqEUuM/sKo9ek=; b=d5dMdkFF4qTw0nVmXSAIfBK1yMUQdfXi4xdmEfEjeJc0emW0FpiU6Atc+zBGPTIKUcDiR1RhwQqTDJlVYjPNFLrnH10o+j1NqL+3CajFbWmhbYxs+N484BK4eQ2+IKJXfMEESolYPOolHm4kgHEH+AgoggwV4UZ5YBN/eWm+299GraFejSlnpX830xDQPIeCP3N+nQj8BAAObpU1tks4gxq98HSfaYN5CWvk9XFb57fr2x0MadVxpAGt/e5ip3lyBgRQbGRncKV+KGE4W7EYknm+s73faaxDTiwL9b+nqTY5C0mVzLKotYMnrTy33hj1BykEMMbPbXZx8TFsMx7eOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zdwRC+SytPAqhFunhPpoZjbmRFTNjMaqEUuM/sKo9ek=; b=utDvwoYQtmCpyS2NRyzX+lAxyGUJmiF4HgbtTVYtK+SFqKrHaJH+TkWiSZ+Xz9YLgADBrZQsjumf/b0dCjkcrMSpAWGoTg2aQ3cRpttY1TE3J/GI9/v4+9Zpz5duQOFGqgejdstf+lWrMsEUqi2PQ+Py8H1I7mu923SaphqqpaU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by BY3PR13MB4882.namprd13.prod.outlook.com (2603:10b6:a03:36e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.28; Mon, 24 Jun 2024 01:58:02 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7698.024; Mon, 24 Jun 2024 01:58:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH 09/17] net/nfp: enlarge the flow rules limitation Date: Mon, 24 Jun 2024 09:57:15 +0800 Message-Id: <20240624015723.3712898-10-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240624015723.3712898-1-chaoyong.he@corigine.com> References: <20240624015723.3712898-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0070.namprd13.prod.outlook.com (2603:10b6:a03:2c4::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BY3PR13MB4882:EE_ X-MS-Office365-Filtering-Correlation-Id: ebbf8d9b-3070-4677-7cf7-08dc93f11470 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|366013|52116011|376011|1800799021|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R7B/V+aR8EbJeNO2lQ749kGUPBfCgh0OLPct+YLJh7b4LABWXDW/QDyeIl2X?= =?us-ascii?Q?5d/mHSgubngMLygptwnM4T6gyOtPrJm18e0gEmmdfKzNU3N9VmDMRvl1P6uF?= =?us-ascii?Q?vbxDhFpBXeJ197GdE7XY3inTmH4voFr1kIyT5Cv1cggtPTqbzVZO3Xo8eu25?= =?us-ascii?Q?x/gRQMFmA1H0RODaO6N0Pk5s0bploXzqBdCpgbwXIAYy+Hq+z7myczrJnc6H?= =?us-ascii?Q?o28q4Z+w0PBEfbVhn8M5/p5IAeoMJoIiGQtnnXoUJ6JIsRxQZqkSl51so2IH?= =?us-ascii?Q?8skf3YL1hGWttVdzZ6vUd1Sl5wbcdFJK7CGDSCmgLwvVaTARWiN0C+67uZ6a?= =?us-ascii?Q?eVFLPUrnhY79ixvKU6Xny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ascii?Q?s8gi2y4wX7/7vv0/3I1a6JxjQBexXuBqajcNvoypCqILoS526/EWvpGYmh8+?= =?us-ascii?Q?YuV7U1qQ1GT27YAetR5vLbcthgU6WEnaM1SaT90GVfEpSX6HJsLSyX+ESYMj?= =?us-ascii?Q?kRZY/XA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(366013)(52116011)(376011)(1800799021)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VDKEdtRWebVAzn2WcliBFPdNqrzPzg0fSoC08ccQ2ujAJ+gjKJVo6NA9sCh7?= =?us-ascii?Q?BbVeBXq5HMJkkOBHvrqpnryDzd+ik1COS/0JRbOMNoAQvkuPjP7IqoRA4LvW?= =?us-ascii?Q?/OCOx4p2RMgz4Vlblxilqb4PFT/qC6hkNaWl/JyaNYofYj2cCmFazzk+rYvm?= =?us-ascii?Q?fXCuE6dLD7pUlKpI2H2RySye1dFE+q4ttw7ej7rTMnQRJf+c6N0wsmg9OphL?= =?us-ascii?Q?XGE6n1EiSzlAlnsrXr2xh5fXPgJd+3bHHJdzvmMlukq2JfaJX48Ba5PxJGB6?= =?us-ascii?Q?S8tFqnJ/DSMTWpJO6KLuO1pJ++l+wGvcYLUULbaoEtwaV3tP2i+aWBGmO9kX?= =?us-ascii?Q?jgFiOv1S9Oq92hc9FxeTaAZC7VqPoIOUAKriE/lrmPS0TwNuY8BKkVet29uT?= =?us-ascii?Q?Y83UZ54K+uufoh1goT6oSrgYnZMEpVfe1VYQI66CJwChL56Jf7sFUChKCaEb?= =?us-ascii?Q?ntac7uOLWOaJvkaEZaKQgymy/Xb1OV0+DvgR2iTYmPF2PsZbn2TLA6RrHFCj?= =?us-ascii?Q?OL4bw0q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GUMSFnNwzvJqMWXLCwqZ?= =?us-ascii?Q?646LdsH1BAPYfwapj6uuKXoPHzBEI2RO/uG3BPRFo+d7HfYMkcF6iqhVkWlI?= =?us-ascii?Q?WeQd54uuN8lD9x33wHiny4pWaYRL0rFYUbQ0ucXINPbvCY755N6QexcS8dea?= =?us-ascii?Q?O/BUb9jUmbD+n5ndeDPLZOMGUH0BpH+AErgxQHmejVT9AH+Q8tt5uBSNlwwY?= =?us-ascii?Q?yA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebbf8d9b-3070-4677-7cf7-08dc93f11470 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 01:58:02.1712 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: n7g4h7Nz2zmFs/8dgX75WTuYeVc5yvMHnWhQBrxBi9MEPVC6QFI0ZSI1e1BYveVNRegCJN4qj4xxFARy6ZZLezJoyr0vjOwMjBCg8lNHqvg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR13MB4882 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: Long Wu The firmware rules limitation is enlarged to 2056(8 Eth + 1024 IPv4 + 1024 IPv6 rules). So enlarge the flow rules limitation and add more precise checks to flow count. Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_net_common.h | 16 +++++- drivers/net/nfp/nfp_net_flow.c | 87 +++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 9 deletions(-) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 8e3e219261..6db849eb07 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -165,12 +165,24 @@ struct nfp_pf_dev { bool speed_updated; }; -#define NFP_NET_FLOW_LIMIT 1024 +#define NFP_NET_ETH_FLOW_LIMIT 8 +#define NFP_NET_IPV4_FLOW_LIMIT 1024 +#define NFP_NET_IPV6_FLOW_LIMIT 1024 + +#define NFP_NET_FLOW_LIMIT ((NFP_NET_ETH_FLOW_LIMIT) + \ + (NFP_NET_IPV4_FLOW_LIMIT) + \ + (NFP_NET_IPV6_FLOW_LIMIT)) + +struct nfp_net_flow_count { + uint16_t eth_count; + uint16_t ipv4_count; + uint16_t ipv6_count; +}; struct nfp_net_priv { uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */ struct rte_hash *flow_table; /**< Hash table to store flow rules. */ - uint16_t flow_count; /**< Flow count in hash table */ + struct nfp_net_flow_count flow_count; /**< Flow count in hash table */ bool flow_position[NFP_NET_FLOW_LIMIT]; /**< Flow position array */ }; diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c index b0d1a57d99..74dd67abd4 100644 --- a/drivers/net/nfp/nfp_net_flow.c +++ b/drivers/net/nfp/nfp_net_flow.c @@ -178,7 +178,8 @@ nfp_net_flow_free(struct nfp_net_priv *priv, static int nfp_net_flow_calculate_items(const struct rte_flow_item items[], - uint32_t *match_len) + uint32_t *match_len, + uint32_t *item_type) { int ret = -EINVAL; const struct rte_flow_item *item; @@ -188,15 +189,18 @@ nfp_net_flow_calculate_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_ETH: PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_ETH detected"); *match_len = sizeof(struct nfp_net_cmsg_match_eth); + *item_type = RTE_FLOW_ITEM_TYPE_ETH; ret = 0; break; case RTE_FLOW_ITEM_TYPE_IPV4: PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected"); *match_len = sizeof(struct nfp_net_cmsg_match_v4); + *item_type = RTE_FLOW_ITEM_TYPE_IPV4; return 0; case RTE_FLOW_ITEM_TYPE_IPV6: PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected"); *match_len = sizeof(struct nfp_net_cmsg_match_v6); + *item_type = RTE_FLOW_ITEM_TYPE_IPV6; return 0; default: PMD_DRV_LOG(ERR, "Can't calculate match length"); @@ -643,6 +647,66 @@ nfp_net_flow_process_priority(struct rte_flow *nfp_flow, } } +static int +nfp_net_flow_check_count(struct nfp_net_flow_count *flow_count, + uint32_t item_type) +{ + int ret = 0; + + switch (item_type) { + case RTE_FLOW_ITEM_TYPE_ETH: + if (flow_count->eth_count >= NFP_NET_ETH_FLOW_LIMIT) + ret = -ENOSPC; + break; + case RTE_FLOW_ITEM_TYPE_IPV4: + if (flow_count->ipv4_count >= NFP_NET_IPV4_FLOW_LIMIT) + ret = -ENOSPC; + break; + case RTE_FLOW_ITEM_TYPE_IPV6: + if (flow_count->ipv6_count >= NFP_NET_IPV6_FLOW_LIMIT) + ret = -ENOSPC; + break; + default: + ret = -ENOTSUP; + break; + } + + return ret; +} + +static int +nfp_net_flow_calculate_count(struct rte_flow *nfp_flow, + struct nfp_net_flow_count *flow_count, + bool delete_flag) +{ + uint16_t *count; + + switch (nfp_flow->payload.cmsg_type) { + case NFP_NET_CFG_MBOX_CMD_FS_ADD_V4: + case NFP_NET_CFG_MBOX_CMD_FS_DEL_V4: + count = &flow_count->ipv4_count; + break; + case NFP_NET_CFG_MBOX_CMD_FS_ADD_V6: + case NFP_NET_CFG_MBOX_CMD_FS_DEL_V6: + count = &flow_count->ipv6_count; + break; + case NFP_NET_CFG_MBOX_CMD_FS_ADD_ETHTYPE: + case NFP_NET_CFG_MBOX_CMD_FS_DEL_ETHTYPE: + count = &flow_count->eth_count; + break; + default: + PMD_DRV_LOG(ERR, "Flow count calculate failed."); + return -EINVAL; + } + + if (delete_flag) + (*count)--; + else + (*count)++; + + return 0; +} + static struct rte_flow * nfp_net_flow_setup(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -652,6 +716,7 @@ nfp_net_flow_setup(struct rte_eth_dev *dev, int ret; char *hash_data; uint32_t port_id; + uint32_t item_type; uint32_t action_len; struct nfp_net_hw *hw; uint32_t match_len = 0; @@ -666,12 +731,18 @@ nfp_net_flow_setup(struct rte_eth_dev *dev, app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(hw_priv->pf_dev->app_fw_priv); priv = app_fw_nic->ports[hw->idx]->priv; - ret = nfp_net_flow_calculate_items(items, &match_len); + ret = nfp_net_flow_calculate_items(items, &match_len, &item_type); if (ret != 0) { PMD_DRV_LOG(ERR, "Key layers calculate failed."); return NULL; } + ret = nfp_net_flow_check_count(&priv->flow_count, item_type); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Flow count check failed."); + return NULL; + } + action_len = sizeof(struct nfp_net_cmsg_action); port_id = ((struct nfp_net_hw *)dev->data->dev_private)->nfp_idx; @@ -705,7 +776,11 @@ nfp_net_flow_setup(struct rte_eth_dev *dev, goto free_flow; } - priv->flow_count++; + ret = nfp_net_flow_calculate_count(nfp_flow, &priv->flow_count, false); + if (ret != 0) { + PMD_DRV_LOG(ERR, "NFP flow calculate count failed."); + goto free_flow; + } nfp_net_flow_process_priority(nfp_flow, match_len); @@ -719,11 +794,9 @@ nfp_net_flow_setup(struct rte_eth_dev *dev, static int nfp_net_flow_teardown(struct nfp_net_priv *priv, - __rte_unused struct rte_flow *nfp_flow) + struct rte_flow *nfp_flow) { - priv->flow_count--; - - return 0; + return nfp_net_flow_calculate_count(nfp_flow, &priv->flow_count, true); } static int -- 2.39.1