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 EE3D145BCC; Wed, 30 Oct 2024 22:40:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31D444342A; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id C139D433E5 for ; Wed, 30 Oct 2024 22:40:05 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2240.outbound.protection.outlook.com [104.47.11.240]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vxe4ivTPDWIzPf3BlmHqFofNcfDW7hqVsvG2d+spSeHIJmsE43PVbpsZVDTkaX/7E7HgMIWMJP87FIdnGmg+4/lY4NCKL6MBTPHMvJ6fkpeBHFn89ErI8cu4PH4d5UEgw5s2e9HEbYJ7CZ9CyxzMt2Mv+zVUnRUL15jqDi5yroqi/ODp3AirSCfs22seqIh1nUNYl9vMmN4xEmz2QL8xmVe/u8zA+TDtu98xzXSfHV31npVe287n/20kEO4NiaYzX8jDS5+4mKoS0J6iW3HDQr9/5xOR8/wXJ7thHWIWwRgJjBACYDc7wSt65ZMdrpU8X+kA4C2ccpGB48VSILVPhw== 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=7G45f0WhmA+1w6T731Zy/ico7xiF+x84NVc9y1f0Pkc=; b=N2ahdijoFdM1/bQI/ZRLPtERq7VXBdnJRTpnubaZFAy0myoB/6lBs9yc5qqNFPU2nbIL9brhU77KFJfch75oskx6Az4jAMBj6VSFiCopdCodUky3HL/3OXahGoP0bWbhUNWmUIBxttvvpuvWXUaND/v6c/mQJ/TDwnjoUnCHvr+LOvsPIrvXKbhZ/SYtxELuywKlJzBOWbMbkkHJo6oC0qvO6V0J8DQUaOz2RsqRUK1lSwy7/CDIHRFx0KHsZ+UA1mOGBBJCDuLpr5xpAT86tGxGwYm7s3gFNnLfhstKSxx9TVtOIKRB37XFoI08aiUvUFpJk3y1vm2YLxQETxSGdA== 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=7G45f0WhmA+1w6T731Zy/ico7xiF+x84NVc9y1f0Pkc=; b=cFSwIPpgbAmOasT5x0R5ovVXTLPn/NjBJUEfJZSwPnvC81xLFdqYs70VR0FfjHxFIy/cnLVivcoU9xST2tB9MjyagAkOPQ2tSKb246IG4sX7B2AslbuKKOHCZv0YPEnuoIiICIWbD+alo8SBHxyhlLNpoe/vJqh3oeYxtvXFpOM= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by AS8P190MB1125.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:00 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f4) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40:00 +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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:00 +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 v5 09/80] net/ntnic: add infrastructure for for flow actions and items Date: Wed, 30 Oct 2024 22:38:16 +0100 Message-ID: <20241030213940.3470062-10-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1125:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 9163f36b-bb20-469a-e468-08dcf92b6857 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TAnw/bAvIaRs9pi4yzH/tlX9uLdUy0A6wdt93PxEXgz4cGsJiGoaLfIY13Tf?= =?us-ascii?Q?hD46Q3k9jiBXwiisVzgA7C3eFbuEVkNgpK+LZAueUKWXZ6OnFrk42fMFnSw4?= =?us-ascii?Q?KSduXZluL6LDRYLJ6QqTb2vp7oFdCDC7wGCNcQ08oMphldJ36uFBp5bu+NxF?= =?us-ascii?Q?qjviSBrM+Xvti78BPxi6UOMliG1d3C/1POSuT6ovDu7J36+Mf5kBI6UzpDBe?= =?us-ascii?Q?mukLOzVbAufnCYs+x7DHVyD7Auzhv0XJ4cJXyfOHqbG5MfJqCX8PuFo5n3W1?= =?us-ascii?Q?60cPS1sFb+UCPr90MbKflBJ1qEMup9tHtSe+u61PL7AkF8lwPbkFvgb63Jsq?= =?us-ascii?Q?HJ0mddf1S5Km+29GCgEwXXpZx+Xs6zElUC21sADRKiZJzqAYxhBp1OjqneC3?= =?us-ascii?Q?KCfgupNbI6WCV4Yb4NPMlWY8ev7br0qjjSn8tkwVgX/TWFIoRMMknBXtG5yo?= =?us-ascii?Q?7IWeaMTmfllA2VzN1QfBlrFn5PlyxSe9fysEr5BZdvheAzAg/krNTQbAFb67?= =?us-ascii?Q?sUyKDBzK4pyIPsru5dU8dLiqKSl22bydGAPUHsRc5dXIpe3qZ4s9U/JCXvK1?= =?us-ascii?Q?3nlWc+EVHjmEU+rEvgeHFcM8LjrNot+rKWkgPXskbE5CVyYniiNvrFIaoqeU?= =?us-ascii?Q?4X9CX7SvfvcOmi/xpuNNm77K2PIduIGWpHz+Og74QdcoY5yR1pvAQFLnHSEx?= =?us-ascii?Q?/anMCFrCfe3lD15iQZNjW+1O7ZLsv3udnXeuxs35kJwscN+q+grmlFRtQx4b?= =?us-ascii?Q?yY8WYp0JSdk9N/ur9XcETk2BDHj1KrhS2LOGisqff+5jSPDGavwAnzk6Xoc8?= =?us-ascii?Q?vFmU+B2Q7Ya4MPzIjIitz8w8E/uYEzxjnpKsIQukS3s0cEm/Ms+WrQ6lyAG9?= =?us-ascii?Q?qf7HvlWuHq2QBA9iJQagtJRB6FTj+L56tkoMMunJ+Za844VIlPKQmAMpVGVn?= =?us-ascii?Q?iZ9xfPk0n2QLEH8lgsOpE+S9NQcxf3gHLxjWwNIlasTlYnPaT37l+rCkCizt?= =?us-ascii?Q?vpQBTt7ZmQy2ON6S9eMjNIMsnvqi+UtHREUEyBA+EN7fcopl+8qkTF3wAAYy?= =?us-ascii?Q?eklkD9oIF2AyOA46wcFnmFnZZx3D40VdlhqFykR2UV4yF+XSaawh3QG6cQ0o?= =?us-ascii?Q?bHt8g17LtRpyYCL6hN8uW0ZdmOH8napNFJ0ZTrkjXEVupitlcev6vG5a203e?= =?us-ascii?Q?fBsajSeypbFPQLSuWulNA2cdZLfNXSClydZ3V1kHm9K40O+2vlse4pUHslV5?= =?us-ascii?Q?hrPFMjRWeQD6h7YcZNqD8rwxlO8BswrKCx8gbGH1keG+6dp9gih7fTl7vplw?= =?us-ascii?Q?dD+/mwKVCJUQyK5IAU6hEhVSsR2F7jlDa5C9i3LOZQaagmh68Gstj7Wqp/fT?= =?us-ascii?Q?1oZYw66DzDMO0XBH0SnFgW+abnzby192AtBPse5Guknba3i/TA=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)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: yklo2mRuUSNhi1pJ94nS+OahulLtiEaSwRDKlawX9pHmI0QFMfUCiOqHnXPm7gzaQEK/gHAoqHwuhWhAxF9rpqCJnE1a8W47bxi9QKPLdZVw2mSC0LgCoFOBOqqoG+gIuyU04HsD8NeHHU/xVo93djw3HhdUeXaHIkpbPw3HAdxnwYSUfw8mXTFevpkxIOHe0vozJf3pglka44uD5SEabanelzzhfZ9w41mcSfG+oBFxiOIO1bEDMtkQFRlpT/Dh9YsCpEI3ucEXijox1WpnRdHeQH1t7O60wqU8zYk4XPdn9BGFsWJUAmlO9YyxgpOz8glHMB1W7R5J7RonoBLyLbBXA5h5FVeWK1I4BofhNmF4G7gNOh81vuSbnxx1ZW5HDkr2A9Ctk0pZSw4VUlkLM7Ey0hxlRaOFjUAbtvl+7oUFE8KK8/xDMSGkLx/ZcT0jIwvVhBPs/DeW38gOKgZC7Yb530RoF2bi+f87FLyNjA0WUOhODZwog8RnpUj1wHVFsMjzjvWBzw2lNnjMr+MTq6UIc0fUHZ+fCRoFsLazOp04ifas2yspKhoIKBi2aSQxlR9zSJPngzU//m+mDDXNjJqJMb+EiImw6rO6W21otYcwzjrGBE3i62MAsGE+K+se+LocRgqrvCg1ltOALdB06OHIjZDYsaZ26FAz8hfSGBg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:00.6612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9163f36b-bb20-469a-e468-08dcf92b6857 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1125 X-BESS-ID: 1730324402-312176-12713-40675-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.240 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGRuYmQGYGUNQgzTIlJS0lxc gwycg8ySwtzTLRNCk5Lc3MMDHZMCnVUKk2FgBatQBoQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.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 support 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 | 44 ++++++++++ drivers/net/ntnic/nthw/flow_api/flow_km.c | 81 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 68 +++++++++++++++- 5 files changed, 269 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..22430bb3db 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,17 @@ enum { } \ } while (0) +enum frame_offs_e { + DYN_L2 = 1, + DYN_L3 = 4, + DYN_L4 = 7, + DYN_L4_PAYLOAD = 8, + DYN_TUN_L3 = 13, + DYN_TUN_L4 = 16, +}; + +/* Sideband info bit indicator */ + enum km_flm_if_select_e { KM_FLM_IF_FIRST = 0, KM_FLM_IF_SECOND = 1 @@ -133,6 +144,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 d61912d49d..1b6a01a7d4 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