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 2601CA00C5; Thu, 15 Sep 2022 12:45:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03C7D42B89; Thu, 15 Sep 2022 12:45:09 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2090.outbound.protection.outlook.com [40.107.101.90]) by mails.dpdk.org (Postfix) with ESMTP id 6A91142B85 for ; Thu, 15 Sep 2022 12:45:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GnGt6glXI+oYf0a50LXmxtVTb4Nd4+AZZc9z54JUzlGfhO/HGBqF8HhgvmcFlz0PaGwCCf38+dtW341NY0mA4yf41n7bmLllU6eSFkWZRlNvqxKGe5VoGy3EJn+qo0ZCN2ytDKFV2I/QcXvWcdCjbiepiguHu1UuVN7b8+9SV92HTizaEgQhqyj2O/zdo76aJRxLi72plqzehWCHGh7RTLnq3ZWJaySYobVmYUo0x6Wht2xJQ+fx+DMGJQB7GiXGsY7wit1JpcIoELQUdBQ7pfwotLQCskaz7iDVRvGQtECkRSbNkfOHF3Hfqd/lZt6RsoeUDvZQf+9fLhG7W7HrpA== 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=hXhGqGbIRV3tlbWmfOTbrKqu8ddrW19MdZPko4vR+QE=; b=MloF0JZA9SstryD07/GvlQf6pjgdGyBdgE0pu8A2p+OA2gxnACRBjsPYdj28StDFndNsAyRgtw5DyUy/cqefJVNTqAPVIyftzypCScYAuV4Sd2pFJMZMwlG3R26kPfCg0pYz5iKrE0XrkVAfR4T2Z3jQr4bUDzVkp2J1VTzycONKxTsf4US9TnWsE+cKWlDQdwIjZ3rfYWW8re3efltygwAjWGzmkx8obtDh2nEtEM37BrEG/2RYDEZy+xw7X1thOaF4KRKlYwcFuL50nGYZslnt9DQNXuRaEb8/+KkNMo+rnV9OxIoS2X8PdTsLYZZ1jd41ADWfpXWLIO9h3J4X9Q== 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=hXhGqGbIRV3tlbWmfOTbrKqu8ddrW19MdZPko4vR+QE=; b=lUp4CqSve3GWfdqKvA/iOIdYEHg5vx7JNtWgpfhfRXojeBdc8ug7t3HbGtdBaCHtJKX1guFwaNVGpuStfTAe/xz+Bs2Yt63ic5a4QYhF1/3lKpsKizzzC5nrzv6m9tb4ubvju2B1QJQhNuF2MP83nFNtHLr5S+9OpiiS2/Y6cDM= 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 SA0PR13MB4158.namprd13.prod.outlook.com (2603:10b6:806:9b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.5; Thu, 15 Sep 2022 10:45:05 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15%4]) with mapi id 15.20.5632.012; Thu, 15 Sep 2022 10:45:05 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , Heinrich Kuhn Subject: [PATCH v9 09/12] net/nfp: add flower ctrl VNIC rxtx logic Date: Thu, 15 Sep 2022 18:44:26 +0800 Message-Id: <1663238669-12244-10-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> References: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR11CA0071.namprd11.prod.outlook.com (2603:10b6:a03:80::48) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA0PR13MB4158:EE_ X-MS-Office365-Filtering-Correlation-Id: b44b9af0-d193-4d99-084a-08da970759da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A4u7gnou8nFkYtjzM17fcxXo5kyLbsAbdLqKxQGE+hkDmf/f5VyTwGk98cIWe3uqoARE5K7xtL+IcVIPTnEeC8FCnrcXJ7kzfi3UyllvhadTVUOyHBVV3akrTGBhLxvd0Y4O+n0jOgQW/3CN+lfiJ6Xa5vX0WO8yQNhsSFCoMsfkwbLX3k2nz3NYwet2Dr88VoqF4BfWiFOD1IT6jNi1KVby+g5KiwmtNaIloViMg47GASfThQ2ZUbIFVPeAtYZb9X5fsSPHUVX0AhETws+Ztk4sy0ANB0Cv6kPoOIxrdKCmZoqeSazpdvIYba+r8cws3xWKhCw87qIaLEtY5xLq19Ou7vI2zn7bwxU7VTlu5TZVZkbyuqQvkxKblX+qM0hxi9/dgCs8QEQ2SuSnoiGw74wc0YyDmvzYwtKaZDv3xPFF/Cklt+E7DX/sDX3+Dy1L/L9XPAMToJEM3Tn4PDU9/UYQMVU4xTNyPHCkjNM479MHTE0iJHBW14m50XGkYBHiP/bsEnF+YNZ89hRYqP/cReokA+u3MgtWLzSeNhtlQvl6s+h1bBLemyQWNOkyxRCsplXTYqUDQpM8sI/3pdxAP5COStbqfPJ714J87x+TiBMwTjGVhcjt3IBXV14zJTEBrGgw0PeEXT7zu0VM+i9eP/UiM8GhXiqY4nohdMLWbks1VbtxnqXLeSBwPxU7YsgjmaneFGkDcsoGjIkz7e0naeps/mdQeL4wgILAEe2eCSmmaou+UrY9YezMda+ZTHRNE3rDTLk1CfO0j4p3JOKlxg== 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:(13230022)(4636009)(396003)(346002)(366004)(376002)(39840400004)(136003)(451199015)(2616005)(38350700002)(38100700002)(186003)(86362001)(83380400001)(107886003)(8676002)(66946007)(66476007)(4326008)(66556008)(44832011)(8936002)(41300700001)(2906002)(5660300002)(6506007)(478600001)(6666004)(316002)(30864003)(6512007)(26005)(6486002)(52116002)(54906003)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MzhSUWs0aWJLR3pHQkFVN29iVWxFdm1qVWw5M1E0WE0vbFlUTkwzMnh4MkVl?= =?utf-8?B?TCtxR1JWV1BoZzlESG5GVlpYTGh6c3dQcEx1RVVscTQ4WVRQU0ZQM0xQcC9w?= =?utf-8?B?d2tacXJrZG5BTEp6MktjYThLRjVEMXNYVXNVOFJMOVJnYjMvaHoyR3VpVEVi?= =?utf-8?B?THV1RnRoSDJPY0ZKMFloakpGVWVRdUllMlFHRGM5eEpTWHZlanNSQzN6RnpR?= =?utf-8?B?WlJIazZhaW5SRWM5c0d6MVFPUno4aWhwSUlDdnplREZSSFlKWnovSjRST0NN?= =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TNDUVgva3Z2dzl4VERZa242S1FjdnZ4ekxMSENXQUNW?= =?utf-8?B?Kzc5YTR3Nyt3MVB0aVRuMnJQNW44b3ZMRXVtKzBRMVV1dFN5Wktqd1g1OSti?= =?utf-8?B?MGc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR13MB4158 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 the 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 | 59 ++++++++ drivers/net/nfp/flower/nfp_flower.h | 21 +++ 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, 345 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 6a666aa..c5a8c08 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -61,6 +61,7 @@ New Features * 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 18ffa5c..e935821 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -20,6 +20,7 @@ #include "../nfpcore/nfp_rtsym.h" #include "../nfpcore/nfp_nsp.h" #include "nfp_flower.h" +#include "nfp_flower_ctrl.h" #define MAX_PKT_BURST 32 #define MBUF_PRIV_SIZE 128 @@ -681,6 +682,56 @@ struct dp_packet { return 0; } +static int +nfp_flower_ctrl_vnic_service(void *arg) +{ + struct nfp_app_fw_flower *app_fw_flower = arg; + + nfp_flower_ctrl_vnic_poll(app_fw_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 +nfp_flower_enable_services(struct nfp_app_fw_flower *app_fw_flower) +{ + int i; + int ret; + + for (i = 0; i < NFP_FLOWER_SERVICE_MAX; i++) { + /* Pass a pointer to the flower app to the service */ + flower_services[i].callback_userdata = (void *)app_fw_flower; + + /* Register the flower services */ + ret = rte_service_component_register(&flower_services[i], + &app_fw_flower->service_ids[i]); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not register %s", + flower_services[i].name); + return -EINVAL; + } + + PMD_INIT_LOG(INFO, "%s registered", flower_services[i].name); + + /* Map them to available service cores*/ + ret = nfp_map_service(app_fw_flower->service_ids[i]); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not map %s", + flower_services[i].name); + return -EINVAL; + } + } + + return 0; +} + int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { @@ -777,6 +828,14 @@ struct dp_packet { goto ctrl_vnic_cleanup; } + /* Start up flower services */ + ret = nfp_flower_enable_services(app_fw_flower); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not enable flower services"); + ret = -ESRCH; + goto ctrl_vnic_cleanup; + } + 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..b9379e5 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -6,8 +6,23 @@ #ifndef _NFP_FLOWER_H_ #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_fw_flower { + /* List of rte_service ID's */ + uint32_t service_ids[NFP_FLOWER_SERVICE_MAX]; + /* Pointer to a mempool for the PF vNIC */ struct rte_mempool *pf_pktmbuf_pool; @@ -22,6 +37,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..df908ef --- /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 != 0) { + 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