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 0C43EA0543; Fri, 12 Aug 2022 12:24:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CCA0642C5B; Fri, 12 Aug 2022 12:23:04 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2091.outbound.protection.outlook.com [40.107.95.91]) by mails.dpdk.org (Postfix) with ESMTP id 673E542C5F for ; Fri, 12 Aug 2022 12:23:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vt9GCXalPuVaMJf6AaWfCIfQMkITj02RN70uT2euVmbblWnIhBmCifF3mLdxCT0ediKiiLqv75X7u4NePuLSjb4OnCpFicIN4mwkVhrD3YF49XLwdgZVpCdD7ZmQ1tGyGoZ7uO8vH2pX7eJoPVshHeXAXsjXJi+UJzcGckSHfUjms+ceD4zSuGDfmACGkDK+e+x6g3qFzKcHbfeDRg5ssUJG9/Ez0ODsupfQIe4o8qR/AG+h97xyg7dxfwxo2vL57ba4TH4VTlrIK5DNTG6yWbaZORIqFYrfaFA2nsbsIxIecAfi4d19rk3VE7G6P/6D4T4ev1PjszBbbybiEpvvYw== 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=ilb+zOs7Nmw3DYNXEGGVlIhHGCXDaL9cBlLtrhJnCrU=; b=a8dYmL2eTMrsrSP5GzA3KMo2UpzdOqVrznhq3iSKnuV3qfFjZ9vrdrsuwSdwtQQYdMpxlyrb2ITp72ZwG0b4L6wt/iQUJz48efzoHVuWJt/tB+RA1QDcGbw6gvdfXCGRH1lRWBX4CUafgnP6+lX8Sxh/cEMF0EAHkiPdyKkxjECdUfEi/mja2XF5Wa0BxBYD6XGzvuawtdl5uNvuQ+dL+gPW3Z5ewFSXNeCvC4GUI/nFHCV7Bm6ncHmJ5av59Lw4p1NAoSfkv1/QM6SRKgnovVarFPpMzvFUKuCk7FM/bT4CWuQnVibF5V/oxuxiWyq03GjB6CWTpRnjFzGi+iCiag== 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=ilb+zOs7Nmw3DYNXEGGVlIhHGCXDaL9cBlLtrhJnCrU=; b=VeHkIUXc2cDvOKFThS9mSFCClS8Es4Q4G2nMXhn8EeusA++Mrwpvl3XpuGmNBYyUuY7sUppKb+Hv+8vUi/0VT7/CN6tR1nUhBrJXIMSDoesopzlEN3WcScLXyBVXd2pMgIAxW50L/UN5WVXsxTM11M/KjYnIEaOT1GrWlo2CwjI= 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 MN2PR13MB2624.namprd13.prod.outlook.com (2603:10b6:208:ed::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.9; Fri, 12 Aug 2022 10:23:02 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%5]) with mapi id 15.20.5525.009; Fri, 12 Aug 2022 10:23:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v7 11/12] net/nfp: move rxtx function to header file Date: Fri, 12 Aug 2022 18:22:29 +0800 Message-Id: <1660299750-10668-12-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> References: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR01CA0019.prod.exchangelabs.com (2603:10b6:a02:80::32) 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: def6d38f-2be2-447d-e618-08da7c4ca2cd X-MS-TrafficTypeDiagnostic: MN2PR13MB2624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FNkQz2QtYJ3e9TM/kiKjOE6oZOAOXzInPr4bxSraZu7CuR6+1qiBAKdZCLit5AcQETnOk0J4+hLSXq9RHplaVVcHP6D90mP1ApW2+eQAYJEw9jfuNOp0JUOHqce/hBfS4OZuhmMYZVqQJhIp9FdDi3peWlCpYMLZzaIIaCUF2WyT8092mk/3qNh/MLH+QWFG+v9gTzIbHrpOoRxhpktLyzwVG/VgAJanhHvd5BhcSihQSO8Mme1o1TQP7rk74jV3xh8jQcvJd7XOkqsufinYTFIpy4IgVvXBZAO6vhKaM21cC5NZ77rWm69FdjgYLjI0U9Z8hg+/SWYVYU236+6m4mM2FrYdu9BDaruhwbUB4yEMXRqbdAL/8SxPkDdNP8mC8K7nnaIBZBrIZ3XjqsJVkjZXu1O8Dhtv0Bx0Xu/xYyPATiZjXRpA4yHZ4N/8fGphh+bkNwLd8gsOpq5c/5gUBnftdFZcoiqV9l41bqyU4giGkN2arJNt8n+yeo+R8bpLjBhajw5YFS/staWbobw91OMXFqz/PFG0JqhQYiO5n/PWCrhlgA4e7FPbtkuE60LOTZ3cVHTVJVHDTiQfE1CDc3zOiVZNwAXc+MIxMUHU+68XIoWIjRyYyQIOtGoq4o6TFlOrrJOMoVEYfzMmLmobCTcqhnZDB0ZwQbQxv4lrvRrOzEMQoVuSu7Y1Dulm0Ac+cw0ScAlEmyFCVViYLLkE89g/iq/YGrJQhFhV66Vqu7mC9wLSDvkQXz2kgRY4DKqsq71wJeD672u7/Vc+j4SWwDUMODWBjRoawjEtrkKOWDs= 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)(366004)(396003)(346002)(39840400004)(376002)(136003)(52116002)(41300700001)(54906003)(6916009)(316002)(26005)(478600001)(6486002)(6512007)(186003)(6666004)(36756003)(83380400001)(5660300002)(2616005)(107886003)(6506007)(66476007)(8676002)(4326008)(66556008)(66946007)(44832011)(86362001)(2906002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cnduTG9qVExFTjdUalBFN21RRnB5MUdnWk8wSXFFK0wwODZ6QWtvSmVUdnJo?= =?utf-8?B?TVBtOEI5eUcxckhEd0FDNEsxQ05RTmowSHl6S1FKTHh3RFNjSXhTSjZEYlRK?= =?utf-8?B?dmF0NU5LVmZ4Z3Y5djA1VHhSWDljNHkxbEJmeHFBTmcxZjh4T2IwYVYyRnNn?= =?utf-8?B?bnV2b0w0YlFUSHBIL1o0cHFlWGsvMWJDSHZUNVlwdnVkMEtlcTJGZEFBU2cw?= =?utf-8?B?NVVaKzVFNHdDR1ZpTENQTWlPYTFMcG5XNm80YXA4cXE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dnNlUxWHYxOTYrV09aNXBWdFUxTnU1dkhUb0p5RU5vRG1RK25y?= =?utf-8?B?VFMwdTNiTzZNZE5aTnptR3QzV1UyVDdTc0pYQ3lGeTNrOEcydEk1Tlc5Vi9a?= =?utf-8?B?UEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: def6d38f-2be2-447d-e618-08da7c4ca2cd X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 10:23:01.9295 (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: i3tJqfYftDdLOOD9HqPbHFKXmuidn2ZEJHIGXJPl4QsFw0qtf+rYcbCa3cDWaAX6I4Dn7czYnZ7jrcETgzc3pw+qjUWCYCAeJ5YUK4dMU6g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2624 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 e097a58..87eb116 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 8d63a7b..95403a3 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