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 4FE52A0545; Thu, 23 Jun 2022 04:27:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80C4242B85; Thu, 23 Jun 2022 04:27:22 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2134.outbound.protection.outlook.com [40.107.94.134]) by mails.dpdk.org (Postfix) with ESMTP id A6E9E4069C for ; Thu, 23 Jun 2022 04:27:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ddu8jtBtO7M/fxqU3A/AFlqKGbWTht/2Igq3XHBLMMBEsUwRLwouJi1oBvd3GwPdW3SKekEQHf1dqdM+XJ6g5RTTtBgnddAfySpxQ8nVHh3evjj21eR/Rqc/ELTJXyh/wT7NOjqxpsI1IWLy2XEnQBYYL79IHVfBTjznDta4TF8aFn4j0OCOc5swve5HfP5EQ0g4D7cX+dBqApW8pUu0OzyrQNM/rIVJtaxe4YmU38jd8Fz5IATto4UCxuCoHqX8YPqBVDEqwfWZpXku2Mn8fNDvoQYXbSIr4VgRlAmJHM9Du6qiAedFEsFm6CUjvrs1vXRma8zwoh92O3tBiSJmrg== 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=MoQsr4EhxfQ9iPrVyE2HRtvLfTCzUUfA8wN0a82cIj8=; b=Ya93p5EydQ0ifbBoSxlILNHv0VQeE+/IS/1HCGVGiiNa4SWjThJfDBLNGXKn62blHg0StfkeKNBO4lfZt4VlAtYdvngnrqXk42NgGjIUkrGRmEM8DGAQ5VZhA2XkeED+KUaid9i2mpmA2ryYlJ/A6JxbjIBB6FaY4/oELOFOfd2CXHW5s0zFe4G/jW/AdSCEjOy8nHEz0A0kzLZFhkRpDRPzNZM74582OSbBM1efeoWecYpJ9KqpA0aICHS9nRlSJffXBl+ioWTZMxCMnaSjEdfvu2m0fQ6cmF8qpp0CWo0w8q8bfsdfQwC0uIn9Giocc9FzXgI1uUgjciN3t8jlGA== 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=MoQsr4EhxfQ9iPrVyE2HRtvLfTCzUUfA8wN0a82cIj8=; b=HO/OSoKY1znE1rA9omdhrKmdxY/YqAPiPF70DXgWDnxDDcHQ8Pbj6vvX8/VGlWH9NEVs9fxU1mJ8ZJUHb8O7i7dyVzx7ixgtekE78Elgz9o7G/oYeBvklZ61itUiiETdPqDFisPSjZfvD70nAZLvASuG3lr/TWT1gL7eNgvG5Ao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) by MN2PR13MB3535.namprd13.prod.outlook.com (2603:10b6:208:169::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Thu, 23 Jun 2022 02:27:16 +0000 Received: from DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35]) by DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35%7]) with mapi id 15.20.5373.015; Thu, 23 Jun 2022 02:27:16 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH v4 09/13] net/nfp: nfdk netdev option and queue function Date: Thu, 23 Jun 2022 04:26:11 +0200 Message-Id: <20220623022615.3628093-10-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220623022615.3628093-1-jin.liu@corigine.com> References: <20220617093444.2004000-1-jin.liu@corigine.com> <20220623022615.3628093-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P265CA0222.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::10) To DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6bdfd8f-ff1d-4d55-1e74-08da54bfe35f X-MS-TrafficTypeDiagnostic: MN2PR13MB3535: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: x+m9Vkjj4uvVlcyxFqhKxXrEGYrm8PTokr9ma7+Mu18gXoHW4L+vPhp37/TVtjhW2Aof3RUA3taaq/FM/epmv6CGLCM4ji41pT0GKsvwjSlm6ffJUoeBFmBvloJNLdCxeSIzAf1X4hcAEbgLSpZ5Xl87tCHv6yKE4DD9gsyCn3dY/KRGYA5oifPpP2wLyXBXo2+uvc/jt21X+NuTHmaJms4oEJwqxK1zFJE5V70V0YRhfkBiX73ZBaH4/ymxA330ZCTiOcOYd5puwG72/NXwsHWGyaHaaEeZhq/jpr0vmw1A5nOSVjGUOJIamk2891iAsh66YGAt5p0tquldfuVzErKSJp5lpWGAkrqIqgJ3IRofNo5tMxxVAV3rc+KfO3SdIemcskZ2TGsqjtEpwEHvdEhrtaAkDSXToMryLWkcDZauo6VkxnhgMSBJ/50N3pI5eFeBBZ5r6KrPX8B+uPt8igMKjaHvMnSnPEHaGfdHmYnfeE/3nrd7BcgYam7XHOWWiuVpO1By6mHwYIeEgKMK1I1/m820UVT9ecB5VduL7snXB/p5sVDDTE5s82o7Kh9CZOPADgqOMVcgDeK7BQHQoYf/Ctooj1+++rniOaIP9RQF2ByWcybEzhbLeyD0mcbc/ebOtdf0oxsSFYAkirH59EDSsKsCCizCPV3/5EjS1RF6rlTphfcgtxg6GaQ8w8A9jfpIUuuM0qaE00YFOlMuNSQ2KBQPT8L4IFO8Ft8vuWfzUzmzjFSOGaXzHpVWnjLwl8XlAezemPIxxd4QCGfZ++Y5NfSjekMVfMsiNvisKNc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR13MB3004.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(366004)(346002)(136003)(396003)(39830400003)(6666004)(107886003)(1076003)(38100700002)(38350700002)(6486002)(36756003)(66574015)(8936002)(54906003)(2616005)(6916009)(5660300002)(316002)(66556008)(52116002)(6506007)(186003)(66946007)(8676002)(4326008)(66476007)(41300700001)(86362001)(6512007)(26005)(83380400001)(478600001)(2906002)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a2Z5VWQrMExCckVjR1NrMDlDNnE3L2JhTFZZT0ZiR0JuSVlTdTRBelI4K2d3?= =?utf-8?B?UnF0R2MzeitRczRpVWduY2k2STc0MnNLUkpBMjNwWVJqODdrWFEwRllZQWZw?= =?utf-8?B?SVkwdnl1QnAwaGN3SkUzakhSL3EzSFVubUt3VTlrZk9MYlg2dXpyb0JFKzZY?= =?utf-8?B?ZHNBRklmcHhaQnQ3TkNNRFIxMUErSXo4YVM4NFZiZWxYMzFmY0t2d1VXYk10?= =?utf-8?B?NUcvTUpSbzRDcVBaSn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1ZxUFNQbHFkMjJWMWljSzFB?= =?utf-8?B?TTVqZENDK284b25uWHBUTFZQTkRiOVJsU0YyZTBwWWlEQi92NXY3WTFremxp?= =?utf-8?Q?GLQeJB79RXhGHQE7BUSHFEEkf?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6bdfd8f-ff1d-4d55-1e74-08da54bfe35f X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2022 02:27:15.9932 (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: /p8YBSuDQjga4q3XMwDUQFb0ivLnPsbjXKVyXxPhcYTCXRTasfP0K3jkSv/aV6eHRuYlh06weq6pkmvrYSbdFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB3535 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 ethdev option for firmware with NFDk, implement tx_queue setup function for firmware with NFDk. Signed-off-by: Jin Liu Signed-off-by: Diana Wang Signed-off-by: Peng Zhang Signed-off-by: Chaoyong He Signed-off-by: Niklas Söderlund --- drivers/net/nfp/nfp_ethdev.c | 32 ++++++++- drivers/net/nfp/nfp_ethdev_vf.c | 32 ++++++++- drivers/net/nfp/nfp_rxtx.c | 117 ++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_rxtx.h | 5 ++ 4 files changed, 184 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 1bbba9187e..0d650efd27 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -358,11 +358,41 @@ static const struct eth_dev_ops nfp_net_nfd3_eth_dev_ops = { .rx_queue_intr_disable = nfp_rx_queue_intr_disable, }; +static const struct eth_dev_ops nfp_net_nfdk_eth_dev_ops = { + .dev_configure = nfp_net_configure, + .dev_start = nfp_net_start, + .dev_stop = nfp_net_stop, + .dev_set_link_up = nfp_net_set_link_up, + .dev_set_link_down = nfp_net_set_link_down, + .dev_close = nfp_net_close, + .promiscuous_enable = nfp_net_promisc_enable, + .promiscuous_disable = nfp_net_promisc_disable, + .link_update = nfp_net_link_update, + .stats_get = nfp_net_stats_get, + .stats_reset = nfp_net_stats_reset, + .dev_infos_get = nfp_net_infos_get, + .dev_supported_ptypes_get = nfp_net_supported_ptypes_get, + .mtu_set = nfp_net_dev_mtu_set, + .mac_addr_set = nfp_net_set_mac_addr, + .vlan_offload_set = nfp_net_vlan_offload_set, + .reta_update = nfp_net_reta_update, + .reta_query = nfp_net_reta_query, + .rss_hash_update = nfp_net_rss_hash_update, + .rss_hash_conf_get = nfp_net_rss_hash_conf_get, + .rx_queue_setup = nfp_net_rx_queue_setup, + .rx_queue_release = nfp_net_rx_queue_release, + .tx_queue_setup = nfp_net_nfdk_tx_queue_setup, + .tx_queue_release = nfp_net_tx_queue_release, + .rx_queue_intr_enable = nfp_rx_queue_intr_enable, + .rx_queue_intr_disable = nfp_rx_queue_intr_disable, +}; + static inline int nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) { switch (NFD_CFG_CLASS_VER_of(hw->ver)) { case NFP_NET_CFG_VERSION_DP_NFD3: + eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; break; case NFP_NET_CFG_VERSION_DP_NFDK: if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { @@ -370,13 +400,13 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) NFD_CFG_MAJOR_VERSION_of(hw->ver)); return -EINVAL; } + eth_dev->dev_ops = &nfp_net_nfdk_eth_dev_ops; break; default: PMD_DRV_LOG(ERR, "The version of firmware is not correct."); return -EINVAL; } - eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index 0b4660aba6..2342f44523 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -265,11 +265,41 @@ static const struct eth_dev_ops nfp_netvf_nfd3_eth_dev_ops = { .rx_queue_intr_disable = nfp_rx_queue_intr_disable, }; +static const struct eth_dev_ops nfp_netvf_nfdk_eth_dev_ops = { + .dev_configure = nfp_net_configure, + .dev_start = nfp_netvf_start, + .dev_stop = nfp_netvf_stop, + .dev_set_link_up = nfp_netvf_set_link_up, + .dev_set_link_down = nfp_netvf_set_link_down, + .dev_close = nfp_netvf_close, + .promiscuous_enable = nfp_net_promisc_enable, + .promiscuous_disable = nfp_net_promisc_disable, + .link_update = nfp_net_link_update, + .stats_get = nfp_net_stats_get, + .stats_reset = nfp_net_stats_reset, + .dev_infos_get = nfp_net_infos_get, + .dev_supported_ptypes_get = nfp_net_supported_ptypes_get, + .mtu_set = nfp_net_dev_mtu_set, + .mac_addr_set = nfp_net_set_mac_addr, + .vlan_offload_set = nfp_net_vlan_offload_set, + .reta_update = nfp_net_reta_update, + .reta_query = nfp_net_reta_query, + .rss_hash_update = nfp_net_rss_hash_update, + .rss_hash_conf_get = nfp_net_rss_hash_conf_get, + .rx_queue_setup = nfp_net_rx_queue_setup, + .rx_queue_release = nfp_net_rx_queue_release, + .tx_queue_setup = nfp_net_nfdk_tx_queue_setup, + .tx_queue_release = nfp_net_tx_queue_release, + .rx_queue_intr_enable = nfp_rx_queue_intr_enable, + .rx_queue_intr_disable = nfp_rx_queue_intr_disable, +}; + static inline int nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) { switch (NFD_CFG_CLASS_VER_of(hw->ver)) { case NFP_NET_CFG_VERSION_DP_NFD3: + eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops; break; case NFP_NET_CFG_VERSION_DP_NFDK: if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { @@ -277,13 +307,13 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) NFD_CFG_MAJOR_VERSION_of(hw->ver)); return -EINVAL; } + eth_dev->dev_ops = &nfp_netvf_nfdk_eth_dev_ops; break; default: PMD_DRV_LOG(ERR, "The version of firmware is not correct."); return -EINVAL; } - eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops; eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 9b769c9775..4f422c5090 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -987,3 +987,120 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk return i; } + +int +nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, + uint16_t queue_idx, + uint16_t nb_desc, + unsigned int socket_id, + const struct rte_eth_txconf *tx_conf) +{ + const struct rte_memzone *tz; + struct nfp_net_txq *txq; + uint16_t tx_free_thresh; + struct nfp_net_hw *hw; + uint32_t tx_desc_sz; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + PMD_INIT_FUNC_TRACE(); + + /* Validating number of descriptors */ + tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfdk_tx_desc); + if (((NFDK_TX_DESC_PER_SIMPLE_PKT * tx_desc_sz) % NFP_ALIGN_RING_DESC) != 0 || + ((NFDK_TX_DESC_PER_SIMPLE_PKT * nb_desc) % NFDK_TX_DESC_BLOCK_CNT) != 0 || + nb_desc > NFP_NET_MAX_TX_DESC || nb_desc < NFP_NET_MIN_TX_DESC) { + PMD_DRV_LOG(ERR, "Wrong nb_desc value"); + return -EINVAL; + } + + tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ? + tx_conf->tx_free_thresh : + DEFAULT_TX_FREE_THRESH); + + if (tx_free_thresh > (nb_desc)) { + PMD_DRV_LOG(ERR, + "tx_free_thresh must be less than the number of TX " + "descriptors. (tx_free_thresh=%u port=%d " + "queue=%d)", (unsigned int)tx_free_thresh, + dev->data->port_id, (int)queue_idx); + return -(EINVAL); + } + + /* + * Free memory prior to re-allocation if needed. This is the case after + * calling nfp_net_stop + */ + if (dev->data->tx_queues[queue_idx]) { + PMD_TX_LOG(DEBUG, "Freeing memory prior to re-allocation %d", + queue_idx); + nfp_net_tx_queue_release(dev, queue_idx); + dev->data->tx_queues[queue_idx] = NULL; + } + + /* Allocating tx queue data structure */ + txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nfp_net_txq), + RTE_CACHE_LINE_SIZE, socket_id); + if (txq == NULL) { + PMD_DRV_LOG(ERR, "Error allocating tx dma"); + return -ENOMEM; + } + + /* + * Allocate TX ring hardware descriptors. A memzone large enough to + * handle the maximum ring size is allocated in order to allow for + * resizing in later calls to the queue setup function. + */ + tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, + sizeof(struct nfp_net_nfdk_tx_desc) * + NFDK_TX_DESC_PER_SIMPLE_PKT * + NFP_NET_MAX_TX_DESC, NFP_MEMZONE_ALIGN, + socket_id); + if (tz == NULL) { + PMD_DRV_LOG(ERR, "Error allocating tx dma"); + nfp_net_tx_queue_release(dev, queue_idx); + return -ENOMEM; + } + + txq->tx_count = nb_desc * NFDK_TX_DESC_PER_SIMPLE_PKT; + txq->tx_free_thresh = tx_free_thresh; + txq->tx_pthresh = tx_conf->tx_thresh.pthresh; + txq->tx_hthresh = tx_conf->tx_thresh.hthresh; + txq->tx_wthresh = tx_conf->tx_thresh.wthresh; + + /* queue mapping based on firmware configuration */ + txq->qidx = queue_idx; + txq->tx_qcidx = queue_idx * hw->stride_tx; + txq->qcp_q = hw->tx_bar + NFP_QCP_QUEUE_OFF(txq->tx_qcidx); + + txq->port_id = dev->data->port_id; + + /* Saving physical and virtual addresses for the TX ring */ + txq->dma = (uint64_t)tz->iova; + txq->ktxds = (struct nfp_net_nfdk_tx_desc *)tz->addr; + + /* mbuf pointers array for referencing mbufs linked to TX descriptors */ + txq->txbufs = rte_zmalloc_socket("txq->txbufs", + sizeof(*txq->txbufs) * txq->tx_count, + RTE_CACHE_LINE_SIZE, socket_id); + + if (txq->txbufs == NULL) { + nfp_net_tx_queue_release(dev, queue_idx); + return -ENOMEM; + } + PMD_TX_LOG(DEBUG, "txbufs=%p hw_ring=%p dma_addr=0x%" PRIx64, + txq->txbufs, txq->ktxds, (unsigned long)txq->dma); + + nfp_net_reset_tx_queue(txq); + + dev->data->tx_queues[queue_idx] = txq; + txq->hw = hw; + /* + * Telling the HW about the physical address of the TX ring and number + * of descriptors in log2 format + */ + nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma); + nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count)); + + return 0; +} diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 106980b9a7..ba8ffbd1ff 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -347,6 +347,11 @@ int nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, const struct rte_eth_txconf *tx_conf); uint16_t nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +int nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, + uint16_t queue_idx, + uint16_t nb_desc, + unsigned int socket_id, + const struct rte_eth_txconf *tx_conf); #endif /* _NFP_RXTX_H_ */ /* -- 2.27.0