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 B450843220; Sat, 28 Oct 2023 08:17:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09A3E41143; Sat, 28 Oct 2023 08:16:53 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2135.outbound.protection.outlook.com [40.107.92.135]) by mails.dpdk.org (Postfix) with ESMTP id 7C2D740E2D for ; Sat, 28 Oct 2023 08:16:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/YOkWdKxpQ/pED72m6thQFcnj3tbCL0HhNcTCxWLzG+jGj5vEJ8zih9LYadO+XwQRymyuOe1KnCNbwGgveFQazVpRAAEm3+ZTEP8XKLjkrNW07VQmEHnX1rCl3zgEWlVNbIaAgUbMBB35JbX5FndnOcrGlWAOlTFV5ApqaQOXWfGY3oruJCln9zRrDTDqCEvtYIJ8FZQ5HcPpfPRNYx/l+JL9pOHCDugAsNx1GkQnkXB074sqCD6c4ckcHJeOa1y8/u+PBZIqyIcGSkTycpy02Sm91K9KCcufcnbhC8xy6txQlEqNYnpcQyBvEsUgfoaIOcyUq8w/08v+v8JkbHPQ== 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=Cvqlu2R+tOwcHb+qvQF9JkT9KaKwZojpLEiw459iCJI=; b=VfNmkEPWAd9MTkd97xCEXSyzYmkJTtKiGiw/GhupM6sZVZK/F3uDvUILeH/NoPyZuUaNoFMYkEmB8mJ9LwDG+avhxCAkNnzQkoMq3FSFHGVEwoUEGf3QNHfPh/CAxEJcKkhgeul4R+gC9ftZbcOj75aC6b0rsWl2zKQ7F1cNXin40ZFL2h3Q+kIid//BfsB+S7ogmOouBJg7XY/CdTmuuOv/Joev2TfoSSi6ddmiXbX9YNz4+2OG885PCZAjHHCbbuUdaoDd0FiTr6lg1XTiv3AIE3Exa9y4XuFfMRAqlaxfVja3AksG85rjf6tEZa6G/sEQX4qXalC/tVQV1oQkmA== 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=Cvqlu2R+tOwcHb+qvQF9JkT9KaKwZojpLEiw459iCJI=; b=O+qZDU7nthWVi2zgYxf7WGDas/3J+5epakxhzdFsEqz5EJYBn0YA/jNKSMMI38xAX6XkypuUK4UHJ/sWLd969iOZURJpZZvVwYL0aYyMDMmS2BzdhMJ0FKPiIk74z7jGfgJaldHkMzzdCYX1ncTMQjakpaWElPv5cED2/hEw7RQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH7PR13MB6268.namprd13.prod.outlook.com (2603:10b6:510:24f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22; Sat, 28 Oct 2023 06:16:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b%6]) with mapi id 15.20.6933.022; Sat, 28 Oct 2023 06:16:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Peng Zhang Subject: [PATCH 11/11] net/nfp: remove the redundancy logic of representor port Date: Sat, 28 Oct 2023 14:15:58 +0800 Message-Id: <20231028061558.1842855-12-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231028061558.1842855-1-chaoyong.he@corigine.com> References: <20231028061558.1842855-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0246.namprd03.prod.outlook.com (2603:10b6:a03:3a0::11) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6268:EE_ X-MS-Office365-Filtering-Correlation-Id: 494f0153-ca74-4864-4743-08dbd77d76aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6qKsNDd3FZ032PWBMtHiUONK/FZKqt/azDyJlFgkXtFMW43rTZ55Wh1FEcIyvXTDj023bIyDZdrr5nSR93cCsfMrGbWfde7mHxxjfmxQjZvjpvS31hFoxgVVsYT2JwxZmcFoK/Tsto63IO8pTDLm1XpUfUKldUcMd50pQfBZKlWMqP5G+NI/mHUUEtHIx0TknzQ0gU4cmKFEceEItM2PBCEPORgkcHhXfHB8AqWBXEW05phQHx36n2Zx+fIQYUNQnwq8h0jp0b2ElHwk9ypK72WPV9efEqOIdd6B8MH7BRo8foIZOwT0h6L71pGPtEARNNr7uGSBJhABgeHw52L5F3Nyiktkzai9RZ8HPVqLnk3WtQH8K5p51pP1OskuRXZcluRcCGKxqx+pHXTIlOzYL0aqmE4sIv75CnYUss1NNuFkMFseZRdkTe472odcJH27TYIHotcsyeytbjeWBLxgiHqvsE1m/0zKgX2p6DeCv8WV27vWSLqw/9M2s2RKTZyeE4cLYgGMSmmvA68YLsWeAisIM4IH7AR5vRk8d8PDezRe8NWo0iTDfzfWsFGdBmfyXVioLMxCdgtoEXCX3TXdVgCoc3oF5e3Qu3Wpohp8tLc3PtwWSNJ+4tvEIfPH22qyNT80/kDjejo34Z2cwmvkCSvufiwd0j+Xa8A5p7mI05k= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(39830400003)(366004)(346002)(376002)(136003)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(2906002)(38100700002)(30864003)(83380400001)(1076003)(107886003)(5660300002)(2616005)(86362001)(6512007)(41300700001)(44832011)(36756003)(38350700005)(66476007)(316002)(6916009)(66946007)(54906003)(66556008)(52116002)(6666004)(6506007)(6486002)(8676002)(26005)(478600001)(4326008)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EHaiB/XgMcFoUIzpS5CPdUlwTMmtccuHpNYvGWJWnK+Vp4I+L4vFSgaM2fdE?= =?us-ascii?Q?k+XQUttT9nIqG9Js1iUoVMgZgNxOIHU3INdWuuF+gnrGsP9LkjbauWTFmPNs?= =?us-ascii?Q?v/4EPovByFobmv8pFcM2QSv4If6wafAPJl11g37V6rb6j7CIuEhVwo5GiKx+?= =?us-ascii?Q?SxhZXQ7i/K3kx4bz9lSbo5pwLeOKaMq3d1WmoIYIo/DmuYH9EeG5TYPIjwVn?= =?us-ascii?Q?ghOhxSQWVRXHziHWHPCXksNbfl5FW2wMBpxqLfkP6Z+4oP/671xNmv9hZGSD?= =?us-ascii?Q?OnaSf4QJdVkEe6LgeWCuqgxZYa8hFbWuqOiw7Kd6D4oaoV06mYD7vw/aVGHV?= =?us-ascii?Q?juH8PH9ktlwN92nYS9BKFCAb1dmmv16rLmkV32yBhB9oUDMoFiwwpB1WAkGe?= =?us-ascii?Q?YYRGLJ3sqseqXLPhEFDtdAK94081m9sSWdZhMlpSMhCp8DLEzwY/9D7fLpRA?= =?us-ascii?Q?ggImZ8VhaszpvtdCCcHGBihX3uhW1SeGqxSSHaOMTVdbbAJkjy/+EuuGHlNQ?= =?us-ascii?Q?vNVfyT6GpGysqZ6EZCKM+MvJ53E7ALZK/enyC7i/f0y4KTpfzsolutVGGGrH?= =?us-ascii?Q?zf4PD/oS66guwqSfxhRTBMAtHxOJQjpqNhgKWzfGJVrbdy3fxs2+ocsiHTw/?= =?us-ascii?Q?ND/m+TMSBDKjWH5GiRQ43bSLUIymOBD/Y6L6lqIlskj/wn5PMi6nFlxZ73/f?= =?us-ascii?Q?qHvhDirp1am/bJK+yP5uq7/1WrK374VYMqutcxe265+/Rd4tIOQG+nA7v9J6?= =?us-ascii?Q?TCbO+S4kk0X6bEU10AoQ+Q5ZqMam3h9IijhjX6HyzLEQn9dp1vvLomPyARwK?= =?us-ascii?Q?0iC2J3sGNs0NFL21hX/Bg4r56p+Iwa/lbG8fy1zdWX5szopM6m8vri98+rp3?= =?us-ascii?Q?7NZ9Xbi5S1nnrsP68FSDlEMHHZplRbpFDKqIZnDW4Ofr0pH9gma5rrg0e8Qa?= =?us-ascii?Q?ULceG0ouC7m4msayE1uqLJap6kcr3jOHMEH3F4X2vUIX52c+AzolBItyPzu7?= =?us-ascii?Q?0VEWU4k0mgQOoRdQ2XCjcdObo6IzW+IMGP6z9wy58zLAr4R0Ysv2yAcSvBuX?= =?us-ascii?Q?15A0Cpv/1Er38klFc4Pr9NRJ4zmLOcdhCn9xn3XDqWz6acFa2/T1HAZ321PG?= =?us-ascii?Q?JD2+zMHx7FrGWCgDN3rkSfgBFeqQ499xGSCDqqxFL4sL0MO3lDC/eEd5efHL?= =?us-ascii?Q?GX976G9ZsG52attAM08VKk7ru5fHRcjgO02DssGWTECT9tavRSqk4XiWP/c8?= =?us-ascii?Q?vGcLR0irA3AEGv2ir1pWhPKtZf5MC/BSjSbMIcxotP3EvIff8Bz3mkfMiBPX?= =?us-ascii?Q?JqbpE+eeOSb2Fp6D+Vsl3ca/E/JXl+TIf1kbm2fhf7I0yHdewBAkhcF6+FDg?= =?us-ascii?Q?bDec+bzQuv5ZS82tlXruq0elJHlN/qiwalxxI0MTAyTXA2ZBI+ZesA0q//fK?= =?us-ascii?Q?2VdOrzyFZnBHwihlkTGwmiMCQnFyfavcKs+WO9B068lwEGrdbIGURJBPfJsd?= =?us-ascii?Q?QHeeK2PPH4Zg49FPNxF28wrRanfm5fFdOTH5wpO5At5LEWb3mLluRKn4FSmv?= =?us-ascii?Q?37ge6FPNwajuj/hOOVtCpZfEt7oJcJJf76Mnf1Y80xjrH83MlNImWiUzGjuI?= =?us-ascii?Q?AA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 494f0153-ca74-4864-4743-08dbd77d76aa X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2023 06:16:46.9675 (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: kehBcLoxkp9UgTb0qPPa24YcZ3CQS8qVfptdJtXfNjuXR6ZH2BBtZVPXx7FCYHl5u9o3uQ0unXSk3e7TkzPg8Uf4haNNfc2Zx7BqCO9+ZI8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6268 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 Using the helper function, we can remove some redundancy logic of representor port by reusing the functions in common module. Signed-off-by: Chaoyong He Reviewed-by: Peng Zhang --- drivers/net/nfp/flower/nfp_flower.c | 47 +--- drivers/net/nfp/flower/nfp_flower.h | 1 - .../net/nfp/flower/nfp_flower_representor.c | 253 +----------------- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 28 +- drivers/net/nfp/nfp_net_common.c | 128 +++++---- drivers/net/nfp/nfp_net_common.h | 6 +- drivers/net/nfp/nfp_rxtx.c | 4 +- 9 files changed, 94 insertions(+), 377 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 0727e7fd9f..f2e6eb6a6f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -48,11 +48,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) nfp_net_params_setup(net_hw); update |= NFP_NET_CFG_UPDATE_RSS; - - if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0) - new_ctrl |= NFP_NET_CFG_CTRL_RSS2; - else - new_ctrl |= NFP_NET_CFG_CTRL_RSS; + new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap); /* Enable device */ new_ctrl |= NFP_NET_CFG_CTRL_ENABLE; @@ -62,8 +58,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0) new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG; - nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl); - /* If an error when reconfig we avoid to change hw state */ ret = nfp_reconfig(hw, new_ctrl, update); if (ret != 0) { @@ -88,43 +82,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) return 0; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -int -nfp_flower_pf_stop(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_hw *hw; - struct nfp_net_txq *this_tx_q; - struct nfp_net_rxq *this_rx_q; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Reset and stop device. The device can not be restarted. */ static int nfp_flower_pf_close(struct rte_eth_dev *dev) @@ -188,7 +145,7 @@ static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_configure = nfp_net_configure, .dev_start = nfp_flower_pf_start, - .dev_stop = nfp_flower_pf_stop, + .dev_stop = nfp_net_stop, .dev_close = nfp_flower_pf_close, }; diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index a989c4a8b8..220b714018 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -113,7 +113,6 @@ bool nfp_flower_pf_dispatch_pkts(struct nfp_net_hw *hw, uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); int nfp_flower_pf_start(struct rte_eth_dev *dev); -int nfp_flower_pf_stop(struct rte_eth_dev *dev); uint32_t nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower, struct rte_mbuf *mbuf, uint32_t port_id); diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index b52c6f514a..0f0e63aae0 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -18,232 +18,23 @@ enum nfp_repr_type { NFP_REPR_TYPE_MAX, /*<< Number of representor types */ }; -static int -nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev, - uint16_t queue_idx, - uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mp) -{ - struct nfp_net_hw *hw; - struct nfp_net_rxq *rxq; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - /* Allocating rx queue data structure */ - rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct nfp_net_rxq), - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq == NULL) - return -ENOMEM; - - dev->data->rx_queues[queue_idx] = rxq; - - /* Hw queues mapping based on firmware configuration */ - rxq->qidx = queue_idx; - rxq->fl_qcidx = queue_idx * hw->stride_rx; - rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx); - - /* - * Tracking mbuf size for detecting a potential mbuf overflow due to - * RX offset. - */ - rxq->mem_pool = mp; - rxq->mbuf_size = rxq->mem_pool->elt_size; - rxq->mbuf_size -= (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM); - hw->flbufsz = rxq->mbuf_size; - - rxq->rx_count = nb_desc; - rxq->port_id = dev->data->port_id; - rxq->rx_free_thresh = rx_conf->rx_free_thresh; - - /* - * Allocate RX 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, "rx_ring", queue_idx, - sizeof(struct nfp_net_rx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating rx dma"); - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - /* Saving physical and virtual addresses for the RX ring */ - rxq->dma = (uint64_t)tz->iova; - rxq->rxds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to RX descriptors */ - rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs", - sizeof(*rxq->rxbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq->rxbufs == NULL) { - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_rx_queue(rxq); - rxq->hw = hw; - - /* - * Telling the HW about the physical address of the RX ring and number - * of descriptors in log2 format. - */ - nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - -static int -nfp_pf_repr_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) -{ - struct nfp_net_hw *hw; - struct nfp_net_txq *txq; - uint16_t tx_free_thresh; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - tx_free_thresh = (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh : - DEFAULT_TX_FREE_THRESH; - if (tx_free_thresh > nb_desc) - return -EINVAL; - - /* 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; - } - - dev->data->tx_queues[queue_idx] = txq; - - /* - * 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_nfd3_tx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating tx dma"); - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - txq->tx_count = nb_desc; - txq->tx_free_thresh = tx_free_thresh; - - /* 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->txds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to TX descriptors */ - txq->txbufs = rte_zmalloc_socket("txq->txbufs", - sizeof(*txq->txbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (txq->txbufs == NULL) { - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_tx_queue(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->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - static int nfp_flower_repr_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { int ret; - uint32_t i; uint32_t nn_link_status; struct nfp_net_hw *pf_hw; struct rte_eth_link *link; - struct nfp_eth_table *nfp_eth_table; struct nfp_flower_representor *repr; - static const uint32_t ls_to_ethtool[] = { - [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_1G] = RTE_ETH_SPEED_NUM_1G, - [NFP_NET_CFG_STS_LINK_RATE_10G] = RTE_ETH_SPEED_NUM_10G, - [NFP_NET_CFG_STS_LINK_RATE_25G] = RTE_ETH_SPEED_NUM_25G, - [NFP_NET_CFG_STS_LINK_RATE_40G] = RTE_ETH_SPEED_NUM_40G, - [NFP_NET_CFG_STS_LINK_RATE_50G] = RTE_ETH_SPEED_NUM_50G, - [NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G, - }; - repr = dev->data->dev_private; link = &repr->link; - link->link_speed = RTE_ETH_SPEED_NUM_NONE; - pf_hw = repr->app_fw_flower->pf_hw; - if (link->link_status == RTE_ETH_LINK_UP) { - if (pf_hw->pf_dev != NULL) { - nfp_eth_table = pf_hw->pf_dev->nfp_eth_table; - if (nfp_eth_table != NULL) { - uint32_t speed = nfp_eth_table->ports[pf_hw->idx].speed; - for (i = 0; i < RTE_DIM(ls_to_ethtool); i++) { - if (ls_to_ethtool[i] == speed) { - link->link_speed = speed; - break; - } - } - } - } else { - nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; - - if (nn_link_status < RTE_DIM(ls_to_ethtool)) - link->link_speed = ls_to_ethtool[nn_link_status]; - } - } + pf_hw = repr->app_fw_flower->pf_hw; + nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - ret = rte_eth_linkstatus_set(dev, link); - if (ret == 0) { - if (link->link_status) - PMD_DRV_LOG(INFO, "NIC Link is Up"); - else - PMD_DRV_LOG(INFO, "NIC Link is Down"); - } + ret = nfp_net_link_update_common(dev, pf_hw, link, nn_link_status); return ret; } @@ -275,30 +66,6 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev, return 0; } -static int -nfp_flower_repr_dev_configure(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *pf_hw; - struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - pf_hw = repr->app_fw_flower->pf_hw; - - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - - /* Checking MTU set */ - if (rxmode->mtu > pf_hw->flbufsz) { - PMD_DRV_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported", - rxmode->mtu, pf_hw->flbufsz); - return -ERANGE; - } - - return 0; -} - static int nfp_flower_repr_dev_start(struct rte_eth_dev *dev) { @@ -528,11 +295,11 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_pf_start, - .dev_configure = nfp_flower_repr_dev_configure, - .dev_stop = nfp_flower_pf_stop, + .dev_configure = nfp_net_configure, + .dev_stop = nfp_net_stop, - .rx_queue_setup = nfp_pf_repr_rx_queue_setup, - .tx_queue_setup = nfp_pf_repr_tx_queue_setup, + .rx_queue_setup = nfp_net_rx_queue_setup, + .tx_queue_setup = nfp_net_tx_queue_setup, .link_update = nfp_flower_repr_link_update, @@ -543,14 +310,14 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, }; static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_repr_dev_start, - .dev_configure = nfp_flower_repr_dev_configure, + .dev_configure = nfp_net_configure, .dev_stop = nfp_flower_repr_dev_stop, .rx_queue_setup = nfp_flower_repr_rx_queue_setup, @@ -565,7 +332,7 @@ static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, .flow_ops_get = nfp_net_flow_ops_get, .mtr_ops_get = nfp_net_mtr_ops_get, diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index 3f9909c6e0..ff9b10f046 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -377,7 +377,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_free_thresh; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index fe87ea3e25..1f330b7bb6 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -454,7 +454,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_txq *txq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index c4a36027b9..69050e03f5 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -51,7 +51,6 @@ nfp_net_start(struct rte_eth_dev *dev) uint32_t ctrl_extend = 0; struct nfp_net_hw *net_hw; struct nfp_pf_dev *pf_dev; - struct rte_eth_conf *dev_conf; struct rte_eth_rxmode *rxmode; struct nfp_app_fw_nic *app_fw_nic; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -113,9 +112,7 @@ nfp_net_start(struct rte_eth_dev *dev) /* Writing configuration parameters in the device */ nfp_net_params_setup(net_hw); - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - + rxmode = &dev->data->dev_conf.rxmode; if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) { nfp_net_rss_config_default(dev); update |= NFP_NET_CFG_UPDATE_RSS; @@ -197,29 +194,6 @@ nfp_net_start(struct rte_eth_dev *dev) return ret; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -static int -nfp_net_stop(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - - hw = dev->data->dev_private; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - nfp_net_stop_tx_queue(dev); - nfp_net_stop_rx_queue(dev); - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Set the link up. */ static int nfp_net_set_link_up(struct rte_eth_dev *dev) diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 6abd91965c..13dd952754 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -581,43 +581,27 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) return 0; } -/* - * Return 0 means link status changed, -1 means not changed - * - * Wait to complete is needed as it can take up to 9 seconds to get the Link - * status. - */ int -nfp_net_link_update(struct rte_eth_dev *dev, - __rte_unused int wait_to_complete) +nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status) { int ret; uint32_t i; - struct nfp_net_hw *hw; uint32_t nn_link_status; - struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = nfp_net_get_hw(dev); - - memset(&link, 0, sizeof(struct rte_eth_link)); + link->link_speed = RTE_ETH_SPEED_NUM_NONE; - /* Read link status */ - nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); - if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) - link.link_status = RTE_ETH_LINK_UP; - - link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - - if (link.link_status == RTE_ETH_LINK_UP) { + if (link->link_status == RTE_ETH_LINK_UP) { if (hw->pf_dev != NULL) { nfp_eth_table = hw->pf_dev->nfp_eth_table; if (nfp_eth_table != NULL) { uint32_t speed = nfp_eth_table->ports[hw->idx].speed; for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) { if (nfp_net_link_speed_nfp2rte[i] == speed) { - link.link_speed = speed; + link->link_speed = speed; break; } } @@ -627,21 +611,52 @@ nfp_net_link_update(struct rte_eth_dev *dev, * Shift and mask nn_link_status so that it is effectively the value * at offset NFP_NET_CFG_STS_NSP_LINK_RATE. */ - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & + nn_link_status = (link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & NFP_NET_CFG_STS_LINK_RATE_MASK; if (nn_link_status < RTE_DIM(nfp_net_link_speed_nfp2rte)) - link.link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; + link->link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; } } - ret = rte_eth_linkstatus_set(dev, &link); + ret = rte_eth_linkstatus_set(dev, link); if (ret == 0) { - if (link.link_status != 0) + if (link->link_status != 0) PMD_DRV_LOG(INFO, "NIC Link is Up"); else PMD_DRV_LOG(INFO, "NIC Link is Down"); } + return ret; +} + +/* + * Return 0 means link status changed, -1 means not changed + * + * Wait to complete is needed as it can take up to 9 seconds to get the Link + * status. + */ +int +nfp_net_link_update(struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +{ + int ret; + struct nfp_net_hw *hw; + uint32_t nn_link_status; + struct rte_eth_link link; + + hw = nfp_net_get_hw(dev); + + memset(&link, 0, sizeof(struct rte_eth_link)); + + /* Read link status */ + nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); + if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) + link.link_status = RTE_ETH_LINK_UP; + + link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; + + ret = nfp_net_link_update_common(dev, hw, &link, nn_link_status); + /* * Notify the port to update the speed value in the CTRL BAR from NSP. * Not applicable for VFs as the associated PF is still attached to the @@ -1996,11 +2011,16 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (fw_size < FW_VER_LEN) return FW_VER_LEN; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); - snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", + + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, hw->ver.major, hw->ver.minor); + } else { + snprintf(vnic_version, FW_VER_LEN, "*"); + } nfp_net_get_nsp_info(hw, nsp_version); nfp_net_get_mip_name(hw, mip_name); @@ -2012,33 +2032,6 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, return 0; } -int -nfp_repr_firmware_version_get(struct rte_eth_dev *dev, - char *fw_version, - size_t fw_size) -{ - struct nfp_net_hw *hw; - char mip_name[FW_VER_LEN]; - char app_name[FW_VER_LEN]; - char nsp_version[FW_VER_LEN]; - struct nfp_flower_representor *repr; - - if (fw_size < FW_VER_LEN) - return FW_VER_LEN; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_get_nsp_info(hw, nsp_version); - nfp_net_get_mip_name(hw, mip_name); - nfp_net_get_app_name(hw, app_name); - - snprintf(fw_version, FW_VER_LEN, "* %s %s %s", - nsp_version, mip_name, app_name); - - return 0; -} - bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) { @@ -2059,3 +2052,26 @@ nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) return false; } + +/* Disable rx and tx functions to allow for reconfiguring. */ +int +nfp_net_stop(struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + hw = nfp_net_get_hw(dev); + + nfp_net_disable_queues(dev); + + /* Clear queues */ + nfp_net_stop_tx_queue(dev); + nfp_net_stop_rx_queue(dev); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + /* Configure the physical port down */ + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); + else + nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); + + return 0; +} diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index e242251bc2..af8f8d15ae 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -178,6 +178,10 @@ int nfp_configure_rx_interrupt(struct rte_eth_dev *dev, uint32_t nfp_check_offloads(struct rte_eth_dev *dev); int nfp_net_promisc_enable(struct rte_eth_dev *dev); int nfp_net_promisc_disable(struct rte_eth_dev *dev); +int nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status); int nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); @@ -235,9 +239,9 @@ int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); void nfp_net_init_metadata_format(struct nfp_net_hw *hw); void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); -int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); +int nfp_net_stop(struct rte_eth_dev *dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index be1ac32c73..b2a9ba6875 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -840,7 +840,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_rxq *rxq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); @@ -1067,7 +1067,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, -- 2.39.1