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 83FC7A0543; Fri, 12 Aug 2022 11:23:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE84242C4A; Fri, 12 Aug 2022 11:22:57 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2092.outbound.protection.outlook.com [40.107.92.92]) by mails.dpdk.org (Postfix) with ESMTP id 2CFFB42C4A for ; Fri, 12 Aug 2022 11:22:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QUk7+YUqYtuSD6/XNA18kH8AhaYkulMXV5z5ce98AfXOYLUPctkksTbmMbtdz4NDEMH1gfnB3YC7ZEN3uRc9eOASFClYy7LpoM6LcBATEOohkTGZfizhSQDtynO1ORjNsLUxmxJltYCuNJckR67qAREq9Uc9CKXvNiV+QRIDVHYS/p+RnUI6w5jg32322oORLD2vCFM5OC1I8a55ZtN7UBSW9aZrABPttH7lHSKeSoKyidC4o+bhWhHMYmjGr6vTutkPxDQt94VTxFty1caNT9HLeYf0ikVNEfpYKOpmaLqfWgZpnDnrQViFta4XxXhj2GfgQdcCbHdE93Yb/eHMhg== 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=XxP6cRupQh7Y0EVSJkhcfKG1M6YbYdyx14aehwsvKss=; b=Z62GFDqz4aor3RkNJ+s+pV1Lbxp48k1j7XgP5SEORkthHmQI073KbZNVOjEHHLGVs7812EZ0GuTnOYM83aKdOmCBE+ktmfcdTgBcqnnNGBlvc0MJ5ehSjgEBodoipJGS5pe28ViAh98Dvmeq+uvaUBoW+hgKV6HUw5/oGhdqTs6+WeasP8hPoSNKk5Yg9BEJdRrC8ezWE9XePya+aoR8rU6XPfgkudO7R1IRfumR3PpNHbYLqKatswjhXj8PvtLx1h/TZ6Q+tAFbLfSChdx4WCt6z0cqKYKh0bi5F8ZYKYoppWc/659F2Qfi/parfcEMVbzhXWNvNYlTfskQEAT9Ww== 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=XxP6cRupQh7Y0EVSJkhcfKG1M6YbYdyx14aehwsvKss=; b=nVhgYDJDMNvwnjhTQjlmivbS7ly1xZeZrddh/07TkxHtKGUS/PmehQXS1ExevbE4zH7pVG9kKBsT3kj33AM52PFScgQAUWo4bsb+mn8oh56I5VbVW2qcD6gAPzC5RMYhbSKhJW79M+YREWCm/+xbPqbOOXZnALODvEnn0jJljKA= 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 MW2PR13MB4220.namprd13.prod.outlook.com (2603:10b6:302:e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.7; Fri, 12 Aug 2022 09:22:54 +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 09:22:53 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v6 09/12] net/nfp: add flower ctrl VNIC rxtx logic Date: Fri, 12 Aug 2022 17:22:10 +0800 Message-Id: <1660296133-35266-10-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> References: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) 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: 8284d14c-ecf9-4f0e-c230-08da7c443c56 X-MS-TrafficTypeDiagnostic: MW2PR13MB4220:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cdiypAxY2fwl5nCw4T9cqmymyC+YAG2wAocv05dYd42+GEjll66lIK0OvUN6k5WPLA7mTuDmu1Vt0V2bn4eEkv6d1wji/bJjJiutMQCfmOe3PossqnAJMFU2+mo769xtLSoEQo0Ga5S3H7iEMH/PswojaW6Af+3U2rbZPC69uwHP86N8veubgudAuv9kDWAP4UedGR2pMsRHxfuxVm5FrcOIyfgmNi5FoQ1Nt6NiYS9RtlJNBZqRFdoinrTlIgcK5xO6mb7cyF0RQwX4JnqF5kQvWjRi1Dkf7UPAjQZwc/wWW/uma9WdclHzhXFxR2/Ek5pHhW5ZB/TXM67ly2j0wAngDgpJ5Nd/5r1kP6frqAgyRfYAiC3LbTPHl2V6k+r/CNkVu13zxUN2tVJ9N1EdXvql+pceG8hVQOSHekwNr1hulocVXUSZLkSeI9h02YCaHgl4oL95M3HW9E7X36BgSrvkSpddOb5qKJagNsldAaZ8ptYxb7rBRd4qPRVMX3UszOEqiPI2lJIa/ElIIMMbw0ClThjnHGoaLI6Tivd7z1xSyAjwTp1iKngIRAOQSIkUBLMcxEJzJrl/scKNtYFFlbgQ+kSgD4E/ZECsi+fCf+H/Mf1wVL7d54rNBAvVJ/YOsOAzWK2n2Q4KTeocGPMz327O4DM2crp61HDdH7+GrJkEbCGz3bWiZmVUlgSc4ka14gxtWck+ZbTBYxLYmw/7h4ybfzP/mqcanO24bVZ8wykAYV9pwOvJdzAJ9m8ZfBCw/3E1lBryokJsw83ELknhKHxG6ow5CUNRn3PE6/n+SbtOrIF+USQiwSw/hvFv48Ju4W2P7fV5ABLaZG6PIwBhYEix8jU5Kp+leZK2jNjgcUE= 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)(136003)(366004)(376002)(396003)(39830400003)(346002)(44832011)(83380400001)(8676002)(66946007)(2906002)(66476007)(8936002)(5660300002)(36756003)(66556008)(316002)(54906003)(4326008)(6666004)(41300700001)(6916009)(26005)(52116002)(186003)(2616005)(38350700002)(38100700002)(107886003)(6506007)(6512007)(6486002)(86362001)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TWs4Q2JzSWZ2Rk1WcjZQeHJRZlBFM0h6MmUwSjdGcGlxdHpMdW5NbFNKaXBj?= =?utf-8?B?c0xHNlZTNVY0bXVFTG9DTlR0NEg1cTVMSWRKNENXSkN1d25oL1J0QnBVNzla?= =?utf-8?B?cU9JdjVnc21sRXRpTHJwMWM2aU9MVWdJVGR2SXpveVVSeVFjWUppMmdlaWMr?= =?utf-8?B?WCtra1M0QmpSeXBtUEJOU1dsQkZQWWhtMFRuNVFzQThwRHJ2S3dVd0JjRmR0?= =?utf-8?B?ZS94M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zc1lENVdG?= =?utf-8?B?ZE8wcytmSkRpak45UUxreFBxOEZyR3BFdlVBREljOWVVVDFmaEFoenFVdEEw?= =?utf-8?B?L0owYlBNRXoyMmtMTGJTdTNBSkFwYXpsOUJmeTEyMG5vQkluWjZXRU5iUHZQ?= =?utf-8?B?NGc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8284d14c-ecf9-4f0e-c230-08da7c443c56 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 09:22:53.8910 (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: 7u0SQd3lpiCyKoU39rJPcEb8eeBcDYXvh41gCa6xp0seSvzDKfD0V1jjN9xJJI8Om3+LZqS7jVXabYMGnzkafco4fy/Gmv9l0HcukApMldM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR13MB4220 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 --- drivers/net/nfp/flower/nfp_flower.c | 15 ++ drivers/net/nfp/flower/nfp_flower.h | 15 ++ drivers/net/nfp/flower/nfp_flower_ctrl.c | 252 +++++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_ctrl.h | 13 ++ drivers/net/nfp/meson.build | 1 + 5 files changed, 296 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 c9a4d50..de91fb4 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 @@ -212,7 +213,21 @@ .dev_configure = nfp_net_configure, }; +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..fc62ec0 --- /dev/null +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -0,0 +1,252 @@ +/* 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)) { + rte_pktmbuf_free(mb); + /* + * 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); + 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_flower *app_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_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"); + 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(ERROR, "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_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_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