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 778E0A0547; Thu, 16 Jun 2022 04:41:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5433842BE0; Thu, 16 Jun 2022 04:41:22 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2100.outbound.protection.outlook.com [40.107.94.100]) by mails.dpdk.org (Postfix) with ESMTP id A715B42BD2 for ; Thu, 16 Jun 2022 04:41:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TXnrPiXwKJY7Vf+ztWrQpsS0FRUYE0aS+sFHjdzIaTj8FAtmjw7tUcoCrWCWBcFhrV98FAD2L/Rog9/lQ/nBlmp/DB+3RZzWPMZUOkLv5tEVQDoZMeTDrpOQAocvxzFtTHDROIFTp3KqrqxQ0gwcivPEv7k7joKxuquGS1xlNgGRvF2Me13RAHN7vwJ0zQDZpr5Vb7icO+U79EneKj58KJm20IxxprNi0V9kvW5JOAG6epHVDbWLSDQ5nkWUsQSnToZ4bCrnf+TG4wia1zySAw5+QuABC9AxGMfWaXdWrVHfvbJ6m3DOrTXzCpXRCzaucnxwM59dOqNesJbi0f0SoA== 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=D081hqYNe96bl0mx2TZVNmGZu33HZNP38KUhD5Hqyuc4CGUBhUWyNYdlygq+Z/1A8dWv2gSbYI0c+yMqmMEHNNBa+M2sXy7Z7Gf+J+5edpzqYGL3rMUTnIQCQwik3VNPT3vtA/OFsvCaeOXKI985e5MDcR2Uo+r8/NPRPqs+LSYvLla2YcO+wkfuSkXFoVWPH6+fFvOSlwg9AP4f1cQl41jjW/VyUEhWKUI5gcPXLS03hv8ZwDBpeWHc1/IMrNZQW/Q5alnTvOURJwXNQRuex6OF4I83mtPazbydvgQDs3YnnSuZ4dv7G2bD1XM+hFASaNEQGXIGfyUuYmW5O/lK2g== 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=niecC2YTD+zV+WgXC69kdwp3QSq93u8oW+mlHhQsIM7nR9wyXKiGr+yg+GcnNB0Yhcqhk1SxpkMoH9X3FkSTiAnA2V2h0NtTxbk2f/T6pgSj3Ko6owrnaHvkNdYT7bKcmBIl1aG9jB/bV32I/GkkFfuccelVkh4+KuBMUgghhyA= 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 DM6PR13MB2345.namprd13.prod.outlook.com (2603:10b6:5:be::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.9; Thu, 16 Jun 2022 02:41:18 +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.5353.011; Thu, 16 Jun 2022 02:41:18 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH v2 11/15] net/nfp: nfdk netdev option and queue function Date: Thu, 16 Jun 2022 04:39:35 +0200 Message-Id: <20220616023939.1798769-12-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220616023939.1798769-1-jin.liu@corigine.com> References: <20220602015304.710197-1-jin.liu@corigine.com> <20220616023939.1798769-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0087.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:190::20) 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: f573c4ef-7fe3-4bc3-555c-08da4f41b06c X-MS-TrafficTypeDiagnostic: DM6PR13MB2345: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: pbd7Ncq9C+NV0P6yIe6E9Mh22jAPCIWzz1JyFfG4r0h4dxJTqe0KIm9DqupO4PTNaer2H2RvJIk3sisJMd+1w98HNFCXW1+sjpZ2WbesQfC/imUK/jSGx0pJ/kDpgv+unPIVfDycq4ZMSonqLQkqbDI6lKzx47Hdydf+hHyh6Vt2HjwgblMcvJhWCwwi3tlwu1XoeIhCuUEdaiNhvsmvpiGzJ2wfCWwBMmDwcax7vqdPCsnNDT0KZE17r22gma2W2TOtjoQCm8Li1+WiiKUA4GZOWPFUccGHU4VHIWibvUculGuC0eoJFLVmdYqrCa0LPb55oo5Ml+BdaJYS5tTRTvvn/1d1pxXvHLyl/5UiUAK3APNZavYSDHvyU72IkDhHGzmcx4MgDObIFzJZSFyWEPQnOLEdTpylDxGpcE88nmfG0bH1kxaIrQ6pyajUm1u+fF4AQv+gYAVcc+Cs8rZz5PkRMcTyDvB27C5XdxasEakGPbcDYx9X+hAA3JcO8XzcMBiwOR4QPJcw74pA+oF7ICWL1STE0LqE6VRqv+WLIGKl3QOvj87hEv48dn1q9yUBK1bW7sIXfbJoO2jYhPCQmDITA9N5Mhlk9/xh2StJXtvbFDB1lk/CS9A/z+fUfsGu3OVsehG0fmaKKoluBhax3MQUvPhDqYYj/Zs7vlBIu4ujoXtx50MtvTT1BUV2rppf 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)(346002)(396003)(366004)(39830400003)(136003)(6506007)(6666004)(26005)(316002)(66574015)(186003)(107886003)(6486002)(508600001)(41300700001)(2616005)(83380400001)(1076003)(36756003)(54906003)(6916009)(66556008)(8676002)(2906002)(4326008)(44832011)(38350700002)(6512007)(52116002)(5660300002)(66476007)(66946007)(86362001)(8936002)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RU1VOHpLdXRWRUMwdGhPRXdkTWs3elZzYkRmV1VZMVN5Mks4TFpsYVRvbnZt?= =?utf-8?B?UTlMWmVPYk84aElGT2xWSDcwblV3aG9sOW84NWMxS1VsRHJHS0UzZlcxdTJ1?= =?utf-8?B?dEtKcU1jNk1YelE4N2UzOUI5WnhFOUk0K2krdi9IKy9OT29Nb2pGcW9nZFFG?= =?utf-8?B?QlNheXVUcnExeXpXdVVHdW1wQ3QwSko0UWJaTmZ4UjVuWk1MdEp3MnNyUmRy?= =?utf-8?B?WVF5eGd2QWk3MHR1MTlKZlM0Vy92WFdVOFVXcHZRYWpsSWVLOVREcnBwU3Ey?= =?utf-8?B?YTJRbkZobmI3aVFhYjhLYS9reVUzejlLTkV6OGgvaCszV0Y1b1pGZk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WkNHQW9KVjIrNmlGYTZuRGZ2MTQx?= =?utf-8?B?Q1ZiK2RNT3haQWJ5T1pxanZsKytLbjNpbnJuK3lJTE9JVWF5TTZaekc2Rzhv?= =?utf-8?B?OHRwK3ovK0RjblpkZ2pPZU4zZnBneE5vb28vNnNEMGZBZXZPTktuRG1MaFI0?= =?utf-8?B?RGZxR3hZVEhHUXJsd0h2Z1NQaU5IY2FhYzRON0NRbUlpaEZrSlBNUT09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f573c4ef-7fe3-4bc3-555c-08da4f41b06c X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2022 02:41:18.1298 (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: SMRHutIjskUpaSZNgy+ps9NTOiOHHBCLaowMSz63I/mErNcSAM7pyij8d96I4nADjRL6ckV2ogJbhFwoWDLLLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB2345 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