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 4C8DEA0093; Fri, 17 Jun 2022 11:36:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B76D342B7C; Fri, 17 Jun 2022 11:35:38 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2096.outbound.protection.outlook.com [40.107.94.96]) by mails.dpdk.org (Postfix) with ESMTP id 6372142B81 for ; Fri, 17 Jun 2022 11:35:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qe32sNi6g7iPZf5D9/+R5f+Y7lcQ60CZJBRX5awZjvTPn9GfXMKh1a/Xs4Wg2+5Lc4L8bPnzgldWqyaaNAtKFN3JHh2YOqhDFW+Bk46jaM2lITErW1R1d907ac1sMJvdItAHb/2XT/DGyjVPwSANolVQ5W/EOd5bzgLm8aGXaAXxj9wH8qqSbfKE8sd6vkuwgis8iGOjYwE5orvQq1Xff6OmQQrwowaCo8YcMrh/sjnvvfH+ir3781gA2ajJPgMKLfx0FjEIOGCfDhACdCN/adw4wOHuks3jiUcbB4h4IcPTHxIZKtTvjz2Xdf/BRk8H+4NQQ/PO/ZMBne/BYNHURQ== 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=eCyuGY6klLumQ5bTJeH7Qdfsj32XtngsWektnoLBXYAm5LVfTmG1vvfzgAIW5C3CAAMerM1IcoPwJ+eo9IelNNbC4wyntgFAyGE9Y6T37JOtVvhuQSzXHf7qeGDlLDrdSYcyYM++9zyIUj7+tRBCdnPpWAsNkR2QO18U+iQe/yzgZU3T0ye717mUNSmOHTYUtQ4wOlffbAGMY+XDrSIFUoDCwHF4Zdqp4kTZcq4Dui9tEerHk6KHvEToY9+TyJ2hFEl+0r/JAzxHAr+yaKQSUkBPQN+o9ObkCSoXvLomSABSWA1slEIW4AwJeCSOFGQaPXPBPnVBi4hoSLHW2qIgAg== 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=jDiWoiaECLtGsNEkfN6dqfVMlmpvUgoS+rpc2cSDd0yI26Xx+eGb/19Im41U2ON8/DZpDgzAJ4E93yetbkDktWxc5tYzGasmkfaHvVXat9aVKHhoa0MORMoNttscNRgDqq2cNvVG4kEWmA+JG2kE7zpOgTxF3px3otHItGTH0sA= 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 CO3PR13MB5671.namprd13.prod.outlook.com (2603:10b6:303:17a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.9; Fri, 17 Jun 2022 09:35:32 +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.009; Fri, 17 Jun 2022 09:35:32 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH v3 09/13] net/nfp: nfdk netdev option and queue function Date: Fri, 17 Jun 2022 11:34:40 +0200 Message-Id: <20220617093444.2004000-10-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220617093444.2004000-1-jin.liu@corigine.com> References: <20220616023939.1798769-1-jin.liu@corigine.com> <20220617093444.2004000-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0192.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::17) 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: e5d3b5f8-f35b-46b2-5467-08da5044b94d X-MS-TrafficTypeDiagnostic: CO3PR13MB5671: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: Gaqj8f4scivtv5Hz43yri7xfN7WTJJ7txxDvmb2g5uLnvI4jBIKtGYP3k/vmybvMJorpMFUTfFtandgE8a5liav4pbzCtUx4fUJN7cVgiewexSzCBHk+C0Du0c1bLYkznjtZ86ZjxYkCH5trII0IxSaxuG6cczJyj13nKXigE7/+SLjudzH7SG/078pdTGzMbGcGnpzgbgAH/ZjQok7CFFUDa125XBytZ2QtVd6Ic7Dw+3PgTUz4XmeDU+f7zxqlhuxRsdcmbAkPvMH0B09pVPe4l/xZN3VwfxFU6Z8G67YFxlOBvzApDzyFmkP2qIGrGTr0TXgnzSXvnDLrilmcLS7t4dqFU/ZUGoDPATG273EjkAbqBdttEfBUOd9VwIXDLsdn7eJQErXkT1pjCrWBKa4GKtbAGfiAalNiy0xywc4VojCppUo8CO1IPcfWCuToW/ROBdQll5V5OG2fnARhHcgV7wqdYxrtMvOBWXmn76Nz656yHZRiPKazhaI2VoXbGnno8nH2Wq6OyAh85Ry8t0X4yQC8Y6SqpuH7LVRCkSmPo7++WNApoBI2Hq9LKqlIsMapIxW6JzPaXSdqY/Tj07/lO6odT2y4yKTCSykmJAWiGUVOuW79OkjH5Cf5bD2rg1fGJVq7f2S64efAVIR5pSn2MGi8VOiWeZi8N9F70vDbr/aq09rHOublmoVCItFHXdcThq5aMD5bwZ14AClx1l5MBQtq5hlH3ZKPIZCp6TcUOo7jJ1ypBm1Oql2VAO0H 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)(136003)(366004)(396003)(39840400004)(66476007)(66556008)(26005)(8676002)(66574015)(6666004)(107886003)(66946007)(6506007)(6916009)(44832011)(2906002)(316002)(4326008)(38350700002)(186003)(508600001)(54906003)(5660300002)(6486002)(6512007)(1076003)(8936002)(2616005)(36756003)(52116002)(83380400001)(86362001)(38100700002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TVNxWnBoNlZqY0ZjWVFUMXJYSDdVQVlnNFZtbWhMemhKdkpMYUh2Y2wwYVBK?= =?utf-8?B?T2V3eHdQemJTQ2IreHZiQlAvSHFZYlVOSitQMk9pcE4wM3BydkpCYlhidTZB?= =?utf-8?B?bTNUSzBCUXRHK1YxQmJWNjhWR3ppdkFNK25UaDBRS2ZpeURjMWk3OEhoRFcz?= =?utf-8?B?elozMU9uV0R1aUczMmN4d1hlRzd4TEdtMVNzenVzK3ErS3lOazlLWUE0cjVJ?= =?utf-8?B?WnVGRm5FdkZoVnNHd3RnOEx6NlY3cXpCYlNmVmttZzE4VzJic0Z3Tjk2K0ox?= =?utf-8?B?bml4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5jYk1VaVB1?= =?utf-8?B?UGc3UW9reUVGS1pHS01HWklidXQxSVZFY0I1cWFqMTNmZzBUT1hyWWhVdExx?= =?utf-8?B?ZFpHVnJKV1RWRFNXelhPOWRvWFEwYys5Ni92M21hZlpheDc4cGZQQ3dYOHIz?= =?utf-8?B?RUswSEs5UlNvaUtUQWlPalNBNlNFNHV2dW9nK0VNUWtLMEZMQXR4RTdWcDhC?= =?utf-8?B?RUFTZ2E2Q0tESVYxbCtuSHR3dVFpcXZ0TXpMajgyYjlDZ3hwZ09WQT09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5d3b5f8-f35b-46b2-5467-08da5044b94d X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 09:35:32.6947 (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: 8Qnt/nc8QvTBdle+w/xTsSdvEru3Qlp9HnY598xD3ZR+swg7YUkzNfQD2gljuCJ2psznC2RufdpCdPjzzdOEEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5671 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