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 3E6E741CF5; Tue, 21 Feb 2023 04:29:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5DD643158; Tue, 21 Feb 2023 04:29:28 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2097.outbound.protection.outlook.com [40.107.212.97]) by mails.dpdk.org (Postfix) with ESMTP id 0B5124314A for ; Tue, 21 Feb 2023 04:29:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/TXQ3QoXTXkTfn7oYNBvK149TOw6DuvZ+aiIW58BjHN65z5bpzsA2DVxfrnBwPhd96aCBbg0g5F4pb97lBdcVHWAPz4gZn/9lDhR/9kz8a++Fs6GdpC7ECyRsEgZb5LsLxe/CzFW6UlocW9FPMp7XOTDgpQfllMr1+5Y9eiHeMftxYAj9CsIgH6336SeF79uY9ES2uUSEigT37d37Fcob2muqpz6eLSHRMHwLJ15fjfLReSKFmJGEf3unz1WKGjcXI8Ughx/HXwi4JISP8gLDFnE6Qw9bqYClQ86bRKNPkXtAiDRIyJauR3C6On0Mfmn6TMTWkW18BJ676wkAF4tg== 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=1i9x1rM91w0oasQOHGmPtV99hAuWOycVjz0p1cUZiek=; b=KBN5l5ghB5k9OTKufcIC9ngTFIJuR9cpNd4S+iZWwRI8WG4bGAm3bFZdI9/9LzDaFtD1A/TIHaCKL+iVM2CIJmGEgubSQ7ZH/TkYkC5uow9W3NUVXwUW718UOiEBBV6ZyS1/Hq2yMAq9Kl3TUitei4OBNOBHEYSFwaig+F37Gi6Ca07fsgyLreN6b64VlH52TIWt2zpQ/YyEZMRaoTwT4KiyBCoiNobmJojo0COkfOR2LtbFDyD2pTklYAHaDcmFqIOADCazKsbvKv2INPhfnW0HcL43hRzdHJ7DEdA29b0zT3o7KbgbYVeQ1V/8c+cLRJtyvPHvH8QXLbbYiX51Gg== 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=1i9x1rM91w0oasQOHGmPtV99hAuWOycVjz0p1cUZiek=; b=PbGZr6b8L+i8rUuoRElBtrpxcHVP6D+9GzdHD8cieAiO2Vt/jMgWm9pBzM4ChqLafT7SsZOz5s2hQfnEZvBrDi5iZ3XiS8P1+aBo+wsGPd4DIlJdkVBTxuAIb7HqV1WLURLEF9EF8iv97zZtcZV3Z8iEyXHsk853msZnWTdGhQg= 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 PH7PR13MB5479.namprd13.prod.outlook.com (2603:10b6:510:139::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Tue, 21 Feb 2023 03:29:26 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7ea4:e421:5dd5:9f4d]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7ea4:e421:5dd5:9f4d%7]) with mapi id 15.20.6111.021; Tue, 21 Feb 2023 03:29:26 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Long Wu , Chaoyong He Subject: [PATCH v2 2/2] net/nfp: modify RSS's processing logic Date: Tue, 21 Feb 2023 11:29:09 +0800 Message-Id: <20230221032909.16888-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20230221032909.16888-1-chaoyong.he@corigine.com> References: <20230221031055.5484-1-chaoyong.he@corigine.com> <20230221032909.16888-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR03CA0168.namprd03.prod.outlook.com (2603:10b6:a03:338::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5479:EE_ X-MS-Office365-Filtering-Correlation-Id: 68e8f41a-b721-4502-8350-08db13bbd501 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lDrA7yaKSLo5vwgSyk5JUscWelHV3GxEoEty8am8CPXn7rfDJyX3vGUtvZUJqjWgSaOTFbwuo2WxoeZqZg/Z+w4k4z7sl3ZXj63AL3qjLiMPOydyZh7+7aszVrY0ZorXwxXfnn9rlnCYIf+7Vdq6gLafkS9E20V/h1HYWFa13W2miXYKvtNiGdPpj0OmFUVr1y8jT6OS/FDcHRb7Y7DEkwYXgo5m3V5rauaJEb1G4/jj+pK6Mlz5t93IAOa/Yr5DocRQRvJUoGDyIydYtT8Qw7MlBat2dSu1jozsqbiMXCd+RnLme53TYESlqvVjssgErQQ7Ac2ErIT/XJVciEFQ3JwZcuU6Qf0tXCRrzjfM2vnU9+aMZRxNCDubxaPVF2Cg599tpyjt31k/04I3mQdMC9e7z8Oi2GMsoG4BgZjgGQaAgcIeYxKaMcmzt0gqQgXDqiOZfuqRz5Aep70ZceWagoKnVZ5NllMnH8sOHFQniOswTnRQ2Zae5gE+gnBu7jYpK8Y+llDNfqSOgfYnMc3cAXxBijPBKaX+yu04HcQ/xiJaGv5LmTWKtnX1Bdd/7bk82GrfyGPZ/3Ayiee1l3NKQgifKBJxUoDbw4oOzS/fZBraEatVgCkA5SkzITehyYlD0swDSm+c/9MaOaYoHzc3ivw103408rof2VJ0ZKRHftgsrGD/V30YJfDhokQ3Q33sQRTlV/OZEY2evKXoBUmo+DfVIP2xaVS8Kd2oMmO2W8iEVkARngpBxrTYG9J2cbcK 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:(13230025)(4636009)(366004)(346002)(376002)(39840400004)(136003)(396003)(451199018)(36756003)(86362001)(4326008)(66476007)(316002)(6916009)(8676002)(66946007)(41300700001)(5660300002)(54906003)(52116002)(66556008)(44832011)(8936002)(6486002)(2906002)(83380400001)(38350700002)(30864003)(6506007)(26005)(6666004)(6512007)(1076003)(186003)(107886003)(478600001)(66574015)(2616005)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d1RRQzZkRmozVXJ1cCtKYUxYbHR3UG1ZMm9WNkdxclF0ekowZ016YkxIaGVh?= =?utf-8?B?alJhSTRNSWhLWU92RU0ydzdxN0xXc0wzMUVaVEdmQ2trZ2c4ZkE0ZU55L1kv?= =?utf-8?B?Y0Vzd3d1ZGNXSW4zQ0o4ZXkrZ0FreEhXZ3lvbks0M2x1Q0QvdU93UW1qbThH?= =?utf-8?B?cndtK0NQZDZoL2hKelpxVzdDOFQ0MDUyVW8reHZSUzd6Z2QvTS9nbnd3RnJP?= =?utf-8?B?Y3ZHdWZ6NmZKaDFpeGowcHdESkhNUEdzaW5MVWZqRGpKdEVRRH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OE45U0JoOWhSWGN4aWY1MVZPRWRpWFhWR0RjbnY2TDIrMjIv?= =?utf-8?B?TEFUbTJzTnY4ZHhvMlMwaTlPQTZPbnZPREZjRWZXeCtJT1pEQlRzYUM3Z2hN?= =?utf-8?B?Zmc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68e8f41a-b721-4502-8350-08db13bbd501 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2023 03:29:26.0591 (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: 1Z0pPRy3v/y64bgJ9eIlEWcbH4l3m2Dcu8IjnFs2guo8aiyThKe+LMNqvPdm//ZJvBFvT9bkjo0VfHOCYn+3Bpz1E4g6m7sUJYxeknnwUgk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5479 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 The initial logic only support the single type metadata and this commit add the support of chained type metadata. This commit also make the relation between the RSS capability (v1/v2) and these two types of metadata more clear. Signed-off-by: Long Wu Reviewed-by: Niklas Söderlund Reviewed-by: Chaoyong He --- drivers/net/nfp/nfp_common.c | 23 +++++++ drivers/net/nfp/nfp_common.h | 7 +++ drivers/net/nfp/nfp_ctrl.h | 18 +++++- drivers/net/nfp/nfp_ethdev.c | 7 +-- drivers/net/nfp/nfp_ethdev_vf.c | 7 +-- drivers/net/nfp/nfp_rxtx.c | 108 ++++++++++++++++++++------------ 6 files changed, 121 insertions(+), 49 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index a545a10013..a1e37ada11 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -1584,6 +1584,29 @@ nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name) 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 (NFD_CFG_MAJOR_VERSION_of(hw->ver) == 4) { + hw->meta_format = NFP_NET_METAFORMAT_CHANINED; + } else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) { + hw->meta_format = NFP_NET_METAFORMAT_CHANINED; + /* + * RSS is incompatible with chained metadata. hw->cap just represents + * firmware's ability rather than the firmware's configuration. We decide + * to reduce the confusion to allow us can use hw->cap to identify RSS later. + */ + hw->cap &= ~NFP_NET_CFG_CTRL_RSS; + } else { + hw->meta_format = NFP_NET_METAFORMAT_SINGLE; + } +} + /* * Local variables: * c-file-style: "Linux" diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 980f3cad89..d33675eb99 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -127,6 +127,11 @@ enum nfp_qcp_ptr { NFP_QCP_WRITE_PTR }; +enum nfp_net_meta_format { + NFP_NET_METAFORMAT_SINGLE, + NFP_NET_METAFORMAT_CHANINED, +}; + struct nfp_pf_dev { /* Backpointer to associated pci device */ struct rte_pci_device *pci_dev; @@ -203,6 +208,7 @@ struct nfp_net_hw { uint32_t max_mtu; uint32_t mtu; uint32_t rx_offset; + enum nfp_net_meta_format meta_format; /* Current values for control */ uint32_t ctrl; @@ -455,6 +461,7 @@ int 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); #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ (&((struct nfp_net_adapter *)adapter)->hw) diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h index 1069ff9485..bdc39f8974 100644 --- a/drivers/net/nfp/nfp_ctrl.h +++ b/drivers/net/nfp/nfp_ctrl.h @@ -110,6 +110,7 @@ #define NFP_NET_CFG_CTRL_MSIX_TX_OFF (0x1 << 26) /* Disable MSIX for TX */ #define NFP_NET_CFG_CTRL_LSO2 (0x1 << 28) /* LSO/TSO (version 2) */ #define NFP_NET_CFG_CTRL_RSS2 (0x1 << 29) /* RSS (version 2) */ +#define NFP_NET_CFG_CTRL_CSUM_COMPLETE (0x1 << 30) /* Checksum complete */ #define NFP_NET_CFG_CTRL_LIVE_ADDR (0x1U << 31)/* live MAC addr change */ #define NFP_NET_CFG_UPDATE 0x0004 #define NFP_NET_CFG_UPDATE_GEN (0x1 << 0) /* General update */ @@ -135,6 +136,8 @@ #define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2) #define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2) +#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \ + NFP_NET_CFG_CTRL_CSUM_COMPLETE) /* * Read-only words (0x0030 - 0x0050): * @NFP_NET_CFG_VERSION: Firmware version number @@ -218,7 +221,7 @@ /* * RSS configuration (0x0100 - 0x01ac): - * Used only when NFP_NET_CFG_CTRL_RSS is enabled + * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled * @NFP_NET_CFG_RSS_CFG: RSS configuration word * @NFP_NET_CFG_RSS_KEY: RSS "secret" key * @NFP_NET_CFG_RSS_ITBL: RSS indirection table @@ -334,6 +337,19 @@ /* PF multiport offset */ #define NFP_PF_CSR_SLICE_SIZE (32 * 1024) +/* + * nfp_net_cfg_ctrl_rss() - Get RSS flag based on firmware's capability + * @hw_cap: The firmware's capabilities + */ +static inline uint32_t +nfp_net_cfg_ctrl_rss(uint32_t hw_cap) +{ + if ((hw_cap & NFP_NET_CFG_CTRL_RSS2) != 0) + return NFP_NET_CFG_CTRL_RSS2; + + return NFP_NET_CFG_CTRL_RSS; +} + #endif /* _NFP_CTRL_H_ */ /* * Local variables: diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index fed7b1ab13..47d5dff16c 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -134,10 +134,7 @@ nfp_net_start(struct rte_eth_dev *dev) if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) { nfp_net_rss_config_default(dev); update |= NFP_NET_CFG_UPDATE_RSS; - if (hw->cap & NFP_NET_CFG_CTRL_RSS2) - new_ctrl |= NFP_NET_CFG_CTRL_RSS2; - else - new_ctrl |= NFP_NET_CFG_CTRL_RSS; + new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap); } /* Enable device */ @@ -611,6 +608,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev) if (hw->cap & NFP_NET_CFG_CTRL_LSO2) hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN; + nfp_net_init_metadata_format(hw); + if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index c1f8a0fa0f..7834b2ee0c 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -95,10 +95,7 @@ nfp_netvf_start(struct rte_eth_dev *dev) if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) { nfp_net_rss_config_default(dev); update |= NFP_NET_CFG_UPDATE_RSS; - if (hw->cap & NFP_NET_CFG_CTRL_RSS2) - new_ctrl |= NFP_NET_CFG_CTRL_RSS2; - else - new_ctrl |= NFP_NET_CFG_CTRL_RSS; + new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap); } /* Enable device */ @@ -373,6 +370,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) if (hw->cap & NFP_NET_CFG_CTRL_LSO2) hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN; + nfp_net_init_metadata_format(hw); + if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 17a04cec5e..1c5a230145 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -116,26 +116,18 @@ nfp_net_rx_queue_count(void *rx_queue) return count; } -/* nfp_net_parse_meta() - Parse the metadata from packet */ -static void -nfp_net_parse_meta(struct nfp_meta_parsed *meta, - struct nfp_net_rx_desc *rxd, - struct nfp_net_rxq *rxq, - struct rte_mbuf *mbuf) +/* nfp_net_parse_chained_meta() - 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) { + uint8_t *meta_offset; uint32_t meta_info; uint32_t vlan_info; - uint8_t *meta_offset; - struct nfp_net_hw *hw = rxq->hw; - if (unlikely((NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) || - NFP_DESC_META_LEN(rxd) == 0)) - return; - - meta_offset = rte_pktmbuf_mtod(mbuf, uint8_t *); - meta_offset -= NFP_DESC_META_LEN(rxd); - meta_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); - meta_offset += 4; + 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) { @@ -157,9 +149,11 @@ nfp_net_parse_meta(struct nfp_meta_parsed *meta, break; default: /* Unsupported metadata can be a performance issue */ - return; + return false; } } + + return true; } /* @@ -170,33 +164,18 @@ nfp_net_parse_meta(struct nfp_meta_parsed *meta, */ static void nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta, - struct nfp_net_rx_desc *rxd, struct nfp_net_rxq *rxq, struct rte_mbuf *mbuf) { - uint32_t hash; - uint32_t hash_type; struct nfp_net_hw *hw = rxq->hw; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) return; - if (likely((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0 && - NFP_DESC_META_LEN(rxd) != 0)) { - hash = meta->hash; - hash_type = meta->hash_type; - } else { - if ((rxd->rxd.flags & PCIE_DESC_RX_RSS) == 0) - return; - - hash = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_OFFSET); - hash_type = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_TYPE_OFFSET); - } - - mbuf->hash.rss = hash; + mbuf->hash.rss = meta->hash; mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH; - switch (hash_type) { + switch (meta->hash_type) { case NFP_NET_RSS_IPV4: mbuf->packet_type |= RTE_PTYPE_INNER_L3_IPV4; break; @@ -223,6 +202,21 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta, } } +/* + * nfp_net_parse_single_meta() - 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)); +} + /* * nfp_net_parse_meta_vlan() - Set mbuf vlan_strip data based on metadata info * @@ -304,6 +298,45 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta, mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED; } +/* nfp_net_parse_meta() - 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) +{ + uint8_t *meta_base; + rte_be32_t meta_header; + struct nfp_meta_parsed meta = {}; + + if (unlikely(NFP_DESC_META_LEN(rxds) == 0)) + return; + + meta_base = rte_pktmbuf_mtod(mb, uint8_t *); + meta_base -= NFP_DESC_META_LEN(rxds); + meta_header = *(rte_be32_t *)meta_base; + + switch (hw->meta_format) { + case NFP_NET_METAFORMAT_CHANINED: + 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); + } 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."); + } +} + /* * RX path design: * @@ -341,7 +374,6 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) struct nfp_net_hw *hw; struct rte_mbuf *mb; struct rte_mbuf *new_mb; - struct nfp_meta_parsed meta; uint16_t nb_hold; uint64_t dma_addr; uint16_t avail; @@ -437,11 +469,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) mb->next = NULL; mb->port = rxq->port_id; - memset(&meta, 0, sizeof(meta)); - nfp_net_parse_meta(&meta, rxds, rxq, mb); - nfp_net_parse_meta_hash(&meta, rxds, rxq, mb); - nfp_net_parse_meta_vlan(&meta, rxds, rxq, mb); - nfp_net_parse_meta_qinq(&meta, rxq, mb); + nfp_net_parse_meta(rxds, rxq, hw, mb); /* Checking the checksum flag */ nfp_net_rx_cksum(rxq, rxds, mb); -- 2.29.3