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 B33A2A0548; Thu, 2 Jun 2022 03:55:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5FE84114F; Thu, 2 Jun 2022 03:55:00 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2092.outbound.protection.outlook.com [40.107.223.92]) by mails.dpdk.org (Postfix) with ESMTP id AE3974021E for ; Thu, 2 Jun 2022 03:54:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ajkr9WJHcqbTobw89yLpePga1ILG/BY/36vRV35UHEpHYlUsZ9dhfX1XemcuJhG4th0NFpKGVI9bN7FWtv2KfrpCo/svA0KchTnagq8ClX8HuryUQ8LPGshWlpiOEcCxXhy6fgc4KrYCvWDfi0mvKpwMjtA/Dv+uFz0036pRJxymphu/xgPBRvK1N4l/3q8qdYfSY7YYoWXVmfkaNNXZWO6+aYzlvQFFoxOtR02UWJvT8TOB2MmkN0RTS+FUr5pgzKfcTGyRsIZSP8entJTmuXn2oTAKu1vDDwFrZ55qTflQwsn+PoBIqIXgmNywm+E20yALBxm0dwzPVCmPVHrEug== 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=/iCTxPWHt2xt8CJmcuYqEW0PndjKZ3xe6PbOOAXbQIA=; b=bNwHl79ean+OSvdb+moMpdHl1Azy2SO4EVL+EyVyQhyCmCgDOtZREaHoBUtGSY5LiKNh1hgasxrIIpLWqsK3mjsWYEbvFEAoetHJWSdkl1ceGiTRg7VMAeGB1cr336RjPkcyQdLGTNqBwGRtPqwsO3WWpPJ2BWxpCMvY7g2YyCXoHIWEYNpXhrlafziBQfDn23Iol33JrQQ4/RmPkovRrPJNpWWRdwEpoMxBMxj/ozfpILyK5NyuG28NAkvuw7jnCRAz93X7sfaPuc57/RkMTii8VhLxpavj/mfc+W5PxaYpQKA6jnjPihRA/2oYAt2OIX4FLqof5WcM9MB7QwTmWg== 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=/iCTxPWHt2xt8CJmcuYqEW0PndjKZ3xe6PbOOAXbQIA=; b=gAlh8lw+A92bI2mcV1Rxv4dPLcyklzH0LTPPcV/qFbAoP1Z9VsRVUN8lcKtCmmNLuobdICIq1bXDUC2D+6ocBKcydw/Oe/vHYJs0hkY5VgJrOoRxWFk8w43yrXsLaSo+gJ/pXwWzqr0yJ/Xom26GxZZPLIf5D/YMrZz/INqKtqw= 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 DM4PR13MB5858.namprd13.prod.outlook.com (2603:10b6:8:46::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.11; Thu, 2 Jun 2022 01:54:57 +0000 Received: from DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::d902:ed7d:82bb:c753]) by DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::d902:ed7d:82bb:c753%4]) with mapi id 15.20.5314.013; Thu, 2 Jun 2022 01:54:57 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH 09/14] net/nfp: nfdk netdev option and queue function Date: Thu, 2 Jun 2022 03:52:59 +0200 Message-Id: <20220602015304.710197-10-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220602015304.710197-1-jin.liu@corigine.com> References: <20220602015304.710197-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0457.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::12) 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: ea5c1a5c-3746-428b-a88a-08da443ae4f8 X-MS-TrafficTypeDiagnostic: DM4PR13MB5858: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: nyiOxbS0Wi9DsEYJeBzZEo2UmGkTLyLOLhbFu+pxqZ55TwwUtZOZR4edrywXdJq3xkfSXyG/tZTsntWcLwcxR5QbHFJMQTe8aOd+FGYNyu5F8dfp9YcNiJTTCLfrt8M76L+UWUZ4HBynK/nTOIa95nhl6N/LG5p0151yyMRufN9RyPaFogGOz1nOk28SEH/cohgSaZb9agM935MidiW3UvBICCCscYkoKozfW+U5SXomRpNxy6bBZNwhyBMB0nkTV17Y9WeAFvwNvZlxf+On2eHUctwUPD4m4w0OKbWjKMsZrHWyNVspLRJTc4YPUqi6Hf4o/GIObUaVd1j92hG7ocZ2Tb4MvvJcQaY1NFsfYn5Ha4KmwCWca12nAGrafpawxsGVnYzhpGwGLMIz00fiFUQqVvUT+KYk7YpcCedxjC5kWjbgejzb1fcWGdgo/ZdkZ64VeKr5VSLJHs3hs9BtqkdhwxXn9ioTn93z3wY22UiMzDmczVpvcTOWqpxnEdrDaCLpV7tpzaXbnuM3nR1ZVAUCjo4CMDKfgH4Ccpt4EHPZXsCFSF8kPtG2omUXJBjCdj8+C1L0AtJFiA7CwrwANRmlvnPTJrxAeCfnKW+0qhf4don+J25H/cmX4FVpooqzIG42fEkuffx4Dwug9vOoyRbXs9QRzcobYjnIb7K1XmP6BCjMhdFIccZ5kaBUuqIAnahn6rOBIxC/fsCp33gOuw== 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:(13230001)(4636009)(346002)(366004)(396003)(136003)(376002)(39840400004)(36756003)(186003)(66574015)(83380400001)(30864003)(5660300002)(4326008)(44832011)(8936002)(2906002)(6916009)(54906003)(1076003)(107886003)(6506007)(316002)(2616005)(41300700001)(8676002)(66946007)(66476007)(66556008)(26005)(6512007)(52116002)(38100700002)(38350700002)(86362001)(6486002)(508600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bHNQcEZGU1I3a2RhS2pMeXBXRzV0UGVTcnlNVHFmajBVUFBFelFWTThqU1pj?= =?utf-8?B?M1VCeFZWTCtkakFyUEVkK2JKdjhzQkEzeHVVUVZQTlVtKzNCTlIvbFRTRi9w?= =?utf-8?B?bFNCODd0Rk5SczVkbi9MVmUySDlOTVBWdmhuSTloendhczBxYUVSY05EQzhT?= =?utf-8?B?L1JIay9aTUZxZVorNUVmQTV6Uk1FR21IU3htbmhjTGMzSG53T0tkWEdJUWJm?= =?utf-8?B?QTVVbkUwaWJ1Ky9tSDVuanBCK01kdjFtVlNMWDkyS1dHTXNYbENiZEZXUkxh?= =?utf-8?B?TVpUOUkyVU90cHVOL3pEektxUmVEZGl3ZnhvSEJ2RWhzRnkrUVJ2MUhDL2lT?= =?utf-8?B?QTRjYmdYWVR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Uk5JSnJh?= =?utf-8?B?c24rL0JRYUd5a3V1OEhFU1BEYWx1NFNyY0dCRXpxankzdnRyQlgvejIybFkw?= =?utf-8?B?MFpMQkZPdTRLK3BmNVhXWHgybnFCWjBCNXhEYk41M0EyTGhYeUJnMUV1RWRy?= =?utf-8?B?ajJLemxleU41SCtvdzlFRVc5dFJhYVNKczAvRWtBV3M2cnBNeHdTZz09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea5c1a5c-3746-428b-a88a-08da443ae4f8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 01:54:56.9295 (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: TIbs+MxGh+weUoqgKq2G3ucjXdNzgZKjxJLwS9zU4aLNQYyqwcC3ruuY9gsz27IlQE9hmN1Qkt0qnMbqz/ntNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR13MB5858 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 NFDK firmware, implement tx_queue setup and release function for NFDK firmware. 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 | 40 +++++++-- drivers/net/nfp/nfp_rxtx.c | 153 ++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_rxtx.h | 7 ++ 4 files changed, 226 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index c09a035323..2bf7a565bc 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_nfd3_stop, + .dev_set_link_up = nfp_net_set_link_up, + .dev_set_link_down = nfp_net_set_link_down, + .dev_close = nfp_net_nfd3_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_nfdk_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 e83c9dbcaf..ee9ff977cc 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -265,6 +265,35 @@ 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_nfd3_stop, + .dev_set_link_up = nfp_netvf_set_link_up, + .dev_set_link_down = nfp_netvf_set_link_down, + .dev_close = nfp_netvf_nfd3_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_nfdk_tx_queue_release, + .rx_queue_intr_enable = nfp_rx_queue_intr_enable, + .rx_queue_intr_disable = nfp_rx_queue_intr_disable, +}; + static int nfp_netvf_init(struct rte_eth_dev *eth_dev) { @@ -291,11 +320,6 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - 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; - hw->ctrl_bar = (uint8_t *)pci_dev->mem_resource[0].addr; if (hw->ctrl_bar == NULL) { PMD_DRV_LOG(ERR, @@ -309,6 +333,7 @@ nfp_netvf_init(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) { @@ -316,12 +341,17 @@ nfp_netvf_init(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->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; + /* For secondary processes, the primary has done all the work */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 2c9875e829..bf5817db4b 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -987,3 +987,156 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk return i; } + +static void +nfp_net_nfdk_tx_queue_release_mbufs(struct nfp_net_txq *txq) +{ + uint32_t i; + + if (txq->ktxbufs == NULL) + return; + + for (i = 0; i < txq->tx_count; i++) { + if (txq->ktxbufs[i].mbuf) { + rte_pktmbuf_free_seg(txq->ktxbufs[i].mbuf); + txq->ktxbufs[i].mbuf = NULL; + } + } +} + +void +nfp_net_nfdk_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx) +{ + struct nfp_net_txq *txq = dev->data->tx_queues[queue_idx]; + + if (txq) { + nfp_net_nfdk_tx_queue_release_mbufs(txq); + rte_free(txq->ktxbufs); + rte_free(txq); + } +} + +void +nfp_net_nfdk_reset_tx_queue(struct nfp_net_txq *txq) +{ + nfp_net_nfdk_tx_queue_release_mbufs(txq); + txq->wr_p = 0; + txq->rd_p = 0; +} + +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_nfdk_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_nfdk_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->ktxbufs = rte_zmalloc_socket("txq->ktxbufs", + sizeof(*txq->ktxbufs) * txq->tx_count, + RTE_CACHE_LINE_SIZE, socket_id); + + if (txq->ktxbufs == NULL) { + nfp_net_nfdk_tx_queue_release(dev, queue_idx); + return -ENOMEM; + } + PMD_TX_LOG(DEBUG, "ktxbufs=%p hw_ring=%p dma_addr=0x%" PRIx64, + txq->ktxbufs, txq->ktxds, (unsigned long)txq->dma); + + nfp_net_nfdk_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 81e2f7560b..cce3e0c0e5 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -352,6 +352,13 @@ 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); +void nfp_net_nfdk_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx); +void nfp_net_nfdk_reset_tx_queue(struct nfp_net_txq *txq); #endif /* _NFP_RXTX_H_ */ /* -- 2.27.0