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 75A2C45BA3; Tue, 22 Oct 2024 18:57:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29D0C40B9B; Tue, 22 Oct 2024 18:56:22 +0200 (CEST) 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 983BA402E1 for ; Tue, 22 Oct 2024 18:56:13 +0200 (CEST) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2240.outbound.protection.outlook.com [104.47.51.240]) by mx-outbound15-54.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O7riT59xMWcPEoSUBJBD7j8ueIYaN+QOpy64RQJhQwR07TgBmoBzzM4w9vM51zVEeFefPR2NqgHZzVHQzg8TPaZdbO03s+J7Ig6CH2Zt5WyiCeXWfaY2K5aVrajOYR+7qzUYnXFVnNiNsjr/lEjfBRRI/Ib+So05D9lSz9GCOG1h350eqPyeNrOVUsREdPpzza8fqYL+pHq0dhtpFFBICr+4oEP0H8lR4Kz7xBlak2/cntO3kLpa0jJ1jZ5U60eBNIZPyjyEfwlAPfBV44MwFzOqO7Uh1cH28Hhno1nfJSKZbLizF9LpfxvFiEP3GO4MNiytJoDqyaVe2L8vOOUNXA== 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=QAv4PKu0khOXbPc2hq+9QK6F/33dFp1gJ/z1NdAU/yXZFTAcP03bR41z76tqLrFU6sTjDMo4xs/nexpkxR5j2eRekoiWVX3uPqkNVtfnqQ0gfdLBpbksiP6k+Qtts9wadhZQ5v+VuMozv1T9pES5mY6qgd3M6rhZnL2/d2DqsIKqCscWKXcTZaK8YI2NMcPUTFgCo3FPg+Ro5j4HFYhLbgoq4pO474q4pvBBBOWs1UmCvwNecvwchZQ3NvndhceAIUYR1Vo8P0+OUFZxusZrpSIYOxKbyG9oZYUJGPz/sucgAbeaZq3yBZDTaTA5fehJo+Q64QNdP9HzUiwqi02GKQ== 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=RXo3ksBlsDNsWPPMrUyE0UPuhcCGgx3O45JVuc4pUWXXArmxIn3AdmDUs65X1xaZCOB9wOEv+U5dDIEtx7PCSH+td/Nrjk5oT2nkq263jMbSDZoboIRbtAEy3A0QG0tXF7re5cTuTQEQlhXChRAz4GL2qVyvZEbE4aDguG/CX00= Received: from DB9PR06CA0011.eurprd06.prod.outlook.com (2603:10a6:10:1db::16) by PR3P190MB1004.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:84::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 16:56:07 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::bb) by DB9PR06CA0011.outlook.office365.com (2603:10a6:10:1db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 16:56:07 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:06 +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 v2 09/73] net/ntnic: add infrastructure for for flow actions and items Date: Tue, 22 Oct 2024 18:54:26 +0200 Message-ID: <20241022165541.3186140-10-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|PR3P190MB1004:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: e2e90185-382e-476b-d3b6-08dcf2ba6c27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9wrY+b7voDiIjyYYeJWC8uXc1JA5FPMv3MBP1AnM7eqN2o0XLwgrP58GcLEP?= =?us-ascii?Q?HK1XplSRhu5Hf9VGjxVFRBaGR5QR683jNv/kxD4jEUdzW34tQdBTveFmrngs?= =?us-ascii?Q?43L1gyvTnVfQNfXHM6GiTg0KMNMeRp1Exutkchn/fcHZvaDKqSjwiG8XVUjf?= =?us-ascii?Q?JRMSjUTo5CVd3DwVHsQTjeeiQmVEHr1e6931good31F1ICwWNkQxdx55AXq+?= =?us-ascii?Q?6TT+EJ5iIOWZRy7pTHzu9hz/JiyJFGcqknACmEIi7TzMXNi+AUNFRE9RGT5Z?= =?us-ascii?Q?VzVgvZLmCDxRwWadlUm1lFB+k2txJCXNrjs5bPBtwt5RKNawZY6okCLMRuHt?= =?us-ascii?Q?23x3R9zOAwW+MHRu43DhbMSV1fU5UmO7Jt/7EWa6zigU0a2YFPGxKdHIxINe?= =?us-ascii?Q?ITTlw756D8wEEbwR+OgLB1faHytj18BnvaROFdqQXUP8lYzHgTq/0dTPBbRS?= =?us-ascii?Q?LlpNLT2IIo0S1+ktMcYzf68TMdP8/Z0pDSPpMTHU2L9026wrRL6ZGeX+0s/9?= =?us-ascii?Q?BVdmfuaNcAU6wYMsLXVU0sLKcmhJzSXsqZUBGsmM4nYtRBQGED79VdurO8Fy?= =?us-ascii?Q?DPKBvX/qp2M8/w/aj/NgapQUD0TwB+Wnzk6b97A3ECCMN1u+75m6mdDp8IIg?= =?us-ascii?Q?FClakFRtoKDjD/BR2bilawmyrTlMVe1ViJZ0Qrzt+I2HQtooFIdHEjG5y0/T?= =?us-ascii?Q?xb1Tbt1A92jzxMzIPRMaoijnCMUuOuGWLXqg7TIQX1prDvSkiQeC6j5Q/rdS?= =?us-ascii?Q?uvuK4m9wtuc+IfeREs5x879T6O6JTNvzCJBJ9OH0cESNKr5od5Bz+DhYgUhi?= =?us-ascii?Q?+yrcyqmls3y6a8NQ9mCAt+ULPGbC2+ONY6wEHI3o2Vu+a7B9qZyPYsFrQgbn?= =?us-ascii?Q?zAiba5+x7mwdyrFkllysJJGvqfN6izm5EIPqagOEgHRC7g3qOeQz3aAC6d2F?= =?us-ascii?Q?TvB0JeVpIgPLStTLD6Mmji+65i4on69VBuYIQiFKA+iSVksKUyMamopi7iM4?= =?us-ascii?Q?YCSBDSVtW+Hfzzj7B2tZf6+Isqta2FT2XZZs+P9R3Vnhts9m1fiTtjBFoU6k?= =?us-ascii?Q?BE8R5rVGoROzWCgrgsqIGyT3PyV4OEbnDEZ8Hs82AmPr8AKCEIYTUYjtuX4Z?= =?us-ascii?Q?KrcJ0i4gHK3xpGApDFS2yTnsW+0QVHiqTwrB1hzFIC4mgmNNdx5BgqVh9RKD?= =?us-ascii?Q?Kk0772Zh92eaIqgcXo12xXi4SEQb3B81ktv8VA5dnry3aYA6LTC4podqottV?= =?us-ascii?Q?hdO6QfLHREkmPe034zmFXU/jXUiz8EbZ0C4Ms6S1AIQa0O1mnTk9I7n2VvQa?= =?us-ascii?Q?Ewt3OWzEEmja3qLGtI/hwKswLw/XXszxLqBVIYizKYXtoo6y7V7A+R76Lbrw?= =?us-ascii?Q?+gZkDxLaihM+WoWjddpI/eOJ38kTnsqyheuGVW2o7xcBKTlQ+g=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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZDZjlCwXiqXrgivCXw2qdnJywf1WG90smTtIp68v/yK4HEJLr61cd3RUf+3+hbrbkLDwArCaVSdyBLu/Oaq+EQMZvo+yt6R2afDdYbSzoWU1HQNlPTk/eg7ewgnK5K/tBR/SZwY4+jxKS5Ax0PcBC/za+FUINx3RAonRn38FM87P2U2t3wwl/eqV35Gci8sKIeUbTTx3jyn7xRUb3IDEoW1ASwJ6vn7A/6o0kdH+v2d1miz6T2qx8GBsqqkDxMTGvamVVDdzcz3BbcHnvdl2jDE0hqmWzhiC2/xDDYfinm3gv8QT6kbpfvcBwS0GbL+F6377aghHMWUo7tKIacG0JW5WhreP3Yc3LXQnqfLVMw+uTwTLNnrAvZM6pyoMzV1bUpN8SqoGQoY/TWGn0lo33eU13M+2i4sM7ZlY3grJyo48/AubcZJ9haEs8j0nAx2ukA8BCt+ItH/7BD3ECdx1V/tnhtM57VJb1xUXxGeaXwgVlDAIN4SaeMqY2VYAw3BHGaMo/nwc6ZfDhN82oPxq54o83lMCv+dHqM3u5ry3oML9HYqa6lrGRJ8jQQH3xrOyCqTsKv2k28TvNveIBkuhoMQv5Ol8z0D5g7fTVJRj8ckcduST4lwU88rZSoR6/fCgGZOlj01e2QrcjvmfDg7nPtGZ+cTJqzIGJd+JhrddaUk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:06.9343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2e90185-382e-476b-d3b6-08dcf2ba6c27 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB1004 X-BESS-ID: 1729616168-303894-12663-13504-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.240 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.259902 [from cloudscan15-37.eu-central-1a.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