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 0F0A243B80; Tue, 5 Mar 2024 03:29:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 13871402F1; Tue, 5 Mar 2024 03:29:49 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2097.outbound.protection.outlook.com [40.107.94.97]) by mails.dpdk.org (Postfix) with ESMTP id 597154026B for ; Tue, 5 Mar 2024 03:29:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S/W9MIQtKNHDBUAa6TzIqojPEd98rYjHhoJ1cRddPxIFF+6u5N8Q4oLjkGv5e97yGl2cMJZKz+3nCGL/Zxe67nVYjQj3Xs4Etl/Wr8VfMg5WrnlUZoChIPH+OFUS2vZkmETrHkyS8MgrEfKkwM7+8QtOHtp0wFKS2NxT9DentgtxmeyX4mkz6j6KJ8wHfq2aT5zaI8/rn6mXnnmoGxmpjrA5mV5bp1doC0oeRJrzBA8lJVnD2WhF5WOCYZYDHbzlfpP9jeMl3KoYACv/auzSpvDALBOnMDNxlVRdx7qhfqnqWpHiVXgQ5uqjUBiX+R6Li80M9ejvojR7ALAwVlknxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9b9rN1X4cn+sbPozpcu46Mn7rpAyWGjaR3i+cq32sJs=; b=BCzrf8CELfi9jxlwekLuX8WN25k3mQ56+QIOyEQfT+vGndrAmhyatMe8SKb6T4/71Q/ZMdhBo1Awb4/5l5CXxWUREwTICf6fm398iQNHltRSjiyXZZ1wc4VCExUosAblzZI1a2EkLpB4SyvRdp+qRKciS1NpbVsxCQ+i6V+eSYd6vZNl3w3pb0UB1mYNPNDUtCv+0nJN7ySF8tK6UVxiCk7Ue7GHix9fR1742PDPkZArYcsAvbG4mdQhCzZpWbsZIbkvF/nyZCzuQxtvwcLCtyXQOAfX8FQdCdBmKkbXXrow4UkeWmON0wnzGthSof9DrjQbdcWNYz+KmPPZkzU30w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9b9rN1X4cn+sbPozpcu46Mn7rpAyWGjaR3i+cq32sJs=; b=mP3e481pO1Z8BsyEWjmFfgl/D4ENaAZ65Znw+dXN3i3ELrfZA39ugDb4/Odf6wIK81kx7S1EgBhNZzGrU/O4F30YRBTith06o29y7nt8R9Y0+bxGGHehVLwN8AgU0BW+3uILPOhn/IVwrl8jyu0+ctrOfYshitdpVZ/YxJRVBAo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH0PR13MB5780.namprd13.prod.outlook.com (2603:10b6:510:11b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Tue, 5 Mar 2024 02:29:44 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7339.035; Tue, 5 Mar 2024 02:29:44 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He Subject: [PATCH 1/5] net/nfp: create new meta data module Date: Tue, 5 Mar 2024 10:29:19 +0800 Message-Id: <20240305022923.891544-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240305022923.891544-1-chaoyong.he@corigine.com> References: <20240305022923.891544-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR04CA0028.namprd04.prod.outlook.com (2603:10b6:a03:1d0::38) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH0PR13MB5780:EE_ X-MS-Office365-Filtering-Correlation-Id: a4691bb0-a31f-4b50-ffc5-08dc3cbc1e37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wH/dxnJk6Ol9AF6Q56nlKUmZb4EgFwFeUXEOF+f+8stgqvOpWTny47Z7ZYoFN5MZsDYJUNYvmswnvC6gbDN0bMzqQ/De6B0TRQAE/p7DBhdsL0765QwSAxv+RZ86MYClTadF4j7VFA9kt5ZbjJOWPf1rbyhSx8a381PxXVW6+fvEt+65F9wBrm6bwyP4Nvb7ykGxuYmeF7LpFkQl4HBx1IN/L+wz4OjDXrfwJNOk/Bu9KoEOAJ3IxbBxWibTOGRQc2oQEXgZ4Q0D2UKn5dQYnSIZd++N8cmVrrum5sBWwx2WDN7Kj8EqDBBFBPkYEGdlQXRex0le9MWNXpqZ2+uRQkAJlkDoqd8R36xE7MdrQciJNG3M1shrtAL4vdJllAMmWRztRAf4IFJwr14s1VZlVPgDEWuiUr/z9J56umKdeNiMGj7kPdw4C1qNFzIlp1SpOMrJpw0ynllgeVI6N9Q8u86fWeOu+55eZIBctJqwXKOpMFcHQltNwsnMSWmC8ENJqtqjcKoWaEGFIhByJxFJlUvLfrJYDykd9EEDbhV1ccTiTgacv4/H9vQ6WYNZt+DVs15igor9gQ4+wdza+KSVsg70EUyrdPeKH02+7ktXZNcnqIaLnhjssR/cBTqm5N2v/5gkrtXUvSDPI55l7BWqTcyLE++SaeAUry30jaS+2GY9/7GrTsqEf39trmVPru+16odgvRSKuc4LJTvJMbFZmJnGUEtKSJvR0Fs2M0q0aGE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0b0aR4zsx2/E+cJmY0sxTxqmQnIMlNq+3LL6RVGM3esXXSims5Fq/HfM41LF?= =?us-ascii?Q?0niTs+Y/+KzPYiFk7hLDO9TEF0TWTL2KoaxDBrtxLHxueBPdkvgGMpIYAGE0?= =?us-ascii?Q?p3gWm2FwKA+PhPlrFChtTC8w9sMcby3wKvrVUmjbvc9X6sBM/IX+n9JfOZR2?= =?us-ascii?Q?25kSkbLEF7NuBSLqZUYLHhYo6BsMo8tkQCFpIVgtaJYtXYo1pPEFU6sJ69op?= =?us-ascii?Q?zQF+kl+oNWN48TJcFedbXpWh0UhxIc95UzNnaB9ureyzK+P8euDtOOLqZxjN?= =?us-ascii?Q?OC0P70oQhBzQcJ6OGOc/4KS8h8yMarjDN0AUENYBMOpJ37xm56b//3nZo9H8?= =?us-ascii?Q?I1udTSLQESDbKI21qCPY+uhqAhsI5d3WT4/J165sm26kOkZRInmgASiuW/6X?= =?us-ascii?Q?sYyiAiFF0GxV7GX0s0JVWRkHI3nQ3C4C+ODGg86R07Q1kIXizwcUELWlWXPF?= =?us-ascii?Q?1Qb3sGyHK4QPK8B4abizTwkPIiMlWf1uB+T0zZ2edeafEtxWCvqto6PxDX0b?= =?us-ascii?Q?TLFpLK++/LIio5drZIvSOn0NEwzcztS9T3KkteLxccg7cK1DkY5Xt2iHA8P3?= =?us-ascii?Q?3mR50UXRj8+rZuc01lY6RIH7JX2naASdHVPFIbJ/NQQAVaMyWxFgRWUvM9lr?= =?us-ascii?Q?ZCH0TLOuAhjv3lrVJl2GjS6hnJVRyS207jNnATQiM5nDw7ffeFC4Rani9lxM?= =?us-ascii?Q?shRCIm89BpQJF76p/+AAyinZMXBBjmcpHFMURa45upCgnbBh86u4aZ4Gl/FQ?= =?us-ascii?Q?6IP6NCLxi/Sa21K53g+8feHV34kGdykBvRWGwDP9Rwh4IIUyK5uYm+V+6UQU?= =?us-ascii?Q?yNr4ojdDuC/4IdPz2GpU0TwZKil+OxUxdJ+j4knNOxwlTpaZEuwbY5nqmKCn?= =?us-ascii?Q?2nXMZ28AkA7+orKApHr//V1tPGQctloW7roId/csrH6yRV9JTFxJqDuEs+f/?= =?us-ascii?Q?8g/XNzGvo8DFGQFHKOos8vGpyMi4y0uhQpO1X9mgayIItpqTUaH5OMBqKXSq?= =?us-ascii?Q?d30hM2uxhO0lC/GTwJNnYLPP2lDfnStqh54Xa1rjBO/gIZiBAE1JMtfFalOK?= =?us-ascii?Q?PQc+da7Z8NGvFdOnMYDpnT6LGL18S5k2KBWIIcPREKsvPWaSVuJpgTFtkZWf?= =?us-ascii?Q?6wIvvgxWlVGI1DPcNmsq7FeJPRbx6upf5kpl71nQ6/ws9OuKlA2gkEhJpnbh?= =?us-ascii?Q?TuKyzUkOSDHwQW9VbxERUCmwA4BszZr5nkDbMw5qzPR9EVKEGRj097h3AMec?= =?us-ascii?Q?qqBGUoui5eDjTxsv4PUuxOV405bM60lxaUEhBtTErsU6TA/ySVEKTUapN6IV?= =?us-ascii?Q?jJzeBv85dPec3ryVtphvDlqT6lVoE/PE3rlLP/psqO/2nZCXzYnwoQY3VLp8?= =?us-ascii?Q?N8ktVOIxfQtBArC7YfJm9Eyf48aL6sBJGUpbFWr5CCkj/exd3CK4ggMhaH3/?= =?us-ascii?Q?dWXnrRyq7XF9au5HHhtBniaH7wEsAh6ZrsbE+sezgkKSOtSXHHuRjYxt2ySa?= =?us-ascii?Q?eGcU9XMkv67p7cVnPxL+iUsBj63AaSzeeRr453pp5zhl9WlE/FqIM7c/vQQB?= =?us-ascii?Q?TkGEdBsk7k3Xlq6ELEL1JoNlYW8alhSSLQCmHJPgBxdIxs7Br6zpnL57lkKL?= =?us-ascii?Q?SQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4691bb0-a31f-4b50-ffc5-08dc3cbc1e37 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 02:29:44.4821 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: asGEwNIBIcT0iRK8a+5YhvKZzFwpu2PNNSh5n893LGR0EA7wyXgApxEanCw5cVaxAg/VaEyM6ZuqAymDUdb0kjlCHJA5ie5O7TbQZOVOCpI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5780 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: Long Wu Move the Rx meta data code to new 'nfp_net_meta' module, which makes related logic more clean and the code architecture more reasonable. There is no functional change, just moving verbatim code around. Signed-off-by: Long Wu Reviewed-by: Chaoyong He --- drivers/common/nfp/nfp_common_ctrl.h | 41 --- drivers/net/nfp/flower/nfp_flower.c | 1 + drivers/net/nfp/flower/nfp_flower_cmsg.c | 1 + drivers/net/nfp/flower/nfp_flower_ctrl.c | 1 + drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 1 + drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 1 + drivers/net/nfp/nfp_ipsec.c | 1 + drivers/net/nfp/nfp_ipsec.h | 6 - drivers/net/nfp/nfp_net_common.c | 24 +- drivers/net/nfp/nfp_net_common.h | 7 +- drivers/net/nfp/nfp_net_meta.c | 320 +++++++++++++++++++++++ drivers/net/nfp/nfp_net_meta.h | 108 ++++++++ drivers/net/nfp/nfp_rxtx.c | 305 +-------------------- drivers/net/nfp/nfp_rxtx.h | 20 -- 15 files changed, 438 insertions(+), 400 deletions(-) create mode 100644 drivers/net/nfp/nfp_net_meta.c create mode 100644 drivers/net/nfp/nfp_net_meta.h diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h index 7749ba6459..6badf769fc 100644 --- a/drivers/common/nfp/nfp_common_ctrl.h +++ b/drivers/common/nfp/nfp_common_ctrl.h @@ -13,47 +13,6 @@ */ #define NFP_NET_CFG_BAR_SZ (32 * 1024) -/* Offset in Freelist buffer where packet starts on RX */ -#define NFP_NET_RX_OFFSET 32 - -/* Working with metadata api (NFD version > 3.0) */ -#define NFP_NET_META_FIELD_SIZE 4 -#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1) -#define NFP_NET_META_HEADER_SIZE 4 -#define NFP_NET_META_NFDK_LENGTH 8 - -/* Working with metadata vlan api (NFD version >= 2.0) */ -#define NFP_NET_META_VLAN_INFO 16 -#define NFP_NET_META_VLAN_OFFLOAD 31 -#define NFP_NET_META_VLAN_TPID 3 -#define NFP_NET_META_VLAN_MASK ((1 << NFP_NET_META_VLAN_INFO) - 1) -#define NFP_NET_META_VLAN_TPID_MASK ((1 << NFP_NET_META_VLAN_TPID) - 1) -#define NFP_NET_META_TPID(d) (((d) >> NFP_NET_META_VLAN_INFO) & \ - NFP_NET_META_VLAN_TPID_MASK) - -/* Prepend field types */ -#define NFP_NET_META_HASH 1 /* Next field carries hash type */ -#define NFP_NET_META_MARK 2 -#define NFP_NET_META_VLAN 4 -#define NFP_NET_META_PORTID 5 -#define NFP_NET_META_IPSEC 9 - -#define NFP_META_PORT_ID_CTRL ~0U - -/* Hash type prepended when a RSS hash was computed */ -#define NFP_NET_RSS_NONE 0 -#define NFP_NET_RSS_IPV4 1 -#define NFP_NET_RSS_IPV6 2 -#define NFP_NET_RSS_IPV6_EX 3 -#define NFP_NET_RSS_IPV4_TCP 4 -#define NFP_NET_RSS_IPV6_TCP 5 -#define NFP_NET_RSS_IPV6_EX_TCP 6 -#define NFP_NET_RSS_IPV4_UDP 7 -#define NFP_NET_RSS_IPV6_UDP 8 -#define NFP_NET_RSS_IPV6_EX_UDP 9 -#define NFP_NET_RSS_IPV4_SCTP 10 -#define NFP_NET_RSS_IPV6_SCTP 11 - /* * @NFP_NET_TXR_MAX: Maximum number of TX rings * @NFP_NET_TXR_MASK: Mask for TX rings diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index c6a744e868..97219ff379 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -16,6 +16,7 @@ #include "../nfp_cpp_bridge.h" #include "../nfp_logs.h" #include "../nfp_mtr.h" +#include "../nfp_net_meta.h" #include "nfp_flower_ctrl.h" #include "nfp_flower_representor.h" #include "nfp_flower_service.h" diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 8effe9474d..f78bfba332 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -7,6 +7,7 @@ #include "../nfpcore/nfp_nsp.h" #include "../nfp_logs.h" +#include "../nfp_net_meta.h" #include "nfp_flower_ctrl.h" #include "nfp_flower_representor.h" diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index bcb325d475..720a0d9495 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -10,6 +10,7 @@ #include "../nfd3/nfp_nfd3.h" #include "../nfdk/nfp_nfdk.h" #include "../nfp_logs.h" +#include "../nfp_net_meta.h" #include "nfp_flower_representor.h" #include "nfp_mtr.h" #include "nfp_flower_service.h" diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index 959ca01844..d805644ec5 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -41,6 +41,7 @@ sources = files( 'nfp_net_common.c', 'nfp_net_ctrl.c', 'nfp_net_flow.c', + 'nfp_net_meta.c', 'nfp_rxtx.c', 'nfp_service.c', ) diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index be31f4ac33..5fb76ae9d7 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -10,6 +10,7 @@ #include "../flower/nfp_flower.h" #include "../nfp_logs.h" +#include "../nfp_net_meta.h" /* Flags in the host TX descriptor */ #define NFD3_DESC_TX_CSUM RTE_BIT32(7) diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index daf5ac5b30..8bdab5d463 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -11,6 +11,7 @@ #include "../flower/nfp_flower.h" #include "../nfp_logs.h" +#include "../nfp_net_meta.h" #define NFDK_TX_DESC_GATHER_MAX 17 diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c index 0b815fa983..0bf146b9be 100644 --- a/drivers/net/nfp/nfp_ipsec.c +++ b/drivers/net/nfp/nfp_ipsec.c @@ -18,6 +18,7 @@ #include "nfp_net_common.h" #include "nfp_net_ctrl.h" #include "nfp_rxtx.h" +#include "nfp_net_meta.h" #define NFP_UDP_ESP_PORT 4500 diff --git a/drivers/net/nfp/nfp_ipsec.h b/drivers/net/nfp/nfp_ipsec.h index d7a729398a..4ef0e196be 100644 --- a/drivers/net/nfp/nfp_ipsec.h +++ b/drivers/net/nfp/nfp_ipsec.h @@ -168,12 +168,6 @@ struct nfp_net_ipsec_data { struct nfp_ipsec_session *sa_entries[NFP_NET_IPSEC_MAX_SA_CNT]; }; -enum nfp_ipsec_meta_layer { - NFP_IPSEC_META_SAIDX, /**< Order of SA index in metadata */ - NFP_IPSEC_META_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */ - NFP_IPSEC_META_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */ -}; - int nfp_ipsec_init(struct rte_eth_dev *dev); void nfp_ipsec_uninit(struct rte_eth_dev *dev); diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 20e628bfd1..384e042dfd 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -15,6 +15,7 @@ #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_nsp.h" #include "nfp_logs.h" +#include "nfp_net_meta.h" #define NFP_TX_MAX_SEG UINT8_MAX #define NFP_TX_MAX_MTU_SEG 8 @@ -2038,29 +2039,6 @@ nfp_net_check_dma_mask(struct nfp_net_hw *hw, return 0; } -void -nfp_net_init_metadata_format(struct nfp_net_hw *hw) -{ - /* - * ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of - * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2) - * also indicate that we are using chained metadata. - */ - if (hw->ver.major == 4) { - hw->meta_format = NFP_NET_METAFORMAT_CHAINED; - } else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) { - hw->meta_format = NFP_NET_METAFORMAT_CHAINED; - /* - * RSS is incompatible with chained metadata. hw->super.cap just represents - * firmware's ability rather than the firmware's configuration. We decide - * to reduce the confusion to allow us can use hw->super.cap to identify RSS later. - */ - hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS; - } else { - hw->meta_format = NFP_NET_METAFORMAT_SINGLE; - } -} - void nfp_net_cfg_read_version(struct nfp_net_hw *hw) { diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 628c0d3491..49a5a84044 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -16,6 +16,7 @@ #include "nfpcore/nfp_sync.h" #include "nfp_net_ctrl.h" #include "nfp_service.h" +#include "nfp_net_meta.h" /* Interrupt definitions */ #define NFP_NET_IRQ_LSC_IDX 0 @@ -67,11 +68,6 @@ enum nfp_app_fw_id { NFP_APP_FW_FLOWER_NIC = 0x3, }; -enum nfp_net_meta_format { - NFP_NET_METAFORMAT_SINGLE, - NFP_NET_METAFORMAT_CHAINED, -}; - /* Parsed control BAR TLV capabilities */ struct nfp_net_tlv_caps { uint32_t mbox_off; /**< VNIC mailbox area offset */ @@ -306,7 +302,6 @@ void nfp_net_tx_desc_limits(struct nfp_net_hw *hw, uint16_t *min_tx_desc, uint16_t *max_tx_desc); int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); -void nfp_net_init_metadata_format(struct nfp_net_hw *hw); void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c new file mode 100644 index 0000000000..0bc22b2f88 --- /dev/null +++ b/drivers/net/nfp/nfp_net_meta.c @@ -0,0 +1,320 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#include "nfp_net_meta.h" + +#include "nfp_net_common.h" +#include "nfp_ipsec.h" +#include "nfp_logs.h" + +enum nfp_ipsec_meta_layer { + NFP_IPSEC_META_SAIDX, /**< Order of SA index in metadata */ + NFP_IPSEC_META_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */ + NFP_IPSEC_META_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */ +}; + +/* Parse the chained metadata from packet */ +static bool +nfp_net_parse_chained_meta(uint8_t *meta_base, + rte_be32_t meta_header, + struct nfp_meta_parsed *meta) +{ + uint32_t meta_info; + uint32_t vlan_info; + uint8_t *meta_offset; + + meta_info = rte_be_to_cpu_32(meta_header); + meta_offset = meta_base + 4; + + for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, meta_offset += 4) { + switch (meta_info & NFP_NET_META_FIELD_MASK) { + case NFP_NET_META_PORTID: + meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); + break; + case NFP_NET_META_HASH: + /* Next field type is about the hash type */ + meta_info >>= NFP_NET_META_FIELD_SIZE; + /* Hash value is in the data field */ + meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); + meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK; + break; + case NFP_NET_META_VLAN: + vlan_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); + meta->vlan[meta->vlan_layer].offload = + vlan_info >> NFP_NET_META_VLAN_OFFLOAD; + meta->vlan[meta->vlan_layer].tci = + vlan_info & NFP_NET_META_VLAN_MASK; + meta->vlan[meta->vlan_layer].tpid = NFP_NET_META_TPID(vlan_info); + meta->vlan_layer++; + break; + case NFP_NET_META_IPSEC: + meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); + meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK; + break; + case NFP_NET_META_MARK: + meta->flags |= (1 << NFP_NET_META_MARK); + meta->mark_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); + break; + default: + /* Unsupported metadata can be a performance issue */ + return false; + } + } + + return true; +} + +/* + * Parse the single metadata + * + * The RSS hash and hash-type are prepended to the packet data. + * Get it from metadata area. + */ +static inline void +nfp_net_parse_single_meta(uint8_t *meta_base, + rte_be32_t meta_header, + struct nfp_meta_parsed *meta) +{ + meta->hash_type = rte_be_to_cpu_32(meta_header); + meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4)); +} + +/* Set mbuf hash data based on the metadata info */ +static void +nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta, + struct nfp_net_rxq *rxq, + struct rte_mbuf *mbuf) +{ + struct nfp_net_hw *hw = rxq->hw; + + if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) + return; + + mbuf->hash.rss = meta->hash; + mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH; +} + +/* Set mbuf vlan_strip data based on metadata info */ +static void +nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta, + struct nfp_net_rx_desc *rxd, + struct nfp_net_rxq *rxq, + struct rte_mbuf *mb) +{ + uint32_t ctrl = rxq->hw->super.ctrl; + + /* Skip if hardware don't support setting vlan. */ + if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0) + return; + + /* + * The firmware support two ways to send the VLAN info (with priority) : + * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set, + * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set. + */ + if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) { + if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) { + mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci); + mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; + } + } else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) { + if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) { + mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info); + mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; + } + } +} + +/* + * Set mbuf qinq_strip data based on metadata info + * + * The out VLAN tci are prepended to the packet data. + * Extract and decode it and set the mbuf fields. + * + * If both RTE_MBUF_F_RX_VLAN and NFP_NET_CFG_CTRL_RXQINQ are set, the 2 VLANs + * have been stripped by the hardware and their TCIs are saved in + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer). + * If NFP_NET_CFG_CTRL_RXQINQ is set and RTE_MBUF_F_RX_VLAN is unset, only the + * outer VLAN is removed from packet data, but both tci are saved in + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer). + * + * qinq set & vlan set : meta->vlan_layer>=2, meta->vlan[0].offload=1, meta->vlan[1].offload=1 + * qinq set & vlan not set: meta->vlan_layer>=2, meta->vlan[1].offload=1,meta->vlan[0].offload=0 + * qinq not set & vlan set: meta->vlan_layer=1, meta->vlan[0].offload=1 + * qinq not set & vlan not set: meta->vlan_layer=0 + */ +static void +nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta, + struct nfp_net_rxq *rxq, + struct rte_mbuf *mb) +{ + struct nfp_hw *hw = &rxq->hw->super; + + if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 || + (hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0) + return; + + if (meta->vlan_layer < NFP_META_MAX_VLANS) + return; + + if (meta->vlan[0].offload == 0) + mb->vlan_tci = rte_cpu_to_le_16(meta->vlan[0].tci); + + mb->vlan_tci_outer = rte_cpu_to_le_16(meta->vlan[1].tci); + PMD_RX_LOG(DEBUG, "Received outer vlan TCI is %u inner vlan TCI is %u", + mb->vlan_tci_outer, mb->vlan_tci); + mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED; +} + +/* + * Set mbuf IPsec Offload features based on metadata info. + * + * The IPsec Offload features is prepended to the mbuf ol_flags. + * Extract and decode metadata info and set the mbuf ol_flags. + */ +static void +nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta, + struct nfp_net_rxq *rxq, + struct rte_mbuf *mbuf) +{ + int offset; + uint32_t sa_idx; + struct nfp_net_hw *hw; + struct nfp_tx_ipsec_desc_msg *desc_md; + + hw = rxq->hw; + sa_idx = meta->sa_idx; + + if (meta->ipsec_type != NFP_NET_META_IPSEC) + return; + + if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) { + mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED; + } else { + mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD; + offset = hw->ipsec_data->pkt_dynfield_offset; + desc_md = RTE_MBUF_DYNFIELD(mbuf, offset, struct nfp_tx_ipsec_desc_msg *); + desc_md->sa_idx = sa_idx; + desc_md->enc = 0; + } +} + +static void +nfp_net_parse_meta_mark(const struct nfp_meta_parsed *meta, + struct rte_mbuf *mbuf) +{ + if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0) + return; + + mbuf->hash.fdir.hi = meta->mark_id; + mbuf->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID; +} + +/* Parse the metadata from packet */ +void +nfp_net_parse_meta(struct nfp_net_rx_desc *rxds, + struct nfp_net_rxq *rxq, + struct nfp_net_hw *hw, + struct rte_mbuf *mb, + struct nfp_meta_parsed *meta) +{ + uint8_t *meta_base; + rte_be32_t meta_header; + + if (unlikely(NFP_DESC_META_LEN(rxds) == 0)) + return; + + meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds)); + meta_header = *(rte_be32_t *)meta_base; + + switch (hw->meta_format) { + case NFP_NET_METAFORMAT_CHAINED: + if (nfp_net_parse_chained_meta(meta_base, meta_header, meta)) { + nfp_net_parse_meta_hash(meta, rxq, mb); + nfp_net_parse_meta_vlan(meta, rxds, rxq, mb); + nfp_net_parse_meta_qinq(meta, rxq, mb); + nfp_net_parse_meta_ipsec(meta, rxq, mb); + nfp_net_parse_meta_mark(meta, mb); + } else { + PMD_RX_LOG(DEBUG, "RX chained metadata format is wrong!"); + } + break; + case NFP_NET_METAFORMAT_SINGLE: + if ((rxds->rxd.flags & PCIE_DESC_RX_RSS) != 0) { + nfp_net_parse_single_meta(meta_base, meta_header, meta); + nfp_net_parse_meta_hash(meta, rxq, mb); + } + break; + default: + PMD_RX_LOG(DEBUG, "RX metadata do not exist."); + } +} + +void +nfp_net_init_metadata_format(struct nfp_net_hw *hw) +{ + /* + * ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of + * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2) + * also indicate that we are using chained metadata. + */ + if (hw->ver.major == 4) { + hw->meta_format = NFP_NET_METAFORMAT_CHAINED; + } else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) { + hw->meta_format = NFP_NET_METAFORMAT_CHAINED; + /* + * RSS is incompatible with chained metadata. hw->super.cap just represents + * firmware's ability rather than the firmware's configuration. We decide + * to reduce the confusion to allow us can use hw->super.cap to identify RSS later. + */ + hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS; + } else { + hw->meta_format = NFP_NET_METAFORMAT_SINGLE; + } +} + +void +nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data, + struct rte_mbuf *pkt, + uint8_t layer) +{ + uint16_t tpid; + uint16_t vlan_tci; + + tpid = RTE_ETHER_TYPE_VLAN; + vlan_tci = pkt->vlan_tci; + + meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci); +} + +void +nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data, + struct nfp_net_txq *txq, + struct rte_mbuf *pkt, + uint8_t layer, + uint8_t ipsec_layer) +{ + int offset; + struct nfp_net_hw *hw; + struct nfp_tx_ipsec_desc_msg *desc_md; + + hw = txq->hw; + offset = hw->ipsec_data->pkt_dynfield_offset; + desc_md = RTE_MBUF_DYNFIELD(pkt, offset, struct nfp_tx_ipsec_desc_msg *); + + switch (ipsec_layer) { + case NFP_IPSEC_META_SAIDX: + meta_data->data[layer] = desc_md->sa_idx; + break; + case NFP_IPSEC_META_SEQLOW: + meta_data->data[layer] = desc_md->esn.low; + break; + case NFP_IPSEC_META_SEQHI: + meta_data->data[layer] = desc_md->esn.hi; + break; + default: + break; + } +} diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h new file mode 100644 index 0000000000..da2091ce9f --- /dev/null +++ b/drivers/net/nfp/nfp_net_meta.h @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2014, 2015 Netronome Systems, Inc. + * All rights reserved. + */ + +#ifndef __NFP_NET_META_H__ +#define __NFP_NET_META_H__ + +#include "nfp_rxtx.h" + +/* Hash type prepended when a RSS hash was computed */ +#define NFP_NET_RSS_NONE 0 +#define NFP_NET_RSS_IPV4 1 +#define NFP_NET_RSS_IPV6 2 +#define NFP_NET_RSS_IPV6_EX 3 +#define NFP_NET_RSS_IPV4_TCP 4 +#define NFP_NET_RSS_IPV6_TCP 5 +#define NFP_NET_RSS_IPV6_EX_TCP 6 +#define NFP_NET_RSS_IPV4_UDP 7 +#define NFP_NET_RSS_IPV6_UDP 8 +#define NFP_NET_RSS_IPV6_EX_UDP 9 +#define NFP_NET_RSS_IPV4_SCTP 10 +#define NFP_NET_RSS_IPV6_SCTP 11 + +/* Offset in Freelist buffer where packet starts on RX */ +#define NFP_NET_RX_OFFSET 32 + +/* Working with metadata api (NFD version > 3.0) */ +#define NFP_NET_META_FIELD_SIZE 4 +#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1) +#define NFP_NET_META_HEADER_SIZE 4 +#define NFP_NET_META_NFDK_LENGTH 8 + +/* Working with metadata vlan api (NFD version >= 2.0) */ +#define NFP_NET_META_VLAN_INFO 16 +#define NFP_NET_META_VLAN_OFFLOAD 31 +#define NFP_NET_META_VLAN_TPID 3 +#define NFP_NET_META_VLAN_MASK ((1 << NFP_NET_META_VLAN_INFO) - 1) +#define NFP_NET_META_VLAN_TPID_MASK ((1 << NFP_NET_META_VLAN_TPID) - 1) +#define NFP_NET_META_TPID(d) (((d) >> NFP_NET_META_VLAN_INFO) & \ + NFP_NET_META_VLAN_TPID_MASK) + +/* Prepend field types */ +#define NFP_NET_META_HASH 1 /* Next field carries hash type */ +#define NFP_NET_META_MARK 2 +#define NFP_NET_META_VLAN 4 +#define NFP_NET_META_PORTID 5 +#define NFP_NET_META_IPSEC 9 + +#define NFP_META_PORT_ID_CTRL ~0U + +#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) + +/* Maximum number of NFP packet metadata fields. */ +#define NFP_META_MAX_FIELDS 8 + +/* Maximum number of supported VLANs in parsed form packet metadata. */ +#define NFP_META_MAX_VLANS 2 + +enum nfp_net_meta_format { + NFP_NET_METAFORMAT_SINGLE, + NFP_NET_METAFORMAT_CHAINED, +}; + +/* Describe the raw metadata format. */ +struct nfp_net_meta_raw { + uint32_t header; /**< Field type header (see format in nfp.rst) */ + uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */ + uint8_t length; /**< Number of valid fields in @header */ +}; + +/* Record metadata parsed from packet */ +struct nfp_meta_parsed { + uint32_t port_id; /**< Port id value */ + uint32_t sa_idx; /**< IPsec SA index */ + uint32_t hash; /**< RSS hash value */ + uint32_t mark_id; /**< Mark id value */ + uint16_t flags; /**< Bitmap to indicate if meta exist */ + uint8_t hash_type; /**< RSS hash type */ + uint8_t ipsec_type; /**< IPsec type */ + uint8_t vlan_layer; /**< The valid number of value in @vlan[] */ + /** + * Holds information parses from NFP_NET_META_VLAN. + * The inner most vlan starts at position 0 + */ + struct { + uint8_t offload; /**< Flag indicates whether VLAN is offloaded */ + uint8_t tpid; /**< Vlan TPID */ + uint16_t tci; /**< Vlan TCI (PCP + Priority + VID) */ + } vlan[NFP_META_MAX_VLANS]; +}; + +void nfp_net_init_metadata_format(struct nfp_net_hw *hw); +void nfp_net_parse_meta(struct nfp_net_rx_desc *rxds, + struct nfp_net_rxq *rxq, + struct nfp_net_hw *hw, + struct rte_mbuf *mb, + struct nfp_meta_parsed *meta); +void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data, + struct rte_mbuf *pkt, + uint8_t layer); +void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data, + struct nfp_net_txq *txq, + struct rte_mbuf *pkt, + uint8_t layer, + uint8_t ipsec_layer); + +#endif /* __NFP_NET_META_H__ */ diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index cbcf57d769..0256eba456 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -16,30 +16,7 @@ #include "nfp_ipsec.h" #include "nfp_logs.h" - -/* Maximum number of supported VLANs in parsed form packet metadata. */ -#define NFP_META_MAX_VLANS 2 - -/* Record metadata parsed from packet */ -struct nfp_meta_parsed { - uint32_t port_id; /**< Port id value */ - uint32_t sa_idx; /**< IPsec SA index */ - uint32_t hash; /**< RSS hash value */ - uint32_t mark_id; /**< Mark id value */ - uint16_t flags; /**< Bitmap to indicate if meta exist */ - uint8_t hash_type; /**< RSS hash type */ - uint8_t ipsec_type; /**< IPsec type */ - uint8_t vlan_layer; /**< The valid number of value in @vlan[] */ - /** - * Holds information parses from NFP_NET_META_VLAN. - * The inner most vlan starts at position 0 - */ - struct { - uint8_t offload; /**< Flag indicates whether VLAN is offloaded */ - uint8_t tpid; /**< Vlan TPID */ - uint16_t tci; /**< Vlan TCI (PCP + Priority + VID) */ - } vlan[NFP_META_MAX_VLANS]; -}; +#include "nfp_net_meta.h" /* * The bit format and map of nfp packet type for rxd.offload_info in Rx descriptor. @@ -254,242 +231,6 @@ nfp_net_rx_queue_count(void *rx_queue) return count; } -/* Parse the chained metadata from packet */ -static bool -nfp_net_parse_chained_meta(uint8_t *meta_base, - rte_be32_t meta_header, - struct nfp_meta_parsed *meta) -{ - uint32_t meta_info; - uint32_t vlan_info; - uint8_t *meta_offset; - - meta_info = rte_be_to_cpu_32(meta_header); - meta_offset = meta_base + 4; - - for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, meta_offset += 4) { - switch (meta_info & NFP_NET_META_FIELD_MASK) { - case NFP_NET_META_PORTID: - meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - break; - case NFP_NET_META_HASH: - /* Next field type is about the hash type */ - meta_info >>= NFP_NET_META_FIELD_SIZE; - /* Hash value is in the data field */ - meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK; - break; - case NFP_NET_META_VLAN: - vlan_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - meta->vlan[meta->vlan_layer].offload = - vlan_info >> NFP_NET_META_VLAN_OFFLOAD; - meta->vlan[meta->vlan_layer].tci = - vlan_info & NFP_NET_META_VLAN_MASK; - meta->vlan[meta->vlan_layer].tpid = NFP_NET_META_TPID(vlan_info); - meta->vlan_layer++; - break; - case NFP_NET_META_IPSEC: - meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK; - break; - case NFP_NET_META_MARK: - meta->flags |= (1 << NFP_NET_META_MARK); - meta->mark_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - break; - default: - /* Unsupported metadata can be a performance issue */ - return false; - } - } - - return true; -} - -/* Set mbuf hash data based on the metadata info */ -static void -nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta, - struct nfp_net_rxq *rxq, - struct rte_mbuf *mbuf) -{ - struct nfp_net_hw *hw = rxq->hw; - - if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) - return; - - mbuf->hash.rss = meta->hash; - mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH; -} - -/* - * Parse the single metadata - * - * The RSS hash and hash-type are prepended to the packet data. - * Get it from metadata area. - */ -static inline void -nfp_net_parse_single_meta(uint8_t *meta_base, - rte_be32_t meta_header, - struct nfp_meta_parsed *meta) -{ - meta->hash_type = rte_be_to_cpu_32(meta_header); - meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4)); -} - -/* Set mbuf vlan_strip data based on metadata info */ -static void -nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta, - struct nfp_net_rx_desc *rxd, - struct nfp_net_rxq *rxq, - struct rte_mbuf *mb) -{ - uint32_t ctrl = rxq->hw->super.ctrl; - - /* Skip if hardware don't support setting vlan. */ - if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0) - return; - - /* - * The firmware support two ways to send the VLAN info (with priority) : - * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set, - * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set. - */ - if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) { - if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) { - mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci); - mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; - } - } else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) { - if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) { - mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info); - mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; - } - } -} - -/* - * Set mbuf qinq_strip data based on metadata info - * - * The out VLAN tci are prepended to the packet data. - * Extract and decode it and set the mbuf fields. - * - * If both RTE_MBUF_F_RX_VLAN and NFP_NET_CFG_CTRL_RXQINQ are set, the 2 VLANs - * have been stripped by the hardware and their TCIs are saved in - * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer). - * If NFP_NET_CFG_CTRL_RXQINQ is set and RTE_MBUF_F_RX_VLAN is unset, only the - * outer VLAN is removed from packet data, but both tci are saved in - * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer). - * - * qinq set & vlan set : meta->vlan_layer>=2, meta->vlan[0].offload=1, meta->vlan[1].offload=1 - * qinq set & vlan not set: meta->vlan_layer>=2, meta->vlan[1].offload=1,meta->vlan[0].offload=0 - * qinq not set & vlan set: meta->vlan_layer=1, meta->vlan[0].offload=1 - * qinq not set & vlan not set: meta->vlan_layer=0 - */ -static void -nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta, - struct nfp_net_rxq *rxq, - struct rte_mbuf *mb) -{ - struct nfp_hw *hw = &rxq->hw->super; - - if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0) - return; - - if (meta->vlan_layer < NFP_META_MAX_VLANS) - return; - - if (meta->vlan[0].offload == 0) - mb->vlan_tci = rte_cpu_to_le_16(meta->vlan[0].tci); - - mb->vlan_tci_outer = rte_cpu_to_le_16(meta->vlan[1].tci); - PMD_RX_LOG(DEBUG, "Received outer vlan TCI is %u inner vlan TCI is %u", - mb->vlan_tci_outer, mb->vlan_tci); - mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED; -} - -/* - * Set mbuf IPsec Offload features based on metadata info. - * - * The IPsec Offload features is prepended to the mbuf ol_flags. - * Extract and decode metadata info and set the mbuf ol_flags. - */ -static void -nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta, - struct nfp_net_rxq *rxq, - struct rte_mbuf *mbuf) -{ - int offset; - uint32_t sa_idx; - struct nfp_net_hw *hw; - struct nfp_tx_ipsec_desc_msg *desc_md; - - hw = rxq->hw; - sa_idx = meta->sa_idx; - - if (meta->ipsec_type != NFP_NET_META_IPSEC) - return; - - if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) { - mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED; - } else { - mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD; - offset = hw->ipsec_data->pkt_dynfield_offset; - desc_md = RTE_MBUF_DYNFIELD(mbuf, offset, struct nfp_tx_ipsec_desc_msg *); - desc_md->sa_idx = sa_idx; - desc_md->enc = 0; - } -} - -static void -nfp_net_parse_meta_mark(const struct nfp_meta_parsed *meta, - struct rte_mbuf *mbuf) -{ - if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0) - return; - - mbuf->hash.fdir.hi = meta->mark_id; - mbuf->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID; -} - -/* Parse the metadata from packet */ -static void -nfp_net_parse_meta(struct nfp_net_rx_desc *rxds, - struct nfp_net_rxq *rxq, - struct nfp_net_hw *hw, - struct rte_mbuf *mb, - struct nfp_meta_parsed *meta) -{ - uint8_t *meta_base; - rte_be32_t meta_header; - - if (unlikely(NFP_DESC_META_LEN(rxds) == 0)) - return; - - meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds)); - meta_header = *(rte_be32_t *)meta_base; - - switch (hw->meta_format) { - case NFP_NET_METAFORMAT_CHAINED: - if (nfp_net_parse_chained_meta(meta_base, meta_header, meta)) { - nfp_net_parse_meta_hash(meta, rxq, mb); - nfp_net_parse_meta_vlan(meta, rxds, rxq, mb); - nfp_net_parse_meta_qinq(meta, rxq, mb); - nfp_net_parse_meta_ipsec(meta, rxq, mb); - nfp_net_parse_meta_mark(meta, mb); - } else { - PMD_RX_LOG(DEBUG, "RX chained metadata format is wrong!"); - } - break; - case NFP_NET_METAFORMAT_SINGLE: - if ((rxds->rxd.flags & PCIE_DESC_RX_RSS) != 0) { - nfp_net_parse_single_meta(meta_base, meta_header, meta); - nfp_net_parse_meta_hash(meta, rxq, mb); - } - break; - default: - PMD_RX_LOG(DEBUG, "RX metadata do not exist."); - } -} - /** * Set packet type to mbuf based on parsed structure. * @@ -1038,50 +779,6 @@ nfp_net_reset_tx_queue(struct nfp_net_txq *txq) txq->rd_p = 0; } -void -nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data, - struct rte_mbuf *pkt, - uint8_t layer) -{ - uint16_t tpid; - uint16_t vlan_tci; - - tpid = RTE_ETHER_TYPE_VLAN; - vlan_tci = pkt->vlan_tci; - - meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci); -} - -void -nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data, - struct nfp_net_txq *txq, - struct rte_mbuf *pkt, - uint8_t layer, - uint8_t ipsec_layer) -{ - int offset; - struct nfp_net_hw *hw; - struct nfp_tx_ipsec_desc_msg *desc_md; - - hw = txq->hw; - offset = hw->ipsec_data->pkt_dynfield_offset; - desc_md = RTE_MBUF_DYNFIELD(pkt, offset, struct nfp_tx_ipsec_desc_msg *); - - switch (ipsec_layer) { - case NFP_IPSEC_META_SAIDX: - meta_data->data[layer] = desc_md->sa_idx; - break; - case NFP_IPSEC_META_SEQLOW: - meta_data->data[layer] = desc_md->esn.low; - break; - case NFP_IPSEC_META_SEQHI: - meta_data->data[layer] = desc_md->esn.hi; - break; - default: - break; - } -} - int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 5695a31636..6ecabc232c 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -8,18 +8,6 @@ #include -#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) - -/* Maximum number of NFP packet metadata fields. */ -#define NFP_META_MAX_FIELDS 8 - -/* Describe the raw metadata format. */ -struct nfp_net_meta_raw { - uint32_t header; /**< Field type header (see format in nfp.rst) */ - uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */ - uint8_t length; /**< Number of valid fields in @header */ -}; - /* Descriptor alignment */ #define NFP_ALIGN_RING_DESC 128 @@ -238,13 +226,5 @@ int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); uint32_t nfp_net_tx_free_bufs(struct nfp_net_txq *txq); -void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data, - struct rte_mbuf *pkt, - uint8_t layer); -void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data, - struct nfp_net_txq *txq, - struct rte_mbuf *pkt, - uint8_t layer, - uint8_t ipsec_layer); #endif /* __NFP_RXTX_H__ */ -- 2.39.1