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 4A22E45BC0; Tue, 29 Oct 2024 18:17:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 602C143264; Tue, 29 Oct 2024 18:16:56 +0100 (CET) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id B86294325B for ; Tue, 29 Oct 2024 18:16:52 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2105.outbound.protection.outlook.com [104.47.17.105]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 17:16:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RFUf/SSbltoFD0zfUXqsJSiF3ZSZwI0jz83HPL3HPz3HjR4u22oZYP3Dz5UczOvSDrpnfXBidjJTaK5sHOSX70vmuPnKlBU34dG/T5xJItKmvkQAi6WfZzWJ7g9IQGONED9qKWBmVfFCx6rlnBgFRANbT5tndlWt1EQmmR931WS6DyHMczqFQq/R94WGenI2A6RwYnPUMbag/MscI9YdW63+WC/c1jCo+joUzWGyuWXbtntAPinG36k9cPAA+xD5M1ZE0c3pThg4rzTOhEyEj2H5+xe+JgJhbij2o1WqDpxWAdRjEkarJxgU+kvpXcDNUt2j65n4RUadqNHSfxJInQ== 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=f+4pxIwdyAncqNveILnTSyt/KxYzkjyRoxJQWXR+Hts=; b=QkLIHrdVkVeycargPY0/eEGBAPXo+cbs/nM4CuSIpPvo/ENh6iGJpad9AafLujXiaZRthootBxAz4CBDzE3D4e+qW1ZTXCatq1FhAYb8MLMVKyfb3YJElx7K9rkSnU3wvLia+I7cbZe85GEcxxYKz1QBWv+pRNF5RJs+FrlcBvP6NJxRfNpU5FqEEHsSZezh3mKRsBM9DP9NJqqHFk5rPQ42MJKU4AYrfVCvQkrHCwBhOQfQSjHPr8bybbJ7ZpzfFdTJtLUKPIBBJWv3BY1lrGH5JOEXebbL9Ixr8X8J1Xr23Xdbz5mkS6gKuCJzYlufipCh+0UiYmLSpK2T4oUFUg== 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=f+4pxIwdyAncqNveILnTSyt/KxYzkjyRoxJQWXR+Hts=; b=po4pBhQmGxqWX443b77krMFHV9/p+6s3/0VbDKN+4C3LI+1HXf9hPOSijR9wj/jVzxC8Q1X/uirf66GrQvTTu5iKVe75aBrXaaRKTgyc6K1edFH82LhajfYwrI2REcSiMBP6v2AuNwnmYrJHDjDiA3QzSByeiKGWJ20GY9Bx670= Received: from DUZPR01CA0210.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::24) by VE1P190MB0992.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1ab::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:44:16 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::92) by DUZPR01CA0210.outlook.office365.com (2603:10a6:10:4b6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:44:16 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:44: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, Oleksandr Kolomeiets Subject: [PATCH v4 85/86] net/ntnic: add MTU configuration Date: Tue, 29 Oct 2024 17:42:29 +0100 Message-ID: <20241029164243.1648775-86-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VE1P190MB0992:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ac045f8a-c350-4b59-a191-08dcf838ed71 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: =?us-ascii?Q?QA6FrfdLJ0YzKLq68NaVugT+0g7k2Nnzklh9tcLzjuY+Rxspftf+NBMOJ+6h?= =?us-ascii?Q?w+mFv5qYtDSOo7VB5iCXRuLiZkx6Qhg1hwyilv3CrP/+GipjNhbd9ddh4Mva?= =?us-ascii?Q?Z/X4oMjJgyBeSnEMbuzFVfYzsEuMEQMM1LSwiaDkE0nJQ82y8pM0ztxLBZ/H?= =?us-ascii?Q?P1Vtt8R4A8cWcWY4bYNHyqLFUn09a9SNMgCe3Qzfh/GKAVjD/M3ZkEzTKW/Z?= =?us-ascii?Q?uVy48ZYkzaQI1GXzf39Tmal8yarTVOtnWC9ZoBJRf9U/J/3Zl2zBYX69GQW8?= =?us-ascii?Q?do+32ZjPWsX071w3cWvbkhQS8W6Z03KqEy/VPm/+EM2lyB5Uatnyh9zRRNsH?= =?us-ascii?Q?zNZ0STYZDrFzMOsExw7zR90pObQbXv8xSGpWPcHr3kx8KktpOepLg8kxdKm6?= =?us-ascii?Q?A/aJhMHaYJmXWQqOk0BgjHBqJ7DNC5Z88WdWhkzBLaF0fXH70aEYdxsOk8Xk?= =?us-ascii?Q?oC3DxW/M3E32dBMeU3kYjVG0yfHUklc3dwWNgcCz4n3lUzfVhQBpJeQ3mCdv?= =?us-ascii?Q?f3kxEr+bFPJ3uIdKR7G3N3X/v8kLywMa74NOWZqw/ZSGTH4nqxDWFfS0EaLg?= =?us-ascii?Q?I1d92ji3LWs5/Ojr6BKwpVciaE7WVmGAP9BhUX+czuKKAQnMzeU2x76S505n?= =?us-ascii?Q?TIDhk7WHE3IbfU9uh7iMf0C6wTWNc8h4dHLs9KOnEJ+eVNH8pw/kRdKeJX1E?= =?us-ascii?Q?O+WDhPeoK5f7oWV9gqxPOiCyXjWSymnMl32vM3qL/P81rwYn2EdILk+w3owb?= =?us-ascii?Q?jfHy3OXAsxpKNihcttTRu2axGyjFFlv4FpLglarNqJkmkDKJpDIcDnujxzG9?= =?us-ascii?Q?PZ4HLtSxHM1DtzVPZL16sUdKkk/nB7ihG+y4wDK2DqxjrdB/B7zHt1c5mYpc?= =?us-ascii?Q?kNz8rQKi8zEFT4g/VTrlEgGDzLQNro/JSlJ1CJz7EoXyK9nf94joLi/kcnMi?= =?us-ascii?Q?nQXQ0uv97llMUApJ1YmHAyCj94Ifg21/wKrTzmCDf+X4JInDyylCif5x/iRo?= =?us-ascii?Q?MbZV3dnKS2wt8kr+meeaQbmViVZnqjFv6VtM6cUazALRjgOa2OzoQO8DyGVG?= =?us-ascii?Q?FmdNDD2I3sTUXO5C9znmx/HAja11PqEorq3G//ls3WbgjalX0tqbA9KfiTnj?= =?us-ascii?Q?OqompVCipxO2FhKEAZ3Qgw5Z2YXk2mIZ20S/FFwVrs1xuOku9tG7Fe32H+BC?= =?us-ascii?Q?736dAddLVCXDSWMA9P/dI9JSlQaSCHGFhghu1LUh94YJaEHN3znV0+fDmMFk?= =?us-ascii?Q?pPud/FJ8PpyyhwPElKm0mG6H6qPt0L2c7YryIjUiQfqz664TH7Ec5bk6Lo3k?= =?us-ascii?Q?KDYIoWXg+rdhhFg7r8O9Jc/67raqUBYf5feYwFd3Suul1Njz+e4Mfa/h/ist?= =?us-ascii?Q?SN3zBOeoAJqkTZB5d+dAMvJr/rSPvAWsX8hKqE2NjL/A4cb2cA=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: 78bOP8Rrol65mehM9cYVGVhFsGuGm1Y5A2iO4TF30ieLQXWSOEDCSu3iPiDmqUQbIUdunqHxe1RhAHxttgp9l6h4XxrjOcBnO/DpgIxfQTv/guPN68pXDxZU/QdGbxtVsyB2TbTivDzAleATcd0IJ5XI81IQkbScgvs6FEAG1tUzJp2zRwUP2sLqi7An0AxjDwicFZg+5ZuTqxRDy0lF/lGkRKkwHG4NifcHsBuvyVJpO0kRkShCbUChAAuE9AypXgOuhbE1Q9usu+9JURdUdds0CNtATGBvv2sR+Sd89J2HlSRXl6xCngxk6W6DDtrz+7KZBoie1Rkl6wr7l3qIgzaPWKphfHZBAUaxqm89r84wkWAS9Ibytvup1E139Jfh4vXkUEKhrOxdX4GZZtdrjo9bhKqrRbopusQi3E0w6I62P4p3Apb/1XFt1SAx4wxgKo7L7ni4AZ27mMo3FfOwTjvrOUT1O3UzGJFFdUgPgWlBke+DODWaLiRrjsG1YdkDbOXBksqJr8WY2+UYTpmwTeNbUykZ2g4HTnXVcldGLpALQiNVq5LNQImrqUX7a07KmTbdM8NkZo/0RFqwX7csQZwEraSiDBP3GIslVsYoA0sle3+BR2U+T7RIVrFOoh9FMPcvgaNoC/Og4jJ8H26GCLv7y4avnNSXmKtVcDW4Btk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:44:16.1834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac045f8a-c350-4b59-a191-08dcf838ed71 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P190MB0992 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222209-311207-12650-29483-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFmbmQGYGUNQs2cLE3NwwOc 3AIskkNc040cDQ2NwQSCWlGKVZpKYq1cYCALF31oZCAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan18-5.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Oleksandr Kolomeiets Add supporting API rte_eth_dev_set_mtu Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/include/flow_api_engine.h | 7 ++ drivers/net/ntnic/include/hw_mod_backend.h | 4 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c | 96 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.c | 82 +++++++++++++++- .../profile_inline/flow_api_profile_inline.h | 9 ++ .../flow_api_profile_inline_config.h | 50 ++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 41 ++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 5 + 8 files changed, 292 insertions(+), 2 deletions(-) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 8604dde995..5eace2614f 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -280,6 +280,11 @@ struct nic_flow_def { * AGE action timeout */ struct age_def_s age; + + /* + * TX fragmentation IFR/RPP_LR MTU recipe + */ + uint8_t flm_mtu_fragmentation_recipe; }; enum flow_handle_type { @@ -340,6 +345,8 @@ struct flow_handle { uint8_t flm_qfi; uint8_t flm_scrub_prof; + uint8_t flm_mtu_fragmentation_recipe; + /* Flow specific pointer to application template table cell stored during * flow create. */ diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 7a36e4c6d6..f91a3ed058 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -958,8 +958,12 @@ int hw_mod_tpe_rpp_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, i 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_rpp_ifr_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); int hw_mod_tpe_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_tpe_ifr_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value); 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, 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 ba8f2d0dbb..2c3ed2355b 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 @@ -152,6 +152,54 @@ int hw_mod_tpe_rpp_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, i return be->iface->tpe_rpp_ifr_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_rpp_ifr_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_ifr_categories) + return INDEX_TOO_LARGE; + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_IFR_RCP_IPV4_EN: + GET_SET(be->tpe.v3.rpp_ifr_rcp[index].ipv4_en, value); + break; + + case HW_TPE_IFR_RCP_IPV4_DF_DROP: + GET_SET(be->tpe.v3.rpp_ifr_rcp[index].ipv4_df_drop, value); + break; + + case HW_TPE_IFR_RCP_IPV6_EN: + GET_SET(be->tpe.v3.rpp_ifr_rcp[index].ipv6_en, value); + break; + + case HW_TPE_IFR_RCP_IPV6_DROP: + GET_SET(be->tpe.v3.rpp_ifr_rcp[index].ipv6_drop, value); + break; + + case HW_TPE_IFR_RCP_MTU: + GET_SET(be->tpe.v3.rpp_ifr_rcp[index].mtu, value); + break; + + default: + return UNSUP_FIELD; + } + + break; + + default: + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_rpp_ifr_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_rpp_ifr_rcp_mod(be, field, index, &value, 0); +} + /* * RPP_RCP */ @@ -262,6 +310,54 @@ int hw_mod_tpe_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int c return be->iface->tpe_ifr_rcp_flush(be->be_dev, &be->tpe, start_idx, count); } +static int hw_mod_tpe_ifr_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_ifr_categories) + return INDEX_TOO_LARGE; + + switch (_VER_) { + case 3: + switch (field) { + case HW_TPE_IFR_RCP_IPV4_EN: + GET_SET(be->tpe.v3.ifr_rcp[index].ipv4_en, value); + break; + + case HW_TPE_IFR_RCP_IPV4_DF_DROP: + GET_SET(be->tpe.v3.ifr_rcp[index].ipv4_df_drop, value); + break; + + case HW_TPE_IFR_RCP_IPV6_EN: + GET_SET(be->tpe.v3.ifr_rcp[index].ipv6_en, value); + break; + + case HW_TPE_IFR_RCP_IPV6_DROP: + GET_SET(be->tpe.v3.ifr_rcp[index].ipv6_drop, value); + break; + + case HW_TPE_IFR_RCP_MTU: + GET_SET(be->tpe.v3.ifr_rcp[index].mtu, value); + break; + + default: + return UNSUP_FIELD; + } + + break; + + default: + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_tpe_ifr_rcp_set(struct flow_api_backend_s *be, enum hw_tpe_e field, int index, + uint32_t value) +{ + return hw_mod_tpe_ifr_rcp_mod(be, field, index, &value, 0); +} + /* * INS_RCP */ 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 89e7041350..42d4c19eaa 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 @@ -803,6 +803,11 @@ static inline void set_key_def_sw(struct flm_flow_key_def_s *key_def, unsigned i } } +static inline uint8_t convert_port_to_ifr_mtu_recipe(uint32_t port) +{ + return port + 1; +} + 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; @@ -1023,6 +1028,8 @@ static int flm_flow_programming(struct flow_handle *fh, uint32_t flm_op) learn_record->rqi = fh->flm_rqi; /* Lower 10 bits used for RPL EXT PTR */ learn_record->color = fh->flm_rpl_ext_ptr & 0x3ff; + /* Bit [13:10] used for MTU recipe */ + learn_record->color |= (fh->flm_mtu_fragmentation_recipe & 0xf) << 10; learn_record->ent = 0; learn_record->op = flm_op & 0xf; @@ -1121,6 +1128,9 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, fd->dst_id[fd->dst_num_avail].active = 1; fd->dst_num_avail++; + fd->flm_mtu_fragmentation_recipe = + convert_port_to_ifr_mtu_recipe(port); + if (fd->full_offload < 0) fd->full_offload = 1; @@ -3070,6 +3080,8 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def break; } } + + fh->flm_mtu_fragmentation_recipe = fd->flm_mtu_fragmentation_recipe; fh->context = fd->age.context; } @@ -3187,7 +3199,7 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, /* Setup COT */ struct hw_db_inline_cot_data cot_data = { .matcher_color_contrib = empty_pattern ? 0x0 : 0x4, /* FT key C */ - .frag_rcp = 0, + .frag_rcp = empty_pattern ? fd->flm_mtu_fragmentation_recipe : 0, }; struct hw_db_cot_idx cot_idx = hw_db_inline_cot_add(dev->ndev, dev->ndev->hw_db_handle, &cot_data); @@ -3501,7 +3513,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n /* Setup COT */ struct hw_db_inline_cot_data cot_data = { .matcher_color_contrib = 0, - .frag_rcp = 0, + .frag_rcp = fd->flm_mtu_fragmentation_recipe, }; struct hw_db_cot_idx cot_idx = hw_db_inline_cot_add(dev->ndev, dev->ndev->hw_db_handle, @@ -5416,6 +5428,67 @@ int flow_get_flm_stats_profile_inline(struct flow_nic_dev *ndev, uint64_t *data, return 0; } +int flow_set_mtu_inline(struct flow_eth_dev *dev, uint32_t port, uint16_t mtu) +{ + if (port >= 255) + return -1; + + uint32_t ipv4_en_frag; + uint32_t ipv4_action; + uint32_t ipv6_en_frag; + uint32_t ipv6_action; + + if (port == 0) { + ipv4_en_frag = PORT_0_IPV4_FRAGMENTATION; + ipv4_action = PORT_0_IPV4_DF_ACTION; + ipv6_en_frag = PORT_0_IPV6_FRAGMENTATION; + ipv6_action = PORT_0_IPV6_ACTION; + + } else if (port == 1) { + ipv4_en_frag = PORT_1_IPV4_FRAGMENTATION; + ipv4_action = PORT_1_IPV4_DF_ACTION; + ipv6_en_frag = PORT_1_IPV6_FRAGMENTATION; + ipv6_action = PORT_1_IPV6_ACTION; + + } else { + ipv4_en_frag = DISABLE_FRAGMENTATION; + ipv4_action = IPV4_DF_DROP; + ipv6_en_frag = DISABLE_FRAGMENTATION; + ipv6_action = IPV6_DROP; + } + + int err = 0; + uint8_t ifr_mtu_recipe = convert_port_to_ifr_mtu_recipe(port); + struct flow_nic_dev *ndev = dev->ndev; + + err |= hw_mod_tpe_rpp_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV4_EN, ifr_mtu_recipe, + ipv4_en_frag); + err |= hw_mod_tpe_rpp_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV6_EN, ifr_mtu_recipe, + ipv6_en_frag); + err |= hw_mod_tpe_rpp_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_MTU, ifr_mtu_recipe, mtu); + err |= hw_mod_tpe_rpp_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV4_DF_DROP, ifr_mtu_recipe, + ipv4_action); + err |= hw_mod_tpe_rpp_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV6_DROP, ifr_mtu_recipe, + ipv6_action); + + err |= hw_mod_tpe_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV4_EN, ifr_mtu_recipe, + ipv4_en_frag); + err |= hw_mod_tpe_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV6_EN, ifr_mtu_recipe, + ipv6_en_frag); + err |= hw_mod_tpe_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_MTU, ifr_mtu_recipe, mtu); + err |= hw_mod_tpe_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV4_DF_DROP, ifr_mtu_recipe, + ipv4_action); + err |= hw_mod_tpe_ifr_rcp_set(&ndev->be, HW_TPE_IFR_RCP_IPV6_DROP, ifr_mtu_recipe, + ipv6_action); + + if (err == 0) { + err |= hw_mod_tpe_rpp_ifr_rcp_flush(&ndev->be, ifr_mtu_recipe, 1); + err |= hw_mod_tpe_ifr_rcp_flush(&ndev->be, ifr_mtu_recipe, 1); + } + + return err; +} + int flow_info_get_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, struct rte_flow_port_info *port_info, struct rte_flow_queue_info *queue_info, struct rte_flow_error *error) @@ -6000,6 +6073,11 @@ static const struct profile_inline_ops ops = { .flm_free_queues = flm_free_queues, .flm_mtr_read_stats = flm_mtr_read_stats, .flm_update = flm_update, + + /* + * Config API + */ + .flow_set_mtu_inline = flow_set_mtu_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 0dc89085ec..ce1a0669ee 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,10 @@ #include "flow_api.h" #include "stream_binary_flow_api.h" +#define DISABLE_FRAGMENTATION 0 +#define IPV4_DF_DROP 1 +#define IPV6_DROP 1 + /* * Management */ @@ -120,4 +124,9 @@ int flow_configure_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); +/* + * Config API + */ +int flow_set_mtu_inline(struct flow_eth_dev *dev, uint32_t port, uint16_t mtu); + #endif /* _FLOW_API_PROFILE_INLINE_H_ */ 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 index 3b53288ddf..c665cab16a 100644 --- 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 @@ -6,6 +6,56 @@ #ifndef _FLOW_API_PROFILE_INLINE_CONFIG_H_ #define _FLOW_API_PROFILE_INLINE_CONFIG_H_ +/* + * Per port configuration for IPv4 fragmentation and DF flag handling + * + * ||-------------------------------------||-------------------------||----------|| + * || Configuration || Egress packet type || || + * ||-------------------------------------||-------------------------|| Action || + * || IPV4_FRAGMENTATION | IPV4_DF_ACTION || Exceeding MTU | DF flag || || + * ||-------------------------------------||-------------------------||----------|| + * || DISABLE | - || - | - || Forward || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DF_DROP || no | - || Forward || + * || | || yes | 0 || Fragment || + * || | || yes | 1 || Drop || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DF_FORWARD || no | - || Forward || + * || | || yes | 0 || Fragment || + * || | || yes | 1 || Forward || + * ||-------------------------------------||-------------------------||----------|| + */ + +#define PORT_0_IPV4_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_0_IPV4_DF_ACTION IPV4_DF_DROP + +#define PORT_1_IPV4_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_1_IPV4_DF_ACTION IPV4_DF_DROP + +/* + * Per port configuration for IPv6 fragmentation + * + * ||-------------------------------------||-------------------------||----------|| + * || Configuration || Egress packet type || || + * ||-------------------------------------||-------------------------|| Action || + * || IPV6_FRAGMENTATION | IPV6_ACTION || Exceeding MTU || || + * ||-------------------------------------||-------------------------||----------|| + * || DISABLE | - || - || Forward || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DROP || no || Forward || + * || | || yes || Drop || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | FRAGMENT || no || Forward || + * || | || yes || Fragment || + * ||-------------------------------------||-------------------------||----------|| + */ + +#define PORT_0_IPV6_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_0_IPV6_ACTION IPV6_DROP + +#define PORT_1_IPV6_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_1_IPV6_ACTION IPV6_DROP + /* * Statistics are generated each time the byte counter crosses a limit. * If BYTE_LIMIT is zero then the byte counter does not trigger statistics diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 77436eb02d..2a2643a106 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -39,6 +39,7 @@ const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL } #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) +#define MIN_MTU_INLINE 512 #define EXCEPTION_PATH_HID 0 @@ -70,6 +71,8 @@ const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL } #define MAX_RX_PACKETS 128 #define MAX_TX_PACKETS 128 +#define MTUINITVAL 1500 + uint64_t rte_tsc_freq; static void (*previous_handler)(int sig); @@ -338,6 +341,7 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info dev_info->max_mtu = MAX_MTU; if (p_adapter_info->fpga_info.profile == FPGA_INFO_PROFILE_INLINE) { + dev_info->min_mtu = MIN_MTU_INLINE; dev_info->flow_type_rss_offloads = NT_ETH_RSS_OFFLOAD_MASK; dev_info->hash_key_size = MAX_RSS_KEY_LEN; @@ -1149,6 +1153,26 @@ static int eth_tx_scg_queue_setup(struct rte_eth_dev *eth_dev, return 0; } +static int dev_set_mtu_inline(struct rte_eth_dev *eth_dev, uint16_t mtu) +{ + 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 -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + struct flow_eth_dev *flw_dev = internals->flw_dev; + int ret = -1; + + if (internals->type == PORT_TYPE_PHYSICAL && mtu >= MIN_MTU_INLINE && mtu <= MAX_MTU) + ret = profile_inline_ops->flow_set_mtu_inline(flw_dev, internals->port, mtu); + + return ret ? -EINVAL : 0; +} + static int eth_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) { eth_dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; @@ -1714,6 +1738,7 @@ static struct eth_dev_ops nthw_eth_dev_ops = { .xstats_reset = eth_xstats_reset, .xstats_get_by_id = eth_xstats_get_by_id, .xstats_get_names_by_id = eth_xstats_get_names_by_id, + .mtu_set = NULL, .promiscuous_enable = promiscuous_enable, .rss_hash_update = eth_dev_rss_hash_update, .rss_hash_conf_get = rss_hash_conf_get, @@ -2277,6 +2302,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) internals->pci_dev = pci_dev; internals->n_intf_no = n_intf_no; internals->type = PORT_TYPE_PHYSICAL; + internals->port = n_intf_no; internals->nb_rx_queues = nb_rx_queues; internals->nb_tx_queues = nb_tx_queues; @@ -2386,6 +2412,21 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* increase initialized ethernet devices - PF */ p_drv->n_eth_dev_init_count++; + if (get_flow_filter_ops() != NULL) { + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && + internals->flw_dev->ndev->be.tpe.ver >= 2) { + assert(nthw_eth_dev_ops.mtu_set == dev_set_mtu_inline || + nthw_eth_dev_ops.mtu_set == NULL); + nthw_eth_dev_ops.mtu_set = dev_set_mtu_inline; + dev_set_mtu_inline(eth_dev, MTUINITVAL); + NT_LOG_DBGX(DBG, NTNIC, "INLINE MTU supported, tpe version %d", + internals->flw_dev->ndev->be.tpe.ver); + + } else { + NT_LOG(DBG, NTNIC, "INLINE MTU not supported"); + } + } + /* Port event thread */ if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { res = THREAD_CTRL_CREATE(&p_nt_drv->port_event_thread, "nt_port_event_thr", diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index eb764356eb..71861c6dea 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -408,6 +408,11 @@ struct profile_inline_ops { const struct rte_flow_port_attr *port_attr, uint16_t nb_queue, const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); + + /* + * Config API + */ + int (*flow_set_mtu_inline)(struct flow_eth_dev *dev, uint32_t port, uint16_t mtu); }; void register_profile_inline_ops(const struct profile_inline_ops *ops); -- 2.45.0