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 225D345BC0; Tue, 29 Oct 2024 17:43:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B3BC42EDC; Tue, 29 Oct 2024 17:43:08 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 62C9942EB8 for ; Tue, 29 Oct 2024 17:43:00 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cmQiLJUbHrRulutxP6vuprgjpka6T8FyDC3pJqLqCZavK9+//jesOw0qgRWTOZiDrww+5Ovlz7AWrLiE7gu16Ubkkrfze0NKSctXPQVGjGSpypqr8d7GpwE1QqMjwvVeo21opdCxIVxKRwbNf99tdBfOW0E1bJGc5ZArZOLhk9x0Z6wKMZG4ekCq14ESW9+JFQWU/M4aqywFM1St/M771R4LZoW+wJnFI1hk6Z7RZIMuS1VyTgpo7uaXfNdpHtobewHi77cvwsZmjT9yDduNl03bAg+WoRmq5HPPgVesDikocF1nt42Ervn/fuUwotg+Rk+ot8L0P9KaHYqEu/YkyQ== 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=2N7uaTPehvs5LqHI2EQnUbggrT0QCXJauQ47BQlehew=; b=qyTzBL89nV7e7duhFzAdoZhrIgV2fHfHZNsczLKmvJx/o/bdpG1NQj4ujp8ioyfSYKAU0uBdwAjm6Hb2hQdZ1/rM3ZJicFHmjZcPGouT/1WJvEoxg1yoCP/CMCCUCWOA7Cu/6y32mCFOP92zJrXjyG+F3cPsBn4TRdDq5kVR2X+TRqF07MAI8ffmdYX75A9EQN+DjzsVaBW4wTJM7C7EkRo5XikKlds0+p/M3Fii30UKCj7YkjbPCZs6wCx6s791kymgj9K3RCbArfxypNHnMCczZixBOHcmsQvux7Vpk1cw0aX/YlmobiEwWEOXoZKnMPgwWq6SiwMrDxnYJNHCgw== 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=2N7uaTPehvs5LqHI2EQnUbggrT0QCXJauQ47BQlehew=; b=lyE3aoZ50oi49cdyqvpgy608SRx/uFHrf8NBAljHamAWhICZ6A5e5M+6yB/s02N+IoZBVA16aM9STapu5t+Lph+8yZ9RBC75R0aIsyLQzMDX16/taoc/HyiirrU+VrEtgsf1pnjkK4BpSr1Lrqoq0oI/3FIZBey/rPsN1pzF+m4= Received: from DUZPR01CA0187.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::17) by PA1P190MB2248.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:482::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Tue, 29 Oct 2024 16:42:56 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::b5) by DUZPR01CA0187.outlook.office365.com (2603:10a6:10:4b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 16:42:55 +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:42:55 +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 Subject: [PATCH v4 09/86] net/ntnic: add infrastructure for for flow actions and items Date: Tue, 29 Oct 2024 17:41:13 +0100 Message-ID: <20241029164243.1648775-10-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_|PA1P190MB2248:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: aa9986f0-b034-4721-fd05-08dcf838bd67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?x5TMtXLc4taSMc4IZKMzklAz+mwSonOBJ0bEAfJZsOYyh0OoqR3y3QaYiprB?= =?us-ascii?Q?T98396q1YTceF2a0NnR6mB7X932DwJhyKl+GjeZvvwSwje5hCG3a44i006kh?= =?us-ascii?Q?oF5mYEmSyzxoO1ySPgI3B7CkhCruZV7SeLFzUX42hNBeG7E3BbKkXf9mM/+1?= =?us-ascii?Q?VrAvZTBzKl0dAnrAOC0KmhHH4P4OLUEpUqZ+NRPll8M+ziuOVje5nSa0zSPJ?= =?us-ascii?Q?lLLGaBYfVSJtHfu2sw7/cc/xsdrlwS9ybjbwMJlNzu8Tuu/UFZTj3NB/iJAL?= =?us-ascii?Q?Z2J2yccsr0cNN/BVgZvioZsw88gNeha/KuDtxnaoLGCOkk3TV+vBDOaqhwfH?= =?us-ascii?Q?OPZXscNfHGMTmv5eQ9qoo2KJ9z/zjDLIeGZE8i3yDsOS3hnb+hmTXHFl/76Q?= =?us-ascii?Q?enhVmj187qPt0S7NlY/YcLHdTi+dX6OkPNBS0kVZYHW30+oGQLcu0g67MFEv?= =?us-ascii?Q?9b2bqlbaz6NToUNTRzu1v4q83cDGlMQ00WJd0BfIjLoWYhFFwXzbvvq8X4t/?= =?us-ascii?Q?eYb9ijXdj82IwTfLr7PczBvGVLlyFTX/wBfGg/WloR3fmYdi007aX/ogVhxf?= =?us-ascii?Q?pstP3QHEmg4w7h+xXhOiuQyMGWQ92eE5o30TxfrcxyUADlwEsgDPT+ZMGUYT?= =?us-ascii?Q?ofPfnaK5lH/RY3B11n/5byUjeoWB8uqKbn72D7g49kHheb6dztYrI0bry/2M?= =?us-ascii?Q?nSn3QxOCTsy8ODHrGh1kY9BIfxSsBp+4c6WHKlpnA5TTwmz9PblcE3DJwmwb?= =?us-ascii?Q?hgoXPfLa21uYrO0D7ZO6jC7LJBZ+qTUw4AKim0+EqYprfnT26gbnt4/OJD/V?= =?us-ascii?Q?2f5+cslsRm/XvQmxP0AY3ZN9FZpzU0SjTHqAfWkYzIqtUcKst1iziCFhSU9x?= =?us-ascii?Q?ef+Pj9ziLp/a/FD1CjC1t3KjS6OZDpdWa0RBsROLah46LjfRoqQNXjoIKVyg?= =?us-ascii?Q?iLQD9wwzeFwkzZ4ThqQotM07KHeqCfXrNodiPsZV9QCxfG70B502ZiSMpNFz?= =?us-ascii?Q?uYgPKLdlJLZ1219yVRHQTxVuneQ0HgqUQRjjiJ9qcyVT4Fj6g3CL8u1zPNUJ?= =?us-ascii?Q?bVj7c6AsInF8QJNmax3BpT8i+jcgEZWErq29KZGTpOjcChl2gEf+g2pQgZPa?= =?us-ascii?Q?WFsg8DaUPad/0E+sgtD4qaRwnR5YLv36xRQwE08meaBur8gLaMnnBUynouwH?= =?us-ascii?Q?keckLp6lNL/CARRPQLA1tbUi6tx5+YGtg7XmKBjlAzVsyp/yg9Wq2ObhSAKm?= =?us-ascii?Q?zPDuiejiDdHQcVnkdffTmApnJDNwq4NbZ4SV5ZUk9+K9AYF1W3lmXAT0HGuN?= =?us-ascii?Q?dqn6QJ/fdNRxdRRoYimKhtW6VVUx7U7SOdnuQgB9qRUscHRsEc4Td5MV5/n4?= =?us-ascii?Q?QAIR4Gyh5sw7yQPekItSgZzRpDAEwaAbFuvsqjmVF7BgfxSLSQ=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)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4YNB8vzKL89/Qrpr++FXPDrNypRXAE+3iIGnlhvnzHa+C6qZotIGKTECBsB0+kW3bfoXi8e4v20mc7nX2QpEXazfwSuUPuOoZ0AepZj6xLVU02SbmrjRD1lgozgbplmSOiH1svjGqNw8181tEdO8YPnDsKor/AAu0BULiKGdjcBddOqnsDYmgnnGjExFgEQUgZv/Lw51xO5JJ0m9PtR776rUm6TNxcB7SJK0kUpt4cf2OrdYGtx4POY3/K50jh41LMzL3CsRxx7WNI/nmRjlIaBiGnOsZCi05xv3qkTuyElSiwFdd4jVrWTjmFiDNDTXIyp1B/aloiFxF4WIuJMTcDFeUIiR+HqsdH1r95HK7zLPnmnCYeTnvdx6KOjChW3mnGdkZkwX3e1I4ZOc3q67HewGMJWk+EMy9gvCUY+NH2NKxi0kwPtlP6VhHGT6UJd0XrEqVddN+mGX56xeSI/r2H35/6uZAAzItthhsafAVm+AVpuTKlkvKMHAcvOlgZEEi3YQdscWRWG6MY+08D3s35d1jqIMxdA/WURmwQ37NTzAVyxjehsRTk6uAyZfbd5fg0XYxKxT/Cnaq6ANsB18G421Mpw0cKkfroXMJnLXg4L1VACrKtmnstKOPn/QY8E4v6nFRiqVResicsUFSi6pePf5ZiDHGP/95a+skvQ52Bw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:55.6208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa9986f0-b034-4721-fd05-08dcf838bd67 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: PA1P190MB2248 X-BESS-ID: 1730220177-303097-12765-29315-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.233 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGFpYWQGYGUDTVICnVINXAIt UwycQizdTQwMTC2MjUwNgiNckoNcXSVKk2FgDHRmWjQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan23-32.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_SC1_TG070 META: Custom Rule TG070 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_SC1_TG070, 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 Add etities(utilities, structures, etc) required for flow API Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/include/flow_api.h | 34 ++++++++ drivers/net/ntnic/include/flow_api_engine.h | 46 +++++++++++ drivers/net/ntnic/include/hw_mod_backend.h | 33 ++++++++ drivers/net/ntnic/nthw/flow_api/flow_km.c | 81 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 68 +++++++++++++++- 5 files changed, 258 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 667dad6d5f..7f031ccda8 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -85,13 +85,47 @@ struct flow_nic_dev { enum flow_nic_err_msg_e { ERR_SUCCESS = 0, ERR_FAILED = 1, + ERR_MEMORY = 2, ERR_OUTPUT_TOO_MANY = 3, + ERR_RSS_TOO_MANY_QUEUES = 4, + ERR_VLAN_TYPE_NOT_SUPPORTED = 5, + ERR_VXLAN_HEADER_NOT_ACCEPTED = 6, + ERR_VXLAN_POP_INVALID_RECIRC_PORT = 7, + ERR_VXLAN_POP_FAILED_CREATING_VTEP = 8, + ERR_MATCH_VLAN_TOO_MANY = 9, + ERR_MATCH_INVALID_IPV6_HDR = 10, + ERR_MATCH_TOO_MANY_TUNNEL_PORTS = 11, ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM = 12, + ERR_MATCH_FAILED_BY_HW_LIMITS = 13, ERR_MATCH_RESOURCE_EXHAUSTION = 14, + ERR_MATCH_FAILED_TOO_COMPLEX = 15, + ERR_ACTION_REPLICATION_FAILED = 16, + ERR_ACTION_OUTPUT_RESOURCE_EXHAUSTION = 17, + ERR_ACTION_TUNNEL_HEADER_PUSH_OUTPUT_LIMIT = 18, + ERR_ACTION_INLINE_MOD_RESOURCE_EXHAUSTION = 19, + ERR_ACTION_RETRANSMIT_RESOURCE_EXHAUSTION = 20, + ERR_ACTION_FLOW_COUNTER_EXHAUSTION = 21, + ERR_ACTION_INTERNAL_RESOURCE_EXHAUSTION = 22, + ERR_INTERNAL_QSL_COMPARE_FAILED = 23, + ERR_INTERNAL_CAT_FUNC_REUSE_FAILED = 24, + ERR_MATCH_ENTROPHY_FAILED = 25, + ERR_MATCH_CAM_EXHAUSTED = 26, + ERR_INTERNAL_VIRTUAL_PORT_CREATION_FAILED = 27, ERR_ACTION_UNSUPPORTED = 28, ERR_REMOVE_FLOW_FAILED = 29, + ERR_ACTION_NO_OUTPUT_DEFINED_USE_DEFAULT = 30, + ERR_ACTION_NO_OUTPUT_QUEUE_FOUND = 31, + ERR_MATCH_UNSUPPORTED_ETHER_TYPE = 32, ERR_OUTPUT_INVALID = 33, + ERR_MATCH_PARTIAL_OFFLOAD_NOT_SUPPORTED = 34, + ERR_MATCH_CAT_CAM_EXHAUSTED = 35, + ERR_MATCH_KCC_KEY_CLASH = 36, + ERR_MATCH_CAT_CAM_FAILED = 37, + ERR_PARTIAL_FLOW_MARK_TOO_BIG = 38, + ERR_FLOW_PRIORITY_VALUE_INVALID = 39, ERR_ACTION_MULTIPLE_PORT_ID_UNSUPPORTED = 40, + ERR_RSS_TOO_LONG_KEY = 41, + ERR_ACTION_AGE_UNSUPPORTED_GROUP_0 = 42, ERR_MSG_NO_MSG }; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index b8da5eafba..13fad2760a 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -54,6 +54,30 @@ enum res_type_e { #define MAX_CPY_WRITERS_SUPPORTED 8 +#define MAX_MATCH_FIELDS 16 + +struct match_elem_s { + int masked_for_tcam; /* if potentially selected for TCAM */ + uint32_t e_word[4]; + uint32_t e_mask[4]; + + int extr_start_offs_id; + int8_t rel_offs; + uint32_t word_len; +}; + +struct km_flow_def_s { + struct flow_api_backend_s *be; + + /* For collect flow elements and sorting */ + struct match_elem_s match[MAX_MATCH_FIELDS]; + int num_ftype_elem; + + /* Flow information */ + /* HW input port ID needed for compare. In port must be identical on flow types */ + uint32_t port_id; +}; + enum flow_port_type_e { PORT_NONE, /* not defined or drop */ PORT_INTERNAL, /* no queues attached */ @@ -99,6 +123,25 @@ struct nic_flow_def { uint32_t jump_to_group; int full_offload; + + /* + * Modify field + */ + struct { + uint32_t select; + union { + uint8_t value8[16]; + uint16_t value16[8]; + uint32_t value32[4]; + }; + } modify_field[MAX_CPY_WRITERS_SUPPORTED]; + + uint32_t modify_field_count; + + /* + * Key Matcher flow definitions + */ + struct km_flow_def_s km; }; enum flow_handle_type { @@ -159,6 +202,9 @@ struct flow_handle { void km_free_ndev_resource_management(void **handle); +int km_add_match_elem(struct km_flow_def_s *km, uint32_t e_word[4], uint32_t e_mask[4], + uint32_t word_len, enum frame_offs_e start, int8_t offset); + void kcc_free_ndev_resource_management(void **handle); /* diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 34154c65f8..99b207a01c 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -133,6 +133,39 @@ enum km_flm_if_select_e { unsigned int alloced_size; \ int debug +enum { + PROT_OTHER = 0, + PROT_L2_ETH2 = 1, +}; + +enum { + PROT_L3_IPV4 = 1, +}; + +enum { + PROT_L4_ICMP = 4 +}; + +enum { + PROT_TUN_L3_OTHER = 0, + PROT_TUN_L3_IPV4 = 1, +}; + +enum { + PROT_TUN_L4_OTHER = 0, + PROT_TUN_L4_ICMP = 4 +}; + + +enum { + CPY_SELECT_DSCP_IPV4 = 0, + CPY_SELECT_DSCP_IPV6 = 1, + CPY_SELECT_RQI_QFI = 2, + CPY_SELECT_IPV4 = 3, + CPY_SELECT_PORT = 4, + CPY_SELECT_TEID = 5, +}; + struct common_func_s { COMMON_FUNC_INFO_S; }; diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c index e04cd5e857..237e9f7b4e 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_km.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c @@ -3,10 +3,38 @@ * Copyright(c) 2023 Napatech A/S */ +#include #include #include "hw_mod_backend.h" #include "flow_api_engine.h" +#include "nt_util.h" + +#define NUM_CAM_MASKS (ARRAY_SIZE(cam_masks)) + +static const struct cam_match_masks_s { + uint32_t word_len; + uint32_t key_mask[4]; +} cam_masks[] = { + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } }, /* IP6_SRC, IP6_DST */ + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0xffff0000 } }, /* DMAC,SMAC,ethtype */ + { 4, { 0xffffffff, 0xffff0000, 0x00000000, 0xffff0000 } }, /* DMAC,ethtype */ + { 4, { 0x00000000, 0x0000ffff, 0xffffffff, 0xffff0000 } }, /* SMAC,ethtype */ + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000 } }, /* ETH_128 */ + { 2, { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 } }, /* IP4_COMBINED */ + /* + * ETH_TYPE, IP4_TTL_PROTO, IP4_SRC, IP4_DST, IP6_FLOW_TC, + * IP6_NEXT_HDR_HOP, TP_PORT_COMBINED, SIDEBAND_VNI + */ + { 1, { 0xffffffff, 0x00000000, 0x00000000, 0x00000000 } }, + /* IP4_IHL_TOS, TP_PORT_SRC32_OR_ICMP, TCP_CTRL */ + { 1, { 0xffff0000, 0x00000000, 0x00000000, 0x00000000 } }, + { 1, { 0x0000ffff, 0x00000000, 0x00000000, 0x00000000 } }, /* TP_PORT_DST32 */ + /* IPv4 TOS mask bits used often by OVS */ + { 1, { 0x00030000, 0x00000000, 0x00000000, 0x00000000 } }, + /* IPv6 TOS mask bits used often by OVS */ + { 1, { 0x00300000, 0x00000000, 0x00000000, 0x00000000 } }, +}; void km_free_ndev_resource_management(void **handle) { @@ -17,3 +45,56 @@ void km_free_ndev_resource_management(void **handle) *handle = NULL; } + +int km_add_match_elem(struct km_flow_def_s *km, uint32_t e_word[4], uint32_t e_mask[4], + uint32_t word_len, enum frame_offs_e start_id, int8_t offset) +{ + /* valid word_len 1,2,4 */ + if (word_len == 3) { + word_len = 4; + e_word[3] = 0; + e_mask[3] = 0; + } + + if (word_len < 1 || word_len > 4) { + assert(0); + return -1; + } + + for (unsigned int i = 0; i < word_len; i++) { + km->match[km->num_ftype_elem].e_word[i] = e_word[i]; + km->match[km->num_ftype_elem].e_mask[i] = e_mask[i]; + } + + km->match[km->num_ftype_elem].word_len = word_len; + km->match[km->num_ftype_elem].rel_offs = offset; + km->match[km->num_ftype_elem].extr_start_offs_id = start_id; + + /* + * Determine here if this flow may better be put into TCAM + * Otherwise it will go into CAM + * This is dependent on a cam_masks list defined above + */ + km->match[km->num_ftype_elem].masked_for_tcam = 1; + + for (unsigned int msk = 0; msk < NUM_CAM_MASKS; msk++) { + if (word_len == cam_masks[msk].word_len) { + int match = 1; + + for (unsigned int wd = 0; wd < word_len; wd++) { + if (e_mask[wd] != cam_masks[msk].key_mask[wd]) { + match = 0; + break; + } + } + + if (match) { + /* Can go into CAM */ + km->match[km->num_ftype_elem].masked_for_tcam = 0; + } + } + } + + km->num_ftype_elem++; + return 0; +} 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 7f9869a511..0f136ee164 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 @@ -416,10 +416,67 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, return 0; } -static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_data __rte_unused, - uint32_t flm_key_id __rte_unused, uint32_t flm_ft __rte_unused, - uint16_t rpl_ext_ptr __rte_unused, uint32_t flm_scrub __rte_unused, - uint32_t priority __rte_unused) +static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def *fd, + const uint32_t *packet_data, uint32_t flm_key_id, uint32_t flm_ft, + uint16_t rpl_ext_ptr, uint32_t flm_scrub __rte_unused, uint32_t priority) +{ + switch (fd->l4_prot) { + case PROT_L4_ICMP: + fh->flm_prot = fd->ip_prot; + break; + + default: + switch (fd->tunnel_l4_prot) { + case PROT_TUN_L4_ICMP: + fh->flm_prot = fd->tunnel_ip_prot; + break; + + default: + fh->flm_prot = 0; + break; + } + + break; + } + + memcpy(fh->flm_data, packet_data, sizeof(uint32_t) * 10); + + fh->flm_kid = flm_key_id; + fh->flm_rpl_ext_ptr = rpl_ext_ptr; + fh->flm_prio = (uint8_t)priority; + fh->flm_ft = (uint8_t)flm_ft; + + for (unsigned int i = 0; i < fd->modify_field_count; ++i) { + switch (fd->modify_field[i].select) { + case CPY_SELECT_DSCP_IPV4: + case CPY_SELECT_RQI_QFI: + fh->flm_rqi = (fd->modify_field[i].value8[0] >> 6) & 0x1; + fh->flm_qfi = fd->modify_field[i].value8[0] & 0x3f; + break; + + case CPY_SELECT_IPV4: + fh->flm_nat_ipv4 = ntohl(fd->modify_field[i].value32[0]); + break; + + case CPY_SELECT_PORT: + fh->flm_nat_port = ntohs(fd->modify_field[i].value16[0]); + break; + + case CPY_SELECT_TEID: + fh->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; + } + } +} + +static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_data, + uint32_t flm_key_id, uint32_t flm_ft, uint16_t rpl_ext_ptr, + uint32_t flm_scrub, uint32_t priority) { struct nic_flow_def *fd; struct flow_handle fh_copy; @@ -443,6 +500,9 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d for (int i = 0; i < RES_COUNT; ++i) fh->flm_db_idxs[i] = fh_copy.db_idxs[i]; + copy_fd_to_fh_flm(fh, fd, packet_data, flm_key_id, flm_ft, rpl_ext_ptr, flm_scrub, + priority); + free(fd); return 0; -- 2.45.0