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 B00D0A0543; Tue, 21 Jun 2022 10:12:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E83542BC3; Tue, 21 Jun 2022 10:09:34 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2127.outbound.protection.outlook.com [40.107.93.127]) by mails.dpdk.org (Postfix) with ESMTP id D338E42BBA for ; Tue, 21 Jun 2022 10:09:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZlTWt22cUNhiD3j0GHBRT1Q4T1CU6yPbuP9XZReaG3qX81uO1L4zqqOrzdmcE9Fs+PR/9tHeosaPZ0xpSK9AKfBSbaEQfN3bXo/Oix3J0icQz+XVH2f3utx3rpGV22DaUGZKQfA514RcWSnmvcCrLgQseZdK92CybmSYMck/i9draXXTNDlSZGY2pSpkbgtVRVpbZIUwzZcTvfs5V7/4wuqANEGXwAGMAGDNwbFWJf3AKnjeyNcxqHt7XhZyjA7scrCtM8KYH7WQu/o5oL++vpMFtBpUw0E2cwYvZZDXZebteis1Ii5qaD0zKKcv0JdQnXWSmb+3JYMPi4uDtfQQQ== 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=l2hTYATcDEW3vlEek8k9pHjvSZi4AkPFshOww9lL5DM=; b=JOMDoe5zWpxtRKt/OMde4XScOqlktwGCazBxZVJMFnsynw/A36g8E3TCaecqYrRKiEOz0kTeLW72jSIM8g7xqYo/8g8a8j+hYc+dioPB9YM5FeAMfPpVFgbiB2yzu2Yn883n335mfJ+uVRpPM3baFuqK77+6AS8fElxLTC37t/cnXDB2a4bTgmPTZ8qIlF2msJOeSMHC00UzaUyIJ2YooIgVuS/5QVWv2e4uCV+ENa/aimdUxOOOhT7Uo0laMsBpHiRlMjluvhUM5pKZkJWQwvRWpwJbWA39CamZSgwgDNeJuUryyIhUEXhl4JrWzqi3/Ug2EHbWTHHiYcT/h6a8mA== 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=l2hTYATcDEW3vlEek8k9pHjvSZi4AkPFshOww9lL5DM=; b=P5N4m0YUj7tFiPqycWwICcYrNWEiQfsV94oGG9dge4c8NhIxpU2CAoeiZ6l54rfx9d4Aow8EANmFz8cZnm3K2qmQVfjzX5mrHIu5/CNKMMUUdvfmSZcbyk4EXWvDqhXxQWQKrTZOaNk3gaVRZ3Ahfbc9deYScH+55RNrOFLSn/g= 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 DM6PR13MB2730.namprd13.prod.outlook.com (2603:10b6:5:13e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.13; Tue, 21 Jun 2022 08:09:29 +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 08:09:29 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH 11/12] net/nfp: move rxtx function to header file Date: Tue, 21 Jun 2022 16:08:38 +0800 Message-Id: <1655798919-38659-12-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> References: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0P286CA0009.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:9c::14) 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: 1f61db3d-469a-41dc-b7e2-08da535d5d92 X-MS-TrafficTypeDiagnostic: DM6PR13MB2730: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: b32bEpfkFh1dfZTIk2DStLBBr/lGMWyAts/XcYmJEZ+/10Ti8i51uVZfxT/RMWOlrNv/Li1BUSFvG0e+J9zI8skIBpjBaPsd9IMXz5hWfZrf+r/wBhsGLw5jgV/pF8nARyC/ytW4wCPHW7aBWSgu1KzAFeuCqfyNRskD3NRHQWV8AleBEcEjEVi+JAPgzMkGw7l+b9I7ykgyOhECUq38/m1OuP0pw8X7+n/tQ+zz0k52iBBRhKm4N3y2W23NhKW+W8Ql4U2XrX8Hp7fVceBPY0qcCOz5wRMQb5vyVcU/j5j1bqY7gk74GAdg0K1x3uSY5IzgWsTnAvRiXEZft+BA+iXB84iPj/bgxBNUjX6sSoPsYtDCkrYRTgTUrhSfGJq4kjCLj+/DeOpcsD4BpyBhE9+gwfwTp6Zgjsi5WUD8qfp8hVeagXpkoTBVty0vME8qTKhVOokHUbKTz/8KuD0D1Ax/S7K87b24r6zO76lm9AMHmcj33H2pj2QAaQIcOjP7l+L/7NmjBJh8UAHegiC6BoI2PZkkpxN9Cot//jGzapPfRqsKCngmuwvYPEhJqFh75yQqXn3eeYYN0jsaRhsaa/ZL0ACdol3Bl9RRq+qLQTMv5iyHqBWWg5kpRMfJmU1N4vD90kHxAydnJyXq62eLaR93JL8XOkg7aSZNVIpUg3rWw1aHqXD/OsOgyaMhdUAD4D46oMHGFIkaf1NCJJMSLg== 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)(376002)(366004)(136003)(346002)(396003)(38100700002)(2616005)(38350700002)(86362001)(83380400001)(66946007)(66476007)(41300700001)(186003)(8936002)(8676002)(66556008)(5660300002)(107886003)(44832011)(2906002)(316002)(4326008)(6506007)(26005)(6512007)(6916009)(54906003)(478600001)(52116002)(6666004)(36756003)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MWVmOXpFNEdidkRhNnpZbW5SVThpOWZPWS9pMk1KQitDVVJpNDVIblp5NVd6?= =?utf-8?B?dm1wK2RRNDdRTklXUDY1eWZ0UWxDd3VwZ2RranNjdFVkSFhSRnVidkVLSzc4?= =?utf-8?B?SUlyQjNubksyLzJEemhqZFEzUHZGTExzT05XSkVHaDllb2JEMmRQZ1FNV2Rx?= =?utf-8?B?Y3VtSVRUTEJxMENvTEhQQjJWWE50aGlLVExrRUdPYWM3Z004TDFnajZCV2ly?= =?utf-8?B?RzBDV1pzZ0ZTZ1R3Uno3djcwdnRyUlNSR3Y0S1QybnVtU2F2azFQOEtJbzdo?= =?utf-8?B?Rm1LVmFIbFpTdzhBcm5ONXZ6YXA0amM0MTgxNVNpTlZiU0tVd0NkTWh1cHhs?= =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kJheTNpdzhwN0ttVW5MYkczdDI0eXdhYzNC?= =?utf-8?B?ZjFTQ0lVYTlrcmd5b1J2SFFHRXR0NWlWUGJuTDRwZDdNZW5YeFRqUnVVQjhJ?= =?utf-8?B?UVV1OU90a09pb3VSMFV5eDFGYjVOU2hsdkV3eFdCa0M0Rm9MRE1heFpQcXJh?= =?utf-8?B?aWdYNERWU0JpcG9MZmVWL3ZmTEV0V0oyYlRkWFhCajRIOWVWZExkaDdlVE1H?= =?utf-8?Q?YOBs3u1ZhEz05wVg=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f61db3d-469a-41dc-b7e2-08da535d5d92 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:09:29.5493 (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: WjgN9b2Rq6giU4wUbk5kW9fgqpzC2j4wsX0WpXxOLWlLgMcDvts4E4xKz4w00qy4J5AAkut3ceLt3aGLMllxdyTVnW/VFP+24gREWeLQp3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB2730 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 0756813..621ba7d 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