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 3A5E4426D6; Sat, 7 Oct 2023 04:35:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A72440EE4; Sat, 7 Oct 2023 04:34:21 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by mails.dpdk.org (Postfix) with ESMTP id 54E5440EDB for ; Sat, 7 Oct 2023 04:34:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GKhjBX4ZT4naJAnNZIURtyl7lidgLyd3K8wZYLPVoV5EtRzA1J9mLkZnS1TsA2rJhMwQ2lxV/tBLY8JqpX3Pr+9LkAGYXzS98wLWgYR/SD9SLPEbk6j3tqcGmB538aZhRWWgprTWa8uLVrXfZQr2xyqKQTkUdbXIfS4/BX58RAjQTuNrUk9D7cjO8xKxjIvEB21/vAv9zITzZ1cbAwAA6Lq+E1L6GOEEPhFrBqFHpN7i+VbVGCD3PuI3CdlgP1lAMvILBO72+LFXTjvy8QuXkNOFDz3BB+CYn+GV1VzqGQxtmLZ/6LWuPVoxS2OdlCUbqpJqktqXU2MrheChuj+wUw== 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=8Fm/Nd/R9LF1A86NB+N8NZau7/mOAkZe6dpi7iWj7TQ=; b=KkIgiWyHXlVc0lCrvzsPSBHmQ6i85jD7ddTmZz5haIFAEaBcBjc94SipZVJhgiCkNHRb4XwONs7iNuX+eFWVzmcUFWx731Ny2OB5FU3RDw8tq4mSFsw7xhj7WWhXnTWJdMu7EOXEtgdMGdDQXqHXdyFVk++Mr52aO4DOC2DvT7awOcfneF2nMxP0u0gscV1MCamQ9S7YXE4hM7r4kUJQG2fD8Tw9EXbZagfEnvnxFhKEhPaGxT3FWoUeatlqfDNGZsplb8EeylMlWOGDtKtLnvcN7PWcWHaVS2lASuNoZWjjQ81Qmszlq2y3lMVgDmnVJTm4Ft9T3w3GZoTf/0A6XA== 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=8Fm/Nd/R9LF1A86NB+N8NZau7/mOAkZe6dpi7iWj7TQ=; b=wEQuGLDEaySgnU6X14uJNA2kAH7hAOlSkTkrqRNvm7T/41WquaOidqIeV2vlaH8XFNibY9Zxc0KnWzUQOw6up6dNPYkOKA++A/AX68ZP0twnyaFYkktTs79SOtrOD2xIyRC8lOIXiB8HdIE8t98QHjl0msZqeDuraF67rssjNFY= 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 SA0PR13MB3936.namprd13.prod.outlook.com (2603:10b6:806:97::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.38; Sat, 7 Oct 2023 02:34:17 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::28c0:63e2:ecd1:9314]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::28c0:63e2:ecd1:9314%4]) with mapi id 15.20.6813.027; Sat, 7 Oct 2023 02:34:17 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 10/11] net/nfp: adjust logic to make it more readable Date: Sat, 7 Oct 2023 10:33:38 +0800 Message-Id: <20231007023339.1546659-11-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231007023339.1546659-1-chaoyong.he@corigine.com> References: <20231007023339.1546659-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0212.namprd03.prod.outlook.com (2603:10b6:a03:39f::7) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA0PR13MB3936:EE_ X-MS-Office365-Filtering-Correlation-Id: 757f9eae-4c1f-4ae2-d899-08dbc6dde744 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Drqdpqu7mLT2SsLLDk3nH4Mvwbu69Djt8MXZE6/HqSdg6G1rZbBUzW3/n4wYPmm7e+iI1O2RTtKvEvCmkYIf/VJSIRmrBRjf8t7HGC3P7pJ87FAUwPIH8NaFQLHCobOWtVj3cf7j9n+kWEV/2JMZOz+NthYBSxhNiWQVwQ7tOj3WqU2O2DowbRyAPjxn6G/RU09SKUzoDC3jsDBLB9nad1nfviHpEPJfWHqWBsoxyw0zwD5h9R2Ixk3E1kM6Z8SAbzGlZVjVLSjePafk1Hp/nHKC5k9B7uJx7oYlJcAzL20iiRQbRPWKgk2Q9Hv24Vgj3++GSXi2hnjVrwnLhGoZMdZv5zPGYlldSsrT1uSgCRFmYqT5F2ZCL2JOXe3BZDbGs+xuS+MZkWYU8rVFuYNKyuMuJtYAM+c+sLsFs4taSruauVzjBi+SqmBmj6Aksxct9EdEfH6tcPdrWFUYL7436jkthIL2wOdhQycBVdmVQIPvjJgSXZi0OkiB2AW47SxkN4IoDKe88giikTtxzMWVMgLub2CRajr+Vj9tYETcXnLASADy4rq6tjPPBS3ehmsKiEEKE70gKXZyccDzKM5JJnp+NfFP6fDgWp/k5lt9Xc2fGX2ZTWqOTfWx/NLOJUoq+7s4m/9S9esL4ktn9iGnLVrr7FK+gpVuKtpXCcdUt0w= 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)(366004)(376002)(346002)(396003)(39830400003)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6666004)(6506007)(52116002)(6512007)(478600001)(6486002)(26005)(107886003)(1076003)(6916009)(316002)(30864003)(41300700001)(2906002)(44832011)(66476007)(8936002)(5660300002)(4326008)(54906003)(66556008)(66946007)(36756003)(8676002)(86362001)(38350700002)(38100700002)(2616005)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FhC55s2ikjcRCbPcuqsBnanxCjrO84JU0Kzmo7SEou97CCBBLmGOEEG8i4U4?= =?us-ascii?Q?MIpnn9m62VmEtPQkyIPZqTHNRy1wm0IUhyVcqN8ZblRhtfq0Tpop5wglYcZ7?= =?us-ascii?Q?mEn7Q3cjzePXkKXi8Dh3Qjmfq43NncrUivwAgC/i2U2CwVCiBLppY5omhBQ0?= =?us-ascii?Q?X8rreLAFZAr7sLbQYFdVb6mlU8hzyFwE4ofXAgyTXc8DiYHOlwe2dCwCIZSa?= =?us-ascii?Q?xDPgz2rt//z5pXTGB/L4DJnKs9ZxWnsZZ0YUTZ2IyprP3DZKvXRtnrOfC0jl?= =?us-ascii?Q?zEWH32FfVdCo7mRLK5488b6VYhOLJz0m//gE2O1IruUYlU/Mf1A4zwe1h0g8?= =?us-ascii?Q?+bsu1/XseEGdPoYv7Y3mtGYya3jjF0ZH8VaWVXGeN1lbMZtWpMUXDO0B1xTk?= =?us-ascii?Q?nB/PKqdNdeLmExwXs5wes33VHXTmy0dJqO/4k1akxhyB1Vn/Zfq/AF3jYAkD?= =?us-ascii?Q?xUme0rdQZXtJErPhmzxEqGjz30zZyOoARMnNiN/HQRJ+y9cNpcMDlQVzrXcI?= =?us-ascii?Q?lSLT0Zdc7P/orZiOH04hkqyNz5z/Jvo+o6On3pBjcDPPutA3Q2TlSDNTvqjo?= =?us-ascii?Q?uWgtkhKv9MdjdEBCZ/ZvnTHiJspWE7LxvxnR7kMtqJUK1qmpjzNf8GEFIDw9?= =?us-ascii?Q?LAiYfs6iB40HEY0X2LYxWbclSShSTXG7fFnWbWhyhiivP6ph2aDp01iq605P?= =?us-ascii?Q?etNJnJDSb0IllMZ2+CLPu8TG6J8DoeeFdFuQzmNNcG5PlFUor1Fg5Ixe/jv4?= =?us-ascii?Q?EZG92OwDsYTvyfiPxTPQP8FombCg4KTErRJ8x9XjIF1jkrGGyICJV1gYdLvG?= =?us-ascii?Q?8G5UUBK0RY0jwp5kbxiqaIB+60pQaR2l6b4Y97cBvB77pVBYk7b0wl2mitJ1?= =?us-ascii?Q?DPKC5aan3QawZlqzVvARA9tPi39gPupD7D/0vGH2t7Qs6ivPyMJIIQrlHcWv?= =?us-ascii?Q?d1qOpHqx01ZZIEu14/VRYKETbEyJY9LKMZu+LzqeBkEM4pOfGMDlrnvBWIrv?= =?us-ascii?Q?O9NG/dW2mxoYkUgQxVsVGUBE2IedQ4gfymMtGLsw7TXAFOjEg09Hydn7G+pc?= =?us-ascii?Q?MBJnHEp8iTJkTtKC2h4a7TnQsFsFbZfNO6yduMlpb4yNSRWra05ZIPHUzzus?= =?us-ascii?Q?+yHzLZVKB3/XQIjjV3iUPcA3Ceqz6O2M71GhkBY+N5ToiVkSKOF9vXvAh+ip?= =?us-ascii?Q?IuIbRMtNAKFZzaa1bmN+THspQhU39JBc52a0hQU6UGW9aDsx/Se3uw+fRcgJ?= =?us-ascii?Q?6/uh/ycrHdUmwWAPmg/s9akLw0Tw7060UrHisqzRmLVCpzmIsGAAtYw0akrG?= =?us-ascii?Q?wBQQptI5MujZhTBKd9Xz/irbUuoOXr1HtBUMPG0grVGg79lUs7JFXQQr+S8Y?= =?us-ascii?Q?2Ld9EMgqqNkWwyc+NzOAuchuXqJu1Kw2aInYSupj6GzX67i4nA0SLh1wwE01?= =?us-ascii?Q?r+5DIS2nZNINL7n50WecIKXdk7kHvRmB9tjFU5w0xOMo6MdvavP02yrNo9tv?= =?us-ascii?Q?pzwNChG/nuweGWpsK+2CnRQTpHMtEsWH6bMvwqzGRm9NMkL5M4LktylVnKYX?= =?us-ascii?Q?X0MJsdbl6G67ztCyr6YdJCdcNL3zS2a3jXbTDEnxGFAhDSQtSGPc2asDakE7?= =?us-ascii?Q?AA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 757f9eae-4c1f-4ae2-d899-08dbc6dde744 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2023 02:34:17.5803 (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: tOH7eiNVYQc/GtMwcbDIGx3bnssrS4/FuFeYkUGpaxrzCEz7JoCRzpM8QtEXJLXJ6jWKg9XdegJeDQ75uMzWcdS1e8FRcuHa+oW1kY709NA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR13MB3936 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 Adjust some logic to make it easier to understand. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_common.c | 83 +++++++++++++++++--------------- drivers/net/nfp/nfp_cpp_bridge.c | 5 +- drivers/net/nfp/nfp_ctrl.h | 2 - drivers/net/nfp/nfp_ethdev.c | 23 ++++----- drivers/net/nfp/nfp_ethdev_vf.c | 15 +++--- drivers/net/nfp/nfp_rxtx.c | 2 +- 6 files changed, 61 insertions(+), 69 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 3409ee8cb8..f6cd506dd6 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -467,19 +467,19 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { uint16_t i; struct nfp_net_hw *hw; - uint64_t enabled_queues = 0; + uint64_t enabled_queues; hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); /* Enabling the required TX queues in the device */ + enabled_queues = 0; for (i = 0; i < dev->data->nb_tx_queues; i++) enabled_queues |= (1 << i); nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues); - enabled_queues = 0; - /* Enabling the required RX queues in the device */ + enabled_queues = 0; for (i = 0; i < dev->data->nb_rx_queues; i++) enabled_queues |= (1 << i); @@ -619,33 +619,33 @@ uint32_t nfp_check_offloads(struct rte_eth_dev *dev) { uint32_t ctrl = 0; + uint64_t rx_offload; + uint64_t tx_offload; struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct rte_eth_txmode *txmode; hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - txmode = &dev_conf->txmode; + rx_offload = dev_conf->rxmode.offloads; + tx_offload = dev_conf->txmode.offloads; - if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) { + if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) { if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0) ctrl |= NFP_NET_CFG_CTRL_RXCSUM; } - if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0) + if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0) nfp_net_enbable_rxvlan_cap(hw, &ctrl); - if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) { + if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) { if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0) ctrl |= NFP_NET_CFG_CTRL_RXQINQ; } hw->mtu = dev->data->mtu; - if ((txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) { + if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) { if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2; else if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN) != 0) @@ -661,14 +661,14 @@ nfp_check_offloads(struct rte_eth_dev *dev) ctrl |= NFP_NET_CFG_CTRL_L2MC; /* TX checksum offload */ - if ((txmode->offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) != 0 || - (txmode->offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) != 0 || - (txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) != 0) + if ((tx_offload & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) != 0 || + (tx_offload & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) != 0 || + (tx_offload & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) != 0) ctrl |= NFP_NET_CFG_CTRL_TXCSUM; /* LSO offload */ - if ((txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 || - (txmode->offloads & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) { + if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 || + (tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) { if ((hw->cap & NFP_NET_CFG_CTRL_LSO) != 0) ctrl |= NFP_NET_CFG_CTRL_LSO; else @@ -676,7 +676,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) } /* RX gather */ - if ((txmode->offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) != 0) + if ((tx_offload & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) != 0) ctrl |= NFP_NET_CFG_CTRL_GATHER; return ctrl; @@ -766,11 +766,10 @@ nfp_net_link_update(struct rte_eth_dev *dev, hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - /* Read link status */ - nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS); - memset(&link, 0, sizeof(struct rte_eth_link)); + /* Read link status */ + nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS); if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) link.link_status = RTE_ETH_LINK_UP; @@ -828,6 +827,9 @@ nfp_net_stats_get(struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct rte_eth_stats nfp_dev_stats; + if (stats == NULL) + return -EINVAL; + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -892,11 +894,8 @@ nfp_net_stats_get(struct rte_eth_dev *dev, nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS); nfp_dev_stats.imissed -= hw->eth_stats_base.imissed; - if (stats != NULL) { - memcpy(stats, &nfp_dev_stats, sizeof(*stats)); - return 0; - } - return -EINVAL; + memcpy(stats, &nfp_dev_stats, sizeof(*stats)); + return 0; } /* @@ -1379,13 +1378,14 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); pci_dev = RTE_ETH_DEV_TO_PCI(dev); if (rte_intr_type_get(pci_dev->intr_handle) != RTE_INTR_HANDLE_UIO) base = 1; /* Make sure all updates are written before un-masking */ rte_wmb(); + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1399,14 +1399,16 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); pci_dev = RTE_ETH_DEV_TO_PCI(dev); if (rte_intr_type_get(pci_dev->intr_handle) != RTE_INTR_HANDLE_UIO) base = 1; /* Make sure all updates are written before un-masking */ rte_wmb(); - nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), 0x1); + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); + return 0; } @@ -1445,13 +1447,13 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); pci_dev = RTE_ETH_DEV_TO_PCI(dev); + /* Make sure all updates are written before un-masking */ + rte_wmb(); + if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) { /* If MSI-X auto-masking is used, clear the entry */ - rte_wmb(); rte_intr_ack(pci_dev->intr_handle); } else { - /* Make sure all updates are written before un-masking */ - rte_wmb(); nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX), NFP_NET_CFG_ICR_UNMASKED); } @@ -1548,19 +1550,18 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int ret; uint32_t update; uint32_t new_ctrl; + uint64_t rx_offload; struct nfp_net_hw *hw; uint32_t rxvlan_ctrl = 0; - struct rte_eth_conf *dev_conf; hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - dev_conf = &dev->data->dev_conf; + rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; - nfp_net_enbable_rxvlan_cap(hw, &rxvlan_ctrl); - /* VLAN stripping setting */ if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) { - if ((dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0) + nfp_net_enbable_rxvlan_cap(hw, &rxvlan_ctrl); + if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0) new_ctrl |= rxvlan_ctrl; else new_ctrl &= ~rxvlan_ctrl; @@ -1568,7 +1569,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, /* QinQ stripping setting */ if ((mask & RTE_ETH_QINQ_STRIP_MASK) != 0) { - if ((dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) + if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) new_ctrl |= NFP_NET_CFG_CTRL_RXQINQ; else new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ; @@ -1580,10 +1581,12 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, update = NFP_NET_CFG_UPDATE_GEN; ret = nfp_net_reconfig(hw, new_ctrl, update); - if (ret == 0) - hw->ctrl = new_ctrl; + if (ret != 0) + return ret; - return ret; + hw->ctrl = new_ctrl; + + return 0; } static int diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c index 080070f58b..f37de7060a 100644 --- a/drivers/net/nfp/nfp_cpp_bridge.c +++ b/drivers/net/nfp/nfp_cpp_bridge.c @@ -22,9 +22,6 @@ #define NFP_IOCTL_CPP_IDENTIFICATION _IOW(NFP_IOCTL, 0x8f, uint32_t) /* Prototypes */ -static int nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp); -static int nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp); -static int nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp *cpp); static int nfp_cpp_bridge_service_func(void *args); int @@ -438,7 +435,7 @@ nfp_cpp_bridge_service_func(void *args) return -EIO; } - while (1) { + for (;;) { ret = recv(datafd, &op, 4, 0); if (ret <= 0) { PMD_CPP_LOG(DEBUG, "%s: socket close", __func__); diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h index 71fe125420..1012b37b1f 100644 --- a/drivers/net/nfp/nfp_ctrl.h +++ b/drivers/net/nfp/nfp_ctrl.h @@ -442,8 +442,6 @@ struct nfp_net_fw_ver { #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS6 (NFP_MAC_STATS_BASE + 0x1f0) #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS7 (NFP_MAC_STATS_BASE + 0x1f8) -#define NFP_PF_CSR_SLICE_SIZE (32 * 1024) - /* * General use mailbox area (0x1800 - 0x19ff) * 4B used for update command and 4B return code followed by diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 0493548c81..362fd2b601 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -80,7 +80,7 @@ nfp_net_start(struct rte_eth_dev *dev) * Better not to share LSC with RX interrupts. * Unregistering LSC interrupt handler */ - rte_intr_callback_unregister(pci_dev->intr_handle, + rte_intr_callback_unregister(intr_handle, nfp_net_dev_interrupt_handler, (void *)dev); if (dev->data->nb_rx_queues > 1) { @@ -525,7 +525,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) return -ENODEV; /* Use port offset in pf ctrl_bar for this ports control bar */ - hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_PF_CSR_SLICE_SIZE); + hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ); hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar + (port * NFP_MAC_STATS_SIZE); } @@ -743,8 +743,7 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, const struct nfp_dev_info *dev_info) { uint8_t i; - int ret; - int err = 0; + int ret = 0; uint32_t total_vnics; struct nfp_net_hw *hw; unsigned int numa_node; @@ -765,8 +764,8 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, pf_dev->app_fw_priv = app_fw_nic; /* Read the number of vNIC's created for the PF */ - total_vnics = nfp_rtsym_read_le(pf_dev->sym_tbl, "nfd_cfg_pf0_num_ports", &err); - if (err != 0 || total_vnics == 0 || total_vnics > 8) { + total_vnics = nfp_rtsym_read_le(pf_dev->sym_tbl, "nfd_cfg_pf0_num_ports", &ret); + if (ret != 0 || total_vnics == 0 || total_vnics > 8) { PMD_INIT_LOG(ERR, "nfd_cfg_pf0_num_ports symbol with wrong value"); ret = -ENODEV; goto app_cleanup; @@ -874,8 +873,7 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, static int nfp_pf_init(struct rte_pci_device *pci_dev) { - int ret; - int err = 0; + int ret = 0; uint64_t addr; uint32_t cpp_id; struct nfp_cpp *cpp; @@ -943,8 +941,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) } /* Read the app ID of the firmware loaded */ - app_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); - if (err != 0) { + app_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &ret); + if (ret != 0) { PMD_INIT_LOG(ERR, "Couldn't read app_fw_id from fw"); ret = -EIO; goto sym_tbl_cleanup; @@ -1080,7 +1078,6 @@ nfp_secondary_init_app_fw_nic(struct rte_pci_device *pci_dev, static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) { - int err = 0; int ret = 0; struct nfp_cpp *cpp; enum nfp_app_fw_id app_fw_id; @@ -1124,8 +1121,8 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) } /* Read the app ID of the firmware loaded */ - app_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); - if (err != 0) { + app_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &ret); + if (ret != 0) { PMD_INIT_LOG(ERR, "Couldn't read app_fw_id from fw"); goto sym_tbl_cleanup; } diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index af0689832a..b6ebbc1ea5 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -39,8 +39,6 @@ nfp_netvf_start(struct rte_eth_dev *dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - /* Disabling queues just in case... */ nfp_net_disable_queues(dev); @@ -54,7 +52,7 @@ nfp_netvf_start(struct rte_eth_dev *dev) * Better not to share LSC with RX interrupts. * Unregistering LSC interrupt handler */ - rte_intr_callback_unregister(pci_dev->intr_handle, + rte_intr_callback_unregister(intr_handle, nfp_net_dev_interrupt_handler, (void *)dev); if (dev->data->nb_rx_queues > 1) { @@ -77,6 +75,7 @@ nfp_netvf_start(struct rte_eth_dev *dev) new_ctrl = nfp_check_offloads(dev); /* Writing configuration parameters in the device */ + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); nfp_net_params_setup(hw); dev_conf = &dev->data->dev_conf; @@ -244,15 +243,15 @@ static int nfp_netvf_init(struct rte_eth_dev *eth_dev) { int err; + uint16_t port; uint32_t start_q; - uint16_t port = 0; struct nfp_net_hw *hw; uint64_t tx_bar_off = 0; uint64_t rx_bar_off = 0; struct rte_pci_device *pci_dev; const struct nfp_dev_info *dev_info; - struct rte_ether_addr *tmp_ether_addr; + port = eth_dev->data->port_id; pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); dev_info = nfp_dev_info_get(pci_dev->id.device_id); @@ -325,9 +324,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) } nfp_netvf_read_mac(hw); - - tmp_ether_addr = &hw->mac_addr; - if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) { + if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) { PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port); /* Using random mac addresses for VFs */ rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]); @@ -344,7 +341,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(INFO, "port %hu VendorID=%#x DeviceID=%#x " "mac=" RTE_ETHER_ADDR_PRT_FMT, - eth_dev->data->port_id, pci_dev->id.vendor_id, + port, pci_dev->id.vendor_id, pci_dev->id.device_id, RTE_ETHER_ADDR_BYTES(&hw->mac_addr)); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 4632837c0e..e11f617f9a 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -284,7 +284,7 @@ nfp_net_parse_chained_meta(uint8_t *meta_base, meta->vlan[meta->vlan_layer].tci = vlan_info & NFP_NET_META_VLAN_MASK; meta->vlan[meta->vlan_layer].tpid = NFP_NET_META_TPID(vlan_info); - ++meta->vlan_layer; + meta->vlan_layer++; break; case NFP_NET_META_IPSEC: meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset); -- 2.39.1