From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0EF0E45BA3; Tue, 22 Oct 2024 19:00:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2E1240E3A; Tue, 22 Oct 2024 18:56:55 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id DC951402E1 for ; Tue, 22 Oct 2024 18:56:39 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xRiegrJeAZ3RTJagTM/Gc4FBkwkGp/0ciOicGuXvP9yF7Vp/843lhoTSJRpovbmY9Su39xpJ4NK25NwMxA1mQ/U/3AfLtu6l7h95VBKy94E8ABoNKGKAtNp8h0V0ryKqL4iMZCybnPgUXIkgL7h1TuAMID6rpt/KA9yMwv7Tkl6OzYm8gAep7UuQZkmn+YWun8MEM7NhbSqqYYkXHbAvafowHQkvGAY2eVhgxscw9r1Rb3TKq/Be9dNd3np8wzXQKB2dKc771SXNRmXPc1EWcBv5PwWTbVR+BTckgCkTaXmNUWjhqrhtKsKutON21lABxmPnGcYxPkQ4E5u2DcIY6g== 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=q+6S+jmHNVhFEarVk5VGzHHigkA8ue4iyJmPRS57PkY=; b=aBxGuawSetYXlDjAwycnrxTuclmVERR1a7uculDhbace4uiLXrKVoFe9hQnVlhpEHCK9tEf9Xm1BQQDecSU2LeqFToQu8r/Oj8hbdvrxCymf4vIdPpth6y0LQh2yVBnNCmrtRwhWv6VAF26rsrTYMEwVHN+KGvhdhNSjZxz2fgKDOu//6zjNEvNnSeAMWlVR9JEfDcwyXhywoQVzp+/FmUCvL7cekl6WykB+qqe/18Cy7jBJh9ixwxRn12ZrsOdZF5JWxlfGyb+6z/yp7HZ5dKZJoVAXygOVXjVT6WTOrAp2iDU7eTxsVXwW02po0v5V0VoVLM9wmQM0nW6vwZfgBw== 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=q+6S+jmHNVhFEarVk5VGzHHigkA8ue4iyJmPRS57PkY=; b=EclSIasg2QWgM2d5pZT1nenc6OlUM07TuOIIvLOiQ3IloGVLUbtXh/8dgRQ0BXhBAqPHAZrqMKzLpyk3eiTE9w3PE3RBo3/Zgy5QexMTMxUNBhs0tokLCOSxjMV/MoCfzlhz6e3CtR6Bjit81Rbph0kr8uc/XX7G+3bIiaxwMqU= Received: from DB9PR06CA0006.eurprd06.prod.outlook.com (2603:10a6:10:1db::11) by AS4P190MB1733.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Tue, 22 Oct 2024 16:56:34 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::49) by DB9PR06CA0006.outlook.office365.com (2603:10a6:10:1db::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:34 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org, Danylo Vodopianov Subject: [PATCH v2 32/73] net/ntnic: add TPE module Date: Tue, 22 Oct 2024 18:54:49 +0200 Message-ID: <20241022165541.3186140-33-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|AS4P190MB1733:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 480f04f8-148f-491d-f64c-08dcf2ba7c78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hHWZb8f4CH5tVLTuuMWRPHM4IzH88g79gZxHU0FTxNzO+E7Rcv8vZH5HCN5H?= =?us-ascii?Q?KoaAf0CDycDQcagKhmeICJKCVRfBBicJkhgsowAomyDv2IJK3t9PmlLE5hJZ?= =?us-ascii?Q?t52YDybcrBzXMIM6hnv2gyrkctZGAujwp/wF7fN1ouMUM9QR1+7FW1AxFUkS?= =?us-ascii?Q?mkOToVFIheTDGIhOapzusWKgvt44ZRl40hfxHgoSXZbv6VgkVamsj2a1sSso?= =?us-ascii?Q?MtIzQ5vG0bMGuQn/r+1AubJB16ExjF0zuefZTGrcWE4lQPlF3VvGeDgZkxL1?= =?us-ascii?Q?xk/prxNIojZrFLA8TZI3cGcllHbwwTtRprafCbnXsJv2Qqk9I4er/W32GNt+?= =?us-ascii?Q?dKKNsePDQuANV8IeTLGdNip01fW+kuyLaeVyn3HLtGCzPbP9LiUeQuPIP8WP?= =?us-ascii?Q?72jjcLOdxzZ6avj/EfURhsXXKcuYWho+qQxnRqsTJG8l/QZs+0K8kkDc+Qux?= =?us-ascii?Q?F3JQTMEXOqYxGc0hhH21YuqcF/ezrawHsnDkjfaRsgijyH60uirU8cL6KXGf?= =?us-ascii?Q?1MeknhWD4fnWdfUIo0IZjLRD7/mAhGjEVZ/XtG0ywCnzUfkn2yU92hJR03U5?= =?us-ascii?Q?LkjYv/uuhoYr6FnvB7nzouAJpH3e7axEWW6XnSGODJc109EWqMhW8g5Xy8Kj?= =?us-ascii?Q?yD4LeuS2HCENW+wlxIW7ndK/x7k3HmRG3vCwztX/0hWsqFRqsRNlwpmxFJij?= =?us-ascii?Q?PCqxDXxBabApHJUHYaiD+Q7N/pb3rfmowd7S5bX/1zWXy88x29wyVfFpnvYG?= =?us-ascii?Q?F8/81s7LlKVE3rdnH5tRMWpc0D0lUEVwBuFCi+j8jGX3p+An1Lt2LBtCvgEL?= =?us-ascii?Q?mOW8Pp9AgL/19UkVtyjJSOo5m5iqa4zzpFieQWxIDiir3lpued+hlLmrx0hp?= =?us-ascii?Q?HGS7Uq2P9dKPZgQr5Ezg7025ePO5zhjqFQ6xplODlqzcoON4KulbtKVebPnD?= =?us-ascii?Q?KLyjRWO/ONCnZPSGF0+x4wJ8JTLr0N/cyJXd6oNtNOhtd3mUIGynDsPHg7C2?= =?us-ascii?Q?p/+/izIl6iN/Yw76PXJce8c1azmazRb6f2DSflcfqAPaKA9BeRJQumoU45M5?= =?us-ascii?Q?mLdKOj2332CmLKKi8Kc955KDZ0V5vX47V94lAcM2pc9xji7g/7rmnEoMoZM8?= =?us-ascii?Q?060b2hyBa/MiXVra41bhm1xPr3Aw/KsDRZ3PCEZKQp/B5FM6emWo3BGwBSLh?= =?us-ascii?Q?bBqaMGFjHLhlhuor5aBnJHYG+VFIksV9xP32rZMIM/MSkw8ZesHu1NilaG7f?= =?us-ascii?Q?bwn4gUUzx4/mN/oaYAV5LyiHXBLS1d4czxwdXhjxMPZLHB9UwCLiSOFNfBIp?= =?us-ascii?Q?4OYIVbNaQ1qrrucuaSYyjPHYXHQK08+R2aKJVXhRtHifb8l7SNwwxzhR1qqA?= =?us-ascii?Q?1PzXcmYI3n8orC3TAVKqZ3u19WhRIi+kTYLcSlQvrImDywF9lA=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)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +k4O2fRbIAaD+a+ZQ1j34IsGI0pk0DdMVOGQ8Og18cUJwnsZees8PBkBfT1ELg3XGRx+LUa9pH46UacMFjfXyC4RbI1s3ItbcE6s63ZVqUL+hzzNO7ITDNsd15+4oZQLUBef4meyxb6L3Up/mHi8Dlsei0slJa9INoPsqy0QNAJv86dhdbL4uH7DdDymiBtTvyVhrIeLdc1rKnirVRyGJ+g/NjdcDcDN2nnlh2YNYTLsf7tvZ4+tTfzlKFec8Eai8QYeqQGD9uf3FOdvmLVOJdTTSnYLjNFTqzWNHU9LY3V2yh035amXDqrQJ55tZ1QLN9cMjdlidf5CZUyFk92uKeX978vRlDog2qg2whFregaEtuEf6v2wwyit8h/mapNodZPKMgMdYptf7awtb95IiFlQGY/BWzLcuDyC14L8T81aqUoYiF5z27D6YTCxqsa8Ez1CR6ziyo3wuXixuZjuctsk7YQn9j9CvnlMlYgLdWZQwLUZu6yodx7Szdh6N4wEoocAcQcKkkPKSAvsKTOpSnQNnqo/FMA+I8ct5JRSzRo54mHN3MFBMF6Hgx99o5kbbS9PdRwPcvRHg7kMGmTIcB9FsRqkb9s+DYzPYMCPcMtNw+A4ZzZXBuZgc1OJc5OGQdFmMdoOd8+UQGy38ttX1wedu/J2wzYt3d3F/nCjg3k= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:34.2471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 480f04f8-148f-491d-f64c-08dcf2ba7c78 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB1733 X-BESS-ID: 1729616197-304983-12656-14400-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViamJkYWQGYGUNTULMkizcjSMs 3cJDnF1MjEOCktMS05yQAoYmFhZGyuVBsLAOB4i1dCAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan15-77.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 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 ebdf68385e..35ecea28b6 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 @@ -2420,6 +2422,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; } @@ -2540,6 +2628,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 */ @@ -2848,6 +2960,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); @@ -2873,8 +2995,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 */ -- 2.45.0