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 E853EA054A; Tue, 22 Nov 2022 14:10:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 984DE42D61; Tue, 22 Nov 2022 14:10:25 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2107.outbound.protection.outlook.com [40.107.101.107]) by mails.dpdk.org (Postfix) with ESMTP id 92FC8427EB for ; Tue, 22 Nov 2022 14:10:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F9fU8Rjcbx+gIInw9jFTemLHB+XR9Fg24RLhRw6YQc8cGx5ize/lKWV64BJzWotPDdO/9keIr1ha4CQbdx5pNTzmNqPvP2yUOgEwpaWVBTPzrfOCgyuNcKCJa4/zjta67tnnjpmTPXzh+McDzsnN3yvzsH+6rtMwCVH2Atd49B8r2aLdGKCSHCO0/Q6vdrfprYhRSTYxa4k6exSLUnAJAN4t9gujkBlKXlxfr/y5ZRe9kFgAPs9ciRdwI7v9B6U9g/smN1mD0i0QBeGlgycO5isfjXJrNZs1YHalXbc9lzRoIKAcR0we/4h5kOfgD1ZiB3Id6St956/7/BVr+e6tnw== 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=mnZB93e09f/haVvZzulldiMhl1CPHu4jDVj71aa6Hfo=; b=B5xxIc0q6Twa+aWW+SeHv53wPmyok8otm94ifBX9KKbl0ic8oGQ7NBYqrrmf/gHP7QQOQIK+NVyNLo7INvd1W3K0IX5DZ2Zy53JQgTrO1M5RhbSe1ukggkmi7RWqL7yURkNK7B1L9mEFlbjsY4zdN9CJ8O3nJUhE3DcAE8nLaJs4jh+H4dx8f3i1O+szbFUN+OZZFM9GBTpm3Uv8Vs2VEBlDYXmwKB8MvzZ3FaevgJ/6Ph3PqpVOnFJt/vDGSDVVFsYPHEXzd1CliuanV5FLdxGwWdqLEPUKnCvHPZO6FAooQihMExt3uIS98d4Uge648+fqgrmkFhyLc0RKZNnVcw== 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=mnZB93e09f/haVvZzulldiMhl1CPHu4jDVj71aa6Hfo=; b=A3TFoCuLs8rG9Z8Ftxw1bw8+9cdoVC9NNq59lMpKsOvXrqv4G/4UAbE/JZRv8AXT3rJe2P4QpRkA4+3cQBsVuQtftYNmfD0lTpgD9k9pMQ0lQQsRITLIqx/2APx+Wha9mhWEtQ+de29OmV0MuaLvuezDEULki1/6Ka4oNsbiUPU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB6037.namprd13.prod.outlook.com (2603:10b6:a03:3e2::9) by DS7PR13MB4703.namprd13.prod.outlook.com (2603:10b6:5:3a0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Tue, 22 Nov 2022 13:10:20 +0000 Received: from SJ0PR13MB6037.namprd13.prod.outlook.com ([fe80::9d7f:1fa0:af36:e57a]) by SJ0PR13MB6037.namprd13.prod.outlook.com ([fe80::9d7f:1fa0:af36:e57a%8]) with mapi id 15.20.5834.009; Tue, 22 Nov 2022 13:10:19 +0000 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: dev@dpdk.org Cc: oss-drivers@corigine.com, Jin Liu , Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH] net/nfp: update descriptors logic Date: Tue, 22 Nov 2022 14:09:48 +0100 Message-Id: <20221122130948.4100369-1-niklas.soderlund@corigine.com> X-Mailer: git-send-email 2.38.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::10) To SJ0PR13MB6037.namprd13.prod.outlook.com (2603:10b6:a03:3e2::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB6037:EE_|DS7PR13MB4703:EE_ X-MS-Office365-Filtering-Correlation-Id: f7d0b73f-87be-406b-25ea-08dacc8ae809 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2b0HrVavDKafbU+K4nXa4O7ya7Kw2lojafRbOttY3B+nAuf0aYKskH0zujOWqVGnxEr6UOw0iMNe0KORQN1Q5VEmI7s1TwjFMFcGwp4JThAzhhuDP3mufHVv5UaDUMRepa7C6jCu2f6/uITifEEbf9yTSkiUy5qS5pUmVQw7gUgPMCsBKdYuRlZD9F2234qnPd4xJa/A3cL6ikOgfFpBose+Pu42IgkomBoj5ydYhjOdnWjd6I343NkMr2aWHdBPCNVUJs77wqbTOiRZM/4EeleecZMwAUY3ZP6OQyjLHE+6NmD3dKouYIigwVQlayeiBlKWDclevzT6WpBQJuoyGO4aS7F1SMOt//irUuyxL5L+dpn2pViJclDVuq8F4tfG7WiKIgGb5ugn4mlktY6p+10K1y0Gkspvjw2eN97MFJQAEnpfTCOdKOiGebzuDIHb6YkxfWqG6fK9/yxDSdUswByEzxjwVlgRGSc2bmvo9eXOPEOtd+b1rNQKkyQzsOdeAsLhFRZvmzqOEQm6yWoCGmck9AMgcs2Gdie+nHR5xXP6pKL5eCQUjiN9Nadj5Iemx0gYa0KtdP0qq2FZGHDtne9mx8zFLDlEqF+iezHLJi9x8LNGz4pZvfV6u4pIWykEinY15fuGPcXhiNc5bhVY0T1SGBWyR3UEuzFYkshmn5DNjer/rC+h6uTt5EjUGkzPgHw4ZxFPSBcNZEFFPP4AtUNti0tKNBZVq+X9D0tAskk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB6037.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(346002)(376002)(366004)(39840400004)(396003)(451199015)(41300700001)(8936002)(30864003)(54906003)(316002)(66946007)(5660300002)(6916009)(66556008)(4326008)(66476007)(8676002)(86362001)(36756003)(6666004)(6506007)(83380400001)(478600001)(6486002)(26005)(2906002)(2616005)(1076003)(186003)(66574015)(6512007)(107886003)(38100700002)(38350700002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?STZHQmJpUHduMHdET2VOOUZDYjBCTmszdy9OMlkxTDlNTGJoZjdaRFFHa2pj?= =?utf-8?B?VXRLQVR6b2RVUDBMd0NsQmFycldlT3dlRnhNbGFTODFleU5CaEhnd3hjTzh3?= =?utf-8?B?dVlZbmdvd1JvWnJhbkUzK0d2WGNKc05rTE5XVmFDVU1PK0gxQ0Ftd3Z6S2dC?= =?utf-8?B?UGRBV2N3ZFZMQ2VzZmdXbXY1elBmNlVmL3JnS1ovclVpT21nNlpnLzJ6bFUz?= =?utf-8?B?Vk1YT0RJOE9JQzloMHRYVmQ3MVp0Q3JEbG9DcHFUMjRkbU1sckM2VEU5eEw2?= =?utf-8?B?a1ZEd2NOa0F3RlZQS3djZHBhRkRtTjlnOXhleldyTkN1UjFKc0s0WjZaUDFY?= =?utf-8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HRC9KUmcwdVlvV2hxNldsMnloR2l4WUt5S1M3UWt6ODZ0eEhtbEYyN2Fw?= =?utf-8?B?cFE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7d0b73f-87be-406b-25ea-08dacc8ae809 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB6037.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2022 13:10:19.7750 (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: 5Jvtkx6B53ddNwblFzLL/OtULPBzVZCD3Q+Fn8BYXVHeQDhOQCdxw2cXh42iKnUlgfL8qsmcTBrrKMZ0ElqR18w0s1yo98v4vvGhJEUr6A0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR13MB4703 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 From: Jin Liu The minimum value of TX/RX descriptors for NFP3800 card is not same with NFP4000 card, the minimum value of NFP4000 card is 256 while NFP3800 card is 512, add the minimum descriptor macro for NFP3800 card. Modify the logic of get descriptor value, assign the value of descriptor for the corresponding network card according to its type. In TX stage, firmware with NFD3 use one descriptor per packet while firmware with NFDk use two descriptors. In order to be consistent with the kernel driver, the number of descriptor of firmware with NFDk should be divided by 2. Signed-off-by: Jin Liu Reviewed-by: Chaoyong He Reviewed-by: Niklas Söderlund Signed-off-by: Niklas Söderlund --- drivers/net/nfp/nfp_common.c | 86 ++++++++++++++++++++++++++++++++++-- drivers/net/nfp/nfp_common.h | 6 +++ drivers/net/nfp/nfp_rxtx.c | 51 ++++++++++++++------- drivers/net/nfp/nfp_rxtx.h | 3 ++ 4 files changed, 127 insertions(+), 19 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 71711bfa228e..4defd6d93871 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -697,13 +697,91 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) return 0; } +int +nfp_net_rx_desc_limits(struct nfp_net_hw *hw, + uint16_t *min_rx_desc, + uint16_t *max_rx_desc) +{ + *max_rx_desc = NFP_NET_MAX_RX_DESC; + + switch (hw->device_id) { + case PCI_DEVICE_ID_NFP3800_PF_NIC: + case PCI_DEVICE_ID_NFP3800_VF_NIC: + *min_rx_desc = NFP3800_NET_MIN_RX_DESC; + return 0; + case PCI_DEVICE_ID_NFP4000_PF_NIC: + case PCI_DEVICE_ID_NFP6000_PF_NIC: + case PCI_DEVICE_ID_NFP6000_VF_NIC: + *min_rx_desc = NFP_NET_MIN_RX_DESC; + return 0; + default: + PMD_DRV_LOG(ERR, "Unknown NFP device id."); + return -EINVAL; + } +} + +int +nfp_net_tx_desc_limits(struct nfp_net_hw *hw, + uint16_t *min_tx_desc, + uint16_t *max_tx_desc) +{ + uint16_t tx_dpp; + + switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + case NFP_NET_CFG_VERSION_DP_NFD3: + tx_dpp = NFD3_TX_DESC_PER_SIMPLE_PKT; + break; + case NFP_NET_CFG_VERSION_DP_NFDK: + if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", + NFD_CFG_MAJOR_VERSION_of(hw->ver)); + return -EINVAL; + } + tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT; + break; + default: + PMD_DRV_LOG(ERR, "The version of firmware is not correct."); + return -EINVAL; + } + + *max_tx_desc = NFP_NET_MAX_TX_DESC / tx_dpp; + + switch (hw->device_id) { + case PCI_DEVICE_ID_NFP3800_PF_NIC: + case PCI_DEVICE_ID_NFP3800_VF_NIC: + *min_tx_desc = NFP3800_NET_MIN_TX_DESC / tx_dpp; + return 0; + case PCI_DEVICE_ID_NFP4000_PF_NIC: + case PCI_DEVICE_ID_NFP6000_PF_NIC: + case PCI_DEVICE_ID_NFP6000_VF_NIC: + *min_tx_desc = NFP_NET_MIN_TX_DESC / tx_dpp; + return 0; + default: + PMD_DRV_LOG(ERR, "Unknown NFP device id."); + return -EINVAL; + } +} + int nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { + int ret; + uint16_t min_rx_desc; + uint16_t max_rx_desc; + uint16_t min_tx_desc; + uint16_t max_tx_desc; struct nfp_net_hw *hw; hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + ret = nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); + if (ret != 0) + return ret; + + ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); + if (ret != 0) + return ret; + dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues; dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues; dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU; @@ -764,14 +842,14 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) }; dev_info->rx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = NFP_NET_MAX_RX_DESC, - .nb_min = NFP_NET_MIN_RX_DESC, + .nb_max = max_rx_desc, + .nb_min = min_rx_desc, .nb_align = NFP_ALIGN_RING_DESC, }; dev_info->tx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = NFP_NET_MAX_TX_DESC, - .nb_min = NFP_NET_MIN_TX_DESC, + .nb_max = max_tx_desc, + .nb_min = min_tx_desc, .nb_align = NFP_ALIGN_RING_DESC, .nb_seg_max = NFP_TX_MAX_SEG, .nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG, diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 36c19b47e4d5..a871e437e4d2 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -447,6 +447,12 @@ void nfp_net_close_rx_queue(struct rte_eth_dev *dev); void nfp_net_stop_tx_queue(struct rte_eth_dev *dev); void nfp_net_close_tx_queue(struct rte_eth_dev *dev); int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port); +int nfp_net_rx_desc_limits(struct nfp_net_hw *hw, + uint16_t *min_rx_desc, + uint16_t *max_rx_desc); +int nfp_net_tx_desc_limits(struct nfp_net_hw *hw, + uint16_t *min_tx_desc, + uint16_t *max_tx_desc); #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ (&((struct nfp_net_adapter *)adapter)->hw) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 01cffdfde0b4..0de7312e217d 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -439,6 +439,9 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) { + int ret; + uint16_t min_rx_desc; + uint16_t max_rx_desc; const struct rte_memzone *tz; struct nfp_net_rxq *rxq; struct nfp_net_hw *hw; @@ -448,11 +451,14 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); + ret = nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); + if (ret != 0) + return ret; + /* Validating number of descriptors */ rx_desc_sz = nb_desc * sizeof(struct nfp_net_rx_desc); if (rx_desc_sz % NFP_ALIGN_RING_DESC != 0 || - nb_desc > NFP_NET_MAX_RX_DESC || - nb_desc < NFP_NET_MIN_RX_DESC) { + nb_desc > max_rx_desc || nb_desc < min_rx_desc) { PMD_DRV_LOG(ERR, "Wrong nb_desc value"); return -EINVAL; } @@ -502,7 +508,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, */ tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, sizeof(struct nfp_net_rx_desc) * - NFP_NET_MAX_RX_DESC, NFP_MEMZONE_ALIGN, + max_rx_desc, NFP_MEMZONE_ALIGN, socket_id); if (tz == NULL) { @@ -628,6 +634,9 @@ nfp_net_nfd3_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) { + int ret; + uint16_t min_tx_desc; + uint16_t max_tx_desc; const struct rte_memzone *tz; struct nfp_net_txq *txq; uint16_t tx_free_thresh; @@ -638,11 +647,14 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, PMD_INIT_FUNC_TRACE(); + ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); + if (ret != 0) + return ret; + /* Validating number of descriptors */ tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfd3_tx_desc); - if (tx_desc_sz % NFP_ALIGN_RING_DESC != 0 || - nb_desc > NFP_NET_MAX_TX_DESC || - nb_desc < NFP_NET_MIN_TX_DESC) { + if ((NFD3_TX_DESC_PER_SIMPLE_PKT * tx_desc_sz) % NFP_ALIGN_RING_DESC != 0 || + nb_desc > max_tx_desc || nb_desc < min_tx_desc) { PMD_DRV_LOG(ERR, "Wrong nb_desc value"); return -EINVAL; } @@ -688,7 +700,8 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, */ tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, sizeof(struct nfp_net_nfd3_tx_desc) * - NFP_NET_MAX_TX_DESC, NFP_MEMZONE_ALIGN, + NFD3_TX_DESC_PER_SIMPLE_PKT * + max_tx_desc, NFP_MEMZONE_ALIGN, socket_id); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating tx dma"); @@ -697,7 +710,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, return -ENOMEM; } - txq->tx_count = nb_desc; + txq->tx_count = nb_desc * NFD3_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; @@ -716,7 +729,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, /* mbuf pointers array for referencing mbufs linked to TX descriptors */ txq->txbufs = rte_zmalloc_socket("txq->txbufs", - sizeof(*txq->txbufs) * nb_desc, + sizeof(*txq->txbufs) * txq->tx_count, RTE_CACHE_LINE_SIZE, socket_id); if (txq->txbufs == NULL) { nfp_net_tx_queue_release(dev, queue_idx); @@ -735,7 +748,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, * 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(nb_desc)); + nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count)); return 0; } @@ -760,7 +773,8 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk PMD_TX_LOG(DEBUG, "working for queue %u at pos %d and %u packets", txq->qidx, txq->wr_p, nb_pkts); - if ((nfp_net_nfd3_free_tx_desc(txq) < nb_pkts) || (nfp_net_nfd3_txq_full(txq))) + if (nfp_net_nfd3_free_tx_desc(txq) < NFD3_TX_DESC_PER_SIMPLE_PKT * nb_pkts || + nfp_net_nfd3_txq_full(txq)) nfp_net_tx_free_bufs(txq); free_descs = (uint16_t)nfp_net_nfd3_free_tx_desc(txq); @@ -879,6 +893,9 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { + int ret; + uint16_t min_tx_desc; + uint16_t max_tx_desc; const struct rte_memzone *tz; struct nfp_net_txq *txq; uint16_t tx_free_thresh; @@ -889,11 +906,15 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); + ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); + if (ret != 0) + return ret; + /* 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) { + 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 > max_tx_desc || nb_desc < min_tx_desc) { PMD_DRV_LOG(ERR, "Wrong nb_desc value"); return -EINVAL; } @@ -938,7 +959,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, 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, + max_tx_desc, NFP_MEMZONE_ALIGN, socket_id); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating tx dma"); diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index ced05fde908d..4f0de5e93227 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -31,9 +31,11 @@ */ #define NFP_NET_MAX_TX_DESC (32 * 1024) #define NFP_NET_MIN_TX_DESC 256 +#define NFP3800_NET_MIN_TX_DESC 512 #define NFP_NET_MAX_RX_DESC (32 * 1024) #define NFP_NET_MIN_RX_DESC 256 +#define NFP3800_NET_MIN_RX_DESC 512 /* Descriptor alignment */ #define NFP_ALIGN_RING_DESC 128 @@ -57,6 +59,7 @@ #define NFDK_DESC_TX_DMA_LEN_HEAD 0x0fff #define NFDK_DESC_TX_TYPE_HEAD 0xf000 #define NFDK_DESC_TX_DMA_LEN 0x3fff +#define NFD3_TX_DESC_PER_SIMPLE_PKT 1 #define NFDK_TX_DESC_PER_SIMPLE_PKT 2 #define NFDK_DESC_TX_TYPE_TSO 2 #define NFDK_DESC_TX_TYPE_SIMPLE 8 -- 2.38.1