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 77C5FA00C5; Tue, 21 Jun 2022 12:35:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A92744280E; Tue, 21 Jun 2022 12:34:22 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2126.outbound.protection.outlook.com [40.107.101.126]) by mails.dpdk.org (Postfix) with ESMTP id 9BF694281E for ; Tue, 21 Jun 2022 12:34:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ROyQ+Kd5m81pqqmo2Z+9gRfn/XIIH9hswUW54jgfsYR6mmnLOR4ruXHghcTJLYyiyy2riRO1HNnJUoXtidyoOnJtrqJ4pwnwF/uu3w03+B6H05dzgK80NrWGaIow4AHo3Ez0tFw5WncOFTCmv/tug2XWYzqGGmijk+HiA0VktbEL0++ghvSIkvIfzu14vUGvyGN7W0XRs8nAKyFSgBM+iHAtbg7SktTNYIcYRhixWgI+RZg/Jvgp+W0Cb3dfTew5lKQxpZkezhQ1y7lMsdnPKriSLRmo94CdXcXEtfEfA7oFezOonwwvFXgAZQScjA7tUh+RpffvdullcH3/mBxlQA== 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=RLih/exeeLcgDytXAfmMlOu3aV521w+DOOxrwU9CsuM=; b=BZz2PtXREFFruNU9c3B8jVJMcsIUtGVy4ukueUrbtSESKlxO0ALba8f5JJ3uInkbix0D4mTBge8MvQm5ohR8tUca/lfusC94NdNHNnVQtQIGlVxtz4F6YxCBEVS2gmQOhNMW+BuW1dkIMku20uKPzxgKLvRJxG0bHUvwLOzoJ8KqXddObG2v7S3wXL+TFDW2gYZqcmIyUaiONEQTH5LZLalsX3mG52OcM1hh9zJVOEpWuU4vn9HOvc6vWGvnp9ztyZdNJGS7jFUPboYC+ZOKa0Qkx6I0LU6d6Oz9riGkeeYs7N3KCK5gfWHRFJQXGd+VXngVCB3Ea+COgDoyZ7oOvw== 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=RLih/exeeLcgDytXAfmMlOu3aV521w+DOOxrwU9CsuM=; b=Ez96jE5BMEadBnJJkcRsn9qZUhFN5xwbauwANPbmK73wX/Hj2iRN0CvuY8nHEUfWImM5eJ5PHawGLDVaiQJxYR7K+bKZNa4QwkdDox0aI8Yj1253lD7G9A1WAhwlEvbUcPhJoNvVL5irf4LWcY44c9E+A+yxYyqHMGIoN4joKIA= 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 MWHPR13MB1583.namprd13.prod.outlook.com (2603:10b6:300:125::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Tue, 21 Jun 2022 10:34:18 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021%7]) with mapi id 15.20.5373.015; Tue, 21 Jun 2022 10:34:17 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v2 11/12] net/nfp: move rxtx function to header file Date: Tue, 21 Jun 2022 18:33:07 +0800 Message-Id: <1655807588-7320-12-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> References: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0PR01CA0018.jpnprd01.prod.outlook.com (2603:1096:604:24::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22bea3c5-8c55-490c-8538-08da537197c6 X-MS-TrafficTypeDiagnostic: MWHPR13MB1583:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XVleEbqkkzuwn0HtR+L5krA6I0F2s80VwYyYqIWKhZ+INsChI/tk4Y2dGh0NSlYoR0qv4Vw76GTVe+pD95NmUmC0WvZ2MojapuSXPpSSJc9I2LwI7TKClDURGI9AtORr9jqd3R29D9nzG4OlcOcXaBX9vpseh+0DSS8mT5pfShY6BGBG1G4KVObdMVNiWWsI0nyTYvNprBIEkkMPmWbDGlevBdMXq+/NIJZGpZMgioyfWJf7ipA/uh05IPNBHCRpl5mw3dLHVXHx1gtPbeRfsHC3xFnUT4UXEHE30Odk/KeE8vRKzButnA0Ujv7MdlCv+GD1Cg3npRd5jXG03tLsDUotsAfCCkOZ9dSw2GH7FKSyAXtUO68T0yWvJcr62b9F2FytLkWVwRDP5N5FUZgm+Vm/DBaRimztmK7sYXiVkCfrOtXCtmdu9ZDxDTfcoh+bSIbkLRij1iIrFv6UEhpFonXIjG8BP5Ch+3uQZvwlqz/w0EFKWHYQ7Pwgg4KwaXDEQZjbmmp47Uak9XgCxxR5O1hDV4OdseprdOhz80P49qyMQkmSZ9E3HM3Ua6cvRRG5xO0a0bsVaiApDcRVQ3TLtgzYdACO1cWvKyWemDakEVVyY+IZP07YAnSsEO3VchRd2qb1/juulL2NDVYmPabW495eX1YkGoj2QV7WuxByiGM+wkVH2UQcKEddCE1H6YhRBu26lI8QA4+ONILuCp5AnA== 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:(13230016)(4636009)(39840400004)(136003)(376002)(396003)(346002)(366004)(186003)(6512007)(107886003)(2616005)(41300700001)(6506007)(8936002)(6666004)(26005)(52116002)(38100700002)(2906002)(86362001)(38350700002)(4326008)(83380400001)(44832011)(5660300002)(316002)(6916009)(478600001)(8676002)(66476007)(66556008)(54906003)(66946007)(6486002)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z1RhVk9EUGgrZ01RVDJNQnQ2eW9zdVRuSjFUUjdHd0Q1Q3dzOXBHZmpMR0dH?= =?utf-8?B?N2RxTkEzdzYrdFAzVGQ4aE43R2FscDBqeGZBMnUxdHNVVHpTNk5xU2xUelVR?= =?utf-8?B?Mjl6NkwyNDY3M3lPakVUbm1ES1lnRDhJd3R5QzJFQ0xFdTlOT1dOQlBzMW4x?= =?utf-8?B?Yldmd0s0Mm5uZjFZekR0WXZvQXRXWDhKZlNWTVdVYXZJM0V6dWt4NlpRNlJi?= =?utf-8?B?NFVUVnBWc3NHam43SzdES0lBQW43dHk2bWdSUDltaHhMcG83Yi9La2kvQWgr?= =?utf-8?B?RjJ1a3RvRDF0NzlUL0MwSVZTWnRVU3hzUkErR1g4OXNYeU1jK05QZnBwZkE3?= =?utf-8?B?RnF4Zl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U1YnJtTEpnc0pj?= =?utf-8?B?TndoREhEVytDNEFmR09FbmxxNHdFR05lRG1ZZGkvSTNLR3VaYWlJbDJTYW8v?= =?utf-8?B?VFJGczEyRHpPTTZoNDVJTUtXTGRSM0p5VVZWUFlpd2JKT3VTZ2hiN050RE8y?= =?utf-8?B?SEhGZDgwczVqV0JqQ3MwMUFvZEhUOS80V0ZCeE1sUDFPS1l5SE5sdTQwcHRC?= =?utf-8?Q?qE29SJTmW9WlCBE0=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22bea3c5-8c55-490c-8538-08da537197c6 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 10:34:17.4919 (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: RMyHyg65rRrLvHTe3zJYtaAVCo3dC0NyWJEOLyqOD8KtfbdWfjvoKcq+45KrfbLu9Xk7//ia/GcWcZ8fdA5EKn7AOTvu66Y/TeIAG9Giybo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR13MB1583 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 Flower makes use of the same Rx and Tx checksum logic as the normal PMD. Expose it so that flower can make use of it. Signed-off-by: Chaoyong He Signed-off-by: Heinrich Kuhn Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfp_common.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 2 +- drivers/net/nfp/nfp_ethdev_vf.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 91 +---------------------------------------- drivers/net/nfp/nfp_rxtx.h | 90 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 93 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 0e55f0c..e86929c 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -38,9 +38,9 @@ #include "nfpcore/nfp_nsp.h" #include "nfp_common.h" +#include "nfp_ctrl.h" #include "nfp_rxtx.h" #include "nfp_logs.h" -#include "nfp_ctrl.h" #include "nfp_cpp_bridge.h" #include diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 4ab89db..a647f66 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -33,9 +33,9 @@ #include "nfpcore/nfp_nsp.h" #include "nfp_common.h" +#include "nfp_ctrl.h" #include "nfp_rxtx.h" #include "nfp_logs.h" -#include "nfp_ctrl.h" #include "nfp_cpp_bridge.h" #include "flower/nfp_flower.h" diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index d304d78..ceaf618 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -19,9 +19,9 @@ #include "nfpcore/nfp_rtsym.h" #include "nfp_common.h" +#include "nfp_ctrl.h" #include "nfp_rxtx.h" #include "nfp_logs.h" -#include "nfp_ctrl.h" static void nfp_netvf_read_mac(struct nfp_net_hw *hw) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index cdcf5c2..7a6757c 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -17,9 +17,9 @@ #include #include "nfp_common.h" +#include "nfp_ctrl.h" #include "nfp_rxtx.h" #include "nfp_logs.h" -#include "nfp_ctrl.h" #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_rtsym.h" #include "nfpcore/nfp-common/nfp_platform.h" @@ -208,34 +208,6 @@ } } -/* nfp_net_rx_cksum - set mbuf checksum flags based on RX descriptor flags */ -static inline void -nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd, - struct rte_mbuf *mb) -{ - struct nfp_net_hw *hw = rxq->hw; - - if (!(hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM)) - return; - - /* If IPv4 and IP checksum error, fail */ - if (unlikely((rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM) && - !(rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM_OK))) - mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; - else - mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; - - /* If neither UDP nor TCP return */ - if (!(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) && - !(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM)) - return; - - if (likely(rxd->rxd.flags & PCIE_DESC_RX_L4_CSUM_OK)) - mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; - else - mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; -} - /* * RX path design: * @@ -768,67 +740,6 @@ return 0; } -/* nfp_net_tx_tso - Set TX descriptor for TSO */ -static inline void -nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd, - struct rte_mbuf *mb) -{ - uint64_t ol_flags; - struct nfp_net_hw *hw = txq->hw; - - if (!(hw->cap & NFP_NET_CFG_CTRL_LSO_ANY)) - goto clean_txd; - - ol_flags = mb->ol_flags; - - if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) - goto clean_txd; - - txd->l3_offset = mb->l2_len; - txd->l4_offset = mb->l2_len + mb->l3_len; - txd->lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len; - txd->mss = rte_cpu_to_le_16(mb->tso_segsz); - txd->flags = PCIE_DESC_TX_LSO; - return; - -clean_txd: - txd->flags = 0; - txd->l3_offset = 0; - txd->l4_offset = 0; - txd->lso_hdrlen = 0; - txd->mss = 0; -} - -/* nfp_net_tx_cksum - Set TX CSUM offload flags in TX descriptor */ -static inline void -nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd, - struct rte_mbuf *mb) -{ - uint64_t ol_flags; - struct nfp_net_hw *hw = txq->hw; - - if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM)) - return; - - ol_flags = mb->ol_flags; - - /* IPv6 does not need checksum */ - if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) - txd->flags |= PCIE_DESC_TX_IP4_CSUM; - - switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) { - case RTE_MBUF_F_TX_UDP_CKSUM: - txd->flags |= PCIE_DESC_TX_UDP_CSUM; - break; - case RTE_MBUF_F_TX_TCP_CKSUM: - txd->flags |= PCIE_DESC_TX_TCP_CSUM; - break; - } - - if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK)) - txd->flags |= PCIE_DESC_TX_CSUM; -} - uint16_t nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index a30171f..cd70bdd 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -360,6 +360,96 @@ struct nfp_net_rxq { return (nfp_net_nfd3_free_tx_desc(txq) < txq->tx_free_thresh); } +/* set mbuf checksum flags based on RX descriptor flags */ +static inline void +nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd, + struct rte_mbuf *mb) +{ + struct nfp_net_hw *hw = rxq->hw; + + if (!(hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM)) + return; + + /* If IPv4 and IP checksum error, fail */ + if (unlikely((rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM) && + !(rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM_OK))) + mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; + else + mb->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; + + /* If neither UDP nor TCP return */ + if (!(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) && + !(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM)) + return; + + if (likely(rxd->rxd.flags & PCIE_DESC_RX_L4_CSUM_OK)) + mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; + else + mb->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; +} + +/* Set NFD3 TX descriptor for TSO */ +static inline void +nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq, + struct nfp_net_nfd3_tx_desc *txd, + struct rte_mbuf *mb) +{ + uint64_t ol_flags; + struct nfp_net_hw *hw = txq->hw; + + if (!(hw->cap & NFP_NET_CFG_CTRL_LSO_ANY)) + goto clean_txd; + + ol_flags = mb->ol_flags; + + if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) + goto clean_txd; + + txd->l3_offset = mb->l2_len; + txd->l4_offset = mb->l2_len + mb->l3_len; + txd->lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len; + txd->mss = rte_cpu_to_le_16(mb->tso_segsz); + txd->flags = PCIE_DESC_TX_LSO; + return; + +clean_txd: + txd->flags = 0; + txd->l3_offset = 0; + txd->l4_offset = 0; + txd->lso_hdrlen = 0; + txd->mss = 0; +} + +/* Set TX CSUM offload flags in NFD3 TX descriptor */ +static inline void +nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd, + struct rte_mbuf *mb) +{ + uint64_t ol_flags; + struct nfp_net_hw *hw = txq->hw; + + if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM)) + return; + + ol_flags = mb->ol_flags; + + /* IPv6 does not need checksum */ + if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) + txd->flags |= PCIE_DESC_TX_IP4_CSUM; + + switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) { + case RTE_MBUF_F_TX_UDP_CKSUM: + txd->flags |= PCIE_DESC_TX_UDP_CSUM; + break; + case RTE_MBUF_F_TX_TCP_CKSUM: + txd->flags |= PCIE_DESC_TX_TCP_CSUM; + break; + } + + if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK)) + txd->flags |= PCIE_DESC_TX_CSUM; +} + int nfp_net_rx_freelist_setup(struct rte_eth_dev *dev); uint32_t nfp_net_rx_queue_count(void *rx_queue); uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, -- 1.8.3.1