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 18F4645BC0; Tue, 29 Oct 2024 18:17:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3644E42F00; Tue, 29 Oct 2024 18:17:03 +0100 (CET) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 3333E42FFF for ; Tue, 29 Oct 2024 18:16:58 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2232.outbound.protection.outlook.com [104.47.51.232]) by mx-outbound17-86.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 17:16:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RstMdyUOsiWfwbsG4sPrOmFZ2l8flUYeE3OnIAXvyWNoeAkD250CKruxY2K3szphv/4XvMk4+AfTpMeMzHdEm74ukRsnQPKGfiuYlnI4JjgAXozP3k8NouM0NckGettoAhDIXXNpLNuZG1HstpZxQvYDxhlo/IfAaRS6sQCeSozVyZdiRwfAbP/O/foPJT4ZWPYo5Uj099hwk43z9FjUTVQj77XNv6Znc3Q/D7BQB9EZzBEDMVGuSxMRaU6jdrJvNwPt2CojZmqpFB0gZuf/aVqpDoDbRjKhP6wGl8Eu4aD4JOZ3ejp6T2USNKpwLUiogWvM4As2o31Rrgnr38j2Nw== 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=doIiJQohRBNk+wwyanYT1Bd7IPVTDvhXSoBbh8YbSmQ=; b=SQpt/kZJEakM+0ILzX/7Wp0qteF4L8MzEvqBkD6tQh2f1uO2GwykzTdwXn4Ibn3a4ZEB6DvNxFDGGsVizvaog/hKqfA/gLdwZEnpxDTFee0oCPqSYgREppruWVyW4+34sLW5Sq/euax/jMvIrtWHv6mLNHWEp0bk7CiG/+Ur+5kamn5Ctj5TqXxIlpfaVpAZPHWFp4zXJPtLXRnQW+eig2vzOnvjuD0nYsRjrmBaZSD2jCuXDbgTJ1b96E+1POcx72bu6+1uc7o5YQ7u/2zHo2fZmYdTo82n3zmtXSzgZgALrfQpGsxT3l1/t3ZYtms1JIA+4H9bAgwV6DTqN1DvaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=doIiJQohRBNk+wwyanYT1Bd7IPVTDvhXSoBbh8YbSmQ=; b=O9CuAsoQ/KHUCMofItLlYvJOIhurtoi3QEUDNj4SdJQCYdd0KLU0mJHskeDUkQ7hlO5V9KCNm3/DmEMEGAG2mmcFT/BPdfv8zPLjeFAr9cBgAvCGb/TqQrYujJgib0knqke8RxhRLW/PEzQt10LGTosCN6pf1Z45f7g/NycWFSY= Received: from DUZPR01CA0193.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::14) by PA1P190MB2143.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:449::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Tue, 29 Oct 2024 16:44:08 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::55) by DUZPR01CA0193.outlook.office365.com (2603:10a6:10:4b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:44:08 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:44:08 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org, Danylo Vodopianov Subject: [PATCH v4 76/86] net/ntnic: flow update was added Date: Tue, 29 Oct 2024 17:42:20 +0100 Message-ID: <20241029164243.1648775-77-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA1P190MB2143:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 8a2247a1-f466-4f9c-b352-08dcf838e892 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?78weCFkEdH58tc6xiBnEA5X3krFEskDQumazzbW3iw6AhJikcsw2mUyDj9Hx?= =?us-ascii?Q?0qgEF6kdyMoyjz9otanjLtunYPlLXdYIrGm27qbjZKuNd2yH3PbQOKDiv8ea?= =?us-ascii?Q?Uh+rEWSPeQiKNDBw8iO62m5nhIR4GQfjiX0Wg/cacbhMflfLaAfLcWJMhUqR?= =?us-ascii?Q?1cVMQyCmdfhEYaXWd2xUnMFpxjxyU7E13fY8f95px98DIWN0iv6l1pHk5lsJ?= =?us-ascii?Q?JOb47Xgbm3YNhV0fVaJ0Nqh5EBdb+qeXVLaAh4SsD7+ydcNiRHJ7q1KXWFQM?= =?us-ascii?Q?bjviN0B3TNJe87FrXs/kOsbD9HiATJBZiKj+PhGwiuYdfId50AVKMBS8TBUW?= =?us-ascii?Q?9wAgp0j3JLfNj6cvHHkQhxwr2QZk9x35gCEPcheosDOWTk6DjlrA8xt3ObQx?= =?us-ascii?Q?5ydV9PJQVyl/wxCPP4VgMhVVTzgDQIiOy7tOrC6JLygSnvbUHAIP4nF+AFvx?= =?us-ascii?Q?jhwKsdhbPEd4V2LknGmbMGHDteTjnanb0Sl5044v7ouZ/I6x+R1FZ4T8vXxB?= =?us-ascii?Q?AzGnG+qiQJUkLmoKr5HL0OrMpB/zllPbXbILGGSQMD0w6C4VU9SiC5+la2JW?= =?us-ascii?Q?3jcRuQmzTTJ3AXIiBhCV7WmctmcA8xeDveN1fF+b8Sok08zmDk+nCrwcuhog?= =?us-ascii?Q?Jxup/K4hK+79Sc5F27GYRUlxL/sIRLOOieFNGCitBxXZxhAmHxxgieO1uHOa?= =?us-ascii?Q?e/jqziwH8TQpjA8wjml18MIggQziyg8FcqQLg8kRKgjw/aSSEuA8W5TcL2MQ?= =?us-ascii?Q?/FljkAgq7ebZJIREj5zf1WWQpuCxBTAhhjx+jcfo7JPtp/HmSmwaM1GfB8+8?= =?us-ascii?Q?Kg9/X7fJP4MDkS/JrjdHqCd/lp1at6MUGjkYbhUaGvMAMqy2J9qxpH1w+T6I?= =?us-ascii?Q?9MtOVYnCnktRf45x1BLG9BcqysKAfnb/0r7cPxzW2KureqHn0IVGl1yv3bw8?= =?us-ascii?Q?xSHb736PNsAtCFP/iy7wRjyMobXaRdtHN6FAWWmZoykn+PbaLEaVlnvojW9X?= =?us-ascii?Q?IlHOVBDD+IxVDTYWuiRCwDy3zyq1mkgHuM7TEpShV23l9d6I+PeabzVCdxId?= =?us-ascii?Q?PQz1mO/Xcs1pEC3Jq8mhmI52V7s6yNYYkp2DZaR05JHmmfJPcWKR2j5pMU9y?= =?us-ascii?Q?uFYQHISTu82N4osc2QazRaTtNV7BaWlm6SBIkeRJI6r/SbPSB+XwrSxwv8fV?= =?us-ascii?Q?cL7vIqRZHOgaJSq3BSSHvHTqGAtSoUYSJkhyXN4OsdmzlU9Sw1CnC75vKzFm?= =?us-ascii?Q?1beFBlpmfMHuE0uL9W0vcJxuwrLjkmhld3HKTwJpscS6Djfgs/2i1FfBpYbn?= =?us-ascii?Q?riiESopxaxIecDs4en/Kk0PMat+02l2iU45F0Rg98ZOY4x6NhMSnyi1oDiPV?= =?us-ascii?Q?nRRkgZaj8F5jVVXG9KAcY/PTiJ4LOX2ZOG+0on3SEcCFe66A4g=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6b3Q77gmzXPHLp5RjzguryMRzFjetXXY20T89bBpEpl2jK1Y+w8wmmaGdDXouyi0FqqiJhmL2j5HLfXOa8tMu2AtH2//fSGLALrNiUYdHktEEaEJg6NKy7mVVDJR6slvNxXNrpYSB8MklZ6PWXAmpPoQtAwdnC7VKmsLnWdwpbi1h1YwFUQkP9VRsDRfgi/WM9apab++ZGhS/SWgcy/Z1hQdHXy6s9x9iM8LaGUsuLyt7QQs3io1t1qGvLItxDyHcYbfEdEBwnq/n73b8sPdkCOf5LWZCotGBsiahwImExIY8vrYKOcqLMkKBkiRvVkRQpDkDWQk7lKltgV2xCPVJEJg2Mq74I6jaHeRNd0flKsLxxI6yin9Y1WsPLiEsYObZMpHo47Ae9mkjyLBRqwF9L6JFW02bydiz6zNaXlyF5i2zdhIgr+IS81G638giANc1WuU38frssfNQcsiTT28NZPC4StO6k59AoZTl2MuzLfzGSTKu9kAmOOxjgUU2lsLWzKboGWEYk4qH8L5HNd4fGLLVfRGMjQJFvxsSkcvjXRP6eOLQ38oAQpvNlu0c698tFzcHO/xCSyMh6rM6ORvkwlluTHMuCuTOFCAmRUiLIQP3OklfdEK+7m/IZ15Dq+yo3zdB9lA+8MTHY+stQb01vQtpqkRapLg4baLCsJ84UU= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:44:08.0584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a2247a1-f466-4f9c-b352-08dcf838e892 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1P190MB2143 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222215-304438-12711-32021-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.232 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaGppZAVgZQ0DjR3MTQMMUk2d DQ1MzYyNIQKGBsamKYamRibJJibKlUGwsAY4RRn0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan14-117.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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: Danylo Vodopianov Flow action update was implemented. Signed-off-by: Danylo Vodopianov --- .../profile_inline/flow_api_profile_inline.c | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 88b716d836..98bfc01539 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -15,6 +15,7 @@ #include "flow_api_hw_db_inline.h" #include "flow_api_profile_inline_config.h" #include "flow_id_table.h" +#include "rte_flow.h" #include "stream_binary_flow_api.h" #include "flow_api_profile_inline.h" @@ -36,6 +37,7 @@ #define NT_FLM_UNHANDLED_FLOW_TYPE 1 #define NT_FLM_OP_UNLEARN 0 #define NT_FLM_OP_LEARN 1 +#define NT_FLM_OP_RELEARN 2 #define NT_FLM_VIOLATING_MBR_FLOW_TYPE 15 #define NT_VIOLATING_MBR_CFN 0 @@ -4385,6 +4387,168 @@ int flow_flush_profile_inline(struct flow_eth_dev *dev, return err; } +int flow_actions_update_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + const struct rte_flow_action action[], + struct rte_flow_error *error) +{ + assert(dev); + assert(flow); + + uint32_t num_dest_port = 0; + uint32_t num_queues = 0; + + int group = (int)flow->flm_kid - 2; + + flow_nic_set_error(ERR_SUCCESS, error); + + if (flow->type != FLOW_HANDLE_TYPE_FLM) { + NT_LOG(ERR, FILTER, + "Flow actions update not supported for group 0 or default flows"); + flow_nic_set_error(ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM, error); + return -1; + } + + struct nic_flow_def *fd = allocate_nic_flow_def(); + + if (fd == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate nic_flow_def"; + return -1; + } + + fd->non_empty = 1; + + int res = + interpret_flow_actions(dev, action, NULL, fd, error, &num_dest_port, &num_queues); + + if (res) { + free(fd); + return -1; + } + + pthread_mutex_lock(&dev->ndev->mtx); + + /* Setup new actions */ + uint32_t local_idx_counter = 0; + uint32_t local_idxs[RES_COUNT]; + memset(local_idxs, 0x0, sizeof(uint32_t) * RES_COUNT); + + struct hw_db_inline_qsl_data qsl_data; + setup_db_qsl_data(fd, &qsl_data, num_dest_port, num_queues); + + struct hw_db_inline_hsh_data hsh_data; + setup_db_hsh_data(fd, &hsh_data); + + { + uint32_t flm_ft = 0; + uint32_t flm_scrub = 0; + + /* Setup FLM RCP */ + const struct hw_db_inline_flm_rcp_data *flm_data = + hw_db_inline_find_data(dev->ndev, dev->ndev->hw_db_handle, + HW_DB_IDX_TYPE_FLM_RCP, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter); + + if (flm_data == NULL) { + NT_LOG(ERR, FILTER, "Could not retrieve FLM RPC resource"); + flow_nic_set_error(ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM, error); + goto error_out; + } + + struct hw_db_flm_idx flm_idx = + hw_db_inline_flm_add(dev->ndev, dev->ndev->hw_db_handle, flm_data, group); + + local_idxs[local_idx_counter++] = flm_idx.raw; + + if (flm_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM RPC resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + if (setup_flow_flm_actions(dev, fd, &qsl_data, &hsh_data, group, local_idxs, + &local_idx_counter, &flow->flm_rpl_ext_ptr, &flm_ft, + &flm_scrub, error)) { + goto error_out; + } + + /* Update flow_handle */ + for (int i = 0; i < MAX_FLM_MTRS_SUPPORTED; ++i) { + struct flm_flow_mtr_handle_s *handle = dev->ndev->flm_mtr_handle; + struct flm_mtr_stat_s *mtr_stat = + handle->port_stats[flow->caller_id]->stats; + flow->flm_mtr_ids[i] = + fd->mtr_ids[i] == UINT32_MAX ? 0 : mtr_stat[fd->mtr_ids[i]].flm_id; + } + + for (unsigned int i = 0; i < fd->modify_field_count; ++i) { + switch (fd->modify_field[i].select) { + case CPY_SELECT_DSCP_IPV4: + + /* fallthrough */ + case CPY_SELECT_DSCP_IPV6: + flow->flm_dscp = fd->modify_field[i].value8[0]; + break; + + case CPY_SELECT_RQI_QFI: + flow->flm_rqi = (fd->modify_field[i].value8[0] >> 6) & 0x1; + flow->flm_qfi = fd->modify_field[i].value8[0] & 0x3f; + break; + + case CPY_SELECT_IPV4: + flow->flm_nat_ipv4 = ntohl(fd->modify_field[i].value32[0]); + break; + + case CPY_SELECT_PORT: + flow->flm_nat_port = ntohs(fd->modify_field[i].value16[0]); + break; + + case CPY_SELECT_TEID: + flow->flm_teid = ntohl(fd->modify_field[i].value32[0]); + break; + + default: + NT_LOG(DBG, FILTER, "Unknown modify field: %d", + fd->modify_field[i].select); + break; + } + } + + flow->flm_ft = (uint8_t)flm_ft; + flow->flm_scrub_prof = (uint8_t)flm_scrub; + flow->context = fd->age.context; + + /* Program flow */ + flm_flow_programming(flow, NT_FLM_OP_RELEARN); + + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter); + memset(flow->flm_db_idxs, 0x0, sizeof(struct hw_db_idx) * RES_COUNT); + + flow->flm_db_idx_counter = local_idx_counter; + + for (int i = 0; i < RES_COUNT; ++i) + flow->flm_db_idxs[i] = local_idxs[i]; + } + + pthread_mutex_unlock(&dev->ndev->mtx); + + free(fd); + return 0; + +error_out: + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, (struct hw_db_idx *)local_idxs, + local_idx_counter); + + pthread_mutex_unlock(&dev->ndev->mtx); + + free(fd); + return -1; +} + static __rte_always_inline bool all_bits_enabled(uint64_t hash_mask, uint64_t hash_bits) { return (hash_mask & hash_bits) == hash_bits; @@ -5328,6 +5492,7 @@ static const struct profile_inline_ops ops = { .flow_create_profile_inline = flow_create_profile_inline, .flow_destroy_profile_inline = flow_destroy_profile_inline, .flow_flush_profile_inline = flow_flush_profile_inline, + .flow_actions_update_profile_inline = flow_actions_update_profile_inline, .flow_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, .flow_get_aged_flows_profile_inline = flow_get_aged_flows_profile_inline, /* -- 2.45.0