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 5024645B96; Mon, 21 Oct 2024 23:08:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64D7540E3F; Mon, 21 Oct 2024 23:06:17 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 2A9D74067C for ; Mon, 21 Oct 2024 23:05:56 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2110.outbound.protection.outlook.com [104.47.18.110]) by mx-outbound46-162.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xw5xDpz5ZHsMumOpZ5Sn9SDj+wBLGd2sHLKxB4e/Rp61p+0KX0U8hpSwwLFpKR1zL1Aj+xoiAEKmcyB/R7etmiw0MrN44FBKSyWO88+7z0v18P0JzduVHIt85lV2Fn8yLlD3jwl8eUEgjw0SYHA2uDukOeOXOfgO3zkr7gJweRlJzbANmj5ER9wz273QCSxeLfoLmyGHbnNZYFmyQ/+M0/eazer2uUZ1YTVJkG57C9jBTSwWRDeHme9cKBk/YmOCshXmP5JLhX/X8GXK5X9S5p/33t6Nq0XfPe7CBFQ1OQzz8hQnX0b4GeszUsVxVO0gpglizWEHN44PLpwzB6VPfQ== 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=iVaXGEQjYh48R2v02Co3AstweF1EPOhor5Q/PUZQgSU=; b=ingAzlXUscsQpEiejVkbFIVn+IYgzp8UCqNZ8HKsxh1Ctt5FviD+oh0k3K6OEmwdLs88dN5SLmb+lCNp9+zPzpUqBIFkei5fX7dEMw++RUPi5Ul8EZx7QvPMW7JRPeHVTRezt0pdf7T2Ux0dHij0BOJvdSV4uxcFlCdX+HLwJY0e2N08jhZSR8gDZR/UxEZx3/+41ii85P4At6a5pAUy1AeAwBz4Ipw1trVf+YhrWMQM3Af1MjOqbu3jflhB1kZC43gUoq3xF7N9YA6zCnnMaOlV2csSJtJb7OxZTXM/Xs9JAeG/QhkMfqDYdd7w2amrKVbawSTmY7hRTOVE8rvqkw== 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=iVaXGEQjYh48R2v02Co3AstweF1EPOhor5Q/PUZQgSU=; b=abrVo5pmEJM4tJD1dcC0KewOOwb2N24fbH0VngJTplEAdq/IsMt0Xz1hnJ+bUzW9v1rSarUUQlsPgMf9R0+psYIxgELzUw+yzimW5uGkiN7Bh+Krfnz6z0+X6XlHPNX2OkBnxbiPnLe/fS4m/E94x82xiZll3wuWqj8X+AgTaO0= Received: from AS9PR04CA0137.eurprd04.prod.outlook.com (2603:10a6:20b:48a::12) by AS4P190MB1736.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4b0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 21:05:51 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::91) by AS9PR04CA0137.outlook.office365.com (2603:10a6:20b:48a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 21:05:51 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:05: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, Danylo Vodopianov Subject: [PATCH v1 26/73] net/ntnic: add cat module Date: Mon, 21 Oct 2024 23:04:28 +0200 Message-ID: <20241021210527.2075431-27-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|AS4P190MB1736:EE_ X-MS-Office365-Filtering-Correlation-Id: 543a8bc8-bc9a-4c16-32d5-08dcf2142532 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-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l6OHpacnRBR0RrTlZhQ2Ewd3IxbjFzaytaeWRi?= =?utf-8?B?U2c3YWhjUXNiZ01ubGpDTTlBQ29yMWxzZzlRTVVqN1h1L1g0emdadU0rZzVD?= =?utf-8?B?d2pRY2JQTGdOeTJkbE9HYzlTWXAwY21oVHlQaW83M2h5bWc9PQ==?= 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: Pyvv2KHHjOaqYKQFBT4n6txaF1Y1dSin6CTSpLBwSHdcRxyowpo5XmNVc2t0l4ZsyQXiixGXz7BUBvYpS8E9r1lcRTLoTjjoZ/YftWPYNgX+nJTYrl8cP51SaWWOU5nu9wnFAMFcxWGc4keJDxIaOM/TrV8Fu4TTJ1JGjLWII2l2oNfnR8wus2gWm1LKNEvf8LL99RLa7rgq6geQkQf4t/0aqznkAedKXJ3+y22A/auDXgCwOzKde3ySqhtP8qLuf37cDQRCnbBhOESYs9CR/WNMhBcJonsWl9zPGPkIIqHfNEsQXLC5jJ/LZpeeTwDhAtWvN6KeB46G3/PSHCD3hAlBEzfSDb/VCTHNr6CDShwrMBhts/qxQIGB3q2RqNPuqpE6X7SNdSy28y0N26Ri7qEl4htS47bOzlV+dR5B6rxZT97Fx+iNjXG+tHDrhzKR0U/JLUKLjJhpZqGCqPguYo5IBz9A1uNrDQtCBufY73/Y2P5Fhu3IWah+wYNtZcj4n+s7ueQbUBKkcIdCr7GGmTSlYqR0VVcQ3UUsrfkATu7lFOqKI64UqARiD53QDhAQPc/Y6VF08k5nxn+fccfNKIKc3mlL+UJonHnfmSc3Z74nUEdVbUGHRDqBi4HyRDVfn2y5NgwZac51AFYMho6ifiRxgTG9h/X+vhLYm6YbYME= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:51.5519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 543a8bc8-bc9a-4c16-32d5-08dcf2142532 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB1736 X-BESS-ID: 1729544753-311938-13027-41084-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.110 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGBpaWQGYGUNTcKNHQINXC2N Q82cLYODHZwCgxycI42TjNItXQKDnRWKk2FgDDrF2FQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan17-111.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 eb6bad07b8..4d5bcbef49 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 @@ -21,6 +21,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 { @@ -46,6 +54,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; } @@ -55,6 +71,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); @@ -69,6 +86,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; @@ -79,6 +100,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 */ /******************************************************************************/ @@ -149,3 +233,84 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct h 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 af4763ea3f..f7babec3b4 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 @@ -20,6 +20,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) @@ -2366,6 +2370,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); } @@ -2398,6 +2463,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) @@ -2432,6 +2511,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); -- 2.45.0