From patchwork Tue Oct 29 16:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147607 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30A4645BC0; Tue, 29 Oct 2024 17:43:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3A8242EB4; Tue, 29 Oct 2024 17:42:56 +0100 (CET) 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 D28F242E48 for ; Tue, 29 Oct 2024 17:42:54 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OI+j0elfSSvLoWThIcJrYc5XCS+7Am0otcp4q7uL50NEZ9oOmD3WNkmmt/DSFJDnj2vDELuqtjtvRRLlEJS+Z9OmWdryO4MMROjzjdkmHP9lLnLKNalR/5xBQg7BQ1ih8fBIwCvOJPevZH56E1mFms5pVkpyfGmTV5roVRigqeiahckfa6yl6pBPLfh5rLPgZrMOedV9R8o3Gvk6q9vCbITdaT2ZRSiPQuB0T0tDTo6B8D4MdH5ME0mbqiLducv7FIgaatcdzP9BjIgJVQvqfTY8aZBEOvt3tKrb/mgAhhF2a97NrH6+smc8DwZTuaVCzNUznHPHxZcTWE8gTcaBQw== 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=Ka/w6o4fiuPPcBa6MrrIv6UYm/lMdw0rqmM2G4pJXOc=; b=VAtqALgh0sQ565nEFAX/Bwsp2E/jEyWSIemZDNlSHRGOG/2umuVeV8++WhRkC3LQr79wbr4veOIrt6Rdv3k6Z6bUSU7+NUesM9ro/+Je1j19A0RKQadinVIsDrw3dByywIN6CdyTwbCR3KegvvLVjr4J3BFLuve5EAM6/e2fOx2rwJpBApLSwIZWLrTWJMtFEqnEyvCZ7b4/FZalib+N7KbQXh/e2ALUP7GR+4AOBpZ+D8n5ooFjbdQ4iYcDLcOL223r2IOtZwNWX0uLEKkWIj8FROQjZ1lXXa8tbUXi70iMNqmeK0x6HzYkEU70N8TtISJYdmZMWKpT7dbBCWY0Zg== 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=Ka/w6o4fiuPPcBa6MrrIv6UYm/lMdw0rqmM2G4pJXOc=; b=prlp3MZcX6NYR1rpXOLrThP4FWAfyKwlpYixKt1aYIVRgX0bOr41Szs5zaNqp4gh8tTZTnuoV1HXRHU2REKmeaQqYaua6f9n+ABnefwVxitc9PnZ24DzVklRTKIwoIxaUTabOQih4lEUNUHr61WxDTDMWaZ013Qg8L87jQcOSzE= Received: from DUZPR01CA0204.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::25) by AM8P190MB0804.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1d2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:49 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::5a) by DUZPR01CA0204.outlook.office365.com (2603:10a6:10:4b6::25) 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:42:49 +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:48 +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 01/86] net/ntnic: add API for configuration NT flow dev Date: Tue, 29 Oct 2024 17:41:05 +0100 Message-ID: <20241029164243.1648775-2-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM8P190MB0804:EE_ X-MS-Office365-Filtering-Correlation-Id: c3b0ed25-e082-436f-7bcd-08dcf838b958 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: oAY4dTPX7sAu3fI6LUxwQptUR8pN7j5UUOOWZWaOEBF8k0l3AB2bBdqVgmvGPqfDwGdvFHD02Xnh3G8CYLBUcMA2vA5Y+TEyK7x/b6LKoK7lfUd/KpcA4LbidPGgV9kd/L/LK6lxXTlLzlCVaWvkTm+2q7tSdgkKU4GWPAa/aoW9z6aepD6uU9QP2E+pLCa4ytJxtL+ffmccmzYqJ+jgzGJZCPoDt3P8zoyJoKBjXWRqrOGR4g1rqcfCr18tRr2jD+W5OcCuOTdhl2UcZGzH0l+9BcojgzzJ7Dri22qEKHs8KLXHPevNas8Ldq0mQT5DnGG1EAshKDdYdDUArsukDQhrlbdwJVr3D3Z8FDgNzN6fz9OE48gxX/tgVel343uFh4d5fFk7fkKYqtHmB/r6hfD2/qIIl3kTB/IwhaihWIX6rdzTyj1SIfWQktdJF5T16mAbYGriz9g7Xb8QSKJDoGnm62RXUQ69o5203iDj/WcWCT+UZoJRsSGq/umzgMzPbG5kkFLbj7WphBqhhrDWnRr/ltuAuKfcpG31a2hjcdAcWsXxf7/8bmvoDLUGdaPJtwqQ3PwogZUUpD49XdbO6aCVHaqR0c29Whc9QAGT2At4a09xNKxCiZw9JXo120BgwD6bxUw3EJAKS20g5mMZxQMsFtNuNPNC7/zZbTQ0plAl+ZmkKYYPg7kjGTMyuWRDwuZjdxNvSrSrZMLSPE94/D/OV9ggkWivvaHQcnqOGeYFtz/Vyl0Q71g6p4vyJqk/Kq85fCJB7EKbLGsDQ0wkcSbR2MciQEXWfEOoLD+sxw1DO48r9GM72LPQWmm/JVPdL8gn7QisaOjizc6LNgznrxnM599kTLgfTA5Ng2XI6vM5HSLiAUuA2+pSc3u8b1OhREpb/GieDwGwSaTbtLtyd8zlg8qv+/7C03x/SBF2id2LJh8P3yfehcJwToL1g4i/uDwsJUdL9luSqeJyWpR4vph8ruyysYpkuLmJPrM4qU6Ib5Xnkg22qx65yP/V8N1/o1U160bOHyvmtY/ys4Whp3icvCGG5SqNpEhXa7a9+cEVMtgLPGgiZwt78bF+MPzJdN6ThNOWzQWnO0RRcMa1VNF5SsjAb3LhUxS8JhOHIRFwU4w9AbKlTDoPfRMDTxR2r0TI1wE9CYONcdOd3cySmb0sb68IXzqp1eLUJIecbGdNejw7QzFpa0mTN+BqjOvncyqcG6FWp4b1vRTL/mfp1BuWNE9s6DbF0izGsqIil66xxke8Mq0mbs+sUizWZw0svc0VF/WLt0Ge7eSkzTfzs5la2+bcIOrb0qShbQ9LZiCkks8ZuOEkzYlKILLE26TQcHTVvsMMy6sboLOS3mWLbqdmsgkZz9u6G6pDQ8cZTaV/IxR/ZmPR+Q74Qyvuw30WB/w0wFMZmK3mDqwF+D/5Rw== 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: hWgHS5PFxuFjlzESpbHfP1y4D4FiGnA0bboBvN8W+9lDfBcgug0DNLJyte/eLsbwhjlFPncI6w90oMI7FPJwaFDXDXn6ppRoHwqGHlFq5sXZuK3TlA0y2r2xTRHcKiGOKbRdaye81ikTxgNWqUMlZY5uNZwzwRG+w+apPub0zjQNRMr+W+zJDTL/OXt9LjrEEEfn5kE5XZtUV7xXCJNr4N8Wkxrzig8dADebY1R/8EqgLugMjaIIU7GKAO4jg0F5Lkn5zhD2q45VrsHN0cmhiZwTY9KthJycD61meIB8roSZ3MBvfR5ApY+HrFgqvPybLtcMlf1Dck+nukR3UYdUML6UN0nlHKwbeovKEtVwutlrksJ1RxwyL8wNW9BlJ+d9C3YbBebNTrqAPlICRYxmQHhWw5szzalvNq1lfmG9+BeyCTWeRzdcPk2mxWodRP/Xi4anIL0VFgt4yAEqeT378R0GUaDL1T8udtXPnRsQC7P3I25gGMCuAhe/BevrenlJkwiiXISnGp2Cx6TeuHchxiIE2Q/TGbF/qRsc4l8jnibkNMyln19WN1/wRJMNrSFJWNEKt+BxSkQvG5LkgBNB6QitM0MdX+SclDCjh0Rpoha0leZ7BvyooAgxrKOENbbjYBPgd47/bV1kSQFsECQdK9gQf2lD5HYaR3gNQCtXCvg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:48.8239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3b0ed25-e082-436f-7bcd-08dcf838b958 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: AM8P190MB0804 X-BESS-ID: 1730220170-311207-12665-27812-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZm5pYWQGYGUNTYOM00zdI8xT IpKTHNwNLUItXI0NzSMM3C2NDMwsAoTak2FgC21O+8QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 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.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 This API allows to enable of flow profile for NT SmartNIC Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api.h | 30 +++ drivers/net/ntnic/include/flow_api_engine.h | 5 + drivers/net/ntnic/include/ntos_drv.h | 1 + .../ntnic/include/stream_binary_flow_api.h | 9 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 221 ++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 22 ++ drivers/net/ntnic/ntnic_mod_reg.c | 5 + drivers/net/ntnic/ntnic_mod_reg.h | 14 ++ 8 files changed, 307 insertions(+) diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 984450afdc..c80906ec50 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -34,6 +34,8 @@ struct flow_eth_dev { struct flow_nic_dev *ndev; /* NIC port id */ uint8_t port; + /* App assigned port_id - may be DPDK port_id */ + uint32_t port_id; /* 0th for exception */ struct flow_queue_id_s rx_queue[FLOW_MAX_QUEUES + 1]; @@ -41,6 +43,9 @@ struct flow_eth_dev { /* VSWITCH has exceptions sent on queue 0 per design */ int num_queues; + /* QSL_HSH index if RSS needed QSL v6+ */ + int rss_target_id; + struct flow_eth_dev *next; }; @@ -48,6 +53,8 @@ struct flow_eth_dev { struct flow_nic_dev { uint8_t adapter_no; /* physical adapter no in the host system */ uint16_t ports; /* number of in-ports addressable on this NIC */ + /* flow profile this NIC is initially prepared for */ + enum flow_eth_dev_profile flow_profile; struct hw_mod_resource_s res[RES_COUNT];/* raw NIC resource allocation table */ void *km_res_handle; @@ -73,6 +80,14 @@ struct flow_nic_dev { extern const char *dbg_res_descr[]; +#define flow_nic_set_bit(arr, x) \ + do { \ + uint8_t *_temp_arr = (arr); \ + size_t _temp_x = (x); \ + _temp_arr[_temp_x / 8] = \ + (uint8_t)(_temp_arr[_temp_x / 8] | (uint8_t)(1 << (_temp_x % 8))); \ + } while (0) + #define flow_nic_unset_bit(arr, x) \ do { \ size_t _temp_x = (x); \ @@ -85,6 +100,18 @@ extern const char *dbg_res_descr[]; (arr[_temp_x / 8] & (uint8_t)(1 << (_temp_x % 8))); \ }) +#define flow_nic_mark_resource_used(_ndev, res_type, index) \ + do { \ + struct flow_nic_dev *_temp_ndev = (_ndev); \ + typeof(res_type) _temp_res_type = (res_type); \ + size_t _temp_index = (index); \ + NT_LOG(DBG, FILTER, "mark resource used: %s idx %zu", \ + dbg_res_descr[_temp_res_type], _temp_index); \ + assert(flow_nic_is_bit_set(_temp_ndev->res[_temp_res_type].alloc_bm, \ + _temp_index) == 0); \ + flow_nic_set_bit(_temp_ndev->res[_temp_res_type].alloc_bm, _temp_index); \ + } while (0) + #define flow_nic_mark_resource_unused(_ndev, res_type, index) \ do { \ typeof(res_type) _temp_res_type = (res_type); \ @@ -97,6 +124,9 @@ extern const char *dbg_res_descr[]; #define flow_nic_is_resource_used(_ndev, res_type, index) \ (!!flow_nic_is_bit_set((_ndev)->res[res_type].alloc_bm, index)) +int flow_nic_alloc_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, + uint32_t alignment); + void flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int idx); int flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index); diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index db5e6fe09d..d025677e25 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -41,6 +41,11 @@ enum res_type_e { RES_INVALID }; +/* + * Flow NIC offload management + */ +#define MAX_OUTPUT_DEST (128) + void km_free_ndev_resource_management(void **handle); void kcc_free_ndev_resource_management(void **handle); diff --git a/drivers/net/ntnic/include/ntos_drv.h b/drivers/net/ntnic/include/ntos_drv.h index d51d1e3677..8fd577dfe3 100644 --- a/drivers/net/ntnic/include/ntos_drv.h +++ b/drivers/net/ntnic/include/ntos_drv.h @@ -86,6 +86,7 @@ struct __rte_cache_aligned ntnic_tx_queue { struct pmd_internals { const struct rte_pci_device *pci_dev; + struct flow_eth_dev *flw_dev; char name[20]; int n_intf_no; int lpbk_mode; diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h index 10529b8843..47e5353344 100644 --- a/drivers/net/ntnic/include/stream_binary_flow_api.h +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -12,11 +12,20 @@ #define FLOW_MAX_QUEUES 128 +/* + * Flow eth dev profile determines how the FPGA module resources are + * managed and what features are available + */ +enum flow_eth_dev_profile { + FLOW_ETH_DEV_PROFILE_INLINE = 0, +}; + struct flow_queue_id_s { int id; int hw_id; }; struct flow_eth_dev; /* port device */ +struct flow_handle; #endif /* _STREAM_BINARY_FLOW_API_H_ */ diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 34e84559eb..f49aca79c1 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -7,6 +7,7 @@ #include "flow_api_nic_setup.h" #include "ntnic_mod_reg.h" +#include "flow_api.h" #include "flow_filter.h" const char *dbg_res_descr[] = { @@ -35,6 +36,24 @@ const char *dbg_res_descr[] = { static struct flow_nic_dev *dev_base; static pthread_mutex_t base_mtx = PTHREAD_MUTEX_INITIALIZER; +/* + * Resources + */ + +int flow_nic_alloc_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, + uint32_t alignment) +{ + for (unsigned int i = 0; i < ndev->res[res_type].resource_count; i += alignment) { + if (!flow_nic_is_resource_used(ndev, res_type, i)) { + flow_nic_mark_resource_used(ndev, res_type, i); + ndev->res[res_type].ref[i] = 1; + return i; + } + } + + return -1; +} + void flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int idx) { flow_nic_mark_resource_unused(ndev, res_type, idx); @@ -55,10 +74,60 @@ int flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, return !!ndev->res[res_type].ref[index];/* if 0 resource has been freed */ } +/* + * Nic port/adapter lookup + */ + +static struct flow_eth_dev *nic_and_port_to_eth_dev(uint8_t adapter_no, uint8_t port) +{ + struct flow_nic_dev *nic_dev = dev_base; + + while (nic_dev) { + if (nic_dev->adapter_no == adapter_no) + break; + + nic_dev = nic_dev->next; + } + + if (!nic_dev) + return NULL; + + struct flow_eth_dev *dev = nic_dev->eth_base; + + while (dev) { + if (port == dev->port) + return dev; + + dev = dev->next; + } + + return NULL; +} + +static struct flow_nic_dev *get_nic_dev_from_adapter_no(uint8_t adapter_no) +{ + struct flow_nic_dev *ndev = dev_base; + + while (ndev) { + if (adapter_no == ndev->adapter_no) + break; + + ndev = ndev->next; + } + + return ndev; +} + /* * Device Management API */ +static void nic_insert_eth_port_dev(struct flow_nic_dev *ndev, struct flow_eth_dev *dev) +{ + dev->next = ndev->eth_base; + ndev->eth_base = dev; +} + static int nic_remove_eth_port_dev(struct flow_nic_dev *ndev, struct flow_eth_dev *eth_dev) { struct flow_eth_dev *dev = ndev->eth_base, *prev = NULL; @@ -242,6 +311,154 @@ static int list_remove_flow_nic(struct flow_nic_dev *ndev) return -1; } +/* + * adapter_no physical adapter no + * port_no local port no + * alloc_rx_queues number of rx-queues to allocate for this eth_dev + */ +static struct flow_eth_dev *flow_get_eth_dev(uint8_t adapter_no, uint8_t port_no, uint32_t port_id, + int alloc_rx_queues, struct flow_queue_id_s queue_ids[], + int *rss_target_id, enum flow_eth_dev_profile flow_profile, + uint32_t exception_path) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + + int i; + struct flow_eth_dev *eth_dev = NULL; + + NT_LOG(DBG, FILTER, + "Get eth-port adapter %i, port %i, port_id %u, rx queues %i, profile %i", + adapter_no, port_no, port_id, alloc_rx_queues, flow_profile); + + if (MAX_OUTPUT_DEST < FLOW_MAX_QUEUES) { + assert(0); + NT_LOG(ERR, FILTER, + "ERROR: Internal array for multiple queues too small for API"); + } + + pthread_mutex_lock(&base_mtx); + struct flow_nic_dev *ndev = get_nic_dev_from_adapter_no(adapter_no); + + if (!ndev) { + /* Error - no flow api found on specified adapter */ + NT_LOG(ERR, FILTER, "ERROR: no flow interface registered for adapter %d", + adapter_no); + pthread_mutex_unlock(&base_mtx); + return NULL; + } + + if (ndev->ports < ((uint16_t)port_no + 1)) { + NT_LOG(ERR, FILTER, "ERROR: port exceeds supported port range for adapter"); + pthread_mutex_unlock(&base_mtx); + return NULL; + } + + if ((alloc_rx_queues - 1) > FLOW_MAX_QUEUES) { /* 0th is exception so +1 */ + NT_LOG(ERR, FILTER, + "ERROR: Exceeds supported number of rx queues per eth device"); + pthread_mutex_unlock(&base_mtx); + return NULL; + } + + /* don't accept multiple eth_dev's on same NIC and same port */ + eth_dev = nic_and_port_to_eth_dev(adapter_no, port_no); + + if (eth_dev) { + NT_LOG(DBG, FILTER, "Re-opening existing NIC port device: NIC DEV: %i Port %i", + adapter_no, port_no); + pthread_mutex_unlock(&base_mtx); + flow_delete_eth_dev(eth_dev); + eth_dev = NULL; + } + + eth_dev = calloc(1, sizeof(struct flow_eth_dev)); + + if (!eth_dev) { + NT_LOG(ERR, FILTER, "ERROR: calloc failed"); + goto err_exit1; + } + + pthread_mutex_lock(&ndev->mtx); + + eth_dev->ndev = ndev; + eth_dev->port = port_no; + eth_dev->port_id = port_id; + + /* Allocate the requested queues in HW for this dev */ + + for (i = 0; i < alloc_rx_queues; i++) { +#ifdef SCATTER_GATHER + eth_dev->rx_queue[i] = queue_ids[i]; +#else + int queue_id = flow_nic_alloc_resource(ndev, RES_QUEUE, 1); + + if (queue_id < 0) { + NT_LOG(ERR, FILTER, "ERROR: no more free queue IDs in NIC"); + goto err_exit0; + } + + eth_dev->rx_queue[eth_dev->num_queues].id = (uint8_t)queue_id; + eth_dev->rx_queue[eth_dev->num_queues].hw_id = + ndev->be.iface->alloc_rx_queue(ndev->be.be_dev, + eth_dev->rx_queue[eth_dev->num_queues].id); + + if (eth_dev->rx_queue[eth_dev->num_queues].hw_id < 0) { + NT_LOG(ERR, FILTER, "ERROR: could not allocate a new queue"); + goto err_exit0; + } + + if (queue_ids) + queue_ids[eth_dev->num_queues] = eth_dev->rx_queue[eth_dev->num_queues]; +#endif + + if (i == 0 && (flow_profile == FLOW_ETH_DEV_PROFILE_INLINE && exception_path)) { + /* + * Init QSL UNM - unmatched - redirects otherwise discarded + * packets in QSL + */ + if (hw_mod_qsl_unmq_set(&ndev->be, HW_QSL_UNMQ_DEST_QUEUE, eth_dev->port, + eth_dev->rx_queue[0].hw_id) < 0) + goto err_exit0; + + if (hw_mod_qsl_unmq_set(&ndev->be, HW_QSL_UNMQ_EN, eth_dev->port, 1) < 0) + goto err_exit0; + + if (hw_mod_qsl_unmq_flush(&ndev->be, eth_dev->port, 1) < 0) + goto err_exit0; + } + + eth_dev->num_queues++; + } + + eth_dev->rss_target_id = -1; + + *rss_target_id = eth_dev->rss_target_id; + + nic_insert_eth_port_dev(ndev, eth_dev); + + pthread_mutex_unlock(&ndev->mtx); + pthread_mutex_unlock(&base_mtx); + return eth_dev; + +err_exit0: + pthread_mutex_unlock(&ndev->mtx); + pthread_mutex_unlock(&base_mtx); + +err_exit1: + if (eth_dev) + free(eth_dev); + +#ifdef FLOW_DEBUG + ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); +#endif + + NT_LOG(DBG, FILTER, "ERR in %s", __func__); + return NULL; /* Error exit */ +} + struct flow_nic_dev *flow_api_create(uint8_t adapter_no, const struct flow_api_backend_ops *be_if, void *be_dev) { @@ -383,6 +600,10 @@ void *flow_api_get_be_dev(struct flow_nic_dev *ndev) static const struct flow_filter_ops ops = { .flow_filter_init = flow_filter_init, .flow_filter_done = flow_filter_done, + /* + * Device Management API + */ + .flow_get_eth_dev = flow_get_eth_dev, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index bff893ec7a..510c0e5d23 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -1355,6 +1355,13 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { static int nthw_pci_dev_init(struct rte_pci_device *pci_dev) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "flow_filter module uninitialized"); + /* Return statement is not necessary here to allow traffic processing by SW */ + } + nt_vfio_init(); const struct port_ops *port_ops = get_port_ops(); @@ -1378,10 +1385,13 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) uint32_t n_port_mask = -1; /* All ports enabled by default */ uint32_t nb_rx_queues = 1; uint32_t nb_tx_queues = 1; + uint32_t exception_path = 0; struct flow_queue_id_s queue_ids[MAX_QUEUES]; int n_phy_ports; struct port_link_speed pls_mbps[NUM_ADAPTER_PORTS_MAX] = { 0 }; int num_port_speeds = 0; + enum flow_eth_dev_profile profile = FLOW_ETH_DEV_PROFILE_INLINE; + NT_LOG_DBGX(DBG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i", pci_dev->name, pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); @@ -1681,6 +1691,18 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) return -1; } + if (flow_filter_ops != NULL) { + internals->flw_dev = flow_filter_ops->flow_get_eth_dev(0, n_intf_no, + eth_dev->data->port_id, nb_rx_queues, queue_ids, + &internals->txq_scg[0].rss_target_id, profile, exception_path); + + if (!internals->flw_dev) { + NT_LOG(ERR, NTNIC, + "Error creating port. Resource exhaustion in HW"); + return -1; + } + } + /* connect structs */ internals->p_drv = p_drv; eth_dev->data->dev_private = internals; diff --git a/drivers/net/ntnic/ntnic_mod_reg.c b/drivers/net/ntnic/ntnic_mod_reg.c index a03c97801b..ac8afdef6a 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.c +++ b/drivers/net/ntnic/ntnic_mod_reg.c @@ -118,6 +118,11 @@ const struct flow_backend_ops *get_flow_backend_ops(void) return flow_backend_ops; } +const struct profile_inline_ops *get_profile_inline_ops(void) +{ + return NULL; +} + static const struct flow_filter_ops *flow_filter_ops; void register_flow_filter_ops(const struct flow_filter_ops *ops) diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 5b97b3d8ac..017d15d7bc 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -8,6 +8,7 @@ #include #include "flow_api.h" +#include "stream_binary_flow_api.h" #include "nthw_fpga_model.h" #include "nthw_platform_drv.h" #include "nthw_drv.h" @@ -223,10 +224,23 @@ void register_flow_backend_ops(const struct flow_backend_ops *ops); const struct flow_backend_ops *get_flow_backend_ops(void); void flow_backend_init(void); +const struct profile_inline_ops *get_profile_inline_ops(void); + struct flow_filter_ops { int (*flow_filter_init)(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, int adapter_no); int (*flow_filter_done)(struct flow_nic_dev *dev); + /* + * Device Management API + */ + struct flow_eth_dev *(*flow_get_eth_dev)(uint8_t adapter_no, + uint8_t hw_port_no, + uint32_t port_id, + int alloc_rx_queues, + struct flow_queue_id_s queue_ids[], + int *rss_target_id, + enum flow_eth_dev_profile flow_profile, + uint32_t exception_path); }; void register_flow_filter_ops(const struct flow_filter_ops *ops); From patchwork Tue Oct 29 16:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147608 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A42345BC0; Tue, 29 Oct 2024 17:43:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7FDE242EC5; Tue, 29 Oct 2024 17:43:02 +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 D7D4D42EB4 for ; Tue, 29 Oct 2024 17:42:55 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nD86jgcaSEJ3Os1EnGRZVzTPnmS5Ee8I5ufn17mRBhes7s5MH9V63ahD/Cw//lzbyTD3ouvMkC2biPLAmmqR9WnKBJBv0uQ5L1eVfN/9ocYuud6ibuPeaKTDnRL5Wt0xkusFy+MjfxUSHQLeHJNnH13UvLU5i9mUaYn9bpDkvDAYZfjo2QeyfL3Evf5cDNGcup4lUjS00Ik4+XKJ4+d75iGFk2M+iM603tfoX7GnLV9aUz+1h0GSIjeWeiymMlIz4hw9VBw+kUZo2dFKUWrBTDZgy9kLJBBpmHDczEhx7vzHZ4b/M9CHlIeLdgqHHRfl+FngmZrVwD3aoSbKEVY8Sg== 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=LsBlGj62fOMsIIXEknkCpltVIOtBmVkYGG/5OxAKr24=; b=rMEyph1aNWZDxiigZQiXFMhNErjEVQ1lI1iq1Il886iI6fk+cq3cblXKWy81vJrFoeu6bY448lQyAw3rqDyWJ5gaSkL8R0YsY/OpczgkwJHtKZ4J96Fpb/jPT6jDGBNiTRvAGHKveNl09ioEtGfPiMrnPmn3FHtfUwtcsSb3MVdIbuqbyKHYOIYbEaHaCwBrTE3dEVWDwlBUProB089G09t9gWQ7T245ICewFpdzh3SDDnyjYkxxZGV0YMoKJ/+WXwo1ZcTmR4/ch4bUW8f8OO32p2mVIYsNuAOofHLwJYE1wFyxOjkoiWbSM7+nM6ZF+evQmCTB35pkwp8z9PuDNA== 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=LsBlGj62fOMsIIXEknkCpltVIOtBmVkYGG/5OxAKr24=; b=NTEuo0SSm1+gKip7zcxbTXA1cM8+wlBGnrqIuF286QiFKYocWA2Eym4aIQyW/HUsmUyeO0mxj04N6Y2/jQJNLlK0xh0DLrVjEedv2dfqoh3+jYMz5TvgVbAsAmVUsBUlSo9vqj7gLHCbgPZhSEacKrGR0mclsRW0pw/gJg8YPIc= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by DB9P190MB1068.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:224::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:49 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::8) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:42:49 +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:49 +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 02/86] net/ntnic: add flow filter API Date: Tue, 29 Oct 2024 17:41:06 +0100 Message-ID: <20241029164243.1648775-3-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB9P190MB1068:EE_ X-MS-Office365-Filtering-Correlation-Id: b4656643-e2d7-4e2c-27b2-08dcf838b9c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: GS1nvl5Q0apNepsOAylNG276KJnObwEqr92M2fXjygKlEWTEB58scagzrkWa9znGmonfGb9ptTeQuVbrovFXl2mM1/mp1FztNAF6xyX+ZfuU5iE9TX18MI1X+7jpX+EWRQ7yeePQeojWJqpKM2oZ9prXh1vs2w/8EIaXsjAFkdjxsYg6IPhpKcIIvKgwyzhuFrISWoJYZZqXBdPZLpohrbUtryd2vyIe2JOalez94CvvEVAfIj5ain9LfDONWCjxqkdutVH0Q67xTHdMkQ7cg852a4a+VdbmwK9b5zM1Eq1BAnHCGHasCi3gnlkbnifV57jOw4t6yQmEzzo1RbGoYpvF1Npa1hVsyAD1ystMYCQJGrhPyMCJTofvyeWZIK2S34mzKTCRptY47b9qjlU9yJreWHbLitzKJE/tWIKJb/aG42WcOusd48824wztTRcRiyVoaxNllRqlL4m9sbAjJOIynVBDdA510n73LV1IXLQf/O8xU20wt1WhvgyGV8bYIkHIafu2MqToAJz1AkobWLf/AsLww01bUIjj0gJ1VvZ0TQJ5hsV5bR22EjEdRBYpIt+x4WkgjwEkT3Ucpu5Uz+sqZl6JGRarPZwM++AEfzeUtn/or2GlmHk7HA8EEeQ8TGvI0JOQxsiWx9Ix8bFjeE1pcN/enMMjNKKEZ5OXRv9HFNAf5NHt2CWnTuSd4fHPb5Y8kgFfOOEe8jvwHCwaDJVTk7tRlYm+xat/WktidFtuKnkj86S/LV00x5y+Gw3zTMl5gB5F4CN4uBW4fhXJwonURYtIuD/DGLh3esUDV+xINMmn9jvPg+mbOZpK3Cs6rH8XrabtMcpv0QwBtb6rJqdbw6oikJjubxL084zJRnzf308V+QHyCPSsVGwmkOOcwzMvpILG3SprMci8vcyHBqxm6uAA1hFX6kQudE799eNKqiOmTZmSYbpFQoovAE1cz44COuJ1il4/ZZF69GhqCsEn7VK0QRc68LJxgEoC/fypMs98sgUUwvm7epSWFhPqMaLx9tyli4uihuu4i1nHdGqOnELXkUKELJlgk6Gu4A9UGtgRVBLnXCJlplq74cHg8AqWRdBHaCBufBwzE4e07kYMGkIcJRUmW6NQ+eG7g3KuUMOtEDF7XgUsEKWt+/9mDSSl1YieHMMsMgxRkwE5nTi6qjO655KYs8r6Lb41OsrnpJY8uiPKSBSIx6LiMOknIyM3pewRp2vAIjD/dPdvx2bAH48onvn2jADd7B8Z8CaJwcCtpioxHWkwbTdQF/LBAPlIc7X1BP2RbSUmGfmHgHiw7xcKMYF2ICZBOIPBDVAgo9APJghGql4QjBVysdLLTL6FqMSyO6fH1zmT4zDnBOLbg18FROApIJbaP/4G3u6yVkr+SMJY3w/El2OOhsdkldzLZWX+n9q6QfuHmY7TAA== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fv3xvTCeIXTXAt2k+kSmU+o3hnxOE4jUFrk8+Zno1QOel5/FiGZdh35WCH+m/xgI1kO+v78aqGvE6Ru8zDqUdKDBJcpDeBSvqtuaUoM3bZjejVSVQ4Yj1MheITzqdLNNwmg/GnOPhp56EOHyGPXDGLknvAVevTDDC7fAXlYlmCnCZ9d0IPf7V0SQkMVwGwhzLFZ+g04KAKyMHhJL1fjTcVAX4CGf/5OHMAVjOgBfRaF8dVdbG9aIZEN5x7IxbKJAm8uE2rsGDw1HruCV02UyTMDYpcxqGtCXL8unwKFbKwNUzvGPIK+VMsMv1qsS77nHEfWhMqXN/0V7jfxbVWqiq8XGhIo+gCfdjwHo03DAtKnMZcJvt44pR4ytla8BK6U06aIiFDlV4B95NBkZwQAWlgC3cUKA1MBCc2rXm0PmxO453Tm4hUuez8+1r2f4LvspeaZB/MxAvDiRRJE3ML9eqESvns6G9WAlbYkYp8Vhl2so3DPInfaA9VZmPLeBkTZwD25l07TvtutMpn2nC4dSiSVxN5z/gYZd4ABX6P7fZ0qKmwqyMkSLlaj14GiNSnV6mkRNsVQgrD1S+2JsS2QRw8UIGUrArBUb0CSnF9VdERp5zt/d7esy5YTOrnDV4kphvnXECT26E77f/LuEAAHCQdOqZbhQaScNiHkciMUDxSw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:49.5739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4656643-e2d7-4e2c-27b2-08dcf838b9c6 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: DB9P190MB1068 X-BESS-ID: 1730220173-311207-12661-27814-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqbG5oZAVgZQ0NAsKSkpNdnMwj DRMtksycwixcDMxMzSItXAPNHUxNhQqTYWALfMOKZBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-215.eu-central-1b.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 Enable flow ops getter Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/include/create_elements.h | 13 +++++++ .../ntnic/include/stream_binary_flow_api.h | 2 + drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/ntnic_ethdev.c | 7 ++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 37 +++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.c | 15 ++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 5 +++ 7 files changed, 80 insertions(+) create mode 100644 drivers/net/ntnic/include/create_elements.h create mode 100644 drivers/net/ntnic/ntnic_filter/ntnic_filter.c diff --git a/drivers/net/ntnic/include/create_elements.h b/drivers/net/ntnic/include/create_elements.h new file mode 100644 index 0000000000..802e6dcbe1 --- /dev/null +++ b/drivers/net/ntnic/include/create_elements.h @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef __CREATE_ELEMENTS_H__ +#define __CREATE_ELEMENTS_H__ + + +#include "stream_binary_flow_api.h" +#include + +#endif /* __CREATE_ELEMENTS_H__ */ diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h index 47e5353344..a6244d4082 100644 --- a/drivers/net/ntnic/include/stream_binary_flow_api.h +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -6,6 +6,8 @@ #ifndef _STREAM_BINARY_FLOW_API_H_ #define _STREAM_BINARY_FLOW_API_H_ +#include "rte_flow.h" +#include "rte_flow_driver.h" /* * Flow frontend for binary programming interface */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 3d9566a52e..d272c73c62 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -79,6 +79,7 @@ sources = files( 'nthw/nthw_platform.c', 'nthw/nthw_rac.c', 'ntlog/ntlog.c', + 'ntnic_filter/ntnic_filter.c', 'ntutil/nt_util.c', 'ntnic_mod_reg.c', 'ntnic_vfio.c', diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 510c0e5d23..a509a8eb51 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -1321,6 +1321,12 @@ eth_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, size_t fw_size } } +static int dev_flow_ops_get(struct rte_eth_dev *dev __rte_unused, const struct rte_flow_ops **ops) +{ + *ops = get_dev_flow_ops(); + return 0; +} + static int promiscuous_enable(struct rte_eth_dev __rte_unused(*dev)) { @@ -1349,6 +1355,7 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { .mac_addr_add = eth_mac_addr_add, .mac_addr_set = eth_mac_addr_set, .set_mc_addr_list = eth_set_mc_addr_list, + .flow_ops_get = dev_flow_ops_get, .promiscuous_enable = promiscuous_enable, }; diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c new file mode 100644 index 0000000000..445139abc9 --- /dev/null +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include "ntnic_mod_reg.h" + +static int +eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + int res = 0; + + return res; +} + +static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + const struct rte_flow_item items[] __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + struct rte_flow *flow = NULL; + + return flow; +} + +static const struct rte_flow_ops dev_flow_ops = { + .create = eth_flow_create, + .destroy = eth_flow_destroy, +}; + +void dev_flow_init(void) +{ + register_dev_flow_ops(&dev_flow_ops); +} diff --git a/drivers/net/ntnic/ntnic_mod_reg.c b/drivers/net/ntnic/ntnic_mod_reg.c index ac8afdef6a..ad2266116f 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.c +++ b/drivers/net/ntnic/ntnic_mod_reg.c @@ -137,3 +137,18 @@ const struct flow_filter_ops *get_flow_filter_ops(void) return flow_filter_ops; } + +static const struct rte_flow_ops *dev_flow_ops; + +void register_dev_flow_ops(const struct rte_flow_ops *ops) +{ + dev_flow_ops = ops; +} + +const struct rte_flow_ops *get_dev_flow_ops(void) +{ + if (dev_flow_ops == NULL) + dev_flow_init(); + + return dev_flow_ops; +} diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 017d15d7bc..457dc58794 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -15,6 +15,7 @@ #include "nt4ga_adapter.h" #include "ntnic_nthw_fpga_rst_nt200a0x.h" #include "ntnic_virt_queue.h" +#include "create_elements.h" /* sg ops section */ struct sg_ops_s { @@ -243,6 +244,10 @@ struct flow_filter_ops { uint32_t exception_path); }; +void register_dev_flow_ops(const struct rte_flow_ops *ops); +const struct rte_flow_ops *get_dev_flow_ops(void); +void dev_flow_init(void); + void register_flow_filter_ops(const struct flow_filter_ops *ops); const struct flow_filter_ops *get_flow_filter_ops(void); void init_flow_filter(void); From patchwork Tue Oct 29 16:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147609 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0FD2E45BC0; Tue, 29 Oct 2024 17:43:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1E8542ECA; Tue, 29 Oct 2024 17:43:03 +0100 (CET) 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 6398E42EB4 for ; Tue, 29 Oct 2024 17:42:56 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2110.outbound.protection.outlook.com [104.47.11.110]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iSJ0q5yNR5hqHzLuZ08OOfQVsEB6qJBDm8QBbyu7Dbec4ppRLkDw3vHW/YIIF0zHFVYr79hAOpfJFao53+aZIDupOHlmxfOsg4/EpumcpAazSvVBJvqak531bGX1YYIL/5NiuCNk1gqhvcbQXu7a8+oU2xVGb4CPsdYKZmV1Gmxpgk92bTfI7TNeJZFSze7Al/BBCFYbgg6JP7Wsjz6kbJhescj3+L6hlYgpKivCyFetVsUV8BLlLMj9NXNjW8C4rol3Y1EXq+po8xpLHXEbMEvaCaWzS6B8WNpux/EcYP/G2Fm0lTWXPg5/eHI925DHHppErJ1WUdYN3TlWRiVIMw== 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=8QZRxv5IpNPnb1s1SXXS9HiAE8/H+JObuMbprksQF0c=; b=yet0blS3UjyOgBoI13jCxYteIbP1sNsBYRrwACcw8qTPEYoBMPCt2+1QGblATlzDBGH8gxItc4d6khTXmO3bE7PNjePUhIA+QHT6WGkQRqBSunztIw+CZCJ/2Sir2JvDYl2nXsGPZkmpIcpeWi0mYdbWpedCTk2DQCZIO8F1lQBynfBuZayJbXEgeM11K9wUufj1wyOVotBdZnRdGSau44nsACgZzWG/xp2w/kHNatF4S9Clm6agR4sG6AwH/4vX61vTrhStKvAGCpUJzA6OGLQ9UZR6aFUUqLAtCZwXay9SpEij6Bw+cci/C72lHK8RMwnL5LWHybr14mEsMkhwsw== 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=8QZRxv5IpNPnb1s1SXXS9HiAE8/H+JObuMbprksQF0c=; b=LKgwIhzju4bDIbdnsLGJtWqGZSxPwxBWUKThoLCBOeHURduGaCQULVN12mB5U2kmJuBixl9GdHxtWu5CypboxvnC596VL5XeIeprWn8B0xn2hwO9KJmiohdCNbHKSRQxpS9BLLZ9eQ909oOD+ymLlOzXUc6YRfd0nrCEp1y7SzE= Received: from DUZPR01CA0197.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::11) by DBAP190MB1014.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1ac::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Tue, 29 Oct 2024 16:42:50 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::96) by DUZPR01CA0197.outlook.office365.com (2603:10a6:10:4b6::11) 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:42:50 +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:50 +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 03/86] net/ntnic: add minimal create/destroy flow operations Date: Tue, 29 Oct 2024 17:41:07 +0100 Message-ID: <20241029164243.1648775-4-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DBAP190MB1014:EE_ X-MS-Office365-Filtering-Correlation-Id: 00591388-0413-40ec-98c0-08dcf838ba38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 6PBl7YpKd/EvPEpp6zJcK8qVwMG/ob/EY775c7gV18xAC4GhJvx6YxlRU9aijmoxLqVPs4FC7rwQ8M+xxZDtNgvut8ZKY7xZbqQ+icO26yUPl4n/QK6D/IFtyva75psWt7yFBxU0eshrBwHDM+mmr86VMSKVCwTYH5LZq/iLhZ6L22r4hvM9Al4QkyU5Miy4XUZMAIYep4oAZSLCy/2TkTZwpkhL26Icq6AaBC5wPMV3QPUYB+86QcwQ4+Gx5aRKjcYKP1gPa5Rg5KlwwjQ0K/KH+99RtYxYyy5mCdf4JHvQn/cDbo4p/WFGoS0YPNPQsQFugHVZn0vzUU5cPkgSYe9FKGtSHG4ZZSHm35ltE9h/b6uidHr1IzLDl5PnHpeTyxXYWiTEbHftgDvrR/DD1zHRGtQWKOm1XCWvAJ/rP+HHBDDIwb0ppDaEOTbjHALAprdO5Q0OLxDocdm4duX5osbqUZJngmP8kdzKurCmaFLd5OWAjjDo4NdVjeepP1BJQvRD2RJzK8PZiU7hvj++LKEWXjOdFtlSHXjl1lo2frQ5NiCK5Be1pb+kV2SDpfjwtI1lfqlWif4f/w6CVfvvju8RYfBFaxflIlQknmFARgu55jR+ZMaOFpfFLz/Iobx5WFd2F0HFemSnZ0iffWk0yL2nHMe4nRWzJhYc8QDry9lHMrzuVzAd47P8yu4b8MpPW9eRjRkPoyKEQ9crilxwf5UdYhTwYqsEj4C+yARqCMrSuBQxbt4IHvm4gR283+tLUOZ495K/izUCCASx4yHIM2G/7i9eY+zA3vBKG6OHbTjBvo8VdTHA0bOU8PRirix6WSY72oTcx6cTWiFsgPkLZSC5hj8qQI5cnYMoEJxwoX13Dc71HbmIpQe6ESViIOvxgIpB1ef7vNA6R0I/XhrR8U3DWByckPfOoNouVIik3qRANLrmIvJfQBbTqS5crL8SIJ5BUOVh6hobRPSy8Iw3p5mchzm9ZelbA3+ufLQBAPD5ev/bz4auquuCW4JZu1vlOVW1BZ8ylTU7kdFWcRsLJse6FJDETCEfuiMp1GKDZBf1uOIqSHnfFZB660y90k+5IF0kBMlUUNLICCIUWzVqomtKsalohasWVBYfiM8LVAhYmwCL5o5O4FNb27OaUU5dvRFRFISIC8Ef8k+siLZg8F2tQHnloWcosGeSILW/IP0C6EXGivIx8dssa42Dyxy+mYvt/RxolpiIkFCCXhyP9olowPUjgzjBK5eOSIhhto7QH5pD7lqW1uydHGwSfZnoZRqNi64TM5/kv1+BA0U712Ejdx/SObuehMvQTVixsgXDYlTzI2Vs/ydKm056Z+3RMEPIEYzsPNEV+Kk0jULJ0PPNoCXmfE9YOGDYGaK3M+UC1FdmXfBnLYP47VhszgRHz3EY1Xgy+RxbbysiCwZlqw== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VIIHUMxz5GYkq8SfSx2gw2/zyYzrNeaPb2AoSF/o/1UBR0AQjSlHvbpQho0nGfuuQSs/V2+Jbe6XyyWLX76a3VM9UZf/8kKRr9NXRTi+rTqqHkCdRc0Vf8Nal5ld90pIPJ7pJd6HQ6FMIiwq/zRuHmMNZfr2dcVW5JBPtT80Rc0wmVZMuTyJV8vtL+JDjI2rejaK0KBE7d1+DPWBG3J3tPd08oRoM8sOzRm0R7RVV0eMntKSNvf7fyZOqhG8IosGhVDe7FoMUYMj9LFdhlg4yGdZ5+iKRHHt+Hs67HluSJ+85Xe0s15Y/F2CpApo0KH3iz0pVwilIjQhcY6rZaWBpwOZOln8l+UORz4yJHQNuaOL4Z408AEpeSQVlq7RyTqE6tKTLxNPQJSzyvmUS/jHmPaRUi1KOYqzeTZc/MTcV6gWQbIlt3YdEFXXSODuy3GOVpcyFgSJ9XELJfkLnKTHMOFgJxv+uiOytW6eZZSHwneBSMweOkQ5+qNyjXyn0EEdhcyOEQuprj1IKRNkTTKNb8waeTnLPmcLmtmgCrvRAVVCWMnJEwoXBi0jPjg4VR6Si0vDCWp2WayCI0poAzJd7DONFNtVDNy7DXyejR+WzonoC50pI1JPqNQ8nuColyDfLTfjtQbANA70b8uMNrbGJ6bsEuGl4AuF7xLLCNh+PxM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:50.3239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00591388-0413-40ec-98c0-08dcf838ba38 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: DBAP190MB1014 X-BESS-ID: 1730220172-311207-12665-27814-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.110 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmFuZAVgZQ0CDNMtUi1dw8yT gpKdXUwMA8xdzIxMTMKDkxzcjEONFAqTYWALuwYxRBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan14-53.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 Add high level API with describes base create/destroy implementation Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/include/create_elements.h | 51 ++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 227 +++++++++++++++++- drivers/net/ntnic/ntutil/nt_util.h | 3 + 3 files changed, 274 insertions(+), 7 deletions(-) diff --git a/drivers/net/ntnic/include/create_elements.h b/drivers/net/ntnic/include/create_elements.h index 802e6dcbe1..179542d2b2 100644 --- a/drivers/net/ntnic/include/create_elements.h +++ b/drivers/net/ntnic/include/create_elements.h @@ -6,8 +6,59 @@ #ifndef __CREATE_ELEMENTS_H__ #define __CREATE_ELEMENTS_H__ +#include "stdint.h" #include "stream_binary_flow_api.h" #include +#define MAX_ELEMENTS 64 +#define MAX_ACTIONS 32 + +struct cnv_match_s { + struct rte_flow_item rte_flow_item[MAX_ELEMENTS]; +}; + +struct cnv_attr_s { + struct cnv_match_s match; + struct rte_flow_attr attr; + uint16_t forced_vlan_vid; + uint16_t caller_id; +}; + +struct cnv_action_s { + struct rte_flow_action flow_actions[MAX_ACTIONS]; + struct rte_flow_action_queue queue; +}; + +/* + * Only needed because it eases the use of statistics through NTAPI + * for faster integration into NTAPI version of driver + * Therefore, this is only a good idea when running on a temporary NTAPI + * The query() functionality must go to flow engine, when moved to Open Source driver + */ + +struct rte_flow { + void *flw_hdl; + int used; + + uint32_t flow_stat_id; + + uint16_t caller_id; +}; + +enum nt_rte_flow_item_type { + NT_RTE_FLOW_ITEM_TYPE_END = INT_MIN, + NT_RTE_FLOW_ITEM_TYPE_TUNNEL, +}; + +extern rte_spinlock_t flow_lock; +int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error); +int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr); +int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[], + int max_elem); +int create_action_elements_inline(struct cnv_action_s *action, + const struct rte_flow_action actions[], + int max_elem, + uint32_t queue_offset); + #endif /* __CREATE_ELEMENTS_H__ */ diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 445139abc9..74cf360da0 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -4,24 +4,237 @@ */ #include +#include "nt_util.h" +#include "create_elements.h" #include "ntnic_mod_reg.h" +#include "ntos_system.h" + +#define MAX_RTE_FLOWS 8192 + +#define NT_MAX_COLOR_FLOW_STATS 0x400 + +rte_spinlock_t flow_lock = RTE_SPINLOCK_INITIALIZER; +static struct rte_flow nt_flows[MAX_RTE_FLOWS]; + +int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error) +{ + if (error) { + error->cause = NULL; + error->message = rte_flow_error->message; + + if (rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE || + rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE) + error->type = RTE_FLOW_ERROR_TYPE_NONE; + + else + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + } + + return 0; +} + +int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr) +{ + memset(&attribute->attr, 0x0, sizeof(struct rte_flow_attr)); + + if (attr) { + attribute->attr.group = attr->group; + attribute->attr.priority = attr->priority; + } + + return 0; +} + +int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[], + int max_elem) +{ + int eidx = 0; + int iter_idx = 0; + int type = -1; + + if (!items) { + NT_LOG(ERR, FILTER, "ERROR no items to iterate!"); + return -1; + } + + do { + type = items[iter_idx].type; + + if (type < 0) { + if ((int)items[iter_idx].type == NT_RTE_FLOW_ITEM_TYPE_TUNNEL) { + type = NT_RTE_FLOW_ITEM_TYPE_TUNNEL; + + } else { + NT_LOG(ERR, FILTER, "ERROR unknown item type received!"); + return -1; + } + } + + if (type >= 0) { + if (items[iter_idx].last) { + /* Ranges are not supported yet */ + NT_LOG(ERR, FILTER, "ERROR ITEM-RANGE SETUP - NOT SUPPORTED!"); + return -1; + } + + if (eidx == max_elem) { + NT_LOG(ERR, FILTER, "ERROR TOO MANY ELEMENTS ENCOUNTERED!"); + return -1; + } + + match->rte_flow_item[eidx].type = type; + match->rte_flow_item[eidx].spec = items[iter_idx].spec; + match->rte_flow_item[eidx].mask = items[iter_idx].mask; + + eidx++; + iter_idx++; + } + + } while (type >= 0 && type != RTE_FLOW_ITEM_TYPE_END); + + return (type >= 0) ? 0 : -1; +} + +int create_action_elements_inline(struct cnv_action_s *action __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + int max_elem __rte_unused, + uint32_t queue_offset __rte_unused) +{ + int type = -1; + + return (type >= 0) ? 0 : -1; +} + +static inline uint16_t get_caller_id(uint16_t port) +{ + return MAX_VDPA_PORTS + port + 1; +} + +static int convert_flow(struct rte_eth_dev *eth_dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct cnv_attr_s *attribute, + struct cnv_match_s *match, + struct cnv_action_s *action, + struct rte_flow_error *error) +{ + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + uint32_t queue_offset = 0; + + /* Set initial error */ + convert_error(error, &flow_error); + + if (!internals) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Missing eth_dev"); + return -1; + } + + if (internals->type == PORT_TYPE_OVERRIDE && internals->vpq_nb_vq > 0) { + /* + * The queues coming from the main PMD will always start from 0 + * When the port is a the VF/vDPA port the queues must be changed + * to match the queues allocated for VF/vDPA. + */ + queue_offset = internals->vpq[0].id; + } + + if (create_attr(attribute, attr) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR, NULL, "Error in attr"); + return -1; + } + + if (create_match_elements(match, items, MAX_ELEMENTS) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "Error in items"); + return -1; + } + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + if (create_action_elements_inline(action, actions, + MAX_ACTIONS, queue_offset) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Error in actions"); + return -1; + } + + } else { + rte_flow_error_set(error, EPERM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Unsupported adapter profile"); + return -1; + } + + return 0; +} static int -eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow, + struct rte_flow_error *error) { + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; int res = 0; + /* Set initial error */ + convert_error(error, &flow_error); + + if (!flow) + return 0; return res; } -static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_item items[] __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_error *error __rte_unused) +static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) { + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; + + struct cnv_attr_s attribute = { 0 }; + struct cnv_match_s match = { 0 }; + struct cnv_action_s action = { 0 }; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + uint32_t flow_stat_id = 0; + + if (convert_flow(eth_dev, attr, items, actions, &attribute, &match, &action, error) < 0) + return NULL; + + /* Main application caller_id is port_id shifted above VF ports */ + attribute.caller_id = get_caller_id(eth_dev->data->port_id); + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && attribute.attr.group > 0) { + convert_error(error, &flow_error); + return (struct rte_flow *)NULL; + } + struct rte_flow *flow = NULL; + rte_spinlock_lock(&flow_lock); + int i; + + for (i = 0; i < MAX_RTE_FLOWS; i++) { + if (!nt_flows[i].used) { + nt_flows[i].flow_stat_id = flow_stat_id; + + if (nt_flows[i].flow_stat_id < NT_MAX_COLOR_FLOW_STATS) { + nt_flows[i].used = 1; + flow = &nt_flows[i]; + } + + break; + } + } + + rte_spinlock_unlock(&flow_lock); return flow; } diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h index 64947f5fbf..71ecd6c68c 100644 --- a/drivers/net/ntnic/ntutil/nt_util.h +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -9,6 +9,9 @@ #include #include "nt4ga_link.h" +/* Total max VDPA ports */ +#define MAX_VDPA_PORTS 128UL + #ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) RTE_DIM(arr) #endif From patchwork Tue Oct 29 16:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147612 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 938A245BC0; Tue, 29 Oct 2024 17:43:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 207A042EDA; Tue, 29 Oct 2024 17:43:07 +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 6392142EBB for ; Tue, 29 Oct 2024 17:42:58 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) 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:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z9E0SqAVzwIgUs9OULNmJARYQEjiGrUyIsqg1ryTjThF8Q56QGArDsnd8JAfTOvL/zzpT/yxv+VnQijTv85yQy94vV9QXgILM0Ap2hoi7fkTafQFCOKvBS69U96QGqxH4C3l953pMEd4zQgAme0oB5+/q39rz2aZiv0OpBEwPwJ0tALXhU2RcjTSF89wb3x7uLHLISuK0XorxuaLKQrwFRgvq65E8b0L4/ydvh3q4SZApqM8mvZaSx8aQUe8Ef4VPSpEDcCRYQB7B4WqiqmH39gw/QTz5oOzPTDenqMmKPm/n4S/xO+5ExtGgrM3Badjxri4L1gSKP8o6jJW0qukmg== 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=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=MSwqwQMUB7N8YNqzpsByBoV3veEJ+1nLHB7CkY5EKSf+zWN0lWsh5sriTO1nUeFT5vLayxAtXRUDsPtbu+FHp5V7komkW4Xqnx1Y6gIKnw2Q3pjXne4m//P0SsXR7n2xyeRpbj/8SY7NrsuyruNTDhDdtRGoBiKUIMZgLycr7zvqaatXUpbBh1uMuzFfAFtgo6rsnRDhrMkHtNn77MeTrMsuFUHNbyZufncpWZCK9lWxQkSbdUVD3apAFQeFv5nYXzBP6gbo+vGolaPdog8aCLt3Ot8zKjEl08dhhF2YsXJyVQ5t0zdXleS4wpupkLm8xetrM0lEhNG+HAorR7Bduw== 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=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=I6xfRVJ4CRDcHm4I7fQPC81YppooMj4rygKL5UsT8p8LAwagWNF4rJrYWf2lc8fnQ/4AY6kTQAM1YkQxlfi2hXuzJqED8cPiqlvg3J7+MFwFSNQqSsbi5jhHvTgNpUa9PeUOGxDAdUs8fE+FFfe92hubtNxIDZI83ePTOhmx74M= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by DBAP190MB0869.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1b0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:51 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::f5) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:42:51 +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:51 +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 04/86] net/ntnic: add internal flow create/destroy API Date: Tue, 29 Oct 2024 17:41:08 +0100 Message-ID: <20241029164243.1648775-5-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DBAP190MB0869:EE_ X-MS-Office365-Filtering-Correlation-Id: 86bf50a1-f0bf-4e0c-097b-08dcf838baab 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: cEYJys1VaUYdmtM89SyWCseq2Z8deeRhlv+KgOVOLA4Axtm/GMMmSnQjPD5V5ubUE2Rk+NSc9Ov+gTgEuAkQgay307UsKR90EYar5D/hUZtqmRCkuIy6pFUPPx0YYZ0XVfT1jxDdSuSqpxA7Y83BOZa9dwQYsKZvBIodcx5pqhJ8sMRd8cPVJhL2htiZHFo6yNMGCqepoSPKCvhHGwsul6vftPOF1bb90oCd6ZW6PM+Qwhts110Ic8Mg+UaECi6tNmJ8TsrcyTnlXV4dLiOTJLOF2lBKoEFqBcIcy3NmntxkdWbJQNvAiQDxDNyL0IhXTgAB13y3snSqRO1KlgZ+lXXck05o5+RB2aeoh20ZYgS3rOixIbAx+Ext/ziVKvzviib/VFhDhB2mbKQ46dx5jgpJ8iemLBe3WFqj7aWBIj0dthm24fMSpGzxEHscEVLzSfs4I4LBwMJ1qfALRv+7FS3F2M53cf8D6obwyTyEMK9fjTFAs7OWHB7GYkIdxBsNTEC31eGLENtvON9/czFhJ1yTCiP4qNOaM/kw5aKzfpV62Ku99kKpgCzKF2iI3taQ4MvihwNqz5D6xCI63xzoN4VT48ncM88MA/cBZPUHXvXh38y6OCVDjgks1HUig+wQbDJVjlzWoaoQrPVbO2qbaR38F0M9M7N4nSC77cGnjjZIb4KJxXgsNPo801aXugFsNft0e4t/Ln2beA6fk3d5CjOYH4L/w2lasN5zFwn/SXEY5xoK/Ax/SyGqiWnYdBvWYp1Z6+hjnChb9Oq2NFg62ZOwtgFCDqJ1EAxgAUIIDO+8LxBFifWri5OgF/PAm3PXnbeig7M0tXK49FlktTHfuM4ezB2R1hOegdrIVjQ6qPVo+X7PQn29Gf9+tvFn6khp8SHxD9oW2ULjk/R61CDC5vAmMPTv8bs6hiSZluOLrUaMGcTUbcYGXQB7nG+Q58KZzfPMmptYRdCLK07Xp52IOX0Qhaz81gOsZPAq0f13RZegDas+pMFGGWLFYSuJ7eiD7nj4rkUZZFhe9cZRQ9HaX+7+Yzb6D0hUJjXZ/SP2GH7fkgMagCQVex9ZNEOWyPmHtfkoEDTt8xNrcuCA0pkIuEp0MVGHTpPmcF0RwbkVlOXJcGkeH/blPon2dKX/Oi5jwF2H1+BUK5YZ0CuvcsbynayEM18EVC8LoitJPRMouZ46s9HOAeVILJGQaTpN2KUV7rJdju70/IRHEj1t/JHgszt78Wq6wC6CF7G+7KHaJw23d4kU6OHnM41DC6MG/Tl+NhCIK9BkPY0ErNKOZEJ6ibH1Ro0I7/ZVdf/ta41sGhL8M4leygc2bAvn4PS6yzKknPBuREWDyl7rM+AMbBRtxjmN2ZUblSLipDuYzgKLAO/E16UqdIphqXJ9cFbDgvDFUPx9cbGjQEY4rISmudfoMA== 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: OA0KMBpNhNpAETbccMZ3gucrspv+mEEege6fdcktx4wMsDSEzSNLqrNrG+DGVvEjfblg//8AZRwHoZFjvdoIiJN+gxDnJUPAjSbjMXzRlWcIFEiJQlYuDu1RRkwIBU/FaTHSH8wK2RmyTGCypkRaGkhrbRzHbf2eyN7Q0owoQAchLwbJuDzWCc1KZOCoUbGWELN9aQ5CfmCv2QTalsU6/pbOt/dhe7VuG8kWOPUZ0H2Sl+gFD8GqQhQCjqSzIife2AsiopFmgNPEAD4mXJEMEfVz6AhjqBz8sC4C6LlImrjOBldUwdG1eU5TItC7n+B0Gap/BEjcXF5aAZiG0drWj+V3IIlySzDh1BYiFLRsFkr0Kvt0NBQqHxqk9pz9mxAzM3MdR0Blt/aaG8c4tIoNXtIr2d+DCr0PsFWYEFvpJCtXGtGtn7c3LRtdo/Vw0PSmvBPhrTxdbVDR2u+hksfjgJLF+5RUX9BdPRILPpAnyRz3GqNMbLpWIGqOQsxJ6sQ2YQ/hoVfLuSX4iRugemBl167SJeLVj1ae0nq7X231c1XXpYRI9XAF1WNGyGcbRUCYMJlLxdLCk8GAkmWOR9bQQktJt4xxrKCCg2Yg2Vj1EDwaROlMmKhmtIiGfielW0ORulLH0Dxc19VGblVi/TCzgTMN403htEid88hcO5UHQG4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:51.0739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86bf50a1-f0bf-4e0c-097b-08dcf838baab 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: DBAP190MB0869 X-BESS-ID: 1730220175-303097-12767-29293-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZmFkZAVgZQ0MLE1DLZIjHNON nMxDg1LSnN3CglKcnQ2MIoySzNJDFVqTYWAKpeF85BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan23-168.eu-central-1b.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 NT-specific flow filter API for creating/destroying a flow Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 39 +++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 66 ++++++++++++++++++- drivers/net/ntnic/ntnic_mod_reg.h | 14 ++++ 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index f49aca79c1..d779dc481f 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -117,6 +117,40 @@ static struct flow_nic_dev *get_nic_dev_from_adapter_no(uint8_t adapter_no) return ndev; } +/* + * Flow API + */ + +static struct flow_handle *flow_create(struct flow_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + uint16_t forced_vlan_vid __rte_unused, + uint16_t caller_id __rte_unused, + const struct rte_flow_item item[] __rte_unused, + const struct rte_flow_action action[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return NULL; + } + + return NULL; +} + +static int flow_destroy(struct flow_eth_dev *dev __rte_unused, + struct flow_handle *flow __rte_unused, struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return -1; +} /* * Device Management API @@ -604,6 +638,11 @@ static const struct flow_filter_ops ops = { * Device Management API */ .flow_get_eth_dev = flow_get_eth_dev, + /* + * NT Flow API + */ + .flow_create = flow_create, + .flow_destroy = flow_destroy, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 74cf360da0..b9d723c9dd 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -110,6 +110,13 @@ static inline uint16_t get_caller_id(uint16_t port) return MAX_VDPA_PORTS + port + 1; } +static int is_flow_handle_typecast(struct rte_flow *flow) +{ + const void *first_element = &nt_flows[0]; + const void *last_element = &nt_flows[MAX_RTE_FLOWS - 1]; + return (void *)flow < first_element || (void *)flow > last_element; +} + static int convert_flow(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], @@ -173,9 +180,17 @@ static int convert_flow(struct rte_eth_dev *eth_dev, } static int -eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow, - struct rte_flow_error *error) +eth_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *flow, struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + static struct rte_flow_error flow_error = { .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; int res = 0; @@ -185,6 +200,20 @@ eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow if (!flow) return 0; + if (is_flow_handle_typecast(flow)) { + res = flow_filter_ops->flow_destroy(internals->flw_dev, (void *)flow, &flow_error); + convert_error(error, &flow_error); + + } else { + res = flow_filter_ops->flow_destroy(internals->flw_dev, flow->flw_hdl, + &flow_error); + convert_error(error, &flow_error); + + rte_spinlock_lock(&flow_lock); + flow->used = 0; + rte_spinlock_unlock(&flow_lock); + } + return res; } @@ -194,6 +223,13 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return NULL; + } + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; @@ -213,8 +249,12 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, attribute.caller_id = get_caller_id(eth_dev->data->port_id); if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && attribute.attr.group > 0) { + void *flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); convert_error(error, &flow_error); - return (struct rte_flow *)NULL; + return (struct rte_flow *)flw_hdl; } struct rte_flow *flow = NULL; @@ -236,6 +276,26 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, rte_spinlock_unlock(&flow_lock); + if (flow) { + flow->flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); + convert_error(error, &flow_error); + + if (!flow->flw_hdl) { + rte_spinlock_lock(&flow_lock); + flow->used = 0; + flow = NULL; + rte_spinlock_unlock(&flow_lock); + + } else { + rte_spinlock_lock(&flow_lock); + flow->caller_id = attribute.caller_id; + rte_spinlock_unlock(&flow_lock); + } + } + return flow; } diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 457dc58794..ec8c1612d1 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -242,6 +242,20 @@ struct flow_filter_ops { int *rss_target_id, enum flow_eth_dev_profile flow_profile, uint32_t exception_path); + /* + * NT Flow API + */ + struct flow_handle *(*flow_create)(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item item[], + const struct rte_flow_action action[], + struct rte_flow_error *error); + + int (*flow_destroy)(struct flow_eth_dev *dev, + struct flow_handle *flow, + struct rte_flow_error *error); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); From patchwork Tue Oct 29 16:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147611 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F70345BC0; Tue, 29 Oct 2024 17:43:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9FE242ECE; Tue, 29 Oct 2024 17:43:05 +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 A117942EBD for ; Tue, 29 Oct 2024 17:42:57 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) 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 16:42:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Eq6soOwfJNuSUzQFOjTyG35L/oaGt4oU0o+Kkgc54GIioVGaauDB9l3C4Aiopz+9K5AhqNIqr8XdxNhNzQgeiK9mMTHTr8QCIAbtySxi/mqGP6KQK88dirphfdFevu/eFmsUJOP+I8tW2QIkoOjr3b/pm0TTCniIltd6iDOlwwPWXMoh28T5LdpGfjTVu75gwerAMAPErnQARaIHcjc332B0N5wQDMOYtQfWlgfG62/CMhDkTak1R1KJ1Dfi6K//ZFPxqiAAb0qTySBlpcd3HXHr2RNQrl5w1QMcwmPSubUaHFQGCK2Px579FptyJZjcKW+MO9RKexCcBqw0x7lYNA== 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=r6YBcNkQluz8OWGiWS9ZZl9vMUqCyDgiWFZQJ7PHLwQ=; b=jebhcaxxXKCl3trHCnbWvDgfB+KhZDBgDVbERSUByT8zCwKIN0Dr/9M0gQcv52s0YMoRzwx3AQBWOxD0N1TVzwgxR0e9NDIr18toQnBdycG+cuWdgAmbcsPfL9xAxI1s2YJv22RVjv1/7wXOlDS+0PQLTVcb78biPNacMj6YVaKqquvCKgeTl6Tz6CCRGuCA9oFzDngcpcgB8I1Y6YnZgdqHUChSbYQC+1RjD6/N4Wo9Z9uqNrLCx+sLOdt2vwT9NZ6j5Ntl36ZT9jq06p8FRRDCVNdAMZ1denZnzFw64MnEePG9U3+2X7gdAukncQ/RU0vV62Vq+aoXc7kRLzRKAQ== 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=r6YBcNkQluz8OWGiWS9ZZl9vMUqCyDgiWFZQJ7PHLwQ=; b=osDqNHMeJB1f5gBiqAt//iyvTV0uyfz2dzdraP3/R1iUQl/oYssny6r6NaEKtWFw/JlabSxgYFQq5e+1Cc6JosuHyhk3sgcmXXDu8l8aNZVv+ibcVIzb0u3qAdQ1mlB2mXZRu8jeiy6sVBgX+BRRmVexdTwrMMdsXuDvVvrbwJQ= Received: from DUZPR01CA0197.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::11) by FRZP190MB2168.EURP190.PROD.OUTLOOK.COM (2603:10a6:d10:136::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 16:42:52 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::60) by DUZPR01CA0197.outlook.office365.com (2603:10a6:10:4b6::11) 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:42:52 +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:51 +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 05/86] net/ntnic: add minimal NT flow inline profile Date: Tue, 29 Oct 2024 17:41:09 +0100 Message-ID: <20241029164243.1648775-6-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|FRZP190MB2168:EE_ X-MS-Office365-Filtering-Correlation-Id: dded94a0-cf2c-4a35-b5ad-08dcf838bb18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: +Ac9YrtqNcDkSovoxehWWVxka/8bPvx5fsoGl/sewlkMHjiC+EainWcPpRl+D6LQQRfV2lR0nZLJLhVRYVeb15E/W3MyYF4/YuKiWZxNlH0xy2z+D6VaBVrFqPiwr/krM86t9KX0BL60N6xUxS4UhmppzMCiYXUXOOHjTmRbinIq3QwAE3hUodG2AYjI1u46qKWFLXOcYIlsi82L/Oh7/KhPWyny6hB0fbh6CKxCys1sh8kKez1ioCG3RrNnFFI76ujR7Ck8R0of/xEOlAqPJdG1kL/LJERvTDfmE10h0640ucMArXIlT4SD4h1cGudjzPTG/wnPBZ43uUxckwcRae7bp/JtM+3YXPCojKrbsY9mjPzH9L7Omu/DQKR12mJ1ecNvBlcuNoAUVKXr+ae7s356Dlct8vlayLmEbKthyLTXhZ5vL7qlveCMDVN2i6sxbzNCDzk2Xe75tKncRQCA8U7w52pu7oCuX7nn0/0ea/5lmNAn4ke+5Jheq3Qnv5QAptiUomZhh18VAl2IPpzvMUg78tnUwGPyXra7PwBSn07AqWDOuEvUZ66rB9y0nnEtYMK57PFkDmMlThbQSx/68uJ/2TTapbdPwVZtWCctlUruZD4Fukb/BJTVYWWpWZzoyGcSK8epsXs52vS6FmbokGPyWrZJAJuj29fS/OrpHHVsB6++nJUkVjAwO3utNqsDJxYoIT//qkDTczfQHLFXX9l+W4usR8DTPQcOH1WQ2kGnahTAa4X3mYXb5Rt8M7+Fr22u4e2A96c+WJh5i7nRL6Ux1z3WzO42mZVbffoezykSLXH2Br4OtWurrjJWAst0rs10dFzmUpzuZubZt2Zuro/JabXje+oBj/iDgicmRh0UHXCGVoOPDz4tGHIeLRIqi2k1r6dfUOtJnvJTEpHNfDrAf7zHMw0F021aBmi6v8stE+WtKjW41Bqn+8SFLfPAa8BDvqKTy9Zuv8IMzbkG/+nuGEb+ia2rrD3JF2qgK+2q8TLyUohQ9Hq8RnuMErr9hFRbSLI0HKpgOxLAUYtb8ghWm6UpNDA+q2e9/pb94/j28M0B0uodZaPn4M36oSyZ4V4dlLEKmGiSHihLyY2+Jm3cUTiBVxjVye5I12xDYa+1sOtFqS150I2AXxrC1EhqEMeeNYxrxBGN+J3VdzsDWNRrTRwwaIhxxUh9fXPrZ10Hzm3aAP1hQtbv5CCaL67q3aKAy+wgCmaOXTdVtTtisOen7ktgKDnexjFJmN+r3e4KT253PUW8IXeeI+vXBSA3DgDoit6ome40NA5ZFJs7g5mSxmDu4maOfP5tPSPqyPCEPYdDPlZ10OuzLUzLti2cqZDdk6/3pxEi8e0FzPzu5zI3JgbqTWuzQwC9Y43UgMZ0KOs+VX1IWmahGOo3HgCRH4WncUusc9CvGwXhsBfl+w== 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)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DaCjSqQnHfN9W++dLEoWtkv4JHbtiyIr4mRWTdAsTpY1TXTIOo/Z7YDdad7z7QsEVN5TVEcF8/pnWYgjGBMGsaZ/w+ngt9KSNOWymT2ENLzG20JIDOIQZSUCsKExetAlWSqB8IsmxM2qySyHE+kSFUFfDVchnr1xs5jrKAPH1YnE9rTh8KSAcbMrD6mSNQE2jxB9hZyTXUaWE08erzGMdbjvuz1ZJUpxDJUXz8ufnJb8pwdu0T/WjsDT8NPBzCS+2PypOBvttAsyWBT6C45MOVTfJTyDR0e26CiVDh7ubYfa2qrRyWFa86mB/5MSpg/G4y+VwzCNO3NZLK85OHlk9wcqiUXJAs8GSbLfKXVnoCztvimAE0hmyWJTowCD6dGdd/B5/E0hnfvCQVOm/R8R6r0RY2aEjDkwfsCJnhr+7uGeslDwLu+ws/HgsCf5N9AO4ESMvIrbceGUB1aD4Lnz9eShajdxJjpt/1shey70iOBwaM0zenjIdQPG+YA/dkeXQch0mO000LuXL++qT1lam2TKjWHHSI9kYL/Dq2CwBnFqGjSvalsDSV5/jXBJn40P/3bwQ3DwMTgk873c2BvIwBoWz2PMojgAMRyDeFFxYFxn/mELs+keH4Nide+ho1l/TFiafscTwMGuEpPK2IbQEpCVA2UcE3lIu7W6UV2OlLE= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:51.7927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dded94a0-cf2c-4a35-b5ad-08dcf838bb18 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: FRZP190MB2168 X-BESS-ID: 1730220174-304438-12709-29883-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhYmxuZAVgZQMMU40cTSONnQwt w82cwsMc3U0MgyxdjQxCjN0MDUMiVZqTYWAKhLjAxBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan14-53.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 The flow profile implements a all flow related operations Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/include/flow_api.h | 15 +++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 28 +++++++- .../profile_inline/flow_api_profile_inline.c | 65 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.h | 33 ++++++++++ drivers/net/ntnic/ntnic_mod_reg.c | 12 +++- drivers/net/ntnic/ntnic_mod_reg.h | 23 +++++++ 7 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index c80906ec50..3bdfdd4f94 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -74,6 +74,21 @@ struct flow_nic_dev { struct flow_nic_dev *next; }; +enum flow_nic_err_msg_e { + ERR_SUCCESS = 0, + ERR_FAILED = 1, + ERR_OUTPUT_TOO_MANY = 3, + ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM = 12, + ERR_MATCH_RESOURCE_EXHAUSTION = 14, + ERR_ACTION_UNSUPPORTED = 28, + ERR_REMOVE_FLOW_FAILED = 29, + ERR_OUTPUT_INVALID = 33, + ERR_ACTION_MULTIPLE_PORT_ID_UNSUPPORTED = 40, + ERR_MSG_NO_MSG +}; + +void flow_nic_set_error(enum flow_nic_err_msg_e msg, struct rte_flow_error *error); + /* * Resources */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index d272c73c62..f5605e81cb 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -47,6 +47,7 @@ sources = files( 'nthw/core/nthw_sdc.c', 'nthw/core/nthw_si5340.c', 'nthw/flow_api/flow_api.c', + 'nthw/flow_api/profile_inline/flow_api_profile_inline.c', 'nthw/flow_api/flow_backend/flow_backend.c', 'nthw/flow_api/flow_filter.c', 'nthw/flow_api/flow_kcc.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index d779dc481f..d0dad8e8f8 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -36,6 +36,29 @@ const char *dbg_res_descr[] = { static struct flow_nic_dev *dev_base; static pthread_mutex_t base_mtx = PTHREAD_MUTEX_INITIALIZER; +/* + * Error handling + */ + +static const struct { + const char *message; +} err_msg[] = { + /* 00 */ { "Operation successfully completed" }, + /* 01 */ { "Operation failed" }, + /* 29 */ { "Removing flow failed" }, +}; + +void flow_nic_set_error(enum flow_nic_err_msg_e msg, struct rte_flow_error *error) +{ + assert(msg < ERR_MSG_NO_MSG); + + if (error) { + error->message = err_msg[msg].message; + error->type = (msg == ERR_SUCCESS) ? RTE_FLOW_ERROR_TYPE_NONE : + RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + } +} + /* * Resources */ @@ -136,7 +159,8 @@ static struct flow_handle *flow_create(struct flow_eth_dev *dev __rte_unused, return NULL; } - return NULL; + return profile_inline_ops->flow_create_profile_inline(dev, attr, + forced_vlan_vid, caller_id, item, action, error); } static int flow_destroy(struct flow_eth_dev *dev __rte_unused, @@ -149,7 +173,7 @@ static int flow_destroy(struct flow_eth_dev *dev __rte_unused, return -1; } - return -1; + return profile_inline_ops->flow_destroy_profile_inline(dev, flow, error); } /* 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 new file mode 100644 index 0000000000..a6293f5f82 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -0,0 +1,65 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include "ntlog.h" + +#include "flow_api_profile_inline.h" +#include "ntnic_mod_reg.h" + +struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item elem[], + const struct rte_flow_action action[], + struct rte_flow_error *error) +{ + return NULL; +} + +int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *fh, + struct rte_flow_error *error) +{ + assert(dev); + assert(fh); + + int err = 0; + + flow_nic_set_error(ERR_SUCCESS, error); + + return err; +} + +int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, + struct rte_flow_error *error) +{ + int err = 0; + + flow_nic_set_error(ERR_SUCCESS, error); + + if (flow) { + /* Delete this flow */ + pthread_mutex_lock(&dev->ndev->mtx); + err = flow_destroy_locked_profile_inline(dev, flow, error); + pthread_mutex_unlock(&dev->ndev->mtx); + } + + return err; +} + +static const struct profile_inline_ops ops = { + /* + * Flow functionality + */ + .flow_destroy_locked_profile_inline = flow_destroy_locked_profile_inline, + .flow_create_profile_inline = flow_create_profile_inline, + .flow_destroy_profile_inline = flow_destroy_profile_inline, +}; + +void profile_inline_init(void) +{ + register_profile_inline_ops(&ops); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h new file mode 100644 index 0000000000..a83cc299b4 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_PROFILE_INLINE_H_ +#define _FLOW_API_PROFILE_INLINE_H_ + +#include + +#include "flow_api.h" +#include "stream_binary_flow_api.h" + +/* + * Flow functionality + */ +int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *fh, + struct rte_flow_error *error); + +struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item elem[], + const struct rte_flow_action action[], + struct rte_flow_error *error); + +int flow_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + struct rte_flow_error *error); + +#endif /* _FLOW_API_PROFILE_INLINE_H_ */ diff --git a/drivers/net/ntnic/ntnic_mod_reg.c b/drivers/net/ntnic/ntnic_mod_reg.c index ad2266116f..593b56bf5b 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.c +++ b/drivers/net/ntnic/ntnic_mod_reg.c @@ -118,9 +118,19 @@ const struct flow_backend_ops *get_flow_backend_ops(void) return flow_backend_ops; } +static const struct profile_inline_ops *profile_inline_ops; + +void register_profile_inline_ops(const struct profile_inline_ops *ops) +{ + profile_inline_ops = ops; +} + const struct profile_inline_ops *get_profile_inline_ops(void) { - return NULL; + if (profile_inline_ops == NULL) + profile_inline_init(); + + return profile_inline_ops; } static const struct flow_filter_ops *flow_filter_ops; diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index ec8c1612d1..d133336fad 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -225,7 +225,30 @@ void register_flow_backend_ops(const struct flow_backend_ops *ops); const struct flow_backend_ops *get_flow_backend_ops(void); void flow_backend_init(void); +struct profile_inline_ops { + /* + * Flow functionality + */ + int (*flow_destroy_locked_profile_inline)(struct flow_eth_dev *dev, + struct flow_handle *fh, + struct rte_flow_error *error); + + struct flow_handle *(*flow_create_profile_inline)(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item elem[], + const struct rte_flow_action action[], + struct rte_flow_error *error); + + int (*flow_destroy_profile_inline)(struct flow_eth_dev *dev, + struct flow_handle *flow, + struct rte_flow_error *error); +}; + +void register_profile_inline_ops(const struct profile_inline_ops *ops); const struct profile_inline_ops *get_profile_inline_ops(void); +void profile_inline_init(void); struct flow_filter_ops { int (*flow_filter_init)(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, From patchwork Tue Oct 29 16:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147610 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5DF3445BC0; Tue, 29 Oct 2024 17:43:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C60AD42ED0; Tue, 29 Oct 2024 17:43:04 +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 EB2C042EBA for ; Tue, 29 Oct 2024 17:42:56 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2235.outbound.protection.outlook.com [104.47.51.235]) 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:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JutMvprsw0raocsr4lR4P+UstNxrSiCTBb6c75B3cidmUXqe6GmfUTIVHVxmgrQE69Mzd2UOT6rRtO8TKkDkM7JYU8eoGo+w3iNn0XqDuMZI/NPrm3pvbBJvHXK62sZtLZB65Z/VFqEWsmHvE6gLif6MpXJvJ5asE9Z2TllOyCiO4wnv6AioBgTvF1bGBCUWX3ccqZhpXLOEUhFrBMp3s8kcNxWtH3TaaQroGCVshrQ8RtrlYIkiE5WEDkk4BrK+Kt55IBPl0ym5pCIei0LXVVr3gVS9zLpfYjsyXAuasfYa2jC9emmyPt8kwRxeEf4ItNWJny4l6+pJxbAncmhdFg== 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=K5D/X7SXwiJ1s0nj/0CiLfStJoXpqrZLFz6eT0KvLkk=; b=o9ScWxWjth6lfmnq3q2nWgTfJjWjGYctOk/Gm/+BnJ16+Pb8naZ8kRV3R4B/qpafEMvRJX3j07d9JpQIhgSQs+LWR7Mtn0/jzyFxYyW6VY79hOA8Zj4sUyOwoaVF7trXEJC/P/gigtdHk55IAxcrWRmiq4IgwbGZDk6KPoSmyvmxc+zHKC1ZQmIwZ9gHHwCkNm937w0em60SvhjcW6h2xcuR1kgy1HnQ+8FcFRTbhpY6J5hksqNA45DjRP95iev9EjTb7JYryKGPhlNqbaeWNxAgV20b8NlflX4aN5XoZX9JzUDj2urVRTmubqqRNbhSFQ9kWt1kDAFpOYUVTKL/rg== 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=K5D/X7SXwiJ1s0nj/0CiLfStJoXpqrZLFz6eT0KvLkk=; b=kevYXakTGiuksQao1ludFgISLbDFb/7b6803EXWa3fnuADGUP2gRvfLVjHHxl7i9ls16RqWCJ37CcGZW7gj7DfpWZ0S2pPj5zgffpwaDPreSnVp/rha7DoyKf+8Wrh2gBJBifXYGjSaj1ujRdACBi+D1IezMnHmLEFMVYAQStCQ= Received: from DUZPR01CA0194.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::19) by DBAP190MB1015.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1a0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:42:52 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::2) by DUZPR01CA0194.outlook.office365.com (2603:10a6:10:4b6::19) 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:42:52 +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:52 +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 06/86] net/ntnic: add management API for NT flow profile Date: Tue, 29 Oct 2024 17:41:10 +0100 Message-ID: <20241029164243.1648775-7-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DBAP190MB1015:EE_ X-MS-Office365-Filtering-Correlation-Id: 45a0a58d-23a6-44a5-d6f6-08dcf838bb9b 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: 7dtPtIqzGHV2V3LG3LjuPmx683yYJ/6seRmMKy2nK2UcV1aQpisKrDSaPAKe9wD9vCNFccHzzrAKo2nJDAWYnUo21Iu+EnRx0i8DV+ohPnHVIbu8pnPKLwwLZkMjFaS5LN6DKbaNLrEnKxs0ErX0QE14TEcroPkTfKWElsEF/JgwgYpMOTKjPp+J2GezzFL+nDqiOyFYNcJKgQNV47Cz4ZFYxCl0DFZ0Sj/Cf3VDB+AkmCrICQK3pKoCORZXHK5WnTYmrMoDa9QGk0s+9wwHueBdiXCmoDzPZW+rO1k+i9UmkGWGe/mwsBoPZpKE7nTSG7x/tlXd0zHGi5aaow6Vo6euHgw4j/2jg81qcGYZnkcd7ETeK3lMRiOlcy97cE5DmEg9QxUxgwDpOw3btNrm7wLb5QhD2dn32XFGhs9uvHT6vstbcMOXOFE01kkMj+o/hxLKWzb692d8mndE/L1jDhft4DSQ+JxRJpl/pfpuf2FYvoyAtCPqeaWmrKCNc9HOOnRrcdaEn8N3vJL6tSA0R7ph6x51ARpduk4gAczRTOoE6VSE3ygGAcTDOUg2/gyzd0Re7hE6mPst429/W3pbA6FyHsVUPbKJczrFHZ/ujp3gpqlnFzmynZErkBtE7d5l3lQ8vSw3eluTBOLgRnNAs5YQ5k09AqX6F3wI746G5OX1qOgzy3+ngYqPhEtEQBvXjz5Z+ZsltHjQyum1FRxE1VMfRMxRYmLPAi7HL1Obp5DgKDTMhSrdthuzd9mxwBoHV/JWtpumixIEZpSVW25xgCNiNyFBODc/CXDAv3kqc14SgJPRfJWKM1RzZlkjq4lBsULrAhUbV95mgcKL26hjXgdZvB9LQuwlclBOKe5aH5KNAWdilnVpJSGDFCVAdHVUAO4xgq8Rp+dfxK++0LzNVFrmZG39GFsC4RnlWcM2yamlj07bdHUtIV3Oa53NGqD5F5BQ1GLaXhOET1z6f7q/WXXYd/F8rw7XZ9qqj1snfIY4rYvu7eeGY/zH2nBntUBCGOmTQ/U6y3ffBx6cWSvOd5F0FYi4MXmOJ+HaHL1HKOmx9rrqkbWDU/T5/R0CR7a1nVmG29c1NWBnV8QEhKrSU9+Fa/sCXdl2ouqsyrldG0USk2d9wV4mKeRVdIaol3q+Y5s8mfhZr26TutyDu05W3XsIX1KiSlaAky1zDKotpn9bJ45yLIpH1ci7ghFkxT/Axej3HFepvceGxEfyAl9NT60cqmULnnQ3B9Cj1ezG0AmxjX4FmjlXVhjT9lx7sxYX0FMzXylF9QZTYW9I4T8wJxx4Kt2YGNB0lMPrd5FAOUYvzId/QF60xjgTG/RpP+rFbbcAgqwIDJJLHaFLsDyFbb/ovwtHiQYArX4k7VpCnu1YdO75kKup1f13+qhvqVJUi9DXTtLcl9ArnjIgGxVyNg== 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: F4G06rI2UijtPYt5AlEETtrocZtrS+gCOPxIKOFAWwoc0qKa+qlbp2+vp8xdAQyafEAT05BU5Zm/DKlWSihA28RGEn9SNIta3pUAXzofVCSUK4px3qdZ39jC5+fP7o/vCIhxsb3ddzqP1L5ei7i906ld6JkSkOvMfDQpNLj33zWMks1Y/bTXs9/Z7X4Dm53NFBPjaNUjBQYAAatkMCAKWw2Vh/dlABlIX/zacAnb4c7MFZhOEZ2Z5X0h81T6wWtucNfaaeAOOyu2yiAe/hHbeVIFNhqAox4xdQoxkHoUoEX3Rp1P6Jtjc8UjCOkOOXFUf51KauqbjoY812uiO+CyLlTRL/9eDwDUy3OFHLX7sLhVEJCRfDaYyG3FTGSQdMczRt0sr5XC4yg3gfjUfK0bYvpr8Tr0kM1NMZwALYbUASdPWHo1A4NYzYWEFXBs6cYUbbVZtCGV23Y0E0XBMu3w7kSl/GAs1I+377r7W/s3oOIDviBXreJOSbq8wx576qVAIYDVJphtGemGTPKP3PJzh7X2VQ/eRTlJpnBp6zhIba5PkUbJbfgtyT0D0dyCRTFaZf/5nLx/rW9dnGQebkmFG2o9ShjOQ1mOE2+CRoZZohOE520IgJTuA4RN5tfmGQTSv6WUobmwnDeNcqdmj4+dNddPtstsoGjWrhjEtdxthUc= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:52.6521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45a0a58d-23a6-44a5-d6f6-08dcf838bb9b 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: DBAP190MB1015 X-BESS-ID: 1730220174-303097-12766-29317-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.235 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuZG5hZAVgZQMDUtxdTUwCjVxC TVJDXRLDUlxdLMKM3ANNXczDDVItVcqTYWAI3s5aNBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan22-120.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 Management API implements (re)setting of the NT flow dev Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/include/flow_api.h | 1 + drivers/net/ntnic/include/flow_api_engine.h | 5 ++ drivers/net/ntnic/nthw/flow_api/flow_api.c | 60 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 20 +++++++ .../profile_inline/flow_api_profile_inline.h | 8 +++ drivers/net/ntnic/ntnic_mod_reg.h | 8 +++ 6 files changed, 102 insertions(+) diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 3bdfdd4f94..790b2f6b03 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -55,6 +55,7 @@ struct flow_nic_dev { uint16_t ports; /* number of in-ports addressable on this NIC */ /* flow profile this NIC is initially prepared for */ enum flow_eth_dev_profile flow_profile; + int flow_mgnt_prepared; struct hw_mod_resource_s res[RES_COUNT];/* raw NIC resource allocation table */ void *km_res_handle; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index d025677e25..52ff3cb865 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -46,6 +46,11 @@ enum res_type_e { */ #define MAX_OUTPUT_DEST (128) +struct flow_handle { + struct flow_eth_dev *dev; + struct flow_handle *next; +}; + void km_free_ndev_resource_management(void **handle); void kcc_free_ndev_resource_management(void **handle); diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index d0dad8e8f8..6800a8d834 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -10,6 +10,8 @@ #include "flow_api.h" #include "flow_filter.h" +#define SCATTER_GATHER + const char *dbg_res_descr[] = { /* RES_QUEUE */ "RES_QUEUE", /* RES_CAT_CFN */ "RES_CAT_CFN", @@ -210,10 +212,29 @@ static int nic_remove_eth_port_dev(struct flow_nic_dev *ndev, struct flow_eth_de static void flow_ndev_reset(struct flow_nic_dev *ndev) { + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return; + } + /* Delete all eth-port devices created on this NIC device */ while (ndev->eth_base) flow_delete_eth_dev(ndev->eth_base); + /* Error check */ + while (ndev->flow_base) { + NT_LOG(ERR, FILTER, + "ERROR : Flows still defined but all eth-ports deleted. Flow %p", + ndev->flow_base); + + profile_inline_ops->flow_destroy_profile_inline(ndev->flow_base->dev, + ndev->flow_base, NULL); + } + + profile_inline_ops->done_flow_management_of_ndev_profile_inline(ndev); + km_free_ndev_resource_management(&ndev->km_res_handle); kcc_free_ndev_resource_management(&ndev->kcc_res_handle); @@ -255,6 +276,13 @@ static void flow_ndev_reset(struct flow_nic_dev *ndev) int flow_delete_eth_dev(struct flow_eth_dev *eth_dev) { + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + struct flow_nic_dev *ndev = eth_dev->ndev; if (!ndev) { @@ -271,6 +299,20 @@ int flow_delete_eth_dev(struct flow_eth_dev *eth_dev) /* delete all created flows from this device */ pthread_mutex_lock(&ndev->mtx); + struct flow_handle *flow = ndev->flow_base; + + while (flow) { + if (flow->dev == eth_dev) { + struct flow_handle *flow_next = flow->next; + profile_inline_ops->flow_destroy_locked_profile_inline(eth_dev, flow, + NULL); + flow = flow_next; + + } else { + flow = flow->next; + } + } + /* * remove unmatched queue if setup in QSL * remove exception queue setting in QSL UNM @@ -445,6 +487,24 @@ static struct flow_eth_dev *flow_get_eth_dev(uint8_t adapter_no, uint8_t port_no eth_dev->port = port_no; eth_dev->port_id = port_id; + /* First time then NIC is initialized */ + if (!ndev->flow_mgnt_prepared) { + ndev->flow_profile = flow_profile; + + /* Initialize modules if needed - recipe 0 is used as no-match and must be setup */ + if (profile_inline_ops != NULL && + profile_inline_ops->initialize_flow_management_of_ndev_profile_inline(ndev)) + goto err_exit0; + + } else { + /* check if same flow type is requested, otherwise fail */ + if (ndev->flow_profile != flow_profile) { + NT_LOG(ERR, FILTER, + "ERROR: Different flow types requested on same NIC device. Not supported."); + goto err_exit0; + } + } + /* Allocate the requested queues in HW for this dev */ for (i = 0; i < alloc_rx_queues; i++) { 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 a6293f5f82..c9e4008b7e 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 @@ -8,6 +8,20 @@ #include "flow_api_profile_inline.h" #include "ntnic_mod_reg.h" +/* + * Public functions + */ + +int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) +{ + return -1; +} + +int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) +{ + return 0; +} + struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev, const struct rte_flow_attr *attr, uint16_t forced_vlan_vid, @@ -51,6 +65,12 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *fl } static const struct profile_inline_ops ops = { + /* + * Management + */ + .done_flow_management_of_ndev_profile_inline = done_flow_management_of_ndev_profile_inline, + .initialize_flow_management_of_ndev_profile_inline = + initialize_flow_management_of_ndev_profile_inline, /* * Flow functionality */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index a83cc299b4..b87f8542ac 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -11,6 +11,14 @@ #include "flow_api.h" #include "stream_binary_flow_api.h" +/* + * Management + */ + +int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev); + +int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev); + /* * Flow functionality */ diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index d133336fad..149c549112 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -226,6 +226,14 @@ const struct flow_backend_ops *get_flow_backend_ops(void); void flow_backend_init(void); struct profile_inline_ops { + /* + * Management + */ + + int (*done_flow_management_of_ndev_profile_inline)(struct flow_nic_dev *ndev); + + int (*initialize_flow_management_of_ndev_profile_inline)(struct flow_nic_dev *ndev); + /* * Flow functionality */ From patchwork Tue Oct 29 16:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147617 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E139545BC0; Tue, 29 Oct 2024 17:44:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8840F42F13; Tue, 29 Oct 2024 17:43:14 +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 1B4A142EBC for ; Tue, 29 Oct 2024 17:43:02 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T5Xyo40hnrtUEBTlj3KQDLe+p+7AIaYPXo6oLA5Fsn7iHGwfAcnIGRXfkcV5HLK0x/C73ddUhGPq894R3LNlP7XKQtVU4kSXUKk7iQBh1qjP11aOJJhnxORWb15AwLurM1aAP4nO2PWkjrzIBRE5MkXS3yWy3TuBnLqueEHw2AdaVcJz1oGgbYkwzzTRnPi70i6+gTO9+GEm6i0FbwIdh263R0vx572W9gT2W9wZtEkEUMVCNlcRBU3aJcvcO3AmrLQ/7NPk9XdksgSRi17Kr0hlOuePNtC3i3NSCdqSs3RTJg/vKrCXBytqKP5nPaH5/CUCINm0hD74WhPB6ntBIQ== 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=IhrZ4zgA7X23xhXCFfXW0YGqvGjQN+UQGRVVjincnOQ=; b=GDERE8dAdUN4b7MUoY1Tg9uwkhB5zzHlYl/lpO+viJu2ti42ijXQiI5yufCLgzi8+qJr3qDbTQSMjQT+j2ue3pfh05Egc633pr4k+Re3qLfJ9MznN+GxwihNptIGjU7Zjnr8SG1qrSw0szDivEWN77E1SNPHfXItfHsc2SO3fzVFJLz0YS2tAlcAPoBIrLTyLYKSwihXCSnwnaUXjny9EbGIDVJfIqWaraLeDDlFh/pkQS472/GHgRdVd90Hz+0+06GmVUp5ENoPWy51urygzh1s6mRL2cQyZXDJEOnsE1MESDR4gwlEvRRyqxTqYoqz0t+6jNRCriGKI7NILXfYNg== 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=IhrZ4zgA7X23xhXCFfXW0YGqvGjQN+UQGRVVjincnOQ=; b=RF7f0JHEjeivUQeZM3X3Yd/nZi2CLHDU/y4oKJlTpyR5g7foHnQ9jXO7RXXWzYxZyLDFI6LJ7OR9o6F73f2jLaNSHyTTGNCmZBUEF4HsDb68oQ9TfGe7mUnJfuUdHquL+Eeg2cDtZt766JtXT8Xr+7BYePDxvNcIJeaarri6zCE= Received: from DUZPR01CA0187.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::17) by PA4P190MB1230.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:107::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:42:53 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::5f) 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:53 +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:53 +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 07/86] net/ntnic: add NT flow profile management implementation Date: Tue, 29 Oct 2024 17:41:11 +0100 Message-ID: <20241029164243.1648775-8-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA4P190MB1230:EE_ X-MS-Office365-Filtering-Correlation-Id: 2af76ee4-56b1-404e-5ad5-08dcf838bc21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: HGIiTbLxL/6bwYWdKRhZ3DgO6GJj5i+/odVSBmsOBmzBvQ2wLkVbOVSiXlKWQawNg7wSX6jwTlQ4YRj1PrXqanqyksO50aBjtZj6UHIEmZrpOfIbuXYQYj26YZQigddwJEStVRyUqIyr3hbrmYRdFCJbYOel0LMIbfpLe0WqC1/zpWuJw12QpMQw6wKXtcsu+DF5f9CoyLGcwmB4+/SkVFQa3f1WCFHib5pq79SxA4N7cDgLQjnl08S+qxOC6AVWb6E6vQV09MbBgW3LyEayVWZtk7P28VFfORteSuOyhovoJ8y9j+yHGnmilTxC+MzIqZpFhSrnp+uBn1o5IYqYGoRRt2VhP9qWn3ydOor2tPsn++bp03em45oXUEQtPSLVacKUaGkXSX/5Xr1PtmV+kZ2Plvya4BtDUNzhQ3u8lS/IN5Zdtc3W0AJAZ6+HsEKk2SXl3NDWSKN8So81HVPYH+rufpFb+LjLwBesGDZhGa4Z4rGfurOIe2A1BQjlgujNSCozocHPqNdkOG6QLOxFpDFP/5REWPbeuP0uXthHe1zQIPWx1pcoADr42IB58sa/ntyzvTJrEMKXT5V4X734LG40RY0c3SfhSnZ2cpS6ZWF08zEk91Zqzz4aTdD9L0ZFT4jaNTj8Y6o4bLKLP1FdUQmgvdaeKn/pj+QM3yI9vnbuVbtD4Dwf9h1T0XSqtO9+xN358/4Bt9GiOublYtfbmJ757wxLkwYbOwFX6p9Qyb9pHMGaom0GffcGv1+23Ah0k23HyyRKOkvVTDoNKhuPFCtSK8ObNoiyQlFXMPCxhCMdGNZmUD9eet9gWT5iDeBELfIKO1GZwIpGILvDm1Mep79YnJz+X8ggEkKf2bNDn7GGQgNb5pfruDbQh2UHmTv1R8+Khrz24UvDXZnvhGMhevYPyF5oL4a6Su2PgECyvVPAbeJK+SntRitBxPm2uc4GU3+uFN4qxYc5r11NcXrUhEvYE0hSCGwgGRY+mOu3k0970Ljc1d0Q4lIvEtegP7ZwsbjXkberTUR3oszBCZoP3eNb1tKuF6JS/dkgldop0EL5JtehkxU/rAQj6MJRXGIDm2gYRjJ5jPuP2N8xKktzxIeu8S/Ok5rR1NmWXFnb1ajp2YYfrEV8avkKANRQDVuM/b7VnH1Yyj1PrDgJ8qf8oVUmZygu5n2XfU6NVH2W85BVuWHtggyHuuX34hFwFn0KX7NNSomsDsrXG9j7ZVojCGT151n4Nd9haGqDjOOA2c3Z/DiZ1DzZ1BihRAnwlHkwl5fYZYs7Hi8JtlvxleQTCQMJ4EGsDVnjo/dgKBqZw0prDtdVXAzHwtMDnYvqNu8UT5cay6jVJhV0bSWltqWHDX3HDh3CUfQPZxGqmPe2IbkM3vRMw/go9+cIQPV1KfgqeMzE3PRjkhn+DOdKyqjOeQ== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7dB86BDrnkeTJj3PfZ0UncoNAYbtLaXhiGrmJBqNVBgfg4PAYa223Q4BVAM2sySd18+PNTn9sbggvSSOozSZu7k65ohyPS1Xt2rSj4aqZAg7V6IoeWr9BFJCcPDyMrbl+3fePF531HVFnFJowZew85S3+lskQBL4UTRxqt2/07DgxJL4wQMT9ZPpvYqZfJidKdPR9rTJWgPMFPuees+pNE41I8oQCD9piEvE/HG+7zvHOwHtfnqiOMdIyTr9J3HmxBwJ6rpHSy1v6uBjtNaB9YonoFiQ2PeN68v/Vo1cCywnb3iFl2WIPh0urMwZCiR1pxYBcpF3gMPNPs5+HlE0GnUzdCRndSF4Djd9r9GXd/SjmH9OdAszYVjhN3rx3yMf91pDm8BJsq5Dkh2YJYbL45y6lmWpZTV6ZjBvYap0xWXGs18JGKZWStm56rlbJWVSGU7u1mv/zbSm4OmRh6WfZ6L1M9Doji8Qhtk9dTXEx8k94I+oODrmPclMkyNIcebAR0IQpMTbNxSzLBRiOQUSiIsOfNz7l941VPYAb+InFraYvYX3sBgGLxJjG3Io5nryFV836ICBIXJsqlsqyacAlJ1m2B+DuFhvp9Hfntesjk9RNF1HKzllnKba91J61+WmUDvJ/yo2u6JoiLVshBu15NV/NWVBztqrQqw+2m42VK0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:53.5271 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2af76ee4-56b1-404e-5ad5-08dcf838bc21 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: PA4P190MB1230 X-BESS-ID: 1730220176-311207-12674-27816-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGxqYmQGYGUNTQyNjSPMnAzN TELMXA0tzSzMzAIiUl0dI42dI4xdQ4Uak2FgA7bYCzQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan19-202.eu-central-1b.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 Implements functions required for (re)set NT flow dev Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/include/flow_api.h | 4 ++ drivers/net/ntnic/include/flow_api_engine.h | 10 ++++ drivers/net/ntnic/meson.build | 4 ++ drivers/net/ntnic/nthw/flow_api/flow_group.c | 55 +++++++++++++++++ .../net/ntnic/nthw/flow_api/flow_id_table.c | 52 ++++++++++++++++ .../net/ntnic/nthw/flow_api/flow_id_table.h | 19 ++++++ .../profile_inline/flow_api_hw_db_inline.c | 59 +++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 23 ++++++++ .../profile_inline/flow_api_profile_inline.c | 52 ++++++++++++++++ 9 files changed, 278 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_group.c create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_id_table.c create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_id_table.h create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 790b2f6b03..748da89262 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -61,6 +61,10 @@ struct flow_nic_dev { void *km_res_handle; void *kcc_res_handle; + void *group_handle; + void *hw_db_handle; + void *id_table_handle; + uint32_t flow_unique_id_counter; /* linked list of all flows created on this NIC */ struct flow_handle *flow_base; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 52ff3cb865..2497c31a08 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -6,6 +6,8 @@ #ifndef _FLOW_API_ENGINE_H_ #define _FLOW_API_ENGINE_H_ +#include + /* * Resource management */ @@ -46,6 +48,9 @@ enum res_type_e { */ #define MAX_OUTPUT_DEST (128) +#define MAX_CPY_WRITERS_SUPPORTED 8 + + struct flow_handle { struct flow_eth_dev *dev; struct flow_handle *next; @@ -55,4 +60,9 @@ void km_free_ndev_resource_management(void **handle); void kcc_free_ndev_resource_management(void **handle); +/* + * Group management + */ +int flow_group_handle_create(void **handle, uint32_t group_count); +int flow_group_handle_destroy(void **handle); #endif /* _FLOW_API_ENGINE_H_ */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index f5605e81cb..f7292144ac 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -18,6 +18,7 @@ includes = [ include_directories('nthw/supported'), include_directories('nthw/model'), include_directories('nthw/flow_filter'), + include_directories('nthw/flow_api'), include_directories('nim/'), ] @@ -47,7 +48,10 @@ sources = files( 'nthw/core/nthw_sdc.c', 'nthw/core/nthw_si5340.c', 'nthw/flow_api/flow_api.c', + 'nthw/flow_api/flow_group.c', + 'nthw/flow_api/flow_id_table.c', 'nthw/flow_api/profile_inline/flow_api_profile_inline.c', + 'nthw/flow_api/profile_inline/flow_api_hw_db_inline.c', 'nthw/flow_api/flow_backend/flow_backend.c', 'nthw/flow_api/flow_filter.c', 'nthw/flow_api/flow_kcc.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_group.c b/drivers/net/ntnic/nthw/flow_api/flow_group.c new file mode 100644 index 0000000000..a7371f3aad --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_group.c @@ -0,0 +1,55 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include + +#include "flow_api_engine.h" + +#define OWNER_ID_COUNT 256 +#define PORT_COUNT 8 + +struct group_lookup_entry_s { + uint64_t ref_counter; + uint32_t *reverse_lookup; +}; + +struct group_handle_s { + uint32_t group_count; + + uint32_t *translation_table; + + struct group_lookup_entry_s *lookup_entries; +}; + +int flow_group_handle_create(void **handle, uint32_t group_count) +{ + struct group_handle_s *group_handle; + + *handle = calloc(1, sizeof(struct group_handle_s)); + group_handle = *handle; + + group_handle->group_count = group_count; + group_handle->translation_table = + calloc((uint32_t)(group_count * PORT_COUNT * OWNER_ID_COUNT), sizeof(uint32_t)); + group_handle->lookup_entries = calloc(group_count, sizeof(struct group_lookup_entry_s)); + + return *handle != NULL ? 0 : -1; +} + +int flow_group_handle_destroy(void **handle) +{ + if (*handle) { + struct group_handle_s *group_handle = (struct group_handle_s *)*handle; + + free(group_handle->translation_table); + free(group_handle->lookup_entries); + + free(*handle); + *handle = NULL; + } + + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c new file mode 100644 index 0000000000..9b46848e59 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#include +#include +#include + +#include "flow_id_table.h" + +#define NTNIC_ARRAY_BITS 14 +#define NTNIC_ARRAY_SIZE (1 << NTNIC_ARRAY_BITS) + +struct ntnic_id_table_element { + union flm_handles handle; + uint8_t caller_id; + uint8_t type; +}; + +struct ntnic_id_table_data { + struct ntnic_id_table_element *arrays[NTNIC_ARRAY_SIZE]; + pthread_mutex_t mtx; + + uint32_t next_id; + + uint32_t free_head; + uint32_t free_tail; + uint32_t free_count; +}; + +void *ntnic_id_table_create(void) +{ + struct ntnic_id_table_data *handle = calloc(1, sizeof(struct ntnic_id_table_data)); + + pthread_mutex_init(&handle->mtx, NULL); + handle->next_id = 1; + + return handle; +} + +void ntnic_id_table_destroy(void *id_table) +{ + struct ntnic_id_table_data *handle = id_table; + + for (uint32_t i = 0; i < NTNIC_ARRAY_SIZE; ++i) + free(handle->arrays[i]); + + pthread_mutex_destroy(&handle->mtx); + + free(id_table); +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h new file mode 100644 index 0000000000..13455f1165 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h @@ -0,0 +1,19 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#ifndef _FLOW_ID_TABLE_H_ +#define _FLOW_ID_TABLE_H_ + +#include + +union flm_handles { + uint64_t idx; + void *p; +}; + +void *ntnic_id_table_create(void); +void ntnic_id_table_destroy(void *id_table); + +#endif /* FLOW_ID_TABLE_H_ */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c new file mode 100644 index 0000000000..5fda11183c --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + + +#include "flow_api_hw_db_inline.h" + +/******************************************************************************/ +/* Handle */ +/******************************************************************************/ + +struct hw_db_inline_resource_db { + /* Actions */ + struct hw_db_inline_resource_db_cot { + struct hw_db_inline_cot_data data; + int ref; + } *cot; + + uint32_t nb_cot; + + /* Hardware */ + + struct hw_db_inline_resource_db_cfn { + uint64_t priority; + int cfn_hw; + int ref; + } *cfn; +}; + +int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) +{ + /* Note: calloc is required for functionality in the hw_db_inline_destroy() */ + struct hw_db_inline_resource_db *db = calloc(1, sizeof(struct hw_db_inline_resource_db)); + + if (db == NULL) + return -1; + + db->nb_cot = ndev->be.cat.nb_cat_funcs; + db->cot = calloc(db->nb_cot, sizeof(struct hw_db_inline_resource_db_cot)); + + if (db->cot == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + *db_handle = db; + return 0; +} + +void hw_db_inline_destroy(void *db_handle) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + free(db->cot); + + free(db->cfn); + + free(db); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h new file mode 100644 index 0000000000..23caf73cf3 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_HW_DB_INLINE_H_ +#define _FLOW_API_HW_DB_INLINE_H_ + +#include + +#include "flow_api.h" + +struct hw_db_inline_cot_data { + uint32_t matcher_color_contrib : 4; + uint32_t frag_rcp : 4; + uint32_t padding : 24; +}; + +/**/ + +int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); +void hw_db_inline_destroy(void *db_handle); + +#endif /* _FLOW_API_HW_DB_INLINE_H_ */ 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 c9e4008b7e..986196b408 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 @@ -4,6 +4,9 @@ */ #include "ntlog.h" +#include "flow_api_engine.h" +#include "flow_api_hw_db_inline.h" +#include "flow_id_table.h" #include "flow_api_profile_inline.h" #include "ntnic_mod_reg.h" @@ -14,11 +17,60 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) { + if (!ndev->flow_mgnt_prepared) { + /* Check static arrays are big enough */ + assert(ndev->be.tpe.nb_cpy_writers <= MAX_CPY_WRITERS_SUPPORTED); + + ndev->id_table_handle = ntnic_id_table_create(); + + if (ndev->id_table_handle == NULL) + goto err_exit0; + + if (flow_group_handle_create(&ndev->group_handle, ndev->be.flm.nb_categories)) + goto err_exit0; + + if (hw_db_inline_create(ndev, &ndev->hw_db_handle)) + goto err_exit0; + + ndev->flow_mgnt_prepared = 1; + } + + return 0; + +err_exit0: + done_flow_management_of_ndev_profile_inline(ndev); return -1; } int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) { +#ifdef FLOW_DEBUG + ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_WRITE); +#endif + + if (ndev->flow_mgnt_prepared) { + flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); + flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); + + flow_group_handle_destroy(&ndev->group_handle); + ntnic_id_table_destroy(ndev->id_table_handle); + + flow_nic_free_resource(ndev, RES_CAT_CFN, 0); + + hw_mod_tpe_reset(&ndev->be); + flow_nic_free_resource(ndev, RES_TPE_RCP, 0); + flow_nic_free_resource(ndev, RES_TPE_EXT, 0); + flow_nic_free_resource(ndev, RES_TPE_RPL, 0); + + hw_db_inline_destroy(ndev->hw_db_handle); + +#ifdef FLOW_DEBUG + ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); +#endif + + ndev->flow_mgnt_prepared = 0; + } + return 0; } From patchwork Tue Oct 29 16:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147615 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2F7145BC0; Tue, 29 Oct 2024 17:44:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90ECE42EE5; Tue, 29 Oct 2024 17:43:10 +0100 (CET) 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 68F9C42EBB for ; Tue, 29 Oct 2024 17:43:01 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) 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 16:42:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TiUxsa8c061Si+ZpJ8Zvn6CR+0wn4kc0Myis9S3wUh89gL2KFIrHKPwcVhYLVMR9qU1yuJWUGftmFCGPbDXjLWi7J77WgcVVv3wpS2SmvDFh9FqQSVZjH5DafLlkJnztm6xnSDmgOIzwrWF0kTHp7fKYq+9Pcs9sO7w1+Uq1PZgWeaZdDnl2jsbivwKksOt13Ba6QDRQzZvKp1beb81xPczyPUzmxoAJf9X2hERYxac0yXOgQcdwNdLo4lJ7qEcfcn5VqN4lWeiNiRPrlyS1NIgvIvwI6+GixysOMRHBNkURg2DBnM+Nb+bk9dI9XoUajXH4djhZeRDYD+kwrdRn9w== 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=BR93xM6rdHsRmG+9g5CEPnLoW011HvJEAeH9OS7Dw9g=; b=KXCUPpeHj3RL8THzjcj50kYWk0XZ6AmMrWjsFGF0gx/kkSt+5KUTQoyaXVbnn0fpAOTo2kB1AsNvUvKZvmfij9gstZ/n8W1+EFVC71n24Yaf8G7eu7ze3H28F+q8Z7ulBNA0/J9la7/sQC14t7DqWYSLnSDy2eXdm13Mzpgs9AELWfgcMCTNaWuoovpF5UX+n2DkfwtEgOvhnw/eMPFC1YsAg27lmYqdR7hepFey+m2HBWNlN2ssaeJrjW1Akd/znjJXzeLZAHOFjz5FMxlXiqLM+zMcIFOkm077wHqjucz//lFfirNkEwwrIu2pShZDrz0uuYB8cyfn+TtbJUm5iA== 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=BR93xM6rdHsRmG+9g5CEPnLoW011HvJEAeH9OS7Dw9g=; b=MNRXYoDmQY82SZ4enUvY5lRjyMF42x7pT59Xay0rEwwNnkNzn3EBcpsQYFeZCzZMH4QT4KU8rTit+wQOtztlBILqIHnycBcanXpVK2Ytw6L0gjeznKjAzTxqztfxp0MPtrChR2kVXP52kQMlFY1XiWKhZxVIrO2nUWlOUaTVnbI= Received: from DUZPR01CA0200.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::10) by VE1P190MB0878.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:55 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::7b) by DUZPR01CA0200.outlook.office365.com (2603:10a6:10:4b6::10) 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:54 +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:54 +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 08/86] net/ntnic: add create/destroy implementation for NT flows Date: Tue, 29 Oct 2024 17:41:12 +0100 Message-ID: <20241029164243.1648775-9-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VE1P190MB0878:EE_ X-MS-Office365-Filtering-Correlation-Id: c8437a26-fe36-4ee9-8ef3-08dcf838bcb7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: hoNzbDKW2KSAJpdOXoMoKXD0Jyvu8UQHFQ+LulPgNPLV0cEnkEgpzgViG/QIOkVN+gOiRhVPGGVagIH5op5h5RiwqbBwz6DfZjWQGvVz53nT6XmEieePhZdFO5O1ybtvu0TcQ2TWqOt8TOFtOWNavb0igxwAhV3ZoutkIhOZ/AfJDkDaNgmBXXXHWGoFb3+z6G6tKQDMcODBoEXrUxXlVoK0CJla3DXGLem+nGPoIhDayGfDQ6SUKfRqA8pZMurs9iZcW24yQFo/m4xLTzoHsHomY5kIg9UaHVjbW82dU33NoTXJe0jh1hiWlVzVwrbX8pEu+0mm2pJzS9sREyra/fU5zLdDzxC41sY54/CIJUiITqVHnjKfx/8HGNQqINYe3bnOoOpBcNdWIjBQFwPp6SRUCc4VcqMnjRuWgoifyBvFnmYW3TpsGSpleEdMVwf8wjZg6QxyY/Zp1eQrAhTjF7MstUwvMMfWl4Ji2I/zGmPjVZu7TeeSc/3oqGgLYnrs1lTet/oWm6xHvNj3TzzL890yuV06R9SbYWqFtf6FM/SfvKRe3zNoJkq3g6AzTRMLSNbhMuSbh/F1wizmRYHLSPx3w8fZvFx/WntG2ca7m8tGlAqzhXxsnlepQ1Jh3xpcFFC5Q9VQrJKNw2uoKWnE1N0obMSwyqnrY6U15N99qAudpvlcevwIH7fi9tSd6zCEjby45NZ1eBv1/AKCdK7KA6yOenI4HwPZv6DUbayXCKgtVkKS70so9AE8k1Qi7fo7X5YFOcz38/9iMQwWgmJWXZytdjbjpQ20GgcBPkLKQec5OYNdYXRI4n9KJNPbeAlsGdqKe1AC+PJXXn9GRo2ytyzqjFHFD/eG96cJDr08ewVbjo0OIWi1FshSoZgfYuyp+0H4TsfG5vRiQeBgBsW3UzkF2QyF1uHWaBHlPJ89+pCop/+giNfH2PFw1C260GokQJRt7P9aMBF2LcnEqKaZj2i/VJAS249DoJdQ/4G6gqtR9qHUssdFCRbXoDfpzN+btRLF/oLu9mp7GwIfAxH0gZGcjZoNy0fRMBj1eYrWcictX8LB/q0eB3HYYz9IwOrlYUUVImqbQgcLnqABX+kXDcl0R9EM52GaPW+0EDwqG49dbtj4Y58IkTY1u3owhQBtw0CzL2rd1UETQYG+2phLS32qhh82rj80JT+KYuomgv3YvGyQgg4NZCh78WiGFX1jxaRqowiA5FUeZP2KE57MKnle1r5JHXvSmHHOvqpPZCb2HjoKOFEX9ryfXiMEwrLerEkdkhhwmQ0j3Ghrdy3SvzvYzZnXopGd43EfbwohHkJbyrCV0QL484gL6LGwDLrkr/OprUbQ9oOkOXOz12ttnWShoUx9rsJV+9u64vcOR2BmSli7wuncZwhGZu1Ac8QgycFbPXggJfeKBA8bX9mLBA== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: p3rrTfhOOoemmtOmW5a3g0tHpitDyBHuHWFvR7xz/2wOyM3hOF+O5HIVh3Hmq7YBF+bmEdX82NYWc9zdhXIwp9J6aC6GKqNf4KxJ21rU2xJQWsegkKFXI0hjZXDMAv6fwcZQm+IEP18XABrp7SiImz9Tl8DD08tGkm9YebIR5TWiWD6Dxj5P0j1RNgd4zz6mzIgkfv7Xxg3Na/DC3C91v1QEkVR+DmZ3p21ZJVkAEZZcBvs0b7jAeqW3xFyz4t/NY8rtFBY2rPA4Sjl26aQqrOZrSvrVfb23JEgME2ZaFRR+nBGPXZh/42TH4jHtN7zAlwiSqv2clDQcEc/0MGX8rz70g54DTArLWxr2IlsK/OVbFOsuXuydTzIAXJIcXOViM8pRjjp8ZPJbVXv/wBSClKm4CZksU7oav1Q8/Wf/0dy9kUhmk/Ab9X7eAWuIKMhp97p7tTDb12J/sIvz6WByzwnBaHX6IpgSQGUpt5Kcr+jsvqwBauL5gG+JvlheWo6ScTwzu7JVI4poFCA0hlYgtjeLVFcfxYjrYeD15Rd6opIl/VJS46JV4KJkIMMIyMgtrP/Jq8ePeWSjCGGqFotN8UpCOn9TDtzJ+U7NhvjlwNgcydvIoKUGgTyHHwsWMyCSymd63FrozMluVS1YO8Wlkk57p49HgQ1uNAZhTQ8rCCE= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:54.5114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8437a26-fe36-4ee9-8ef3-08dcf838bcb7 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: VE1P190MB0878 X-BESS-ID: 1730220176-304438-12707-30005-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbmxkZmQGYGUDTF3CzJ0NjA2M woOTE52SzN0MLAxDTFwNTIKNHcIs00Sak2FgAFFXowQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-5.eu-central-1b.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 Implements flow create/destroy functions with minimal capabilities item any action port id Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 6 + drivers/net/ntnic/include/flow_api.h | 3 + drivers/net/ntnic/include/flow_api_engine.h | 105 +++ .../ntnic/include/stream_binary_flow_api.h | 4 + drivers/net/ntnic/meson.build | 2 + drivers/net/ntnic/nthw/flow_api/flow_group.c | 44 ++ .../net/ntnic/nthw/flow_api/flow_id_table.c | 79 +++ .../net/ntnic/nthw/flow_api/flow_id_table.h | 4 + .../flow_api/profile_inline/flm_lrn_queue.c | 28 + .../flow_api/profile_inline/flm_lrn_queue.h | 14 + .../profile_inline/flow_api_hw_db_inline.c | 93 +++ .../profile_inline/flow_api_hw_db_inline.h | 64 ++ .../profile_inline/flow_api_profile_inline.c | 657 ++++++++++++++++++ 13 files changed, 1103 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 8b9b87bdfe..1c653fd5a0 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -12,3 +12,9 @@ Unicast MAC filter = Y Multicast MAC filter = Y Linux = Y x86-64 = Y + +[rte_flow items] +any = Y + +[rte_flow actions] +port_id = Y diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 748da89262..667dad6d5f 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -68,6 +68,9 @@ struct flow_nic_dev { uint32_t flow_unique_id_counter; /* linked list of all flows created on this NIC */ struct flow_handle *flow_base; + /* linked list of all FLM flows created on this NIC */ + struct flow_handle *flow_base_flm; + pthread_mutex_t flow_mtx; /* NIC backend API */ struct flow_api_backend_s be; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 2497c31a08..b8da5eafba 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -7,6 +7,10 @@ #define _FLOW_API_ENGINE_H_ #include +#include + +#include "hw_mod_backend.h" +#include "stream_binary_flow_api.h" /* * Resource management @@ -50,10 +54,107 @@ enum res_type_e { #define MAX_CPY_WRITERS_SUPPORTED 8 +enum flow_port_type_e { + PORT_NONE, /* not defined or drop */ + PORT_INTERNAL, /* no queues attached */ + PORT_PHY, /* MAC phy output queue */ + PORT_VIRT, /* Memory queues to Host */ +}; + +struct output_s { + uint32_t owning_port_id;/* the port who owns this output destination */ + enum flow_port_type_e type; + int id; /* depending on port type: queue ID or physical port id or not used */ + int active; /* activated */ +}; + +struct nic_flow_def { + /* + * Frame Decoder match info collected + */ + int l2_prot; + int l3_prot; + int l4_prot; + int tunnel_prot; + int tunnel_l3_prot; + int tunnel_l4_prot; + int vlans; + int fragmentation; + int ip_prot; + int tunnel_ip_prot; + /* + * Additional meta data for various functions + */ + int in_port_override; + int non_empty; /* default value is -1; value 1 means flow actions update */ + struct output_s dst_id[MAX_OUTPUT_DEST];/* define the output to use */ + /* total number of available queues defined for all outputs - i.e. number of dst_id's */ + int dst_num_avail; + + /* + * Mark or Action info collection + */ + uint32_t mark; + + uint32_t jump_to_group; + + int full_offload; +}; + +enum flow_handle_type { + FLOW_HANDLE_TYPE_FLOW, + FLOW_HANDLE_TYPE_FLM, +}; struct flow_handle { + enum flow_handle_type type; + uint32_t flm_id; + uint16_t caller_id; + uint16_t learn_ignored; + struct flow_eth_dev *dev; struct flow_handle *next; + struct flow_handle *prev; + + void *user_data; + + union { + struct { + /* + * 1st step conversion and validation of flow + * verified and converted flow match + actions structure + */ + struct nic_flow_def *fd; + /* + * 2nd step NIC HW resource allocation and configuration + * NIC resource management structures + */ + struct { + uint32_t db_idx_counter; + uint32_t db_idxs[RES_COUNT]; + }; + uint32_t port_id; /* MAC port ID or override of virtual in_port */ + }; + + struct { + uint32_t flm_db_idx_counter; + uint32_t flm_db_idxs[RES_COUNT]; + + uint32_t flm_data[10]; + uint8_t flm_prot; + uint8_t flm_kid; + uint8_t flm_prio; + uint8_t flm_ft; + + uint16_t flm_rpl_ext_ptr; + uint32_t flm_nat_ipv4; + uint16_t flm_nat_port; + uint8_t flm_dscp; + uint32_t flm_teid; + uint8_t flm_rqi; + uint8_t flm_qfi; + }; + }; }; void km_free_ndev_resource_management(void **handle); @@ -65,4 +166,8 @@ void kcc_free_ndev_resource_management(void **handle); */ int flow_group_handle_create(void **handle, uint32_t group_count); int flow_group_handle_destroy(void **handle); + +int flow_group_translate_get(void *handle, uint8_t owner_id, uint8_t port_id, uint32_t group_in, + uint32_t *group_out); + #endif /* _FLOW_API_ENGINE_H_ */ diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h index a6244d4082..d878b848c2 100644 --- a/drivers/net/ntnic/include/stream_binary_flow_api.h +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -8,6 +8,10 @@ #include "rte_flow.h" #include "rte_flow_driver.h" + +/* Max RSS hash key length in bytes */ +#define MAX_RSS_KEY_LEN 40 + /* * Flow frontend for binary programming interface */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index f7292144ac..e1fef37ccb 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -50,6 +50,8 @@ sources = files( 'nthw/flow_api/flow_api.c', 'nthw/flow_api/flow_group.c', 'nthw/flow_api/flow_id_table.c', + 'nthw/flow_api/hw_mod/hw_mod_backend.c', + 'nthw/flow_api/profile_inline/flm_lrn_queue.c', 'nthw/flow_api/profile_inline/flow_api_profile_inline.c', 'nthw/flow_api/profile_inline/flow_api_hw_db_inline.c', 'nthw/flow_api/flow_backend/flow_backend.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_group.c b/drivers/net/ntnic/nthw/flow_api/flow_group.c index a7371f3aad..f76986b178 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_group.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_group.c @@ -53,3 +53,47 @@ int flow_group_handle_destroy(void **handle) return 0; } + +int flow_group_translate_get(void *handle, uint8_t owner_id, uint8_t port_id, uint32_t group_in, + uint32_t *group_out) +{ + struct group_handle_s *group_handle = (struct group_handle_s *)handle; + uint32_t *table_ptr; + uint32_t lookup; + + if (group_handle == NULL || group_in >= group_handle->group_count || port_id >= PORT_COUNT) + return -1; + + /* Don't translate group 0 */ + if (group_in == 0) { + *group_out = 0; + return 0; + } + + table_ptr = &group_handle->translation_table[port_id * OWNER_ID_COUNT * PORT_COUNT + + owner_id * OWNER_ID_COUNT + group_in]; + lookup = *table_ptr; + + if (lookup == 0) { + for (lookup = 1; lookup < group_handle->group_count && + group_handle->lookup_entries[lookup].ref_counter > 0; + ++lookup) + ; + + if (lookup < group_handle->group_count) { + group_handle->lookup_entries[lookup].reverse_lookup = table_ptr; + group_handle->lookup_entries[lookup].ref_counter += 1; + + *table_ptr = lookup; + + } else { + return -1; + } + + } else { + group_handle->lookup_entries[lookup].ref_counter += 1; + } + + *group_out = lookup; + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c index 9b46848e59..5635ac4524 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -11,6 +12,10 @@ #define NTNIC_ARRAY_BITS 14 #define NTNIC_ARRAY_SIZE (1 << NTNIC_ARRAY_BITS) +#define NTNIC_ARRAY_MASK (NTNIC_ARRAY_SIZE - 1) +#define NTNIC_MAX_ID (NTNIC_ARRAY_SIZE * NTNIC_ARRAY_SIZE) +#define NTNIC_MAX_ID_MASK (NTNIC_MAX_ID - 1) +#define NTNIC_MIN_FREE 1000 struct ntnic_id_table_element { union flm_handles handle; @@ -29,6 +34,36 @@ struct ntnic_id_table_data { uint32_t free_count; }; +static inline struct ntnic_id_table_element * +ntnic_id_table_array_find_element(struct ntnic_id_table_data *handle, uint32_t id) +{ + uint32_t idx_d1 = id & NTNIC_ARRAY_MASK; + uint32_t idx_d2 = (id >> NTNIC_ARRAY_BITS) & NTNIC_ARRAY_MASK; + + if (handle->arrays[idx_d2] == NULL) { + handle->arrays[idx_d2] = + calloc(NTNIC_ARRAY_SIZE, sizeof(struct ntnic_id_table_element)); + } + + return &handle->arrays[idx_d2][idx_d1]; +} + +static inline uint32_t ntnic_id_table_array_pop_free_id(struct ntnic_id_table_data *handle) +{ + uint32_t id = 0; + + if (handle->free_count > NTNIC_MIN_FREE) { + struct ntnic_id_table_element *element = + ntnic_id_table_array_find_element(handle, handle->free_tail); + id = handle->free_tail; + + handle->free_tail = element->handle.idx & NTNIC_MAX_ID_MASK; + handle->free_count -= 1; + } + + return id; +} + void *ntnic_id_table_create(void) { struct ntnic_id_table_data *handle = calloc(1, sizeof(struct ntnic_id_table_data)); @@ -50,3 +85,47 @@ void ntnic_id_table_destroy(void *id_table) free(id_table); } + +uint32_t ntnic_id_table_get_id(void *id_table, union flm_handles flm_h, uint8_t caller_id, + uint8_t type) +{ + struct ntnic_id_table_data *handle = id_table; + + pthread_mutex_lock(&handle->mtx); + + uint32_t new_id = ntnic_id_table_array_pop_free_id(handle); + + if (new_id == 0) + new_id = handle->next_id++; + + struct ntnic_id_table_element *element = ntnic_id_table_array_find_element(handle, new_id); + element->caller_id = caller_id; + element->type = type; + memcpy(&element->handle, &flm_h, sizeof(union flm_handles)); + + pthread_mutex_unlock(&handle->mtx); + + return new_id; +} + +void ntnic_id_table_free_id(void *id_table, uint32_t id) +{ + struct ntnic_id_table_data *handle = id_table; + + pthread_mutex_lock(&handle->mtx); + + struct ntnic_id_table_element *current_element = + ntnic_id_table_array_find_element(handle, id); + memset(current_element, 0, sizeof(struct ntnic_id_table_element)); + + struct ntnic_id_table_element *element = + ntnic_id_table_array_find_element(handle, handle->free_head); + element->handle.idx = id; + handle->free_head = id; + handle->free_count += 1; + + if (handle->free_tail == 0) + handle->free_tail = handle->free_head; + + pthread_mutex_unlock(&handle->mtx); +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h index 13455f1165..e190fe4a11 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h @@ -16,4 +16,8 @@ union flm_handles { void *ntnic_id_table_create(void); void ntnic_id_table_destroy(void *id_table); +uint32_t ntnic_id_table_get_id(void *id_table, union flm_handles flm_h, uint8_t caller_id, + uint8_t type); +void ntnic_id_table_free_id(void *id_table, uint32_t id); + #endif /* FLOW_ID_TABLE_H_ */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c new file mode 100644 index 0000000000..ad7efafe08 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c @@ -0,0 +1,28 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#include +#include +#include + +#include + +#include "hw_mod_flm_v25.h" + +#include "flm_lrn_queue.h" + +#define ELEM_SIZE sizeof(struct flm_v25_lrn_data_s) + +uint32_t *flm_lrn_queue_get_write_buffer(void *q) +{ + struct rte_ring_zc_data zcd; + unsigned int n = rte_ring_enqueue_zc_burst_elem_start(q, ELEM_SIZE, 1, &zcd, NULL); + return (n == 0) ? NULL : zcd.ptr1; +} + +void flm_lrn_queue_release_write_buffer(void *q) +{ + rte_ring_enqueue_zc_elem_finish(q, 1); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h new file mode 100644 index 0000000000..8cee0c8e78 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h @@ -0,0 +1,14 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#ifndef _FLM_LRN_QUEUE_H_ +#define _FLM_LRN_QUEUE_H_ + +#include + +uint32_t *flm_lrn_queue_get_write_buffer(void *q); +void flm_lrn_queue_release_write_buffer(void *q); + +#endif /* _FLM_LRN_QUEUE_H_ */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 5fda11183c..4ea9387c80 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -3,7 +3,11 @@ */ +#include "hw_mod_backend.h" +#include "flow_api_engine.h" + #include "flow_api_hw_db_inline.h" +#include "rte_common.h" /******************************************************************************/ /* Handle */ @@ -57,3 +61,92 @@ void hw_db_inline_destroy(void *db_handle) free(db); } + +void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_idx *idxs, + uint32_t size) +{ + for (uint32_t i = 0; i < size; ++i) { + switch (idxs[i].type) { + case HW_DB_IDX_TYPE_NONE: + break; + + case HW_DB_IDX_TYPE_COT: + hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); + break; + + default: + break; + } + } +} + +/******************************************************************************/ +/* COT */ +/******************************************************************************/ + +static int hw_db_inline_cot_compare(const struct hw_db_inline_cot_data *data1, + const struct hw_db_inline_cot_data *data2) +{ + return data1->matcher_color_contrib == data2->matcher_color_contrib && + data1->frag_rcp == data2->frag_rcp; +} + +struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cot_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_cot_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_COT; + + for (uint32_t i = 1; i < db->nb_cot; ++i) { + int ref = db->cot[i].ref; + + if (ref > 0 && hw_db_inline_cot_compare(data, &db->cot[i].data)) { + idx.ids = i; + hw_db_inline_cot_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->cot[idx.ids].ref = 1; + memcpy(&db->cot[idx.ids].data, data, sizeof(struct hw_db_inline_cot_data)); + + return idx; +} + +void hw_db_inline_cot_ref(struct flow_nic_dev *ndev __rte_unused, void *db_handle, + struct hw_db_cot_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->cot[idx.ids].ref += 1; +} + +void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_handle, + struct hw_db_cot_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->cot[idx.ids].ref -= 1; + + if (db->cot[idx.ids].ref <= 0) { + memset(&db->cot[idx.ids].data, 0x0, sizeof(struct hw_db_inline_cot_data)); + db->cot[idx.ids].ref = 0; + } +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 23caf73cf3..0116af015d 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -9,15 +9,79 @@ #include "flow_api.h" +#define HW_DB_INLINE_MAX_QST_PER_QSL 128 +#define HW_DB_INLINE_MAX_ENCAP_SIZE 128 + +#define HW_DB_IDX \ + union { \ + struct { \ + uint32_t id1 : 8; \ + uint32_t id2 : 8; \ + uint32_t id3 : 8; \ + uint32_t type : 7; \ + uint32_t error : 1; \ + }; \ + struct { \ + uint32_t ids : 24; \ + }; \ + uint32_t raw; \ + } + +/* Strongly typed int types */ +struct hw_db_idx { + HW_DB_IDX; +}; + +struct hw_db_cot_idx { + HW_DB_IDX; +}; + +enum hw_db_idx_type { + HW_DB_IDX_TYPE_NONE = 0, + HW_DB_IDX_TYPE_COT, +}; + +/* Functionality data types */ +struct hw_db_inline_qsl_data { + uint32_t discard : 1; + uint32_t drop : 1; + uint32_t table_size : 7; + uint32_t retransmit : 1; + uint32_t padding : 22; + + struct { + uint16_t queue : 7; + uint16_t queue_en : 1; + uint16_t tx_port : 3; + uint16_t tx_port_en : 1; + uint16_t padding : 4; + } table[HW_DB_INLINE_MAX_QST_PER_QSL]; +}; + struct hw_db_inline_cot_data { uint32_t matcher_color_contrib : 4; uint32_t frag_rcp : 4; uint32_t padding : 24; }; +struct hw_db_inline_hsh_data { + uint32_t func; + uint64_t hash_mask; + uint8_t key[MAX_RSS_KEY_LEN]; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); void hw_db_inline_destroy(void *db_handle); +void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_idx *idxs, + uint32_t size); + +/**/ +struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cot_data *data); +void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); +void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); + #endif /* _FLOW_API_HW_DB_INLINE_H_ */ 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 986196b408..7f9869a511 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 @@ -4,12 +4,545 @@ */ #include "ntlog.h" +#include "nt_util.h" + +#include "hw_mod_backend.h" +#include "flm_lrn_queue.h" +#include "flow_api.h" #include "flow_api_engine.h" #include "flow_api_hw_db_inline.h" #include "flow_id_table.h" +#include "stream_binary_flow_api.h" #include "flow_api_profile_inline.h" #include "ntnic_mod_reg.h" +#include + +#define NT_FLM_OP_UNLEARN 0 +#define NT_FLM_OP_LEARN 1 + +static void *flm_lrn_queue_arr; + +struct flm_flow_key_def_s { + union { + struct { + uint64_t qw0_dyn : 7; + uint64_t qw0_ofs : 8; + uint64_t qw4_dyn : 7; + uint64_t qw4_ofs : 8; + uint64_t sw8_dyn : 7; + uint64_t sw8_ofs : 8; + uint64_t sw9_dyn : 7; + uint64_t sw9_ofs : 8; + uint64_t outer_proto : 1; + uint64_t inner_proto : 1; + uint64_t pad : 2; + }; + uint64_t data; + }; + uint32_t mask[10]; +}; + +/* + * Flow Matcher functionality + */ +static uint8_t get_port_from_port_id(const struct flow_nic_dev *ndev, uint32_t port_id) +{ + struct flow_eth_dev *dev = ndev->eth_base; + + while (dev) { + if (dev->port_id == port_id) + return dev->port; + + dev = dev->next; + } + + return UINT8_MAX; +} + +static void nic_insert_flow(struct flow_nic_dev *ndev, struct flow_handle *fh) +{ + pthread_mutex_lock(&ndev->flow_mtx); + + if (ndev->flow_base) + ndev->flow_base->prev = fh; + + fh->next = ndev->flow_base; + fh->prev = NULL; + ndev->flow_base = fh; + + pthread_mutex_unlock(&ndev->flow_mtx); +} + +static void nic_remove_flow(struct flow_nic_dev *ndev, struct flow_handle *fh) +{ + struct flow_handle *next = fh->next; + struct flow_handle *prev = fh->prev; + + pthread_mutex_lock(&ndev->flow_mtx); + + if (next && prev) { + prev->next = next; + next->prev = prev; + + } else if (next) { + ndev->flow_base = next; + next->prev = NULL; + + } else if (prev) { + prev->next = NULL; + + } else if (ndev->flow_base == fh) { + ndev->flow_base = NULL; + } + + pthread_mutex_unlock(&ndev->flow_mtx); +} + +static void nic_insert_flow_flm(struct flow_nic_dev *ndev, struct flow_handle *fh) +{ + pthread_mutex_lock(&ndev->flow_mtx); + + if (ndev->flow_base_flm) + ndev->flow_base_flm->prev = fh; + + fh->next = ndev->flow_base_flm; + fh->prev = NULL; + ndev->flow_base_flm = fh; + + pthread_mutex_unlock(&ndev->flow_mtx); +} + +static void nic_remove_flow_flm(struct flow_nic_dev *ndev, struct flow_handle *fh_flm) +{ + struct flow_handle *next = fh_flm->next; + struct flow_handle *prev = fh_flm->prev; + + pthread_mutex_lock(&ndev->flow_mtx); + + if (next && prev) { + prev->next = next; + next->prev = prev; + + } else if (next) { + ndev->flow_base_flm = next; + next->prev = NULL; + + } else if (prev) { + prev->next = NULL; + + } else if (ndev->flow_base_flm == fh_flm) { + ndev->flow_base_flm = NULL; + } + + pthread_mutex_unlock(&ndev->flow_mtx); +} + +static inline struct nic_flow_def *prepare_nic_flow_def(struct nic_flow_def *fd) +{ + if (fd) { + fd->full_offload = -1; + fd->in_port_override = -1; + fd->mark = UINT32_MAX; + fd->jump_to_group = UINT32_MAX; + + fd->l2_prot = -1; + fd->l3_prot = -1; + fd->l4_prot = -1; + fd->vlans = 0; + fd->tunnel_prot = -1; + fd->tunnel_l3_prot = -1; + fd->tunnel_l4_prot = -1; + fd->fragmentation = -1; + fd->ip_prot = -1; + fd->tunnel_ip_prot = -1; + + fd->non_empty = -1; + } + + return fd; +} + +static inline struct nic_flow_def *allocate_nic_flow_def(void) +{ + return prepare_nic_flow_def(calloc(1, sizeof(struct nic_flow_def))); +} + +static bool fd_has_empty_pattern(const struct nic_flow_def *fd) +{ + return fd && fd->vlans == 0 && fd->l2_prot < 0 && fd->l3_prot < 0 && fd->l4_prot < 0 && + fd->tunnel_prot < 0 && fd->tunnel_l3_prot < 0 && fd->tunnel_l4_prot < 0 && + fd->ip_prot < 0 && fd->tunnel_ip_prot < 0 && fd->non_empty < 0; +} + +static inline const void *memcpy_mask_if(void *dest, const void *src, const void *mask, + size_t count) +{ + if (mask == NULL) + return src; + + unsigned char *dest_ptr = (unsigned char *)dest; + const unsigned char *src_ptr = (const unsigned char *)src; + const unsigned char *mask_ptr = (const unsigned char *)mask; + + for (size_t i = 0; i < count; ++i) + dest_ptr[i] = src_ptr[i] & mask_ptr[i]; + + return dest; +} + +static int flm_flow_programming(struct flow_handle *fh, uint32_t flm_op) +{ + struct flm_v25_lrn_data_s *learn_record = NULL; + + if (fh->type != FLOW_HANDLE_TYPE_FLM) + return -1; + + if (flm_op == NT_FLM_OP_LEARN) { + union flm_handles flm_h; + flm_h.p = fh; + fh->flm_id = ntnic_id_table_get_id(fh->dev->ndev->id_table_handle, flm_h, + fh->caller_id, 1); + } + + uint32_t flm_id = fh->flm_id; + + if (flm_op == NT_FLM_OP_UNLEARN) { + ntnic_id_table_free_id(fh->dev->ndev->id_table_handle, flm_id); + + if (fh->learn_ignored == 1) + return 0; + } + + learn_record = + (struct flm_v25_lrn_data_s *) + flm_lrn_queue_get_write_buffer(flm_lrn_queue_arr); + + while (learn_record == NULL) { + nt_os_wait_usec(1); + learn_record = + (struct flm_v25_lrn_data_s *) + flm_lrn_queue_get_write_buffer(flm_lrn_queue_arr); + } + + memset(learn_record, 0x0, sizeof(struct flm_v25_lrn_data_s)); + + learn_record->id = flm_id; + + learn_record->qw0[0] = fh->flm_data[9]; + learn_record->qw0[1] = fh->flm_data[8]; + learn_record->qw0[2] = fh->flm_data[7]; + learn_record->qw0[3] = fh->flm_data[6]; + learn_record->qw4[0] = fh->flm_data[5]; + learn_record->qw4[1] = fh->flm_data[4]; + learn_record->qw4[2] = fh->flm_data[3]; + learn_record->qw4[3] = fh->flm_data[2]; + learn_record->sw8 = fh->flm_data[1]; + learn_record->sw9 = fh->flm_data[0]; + learn_record->prot = fh->flm_prot; + + /* Last non-zero mtr is used for statistics */ + uint8_t mbrs = 0; + + learn_record->vol_idx = mbrs; + + learn_record->nat_ip = fh->flm_nat_ipv4; + learn_record->nat_port = fh->flm_nat_port; + learn_record->nat_en = fh->flm_nat_ipv4 || fh->flm_nat_port ? 1 : 0; + + learn_record->dscp = fh->flm_dscp; + learn_record->teid = fh->flm_teid; + learn_record->qfi = fh->flm_qfi; + learn_record->rqi = fh->flm_rqi; + /* Lower 10 bits used for RPL EXT PTR */ + learn_record->color = fh->flm_rpl_ext_ptr & 0x3ff; + + learn_record->ent = 0; + learn_record->op = flm_op & 0xf; + /* Suppress generation of statistics INF_DATA */ + learn_record->nofi = 1; + learn_record->prio = fh->flm_prio & 0x3; + learn_record->ft = fh->flm_ft; + learn_record->kid = fh->flm_kid; + learn_record->eor = 1; + learn_record->scrub_prof = 0; + + flm_lrn_queue_release_write_buffer(flm_lrn_queue_arr); + return 0; +} + +/* + * This function must be callable without locking any mutexes + */ +static int interpret_flow_actions(const struct flow_eth_dev *dev, + const struct rte_flow_action action[], + const struct rte_flow_action *action_mask, + struct nic_flow_def *fd, + struct rte_flow_error *error, + uint32_t *num_dest_port, + uint32_t *num_queues) +{ + unsigned int encap_decap_order = 0; + + *num_dest_port = 0; + *num_queues = 0; + + if (action == NULL) { + flow_nic_set_error(ERR_FAILED, error); + NT_LOG(ERR, FILTER, "Flow actions missing"); + return -1; + } + + /* + * Gather flow match + actions and convert into internal flow definition structure (struct + * nic_flow_def_s) This is the 1st step in the flow creation - validate, convert and + * prepare + */ + for (int aidx = 0; action[aidx].type != RTE_FLOW_ACTION_TYPE_END; ++aidx) { + switch (action[aidx].type) { + case RTE_FLOW_ACTION_TYPE_PORT_ID: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_PORT_ID", dev); + + if (action[aidx].conf) { + struct rte_flow_action_port_id port_id_tmp; + const struct rte_flow_action_port_id *port_id = + memcpy_mask_if(&port_id_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_port_id)); + + if (*num_dest_port > 0) { + NT_LOG(ERR, FILTER, + "Multiple port_id actions for one flow is not supported"); + flow_nic_set_error(ERR_ACTION_MULTIPLE_PORT_ID_UNSUPPORTED, + error); + return -1; + } + + uint8_t port = get_port_from_port_id(dev->ndev, port_id->id); + + if (fd->dst_num_avail == MAX_OUTPUT_DEST) { + NT_LOG(ERR, FILTER, "Too many output destinations"); + flow_nic_set_error(ERR_OUTPUT_TOO_MANY, error); + return -1; + } + + if (port >= dev->ndev->be.num_phy_ports) { + NT_LOG(ERR, FILTER, "Phy port out of range"); + flow_nic_set_error(ERR_OUTPUT_INVALID, error); + return -1; + } + + /* New destination port to add */ + fd->dst_id[fd->dst_num_avail].owning_port_id = port_id->id; + fd->dst_id[fd->dst_num_avail].type = PORT_PHY; + fd->dst_id[fd->dst_num_avail].id = (int)port; + fd->dst_id[fd->dst_num_avail].active = 1; + fd->dst_num_avail++; + + if (fd->full_offload < 0) + fd->full_offload = 1; + + *num_dest_port += 1; + + NT_LOG(DBG, FILTER, "Phy port ID: %i", (int)port); + } + + break; + + default: + NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", + action[aidx].type); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + } + + if (!(encap_decap_order == 0 || encap_decap_order == 2)) { + NT_LOG(ERR, FILTER, "Invalid encap/decap actions"); + return -1; + } + + return 0; +} + +static int interpret_flow_elements(const struct flow_eth_dev *dev, + const struct rte_flow_item elem[], + struct nic_flow_def *fd __rte_unused, + struct rte_flow_error *error, + uint16_t implicit_vlan_vid __rte_unused, + uint32_t *in_port_id, + uint32_t *packet_data, + uint32_t *packet_mask, + struct flm_flow_key_def_s *key_def) +{ + *in_port_id = UINT32_MAX; + + memset(packet_data, 0x0, sizeof(uint32_t) * 10); + memset(packet_mask, 0x0, sizeof(uint32_t) * 10); + memset(key_def, 0x0, sizeof(struct flm_flow_key_def_s)); + + if (elem == NULL) { + flow_nic_set_error(ERR_FAILED, error); + NT_LOG(ERR, FILTER, "Flow items missing"); + return -1; + } + + int qw_reserved_mac = 0; + int qw_reserved_ipv6 = 0; + + int qw_free = 2 - qw_reserved_mac - qw_reserved_ipv6; + + if (qw_free < 0) { + NT_LOG(ERR, FILTER, "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + for (int eidx = 0; elem[eidx].type != RTE_FLOW_ITEM_TYPE_END; ++eidx) { + switch (elem[eidx].type) { + case RTE_FLOW_ITEM_TYPE_ANY: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ANY", + dev->ndev->adapter_no, dev->port); + break; + + default: + NT_LOG(ERR, FILTER, "Invalid or unsupported flow request: %d", + (int)elem[eidx].type); + flow_nic_set_error(ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM, error); + return -1; + } + } + + 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) +{ + struct nic_flow_def *fd; + struct flow_handle fh_copy; + + if (fh->type != FLOW_HANDLE_TYPE_FLOW) + return -1; + + memcpy(&fh_copy, fh, sizeof(struct flow_handle)); + memset(fh, 0x0, sizeof(struct flow_handle)); + fd = fh_copy.fd; + + fh->type = FLOW_HANDLE_TYPE_FLM; + fh->caller_id = fh_copy.caller_id; + fh->dev = fh_copy.dev; + fh->next = fh_copy.next; + fh->prev = fh_copy.prev; + fh->user_data = fh_copy.user_data; + + fh->flm_db_idx_counter = fh_copy.db_idx_counter; + + for (int i = 0; i < RES_COUNT; ++i) + fh->flm_db_idxs[i] = fh_copy.db_idxs[i]; + + free(fd); + + return 0; +} + +static int setup_flow_flm_actions(struct flow_eth_dev *dev __rte_unused, + const struct nic_flow_def *fd __rte_unused, + const struct hw_db_inline_qsl_data *qsl_data __rte_unused, + const struct hw_db_inline_hsh_data *hsh_data __rte_unused, + uint32_t group __rte_unused, + uint32_t local_idxs[] __rte_unused, + uint32_t *local_idx_counter __rte_unused, + uint16_t *flm_rpl_ext_ptr __rte_unused, + uint32_t *flm_ft __rte_unused, + uint32_t *flm_scrub __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + return 0; +} + +static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct nic_flow_def *fd, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, + struct rte_flow_error *error, uint32_t port_id, + uint32_t num_dest_port __rte_unused, uint32_t num_queues __rte_unused, + uint32_t *packet_data __rte_unused, uint32_t *packet_mask __rte_unused, + struct flm_flow_key_def_s *key_def __rte_unused) +{ + struct flow_handle *fh = calloc(1, sizeof(struct flow_handle)); + + fh->type = FLOW_HANDLE_TYPE_FLOW; + fh->port_id = port_id; + fh->dev = dev; + fh->fd = fd; + fh->caller_id = caller_id; + + struct hw_db_inline_qsl_data qsl_data; + + struct hw_db_inline_hsh_data hsh_data; + + if (attr->group > 0 && fd_has_empty_pattern(fd)) { + /* + * Default flow for group 1..32 + */ + + if (setup_flow_flm_actions(dev, fd, &qsl_data, &hsh_data, attr->group, fh->db_idxs, + &fh->db_idx_counter, NULL, NULL, NULL, error)) { + goto error_out; + } + + nic_insert_flow(dev->ndev, fh); + + } else if (attr->group > 0) { + /* + * Flow for group 1..32 + */ + + /* Setup Actions */ + uint16_t flm_rpl_ext_ptr = 0; + uint32_t flm_ft = 0; + uint32_t flm_scrub = 0; + + if (setup_flow_flm_actions(dev, fd, &qsl_data, &hsh_data, attr->group, fh->db_idxs, + &fh->db_idx_counter, &flm_rpl_ext_ptr, &flm_ft, + &flm_scrub, error)) { + goto error_out; + } + + /* Program flow */ + convert_fh_to_fh_flm(fh, packet_data, 2, flm_ft, flm_rpl_ext_ptr, + flm_scrub, attr->priority & 0x3); + flm_flow_programming(fh, NT_FLM_OP_LEARN); + + nic_insert_flow_flm(dev->ndev, fh); + + } else { + /* + * Flow for group 0 + */ + nic_insert_flow(dev->ndev, fh); + } + + return fh; + +error_out: + + if (fh->type == FLOW_HANDLE_TYPE_FLM) { + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)fh->flm_db_idxs, + fh->flm_db_idx_counter); + + } else { + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)fh->db_idxs, fh->db_idx_counter); + } + + free(fh); + + return NULL; +} /* * Public functions @@ -82,6 +615,92 @@ struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev, const struct rte_flow_action action[], struct rte_flow_error *error) { + struct flow_handle *fh = NULL; + int res; + + uint32_t port_id = UINT32_MAX; + uint32_t num_dest_port; + uint32_t num_queues; + + uint32_t packet_data[10]; + uint32_t packet_mask[10]; + struct flm_flow_key_def_s key_def; + + struct rte_flow_attr attr_local; + memcpy(&attr_local, attr, sizeof(struct rte_flow_attr)); + uint16_t forced_vlan_vid_local = forced_vlan_vid; + uint16_t caller_id_local = caller_id; + + if (attr_local.group > 0) + forced_vlan_vid_local = 0; + + flow_nic_set_error(ERR_SUCCESS, error); + + struct nic_flow_def *fd = allocate_nic_flow_def(); + + if (fd == NULL) + goto err_exit; + + res = interpret_flow_actions(dev, action, NULL, fd, error, &num_dest_port, &num_queues); + + if (res) + goto err_exit; + + res = interpret_flow_elements(dev, elem, fd, error, forced_vlan_vid_local, &port_id, + packet_data, packet_mask, &key_def); + + if (res) + goto err_exit; + + pthread_mutex_lock(&dev->ndev->mtx); + + /* Translate group IDs */ + if (fd->jump_to_group != UINT32_MAX && + flow_group_translate_get(dev->ndev->group_handle, caller_id_local, dev->port, + fd->jump_to_group, &fd->jump_to_group)) { + NT_LOG(ERR, FILTER, "ERROR: Could not get group resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto err_exit; + } + + if (attr_local.group > 0 && + flow_group_translate_get(dev->ndev->group_handle, caller_id_local, dev->port, + attr_local.group, &attr_local.group)) { + NT_LOG(ERR, FILTER, "ERROR: Could not get group resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto err_exit; + } + + if (port_id == UINT32_MAX) + port_id = dev->port_id; + + /* Create and flush filter to NIC */ + fh = create_flow_filter(dev, fd, &attr_local, forced_vlan_vid_local, + caller_id_local, error, port_id, num_dest_port, num_queues, packet_data, + packet_mask, &key_def); + + if (!fh) + goto err_exit; + + NT_LOG(DBG, FILTER, "New FlOW: fh (flow handle) %p, fd (flow definition) %p", fh, fd); + NT_LOG(DBG, FILTER, ">>>>> [Dev %p] Nic %i, Port %i: fh %p fd %p - implementation <<<<<", + dev, dev->ndev->adapter_no, dev->port, fh, fd); + + pthread_mutex_unlock(&dev->ndev->mtx); + + return fh; + +err_exit: + + if (fh) + flow_destroy_locked_profile_inline(dev, fh, NULL); + + else + free(fd); + + pthread_mutex_unlock(&dev->ndev->mtx); + + NT_LOG(ERR, FILTER, "ERR: %s", __func__); return NULL; } @@ -96,6 +715,44 @@ int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev, flow_nic_set_error(ERR_SUCCESS, error); + /* take flow out of ndev list - may not have been put there yet */ + if (fh->type == FLOW_HANDLE_TYPE_FLM) + nic_remove_flow_flm(dev->ndev, fh); + + else + nic_remove_flow(dev->ndev, fh); + +#ifdef FLOW_DEBUG + dev->ndev->be.iface->set_debug_mode(dev->ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_WRITE); +#endif + + NT_LOG(DBG, FILTER, "removing flow :%p", fh); + if (fh->type == FLOW_HANDLE_TYPE_FLM) { + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)fh->flm_db_idxs, + fh->flm_db_idx_counter); + + flm_flow_programming(fh, NT_FLM_OP_UNLEARN); + + } else { + NT_LOG(DBG, FILTER, "removing flow :%p", fh); + + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)fh->db_idxs, fh->db_idx_counter); + free(fh->fd); + } + + if (err) { + NT_LOG(ERR, FILTER, "FAILED removing flow: %p", fh); + flow_nic_set_error(ERR_REMOVE_FLOW_FAILED, error); + } + + free(fh); + +#ifdef FLOW_DEBUG + dev->ndev->be.iface->set_debug_mode(dev->ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); +#endif + return err; } From patchwork Tue Oct 29 16:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147613 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA1P190MB2248:EE_ 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: x5TMtXLc4taSMc4IZKMzklAz+mwSonOBJ0bEAfJZsOYyh0OoqR3y3QaYiprBT98396q1YTceF2a0NnR6mB7X932DwJhyKl+GjeZvvwSwje5hCG3a44i006khoF5mYEmSyzxoO1ySPgI3B7CkhCruZV7SeLFzUX42hNBeG7E3BbKkXf9mM/+1VrAvZTBzKl0dAnrAOC0KmhHH4P4OLUEpUqZ+NRPll8M+ziuOVje5nSa0zSPJlLLGaBYfVSJtHfu2sw7/cc/xsdrlwS9ybjbwMJlNzu8Tuu/UFZTj3NB/iJALZ2J2yccsr0cNN/BVgZvioZsw88gNeha/KuDtxnaoLGCOkk3TV+vBDOaqhwfHOPZXscNfHGMTmv5eQ9qoo2KJ9z/zjDLIeGZE8i3yDsOS3hnb+hmTXHFl/76QenhVmj187qPt0S7NlY/YcLHdTi+dX6OkPNBS0kVZYHW30+oGQLcu0g67MFEv9b2bqlbaz6NToUNTRzu1v4q83cDGlMQ00WJd0BfIjLoWYhFFwXzbvvq8X4t/eYb9ijXdj82IwTfLr7PczBvGVLlyFTX/wBfGg/WloR3fmYdi007aX/ogVhxfpstP3QHEmg4w7h+xXhOiuQyMGWQ92eE5o30TxfrcxyUADlwEsgDPT+ZMGUYTofPfnaK5lH/RY3B11n/5byUjeoWB8uqKbn72D7g49kHheb6dztYrI0bry/2MnSn3QxOCTsy8ODHrGh1kY9BIfxSsBp+4c6WHKlpnA5TTwmz9PblcE3DJwmwbhgoXPfLa21uYrO0D7ZO6jC7LJBZ+qTUw4AKim0+EqYprfnT26gbnt4/OJD/V2f5+cslsRm/XvQmxP0AY3ZN9FZpzU0SjTHqAfWkYzIqtUcKst1iziCFhSU9xef+Pj9ziLp/a/FD1CjC1t3KjS6OZDpdWa0RBsROLah46LjfRoqQNXjoIKVygiLQD9wwzeFwkzZ4ThqQotM07KHeqCfXrNodiPsZV9QCxfG70B502ZiSMpNFzuYgPKLdlJLZ1219yVRHQTxVuneQ0HgqUQRjjiJ9qcyVT4Fj6g3CL8u1zPNUJbVj7c6AsInF8QJNmax3BpT8i+jcgEZWErq29KZGTpOjcChl2gEf+g2pQgZPaWFsg8DaUPad/0E+sgtD4qaRwnR5YLv36xRQwE08meaBur8gLaMnnBUynouwHkeckLp6lNL/CARRPQLA1tbUi6tx5+YGtg7XmKBjlAzVsyp/yg9Wq2ObhSAKmzPDuiejiDdHQcVnkdffTmApnJDNwq4NbZ4SV5ZUk9+K9AYF1W3lmXAT0HGuNdqn6QJ/fdNRxdRRoYimKhtW6VVUx7U7SOdnuQgB9qRUscHRsEc4Td5MV5/n4QAIR4Gyh5sw7yQPekItSgZzRpDAEwaAbFuvsqjmVF7BgfxSLSQ== 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; From patchwork Tue Oct 29 16:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147616 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F02F45BC0; Tue, 29 Oct 2024 17:44:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A64642F0C; Tue, 29 Oct 2024 17:43:13 +0100 (CET) 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 E498542EB8 for ; Tue, 29 Oct 2024 17:43:01 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2240.outbound.protection.outlook.com [104.47.11.240]) 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 16:42:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jZ4IJ+NdR8llW0vMODJXdq7llWI8BgFmBmyJ4yDSUeGqU5wCjsMqYEUf3gM5y7VuOqCIApsnqoo7PDBxpjKAoLEEK2SLZ2eRT4Z7KYgzhr/GHK5XOvjOxbg5sPUaGzcBx2E4ua38AJYOTJak1SR2i+VySx96XOvvwQGmw0FRi/4ITzQ6qKn775szwqPp3+4oGYfgPcyBr5mhnJA3o6Fgcf0WurpUTq0V/4SciId3pxl3YNKjK7gkKSQxchFpUfiBNJE5RJ5I6BBYizsMjmGqMftHX5ZX8IeFAnADTRPM7+PhBl2mtU6L+urAK8f2CNrwZkdfViDT/gZY7Y6Lvw9+HQ== 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=AaJuj1wNbEG/IsPq4NrQUTqwIAeTi0jRNKgtlaFugLk=; b=Ex5NqMwuAS4+JdavRrx0HsEr5GhfliN8AjioQDp+60dxDnbHDlflLRn91WLiGgbkxyo/zy1uB1PHkZI7pgjRiw0ujp9CBDsJpkF431QjcH3ALgqrS5hhzNIgxsQCnOjdvu56LhRfc048NStVVdp8ukqhqpkH5iHjmaRYmDPBuLNvCG+MIb4FPvR1n2nkhP9trx+Z815qrgL0UVpL4DxgRHmIOOf+WIuRxF56lYNpv0s3tm24ocU9iO2hQBBskDzQXopD/TBbiojWmVJDx7d4Nu3mqEz1SRcNvcmVp0Vv1a/TQJg6qksw7jEztiBZkDZckOolE8G+efBOgYnORKRTfg== 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=AaJuj1wNbEG/IsPq4NrQUTqwIAeTi0jRNKgtlaFugLk=; b=XI/DYt4aAvsZmat6ZSninQqbNf6HgsC9D8wk8Y8/1sf90ScWIatoJ4tK836HTpU4BctDNzP+ESPQlhT9jdRNU3VLJG5OiAj40NFeP1JiyoBPrIQAupdicT0lPmYxEP8Hy7ZGnRGW6Vsc1hZWbjLfZ83BLzSaKgdNvAZZWzhUOgc= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by AM9P190MB1106.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:270::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:56 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::b9) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:42:56 +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:56 +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 10/86] net/ntnic: add action queue Date: Tue, 29 Oct 2024 17:41:14 +0100 Message-ID: <20241029164243.1648775-11-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM9P190MB1106:EE_ X-MS-Office365-Filtering-Correlation-Id: e329cc84-610c-4162-a96d-08dcf838bdd5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: giPCcrb3Sew+qmNLVCw8IQI+XpA3ivsX2TtMq9tn7lVSdc6hYMwijbKsJhqZ1+fSbkDOdAElNZKksMYNfmJNUW+pbMGqcloK95fMvhlto5y/3v+Z8Srn39koN6SLImt1DnnZp9p9o/dTIec3xYABMalMd9ii9l4W/BOBx1qJtuKpy7lBZtnMz2f5IHmrejLi9Nfe2MOlBlmQAXo910Nkh6Bz9MCyLhVvCd3/CHaZZwSQWA/1OTvm7scCM++3WLq/4hewdzUMvhUxAG0jZr/hk00Jvu+s8UtYciMG/8KPKGURgtK3nKNMi0b6vIgp7iI1NvCDcg6+QLNR9p7VEacdoKiElKHDWXu/WaQIcQjSsCP1wq6cPl2LnW2kBWSEZSN7dpPNTLDAtX7UCSwZa/yvejiQUnHXDaHHfvBsWs7lE2YKYR+lQdx+gZ4eW1vx785Qfu+s1VEqegTbPfhL4gX29UCQhqw2LXNIhjNXhLBThGJR53iuK4Iv16Rr4GnDsudAwz0s9J8QIBbce9MHdS06oE7PVGdW5x/twrTljkAqNTreoY6DBE9XWPfKl/Pn9G/LkA3raKJfPe8Grn0GRTgr82CIECpcSmLaAEwZcVhBF7SBvnQ53YA3UFqfZCc7UjdkNuB2Scg8VEeCwAqf/xEF988voHI/ctMTdmtCty7hyr4qcZsB9dqtzRYo1MzxaZuW1GO4zyGlMDf5ztG7v/JFdrYIUTq0p2lv1AlbaMyXyjlzgTUljBpHhp3LvLMhUqqeska2iUDNjsGY/NT422IflZ7JMbSl4pcLyhLh7sJ7jbk/knQz3qLIHPCmf09dhmKrXaCUIL7cRrwu7jNZAJFT4i2jdI6JC+z8cE8kP+2RGyuc5vxqR5wgZj7ntSEXcr2EuVXTI56kZyrRRUdUbEvzhnIuUFStxz9Yn5G0tv6zKLLYoIBb6WxSdZCM7URQ02aN6TBeK+FBP8WVakapyBv5268XgwFgnXxU1hB+heOklV42bDmKvUCm+Q1faRIdUG1ybnjK8e3GMF270m/f7KFtKoVW226Caipjb56XYAM671QlFlNAHeelWWDv+C7q93PKcKvr8iqBN4hbfbfRfX1SHDXHdNvMiC5YVHXO2HUtBdLNuTIN956KLMJ8Pi2ZKBrgyQ0DJp4DjgCsBfnsHqMrC6Chw8Lo7/1iNx+vo6NXksEiROJ+B9Ip913Szc83CPHM0L+Zp3yagJUqfgbWmHj3BIOJ39nBHzdKKwyN0CnaNqowshY9Q8CcUvY6P2SF/IMbfDQmXPPggIy8RTgfkh9i0VMxEd4cYsk/n4t+BokssZ8Qm0byfNM00SMKu9oPTmHn1IOw49soRLXxtdPtyTkdYbYufi6+GEK76ZBWh7hG5JLcULwxa8SvwV9cTiTKuPfuwqjx377ejMcUr76zdZeEEA== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: q1UgSVwGiNoTEWEitwqknqJCGeflKnQio4DcrO31tTXxn1A7SQu2KO1hMk42FH7VB6mAniry/YIvyuE5url2/GU6EGWev2p5hFKrTCMMrdRuAvWZKfSzgHRYWN3dR0CMUHxugSFvVrdaiuH52GZxzQDdSqiyyNQzWdq/qTzrEFPurwTWJMupoSusm1N0Evpwm+Eyt8PekfJ9f3XW4FlWMkkFqXqeILmFerDF/AgQ3QPnvr5/Q59/U+yhVPO7WpHCIzsTMIJJu/J7P+Zvy7elTTFEuAG6zoDZ09mXR2hJcpRqq0lVgLnEfQMdmMZPmf1COITo8DSrgFwcSaW2t1Pert6QK2Fzag9UH+igg2QAWXDOolrxJK1xS1KAnh8qsP1bkcMPIIsBCzRku0mGug92RfZDAL8qaBgWJb/8bWYRRN+IdIcwC5+xW6m+eMK0e/56PgvCrR5zUb0bx2Be0vjGR7HxZ5VKJG6rR1z5VygJVGTUl+jDbh2/WCU3awEA7yedd4jgTyT1+vxqvJTC1LYVggNT94HLUVWdmUe+1MCdaAqiiYdZ3uXhLdWakUeh1KhoK3EoeQIC3Uowul9uwTdhHBhkkqFrei+QgP5+Ko1mAVT+DmlbjbuPEzFRAph63tBtKB9ans1ADi9mBKvi/jn34u/s9YbIP81FoGIFa0mf88Y= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:56.3864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e329cc84-610c-4162-a96d-08dcf838bdd5 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: AM9P190MB1106 X-BESS-ID: 1730220179-304438-12708-29921-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.240 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGFpZAVgZQMDE5NcXSyCQpLc U0Jc0oJTE5JcXSNNkgySzRzDQxzTBZqTYWAHVOz+1BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan19-202.eu-central-1b.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 Add possibility to use RTE_FLOW_ACTION_TYPE_QUEUE Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 1c653fd5a0..5b3c26da05 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -18,3 +18,4 @@ any = Y [rte_flow actions] port_id = Y +queue = Y 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 0f136ee164..a3fe2fe902 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 @@ -23,6 +23,15 @@ static void *flm_lrn_queue_arr; +static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) +{ + for (int i = 0; i < dev->num_queues; ++i) + if (dev->rx_queue[i].id == id) + return dev->rx_queue[i].hw_id; + + return -1; +} + struct flm_flow_key_def_s { union { struct { @@ -349,6 +358,34 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_QUEUE: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_QUEUE", dev); + + if (action[aidx].conf) { + struct rte_flow_action_queue queue_tmp; + const struct rte_flow_action_queue *queue = + memcpy_mask_if(&queue_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_queue)); + + int hw_id = rx_queue_idx_to_hw_id(dev, queue->index); + + fd->dst_id[fd->dst_num_avail].owning_port_id = dev->port; + fd->dst_id[fd->dst_num_avail].id = hw_id; + fd->dst_id[fd->dst_num_avail].type = PORT_VIRT; + fd->dst_id[fd->dst_num_avail].active = 1; + fd->dst_num_avail++; + + NT_LOG(DBG, FILTER, + "Dev:%p: RTE_FLOW_ACTION_TYPE_QUEUE port %u, queue index: %u, hw id %u", + dev, dev->port, queue->index, hw_id); + + fd->full_offload = 0; + *num_queues += 1; + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); From patchwork Tue Oct 29 16:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147614 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BAB045BC0; Tue, 29 Oct 2024 17:43:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 903A042EE1; Tue, 29 Oct 2024 17:43:09 +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 4312142EB8 for ; Tue, 29 Oct 2024 17:43:01 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2111.outbound.protection.outlook.com [104.47.17.111]) 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:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iKT4Bu/6sij1lvLPY0uvbdFmpShcX0VjgwusTsyp2L+wnL+R3J8nV9fSovjoT2IuMFX0zaDIdU5pBhdgg/6N5RDiQnWt2mIG1pe1s9ChWbjTNrQ3Jj1Vs6uqENfoRmNLY/XZO/voJ4WecQVStDk46Dr/h5bIST0AYXTzjGxTXWAa6djtLR0u3WyG9MFVca8Q9ags+JKV/RQEwEPdQGqwEAhbLcHMh1+g1DvV0Na6aLAw0wGs6p9SzhtfpQpKuoYBjJOc9dgAtB38f/drezWlOQH1ZFW/FcqHNoo85AJwBFMWrgbIPZXxnTT0YrtrS0ziInCmeIQvSvvFjb9s+kQ1KA== 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=pDnNHzFmP3gjrDde/IbPadvYXZ/RukS+BWdu/qHrzY4=; b=vmmqgW5FTMZaKjzFd2MgowP4w8UurMjvQceFC/e587nxrGeGWKPuq//ALDq0cCJSs/3Pvkswr8ou3E66TxE8bYAd6d4Fjwm7Bio/CdtNNkHYZVjomfpbJjdJSDRUKbts8ZnqdCgRKrvkDALnLxiklq7giY+Rh/WHwcsbE1Oo4i49L/wacQmaAam03E25VjZIpLhfD2oGj8KeD24M+bBK+Dz0gCGwODEstI+WxVFxLsUeKoK0c5pF6nJ5deHmvTsuaK5XdplgRXkZLDSkXLnp5gX+XeSc8F7Ld3wuRsbqqba7882qC3XH89x2okNcjXYnMOzSm4dYqxLSEAaWIHB6jw== 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=pDnNHzFmP3gjrDde/IbPadvYXZ/RukS+BWdu/qHrzY4=; b=UhlovpbK/5oG4cycVvPl+51E3R9vyEBZU9KJpvG5+Hq9Nxe9m8sLFcL0XuNJRP1Bi7fQVJ40S42GkYzTdAMZ1PgAp9XnH+I5iXWRMUE30x49GcDSUZdC2uzP4fz4F4JYBYY1ZhAs+XB3GROKj2f7A5blaIEvtTtR7k2I4s0yBKE= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by AM8P190MB0962.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1d2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:57 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::b3) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:42:57 +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:57 +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 11/86] net/ntnic: add action mark Date: Tue, 29 Oct 2024 17:41:15 +0100 Message-ID: <20241029164243.1648775-12-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM8P190MB0962:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ef35de6-7bad-4f84-1a4e-08dcf838be48 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: YJs5135qJaUhrIvaWGvARI8epT93IE/gij/8UQRdLcM4F1DRkpvSMoQGZdASuROevwDPwYB/iBc/2Dpay6HE5Og4m9vlmshsTuFfzuD6voDpjgsvc0/Ov/1VzhD4SfEIZjhe2zp7UhiWLP59jY1y1N3E/nWruuX/h69LDQGUiviqoFWEVn3MErh9AwZS3etGPjEbF6MmWtfSj1ZOfuKwdWNj9DD230oPQaYkZT9eOe6stUecQK5w1ZORSyRlbICkAD7mcSeYhiSys0SWVtF8kRv7wEnOJUdUa2TWU3dPlh77AAyoO1g4WyiSXd3Udkdkq5DgGWpVI5HCjoY6Za8cCTI1/KpJLh2jWFPbuHNjA3JDn+5wX/ZZ0aRGrs1DPG6AoTTPUHZY8rfgeuB742GB9Gfzi5J2pqG+qCI81hsK/nlcIVZbf9L502aAiFEccEhbYQHbESwXhAaE6yNddMXqnX7PUCtdfNbaVFHDjOkVhi4rasgZeqzJGwjsXyJduatI/SUBxlEGJexAGuzxBqeONikeHjjzz2ZBGn57ujXrUfe+SS3NSolF8vc8PLKGBFZznvA8f0AGUZp51ihkx7kPx5+YJcHCJSOweCL6NxZ671AzuYy1p0PzW2P3Q6liE5lk+6kNjsAWmZ9O05gZq3rdZGBySUVLMUDCwapf4eubTTacWUUK/uvIyflP1CWuCz0tKRqjkD2SnckmILyhdEfmPayNuQMSVJXjw5WJf+XFzgQpRfvSVI2DKu9ushSTELqegV8X1+IB/k7TD0BNEiJqmvKrF2Q7qV6yeh2h+2ILA38EHfAKGR703iKJhwaUsLTOGSLtxS7zKDiv48doZO+71V+HD99BDMYryD53vwDZioZ+KkcG6gD62+L+jLhG09YRhNxVqbnpVHXYxITzdXmHFZt7laOalz+Boxy+kVneQKtLwfTQyeOcGJvL6kWf6rIGi6YsIBrsH/t2jt/ur2EHkJ4JcZMK27P+svXpjuxqRDEkjYe4O7q76RnB5W3SMNLrrG105ZvXOIxR6VIFsxBC0u2lOohGEovFiN+U7L97XYwnTrrvMsdTv2RoEXPhc18OircwGZ8Q0JyRMsW03NFtIBQyEcb3Pv7mE19zxYi9RIcjp1W8NGDOHTRhiZR52ZT8uqaKEHDUGWtrpV/oEwoLOzXTSY/XTKwV974Quk4mAwV/h78pLbMRvC1VxFV/pWD/d1tsn4N7wAv897uDDeem23eNfN7byK+jLaic+zTlIns4Eezl/va0YBYg+2e2eN030gAoFyrmnTtb91d+fgGcHgCI48mijE7gshaOdnY02B0eSSZk2CaYIIoXhJNK5KJmuvey9GG7XmbTkThfAbedVYTdPK42ev7Q+3gJ32ajB0zSRzwic1F0pcfl9ymHVo+Jxka1Dm0wKdQcMJEqtKtSHQ== 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: jqeRSGAJusg9hgrqB87TGeMh3umrudg81TmLluv/j7TpetmNJEfqCchhR0l5NfEBNnv5WlWbaai76zY1LWkqVx1VZLg3kXo7nZmFoL9oTBv4KnHuwRiA91/EZqZY06RH8CbqNNGbzkJIBsksBpkZaj6LwWSeFHwNgt/o8ZcOAvLLamhCgqSzcItoALolk5X2ltIOrnwRuk9jZ0oFze7LtpE/Rtk0JuMfVcdDSPzta4oODi7CsOZmt1dfJ/Pul4zLy8Wqu2IVDAE15Q8cx4kzP2sqltMYAfQ/iZ2E7p8msF+TyORLoVGrO/Bym3j9HZkYJnWWoi3Tu/v8yIQ58Uxeq+Tqvz8b27jIILTx1Y15K0CSivpW/syUZSk4XwpRFD3DQRiArVw2BbT0dUy9h9L7u2UV/LG3FQunHIV0gEuKVaTqsgeiUgmXaaYTrRXrXTKEagQbk5Kk5AonJBUYk65LM483vyp0LSkzOAY1VN4SF05GhFgEGiCvtiYgFJ66nnD6oyhrYVObUEQSCbOCwji1U5CIFVE//uwBn7o/2bciJpntz00cTFFP1Ttp3DY6wrq+nbqp+CWqkNDgI6XpZlPjhbR/GK1hmSmxKbxtPLA/JhpYwS3t0t71yiuM8YJeGUQq2IguHplEUKBVUMh+XS1OkXtaBvEng+z5o+MG/lu88/0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:57.1364 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ef35de6-7bad-4f84-1a4e-08dcf838be48 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: AM8P190MB0962 X-BESS-ID: 1730220179-303097-12758-29318-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.111 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmlsZAVgZQMMXcINUi0dzIMN nULC3J0iI5NdXQzMTYMtXcPDUtNdlQqTYWAB63Pr9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-223.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 Add possibility to use RTE_FLOW_ACTION_TYPE_MARK Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 5b3c26da05..42ac9f9c31 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -17,5 +17,6 @@ x86-64 = Y any = Y [rte_flow actions] +mark = Y port_id = Y queue = Y 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 a3fe2fe902..96b7192edc 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 @@ -386,6 +386,22 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_MARK: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_MARK", dev); + + if (action[aidx].conf) { + struct rte_flow_action_mark mark_tmp; + const struct rte_flow_action_mark *mark = + memcpy_mask_if(&mark_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_mark)); + + fd->mark = mark->id; + NT_LOG(DBG, FILTER, "Mark: %i", mark->id); + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); From patchwork Tue Oct 29 16:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147618 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 93E1345BC0; Tue, 29 Oct 2024 17:44:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1EE9242EE0; Tue, 29 Oct 2024 17:43:33 +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 BB1CC42ECC for ; Tue, 29 Oct 2024 17:43:03 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2111.outbound.protection.outlook.com [104.47.18.111]) 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:43:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kq2D39eOLLdoLgBOyQBci337HWbSqenyAGQ5mw4TCaHOwNSSPoO0q+7cmyWV3cXh4XZeDIX0kQLSD9RLvWm5M1x/35VBO+8VpRS1NutxrpvDeWtH9alGjNUGRqR02x94nPAWOFHby4ArXVIYK8BhcPZyEKilvQHOOkz3VbIHbLMJXI8LECLJwBJx8EqiU+uQGyTu61fk0hgvokxlmHJ39kf4g3imKb+5yXcpoh2E/YyUKQAFFG+QwoAnHsoSnSwrFwPu9kh9Era8JY5meSbqqlyzx7ta7EJKMPsptCJ2fFBCqC2klUhdfBSMwyDM2oYun90aYKjy9mk1hAJ/rvlhBQ== 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=X9LamrOLILG9hkWp11QXJhepv2G49oHuJ1jq3SD/a20=; b=fgQECWY7gxJMycnajAMjgoPDSHo1PeJNR9gDcY+0QDHnHJKaks+z0y3FZff3HRmd/IjKM911dTU6cuDNB0n8Xln3nHPBpX4UmhFGQGMaHE1xJVncZl4mN7tzTzZebyBb4f+GBxtN5GYHdtFERtxVbcJEFIXOyqrpUYdg/G7W4oybYiYHTeB0qQnCk2jpJ0zTsRo+SZWpJagPmx/nqElg2w4Tgb1VnYEvEYqCxMnKX+zIMbtyzIKHCyfnlqv+kYQ3ZneRTmjosHLN5QpTndbmJkBPaFEdrpV6gNF+EXUmZXbVoOb1/yT1jR5W2m9KI4lDlHaZ/FyLjdgomny0taqvUw== 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=X9LamrOLILG9hkWp11QXJhepv2G49oHuJ1jq3SD/a20=; b=LTul/Gs5XPFE4xZAXpZu9rAggPbP+yw83j4upGf5UoGMAvLKyA8Yn2MgtVIvgJAVFGTNztIWC5zYpVvBO1/EyTRX4jxQu8ta5De38I+2vwJtEtmyPq/RaU/2CWdbEL0d7ynVZJSPSF7jSkHElEgsIX3XCrZVUmFGREKP0yeQS9o= Received: from DUZPR01CA0193.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::14) by VI2P190MB2121.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:230::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:58 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::c9) 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:42:58 +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:57 +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 12/86] net/ntnic: add ation jump Date: Tue, 29 Oct 2024 17:41:16 +0100 Message-ID: <20241029164243.1648775-13-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI2P190MB2121:EE_ X-MS-Office365-Filtering-Correlation-Id: b690e333-876f-4d0c-0052-08dcf838bed0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 2s3SUglrOamJk3R75D5KVYPiz23BNnEz1kIqacS3oE3w3yhKovCdGTPJUw4ublCglo+AwaYRRSnepDzLN10YCqxwq1We4hRTnyQN4NY06NliF7Y4gS3i954lkc4TveCEYHN+DeGXOjzZX2x/Em4lTv9/3k+5Kk9F8P3b91/By5bLriryUQIQJsg1PihAPtjvHAxooGsYyR0b8fvIQU0kBwFTVClaqRDmCepXHFHsXdefc5eScbaIvTBedDEsE2isxqZP0+mOEJ85et8BqCD2s9OTlPQJqAOZx33+Bv1/eZ8ZLV/KWSuXnR3a8wZa3QHpB4ub+jf2ZaKrOBPw8CxHvY8gDr2xX/gV0IKnZehDaxohZbq+T4XpG/KEH7CK0tHE9VHNLJ+8pQ6cch9FMB6zpnwjsKMto1d5aYUrF/bWHzagSybzwGMzemtSj53pxKIjc90rHE5z0ui0ugXYhw5E4EsIALUx22jnxUZKWJKl09hCuc/NaZqd1VLyc02x90veRtjmpqFqXfKSeAS9sDl5toeNzoGQXApLUCYTS6KXxgwpH3UcdD0nx2DxpAcI7lyJClExBvXTmygnH7PolDh5aIx3JB15F3fJVpB3BZT2kecHbyLyL9l1gx1vegH2rSijl/NmATJrpKwX+dtO7zSTSDr7ON0OUwK4c3Kw0Tyj9cHt/jKE/m2gH3haGaiRsI6RZSgPKhJzDg/QcPa4cDjc7UJGVAFSxxwuYileQT2GTK+Oft66VvhHb6AZJuU5SQvd+7ALdTYfqpad1PZyHjclGnIGfSv7nL5Ma7yNF/Mi4DwRBZqjWO8h7lV/WL+dDO8F6mZp0Z37FYEkvE1p22JuaTZ2TiReiGiBrin1gGlrFE/7fg8ABEDiCZJ1MIvzmrjDsB1cX19wyfM1Sc7sWYDnVYJjhx8K1VyqYe/YJ5q+rsvEBRxFxof9831uohsZb/rugoUiQrCKtjeHedUVn8Y7zzSbAYd+sU3dRpSikp7SOLAsh9KL7yu03lv+blmJ1D02am6CDL0Dc4aiEzH/tiMrCnuXpj3zAmBgYyRtPOO2Flh2nBxhl0JQtz05XvJ2PTR/KagaLBheRi2ms1ko0bvRivUBAe93hrhjz8btIqexHBMCXVC3Ms0dQhEDCKZ2eSKeu0L+m7PsTVmAIcHSP+Na1yehUcrSUWNl8m7tC6ht6sf7fjRj8RkUblSc1KoWtd7f9ulJ2rRPsV3i+wj9IbwPGcZPsQxdScNWYBwiZ3DkmgZZ+5+XYjX+YDutADdxTNGbOa0DXgxqpLFSZueCbmdf3zmjV/kbyuPfRfoK57b5HxZ5929+754V/0gYxyRRJ6z5DofEEjxVgAOZvhHBIR5EBUyHHMuVI4yIdW7BV3z8xl8SQN9Hx21En47uB2Hp3taJb1/IHBAxDTb1+TMe1ckV+Q== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pxIqvc2KYu3jQErwI56jtHFlYkvCPIJZojx5SXGIz5+wBzOYmwjtRStMK2rcs4BvciTvrxfMSyhR4G4bwvyoXH7gll3dK2qXDFpa2WoQ7HlmjtFaQ3iICy47p4k27NEmGn4YX5ZAISsHGa+3woHWyYhAjtIZNdL0YN4Mu6Z31PpWtv6CwDnHYDybgyrohG1rSFwuyj4JvBu5LYUAkL7WOgNKbtpkV/ADojouA0pdfHbyZe8efMImo9Y0wVCOxRN0c/G+nh74kjeIYkmt24jEgwaU+nSrHytIDvUwvfngxSstk3unH9gvQWb4RJcPf1nkzjUGJQK7e/uCbfmfRJ+ShKpeBbCA3H5sFliky9q+lk6U8dNOIM3fOcNENMOWryUlvQHYoFU4lhPhT+8lsS07XQxV4OEi245q2uFStI2sWyEnfufuDosNkcd6rEz8m5eZR3SK28L4NAZ3d02DN2FH/V1BM/lxAG4yi1cWxpRTY8mjYnpnpTrxb7d95hr9JmMOL/Uc5v5gASwCHKziUSpekNNwEPK93qhz+2PPoIimWM6rdzrFT0UgnqlY5tf4/szmMLCnQ5cLU49aKQo4gfkw06V30i4yZJFCHVbNSL3pWl8IaQRhYoA3RJ4jkcaqG8OlxvKDD1/5Ei8oOOZqhocX0GDzgMHMVtXTQ6ZXd7jsaCk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:57.9646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b690e333-876f-4d0c-0052-08dcf838bed0 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: VI2P190MB2121 X-BESS-ID: 1730220181-303097-12763-29321-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.111 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobm5pZAVgZQ0NzQ2NTSzNTcyN jIwtAwydDYyDTF3Mwo2cASyElNSVWqjQUAtvNo1UEAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan14-53.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 Add possibility to use RTE_FLOW_ACTION_TYPE_JUMP Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 42ac9f9c31..f3334fc86d 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -17,6 +17,7 @@ x86-64 = Y any = Y [rte_flow actions] +jump = Y mark = Y port_id = Y queue = Y 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 96b7192edc..603039374a 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 @@ -402,6 +402,23 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_JUMP: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_JUMP", dev); + + if (action[aidx].conf) { + struct rte_flow_action_jump jump_tmp; + const struct rte_flow_action_jump *jump = + memcpy_mask_if(&jump_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_jump)); + + fd->jump_to_group = jump->group; + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_JUMP: group %u", + dev, jump->group); + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); From patchwork Tue Oct 29 16:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147619 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C646645BC0; Tue, 29 Oct 2024 17:44:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4084242EF6; Tue, 29 Oct 2024 17:43:34 +0100 (CET) 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 5AAE342ED5 for ; Tue, 29 Oct 2024 17:43:05 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2107.outbound.protection.outlook.com [104.47.30.107]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fdyWo7HOiXhlpaIEKNwHlH9lqxhXn/ECq1zVxLQkg//V3Hh3ua++nRn/oHZTI887EUyml2bfZeSYPCK3JtuqdHRFOCzE1eNI0GcIQDWy2O77GbdvXQwFYZejzRDSaF56SImHkAkjnp8u2ILQ+lzggRVHr0AlMjUam9S1wsIq62RZcwY1pqx2we/3LE/JQAMr2QuLZKb2q0PmB14lkW14T5DrXqjTnlDagEdFr/FlWIfAjzQU2gKTGbfy+sXzGSiOOsn6T2beRySR2z/OpAuu1D0Y6mGCVwB3XBds4vcAX/UpqmVi0KIt9WhcFPX7yUwc4xhZRURlaKKmzy1liYAL5w== 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=Lz4+ghfgscdfLjKF381KR3c7W8pFmP6F21yGKlU1D54=; b=IhYu+PJ4C8p7Wl2GxsQ4VABvlJfEITMqxU0P/+VS1GB30QV/tRWIrq2VlT+1+PYCmywpZhWW/9y0Ysj8fe9NtP2SGcb4d0ctgQUSRj9STsLeRYW8aQqPWIHpQRhaWrQSFR6sfVYdBsSGPiTz4XCjhoiuTv/5AP+8072i7J6dDtpVeziIw6gaO/vdx6KBWaSa7mvWysmXRPaNGbByMHSR6whTt00hDqP5vbHIKj1R0+w4DB+P0GJ9aZ0lWnOG8vtcpU18BFVUO3paysqVm+EhDRMxXysG6YUnyVZ53kvVkPc7F3mcEqBnk3W1HTtA4YeRDELcgK+iaJEGUuUyJkEl6g== 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=Lz4+ghfgscdfLjKF381KR3c7W8pFmP6F21yGKlU1D54=; b=W/S+mFhoiF9QD2pG/f0w2CyR/x+uMJUVZHPeO/PG8qQ2lDEMwqggNDHabAIYv5TFFUIhp8aItwRrrB0qEUFzm5+5UnS+Svf6H403NMweBBsYeYrSh+Kxe6IE2OQZ0TcH3/jLPoT56kC1yeso5LwTMYDISyByjDHnoCDLGYBK70s= Received: from DUZPR01CA0210.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::24) by VI1P190MB0688.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:126::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:42:59 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::f0) by DUZPR01CA0210.outlook.office365.com (2603:10a6:10:4b6::24) 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:42:59 +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:59 +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 13/86] net/ntnic: add action drop Date: Tue, 29 Oct 2024 17:41:17 +0100 Message-ID: <20241029164243.1648775-14-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI1P190MB0688:EE_ X-MS-Office365-Filtering-Correlation-Id: e1cb986d-dba7-453a-32db-08dcf838bf85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 4pEboxoVjXZD2NNFDCA8w/mUco3BvA8AeiDd4HB6gCXOGw8DlvKxX+SpbN383CN69hYVnwaEd99ewLXYtqNtqFQBsCumn9Ox3q5/D9QXo7IsdiBcuCpZ6FiKV/W76Kimmt/1JGPA3VUAVbD6zpHasauE9OovQALGKOU1wqfd1bfIbd5jfx7l85FB95+yxWv7618Cav+cIJR+iDz/4LlO92yCJV7wxXxiBpk7DlR3Vzf/ML6C/dMdE4rOFaypRYS6yb0/72146ZOeG9Pjn6Jotrb6yXACkaZvEoSgRlp+sF20lynL5tgiC5t8LfI5xYpr7Zk/HQ7+7Q7G59lVnXWcTiSa13JNm7xN+/vJNUDwZ4YIKexiGMSR3mjD5CC/5tpm0oqJvJN4b6GK3uTXrrJwEUGt14m6sQh51QX3f4jRcgW2ymYJiAwfJF195hO9qmGK5La04BkIJhKjxNG9inNlTO0ujlO1ouoBItZ6Sg9uGMKAmNpYQ4kS6geVaolLSYPnU8NwOQ1f3hpRxaj6Z6yZJzOG3R2KGwzYyDqz8FcE35qqN+EW/z3XnDqBNikTyLBEgKVCz128/2Y/F1m40b8h0iCmgWXKvkaxKkbjqRIQADgpyP/a6WQe5rhi9blnWgjHF24IrQCw6ySLvrfs5vgvyeS3HWPJjdk30tMVFhEIY2tZlFCHbFip4U7NDNlSwxhWvowSMmtFYg4DgBvo8GyfDaZYASj06jL7NbpNLFNIrDUbAvyF4MFbzYQU3APhXvIhGyBGt0DQgdMlMoT5Cu3x60nPuneXPmYXwzgm/Gl4hSp3GlN+25JR5kicKzWre8TULa+sXH+zrG7BCjZ+m7jJSg9HL4cQtpodsvq+woB1yV5DXnGSMGYEwx62lEzC1ppFfo/CW5SqbQz7kQLBDny+xz1pMdZoK1DkVGrsPt2Bqo2udit86YdwsdujNMEl8GEgxgp3YXZ5IUP+wAVDcZeKXq9ILRztdBZEyEBDUZ4DrfAvUrdLmWreXC7VN4NJT/W4zZQ3BAKHRcAGbNPQNzX9qlwZaM+3TWkPXTEsSFTuSGjBxkTu5UzGN6Rr1pIp543+GXkbHW2Mt+mwJ8vFVyztp5PJexDrVMmqY+/MjlEVYGiKEI9uaqtrouCNjFdYVPOPflmW8kCMyTTYrhagzNo3IpLxS3HcLsvHZgI3tPzdhVPGMgGvaWN8Z7FPsU6fd6ZcMYv/B4VZ/q1Qe2OivG/AugEbcv0kOPh3kb2OCI8b/6ERnUZDwBN6AWJ6/QK0ZgTyYgQ7O48gLYYQ149x++/G6dh8U5r3VqgTLGG9Pt//zQiqK32USGkYr+BNQeP4jE66x0djhsKlRrtUnuWEOuNsb8DFLB7t3rowRsYnk9liNGK2fwJlmDmJ2qRddwieNGLmu/DZAQI+hdRIS+x1dypA/g== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: r3HHf+pRPGTSBLMkQ2vwH5cHFZjiWlTIszl/tpVxf45n8cjHKfcyjRRm0EhefNl60zIGJo3X0H72x7SC5NIqJ9f2WvmWAzr5ES400fKpEVa1ZQTlFl1jBDJxgSXlgPCuuaNbdNSr2H8xTe365u8KYMOXvNWfX5uim0pWxkkgncTbUM6tDjdvPlmDAjEEcOaPQXhWMTZ36N4dZTyF7Ve0G8kdUbLk16e3PP0WTj1o3/l9WEuBdk7Q45I2mFCnLugHTf5QunVJACqcPuqx0LGaw0UbEb3p/VyW1XBA9crbPcAK02rLaDyDUUmfgn062+NKzdRa3TzmhJbsWItdFxj0ded1gTLvXoaRMZMgDtbWidT3JVgvQZdem7iLcZ9Wp/5xEGm8VajrdDjEPcmmLgtrJU8TJaCPve0TYacEsTBmwNKwuXkOZPMvdeYyXc1HTEfPMUkHXEWxrdw4mAjaeF6o1+d6E0ksm+HdhrWK4haHSdObx7fw6/lXL5Vw3QUii1Y1wBmnkWk5d0YgeUAoM3S8OEZp+fy4uHaFCeFaxg4KOwYWM/OrsQ1FLE2IIbwr43sVzcJBK1DUW6RB4hT1x0joqpiA1m21HwfFCvCenf8qaNA/MRkIuYuRBAZCjYsmXk0Dv4cqrWgHreDRCap252i+EhBBaSNvtmHMrB/jByNFKmw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:59.1989 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1cb986d-dba7-453a-32db-08dcf838bf85 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: VI1P190MB0688 X-BESS-ID: 1730220182-311207-12668-27823-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.30.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamFhZAVgZQ0MLSzMLSwCApyT Qp0TQ11cjC3Dg1DShmamaQmmhmbKJUGwsADgZKk0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-5.eu-central-1b.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 Add possibility to use RTE_FLOW_ACTION_TYPE_DROP Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index f3334fc86d..372653695d 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -17,6 +17,7 @@ x86-64 = Y any = Y [rte_flow actions] +drop = Y jump = Y mark = Y port_id = Y 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 603039374a..64168fcc7d 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 @@ -419,6 +419,18 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_DROP: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_DROP", dev); + + if (action[aidx].conf) { + fd->dst_id[fd->dst_num_avail].owning_port_id = 0; + fd->dst_id[fd->dst_num_avail].id = 0; + fd->dst_id[fd->dst_num_avail].type = PORT_NONE; + fd->dst_num_avail++; + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); From patchwork Tue Oct 29 16:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147621 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41B9C45BC0; Tue, 29 Oct 2024 17:45:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BAB442F09; Tue, 29 Oct 2024 17:43:36 +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 59A5542EDB for ; Tue, 29 Oct 2024 17:43:07 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) 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:43:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D+TQm+Qm1Can27WeCsKhSatn77K1Bo4Yq8+nWGhxrKnJY6gfUDHo1hJ/OCf0RGglUHwqjOZuOPsYukPF68a1YPH8WiX+0gBToVSJ3sgcLLW16v7Y1QJvHeMiz0VZBqkpuGGF3tRmxLYPNupkYNgpWQzVS7G0BH6zvZHSoxNU0Ytr7Qawc1zPvnr/6ysOTlpw15/uwsIs2j+0MQldzyn9Hfb1jJ+4dkpPnYR2nKwCwNED/yeSVfOgaGPrNYqfvuF3cUyOo1rQzXwgjmD5hkQ90eKepmX7Ky+SLBEJQ6OarPmeRDziHF1jxUmeoLwq8pfcUok2msn0dKH6OVTZNCaAjQ== 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=7WcEVqHR7FHK1OyxfOhvgIVsx57bx54UAkxU8NYdUe8=; b=M/2lRHQ80FW29JeJ3y9noBGFLxVERI+Gk4A6DJkaEfyh1TR5Va8iL/CVzR7t+NsK2Jk/tfL4UNfaX6kDHbvhUuqGgUdokz8FoxaPX56tcRMk0AxMHCWfGNVluuEZyKfDwvOUjGh7VlyeAjAU+o7f/tQhdVOZ50ZG98AgUPGyuPX2FuQ0jLfCPcsXcwMaGo1y+2otzhcP2otN4wJ1XzyMCtlrkha8Itn/f+qnr8y/Wc//p6LkrDuX29yBYwVpNJJen+tdRYCOFnsCxL+OP0SBzbmZkQUyzhwWe7ajIWuP5rUYG9tS+T7/bWFDNg+B9KZq5rXcvWk1+brNV1o7Qc0EYw== 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=7WcEVqHR7FHK1OyxfOhvgIVsx57bx54UAkxU8NYdUe8=; b=N1b/7UmypGc+VwH0R5rjRhQY9rHkkqY5G/v9E36k5thEOgHpC6l4fxI5JZiWf2n5znfwznEHVjStPwSYjvpo2RP5GVIiwVc6mNJ/UV4sw9fnQho/NWovU6K37Oug5efLo8Mk23Xfjnsqjwp2YO9Cr/OEj5Ao/Q0hn9qSP3j+9Gk= Received: from DUZPR01CA0199.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::28) by AM7P190MB0615.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:11e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:00 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::32) by DUZPR01CA0199.outlook.office365.com (2603:10a6:10:4b6::28) 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:43: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 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:43: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 v4 14/86] net/ntnic: add item eth Date: Tue, 29 Oct 2024 17:41:18 +0100 Message-ID: <20241029164243.1648775-15-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM7P190MB0615:EE_ X-MS-Office365-Filtering-Correlation-Id: 16a11a32-6d25-40f5-3e98-08dcf838c033 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: R9tLetmEsVKzbkWxW4oXsULCKRcwuIo/9hgAtQEL7bvkCCcZEtZ519uQaVck+MHku0zxUXezyo2KX81S8LPR4DEtzHkunX5/1p0c2V//Akhvs8hb/aMuj9qJQSaraKe89o9j4J4h0htg+sZ77YnSSRq4tg2hBWClj0SbSaR7KRx00K7tHJkI34qDz4XvH+WHPoidNgO82vrPiLT/X2b6nbBsmnt3/oGUEn9mmhepfuLd6L3HmvLZZT4BUSYKbH5CQGwLhMGJijpq7JCuUVKCHxP0qWLTJny2LVL/ETIaVaN6HV12SUI7cughD/Wlo3O2qODnScHVBbyp7pQB4aHNWVS+rTUmNBUY3xtrVZt1yL+kyfVpdYp+9I0lLRAd9itMNzjjVo8fP/zOkMF9OuDxqV5GbTRQMyATeoFE9H9HcFFRGvneB75P1JqRMEF2KyRa6g7yfeZYytEIAA5g1w44LlpE+JEbKAjK13HynG41hDrCaTSH4KwyVVqdrs8lMzxcbrz40o0Lc5AxXcqAPKui0fTUcAQBvkDf/vXRJIUmIUfz8/ES9DIxE1uj0m46gwCBDn2P0G4PlYPO4ZSmzb+7CSfK9RU2xYXFhCOFuYhqBBvTO0yvVq0Dhc+UPmJeFbK8iOFRB0deFRp6VkQ9w7y2sSfV4FwU9JV/WP0byHPvJqddvf+YEl+FNH8KWDhFe1YNUrZlMTojTkHqi/jAhPCzdMwvDArD4xCOxl+LfZfPNNLyeUWOLyw/93/SlVb41omV279my1Vxu1L9Ki+EHTirVrsStTNHMD907Zpc8CXrBQBh4ExrrdUpC5E25IcvS/aKSAF9OC0DhluGGYkUui4l7/hDA9PaS1UqWVJAfUbb01gKSGH+S9hzfG5m02T8E0g7OdCtkEngBIt3zE3h08ZOqKPQm40XmzeGkOcM3wKI3AgJqllWRtoWXIpaMmcwDinYafe7l8GAkvPT8cch3LQOwVdNkUdf9q1hji4JWz8GUCwaZPs0IT/D8V10enJTA5/5HBFaqfkXX1BGIfkbQ48sJJ1bndgPxlIY5ZzlZ9prvnBh7G1VgG9D5GIMtG8xD07p9m6Ru7ValFTLNzrR/mnu9fgn8NylbR4ipXQpWsXD918+venci0Vw49q2t6MR8cfvqbfvhLUzj2QnNzL9uifCdanKPnrLP8yIKKAyKxdl06FNe3p9GIogLMdB72aCjAuv3xieqDoJLaNe2c8mCw4yYXhctdtd4KG4l6AkwbADKpqm4MGSMfasNJiXfUmxQY4OVTjbLBtN19bQ/TSR0A9iWZ6vsbaFIJloJfi82IjuOhZdUYTlopjqpO0J9iymFh+78yh+Vrb6/K9b3IsiDROYEP1mJ3pNwWcTgWTnfbohuGChicBGXBOUrtW+BRbT2kFXp36y6UPxqBegM/BvkzsRSQ== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aqBk2uMVXrHVMzqgnvo0xXfpsZ6RuD+bgT4sfsW2baFCrYkVKMumDXO1iUR6Ns1Z86JQpnPd9pBG6bXbMyRmr/QG33RrgwpeFF96e8DZgbZIZ6SIFpZ3hiiqZ9QZtuwzuaKBzxMlc+SyZhm2iEpbH5ZAKOIHY4SzA5MIKyjWRx63nhWq0DlNFUd2X8gheuYDqVO5xyNCMQ7O0uX73NSagGV4P9EbBW0vRe8AVJWy9XMYhZlhtzJF7qN8aVJBgwAWqj60CGFUuGhxF2gv15q6fxmDh/Uvd2PtMdWGTSdCfIxGDCIGa2yFfBHm9v6QPYVKTU5g95IowyFQ1sTET892DuDTDS+zlAX+xkLpBW4Hszu1F/9YpynvlDoSp7lfE8le37GQi9QqPqqs3FWzOlCi9lUPJj1dCOxNXJF4c1IlNZ6p9ZdxSndkvSQuR/KOlIRuqCDR4IH5QAkcD5y14420eMRVmzskeH5IStDGUN+XPVpeAZ9yOsI4GkhliR4Y9kT/cOlJgQtpRwVRxWdBxpgcvxDSHaMfKDLITe9v8gxlZWPJyg8SmK2mpV0BFsGVqP0KZr9VO7XqyKBwqdbpND1b9wJdT2+kkFhN5al7d9j0VxX6uAPLXZ8p3lBeFTOso+MwE5kBKPvpOE3OJ97pxuauLrfs3voe0ukNecF8JnHQ5oI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:00.3552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16a11a32-6d25-40f5-3e98-08dcf838c033 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: AM7P190MB0615 X-BESS-ID: 1730220183-303097-12765-29322-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhaGlhZAVgZQMNEyNS3VOM3MIt EgKcnENM0w1cLMNCXNzMA8LcXIyNJQqTYWAKoAZldBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan19-218.eu-central-1b.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 Add possibility to use RTE_FLOW_ITEM_TYPE_ETH Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 23 +++ .../profile_inline/flow_api_profile_inline.c | 180 ++++++++++++++++++ 3 files changed, 204 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 372653695d..36b8212bae 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -15,6 +15,7 @@ x86-64 = Y [rte_flow items] any = Y +eth = Y [rte_flow actions] drop = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 99b207a01c..0c22129fb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,29 @@ enum { } \ } while (0) +static inline int is_non_zero(const void *addr, size_t n) +{ + size_t i = 0; + const uint8_t *p = (const uint8_t *)addr; + + for (i = 0; i < n; i++) + if (p[i] != 0) + return 1; + + return 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 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 64168fcc7d..93f666a054 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 @@ -55,6 +55,36 @@ struct flm_flow_key_def_s { /* * Flow Matcher functionality */ +static inline void set_key_def_qw(struct flm_flow_key_def_s *key_def, unsigned int qw, + unsigned int dyn, unsigned int ofs) +{ + assert(qw < 2); + + if (qw == 0) { + key_def->qw0_dyn = dyn & 0x7f; + key_def->qw0_ofs = ofs & 0xff; + + } else { + key_def->qw4_dyn = dyn & 0x7f; + key_def->qw4_ofs = ofs & 0xff; + } +} + +static inline void set_key_def_sw(struct flm_flow_key_def_s *key_def, unsigned int sw, + unsigned int dyn, unsigned int ofs) +{ + assert(sw < 2); + + if (sw == 0) { + key_def->sw8_dyn = dyn & 0x7f; + key_def->sw8_ofs = ofs & 0xff; + + } else { + key_def->sw9_dyn = dyn & 0x7f; + key_def->sw9_ofs = ofs & 0xff; + } +} + static uint8_t get_port_from_port_id(const struct flow_nic_dev *ndev, uint32_t port_id) { struct flow_eth_dev *dev = ndev->eth_base; @@ -457,6 +487,11 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, uint32_t *packet_mask, struct flm_flow_key_def_s *key_def) { + uint32_t any_count = 0; + + unsigned int qw_counter = 0; + unsigned int sw_counter = 0; + *in_port_id = UINT32_MAX; memset(packet_data, 0x0, sizeof(uint32_t) * 10); @@ -472,6 +507,28 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, int qw_reserved_mac = 0; int qw_reserved_ipv6 = 0; + for (int eidx = 0; elem[eidx].type != RTE_FLOW_ITEM_TYPE_END; ++eidx) { + switch (elem[eidx].type) { + case RTE_FLOW_ITEM_TYPE_ETH: { + const struct rte_ether_hdr *eth_spec = + (const struct rte_ether_hdr *)elem[eidx].spec; + const struct rte_ether_hdr *eth_mask = + (const struct rte_ether_hdr *)elem[eidx].mask; + + if (eth_spec != NULL && eth_mask != NULL) { + if (is_non_zero(eth_mask->dst_addr.addr_bytes, 6) || + is_non_zero(eth_mask->src_addr.addr_bytes, 6)) { + qw_reserved_mac += 1; + } + } + } + break; + + default: + break; + } + } + int qw_free = 2 - qw_reserved_mac - qw_reserved_ipv6; if (qw_free < 0) { @@ -484,6 +541,129 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, switch (elem[eidx].type) { case RTE_FLOW_ITEM_TYPE_ANY: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ANY", + dev->ndev->adapter_no, dev->port); + any_count += 1; + break; + + case RTE_FLOW_ITEM_TYPE_ETH: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ETH", + dev->ndev->adapter_no, dev->port); + { + const struct rte_ether_hdr *eth_spec = + (const struct rte_ether_hdr *)elem[eidx].spec; + const struct rte_ether_hdr *eth_mask = + (const struct rte_ether_hdr *)elem[eidx].mask; + + if (any_count > 0) { + NT_LOG(ERR, FILTER, + "Tunneled L2 ethernet not supported"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (eth_spec == NULL || eth_mask == NULL) { + fd->l2_prot = PROT_L2_ETH2; + break; + } + + int non_zero = is_non_zero(eth_mask->dst_addr.addr_bytes, 6) || + is_non_zero(eth_mask->src_addr.addr_bytes, 6); + + if (non_zero || + (eth_mask->ether_type != 0 && sw_counter >= 2)) { + if (qw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = ((eth_spec->dst_addr.addr_bytes[0] & + eth_mask->dst_addr.addr_bytes[0]) << 24) + + ((eth_spec->dst_addr.addr_bytes[1] & + eth_mask->dst_addr.addr_bytes[1]) << 16) + + ((eth_spec->dst_addr.addr_bytes[2] & + eth_mask->dst_addr.addr_bytes[2]) << 8) + + (eth_spec->dst_addr.addr_bytes[3] & + eth_mask->dst_addr.addr_bytes[3]); + + qw_data[1] = ((eth_spec->dst_addr.addr_bytes[4] & + eth_mask->dst_addr.addr_bytes[4]) << 24) + + ((eth_spec->dst_addr.addr_bytes[5] & + eth_mask->dst_addr.addr_bytes[5]) << 16) + + ((eth_spec->src_addr.addr_bytes[0] & + eth_mask->src_addr.addr_bytes[0]) << 8) + + (eth_spec->src_addr.addr_bytes[1] & + eth_mask->src_addr.addr_bytes[1]); + + qw_data[2] = ((eth_spec->src_addr.addr_bytes[2] & + eth_mask->src_addr.addr_bytes[2]) << 24) + + ((eth_spec->src_addr.addr_bytes[3] & + eth_mask->src_addr.addr_bytes[3]) << 16) + + ((eth_spec->src_addr.addr_bytes[4] & + eth_mask->src_addr.addr_bytes[4]) << 8) + + (eth_spec->src_addr.addr_bytes[5] & + eth_mask->src_addr.addr_bytes[5]); + + qw_data[3] = ntohs(eth_spec->ether_type & + eth_mask->ether_type) << 16; + + qw_mask[0] = (eth_mask->dst_addr.addr_bytes[0] << 24) + + (eth_mask->dst_addr.addr_bytes[1] << 16) + + (eth_mask->dst_addr.addr_bytes[2] << 8) + + eth_mask->dst_addr.addr_bytes[3]; + + qw_mask[1] = (eth_mask->dst_addr.addr_bytes[4] << 24) + + (eth_mask->dst_addr.addr_bytes[5] << 16) + + (eth_mask->src_addr.addr_bytes[0] << 8) + + eth_mask->src_addr.addr_bytes[1]; + + qw_mask[2] = (eth_mask->src_addr.addr_bytes[2] << 24) + + (eth_mask->src_addr.addr_bytes[3] << 16) + + (eth_mask->src_addr.addr_bytes[4] << 8) + + eth_mask->src_addr.addr_bytes[5]; + + qw_mask[3] = ntohs(eth_mask->ether_type) << 16; + + km_add_match_elem(&fd->km, + &qw_data[(size_t)(qw_counter * 4)], + &qw_mask[(size_t)(qw_counter * 4)], 4, DYN_L2, 0); + set_key_def_qw(key_def, qw_counter, DYN_L2, 0); + qw_counter += 1; + + if (!non_zero) + qw_free -= 1; + + } else if (eth_mask->ether_type != 0) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohs(eth_mask->ether_type) << 16; + sw_data[0] = ntohs(eth_spec->ether_type) << 16 & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], + &sw_mask[0], 1, DYN_L2, 12); + set_key_def_sw(key_def, sw_counter, DYN_L2, 12); + sw_counter += 1; + } + + fd->l2_prot = PROT_L2_ETH2; + } + + break; + dev->ndev->adapter_no, dev->port); break; From patchwork Tue Oct 29 16:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147620 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A69DD45BC0; Tue, 29 Oct 2024 17:45:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B7BE42F01; Tue, 29 Oct 2024 17:43:35 +0100 (CET) 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 EDF0642EBC for ; Tue, 29 Oct 2024 17:43:06 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2113.outbound.protection.outlook.com [104.47.17.113]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pa0bw0ri6/+FARscYcw8e1fcjl8RxMABa4Y5aL14WCYxN2JJhQOoeLuXEjbz1bkUbH4eUSXB0nfZoZGmB8o88pSe/Oldtl1VsCghW4e1tVz2Vp2EzmOazD8s1A0URIUOxeFpbmlEfzpZsTwjEXybziMczdTa2yo2SO3Wk+ftIgrMuZB8bkO72R+RHk9Gv+7aKj+7xUUTk9Ctj2Vu2w+l83qTxIoNWmt3HRlb4clIe5diRCFKkehDPy2w+n9aDFVYFAxjrMmLcz6AtrtRdC808w0bCN9ufVXCKzrXOyeNneubuD8H6gpxDUj48vHaB8Yqd/so34o6e6DIveIzOghK+w== 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=j/Ey7qUYp3FUgLOJcQ6s1M6EHunMNoby3YY7ePKZntU=; b=YMvSXuHwJAkA6i3sWJzVaNRu1pH8npvmBQ+ET5Dh6WVN0B4mp/C+M+6I/a5PCwgcKykMkDO3iMetNxL1O3DKfcOiX1yy4dTZbNU6MGEoBMsiCN/XwJALvGb9CvQ2D/BVFicpSr1g9SNz8hEyI2hQ/JtMHdHEEwQ6qbaCMRmKmHwVc4n1eJ1fmGaPv4nxbjnFKpeghF5a9uJAOKiM37qtaoUdfRND+lyklLHxSJybm30Uxoktgt28Vjj5Za+O84iLO8ChzXKWxpLQ0as76r1JQTSkES7ccR4XdHcv2qzwWqXyQ0UgwIKlfiLCt2AMHIgymL3739DPthcEzdUSS2RJqg== 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=j/Ey7qUYp3FUgLOJcQ6s1M6EHunMNoby3YY7ePKZntU=; b=KDLEO8Dc20Rz+ozR2Pk29t4N9AsM36ranMTKoULQa8tBWu/RsBwHycMcrO36QZKKjewJJoW2iMx/MMhSOBJxGj/whKJzCOwPmX8PQ7VuWfU1yCD0xRxsvryXVh3OW4MRoBEf3/KDqY1H8TXvwl4USwQevjDMLK/WpXxRygpssPI= Received: from DUZPR01CA0196.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::23) by PA4P190MB1247.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:106::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:01 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::38) by DUZPR01CA0196.outlook.office365.com (2603:10a6:10:4b6::23) 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:43:01 +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:43:01 +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 15/86] net/ntnic: add item IPv4 Date: Tue, 29 Oct 2024 17:41:19 +0100 Message-ID: <20241029164243.1648775-16-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA4P190MB1247:EE_ X-MS-Office365-Filtering-Correlation-Id: e5e38ed6-b3df-4155-85aa-08dcf838c0dc 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: kCytxtR29gbwyM+DCf9aan3Z0O+riPpU3ufS7dDCHJymg0ftc6wL/tSEQGR6M4EyAYPjSZUwQy4HF9qLWYpU2XTgco7J/S5okV5k8DgO++fGyfbuyoRlUK0Y/9YoTVIr2wHEA65H/3s3NkYVX0RnXoWy4jyapnSN3PLZTyvfeLWX/bkV39CFwB7jKue30755p2eGMHuU/+dLOx5o+6OIU7GRrRxj4nHLB9ZVESY+fwM7oUG1L3wwDO5CESoLNCE8glB17VJG/Q5WV2b+VmXnrsHmxhDfg6NktpOLh3+FwvXXJnf1YdGmkzCEkyqrPeD91DGm/G5amnBQ2u7n5sDgUMUfkBxmmcwavTgqT/lugmwvQxdr641yodx0TCHkYhInGFwVhzW9YVUW/bsmT6uuFo0VdqAF5vz24xPYhU3T80xOkaWK5oHzLoeiI7qtSfRsHics+3dDWoXnC7ENxeIOJx2xiDn/Hwgx1m7SVCyqpk443wfYwDzDMA0Vwjpzsh8zZGgsf/YtTUeoM7WnfCoNsTZ4llS0/ekNPsbaZ56qBsP4XLpycVEGvyacL7WFkf70MIInwHPc0JGgi7kr2h3gCNkrasS7W2yLC5MkcfSYDAM2Dsv2QuAxhCFeZ3THunJ6+4bW6CHjmweVrWW0D/qu45K+1fTJMeCRy7FQgtjBX2eAIvtZl0PlBTZMCCdL8kvNfiXmB52grwS914GxYKvKCOj7fmXzx+dtIoQCA6unorJv/qJmsDa9cwAtNqK8CqBOKrrdDZaKHK4Auz0xUvL4hL/fawhZ8/3pn9UIo6xxgl3ZY1++EbU0rTFceuqmmP8nsCAJJxdd1uE8M/fJxsX7ITFnwxyMKoXdt5jIC0Mv7+yI2thsTco8FARQJkDqJWiTEN0Z585bWh/ZYXMZjy++G++yQ2oTkEyDbzMEVM4gEXEqnP3KG0uVsmWSMZJO7wZVPoMney9F1vdt+dVR49R055Df6Re0X8m3BuOF5wCi3RdqM7v/08ahqHXIII44rDcdfW8mRQO0gPL7G9Op+tvbFE0sJbOdlNJbeeNAsC6NzfItMBmjP6G8HHUf7SJ3q6iPjs6uPRxF9GEretKRKGRxYadeJgSEhA7kLXVnokHSCewqEBTN8UnXC+XhyLqZKZE1EdyBtev5Mjz/sZCInzX6u8R6leaIB0CuZkb6ZfJ91WIrGZIM4g6OW0QOiEbOABgGcme+flyu/C9iGRW15AH28u5P4mUnB9/ukTrPEZJ1l/dLTT6m987H+Gux+HP1ffxv/lawV9hB9IpAyyUohg/yz8gEw/YIzNb4SvojW+v1PtncPfXztJI6eb9/gEzKhtE93E/nYRn4AVrjPffZf8uT0MXyUySlxABc6lXJsHIC8C9luQWp/8ORZ7gyyUZv8yv5VT/pcSnsDsiKlqqtytT8Zg== 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: g6GnljQ0szW00k7BfwtmXyTCoybzAVXfFwKPv3slwLh9A9uBBMnKD5ZuUGe/MeKUrcSYa44WbbL+95VeDt8M/vTSo5e0Ee2cgvHJMMzq6ai4XmuYQAy9WuRZC6G/VTWmC7hNKY5VJQjvp/Cdh7fvCvIo2R4s8dAsOKKXpD0QJ058nEJKLTOw5KBDqD4mjPI7UC6WGk8UoUu2ompLDQXKAcOwaIsPJbXoMdqtkhHAXYuQYMjVVUcKiSF848nZyXQf54WIQgnCRtuV3T5AcDyo1EmOH/1DI87IEVvCUopcHAEY+uU9EAFJfyWzKbWyR+u9w48eBYMJDoj1btOqU1gWAqe02TFzInCV9fovZ/PKQWsFPPkjAIJebAVr6QtghqENVw0kY64l9jXKp+3uWuPxlnxvzqoAPCwRLAbI9Q1b1Jo70DWR36Vzp3bgdRLSjBTpZ/iWH6o5a+igi+g2faiMVpPJ57ZxabLnfsn/hIsQfGvs/nOJYJjI0d64wBUauLwsQ/7DIQJgNVTldugnKNOFzLwnNoko63Z43wjFBZ4uU2c8McGoOFyoVSjKiQ7YOk//17nSjgI4HtWoWCLYQmiKfJRToODN/NSKDvAYwKX5N9M+Q38R1d8ggR0G0FhC7op+wZWel8o0RBYvv667PNNDNAJV33VAOnGiek2tm7jb21I= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:01.4646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5e38ed6-b3df-4155-85aa-08dcf838c0dc 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: PA4P190MB1247 X-BESS-ID: 1730220184-311207-12674-27823-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZGRoZAVgZQ0MzY2MjIJMncPN UyzdTQHMhJTkmxMDU2M7Y0SE0yMlCqjQUANlzRv0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan10-54.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 Add possibility to use RTE_FLOW_ITEM_TYPE_IPV4 Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 162 ++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 36b8212bae..bae25d2e2d 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -16,6 +16,7 @@ x86-64 = Y [rte_flow items] any = Y eth = Y +ipv4 = Y [rte_flow actions] drop = Y 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 93f666a054..d5d853351e 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 @@ -664,7 +664,169 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + + case RTE_FLOW_ITEM_TYPE_IPV4: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_IPV4", dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_ipv4 *ipv4_spec = + (const struct rte_flow_item_ipv4 *)elem[eidx].spec; + const struct rte_flow_item_ipv4 *ipv4_mask = + (const struct rte_flow_item_ipv4 *)elem[eidx].mask; + + if (ipv4_spec == NULL || ipv4_mask == NULL) { + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (ipv4_mask->hdr.version_ihl != 0 || + ipv4_mask->hdr.type_of_service != 0 || + ipv4_mask->hdr.total_length != 0 || + ipv4_mask->hdr.packet_id != 0 || + (ipv4_mask->hdr.fragment_offset != 0 && + (ipv4_spec->hdr.fragment_offset != 0xffff || + ipv4_mask->hdr.fragment_offset != 0xffff)) || + ipv4_mask->hdr.time_to_live != 0 || + ipv4_mask->hdr.hdr_checksum != 0) { + NT_LOG(ERR, FILTER, + "Requested IPv4 field not support by running SW version."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (ipv4_spec->hdr.fragment_offset == 0xffff && + ipv4_mask->hdr.fragment_offset == 0xffff) { + fd->fragmentation = 0xfe; + } + + int match_cnt = (ipv4_mask->hdr.src_addr != 0) + + (ipv4_mask->hdr.dst_addr != 0) + + (ipv4_mask->hdr.next_proto_id != 0); + + if (match_cnt <= 0) { + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (qw_free > 0 && + (match_cnt >= 2 || + (match_cnt == 1 && sw_counter >= 2))) { + if (qw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, + error); + return -1; + } + + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + qw_mask[0] = 0; + qw_data[0] = 0; + + qw_mask[1] = ipv4_mask->hdr.next_proto_id << 16; + qw_data[1] = ipv4_spec->hdr.next_proto_id + << 16 & qw_mask[1]; + + qw_mask[2] = ntohl(ipv4_mask->hdr.src_addr); + qw_mask[3] = ntohl(ipv4_mask->hdr.dst_addr); + + qw_data[2] = ntohl(ipv4_spec->hdr.src_addr) & qw_mask[2]; + qw_data[3] = ntohl(ipv4_spec->hdr.dst_addr) & qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 4); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 4); + qw_counter += 1; + qw_free -= 1; + + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (ipv4_mask->hdr.src_addr) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(ipv4_mask->hdr.src_addr); + sw_data[0] = ntohl(ipv4_spec->hdr.src_addr) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 12); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 12); + sw_counter += 1; + } + + if (ipv4_mask->hdr.dst_addr) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(ipv4_mask->hdr.dst_addr); + sw_data[0] = ntohl(ipv4_spec->hdr.dst_addr) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 16); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 16); + sw_counter += 1; + } + + if (ipv4_mask->hdr.next_proto_id) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ipv4_mask->hdr.next_proto_id << 16; + sw_data[0] = ipv4_spec->hdr.next_proto_id + << 16 & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 8); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 8); + sw_counter += 1; + } + + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + + else + fd->l3_prot = PROT_L3_IPV4; + } + + break; break; default: From patchwork Tue Oct 29 16:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147622 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A90E945BC0; Tue, 29 Oct 2024 17:45:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73A0142F21; Tue, 29 Oct 2024 17:43:37 +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 D3B8942EDC for ; Tue, 29 Oct 2024 17:43:07 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2109.outbound.protection.outlook.com [104.47.17.109]) 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 16:43:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ImdCYrbvYHyYUKeaSYwSPZ70bNC9YGZhbuWM5B5Y3Ema8KSPwmMbWN98mhevcukJtzA3XcFWcGE1OXxs+ZJVfIHwUccH1RDjEK6N5s3auMO6xICXlNurQapqMxjlJurZGZVfHICSlf32jh569G+quKUzXGAxM8iABViMg0Vme3RYfDAiSChBtwVwH2FkHiJoo1rPbZW3e3SeVBXQETW5dGJ0YMEy1VaGY2OsE6dskbFVdwwIpyud6Mr5yZOIf85+iBOsO0rq6lyy+nFVM0RFant4fHih85/85gvCb++SlVLDVXO70imS0Pr9ggG+FnL7TishJCVJ7aYYeYAdulU29Q== 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=pPN9eumyEk/ovJ4HmzmQrta4bZY5JZ/WnHI64XwQ1VA=; b=n/wmpu6Oc/WpTrymMCjJWoAISyN3bu7EJ3cC42f0P675N1Dhd9/E6QzhCpEHqpCy73M4sh3wHCh6aXyCReLq8RBeE+75dDIwJvad6Tjfo3w8SIH9gP89V5LP8f6dhNQa06AVr24RqFiamy5TYXDP2NPlbc8zdEl/BLW36KubzsxZOw1bi9Sx8APECFRB27MuGCxkzJpZpx6JSoE9sDE/j1xk9LlRTjdG6SPQsJV6E7C24+bzUVR8YeKp9ufm/7RrxSwQ2peRZXSPtBkRbZ5vZpdGSZM0vsMs2GF+v5ikBJOBG8mOiq2EYpDrmbth+6NZhxx7ouKlIMPesOqswz+7nQ== 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=pPN9eumyEk/ovJ4HmzmQrta4bZY5JZ/WnHI64XwQ1VA=; b=K01YFUAkstLzwDNTugfrJhYSAzvAIvqIfKUQ4qRYk8dq94zZzix73doZbpqVT00fNVz2QmOYfQmo23nWMYX966MCycpIiZt7I5rpeWkJPjYrFgE/yjQWCnduu8kcHoTdeNpNydh4k9G7n7jLBAomV//ykD+SPiJB8L5V8a9K/2w= Received: from DUZPR01CA0202.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::13) by PA4P190MB1214.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:02 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::1e) by DUZPR01CA0202.outlook.office365.com (2603:10a6:10:4b6::13) 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:43:02 +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:43:02 +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 16/86] net/ntnic: add item ICMP Date: Tue, 29 Oct 2024 17:41:20 +0100 Message-ID: <20241029164243.1648775-17-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA4P190MB1214:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ae883cf-990f-4702-7ffc-08dcf838c158 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: yneeTtB+6rpmy4t79zr/fBvy2yK3eNUPSz3ysjwBMbVchnQ8JoYmflbvAj7mFTEC+fUHwteqrQUHZBU34s8RvY/70VZ8jJ9VEjCz6UbfzMalfakGDL+Rh1mAMIMlpIE4Rng66uhLMAUAVXBrW9UBPSLLWaIPS/ETjoWlcoGLJGPrQJaGnJP30ciQ5oXR3llzDcbPaQbf25LBqfK10FFgqIP5YlthtTFuNGjGKLVetrOG31PUm6iQOg7teJVD1CV6zedqaxEg0TBsnsTTWNewDu8JaeyLv0D7IUwKQ/xII25P3w4Mml4DP8Mmr4GOi9vLD5skjtxuZmT2u83brZ4Kw8BKklq/zNkzkJeED/QarKG1DWEzJcfEksIvIbs10W1VMOXcnd+QiFaREohHrG1869aIyp5Bokv8IlyJiiEnxFehP0S7RLVgeJOd4dDhfAqjQ6l7eUQMX+ZWxIgiWgrVTMkio3jLngXQFxGxuHvNxGMXbjonafaTD6oplR/eK/7qg/G49bQUb/g94oxrRyVT5/GNCydB0b2L7VfPA3fcz/AnzIdz5eNAJeLoAfgTxSeCpC6NSdRKmK9vyixe8OUAxaN6dZ0HWLsOcjCILCJBuo9BDa8b6ORlJUufzb0RXnAeV0ndH98CNxYeX9lwHNACT1qhGCAA6vJm6UroEmd0EU0DFBcMABXFn3KhWIFB5KefN5wJwfwmrS/PUrXgsfsHo2kE3yhTIoOl0n4tLKF9uVkoHtlQSstaKPB1VaA4NENCkmVo+yjAMe4SAMPigCfy5J34oKm3ll9/coXeUn8iqxnwIwPBn2bkS5H29uniAmVTrCyV3BbnOo66Rg2R/kN9Csc1Kkex+V37Y6sk9jgw2Pz94vhO87JbIaBvPEf+rIDmgInAg9F4oNJAbVfuEZMBwNs8M7Gk3JFRPtJIw02rki9nVmZ9MGvh+CQfV9Xsjt2ncPo//aRiRkA37TB+fH2gRdfXI/c5Pfn2ToalCYnLD0p7UaJe1iRVBIn38KGD1//mW+EfwfV8l1WaX8C99pgLE2AxKFcfDkD463XThsX4hmoPqpH/yrXF+hXEyfr6Nj4ch6JTPdVi9/TvMDqaI8FSXzxPLxp1ka78StQbBZVLwC4hKv5To/QqLP3ID6i8KeXsBOh8l0C3Q7LE5pNEaHjBbUjT51zIjbhcZNCLCAVmJXAWY4GZiQNDrtLiEzY/uF0PPUzPt1r/ewEYf78IT8mCt2mrXTp1vulT6N2yD66b0yn5j5+8TnfGGBBa7+MrHGDkMlqoZy4MnPaZbxFMxoP7/9kG4GRT4o/tRu5kPWNrHL0LdN74bWgCK5J1Vg+q4+Giy9rpIIcFZ6Y3tNfl6gQ2dLhUXNJ9wc63cYqpuHK8LYLQJSeDoL7OlHDN0zq09vO3a3ZJ4Yh/x6Q0XLQOmyOb2w== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FPbUBFpkwvxEkhwPtUc9y0HFLKp8hk309lo2XUcBh+XJ3NtbYgGpBcz3HSBxzkx2nDJzAJuOCJ+i2m48z/vvJWGqyUoxoMWQ8CsqBrB8rtuuKjbzkiQFRp3rdDbH92Q+JWAXhxpq6lsNx/FGnTfdgFbOcCK+bDF1iRjSIwO24z+ssG118PxHYBvNTOiWvAanmuNThhMUEKR66asb6b7iss4/LZ92vv18bOOV2m+v8kDgxsyBffZTq8+ZDLO+PFfC7bXzZcLRAPMWhkzvLpjJebP5oLjJBjLRLvHWdNQir9rn57mSlhUSc3HjABidBCiuXO3zaGVdSd7i105E7aR0Jp7VUXkZZSslC/KcvoiR1R4tJdud0nqmyyRf0WRB4T+4YgJ2iPcZL7EwU42eremBu2+i4PxN923ND3hoxodJSuvseWJnzNEIi4UwMfDvOOsKXvScvH8+g9OLgGt9/BQgN9zxCxffyjcvh3Gqrfd9bk0VAolon9Opqx6k44WhFCORY59pUwjRa8KR9C+7FBkn1bVlpdPIBOFntJONsE7j0j4J7RZyTBkHKcwYXnDfMj0D4Y4XO8uKchtrEbmyCW/Ky6xoBtM37q4OtQJnB6HOkbF8eJ0nuudvE7Id432+EQMZQrzkMUItEOW3rEXs/di+RNl3zURcZBh4RqoR4uKvScs= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:02.2771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ae883cf-990f-4702-7ffc-08dcf838c158 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: PA4P190MB1214 X-BESS-ID: 1730220184-304438-12712-30011-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViZGBiZAVgZQMMXE3CIlJc3YwN TEwNLSPMnYzNzAyCzJwMw82dzUyDhJqTYWABfv/F5BAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan12-135.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 possibility to use RTE_FLOW_ITEM_TYPE_ICMP Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 101 ++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index bae25d2e2d..d403ea01f3 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -16,6 +16,7 @@ x86-64 = Y [rte_flow items] any = Y eth = Y +icmp = Y ipv4 = Y [rte_flow actions] 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 d5d853351e..6bf0ff8821 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 @@ -827,6 +827,107 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, } break; + + case RTE_FLOW_ITEM_TYPE_ICMP: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ICMP", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_icmp *icmp_spec = + (const struct rte_flow_item_icmp *)elem[eidx].spec; + const struct rte_flow_item_icmp *icmp_mask = + (const struct rte_flow_item_icmp *)elem[eidx].mask; + + if (icmp_spec == NULL || icmp_mask == NULL) { + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_ICMP; + fd->tunnel_ip_prot = 1; + key_def->inner_proto = 1; + } else { + fd->l4_prot = PROT_L4_ICMP; + fd->ip_prot = 1; + key_def->outer_proto = 1; + } + break; + } + + if (icmp_mask->hdr.icmp_cksum != 0 || + icmp_mask->hdr.icmp_ident != 0 || + icmp_mask->hdr.icmp_seq_nb != 0) { + NT_LOG(ERR, FILTER, + "Requested ICMP field not supported by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (icmp_mask->hdr.icmp_type || icmp_mask->hdr.icmp_code) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = icmp_mask->hdr.icmp_type << 24 | + icmp_mask->hdr.icmp_code << 16; + sw_data[0] = icmp_spec->hdr.icmp_type << 24 | + icmp_spec->hdr.icmp_code << 16; + sw_data[0] &= sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], + &sw_mask[0], 1, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_sw(key_def, sw_counter, + any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = icmp_spec->hdr.icmp_type << 24 | + icmp_spec->hdr.icmp_code << 16; + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = icmp_mask->hdr.icmp_type << 24 | + icmp_mask->hdr.icmp_code << 16; + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_ICMP; + fd->tunnel_ip_prot = 1; + key_def->inner_proto = 1; + + } else { + fd->l4_prot = PROT_L4_ICMP; + fd->ip_prot = 1; + key_def->outer_proto = 1; + } + } + + break; break; default: From patchwork Tue Oct 29 16:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147624 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 58E4E45BC0; Tue, 29 Oct 2024 17:45:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA92842F2B; Tue, 29 Oct 2024 17:43:39 +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 AB9E942EE7 for ; Tue, 29 Oct 2024 17:43:10 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2042.outbound.protection.outlook.com [104.47.11.42]) 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:43:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l2wFgDCFXe38bYfq7Sl4qbjTfnOuOoyOb6zM/5/GgxRD0fHrVhJ2yhzoMhvCdMTC19eOiW4T1GI9g3B2EIsskdKchReqtdIOB9pJbppUWJgOhBgWw/ZWqUEvFdojQRqxi30NfBf3wV5kf4VbDA1kY4OMKXB5GM0jbLrKqzVcXaapYaHgOR11xDWbVnpheS0n2HXjo9PUyYx5aEzzLSscFIZ0Ap8xy+Q9EIhkRukWGDvWBtI2A+6MN1WDNh/eiT8YuKbW54D6cFoceatd3PRH5mIITVjZQYGP3FmcQZGFlg8z3z/1pH4oitScdoANcuHqtWO5ZwW/2XvhsOMmmfN2GA== 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=3lx9RJyRUrzVUP4HQRLdEdglmVD2PH9JGqbjeAXdPeM=; b=BnFKjGyzayvxbTXBn7P2g6mEDGE7Rfwd1/Ga8cgf9030XeUlt0iwPVHinuHYRD8IIMj7agPE8VUdK9ab590zddnBBHfIkXi32bHcFPuyP80LQCakswz10D0+d6/Y/5+xEG1YDeGLn5GPV129HdTPIJJCMLGup9NA1PumQo6zBQH4jTwswVpCgnYWmHjb3P8j1zB04cKtGbHAccUuXfitZ90+G7OjRH/cxjw87Ll5j/LWrYYoGYi8lq6jtEjvu7ZHjbMYFYRlkY/3DX+UC2qQXCVwCQVoheZyhjxxWzUEPjMR97rgDilqMMsV5OzpVH38MWhnBHhrs6jA1oPZYoA75Q== 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=3lx9RJyRUrzVUP4HQRLdEdglmVD2PH9JGqbjeAXdPeM=; b=WiwPhS7Ypg+zO39l0ermOvhIiPPAZUBMNibg+DiUqwC9zBLT0Fes8jcRUStyFdmEbfryGkGfER6M3wZlVFln+SWm5HHU5kaScdkU0VCSpJUoBVbCIw07SORUdiEC/l3LD/w6fqJmrUQDtfqV4bmMq6NArWNUepkSPdxmSPYj7Z4= Received: from DUZPR01CA0195.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::26) by VE1P190MB1024.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1a2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:03 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::32) by DUZPR01CA0195.outlook.office365.com (2603:10a6:10:4b6::26) 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:43:03 +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:43:03 +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 17/86] net/ntnic: add item port ID Date: Tue, 29 Oct 2024 17:41:21 +0100 Message-ID: <20241029164243.1648775-18-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VE1P190MB1024:EE_ X-MS-Office365-Filtering-Correlation-Id: 90594764-fa55-4b1f-03d8-08dcf838c1de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: BeS9v84Hhrz3fCwLGrFAIeuWs6RCS2VNBOe/qcj0xhNqe5ZWMprGXeiHJMN6QVVZ8EVC6CAOUCOFzZ9hv3pmKgGlXZ/IIwBzuEEl3Mno9DA4ufHI182/3BnDT3IYymKSWh2a8TSNefAzbIXi0vd+8KApV9cOJ45nt65FQIjXJrL8kgtCPrEEyiPyhIwa9xRQLerMa5mEGbHNKBXGtzdDefi4Hzi1n7y8ArDo+PWSy8vPEtggTr66CKzfn+AmDGhLvxv4K9M5T2KrzaSjzB9prC0XY7v3fM5vs3/HDESlq0J4yHtgr0rmHq80kLZ/Xw53c4vJYdiLhaO3a8boglDnf/ODGdikeOEPJ/60RBvpLRvTfvEFTkk9hu/cvz50jdgOAr2NKygYc853lPV0Hc9O+ogBjWE1dLIEO36Vm7u/HObZ9uEq6JIYosQnkKOO99kcF9cGCcBmhJTE5Yv+Ymu8ezmPAFqV74yVa56VZUxn5OHb5WkSuQXIs/D+OCmpfhwqgbiyV/zyPeqsPACfAfreWTmLWDlITisM12BS74F/2KGaKZxKKey9v76zUqWTfosTwt8wqVGLKs+F3qDydiUGo8oUHmtXZ/4SUijjxbBSOrKtWsC24yerpY5kIEVRPb5HUfK6iTMHnzYBcL/1+QXjNb2XNisOu1aUOdqM9tYW3OJvScpDA9wG/xuoYytHRyM9jV0GLAVbp4+hgRbut60j0w9UgKI/rKmZCrbRpac3HCCVDHqyNqAxrFa7HmhzoQ854t34JOZzMVtosKin56FJRmTvcnqUgbt/M+GQra3wOmj7g1R/aG/adzv+67Fn6UHrh2dURxkYz9CzMHaml11FtlmWwaSCgRZ7LBOS0WF5Q/ZHKuNRCgmNh9x7Mb27YCFhN7ddMahUC48TJMhSCHSlK28ZmPWsVxcNAvturDzsHWT3b/Xj49UXSgcdpYybwkt7VVa2GEORXXAEQyIzAYWsibYxZX5u0neCmPQubzOXqobjlUi3174izwf6vtkKMgDLs3PTRk6tO0f4XiIilS1DztG1PmRETYWbLZIlBnxzrXpcoAAsa/fMLuYMyJp7Bf3h7+8hAhI5GVn4fD/0vVd/K6dNfEkvIN/6BXeDOQc9hTrzn/gXnB+Zk+7WbWVCU78PxwkaZTecQgfBwHBpGS4DsFJETKpc1MzFGpup4VDauefwGoqbJOxuqQOtE1nJ7fHihiZxXvMHa9WDsdMZ+gILsGe1en9v+90FdpS/5NDdLjt+ENyluxCGUtfRPUtR6wX3Ny7OTTNW+tKKy1y9OiHORaDxljar4HXis5DpTNw5tCSo9a+qMrGo2fhXEeyl1wJfn9ZG2CTpwr8gINKYWEJ9U/1+S4qF6kDL/HFmZ4ivdUCVb0eP8dAE9tDLRdexjCZ54jNvlj2BcCXTVHq2H2wzGA== 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)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: jEB8ExeVdcZHyBjbQU2kwtqnLPtKePhqpbTkOwLwPWayADxhVSXuwxXsafO2D7vQ4cfay8GJ2C4Ay9pV9leNr3AIsbNTgkKUWWXqjakEs5P7gmZbfoSCZl6tl47pYVQKopPcgv/Dj6qp2L0YbzgPtjEWciu1ggRtEfGSz+0H5lny7FZk7ICcRQGPynjquxGhxE8vNYKfLDCLl35KBwpatj9ikapmZOgGDCz9wcPBx4dvTQpTF9SeBcOVp0JSMsfYlVUKPtw2INNHQLjozLiB9doxTxlBHBHT5wb/eMQFbzLxOA6KR7rQjHGRVGLVtQPMRYAFIbpW/YGZLg/lXyS6gVPVT7kRqpJIL+Wt9a5c4qLKgjhUreBo35VmMRB6IShk8atPqLCYONfu4jl9UojbI5ZXnJh1ZCbWnHe+r7qwE5+UQ/GZJ6M40w7yu1vKnjInrhuKfmoGwchfoCe5/C5pNl1SeilM4GYBgb0qkrWmHErtDk/DuEeJ6xlDfxKPoDSPRICt/urf5o1O0j6m/czsJ5Y9whnB0JLPKRbzHdxRUpCsZJDq5r5v57tcvWMWd0DuoVmPsQwe2sudZkiCCu6o9uSk6D6aaU6lNcP//Lt1BVIvN8z+9UK+wCXxckNW3sn5i/ocn3ygjAEqt2AnwkWURZBL18teUV54An4/mSX3/PY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:03.1521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90594764-fa55-4b1f-03d8-08dcf838c1de 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: VE1P190MB1024 X-BESS-ID: 1730220188-303097-12762-29331-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.42 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYmZgZAVgZQ0CAxxdzQKNXQ1M TExMjc0sQ0JTEpzTTJwiDNJMUoLc1CqTYWAOd2OudBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan14-53.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 possibility to use RTE_FLOW_ITEM_TYPE_PORT_ID Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../flow_api/profile_inline/flow_api_profile_inline.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index d403ea01f3..cdf119c4ae 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -18,6 +18,7 @@ any = Y eth = Y icmp = Y ipv4 = Y +port_id = Y [rte_flow actions] drop = Y 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 6bf0ff8821..efefd52979 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 @@ -928,6 +928,17 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, } break; + + case RTE_FLOW_ITEM_TYPE_PORT_ID: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_PORT_ID", + dev->ndev->adapter_no, dev->port); + + if (elem[eidx].spec) { + *in_port_id = + ((const struct rte_flow_item_port_id *)elem[eidx].spec)->id; + } + + break; break; default: From patchwork Tue Oct 29 16:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147623 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2196445BC0; Tue, 29 Oct 2024 17:45:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 945B942F31; Tue, 29 Oct 2024 17:43:38 +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 DD18D42EE3 for ; Tue, 29 Oct 2024 17:43:09 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) 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 16:43:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SInM1JBt8FA9cWOE5uZravbfb3QZ3dxobSrXLLggMTz7uh/c46gEheyq0YT6/7lYkiWTioXegXTnbRaB3yOdH+sH2r1j9DD9iZ7tem58RPJIUJtyl4qUXltB0gPCSfgmio9Ei0EpqB9HWergej/o8Ca0IkpZ8haYACZNZB+kFRA013BtLkahEKvx82Pbtr3xi73Ey00i59NWPDySDQR5hvBZEdk/UJhxa1a2+x5lXUruTBF9xYBchcweU0jDLr846760mQku+ckbqjtv+p5tUpW+LTNm/+XGRpA1PuT6RVIrDgM3FsyZruSDQle/rB9GbARI0ulDsg5nBfhZYJBY2w== 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=pNP/DcXPxy9YPmAaqviPinO9Cpb1fG2K6LftUPHMycc=; b=qEFE3t/bwzQ47arLsBFeJKTIHmN7gcxhpH1GgS+9HYr4CNmjPHZ8jVSsbpZ5GVSkXPqoM+p7LQIdc8IWWSCvOdkpeXp33MIwM15MOI4K33br2A3NyVCrObZ1GxI5chTaQ1z9ZaEoqPerXX6qaI3gmrFfpoSDiP9D32or6YMoNMHd0zvockvfmDzisUa9d2/vjtHnAC5it2Y1lcSsWgJvA6zjaXlh2+2r9Y76PBodALuSRLE3pylANq1IKf/h6AUyUKT6mrPOrytjm2DU3+HVnuET9u5ubDRrUhT3iDf3fiGah65Ig/b7MgdkboJJbtxECwxToMxxTzwA818YBhd5GQ== 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=pNP/DcXPxy9YPmAaqviPinO9Cpb1fG2K6LftUPHMycc=; b=j7i2gqEL6nv/kD1RqS0j9PaBiWJ1HxXMrcF+vO3BG7twqEXQfCN2JhG2gF1V2Uifcejmc13+ciSYPzoNx427nYKNNkmgv7YogPEbB3g8SivtghEPyRIQqoNcYVIOfJyOP/xWpH/sNbbJd6n+AHF3EJWu/VRZVAFxbanxwq/PQ2Y= Received: from DUZPR01CA0204.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::25) by DU0P190MB1729.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:341::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 16:43:04 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::a4) by DUZPR01CA0204.outlook.office365.com (2603:10a6:10:4b6::25) 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:43:04 +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:43:04 +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 18/86] net/ntnic: add item void Date: Tue, 29 Oct 2024 17:41:22 +0100 Message-ID: <20241029164243.1648775-19-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DU0P190MB1729:EE_ X-MS-Office365-Filtering-Correlation-Id: 45debe34-03e0-445b-7335-08dcf838c26f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: FoNcM3qEPISA2PYY4ou5cTKQA+1eD95q2HQT69WmCfIkOA/fZnbeZ/VlmUVdG8faULb0QLFRlAoAAbM+0E+j60hTV6Eqi0P/yE9ixTS4/vAdzIP0DzVsMvJAvkPe/kqXiF+jYWmsITHQPP7lShJ/p+5VCc8hrltXfM3TTsoaSbkcrGw5Or+JG0HIrd6WbLM7LHFHDIYDcQjodxmlZu9vb+b1JbT+7IlqF42OFwPony/uFAHXDnyu9Umm5m9OFAA+s2XOQeOzsmSgA/oR1C/4uUnIivj0//mTpAhXl9xPvmAAmlOjdp3AOYgkpl7HSkA/CbjcPK1Xw6UWO1xzJqSkxilh7YlTM7e7NDa/S7utRvZcTbzAC+crZyJoMt0hBOtCQG64aIlqEsiHhAYpEWC/9rSeJxDzdOfUbu/lGfmGe/HKvkT3rjpyfOIrPH7CJ4RjcReDCJcghKpPyGZ5wf3NrWHpMNLBHHxg/LMhpK0ccc9D7ZyRK3bxtAzYwp3TIIdQYUUuaGWI59U0g2Ym2veGNpGH3ehFvt5Js0kqO46H/T2ykyWV1nzo/JpEIWKGz0f+Nv629duOWk6VxSuZZAt7wizp24yYete+iX9ScaPUNwwcgR/GjsGlPe/X89l1euZZ+z4AO0CXGO0qQH7AVaL/MxMgp8mrXufPI+yfcwPJpoHCm0yjwwxt3GeKD8qrOluMDTaYM+qGVPtAnpc22FnQuJCmaIj6WeJrk65HnhLqsAAJ5FtCbOci40dY5pCerygJcFSgOMVxjRfm4YygST5q7xQ9oqayF9pxcBooUSfywlesCQs8Yx3L5h6AM4rs2O8vsbJGiM6tbL488N7z5j0n80sx4nF99RRwulSfvd9o138FmplaA4tGgwMhcTVpD4Z7jCi9oJrNdfQ7flbTzLBdlPnM8TO1hbmqEGOqZ8kUUIGd/mZTs9or5peW8plORaBg6IvUHzZIC5MCwq9GlaitclOYGrAEpPlpVeYisajq/H/QDtz1iI8Epo5OpdO2xZkBcbjl4VjehOaLHD6JKPExOHePgxpiJSPE9h+Djgbn1M83zesZHBkznvHL3etDCmnDhHUHnJjTlUsM8mM0mnq84/Gr/vJSao+WWoDgxvNOi/u+dgnFtm/HfJ0buKTQX/Cf6etfGcH6hB5/XOoDkYMmdO8AlKuR8OJpq8Up1OAgj9FNinSOLpCax+I52oYRov3LnGBDPzLEfh5KoLu1h92uSbGlRUF+WFm2rtYNNq2Caqo/EEQokOxvnjICRcv112n/mUCDeS94hG4f5R9yPx0hQYs3qiEmNB/4ThRHhxcJPjLR5xtrHBLF2EiiXBirh7/61iPn2e5utyQ1bMgEqgz4wgofY1SSK2HJG0ItI6Cv19Zi2Unx6LjhhccFPO8U+DeN7eI5GrklE//Zs1TboswakA== 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)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kb7E+rSvKP7RxxZWLBbQ4bREZIm/ewP79jtI5k9m5Hy4ENfA96te2h46n6OPCx8K28zcPXlxW1UkcN7S3RvtMAf8odTNuU7jZjTuaFZ4FD9k1GUQESE2gVK529+17QNACNB7XOKNhuH0XfkrU77Vmd0V1fCHs0IbSKRD8qQnBtfysQBZNF+Dnrq3mk+C/6+aeMukpEgRdMOMbgeGRHFdIMLUhXKbqOwbtR2cOg2uDnq0L9qs84Rrw/0109E6mk/6hui0bXqdMvKdc2zSSLpqwhr3ys79tBurfNyEuXIaDJ+GC5CAVQxMPBhlBtggFbfKhi5wD/8ZcSDdJn1sqFAq4N7n5CMlo/+jvwPkoQCgNTsU1yOfsf6eidiSuXIAPOPd2u1Sr3ndCvFjGq7pLBrOrxx9clakThffoV4tRY8rzgMFOBcY0iVlyrOup30KfHW0p2EOIdlmFCxulPmFJBd4BbpJ/chqdjL6NWxax52G7Gg0rjJ6vfWRFCEiiDY51gKvP8/xY1zKmmhRKldbsiGZUh2ivu+BIF66JDiafQqO7MQorQ3GDIe5EOgLhnGx0baIOgMrwyu/RzxafqRtrTeBPac7rmwHefYDLH4HqTIaGjUEDmqy4dOCyMf8nYms+gfXisExF6x3OjAAWm6jqEJ8IVtD3RAmRzNqaUtlmjOGHzY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:04.1052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45debe34-03e0-445b-7335-08dcf838c26f 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: DU0P190MB1729 X-BESS-ID: 1730220187-304438-12711-30017-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhampkBGBlDMKMUo2cLEwjLFyM Aw1dLSwsQ8OTnZzMLQIC3VyMLCMFGpNhYAoDrctEAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan10-180.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 Add possibility to use RTE_FLOW_ITEM_TYPE_VOID Signed-off-by: Serhii Iliushyk --- .../nthw/flow_api/profile_inline/flow_api_profile_inline.c | 4 ++++ 1 file changed, 4 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 efefd52979..e47014615e 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 @@ -939,6 +939,10 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, } break; + + case RTE_FLOW_ITEM_TYPE_VOID: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_VOID", + dev->ndev->adapter_no, dev->port); break; default: From patchwork Tue Oct 29 16:41:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147641 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AAA4245BC0; Tue, 29 Oct 2024 17:48:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66CC442FA9; Tue, 29 Oct 2024 17:44:24 +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 2772F42EFF for ; Tue, 29 Oct 2024 17:43:34 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2105.outbound.protection.outlook.com [104.47.17.105]) 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 16:43:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lUYO8styfG7qsL1E9ji+hvSjfhrIHmhED7fEhjBjJnf92nahZVZCUSdNVLWV/mn2bgXghObJUMtKpvMF5uMX1GzolUL3mh6qQdJ1RXYiQ/WKYMa1mg/2NTVc5N39mQAPb2mK5lPlS5VMpfjqBzZI/gx1bJyUK9T8AFQgBph1/8DKO+eR5BNxkelpOIVzT2ikzCSN5nmBXR8v7u0mU/85s+JmRRT9N493hx+YAR17N/LNEbc+qErQrBWbdl5RSdYtcCv5lFQKrL5/p8NeQGIToSSGMYWifqaMWIm/5EdsNBO6MtoJWHwKBHpJFFfONlgpiXUt8bK0OvD1f7taWiyxXw== 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=sgKavKocV7Q3ccCb9ZfjoAx94f6Hb6zX5ErhfRDT0ec=; b=PQk563e8QDfstzF8xYwvMHV7NhYsrvin4TjIdO0/Ze57imb0jClzPoRfV+wCSWJuHFIYFnHWjoLcjVc3YMMtYh1hRPYVdju0s8BfZ7nF5JnKB423OZKSHIKm8mT6fjqufQKH6cUbr3PZA8rGsmp3cHtqL2ZfXdYVNk1Vhqy1NZM+b2VtRqlHXAh5NCHgB01lWxrcH3HUYZXudsjfYLKP18/1Mucc0C1/8EIhO7hdcl+MhcPn5JQVTHmIjhHQgbUcC6+xVialWKUDmFIn9153GRRUlfYl2V8QBFv4z6vkoPMVW4EFMF6W39VEmFJ+xHBiZmuCl2W0ZlyrPmvGeYoeAg== 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=sgKavKocV7Q3ccCb9ZfjoAx94f6Hb6zX5ErhfRDT0ec=; b=VlfsHQp1mccDyHKK9sH9OWxPzRzh/3nQRe++C/Cram4urSu3HEb4wfOBht2FoZUzg9O/nudkx/nfVZmoZP4vGt4Qn4VWXVzg3kLUFUEqKdMAc8hlxyxbKmDPC6wcqHmlMLpoAGMt/KRpF3aPVAf3H10n2pFZ3K71xQO+hSyTSko= Received: from DUZPR01CA0204.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::25) by DU4P190MB2224.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:571::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:05 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::36) by DUZPR01CA0204.outlook.office365.com (2603:10a6:10:4b6::25) 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:43:05 +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:43:05 +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 19/86] net/ntnic: add item UDP Date: Tue, 29 Oct 2024 17:41:23 +0100 Message-ID: <20241029164243.1648775-20-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DU4P190MB2224:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e784270-9ec9-43ec-f408-08dcf838c332 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: ryDBZmE99QuSvRWlogBkFsquBM2gFAOlrGhQrZZuxsT1ig+eZnzeUEip5xxZ5rKZXr48/dXmZnbwF8TKJq7KmQy0itMmKl6/ztPTrMF7QXh/sXL/w9fwZmslwhQs8VkdJMggkGAlnVY9qcIbueDp+VEkVw26icyBS78SeMd/SXlKl7qTLdMM/kT0MfiI3doDKiUxsM39YUfIVdq2Wy40Ihy1mzqNllyiF5cEyPTk5pikUzO2qWax8hD+Qp6w5ixtSac6liEdQFF/W8DhtP4Ilwt7HwPw6TYsvxVtovMVsVGuLUQBk41kgZp+Z4uy5EgvDSRpJF02TWlKmQ/tCmXq6mYQCK/P246WRsEC//o5ZrYSYgNKK6ktyKMY7r4PTEg4HYuA5O7UfUBF+6TdC95OTN+/eYJa97IlL5jvhh64v26va+dCsSiBvtuHSbQNZvgnmr620cB8Vk7J+YOJ2580Wk/fjzBMFoAxo870x/CqUzUnfpl2seqL6FTTkzJwRTPfJFgI4viZwUkgfw7q3lHvMmMACUl7DQubm6qXHvnmsi0z3VZVnZ/WwpxpZ3Vf5D0N+U3ABW1AblYs7BqwSQuEAX5m17dX/YasMxe165Yoj8tP6eWHzQDH33uaGGko1UH2CVMfjiUG+lqnQZFmxmeHcnBWdUHJfmI6TzCyVN/TCXBoHAWyjouxNV+ue+4cErEPq9wexp/IGLVoOIbf6dIRtJD5ygp+1aYRiov63c5a3hmdzgY4RgjuAL3+TRYdDFVsFF9HbFvXq+JgKl2fciH1HzbWD617Ycb5TxB+G5MdEw2x2aNFLtC8CKBVqnvajBcqbrWqM1e7CVjdbaWZsDJwVBIux/9lGYhJI4ui7hG44exWM9nzDkmRpHFnV+wyFMUW4cNbU9b/3X8z1dOD9Fe6Dbth3RUp6g1J2A0Vid8R2+9Ynf+2IEkJgjpsTVmUmwlCMvdiifmf3Jizu/Mgg8sDgfnZlPcfeHq82sJh9yg+xeNJVxgw59TtJeFRdfRmV8svzZOO4HRF1aeICUUE2gMIIdiFjiP7t7R9BkeFIOkKSqdT9ttKlFpCVhYReCLYAy61qAV+YcXY8XioKummZlkXUiDGI/GnDOvGoUqr301E3zk2b/4AcEv1gUlnCj3/X27Kyb/iPoA/9tdm1K1WcU7YaWpRe+a/h0etNhitBDLzMjXBcLZJxycPsEWD+V7nvIRVAjJ97pBHuinq9HXVqennN1uI0FVBuu5q6UlUOcSFYzpQGKsvc2o/OuyG9qhHdiSFKL9uR/I/HkE5I1Q4En9BNHEGzeuSR/03Fpp7Atj4EKsQ+4zZFZ5G/jFp4ZNN0VRSFdutG8+ciMWuvGtqf7KMAhU8e8ffBt17eRz4xMf9G80nyGnPb3GTT/U7AgUHB9+lnAtpqAVWZ5DsyWakcJSOyQ== 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: 7y2RxzFt7b+n1aE2krtVUUGaDwO0SAsNcKg5hhzVU93/2gmUVYlcRY2UqtpMmmX2M+v3K60ey5qyjrwpnTSTxaE2dkmI/4IHTCqii0ZojhBHuFfpwnELoBSBbQPH2odEMDzOP1c33HUDv7my1arkyFmcHepQgHzd1cWTGzZg64NyHhTyw81zoQiB7LVIkCLA8H7TXXP9iK1cB86IC3Rjqvh+Tz8ge5z5v0ABGP4gqRoRuKBXwP4SmfAghVAfH24NRfdh14xqJ6TwbTgtOI999S+Ou72uiH13HxkOwoE+bZrZwGBm+VhV+mhqEuQIepNSrkvBdDcUivK5+yN1KgBddskc7Vt1gQGRedQ4wlUblUOBL0jJuyhHviIp7p8jxpqjOVgXyOk7p1MMrx6Ftiw7peRc4x5PXawrZWyoe6geI5kQIANmwTJ+tXkDolYqb7Tkk+g4mj+lgV/AecMxNCh4XJxhXCS4FJRCAZwH+K4pLegSDymMWLJILTk2YldXi+yemeuZDNEHZbPtRTxeLIn5aIc43+FdrWsuyENIr6VHmub55BYO/wA0/0dRafufMgKQ8uUas10gmNDWzGHtDSs6xtcy1wKpg2XGetqC9vVU0YvF3TA5oIGFAG/Gi6r80z6daKf7AsVIWd1WBK85EW8plSSOcHTJzfZwaeGCaXfTi8I= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:05.2927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e784270-9ec9-43ec-f408-08dcf838c332 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: DU4P190MB2224 X-BESS-ID: 1730220211-304438-12711-30041-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqZGBsZAVgZQMNUsNTXZ1Cg1xS LJMDXVNNXCxDwpycgkyTDJKNXCwjBRqTYWAH777UZBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan19-218.eu-central-1b.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 Add possibility to use RTE_FLOW_ITEM_TYPE_UDP Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 2 + .../profile_inline/flow_api_profile_inline.c | 103 ++++++++++++++++++ 3 files changed, 106 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index cdf119c4ae..61a3d87909 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -19,6 +19,7 @@ eth = Y icmp = Y ipv4 = Y port_id = Y +udp = Y [rte_flow actions] drop = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 0c22129fb4..a95fb69870 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -166,6 +166,7 @@ enum { }; enum { + PROT_L4_UDP = 2, PROT_L4_ICMP = 4 }; @@ -176,6 +177,7 @@ enum { enum { PROT_TUN_L4_OTHER = 0, + PROT_TUN_L4_UDP = 2, PROT_TUN_L4_ICMP = 4 }; 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 e47014615e..3d4bb6e1eb 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 @@ -828,6 +828,101 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_UDP: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_UDP", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_udp *udp_spec = + (const struct rte_flow_item_udp *)elem[eidx].spec; + const struct rte_flow_item_udp *udp_mask = + (const struct rte_flow_item_udp *)elem[eidx].mask; + + if (udp_spec == NULL || udp_mask == NULL) { + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_UDP; + key_def->inner_proto = 1; + } else { + fd->l4_prot = PROT_L4_UDP; + key_def->outer_proto = 1; + } + break; + } + + if (udp_mask->hdr.dgram_len != 0 || + udp_mask->hdr.dgram_cksum != 0) { + NT_LOG(ERR, FILTER, + "Requested UDP field not support by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (udp_mask->hdr.src_port || udp_mask->hdr.dst_port) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = (ntohs(udp_mask->hdr.src_port) << 16) | + ntohs(udp_mask->hdr.dst_port); + sw_data[0] = ((ntohs(udp_spec->hdr.src_port) + << 16) | ntohs(udp_spec->hdr.dst_port)) & + sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], + 1, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = (ntohs(udp_spec->hdr.src_port) + << 16) | ntohs(udp_spec->hdr.dst_port); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = (ntohs(udp_mask->hdr.src_port) + << 16) | ntohs(udp_mask->hdr.dst_port); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_UDP; + key_def->inner_proto = 1; + + } else { + fd->l4_prot = PROT_L4_UDP; + key_def->outer_proto = 1; + } + } + + break; + case RTE_FLOW_ITEM_TYPE_ICMP: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ICMP", dev->ndev->adapter_no, dev->port); @@ -961,12 +1056,20 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def uint16_t rpl_ext_ptr, uint32_t flm_scrub __rte_unused, uint32_t priority) { switch (fd->l4_prot) { + case PROT_L4_UDP: + fh->flm_prot = 17; + break; + case PROT_L4_ICMP: fh->flm_prot = fd->ip_prot; break; default: switch (fd->tunnel_l4_prot) { + case PROT_TUN_L4_UDP: + fh->flm_prot = 17; + break; + case PROT_TUN_L4_ICMP: fh->flm_prot = fd->tunnel_ip_prot; break; From patchwork Tue Oct 29 16:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147625 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 121CB45BC0; Tue, 29 Oct 2024 17:45:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C485B42F3F; Tue, 29 Oct 2024 17:43:40 +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 C1D4E42F06 for ; Tue, 29 Oct 2024 17:43:13 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2109.outbound.protection.outlook.com [104.47.11.109]) 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:43:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MQUaUPUYwfPzDczieRggPfuTX5k8SDuoQCTr4sQCAlpdLsqevWlqAlCyB1Jqit5Cz3D7XFXyt014AC/mUdBuqkIXYyB3iGk6B5eoTDRaWjz8N8V6a5s+ToAWrAVl399d/sBOxkd79PkMysCQLdOfLpNzJ2ZiEwKsNbD1aGOHiqpNLYvVwPK55HH78O8AWK/VvVoNiZUePxNYZzLIvtOmpppW/v6l4/hwfQ7LGa8UmBaj86AzhsZ5WybyKlI57/6CjipJ/rYo/vunyPuIRTHcVzsUkqsWXj8u75NyetIlT+DX9MbKP0LY+H/vZ20BOZwwDwxiaETDkVNGKu+5Al20Xg== 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=JJIdf/LYGhq0RVdw60J+lgDUNJKvu+99I1b1z6V6mMM=; b=ZoQmg+6cnjxmI1O6C5TALFd5VU/DTV+wt4mf+h8fCryPYiwAUERFuvZkXf1bgSOl6OzzXnJRtyGrKRWfp9bjTRq/JtG+6qRn3Iv+hmqA+Euy73ovtmIYyLjQP4n3EH5GfaBDeHt+h7U1TYYIk0Wvp60RDjwmQAmauiTEClRM2a3FkkeJqDwDS+RgKP52N8JMOLr8EO3r/STh8wEf4LyGEkuJgp4xnOT70NtZLRFfnQv3babfD6yl3zDArXGhXpn317GVxngnTiDE2IDXsQKDV4JVlLrPJVZQUSiqcBdgWLhjbIf5VTyUUyld+xdk6x5X1rP0Eb2CH7yN51v18qZf5g== 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=JJIdf/LYGhq0RVdw60J+lgDUNJKvu+99I1b1z6V6mMM=; b=jEiKlnII2rW1ta0DUrlBjeW9tsnrEYrI3FkqWVvbg7Supm5Uu8idJQZwfgL+CB4xIzKj0gTGdVJVgvvqHvjbceAbO3nCdoA5YWtXWyJuLBBcGMVRh5LyMnqMcuBOPH8lzlDZZohCU8LIbhEpsVFbYHFVYDzzWV7v0IIQTGwazw4= Received: from DUZPR01CA0198.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::29) by AM0P190MB0689.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:198::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:08 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::68) by DUZPR01CA0198.outlook.office365.com (2603:10a6:10:4b6::29) 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:43: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 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:43:07 +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 20/86] net/ntnic: add action TCP Date: Tue, 29 Oct 2024 17:41:24 +0100 Message-ID: <20241029164243.1648775-21-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM0P190MB0689:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f19146b-a6fb-4b6b-d036-08dcf838c493 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: 0WK8c1E8BxvtWLLBRN3/d26I8i9K6KIi5chlUuZ0slgPkc3q8cx8WNSXipHrmo6iafd2cx7pNcctN6jX+g3xtyq3tpPyXhsHdl/EeSJYfv//56YX4tZBtt4RyFPC5Zicqic5DV7Uv/ChjNSufKtqPimr1IhEfIRgiSpg1BQ1WASsDxrYi7E5CKX5bE3DgOF3iUvdmGYYV1W5HCFeyzv6M2vBpdL7ksuqXo8mDEX+I1G3hYidN7R030F8g2OfGHQS9vz+kEO96Ea4wZDovc0oVsmB9FtPHYoTOHDJLrrQFRVTCJh7fwd+PJKwj1GM4bCRIHi2vE7pL88LQedhZP5StgXcKcwirtNXzyGZoSfdK+e3SUwHFa9rSQoRgIIWbbCRbjUwo+C4Nn1+WUJzVS4ehGNn+S+eoE/0zpFEpFw4zwgf2rj6C+Xq4Knj6LXBFy1elu968py5V8YjWZYFBcgJHl+7l4CWRFDm6qGcKupUpnWEfHGblx5TNuT7THY4cCShzIl5R+MIJB0Y3XFs4hPPj7tXOfpLUdQ8SGv9g/LybBrFtDT4n62Jl7kHeuq1BlX3JRbAuXa2XCS7BZZI5j59UJCGp0nT//cUoTLP19O7A6jIYWWRTHtZncxXTEWTqgtrWPhv+Pta79YQNXHZ9bTi9ZIQlwnKmYAHq8uUd0IIsmGaUOngbFC5mZcpTCgE+bnc1f8bqwxDYHLE5nu2h8hp1xjrXXNlQV/T0zMuhNLYXht/vY2US1DMcZ+280Lu3ONPIqj2K+umE0TGsfxIV1jOjQIFjxH+VkV6LU24t1H7qlnqhq+jOy+wgsXo0AwjYLuTC/KFLP2MbBZOCB2tAO9X2RpXC8xqKtfocn5D4p4dgTi8YgsIioP0egi8M45Pw6uyBYsT/qTF3tqZ30wxjiIXBW4NFZU2W9kfeR9FvIn+HhJkmtszXBNW9WwOcQyK48dn8v0HCo02iNXYY4BaDO9I8xsuPTlU3D+oUlXOxKW0XcPWR7Yce/BdfGNxvSURewdFkSVfL24jZ9Z4GGSDdZBBw1PzI5zt/Z9rT5ZIV29R7kL7wxfV2aMgnSXYdxDFBPmVXQPaUtXlbI/GZ3cnrTl1FAcuDv2XhcLG7CgP4WsykEN9t1dpuypK9vWyQuPMp4pC5N0LZ5Wecn6rtxyWb3MacWzICLTwYZE9dMSvrVvxChEnEpV+a8ZTWYMwkkXcGfllGWvp1tsw+5xTW2uFECPELL49Ht71bvw+iUu3dwaUyB52/Imoqn03ADE2qbJGuQxdi3NwKpP3i+3XmmXBIYoL6Q6cwdJy73Od0M+craD+YOGbxm5AZ+SOr7MojR+TmR+q5BZt+Afiz9dgW6GbbySHrP0zexX/i2+1zm4CeKhQuyRnV0t08ekQ3rTuaEpwbNbjtJBmHOTWgCGl5/+hXqOivA== 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: EYMs4K/IObtulp4LllURAoPGecUQ26fzdNGryLrkN93hAe7n51NsaqzqXJCZ0FSr+H5gwPyNcOu3kr+5vIVhqh5oQl/4mI1PHPT0ijVxErShYDmscH+i48FRyQcg8Aj4tmcpJIEA/02hVLFzgH+AXcYfSdF+IOSZg9oTJ5lEQRsj6oTHY4SJwf5Am/dHAx8m8huSexbeRnFnMo2UqBAzaxIvku+/3pruC05V89P9HPvu/Lx3b9WSjEfAHmxVcbMTUuaJnEV6DErwVZ8IIyIaulF3ssdHoBfm9L1xyjl1/i0BZpcitGGSe80G454szxj3NaONImayNFyXKSkevm+c5pw4hPS09jVRPjbc05bt8g+yorE5SRu0n+pi3bM7lSKYC8V82iwXGbqFrRq5WoY5GK/q208Z3HRGQXa759MH6UHKdo2kkhL/lIEnAGRzNCJWrepAgTqn72iRUWn+IYAqs3fpaf6ybcPAU1tzd2t8t3cOiIqcdwgA5RuBPu8mLtnZMZXMa4f1jq5Vx88U1yE/Qzsg3dZyphbKIPvkFcqdXrjcgcHmOwl9jkIH97I5ukBpawhIw+XAu71W/IEQQzxPAtr/dJjKe8Z5qwcZMKLkG4orK5d351VSuzT32BYdPEOJDKVnPokHGRq2sFIKAcEHaha89CgY/Yi6Hr0V3pM9+os= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:07.6677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f19146b-a6fb-4b6b-d036-08dcf838c493 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: AM0P190MB0689 X-BESS-ID: 1730220190-303097-12763-29332-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYmlpZAVgZQ0DTV0MAwJcXcwt DSwsw4xdDMJC01xcIwycQiOcky0TBFqTYWABfBaW9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-12.eu-central-1b.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 Add possibility to use RTE_FLOW_ITEM_TYPE_TCP Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 2 + .../profile_inline/flow_api_profile_inline.c | 108 ++++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 61a3d87909..e3c3982895 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -19,6 +19,7 @@ eth = Y icmp = Y ipv4 = Y port_id = Y +tcp = Y udp = Y [rte_flow actions] diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index a95fb69870..a1aa74caf5 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -166,6 +166,7 @@ enum { }; enum { + PROT_L4_TCP = 1, PROT_L4_UDP = 2, PROT_L4_ICMP = 4 }; @@ -177,6 +178,7 @@ enum { enum { PROT_TUN_L4_OTHER = 0, + PROT_TUN_L4_TCP = 1, PROT_TUN_L4_UDP = 2, PROT_TUN_L4_ICMP = 4 }; 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 3d4bb6e1eb..f24178a164 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 @@ -1024,6 +1024,106 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_TCP: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_TCP", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_tcp *tcp_spec = + (const struct rte_flow_item_tcp *)elem[eidx].spec; + const struct rte_flow_item_tcp *tcp_mask = + (const struct rte_flow_item_tcp *)elem[eidx].mask; + + if (tcp_spec == NULL || tcp_mask == NULL) { + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_TCP; + key_def->inner_proto = 1; + } else { + fd->l4_prot = PROT_L4_TCP; + key_def->outer_proto = 1; + } + break; + } + + if (tcp_mask->hdr.sent_seq != 0 || + tcp_mask->hdr.recv_ack != 0 || + tcp_mask->hdr.data_off != 0 || + tcp_mask->hdr.tcp_flags != 0 || + tcp_mask->hdr.rx_win != 0 || + tcp_mask->hdr.cksum != 0 || + tcp_mask->hdr.tcp_urp != 0) { + NT_LOG(ERR, FILTER, + "Requested TCP field not support by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (tcp_mask->hdr.src_port || tcp_mask->hdr.dst_port) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = (ntohs(tcp_mask->hdr.src_port) + << 16) | ntohs(tcp_mask->hdr.dst_port); + sw_data[0] = + ((ntohs(tcp_spec->hdr.src_port) << 16) | + ntohs(tcp_spec->hdr.dst_port)) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], + 1, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = (ntohs(tcp_spec->hdr.src_port) + << 16) | ntohs(tcp_spec->hdr.dst_port); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = (ntohs(tcp_mask->hdr.src_port) + << 16) | ntohs(tcp_mask->hdr.dst_port); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_TCP; + key_def->inner_proto = 1; + + } else { + fd->l4_prot = PROT_L4_TCP; + key_def->outer_proto = 1; + } + } + + break; + case RTE_FLOW_ITEM_TYPE_PORT_ID: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_PORT_ID", dev->ndev->adapter_no, dev->port); @@ -1056,6 +1156,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def uint16_t rpl_ext_ptr, uint32_t flm_scrub __rte_unused, uint32_t priority) { switch (fd->l4_prot) { + case PROT_L4_TCP: + fh->flm_prot = 6; + break; + case PROT_L4_UDP: fh->flm_prot = 17; break; @@ -1066,6 +1170,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def default: switch (fd->tunnel_l4_prot) { + case PROT_TUN_L4_TCP: + fh->flm_prot = 6; + break; + case PROT_TUN_L4_UDP: fh->flm_prot = 17; break; From patchwork Tue Oct 29 16:41:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147626 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6A4A145BC0; Tue, 29 Oct 2024 17:45:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E917D42F45; Tue, 29 Oct 2024 17:43:41 +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 3563442EE9 for ; Tue, 29 Oct 2024 17:43:15 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2171.outbound.protection.outlook.com [104.47.17.171]) 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 16:43:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UtzNTe1GD2jg/MiKy9JHCi2h5HXNqE4L5Ojv7Ro58adTNko1Ad3jau3tdUQsxgGgxfFkD8s4CJeiBbw52TrNoabErzHrjdGqzgDP+a6UgsQe/3+i7CMIzm1p0ny3qYA7mWwS8PU64ZjVgOXMZDftJUy8G1tgnlR1PohBIdqSeY9SqXNqhLVN6UtGXUy7Mj12c1A9nMFBt84Fa1gh1D2ECuY+TJ0ACMkf5uHmAWXw7qHtd9JNKpaMz54UTgnnCtFgRZu+z2og6D3xCjj9C4utNEK2ou73+ay0DPHp52IchYhxa38SEQ9Lm7QgWDX5JsLctjhWtYTiGu0AdVeDHligsg== 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=2ORsmIbUs9+AreWbb4DUG9MMuXQUn2RoHJSsl2A0VlI=; b=jqKwX+97UPYJWrMxtt6qOzETzxIbXEUhp2ZXBZ3U8g8S1WtxwxXtKyEJIThxJ9e1pXS1WqkzylP5gl51S+01+tEl26qC4RfJn4IWtXCdelkdFBT7MYBPMkTOGntqXVSvZNAjzcOHz0A7zh+sAIy/XU4JtldvLMORRVBS+EX9HsN/iHQweMVx8sRHB6Onqvm9rN51fmAiHNs0rJ5fvxxlC70CbszOS8L4R5pKDgdVqp/BA8Jt+5lEmnRoP5uUPvo2dGdZLMMleCyIzKqFjUYXYxm4tzpEGrxODlPKMnJJ9dBUUkabd4O0a/16MPoH26AxyoBE63eLyrvsQsZgRbGNCA== 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=2ORsmIbUs9+AreWbb4DUG9MMuXQUn2RoHJSsl2A0VlI=; b=nrX/1z/i6n4eoNIC/oNahzlyyxjrbo65LTfFmElTf5wPz51ByqOE06JwLwLl9Fbu9GuNU46CHyqrXqqvcDvnm/KM3flBKZ2zQVaAogH8yDDVmW5D17DrBy7/Pz9phbX3rLHFkt5QpkjULusMUW2SgoDpamoMZIRIm0tsSNe0hBw= Received: from DUZPR01CA0204.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::25) by PAXP190MB1717.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:285::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:09 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::36) by DUZPR01CA0204.outlook.office365.com (2603:10a6:10:4b6::25) 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:43:09 +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:43:09 +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 21/86] net/ntnic: add action VLAN Date: Tue, 29 Oct 2024 17:41:25 +0100 Message-ID: <20241029164243.1648775-22-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PAXP190MB1717:EE_ X-MS-Office365-Filtering-Correlation-Id: 73e92bbe-3fa7-464e-c508-08dcf838c58b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: 8oAv7Sw3QOpIIgpt085lahPdYk180cUy/Opp8cnTMy2wv4O5TbFyMlaTE0ao/ThY3N8v2pRE26J5JGwaHaqQCujqE5dDtkdqO0U3l/sznYxcQhOuipsLFecEwk8mX1Amwmt3MSbMO1lRA+y6G+AlIfoA+Jpdv9pVKkZ9c/sOgV0g0DvLwagTzk96lCx/QV/83/7hDi1xeJy5BC5DWeT/5CoD4ewv336/V8pEv4ZvMEvSKPS181IVvsG5VEHOWHzlUSZJS/O5zuMpT1oPg1qUhBTNNN8uo56TnSxkjkIIwl0Xscu0ssl3EGp65pMgWhKTcRBaQS1ZxBaMMZwcsje48uaFQPW2jF9W6gEPPe9V06BKuj3LuWVCFCZpm5Uadq/CUqoZK17GUgUIBT//PoWqM6NOybRvtcJaA19qbMOgb1XCku8G4ry/7IhnxIeLH60z1fEhz0Ndw84kzK529fjXzkAjnuvCZ5lMBowy+weGK1AhUQU7/CbhXXbwfntLWNlbeyU4/bu170d9bodH0b2AZ36NWUhhXMj/R5DkDEZdwKJ++zJ543BBkJibZO9saf/6gDjSS1a8z2/biQD85KqQM4atECvctPGXUsJrZJ+KX8VtEgBwWg/jiyDv++ZHF9pc3FXuBB5IrtZptmMGISFebW5YGyGcBpVuO9EzMR/ljRIA0/RHbEWl63Q+tDxE+3vhpVVVv2JYsFi+UesgJyV1H9OJ0vlQG2g1+naUbkgeGBwc5qh6/CN4NUwNOS7qYh6ax3sEdxrBL8H+F5jf79uIQOX4kpIePm1341l74RtsOC3T4nnyfsFTxgC33B3aKtQAd1g4IjWDNEw/2puwSyVqxaklbJbEhiASb+fDBBhhp+KRi3MI8Hx23YPnOK2ceakkNYGE+2v6RgofuvdFsNvOSIkmT3d4DZFCMjiYadK8RnMdBHxQPf9uyZ7X/ljism3fCLWT+fSNrOQ1yA3UrujaB4g6U+Qca0cr2HEa1tUyCldAKWjdPnCu9A3sICka30NzfR0Gc4E00xZrpRsLoAQpQbQ+yxziJy5dHqWYii2YvyBz5gmU9pyzBs25YhBspnx+WYZiovwrAP285AU/3IOH56jw5h5et/PZkcyiSo0Kha+gfWld6Acfv8PudIWxaWV2y944kFsWSfXTwnEL/lWTp6n8mk+YOpgBG0u4ehqsPwjM21E8ifUk5MWUtrjtKq93HYnwe8cB2ZNK7jENWO6w9k3kPCzYwqIlG/EQr+q2PSFUpcenajkNxo2uZJ7QVc8fLp0s1G5AQuuTByYMWPPlKqG9SRo33KHWObUwna3P+fs404tqpjHiI04osecv+wkYHSmZzFyqse7/6FtgPz95+6TwfcgF1sU79ULzzcGW2Y1dC1uIBz/gqBwIqMEZqKUl/zzdGmb8P8vSm9Fdi+T6eA== 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ACnL4wQYmauBbXU3/9/E9yMGHgvaLfvKgYVdPgn65MnhnoaWxd4xCYkBlZKoLx+jwdw4EWfONRFG9pKBKXR3LXc2DWwj/X4jkZqvnWjszD2rzsfyZ5w5TsOLYgXiaSxZ6DHqIZSudSGoJZtrqIRSEdDxi74mCTXwMyK/OIe34MrG1quDQEOwT76tcg6akXCavQHs3olOOJ0P+OA/xL8pACn47vO7PahF8Oe5U9N2S2K+XIQFYk6rMRbJfdDB3zn3PGVwjtVv8KePWSVNiiX57Fkd3cijWm7MWNOrqhpwsPeiK2EVjl3cxtOMbQfUYWr9/lZ3fVxn6RIHRKmqR4KIPPIjy2hU7wxz/6jk+wbliUOlwQZTeHgGztOMZfneQz4I6CBjYnOXYeTAPIzG/9xyELFNaRo43BkAmuOQsOcSvR4f/MtEYdGkr2r/AdwI65WLMHYGT4Z9k+P7+pTfrDGOb3fBxKTy0z4xDkb2SvT9QawHQj4JeVfXG7qv/D6MHTSw6yr/nbRXFhUhQykwvAQu7UuTOV/u4a/YNxp2ux7AABTpeVeVlLK+XdtzQrQQ+72T0ks2YHXFYnjxhVPb+gDZAwQptIhSaqehF/6X8UyX2T9HRYmDKzp2ZRh5kTP4ZP5yDBYvMutoNb0VT/t/BlzFD1CC4gA8DXziHOEXV+laJ6Q= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:09.2771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73e92bbe-3fa7-464e-c508-08dcf838c58b 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: PAXP190MB1717 X-BESS-ID: 1730220192-304438-12711-30021-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmBiZAVgZQ0MLYwMwyzTLVON E02dDCzMwyyTLRLAXENk5NMTZKVaqNBQCsBDODQQAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-168.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 From: Danylo Vodopianov Add possibility to use RTE_FLOW_ITEM_TYPE_VLAN Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 1 + .../profile_inline/flow_api_profile_inline.c | 94 +++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index e3c3982895..8b4821d6d0 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -21,6 +21,7 @@ ipv4 = Y port_id = Y tcp = Y udp = Y +vlan = Y [rte_flow actions] drop = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index a1aa74caf5..82ac3d0ff3 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -134,6 +134,7 @@ static inline int is_non_zero(const void *addr, size_t n) enum frame_offs_e { DYN_L2 = 1, + DYN_FIRST_VLAN = 2, DYN_L3 = 4, DYN_L4 = 7, DYN_L4_PAYLOAD = 8, 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 f24178a164..7c1b632dc0 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 @@ -504,6 +504,20 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, return -1; } + if (implicit_vlan_vid > 0) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = 0x0fff; + sw_data[0] = implicit_vlan_vid & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, DYN_FIRST_VLAN, 0); + set_key_def_sw(key_def, sw_counter, DYN_FIRST_VLAN, 0); + sw_counter += 1; + + fd->vlans += 1; + } + int qw_reserved_mac = 0; int qw_reserved_ipv6 = 0; @@ -664,6 +678,86 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_VLAN: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_VLAN", + dev->ndev->adapter_no, dev->port); + { + const struct rte_vlan_hdr *vlan_spec = + (const struct rte_vlan_hdr *)elem[eidx].spec; + const struct rte_vlan_hdr *vlan_mask = + (const struct rte_vlan_hdr *)elem[eidx].mask; + + if (vlan_spec == NULL || vlan_mask == NULL) { + fd->vlans += 1; + break; + } + + if (!vlan_mask->vlan_tci && !vlan_mask->eth_proto) + break; + + if (implicit_vlan_vid > 0) { + NT_LOG(ERR, FILTER, + "Multiple VLANs not supported for implicit VLAN patterns."); + flow_nic_set_error(ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM, + error); + return -1; + } + + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohs(vlan_mask->vlan_tci) << 16 | + ntohs(vlan_mask->eth_proto); + sw_data[0] = ntohs(vlan_spec->vlan_tci) << 16 | + ntohs(vlan_spec->eth_proto); + sw_data[0] &= sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + DYN_FIRST_VLAN, 2 + 4 * fd->vlans); + set_key_def_sw(key_def, sw_counter, DYN_FIRST_VLAN, + 2 + 4 * fd->vlans); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = ntohs(vlan_spec->vlan_tci) << 16 | + ntohs(vlan_spec->eth_proto); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = ntohs(vlan_mask->vlan_tci) << 16 | + ntohs(vlan_mask->eth_proto); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + DYN_FIRST_VLAN, 2 + 4 * fd->vlans); + set_key_def_qw(key_def, qw_counter, DYN_FIRST_VLAN, + 2 + 4 * fd->vlans); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + fd->vlans += 1; + } + + break; case RTE_FLOW_ITEM_TYPE_IPV4: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_IPV4", From patchwork Tue Oct 29 16:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147628 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 78FA245BC0; Tue, 29 Oct 2024 17:46:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1031142F55; Tue, 29 Oct 2024 17:43:44 +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 BCD4D42EEA for ; Tue, 29 Oct 2024 17:43:18 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) 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:43:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zVzUQ+IZ1FqoyI2ReMa7Ty5hg2yXO3cvEsKw5/Xl7wqLtRdyUF3eV9jEjJkvyCLqg/Qd3JjAV9u634oW86fK9bfjSPhUWyaUOvS9qw109b7HQeuNsUueNbB0kMFh5kYG9NhrrzwJtPKZ+WpXYgcXAzi+lUU8dKEEcszbEC+duiIBYdfCi9O/n8KUQD4RJ+6/0N1NsXUI8pj3voduPfjnDh5xofzsJXCekPRPsfRPBEzyXdRPFa+lovZ65FbQjEBGn2brZvzcZxKTKZ/Pi+uEqYljtCJ76+fHOJzC3hIKrP2Vn/7OvLZyNcGXWFr6Kg0kcRpzFKVXrcAwMrRFGKum/A== 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=wZKzx16D0OTjHTSqAYb/tKA9hpA6o1aCSzM3D55atVg=; b=nRVm9urwzpxXv9kknRsGNJzNo2NS3KH/W3Q5xAquDZpkU6BKgc7KlzluQ5aPnMAX6cX86EpYxqPxqpBYIAX/kcrEjqAMSo2xkKMZIqxA4v0e4oWbxIm8951r62upeE0tjciKdOkVMRGxMH0QW2KlFlvXZRBzSip6bGIwBj4lBvA6Bcxw7XqJWDG0e73Zv5gsQev8YStFNBzznEhLxE0yckEjSAhahL6BoAzIvRwiyYMzSksuJVX0zj+9CRF94gPgPqYMyYfJDMVZjHZY0ysGfWYvPk7pWJlnZWtvRQd5VQbTOupUQcDc7Y4xgFeGlHHT9FV7ihDOQElAp0dfyFX3mw== 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=wZKzx16D0OTjHTSqAYb/tKA9hpA6o1aCSzM3D55atVg=; b=nJUOX4fxyxSf0Nh75S3hilH4slgfafoe8a5C3Ef/Adb8LpTPU49KlLrTB1GcI8KbY9W6jlFxbt2OKtPl9TLvE9sIJlNkOswBrZ5gDx2bu6IYTefBKukB1DTCLl8dprSH2gTLvdKj69YwqHxvgVSD+f8klNuz7qdacxtiIuPBPlM= Received: from DUZPR01CA0199.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::28) by GVXP190MB1941.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:69::15) 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:43:11 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::9a) by DUZPR01CA0199.outlook.office365.com (2603:10a6:10:4b6::28) 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:43:11 +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:43:10 +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 22/86] net/ntnic: add item SCTP Date: Tue, 29 Oct 2024 17:41:26 +0100 Message-ID: <20241029164243.1648775-23-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|GVXP190MB1941:EE_ X-MS-Office365-Filtering-Correlation-Id: 2db6b220-99df-4584-1bba-08dcf838c686 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: vZUHdABA6ZzEfoN8jieepsfoEXO92FmjOc8/rvOAKjMQrWrjj2tCVGUu23Tb/17+Ebd5UM45mAmQQPErQfbKitY+SGMgU0MSHjXafOQbXxaC6Dribb9jtIp2u5DIQVSC4H/pLEX5Lp/GI73jTQ13hdxT7ZPc+R+pjZ88bUqpevZwEBhijSSWY6AlNyu1OLne8v6ObKMvxD6/cI1YS/qGAZklaXgH7rSDMwc4JH98Ixn6JxwHgSokdFpLYMD5D58ZTxh40+egqcs8dsFgf/z4Llump5nElXBeyGFZIdAeJD5kBH6w1hZuThyb+xFCn9MNtRDLADN77kpSKcFB/ua14w1v+cBmh0XY08shmTGCeVNK84UkBuBTOSJGIcv5rMQOPzGg9UuV0J/YnJm5qOCgETK9BUshbMca/3J1ssL7/QkIjOa0g21Q27Khe/iavsVmr92Gmuz2lAJvFhMcwYd+dZwYngjKuw84c897NhLuNfMXH5Gw2YmDLPbFJCZoOKNVorSEbzLmfODieZeYBBXAjHOmODBcPQhJCvqcIeCAZGV0VSnsem31rdrG56Oen520JSFYawfUB9PobJCwTUXbHCWeenRI3IPgAgZZHTKhj65sUJiajbgnqrNwglY94RdJpzT5T5RX+cr3JaXHv5gUABAQjEf9aaoieA9yo+6SJyKClyZ/f7KU+FE2khPPepZQFcptJkdUlydr96NLCGZHOWSVIMoPCcWnJnsmoQD5TW6emAPsnz9aWMc7eKptgaQ3GomXj8BzGEhyFQhFcLyXaYiSE/hF5mWdKYCc2+4e5thcZw4/jJp06h4S7b0sOBnxVkL8b9p6Um1D5VZm3Nf/NHSbSR9bKEL5IUSSgSafzvRxTn3Zf25CEcnUvuOTZSW/St7YMkZk/+N5LrNi1WvjfNNLAfPdhfxl8nMczmxRdfLKcXLvyLg6K5tNuKgUbjT2Z1gmj18RNWm9DA4Gi701lYz9uDaIUNtPHK27stp7FKydf3Cbjc98CwZ8U5KMYgEP97QdvorbWU9OGzJ5UPnYEIJv8jiQey0xjcNPHxEM96MsgWfkKnW+x8QXvZcyRTDKBtSnZC5YWvFQ8xHMqqN6G1fQoFKFlL7OFtPOLXCKB8UjtJUl07SdpdcEmPxoazNyEVMa6DZ0bgFbkP6xrFy82tIRdIO4+FVaW7Prn/4plbXVB88R+6g0lM+IHQkPziWUkV5SqT7FmNHRU6Fcz+vTK+oCLfIALW+vFYI1H5cE6Lk5fWO0114YU/HGU64hNytXUZofHRnSms5iCeB3RnfRw6nod4PH0KmIltED9qtfvxX2bpHLuUfZoYKl4RPHcUn7ZKrtBShzs7dD58E6OjHCSEtFT9oXuALWBvlSRi71odZ2z48VZEXgEUdahAOR2eH14CDU1/tE623fJiYb3YmYyg== 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)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aMMDJAU/hfisskQsqwqlCFxVhxEfz9xZEm1ZoXqlntNtT5b6BeXvYPZumlhIccfPgTw/NNN61RIaRRR2lFg1MirDcsK3iUgtcLWwv03QlCQwsxuCggh/zMF4pqUSJ34l9ze7LHa8P/9d0oUDIM8Z/tH3KcxlRM+lIjheIWSNCB4WrNFMq19+fakXjhLnJ4j3yD/teyLWONIJKn1E1IrnXSLAJBPA046rU3qN4YchgQXzij3GiKzaPyXjLV9dL2HGtiJuPiMfMynlV4NrXhDsiebx+tgPYS95XCSmYIo62iRU2TIxrTfNn2QmAho7s1VWkR2x7YfWe548V4WYjkNcPLVo0wKI912w3FwQ1CFt0DVFWaIZLZFgtvwDsUS6Ptbe7FG5oJ8U3IGeX8e/rD6tSf+naZzOBnxv1+ONGSfz455CGCabffcRjbXL2Dgi06xQn3RW0v6BRuUVTFtCejLJ9Dqsf7OijMBT+L5fclHwMkOezZ3FlXuvSPYnMt5WvWojxm/xiEXOZALC4uPfOp224mlDrQvE8y6DcZFyyLkg2QNj728dL4S4BExajSR5Juc+6PYCrti5Dw3BR/qUNx279fOcDGlxEnzQijweI/47jpdS665P3Pn0lxcaRJc2Mq7hSUO61zS+VvhaLB94hjFkS4eKZy7cAUs3+LTvuQMuPTY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:10.9333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2db6b220-99df-4584-1bba-08dcf838c686 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: GVXP190MB1941 X-BESS-ID: 1730220195-303097-12762-29338-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqbGJgZAVgZQMNHMwNjI0Cgtzc gyJdnYIMkk1cDcMjXVwtLczDLV3NxQqTYWAB8sb8ZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-73.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 From: Danylo Vodopianov Add possibility to use RTE_FLOW_ITEM_TYPE_SCTP Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 2 + .../profile_inline/flow_api_profile_inline.c | 102 ++++++++++++++++++ 3 files changed, 105 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 8b4821d6d0..6691b6dce2 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -19,6 +19,7 @@ eth = Y icmp = Y ipv4 = Y port_id = Y +sctp = Y tcp = Y udp = Y vlan = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 82ac3d0ff3..f1c57fa9fc 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -169,6 +169,7 @@ enum { enum { PROT_L4_TCP = 1, PROT_L4_UDP = 2, + PROT_L4_SCTP = 3, PROT_L4_ICMP = 4 }; @@ -181,6 +182,7 @@ enum { PROT_TUN_L4_OTHER = 0, PROT_TUN_L4_TCP = 1, PROT_TUN_L4_UDP = 2, + PROT_TUN_L4_SCTP = 3, PROT_TUN_L4_ICMP = 4 }; 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 7c1b632dc0..9460325cf6 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 @@ -1017,6 +1017,100 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_SCTP: + NT_LOG(DBG, FILTER, "Adap %i,Port %i:RTE_FLOW_ITEM_TYPE_SCTP", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_sctp *sctp_spec = + (const struct rte_flow_item_sctp *)elem[eidx].spec; + const struct rte_flow_item_sctp *sctp_mask = + (const struct rte_flow_item_sctp *)elem[eidx].mask; + + if (sctp_spec == NULL || sctp_mask == NULL) { + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_SCTP; + key_def->inner_proto = 1; + } else { + fd->l4_prot = PROT_L4_SCTP; + key_def->outer_proto = 1; + } + break; + } + + if (sctp_mask->hdr.tag != 0 || sctp_mask->hdr.cksum != 0) { + NT_LOG(ERR, FILTER, + "Requested SCTP field not support by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (sctp_mask->hdr.src_port || sctp_mask->hdr.dst_port) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = (ntohs(sctp_mask->hdr.src_port) + << 16) | ntohs(sctp_mask->hdr.dst_port); + sw_data[0] = ((ntohs(sctp_spec->hdr.src_port) + << 16) | ntohs(sctp_spec->hdr.dst_port)) & + sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], + 1, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = (ntohs(sctp_spec->hdr.src_port) + << 16) | ntohs(sctp_spec->hdr.dst_port); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = (ntohs(sctp_mask->hdr.src_port) + << 16) | ntohs(sctp_mask->hdr.dst_port); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_SCTP; + key_def->inner_proto = 1; + + } else { + fd->l4_prot = PROT_L4_SCTP; + key_def->outer_proto = 1; + } + } + + break; + case RTE_FLOW_ITEM_TYPE_ICMP: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ICMP", dev->ndev->adapter_no, dev->port); @@ -1258,6 +1352,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def fh->flm_prot = 17; break; + case PROT_L4_SCTP: + fh->flm_prot = 132; + break; + case PROT_L4_ICMP: fh->flm_prot = fd->ip_prot; break; @@ -1272,6 +1370,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def fh->flm_prot = 17; break; + case PROT_TUN_L4_SCTP: + fh->flm_prot = 132; + break; + case PROT_TUN_L4_ICMP: fh->flm_prot = fd->tunnel_ip_prot; break; From patchwork Tue Oct 29 16:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147627 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B8D845BC0; Tue, 29 Oct 2024 17:45:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC4BC42F4F; Tue, 29 Oct 2024 17:43:42 +0100 (CET) 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 21E3242EEA for ; Tue, 29 Oct 2024 17:43:18 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) 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 16:43:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XrMAdKLHN6Z7TEs1/Gw2+wf+EZZ+beV66K7j13XAuS8PGmPICTp+vBw8DBmsP96724P9rfoUPVw8Bki2I5GmjE0TT8Qpc03oVNcRsjzpvxL9G0ncJ8k+hNmf2jwJMle2IBkHM5osB14X728yqL3o1UBCWogmVYbYdKVs/rBViQxk4o6WKofyq7qb1NqPz14k4zJWNEd8Pm9XPQMEne4Gxx64JTX0IW5pznM/9DgfuURVi1jhU+xbQWnnm3QKS3pP+pRtrekLowx7UPqjN9Z08yHKasFL6Al8XEqVfjIN1YHGbvuItdepmb7Qb6AKxmuZsAH0MzEQ7Jw/PJrx/8sEbg== 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=ecx4E/k/paGLarb20VPImMYLkElJEiAaHqeL9AZHdSA=; b=xmw7iKghk24L7uUVGKn8EY49P+E4IHUCGrH8mDzTWvV1Ur2u/2usq9ZP/gYh5ByHSEqF8y3EbzOCTcts0y+W9WiTxwao5u1IuTwFvnmoD08HJ7cAWeyamuXUdfesNfhJKJwhip/FCGsqEwrbv3EqzDeJ+B6I/aFs+UpaZggSEUm/OfYtE8TsifapPai6i9ZXMjx2GY+DpN6p++s5UMIK1K4T1QohljnHbEsMf2isaitZkzTpnntcEQVCZVhovziCb3FIq0iifa1fzPfpVze8AAhpjHqoptp1muscDdqmBlcSfk/L7SJvzNdBcplorvj1pDJv9W+BfnbkIORh+lmquw== 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=ecx4E/k/paGLarb20VPImMYLkElJEiAaHqeL9AZHdSA=; b=B6qYaxtwh1q5nFYiud1d1kVxOTz7Ovt50T4A6CA7EpXSbNfGHdJxA+HuzW+FlMCd5dHCTFzIELpyHdh75FHdi0TOlyayU/r+ia45rOaKgRKebt0ujqejkfRyLefgTi+7H1Nug4111XHvwH3ZtX/MtNWAEthbfRe7CglEezAAxmE= Received: from DUZPR01CA0210.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::24) by DB9P190MB1817.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:33d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29; Tue, 29 Oct 2024 16:43:12 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::e7) by DUZPR01CA0210.outlook.office365.com (2603:10a6:10:4b6::24) 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:43:12 +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:43:12 +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 23/86] net/ntnic: add items IPv6 and ICMPv6 Date: Tue, 29 Oct 2024 17:41:27 +0100 Message-ID: <20241029164243.1648775-24-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB9P190MB1817:EE_ X-MS-Office365-Filtering-Correlation-Id: 6aa6f251-a02d-4633-eab9-08dcf838c757 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: sa+KenrAplOzUsiAmA+dDDL//fdqGrdVXOo0bJheWi35l/vKQmHWjGjk5Z6lU7Y7Z4pouv0ot33OBZH/uWMzeO94m2IOhmCkJoVz4t4pC7IFWv3o+TlZ3wX2fNQVipEWj2I/ufc12Ug8neXEbaennimtWuR/sTj+95+EWx7U2mDZU4vmETilDB3oF3i83G9T6kfYgoO88hACjay1xzBOK0YPfxi7zLaRn+wwntpSTnoM0bqSKufquuSWnrI5sQdk99qo7+IHfatvQ2y5ABQpgCFZtPbsiNuv2tcgoXRcNw3jht3zERSoKZ9pWOui+8efFeRoXPsXXbJn6J0/huZ4yFxhk7a8oU871z6S1c21v7naseFlTeq5c0Igqm0hiN07+ER4fcxDngOrFSn2IRoLSIu6IKqmz48a8E48ya9cCc+saXWp7Pj2NgfqIsUWyKNX5OEsGEZ6sMir7QFdshjpUx+wp6qxvlGp55HcLjgMxElwJlHtlS2Lt4MeMdnkEwiTFJ6wReWuuaP7j5bXAQhhf6v+MW4ym8oxy2GszkNEjuMoV8EKOGe3EUM3PmjmPPfL2ee70Rb7HlCYbzetUjIOObIqnAv0VxV6LEjBL7EPMUHh9RFjswCh49bIkXzUiv6ZTgLrmXXKQkKgSy57lAda4qOsfKLacO8IJQPIqd6aSop9AFIWmDgZ0g4TFt4nHbIrT9uAwn6M+2BzN4T/eQb5tTg5cOEtaCgC+PeNrDnw8X3QnfllQXZox+gwp+nNtmEqrdTWTQa95YyYSWONfDEGFnexQ/2Tgftb+f5Kc4eRdUp48vklSuHVtZPm3oOyxlV2o8w7r3V/cTiCiVa8kOpE3Y7AFt7rhZPmTWYZhqVCtHZZFIzbaoZXRPr57CPEg7Emaqx+K4VFQR399NDPRKtKixYm3qp7eAXPqssKWPqwqyu/QogkEmoIgfUS/upnjc2BixC2TK3qny7+hyTV5hbxcmxrn5pNpOLYXHzGiri/6rTXiI53mRu7YCnaA2EhKAVjdfmZIs9hXB1+5MnDh+9/6/xFA1qC98pJlWdzDkvx+YCdwVgGbnBcbZKmu62rapeSuBQVDssy/kAkW8+A99h7ZvfjQy/GuFwgeTwRZemCSa3d0/C2jLQjwJRbsBY0MEK3hRSB6vG76CZYR86JY83vREIve+dZvshiBrGDADUXzAuzXG5CaqFKoB1brtr8Q17ZEOOFloEOQJ0Z6vf0STkovafbjqqAj4eckMgtYGxRoqmtlc/ldIFPJzFhKgvnE2/VmKQKzvFC0O/FTiGNlypdWbSkPKC3KkHZnW8p07zaeDHcipfqXNOObeLVDlaseWpEioPap3CDOKLGcFPbWqGPcSgxD1BzIeMZ3ZFSQ4T0JqQW6FFJQfvDULkcM1ITI0D7sr5N4IxCHZ81JivSsvv3uw== 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: jFOHWJ4ie+4LUx4ISqn8dRQO8aubAs9EkHNxXpeG7gkME5goFswY05ma1t0reSzmA+WwDrmXMmc01KLW6eOxpu8dWPAhgHG9srR53bjBCNUcI7kNxPtRYPnWW2Ei6cXtu/gVQARzXE/U198d3rgal9h3kAj9563Z+EakibAMMfd5wwZWt4ufWbV2zv922h5iN1loO0EDYt2MP5ozDj8TCxDBtpleG4GkULeayL6AVzObs/cM0YbHMQ5MzdVkcBv0tj6eC8Pn2LUpm+hFp+TAGvDwDacue8PWtHQoWssXtIxMPtR7peKaPaFdh9O5jaeEXuWCiMY8r8LnYThIrI2Sx1GiRaE+8YzLQrhtpNcuSGOQkCiso22Ki+xVtpWZ+fDpwWe/Rl4lyM5xD6nQqoxjB4vPeAXOF0vKHeJmFz9jBHuH37Tig9Dy2MMpes2+C+2HHvWLgNnUunPflmn+AsmXUthKsag4RXxAu7CMqFcB/0Ai5Sr7GeviVWcnzC/TcT7Rzzlau5TrzywriNbI6dR/GyRPorQs8LqzWmbAr/Cbd026W1nIW3RnTI0qnf7jTdBj2CWi24++vUxGqMgIqooJEwWBtQ1SArUHrCOnTUcfvwwYIgzdC08CLP5V4sInNVSba9ZR4Qk9Y7WnAoy+l4ofjl7prmJX3e+8HYH04Pw0j+k= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:12.3083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6aa6f251-a02d-4633-eab9-08dcf838c757 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: DB9P190MB1817 X-BESS-ID: 1730220195-304438-12707-30024-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGZsZGQGYGUNQkzSA10dw4NT k11Sg1OcUiOc3YMs0sNcUyzcTcPDHFQKk2FgBZawCGQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan10-54.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 Add possibility to use * RTE_FLOW_ITEM_TYPE_IPV6 * RTE_FLOW_ITEM_TYPE_ICMP6 Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 2 + drivers/net/ntnic/include/hw_mod_backend.h | 2 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 27 ++ .../profile_inline/flow_api_profile_inline.c | 272 ++++++++++++++++++ 4 files changed, 303 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 6691b6dce2..320d3c7e0b 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -17,7 +17,9 @@ x86-64 = Y any = Y eth = Y icmp = Y +icmp6 = Y ipv4 = Y +ipv6 = Y port_id = Y sctp = Y tcp = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index f1c57fa9fc..4f381bc0ef 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -164,6 +164,7 @@ enum { enum { PROT_L3_IPV4 = 1, + PROT_L3_IPV6 = 2 }; enum { @@ -176,6 +177,7 @@ enum { enum { PROT_TUN_L3_OTHER = 0, PROT_TUN_L3_IPV4 = 1, + PROT_TUN_L3_IPV6 = 2 }; enum { diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 6800a8d834..2aee2ee973 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -47,6 +47,33 @@ static const struct { } err_msg[] = { /* 00 */ { "Operation successfully completed" }, /* 01 */ { "Operation failed" }, + /* 02 */ { "Memory allocation failed" }, + /* 03 */ { "Too many output destinations" }, + /* 04 */ { "Too many output queues for RSS" }, + /* 05 */ { "The VLAN TPID specified is not supported" }, + /* 06 */ { "The VxLan Push header specified is not accepted" }, + /* 07 */ { "While interpreting VxLan Pop action, could not find a destination port" }, + /* 08 */ { "Failed in creating a HW-internal VTEP port" }, + /* 09 */ { "Too many VLAN tag matches" }, + /* 10 */ { "IPv6 invalid header specified" }, + /* 11 */ { "Too many tunnel ports. HW limit reached" }, + /* 12 */ { "Unknown or unsupported flow match element received" }, + /* 13 */ { "Match failed because of HW limitations" }, + /* 14 */ { "Match failed because of HW resource limitations" }, + /* 15 */ { "Match failed because of too complex element definitions" }, + /* 16 */ { "Action failed. To too many output destinations" }, + /* 17 */ { "Action Output failed, due to HW resource exhaustion" }, + /* 18 */ { "Push Tunnel Header action cannot output to multiple destination queues" }, + /* 19 */ { "Inline action HW resource exhaustion" }, + /* 20 */ { "Action retransmit/recirculate HW resource exhaustion" }, + /* 21 */ { "Flow counter HW resource exhaustion" }, + /* 22 */ { "Internal HW resource exhaustion to handle Actions" }, + /* 23 */ { "Internal HW QSL compare failed" }, + /* 24 */ { "Internal CAT CFN reuse failed" }, + /* 25 */ { "Match variations too complex" }, + /* 26 */ { "Match failed because of CAM/TCAM full" }, + /* 27 */ { "Internal creation of a tunnel end point port failed" }, + /* 28 */ { "Unknown or unsupported flow action received" }, /* 29 */ { "Removing flow failed" }, }; 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 9460325cf6..12cbfa97a8 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 @@ -538,6 +538,22 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, } break; + case RTE_FLOW_ITEM_TYPE_IPV6: { + const struct rte_flow_item_ipv6 *ipv6_spec = + (const struct rte_flow_item_ipv6 *)elem[eidx].spec; + const struct rte_flow_item_ipv6 *ipv6_mask = + (const struct rte_flow_item_ipv6 *)elem[eidx].mask; + + if (ipv6_spec != NULL && ipv6_mask != NULL) { + if (is_non_zero(&ipv6_spec->hdr.src_addr, 16)) + qw_reserved_ipv6 += 1; + + if (is_non_zero(&ipv6_spec->hdr.dst_addr, 16)) + qw_reserved_ipv6 += 1; + } + } + break; + default: break; } @@ -922,6 +938,163 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_IPV6: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_IPV6", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_ipv6 *ipv6_spec = + (const struct rte_flow_item_ipv6 *)elem[eidx].spec; + const struct rte_flow_item_ipv6 *ipv6_mask = + (const struct rte_flow_item_ipv6 *)elem[eidx].mask; + + if (ipv6_spec == NULL || ipv6_mask == NULL) { + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV6; + else + fd->l3_prot = PROT_L3_IPV6; + break; + } + + if (ipv6_mask->hdr.vtc_flow != 0 || + ipv6_mask->hdr.payload_len != 0 || + ipv6_mask->hdr.hop_limits != 0) { + NT_LOG(ERR, FILTER, + "Requested IPv6 field not support by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (is_non_zero(&ipv6_spec->hdr.src_addr, 16)) { + if (qw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + memcpy(&qw_data[0], &ipv6_spec->hdr.src_addr, 16); + memcpy(&qw_mask[0], &ipv6_mask->hdr.src_addr, 16); + + qw_data[0] = ntohl(qw_data[0]); + qw_data[1] = ntohl(qw_data[1]); + qw_data[2] = ntohl(qw_data[2]); + qw_data[3] = ntohl(qw_data[3]); + + qw_mask[0] = ntohl(qw_mask[0]); + qw_mask[1] = ntohl(qw_mask[1]); + qw_mask[2] = ntohl(qw_mask[2]); + qw_mask[3] = ntohl(qw_mask[3]); + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 8); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 8); + qw_counter += 1; + } + + if (is_non_zero(&ipv6_spec->hdr.dst_addr, 16)) { + if (qw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + memcpy(&qw_data[0], &ipv6_spec->hdr.dst_addr, 16); + memcpy(&qw_mask[0], &ipv6_mask->hdr.dst_addr, 16); + + qw_data[0] = ntohl(qw_data[0]); + qw_data[1] = ntohl(qw_data[1]); + qw_data[2] = ntohl(qw_data[2]); + qw_data[3] = ntohl(qw_data[3]); + + qw_mask[0] = ntohl(qw_mask[0]); + qw_mask[1] = ntohl(qw_mask[1]); + qw_mask[2] = ntohl(qw_mask[2]); + qw_mask[3] = ntohl(qw_mask[3]); + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 24); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 24); + qw_counter += 1; + } + + if (ipv6_mask->hdr.proto != 0) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ipv6_mask->hdr.proto << 8; + sw_data[0] = ipv6_spec->hdr.proto << 8 & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], + 1, any_count > 0 ? DYN_TUN_L3 : DYN_L3, 4); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 4); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = 0; + qw_data[1] = ipv6_mask->hdr.proto << 8; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = 0; + qw_mask[1] = ipv6_spec->hdr.proto << 8; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L3 : DYN_L3, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV6; + + else + fd->l3_prot = PROT_L3_IPV6; + } + + break; + case RTE_FLOW_ITEM_TYPE_UDP: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_UDP", dev->ndev->adapter_no, dev->port); @@ -1212,6 +1385,105 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_ICMP6: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ICMP6", + dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_icmp6 *icmp_spec = + (const struct rte_flow_item_icmp6 *)elem[eidx].spec; + const struct rte_flow_item_icmp6 *icmp_mask = + (const struct rte_flow_item_icmp6 *)elem[eidx].mask; + + if (icmp_spec == NULL || icmp_mask == NULL) { + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_ICMP; + fd->tunnel_ip_prot = 58; + key_def->inner_proto = 1; + } else { + fd->l4_prot = PROT_L4_ICMP; + fd->ip_prot = 58; + key_def->outer_proto = 1; + } + break; + } + + if (icmp_mask->checksum != 0) { + NT_LOG(ERR, FILTER, + "Requested ICMP6 field not supported by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (icmp_mask->type || icmp_mask->code) { + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = icmp_mask->type << 24 | + icmp_mask->code << 16; + sw_data[0] = icmp_spec->type << 24 | + icmp_spec->code << 16; + sw_data[0] &= sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], + 1, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = icmp_spec->type << 24 | + icmp_spec->code << 16; + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = icmp_mask->type << 24 | + icmp_mask->code << 16; + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], + 4, any_count > 0 ? DYN_TUN_L4 : DYN_L4, 0); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L4 : DYN_L4, 0); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + if (any_count > 0 || fd->l4_prot != -1) { + fd->tunnel_l4_prot = PROT_TUN_L4_ICMP; + fd->tunnel_ip_prot = 58; + key_def->inner_proto = 1; + + } else { + fd->l4_prot = PROT_L4_ICMP; + fd->ip_prot = 58; + key_def->outer_proto = 1; + } + } + + break; + case RTE_FLOW_ITEM_TYPE_TCP: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_TCP", dev->ndev->adapter_no, dev->port); From patchwork Tue Oct 29 16:41:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147629 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C4A045BC0; Tue, 29 Oct 2024 17:46:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 043D342F5F; Tue, 29 Oct 2024 17:43:45 +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 C0D4242EF1 for ; Tue, 29 Oct 2024 17:43:19 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2048.outbound.protection.outlook.com [104.47.11.48]) 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 16:43:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dPg6suLWdQS47E9gGL8icM05F4KeP0xvnGK/0jLGDwzcdO17WT7CKkc/GLIZU6ZoTJaPQHKjA7FwC3nmF/KDJCfHMpfy9EG/rqvdNalJNNUoydcTslgEHXXk9fGgeehRKRguJszjqGW1YLo08QJAX7ZkGF/VD8Y5q8HriYBJIXMKy4TTrVOF5gmlLPCyNTxUza7gUEC7XNXeMcL/rWXQszVODw0kLyTFq/vburIEsmWxYSRiGTRotgaFHJihvS7UzxV+p/1HVrqj/vJU0IBx10Gb2G7dlRwxFBFoNvtKuHZHVz6BcEqHpqPMcYej8M628lJ35J5d0E/G99o8ge1JHg== 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=EFEih29THi4eKokwkiVkQfZljDUf1jpwVOI94jwHP4k=; b=v6f0RPt9ZkyoSiakoMXhBzu4vkePh0DYCIRRUXpLvYSdoQE8KhAsloMWaFZc79iNfCkIHKAaOuFx1LzqQ8DWG0i0ZnlB6qY7Jz8wtoNUXxNzQx9iIGAC3e3cCHA0eJNCM/tcyDaLoYLwEUt3rXuaavHTmiLzlFKxvPKzjUZcIQO+3nF1wKsfK6aaI1iuzhzummv4cD8as6a5Bf1Nge116zZkiOyaC/yWFR3/NOgtQ9rCowxCVPZf8Lv3ZKyG6LU29YwhcQqZ/Lq/wdFGtYrXyWBlpUxcn0wumQthq1Ehk4PnhvRZR5qZUQbtEjm56s4VSMUGnPLaqvnTXxK4D2YMAg== 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=EFEih29THi4eKokwkiVkQfZljDUf1jpwVOI94jwHP4k=; b=VZxw1Jyv6PhITFZkpQ0Isx9CRUKqPLavwrqGS/MAqICSn/LR9APLlOobCx9OgVjXVFUzyXa+FI3xDF2Bo7+cCBXP8xS51X9DlZvHh959Kpm841iNGrc3VXywVjQ6D8OaziUtHh77ej0yl4G/qKsFo3xS5ghwMJtFV2jM1eN5DU4= Received: from DUZPR01CA0208.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::6) by AM8P190MB0916.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1da::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:43:13 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::e2) by DUZPR01CA0208.outlook.office365.com (2603:10a6:10:4b6::6) 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:43:13 +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:43:13 +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 24/86] net/ntnic: add action modify filed Date: Tue, 29 Oct 2024 17:41:28 +0100 Message-ID: <20241029164243.1648775-25-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM8P190MB0916:EE_ X-MS-Office365-Filtering-Correlation-Id: 82467c7f-4da7-4084-5bc3-08dcf838c7ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: ED0N7KMbNjeeQzFlqvTTsTGcbG4HE7KxNXDX7GFMncNNevqhiQDi4cgOG5HYdHLiNvYUaFY/ogCCP4K5xho9XNnGlSIqHyt3snHRwOICB+qQVENiy9DxnWnlCpcXw8/0NMfcn6vEUsMLT7NmLWhaHIG8lI7qeGKF7zWf//BXYh9p5vb/PkuHSuMXii6W5y8uFWDRjCcamIy4+pljufYKSBNKIiwX77bEVUGhPGh6NF1ttUyBs7yyAisaI7il6njUqbFLK8bxnhZ3hPNsO8BntnvS1RMt1lfYOnFt749Vmuuecxll4ngjPoKa00KXbY8keW6i/iX7mcIQyvjUpsl/tHlzjbbuel4Q55FTUpbOa+Vwo5C4yVYtu3IOdjLle/ZeFwqmx2DYXEQgkHDsrvQW22mzzrpjIoCX/MlWHt6wTUu26fUfylGaTAFlIgqwsKeYWZdu4Qu65A4lZIlbvK6mu5lrim5nsWgIIHWOz2wS+EUieCju8JNXg200LIM8/9auGZIVXquA0ylYtPTWTchyH9vGEFX2nuVKf25tgnDq7K3ZTD7CUWpx6aabv3awWZqTKMR8mdSubo2dDZY7/jEfggixm+v6VwREJmxdDccp3MGH32nmrRN4TBfRZ5sedhsD1fpAj7du5pq7Xz4sh8hxAOmaJXemdQ0zmB03oL+ju8ukYsjhymYXqXQk+EtXgKP+SXY7XDvGWomCZ7JO+D1YNhM2xwpuCsdwczhvAfoyxo8qooa4GKW/8xkoVSthTtPNy9rmG/b1u2KO2CgnPnm/TqGFlECKx+AB/ETtaO1R6VtPWQllFZ3tw/J21TwP90lMNO52ecoo3+8psfsEsrmZSqXzuxaWARCLKEvst0375NXiI2+GF78ZZn8rCx7Od/MPvf+6qSmlIHkL/4SHtt8qRZv+ZaTu38pa9W0DEgJUzDvo3Yk8K57wndrshBLa9HvemnM8wJypNSZ7EAWl/lZkQjjPWI0UKYEnJl6nfEMCDYr8uPqdMkn/X6wPe553dCYWjvxCns4qoeqixcx2u9x4RfV+V25eXRxZRrWom/7C6MEckHRMDUxzLKvo5uDR8XSLI7or4jN+KGqwMEdeujDKtsei86VuxzqOSd80rbiZf1CpWMzXhLqVdRUtQ6AaVr+NBu+PsxSctiMq1lXJeytMEWiIpIjtZCCrf+rk7dCI1zB28jzobk5kLeVpZ8XQ4JMkS8mAYnr9HB2xhfXCpMInWGicWiFGGSn+ZYooMe1WiI11yor2zBU+f0MFD0F1hMVYZh94HAjcdagz0boGjbEscNnEJngBIWx5Jp5BVaCN7goIP9qCJ4o2QVcmCFlJ4M2vh5Eh/4A9ZVNAQZHXQ+j9TuRuYaOJ2bfRS9U/CGCezjXTjZ2fEf2iJVSv9ZNtVXI/iKt6WNnWosrSerQvwSdhow== 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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9zsI6mbAU48KIv6H4Z29MtwP/FVNskauvlr+gwvdKRb72FXi3MvmaULOTE8kA3y9jG6UCEfS2oojethfH/sJ0YNHs28PMmMDe4ZWWj14AdtHQus5FiDsyUapQhAzpOWeOnviykPZEA8h8ieioJzOJBHCP5oxTf86svzdzkQ5TX3dUjq33+3/cGHR/yDaKtUzOGTuD2hVX8iQxPbo5K06Z6kF5g0JdBjeqeEao02O5EFwH3niTecrxlk3MNV6w4N4f958+Ccbv4P2XqWSlb713MSHMPZQYaTZ+GQkdcv5gpslzi5+6OyRb2UENNBv5KScviAk69NpNmMpOXhu8maVVOUPENfWqszqTAXqcuCjG2xkRieex05/l9CzWBH36J/kw2l/eL5C58lEicn4J4HM53eWfAiAcIpLI5UbUYxWO1/N6wdIamNhpQ95iaJ9GQEcK4PCML4mDD+7gaLbxLrG+3zage7ffed5ourjgfuN0KazxwAq24AWUULfoNd17q0jHjxNOmVEej1Lc8FY10cwyDVFi2honudEh2cWlPpbWo5uedYxa10xAOOR5F4zdDy/r5MpG7NPCjY+hUnVY3+W6T85SXbPcpZT+61+T/eaCMptNWDqKCsaOWh0YHcTGbCHEaI7wg9y1YiM68Kb3agO4Xk0j1W84m4ZuJlHwaDxh2I= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:13.0583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82467c7f-4da7-4084-5bc3-08dcf838c7ca 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: AM8P190MB0916 X-BESS-ID: 1730220197-304438-12706-30027-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.48 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhaWpkZAVgZQ0NDIzNLczNw01T LZ3MLQMtnUMsUyydjEMjXV3NLY0sRCqTYWANERcLJBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan10-180.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 From: Danylo Vodopianov Add possibility to use RTE_FLOW_ACTION_TYPE_MODIFY_FIELD Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/flow_api_engine.h | 7 + drivers/net/ntnic/include/hw_mod_backend.h | 1 + .../profile_inline/flow_api_profile_inline.c | 181 ++++++++++++++++++ 4 files changed, 190 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 320d3c7e0b..4201c8e8b9 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -30,5 +30,6 @@ vlan = Y drop = Y jump = Y mark = Y +modify_field = Y port_id = Y queue = Y diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 13fad2760a..f6557d0d20 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -129,6 +129,10 @@ struct nic_flow_def { */ struct { uint32_t select; + uint32_t dyn; + uint32_t ofs; + uint32_t len; + uint32_t level; union { uint8_t value8[16]; uint16_t value16[8]; @@ -137,6 +141,9 @@ struct nic_flow_def { } modify_field[MAX_CPY_WRITERS_SUPPORTED]; uint32_t modify_field_count; + uint8_t ttl_sub_enable; + uint8_t ttl_sub_ipv4; + uint8_t ttl_sub_outer; /* * Key Matcher flow definitions diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 4f381bc0ef..6a8a38636f 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -140,6 +140,7 @@ enum frame_offs_e { DYN_L4_PAYLOAD = 8, DYN_TUN_L3 = 13, DYN_TUN_L4 = 16, + DYN_TUN_L4_PAYLOAD = 17, }; /* Sideband info bit indicator */ 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 12cbfa97a8..1c6404b542 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 @@ -323,6 +323,8 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, { unsigned int encap_decap_order = 0; + uint64_t modify_field_use_flags = 0x0; + *num_dest_port = 0; *num_queues = 0; @@ -461,6 +463,185 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_MODIFY_FIELD", dev); + { + /* Note: This copy method will not work for FLOW_FIELD_POINTER */ + struct rte_flow_action_modify_field modify_field_tmp; + const struct rte_flow_action_modify_field *modify_field = + memcpy_mask_if(&modify_field_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_modify_field)); + + uint64_t modify_field_use_flag = 0; + + if (modify_field->src.field != RTE_FLOW_FIELD_VALUE) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only src type VALUE is supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (modify_field->dst.level > 2) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only dst level 0, 1, and 2 is supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (modify_field->dst.field == RTE_FLOW_FIELD_IPV4_TTL || + modify_field->dst.field == RTE_FLOW_FIELD_IPV6_HOPLIMIT) { + if (modify_field->operation != RTE_FLOW_MODIFY_SUB) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only operation SUB is supported for TTL/HOPLIMIT."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (fd->ttl_sub_enable) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD TTL/HOPLIMIT resource already in use."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + fd->ttl_sub_enable = 1; + fd->ttl_sub_ipv4 = + (modify_field->dst.field == RTE_FLOW_FIELD_IPV4_TTL) + ? 1 + : 0; + fd->ttl_sub_outer = (modify_field->dst.level <= 1) ? 1 : 0; + + } else { + if (modify_field->operation != RTE_FLOW_MODIFY_SET) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only operation SET is supported in general."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (fd->modify_field_count >= + dev->ndev->be.tpe.nb_cpy_writers) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD exceeded maximum of %u MODIFY_FIELD actions.", + dev->ndev->be.tpe.nb_cpy_writers); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + int mod_outer = modify_field->dst.level <= 1; + + switch (modify_field->dst.field) { + case RTE_FLOW_FIELD_IPV4_DSCP: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_DSCP_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 1; + fd->modify_field[fd->modify_field_count].len = 1; + break; + + case RTE_FLOW_FIELD_IPV6_DSCP: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_DSCP_IPV6; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 0; + /* + * len=2 is needed because + * IPv6 DSCP overlaps 2 bytes. + */ + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_GTP_PSC_QFI: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_RQI_QFI; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4_PAYLOAD + : DYN_TUN_L4_PAYLOAD; + fd->modify_field[fd->modify_field_count].ofs = 14; + fd->modify_field[fd->modify_field_count].len = 1; + break; + + case RTE_FLOW_FIELD_IPV4_SRC: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 12; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + case RTE_FLOW_FIELD_IPV4_DST: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 16; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + case RTE_FLOW_FIELD_TCP_PORT_SRC: + case RTE_FLOW_FIELD_UDP_PORT_SRC: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_PORT; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4 : DYN_TUN_L4; + fd->modify_field[fd->modify_field_count].ofs = 0; + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_TCP_PORT_DST: + case RTE_FLOW_FIELD_UDP_PORT_DST: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_PORT; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4 : DYN_TUN_L4; + fd->modify_field[fd->modify_field_count].ofs = 2; + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_GTP_TEID: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_TEID; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4_PAYLOAD + : DYN_TUN_L4_PAYLOAD; + fd->modify_field[fd->modify_field_count].ofs = 4; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + default: + NT_LOG(ERR, FILTER, + "MODIFY_FIELD dst type is not supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + modify_field_use_flag = 1 + << fd->modify_field[fd->modify_field_count].select; + + if (modify_field_use_flag & modify_field_use_flags) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD dst type hardware resource already used."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + memcpy(fd->modify_field[fd->modify_field_count].value8, + modify_field->src.value, 16); + + fd->modify_field[fd->modify_field_count].level = + modify_field->dst.level; + + modify_field_use_flags |= modify_field_use_flag; + fd->modify_field_count += 1; + } + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); From patchwork Tue Oct 29 16:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147630 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 121D145BC0; Tue, 29 Oct 2024 17:46:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 045D442F6B; Tue, 29 Oct 2024 17:43:46 +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 2224F42EF1 for ; Tue, 29 Oct 2024 17:43:20 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2105.outbound.protection.outlook.com [104.47.18.105]) 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 16:43:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F6hjPG852ZSUqcgpa+TRCPxkMw270r7T5ZFmkfOywL0lXyeQWPFnU+7z8w6ezsn7KUI3w+zh/R+kLiglyhgeXgeNVTy826VHZdTRHMLEW/x521GBiOXh34Nv1ju+TWF5zbOwxECnEDX/ZJGW2ZoYtlS42yLeTy7xht8j5/EZ0M+dZzqxAR6SB1tg1hbcj3AKL7/ofVIPP+KSIBwTul2XqyGgzbB3vZKPYOk+5w6axXp5w0TUqxGDOpXVHBP+PtzLgT+l6bzX1IKliscbABaleSFXWWxPK4kXAbcjxyKYYE64Qd5QIBudLaxVmDDi1061XOb/2BVTHV8F6keGjkOa9Q== 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=N7m7lv60Eou0WdRFUbfvtqhK3cJ+jE3fWWL1h8fW0Qc=; b=MCTXfGC1wC9g0VpSaBGlF/Ol/EduMUqlnodFhaXyhcRe3Wct70ddKDybs9dHEahCmkkI4YIjK1+kxGRxVe58U0lxLyjQJpNJ+GEU66iqraSKQwmloKOM9vQ00grGG6dwzKeqAZCQ67scZDeKafAWPnZodIfCMrle/kQtxRvcuSe5GGDcQBWntT6Q08BWgCMXERwwLFXKUSSINvyd4sIxUXup2ftRUhnk23YV8z8185zmn/iTDr4XePoxMnUAgDkpENjI61Ib9PTSjMXA3U1oYHyQeJ1C+B4rU5h5GbS+NND9awRmAJHqJkwfzzxCojTG+dd7RJcrA4jBRruPZgKwlQ== 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=N7m7lv60Eou0WdRFUbfvtqhK3cJ+jE3fWWL1h8fW0Qc=; b=poA4fWTG/LjRx8EKFo6aeU3aOIKv61GqWGLM/gNJ9Ii3XP3hG8V+Od17bUsF04BeaTgN7EAzIG1ZDFnFH7uhizU00agat6ZTgahtOqSyIVjgs56DUf1p/w3wwmH4qWzi55X7ADr1QNEdLGDHipmgauzq26oEyuhqYkenRp886wg= Received: from DUZPR01CA0192.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::15) by PRAP190MB1785.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:29e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Tue, 29 Oct 2024 16:43:14 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::1e) by DUZPR01CA0192.outlook.office365.com (2603:10a6:10:4b6::15) 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:43:14 +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:43:13 +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 25/86] net/ntnic: add items gtp and actions raw encap/decap Date: Tue, 29 Oct 2024 17:41:29 +0100 Message-ID: <20241029164243.1648775-26-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PRAP190MB1785:EE_ X-MS-Office365-Filtering-Correlation-Id: eebb5a7f-9531-48db-066a-08dcf838c857 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: vgsd+D2AqOM2Tb3neyIzUcBdD1jjB84l7/yrksrnn0LQNHVQKiCCJLPvVfRg5DAm6ocf14kZmlY6xLlaL93fkq0Rq/Y80XZPQPXIC2x+6daDrYHqHgn+V16h2FF8ILEQN8zuRoMMr4XhBNNLrRRFZ7zZlJrhBPMQ1aNqrBwvJwT9TRRyBRnJD+ablcUFxeihJVPUbuTcRjjrEWrOSF6uVHnbkogkPjjbnWZtVYswr28K0V7293mOYOWwNbcnj2in/t2q+Bz0lRCkYdVU0tulVeCnSDtoc5/92uWiabx4noANRSBAzzfg51QauigipmBuWmBvdEwaXKme11EfTJivhGkttRNKoR0gBvNjtlCXSXduvTIAyQE+LGvOdPz+guq1l3JG/2nyszblXNnur2r95IWzwraFllg6whsX9sa43vDq88v8RBE36JR4sjp8kST5goQGTRQvYEWJ3NVS2bpAgh0iim/LAA+WPs0E+C4Ha/CjshXFbUv8BjJ4fSnVijNFNnpwJA+CBXnfrkFak6a9GGdY4yOX2bB11ao2lQgAo9ET+C7+LfwLrtUEnq3/53S1Ue6sPa2AopGWHoqASKyRz1NdwUzQdps11d9Qg8Uu+9yYxszYBMkW13OTl2LpIDoffRXMJ/JA31p0iMPw2ZXLbJCEwZUUfVnSu55aq1hCE1vGEs1wlHgWYmAmmdlwti1g6TdSTn/iCTt+aMP1HTtR6I2rockPRaOkG9JUPNQ5RNss6r3eaNSsX/GT5T8FBXv2i+hbunSOi6LkZFCwR2zlDx8IqIqltyKhBgERH9izY7J3b3DE9YejCeaFZTR8UrsCGs2oKRaj6bQ2wZmwiXuN6WsmlP8fFVR9Yrn241eJqADV70/aRWakOatxSIQYDNDYzFjY4y55h8WLmDDDEfL5mvbizf4jL/bzG5+4yC8R2eGmDLSFUzUQC8uINp4qZ2iE/nTIzvCAPG2LBzrFcq2+5ZYtHJf04ROdit/phhhHuijgj8M627geHveqKUXzwGDu6/u/gzdIGuEBIZFaEwQRwTAyVlRfZPEfSOQ5jDfrJfM+fSBR/k6rO1KMem75VibDWKMUIRa4FbuSWDTOUW4VmqlV3ou997bqrpGshr6KCQ8cCtvh985ZMH73DQ8MEQqu/5e7byNSIeBEW6ImuZvWIB4yFiqQezwgRqkxdt4fK+ijI/Pt0HTtThmg8jcM/CS86r9sVVDxxDJga+JkmztkGpaB+hAcsWo+CZVLSH0PrHx6LNilqwg/U92lRmRDpas4U9vpvqkGa+aN3FLA8BePIISh8YATbKsFgVCw0vcNPY1eak981Als320QIye0nYPM54eUrD0T22cnoYZGsTrNL8eK6ySyqg/jgwyzRdV47eHyxLG6fpM6JOJVzpGW3yAKx+SjW+AZBrsbsqvZ5pjRGw== 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)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PSD/XU20W7vhmNciS8S3QnmpyEY/Zd2SU1eUfsYpZ6jRmJ1013TM/vq2FPn+c+20GKLhwDnCnGORWDPjGxQVycx1iiLUIILP2lYYJabstIXunaRbQDbi8le5U5vdgglGK9K/Ch+XVROXHZXUhwBSTvNeJHP8j5F614R+A2VeI7yKnIKk0WdCIXxVWDFX/4WDLsfLa/Bo43UllJ0dH/3k9qeR267iBnU/vm058q7sv86lU/U8pVEXSPlkwf5qzwIKTz79xD2fMfePmAZVXlTNkD9LTiifdutI5lNUny6f/7eKufIkeBWgkhY/UKHjkI5T8+NKQbHUcSuDJAOiB7/MM0WoHkyNP1AVmIAJO01lw9St8/3B3YWg5tM0kU/x3gg+ytMVmbnBBuATz1nGImqy0pKm3nfCzg4iMqX7KoONFzDoJjzJi8YRMBUFIDI0qQlzH3a7MCU+lwdnJrezLaaY+BeKJY5s6TnWPs/NjvfcABqWOmQ7+BVg66kHKktjJUT1EzYY/h5lv41hZvcS0mNSDLXHVkmJtEWc0asiJy+hCYdpiWPIOhrD8YaTY04rEFYQu4ZXFqh+iW/LglhIiyo64SPc2G5WUZY9wj71qa6/vnr/kU6fMQYbyHgAlL2dDmhEbF+RXHXnbBQVjQR6Jj1UUHFQjeHe/X4b2S1UCIP4PSg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:13.9802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eebb5a7f-9531-48db-066a-08dcf838c857 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: PRAP190MB1785 X-BESS-ID: 1730220196-304438-12708-29941-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYmJkYWQGYGUDQpKdUiOdXE0N jC0jI51TzNOCnNzNjU3Mzc0CTRKDnJSKk2FgAqNcqBQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-5.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 From: Danylo Vodopianov Add possibility to use * RTE_FLOW_ITEM_TYPE_GTP * RTE_FLOW_ITEM_TYPE_GTP_PSC * RTE_FLOW_ACTION_TYPE_RAW_ENCAP * RTE_FLOW_ACTION_TYPE_RAW_DECAP Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 4 + drivers/net/ntnic/include/create_elements.h | 4 + drivers/net/ntnic/include/flow_api_engine.h | 40 ++ drivers/net/ntnic/include/hw_mod_backend.h | 4 + .../ntnic/include/stream_binary_flow_api.h | 22 ++ .../profile_inline/flow_api_profile_inline.c | 366 +++++++++++++++++- drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 291 +++++++++++++- 7 files changed, 726 insertions(+), 5 deletions(-) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 4201c8e8b9..4cb9509742 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -16,6 +16,8 @@ x86-64 = Y [rte_flow items] any = Y eth = Y +gtp = Y +gtp_psc = Y icmp = Y icmp6 = Y ipv4 = Y @@ -33,3 +35,5 @@ mark = Y modify_field = Y port_id = Y queue = Y +raw_decap = Y +raw_encap = Y diff --git a/drivers/net/ntnic/include/create_elements.h b/drivers/net/ntnic/include/create_elements.h index 179542d2b2..70e6cad195 100644 --- a/drivers/net/ntnic/include/create_elements.h +++ b/drivers/net/ntnic/include/create_elements.h @@ -27,6 +27,8 @@ struct cnv_attr_s { struct cnv_action_s { struct rte_flow_action flow_actions[MAX_ACTIONS]; + struct flow_action_raw_encap encap; + struct flow_action_raw_decap decap; struct rte_flow_action_queue queue; }; @@ -52,6 +54,8 @@ enum nt_rte_flow_item_type { }; extern rte_spinlock_t flow_lock; + +int interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct rte_flow_item *out); int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error); int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr); int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[], diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index f6557d0d20..b1d39b919b 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -56,6 +56,29 @@ enum res_type_e { #define MAX_MATCH_FIELDS 16 +/* + * Tunnel encapsulation header definition + */ +#define MAX_TUN_HDR_SIZE 128 +struct tunnel_header_s { + union { + uint8_t hdr8[MAX_TUN_HDR_SIZE]; + uint32_t hdr32[(MAX_TUN_HDR_SIZE + 3) / 4]; + } d; + uint32_t user_port_id; + uint8_t len; + + uint8_t nb_vlans; + + uint8_t ip_version; /* 4: v4, 6: v6 */ + uint16_t ip_csum_precalc; + + uint8_t new_outer; + uint8_t l2_len; + uint8_t l3_len; + uint8_t l4_len; +}; + struct match_elem_s { int masked_for_tcam; /* if potentially selected for TCAM */ uint32_t e_word[4]; @@ -124,6 +147,23 @@ struct nic_flow_def { int full_offload; + /* + * Action push tunnel + */ + struct tunnel_header_s tun_hdr; + + /* + * If DPDK RTE tunnel helper API used + * this holds the tunnel if used in flow + */ + struct tunnel_s *tnl; + + /* + * Header Stripper + */ + int header_strip_end_dyn; + int header_strip_end_ofs; + /* * Modify field */ diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 6a8a38636f..1b45ea4296 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -175,6 +175,10 @@ enum { PROT_L4_ICMP = 4 }; +enum { + PROT_TUN_GTPV1U = 6, +}; + enum { PROT_TUN_L3_OTHER = 0, PROT_TUN_L3_IPV4 = 1, diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h index d878b848c2..8097518d61 100644 --- a/drivers/net/ntnic/include/stream_binary_flow_api.h +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -18,6 +18,7 @@ #define FLOW_MAX_QUEUES 128 +#define RAW_ENCAP_DECAP_ELEMS_MAX 16 /* * Flow eth dev profile determines how the FPGA module resources are * managed and what features are available @@ -31,6 +32,27 @@ struct flow_queue_id_s { int hw_id; }; +/* + * RTE_FLOW_ACTION_TYPE_RAW_ENCAP + */ +struct flow_action_raw_encap { + uint8_t *data; + uint8_t *preserve; + size_t size; + struct rte_flow_item items[RAW_ENCAP_DECAP_ELEMS_MAX]; + int item_count; +}; + +/* + * RTE_FLOW_ACTION_TYPE_RAW_DECAP + */ +struct flow_action_raw_decap { + uint8_t *data; + size_t size; + struct rte_flow_item items[RAW_ENCAP_DECAP_ELEMS_MAX]; + int item_count; +}; + struct flow_eth_dev; /* port device */ struct flow_handle; 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 1c6404b542..07a2a12cc9 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 @@ -463,6 +463,202 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_RAW_ENCAP", dev); + + if (action[aidx].conf) { + const struct flow_action_raw_encap *encap = + (const struct flow_action_raw_encap *)action[aidx].conf; + const struct flow_action_raw_encap *encap_mask = action_mask + ? (const struct flow_action_raw_encap *)action_mask[aidx] + .conf + : NULL; + const struct rte_flow_item *items = encap->items; + + if (encap_decap_order != 1) { + NT_LOG(ERR, FILTER, + "ERROR: - RAW_ENCAP must follow RAW_DECAP."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (encap->size == 0 || encap->size > 255 || + encap->item_count < 2) { + NT_LOG(ERR, FILTER, + "ERROR: - RAW_ENCAP data/size invalid."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + encap_decap_order = 2; + + fd->tun_hdr.len = (uint8_t)encap->size; + + if (encap_mask) { + memcpy_mask_if(fd->tun_hdr.d.hdr8, encap->data, + encap_mask->data, fd->tun_hdr.len); + + } else { + memcpy(fd->tun_hdr.d.hdr8, encap->data, fd->tun_hdr.len); + } + + while (items->type != RTE_FLOW_ITEM_TYPE_END) { + switch (items->type) { + case RTE_FLOW_ITEM_TYPE_ETH: + fd->tun_hdr.l2_len = 14; + break; + + case RTE_FLOW_ITEM_TYPE_VLAN: + fd->tun_hdr.nb_vlans += 1; + fd->tun_hdr.l2_len += 4; + break; + + case RTE_FLOW_ITEM_TYPE_IPV4: + fd->tun_hdr.ip_version = 4; + fd->tun_hdr.l3_len = sizeof(struct rte_ipv4_hdr); + fd->tun_hdr.new_outer = 1; + + /* Patch length */ + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + 2] = 0x07; + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + 3] = 0xfd; + break; + + case RTE_FLOW_ITEM_TYPE_IPV6: + fd->tun_hdr.ip_version = 6; + fd->tun_hdr.l3_len = sizeof(struct rte_ipv6_hdr); + fd->tun_hdr.new_outer = 1; + + /* Patch length */ + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + 4] = 0x07; + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + 5] = 0xfd; + break; + + case RTE_FLOW_ITEM_TYPE_SCTP: + fd->tun_hdr.l4_len = sizeof(struct rte_sctp_hdr); + break; + + case RTE_FLOW_ITEM_TYPE_TCP: + fd->tun_hdr.l4_len = sizeof(struct rte_tcp_hdr); + break; + + case RTE_FLOW_ITEM_TYPE_UDP: + fd->tun_hdr.l4_len = sizeof(struct rte_udp_hdr); + + /* Patch length */ + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + + fd->tun_hdr.l3_len + 4] = 0x07; + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + + fd->tun_hdr.l3_len + 5] = 0xfd; + break; + + case RTE_FLOW_ITEM_TYPE_ICMP: + fd->tun_hdr.l4_len = sizeof(struct rte_icmp_hdr); + break; + + case RTE_FLOW_ITEM_TYPE_ICMP6: + fd->tun_hdr.l4_len = + sizeof(struct rte_flow_item_icmp6); + break; + + case RTE_FLOW_ITEM_TYPE_GTP: + /* Patch length */ + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + + fd->tun_hdr.l3_len + + fd->tun_hdr.l4_len + 2] = 0x07; + fd->tun_hdr.d.hdr8[fd->tun_hdr.l2_len + + fd->tun_hdr.l3_len + + fd->tun_hdr.l4_len + 3] = 0xfd; + break; + + default: + break; + } + + items++; + } + + if (fd->tun_hdr.nb_vlans > 3) { + NT_LOG(ERR, FILTER, + "ERROR: - Encapsulation with %d vlans not supported.", + (int)fd->tun_hdr.nb_vlans); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + /* Convert encap data to 128-bit little endian */ + for (size_t i = 0; i < (encap->size + 15) / 16; ++i) { + uint8_t *data = fd->tun_hdr.d.hdr8 + i * 16; + + for (unsigned int j = 0; j < 8; ++j) { + uint8_t t = data[j]; + data[j] = data[15 - j]; + data[15 - j] = t; + } + } + } + + break; + + case RTE_FLOW_ACTION_TYPE_RAW_DECAP: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_RAW_DECAP", dev); + + if (action[aidx].conf) { + /* Mask is N/A for RAW_DECAP */ + const struct flow_action_raw_decap *decap = + (const struct flow_action_raw_decap *)action[aidx].conf; + + if (encap_decap_order != 0) { + NT_LOG(ERR, FILTER, + "ERROR: - RAW_ENCAP must follow RAW_DECAP."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (decap->item_count < 2) { + NT_LOG(ERR, FILTER, + "ERROR: - RAW_DECAP must decap something."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + encap_decap_order = 1; + + switch (decap->items[decap->item_count - 2].type) { + case RTE_FLOW_ITEM_TYPE_ETH: + case RTE_FLOW_ITEM_TYPE_VLAN: + fd->header_strip_end_dyn = DYN_L3; + fd->header_strip_end_ofs = 0; + break; + + case RTE_FLOW_ITEM_TYPE_IPV4: + case RTE_FLOW_ITEM_TYPE_IPV6: + fd->header_strip_end_dyn = DYN_L4; + fd->header_strip_end_ofs = 0; + break; + + case RTE_FLOW_ITEM_TYPE_SCTP: + case RTE_FLOW_ITEM_TYPE_TCP: + case RTE_FLOW_ITEM_TYPE_UDP: + case RTE_FLOW_ITEM_TYPE_ICMP: + case RTE_FLOW_ITEM_TYPE_ICMP6: + fd->header_strip_end_dyn = DYN_L4_PAYLOAD; + fd->header_strip_end_ofs = 0; + break; + + case RTE_FLOW_ITEM_TYPE_GTP: + fd->header_strip_end_dyn = DYN_TUN_L3; + fd->header_strip_end_ofs = 0; + break; + + default: + fd->header_strip_end_dyn = DYN_L2; + fd->header_strip_end_ofs = 0; + break; + } + } + + break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_MODIFY_FIELD", dev); { @@ -1765,6 +1961,174 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_GTP: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_GTP", + dev->ndev->adapter_no, dev->port); + { + const struct rte_gtp_hdr *gtp_spec = + (const struct rte_gtp_hdr *)elem[eidx].spec; + const struct rte_gtp_hdr *gtp_mask = + (const struct rte_gtp_hdr *)elem[eidx].mask; + + if (gtp_spec == NULL || gtp_mask == NULL) { + fd->tunnel_prot = PROT_TUN_GTPV1U; + break; + } + + if (gtp_mask->gtp_hdr_info != 0 || + gtp_mask->msg_type != 0 || gtp_mask->plen != 0) { + NT_LOG(ERR, FILTER, + "Requested GTP field not support by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (gtp_mask->teid) { + if (sw_counter < 2) { + uint32_t *sw_data = + &packet_data[1 - sw_counter]; + uint32_t *sw_mask = + &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(gtp_mask->teid); + sw_data[0] = + ntohl(gtp_spec->teid) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], + &sw_mask[0], 1, + DYN_L4_PAYLOAD, 4); + set_key_def_sw(key_def, sw_counter, + DYN_L4_PAYLOAD, 4); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - + qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - + qw_counter * 4]; + + qw_data[0] = ntohl(gtp_spec->teid); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = ntohl(gtp_mask->teid); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], + &qw_mask[0], 4, + DYN_L4_PAYLOAD, 4); + set_key_def_qw(key_def, qw_counter, + DYN_L4_PAYLOAD, 4); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + fd->tunnel_prot = PROT_TUN_GTPV1U; + } + + break; + + case RTE_FLOW_ITEM_TYPE_GTP_PSC: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_GTP_PSC", + dev->ndev->adapter_no, dev->port); + { + const struct rte_gtp_psc_generic_hdr *gtp_psc_spec = + (const struct rte_gtp_psc_generic_hdr *)elem[eidx].spec; + const struct rte_gtp_psc_generic_hdr *gtp_psc_mask = + (const struct rte_gtp_psc_generic_hdr *)elem[eidx].mask; + + if (gtp_psc_spec == NULL || gtp_psc_mask == NULL) { + fd->tunnel_prot = PROT_TUN_GTPV1U; + break; + } + + if (gtp_psc_mask->type != 0 || + gtp_psc_mask->ext_hdr_len != 0) { + NT_LOG(ERR, FILTER, + "Requested GTP PSC field is not supported by running SW version"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (gtp_psc_mask->qfi) { + if (sw_counter < 2) { + uint32_t *sw_data = + &packet_data[1 - sw_counter]; + uint32_t *sw_mask = + &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(gtp_psc_mask->qfi); + sw_data[0] = ntohl(gtp_psc_spec->qfi) & + sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], + &sw_mask[0], 1, + DYN_L4_PAYLOAD, 14); + set_key_def_sw(key_def, sw_counter, + DYN_L4_PAYLOAD, 14); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = + &packet_data[2 + 4 - + qw_counter * 4]; + uint32_t *qw_mask = + &packet_mask[2 + 4 - + qw_counter * 4]; + + qw_data[0] = ntohl(gtp_psc_spec->qfi); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = ntohl(gtp_psc_mask->qfi); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], + &qw_mask[0], 4, + DYN_L4_PAYLOAD, 14); + set_key_def_qw(key_def, qw_counter, + DYN_L4_PAYLOAD, 14); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + } + + fd->tunnel_prot = PROT_TUN_GTPV1U; + } + + break; + case RTE_FLOW_ITEM_TYPE_PORT_ID: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_PORT_ID", dev->ndev->adapter_no, dev->port); @@ -1928,7 +2292,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, uint32_t num_dest_port __rte_unused, uint32_t num_queues __rte_unused, - uint32_t *packet_data __rte_unused, uint32_t *packet_mask __rte_unused, + uint32_t *packet_data, uint32_t *packet_mask __rte_unused, struct flm_flow_key_def_s *key_def __rte_unused) { struct flow_handle *fh = calloc(1, sizeof(struct flow_handle)); diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index b9d723c9dd..20b5cb2835 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -16,6 +16,224 @@ rte_spinlock_t flow_lock = RTE_SPINLOCK_INITIALIZER; static struct rte_flow nt_flows[MAX_RTE_FLOWS]; +int interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct rte_flow_item *out) +{ + int hdri = 0; + int pkti = 0; + + /* Ethernet */ + if (size - pkti == 0) + goto interpret_end; + + if (size - pkti < (int)sizeof(struct rte_ether_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_ETH; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + rte_be16_t ether_type = ((struct rte_ether_hdr *)&data[pkti])->ether_type; + + hdri += 1; + pkti += sizeof(struct rte_ether_hdr); + + if (size - pkti == 0) + goto interpret_end; + + /* VLAN */ + while (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) || + ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ) || + ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ1)) { + if (size - pkti == 0) + goto interpret_end; + + if (size - pkti < (int)sizeof(struct rte_vlan_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_VLAN; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + ether_type = ((struct rte_vlan_hdr *)&data[pkti])->eth_proto; + + hdri += 1; + pkti += sizeof(struct rte_vlan_hdr); + } + + if (size - pkti == 0) + goto interpret_end; + + /* Layer 3 */ + uint8_t next_header = 0; + + if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4) && (data[pkti] & 0xF0) == 0x40) { + if (size - pkti < (int)sizeof(struct rte_ipv4_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_IPV4; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + next_header = data[pkti + 9]; + + hdri += 1; + pkti += sizeof(struct rte_ipv4_hdr); + + } else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6) && + (data[pkti] & 0xF0) == 0x60) { + if (size - pkti < (int)sizeof(struct rte_ipv6_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_IPV6; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + next_header = data[pkti + 6]; + + hdri += 1; + pkti += sizeof(struct rte_ipv6_hdr); + } else { + return -1; + } + + if (size - pkti == 0) + goto interpret_end; + + /* Layer 4 */ + int gtpu_encap = 0; + + if (next_header == 1) { /* ICMP */ + if (size - pkti < (int)sizeof(struct rte_icmp_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_ICMP; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + hdri += 1; + pkti += sizeof(struct rte_icmp_hdr); + + } else if (next_header == 58) { /* ICMP6 */ + if (size - pkti < (int)sizeof(struct rte_flow_item_icmp6)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_ICMP6; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + hdri += 1; + pkti += sizeof(struct rte_icmp_hdr); + + } else if (next_header == 6) { /* TCP */ + if (size - pkti < (int)sizeof(struct rte_tcp_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_TCP; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + hdri += 1; + pkti += sizeof(struct rte_tcp_hdr); + + } else if (next_header == 17) { /* UDP */ + if (size - pkti < (int)sizeof(struct rte_udp_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_UDP; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + gtpu_encap = ((struct rte_udp_hdr *)&data[pkti])->dst_port == + rte_cpu_to_be_16(RTE_GTPU_UDP_PORT); + + hdri += 1; + pkti += sizeof(struct rte_udp_hdr); + + } else if (next_header == 132) {/* SCTP */ + if (size - pkti < (int)sizeof(struct rte_sctp_hdr)) + return -1; + + out[hdri].type = RTE_FLOW_ITEM_TYPE_SCTP; + out[hdri].spec = &data[pkti]; + out[hdri].mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + hdri += 1; + pkti += sizeof(struct rte_sctp_hdr); + + } else { + return -1; + } + + if (size - pkti == 0) + goto interpret_end; + + /* GTPv1-U */ + if (gtpu_encap) { + if (size - pkti < (int)sizeof(struct rte_gtp_hdr)) + return -1; + + out[hdri] + .type = RTE_FLOW_ITEM_TYPE_GTP; + out[hdri] + .spec = &data[pkti]; + out[hdri] + .mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + int extension_present_bit = ((struct rte_gtp_hdr *)&data[pkti]) + ->e; + + hdri += 1; + pkti += sizeof(struct rte_gtp_hdr); + + if (extension_present_bit) { + if (size - pkti < (int)sizeof(struct rte_gtp_hdr_ext_word)) + return -1; + + out[hdri] + .type = RTE_FLOW_ITEM_TYPE_GTP; + out[hdri] + .spec = &data[pkti]; + out[hdri] + .mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + uint8_t next_ext = ((struct rte_gtp_hdr_ext_word *)&data[pkti]) + ->next_ext; + + hdri += 1; + pkti += sizeof(struct rte_gtp_hdr_ext_word); + + while (next_ext) { + size_t ext_len = data[pkti] * 4; + + if (size - pkti < (int)ext_len) + return -1; + + out[hdri] + .type = RTE_FLOW_ITEM_TYPE_GTP; + out[hdri] + .spec = &data[pkti]; + out[hdri] + .mask = (preserve != NULL) ? &preserve[pkti] : NULL; + + next_ext = data[pkti + ext_len - 1]; + + hdri += 1; + pkti += ext_len; + } + } + } + + if (size - pkti != 0) + return -1; + +interpret_end: + out[hdri].type = RTE_FLOW_ITEM_TYPE_END; + out[hdri].spec = NULL; + out[hdri].mask = NULL; + + return hdri + 1; +} + int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error) { if (error) { @@ -95,13 +313,78 @@ int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item return (type >= 0) ? 0 : -1; } -int create_action_elements_inline(struct cnv_action_s *action __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - int max_elem __rte_unused, - uint32_t queue_offset __rte_unused) +int create_action_elements_inline(struct cnv_action_s *action, + const struct rte_flow_action actions[], + int max_elem, + uint32_t queue_offset) { + int aidx = 0; int type = -1; + do { + type = actions[aidx].type; + if (type >= 0) { + action->flow_actions[aidx].type = type; + + /* + * Non-compatible actions handled here + */ + switch (type) { + case RTE_FLOW_ACTION_TYPE_RAW_DECAP: { + const struct rte_flow_action_raw_decap *decap = + (const struct rte_flow_action_raw_decap *)actions[aidx] + .conf; + int item_count = interpret_raw_data(decap->data, NULL, decap->size, + action->decap.items); + + if (item_count < 0) + return item_count; + action->decap.data = decap->data; + action->decap.size = decap->size; + action->decap.item_count = item_count; + action->flow_actions[aidx].conf = &action->decap; + } + break; + + case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: { + const struct rte_flow_action_raw_encap *encap = + (const struct rte_flow_action_raw_encap *)actions[aidx] + .conf; + int item_count = interpret_raw_data(encap->data, encap->preserve, + encap->size, action->encap.items); + + if (item_count < 0) + return item_count; + action->encap.data = encap->data; + action->encap.preserve = encap->preserve; + action->encap.size = encap->size; + action->encap.item_count = item_count; + action->flow_actions[aidx].conf = &action->encap; + } + break; + + case RTE_FLOW_ACTION_TYPE_QUEUE: { + const struct rte_flow_action_queue *queue = + (const struct rte_flow_action_queue *)actions[aidx].conf; + action->queue.index = queue->index + queue_offset; + action->flow_actions[aidx].conf = &action->queue; + } + break; + + default: { + action->flow_actions[aidx].conf = actions[aidx].conf; + } + break; + } + + aidx++; + + if (aidx == max_elem) + return -1; + } + + } while (type >= 0 && type != RTE_FLOW_ITEM_TYPE_END); + return (type >= 0) ? 0 : -1; } From patchwork Tue Oct 29 16:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147633 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4400845BC0; Tue, 29 Oct 2024 17:46:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 581AD42F03; Tue, 29 Oct 2024 17:44:13 +0100 (CET) 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 72B8042EBE for ; Tue, 29 Oct 2024 17:43:25 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xSHi+8jK/1MhIY1eAZn1nt674rYPRe+9OWJw9Gc1sCFavdkPw1++uviYCRGYEJhtkAxcRStWxHUEJYT5Hn3rhuXq99vSEQbOgYpur7gyXcF+JL5HYEyyckj+OrpsT/QXdj7SpKrX5R46yO8wv6EWL5YNUJ5IGxb74DFD4vk1wUk5I6RJiNec4GGjryPnghJl78yWbzTTGjiAQRUew4xcgoO1i+hDJG+aoTVuWxQQj4jX5L5lhe3+m9A/C0jtqyigvOjYArRYCCXiGKFX/pWh7qmZXBD5Oc3tlzYDEKLz/jupbW7tTQI+kOycT4tbVpRZiIBMSjiUH6bql8MTZrKj1A== 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=h/MFBPuhtGB+XBuQsjK//UAGqPvUeQ9h/wc+MkwqN0I=; b=HjtE6WLJBzkwd5M+2C4FNUjJl2ITXAjvKEdDP3Kqv0WcN68yBslmfGzMiN3G433qVkXtUi/cTDwnXaqIVnzJismScEodEM3FjdgAFIdtNWWb9r2ISvqUmQRoiF3kRVEpJgxf/6orCSocGW8TNWgg1BK7J5P4TETloaADqpR1KBqCuYRrZM12xcOCe5pejJlfMrJMHpVLWXA2bJUAuR4JekEuvIMhXKaa1SDAXGvsE4eefEGRouqGKJ0EPp8hgx12D84mTX3m4A5Tzncet6ua9qqdL5Qqx5QSWQhkRdpT8rIfxdgXqubCsgjhDhLz+gVDFfy9cShRhssr26+jUcxIkw== 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=h/MFBPuhtGB+XBuQsjK//UAGqPvUeQ9h/wc+MkwqN0I=; b=QkEwA6B3nxKBrljaxZlsNdRp8ulfPTrVBTcJGps2n9Vx2Gcg/MouVtkLh9FHS70dbCCbhlN7/6O0nVirDCtFOEkswOKg6TxoodM064wZxf3qW9GTsA0BICTJxXwdgwRXjkBeD0s2Zm547NEzdllP/sewWlXf+YVBDhgWeOYJA1o= Received: from DUZPR01CA0198.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::29) by GVXP190MB2231.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:218::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:15 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::68) by DUZPR01CA0198.outlook.office365.com (2603:10a6:10:4b6::29) 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:43:15 +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:43:14 +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 26/86] net/ntnic: add cat module Date: Tue, 29 Oct 2024 17:41:30 +0100 Message-ID: <20241029164243.1648775-27-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|GVXP190MB2231:EE_ X-MS-Office365-Filtering-Correlation-Id: 5eeecfb4-54e0-4640-8a55-08dcf838c8dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?G68xrMTXjbDcNb9tA2wvR0xHyaxJxZT?= =?utf-8?q?ypFU6Zz4y5zBTQwrH1MQ9+S+6/xOshKnpSESKvoNxC+fgKgVNDRcf/gvH7ZvZdsx1?= =?utf-8?q?NBfluvxvjgClVgOHPzO3lKpAyj+Nx8sA+ZgMLIWYW40o7Yf2zQUyUG+G+K+2AIUcB?= =?utf-8?q?3sgvr5hvTRI9wzUXdn9wQnXwbc6oojZTphNekLJm7BC80gVP5G0LjOvGhKmhqltPW?= =?utf-8?q?xKipf+1CJ8eJR4Q09LqoW8La+SBCYuDdyisHNLWM2qxV8ByItFVTgqbnH8O3UDmw3?= =?utf-8?q?mll8Qx97GCNM7lfST6mcle4QI9WxBpr+ZW8jwxeC2WzO2gezJW9ZTW5QldpiwGxXb?= =?utf-8?q?IBTBiTVeaqrTS+fFvOfa4vhpUjbwmyNvFNpacLdfg2cg0LJmUpt+gB8UTElTlJg6H?= =?utf-8?q?Kbz73o9LC0B9BrcrCpDwFl8ENnWl12gWXBhbmQ5SWHSFrvCma/J3zeyIvjuvax3Dh?= =?utf-8?q?R324P+rBssrew4rX/EDdJhlVilrYgWyARzOa9FevuA/OG7Tosd3+EpkNvm8fd9dpf?= =?utf-8?q?oNpj7ckfw/Cj8rz+V+0qWDzpzJLcCRycfr/0dojfhHer3Kew/d5/9EEzlcP3YO/+Z?= =?utf-8?q?VahlSfPE8yLLY/QO8lnMwwmUKUR2MVjFNZOH4bfUOFosxelrus11/Hqn0Eliu6BBv?= =?utf-8?q?8iRw53XgPuPxPYXfAB8gbryJyOMP/r56fsSGFkNQUEd3TYcyQ5BVYaQlnww/BE4L7?= =?utf-8?q?DvYe5EFoe68CAR0HKsuiDYFkjvwZPuWOIvVywtT5b2ZjSmHD2I7Vi8R0KmGPs1KLF?= =?utf-8?q?PvxPULWNrs08GJp9EE4Q2PM+JBYp9jyykZrHCKg9Za4vWuW98Jp3taVgB4j8pzQHk?= =?utf-8?q?N7pMAb1w6hdJVAsE/uvaOIY3+Xsu8tPXDN+DtIRQ+uY1Xv/Hrc0Ekr+WsB4foX/32?= =?utf-8?q?AouOuwipww0ZxVnt7QBgzEI6/hcVNcgCgplbPRe5RUkARYCVLPHp+ScKer+B7BjOy?= =?utf-8?q?tPp26sUE4iFjj7BoCjAkL0Xi3OLJiqlePqE/jzRb6mL7FycopNCbyleogwkg89JnN?= =?utf-8?q?zowkTToHgx+HwWcjtfyxCwPQXpZ6fKsy0HfvJV1Qr7SN8glU1f4L97hp6ec0SzqSu?= =?utf-8?q?1b/uXA4OAT9wAnQ3xy+eYCWyLcBnccwhi4tAmqDX5hR7caDp9ZD5XuuijwyyPAUzb?= =?utf-8?q?jxFO8VIOsvrDs93k+QynJan67TGwXV8Dr7rnMp+HjQNu/iDagGsBvxQhGSPn4r35J?= =?utf-8?q?/CLA1D6SwWuTDlPvrx7/ZvkRtdrRfno89JnsLc659wTro3eeok4F99tNDkBSCRpB6?= =?utf-8?q?Zi4tyvGvmY3kS0svxiWIsBZ1ThwLOQ8JZ1GUou/rWDDffZfFAPAu6DERFaJf5Oabc?= =?utf-8?q?cywf9ByNffBvoOJaHeiPGb2RvDBwFfyYGQ=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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UBobXFhqGc4vRZsiP7n6vjQFbAvw0sGHKmTMe0RidUQ0v5SyJJo6Zyc/p5NJkAFMVH9/ANa/TTywvP+NgQe4JyALcN6+WnbgkcI8JA6LyV7mZ9IdY5E5Q5UpZZnhMug67xfFxiXnJxr9VojzaG48davlvTp9Ctnyc3Roa8RA0rqfx7z7ZTTH03A8SymmXbgN/X/6t4vgVih0zK4zT7etGGxE4aykLP+Kpxav+k6GXds+nKgbGq4gRYGeMgGY3ECXKBz6HSmZWFG+P2sbi6NM2CjVyse25aD9sOIJMT9n3dU4XFxrRy6UsYZl8mKzwOJpsXQ9KqEpQ+X6QdiwJC14TDFO4HuyGlvxB5rLCnQqxB/VIJnNbwFJahnD7NkzHT72Jr9AZvPvu8cO6lgLrTvVYH48CQPZx508RDgrg2lK2W7zsQNC8iSKu66s1BNKYmt/irC7N8DMKq/gug09HOWj6SeQX7EdqG6w/j0bCJgYGldJEiZvxX7+JxJU2m3hoqXoHvdyh3fu3eyJI3wGau1869AdBwAG8h5CD3Am+vaRTWx2JNGQPIPRUhgOqrRgnllqh1bpRgMi26SOY/aOuRwdciEbVaGEL/J4wF6/B+9wZdzufoB5BQeja5HwVerRr6ev5U+Yf8Va3EkC12ZXO2W4aCZ5i6vkv46qIXuXY8kPA9U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:14.8552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5eeecfb4-54e0-4640-8a55-08dcf838c8dc 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: GVXP190MB2231 X-BESS-ID: 1730220201-311207-12665-27841-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGBpaWQGYGUNQyLdHc0tA42S LZ0tzc0sjc3NTCIsXQNDHFLCklySLZUKk2FgAvS9LOQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan22-120.eu-central-1b.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 The Categorizer module’s main purpose is to is select the behavior of other modules in the FPGA pipeline depending on a protocol check. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 24 ++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c | 267 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 165 +++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 47 +++ .../profile_inline/flow_api_profile_inline.c | 83 ++++++ 5 files changed, 586 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 1b45ea4296..87fc16ecb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -315,11 +315,35 @@ int hw_mod_cat_reset(struct flow_api_backend_s *be); int hw_mod_cat_cfn_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cfn_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, int word_off, uint32_t value); +/* KCE/KCS/FTE KM */ +int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +/* KCE/KCS/FTE FLM */ +int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cct_flush(struct flow_api_backend_s *be, int start_idx, int count); + int hw_mod_cat_kcc_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_exo_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c index d266760123..9164ec1ae0 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c @@ -951,6 +951,97 @@ static int hw_mod_cat_fte_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_fte_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_fte_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_fte_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_fte_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + const uint32_t key_cnt = (_VER_ >= 20) ? 4 : 2; + + if ((unsigned int)index >= (be->cat.nb_cat_funcs / 8 * be->cat.nb_flow_types * key_cnt)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_FTE_ENABLE_BM: + GET_SET(be->cat.v18.fte[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_FTE_ENABLE_BM: + GET_SET(be->cat.v21.fte[index].enable_bm[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 1, index, value, 1); +} + int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -964,6 +1055,45 @@ int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cte_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cte_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->cat.nb_cat_funcs) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_CTE_ENABLE_BM: + GET_SET(be->cat.v18.cte[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cte_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count) { int addr_size = (_VER_ < 15) ? 8 : ((be->cat.cts_num + 1) / 2); @@ -979,6 +1109,51 @@ int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cts_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cts_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + int addr_size = (be->cat.cts_num + 1) / 2; + + if ((unsigned int)index >= (be->cat.nb_cat_funcs * addr_size)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_CTS_CAT_A: + GET_SET(be->cat.v18.cts[index].cat_a, value); + break; + + case HW_CAT_CTS_CAT_B: + GET_SET(be->cat.v18.cts[index].cat_b, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cts_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -992,6 +1167,98 @@ int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cot_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cot_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_COT_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->cat.v18.cot[index], (uint8_t)*value, + sizeof(struct cat_v18_cot_s)); + break; + + case HW_CAT_COT_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->cat.v18.cot, struct cat_v18_cot_s, index, *value); + break; + + case HW_CAT_COT_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->cat.v18.cot, struct cat_v18_cot_s, index, *value, + be->max_categories); + break; + + case HW_CAT_COT_COPY_FROM: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memcpy(&be->cat.v18.cot[index], &be->cat.v18.cot[*value], + sizeof(struct cat_v18_cot_s)); + break; + + case HW_CAT_COT_COLOR: + GET_SET(be->cat.v18.cot[index].color, value); + break; + + case HW_CAT_COT_KM: + GET_SET(be->cat.v18.cot[index].km, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cot_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cct_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 4ea9387c80..addd5f288f 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -22,6 +22,14 @@ struct hw_db_inline_resource_db { uint32_t nb_cot; + /* Items */ + struct hw_db_inline_resource_db_cat { + struct hw_db_inline_cat_data data; + int ref; + } *cat; + + uint32_t nb_cat; + /* Hardware */ struct hw_db_inline_resource_db_cfn { @@ -47,6 +55,14 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_cat = ndev->be.cat.nb_cat_funcs; + db->cat = calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_cat)); + + if (db->cat == NULL) { + hw_db_inline_destroy(db); + return -1; + } + *db_handle = db; return 0; } @@ -56,6 +72,7 @@ void hw_db_inline_destroy(void *db_handle) struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; free(db->cot); + free(db->cat); free(db->cfn); @@ -70,6 +87,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct case HW_DB_IDX_TYPE_NONE: break; + case HW_DB_IDX_TYPE_CAT: + hw_db_inline_cat_deref(ndev, db_handle, *(struct hw_db_cat_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_COT: hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); break; @@ -80,6 +101,69 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct } } +/******************************************************************************/ +/* Filter */ +/******************************************************************************/ + +/* + * Setup a filter to match: + * All packets in CFN checks + * All packets in KM + * All packets in FLM with look-up C FT equal to specified argument + * + * Setup a QSL recipe to DROP all matching packets + * + * Note: QSL recipe 0 uses DISCARD in order to allow for exception paths (UNMQ) + * Consequently another QSL recipe with hard DROP is needed + */ +int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, + uint32_t qsl_hw_id) +{ + (void)ft; + (void)qsl_hw_id; + + const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; + (void)offset; + + /* Select and enable QSL recipe */ + if (hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 1, qsl_hw_id)) + return -1; + + if (hw_mod_cat_cts_flush(&ndev->be, offset * cat_hw_id, 6)) + return -1; + + if (hw_mod_cat_cte_set(&ndev->be, HW_CAT_CTE_ENABLE_BM, cat_hw_id, 0x8)) + return -1; + + if (hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1)) + return -1; + + /* Make all CFN checks TRUE */ + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cat_hw_id, 0, 0x1)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L3, cat_hw_id, 0, 0x0)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_INV, cat_hw_id, 0, 0x1)) + return -1; + + /* Final match: look-up_A == TRUE && look-up_C == TRUE */ + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM0_OR, cat_hw_id, 0, 0x1)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM1_OR, cat_hw_id, 0, 0x3)) + return -1; + + if (hw_mod_cat_cfn_flush(&ndev->be, cat_hw_id, 1)) + return -1; + + return 0; +} + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -150,3 +234,84 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_han db->cot[idx.ids].ref = 0; } } + +/******************************************************************************/ +/* CAT */ +/******************************************************************************/ + +static int hw_db_inline_cat_compare(const struct hw_db_inline_cat_data *data1, + const struct hw_db_inline_cat_data *data2) +{ + return data1->vlan_mask == data2->vlan_mask && + data1->mac_port_mask == data2->mac_port_mask && + data1->ptc_mask_frag == data2->ptc_mask_frag && + data1->ptc_mask_l2 == data2->ptc_mask_l2 && + data1->ptc_mask_l3 == data2->ptc_mask_l3 && + data1->ptc_mask_l4 == data2->ptc_mask_l4 && + data1->ptc_mask_tunnel == data2->ptc_mask_tunnel && + data1->ptc_mask_l3_tunnel == data2->ptc_mask_l3_tunnel && + data1->ptc_mask_l4_tunnel == data2->ptc_mask_l4_tunnel && + data1->err_mask_ttl_tunnel == data2->err_mask_ttl_tunnel && + data1->err_mask_ttl == data2->err_mask_ttl && data1->ip_prot == data2->ip_prot && + data1->ip_prot_tunnel == data2->ip_prot_tunnel; +} + +struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cat_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_cat_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_CAT; + + for (uint32_t i = 0; i < db->nb_cat; ++i) { + int ref = db->cat[i].ref; + + if (ref > 0 && hw_db_inline_cat_compare(data, &db->cat[i].data)) { + idx.ids = i; + hw_db_inline_cat_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->cat[idx.ids].ref = 1; + memcpy(&db->cat[idx.ids].data, data, sizeof(struct hw_db_inline_cat_data)); + + return idx; +} + +void hw_db_inline_cat_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->cat[idx.ids].ref += 1; +} + +void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->cat[idx.ids].ref -= 1; + + if (db->cat[idx.ids].ref <= 0) { + memset(&db->cat[idx.ids].data, 0x0, sizeof(struct hw_db_inline_cat_data)); + db->cat[idx.ids].ref = 0; + } +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 0116af015d..38502ac1ec 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -36,12 +36,37 @@ struct hw_db_cot_idx { HW_DB_IDX; }; +struct hw_db_cat_idx { + HW_DB_IDX; +}; + enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, + HW_DB_IDX_TYPE_CAT, }; /* Functionality data types */ +struct hw_db_inline_cat_data { + uint32_t vlan_mask : 4; + uint32_t mac_port_mask : 8; + uint32_t ptc_mask_frag : 4; + uint32_t ptc_mask_l2 : 7; + uint32_t ptc_mask_l3 : 3; + uint32_t ptc_mask_l4 : 5; + uint32_t padding0 : 1; + + uint32_t ptc_mask_tunnel : 11; + uint32_t ptc_mask_l3_tunnel : 3; + uint32_t ptc_mask_l4_tunnel : 5; + uint32_t err_mask_ttl_tunnel : 2; + uint32_t err_mask_ttl : 2; + uint32_t padding1 : 9; + + uint8_t ip_prot; + uint8_t ip_prot_tunnel; +}; + struct hw_db_inline_qsl_data { uint32_t discard : 1; uint32_t drop : 1; @@ -70,6 +95,16 @@ struct hw_db_inline_hsh_data { uint8_t key[MAX_RSS_KEY_LEN]; }; +struct hw_db_inline_action_set_data { + int contains_jump; + union { + int jump; + struct { + struct hw_db_cot_idx cot; + }; + }; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); @@ -84,4 +119,16 @@ struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_ha void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); +/**/ + +struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cat_data *data); +void hw_db_inline_cat_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx); +void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx); + +/**/ + +int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, + uint32_t qsl_hw_id); + #endif /* _FLOW_API_HW_DB_INLINE_H_ */ 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 07a2a12cc9..3ea4c73e24 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 @@ -21,6 +21,10 @@ #define NT_FLM_OP_UNLEARN 0 #define NT_FLM_OP_LEARN 1 +#define NT_FLM_VIOLATING_MBR_FLOW_TYPE 15 +#define NT_VIOLATING_MBR_CFN 0 +#define NT_VIOLATING_MBR_QSL 1 + static void *flm_lrn_queue_arr; static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) @@ -2346,6 +2350,67 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n /* * Flow for group 0 */ + struct hw_db_inline_action_set_data action_set_data = { 0 }; + (void)action_set_data; + + if (fd->jump_to_group != UINT32_MAX) { + /* Action Set only contains jump */ + action_set_data.contains_jump = 1; + action_set_data.jump = fd->jump_to_group; + + } else { + /* Action Set doesn't contain jump */ + action_set_data.contains_jump = 0; + + /* Setup COT */ + struct hw_db_inline_cot_data cot_data = { + .matcher_color_contrib = 0, + .frag_rcp = 0, + }; + struct hw_db_cot_idx cot_idx = + hw_db_inline_cot_add(dev->ndev, dev->ndev->hw_db_handle, + &cot_data); + fh->db_idxs[fh->db_idx_counter++] = cot_idx.raw; + action_set_data.cot = cot_idx; + + if (cot_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference COT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + } + + /* Setup CAT */ + struct hw_db_inline_cat_data cat_data = { + .vlan_mask = (0xf << fd->vlans) & 0xf, + .mac_port_mask = 1 << fh->port_id, + .ptc_mask_frag = fd->fragmentation, + .ptc_mask_l2 = fd->l2_prot != -1 ? (1 << fd->l2_prot) : -1, + .ptc_mask_l3 = fd->l3_prot != -1 ? (1 << fd->l3_prot) : -1, + .ptc_mask_l4 = fd->l4_prot != -1 ? (1 << fd->l4_prot) : -1, + .err_mask_ttl = (fd->ttl_sub_enable && + fd->ttl_sub_outer) ? -1 : 0x1, + .ptc_mask_tunnel = fd->tunnel_prot != + -1 ? (1 << fd->tunnel_prot) : -1, + .ptc_mask_l3_tunnel = + fd->tunnel_l3_prot != -1 ? (1 << fd->tunnel_l3_prot) : -1, + .ptc_mask_l4_tunnel = + fd->tunnel_l4_prot != -1 ? (1 << fd->tunnel_l4_prot) : -1, + .err_mask_ttl_tunnel = + (fd->ttl_sub_enable && !fd->ttl_sub_outer) ? -1 : 0x1, + .ip_prot = fd->ip_prot, + .ip_prot_tunnel = fd->tunnel_ip_prot, + }; + struct hw_db_cat_idx cat_idx = + hw_db_inline_cat_add(dev->ndev, dev->ndev->hw_db_handle, &cat_data); + fh->db_idxs[fh->db_idx_counter++] = cat_idx.raw; + + if (cat_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference CAT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + nic_insert_flow(dev->ndev, fh); } @@ -2378,6 +2443,20 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) /* Check static arrays are big enough */ assert(ndev->be.tpe.nb_cpy_writers <= MAX_CPY_WRITERS_SUPPORTED); + /* COT is locked to CFN. Don't set color for CFN 0 */ + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, 0, 0); + + if (hw_mod_cat_cot_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + /* Setup filter using matching all packets violating traffic policing parameters */ + flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); + + if (hw_db_inline_setup_mbr_filter(ndev, NT_VIOLATING_MBR_CFN, + NT_FLM_VIOLATING_MBR_FLOW_TYPE, + NT_VIOLATING_MBR_QSL) < 0) + goto err_exit0; + ndev->id_table_handle = ntnic_id_table_create(); if (ndev->id_table_handle == NULL) @@ -2412,6 +2491,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_group_handle_destroy(&ndev->group_handle); ntnic_id_table_destroy(ndev->id_table_handle); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PRESET_ALL, 0, 0, 0); + hw_mod_cat_cfn_flush(&ndev->be, 0, 1); + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, 0, 0); + hw_mod_cat_cot_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_CAT_CFN, 0); hw_mod_tpe_reset(&ndev->be); From patchwork Tue Oct 29 16:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147631 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1044A45BC0; Tue, 29 Oct 2024 17:46:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14BF042F77; Tue, 29 Oct 2024 17:43:47 +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 A0F4442EE8 for ; Tue, 29 Oct 2024 17:43:22 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2240.outbound.protection.outlook.com [104.47.51.240]) 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:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V+Z8n4m/p/9MSJ9VPDYOXR7w7XfgqSpCv7WD45p1UkYM27Jvp/9cmL0OHf22PzGM8MWA5IXTzaIBUOI6J2HSmdKoZ0HgdQJipbxSEesjLcU+ev8W1DTkU8UD+gUesm8M1zZ5al3HzmJC5x0amU2pAJ84F1XvJw5NqSVzaIA4TGgMTfb8BorzFVjmHHSckwIdenCm/kcooHIoFmsk6JJTXWDrVgHLXHE0p7tRRaQP2n5UM8Or4xGfJpxyCNBS1WQsnRZTZ115hHDuIO8NPlnvNSmi4jPj/GJ+cj0/7Ynl4VUyHf/+GxaHMv0V2jtUuzmsJ3wHjdQvnofANcLV4z5eDw== 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=DKZbQsMHBrYd9PJ83TdPWkxhbwY8dg/1COUfgRwuyUk=; b=q0//dvC/AWxIf7KwZMIFt59ugk5pB3TU7Az8z3bhYrj6Y9fOhkIYvkN6RiEDKKXTrT6INQkZmt9F6lqJgUTe8NM9WiuJ1485PqgCdkneFoIaalqQuNDT3yK6bh7gOzaVvLkBjW9Adj1c7qE9nEwg4Utwn/HNpVSMGW+DsQC1+v3yEdTc0YsKbMUCDhmZszwuufXgtuKK33uhYe/O2mRAwcblxaqY1hIqPc9BZ6ANums6VpUkH3UXV7wn7t4dKQX99cfr3ydMNdbhSyWXtJivpzDkrvCeke9CzgpyY+2vzoMMIkrjY/ksdIhkXgJJgsh/OzTlRnJrddgGyiQMyLMPDQ== 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=DKZbQsMHBrYd9PJ83TdPWkxhbwY8dg/1COUfgRwuyUk=; b=ikCLYGDnW1bbNMDtFDQNVG7i70Z59+kiP9FuJIeDN4f1NK2sPKMjit7Uho8W3lvVdXaQClSV/VzFcUSpQYyzrm9VFFI59I03sKoPQjWqHsXDIMvefS4ppGXc9zgJbtnUXlRYQAGu9CE+OUti8a5iQevczApjC9V9IS4UcIpTdF0= Received: from DUZPR01CA0194.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::19) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:16 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::d0) by DUZPR01CA0194.outlook.office365.com (2603:10a6:10:4b6::19) 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:43:16 +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:43:16 +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 27/86] net/ntnic: add SLC LR module Date: Tue, 29 Oct 2024 17:41:31 +0100 Message-ID: <20241029164243.1648775-28-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS8P190MB1063:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d74120d-ac0d-4212-e29d-08dcf838c9b7 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: UUp/cdcf+RUX1G1xe1F02JWVDdhbHcgESH6xCLmEnzd0+Qa18khbnDQNVY9ewKZjq7/J38dnBKVoVzCifiy0chnKQfQwK4ZEWJjDu81OKOWAlb2LySzxCPRJv7B3pr48PdPYv4WjIsjnpx6PTK+yRyEL+2diLhfZonmdMVtn/B5XTeXBw/9JkVnuN0OUL7ZRKJXLuHHbQRcsf3T9ffTOIu5/HnaAaEsSbLGL8TBwhB5NnCue0Gjj8KWuqZG368dIJT2zkIKrE97yNoRHtJdJB/Y+cr2rU33hrDOiNY9GvbuWSrlcaqxbwaY4Nbr6b+XzEF21KhqYcVYDGDQTCLz72py8pJJQRshh1El7TUD2cEGvCjsgGxUj0ngU1z5R5Awq74GQPKFxnkQS8VTnBwM84CMltCqHf/ZDGTBV23l53HoYk2uHqoChrPxWB2YwWAf1vhAjyzSyESgI7bcQrtOB4hzsqjAsZHD06Z4lYdIpPh6pA0FhRO00sPENFO0dhO81tm9K4F05Zjhb78Vh46hVr66c+6GmlVRtW2vzR85pavdlos/qvCKNwoKPSpMe/p11Oankvzk5FQtDrFtPqwNsjEHxbD/MlZ3Vj3rPXSzLGGmdVQc+pvXXRImvfewXim4m8HC85CL9/VftjWs1PtZ/INNcpn1eXmQWfbKmtfMWQThxVpf5j3+JnSqcH1TnYyV2wefNqT30HMz1kdcp5kw+oFSLy3bbBryVf3WKs60lNZv+EdmdaudzA0qptH+MFg1IPWzsn4mofirjjMgj/6a94WYbbUfeOkc15osI87TmchetAcH5g6S7q0VEQND+9NaKYdAK7bbQKNxiCmK62BLXaybqkiBbXnl70VKCgaNGez9AZmC+q95x90U4ex1wBYzxuZnAdelx9tQdVnnQXgHgMpbgqpQxtoRehfUlWxq1l4I0KQBhPOBhcuN1OZH2VQ2JY6HI6KcryHQ3gHkalTnCgiDZJ6k2e3S7NibFCdgjhIIxaFwD0iO/VG/j6SZkMy03Vjt6pLpO76DlRsQEXr09i9IR63R1svs2krTr2GjdCd/mFJUsE2/MImKIaNyt7laA8T4lcQTpxPliQLSCpObB+41RHcpTWJHZOZI7sZToLst0e578aUPqiR0Sx2fO5C5MtRXqwNKgHcqiCcmeu8NUiZpNvMkUdi6E3eMVjR905Zfa/UjPfG3EdSSQPRxPdgqLmungN1+G6nT9v4rcScoIFPyPYglPN0NxZ5ym4IdngBrY0B5rPFuS8aPgC6MlKx3g4xW7SUaBwWylWV0EjtMHXJ5/XPHIxHPXWmSwOQN1BwD2UjkVVqPHkLP0qc329ziwc+KLBpDg+VHmE79LU3NKPhwhhRi114+vXaU1BqKaOU4aNWXzdh7zBiwa+Y8VGFXbOitTEw+VLUbiQ/6kt/Bs+g== 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: s3YOX7i8iVlLyZuz7HbC6xZvrYVT6xJH3Rw5ty7WqIcJls+ndajw70hwsgIFpjRUFZz+tcZsP4m6E+68z5uqQcCOuFqe16lY5hJNZ38jahcc/x7tnI+181/O6qK2Q0c2KwLnAtgBEWo3RSnMQv1Woe41ly7bj/JEVywLfnHYTb/v9RL4mtlMf8oxDGEk/q6F1AZD17gZltZywhERzOC5d7wqv2DjI+rIXgDOMc0wnet74NmqUl37zoKoa2xcHzA3zOxdc4jyJIeCt+5zU3zwqc9pJkYnlzp/Ojw4WC7gR+/fJGO/Yas6k8AOMWkWiL7KUSzH1WeN0OQksR+W/v1XZLltNv9bwVyLPVS80Z6r1QdhQtXqO2fTED3AdgMPdLBXP7AZGXM8PucJWpS94Mi6AR+SGdt3+6f1thIpAdbE7wBxXAxuS+7CCmwxqQp+gqhnD2vz5aUe6jGi/gYxep4Bl0tPNZT+EQvKaoGymwuW+bbQYNq5zRCQnCrLy30yo5q10ChrryFIxOLa2pBnxw6nzC+PpCFC/27Nohi56UPNwWiMo3XFUm7o53xZYTPN/eZXnGY5YHKDo57oLGOSGchKdu6Xq2tRVPDRGC7jfJTWEDEq0jubqd4mG9F6IHFFTustgMCa62uwE7EJ8lCAGBUcg9errQlf1CbcuD82CADqVDs= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:16.2771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d74120d-ac0d-4212-e29d-08dcf838c9b7 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: AS8P190MB1063 X-BESS-ID: 1730220199-303097-12758-29338-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.240 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGBubmQGYGUNTS0jDV0jApzT LN0sDYKNUyLS3V3CIpyTLR0DTZxMA4Wak2FgAlMnk4QgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-223.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 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_RULE_7582B, 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 The Slicer for Local Retransmit module can cut of the head a packet before the packet leaves the FPGA RX pipeline. This is used when the TX pipeline is configured to add a new head in the packet. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 2 + .../nthw/flow_api/hw_mod/hw_mod_slc_lr.c | 100 +++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 104 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 19 ++++ .../profile_inline/flow_api_profile_inline.c | 37 ++++++- 5 files changed, 257 insertions(+), 5 deletions(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 87fc16ecb4..2711f44083 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -697,6 +697,8 @@ int hw_mod_slc_lr_alloc(struct flow_api_backend_s *be); void hw_mod_slc_lr_free(struct flow_api_backend_s *be); int hw_mod_slc_lr_reset(struct flow_api_backend_s *be); int hw_mod_slc_lr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_slc_lr_rcp_set(struct flow_api_backend_s *be, enum hw_slc_lr_e field, uint32_t index, + uint32_t value); struct pdb_func_s { COMMON_FUNC_INFO_S; diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c index 1d878f3f96..30e5e38690 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c @@ -66,3 +66,103 @@ int hw_mod_slc_lr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int co return be->iface->slc_lr_rcp_flush(be->be_dev, &be->slc_lr, start_idx, count); } + +static int hw_mod_slc_lr_rcp_mod(struct flow_api_backend_s *be, enum hw_slc_lr_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 2: + switch (field) { + case HW_SLC_LR_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->slc_lr.v2.rcp[index], (uint8_t)*value, + sizeof(struct hw_mod_slc_lr_v2_s)); + break; + + case HW_SLC_LR_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->slc_lr.v2.rcp, struct hw_mod_slc_lr_v2_s, index, + *value, be->max_categories); + break; + + case HW_SLC_LR_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->slc_lr.v2.rcp, struct hw_mod_slc_lr_v2_s, index, + *value); + break; + + case HW_SLC_LR_RCP_HEAD_SLC_EN: + GET_SET(be->slc_lr.v2.rcp[index].head_slc_en, value); + break; + + case HW_SLC_LR_RCP_HEAD_DYN: + GET_SET(be->slc_lr.v2.rcp[index].head_dyn, value); + break; + + case HW_SLC_LR_RCP_HEAD_OFS: + GET_SET_SIGNED(be->slc_lr.v2.rcp[index].head_ofs, value); + break; + + case HW_SLC_LR_RCP_TAIL_SLC_EN: + GET_SET(be->slc_lr.v2.rcp[index].tail_slc_en, value); + break; + + case HW_SLC_LR_RCP_TAIL_DYN: + GET_SET(be->slc_lr.v2.rcp[index].tail_dyn, value); + break; + + case HW_SLC_LR_RCP_TAIL_OFS: + GET_SET_SIGNED(be->slc_lr.v2.rcp[index].tail_ofs, value); + break; + + case HW_SLC_LR_RCP_PCAP: + GET_SET(be->slc_lr.v2.rcp[index].pcap, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_slc_lr_rcp_set(struct flow_api_backend_s *be, enum hw_slc_lr_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_slc_lr_rcp_mod(be, field, index, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index addd5f288f..b17bce3745 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -20,7 +20,13 @@ struct hw_db_inline_resource_db { int ref; } *cot; + struct hw_db_inline_resource_db_slc_lr { + struct hw_db_inline_slc_lr_data data; + int ref; + } *slc_lr; + uint32_t nb_cot; + uint32_t nb_slc_lr; /* Items */ struct hw_db_inline_resource_db_cat { @@ -55,6 +61,14 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_slc_lr = ndev->be.max_categories; + db->slc_lr = calloc(db->nb_slc_lr, sizeof(struct hw_db_inline_resource_db_slc_lr)); + + if (db->slc_lr == NULL) { + hw_db_inline_destroy(db); + return -1; + } + db->nb_cat = ndev->be.cat.nb_cat_funcs; db->cat = calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_cat)); @@ -72,6 +86,7 @@ void hw_db_inline_destroy(void *db_handle) struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; free(db->cot); + free(db->slc_lr); free(db->cat); free(db->cfn); @@ -95,6 +110,11 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_SLC_LR: + hw_db_inline_slc_lr_deref(ndev, db_handle, + *(struct hw_db_slc_lr_idx *)&idxs[i]); + break; + default: break; } @@ -235,6 +255,90 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_han } } +/******************************************************************************/ +/* SLC_LR */ +/******************************************************************************/ + +static int hw_db_inline_slc_lr_compare(const struct hw_db_inline_slc_lr_data *data1, + const struct hw_db_inline_slc_lr_data *data2) +{ + if (!data1->head_slice_en) + return data1->head_slice_en == data2->head_slice_en; + + return data1->head_slice_en == data2->head_slice_en && + data1->head_slice_dyn == data2->head_slice_dyn && + data1->head_slice_ofs == data2->head_slice_ofs; +} + +struct hw_db_slc_lr_idx hw_db_inline_slc_lr_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_slc_lr_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_slc_lr_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_SLC_LR; + + for (uint32_t i = 1; i < db->nb_slc_lr; ++i) { + int ref = db->slc_lr[i].ref; + + if (ref > 0 && hw_db_inline_slc_lr_compare(data, &db->slc_lr[i].data)) { + idx.ids = i; + hw_db_inline_slc_lr_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->slc_lr[idx.ids].ref = 1; + memcpy(&db->slc_lr[idx.ids].data, data, sizeof(struct hw_db_inline_slc_lr_data)); + + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_SLC_EN, idx.ids, data->head_slice_en); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_DYN, idx.ids, data->head_slice_dyn); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_OFS, idx.ids, data->head_slice_ofs); + hw_mod_slc_lr_rcp_flush(&ndev->be, idx.ids, 1); + + return idx; +} + +void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->slc_lr[idx.ids].ref += 1; +} + +void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->slc_lr[idx.ids].ref -= 1; + + if (db->slc_lr[idx.ids].ref <= 0) { + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_PRESET_ALL, idx.ids, 0x0); + hw_mod_slc_lr_rcp_flush(&ndev->be, idx.ids, 1); + + memset(&db->slc_lr[idx.ids].data, 0x0, sizeof(struct hw_db_inline_slc_lr_data)); + db->slc_lr[idx.ids].ref = 0; + } +} + /******************************************************************************/ /* CAT */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 38502ac1ec..ef63336b1c 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -40,10 +40,15 @@ struct hw_db_cat_idx { HW_DB_IDX; }; +struct hw_db_slc_lr_idx { + HW_DB_IDX; +}; + enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, HW_DB_IDX_TYPE_CAT, + HW_DB_IDX_TYPE_SLC_LR, }; /* Functionality data types */ @@ -89,6 +94,13 @@ struct hw_db_inline_cot_data { uint32_t padding : 24; }; +struct hw_db_inline_slc_lr_data { + uint32_t head_slice_en : 1; + uint32_t head_slice_dyn : 5; + uint32_t head_slice_ofs : 8; + uint32_t padding : 18; +}; + struct hw_db_inline_hsh_data { uint32_t func; uint64_t hash_mask; @@ -119,6 +131,13 @@ struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_ha void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); +struct hw_db_slc_lr_idx hw_db_inline_slc_lr_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_slc_lr_data *data); +void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx); +void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx); + /**/ struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, 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 3ea4c73e24..d7491fce63 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 @@ -2276,18 +2276,38 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d return 0; } -static int setup_flow_flm_actions(struct flow_eth_dev *dev __rte_unused, - const struct nic_flow_def *fd __rte_unused, +static int setup_flow_flm_actions(struct flow_eth_dev *dev, + const struct nic_flow_def *fd, const struct hw_db_inline_qsl_data *qsl_data __rte_unused, const struct hw_db_inline_hsh_data *hsh_data __rte_unused, uint32_t group __rte_unused, - uint32_t local_idxs[] __rte_unused, - uint32_t *local_idx_counter __rte_unused, + uint32_t local_idxs[], + uint32_t *local_idx_counter, uint16_t *flm_rpl_ext_ptr __rte_unused, uint32_t *flm_ft __rte_unused, uint32_t *flm_scrub __rte_unused, - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { + /* Setup SLC LR */ + struct hw_db_slc_lr_idx slc_lr_idx = { .raw = 0 }; + + if (fd->header_strip_end_dyn != 0 || fd->header_strip_end_ofs != 0) { + struct hw_db_inline_slc_lr_data slc_lr_data = { + .head_slice_en = 1, + .head_slice_dyn = fd->header_strip_end_dyn, + .head_slice_ofs = fd->header_strip_end_ofs, + }; + slc_lr_idx = + hw_db_inline_slc_lr_add(dev->ndev, dev->ndev->hw_db_handle, &slc_lr_data); + local_idxs[(*local_idx_counter)++] = slc_lr_idx.raw; + + if (slc_lr_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference SLC LR resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + } + return 0; } @@ -2449,6 +2469,9 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) if (hw_mod_cat_cot_flush(&ndev->be, 0, 1) < 0) goto err_exit0; + /* SLC LR index 0 is reserved */ + flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); + /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); @@ -2497,6 +2520,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) hw_mod_cat_cot_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_CAT_CFN, 0); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_PRESET_ALL, 0, 0); + hw_mod_slc_lr_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_SLC_LR_RCP, 0); + hw_mod_tpe_reset(&ndev->be); flow_nic_free_resource(ndev, RES_TPE_RCP, 0); flow_nic_free_resource(ndev, RES_TPE_EXT, 0); From patchwork Tue Oct 29 16:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147632 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1CBA45BC0; Tue, 29 Oct 2024 17:46:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D66142EC9; Tue, 29 Oct 2024 17:44:12 +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 7449342EF1 for ; Tue, 29 Oct 2024 17:43:23 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) 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 16:43:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DDGDWhVKVLbs2z73S0nvt1QbiMMWnnJMYeI6PQzMhSgNBgv8pgd18u1Fc9bQdVRF1+MvWXV/jaHY7/izv4sP1pBrhle72g7KGI4NI5/GUQuHlMhNKzU0LxUdMKLrn3T1wMtARY8AahP5gqApgt2oN227xuMnV+T6ikDdsxhzAUfe9F8nL6jukNfDYhZ5FwwzteHhTPsTH6WoX5RwAn6Cmu1ZCNcy/sBgPcIusWEWJj4VQ8yodDreVgQO2w/Z5Ke9qMZ4fyisIK48v0uRBgt2NxZIxHOCNw5ynybutLgYDUnZ+XRqULOJRYVLhJXD5Y+MaKmOAUhRQXom+URalMNaTA== 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=U8qH76za/ZaQYk/+bD+aXd6f/okYVVEC8I1Ekj6xdC8=; b=d1tIyEHut1ISpMmqggdcDx3lcbD7GJsBRkwLTgzvWmPWc35nl/vWiqmq+QrfQWJZX5Z0qSW4uWcvDN8WpujxRqhl8OGIXbCzBJKB44J6IUWY7uUh1dG7/Oe9hCZPIYczpxz93+DG3sVOruLpW3jwT6Vt+VssHu6VdiNREtTgTQdf+OQheYpfAWH3hoeiAe5qPGpxfREO481K7zqvXWcUN0sXWq0Sn7W0R5W33yzVf6DxZHOcyb/wBuA7Q6WFQBVcJRiZQzA05wP9XjPsXjsc1pMM2XJqjtPCo3usMfLChiLhTH2wOeCIRBcq4v353Fvw0KZ1GOixtXIKEaYEaOgFyw== 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=U8qH76za/ZaQYk/+bD+aXd6f/okYVVEC8I1Ekj6xdC8=; b=IBK7SxfLvuzZIdyJ2nzO0gNPGzV7SjXbDeEe1f3FohSr8q6G4LF8v5a3Yzzn/pNwSKDmnk7XfXaIa8J2poVaRGsTUDn1VwCikgwVcD6/PNy+6dJNo3qz22RvYrawc1m52qwXFy+CbywzocGhYl41cIA8/a5wqfSLF+G6F/xSQF0= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by DB8P190MB0634.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:12d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:17 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6::4) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:43:17 +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:43:17 +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 28/86] net/ntnic: add PDB module Date: Tue, 29 Oct 2024 17:41:32 +0100 Message-ID: <20241029164243.1648775-29-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB8P190MB0634:EE_ X-MS-Office365-Filtering-Correlation-Id: 079500a4-4494-4a0b-16eb-08dcf838ca4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: qCHWFpcfUitgisraW+vybxpvhXhGuQs71prrz2aQ3gkkZNVKAVBk1n2hDWiDXpBDxlANnI8WOkmOCNfutnauksFh6NaSihW7m46JjfIAc/eNH1AFPZy3Ab0OaPPWqPG4N8qt5dP7OK1YSKBxz57EUOP+Wj2CseVo6/cB1FRDVsoBrbkoPgWYVXcK6zDHKk2cfwvO37n7gwIC5e4x7zdVyR6K8zmN2KtLH6OLTAPwmNSuo5bA68Bh5AUN4blx8txTkGu2/OC4y4oKeJgzSHaQfUUirH9HeBWlxhz5mEzRHQcFwHO2lVYXBvsM4qryMKZHyR8q0Vr0JjOSfVZNtvN4hdU3XqLuDsFWJVZLZ0BKEX+Y26echqsvCNDITQiFBKLzHk8S+10buV0B1N97ezoEWZYSvB7tz9Br/LonLYUdls1G/NKeo0rnuFQqBXbdOfSN/eyOVhoc8U6zlGtlW6fQmUNnw8FG6FBHm6wFOmEaj9VnFkXSqu3A7UEcq+gf0n0B3aJloawuwsbNHWTtCQYzRZnNGfOGXvsMJXHI74g4zw/8iIzeBfv3QBPVKkw7IcSEbBONTpqJiVPXpZtu69qnaKOrj3Kip4B5GmEQpbVlt+u+DdelD7KNg7R8fuqP39S46o+QPki24NDgLZZox8VT4Ijebv1nI/E8JUuZA8y9Ua4IFyanzhyXlVPLX0Afiac1bB+jL327NQNqOBoaxeqGjKb2HZX3HjuvtWZJ2hFe8EoRYGw1/usuDtcq6Mx2WTQisUNc5or6HCoN4ogq1zF7eltNypgKQVTat1vS8FggaFarUeEtkqbAfQe55cdoCx8VaCawUcn6Ai7N+4G/pmSVta+3dl6zgb5IlmeVsidvhod26vsBivcerMbMBl7X7HK8zHU7sZ6nJDuB5NRkDTNMad8pdkVZVt2qO2KuhX6YdIOEzk46jC8mgBPcogS20EQov1CPAoRF4IjLm+tK34prwNBN8a0z7a7eg2jty891OdDI9P699NEy3K3WOulPcbHT0Hm4FkGQE2OjkKogqw5oqFjWDIflnjOcxsmhFjR1dKb8OjTNjql8+r4LeZEtomQcy699LUVAz27El/RfqjIDJ7+ybA2wotqZWT+N+itj3gON+jSoAf8IXtajPi0eljwdZRW1ZxoO97G7XaDqWRSkqkemsU6VIajOnHqcq/ZiHdtrXMKWFWxhTxixbvf4H6Uq7YuX+MeVFD8LbXUT3/zZNhcF6nngvpNKKrrXktazY6BA3Hh2M5CxZB/FHJO4SJMoCCxeqclQa3qVYeQKQRE4ciC1bWMUigUpOqWTPnEALcFxsDKLAgY8qwOk7F/QZdTTNMBsmR10M2inEC3ydpyS7DH3kk6FRQlB2RvgKn4XOz9JcXzfHCRvVs/UDM5GVKJkMDTzedj0zS9s9oaUBNs5mw== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2S3Fk6LfM3cicqx2Bce/SIKq164Oy34a++5OMKiaiGJJyaM93GRNNrcOK/+q6IJedn/iF7FTLZGWEGeNXufOTA0/G/ZWAzqVgyN5udGBwMgZ+QnqWyYm6CK4MS5Wl05oVRN/PtToLpZf+NQhWCjGijrC1c8wQHuydL9Y3HqwsNo5/krHZvwvcBnsPoRBP7wsFrLVKq8p5omhHvZ4hLhlNY6z528To3EBxdkhg/8SrXVk8CDxIAR8fVHy4pwM0ab6WOFUlyItXVuAehmd5Z1kZLY0sXZD37sRWumjTsnRZh1X1POXULsTZtvJSyIxYnZIA3eaXDzWtIc+AouliB34djrazBBddGhiEzHCtuPS0gyhreL/UPbB0fMjrT4ZfiMcyXXKrjwqEft307eUHbbpdWdqQpAAIVrJZSmTNKTP1YNDSuyAdkEo1J3qAUtsk7Rpri34Ps9cLJH7+WFKNAdzhf+hJXSLtMm6PTVViYl+/GmxlqwWHcagpZBbCw+VXhzhK9JI+M197US8kRLGmXjcDmiYZJq5fWnLd0jSCUjeognK+Di9Cb9liJWnAjc+kps1OQjIY89Cz/V3hwp1b9QdYZvp2p4UJ3rrnCk33b/MVPtfXaSe9BVas0Sh03ZTQwr7Sy22auqAL6B6BkuMzsY26x0iBIbkk5ICbyQKcfz7Qrg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:17.2615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 079500a4-4494-4a0b-16eb-08dcf838ca4e 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: DB8P190MB0634 X-BESS-ID: 1730220200-304438-12711-30030-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYmZoZAVgZQ0NTY3MjcINkgLc nAONkwxSLR2MjYzNw4ydLQxMjIwMRQqTYWAOaG3N9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan20-62.eu-central-1b.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 The Packet Description Builder module creates packet meta-data for example virtio-net headers. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 3 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c | 144 ++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 17 +++ 3 files changed, 164 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 2711f44083..7f1449d8ee 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -740,6 +740,9 @@ int hw_mod_pdb_alloc(struct flow_api_backend_s *be); void hw_mod_pdb_free(struct flow_api_backend_s *be); int hw_mod_pdb_reset(struct flow_api_backend_s *be); int hw_mod_pdb_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_pdb_rcp_set(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t value); + int hw_mod_pdb_config_flush(struct flow_api_backend_s *be); struct tpe_func_s { diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c index c3facacb08..59285405ba 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_pdb.c @@ -85,6 +85,150 @@ int hw_mod_pdb_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->pdb_rcp_flush(be->be_dev, &be->pdb, start_idx, count); } +static int hw_mod_pdb_rcp_mod(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t *value, int get) +{ + if (index >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 9: + switch (field) { + case HW_PDB_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->pdb.v9.rcp[index], (uint8_t)*value, + sizeof(struct pdb_v9_rcp_s)); + break; + + case HW_PDB_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->pdb.v9.rcp, struct pdb_v9_rcp_s, index, *value, + be->pdb.nb_pdb_rcp_categories); + break; + + case HW_PDB_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->pdb.nb_pdb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->pdb.v9.rcp, struct pdb_v9_rcp_s, index, *value); + break; + + case HW_PDB_RCP_DESCRIPTOR: + GET_SET(be->pdb.v9.rcp[index].descriptor, value); + break; + + case HW_PDB_RCP_DESC_LEN: + GET_SET(be->pdb.v9.rcp[index].desc_len, value); + break; + + case HW_PDB_RCP_TX_PORT: + GET_SET(be->pdb.v9.rcp[index].tx_port, value); + break; + + case HW_PDB_RCP_TX_IGNORE: + GET_SET(be->pdb.v9.rcp[index].tx_ignore, value); + break; + + case HW_PDB_RCP_TX_NOW: + GET_SET(be->pdb.v9.rcp[index].tx_now, value); + break; + + case HW_PDB_RCP_CRC_OVERWRITE: + GET_SET(be->pdb.v9.rcp[index].crc_overwrite, value); + break; + + case HW_PDB_RCP_ALIGN: + GET_SET(be->pdb.v9.rcp[index].align, value); + break; + + case HW_PDB_RCP_OFS0_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs0_dyn, value); + break; + + case HW_PDB_RCP_OFS0_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs0_rel, value); + break; + + case HW_PDB_RCP_OFS1_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs1_dyn, value); + break; + + case HW_PDB_RCP_OFS1_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs1_rel, value); + break; + + case HW_PDB_RCP_OFS2_DYN: + GET_SET(be->pdb.v9.rcp[index].ofs2_dyn, value); + break; + + case HW_PDB_RCP_OFS2_REL: + GET_SET_SIGNED(be->pdb.v9.rcp[index].ofs2_rel, value); + break; + + case HW_PDB_RCP_IP_PROT_TNL: + GET_SET(be->pdb.v9.rcp[index].ip_prot_tnl, value); + break; + + case HW_PDB_RCP_PPC_HSH: + GET_SET(be->pdb.v9.rcp[index].ppc_hsh, value); + break; + + case HW_PDB_RCP_DUPLICATE_EN: + GET_SET(be->pdb.v9.rcp[index].duplicate_en, value); + break; + + case HW_PDB_RCP_DUPLICATE_BIT: + GET_SET(be->pdb.v9.rcp[index].duplicate_bit, value); + break; + + case HW_PDB_RCP_PCAP_KEEP_FCS: + GET_SET(be->pdb.v9.rcp[index].pcap_keep_fcs, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 9 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_pdb_rcp_set(struct flow_api_backend_s *be, enum hw_pdb_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_pdb_rcp_mod(be, field, index, &value, 0); +} + int hw_mod_pdb_config_flush(struct flow_api_backend_s *be) { return be->iface->pdb_config_flush(be->be_dev, &be->pdb); 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 d7491fce63..405d87f632 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 @@ -2472,6 +2472,19 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) /* SLC LR index 0 is reserved */ flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); + /* PDB setup Direct Virtio Scatter-Gather descriptor of 12 bytes for its recipe 0 + */ + if (hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_DESCRIPTOR, 0, 7) < 0) + goto err_exit0; + + if (hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_DESC_LEN, 0, 6) < 0) + goto err_exit0; + + if (hw_mod_pdb_rcp_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + flow_nic_mark_resource_used(ndev, RES_PDB_RCP, 0); + /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); @@ -2529,6 +2542,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_free_resource(ndev, RES_TPE_EXT, 0); flow_nic_free_resource(ndev, RES_TPE_RPL, 0); + hw_mod_pdb_rcp_set(&ndev->be, HW_PDB_RCP_PRESET_ALL, 0, 0); + hw_mod_pdb_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_PDB_RCP, 0); + hw_db_inline_destroy(ndev->hw_db_handle); #ifdef FLOW_DEBUG From patchwork Tue Oct 29 16:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147636 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D22F45BC0; Tue, 29 Oct 2024 17:47:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B63F42F7A; Tue, 29 Oct 2024 17:44:16 +0100 (CET) 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 7A1E342ECF for ; Tue, 29 Oct 2024 17:43:31 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AsPo5bIEivwQY1Y7RSKB6XHUjOL8fCtyMdbz3DTCA56E5fpGxUDc3Jvaq/hGwN6lwAUjnTv0kapn5cnCd0WnQH4R17fLbFVKOdwGyyly9x/eaeuU2Is7c6kl74vgjj7Uk9GD24t5hVmQqV2wjw+d2+UTk6/Cus6auQOqMrfq+Ie6wdGLMQkX9ror97/M8VnSEUH8BP/BXTNtEbGF87Zt65QK1mjzRfBTfZkNqGROO9NQjHkUbECR9eWxyVSSbyvDdYAGV5ozdyixOqpWsQ+czx/hk+nS8cWEmcvJ2avLNNdqvS6++XtrvpA7IgWWS1YHGVuvWRBg6lfELPS+S3fIbg== 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=E4KtoAB8o3dwdwxYLrrtYRg4ouh17wEkqlym6gT1AVg=; b=ccEenqGB2UZkjJMP83yCtdkxRoEoTu7AFMWdwXOHaSIlBAPGJVtWpB8l+mH8i8rKZPy7OzVqt2D3JOqdmY1yGXRf6EfZMf7bQY7SYBMvI0Mya1CQFvJeeDYsGqB1d2OI2R6/SiOL63CaGAZY4BLuqyqc10+M0aTwbtraEJ4H5XNlCaaKHXuZ2wdazLh7AAgcGRBOU1HKQRI7sKmzMKAU/yJOWXc/YwyaGfG64xlb6eJFJ6G/7OrTOAXaO3kNDF24zcBuQFPSzkPX5rv63emP2MHQxLM7RXB/01gLf5U0zxMWk/R/vhOsRkiEG32xOktzDhiHF2xqkiMHY4eDuqX2Fg== 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=E4KtoAB8o3dwdwxYLrrtYRg4ouh17wEkqlym6gT1AVg=; b=qAsMHBdhc1vUfA1/yNybMhOUoGQ8N7ExvPehu8BWlgO6t6ujUgxQl73yj11lSSKXvFdl0gkDqY3Tf+caR6dnuh76PFDAJVuGIzoZNYp0KnDstoUkUichh5HRfSYhikTVabDoIsr33sofchdGd0hUIF1XJp222bD1Q3oF8ByIfrY= Received: from DUZPR01CA0199.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::28) by VI0P190MB2163.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:254::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 16:43:18 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::b5) by DUZPR01CA0199.outlook.office365.com (2603:10a6:10:4b6::28) 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:43:18 +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:43:18 +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 29/86] net/ntnic: add QSL module Date: Tue, 29 Oct 2024 17:41:33 +0100 Message-ID: <20241029164243.1648775-30-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI0P190MB2163:EE_ X-MS-Office365-Filtering-Correlation-Id: 85ea5cba-5fa2-40fd-9a9d-08dcf838cad3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: vNKzrVooJhQtCqHbCysQcT7dhHZUPF7QUrG4o9cn2y+AVQS5T3+zX5Cnth745oTnudsDcdruDfCwpp+NhwQO5FTFuT/bYEupiX3iKy/2pnpAMPoTQV2DvA2zx5JrmxDt61RV9jPbmACKxapSggh9PHOOPY3lB6fAKIV0NmlvnG8bEQILn4uNH/XjTfqFIe5n/SnaNKbsPtg4UnOEFuvfpqjF4AXMbOJFPbiQwUblV0wnnboCZpap8sudgHZ+z0KVyB7fy0B9Rt18dqyHXii++d5yxhBo7uyQbN4VHyUH2+ONE6Vn8Pnc6mOHWXK5dWDUBeix1aKGXHJIXNhZ3sf1LPrbMPF4o1wmKXX6/0yLzOYG3ROYEjmh9KbrHI+YEbbMwZSx25KbPsZIIfv70dHqIOUVsW7kxNs0tV1/KlSnxNapFaHFqGaZ9Qm67ANXm8z5/9xZvpUTk23eGXoty39RNXxfn5X6rld/7jbPBW7FU0A4+iTBDiQxzb0m3n5JP6NXlk36D2k2HFZ+rRCzDRt1NK/JdBS8vuClcIg43wgPuxAuONm4qRU6hcNuH5icw3/WnOx0HLBIteVRTdLrGpL9vzXkOTXJF5oxk6uwRg7OLhC0DUesws7vSBRc7prZs9jUBWVGvQqF0rkwPKr6V4MwEgzlLS5D+26v0TAVs0JazQxgJGepNASez6BtVfvqnCFsTG1NgMcRMJWahdbnkMpDqfz+Evg7uUTYiFbs8bk1UzGlhgC3BnGcIW6dLBA0zjA42MMYecDG8URC8L0PzPqhVF7II2GqzecbEcRdLTZNk0hTWRHO80FFn4HlPydE2cMfn9Dm323XMlePSf/1SsnRmPvp2ElMI0iUfwghbKX7Rhh/S+99Mv2da/gjOOyk4QAxhQeZ2tMT4gqStw5yqDw9YrnzdBXR7R3VdBhpkfYWaNrlIbrLdwrWcnzA/kvoNjDgxfGUip9GA1UKmZSxLYuzv4RfUJY88wpddYXtXfHgPO3nYDTyI7dFTPuVKJq+M7Tfuexu2NuYPvW3oSykV4usY1MmKueW8MadbTNTy40OBRnjTG3lIwl2AWuogYiwS5vvFkNbLnDeCGVmWEA7BmoCY78fAe3SkPlx1MfzT5i/xkAUaj2AXzk2fy/osWo8ojRtJ1stzVtzP7IrqKNhaZnfuQFxihfgTvfgzIcpkakiSQSw1Iv6KhnoSr2qabD97YxTK/q+knVJMIUW1qBykIveRafQujKZuAGwjD74wqgHNEwJ93X3iW77qNVgodV5DvnNX2RVssIXdLCjMYgxewl0i1Aht820D/8eFYwNSpUxf6oKV/j6j9SCzUhXJlk3eAE3XZo12fUl0kE0BDAGPy6YOK/9CgyL9ENNN8wpZEMSlX1yY8RlPV/zzGsf2SAtTp3EfR+azMB2rzo2JTPcgGyCrg== 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aJIzJ7QhdB1vV/7sKuNRSFeCGxHbdwtH73iaT2V5TFiW8mE8dw/VXCLOcwDR6Xk1/iok5TeHEf3oQXF3yuEKerzeFLUZ94TkpwCdbJ8aew+LTMMT3R/7e+RbozBbb/oljzlBwdNR2hDdmw/4ysE0D0L3K/aEAjpPNF6W8H8iLPJtKTLxmTRrkiYogpZqJ5EAg8E7R44jfdsiPdKXN7LJrraXkg4aefKChmUjuzj6s+cODhSxU2RQYeZc0cT6t/UOD8QXlt2mYfwXl0zH4jX5STBwTKZYrSVt8wK65CQONAJwLJpfzTikUjjgd0+WDZVq/QKirgSGRBzed3bbWFbnT46cE9YSjA3X19m9G1tfsw5HyDnQaawQJ0ipsGqXGUghRgoPeappyruvNjOnlW2DwB1ISKjeU9gp9Z/VqA6qt/jkGF8rGT5y2Q8WMdgJ0tHwWMnYGV+XBD4Yal3im7RCLjqQsFr5sImF5NAos4UZ3poiez42XmNyzSyGymEF0pkz15Hwsv5IRyYMa03lxrH/dfAGVfsITOjY6VFFlbz7b8Aq9hRDA21Uu4A2KOg/O4ZeMtYr5qVn4/ZJbszCmwEGSsjPwheFeXEIiTNOU52rdcEQYEGaYhfw+slolfnLJ4FLpTq8ibah2R1wWyDDxL9kcJ3DkQdBBIW8g5Dc8BPQZHQ= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:18.0427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85ea5cba-5fa2-40fd-9a9d-08dcf838cad3 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: VI0P190MB2163 X-BESS-ID: 1730220207-311207-12673-27844-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbmBiYWQGYGUNTQzNzU0sLSNM Uw2czSxCDJNCklMdnE1NzcLDnRLNUwVak2FgBbaFJiQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-215.eu-central-1b.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 The Queue Selector module directs packets to a given destination which includes host queues, physical ports, exceptions paths, and discard. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api.h | 3 + drivers/net/ntnic/include/hw_mod_backend.h | 8 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 65 ++++++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_qsl.c | 218 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 195 ++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 11 + .../profile_inline/flow_api_profile_inline.c | 96 +++++++- 7 files changed, 595 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 7f031ccda8..edffd0a57a 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -184,8 +184,11 @@ extern const char *dbg_res_descr[]; int flow_nic_alloc_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, uint32_t alignment); +int flow_nic_alloc_resource_config(struct flow_nic_dev *ndev, enum res_type_e res_type, + unsigned int num, uint32_t alignment); void flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int idx); +int flow_nic_ref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index); int flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index); #endif diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 7f1449d8ee..6fa2a3d94f 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -666,8 +666,16 @@ int hw_mod_qsl_alloc(struct flow_api_backend_s *be); void hw_mod_qsl_free(struct flow_api_backend_s *be); int hw_mod_qsl_reset(struct flow_api_backend_s *be); int hw_mod_qsl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_qsl_rcp_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value); int hw_mod_qsl_qst_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_qsl_qst_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value); int hw_mod_qsl_qen_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_qsl_qen_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value); +int hw_mod_qsl_qen_get(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t *value); int hw_mod_qsl_unmq_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_qsl_unmq_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, uint32_t value); diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 2aee2ee973..a51d621ef9 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -106,11 +106,52 @@ int flow_nic_alloc_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, return -1; } +int flow_nic_alloc_resource_config(struct flow_nic_dev *ndev, enum res_type_e res_type, + unsigned int num, uint32_t alignment) +{ + unsigned int idx_offs; + + for (unsigned int res_idx = 0; res_idx < ndev->res[res_type].resource_count - (num - 1); + res_idx += alignment) { + if (!flow_nic_is_resource_used(ndev, res_type, res_idx)) { + for (idx_offs = 1; idx_offs < num; idx_offs++) + if (flow_nic_is_resource_used(ndev, res_type, res_idx + idx_offs)) + break; + + if (idx_offs < num) + continue; + + /* found a contiguous number of "num" res_type elements - allocate them */ + for (idx_offs = 0; idx_offs < num; idx_offs++) { + flow_nic_mark_resource_used(ndev, res_type, res_idx + idx_offs); + ndev->res[res_type].ref[res_idx + idx_offs] = 1; + } + + return res_idx; + } + } + + return -1; +} + void flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int idx) { flow_nic_mark_resource_unused(ndev, res_type, idx); } +int flow_nic_ref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index) +{ + NT_LOG(DBG, FILTER, "Reference resource %s idx %i (before ref cnt %i)", + dbg_res_descr[res_type], index, ndev->res[res_type].ref[index]); + assert(flow_nic_is_resource_used(ndev, res_type, index)); + + if (ndev->res[res_type].ref[index] == (uint32_t)-1) + return -1; + + ndev->res[res_type].ref[index]++; + return 0; +} + int flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index) { NT_LOG(DBG, FILTER, "De-reference resource %s idx %i (before ref cnt %i)", @@ -348,6 +389,18 @@ int flow_delete_eth_dev(struct flow_eth_dev *eth_dev) hw_mod_qsl_unmq_set(&ndev->be, HW_QSL_UNMQ_EN, eth_dev->port, 0); hw_mod_qsl_unmq_flush(&ndev->be, eth_dev->port, 1); + if (ndev->flow_profile == FLOW_ETH_DEV_PROFILE_INLINE) { + for (int i = 0; i < eth_dev->num_queues; ++i) { + uint32_t qen_value = 0; + uint32_t queue_id = (uint32_t)eth_dev->rx_queue[i].hw_id; + + hw_mod_qsl_qen_get(&ndev->be, HW_QSL_QEN_EN, queue_id / 4, &qen_value); + hw_mod_qsl_qen_set(&ndev->be, HW_QSL_QEN_EN, queue_id / 4, + qen_value & ~(1U << (queue_id % 4))); + hw_mod_qsl_qen_flush(&ndev->be, queue_id / 4, 1); + } + } + #ifdef FLOW_DEBUG ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); #endif @@ -580,6 +633,18 @@ static struct flow_eth_dev *flow_get_eth_dev(uint8_t adapter_no, uint8_t port_no eth_dev->rss_target_id = -1; + if (flow_profile == FLOW_ETH_DEV_PROFILE_INLINE) { + for (i = 0; i < eth_dev->num_queues; i++) { + uint32_t qen_value = 0; + uint32_t queue_id = (uint32_t)eth_dev->rx_queue[i].hw_id; + + hw_mod_qsl_qen_get(&ndev->be, HW_QSL_QEN_EN, queue_id / 4, &qen_value); + hw_mod_qsl_qen_set(&ndev->be, HW_QSL_QEN_EN, queue_id / 4, + qen_value | (1 << (queue_id % 4))); + hw_mod_qsl_qen_flush(&ndev->be, queue_id / 4, 1); + } + } + *rss_target_id = eth_dev->rss_target_id; nic_insert_eth_port_dev(ndev, eth_dev); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_qsl.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_qsl.c index 93b37d595e..70fe97a298 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_qsl.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_qsl.c @@ -104,6 +104,114 @@ int hw_mod_qsl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->qsl_rcp_flush(be->be_dev, &be->qsl, start_idx, count); } +static int hw_mod_qsl_rcp_mod(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t *value, int get) +{ + if (index >= be->qsl.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 7: + switch (field) { + case HW_QSL_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->qsl.v7.rcp[index], (uint8_t)*value, + sizeof(struct qsl_v7_rcp_s)); + break; + + case HW_QSL_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->qsl.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->qsl.v7.rcp, struct qsl_v7_rcp_s, index, *value, + be->qsl.nb_rcp_categories); + break; + + case HW_QSL_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->qsl.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->qsl.v7.rcp, struct qsl_v7_rcp_s, index, *value); + break; + + case HW_QSL_RCP_DISCARD: + GET_SET(be->qsl.v7.rcp[index].discard, value); + break; + + case HW_QSL_RCP_DROP: + GET_SET(be->qsl.v7.rcp[index].drop, value); + break; + + case HW_QSL_RCP_TBL_LO: + GET_SET(be->qsl.v7.rcp[index].tbl_lo, value); + break; + + case HW_QSL_RCP_TBL_HI: + GET_SET(be->qsl.v7.rcp[index].tbl_hi, value); + break; + + case HW_QSL_RCP_TBL_IDX: + GET_SET(be->qsl.v7.rcp[index].tbl_idx, value); + break; + + case HW_QSL_RCP_TBL_MSK: + GET_SET(be->qsl.v7.rcp[index].tbl_msk, value); + break; + + case HW_QSL_RCP_LR: + GET_SET(be->qsl.v7.rcp[index].lr, value); + break; + + case HW_QSL_RCP_TSA: + GET_SET(be->qsl.v7.rcp[index].tsa, value); + break; + + case HW_QSL_RCP_VLI: + GET_SET(be->qsl.v7.rcp[index].vli, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_qsl_rcp_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_qsl_rcp_mod(be, field, index, &value, 0); +} + int hw_mod_qsl_qst_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -117,6 +225,73 @@ int hw_mod_qsl_qst_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->qsl_qst_flush(be->be_dev, &be->qsl, start_idx, count); } +static int hw_mod_qsl_qst_mod(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t *value, int get) +{ + if (index >= be->qsl.nb_qst_entries) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 7: + switch (field) { + case HW_QSL_QST_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->qsl.v7.qst[index], (uint8_t)*value, + sizeof(struct qsl_v7_qst_s)); + break; + + case HW_QSL_QST_QUEUE: + GET_SET(be->qsl.v7.qst[index].queue, value); + break; + + case HW_QSL_QST_EN: + GET_SET(be->qsl.v7.qst[index].en, value); + break; + + case HW_QSL_QST_TX_PORT: + GET_SET(be->qsl.v7.qst[index].tx_port, value); + break; + + case HW_QSL_QST_LRE: + GET_SET(be->qsl.v7.qst[index].lre, value); + break; + + case HW_QSL_QST_TCI: + GET_SET(be->qsl.v7.qst[index].tci, value); + break; + + case HW_QSL_QST_VEN: + GET_SET(be->qsl.v7.qst[index].ven, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_qsl_qst_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_qsl_qst_mod(be, field, index, &value, 0); +} + int hw_mod_qsl_qen_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -130,6 +305,49 @@ int hw_mod_qsl_qen_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->qsl_qen_flush(be->be_dev, &be->qsl, start_idx, count); } +static int hw_mod_qsl_qen_mod(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t *value, int get) +{ + if (index >= QSL_QEN_ENTRIES) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 7: + switch (field) { + case HW_QSL_QEN_EN: + GET_SET(be->qsl.v7.qen[index].en, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_qsl_qen_set(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_qsl_qen_mod(be, field, index, &value, 0); +} + +int hw_mod_qsl_qen_get(struct flow_api_backend_s *be, enum hw_qsl_e field, uint32_t index, + uint32_t *value) +{ + return hw_mod_qsl_qen_mod(be, field, index, value, 1); +} + int hw_mod_qsl_unmq_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index b17bce3745..5572662647 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -20,12 +20,18 @@ struct hw_db_inline_resource_db { int ref; } *cot; + struct hw_db_inline_resource_db_qsl { + struct hw_db_inline_qsl_data data; + int qst_idx; + } *qsl; + struct hw_db_inline_resource_db_slc_lr { struct hw_db_inline_slc_lr_data data; int ref; } *slc_lr; uint32_t nb_cot; + uint32_t nb_qsl; uint32_t nb_slc_lr; /* Items */ @@ -61,6 +67,14 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_qsl = ndev->be.qsl.nb_rcp_categories; + db->qsl = calloc(db->nb_qsl, sizeof(struct hw_db_inline_resource_db_qsl)); + + if (db->qsl == NULL) { + hw_db_inline_destroy(db); + return -1; + } + db->nb_slc_lr = ndev->be.max_categories; db->slc_lr = calloc(db->nb_slc_lr, sizeof(struct hw_db_inline_resource_db_slc_lr)); @@ -86,6 +100,7 @@ void hw_db_inline_destroy(void *db_handle) struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; free(db->cot); + free(db->qsl); free(db->slc_lr); free(db->cat); @@ -110,6 +125,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_QSL: + hw_db_inline_qsl_deref(ndev, db_handle, *(struct hw_db_qsl_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_SLC_LR: hw_db_inline_slc_lr_deref(ndev, db_handle, *(struct hw_db_slc_lr_idx *)&idxs[i]); @@ -145,6 +164,13 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; (void)offset; + /* QSL for traffic policing */ + if (hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_DROP, qsl_hw_id, 0x3) < 0) + return -1; + + if (hw_mod_qsl_rcp_flush(&ndev->be, qsl_hw_id, 1) < 0) + return -1; + /* Select and enable QSL recipe */ if (hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 1, qsl_hw_id)) return -1; @@ -255,6 +281,175 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_han } } +/******************************************************************************/ +/* QSL */ +/******************************************************************************/ + +/* Calculate queue mask for QSL TBL_MSK for given number of queues. + * NOTE: If number of queues is not power of two, then queue mask will be created + * for nearest smaller power of two. + */ +static uint32_t queue_mask(uint32_t nr_queues) +{ + nr_queues |= nr_queues >> 1; + nr_queues |= nr_queues >> 2; + nr_queues |= nr_queues >> 4; + nr_queues |= nr_queues >> 8; + nr_queues |= nr_queues >> 16; + return nr_queues >> 1; +} + +static int hw_db_inline_qsl_compare(const struct hw_db_inline_qsl_data *data1, + const struct hw_db_inline_qsl_data *data2) +{ + if (data1->discard != data2->discard || data1->drop != data2->drop || + data1->table_size != data2->table_size || data1->retransmit != data2->retransmit) { + return 0; + } + + for (int i = 0; i < HW_DB_INLINE_MAX_QST_PER_QSL; ++i) { + if (data1->table[i].queue != data2->table[i].queue || + data1->table[i].queue_en != data2->table[i].queue_en || + data1->table[i].tx_port != data2->table[i].tx_port || + data1->table[i].tx_port_en != data2->table[i].tx_port_en) { + return 0; + } + } + + return 1; +} + +struct hw_db_qsl_idx hw_db_inline_qsl_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_qsl_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_qsl_idx qsl_idx = { .raw = 0 }; + uint32_t qst_idx = 0; + int res; + + qsl_idx.type = HW_DB_IDX_TYPE_QSL; + + if (data->discard) { + qsl_idx.ids = 0; + return qsl_idx; + } + + for (uint32_t i = 1; i < db->nb_qsl; ++i) { + if (hw_db_inline_qsl_compare(data, &db->qsl[i].data)) { + qsl_idx.ids = i; + hw_db_inline_qsl_ref(ndev, db, qsl_idx); + return qsl_idx; + } + } + + res = flow_nic_alloc_resource(ndev, RES_QSL_RCP, 1); + + if (res < 0) { + qsl_idx.error = 1; + return qsl_idx; + } + + qsl_idx.ids = res & 0xff; + + if (data->table_size > 0) { + res = flow_nic_alloc_resource_config(ndev, RES_QSL_QST, data->table_size, 1); + + if (res < 0) { + flow_nic_deref_resource(ndev, RES_QSL_RCP, qsl_idx.ids); + qsl_idx.error = 1; + return qsl_idx; + } + + qst_idx = (uint32_t)res; + } + + memcpy(&db->qsl[qsl_idx.ids].data, data, sizeof(struct hw_db_inline_qsl_data)); + db->qsl[qsl_idx.ids].qst_idx = qst_idx; + + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_PRESET_ALL, qsl_idx.ids, 0x0); + + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_DISCARD, qsl_idx.ids, data->discard); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_DROP, qsl_idx.ids, data->drop * 0x3); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_LR, qsl_idx.ids, data->retransmit * 0x3); + + if (data->table_size == 0) { + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_LO, qsl_idx.ids, 0x0); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_HI, qsl_idx.ids, 0x0); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_IDX, qsl_idx.ids, 0x0); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_MSK, qsl_idx.ids, 0x0); + + } else { + const uint32_t table_start = qst_idx; + const uint32_t table_end = table_start + data->table_size - 1; + + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_LO, qsl_idx.ids, table_start); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_HI, qsl_idx.ids, table_end); + + /* Toeplitz hash function uses TBL_IDX and TBL_MSK. */ + uint32_t msk = queue_mask(table_end - table_start + 1); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_IDX, qsl_idx.ids, table_start); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_TBL_MSK, qsl_idx.ids, msk); + + for (uint32_t i = 0; i < data->table_size; ++i) { + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_PRESET_ALL, table_start + i, 0x0); + + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_TX_PORT, table_start + i, + data->table[i].tx_port); + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_LRE, table_start + i, + data->table[i].tx_port_en); + + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_QUEUE, table_start + i, + data->table[i].queue); + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_EN, table_start + i, + data->table[i].queue_en); + } + + hw_mod_qsl_qst_flush(&ndev->be, table_start, data->table_size); + } + + hw_mod_qsl_rcp_flush(&ndev->be, qsl_idx.ids, 1); + + return qsl_idx; +} + +void hw_db_inline_qsl_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_qsl_idx idx) +{ + (void)db_handle; + + if (!idx.error && idx.ids != 0) + flow_nic_ref_resource(ndev, RES_QSL_RCP, idx.ids); +} + +void hw_db_inline_qsl_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_qsl_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error || idx.ids == 0) + return; + + if (flow_nic_deref_resource(ndev, RES_QSL_RCP, idx.ids) == 0) { + const int table_size = (int)db->qsl[idx.ids].data.table_size; + + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_PRESET_ALL, idx.ids, 0x0); + hw_mod_qsl_rcp_flush(&ndev->be, idx.ids, 1); + + if (table_size > 0) { + const int table_start = db->qsl[idx.ids].qst_idx; + + for (int i = 0; i < (int)table_size; ++i) { + hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_PRESET_ALL, + table_start + i, 0x0); + flow_nic_free_resource(ndev, RES_QSL_QST, table_start + i); + } + + hw_mod_qsl_qst_flush(&ndev->be, table_start, table_size); + } + + memset(&db->qsl[idx.ids].data, 0x0, sizeof(struct hw_db_inline_qsl_data)); + db->qsl[idx.ids].qst_idx = 0; + } +} + /******************************************************************************/ /* SLC_LR */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index ef63336b1c..d0435acaef 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -36,6 +36,10 @@ struct hw_db_cot_idx { HW_DB_IDX; }; +struct hw_db_qsl_idx { + HW_DB_IDX; +}; + struct hw_db_cat_idx { HW_DB_IDX; }; @@ -48,6 +52,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, HW_DB_IDX_TYPE_CAT, + HW_DB_IDX_TYPE_QSL, HW_DB_IDX_TYPE_SLC_LR, }; @@ -113,6 +118,7 @@ struct hw_db_inline_action_set_data { int jump; struct { struct hw_db_cot_idx cot; + struct hw_db_qsl_idx qsl; }; }; }; @@ -131,6 +137,11 @@ struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_ha void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); +struct hw_db_qsl_idx hw_db_inline_qsl_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_qsl_data *data); +void hw_db_inline_qsl_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_qsl_idx idx); +void hw_db_inline_qsl_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_qsl_idx idx); + struct hw_db_slc_lr_idx hw_db_inline_slc_lr_add(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_slc_lr_data *data); void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, 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 405d87f632..999b1ed985 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 @@ -2276,9 +2276,55 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d return 0; } + +static void setup_db_qsl_data(struct nic_flow_def *fd, struct hw_db_inline_qsl_data *qsl_data, + uint32_t num_dest_port, uint32_t num_queues) +{ + memset(qsl_data, 0x0, sizeof(struct hw_db_inline_qsl_data)); + + if (fd->dst_num_avail <= 0) { + qsl_data->drop = 1; + + } else { + assert(fd->dst_num_avail < HW_DB_INLINE_MAX_QST_PER_QSL); + + uint32_t ports[fd->dst_num_avail]; + uint32_t queues[fd->dst_num_avail]; + + uint32_t port_index = 0; + uint32_t queue_index = 0; + uint32_t max = num_dest_port > num_queues ? num_dest_port : num_queues; + + memset(ports, 0, fd->dst_num_avail); + memset(queues, 0, fd->dst_num_avail); + + qsl_data->table_size = max; + qsl_data->retransmit = num_dest_port > 0 ? 1 : 0; + + for (int i = 0; i < fd->dst_num_avail; ++i) + if (fd->dst_id[i].type == PORT_PHY) + ports[port_index++] = fd->dst_id[i].id; + + else if (fd->dst_id[i].type == PORT_VIRT) + queues[queue_index++] = fd->dst_id[i].id; + + for (uint32_t i = 0; i < max; ++i) { + if (num_dest_port > 0) { + qsl_data->table[i].tx_port = ports[i % num_dest_port]; + qsl_data->table[i].tx_port_en = 1; + } + + if (num_queues > 0) { + qsl_data->table[i].queue = queues[i % num_queues]; + qsl_data->table[i].queue_en = 1; + } + } + } +} + static int setup_flow_flm_actions(struct flow_eth_dev *dev, const struct nic_flow_def *fd, - const struct hw_db_inline_qsl_data *qsl_data __rte_unused, + const struct hw_db_inline_qsl_data *qsl_data, const struct hw_db_inline_hsh_data *hsh_data __rte_unused, uint32_t group __rte_unused, uint32_t local_idxs[], @@ -2288,6 +2334,17 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, uint32_t *flm_scrub __rte_unused, struct rte_flow_error *error) { + /* Finalize QSL */ + struct hw_db_qsl_idx qsl_idx = + hw_db_inline_qsl_add(dev->ndev, dev->ndev->hw_db_handle, qsl_data); + local_idxs[(*local_idx_counter)++] = qsl_idx.raw; + + if (qsl_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference QSL resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + /* Setup SLC LR */ struct hw_db_slc_lr_idx slc_lr_idx = { .raw = 0 }; @@ -2328,6 +2385,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n fh->caller_id = caller_id; 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; @@ -2398,6 +2456,19 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); goto error_out; } + + /* Finalize QSL */ + struct hw_db_qsl_idx qsl_idx = + hw_db_inline_qsl_add(dev->ndev, dev->ndev->hw_db_handle, + &qsl_data); + fh->db_idxs[fh->db_idx_counter++] = qsl_idx.raw; + action_set_data.qsl = qsl_idx; + + if (qsl_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference QSL resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } } /* Setup CAT */ @@ -2469,6 +2540,24 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) if (hw_mod_cat_cot_flush(&ndev->be, 0, 1) < 0) goto err_exit0; + /* Initialize QSL with unmatched recipe index 0 - discard */ + if (hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_DISCARD, 0, 0x1) < 0) + goto err_exit0; + + if (hw_mod_qsl_rcp_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + flow_nic_mark_resource_used(ndev, RES_QSL_RCP, 0); + + /* Initialize QST with default index 0 */ + if (hw_mod_qsl_qst_set(&ndev->be, HW_QSL_QST_PRESET_ALL, 0, 0x0) < 0) + goto err_exit0; + + if (hw_mod_qsl_qst_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + flow_nic_mark_resource_used(ndev, RES_QSL_QST, 0); + /* SLC LR index 0 is reserved */ flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); @@ -2487,6 +2576,7 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); + flow_nic_mark_resource_used(ndev, RES_QSL_RCP, NT_VIOLATING_MBR_QSL); if (hw_db_inline_setup_mbr_filter(ndev, NT_VIOLATING_MBR_CFN, NT_FLM_VIOLATING_MBR_FLOW_TYPE, @@ -2533,6 +2623,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) hw_mod_cat_cot_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_CAT_CFN, 0); + hw_mod_qsl_rcp_set(&ndev->be, HW_QSL_RCP_PRESET_ALL, 0, 0); + hw_mod_qsl_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_QSL_RCP, 0); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_PRESET_ALL, 0, 0); hw_mod_slc_lr_rcp_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_SLC_LR_RCP, 0); From patchwork Tue Oct 29 16:41:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147634 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C8E345BC0; Tue, 29 Oct 2024 17:46:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5129842F2F; Tue, 29 Oct 2024 17:44:14 +0100 (CET) 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 5035D42EF0 for ; Tue, 29 Oct 2024 17:43:28 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2107.outbound.protection.outlook.com [104.47.18.107]) 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 16:43:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nUmG6QEIAynhJ+5ebLOIS74JuloT43XEykrx0VYGjnkDdrpBc/SczcT1iv4LXgwLuqO+0CWttGGHQPxTKKPpkwjjNWT7M2lyGmnDOd68KgT8yj/UtLNP3XBxIJ3wQk8XjfBx7nqlRzrXGHx/sGY+ZA22qDEgm0yduLJThYkNVqb7Kn0uNLRnbyqSj6rcq+MmabVNeXT/WgngdgKFEq/68pDTqk8oqRdguzSSVHQc8zaklIC3ujN9ILrQYOjVi3/bm7ica172fDA6BMJhaUIXjWKpb/6z8Cz39fKxJBRTdmnYmOym30L/kwmuCovCefZ5Bg8LHaXO9JSjOJklX1w32w== 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=Ybn2NarjqJnk+I1R7a9c+tlc1G9qAj+CN5C0LupgKgc=; b=o6OCzPALPBdXLphLWGdTZrvRdUcyWeGwhMySrFDNOOZccY+rP1Kaz1mRnx+s2zcrSGPc5S6jyvgIEG9dxa5Q8qXcLTOPF4rxICOsjEN2En6QM9l807rkNFzsWDUJPXa1WtjzBb+Q04CJEaHkkpqgmvUiFbrLRPfegJssCIp1MA76PAbWyrx/pLIE3ahAQCmsG45mgxV7k4OZPtKmkZ6UETZ9Fj8llpopHeJfVg/SRnJ++enO3X3MbHjLebx+ryfGDg4chJD0TQsVDzy6MaXOgqXdjifVbOXFSVJfccthfW63eJCQDSBJDteJwuvCySYy1R1xqH/YlrldMOGa3m/FFg== 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=Ybn2NarjqJnk+I1R7a9c+tlc1G9qAj+CN5C0LupgKgc=; b=ULE86TjT6Dzg9gKZ9bFvWTANUzeMc+Kep/yHkAquBQn/6puQiv99et/3UELAkOUNkV9GFqfWEmLpNJ2raGsq1XPxrR6qNDD5avYv9FgVmp63XdD03OmyZR6s9f0MejF/B6q8rEo+h0CA5Rhkr3sDQ8z6n/iMvPicFWi+zehOLEM= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by VI1P190MB0637.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:19 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::f7) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:43:19 +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:43:19 +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 30/86] net/ntnic: add KM module Date: Tue, 29 Oct 2024 17:41:34 +0100 Message-ID: <20241029164243.1648775-31-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI1P190MB0637:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bb30224-00f6-45d8-cd52-08dcf838cb88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: Y5liCjFDYA1Ou7/G0gqLnN/FkKc/nKJIrRYAuZGEdO2jVHgBifvfwbmuPuiAb5NCMlpSXYx3IMSdt5dgyXmZoWkP9ili6yadHrR9ORgmFqG/5ebUs/z4+mSFo8FgG7GWk7hKBNGscHIUWs1bkGBLhWsHqE3KhZQnhIA42qG/iCK7uRr3sGQtLIJHBAEJtZ9TFPeVSHLmfSl+59B/wGI0QoSLXDj3r82v9Zym1xyZZ8o/OVXA6knkwEd+9DnBoez8MIMWY9+fXJYOtR9/9ZUoSOr/YLbnfqM0vlObdP4lXGeuVKwVoUSMnY+2fJJuiX0vk+bYixTelJVDU+njXBgaLp7AJnb9v/pznLFCbzHr5S+E4N1IP0LftRKSdJ/2NqrauGdTxFrV9k7jZYaXiH2TwaR/nObwXN1a+9dXKvi1y4Z8Awor/NmXSVMmptqn3Gh4qLItymOiJ9xNwuKEHtvOVSMnDo/UrSGAbVj0YpZGC9VS4MOQQrAi8kkEsl6Sb/ulne5NqYpg1pplLuumGbRYLHBvsiHhYhAvBM7FcWmnA2PfesQNYsB/LTBZaAtVLCrDetsDM11LYFGunjakYiAUwRA0tkzpo35rrac7oQAEODxrv1O8rgi+blO9ghoeHdlR3TVqAA0wwvazyg7MSIwtxV7jtFq9J17LX4FiV0u7Hje4uXpYAoshNE10+VkN3YWzqhdoyQCKfRMLaAHX8hqzWjt5p0iYz4npZNBsZ8bveJsCXQQhEnz8iUrYQHDwjzOsmV6coJ7k4bVyxBqb4okhipexqMcuvMSepdZA/zwGnECCuENuQM1VeAXF7/5DJwj4oyKVHXgnLQwWLNzq12JuAlorPhx2SyyHwpETwgIH5O4xYcHufaYuYzCh7GmSvPKUNPHnnjBEoJcFgavbKGOY4mER+B15SpQldf4Hpw/yMBQFzelmPynGmiGRijI5Hm7QaI+zT9AD7fA7Qz2sWBNa8d//kjgxO5Zwpa6YxabpvXiWD2OeFN81ZYH7tSPt0MQ0P1V7A5fKF9W6lSffS1U2rFKeIZhjvSfsDQHoM4BOl7kGO65+PcFiMrZwzEex3/rD44wNH1gfrSd9BydhWdfok3LOmH7jVGIMh0Lz3lCwl7pFltYo8tjpJAW2ySih8s2C2yzWw9+m4qiStWvIB8qkKSnXD/3T5GhWyL0HajtRyY3lajAdDM2rQvKWpdnv0R+qDS5opTcuW/hiokJa4O9jHPpE054YaQ8/sZ6UgqPBBXviOuvmUQy/qJCrXyqXh2ImOSynN8/0VHQWJ+V5NibTQM+E1LlG9lYFLP/ppIOtcACFQGcPLweY+T7DlftlGvsDs87jm1DLPMBdAj8fUGIBda87a6ndpR/9l1JYW3SXqtTPoVz9qNpAygkeQ1rfw9rbB+62t+aWGqh3fkC7Ym4p4g== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WW/nww2AslKKC45hgd1Ea/Msf7Ww5aDNG2VHfEDMhPWcELZkLiotEPBwoDCIhWYinDLZ+WuULh0Vg9Ha4hn3uiPQLUKozJB37bYluauPjKz8uTZpq5I1ttkPBFQ4x8BWz01JhGo1WogT/CthRuwDzjS/HRPQMp9SC1l94I9Yqvgco8cdi3ENyq8BUC/Dl+RkLFiDYgBcZWYZubFQDdzfuqsSzboqipyhsR0c580d8eJROUiidIqtVP7jf71jfZPAO4LeC0GfS1i1rtg86BFlEZEiy+K+hRHTaKYth4wyNB9DWoNSpt1EiCEJLGVfYfT3SPMs6L9issM54JY0nSmUmq4gDgv5zHDasrGIpv+a3QBCYu2Ge78Yx8RVUPnV5AjLcwA0JLdqQIe8FuLABszjgJNA/TjPhQrgVW9RF8asBk/gKuJvdkNvaDo2BDqGmhvaD4+f/FUhjQ+w5c9ROLDuI6+9C4IuioUfzZkbrt+c7vTAmMG+2iWWztkwWBURQJ2EZ9KgOiakRwrCxq9+M/N4z0XP3iLFUQIsSY9ZpmMkTyiT+yfImoRpwQ+pGS7+gRQyVINCy8IIC4NJ0iI1MfFWZwiNKwueJthMeyEG9CVXp02eK7dodEV//4s7vhE4Vu3GfiLBsOju8+HzzjfUVszDDBEXVrMOe5l6yn9J9+HtcFA= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:19.3396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb30224-00f6-45d8-cd52-08dcf838cb88 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: VI1P190MB0637 X-BESS-ID: 1730220202-304438-12709-29914-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmbGpkamQGYGUNQ0KcnA3MzAyD DNwCzJxMDcItU01czQIsXI0DTZ0jjZQqk2FgA+4+/WQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan22-204.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 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_RULE_7582B, 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 The Key Matcher module checks the values of individual fields of a packet. It supports both exact match which is implemented with a CAM, and wildcards which is implemented with a TCAM. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api_engine.h | 110 +- drivers/net/ntnic/include/hw_mod_backend.h | 64 +- drivers/net/ntnic/nthw/flow_api/flow_km.c | 1065 +++++++++++++++++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_km.c | 380 ++++++ .../profile_inline/flow_api_hw_db_inline.c | 234 ++++ .../profile_inline/flow_api_hw_db_inline.h | 38 + .../profile_inline/flow_api_profile_inline.c | 162 +++ 7 files changed, 2024 insertions(+), 29 deletions(-) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index b1d39b919b..a0f02f4e8a 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -52,34 +52,32 @@ enum res_type_e { */ #define MAX_OUTPUT_DEST (128) +#define MAX_WORD_NUM 24 +#define MAX_BANKS 6 + +#define MAX_TCAM_START_OFFSETS 4 + #define MAX_CPY_WRITERS_SUPPORTED 8 #define MAX_MATCH_FIELDS 16 /* - * Tunnel encapsulation header definition + * 128 128 32 32 32 + * Have | QW0 || QW4 || SW8 || SW9 | SWX in FPGA + * + * Each word may start at any offset, though + * they are combined in chronological order, with all enabled to + * build the extracted match data, thus that is how the match key + * must be build */ -#define MAX_TUN_HDR_SIZE 128 -struct tunnel_header_s { - union { - uint8_t hdr8[MAX_TUN_HDR_SIZE]; - uint32_t hdr32[(MAX_TUN_HDR_SIZE + 3) / 4]; - } d; - uint32_t user_port_id; - uint8_t len; - - uint8_t nb_vlans; - - uint8_t ip_version; /* 4: v4, 6: v6 */ - uint16_t ip_csum_precalc; - - uint8_t new_outer; - uint8_t l2_len; - uint8_t l3_len; - uint8_t l4_len; +enum extractor_e { + KM_USE_EXTRACTOR_UNDEF, + KM_USE_EXTRACTOR_QWORD, + KM_USE_EXTRACTOR_SWORD, }; struct match_elem_s { + enum extractor_e extr; int masked_for_tcam; /* if potentially selected for TCAM */ uint32_t e_word[4]; uint32_t e_mask[4]; @@ -89,16 +87,76 @@ struct match_elem_s { uint32_t word_len; }; +enum cam_tech_use_e { + KM_CAM, + KM_TCAM, + KM_SYNERGY +}; + struct km_flow_def_s { struct flow_api_backend_s *be; + /* For keeping track of identical entries */ + struct km_flow_def_s *reference; + struct km_flow_def_s *root; + /* For collect flow elements and sorting */ struct match_elem_s match[MAX_MATCH_FIELDS]; + struct match_elem_s *match_map[MAX_MATCH_FIELDS]; int num_ftype_elem; + /* Finally formatted CAM/TCAM entry */ + enum cam_tech_use_e target; + uint32_t entry_word[MAX_WORD_NUM]; + uint32_t entry_mask[MAX_WORD_NUM]; + int key_word_size; + + /* TCAM calculated possible bank start offsets */ + int start_offsets[MAX_TCAM_START_OFFSETS]; + int num_start_offsets; + /* Flow information */ /* HW input port ID needed for compare. In port must be identical on flow types */ uint32_t port_id; + uint32_t info; /* used for color (actions) */ + int info_set; + int flow_type; /* 0 is illegal and used as unset */ + int flushed_to_target; /* if this km entry has been finally programmed into NIC hw */ + + /* CAM specific bank management */ + int cam_paired; + int record_indexes[MAX_BANKS]; + int bank_used; + uint32_t *cuckoo_moves; /* for CAM statistics only */ + struct cam_distrib_s *cam_dist; + + /* TCAM specific bank management */ + struct tcam_distrib_s *tcam_dist; + int tcam_start_bank; + int tcam_record; +}; + +/* + * Tunnel encapsulation header definition + */ +#define MAX_TUN_HDR_SIZE 128 + +struct tunnel_header_s { + union { + uint8_t hdr8[MAX_TUN_HDR_SIZE]; + uint32_t hdr32[(MAX_TUN_HDR_SIZE + 3) / 4]; + } d; + + uint8_t len; + + uint8_t nb_vlans; + + uint8_t ip_version; /* 4: v4, 6: v6 */ + + uint8_t new_outer; + uint8_t l2_len; + uint8_t l3_len; + uint8_t l4_len; }; enum flow_port_type_e { @@ -247,11 +305,25 @@ struct flow_handle { }; }; +void km_attach_ndev_resource_management(struct km_flow_def_s *km, void **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); +int km_key_create(struct km_flow_def_s *km, uint32_t port_id); +/* + * Compares 2 KM key definitions after first collect validate and optimization. + * km is compared against an existing km1. + * if identical, km1 flow_type is returned + */ +int km_key_compare(struct km_flow_def_s *km, struct km_flow_def_s *km1); + +int km_rcp_set(struct km_flow_def_s *km, int index); + +int km_write_data_match_entry(struct km_flow_def_s *km, uint32_t color); +int km_clear_data_match_entry(struct km_flow_def_s *km); + 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 6fa2a3d94f..26903f2183 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -132,6 +132,22 @@ static inline int is_non_zero(const void *addr, size_t n) return 0; } +/* Sideband info bit indicator */ +#define SWX_INFO (1 << 6) + +enum km_flm_if_select_e { + KM_FLM_IF_FIRST = 0, + KM_FLM_IF_SECOND = 1 +}; + +#define FIELD_START_INDEX 100 + +#define COMMON_FUNC_INFO_S \ + int ver; \ + void *base; \ + unsigned int alloced_size; \ + int debug + enum frame_offs_e { DYN_L2 = 1, DYN_FIRST_VLAN = 2, @@ -141,22 +157,39 @@ enum frame_offs_e { DYN_TUN_L3 = 13, DYN_TUN_L4 = 16, DYN_TUN_L4_PAYLOAD = 17, + SB_VNI = SWX_INFO | 1, + SB_MAC_PORT = SWX_INFO | 2, + SB_KCC_ID = SWX_INFO | 3 }; -/* Sideband info bit indicator */ +enum { + QW0_SEL_EXCLUDE = 0, + QW0_SEL_FIRST32 = 1, + QW0_SEL_FIRST64 = 3, + QW0_SEL_ALL128 = 4, +}; -enum km_flm_if_select_e { - KM_FLM_IF_FIRST = 0, - KM_FLM_IF_SECOND = 1 +enum { + QW4_SEL_EXCLUDE = 0, + QW4_SEL_FIRST32 = 1, + QW4_SEL_FIRST64 = 2, + QW4_SEL_ALL128 = 3, }; -#define FIELD_START_INDEX 100 +enum { + DW8_SEL_EXCLUDE = 0, + DW8_SEL_FIRST32 = 3, +}; -#define COMMON_FUNC_INFO_S \ - int ver; \ - void *base; \ - unsigned int alloced_size; \ - int debug +enum { + DW10_SEL_EXCLUDE = 0, + DW10_SEL_FIRST32 = 2, +}; + +enum { + SWX_SEL_EXCLUDE = 0, + SWX_SEL_ALL32 = 1, +}; enum { PROT_OTHER = 0, @@ -440,13 +473,24 @@ int hw_mod_km_alloc(struct flow_api_backend_s *be); void hw_mod_km_free(struct flow_api_backend_s *be); int hw_mod_km_reset(struct flow_api_backend_s *be); int hw_mod_km_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_km_rcp_set(struct flow_api_backend_s *be, enum hw_km_e field, int index, int word_off, + uint32_t value); +int hw_mod_km_rcp_get(struct flow_api_backend_s *be, enum hw_km_e field, int index, int word_off, + uint32_t *value); int hw_mod_km_cam_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count); +int hw_mod_km_cam_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int record, + uint32_t value); + int hw_mod_km_tcam_flush(struct flow_api_backend_s *be, int start_bank, int count); int hw_mod_km_tcam_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int byte, int byte_val, uint32_t *value_set); +int hw_mod_km_tcam_get(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int byte, + int byte_val, uint32_t *value_set); int hw_mod_km_tci_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count); +int hw_mod_km_tci_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int record, + uint32_t value); int hw_mod_km_tcq_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c index 237e9f7b4e..30d6ea728e 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_km.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c @@ -10,8 +10,34 @@ #include "flow_api_engine.h" #include "nt_util.h" +#define MAX_QWORDS 2 +#define MAX_SWORDS 2 + +#define CUCKOO_MOVE_MAX_DEPTH 8 + #define NUM_CAM_MASKS (ARRAY_SIZE(cam_masks)) +#define CAM_DIST_IDX(bnk, rec) ((bnk) * km->be->km.nb_cam_records + (rec)) +#define CAM_KM_DIST_IDX(bnk) \ + ({ \ + int _temp_bnk = (bnk); \ + CAM_DIST_IDX(_temp_bnk, km->record_indexes[_temp_bnk]); \ + }) + +#define TCAM_DIST_IDX(bnk, rec) ((bnk) * km->be->km.nb_tcam_bank_width + (rec)) + +#define CAM_ENTRIES \ + (km->be->km.nb_cam_banks * km->be->km.nb_cam_records * sizeof(struct cam_distrib_s)) +#define TCAM_ENTRIES \ + (km->be->km.nb_tcam_bank_width * km->be->km.nb_tcam_banks * sizeof(struct tcam_distrib_s)) + +/* + * CAM structures and defines + */ +struct cam_distrib_s { + struct km_flow_def_s *km_owner; +}; + static const struct cam_match_masks_s { uint32_t word_len; uint32_t key_mask[4]; @@ -36,6 +62,25 @@ static const struct cam_match_masks_s { { 1, { 0x00300000, 0x00000000, 0x00000000, 0x00000000 } }, }; +static int cam_addr_reserved_stack[CUCKOO_MOVE_MAX_DEPTH]; + +/* + * TCAM structures and defines + */ +struct tcam_distrib_s { + struct km_flow_def_s *km_owner; +}; + +static int tcam_find_mapping(struct km_flow_def_s *km); + +void km_attach_ndev_resource_management(struct km_flow_def_s *km, void **handle) +{ + km->cam_dist = (struct cam_distrib_s *)*handle; + km->cuckoo_moves = (uint32_t *)((char *)km->cam_dist + CAM_ENTRIES); + km->tcam_dist = + (struct tcam_distrib_s *)((char *)km->cam_dist + CAM_ENTRIES + sizeof(uint32_t)); +} + void km_free_ndev_resource_management(void **handle) { if (*handle) { @@ -98,3 +143,1023 @@ int km_add_match_elem(struct km_flow_def_s *km, uint32_t e_word[4], uint32_t e_m km->num_ftype_elem++; return 0; } + +static int get_word(struct km_flow_def_s *km, uint32_t size, int marked[]) +{ + for (int i = 0; i < km->num_ftype_elem; i++) + if (!marked[i] && !(km->match[i].extr_start_offs_id & SWX_INFO) && + km->match[i].word_len == size) + return i; + + return -1; +} + +int km_key_create(struct km_flow_def_s *km, uint32_t port_id) +{ + /* + * Create combined extractor mappings + * if key fields may be changed to cover un-mappable otherwise? + * split into cam and tcam and use synergy mode when available + */ + int match_marked[MAX_MATCH_FIELDS]; + int idx = 0; + int next = 0; + int m_idx; + int size; + + memset(match_marked, 0, sizeof(match_marked)); + + /* build QWords */ + for (int qwords = 0; qwords < MAX_QWORDS; qwords++) { + size = 4; + m_idx = get_word(km, size, match_marked); + + if (m_idx < 0) { + size = 2; + m_idx = get_word(km, size, match_marked); + + if (m_idx < 0) { + size = 1; + m_idx = get_word(km, 1, match_marked); + } + } + + if (m_idx < 0) { + /* no more defined */ + break; + } + + match_marked[m_idx] = 1; + + /* build match map list and set final extractor to use */ + km->match_map[next] = &km->match[m_idx]; + km->match[m_idx].extr = KM_USE_EXTRACTOR_QWORD; + + /* build final entry words and mask array */ + for (int i = 0; i < size; i++) { + km->entry_word[idx + i] = km->match[m_idx].e_word[i]; + km->entry_mask[idx + i] = km->match[m_idx].e_mask[i]; + } + + idx += size; + next++; + } + + m_idx = get_word(km, 4, match_marked); + + if (m_idx >= 0) { + /* cannot match more QWords */ + return -1; + } + + /* + * On km v6+ we have DWORDs here instead. However, we only use them as SWORDs for now + * No match would be able to exploit these as DWORDs because of maximum length of 12 words + * in CAM The last 2 words are taken by KCC-ID/SWX and Color. You could have one or none + * QWORDs where then both these DWORDs were possible in 10 words, but we don't have such + * use case built in yet + */ + /* build SWords */ + for (int swords = 0; swords < MAX_SWORDS; swords++) { + m_idx = get_word(km, 1, match_marked); + + if (m_idx < 0) { + /* no more defined */ + break; + } + + match_marked[m_idx] = 1; + /* build match map list and set final extractor to use */ + km->match_map[next] = &km->match[m_idx]; + km->match[m_idx].extr = KM_USE_EXTRACTOR_SWORD; + + /* build final entry words and mask array */ + km->entry_word[idx] = km->match[m_idx].e_word[0]; + km->entry_mask[idx] = km->match[m_idx].e_mask[0]; + idx++; + next++; + } + + /* + * Make sure we took them all + */ + m_idx = get_word(km, 1, match_marked); + + if (m_idx >= 0) { + /* cannot match more SWords */ + return -1; + } + + /* + * Handle SWX words specially + */ + int swx_found = 0; + + for (int i = 0; i < km->num_ftype_elem; i++) { + if (km->match[i].extr_start_offs_id & SWX_INFO) { + km->match_map[next] = &km->match[i]; + km->match[i].extr = KM_USE_EXTRACTOR_SWORD; + /* build final entry words and mask array */ + km->entry_word[idx] = km->match[i].e_word[0]; + km->entry_mask[idx] = km->match[i].e_mask[0]; + idx++; + next++; + swx_found = 1; + } + } + + assert(next == km->num_ftype_elem); + + km->key_word_size = idx; + km->port_id = port_id; + + km->target = KM_CAM; + + /* + * Finally decide if we want to put this match->action into the TCAM + * When SWX word used we need to put it into CAM always, no matter what mask pattern + * Later, when synergy mode is applied, we can do a split + */ + if (!swx_found && km->key_word_size <= 6) { + for (int i = 0; i < km->num_ftype_elem; i++) { + if (km->match_map[i]->masked_for_tcam) { + /* At least one */ + km->target = KM_TCAM; + } + } + } + + NT_LOG(DBG, FILTER, "This flow goes into %s", (km->target == KM_TCAM) ? "TCAM" : "CAM"); + + if (km->target == KM_TCAM) { + if (km->key_word_size > 10) { + /* do not support SWX in TCAM */ + return -1; + } + + /* + * adjust for unsupported key word size in TCAM + */ + if ((km->key_word_size == 5 || km->key_word_size == 7 || km->key_word_size == 9)) { + km->entry_mask[km->key_word_size] = 0; + km->key_word_size++; + } + + /* + * 1. the fact that the length of a key cannot change among the same used banks + * + * calculate possible start indexes + * unfortunately restrictions in TCAM lookup + * makes it hard to handle key lengths larger than 6 + * when other sizes should be possible too + */ + switch (km->key_word_size) { + case 1: + for (int i = 0; i < 4; i++) + km->start_offsets[0] = 8 + i; + + km->num_start_offsets = 4; + break; + + case 2: + km->start_offsets[0] = 6; + km->num_start_offsets = 1; + break; + + case 3: + km->start_offsets[0] = 0; + km->num_start_offsets = 1; + /* enlarge to 6 */ + km->entry_mask[km->key_word_size++] = 0; + km->entry_mask[km->key_word_size++] = 0; + km->entry_mask[km->key_word_size++] = 0; + break; + + case 4: + km->start_offsets[0] = 0; + km->num_start_offsets = 1; + /* enlarge to 6 */ + km->entry_mask[km->key_word_size++] = 0; + km->entry_mask[km->key_word_size++] = 0; + break; + + case 6: + km->start_offsets[0] = 0; + km->num_start_offsets = 1; + break; + + default: + NT_LOG(DBG, FILTER, "Final Key word size too large: %i", + km->key_word_size); + return -1; + } + } + + return 0; +} + +int km_key_compare(struct km_flow_def_s *km, struct km_flow_def_s *km1) +{ + if (km->target != km1->target || km->num_ftype_elem != km1->num_ftype_elem || + km->key_word_size != km1->key_word_size || km->info_set != km1->info_set) + return 0; + + /* + * before KCC-CAM: + * if port is added to match, then we can have different ports in CAT + * that reuses this flow type + */ + int port_match_included = 0, kcc_swx_used = 0; + + for (int i = 0; i < km->num_ftype_elem; i++) { + if (km->match[i].extr_start_offs_id == SB_MAC_PORT) { + port_match_included = 1; + break; + } + + if (km->match_map[i]->extr_start_offs_id == SB_KCC_ID) { + kcc_swx_used = 1; + break; + } + } + + /* + * If not using KCC and if port match is not included in CAM, + * we need to have same port_id to reuse + */ + if (!kcc_swx_used && !port_match_included && km->port_id != km1->port_id) + return 0; + + for (int i = 0; i < km->num_ftype_elem; i++) { + /* using same extractor types in same sequence */ + if (km->match_map[i]->extr_start_offs_id != + km1->match_map[i]->extr_start_offs_id || + km->match_map[i]->rel_offs != km1->match_map[i]->rel_offs || + km->match_map[i]->extr != km1->match_map[i]->extr || + km->match_map[i]->word_len != km1->match_map[i]->word_len) { + return 0; + } + } + + if (km->target == KM_CAM) { + /* in CAM must exactly match on all masks */ + for (int i = 0; i < km->key_word_size; i++) + if (km->entry_mask[i] != km1->entry_mask[i]) + return 0; + + /* Would be set later if not reusing from km1 */ + km->cam_paired = km1->cam_paired; + + } else if (km->target == KM_TCAM) { + /* + * If TCAM, we must make sure Recipe Key Mask does not + * mask out enable bits in masks + * Note: it is important that km1 is the original creator + * of the KM Recipe, since it contains its true masks + */ + for (int i = 0; i < km->key_word_size; i++) + if ((km->entry_mask[i] & km1->entry_mask[i]) != km->entry_mask[i]) + return 0; + + km->tcam_start_bank = km1->tcam_start_bank; + km->tcam_record = -1; /* needs to be found later */ + + } else { + NT_LOG(DBG, FILTER, "ERROR - KM target not defined or supported"); + return 0; + } + + /* + * Check for a flow clash. If already programmed return with -1 + */ + int double_match = 1; + + for (int i = 0; i < km->key_word_size; i++) { + if ((km->entry_word[i] & km->entry_mask[i]) != + (km1->entry_word[i] & km1->entry_mask[i])) { + double_match = 0; + break; + } + } + + if (double_match) + return -1; + + /* + * Note that TCAM and CAM may reuse same RCP and flow type + * when this happens, CAM entry wins on overlap + */ + + /* Use same KM Recipe and same flow type - return flow type */ + return km1->flow_type; +} + +int km_rcp_set(struct km_flow_def_s *km, int index) +{ + int qw = 0; + int sw = 0; + int swx = 0; + + hw_mod_km_rcp_set(km->be, HW_KM_RCP_PRESET_ALL, index, 0, 0); + + /* set extractor words, offs, contrib */ + for (int i = 0; i < km->num_ftype_elem; i++) { + switch (km->match_map[i]->extr) { + case KM_USE_EXTRACTOR_SWORD: + if (km->match_map[i]->extr_start_offs_id & SWX_INFO) { + if (km->target == KM_CAM && swx == 0) { + /* SWX */ + if (km->match_map[i]->extr_start_offs_id == SB_VNI) { + NT_LOG(DBG, FILTER, "Set KM SWX sel A - VNI"); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_SWX_CCH, index, + 0, 1); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_SWX_SEL_A, + index, 0, SWX_SEL_ALL32); + + } else if (km->match_map[i]->extr_start_offs_id == + SB_MAC_PORT) { + NT_LOG(DBG, FILTER, + "Set KM SWX sel A - PTC + MAC"); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_SWX_SEL_A, + index, 0, SWX_SEL_ALL32); + + } else if (km->match_map[i]->extr_start_offs_id == + SB_KCC_ID) { + NT_LOG(DBG, FILTER, "Set KM SWX sel A - KCC ID"); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_SWX_CCH, index, + 0, 1); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_SWX_SEL_A, + index, 0, SWX_SEL_ALL32); + + } else { + return -1; + } + + } else { + return -1; + } + + swx++; + + } else { + if (sw == 0) { + /* DW8 */ + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW8_DYN, index, 0, + km->match_map[i]->extr_start_offs_id); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW8_OFS, index, 0, + km->match_map[i]->rel_offs); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW8_SEL_A, index, 0, + DW8_SEL_FIRST32); + NT_LOG(DBG, FILTER, + "Set KM DW8 sel A: dyn: %i, offs: %i", + km->match_map[i]->extr_start_offs_id, + km->match_map[i]->rel_offs); + + } else if (sw == 1) { + /* DW10 */ + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW10_DYN, index, 0, + km->match_map[i]->extr_start_offs_id); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW10_OFS, index, 0, + km->match_map[i]->rel_offs); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_DW10_SEL_A, index, 0, + DW10_SEL_FIRST32); + NT_LOG(DBG, FILTER, + "Set KM DW10 sel A: dyn: %i, offs: %i", + km->match_map[i]->extr_start_offs_id, + km->match_map[i]->rel_offs); + + } else { + return -1; + } + + sw++; + } + + break; + + case KM_USE_EXTRACTOR_QWORD: + if (qw == 0) { + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW0_DYN, index, 0, + km->match_map[i]->extr_start_offs_id); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW0_OFS, index, 0, + km->match_map[i]->rel_offs); + + switch (km->match_map[i]->word_len) { + case 1: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW0_SEL_A, index, 0, + QW0_SEL_FIRST32); + break; + + case 2: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW0_SEL_A, index, 0, + QW0_SEL_FIRST64); + break; + + case 4: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW0_SEL_A, index, 0, + QW0_SEL_ALL128); + break; + + default: + return -1; + } + + NT_LOG(DBG, FILTER, + "Set KM QW0 sel A: dyn: %i, offs: %i, size: %i", + km->match_map[i]->extr_start_offs_id, + km->match_map[i]->rel_offs, km->match_map[i]->word_len); + + } else if (qw == 1) { + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW4_DYN, index, 0, + km->match_map[i]->extr_start_offs_id); + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW4_OFS, index, 0, + km->match_map[i]->rel_offs); + + switch (km->match_map[i]->word_len) { + case 1: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW4_SEL_A, index, 0, + QW4_SEL_FIRST32); + break; + + case 2: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW4_SEL_A, index, 0, + QW4_SEL_FIRST64); + break; + + case 4: + hw_mod_km_rcp_set(km->be, HW_KM_RCP_QW4_SEL_A, index, 0, + QW4_SEL_ALL128); + break; + + default: + return -1; + } + + NT_LOG(DBG, FILTER, + "Set KM QW4 sel A: dyn: %i, offs: %i, size: %i", + km->match_map[i]->extr_start_offs_id, + km->match_map[i]->rel_offs, km->match_map[i]->word_len); + + } else { + return -1; + } + + qw++; + break; + + default: + return -1; + } + } + + /* set mask A */ + for (int i = 0; i < km->key_word_size; i++) { + hw_mod_km_rcp_set(km->be, HW_KM_RCP_MASK_A, index, + (km->be->km.nb_km_rcp_mask_a_word_size - 1) - i, + km->entry_mask[i]); + NT_LOG(DBG, FILTER, "Set KM mask A: %08x", km->entry_mask[i]); + } + + if (km->target == KM_CAM) { + /* set info - Color */ + if (km->info_set) { + hw_mod_km_rcp_set(km->be, HW_KM_RCP_INFO_A, index, 0, 1); + NT_LOG(DBG, FILTER, "Set KM info A"); + } + + /* set key length A */ + hw_mod_km_rcp_set(km->be, HW_KM_RCP_EL_A, index, 0, + km->key_word_size + !!km->info_set - 1); /* select id is -1 */ + /* set Flow Type for Key A */ + NT_LOG(DBG, FILTER, "Set KM EL A: %i", km->key_word_size + !!km->info_set - 1); + + hw_mod_km_rcp_set(km->be, HW_KM_RCP_FTM_A, index, 0, 1 << km->flow_type); + + NT_LOG(DBG, FILTER, "Set KM FTM A - ft: %i", km->flow_type); + + /* Set Paired - only on the CAM part though... TODO split CAM and TCAM */ + if ((uint32_t)(km->key_word_size + !!km->info_set) > + km->be->km.nb_cam_record_words) { + hw_mod_km_rcp_set(km->be, HW_KM_RCP_PAIRED, index, 0, 1); + NT_LOG(DBG, FILTER, "Set KM CAM Paired"); + km->cam_paired = 1; + } + + } else if (km->target == KM_TCAM) { + uint32_t bank_bm = 0; + + if (tcam_find_mapping(km) < 0) { + /* failed mapping into TCAM */ + NT_LOG(DBG, FILTER, "INFO: TCAM mapping flow failed"); + return -1; + } + + assert((uint32_t)(km->tcam_start_bank + km->key_word_size) <= + km->be->km.nb_tcam_banks); + + for (int i = 0; i < km->key_word_size; i++) { + bank_bm |= + (1 << (km->be->km.nb_tcam_banks - 1 - (km->tcam_start_bank + i))); + } + + /* Set BANK_A */ + hw_mod_km_rcp_set(km->be, HW_KM_RCP_BANK_A, index, 0, bank_bm); + /* Set Kl_A */ + hw_mod_km_rcp_set(km->be, HW_KM_RCP_KL_A, index, 0, km->key_word_size - 1); + + } else { + return -1; + } + + return 0; +} + +static int cam_populate(struct km_flow_def_s *km, int bank) +{ + int res = 0; + int cnt = km->key_word_size + !!km->info_set; + + for (uint32_t i = 0; i < km->be->km.nb_cam_record_words && cnt; i++, cnt--) { + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_W0 + i, bank, km->record_indexes[bank], + km->entry_word[i]); + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_FT0 + i, bank, km->record_indexes[bank], + km->flow_type); + } + + km->cam_dist[CAM_KM_DIST_IDX(bank)].km_owner = km; + + if (cnt) { + assert(km->cam_paired); + + for (uint32_t i = 0; i < km->be->km.nb_cam_record_words && cnt; i++, cnt--) { + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_W0 + i, bank, + km->record_indexes[bank] + 1, + km->entry_word[km->be->km.nb_cam_record_words + i]); + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_FT0 + i, bank, + km->record_indexes[bank] + 1, km->flow_type); + } + + km->cam_dist[CAM_KM_DIST_IDX(bank) + 1].km_owner = km; + } + + res |= hw_mod_km_cam_flush(km->be, bank, km->record_indexes[bank], km->cam_paired ? 2 : 1); + + return res; +} + +static int cam_reset_entry(struct km_flow_def_s *km, int bank) +{ + int res = 0; + int cnt = km->key_word_size + !!km->info_set; + + for (uint32_t i = 0; i < km->be->km.nb_cam_record_words && cnt; i++, cnt--) { + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_W0 + i, bank, km->record_indexes[bank], + 0); + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_FT0 + i, bank, km->record_indexes[bank], + 0); + } + + km->cam_dist[CAM_KM_DIST_IDX(bank)].km_owner = NULL; + + if (cnt) { + assert(km->cam_paired); + + for (uint32_t i = 0; i < km->be->km.nb_cam_record_words && cnt; i++, cnt--) { + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_W0 + i, bank, + km->record_indexes[bank] + 1, 0); + res |= hw_mod_km_cam_set(km->be, HW_KM_CAM_FT0 + i, bank, + km->record_indexes[bank] + 1, 0); + } + + km->cam_dist[CAM_KM_DIST_IDX(bank) + 1].km_owner = NULL; + } + + res |= hw_mod_km_cam_flush(km->be, bank, km->record_indexes[bank], km->cam_paired ? 2 : 1); + return res; +} + +static int move_cuckoo_index(struct km_flow_def_s *km) +{ + assert(km->cam_dist[CAM_KM_DIST_IDX(km->bank_used)].km_owner); + + for (uint32_t bank = 0; bank < km->be->km.nb_cam_banks; bank++) { + /* It will not select itself */ + if (km->cam_dist[CAM_KM_DIST_IDX(bank)].km_owner == NULL) { + if (km->cam_paired) { + if (km->cam_dist[CAM_KM_DIST_IDX(bank) + 1].km_owner != NULL) + continue; + } + + /* + * Populate in new position + */ + int res = cam_populate(km, bank); + + if (res) { + NT_LOG(DBG, FILTER, + "Error: failed to write to KM CAM in cuckoo move"); + return 0; + } + + /* + * Reset/free entry in old bank + * HW flushes are really not needed, the old addresses are always taken + * over by the caller If you change this code in future updates, this may + * no longer be true then! + */ + km->cam_dist[CAM_KM_DIST_IDX(km->bank_used)].km_owner = NULL; + + if (km->cam_paired) + km->cam_dist[CAM_KM_DIST_IDX(km->bank_used) + 1].km_owner = NULL; + + NT_LOG(DBG, FILTER, + "KM Cuckoo hash moved from bank %i to bank %i (%04X => %04X)", + km->bank_used, bank, CAM_KM_DIST_IDX(km->bank_used), + CAM_KM_DIST_IDX(bank)); + km->bank_used = bank; + (*km->cuckoo_moves)++; + return 1; + } + } + + return 0; +} + +static int move_cuckoo_index_level(struct km_flow_def_s *km_parent, int bank_idx, int levels, + int cam_adr_list_len) +{ + struct km_flow_def_s *km = km_parent->cam_dist[bank_idx].km_owner; + + assert(levels <= CUCKOO_MOVE_MAX_DEPTH); + + /* + * Only move if same pairness + * Can be extended later to handle both move of paired and single entries + */ + if (!km || km_parent->cam_paired != km->cam_paired) + return 0; + + if (move_cuckoo_index(km)) + return 1; + + if (levels <= 1) + return 0; + + assert(cam_adr_list_len < CUCKOO_MOVE_MAX_DEPTH); + + cam_addr_reserved_stack[cam_adr_list_len++] = bank_idx; + + for (uint32_t i = 0; i < km->be->km.nb_cam_banks; i++) { + int reserved = 0; + int new_idx = CAM_KM_DIST_IDX(i); + + for (int i_reserved = 0; i_reserved < cam_adr_list_len; i_reserved++) { + if (cam_addr_reserved_stack[i_reserved] == new_idx) { + reserved = 1; + break; + } + } + + if (reserved) + continue; + + int res = move_cuckoo_index_level(km, new_idx, levels - 1, cam_adr_list_len); + + if (res) { + if (move_cuckoo_index(km)) + return 1; + + assert(0); + } + } + + return 0; +} + +static int km_write_data_to_cam(struct km_flow_def_s *km) +{ + int res = 0; + assert(km->be->km.nb_cam_banks <= MAX_BANKS); + assert(km->cam_dist); + + NT_LOG(DBG, FILTER, "KM HASH [%03X, %03X, %03X]", km->record_indexes[0], + km->record_indexes[1], km->record_indexes[2]); + + if (km->info_set) + km->entry_word[km->key_word_size] = km->info; /* finally set info */ + + int bank = -1; + + /* + * first step, see if any of the banks are free + */ + for (uint32_t i_bank = 0; i_bank < km->be->km.nb_cam_banks; i_bank++) { + if (km->cam_dist[CAM_KM_DIST_IDX(i_bank)].km_owner == NULL) { + if (km->cam_paired == 0 || + km->cam_dist[CAM_KM_DIST_IDX(i_bank) + 1].km_owner == NULL) { + bank = i_bank; + break; + } + } + } + + if (bank < 0) { + /* + * Second step - cuckoo move existing flows if possible + */ + for (uint32_t i_bank = 0; i_bank < km->be->km.nb_cam_banks; i_bank++) { + if (move_cuckoo_index_level(km, CAM_KM_DIST_IDX(i_bank), 4, 0)) { + bank = i_bank; + break; + } + } + } + + if (bank < 0) + return -1; + + /* populate CAM */ + NT_LOG(DBG, FILTER, "KM Bank = %i (addr %04X)", bank, CAM_KM_DIST_IDX(bank)); + res = cam_populate(km, bank); + + if (res == 0) { + km->flushed_to_target = 1; + km->bank_used = bank; + } + + return res; +} + +/* + * TCAM + */ +static int tcam_find_free_record(struct km_flow_def_s *km, int start_bank) +{ + for (uint32_t rec = 0; rec < km->be->km.nb_tcam_bank_width; rec++) { + if (km->tcam_dist[TCAM_DIST_IDX(start_bank, rec)].km_owner == NULL) { + int pass = 1; + + for (int ii = 1; ii < km->key_word_size; ii++) { + if (km->tcam_dist[TCAM_DIST_IDX(start_bank + ii, rec)].km_owner != + NULL) { + pass = 0; + break; + } + } + + if (pass) { + km->tcam_record = rec; + return 1; + } + } + } + + return 0; +} + +static int tcam_find_mapping(struct km_flow_def_s *km) +{ + /* Search record and start index for this flow */ + for (int bs_idx = 0; bs_idx < km->num_start_offsets; bs_idx++) { + if (tcam_find_free_record(km, km->start_offsets[bs_idx])) { + km->tcam_start_bank = km->start_offsets[bs_idx]; + NT_LOG(DBG, FILTER, "Found space in TCAM start bank %i, record %i", + km->tcam_start_bank, km->tcam_record); + return 0; + } + } + + return -1; +} + +static int tcam_write_word(struct km_flow_def_s *km, int bank, int record, uint32_t word, + uint32_t mask) +{ + int err = 0; + uint32_t all_recs[3]; + + int rec_val = record / 32; + int rec_bit_shft = record % 32; + uint32_t rec_bit = (1 << rec_bit_shft); + + assert((km->be->km.nb_tcam_bank_width + 31) / 32 <= 3); + + for (int byte = 0; byte < 4; byte++) { + uint8_t a = (uint8_t)((word >> (24 - (byte * 8))) & 0xff); + uint8_t a_m = (uint8_t)((mask >> (24 - (byte * 8))) & 0xff); + /* calculate important value bits */ + a = a & a_m; + + for (int val = 0; val < 256; val++) { + err |= hw_mod_km_tcam_get(km->be, HW_KM_TCAM_T, bank, byte, val, all_recs); + + if ((val & a_m) == a) + all_recs[rec_val] |= rec_bit; + else + all_recs[rec_val] &= ~rec_bit; + + err |= hw_mod_km_tcam_set(km->be, HW_KM_TCAM_T, bank, byte, val, all_recs); + + if (err) + break; + } + } + + /* flush bank */ + err |= hw_mod_km_tcam_flush(km->be, bank, ALL_BANK_ENTRIES); + + if (err == 0) { + assert(km->tcam_dist[TCAM_DIST_IDX(bank, record)].km_owner == NULL); + km->tcam_dist[TCAM_DIST_IDX(bank, record)].km_owner = km; + } + + return err; +} + +static int km_write_data_to_tcam(struct km_flow_def_s *km) +{ + int err = 0; + + if (km->tcam_record < 0) { + tcam_find_free_record(km, km->tcam_start_bank); + + if (km->tcam_record < 0) { + NT_LOG(DBG, FILTER, "FAILED to find space in TCAM for flow"); + return -1; + } + + NT_LOG(DBG, FILTER, "Reused RCP: Found space in TCAM start bank %i, record %i", + km->tcam_start_bank, km->tcam_record); + } + + /* Write KM_TCI */ + err |= hw_mod_km_tci_set(km->be, HW_KM_TCI_COLOR, km->tcam_start_bank, km->tcam_record, + km->info); + err |= hw_mod_km_tci_set(km->be, HW_KM_TCI_FT, km->tcam_start_bank, km->tcam_record, + km->flow_type); + err |= hw_mod_km_tci_flush(km->be, km->tcam_start_bank, km->tcam_record, 1); + + for (int i = 0; i < km->key_word_size && !err; i++) { + err = tcam_write_word(km, km->tcam_start_bank + i, km->tcam_record, + km->entry_word[i], km->entry_mask[i]); + } + + if (err == 0) + km->flushed_to_target = 1; + + return err; +} + +static int tcam_reset_bank(struct km_flow_def_s *km, int bank, int record) +{ + int err = 0; + uint32_t all_recs[3]; + + int rec_val = record / 32; + int rec_bit_shft = record % 32; + uint32_t rec_bit = (1 << rec_bit_shft); + + assert((km->be->km.nb_tcam_bank_width + 31) / 32 <= 3); + + for (int byte = 0; byte < 4; byte++) { + for (int val = 0; val < 256; val++) { + err = hw_mod_km_tcam_get(km->be, HW_KM_TCAM_T, bank, byte, val, all_recs); + + if (err) + break; + + all_recs[rec_val] &= ~rec_bit; + err = hw_mod_km_tcam_set(km->be, HW_KM_TCAM_T, bank, byte, val, all_recs); + + if (err) + break; + } + } + + if (err) + return err; + + /* flush bank */ + err = hw_mod_km_tcam_flush(km->be, bank, ALL_BANK_ENTRIES); + km->tcam_dist[TCAM_DIST_IDX(bank, record)].km_owner = NULL; + + NT_LOG(DBG, FILTER, "Reset TCAM bank %i, rec_val %i rec bit %08x", bank, rec_val, + rec_bit); + + return err; +} + +static int tcam_reset_entry(struct km_flow_def_s *km) +{ + int err = 0; + + if (km->tcam_start_bank < 0 || km->tcam_record < 0) { + NT_LOG(DBG, FILTER, "FAILED to find space in TCAM for flow"); + return -1; + } + + /* Write KM_TCI */ + hw_mod_km_tci_set(km->be, HW_KM_TCI_COLOR, km->tcam_start_bank, km->tcam_record, 0); + hw_mod_km_tci_set(km->be, HW_KM_TCI_FT, km->tcam_start_bank, km->tcam_record, 0); + hw_mod_km_tci_flush(km->be, km->tcam_start_bank, km->tcam_record, 1); + + for (int i = 0; i < km->key_word_size && !err; i++) + err = tcam_reset_bank(km, km->tcam_start_bank + i, km->tcam_record); + + return err; +} + +int km_write_data_match_entry(struct km_flow_def_s *km, uint32_t color) +{ + int res = -1; + + km->info = color; + NT_LOG(DBG, FILTER, "Write Data entry Color: %08x", color); + + switch (km->target) { + case KM_CAM: + res = km_write_data_to_cam(km); + break; + + case KM_TCAM: + res = km_write_data_to_tcam(km); + break; + + case KM_SYNERGY: + default: + break; + } + + return res; +} + +int km_clear_data_match_entry(struct km_flow_def_s *km) +{ + int res = 0; + + if (km->root) { + struct km_flow_def_s *km1 = km->root; + + while (km1->reference != km) + km1 = km1->reference; + + km1->reference = km->reference; + + km->flushed_to_target = 0; + km->bank_used = 0; + + } else if (km->reference) { + km->reference->root = NULL; + + switch (km->target) { + case KM_CAM: + km->cam_dist[CAM_KM_DIST_IDX(km->bank_used)].km_owner = km->reference; + + if (km->key_word_size + !!km->info_set > 1) { + assert(km->cam_paired); + km->cam_dist[CAM_KM_DIST_IDX(km->bank_used) + 1].km_owner = + km->reference; + } + + break; + + case KM_TCAM: + for (int i = 0; i < km->key_word_size; i++) { + km->tcam_dist[TCAM_DIST_IDX(km->tcam_start_bank + i, + km->tcam_record)] + .km_owner = km->reference; + } + + break; + + case KM_SYNERGY: + default: + res = -1; + break; + } + + km->flushed_to_target = 0; + km->bank_used = 0; + + } else if (km->flushed_to_target) { + switch (km->target) { + case KM_CAM: + res = cam_reset_entry(km, km->bank_used); + break; + + case KM_TCAM: + res = tcam_reset_entry(km); + break; + + case KM_SYNERGY: + default: + res = -1; + break; + } + + km->flushed_to_target = 0; + km->bank_used = 0; + } + + return res; +} diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_km.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_km.c index 532884ca01..b8a30671c3 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_km.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_km.c @@ -165,6 +165,240 @@ int hw_mod_km_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) return be->iface->km_rcp_flush(be->be_dev, &be->km, start_idx, count); } +static int hw_mod_km_rcp_mod(struct flow_api_backend_s *be, enum hw_km_e field, int index, + int word_off, uint32_t *value, int get) +{ + if ((unsigned int)index >= be->km.nb_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 7: + switch (field) { + case HW_KM_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->km.v7.rcp[index], (uint8_t)*value, sizeof(struct km_v7_rcp_s)); + break; + + case HW_KM_RCP_QW0_DYN: + GET_SET(be->km.v7.rcp[index].qw0_dyn, value); + break; + + case HW_KM_RCP_QW0_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].qw0_ofs, value); + break; + + case HW_KM_RCP_QW0_SEL_A: + GET_SET(be->km.v7.rcp[index].qw0_sel_a, value); + break; + + case HW_KM_RCP_QW0_SEL_B: + GET_SET(be->km.v7.rcp[index].qw0_sel_b, value); + break; + + case HW_KM_RCP_QW4_DYN: + GET_SET(be->km.v7.rcp[index].qw4_dyn, value); + break; + + case HW_KM_RCP_QW4_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].qw4_ofs, value); + break; + + case HW_KM_RCP_QW4_SEL_A: + GET_SET(be->km.v7.rcp[index].qw4_sel_a, value); + break; + + case HW_KM_RCP_QW4_SEL_B: + GET_SET(be->km.v7.rcp[index].qw4_sel_b, value); + break; + + case HW_KM_RCP_DW8_DYN: + GET_SET(be->km.v7.rcp[index].dw8_dyn, value); + break; + + case HW_KM_RCP_DW8_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].dw8_ofs, value); + break; + + case HW_KM_RCP_DW8_SEL_A: + GET_SET(be->km.v7.rcp[index].dw8_sel_a, value); + break; + + case HW_KM_RCP_DW8_SEL_B: + GET_SET(be->km.v7.rcp[index].dw8_sel_b, value); + break; + + case HW_KM_RCP_DW10_DYN: + GET_SET(be->km.v7.rcp[index].dw10_dyn, value); + break; + + case HW_KM_RCP_DW10_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].dw10_ofs, value); + break; + + case HW_KM_RCP_DW10_SEL_A: + GET_SET(be->km.v7.rcp[index].dw10_sel_a, value); + break; + + case HW_KM_RCP_DW10_SEL_B: + GET_SET(be->km.v7.rcp[index].dw10_sel_b, value); + break; + + case HW_KM_RCP_SWX_CCH: + GET_SET(be->km.v7.rcp[index].swx_cch, value); + break; + + case HW_KM_RCP_SWX_SEL_A: + GET_SET(be->km.v7.rcp[index].swx_sel_a, value); + break; + + case HW_KM_RCP_SWX_SEL_B: + GET_SET(be->km.v7.rcp[index].swx_sel_b, value); + break; + + case HW_KM_RCP_MASK_A: + if (word_off > KM_RCP_MASK_D_A_SIZE) { + WORD_OFF_TOO_LARGE_LOG; + return WORD_OFF_TOO_LARGE; + } + + GET_SET(be->km.v7.rcp[index].mask_d_a[word_off], value); + break; + + case HW_KM_RCP_MASK_B: + if (word_off > KM_RCP_MASK_B_SIZE) { + WORD_OFF_TOO_LARGE_LOG; + return WORD_OFF_TOO_LARGE; + } + + GET_SET(be->km.v7.rcp[index].mask_b[word_off], value); + break; + + case HW_KM_RCP_DUAL: + GET_SET(be->km.v7.rcp[index].dual, value); + break; + + case HW_KM_RCP_PAIRED: + GET_SET(be->km.v7.rcp[index].paired, value); + break; + + case HW_KM_RCP_EL_A: + GET_SET(be->km.v7.rcp[index].el_a, value); + break; + + case HW_KM_RCP_EL_B: + GET_SET(be->km.v7.rcp[index].el_b, value); + break; + + case HW_KM_RCP_INFO_A: + GET_SET(be->km.v7.rcp[index].info_a, value); + break; + + case HW_KM_RCP_INFO_B: + GET_SET(be->km.v7.rcp[index].info_b, value); + break; + + case HW_KM_RCP_FTM_A: + GET_SET(be->km.v7.rcp[index].ftm_a, value); + break; + + case HW_KM_RCP_FTM_B: + GET_SET(be->km.v7.rcp[index].ftm_b, value); + break; + + case HW_KM_RCP_BANK_A: + GET_SET(be->km.v7.rcp[index].bank_a, value); + break; + + case HW_KM_RCP_BANK_B: + GET_SET(be->km.v7.rcp[index].bank_b, value); + break; + + case HW_KM_RCP_KL_A: + GET_SET(be->km.v7.rcp[index].kl_a, value); + break; + + case HW_KM_RCP_KL_B: + GET_SET(be->km.v7.rcp[index].kl_b, value); + break; + + case HW_KM_RCP_KEYWAY_A: + GET_SET(be->km.v7.rcp[index].keyway_a, value); + break; + + case HW_KM_RCP_KEYWAY_B: + GET_SET(be->km.v7.rcp[index].keyway_b, value); + break; + + case HW_KM_RCP_SYNERGY_MODE: + GET_SET(be->km.v7.rcp[index].synergy_mode, value); + break; + + case HW_KM_RCP_DW0_B_DYN: + GET_SET(be->km.v7.rcp[index].dw0_b_dyn, value); + break; + + case HW_KM_RCP_DW0_B_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].dw0_b_ofs, value); + break; + + case HW_KM_RCP_DW2_B_DYN: + GET_SET(be->km.v7.rcp[index].dw2_b_dyn, value); + break; + + case HW_KM_RCP_DW2_B_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].dw2_b_ofs, value); + break; + + case HW_KM_RCP_SW4_B_DYN: + GET_SET(be->km.v7.rcp[index].sw4_b_dyn, value); + break; + + case HW_KM_RCP_SW4_B_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].sw4_b_ofs, value); + break; + + case HW_KM_RCP_SW5_B_DYN: + GET_SET(be->km.v7.rcp[index].sw5_b_dyn, value); + break; + + case HW_KM_RCP_SW5_B_OFS: + GET_SET_SIGNED(be->km.v7.rcp[index].sw5_b_ofs, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_km_rcp_set(struct flow_api_backend_s *be, enum hw_km_e field, int index, int word_off, + uint32_t value) +{ + return hw_mod_km_rcp_mod(be, field, index, word_off, &value, 0); +} + +int hw_mod_km_rcp_get(struct flow_api_backend_s *be, enum hw_km_e field, int index, int word_off, + uint32_t *value) +{ + return hw_mod_km_rcp_mod(be, field, index, word_off, value, 1); +} + int hw_mod_km_cam_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count) { if (count == ALL_ENTRIES) @@ -180,6 +414,103 @@ int hw_mod_km_cam_flush(struct flow_api_backend_s *be, int start_bank, int start return be->iface->km_cam_flush(be->be_dev, &be->km, start_bank, start_record, count); } +static int hw_mod_km_cam_mod(struct flow_api_backend_s *be, enum hw_km_e field, int bank, + int record, uint32_t *value, int get) +{ + if ((unsigned int)bank >= be->km.nb_cam_banks) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + if ((unsigned int)record >= be->km.nb_cam_records) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + unsigned int index = bank * be->km.nb_cam_records + record; + + switch (_VER_) { + case 7: + switch (field) { + case HW_KM_CAM_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->km.v7.cam[index], (uint8_t)*value, sizeof(struct km_v7_cam_s)); + break; + + case HW_KM_CAM_W0: + GET_SET(be->km.v7.cam[index].w0, value); + break; + + case HW_KM_CAM_W1: + GET_SET(be->km.v7.cam[index].w1, value); + break; + + case HW_KM_CAM_W2: + GET_SET(be->km.v7.cam[index].w2, value); + break; + + case HW_KM_CAM_W3: + GET_SET(be->km.v7.cam[index].w3, value); + break; + + case HW_KM_CAM_W4: + GET_SET(be->km.v7.cam[index].w4, value); + break; + + case HW_KM_CAM_W5: + GET_SET(be->km.v7.cam[index].w5, value); + break; + + case HW_KM_CAM_FT0: + GET_SET(be->km.v7.cam[index].ft0, value); + break; + + case HW_KM_CAM_FT1: + GET_SET(be->km.v7.cam[index].ft1, value); + break; + + case HW_KM_CAM_FT2: + GET_SET(be->km.v7.cam[index].ft2, value); + break; + + case HW_KM_CAM_FT3: + GET_SET(be->km.v7.cam[index].ft3, value); + break; + + case HW_KM_CAM_FT4: + GET_SET(be->km.v7.cam[index].ft4, value); + break; + + case HW_KM_CAM_FT5: + GET_SET(be->km.v7.cam[index].ft5, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_km_cam_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int record, + uint32_t value) +{ + return hw_mod_km_cam_mod(be, field, bank, record, &value, 0); +} + int hw_mod_km_tcam_flush(struct flow_api_backend_s *be, int start_bank, int count) { if (count == ALL_ENTRIES) @@ -273,6 +604,12 @@ int hw_mod_km_tcam_set(struct flow_api_backend_s *be, enum hw_km_e field, int ba return hw_mod_km_tcam_mod(be, field, bank, byte, byte_val, value_set, 0); } +int hw_mod_km_tcam_get(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int byte, + int byte_val, uint32_t *value_set) +{ + return hw_mod_km_tcam_mod(be, field, bank, byte, byte_val, value_set, 1); +} + int hw_mod_km_tci_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count) { if (count == ALL_ENTRIES) @@ -288,6 +625,49 @@ int hw_mod_km_tci_flush(struct flow_api_backend_s *be, int start_bank, int start return be->iface->km_tci_flush(be->be_dev, &be->km, start_bank, start_record, count); } +static int hw_mod_km_tci_mod(struct flow_api_backend_s *be, enum hw_km_e field, int bank, + int record, uint32_t *value, int get) +{ + unsigned int index = bank * be->km.nb_tcam_bank_width + record; + + if (index >= (be->km.nb_tcam_banks * be->km.nb_tcam_bank_width)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 7: + switch (field) { + case HW_KM_TCI_COLOR: + GET_SET(be->km.v7.tci[index].color, value); + break; + + case HW_KM_TCI_FT: + GET_SET(be->km.v7.tci[index].ft, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 7 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_km_tci_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int record, + uint32_t value) +{ + return hw_mod_km_tci_mod(be, field, bank, record, &value, 0); +} + int hw_mod_km_tcq_flush(struct flow_api_backend_s *be, int start_bank, int start_record, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 5572662647..4737460cdf 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -40,7 +40,19 @@ struct hw_db_inline_resource_db { int ref; } *cat; + struct hw_db_inline_resource_db_km_rcp { + struct hw_db_inline_km_rcp_data data; + int ref; + + struct hw_db_inline_resource_db_km_ft { + struct hw_db_inline_km_ft_data data; + int ref; + } *ft; + } *km; + uint32_t nb_cat; + uint32_t nb_km_ft; + uint32_t nb_km_rcp; /* Hardware */ @@ -91,6 +103,25 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_km_ft = ndev->be.cat.nb_flow_types; + db->nb_km_rcp = ndev->be.km.nb_categories; + db->km = calloc(db->nb_km_rcp, sizeof(struct hw_db_inline_resource_db_km_rcp)); + + if (db->km == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + for (uint32_t i = 0; i < db->nb_km_rcp; ++i) { + db->km[i].ft = calloc(db->nb_km_ft * db->nb_cat, + sizeof(struct hw_db_inline_resource_db_km_ft)); + + if (db->km[i].ft == NULL) { + hw_db_inline_destroy(db); + return -1; + } + } + *db_handle = db; return 0; } @@ -104,6 +135,13 @@ void hw_db_inline_destroy(void *db_handle) free(db->slc_lr); free(db->cat); + if (db->km) { + for (uint32_t i = 0; i < db->nb_km_rcp; ++i) + free(db->km[i].ft); + + free(db->km); + } + free(db->cfn); free(db); @@ -134,12 +172,61 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_slc_lr_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_KM_RCP: + hw_db_inline_km_deref(ndev, db_handle, *(struct hw_db_km_idx *)&idxs[i]); + break; + + case HW_DB_IDX_TYPE_KM_FT: + hw_db_inline_km_ft_deref(ndev, db_handle, *(struct hw_db_km_ft *)&idxs[i]); + break; + default: break; } } } + +const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, + enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + for (uint32_t i = 0; i < size; ++i) { + if (idxs[i].type != type) + continue; + + switch (type) { + case HW_DB_IDX_TYPE_NONE: + return NULL; + + case HW_DB_IDX_TYPE_CAT: + return &db->cat[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_QSL: + return &db->qsl[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_COT: + return &db->cot[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_SLC_LR: + return &db->slc_lr[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_KM_RCP: + return &db->km[idxs[i].id1].data; + + case HW_DB_IDX_TYPE_KM_FT: + return NULL; /* FTs can't be easily looked up */ + + default: + return NULL; + } + } + + return NULL; +} + /******************************************************************************/ /* Filter */ /******************************************************************************/ @@ -614,3 +701,150 @@ void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct h db->cat[idx.ids].ref = 0; } } + +/******************************************************************************/ +/* KM RCP */ +/******************************************************************************/ + +static int hw_db_inline_km_compare(const struct hw_db_inline_km_rcp_data *data1, + const struct hw_db_inline_km_rcp_data *data2) +{ + return data1->rcp == data2->rcp; +} + +struct hw_db_km_idx hw_db_inline_km_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_km_rcp_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_km_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_KM_RCP; + + for (uint32_t i = 0; i < db->nb_km_rcp; ++i) { + if (!found && db->km[i].ref <= 0) { + found = 1; + idx.id1 = i; + } + + if (db->km[i].ref > 0 && hw_db_inline_km_compare(data, &db->km[i].data)) { + idx.id1 = i; + hw_db_inline_km_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&db->km[idx.id1].data, data, sizeof(struct hw_db_inline_km_rcp_data)); + db->km[idx.id1].ref = 1; + + return idx; +} + +void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->km[idx.id1].ref += 1; +} + +void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx) +{ + (void)ndev; + (void)db_handle; + + if (idx.error) + return; +} + +/******************************************************************************/ +/* KM FT */ +/******************************************************************************/ + +static int hw_db_inline_km_ft_compare(const struct hw_db_inline_km_ft_data *data1, + const struct hw_db_inline_km_ft_data *data2) +{ + return data1->cat.raw == data2->cat.raw && data1->km.raw == data2->km.raw && + data1->action_set.raw == data2->action_set.raw; +} + +struct hw_db_km_ft hw_db_inline_km_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_km_ft_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_km_rcp *km_rcp = &db->km[data->km.id1]; + struct hw_db_km_ft idx = { .raw = 0 }; + uint32_t cat_offset = data->cat.ids * db->nb_cat; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_KM_FT; + idx.id2 = data->km.id1; + idx.id3 = data->cat.ids; + + if (km_rcp->data.rcp == 0) { + idx.id1 = 0; + return idx; + } + + for (uint32_t i = 1; i < db->nb_km_ft; ++i) { + const struct hw_db_inline_resource_db_km_ft *km_ft = &km_rcp->ft[cat_offset + i]; + + if (!found && km_ft->ref <= 0) { + found = 1; + idx.id1 = i; + } + + if (km_ft->ref > 0 && hw_db_inline_km_ft_compare(data, &km_ft->data)) { + idx.id1 = i; + hw_db_inline_km_ft_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&km_rcp->ft[cat_offset + idx.id1].data, data, + sizeof(struct hw_db_inline_km_ft_data)); + km_rcp->ft[cat_offset + idx.id1].ref = 1; + + return idx; +} + +void hw_db_inline_km_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_ft idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) { + uint32_t cat_offset = idx.id3 * db->nb_cat; + db->km[idx.id2].ft[cat_offset + idx.id1].ref += 1; + } +} + +void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_ft idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_km_rcp *km_rcp = &db->km[idx.id2]; + uint32_t cat_offset = idx.id3 * db->nb_cat; + + if (idx.error) + return; + + km_rcp->ft[cat_offset + idx.id1].ref -= 1; + + if (km_rcp->ft[cat_offset + idx.id1].ref <= 0) { + memset(&km_rcp->ft[cat_offset + idx.id1].data, 0x0, + sizeof(struct hw_db_inline_km_ft_data)); + km_rcp->ft[cat_offset + idx.id1].ref = 0; + } +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index d0435acaef..e104ba7327 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -32,6 +32,10 @@ struct hw_db_idx { HW_DB_IDX; }; +struct hw_db_action_set_idx { + HW_DB_IDX; +}; + struct hw_db_cot_idx { HW_DB_IDX; }; @@ -48,12 +52,22 @@ struct hw_db_slc_lr_idx { HW_DB_IDX; }; +struct hw_db_km_idx { + HW_DB_IDX; +}; + +struct hw_db_km_ft { + HW_DB_IDX; +}; + enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, HW_DB_IDX_TYPE_CAT, HW_DB_IDX_TYPE_QSL, HW_DB_IDX_TYPE_SLC_LR, + HW_DB_IDX_TYPE_KM_RCP, + HW_DB_IDX_TYPE_KM_FT, }; /* Functionality data types */ @@ -123,6 +137,16 @@ struct hw_db_inline_action_set_data { }; }; +struct hw_db_inline_km_rcp_data { + uint32_t rcp; +}; + +struct hw_db_inline_km_ft_data { + struct hw_db_cat_idx cat; + struct hw_db_km_idx km; + struct hw_db_action_set_idx action_set; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); @@ -130,6 +154,8 @@ void hw_db_inline_destroy(void *db_handle); void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_idx *idxs, uint32_t size); +const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, + enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); /**/ struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_handle, @@ -158,6 +184,18 @@ void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct h /**/ +struct hw_db_km_idx hw_db_inline_km_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_km_rcp_data *data); +void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx); +void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx); + +struct hw_db_km_ft hw_db_inline_km_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_km_ft_data *data); +void hw_db_inline_km_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_ft idx); +void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_ft idx); + +/**/ + int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, uint32_t qsl_hw_id); 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 999b1ed985..78d662d70c 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 @@ -2334,6 +2334,23 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, uint32_t *flm_scrub __rte_unused, struct rte_flow_error *error) { + const bool empty_pattern = fd_has_empty_pattern(fd); + + /* Setup COT */ + struct hw_db_inline_cot_data cot_data = { + .matcher_color_contrib = empty_pattern ? 0x0 : 0x4, /* FT key C */ + .frag_rcp = 0, + }; + struct hw_db_cot_idx cot_idx = + hw_db_inline_cot_add(dev->ndev, dev->ndev->hw_db_handle, &cot_data); + local_idxs[(*local_idx_counter)++] = cot_idx.raw; + + if (cot_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference COT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + /* Finalize QSL */ struct hw_db_qsl_idx qsl_idx = hw_db_inline_qsl_add(dev->ndev, dev->ndev->hw_db_handle, qsl_data); @@ -2428,6 +2445,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n /* * Flow for group 0 */ + int identical_km_entry_ft = -1; + struct hw_db_inline_action_set_data action_set_data = { 0 }; (void)action_set_data; @@ -2502,6 +2521,130 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n goto error_out; } + /* Setup KM RCP */ + struct hw_db_inline_km_rcp_data km_rcp_data = { .rcp = 0 }; + + if (fd->km.num_ftype_elem) { + struct flow_handle *flow = dev->ndev->flow_base, *found_flow = NULL; + + if (km_key_create(&fd->km, fh->port_id)) { + NT_LOG(ERR, FILTER, "KM creation failed"); + flow_nic_set_error(ERR_MATCH_FAILED_BY_HW_LIMITS, error); + goto error_out; + } + + fd->km.be = &dev->ndev->be; + + /* Look for existing KM RCPs */ + while (flow) { + if (flow->type == FLOW_HANDLE_TYPE_FLOW && + flow->fd->km.flow_type) { + int res = km_key_compare(&fd->km, &flow->fd->km); + + if (res < 0) { + /* Flow rcp and match data is identical */ + identical_km_entry_ft = flow->fd->km.flow_type; + found_flow = flow; + break; + } + + if (res > 0) { + /* Flow rcp found and match data is different */ + found_flow = flow; + } + } + + flow = flow->next; + } + + km_attach_ndev_resource_management(&fd->km, &dev->ndev->km_res_handle); + + if (found_flow != NULL) { + /* Reuse existing KM RCP */ + const struct hw_db_inline_km_rcp_data *other_km_rcp_data = + hw_db_inline_find_data(dev->ndev, dev->ndev->hw_db_handle, + HW_DB_IDX_TYPE_KM_RCP, + (struct hw_db_idx *) + found_flow->flm_db_idxs, + found_flow->flm_db_idx_counter); + + if (other_km_rcp_data == NULL || + flow_nic_ref_resource(dev->ndev, RES_KM_CATEGORY, + other_km_rcp_data->rcp)) { + NT_LOG(ERR, FILTER, + "Could not reference existing KM RCP resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + km_rcp_data.rcp = other_km_rcp_data->rcp; + } else { + /* Alloc new KM RCP */ + int rcp = flow_nic_alloc_resource(dev->ndev, RES_KM_CATEGORY, 1); + + if (rcp < 0) { + NT_LOG(ERR, FILTER, + "Could not reference KM RCP resource (flow_nic_alloc)"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + km_rcp_set(&fd->km, rcp); + km_rcp_data.rcp = (uint32_t)rcp; + } + } + + struct hw_db_km_idx km_idx = + hw_db_inline_km_add(dev->ndev, dev->ndev->hw_db_handle, &km_rcp_data); + + fh->db_idxs[fh->db_idx_counter++] = km_idx.raw; + + if (km_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference KM RCP resource (db_inline)"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + /* Setup KM FT */ + struct hw_db_inline_km_ft_data km_ft_data = { + .cat = cat_idx, + .km = km_idx, + }; + struct hw_db_km_ft km_ft_idx = + hw_db_inline_km_ft_add(dev->ndev, dev->ndev->hw_db_handle, &km_ft_data); + fh->db_idxs[fh->db_idx_counter++] = km_ft_idx.raw; + + if (km_ft_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference KM FT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + /* Finalize KM RCP */ + if (fd->km.num_ftype_elem) { + if (identical_km_entry_ft >= 0 && identical_km_entry_ft != km_ft_idx.id1) { + NT_LOG(ERR, FILTER, + "Identical KM matches cannot have different KM FTs"); + flow_nic_set_error(ERR_MATCH_FAILED_BY_HW_LIMITS, error); + goto error_out; + } + + fd->km.flow_type = km_ft_idx.id1; + + if (fd->km.target == KM_CAM) { + uint32_t ft_a_mask = 0; + hw_mod_km_rcp_get(&dev->ndev->be, HW_KM_RCP_FTM_A, + (int)km_rcp_data.rcp, 0, &ft_a_mask); + hw_mod_km_rcp_set(&dev->ndev->be, HW_KM_RCP_FTM_A, + (int)km_rcp_data.rcp, 0, + ft_a_mask | (1 << fd->km.flow_type)); + } + + hw_mod_km_rcp_flush(&dev->ndev->be, (int)km_rcp_data.rcp, 1); + + km_write_data_match_entry(&fd->km, 0); + } + nic_insert_flow(dev->ndev, fh); } @@ -2782,6 +2925,25 @@ int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev, } else { NT_LOG(DBG, FILTER, "removing flow :%p", fh); + if (fh->fd->km.num_ftype_elem) { + km_clear_data_match_entry(&fh->fd->km); + + const struct hw_db_inline_km_rcp_data *other_km_rcp_data = + hw_db_inline_find_data(dev->ndev, dev->ndev->hw_db_handle, + HW_DB_IDX_TYPE_KM_RCP, + (struct hw_db_idx *)fh->flm_db_idxs, + fh->flm_db_idx_counter); + + if (other_km_rcp_data != NULL && + flow_nic_deref_resource(dev->ndev, RES_KM_CATEGORY, + (int)other_km_rcp_data->rcp) == 0) { + hw_mod_km_rcp_set(&dev->ndev->be, HW_KM_RCP_PRESET_ALL, + (int)other_km_rcp_data->rcp, 0, 0); + hw_mod_km_rcp_flush(&dev->ndev->be, (int)other_km_rcp_data->rcp, + 1); + } + } + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, (struct hw_db_idx *)fh->db_idxs, fh->db_idx_counter); free(fh->fd); From patchwork Tue Oct 29 16:41:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147635 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC7B745BC0; Tue, 29 Oct 2024 17:47:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D4A342EFE; Tue, 29 Oct 2024 17:44:15 +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 D135342ED8 for ; Tue, 29 Oct 2024 17:43:29 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2042.outbound.protection.outlook.com [104.47.11.42]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kfsGdy+jqXzAgiwfeSMXKX48aqVuPIyk9kdXHUCR2KZcVhgQtoXhqKnLLwwnspb1T3BIn3KFdT0x4s50vE0GNxGBVy4O1tYJ2hefQ83E/e1VPrj1Xwdyanv2U2RHuzkN+jIEdQOpmNYf0FAYO2zNaQ/Orb+kCTgtV7Y/qUN4HwL2hlPOhLzkjKMV5dy8N+ih4bEYX1gSPiiJTOQe0rPQXRChbdBn8l00vyRsuOi8gYD9Mm2SNciCD/UOF81p3lbQej1j1sXYiwoRAA/5vGXwRISr3/KgElW68anGI4mIsiV4EHdOFlTCRcoiVt+N8MEUEHpu14T+ejESd46rM8mzDg== 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=PfSm9dNxcaCpwljrCbWTCELCYKl3FHkEYvqLc1OoXqQ=; b=QvTypDTAsoxpxHqeIyicb5SVq6xJ/YfrGBFEVnn+EBrCOfvMCsayGXaPy5yqtxMAL+VZ37yD68PG5UKgBW+1Paf+wFtxls7O/oJvY8gnsdfFGNWrCCYPG7TplW/U7mwkReEYNMObrpBdXwuTHhLGRbQQWf9vhYauDH1pYy6fssTh+9a4GMMniQQjC++2LrKn0oZa6rDSdDsw1iSbr/kmoV0sTXK//z1EqRr1zhNxGKuAwZZMI2CtUK+9fjSnCa9az1qLsvfWcrpWJOo/Q6ObvsQfGFLOACjd5KguarAF6lHH2fjGtlF9ZK1zUMd0jYLdm1gBK24Ea8l+F0pk4I7bKg== 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=PfSm9dNxcaCpwljrCbWTCELCYKl3FHkEYvqLc1OoXqQ=; b=JyE3v88e2kMgjl8C52zE7naRjD+scq3F+EaFcT47PxxEJy/KjNIqTfnhJZKyp3EsWlODg3jzNK+Cjh4vHX9DAM7jtdXWpieW128xQfABJlF9OHP+mj+JP9juKO7QViga/VkHUvC0LhNGdKB6iFkR9vx4c3JIldU37l+yezAdKKs= Received: from DUZPR01CA0187.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::17) by DB9P190MB1306.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:22d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:21 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::fb) 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:43:20 +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:43:20 +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 31/86] net/ntnic: add hash API Date: Tue, 29 Oct 2024 17:41:35 +0100 Message-ID: <20241029164243.1648775-32-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB9P190MB1306:EE_ X-MS-Office365-Filtering-Correlation-Id: 79492c93-0672-41d9-b069-08dcf838cc4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: hhLaNCKdW+0PJU7ok5w03nH/NG/oohBk5Bs6E8tMXI/WT0xn8eHUjs/65pDZoEtLEwn7j05BcEieNEEioo+Kmd+kUFcc2uxWcEB81i1/ciYuJc1q0Ao6sBJeBg/DHrrQ5BmDzGV7aFqN29cjIKQZsygFFkSLK2bK9wxDAo3UPm2yAURIkSJzs8QdMWMrSB89eASMzJbqVF+/9cUR65MJ7S3T27oN9KQBOvFUKSNU0wHei/+fWSfahSNQA5DPc5zM1BaJ19vYZk4TwW1Q3vLeSawK580jexqP0mqT5VGltTuWe8t1vmwHGaFYFXc0vup1eUKPshViO1btS4UVFfP2ZdnXATUgNZDlrpifk/qXdadqoE3zP9Szl1n/nbEgXJQh6LrdZErUsx6ymMsmMqiy2pKGaN3D7ZNPxupYJBKxqqVY7re3D6TZfxZwaKGfUC/p+KpquU4ZBCXWPv61Px/jyBWqNew1NKL0cfwncv2GfQHPJD5mMwwJvb6YNMUP+JCoo6RhDmnxmmuvuMAeBY3htj3zjid7DSyG0BELlwoR/4D/flcEGQwdWavVpTUDKd944cOBVc71GlgnUNH3jS+BSOOn34/oUdlrvbD7fjKaVmjPPIjLzG76sqV3nAjBCR9d8Fzmv2sKnhaggPhDMIlz6y959D/iff5ijnFT/d4X5gBOlF4IydXw5dF7O2Impao3L9OrR/q347J01KIVR58M+jGCtWYwnUZVwJwlk5ThkBJZMvk2q6funiAk2HtEBor6I7nclzSM8goIPX4FEiFyxKyh3CCaDRtYoBgP/YNlglvmPmjgFzl1ufIGukg/Kqfwyy2LVVtdP1X3jwvDoFZIbMcq/ooXRl4qBTIwnFDvggWdUP7JrH+mBYpkn9LQOFHCFy7sAHie8sNAW7sSj6v+o65rvaH9xoNxI69mi9oGo4ABGYQMO2QlnYp+jNxNUmJ5ddoQBXlaGRKPCUXoc24IK4qtjqAR72KUgAVre8iNMhiuzT+h9aj+CdNqLgOyEbCnWBil16lQt1uuKqCZIdt9Ch4SWMj5qmpSfPQKi+jD2aqzjoTkFH1BYE4zXfF5q8dickuiDyGHT2opkMoQkdUtqDOYanf0kRMu5lBot9xffrtBV/wOyEK/FKzi86UiCjwd6TIi8DpzD6z1XGsjI1oQiRLKFMhK0IBOYY4mcepzdCYiBF1mUyIuZvWgdt3EP1R29jMBS+jqibIji33+itT1gpjs3BFDYV+12UXGo/ByXuR/x6CJrFCJA1qe0jfbGhkthNrs46nWxrs2B7RXj0U/WXJyOb7CbhcGFJsI/Y4l5VjtlKlFCqknMOUm9RE9soWxQEx/lmcHvZuTuA0k+OBglpnGanLWev4ZfhA7Az/qxwahjrlARw2CeTjrLspidEYJOGkauuVFgAZHMcQOnuRtZw== 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)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9qf9fw6Qgp/mhE1fV5gLFX/maJ8ddWp5NqzZ5uHy/WKrW56eC9g5XXQ1Fqg5aUabrqKNqqxR+RUQ6LkricuVpL428pQ52heFVq0lpKI/N3gD0sDc+kad2o4htblovd1jbLShW9FtRr6qhDeCz6HVHR/TYlKfQgOqhn1G4yibCkP3bWhGr+o/7pbwL+P5KhPb6h+RDsSvbjlIHrha/Mta3kbr0fnnks08QKfvr67J0zDLEA7Y0ATz7e0kAda+Lae3oemym2IkJ4Fdwk4DpmeCGOThPsQAH+jmodekLZlVZft+suvmSrSAGyYIMBup+dvIL1lc60jI1z063PyP9iKyHEO42XjQwOEF3UsuwxjIAOXr0yCQ7i5HDLhk2EilRksUt1GaZqEcN8UzzOn1lYGNT0hstY4hT0NKD7YHHfl4jg1kT2mKSQNcMfecqDSfQZIj4S6QVVaA4pQvrE/x00YiaO+KQPBGSM6898bMBXO3Laz40b5ew5HYbYRn29vG6ZO1jQus0IdTkvnw80RhKiqTdK+iH+iX0ElWrxYjAspPneZk9PvxhY7JOjtYwJrTNvule3zxeANX1Tq0OqHn+jUhjaoAXjgJcNw29PCtSiWaVOoPvgEuCwQfzoZKJR3XT0mXHHhuPFnU/ts6IHvyHhTIjUOuBInxJROC1kNtgd0paDg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:20.6365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79492c93-0672-41d9-b069-08dcf838cc4e 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: DB9P190MB1306 X-BESS-ID: 1730220204-311207-12673-27842-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.42 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYWxkYmQGYGUNQixdzQ1NIk1T zF0iwlKdXUODUtzTg11cLAzCIlLdUgRak2FgC50k2lQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan13-243.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 The Hasher module calculates a configurable hash value to be used internally by the FPGA. The module support both Toeplitz and NT-hash. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api.h | 40 + drivers/net/ntnic/include/flow_api_engine.h | 17 + drivers/net/ntnic/include/hw_mod_backend.h | 20 + .../ntnic/include/stream_binary_flow_api.h | 25 + drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 212 +++++ drivers/net/ntnic/nthw/flow_api/flow_hasher.c | 156 ++++ drivers/net/ntnic/nthw/flow_api/flow_hasher.h | 21 + drivers/net/ntnic/nthw/flow_api/flow_km.c | 25 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_hsh.c | 179 ++++ .../profile_inline/flow_api_hw_db_inline.c | 142 +++ .../profile_inline/flow_api_hw_db_inline.h | 11 + .../profile_inline/flow_api_profile_inline.c | 850 +++++++++++++++++- .../profile_inline/flow_api_profile_inline.h | 4 + drivers/net/ntnic/ntnic_mod_reg.h | 4 + 15 files changed, 1706 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_hasher.c create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_hasher.h diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index edffd0a57a..2e96fa5bed 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -29,6 +29,37 @@ struct hw_mod_resource_s { */ int flow_delete_eth_dev(struct flow_eth_dev *eth_dev); +/** + * A structure used to configure the Receive Side Scaling (RSS) feature + * of an Ethernet port. + */ +struct nt_eth_rss_conf { + /** + * In rte_eth_dev_rss_hash_conf_get(), the *rss_key_len* should be + * greater than or equal to the *hash_key_size* which get from + * rte_eth_dev_info_get() API. And the *rss_key* should contain at least + * *hash_key_size* bytes. If not meet these requirements, the query + * result is unreliable even if the operation returns success. + * + * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), if + * *rss_key* is not NULL, the *rss_key_len* indicates the length of the + * *rss_key* in bytes and it should be equal to *hash_key_size*. + * If *rss_key* is NULL, drivers are free to use a random or a default key. + */ + uint8_t rss_key[MAX_RSS_KEY_LEN]; + /** + * Indicates the type of packets or the specific part of packets to + * which RSS hashing is to be applied. + */ + uint64_t rss_hf; + /** + * Hash algorithm. + */ + enum rte_eth_hash_function algorithm; +}; + +int sprint_nt_rss_mask(char *str, uint16_t str_len, const char *prefix, uint64_t hash_mask); + struct flow_eth_dev { /* NIC that owns this port device */ struct flow_nic_dev *ndev; @@ -49,6 +80,11 @@ struct flow_eth_dev { struct flow_eth_dev *next; }; +enum flow_nic_hash_e { + HASH_ALGO_ROUND_ROBIN = 0, + HASH_ALGO_5TUPLE, +}; + /* registered NIC backends */ struct flow_nic_dev { uint8_t adapter_no; /* physical adapter no in the host system */ @@ -191,4 +227,8 @@ void flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int flow_nic_ref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index); int flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index); +int flow_nic_set_hasher(struct flow_nic_dev *ndev, int hsh_idx, enum flow_nic_hash_e algorithm); +int flow_nic_set_hasher_fields(struct flow_nic_dev *ndev, int hsh_idx, + struct nt_eth_rss_conf rss_conf); + #endif diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index a0f02f4e8a..e52363f04e 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -129,6 +129,7 @@ struct km_flow_def_s { int bank_used; uint32_t *cuckoo_moves; /* for CAM statistics only */ struct cam_distrib_s *cam_dist; + struct hasher_s *hsh; /* TCAM specific bank management */ struct tcam_distrib_s *tcam_dist; @@ -136,6 +137,17 @@ struct km_flow_def_s { int tcam_record; }; +/* + * RSS configuration, see struct rte_flow_action_rss + */ +struct hsh_def_s { + enum rte_eth_hash_function func; /* RSS hash function to apply */ + /* RSS hash types, see definition of RTE_ETH_RSS_* for hash calculation options */ + uint64_t types; + uint32_t key_len; /* Hash key length in bytes. */ + const uint8_t *key; /* Hash key. */ +}; + /* * Tunnel encapsulation header definition */ @@ -247,6 +259,11 @@ struct nic_flow_def { * Key Matcher flow definitions */ struct km_flow_def_s km; + + /* + * Hash module RSS definitions + */ + struct hsh_def_s hsh; }; enum flow_handle_type { diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 26903f2183..cee148807a 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -149,14 +149,27 @@ enum km_flm_if_select_e { int debug enum frame_offs_e { + DYN_SOF = 0, DYN_L2 = 1, DYN_FIRST_VLAN = 2, + DYN_MPLS = 3, DYN_L3 = 4, + DYN_ID_IPV4_6 = 5, + DYN_FINAL_IP_DST = 6, DYN_L4 = 7, DYN_L4_PAYLOAD = 8, + DYN_TUN_PAYLOAD = 9, + DYN_TUN_L2 = 10, + DYN_TUN_VLAN = 11, + DYN_TUN_MPLS = 12, DYN_TUN_L3 = 13, + DYN_TUN_ID_IPV4_6 = 14, + DYN_TUN_FINAL_IP_DST = 15, DYN_TUN_L4 = 16, DYN_TUN_L4_PAYLOAD = 17, + DYN_EOF = 18, + DYN_L3_PAYLOAD_END = 19, + DYN_TUN_L3_PAYLOAD_END = 20, SB_VNI = SWX_INFO | 1, SB_MAC_PORT = SWX_INFO | 2, SB_KCC_ID = SWX_INFO | 3 @@ -227,6 +240,11 @@ enum { }; +enum { + HASH_HASH_NONE = 0, + HASH_5TUPLE = 8, +}; + enum { CPY_SELECT_DSCP_IPV4 = 0, CPY_SELECT_DSCP_IPV6 = 1, @@ -670,6 +688,8 @@ int hw_mod_hsh_alloc(struct flow_api_backend_s *be); void hw_mod_hsh_free(struct flow_api_backend_s *be); int hw_mod_hsh_reset(struct flow_api_backend_s *be); int hw_mod_hsh_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_hsh_rcp_set(struct flow_api_backend_s *be, enum hw_hsh_e field, uint32_t index, + uint32_t word_off, uint32_t value); struct qsl_func_s { COMMON_FUNC_INFO_S; diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h index 8097518d61..e5fe686d99 100644 --- a/drivers/net/ntnic/include/stream_binary_flow_api.h +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -12,6 +12,31 @@ /* Max RSS hash key length in bytes */ #define MAX_RSS_KEY_LEN 40 +/* NT specific MASKs for RSS configuration */ +/* NOTE: Masks are required for correct RSS configuration, do not modify them! */ +#define NT_ETH_RSS_IPV4_MASK \ + (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV4_UDP) + +#define NT_ETH_RSS_IPV6_MASK \ + (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_IPV6_EX | \ + RTE_ETH_RSS_IPV6_TCP_EX | RTE_ETH_RSS_IPV6_UDP_EX | RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV6_UDP) + +#define NT_ETH_RSS_IP_MASK \ + (NT_ETH_RSS_IPV4_MASK | NT_ETH_RSS_IPV6_MASK | RTE_ETH_RSS_L3_SRC_ONLY | \ + RTE_ETH_RSS_L3_DST_ONLY) + +/* List of all RSS flags supported for RSS calculation offload */ +#define NT_ETH_RSS_OFFLOAD_MASK \ + (RTE_ETH_RSS_ETH | RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP | \ + RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_SRC_ONLY | RTE_ETH_RSS_L2_DST_ONLY | \ + RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY | RTE_ETH_RSS_L3_SRC_ONLY | \ + RTE_ETH_RSS_L3_DST_ONLY | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_LEVEL_MASK | \ + RTE_ETH_RSS_IPV4_CHKSUM | RTE_ETH_RSS_L4_CHKSUM | RTE_ETH_RSS_PORT | RTE_ETH_RSS_GTPU) + /* * Flow frontend for binary programming interface */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index e1fef37ccb..d7e6d05556 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -56,6 +56,7 @@ sources = files( 'nthw/flow_api/profile_inline/flow_api_hw_db_inline.c', 'nthw/flow_api/flow_backend/flow_backend.c', 'nthw/flow_api/flow_filter.c', + 'nthw/flow_api/flow_hasher.c', 'nthw/flow_api/flow_kcc.c', 'nthw/flow_api/flow_km.c', 'nthw/flow_api/hw_mod/hw_mod_backend.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index a51d621ef9..043e4244fc 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -2,6 +2,8 @@ * SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2023 Napatech A/S */ +#include "ntlog.h" +#include "nt_util.h" #include "flow_api_engine.h" #include "flow_api_nic_setup.h" @@ -12,6 +14,11 @@ #define SCATTER_GATHER +#define RSS_TO_STRING(name) \ + { \ + name, #name \ + } + const char *dbg_res_descr[] = { /* RES_QUEUE */ "RES_QUEUE", /* RES_CAT_CFN */ "RES_CAT_CFN", @@ -807,6 +814,211 @@ void *flow_api_get_be_dev(struct flow_nic_dev *ndev) return ndev->be.be_dev; } +/* Information for a given RSS type. */ +struct rss_type_info { + uint64_t rss_type; + const char *str; +}; + +static struct rss_type_info rss_to_string[] = { + /* RTE_BIT64(2) IPv4 dst + IPv4 src */ + RSS_TO_STRING(RTE_ETH_RSS_IPV4), + /* RTE_BIT64(3) IPv4 dst + IPv4 src + Identification of group of fragments */ + RSS_TO_STRING(RTE_ETH_RSS_FRAG_IPV4), + /* RTE_BIT64(4) IPv4 dst + IPv4 src + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_NONFRAG_IPV4_TCP), + /* RTE_BIT64(5) IPv4 dst + IPv4 src + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_NONFRAG_IPV4_UDP), + /* RTE_BIT64(6) IPv4 dst + IPv4 src + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_NONFRAG_IPV4_SCTP), + /* RTE_BIT64(7) IPv4 dst + IPv4 src + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_NONFRAG_IPV4_OTHER), + /* + * RTE_BIT64(14) 128-bits of L2 payload starting after src MAC, i.e. including optional + * VLAN tag and ethertype. Overrides all L3 and L4 flags at the same level, but inner + * L2 payload can be combined with outer S-VLAN and GTPU TEID flags. + */ + RSS_TO_STRING(RTE_ETH_RSS_L2_PAYLOAD), + /* RTE_BIT64(18) L4 dst + L4 src + L4 protocol - see comment of RTE_ETH_RSS_L4_CHKSUM */ + RSS_TO_STRING(RTE_ETH_RSS_PORT), + /* RTE_BIT64(19) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_VXLAN), + /* RTE_BIT64(20) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_GENEVE), + /* RTE_BIT64(21) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_NVGRE), + /* RTE_BIT64(23) GTP TEID - always from outer GTPU header */ + RSS_TO_STRING(RTE_ETH_RSS_GTPU), + /* RTE_BIT64(24) MAC dst + MAC src */ + RSS_TO_STRING(RTE_ETH_RSS_ETH), + /* RTE_BIT64(25) outermost VLAN ID + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_S_VLAN), + /* RTE_BIT64(26) innermost VLAN ID + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_C_VLAN), + /* RTE_BIT64(27) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_ESP), + /* RTE_BIT64(28) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_AH), + /* RTE_BIT64(29) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L2TPV3), + /* RTE_BIT64(30) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_PFCP), + /* RTE_BIT64(31) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_PPPOE), + /* RTE_BIT64(32) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_ECPRI), + /* RTE_BIT64(33) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_MPLS), + /* RTE_BIT64(34) IPv4 Header checksum + L4 protocol */ + RSS_TO_STRING(RTE_ETH_RSS_IPV4_CHKSUM), + + /* + * if combined with RTE_ETH_RSS_NONFRAG_IPV4_[TCP|UDP|SCTP] then + * L4 protocol + chosen protocol header Checksum + * else + * error + */ + /* RTE_BIT64(35) */ + RSS_TO_STRING(RTE_ETH_RSS_L4_CHKSUM), +#ifndef ANDROMEDA_DPDK_21_11 + /* RTE_BIT64(36) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L2TPV2), +#endif + + { RTE_BIT64(37), "unknown_RTE_BIT64(37)" }, + { RTE_BIT64(38), "unknown_RTE_BIT64(38)" }, + { RTE_BIT64(39), "unknown_RTE_BIT64(39)" }, + { RTE_BIT64(40), "unknown_RTE_BIT64(40)" }, + { RTE_BIT64(41), "unknown_RTE_BIT64(41)" }, + { RTE_BIT64(42), "unknown_RTE_BIT64(42)" }, + { RTE_BIT64(43), "unknown_RTE_BIT64(43)" }, + { RTE_BIT64(44), "unknown_RTE_BIT64(44)" }, + { RTE_BIT64(45), "unknown_RTE_BIT64(45)" }, + { RTE_BIT64(46), "unknown_RTE_BIT64(46)" }, + { RTE_BIT64(47), "unknown_RTE_BIT64(47)" }, + { RTE_BIT64(48), "unknown_RTE_BIT64(48)" }, + { RTE_BIT64(49), "unknown_RTE_BIT64(49)" }, + + /* RTE_BIT64(50) outermost encapsulation */ + RSS_TO_STRING(RTE_ETH_RSS_LEVEL_OUTERMOST), + /* RTE_BIT64(51) innermost encapsulation */ + RSS_TO_STRING(RTE_ETH_RSS_LEVEL_INNERMOST), + + /* RTE_BIT64(52) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE96), + /* RTE_BIT64(53) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE64), + /* RTE_BIT64(54) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE56), + /* RTE_BIT64(55) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE48), + /* RTE_BIT64(56) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE40), + /* RTE_BIT64(57) Not supported */ + RSS_TO_STRING(RTE_ETH_RSS_L3_PRE32), + + /* RTE_BIT64(58) */ + RSS_TO_STRING(RTE_ETH_RSS_L2_DST_ONLY), + /* RTE_BIT64(59) */ + RSS_TO_STRING(RTE_ETH_RSS_L2_SRC_ONLY), + /* RTE_BIT64(60) */ + RSS_TO_STRING(RTE_ETH_RSS_L4_DST_ONLY), + /* RTE_BIT64(61) */ + RSS_TO_STRING(RTE_ETH_RSS_L4_SRC_ONLY), + /* RTE_BIT64(62) */ + RSS_TO_STRING(RTE_ETH_RSS_L3_DST_ONLY), + /* RTE_BIT64(63) */ + RSS_TO_STRING(RTE_ETH_RSS_L3_SRC_ONLY), +}; + +int sprint_nt_rss_mask(char *str, uint16_t str_len, const char *prefix, uint64_t hash_mask) +{ + if (str == NULL || str_len == 0) + return -1; + + memset(str, 0x0, str_len); + uint16_t str_end = 0; + const struct rss_type_info *start = rss_to_string; + + for (const struct rss_type_info *p = start; p != start + ARRAY_SIZE(rss_to_string); ++p) { + if (p->rss_type & hash_mask) { + if (strlen(prefix) + strlen(p->str) < (size_t)(str_len - str_end)) { + snprintf(str + str_end, str_len - str_end, "%s", prefix); + str_end += strlen(prefix); + snprintf(str + str_end, str_len - str_end, "%s", p->str); + str_end += strlen(p->str); + + } else { + return -1; + } + } + } + + return 0; +} + +/* + * Hash + */ + +int flow_nic_set_hasher(struct flow_nic_dev *ndev, int hsh_idx, enum flow_nic_hash_e algorithm) +{ + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, hsh_idx, 0, 0); + + switch (algorithm) { + case HASH_ALGO_5TUPLE: + /* need to create an IPv6 hashing and enable the adaptive ip mask bit */ + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_LOAD_DIST_TYPE, hsh_idx, 0, 2); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_QW0_PE, hsh_idx, 0, DYN_FINAL_IP_DST); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_QW0_OFS, hsh_idx, 0, -16); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_QW4_PE, hsh_idx, 0, DYN_FINAL_IP_DST); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_QW4_OFS, hsh_idx, 0, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_W8_PE, hsh_idx, 0, DYN_L4); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_W8_OFS, hsh_idx, 0, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_W9_PE, hsh_idx, 0, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_W9_OFS, hsh_idx, 0, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_W9_P, hsh_idx, 0, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_P_MASK, hsh_idx, 0, 1); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 0, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 1, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 2, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 3, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 4, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 5, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 6, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 7, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 8, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, 9, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_SEED, hsh_idx, 0, 0xffffffff); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_HSH_VALID, hsh_idx, 0, 1); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_HSH_TYPE, hsh_idx, 0, HASH_5TUPLE); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_AUTO_IPV4_MASK, hsh_idx, 0, 1); + + NT_LOG(DBG, FILTER, "Set IPv6 5-tuple hasher with adaptive IPv4 hashing"); + break; + + default: + case HASH_ALGO_ROUND_ROBIN: + /* zero is round-robin */ + break; + } + + return 0; +} + +int flow_nic_set_hasher_fields(struct flow_nic_dev *ndev, int hsh_idx, + struct nt_eth_rss_conf rss_conf) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return profile_inline_ops->flow_nic_set_hasher_fields_inline(ndev, hsh_idx, rss_conf); +} + static const struct flow_filter_ops ops = { .flow_filter_init = flow_filter_init, .flow_filter_done = flow_filter_done, diff --git a/drivers/net/ntnic/nthw/flow_api/flow_hasher.c b/drivers/net/ntnic/nthw/flow_api/flow_hasher.c new file mode 100644 index 0000000000..86dfc16e79 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_hasher.c @@ -0,0 +1,156 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include + +#include "flow_hasher.h" + +static uint32_t shuffle(uint32_t x) +{ + return ((x & 0x00000002) << 29) | ((x & 0xAAAAAAA8) >> 3) | ((x & 0x15555555) << 3) | + ((x & 0x40000000) >> 29); +} + +static uint32_t ror_inv(uint32_t x, const int s) +{ + return (x >> s) | ((~x) << (32 - s)); +} + +static uint32_t combine(uint32_t x, uint32_t y) +{ + uint32_t x1 = ror_inv(x, 15); + uint32_t x2 = ror_inv(x, 13); + uint32_t y1 = ror_inv(y, 3); + uint32_t y2 = ror_inv(y, 27); + + return x ^ y ^ + ((x1 & y1 & ~x2 & ~y2) | (x1 & ~y1 & x2 & ~y2) | (x1 & ~y1 & ~x2 & y2) | + (~x1 & y1 & x2 & ~y2) | (~x1 & y1 & ~x2 & y2) | (~x1 & ~y1 & x2 & y2)); +} + +static uint32_t mix(uint32_t x, uint32_t y) +{ + return shuffle(combine(x, y)); +} + +static uint64_t ror_inv3(uint64_t x) +{ + const uint64_t m = 0xE0000000E0000000ULL; + + return ((x >> 3) | m) ^ ((x << 29) & m); +} + +static uint64_t ror_inv13(uint64_t x) +{ + const uint64_t m = 0xFFF80000FFF80000ULL; + + return ((x >> 13) | m) ^ ((x << 19) & m); +} + +static uint64_t ror_inv15(uint64_t x) +{ + const uint64_t m = 0xFFFE0000FFFE0000ULL; + + return ((x >> 15) | m) ^ ((x << 17) & m); +} + +static uint64_t ror_inv27(uint64_t x) +{ + const uint64_t m = 0xFFFFFFE0FFFFFFE0ULL; + + return ((x >> 27) | m) ^ ((x << 5) & m); +} + +static uint64_t shuffle64(uint64_t x) +{ + return ((x & 0x0000000200000002) << 29) | ((x & 0xAAAAAAA8AAAAAAA8) >> 3) | + ((x & 0x1555555515555555) << 3) | ((x & 0x4000000040000000) >> 29); +} + +static uint64_t pair(uint32_t x, uint32_t y) +{ + return ((uint64_t)x << 32) | y; +} + +static uint64_t combine64(uint64_t x, uint64_t y) +{ + uint64_t x1 = ror_inv15(x); + uint64_t x2 = ror_inv13(x); + uint64_t y1 = ror_inv3(y); + uint64_t y2 = ror_inv27(y); + + return x ^ y ^ + ((x1 & y1 & ~x2 & ~y2) | (x1 & ~y1 & x2 & ~y2) | (x1 & ~y1 & ~x2 & y2) | + (~x1 & y1 & x2 & ~y2) | (~x1 & y1 & ~x2 & y2) | (~x1 & ~y1 & x2 & y2)); +} + +static uint64_t mix64(uint64_t x, uint64_t y) +{ + return shuffle64(combine64(x, y)); +} + +static uint32_t calc16(const uint32_t key[16]) +{ + /* + * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Layer 0 + * \./ \./ \./ \./ \./ \./ \./ \./ + * 0 1 2 3 4 5 6 7 Layer 1 + * \__.__/ \__.__/ \__.__/ \__.__/ + * 0 1 2 3 Layer 2 + * \______.______/ \______.______/ + * 0 1 Layer 3 + * \______________.______________/ + * 0 Layer 4 + * / \ + * \./ + * 0 Layer 5 + * / \ + * \./ Layer 6 + * value + */ + + uint64_t z; + uint32_t x; + + z = mix64(mix64(mix64(pair(key[0], key[8]), pair(key[1], key[9])), + mix64(pair(key[2], key[10]), pair(key[3], key[11]))), + mix64(mix64(pair(key[4], key[12]), pair(key[5], key[13])), + mix64(pair(key[6], key[14]), pair(key[7], key[15])))); + + x = mix((uint32_t)(z >> 32), (uint32_t)z); + x = mix(x, ror_inv(x, 17)); + x = combine(x, ror_inv(x, 17)); + + return x; +} + +uint32_t gethash(struct hasher_s *hsh, const uint32_t key[16], int *result) +{ + uint64_t val; + uint32_t res; + + val = calc16(key); + res = (uint32_t)val; + + if (hsh->cam_bw > 32) + val = (val << (hsh->cam_bw - 32)) ^ val; + + for (int i = 0; i < hsh->banks; i++) { + result[i] = (unsigned int)(val & hsh->cam_records_bw_mask); + val = val >> hsh->cam_records_bw; + } + + return res; +} + +int init_hasher(struct hasher_s *hsh, int banks, int nb_records) +{ + hsh->banks = banks; + hsh->cam_records_bw = (int)(log2(nb_records - 1) + 1); + hsh->cam_records_bw_mask = (1U << hsh->cam_records_bw) - 1; + hsh->cam_bw = hsh->banks * hsh->cam_records_bw; + + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_hasher.h b/drivers/net/ntnic/nthw/flow_api/flow_hasher.h new file mode 100644 index 0000000000..15de8e9933 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_hasher.h @@ -0,0 +1,21 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_HASHER_H_ +#define _FLOW_HASHER_H_ + +#include + +struct hasher_s { + int banks; + int cam_records_bw; + uint32_t cam_records_bw_mask; + int cam_bw; +}; + +int init_hasher(struct hasher_s *hsh, int _banks, int nb_records); +uint32_t gethash(struct hasher_s *hsh, const uint32_t key[16], int *result); + +#endif /* _FLOW_HASHER_H_ */ diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c index 30d6ea728e..f79919cb81 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_km.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c @@ -9,6 +9,7 @@ #include "hw_mod_backend.h" #include "flow_api_engine.h" #include "nt_util.h" +#include "flow_hasher.h" #define MAX_QWORDS 2 #define MAX_SWORDS 2 @@ -75,10 +76,25 @@ static int tcam_find_mapping(struct km_flow_def_s *km); void km_attach_ndev_resource_management(struct km_flow_def_s *km, void **handle) { + /* + * KM entries occupied in CAM - to manage the cuckoo shuffling + * and manage CAM population and usage + * KM entries occupied in TCAM - to manage population and usage + */ + if (!*handle) { + *handle = calloc(1, + (size_t)CAM_ENTRIES + sizeof(uint32_t) + (size_t)TCAM_ENTRIES + + sizeof(struct hasher_s)); + NT_LOG(DBG, FILTER, "Allocate NIC DEV CAM and TCAM record manager"); + } + km->cam_dist = (struct cam_distrib_s *)*handle; km->cuckoo_moves = (uint32_t *)((char *)km->cam_dist + CAM_ENTRIES); km->tcam_dist = (struct tcam_distrib_s *)((char *)km->cam_dist + CAM_ENTRIES + sizeof(uint32_t)); + + km->hsh = (struct hasher_s *)((char *)km->tcam_dist + TCAM_ENTRIES); + init_hasher(km->hsh, km->be->km.nb_cam_banks, km->be->km.nb_cam_records); } void km_free_ndev_resource_management(void **handle) @@ -839,9 +855,18 @@ static int move_cuckoo_index_level(struct km_flow_def_s *km_parent, int bank_idx static int km_write_data_to_cam(struct km_flow_def_s *km) { int res = 0; + int val[MAX_BANKS]; assert(km->be->km.nb_cam_banks <= MAX_BANKS); assert(km->cam_dist); + /* word list without info set */ + gethash(km->hsh, km->entry_word, val); + + for (uint32_t i = 0; i < km->be->km.nb_cam_banks; i++) { + /* if paired we start always on an even address - reset bit 0 */ + km->record_indexes[i] = (km->cam_paired) ? val[i] & ~1 : val[i]; + } + NT_LOG(DBG, FILTER, "KM HASH [%03X, %03X, %03X]", km->record_indexes[0], km->record_indexes[1], km->record_indexes[2]); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_hsh.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_hsh.c index df5c00ac42..1750d09afb 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_hsh.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_hsh.c @@ -89,3 +89,182 @@ int hw_mod_hsh_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->hsh_rcp_flush(be->be_dev, &be->hsh, start_idx, count); } + +static int hw_mod_hsh_rcp_mod(struct flow_api_backend_s *be, enum hw_hsh_e field, uint32_t index, + uint32_t word_off, uint32_t *value, int get) +{ + if (index >= be->hsh.nb_rcp) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 5: + switch (field) { + case HW_HSH_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->hsh.v5.rcp[index], (uint8_t)*value, + sizeof(struct hsh_v5_rcp_s)); + break; + + case HW_HSH_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if ((unsigned int)word_off >= be->hsh.nb_rcp) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->hsh.v5.rcp, struct hsh_v5_rcp_s, index, word_off); + break; + + case HW_HSH_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if ((unsigned int)word_off >= be->hsh.nb_rcp) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->hsh.v5.rcp, struct hsh_v5_rcp_s, index, word_off, + be->hsh.nb_rcp); + break; + + case HW_HSH_RCP_LOAD_DIST_TYPE: + GET_SET(be->hsh.v5.rcp[index].load_dist_type, value); + break; + + case HW_HSH_RCP_MAC_PORT_MASK: + if (word_off > HSH_RCP_MAC_PORT_MASK_SIZE) { + WORD_OFF_TOO_LARGE_LOG; + return WORD_OFF_TOO_LARGE; + } + + GET_SET(be->hsh.v5.rcp[index].mac_port_mask[word_off], value); + break; + + case HW_HSH_RCP_SORT: + GET_SET(be->hsh.v5.rcp[index].sort, value); + break; + + case HW_HSH_RCP_QW0_PE: + GET_SET(be->hsh.v5.rcp[index].qw0_pe, value); + break; + + case HW_HSH_RCP_QW0_OFS: + GET_SET_SIGNED(be->hsh.v5.rcp[index].qw0_ofs, value); + break; + + case HW_HSH_RCP_QW4_PE: + GET_SET(be->hsh.v5.rcp[index].qw4_pe, value); + break; + + case HW_HSH_RCP_QW4_OFS: + GET_SET_SIGNED(be->hsh.v5.rcp[index].qw4_ofs, value); + break; + + case HW_HSH_RCP_W8_PE: + GET_SET(be->hsh.v5.rcp[index].w8_pe, value); + break; + + case HW_HSH_RCP_W8_OFS: + GET_SET_SIGNED(be->hsh.v5.rcp[index].w8_ofs, value); + break; + + case HW_HSH_RCP_W8_SORT: + GET_SET(be->hsh.v5.rcp[index].w8_sort, value); + break; + + case HW_HSH_RCP_W9_PE: + GET_SET(be->hsh.v5.rcp[index].w9_pe, value); + break; + + case HW_HSH_RCP_W9_OFS: + GET_SET_SIGNED(be->hsh.v5.rcp[index].w9_ofs, value); + break; + + case HW_HSH_RCP_W9_SORT: + GET_SET(be->hsh.v5.rcp[index].w9_sort, value); + break; + + case HW_HSH_RCP_W9_P: + GET_SET(be->hsh.v5.rcp[index].w9_p, value); + break; + + case HW_HSH_RCP_P_MASK: + GET_SET(be->hsh.v5.rcp[index].p_mask, value); + break; + + case HW_HSH_RCP_WORD_MASK: + if (word_off > HSH_RCP_WORD_MASK_SIZE) { + WORD_OFF_TOO_LARGE_LOG; + return WORD_OFF_TOO_LARGE; + } + + GET_SET(be->hsh.v5.rcp[index].word_mask[word_off], value); + break; + + case HW_HSH_RCP_SEED: + GET_SET(be->hsh.v5.rcp[index].seed, value); + break; + + case HW_HSH_RCP_TNL_P: + GET_SET(be->hsh.v5.rcp[index].tnl_p, value); + break; + + case HW_HSH_RCP_HSH_VALID: + GET_SET(be->hsh.v5.rcp[index].hsh_valid, value); + break; + + case HW_HSH_RCP_HSH_TYPE: + GET_SET(be->hsh.v5.rcp[index].hsh_type, value); + break; + + case HW_HSH_RCP_TOEPLITZ: + GET_SET(be->hsh.v5.rcp[index].toeplitz, value); + break; + + case HW_HSH_RCP_K: + if (word_off > HSH_RCP_KEY_SIZE) { + WORD_OFF_TOO_LARGE_LOG; + return WORD_OFF_TOO_LARGE; + } + + GET_SET(be->hsh.v5.rcp[index].k[word_off], value); + break; + + case HW_HSH_RCP_AUTO_IPV4_MASK: + GET_SET(be->hsh.v5.rcp[index].auto_ipv4_mask, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 5 */ + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_hsh_rcp_set(struct flow_api_backend_s *be, enum hw_hsh_e field, uint32_t index, + uint32_t word_off, uint32_t value) +{ + return hw_mod_hsh_rcp_mod(be, field, index, word_off, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 4737460cdf..068c890b45 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -30,9 +30,15 @@ struct hw_db_inline_resource_db { int ref; } *slc_lr; + struct hw_db_inline_resource_db_hsh { + struct hw_db_inline_hsh_data data; + int ref; + } *hsh; + uint32_t nb_cot; uint32_t nb_qsl; uint32_t nb_slc_lr; + uint32_t nb_hsh; /* Items */ struct hw_db_inline_resource_db_cat { @@ -122,6 +128,21 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) } } + db->cfn = calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_cfn)); + + if (db->cfn == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->nb_hsh = ndev->be.hsh.nb_rcp; + db->hsh = calloc(db->nb_hsh, sizeof(struct hw_db_inline_resource_db_hsh)); + + if (db->hsh == NULL) { + hw_db_inline_destroy(db); + return -1; + } + *db_handle = db; return 0; } @@ -133,6 +154,8 @@ void hw_db_inline_destroy(void *db_handle) free(db->cot); free(db->qsl); free(db->slc_lr); + free(db->hsh); + free(db->cat); if (db->km) { @@ -180,6 +203,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_inline_km_ft_deref(ndev, db_handle, *(struct hw_db_km_ft *)&idxs[i]); break; + case HW_DB_IDX_TYPE_HSH: + hw_db_inline_hsh_deref(ndev, db_handle, *(struct hw_db_hsh_idx *)&idxs[i]); + break; + default: break; } @@ -219,6 +246,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_KM_FT: return NULL; /* FTs can't be easily looked up */ + case HW_DB_IDX_TYPE_HSH: + return &db->hsh[idxs[i].ids].data; + default: return NULL; } @@ -247,6 +277,7 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, { (void)ft; (void)qsl_hw_id; + (void)ft; const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; (void)offset; @@ -848,3 +879,114 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } + +/******************************************************************************/ +/* HSH */ +/******************************************************************************/ + +static int hw_db_inline_hsh_compare(const struct hw_db_inline_hsh_data *data1, + const struct hw_db_inline_hsh_data *data2) +{ + for (uint32_t i = 0; i < MAX_RSS_KEY_LEN; ++i) + if (data1->key[i] != data2->key[i]) + return 0; + + return data1->func == data2->func && data1->hash_mask == data2->hash_mask; +} + +struct hw_db_hsh_idx hw_db_inline_hsh_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_hsh_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_hsh_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_HSH; + + /* check if default hash configuration shall be used, i.e. rss_hf is not set */ + /* + * NOTE: hsh id 0 is reserved for "default" + * HSH used by port configuration; All ports share the same default hash settings. + */ + if (data->hash_mask == 0) { + idx.ids = 0; + hw_db_inline_hsh_ref(ndev, db, idx); + return idx; + } + + for (uint32_t i = 1; i < db->nb_hsh; ++i) { + int ref = db->hsh[i].ref; + + if (ref > 0 && hw_db_inline_hsh_compare(data, &db->hsh[i].data)) { + idx.ids = i; + hw_db_inline_hsh_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + struct nt_eth_rss_conf tmp_rss_conf; + + tmp_rss_conf.rss_hf = data->hash_mask; + memcpy(tmp_rss_conf.rss_key, data->key, MAX_RSS_KEY_LEN); + tmp_rss_conf.algorithm = data->func; + int res = flow_nic_set_hasher_fields(ndev, idx.ids, tmp_rss_conf); + + if (res != 0) { + idx.error = 1; + return idx; + } + + db->hsh[idx.ids].ref = 1; + memcpy(&db->hsh[idx.ids].data, data, sizeof(struct hw_db_inline_hsh_data)); + flow_nic_mark_resource_used(ndev, RES_HSH_RCP, idx.ids); + + hw_mod_hsh_rcp_flush(&ndev->be, idx.ids, 1); + + return idx; +} + +void hw_db_inline_hsh_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_hsh_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->hsh[idx.ids].ref += 1; +} + +void hw_db_inline_hsh_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_hsh_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->hsh[idx.ids].ref -= 1; + + if (db->hsh[idx.ids].ref <= 0) { + /* + * NOTE: hsh id 0 is reserved for "default" HSH used by + * port configuration, so we shall keep it even if + * it is not used by any flow + */ + if (idx.ids > 0) { + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, idx.ids, 0, 0x0); + hw_mod_hsh_rcp_flush(&ndev->be, idx.ids, 1); + + memset(&db->hsh[idx.ids].data, 0x0, sizeof(struct hw_db_inline_hsh_data)); + flow_nic_free_resource(ndev, RES_HSH_RCP, idx.ids); + } + + db->hsh[idx.ids].ref = 0; + } +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index e104ba7327..c97bdef1b7 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -60,6 +60,10 @@ struct hw_db_km_ft { HW_DB_IDX; }; +struct hw_db_hsh_idx { + HW_DB_IDX; +}; + enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, @@ -68,6 +72,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_SLC_LR, HW_DB_IDX_TYPE_KM_RCP, HW_DB_IDX_TYPE_KM_FT, + HW_DB_IDX_TYPE_HSH, }; /* Functionality data types */ @@ -133,6 +138,7 @@ struct hw_db_inline_action_set_data { struct { struct hw_db_cot_idx cot; struct hw_db_qsl_idx qsl; + struct hw_db_hsh_idx hsh; }; }; }; @@ -175,6 +181,11 @@ void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_slc_lr_idx idx); +struct hw_db_hsh_idx hw_db_inline_hsh_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_hsh_data *data); +void hw_db_inline_hsh_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_hsh_idx idx); +void hw_db_inline_hsh_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_hsh_idx idx); + /**/ struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, 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 78d662d70c..f6482941d6 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 @@ -25,6 +25,15 @@ #define NT_VIOLATING_MBR_CFN 0 #define NT_VIOLATING_MBR_QSL 1 +#define RTE_ETH_RSS_UDP_COMBINED \ + (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_IPV6_UDP_EX) + +#define RTE_ETH_RSS_TCP_COMBINED \ + (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_IPV6_TCP_EX) + +#define NT_FLM_OP_UNLEARN 0 +#define NT_FLM_OP_LEARN 1 + static void *flm_lrn_queue_arr; static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) @@ -2322,10 +2331,27 @@ static void setup_db_qsl_data(struct nic_flow_def *fd, struct hw_db_inline_qsl_d } } +static void setup_db_hsh_data(struct nic_flow_def *fd, struct hw_db_inline_hsh_data *hsh_data) +{ + memset(hsh_data, 0x0, sizeof(struct hw_db_inline_hsh_data)); + + hsh_data->func = fd->hsh.func; + hsh_data->hash_mask = fd->hsh.types; + + if (fd->hsh.key != NULL) { + /* + * Just a safeguard. Check and error handling of rss_key_len + * shall be done at api layers above. + */ + memcpy(&hsh_data->key, fd->hsh.key, + fd->hsh.key_len < MAX_RSS_KEY_LEN ? fd->hsh.key_len : MAX_RSS_KEY_LEN); + } +} + static int setup_flow_flm_actions(struct flow_eth_dev *dev, const struct nic_flow_def *fd, const struct hw_db_inline_qsl_data *qsl_data, - const struct hw_db_inline_hsh_data *hsh_data __rte_unused, + const struct hw_db_inline_hsh_data *hsh_data, uint32_t group __rte_unused, uint32_t local_idxs[], uint32_t *local_idx_counter, @@ -2362,6 +2388,17 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, return -1; } + /* Setup HSH */ + struct hw_db_hsh_idx hsh_idx = + hw_db_inline_hsh_add(dev->ndev, dev->ndev->hw_db_handle, hsh_data); + local_idxs[(*local_idx_counter)++] = hsh_idx.raw; + + if (hsh_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference HSH resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + /* Setup SLC LR */ struct hw_db_slc_lr_idx slc_lr_idx = { .raw = 0 }; @@ -2405,6 +2442,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n 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); if (attr->group > 0 && fd_has_empty_pattern(fd)) { /* @@ -2488,6 +2526,19 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); goto error_out; } + + /* Setup HSH */ + struct hw_db_hsh_idx hsh_idx = + hw_db_inline_hsh_add(dev->ndev, dev->ndev->hw_db_handle, + &hsh_data); + fh->db_idxs[fh->db_idx_counter++] = hsh_idx.raw; + action_set_data.hsh = hsh_idx; + + if (hsh_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference HSH resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } } /* Setup CAT */ @@ -2667,6 +2718,126 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n return NULL; } +/* + * Public functions + */ + +/* + * FPGA uses up to 10 32-bit words (320 bits) for hash calculation + 8 bits for L4 protocol number. + * Hashed data are split between two 128-bit Quad Words (QW) + * and two 32-bit Words (W), which can refer to different header parts. + */ +enum hsh_words_id { + HSH_WORDS_QW0 = 0, + HSH_WORDS_QW4, + HSH_WORDS_W8, + HSH_WORDS_W9, + HSH_WORDS_SIZE, +}; + +/* struct with details about hash QWs & Ws */ +struct hsh_words { + /* + * index of W (word) or index of 1st word of QW (quad word) + * is used for hash mask calculation + */ + uint8_t index; + uint8_t toeplitz_index; /* offset in Bytes of given [Q]W inside Toeplitz RSS key */ + enum hw_hsh_e pe; /* offset to header part, e.g. beginning of L4 */ + enum hw_hsh_e ofs; /* relative offset in BYTES to 'pe' header offset above */ + uint16_t bit_len; /* max length of header part in bits to fit into QW/W */ + bool free; /* only free words can be used for hsh calculation */ +}; + +static enum hsh_words_id get_free_word(struct hsh_words *words, uint16_t bit_len) +{ + enum hsh_words_id ret = HSH_WORDS_SIZE; + uint16_t ret_bit_len = UINT16_MAX; + + for (enum hsh_words_id i = HSH_WORDS_QW0; i < HSH_WORDS_SIZE; i++) { + if (words[i].free && bit_len <= words[i].bit_len && + words[i].bit_len < ret_bit_len) { + ret = i; + ret_bit_len = words[i].bit_len; + } + } + + return ret; +} + +static int flow_nic_set_hasher_part_inline(struct flow_nic_dev *ndev, int hsh_idx, + struct hsh_words *words, uint32_t pe, uint32_t ofs, + int bit_len, bool toeplitz) +{ + int res = 0; + + /* check if there is any free word, which can accommodate header part of given 'bit_len' */ + enum hsh_words_id word = get_free_word(words, bit_len); + + if (word == HSH_WORDS_SIZE) { + NT_LOG(ERR, FILTER, "Cannot add additional %d bits into hash", bit_len); + return -1; + } + + words[word].free = false; + + res |= hw_mod_hsh_rcp_set(&ndev->be, words[word].pe, hsh_idx, 0, pe); + NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %d)", words[word].pe, + hsh_idx, pe); + res |= hw_mod_hsh_rcp_set(&ndev->be, words[word].ofs, hsh_idx, 0, ofs); + NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %d)", words[word].ofs, + hsh_idx, ofs); + + /* set HW_HSH_RCP_WORD_MASK based on used QW/W and given 'bit_len' */ + int mask_bit_len = bit_len; + uint32_t mask = 0x0; + uint32_t mask_be = 0x0; + uint32_t toeplitz_mask[9] = { 0x0 }; + /* iterate through all words of QW */ + uint16_t words_count = words[word].bit_len / 32; + + for (uint16_t mask_off = 1; mask_off <= words_count; mask_off++) { + if (mask_bit_len >= 32) { + mask_bit_len -= 32; + mask = 0xffffffff; + mask_be = mask; + + } else if (mask_bit_len > 0) { + /* keep bits from left to right, i.e. little to big endian */ + mask_be = 0xffffffff >> (32 - mask_bit_len); + mask = mask_be << (32 - mask_bit_len); + mask_bit_len = 0; + + } else { + mask = 0x0; + mask_be = 0x0; + } + + /* reorder QW words mask from little to big endian */ + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, + words[word].index + words_count - mask_off, mask); + NT_LOG(DBG, FILTER, + "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, %d, %d, 0x%" PRIX32 + ")", + hsh_idx, words[word].index + words_count - mask_off, mask); + toeplitz_mask[words[word].toeplitz_index + mask_off - 1] = mask_be; + } + + if (toeplitz) { + NT_LOG(DBG, FILTER, + "Partial Toeplitz RSS key mask: %08" PRIX32 " %08" PRIX32 " %08" PRIX32 + " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 + " %08" PRIX32 "", + toeplitz_mask[8], toeplitz_mask[7], toeplitz_mask[6], toeplitz_mask[5], + toeplitz_mask[4], toeplitz_mask[3], toeplitz_mask[2], toeplitz_mask[1], + toeplitz_mask[0]); + NT_LOG(DBG, FILTER, + " MSB LSB"); + } + + return res; +} + /* * Public functions */ @@ -2717,6 +2888,12 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_mark_resource_used(ndev, RES_PDB_RCP, 0); + /* Set default hasher recipe to 5-tuple */ + flow_nic_set_hasher(ndev, 0, HASH_ALGO_5TUPLE); + hw_mod_hsh_rcp_flush(&ndev->be, 0, 1); + + flow_nic_mark_resource_used(ndev, RES_HSH_RCP, 0); + /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); flow_nic_mark_resource_used(ndev, RES_QSL_RCP, NT_VIOLATING_MBR_QSL); @@ -2783,6 +2960,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) hw_mod_pdb_rcp_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_PDB_RCP, 0); + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, 0, 0, 0); + hw_mod_hsh_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_HSH_RCP, 0); + hw_db_inline_destroy(ndev->hw_db_handle); #ifdef FLOW_DEBUG @@ -2980,6 +3161,672 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *fl return err; } +static __rte_always_inline bool all_bits_enabled(uint64_t hash_mask, uint64_t hash_bits) +{ + return (hash_mask & hash_bits) == hash_bits; +} + +static __rte_always_inline void unset_bits(uint64_t *hash_mask, uint64_t hash_bits) +{ + *hash_mask &= ~hash_bits; +} + +static __rte_always_inline void unset_bits_and_log(uint64_t *hash_mask, uint64_t hash_bits) +{ + char rss_buffer[4096]; + uint16_t rss_buffer_len = sizeof(rss_buffer); + + if (sprint_nt_rss_mask(rss_buffer, rss_buffer_len, " ", *hash_mask & hash_bits) == 0) + NT_LOG(DBG, FILTER, "Configured RSS types:%s", rss_buffer); + + unset_bits(hash_mask, hash_bits); +} + +static __rte_always_inline void unset_bits_if_all_enabled(uint64_t *hash_mask, uint64_t hash_bits) +{ + if (all_bits_enabled(*hash_mask, hash_bits)) + unset_bits(hash_mask, hash_bits); +} + +int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, + struct nt_eth_rss_conf rss_conf) +{ + uint64_t fields = rss_conf.rss_hf; + + char rss_buffer[4096]; + uint16_t rss_buffer_len = sizeof(rss_buffer); + + if (sprint_nt_rss_mask(rss_buffer, rss_buffer_len, " ", fields) == 0) + NT_LOG(DBG, FILTER, "Requested RSS types:%s", rss_buffer); + + /* + * configure all (Q)Words usable for hash calculation + * Hash can be calculated from 4 independent header parts: + * | QW0 | Qw4 | W8| W9| + * word | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + */ + struct hsh_words words[HSH_WORDS_SIZE] = { + { 0, 5, HW_HSH_RCP_QW0_PE, HW_HSH_RCP_QW0_OFS, 128, true }, + { 4, 1, HW_HSH_RCP_QW4_PE, HW_HSH_RCP_QW4_OFS, 128, true }, + { 8, 0, HW_HSH_RCP_W8_PE, HW_HSH_RCP_W8_OFS, 32, true }, + { + 9, 255, HW_HSH_RCP_W9_PE, HW_HSH_RCP_W9_OFS, 32, + true + }, /* not supported for Toeplitz */ + }; + + int res = 0; + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, hsh_idx, 0, 0); + /* enable hashing */ + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_LOAD_DIST_TYPE, hsh_idx, 0, 2); + + /* configure selected hash function and its key */ + bool toeplitz = false; + + switch (rss_conf.algorithm) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + /* Use default NTH10 hashing algorithm */ + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_TOEPLITZ, hsh_idx, 0, 0); + /* Use 1st 32-bits from rss_key to configure NTH10 SEED */ + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_SEED, hsh_idx, 0, + rss_conf.rss_key[0] << 24 | rss_conf.rss_key[1] << 16 | + rss_conf.rss_key[2] << 8 | rss_conf.rss_key[3]); + break; + + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + toeplitz = true; + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_TOEPLITZ, hsh_idx, 0, 1); + uint8_t empty_key = 0; + + /* Toeplitz key (always 40B) must be encoded from little to big endian */ + for (uint8_t i = 0; i <= (MAX_RSS_KEY_LEN - 8); i += 8) { + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, hsh_idx, i / 4, + rss_conf.rss_key[i + 4] << 24 | + rss_conf.rss_key[i + 5] << 16 | + rss_conf.rss_key[i + 6] << 8 | + rss_conf.rss_key[i + 7]); + NT_LOG(DBG, FILTER, + "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, %d, %d, 0x%" PRIX32 + ")", + hsh_idx, i / 4, + rss_conf.rss_key[i + 4] << 24 | rss_conf.rss_key[i + 5] << 16 | + rss_conf.rss_key[i + 6] << 8 | rss_conf.rss_key[i + 7]); + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, hsh_idx, i / 4 + 1, + rss_conf.rss_key[i] << 24 | + rss_conf.rss_key[i + 1] << 16 | + rss_conf.rss_key[i + 2] << 8 | + rss_conf.rss_key[i + 3]); + NT_LOG(DBG, FILTER, + "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, %d, %d, 0x%" PRIX32 + ")", + hsh_idx, i / 4 + 1, + rss_conf.rss_key[i] << 24 | rss_conf.rss_key[i + 1] << 16 | + rss_conf.rss_key[i + 2] << 8 | rss_conf.rss_key[i + 3]); + empty_key |= rss_conf.rss_key[i] | rss_conf.rss_key[i + 1] | + rss_conf.rss_key[i + 2] | rss_conf.rss_key[i + 3] | + rss_conf.rss_key[i + 4] | rss_conf.rss_key[i + 5] | + rss_conf.rss_key[i + 6] | rss_conf.rss_key[i + 7]; + } + + if (empty_key == 0) { + NT_LOG(ERR, FILTER, + "Toeplitz key must be configured. Key with all bytes set to zero is not allowed."); + return -1; + } + + words[HSH_WORDS_W9].free = false; + NT_LOG(DBG, FILTER, + "Toeplitz hashing is enabled thus W9 and P_MASK cannot be used."); + break; + + default: + NT_LOG(ERR, FILTER, "Unknown hashing function %d requested", rss_conf.algorithm); + return -1; + } + + /* indication that some IPv6 flag is present */ + bool ipv6 = fields & (NT_ETH_RSS_IPV6_MASK); + /* store proto mask for later use at IP and L4 checksum handling */ + uint64_t l4_proto_mask = fields & + (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_UDP | + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | + RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_NONFRAG_IPV6_UDP | + RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_OTHER | + RTE_ETH_RSS_IPV6_TCP_EX | RTE_ETH_RSS_IPV6_UDP_EX); + + /* outermost headers are used by default, so innermost bit takes precedence if detected */ + bool outer = (fields & RTE_ETH_RSS_LEVEL_INNERMOST) ? false : true; + unset_bits(&fields, RTE_ETH_RSS_LEVEL_MASK); + + if (fields == 0) { + NT_LOG(ERR, FILTER, "RSS hash configuration 0x%" PRIX64 " is not valid.", + rss_conf.rss_hf); + return -1; + } + + /* indication that IPv4 `protocol` or IPv6 `next header` fields shall be part of the hash + */ + bool l4_proto_hash = false; + + /* + * check if SRC_ONLY & DST_ONLY are used simultaneously; + * According to DPDK, we shall behave like none of these bits is set + */ + unset_bits_if_all_enabled(&fields, RTE_ETH_RSS_L2_SRC_ONLY | RTE_ETH_RSS_L2_DST_ONLY); + unset_bits_if_all_enabled(&fields, RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY); + unset_bits_if_all_enabled(&fields, RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY); + + /* L2 */ + if (fields & (RTE_ETH_RSS_ETH | RTE_ETH_RSS_L2_SRC_ONLY | RTE_ETH_RSS_L2_DST_ONLY)) { + if (outer) { + if (fields & RTE_ETH_RSS_L2_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set outer src MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L2, 6, 48, toeplitz); + + } else if (fields & RTE_ETH_RSS_L2_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set outer dst MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L2, 0, 48, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set outer src & dst MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L2, 0, 96, toeplitz); + } + + } else if (fields & RTE_ETH_RSS_L2_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set inner src MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L2, 6, + 48, toeplitz); + + } else if (fields & RTE_ETH_RSS_L2_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set inner dst MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L2, 0, + 48, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner src & dst MAC hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L2, 0, + 96, toeplitz); + } + + unset_bits_and_log(&fields, + RTE_ETH_RSS_ETH | RTE_ETH_RSS_L2_SRC_ONLY | + RTE_ETH_RSS_L2_DST_ONLY); + } + + /* + * VLAN support of multiple VLAN headers, + * where S-VLAN is the first and C-VLAN the last VLAN header + */ + if (fields & RTE_ETH_RSS_C_VLAN) { + /* + * use MPLS protocol offset, which points just after ethertype with relative + * offset -6 (i.e. 2 bytes + * of ethertype & size + 4 bytes of VLAN header field) to access last vlan header + */ + if (outer) { + NT_LOG(DBG, FILTER, "Set outer C-VLAN hasher."); + /* + * use whole 32-bit 802.1a tag - backward compatible + * with VSWITCH implementation + */ + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_MPLS, -6, + 32, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner C-VLAN hasher."); + /* + * use whole 32-bit 802.1a tag - backward compatible + * with VSWITCH implementation + */ + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_MPLS, + -6, 32, toeplitz); + } + + unset_bits_and_log(&fields, RTE_ETH_RSS_C_VLAN); + } + + if (fields & RTE_ETH_RSS_S_VLAN) { + if (outer) { + NT_LOG(DBG, FILTER, "Set outer S-VLAN hasher."); + /* + * use whole 32-bit 802.1a tag - backward compatible + * with VSWITCH implementation + */ + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_FIRST_VLAN, 0, 32, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner S-VLAN hasher."); + /* + * use whole 32-bit 802.1a tag - backward compatible + * with VSWITCH implementation + */ + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_VLAN, + 0, 32, toeplitz); + } + + unset_bits_and_log(&fields, RTE_ETH_RSS_S_VLAN); + } + /* L2 payload */ + /* calculate hash of 128-bits of l2 payload; Use MPLS protocol offset to address the + * beginning of L2 payload even if MPLS header is not present + */ + if (fields & RTE_ETH_RSS_L2_PAYLOAD) { + uint64_t outer_fields_enabled = 0; + + if (outer) { + NT_LOG(DBG, FILTER, "Set outer L2 payload hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_MPLS, 0, + 128, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner L2 payload hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_MPLS, + 0, 128, toeplitz); + outer_fields_enabled = fields & RTE_ETH_RSS_GTPU; + } + + /* + * L2 PAYLOAD hashing overrides all L3 & L4 RSS flags. + * Thus we can clear all remaining (supported) + * RSS flags... + */ + unset_bits_and_log(&fields, NT_ETH_RSS_OFFLOAD_MASK); + /* + * ...but in case of INNER L2 PAYLOAD we must process + * "always outer" GTPU field if enabled + */ + fields |= outer_fields_enabled; + } + + /* L3 + L4 protocol number */ + if (fields & RTE_ETH_RSS_IPV4_CHKSUM) { + /* only IPv4 checksum is supported by DPDK RTE_ETH_RSS_* types */ + if (ipv6) { + NT_LOG(ERR, FILTER, + "RSS: IPv4 checksum requested with IPv6 header hashing!"); + res = 1; + + } else if (outer) { + NT_LOG(DBG, FILTER, "Set outer IPv4 checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_L3, 10, + 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner IPv4 checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L3, + 10, 16, toeplitz); + } + + /* + * L3 checksum is made from whole L3 header, i.e. no need to process other + * L3 hashing flags + */ + unset_bits_and_log(&fields, RTE_ETH_RSS_IPV4_CHKSUM | NT_ETH_RSS_IP_MASK); + } + + if (fields & NT_ETH_RSS_IP_MASK) { + if (ipv6) { + if (outer) { + if (fields & RTE_ETH_RSS_L3_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set outer IPv6/IPv4 src hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_FINAL_IP_DST, + -16, 128, toeplitz); + + } else if (fields & RTE_ETH_RSS_L3_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set outer IPv6/IPv4 dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_FINAL_IP_DST, 0, + 128, toeplitz); + + } else { + NT_LOG(DBG, FILTER, + "Set outer IPv6/IPv4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_FINAL_IP_DST, + -16, 128, toeplitz); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_FINAL_IP_DST, 0, + 128, toeplitz); + } + + } else if (fields & RTE_ETH_RSS_L3_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set inner IPv6/IPv4 src hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_FINAL_IP_DST, -16, + 128, toeplitz); + + } else if (fields & RTE_ETH_RSS_L3_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set inner IPv6/IPv4 dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_FINAL_IP_DST, 0, + 128, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner IPv6/IPv4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_FINAL_IP_DST, -16, + 128, toeplitz); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_FINAL_IP_DST, 0, + 128, toeplitz); + } + + /* check if fragment ID shall be part of hash */ + if (fields & (RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_FRAG_IPV6)) { + if (outer) { + NT_LOG(DBG, FILTER, + "Set outer IPv6/IPv4 fragment ID hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_ID_IPV4_6, 0, + 32, toeplitz); + + } else { + NT_LOG(DBG, FILTER, + "Set inner IPv6/IPv4 fragment ID hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_TUN_ID_IPV4_6, + 0, 32, toeplitz); + } + } + + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_AUTO_IPV4_MASK, hsh_idx, 0, + 1); + + } else { + /* IPv4 */ + if (outer) { + if (fields & RTE_ETH_RSS_L3_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set outer IPv4 src only hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_L3, 12, + 32, toeplitz); + + } else if (fields & RTE_ETH_RSS_L3_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set outer IPv4 dst only hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_L3, 16, + 32, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set outer IPv4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_L3, 12, + 64, toeplitz); + } + + } else if (fields & RTE_ETH_RSS_L3_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set inner IPv4 src only hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L3, 12, 32, + toeplitz); + + } else if (fields & RTE_ETH_RSS_L3_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set inner IPv4 dst only hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L3, 16, 32, + toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner IPv4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L3, 12, 64, + toeplitz); + } + + /* check if fragment ID shall be part of hash */ + if (fields & RTE_ETH_RSS_FRAG_IPV4) { + if (outer) { + NT_LOG(DBG, FILTER, + "Set outer IPv4 fragment ID hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_ID_IPV4_6, 0, + 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, + "Set inner IPv4 fragment ID hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, + DYN_TUN_ID_IPV4_6, + 0, 16, toeplitz); + } + } + } + + /* check if L4 protocol type shall be part of hash */ + if (l4_proto_mask) + l4_proto_hash = true; + + unset_bits_and_log(&fields, NT_ETH_RSS_IP_MASK); + } + + /* L4 */ + if (fields & (RTE_ETH_RSS_PORT | RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY)) { + if (outer) { + if (fields & RTE_ETH_RSS_L4_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set outer L4 src hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 0, 16, toeplitz); + + } else if (fields & RTE_ETH_RSS_L4_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set outer L4 dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 2, 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set outer L4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 0, 32, toeplitz); + } + + } else if (fields & RTE_ETH_RSS_L4_SRC_ONLY) { + NT_LOG(DBG, FILTER, "Set inner L4 src hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L4, 0, + 16, toeplitz); + + } else if (fields & RTE_ETH_RSS_L4_DST_ONLY) { + NT_LOG(DBG, FILTER, "Set inner L4 dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L4, 2, + 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner L4 src & dst hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_TUN_L4, 0, + 32, toeplitz); + } + + l4_proto_hash = true; + unset_bits_and_log(&fields, + RTE_ETH_RSS_PORT | RTE_ETH_RSS_L4_SRC_ONLY | + RTE_ETH_RSS_L4_DST_ONLY); + } + + /* IPv4 protocol / IPv6 next header fields */ + if (l4_proto_hash) { + /* NOTE: HW_HSH_RCP_P_MASK is not supported for Toeplitz and thus one of SW0, SW4 + * or W8 must be used to hash on `protocol` field of IPv4 or `next header` field of + * IPv6 header. + */ + if (outer) { + NT_LOG(DBG, FILTER, "Set outer L4 protocol type / next header hasher."); + + if (toeplitz) { + if (ipv6) { + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_L3, 6, 8, + toeplitz); + + } else { + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_L3, 9, 8, + toeplitz); + } + + } else { + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_P_MASK, hsh_idx, 0, + 1); + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_TNL_P, hsh_idx, 0, + 0); + } + + } else { + NT_LOG(DBG, FILTER, "Set inner L4 protocol type / next header hasher."); + + if (toeplitz) { + if (ipv6) { + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_TUN_L3, + 6, 8, toeplitz); + + } else { + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, + words, DYN_TUN_L3, + 9, 8, toeplitz); + } + + } else { + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_P_MASK, hsh_idx, 0, + 1); + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_TNL_P, hsh_idx, 0, + 1); + } + } + + l4_proto_hash = false; + } + + /* + * GTPU - for UPF use cases we always use TEID from outermost GTPU header + * even if other headers are innermost + */ + if (fields & RTE_ETH_RSS_GTPU) { + NT_LOG(DBG, FILTER, "Set outer GTPU TEID hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, DYN_L4_PAYLOAD, 4, 32, + toeplitz); + unset_bits_and_log(&fields, RTE_ETH_RSS_GTPU); + } + + /* Checksums */ + /* only UDP, TCP and SCTP checksums are supported */ + if (fields & RTE_ETH_RSS_L4_CHKSUM) { + switch (l4_proto_mask) { + case RTE_ETH_RSS_NONFRAG_IPV4_UDP: + case RTE_ETH_RSS_NONFRAG_IPV6_UDP: + case RTE_ETH_RSS_IPV6_UDP_EX: + case RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP: + case RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_IPV6_UDP_EX: + case RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_IPV6_UDP_EX: + case RTE_ETH_RSS_UDP_COMBINED: + if (outer) { + NT_LOG(DBG, FILTER, "Set outer UDP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 6, 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner UDP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L4, 6, 16, + toeplitz); + } + + unset_bits_and_log(&fields, RTE_ETH_RSS_L4_CHKSUM | l4_proto_mask); + break; + + case RTE_ETH_RSS_NONFRAG_IPV4_TCP: + case RTE_ETH_RSS_NONFRAG_IPV6_TCP: + case RTE_ETH_RSS_IPV6_TCP_EX: + case RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP: + case RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_IPV6_TCP_EX: + case RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_IPV6_TCP_EX: + case RTE_ETH_RSS_TCP_COMBINED: + if (outer) { + NT_LOG(DBG, FILTER, "Set outer TCP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 16, 16, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner TCP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L4, 16, 16, + toeplitz); + } + + unset_bits_and_log(&fields, RTE_ETH_RSS_L4_CHKSUM | l4_proto_mask); + break; + + case RTE_ETH_RSS_NONFRAG_IPV4_SCTP: + case RTE_ETH_RSS_NONFRAG_IPV6_SCTP: + case RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP: + if (outer) { + NT_LOG(DBG, FILTER, "Set outer SCTP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_L4, 8, 32, toeplitz); + + } else { + NT_LOG(DBG, FILTER, "Set inner SCTP checksum hasher."); + res |= flow_nic_set_hasher_part_inline(ndev, hsh_idx, words, + DYN_TUN_L4, 8, 32, + toeplitz); + } + + unset_bits_and_log(&fields, RTE_ETH_RSS_L4_CHKSUM | l4_proto_mask); + break; + + case RTE_ETH_RSS_NONFRAG_IPV4_OTHER: + case RTE_ETH_RSS_NONFRAG_IPV6_OTHER: + + /* none or unsupported protocol was chosen */ + case 0: + NT_LOG(ERR, FILTER, + "L4 checksum hashing is supported only for UDP, TCP and SCTP protocols"); + res = -1; + break; + + /* multiple L4 protocols were selected */ + default: + NT_LOG(ERR, FILTER, + "L4 checksum hashing can be enabled just for one of UDP, TCP or SCTP protocols"); + res = -1; + break; + } + } + + if (fields || res != 0) { + hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, hsh_idx, 0, 0); + + if (sprint_nt_rss_mask(rss_buffer, rss_buffer_len, " ", rss_conf.rss_hf) == 0) { + NT_LOG(ERR, FILTER, + "RSS configuration%s is not supported for hash func %s.", + rss_buffer, + (enum rte_eth_hash_function)toeplitz ? "Toeplitz" : "NTH10"); + + } else { + NT_LOG(ERR, FILTER, + "RSS configuration 0x%" PRIX64 + " is not supported for hash func %s.", + rss_conf.rss_hf, + (enum rte_eth_hash_function)toeplitz ? "Toeplitz" : "NTH10"); + } + + return -1; + } + + return res; +} + + static const struct profile_inline_ops ops = { /* * Management @@ -2993,6 +3840,7 @@ static const struct profile_inline_ops ops = { .flow_destroy_locked_profile_inline = flow_destroy_locked_profile_inline, .flow_create_profile_inline = flow_create_profile_inline, .flow_destroy_profile_inline = flow_destroy_profile_inline, + .flow_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, }; void profile_inline_init(void) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index b87f8542ac..e623bb2352 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -38,4 +38,8 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); +int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, + int hsh_idx, + struct nt_eth_rss_conf rss_conf); + #endif /* _FLOW_API_PROFILE_INLINE_H_ */ diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 149c549112..1069be2f85 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -252,6 +252,10 @@ struct profile_inline_ops { int (*flow_destroy_profile_inline)(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); + + int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, + int hsh_idx, + struct nt_eth_rss_conf rss_conf); }; void register_profile_inline_ops(const struct profile_inline_ops *ops); From patchwork Tue Oct 29 16:41:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147637 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DE3A745BC0; Tue, 29 Oct 2024 17:47:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E09BD42F7E; Tue, 29 Oct 2024 17:44:17 +0100 (CET) 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 C694442ECF for ; Tue, 29 Oct 2024 17:43:31 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) 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 16:43:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WVVBIwNG4/RF9Tg5bVOJHQNRtTOXfNW6HOjl/wbuFyKIezs/IIUdNsGWweSkF4dk2Ns6gd0n4L9R9DAqUTBUI4DavfGtHewMWe7nPGZ/rslPkuv1RksAuvgrAiTLgvO98YfISYqDF1h8rHn7R/n1GKm0vbJqbRuPVDelboOJpVHUJQ0YAdSG9XEminnKs8xe0n6x/SHX4/DwpiuRcsAgrzDVGHbCR9egqpLEuuU+6M+tykZW0YukcVRUuH8nouEktqPD1J6Cn3kjX75wqOQalsEPmzaHG6hWv+ch9tkt90RsDNd0GW+IkQnkRqOBTvaKRDYFz9p4rd6P2VqB3WasDg== 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=A61/ZYPptfE9JAZlbSSrD9UAYi0ChCaXzlV8bet8Qcg=; b=FtLPvtKPtntJFlfX1bEidegWX/3MT55NJAbh/gVbVZ2RpG9LbxSuLeZozzhrgkiJcbDNBAWa0Y6x5OMjwuZy5J9zliDxicjwlp4EROGjmTSNZGOWpJdZ9H1aWTP8k2gU6TAYfFPn11jrk7YODmV7ZQ0qGr5da7DsgHVTaq0llL+WKtlugs6Oh5+qJVqEjFUTlzkISfzlVJZkMpM7FgfIGSpQ0AvRgtAw2GKboqxg/0j9T0R/OcK+ASS0u0VcjA517f9F5u5FhxngAu5xhyddZayq6I1qsRKRBGH7erQLEgz060alm10Xjhq1jr2cV4VrpAelBvUHaOPFexkt1GJ8Mw== 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=A61/ZYPptfE9JAZlbSSrD9UAYi0ChCaXzlV8bet8Qcg=; b=GiCrFHj5PuL5M8chG+gv3VOUnXoNGhraoL8Ex6Br7ZzEm+JbZauElGNbyfFKnH/hDv2YknDP9T/iwX/Ta/TRr9IX117jPe20mcTQ+eC/iPk0edW2DZJ1ld9/z3u51sZDYUwuevrvBrYOiEq8gMscejKt0UZ0oIQOindFs+O+4us= Received: from DUZPR01CA0201.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::12) by DB8P190MB0697.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:125::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:21 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::19) by DUZPR01CA0201.outlook.office365.com (2603:10a6:10:4b6::12) 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:43:21 +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:43:21 +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 32/86] net/ntnic: add TPE module Date: Tue, 29 Oct 2024 17:41:36 +0100 Message-ID: <20241029164243.1648775-33-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB8P190MB0697:EE_ X-MS-Office365-Filtering-Correlation-Id: 533d9d20-e9d2-4226-e66f-08dcf838ccc5 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: 9KguVJbUu6QUZOCFXf8WKNk/P5TzbrqJSP6O7ImbGyib/liAiJp67gPyrR9v2nqavYOAvlEsL+EyNgACJa4yLCKP/GpDFM46ETG4bQIDJdDzFbARhdhWKCpws0o9MnoJFj8N+mhQJK6bGtmCErPRBptPPU46lkIwVFmudFYSuKPVCk6WqND2ibdbMgM+dsRqtt55ykOUfReJWA/dLPPE1hLN3Rg8ymrdHuLRqmcun82mb1k73vZZH6dVyGj6yglx8nqoQ/cyfDxdxCrrR56X3o/mYdWfXFti16BlyUiRlU/J0cDaMZDQbF3XDG/OSO1t7QVc8atFoIvbCVP+cn6868LayYHQ2YoiFbH8uVIYX+ekb2WezFTR+E66wjO56uET7azoxZwyT0qRQVs/sDHOzEd0l0yJygPLPuR7AqPEAXmkghQTcER55Qguwtdyf1K/nPmU4AXkCwwfCuYy/biZbuxqx4GtnWjkWw8cCpyJ9lm1bzfLcChEIEsyrGP1rRUWrowRtPGbsySQD9hkH2fbsIl6r09029EqbcoytWzC9l6zSKFFE0ol752ptKwnpRw53dq6pda3DVheW04AatyTSQaX6LeVNW90ed7uOZoa1B4baE5OBoTAcNcPIwI6dJBcD08HwDvQj/EuqMONg4iVVEuwq3QjtezcKJrZSP9+4m9Z9iaSy9Ag2iKFlhR+opG1rj8thkCFk6JKwyikud3a0F06cyZClri6m0P240C5AjIhxLnBa1FVlkO1RszR2TKS40gjvLkQmgNdx2rKkFDp4GFAQY8JQ7uYx68lFN7IkH9jzpm2aO4Kpo9q/RP1aKoSZmJAL3gC2q1uDtddI5rIMRcVIltfyfZEHAruyNJ7WtEWk0VwrBoxKCxP5IZGIOM5Sw8RekgQdwPp7t5tsrCE1DltdzUvrzF0wonvyDZj4qDH0ozry8hSQP5kjfsdxXibGG6gdewYpur9zB39r0xXQ3KCQ6831TUD7wUqMMt2gSa24W+LI/QP+ZajSa1lx72KEhuqBEiJF/uvc5RDo4fKGQEED2m8pO8+mLgn5vnffx/qhBtMYfmYoCTTMkfv4jBQoqrCiHq10xqgmnrUvXFotQYZpXnDlmddjpbIVdhnoqxJ7rY/NaolI+zT81wHYW/qLwyoUtCNsGpzyl2wvytAyzGNVSpuNdWivwrVD8+Vv3mpz0J+A37muMftcCrl+o+OuEvbspV/zHrBHyl03W12dRD7UGH4IlbHvH57lNMpalH0yC6LqRb73P8p0r/MQRREeEyTc0o/9KaotKs/Ka4RR8eaRaUn4jkN8mggaqbU+TBMzTTDnJVzp9LjRcklHjVwRmWGEtTRZxAjq5zMLUqCCTi1y7l6VMD8M8JGk+4WuDopht+7zBmHzX9mECfmtmfqa1W7Ln0tmWMZedSNgXwmSA== 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: bzU3pJaS2VeA3/4y5eLNGOiPay3uVffNjKg5hxPiBV321fbFMhHnn8Qrwe45zQHgFcfXAhkCX9SPIdVcAg6l0Z6aG2VALaBRDkI6dAqCtNNEGZSqA9D8ChL3fMGBgPwP13t8krhmhSRX6u+68utuhzfNB64I24b4K9fQYb/IKLAm3MbMjfnKQU4xwzuh60wBc2Pzjy0gaZcY3zhqpycF4TwtIQOyyDAgDwW31KedxFkRxAsxNCL7I65RCHgF8fX3rVckbtuBsY0NJY1fu9hkmLTot6E+NfcAbIoZ3cn+DnkifaR/KnwGRnwtD4e52M316Qo/RY4kqEUscvzdRc277CLlw6rdNpeYhsruLWFULhElCQStKYfz8VYdsKa8Pq4jmwUgN7RvU9UBeFdrSqTQNbrfiv3E37dJd8gJzG3SCcQSDmg3PqURoD86BykXrwJbo9yM2gqALRu+c6nha8iMVsRMbUK1v8U4I0IlU/PNAXqhA0u4Qq3m7aEuhJ47ah9JUihKn4hf3J5TkJ53DOXrCcj7TF4pviAC8Z4JdxeCZhM3YAFm0mPg4+6vowX66PGDpPoPw+X2ISYWhMYHcIojPSzaDI+3Wz+7reKSa0GFDLI4PD8XTKqXWSW46WQrKAHZggBOXxUIirWMazg9GLE+oOVr7p0l3E4FXjZxFSDv/YI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:21.4177 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 533d9d20-e9d2-4226-e66f-08dcf838ccc5 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: DB8P190MB0697 X-BESS-ID: 1730220207-304438-12706-30037-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViamJkYWQGYGUNQoMcXMzNzEND nJxMjc0MjC0szUwMTY3CTJyMTAINnSWKk2FgBVRsKmQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan22-120.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 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_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 From: Danylo Vodopianov The TX Packet Editor is a software abstraction module, that keeps track of the handful of FPGA modules that are used to edit packets in the TX pipeline. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 16 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c | 757 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 373 +++++++++ .../profile_inline/flow_api_hw_db_inline.h | 70 ++ .../profile_inline/flow_api_profile_inline.c | 127 ++- 5 files changed, 1342 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index cee148807a..e16dcd478f 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -889,24 +889,40 @@ void hw_mod_tpe_free(struct flow_api_backend_s *be); int hw_mod_tpe_reset(struct flow_api_backend_s *be); int hw_mod_tpe_rpp_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_rpp_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_rpp_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_tpe_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_tpe_ins_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_ins_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_rpl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_rpl_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_rpl_ext_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_rpl_ext_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_rpl_rpl_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_rpl_rpl_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t *value); int hw_mod_tpe_cpy_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_cpy_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_hfu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_hfu_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_csu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_csu_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); enum debug_mode_e { FLOW_BACKEND_DEBUG_MODE_NONE = 0x0000, diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c index 0d73b795d5..ba8f2d0dbb 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c @@ -169,6 +169,82 @@ int hw_mod_tpe_rpp_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_rpp_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_rpp_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.rpp_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v1_rpp_v0_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.rpp_rcp, struct tpe_v1_rpp_v0_rcp_s, index, + *value, be->tpe.nb_rcp_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.rpp_rcp, struct tpe_v1_rpp_v0_rcp_s, index, + *value); + break; + + case HW_TPE_RPP_RCP_EXP: + GET_SET(be->tpe.v3.rpp_rcp[index].exp, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_rpp_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_rpp_rcp_mod(be, field, index, &value, 0); +} + /* * IFR_RCP */ @@ -203,6 +279,90 @@ int hw_mod_tpe_ins_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_ins_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_ins_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.ins_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v1_ins_v1_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.ins_rcp, struct tpe_v1_ins_v1_rcp_s, index, + *value, be->tpe.nb_rcp_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.ins_rcp, struct tpe_v1_ins_v1_rcp_s, index, + *value); + break; + + case HW_TPE_INS_RCP_DYN: + GET_SET(be->tpe.v3.ins_rcp[index].dyn, value); + break; + + case HW_TPE_INS_RCP_OFS: + GET_SET(be->tpe.v3.ins_rcp[index].ofs, value); + break; + + case HW_TPE_INS_RCP_LEN: + GET_SET(be->tpe.v3.ins_rcp[index].len, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_ins_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_ins_rcp_mod(be, field, index, &value, 0); +} + /* * RPL_RCP */ @@ -220,6 +380,102 @@ int hw_mod_tpe_rpl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_rpl_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_rpl_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.rpl_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v3_rpl_v4_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.rpl_rcp, struct tpe_v3_rpl_v4_rcp_s, index, + *value, be->tpe.nb_rcp_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.rpl_rcp, struct tpe_v3_rpl_v4_rcp_s, index, + *value); + break; + + case HW_TPE_RPL_RCP_DYN: + GET_SET(be->tpe.v3.rpl_rcp[index].dyn, value); + break; + + case HW_TPE_RPL_RCP_OFS: + GET_SET(be->tpe.v3.rpl_rcp[index].ofs, value); + break; + + case HW_TPE_RPL_RCP_LEN: + GET_SET(be->tpe.v3.rpl_rcp[index].len, value); + break; + + case HW_TPE_RPL_RCP_RPL_PTR: + GET_SET(be->tpe.v3.rpl_rcp[index].rpl_ptr, value); + break; + + case HW_TPE_RPL_RCP_EXT_PRIO: + GET_SET(be->tpe.v3.rpl_rcp[index].ext_prio, value); + break; + + case HW_TPE_RPL_RCP_ETH_TYPE_WR: + GET_SET(be->tpe.v3.rpl_rcp[index].eth_type_wr, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_rpl_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_rpl_rcp_mod(be, field, index, &value, 0); +} + /* * RPL_EXT */ @@ -237,6 +493,86 @@ int hw_mod_tpe_rpl_ext_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_rpl_ext_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_rpl_ext_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rpl_ext_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.rpl_ext[index], (uint8_t)*value, + sizeof(struct tpe_v1_rpl_v2_ext_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rpl_ext_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.rpl_ext, struct tpe_v1_rpl_v2_ext_s, index, + *value, be->tpe.nb_rpl_ext_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rpl_ext_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.rpl_ext, struct tpe_v1_rpl_v2_ext_s, index, + *value); + break; + + case HW_TPE_RPL_EXT_RPL_PTR: + GET_SET(be->tpe.v3.rpl_ext[index].rpl_ptr, value); + break; + + case HW_TPE_RPL_EXT_META_RPL_LEN: + GET_SET(be->tpe.v3.rpl_ext[index].meta_rpl_len, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_rpl_ext_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_rpl_ext_mod(be, field, index, &value, 0); +} + /* * RPL_RPL */ @@ -254,6 +590,89 @@ int hw_mod_tpe_rpl_rpl_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_rpl_rpl_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_rpl_rpl_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rpl_depth) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.rpl_rpl[index], (uint8_t)*value, + sizeof(struct tpe_v1_rpl_v2_rpl_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rpl_depth) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.rpl_rpl, struct tpe_v1_rpl_v2_rpl_s, index, + *value, be->tpe.nb_rpl_depth); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rpl_depth) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.rpl_rpl, struct tpe_v1_rpl_v2_rpl_s, index, + *value); + break; + + case HW_TPE_RPL_RPL_VALUE: + if (get) + memcpy(value, be->tpe.v3.rpl_rpl[index].value, + sizeof(uint32_t) * 4); + + else + memcpy(be->tpe.v3.rpl_rpl[index].value, value, + sizeof(uint32_t) * 4); + + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_rpl_rpl_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t *value) +{ + return hw_mod_tpe_rpl_rpl_mod(be, field, index, value, 0); +} + /* * CPY_RCP */ @@ -273,6 +692,96 @@ int hw_mod_tpe_cpy_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_cpy_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_cpy_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + const uint32_t cpy_size = be->tpe.nb_cpy_writers * be->tpe.nb_rcp_categories; + + if (index >= cpy_size) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.cpy_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v1_cpy_v1_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= cpy_size) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.cpy_rcp, struct tpe_v1_cpy_v1_rcp_s, index, + *value, cpy_size); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= cpy_size) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.cpy_rcp, struct tpe_v1_cpy_v1_rcp_s, index, + *value); + break; + + case HW_TPE_CPY_RCP_READER_SELECT: + GET_SET(be->tpe.v3.cpy_rcp[index].reader_select, value); + break; + + case HW_TPE_CPY_RCP_DYN: + GET_SET(be->tpe.v3.cpy_rcp[index].dyn, value); + break; + + case HW_TPE_CPY_RCP_OFS: + GET_SET(be->tpe.v3.cpy_rcp[index].ofs, value); + break; + + case HW_TPE_CPY_RCP_LEN: + GET_SET(be->tpe.v3.cpy_rcp[index].len, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_cpy_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_cpy_rcp_mod(be, field, index, &value, 0); +} + /* * HFU_RCP */ @@ -290,6 +799,166 @@ int hw_mod_tpe_hfu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_hfu_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_hfu_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.hfu_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v1_hfu_v1_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.hfu_rcp, struct tpe_v1_hfu_v1_rcp_s, index, + *value, be->tpe.nb_rcp_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.hfu_rcp, struct tpe_v1_hfu_v1_rcp_s, index, + *value); + break; + + case HW_TPE_HFU_RCP_LEN_A_WR: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_wr, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_OUTER_L4_LEN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_outer_l4_len, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_POS_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_pos_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_POS_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_pos_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_ADD_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_add_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_ADD_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_add_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_A_SUB_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_a_sub_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_WR: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_wr, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_POS_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_pos_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_POS_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_pos_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_ADD_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_add_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_ADD_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_add_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_B_SUB_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_b_sub_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_WR: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_wr, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_POS_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_pos_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_POS_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_pos_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_ADD_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_add_dyn, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_ADD_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_add_ofs, value); + break; + + case HW_TPE_HFU_RCP_LEN_C_SUB_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].len_c_sub_dyn, value); + break; + + case HW_TPE_HFU_RCP_TTL_WR: + GET_SET(be->tpe.v3.hfu_rcp[index].ttl_wr, value); + break; + + case HW_TPE_HFU_RCP_TTL_POS_DYN: + GET_SET(be->tpe.v3.hfu_rcp[index].ttl_pos_dyn, value); + break; + + case HW_TPE_HFU_RCP_TTL_POS_OFS: + GET_SET(be->tpe.v3.hfu_rcp[index].ttl_pos_ofs, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_hfu_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_hfu_rcp_mod(be, field, index, &value, 0); +} + /* * CSU_RCP */ @@ -306,3 +975,91 @@ int hw_mod_tpe_csu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_csu_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } + +static int hw_mod_tpe_csu_rcp_mod(struct flow_api_backend_s *be, enum hw_tpe_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->tpe.v3.csu_rcp[index], (uint8_t)*value, + sizeof(struct tpe_v1_csu_v0_rcp_s)); + break; + + case HW_TPE_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->tpe.v3.csu_rcp, struct tpe_v1_csu_v0_rcp_s, index, + *value, be->tpe.nb_rcp_categories); + break; + + case HW_TPE_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->tpe.v3.csu_rcp, struct tpe_v1_csu_v0_rcp_s, index, + *value); + break; + + case HW_TPE_CSU_RCP_OUTER_L3_CMD: + GET_SET(be->tpe.v3.csu_rcp[index].ol3_cmd, value); + break; + + case HW_TPE_CSU_RCP_OUTER_L4_CMD: + GET_SET(be->tpe.v3.csu_rcp[index].ol4_cmd, value); + break; + + case HW_TPE_CSU_RCP_INNER_L3_CMD: + GET_SET(be->tpe.v3.csu_rcp[index].il3_cmd, value); + break; + + case HW_TPE_CSU_RCP_INNER_L4_CMD: + GET_SET(be->tpe.v3.csu_rcp[index].il4_cmd, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_csu_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_csu_rcp_mod(be, field, index, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 068c890b45..dec96fce85 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -30,6 +30,17 @@ struct hw_db_inline_resource_db { int ref; } *slc_lr; + struct hw_db_inline_resource_db_tpe { + struct hw_db_inline_tpe_data data; + int ref; + } *tpe; + + struct hw_db_inline_resource_db_tpe_ext { + struct hw_db_inline_tpe_ext_data data; + int replace_ram_idx; + int ref; + } *tpe_ext; + struct hw_db_inline_resource_db_hsh { struct hw_db_inline_hsh_data data; int ref; @@ -38,6 +49,8 @@ struct hw_db_inline_resource_db { uint32_t nb_cot; uint32_t nb_qsl; uint32_t nb_slc_lr; + uint32_t nb_tpe; + uint32_t nb_tpe_ext; uint32_t nb_hsh; /* Items */ @@ -101,6 +114,22 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_tpe = ndev->be.tpe.nb_rcp_categories; + db->tpe = calloc(db->nb_tpe, sizeof(struct hw_db_inline_resource_db_tpe)); + + if (db->tpe == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->nb_tpe_ext = ndev->be.tpe.nb_rpl_ext_categories; + db->tpe_ext = calloc(db->nb_tpe_ext, sizeof(struct hw_db_inline_resource_db_tpe_ext)); + + if (db->tpe_ext == NULL) { + hw_db_inline_destroy(db); + return -1; + } + db->nb_cat = ndev->be.cat.nb_cat_funcs; db->cat = calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_cat)); @@ -154,6 +183,8 @@ void hw_db_inline_destroy(void *db_handle) free(db->cot); free(db->qsl); free(db->slc_lr); + free(db->tpe); + free(db->tpe_ext); free(db->hsh); free(db->cat); @@ -195,6 +226,15 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_slc_lr_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_TPE: + hw_db_inline_tpe_deref(ndev, db_handle, *(struct hw_db_tpe_idx *)&idxs[i]); + break; + + case HW_DB_IDX_TYPE_TPE_EXT: + hw_db_inline_tpe_ext_deref(ndev, db_handle, + *(struct hw_db_tpe_ext_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_KM_RCP: hw_db_inline_km_deref(ndev, db_handle, *(struct hw_db_km_idx *)&idxs[i]); break; @@ -240,6 +280,12 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_SLC_LR: return &db->slc_lr[idxs[i].ids].data; + case HW_DB_IDX_TYPE_TPE: + return &db->tpe[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_TPE_EXT: + return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_KM_RCP: return &db->km[idxs[i].id1].data; @@ -652,6 +698,333 @@ void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, } } +/******************************************************************************/ +/* TPE */ +/******************************************************************************/ + +static int hw_db_inline_tpe_compare(const struct hw_db_inline_tpe_data *data1, + const struct hw_db_inline_tpe_data *data2) +{ + for (int i = 0; i < 6; ++i) + if (data1->writer[i].en != data2->writer[i].en || + data1->writer[i].reader_select != data2->writer[i].reader_select || + data1->writer[i].dyn != data2->writer[i].dyn || + data1->writer[i].ofs != data2->writer[i].ofs || + data1->writer[i].len != data2->writer[i].len) + return 0; + + return data1->insert_len == data2->insert_len && data1->new_outer == data2->new_outer && + data1->calc_eth_type_from_inner_ip == data2->calc_eth_type_from_inner_ip && + data1->ttl_en == data2->ttl_en && data1->ttl_dyn == data2->ttl_dyn && + data1->ttl_ofs == data2->ttl_ofs && data1->len_a_en == data2->len_a_en && + data1->len_a_pos_dyn == data2->len_a_pos_dyn && + data1->len_a_pos_ofs == data2->len_a_pos_ofs && + data1->len_a_add_dyn == data2->len_a_add_dyn && + data1->len_a_add_ofs == data2->len_a_add_ofs && + data1->len_a_sub_dyn == data2->len_a_sub_dyn && + data1->len_b_en == data2->len_b_en && + data1->len_b_pos_dyn == data2->len_b_pos_dyn && + data1->len_b_pos_ofs == data2->len_b_pos_ofs && + data1->len_b_add_dyn == data2->len_b_add_dyn && + data1->len_b_add_ofs == data2->len_b_add_ofs && + data1->len_b_sub_dyn == data2->len_b_sub_dyn && + data1->len_c_en == data2->len_c_en && + data1->len_c_pos_dyn == data2->len_c_pos_dyn && + data1->len_c_pos_ofs == data2->len_c_pos_ofs && + data1->len_c_add_dyn == data2->len_c_add_dyn && + data1->len_c_add_ofs == data2->len_c_add_ofs && + data1->len_c_sub_dyn == data2->len_c_sub_dyn; +} + +struct hw_db_tpe_idx hw_db_inline_tpe_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_tpe_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_tpe_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_TPE; + + for (uint32_t i = 1; i < db->nb_tpe; ++i) { + int ref = db->tpe[i].ref; + + if (ref > 0 && hw_db_inline_tpe_compare(data, &db->tpe[i].data)) { + idx.ids = i; + hw_db_inline_tpe_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->tpe[idx.ids].ref = 1; + memcpy(&db->tpe[idx.ids].data, data, sizeof(struct hw_db_inline_tpe_data)); + + if (data->insert_len > 0) { + hw_mod_tpe_rpp_rcp_set(&ndev->be, HW_TPE_RPP_RCP_EXP, idx.ids, data->insert_len); + hw_mod_tpe_rpp_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_ins_rcp_set(&ndev->be, HW_TPE_INS_RCP_DYN, idx.ids, 1); + hw_mod_tpe_ins_rcp_set(&ndev->be, HW_TPE_INS_RCP_OFS, idx.ids, 0); + hw_mod_tpe_ins_rcp_set(&ndev->be, HW_TPE_INS_RCP_LEN, idx.ids, data->insert_len); + hw_mod_tpe_ins_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_DYN, idx.ids, 1); + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_OFS, idx.ids, 0); + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_LEN, idx.ids, data->insert_len); + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_RPL_PTR, idx.ids, 0); + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_EXT_PRIO, idx.ids, 1); + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_RPL_RCP_ETH_TYPE_WR, idx.ids, + data->calc_eth_type_from_inner_ip); + hw_mod_tpe_rpl_rcp_flush(&ndev->be, idx.ids, 1); + } + + for (uint32_t i = 0; i < 6; ++i) { + if (data->writer[i].en) { + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_READER_SELECT, + idx.ids + db->nb_tpe * i, + data->writer[i].reader_select); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_DYN, + idx.ids + db->nb_tpe * i, data->writer[i].dyn); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_OFS, + idx.ids + db->nb_tpe * i, data->writer[i].ofs); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_LEN, + idx.ids + db->nb_tpe * i, data->writer[i].len); + + } else { + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_READER_SELECT, + idx.ids + db->nb_tpe * i, 0); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_DYN, + idx.ids + db->nb_tpe * i, 0); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_OFS, + idx.ids + db->nb_tpe * i, 0); + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_CPY_RCP_LEN, + idx.ids + db->nb_tpe * i, 0); + } + + hw_mod_tpe_cpy_rcp_flush(&ndev->be, idx.ids + db->nb_tpe * i, 1); + } + + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_WR, idx.ids, data->len_a_en); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_OUTER_L4_LEN, idx.ids, + data->new_outer); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_POS_DYN, idx.ids, + data->len_a_pos_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_POS_OFS, idx.ids, + data->len_a_pos_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_ADD_DYN, idx.ids, + data->len_a_add_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_ADD_OFS, idx.ids, + data->len_a_add_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_A_SUB_DYN, idx.ids, + data->len_a_sub_dyn); + + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_WR, idx.ids, data->len_b_en); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_POS_DYN, idx.ids, + data->len_b_pos_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_POS_OFS, idx.ids, + data->len_b_pos_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_ADD_DYN, idx.ids, + data->len_b_add_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_ADD_OFS, idx.ids, + data->len_b_add_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_B_SUB_DYN, idx.ids, + data->len_b_sub_dyn); + + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_WR, idx.ids, data->len_c_en); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_POS_DYN, idx.ids, + data->len_c_pos_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_POS_OFS, idx.ids, + data->len_c_pos_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_ADD_DYN, idx.ids, + data->len_c_add_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_ADD_OFS, idx.ids, + data->len_c_add_ofs); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_LEN_C_SUB_DYN, idx.ids, + data->len_c_sub_dyn); + + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_TTL_WR, idx.ids, data->ttl_en); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_TTL_POS_DYN, idx.ids, data->ttl_dyn); + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_HFU_RCP_TTL_POS_OFS, idx.ids, data->ttl_ofs); + hw_mod_tpe_hfu_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_csu_rcp_set(&ndev->be, HW_TPE_CSU_RCP_OUTER_L3_CMD, idx.ids, 3); + hw_mod_tpe_csu_rcp_set(&ndev->be, HW_TPE_CSU_RCP_OUTER_L4_CMD, idx.ids, 3); + hw_mod_tpe_csu_rcp_set(&ndev->be, HW_TPE_CSU_RCP_INNER_L3_CMD, idx.ids, 3); + hw_mod_tpe_csu_rcp_set(&ndev->be, HW_TPE_CSU_RCP_INNER_L4_CMD, idx.ids, 3); + hw_mod_tpe_csu_rcp_flush(&ndev->be, idx.ids, 1); + + return idx; +} + +void hw_db_inline_tpe_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_tpe_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->tpe[idx.ids].ref += 1; +} + +void hw_db_inline_tpe_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_tpe_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->tpe[idx.ids].ref -= 1; + + if (db->tpe[idx.ids].ref <= 0) { + for (uint32_t i = 0; i < 6; ++i) { + hw_mod_tpe_cpy_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, + idx.ids + db->nb_tpe * i, 0); + hw_mod_tpe_cpy_rcp_flush(&ndev->be, idx.ids + db->nb_tpe * i, 1); + } + + hw_mod_tpe_rpp_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_rpp_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_ins_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_ins_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_rpl_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_rpl_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_hfu_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_hfu_rcp_flush(&ndev->be, idx.ids, 1); + + hw_mod_tpe_csu_rcp_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_csu_rcp_flush(&ndev->be, idx.ids, 1); + + memset(&db->tpe[idx.ids].data, 0x0, sizeof(struct hw_db_inline_tpe_data)); + db->tpe[idx.ids].ref = 0; + } +} + +/******************************************************************************/ +/* TPE_EXT */ +/******************************************************************************/ + +static int hw_db_inline_tpe_ext_compare(const struct hw_db_inline_tpe_ext_data *data1, + const struct hw_db_inline_tpe_ext_data *data2) +{ + return data1->size == data2->size && + memcmp(data1->hdr8, data2->hdr8, HW_DB_INLINE_MAX_ENCAP_SIZE) == 0; +} + +struct hw_db_tpe_ext_idx hw_db_inline_tpe_ext_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_tpe_ext_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_tpe_ext_idx idx = { .raw = 0 }; + int rpl_rpl_length = ((int)data->size + 15) / 16; + int found = 0, rpl_rpl_index = 0; + + idx.type = HW_DB_IDX_TYPE_TPE_EXT; + + if (data->size > HW_DB_INLINE_MAX_ENCAP_SIZE) { + idx.error = 1; + return idx; + } + + for (uint32_t i = 1; i < db->nb_tpe_ext; ++i) { + int ref = db->tpe_ext[i].ref; + + if (ref > 0 && hw_db_inline_tpe_ext_compare(data, &db->tpe_ext[i].data)) { + idx.ids = i; + hw_db_inline_tpe_ext_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + rpl_rpl_index = flow_nic_alloc_resource_config(ndev, RES_TPE_RPL, rpl_rpl_length, 1); + + if (rpl_rpl_index < 0) { + idx.error = 1; + return idx; + } + + db->tpe_ext[idx.ids].ref = 1; + db->tpe_ext[idx.ids].replace_ram_idx = rpl_rpl_index; + memcpy(&db->tpe_ext[idx.ids].data, data, sizeof(struct hw_db_inline_tpe_ext_data)); + + hw_mod_tpe_rpl_ext_set(&ndev->be, HW_TPE_RPL_EXT_RPL_PTR, idx.ids, rpl_rpl_index); + hw_mod_tpe_rpl_ext_set(&ndev->be, HW_TPE_RPL_EXT_META_RPL_LEN, idx.ids, data->size); + hw_mod_tpe_rpl_ext_flush(&ndev->be, idx.ids, 1); + + for (int i = 0; i < rpl_rpl_length; ++i) { + uint32_t rpl_data[4]; + memcpy(rpl_data, data->hdr32 + i * 4, sizeof(rpl_data)); + hw_mod_tpe_rpl_rpl_set(&ndev->be, HW_TPE_RPL_RPL_VALUE, rpl_rpl_index + i, + rpl_data); + } + + hw_mod_tpe_rpl_rpl_flush(&ndev->be, rpl_rpl_index, rpl_rpl_length); + + return idx; +} + +void hw_db_inline_tpe_ext_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_tpe_ext_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->tpe_ext[idx.ids].ref += 1; +} + +void hw_db_inline_tpe_ext_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_tpe_ext_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->tpe_ext[idx.ids].ref -= 1; + + if (db->tpe_ext[idx.ids].ref <= 0) { + const int rpl_rpl_length = ((int)db->tpe_ext[idx.ids].data.size + 15) / 16; + const int rpl_rpl_index = db->tpe_ext[idx.ids].replace_ram_idx; + + hw_mod_tpe_rpl_ext_set(&ndev->be, HW_TPE_PRESET_ALL, idx.ids, 0); + hw_mod_tpe_rpl_ext_flush(&ndev->be, idx.ids, 1); + + for (int i = 0; i < rpl_rpl_length; ++i) { + uint32_t rpl_zero[] = { 0, 0, 0, 0 }; + hw_mod_tpe_rpl_rpl_set(&ndev->be, HW_TPE_RPL_RPL_VALUE, rpl_rpl_index + i, + rpl_zero); + flow_nic_free_resource(ndev, RES_TPE_RPL, rpl_rpl_index + i); + } + + hw_mod_tpe_rpl_rpl_flush(&ndev->be, rpl_rpl_index, rpl_rpl_length); + + memset(&db->tpe_ext[idx.ids].data, 0x0, sizeof(struct hw_db_inline_tpe_ext_data)); + db->tpe_ext[idx.ids].ref = 0; + } +} + + /******************************************************************************/ /* CAT */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index c97bdef1b7..18d959307e 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -52,6 +52,60 @@ struct hw_db_slc_lr_idx { HW_DB_IDX; }; +struct hw_db_inline_tpe_data { + uint32_t insert_len : 16; + uint32_t new_outer : 1; + uint32_t calc_eth_type_from_inner_ip : 1; + uint32_t ttl_en : 1; + uint32_t ttl_dyn : 5; + uint32_t ttl_ofs : 8; + + struct { + uint32_t en : 1; + uint32_t reader_select : 3; + uint32_t dyn : 5; + uint32_t ofs : 14; + uint32_t len : 5; + uint32_t padding : 4; + } writer[6]; + + uint32_t len_a_en : 1; + uint32_t len_a_pos_dyn : 5; + uint32_t len_a_pos_ofs : 8; + uint32_t len_a_add_dyn : 5; + uint32_t len_a_add_ofs : 8; + uint32_t len_a_sub_dyn : 5; + + uint32_t len_b_en : 1; + uint32_t len_b_pos_dyn : 5; + uint32_t len_b_pos_ofs : 8; + uint32_t len_b_add_dyn : 5; + uint32_t len_b_add_ofs : 8; + uint32_t len_b_sub_dyn : 5; + + uint32_t len_c_en : 1; + uint32_t len_c_pos_dyn : 5; + uint32_t len_c_pos_ofs : 8; + uint32_t len_c_add_dyn : 5; + uint32_t len_c_add_ofs : 8; + uint32_t len_c_sub_dyn : 5; +}; + +struct hw_db_inline_tpe_ext_data { + uint32_t size; + union { + uint8_t hdr8[HW_DB_INLINE_MAX_ENCAP_SIZE]; + uint32_t hdr32[(HW_DB_INLINE_MAX_ENCAP_SIZE + 3) / 4]; + }; +}; + +struct hw_db_tpe_idx { + HW_DB_IDX; +}; +struct hw_db_tpe_ext_idx { + HW_DB_IDX; +}; + struct hw_db_km_idx { HW_DB_IDX; }; @@ -70,6 +124,9 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_CAT, HW_DB_IDX_TYPE_QSL, HW_DB_IDX_TYPE_SLC_LR, + HW_DB_IDX_TYPE_TPE, + HW_DB_IDX_TYPE_TPE_EXT, + HW_DB_IDX_TYPE_KM_RCP, HW_DB_IDX_TYPE_KM_FT, HW_DB_IDX_TYPE_HSH, @@ -138,6 +195,7 @@ struct hw_db_inline_action_set_data { struct { struct hw_db_cot_idx cot; struct hw_db_qsl_idx qsl; + struct hw_db_tpe_idx tpe; struct hw_db_hsh_idx hsh; }; }; @@ -181,6 +239,18 @@ void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_slc_lr_idx idx); +struct hw_db_tpe_idx hw_db_inline_tpe_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_tpe_data *data); +void hw_db_inline_tpe_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_tpe_idx idx); +void hw_db_inline_tpe_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_tpe_idx idx); + +struct hw_db_tpe_ext_idx hw_db_inline_tpe_ext_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_tpe_ext_data *data); +void hw_db_inline_tpe_ext_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_tpe_ext_idx idx); +void hw_db_inline_tpe_ext_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_tpe_ext_idx idx); + struct hw_db_hsh_idx hw_db_inline_hsh_add(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_hsh_data *data); void hw_db_inline_hsh_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_hsh_idx idx); 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 f6482941d6..85a8a4fc0e 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 @@ -18,6 +18,8 @@ #include "ntnic_mod_reg.h" #include +#define NT_FLM_MISS_FLOW_TYPE 0 +#define NT_FLM_UNHANDLED_FLOW_TYPE 1 #define NT_FLM_OP_UNLEARN 0 #define NT_FLM_OP_LEARN 1 @@ -2419,6 +2421,92 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, } } + /* Setup TPE EXT */ + if (fd->tun_hdr.len > 0) { + assert(fd->tun_hdr.len <= HW_DB_INLINE_MAX_ENCAP_SIZE); + + struct hw_db_inline_tpe_ext_data tpe_ext_data = { + .size = fd->tun_hdr.len, + }; + + memset(tpe_ext_data.hdr8, 0x0, HW_DB_INLINE_MAX_ENCAP_SIZE); + memcpy(tpe_ext_data.hdr8, fd->tun_hdr.d.hdr8, (fd->tun_hdr.len + 15) & ~15); + + struct hw_db_tpe_ext_idx tpe_ext_idx = + hw_db_inline_tpe_ext_add(dev->ndev, dev->ndev->hw_db_handle, + &tpe_ext_data); + local_idxs[(*local_idx_counter)++] = tpe_ext_idx.raw; + + if (tpe_ext_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference TPE EXT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + + if (flm_rpl_ext_ptr) + *flm_rpl_ext_ptr = tpe_ext_idx.ids; + } + + /* Setup TPE */ + assert(fd->modify_field_count <= 6); + + struct hw_db_inline_tpe_data tpe_data = { + .insert_len = fd->tun_hdr.len, + .new_outer = fd->tun_hdr.new_outer, + .calc_eth_type_from_inner_ip = + !fd->tun_hdr.new_outer && fd->header_strip_end_dyn == DYN_TUN_L3, + .ttl_en = fd->ttl_sub_enable, + .ttl_dyn = fd->ttl_sub_outer ? DYN_L3 : DYN_TUN_L3, + .ttl_ofs = fd->ttl_sub_ipv4 ? 8 : 7, + }; + + for (unsigned int i = 0; i < fd->modify_field_count; ++i) { + tpe_data.writer[i].en = 1; + tpe_data.writer[i].reader_select = fd->modify_field[i].select; + tpe_data.writer[i].dyn = fd->modify_field[i].dyn; + tpe_data.writer[i].ofs = fd->modify_field[i].ofs; + tpe_data.writer[i].len = fd->modify_field[i].len; + } + + if (fd->tun_hdr.new_outer) { + const int fcs_length = 4; + + /* L4 length */ + tpe_data.len_a_en = 1; + tpe_data.len_a_pos_dyn = DYN_L4; + tpe_data.len_a_pos_ofs = 4; + tpe_data.len_a_add_dyn = 18; + tpe_data.len_a_add_ofs = (uint32_t)(-fcs_length) & 0xff; + tpe_data.len_a_sub_dyn = DYN_L4; + + /* L3 length */ + tpe_data.len_b_en = 1; + tpe_data.len_b_pos_dyn = DYN_L3; + tpe_data.len_b_pos_ofs = fd->tun_hdr.ip_version == 4 ? 2 : 4; + tpe_data.len_b_add_dyn = 18; + tpe_data.len_b_add_ofs = (uint32_t)(-fcs_length) & 0xff; + tpe_data.len_b_sub_dyn = DYN_L3; + + /* GTP length */ + tpe_data.len_c_en = 1; + tpe_data.len_c_pos_dyn = DYN_L4_PAYLOAD; + tpe_data.len_c_pos_ofs = 2; + tpe_data.len_c_add_dyn = 18; + tpe_data.len_c_add_ofs = (uint32_t)(-8 - fcs_length) & 0xff; + tpe_data.len_c_sub_dyn = DYN_L4_PAYLOAD; + } + + struct hw_db_tpe_idx tpe_idx = + hw_db_inline_tpe_add(dev->ndev, dev->ndev->hw_db_handle, &tpe_data); + + local_idxs[(*local_idx_counter)++] = tpe_idx.raw; + + if (tpe_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference TPE resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + return 0; } @@ -2539,6 +2627,30 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); goto error_out; } + + /* Setup TPE */ + if (fd->ttl_sub_enable) { + struct hw_db_inline_tpe_data tpe_data = { + .insert_len = fd->tun_hdr.len, + .new_outer = fd->tun_hdr.new_outer, + .calc_eth_type_from_inner_ip = !fd->tun_hdr.new_outer && + fd->header_strip_end_dyn == DYN_TUN_L3, + .ttl_en = fd->ttl_sub_enable, + .ttl_dyn = fd->ttl_sub_outer ? DYN_L3 : DYN_TUN_L3, + .ttl_ofs = fd->ttl_sub_ipv4 ? 8 : 7, + }; + struct hw_db_tpe_idx tpe_idx = + hw_db_inline_tpe_add(dev->ndev, dev->ndev->hw_db_handle, + &tpe_data); + fh->db_idxs[fh->db_idx_counter++] = tpe_idx.raw; + action_set_data.tpe = tpe_idx; + + if (tpe_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference TPE resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + } } /* Setup CAT */ @@ -2847,6 +2959,16 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) if (!ndev->flow_mgnt_prepared) { /* Check static arrays are big enough */ assert(ndev->be.tpe.nb_cpy_writers <= MAX_CPY_WRITERS_SUPPORTED); + /* KM Flow Type 0 is reserved */ + flow_nic_mark_resource_used(ndev, RES_KM_FLOW_TYPE, 0); + flow_nic_mark_resource_used(ndev, RES_KM_CATEGORY, 0); + + /* Reserved FLM Flow Types */ + flow_nic_mark_resource_used(ndev, RES_FLM_FLOW_TYPE, NT_FLM_MISS_FLOW_TYPE); + flow_nic_mark_resource_used(ndev, RES_FLM_FLOW_TYPE, NT_FLM_UNHANDLED_FLOW_TYPE); + flow_nic_mark_resource_used(ndev, RES_FLM_FLOW_TYPE, + NT_FLM_VIOLATING_MBR_FLOW_TYPE); + flow_nic_mark_resource_used(ndev, RES_FLM_RCP, 0); /* COT is locked to CFN. Don't set color for CFN 0 */ hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, 0, 0); @@ -2872,8 +2994,11 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_mark_resource_used(ndev, RES_QSL_QST, 0); - /* SLC LR index 0 is reserved */ + /* SLC LR & TPE index 0 were reserved */ flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); + flow_nic_mark_resource_used(ndev, RES_TPE_RCP, 0); + flow_nic_mark_resource_used(ndev, RES_TPE_EXT, 0); + flow_nic_mark_resource_used(ndev, RES_TPE_RPL, 0); /* PDB setup Direct Virtio Scatter-Gather descriptor of 12 bytes for its recipe 0 */ From patchwork Tue Oct 29 16:41:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147640 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 90D6645BC0; Tue, 29 Oct 2024 17:48:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 434AD42FDB; Tue, 29 Oct 2024 17:44:23 +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 D36BD42EF6 for ; Tue, 29 Oct 2024 17:43:33 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) 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:43:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HR1yIeHa9rLZ/IQxa0+69dCYivuRIcyFzRmVMpdnAowbMVI3TF7mNghd1Hur+GwLvENI1d0ASdI1J6/5xyXDSmvay9TxKRXsQbKTS19wjbL8a/G6ZHWOPkxmRWhOCDcxh85WcYEQyjs3mjbnOqkB0rqCcQZPArMN5jal9H4RIOsUMJaSQaRMOFizGyycA+/H0sUUwFtA+UoZPfMb32v/9D/1SR2pdpYvKwHGAojky1LIm9AZG1r8kZ7Bph6YGK7qwdY7X1y4RcxgTgoBDXrueGCcbCgjz4P3oubvBYABwSoZ51pBj3J3nfEhToA0oXG7qs5tEPMnevqsDvQBxSlI6w== 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=J89GzO0VZM3vULGYGgdyTy4/5OH0NCSYzYupSlCK83E=; b=M4e9DoiX4rTdWsKVyvw5sXddkHrB1/ewtpkY9DJR8ihDDMGZ0QGJ9qquuatiU+1HjlrMEshgZVAX+jdvqk4O6JNewQkrjtpN0yqdWgUQJVwVBZDoqCx17li+6ze5KzoyAqHpbRwL7kBGHrBpMgVC+c9Ab5Db5g7kALinE8+MhcImPkvhiT+NT6hyNlOzvp1SpTtW/H6aDgWyyqtFYdlJYTnZeT8HyoMHyITRMuy1gv3+v4aEz5HwQ8698yAjmkWYacU+E32yWBfA6cgyF9EpjjHZl8r/1tNxPp0Y05a/Iswn8t2OhtNYdUOZYB94oxZmrhFjyqeqVCfjhTsM+XBHMQ== 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=J89GzO0VZM3vULGYGgdyTy4/5OH0NCSYzYupSlCK83E=; b=QI9/Scy+fYN6F4Np2kdh8mWzi74L03DPrjP1xNgCkHp2I+1t3PLALuD6LzPAAbb6UN+zKH7xUR1VXa72Crwh1HF258vRqQu1pUkJ3H2hKwXSE1D/DFix+AgSpyk4Z1WtIGpvMYTfwBbCJgPEGNS/XFxPx76t2dAdO+WiY1I11uc= Received: from DUZPR01CA0197.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::11) by AM7P190MB0647.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:115::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:26 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::23) by DUZPR01CA0197.outlook.office365.com (2603:10a6:10:4b6::11) 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:43:25 +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:43:25 +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 33/86] net/ntnic: add FLM module Date: Tue, 29 Oct 2024 17:41:37 +0100 Message-ID: <20241029164243.1648775-34-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM7P190MB0647:EE_ X-MS-Office365-Filtering-Correlation-Id: eb91f233-c8b0-4446-41ac-08dcf838cf09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: WbeI4emPBS8Nr+xHQGWG22Jaj7ZxFW17rVc6lXmxELO+6glnM4PGpQXINlNHmbzhToBZJiPTzfAcKL/v+OQZoDN/h0M23JirD+sC7YOnqMYdne8fNdOb1dcxvP6EqTW7QHXBwJ9DSHC0X8yUclA3ydZ2Kvx1LyAx9/ZFca6EdaiacJxVD7VHGR2rFa72et1jhwy3htfZ/9ouUFzYXhh6PjxbMs/YJc7GC7p6IS4cTzaFzHgQarQSgjRFEIcVQVPRfRNaHoQgIuEQkXZpZRBia1p98HXa7EcCrGTJzNiY0e0KOFXgJnJSQCdLj3oKW2hZkeMMgvLG7aKB5TkU+aMIIBaoca1JsDzrQPQoAxw7MbrcHRLsl3LpSVTd7+6QPph9elt5BPAn5xy+REA66s+saeHA820L3vXllKk9d3YDbAmFQXOBIg2ELOFaBbdHjTTd5a3osIQXxCT9QCSA8tsT9CbzzV+r0EQzAT4OIAdm28DIlpTVc0qhxrsxQHO29buAZz3DxitqgwEkLp5/KuC5NIoQ5Jv4rRSdJyfLmOW2ral0G+zRVfpbhL/Sb/yu6+z2LSkbhVBEylhGGR7mfMVLiL4iW7ECelliqpROigiBfCJMGIQVtDAvnW3WZtg766lATKW3pbMWBGMj0Fa0OOibOr0cC1f1eN2XZ14axuAa1iNoYA7eljGAS/befVXYe3m42RZ2ZNk0ROox1gTwKl99qKnVvltQ5c/6/GwoQkr8hE3HZcf9Z6bNZOtS5E1S3BBDoVFqVGO/cu3MhU/bgisYt7VFt6F0LIKI/C3nxPHbfS6oSawJuSUAFUw3EhCZOrIqwCS1byyypQyqFj2Gg9LwnBsjjDipC4dOb5Pil9z1Sw0p4ae7mfJe41AMEKheifAPHRxXCIjwEHxy6p4lfHvjIotepRu5rZxUZgRq+8L6+sAW3j4nznOu2+cac6vbMTfP5b0lO/q7mkYePAoEm3CtmeGeCxS9lm/mnvP74lFFoyGLORItgXLbOJ8kPN+xMMpaMw+TciMXJaqlkXw9PwC2pF4Z5KDZB05TSmROGCTQhY4kSDJBj+QxvLg1e92IgXaVszwBrRFkDOrlFwpXwCiPqv9v5B8wiVaObJ2rnpKLXUKheozFYAt9uzMtEkKo11Vgnm+60EDO6hB9A/8F/vyIloKK2Z4f1GkSHq8m6VMtU9iqFmm9KS8oBL+UrllqIdUGog+B7SajeXU+pwXB8Ql28ZyvNmBT3i0/UxPv/Ia3jzFFsnwZ/mCjsOD/0QT57hZ2rnFhZaI1Nrs/w+w17Sgj533m1xhgIdsM4T4zPhl2K2mzMaEFH0pgR+rqhyBs6jaoXORdLAq1Qe1MTEew1agRvxMj18EVW8x9R2cJlPVD/kK+deTS4tRtuY3uAw8D1arZiqBOAQaXcmuZbQo5fJq8IA== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TKsC2nFn2g8sjp3ikfplyE4usnrs03yEkAju8nk2Jrfs03MHW6plJGy1YaNiTiQ+5ZPV1bXDZt743d5haLjuvb6GnE6RvHcAGIWkH00BKBXqwUVt6ICfnxrg8yOsdPwRvz8wzmBYfPMVrskyoUuSgjps1isitLqv3tCj86FpbkiCXOGULaeaxHVO7veVIXfEBB0DGDI2IBQvetLtrg/uxAKK0bO9arpZIfD5o8BJThdXrGebcQRoio160a5PrLcGgb0TuPBNXQZPUbcNB3KGATJ1vfMdL9+BUXQtU6SgFSVp03MXooqegXHOCzdVKh7PoIvY73ZYAeQ/RDfWOve3DN/1pKaWRPSohtz+CaFrkoKAG2QQo3+Nh5BfLmGd+n/zkqUvpXfZm7yTXcBlxiOavmnXqxEdGyn3WUgy342aFjeag5de420gA4DbJ8jTe+pNZaX+YsW4IdNa6NfDjy4wQFSr6cK9N+ON/FtQykdizw2hUZpd/bGlp2FvbTfXskOD0ckhK/36/IjHtOlbrqUJYiFJB9SWVBQcPOlFSDio1hS65jyRgtrVLRhLZ+1m4DHh5gX3nYcWKzR9pfESypIX4dRaQe1KukqWq5KldxY/+8KwLDGNrPNkT05+j0nv1dui5i91OKXIAZXbPRh0X49KCWHm6JRUpAf2o7lqGc9jHLU= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:25.2146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb91f233-c8b0-4446-41ac-08dcf838cf09 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: AM7P190MB0647 X-BESS-ID: 1730220209-303097-12765-29347-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYGlgaGQGYGUNQo2cTAOC3F0M zY3NjMMtUgzSDV2NLSIMncxNzS0swsRak2FgBQiS0QQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan20-62.eu-central-1b.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 The Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 42 +++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c | 190 +++++++++++++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 257 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 234 ++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 33 +++ .../profile_inline/flow_api_profile_inline.c | 224 ++++++++++++++- .../flow_api_profile_inline_config.h | 58 ++++ drivers/net/ntnic/ntutil/nt_util.h | 8 + 8 files changed, 1042 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index e16dcd478f..de662c4ed1 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -367,6 +367,18 @@ int hw_mod_cat_cfn_flush(struct flow_api_backend_s *be, int start_idx, int count int hw_mod_cat_cfn_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, int word_off, uint32_t value); /* KCE/KCS/FTE KM */ +int hw_mod_cat_kce_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kce_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kce_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +int hw_mod_cat_kcs_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kcs_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kcs_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, int start_idx, int count); int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, @@ -374,6 +386,18 @@ int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, enum km_flm_if_select_e if_num, int index, uint32_t *value); /* KCE/KCS/FTE FLM */ +int hw_mod_cat_kce_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kce_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kce_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +int hw_mod_cat_kcs_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kcs_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kcs_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, int start_idx, int count); int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, @@ -384,10 +408,14 @@ int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, uint32_t value); +int hw_mod_cat_cte_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value); int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, uint32_t value); +int hw_mod_cat_cts_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value); int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, @@ -638,7 +666,21 @@ int hw_mod_flm_reset(struct flow_api_backend_s *be); int hw_mod_flm_control_flush(struct flow_api_backend_s *be); int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); +int hw_mod_flm_status_update(struct flow_api_backend_s *be); +int hw_mod_flm_status_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value); + int hw_mod_flm_scan_flush(struct flow_api_backend_s *be); +int hw_mod_flm_scan_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_load_bin_flush(struct flow_api_backend_s *be); +int hw_mod_flm_load_bin_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_prio_flush(struct flow_api_backend_s *be); +int hw_mod_flm_prio_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_pst_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value); int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c index 9164ec1ae0..985c821312 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c @@ -902,6 +902,95 @@ static int hw_mod_cat_kce_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_kce_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_kce_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kce_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_kce_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kce_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_kce_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= (be->cat.nb_cat_funcs / 8)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_KCE_ENABLE_BM: + GET_SET(be->cat.v18.kce[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_KCE_ENABLE_BM: + GET_SET(be->cat.v21.kce[index].enable_bm[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_kce_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_kce_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_kce_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_kce_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 1, index, value, 1); +} + /* * KCS */ @@ -925,6 +1014,95 @@ static int hw_mod_cat_kcs_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_kcs_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_kcs_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kcs_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_kcs_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kcs_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_kcs_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->cat.nb_cat_funcs) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_KCS_CATEGORY: + GET_SET(be->cat.v18.kcs[index].category, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_KCS_CATEGORY: + GET_SET(be->cat.v21.kcs[index].category[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_kcs_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_kcs_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_kcs_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_kcs_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 1, index, value, 1); +} + /* * FTE */ @@ -1094,6 +1272,12 @@ int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int i return hw_mod_cat_cte_mod(be, field, index, &value, 0); } +int hw_mod_cat_cte_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value) +{ + return hw_mod_cat_cte_mod(be, field, index, value, 1); +} + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count) { int addr_size = (_VER_ < 15) ? 8 : ((be->cat.cts_num + 1) / 2); @@ -1154,6 +1338,12 @@ int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int i return hw_mod_cat_cts_mod(be, field, index, &value, 0); } +int hw_mod_cat_cts_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value) +{ + return hw_mod_cat_cts_mod(be, field, index, value, 1); +} + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index 8c1f3f2d96..f5eaea7c4e 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -293,11 +293,268 @@ int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, u return hw_mod_flm_control_mod(be, field, &value, 0); } +int hw_mod_flm_status_update(struct flow_api_backend_s *be) +{ + return be->iface->flm_status_update(be->be_dev, &be->flm); +} + +static int hw_mod_flm_status_mod(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_STATUS_CALIB_SUCCESS: + GET_SET(be->flm.v25.status->calib_success, value); + break; + + case HW_FLM_STATUS_CALIB_FAIL: + GET_SET(be->flm.v25.status->calib_fail, value); + break; + + case HW_FLM_STATUS_INITDONE: + GET_SET(be->flm.v25.status->initdone, value); + break; + + case HW_FLM_STATUS_IDLE: + GET_SET(be->flm.v25.status->idle, value); + break; + + case HW_FLM_STATUS_CRITICAL: + GET_SET(be->flm.v25.status->critical, value); + break; + + case HW_FLM_STATUS_PANIC: + GET_SET(be->flm.v25.status->panic, value); + break; + + case HW_FLM_STATUS_CRCERR: + GET_SET(be->flm.v25.status->crcerr, value); + break; + + case HW_FLM_STATUS_EFT_BP: + GET_SET(be->flm.v25.status->eft_bp, value); + break; + + case HW_FLM_STATUS_CACHE_BUFFER_CRITICAL: + GET_SET(be->flm.v25.status->cache_buf_critical, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_status_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value) +{ + return hw_mod_flm_status_mod(be, field, value, 1); +} + int hw_mod_flm_scan_flush(struct flow_api_backend_s *be) { return be->iface->flm_scan_flush(be->be_dev, &be->flm); } +static int hw_mod_flm_scan_mod(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value, + int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_SCAN_I: + GET_SET(be->flm.v25.scan->i, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_scan_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_scan_mod(be, field, &value, 0); +} + +int hw_mod_flm_load_bin_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_load_bin_flush(be->be_dev, &be->flm); +} + +static int hw_mod_flm_load_bin_mod(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_LOAD_BIN: + GET_SET(be->flm.v25.load_bin->bin, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_load_bin_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_load_bin_mod(be, field, &value, 0); +} + +int hw_mod_flm_prio_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_prio_flush(be->be_dev, &be->flm); +} + +static int hw_mod_flm_prio_mod(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value, + int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_PRIO_LIMIT0: + GET_SET(be->flm.v25.prio->limit0, value); + break; + + case HW_FLM_PRIO_FT0: + GET_SET(be->flm.v25.prio->ft0, value); + break; + + case HW_FLM_PRIO_LIMIT1: + GET_SET(be->flm.v25.prio->limit1, value); + break; + + case HW_FLM_PRIO_FT1: + GET_SET(be->flm.v25.prio->ft1, value); + break; + + case HW_FLM_PRIO_LIMIT2: + GET_SET(be->flm.v25.prio->limit2, value); + break; + + case HW_FLM_PRIO_FT2: + GET_SET(be->flm.v25.prio->ft2, value); + break; + + case HW_FLM_PRIO_LIMIT3: + GET_SET(be->flm.v25.prio->limit3, value); + break; + + case HW_FLM_PRIO_FT3: + GET_SET(be->flm.v25.prio->ft3, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_prio_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_prio_mod(be, field, &value, 0); +} + +int hw_mod_flm_pst_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->flm.nb_pst_profiles; + + if ((unsigned int)(start_idx + count) > be->flm.nb_pst_profiles) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->flm_pst_flush(be->be_dev, &be->flm, start_idx, count); +} + +static int hw_mod_flm_pst_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_PST_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->flm.v25.pst[index], (uint8_t)*value, + sizeof(struct flm_v25_pst_s)); + break; + + case HW_FLM_PST_BP: + GET_SET(be->flm.v25.pst[index].bp, value); + break; + + case HW_FLM_PST_PP: + GET_SET(be->flm.v25.pst[index].pp, value); + break; + + case HW_FLM_PST_TP: + GET_SET(be->flm.v25.pst[index].tp, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value) +{ + return hw_mod_flm_pst_mod(be, field, index, &value, 0); +} + int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index dec96fce85..61492090ce 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -9,6 +9,14 @@ #include "flow_api_hw_db_inline.h" #include "rte_common.h" +#define HW_DB_FT_LOOKUP_KEY_A 0 + +#define HW_DB_FT_TYPE_KM 1 +#define HW_DB_FT_LOOKUP_KEY_A 0 +#define HW_DB_FT_LOOKUP_KEY_C 2 + +#define HW_DB_FT_TYPE_FLM 0 +#define HW_DB_FT_TYPE_KM 1 /******************************************************************************/ /* Handle */ /******************************************************************************/ @@ -59,6 +67,23 @@ struct hw_db_inline_resource_db { int ref; } *cat; + struct hw_db_inline_resource_db_flm_rcp { + struct hw_db_inline_resource_db_flm_ft { + struct hw_db_inline_flm_ft_data data; + struct hw_db_flm_ft idx; + int ref; + } *ft; + + struct hw_db_inline_resource_db_flm_match_set { + struct hw_db_match_set_idx idx; + int ref; + } *match_set; + + struct hw_db_inline_resource_db_flm_cfn_map { + int cfn_idx; + } *cfn_map; + } *flm; + struct hw_db_inline_resource_db_km_rcp { struct hw_db_inline_km_rcp_data data; int ref; @@ -70,6 +95,7 @@ struct hw_db_inline_resource_db { } *km; uint32_t nb_cat; + uint32_t nb_flm_ft; uint32_t nb_km_ft; uint32_t nb_km_rcp; @@ -173,6 +199,13 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) } *db_handle = db; + + /* Preset data */ + + db->flm[0].ft[1].idx.type = HW_DB_IDX_TYPE_FLM_FT; + db->flm[0].ft[1].idx.id1 = 1; + db->flm[0].ft[1].ref = 1; + return 0; } @@ -235,6 +268,11 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_tpe_ext_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_FLM_FT: + hw_db_inline_flm_ft_deref(ndev, db_handle, + *(struct hw_db_flm_ft *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_KM_RCP: hw_db_inline_km_deref(ndev, db_handle, *(struct hw_db_km_idx *)&idxs[i]); break; @@ -286,6 +324,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_TPE_EXT: return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_FLM_FT: + return NULL; /* FTs can't be easily looked up */ + case HW_DB_IDX_TYPE_KM_RCP: return &db->km[idxs[i].id1].data; @@ -307,6 +348,61 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, /* Filter */ /******************************************************************************/ +/* + * lookup refers to key A/B/C/D, and can have values 0, 1, 2, and 3. + */ +static void hw_db_set_ft(struct flow_nic_dev *ndev, int type, int cfn_index, int lookup, + int flow_type, int enable) +{ + (void)type; + (void)enable; + + const int max_lookups = 4; + const int cat_funcs = (int)ndev->be.cat.nb_cat_funcs / 8; + + int fte_index = (8 * flow_type + cfn_index / cat_funcs) * max_lookups + lookup; + int fte_field = cfn_index % cat_funcs; + + uint32_t current_bm = 0; + uint32_t fte_field_bm = 1 << fte_field; + + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, fte_index, + ¤t_bm); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, fte_index, + ¤t_bm); + break; + + default: + break; + } + + uint32_t final_bm = enable ? (fte_field_bm | current_bm) : (~fte_field_bm & current_bm); + + if (current_bm != final_bm) { + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index, final_bm); + hw_mod_cat_fte_flm_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index, 1); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index, final_bm); + hw_mod_cat_fte_km_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index, 1); + break; + + default: + break; + } + } +} + /* * Setup a filter to match: * All packets in CFN checks @@ -348,6 +444,17 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, if (hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1)) return -1; + /* KM: Match all FTs for look-up A */ + for (int i = 0; i < 16; ++i) + hw_db_set_ft(ndev, HW_DB_FT_TYPE_KM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, i, 1); + + /* FLM: Match all FTs for look-up A */ + for (int i = 0; i < 16; ++i) + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, i, 1); + + /* FLM: Match FT=ft_argument for look-up C */ + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_C, ft, 1); + /* Make all CFN checks TRUE */ if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0)) return -1; @@ -1252,6 +1359,133 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } +/******************************************************************************/ +/* FLM FT */ +/******************************************************************************/ + +static int hw_db_inline_flm_ft_compare(const struct hw_db_inline_flm_ft_data *data1, + const struct hw_db_inline_flm_ft_data *data2) +{ + return data1->is_group_zero == data2->is_group_zero && data1->jump == data2->jump && + data1->action_set.raw == data2->action_set.raw; +} + +struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[data->jump]; + struct hw_db_flm_ft idx = { .raw = 0 }; + + idx.type = HW_DB_IDX_TYPE_FLM_FT; + idx.id1 = 0; + idx.id2 = data->group & 0xff; + + if (data->is_group_zero) { + idx.error = 1; + return idx; + } + + if (flm_rcp->ft[idx.id1].ref > 0) { + if (!hw_db_inline_flm_ft_compare(data, &flm_rcp->ft[idx.id1].data)) { + idx.error = 1; + return idx; + } + + hw_db_inline_flm_ft_ref(ndev, db, idx); + return idx; + } + + memcpy(&flm_rcp->ft[idx.id1].data, data, sizeof(struct hw_db_inline_flm_ft_data)); + flm_rcp->ft[idx.id1].idx.raw = idx.raw; + flm_rcp->ft[idx.id1].ref = 1; + + return idx; +} + +struct hw_db_flm_ft hw_db_inline_flm_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[data->group]; + struct hw_db_flm_ft idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_FLM_FT; + idx.id1 = 0; + idx.id2 = data->group & 0xff; + + /* RCP 0 always uses FT 1; i.e. use unhandled FT for disabled RCP */ + if (data->group == 0) { + idx.id1 = 1; + return idx; + } + + if (data->is_group_zero) { + idx.id3 = 1; + return idx; + } + + /* FLM_FT records 0, 1 and last (15) are reserved */ + /* NOTE: RES_FLM_FLOW_TYPE resource is global and it cannot be used in _add() and _deref() + * to track usage of FLM_FT recipes which are group specific. + */ + for (uint32_t i = 2; i < db->nb_flm_ft; ++i) { + if (!found && flm_rcp->ft[i].ref <= 0 && + !flow_nic_is_resource_used(ndev, RES_FLM_FLOW_TYPE, i)) { + found = 1; + idx.id1 = i; + } + + if (flm_rcp->ft[i].ref > 0 && + hw_db_inline_flm_ft_compare(data, &flm_rcp->ft[i].data)) { + idx.id1 = i; + hw_db_inline_flm_ft_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&flm_rcp->ft[idx.id1].data, data, sizeof(struct hw_db_inline_flm_ft_data)); + flm_rcp->ft[idx.id1].idx.raw = idx.raw; + flm_rcp->ft[idx.id1].ref = 1; + + return idx; +} + +void hw_db_inline_flm_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error && idx.id3 == 0) + db->flm[idx.id2].ft[idx.id1].ref += 1; +} + +void hw_db_inline_flm_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx) +{ + (void)ndev; + (void)db_handle; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp; + + if (idx.error || idx.id2 == 0 || idx.id3 > 0) + return; + + flm_rcp = &db->flm[idx.id2]; + + flm_rcp->ft[idx.id1].ref -= 1; + + if (flm_rcp->ft[idx.id1].ref > 0) + return; + + flm_rcp->ft[idx.id1].ref = 0; + memset(&flm_rcp->ft[idx.id1], 0x0, sizeof(struct hw_db_inline_resource_db_flm_ft)); +} /******************************************************************************/ /* HSH */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 18d959307e..a520ae1769 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -32,6 +32,10 @@ struct hw_db_idx { HW_DB_IDX; }; +struct hw_db_match_set_idx { + HW_DB_IDX; +}; + struct hw_db_action_set_idx { HW_DB_IDX; }; @@ -106,6 +110,13 @@ struct hw_db_tpe_ext_idx { HW_DB_IDX; }; +struct hw_db_flm_idx { + HW_DB_IDX; +}; +struct hw_db_flm_ft { + HW_DB_IDX; +}; + struct hw_db_km_idx { HW_DB_IDX; }; @@ -128,6 +139,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_TPE_EXT, HW_DB_IDX_TYPE_KM_RCP, + HW_DB_IDX_TYPE_FLM_FT, HW_DB_IDX_TYPE_KM_FT, HW_DB_IDX_TYPE_HSH, }; @@ -211,6 +223,17 @@ struct hw_db_inline_km_ft_data { struct hw_db_action_set_idx action_set; }; +struct hw_db_inline_flm_ft_data { + /* Group zero flows should set jump. */ + /* Group nonzero flows should set group. */ + int is_group_zero; + union { + int jump; + int group; + }; + struct hw_db_action_set_idx action_set; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); @@ -277,6 +300,16 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct /**/ +void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); + +struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data); +struct hw_db_flm_ft hw_db_inline_flm_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data); +void hw_db_inline_flm_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx); +void hw_db_inline_flm_ft_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_flm_ft idx); + int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, uint32_t qsl_hw_id); 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 85a8a4fc0e..85adcbb2d9 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 @@ -11,6 +11,7 @@ #include "flow_api.h" #include "flow_api_engine.h" #include "flow_api_hw_db_inline.h" +#include "flow_api_profile_inline_config.h" #include "flow_id_table.h" #include "stream_binary_flow_api.h" @@ -47,6 +48,128 @@ static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) return -1; } +/* + * Flow Matcher functionality + */ + +static int flm_sdram_calibrate(struct flow_nic_dev *ndev) +{ + int success = 0; + uint32_t fail_value = 0; + uint32_t value = 0; + + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_PRESET_ALL, 0x0); + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_SPLIT_SDRAM_USAGE, 0x10); + hw_mod_flm_control_flush(&ndev->be); + + /* Wait for ddr4 calibration/init done */ + for (uint32_t i = 0; i < 1000000; ++i) { + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_CALIB_SUCCESS, &value); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_CALIB_FAIL, &fail_value); + + if (value & 0x80000000) { + success = 1; + break; + } + + if (fail_value != 0) + break; + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, "FLM initialization failed - SDRAM calibration failed"); + NT_LOG(ERR, FILTER, + "Calibration status: success 0x%08" PRIx32 " - fail 0x%08" PRIx32, + value, fail_value); + return -1; + } + + return 0; +} + +static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable) +{ + int success = 0; + + /* + * Make sure no lookup is performed during init, i.e. + * disable every category and disable FLM + */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0); + hw_mod_flm_control_flush(&ndev->be); + + /* Wait for FLM to enter Idle state */ + for (uint32_t i = 0; i < 1000000; ++i) { + uint32_t value = 0; + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_IDLE, &value); + + if (value) { + success = 1; + break; + } + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, "FLM initialization failed - Never idle"); + return -1; + } + + success = 0; + + /* Start SDRAM initialization */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_INIT, 0x1); + hw_mod_flm_control_flush(&ndev->be); + + for (uint32_t i = 0; i < 1000000; ++i) { + uint32_t value = 0; + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_INITDONE, &value); + + if (value) { + success = 1; + break; + } + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, + "FLM initialization failed - SDRAM initialization incomplete"); + return -1; + } + + /* Set the INIT value back to zero to clear the bit in the SW register cache */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_INIT, 0x0); + hw_mod_flm_control_flush(&ndev->be); + + /* Enable FLM */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, enable); + hw_mod_flm_control_flush(&ndev->be); + + int nb_rpp_per_ps = ndev->be.flm.nb_rpp_clock_in_ps; + int nb_load_aps_max = ndev->be.flm.nb_load_aps_max; + uint32_t scan_i_value = 0; + + if (NTNIC_SCANNER_LOAD > 0) { + scan_i_value = (1 / (nb_rpp_per_ps * 0.000000000001)) / + (nb_load_aps_max * NTNIC_SCANNER_LOAD); + } + + hw_mod_flm_scan_set(&ndev->be, HW_FLM_SCAN_I, scan_i_value); + hw_mod_flm_scan_flush(&ndev->be); + + return 0; +} + + + struct flm_flow_key_def_s { union { struct { @@ -2354,11 +2477,11 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, const struct nic_flow_def *fd, const struct hw_db_inline_qsl_data *qsl_data, const struct hw_db_inline_hsh_data *hsh_data, - uint32_t group __rte_unused, + uint32_t group, uint32_t local_idxs[], uint32_t *local_idx_counter, - uint16_t *flm_rpl_ext_ptr __rte_unused, - uint32_t *flm_ft __rte_unused, + uint16_t *flm_rpl_ext_ptr, + uint32_t *flm_ft, uint32_t *flm_scrub __rte_unused, struct rte_flow_error *error) { @@ -2507,6 +2630,25 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, return -1; } + /* Setup FLM FT */ + struct hw_db_inline_flm_ft_data flm_ft_data = { + .is_group_zero = 0, + .group = group, + }; + struct hw_db_flm_ft flm_ft_idx = empty_pattern + ? hw_db_inline_flm_ft_default(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data) + : hw_db_inline_flm_ft_add(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data); + local_idxs[(*local_idx_counter)++] = flm_ft_idx.raw; + + if (flm_ft_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM FT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + + if (flm_ft) + *flm_ft = flm_ft_idx.id1; + return 0; } @@ -2514,7 +2656,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n const struct rte_flow_attr *attr, uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, - uint32_t num_dest_port __rte_unused, uint32_t num_queues __rte_unused, + uint32_t num_dest_port, uint32_t num_queues, uint32_t *packet_data, uint32_t *packet_mask __rte_unused, struct flm_flow_key_def_s *key_def __rte_unused) { @@ -2808,6 +2950,21 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n km_write_data_match_entry(&fd->km, 0); } + /* Setup FLM FT */ + struct hw_db_inline_flm_ft_data flm_ft_data = { + .is_group_zero = 1, + .jump = fd->jump_to_group != UINT32_MAX ? fd->jump_to_group : 0, + }; + struct hw_db_flm_ft flm_ft_idx = + hw_db_inline_flm_ft_add(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data); + fh->db_idxs[fh->db_idx_counter++] = flm_ft_idx.raw; + + if (flm_ft_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM FT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + nic_insert_flow(dev->ndev, fh); } @@ -3028,6 +3185,63 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) NT_VIOLATING_MBR_QSL) < 0) goto err_exit0; + /* FLM */ + if (flm_sdram_calibrate(ndev) < 0) + goto err_exit0; + + if (flm_sdram_reset(ndev, 1) < 0) + goto err_exit0; + + /* Learn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LDS, 0); + /* Learn fail status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LFS, 1); + /* Learn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LIS, 1); + /* Unlearn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_UDS, 0); + /* Unlearn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_UIS, 0); + /* Relearn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RDS, 0); + /* Relearn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RIS, 0); + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RBL, 4); + hw_mod_flm_control_flush(&ndev->be); + + /* Set the sliding windows size for flm load */ + uint32_t bin = (uint32_t)(((FLM_LOAD_WINDOWS_SIZE * 1000000000000ULL) / + (32ULL * ndev->be.flm.nb_rpp_clock_in_ps)) - + 1ULL); + hw_mod_flm_load_bin_set(&ndev->be, HW_FLM_LOAD_BIN, bin); + hw_mod_flm_load_bin_flush(&ndev->be); + + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT0, + 0); /* Drop at 100% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT0, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT1, + 14); /* Drop at 87,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT1, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT2, + 10); /* Drop at 62,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT2, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT3, + 6); /* Drop at 37,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT3, 1); + hw_mod_flm_prio_flush(&ndev->be); + + /* TODO How to set and use these limits */ + for (uint32_t i = 0; i < ndev->be.flm.nb_pst_profiles; ++i) { + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_BP, i, + NTNIC_FLOW_PERIODIC_STATS_BYTE_LIMIT); + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_PP, i, + NTNIC_FLOW_PERIODIC_STATS_PKT_LIMIT); + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_TP, i, + NTNIC_FLOW_PERIODIC_STATS_BYTE_TIMEOUT); + } + + hw_mod_flm_pst_flush(&ndev->be, 0, ALL_ENTRIES); + ndev->id_table_handle = ntnic_id_table_create(); if (ndev->id_table_handle == NULL) @@ -3056,6 +3270,8 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) #endif if (ndev->flow_mgnt_prepared) { + flm_sdram_reset(ndev, 0); + flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h new file mode 100644 index 0000000000..8ba8b8f67a --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h @@ -0,0 +1,58 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_PROFILE_INLINE_CONFIG_H_ +#define _FLOW_API_PROFILE_INLINE_CONFIG_H_ + +/* + * Statistics are generated each time the byte counter crosses a limit. + * If BYTE_LIMIT is zero then the byte counter does not trigger statistics + * generation. + * + * Format: 2^(BYTE_LIMIT + 15) bytes + * Valid range: 0 to 31 + * + * Example: 2^(8 + 15) = 2^23 ~~ 8MB + */ +#define NTNIC_FLOW_PERIODIC_STATS_BYTE_LIMIT 8 + +/* + * Statistics are generated each time the packet counter crosses a limit. + * If PKT_LIMIT is zero then the packet counter does not trigger statistics + * generation. + * + * Format: 2^(PKT_LIMIT + 11) pkts + * Valid range: 0 to 31 + * + * Example: 2^(5 + 11) = 2^16 pkts ~~ 64K pkts + */ +#define NTNIC_FLOW_PERIODIC_STATS_PKT_LIMIT 5 + +/* + * Statistics are generated each time flow time (measured in ns) crosses a + * limit. + * If BYTE_TIMEOUT is zero then the flow time does not trigger statistics + * generation. + * + * Format: 2^(BYTE_TIMEOUT + 15) ns + * Valid range: 0 to 31 + * + * Example: 2^(23 + 15) = 2^38 ns ~~ 275 sec + */ +#define NTNIC_FLOW_PERIODIC_STATS_BYTE_TIMEOUT 23 + +/* + * This define sets the percentage of the full processing capacity + * being reserved for scan operations. The scanner is responsible + * for detecting aged out flows and meters with statistics timeout. + * + * A high scanner load percentage will make this detection more precise + * but will also give lower packet processing capacity. + * + * The percentage is given as a decimal number, e.g. 0.01 for 1%, which is the recommended value. + */ +#define NTNIC_SCANNER_LOAD 0.01 + +#endif /* _FLOW_API_PROFILE_INLINE_CONFIG_H_ */ diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h index 71ecd6c68c..a482fb43ad 100644 --- a/drivers/net/ntnic/ntutil/nt_util.h +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -16,6 +16,14 @@ #define ARRAY_SIZE(arr) RTE_DIM(arr) #endif +/* + * Windows size in seconds for measuring FLM load + * and Port load. + * The windows size must max be 3 min in order to + * prevent overflow. + */ +#define FLM_LOAD_WINDOWS_SIZE 2ULL + #define PCIIDENT_TO_DOMAIN(pci_ident) ((uint16_t)(((unsigned int)(pci_ident) >> 16) & 0xFFFFU)) #define PCIIDENT_TO_BUSNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 8) & 0xFFU)) #define PCIIDENT_TO_DEVNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 3) & 0x1FU)) From patchwork Tue Oct 29 16:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147639 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 87F8C45BC0; Tue, 29 Oct 2024 17:47:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5904442F95; Tue, 29 Oct 2024 17:44:20 +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 508D942ECF for ; Tue, 29 Oct 2024 17:43:32 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2109.outbound.protection.outlook.com [104.47.11.109]) 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 16:43:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T0XCRSWatsmNBJMHUvyzS2dknp67c2ybT1ZNptcr/Hie0oRXC1jAtOr/bc3NCpjUTSO9v3SHw6CCQIsJfuSupWhlMQogLBH5757FwLSzO/mv5HZyDPfFpUxMr13fACvT1GvhqDlHrAChzGYNbdG08SPKXgqOpb3vA2QAd8Ge21au5MeciXkevPKP5aQ6nuiuSxoMO3EOcYpA9Epn/OyNKXS1epCBBWdps/4I780znbRn140dneu07o/2A2DRp/ByRScJ4fpbJpPsDnEPctkLXEtvr/xWvegf2WAGpJhhyGByd4wvtjyoRsufw4JgaOMQVh8JaOnMhtW6Bi94ShrnmQ== 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=yc4GcvUnNlo/3FkHVCCKTfxipegYTuPVfB7PWxp6zKY=; b=qEc0lWy/Zb+4E57RJzsE9+Tzza3E7EWjjgp+az2PrLgTUy5udidcut2ezakGgs2G2xaB+inMIZ48UHMeJar8QHFTpiXpjhHpUDKa+GvkJJYV9ygxWnoPf3itGg0QbJdRpsEVnCEbhAk1LHwtw7hf66yr23XHu+d39V/1euwvtNqLSZ8ZttUvADkciA67awcnEnrURb+n3r/qdOtWuqCkBH+/ZyBZcLVXxDr4bmoG2Dh9B4sF1oyiN62TrF2WWrBY4bYqHp1oIyby77RGE4BNYPzebItIamEMByeu+Ei0ZmKGM99oWIosHu3QYEPOkXgKtlbz17LDmeDPCb6ttkBX4Q== 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=yc4GcvUnNlo/3FkHVCCKTfxipegYTuPVfB7PWxp6zKY=; b=JRH6loWtJegoai+2PQFEE4Cikxjf9he3lFXoYbEyh8RVC0UwfDF+Lmr7jOsVqtFc/Nd9BgUxRmrsrFq5cz/qdFOzpNNJY9mopT71hix4YN3L3xZAfz/GOoc2QiiVk7L0sn9ji1mPM/WRsio1m+XqHrs90hmaIR38W5nAr4JrvKI= Received: from DUZPR01CA0203.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::16) by AM9P190MB1188.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:261::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:26 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::5c) by DUZPR01CA0203.outlook.office365.com (2603:10a6:10:4b6::16) 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:43:26 +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:43:26 +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 34/86] net/ntnic: add flm rcp module Date: Tue, 29 Oct 2024 17:41:38 +0100 Message-ID: <20241029164243.1648775-35-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM9P190MB1188:EE_ X-MS-Office365-Filtering-Correlation-Id: 709a050b-e567-4230-6024-08dcf838cfca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 3Wcea3+jC02BlIsl5gTYhGuPKxxxF5TynLqSYlPTi/TS62Aimd3ePjjkWowJ/miwFVCoVPoM/H1kqgvJhSCSqN3NFJjhujM0bFzn/gEIa/oxHlbYMiESidJ+OP/5i7LKqkE9OYVFaDCQvvrJB7qeOCd47Ufl2goc6EbZgHQf1JcVjYIh7WcEHUvlP4T+W+8pU0uoRyi1QNYmS4kCqj0habr0NRbjpEBQ48HBbMNuBqQOyUjh9KoWXZe3QB/hyiz/7vuZ9K94CgM6UqfQZLwKpOLLNEEUu1AnNIvOdvbGctPm595a82awJDwj1a8KSkxETdU5UJVK/9ZduMOvTuHnZJPx0dNpmRbSDKIr4XH9XRyZU+gYIv+0MdqkMSMZ1pc8d6xsLmsaGxQS3nnG6MCcG7l6D9rk2krzrLoxqUNXn6OXdcfFBjHJF/cUrwsYHs3ZPIK9qdWZIsa8E+toxP9xyhRjOi8fhgDU6d2BuVVHXiaZA9xKFGvFHmL7cWu+eKAAqzACMGhsezEn7EPmKR0n+zDH1FMSoc5wOkumZgmaCKqYdAuPQMyKdiU4JlqU8x3Cbuv0xJmIIZj28X0qA9orRYJyXuUzYqFvZuxRxObw2pKzijEJ1al2K2fvkdR7n0JdJVgHF1YfB6QYYUthtBLBHyROjxWtpoJZdvQNfMD7UctIkXPFS2C1TE1UDdcAtSPClk3gdnRHAV64/L6uqBiYePi7IJ5rH+VHTb4ECse0koJikYMh3iZJ2UaU7Xq0Pf5kxBD/FPM7IA79AUPdKetr6+GfaWvwabyOaaP8kFCukOV4xkjubu7rtDlzbi0z/nwZP17iktTk6ZUKKIvmlfVDI3WSpB8N3WBsQpYSivrdRg8lPPjC6JvzLAFur+1BPHd5rCviYl9fVUHebkrCBfDoglXdd/1IiOJ4Kko0JTXysjt3wke58OFzYpfyGYevW+OLGzu4gP0cA9Ulhad5YjUnQBUfGB9HVPmNGu60mTV8se98feIdiER7fzxqJ19QoK1Wx7F6dT/9MeeCk0lyjs38ULg6b5HcujTKApf3Nit0wVmyuxtll9swVWh80GTvimWMGj6rH8L+stjwzNns4Fd/lHkMOKbHuuicPfpbi6KI3cVzAMVwJxr0Dnk69aB9Ay6emyagjs404FmXwJIMo35gTgp7SUkM/DIJ2uXZmoOG1beCzWJW/OduQf2klfIT7mMzgKxkpszXMoBPluUVPRKKF3s6xSj4dymXOJ3HBGGdbYWODT7A3MzjDyMBIBnUNL38Sa9dpAHfZB4rzjSsFrZumidCr0426NhTCZYe9h5mcRpGATjGWZsKPM48ukYkN4qDo5/VbbkFpERfrRvm5YTxrsMB67fjOnPE/pjtzGhmmTt3xoHxjzlpdnmEueiS0lWdupG40ZtRlfnOxqRHoyzMFw== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HdcW5Lhys8H/QYwMiGBaAp0MDi6a7Bj4iZqbr9jd7rx5jVH7LbU1mgv64Pp1KF97IrjE48eE3zeUYmXU6gaELx3d9KC41m9z8oQlN3yBI5/ecpADC3iV3KCNEukA+JzsE/wAqkHjKmzaQrbIQM+RC3vPT7Z3NefMlQ2SfTxSZAVFivp0uZWbefmHs4vMz9947sCRp8TDhgk9F9smjEhsTPOW97UXnwt6kGKSKRVd7fQn8SQ097MkjE6TfUKVaKn17BY74vKt7IYxOrvhOJdV2PcuXTrD8ATva3YmngtKCazc1WfQ/dfhK9vqCjMdfdm6OzRsRZImXLll2ZI6ua6zPCXFHgtANlVDq5hFEJP7gTm7a8IS64y6K/8iF8VzZ9gdqWjGgIKlxi8T4DPPtvH2d8/DpO/zTLTncQM2C380QY3wc+zhNUUq2xSJI44UVEbxULIm7AHtpmy33iU6ZUbhxtBh1/+ctIksTMcsPK4P1JXo7HT4cg6VchaiIaZLVI71vhtHjEmV1bURMAkH0z3SQluywd+rDcsi5zhogya5LZb/gkFkJVjYYiztnqYLynqm6tX98vMCR8c9tYEj3DFDZsQqtv+DWQCH8oyIRma2U+ry8By41Fv5Z1lqWUghlr3adg0QgZQV8lMZk2Py/qwQTUHKtzVWH1pU/vq8heWKuww= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:26.4802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 709a050b-e567-4230-6024-08dcf838cfca 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: AM9P190MB1188 X-BESS-ID: 1730220208-304438-12707-30038-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFiZmQGYGUNTMwDLFKNHUIt HY1DjJPNEw0QzISk5KMjI0tgQyLZVqYwFRG8SUQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-223.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 The Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 4 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 133 ++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 195 +++++++++++++++++- .../profile_inline/flow_api_hw_db_inline.h | 20 ++ .../profile_inline/flow_api_profile_inline.c | 42 +++- 5 files changed, 390 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index de662c4ed1..13722c30a9 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -683,6 +683,10 @@ int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i uint32_t value); int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value); +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value); int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index f5eaea7c4e..0a7e90c04f 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -579,3 +579,136 @@ int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int cou } return be->iface->flm_scrub_flush(be->be_dev, &be->flm, start_idx, count); } + +static int hw_mod_flm_rcp_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->flm.v25.rcp[index], (uint8_t)*value, + sizeof(struct flm_v25_rcp_s)); + break; + + case HW_FLM_RCP_LOOKUP: + GET_SET(be->flm.v25.rcp[index].lookup, value); + break; + + case HW_FLM_RCP_QW0_DYN: + GET_SET(be->flm.v25.rcp[index].qw0_dyn, value); + break; + + case HW_FLM_RCP_QW0_OFS: + GET_SET(be->flm.v25.rcp[index].qw0_ofs, value); + break; + + case HW_FLM_RCP_QW0_SEL: + GET_SET(be->flm.v25.rcp[index].qw0_sel, value); + break; + + case HW_FLM_RCP_QW4_DYN: + GET_SET(be->flm.v25.rcp[index].qw4_dyn, value); + break; + + case HW_FLM_RCP_QW4_OFS: + GET_SET(be->flm.v25.rcp[index].qw4_ofs, value); + break; + + case HW_FLM_RCP_SW8_DYN: + GET_SET(be->flm.v25.rcp[index].sw8_dyn, value); + break; + + case HW_FLM_RCP_SW8_OFS: + GET_SET(be->flm.v25.rcp[index].sw8_ofs, value); + break; + + case HW_FLM_RCP_SW8_SEL: + GET_SET(be->flm.v25.rcp[index].sw8_sel, value); + break; + + case HW_FLM_RCP_SW9_DYN: + GET_SET(be->flm.v25.rcp[index].sw9_dyn, value); + break; + + case HW_FLM_RCP_SW9_OFS: + GET_SET(be->flm.v25.rcp[index].sw9_ofs, value); + break; + + case HW_FLM_RCP_MASK: + if (get) { + memcpy(value, be->flm.v25.rcp[index].mask, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + + } else { + memcpy(be->flm.v25.rcp[index].mask, value, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + } + + break; + + case HW_FLM_RCP_KID: + GET_SET(be->flm.v25.rcp[index].kid, value); + break; + + case HW_FLM_RCP_OPN: + GET_SET(be->flm.v25.rcp[index].opn, value); + break; + + case HW_FLM_RCP_IPN: + GET_SET(be->flm.v25.rcp[index].ipn, value); + break; + + case HW_FLM_RCP_BYT_DYN: + GET_SET(be->flm.v25.rcp[index].byt_dyn, value); + break; + + case HW_FLM_RCP_BYT_OFS: + GET_SET(be->flm.v25.rcp[index].byt_ofs, value); + break; + + case HW_FLM_RCP_TXPLM: + GET_SET(be->flm.v25.rcp[index].txplm, value); + break; + + case HW_FLM_RCP_AUTO_IPV4_MASK: + GET_SET(be->flm.v25.rcp[index].auto_ipv4_mask, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value) +{ + if (field != HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_rcp_mod(be, field, index, value, 0); +} + +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value) +{ + if (field == HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_rcp_mod(be, field, index, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 61492090ce..0ae058b91e 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -68,6 +68,9 @@ struct hw_db_inline_resource_db { } *cat; struct hw_db_inline_resource_db_flm_rcp { + struct hw_db_inline_flm_rcp_data data; + int ref; + struct hw_db_inline_resource_db_flm_ft { struct hw_db_inline_flm_ft_data data; struct hw_db_flm_ft idx; @@ -96,6 +99,7 @@ struct hw_db_inline_resource_db { uint32_t nb_cat; uint32_t nb_flm_ft; + uint32_t nb_flm_rcp; uint32_t nb_km_ft; uint32_t nb_km_rcp; @@ -164,6 +168,42 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + + db->nb_flm_ft = ndev->be.cat.nb_flow_types; + db->nb_flm_rcp = ndev->be.flm.nb_categories; + db->flm = calloc(db->nb_flm_rcp, sizeof(struct hw_db_inline_resource_db_flm_rcp)); + + if (db->flm == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + db->flm[i].ft = + calloc(db->nb_flm_ft, sizeof(struct hw_db_inline_resource_db_flm_ft)); + + if (db->flm[i].ft == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].match_set = + calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_flm_match_set)); + + if (db->flm[i].match_set == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].cfn_map = calloc(db->nb_cat * db->nb_flm_ft, + sizeof(struct hw_db_inline_resource_db_flm_cfn_map)); + + if (db->flm[i].cfn_map == NULL) { + hw_db_inline_destroy(db); + return -1; + } + } + db->nb_km_ft = ndev->be.cat.nb_flow_types; db->nb_km_rcp = ndev->be.km.nb_categories; db->km = calloc(db->nb_km_rcp, sizeof(struct hw_db_inline_resource_db_km_rcp)); @@ -222,6 +262,16 @@ void hw_db_inline_destroy(void *db_handle) free(db->cat); + if (db->flm) { + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + free(db->flm[i].ft); + free(db->flm[i].match_set); + free(db->flm[i].cfn_map); + } + + free(db->flm); + } + if (db->km) { for (uint32_t i = 0; i < db->nb_km_rcp; ++i) free(db->km[i].ft); @@ -268,6 +318,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_tpe_ext_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_FLM_RCP: + hw_db_inline_flm_deref(ndev, db_handle, *(struct hw_db_flm_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_FLM_FT: hw_db_inline_flm_ft_deref(ndev, db_handle, *(struct hw_db_flm_ft *)&idxs[i]); @@ -324,6 +378,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_TPE_EXT: return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_FLM_RCP: + return &db->flm[idxs[i].id1].data; + case HW_DB_IDX_TYPE_FLM_FT: return NULL; /* FTs can't be easily looked up */ @@ -481,6 +538,20 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, return 0; } +static void hw_db_inline_setup_default_flm_rcp(struct flow_nic_dev *ndev, int flm_rcp) +{ + uint32_t flm_mask[10]; + memset(flm_mask, 0xff, sizeof(flm_mask)); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, flm_rcp, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, flm_rcp, 1); + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, flm_rcp, flm_mask); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, flm_rcp, flm_rcp + 2); + + hw_mod_flm_rcp_flush(&ndev->be, flm_rcp, 1); +} + + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -1268,10 +1339,17 @@ void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_d void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx) { (void)ndev; - (void)db_handle; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; if (idx.error) return; + + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, sizeof(struct hw_db_inline_km_rcp_data)); + db->flm[idx.id1].ref = 0; + } } /******************************************************************************/ @@ -1359,6 +1437,121 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } + +/******************************************************************************/ +/* FLM RCP */ +/******************************************************************************/ + +static int hw_db_inline_flm_compare(const struct hw_db_inline_flm_rcp_data *data1, + const struct hw_db_inline_flm_rcp_data *data2) +{ + if (data1->qw0_dyn != data2->qw0_dyn || data1->qw0_ofs != data2->qw0_ofs || + data1->qw4_dyn != data2->qw4_dyn || data1->qw4_ofs != data2->qw4_ofs || + data1->sw8_dyn != data2->sw8_dyn || data1->sw8_ofs != data2->sw8_ofs || + data1->sw9_dyn != data2->sw9_dyn || data1->sw9_ofs != data2->sw9_ofs || + data1->outer_prot != data2->outer_prot || data1->inner_prot != data2->inner_prot) { + return 0; + } + + for (int i = 0; i < 10; ++i) + if (data1->mask[i] != data2->mask[i]) + return 0; + + return 1; +} + +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_flm_idx idx = { .raw = 0 }; + + idx.type = HW_DB_IDX_TYPE_FLM_RCP; + idx.id1 = group; + + if (group == 0) + return idx; + + if (db->flm[idx.id1].ref > 0) { + if (!hw_db_inline_flm_compare(data, &db->flm[idx.id1].data)) { + idx.error = 1; + return idx; + } + + hw_db_inline_flm_ref(ndev, db, idx); + return idx; + } + + db->flm[idx.id1].ref = 1; + memcpy(&db->flm[idx.id1].data, data, sizeof(struct hw_db_inline_flm_rcp_data)); + + { + uint32_t flm_mask[10] = { + data->mask[0], /* SW9 */ + data->mask[1], /* SW8 */ + data->mask[5], data->mask[4], data->mask[3], data->mask[2], /* QW4 */ + data->mask[9], data->mask[8], data->mask[7], data->mask[6], /* QW0 */ + }; + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, idx.id1, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, idx.id1, 1); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_DYN, idx.id1, data->qw0_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_OFS, idx.id1, data->qw0_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_DYN, idx.id1, data->qw4_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_OFS, idx.id1, data->qw4_ofs); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_DYN, idx.id1, data->sw8_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_OFS, idx.id1, data->sw8_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_DYN, idx.id1, data->sw9_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_OFS, idx.id1, data->sw9_ofs); + + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, idx.id1, flm_mask); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, idx.id1, idx.id1 + 2); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_OPN, idx.id1, data->outer_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_IPN, idx.id1, data->inner_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_DYN, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_OFS, idx.id1, -20); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_TXPLM, idx.id1, UINT32_MAX); + + hw_mod_flm_rcp_flush(&ndev->be, idx.id1, 1); + } + + return idx; +} + +void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->flm[idx.id1].ref += 1; +} + +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + if (idx.id1 > 0) { + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, + sizeof(struct hw_db_inline_flm_rcp_data)); + db->flm[idx.id1].ref = 0; + + hw_db_inline_setup_default_flm_rcp(ndev, idx.id1); + } + } +} + /******************************************************************************/ /* FLM FT */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index a520ae1769..9820225ffa 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -138,6 +138,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_TPE, HW_DB_IDX_TYPE_TPE_EXT, + HW_DB_IDX_TYPE_FLM_RCP, HW_DB_IDX_TYPE_KM_RCP, HW_DB_IDX_TYPE_FLM_FT, HW_DB_IDX_TYPE_KM_FT, @@ -165,6 +166,22 @@ struct hw_db_inline_cat_data { uint8_t ip_prot_tunnel; }; +struct hw_db_inline_flm_rcp_data { + uint64_t qw0_dyn : 5; + uint64_t qw0_ofs : 8; + uint64_t qw4_dyn : 5; + uint64_t qw4_ofs : 8; + uint64_t sw8_dyn : 5; + uint64_t sw8_ofs : 8; + uint64_t sw9_dyn : 5; + uint64_t sw9_ofs : 8; + uint64_t outer_prot : 1; + uint64_t inner_prot : 1; + uint64_t padding : 10; + + uint32_t mask[10]; +}; + struct hw_db_inline_qsl_data { uint32_t discard : 1; uint32_t drop : 1; @@ -300,7 +317,10 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct /**/ +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group); void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_flm_ft_data *data); 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 85adcbb2d9..94635d7aaf 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 @@ -101,6 +101,11 @@ static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable) hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0); hw_mod_flm_control_flush(&ndev->be); + for (uint32_t i = 1; i < ndev->be.flm.nb_categories; ++i) + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, i, 0x0); + + hw_mod_flm_rcp_flush(&ndev->be, 1, ndev->be.flm.nb_categories - 1); + /* Wait for FLM to enter Idle state */ for (uint32_t i = 0; i < 1000000; ++i) { uint32_t value = 0; @@ -2657,8 +2662,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, uint32_t num_dest_port, uint32_t num_queues, - uint32_t *packet_data, uint32_t *packet_mask __rte_unused, - struct flm_flow_key_def_s *key_def __rte_unused) + uint32_t *packet_data, uint32_t *packet_mask, + struct flm_flow_key_def_s *key_def) { struct flow_handle *fh = calloc(1, sizeof(struct flow_handle)); @@ -2691,6 +2696,31 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n * Flow for group 1..32 */ + /* Setup FLM RCP */ + struct hw_db_inline_flm_rcp_data flm_data = { + .qw0_dyn = key_def->qw0_dyn, + .qw0_ofs = key_def->qw0_ofs, + .qw4_dyn = key_def->qw4_dyn, + .qw4_ofs = key_def->qw4_ofs, + .sw8_dyn = key_def->sw8_dyn, + .sw8_ofs = key_def->sw8_ofs, + .sw9_dyn = key_def->sw9_dyn, + .sw9_ofs = key_def->sw9_ofs, + .outer_prot = key_def->outer_proto, + .inner_prot = key_def->inner_proto, + }; + memcpy(flm_data.mask, packet_mask, sizeof(uint32_t) * 10); + struct hw_db_flm_idx flm_idx = + hw_db_inline_flm_add(dev->ndev, dev->ndev->hw_db_handle, &flm_data, + attr->group); + fh->db_idxs[fh->db_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; + } + /* Setup Actions */ uint16_t flm_rpl_ext_ptr = 0; uint32_t flm_ft = 0; @@ -2703,7 +2733,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n } /* Program flow */ - convert_fh_to_fh_flm(fh, packet_data, 2, flm_ft, flm_rpl_ext_ptr, + convert_fh_to_fh_flm(fh, packet_data, flm_idx.id1 + 2, flm_ft, flm_rpl_ext_ptr, flm_scrub, attr->priority & 0x3); flm_flow_programming(fh, NT_FLM_OP_LEARN); @@ -3275,6 +3305,12 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, 0, 0); + hw_mod_flm_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 0); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 1); + flow_nic_free_resource(ndev, RES_FLM_RCP, 0); + flow_group_handle_destroy(&ndev->group_handle); ntnic_id_table_destroy(ndev->id_table_handle); From patchwork Tue Oct 29 16:41:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147638 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7EDE845BC0; Tue, 29 Oct 2024 17:47:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F03C42F8B; Tue, 29 Oct 2024 17:44:19 +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 0101342EE0 for ; Tue, 29 Oct 2024 17:43:31 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2112.outbound.protection.outlook.com [104.47.30.112]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GtGJdxKOiCtA22ya65va7b0OvJ8aMPLxRtNZLf/xXqAWYMCc/MQhbNgi9FFp3rz35OR/X8NUEgEsXK9Fo5DkuZrQqz6TsfMw2GD1ztqe2PA5p9wTSkYzh6btLq5qbX4hy60xJDKKOcV5af20cl/1HRwfr+ASisAz4mJprGoikFENzRJXrVafoDzlBoSbot/+MVHzwuXucy9ksPJS6B6PGWPUHi0sbFJ/7Wf0xNxa31/fOAikRdTM7JZn08Ej8o+jLiI9io4suxClke5lSgtun6Z9XMtsiGJbn3yYK2SNLf61mef5Cnz/bC9KybhOs8v2VRuVXOOquKC/o3+pE9l2vw== 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=wR60WKslyVw+wYncG1GI3SY8eQtdTSznPvqH1OTHrKI=; b=dtmPR4aq5hYgIffqLu3kggdRHmNJokTya/Ur4gOQUUBDImYNC7pCCjfLV4+aIgNwrtDZMuH3EhgAngFQ33UNchvz6PxP8K9C8Rew+DWoEAC/WDFh/VJRPRYtIFbeTy5JaGqKS7c/4xxXqzcNdfOuDksfar5/0Hjul9q9oYpFqskNlz8pdOX2LbLGK3cjFpfcvaNdppRv7Lsr6DDN3fNyHdpiMbGMu0SHxz80ZdnSWcVvcGMVXP1NrxUIJB0F4PJ2a3esgDkVt8vmJsgCpXIqBdsCdcNPXDOdAhiv0PJwz2IGjT9oqKj3Si9mXYiBSosKa6MPnB0qGB2sDF/nnvfhBQ== 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=wR60WKslyVw+wYncG1GI3SY8eQtdTSznPvqH1OTHrKI=; b=Gkv283/QkyERtTnhaSgpOf/+ratRNHLrcJHpZzuOK3FKa1Dhbbr1Vd0wfZvRa+TAFcuMKofOGgrRcoq5mOdltvuYRiLJbb7ZwwnjETs9+ECz1gHdw3xnRsBR2hp/T/bRkPazjjA/xB0WpD4AZjB4oUnPV3dTRuE7Bw5eT1HJXu0= Received: from DUZPR01CA0204.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::25) by AS4P190MB1733.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:27 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::75) by DUZPR01CA0204.outlook.office365.com (2603:10a6:10:4b6::25) 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:43:27 +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:43:27 +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 35/86] net/ntnic: add learn flow queue handling Date: Tue, 29 Oct 2024 17:41:39 +0100 Message-ID: <20241029164243.1648775-36-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS4P190MB1733:EE_ X-MS-Office365-Filtering-Correlation-Id: aa725ca0-a352-49ab-9607-08dcf838d041 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: wlBERJEPWfX9L0hcNNLVJzojCi18zqiFWuk/4r7cf4I5KmYVmJGnXNGhDxwc0oLWXDs1wO86mWJC3CbS8EG9OjXgT/tzuDOFCLUipmNpt8paQqRmcC6hT6hDWYLKW9TOvG4enIV4NDh8CZ6FLDVilwi+yyeyRBzz3j7PXcOQsEY/7QqWn6w1Ur4HNS/zOnyiWhu/Sv/EcUr/19JuoUu3nn4Bfls03NbXcXVaiyZxp9C6spiFeehbc5Aj5BHyYfowHp8XTLxwM7e0JdiUfDxQWTkTbMcOWqpv14WcOmUnQkawpV9C3NEXlXPbH1zHU1B1xx23qGpXyRG0+/+yxFMKYN1GHrKar9Fst5E5beOtff+kf1kPrJqMEMr5YN9qr9Rc0AqaiXROwYcjtSeVe4IaC0KHDKL6O4q3KGG7ZPbkK6A4/y8eZeBbH+2vygUJZ3DFc7+YNzXYe/+/UzUBxQE497mdCbnphW3ueCS0ZZbafSKKteSDKBLyS1rQoD0utaXqiRX5Lx1+SqXbzwttl/TI7ONmKpJ2e2ZGB3v1MUimSNVgeQLlqrdkspa4FV/MSP4a3RzGTsI5+9eCwvyBbRSPbaQqSPwdKqly4BRapiBdLoOXO69qR+K9Co6oLq1oy1Z5/AFQWFhsPVGin+IaqQxl0JSH+3C/BeagLldZtmB+iDGyUXXMi/WVppLhfAbsU5sf4mvGnO9CbOHzrZNQ0XX/8BOD9lHo8Ws7wS/4eHsBd49fiySEqmrF3e3TQqcZnqpft5/USUsX2dyJGNBUcyvGTNSUO9o5kwZlfZnVH8JjF1uxdDHJCJl3xied5sXxsvt914aIFTWPS2ij1dxAKgtWgeEWkabPq3o7kx7VUIn3RKM9bXhf+Sn6jQ97hD/FQCBN7QiBHwFH+jkwNOJg8yCZNgdFditvb3P6cr4L55sOGwzbeCYfzUAdiWB9437alxM4CYG97CGPPAqocUlbgziTQxb8SfV3pEeebQGigQMDoAAl2qOh47jDpcM/Pox2EG+s3UGfYLosXWbefy3bL41ybZrQgZbT+qBUrUd1xj4LgviB0I4KHitJLu7PnzpOM1dXiARZSb2U5tjv89z9TGL/knOqWsJf1TEsE/zNrxUYJJnkY8U9eqwd+LWRlFr6P+/mM06h3NhAg60xNYdh7OJJagwx42jmIMwAHAV3I3oL01apl943D+xJZ64OqrW+HdK2vo6wlC7fZf6FnRyMsIUFC3cQ31Y7OuyYcdBTo0O0ZGyM3xxttr4FqroyfSj0YcD98+ByNRYo/l+PMYKhY4uo7xh+2lA+kgqQ0RjW9DUmZjvuNdh+WRE9K86N4wOSKdj2RPM9ECpReo8ynKVwSdnwPHHNhEHVUmZEMIUJ34XL7LShGb5UzCYMOjSbDuN5Kyyz730sj49ercCYitz6j+bM5w== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: uALMbfj0/pTpVU2e2r2tvo4RLnf67QoJ7M4XjC4MfRNBoijU745pps9gH3Bq2lXoe0TerJK88Buw1LM5RvCphOPK7I/CFmu/qc28pSAKhB3tEa7J1ogvW31OHPGiAnCWE1cs7J+3/S5UAUwGbfQDvwUSSRVthdkRo41ikXOwV3FrbRZki7MYMCCRxpGrTqL6wFRjBhMYwEDIENrSPV0MvFv/3sNWiKVm4hWNUdBWJ7GvkWhgmK1lzhpS7PzBq1MHQ7SafOjf8d+Fx5TDk+3axt/YpD0YFdqfmHtX1TpqyjOR6uXyICFrpgWmO4qOjtHrfcXdmS0qAaTabkj1NDiTHA42GdEqjn17zmingGoZhGHiGhgqGs1iT8v+P69L8ZbTEsjFZ1olwU+p1hRiq7IDTgEP8/nVdP8CpedYRBZaPERKJeefZ8rENMKbY9KpzCxZazcQJEz/VLJH/gNfL7x/NhPwp0fg4tsrFQmf5ieKeorrAm3C72KxaTcuxvOLRwapeFtetREZC9EdyQMDu1myNmL52J7fCdV13a+44OuEr7TMT8Q5kLJuO8zuh9MuDqnAwyTPmvLC+/0w8PYrbtwJw4WwVfCeQDlWfh4ePzv6COna/vhspto05WHvohoSgoEOT++b9yA800jXlMjoSX09TAn1DBtjdNwXsGNYnWp9X8E= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:27.2615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa725ca0-a352-49ab-9607-08dcf838d041 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: AS4P190MB1733 X-BESS-ID: 1730220208-311207-12650-27720-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.30.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGxiZGQGYGUNTMwDIlxcAizd A0JSnRwiTRIDE1yTDNMtEo1TTNLC0tVak2FgDuLQf9QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-5.eu-central-1b.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 Implements thread for handling flow learn queue Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 5 + drivers/net/ntnic/include/ntdrv_4ga.h | 1 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 33 +++++++ .../flow_api/profile_inline/flm_lrn_queue.c | 42 +++++++++ .../flow_api/profile_inline/flm_lrn_queue.h | 11 +++ .../profile_inline/flow_api_profile_inline.c | 48 ++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 94 +++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 ++ 8 files changed, 241 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 13722c30a9..17d5755634 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -688,6 +688,11 @@ int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, uint32_t value); +int hw_mod_flm_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e field, + const uint32_t *value, uint32_t records, + uint32_t *handled_records, uint32_t *inf_word_cnt, + uint32_t *sta_word_cnt); + int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); struct hsh_func_s { diff --git a/drivers/net/ntnic/include/ntdrv_4ga.h b/drivers/net/ntnic/include/ntdrv_4ga.h index 8017aa4fc3..8ebdd98db0 100644 --- a/drivers/net/ntnic/include/ntdrv_4ga.h +++ b/drivers/net/ntnic/include/ntdrv_4ga.h @@ -14,6 +14,7 @@ typedef struct ntdrv_4ga_s { char *p_drv_name; volatile bool b_shutdown; + rte_thread_t flm_thread; } ntdrv_4ga_t; #endif /* __NTDRV_4GA_H__ */ diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index 0a7e90c04f..f4c29b8bde 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -712,3 +712,36 @@ int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i return hw_mod_flm_rcp_mod(be, field, index, &value, 0); } + +int hw_mod_flm_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e field, + const uint32_t *value, uint32_t records, + uint32_t *handled_records, uint32_t *inf_word_cnt, + uint32_t *sta_word_cnt) +{ + int ret = 0; + + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_FLOW_LRN_DATA: + ret = be->iface->flm_lrn_data_flush(be->be_dev, &be->flm, value, records, + handled_records, + (sizeof(struct flm_v25_lrn_data_s) / + sizeof(uint32_t)), + inf_word_cnt, sta_word_cnt); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return ret; +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c index ad7efafe08..6e77c28f93 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c @@ -13,8 +13,28 @@ #include "flm_lrn_queue.h" +#define QUEUE_SIZE (1 << 13) + #define ELEM_SIZE sizeof(struct flm_v25_lrn_data_s) +void *flm_lrn_queue_create(void) +{ + static_assert((ELEM_SIZE & ~(size_t)3) == ELEM_SIZE, "FLM LEARN struct size"); + struct rte_ring *q = rte_ring_create_elem("RFQ", + ELEM_SIZE, + QUEUE_SIZE, + SOCKET_ID_ANY, + RING_F_MP_HTS_ENQ | RING_F_SC_DEQ); + assert(q != NULL); + return q; +} + +void flm_lrn_queue_free(void *q) +{ + if (q) + rte_ring_free(q); +} + uint32_t *flm_lrn_queue_get_write_buffer(void *q) { struct rte_ring_zc_data zcd; @@ -26,3 +46,25 @@ void flm_lrn_queue_release_write_buffer(void *q) { rte_ring_enqueue_zc_elem_finish(q, 1); } + +read_record flm_lrn_queue_get_read_buffer(void *q) +{ + struct rte_ring_zc_data zcd; + read_record rr; + + if (rte_ring_dequeue_zc_burst_elem_start(q, ELEM_SIZE, QUEUE_SIZE, &zcd, NULL) != 0) { + rr.num = zcd.n1; + rr.p = zcd.ptr1; + + } else { + rr.num = 0; + rr.p = NULL; + } + + return rr; +} + +void flm_lrn_queue_release_read_buffer(void *q, uint32_t num) +{ + rte_ring_dequeue_zc_elem_finish(q, num); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h index 8cee0c8e78..40558f4201 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h @@ -8,7 +8,18 @@ #include +typedef struct read_record { + uint32_t *p; + uint32_t num; +} read_record; + +void *flm_lrn_queue_create(void); +void flm_lrn_queue_free(void *q); + uint32_t *flm_lrn_queue_get_write_buffer(void *q); void flm_lrn_queue_release_write_buffer(void *q); +read_record flm_lrn_queue_get_read_buffer(void *q); +void flm_lrn_queue_release_read_buffer(void *q, uint32_t num); + #endif /* _FLM_LRN_QUEUE_H_ */ 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 94635d7aaf..6ad9f53954 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 @@ -39,6 +39,48 @@ static void *flm_lrn_queue_arr; +static void flm_setup_queues(void) +{ + flm_lrn_queue_arr = flm_lrn_queue_create(); + assert(flm_lrn_queue_arr != NULL); +} + +static void flm_free_queues(void) +{ + flm_lrn_queue_free(flm_lrn_queue_arr); +} + +static uint32_t flm_lrn_update(struct flow_eth_dev *dev, uint32_t *inf_word_cnt, + uint32_t *sta_word_cnt) +{ + read_record r = flm_lrn_queue_get_read_buffer(flm_lrn_queue_arr); + + if (r.num) { + uint32_t handled_records = 0; + + if (hw_mod_flm_lrn_data_set_flush(&dev->ndev->be, HW_FLM_FLOW_LRN_DATA, r.p, r.num, + &handled_records, inf_word_cnt, sta_word_cnt)) { + NT_LOG(ERR, FILTER, "Flow programming failed"); + + } else if (handled_records > 0) { + flm_lrn_queue_release_read_buffer(flm_lrn_queue_arr, handled_records); + } + } + + return r.num; +} + +static uint32_t flm_update(struct flow_eth_dev *dev) +{ + static uint32_t inf_word_cnt; + static uint32_t sta_word_cnt; + + if (flm_lrn_update(dev, &inf_word_cnt, &sta_word_cnt) != 0) + return 1; + + return inf_word_cnt + sta_word_cnt; +} + static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) { for (int i = 0; i < dev->num_queues; ++i) @@ -4218,6 +4260,12 @@ static const struct profile_inline_ops ops = { .flow_create_profile_inline = flow_create_profile_inline, .flow_destroy_profile_inline = flow_destroy_profile_inline, .flow_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, + /* + * NT Flow FLM Meter API + */ + .flm_setup_queues = flm_setup_queues, + .flm_free_queues = flm_free_queues, + .flm_update = flm_update, }; void profile_inline_init(void) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index a509a8eb51..bfca8f28b1 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -24,6 +24,11 @@ #include "ntnic_mod_reg.h" #include "nt_util.h" +const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL }; +#define THREAD_CTRL_CREATE(a, b, c, d) rte_thread_create_internal_control(a, b, c, d) +#define THREAD_JOIN(a) rte_thread_join(a, NULL) +#define THREAD_FUNC static uint32_t +#define THREAD_RETURN (0) #define HW_MAX_PKT_LEN (10000) #define MAX_MTU (HW_MAX_PKT_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN) @@ -120,6 +125,16 @@ store_pdrv(struct drv_s *p_drv) rte_spinlock_unlock(&hwlock); } +static void clear_pdrv(struct drv_s *p_drv) +{ + if (p_drv->adapter_no > NUM_ADAPTER_MAX) + return; + + rte_spinlock_lock(&hwlock); + _g_p_drv[p_drv->adapter_no] = NULL; + rte_spinlock_unlock(&hwlock); +} + static struct drv_s * get_pdrv_from_pci(struct rte_pci_addr addr) { @@ -1240,6 +1255,13 @@ eth_dev_set_link_down(struct rte_eth_dev *eth_dev) static void drv_deinit(struct drv_s *p_drv) { + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "profile_inline module uninitialized"); + return; + } + const struct adapter_ops *adapter_ops = get_adapter_ops(); if (adapter_ops == NULL) { @@ -1251,6 +1273,22 @@ drv_deinit(struct drv_s *p_drv) return; ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv; + fpga_info_t *fpga_info = &p_nt_drv->adapter_info.fpga_info; + + /* + * Mark the global pdrv for cleared. Used by some threads to terminate. + * 1 second to give the threads a chance to see the termonation. + */ + clear_pdrv(p_drv); + nt_os_wait_usec(1000000); + + /* stop statistics threads */ + p_drv->ntdrv.b_shutdown = true; + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + THREAD_JOIN(p_nt_drv->flm_thread); + profile_inline_ops->flm_free_queues(); + } /* stop adapter */ adapter_ops->deinit(&p_nt_drv->adapter_info); @@ -1359,6 +1397,43 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { .promiscuous_enable = promiscuous_enable, }; +/* + * Adapter flm stat thread + */ +THREAD_FUNC adapter_flm_update_thread_fn(void *context) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, NTNIC, "%s: profile_inline module uninitialized", __func__); + return THREAD_RETURN; + } + + struct drv_s *p_drv = context; + + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + struct adapter_info_s *p_adapter_info = &p_nt_drv->adapter_info; + struct nt4ga_filter_s *p_nt4ga_filter = &p_adapter_info->nt4ga_filter; + struct flow_nic_dev *p_flow_nic_dev = p_nt4ga_filter->mp_flow_device; + + NT_LOG(DBG, NTNIC, "%s: %s: waiting for port configuration", + p_adapter_info->mp_adapter_id_str, __func__); + + while (p_flow_nic_dev->eth_base == NULL) + nt_os_wait_usec(1 * 1000 * 1000); + + struct flow_eth_dev *dev = p_flow_nic_dev->eth_base; + + NT_LOG(DBG, NTNIC, "%s: %s: begin", p_adapter_info->mp_adapter_id_str, __func__); + + while (!p_drv->ntdrv.b_shutdown) + if (profile_inline_ops->flm_update(dev) == 0) + nt_os_wait_usec(10); + + NT_LOG(DBG, NTNIC, "%s: %s: end", p_adapter_info->mp_adapter_id_str, __func__); + return THREAD_RETURN; +} + static int nthw_pci_dev_init(struct rte_pci_device *pci_dev) { @@ -1369,6 +1444,13 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* Return statement is not necessary here to allow traffic processing by SW */ } + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "profile_inline module uninitialized"); + /* Return statement is not necessary here to allow traffic processing by SW */ + } + nt_vfio_init(); const struct port_ops *port_ops = get_port_ops(); @@ -1597,6 +1679,18 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) return -1; } + if (profile_inline_ops != NULL && fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + profile_inline_ops->flm_setup_queues(); + res = THREAD_CTRL_CREATE(&p_nt_drv->flm_thread, "ntnic-nt_flm_update_thr", + adapter_flm_update_thread_fn, (void *)p_drv); + + if (res) { + NT_LOG_DBGX(ERR, NTNIC, "%s: error=%d", + (pci_dev->name[0] ? pci_dev->name : "NA"), res); + return -1; + } + } + n_phy_ports = fpga_info->n_phy_ports; for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) { diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 1069be2f85..27d6cbef01 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -256,6 +256,13 @@ struct profile_inline_ops { int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); + + /* + * NT Flow FLM queue API + */ + void (*flm_setup_queues)(void); + void (*flm_free_queues)(void); + uint32_t (*flm_update)(struct flow_eth_dev *dev); }; void register_profile_inline_ops(const struct profile_inline_ops *ops); From patchwork Tue Oct 29 16:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147642 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7E5545BC0; Tue, 29 Oct 2024 17:48:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1892442FB3; Tue, 29 Oct 2024 17:44:26 +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 AB1FC42ECF for ; Tue, 29 Oct 2024 17:43:34 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qnlu/sCOW7WztNPE+bpAs4QQ2dpeTuiQL/qr0KYfWSSMqsmMMQk9MynpzKp+Hto/HwKWYd7y1ipNsDdNDvWstIjXCmsirjPDKBqvCGPaRsbN2URUtiTmrzHWLTYi5TVaC25JNfqpc2JqJWOrf8lClwFkbyw9IjdoqPxM+4Is87jF6b4yeen2licz8fbGncFX+86Jm6CJNbxO8s3rtdO1ovR6ieTn4DxiASYTx0xEHI7IAb3eXC0rs1/Wj8/x9w33CqdctZrNxG0BztadiZb5nFvahk1+RWfW/09/rHbzkmkGWltDmlqlkIsd9GvSxGHvfp1sSEtWlGnnRs8wTjWYew== 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=LdeMVYMwsQQZuMX6iCC1wQIk6ODj+hQI9a3xMTsgOf4=; b=PpnsNILWiIOeNgneqyVvZ4unC/rM6yn5OgCP9/6/UXgrZ57QJrSdUZwtCEBPLn0cXC6PCcRJyzdVLXa7tc6FakBR8aIelHQnAHLtfF2KhRz/O5/ZaGVNMMQxkTMw89huDC4tHmQ3Zt6q2Sx1uXI55ORcLGyxrZ/PLV61LR/tHmhU520lsZMIx+v2r/XklgyuiCaPP9Pq8Tnv3l9qtweRMYu0rgCFgVPJltEcp4nPRYIppOnOBmf8uQZP32wiflnsUW0o14GC3iQWzXLT+b/3PHXQ3D9ZcNRz0No2aDg6oX/GVew08wO5FI2Gb+Gtki6SVHwxcHBYQbPKTB43zKDb0g== 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=LdeMVYMwsQQZuMX6iCC1wQIk6ODj+hQI9a3xMTsgOf4=; b=TkH3uE+K0e4inlliGpPFttcRAKXwNDkhrkdWP2pRxMlr/pbwVKXfyD5AGbC0heQZOGG2TGNPt+OHGxRdvhLBmGOXT2m5VawJIa6njbXevNHOqW5XuivLe2aghGL5e9jFmzQiIfSjdA0b4RkH4mhLDxmK90Cv7e48Hnxt/i1J+vY= Received: from DUZPR01CA0192.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::15) by AS8P190MB1109.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:28 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::25) by DUZPR01CA0192.outlook.office365.com (2603:10a6:10:4b6::15) 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:43:28 +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:43:28 +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 36/86] net/ntnic: match and action db attributes were added Date: Tue, 29 Oct 2024 17:41:40 +0100 Message-ID: <20241029164243.1648775-37-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS8P190MB1109:EE_ X-MS-Office365-Filtering-Correlation-Id: 80b0a54c-5e63-474a-f286-08dcf838d0bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: eI7cPOfr3nkpiEpZwKho77Arp3pPoi8/8IzXJ8j2asKhtRfTWzWzmJGJrDTfadcK0/PCWDJH1jHCU1OwrGCAL7qvdlmMkB2VijqyQkwEsk0lN5wBIXFK4qWGU3W0U+4rIAaLb7SEA6rdBEd1mFacUSCfYZlpsE8eqMbYdDXQIIqnkhca41FwyeL200d6R4JiEpM02znXe6w7giKcrQ8vwusaayqvLk051ce/TSr0k1E3+bwZ99F25Kg5BWSvkT/EDkFBCs4RDXiLaWTlGmIGhGlma+ufW5w1u+vJ1/9uTSHBOQXtqNjbiI4XwpYCab+gU8TMahVvpW5/5rPsOWxFLzM211IatNNv2znksbJtugb79yXJtgbRIdqlTZo79LZHkqU3+WYrS40mvysD13yibiA0JxPpCwW9MdzSPxFth1df+GORcvaFlL8140FKfHh7RXuxtKvcOswf4IS/yyGOq99LFQ9nXqqfP0i6mhdaQw4K6KIzj5il8XF9MDRsA1k2KJGQ4YSs4p5Ve0i9X7OVirmfGJjD0qKEzu5d74bpEYdllpBjSGh/WjO6KJT4ZwzP00h+xblDkl+9pOGZvzPovtoFRYe3JvDRzRZdopgVv6T6sM92xkblr5We875ipHo/ecX5xZKIUCbyYjtxQL9egd/KMw4nrj4AcXYhwYIXltfcgJRXsLcLV7DKTzxtuPIW/xPTCzJL2NV3JODjOSufFnxHLNzQGPOk+KKjnC6v4Yt4Y6ceXwxM5VbkoL9zBICEs8YZkiOvMMxhf5ioPoF/HaYJp11R2+IT5IhaQ1X5ecyv7Gw3FWD4K1Uq+/yZpqf7FT5IhNMsakt5Gno81ffISA4aGnkuHl/dAS5AEuSSXgMRUkuhOjkekdvJIb4K5kosJFdJMeaIl2BiRpdUE8fycJRQaT10hsRCiFP//sweNaC6Cw1Ryci9WK3wLLEz8PmwquX6W8c4LNkVFI4mQu7sd0WBVCEqGj/qa0MwDYxTGhIWcuPsx1pyVgO57Hwmp+INYZqV6ElhtsztlI4EVfOmvjzgqmFZGIztwRWrR8VtVwL+eNHCBxV1zX6AFD4uK4P+S/oWKD4+AMAWlXMzy1F5rsQFUu54Mm2JyBwx1tp3F6b0EAIIyo5YxtyaGcweUkaS/SN+5P5AfydJLTduIibmlV6Rq/3aaasAz7ob4RXN8k4WZ3D0D61eQZEibq+UtkcTGXrI/xZHBMWcRfIXWgSkxEelhLaNQ34B1sjLgkAuCG8EPyPKJNi7LwsD3AIH8CrBfHZx4EDsNggtozS1kcmwQ1XGlDnOVpJPy99h67dk5uDMaDTR7Ujy+H73j/NcK/ZVi+bvPgzsHUb5qrzxV9de9L4AsOphMJSlLxT4E0IlyYzsSZ5q+aCo5pU+0Pthnrn5Nof4wKE/Uj6rSov5mtqJ3Q== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0qWv0NpOaQWf2liwu85AH9AgnkntnygTdrJIwXfK3lVOUVfjw2ushnivmajpVMj7aqrwo/iOiUSneBxg20faI+M0Dz+XF0hitBZs9Yc8tAKdlLy1FUt4xsYs9agXfDZXWB3Ix5/PDMa+s7YwAe9uGcEv+987YQUR6Shy/9AMsx0JDsem0tSZ6nEA1IKIN6hGGDPSz4+f07NAKTZ1M7uBrN2NsnEawFgtfg+3YN0h+FFmHaf3W0kjfqFVBOMqFbIddkbyf4XxoR00CEjf0BC8hvQj86hibsg8nOtp5KiNWvyjVRPENJuSX2tm6yjvn+JNmwLl3epnwd37kgXignnAR6yqj9wHZ1QVxF9N2ZW0QGfgeyJeyuIwaAas9W29ORmefudzToo6EVFxpeDZjsOA3JJEDofB3XeC6DVo3g9TqXV3HwbR1VLYL7xmOyyUK5Ktc6bRCx9fFeoT8LA1cmj2wU4Vq2iMC2IC7HfKEUJZ/eQ/Mjp8CljBMySY9qVrljHhJ2aq+WpSwHrjkQFdNgKrvxnWSC2X8VZwA+LMwYEdxY6CPmNN0NWrxhhQHU8L75ggNhOWiSQArNgKsDL6tpxEdAjcVG+tAyi3kCp/54mOP3JPItAe3f/GGZizxyjh4TpR8E9Dy4t6FCoeZsrGbPyccCY61tz3mSGUCi60bPFk8wc= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:28.0896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80b0a54c-5e63-474a-f286-08dcf838d0bf 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: AS8P190MB1109 X-BESS-ID: 1730220210-311207-12675-26837-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsamBpYGQGYGUDTJIsUoxcLc3M LM3DzNMskyxSjJwtDSwtI4zcg8OdnSWKk2FgCt8k7tQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan18-12.eu-central-1b.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 Implements match/action dereferencing Signed-off-by: Danylo Vodopianov --- .../profile_inline/flow_api_hw_db_inline.c | 795 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 35 + .../profile_inline/flow_api_profile_inline.c | 55 ++ 3 files changed, 885 insertions(+) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 0ae058b91e..52f85b65af 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -9,6 +9,9 @@ #include "flow_api_hw_db_inline.h" #include "rte_common.h" +#define HW_DB_INLINE_ACTION_SET_NB 512 +#define HW_DB_INLINE_MATCH_SET_NB 512 + #define HW_DB_FT_LOOKUP_KEY_A 0 #define HW_DB_FT_TYPE_KM 1 @@ -110,6 +113,20 @@ struct hw_db_inline_resource_db { int cfn_hw; int ref; } *cfn; + + uint32_t cfn_priority_counter; + uint32_t set_priority_counter; + + struct hw_db_inline_resource_db_action_set { + struct hw_db_inline_action_set_data data; + int ref; + } action_set[HW_DB_INLINE_ACTION_SET_NB]; + + struct hw_db_inline_resource_db_match_set { + struct hw_db_inline_match_set_data data; + int ref; + uint32_t set_priority; + } match_set[HW_DB_INLINE_MATCH_SET_NB]; }; int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) @@ -292,6 +309,16 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct case HW_DB_IDX_TYPE_NONE: break; + case HW_DB_IDX_TYPE_MATCH_SET: + hw_db_inline_match_set_deref(ndev, db_handle, + *(struct hw_db_match_set_idx *)&idxs[i]); + break; + + case HW_DB_IDX_TYPE_ACTION_SET: + hw_db_inline_action_set_deref(ndev, db_handle, + *(struct hw_db_action_set_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_CAT: hw_db_inline_cat_deref(ndev, db_handle, *(struct hw_db_cat_idx *)&idxs[i]); break; @@ -360,6 +387,12 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_NONE: return NULL; + case HW_DB_IDX_TYPE_MATCH_SET: + return &db->match_set[idxs[i].ids].data; + + case HW_DB_IDX_TYPE_ACTION_SET: + return &db->action_set[idxs[i].ids].data; + case HW_DB_IDX_TYPE_CAT: return &db->cat[idxs[i].ids].data; @@ -552,6 +585,763 @@ static void hw_db_inline_setup_default_flm_rcp(struct flow_nic_dev *ndev, int fl } +static void hw_db_copy_ft(struct flow_nic_dev *ndev, int type, int cfn_dst, int cfn_src, + int lookup, int flow_type) +{ + const int max_lookups = 4; + const int cat_funcs = (int)ndev->be.cat.nb_cat_funcs / 8; + + int fte_index_dst = (8 * flow_type + cfn_dst / cat_funcs) * max_lookups + lookup; + int fte_field_dst = cfn_dst % cat_funcs; + + int fte_index_src = (8 * flow_type + cfn_src / cat_funcs) * max_lookups + lookup; + int fte_field_src = cfn_src % cat_funcs; + + uint32_t current_bm_dst = 0; + uint32_t current_bm_src = 0; + uint32_t fte_field_bm_dst = 1 << fte_field_dst; + uint32_t fte_field_bm_src = 1 << fte_field_src; + + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_dst, ¤t_bm_dst); + hw_mod_cat_fte_flm_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_src, ¤t_bm_src); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_dst, ¤t_bm_dst); + hw_mod_cat_fte_km_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_src, ¤t_bm_src); + break; + + default: + break; + } + + uint32_t enable = current_bm_src & fte_field_bm_src; + uint32_t final_bm_dst = enable ? (fte_field_bm_dst | current_bm_dst) + : (~fte_field_bm_dst & current_bm_dst); + + if (current_bm_dst != final_bm_dst) { + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_dst, final_bm_dst); + hw_mod_cat_fte_flm_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index_dst, 1); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index_dst, final_bm_dst); + hw_mod_cat_fte_km_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index_dst, 1); + break; + + default: + break; + } + } +} + + +static int hw_db_inline_filter_apply(struct flow_nic_dev *ndev, + struct hw_db_inline_resource_db *db, + int cat_hw_id, + struct hw_db_match_set_idx match_set_idx, + struct hw_db_flm_ft flm_ft_idx, + struct hw_db_action_set_idx action_set_idx) +{ + (void)match_set_idx; + (void)flm_ft_idx; + + const struct hw_db_inline_match_set_data *match_set = + &db->match_set[match_set_idx.ids].data; + const struct hw_db_inline_cat_data *cat = &db->cat[match_set->cat.ids].data; + + const int km_ft = match_set->km_ft.id1; + const int km_rcp = (int)db->km[match_set->km.id1].data.rcp; + + const int flm_ft = flm_ft_idx.id1; + const int flm_rcp = flm_ft_idx.id2; + + const struct hw_db_inline_action_set_data *action_set = + &db->action_set[action_set_idx.ids].data; + const struct hw_db_inline_cot_data *cot = &db->cot[action_set->cot.ids].data; + + const int qsl_hw_id = action_set->qsl.ids; + const int slc_lr_hw_id = action_set->slc_lr.ids; + const int tpe_hw_id = action_set->tpe.ids; + const int hsh_hw_id = action_set->hsh.ids; + + /* Setup default FLM RCP if needed */ + if (flm_rcp > 0 && db->flm[flm_rcp].ref <= 0) + hw_db_inline_setup_default_flm_rcp(ndev, flm_rcp); + + /* Setup CAT.CFN */ + { + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_INV, cat_hw_id, 0, 0x0); + + /* Protocol checks */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_INV, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_ISL, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_CFP, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_MAC, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L2, cat_hw_id, 0, cat->ptc_mask_l2); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_VNTAG, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_VLAN, cat_hw_id, 0, cat->vlan_mask); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_MPLS, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L3, cat_hw_id, 0, cat->ptc_mask_l3); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_FRAG, cat_hw_id, 0, + cat->ptc_mask_frag); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_IP_PROT, cat_hw_id, 0, cat->ip_prot); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L4, cat_hw_id, 0, cat->ptc_mask_l4); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TUNNEL, cat_hw_id, 0, + cat->ptc_mask_tunnel); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L2, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_VLAN, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_MPLS, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L3, cat_hw_id, 0, + cat->ptc_mask_l3_tunnel); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_FRAG, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_IP_PROT, cat_hw_id, 0, + cat->ip_prot_tunnel); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L4, cat_hw_id, 0, + cat->ptc_mask_l4_tunnel); + + /* Error checks */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_INV, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_CV, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_FCS, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_TRUNC, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_L3_CS, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_L4_CS, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_TNL_L3_CS, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_TNL_L4_CS, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_TTL_EXP, cat_hw_id, 0, + cat->err_mask_ttl); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ERR_TNL_TTL_EXP, cat_hw_id, 0, + cat->err_mask_ttl_tunnel); + + /* MAC port check */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_MAC_PORT, cat_hw_id, 0, + cat->mac_port_mask); + + /* Pattern match checks */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_CMP, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_DCT, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_EXT_INV, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_CMB, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_AND_INV, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_OR_INV, cat_hw_id, 0, -1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PM_INV, cat_hw_id, 0, -1); + + /* Length checks */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_LC, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_LC_INV, cat_hw_id, 0, -1); + + /* KM and FLM */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM0_OR, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM1_OR, cat_hw_id, 0, 0x3); + + hw_mod_cat_cfn_flush(&ndev->be, cat_hw_id, 1); + } + + /* Setup CAT.CTS */ + { + const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; + + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 0, cat_hw_id); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 0, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 1, hsh_hw_id); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 1, qsl_hw_id); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 2, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 2, + slc_lr_hw_id); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 3, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 3, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 4, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 4, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + 5, tpe_hw_id); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 5, 0); + + hw_mod_cat_cts_flush(&ndev->be, offset * cat_hw_id, 6); + } + + /* Setup CAT.CTE */ + { + hw_mod_cat_cte_set(&ndev->be, HW_CAT_CTE_ENABLE_BM, cat_hw_id, + 0x001 | 0x004 | (qsl_hw_id ? 0x008 : 0) | + (slc_lr_hw_id ? 0x020 : 0) | 0x040 | + (tpe_hw_id ? 0x400 : 0)); + hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1); + } + + /* Setup CAT.KM */ + { + uint32_t bm = 0; + + hw_mod_cat_kcs_km_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cat_hw_id, + km_rcp); + hw_mod_cat_kcs_km_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id, 1); + + hw_mod_cat_kce_km_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, &bm); + hw_mod_cat_kce_km_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, bm | (1 << (cat_hw_id % 8))); + hw_mod_cat_kce_km_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id / 8, 1); + + hw_db_set_ft(ndev, HW_DB_FT_TYPE_KM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, km_ft, 1); + } + + /* Setup CAT.FLM */ + { + uint32_t bm = 0; + + hw_mod_cat_kcs_flm_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cat_hw_id, + flm_rcp); + hw_mod_cat_kcs_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id, 1); + + hw_mod_cat_kce_flm_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, &bm); + hw_mod_cat_kce_flm_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, bm | (1 << (cat_hw_id % 8))); + hw_mod_cat_kce_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id / 8, 1); + + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, km_ft, 1); + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_C, flm_ft, 1); + } + + /* Setup CAT.COT */ + { + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, cat_hw_id, 0); + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_COLOR, cat_hw_id, cot->frag_rcp << 10); + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_KM, cat_hw_id, + cot->matcher_color_contrib); + hw_mod_cat_cot_flush(&ndev->be, cat_hw_id, 1); + } + + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cat_hw_id, 0, 0x1); + hw_mod_cat_cfn_flush(&ndev->be, cat_hw_id, 1); + + return 0; +} + +static void hw_db_inline_filter_clear(struct flow_nic_dev *ndev, + struct hw_db_inline_resource_db *db, + int cat_hw_id) +{ + /* Setup CAT.CFN */ + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0x0); + hw_mod_cat_cfn_flush(&ndev->be, cat_hw_id, 1); + + /* Setup CAT.CTS */ + { + const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; + + for (int i = 0; i < 6; ++i) { + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cat_hw_id + i, 0); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + i, 0); + } + + hw_mod_cat_cts_flush(&ndev->be, offset * cat_hw_id, 6); + } + + /* Setup CAT.CTE */ + { + hw_mod_cat_cte_set(&ndev->be, HW_CAT_CTE_ENABLE_BM, cat_hw_id, 0); + hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1); + } + + /* Setup CAT.KM */ + { + uint32_t bm = 0; + + hw_mod_cat_kcs_km_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cat_hw_id, + 0); + hw_mod_cat_kcs_km_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id, 1); + + hw_mod_cat_kce_km_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, &bm); + hw_mod_cat_kce_km_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, bm & ~(1 << (cat_hw_id % 8))); + hw_mod_cat_kce_km_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id / 8, 1); + + for (int ft = 0; ft < (int)db->nb_km_ft; ++ft) { + hw_db_set_ft(ndev, HW_DB_FT_TYPE_KM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, ft, + 0); + } + } + + /* Setup CAT.FLM */ + { + uint32_t bm = 0; + + hw_mod_cat_kcs_flm_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cat_hw_id, + 0); + hw_mod_cat_kcs_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id, 1); + + hw_mod_cat_kce_flm_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, &bm); + hw_mod_cat_kce_flm_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cat_hw_id / 8, bm & ~(1 << (cat_hw_id % 8))); + hw_mod_cat_kce_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cat_hw_id / 8, 1); + + for (int ft = 0; ft < (int)db->nb_flm_ft; ++ft) { + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, ft, + 0); + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_C, ft, + 0); + } + } + + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, cat_hw_id, 0); + hw_mod_cat_cot_flush(&ndev->be, cat_hw_id, 1); +} + +static void hw_db_inline_filter_copy(struct flow_nic_dev *ndev, + struct hw_db_inline_resource_db *db, int cfn_dst, int cfn_src) +{ + uint32_t val = 0; + + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_COPY_FROM, cfn_dst, 0, cfn_src); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cfn_dst, 0, 0x0); + hw_mod_cat_cfn_flush(&ndev->be, cfn_dst, 1); + + /* Setup CAT.CTS */ + { + const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; + + for (int i = 0; i < offset; ++i) { + hw_mod_cat_cts_get(&ndev->be, HW_CAT_CTS_CAT_A, offset * cfn_src + i, + &val); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_A, offset * cfn_dst + i, val); + hw_mod_cat_cts_get(&ndev->be, HW_CAT_CTS_CAT_B, offset * cfn_src + i, + &val); + hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cfn_dst + i, val); + } + + hw_mod_cat_cts_flush(&ndev->be, offset * cfn_dst, offset); + } + + /* Setup CAT.CTE */ + { + hw_mod_cat_cte_get(&ndev->be, HW_CAT_CTE_ENABLE_BM, cfn_src, &val); + hw_mod_cat_cte_set(&ndev->be, HW_CAT_CTE_ENABLE_BM, cfn_dst, val); + hw_mod_cat_cte_flush(&ndev->be, cfn_dst, 1); + } + + /* Setup CAT.KM */ + { + uint32_t bit_src = 0; + + hw_mod_cat_kcs_km_get(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cfn_src, + &val); + hw_mod_cat_kcs_km_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cfn_dst, + val); + hw_mod_cat_kcs_km_flush(&ndev->be, KM_FLM_IF_FIRST, cfn_dst, 1); + + hw_mod_cat_kce_km_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_src / 8, &val); + bit_src = (val >> (cfn_src % 8)) & 0x1; + + hw_mod_cat_kce_km_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_dst / 8, &val); + val &= ~(1 << (cfn_dst % 8)); + + hw_mod_cat_kce_km_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_dst / 8, val | (bit_src << (cfn_dst % 8))); + hw_mod_cat_kce_km_flush(&ndev->be, KM_FLM_IF_FIRST, cfn_dst / 8, 1); + + for (int ft = 0; ft < (int)db->nb_km_ft; ++ft) { + hw_db_copy_ft(ndev, HW_DB_FT_TYPE_KM, cfn_dst, cfn_src, + HW_DB_FT_LOOKUP_KEY_A, ft); + } + } + + /* Setup CAT.FLM */ + { + uint32_t bit_src = 0; + + hw_mod_cat_kcs_flm_get(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cfn_src, + &val); + hw_mod_cat_kcs_flm_set(&ndev->be, HW_CAT_KCS_CATEGORY, KM_FLM_IF_FIRST, cfn_dst, + val); + hw_mod_cat_kcs_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cfn_dst, 1); + + hw_mod_cat_kce_flm_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_src / 8, &val); + bit_src = (val >> (cfn_src % 8)) & 0x1; + + hw_mod_cat_kce_flm_get(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_dst / 8, &val); + val &= ~(1 << (cfn_dst % 8)); + + hw_mod_cat_kce_flm_set(&ndev->be, HW_CAT_KCE_ENABLE_BM, KM_FLM_IF_FIRST, + cfn_dst / 8, val | (bit_src << (cfn_dst % 8))); + hw_mod_cat_kce_flm_flush(&ndev->be, KM_FLM_IF_FIRST, cfn_dst / 8, 1); + + for (int ft = 0; ft < (int)db->nb_flm_ft; ++ft) { + hw_db_copy_ft(ndev, HW_DB_FT_TYPE_FLM, cfn_dst, cfn_src, + HW_DB_FT_LOOKUP_KEY_A, ft); + hw_db_copy_ft(ndev, HW_DB_FT_TYPE_FLM, cfn_dst, cfn_src, + HW_DB_FT_LOOKUP_KEY_C, ft); + } + } + + /* Setup CAT.COT */ + { + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_COPY_FROM, cfn_dst, cfn_src); + hw_mod_cat_cot_flush(&ndev->be, cfn_dst, 1); + } + + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cfn_dst, 0, 0x1); + hw_mod_cat_cfn_flush(&ndev->be, cfn_dst, 1); +} + +/* + * Algorithm for moving CFN entries to make space with respect of priority. + * The algorithm will make the fewest possible moves to fit a new CFN entry. + */ +static int hw_db_inline_alloc_prioritized_cfn(struct flow_nic_dev *ndev, + struct hw_db_inline_resource_db *db, + struct hw_db_match_set_idx match_set_idx) +{ + const struct hw_db_inline_resource_db_match_set *match_set = + &db->match_set[match_set_idx.ids]; + + uint64_t priority = ((uint64_t)(match_set->data.priority & 0xff) << 56) | + ((uint64_t)(0xffffff - (match_set->set_priority & 0xffffff)) << 32) | + (0xffffffff - ++db->cfn_priority_counter); + + int db_cfn_idx = -1; + + struct { + uint64_t priority; + uint32_t idx; + } sorted_priority[db->nb_cat]; + + memset(sorted_priority, 0x0, sizeof(sorted_priority)); + + uint32_t in_use_count = 0; + + for (uint32_t i = 1; i < db->nb_cat; ++i) { + if (db->cfn[i].ref > 0) { + sorted_priority[db->cfn[i].cfn_hw].priority = db->cfn[i].priority; + sorted_priority[db->cfn[i].cfn_hw].idx = i; + in_use_count += 1; + + } else if (db_cfn_idx == -1) { + db_cfn_idx = (int)i; + } + } + + if (in_use_count >= db->nb_cat - 1) + return -1; + + if (in_use_count == 0) { + db->cfn[db_cfn_idx].ref = 1; + db->cfn[db_cfn_idx].cfn_hw = 1; + db->cfn[db_cfn_idx].priority = priority; + return db_cfn_idx; + } + + int goal = 1; + int free_before = -1000000; + int free_after = 1000000; + int found_smaller = 0; + + for (int i = 1; i < (int)db->nb_cat; ++i) { + if (sorted_priority[i].priority > priority) { /* Bigger */ + goal = i + 1; + + } else if (sorted_priority[i].priority == 0) { /* Not set */ + if (found_smaller) { + if (free_after > i) + free_after = i; + + } else { + free_before = i; + } + + } else {/* Smaller */ + found_smaller = 1; + } + } + + int diff_before = goal - free_before - 1; + int diff_after = free_after - goal; + + if (goal < (int)db->nb_cat && sorted_priority[goal].priority == 0) { + db->cfn[db_cfn_idx].ref = 1; + db->cfn[db_cfn_idx].cfn_hw = goal; + db->cfn[db_cfn_idx].priority = priority; + return db_cfn_idx; + } + + if (diff_after <= diff_before) { + for (int i = free_after; i > goal; --i) { + int *cfn_hw = &db->cfn[sorted_priority[i - 1].idx].cfn_hw; + hw_db_inline_filter_copy(ndev, db, i, *cfn_hw); + hw_db_inline_filter_clear(ndev, db, *cfn_hw); + *cfn_hw = i; + } + + } else { + goal -= 1; + + for (int i = free_before; i < goal; ++i) { + int *cfn_hw = &db->cfn[sorted_priority[i + 1].idx].cfn_hw; + hw_db_inline_filter_copy(ndev, db, i, *cfn_hw); + hw_db_inline_filter_clear(ndev, db, *cfn_hw); + *cfn_hw = i; + } + } + + db->cfn[db_cfn_idx].ref = 1; + db->cfn[db_cfn_idx].cfn_hw = goal; + db->cfn[db_cfn_idx].priority = priority; + + return db_cfn_idx; +} + +static void hw_db_inline_free_prioritized_cfn(struct hw_db_inline_resource_db *db, int cfn_hw) +{ + for (uint32_t i = 0; i < db->nb_cat; ++i) { + if (db->cfn[i].cfn_hw == cfn_hw) { + memset(&db->cfn[i], 0x0, sizeof(struct hw_db_inline_resource_db_cfn)); + break; + } + } +} + +static void hw_db_inline_update_active_filters(struct flow_nic_dev *ndev, void *db_handle, + int group) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[group]; + struct hw_db_inline_resource_db_flm_cfn_map *cell; + + for (uint32_t match_set_idx = 0; match_set_idx < db->nb_cat; ++match_set_idx) { + for (uint32_t ft_idx = 0; ft_idx < db->nb_flm_ft; ++ft_idx) { + int active = flm_rcp->ft[ft_idx].ref > 0 && + flm_rcp->match_set[match_set_idx].ref > 0; + cell = &flm_rcp->cfn_map[match_set_idx * db->nb_flm_ft + ft_idx]; + + if (active && cell->cfn_idx == 0) { + /* Setup filter */ + cell->cfn_idx = hw_db_inline_alloc_prioritized_cfn(ndev, db, + flm_rcp->match_set[match_set_idx].idx); + hw_db_inline_filter_apply(ndev, db, db->cfn[cell->cfn_idx].cfn_hw, + flm_rcp->match_set[match_set_idx].idx, + flm_rcp->ft[ft_idx].idx, + group == 0 + ? db->match_set[flm_rcp->match_set[match_set_idx] + .idx.ids] + .data.action_set + : flm_rcp->ft[ft_idx].data.action_set); + } + + if (!active && cell->cfn_idx > 0) { + /* Teardown filter */ + hw_db_inline_filter_clear(ndev, db, db->cfn[cell->cfn_idx].cfn_hw); + hw_db_inline_free_prioritized_cfn(db, + db->cfn[cell->cfn_idx].cfn_hw); + cell->cfn_idx = 0; + } + } + } +} + + +/******************************************************************************/ +/* Match set */ +/******************************************************************************/ + +static int hw_db_inline_match_set_compare(const struct hw_db_inline_match_set_data *data1, + const struct hw_db_inline_match_set_data *data2) +{ + return data1->cat.raw == data2->cat.raw && data1->km.raw == data2->km.raw && + data1->km_ft.raw == data2->km_ft.raw && data1->jump == data2->jump; +} + +struct hw_db_match_set_idx +hw_db_inline_match_set_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_match_set_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[data->jump]; + struct hw_db_match_set_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_MATCH_SET; + + for (uint32_t i = 0; i < HW_DB_INLINE_MATCH_SET_NB; ++i) { + if (!found && db->match_set[i].ref <= 0) { + found = 1; + idx.ids = i; + } + + if (db->match_set[i].ref > 0 && + hw_db_inline_match_set_compare(data, &db->match_set[i].data)) { + idx.ids = i; + hw_db_inline_match_set_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + found = 0; + + for (uint32_t i = 0; i < db->nb_cat; ++i) { + if (flm_rcp->match_set[i].ref <= 0) { + found = 1; + flm_rcp->match_set[i].ref = 1; + flm_rcp->match_set[i].idx.raw = idx.raw; + break; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&db->match_set[idx.ids].data, data, sizeof(struct hw_db_inline_match_set_data)); + db->match_set[idx.ids].ref = 1; + db->match_set[idx.ids].set_priority = ++db->set_priority_counter; + + hw_db_inline_update_active_filters(ndev, db, data->jump); + + return idx; +} + +void hw_db_inline_match_set_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_match_set_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->match_set[idx.ids].ref += 1; +} + +void hw_db_inline_match_set_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_match_set_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp; + int jump; + + if (idx.error) + return; + + db->match_set[idx.ids].ref -= 1; + + if (db->match_set[idx.ids].ref > 0) + return; + + jump = db->match_set[idx.ids].data.jump; + flm_rcp = &db->flm[jump]; + + for (uint32_t i = 0; i < db->nb_cat; ++i) { + if (flm_rcp->match_set[i].idx.raw == idx.raw) { + flm_rcp->match_set[i].ref = 0; + hw_db_inline_update_active_filters(ndev, db, jump); + memset(&flm_rcp->match_set[i], 0x0, + sizeof(struct hw_db_inline_resource_db_flm_match_set)); + } + } + + memset(&db->match_set[idx.ids].data, 0x0, sizeof(struct hw_db_inline_match_set_data)); + db->match_set[idx.ids].ref = 0; +} + +/******************************************************************************/ +/* Action set */ +/******************************************************************************/ + +static int hw_db_inline_action_set_compare(const struct hw_db_inline_action_set_data *data1, + const struct hw_db_inline_action_set_data *data2) +{ + if (data1->contains_jump) + return data2->contains_jump && data1->jump == data2->jump; + + return data1->cot.raw == data2->cot.raw && data1->qsl.raw == data2->qsl.raw && + data1->slc_lr.raw == data2->slc_lr.raw && data1->tpe.raw == data2->tpe.raw && + data1->hsh.raw == data2->hsh.raw; +} + +struct hw_db_action_set_idx +hw_db_inline_action_set_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_action_set_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_action_set_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_ACTION_SET; + + for (uint32_t i = 0; i < HW_DB_INLINE_ACTION_SET_NB; ++i) { + if (!found && db->action_set[i].ref <= 0) { + found = 1; + idx.ids = i; + } + + if (db->action_set[i].ref > 0 && + hw_db_inline_action_set_compare(data, &db->action_set[i].data)) { + idx.ids = i; + hw_db_inline_action_set_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&db->action_set[idx.ids].data, data, sizeof(struct hw_db_inline_action_set_data)); + db->action_set[idx.ids].ref = 1; + + return idx; +} + +void hw_db_inline_action_set_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_action_set_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->action_set[idx.ids].ref += 1; +} + +void hw_db_inline_action_set_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_action_set_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->action_set[idx.ids].ref -= 1; + + if (db->action_set[idx.ids].ref <= 0) { + memset(&db->action_set[idx.ids].data, 0x0, + sizeof(struct hw_db_inline_action_set_data)); + db->action_set[idx.ids].ref = 0; + } +} + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -1593,6 +2383,8 @@ struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void flm_rcp->ft[idx.id1].idx.raw = idx.raw; flm_rcp->ft[idx.id1].ref = 1; + hw_db_inline_update_active_filters(ndev, db, data->jump); + return idx; } @@ -1647,6 +2439,8 @@ struct hw_db_flm_ft hw_db_inline_flm_ft_add(struct flow_nic_dev *ndev, void *db_ flm_rcp->ft[idx.id1].idx.raw = idx.raw; flm_rcp->ft[idx.id1].ref = 1; + hw_db_inline_update_active_filters(ndev, db, data->group); + return idx; } @@ -1677,6 +2471,7 @@ void hw_db_inline_flm_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struc return; flm_rcp->ft[idx.id1].ref = 0; + hw_db_inline_update_active_filters(ndev, db, idx.id2); memset(&flm_rcp->ft[idx.id1], 0x0, sizeof(struct hw_db_inline_resource_db_flm_ft)); } diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 9820225ffa..33de674b72 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -131,6 +131,10 @@ struct hw_db_hsh_idx { enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, + + HW_DB_IDX_TYPE_MATCH_SET, + HW_DB_IDX_TYPE_ACTION_SET, + HW_DB_IDX_TYPE_COT, HW_DB_IDX_TYPE_CAT, HW_DB_IDX_TYPE_QSL, @@ -145,6 +149,17 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_HSH, }; +/* Container types */ +struct hw_db_inline_match_set_data { + struct hw_db_cat_idx cat; + struct hw_db_km_idx km; + struct hw_db_km_ft km_ft; + struct hw_db_action_set_idx action_set; + int jump; + + uint8_t priority; +}; + /* Functionality data types */ struct hw_db_inline_cat_data { uint32_t vlan_mask : 4; @@ -224,6 +239,7 @@ struct hw_db_inline_action_set_data { struct { struct hw_db_cot_idx cot; struct hw_db_qsl_idx qsl; + struct hw_db_slc_lr_idx slc_lr; struct hw_db_tpe_idx tpe; struct hw_db_hsh_idx hsh; }; @@ -262,6 +278,25 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); /**/ + +struct hw_db_match_set_idx +hw_db_inline_match_set_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_match_set_data *data); +void hw_db_inline_match_set_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_match_set_idx idx); +void hw_db_inline_match_set_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_match_set_idx idx); + +struct hw_db_action_set_idx +hw_db_inline_action_set_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_action_set_data *data); +void hw_db_inline_action_set_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_action_set_idx idx); +void hw_db_inline_action_set_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_action_set_idx idx); + +/**/ + struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_cot_data *data); void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); 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 6ad9f53954..2afc7447d4 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 @@ -2677,10 +2677,30 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, return -1; } + /* Setup Action Set */ + struct hw_db_inline_action_set_data action_set_data = { + .contains_jump = 0, + .cot = cot_idx, + .qsl = qsl_idx, + .slc_lr = slc_lr_idx, + .tpe = tpe_idx, + .hsh = hsh_idx, + }; + struct hw_db_action_set_idx action_set_idx = + hw_db_inline_action_set_add(dev->ndev, dev->ndev->hw_db_handle, &action_set_data); + local_idxs[(*local_idx_counter)++] = action_set_idx.raw; + + if (action_set_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference Action Set resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + /* Setup FLM FT */ struct hw_db_inline_flm_ft_data flm_ft_data = { .is_group_zero = 0, .group = group, + .action_set = action_set_idx, }; struct hw_db_flm_ft flm_ft_idx = empty_pattern ? hw_db_inline_flm_ft_default(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data) @@ -2867,6 +2887,18 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n } } + struct hw_db_action_set_idx action_set_idx = + hw_db_inline_action_set_add(dev->ndev, dev->ndev->hw_db_handle, + &action_set_data); + + fh->db_idxs[fh->db_idx_counter++] = action_set_idx.raw; + + if (action_set_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference Action Set resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + /* Setup CAT */ struct hw_db_inline_cat_data cat_data = { .vlan_mask = (0xf << fd->vlans) & 0xf, @@ -2986,6 +3018,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n struct hw_db_inline_km_ft_data km_ft_data = { .cat = cat_idx, .km = km_idx, + .action_set = action_set_idx, }; struct hw_db_km_ft km_ft_idx = hw_db_inline_km_ft_add(dev->ndev, dev->ndev->hw_db_handle, &km_ft_data); @@ -3022,10 +3055,32 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n km_write_data_match_entry(&fd->km, 0); } + /* Setup Match Set */ + struct hw_db_inline_match_set_data match_set_data = { + .cat = cat_idx, + .km = km_idx, + .km_ft = km_ft_idx, + .action_set = action_set_idx, + .jump = fd->jump_to_group != UINT32_MAX ? fd->jump_to_group : 0, + .priority = attr->priority & 0xff, + }; + struct hw_db_match_set_idx match_set_idx = + hw_db_inline_match_set_add(dev->ndev, dev->ndev->hw_db_handle, + &match_set_data); + fh->db_idxs[fh->db_idx_counter++] = match_set_idx.raw; + + if (match_set_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference Match Set resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + /* Setup FLM FT */ struct hw_db_inline_flm_ft_data flm_ft_data = { .is_group_zero = 1, .jump = fd->jump_to_group != UINT32_MAX ? fd->jump_to_group : 0, + .action_set = action_set_idx, + }; struct hw_db_flm_ft flm_ft_idx = hw_db_inline_flm_ft_add(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data); From patchwork Tue Oct 29 16:41:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147644 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9850A45BC0; Tue, 29 Oct 2024 17:48:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31E1842FE3; Tue, 29 Oct 2024 17:44:28 +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 C933042F0B for ; Tue, 29 Oct 2024 17:43:36 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) 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:43:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rja0Oss8QlCkeUkrqk6miSKq2Up0+hKKsnghwN3CCM3zjK6a5Th9CdWwNEzvHS+1p9FcrHdWaJB0S6EdxOUQE5tpIXTTeWQyBLv0tfb5BTd4MWZHtPh4i452Um97o+qHAIW1XkY3GB0zbXvfyFOoFXhBTO2g1pRLtOLNp11Hsyvi4b2lwm2wSmSNIwq0EFsgc6hRXeOeOT5QIkV3wqqXA/xgU8+aTCG/L2zINwtIouvn/tUVBvFOATdx6q1fO+EjL44vbVeaX4Tc7nklseBKRLfZjmcTT5j5IPqZlSN66muS3zmqqeZbcowoo3nrbbWqVp3scWOm0NySBJgzLVHnOw== 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=5lHSS1bxv7C5lfy3vJh0MtCdcrw1CfKIBjzVFLaPBCs=; b=h/xMQoh2GEEMvkm4nUEmD9vcFFx14PfdrDPH0sL+2quzFJn18cMhh/VfruDBV5nyojsD4WAD7ollKtlftctmRLfcikujxrCiDyLbHgBcX1j2Ym72bMuYkoamYOXdT1avsOxzNR9IiOsD9VJ8vMHttsnGMTzYLTGbNVDNLbZY/iA+ji2rBjC/ubZf4YQp3ICxxtYIyAIY1rUA3xMdaWAqQT9RzLfcdX6PaBh/jLk7GiJCaexk///7u4rZ/ukJV4YK5py9lf+jix5lZRX1W+Vg5Nk4LXfyubWU6dNIa9kf+MEDxP0py8kk4lPk7t1lR10zULBWRKICGmyPCv5Q/nSnXA== 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=5lHSS1bxv7C5lfy3vJh0MtCdcrw1CfKIBjzVFLaPBCs=; b=GHgV87jnIn/lKGgpAHDLqgJsF8xGlTp/aDK2tw8yIwtik5DNY+ttSKh+wSvQks2RrsdBhHOtIgvQ/8/f01VV0I2zJ0rJL/6fp8h3nHDoo7WYfPtM/6Yo5Sxr5eOTKvU/8FHKUdb7AX2pt2KSbI/Kb+0i3hjB6pijYHNNVpiqrXU= Received: from DUZPR01CA0189.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::7) by AS8P190MB1936.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:521::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:29 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::6b) by DUZPR01CA0189.outlook.office365.com (2603:10a6:10:4b6::7) 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:43:29 +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:43:28 +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, Oleksandr Kolomeiets Subject: [PATCH v4 37/86] net/ntnic: add flow dump feature Date: Tue, 29 Oct 2024 17:41:41 +0100 Message-ID: <20241029164243.1648775-38-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS8P190MB1936:EE_ X-MS-Office365-Filtering-Correlation-Id: aee81c6a-7cc9-493f-13c5-08dcf838d143 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: PdX1YRqfURCvhy/IRjcwiSd1izGWSI4vT62mpTkTc8w72Q0/Mc56NS45HUWndkpxVtni2GO6LZ3SOGFZ+3npv+83CvYNACW5HLm0VgcYb1eoalM9t74mR5lBZG99yetAM3CoYVh5Ht9S0O/tMuBTH1Tt3lJ1BdrTZkqaiP3prp6lWlaVhAWszngbg4WYtrdVOFUC3tjXAZLNvtXNV8dF5zbLboe6GKTcA1i/u9kxDO/dn8Bo3S6Ao1cxCg1z59XFPX7e+QYmcZ3268TNzsPmM/gU28FkBG0I9IE0ST3lMcR2czey4oMFUnKjH0/MxCKvTK15sieMXu+hGT6oOuQjFTD461qH7eOS5FvHNSwvphKVMfic+0SWsJhUnBSgGRgzDCLJ7j9f2F03proXz9iC58iJlh4UkKwXSP9g5hXjIIGgY7q84LVz0Vv4KnV1Ld991JP05g3RKgppYENOyarEaT2etNehW3/YYy1cctxBky5ZGj8S0/PeRHrkdcHrau252tEOVgX9yp/2ajIK/z0cm6UdGQTs4zFLdKRMHefTHU+XK8uxAKA5YaTZv33wcT3q4Vcy8HucL2AGuZaovOfAyypwv5e+UywvrfhLF6Au+0WRApMy7fhRBrDWakP1ebBBHchazOFLUYnsDdY+NZw025j4b9rOGJ/yY6O6NJhKACy3HHzY/Lw5neyajvBseZtzA7XGojYxI7QrPrsCVDt0D5fvJveXzbz8tVqQ/PWiKGw1XDLQkvhM/X6ZVXE19rE/WDdezDdYrS0lhKHO3wdO+ZTSJRryt4+ZgTnuCoaGn1Jji2opFE9JGXcX3KU3Tpp727dX9D3RfL+qRzcgRJ1c4euLKYaZmMwbY9Lysd1Jn9gLps9dvwMZVwZlKAuxjMiICIBP82dDblkpjSra0QhCyFVZ/c1+yx668/mf/SDkd8Zrw89zUOqieac6t8yUTEgBqEAQ92G5rNOjCHm9yt5hDdbintfGJIDH5W04jP4lA7gv1/qZjn+X2XtZ2xEEl3GT7kzjhH3Qk8MdkEakftyfOey/mHiOnAW3nBEQdr6tan7+EI34yV5/x8HkOJTrxoJ0IxY4xlsx2sJL3Y21vWfOr2GPgkh5AXIuiia0y7aYmBUrJW+jPiBG/EAcYpqYFgyrHpSQ7nkkvUM83B3Li1ZfqCppUUOoyyArvSftsME3B+oPs5aJZHvoOxo87fyL3DvoZHpi0D2DR9pPX3MWjRxA1uQY2u/8zGGes+sFksPtvEj8+zE/BrIiRj3psC8iUG5TWLp3b28zy6ZOQNK/YJ/4P9d3GTzpMkSiGAzGo4q3w/cu+Cp+miEEoROc6pAgq8Rxaa2tFRDdzAk2Q7g7uGCeRoSM622rImR4IdfTFwfT7XkMEMSHC25/WnBy+jcBzgq1e7nIoJ5YiiCRXkS5Vb8atQ== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6K/3KoUePn+i0HU2WUhh2fEni9qM2mR1lwBHVDwLZn8xlDnYyIEbNiHGgMPDi4nx9TrBvDnKh/JOP/ygMzl7Ca0eIqrQokvLqZg+7ym4r86mEbbDWo1jR2qmmzO1OiEjN5C+b2JxRRjlcjeK3KBQZ8BrTUA78eyN8V45TRfLss71B3qaphBJGejgsGKcyKygUNMz2z8+2WM6+hmghq/oHyapanuo157n++tBNldid+cB3k092SgGYseEcQJEeGiVabmtFPWf6GITAav47gPNNFDcQ++grBHsEC+TCELc3oEJOZuu/H7KXEypEJt3nRcIGtwUm1NbSGpBhAY7jnrCWWG9n5P4HbT0McGjcXe6JYY2ASjUcibm+ttsu3fpmop3zeI1UgmEdCxTAvejESSEJzE61FtT+dFDwJoz7XBPhwh9XM1PioXBdjUE4YqsMAPiOrjz0TcIsJzbQzLXN+r+txhEy2OiVWmWO/nnUsvHoWS62MwFuHm4pJghxALVwvTYNhDbNcqgHjJEoidqAY3TexqrnJtXCEcQgU81jSXvtwSwzQwpO+Hs+4NywwEKll+qFPVnE9Y57FZuHro23nN2fCqKqdH/aDkbmV7qemc7yti5f3uMgFdI1LT7VS5VIUbUOLv5sxiWRAtsakEZcc7OXNiZMAPrbtYOr/jxjuYC1Ns= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:28.9490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aee81c6a-7cc9-493f-13c5-08dcf838d143 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: AS8P190MB1936 X-BESS-ID: 1730220211-303097-12767-29328-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYW5kamQGYGUDQxLSkxxdLSKM XS1Cw51dLcLMncKNE4zTwp2SDFyMLQQqk2FgCUPqSxQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [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: Oleksandr Kolomeiets Add posibilyty to dump flow in human readable format Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/include/flow_api_engine.h | 2 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 17 ++ .../profile_inline/flow_api_hw_db_inline.c | 264 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 3 + .../profile_inline/flow_api_profile_inline.c | 81 ++++++ .../profile_inline/flow_api_profile_inline.h | 6 + drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 29 ++ drivers/net/ntnic/ntnic_mod_reg.h | 11 + 8 files changed, 413 insertions(+) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index e52363f04e..155a9e1fd6 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -281,6 +281,8 @@ struct flow_handle { struct flow_handle *next; struct flow_handle *prev; + /* Flow specific pointer to application data stored during action creation. */ + void *context; void *user_data; union { diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 043e4244fc..7f1e311988 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1006,6 +1006,22 @@ int flow_nic_set_hasher(struct flow_nic_dev *ndev, int hsh_idx, enum flow_nic_ha return 0; } +static int flow_dev_dump(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return profile_inline_ops->flow_dev_dump_profile_inline(dev, flow, caller_id, file, error); +} + int flow_nic_set_hasher_fields(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf) { @@ -1031,6 +1047,7 @@ static const struct flow_filter_ops ops = { */ .flow_create = flow_create, .flow_destroy = flow_destroy, + .flow_dev_dump = flow_dev_dump, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 52f85b65af..b5fee67e67 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -372,6 +372,270 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct } } +void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, + uint32_t size, FILE *file) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + char str_buffer[4096]; + uint16_t rss_buffer_len = sizeof(str_buffer); + + for (uint32_t i = 0; i < size; ++i) { + switch (idxs[i].type) { + case HW_DB_IDX_TYPE_NONE: + break; + + case HW_DB_IDX_TYPE_MATCH_SET: { + const struct hw_db_inline_match_set_data *data = + &db->match_set[idxs[i].ids].data; + fprintf(file, " MATCH_SET %d, priority %d\n", idxs[i].ids, + (int)data->priority); + fprintf(file, " CAT id %d, KM id %d, KM_FT id %d, ACTION_SET id %d\n", + data->cat.ids, data->km.id1, data->km_ft.id1, + data->action_set.ids); + + if (data->jump) + fprintf(file, " Jumps to %d\n", data->jump); + + break; + } + + case HW_DB_IDX_TYPE_ACTION_SET: { + const struct hw_db_inline_action_set_data *data = + &db->action_set[idxs[i].ids].data; + fprintf(file, " ACTION_SET %d\n", idxs[i].ids); + + if (data->contains_jump) + fprintf(file, " Jumps to %d\n", data->jump); + + else + fprintf(file, + " COT id %d, QSL id %d, SLC_LR id %d, TPE id %d, HSH id %d\n", + data->cot.ids, data->qsl.ids, data->slc_lr.ids, + data->tpe.ids, data->hsh.ids); + + break; + } + + case HW_DB_IDX_TYPE_CAT: { + const struct hw_db_inline_cat_data *data = &db->cat[idxs[i].ids].data; + fprintf(file, " CAT %d\n", idxs[i].ids); + fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x\n", + (int)data->mac_port_mask, (int)data->vlan_mask); + fprintf(file, + " Proto msks: Frag 0x%02x, l2 0x%02x, l3 0x%02x, l4 0x%02x, l3t 0x%02x, l4t 0x%02x\n", + (int)data->ptc_mask_frag, (int)data->ptc_mask_l2, + (int)data->ptc_mask_l3, (int)data->ptc_mask_l4, + (int)data->ptc_mask_l3_tunnel, (int)data->ptc_mask_l4_tunnel); + fprintf(file, " IP protocol: pn %u pnt %u\n", data->ip_prot, + data->ip_prot_tunnel); + break; + } + + case HW_DB_IDX_TYPE_QSL: { + const struct hw_db_inline_qsl_data *data = &db->qsl[idxs[i].ids].data; + fprintf(file, " QSL %d\n", idxs[i].ids); + + if (data->discard) { + fprintf(file, " Discard\n"); + break; + } + + if (data->drop) { + fprintf(file, " Drop\n"); + break; + } + + fprintf(file, " Table size %d\n", data->table_size); + + for (uint32_t i = 0; + i < data->table_size && i < HW_DB_INLINE_MAX_QST_PER_QSL; ++i) { + fprintf(file, " %u: Queue %d, TX port %d\n", i, + (data->table[i].queue_en ? (int)data->table[i].queue : -1), + (data->table[i].tx_port_en ? (int)data->table[i].tx_port + : -1)); + } + + break; + } + + case HW_DB_IDX_TYPE_COT: { + const struct hw_db_inline_cot_data *data = &db->cot[idxs[i].ids].data; + fprintf(file, " COT %d\n", idxs[i].ids); + fprintf(file, " Color contrib %d, frag rcp %d\n", + (int)data->matcher_color_contrib, (int)data->frag_rcp); + break; + } + + case HW_DB_IDX_TYPE_SLC_LR: { + const struct hw_db_inline_slc_lr_data *data = + &db->slc_lr[idxs[i].ids].data; + fprintf(file, " SLC_LR %d\n", idxs[i].ids); + fprintf(file, " Enable %u, dyn %u, ofs %u\n", data->head_slice_en, + data->head_slice_dyn, data->head_slice_ofs); + break; + } + + case HW_DB_IDX_TYPE_TPE: { + const struct hw_db_inline_tpe_data *data = &db->tpe[idxs[i].ids].data; + fprintf(file, " TPE %d\n", idxs[i].ids); + fprintf(file, " Insert len %u, new outer %u, calc eth %u\n", + data->insert_len, data->new_outer, + data->calc_eth_type_from_inner_ip); + fprintf(file, " TTL enable %u, dyn %u, ofs %u\n", data->ttl_en, + data->ttl_dyn, data->ttl_ofs); + fprintf(file, + " Len A enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_a_en, data->len_a_pos_dyn, data->len_a_pos_ofs, + data->len_a_add_dyn, data->len_a_add_ofs, data->len_a_sub_dyn); + fprintf(file, + " Len B enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_b_en, data->len_b_pos_dyn, data->len_b_pos_ofs, + data->len_b_add_dyn, data->len_b_add_ofs, data->len_b_sub_dyn); + fprintf(file, + " Len C enable %u, pos dyn %u, pos ofs %u, add dyn %u, add ofs %u, sub dyn %u\n", + data->len_c_en, data->len_c_pos_dyn, data->len_c_pos_ofs, + data->len_c_add_dyn, data->len_c_add_ofs, data->len_c_sub_dyn); + + for (uint32_t i = 0; i < 6; ++i) + if (data->writer[i].en) + fprintf(file, + " Writer %i: Reader %u, dyn %u, ofs %u, len %u\n", + i, data->writer[i].reader_select, + data->writer[i].dyn, data->writer[i].ofs, + data->writer[i].len); + + break; + } + + case HW_DB_IDX_TYPE_TPE_EXT: { + const struct hw_db_inline_tpe_ext_data *data = + &db->tpe_ext[idxs[i].ids].data; + const int rpl_rpl_length = ((int)data->size + 15) / 16; + fprintf(file, " TPE_EXT %d\n", idxs[i].ids); + fprintf(file, " Encap data, size %u\n", data->size); + + for (int i = 0; i < rpl_rpl_length; ++i) { + fprintf(file, " "); + + for (int n = 15; n >= 0; --n) + fprintf(file, " %02x%s", data->hdr8[i * 16 + n], + n == 8 ? " " : ""); + + fprintf(file, "\n"); + } + + break; + } + + case HW_DB_IDX_TYPE_FLM_RCP: { + const struct hw_db_inline_flm_rcp_data *data = &db->flm[idxs[i].id1].data; + fprintf(file, " FLM_RCP %d\n", idxs[i].id1); + fprintf(file, " QW0 dyn %u, ofs %u, QW4 dyn %u, ofs %u\n", + data->qw0_dyn, data->qw0_ofs, data->qw4_dyn, data->qw4_ofs); + fprintf(file, " SW8 dyn %u, ofs %u, SW9 dyn %u, ofs %u\n", + data->sw8_dyn, data->sw8_ofs, data->sw9_dyn, data->sw9_ofs); + fprintf(file, " Outer prot %u, inner prot %u\n", data->outer_prot, + data->inner_prot); + fprintf(file, " Mask:\n"); + fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[0], + data->mask[1], data->mask[2], data->mask[3], data->mask[4]); + fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[5], + data->mask[6], data->mask[7], data->mask[8], data->mask[9]); + break; + } + + case HW_DB_IDX_TYPE_FLM_FT: { + const struct hw_db_inline_flm_ft_data *data = + &db->flm[idxs[i].id2].ft[idxs[i].id1].data; + fprintf(file, " FLM_FT %d\n", idxs[i].id1); + + if (data->is_group_zero) + fprintf(file, " Jump to %d\n", data->jump); + + else + fprintf(file, " Group %d\n", data->group); + + fprintf(file, " ACTION_SET id %d\n", data->action_set.ids); + break; + } + + case HW_DB_IDX_TYPE_KM_RCP: { + const struct hw_db_inline_km_rcp_data *data = &db->km[idxs[i].id1].data; + fprintf(file, " KM_RCP %d\n", idxs[i].id1); + fprintf(file, " HW id %u\n", data->rcp); + break; + } + + case HW_DB_IDX_TYPE_KM_FT: { + const struct hw_db_inline_km_ft_data *data = + &db->km[idxs[i].id2].ft[idxs[i].id1].data; + fprintf(file, " KM_FT %d\n", idxs[i].id1); + fprintf(file, " ACTION_SET id %d\n", data->action_set.ids); + fprintf(file, " KM_RCP id %d\n", data->km.ids); + fprintf(file, " CAT id %d\n", data->cat.ids); + break; + } + + case HW_DB_IDX_TYPE_HSH: { + const struct hw_db_inline_hsh_data *data = &db->hsh[idxs[i].ids].data; + fprintf(file, " HSH %d\n", idxs[i].ids); + + switch (data->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + fprintf(file, " Func: NTH10\n"); + break; + + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + fprintf(file, " Func: Toeplitz\n"); + fprintf(file, " Key:"); + + for (uint8_t i = 0; i < MAX_RSS_KEY_LEN; i++) { + if (i % 10 == 0) + fprintf(file, "\n "); + + fprintf(file, " %02x", data->key[i]); + } + + fprintf(file, "\n"); + break; + + default: + fprintf(file, " Func: %u\n", data->func); + } + + fprintf(file, " Hash mask hex:\n"); + fprintf(file, " %016lx\n", data->hash_mask); + + /* convert hash mask to human readable RTE_ETH_RSS_* form if possible */ + if (sprint_nt_rss_mask(str_buffer, rss_buffer_len, "\n ", + data->hash_mask) == 0) { + fprintf(file, " Hash mask flags:%s\n", str_buffer); + } + + break; + } + + default: { + fprintf(file, " Unknown item. Type %u\n", idxs[i].type); + break; + } + } + } +} + +void hw_db_inline_dump_cfn(struct flow_nic_dev *ndev, void *db_handle, FILE *file) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + fprintf(file, "CFN status:\n"); + + for (uint32_t id = 0; id < db->nb_cat; ++id) + if (db->cfn[id].cfn_hw) + fprintf(file, " ID %d, HW id %d, priority 0x%" PRIx64 "\n", (int)id, + db->cfn[id].cfn_hw, db->cfn[id].priority); +} const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 33de674b72..a9d31c86ea 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -276,6 +276,9 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct uint32_t size); const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); +void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, + uint32_t size, FILE *file); +void hw_db_inline_dump_cfn(struct flow_nic_dev *ndev, void *db_handle, FILE *file); /**/ 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 2afc7447d4..9727a28d45 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 @@ -4300,6 +4300,86 @@ int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, return res; } +static void dump_flm_data(const uint32_t *data, FILE *file) +{ + for (unsigned int i = 0; i < 10; ++i) { + fprintf(file, "%s%02X %02X %02X %02X%s", i % 2 ? "" : " ", + (data[i] >> 24) & 0xff, (data[i] >> 16) & 0xff, (data[i] >> 8) & 0xff, + data[i] & 0xff, i % 2 ? "\n" : " "); + } +} + +int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error) +{ + flow_nic_set_error(ERR_SUCCESS, error); + + pthread_mutex_lock(&dev->ndev->mtx); + + if (flow != NULL) { + if (flow->type == FLOW_HANDLE_TYPE_FLM) { + fprintf(file, "Port %d, caller %d, flow type FLM\n", (int)dev->port_id, + (int)flow->caller_id); + fprintf(file, " FLM_DATA:\n"); + dump_flm_data(flow->flm_data, file); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter, file); + fprintf(file, " Context: %p\n", flow->context); + + } else { + fprintf(file, "Port %d, caller %d, flow type FLOW\n", (int)dev->port_id, + (int)flow->caller_id); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->db_idxs, flow->db_idx_counter, + file); + } + + } else { + int max_flm_count = 1000; + + hw_db_inline_dump_cfn(dev->ndev, dev->ndev->hw_db_handle, file); + + flow = dev->ndev->flow_base; + + while (flow) { + if (flow->caller_id == caller_id) { + fprintf(file, "Port %d, caller %d, flow type FLOW\n", + (int)dev->port_id, (int)flow->caller_id); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->db_idxs, + flow->db_idx_counter, file); + } + + flow = flow->next; + } + + flow = dev->ndev->flow_base_flm; + + while (flow && max_flm_count >= 0) { + if (flow->caller_id == caller_id) { + fprintf(file, "Port %d, caller %d, flow type FLM\n", + (int)dev->port_id, (int)flow->caller_id); + fprintf(file, " FLM_DATA:\n"); + dump_flm_data(flow->flm_data, file); + hw_db_inline_dump(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)flow->flm_db_idxs, + flow->flm_db_idx_counter, file); + fprintf(file, " Context: %p\n", flow->context); + max_flm_count -= 1; + } + + flow = flow->next; + } + } + + pthread_mutex_unlock(&dev->ndev->mtx); + + return 0; +} static const struct profile_inline_ops ops = { /* @@ -4308,6 +4388,7 @@ static const struct profile_inline_ops ops = { .done_flow_management_of_ndev_profile_inline = done_flow_management_of_ndev_profile_inline, .initialize_flow_management_of_ndev_profile_inline = initialize_flow_management_of_ndev_profile_inline, + .flow_dev_dump_profile_inline = flow_dev_dump_profile_inline, /* * Flow functionality */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index e623bb2352..2c76a2c023 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -38,6 +38,12 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); +int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); + int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 20b5cb2835..67a24a00f1 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -582,9 +582,38 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, return flow; } +static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, + struct rte_flow *flow, + FILE *file, + struct rte_flow_error *error) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG(ERR, NTNIC, "%s: flow_filter module uninitialized", __func__); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + + uint16_t caller_id = get_caller_id(eth_dev->data->port_id); + + int res = flow_filter_ops->flow_dev_dump(internals->flw_dev, + is_flow_handle_typecast(flow) ? (void *)flow + : flow->flw_hdl, + caller_id, file, &flow_error); + + convert_error(error, &flow_error); + return res; +} + static const struct rte_flow_ops dev_flow_ops = { .create = eth_flow_create, .destroy = eth_flow_destroy, + .dev_dump = eth_flow_dev_dump, }; void dev_flow_init(void) diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 27d6cbef01..cef655c5e0 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -253,6 +253,12 @@ struct profile_inline_ops { struct flow_handle *flow, struct rte_flow_error *error); + int (*flow_dev_dump_profile_inline)(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); + int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); @@ -284,6 +290,11 @@ struct flow_filter_ops { int *rss_target_id, enum flow_eth_dev_profile flow_profile, uint32_t exception_path); + int (*flow_dev_dump)(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct rte_flow_error *error); /* * NT Flow API */ From patchwork Tue Oct 29 16:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147643 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9543945BC0; Tue, 29 Oct 2024 17:48:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2561942FCF; Tue, 29 Oct 2024 17:44:27 +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 324C242ECF for ; Tue, 29 Oct 2024 17:43:35 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2106.outbound.protection.outlook.com [104.47.18.106]) 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 16:43:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kc4XgkjKtPdwQYHAkaZ8FpImIg+gekSwfGjiCdpg2nqzWKt029UG2Bf2uknDVz10TEENPNKf1ESWwnGHtJpa7d53ShuG1ul1ozx65AU4QuxN+IBazFRY9a/dKMOCCWVlFkCfH5qOjS4EHcGd1vvE2kE0kjsc+M6nRA+0tBDgjTo8cKbJDm4GKDryZFgYMziV3qM81jyCOk87aSNyCm+d/Ra2TNz6G5u1M3XCt9FyOJeSEj5RQ1jN7PZFfeJg4n3J3yAkgaiDjTGMqbtP3rs0LUFiYRweav6L1wvRZ+O7qThuBhKSdHW5KtwWCJVPu5JeKoNy/3tIMZ9ZPBzpn9Nxsg== 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=iMDWY52y96Pyh8S02wXgqTs7953c7zyRd0z1KwQ8cAw=; b=AXKVbwWHSwCdi1UqbS9yI3h0CesNjEcppM+ME4R676gR1ooATJfbEFs/VHQJNHmAjKcaY+b3fVhQGp6QAB0QSZW0XjHhLsOrE61G/0CvYHm9+kcBlrsCyElDt/0qd20MPObtFbugGfjTBWuVFx0m4Q5pMhSKIKIk1u2q4XEkOAA2+BpShxPNu3CzjSxnXwqnQmWBDA+ybps3NPP4guxTXoeiFaGkExzRjfae4iKv96U3AgnKjDLUAKtFKrButnfaBRMfsH7Ui3AVoPHn6eNKjd4TZPQjvD62pKN5jLsafbQ+MO5tCnRiT6IexlKst/6nk2da1s4p+UayKSHiw03Swg== 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=iMDWY52y96Pyh8S02wXgqTs7953c7zyRd0z1KwQ8cAw=; b=QP1FWPtM9n4LtsyI+Uea55WlzEmYyGFSbdvKIfi1mHU5rCXcTthHLaxYgBuEsVrd7gDLffPbaHGdFJlKKUbNIRqn04G6xaU4e9JdZLtYZk4ZxfrsYQHdPnVaPy1UKcPxH9SWs+LQN5bT0PRV+VWrkws4MSazyrIB7XIevEEzEjQ= Received: from DUZPR01CA0206.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::21) by AS1P190MB1773.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4a9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:30 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::fd) by DUZPR01CA0206.outlook.office365.com (2603:10a6:10:4b6::21) 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:43:30 +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:43:29 +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, Oleksandr Kolomeiets Subject: [PATCH v4 38/86] net/ntnic: add flow flush Date: Tue, 29 Oct 2024 17:41:42 +0100 Message-ID: <20241029164243.1648775-39-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS1P190MB1773:EE_ X-MS-Office365-Filtering-Correlation-Id: 56b955a0-1e17-4378-5c70-08dcf838d1cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: LoVrKx8cqpCgww9hLUSxnnDMohB/KhKJAutWxgxQDQ7NRbDr58qOzCW0WqJqDqSXlPzUfX5EHEsQrjVLzKaol8y1tLQaP/AbTobjLJsfdEiM+vS07y2h1LU9nEksGzcX3TEILDvoqjg29bDpDp1PNPYNDCtC/2kKVFo+WkqFqemBP1itQUpejPvm88bjucBKnW2IhDUi3f3aDqpzxBtTRUBjSOwPW0pS4SFQO3UpSsvYByejG43v/WQvob2fT/SrFb6Lj6ynD+icFuCvK3tQRcHHP+TrIUKZ+uitqi+qyN0/RjMISp23QNHUVnKhtC+2aJTxFRkRPlQ8QcUaCwsN9dQdQVE7Z3GIenJA8tHLc82+ySEWyMwRZqzYub604qAy7NBXVpYnmFudGJGaju+xTZCObA6a/38V6TRLRkgPZmYR81De735eTREzHwYJhuNFEZbS+odviwjzUIitOA2v+BzQEmhfSGaGC5n6JKsyHM34P/g2nRXwQOk0fYOgz7XonU7ncy92qJUyEfvoGb57haaKA7QO8k7999R3lcWerT7Leq/NuQB5DFHXI5SqTjIpER9T2b0YXYWfJavO7cw6FxiVfeQoL/Mff9S0XRFd36izyCgxcz0J2/7zcTEk4du4mO82WT3+211c4Wwvax+Lho7QURF0a9u2lXtvn1DxsV09EY+VGpN49z+s2G5IE8Rpj7s/yora+9+YrfNeGlANw7q42OIwVCUA3VxRzJje5IbVtFLdUUINbj0C6dwSJGFrVT2djhEdwTDbW2XbjZNXpTHUXMEjhEbBukODNG40wLWbkx9xiWwIzhOeWhQcqQ9587dbw6x9yhxgAdqFLnXbaOL5rGEjy09/kBGPDwmwEXI+S4c4uPeCy4sxfV8rL3lGQkuMN2eeWUiOz3ceKzjo3VVOyoft0h6pJLLN9NV27905ps4QyIUUt4kXWYpgaE+wnhfbGbUSVI46UJMFd1FkFae2+am6oa31Ueos4mwQAD/sRx4gv4kaNLZ+ezrtFI8bX2yTtLqEB+v5hma3PCdG11RrV/OWUlyHhUFz5eQq/0eVqWBs9OJU84fDqDiv6PndVv3sLhRFQAoQSX73XiKhExmsu/Smf4LiMZJSpZyZ+SLSkI5zyspvrGkSNnYZDCErtG1Wv+OHOdWKunwyb4Nm8YabvkSpYQyF6+QNsBGWtZ2t3DncjbEa5+k6qT1u2a93k+JztilCSkIQW1dlK/EgkDb1vBKdprka48xQ5OVteqIXzA0ExDcq288SKchdmByawRccrOhsoER7ctSK18q1puD0i6MRD47HVpl+6sdOSrsJ9jBTxoPOP967jK8sIK1YbmJ2b3DF4srlncoyk+jfuMJ2bZ3hkwkleqyMcaS4y8eCNEYmaVKyysDk0EcqxcM2p254PaxWBMnCdpZjP1UfXQ== 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6HaeXAgY0AVXlokCXp9smMbG0LJIElscw1B+uMGrO12Rb76j6xFeVfAqSy9tJCen1jpzOYbe/tB+4J6o1AsD1LAmHuRfJ1v1UCWfBpqSTUOmGh8OFF62Ii3VMW0PVBfiGsBjCoZ4zuGlX9Gb4b54hvO1dlBcwWZMrj7wwVo93HshGsSfDy4cacNHGecyJyCNib9vaoQLUyXTyzIKwdWpj3gxy9HF0PNFlho0rQD90PtqtsHz8brIjSQOaRNhDrCkcSjtsZf+dQSvsfJ5h3HPSZudEJ+jJLBb4jc9IZhq9Sxl+/bqUcwya4svHngYhCOZBQbYUMZmKYlw1VeMOgthX/oGzeOtg2meG6bGJ2jpEMXgXnLte5C6Chcq1XmYv6iSGSZorx+9JFQ6dA8Fm+Vv+yh7JmpJ346UZpIzanpuyv+imwIpo1L4CoZLCXbsDSo06sD0rf3r3HIZx0JIgISqN2o6l9hbASdSp60Um8XzfZoIspr7rUcpUiTF4GFZ+65E5ohGeJA8Aq36toNdP8TW8AWN1lUKxEJqW0dBzbBk1ZHEoxIpbe5x8EnCQIcXDezt/Kay1NH42dmY0XcdQpdhFg2sxB7JEachClNAUU5VovZ8Hqg9KXX62dckPv0RwJAP0MzISpxrLD3kbSQ+pwWTg/LY3zPP/osLHEUEHvj+WO0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:29.8552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56b955a0-1e17-4378-5c70-08dcf838d1cd 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: AS1P190MB1773 X-BESS-ID: 1730220212-304438-12710-30041-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaWliZAVgZQMMnUMtXELNnYwM AiNckszcTCMjnNOC3N0MDM3CI1zchMqTYWAGLc1q1BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan11-75.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: Oleksandr Kolomeiets Implements flow flush API Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 13 ++++++ .../profile_inline/flow_api_profile_inline.c | 43 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.h | 4 ++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 38 ++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 +++ 5 files changed, 105 insertions(+) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 7f1e311988..34f2cad2cd 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -253,6 +253,18 @@ static int flow_destroy(struct flow_eth_dev *dev __rte_unused, return profile_inline_ops->flow_destroy_profile_inline(dev, flow, error); } +static int flow_flush(struct flow_eth_dev *dev, uint16_t caller_id, struct rte_flow_error *error) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "profile_inline module uninitialized"); + return -1; + } + + return profile_inline_ops->flow_flush_profile_inline(dev, caller_id, error); +} + /* * Device Management API */ @@ -1047,6 +1059,7 @@ static const struct flow_filter_ops ops = { */ .flow_create = flow_create, .flow_destroy = flow_destroy, + .flow_flush = flow_flush, .flow_dev_dump = flow_dev_dump, }; 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 9727a28d45..af07819a0c 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 @@ -3635,6 +3635,48 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *fl return err; } +int flow_flush_profile_inline(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error) +{ + int err = 0; + + flow_nic_set_error(ERR_SUCCESS, error); + + /* + * Delete all created FLM flows from this eth device. + * FLM flows must be deleted first because normal flows are their parents. + */ + struct flow_handle *flow = dev->ndev->flow_base_flm; + + while (flow && !err) { + if (flow->dev == dev && flow->caller_id == caller_id) { + struct flow_handle *flow_next = flow->next; + err = flow_destroy_profile_inline(dev, flow, error); + flow = flow_next; + + } else { + flow = flow->next; + } + } + + /* Delete all created flows from this eth device */ + flow = dev->ndev->flow_base; + + while (flow && !err) { + if (flow->dev == dev && flow->caller_id == caller_id) { + struct flow_handle *flow_next = flow->next; + err = flow_destroy_profile_inline(dev, flow, error); + flow = flow_next; + + } else { + flow = flow->next; + } + } + + return err; +} + static __rte_always_inline bool all_bits_enabled(uint64_t hash_mask, uint64_t hash_bits) { return (hash_mask & hash_bits) == hash_bits; @@ -4395,6 +4437,7 @@ static const struct profile_inline_ops ops = { .flow_destroy_locked_profile_inline = flow_destroy_locked_profile_inline, .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_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, /* * NT Flow FLM Meter API diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index 2c76a2c023..c695842077 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -38,6 +38,10 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); +int flow_flush_profile_inline(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error); + int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, uint16_t caller_id, diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 67a24a00f1..93d89d59f3 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -582,6 +582,43 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, return flow; } +static int eth_flow_flush(struct rte_eth_dev *eth_dev, struct rte_flow_error *error) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + int res = 0; + /* Main application caller_id is port_id shifted above VDPA ports */ + uint16_t caller_id = get_caller_id(eth_dev->data->port_id); + + if (internals->flw_dev) { + res = flow_filter_ops->flow_flush(internals->flw_dev, caller_id, &flow_error); + rte_spinlock_lock(&flow_lock); + + for (int flow = 0; flow < MAX_RTE_FLOWS; flow++) { + if (nt_flows[flow].used && nt_flows[flow].caller_id == caller_id) { + /* Cleanup recorded flows */ + nt_flows[flow].used = 0; + nt_flows[flow].caller_id = 0; + } + } + + rte_spinlock_unlock(&flow_lock); + } + + convert_error(error, &flow_error); + + return res; +} + static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FILE *file, @@ -613,6 +650,7 @@ static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, static const struct rte_flow_ops dev_flow_ops = { .create = eth_flow_create, .destroy = eth_flow_destroy, + .flush = eth_flow_flush, .dev_dump = eth_flow_dev_dump, }; diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index cef655c5e0..12baa13800 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -253,6 +253,10 @@ struct profile_inline_ops { struct flow_handle *flow, struct rte_flow_error *error); + int (*flow_flush_profile_inline)(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error); + int (*flow_dev_dump_profile_inline)(struct flow_eth_dev *dev, struct flow_handle *flow, uint16_t caller_id, @@ -309,6 +313,9 @@ struct flow_filter_ops { int (*flow_destroy)(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); + + int (*flow_flush)(struct flow_eth_dev *dev, uint16_t caller_id, + struct rte_flow_error *error); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); From patchwork Tue Oct 29 16:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147646 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E098E45BC0; Tue, 29 Oct 2024 17:48:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68F1142FEF; Tue, 29 Oct 2024 17:44:30 +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 8CF0B42F29 for ; Tue, 29 Oct 2024 17:43:37 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) 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 16:43:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AOxAGgpn5DjbOzzmVu1aXUzuAlaEgtito4fQBOd9ox0M+TNMb/k40hXBn1wL6lM7a25V51dbDAVlGRnLczUkcVUazS2FBqZ22Vwj07sSMzH57GQfGJMtHvNANkG0oNeKyHWRRfa5c1pmfXc2w5H6UCpeDkZiyRwoZSlpSwaV90w2mvo2QHAA3On6RPmhMYndYBC0QHSbfVWQ7MYoGd5HLAPDySoci6t3SwoJnZZ3A2rQ12KZ4SffiWSOK8ijZu8dXuXe/7w5EF97+jKH/36yEh+Psu8wgrCI6cjmIt5EvVlpWo/9HGNBV2dGa2sO+6Vfbl9eo0CrTJ6sALHsntyiBA== 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=v6vIxbABequO1PYH1M/bwB7UCd/excfHnGZZ9mLs5XM=; b=QSDfXFrcpRCQm+08XdJhMGxRY9cYyo/6Qj3ZNr7sEfzKrnVnDjTgHrv3mfHXj0HOi+qgxov+i386w/houl0hujfuo2AagbN+oo9Jeo9FJ0LCADWKB+lUiTyuqpHKvEDrvVmzfirB+GSlc5WglWPw7k4H33bbGB0UBu+lUtfJ4T2s0OAto4dVu4hXcRAsa/8V5e5ERvFTOA7eIbXDr3S8k/S2GCqci1KZym6sIbdTUM5mIL27TywpMH62KiKg/4MdbwciVvH7nstY+TiqJpAoTMlYgxKE+Xxs6utxYvjDTHQHL4V/62NaFd6KRzIAHYcvWyJET3qlp7BONmNbm0/Hwg== 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=v6vIxbABequO1PYH1M/bwB7UCd/excfHnGZZ9mLs5XM=; b=L5khdWyw1yxtdQ6ufSKccKYMO3mipVYl7er8QVUImXHnh4GcR1tVKW03n8t6YZ9wPAoKOQqXSMoIwN/2VDzRz4NpRIpddK09UfEQElZRrF9jPKaeWyNhrd5LCwTln+VENnjt4OzpRpKhaqX4zhL7niyGDdDiwfM3cVzRH71pdBA= Received: from DUZPR01CA0192.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::15) by VI1P190MB0656.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:12b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:31 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::27) by DUZPR01CA0192.outlook.office365.com (2603:10a6:10:4b6::15) 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:43:30 +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:43:30 +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 39/86] net/ntnic: add GMF (Generic MAC Feeder) module Date: Tue, 29 Oct 2024 17:41:43 +0100 Message-ID: <20241029164243.1648775-40-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI1P190MB0656:EE_ X-MS-Office365-Filtering-Correlation-Id: 34b046ab-3711-4b6b-b8db-08dcf838d24b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: MInByfN7U2oePEY44KiGBoiV58RlVPKELLsgujIBs0O7eo+zqQUzx/eIY2lgTvdAXw9Wz0x+bMDcfK9t8IGxg9zgEadzhXLwj+Pm5eBmwb+fFQYrOyx7HuG9895cWRqgaL8GX8cAbgJyxtrpp4aBOGkCa+gwtdZwdSxBAdAt9/akNvXPomAbkQo32mLdc6sXOGFacivfXQ6jd0a1hWhX7R7gZuS+ZRb8dHxLjLw2LQs8hDxTDJZTLfijEQCrCbutLpu3WEEABHD3GEWqCqwHxR9vocgT0wPmjkKJjJwGiSPWjhX2+1kwU8l5eaWQiwEBfaCZNV4DJHquYO5jXbH4WuvOoQDOom3ECnhDmDuyeOT3CtVjk1iT+6v4sbOudd20ZEK0oHVGjprgoKqLWSMqDciWnv8LNq0bOsNuaBjqvnPw4+7szKLlgmB9d2pvLV6yFqiCfsPmF5BnAzhltlDyKapsuJifDGrhbd2p5P/Y4+8MnUCPz1ywXStJYCayu2LBJcl6kF3qSFebOvJ9F15lPvd9s8iFxqEoQGXLDxSY6B6UZ6Ol7a6dkJ0Nt0lrjLzmoSSg/excldB6e2zKQe+J8wrunnfySKvS21Hx+R7rOAGcb0ayEWyBT33qvTB8BMYTDpGARUZ5hRDC+fg9dOr9zgtBOO0iclbXZU/+fC619lpsEuGe/CXikuKhKZgScXDhsJm4LxIVyInLs4FjPwK5FEhG7oAAiRp1jAFiF8VOGbQj2/gzUHNvoJAvVIYlNn0XXADF52R1/vqTD4CGjOidTMRpaR42Q8/n/zEL0sJhoZXp9Rm8jVipfq0agm5ZjDB51OLFonhNlxAw6g+8RyAVGLq6J0rjaXAjNWQNZTzaHHUB8nQ1TpUD7iApI+KYkcwv50cafsnnDv3XOeZq0Gfky8YKffNzCurYIZNi7NuDOUxpKkQgwZaOSzCnpjr8jpMM6QxnnZpBViMYsdFgQ4ouMlDJGpN6ZHArUZUJnQ2+l6kQxC0FcgJAsVCEKuNpCVtLqt/yrC2bRs2ohFLUEaSB2L03nQ2j2XF8fqb7pDr2vJQ+F965eIjUhyWAyFyGDNAbTM6LZf869hvtkycudf5bodA8B+xuH989kzX0QfN+HfW/0wb3e5RjaNaQzG5pavC7bBcU9KMm2X5x+opVN3lThz1bo/iNdEhoE8Epay2cD+LS9gNFEyJKd54GWoOT3CqXFFS9SGWTlX28T/iqKaQ8D5HA9R/AmCdO3k7T9DXiOlee6cliymJFWqbcBW67TzrVFeYb491MZhRRMw6+cMGHPRFfFY7fvQ3nQgJ4J+toOLRhi9VwULxKYx64vu2CN+cPsLfHaW0k8iekNVgG7spbScbYCm5EUWqGnElzwYIzN6Em6oOp4CrcyHU+xHSxgff5uY1vwMmDre31rqm85VjMuQ== 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)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Y+fJT1xB+ORX6cz2bR0vx0iRIb8Ef25+m2gwEdWkeqbH0qX4XzewwNZNaSciust+yktW0Uo1yA29BKNd4DqdpCSdnH2fCK6CbdgJpRj0uih7TJOEmX4j+z9SNw4Z5QRazry0Kp09SSz4p7XVbfQdofYlqRrSYxrUzxpBQ6tmPNrodRS3pghNze1Ku8mAu1Pgd5BziSt3ZeS/cPF8v9oKfYgkRzv1Snhw0MJbAXQS6+SSoVG0NzMVkK4cxMNEO/d/9HqR7mXQSVvfBbL7Sddti4cHs2h+BIhfdiZ+uWvrs5Hi6/sQJAUVrZ4aiglpPNrBDVJ+qRfVMMXgVdg1DvQfe1WaULl9ZuELk6VS6EpC5iTCHMWJQBlTQe3NysHnZTVZoSbes9+5JsI9f20QOKzCDjYp11UsesixrpAPwM6Opuot4BHHJaJuIuK9twQivBOUXpIyHPEeZgcHmYBunUfsd3+aBqNn1K8wS/dL9Db90mGMw1oIvBL5BP2DZ9mRkDl0BmkmaRmihOkQgNCcavQ4ET79siQO7Qa8uyxgUOVtYo71KFubuP2fHECnSDF0Z7lF40xA3yPKSI164wSbFCoA4uYIxkYQmj31w26qDtzYHSrUD6OTTR3Hh2xKL1JmoEqUbulfCVNxI/SOTJIZrvkdowWCQsTYWXFWTFtw/URpnUY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:30.7146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34b046ab-3711-4b6b-b8db-08dcf838d24b 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: VI1P190MB0656 X-BESS-ID: 1730220214-304438-12706-30044-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpaGBgZAVgZQ0MLIyDjFIinFMj XNMC0l0dDMMC3JwMgw1dLCNNHcItlQqTYWANtTvf9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan10-180.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 The Generic MAC Feeder module provides a way to feed data to the MAC modules directly from the FPGA, rather than from host or physical ports. The use case for this is as a test tool and is not used by NTNIC. This module is requireqd for correct initialization Signed-off-by: Serhii Iliushyk --- .../link_mgmt/link_100g/nt4ga_link_100g.c | 8 ++ drivers/net/ntnic/meson.build | 1 + .../net/ntnic/nthw/core/include/nthw_core.h | 1 + .../net/ntnic/nthw/core/include/nthw_gmf.h | 64 +++++++++ drivers/net/ntnic/nthw/core/nthw_gmf.c | 133 ++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_gmf.h create mode 100644 drivers/net/ntnic/nthw/core/nthw_gmf.c diff --git a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c index 8964458b47..d8e0cad7cd 100644 --- a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c +++ b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c @@ -404,6 +404,14 @@ static int _port_init(adapter_info_t *drv, nthw_fpga_t *fpga, int port) _enable_tx(drv, mac_pcs); _reset_rx(drv, mac_pcs); + /* 2.2) Nt4gaPort::setup() */ + if (nthw_gmf_init(NULL, fpga, port) == 0) { + nthw_gmf_t gmf; + + if (nthw_gmf_init(&gmf, fpga, port) == 0) + nthw_gmf_set_enable(&gmf, true); + } + /* Phase 3. Link state machine steps */ /* 3.1) Create NIM, ::createNim() */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index d7e6d05556..92167d24e4 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -38,6 +38,7 @@ sources = files( 'nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c', 'nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c', 'nthw/core/nthw_fpga.c', + 'nthw/core/nthw_gmf.c', 'nthw/core/nthw_gpio_phy.c', 'nthw/core/nthw_hif.c', 'nthw/core/nthw_i2cm.c', diff --git a/drivers/net/ntnic/nthw/core/include/nthw_core.h b/drivers/net/ntnic/nthw/core/include/nthw_core.h index fe32891712..4073f9632c 100644 --- a/drivers/net/ntnic/nthw/core/include/nthw_core.h +++ b/drivers/net/ntnic/nthw/core/include/nthw_core.h @@ -17,6 +17,7 @@ #include "nthw_iic.h" #include "nthw_i2cm.h" +#include "nthw_gmf.h" #include "nthw_gpio_phy.h" #include "nthw_mac_pcs.h" #include "nthw_sdc.h" diff --git a/drivers/net/ntnic/nthw/core/include/nthw_gmf.h b/drivers/net/ntnic/nthw/core/include/nthw_gmf.h new file mode 100644 index 0000000000..cc5be85154 --- /dev/null +++ b/drivers/net/ntnic/nthw/core/include/nthw_gmf.h @@ -0,0 +1,64 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef __NTHW_GMF_H__ +#define __NTHW_GMF_H__ + +struct nthw_gmf { + nthw_fpga_t *mp_fpga; + nthw_module_t *mp_mod_gmf; + int mn_instance; + + nthw_register_t *mp_ctrl; + nthw_field_t *mp_ctrl_enable; + nthw_field_t *mp_ctrl_ifg_enable; + nthw_field_t *mp_ctrl_ifg_tx_now_always; + nthw_field_t *mp_ctrl_ifg_tx_on_ts_always; + nthw_field_t *mp_ctrl_ifg_tx_on_ts_adjust_on_set_clock; + nthw_field_t *mp_ctrl_ifg_auto_adjust_enable; + nthw_field_t *mp_ctrl_ts_inject_always; + nthw_field_t *mp_ctrl_fcs_always; + + nthw_register_t *mp_speed; + nthw_field_t *mp_speed_ifg_speed; + + nthw_register_t *mp_ifg_clock_delta; + nthw_field_t *mp_ifg_clock_delta_delta; + + nthw_register_t *mp_ifg_clock_delta_adjust; + nthw_field_t *mp_ifg_clock_delta_adjust_delta; + + nthw_register_t *mp_ifg_max_adjust_slack; + nthw_field_t *mp_ifg_max_adjust_slack_slack; + + nthw_register_t *mp_debug_lane_marker; + nthw_field_t *mp_debug_lane_marker_compensation; + + nthw_register_t *mp_stat_sticky; + nthw_field_t *mp_stat_sticky_data_underflowed; + nthw_field_t *mp_stat_sticky_ifg_adjusted; + + nthw_register_t *mp_stat_next_pkt; + nthw_field_t *mp_stat_next_pkt_ns; + + nthw_register_t *mp_stat_max_delayed_pkt; + nthw_field_t *mp_stat_max_delayed_pkt_ns; + + nthw_register_t *mp_ts_inject; + nthw_field_t *mp_ts_inject_offset; + nthw_field_t *mp_ts_inject_pos; + int mn_param_gmf_ifg_speed_mul; + int mn_param_gmf_ifg_speed_div; + + bool m_administrative_block; /* Used to enforce license expiry */ +}; + +typedef struct nthw_gmf nthw_gmf_t; + +int nthw_gmf_init(nthw_gmf_t *p, nthw_fpga_t *p_fpga, int n_instance); + +void nthw_gmf_set_enable(nthw_gmf_t *p, bool enable); + +#endif /* __NTHW_GMF_H__ */ diff --git a/drivers/net/ntnic/nthw/core/nthw_gmf.c b/drivers/net/ntnic/nthw/core/nthw_gmf.c new file mode 100644 index 0000000000..16a4c288bd --- /dev/null +++ b/drivers/net/ntnic/nthw/core/nthw_gmf.c @@ -0,0 +1,133 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include +#include "ntlog.h" + +#include "nthw_drv.h" +#include "nthw_register.h" + +#include "nthw_gmf.h" + +int nthw_gmf_init(nthw_gmf_t *p, nthw_fpga_t *p_fpga, int n_instance) +{ + nthw_module_t *mod = nthw_fpga_query_module(p_fpga, MOD_GMF, n_instance); + + if (p == NULL) + return mod == NULL ? -1 : 0; + + if (mod == NULL) { + NT_LOG(ERR, NTHW, "%s: GMF %d: no such instance", + p_fpga->p_fpga_info->mp_adapter_id_str, n_instance); + return -1; + } + + p->mp_fpga = p_fpga; + p->mn_instance = n_instance; + p->mp_mod_gmf = mod; + + p->mp_ctrl = nthw_module_get_register(p->mp_mod_gmf, GMF_CTRL); + p->mp_ctrl_enable = nthw_register_get_field(p->mp_ctrl, GMF_CTRL_ENABLE); + p->mp_ctrl_ifg_enable = nthw_register_get_field(p->mp_ctrl, GMF_CTRL_IFG_ENABLE); + p->mp_ctrl_ifg_auto_adjust_enable = + nthw_register_get_field(p->mp_ctrl, GMF_CTRL_IFG_AUTO_ADJUST_ENABLE); + p->mp_ctrl_ts_inject_always = + nthw_register_query_field(p->mp_ctrl, GMF_CTRL_TS_INJECT_ALWAYS); + p->mp_ctrl_fcs_always = nthw_register_query_field(p->mp_ctrl, GMF_CTRL_FCS_ALWAYS); + + p->mp_speed = nthw_module_get_register(p->mp_mod_gmf, GMF_SPEED); + p->mp_speed_ifg_speed = nthw_register_get_field(p->mp_speed, GMF_SPEED_IFG_SPEED); + + p->mp_ifg_clock_delta = nthw_module_get_register(p->mp_mod_gmf, GMF_IFG_SET_CLOCK_DELTA); + p->mp_ifg_clock_delta_delta = + nthw_register_get_field(p->mp_ifg_clock_delta, GMF_IFG_SET_CLOCK_DELTA_DELTA); + + p->mp_ifg_max_adjust_slack = + nthw_module_get_register(p->mp_mod_gmf, GMF_IFG_MAX_ADJUST_SLACK); + p->mp_ifg_max_adjust_slack_slack = nthw_register_get_field(p->mp_ifg_max_adjust_slack, + GMF_IFG_MAX_ADJUST_SLACK_SLACK); + + p->mp_debug_lane_marker = nthw_module_get_register(p->mp_mod_gmf, GMF_DEBUG_LANE_MARKER); + p->mp_debug_lane_marker_compensation = + nthw_register_get_field(p->mp_debug_lane_marker, + GMF_DEBUG_LANE_MARKER_COMPENSATION); + + p->mp_stat_sticky = nthw_module_get_register(p->mp_mod_gmf, GMF_STAT_STICKY); + p->mp_stat_sticky_data_underflowed = + nthw_register_get_field(p->mp_stat_sticky, GMF_STAT_STICKY_DATA_UNDERFLOWED); + p->mp_stat_sticky_ifg_adjusted = + nthw_register_get_field(p->mp_stat_sticky, GMF_STAT_STICKY_IFG_ADJUSTED); + + p->mn_param_gmf_ifg_speed_mul = + nthw_fpga_get_product_param(p_fpga, NT_GMF_IFG_SPEED_MUL, 1); + p->mn_param_gmf_ifg_speed_div = + nthw_fpga_get_product_param(p_fpga, NT_GMF_IFG_SPEED_DIV, 1); + + p->m_administrative_block = false; + + p->mp_stat_next_pkt = nthw_module_query_register(p->mp_mod_gmf, GMF_STAT_NEXT_PKT); + + if (p->mp_stat_next_pkt) { + p->mp_stat_next_pkt_ns = + nthw_register_query_field(p->mp_stat_next_pkt, GMF_STAT_NEXT_PKT_NS); + + } else { + p->mp_stat_next_pkt_ns = NULL; + } + + p->mp_stat_max_delayed_pkt = + nthw_module_query_register(p->mp_mod_gmf, GMF_STAT_MAX_DELAYED_PKT); + + if (p->mp_stat_max_delayed_pkt) { + p->mp_stat_max_delayed_pkt_ns = + nthw_register_query_field(p->mp_stat_max_delayed_pkt, + GMF_STAT_MAX_DELAYED_PKT_NS); + + } else { + p->mp_stat_max_delayed_pkt_ns = NULL; + } + + p->mp_ctrl_ifg_tx_now_always = + nthw_register_query_field(p->mp_ctrl, GMF_CTRL_IFG_TX_NOW_ALWAYS); + p->mp_ctrl_ifg_tx_on_ts_always = + nthw_register_query_field(p->mp_ctrl, GMF_CTRL_IFG_TX_ON_TS_ALWAYS); + + p->mp_ctrl_ifg_tx_on_ts_adjust_on_set_clock = + nthw_register_query_field(p->mp_ctrl, GMF_CTRL_IFG_TX_ON_TS_ADJUST_ON_SET_CLOCK); + + p->mp_ifg_clock_delta_adjust = + nthw_module_query_register(p->mp_mod_gmf, GMF_IFG_SET_CLOCK_DELTA_ADJUST); + + if (p->mp_ifg_clock_delta_adjust) { + p->mp_ifg_clock_delta_adjust_delta = + nthw_register_query_field(p->mp_ifg_clock_delta_adjust, + GMF_IFG_SET_CLOCK_DELTA_ADJUST_DELTA); + + } else { + p->mp_ifg_clock_delta_adjust_delta = NULL; + } + + p->mp_ts_inject = nthw_module_query_register(p->mp_mod_gmf, GMF_TS_INJECT); + + if (p->mp_ts_inject) { + p->mp_ts_inject_offset = + nthw_register_query_field(p->mp_ts_inject, GMF_TS_INJECT_OFFSET); + p->mp_ts_inject_pos = + nthw_register_query_field(p->mp_ts_inject, GMF_TS_INJECT_POS); + + } else { + p->mp_ts_inject_offset = NULL; + p->mp_ts_inject_pos = NULL; + } + + return 0; +} + +void nthw_gmf_set_enable(nthw_gmf_t *p, bool enable) +{ + if (!p->m_administrative_block) + nthw_field_set_val_flush32(p->mp_ctrl_enable, enable ? 1 : 0); +} From patchwork Tue Oct 29 16:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147647 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5A87545BC0; Tue, 29 Oct 2024 17:48:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C9BB42FF9; Tue, 29 Oct 2024 17:44:31 +0100 (CET) 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 3691D42F29 for ; Tue, 29 Oct 2024 17:43:37 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2106.outbound.protection.outlook.com [104.47.18.106]) 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 16:43:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WX+p+PvzG/IT6YfZb67oPM0HOMC3MuiczfagY0jJLXhPI3zYjUasiSsCu8C/JIYGIiVNR0UDTSn3AkhgXnqNXu3CZzEOk95aR79uhoQS7mXhDnwpeTwXudMUUDPwsR4RuvRuROuRbwmMZuLDhY7Hrv17PX5b+hvluPem0Jl0IGyuKiSvuuHMP+mYimCSqgee5g+/NK/EHyp+m/2lnJ1Vg4fI4etldv2PWOt+oXHJbj/oqlYzqhxLupY+PEwdztREjfQPVBoYWkL1w0bX+U5efjzkZMxy3lAumiaRor689t8KbY6x25P+uWWXHd0UOA/Qduu/lEd/o0Md/5Jmo5StMg== 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=+AGaCCqi1IdAbXMMG+jxRPqFUpQl8EUl57E5yEmZJhs=; b=CZrkldYbDW6OkVqFuWgC02Fo/W6cqT0OCpeQqObI3q6RDC72EUBT+H5Ld/D2dVTNBFiwiM0ChujGnAkDVkPh36iKEw+a4Yp2BDnf4xJ9Q6lwtqea0XJzefeRx88uOwuzxWtCahFlu73Q20wPMrZi9QvHxiz3Vx1okYHkh2bxWndqMdH0QoHqN1sSwZsvtqcjIzI4SkGnSrL0vGhqS40DYB/GMYEV30LN7rjyj51X4N3C74SycznAdZn+51gGZbH4tLpe9W79O0OEVIEcclFM28rKzmbg5lpYXsR/oNzD559Sa2GQI8yoSVlKS5SRIwmMv3xvNLOjx+BX42Kfq0UsOA== 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=+AGaCCqi1IdAbXMMG+jxRPqFUpQl8EUl57E5yEmZJhs=; b=WB8SjYY4L+4lXSuKP2u3C6vWhrdrPySth6sAsLiWC/3OIlVLRjFBJrDy22ModUGJk/lz8J57OcPISl4L5pEoFA8Z64dmjYeviDCHnOu5vV1jrOTYHnzEMoU6h23uwU+w+yYtoIEv4l4Uv29ZXyTB2Roy5raH4IX9tgmDjepCjPE= Received: from DUZPR01CA0203.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::16) by DU4P190MB2150.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:563::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:32 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::76) by DUZPR01CA0203.outlook.office365.com (2603:10a6:10:4b6::16) 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:43:32 +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:43:32 +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, Oleksandr Kolomeiets Subject: [PATCH v4 40/86] net/ntnic: sort FPGA registers alphanumerically Date: Tue, 29 Oct 2024 17:41:44 +0100 Message-ID: <20241029164243.1648775-41-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DU4P190MB2150:EE_ X-MS-Office365-Filtering-Correlation-Id: b74a2346-4ccb-49f6-241c-08dcf838d33a 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: eSfIGB7S5HmyAr32AxrdvTu5vZwmBsT/40+Lqa3vKJ3rr0joC34cfx+Fvq+wSf9toYOY0iqVFlh9UoI/lElV8ENb1PRt//7qnm/ZrKb/mrbXw+iLitZ4F+PzICuzlQewdeMWohaa3/KClr1ZIQcg8yppX/1TJaiJgcZOwfUuZjR3/DXtrj+HEkR1y7z+dIrCLoCFzuWVFkwz3BlkX5mU+9oq0MrJOXqmUl4sQl+djzVNCZWvbpEWnu63Cg38HCCeY6lCa0RxxF2BqwkJo9JfFwoIKe80ZtFH0gj7UVjdOe6ch+dXo3ywBlTEgyp8lhYurzdxe7bwE0/yeQvU4EKrNtJ+0bM69/vk7vDqAg+IcM0bxSf/g4nXFKeocJN4i71/vx1akEEuaBtT7t1cjOzfru73XIRYb7buF+JvGgY/GoyotTlA91hAGScc49S/BhL5yoNqzGLzcDSA/Ut7r1ATXVD1XSs7BADP0V3hABJ2At5uPd5OptDrnDe2jP4pV3RcHcCzN0TczNBqx/Ynfkf+BaaKQiY+WfkPdh0WJCu7a+uZfloNMy2pABbAoR8vN0SnBeF/zZJ0Wp8in2Y3csphzX9tQ5/XsZaBSfKIljBBV/DIbhXuUczZrHj5SdSnEgpyXXeP1ihlATt6FQtn0i/tTRbe1TEc839g2yR4+Mzsw9s1kVqqkWwWEo4NuUO4hPp1uIuhdO8QeKH+smxJh/+pItCueZeVLH3ppY3+cZe3QEtI1vdbGhVZgQr8lUfp38BOJDzK5usLZ7E2Xyy56sOQ3HwbcxpWkAxsEKdVI7xHLnNSkESeHx8AZ8CyEypAmdXPCzSm03S43Pw9QkdnlJHJPUJt4qGkqY2v0/jWAMtDTJ6r8hsHwnVxwha6Qs8mX3cCo8UjPa/GbHaSRYBKis0WMFAaY0VTJeBDXZTavIPjPHee7yy00hQtTualH8n/dM47ZlqCiQVHbzW5xBYGwlUp1jJh9is0ffTqxlLM/vZtlXqehb1ukqiO/5s/ufLr4VeUqCMZwje0W/gPvrLvZNxAepEFCXwy8Kuh8rAsWEmKfyeSa/cjLuKLyQMtWN4+ZlegtKL4343WFD/fmQnZT9vWyH1jn9Tb/s7OyG0f03jYlBwSIvdqrh3ZJotEjfbaui/LzZWJgEjXmGjw7HTiylXzAfIOLxnIrsCBmMgNiG+utf6k2G91guLiSl24YMoXqiU6lW1KPUMgLBEn9/VCXQXJBijvJvIaVeZsQUIpn6JL71hoCs20jy8E66kOzQb/sdFL80Fo1+YFnw/5R58qJhRidpGgHC7RGbsAWzEIOmhUGuxHpkqe7ZMsbgVH+SdG2HZreNgc0jv8hSqmFfv58tEvWhx/93Kfdh99grFS6jppw7ox3fYEuQSmggWMuh4X+GKuEtNRQv4YQpybM5NeZaBnYQ== 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: nOzOzSyvoB6y3dGdp5ueFG7HcHxJu5hwQPjUUt2G8uEPl7Q6TLAkfunAYlhgMPMIGhU6WMdXLbHmsgoz7g3yxy7OMn/iqoY9nN2qrUrVnOeJYfZCmQnEH2E7M5uPaDopP9biBo2uOQdxMFDg8HF8sTYblKTpGslv17089bM5vVwvFfEpoqQfGuwWMikptbB2IVdyeowADzatEjH2zLUJmkj2BrnnGH6vX0MYtCmaxYE8cqCW+b1/DCHgzY8lTk+l1xZOUgBFRw6Ld0inQ48oyHXlvW8uZ/OGmpM3ZYVUO+hoaMTZ5aubJ0beLSu5M8p6L56zPeWF/39ydMRxf5qYcv4dcCmJNsSKtG3/z8G9BD3rwsTI7UzPLrkCTD49K0ltyY4AEu0WQmWxSnhuzhQ/SSHkhonaGN1+0yBAYvulne1QpDEdoMq8hVVtr3k05cWzbtoVYihw0mhPp47Ul6t6NSpcGTalvlqwo9bH2SXBe/Xv81JK0uoFhsCOLK+xwelemYZ2n5slCkVXyUErCQIs8EHf3TIjBYeGn9mIBNcyYCLmC75N7Ju9si6errsY707Aei+tPnNqV0KZVw6hArT2EdEDnhE99auOaaHoHOhAc+TYIl4MOiDmb0+cecwEMB4Ai2BmzDw64btak7mEKkyko556TRpWogtAhRgTfcWWuRw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:32.1677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b74a2346-4ccb-49f6-241c-08dcf838d33a 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: DU4P190MB2150 X-BESS-ID: 1730220214-304438-12712-30041-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmlkZmQGYGUNTEKDk52SLZwM TY0ijNODEp1dgixdQi2STJNDnV3CTJSKk2FgBal0fUQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan19-218.eu-central-1b.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: Oleksandr Kolomeiets Beatification commit. It is required for pretty supporting different FPGA Signed-off-by: Oleksandr Kolomeiets --- .../supported/nthw_fpga_9563_055_049_0000.c | 364 +++++++++--------- 1 file changed, 182 insertions(+), 182 deletions(-) diff --git a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c index 6df7208649..e076697a92 100644 --- a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c +++ b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c @@ -270,6 +270,187 @@ static nthw_fpga_register_init_s cat_registers[] = { { CAT_RCK_DATA, 3, 32, NTHW_FPGA_REG_TYPE_WO, 0, 32, cat_rck_data_fields }, }; +static nthw_fpga_field_init_s dbs_rx_am_ctrl_fields[] = { + { DBS_RX_AM_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_RX_AM_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_am_data_fields[] = { + { DBS_RX_AM_DATA_ENABLE, 1, 72, 0x0000 }, { DBS_RX_AM_DATA_GPA, 64, 0, 0x0000 }, + { DBS_RX_AM_DATA_HID, 8, 64, 0x0000 }, { DBS_RX_AM_DATA_INT, 1, 74, 0x0000 }, + { DBS_RX_AM_DATA_PCKED, 1, 73, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_control_fields[] = { + { DBS_RX_CONTROL_AME, 1, 7, 0 }, { DBS_RX_CONTROL_AMS, 4, 8, 8 }, + { DBS_RX_CONTROL_LQ, 7, 0, 0 }, { DBS_RX_CONTROL_QE, 1, 17, 0 }, + { DBS_RX_CONTROL_UWE, 1, 12, 0 }, { DBS_RX_CONTROL_UWS, 4, 13, 5 }, +}; + +static nthw_fpga_field_init_s dbs_rx_dr_ctrl_fields[] = { + { DBS_RX_DR_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_RX_DR_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_dr_data_fields[] = { + { DBS_RX_DR_DATA_GPA, 64, 0, 0x0000 }, { DBS_RX_DR_DATA_HDR, 1, 88, 0x0000 }, + { DBS_RX_DR_DATA_HID, 8, 64, 0x0000 }, { DBS_RX_DR_DATA_PCKED, 1, 87, 0x0000 }, + { DBS_RX_DR_DATA_QS, 15, 72, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_idle_fields[] = { + { DBS_RX_IDLE_BUSY, 1, 8, 0 }, + { DBS_RX_IDLE_IDLE, 1, 0, 0x0000 }, + { DBS_RX_IDLE_QUEUE, 7, 1, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_init_fields[] = { + { DBS_RX_INIT_BUSY, 1, 8, 0 }, + { DBS_RX_INIT_INIT, 1, 0, 0x0000 }, + { DBS_RX_INIT_QUEUE, 7, 1, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_init_val_fields[] = { + { DBS_RX_INIT_VAL_IDX, 16, 0, 0x0000 }, + { DBS_RX_INIT_VAL_PTR, 15, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_ptr_fields[] = { + { DBS_RX_PTR_PTR, 16, 0, 0x0000 }, + { DBS_RX_PTR_QUEUE, 7, 16, 0x0000 }, + { DBS_RX_PTR_VALID, 1, 23, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_uw_ctrl_fields[] = { + { DBS_RX_UW_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_RX_UW_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_rx_uw_data_fields[] = { + { DBS_RX_UW_DATA_GPA, 64, 0, 0x0000 }, { DBS_RX_UW_DATA_HID, 8, 64, 0x0000 }, + { DBS_RX_UW_DATA_INT, 1, 88, 0x0000 }, { DBS_RX_UW_DATA_ISTK, 1, 92, 0x0000 }, + { DBS_RX_UW_DATA_PCKED, 1, 87, 0x0000 }, { DBS_RX_UW_DATA_QS, 15, 72, 0x0000 }, + { DBS_RX_UW_DATA_VEC, 3, 89, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_am_ctrl_fields[] = { + { DBS_TX_AM_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_TX_AM_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_am_data_fields[] = { + { DBS_TX_AM_DATA_ENABLE, 1, 72, 0x0000 }, { DBS_TX_AM_DATA_GPA, 64, 0, 0x0000 }, + { DBS_TX_AM_DATA_HID, 8, 64, 0x0000 }, { DBS_TX_AM_DATA_INT, 1, 74, 0x0000 }, + { DBS_TX_AM_DATA_PCKED, 1, 73, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_control_fields[] = { + { DBS_TX_CONTROL_AME, 1, 7, 0 }, { DBS_TX_CONTROL_AMS, 4, 8, 5 }, + { DBS_TX_CONTROL_LQ, 7, 0, 0 }, { DBS_TX_CONTROL_QE, 1, 17, 0 }, + { DBS_TX_CONTROL_UWE, 1, 12, 0 }, { DBS_TX_CONTROL_UWS, 4, 13, 8 }, +}; + +static nthw_fpga_field_init_s dbs_tx_dr_ctrl_fields[] = { + { DBS_TX_DR_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_TX_DR_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_dr_data_fields[] = { + { DBS_TX_DR_DATA_GPA, 64, 0, 0x0000 }, { DBS_TX_DR_DATA_HDR, 1, 88, 0x0000 }, + { DBS_TX_DR_DATA_HID, 8, 64, 0x0000 }, { DBS_TX_DR_DATA_PCKED, 1, 87, 0x0000 }, + { DBS_TX_DR_DATA_PORT, 1, 89, 0x0000 }, { DBS_TX_DR_DATA_QS, 15, 72, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_idle_fields[] = { + { DBS_TX_IDLE_BUSY, 1, 8, 0 }, + { DBS_TX_IDLE_IDLE, 1, 0, 0x0000 }, + { DBS_TX_IDLE_QUEUE, 7, 1, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_init_fields[] = { + { DBS_TX_INIT_BUSY, 1, 8, 0 }, + { DBS_TX_INIT_INIT, 1, 0, 0x0000 }, + { DBS_TX_INIT_QUEUE, 7, 1, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_init_val_fields[] = { + { DBS_TX_INIT_VAL_IDX, 16, 0, 0x0000 }, + { DBS_TX_INIT_VAL_PTR, 15, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_ptr_fields[] = { + { DBS_TX_PTR_PTR, 16, 0, 0x0000 }, + { DBS_TX_PTR_QUEUE, 7, 16, 0x0000 }, + { DBS_TX_PTR_VALID, 1, 23, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_qos_ctrl_fields[] = { + { DBS_TX_QOS_CTRL_ADR, 1, 0, 0x0000 }, + { DBS_TX_QOS_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_qos_data_fields[] = { + { DBS_TX_QOS_DATA_BS, 27, 17, 0x0000 }, + { DBS_TX_QOS_DATA_EN, 1, 0, 0x0000 }, + { DBS_TX_QOS_DATA_IR, 16, 1, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_qos_rate_fields[] = { + { DBS_TX_QOS_RATE_DIV, 19, 16, 2 }, + { DBS_TX_QOS_RATE_MUL, 16, 0, 1 }, +}; + +static nthw_fpga_field_init_s dbs_tx_qp_ctrl_fields[] = { + { DBS_TX_QP_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_TX_QP_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_qp_data_fields[] = { + { DBS_TX_QP_DATA_VPORT, 1, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_uw_ctrl_fields[] = { + { DBS_TX_UW_CTRL_ADR, 7, 0, 0x0000 }, + { DBS_TX_UW_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s dbs_tx_uw_data_fields[] = { + { DBS_TX_UW_DATA_GPA, 64, 0, 0x0000 }, { DBS_TX_UW_DATA_HID, 8, 64, 0x0000 }, + { DBS_TX_UW_DATA_INO, 1, 93, 0x0000 }, { DBS_TX_UW_DATA_INT, 1, 88, 0x0000 }, + { DBS_TX_UW_DATA_ISTK, 1, 92, 0x0000 }, { DBS_TX_UW_DATA_PCKED, 1, 87, 0x0000 }, + { DBS_TX_UW_DATA_QS, 15, 72, 0x0000 }, { DBS_TX_UW_DATA_VEC, 3, 89, 0x0000 }, +}; + +static nthw_fpga_register_init_s dbs_registers[] = { + { DBS_RX_AM_CTRL, 10, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_am_ctrl_fields }, + { DBS_RX_AM_DATA, 11, 75, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_rx_am_data_fields }, + { DBS_RX_CONTROL, 0, 18, NTHW_FPGA_REG_TYPE_RW, 43008, 6, dbs_rx_control_fields }, + { DBS_RX_DR_CTRL, 18, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_dr_ctrl_fields }, + { DBS_RX_DR_DATA, 19, 89, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_rx_dr_data_fields }, + { DBS_RX_IDLE, 8, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_idle_fields }, + { DBS_RX_INIT, 2, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_init_fields }, + { DBS_RX_INIT_VAL, 3, 31, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_init_val_fields }, + { DBS_RX_PTR, 4, 24, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_ptr_fields }, + { DBS_RX_UW_CTRL, 14, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_uw_ctrl_fields }, + { DBS_RX_UW_DATA, 15, 93, NTHW_FPGA_REG_TYPE_WO, 0, 7, dbs_rx_uw_data_fields }, + { DBS_TX_AM_CTRL, 12, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_am_ctrl_fields }, + { DBS_TX_AM_DATA, 13, 75, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_tx_am_data_fields }, + { DBS_TX_CONTROL, 1, 18, NTHW_FPGA_REG_TYPE_RW, 66816, 6, dbs_tx_control_fields }, + { DBS_TX_DR_CTRL, 20, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_dr_ctrl_fields }, + { DBS_TX_DR_DATA, 21, 90, NTHW_FPGA_REG_TYPE_WO, 0, 6, dbs_tx_dr_data_fields }, + { DBS_TX_IDLE, 9, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_idle_fields }, + { DBS_TX_INIT, 5, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_init_fields }, + { DBS_TX_INIT_VAL, 6, 31, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_init_val_fields }, + { DBS_TX_PTR, 7, 24, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_ptr_fields }, + { DBS_TX_QOS_CTRL, 24, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_qos_ctrl_fields }, + { DBS_TX_QOS_DATA, 25, 44, NTHW_FPGA_REG_TYPE_WO, 0, 3, dbs_tx_qos_data_fields }, + { DBS_TX_QOS_RATE, 26, 35, NTHW_FPGA_REG_TYPE_RW, 131073, 2, dbs_tx_qos_rate_fields }, + { DBS_TX_QP_CTRL, 22, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_qp_ctrl_fields }, + { DBS_TX_QP_DATA, 23, 1, NTHW_FPGA_REG_TYPE_WO, 0, 1, dbs_tx_qp_data_fields }, + { DBS_TX_UW_CTRL, 16, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_uw_ctrl_fields }, + { DBS_TX_UW_DATA, 17, 94, NTHW_FPGA_REG_TYPE_WO, 0, 8, dbs_tx_uw_data_fields }, +}; + static nthw_fpga_field_init_s gfg_burstsize0_fields[] = { { GFG_BURSTSIZE0_VAL, 24, 0, 0 }, }; @@ -1541,192 +1722,11 @@ static nthw_fpga_register_init_s rst9563_registers[] = { { RST9563_STICKY, 3, 6, NTHW_FPGA_REG_TYPE_RC1, 0, 6, rst9563_sticky_fields }, }; -static nthw_fpga_field_init_s dbs_rx_am_ctrl_fields[] = { - { DBS_RX_AM_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_RX_AM_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_am_data_fields[] = { - { DBS_RX_AM_DATA_ENABLE, 1, 72, 0x0000 }, { DBS_RX_AM_DATA_GPA, 64, 0, 0x0000 }, - { DBS_RX_AM_DATA_HID, 8, 64, 0x0000 }, { DBS_RX_AM_DATA_INT, 1, 74, 0x0000 }, - { DBS_RX_AM_DATA_PCKED, 1, 73, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_control_fields[] = { - { DBS_RX_CONTROL_AME, 1, 7, 0 }, { DBS_RX_CONTROL_AMS, 4, 8, 8 }, - { DBS_RX_CONTROL_LQ, 7, 0, 0 }, { DBS_RX_CONTROL_QE, 1, 17, 0 }, - { DBS_RX_CONTROL_UWE, 1, 12, 0 }, { DBS_RX_CONTROL_UWS, 4, 13, 5 }, -}; - -static nthw_fpga_field_init_s dbs_rx_dr_ctrl_fields[] = { - { DBS_RX_DR_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_RX_DR_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_dr_data_fields[] = { - { DBS_RX_DR_DATA_GPA, 64, 0, 0x0000 }, { DBS_RX_DR_DATA_HDR, 1, 88, 0x0000 }, - { DBS_RX_DR_DATA_HID, 8, 64, 0x0000 }, { DBS_RX_DR_DATA_PCKED, 1, 87, 0x0000 }, - { DBS_RX_DR_DATA_QS, 15, 72, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_idle_fields[] = { - { DBS_RX_IDLE_BUSY, 1, 8, 0 }, - { DBS_RX_IDLE_IDLE, 1, 0, 0x0000 }, - { DBS_RX_IDLE_QUEUE, 7, 1, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_init_fields[] = { - { DBS_RX_INIT_BUSY, 1, 8, 0 }, - { DBS_RX_INIT_INIT, 1, 0, 0x0000 }, - { DBS_RX_INIT_QUEUE, 7, 1, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_init_val_fields[] = { - { DBS_RX_INIT_VAL_IDX, 16, 0, 0x0000 }, - { DBS_RX_INIT_VAL_PTR, 15, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_ptr_fields[] = { - { DBS_RX_PTR_PTR, 16, 0, 0x0000 }, - { DBS_RX_PTR_QUEUE, 7, 16, 0x0000 }, - { DBS_RX_PTR_VALID, 1, 23, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_uw_ctrl_fields[] = { - { DBS_RX_UW_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_RX_UW_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_rx_uw_data_fields[] = { - { DBS_RX_UW_DATA_GPA, 64, 0, 0x0000 }, { DBS_RX_UW_DATA_HID, 8, 64, 0x0000 }, - { DBS_RX_UW_DATA_INT, 1, 88, 0x0000 }, { DBS_RX_UW_DATA_ISTK, 1, 92, 0x0000 }, - { DBS_RX_UW_DATA_PCKED, 1, 87, 0x0000 }, { DBS_RX_UW_DATA_QS, 15, 72, 0x0000 }, - { DBS_RX_UW_DATA_VEC, 3, 89, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_am_ctrl_fields[] = { - { DBS_TX_AM_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_TX_AM_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_am_data_fields[] = { - { DBS_TX_AM_DATA_ENABLE, 1, 72, 0x0000 }, { DBS_TX_AM_DATA_GPA, 64, 0, 0x0000 }, - { DBS_TX_AM_DATA_HID, 8, 64, 0x0000 }, { DBS_TX_AM_DATA_INT, 1, 74, 0x0000 }, - { DBS_TX_AM_DATA_PCKED, 1, 73, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_control_fields[] = { - { DBS_TX_CONTROL_AME, 1, 7, 0 }, { DBS_TX_CONTROL_AMS, 4, 8, 5 }, - { DBS_TX_CONTROL_LQ, 7, 0, 0 }, { DBS_TX_CONTROL_QE, 1, 17, 0 }, - { DBS_TX_CONTROL_UWE, 1, 12, 0 }, { DBS_TX_CONTROL_UWS, 4, 13, 8 }, -}; - -static nthw_fpga_field_init_s dbs_tx_dr_ctrl_fields[] = { - { DBS_TX_DR_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_TX_DR_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_dr_data_fields[] = { - { DBS_TX_DR_DATA_GPA, 64, 0, 0x0000 }, { DBS_TX_DR_DATA_HDR, 1, 88, 0x0000 }, - { DBS_TX_DR_DATA_HID, 8, 64, 0x0000 }, { DBS_TX_DR_DATA_PCKED, 1, 87, 0x0000 }, - { DBS_TX_DR_DATA_PORT, 1, 89, 0x0000 }, { DBS_TX_DR_DATA_QS, 15, 72, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_idle_fields[] = { - { DBS_TX_IDLE_BUSY, 1, 8, 0 }, - { DBS_TX_IDLE_IDLE, 1, 0, 0x0000 }, - { DBS_TX_IDLE_QUEUE, 7, 1, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_init_fields[] = { - { DBS_TX_INIT_BUSY, 1, 8, 0 }, - { DBS_TX_INIT_INIT, 1, 0, 0x0000 }, - { DBS_TX_INIT_QUEUE, 7, 1, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_init_val_fields[] = { - { DBS_TX_INIT_VAL_IDX, 16, 0, 0x0000 }, - { DBS_TX_INIT_VAL_PTR, 15, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_ptr_fields[] = { - { DBS_TX_PTR_PTR, 16, 0, 0x0000 }, - { DBS_TX_PTR_QUEUE, 7, 16, 0x0000 }, - { DBS_TX_PTR_VALID, 1, 23, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_qos_ctrl_fields[] = { - { DBS_TX_QOS_CTRL_ADR, 1, 0, 0x0000 }, - { DBS_TX_QOS_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_qos_data_fields[] = { - { DBS_TX_QOS_DATA_BS, 27, 17, 0x0000 }, - { DBS_TX_QOS_DATA_EN, 1, 0, 0x0000 }, - { DBS_TX_QOS_DATA_IR, 16, 1, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_qos_rate_fields[] = { - { DBS_TX_QOS_RATE_DIV, 19, 16, 2 }, - { DBS_TX_QOS_RATE_MUL, 16, 0, 1 }, -}; - -static nthw_fpga_field_init_s dbs_tx_qp_ctrl_fields[] = { - { DBS_TX_QP_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_TX_QP_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_qp_data_fields[] = { - { DBS_TX_QP_DATA_VPORT, 1, 0, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_uw_ctrl_fields[] = { - { DBS_TX_UW_CTRL_ADR, 7, 0, 0x0000 }, - { DBS_TX_UW_CTRL_CNT, 16, 16, 0x0000 }, -}; - -static nthw_fpga_field_init_s dbs_tx_uw_data_fields[] = { - { DBS_TX_UW_DATA_GPA, 64, 0, 0x0000 }, { DBS_TX_UW_DATA_HID, 8, 64, 0x0000 }, - { DBS_TX_UW_DATA_INO, 1, 93, 0x0000 }, { DBS_TX_UW_DATA_INT, 1, 88, 0x0000 }, - { DBS_TX_UW_DATA_ISTK, 1, 92, 0x0000 }, { DBS_TX_UW_DATA_PCKED, 1, 87, 0x0000 }, - { DBS_TX_UW_DATA_QS, 15, 72, 0x0000 }, { DBS_TX_UW_DATA_VEC, 3, 89, 0x0000 }, -}; - -static nthw_fpga_register_init_s dbs_registers[] = { - { DBS_RX_AM_CTRL, 10, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_am_ctrl_fields }, - { DBS_RX_AM_DATA, 11, 75, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_rx_am_data_fields }, - { DBS_RX_CONTROL, 0, 18, NTHW_FPGA_REG_TYPE_RW, 43008, 6, dbs_rx_control_fields }, - { DBS_RX_DR_CTRL, 18, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_dr_ctrl_fields }, - { DBS_RX_DR_DATA, 19, 89, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_rx_dr_data_fields }, - { DBS_RX_IDLE, 8, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_idle_fields }, - { DBS_RX_INIT, 2, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_init_fields }, - { DBS_RX_INIT_VAL, 3, 31, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_init_val_fields }, - { DBS_RX_PTR, 4, 24, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_rx_ptr_fields }, - { DBS_RX_UW_CTRL, 14, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_rx_uw_ctrl_fields }, - { DBS_RX_UW_DATA, 15, 93, NTHW_FPGA_REG_TYPE_WO, 0, 7, dbs_rx_uw_data_fields }, - { DBS_TX_AM_CTRL, 12, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_am_ctrl_fields }, - { DBS_TX_AM_DATA, 13, 75, NTHW_FPGA_REG_TYPE_WO, 0, 5, dbs_tx_am_data_fields }, - { DBS_TX_CONTROL, 1, 18, NTHW_FPGA_REG_TYPE_RW, 66816, 6, dbs_tx_control_fields }, - { DBS_TX_DR_CTRL, 20, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_dr_ctrl_fields }, - { DBS_TX_DR_DATA, 21, 90, NTHW_FPGA_REG_TYPE_WO, 0, 6, dbs_tx_dr_data_fields }, - { DBS_TX_IDLE, 9, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_idle_fields }, - { DBS_TX_INIT, 5, 9, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_init_fields }, - { DBS_TX_INIT_VAL, 6, 31, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_init_val_fields }, - { DBS_TX_PTR, 7, 24, NTHW_FPGA_REG_TYPE_MIXED, 0, 3, dbs_tx_ptr_fields }, - { DBS_TX_QOS_CTRL, 24, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_qos_ctrl_fields }, - { DBS_TX_QOS_DATA, 25, 44, NTHW_FPGA_REG_TYPE_WO, 0, 3, dbs_tx_qos_data_fields }, - { DBS_TX_QOS_RATE, 26, 35, NTHW_FPGA_REG_TYPE_RW, 131073, 2, dbs_tx_qos_rate_fields }, - { DBS_TX_QP_CTRL, 22, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_qp_ctrl_fields }, - { DBS_TX_QP_DATA, 23, 1, NTHW_FPGA_REG_TYPE_WO, 0, 1, dbs_tx_qp_data_fields }, - { DBS_TX_UW_CTRL, 16, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, dbs_tx_uw_ctrl_fields }, - { DBS_TX_UW_DATA, 17, 94, NTHW_FPGA_REG_TYPE_WO, 0, 8, dbs_tx_uw_data_fields }, -}; - static nthw_fpga_module_init_s fpga_modules[] = { { MOD_CAT, 0, MOD_CAT, 0, 21, NTHW_FPGA_BUS_TYPE_RAB1, 768, 34, cat_registers }, + { MOD_DBS, 0, MOD_DBS, 0, 11, NTHW_FPGA_BUS_TYPE_RAB2, 12832, 27, dbs_registers }, { MOD_GFG, 0, MOD_GFG, 1, 1, NTHW_FPGA_BUS_TYPE_RAB2, 8704, 10, gfg_registers }, { MOD_GMF, 0, MOD_GMF, 2, 5, NTHW_FPGA_BUS_TYPE_RAB2, 9216, 12, gmf_registers }, - { MOD_DBS, 0, MOD_DBS, 0, 11, NTHW_FPGA_BUS_TYPE_RAB2, 12832, 27, dbs_registers}, { MOD_GMF, 1, MOD_GMF, 2, 5, NTHW_FPGA_BUS_TYPE_RAB2, 9728, 12, gmf_registers }, { MOD_GPIO_PHY, 0, MOD_GPIO_PHY, 1, 0, NTHW_FPGA_BUS_TYPE_RAB0, 16386, 2, From patchwork Tue Oct 29 16:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147645 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BC0A45BC0; Tue, 29 Oct 2024 17:48:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 517D642FE7; Tue, 29 Oct 2024 17:44:29 +0100 (CET) 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 7A57742F23 for ; Tue, 29 Oct 2024 17:43:37 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2108.outbound.protection.outlook.com [104.47.11.108]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n1BN8FkTxjpnZRSS7S1jaP3Wh/duk7h2TjfQ7Zaa3BD+C0vi7alQ/j7Bi9tvvCHmeAdJBzO5xflU8aZTSC5PbYZ3/GKye5v78WenX/qlqRx3IQD2RnRSTs985wXbcpxT+awPvdY3Y65+IdPUMfmGSqI8bIvoUFdqWMaoHDsAGykMrgjeBSMid8ZFurb81Vx+VYqtSzqHGu8kI+TxJcZVQmLuv69qFFNyYipdz0b/OCRwwfqHgRuZkQV1K7NHCLZBpbNwadzX4rvfwSuhLbgAPHf/WKkb9DBiSRMsw+/+Q2zgZLlQn/HLY6rtZmrfAA1Ge8IAx49MKR/vgYcl6AdPaw== 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=VO7ys+WIdyPLrbx5lXwaXp/Q3eoJ40kGvW/7tAbpdzU=; b=OFTKlhUKuewWD37jw/+IQwQ/K8urxIuWdbrE2oA33S/wA3hanuJk3TKV64CWK9OtB3+xokbz+ygCxg3mz+42+GktGi1ld3yHTb+7TrnLCSD7foEwnDfNekgBUHHEkwO+GUEmIza943MT4Wp2XgDLWLncNbiN0MJqXy+amqjJqzJq7ErEUxMB2ADblDa9jYtVVuD9Mri2/NzYOGbgaA3j/v0OeHRUe41rlioyQa8pPMt4zMdJMhsLJMIfxPfG4YrwggSsUCb+RfMu8RzgVHBEyKFIwgRjvTCrKBlIr58G/Or/MI/5LO0jv1h0CswKOPHKAV6Jd23d6/Xf9IiFRe9j9A== 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=VO7ys+WIdyPLrbx5lXwaXp/Q3eoJ40kGvW/7tAbpdzU=; b=WVXJZf3KnhnQ4mZMkJ1m2t2UdYLrOPjVzVKwJGZftvKY/rdxnKSCbNZoBVvL3FvtRjrzLzv1AEJifdZrX6oB7txLCBxyMgoj+mbhN7aBCFWwsuvO8DzjCC1cCWPSY29PXTL5SnJ8q84wsJlPW6SvyOl+A193I9TH0uPNMdFZagw= Received: from DUZPR01CA0193.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::14) by AM9P190MB1297.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:262::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:33 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::21) 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:43:33 +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:43:32 +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, Oleksandr Kolomeiets Subject: [PATCH v4 41/86] net/ntnic: add CSU module registers Date: Tue, 29 Oct 2024 17:41:45 +0100 Message-ID: <20241029164243.1648775-42-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM9P190MB1297:EE_ X-MS-Office365-Filtering-Correlation-Id: 279977dc-b5c7-42c3-a942-08dcf838d3a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: oKuZLNXtIdsKDH+fvoKZoWID+/9G0SKwjns0Kfallr2U9ngrokoeBBiHv1guc19v0jOiqM/JA1thX2HLcqRTbcHZvD6H/NZDehGYMjRsM0QhVSJWwjjXMZy0FXQ+UJe6rUwiaEbj7sUCxOM3t0QYvnNVPeXLQFfCbTcsphrVR2U2PqJpZgah55wrfu6mhv1I0PQjYyg5knArgYzHlkSE3xfmFWhbBJJeAj91+NVC4RVaDWiazxukF1T4YrBgVnxo/ebiOy1OVG/N/HASpX3/TL6CuUQAb+UywZ9YBMxrDqCrTleMxF0TTJApklo6vYlLLBKXQj0jIqbwQZBVlAmKB4gIvkOID9ZSnXme23DYusV4ffzEa+/XUAc71tefHcgy321/6/D/8qJPqs3B6fk5qxjvQTuOmO/q5jJck3xXKBUKlCQl2epFYKbbZEwE0S0a0LtGVDZgv0sEQCrRBkhTB2QXzsDdZwPaXqfAxKlXVDKBKnfa7toHlG0RgyJ6xQ0NaSVdx5trZ/urhBzaHLbnC16IAkgub1VODLxPCPJzI5bTq1p4QNElaAwjeBV7ErxMruAt0wmVyQCMbGIok4NrbqjchiQhgFYeMylw8f6lVVcbGAMX/8OpOAfKCsFmm54InyNG9Rf5JY/YSmfdak4KsPRezeyxhXlujcLyfoUfhGVM7P2MrpDC3sOMnAT/UaWyjIIEGPz0ux5LeR3P2QZFIAefL64tq2Wxnt0kQF6AwvwsggZ0xC2n44nQyjeKbZ3hWnuKQAM+9a/nZ82zYNzkbWozHVidIOQa0yxRxNm57gD0+4+jHRqvCRVkJbWGoMN/2v5bDZxt+VeFxglaLRxem/2A8SzuuM32+Tc74SW50nTbu+KjKS8aiXt0ANe4OyZLJhQky33mj21EZwiImyw+QLCAXDqpmVqHGzOPWO7Y1r6ScINshgQ4PS16dudnVqpJBVwWXROpi3YaaVqQmnfFUuapnyJsESvnMnMN5iTAgx/HEMVQpq6wykZ24HuPZ69oRfDUsDh88vc71al/+DUA5tkVO/oL3j01UsJXnr96xnJRpkMmwX8ebtD+QOHrMh6F/X0hZnnYaimUlnnCtv88c50+iyq3b0KwxHN01D2c7KD7MQlDWFnn8DRp4HKXkKBlwqb7Te47tuT6BV4m4vad8QxCerzZc+2Y4wOcsUVGHoujIKlzF938arFGdcYIBT+uiFgAnwd3mvs6s9MjcIX8XV588GjbwRc/0B2xx2GoMmg0cqOATj9DRRnIhs1bvhfEssHjlK5NE/bGFGH8WzjTPbGiFoUjfOzdO9cf7jNsLV3qQ3g3nOepdjnbMk4JfPTYHgvMRhxoBe9yVdSv2goxaXett2eSSdoKxgxzzLJ/LEeqieX/SN6rC0IU9x5h3/GzPuZ15f+Z+1a6yOUdIFqosg== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: uNTGrAYphyex+u7p2PQVEIyoHFaFXHtrIKdwNtlzBRoMVH2Op7d4zvFBnIy3AFpIVLlGZsSxFNioNUk3kkg6okZ2ZbCiqAAXygfsbDc9toHjPsVx1CGCS7YSxTj5XWS7ovTqO7/OsvCbXEMy0PwjZqtB4moGSvzof/flT03T/BCePOOxetjKkykkAUu7UJYAvd2YfJ09hCikNYMqw0pdtJ/fv8wXAALWv6/3WOEybnteaZHw81YrbiaCP3Vx/Tq/XkRu7CMZ/DAHG/wiUuiorYoIPXxIfKEKuoIXt9VyrZSdbiV7hoYkvOFQoWs1TIR7nhle/oL77+Wds3s+ISVvv7RIG1Ct1kpU8IwYHEmgImp8Pq9GS9emAtw97LcpOBLEngvBzeIr+5YO/YJn7BTlMJC7vhv4fqVFrRlaEzpH2BuZiWZZjpaDumTJ96C26kiR12gBEyaCqrNsqm9IedILFJxMFRABqYdHJvd4Fw3o5Ci+ea8IZns04e0aQlNIMHpO2nBsl6cRQyHcg7OM6t/aLVX4fdUKNGvv/QNpR+2224DAP//IJf5yZbYGWspMvxlHdsnbLhokQCxxnLSXyKMYwZvDnlO5HGIc6QYgM9Yf12hu3kkic4i1wt2fMbh+cqGs+Cm0WtptVYgVAvmo5N1VSUgJrw4OTgHFuqP64k6xL1c= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:32.9177 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 279977dc-b5c7-42c3-a942-08dcf838d3a0 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: AM9P190MB1297 X-BESS-ID: 1730220215-311207-12673-27852-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.108 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGlhZAVgZQ0CzRyNQ4ycLQ0D TZ2MDAPDnJNDnNMNU0zczEyNDUJNlUqTYWAFSwgGtBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan13-243.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: Oleksandr Kolomeiets The Checksum Update module updates the checksums of packets that has been modified in any way. Signed-off-by: Oleksandr Kolomeiets --- .../supported/nthw_fpga_9563_055_049_0000.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c index e076697a92..efa7b306bc 100644 --- a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c +++ b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c @@ -270,6 +270,23 @@ static nthw_fpga_register_init_s cat_registers[] = { { CAT_RCK_DATA, 3, 32, NTHW_FPGA_REG_TYPE_WO, 0, 32, cat_rck_data_fields }, }; +static nthw_fpga_field_init_s csu_rcp_ctrl_fields[] = { + { CSU_RCP_CTRL_ADR, 4, 0, 0x0000 }, + { CSU_RCP_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s csu_rcp_data_fields[] = { + { CSU_RCP_DATA_IL3_CMD, 2, 5, 0x0000 }, + { CSU_RCP_DATA_IL4_CMD, 3, 7, 0x0000 }, + { CSU_RCP_DATA_OL3_CMD, 2, 0, 0x0000 }, + { CSU_RCP_DATA_OL4_CMD, 3, 2, 0x0000 }, +}; + +static nthw_fpga_register_init_s csu_registers[] = { + { CSU_RCP_CTRL, 1, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, csu_rcp_ctrl_fields }, + { CSU_RCP_DATA, 2, 10, NTHW_FPGA_REG_TYPE_WO, 0, 4, csu_rcp_data_fields }, +}; + static nthw_fpga_field_init_s dbs_rx_am_ctrl_fields[] = { { DBS_RX_AM_CTRL_ADR, 7, 0, 0x0000 }, { DBS_RX_AM_CTRL_CNT, 16, 16, 0x0000 }, @@ -1724,6 +1741,7 @@ static nthw_fpga_register_init_s rst9563_registers[] = { static nthw_fpga_module_init_s fpga_modules[] = { { MOD_CAT, 0, MOD_CAT, 0, 21, NTHW_FPGA_BUS_TYPE_RAB1, 768, 34, cat_registers }, + { MOD_CSU, 0, MOD_CSU, 0, 0, NTHW_FPGA_BUS_TYPE_RAB1, 9728, 2, csu_registers }, { MOD_DBS, 0, MOD_DBS, 0, 11, NTHW_FPGA_BUS_TYPE_RAB2, 12832, 27, dbs_registers }, { MOD_GFG, 0, MOD_GFG, 1, 1, NTHW_FPGA_BUS_TYPE_RAB2, 8704, 10, gfg_registers }, { MOD_GMF, 0, MOD_GMF, 2, 5, NTHW_FPGA_BUS_TYPE_RAB2, 9216, 12, gmf_registers }, @@ -1919,5 +1937,5 @@ static nthw_fpga_prod_param_s product_parameters[] = { }; nthw_fpga_prod_init_s nthw_fpga_9563_055_049_0000 = { - 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 22, fpga_modules, + 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 23, fpga_modules, }; From patchwork Tue Oct 29 16:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147648 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3941545BC0; Tue, 29 Oct 2024 17:49:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B69BC43003; Tue, 29 Oct 2024 17:44:32 +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 C055B42EC8 for ; Tue, 29 Oct 2024 17:43:38 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2176.outbound.protection.outlook.com [104.47.17.176]) 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:43:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oAwxPsYyktYxLY6ozP0aVaijuSGyCyphlzmAurE5EL6hCC/hW7TUfavuwjZ25Li4/e9jiryJ/0FkMX7H21DDjhUyQ6sOnW9TM193cK5YC+rDurQ4YXaQfssZ4hQzZ5lmu+iJNlGQ3gQGVO6x5byu9e3eXBqHrTLpKopKZA+A5yQ0AcOlHZAKAGPrhytQK0si/9m8YAx48necPZQHD/KbYicHhLtyzcvT6Wp37WpfiJ6Pwnurik8YDqo1RoYpPnWYODQeBsc0zFq1yAIevvRkblwmeGzyj8NKRB/jC+X7MU1j0TrxunaewLOXTh1qs78isl6tl16OPQiE54WwKhWtpA== 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=Wml7F8E+41vF6bpSz8rFg7R7K4n2n/5Rq9n4nbEQJDI=; b=Sin9WlrH4vWbeYSwRWRQx9tw/YHCNYfFmzlh1J+I3d6YNfWED2LS2Az5JDYUXnqeBAxqlRhNE1G/tNzIyJpzT2yiSO3C8aKLPAJWvv75LeJLYqShP7nyyW5u53MMtIXqhbqQ4aQXGG9W5/6fLIwi8XawkchxyMdR8PRU9isuA8z2oOSgFR7tl3R3Wvs6k7Opf1qjdB9MGub0NmlR5C1FdNaDEWzQDe9ySn1PiqRyhdOsDbKr9w8429YvCPaCIUlkaML8BeYGiFZM617esibFItgKnzKl7qw5G5qEGM6mYKufHCKnHKEqmjXUzdK0Wvqe+pu7hzY9IvKMzWMVzhWkNw== 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=Wml7F8E+41vF6bpSz8rFg7R7K4n2n/5Rq9n4nbEQJDI=; b=U2piflFxpLa1+UB/O2JmygXM7T8IvWVqsDTIHWXklteubpgWG/jUqqwsKleWSZkj3jtTDMVcXBrxftpBgGdKOH4bHUccWsV5cd/AS04zI7hyG3faPnE+bVAnqa3U1v5wJtaORa9hC06NXCCy/DXeZ5Bl7A9GBN3zTkZCIDYh6Cg= Received: from DUZPR01CA0194.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::19) by AM9P190MB1204.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:26e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:34 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::23) by DUZPR01CA0194.outlook.office365.com (2603:10a6:10:4b6::19) 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:43:34 +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:43:33 +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, Oleksandr Kolomeiets Subject: [PATCH v4 42/86] net/ntnic: add FLM module registers Date: Tue, 29 Oct 2024 17:41:46 +0100 Message-ID: <20241029164243.1648775-43-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM9P190MB1204:EE_ X-MS-Office365-Filtering-Correlation-Id: b331d935-37a2-4951-2cfe-08dcf838d426 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: eeTVR4s5+nwNQgfAeNA1M3FWx/XV3LR+F+pnK+8zgkjrF3uoZryTYuNFmdyWMW4A095I5ZewrujTpfALbsWHJaSMarLvm36s8Mt28jM3Dc4zohbbciFL8AzgWzPB69yo7aYnQwCH+YzG88kANICrkBxBPDS1KoWaq1iaIZD7oZtvt9z1m4XvJLhfpiMKvb6+3s3YPZx2FGLkmHn36KcvpW2+FG6cqEn3lPxez2V2KreS5ji9lVuCHUAmta3LrX+8ZZDc2fhZl4o+W8OMrGt+leEFtubMcB7u47MUjFrT2f+jjanlHrfwApPu3suLmfGUrXKQZ+sKxmkXDTVd48oWlwwF1IFjBRrWiVTroIKveq5j5I1VjQACuecl8y3dSnRtx9z6jqrlOBfc0nsOakDs1OZEO6U0rIt5K6OL0imcDy37KUKkwvmU+pQdzYlIJ6EEq3itBIORwlHc4x4rSBSDSEfk7fztxaXQWHPe/ytw2yXJXm329UdvAoxaeBPb4TgnSmOmRuLTlIwj7R/Vg4XDGyKxX8vltdSgOKKLgmBHE8QeTkRaA+5E9zNgrMZaM1fdlQr18tvJS/Yy08JYGv/cbVbTy98xU8AcSWCQXyCiTVjur0Gy94ZgoEbPO3pXGG51TODogIc18XnMfqb1whOxFOObpVRwninQsR0d8pJw/TZBBmwRXzRs9317stq/djZMGUz6kgH6L3s76mMNhsw2+1HnVyByiQEH4KWlnCHUg2w5QIglOCBDZLKoAJi4O4W8YwVzxawNNyEtUDh9zdWhlsoUS67AoonYSGnRoy6en80cjvvhSwSKwlXEJlGlXgebP8KaQUiGfs+/49jnC7NhpjU6gFaQK0Eh+z/Z165KKRTLFBjH9hu1RWlUlWObMkYhl58lPFC0BVf7UxK/knqmwwWqgI5vnabtG3i2MIKFTGjI3obXIJf9dPGBsucCPPA+i0y/Z88Z/2AyWaS7BysVwhoSHFk6FwzMbCg4GnVDjBcK5BqGOTMwyDtUezSZ+iVG6yA+qCefKoWrMNhqbqgXL+A+h3HSWJkP01ebi5MUR55r8ks7Tw0YiVyYIvO9/JZpi+o/7Gj3qUOPBIUh2f7Ii5ueFNLk8JcR3rIPffvR7Go7osQjCxpMRKRtNTDqVvmWLg15d9ZEGwj2VjmP8OGR2bSzdDa0IJYtVdpqo1nrWOfFtjDyIm+HRpXKC53ZLn0sxFTZ36sEvUzUmr96ERCxpu0Fmkx/v+rKg/YvX57lUbiE+RrBzB0urnYoDant1ERej0KD6xb61UkBbOcBrYiZRx/2b6QLxOp1ZDvl+ixf0lhsq7cG/fi6bAdkxLLqnXxhuhjMC6Chei7HUiGC4UYeGJnXDi8MAXBy93ncNztWcLIGivzOkO7Geci+zfCFceiUvabT+gR+FGOKzjqOhS+D3Q== 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2+Nk0FctMwF0KlNDSSMu2pWHHGqhayMwUgrRN/ldbm2G3XzKuK4onAm+eZnUFSLQh+ncPToL1JP0LXwId+D+oyO/pZnlG5ONZftDZI+PriAWPg3f9GK7i7cMx9c+XOKEx1en5a8WvY654lfD3ZwLTdZw2YnyKZ1D/LBLewI64CcjeJ8uj5g1XYOOs3LJaT16LzxwqYDewJGkAr0EgR9IxGBR57kMA9tWKXw5j+WXQtOR0I/WGgv4dltQzJbbWmCzNKu2nz440EgoI8UNqvNHSchltm8+ZF+d7uE+qGSzN/GvD0HAPQmC468zpQ9MZfzWRCCfYFVr38WqzM48qT0MoStoT/myGVzeLgLnjfWpaMYEE0yaNPhZUz6RiqJZS/VUlto3vC7Abix6kufrxlT7bTedYsV0TvYcnH43TJXjE+g+1hovadbP6V6tjF2Dn6lh27/twEvTsziZtNsyOGUC1eFuw936t1zTBEJ6cE98RFqrrZPBSkmR3jV4BpJjgHs0DcuPgDHGADaSugIOxem8asZ07g+JN3emUvdb8B02FtdTOxmkMMesOHhbNP2NfbLqhXh8kRa/+5dFgjTziz97hfQGhsSC7mKqefiVolyDYyJRo4Vk6Usms3+b6K7ZyFwCDD2a300jC+KXgFxcibA4kET7BkI5TLvoHSkoNRtORZw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:33.7927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b331d935-37a2-4951-2cfe-08dcf838d426 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: AM9P190MB1204 X-BESS-ID: 1730220216-303097-12765-29352-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.176 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYmRuZmQGYGUNTIJNEy0czIyC TZ0sAs1cTSKNUgySDR2MggzdwwBYiVamMByfWwUkIAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan16-169.eu-central-1b.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: Oleksandr Kolomeiets The Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Oleksandr Kolomeiets --- .../supported/nthw_fpga_9563_055_049_0000.c | 286 +++++++++++++++++- 1 file changed, 284 insertions(+), 2 deletions(-) diff --git a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c index efa7b306bc..739cabfb1c 100644 --- a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c +++ b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c @@ -468,6 +468,288 @@ static nthw_fpga_register_init_s dbs_registers[] = { { DBS_TX_UW_DATA, 17, 94, NTHW_FPGA_REG_TYPE_WO, 0, 8, dbs_tx_uw_data_fields }, }; +static nthw_fpga_field_init_s flm_buf_ctrl_fields[] = { + { FLM_BUF_CTRL_INF_AVAIL, 16, 16, 0x0000 }, + { FLM_BUF_CTRL_LRN_FREE, 16, 0, 0x0000 }, + { FLM_BUF_CTRL_STA_AVAIL, 16, 32, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_control_fields[] = { + { FLM_CONTROL_CALIB_RECALIBRATE, 3, 28, 0 }, + { FLM_CONTROL_CRCRD, 1, 12, 0x0000 }, + { FLM_CONTROL_CRCWR, 1, 11, 0x0000 }, + { FLM_CONTROL_EAB, 5, 18, 0 }, + { FLM_CONTROL_ENABLE, 1, 0, 0 }, + { FLM_CONTROL_INIT, 1, 1, 0x0000 }, + { FLM_CONTROL_LDS, 1, 2, 0x0000 }, + { FLM_CONTROL_LFS, 1, 3, 0x0000 }, + { FLM_CONTROL_LIS, 1, 4, 0x0000 }, + { FLM_CONTROL_PDS, 1, 9, 0x0000 }, + { FLM_CONTROL_PIS, 1, 10, 0x0000 }, + { FLM_CONTROL_RBL, 4, 13, 0 }, + { FLM_CONTROL_RDS, 1, 7, 0x0000 }, + { FLM_CONTROL_RIS, 1, 8, 0x0000 }, + { FLM_CONTROL_SPLIT_SDRAM_USAGE, 5, 23, 16 }, + { FLM_CONTROL_UDS, 1, 5, 0x0000 }, + { FLM_CONTROL_UIS, 1, 6, 0x0000 }, + { FLM_CONTROL_WPD, 1, 17, 0 }, +}; + +static nthw_fpga_field_init_s flm_inf_data_fields[] = { + { FLM_INF_DATA_BYTES, 64, 0, 0x0000 }, { FLM_INF_DATA_CAUSE, 3, 224, 0x0000 }, + { FLM_INF_DATA_EOR, 1, 287, 0x0000 }, { FLM_INF_DATA_ID, 32, 192, 0x0000 }, + { FLM_INF_DATA_PACKETS, 64, 64, 0x0000 }, { FLM_INF_DATA_TS, 64, 128, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_load_aps_fields[] = { + { FLM_LOAD_APS_APS, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_load_bin_fields[] = { + { FLM_LOAD_BIN_BIN, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_load_lps_fields[] = { + { FLM_LOAD_LPS_LPS, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_lrn_data_fields[] = { + { FLM_LRN_DATA_ADJ, 32, 480, 0x0000 }, { FLM_LRN_DATA_COLOR, 32, 448, 0x0000 }, + { FLM_LRN_DATA_DSCP, 6, 698, 0x0000 }, { FLM_LRN_DATA_ENT, 1, 693, 0x0000 }, + { FLM_LRN_DATA_EOR, 1, 767, 0x0000 }, { FLM_LRN_DATA_FILL, 16, 544, 0x0000 }, + { FLM_LRN_DATA_FT, 4, 560, 0x0000 }, { FLM_LRN_DATA_FT_MBR, 4, 564, 0x0000 }, + { FLM_LRN_DATA_FT_MISS, 4, 568, 0x0000 }, { FLM_LRN_DATA_ID, 32, 512, 0x0000 }, + { FLM_LRN_DATA_KID, 8, 328, 0x0000 }, { FLM_LRN_DATA_MBR_ID1, 28, 572, 0x0000 }, + { FLM_LRN_DATA_MBR_ID2, 28, 600, 0x0000 }, { FLM_LRN_DATA_MBR_ID3, 28, 628, 0x0000 }, + { FLM_LRN_DATA_MBR_ID4, 28, 656, 0x0000 }, { FLM_LRN_DATA_NAT_EN, 1, 711, 0x0000 }, + { FLM_LRN_DATA_NAT_IP, 32, 336, 0x0000 }, { FLM_LRN_DATA_NAT_PORT, 16, 400, 0x0000 }, + { FLM_LRN_DATA_NOFI, 1, 716, 0x0000 }, { FLM_LRN_DATA_OP, 4, 694, 0x0000 }, + { FLM_LRN_DATA_PRIO, 2, 691, 0x0000 }, { FLM_LRN_DATA_PROT, 8, 320, 0x0000 }, + { FLM_LRN_DATA_QFI, 6, 704, 0x0000 }, { FLM_LRN_DATA_QW0, 128, 192, 0x0000 }, + { FLM_LRN_DATA_QW4, 128, 64, 0x0000 }, { FLM_LRN_DATA_RATE, 16, 416, 0x0000 }, + { FLM_LRN_DATA_RQI, 1, 710, 0x0000 }, + { FLM_LRN_DATA_SIZE, 16, 432, 0x0000 }, { FLM_LRN_DATA_STAT_PROF, 4, 687, 0x0000 }, + { FLM_LRN_DATA_SW8, 32, 32, 0x0000 }, { FLM_LRN_DATA_SW9, 32, 0, 0x0000 }, + { FLM_LRN_DATA_TEID, 32, 368, 0x0000 }, { FLM_LRN_DATA_VOL_IDX, 3, 684, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_prio_fields[] = { + { FLM_PRIO_FT0, 4, 4, 1 }, { FLM_PRIO_FT1, 4, 12, 1 }, { FLM_PRIO_FT2, 4, 20, 1 }, + { FLM_PRIO_FT3, 4, 28, 1 }, { FLM_PRIO_LIMIT0, 4, 0, 0 }, { FLM_PRIO_LIMIT1, 4, 8, 0 }, + { FLM_PRIO_LIMIT2, 4, 16, 0 }, { FLM_PRIO_LIMIT3, 4, 24, 0 }, +}; + +static nthw_fpga_field_init_s flm_pst_ctrl_fields[] = { + { FLM_PST_CTRL_ADR, 4, 0, 0x0000 }, + { FLM_PST_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_pst_data_fields[] = { + { FLM_PST_DATA_BP, 5, 0, 0x0000 }, + { FLM_PST_DATA_PP, 5, 5, 0x0000 }, + { FLM_PST_DATA_TP, 5, 10, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_rcp_ctrl_fields[] = { + { FLM_RCP_CTRL_ADR, 5, 0, 0x0000 }, + { FLM_RCP_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_rcp_data_fields[] = { + { FLM_RCP_DATA_AUTO_IPV4_MASK, 1, 402, 0x0000 }, + { FLM_RCP_DATA_BYT_DYN, 5, 387, 0x0000 }, + { FLM_RCP_DATA_BYT_OFS, 8, 392, 0x0000 }, + { FLM_RCP_DATA_IPN, 1, 386, 0x0000 }, + { FLM_RCP_DATA_KID, 8, 377, 0x0000 }, + { FLM_RCP_DATA_LOOKUP, 1, 0, 0x0000 }, + { FLM_RCP_DATA_MASK, 320, 57, 0x0000 }, + { FLM_RCP_DATA_OPN, 1, 385, 0x0000 }, + { FLM_RCP_DATA_QW0_DYN, 5, 1, 0x0000 }, + { FLM_RCP_DATA_QW0_OFS, 8, 6, 0x0000 }, + { FLM_RCP_DATA_QW0_SEL, 2, 14, 0x0000 }, + { FLM_RCP_DATA_QW4_DYN, 5, 16, 0x0000 }, + { FLM_RCP_DATA_QW4_OFS, 8, 21, 0x0000 }, + { FLM_RCP_DATA_SW8_DYN, 5, 29, 0x0000 }, + { FLM_RCP_DATA_SW8_OFS, 8, 34, 0x0000 }, + { FLM_RCP_DATA_SW8_SEL, 2, 42, 0x0000 }, + { FLM_RCP_DATA_SW9_DYN, 5, 44, 0x0000 }, + { FLM_RCP_DATA_SW9_OFS, 8, 49, 0x0000 }, + { FLM_RCP_DATA_TXPLM, 2, 400, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_scan_fields[] = { + { FLM_SCAN_I, 16, 0, 0 }, +}; + +static nthw_fpga_field_init_s flm_status_fields[] = { + { FLM_STATUS_CACHE_BUFFER_CRITICAL, 1, 12, 0x0000 }, + { FLM_STATUS_CALIB_FAIL, 3, 3, 0 }, + { FLM_STATUS_CALIB_SUCCESS, 3, 0, 0 }, + { FLM_STATUS_CRCERR, 1, 10, 0x0000 }, + { FLM_STATUS_CRITICAL, 1, 8, 0x0000 }, + { FLM_STATUS_EFT_BP, 1, 11, 0x0000 }, + { FLM_STATUS_IDLE, 1, 7, 0x0000 }, + { FLM_STATUS_INITDONE, 1, 6, 0x0000 }, + { FLM_STATUS_PANIC, 1, 9, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_aul_done_fields[] = { + { FLM_STAT_AUL_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_aul_fail_fields[] = { + { FLM_STAT_AUL_FAIL_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_aul_ignore_fields[] = { + { FLM_STAT_AUL_IGNORE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_csh_hit_fields[] = { + { FLM_STAT_CSH_HIT_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_csh_miss_fields[] = { + { FLM_STAT_CSH_MISS_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_csh_unh_fields[] = { + { FLM_STAT_CSH_UNH_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_cuc_move_fields[] = { + { FLM_STAT_CUC_MOVE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_cuc_start_fields[] = { + { FLM_STAT_CUC_START_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_flows_fields[] = { + { FLM_STAT_FLOWS_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_inf_done_fields[] = { + { FLM_STAT_INF_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_inf_skip_fields[] = { + { FLM_STAT_INF_SKIP_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_lrn_done_fields[] = { + { FLM_STAT_LRN_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_lrn_fail_fields[] = { + { FLM_STAT_LRN_FAIL_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_lrn_ignore_fields[] = { + { FLM_STAT_LRN_IGNORE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_pck_dis_fields[] = { + { FLM_STAT_PCK_DIS_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_pck_hit_fields[] = { + { FLM_STAT_PCK_HIT_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_pck_miss_fields[] = { + { FLM_STAT_PCK_MISS_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_pck_unh_fields[] = { + { FLM_STAT_PCK_UNH_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_prb_done_fields[] = { + { FLM_STAT_PRB_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_prb_ignore_fields[] = { + { FLM_STAT_PRB_IGNORE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_rel_done_fields[] = { + { FLM_STAT_REL_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_rel_ignore_fields[] = { + { FLM_STAT_REL_IGNORE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_sta_done_fields[] = { + { FLM_STAT_STA_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_tul_done_fields[] = { + { FLM_STAT_TUL_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_unl_done_fields[] = { + { FLM_STAT_UNL_DONE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_stat_unl_ignore_fields[] = { + { FLM_STAT_UNL_IGNORE_CNT, 32, 0, 0x0000 }, +}; + +static nthw_fpga_field_init_s flm_sta_data_fields[] = { + { FLM_STA_DATA_EOR, 1, 95, 0x0000 }, { FLM_STA_DATA_ID, 32, 0, 0x0000 }, + { FLM_STA_DATA_LDS, 1, 32, 0x0000 }, { FLM_STA_DATA_LFS, 1, 33, 0x0000 }, + { FLM_STA_DATA_LIS, 1, 34, 0x0000 }, { FLM_STA_DATA_PDS, 1, 39, 0x0000 }, + { FLM_STA_DATA_PIS, 1, 40, 0x0000 }, { FLM_STA_DATA_RDS, 1, 37, 0x0000 }, + { FLM_STA_DATA_RIS, 1, 38, 0x0000 }, { FLM_STA_DATA_UDS, 1, 35, 0x0000 }, + { FLM_STA_DATA_UIS, 1, 36, 0x0000 }, +}; + +static nthw_fpga_register_init_s flm_registers[] = { + { FLM_BUF_CTRL, 14, 48, NTHW_FPGA_REG_TYPE_RW, 0, 3, flm_buf_ctrl_fields }, + { FLM_CONTROL, 0, 31, NTHW_FPGA_REG_TYPE_MIXED, 134217728, 18, flm_control_fields }, + { FLM_INF_DATA, 16, 288, NTHW_FPGA_REG_TYPE_RO, 0, 6, flm_inf_data_fields }, + { FLM_LOAD_APS, 5, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_load_aps_fields }, + { FLM_LOAD_BIN, 3, 32, NTHW_FPGA_REG_TYPE_WO, 0, 1, flm_load_bin_fields }, + { FLM_LOAD_LPS, 4, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_load_lps_fields }, + { FLM_LRN_DATA, 15, 768, NTHW_FPGA_REG_TYPE_WO, 0, 34, flm_lrn_data_fields }, + { FLM_PRIO, 6, 32, NTHW_FPGA_REG_TYPE_WO, 269488144, 8, flm_prio_fields }, + { FLM_PST_CTRL, 12, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, flm_pst_ctrl_fields }, + { FLM_PST_DATA, 13, 15, NTHW_FPGA_REG_TYPE_WO, 0, 3, flm_pst_data_fields }, + { FLM_RCP_CTRL, 8, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, flm_rcp_ctrl_fields }, + { FLM_RCP_DATA, 9, 403, NTHW_FPGA_REG_TYPE_WO, 0, 19, flm_rcp_data_fields }, + { FLM_SCAN, 2, 16, NTHW_FPGA_REG_TYPE_WO, 0, 1, flm_scan_fields }, + { FLM_STATUS, 1, 17, NTHW_FPGA_REG_TYPE_MIXED, 0, 9, flm_status_fields }, + { FLM_STAT_AUL_DONE, 41, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_aul_done_fields }, + { FLM_STAT_AUL_FAIL, 43, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_aul_fail_fields }, + { FLM_STAT_AUL_IGNORE, 42, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_aul_ignore_fields }, + { FLM_STAT_CSH_HIT, 52, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_csh_hit_fields }, + { FLM_STAT_CSH_MISS, 53, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_csh_miss_fields }, + { FLM_STAT_CSH_UNH, 54, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_csh_unh_fields }, + { FLM_STAT_CUC_MOVE, 56, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_cuc_move_fields }, + { FLM_STAT_CUC_START, 55, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_cuc_start_fields }, + { FLM_STAT_FLOWS, 18, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_flows_fields }, + { FLM_STAT_INF_DONE, 46, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_inf_done_fields }, + { FLM_STAT_INF_SKIP, 47, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_inf_skip_fields }, + { FLM_STAT_LRN_DONE, 32, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_lrn_done_fields }, + { FLM_STAT_LRN_FAIL, 34, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_lrn_fail_fields }, + { FLM_STAT_LRN_IGNORE, 33, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_lrn_ignore_fields }, + { FLM_STAT_PCK_DIS, 51, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_pck_dis_fields }, + { FLM_STAT_PCK_HIT, 48, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_pck_hit_fields }, + { FLM_STAT_PCK_MISS, 49, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_pck_miss_fields }, + { FLM_STAT_PCK_UNH, 50, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_pck_unh_fields }, + { FLM_STAT_PRB_DONE, 39, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_prb_done_fields }, + { FLM_STAT_PRB_IGNORE, 40, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_prb_ignore_fields }, + { FLM_STAT_REL_DONE, 37, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_rel_done_fields }, + { FLM_STAT_REL_IGNORE, 38, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_rel_ignore_fields }, + { FLM_STAT_STA_DONE, 45, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_sta_done_fields }, + { FLM_STAT_TUL_DONE, 44, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_tul_done_fields }, + { FLM_STAT_UNL_DONE, 35, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_unl_done_fields }, + { FLM_STAT_UNL_IGNORE, 36, 32, NTHW_FPGA_REG_TYPE_RO, 0, 1, flm_stat_unl_ignore_fields }, + { FLM_STA_DATA, 17, 96, NTHW_FPGA_REG_TYPE_RO, 0, 11, flm_sta_data_fields }, +}; + static nthw_fpga_field_init_s gfg_burstsize0_fields[] = { { GFG_BURSTSIZE0_VAL, 24, 0, 0 }, }; @@ -1743,6 +2025,7 @@ static nthw_fpga_module_init_s fpga_modules[] = { { MOD_CAT, 0, MOD_CAT, 0, 21, NTHW_FPGA_BUS_TYPE_RAB1, 768, 34, cat_registers }, { MOD_CSU, 0, MOD_CSU, 0, 0, NTHW_FPGA_BUS_TYPE_RAB1, 9728, 2, csu_registers }, { MOD_DBS, 0, MOD_DBS, 0, 11, NTHW_FPGA_BUS_TYPE_RAB2, 12832, 27, dbs_registers }, + { MOD_FLM, 0, MOD_FLM, 0, 25, NTHW_FPGA_BUS_TYPE_RAB1, 1280, 43, flm_registers }, { MOD_GFG, 0, MOD_GFG, 1, 1, NTHW_FPGA_BUS_TYPE_RAB2, 8704, 10, gfg_registers }, { MOD_GMF, 0, MOD_GMF, 2, 5, NTHW_FPGA_BUS_TYPE_RAB2, 9216, 12, gmf_registers }, { MOD_GMF, 1, MOD_GMF, 2, 5, NTHW_FPGA_BUS_TYPE_RAB2, 9728, 12, gmf_registers }, @@ -1817,7 +2100,6 @@ static nthw_fpga_prod_param_s product_parameters[] = { { NT_FLM_PRESENT, 1 }, { NT_FLM_PRIOS, 4 }, { NT_FLM_PST_PROFILES, 16 }, - { NT_FLM_SCRUB_PROFILES, 16 }, { NT_FLM_SIZE_MB, 12288 }, { NT_FLM_STATEFUL, 1 }, { NT_FLM_VARIANT, 2 }, @@ -1937,5 +2219,5 @@ static nthw_fpga_prod_param_s product_parameters[] = { }; nthw_fpga_prod_init_s nthw_fpga_9563_055_049_0000 = { - 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 23, fpga_modules, + 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 24, fpga_modules, }; From patchwork Tue Oct 29 16:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147649 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B394345BC0; Tue, 29 Oct 2024 17:49:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D15CA43009; Tue, 29 Oct 2024 17:44:33 +0100 (CET) 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 ED1CF42F35 for ; Tue, 29 Oct 2024 17:43:38 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=utEyiP/lPS8maLT5fS+Vq8w8XyEHdZmh0xGskOmTa0ueEu4o/pv7kLqC05EOQk50DY5T4BaoN+LaQO9Cu6mwQc2NBSdFtcnD3eAhPxiaEw+tVCpgfJcv2oan7LTmH/8dr81uQaJNu3rUvsb/vAP+Sig3z0SsSB7vnDphcq2dIjiktFUJz4xLsb9DxTd1Rdiafv8MP10S0FWhZyeNSTPlnrwNj8md+y8xPJmD6U840+tt9bRVSt9YmbFBfaSyYt7AF32i00oIACfPruZEMOIuqEFD8yTVkU78yu6OqwlrzCNW+rsuc5+9wonBop5QypnRGFePFKiboqiAud262qQjmw== 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=AyNhbwh1htRVMlo2+r8KgZ/xfdd6BmY9V/7uYqIeO18=; b=a0haNHV6ohLNlJkeI4+LVY7OlzriMBWrGImC+fhiihTXn1HHxizEqYOdW2LQbA6YuhqSeOEQ1Gq+3tFAVn+PfTSEDaRTWrZy2QDspwZ8kEdsu6REx9tIPentOnwgtPz6rMbMw2Jpz2iOQWAeqt1mPpYPSGfLyKnoJXPXhJ/EVHYwaqZXp+a4kVTmaykyYxifGbQB+VMnRxbiLcpeF04UKGspbVnYg1zy4Z2Mg8hL1CZMfM5o7LEj0DQqXHcQopDHm2Zx9l24KIBmLf5AKOdys6oeEiXHm1ha5nEXPbcaWGcpTY6QTm+Drccp82TfR7jHG2dds0S429SCD7f5fPCNHA== 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=AyNhbwh1htRVMlo2+r8KgZ/xfdd6BmY9V/7uYqIeO18=; b=NHA27XNIxzetKC82/g/tAxogGZfaEC0qYGyq44fwZU8eZfcu3Ra3vBEV3+qcVAayJ0hp4zZCBduRZ1VxmdcHIM8BYYtU7+rqy2nARzElsYXMWWv5arr8tFzix2iiaPPG60e+UlY+u/k0DIBG5NsZdg1pC0U2W1qvUvu2QmD3rS8= Received: from DUZPR01CA0200.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::10) by DB9P190MB1068.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:224::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:35 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::d3) by DUZPR01CA0200.outlook.office365.com (2603:10a6:10:4b6::10) 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:43:34 +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:43:34 +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, Oleksandr Kolomeiets Subject: [PATCH v4 43/86] net/ntnic: add HFU module registers Date: Tue, 29 Oct 2024 17:41:47 +0100 Message-ID: <20241029164243.1648775-44-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DB9P190MB1068:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a0755e4-06ff-4d3d-ec05-08dcf838d4a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: ju93RtI6KIT8YJXzchjSBslHqQj3qOij4CqpN4VCAKCNARs99afq05jn7ood4fYtxRgIZZI2hW8JYDaKhC/Yy6OrlASZ3nZwOQvOyQ+NXchg+Aivk54Al5bwS9NVnZYTGDom6xWGxZ8Ut4buMUtUJWMGLX5q7f24EuOxjcaIVYiufdB/BEnSqxCN0DG7tZ6k4H7sZK4SICViRiISevndMbdXdtAgrcjsCfBPWHuJLs+beNOjJq6uHR0+d3MzgRx4tL/DcBi+5UEcaMBSOo5z/SUq7aS024HqOb8Pu0f8fU1iBLpPo5QR+iTv12ak1VY0BoG9SZg/k/foMoD+yoSguZeixaD8hBg4M9GfZXnAlkOdfHMG6SxRXj9aIOIAHCfMEUb4xEcAex+g8Oo3RJLWZGCrpfMTM2B9P8nBajJ//G++/IBsUf3nR1TewV/WEQiiahDJtHN7Z2EkCH9iX3nA2hygvVQ9V3IwfXdM6peX3xY/8rrItb/HbH5+L7SH1adGqVUF4INdoEA7bQ18Tu1TSE+uRnyzuEFip5JDTEcNsqZ82YCzoKh1LOVlrdRldZmEo+SsPnOLnOmoTFHY3jZNr8R+bsSRsthK4Ob91mEdSaLMEVt/nbQvy/a5wzju9gyGVNAa/3GnnUyiMgrNE5SAbiVMDg0OXiuNLfM3ertcI9USrCmwIrwbiqYWtlAxoxkdlOdU8WgzKhvswJsDX2zCu31orDJGg3hPpppxIb2700weNagg0wBgLnLnzxdDwXK6kDMivuzoXD954hu/5F+nz+h2Y52z9aHoXnoYU5BWWJ7waa1s2mbEEO0r84oCZFwPUogNmQPrPYlx3J87eMCi+UrGctSPdxNir9ivzUkEgVIt5IzUaQRYvYrU60Y/CYXveY7EGgjbnNjwj4K2lpL6SbdKxeYqip+dF/esEakhioHqyGvhPqvLaNFdFEXd7EZ9ONMbfnEoYGEzd58UfHWmB9iDZj71JPlglEYP00IGYWSaBcWuBIyjYIJMRhkRifgZnlN6hT1/agnL/UTWaRi4caHLfr97elTYQEyUsY2HvLZwUmgrdsa7vCDVwt7033WXjpZ1jcdqYB+wWZiBiwFCc9hsT+VzCXq/gZLVKau2ph8+t94IYWrmpvwudoow7226NR0im6QOyVDsPqZLEOQi3gRSkcTskVj1eHLWp0R3ImLStONRG3Lr/yRbe32phll1lh+zo+2c/CdLALjarlJe3yt37SBykWnjxdsGVMysh/03XDu2gFvH67/0ButyxtKanaRFEExwL3DMrKgxlyYgFK7lyuaFoONHm8gIucRHnpGAv7p12nKeLtx0JNxK3rCsvTPNJayI3p09Kzr/9BUhTFifRY9GGUtQcc6dzBlmb4BiRRMwrpO9t59Fyb/1UAuH4nFtbofMKLqVZviLnmbZig== 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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LCnLJhvVuNEVJpz/iEXnWKaICnVkw7oCROVomgrlHpGUKWhkc0NeBb2U3C4UNjB+6BfD9hHbkd5miS1gmuZbxmHygQDAUmiS2EmQuWZNkZfvES0stu+INDOnhVzr/5DSj9OMDjk0qw3N9sdjERL4X+IdK0AFj0clKMe0n3XMQX68XXqp9puOmjO1d3AF2cJ4EgbiNpjQmWqrx7sS4YrNypnM9IcCIA4GlK1nNrTXb6jYcxYDP/ehTAXH62joI+N93ZjIvcex6Ow1or9R1i17C/ITZyyabjzRbnSST49XVH9QzqwFc1FZF95umaYGwW4zraWftNiSxMzarXKkgdtIa6PLgyaY23qxYa397AvZk3ijBwEHHdbIpv5HiWZ64yjzcfNi0PDiCdd7i3rLkwDmQII8iTcF8wyJqHJtXt2H/aY1LFAGFPJsyninNz1FEueX+gUV/Fsznj3bofPl28cg5faPpbZiBEHXqhWw83DS3dF5M5nqyvS2564LhWUR5AVnskWHVN+Sf4CG7ZddS+CfRcv1VbPUyWOEDLGOWjpnvSKFJMK+ahXLM0BUpIqMr/OS4/L6pNtSZx4SP+Rnqu8APfs+B9B0ISdqgZsp3OkPVRMT73Llsm3W6sKCVSt2ViCi7XYJOUFpQC/bh1UXGDh1JmaY+zVJgTCw8l/JsfrN0bA= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:34.6365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a0755e4-06ff-4d3d-ec05-08dcf838d4a6 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: DB9P190MB1068 X-BESS-ID: 1730220216-311207-12665-27855-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsZGpsZAVgZQ0MzAMjk1NSUp1c DE3CIxJcnMLDXJ1NTYOMXELDXF0sBcqTYWAId/I4FBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan21-180.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 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_RULE_7582B, 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: Oleksandr Kolomeiets The Header Field Update module updates protocol fields if the packets have been changed, for example length fields and next protocol fields. Signed-off-by: Oleksandr Kolomeiets --- .../supported/nthw_fpga_9563_055_049_0000.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c index 739cabfb1c..82068746b3 100644 --- a/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c +++ b/drivers/net/ntnic/nthw/supported/nthw_fpga_9563_055_049_0000.c @@ -919,6 +919,41 @@ static nthw_fpga_register_init_s gpio_phy_registers[] = { { GPIO_PHY_GPIO, 1, 10, NTHW_FPGA_REG_TYPE_RW, 17, 10, gpio_phy_gpio_fields }, }; +static nthw_fpga_field_init_s hfu_rcp_ctrl_fields[] = { + { HFU_RCP_CTRL_ADR, 6, 0, 0x0000 }, + { HFU_RCP_CTRL_CNT, 16, 16, 0x0000 }, +}; + +static nthw_fpga_field_init_s hfu_rcp_data_fields[] = { + { HFU_RCP_DATA_LEN_A_ADD_DYN, 5, 15, 0x0000 }, + { HFU_RCP_DATA_LEN_A_ADD_OFS, 8, 20, 0x0000 }, + { HFU_RCP_DATA_LEN_A_OL4LEN, 1, 1, 0x0000 }, + { HFU_RCP_DATA_LEN_A_POS_DYN, 5, 2, 0x0000 }, + { HFU_RCP_DATA_LEN_A_POS_OFS, 8, 7, 0x0000 }, + { HFU_RCP_DATA_LEN_A_SUB_DYN, 5, 28, 0x0000 }, + { HFU_RCP_DATA_LEN_A_WR, 1, 0, 0x0000 }, + { HFU_RCP_DATA_LEN_B_ADD_DYN, 5, 47, 0x0000 }, + { HFU_RCP_DATA_LEN_B_ADD_OFS, 8, 52, 0x0000 }, + { HFU_RCP_DATA_LEN_B_POS_DYN, 5, 34, 0x0000 }, + { HFU_RCP_DATA_LEN_B_POS_OFS, 8, 39, 0x0000 }, + { HFU_RCP_DATA_LEN_B_SUB_DYN, 5, 60, 0x0000 }, + { HFU_RCP_DATA_LEN_B_WR, 1, 33, 0x0000 }, + { HFU_RCP_DATA_LEN_C_ADD_DYN, 5, 79, 0x0000 }, + { HFU_RCP_DATA_LEN_C_ADD_OFS, 8, 84, 0x0000 }, + { HFU_RCP_DATA_LEN_C_POS_DYN, 5, 66, 0x0000 }, + { HFU_RCP_DATA_LEN_C_POS_OFS, 8, 71, 0x0000 }, + { HFU_RCP_DATA_LEN_C_SUB_DYN, 5, 92, 0x0000 }, + { HFU_RCP_DATA_LEN_C_WR, 1, 65, 0x0000 }, + { HFU_RCP_DATA_TTL_POS_DYN, 5, 98, 0x0000 }, + { HFU_RCP_DATA_TTL_POS_OFS, 8, 103, 0x0000 }, + { HFU_RCP_DATA_TTL_WR, 1, 97, 0x0000 }, +}; + +static nthw_fpga_register_init_s hfu_registers[] = { + { HFU_RCP_CTRL, 0, 32, NTHW_FPGA_REG_TYPE_WO, 0, 2, hfu_rcp_ctrl_fields }, + { HFU_RCP_DATA, 1, 111, NTHW_FPGA_REG_TYPE_WO, 0, 22, hfu_rcp_data_fields }, +}; + static nthw_fpga_field_init_s hif_build_time_fields[] = { { HIF_BUILD_TIME_TIME, 32, 0, 1726740521 }, }; @@ -2033,6 +2068,7 @@ static nthw_fpga_module_init_s fpga_modules[] = { MOD_GPIO_PHY, 0, MOD_GPIO_PHY, 1, 0, NTHW_FPGA_BUS_TYPE_RAB0, 16386, 2, gpio_phy_registers }, + { MOD_HFU, 0, MOD_HFU, 0, 2, NTHW_FPGA_BUS_TYPE_RAB1, 9472, 2, hfu_registers }, { MOD_HIF, 0, MOD_HIF, 0, 0, NTHW_FPGA_BUS_TYPE_PCI, 0, 18, hif_registers }, { MOD_HSH, 0, MOD_HSH, 0, 5, NTHW_FPGA_BUS_TYPE_RAB1, 1536, 2, hsh_registers }, { MOD_IIC, 0, MOD_IIC, 0, 1, NTHW_FPGA_BUS_TYPE_RAB0, 768, 22, iic_registers }, @@ -2219,5 +2255,5 @@ static nthw_fpga_prod_param_s product_parameters[] = { }; nthw_fpga_prod_init_s nthw_fpga_9563_055_049_0000 = { - 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 24, fpga_modules, + 200, 9563, 55, 49, 0, 0, 1726740521, 152, product_parameters, 25, fpga_modules, }; From patchwork Tue Oct 29 16:41:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147676 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB67945BC0; Tue, 29 Oct 2024 18:18:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C40BB4328B; Tue, 29 Oct 2024 18:17:17 +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 94F2443293 for ; Tue, 29 Oct 2024 18:17:06 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2107.outbound.protection.outlook.com [104.47.18.107]) 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:17:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MitH7/gzjrKCOLeiS7GMusYCdQ6Z0aGdiFyQRrQ12oUcWCqn990seHmNLGPIAHOBE8aBPibTH/6VueKSCQJ1/AJnFbviroWG8iAjzHzqHEGc1a2ORiJ3CR4J2d0tfxxbSOiYVq79xlMTasnQFCfF5Uc53JXl60HNEWTOYshekraTcOQajVCgnBV/BLiS0TS8UVuVH3Imwvz+o6X0I0SwBP3f5folwbcYDabKRoMLYSKiqCbKm11y6w8K6CSqm7cGMeUK3YMffnwhoRZVBcECPY+pQIICFl36sScMl49KuoqR2u8980InH7enP7hrU+UQc2W3YILqRgGMKGJ4/Vmvrw== 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=mN1p5G0MTKTOUvZhzoNA+wil2SIMafO5l2KelxehsRM=; b=uIhheIQd3ak91EvZNASALaQQ0g/kOd1fZaCylXA+EzXzm/4KOwS+fCMpHB46wlSTBmlD/YtWuUcrfTc7Y4zbHQRb/pXpD9TXJixhhNamn+wcqnXQt+a0BqCxheHBttOReT/jVvn1/p+fmNkZaJIH4oOBbClRd99kT3RdrTd4ZuhR1So5+jEqZAovROfUNaboJ903E34TBpjxM3lz+d0MFx0pIQjkDaNl/BnwTM4EPrLNaUjwkm8SfaDzP+UjpghOmo1YaVAmK/3St0raw3YVlvt81iUKqUtxtTEyPfbXQsgXfJyRRNx0keJsky3eAhzx4QsCklEV0SzmsKt6o9L2MQ=