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 9943FA0548; Thu, 8 Sep 2022 10:46:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4925A42B8E; Thu, 8 Sep 2022 10:45:49 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2096.outbound.protection.outlook.com [40.107.237.96]) by mails.dpdk.org (Postfix) with ESMTP id F1A2F42B80 for ; Thu, 8 Sep 2022 10:45:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gWM8ZH4dFXOjT1x0AJeSXEdS5MTia8x+rX9pVZC8IVOgxguFamQAD/7Nz074mqPnc4FybAMmBuq3sERPxQDLLBxFvKq4y3hcWosnWGpKn518RWQTPEshpR07PoGZ2xy1c1EGC7ikO2HlfALENGrxebCicapSoge3cIRBrD1eTMeWk13uJ3nx4plaAsT9z9YKinGUtZ+2USWvz2dvTTVdR3Pg5IS0QBNz80C5C4WbkHGLZm83aZmRoLq5KfGPAVYvKMTtEboJ6J7PuX4znXJKBfZ6X8IXZ8wefO2CUcQCuvL3FoO4WZezSyWdIv2HYwjeDohWToJiiOcA81Olzyl0bw== 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=ZmUiktQG+z6EwZPc/cB9NIin+u/IN55z4Gnc2yCFIV8=; b=K6fY2j2IMfHKHxWdiq/wx5JBrokG7ZD2pLErkyEQznM+rZCk/9pGBT0Svce14ZkfxrAY7lpyJL9vow6ctEeH+x+UEB7XZoHt9BuD+UxK1hGbgobZXe24MMRxymYqXi3ScdXvQF5v3uftakG1trITjYPIUjZgEdaq6jYzaplv2nudTVVQatBWj1UlUUXIkmz0l7zHIk7jFIN9St9+FXYOCqL9VC3cswDuI+Bocn3VUoB87jJ8KqbcMiM2omL3j4p0BLz9Qdw7CcQoAsSoARDMSaFZFH6SFDxj3hm50zbHGXWxN5mD4ICVu1facUJZ8oelLz+mZwPNwSTIwad+h0dLwQ== 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=ZmUiktQG+z6EwZPc/cB9NIin+u/IN55z4Gnc2yCFIV8=; b=k4Ww5+Ir1H7GYT7xKWi2zRnh84fqp8SAltDVOSYeVdt0IwbMIQnycGHP5RMDaMNVsMoHaF3K0nuuXTlMWah98iuk01PluPsAxtyD2yHnAPUUZBqPOVY7U51vSTRJ1TQP9IGKNVJY4Q6UeWvJZz5jUkIZs49H9yrUdea3yny+ua8= 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 MW4PR13MB5940.namprd13.prod.outlook.com (2603:10b6:303:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.3; Thu, 8 Sep 2022 08:45:46 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%6]) with mapi id 15.20.5612.009; Thu, 8 Sep 2022 08:45:46 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v8 09/12] net/nfp: add flower ctrl VNIC rxtx logic Date: Thu, 8 Sep 2022 16:44:59 +0800 Message-Id: <1662626702-17254-10-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> References: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5940:EE_ X-MS-Office365-Filtering-Correlation-Id: 2025df73-e0e0-4a25-365f-08da91768526 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4smCrHpHkxT+uJdaDbqVApM/WbAES2o6m0iDbQLyqMsXEm1KRmS3F7Qb3BeyXPn2nXggPY4paFQ4HAKtZHimEIwx8Y6EVMTpm6O8GMKtqKpsywn8fqIo6FFkIPV6gR2iwA8mR1D7UbJhG4dkztA++9AAdNG9WRSB1KbV2CKrc73rtYZAbdl4NcX6IC7OvxLLVC3xAUV0LxMvH5hMz1YJRykl1E3EHXfymZh/RNyQp8JeJhYMgeMcXpVK8TE68QPuc6SDNnFU6FXYaGhp13zMORmb9hl5FakUJmMDJR46b76aFAEHaItkF/Uc4+j0MT0+yNYe2mOzraZQQ8/yyOkchz1hU5PCpHXw2b4PVp/tVSSkZ4jaRkntZ/N9l+auA9y1KR50VsfDzeZemF+hcM+0MrfoyeRr0LyjMuV+G2Azd7etLd0qhRz9cpJPJxFDcIjTiQ/6etcm/JXst7IL6Eifypu4yxf6Ix6/m4qeED1pIsvliIHXun88UCc97BydujBMNU6LrJhkdwrLAL6GNwB02Oj0fu6e/LgT8wxDsM6pK1DQOEIPA+RCn9BXl7d5EQRqCnSZ7tXBfeHajAup+O/omxhYqiMJaSlKhv/IipG0xgN7ryP9HpADato4rnH7ysLt+CfUOBTLPedSzDS5HVxIhFH8SakE0A3VCQxMWCU1Suvtjev94rC0rkLaCf+NEjPtnV91ckDF7EgIq8SrlRctSNXDzZwI2AgylQ4UK/NV75FUngKX9u4dfMgzuLtIy7oLC1nl6nAiBNKQlofwXUCu0Q== 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)(396003)(366004)(39840400004)(346002)(376002)(136003)(107886003)(44832011)(2616005)(30864003)(41300700001)(6916009)(38350700002)(83380400001)(26005)(6512007)(186003)(36756003)(38100700002)(4326008)(54906003)(2906002)(6506007)(316002)(66946007)(478600001)(86362001)(5660300002)(66476007)(52116002)(6486002)(6666004)(8936002)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SEthTisvSURXSWFYQ0FOQ25ZVUI4dVFya3pOSm9rRmZyUmFRUnNnbWJyZjZG?= =?utf-8?B?QXgwSDluMHRLWUtSLzFZYnZyUEppNDJtSFNNWHRxVkJOenNGNEFMa2d6QjNM?= =?utf-8?B?Qmo2WnFLYy9od3g1UnZRYTFRRHRFQlVuNGdvdC9VY2tYMko0dks0L2tQeVNX?= =?utf-8?B?ZnAyYkNUbUFHTVVZNmhoVGtkTXlNdXJNL2kzeGhlanFqV0hJTjNBdDRZTnNH?= =?utf-8?B?TGVVTittWjFkTk84QjRqRk1GR3V6VHhWUE43Z2JiMDVmcDJ0cEQ2YXo4ZW96?= =?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0YyZ0Vz?= =?utf-8?B?UE9TTUhKMUtpeEtiTVFWc0oxby9sYU03UGkrN3NXcU1pSHB2a1NIOGJDUFZF?= =?utf-8?B?NWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5940 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 Adds a Rx and Tx function for the ctrl VNIC. The logic is mostly identical to the normal Rx and Tx functionality of the NFP PMD. Make use of the ctrl VNIC service logic to service the ctrl VNIC Rx path. Signed-off-by: Chaoyong He Signed-off-by: Heinrich Kuhn Reviewed-by: Niklas Söderlund --- doc/guides/rel_notes/release_22_11.rst | 1 + drivers/net/nfp/flower/nfp_flower.c | 3 + drivers/net/nfp/flower/nfp_flower.h | 14 ++ drivers/net/nfp/flower/nfp_flower_ctrl.c | 250 +++++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_ctrl.h | 13 ++ drivers/net/nfp/meson.build | 1 + 6 files changed, 282 insertions(+) create mode 100644 drivers/net/nfp/flower/nfp_flower_ctrl.c create mode 100644 drivers/net/nfp/flower/nfp_flower_ctrl.h diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index bb170e3..0fe928a 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -58,6 +58,7 @@ New Features * **Updated Netronome nfp driver.** Added the support of flower firmware. Added the flower service infrastructure. + Added the control message interactive channels between PMD and firmware. Removed Items ------------- diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 4d07416..b873eba 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -20,6 +20,7 @@ #include "../nfpcore/nfp_nsp.h" #include "nfp_flower.h" #include "nfp_flower_ovs_compat.h" +#include "nfp_flower_ctrl.h" #define MAX_PKT_BURST 32 #define MEMPOOL_CACHE_SIZE 512 @@ -708,6 +709,8 @@ goto ctrl_vnic_cleanup; } + nfp_flower_ctrl_vnic_poll(app_fw_flower); + return 0; ctrl_vnic_cleanup: diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index e18703e..e96d3b2 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -6,6 +6,14 @@ #ifndef _NFP_FLOWER_H_ #define _NFP_FLOWER_H_ +/* + * Flower fallback and ctrl path always adds and removes + * 8 bytes of prepended data. Tx descriptors must point + * to the correct packet data offset after metadata has + * been added + */ +#define FLOWER_PKT_DATA_OFFSET 8 + /* The flower application's private structure */ struct nfp_app_fw_flower { /* Pointer to a mempool for the PF vNIC */ @@ -22,6 +30,12 @@ struct nfp_app_fw_flower { /* the eth table as reported by firmware */ struct nfp_eth_table *nfp_eth_table; + + /* Ctrl vNIC Rx counter */ + uint64_t ctrl_vnic_rx_count; + + /* Ctrl vNIC Tx counter */ + uint64_t ctrl_vnic_tx_count; }; int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev); diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c new file mode 100644 index 0000000..0c04f75 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -0,0 +1,250 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Corigine, Inc. + * All rights reserved. + */ + +#include +#include + +#include "../nfp_common.h" +#include "../nfp_logs.h" +#include "../nfp_ctrl.h" +#include "../nfp_rxtx.h" +#include "nfp_flower.h" +#include "nfp_flower_ctrl.h" + +#define MAX_PKT_BURST 32 + +static uint16_t +nfp_flower_ctrl_vnic_recv(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + uint64_t dma_addr; + uint16_t avail = 0; + struct rte_mbuf *mb; + uint16_t nb_hold = 0; + struct nfp_net_hw *hw; + struct nfp_net_rxq *rxq; + struct rte_mbuf *new_mb; + struct nfp_net_rx_buff *rxb; + struct nfp_net_rx_desc *rxds; + + rxq = rx_queue; + if (unlikely(rxq == NULL)) { + /* + * DPDK just checks the queue is lower than max queues + * enabled. But the queue needs to be configured + */ + PMD_RX_LOG(ERR, "RX Bad queue"); + return 0; + } + + hw = rxq->hw; + while (avail < nb_pkts) { + rxb = &rxq->rxbufs[rxq->rd_p]; + if (unlikely(rxb == NULL)) { + PMD_RX_LOG(ERR, "rxb does not exist!"); + break; + } + + rxds = &rxq->rxds[rxq->rd_p]; + if ((rxds->rxd.meta_len_dd & PCIE_DESC_RX_DD) == 0) + break; + + /* + * Memory barrier to ensure that we won't do other + * reads before the DD bit. + */ + rte_rmb(); + + /* + * We got a packet. Let's alloc a new mbuf for refilling the + * free descriptor ring as soon as possible + */ + new_mb = rte_pktmbuf_alloc(rxq->mem_pool); + if (unlikely(new_mb == NULL)) { + PMD_RX_LOG(ERR, + "RX mbuf alloc failed port_id=%u queue_id=%u", + rxq->port_id, (unsigned int)rxq->qidx); + nfp_net_mbuf_alloc_failed(rxq); + break; + } + + nb_hold++; + + /* + * Grab the mbuf and refill the descriptor with the + * previously allocated mbuf + */ + mb = rxb->mbuf; + rxb->mbuf = new_mb; + + /* Size of this segment */ + mb->data_len = rxds->rxd.data_len - NFP_DESC_META_LEN(rxds); + /* Size of the whole packet. We just support 1 segment */ + mb->pkt_len = mb->data_len; + + if (unlikely((mb->data_len + hw->rx_offset) > rxq->mbuf_size)) { + /* + * This should not happen and the user has the + * responsibility of avoiding it. But we have + * to give some info about the error + */ + RTE_LOG_DP(ERR, PMD, + "mbuf overflow likely due to the RX offset.\n" + "\t\tYour mbuf size should have extra space for" + " RX offset=%u bytes.\n" + "\t\tCurrently you just have %u bytes available" + " but the received packet is %u bytes long", + hw->rx_offset, + rxq->mbuf_size - hw->rx_offset, + mb->data_len); + rte_pktmbuf_free(mb); + break; + } + + /* Filling the received mbuf with packet info */ + if (hw->rx_offset) + mb->data_off = RTE_PKTMBUF_HEADROOM + hw->rx_offset; + else + mb->data_off = RTE_PKTMBUF_HEADROOM + NFP_DESC_META_LEN(rxds); + + /* No scatter mode supported */ + mb->nb_segs = 1; + mb->next = NULL; + mb->port = rxq->port_id; + + rx_pkts[avail++] = mb; + + /* Now resetting and updating the descriptor */ + rxds->vals[0] = 0; + rxds->vals[1] = 0; + dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb)); + rxds->fld.dd = 0; + rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xff; + rxds->fld.dma_addr_lo = dma_addr & 0xffffffff; + + rxq->rd_p++; + if (unlikely(rxq->rd_p == rxq->rx_count)) /* wrapping?*/ + rxq->rd_p = 0; + } + + if (nb_hold == 0) + return 0; + + nb_hold += rxq->nb_rx_hold; + + /* + * FL descriptors needs to be written before incrementing the + * FL queue WR pointer + */ + rte_wmb(); + if (nb_hold >= rxq->rx_free_thresh) { + PMD_RX_LOG(DEBUG, "port=%hu queue=%d nb_hold=%hu avail=%hu", + rxq->port_id, rxq->qidx, nb_hold, avail); + nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold); + nb_hold = 0; + } + + rxq->nb_rx_hold = nb_hold; + + return avail; +} + +uint16_t +nfp_flower_ctrl_vnic_xmit(struct nfp_app_fw_flower *app_fw_flower, + struct rte_mbuf *mbuf) +{ + uint16_t cnt = 0; + uint64_t dma_addr; + uint32_t free_descs; + struct rte_mbuf **lmbuf; + struct nfp_net_txq *txq; + struct nfp_net_hw *ctrl_hw; + struct rte_eth_dev *ctrl_dev; + struct nfp_net_nfd3_tx_desc *txds; + + ctrl_hw = app_fw_flower->ctrl_hw; + ctrl_dev = ctrl_hw->eth_dev; + + /* Flower ctrl vNIC only has a single tx queue */ + txq = ctrl_dev->data->tx_queues[0]; + if (unlikely(txq == NULL)) { + /* + * DPDK just checks the queue is lower than max queues + * enabled. But the queue needs to be configured + */ + PMD_TX_LOG(ERR, "ctrl dev TX Bad queue"); + goto xmit_end; + } + + txds = &txq->txds[txq->wr_p]; + txds->vals[0] = 0; + txds->vals[1] = 0; + txds->vals[2] = 0; + txds->vals[3] = 0; + + if (nfp_net_nfd3_txq_full(txq)) + nfp_net_tx_free_bufs(txq); + + free_descs = nfp_net_nfd3_free_tx_desc(txq); + if (unlikely(free_descs == 0)) { + PMD_TX_LOG(ERR, "ctrl dev no free descs"); + goto xmit_end; + } + + lmbuf = &txq->txbufs[txq->wr_p].mbuf; + RTE_MBUF_PREFETCH_TO_FREE(*lmbuf); + if (*lmbuf) + rte_pktmbuf_free_seg(*lmbuf); + + *lmbuf = mbuf; + dma_addr = rte_mbuf_data_iova(mbuf); + + txds->data_len = mbuf->pkt_len; + txds->dma_len = txds->data_len; + txds->dma_addr_hi = (dma_addr >> 32) & 0xff; + txds->dma_addr_lo = (dma_addr & 0xffffffff); + txds->offset_eop = FLOWER_PKT_DATA_OFFSET | PCIE_DESC_TX_EOP; + + txq->wr_p++; + if (unlikely(txq->wr_p == txq->tx_count)) /* wrapping?*/ + txq->wr_p = 0; + + cnt++; + app_fw_flower->ctrl_vnic_tx_count++; + +xmit_end: + rte_wmb(); + nfp_qcp_ptr_add(txq->qcp_q, NFP_QCP_WRITE_PTR, 1); + + return cnt; +} + +void +nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower) +{ + uint16_t i; + uint16_t count; + struct nfp_net_rxq *rxq; + struct nfp_net_hw *ctrl_hw; + struct rte_eth_dev *ctrl_eth_dev; + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + + ctrl_hw = app_fw_flower->ctrl_hw; + ctrl_eth_dev = ctrl_hw->eth_dev; + + /* ctrl vNIC only has a single Rx queue */ + rxq = ctrl_eth_dev->data->rx_queues[0]; + + while (true) { + count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST); + if (count) { + app_fw_flower->ctrl_vnic_rx_count += count; + /* Process cmsgs here, only free for now */ + for (i = 0; i < count; i++) + rte_pktmbuf_free(pkts_burst[i]); + } + } +} diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.h b/drivers/net/nfp/flower/nfp_flower_ctrl.h new file mode 100644 index 0000000..1e38578 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Corigine, Inc. + * All rights reserved. + */ + +#ifndef _NFP_FLOWER_CTRL_H_ +#define _NFP_FLOWER_CTRL_H_ + +void nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower); +uint16_t nfp_flower_ctrl_vnic_xmit(struct nfp_app_fw_flower *app_fw_flower, + struct rte_mbuf *mbuf); + +#endif /* _NFP_FLOWER_CTRL_H_ */ diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index 7ae3115..8710213 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -7,6 +7,7 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64') endif sources = files( 'flower/nfp_flower.c', + 'flower/nfp_flower_ctrl.c', 'nfpcore/nfp_cpp_pcie_ops.c', 'nfpcore/nfp_nsp.c', 'nfpcore/nfp_cppcore.c', -- 1.8.3.1