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 113F745B96; Mon, 21 Oct 2024 23:07:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2FEB40DCE; Mon, 21 Oct 2024 23:05:58 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 9C19C406B4 for ; Mon, 21 Oct 2024 23:05:46 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx-outbound19-70.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RZC9T9BF9+vXoRZwIfziekudORtRi+tuF/k1Cpc42s4Hhv/jtuLEN+k4zgPBUIHfgMr7kiQ/wbdkg1CSuT7+3vzOuIK9NORo/z7YCJBVcAT4wYrNB+mBGwagCxgU4rH6Ipakyo2bx3O9EdwuWpkYkmWeJeF8ab2MxjmCywv+OZ7r7MmQy9RUtF9zwZlq8X9Q+Aip8WTtjbnc8wKDtmrLxsFYQfLSfIGE+DUz7fUaZ3Rq/zxQxyDtUkFEE2k3lCcSDqNH5ZFeDdzeCnPhYvthFalVbISOhX61k3cbL7Ag/siE1pcNv371kBeSKRYWzfKfOmjHUjFpgCmSVXzSpKEong== 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=H0aU6yykfE4CAGDN88+VqHGjxscH+//Tc9GXWcAOGpk=; b=OhlKjo0qMQNtD3RBl6HhAhyadKvXONNu19F+uNfgh0JafNFtsugrexagmnlGKGugSlVRLCDc6isx+Ad/mouUrxqJarf0IKwlg8mX9qumyKQ6Y1mSJVj52BCIb+sF+yXdzcLX9WZpTI82nzWYH5IPbU19F98Lpindbr+G93gpAYD2AkYD0dM9VnRAgZb9KjS7xOfkaW+zXML4MLGYmOBSMVQwe3PEF2F3Sgw2RPROg7PttopXj04nXc+TDRmet/grK1pUkUMcTugZuw164yQee18hwFUQ3K+z5x0WXXF94CD7FzZHCZH/Z0iy0OR41jIjxmGobmM3DJDrJMG7oaNWWw== 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=H0aU6yykfE4CAGDN88+VqHGjxscH+//Tc9GXWcAOGpk=; b=TzkfPOMYrrwBqKbJhydHQ0zUnoQJ6n4jYcf8XBzJ3Qm1DLPhL9/U05sOY9NxH233JhS7ggZabeT2qM/rQUjDdTpMoKfr5k1PiT3XUgB6/pO7Iv0ER2y6pDR4ZvZgwrmq9ReR1dv548xdFwipPLtmok3w9MBLZeKgOzzexxQTug8= Received: from AS9PR04CA0151.eurprd04.prod.outlook.com (2603:10a6:20b:48a::21) by GV1P190MB2112.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:17b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 21:05:37 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::64) by AS9PR04CA0151.outlook.office365.com (2603:10a6:20b:48a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 21:05:37 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:05:37 +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 Subject: [PATCH v1 09/73] net/ntnic: add infrastructure for for flow actions and items Date: Mon, 21 Oct 2024 23:04:11 +0200 Message-ID: <20241021210527.2075431-10-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|GV1P190MB2112:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d316d4a5-3c88-4381-926f-08dcf2141cd7 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?LRZi85ydHeh6DoGjqhyOldDtH91J1PRolAKkNEaBrxyK5xSSiLz391lEgoSa?= =?us-ascii?Q?NxR92vLJJX7A5XW13toKWRavY3MAtZEWayee0F/Ktid6QliPLjRwCH4bvtVO?= =?us-ascii?Q?juvqGLEVqydsVEECcnHYnRKqjF7AYqYScvsFIoeCxV8hjVnOUfo6N1AB2AHE?= =?us-ascii?Q?Cj3Sw3xiDPHPCzNWOLygtG3vIpWxZRRQixs/Nh2s1Ir/ZrzVfI7+7ev3UO8m?= =?us-ascii?Q?jVn+UxXtSR5bFzPPW5JhzmaoWaMIjrVOSvHS4s8p6DOc+T5aQBL4WyffjBb1?= =?us-ascii?Q?odXbHhw9b/u8h4U7nDrWNUelXHJOTRlxDI+tQNbNb8Mza7D+zk+PDZTWYCri?= =?us-ascii?Q?XJjijIQRDcQ3Jmkc7c/O2qU/x9kA+7ZCCV+ra12rPDgQzu1jg8BDrkC5Ix7Y?= =?us-ascii?Q?2U5A/rfXO3/ONZCB7vk+skb+KeFDOQOj78Fzu3y4LoevUzKyyxpFhXfZXNFT?= =?us-ascii?Q?v3EWNVDCSMEHEEIdybX7Oio0O2y6xLoKizPNVrl5P/XjRGIDnsoPGldbhBRL?= =?us-ascii?Q?VzDIv/i3LPcBPGW8Xlwo5N7Z6Gx76qSvWwDm/5KVxMsJ1u8kjcWs1RMgblv5?= =?us-ascii?Q?T6a5p7Ts1t71kpu3zerytv2y7gOVNHPIbtmUDZ8ft3u2axQRcqrll9vnAJ6L?= =?us-ascii?Q?e2QdCIdcXEjhbRYFy9aCzAtCcqJ8HR9od2Al9msZ0yNZzlP/HDAa7lxr5Kgh?= =?us-ascii?Q?x/lUJRJtvWCvcqsQ5ICx25DSGB0XIed9KkU2+9xPQLDWjvSLbJswadXKtLxR?= =?us-ascii?Q?sWVxg833TmDtAljj0sqZ6F3E2+adKpC+MqH1anAfWpIyUyfUVuMcC6aRDODz?= =?us-ascii?Q?6XjfuhVkXPuA/sxtRAY33f88XNYEZStoH56NU0O8QE41EZQ4SPge93SlSfms?= =?us-ascii?Q?jWjiUGMCKNjG360lzQ+mXR/Ed5Tu8Bn+LQeF121gtw/FYJG8AeZ7QhCxfr4S?= =?us-ascii?Q?w3XyJOO1yrQpZ0LpfP8JXLeSXg24soajRIJ7VlsSnY2JH+WVsrLd90VRbl8K?= =?us-ascii?Q?yVCTmeDLCYQWHY/WsBgSxrQNiAdl2ukjIPd2LTGMbOmxkyzRc7vH6awulX3C?= =?us-ascii?Q?WctAy8Z4PZcsge7SO5naj283d3Yr3zYGIGOj8wYz6bDjLeLxM/812loWb2Tl?= =?us-ascii?Q?5bq0q8PWJW7wqPQwrTZvoG5Xk9Owf3lRVRwCghs7g7NRgQuRzXA21J0AhYHj?= =?us-ascii?Q?A+H83C+Ve01/uR5YVwbTQ5LZNOWllrpeIpkTwisXG9GZUjqh565r35i/kZPY?= =?us-ascii?Q?wHDU6tz098/BZiHlbLJHs+UZ56VaO5Elf3MYl539axEqop6Vx8SEVXNZ8kS1?= =?us-ascii?Q?n4RQw1rYy4YE55blTU9S62O08oPZJDWBXQI0KsUYWYAZtgOfvB47D+nLM4PJ?= =?us-ascii?Q?Y7oa5l/mB9iYNuAdArr5ki7iYaFViu1r9ETDn0EdMJZDniWyCA=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: Q47MaVCw1KFthmiRtqXSCabTagaCBS5zKEavwYq5pOK8TGSpYkj5VdrMd/W5E02hw7SHhz0o4Hkz03+kZdvDs6mYkBe3Kt1PxjD+4gF+GAWdAuGCTVuO+IUwcfjc1YtZsvj0tKpPp2DETff4ER2NqekbsugHG+CRKW4EIAqaujIjYJETeqegMvt1y0iri2yOFQCLwEaeSWqQmUP9J2btjY/huPy+d5Z2CFhAvYFYrPdaYeT9RIP3tSeiVkcWQro2OMMWpIxbHpxzR57WfBZSyHDU2b7Vj2g8G1mbbsSkj1jBDuFqhObtJYW0k+eTbQ23jJfLhudr+jpjcQQxmOiCVae5imzpR+mrtkGsI12zWtab/coD3/vpCX8YimJA/9X7KNx+76QMP5XHhyGCp09UvHhc9w9Puy05zS/mxcnHDcrGtOXa5CmvQLMSsbjC0f7XJ3vJrici9LbZ9ae76MmRZKLbIVrfz8y0FwU42v6vX3ECkG0gDPv3xNPFwNZ2eItYXxXg+feMrvYeXAPccVKWCvDMbwQG6S9/Sp+rrmb/IF3aKpHnd1dsy8Tj9SBsfP1bqLKbzdUPeYVYS93JBB+q6AEZ4SqAYSk58IMJ08qmmYIMDkJk6bT5DzwcWbfdGlx0kZPGf3ci+vbvEROOwuB0OaZmaCwpvzlhNHSrVs/i+TU= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:37.5519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d316d4a5-3c88-4381-926f-08dcf2141cd7 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB2112 X-BESS-ID: 1729544741-304934-12654-45447-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYG5gbmQGYGUDQ5JdkwOdHY0s TAMCXZzNDE2MDQ0NIkzcQgNckyJcXUUKk2FgC6nLn0QgAAAA== X-BESS-Outbound-Spam-Score: 1.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan17-111.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_SC1_TG070 META: Custom Rule TG070 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=1.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_SC1_TG070, BSF_RULE7568M, 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 --- 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 | 69 ++++++++++++++-- 5 files changed, 256 insertions(+), 7 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 eb1f3227ed..fa40f15c0c 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 @@ -418,17 +418,69 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, return 0; } +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, uint32_t priority) +{ + (void)flm_scrub; + 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) { - (void)packet_data; - (void)flm_key_id; - (void)flm_ft; - (void)rpl_ext_ptr; - (void)flm_scrub; - (void)priority; - struct nic_flow_def *fd; struct flow_handle fh_copy; @@ -451,6 +503,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