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 D5D8FA0032; Fri, 24 Jun 2022 04:56:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1994042B87; Fri, 24 Jun 2022 04:55:18 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2136.outbound.protection.outlook.com [40.107.237.136]) by mails.dpdk.org (Postfix) with ESMTP id 11D4642B79 for ; Fri, 24 Jun 2022 04:55:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHP91gt2Yr2O/sfLBd3gvKNuaNdrdrViGC5ihA03o8JHoF6nsbKWrG/o+tvX1f7WF/EcsfY2RSqdmcl14r7gLZlb7EJ8DHSxWjYk6e6UzTVWtr4bUtA3dUz4T5OtK2nGgMJ2ybq8mvp3y4uTwHNqvjvAdeWGBR3oKFgMBst4FabE132DO5Q2nSasZlKl+inIyOZPJCBZHxJt1HLOCaNaTOLIu9nbyysC2SnleirMX1L/UJZ9wsu8k3nWLObA6tDY4Zzimc/g+DRTi3JsXm0PxOMllUw4oAFSdYgIjPHYFadKTWevd78COoq8UcTXynWu7at1dHUXYndfzLNQTtyXSQ== 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=dc+OB3u+oAIlKVE9MJQ+4zssHKMWo0Nx0Shds1ecQwk=; b=H0Hi8KcCMp15reI7i31zXQ+SfOKP85S3ao8eqf3ayIxkqIttlA9FuzrUBMJaVZBGvFTBNA+lbh0rWrMteNl3bEcrg14wUN9xXkdQBTwM/akLbaTKZ8ZS+NNVOj6ZjTPjne7Ld4gB3RctW/q3018Aa8BiFqMA5J1ZjJ3E3CtXT7eacq0qmOoDX4b0a0QJknKavwTJiiB5R/6rN06zG/CjGqv6AmLPH+rumd8GDjaDx4b7Hw7ej6+68zMeLh+cH1hw95/2lEi/TXP06jd7MIQqpt5wy5rWtkziNWU7lx7SDttI3ePYNuPCJIA/3ezzLT7WqWKV3QQHYZkqQDHGrrKrPQ== 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=dc+OB3u+oAIlKVE9MJQ+4zssHKMWo0Nx0Shds1ecQwk=; b=ftCyPR2E8xoi+eS5ZxbGF4v9b0a2FsNo+1T58oQBMxVlocHB1QIAb+cR45iV4fg8vNg1bK4VUx8D6rKWGAyyKZroeXml3pMgaExwrE3Afzayj5RPSuZadYxGnm/bC7PZ4I23OdMLPqLPxW4zrggkpv1LQoW7rLY9HG+ZBzymnn4= 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 MN2PR13MB2752.namprd13.prod.outlook.com (2603:10b6:208:f2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Fri, 24 Jun 2022 02:55:12 +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:12 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v3 09/12] net/nfp: add flower ctrl VNIC rxtx logic Date: Fri, 24 Jun 2022 10:53:58 +0800 Message-Id: <1656039241-20955-10-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: 143bf95d-4ef4-497f-c698-08da558cf541 X-MS-TrafficTypeDiagnostic: MN2PR13MB2752:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0cwtnq1oz26NUs19BV76OI/9JN2ZdzZtLLQWWFzxP9y6F/Pem3i9ZKyS3WyMuZpk89ommXVZNa2Ldl7EosnlWLNCzvD00ceNSRbNqHiOhwVZwtRLXfvGx85QBa/AC9iDUim6dAR//iLQR5YC3zTH/Y/HydTNHqkrYBEc6A1v+qOZXyC1ZLe7Jd9Nx7xiPS35YhKJbLJcpkFHi3H+xB70t5Ty0WflYJD1o1GAadicD75fANFrpWA6ejL1GIykqu/3fNr5l9Fvx3AJL8WErEnUN9wjPZFY0irS6IbuaADMnBoSk8M0XcEIN84Skq9qGPLs3MrmUDXYw6muECN+nnu3pLGBm4uqx8Bh9PxR2TdsCDmRjWaezb5m2MlI0xXcj69bSSZ1LdSuJoeZZCuT/2NuBeRo8MWxftq5kZLEJHmPKyoGPbfAV181hYZNaZE5W54rwThVnNuJeiDk/SmLtuoWGzeiZjP7L6mrPaIbPaqEQo8IeP+QmtF05FX6yksIQp8QnyPzdo+Y3TUhpmMG3t2ZNJvoQyue93csQlxvs8U4HugIWWwJMPFcCvFkO+Q8SR+71xWuLprdeRcxFAk7/5EQnr+TFtECrncZMM6ueuB834MBQqL3xds4+uMaTPEAq6a/QeXCvXvBF5B57pnyZwejJn10v82ogXtYQPYw3yWzSzXqIiNs1OHPjn88ooQ4liX5lEmv+XOZcIL04/6utMbvJq7FIBPl5Q8sVEM10G3+TfxuUVSrd74ma2nuTSKsOUxNhr6mHkJAqLVFEX0XUysOzlkH7Ff3ZDJL5zC8TVoz64D5DVMCkJu3VtFX1D33MfvkgowKvhSlDPHXmDFwnWakng== 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)(376002)(366004)(136003)(346002)(396003)(39840400004)(66556008)(2906002)(66946007)(26005)(83380400001)(6916009)(66476007)(6486002)(2616005)(8676002)(41300700001)(38100700002)(4326008)(6506007)(6512007)(66574015)(44832011)(86362001)(54906003)(478600001)(36756003)(186003)(52116002)(316002)(6666004)(38350700002)(8936002)(107886003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?M0QzdFE1Z09zekdLSG04c1RBY0c1WnZqYVFGLzlEcm4vRjlJWDhqVThCa2ZU?= =?utf-8?B?WnBwYTFwM3EyNHRnd0MwVm1pckJPcjJsbGlOcVRMSmNWbGdIaStwTTBJcndU?= =?utf-8?B?QU0xaVdZb0dLa293SlRpSjF6OEtaWlAvUzR0YUN3MUZiaVV3Rk1sVU1tcWRJ?= =?utf-8?B?L2VJMDFiOENZM2JKKzFuUUluclByNlo4SFBwK3BwZ1BFek9veUE3cnI1TFhR?= =?utf-8?B?aGlRcjUyS3lSc0U3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RnFHY0pXTmdhYzVqTWVP?= =?utf-8?B?bmFhMXZ3d0UyaGROVEYvcjNORGc4ZFRwb0NuQkgzVks3dEZTczNnQVRULzgz?= =?utf-8?B?OVhObmc3VHJrdG1sTVJPM25NcERPeEE2QWhZWDhLVTk0VWJCTm5Gcmt0Rmt2?= =?utf-8?B?RHc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 143bf95d-4ef4-497f-c698-08da558cf541 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:12.5638 (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: SyzTtW53shdYVW4LLNW+Xs4grKyWX79kVYitbpKdXe49XW0ivXQP/SCtAkDjPOJ/1UXdm/oYzwwIeBgn4/MoTqEZu0cJ5wRMEctBb8SlW/w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2752 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 Add a Rx and Tx function for the control vNIC. The logic is mostly identical to the normal Rx and Tx functionality of the NFP PMD. This commit also makes 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 --- drivers/net/nfp/flower/nfp_flower.c | 15 ++ drivers/net/nfp/flower/nfp_flower.h | 15 ++ drivers/net/nfp/flower/nfp_flower_ctrl.c | 248 +++++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_ctrl.h | 13 ++ drivers/net/nfp/meson.build | 1 + 5 files changed, 292 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/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 6cdec87..cdaa89a 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -21,6 +21,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 @@ -216,7 +217,21 @@ .link_update = nfp_flower_pf_link_update, }; +static int +nfp_flower_ctrl_vnic_service(void *arg) +{ + struct nfp_app_flower *app_flower = arg; + + nfp_flower_ctrl_vnic_poll(app_flower); + + return 0; +} + static struct rte_service_spec flower_services[NFP_FLOWER_SERVICE_MAX] = { + [NFP_FLOWER_SERVICE_CTRL] = { + .name = "flower_ctrl_vnic_service", + .callback = nfp_flower_ctrl_vnic_service, + }, }; static int diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index f11ef6d..bdc64e3 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -7,9 +7,18 @@ #define _NFP_FLOWER_H_ enum nfp_flower_service { + NFP_FLOWER_SERVICE_CTRL, NFP_FLOWER_SERVICE_MAX }; +/* + * 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_flower { /* List of rte_service ID's for the flower app */ @@ -29,6 +38,12 @@ struct nfp_app_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_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..100e808 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -0,0 +1,248 @@ +/* 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) +{ + struct nfp_net_rxq *rxq; + struct nfp_net_rx_desc *rxds; + struct nfp_net_rx_buff *rxb; + struct nfp_net_hw *hw; + struct rte_mbuf *mb; + struct rte_mbuf *new_mb; + uint64_t dma_addr; + uint16_t avail = 0; + uint16_t nb_hold = 0; + + 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 -EINVAL; + } + + 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); + return -EINVAL; + } + + /* 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_flower *app_flower, + struct rte_mbuf *mbuf) +{ + 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_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(ERROR, "ctrl dev TX Bad queue"); + return -EINVAL; + } + + 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(ERROR, "ctrl dev no free descs"); + return -EINVAL; + } + + 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; + + rte_wmb(); + nfp_qcp_ptr_add(txq->qcp_q, NFP_QCP_WRITE_PTR, 1); + + app_flower->ctrl_vnic_tx_count++; + + return 0; +} + +void +nfp_flower_ctrl_vnic_poll(struct nfp_app_flower *app_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_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]; + count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST); + if (count > MAX_PKT_BURST) { + PMD_RX_LOG(ERR, "nfp_net_ctrl_vnic_recv failed!"); + return; + } + + if (count) { + app_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..74765c9 --- /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_flower *app_flower); +uint16_t nfp_flower_ctrl_vnic_xmit(struct nfp_app_flower *app_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