From patchwork Thu Jun 23 02:26:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jin Liu X-Patchwork-Id: 113290 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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> 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?q?kfyUd+0LBrEcGSk09C6q7/baLVYO?= =?utf-8?q?FbGBnIYSu4AzR8+gwRqtGc3z+Qs4iUgnci6I742sKRJA23pYRj87kXQ0FYYAfpIY0?= =?utf-8?q?vyuBp0hcwJE3jHR/q3HUnmKwU9kfOLbX6uzroBE+6XdsAFIfpxZBt7NCMDR11A+Iz?= =?utf-8?q?8aS84VbelX31fcKvwUWbMt5G/MJRo4CqPZJyeB06QnltYxgYy9vxtFiF2Jxa8+/Pu?= =?utf-8?q?BbWw32+0y23nm10EDiHTHGhNbY5ysQKd7aLN2tzsvtJpToXfk40GA2Psukeu4F4ke?= =?utf-8?q?NHZo5QR6nVRi6bzYc4VIJd8dbLepal+hOINyOcOH6CRAvdOYhB+8OkehEepIx54rw?= =?utf-8?q?lF+WDbjyB/2dwNgSN7eHGFuERxMXNDaLZQBFpzycqUu3sWn6VMdJm0CzkWLvaifn2?= =?utf-8?q?GqIaqqifVid8LMCZYI469z7CXxWX4+Hirbu8ttVizvlL6A31GdmvL3VmKuQgr8a41?= =?utf-8?q?VlWJRKChdXOOmCO8IC1Dhj020tGugTh1FLCwpS65MtFUYQz3dFwSN0EHOOYoLC+lp?= =?utf-8?q?BNFMZBs1vJ4bdBxAq+WPAy0G9cNwuN2OJ3/Ee9NriKyFJbdlZ00qEoNXWAUWUlCXM?= =?utf-8?q?2tGODqulj4Gexdo0qbvROEX9Ve4m4a11Dq0olo6B88KVa6gOyejAaWLap8pZ6S8fZ?= =?utf-8?q?M2x4la1CG9ISm90BMQo2QWqqOVI/DXHARtFUUInJbfAb/dmbjAF+srcGdGqs0Py1E?= =?utf-8?q?kivYN3E4KvXSNtPgpkdJaQf1sDPgEGSl29EneDSak9lhLjruqSb6FiKYOZxPDvARX?= =?utf-8?q?30h+WJ11qn4VVtB9Bn1vNeZG7QEA98BfVAWpHfqEHj0f2mWszXnu7XNMFlbeiowtj?= =?utf-8?q?BP513jb94/INrJIT0f9f7mdtxde8JprJ5J4jY9jOLZ2F3jT/0gJqYNf5uSrgXLGe+?= =?utf-8?q?dSQck5Ll7KZrYEkAoVGamsP3lAu0MNGv/jO/oSnp0iTjtGC8Rp/so0o9qf/tdl38R?= =?utf-8?q?ExqVVBQjTp+v091xlor9WjTPZE0piJd+qf6tTMtm11mldpjfifkeCbPIxxHgSaTsN?= =?utf-8?q?MTp2XXxiJ90DljAQ94sQCYgMpJJgvZvRuu2SmjqHfErD55AH+zunu5tRLA1dTMTPv?= =?utf-8?q?hVAzZDhIEsuPIC/BaSfVZ+fRV9vBiLOmFPh6xFpC4r6GVUE99URavcZ9ipqGWCBIS?= =?utf-8?q?y+Ecq+YbX53mCm1A5bEfRVtJnmdruQvdJvLgOA4gIYebcafWn0KxTQ7neosYtq0fn?= =?utf-8?q?CV1r1LTyRWo7oucdi3qQ92Wu5hIQmfH1bdJ2ImPdQS35s4iniJkWryAx6BYSIwJGP?= =?utf-8?q?JgYiaPMMsnv422ipd0K5mvuUlp21afCXBV4+x7gqJRPbxt8HFvmIJIo/AykpoQKuE?= =?utf-8?q?0Nddws2Be0PwUSWeVE78fvXvScRTwlcvb2xFrLlbbjEBbyUUFuFTC+UqxfT4KFKkC?= =?utf-8?q?WUzhZj47Ty63mmF32cp6pNHSv4F7QxvXCNqs/xYXZWzZu6mokEZ4stcVqPSPlqd22?= =?utf-8?q?V1icK1AM5jdCC+o8onnXpTLVPNDb9RlSF2e0pYiDB/v5v7Y1kzliGLQeJB79RXhGH?= =?utf-8?q?QE7BUSHFEEkf?= 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_ */ /*