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 4E018A0032; Fri, 24 Jun 2022 04:56:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6D5942B91; Fri, 24 Jun 2022 04:55:22 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2139.outbound.protection.outlook.com [40.107.93.139]) by mails.dpdk.org (Postfix) with ESMTP id 621B642B7D for ; Fri, 24 Jun 2022 04:55:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jrqs1kjmDy9rb8fPiDxxffJvD/DeeSq0GGfmkKI2VLPN+vViCpPv3wkgoLnl4UhzQpcqQjDddFTi+bAnr3En6khf4XOsu5pbVXzXBjelmEawS778YjdkgYFVk78i8CLIh3HotlHkjrVmdkTuFbVPKRiF2XWDER09+qE5F01gnW5xwFDmwVdildq5u0j49vr+kFpFZUsxlfd6JdnT/xY+BCuuEJfpD0+UYhzUR/bwwKJlJE6tsWJ0Ypk6AcU5KHAoLid6S/ohVk5gKbF+OCgNOheREilCm2nH+ENyDxJz5WKxOix9azUghQ0VBz9Yzt2LKEqPhkUDCAGrKwrn4YQ5Ow== 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=Awi24Sy0ORvPE2nH8V84pIS+hkimo/kXHaLwhHKS8ubqP3QccV9jC9y7q6j7chn6v1LrFVRhSjnniMkeQcRkqCDI/wi4jay0NWe1109q7ga6bozy55V+crNfsamtTfumTajAgetCjcxi+6BkqL3L2133BOvhAfSTfmhE8REZn2zY54R8LXTvvW0UDMUnUtdgu8jbZyPd4S2wt87ZQY0cC+I613RK9IavvOu/zxeZCASospEw2yvWKNYhCxlKRc6qMt8mUeTigFEx9f+xNDI4IeIHmZzWR+wcqczPh6MoRQL/7JdjSKfRhC6W5tMa+JRpBfpPVB7JdMVgQdF4U8ZN2Q== 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=KwtyfOq6j2hmUY7yHJ2O8y4SeSuaqhScG0yCoXlCeOAOBsrHXuAJtIp+54etvyTnL+aEusHh4e8+OugLvmt+ECXabku76vEM3N9sX7ktyRabwfCL8Wx79yrFdgyGWkqztCpFzkvCYpYfOCAVnKoXwBtHIw76FTp6EngAFJruc7o= 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 DM5PR1301MB2156.namprd13.prod.outlook.com (2603:10b6:4:2b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.13; Fri, 24 Jun 2022 02:55:16 +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; Fri, 24 Jun 2022 02:55:16 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v3 11/12] net/nfp: move rxtx function to header file Date: Fri, 24 Jun 2022 10:54:00 +0800 Message-Id: <1656039241-20955-12-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> References: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) 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: 63e16c1d-133a-497d-aa1b-08da558cf757 X-MS-TrafficTypeDiagnostic: DM5PR1301MB2156:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FAiSBacvM8oMMdEjm/XQyfAeuYtLwQJH90wIydVslWGhwcr25ZACD7+NoMerbnt6/b869ZAogjhsqAWjjP252+qy5shLgKDPTQN/fI8jCusngYTQVRRkHLjy+9ftt9W/gHBZFDlhLHmPBAoqyp++k04CwwCpZV+SN97Dx3yJkit323nMVsm/w7oV7QuBb1RHZXYR6BphAb9wdN8oFeZ8R1ne+OEfkZKh4OEEfa0kw+NTbd6xMedoQ4j5esmrfuiyB7ezb/6hdsk4bhSXB+j4n5lT3kY1eZ5nv2ddEE6AF3wbxcg/FOLDsLeo/n8u0u24jBzdoLSGMafiqgboboAA7VWj3V6p7k5VwLXRW5PfdQqxvTWtEk12oggSrwOJLjy2Qou/E0DZCjopBIAoGm6kYZxfnFU0Q2HQ2JOcdrdhJxfW2gXZIeXzRDIgJ3yKUkPCBcwI5afpnQk5zkfLrnuJLRHJ2pH/GW/ZBUB6TmmmqUM/nqFPeMAkBjl3Ii3TbBsZGdVlDSNXAIFT+zOlKP3jGefKBxA4GQTRuwALjNs0Sq4uwmXLk7e0xJydobJ5Uix9kKp79U+jW2qh5UiHOFc6LwTZJEgVzffASsHkSggIZSJfCoRdJdBltjytkW+PqME83rYcz2tFoKdSStcWDERKF1UER8VlIcx6shv8h7SAhE9XJd3kFzWm0+41/SY+fbPeOWwvbNYTytcyY2vkfCGUqclmpiFS+keibr4TbR+P8iG171ke2lkS0j4VTKk3fvlXwH0iXwhuW0qMxvCJhCz+DW0FAhRQdhUz4bCaThuDto8= 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)(376002)(396003)(136003)(346002)(39840400004)(66476007)(478600001)(36756003)(38350700002)(8676002)(44832011)(2906002)(38100700002)(8936002)(6666004)(2616005)(86362001)(83380400001)(6512007)(6486002)(5660300002)(6916009)(26005)(107886003)(52116002)(316002)(6506007)(66556008)(41300700001)(4326008)(54906003)(186003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RjBuQ01yOTFScldhcnFrS0ZqWkRORkYraXZ4WHp6MXNjTEtueGZ6aHJ5Ync3?= =?utf-8?B?bWxDMTNCUkJxR29BU0k1alRQZEpKSWlRKytZSDZtOEgwT2dMTXJZYm1tUCsw?= =?utf-8?B?NER1Wi9UYlJXWWZEVmFFUmdRTUp4ZjgybWptU0ozQk9Ra3ZXQVV4Q1pyWFhY?= =?utf-8?B?eHVLQ3RJSmpRTE1qdFI4NTA1T0hHRHRqMkIrN3NVRkQxSGNCVVZUdVRvdDZV?= =?utf-8?B?UlQ5SXNQZzlFSzVXckJGLy9oRzh3WWxmajNuUFQyTmNWeEhSVzZrb2FhNTVk?= =?utf-8?B?SEJQQXBTK25YNDVsWUpzVzh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VmZVUEVDWTR3TGR2WTdPTmYvZDdYb1piNmpy?= =?utf-8?B?djlUelRkVWgrS0dRT0hmNGpIZnd6RCt4aStoWElnZ3B2cmkzUmJNcVArQlZY?= =?utf-8?B?QWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63e16c1d-133a-497d-aa1b-08da558cf757 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 02:55:16.2190 (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: qNVsmWuZPxe14PeAXOg0anGYUPfdgrO6fpYbZlIeOb1a+K9eb7WI1NzvJ3VOqHjUD3ofK/TqGmnRqdQ/UKoC45jZi7aQXdWSbcUMz3gVhVU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1301MB2156 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