From patchwork Wed Oct 30 21:38: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: 147769 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 E9EE545BCC; Wed, 30 Oct 2024 22:40:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 248F24339E; Wed, 30 Oct 2024 22:40: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 E68AA43270 for ; Wed, 30 Oct 2024 22:40:00 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TkOfB2rMaOFJE/EKQMOjBc4c0ea811cdatfWPkU1t/wYZl/pp/wmQ4eqalrM421O1jpxWt9Yszn5rvAUyoewsnUAvdRvh1Y0DAm0M/DY1Af2m7icDlsXGo9GksiloiNOnDTRJfVC9fBQqCQwjxlvNe+M37lqne0yMOH2kTFdpZFiATnatbzlv1aAhg0eQsFdHFtm4S52E3IYG1Cw0IfNKE46BwB8ILuE7OBjUlGzYt48D6x+wH0ohUgY0O1ipszQLUKWlOXwd41YBTfRiC5qrj7ldZFT9gdCHgV/9nBclSGfD1m5PcqdNkKdTA3INUsZ/+l+xGbpBtUrwIiF4UHCcg== 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=xyIKlwqFfc4w1V5G45zbP2DZ2Ryyd19wG2Uu30yP9gw=; b=tV6UWZK/NUjLoMvLHGiG314t/j4wJ0RxKMSh8XVW0aOyiKLPaMFhQOZywsQgET6zoO2hOnAok80RPvt7uwkDVMNNm29J3EgW/GeROSjstY69sWUCx4GjleD6i80Zci5X1tUJcUQF46cXM+3Fiars+vRPBYRpWHuJhTcGoBvoHxF+aU1isUKMGeVHlhy207mseF4gDzyGFmm4Ks66w9HVjIkDsIFCHbNm6UvFYm1YGUt+xNXfMy9hAx1bX4GeKz6spgT6bsyDskRTfu7DQQ+W9wfkNUZ5LQT01fka8mY2AW5QHrHdZvMwTXsZqUCwpkTQzAgisLvnjcxthxeaaYz/gg== 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=xyIKlwqFfc4w1V5G45zbP2DZ2Ryyd19wG2Uu30yP9gw=; b=UEvYCE2l2Z4aNgUV9cFyOLvk/fFqJQdaQrYxfMXwCmEpNvVqtyOO1EeTx+J8oso/AePaUTfe1l+88uXeL7jPkFNQuS3x+95RzMWAOfcqFUumeW09ASekjEfZ1kgUwGXHtZvFH/ihqRc+yKuPeuBv3yBM3bFT0hFK7FmlsJgax1E= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by GV1P190MB2092.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1a2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:39:53 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::d7) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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, Danylo Vodopianov Subject: [PATCH v5 01/80] net/ntnic: add NT flow dev configuration Date: Wed, 30 Oct 2024 22:38:08 +0100 Message-ID: <20241030213940.3470062-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB2092:EE_ X-MS-Office365-Filtering-Correlation-Id: 60120173-70ae-4115-bd11-08dcf92b6320 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: GELVOkz2dpZ2lXJmnwdF8kWKFeQYUP8oHJhkUIfZKyCZ0h6giwWAeLD8hH7S64Tg0qdU5Q7P9dBkv96SMZgxCASxCt6iFGv4Tlzememkh4E6jHKEcUUxorIa3poy4Fdt+qA1H/ma/h994EhWkNhn7nwgmA8iN5n03IbQvyMIXK22TsJ/Lt8JNTXN18uhoKgQCPZn6dmw1RWf1qtyaxDkEHRslCuz7c94SxJn1anGBEIc4PTKC8Z7VZHTQD46XQDNt8HhkqEPRYM1RS1Xd0wEYJNKsHrk2fhW17EVeIkNKq571QnjLHEQvaqZRZusLFk8TsSGO/UiTSPEoPtFmcST6ZDeIEk1aTAnFB4YiBPK/Vp/9G4kj2e4jF69Y6zoiBseGuGEuE4byQjf8PFj0IJcPxCUDQTtTgX4cHRb2trsVzesmYu5kdpN/RiGMu9P6pU59cmZSTCX/3A0P6+9LHctL7LugmGwJIUZUqIqjJaJq3fl69iUuC3IOpdD4ROQbAGXbzRXWfSeEsOeV/7Go2I6efmTAK/6bpemHiMFBpPFsBREvX5+MXtzYxCd747Qg6OXVLAWJT62PreZ2mjVi3Y5NAmUDMwSXYXmscV3I9oDgcDC6lhhSkRKBQ07LhhJu2xOpwu1/6w8WcXh/fhqB0Vst0/T8s8cA5RtVF1OTxE2G+kFy8718HqwxODNzzdhNlnKOE5dz8px6ca+yGDntbYc3O1eUxAbMnvQ6rN3DCLxrjirrlPnhg9Hsu1HbLqJ7nwlIc6/wzbkWGL3YejVdACmQgvc+K3ShIBiSxfL2iywAR2egrOzw+VEA883dguG7OyD+mfA5TN7xZNx/GI3mzLPKPPe3h/p0/HjdGUnLq0hVuOaVm7KX4IiZB55SHya8TCLO4Ar4dgezQuxOlLSxvvG3MwjkzQk9dxCUaJ0WnJZLQynxIZruwo+/19lgLM/SXLDjmlSmHwOrb45LClro+mQVVulevqt+7pu1mmkP8vPuru2f59iIPHilFEWo9u7xyuJ3ywKiO7mXe7zQFBUVrqZjIB7X1JQUNdRJ46A3iVpjxIHQZBcXu9EVn9+q2KLhM6wMkVBzi0f42mGYtWMTRdjU6CWjVQrb3PimOzBguLcwRm3DWESz/2kzTKeFAxa+7BhfoAmD5pQ4VFAsfG6B7aAl2g6pgPiJ/jFseg2oPapEaQPxIMd6WhWqBX9gpV8KVly0N4WSJNNgFzmRUghKOd2Wid+awh2uqS/kAg+ZlBPU059M549PZWTj7bV3hcq1u/X/Sy3wfAZFVYZiaKeVwLQ/j2r91SuR8zJxIIUEJLQdiiw4EvdQU76TDzodtDsLRqsXzaBdvN3tCA2VNekmuV6pyYX8IQwUw57zVvBnVQPe7m1jx65NdnIOzmgHTE6UFUz+tKHkUKDt9WUwHcD17dBhg== 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: HcIAC2wAdKSvDxQri6V3CdaPPL1UDRo8/IjfRX/DRfmmmWbywFNCnJifMoyMcqkteKE5I4ruPXW5Yq5GV1J8jbJYbhDeAk00QktOBAtEdSEs5bGojO/vuCZ7RuXQnB8QDpj+PsAWfTy7UTtlXQG8I4EeMS32Q8e+BJgSZCU4ICV1HiWzMpy7GgvglF7iz239qzkYJUL+2x/bwv0zEn3RTbEe0s0irbMKzINPjTm8Y1P+CMzuBpljTcyVqEqp/1pUp9uF/zo7Ws27IhwncOrnyw246HNQm/kE6FlHwZQBe1np5MenAB7pC0Qxpz12Cgo607LXVp28zx+I6nZ0R2HRPDxTZ17C6c8FiE0djISC07ZjwHaEJLLtlx7DJO8q//UpwMETzvCtX9O3V3PVzMyOHoc5B8znkeLrzc3A5CfUV6ab8aCTudh9I0Wp+JDcTguYTwNtu4fOIysAvkgG3SQFblgLk8eVAy7BvEmRdi70HOdA1BtkAD8vT5Fw2bhdhGmILYQ7H90c3HvXk9XwYKWC3D2HTwz+PpoP/SbzHEpSXI8cTQjhspsUXdQLnPUdeCb4E4cBDS+TOouDibvCnwH4GM6ekX8nXO+Hcju5av4fI9SMCYXMPkRMaFXXFRuwJYTUjvwsAuPtn61WkBTballmo/yh+wjO30syRX1YB8dqKWM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:51.8330 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60120173-70ae-4115-bd11-08dcf92b6320 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB2092 X-BESS-ID: 1730324397-312176-12709-40648-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZm5maWQGYGUNQyzTQ5LdHA0s TAyMDCOCXVMjnR1NLA1NgsxcwwxTQ5Wak2FgD3gV3NQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 This API allows enabling of flow profile for NT SmartNIC. Signed-off-by: Danylo Vodopianov --- v5 * remove unnecessary SCATTER_GATHER condition --- 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 | 209 +++++++++++++++++- 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, 285 insertions(+), 10 deletions(-) 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..7716a9fc82 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; @@ -156,16 +225,6 @@ int flow_delete_eth_dev(struct flow_eth_dev *eth_dev) ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); #endif -#ifndef SCATTER_GATHER - - /* free rx queues */ - for (int i = 0; i < eth_dev->num_queues; i++) { - ndev->be.iface->free_rx_queue(ndev->be.be_dev, eth_dev->rx_queue[i].hw_id); - flow_nic_deref_resource(ndev, RES_QUEUE, eth_dev->rx_queue[i].id); - } - -#endif - /* take eth_dev out of ndev list */ if (nic_remove_eth_port_dev(ndev, eth_dev) != 0) NT_LOG(ERR, FILTER, "ERROR : eth_dev %p not found", eth_dev); @@ -242,6 +301,132 @@ 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++) { + eth_dev->rx_queue[i] = queue_ids[i]; + + 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 +568,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 Wed Oct 30 21:38: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: 147768 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 0C32F45BCC; Wed, 30 Oct 2024 22:40:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D59674334A; Wed, 30 Oct 2024 22:40: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 4F58F4326E for ; Wed, 30 Oct 2024 22:39:59 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2236.outbound.protection.outlook.com [104.47.51.236]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uINTgsUDXu+C8KytHJURCzPYnDSrDzNxA2iNgv4pt8tx/uSN8g5B7+7wZAhEno8UQt7ufkC4aifmctIHjYcKIdGWt9ADgwghhLkzie37camjIo1L/oeAeDZGUbldpByRpjHJvrh0qvJRfUKzSYIUw4ytha85kLQ85wsC+aS1T6wKsgrU+FzsqLm39aUCJ7FZZ7SN/8wFdKssKqlGnDKr8DAhPcTKT/NhQxB9Z2tNCXCJNkX1fIWMMahvaqZu04vnceystJUTY/4OC78qeQ7kHr4jSydfbqgUd2z/Enk0ndUYnTbwiKH6MfKj/z0bpGp2lsv3HrefvohgjbstUvarTA== 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=KrsfdNpEp7beJqBwojElqzgmOmG7o9y9Xu2xzpuhcAA=; b=bm4q/PPz9jBPFGPXcOr/5g2RgvkExWlUkrQpuZXeKtQD3zXklrJ0sab9nUXBHm7twBLatEMrEyg3AX1XNC4f+A4H4LFO2VZ9OFFkR+eJFZHiQvoz3drybHmatZJX2vEli+te4DSS0QL2Ur9rNHuawY361ri/sLnG/vQJH+vS49LXDqFFj2iBPwIxlFhCvFQuX2wNQ5jx+5xZOPdTIJIhRQBesuvX4k7wIl+qzUn0tcUh3Sqhd1fXfnzP9nkuGjMKkqone8JrfC+DXy/AyeJ2YJuArUmFrY2AfFxd+L1FfmEUIGVR2NQpogPBKiwae01WQYR+7ocE0Bwi0U0FW5t1WA== 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=KrsfdNpEp7beJqBwojElqzgmOmG7o9y9Xu2xzpuhcAA=; b=BJ2jWcwtJQ5eAEwnJIE6UXZ5aC5aQQ/KlsdMq9Czo5KKlEn9xsf2mZcaqp5BREMszZoBmr4j9i0/C4EuHs8UROEvalpVTkbd1XNvBGczyGWwOe+/o90AqTp3AF9k4+ikEqUU3Wfog0q/nK8o/KX/cmvdEybRzUnr9cTPh9ecwu4= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by AS8P190MB1237.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Wed, 30 Oct 2024 21:39:54 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::64) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 02/80] net/ntnic: add flow filter support Date: Wed, 30 Oct 2024 22:38:09 +0100 Message-ID: <20241030213940.3470062-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1237:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f941c85-1637-495a-ea8a-08dcf92b6451 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: tT/LkWespnKY86NWpdx9Ey9JgK09r8AtK1kI5hI1/J9vFVV5xEjAecNlc/UaV4Y75+W6n/svvMJvSUUoqi7RVBNUAIh734/WOxR4+dFQY1ISPRIyfX0rTwEUR86TLW+CJ9E3Ci8yuu6K9OMKQ0LgJsKz56fGumz2/sk49t6znUwCvInZzju9IK720hkZNdBRpcEyIuuu8lxu/QdSkMVh8sdres+RTNbSDNt6z96PWu82GSMahbEp8E/s4TlghkfSj87r2c8aE/F3VsvqrTKjIWAs6d9tb6SExlU4BWiUccmpJT8rK6ORRrbS7BknyDIvJIhGgZ+uYce2BqlVtxaJzuzFkRwYgoLNV00EerOO6w9FsR4n1B9MbVkbhTLhLTuyLx525i2qCZQBYj4uPSeBnXQQBMc9MC2Er91uNo7FCHvlejfn530bbjuW4ltG+DL+Mmhy0TrWo+JdcCBmD8IoUyUKMjfg8im4Wrv5KffIw0H4FIzL/I6qzsdj4VVHj+kbqW5SkJzmXNlkmPJmhwAczrllg+W4yArmNMEoMslCfuNoKsFawvSebxzTVrOW500jZuobiLd+l0AluHRltWn3S7p6PcPsDQy9q5yYFb+lEg3Y9LaPKFDeR54ytPI3H3Y2Ww4ztCzJUINhncZptUsL3parlSJg7vw2IpxiQgL8ZqZ8Dpkacy9lmPbZSuzplw4oEiF5jCe0MQHDkHnwS0X9Ttr6F48fIhuuajw2HiOdm78voXD65yirKtwPAIf7sumEK+CNVdlDTo/caUr+5UkW0OI5g+k7V1PXlyb1bVdAzBZxI98NbMn0AMiKKZ+dG3IByq6NcrNnTdi1qah/vKK9NODDRTRTE64MZbWADVW6FeINDUsqzAGKMs9SPd0yJhOYtDqXkLU1sc53sE9zmtv8av1mzPBGhINslgatYR8gupSBbgwoaVW0ttnsNkjzv6JqouQmuGibToNYz4DI9zvUEWj4ZetqAQNQ1nKI+y80SjPuuCf64lmjzpRUq2u7B/KJQexzh4BAKrpgAactjKxLZl/Kk3vNLBJ27yeDUVwbzOR8xrdHEKvKJnt2ZSgq1HcK+i4QuGHBTsqLRjsofrFCZYOf1pyoKoMxaWd/B3rpfDj9mWnNJAUiXNGOcuYMGM0wnprw/nRBNK+YDhlhwLfamr0zBjQiJsXFPU6P2Rb+RXZQWFQrEBAVA59lXI1k7cEs2piOhRluElGJ82gg6B6PD9KQYDxDsxwjG972rLWo0HkRDiu2OXQc1BvbRPGFpHS3fj4451AWTJu/I2k53JKVgXT5n0Xu1Dqu1t3x0B0ouPSOMG+7qM5Mln8cvKtgChq88UW0Y5Z6cEAVTCl4I2c9rv+JZHnVcJEjVGilxUZinfDO0+ZDgSMH4H7sEZxDHmGMKWOsD6X2o76zO6h8AAJD7g== 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: PVywU2aUuVHdcpnzKPOCIcwdFi5wVKrd7kOJWkb5Tc8Y4/+cE7X6vjN6IxhOFpQcC6jGZ5RL653mTzgj4llNSjP7AUnh+cIzup8JXL9Hf1S4qK91L2DgnqL5All2GE8WfiQ4i4/PAqxVxRmetIiKr5S3gj/erPNkdTarxoJplkSFaJgrSMMkZr+2m82nt7xTyQRJBL/9yT1Zu8+warfibPHjhsUNK8Lu3g6lsE/W168TnfilLoQWnU06zBLHIjdZjha2vbpuRw9+L2iY7nIskf6A789hrPtEyjXSpYG8CawF1Ehf8g+lKzX9Gntr3V0Sfo+q9si9wxWaMRp2+7mtHf99EqLlLLFjoSqFxq9dQ44eSeOhLe9PiY094jzVhUD+pmaAcNL4IB7tgdRhSfI0k0JuqM8xmxvXFn4r2xlQlBzt28OtCHeGlpaIUKLfzFlQtKqHlRDDyYJLV7yl/NYiILQSGHyVDz4zeT1RXrahUYGcyDmRXZRL/mjL1Jj2mD+JFVDxI/v0uFIDwQub5lzFnLCly9CPw0TEg5Q0B0h1m8D5FzhDppNHJexeZjYaRll7bWOPXN6p3jEWLhnHEXbsEi3oLLV9MAcTa7MtF3j4VocyNTCoJY7KHzKw5Ixyec22uO3xqP+HViOxdYm/xXPuA1QTqJFqsOmnsF7u1MngdoM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:53.9111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f941c85-1637-495a-ea8a-08dcf92b6451 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1237 X-BESS-ID: 1730324396-304433-12637-44603-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.236 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqbG5kZAVgZQMNHCODHVKNHE3C AxKdkkxcA8zdTYKNnc0tDCLMk01cxSqTYWAHjO+/9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 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 Wed Oct 30 21:38: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: 147770 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 E0E3245BCC; Wed, 30 Oct 2024 22:40:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 216A9433D0; Wed, 30 Oct 2024 22:40:12 +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 0DA8D4334B for ; Wed, 30 Oct 2024 22:40:02 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2235.outbound.protection.outlook.com [104.47.51.235]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ek2M2TaSsNyf82l0ttn6R6dS+J3Eeq/CxPEGkSGlZDDFA8vmeBeylgMx66kfjutmL65B/QRMaXPczcH09Pt88BmgOJeRFIiTQDo/1cmW8aAKeJr8pHch5aML5LCcWJ91MdP2Ecck8HemzqD3r7pyQHtDI9eKMuTLMzowD5QHjEHsOx9fwAMk9GLe2E8Qi0NOJ3FGY06E8G6/5nmNrFpYY9V9Sk4ftPF7rr9hqxywRv7ph3Sugw7bgOt8Zg7Q/0iPBsJ4Mv8m/jeybN2Z21AUTwh/zMca9iLZ2bNMJxivcWWglF9q0y9a52+qQL96MgkmCfrYFVFlXnERlFPJWcTcwA== 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=oBUpTYwQRzziaH/IZcLtaCTbuLVz19dex4XL0Ti1mts=; b=ZVQLhhMR1zvDu3esK2axSe8ysxphXLJdSuMh/Ihe8EG+4/bOWRYEfZ/UjWbNTnqEaRG481BBG27T2/2lNNZr1/E9LRTRsk1EOZHDpjHgcBh3LV2l/x/xxCviot+aVk1roSVbhBdg1iP0xmBQng62DUZOGhazP8oLjrNPKTJfH/NJAnAcZx5XGpBuDbrN4rc7+cFG1u4aWwQH80JyWWodr/UW0Tj22tJTD/Brve6p3JkBdmhJgME0kCvOfgV/Ir1M1l8afB4usLJ1EBdwb2uPL9RxhxYKtzNCuGvIOu19nZ1RVj4ShMb9EOAkkzP++GYVjH4kIIl3yzMHAqQmA938Lg== 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=oBUpTYwQRzziaH/IZcLtaCTbuLVz19dex4XL0Ti1mts=; b=IVRZCCT7k5QJDu0UbNpr66WwS79Wsz8x+gzbREgzeacEjTlwceHPgUgfZmx1edZe9/GwRuXM4fbTtS20LV8pz36Y0u3K3t+OdCtbwhMJZWJb/OO3E/5btZdZ9AdXZP+aLc1wOEaEnVdS69Vtbbhjk+ogpcEEjjibtxKP6aYm91c= Received: from DUZPR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::6) by GV1P190MB1995.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:5a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:39:55 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::61) by DUZPR01CA0013.outlook.office365.com (2603:10a6:10:3c3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 03/80] net/ntnic: add minimal create/destroy flow operations Date: Wed, 30 Oct 2024 22:38:10 +0100 Message-ID: <20241030213940.3470062-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB1995:EE_ X-MS-Office365-Filtering-Correlation-Id: be7b66be-33db-4e4c-a9b8-08dcf92b64d2 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: GouLVwW9lD4Lw11N4DfwqJ09w2C/d0yJXDf05l8Vh7HBkC7yU7VeoDMAUavoCf3mpY8lOLN52JWLWhaaqEqET66W6C3gXTLlEKY/Ey4S93ZSeNZZTy5240y7w/UA1VuEd135504Jq1ZxvGBR3L4QDub/QWNzRvZr+1wFCX/HleM677jNdY8VXTH+pSsffiOZriA503Uj7/Ujh+v/56gxqa4vNw3rORBe/aH72juGiopwzzYI0NJZUlYUCbAUE4+puD0z2nbFu7vqCBsbVNEW7zyBP663/O/1CZQroSYdPUUoylPas6o9m9iiVxO1ysBOiGju55VDade6OGT71+5qBuD3NE/ZDghCCj9dA5mLrIzeUY0vZUSqT8ceELQnD3pjHjOIC3cUU7fEpUUsNZQc6m3mDXesJ7zt/EbybT/v3ArFovXga2HgL0h1sxumzAEpLlzv6jBpkkpLoQKvGnk95htr47yV9aqu/fLEHm54HjjB6m32t4hN+Wr1u4kNfyB2VQ2ievWjhXvOElfFSh9buSxetJEF4/5sV7570F9lMxAId4v5oFB7aZ1+lHi6VtQwEz0KtU8LE6GzvB1cbQWn6S9Pf/+zZKfkf51nOESq0Py8YQmQJiZ/1M2i+USdX1IRgVO4FvKylRTWboL/3t3+zUthZtoG3PHP9gPnuxNzszwOkpiSpFqwY0yC/JtGTDvldV4WCHbYjj4NCAgZKXnPbYjXaGXR/ZpXIVcx9S4Tnsya9xSTa9uoTKZVyDw93HG6cFBy0iqeGgyVOQevXzytQga3wdp4nXK1O+IFLUO991pvWtA+i2pZi1YWgCBRfChyUqruJP+qPOixs1RbrL6BhLLEmz2Z3F4IzIRQ4f+VCbISrNj7YWZMBpX3SnJ8XHLYHDGMu63LTKSDsDr7gs6hXMm9vtdryKntCzTCVIuA8V+j36XEXQX0bGiZnJk2+M5WSw6aLOynEPyHM8t+kVqCKJodShqxmpFtDlmbwnNUjo6kyhMPtMtR0iBeEPKhqcm9b3VC1fvT1tR3DixL94b2Y4uEygXUlW59HnGbJeRv9bdoRRyog/S1KsPwDRelqBXgulfr8oBkX56nMpprPfRhdmr7Rl9ad+eSjusSCVlNQ9SOiqLSBz4tCldaccQu1f/npzFjn/l3QueLdHrl6zsMiIl4Za+sJq87F3HpVht22RRDjDbE0FyfLbpbvKvUfFG9cMHkAHniX34b9/ueAYvJWfsNBwsSc2c/c81JVrfHyUI0rEqCe1pNn6QSwQ17NdIg0SOkk9ti0i1DKIy70kh5vzmxohlob5ybtU8vXQ+/Z/Foj6ybAarbKAkwhsQvtToUePU2acPPv/TOjauzNiQl7VIG6K4RMje6IbsMTEKmeV/4FXnx5ImZBUSRIQJgdCcKeKjRGclrA/F0aeK9xRhH/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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Rzzq7HVoPvye+qXRmqR683NuB4VBwKpDkqbh5DRXN3vsl49wdyF/rOJZYwBgk8VUA7If0+vQm84fs9ZIdrPU3e1iZEYSLsg+qoUaq/0Wg5xZ9WiGZZuzx1z0qsgFbBhrjbsscUmpw5LZAz9mFSFq+RnTWtnMlksT+J70cTMH2cv4X92YTJp7Bulta37lBpI+sh6bwI72NFMkXYg2xi7kigGBhRsl9Zqdsp8/Zw2xcfZy2mc24HKiAATnzV4dV5t6QfPDY6QkhDs49hejfHh367dHBDazJ5Ko90qdTxXJ6Q7hGoBdoT3hMSfFqQwHjpz5Iy5CVtqiBWUnln0BpukL5n6mHqIZrPHD+PSyPDET1/r/YUEhG+VuN/g2Yz8PM1/vBxJrtHfx6bBuTAIG4ODjFRrGGTI83v7dlJL2Ihc5ko4/FLuBMsYqMkQq/vW13kw8lZipaDscuQJ/R9D7eJ6OvD671hoLObq3x59QjwgItXRdZatLPbgew5dbC8mRhoAAULpToyryteqCZ6Rzw3KMuSG1S+phiWJ272hQEDV9kg5/+nhh1L9m+athtFd6KoKR1Rn16/4XvtRK0lcG6pQ907j9iCuW6EKbkq/fsvC5N3zSns6gLf5CVxn8+8nmtMkwGcJEzupcgzpbCadv2UNA8e3+gcZMYnRTmwMLseJqIX8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:54.7392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be7b66be-33db-4e4c-a9b8-08dcf92b64d2 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB1995 X-BESS-ID: 1730324398-302901-12799-43447-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.235 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYm5kZAVgZQMMUizcDU2Dg5Kd kgMSkl2cgiLckozdzE0NLA2MI8NSVVqTYWAALuCbJBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 flow 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 Wed Oct 30 21:38: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: 147772 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 DB76945BCC; Wed, 30 Oct 2024 22:40:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BCB04341A; Wed, 30 Oct 2024 22:40: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 D18AD4327C for ; Wed, 30 Oct 2024 22:40:02 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wpInexilSEnn1X9pnDS+Bo5ugqKERc2tfAOlDm98QbUiZVMe9l3jKFOyEtqCvLCvI9/C5WxgIZIN5LUF7zO9E0ZxTY2G5H0HuyAZcbUQhYdtHabIUdr/QRIrlEtIxiv4IwRiZ5Mdo9J72cxYJXQUvOEe8zQrAvPwpOH5PD/xRoSaO8r9ZpInZAiv7N6DM3sECZjeJRrLlCF7Fj9FtNpMhTtZDtXVLt76LiXb7ic/soNMX0T7F2RunZy9etPXIIx8ZCsD1htNclcAlKCFFPs2XveP0aZUeLT9loH4KyzPb0Sd5Z5IlZMU/vbEXLexVGihXi9yZc9Apd1vdRdBBBLYmw== 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=uqg0DeA27PrwyteJ1FLoUoSxCiLLLKnpAcGKsB3n6hg=; b=M69bFbguQxHBXFKGM8MTGB85jQ4YAEEibBWoYVJ6MF0V8d0LBeusaF9OnV8IOdRuT0067Y3n5qq0o0E3+2T6m8tVOvXg4elImhJEfQg/SteLmztf+paCfFzcT8JGfJfKrQB+gtEwdIRJd5GICuuQMVRegaSnch7gvrmF3o2DC+NJWts38cuuAH0cl5LJYHzLOU26UsydCtxR0cxNe2B1ac/uzDm4+Tkw8LzYREcwAKdaDoTwWsCZRXTcnhcUZ0VIPKpUiW9M1bF5lZmmB5ImRZGWxvqCE76T6bOwvDdmrM9+zOxskg2uSP8tjxJI2jvGhvhzm6yRnbPM37L5GrkhoA== 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=uqg0DeA27PrwyteJ1FLoUoSxCiLLLKnpAcGKsB3n6hg=; b=C0lDkSQQ6gvULyjPMDHKc7gZs30CiV1ydnRBqNTsWI5buS0kFnQDOEMIzXM4wBrgKYu2wy2ji945AE1kKhxTFdCV2hSQn1O3cYDBo+BQHEgrtfhEcVyY2Bn6TBLn98IkVWQm4/GMJDXOM9698XOAIbi/TvfU4JEgtHDxsHuKcR0= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by GVXP190MB2148.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1db::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:39:56 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::5e) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 04/80] net/ntnic: add internal functions for create/destroy Date: Wed, 30 Oct 2024 22:38:11 +0100 Message-ID: <20241030213940.3470062-5-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB2148:EE_ X-MS-Office365-Filtering-Correlation-Id: f4b8fe1b-eaf5-4896-03d5-08dcf92b658f 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: VHA++OLSzVMvg//5//ZKYuUmaA+nkH39OqWUEOWC62J3NzzF6XV+jzQRBVeOEq3tZzjcMLd5bVm6rMmAglKlzdOMFLKY94LOzTDHLH6EIovQuND+Gj5HGHq/NDE6OiYzZAXNAW1gG0kYVl33xfvQVpi6n/THYCiQYO5vkQxrsLW8Ialo1izdtgT92YFBYJz2foeCJ4JsGNR4Q49K4wVTvbHVu3T0kBa2QFoNlJ2I/dBAc1rNC58H5TSNyMeRTVLsR7CMv2PXzf6/4O++oFAmbygFg6jBW1ImzfGb87K2Tpo+Ue7GFC0acoJlYpMM5VkMO/xGHvL6wMVg+G9Z0rgMjYB/NC6g70tmfYPN9VP8SQCXwbgiVJBMv6DZiS3x25jfdU2I4sMvCWB1WHmyVknLex8CM0mTqh7xtuSyrnlAYxDhceX1b9trZlYeN7RlRMJqvxsTTnQaqLzcW2VDOxguIhnqDnFyMB769CMl7qdoDA2wAEk+HgPa+t4zm38MS3aDe08kENXZ4yK6W2PtTeA1h8+OzjRH6Xh0SJH6IdnSdr7/Grp79iK6p+Twli6zJ81y+n2cdu9lU5++lxjUmMiAkvgjvsHPRIL0+UMAxcemGpFv5YinFJMYihr47VW+47Oeaz3xYN9sUASp1s5P4InekKEh7PY1Cp1uD7ON2Hrn6Vc9gtAITsmczaEq1oUV3310X323YBNH71JFkhpH2AyWglofsSPGkYCvjp8XjhvLL9u4XKAM2KjsbbPpfmKiOTwAcHZthr6vVkNYRZvdf+XX2KJ2KuTO+YXH6gxCmx8Q/b83eejg4Vd/P8woN2mW3DslMonfeKhAg46efU4OoKv55Kb0vvLtJYoaAhpVmKmgPi20FdUCkfzyWxGHR64J0iG7RKiKPUixjd65JXouQilIPI1y9ROJUxNY2ulMYs2Eukj5fOMoEZY9ClnzYBv8ZkxJfyM4yWf/vG7LMZE5b3bson0gyxg31dihf6pZMcgQ/oHMya/NOo4LodmzLYZycqBIp6O9jYvp2/tBleimaSes8BqT+13USlTxv3Wh8QXqbT0LRkBXFPlNkJWOkGQ3EAS3pr/OlEF5hW1juCKjLHQAy2DEXejm0vU7lLMllWRAP44Bpt5nukdERfutLQ73NmYi5r/0rMqkQq6wiCvO2airkb90cASfK3mWEzRsudlp97/SwiuPx+TFxXWo5lfr3/2Yv0CMrt6HQkCOuwFNEnIxA3GQMBOgKsRK26JdUow+kbaPOhycHfDC9aiFCpAFnGAAJZF9RCKLSG/M4WY/cFLSL3AAf7Bg4t9ylbYFUlNtk6RzODP0j1I2c/B+1AASlK/tI0SB1Uz0IqINv8Eb4+uEMfNAUY+oQglCk8KKyMF2MDFTaTtCU/sfkWwXhsnjreXYRCV5EfTML16889Xa8c6Kiw== 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: qLfZirX5bBL1LI7LaCrRUxsKXJAFHAiftFsLBR5Kee1E8XHbtQ2OXKjZ4O1X/hebNm3eoo6vT06835z4T4Pd9ZZ8eLGN79xJ4ddEnlhGlFKZ8t3uu2dGLwCTLgq9fDA7CrtR0NUFeK/IESntf8sXzSwI1QpkJhuC54V8LWQYdRI37lRoGeMAYI+QQttMDbDJF9mDlUd3V/t1XiWeyF0cl17bqYu7Z2b2lLsB5+Cx74Y/g/etIAxJejTL9q5aCOyHlBrSJdUmMg5pDutd1gWw8LjQ9eLdkhfO0KU6CMnHQoqyhPxhlIjlqr0II3QEel+x2pOjyjYV9sdRto2jLf0M+adL8bw7zVs9H3m3uNNJ1MT6rojTrYQRKOBy8Nzuh5a59FMpKpmk8M6y7JXsBs7Xmsq1gzNsm25pBM0SAfhpVY0YucvB+oe+joN3Zpi8AXIhMhFJHA1NMcsxEQ5l9ihGwp+ag9VnKc089vPQNNVXXZ71mQt31TnopwvaJfkGzPFNzTKFtPaeAtL/Vg6cc6MUoHEnvaIOVjpb/WVUa5xRAZTVsyIOWc44hzPa1TBpYJfqOEjAnDVde37p2RiQNib5RH194chIiDm50NVSs6E9smmGUHfLJkmyvTUK2ucPQnaEBJ4nBHJ1k+tPMwvclDcZaxO42GTP9uWq7yJHJ3yRiqo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:55.9892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4b8fe1b-eaf5-4896-03d5-08dcf92b658f X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2148 X-BESS-ID: 1730324399-304433-12638-44607-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZm5mZAVgZQ0DjJ3CTFONHA3C TVwsIy2cTQwDTZwjQtOdnCwMLCLNlSqTYWAOHJz8hBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 functions 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 7716a9fc82..acfcad2064 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 @@ -572,6 +606,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 Wed Oct 30 21:38: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: 147771 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 9444645BCC; Wed, 30 Oct 2024 22:40:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4353F433E4; Wed, 30 Oct 2024 22:40:13 +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 58E874339E for ; Wed, 30 Oct 2024 22:40:02 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HrPCRIOEvOZi2JkO6D09SDpINcjhu69i4KARDCSZGEeu3LRT5CcJAJ3/ZuXjxWXHXInp/lBITdDTRJynku+7QudeMy0J7NGRMQ1FR7fpDcedem36Gl+XS5BMMopIFddszwNeN/KpSO9Jgbw7HFXf81jZVvTRsADVtVn/WF7hW2R6oyzpdhCx+1GmIxSN2W6qTxdKnRVQ/W3e0v4TcDah8Vyy/1j99Wv1uNK6iY+HmkwS/QSwCuLbduktjpUma/pm8AAbNVcG78Ib1tl2rAqARvFBRwaSBcsqFvpBGbARtm1yyWIl12A3sTUqI4BwrCpuwvYHdsoz2O48KzKaFHx4Gg== 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=3TPDQdz4v8xPMoPJUkKtoldCxZWgwM3s9N8JxfVg/uc=; b=oenI/LATi7+4XdSIRAMMG1l7SelnQBS+k1nA6W54yKwXs8ixUXrgBfr+z+uRAecFiQfzi7uYYuzA/T3nGVCBY/RRpvMyxFR3RqJKm/T4D0obIrgdm9EyZuiPEVJXpX0KJB/j3cxD5GOYO56f2CyKQ8PsR/6z7rsJixrGDVje9AkEAV3PzzW7FpjkYEyUsQxM02soB7FTHo7Dm53tXO0R7iq4wWIMGJyo315fPDaXwWTwiORcyguzMqYBYLG1g9ugmW+Up5UD5bTf3WrriW97y5LJA4HrvmyVuSiumsLN6OIt5LM3jLP/9/30Pyg+3H6DZRKUYm2/uwTFQBvbDyfSfg== 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=3TPDQdz4v8xPMoPJUkKtoldCxZWgwM3s9N8JxfVg/uc=; b=bAT7EeAlK6bhx/tGhsh9QelQYnuqJL+ZWlGqJPrz6hJf2h00zrnzHffoGACLf4Xd6ooI6FL8hApGjfNcVdBq7v+6cdDDS/j6/ZpchMK1trF9lK/Mwdsp9XcHSRn9ovOpFi3KvS8h10opWVQYeHdzRxjO9fMBOSNQ6xeuBSGKq7A= Received: from DUZPR01CA0015.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::18) by AM9P190MB1219.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:26a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Wed, 30 Oct 2024 21:39:57 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::e2) by DUZPR01CA0015.outlook.office365.com (2603:10a6:10:3c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 05/80] net/ntnic: add minimal NT flow inline profile Date: Wed, 30 Oct 2024 22:38:12 +0100 Message-ID: <20241030213940.3470062-6-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM9P190MB1219:EE_ X-MS-Office365-Filtering-Correlation-Id: 2be7f0ac-7cf0-4caf-102c-08dcf92b663d 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: tcGaEi6xibbuftwoSsl9V80o8Dk5SE35dhkbR1rKtT642sojnQQiDc00LPITcukHUX6n4sQr2MBwf35J9GTkcUi5yPUYFaonKGJ+Zjwlp06kX+o+H/nxBUdgggOau1LRzFpHXLnkULnr3joOG68l+15HCv/z4W/sIUILkX2eUfpwhNLGYFnVu01+ST+OlHp4I3UyV8GsfLD1monHSJZYuv8zdbl/LQ7WHwDUND6ZYN1rZjlxv9XrZ6tWzRs6ENadCWEnJWJyQKN6EadNijJrmPiajPlbPkduWZ4pVUkzycEzNO30Q6sv8z6fIvgwkeZLMW6MQLfXuzemPMpc6icmmKqWTOT5F97Ue/WuyDme4hW/Q12SpA7y4jDh+4lEYP9L6t/S+iO0ZqfseBfNazJ1+Gvlwf42B+NbWm5QjEIqzCtxqZRgAHxRonWut6zBiUK+XgUsMykYOiGU321jM/RssOXkgTtQ8McFl38cbTADIc9M3K0VvafXvXE+DXqTToKwrMXLDbXHOVWVx54gMVTsu4BNQEFQhG/ZNwjGnaY0qQod03pl9zoM+0kTt0rRSZgWkUFweCO3F31lVdR2rOwX8p1PNUrKhQgvGDkIBe51uUf73AWzBO4QKIHlBclAdvSLIvMw5PLgavNUwMMXKaxc5MfJDFiYyFBivDway7rroIKfvfA8Vf+YPY04eygiDwIlsIGt3p5neoEe04/EVO3RrcoErtNKeJTuE05eANuGo22PVDDFcmMC4+AlXqIHwK9icu7t4AMiq569nzyx62Y2lKSox6kvLmky9h2CkP6Q+GS423jddkS8Fd2WrjIxBxSUu0s49B49AZEXobPplrae5asMmJu2z4lN5oh/O3snT7eL1ZB32NtF0YItm8Y5POXQuuuLUXpkDq/uzYWecp6VJhXVxCvul/L2SCXWzU2giKhxc80q4tTUB2yRP/R/5P48drPlJudTGJsqBcsn1mktXKVXiwLeh2Un3T4orn3SV3XAMzsPgsn/Jir179ue5JUVRcpJCbKAIskkUtOxysuZoU7fc7M/f5jhFl12xZnuq+wfYdSmtilhcnFD59yBFSZzrC+X3wDVTShcJHCGlS8GI6Za9WiL2HuFdJlirSITIAeFqHwHIsxUPQ8pMqXdDFUw6axwVBT/3CFxyUipJtKRmvpdMF5U/tfwbSpl564vkYylRYYM9o6LtOTGTDO9xi1joAQR8OIKCWFDqsdTNv2J6ryKc0ap2dzxdCMjXHdKThr0uE0co01lKbZbyM+ttbnSvY8b6Y5InhZImx0jENE+CUDQaALLz1HxvWrBU+7jt7PCruwxDSt9QLywaoBnMzsi74bad5YF8cGmE10D6b+cNOy+QVVK+Z7aNgRXmvQh4KUlEkJguFQNNINYCWNKBbRrmeaGoIcUfvK4a4EE241lFA== 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: Yc0VIeY8vaOnMSGsTutT401JddXGqAq+f4lvHCFkgvi5U1KXGhIesg6bGW6hIAYprLPyJulE7NPMsmuqluSE8b0hX9ake3cfDph4ViJsik8fx/pXcYy28r/MCcJxmQpRUUAndnhATm2Bqns9ohV2w+djoqXj3ysSRi7BrRY3LwxUkJDisDpKc4YeOXR9wkOtVqNFsavpVDJHn98BnXYxQdf0mtcCZdwcX9r9bSWm0cscDUAI1q16uB4Ockd769pkmnXZk2uD4Sqf7HSdYdrcModbYkhqxL6IdjpL8mTSFAuN88aqvfkKfM2XDv+MsM8FKc52ceD2h2vgg/XciWWyV5IyMfWanOX4d3G/hvbsFV0HJHR89zXXSEBCIECjeif8i/9PWQm5dxXIkA+1XF9Mpuopw383ksoAmI0N7q6n2KdgGukNZA1C55T/NPDlP/NUqWMshb2uYefo6B1mPKsrY01NKkTW6a0tMGNe8KqkWywsaHFuGs1lM2kYAgr4TO6UYUNT4V3iwv7e/+sUNiN2WGl41nByhsIcCXrJyKig+Ghhlk2hDBo2QL4hDg5yfo3w8NzO8c9TUEnLukx7o9ISBIpXu9tTZwitBzgSPX9jH0ol4TYmTa6/Fxeuw/KAZlNseDefkE2Gjj6N+yhHVQ8IyDpOzhG+LW1+/b5KlVgL4vI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:57.1299 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2be7f0ac-7cf0-4caf-102c-08dcf92b663d X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1219 X-BESS-ID: 1730324399-312176-19304-20341-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhamRmZAVgZQ0DjRKCUlNc3QzD jNKM3U1DDRNCUpLTXN0iDJ0jjZ3MRQqTYWAGEQuapBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 The flow profile implements 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 acfcad2064..5c5bd147d1 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..34e01c5839 --- /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 __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 elem[] __rte_unused, + const struct rte_flow_action action[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + 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 Wed Oct 30 21:38: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: 147773 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 3019C45BCC; Wed, 30 Oct 2024 22:40:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF9CD43429; Wed, 30 Oct 2024 22:40:15 +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 C17C54327C for ; Wed, 30 Oct 2024 22:40:03 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HK/y8BF7gORDDl/Q6vT3Ajn4abG/Z9AGG5T7WcdYNM49iPKitZ7Oq1eh8zQ2CeV3GnPhdT7FLwm3MefoobuNvPXCo4BBw7qVHnXlgxckokkhM3qw7ydeh3XkIFZx40oEKEaX67e42fIWhuQDrr9aIxESZYNmMlnRLtV58PqOVuxBtBd18C6H17XndrOUpBHLsdQmvuQHHnDhKf0n0Z9NXVR2+54R1NZJaZrGUMP4fwpj4xUTS/vVVgZ+BPzUFkkDb/r6J/l6yH4WNM/qkdGGAkWYq/bw9/9iZOcYj5r/hKYdGW6xd3bH2fE2uLBlMsiqMbpo0fEanlR5iT+QplF/kw== 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=9ZLuChKy0VSRpzDxAtkDnyFlquFsYEFb8XaeK+CnoHc=; b=Nkn/JYIN1qi/PzeaWX3GB54GFS2sVDTNoMLF9ibuCahDwQ71aPC7CznQpC24t4BPowzDH18Moe/fkqsk1nBxx3v2YHCRDFF6aYUp0VN/lg+RVU2RhvVunKcVyKYFdCj7HqsOlOftkLYR/+tLZ6iH62IJheKOm0eo9pjTdmxp/TavBHQZ4sOYM/p3Zsuv+MWTXZNGj1Jb038471Xct+IgRRbsp+EQZtQ1vMNd1xIcnTDZU/K2w2w+ZD4DyTCSyiyMg2eejkNeSmOaaCkSxB2D3CCp41UZxllbg+Ajwe64sMjBUwhr8+uUkPbSakdQbw2JQWOPCv32gb1WFxlCJLFBfg== 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=9ZLuChKy0VSRpzDxAtkDnyFlquFsYEFb8XaeK+CnoHc=; b=dJLnsBApOOiVy9eTWc3E1H+D5leOhwJcVlC5ZMYdXi7dckkT/3TQBv+v/KtwmI5U9BiZhYZFxc/8HPoBE5RNmAFhaoPLEkFoh0hRRbzJ+W4n1bttvz4Y6ZfDFofoTVB/FoDfLSM7OUbk3z7dwy5K0AQgOjcHtI9XPoJA+zhkvmw= Received: from DUZPR01CA0015.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::18) by FRZP190MB2213.EURP190.PROD.OUTLOOK.COM (2603:10a6:d10:13d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Wed, 30 Oct 2024 21:39:58 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::ea) by DUZPR01CA0015.outlook.office365.com (2603:10a6:10:3c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 06/80] net/ntnic: add management functions for NT flow profile Date: Wed, 30 Oct 2024 22:38:13 +0100 Message-ID: <20241030213940.3470062-7-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|FRZP190MB2213:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c713d92-7cd1-420d-31ac-08dcf92b66c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: V+2I9kooYRwCHv8ecXQduBwgXlQS8xTludrFeVWeHXQwIUo8OZ4uZ6UZRxEuM6Wg0E395LqKX/e34R4dqg9FwYhB4roP426Fb4PLr217l7dU34ByLdug+DBsQ/7JdCffQk2hQF3MPkOjCJyyJiFIoe2NRVnFkHdLagCg3BXeQiIQKxg2JW+Gr6T9+55BYCficnwUO8Gv4T9zMSYof45iWcqTKsCutVUGnuAJceKFVDAuvcIrYY4OYBk9e872CwZSog/5Vo6PE8azjNsZGJ5jvSpTc6QLp8f2+Ac37kjAvC+OlyJbmQ/SgkauEky0EnFhMEyQ9OYmkuxl6iY5kUaYdb5iCXkQYMgBAYPbyf+gN2HSOBq9dOVMb4KbYZV1zMNkNiIswrHtbpfKwZlnyVZBarC9mTBvX89lG09v/4cVTqiGvceziKNPwj19Qx3Sr0FD/x4TM6w4vXW/Te5mKXuxFR8COJnPVD/p1okpdOZ5I9/JKfveQKIUzQSB2oIW/6Wqxr/l02gayzO5mA57Pc56uX1x6vv+ukXkRDTX9JE7K9Jnl8KWzqRYOPi0VBY1aMysDFiaWLOk3eWAAPiZJQ4yGcyCWz2AclKXfPvnHVsHImZU56PaSS59Sbzg88gG2noB80wBOlvJaUdvnz6E0Q2QQ/cWSvwM4qeQN2Z01ugEhz9q3bi4NP+zjDwlg4F6P+EbGNHJ7OWvqZ+XuQMBonblGhaJ09K1CWg3CUzbvWC+tZxkPyH7fslW4sH930vRUGkgvu77AjSi63N+9UgPJAhz6m42KuuHqa8pOH+lFeRYO1Xct+1hXsGhRiXfk7xqPaSrhXpRonj4I6HnHK9MPKrp27xdoxet30RgBGCx2nmpT5dMbzPaojYPCa4EH2d29vFWEJ2x8ae+Y1st/sYjAsxRwe96TrNeAYIKAUXGEsHsfHcQdeaHm4mZaK7VMI1nzb3Wg4vHDwLc2pxbKz9dKm4TVRoi8109c1+gMOuIbqS7tlHNlcNQGPgtzzBk/grXTQu3+pqIET2Lh44Tn3+3nuobt2nmMPeXjEq8EA5rWwbSd9udTyNcRAqbV4hiL+Gr2yMAJLg+yarfi0MbdQnmC2+eTwwBRXBUdhMVuhA04aHgi6yAUDFtpwjX0fQQdoUFK6cHBhpPnurUNskExjeLElhNbU20aAz2ExbTlmd63K6URtsRkTBQ0gl5GETNMA274e0A/Ge4mxTCeoGEwcIY7z184F0j6V2QcZlwNJc9/3XmW7phlnRMVn1T4JCwyo6Whu9BoSUpko4ccDsBduJHfQSwjk0l5kGzALJPVO0yMUVaOjHXGGd48pXnu/B9lO+toHSdd8Ebq1HRCfkOBAO0llRQD6pUYMtBE7N2b+klWct7UIOJyyXACh+JEWtTrU8N8z1Q5VfdKCt1qOgyifXspTgFPg== X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7Q/xUYYkviqCoQzqjI8hwGwyOPW9FvkNWk/dHl5WvlncnrqiPNJanktuPiOLcHJjBSrFOF8Fmf2VeDhK0jEdKkfKdWaUUBswisyTM+k/lR8gS22k7oalSSN/wBRexrQ5qNpEa/N9Jp2AEUkE3vnXFrYVaO7woaJdrrPBCX1Vj2R5jU5m8oYWQlkNzoBD1xq+wVWPQOAgxdbZv6eDv1HJSfbqpntYtf3OV4GBOExOdXxki2WrO5pftpF8iaQc1gDEb/b+Zd74If3Tgv2kI1ZhTs02aEtGi5irWNCVm4KA5vJJTd0lqea8pd/DqqJAfNA1SNFuZKrgY1SBLjwPVIIsQuplrytE+PeEBj1AycGziV5ZRIJWAEhTQO9SJBn3LGuc4neBThEUDVmRAsO7dqSo9o8q35QBguQXAtjeHKY95n2vpwXTBAAFpsG1I0FiFOh448crUC3SiJsUQWUozedHTCWP3Wz+lB3wJe6Op8KE+jhaQzvN87sxCdr36lzVgDoVYBIIoYzC/L00ZDDpL7Uf7xSmfCO07L8wP4v3iJLy5YAjoLctNQKeDjhKPhcboolk1cKf7rhMCtKMv4DZH2JESK/8ANQeVQnl8X2Cto6A5kqxxv6urba+9qhW4Akxl5KuhZAFnDKNcBqouqzbECXgIjFtTcbrz332bonZG4a2Mic= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:57.9893 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c713d92-7cd1-420d-31ac-08dcf92b66c0 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: FRZP190MB2213 X-BESS-ID: 1730324400-304433-12636-44608-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuZGhgZAVgZQ0Mgi2cAkJcU0xT DVNMXINMnAzDA1NdHQxMzEKM0y1TxVqTYWAPUTtDZBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 Management functions implements (re)setting of the NT flow dev. Signed-off-by: Serhii Iliushyk --- v5 * Remove unnecessaty SCATTER_GATHER definition --- 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 | 58 +++++++++++++++++++ .../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, 100 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 5c5bd147d1..a9016238d0 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -210,10 +210,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 +274,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 +297,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 @@ -435,6 +475,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 34e01c5839..0400527197 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 __rte_unused) +{ + return -1; +} + +int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev __rte_unused) +{ + return 0; +} + struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev __rte_unused, const struct rte_flow_attr *attr __rte_unused, uint16_t forced_vlan_vid __rte_unused, @@ -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 Wed Oct 30 21:38: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: 147774 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 9349845BCC; Wed, 30 Oct 2024 22:40:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00C374340B; Wed, 30 Oct 2024 22:40:17 +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 2ADE74327C for ; Wed, 30 Oct 2024 22:40:04 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2233.outbound.protection.outlook.com [104.47.11.233]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e7h+l/zrdhE4uVS2L7tuFHfxUwmOKPZsd571QYVV6p+xstB9gIEaOdRwA52MMtRnBs7kG0a/K3QMBeUX57/ssm6ZUWt5B5NvVMPFXJod3zyy4OaUvEQk4l6cVSil37+fy3KDq0lZOQOxLJuAUHgfj6F+SzvBmBcO5AsXI5ivAkH731XEkOPayqzwuGJck3ZQv4CvAdP7l/aQ/HjNKdgLuy3UaOW9wKErmaVsueVJsfCxR1H9K1htUX8ak3wQijdFrEgP0KWFYmXvFrKzChLkWzEPlPZNjxpVPyZU7bSL6eVLxSmjfjsnU0JIXKMb1UXzizTwmrC3K/22zhvuGOnEnQ== 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=su7QfxwqiqbkaQnJ7l2jY85tPmuFOVoigppT2GjQJLo=; b=nxo9ka9Yl5lXhcDKCUrztVEZBL/GqfioMbd84vFOSzJvy5AOf1inZibruwNyODs2XbaXCKRKg5/C63B4OjdGlzlXgoALln9XM0Ba8yYgi9Md4uGvPr2T6ekuqVdOtqjcuQbn4BSOKUSKd66qkQU3+x/pHIilXKkHuVCWssIdPGRjgso6LxEzp3HX0xcstoP9cijg/nWOk0+Mn5pED/VwHAWIs2axHan+33hawfHt2JdN/dPqpww3RAlDa/cX8gaqGkZGq3pGzpxxfdo13XvFwwpZMJ5KzBwnQtJ4aGe5WmQ5q1PT/tQeOJZtA4C3o2WbnwTjsDMoo9UzWJjEs+dfzA== 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=su7QfxwqiqbkaQnJ7l2jY85tPmuFOVoigppT2GjQJLo=; b=ZE4rfYWA4d1eLHt6BXMjU8fMTQrujIM9BTtVZexITzxIBb1+8jaUbXrf9+xMPoQiVCJStfJb8xenRfSSFAK+ZhZ3egU+ZSd6h7dpaBPd6XA8BW9Yxl57c6NIQyI7YGa29UeIT3Tx8R2ZotHiUsm2hBq0pqMuVXKtjLSb2nuHjsA= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by PA4P190MB1167.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:bd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Wed, 30 Oct 2024 21:39:59 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::81) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39:58 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v5 07/80] net/ntnic: add NT flow profile management implementation Date: Wed, 30 Oct 2024 22:38:14 +0100 Message-ID: <20241030213940.3470062-8-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1167:EE_ X-MS-Office365-Filtering-Correlation-Id: b5be47cd-8e02-49d8-c9ac-08dcf92b6739 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: /DF5QyWPcG+5qOAsR2cjj09vTvB9IND754CZkUlSdb29QpF0xaY82juBXTnEeHTfNQRy3Pso9Q6v+/hris9yN01ryEp4ciPq43TChsiy4PkvkoIftRWolYv/sbgSqxIJNtg7RtY0E0MhoYRv+sfrNBDWijf8otEcq5k42HUFjeBMrRq1xJOp7fzLhFkmg7uND3GaVgWhG9CqMfqLCQEbe95zGbDkt4QO5ygeWQ3PkVNfq2Zc2pLyUm2iPidJ5lWSw2NeoV6qel8xj+Yfn0s358/qXsTDUYVwQAg5Cpg3xx/W7m/p3PyOfIQuddHyue1bvuEaFToYjQXSd/9itOmbwXHbzbM3cn2x9aw8WjhWvmS6VuEZKUUga+lbSkRxgJGRrqZIuwGq1QMo0MNRt6WYEA0Msz/JxHJbrjLWRNE8r91DDlo9B+MZLqzTogtDdsgB4/xAeBOqfVrcRiiBfUJLyw4za3biL1WPtr9cTXz4lknOjJ8VKMNNHs2Y2m6mBBAIldM81lPPFwXLw35YzV8JgdQsoeylR3cBWgYU1XU7jBh5iSGrFVqsbbLZoGVbZ/J3dsLM3WwMTQTrBOBnJSOtR3rGN9lZUVu0KKnwZ55QUNohqF8S44lMpN247nu4PSzsi013p2osTdjzvBY4p17siyf12U1CLds4eUpKyBurHvq0R3boirblDA5aut9aDwFo//R8QX5yT/WZDrewpna1sq1kDn+rXWaQ2lmm4D+mAGLdFpZ6OE8MtWAPyFnf0Yj1XgULBdQBtgQHNuht3f7J2T3k4RNI+A70M/eOtr6uQhrdKupds4CtmgTF+6AqEx9B3+/DeykJ2ge+tKgzbxMVFditqNERcHN/kJzzt9hfPN2Y0k8Vpr760Z8q4l2tYIgOy7rN5HM3X+q6zR88PdP1lRELJQVcC2qJpSOiVeQQK6FcxGjKdl1ikdVqo+O+y2+Cqb49oIkNQQQmu/DX6eEhjg7UCBokJUgmcLE4q4RxgEwln9xPa2ht2Ptqc2jWnRYbcrkyxKpcd7RHCpGAm0lbPHKi8MeVW1FuhYCuZ+EK8M1C0oEuaU+gq32yoKfHLRixMyoh09GYRYr+pVs7Gq2cJiynmZeBegJEj4M69VzDXMfbL3Sw+d+e7r+JYf2fW21GHrFD0FelKSZkGmublahquwFQCHMcAginKmn3mhFffTFWZPRD+CylLvys68YhAbEJgNUCSSvCwpzkSG2xQZu0kAdwVQEismXNrTa95RWq2pAf+NOAyIl+TO04XQ77Uj6s860MwhXs0x4v1I+l0voBPraXFjFzyXDas7gc3MejqmUh0PSebGM1mnvMyx1qOVw8GfzpNTZVKDJ0AwZuACgMxtdvcXaxYnesq9otYNf3rtxS0Vv4uXmcqXNwv8Qdq45aujRLOZnPBMZ2/vOJUr0Sjw== 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: AsOjFd23PkhfPo5Gu7o4u2K1LqoocrkFliQCrkHJMheJMhjO14/PMQ81FQUrNPqeiUKoClJyZU74+K8CjKmFBrW1LcP5Wndg+Z6BI3t/LXWTPsjSuG0UeCQPRlip7tY4SRvRkEtbC7kEoyP2WYZu/9kXYp4+R0m0NXe+OArzg5OrBsdUz0uqR6Ptq6EsQzMuS39nZuYgr7U4kOrKjzGI+/oNh464QU4v7mi1GK5DmeEWPuoRUa4qxFsYAeQ03NIaNCyrn7o80hlIV7swVCZiHA89pIMhqfQN7QkjBwJGPxQz36Xz3pn74aNemJDfjtXoiKnlW8JQx13ysKQVV1+OQhzWqmle95FVlRWb5FCj7dtDVDmyQlk3L65n+U5qH14cs5BVxxaVOveIAdrJZ4FxcReNcjEAkMhcFzt6z/ERmwKUPyorsbv/9Q71L0WD2RoCkLhsxRf+Ctsu6h2CjRxHAU7xaLa4LwDqB2sV6gxNWzqkxBVyhcCBCAREh2Z2MzltrC8JWK/4JOfcVrDDjY2F1bDcL7SvYrQTmdEtw/zW0TG0SIZ7A6NvmF65r7mVVoZ0VHqGdhS84GJP9psPkWCvU1XZSwA64Sz0/ECnMHkIsNk1ugCWvw81VStoAdHddHa8NjSj7dlcGfiXXkcPmPxLLtg+9AsjexD6t3xkfQ5zJdY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:58.7862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5be47cd-8e02-49d8-c9ac-08dcf92b6739 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1167 X-BESS-ID: 1730324401-302901-12794-43448-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.233 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGphZGQGYGUDTFINXU3MLIxC w1LdXINC0tzdTUNNHIyNI40QCozMhQqTYWAAHxXkxCAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 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 | 56 +++++++++++++++++- 9 files changed, 280 insertions(+), 2 deletions(-) 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 0400527197..6d91678c56 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" @@ -12,13 +15,62 @@ * Public functions */ -int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev __rte_unused) +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 __rte_unused) +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 Wed Oct 30 21:38: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: 147778 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 9ACFA45BCC; Wed, 30 Oct 2024 22:41:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 632F34346D; Wed, 30 Oct 2024 22:40:21 +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 F3568433B5 for ; Wed, 30 Oct 2024 22:40:07 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2113.outbound.protection.outlook.com [104.47.11.113]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C7wDzvy4N+66XMibLnthezOdcVlk5UFH8L7IJM2qg5jv5dYsjZ8XZPd6LE+gmghlmwXQXVEFWP4v5nz7Epf6rmc7voAjzhMtIrlq8It2b5oHAwwOMob5pluz2nOzhAesDVg8Vgl4e0oUCRWPW152stPWbPWui6x749leREDEqhIi0lxCbj5RMSetefEx2N5+2brK7eqkXW7IlOpId1D/Eo1ct8xXqonRkp3bQDCZReu+UeIDOI2PYIbyufQrhUlIYTCjKVbQ6rFoiLmEq8TiZTnjkJJeLTTKMtpEAIH8b7iy01lsj8KTbouU7+GHMzXzfE1GFZkX3ElFjcd3RQ6qVg== 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=pVf+tLUcrmjV6OtP/sUVT6pD+61d1HZJMa1Al0enLwE=; b=ius/cSvTlFKcza4oF4s1tXZH0cILG9cgoOkf37b6allQZJaiuzw5iKV43sRIL2r0+0patzmH+usQbYCfC26earFCbwPgmk/LJQl9zsEBJFXfUEnYJMSqtrRfBI90zxh600ZCtEYyE8IKm1EnEu99C97pQBFS8JHSgoIggRVgPeQNGMjXPtcf+4zj9MdfvJ5DYu4USJ8StzLh4rOyLQdYpfiY91ju/YyBL93lICvCLDaWV/P/wvVPNux4UCwI+SAvle4BpBwNz81Wu/lvGMJkBjq0f3sV36seL0T9E93fZoHkFgO6g2kuraIBFJ5Bjuodi9CDo/GEQSLtGhOFkt5QKg== 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=pVf+tLUcrmjV6OtP/sUVT6pD+61d1HZJMa1Al0enLwE=; b=F0tEFuZItdt4sJX3VlWuAunUuGDbsTh4h+0ejLxS/gbqno6nlyz5HN3T1vHJIh8tMJLgvXsPJXbru8MGaqL82jqabnAtYc4oWk7SZ8kWPNYGDWx56W0GMKyljYyw4W1Wl/wDZwPXE0Ev1wNY5lVmvI8/ebscS/lf0RD5Dt1GUrA= Received: from DUZPR01CA0015.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::18) by GVXP190MB2015.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:00 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::a5) by DUZPR01CA0015.outlook.office365.com (2603:10a6:10:3c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39: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 v5 08/80] net/ntnic: add create/destroy implementation for NT flows Date: Wed, 30 Oct 2024 22:38:15 +0100 Message-ID: <20241030213940.3470062-9-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB2015:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fc6ee00-20a3-42c2-8917-08dcf92b67ba 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: Fp+SkrqaCy9tboCxVMeEMW3Kua7kSXfa+M7HheTcYT+Uk17dDjH8w4ttAlpa8AJxkQQ1+4qnrpVVyGufAPWx4+Ud4dlR0/WUFfgsZA8cbAYIqiwErTc2XRjXwtSodNfXtbXgiilP8J5zyXy2svm8LfIzz9cRoB1nXI+MZMvMx6g0bZcs2NwEyaHN05B6WD+e5MweBzqjwPeD5k+Ugv2WkMCyj+u6FUPODanwIDnvqzg+TYyHQtGL14ZAVQbL7Ze91pmvIW/WLfKbHsRDUCYdacln0T9BXzehsW02no0kc/TCN7RszTNkL6weaFDV6DCu3y5eym84GEZ0t4wipDUoDnfh/Y0Xa2blCfV+o9vxAhM1wdd0pseCf5xTEXMwKW54XrIcLFYx6tRU6kfyQbOKuu3XgdcTWQWFh2VNlUL78nAwgrYayvtWjZ4rf+bpJ11L0VNbykm8IDPE7ft9+Djuek5b+9laP0Sj9YRSnv1Qo6fiTt+u2rxFnToCSFRUWrLSP/Mw+P1tAmYRkL9HfOd1VaE7seChQJQqlUI0G5HCtAbimXHTAuLJzut+DMYcD+Y3u7bH4a/lyU8/eUX4cb04vY/8m37aatk0bj7D5PUUccSTx2nJba9Nyu0L2ZIjCDv+GQa1IJQMR+IILLqwYmVv6tHSse+cx3Jvb62smGtNk3vquB8NTEv/XBqZGpwITCLqLHiXF7zPYzUhS9zSBpbifRuVAHetPtNPprfqhM/Vq29T0p/ZcJsW9NHizyzJeySqxkoGKax0dTY7PHRqPai8R9hs9jRLpExRcGTnW2gtvkTgK575lfjkJVJWHvgcY1Jk7SxXXGKXLCFrbqNTsYtW/0J4upolQis0gHbSBRbN0q8MIx5bF9wO/UWF+hbj+UgrzebfMASIFTp9wilbD1QUZxM4jnpi8u0i4FCHO835XT6HjhG/STdBl8ddCQ52leSm3N/SHGljK1Xk9KeBUWZ0aaL31RlLB3RZotkTO8d498zP+Zhon55B8OIzButoQ0+wGvwFy41g8cVanEANn5AoMZVigBhxjLS/cg2xURFHlPlKTM9YjXwp9V+4k42t0Dtma3sDaSNYTrslgCJ8qjOF1sxIcT4PknJAdTmz3sWopmSEYZkWpr616eZWUrMBmQwg9u7IZSJzn8aj84ZKmDW/rp366bF9eGj+hojCkkAjqWyiPIzi2Kfn/8DmNYfs8eVszXA3cK1fAz0nndVuNK81LQcqshBKwAl1ViB1sU7Fyf+jCaKplqJpr9l4KAuceSukzSk0AJZN1zOLBD4oKZgULlhtLNz3TqjdiQJHReuQow+H8PsXm5kXMfvTL+lg8BiT+Wq/Sgwyug9ryLVoEn0plwcoZyk+6+pqdt3T+qEaH+6ZG9qXouEg0b/n88zkXLX8l/SkTC7NZI+dq2gBFw80og== 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: 1QaJgcdjCNpbEH2pydO8Ln3AxRKLq5PPcPR23Xb5n52BpbGRSyBSU76mksBJRhMlg6DGjv37jufDnWhTk/YxO7ZekfOb6qzFoh/7X5s1cf7k7Ze72S4vA7e3XZRMMsdapDFoZ1CCbfUSWkNr0mfo5mXeEVVuvPRJnCezeimQWzPOT8JfvqnqioCrAF4WoY8HIDijU9TWdQ4EKpD/Blo1a3zwNGu1y0U3akmS0X7SaA1WsLZ5qWiVHjJ3+mju9E36/LJ6q7e/b8uLlwNR6GaA707va65THPBenyMcNd+qNZvCE9QFUfX5FMwnYX7fIylthucQwYfVkkWxfNLatcqX5RERvcQtqUJL7MOPOE0tErIYVQ/iNOA9nvvMHZ1tYIYt3bpM2pMIcc3/CWjFdS+WWIWKqZe407/GUP4vy2iL+xms8ua3zfLCuWtc9ZbTTn7w0UmnOywOEt4X5++cHoL+vvs24zQtsfga8k021EG47zRG1sF1mTNm2WZijWK1wyCyg9tmNIpnzAg9Q1TzbJ/UF05IiUzRlFiAaTqjfUxllZvQFV7uA7R0/lIQC8JZPiyS/FOEyrm45q3n0Vwd+inJaV2o2pIO7OJFKACJlBpetWNZxKvkou+Vt2XGyvye4yVjMIWEHzDXi8/tJI5ZrjLtZZEGVoludtHXoAmtL4irC5Q= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:59.6299 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fc6ee00-20a3-42c2-8917-08dcf92b67ba X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2015 X-BESS-ID: 1730324403-302901-12799-43451-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsYWxuYmQGYGUDTF2DLRwDDFKN UkzTzRwjIp1djMKM0g0dzIMNHALNXCUqk2FgBbmuCIQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 + doc/guides/nics/ntnic.rst | 2 + doc/guides/rel_notes/release_24_11.rst | 1 + 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 ++++++++++++++++++ 15 files changed, 1106 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index 2c160ae592..a6568cba4e 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -40,6 +40,8 @@ Features - Unicast MAC filter - Multicast MAC filter - Promiscuous mode (Enable only. The device always run promiscuous mode) +- Flow API support. +- Support for multiple rte_flow groups. Limitations ~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 15b64a1829..a235ce59d1 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -161,6 +161,7 @@ New Features * Added NT flow backend initialization. * Added initialization of FPGA modules related to flow HW offload. * Added basic handling of the virtual queues. + * Added flow handling support * **Added cryptodev queue pair reset support.** 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 6d91678c56..d61912d49d 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 __rte_un const struct rte_flow_action action[] __rte_unused, struct rte_flow_error *error __rte_unused) { + 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 Wed Oct 30 21:38: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: 147775 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 EE3D145BCC; Wed, 30 Oct 2024 22:40:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31D444342A; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id C139D433E5 for ; Wed, 30 Oct 2024 22:40:05 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2240.outbound.protection.outlook.com [104.47.11.240]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vxe4ivTPDWIzPf3BlmHqFofNcfDW7hqVsvG2d+spSeHIJmsE43PVbpsZVDTkaX/7E7HgMIWMJP87FIdnGmg+4/lY4NCKL6MBTPHMvJ6fkpeBHFn89ErI8cu4PH4d5UEgw5s2e9HEbYJ7CZ9CyxzMt2Mv+zVUnRUL15jqDi5yroqi/ODp3AirSCfs22seqIh1nUNYl9vMmN4xEmz2QL8xmVe/u8zA+TDtu98xzXSfHV31npVe287n/20kEO4NiaYzX8jDS5+4mKoS0J6iW3HDQr9/5xOR8/wXJ7thHWIWwRgJjBACYDc7wSt65ZMdrpU8X+kA4C2ccpGB48VSILVPhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7G45f0WhmA+1w6T731Zy/ico7xiF+x84NVc9y1f0Pkc=; b=N2ahdijoFdM1/bQI/ZRLPtERq7VXBdnJRTpnubaZFAy0myoB/6lBs9yc5qqNFPU2nbIL9brhU77KFJfch75oskx6Az4jAMBj6VSFiCopdCodUky3HL/3OXahGoP0bWbhUNWmUIBxttvvpuvWXUaND/v6c/mQJ/TDwnjoUnCHvr+LOvsPIrvXKbhZ/SYtxELuywKlJzBOWbMbkkHJo6oC0qvO6V0J8DQUaOz2RsqRUK1lSwy7/CDIHRFx0KHsZ+UA1mOGBBJCDuLpr5xpAT86tGxGwYm7s3gFNnLfhstKSxx9TVtOIKRB37XFoI08aiUvUFpJk3y1vm2YLxQETxSGdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7G45f0WhmA+1w6T731Zy/ico7xiF+x84NVc9y1f0Pkc=; b=cFSwIPpgbAmOasT5x0R5ovVXTLPn/NjBJUEfJZSwPnvC81xLFdqYs70VR0FfjHxFIy/cnLVivcoU9xST2tB9MjyagAkOPQ2tSKb246IG4sX7B2AslbuKKOHCZv0YPEnuoIiICIWbD+alo8SBHxyhlLNpoe/vJqh3oeYxtvXFpOM= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by AS8P190MB1125.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:00 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f4) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40:00 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:00 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v5 09/80] net/ntnic: add infrastructure for for flow actions and items Date: Wed, 30 Oct 2024 22:38:16 +0100 Message-ID: <20241030213940.3470062-10-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1125:EE_ X-MS-Office365-Filtering-Correlation-Id: 9163f36b-bb20-469a-e468-08dcf92b6857 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: TAnw/bAvIaRs9pi4yzH/tlX9uLdUy0A6wdt93PxEXgz4cGsJiGoaLfIY13TfhD46Q3k9jiBXwiisVzgA7C3eFbuEVkNgpK+LZAueUKWXZ6OnFrk42fMFnSw4KSduXZluL6LDRYLJ6QqTb2vp7oFdCDC7wGCNcQ08oMphldJ36uFBp5bu+NxFqjviSBrM+Xvti78BPxi6UOMliG1d3C/1POSuT6ovDu7J36+Mf5kBI6UzpDBemukLOzVbAufnCYs+x7DHVyD7Auzhv0XJ4cJXyfOHqbG5MfJqCX8PuFo5n3W160cPS1sFb+UCPr90MbKflBJ1qEMup9tHtSe+u61PL7AkF8lwPbkFvgb63JsqHJ0mddf1S5Km+29GCgEwXXpZx+Xs6zElUC21sADRKiZJzqAYxhBp1OjqneC3KCfgupNbI6WCV4Yb4NPMlWY8ev7br0qjjSn8tkwVgX/TWFIoRMMknBXtG5yo7IWeaMTmfllA2VzN1QfBlrFn5PlyxSe9fysEr5BZdvheAzAg/krNTQbAFb67sUyKDBzK4pyIPsru5dU8dLiqKSl22bydGAPUHsRc5dXIpe3qZ4s9U/JCXvK13nlWc+EVHjmEU+rEvgeHFcM8LjrNot+rKWkgPXskbE5CVyYniiNvrFIaoqeU4X9CX7SvfvcOmi/xpuNNm77K2PIduIGWpHz+Og74QdcoY5yR1pvAQFLnHSEx/anMCFrCfe3lD15iQZNjW+1O7ZLsv3udnXeuxs35kJwscN+q+grmlFRtQx4byY8WYp0JSdk9N/ur9XcETk2BDHj1KrhS2LOGisqff+5jSPDGavwAnzk6Xoc8vFmU+B2Q7Ya4MPzIjIitz8w8E/uYEzxjnpKsIQukS3s0cEm/Ms+WrQ6lyAG9qf7HvlWuHq2QBA9iJQagtJRB6FTj+L56tkoMMunJ+Za844VIlPKQmAMpVGVniZ9xfPk0n2QLEH8lgsOpE+S9NQcxf3gHLxjWwNIlasTlYnPaT37l+rCkCiztvpQBTt7ZmQy2ON6S9eMjNIMsnvqi+UtHREUEyBA+EN7fcopl+8qkTF3wAAYyeklkD9oIF2AyOA46wcFnmFnZZx3D40VdlhqFykR2UV4yF+XSaawh3QG6cQ0obHt8g17LtRpyYCL6hN8uW0ZdmOH8napNFJ0ZTrkjXEVupitlcev6vG5a203efBsajSeypbFPQLSuWulNA2cdZLfNXSClydZ3V1kHm9K40O+2vlse4pUHslV5hrPFMjRWeQD6h7YcZNqD8rwxlO8BswrKCx8gbGH1keG+6dp9gih7fTl7vplwdD+/mwKVCJUQyK5IAU6hEhVSsR2F7jlDa5C9i3LOZQaagmh68Gstj7Wqp/fT1oZYw66DzDMO0XBH0SnFgW+abnzby192AtBPse5Guknba3i/TA== X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: yklo2mRuUSNhi1pJ94nS+OahulLtiEaSwRDKlawX9pHmI0QFMfUCiOqHnXPm7gzaQEK/gHAoqHwuhWhAxF9rpqCJnE1a8W47bxi9QKPLdZVw2mSC0LgCoFOBOqqoG+gIuyU04HsD8NeHHU/xVo93djw3HhdUeXaHIkpbPw3HAdxnwYSUfw8mXTFevpkxIOHe0vozJf3pglka44uD5SEabanelzzhfZ9w41mcSfG+oBFxiOIO1bEDMtkQFRlpT/Dh9YsCpEI3ucEXijox1WpnRdHeQH1t7O60wqU8zYk4XPdn9BGFsWJUAmlO9YyxgpOz8glHMB1W7R5J7RonoBLyLbBXA5h5FVeWK1I4BofhNmF4G7gNOh81vuSbnxx1ZW5HDkr2A9Ctk0pZSw4VUlkLM7Ey0hxlRaOFjUAbtvl+7oUFE8KK8/xDMSGkLx/ZcT0jIwvVhBPs/DeW38gOKgZC7Yb530RoF2bi+f87FLyNjA0WUOhODZwog8RnpUj1wHVFsMjzjvWBzw2lNnjMr+MTq6UIc0fUHZ+fCRoFsLazOp04ifas2yspKhoIKBi2aSQxlR9zSJPngzU//m+mDDXNjJqJMb+EiImw6rO6W21otYcwzjrGBE3i62MAsGE+K+se+LocRgqrvCg1ltOALdB06OHIjZDYsaZ26FAz8hfSGBg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:00.6612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9163f36b-bb20-469a-e468-08dcf92b6857 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1125 X-BESS-ID: 1730324402-312176-12713-40675-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.240 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGRuYmQGYGUNQgzTIlJS0lxc gwycg8ySwtzTLRNCk5Lc3MMDHZMCnVUKk2FgBatQBoQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_SC1_TG070 META: Custom Rule TG070 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_SC1_TG070, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add etities(utilities, structures, etc) required for flow support Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/include/flow_api.h | 34 ++++++++ drivers/net/ntnic/include/flow_api_engine.h | 46 +++++++++++ drivers/net/ntnic/include/hw_mod_backend.h | 44 ++++++++++ drivers/net/ntnic/nthw/flow_api/flow_km.c | 81 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 68 +++++++++++++++- 5 files changed, 269 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 667dad6d5f..7f031ccda8 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -85,13 +85,47 @@ struct flow_nic_dev { enum flow_nic_err_msg_e { ERR_SUCCESS = 0, ERR_FAILED = 1, + ERR_MEMORY = 2, ERR_OUTPUT_TOO_MANY = 3, + ERR_RSS_TOO_MANY_QUEUES = 4, + ERR_VLAN_TYPE_NOT_SUPPORTED = 5, + ERR_VXLAN_HEADER_NOT_ACCEPTED = 6, + ERR_VXLAN_POP_INVALID_RECIRC_PORT = 7, + ERR_VXLAN_POP_FAILED_CREATING_VTEP = 8, + ERR_MATCH_VLAN_TOO_MANY = 9, + ERR_MATCH_INVALID_IPV6_HDR = 10, + ERR_MATCH_TOO_MANY_TUNNEL_PORTS = 11, ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM = 12, + ERR_MATCH_FAILED_BY_HW_LIMITS = 13, ERR_MATCH_RESOURCE_EXHAUSTION = 14, + ERR_MATCH_FAILED_TOO_COMPLEX = 15, + ERR_ACTION_REPLICATION_FAILED = 16, + ERR_ACTION_OUTPUT_RESOURCE_EXHAUSTION = 17, + ERR_ACTION_TUNNEL_HEADER_PUSH_OUTPUT_LIMIT = 18, + ERR_ACTION_INLINE_MOD_RESOURCE_EXHAUSTION = 19, + ERR_ACTION_RETRANSMIT_RESOURCE_EXHAUSTION = 20, + ERR_ACTION_FLOW_COUNTER_EXHAUSTION = 21, + ERR_ACTION_INTERNAL_RESOURCE_EXHAUSTION = 22, + ERR_INTERNAL_QSL_COMPARE_FAILED = 23, + ERR_INTERNAL_CAT_FUNC_REUSE_FAILED = 24, + ERR_MATCH_ENTROPHY_FAILED = 25, + ERR_MATCH_CAM_EXHAUSTED = 26, + ERR_INTERNAL_VIRTUAL_PORT_CREATION_FAILED = 27, ERR_ACTION_UNSUPPORTED = 28, ERR_REMOVE_FLOW_FAILED = 29, + ERR_ACTION_NO_OUTPUT_DEFINED_USE_DEFAULT = 30, + ERR_ACTION_NO_OUTPUT_QUEUE_FOUND = 31, + ERR_MATCH_UNSUPPORTED_ETHER_TYPE = 32, ERR_OUTPUT_INVALID = 33, + ERR_MATCH_PARTIAL_OFFLOAD_NOT_SUPPORTED = 34, + ERR_MATCH_CAT_CAM_EXHAUSTED = 35, + ERR_MATCH_KCC_KEY_CLASH = 36, + ERR_MATCH_CAT_CAM_FAILED = 37, + ERR_PARTIAL_FLOW_MARK_TOO_BIG = 38, + ERR_FLOW_PRIORITY_VALUE_INVALID = 39, ERR_ACTION_MULTIPLE_PORT_ID_UNSUPPORTED = 40, + ERR_RSS_TOO_LONG_KEY = 41, + ERR_ACTION_AGE_UNSUPPORTED_GROUP_0 = 42, ERR_MSG_NO_MSG }; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index b8da5eafba..13fad2760a 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -54,6 +54,30 @@ enum res_type_e { #define MAX_CPY_WRITERS_SUPPORTED 8 +#define MAX_MATCH_FIELDS 16 + +struct match_elem_s { + int masked_for_tcam; /* if potentially selected for TCAM */ + uint32_t e_word[4]; + uint32_t e_mask[4]; + + int extr_start_offs_id; + int8_t rel_offs; + uint32_t word_len; +}; + +struct km_flow_def_s { + struct flow_api_backend_s *be; + + /* For collect flow elements and sorting */ + struct match_elem_s match[MAX_MATCH_FIELDS]; + int num_ftype_elem; + + /* Flow information */ + /* HW input port ID needed for compare. In port must be identical on flow types */ + uint32_t port_id; +}; + enum flow_port_type_e { PORT_NONE, /* not defined or drop */ PORT_INTERNAL, /* no queues attached */ @@ -99,6 +123,25 @@ struct nic_flow_def { uint32_t jump_to_group; int full_offload; + + /* + * Modify field + */ + struct { + uint32_t select; + union { + uint8_t value8[16]; + uint16_t value16[8]; + uint32_t value32[4]; + }; + } modify_field[MAX_CPY_WRITERS_SUPPORTED]; + + uint32_t modify_field_count; + + /* + * Key Matcher flow definitions + */ + struct km_flow_def_s km; }; enum flow_handle_type { @@ -159,6 +202,9 @@ struct flow_handle { void km_free_ndev_resource_management(void **handle); +int km_add_match_elem(struct km_flow_def_s *km, uint32_t e_word[4], uint32_t e_mask[4], + uint32_t word_len, enum frame_offs_e start, int8_t offset); + void kcc_free_ndev_resource_management(void **handle); /* diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 34154c65f8..22430bb3db 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,17 @@ enum { } \ } while (0) +enum frame_offs_e { + DYN_L2 = 1, + DYN_L3 = 4, + DYN_L4 = 7, + DYN_L4_PAYLOAD = 8, + DYN_TUN_L3 = 13, + DYN_TUN_L4 = 16, +}; + +/* Sideband info bit indicator */ + enum km_flm_if_select_e { KM_FLM_IF_FIRST = 0, KM_FLM_IF_SECOND = 1 @@ -133,6 +144,39 @@ enum km_flm_if_select_e { unsigned int alloced_size; \ int debug +enum { + PROT_OTHER = 0, + PROT_L2_ETH2 = 1, +}; + +enum { + PROT_L3_IPV4 = 1, +}; + +enum { + PROT_L4_ICMP = 4 +}; + +enum { + PROT_TUN_L3_OTHER = 0, + PROT_TUN_L3_IPV4 = 1, +}; + +enum { + PROT_TUN_L4_OTHER = 0, + PROT_TUN_L4_ICMP = 4 +}; + + +enum { + CPY_SELECT_DSCP_IPV4 = 0, + CPY_SELECT_DSCP_IPV6 = 1, + CPY_SELECT_RQI_QFI = 2, + CPY_SELECT_IPV4 = 3, + CPY_SELECT_PORT = 4, + CPY_SELECT_TEID = 5, +}; + struct common_func_s { COMMON_FUNC_INFO_S; }; diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c index e04cd5e857..237e9f7b4e 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_km.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c @@ -3,10 +3,38 @@ * Copyright(c) 2023 Napatech A/S */ +#include #include #include "hw_mod_backend.h" #include "flow_api_engine.h" +#include "nt_util.h" + +#define NUM_CAM_MASKS (ARRAY_SIZE(cam_masks)) + +static const struct cam_match_masks_s { + uint32_t word_len; + uint32_t key_mask[4]; +} cam_masks[] = { + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } }, /* IP6_SRC, IP6_DST */ + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0xffff0000 } }, /* DMAC,SMAC,ethtype */ + { 4, { 0xffffffff, 0xffff0000, 0x00000000, 0xffff0000 } }, /* DMAC,ethtype */ + { 4, { 0x00000000, 0x0000ffff, 0xffffffff, 0xffff0000 } }, /* SMAC,ethtype */ + { 4, { 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000 } }, /* ETH_128 */ + { 2, { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 } }, /* IP4_COMBINED */ + /* + * ETH_TYPE, IP4_TTL_PROTO, IP4_SRC, IP4_DST, IP6_FLOW_TC, + * IP6_NEXT_HDR_HOP, TP_PORT_COMBINED, SIDEBAND_VNI + */ + { 1, { 0xffffffff, 0x00000000, 0x00000000, 0x00000000 } }, + /* IP4_IHL_TOS, TP_PORT_SRC32_OR_ICMP, TCP_CTRL */ + { 1, { 0xffff0000, 0x00000000, 0x00000000, 0x00000000 } }, + { 1, { 0x0000ffff, 0x00000000, 0x00000000, 0x00000000 } }, /* TP_PORT_DST32 */ + /* IPv4 TOS mask bits used often by OVS */ + { 1, { 0x00030000, 0x00000000, 0x00000000, 0x00000000 } }, + /* IPv6 TOS mask bits used often by OVS */ + { 1, { 0x00300000, 0x00000000, 0x00000000, 0x00000000 } }, +}; void km_free_ndev_resource_management(void **handle) { @@ -17,3 +45,56 @@ void km_free_ndev_resource_management(void **handle) *handle = NULL; } + +int km_add_match_elem(struct km_flow_def_s *km, uint32_t e_word[4], uint32_t e_mask[4], + uint32_t word_len, enum frame_offs_e start_id, int8_t offset) +{ + /* valid word_len 1,2,4 */ + if (word_len == 3) { + word_len = 4; + e_word[3] = 0; + e_mask[3] = 0; + } + + if (word_len < 1 || word_len > 4) { + assert(0); + return -1; + } + + for (unsigned int i = 0; i < word_len; i++) { + km->match[km->num_ftype_elem].e_word[i] = e_word[i]; + km->match[km->num_ftype_elem].e_mask[i] = e_mask[i]; + } + + km->match[km->num_ftype_elem].word_len = word_len; + km->match[km->num_ftype_elem].rel_offs = offset; + km->match[km->num_ftype_elem].extr_start_offs_id = start_id; + + /* + * Determine here if this flow may better be put into TCAM + * Otherwise it will go into CAM + * This is dependent on a cam_masks list defined above + */ + km->match[km->num_ftype_elem].masked_for_tcam = 1; + + for (unsigned int msk = 0; msk < NUM_CAM_MASKS; msk++) { + if (word_len == cam_masks[msk].word_len) { + int match = 1; + + for (unsigned int wd = 0; wd < word_len; wd++) { + if (e_mask[wd] != cam_masks[msk].key_mask[wd]) { + match = 0; + break; + } + } + + if (match) { + /* Can go into CAM */ + km->match[km->num_ftype_elem].masked_for_tcam = 0; + } + } + } + + km->num_ftype_elem++; + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index d61912d49d..1b6a01a7d4 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -416,10 +416,67 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, return 0; } -static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_data __rte_unused, - uint32_t flm_key_id __rte_unused, uint32_t flm_ft __rte_unused, - uint16_t rpl_ext_ptr __rte_unused, uint32_t flm_scrub __rte_unused, - uint32_t priority __rte_unused) +static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def *fd, + const uint32_t *packet_data, uint32_t flm_key_id, uint32_t flm_ft, + uint16_t rpl_ext_ptr, uint32_t flm_scrub __rte_unused, uint32_t priority) +{ + switch (fd->l4_prot) { + case PROT_L4_ICMP: + fh->flm_prot = fd->ip_prot; + break; + + default: + switch (fd->tunnel_l4_prot) { + case PROT_TUN_L4_ICMP: + fh->flm_prot = fd->tunnel_ip_prot; + break; + + default: + fh->flm_prot = 0; + break; + } + + break; + } + + memcpy(fh->flm_data, packet_data, sizeof(uint32_t) * 10); + + fh->flm_kid = flm_key_id; + fh->flm_rpl_ext_ptr = rpl_ext_ptr; + fh->flm_prio = (uint8_t)priority; + fh->flm_ft = (uint8_t)flm_ft; + + for (unsigned int i = 0; i < fd->modify_field_count; ++i) { + switch (fd->modify_field[i].select) { + case CPY_SELECT_DSCP_IPV4: + case CPY_SELECT_RQI_QFI: + fh->flm_rqi = (fd->modify_field[i].value8[0] >> 6) & 0x1; + fh->flm_qfi = fd->modify_field[i].value8[0] & 0x3f; + break; + + case CPY_SELECT_IPV4: + fh->flm_nat_ipv4 = ntohl(fd->modify_field[i].value32[0]); + break; + + case CPY_SELECT_PORT: + fh->flm_nat_port = ntohs(fd->modify_field[i].value16[0]); + break; + + case CPY_SELECT_TEID: + fh->flm_teid = ntohl(fd->modify_field[i].value32[0]); + break; + + default: + NT_LOG(DBG, FILTER, "Unknown modify field: %d", + fd->modify_field[i].select); + break; + } + } +} + +static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_data, + uint32_t flm_key_id, uint32_t flm_ft, uint16_t rpl_ext_ptr, + uint32_t flm_scrub, uint32_t priority) { struct nic_flow_def *fd; struct flow_handle fh_copy; @@ -443,6 +500,9 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d for (int i = 0; i < RES_COUNT; ++i) fh->flm_db_idxs[i] = fh_copy.db_idxs[i]; + copy_fd_to_fh_flm(fh, fd, packet_data, flm_key_id, flm_ft, rpl_ext_ptr, flm_scrub, + priority); + free(fd); return 0; From patchwork Wed Oct 30 21:38: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: 147776 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 EB8EA45BCC; Wed, 30 Oct 2024 22:41:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AD9D43450; Wed, 30 Oct 2024 22:40:19 +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 EE463433EC for ; Wed, 30 Oct 2024 22:40:05 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2040.outbound.protection.outlook.com [104.47.11.40]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DKOzMAKrEj9KRI03Y1874O6a48Pb4u+Pysw1HkrK4YjZPoTXQlukpMb8nwhZKtJHo9RQQPNlrsiHrCX/eK6phVzn9YqpwZt6Cc3U7sCOR4ZvwLE0J0mzqIHRP3cTcq0yiASEm0HRtQAdjLavXkYblhhB6fXjZ+dTggEL7p/2bpGZ7lYGJqBAzaEN2HpNoEVBSc6yS+nXcafYz5k9qSuHe+umLBS/OaQ/4KRlgbzXQPhaWSXV22/Y4ZTcA4350keV3IGyyY8pbP5nnTG1knS8je6ol/H8FbUFAxq714tbx2Cpxwr4vVNAqyv5SGPARxrQV8/KsutFCcc3ACXqpgf5Mw== 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=x2OtuHV/CjfC8D9R0sKYNF1PiDI846VFhHYkd+z0BaM=; b=S2u4C45OxUhQCkCBBZh/nd0SwJqj5amD8XTgUXUJJzIXu6eeUusbFNWsLmdQlB2kBEsWj99FxkeBenhPjRSvnrDDBM3PwN1LVO6dJi/Olt3H0dcrieam+Kz4QTVmTy9tlqeeHevLTSB925mp2SyYuGQR5KlryB8uCcoRl7rdbJR+jLYVYxoV1KadnUbBZmeJxI3VY6VQaVL0WIJCzPLPu4x62VXLFjLA165KCAshp0Ymc2eeyWXkEjNhxpRqAfloiwXCsgBcwmY18frLBps2elRoMsaw3NU/0M/CxhJNXRdeJH2NoKN6nd6EQWOSgAmqIyLOepV96yLz8QDZo75ykg== 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=x2OtuHV/CjfC8D9R0sKYNF1PiDI846VFhHYkd+z0BaM=; b=JHL69kuHN7H8gzugImNd4Xta2onIab+5Dp1VD7a10FQxBSgMKtL+zl8qAMwW3fZAw7leWHbsby4psGOsv40kCO3fPFZvHHiOtHO53C/czBoy7wXfKxHDGlxryb7mN+6egFY9njMeDJjlINFET1ZWy5K/HhzjoczJw+imXA2ZZDU= Received: from DUZPR01CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::9) by DBAP190MB0966.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1a3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:01 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::63) by DUZPR01CA0005.outlook.office365.com (2603:10a6:10:3c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 10/80] net/ntnic: add action queue Date: Wed, 30 Oct 2024 22:38:17 +0100 Message-ID: <20241030213940.3470062-11-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DBAP190MB0966:EE_ X-MS-Office365-Filtering-Correlation-Id: 49fd9551-8b64-47e1-f30e-08dcf92b68c7 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: clHzpJQ9P1cC2T3h6q1ZtCLl+OtJuHwJv6OF0pOpxidpKYfYgN2EJltJ98iKMnYqiHAdTGJEZ1M51wL7jYh3Xz6sq+/+bQvujdb5Y2y24YO7Yw/QWPjFXquZcdpcL2EWLhi65mXUKd+ZAGQIg7cA0hus4KOTPmUM3qp+CK8fgC7hOHwWwAm8plz/rfg9j8wPO5hX/+I+DTdrvV5e/YiS9eHUP93NzAlarXiCHjppiUHm10JPap5X8wBUi/V0+wUI8Bos6X3VUflgmHELJtQ50v4Y2J4vXL5oakaODUz5RhDs/+90pEmKo+qOJHLtZWoF8zBVPJjDLsi2wYgBG9zyB3pufN/H/ZHUoJGiLoopFLtPve96lzHNji4peV9ombWbtXGH3/Xyv3eUrFvHASAAK/p+Sa3IfiTveuvq/2X0roVoINkiBG+YTP42CEm71WyN/Ed97TZW7grQGFvzNJ+uhyRGHIbin9wdyui9Kq85I0k+XFAeRrkDTvK5HHL5Ll+S731XqSI2jo7tK28DPe9Qh12jD2dDxqm3lpD+s2CnReJ0szpoW+hb7ySoQKV+lfz7sMI109/7ITiYwRlC1n0WNtIUuPF8JoGzMPP9gLY2+OVgjKYIYQhJQwX5qxqMhwh/jv7krzxSmhCRqG2thr0bdSUvo2tduLWtZKtvn4Oh0953ZbTkDrs/tzmWDz0sXCwOFfD/cGa13I85qquzeFWDr16z7pAqkDozUiiFRMNdQ/mRCj44KgQ3+71b5fFFaM7O4WcjQy7iBGEPbCtdhd/bXOjwfn1Rdx43XrEMCtZZESJs3wnyPIqA83kmMBIJT+gaI9aDggO5PjTudZmPXyJX8wJ0vtBhkAjc1vhOdUJFWZ3p5ANQ+KGOYCCxy4PT6/k0rL8SYJk+PdHuOYKhAG14tYRSOEkNCao/fxbTTocSawAqqzYsLKIOSd57toeh3XfqY4IFCkrMpud3RgdNlz9e4KFf4nyF5nC8ctJ1vjWOR0SkD8aA2+Gh5bdB+VYPQXN5yvCjFr0FUIgerL7UwL6sh8abXQucvEavO40IOMp0h08zkroSU3Y+JHWcgTDDGXOYPp7wchwTQmnQVWEnU4gHF3hBzhkfOCjv3v7Et5x3XEo+AZTr1uJDNtWG7nZnlRruZcJ8VG4H1YpVeA4nHU2WOBrEHhtzdtVtiHw5pPQjnegVJwvBNkPoXlsJXq7XFvWeEsCDtwdrASdHHeLXWK9DtobhPWqwjtzCXRW8wVEnfTBOUdby4e8t+bLdn0QHsBaf8FCa71OMZAs07pZoXaOZ7eAu1qBysGdMAqABhlEmuGnAJqBS8aw6zPtsNnp2uFCXO5X3cqHmnzLKURYMwkp5e7nhecwFDrNxg4I6ewzvlTIxqimUR/nwsgDksJrEuK6JqYDWdk5dmFzIqHWKg1VfGQ== 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: mQmGzEW360s1eZ+9rOwdFJuVnElz0FcxJ5GzN1/b6Z1WtQ6BWeXr0z4Hc6VoeqZtyTiI9QGP8PjMZrYWDHi5z58vyGwMuBCApePByxaPdYfx6/0h6ShYQBLOurH4bwI2QQiWAPy8tzsrN+0zWRm6Azp/GH1ivLtRr1FnHg1ZIK1Y2TeGatMAL7a7JyMEInrsRI9NzJx5D2WguhnTp9r4BToqhePBivy+UD8XGScjmoeHMROC571wBFS6exE0tZpb6jtFP01m/1qfeS4gFNX9SLbNTkavN1o89P14/Gqlo9dsrMP2nNbLTZxW63dHq/T2FefR7V9jKxSSgyPClBtRNqtCxQ+SfdaHyYjJq0GvDfxWlqL6NzgWEptfDtRoXrw96uZyyp/ILBJYlcujHyCw1hrBMKy9hALO2RSkrgDNnWzQ2T6BlcPOi6Xbzwu9qW96fmey5vvgyHLz1agfHhjiJhW2m84T01X3guw4ZlzohGp3YwCCGg78tRbS1zm+X2XRntB4p7Y7Og3s31JNDPycHbdeTL5tzkwX/masCjy8JilhwP0HzDNN/99p25VQTf74X2ysofyAcAebHmp+w3cvpwVJlaA4jSBhFrEFohPYM71e1VOBCnnqwrZwET05FXjSn3XQdiOjMZP2iS3ne4tVwtkgN7UQbIFm1IqDkM8UF3g= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:01.3955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49fd9551-8b64-47e1-f30e-08dcf92b68c7 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0966 X-BESS-ID: 1730324403-302901-12798-43449-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsYmpuZAVgZQMDnJJCnFIMnUKD UlJcXS2Mw4zTzFOMkgNSnZICUxycxUqTYWABOtvJ9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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_QUEUE. Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + doc/guides/nics/ntnic.rst | 4 ++ doc/guides/rel_notes/release_24_11.rst | 1 + .../profile_inline/flow_api_profile_inline.c | 37 +++++++++++++++++++ 4 files changed, 43 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index a6568cba4e..d43706b2ee 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -42,6 +42,10 @@ Features - Promiscuous mode (Enable only. The device always run promiscuous mode) - Flow API support. - Support for multiple rte_flow groups. +- Multiple TX and RX queues. +- Scattered and gather for TX and RX. +- Jumbo frame support. +- Traffic mirroring. Limitations ~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index a235ce59d1..2cace179b3 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -162,6 +162,7 @@ New Features * Added initialization of FPGA modules related to flow HW offload. * Added basic handling of the virtual queues. * Added flow handling support + * Enable virtual queues * **Added cryptodev queue pair reset support.** 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 1b6a01a7d4..f4d4c25176 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 Wed Oct 30 21:38: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: 147777 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 E685645BCC; Wed, 30 Oct 2024 22:41:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 510DE43465; Wed, 30 Oct 2024 22:40:20 +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 84FF243419 for ; Wed, 30 Oct 2024 22:40:06 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2173.outbound.protection.outlook.com [104.47.51.173]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jRPG4SrjAjnqybEARhCP9jasz6Da4A14P9IK73U5lOCg8FTBYh6692Myg7e92DUB+mj+deQ3Y7b9LFvEYnJMJhOWSbjNCbvkX78MSlFgguDjJe9viN9Ak1PJIaWNOyqGaNmsBzkbkzGHRUoak8EuhIKYwkXAXLNn++oH5Y/LzuihhdsWMnrByPtMnH63WUGr3KblsA+O2JBFnag2oR2Iv4Xr3CrtoIugubnYuWb2ZSgcsxncYTFSes6R4ffoA3F2yXNH8m9wgXODfL5pyylBwn1GiTCbyFVPVKWiK9gQpxJRt6+2RRMR9o+8F9pCsrCdN9ngcV0kCz+NWKH/IzidbQ== 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=GBS6K5whTPU4vzjllk6vGeAlHo3OUgLLJT1RB+/k/I0=; b=MT4iix+MgH+WICANiRsiLo37Ter2EiDnEyxe435A2n3skQsZypNs73NHNq0PaUqLW9zJsvC/1YIuOzIpbOeIaab5QiyKg1A3GQACwJ6h3/88BWFBTNFbeKsHD7ScaDE+Xw8o3W9+hYtQ+OVzb7tqb0MNkkbXHyWEVRk1IiNerSiijoQCq0ZdUkjSqXIpm/OQkVYJIreOBT0zOLZrFkehccxJaTEXNsLOHvym2x4z9H2+oHbFwjrE6wJsZ70lbXcwm5+x+mRXpqLmjhWSvNfXG6Y39eKBGR6kRP225fiGJlQ546k0MYMP0DF4tkZzF1gX+3flCEUgEjay/Y90+EiTSA== 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=GBS6K5whTPU4vzjllk6vGeAlHo3OUgLLJT1RB+/k/I0=; b=MfgfcqOhI0RmYavRFiqh1rnV3FeKThld4nF7wMWThJg7wD4M8e8g4uU/58wN4sYvXr9xAGuww4xKZDPvJMFtyxmbs0qA1x3f/17JzN+wucJTWhdpscp8RrHQ4ujA3h+5BzTQxJkdyVXEH42UZgrxEGvs7DgqbfqFBqGQnms+ppQ= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by AM8P190MB0945.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1d0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:02 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::e3) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 11/80] net/ntnic: add action mark Date: Wed, 30 Oct 2024 22:38:18 +0100 Message-ID: <20241030213940.3470062-12-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM8P190MB0945:EE_ X-MS-Office365-Filtering-Correlation-Id: 997d449c-aebe-4d52-3d27-08dcf92b6933 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: wd3RUn9kgBW2VVxo8lkPw8CIMlFFDcx2f0SFq9NLly9PZwgch+RHYFBE9MQWYLRU34W07ZwtimU4W7WoBHyyq9oe4borlbUbksNj9YN9bKr7hdSg7cmK1/g17OPRPvczgvqnTp24Y0eirGtvVOs29CMAtUCTaGJ/rVPQ9z03ZSBw6VeViQlX0Gg49hcW9Iu9gfQCoSGdIip+k+sYX/Nm7UXQ/EgM0e/0XdRgAs+yqR6HgWBS8TiGlvca2iKxYIuAmiuTtUzbvnOG2FzHDTPixDGUcsHF4Nse/6dDveJl6aRfBw3nAXooia5mCKbfBznc5H/GGypNtlvZDxa1Km0wRGZ9kmsPDYWejgYwsyPfCTCZphuRWct3e55KaEwVt3fLCkkVuepggjmgimoQWGxN+Ij+9SnxGnEey4GIzwhOEuYAN3ofI27kBll0QJ2Dzqri5fh0OQQogCjGAj/CevHRGBBv38aBI5GRPtOMZKzDtI0ZPbPBIzeeReNNB/g8ol/744YmlGrBKkB0F/EoyJmiwKDvp/ph4jmXZvgkF7UeZP4n5j0iwEdnQtgrBIVYl0sS6wWqriNxloC2oQxQpOO0maTI9hGj9Ho+0ECUYKQTgL2kRD/W9OovqM1BvBcKjPI2cVaIJFLuVpSXT2Y6lZnq98pwX5wiHCpjM9JhYP0NfnH8DJDxvVUJ2YEEF6eHjaaKHHkNQmMrkZPcTr4MTqM/5fB+pzbWQB4IaW8NNfn8IpSteR2BX8k5RtIsc1dQkTGjtVRLECU+7dhKfGU9WB/TuXYh7kE+EmBEfLD5jfS24MGoNbgmYJHjxKdh/KGwaZV8Sa9QwjslsGLebXTM9oJfF+/uMLunOrBDmQUIu9TWPLtGAqhNrR9UJDN/20VbPUYpkPfrwHIR2Y03JPoPKEaHwSo6cZoFBOR+z3dfA4X1ETZu30sd+eiKqlTKibrj6RUHLekwx7DGcWb/chhhLVJPOhdRQnobe6hgHL/T0LZRzCqCXL3LaITJdHaG8CXlOI6JxzJT3BAbvB4oDPcJyAUgYPJ440AOAt8zHIMjPMQJc1QjJqukEdPnpd57GYpbl67C3MHMxjhkBfmFP2ti9uicVs4bPANMNKceAZsFFW02Y6ALhTGdWRtXKO4fsVBYAFASEbg26Sb5VUqaA1hvgWvOExUCT40Q5ANzvrSLofsefebgB3J116tKC5ypqyMvim+Uh53YB6WhorO9i7MO5KPiXfoxsCsuhj0kZiRZN3kXBTobhxP/12qraHoPV5FWeCudG7YyDK6mzHuXGe6pp3mJM+w6e/9DQNnyAuQDEAc1TfDY78dwbEXkhf+y6UZkPuluRQAbzUqMJgOo/C6vgUoq/euCgnQ+oZsE0tq8yx8GCQ+y8WZ68P+qO6iTMraB72lY4v/hr92hb1EenqgW+7W2hA== 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: F+Nn9IjE3H5ElhoWt7dtHu0SgvylkX/NvwpXUepx5lBFOetMR9To66f27hyhSowzSwAFahwE4O5H9BOfEpkqpKSl+soEjezBGvyxKJ1hMC4qQrBzeF46wM22ePw3LhhdWb3oQP13NOyetUZ7gFN7DHg5rtIq0wefp03U9EE6rOC2R8j6fEV6VpjDpRFRYJnq9pQarCVuOibAEzOTf2Jf+LVmoBSlP6xADmYa5igJli2KxvmCrCjH1pXxUpjhNvdyPDdcysl8rRwY8Wk9lTDE0bHAAjwNn22/UvoF9YUzdmNHoyxB2FWyEWbcZ218VYJG4WQhTkiIY1W1Nk9csgsHnJkWor/hOtMYt86r5yGww3X4dKJokOcrFC29hSgIM0R92tIwkhMWrGpw76iekux/v8oLK1+lNeUOMxc3p3vZPMHByya5eAeiYjM9zNEOaAw3zAFzFG+ZYT75RxPpUlYMvDjZm/iVRKiJ0bYnnjf85/hBuo8DrLq+gDEPqvzVYYUjXYDvTfK6UChvjAkNW0A5fGpT0YQXXey62meWWoUpRlnexO7esUFz6fnow7RTRzlnun5Cl384mdrq+KwYkodDVdM3p4HOkBINcLkscUDqr/svbU8+VV4sniI7gIQdCcp3ApcGImuY1xQrh/aXHdhAHinCMzo2AP8I4IZbmJU7GtQ= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:02.0987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 997d449c-aebe-4d52-3d27-08dcf92b6933 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P190MB0945 X-BESS-ID: 1730324403-302901-12800-43450-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmliZAVgZQMDUxzcTcJM3SzD wx1cTQKNnCJDHF0NzI0jgp2cAwKdVUqTYWANQwwKBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.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 f4d4c25176..e8b31dbdd2 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 Wed Oct 30 21:38: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: 147780 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 382A045BCC; Wed, 30 Oct 2024 22:41:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C12E743486; Wed, 30 Oct 2024 22:40:23 +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 D895743386 for ; Wed, 30 Oct 2024 22:40:08 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2171.outbound.protection.outlook.com [104.47.17.171]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r3zlUDWGiS8IKEEeiE3g7gY7dafVZ9V8wYzhvoOE/eUx3wW8BkPJvyHrq6yaSu6qvltb+UrrNwko5Sq74BhDIFmbcxJTEox2krlRLTbuXiojc+g3G4XH5QaeVCGlkB2SEhh55wFVqam4SQ4K8pK1RM2HYAXygzKxz3HusrdZIR00ET2XZcdDnhflIQdDt1Ra6EX11FgSzvtwtuNfWpgDTVI8fWeb7k8PmR5zjOY1wu7wRKCVVnlvtLVylqrewqoCx3Mx4n1jtZxkFEbilaU51+K40juRo+Ko2Z9kgtgemrh6GJFWbzvTxBLJxAg79OgsLBwsjT4WtJhgtGduoVeG/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=g6gHkphDp1JSMWlTnCTkgIeiAEOkkrwEA3GN5GloLPg=; b=qmbh0LpcLLR4NtYqniTbCOpBDjji+geSiRv/aUsh3+RrOE6666rZZNSIdQVi79xVLVHu1kcA2Ci++uH/g0VgqDfBcQRvqVxLO6mbzdafYYYK/X/6e+3fRp8xbH3ycj+LS+pcILk0XnBRPtziakBKBTL1XC8CfTHhEKhJbOxtDmdXVdQ9rYh5h+avGEP6Bnu8iG5zh4dFUZ9UI/aOToOB+cPcpr0lXQnWVFhQMhN4l8Bco7QcfAza2OlpwjvWyhGOtYpsCeyJcw0bG0/VDF1GgaQtyYKuKyyc0wtTO9ocziDhDnZ1sOB5zAgw0ofalSFkDYKyVB7E2toGCGsY0/a6rQ== 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=g6gHkphDp1JSMWlTnCTkgIeiAEOkkrwEA3GN5GloLPg=; b=dyG/5ssujvjY9eaYggKeLDWmM5acLRAL74aMh49E98MmtXq5epVhM70ymOAjmNaqYDZFZ3zDPFvM1Y/vtoZDqBmMQ6IBIqIlhSKOZDtJazR+7D67rzIYmrkyPp5WlKmPK0AV2x87LuPSLCB0Tym2vfZvy1Z3Qu3dQWHYiQF4Ov8= Received: from DUZPR01CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::9) by GV1P190MB2020.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:5c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Wed, 30 Oct 2024 21:40:03 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::16) by DUZPR01CA0005.outlook.office365.com (2603:10a6:10:3c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 12/80] net/ntnic: add ation jump Date: Wed, 30 Oct 2024 22:38:19 +0100 Message-ID: <20241030213940.3470062-13-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB2020:EE_ X-MS-Office365-Filtering-Correlation-Id: 054dcf1f-34e2-4c56-d555-08dcf92b69ac 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: eRQPNXZOsRZqKpl4mFPvurYHHjlARJaXvDhc7B/7KpOX8JhwvOL/rpXEYqP2r9LHweB4f3MpXdNAGTcKGXzC7Mcsl79OmumH10vjgDQYXVjVbZbOakFLV4OQ1GKjXDlkMgEUd5gpV8Tnp6bQvVf5EXI87kZQ24VIr1sa5fyty40pNXtXiiR0TQtVBIO3u61J+MTu48XIOhLqeXITxboUFt35G2CIKj04vfv1Njinvzdc6nATKMNu0hcR6n4T/FxAR/2mG3cvmmZSq2o746Po27M59Dtm8/hkmiBNlglTniJs5tVWGrY78Obj/CP3AyVQPpgrXOSxHVbS8zB8g9NIkqfKgeElKyfZ44f3F6fSrN7S26+h5AS5JE8TZ3RMEUuErUBwbM/w6W31CGbpmBY8rBIvsy7tpkB02f9HoGaUGHi+FtaZZ2RN1FFGGiqtQZVDv2QdJIetAbS2NSu8rKkJEpRzddro10eK3dctue2ovnjtnnO2WqP8BaXTqmM+NeMMUpVIHn5OrP+Goz1ObW4ZKq3Oj/UPPJgdRABcuqdBSpnAA5bOIFy1TUapLxpqFsdzxEBghBVvSL/i0kDvdi8iLmiWXEevJwZX5ySjRNoeJXdEb67k3sfx6vfdOvh5/wYNb95YcK+OghI8TXUd0bDJmXf3pdXG56AD4b3I6p+s4YyqxY3xyOWxT0PbqWrkSwJL8KYuDuZeaH8FZrOoaOD+cTU0HFpsi1ymQFgECk4IAGvjmGPpzmkvsWURSGMl+XQMgJI/XN6LItUsNh9f3cC3GwgaU4MeX85yBDsDdXOclOPZXhpYj56TRctLqvEmfmApEmOt+DD50c6FgEfg53ANhu2GnxpYCWlVWf2x2jPykDajqdpSWF1zFXr6oQ5fhKt/6fo/P6o/1FnEpqykl7pan+mcPBNjhvxU36HpqVQMEEcxYYR+v20PGpAr0G56MoGzWJLnGszHLJopRQNGt3xm8nqnFUnXmpZNbR8l6CkT00fm7dNvDIUHGpKC3PEkVOY5+Yi58jlZUxDYXAthl3DTlZQL53o5XL1oBKjpIU2J25eULI9jBOG7YGvcMeVFMp2NDprAQhDmLe1L6kIvGKp1/hozIb5xS+I1XbPw/zmyKDnVr7vzI9kCorBIQlacnNkFYngzBAiY5kM7+iJVNYaPmPEhjuZezdTCeV/BR6BZxsB5yZGZucV4nTiy3cD/OAa8E+k1ROu+g17/zzuoEQkEhRGG3MRo9AVASi7NKU8MPkcuiOyYVb5fTNIsoEcMrSSiNNSTNmJfQv/R3ldUK3ZtuPu6ERnSHwbQJbw7JTAXQ7e3GOodHVtmxfomvGmihOinIPXNiblJ5ZQ4QthNOVj7zMAIruuhlNd/P62xGzk80lIQDT6fShD5nnbUW3wF4RdEwwGrmQg+LVN32HNe0QTn8w== 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: JTUa+bs7E5xgXjDvRoB3v6ADVUUTwp3Stp5Q9o0Qly61e3BXePZo2DbIzHLyQ6uVyVEf9dvgTaNEDupC/uSUxZIinvWud/yVKX6SgXo0r9+3l4jr/dhYa8pRqmdmIOWYFeTGPbK+CdO5l3H+4PdwaGK6c0GxV00szC48iujKgJvCiHKuFK3CJ3jaRzMfPHs9MSc9HkVNY2LwxzZ2sK3fxwKnInGUlU9XtExa2rKyY5PqvLKr7JiW4+ao2ZH2LU3bScDvYG8lz0JTWQrjzrqSvBYXEAc6ZjAopFv5chf1nv/x12zkkFkU+3yrK3Fjxl3qx7sZkKAqAXOODrEO0V9Kq4z352Xh8TTtEygWWtcdRdq3sYKEVBi6NK24IYmlj+YuXxF6kejdZT72FFJtdKnDmjmkjS+YX0S+pwb42tfaV2kl0hjeNgl4RBqslELB24Fx3+mcn+3WAMRH2dDy/5lSh/8K0iLR/5fQ4bbgebn3op8FxgLcTDYEVc5tdP/z1oKHzt9eZ84oE1rU/smHTbJxuJHE1S1Q+hn/zFSifKgSrurmZN1tdY4Rxc/6lN+Vfm2OEL/FlM/3LU9xw5rwtcTbrJpcs6adxuZDvi71KvzaYnBo7Jolm6/zTTTfmnKfQTDrbteRaRlI8da/PsE2A6vhhdbuVrzkwdyHzlQGRhxVH2U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:02.8487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 054dcf1f-34e2-4c56-d555-08dcf92b69ac X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB2020 X-BESS-ID: 1730324406-304433-12632-44612-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobmFgZAVgZQ0Mgg1TjRIjHJ0C DFIM3UMNEw2cDc1MLc3MTAPMXEwMJQqTYWADgsGM9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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_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 e8b31dbdd2..9dfa211095 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 Wed Oct 30 21:38: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: 147779 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 8EDD145BCC; Wed, 30 Oct 2024 22:41:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 788A743478; Wed, 30 Oct 2024 22:40:22 +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 0B415433D2 for ; Wed, 30 Oct 2024 22:40:08 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kXz3lWzNVqRAhJnyMJ6IGZf5j1GT+r06zBHs2LmyEKgTTzhGoaJEFcNNgFF3u0IGmSMSremawWvM8sh2/55aXSA+O1LBs45tv40SQBKMAWvUuF8idPQhkmLbic9qsWnyNwtNW4KsXMyqszkg1231zW98+tJrIgXvryiXPuyA6VztAaQUUz+z0SouR9IPLcB/1mdUvnotwNEAVtUnE7KfR5tpQPiNamieFixTe+WWqwrXjXd9QJWwWLne9c8X4AsedIKTFO4aSzTizS20IxOSiLUR0MGGJK3EANsruqW30+eXoY3lnDL0u8fZEwX+V+/xVE2VOOAJ+komwT+6lEU9GQ== 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=U68BvGwErdySiMm9SpZA8piB1vj6cszSQZMUY0HwCx4=; b=eSSTu72cJNBTMZOZISNd5bD3rme4Km2ox2A+7Fv9Yu9hc0vU7+GrezAUF1Sa0gljgZtXdj+B/AfPZrAAY0iYDmpv3ssR3VmRveFMxutTGDRKEaEJcPV7IGYBCHowRS98F/RXdDSBlAWoE+tiEp42NnzlCoPLYo9Zixxc28lk9daxKbembWA0ZGeAN0XGFw9GncSgvOBrVZUSh3z6rRU8GTPsx4ua/t+n/G2xOr6DBUaS7FyBFvnl5nzGBRY00lr78232VI1F+MzFolaOFEvnYJZrKId5BNCksPHGVj+N4sc+smSy6u7ZvBAw0kJOxGDggHRXah/yb7rDH9ynokgqnA== 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=U68BvGwErdySiMm9SpZA8piB1vj6cszSQZMUY0HwCx4=; b=awT9ji05JJWPe0uHy89DuJa2Mea0F3z3OUvoYN1Ss2cjdzz28Q5AAbbZgoDHVKewjkh1CfMJaT/N24AcJsFYU8m+I11R26JcQdDUIlE3rpdzmVCM49pl5yVWwFt3F6sCM+VtbjGesjZdgNRdnTWPs09KPgu67o9be19iRz0HqF0= Received: from DUZPR01CA0015.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::18) by DU0P190MB1953.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:04 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::63) by DUZPR01CA0015.outlook.office365.com (2603:10a6:10:3c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 13/80] net/ntnic: add action drop Date: Wed, 30 Oct 2024 22:38:20 +0100 Message-ID: <20241030213940.3470062-14-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DU0P190MB1953:EE_ X-MS-Office365-Filtering-Correlation-Id: d7d1a823-ab69-4084-7ee3-08dcf92b6a58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: OLO4Q1ErlXf+MGoImXtaAFFCbsJcHebeyoMhjGxE0s3KDuFzUKuIEfd2sGo5VdSOQOPuQfaBUAx1Zp485D2VFWWN/g1OTsVz0CzbEwupAeGwKBc2X0uoNCGtNT25+rZ9JXjUG6ZvaIHhDWX9d5Gd5nDHeKsbVIml/62tsHihb91DjvOsBG3hrmJZOR0jj7TV3q3I1n88io0ZXHosDbboT3QyP8WPPPSiRcn++/B7uO16oVAnmK/C/S0G2GWXPrXb2ehQTdhNR/eEMs9Fu8lwv+womZM5s4iXkyb0SECK9tyD+7E5D4xRk2LLHMB46fTLvSKX62NbzE/F/UVxQ/hjKGG0Xp2LIAF641I10jOsrNUEVMcnnwTNevkhbR1knY4HSRsVaAif7Hnp2m21P8noHxAXTWDBScip+Oq3yFHWyCh0n+5KCaC5clVB6w/V2DIg9JgpUUmhDSz5GE7G+GzKXqcR43TliSh/a4ujCgT8CPxSHvzEqMGaUKqVhIDMz4O0fmud4BSDHG07lhu6A6bUOW0IfS95+aOYmlYsnwJaS2J/XDBArKoXV0kBhS/icvvondjPH7X0s9FoGhoHwY3fqeTtrD1kbFh7gpEewtDoFW+oDDK+qQC3iqoSgLuuITzqR/MzTjWO5Vn97LOq4FuKnBJIaHoxO8Ksvum1RtnbW9fUMGEE/xm/eLc/8gvEncX9vKw0gLbIwsZdtXHYlyLqPe/bLceXhT6XXiK+qwHneONrjp1CNtQ83Pe0CpuYeBYQ53R3hNT5uzy3XX/Yhce4hjctH7HBuM/CvLK4N8v37DFQaDDL6wsNoEpaXzQ+re7w25AeR70O338Eb/isduC9L493YJgOQmGCEeK/4elRKdjyxArHK3jqg/X+4hj8ZgvqJHX/I4b5y9xdTo6M5Fls6IWRrPC73ubE4g6YWK/4obZF1fFj4jt3+ABX+Tu3Itaxo4uhK8Xz1PmRLb5+FxZVJE9oI+gz2FAB3wLK4FMJjcCk3g0Naa/JzWKTGpH31/0EC7P8w8erGHL3fx/Yo02V5TGiIx45ewHCMEwoSKmgtM5I0hXUREA36Zbbtx+wsj5NIUOBwVXIysTRbHkA1FSxZwf+2n+nzpxFew0wRhdjBclQTDvBEHHahpJgvvt1OOQYqRX6H5888LDSbKtURxB3dL55hBiwXIZTVQnLcxfA5svNRQWg64zU60uKasMnLQY578d4D2jbjk4rRfJ6mPksJjhV4GZqedWXMu+L26aaLeXsijf1t9XOx+xKiuUJ0pak+sFajZo084nv3rpRL4oWzJysw6YHTl4PE7Dqg7DdX3bnlG6/6ktPl2VWieKfPLCnHT9bo4o8ac7T8VzpyavgGdy3fhpBNKlhSlwOlrcPVnfaWQye2RQrjJliz44o2z3d4cqoeE6K++H+ZPgsZtRHqw== 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)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: CvmN3gKwQ/sTpvhZMQd94KMdCMTJvhki5iT9KMEzC68xD7XyywTVVdxT0Ehz00d9ozjwjhJHI1xp1YdNST5vuiJSAY7+hsHR6J9HESROp1Ghh9qGR8yzQDVQRw2AHv9Sd/RwXMzgjvjC5h1vQXc3KsEHSkDXfi5GLQFp+0VRxWebBsQtGheANiY3v9JDEAlZsxyA1jgC2nAf9VY118NhlOzu5tfwpASadpkoOwQKnVXJKB/hoSFxHItGoIRApLk+zo0OcaH2NKTdhXk/M2yXrmZLaX4LjTS6XF3ybw13X8t4pKw0HpM8Z5oErEJ7Ozi33TM6dtZIWs/eGLFJ3sytLfTfSExHUkwT3yFGhKD+PioEjnF51wycpXE4vIuJCzFfWvl6W/lsL62bLaLRorZqjMTRg+O7MeozCNrsGd3bVC6BMpJOQi4vOw4//iJ5ZdyBRtna2wQi13+k6lwKD1lx2ZdyqrDhQYXMxZxbEp5tPWRcKVThtSnseNbMgu3j4g8cHz7lLXFobdEB5iJLc3K4s6LgGzWIWqtCjkWrSKBZ9b/BED0dw14tE/fl+CBj3eHBGRSbCcPkJQWA7VxsbgtEfDnNYhGASrPrx721jpdPsRwFCNJeD6aBE189I3t3y0gI+w7a/bS/DDxGCtn6I+eZGPaSWQ9iR8oc/sx8mcvDm1I= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:04.0206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7d1a823-ab69-4084-7ee3-08dcf92b6a58 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0P190MB1953 X-BESS-ID: 1730324405-302901-12792-43449-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamFpZAVgZQ0CIt0TDZ1NTQws zSwDAtJckiKc0s0dgsycDIwtDS3DhNqTYWAFZEV6NBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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_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 9dfa211095..1d949b3b91 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 Wed Oct 30 21:38: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: 147783 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 A3F0245BCC; Wed, 30 Oct 2024 22:41:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6981643283; Wed, 30 Oct 2024 22:40:29 +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 F14AB42E9A for ; Wed, 30 Oct 2024 22:40:11 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2177.outbound.protection.outlook.com [104.47.51.177]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UR6yZ0bI0UmJq2DlmDCEoDQzq9Uk5epUK+1mEW8BgMIzWHBfUpVMFSbc83M4/ecgZU/V3D6sK0+Fnda9JI1zllOWhNrI05xSXADkVtRz0zNtbnnQ0m3uBi3zF3aUOPAEVttq+QELcSs+rJnENRBYzPv7HSdRFGBDvvod5ZZ4YsbGCcmnbxVUh8LZi9kptSWKBUc+p97HkUxwrEkIjg9mQ8N+jxIQwFYOlK8kW+SHxb/lIAd8ejo+s8OtxNdagSkruPup2HobfEZ7Glngp7gfVlvtrUpCypWoJkGyGQn31vpGIOkltDkSH8VScaiu2xFHS6rufb0WR1TBBpAE7AObbQ== 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=hb59sJEvYrtN8y/jilsriaBMgVvgQYJ1I68HMnYeYUY=; b=uLvZ1fIRBqVZ5kHaRS7y0oI7hATOU/08bR2VYYJK3mzUiOrdOWKvUzheMux3Blt/PhdSRIOcc9FBIBddMrcDUChsRZY9r8TSUdam3+GST3OzA5vncN8bSutyYY9sxXhcG7Ugxzdx0YRE+25KX4ZGCCJaDOxMCAJgs9FzLM1VbiMDfh6yOvtCRUyt8lzMSy5PUpi/UpkMKJ3URPuGAqQvfpQMei5w/wUzrKm1VjU7j3y3xFcKH6AO5h6XIa/CiANesfBQUPCh5/PuBgmiNa9gj4bb/PeUov+lOrj06EAKyHtKfIOqDNoIdGTdIz4aNfJZDlxMcwqQJpE6jX9+2lbTYQ== 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=hb59sJEvYrtN8y/jilsriaBMgVvgQYJ1I68HMnYeYUY=; b=klM0a9HEpx3Ek5dp1ha8GDVCHa1icHZ8fz+GTAjqa8q7AcNh/M+6xBKnrJJ3tOp9ugV8Yi7nlRmQ9N4pbODmgjMiTONV/oh8id0ALG6T0wXmnvgOeVQWjaOrA9jdxfqp4oLZjvqzEA2Sqcm0bAn+LNHeT3Lh5c7+nrL/Rne0/uo= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by GVXP190MB2073.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:157::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:05 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::6e) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 14/80] net/ntnic: add item eth Date: Wed, 30 Oct 2024 22:38:21 +0100 Message-ID: <20241030213940.3470062-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB2073:EE_ X-MS-Office365-Filtering-Correlation-Id: d8760c8c-c68e-48e0-8d7b-08dcf92b6ac8 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: TmTIxY3XKUIuMs2EuBppyRKWyIpx+roYsD/8UVpemmqMMNnSI3DtlwFMDp4rB7X1XRgSC47YIQB6auwoGO7RR+36xBYEQcLzPskhvwxIna1vzmvx5Gl2LZ8GspNdLX9oLuh1zq16OZrnNVNPDoAU/6E0RF9zYhr5K1ZTfma76jJDABnzf0aCe3XFG65mAGljfjZWiqxSPZTvg11nPYzv0Qw2+TR4mFh+LVr3woLeZ625MxHOtM6hTA80X/exlkKhQy1BtNX9nApHYyqG5h8CNQfd0U4ywsWZtnwuREJ8RPtchqcqe5At6VLbr8tWNpuJEoDhYgRUrBY6A57KvC3GQ2wRvOr4Sws574h2kcIn7jRYkRTIuQuKuQ1saXe5Zb5l/MfGwRSMkC/0ANZJ+rePYw6e5JnXcNPLfQ8EZWhzKEEzebBVNpMgr/LKRMHvBA96pRA3kDO1dO4wTTcmvYNPN+kVWrM0ljOB9h4ZCVv8ufjwe7S0MWLants+FT7BRmnJB3NzbWYrgxdfN7pKQmxI+uXO3kuQi911g0TTLGCbYAmlQsG00FV8+2pA1AgjtkcVKmAOn9P35fZLrq98BLspXo3eVpFk1Q8c8ekJOlXmB5nxIBRFNUYjVGgAaVS3GQc6Xty0u8QH5mqIuiB2uqWtU50+T9GOCfGym1eWI70Syyl1tISa4FA3lzcRbJ2JiSnxyMoElHS4X6yHdflB07k5Q7O7MoPdYm2tTHFnJ6wfdyO1L0gUuukfMGycMY/21GM+8xEjj/14KDkYyhlLl8+Mantk8qa9ZqPXlP2wNjYhAzAgf6MRz5aYVttUXj6Z9SDFhzir7hgYGRmridmEyAd7OYfslEyPbRiJZ4nllbCgD7D8Sz5QxsSrqIwSym9XFa2PCGCyf2OHMyZe5VFONv1ULXJ+YSEZaQ04vAtP2luLMSkqFINqJRp5y8jT+4QTV/hTDihcbzIqhfO5+Wh2CCmAng7o1UgvOYjOHa8qHbuogYeerZz9gdg0TYSHPiGFcyEAV4uWqhBXK2QnM62SngQi9pVkKBn/hskhzgEpiZJutFcWMWzm1DMhmna/kHrHYafO3HeR+AHsE5AWirDOFPPEzySAIDFabL8TRhUA5Wo2NDov3WzMH6Iq+Rwwy7sEKzIhMdDi1E4f8hN2Zo4+cSUH29kw+9cy6GiXueERpJGE5bnhmOhcGbZtAlpVgsdCS0RHK7aXVtpw7ZXrRfS2+ZVQFzNrYXybYlSczcIdvnn32ZByUq51UPg3ZQw2m5wSQEsEibelHqVZ3ePyNUwapARyHTLc4LV4P+eLc3pT4UaxIu+klyB2ZEkyFxCtyqJZPTa5m1RoyKHz6PijjO4lZfDcmkyeclKmrPqOmce5/hEPjebt3EhBqp3OXkVLeqNPG1Zeb8aeaxmbqVDuU7E5vCrnJA== 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: aYPWR/ZNkeMY2zxu4btLKp2vZVG/wI5zxem6AIF2r+JL6elE6p7zMN8C7Zb/YYO0RgXHZZlHXIkkau3gMXwNJ4mvIhqcmeXaCI2+ThPF7c8iALTaPN+xPHWEI5YinAQbPfWx1EWEVCTTtr7yj2d07uNBoCUJZDfVLOajWPQ9NlRCLUp3bjdm+9Sd3Vz3vBz37iiQlD7p9udUVVriqAmgkVdORKgnLM1eRc9drEYWYdo2kcPIMutMkVkOj+pY6x9q+7UY2bxpzFm8jl9qVOiN1joH9x02rFU7n5P9QHbyfnYxT1gzo3XbF79CF4eHfeoqAPhGtUh8WpRFqZkz5l4Fuco4DANjITWiQ5CovGPI0A/tLXwGFepxO967nllIya+fWkv2lZ+JU3iBhITszhOzZRlPz+FoS8XMRdq7SdQEUtPV7xSFCRKJ3CGObQAkmIom+WDcyrwQDU6hayj/Qh0+mM0RV5BZeJLTYxE1FDc9mRsURWM1XalG58aU9Fn4WHXcJEzoVUryQ443wdYNQgVCZHJitNycQfpgHXKSxW15+pa5UKm0zG6htATmE3iaNzpvK+Y+bwr4qqqug350Ig6cseWRSJVKCGxV40tCCgT8SUHdPNmxxtLPvdIMGtgg8WtsM1AGvqCASTYiQLq3G3sM31kGGDwpA7WzvfJBFjKWLNo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:04.7549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8760c8c-c68e-48e0-8d7b-08dcf92b6ac8 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2073 X-BESS-ID: 1730324409-302901-12792-43452-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuaWxuZAVgZQMDk50cwkydLAwt zCwDLFIMU41dwi0cjc2NDUPNHYzCRZqTYWALVgwiBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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_ETH. Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 12 ++ .../profile_inline/flow_api_profile_inline.c | 177 ++++++++++++++++++ 3 files changed, 190 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 22430bb3db..0c22129fb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,18 @@ 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, 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 1d949b3b91..8ac1165738 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) { @@ -485,6 +542,126 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, 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; default: From patchwork Wed Oct 30 21:38: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: 147781 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 DD4BC45BCC; Wed, 30 Oct 2024 22:41:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 62D7F43493; Wed, 30 Oct 2024 22:40:25 +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 53BA043365 for ; Wed, 30 Oct 2024 22:40:11 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2107.outbound.protection.outlook.com [104.47.11.107]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rkky9I4gBsRe8rjpXTkOeCQEK7hXhqKzERzYOHdUz4cwaBaUAAR0B0QH7HsVV5eMMjmoLcYk/Tqc/JNTqkeDEdaffrNxwIJYA+C/o1kuu5uvFNl95r19F2SbYWzYzKHC4pGe0Di9qjWhH3TXfJblaMHyXYzBwzmR6ZoJ8YhYD8V+rjQ0164y24bp4yJn7JAQ7feKQ6+kanBfpODgWOMbXhRrZ05vrP2G2tFZ6s7Ww5/8pzdqp+aqllWH+hqsLspxCmXD0TL3nSyjUl1j+vvlsr9Mq1urIVZ5OL+mkV0b7+f3Dbz18sZ4jOBYEgFhpifwVbwDa4nQYeMcdt4WmiwkqQ== 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=Lg8pLOyvxcZIivkMJyyRp/ZaU78QfHakfebecNjDhrE=; b=fqgCDn3HozSq56836Lm+D8sDZAvv+aiL7DkJqZAtIfOvFSHGTfRh5IaxqmzIBoMZF3e/LkA2/M7WvOgGhGdhgmCnCKPBjG+OmIa0IHV/tFuDEQIupicD3GTYSlp+w7nFbsym/8j4PcYYku1fD0ouKvLdxqedKVU9vsFmEiuWB2CE6qn5WhXxc7Al3zHNVNTqnTFO5QfyTx3qnjva1OCax5V9XjDqOdKGg51csJJts0+1CyMAcH+fmSlLYv+1AAtG49uqQtnC8ZRiEobt7WY3XMBAfNcNfMF7nC50WlgivkeDGOTEt6leVUBg3Yiws+ZtVrsV6DdJCkOaKK7TpJbn8Q== 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=Lg8pLOyvxcZIivkMJyyRp/ZaU78QfHakfebecNjDhrE=; b=juoGQcs+8cNvYwH/roOlBGUoDuZTcPnw5LYuJPS4KFZ37vUh3y3S9+4IRb9tcLETB1QSezSw+bYYI5TAREzURNk0eO1/qDOk2VUVLyjr0KBJi6uJQNJWUOKyPkbIPbyJUCMXpy//GiIwVVa2oZX4GDHqzC9URp9MW6al+TRRWTI= Received: from DUZPR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::6) by DB9P190MB1097.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1fc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:06 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f1) by DUZPR01CA0013.outlook.office365.com (2603:10a6:10:3c3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:06 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:06 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v5 15/80] net/ntnic: add item IPv4 Date: Wed, 30 Oct 2024 22:38:22 +0100 Message-ID: <20241030213940.3470062-16-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB9P190MB1097:EE_ X-MS-Office365-Filtering-Correlation-Id: 7638c20c-ec6f-4104-98b5-08dcf92b6b95 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: 9k6zjH2h7qXKFMooMbelRAyqr2pDqmWCEcwDENwfaIcv/8JddyXrR0RW5EVgwe3NPOpavoJtNyM0zMtaIQrv0iJTiJP+P8diiVBlWuohszMF79Tkz+0TXSVSOTk9alUMLBNEwaV5G0KUL727GD4r/tIwzqNaj3WjlJGO1CXXJj8NdV5/02sjCV1A3Dt2b9rt0se/Fl2EhKkG1wBhIIitVdlMf7JyDjkO5gRrcqusaF/7Z+58HI7oenxaO6mYzt/o4vmkE4ryceBKpqz/oqBQDRSWwQn/TKjZHbs+uuzar4bZa4E/K7RArBawkpdAP1BLp5HYW5NKvrljZUDAANjB4yS6XAfCOq+NsqK9Dtg70FBKir/lnFYARX1/2Wjy0tcPej7Eos4+EtR9l1jxjBzucTFtp3HXpXm3aK02F/9Q94fqtiASBB9zqsDesXSdPKOASMiWq7Y/2F+ZKs+BgcNDyVJWYGqYIp7MGtVnADFQv/4TOJNf59nJmQljO3ON+5C5zhUlMj/Ncjfx7QksJuxqK4pg6hGDLPTLY/9SaRFOuB0fPXDXii7oc0oJupxunVtfKx7D6yoJhKwfW1EN1a6j3frRwOcbV9XLK1bmgy8s4i6q+CCsKbKc113mucyhBOMsVxvDvAB0t5ZkLUhZm3jHUx4rlK2gr20lJ2N8PNEyhvb4ON44MKQfca59UpA6PxewAvz4GWAKx6dOB382BU2qJ8Yl9W5sBWSpHO2CNDj7ur6WQC2pLQpKpKr3Uf8Nmlzt5ZY0MYkBft0fA1K09eEQm3sScQbJm3mJ08oSnu9kjp5pg+ebBDmCcVShYmOrryBt68GWpcAer0kWlZT6CGmCcJ+ZNfqHbWVvfk6eLOD44mttvMVAnW2oVTHYzWs6N+o1o7iH9kP0kp2vRABTWXRRa5Zv4qiYkFrPhK5KPReAXRi58JE3yce3Z6HtjMid8qAZgaSvjLmTxx0+piVpINP0BS2xmrAXBLojNnorKVtiajObilYa+WClQ2PoNC6qaatvrshacmf64bsYPbYr7hlFRgY5wgKtwGIMZ6s2s4dWN2kG/qpoenDwmeOfvt5V99p14GrMIt1yWC8Zn6XFAGRvkti5z92y7mcX28nNHEgdLesVBvDM1J8BeuSU2Wfa2u8J9dZWmm2GpyMgFFBq8mvc0SEvCMsz4zLkbgCXC8k1RvHNTPgzogLYPwnDD1VkmRHIWIqaDgTesaTISorjOoCCw4KmC4hwc9Ppyrcu0EKLRcdj7L+h01294eCevjyGAy399Jog0uEDqmFJaEx+7A9zW3XcAJMdjzpBnY7mxJcjKdLNPXMsfFzGMXZ7/J9LsDlscLX5P2e3Pocu+v91lxNsIO7Tk9KFxpvBNnVdhirvFmnx8foDMqH6uqFG6qehWjE0ff0PuDBEtaCCDOQQgsv6zA== 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: d0i0YBG6btj5YvYbu8dtKBjOsc2ShVtx8nnf8lRWJ4Cqpr7PlhEEPPwNkMsFT7FWzt7bOHEbDlnwihWZEWysdHSZyQTWtrJ1S1iJFMBG/r7h3cmo6NnAbIiidb6YmL7XIqNn/T9Oq/OOQUoU5HHt44sz+2edgmpv2LwGbkhXUffkCyaYzBIw2Gmt3/aUdCX3l0D4xJYeJbTN53G6SrAGT/8dz0TYRS2fgYoTY7/LC6mn3UFdkhoVDXbsrZoGMNNMIU53o3hd5YN82vJcYNTK5uuk9YRbca147gOW7aaK2n4zwMr4WvLrkhjr+6Tv2M16NfXyNdyiXRM8Vm3DusTv1sQCFz2msLyqtBJt65iY3sqIKDZfzBU0hNUxyGKuKBAb+m0v0F5jkg2ORHcKRk6qUn6j7pbxKwOLbTypKZ5WvFeJak34rFQqAEIXtMV4wtpWHRwZOY7oYDXv/rOTtolsbhNkTEsUlJuCuK9GxYRcsWhVsX3SfQzMH5cmWQFh8IU3Y932kTwAcOPvDB87F1V3SyeFhHRnYHl7Rq1/cooVbSJOGku9oC/oBybTXyX2gZ0np08/rVPQjtZ7ut60oZ79dv9NjUiCJkyQmbyVjW5yzyYOQEnoQdtMmi2D8A9l2zXQZgeEG64cDh+I7IrOAKlxiAPRNfC0dtIw8PEjUnzl+lA= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:06.0674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7638c20c-ec6f-4104-98b5-08dcf92b6b95 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1097 X-BESS-ID: 1730324408-312176-12712-40680-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmbGxpZAVgZQMDE50cTQ0Mw0yS g5NTXJPMk42SAx2TzVIs3EyNAoKc1IqTYWAL9gtK1BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 --- v5 * Remove redundant 'break'. --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 163 ++++++++++++++++++ 2 files changed, 164 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 8ac1165738..eb73e6ca22 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,6 +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; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow request: %d", (int)elem[eidx].type); From patchwork Wed Oct 30 21:38: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: 147782 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 C397945BCC; Wed, 30 Oct 2024 22:41:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25985434A3; Wed, 30 Oct 2024 22:40:27 +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 AD99B43365 for ; Wed, 30 Oct 2024 22:40:11 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2177.outbound.protection.outlook.com [104.47.51.177]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o20QT2lzEb9rEUM1V/ZPlzPkn/mzkHVsETYcT28u4wh+kOtCmmnsyFyuikssgI8immOxHTmqMO0rsfMibWey7q/elk7pxej2+fQIH84ZcRiUPKlB5ubdMDguvJunvm4LI77vZZ2Qaa8F1u1zTLI5wTDkRcLwx3u/yOAyBcVn2SHbBebXHjJftIuXy0oin40IVgfcAmMHMyqmVPrlKickK5S/aupz8ARnxXf2n4rNDBZSwHKjS7z3nVHdlzrCK0ODONO59crokM9KvUsOOSIJ9Is78OSgMBN+PR4f5nWBRC8v1kz6HidOIt7uwwTvDHhDjSjn0DFDtlNhucHT2DHr1Q== 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=csGPe1VbP/F8RRH8CoyBTXSKtwGQHzy8R87/AxFIRsc=; b=REooW8Ut0NzPtYKieKrYH9LQSgASrR+vWNi7vIj1jHcFeNa8bfrb35Ua0qO0/AMmnGpR/xd8UJzEAUj94fFdn8Ft4lRDSE0RN6FLA7eg4BoUj5nqmPO0Dm6QV7/uqI4QSBDWDIA69Z1JTfYESQ4nUvGeZPD1oYHDRqgvD64LrlZNOMCR6FHLf0b9AbCMStHbuOAatcFJpAWnx0JCnR/rzNszXla5A7G/dvjUa2mZ4p4fovNSItmb9Yif49kG3fYIkf5onkjyf82SNnUFkHn/i97H1eEXCknKyU2L8zsgA8MtDWIgQ8pK7yIYoPexOpB8S5JFBIto6LSB+PktBo6Xpw== 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=csGPe1VbP/F8RRH8CoyBTXSKtwGQHzy8R87/AxFIRsc=; b=SfVyw8Cxvc4yjbAS5N11vRZeBdsS70KfaFchzmB1gqFw2AdWJ3wApPC0ereBlrzv7hwwJD/244jJPCRC/mXK6aO1uLp/wjEck/XDrIiNjaqxxIz5izQLY0MUqHCEpKzJTDd2A8z3cSgVdS0+IAwxUSWJBsQwybVgJnux8ZhFCqk= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by AS8P190MB1238.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:07 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::b5) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:06 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v5 16/80] net/ntnic: add item ICMP Date: Wed, 30 Oct 2024 22:38:23 +0100 Message-ID: <20241030213940.3470062-17-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1238:EE_ X-MS-Office365-Filtering-Correlation-Id: 24cdeba7-0451-470a-e1f8-08dcf92b6c00 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: xl8AvgFGOIgJsXfo2i3XYAKfi38ivGE8KUWb1RdRCyR0H1vudHGwRmCYUZpR/PSJ5q9eg7/TRaORYfjJ9N5tpHKrFnP562VGmVg1hZIbAPfD8sTaHfLcebFB4dqJh2tL4mRif51VNGXa0ZCIimmnettfUBmxmKxa0ps635sSYPg9lG+YZVk1lSo7UdXEVX0izT4uljhvmfxyNph+KqeIV0I9ISjNGDHamnvgVckK7dKA6IAo4n1U3YpXHW1tqBxCoiX8OdAyN8XgwuzPVUx/xwXVn8M61o47Ax6OFJDvc3O37ZZoKoNRbwKlIlXXSDeZYHFO7BcMY8ycbmyFsl7I6XpALWqRN3KJkXIRpLMqwMMnXYJuE7EFYB8tUgSPKsaONiC5JoYRZGiWKZeO3F8ft7oGRaqeqnuEWR8ymN3IcXjKRH9FGRDnU5LrTp7252Gp0sGtd7vh9AUvW20OEC1DV2pP/U6K/OIbol5GWp9pYeaD6fcEQEulqY4M+6c68ChBtuurEONCRRnqqszzcw6312XTdHaXYb3e4yEj00+WE9YR4tJNGZ1eYuvstvil1CBpMKnmdEFxMx8UvU+2+HyphEl/dM1RZSZJ2gxiJGu+LRJ/DnjaXBlnyn+ocSmwW1K0fwhtIcLr2U2w/NJOUO6lKi2je4tyry1tNTWLcV7LG0OJgjBxyImYhzjiwqHykJ5wj7sw4U98Vya+NQ1E217Oaq3PPFM4/88dONh4bIQmFCIWf/yqyp0gOB60djipnftgBw4DcNtGKarbKIDrZ9aBclapWnDEuqGKB5WqJDtusicgzHaLEI0050d0PAdxk4R8cL/VaygcedHLloNfpFLCQnB3Qx6pjkgmeggNDnxNZOUpUKm+dWK5+yiWVi8/Jxl5cUrmAXcGgIk2U5hc9cPpP7KenRPcbk5FB7e0tD9pg26VrYhgHKcnFbUD98tRVRkfkkWe8bYT2vtFlnQ9DgFA/0ROclvW2EtVcI1YkWu14P1iLcP0I1seNjAFAp96xHJghqGLvWH4CechptETqAs/bJUDbcqNfXikg43bLwwtk9iaOeI4KWg4+ezQsyfcw+OS+q8DQD8ql0sQLbQbY06zy5JwVJc8syZPeupGzXpvljR0d3FuIHvxknvZ5cKsjesbdsrmJpliehVLL3LlopIzbBNHaS4z+mG0gQrC2PAFHvKcKu3db4O3PmVA/Y/RiVQDtVzAorg09y3N4OAf64oK+6IuqmIJs8LCNHD1ufxwm94veyVPM3TtN3nN5Emhz/wr5qVTY5LFlV7TThcUKHlKxHQwgCAVt9plw8Q/G3zFiKOnyNj8peCLvLF8TTGYz2Z1ui3UI2C48BkuqiqhXWnbX8r8WjLCAH8/3tqlK29mWclhOP+bCXhQrONfKefNwm3Mr81L3rZ+8Emjvt6mtWh+3Q== 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: q7X1cQcS9PbJLNvGvUlCsjOmH3ZRRatUub213/jXFpWB+Vc1G3AG99Ll4BB72JHkRt/+4Vcr5p74ANzbmMNcF+gAmFIgnWopTYZBh5m2bAt8ltIFpxjHAIwkD4VGAgpdk+91W759XdzPPfSF1EVZ6DbnbErfvtKrAbn8nCLG4op9smnFX2TmE/vsKpb03F6DpzITtpwDv7hkyMb25yYmXVZGEMuE1li7mKClz+7KDH0gdQzIv2m07cGv8Gilp/OqZxiiOsUaqB5BbV5IhYhfUpAxViUPdvxyTruqP7yj/IIEMVo8lcugJGIPOSaWo+BJcclXDudCqqLqRur9tIVmmihJK8LBHrzhzwBTrtwS54e36q/ZYu7QOW9Ihzj+HH9HLgWg0FruRbSOmu9/39HGbshOV68dBnomL5dEGChrnt+ZOxgQOgfQGIb+ujUTata1+/eFJ1PVzZn5F2ZL9lqt4vd/PxR9sbofJfvV5/bVGpOZ6qASOjeV871Ysg4PSRQDVdtAurOYuuTzO+cWAVuXmOh5i2yII+46V8oVQQo9Gq6ifGKL6athWtHudyTSS1PnlJQ8Nij4C7Jfm/wYN+FzIxvaCP24sYYd6fedmkwFdnWSrBp57xv+vTteSuEBBVSGpBIyvd6KczshLVihn/3HOYcJ4OJTpa5gBTKp0BFTNlw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:06.8018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24cdeba7-0451-470a-e1f8-08dcf92b6c00 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1238 X-BESS-ID: 1730324408-304433-12638-44613-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViZGFsZAVgZQMNHYKNEoJcnA3D LJxDzNwsIiLc04LcXU2MLMKMnS3MxSqTYWABwQfSpBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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_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 eb73e6ca22..88665dbf15 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; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow request: %d", (int)elem[eidx].type); From patchwork Wed Oct 30 21:38: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: 147784 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 9E2D145BCC; Wed, 30 Oct 2024 22:42:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF5B0434AE; Wed, 30 Oct 2024 22:40:30 +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 4AF29433D5 for ; Wed, 30 Oct 2024 22:40:12 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2108.outbound.protection.outlook.com [104.47.30.108]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wF+ibYTcFyaLobNZY9+XP51LCQojlIK8bnlajJ/vaIHXD72WJeAgwq75+QOTOm6AoDGC+ZnH/FJ0NtCpn+lqWy0AEDstWu5ruCqSUrCcrMNJzEr5bqgKVD+sgNPBPrAMHKKqtWlRbqdOHlcKkDQNvzGc7r6KKfzL4O5lht5cRLBv+F6P6Z1QzobqNFIKfi1o7TpSW7DEwCw6LxX4peNC1FttOk2lDStq5YJc2k0iuLZRqhRoOHRHQ4gTuh2/d5G6hYem1NES+NVsf/m02NAq/I1GyX2DFprPF5mQwLTX646wxXoch7fRahaLtDU5FmIO8O7QlCgnbteOmAlb2AaHWw== 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=mikrOQThe/sgvfoLnzBII4ydmy6YZzyyJVlU/TvkBU4=; b=xAWV2mQwNM02AxgkHbXlNYW5V2eYh8qaeinW0ORhKur9jcNFiGliBDZZQE6lhLKqK8yyrqatvn0LPhjg8unF8gxICQB+oiRvkLrl6vwdACdaNzTL2xpM13X3Z2ypc/NtSe7aAj1SaAFiDWeHQy9RIT+VgDJmy9z808x3/MBjOpqEc/yQ9vem8hdpAv20enXzP47XvP+qJrD1EZiDg8JmiRBeUUyRmV1mAErMAVtjpBDwXqua3vPqMKC1hIWAPI2Ezoo1PomwGFnXfiUuEBmYvjyqg4NW1XxnXPIuQrKJpIyGim1jYCbG34ciirBhnj8tsAyiLUo/Tp90N5BxnQzLpg== 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=mikrOQThe/sgvfoLnzBII4ydmy6YZzyyJVlU/TvkBU4=; b=UNT1rPIFDaYVDwspUPPH4t0ovyHKFuEtv7ZBhK5cQipTqzUcVfSW8gr7dFiIJssnZ2C1DiseRpKgVZT3YUxHpt0nX5I+kI21rbiT17mXdXYBPFDJ6cJ0LixZCXfipExoBZ171kfb/kV6V0aHI46XT/WUq6mXrr9ynkdE91oSxUI= Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by DB9P190MB1082.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:22b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:07 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::74) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 Subject: [PATCH v5 17/80] net/ntnic: add item port ID Date: Wed, 30 Oct 2024 22:38:24 +0100 Message-ID: <20241030213940.3470062-18-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB9P190MB1082:EE_ X-MS-Office365-Filtering-Correlation-Id: dc0f2db8-ec83-436a-3f2d-08dcf92b6c7f 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: XqIPd8mJo1bHml6BmkK/IWbCcrQtQPSUbhTj5/xwyxniksZpWtzJhKf2lgKsthc9B2GLIyDfnjLaRNSXx9EujY27uxfFXpYIYipu83qy0T47K4Fio0Rpnq/v+NcbfGAnfII/PTLYhHP/wgAHUHfdcq17UNKWkLhwhDhx2FDnxlkU9yfZZIjoi1nHkB7sSMPcLRi3DHuhW/eQKrV4BD3ippD9Jor01Ks3iLmS6RLJcYqugARssOHnnqj+x480QjL0DAvC9jReRkJo1NUBy8LHy20TUDBkHW3DsWnS4wZadpaGT4skYH2rykne4scM5unzww7uGx7tfZTz4diMfYsxMxeSUGhP1pbChfcEpITSfsyRGOvakqx7p4m4lM3Y/BDb5boKx51sjMyBJUcPIO3VkvzJZCq1zp90Gi+KaguuyK81F9WmJIxdEXGpk0NWzuJELztpLIyJpmOiWB+2Ox5M5hG9mrH82Fdy7Yw+4U9mJFcuYez3gTPksNtF1nIwtAr9ue4fN8+qUeBdeGNkhI2Id9dB4RFEc6B3JsAxCKwVPrhz4L0Ju8PbOvspR9MoveJEajJId+2tWcvaPK+xUZ349B7RPAJIiW5MKzxUL1eyIFx36iON348GpS0mLj0MphH8VW4QcG7aNg/+Eb56lT89A+i/f3v0spDmzi9OUecBz2PGIqRfOZoK2U1Bo9dfKCJWi2piQD78E4dshR2gIPTb2zo9OnugBIcGE39byGcpSNICqrGqynfbi2QCoaj39Ru/iTqBfb1ZyWjin5e2uLQsBSpo9NZ1UvKFTqfjRtFqQfC/TQDZWrV/E+pYlRDUXv9k8O63NVSxW1RnP7J0dSKtZjPD7uP/qk5skiZaPVSKfEFs7KbjxEn6Lf34vWbBfYMu8RGzEz3IKwxgPaoovKb3Hb10oLkf8pYFhx6jxeSu1HSxno8k1QX5g36l92oBc/m/BNL+UZl8w9Ohiq8BE9NOESnRSNkc8LmkJRw0YZRIoREuYx7kJ62hQ8FIq01tVWTj5cTUVcCX9iOdkx+6clrKxDtipArIk9jk8I/dqEYketqSlvV8ReETFlxBRCItEPTePM2PLD/wZJNulWV0JBDzI4OhcRcgpvV9LUXJlKgR2ZqLmOzhgmnTEJKqkAQ354cyaYNyNAnApb08XCwMs+UXRwGdePtPGTzipBsg71DFIROQE6pLG813U0tB+uowSef8Bhud/lW8nBbl5C8+jWUmDolBQ4tcx4V+4YmlTLR6LrQFoaMzczEqD0mL3Mb36EQ/exmtPAgrnlY5jb6vzZcolUH7YEw+cU4YHTAdjp0Z1pPpqgj72YBODBpAqhg4gpnT8vUYSwfhviYLsuB4XgWrnMLIvl1M3+yo5HTnM7VE6QfXtSHsGd7+YN49A9kfAD0VKX14WU5dzpstewS9N2mviQ== 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: V1cKTaPcwuhhRvTCTCEZuG13XYqnN2t8+z7+PIcxkB14qs+pZbEgw+0zrzMSdmBmgZOxNH57vHjCFuD+Hc1kNud0Q7cU1B+niw4SRuxg51DekkTKp3gLd+a9R8SPc0RwryaPzyoI6xlDmGmaJZ87ZE1ISM1TaOFPLfly9PxaUDagoO/3qt++ECwbIdQtkKerUPT5gDfWv/aa85nU19bsC7tM4WzGyFC50V978EbAYKLf9JZgozObwcx8h/ectOg1dbyU0phX6PD3ITqMT1BBVdkBT83uaV4JPuAUPFpnumDdGaDn2/OVJFudqTrm9FB8IZFY9+vO15kXkZ9drvmZWSxky60BAq2iQxgzTUrh+HoPq0Cn0JDUlwEq6gFOUz1VTIzixbFJahp2UvnourAk3ZfBUlemxL676+fSwsN8kAzWH5dG15OVGqoGsbhUQqIbaAzLzu768C2zMUwPBS/nfBdCPnpWDmahx3Je3f4rTvw0hBpbddFneAF0ekVF/ZsMrSN5LexERv8DPO1f0w85RLbjMMLal47VgU4/aAgdMj80MI4sQO5dFFk+ZRnTSjxKIjtHE4HT6GDMuka2l9Ps+c0FRnlH33HKcUIgBXmf4qVyOLI8CAyBnVStJ9HxrYWOigNhJT7qFgoAgZVKtezAEkqzhO0EJpV1+UFcTBcUNx4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:07.6299 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc0f2db8-ec83-436a-3f2d-08dcf92b6c7f X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1082 X-BESS-ID: 1730324409-302901-12800-43455-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.30.108 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamxpZAVgZQ0NTCIMXSODHNPM nI2NAkxczYJC3NyCTRItk00TgRSCvVxgIAcU49T0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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_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 88665dbf15..4fc5afcdaa 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; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow request: %d", (int)elem[eidx].type); From patchwork Wed Oct 30 21:38: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: 147785 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 07F0B45BCC; Wed, 30 Oct 2024 22:42:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2EC6434B0; Wed, 30 Oct 2024 22:40: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 B74E142E9A for ; Wed, 30 Oct 2024 22:40:12 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2111.outbound.protection.outlook.com [104.47.17.111]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=biYZKCUuClTbiyZdZWLFGUcKtp7xsbICNgwNE/l2AZd1ztH4Xqm56d4sm6m6EskIROr5MKAayATEMWk5nS1jOumBhusJWXL4U123XBwjjOfmMW2Nwch9ecfXlVEH+058GxTvaB1u7jr76b3ax754da6El4Fe2fjYx59A7mL6Re6y6B2QMmM/QZOyUrrYLZmnbe4/UdIWIJxPZ8E2OTOkPnySKiyZnugrMxM98dbw27lppqy8dPvpFOGa6NpyP7KC5fbykT3gp9tJ4sNbaFt2v2ybrxxklOqpg0KXyjaZIo66T5I7UsgyT9AdCQQG7RzUQb/shhs9iK/JhD+28tGL6g== 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=XWAAuqN+PjWBNc4hMVqMbYEvEgJ2Zjtgoj3qzlc5v4o=; b=Gy2+cWxmAaJNQ0aJpmc/BYDWPmEIYUrBOe36EZSnJ4H1fx6Iem5yeQO8SQmTKYZj9iRU8zGgXk2REyHtH47ITCzyJ5GsySulOxYYlIuPDseGnTL+5YjcaHebIIe24NJ+yE0NEIHf8iBMF/gBaKnUw2iFkRF6Y0/dweGJKN+dVAt/tvdertSN8DKRAA9VnQ+b0lFL/fVIJgPcIjde3dg5PGMt/0TJe6jurcer6eyDZQIXxh0QHRD6yKeDZApC/GRMQ8Kk0q2g6+oDqst0nJdXKNkDHEBZfm5+fJcVrpVd6w15gFmrn0L/LvNoHo21OlEvJF899EQxiITwmbxn9+vnUQ== 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=XWAAuqN+PjWBNc4hMVqMbYEvEgJ2Zjtgoj3qzlc5v4o=; b=aCi9YTZlPCDzu6bvjjtwTzwHci/pqWmvdbzJw7fDbRWEO5T1ST9tRnWQqZDKtbCxGVuGkTvk7oKGMC/oHggKgUvPER/vbApTMIK9LYkpkWZecaB3TJgePc15QgE2SOWsr+4RrJjndB1GqznLnp2kroVM605NhbMuejPGXOEeS8c= Received: from DUZPR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::6) by AS8P190MB1029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:08 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::2b) by DUZPR01CA0013.outlook.office365.com (2603:10a6:10:3c3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:08 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:08 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v5 18/80] net/ntnic: add item void Date: Wed, 30 Oct 2024 22:38:25 +0100 Message-ID: <20241030213940.3470062-19-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1029:EE_ X-MS-Office365-Filtering-Correlation-Id: b6b3caf6-ceb1-4bc8-c458-08dcf92b6ce5 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: TqHt0uqrcaSdxXLeHeQWHBArFeIGfPNsRi1dSIILE8MvNigg8+Ymr/m97WvzCCiNJ43hpQw7GxcObXTTYfGYXAkQOrQtYuqe7shJc4wTixs0VV/+wCjnPm05IWssYV36Nr6FoL/CPviTW04G5/E8QyiK3Bfud3LduA/CoxFULuNmt+dJaL6wLBu1Wc/S0TE2BQQi3SsU0Coovpt2utmIoy5k7yzw7arB0u0jPMJ/QoZgNrSa055JY83FzVWps7XWnCC+bzHAb8hXHucXF7wQWyQfeQymzKr5TYaGh8lcQrNuEnC2oFFA8ZMEfPCfbN88wV8toO85Tl7V0IE4OLVMvTYaRoMOI2yi/K2MHEzqPTEcqkDqheVWiC2NUXtRLhexedk/05TCGZ+vwBxL1Vorq6WBvGmLMcL29/te+zJ6NpKbfrJ2cFmMaZF+oQvAzcUQChMNqsIeu3AiOZVbV7LXzarW+R4UB1GQ4Syyn4GsGuUeOgw8a1iKOPDBpdzJT6lK4e5uNh9tCTahXiKrvUw8JWkwuJQyLn5oz7F7phxvQghPUN2/f72ZAdGkGP2VhzKmzxKkqZNWiQ9XB5ukcI+fweB5YOEv9h9k6qI8XNIZESy5mZ8hhSNFeayT9p6l8vhPS/vVtn1c4YPI4SsRJfwfGMA6GaotJFAKcYyN4jGQbZlwQNyC0Ff0beE8OuKTBQT1ZfmfgeOa7P7f4wJejhjT8AOzengWIQOpjkZ0+Gh/ueRSSg5GHJvuzkuGNy3GtSD7DVq+R7AQZEuhwnIJ3iWewEa0z3xAgjAurCOEq4ctok2YUjDJPVlrfv2tWTc03RWvO8HJq0r5qDM3xu2OlIy7VyuUZOUNFreBWTnynI2fgBkCCAwqyIEW7MxxFGi/YkRSS25tyqXTsI3AQrCr/RmdXtEcqWDO1aR69WM2VKqinjJy3gqy/2mEdX3yvJjol2u8iaX91u235EUo1VYz7ct9p3+LbKZ0F91wDFKdU9YyQa8a5ZmeehZSaECaW2UC6V6StaeNBf7p4qMVoMLoSK19PlbFA1xK16gLUdvazH1miSQwTZUT3dI7JQ7stzNyH5WsUKvLH8oRKnq4cAzUNPWK7Pup5CrnhMof3YdFle4YDeyPQBPbMHwYKbdFSdP/AGUAe0LO0l1cGG1ZQXur1MNG38aaLg9v+HiCVSxci3YKIzxeoPX7FdliqdRJDzC8ATl6tr7oHujS9ePsKb+65nTuHmA3MAhB93r12h/ZmyOKi+FaRr6hgRmwQPR09TYN+9O0Sl98f3y9ZgUtMl2yCRzub10fzKF0rYgP5DL6cZ/CzipV6EUuY8Cb4zbTC/vCwHpzx/gQzPnjK23M74Hstlv1+pCsJ+thPsHiuck8bX9nVE79wGF/LOu+ZdTkAkoYnHT0SVT8F93SVQIY7jGG5ivlEw== 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: gLXOFfo/ikqTAAAybyItT0hkY+Z3Vdo4VwqJKI/s/30KlxwPrBJlTXM7PG5ojDKP2kBBPgpjBreY1LqS2KapJtCG2CZXa57q3IAKCkpqYc/sd5K4pfbhlOy+ouxGWna5LpvcfbgQ8nlByxDUudfZXilbiBUnK+oy23GwFXzaGkZqg9A9XrcoziPEmhj+fxfocK0d49y3akrCkxsq5zqYW+F3W8P3c+nPDpHwpnrRPt3qrU8pgUJ69Wuzkp9Jn57QxYe0wtJ05dCzz+v85URMT8AvUoasyY70J48f3VypUNeDxphstx08ksWj6NuLadyDUTD8w6TpUd1Qr/0dSInZsHDXqkEmonr2w6nND7D4BiPzDXI3tWo3mKCPSnq+GjRoiz1u+uafAzwBiYoWVqZkodq4SwmbNDoZ1/mYrpctrMawrhuGTwyqsMeeHAwnHPW3mBKb8VUSORxsz/HrvSEPs3QjDzPMJhQB68CadNCpSFH7xBqDkYIIc8LDY1NFkOv1HdRphxgzhJpOVhmTy7tkXS8mDCCDnKHK/Oppgaj6fcevudN0GuHCMtB1BQBuqUGzg7BFp8IEXEAkZbA86wvcCeUQRjH0smEyWzYUw+UD9V86HSMZKyrUnXCsJF2eK4oPTT+w3xnOm8oD+8r2KE5UPMZgIlT8TPtYE0V++sI1/EY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:08.3018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6b3caf6-ceb1-4bc8-c458-08dcf92b6ce5 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1029 X-BESS-ID: 1730324410-304433-12634-44613-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.111 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmpkBGBlDMKNnYONHUOMnSID E10dQsKdkoLdHIwsIsKdEk1cTU3EKpNhYAH3Z0gkAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 | 5 +++++ 1 file changed, 5 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 4fc5afcdaa..29fe0c4b2f 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,11 @@ 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: NT_LOG(ERR, FILTER, "Invalid or unsupported flow request: %d", (int)elem[eidx].type); From patchwork Wed Oct 30 21:38: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: 147787 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 92B1E45BCC; Wed, 30 Oct 2024 22:42:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE8DA434C3; Wed, 30 Oct 2024 22:40:33 +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 4944543401 for ; Wed, 30 Oct 2024 22:40:14 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2110.outbound.protection.outlook.com [104.47.17.110]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vAhlwk+45nj0R1e/UYKAIfCSL+bsC/WN66dyEZPYMkg5NCHkLNNz2u+48L/XVow3XiyQCcb1cUNzuTIIcY8jNI9PfcJdIXLw7wYGvitHJlkt4FKZHnzdfHd/yLz/G1apbovhk7OGGgvMul2I8VxsPTIKoFIg/PMT13sVA4p9FKPmNGIIfCmKpOI1JCRo4+lwDaAs6OO23bHhHa8XFzZWWg1GqfeLSs3ZNEaAhWgOb7cK8eCCYHTcNnZSIuxYSL7T4ZSxEbtXCVov/YYZ16e8iOmRw45SN/t8OS03V5w6yBGJwKY34zRmwcncdJY4tOH5Osb9vfUPY0CBTOOLrEBIRw== 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=3vodIAVuC81q1X+0qpZ07i/pFB1AY8ePB0e/bpFEwOM=; b=hczLZHz9tvVznpe+DwdV+NklTkMcSS+/KfbvO6kML8WqpckITt0xlc3WuyVXPfq+Pxs86vpiMHLfovPC7T/Wz3gqR44jLjF/LzoIvCPf1zqz/82pami8jyuFF53BiQihW4Gt3tkrVFqEhU+sXZYZgKVRJQQ8kM7B6Lz43OpCXZ8/Lv4LlOe2atOc/kCL6SMdBEgxXueLIxSXyPCoVd3AdaYvDqZiBbenaCe5SbXS5WkcyB5egEnJukUz0t46u+z5YDQ6WstCQ9gAq64ge1YPrjC0qty3NPkVQgiKX8vwjfKh9kXPArj3ZlruMuCIjm88qzZ4+bUBjHCzVNvQGaOjOw== 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=3vodIAVuC81q1X+0qpZ07i/pFB1AY8ePB0e/bpFEwOM=; b=PbNdLNORy6UtC3N4xmHCJS/dpLlLdM1QuUX19Ps/z79lpY+8ZZ/90M/0qLWKQtNblNYHnikymO3Z5HyL7MJ7d/NvDN2jyVMD4+dkmtdHn2Hrl4EfXyY7zthPJGAN/Vc7mosxq3/eQc42qJ7VrW7n35SMXQIxheYs72+JR3e+Nxs= Received: from DUZPR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::15) by DB9P190MB2011.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:39b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Wed, 30 Oct 2024 21:40:09 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::16) by DUZPR01CA0003.outlook.office365.com (2603:10a6:10:3c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 19/80] net/ntnic: add item UDP Date: Wed, 30 Oct 2024 22:38:26 +0100 Message-ID: <20241030213940.3470062-20-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB9P190MB2011:EE_ X-MS-Office365-Filtering-Correlation-Id: 11d94c9c-5a4c-4c67-6f5b-08dcf92b6d72 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: 62h57TL4rjfk0fdhkE6ydF8wbq/M+rfouWTUm2SLhkHf6NBNy5mS/SnSmyuymabEEaznMzo+OdunctRJ5zKZWkN19YCWxMwzCceMtqB800gME2ceM3oA7nQWuhqSbACVZmtFPL1KcbfpyAiOcpLO1573Ko3muWIx9jf8cW/j6534zMO4Ao6lNdfGzzcXNCNwgZ+1WGvwMkxeU9yoaZ2bTTRmvhI1tc4eKr2/g77MlfXsZ/IxvVDE2MRH8YB5xPibrZRbarK6mCHA621GSyEyYN2scfPZKBKqov1OtJQNcD1wtMR2c5Cd26xFHJee9Necc+AbQztyJzwG4pdcJgCxQ5/XRN/BEpgXHPB/PciODRLlAA1amBVfw1ugTht+Ud1NRQwgnhaWSAFtepk1EboHEH5UhNE69jfKcXGWz0spyJtvCH0lDduKgWCR4hwdAFyaXSusAYfAEfB6Yp2KNxKS0W9tcl2TuCvnR7pB9CjJGTpbQ6ZA48W5ktCCB1IeWzfCR5jQkT3+nK51At0TT7Ky3cnviTMRcn3zOKpu/kFOt/y9rRpxjZhu3ezkgaEE++CJE4B/+zaWrvJL5sKuKrx+3F07e80XeYU+7yh8D6iddfvQGjXgNGkYBL/SOP3Pf9hwQKPSzGD5olicrHVoJetDLyyCOepAv5d9qyzmrSCLRZRH8CGZK+mNEC81hnl18vTMqoom8xhxRaHk/DuSP9grNlGBzGUCHbnOQgGq2Vt7tIgxyiWZrcJyPCqEbTrQnrMWBjz5pbdAEKQGLhM2JXPNqeXAvLyOxkR1KBlwM30ezCrYnKJmyNwEpE7YvaM/yzINwOjWt2xtdfNu5mwM2MpjJtxZPfL2ol5/WhoFzrLK4itRzjtpsr2eMyPTEtu/YOkeMlB2RbBo8UO3v+99F/FRZeeFv9oYX3M7/hGC1JSEEKnZe8uzhUAxzmAjjcgvqdHOgv3CmyIF11ICBth+a0VKsXSykxRYQjm51SGRkbTP/hx2v0JzcWm6CIEpOTW0XVAiYcnwUuJ5edWx51iNDbXtPywzrIGJLSTHUIViKfYJz4eYNzKN6ks89pDPsnBuR0gCXyxbViLmrTBybn3oRh/MePng18yKjhCyBykZU/ZvvQ/pztVO3uCvH8uWt+XxZEZm5UdV7mMaW3+CNFYm1JOt7MlUuCcXuI9o1M84UyuxjWSpBXOX86LSfEyUwrWvIw9GCsyIh8mrj1apR3RZJvqHnQ4hOeiaOWxCk+aFXaSuC4+nVv/YNvoZZbHqkD09lgfdg2udu7loBFdgu03zD0NaWdY+pkAKugcjGnvoJiCJZ94wWs9H5ZpxrIj/ovmdA51haQYmS9vv/9KR2idGRxk1fALYz7zT30j4DbDP+BGV/+uRbun3wyJm4HkOR6BeC4UrGIo3z8pNN9FfLD74pjE/Ow== 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: EOYmr2tJI4j05lda/tqHAwS2YlkJZnw6tW4szYeeIx5uxihY5sVn8AgmkfH5mjSLOb4BQHwvECvP5l78cavHDiG8yxMAzO+KkZGW/EMebeRmMVizJbrsKOoGrmYjWHJrPJflgNKNF91jIB5HMCP5utnRZ2DxvoK/OYOTUaIM4PbEnY+Y2Exoh/ferw4dD3Ky47ccoU3FK9MM41/mA9ElacjlMJIs6mqR02LDJbkDru4GhQ9mKCYYbmb1QsptvUMUH71c8LiposEJBf79Io+Lg1HCnqqR7uArn28pKmyBxeVcuOB/YzMOppHRY3TaiA6fPgb0agbb7ASpBTcp6czL6M3B9+pUMm4DAt4lba/CcDnsy+C9mJpjLzh/+Z1VIZpTYsaejjqOAO+vs/e96sGKVALwZydWuCkoxcmBjnvAwy3HKjYor0BHqhzBW1es5SayVkuyjSDkeXZIU6edOTL5li9HJAAM0rA/b/f0rMaVlLho3039Wfj4Wy5Wdk89lv9FQ1xDlpEVSb6jfgNcdcIUeu/cdBwJoB81egX/UjAFSjYcF9iw/bbbI5umlYPv5tDRbMwBxTwxv9MRCgla0bYRfLYSvo9cy5HYRzYZGbOTsyxMcxUORUR/rdNkBpGDnGIm9jARIyqstOzkJ6qRQpfrNngzKcowR7GB61UdVA9Qtm4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:09.1925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11d94c9c-5a4c-4c67-6f5b-08dcf92b6d72 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB2011 X-BESS-ID: 1730324411-304433-12634-44614-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.110 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqZGBiZAVgZQMMnS2NA02dg81d LcItHMwMDSLMnQwDg50dA80cIy2dxcqTYWAKHdxNxBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 29fe0c4b2f..1a92de92bc 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,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); @@ -960,12 +1055,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 Wed Oct 30 21:38: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: 147786 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 C6DE445BCC; Wed, 30 Oct 2024 22:42:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF8A84348A; Wed, 30 Oct 2024 22:40:32 +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 70C184340B for ; Wed, 30 Oct 2024 22:40:14 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2109.outbound.protection.outlook.com [104.47.30.109]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NvMyC/R6iwOc019sZYxZiQb03UXyKd5XuKA8egHJBccvej7wf9M4rmEm5fo8aDqB9Ni7ySZlK7NtsNotQSxZ4uGXCxsC3EmhAKf2FsK68MPoEtFGiv1kChNx1WNscjHnMXNISIKONsCc7GS9R/CcTYy0yBgWNC+PWmotkjN/6/sPv8O2dN3yb3xYAccKRfDdQqkwCINNePb7NbzlNGWtumTVAsUrHiybwbsch+Ms/w87qn0PU+lPqrcEk+3rXheY8i0TgUEFAOjtF1+JT9wlfxgv0RZUytVyKU/5UDKtPkYqLr11PjQM1wNc/e30HEUnbEFY+eV+amQjntw20yGUHQ== 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=NeykQSfDni396lBLDy/Kt1CYB+Mm8YBjcxoHexhNkfs=; b=Dxowr9094h3xaSEmaU8NSIWbNsi0BL7IjEp2YQnV9tgbFCyNllek8Uy3/KqieTz9/CzjUGQ9kexG3pnHWdbQinZYaNSdkh1pK0X14KnLEVg0CqexZFtDuaup3LqveVUKfnYlR4ia54rfu5kNqAy8Fp0YRgSv096USr4UMf7YUQaKc9wDK84n6Tjh8AS3v2WHaWzXuXRmj4Yndf1DMn9/jb9oPrZWZdgF+R9g6Ud6UiHe21jickD18QXz8cFxtkW6MPe2X3C6aijKXZgGav7WvqlYtsxkw7dMUZTGmaXo2zNNbFd7K8yhdIbAWm/PDPMZdiyEADnCnNDazZSPKhnJdw== 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=NeykQSfDni396lBLDy/Kt1CYB+Mm8YBjcxoHexhNkfs=; b=YlBj6v37+zhT5kyigfE3Hd1pSuLFMUUiA7ik2LmkaEGkh9wsauTTeXLsDUt61MpZSXSooK9iBi0EskdekGfdBh8HQghuRi620ZvMR4y+VFYJFl/anlTwcJSasJcZtjqueL6uTtccp9BHa0Yesuw+EZaeAneeyboxpLqbrQlv0lU= Received: from DUZPR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::6) by AM7P190MB0598.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:11c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:10 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::2b) by DUZPR01CA0013.outlook.office365.com (2603:10a6:10:3c3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:10 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 20/80] net/ntnic: add action TCP Date: Wed, 30 Oct 2024 22:38:27 +0100 Message-ID: <20241030213940.3470062-21-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0598:EE_ X-MS-Office365-Filtering-Correlation-Id: 7933f436-85f1-4263-e094-08dcf92b6de4 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: /NeOXjFy8lSKjzqnth3Jc4LFYKWRlNxQ2NQ5KPkgxivOkKhvrgq3b9JfRFz1kHYbvXcHiwTYjqfrWUrjcn2mG6Rw1M9QVMi/cHtve2r9HwYc9B0vyafeU2XUfaBCrz2kqNokgzh46DMbl0RNovO32WrXjXA7JZdGjiEXlR1kamOgkZGpKAGqI7Gf8vUD9/8yJfhMlnD+bIe3R2V5m7Q3lZU9Q7EGllG7wxW16Ff5Ok88RVbCkyqZm4ayaamAE72aAn6bbyq4EeJjF3649CHbhgabHUn3BolMqdArigZZK1x5zlmqGEfzxzAgPgPuahrC7pAnnzr24xiG/CcVYRtvgv/h79HnEIsQnftb0xL6MIHm3rR/VYTO6QskXFC9O991nNSMUXkjNv4T5eT6UtJ+Sd4j55Nv6frcW9McsEuRTpD62pUrhOwYABlN/yWKLxkwMfSQr2g/hvyLn10aHnu6yMHIbISVoRqHfB6cZCPlAAjdBbWrrjLVKTA0JhlEdwoYMxpxOm7CK90BCMjqDWIt9ce9I/5yDfH7+LX4+kUVXINpO1YkRM++dp3JKo+xqfqPJMPeBlbrepT39gG4eKsFbjyVuUYzlooGEilO2FweNyRpuTm3UdVfsmhGXT9dm04GuG+s9iM01waRziXscX8Ns3WBH3OOU0NqYDAt+ElXowgyxwaUwN8gRS81hDd7QZ9G9mDNF+6amcUtqWjbxgIPIqWzuORMeVsru8Vo8OwW6dceBJvKvLGTLjH0K67NcSZysrrQJH6FqDgNpyGv9OX6EhBRB6kQA5MWqv0VQMsPlrPlN4Tcrk4pI4AKttZIBZFicvELWrL7HLT1faiTc7XpAr2jEmK4rfuIOQuUVzHAELVec7D03R1IV1im1m7bSlYgJsSHTHz6Ii0gxZOiHYmWPV+xEuI7bdBxWN1E1vIEolsDsZhoxpvTjmqubry/7iSpbUTbqpHBK6ojNSFM0yuQ2MV1OsZOzNc6XoAUQm2HSuNJ5t4Q7E6rvWfqsO8Z16wtNDBYiMASTeMcWcwaKJWoFcthL6IzdI2N1kfFe6NvDZeb2BOUOBpXa+ee65OAGPXxralwwdpXtMotMjL/9vCJS/4MGTS69uYOO2HT0uARUptRuLW98l1/sdQL9REW8t3JH9SWQlnhuYfi+3leN+qAgZOntB81U4BydnZW4sPKOwE1pc7L3dbljKEaXrgnoSiAzQtQKrVD88v5YrCc0n4idfKBdtDIE+bB7+iXrG5o3F3Rl6dvUYVFZl7KxlRQtFpHIOb68Sebb+/vqZ7RA2t26saKhdoDnhBwZ60PmnoTltnwR8u/KbgH89CdiOxvT+pzIhU5uLOYr4KPKqE/np1pl7Rh3wjcArfuAV78ehqpQoaeY3YU4EQTTVakLXb8bDWFe2MzYCItrZDLkF67bjGQ7g== 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: G+be+VayYEuJNVfwfNG+vWTLkmZjiB0WkFbmpiufTQ4cXd6qM1ECpVb2IfweF7zgXB4rMMrQVuLBDVhAjWc95SwMcdDSuyZ+NnseS+Z2DbbBxjy6+17o65jHzJwGsdz1gbF4lx+uAADx1ncfJX4HJjyEjKG+thYNsWj03LbITAKkfNMCAFNXSGNu6TV3wjAZwJC1ciI9SsFZp3N+1PE9BqjJHlQ17hzUxSO9zOr5WAgWhxkp4p8O7L9B6H25Auzl7nltbKa7LYBxN53QbeWWh0E+btWsFWTs+nGHWN/+nJbTnl5bh+/mpJIoAcEccHoSvdipaxxpmuBbqf73ooE6whQ0Dz4MyDBZn46ynUzMnAkVOyigh1mNh25u2bbj3TzWONoaAl/QBwi0irpZY02SMHPmyN6wLK/ulIwuFAYG3wVU6TJtUZ8uvdMpg38K2Y5I7Z0DP+yxYNCMHEB7sE45+RWTqATz5P+qY5i4kg984j+mJOfpzsjQzg4HBVHCcv+I7dTfmsTdpJq0sKca2Rlvm6MMbG8NCgMCCrXxKXTcZ1auMjtccdbW7vT9GpJQI579KsfxcCMsckBjiLj4X+P35z7zy5XWc+XOFnKQA5W5+myKedXRoRsD4T1FAlI3EGopPnzxzwF+S1b5pBWeBJd3Wpf9wWdPSYglJ7g7Esbbf+M= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:09.9425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7933f436-85f1-4263-e094-08dcf92b6de4 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0598 X-BESS-ID: 1730324411-304433-12636-44616-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.30.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqamBgZAVgZQMNnUODXR0NTMKC nZwszcJNHM0CjN2Ng41dzAzMgyyShZqTYWAOT5PRJBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.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 1a92de92bc..4c3844e9b8 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 @@ -1023,6 +1023,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); @@ -1055,6 +1155,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; @@ -1065,6 +1169,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 Wed Oct 30 21:38: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: 147789 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 C8BBD45BCC; Wed, 30 Oct 2024 22:42:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8789343489; Wed, 30 Oct 2024 22:40: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 0DF6943386 for ; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2171.outbound.protection.outlook.com [104.47.17.171]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SYXAMwKhNJxc1pqtC/Qyq9flbKxNbqNaGoaOevH2VzTqLE8I8Hbj7PMtiU1OcMpsy2ooa1JA33TvQTrBjwIje0PqwjrS208o/7YhiHHQwh7xNVqdgU1uKTkiu6EX7GeKiVOXdoP0zf6KfRzCqewMfd9tVsUpn0lRxmx8jBYXfyGDz5Zv4Fa/3/5j91ld/dnuAxDpfmYMAt0fONDh9F/f6xOPtMNFwRPvM1SvVoOLhW9QygwBdRF18fwYNfdx0M9DpYMXd8clvwzylhqZw+lOOmqZ98vCj2L3dPW5nVy4NLUBbI3o1hjakC5FzDDulkAO5VbFleYDqUBGlCMfHTTedA== 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=nNgZ/fcx45i8Y4C7RjEyVTBsI7Yex/iPyjd/zBxj2G0=; b=pNycjyI444YzYRMqqWjUvGwT7F4rRrfF8nXfjNSpYZ7okjOmnehZvr9kI+Dy3fYAc8iuJLiYImBTE48WCMG2J7S8trVzKrH9AMnOrM5Dz0YrIlYIuHKnYM5zKF8ojJKL5GUU7YJedbjUVLpTk41fKiI+PvcGeM8pqstfgmP9pXkngUJV295IT/J2KNMFvsIws98EwAWY34QlWIDvcx6yOZ++wcOy1fVridqqqp22xqgaT74bL0dQOUlTt8oiO9ox/Ag76SA0dP2Ae3jA8J2J/TuTwjU8REb7EDjncHuUYAb9vWTQ3HtQAPbOnF48TNB9Fal6lnqf6LASmNtLMtdMLg== 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=nNgZ/fcx45i8Y4C7RjEyVTBsI7Yex/iPyjd/zBxj2G0=; b=QBRKaP9NYgiB/NnkZOaOgeEwxSpYjK6D1/+utKrAjUDrPbtl++95r+RRVUHalTUK9kys2DVl+NXO+eb7PXQdUr/hJCwSkH/TyMSyVmkMdJVZNKPXN5wcYBs/wb5Twq/fbZQq1alv3VS2kzlWeyTKS2CO7KfPjkFHGS6cAkM9E8s= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by GV1P190MB1946.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:55::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Wed, 30 Oct 2024 21:40:11 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::b) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 21/80] net/ntnic: add action VLAN Date: Wed, 30 Oct 2024 22:38:28 +0100 Message-ID: <20241030213940.3470062-22-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB1946:EE_ X-MS-Office365-Filtering-Correlation-Id: b33e3c8b-49bc-469c-14c8-08dcf92b6e7b 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: 3eAVSodzOEE0dXELMwhI4o1RCjZGMmDx+etO9tcu23v5eEGum6hC0Ip1EVYt0RSa21tcr3gVMC15e47sDu40JmYC8BzB30Z/T2JS72HW0g3wuplbXgml3q5V0f9uKtptZ21YvIQowHKlLnRmEi+3NlLt3FCVU5p4CYpd4zcsZqkoIQFqkX66iH9vipUz0SJRIYkBdnJruGG1zl/Zh+HHpSF3vYphmhuEED7RCKcLpd5lUMKxIEVa4dHLwDhSxid0AVfGplAhVGLVWlARQpa2UMio3OBizClCCGp7p8grPuFZxpcXUSwXiRktFktXZwrE1LyIZfcf4A397ZRJj1tP3rS5HI769vuKrbvnsNjxj6qE773BDJzhC+kEIMOzM0Dd+eaUcTb6egT5J8AB090L+jtvIxf45kdCcqbGMLdkwm6F7AVc5g3a6s0yrbydzGmzx6j+hjGgQp2/zj1geYOncnhnCtWYXGJermXGCCWVPFm6u08jUJozAU297mZT4vo2dhVsDxl4z1RS2B+bkx4PVoHwNWTm4GUC1vqo+xiV3zFEBSfDQJwhF18lMEiAsQXGm7bkWPjfj5pZfCysE2XKcoVE/q9dnwTXPuk7z76ZBp5XD3Ngm/ZhhrhYegNBNduOe9XbPreOhuZuV65xHC2F6728/5Fbo3bJil/yEoNRJ8ug2qRLup2xSUhIH+n0FbgMZ577fyYpkU2jPHjTdWi12cmLzbopmz1AU0xsOLpt1xIw8kwIEPiKsD5HPEEt76owSbIv9unBROkwqvzb3JuIj0WtmyzkjNkd4IIElQzyS92o9LICjKAyNW85Vim7+YBl5F0epLvU36lOEqqctXZkFCtlJ+rDFIDqphI/9g0Yq2/YWtmh7AxYfjU7OdzaEOyUfzH1YA2lPD4nDReotOoR3MgEN/yGVfpFbTTDstichFrw7UbxqJP7EDMsNddF0+LwiIan2J16B5f3tU3Wa4xSUdvcccZR1jCmGibSBGnoSEUNvlefxSyZOptJ7FpGEZcYSESMHlzE3+Ju3kZwBnIPyinfp96GAiZeWZsJ5mcdsO3Fo5aQMuZ+VURbjwN4rZuwBe8z1X2+0PxkW+4vxB/NkREvLOG1ZEByUroe9B9JChB5Gam060et+lTWqa20XYNocOI0dopsgI5JxRZGVlOUwQ9Cnrjgf4WZfxxlWX2kN9fcr74dXWNYgD/Q0Pfzw/f8bHukUGEagLVUApXdNJHyGF+XPDw2+ic8OL8bt/p7/OwEO2jkf7g4unfgyVaKvlElsP8dgnoxVNijwyvgUPdG2bmy3HaGTuaopibNsr3memLGTp5L54ZN0GTJwgXoWQJQQETqr7plR6byxogiIRtk1nxuvpOC2IrftrjaCNwuPjS9qA+65ImlmwqJG++VCj1F1mzR/TIRAM+FlzCTVMWiIQ== 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: 1vMMattNUHtIFKNJaDlrekGIXvkuErMZIQFrdPGTXRFay+GCQlscDLD2oBdn3KzAL/ac9vqZJF21tA2hZNZqlYxIkwhWEBhM882Yk5/5KVpwo8fPDSiNwNPmBZOAwnQtOk0L9RKDSZq3rxlrKiEk+6ABWX6OayKdC9/6WZdSbI8lh3+/j2vR1TKIWGq5Krnsl7hnnwBOr47lqWn/sn9Fjr/Ezq12bVNuX0yrteMC+yPlUIJxrhgiGqrINHX7MKN/nIOFTarzZGUNJCNu9HyaaiJRT6yvlkyv4Q1WH9/L8cEO4vF75dv2cFHslgM5Lwiz5lvPb9zxaNgOgVAjzVBH5M+bio4hp7Ixj4acYPTiJ9zlAz3FrQFkKtEQh8FNOWVw0LnzFrRdyE6fG1cOhH3po0pPMh/dJ6VCp36fCI4WIFL25Ew7F4wGQH1cezkWEs9xuDsuFsIQgjGvlgKgmD2OGVFu3UxA/LfwHHZSKCBgMWtzNz0kiXaBCHF2Myw6W8qvLUwsd7TF0QFBpFYQcLXnCj4mnzNfE4fi0+2h/fP+/mZHlclM3FGFXUNVTdBL8DblE1msF7gScvItVkm2fYITXajGnek2PdQCgMHzbZdVEjZ9Bc6YDKvLknOTRiTnmO/fgouifwrqhHg+BdZo8uUEBTMTXbLjac/pDysehH0+Gew= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:10.9269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b33e3c8b-49bc-469c-14c8-08dcf92b6e7b X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB1946 X-BESS-ID: 1730324415-302901-12794-43460-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqaGRqZAVgZQ0Cg1zdTA0iTFws IszcDQwCwp1dDA1CLVyDAtJTHRzMRSqTYWAGNMPqtBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 + doc/guides/nics/ntnic.rst | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 1 + .../profile_inline/flow_api_profile_inline.c | 95 +++++++++++++++++++ 4 files changed, 98 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index d43706b2ee..f2ce941fe9 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -46,6 +46,7 @@ Features - Scattered and gather for TX and RX. - Jumbo frame support. - Traffic mirroring. +- VLAN filtering. Limitations ~~~~~~~~~~~ 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 4c3844e9b8..627d32047b 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,87 @@ 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", dev->ndev->adapter_no, dev->port); From patchwork Wed Oct 30 21:38: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: 147788 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 0518D45BCC; Wed, 30 Oct 2024 22:42:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75007434D0; Wed, 30 Oct 2024 22:40:35 +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 1C08A43386 for ; Wed, 30 Oct 2024 22:40:17 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2040.outbound.protection.outlook.com [104.47.11.40]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lRyPJCUhJHhCyGAl//vjY7OaZg1ejXgBQlI88O18KcB5a0YjUZnmPG8BSCBObYkN3cjp7UG9O9PmQDn/cRMZzx1PDb2A7s9sXp5uEse07AC9guIwxIlUniXYotNqNswK5fcI3glTz30YhliDBN/OFStxHClInjk6Bgf2iJEMZF9bHgA1S8EwDKPbthrwmCvUTrfwqZhjpioZRYnuX3N/10vcAz+uVheAqaPpKAtusd7LswGy+D4nrCA2DSClC2vF5xP3ScyKK2YcC6tG21pQEdsD1WR904sLEvfdqLWN7/F0Q+lafhbCDG6W4Qc+27fsr/HKnVdqk8gwlRgCBtc5iA== 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=XwKOs9MpnvaTsuvkpW2hLvd8myHvQdcPA8rTnU25W18=; b=KsOB7GhV5NOvaP2ighL/Pw+EMakwt0iaRPKd8rHgK6xMpqmLjN6eipVt4hnqY/q5hnbE3AMiqt72lfwO2JoRmqOPjbx/bl9ZWpboeGaU59AnBQLi0b8r6tHZLVpz/L1czyqjLTtHDbLDvBTxdRUIJD2DxUxdWzqO3cySGzEf7edm0k/oQZeYW1eoM09WwBzd+KxWl0YcZqoVVG33MyQyFF+33dZrJgKhOJqiw4hGCD5BuDWrp5bgJVhq6JN5lxFhY5KdYixnkIdK+zjqQfxZC+gPtraNpOwIHM7/8gXua4JDcfS1PPrI812Nuh4NqoMPxRIMVtBRa+4hMmwFNxVuNA== 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=XwKOs9MpnvaTsuvkpW2hLvd8myHvQdcPA8rTnU25W18=; b=pYE+fyl9suiSx2hBRBmP6jNjy31KrCcreRxoKIRxJC2iImfoW52nc5HfIQe8Tlg/YbcnTLk3qVkR1miqM6eL8u6uNO1JoahCUb0gDPkw537GdfswGxDbQJt6aZYScdw2pZGkYkMx3P36egy8Dtto7Z6aQY5ohJMEyNDPOezWcyU= Received: from DUZPR01CA0012.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::14) by AS8P190MB1095.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2ec::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Wed, 30 Oct 2024 21:40:12 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::9) by DUZPR01CA0012.outlook.office365.com (2603:10a6:10:3c3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 22/80] net/ntnic: add item SCTP Date: Wed, 30 Oct 2024 22:38:29 +0100 Message-ID: <20241030213940.3470062-23-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1095:EE_ X-MS-Office365-Filtering-Correlation-Id: 6180813d-5d1c-4b8c-6ee7-08dcf92b6f37 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: /ZulqDNrqXn8g+6d187BY/WtEpfiBvsWTMp8cvGVr9icnFdTvqr9UF28eOiQJgxXqLTtMMqCZKsAc7F5c6V/YcQvFqCdF+SmMENITCIkxo6VcMJD1cL4XSqLo5v8Kio3g0SHJ3il5Tg+lApkmqhsOwiYOLpEEQWhTGijV1y7u3WzmXnC8TYifUgccLtqBjIip36cLKzmOA9wixSQgspTA0Nj/OMQo5qyjbLWxBSQCoMMeajhDRlWpIWZmTRAOsgI5arqpiTqKT/7ofrmazG3p+P3e6FxAm6OxlzbMFXvl4ogqX9qKdWvw0A9r1XKcXtie7lX5d0dFG0X7v2Y+gMaPD6BP/sAGBQZMiLW0+Jqe1QLBQgb7PjC40Scq8Lzp1jxZX3JfEXL3x5wCb8bUIeF6EJHHt+YAgqfi3nmo8bB/YUYtu5VI2crP1m/BClfndPRMRmyjsRGfZaKRguGnCwoV9qmtYrop0XfRpeG+6gOPpuHYNaZAh4azwrSJWpyeUYrRhmnhgll4OYy7Np1e/On98u8Mtf2bRvFqJFaaPuZTQ3PiHEgvhaeFOn4UmPOUAaIRedwdBynsPKK8+b8eFi5KML2wQn0SKyfkhX3N9cpc8CjiMJNrPzFk/3nJNsMMcLCAcslqSx6wjkwvlfzEBNLtFBbPvA0mEzUdw8qJ6m8IEBe83V9TJlWks66TJwZSqqqZsYoCF+omGEZWlJ80zRGqC9EEL7YOLU2xLIE01r7EU61hugedelxie8srNv2y3+0g7n2UTfKFOEgfoZk/O7mxewn3T9z/1Y1ehLD+Zgyt4C6Phwm1SBWcVcDk70NOB0OKcy7TTeBdPz5oHcf93EiVl6e2HFOBpuSYPiG/1Et+ujjKHNL9YT91MCcDfyJG0E7bosZmXv7zU35Q2Cmr1OqfsiScwCUU83xjXouV/7G8IukgODkX5EmcnNhZLAiqq9YM+T6mXa7EuvA8yMtiTjlQrOVEglJxMj6uGKnkFkvTI1rt1163Kf0uC0JJkZUars969qKjUiip9SBt0N9yZlS15U3P4JNTN8GuOxVZUiM9yppgv4ajAqICmWxG8ueszciXiDayMx0/ZLYiRkAbkQLYJrpou6mwP6Ll0Z5hD7xyF1sgdKYzJU+KJttUBhvAlMgdHL6z+gCY/+A4gQvMMn5bVJNphveGBb2ws5UD57O2lYhupNrW28nptYL1mzs3cwkYNbdBFM0BjzuvCskfhWY7BuUnXp12TbIdyEC6rntXXyOxsqzznO6LSdhQyPCKnhR2nEQpDbtBkfqjq8u/qPxBMz3Ywuwg+cg0RBIKOHu/cMjVMduMNEFAz+z0vanXbHrM4bc0/MDcuCkmv1RM5B3UmjN5fOG0gk0w5OlFPaw2dk81RqSXN11dL/6GYP81Czh2Vr3nxt8H6zNanK1FAyZzg== 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: Gb3VgeXpvZdq1R7TBqUJj6E49GvOcMIYHyOntC8wXfHEkLF72wBM6x2S+FdugiIeqkxTp3zM0Oo0CBSKmjzRPhGscYy3ui1muUFWwK/ogQqto+BfHLa8gebCOMG65DeMF8xdGB6qvofhqjDm3I/E1nAjfNC/4DlSPZOKLX1CbfT/FAOZIYZeDnMgSBFZXiiasqCFCDxxrTY/Td49/qanxO0i29Q6brkXF7mi1zfvN7pWiUBUy9YOVx4AkhxcuFg0CPNi0GIfvYGxteTZupPy8YQfn8bNfEH6AHV4gXW2SjMfgjYrCbaonuYoyWZERVsBxrCxFS3BX/6dJfYCO9BMDNvlK+1coLNyjFGKaTu8RiYKrBuy3Ig9WUFDOVb/Azy3uet/1+hIhWYQqm4S92yiRrtXYdcGjxGOzApGRu27/C9/xqTLY4MW4E337RcqQ9OJZn+8G2kUUE3ZftWhnf8ibUMwU3+Oim6wy2/t2aNDe03uNeQhWP+MtiMIJSq/RPXj0nC6g2vJw1lmvjHuQbimLiDBVYlw9FTKpOYhCW8PLhpuwIGlZLwswa5gLHThUA1SRTnLA1q8eXzRkI92XOkCJ/NtyR/iDV5NRj4H3Hgso9p2uNTgXCC7mkLrBQnif0cwnGd2if2+hdAMCQF+Ir5H2NynTaYlOB3oUzkpF2ckyzw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:12.1612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6180813d-5d1c-4b8c-6ee7-08dcf92b6f37 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1095 X-BESS-ID: 1730324414-302901-12794-43459-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqbGJoZAVgZQ0NQkOcUk0dwwxc zCxNzYJNEsxcLI2MTU2NDYwtIiKdVYqTYWAEKSz/1BAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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_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 627d32047b..26e6ee430c 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 Wed Oct 30 21:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147790 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 160B145BCC; Wed, 30 Oct 2024 22:42:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9010E434D8; Wed, 30 Oct 2024 22:40:37 +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 375924343E for ; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XiopGD0MBSZe0PmflzSucB3Kx0m2Y79+xDKVdZzdw9PKVuYf3XEaY6I6cZC936HvCoWLYTDO8zm8REW0/M7cpe+Twpe9yKpOqnXXdBKSnYrIJytMrLJ8a+i5TluZ+0mHzn7RQHyRt7ZE6ROIlVN+UnKUx6JmJ+4jxure1uCTuyxH4h+wY4afMQxAp+Ke1/18nradIZzO3n72w0bt5PPtvfWgzccPMDXhvvM64RHplDaFboLJ3N+05FL4bx88bqh0Hru36+wH2YJwt9Wy4ME5VnGPxSttjryLidbR/+eltyB2LMtkLWuZ+PGBmaNJ6Zbs4Mkr40YcvBuY2d638y1ByQ== 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=hghca1A0hmH3wQt9XQd/GRGc53/mPen0XOyRhU16PXI=; b=PI8o2yMR48zW55YE1xuTwBVx8ihTX81UE61njHWqr6BiORLWE1NdQbIF4WCeHPHI3/U7epgk+JpN4F9EXoyELouYGEtls11/qdTKaIHpWCibbdz357ySu22LeqZb+6/toB71/k7fdMkKdsW2xxUkX9RKgW1xkWp+aAYDy+DNig97qDFTe1v7jXP+4AISObfRC0fNNaBW6KJo17qXYDTWbFdqOXfPHPnSqSc6GCnpOu5iX4SzZDsJ0m/fLnIGq8ZreYfTrlf9hLdiTzV+T93i/EH3Q/yqKKE/GxEJqtC3qtIh0XuifZUVaTukaKvgKsXYQJPwVAIsIeY+NhjYze/edQ== 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=hghca1A0hmH3wQt9XQd/GRGc53/mPen0XOyRhU16PXI=; b=atJTQITG2G9UTVC3ClipBGxu7z2ljqOTfJmdPHA6G/Z7vN523ZUXH8R1eiv0P+65tA5pVB7OkGQpKG2JeJj+N72ibbHCIgD5adTRDefv5T3/yYeCeS/V9QGt/q0pM67kFOqEdKshQj/YD6MOQd+rgJF86Db4v8UOXKKpOnZfzUA= Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by DBBP190MB2036.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:52f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:13 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::86) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 23/80] net/ntnic: add items IPv6 and ICMPv6 Date: Wed, 30 Oct 2024 22:38:30 +0100 Message-ID: <20241030213940.3470062-24-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DBBP190MB2036:EE_ X-MS-Office365-Filtering-Correlation-Id: 44532845-629b-429b-5557-08dcf92b6fbf 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: 4XuGLM9nrecl5u5araS3ZwIUki2yNvuR6B83zl5TcPV/TUsH8GFIjkYxBl+C5xB8kCqcdzArddnAu3YgezKrkpjyTPBEflQdxhELNNfJESeblSUGRus09+O7MnommEMCWS/yfsVfUqBWpyIT9F0ghV7RDCNoE5qy+vxLKpgXgwhZPVtpefpeX8tWXfBvkjFu3JQfNZT2oDsFc1jOZgYWK1G7Cq1VZ5tCv1c7R74zh763/j3V7gbyTjPUyBw0QiRknaI3Lc/6CWqX+EF8AE/1TwnBnlwMyd0eAxhKSmR1bCdYA/y7PQwXdS3OLNY5HtyAsPf0ALpVhZT2RGvY9UnQ/CY3rHzRCHggCQc86VDwlgfNGfINFydjfFPEd1WHZ6+ZuHdby+CpAPCLApKdnaO/EXgax204Dj9idwacvR35957JgeCVQhw/qFK3Zjz5zul9FOrNPVnG34faEeEHIA4ppikznA8EOe56xzmhn4XNmdit8hN8yxiDrcLvMhw5L9rzrY5F3/8xK8AIBeZ4NgsppZ+V/2txTHkgFPsmdb8I71rLOW+7GOlJVDe4AR3tAxJkdHJUumphERmC38gpbdpcfD24QZ4+EITcHZk7gDFqhEKfzXuRVzdsdsdlMOYLbgC7mBwOedleOWqfnV28i6hi60awPC0w5vwQzt8x6vGHuezanSrh8EcmfhFY055GjCXuscvXhFTC3QVGXzvKXSju1jU/VqA+t64AcZOSTZgCFCYf0LUr89DOc4F41CLjtw8c86nP9zf359LlbDtyP+++TtVkN1RdFaISzpIPvUoTbeyPnRQh1a6XsMg5ThjUc+0F9d51EpTdzJQCUxX2HOjuHt1WfspK8lgU9gIipK4ILtevCA0GyeaosSetJsPkcflEWcVAgZrzpp5fQh1JXT9TneHd/st+Bsw+j/veXUoRC25OAH4y+E2z2o8QKkEAaiPfwjs9zP5yzxy0rfuC5Iua9XjWpnUwuYunsNcj/fuvDJQFLmi6/QviGQg8prI0jSctOvEQxJ2GctIlXphRqtn5kjVY5mfcSr/Z8cSOPT/dVZalTaS76LWCiw+jkoE50J0d5twwaFuSDWW06hTlSAbgmcrMNElKMyQ06CXzvWtccgqiEQBuYnNsIyroVzi+EfcidgFknj5fH48eHkTAdVQgQmCGsfdo1ZJg1PFi2fHOXmJePJlXoTxFY920hNlFTtdPxxioe+iKlDHq9LCFoxg/HKw0sBVvqjHM/chSyrpwMjoU9ObIv6IA4dkg+egVLwgqidirMM7JQYjYimfotaB4wA3umyAie3o3+OW1Kp2bhZSw0bl2Xp//Skwra3sZIGG7PSV33QCyDbb6vLQh0txDFJdfBBghqeWzDln7iKSGW6bs7cuZlbZul+UD3yfBFIxsL0uH7v5AGuVu14RMmDj6Qg== 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: U7qMPWvRjuwL182kkoGwHnXugZ9jHv8nzh65a3MHSZcfH0nbkhJsSkqnahzcCkouXa7/Zz83Fs93/6T44gHIinrUJVW05yOGl/zG38qigKBw/VKyMUeEEzRPYVOafIa4twbZ9BdiilQu7GaqAmARhUIgLIjOIPxr09ETsCceDl6TpbFRql0+F0hXMiHG/FxqZIFD/Ywjzwvjfe3PmYJ34oQnB3+ckZgBmtiyNoOC0jQ1RSW1WWOFfGmPoepUkAoKbQ08dGJnuRFscT+URnvn1zSgK3CdWZ/lCUXCjlVnfVA02GeO+x/b37Mb20RDQQK6DA01XkpWo7jKwQjMxUX2mMg5STfqz0jvVQtgJzY7TVNh0cccBdnbwf2kt190OwdrqOSDPBEbjQRFm3p7BZc0SxmNmZctH9rJ83/CDyAt2H18OKph5GCHNjiMNmem1lDKl3ItRTFsqZir8gxE9gLcZAjgGrgxWMwkZxf8Tzi8JWE5LM428apnw8nf4LmVEhEAamUur/oJxTGqXwEECtEs4St0CaRHvSAXj4PPsjWPCiVOTLqKasPm7G+zd3To7KHvoLw/FZqvuqOSgmwgGYGjw0Zn/JpZ4rZF/m0oMEv7xg+vziRENgGGQMN0NhLZr+bZld0XfOQb1ZhGcXE+plIkRvsyPL+FdtKN989zuQSOmvU= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:13.0519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44532845-629b-429b-5557-08dcf92b6fbf X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBP190MB2036 X-BESS-ID: 1730324415-302901-12793-43460-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGZsZGQGYGUDTN3CTFzMggzS TV1MwyOc3cNMUwxdjQyMLAzMA82TLNRKk2FgCRLGlUQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 a9016238d0..4bd68c572b 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -45,6 +45,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 26e6ee430c..f7a5d42912 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 Wed Oct 30 21:38: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: 147791 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 8887645BCC; Wed, 30 Oct 2024 22:42:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F948433E6; Wed, 30 Oct 2024 22:40:38 +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 3FCA243445 for ; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NCCOZLXhPXfcOPW586Ri/FlZeotL/guhdk45VCZifYJ1CWa0ieRsJppgSBJKHgO/X5A9rBX202m+NJ+QPxWJYQKWhy4i1xV5ztouOee5/3UMIGCnurDDFQMpeS96+QHc28SuX9imK55IvNLNpavbUl+UmFY9XdiiXqOL3SdV9DePtsxZ2zXE6mtw74sRY6JJAjBYRo0S/DWF4xtE5RI3QFXd2rELctZeYFKjQ9d0NHZnwt9yGEtTsfrhocj7UvtESX1QQ52In7+GDZ7ANIzGsWUKvdCnxbnX0u1MPCunNMx4AdUJE+84K3WzlyT+DSRKkehGE+qCst4aKn86VWO9cA== 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=NiaNpr4K+yb4xmlbVoaTPx57f5sditc32hQQ4J/nFMA=; b=m4/KTNL6qGSiH/OYgDLx7unSv71dRyK6cSj0qqXIdFx+Qj+ve0BXsWEYrrX2mugv5AzJfnsz1R3FJEuhnCHxajIYuztn+LxWZFCUWX13nmc8gz+dYYlSIdxPqcj6trLJAM4Fv24CEUjn9L30X/bz8mOxzGtRvbfHBzm9mkUUU3F8yO8x3gBJGvfTGri4dQpYtVj1lRzl3RQGxHaDpZ4OfHOW00cCCE/NNnzqg97zV8A8kKG8nXZwIdhHLFbrfJcSFYO7UStuQzpRorZsqP4KF7FsNACyZa6nNBz9ouf7mTIRikReD9jLrmQeWZks4RT7tgRIR9uE7RUre8lUDzit2g== 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=NiaNpr4K+yb4xmlbVoaTPx57f5sditc32hQQ4J/nFMA=; b=i20Sy1ymZTljVNZoJqmCb0NzUWTgE9wT2FBD3W4FmjlrGLwPCV/GzmeXKLhOMxMjy2KRItvfWX+HdtrHM3hdu4PAeJtIbKrBMa5Qv2GkbGldGbkqgroVK+lsal/bZZo6FQXTHv0IWVqkgXOHE3KdSn0doplpbA1Vsisx6/Uw43M= Received: from DUZPR01CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::20) by PA4P190MB1117.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:105::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:14 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::78) by DUZPR01CA0004.outlook.office365.com (2603:10a6:10:3c3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 24/80] net/ntnic: add action modify filed Date: Wed, 30 Oct 2024 22:38:31 +0100 Message-ID: <20241030213940.3470062-25-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1117:EE_ X-MS-Office365-Filtering-Correlation-Id: 59fa3be7-244a-4275-8af3-08dcf92b7036 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: EQGxQQhd6zldjUa6VUiz3iSvvqJj8GFGQqpt8i9gFhDqpyU0F9NvfXD3nYw3zBsfg6otAUn+L9M40wrvDqmowzoq4H5f9foVrrvU3HKgNByNj43BbqrVZU+MSTeZCRrOtM2aD7jTmZeuqG8er6Mq3tEGOJwFZ9U/7Rql3SE33Nxe0zuW6cbroFiMeFaXzn5mUL4RhLGNth0QGmSNU42k0vw7wqUphgAWILUvCNpumlFYRCHdYFTbjpa0dNKpI/LXWpuCSVTnMLNFVT3wxiqIJLhzmB4WlH+yTWxX+nC9IRCFRaS0xmNdySlHYPEYZynGvvsRPghreIgxqyxaGHXhvUqhX5w8vID4rW1h4a65LFSLUIckXxiHcjfDt6KgAgV/EXZHIQTMO5tFjv5U9qyzGeiReQCq8MsrNRZPvsjMgW9j2Pes2EluLnwtJA64QNamsOw/YFmfhgMC7dHovp4/qiSTNAzyUlpa8eBsxKn8ejV2PCF30auI9TDI/F4Av3GtFqasbsEuLOVZr6aEzQT8AL2Ck8w1sZ8RXZ27OovIVz0NBuuiKbcKjCYi8J7Yys0gbIfVbV0USbA9eC6v+h0z1HdbaSII9YQA3fFYiMN0vs9LsQKAnefiqyuCYDVqjb6Ec4ak/KEjFxyKRYNZ93bAR5pzP026phmYfY9elOCtCDv5qRxDrinxgJ3cN0XfGnVMWwJ5UAw98XKlFf4gN49QwBl8nY0FPwG0bXLLvddoj/22pRDYNgHgDb7aERF4CUvBsjTEZWNt/5122Hn0oMHr9LILjXueGNCJmwOxAZqh9oXR5oJ48nUKT4I647Eq0hFzVPkpSxbCNQqV+fo1WhnK4+SSteHd5FeGQxWtSd3MLSspBBV+WNgHMKM6loWuyA6bu4cWaE0zp5VaJq2hLiAusQi1F20KlkFAkwolBPcs1njhfktPuC8hG/SqqbPHeBErRGOtpQ4a5tO3H9bGAMkRBo7gsS7kT/F8pYNCD12WND+NNQLi7pgmDcwntjKAOZW9z7xLbWlut4e1R7a4OYsPBXoikQEIDZgxa5GSLFiEb+MzJE7DX41/+9bfWMOIUF9nrHuBCoe2LjQfIECJ90zZ3Jdz+MhkDnyt4klF2kKYDFmtlbfTXCxj7tHU2TEVKtsByLxnzXW0Siy7b6nKUEIdFwxUII3pudwj+6f9S7uC48O2E0lQ9Gh1yqRL6DmA2GHw6CTLGj3cx0PfuJnwlHqT982EhgAPnBKAWaf4uplIe9Tn/X3WKpS8aLUV95qc9H39ry2dfv6wdIchIc6Ps+2/C1uANJ9Na8Qulg3N3W2N16g7gz/ig8tC03hkB7NVzFlMjHEK/iZUi587eNivkZax35YY+2ZqwnLKJdvpMd0SQhhqvKunVQF4q8snMnhscqFOe/V3N9hKmr/jItC45wzyqA== 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: 1ih7SOZuFn4oBFExSnR6Q+wh+V+LWaqFxU2TGCi6KG3ZBsb7QDdDEkWnaY/Xds0m/OrPFGM3pRHm2UchCHWQzjIRreqwQOEvpTjPQLZHKetgf0YTC+4Xd2a258WgL+0SrinE2m0f+cNpwx7hLXtOxlT4BxGks6iyChM0DAiCdVF++zugap5/Sy9s3w6Agov9tKapkIqAEpB2N1Hw7YyIdBmA/BQq4FNvK38yIUq8NFEkTuBjuqs5gCGIuvJjdGOoyDWme//rP2zxfMg2GISjyH0ufwTnP6t+IneVdDChtm92HRRRU6r8dEpgNqkE8gEU5DYQt8NvY8l5kusO9e2OWnhjCo//SzKpQrbnawYt+K2rXELqIIj+roLRJwc9i5FUSTR9zHguOeLadxv8kBXVTYzjJUR4cR5dmB2Ol4WePghmI81qr7uNRJBXqCNhqzcnnqnJRmNMITyRs7m3DdgZqf35mjbQVLbo2Kz3OcFHDy/04P2FvmrgkcMzttPQJAaV/RvhRxiMW/gQG0PXqA+59onR6Dy4itLN36nvwCpuq3zfYHZLt2Lirr3AArfp6sXCy1oB5v5m+ar4BJ6SFo4ojLq/67JhHjki/Oo1HJKJ7ffJfGrodhEz6/L5PWvkOtmFuuPG4SmvwdXSmjBSEwdYFBUGNuElKS0X9THicFs8y4U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:13.8331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59fa3be7-244a-4275-8af3-08dcf92b7036 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1117 X-BESS-ID: 1730324415-312176-12708-40686-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpbGpkZAVgZQ0MjMKDUpxdIy1d DYMsU4OdUsMckoMdnIwiTF0AQokqhUGwsAqhWyYUEAAAA= X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 + doc/guides/nics/ntnic.rst | 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 ++++++++++++++++++ 5 files changed, 191 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index f2ce941fe9..63ad4d95f5 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -47,6 +47,7 @@ Features - Jumbo frame support. - Traffic mirroring. - VLAN filtering. +- Packet modification: NAT, TTL decrement, DSCP tagging Limitations ~~~~~~~~~~~ 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 f7a5d42912..4cadd3169b 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 Wed Oct 30 21:38: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: 147811 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 0031C45BCC; Wed, 30 Oct 2024 22:44:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D616434B8; Wed, 30 Oct 2024 22:42:17 +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 E816A43498 for ; Wed, 30 Oct 2024 22:40:40 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2239.outbound.protection.outlook.com [104.47.51.239]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tuBX/E8IzjiQ3rw9NvpaaDq9SIkCfjL6JdyoWERXq+KQRL+LVflA01nPO/k9/V0hJSrs7ArynpIeQVe0Tvx+kbr6J+Sx/ipgIzyTgwsr66GnhLQhAX86tkhKiXjgjzl9HV6OnIy3ALuNk2mrGfFlVxv9jJyMV5BWOnghYI1aFzb8mK0iocYLYyGXHMsYG5LNHn1yR5/gggGHys6jZxXW5nOiDKOdV6hZbM1lDospSBMwdeqrG5kQtHYpHur9i0h/zzEV63qWru1GcXqlLqXQHeQLVDcbyzAAIbPVmznn0s6kdbH72dkalP7+EG/xqepPIHEhYMQQHrLlzNeh8k/Ugw== 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=al8CLmKS99T4BpqVtwkMPIjhScD6M3dDVS0Ku/hPMXI=; b=Kb+afmvTtT4sD8d4eS3mfYGIWQ9YiRB0D6Lel4abZ2S3V7JC9aQEwCTQ1RO+uErKfkI8UbsLr814owcBu3kPmqM3TGAW4zZohe9Tsy3742u4LRgBP6L0vrnEt4Cgk+cpI+IvB4SF9P/3zhDuYld77xgaxJs1ZjOkN7fD1a2l26A/NYM61u5xlXZbLquT3qH4OHGKS7bVWkgVmPo97Rgo/d8lpUHo26EpGrfTDSi3e+4vZIxSEY/3hChsnegPTHhF/Qin7mf+0OE3d3+aWdZFhJ7cwJAs45FCgPNENwZkavkdhm6uTdYWl8NYVXg4tUuhiQ5YNfF3bAOWjiUhAOWDcw== 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=al8CLmKS99T4BpqVtwkMPIjhScD6M3dDVS0Ku/hPMXI=; b=aP0R65DrlrB5/C5IoHqXaepVjX8QGYgDo4pTXaUUm1lSQVT4plE/vjbRJhlIkfY5QJMhGkPIWRmNCCPRzHBkX+WNrar3qJSobEXMt5NFP1fMQ3Fzg0FfBkWG410Gm0lWC7VvSPYp8vJXTOADFaaV4LenB8IjjRP3Y577s0i7U9U= Received: from DUZPR01CA0010.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::12) by GV1P190MB2133.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1c4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:15 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::dd) by DUZPR01CA0010.outlook.office365.com (2603:10a6:10:3c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 25/80] net/ntnic: add items gtp and actions raw encap/decap Date: Wed, 30 Oct 2024 22:38:32 +0100 Message-ID: <20241030213940.3470062-26-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB2133:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cf188ad-5826-4c8e-2313-08dcf92b70b0 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: J9k8v0v5VZBSylvwT14In4v2FM2p+GM1z2pCpnL9m1yWLtya40t2Xksgj9gPWVOc6lc6PP/kVmrAIFalUkzpCy3uEtY6izFhFKxva+WiVSvebyz6hKnU5uQitj6H7xOGhQG5MgRBqP2rZ0Gt29r6pmLY4tbM40QFBUvfnSEAXvcEBYi5NTGIgs5Y10mfblddL02BieIwKXluNI0K8Dbzt5bNC5n1JNiUt1OlurBXbbm0UWbk3RTpiz+8B19stNxD4M1sST8oppUeNnvMhQTpux7D8cZV3t7TA3ELckAqHxpso7wnaR28hO94rBB64BpYBRoBfsiLewfDFsbvmNOlxy5TPhe+AENGUhLtKNZtxfKw1jLQfHAWwStd4r5Thp9xCcDL69jj27wyPdJNcal05Afx8I+3Cn19ZMl4z1C/JTzP1qwfMXKfoO9DUBFkuJImDnvlN7JRWab7uM2PIj96ZisC2v8cJzKbGI2ixk6hkvkM93ViFDHVAy07bUnflBl5i+35trd1YEhmy1tQ17aRck06QDC8jACxdw53Ljnz9XH5b+SLLk+4LQ0i9bVzgE2ZZEAy63VjAuMP7yoQhZMuG6reHOHX1DD2A9yeCKyXfxQ6idrf0SYOgMjPoy2FQRzKO98hiF8ukv+WQXjvqBXUcFrAoqbAjbshoaIDuXCLZs8lYpBTme4nFjlWGmzRTOQbphjyPixM4R1DvNxvTDbA60bYkbdElGQ4VpiUEtqDNSSkVvRCXWl5ClYwkgqyKBoQtecOk+gUhhCEmtXmkmofQo511TzlFO4It5xLo8hAADMnzsdXpS9N2mHj2fN+YF1Nh8Xx1lpYnNkvieijg+RHScepp441X9i8kPLPeDLCtxZsOn6Djd1L3immqHDgWudvgyxGcc3hm3vmHTDBStfz/5Il8JNDu4h10hHX9UFHqzDsiqutwyoNo/kVnicO/YYWrSDQtYWnpzuU5fqkXyeV8ZE+ocAM73rIkN4fslrkA0YNlaLh5JUa5l+9ylK8SBqWIZDBUbwS8u7jK5apkS69xGvGayRRn+H6EShxf7euJ53y9g6Kn73Vz5ysyubjVmiumeWhOKZiOO7bR+sChZ73hzAu2jog3iBoPxsxBMKf03TsmLs/TGyttCc3uF1TAjjrhoPvhqkFPMdBYnqQcRARq+IVUIkB6oxjvtYDGnSH7+cKCnWjkYi5FDkTmJXSJ17ZKTdxAG4NgKk9yqpnyc61H5TCEZGefSreeC56xXpmTL80D59QVVmn/IITFjVm16VSiQuzYwFDWOVecYokgBXA6gDCO3CabHNk8Wc0dj8kTw+IvYCyigeSCWwI2ZfvuP8z5xcZ3DPzdSAbz9j/yxomXn/Xi+Cv+HGaxZZ/AHFfOCLX/8zA6UavmGZI+QTuWy01l/Wru/ysJfplGami1F7u8Q== 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: tvGBglQb9bHX/t2IZe4XzUBBUKQjVw1sCUxy7XTDZ2IUH3lKERkfXhid7qyfqWwuSb2VDSVvUo29sySl4fCeNZ9yqqIp1RX6WWG90/coecI0+o6HlL/EBQFwu/NvBAmKo+KIqw9BZMMeNh0CQHwPbifOpwZgqj/Iu6Dqu23cSuaz9ATwgcXCgGBv5wKPETwY7zozcomWEazxm6ytm6A7uncCcDe9vvE7n2K1j//zU6h2839b7Ya0adZVZ3zzVkEzjBwufv0EcWvhlqkSIRXgbeZqMRpBHzkItqgOOBdYImX/hBc0+dzbWwGoR441svtgqSj7AlroPfmMAWfuhzTBKgswq8LCdNqv3fWwg1mYgtGEo+RsPq+YczI3x6CKxOSHAs0kEKbeMNJfZalup03T39CQ8tPio7se+jlGXvoNfvVokZn0sKLKFMNK3nRjooTxQJjYZxWwdCvaJ1c9ci+Vg0h+PTPekqKGpqVtH5IyDr3wQqT3626rXY95i6F7k4khl++Ohx+xdnnx9fCr7jkeClRRcr5hl+heG8EHysS8iDEjAZCEjXz+ifO7zuVG8w1hN9d39lEykB2vD6D3yHWuYlAXzufHvPM1Y8ZlybFoUWpEYUCoBw9nUmUWfElUrHkYqhmQv+QbZjWBLqdStClL8GdSRPFyNZwMD0/F3X8B5AQ= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:14.6300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cf188ad-5826-4c8e-2313-08dcf92b70b0 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB2133 X-BESS-ID: 1730324437-302901-12791-43477-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.239 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYmliZmQGYGUNTE3NTUwNAsJS 3J2NQg0dzUwijZwNLM0jzFMtXUICXZQKk2FgDegiLeQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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_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 + doc/guides/nics/ntnic.rst | 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 +++++++++++++- 8 files changed, 730 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index 63ad4d95f5..cd7d315456 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -48,6 +48,10 @@ Features - Traffic mirroring. - VLAN filtering. - Packet modification: NAT, TTL decrement, DSCP tagging +- Tunnel types: GTP. +- Encapsulation and decapsulation of GTP data. +- RX VLAN stripping via raw decap. +- TX VLAN insertion via raw encap. Limitations ~~~~~~~~~~~ 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 4cadd3169b..7b932c7cc5 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 Wed Oct 30 21:38:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147797 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 9F6C045BCC; Wed, 30 Oct 2024 22:43:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F2E9434D4; Wed, 30 Oct 2024 22:41:30 +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 D70E743476 for ; Wed, 30 Oct 2024 22:40:21 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2171.outbound.protection.outlook.com [104.47.51.171]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nhi7to6p2CUEKDNRrpu/FviB6Ltai9s39SVa6bkOTmd8tQ7KTHo8uFRll1HH9/wTHyiKVrNOoO5Dx8yedPCOmxaQ5xT+aco0WtbymwiYBkoWsSvULJ5R4zxcYR35lQ4Lms/ZCLOTmSV4MinLqlGyKSljf/p8Igy5uPBg8tTU3oy0+OTPelduIzi8nqgWkMfoOwF/rO8OezqepTG1JBySFFhLOijnBnxPuST2pBJCSAPA5sPDgvwUmw57DG6fwCjHwF72549yGFD1+JQE0ED5Vm9jqOTBEcCGRSGemyuWqTGmx/dhovoKNDRe055v8PPK9xF9tXO/MYQH0IJt4l1G7Q== 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=zsNRRSNTWx2WgB/9dGfP/Z0bRQeQCLZt4aOaCu3Xtyk=; b=dCcbaWbWv2ctlLHmt15ASQIaIeCvpsK8wEGcj+491Lu0NeutRcC9ej8H7eAdC627szSJncKgQxaMbxPsRcETB9KQdwul3VZuxKoimNWs5zjzmTlgmrcdyC8b0UrW5qDLz9E/mLwPSvzuNIaieHUKiomD9OyGdFuSnyaN1Tv8clIwgcRE21hyp8hYBqSH4FMOeDgNC2QCMxjKX8DYfkaKbK4aivflgFlzaR136h9CmLDSnQm8OgcFVfgZeTsKe8uompsi8XMwB+BxbfZPyyNH/5h5b26rZNYE04h3yJOQFj/XLndzrxufgnj9XkTfyW8aNwKkvmuqY40aLtTaemzyDQ== 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=zsNRRSNTWx2WgB/9dGfP/Z0bRQeQCLZt4aOaCu3Xtyk=; b=EFS9BrEo9pQeYQk7YiiXJ6O9Gz2taosY5ko/118bChxD4QF+Set7pTccjmZ/qh+LFy9pTsaXcWM6JePpJx4BpgFHcNZ6FqlidXSfXn4O9uuLZT83i/k8tnoBB2KmLzOJ7Mdli61yaD1drIUeo+T9mRjhTm+wVS94hTk3Xzp2a3o= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by AM7P190MB0583.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:113::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:16 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::5e) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 26/80] net/ntnic: add cat module Date: Wed, 30 Oct 2024 22:38:33 +0100 Message-ID: <20241030213940.3470062-27-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0583:EE_ X-MS-Office365-Filtering-Correlation-Id: c757881a-829b-428d-1967-08dcf92b7189 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: =?utf-8?q?Y7dcSrzp+lYIh9Rk4gs3kLmw9WtItPw?= =?utf-8?q?Ugmtd8zSfULBSCLkogZZvWbeEb48bK2q1wVZ0xSv8MDJHjsM172lqk167Jz6UKbV3?= =?utf-8?q?ATHnRRG+iQV8sC4D5XOy2Kp81qvk5dDSIFzrq08GpZNcpglyKkO45oY6znTKWOcgM?= =?utf-8?q?7pH7QkeO2zX3RPJmGQemp/eS4/UkcD4m93BAuVMmAFXE58iPhfymRuw9k1DAU7dkB?= =?utf-8?q?RNLN/Bn/CDhSsTzOnfkt/jvmUg89hfUHjSJQ28dWTrQSPiubpsX0F7fJr56g2ln3r?= =?utf-8?q?etYPirs1XIYg/gKcCMuF6+hldeMMeMx+wp72gz7YLrpKMuImJZyw7q1vtwoWKuBJf?= =?utf-8?q?CyUMDiyByyym3syAz+rYpiNdVKXy+3ewskXBFiTymEPgNaIZu6fngT724NitAkK9k?= =?utf-8?q?BZhYwOnrRezDSc6HEKoC0/7fIvIopEBFs4FSam5m8JL4IhchJHz11p3u2kEM7Ignf?= =?utf-8?q?Dk9POx1QRbDUG13/ukJ6gx6EtV1zHaZJ691LXOAH6dDVmZ/2ZV9cdolu2U+qLmje0?= =?utf-8?q?hfunQ4NdXwVm+qLrC8mwWytmk8PdWKyk51LrOj47qBM2/C5yVY5G16J6QT4/SyPa5?= =?utf-8?q?dIJPtp9ZCzPpAtJ8d3zWQIVkPAXKpxw7/Rdg7Wd0ChNLLtnaKRTrTkKgC0WtkfmnE?= =?utf-8?q?1QWeIoH85rxt+6w11lI1Pc2XJVAwBCR9YDFbBoo/ToxFP9/cQ3TsSPfqmZeuofoVy?= =?utf-8?q?904akqk87pv3q3v1IBZEnumGs01GlOzg6RzWfr29UiXi0g1ojMqZzwL6V94ctTnpT?= =?utf-8?q?OfHxyoGFS08W+ZJ1pvi0T1g13BBjvBn+ru5wAiwkUVOg/dYYMAF4/bpKpJu3wgVCJ?= =?utf-8?q?XfABpMw5IaFWKfaGR3PIsAXG2YBE+wVrm3CNhSpOdt0fL7pNLIoQsetbb+efQ4+u3?= =?utf-8?q?FurgBKi6oy7u+Ov/hWSj5fjGfSqXY7OhcUhSOjIboZPp/4cN5smvJXILYJx0KqSi0?= =?utf-8?q?wgLSj71LsVXlR7wACMyd5cgRmBF8Afu9bMPl5wXNK09pwBihOHIXIzmRXAIHV2d7L?= =?utf-8?q?4DlxFIHcSktDQs/TdfaiaeVLh/CXzjZp3bYfRPJgb6psqEF/U2+bVkislKtdbYv58?= =?utf-8?q?qy08JUgVB5AsWQ7p/988vVsQdZlUz+r26Jd/Wp0XUgjTqmVCHKxSVLtJmVjQwQscD?= =?utf-8?q?+p2WKuGXTo9HQzGbTk8j7OWieTX9xB2K9Pm3Chz7Jkr5aRADne9laN3o7oIP0qXE1?= =?utf-8?q?+ESB3/C/yM8DdBbE2ee/3m4660VlbPlj0UJ/2Xr+fZ8M+GPofXioQv0KnvKwDVuXq?= =?utf-8?q?vCGN4754H/jx+cqu6xtGLu1O/Xi0CDeUx+iAjw/MJYycoLr5qtmMKebYElNZAWGp9?= =?utf-8?q?3rV449QIjowE9ohAhWcb9vv7+gDupN/qYA=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: v9wmxLZLWCr39s21nN7tNFDACofRrjro3c6YSIOAbf97WlK5Pelp3uq1kmHihYI3eAN96MQTztHssLPZEtinuFczNU7ICM5xZ91VYB7xVsvPdAI6VO89tweQF7Gga27sJ3HIzwiW2dlQuhqqCztvIm35LAkhv4i7J7vmNkx7iQZBV1IhaylpwycRsU56U04DM2Lyc4mhE59KPEyOfU0nea5fDBmHTlgecKfG2eQa9STKSiLCaXYO90F8RFBT+Zb/O+fF644NAnqNo63U3/OIGPPM+0ItA/ZuwCw/ia+dEF0lIVw+vZ7MgaIlR9RSwDWC+4+UHfirbgFiRjgEs/UEEEyVxjKvSfbtSvgwCaxe3by/ZyixpkwGt9IogocN7c/puckpigB6obybiSF/XuDOAomlucFTrVZ7fxm1lKfpGkrxrjYUWEvkaixSji4fMIJduEtz+t55I28llKlUhZL3dMOaiGk2Jvb3qrv6vGQofJtzGTsibkTzQwyOo2o5SJbYbJ2fl0yKVlODrRNKGStyd/7YqMCApQqf1A9uqfJzLk45VaAoPHyl47xjiGrSP2xycYs41HhUtKDeQZE2Kx2WODeDYzl/5wKjU9o5cXkruF3ZEte5VblStnMbMiiFPjP8DvWQx+Tk9sWZNaBccYdMFVoumFulGOp2uPGPqHO9Bkk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:16.0519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c757881a-829b-428d-1967-08dcf92b7189 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0583 X-BESS-ID: 1730324418-312176-12713-40686-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGBpaWQGYGUNTMwjzF1CQpLc 3YMsUwycLUOMUgKcnMNMnIzMwk2dwsVak2FgD2IHwDQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 7b932c7cc5..3cfeee2c25 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 Wed Oct 30 21:38: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: 147798 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 3A67645BCC; Wed, 30 Oct 2024 22:43:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D18C434DE; Wed, 30 Oct 2024 22:41:31 +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 6BFEB4347F for ; Wed, 30 Oct 2024 22:40:22 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VJSYzWGczc0XmHaQEThx3S61VJ81yc3pSKyhGR68bCxw2DyXpwtgefyJuuFX+Gea+2PUx9dk3UlgupGhx84/qlpPFxdKkvvQbma/NHtJkbR1huHPVZ6nAH+1pTktz5cP8hcu6VQiAUXy7plWIZEGvbUimSz4BqMtF8tF22mPH6649bIVPDE5NYIJXRleI3VxtHuMA4snwn6meiL4NU1HnT694uPo40k4Jsu6+p82TLPJHCes82S+rUO/S+FyXetWa2bhzb67w97sNHYjrTLU33RCnvTt5kPeHDcEKYErWKgOEWhRWc8IufMGnT1Ohs+0KpR9AgiRlpO/Ru69qs+Lxw== 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=ms6t6X5Yx+ueKtFSt1n6wb5CHMwZMM7R0mtgxACcQQI=; b=YAmX4gIHNRnoo3Aqg5Z5DJo/rgYiNdDy5LGM3xkl2VI7P7Kj6+CEMJLPO9PSqTdXPljeopnNiI/Sz+1hUakD0V+NwiLsfMe4QFVqTrtP+6slpFZ77Au8b8jNCJJpU+l2/PXYT4KBNfhcK7FOqBI8OfjXIwaIhB8nOBuBsjVw0v5sne7bJWeTMtFpZnxvH5x+HRjnkOrdwbihkG1ab9lYxOnk/ZQ3nk67HZJbLoz0kY7DihD/xnKcpzfYffQlJx4PVol+nj4bDo0jdheI0UX5P356rCqrg0HOINoVtHa6EwkObch1cQeqon/UEnEh9S4S8aCTZ4iFDjianXt6Q1dfZg== 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=ms6t6X5Yx+ueKtFSt1n6wb5CHMwZMM7R0mtgxACcQQI=; b=bTNh7IXrHe3Kq4MWus1rgrW14qg4jsWE6PvMNvqTysuX9tOpMpPgWlB721tv0peoca6Ar+56Qp+pMzxUFNM9lQT9QIGnZgppNuOe9YGGPh/BlwQfXz14H1tHcBexXVbraTAZZMgvb4Y0p31TKVdyxD7Cj/a8IuEMUmVMk+TepJQ= Received: from DUZPR01CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::9) by AM9P190MB1217.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:264::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:17 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::eb) by DUZPR01CA0005.outlook.office365.com (2603:10a6:10:3c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 27/80] net/ntnic: add SLC LR module Date: Wed, 30 Oct 2024 22:38:34 +0100 Message-ID: <20241030213940.3470062-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM9P190MB1217:EE_ X-MS-Office365-Filtering-Correlation-Id: bcb6fb73-5e9b-4479-4e0f-08dcf92b721f 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: gZcS3LVxYA6qjYyJq2vkg9VA9yfZ335Hd4xJGVC3D4kLzh1QWAB15xo+9oMXgSlaOlLn0NpR64dgIN4Z3EnC9xBvTz3yTIp3KluRCfNQNdS0vf/QJNz/6AoflRg2hwldfLwvvsZeGsbUxu7cov653NmEaufSF6F6Vj5U158AbqPa8PjdjqUa5cndDmoyYG0uXg37l6PNDdRyFGb9A48bJZHO+0dHcW/JApeYD0/hL14Clb9/cRa0FIv6reN9Vo4RVEGtvYYofEhe2cmWtOuH9omDZ0oybmaLu9a7s9w9RNPwwDWudNHh9Fk2Q/5l47K2YV+SHWMheglJp26lVJnHnwBiTA5X+BcM6qHOrAPYMmQLBq9b8cyPUNTTz8rgIK1I1eMiEO3j/Q2fB4HmwETlXc6s/s9sMP7Z5qpewa6RDrUaFcOLyrboX+Hqk02agClBiQj40RnyzQ/p8/Sz9m18KsruqGu7oyT+IVJc18//VUECSAc4scmx+ZNELsG7pcgkujH3l26vWY5xxWU6F1FcVDysVGhJkJEhnv7vv+Je+RgB7sat2YMpaiqRviZzBlEGK2hn1j1/NJsz4tGxqmncem03ez4pbauWljghvxFqFRO3c60fl77Q60h9EGG8lC1Xx1pfJp75GLTjJEsRLefEsiKJ7spdda1aNXFb135t9N8ISfA3a/JmvOivELFnvBmYmbk5Se5kfN9/eN6QIqKuJrePDwrYCNPlN19RcpsJtDAqPBDiDXdugfxnQvv6co81RsyPASq1MSqkNxa/qSrODrkn4UTA+YTNXnktrRL+xq8a8ax9oe4lTvbiD2ctkzQCz3MEEkJUWk6QHO6Vl3ndivroQHWE9vO1BcbLULd5SF2Q6YkZDy6Uefzd2kXTlRF4iy8wLa1Ntr2nLURMLFW4dYINYl4RQsYZ8yTUW+mBFjSqKz4py1Efg/9L2/JTb4egvbN7sJkcme50swRGQZKsYL8LQD6ku1Haa3izgytYdElzKB2ZFrMPl8MCAYU56UsGWiz/Bj7LXpvYzxLiX2eKSM83ljgcuAkfWf/Trl5Aq7/3YLcM8ZWWD5UD5D/colmlYwu+pnauS4I2DNSX6MateetFHpo6DZu3A9YWC60GS/h+VyQFVwDVcyjNWUfmgN19FCgFtObIdZYZMRg3cSZCsRlbFsPKvPpk/zWLorOjQTmWV+wqG/xyfnXf6sUBFUb4gLc4eUzCLFXd0Wg0zP1mq7SN5JcOngOCexYu94MC6BRElLHreHM+vI1dIjhZN/ot5kRip3MK9q8FOJzvN6wghC0xAVfCdzmOWOmsBUaTW11ahV7yDGqWoGuP8EaCj/Ff94Jri7ToiRWAgvNZPXZa5CaJxGmBLURZu5JgdEGJU1XF09qEUbpOgJeup11vtBvKQ5hPwybYM73PxEBiL12uhw== 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: Aq13Nbz62nTj9BzMVQ9T599zeFgoGDD3ysDRuxqIJwS0OZAiaK8A7148Wivp2C+KFo3Yw/rskUdMG1KLzj4xOoxo8sQktxuU3kzMToW2vYPehdOYcdFpYCCf9ekNe9ccuudxyhuqOsxw4R0bVx2JQdE20xfB+zwNwcDeNm8xlHigqV8HLt7nk2aG6j6KdJpLbSkcw2FTWx+bqzg85JsFSYrUWJyaTSBs3Rljz6ZOfWhrCLDUUGN5KU2XsDcPbxICRceKZOPx9JFLtdDtR1fvXfNVAZ4ilRZ5Sxln/kF64sE74wq6HeQETS8ILi3tdGEPTO00ZU9tXxBHdNz4viOWxkVTSUbNjPzCNvzhBjNe6cBUPv+Col4K4LCWoWdCwv4BTKf7NeOtJmetdleTUq0baopugnphPOBV18SchVPIbjCtk7EocEGt0NRyWwUtGc3QdgH9aAdS1EsfffZSS9Ts0IFrYdbCJaA2NKG95EQXsRiYxiEjPYhIbmSEP8VBvE7RKsKz4KTGK79KcN8LJewdXCSmGejqyobyT5Axxw5VdAetRyjmqVZTIcDeeUE8iQ4rwzzeVcvDLsUOLfSzNiHSHdz8c2II3NkCh8/mLPx/eNnSmaXl8KYyHj5NJ11NFeklC1cjC1MbwoqBaZucVOqFMld0vt/ZJufGT00Djg/b8m4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:16.9425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcb6fb73-5e9b-4479-4e0f-08dcf92b721f X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1217 X-BESS-ID: 1730324419-302901-12794-43463-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGBubmQGYGUDQp2cLAzCzZzM QgycA82dg8zdQy2czMyCTN0jTJ1CLJUKk2FgAoWJH5QgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 3cfeee2c25..4a5bcc04cf 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 Wed Oct 30 21:38: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: 147799 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 CD4BB45BCC; Wed, 30 Oct 2024 22:43:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6A05434DC; Wed, 30 Oct 2024 22:41: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 3D2D04347F for ; Wed, 30 Oct 2024 22:40:23 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SRYEFxT6zjD99zMETaRhB9ytj4fUEAijaq1VZekvrtGmamdD0wwTSOqo+gosYN3VEd7L5UrBQ+xZ4ZkKPzZUzU8RNebTkfBUgWuY1dVYLUyEUat6zyxTLJo5VSAE38tcsHBo8RkE34bJL58uRRtylB6131+/38/Uy4yXkmYrx/wnr4MMVfScV9YLcLJHGN+OQZOtNDYmJnDPg0WPnPtEEM0bgWkXjlpPWBYubXYgMdp2yxGnxunf/bv6eUioCllCywyJy96eInu5J7mEXWjNhUmO1DPzNsQgQILFs3Lt7a3fxAZCCkJaWivDWoxvGv5ZkRZtY3t4ubl5Z1yL9eN6oA== 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=mgbMScIysJ1Z/fOe03JBtsFyfCKo9pkc1NEv5skx+JI=; b=D1MXwtm9EyClRFbEOnsfNqyA+xlWuvKX72ZYvLEppLJ5v03qJCuDKitJRFDOr/6DO3THW8+3eSMV5RusqC8zHqg4VcBgleZ6WBvfsaFtLvwtIz2wbMHoQwYSGbZNR2gP+G6ulE1NuxwU0nFUCU55UP1xZjVm0RqPjIc3uNcvvIM63DP/Xbrz9/UnPuYQ1t0hbxEHofYqacTBghmRcydD1pAjBA8Xmi+SpwHrLudgPHZlIr/sCSs8TBofEFYZ0JV1heDx0Hx3Fg43zMsW1ub8uCebR7gLAE/8eZQBXwB26NW+SvljXvUjvOT7LKGC2Pbb30Gz2cwzcmB6zKv04XwPJA== 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=mgbMScIysJ1Z/fOe03JBtsFyfCKo9pkc1NEv5skx+JI=; b=MIaRs1Nj5SJQogINkucwc3ndm7pxH3pPOQQFZmZBiZmqBDd/6srAceQuzfDDxwkfoYz9csnnjNSMPq2XStOz3WF+6yXP7M4p7VL8ythnTfXlX/QMdef1dx0OMYVLyFGjJB/EtIwzTnf47ypZz1tGIa5MgWLNNHANfmadqiVc94E= Received: from DUZPR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::15) by PA4P190MB1087.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:102::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:18 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::e0) by DUZPR01CA0003.outlook.office365.com (2603:10a6:10:3c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 28/80] net/ntnic: add PDB module Date: Wed, 30 Oct 2024 22:38:35 +0100 Message-ID: <20241030213940.3470062-29-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1087:EE_ X-MS-Office365-Filtering-Correlation-Id: ec8dec68-f9ba-43ae-d1b1-08dcf92b72a4 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: wmzC59/KwKJBKq7YeR46QaNJaxzWuLcssKqNbin3NJCwxgUmiZiz14VRVDhikYDuaXr3CnmSWKg6ApNHSQLsFYldP9J31AY8U2/sb+OAIWInE4kBagY9nySNKSsQXKz+Xs96cc33+wgv0pozyJiOWTw5KcdYb0FTrATq7ZFp2of5U8VI8ijbKyiVeWaguFVArO6Ar3EPoFEMWyjjGgIsN8mIe27qyivTcGgZhRtwTX5N2myd4h/D5b+tb6zy84XARbT2cW5h1kTW2VVIL+IydJn8bMUSTtx4M474m29BRKr0yVt0lqU5wZJF39G1N4N0qrFOBHdA9HSKK1Pg+L5xyl+LmOPGqwFaxIiK+q3ukk0DGDeFuy6TU/9OkjhzgLBwjPMG2+c7L3eoRrE8uPI9gAtjjsa/QHqaB/vNcdV9/awXBEzS8A/7AZysvyx/OhMgL7385aQ4Qv/iuDfSOlzd7k3IameOOkp/0sGq3Q3vkrPyM88MFr6xFLmQhCS1lrWU82QGVVMHoLCYluWCRmnkp+CJIz2M5kHVFPL3W/8ZRt+fRUHjQVDff1RlD0l8kS747/+JgtqSfsSJHLtNZLKuGGWj1yvZyufZ5rPBusiBubG8HVHYp3ee6G/d8ed9LOO/wTyMsl0P47tvhFicaOpusjyJ4eGeg3vA9vUcJZRk/cjCtpQJeFbPDUBbsMDNy9TC+61na3Dq9OwoPIzy+Tf7Ov4fcvUsd8dQe23mmlgbrBaxImkrjvaz40+COMLH91BsBKDDVCDWwHhCsxymrA+Ux+x/0btjpXFtsCTpWX0z6VA5pceyzov/0md03GlmNqwlgfmgJutrM8zA2VWuHM+2VWfgVNa0yUnAkVMqE0ji0lmCWOatGGlMksOh46ScSHvW9+Iie4VS6lgdIr9ai9gzWyDj3Zp7mlqPubB2EMB1N05cIyJljMLtyfrq3TdxtT2RPaiEQzJ1B0Aec0v5rG1qbakyKFEuki7yJt0Zam7hIoLlE0RqH5HKlyZfs7P0jrGaNQ7CYUF4Yw9B3VlcthrDHFT7gPIH5gMyLot8dUkh7a7pdz4JQK/qKQiMOuMctcIO0pMHLurP/Ls0Bfgj7+yyN7z4JO8suGIzzTDSmkBUwSa3scnyXTJjKj26h3ImlhEmQsXyF1I1rZj4IhTHeuB4cwArZeuYxJ/QmkoMh7wW8UclZQHkVjj66nIJ3WA1espog0r6lrjq6BQlobHB+5fFWEfc8DkE0V4U0fJ4ZKWqf1cRy6w+waM7zOqcNLmLFcT5bmkWCcvEMXs/TkFxFUEZ6B3JxCZLoc76NTKYFebxhdNdtYIE704Wz/FLFCMgSQinJdpWPq/BDJy7adfhmE4Hv6s0MKENnKntlBS85Zt4KlOIR9fMyr8iTUPISV67V3yCB9/Mj1bohzXcAgW/D4X70w== 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: mQAQ2KeLrBX915agXxbeiINcpv+HXE9pID5k6g53UH0FgINpyOBoD9dr6MJHmPRc9vyh2XOAZFIEKunq/IHh7R8tpfGnswR/94nXJ2PaeLCm1L2YIx+B5lL3DN03dkxuZCFGxmzhJaNs6batQg7uuB0PMtHvXH8erxDWiJfRIJAL5SMiW1zsjAvWaBLHT/rrZmwMYrNhMl28lRfxG1qAizu/wsxF81YbucixvdlfdIm+b45ZWcv8xPfMlXjzw7Vhv5ypKMy+4H4d7zNsUyQyIH0Q6OvKjXTahBBD6FHgR3Vcd3TbGQWrpiXvv3cLkFcbfUlKihYNMUDuVrb1bFc3y14dVwAUk4pKz1JnB7ALebenMXgxD1IFJhy1tjD6buyobAu+lV/vSISxDccmP6z4FxOhQtNBrRTY2sHHV4Im69L4/sYzOph9CJRZRHo2KtfV90uFhUfsdPQbQR9EOIHV7icLXakvDYDCMZnFds2bKDpKYCc9ldhDpvAD9aV7br6KlxsvH1rJxNpoaeAp+D/onozTpJGgWq/rr6HptD/0ivD50rzmXZjbagJEUrFO0h5mFAm3JPwyKWVHVnwXKj/hDZcyQhL1hmjkWXo28t5Y9mECcrbTIbtw7CDk0JnpgHRIdnYFsTWnvCDTNU03eo36JH2QMVFTzG1o4705pQmlRXg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:17.9113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec8dec68-f9ba-43ae-d1b1-08dcf92b72a4 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1087 X-BESS-ID: 1730324419-302901-12799-43464-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYmZoZAVgZQMNnC1MTAzMw82T jZzMTIzMg0MTUxLcUsLdHEzCTJwNJYqTYWAEXANOVBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 4a5bcc04cf..7033674270 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 Wed Oct 30 21:38: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: 147800 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 BAB6D45BCC; Wed, 30 Oct 2024 22:43:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB6A1434A1; Wed, 30 Oct 2024 22:41:33 +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 DEC2F43496 for ; Wed, 30 Oct 2024 22:40:25 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2043.outbound.protection.outlook.com [104.47.11.43]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jqzHLSQ6D9hNr/ekudD/YIKK+bFKaYxuQdjG/puEHt/ynZ9yNnpVg/4Cu6byU7Vj9vGAQ+DwDUHD4ahImrQ1iVoKwzzzu7pDprabd5eQAWrmzvUZA1V9cj6pe57Idy3hk08TLV1uq//mgViHLPEsYR5XH2vsET5Ppnwbsw6suoOYCN097R7634tpC5w1teTbUWxBiSsDQbFepybfhbFo6Rn/t9BW9yDl2dOVPXTq3U2EcrkAoNzjOQQIEjNZJf8hhmB9MdYv9Qd4r9aepBWEqVUf+gl/S7xUEVJjfULLgKXZDEXdVs+K/zRK8s2C3b84LjOSQ0h0jgtYeUz8O7wcKQ== 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=AY30D/dnV5RWf9jNe+lEiMiqWwx7n9nZYGx5X1uB670=; b=t9O1reEmlVlKRg3ZrFwVUsbp9uuiWEHX7/MTD8P74ox9tA290x3ZMiF6DrmKel7k4KDBYKReaWd+gHWrRRPeZ4YRHypKy3HQwyAD7Pj3aa1q85+9WUUePeDJFaYNJpQblhKOWznT4v6O+tBWScJ//uWJpVFRadYpN2qf2gTqZW8eNS6m9QoHng1yjKUCaq672IhdbDIR0ldGTICqUqcxmbUYOsb/pS/1p6Pnxdy0tGNdshF+yr6nzhM+Rgrq8opeccMbnt2F2xhVyqZKBC8YPtfvbQeV/Tvzw0GzrPSWWag7rcHtS85LqGD8Oqw3r3o37i2nVBonnrP5C+fazsIINw== 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=AY30D/dnV5RWf9jNe+lEiMiqWwx7n9nZYGx5X1uB670=; b=Vs4x9kZEJOEvxO13aLQJPAnD5BBNnwGDuPmKUl4IOcUBoCMuoVVENRtmL0nDjWvKQj2r7P2ylXZlbNVEr4J7AMfp5IVOxWdbphyrsYVV384jRTeDMsU4YhkghfZCxdGmr/7VSdNE9DhWylTzVEDwURJjQiWd7FxbJRn35f2rU7Q= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by VI1P190MB0782.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:122::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.23; Wed, 30 Oct 2024 21:40:19 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::1) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 29/80] net/ntnic: add QSL module Date: Wed, 30 Oct 2024 22:38:36 +0100 Message-ID: <20241030213940.3470062-30-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|VI1P190MB0782:EE_ X-MS-Office365-Filtering-Correlation-Id: 531a47f3-fb5a-462e-68b8-08dcf92b733d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: HZzQoGHG7V+PDXgsKxKxXG+N6nd0YRNrGBYAmdhaE/aqKGIcHo2bFcOgQM+c53fF8EZkhmncWRfkDXjTviP6RZQ2+5zHEbqqVgmlZRDe1BLX9QotgoO9hryq9+wZl0M6TJqisOzpGz2fGllcGy2RKkqL1Dw7wzWeWDAAm1TTf3Ut80Iliquv3W1OCKQNMYHMRhHBKvs9R2m9WbN16X00IOX8WeRl8ILINcAP8bMM5ZokGCo9GK3lLgCHf/+z3gSzuI/KTpGAOEYzYSAwbtAPtiDVrDYbFuzDGU5iRvWjpp1UnyxVBM8KLj3POI8uahE+31zY0W9xQi/d0txV8XakWUxYKNw9LYMb0nrTtiOZV5ME6TmPdEllOKjkaskHy0mUrqmJQS4TYTsuSMWOH3nIc8EJQUBzbryo9NEudvJe6q8f7ari9s/g14ywFBFs1HWrFtapJw4ctMwBhP+jB4Av/btQLUjn/JD95NTmpY1p18P8U1YHtJ/j3i8roReFmdTfyg3PUEYGFYg7n8qI4mlp1b0PiX8fN+xA0HeNdGh5kkFV3/YUYjulr6/ERbcTzT9sk+pxQk6ef57+PFxBbeUGVZawhblQB3txK1bnxDwy28+xc4R9DMOnQBymW2liU6s8WgzuNGw8XuseGTt3pxsR94Q8G1FpoOXE4vTmtpNRsBJkRyPlIXIqJD9XRH/X2j7lo+6vZW9Zd8u7D7P6XWH0oF+aYaS6Rv5f2/Dt/8VqExdbHiao1A99oqBBGoUQPr0h40ntPOvyrHsc2UpqCredTGMcBAtl7YgmmRGpIs+6z8BJDASyBNQe8p5inCDmArUy4Rrm6CzCuMi30nI71C458Eqsj5LRWRFuafvMVay8kZsztV9YI8ea1w/vW/F/MpUZ3t6rEvgwhvfwHKrk3rmtQ9aW3RAIaxxPVZh43MbBtMvGzQnXnorEgzT7UMKTHZcW53Ay4bLFBLN7OGSk3fsfdRVMwfn8jkm6vH+NWUZ1+dajh4gJ2mBWge3bP54oRlhNAlbF2+ZoqbKa3ajAB7MRC4lEtL2QOb4x+03/BbrDPDLK4oZhAqgIVophQVIcmT3Vw0hKCcE3y27BdZLOVcl8Ge9H8bNX7oMb5QCqDJ8m5wN6fqhZLdlvLEPVxHvyvDa/9a2kDzhtPGvH2QC3KjIXcSX01V1G9klT0NMBw1IXDCeqRy55Yd7M2m/3fwWea9Kma6MKGpthjMDFbZj4zQNarsG360ETCZ3mDcZUPwiOJAXX7JvqG09sR2il6WIsAa4wEtnJlhSmrTIMBgp/QVkAvUSw7nVd66zmW5glDjYRT/8hc0mRdaDr80eCqfs5GrHENaFyIrksL+Ix57d54pR9RBUMz8WTnAI68j8Z8MLvD5dCcntTy+/yQZwlvGz0le0dXXWkdePbA8KhZthKczAJIQ== 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)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZGn454967jQQjMyG4g8otHnXV7x7nonfYF91RkD7hFEN6mmk2yCJzJxqvrRGt9QPIFSkYxIAr9Pm/HEHQ489uPKEXNUtRv0C8HQSH3vbx2lz6/HXqxaLDCiZM4wsM2yEyjRE72JZ57j0RFlRZTOe4W18LFPzf2vX3yE0lE6HZ/bzg8sFB+YLfF/Tm7SJIUC4/5aTA2VYSaKBXsPFY/GcnRoekhcS/2++c2ijz4DfFnceLxwLHPF+Sae8MEYGKzvl+dzLGWfl6BDiABFywJ4d13qvaqVQRD26trVF4Xkj+wqzHTXSRFdKeOpYhaWmxL6g8I8hqUThNaBgSwA9+/BlMwLO6gJTIRZ+zBZp3/EsMIg49gQOPnVnQZyggUJhykkaCvrTawJEuenlcqu9SgNr2nHI9cLZF/O7fASVcsqxEPseAaQUUVE0+IvACK/Xdtun61sD3RfWpanQ16PoWGcDGdZvOkMFA/NnScQ0/f9hqVDZ31G5ZllAgjSjJkKF76uktPCU1okzmELBxDlDuTq9Hr42OCTQoTgJ/+w+Pn7dghd1YfGmRCTyreScn9a49MTFEM8Hhlz3Re5UhPdx5jF0B+sHpebiGJPSrFCnYCAIU8TPc6yTgFYfPtAOvFQxiL7K6rMrRTUm7nr0bw3ogHvTg4HJZKaurOjE6dqOqkcF3Bo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:18.9113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 531a47f3-fb5a-462e-68b8-08dcf92b733d X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1P190MB0782 X-BESS-ID: 1730324422-302901-12794-43465-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.43 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbmBiYWQGYGUNQsMdnMwCQxyd TMNNUs0dLCxNDCMtky2TDNINHE3NDITKk2FgB446EaQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 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 4bd68c572b..22d7905c62 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -104,11 +104,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)", @@ -346,6 +387,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 @@ -546,6 +599,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 7033674270..a5b15bc281 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 Wed Oct 30 21:38: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: 147793 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 388CC45BCC; Wed, 30 Oct 2024 22:43:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 426A8434AF; Wed, 30 Oct 2024 22:41:25 +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 9B08F434BA for ; Wed, 30 Oct 2024 22:40:29 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BpMukBkkIQn6IP/EYsBGFacKVitPnb62ZQk4Xd3aeIuSgyROjQirsxfASrfUj4QD2SZCUGsfwvG4bTIYhmPhZxKUf5XKXMg0xehuhmtklbaTq5XvleOc4m30ALXYbmhoo/tFR368syS+/5Gwlt7m0uC9yggXZgn159nWcjGAXWgFKFh/Yu+ca142kCts/uDxCI3WPRBsRfZO5BuQ1ePq9ILE9X/1Yi76cvHrd1WWDvYNyy7zJCCFgmQmsh09mJiUUKsE/87XH2oDs8e8mvmksZwHtWRHgkbYZZYDuAJI0Q3dfiv2i8/cCjwsJLlG2bJypy40VR2IYaHkaji/lvX8Ow== 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=+eHVJERZ2G2t8+z67UT8FXxiRJ1A7VPDrmLuYy+Zh8U=; b=n5A2mucFJ2xnESPhhHmuC7DCo+TsPsljylbH5RRt0gox0qsFxw1h/2ShM8ldTnC6O6l51889Xb87DR1NiGFvgyBrgo9MqX0azLK13oeEzo4dt1nLe1Dqz2nitOer/tzMdQSVnhR03xearQzQ/3VFXioITHGgysl7LxHV6zUJRiN/m8zsBAHxrLp6iwt7PVJrqZ5NerzfGIGd05xvSjycxdtP7W9S3YlbrNDYLHR4ulx8MUntWXUqm2S66RhVuo4211t8V+sUz7y13gWBfnVw2T0yoOG5zMgIvk3kYQPwavcUcZX24R2n8nKgs7M+ggj6CM3OUR1sCvFAHsxDd7CBKg== 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=+eHVJERZ2G2t8+z67UT8FXxiRJ1A7VPDrmLuYy+Zh8U=; b=AVDLMCGZPDuLP72PIUQiGkt87wfFmiCod8xtoVEZSYvn9RNvCv1Dn/FRYXj37Pi/K2mDPHCXh1sae/cdwKfyhfSrs8UOxE246WC4VhTNpMHtzUttyKiVlaqme4CW5l+USPRWr2nwsaCeoKHhyqGEK0nFdChvxhTpU89x1DyxVWk= Received: from DUZPR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::13) by GVXP190MB2094.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1b5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:20 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::a8) by DUZPR01CA0006.outlook.office365.com (2603:10a6:10:3c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 30/80] net/ntnic: add KM module Date: Wed, 30 Oct 2024 22:38:37 +0100 Message-ID: <20241030213940.3470062-31-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB2094:EE_ X-MS-Office365-Filtering-Correlation-Id: 36d07eb3-28f7-4593-4c32-08dcf92b7403 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: sTnDYsWmU8LvCX0mmP/ZwsW6kIFoApRF0l3g9wxnwT/Xumsp13hCGBIGpFvU2Cqbpfjx4//9bbjXkYsBoMxQyB4nSDjCWwYlcvu3KJGH53OnYSvj7Tw1vfMLu4stCOFRgGspxmCB7HS+fNpFLC3LktXBSrrNoEhDymv+uNS/6Ukh8VpJTMnLlmXQJcZJHRhctUORHW9o+c3lJ/mxS+NkqxoM/CV1B95pCdTZSl6IyVnnQqfOI64Gseb67gEWPV55G+1Heqo/iMXxQ30lj3yjzsDCz8wkDKv4Vn+ItyRfvWXiAfYqKU77k1pEKytvua/yGB+Y9quPauIiVJsPASQ5s4rsttwh3xqbHqQjWQnQi5QXTd7B+nGQW+ZJEc4+7FXEU83+rKdxB6BEAK4B5VpHqG6fRm/0D723nTSZcJgTytwNgsMBY0tQuMfv0qh/qHp9D549mv94lY8CSd8hfnlezXIJkS01LWyh5kLm+QGDmmxnJ/fQfAFNQcCvaaAcRMSg4RnYCbhyguKj8/5n5bA5BMa8eOf6kDi44BF+t+PadhXv/jsilLu4Qdr4mYzYVSkt4cQAE94E7O0lP8G+ljnIHF/UE2MBc/SoDdOXmBVzMIlnFcXdXoqaLVk4lJj1uNdrFhHxHXy4OJT+RgFn7DUqa29Cknpdyy6fr/VC8HmrN4URIHfG/RPCZ5SQ1G00XOT0OHHdMenl06fY67cwMkgaJmr74JzdeOSzbKJ+NHnBgEtHquyk1u3dGwLYyOBgRPsZR1CfuqGGYMn32Vno/Q6nToZXnL5WLXOztvRzXiTGlK/jhe6pA6SeV150td1sGdg4dGtv6nu2JfKJuB+fJTJOFhaaN5Om8NKBg7ch+KHHsnOEKQ+fuhBoKx2V/8NENclAPCjHyyJc+NSyzWgdxOm5AMrswh9fqzJ8XIFS6H0IPCa1yNzM+qVeb1aT3kWQTviSn6aaFw6Jv1HgY+zxqcp/QXOJd9CXH7T9RoOXFtkXo0jJYj3/jD/HtYN/0Kvt8tPbdcx54i5CSz8dZ0vxhDm3Lud8MsVhq7IONJT2xLRa6FzvAVKXORBIj8ohcXOULM/Yhy4NrDRunsx8ybeq+8ZxruRxDc571oAx8iTugAGYL+HccJYzIE+6nhWv3MA8M+RAdN9b86/WlaNRzG2e1uBQw3obWKRDa8M4wCns0AjTUsL5JYjhcCNEnBFzu8qsa8SifbViJjJN9qiyUHqBqtpaAK/xMKZqJ0MA2JtMcn0afY1dMAOf21HytLGkb0jY9gG9bHMpt3O676Tw9Lfzfbb2FVXl1m8yNXUnNCvgWM4B2ZWewiDpHhMI/rrtLMVhDQxkQ3oHsJHOsyJ4vZ1ZKN8hP3wfJNT5oFMi7jlQecsMpmAV/ArbvDIUs8ICMYzMy202fF64VqcMR34shRDUKyC5xg== 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: BNeG3lbg9/PrT7+SIMa3U2yFgeQvITxrG3tlXelGp/bqlS/J+j9CUyKBpeVuOn4wZYvr6N8daLZdkp9mcakTCa7DVBcE5jxHVqc4JGeS0UEEFceggeiTuiY06hQaiSqYUkCs01cBvNi79HjYUAkfrwucKbZcGxbqXiFLsBtEEi96t2pd5QpxyBDux8Ml3l6Jto9mfUi/R1m+PJZtC0lIeQ3+Z/2ZY03i0KrPY22l9rC+RaqxUmYpCSpBT/cbKAPvmcaYtE0JdTEey0t68rvja6bIL8/bxivjkt9M5ia91n4rEoTwpTRfEcV6qEzaLuyMPfGLM1QZ/dDNlsWtSCW0xNxseMcKCIHF3Bn0MssupZ7AK2q0XR5paa46K/gBNeNitUB7CcXtxPgr9ONOLenD0/6yJSWgTTlztfhBzT/V60mBcLzCjaS0YDARVz4ubEddG3EHlmieM/SF2gYvcMZiJf250jerJTXrQ3YXaDmbyH1Er1ti+AFKgEDMMPi/GM1wbnLj6PvAZQ3SZ1Z81vvOA78piSa7xzCenJiQcMDcKUNF02bZVvqD5wnoG2UTxRLANxr77ZvMs2VH4lKHiYKyrg/iqa8E8OiMFkNWqgbeuZavgtTM0e2KfOViQRfNXTOM2hrKuNTJTPNMClkNIlfOwRO/7bMv5Dyn2QmDuOhQHqY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:20.2082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36d07eb3-28f7-4593-4c32-08dcf92b7403 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2094 X-BESS-ID: 1730324424-302901-12798-43466-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYmBgamQGYGUNTAwszE0NTc2M I40cQo1cDUzNI4ydQCKGpkmWJmbmqoVBsLAE7URLdCAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_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 --- doc/guides/nics/ntnic.rst | 2 + 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 +++ 8 files changed, 2026 insertions(+), 29 deletions(-) diff --git a/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index cd7d315456..ed306e05b5 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -52,6 +52,8 @@ Features - Encapsulation and decapsulation of GTP data. - RX VLAN stripping via raw decap. - TX VLAN insertion via raw encap. +- CAM and TCAM based matching. +- Exact match of 140 million flows and policies. Limitations ~~~~~~~~~~~ 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 a5b15bc281..bf6cbcf37d 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 Wed Oct 30 21:38: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: 147794 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 EF95A45BCC; Wed, 30 Oct 2024 22:43:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B898F43491; Wed, 30 Oct 2024 22:41: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 03D0A43499 for ; Wed, 30 Oct 2024 22:40:29 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2113.outbound.protection.outlook.com [104.47.11.113]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zWn4/3KpoZF7IQHx+pmTddfjdDZIkncK6v6VK0mcXAzF27VJ7aLcdSS4WgqZvbX6iGyXFMsQb1289BjZBk9X/hi20z5OYFeAamRiGEDm6PtwS8VIZkUV//dhJdkI42XaOwu9N8ixQOwY2nYoNvConsT4qp6GQlRxXKXRPcn3fiABRj4jLrrq2DVITyNZlikdplbMjeR3OdNMjsYjE3qD84viDkQ+c0iwFMXAgLVny9HXyZtVtMrYqyjVa+foBlCDjXgQTrZ1095wjQ8+avDSH01DHy4efCqW+tnVytAT61MMcJSQ3g7onBYvk+JHmR3RHy/XeCwudVDa+Q48AtEXdQ== 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=ITOBh+UubjGTSXiABxrdAhHWJDMgFao32dLqNg7MYIM=; b=dvJss7vQn0yXhbK58ZUSEIJTvXZcHtQ3YUsQrXeULDk4kDhVhutDC10VHyNAyzC7HxdmJXC6QQC+dJlKj/ympd4N/IzI8Xov0RhcG6AqdckOF4jqEUwOubyxdHcASub1FA3+9sCUVqK8V3WNTbsUe4HNLr86hJNR8DZ/vMsMlPAeXPzxVLlEfICd+sdoJ6qJffUMPZ1dj2WoNz7d1o0bQuY5eSVCsXVGoBVMhO6H64VFyQSGSwMReE3hAs3ZgOsqUOgYTLrAXh9ge9T5z4IkcYuULpcuwiTNv+WHr220jxMraV7z5Ec/z3rXsdWapBfmGz/gkaspu8qJo5cugSS+UA== 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=ITOBh+UubjGTSXiABxrdAhHWJDMgFao32dLqNg7MYIM=; b=bUh5RW0IZw2XzjBP+Phz8ysv3NWf38nYbQ3CC8hwqu3OHR3oIL6XRyNP4rs+eKOGmj2dms6H+e5pIHKOxMc/0Vmtr90OS+RNOWRBkzNiEhJnvZl34JQ9jSKYo9SGR3f12Ov0b0FlgDU1uojjszN1R11TMQbxd4g6tgjaKMYRPqI= Received: from DUZPR01CA0010.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::12) by DB9P190MB1987.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:39a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:21 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::c1) by DUZPR01CA0010.outlook.office365.com (2603:10a6:10:3c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 31/80] net/ntnic: add hash API Date: Wed, 30 Oct 2024 22:38:38 +0100 Message-ID: <20241030213940.3470062-32-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB9P190MB1987:EE_ X-MS-Office365-Filtering-Correlation-Id: 26354dd2-9026-47ae-6aed-08dcf92b74c4 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: SjgYAzTAyWfZa1Tljuc6rzelaJiB7p8UxLn4niR6gNpftdSZ/PEXy3hYqnfRPxbryqGlHxAx+esxcQUqPFUkmrmxFTyAwm9MUMOKJvRm9eZMRGPr/PSk7yV58T2C3eJ1xTg5xyX3mZw2CsyG6IVCmw5OuiaKy17zLCG9IJLKmpLNczYVYjNKzjdrDEZ4zVWn3qCRbvCtcWbgiZkftVriQgbmOLjEc90nUrut2i00Fpl5pvjJmqxdGGtctlRRNvZGehrcGrLWKhl+WIcKj4EwR0WUQ2sjFLpSOHI1GwgwgXpA1jYNSuIXJv7sieZjA9Nybuqy3t1qG5CNZE4r/0WeaRoVOLH5ufeBQwF0skUZo+B37Hc8wRustQqcwkEG8d9mQeLMcMCi3NBbR5GHhMiSJ0XUz6XAAgYFHp+XSI77tMk/b77a4E6nN71iLRmG/211qnWlLMt6V83IGzHlD9JEA+y1FPytI3HX6TarRSwXL8/Cz3XL3molYkQsCE5JKqIZtD07I2luLpoUKSChVJPbnWqD2+kN7VvJ9/L8yC1JxB5GcYk6io9h+GlxHpPAs4MWnKO/ntQPbcG98qSWQ9vJTX1l3P45Nqh+st0yP9PHOsuktZOQyGxJK1dxfvVYwd/MgGWTv/xitelX6TTpGZThI1UHvDVSTiBvUMkUGiU1Kik/dEoD9FzSt6iDE8Wi8ShMrOj8KpFVUrdWaoM13eM+ApU13neljgfYPesgaKyperCT5OvFvA/a1rK4KTDp7jxUeB0oVTxDiJ/NSAT+V/hwmdveymglxc257XTYkl9TrxwEVi6UDfvP2AqPmpRAXF28qGxUc9w1CheOta6QUrWAzJkXl2uozjrZyWk3bUYAiRdny2l2/RxqLxKBFZYUPkQSw/MJ3JMSrl3ktF7yqumJwnufid2oNw9fV6LrWxpIfYWEqWRqqlcIr1adeu2f+og/lf9ZC9geAO6rQSeugEkD4lO+TUIkndbDREslw+ZaVMOVInY/Cnv8cFaHyh4cWyJO/khM2M2dBZL9rYDWUpHp7LV0ny8SD1YjlRBEMOXIg844m0cFYVAirbU9gQ832X4/av9Mz+ycupBbWpGc45rKrrlYtetcohQva/zSimcO3afhMM3+vIs3oKQY5yMe7GTSzDGUe8RmvhMTWf2FCLayYv/Y4RsdjEipLff6YcE4ddjoY7ICPe7Neim16WrloPjY8xKlfKjqEG/I4lfE6mR6bsYphLWlCjq4E8DQx2qW56HblYt2HoQgRezhsH90bgXp/RsBDYc5V4Tgk4zWPQELtoMhg294dVpJ/SujQw/hPKfQ4wddwVq3fZgYJ22/UipQGErTLLnYDIkPMxxJkiVegRqx2viZQupsDVyqtHe3kxQFqoqdvzVkRdxdfc2KYf05zL8/2Z1BLuYCbcSey4greQ== 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: i2nDhjU171yK+RDObOjQC0MSbNFEZuch6NubvQbFTt26soUDKCQqAO9sh+UnLWXCIVgE3+JOqiEo1Sv51FHZwHEWFwCzYva3Al2K2y8oRpccwv9dD/vvx1Urj0zR4RH1E48YRAgDgioUtEb6eecSEG8w6wgclKkQv4xCMb0KCB5N+hp7TDx1PyOgtjQ2Y3qVVu/t0E0csjjp7CBcYhPrZrEqyVYWS6n7EhdAaM93ivaanYBIAnjF4KmHIWFKRg2GpwxwTK0AVprASIxskwncWOT2kBJPL72bmKZNiWYYMUhcwi7Np/wF/MiEtIgVBgfwh6knEtmjAhfuddcvA7rCS1EGsZbGMmP2RLTmxqsQG6WPLFJdmmpwkvWSV1pawK4vh5Z+5e2w7gFW7YQvdsrZ0uArpImXhGpACxChmb4xPdnFdxa7D1luBEzgUxJmw2AFb54I2fpdSYQz83j8GD0EO8yaaLyl8YvEenwCsLrie8HYUoi4zyb3tjReQ1+DyiPeAMA/oWQVNJ1buNHiy/+AFlHO6jzzsyJcQIW20iOjXN3wVRBtlOndpQ3N85WCeNDIBxNYhkyWjcewBtWgtUbzsnqzl6kb7Godb12dojnjsRcoUokDxDNDooqa6Kcs758wJH/68Q5vct/9dxCKGs4DJNaAXkJdHyfcUJgdBeFZL8U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:21.4738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26354dd2-9026-47ae-6aed-08dcf92b74c4 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1987 X-BESS-ID: 1730324424-304433-12632-44624-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYWFgYGQGYGUDTZIC3ZwtTEKN nIwMDY1MAk1czU1MzIMtUgLdXQNMXCQqk2FgB+htfVQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 --- doc/guides/nics/ntnic.rst | 2 + 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 | 846 +++++++++++++++++- .../profile_inline/flow_api_profile_inline.h | 4 + drivers/net/ntnic/ntnic_mod_reg.h | 4 + 16 files changed, 1704 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index ed306e05b5..f2cb7a362a 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -54,6 +54,8 @@ Features - TX VLAN insertion via raw encap. - CAM and TCAM based matching. - Exact match of 140 million flows and policies. +- Tunnel HW offload: Packet type, inner/outer RSS, IP and UDP checksum + verification. Limitations ~~~~~~~~~~~ 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 22d7905c62..577b1c83b5 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" @@ -10,6 +12,11 @@ #include "flow_api.h" #include "flow_filter.h" +#define RSS_TO_STRING(name) \ + { \ + name, #name \ + } + const char *dbg_res_descr[] = { /* RES_QUEUE */ "RES_QUEUE", /* RES_CAT_CFN */ "RES_CAT_CFN", @@ -773,6 +780,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 bf6cbcf37d..8ba100edd7 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,122 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n return NULL; } +/* + * 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 +2884,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 +2956,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 +3157,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 +3836,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 Wed Oct 30 21:38: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: 147792 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 2D27545BCC; Wed, 30 Oct 2024 22:42:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37B524349F; Wed, 30 Oct 2024 22:41:24 +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 38A0A434A9 for ; Wed, 30 Oct 2024 22:40:28 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2173.outbound.protection.outlook.com [104.47.51.173]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fjdmik9AExx+CvXUt5yi8YbT1pjgTrHcEOIs4KnRgrrCgd6ajIX6cSTpjRKhfdJkOm/ajNDLsDFUTnzRr9tdWHSM0DjChauabgDZl3x2MXsop203wq2o9aFp4+L3l0IWCBQ8u+uB8YblcQEHPHMgE6kg/CPO7LZzEbNtewRo1kK9aPcCbls6EAzHc4ddksYbtzfwiE9VCH+UGVAVjSG5fIgT9JbkovlUmQMGDBSFaBOx83lawBnnrAn7IUi55RdtcxyAZIyF5Kga2wbjmoFwcAsvYSGONWg2ifERpSTTWQWjJiUA8K1RqT6EOo0DuPl2ygI9RrQMwfownD+U07bqSw== 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=TnEJyP7zqNDJFKkNrc8+gbI2nEFZlzvS8uTOBjLYtNw=; b=uzw+PKB4XuKgQP5mPsxzy0DAbbo2c/Wilbv9JDNASI4t+1rFvmBxUVeohltAkfEq/yhnuOAzpAZUOyFJNQiw9m++4jYMeXU5I6cazX26Qst+BeARWMQfCVKZvLrwa3VRycaPd5ANHYLfWFGa5mQK9uTvNUtPCr5PqPsskbgWWZ8TBvhJQJ73AJTPUb79BkTh7XMGqUweVWnlwm6oxs9BF8xDnvitE0WbUWxuUZWkdobK6xVl+JhdsKFK8zax9mgGxVEySVuC41DnvtpCEZApmalWVbhVhNDalLPo/QZZglSkojuASsLXfNz4DQ2COFu3K+n3VrxlRDVMMLApjYsjjg== 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=TnEJyP7zqNDJFKkNrc8+gbI2nEFZlzvS8uTOBjLYtNw=; b=O33bXk0Lme8ANI3VHYQrc6RLw1+VRkFYcfiLNPycvogrUjgFpJ5kNh8ttZLcM1iLuLoAL7BEjJB98ely0GkkexvXMpPLwPUGDafljwOHy+OFQ/YOFY2D0UmUVudDADIt63iYTtnHXpZS97OQTPTx1/FdtTs7kvr2FI3Vn5zGh9I= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by AS8P190MB1238.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:22 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::b2) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:22 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:22 +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 v5 32/80] net/ntnic: add TPE module Date: Wed, 30 Oct 2024 22:38:39 +0100 Message-ID: <20241030213940.3470062-33-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1238:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b9b1ed3-40f6-4ffb-2a30-08dcf92b7545 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: zSrLq5I5ofg3RgTVLUwAZbGfpxYdoEbhjTbpgA9MUfFKpVwxM4F9xXVisAXfwIuz3pz2bEH5ahiKbA9ydH9/qSN4Ys8sOA4XG0KmNedQfKfw8yb/wjBrN+bDM0Wm5PYJaJg2b1MbGEz0KACTe6SAWBXbzl2Ejh2wuhBrFwWMmAagLXbyQAnHeFMdyEFk0w8iJTM3EiAHXQQL2y9jmx+T4y3jWA61+ZR98oT76oGYDOyI9m0pswCd2ONWHeE23MbGBZ3xOxNFESbXBvsVi0kEQCsgeKACERhZaYwTFrcFMbypJ+XkqHy6dEUa3vZcYE8bFfSsfLoH3ecX3sYIv+SdJ1YWeqxCRxq8ZiwYMYd6J8Yjp/Srn2xARmYsLZxNl4xz0f2wCVauI+XRbtr4/SVsq45NJGyQPaKV6P/Av53A1PW2vjcvtjdXqAnOGH0vORGB6XX/iv+BwiIicLU2fZ5ETw8gaZk2sG0DSarltEGBB4kYQd7Z0Dk5H9sMa1AH5wa7apqHUgwtK6Zr4KUtS20RdK9LGxmtDz1nIahQGjE9VYaNO1V0KAZ/ifeJ7LQcBNPo4xaY8UxliSsfzLPoSXwMPsjVnypUuK+2dx7YBl3m2HDjHD+JgCMGi4+wmYN8HY5mzXnDAAglsNAxdQxHPlTderGIhibyaNK8WsgEghsmPYoLuxzhm1vlMDPBzlN/dtcL8JO325ItlDIIoyoVCsS33zwn5ULjP5U2Pp5H0xwGSfoGAqa/I28LqhcmCJPRsI9z6yqQbBmWgWEJ2YWY3f3FufgGnZtEwOFQMhsImi5q9zEbH6vAwR/loIGfAD07t4ATVK8tLFQ/0QVl5YitPoCtFTpFA1ayaBPVjdzQFM6bezOOAv2pBczVcz1kBtJXjkJ08ifSicB/kKXaqLzQOtFeOpWqWIwWO3rGL8l6TZWievvVAtpdoLBxsUyZGdyztBhUF8phg4qZsC+o0hvOk8jre78uo0amQ0any6LKtGGoTV/IN0Ovwy/MsVSMkOnDg5Rci3suX4cAY7MqpXSDL6mJZ5tad9VprMgCtQ0elrmDPWrz+stofTmoAgA8PTYBtry+CnvV8g7OhKo4+iH9GJvK6Do5KtMIlGBJaE8B/psjzy+UigBAj/F5h21+uH/lD0X5Odv4hHs4wT/hKdMWkhtIFtQHTB5gaFZGWnmkVYFCxbF/+cTSzgcSS7QVSAMoUgwLN5ZWsuzRfF9SfupLFxKnK1z+XLrRPQVt9baymNMDPtP9p3d7nO2t3ZjoFC1Ip1lccJefSAG/mM+8HLvG7/ljLgB6m5u7YJU7s9OyoZJtPe4uoouWMESdlJ6IcSAdaEJckJD/8XO+UTz6pdM7JrC509imDqvP3113+5CiFI976+ZYgzIpcrISsY2nc5Fr5+5CKnoSce7Jdgkf+PCV3xue/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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VylYrwhQMxgq6fHaazpWIiyDN8fUaCQe3RJO1jWR4ospVtznkxqW+OKSoiD48dQ+RsilXT0eAxAinopf1OPFzZBGvbj9ga8F8/GyuA1JO/YP7vO3S0PvCUqdTIfFWUZZQjPkzHfKQLtNCcGzJvL2YD2dN8wZOhVeqEslG3GKL+aiZmE1YWizeXtT4NOMTEF4V5vWHwP1FuCBSyuB9/yRyMi/gbyxzdTWnG1tTxhmdxYbL0CB3mIgjxcASH1kNnNmfjJvAExbBU79gIKWqz1SJ43RTBIFdWd+5dQyvhJBoXUf3ApMWVfzRO6a0kk206FY+dfHy2V6/n8e5ciBSzPAq613OZIYuNadDpGFHsdofIRIKuHWnbkVzIGxjUS+gWF4fqzvcNuzvWOdubIQKSCs2RCBvrlJGRgOZyIy42OqBLYhFl9OMNKOCxDPGCPqh7pJZ5PntvmumoAUvlkJuShvy/H8Mr6Cj3wq6kDBS0BIyJgx3RIiR/oAyCuaL+HYt0Ve5CHEBVv20rKzjkD99x8Zmtu3b3IAIMnY9KMuO6gl7AFmeqF854NFvbEYUMomEJSz5UVfFTEA0a0ua7vP9ZZ1SdTeu2TqrWuXhJzJRqu/hr/+h1yMwvaSXBEy7lwKi3Q4ZIfTAgTjRRiL7lDkIeJtEH6RXaQq0uqOjQZb2YAcD+g= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:22.3176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b9b1ed3-40f6-4ffb-2a30-08dcf92b7545 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1238 X-BESS-ID: 1730324424-304433-12633-44621-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViamJkYWQGYGUNTSwDAxzSglJS k1MdXA3CwtxcTCyNAoKcXYwjQlycTESKk2FgD64culQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 8ba100edd7..07801b42ff 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 */ @@ -2843,6 +2955,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); @@ -2868,8 +2990,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 Wed Oct 30 21:38: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: 147795 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 15E0445BCC; Wed, 30 Oct 2024 22:43:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E26A43492; Wed, 30 Oct 2024 22:41: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 C666C434A8 for ; Wed, 30 Oct 2024 22:40:29 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bgftTJnZ5jwlAgl8o8yDq3kiC09YCcZSeB61aGuKHksxkw5E+SdeDS53g0LfMJCw7dnHuKTqYx4tz8ch0q3dVBW6JJveZYwI8NZbq5ZfNme9afLwh+2eV/ECY4rCta3EN9pS8MiICHeHdun4DJNrhspl1yoUWng7uOMl1Ooue6UffNzthF8RkRyUMR/m5/08nVTB1OJT0jMy8731sHCbH2oERbXL+5qp3tC8WW3jbszEnUcIlnobOvuNPLLqQ/Ut8+ONKX1ojJawMutiMYVA+LMqhJl53oBFB90OtXHvlTvClrdclmQw5o9KbI+L+1GYoJrJVLQD7eIjGGT4ccLUQw== 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=aabmSIsZx/e8QWelEOlWDUGCoNPaM5uSwxo71EVDJo4=; b=odMKKL0NPYoANYdUhuX/uZQ0bcAFlusgv9i+DfIRmi/XpVVSuxJ1wZ+6eSGZl3v6C0VSVc6cXgyrZeSynyn2bN7K7nfBVPtab5jMP7bXS+ZRjlXSWFMO9Qn76DIQGr80883JLLtjV+MMGYHZLyuTzG+gkKrcLnylWlmt6Kg/vFifyB//BrnrM7+llCf0A3LQYjgJXduRZoDNvxfxGTyjiXv0qsRvSYTxFAEPQeoBtLz3yW9vN4Vony5gERcHxVhEBoNaz8iRwJy2xoIDLxVS35IDI7d9JaMB2444QKynNkEnWo5gwVdv2zarFakXZc8N/Nics+jLEqFJrbEHnWPaQQ== 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=aabmSIsZx/e8QWelEOlWDUGCoNPaM5uSwxo71EVDJo4=; b=TEEkAnDaua5Ln8La3Qy/RCqkCKz8rTIXJYAZJ98IGsn9S+imhRK7ZAtPsbdPjRLBsE6LQ6l/BoG83aI5myO+9vYZtzwugCxaHp9zhX5rwzLZnfXWP+r0UJg78E+fTdlqTKcQ2jRZI/uatFOi+LKhjwchwvb3KIEu2PHiofSTU6o= Received: from DUZPR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::15) by AM7P190MB0582.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:122::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:23 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::49) by DUZPR01CA0003.outlook.office365.com (2603:10a6:10:3c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:23 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:23 +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 v5 33/80] net/ntnic: add FLM module Date: Wed, 30 Oct 2024 22:38:40 +0100 Message-ID: <20241030213940.3470062-34-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0582:EE_ X-MS-Office365-Filtering-Correlation-Id: 6014a27d-30be-4ed7-24b5-08dcf92b75c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: U6OblBs7OhB10GdF3KosC6HGUsOXg9VKrifpH8evelE1ZCBEu4QHkM2zjCR4HY0wl8OlxTTTAl5XIdU3pXw5qpPJa7+Ytn0pni51hfThXMhsO4ULRhjsSUboxGAXevjPMSRNGbeGSvFeznntI3+yQ8WCTZi7nUbFqgNAe68o3qeU7UQ10lPHyFKeerQDNlb9G4KFBw9JX4vgjEOYqlTRth/VEcWZXdPei+rzwsYFiNRGQo7qiF3te4CLzEkD7HNB1IweRX3rUTsTrR/UHSgnkOGF7Fm1BcXVZq7P9vIko8euqlTqs5Y6yfGGquXKc5fZgpy19MLf1/PS+v1q9sSssxmcnZZvDF2gY9L8eqswdy5xTcJEQLFpTyB28ibjOWsHMNuDci8X1dHxuqOe14aruiLL7pkiHGOzIvNvShDTknLo8f+Fbmeyv1G2sDFny4Howzkqy27UGeeDwn8oGdFuErtUzqEsfmPBdgZVLjL87mo4nj+8zkkzrKXENjMXNHntD0ILZDjJqDKFy8olTN670SErQ8+B5frrCAm9lf/33CqYi7sk1VV4xxE1PmUillbuvoZQRzCcw9+o2YATPrmhqaQbbm6vZ4fmRL22t7leTM1Ueu0kpjlJ7R0JZMbha6idA02kYpBB8lk6uPNOFb7n2mO5ypO+x0SR5bNtqxSR/MOcLe2/77coCPBTjctxGIe7ZT9GHRpp828K2UY6p7kmM879mdFypqyXc+VmW5REuGlZaqeuk+hbVLiNhYzQHPRGjAJNoAuKRMPnM/TvL1JL0ncPM5VwzLFeqRYUtzjGiTtGKyzc4p7Jk0tn7cuuov8/3SuPMoWwvpAzMpd+uS+Y0J2jUJ92KqVnhCkWcD7DE/a/XghmVneriwpzZa5YlCDPM0sjbUMbXjzAK5xGOCmtLdyMMvhVmBhDLaG6pOxuXjt5E8ceXZtsjHuEZpKqf2DyalzIoHR1YeWckd8kYG5MmFSd2FtbVZ5O30GKBDMiMISsKxlVVcBks93zUfgqhNavBzpVcNFZD6RXsfULSOxZoVVd6x6FQe99pvM8Y5hcLikCoU6TnHQ8CCICqcQSxjVC/2HdbBKwH7RjyLT7jO5KKfUVIPiwUYonErVk6PY4QbOLBhen5waPk8M23LlRgXcA/PBRBpofgPSC/AorYII+ZqvnPVdRZ37kUpaoSUwxTR7qfcad34EvNp06vggpapuEzk46X16VKl5fFU7tKKlRLec2RH5hhZZXP5EfY7oDzT004g5uleohnybwfuQ3xwuwPJQcyFu94sO1cOSScsvnGxY84g3VN/BVtZ3AtbBWYh2wTtl7uw0ybusFOcDOIfF3h7JZSDyRItJbuWzX3KpePnZJ+9oa3C98qLpAwpV5MLM62/AgHkOEgWCQZ9oyipeMSDdyXGE/bSWftMjZxRIzGA== 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)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nQ/DiCh1c5h0Y6lnYftd8TnKByCZ9orqzPZX8Y6iscSYBhVVO6RaOE274Apnen7WLRLD5SKJ23PxdUsiBQ+a2Y39WjcgPcQ/E+D6zZM7506PADVM34qJAvmVoV3p2RbfsSfReQQMXeuQ0XtaJFpLn8Yua/+MMjWMcf9acb0bYsrxuaFLNlChqE3rZfzAs3eGl0QBJI0kIqfp/9xnMS4Iz5KPnNzTCoY5BZIn11sAdfarsvn29SWqy+f+ZfKJ42IzSmpo+RY35e08+fZjz1K7E7SOFIWu54X/Kn1P1GI/PytaGo7MtxdsaV7nLOVMUfcXgpvqyHSXowDRz4bShwWo1fO7BFIYWL+LO3EEnTKoxi2I/p+rgfafYtVDbRqlecteZAvyc5L5+vLgcQBUtiffHkpQTAIETrUB4GvxUfyDZ1M5TjAvZFuNzyBZFpVM/El9oZO+H5Y2DbxaquwqcyZoyz2gmXp4g50SXqolVAzB+rlt63MTWGX8Qv9NtPb1rWt4Eskygv0upsqJp19+AT768cdIE2FSDrX8jK888D1Fbz2A+x3hqkFgRvag7SG29EuHqXfp+IYut3JnzP2LgWfJSHp9VaJkpD1K6MlxhPffIcmLk6karoeC37HNry19VLJuZA6thP9id5lMFfge57humo54WF5X993Az71HrcDDod4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:23.1301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6014a27d-30be-4ed7-24b5-08dcf92b75c1 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0582 X-BESS-ID: 1730324425-302901-12791-43467-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYGlgaGQGYGUNTY0tw4xSTJ1D zJ1MQy0cwgzdjIyNAy0SLVwNTUzMDCUKk2FgD43J/4QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 | 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 07801b42ff..46ea70df20 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); } @@ -3024,6 +3181,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) @@ -3052,6 +3266,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 Wed Oct 30 21:38: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: 147796 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 A5E9745BCC; Wed, 30 Oct 2024 22:43:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50EF8434CF; Wed, 30 Oct 2024 22:41: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 46CB1434C2 for ; Wed, 30 Oct 2024 22:40:31 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2172.outbound.protection.outlook.com [104.47.17.172]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bQQp1UjRbzJynrvUGolGXovrxiZmIwB1acTnTBZdycO3Ik2vq/7kkg8+uiW/AfFnoetGFGeATJHGE1cThg/4iPQ5YoE1z4vT59Stfw7yoW3nnwXLiC0edYINLO4+HoMrX5awF0Yh0YwyA5chv9Z+AbldSNqaXCZqxDbhj3EfWx98ujcP4yNXrN1G9Z1+Jb8mCOK1uOCf9CUKWskzMiJouYDZUMzqHWqIBefDZhL/rBjZSFFjZMAkdiN1LZsAWvuFy6bUgwgNhIyeFX3XfgHEWZX6hjPvGNab4qmS471BHR3P7T2Uam3UVlhCWgLeTc8/R8nRWNt2+ewWsgrcTvXNWg== 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=c69klxs37gBcECm5daSDClNBQLrPAVqPAP0Ir/WhNGs=; b=g5tWGNUrbLMqKK7iOxa4rnrddYnR2gsWa/Q0kRoRtSZOKv9Ba9DVGgmT9FonNZ/Mu/6Ek0+F9VS209CxClchSHinNGuGvXi2pr0QW5FuyfMSnk+vNbYEnaH/4rh1DOSsxNlqJbXLTiapXUhmglWR+IbmlRNQcyY8jVQQk0aVeoUhKM9LDg9tCIw6fQ75zd6qq9AV+KO5GqCzpd9NaPquvfbgzyvXR6qzBZYCJMyoBWUK1i1P5O4yDxe4ys+XlGqiOsZX0ih1iqvqN6WUoFHgOpOzcl21goui5Z2CjfV+1oLs+D1pDvRXot4Du8l//+Rh9Xc0LjpSf6Psi5j3hzVONg== 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=c69klxs37gBcECm5daSDClNBQLrPAVqPAP0Ir/WhNGs=; b=qB1VbdO9ldafueGA3HFmFWW6Wvem7VLsKIuZHoH8/GlnxYx3a7CwPeJrJimSJCgT0wttNIlgzn4lPYWE0w9f4J1NWz4Z8wvHLsiYaDJTvCKsNrhbcCkWHfzakHOfetGJjpJjQ0yCKhSwIhzRK1c7GGXs8G8G+Bs1Kmgp+TYyuYI= Received: from DUZPR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::13) by VE1P190MB0927.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1b1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:24 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f4) by DUZPR01CA0006.outlook.office365.com (2603:10a6:10:3c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:24 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:24 +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 v5 34/80] net/ntnic: add FLM RCP module Date: Wed, 30 Oct 2024 22:38:41 +0100 Message-ID: <20241030213940.3470062-35-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|VE1P190MB0927:EE_ X-MS-Office365-Filtering-Correlation-Id: bad72b4a-91f0-4d7e-6d4f-08dcf92b764b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: JsArJFdMLLogsiyUzcCFENeRC/bR1z2tPnzgcHQF1xHrzkTtNZ0WgM4iYE6pb2ekVjkzo06iXNyP7Nnid038CsNVAXdxdxx7nk5h7HV+QXGxk4VCGqXIWil/Ij2I3GQVYoBKkZGGaSld0AKMfak8Cene6FFuPJwxPQl25anINAx8hbrykSuSUDs7HQNDtaiki3iYipoarosg6wGWbMhXbIANZRjp7C8jcmdac8S38iCpbC4Y/41n4T5o/7y4VdyS1xlah1Ej5il4Iv5UcGhqMRY9eIWHO2iCUvnAYheLPS13AZqH6zskiWfKzMvbzMv7ZGvzbRiD8Jm+HT3HILu8g/IQdCbJhrAu88YHqsl+In763maC77XSzvUVkpPYYDuf3kLeg/zm+EcGPIEBpLc5Zj62UK3UscYe8ggb8+QHqco+hpAxazHWPCDMWCETcv+KA2xvkYi3fcxFndVVu0UZknJ9ZCARyw0IzPmC+tJBQaq+iDgMs2kjAbczYEvS5rXrHCnU1NSx6bpnZrlRr8/U+qrEUQjYjI7P3loXI5zgL2PF2IGU6UzoFss49ndlt3dXyxeX+D4HD4cX5YMHDCQW3+Ttmf200hHIS4X5Ijqgw1XMhx6eWYgNBcbg+xH6mUpALKigttrkYBYm4yt4UWcJ8f/ohhfYMldtuKVDaA5ztkV0d5fNvxHqv4dX6w6u6g5jXiV9RqShc2VCDfxhOSNXzVN4CsC+qqbNFXKHqoe8+nvaUGVUSbeonMeD5m2Xq4fqFdPunYaQcGrG8DxPRSi+MtaBCRycRrkSPe6FaGWsCimkT2HapPBRtOeulLAr46GvRm/649wai9cw8wcKwT/8sQUD4PGOpQSaeXuVO0j4UBLdR9b+kaYggfqmPFmCbgUhU7TkJ29jL/3xCEPSAiuIUctaPr1xqMw8PEgfeHsAENw5t3dHglXuLF4kQ85PAIiR4ZU/rOhNwr5IVGzTJmb3YMPSaE/Dchua7f+bIRFuh6/waAQprBpnUsCWRfYXJw41REU1SBWPkOXbTF00vEln8vGudEGBN9OdiZ1wgSdInp0HcpR9ujTnC77dweRUMdt/qa/8XthOd0PFE6QBAyqypCifew5vigmVKcYu09DFdnp1wLBYFlB2BONYH6AXcqtmiP91E5bgH7fFHji4Sw9CWKA5v7xKbN0+1SFI2WrwhjGXt8WI/qUes/6ktyT5+C50prLYvXS3Mp4tkKoXGlPIbc4T+bRXqh1PbmeZZXHgn0De2TiytSjM0FlbdFTkilxiiq+cz2IDVCN+exksC/CXVokcDEbsgZrAK+0mLIUnjjSFh+eAQmtakQ/uSU9/b3TMfXk/H73Jly4vCoAyqsvhRwGvnsNle1SPIhKS5Yu7OIfq4pVLd9k0K8nnh2sKU7WZ7tbZgFIQFxLGFjQLbZvoBg== 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)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +AFJueE6M7echc6+uZHLmGmA6UevdG4+yNQjbBgSMkG82lGpRnhB0YgRfJG+8uKg+K8RX8F022WBVRYH1PHNTgokUjkhKgOQFD7S0v1mvcHsTsiJZtmXtlEEt83dVM9/1BnP/rfP/BicV1Lv9EO58H9XnilHRNr93iCQ02/79KRdkMgz0u7X6cXQxqncR/mnil0P/PLlYZy6uEmfbYL5Xi7VdQIc9RcRCDmgEAlNaBzRTYj7VJltzVGlN2revRrcGWR+RPxUlnQ/LotvzufzmxrOBSpV139xcXMxnKLkf/XuabWzQLr9JQuCAynP1yB2xlr9Hm3miG4ppAOPT6O47gmvSIomhDpNQ2D1aFeexezW2lpV04iGbZdF5PymO3YLHqzPioUFXXTKfDfcfa40hSdo9f5lFJRAq9Cj43Y5RD5QxpKjRpcoMAoyGs4ZV9+wNbqg2su6XQHClZCJ6qSx0Ml4/f9rWVWd7AG7zsyz1FKvwCOo4U2i+RofKfvp7vS4qez1Ngu2HnM37Lgwu05N9ORoB0MIXyw/bOUgOja5X9Bs+hB4YpOSMvOJsqzncs/Cm7zJq7oUWQh72iCiG6F2JSH8+Gt8DbW59IACTyCpq5H9tV8z5OBJ4Cxjodkit9I1dFHQLwXYmW3fPgolswQfJldqhP73t7KXRO0hvtDSHQ0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:24.0363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bad72b4a-91f0-4d7e-6d4f-08dcf92b764b X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P190MB0927 X-BESS-ID: 1730324427-304433-12632-44626-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.172 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFiZmQGYGUDTVMDXJwCLNIM nELDnZwtjAyMjQ0MDCxCLFKDHZPCXNQqk2FgCuC+VzQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.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 46ea70df20..7a0cb1f9c4 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); @@ -3271,6 +3301,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 Wed Oct 30 21:38: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: 147801 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 50BA845BCC; Wed, 30 Oct 2024 22:43:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2345B43497; Wed, 30 Oct 2024 22:41:35 +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 4F1C5434C3 for ; Wed, 30 Oct 2024 22:40:31 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tcUiGtrntXjN4tdOkJo6iDIx2KPKR+PTQvpZqjWYgUWjqeyjzTG9wROss/0u+As2V0/202r/VTWQszii81LZRfeWxHYzxh+sb2c2jypQPXhGbPu3cgCMA5QmMqb1++AF6OsS+Z7ob55n64ypAvqETotINdS4bphP8CT6n+IGxDhKvGLPLfkSFg0aNIdRYxXWmMpQT5h2SfW7EzJ5cTfa7lM1W9G08J1JgiTHDDalJcdp9/rAYp4gvKerfT5bna528oDrm4oqtKTI+J9RLBDdQQzX/mU/qTTTFN3Pp4PNX3b1j2belUrbQJUTCMvYtYTmKAZobnPc43Ujyk+ltiG5hQ== 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=eSGSqpWzzBqAAABZsryUNyWn49dgT5Otstrz9LdbS/w=; b=JN/E7w93zHWl1Yyrs0lM6xOeZ/wQS/XDAZeNzYOMhrz535w+IwB0JCk03p+WaRf0DuJWGJYRIMcB/p6Zp2zZm3VXyhyjWrYX4/imDHbOrg4sgEsXoPEWZs89uOHfTL7Nt/df1sw01yqJ91KXUCCU28VyutJ0cUTlA6t/C9NUj6p95OE5lP6wRggQqfrzwHtQqW0chif/e6kdRuKKdCmcB4jtZigbwNrO7USXPbdcVpK5h932AfB9jPZyiDI+iplCW2f13Fx1Pfjb+NQkpzw3ZcqTFW0iQCbULMP4DaUmEWvJjn7WmlDeAMww6q2OSDkp1aHi5uExGZ8aUeaOwbZHVw== 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=eSGSqpWzzBqAAABZsryUNyWn49dgT5Otstrz9LdbS/w=; b=m4B9uWUlY5o8R88+J+f87iu/UEsYJ58TEoAEVd+r3MIL5O8AZjpJIFPVSBRjgv1cjp8OlEWNPQBz8movIaKeriVAVRElJKl8GezGELX9uc1uWEersWlML8DcXxU+a5KX5snB8TsLp5xlh7dmsCvGsoqJhcN1MSASIAtLUSFWi+g= Received: from DUZPR01CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::7) by AM7P190MB0727.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:114::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:25 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::6b) by DUZPR01CA0014.outlook.office365.com (2603:10a6:10:3c3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 35/80] net/ntnic: add learn flow queue handling Date: Wed, 30 Oct 2024 22:38:42 +0100 Message-ID: <20241030213940.3470062-36-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0727:EE_ X-MS-Office365-Filtering-Correlation-Id: 10b5b495-5560-4691-29cb-08dcf92b770a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 2emdn7bLzzAgXXela5Qx+T34s4EstnqZ33yTpExHv37TASZAdMfstcJ7PqwEfI6ONnUfpfypmCEvt3bY6RTPmQZSSgTnHB44+Pwox+5kWUuzFcacHEPnFN2viKqXqNiSD2vM7KFuOGVvPiNDOL7j3CD5a+NklUG9NrFJbiz+slJHpuayXzqmla27h5ojvXK5c+pu/uoAxbpXehMcruDXXiPv9N/NADuMnK0gYd1GF1DA2rf6pswOoPDUm83Gc9a9lWc8sB1INsa5zbnKHQt+PRU1YQbxQqwvPuqMtoJdYoCI+WwFGaacVxDH08o82a7E447MY3cxa8k4IJN9YBIrMZ+NBqZcX0yaLLJlDKoicX1ixORgSVGFmAAw3hqIwqbkdw7d5VkM3PzvZsTvuts4loakDrIUuuTQPA+084XgK45dgg4yCgkXPCsntDZFoTrSS3axUhM3Yvw4WGLBKExmtwzGJOFCR6t6r3tMhNNTCI8eg7YgT/UOjrEV9xm7Td7KHwwIn84S8ed5eTV8o9oYFL0w7epxeAyceezDGr37bOYdqNfmeQT4P2Xi0h5PAOcDVsfAg5uEbgPwzVKnu6an6OY4QA/VQjpmCUWvXlc/4crTPwIDeMi28wTFw/9LXtkNzsVSDugNtikAXTdNmmmZgZMFPLgc07zQpJ7EkEwmOkJ20wXAF4Dit4uCTzaumMNRQcYNRNmR/Fvt4aZoFU5O88ST8u+vJ+xJ5wGHFpl/Gn1sfE1hhp89eoTvZyXy6DxTom0P8JpLeeM/dMLY8vjBVGGXSqU2l67nT24gtKTuLkqJg9B5o4RfBUMqyXUQN0PSKWEfeig4psfBnAgNP6gxcx+c6sVOQKk4/UEAMjxZwrSJFzKAr2ZWOR6bgJpKyN0WyBjuVxZM52M5ORQ/BYd0EJ3Iv+7+WHBwzJyafNsaXuzMp70+lZpfq4jd6hitZtF6JP84H9CePTA/G7OQidc4GcBD5KhgnINFlvz4/9Y3rvfJvPiWTPNheOy1ZacthY8jJ3ql4h1uHzE8kKBIckCb62Gs3tZD0c+iU2u1l+Iwun9r1om0zom7iXtILOXxFscWTxX2aD7sAtW04J6ZQ8pGgVv8cSRPJxWaf6U0i53Sx9i9hoRswIkiTfFDeq3WHqt8JhWJqarrIRQI7q0SP0HdcXPFvI3Bh9sChYeMEow+spGHxE1dIGX75ZlMiHxuXaC9R4eMpNtGzdIa+0L9JWrnxYcZlM32ZzFxYbqEVR8wu5jUkw5e9EBN40k9CMO9j7BbeMMj8s+hmFXS0msLPp/+dgOLd2ZnshpOXjNCSLSsa/qMMufVVxnsWWV467MfzcetVB9gjSOLEI4kYFmH+8wGsq4dGnUyo2Tses1FcEW53C8sgidHxQMnB6xXM5ZeNB/cAFK3jpZwwixyPTc+q7c7UA== 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)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5TKh6im2/SP6gjK9G9mR0emGnG+3wehOsn/BCxUxjla1UO0G6jKVKcKm62kxLKWDRVds2aTIf8upHgLSqDPVlYYAI6A+pmRfFcNoIzSci3j8knksQOkGjaZBi8KQvBgpVeRJM4C6XlivbdFUrRkhEnrAOyvZaxq+A1lj1WIEdOhIlpIch8O0POjbDg+qZpg89zleMRs4uAvCyRNlMGHGtwPA6yxE6ECb6UKY6wDBURWOYtq6VxcjczztXjdETGHEcsVFwJnWkkWsAcuzbO/n6PvtbcF2MtWvdfAH0WsGxzwM80NyfUEGjnh8moUQhakQkTVJ2PL28ev4NCDg8wNg/IpQbMcxJtHasOgQWzxCjt/NczKmjSfxtKm3y4z37pOZR0hIm6EVh7XivNSOo+ODe56xf5iO8x++aTPF4ImXVzNCSgfchbfwUkk7tjpoRqZllJXa/hzoIAQafvo2d0Bsh0YKAroFVOEBrfxMCDPttXNf3JFKcXOJodxJC7PQKkyDLV0r7U3mOhevJyGmNXN+93uTdxQgjpgfY7OlQ9MlJo/rHDMhMzcAjyIA2HEBUhRIVcOQ+hDM1KEkjTjeaXnA0k0O8V3TNRosIHOU/liNoVkG3rN3/Z+j2fSJtjoKhqq9cuYniCMv9b31xv4geSo3OvSKUBl14HJqQx0NujjREL4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:25.2863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10b5b495-5560-4691-29cb-08dcf92b770a X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0727 X-BESS-ID: 1730324427-312176-12709-40671-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGxiZGQGYGUNQgLdUgxSjJKN nIyNAixcjM0MDILNncwtzQ1DAp2TTJQqk2FgDTZGFCQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.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 7a0cb1f9c4..7487b5150e 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) @@ -4214,6 +4256,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 Wed Oct 30 21:38: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: 147803 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 3593D45BCC; Wed, 30 Oct 2024 22:44:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9646434EE; Wed, 30 Oct 2024 22:41: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 41DCE4349E for ; Wed, 30 Oct 2024 22:40:33 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2113.outbound.protection.outlook.com [104.47.30.113]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=guKn5DIu8xxyTM6MbHOTGIZHEnRjF8FRGjuX0XPVERPXVvtuuoT+/H7tJz7+L+S86zuL0snQw0c1IT83RBr4nAJDVXjiDOrWEgJQIRVn8/LasEzN+kd2xLPiCCciGoTEgh8tZ9a3xxUktzsvupHcTrB53iQ/47/ldSaCaZr8vQSyuJtnOBRL5eGZJKahpwlrJyXH+93ldI6/29JcvkedJhECXSSuFHb36YNb01Ylu/W8+VIwha11/U/3grp+tCmAPJ8bjR6RGdgqMRe33Ol7O/Oo06/ACGR+ODXofDfUv58KSCRy+/Kk3xrd25mc3RW+OMOWrPBY50U+0C+4caDS8g== 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=++uiEy/2R7XwNMwd96sJ6unj7np6H+3zBOe4s0xgRrs=; b=VYymwli5DuC9GoaBCH8JuIaotIhfKkTNyZVwKdsps0xnHqMdbPvU9HY4r1PywJwcyDm+zOmAQA75IshWP0EJojagi35KD6k94cVfJkgmxCJnc8P1FIKboFxw+AprV9NzWw7htzMs6DIBUuXQ2i+vtEAli+LfnNH0DGsEjr56Egcf5QIZ1VSrm/UJLXt7klolWuiYg3fQLzaIEysiANnZ2wa5DJ9cq/x45Z8/U3gkn3jBeRDm+czsxn44Wj8TafKEhKbMizDEi0pALEVdH+XMDPbefGq1SUkF7DBOLwdaVowWoKZUTfoSelh86dzWg33901A4HNOcYUdB821RYwi6eQ== 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=++uiEy/2R7XwNMwd96sJ6unj7np6H+3zBOe4s0xgRrs=; b=SJ23+1W3aYYLc5+SkZ9n3sjofG3NmqaTzYsieQXJuv2LLHENmbzzNTK8uYPlqA9amWIh/zm1B/LYOekfdtnTAm9n6gDYXYJGTpx73mNyz+81ZetWkQG0bpK+8yyH5YjdBBxeuZSOi6G3X60YqUw1NPTC3O0EsB+geXolvHwGFUs= Received: from DUZPR01CA0010.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::12) by DB8P190MB0681.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:126::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:26 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::69) by DUZPR01CA0010.outlook.office365.com (2603:10a6:10:3c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 36/80] net/ntnic: match and action db attributes were added Date: Wed, 30 Oct 2024 22:38:43 +0100 Message-ID: <20241030213940.3470062-37-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB8P190MB0681:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a956e1e-e5f1-4a83-d4b8-08dcf92b7796 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: T+fH5EaVtLfRjaZ2NmfGYS/OwvOhzu+I6WE/D/2nyRoSyNtPDV0UbCAbeOcgftDCgbnN7HVSVQlyZ3FAYfeWDL36qMLZNJAKuMBI8P3aSvxcxNTBK19iUzma1t3pAKe/CtWRA5I4vnsi1F4dLOFKmkgB37auxcW1OQZIK6uEH+qwFmzbFNcoMjgEZxzqMMotLzbj2/zjMxjsI+bLdecGuHVFVxw6WScUX0WK+DQw2J+6KjFQHJNTl0dfEDikJ3Cffr+aC6Ap+xF5Vxx4KZUU4PXoxnrqZRLgb3ZwO38igyI+oljGHtpltXlguXdRZvRdRbHzjRSSlziuHP4lvXOO7Qqu7lYYnERzKNwUsdyFMSVhdwgjxFhhbUE0LEHWyyP3m8vCazC5yDF0k3gcxQTUZ8iNMfRfEEVkcrU7Fxx19KRNmQ4qaMW2rZPeYXKkZBrCASesPt3zEW1BUKSF8QRGpKTIPHvG2ckp0oAEqZCEVz0eI7qTIdgysx+0mDkjps5zouLPnH32MALVBQYCXDuieWIxmobgGePCI0EkZMVdEcGmND08PCRoMy4dhHSIdqzDMICv6iVmqMNRxPNxZ5bGboV5KoKPTYeyVlgfTfsVc8fMJ4U2QdGs6a1CeAi24MtFHpZ0wpLzXbQjx3n+tRMK0CfX5/T+zJZfDwl3E1ysr7WoAQuSPYauj0psu2nHtYpX5gYOEeoVzvAcUND1olzYe6HPdMyynAqIC+wZuL5hOa0tg0NpITh1uqtvQ/9KSX29N7ha3E1PpcCpPoGtUwTclArujoomjMfh+Liu5c6Tir/VH4ZXJxwg/Phk7XFj40ySzZG5Qzv+Qsvoou6j0t1V+NnaONstB5icYcDfYxyfhkeLaTi6ljvDwDlI6+bo0Tp1nlQkjXpDPdJaopt7djswIfxVTYAaT1SHbmwGGfVXqIhmYxU+xKk8KKz4rgNQAU+r79zub0MVGko6fu2fXD17BH+Gn2azrMXfcy1GG/cLn+DO6uAqatW2OQ1MyKD7JSyzJrk6iO/aLQ+JDW4ERyC0ALjUdMWUUFUVWjxylwJreZuLd8JQ+3NbU6FzgSDDdzXcb09nxSM4zI/KgyZYxUBY6YG7tOM1am+gEa1nS7hD1GjU8vSlmJaUbMThvqWsFmHZYd3lX7dKHqG5/TMIk5WN6XGI+ufJWgSXplSKdUkQFhXVdfqN2ZLCMYQwSO3gFWB+KjfY8/8kKpqGSg2Hq6cC7mjkNUpPQH25c3XMWqfPx6FTp/rSyR/ppjuWi4TXb8H0iAd8TY/E4eHQAI+OBOfco4TqSuDKLKEr+mAAkC010Q1Qm9y0xuSHxHMeJhR+ZuOEBeAMSSbtgKEDXbQDqCZXvkg5LclC5mhCAathtIbWs0lHCbt+/fSyWPoK8NwsM5IWzpsX327VNcRLuzJ5gd0h3g== 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: tEjI6+jp8x0PME8f6OkvQAosr+jga6m2HHvIDdeLUx0e5YlhhbX/n6IdRauSjc4cXLRwylXvHmOfVs+4u41nO2pZsAgbh62/xqm+cEXfv6v/BwKPVyUdLWbmogqjjmb+lFoOSxrs7AHXfUCCI4r2bV+xEunNYnDWHUNHcoYTEOf1X0TWnAKJTEN/o1KYVEplmdNmf/N2Rml8N0pweKGws2fXRa3/KXMZkf8vsFfdviCa4uRaokXPhxYOSA6sKYhktvTe+i3Ogm459HLyRUadcYqh6KY7/amJF4D/xGKIr/fe2mO/bRsd1PCCINumI8EN9AbNlEDJHa36V2R/rjy25DRZcYxt/j5P/fEQqSd3XZ9XpQQQuquX3q8M60DOZig3UUh8VjHMxQa+rEZclp7JguIoHLUB3ARlI9n7mNsj1uhWAWKdXClU4a/NyFXSEHKvPTeeWdTvMSmjcL/zGDqGDgl2Xl4ejv6Ta7rhBZXq5gpTeNBjBZH1eBggM8joJ1JjDKKsPn/xwCYLaKhPMOhrhxqxaGYuV5VJ5hvFN+Vn0NRfLrH73+vqUHEzXq/U78lucrtnjg3tAMkmv/ncQrkK/a8Xtw8TGdjOWts9Ml3A+XKrQmSoegYrlfJR/qTaar7l/DC63kUW/sFP3k3fUGAQantESxR1z3dCUj0mBGbd40Y= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:26.1926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a956e1e-e5f1-4a83-d4b8-08dcf92b7796 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0681 X-BESS-ID: 1730324428-304433-12636-44628-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.30.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsamBpYGQGYGUNQoxcQk0Tw1yT zFOMXMwCLZwMIwLTnRwNA4NS0pyTDRQqk2FgDPlZ86QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 7487b5150e..193959dfc5 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 Wed Oct 30 21:38: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: 147802 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 16CD945BCC; Wed, 30 Oct 2024 22:44:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F1AE434F0; Wed, 30 Oct 2024 22:41: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 E3FFF434B3 for ; Wed, 30 Oct 2024 22:40:32 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R8dk+PDy+SMMwVJbyUZuoljnNL0gJIrgxchJyYjPX8JgMpz6cP7AYFBfpmZ4nhNs/khEN4diPmkLUMfIaaXLeDXJwxc9IK6wbdJNVh+AISrn+LCOEDMNwN3XwoWbfnSsCwMSRJOf5s5/r1xkY8gf2AGZ14radVsWeHSnq0sntDC+M3STZf1zT7ojpoi5byXVaXcJeMm3OvADvlvnzxsjqe1QaXkuA7F+NNEh9XBtK7UUv8zDuogJWICs+zj1g45r4Bce/x/P/KHgUoi4MLoYC1wwfpeLRBAOX9+BLGqLNFq71DojTXpS0QMq/9XTVmVG3WCj2b76OJMyUwVP0gxz5w== 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=G1fCJRE4DnN0CVsY7VKC3AbOyGGnwXj52RZkPNJm6o4=; b=oUYGQBslcHATFEcT67Su7Gc7vD8UKeNV/gpRji7uTYbz/MkWec6AITP2A29fCKp3niYjEqfSyS3oI2XfXlUXVjmRWswZPmfrLFlzR9qmi+Z+Ogyy4gP+CjRPGMSdb6M4ZipiU/pzdjilLVZZ4w2cFDiNVghUkIURa7ff/xMpzeUsr7u0vqv/4uO7A/vlC9nsfr4mFB6jEEL0NUjMU0d2uKuJhsJ3pEyZE6MrEYPAHh8P8KIRUVVj4sXA2RG8sX1wIWp+ZftHcyJRm89Evc7dVCVhQWgJc22Vs+QAjYJ7ZoKDTfdXtnYMmFh/NGIirlJXSn2jcWTHQTICzVC7dO0jDQ== 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=G1fCJRE4DnN0CVsY7VKC3AbOyGGnwXj52RZkPNJm6o4=; b=htFdoizJ2+4KhTxEfzTwZsDkMpO1PFL6Vu+XK4cg0xYT58wvoZoFvXsApxTiM+e+0YjaGT06JPVP0qpOxxC1bIpcEDTim4876o1JZoZvXH//adAT6jjUaEcRAt2X5hsgLT1LB/r5k5HjZvBJEUeCbGK0fYQ7Kgll/Nb9g52FunE= Received: from DUZPR01CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::7) by DB8P190MB0715.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:12d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:27 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::10) by DUZPR01CA0014.outlook.office365.com (2603:10a6:10:3c3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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, Oleksandr Kolomeiets Subject: [PATCH v5 37/80] net/ntnic: add flow dump feature Date: Wed, 30 Oct 2024 22:38:44 +0100 Message-ID: <20241030213940.3470062-38-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB8P190MB0715:EE_ X-MS-Office365-Filtering-Correlation-Id: 68531219-20aa-4da0-318c-08dcf92b7815 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: egg+v5/Lo0hpaYM2TOqgTAmnKHwq6Z9vY7DZM3hSPWO2oFmVjOb17kZiFJE/kyfo1/ko2YjAGM8PM/ew7b+4V+isPZigG5lLRgKp3vZSQSO8RFAmjkHajp3AKiiUq7DqJmDTdt5hj9KieRctxEbJE/iHpGcrG+rHjT2A1a2DILQ43VMKNrK+Ylev+OeQys8H2jFao/UrlwzNF/fvXpeauWx7l7Vgw22qtWmpNnjHI3D3zb+Dheoii6S1T3Sqa1twtjDln+SJ4SaqkZ9xA1vqkLauMEBo9Z47VFxK5LfuHVW3uX7yWnGELCf4C0c3t1EPirKm4Q82CBdoHJvFFCQ+BR3DaoLKToPEa7ut2Ti7qLiTT64Gfvs/ZElT1WC8NHUK2bPOjX8OAxcHrmxtTFY7LbVytAlGRYfKfvzplR+evVC0aF+8flzBjtJ5qSmDtgByd7O0w2DN18VyGqxYMvgqnfXKEhx5wGXNaUXUo+FL7WDGphfj4Gpiatlqlv535zQHNYiMTkgh0XWbWbKHJl3X2lCyWnSG7hy9LRiz3jbJHMmyYmTdXexroZQ+EVvPNTxyT8W8D4XofDwikNKwLZzCfRX2GAN9hOIO42Pdi0WMzZmK3RyTVy2ZHBc4T8gOk0+/Xphs2U/DDLaqfWraORi4GYKhJSAYO+Pp4n5j8ulTgYY7jsfjjV1JT30ZMqS7Myqubjjt6g0Ap+L6wyfKeKoAlY7oICahNeoqbBKxb1lVxCgbep2HtBpnHOWdaXn+K5UuvPBZrHAqsNwy/PUMSoTpxQU6jWRQ+2rp+4ClQZkrTQ2MchfcLPuPXIGaLoGqjC9q2ugrDG+3Walh2658H6KPn8FS7MIVc3UF4MGOsT0xE+JHl67g02XwgH0DVpAy9MBoX6kMnptBhRmJGzj8xcEUGnh05pth8nQ0BThwzF+E3yTu0s4KGJv3+t38ZZLJKcSi1auzb0bFrPxgvwC9FhYF1z0J/bpkxCAAR8BpSaYkrhobVJHYwWOCY5TSv1+iJydwEO6xf8afMh1YVn7+XoXnRBkKWnDegFWA3YJvTXtkddtBnGLiGSC1DIjjA/t0SlNrhEszzL+LaidDVt6uWTdswibSyN3aZIqPFc5dGgFpdMOVerYR+L/0DWlZwir6UWCERixFvQr9OO4xJ/X0mdJU8lgmkhpiyIadsSM9ibz22/H31jgkeRbL/YY7/U6QdOYf1LT8Q5t/QvtRVuanAtlGOQ8jqO3YZmj5LFomTHRdS8RVJDXdGf+p92DHUWNuAf/onwmJ07i34HKBtNqYOks6zsPypkn9Ge9y9a684d78ub8g1TkoP7qOoJcZabRqcb++Kvjhok4XRi8Pj9OriOVRx0QXIu2XZK07dtXkDFpu6k332zp4rBRlo9VdccJXJ1c5IS3+Aoq7aNb2i8VB8k+cFg== 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: jtcgpM7JR+abWPWpTu25cw8G0pByvoJ0fN5xkQ2laOlps4cbeCD4gmoNO2FlAYp7oyep9fVUIGuvlokMEWmZYn/EA/qHKKRecic7EGCzeRl0qTgBRyWWTxNOo92xh7tnXz2mL+qpRmcLqCAWIogAVh9m2eCIOtcnFZlYb7Jb3TuI0C2JusbBTWZXZ5+MiDYYQoJd9vrvUqZpPLNHnxZjEr8m5gIsR9f+SfV5JFBtwM3CdAVjnVptmjRHSYz1xJSSIVCoiv3ERddRL3JtuhmTFZETa7O1SKauFqjrpKOxvYTjsUzGvd8gyI0LGYHYIezOgAdZktEVYVZ4hS8Zzp6bdRVI2xl4mLNV4DOumPIJVCdlz2rtYOqodzEWLzKTUia4dkWiG8cmMKbDplFMy6vhcdiNGHKtEMqvGdrZSsmK8loWFXEERWoM60yLzUYSmjUHNOPw90g90ZXAqrridEFBzOtopcn7In9swdlzHc9EpVyG5xtkbVeBVE6VEQbI3kVHnzVLEFp50PgIvgPz2wGeeUOsK1aUE/q6WOSZXwn6rIG/ns47ZeWK7k5lku6YoCTY/dQIhfj1wB1GfNiy1u1J2ReQ61fJxmQaIcmBHB/yCSojFinzjWTbXGbJ334Gss+2Ntsac4lqm7xQ1HPdu8GeJuCUcdNsMJ+WiVTsEYnYXwc= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:27.0363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68531219-20aa-4da0-318c-08dcf92b7815 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0715 X-BESS-ID: 1730324429-302901-12791-43470-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYW5kZGQGYGUNTUIskkNSk1Jd HCyDTZNNnc2MjCLNEy2cQoNdXQyCzZRKk2FgAbf1mCQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.50 BSF_RULE_7582B META: Custom Rule 7582B X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_RULE_7582B 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 577b1c83b5..ec91d08e27 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -972,6 +972,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) { @@ -997,6 +1013,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 193959dfc5..2d3df62cda 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 @@ -4296,6 +4296,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 = { /* @@ -4304,6 +4384,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 Wed Oct 30 21:38: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: 147804 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 9E22845BCC; Wed, 30 Oct 2024 22:44:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA2E6434F5; Wed, 30 Oct 2024 22:41:38 +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 75484434C7 for ; Wed, 30 Oct 2024 22:40:34 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2174.outbound.protection.outlook.com [104.47.51.174]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TwYAIYEuxARRugTQ7jIlZwnZJsitqtyZlOaet1mRTTX+lcSllgiaDpJBvb+pZI5L3unqPPBxoMfgQn5fDPS4bt+exRg3SY3dBLjSL1T3c9a9deAV0keoCSsM3WS3xMnuEKhDwRb3PfLvOrY6xm2Udk3lMmazt8eAPRJXazY+NKdP+xuNrqdkZqAAcOWdBrwEB68ZLYcmDc28Bek5ay8Pa+zKZpvSRJThNLrIp1ujQUJziqvlF+lcgNWI9TbBAjgHfuJjrz3HvmqAlFU2RREcYH+fxuQNHLljdQUj47OjpN4k9Hh8WNTUjLqKGbkzlepFfG8f1FS0UU+n56Oz6rBANA== 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=JCUzpVnKe9mKgZxUVvyIouAMvqyMqIRGX9biAUy4exk=; b=DDq92y/GpXzU2I/7XXu8JF7a0WhuyNASYo2JMvc37Y4kyqC97AUDbhNjpACXR+hdIFmyfMzZKTRckXmFYA13W6B1IlroHZKaNZXLeKZSv5a5+YQneZvNi7xjmwtz6iR41wchvWPRYiKtNnz8+J748J8IIH1RX1Lz1dtx+WZD/5lVbreHRZIjSJ7T4iEqzlDpLhNhFWamIEA+dXQCWMPZc7fCvmHSsKMMkk4m9tAZBXYginSTJgzyz/jdN92Qirll2+K8ugQTJGd4lYn+9TeI01RF0jV4/WJEi5ELpUP0YeU4bf9LAp7lCDbTEOjU1IaU0qPh7HmFbyxLwOb2ixgopQ== 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=JCUzpVnKe9mKgZxUVvyIouAMvqyMqIRGX9biAUy4exk=; b=DRrEnM59b+/sjrLEV82C/G3R+9ECwW6+6rEyFnAbo5XSBCVQDPMwafvwh8jj7PYMAZdswEJUj7TX4cKPEokqSWXnJgN/73+HBCLjM9xTyqm4ZDgq/Bl700W3CTBZ/zFrxCAbksRpQKVuoahOIK5hlNb7czzMoC13rVL1Tx+NGvs= Received: from DUZPR01CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::7) by GVXP190MB1989.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:28 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::3c) by DUZPR01CA0014.outlook.office365.com (2603:10a6:10:3c3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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, Oleksandr Kolomeiets Subject: [PATCH v5 38/80] net/ntnic: add flow flush Date: Wed, 30 Oct 2024 22:38:45 +0100 Message-ID: <20241030213940.3470062-39-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB1989:EE_ X-MS-Office365-Filtering-Correlation-Id: a58b637d-60f1-4dd7-0505-08dcf92b788a 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: CMMHjNFJWJMGDvANl7d/Dv1XBmbHg4/DTo4lw9D9xJqwvSg2DtljtLLDpB5BdfFATCgd1p9RoxSCSZS4ajtbEk7U45289/8lO2OcMaaYxsZ9vJCjZTz/lMsMXKf64GfMvh85d/kGdCbK2ryW+CYDksgK366bx2tbwf5b+I4TwwKXl0u+Oam2dlSP29kloUMYVJRLJ0NmSzqIc/EHU/6UHaevzQUcMRzI2vkObJW6S6iLYt2Z4A7Db5kEMdroRvgndFCidYrT/bHl0/v3HtjirF9QchDOZoeAO+VpdtG77feXUGnw9U6mu1XlgnRd2M84UVKy5GJx/RC7I7xrnIN1aqYnL7uXyw8TnEEMAErL3GT/zXuIDQJ9Ej9qfV9fC/Mu47zJxLnj4naIDrdlVAxnfFXxZftXm2p0+q6zfo95oiqKMqtQ5gO3cyoNkOWetRFLFHvMMeuvCbqMR9yllCWcLMPI4XX5CgfgnFFKorVafpacQH1MU+VDJ0IjpytMcq8GkJN8vJEuWFkH8PpMGJ/JyR4a9HxXwib+cj6SparXvMj8mxGP946pFUZyfFuWMlUquNNEFFcY0A1jdPfx3MpXXOw3iOmHIfuT9WpfxWHi4uVazwHTyUsz31V/+fLQ9a8cTVOOiEjhoLQstwEwP/ajK7lIyj70zd0rwm0IE+BINGXshyO294l3GGvhiFZGPBwAQLODM5aQwk2PeYSXxbZJVKPXqi6qG5sc7S5Edo95mSezpkZ5ahvls/VrOwdnkE4QEZrxeBrgKpxZSgziSQDlingeDAtsPbKt9ce7qauFQ3+jdbwHRQqGGunKMwPOKfAP9VBBY7FNMuoW5y9BuK6JS1oAg+/GzzKsOBO8Cj+fbh22poGvzdtQZOMKOF35vsBhBRw4flBxiTqFwt1rEy1T5bjF+bGeadnW/7u9hdk8fCKr2y7uATSJ3pHBsHFRz4xs8suKigqtLSEp0b8vgyufJBA95kITqHu8DtoAecyb6JeYSWX1jr17ESskg63uw4wmGAY9SHsgEiWFcRknzAC2zA1prQ9qs69ukYVBjqvob/WK1SnqCKeJyh3cml/6JdLTtDqamU+5WKymG505obtlKFX4bbR7PXyN93HxSr8+INzn91ZwB8IIN+linpHc1zE6fJwjkT2YJ1L2tUnS8qoIXUMwJTY3IFmuaEstTrR1eLxjQq6SHNgwv0ilt3LeQGigaLzrWUuLYwlrndJsh2OzChWmghEkOk066ZFdS2skGf/IdERUz4XjjIn50Z8/hV/eoZnlbIEjwnMX3ZbyHTgl9VIiNe11DjOHYvl0Aud8A48nvqPgvA1/QvbqNz3mxzO0+osQSpiMfxD4YhAyRHmDpanL8R0eX+72lrrm5nn9ItIBLZodQIvYM9R9A4mXChOZ5+CYWZjbU/nSj7nps+stmA== 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: UzSBu5eAXKWu5KPal9tbfyNukIBhlljA/qMpGBgjLmkSiXYhQ30b3lqmoD6l/InR3mFTvukabps8ONd2r72jCWLeKpapMT5RULAnWPKvt1NCJewJtI1YkGQmtCYXWk+MfhLWM8f/K0xmKEMWIwpXNE4/H2Aw8tOHzKSZ+hjOPSaHgukXxuMzxgzVoLJ4OhHv/k9sigpnQLerOqnaaWJEatn/Im2P5bp0Sje7S7/8dcW6G09QnloZLS134YhMDG1V3FrHFCYHSpkp4T1sYVWz3czJdKRq/zjWY9dKnly63q3igVAStUVlFtiq1OWEltiMNElNAvVVisGc9jQeHMH1CFgsbtolpwmr/C3kyBZiCgTa96+OclVRQgvVkLEiu250F5QH8JU5NCUiw5xoLoQ4ogRbJd9dKyNYnVUZxoHfUrM8DooD6P9cCwy5u7aeflS2AgaaDKSDOHlgepjhMvbXI8x9NjKKv0E48y+r5xhkavvo8dnONPTLiUzhFVx+orPgWKd/vccqOHs82nFRlWoGEJ36dWeDp0LbSBT+2xjLYa+GSTUg1+CoF86pvJGG7DSAj1V9JEk+UIQuJu1r+roWJSmimjBQbhczc0BPMn3Ni7XfQt8AEw6F+g1T71N1PHt5nWU84Bo4c2ewJQmfc+NUjxYQhqqFBI2k88K2IXSc/gw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:27.8020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a58b637d-60f1-4dd7-0505-08dcf92b788a X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB1989 X-BESS-ID: 1730324431-302901-12798-43472-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaWlhZAVgZQ0MDE1MI0zTzF1M zYwiI5ySTV0DTFItUYSJkYWVoYWSrVxgIAiT1A90EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 support 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 ec91d08e27..fc9c68ed1a 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -251,6 +251,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 */ @@ -1013,6 +1025,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 2d3df62cda..0232954bec 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 @@ -3631,6 +3631,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; @@ -4391,6 +4433,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 Wed Oct 30 21:38: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: 147805 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 F00C745BCC; Wed, 30 Oct 2024 22:44:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 33948434F8; Wed, 30 Oct 2024 22:41:40 +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 AB50B43400 for ; Wed, 30 Oct 2024 22:40:34 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tp7fOp4dzsLK1ILxp0C5JvwfZBOARNZUzSzY/Jwe/vhwaBPpmMOhSRktLggdcdPeHzjDCw2+IQINq7sDoribwxNqX9lQhuLg79gQuZT6YwKKDhBWju2rS8FEGRDv4NmLmqQmhCk23KMAxpdIYx2jNUJmJ6degGXSTpEm2/JWdEJQKL9wNinWp0bBJKIRnvSwgrQ/9e1Spidkl9tKj2Xvgtgg/uySD38orQEr5CQ6oQWFrNTzty0aEnx8BV38UX8VeASQNjZZs66MxXvd4ChP9zmR4eblrVGvB4/ihqBC3p10yF71P7NQRESvSezhCOMALF/sEw2vdPdZV5PM+hIK1g== 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=Sazj7i0zLWm18uoNwqUyMjnKQxBNfcQ6GP+dTDhQFI5IIpy+iHINw205g1PDmWGZ7O4uEHGhy5DJsjKYYNkw6slGClX0ZlLXp6SVXeVoayfQ9tRD6JWJ9qMcDZLexZdK6WqDzlIHCxlCnHYbl/y4Th6UMqiV3MmIsttmnDMT1zqeYJq4eL7QmqqxsrwZ3ewQ8lSZQyRzy9x/PkN9KnoNPJw75xl3YD96OD8s3H7fVmIxX23uYOD1NbX6wp57ciTqnL1nz1qWR9bzSEfUfsgEL3JAQ7U1sh/Ly/YJNRqb8aRtCvzV2MUfmjTZebDL71e9BMePel1GBdnawTeKofJ7eQ== 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=ftSHrfmaPlWaK9cJqVA8UDGCLq1y4kl2Qud7KGTSdJ44iTzpqnG5Ghc7mCijv/J9E+bvksyj9vk6yYMGrL6zBf5m+sN4bil8C+GKGM7ofrb3t17AAAOkAMBmRLzjXTLKFlPBd9fef1P2bZrjhNOfolntvV/Lubo9rizceXhswcA= Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by AS8P190MB1079.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:29 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::a0) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 Subject: [PATCH v5 39/80] net/ntnic: add GMF (Generic MAC Feeder) module Date: Wed, 30 Oct 2024 22:38:46 +0100 Message-ID: <20241030213940.3470062-40-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS8P190MB1079:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f9e6916-b239-4ff9-c176-08dcf92b7948 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: NFn9zvy1udcuBY2SIibU/xEnOP4Dxs1PKrAmYQk/JXSwu5NS6cL9H82zPwuzTwVn7FHDoGeHOx01IORIrPqqAY978hXS7ffm7Ziee20bmOojenVYEqvnQETaZUgcZSB4rxk/6HGT1BpwF3ccCSZXGY/RNh8SqtSEkKKIjb2PTCSA31AoIV71gGR+R1hsRvTD/A69qfLw/EJKJs1hBX3bGFx7yXV7BzEMngF+JD5gBaF+2Nj7yBvRtUSu4dBBZNpnRjwQRw7rqu8nejKD8jpu5AaDwtHqbdVlSCpl88SryDPE0dl6WN9Sln+s/BHDfgmpEf8mtH743c9s/4XoXDRnhHSKrU6dAlC0s6umNaSyOe9moMLdVgOLnZ9ch6oy2kyn3Pa2lGaiR0TABej0RMXLiOZxzaMzLS3Dw+oLDNGMhFfru89bXnYF1/AiZULjYiIb8SqWccrcq0BFuAkdR5WqKGx89AAwVCrrzqAoldLVw6VxfBLlJj/PV2UB//e2Y8Adc2AAp4SbwcJV/Ybu/Pj1SUHh8tIF9H9HN/8RbkW8pceADBLZvxDV0LcbB1343OjXCXDz/cWYcVdcxSFsZrzZnX5QKS9NUON1fgeTLmde5qv7JydBErfnJL2bHhsm9gw8KbdJN/MNbYUIH93YVjj2apan7xx1dwoPony0wNuL8a1VZJpBebeA7t/OVh+uDllEB9GV3GPtmIG3AKs5BkvV3SqAiEeGJrZKI/WprWlt4ZV8tS2Td0BlHEzCJN4APp9HCzBGORXL2NjuuL/l+nMrJNJBd2O+7T2c0UHn2Poi36UNMtlpV2JBVqRL2XFgb52pF3dzPNH8Gp8a0jfsUmO7cEBFNvAlNJ4KxBXwOYux1H4/50ojgYaJV9CqUi0EKwWIue97XFrOxJPuU0c2jxzxtdJYsqfVZgcb5wVKnlqYeqaCx07fZkxS9qOLTVb1oKSyw+g0O32rHjyc0xxijL0wGKa+KrPxLEYqg4Adh2+FcHlq26Gf6aNCM9FZwit18FuvtUFwDAWPWtf58nmCK2Q/+CnaU2usf3cAgo9wrEICEfq92kjfV1/z5a5lMIVsvOHch550Gxyq3N+XsiSGEen6gTUwMMBqr8eHzX4H265EFIt6IAC4eRw46CET/clTi3EaWU5yd6RGL7Wd5//qhNQvkxjg/7zyzIw3twDdkly13mPbaUaiX6NleL7Z+DDZp2sQTIBK2IhzWF5XWhU9wBYp4SrJw5C/M4a7YmiZl4oqU4HiJAI7LHRCcpSY16CE3/RAsAD19X/DlXZgy2U4NLM+oilL6cDChEFuTtdbfEGhi/ICaSRbUNc26n8MX20FISZo173SQCkOkVqFiApODMNdMws5POcqnf/3L3LfDhWAbqC4qcOl8nsb5pZqZiWGa5PxTSv3AuXvTV6/zgLI8jk21w== 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: qiTDRwDqjragtU/Rf0Y2ved11Kn/7nvt+EqjXOl8mO/RuF0DCFXtGVXAdgrn/LzjMZPAHmabqOp8Wg0mddAdIAb4jnrb02TXHx21LTh4anU/ytTmM0mVpNgzCdJF6FkHaUOsN9hOOaIbWJKhxfDlJR+cQ9ES17IATCUaR7ICJZym6x395TWX5PO5PshR/WGPHu40OaLC2MxnvW8P/Al0kj2KT73iyrMKzYrLdvoYhZPEHW2ZCR7fB0Vl2hT7Fa212ZNk0upu4Rj+xzNTXR0L+uaa/IiaUela8cPf7E7b5UVMorjeMR+xSPfBivTecmxGfFs9M37ZiwftO/EX0OolQXlF6xkRSuq6aodMyq+KbQxZhTNynV58lGtQvXhRGa3zqpWPZOQmCrkLMbdMPdBi8nbk226BRO4vbehDx3/zDkGoBZCFzbnUtILRkPsaXQBQErupot2++ff1uqFh+4THlIanW745OPcQ8f/lSeB5AMdjxDX+XjjBY96NwbesHroc6zCCsfNq9Ne/d2M7/S3KNZABlCYjcehheDKAAgVNdoY9+4dhySJdCUS6dch8D7/vYmSsPBaQCacdZJ618hHa3UmJBaGKdlXEMM583rtJlTcapVBNAA1hjljUajKfYFB8/ehosYJlrGrQIMxoRNZL5fZ/Dew1Ja231Fv+lFVOmI8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:29.0832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f9e6916-b239-4ff9-c176-08dcf92b7948 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1079 X-BESS-ID: 1730324431-304433-12634-44629-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.173 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.260091 [from cloudscan20-80.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 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 Wed Oct 30 21:38: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: 147806 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 DDDF145BCC; Wed, 30 Oct 2024 22:44:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57FE3434E3; Wed, 30 Oct 2024 22:41:41 +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 F228D434CB for ; Wed, 30 Oct 2024 22:40:36 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TVgVCNLu39FWHv2uS32Yqx6DuC6X4JirgMaODga/IF58JUawotKgSw3Qf+dtmlLX8VsmjOfJIJRtfd2zTPnPIuETCJqgXht/+vLURk0ysMYa2eMnE42wRSZzpxcuE9H0ahtZ66nVbgYTj7N8LVX0LUjEGL+SZNvyJNVQzJMxT2Rbzlr1JYDFpe2txY3faxwLEIrdUObYCeOVVFWoJojhAXQKP7XwMtsRc+3yiV2VWOkmp5n+NHV/zmTji/GvxNsvCyFwe4pI49kSaUFQtyCkYCegnoWLpz5F7T4kj2t5VaO+DCibWiPQ+JTpIILt2gC52GyslBVZ/liht+YdP+opTA== 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=FILQPqyjwO5OTfcSfW8UebrS9V+n3166TwarUfpJClj8v20VZtBHTM1ML8GemjVhUzcmJvfT1Z57IcLPzCOPro7rvqDk0RwDVhMhpJGst4enPb14yIXrukYAfPrHYc4zJnwOoOnUbeMBqgfWILuU5eWCsGWFYgdsreK8d99Qp0W7pvj4zMXZbRfMXF3MH5EbamDrsl/k29Me7yLKeRDwfIHfmmAW7c95ktRQy/AL0CLi9ZgY50ixjDTnA8ZsctRLgj3BEwV5IwEZVoDUVCkcOCj2KqT40BxqytlsQhKswDBE94aVZGMo1AM7E4o59RWxeJ1MWLT8SNkADiZN1oCKuA== 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=Of3L4b6ndI05zN5EA93EQk8Nu752GxIe7/stWFKMBktngPwuoIyYmS4oOcVrZOCHt6waNBCLRWSVxBVGOVOe5n1BcZswQPqCkfYx/gBfhoT4E+gajHBEvaI21KOc8p8C8V4rF3r7G/cXFXXyfQsKk1XYHkxRl7k8gu1rbkI6bpM= Received: from DUZPR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::13) by GV1P190MB1946.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:55::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Wed, 30 Oct 2024 21:40:30 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::8) by DUZPR01CA0006.outlook.office365.com (2603:10a6:10:3c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 40/80] net/ntnic: sort FPGA registers alphanumerically Date: Wed, 30 Oct 2024 22:38:47 +0100 Message-ID: <20241030213940.3470062-41-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1P190MB1946:EE_ X-MS-Office365-Filtering-Correlation-Id: 294a8372-c284-4b0e-6cb4-08dcf92b79d5 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: rwFxO1dohrWyQSSWvYWchbknELENzZ5hqAmjBpkQ+CuS0idMsI4qHxTtEYMUCms99SdPhBLz2IqNRZsJEoiYFkHgz4i+ntCNmkAO1eTko5HHZnpSiazU1iM2gfs2cPdH2xBNZ4IPpxim6MEo0AdmvaccKDx4yhqys4zA5Irq4jeLBBhGL4/2EcyhBfAVnmuf6LAHdUh9zoJIb/b7V8FyH/bhLs5UfkH8b9h09ORkeAGv7V7+f7R3mlxWsyUeo8kl2K/rHc2eZxc/rcwnkGNSgalN7CT7mNFPiMaK0ztXnRPeS2Ul02LpSHpazVjqziS8W0w1KXdmUwqGExKb5eo2wuZqKTNxU26BxzUD0rpPtRrbYP3TNdo2jy0s3tpRSLOivQ2PRCm3tQ8oAlNU6qQyxsCRuiCSSYZSe74+ZiJTDnqod05IGEuQtUFwhlJrGcOJG4ZAke+gYraxm7lbqFDtKONw70tTHg4i4mRIWBp2MtZFCto4lkgzXPbm/sdqCKaJAo9vCN5ffDQLZjU7I8/A2NItC76KPxwQV4vrNm5b3j4CPe/nD3lhR3S8IW5scYXj+W2rCEZGBOBPvB93bcxVBdGVXhnMZ/v1Yh2xH5/uPWqFVTKtq7+NEnX/n5Mm29suasJS4NhYkqk80qYwkHuYOtchox79F5ix3NCybI3DnVsy4t7+tM3fQWnaV2zg0KraHTw7agxTdIvCBYZmcmN2k6e+lkI25m5SWmFOaFAei0+rlywsUei5l5nnH8oSj7SzPSzAv9BKsTos9AyxrPxjjzIuRpP3HXK1sP2NpvswUajW/TyVk87XBeTZyntS1hGl36pqvjdcS2/hu5U7W5KNRqXvCw9hl7sAqKpyIEwQ5F8gq+bUWQJxln3LrsDMIQuXJCIeVh1n3thLptcUaAUAtAdiFMuA2Mk7j4ZV1m6vMmTJ0T4K/EVCtX1EBwPKXrj+3lq1X4RITq0FkJ54ggGwjGB4dYImMvwpIo86RJAikPUuzgGGS8bfc7ToO2pVHlk0BGuUgbPi9vk2zIAfU6DtGowAwrDDndsyf3T5ybET5JgAG/RZ0qfBbvPlX9XEywyXMzd57zl1j4CrNVbdZ0pWr4Nt5kaKa8SuBJcpPOUYUGKUWmpqdH7RHEO96Muo7gEB2HKT8/8iOTXpgG7I6GS1hekgZ1o0nBwPygjrt4hqwdbY/WcTSb6vCmEc2Jz/7OvI3pj8I8oVBDsndf1TqTLnUJ8sUG5kRCuLN+IbVR1TVGy/hVk3TNw3YLbgl1MsLAuMBIv1MfLFI9GcF3X31gaB5C7/4skXtlwSqx1z88HBNscExXGxZ5iFWLhMmF6PC0zeZ8jVeC3xpYI0I9JPalphj+TUzzaqW+qkZDRqp/jKa3Qn/GdVSMteV00u824LEAR6rosO6wyxjjuJjTGw029Q9A== 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: IpntVsBjrUdiwDz5HVgV0KTu5rtBeHl4tjETQZJf/6TdY220TsHWAm9UpS4p603VE/sF3PZVcbvJ2S3ofiNoq+RcVzmsTgrC65u/USLfd0SLG/Wy1jmJ425rmcb/594ZPDI4wRcaliEMXTQHpbIOQXBTn0JtaC4y+ShgYyFldQ+7gxtfcYnHZG1AaOIQegXZmPIBzeoEIydS3xJ5DOajtKOfJ52gryTo1NqTpQu5BsgLXgmcRiQO0+dxiRHoFU5GzxnRyg9nwwDlXRcGInMiJySF1oY+Q4/0q47uEqY555LbgvBQeCFg+CYQGUlHGOu/wIBMfg1mKL1r1g58YNwZY3/oGurgfyEMwCCjP2UV8n7MI3kurZLnwMnPlyLzBp2jAcchq1PXyp41eiomX5HOGlve4i70hgcZPxWU/CeKaUNPEE8cmhnXX2QDMweFRVRD/0X4EwYECJlFuPi3Hru1zBmRxpsNdjkyEak2tly5DxtdNFcRX4hnwQVVs/qKVxNVhH9fJ1yYr1hGJ0BB/Vg9dq54iBRvnSCb5JkOIBgAmaqIOofWBFW1yscJEB+JX9+hu529jC5hKXEOtxojX3QqxmbTY2vb6lTlt+IOJJJLK8paKzjr4cUDqLOhHoXrVgBYLhSZ2nkMFFQjg44x7xmfifVcXXM3wQ7eEL94mxOHioI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:29.9582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 294a8372-c284-4b0e-6cb4-08dcf92b79d5 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB1946 X-BESS-ID: 1730324431-302901-12799-43474-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.175 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.260091 [from cloudscan15-25.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 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 Wed Oct 30 21:38: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: 147807 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 3938645BCC; Wed, 30 Oct 2024 22:44:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75DE143503; Wed, 30 Oct 2024 22:41:42 +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 60AAF434D5 for ; Wed, 30 Oct 2024 22:40:37 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2237.outbound.protection.outlook.com [104.47.51.237]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YmMm5fsjGTf8JdnBn4jtmNhJXucodZQcJOZDRZNHYrfqEm7twj7sfnVf1XPmoDiNW2JeLTEYPXPRu4E+lXw9n6suN0tf4f9L743swa7F1kSSzCFLLwWGJxIFUmo/jlhifnId1CUd4JxVHXC5fmix7RbhWnDo0kbBx5Mt/mw7BSQTijdlD/1M53pUXQZ1z7IcX89j9DREADiTHeonpIzKwdieILjil8wJBmwiaAFf31rzWjbFN/t5tOMUiMblLgutWokNH1KwG4ySaDezTCPrdKMh1D32uz1zGVs6UeYniuAcsYCwPcEP4pf1UGtmUTN60b9uICjdxpjO4EeRShy9Eg== 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=BnbMQfY1Sa91W4EZVR03uYHgFvNIUwP21OKtLS7VO7Dd8ZJggPEnIjZOK69x9e4br5Cqwbl7XLQEqrfsofrHrKNQFV+zpkGixe79dieC4YwEZcnEC0Nxa0S7o/F4u+nv7d2eOHVIjN7OvwHC/5LtJqoZ/+UnQ6RuRLLbbdjznFdC6v/hDy3kffVxObcqQgxzcIqZWQkJsMpsKdnuPSnfGCLq6MsSCdqMArw/M0Pkb4wKIrpBPlJDq1Woszw9QatDeroveI7OtafdpbpNwUF2InHr3dUgTUan4MMOOhDgNNuBo4r3yO9XgCv1zS3FQ3Z4WbumzKi5wFSE2xnRj7tgYA== 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=i47yMxCT0bmgndPG/ZyWmojTk2ST5fJ/T9BFZG2ssCvhvDDwWPLrchs16aCCBAQbVeb1O1dqL4O22nRpa4y1Ra5wfLon0fqr3zLZeTy2/vuc0Z8xZY56ryxJiT76M/FcpVe3JDbdI0zEgRCucC6Aazdqp59cxUWFSy9CWBS7M2c= Received: from DUZPR01CA0001.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::10) by VI0P190MB2235.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:25c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:40:31 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::9d) by DUZPR01CA0001.outlook.office365.com (2603:10a6:10:3c3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:31 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:31 +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 v5 41/80] net/ntnic: add CSU module registers Date: Wed, 30 Oct 2024 22:38:48 +0100 Message-ID: <20241030213940.3470062-42-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|VI0P190MB2235:EE_ X-MS-Office365-Filtering-Correlation-Id: 9848f6ac-155e-40ea-7894-08dcf92b7a83 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: Td54KfWgR+O+gcpvM9+Es2dX3o5tCiM+60fC+bGnaODQJWJXwVH9dnrIoxnlnEAkgQdGmvLtwJNlMK8aj9jrDCvJwlMqRlQo+L99usBZGkMRUQ0H3Z2dIDNeoMEk3ejUACyRkYf12qcxmmf+FvANT0rbJQlR0MilaEUqy+fdchYiHJs5X9zyD5vtn63xb+6Sy0fbabSD1WNGU512aycJ6PxiyavoQ7Ev2kB4ZVDyhGexvJEqf6zXx3OKiijnSK8WZZPelRB/m7qlG2fgTKmm1jG/J8518Y1vF8ev5t3srU1U306HLOpCz4QixCJK8gTOnoDJnZfl6FW1cKPXTGItUW5DoMMzIfPihsKJrklcrLYKF/LzSGsxUlBNz0RMaXnIeyYKLMCzSkyyW7vY/bqZefkAophaIMex1S0X6kkyUaENIw2az6P+hmpalDgfUPjvYwZeR2N68+lUNdMrol9+mdihC8UF4Hijs8mZwUDPMIaWWFmGoBh21xH/9rpJqJpbbgHBtzS2Tp53ZRYfHlcyArOtOUWTQOEPRS073QRLeasQDnFypYyCE+SR7YHS9UkPASyBZv9SAATxr5BivJU0rh5ms0t9MZhWFYwToWryoXZfycaNcXD1qORyVvHLdx5cQeOQK7I5DLF0QZpOAPj0zBTWxwKwtYia6tTrKrXe3yXS7KffXAcSvAJ8Hvbpnm2goIG/nNOPjSMRLM3/YX0rO0Vv4kX0oGggdXdl3TcTMRZos7Omti0vXqk4WUvJUasWQ6r8vNuCNsqAfoRdTXuk6rIbFePsmgKcgYtJuPnm9EPUI8Koa30JBdfPOGmX4ft9MnoN+Q7WJn18uIKMGwtqogaU/1KK9+frniXF8w/JYsJpbmYOT0DOkom09QSIQ1kYH61dEpkmRFbgertF8uKBK1gB3R7BIk3oyjCemYsElZfIAhfW9yF3oMiYaEDXglQuelTn6gI93npNBK9XrAwAskoP2t+Qnhcg3aSNn3+/UsxA2V14j3ISFUeXhV9n7+y/GJn8I9pz2bMutEzN+JO3189E9skbrr5bMRwYySn8BTGfcAyK37Zkyvt9LXwzKXffiyABDbNr9pWH+TwiShTO8Z7H/B5Y1PdUcv5Rh/Mf3pUF4jexkv5yVKRBSh4NcER6+RLrK5NobMoybX2GMi7Q50/gMxK01p1sNmf6NpraiWuY3TZImzFHG2oFB8o9UBj2BjJklRlp0OUytsUmPH6pu54ErtXve07SXWGOVvXe97wpRKmietrYR9SZLCwxezufrqEUeR2yUPktsyYwl8nPWNBMobIcEyH1tNSs0EviqSx99swvZV0JXmh2ZTX3H+C+ZbYe/VNsHwj7sodqF/9KDo/tHb2jI0R4MGd4xybH5TX8m/Z8u/+Z94YQyad2zwkxV8i/N2YklwTW6VZF7liXcQ== 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: CU++NI/OVjam0NdGHojB3TQIyL8sN+O3A4l4iZJJrgw/Lywxk4hP2KXCTVYPuceJMmDQQpEva8I6J6r0cIQlnUPhx6iR+62SBMsjEwF9OnJgMsXHEn07NW1oF5XOUec5kb3xiE/wai2MMMYRd/N36PrfVGYid5S0C67DmGbeJ6Ceozz53q7Lm5v+vBu/z86GyKJEINmXO/aifhTqAHHp762SNaMASUJ0RR7ET2fF4//HRv4yMWSEbK0kzmpYLjRz/QE9dT/awr8FdmA7VE/VR7IFADLHYNoAmEYx+YOHgFPz92TIPrILn2HocS+RMoY8ojZRTqyWxy+F40mT4ob3GtShIQMYC9HH568Nfxwb6CW2K4ZOAIzkaopLm8PQ04sPjPAasr4vTO+dadwkp11FQ7xxartz+SzwYaI2uqa1sVIhScbV3PXzBP5YRHNVImyWjQMb6iA4/s13oLswGxZYPO5f5AIxh4QBKYnO7B2z962rhJzPbAdsVbViQEuanT5JlrMzc0d8sZ9zCBs2z2P8+4Cq3bNbA413IPyTOlcTYdk/tThXlbH4oaDYn53K3u1kwlXX3v72xpkac69XHOFeA+mg74KyV3th+PgTTU6ddGGBIv5ZzJKQQO+3ajC4NH/S7/uon7hyMG4AduOmbEjNrDEm8sY2KXYd7RuZcyFKsEE= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:31.1145 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9848f6ac-155e-40ea-7894-08dcf92b7a83 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0P190MB2235 X-BESS-ID: 1730324434-312176-19304-20366-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.237 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.260091 [from cloudscan15-25.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 Wed Oct 30 21:38:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147808 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 5BF4D45BCC; Wed, 30 Oct 2024 22:44:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 032204344E; Wed, 30 Oct 2024 22:42:14 +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 5B075434D4 for ; Wed, 30 Oct 2024 22:40:37 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2172.outbound.protection.outlook.com [104.47.17.172]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L1wiTDfJGdl60kUrwIP906+iLHvfnVCQXAU2QJe36Wv4ixeBp4CAB+2+mYW//fG+OH3xn6tsWwfSvsUUVi+rnSFPZiwSaYQdNtvkRSi2cgU4KtNWAx0QiwzSMiCAWyITVXrZZ4lVd2/dMFLe4nuXXSmLAZGoiIFuorcyDmMwAP30oDixOkNPqXKiWbOs/ffH058MQTg7ZroSKFbDlQdei4ILdGEVkIEGYemi9Bq5ngDQUjkTJ2EALnOXCR7nbuV6Febh+pP5SofpZihXaBEIdYPHYo8UciqgWYdbSuygJu5uprjjM7pE065owK2hc71esmrz1cTRF7fCAeasvdTJ1g== 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=vmHUX41lNDg5yOU8h/aki1eQK0iYs9GOMWN2abRbmokwR970s7Grq3Mu+CTqrqwLHl9DqTy44boXP7mWnh5+vhugpxHQc28AUdNJD1zDdjjCgHBMRUsBYwdUt2J/56fa0SF2rgAlZjtNsXVv//dHU6duvS6916xLJtmKUvSbZvLsDExBqAyJV2ldSOvX2tPt22nunDXdN2yMhSIdMtZUJFKl2lim5Mn3iToVDLXEMmCsuQ8jhZOHolhW+EHoL8TFc8CM7mRnd016dXoUWuVbs52JLkUsIsHoxJkvIZTYeKA5BMJGCT1I6EJuCz9vzYRflHCTcgbevgije8RVBbXgHQ== 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=aSdevKbfRS9Gel3fXWv7Wr/9rE5yNx2SsbXiCYVoBFr8LgXVz5oRiEioAMmE6UnE9XSVaUOJJOeYc80su50CkpSSb7Mf4O6g4EIG/8DZ6o/tV10HVMKe2FmBUzHpul7trY3WMl+xmcVjRNhNJcgZEiw+YDL+B9tDguS2Dz3RCVw= Received: from DUZPR01CA0009.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::16) by PA1P190MB2097.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:45c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:32 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f1) by DUZPR01CA0009.outlook.office365.com (2603:10a6:10:3c3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 42/80] net/ntnic: add FLM module registers Date: Wed, 30 Oct 2024 22:38:49 +0100 Message-ID: <20241030213940.3470062-43-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA1P190MB2097:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c29d529-dea1-432c-975c-08dcf92b7b44 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: NykWquzTJazEoeOsBJjASTI6H+plyBCphmjTafAjq//rSE4apRtePFZLTVynDovrNKgI9LMZbaAn+n9RI5MClHzRQ9owIx4Efb/iZMWWc08cZjfeb9UrI6wH+PljQSVNo9/fEkYXgar8fX+jkaZoE/Ytm9SV1nYw3oW2W6ue9cfjXMoujcS/NcQTaZKfwXokqlTmfYrTbxoi8qpU8zUc7dofSCfr9NS//tqo5HgRI+AS4bysCxFCKU7pXAHBQqk2jbqCo66AQrbAUC1MBMMCVYsvjvNSe9Mic+LZOKhIUugerKBFnRZIjnLWrP+zLvlyWq2mjLuFKUJ5E0vxhV3EWqx99UMgvNTrWAjlRKisHgOZN0eTcLuTOM0FjDYo/vEyRIKNmL/PrcIjlUSLUGjufwze9N2fsvyfznukCfVdFdbo71NxON28bv/YfQx13tvP1fli5ijNYE2y9HXM70ZtC/ld5fbH517otrjWtMn9LB2/C+2aUbMSkql+fNObTsB/GgNbOqU8AdSRsA63gj9vJtp4zFtvogUAoPPgPUon+T6PHwfKFUaDqqvxS1rnk9xy+BxSznWwRy5gOyHAFxAoUOPTwM3TwD0ID1Ma4yYY5tN+5LC00ZyBr4IneQSrum47baAG4xXiE/NTYyznqioloEoNlOYeT+MVLoBCgKaWQe0yjPOkOiHvMeywANCze6VqZsvMjDvGXWXc71RY27jz8k/BHIGGXF6uxwnq7MK3RxvzWW7Bgu0y2DI/ObnJlPGdiXrTsNxDkC6MyDf3o+qZ6nAIxPoYDSVEprtglc26MLtMGwIxpn+kcTnc0YB+IYk0h4BfZnpbrZaVzxEOJq8ziLQB1ballHeXCyWJiWxzJZax0gSTl3s739UVlYJjHjvJuFhoLK30Zg+KQa0IHSR50BF4638it31MzCZZn/28fcYHilzqM/tK9RvWpFxj3gBIYPEQiAmy0eK0sscjqdLJvJ1kJvi168GQjnT51p4El2mD/+wPrmWzLh0RlYzTBBFFJP2LVMxgT9dldeBjuuaX5y8dIDVX6AI1nFE8Vpb49XKo1fLI2ivpcZffLqtWZqs5b7MKYbh3EcXqp5Vesjpw7Pj8pi3rjDuCJdL92P+DSDr+0A+6cVLrTmhiFSsTDQ7jVGC02Ohl77PjIcm4nj3mu3N0R/4ud57slI6O4NX0RZyP/FGDbEzwIRvSYLx7bot/nN/yJlkIMQH9RfWUTjCoSU1kwXHwMJ3e3PZK+9YY2FnItreDbI+6jZ/iz6vrEFEpkrxb431pTt/56QtNOrqoTqBTrTN4CmkT+8HVlheULNbOJONlVi9ibLHPwQ7epzUu9Jhz6qsF9O73slbQU3yJBb4VSkmuknf1tI1odXQg+44iCVXmrI9PcbsErSbtQi1DjMainJcuqGsFxT5KJFcGRw== 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: sdv6uHgP/U8VIHBYAyPsNv5qsK+/xclsaFggr1OH1HiApu6o2wZD0eYsr/T4/zLXnNVDK5YPwmDFLsDnwftPFGpOvwZX5X2ogdcIVyG43tvTznbpgwcU81/9rBk1+M3tAQOjM90rJSXIvyya92zRgeLVtzQxanCQFiFTQQ9K4yN9KW15K8ANBMtEIQR/FOMfQvoV+Rbkin1MxBokWC/DJ+udfVPeic58ArQO9Knc+g0dUDjYb6aAbFvZfxyJZnn9WFmBZm2gR5wxdhXEIRVF9m9S0HAigR45TnQxb5wTnIP8s0omrXYj6wqmQFk3NSns6v1lK9Ezb4E4eHsYiAiaXu/WyjMrLaRUFKTmT28+douOOc+Zz2VnJ2sRhhDksrsko7nk60NpT5tBXcIOjGY0QOs5UjVqGDSHEfOrYEA0NNg09T3hvSMFGivoLAUqeKpqvSR5u2alG8pYU9FwMdHhQm6rapH0WJRkBXgaThgsxncsjKiLPrikpRBjugYqn3nFJowsd1N+JzyCe3BKHSQfGc229NY9pxS9K0kW4F8Bj6Ma6cRLr8XnvUgiafhEvJyEtll+X08ij3LaYj4vaaSDrJT+wqptfJaKRtAP968sVi6X8PCjg4szJiw+yVmJhhkYpVCvTO4Jo7nLuaS7IjJSGpFmePWmiQen0TUl9SEbrD8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:32.3645 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c29d529-dea1-432c-975c-08dcf92b7b44 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1P190MB2097 X-BESS-ID: 1730324434-302901-12798-43475-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.172 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.260091 [from cloudscan15-25.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 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 Wed Oct 30 21:38:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 147809 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 1FB8245BCC; Wed, 30 Oct 2024 22:44:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C05C433E0; Wed, 30 Oct 2024 22:42:15 +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 6941A434CC for ; Wed, 30 Oct 2024 22:40:38 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XzhBQcK4oOn7m8P8357Myrnuctrgk49rwnJHQa75ZnF2JTkNvbVzMn0u4z4gKHYnJ8G/pgLdMvLQx0neYtBRiMHuqD8v+ScdP9QMxQZvq+AZOraHDGFn2R19BVk+RP/tDb8hx1K+z7zXhIThSkWIYS+HGw1qNtuyQFF3ZgSzP5wdEGtJd1/fGPixfhhwOqntIyiwHQvnIhqmP9BNVeNmWsIB4wnyYyGtOObtDjAOiFhF/GQWT8rskzK02hSb+F1m03xH+VaYPGZN0rDy2TfzasaAe/WgWmt7s1DaMU3MbAPTaMHIu2LPxn0QcQLh/LgWw/yKdScWxwuMADjliS5f4Q== 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=KLbPhRsqAZdGrYp4nsi19LkTviny+uaxlAeLfhzteh8PZ9TP10EHh6NKbdtdWVVbD3qWoiK08V4tmm4hKGbxWRSqZpFjkT1pySOOolxsBBfPUTBzost5BdHzx5mVnCd6htR+IEKNPIOZO/r/cvCYeaQwiZ2Pi8upjetH25Kp94yX7fLRVTaCqZfig06/2XTyD2xVtYIZLUhTk+l3L2sDe5lx5uFUO42Czrllw8MoQeUxaY6NiGj249nUMMmpZlZgdkcJC2a5G980JeIyZC1gtv6CTJMx5Gt01oP4ukCNOOSiOMNnkDXqD2/rUigkNH8F8WOZT957wiAe+8NSD5hz7g== 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=okYIO4qxP3Wy4ANaO4WhCQ2xCZxzvOXpA/hRDBao8EwuDBlaWdXIcpek7NyAcyZxhOEUuVZUQS5XIpmM1Z/BvHFM/wSx/9Bths0fMsQLkfnlfzPl2BlOJoliwpmvp4dMixOvD1AYAMHMf6TRpAhZjLgfrdbL+aivUlZyGQ7j4bw= Received: from DUZPR01CA0012.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::14) by PA4P190MB1103.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:34 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::fa) by DUZPR01CA0012.outlook.office365.com (2603:10a6:10:3c3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 43/80] net/ntnic: add HFU module registers Date: Wed, 30 Oct 2024 22:38:50 +0100 Message-ID: <20241030213940.3470062-44-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1103:EE_ X-MS-Office365-Filtering-Correlation-Id: 38b8f3e9-7a24-43fc-7da6-08dcf92b7beb 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: d8UjIEDWVyaVKeBlTO5tw/hk9RLZCY0eSpJ8gHx7lXkUZOeTuRfhYWU4PPQMGb+Vdg80qSJYkzJVwzc8OtfBnRHyGrG6oMNSQuf/xgCMN/C9/PXf/gLaCExDA12Gvr9AysThN29OF7gRyidyjYKCmE9Ck2dEVd+nyCDJifUW4N8hhKu5oJBE6LzQjHvIHJik6ypmrVGJTmQgdH2glACwCaPaC9Hr64wQLUZLQyd1n7zuIs2D8yUyJncCC7z7D3Vqr4+FwyRHafqgkw0xazG/zzB35WDqnk9drqM1Xkzh1M7eyrnr/PZKT84CeW1Ohlhxc//uBA7MQJbRuEzMpzGhvcZQ4sl4rmdKGWvaLJpzeHbHeFR+8HFVHnAWhZwVO7TzCLwstkdzvXGS4EPK7N63QLJaLAp5voNJgvcvG/VNCODvZxAm8HRHyEskIewbuo/nyXVjbRJ28Q4ZGKDKMdgLw9Yd6ukcBJSL7L3CPz55qtMhqIxHowuQssLSUhK4NMrya7Yr8y8Q5q6MFUqP1z9O65smtd9FlmZE1glvH8bf7Z87ww2iXWr+unzyiCZZYa3Wr7CfX+awC3XwL0nPRJhraOEmwdp+Iz4HPuaycmeol6b4LzIj4RogARNzql6GQuWtk4Ea2mW4cQPCypyablpb9m2maSMYJd7XMqpweyrEPx/zgPHsNYb4u3pD9Fea3Spo2Jtl+LzU3WjMSgYTzFYrTRXFebKNXzeWaFNSGcjjVcDdbxjWlTStl+JCIYA3GPZKadecBjpE7Gm9eTmzOGbtBCvtVpSZtQaCOIKSiawsNraP8N1dd5qdqo6VxbLdTvsYZxztLyK/OzxCUcBovsQK1QZz+lyIJnzfH1GPowhBqasfeSgJ4OEtdxcdy+nOvno8YoDMbWzjKwL5sZVL3OPRJjPCvDpuqexTY8MzzlOgkuNOYyRkoAiR3d/rgH3hSgQi+RX+/aUv3+CxS5ec+OvUsTAPGKo+Or2eqDFnlZwbOlBZuLCejuEb1gLDzyxuVvwEbOGfNIbMX8YMmk14jK0q3r1IQ6Q+EDBN/B7rSr5+4fHukDdgVTDHmCmedDgvEtN+tkZ+bXTjzHMD5qFYLP/0ENFT3Z2rTp23q0It0lsZ6I0BfSlf5qwABZk03RjTiq5Z3tsp54bCXeNONPG1+AdxGihfq1uK/IVqVBLmlw72uWIA4MLlzMQtFGm5SiE2RU6pUqUW8a9NGaQAmQMDNPQ1IErMB81Nqkh6o20dGVLAY9nHV9bv8MSDAs7v5ZfVoUKybohWKFyi1jyvWRse7Cio6g1MUM9UPf6edxA9wv8rdWfysJnIfaxGamiBQb4g6ZqoERTgjlG33pzJnHFEAdjYaVpl0HIifvh/JCdOYsOlXjiwagHGG5ev0ip4Je2eVNFd1qjSD9Nms1SBaZX1ANkguA== 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: Ye9YKqzmw9YBmEn5qQHAjlfiErd8FYSbZARKZgtwJvSp6hOBi4u/xwmtckrYTIFj4i1udNUWFxO1q6tqoXldmDqbkmkPhj1Rqg9CCqvMWghgpf7Tx1Pn22Jz5OKhfP7GDnstkJYrLaJ96Rc7knNx4cGvcTob+FXxK6GTasnW7aR2ZV9DBmMh6m7nEUUK9JFxIUJZ5GHmtMvz3J6RkBDrEf0mEuzmW5tJ+YGpFj3aGaLfQ8+bIC0ke9PpUrsS8dwsZ0S0KDKWSamYEI/KPMUTUrhEr4rXjwzVFZpqSzZ05NHMoJRgqT4/okeL8wIDgh+HLT9YeRrDwY7NhMxnw0QkBCNydTzq+PEuBxLUeU6igTG21Xcsr53MiuvzCdIGXB5DjvqLq4Uz52tFLsbDX2cF3eSTPE89MchKst1MMzLP0aAkF4m8COQIPSlr00Fkq/fw4wFUtN1cmUag0JHiG4m9XKW51thGv63rPz8yEwSvgZ5qp30pnTv8ggRaBqin9ragcYyvkc2Xjw/HRiLqewAhtaDAxnXDC33I+91ePjXF4zOMtUewPYd4sUM1UICWGsN66SzyOzgmfdMVDA30RgrSzR329iB/ktNdbg+UwBAOBxlmFJKNMREf4JdfrVJGC5vggAHk0n89hh1YtsEGPbrsh2iJf3wZ3+gNx6LUdSmlXMs= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:33.3958 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38b8f3e9-7a24-43fc-7da6-08dcf92b7beb X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1103 X-BESS-ID: 1730324435-304433-12636-44633-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.177 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.260091 [from cloudscan15-95.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: 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 @@