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 6CBA1A0093; Fri, 17 Jun 2022 11:35:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61E2A41141; Fri, 17 Jun 2022 11:35:15 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2097.outbound.protection.outlook.com [40.107.94.97]) by mails.dpdk.org (Postfix) with ESMTP id 3FBAD40698 for ; Fri, 17 Jun 2022 11:35:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9XlOVQJldad8eGRxOfM7eb9ixkSZ5m7G2FIkMicmej4NcLhyHeFeuVcvc4iA1XXyCeH05kR/g5Th/BGhOwr3WoQDoCcW9okipKR0UqnorW2HpohCxak2MPHEyECJPLOtid1jEWkJW3ARIHFgDZRclu4Ts7WwuSJqkq7x4xOKc6V+8acryOqbyWwU6RDFr2wQnrdHzBggAm/yiYFLoxaXk4n68I4l9AY7eNn9qteaNoWvbYC40AoFNqJVT6AgjCSmhbqg777uMkmPDXdH3b7MHW2R4wIdzb/cnvHyv3RkzfLkEaWgAch2GSTtREWyMqx9dxx6afFvex1K+eLFk3JgQ== 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=E1F0KhzKNLTITEtuMBBwGbCAeEgIHdkg/fCLINgmD14=; b=mtnfibjDiCuUXyUfl3tJKOeEdB+L3B0ofu0KDcfZi0Yp3Xb5FwmPBYN2kWjdK/ChAQ58GVwqcrEF3JCp5iDtlbLd2us0kob0ZlrohHkj2s6fXZjbOag/8L0Yt0bpzwQhpRe74DxIcfCtOg+qwPhh/1PKPbz7x6Jd8cv40iCZ5MSk7SKUSWYZ8DpvYuOL/foEINtR5UO8lcifGRPnx3KXXos7h3+C0FFCGBoKdXZEWIiM5Zj3BJGDm60vZ7ljw/oT+m50SqxTBsng9RjYcU/zrxN2hQyxTz9/sR2Kz+9qSqPibjyhmqM4LopTTQaWa6/qu49ayjUa6Kj5RPT9j6KQ4Q== 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=E1F0KhzKNLTITEtuMBBwGbCAeEgIHdkg/fCLINgmD14=; b=rNDdScKv/2a593LtWdRHNeCHa4cKuI5xHgmnnpuod8uhWI2oCSJDSo6384D1PMHCaDQS/u2qsGQ2u3Qa0vVRhqAyIbWKzDtyIDUpSP4jfF3eVzKNoMd1YhxVLdYpmYK22O9iCn+Lvde+rouNj+TljwCgHX5r9LpRtu+D4DT6tPM= 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 CO3PR13MB5671.namprd13.prod.outlook.com (2603:10b6:303:17a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.9; Fri, 17 Jun 2022 09:35:10 +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.009; Fri, 17 Jun 2022 09:35:10 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Chaoyong He Subject: [PATCH v3 01/13] net/nfp: change the coding style Date: Fri, 17 Jun 2022 11:34:32 +0200 Message-Id: <20220617093444.2004000-2-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220617093444.2004000-1-jin.liu@corigine.com> References: <20220616023939.1798769-1-jin.liu@corigine.com> <20220617093444.2004000-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0192.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::17) 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: 5df4cc50-0dd6-4fb5-6f26-08da5044ac35 X-MS-TrafficTypeDiagnostic: CO3PR13MB5671: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: OJ0NiJkBBt7dcLoE37N4dXZIGk15FVNN/wMoCCtP3qiQeC4tQgF0ZAl7r4yd0ILa3AwNuRsmqffsjp+dAL/BSJ3kUE2c6Wf9YqF5xfgVryDbgxDQeJU8WQ66iMna/zjpYwHp5Y1fnOPeymQUP5HMuLmx6Y/DEBWqDQ++zDuoXHYnHoOugLjI984CaCl1jNjgm6UZoMXxvfjV7zoMeSsKxzp8d5BtZ7O9f1a/Iy2BL8RuI+bOQ13YFR8TaAmGFYwOjsVI6YPE73qym5tYIY06pQ53DspgMZ++LjswRM8QFuLxETHdDXR1KNVhzfgjrhZF+xBlvU82pKwIB8JxHggYOCxiAJFGh8y+Q5j9Zw02nRHrBFBgfu+jIPAEpr+kMx2xQ+IjiW+ciycKiZpiY8SzKaEq/PIDIYrgEVkBqhP1H5E2VbOUuOnLv9A3CKO3ZZ1psWy6UXZVCjLc6hlevupupt274tgBb3Tk67RxSJo5jB93iLFbpKQRaBbb5pX6wXg2yd44hzyvTwbd8redfuROJBefH/T2rXuAyGS3ciJME+YfMkO7w4wrSC/xifYm9vcnsR9XAy29OxGAt9511fCktjOv8aYZo+3T4tGJXKU7de6BbFLWw58+CFYEQTaBe9UUQCguqPfT7MqDKyO/zPimZUVGfve/I98gk1kpiTJ+6LeTfqvjQcclxnxodE0U2OvfdfSErz21c/ePNCc5SoEWH6oVOtQN3Am/X+de0wYR0s1K6324lKi2AUWzPfAW6OxR 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)(346002)(136003)(366004)(396003)(39840400004)(66476007)(66556008)(26005)(8676002)(66574015)(6666004)(107886003)(66946007)(6506007)(6916009)(44832011)(30864003)(2906002)(316002)(4326008)(38350700002)(186003)(508600001)(54906003)(5660300002)(6486002)(6512007)(1076003)(8936002)(2616005)(36756003)(52116002)(83380400001)(86362001)(38100700002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YjA2RkdYVHVSNUV4ajNORnQxbUhUYjFyMEc1NjlxZ0NFZEpJVlZLOXlLTTBW?= =?utf-8?B?RWNjZGhCTXJueXRjaHNVOXdoVmc0Zm9XQ2dtcGQ4bzdhUVYwZXhaaEhNRUpz?= =?utf-8?B?bi9TcGxkbFpLMXQ2TW1rMWRia29wdndBR3BSNG1KS0RNRG5XbXJuZ2RDSkJ4?= =?utf-8?B?aExPME9vQ09GZzlRRHlKRlJvL09jZXZ4cU1KNEllNHk4dWhQS1J0YUZqWFRl?= =?utf-8?B?amN5SzM4Ymx5cDRlM1V1QjV2TlRCM0VEOVJqTUVyK1NFS0oxdWpzMG9jd0li?= =?utf-8?B?QUQ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?= =?utf-8?B?Rzd1clBWK2Q5Z0hvaTFXM0FYUHd3VzhVUHVzSTkxc3l4a0xwV1JJa3JJb0sr?= =?utf-8?B?Q0c0VjFoWkt6RXg4VlYzU3ZkdlU4OVZOa2F4Tk5Ibi9NUFl0OHJLVWt2RVg4?= =?utf-8?B?SDVCMzBlTFk2S1VXTk9ZOXFSTzZoTjJzQjFvWTNHblRvcUFpM20vTnlDbTRB?= =?utf-8?B?YTczK0FaWG1nYTg3NHpueFArOHRrbFFPNjZ6MFZqUnNCWXdkemR6UT09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5df4cc50-0dd6-4fb5-6f26-08da5044ac35 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 09:35:10.7277 (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: XZ8JoKpAHcpGKvMzmkR9IDnGg6uezAPCRzYEfSej6DJWaToQGkDZo+vrasU5sIqRF0SnYoo0cPGPf2zF/diPRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5671 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 Change the coding style of some logics, to make it more compatible with the DPDK coding style. Signed-off-by: Chaoyong He Signed-off-by: Jin Liu Signed-off-by: Niklas Söderlund --- drivers/net/nfp/nfp_ethdev.c | 149 ++++++++++++++++---------------- drivers/net/nfp/nfp_ethdev_vf.c | 8 +- 2 files changed, 77 insertions(+), 80 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 9166f65da3..eb0d92a98c 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -340,8 +340,7 @@ nfp_net_close(struct rte_eth_dev *dev) /* unregister callback func from eal lib */ rte_intr_callback_unregister(pci_dev->intr_handle, - nfp_net_dev_interrupt_handler, - (void *)dev); + nfp_net_dev_interrupt_handler, (void *)dev); /* * The ixgbe PMD disables the pcie master on the @@ -388,8 +387,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev) struct nfp_pf_dev *pf_dev; struct nfp_net_hw *hw; struct rte_ether_addr *tmp_ether_addr; - - uint64_t tx_bar_off = 0, rx_bar_off = 0; + uint64_t rx_bar_off = 0; + uint64_t tx_bar_off = 0; uint32_t start_q; int stride = 4; int port = 0; @@ -404,11 +403,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev) /* NFP can not handle DMA addresses requiring more than 40 bits */ if (rte_mem_check_dma_mask(40)) { - RTE_LOG(ERR, PMD, "device %s can not be used:", - pci_dev->device.name); - RTE_LOG(ERR, PMD, "\trestricted dma mask to 40 bits!\n"); + RTE_LOG(ERR, PMD, + "device %s can not be used: restricted dma mask to 40 bits!\n", + pci_dev->device.name); return -ENODEV; - }; + } port = ((struct nfp_net_hw *)eth_dev->data->dev_private)->idx; if (port < 0 || port > 7) { @@ -416,14 +415,14 @@ nfp_net_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - /* Use PF array of physical ports to get pointer to + /* + * Use PF array of physical ports to get pointer to * this specific port */ hw = pf_dev->ports[port]; PMD_INIT_LOG(DEBUG, "Working with physical port number: %d, " - "NFP internal port number: %d", - port, hw->nfp_idx); + "NFP internal port number: %d", port, hw->nfp_idx); eth_dev->dev_ops = &nfp_net_eth_dev_ops; eth_dev->rx_queue_count = nfp_net_rx_queue_count; @@ -456,13 +455,10 @@ nfp_net_init(struct rte_eth_dev *eth_dev) if (port == 0) { hw->ctrl_bar = pf_dev->ctrl_bar; } else { - if (!pf_dev->ctrl_bar) + if (pf_dev->ctrl_bar == NULL) 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); + /* 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); } PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); @@ -557,8 +553,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) tmp_ether_addr = (struct rte_ether_addr *)&hw->mac_addr; if (!rte_is_valid_assigned_ether_addr(tmp_ether_addr)) { - PMD_INIT_LOG(INFO, "Using random mac address for port %d", - port); + PMD_INIT_LOG(INFO, "Using random mac address for port %d", port); /* Using random mac addresses for VFs */ rte_eth_random_addr(&hw->mac_addr[0]); nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr); @@ -583,8 +578,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY) { /* Registering LSC interrupt handler */ rte_intr_callback_register(pci_dev->intr_handle, - nfp_net_dev_interrupt_handler, - (void *)eth_dev); + nfp_net_dev_interrupt_handler, (void *)eth_dev); /* Telling the firmware about the LSC interrupt entry */ nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX); /* Recording current stats counters values */ @@ -656,8 +650,10 @@ nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card) } static int -nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp, - struct nfp_eth_table *nfp_eth_table, struct nfp_hwinfo *hwinfo) +nfp_fw_setup(struct rte_pci_device *dev, + struct nfp_cpp *cpp, + struct nfp_eth_table *nfp_eth_table, + struct nfp_hwinfo *hwinfo) { struct nfp_nsp *nsp; const char *nfp_fw_model; @@ -675,12 +671,12 @@ nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp, if (nfp_eth_table->count == 0 || nfp_eth_table->count > 8) { PMD_DRV_LOG(ERR, "NFP ethernet table reports wrong ports: %u", - nfp_eth_table->count); + nfp_eth_table->count); return -EIO; } PMD_DRV_LOG(INFO, "NFP ethernet port table reports %u ports", - nfp_eth_table->count); + nfp_eth_table->count); PMD_DRV_LOG(INFO, "Port speed: %u", nfp_eth_table->ports[0].speed); @@ -689,7 +685,7 @@ nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp, nfp_eth_table->ports[0].speed / 1000); nsp = nfp_nsp_open(cpp); - if (!nsp) { + if (nsp == NULL) { PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle"); return -EIO; } @@ -701,19 +697,19 @@ nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp, return err; } -static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) +static int +nfp_init_phyports(struct nfp_pf_dev *pf_dev) { + int i; + int ret = 0; struct nfp_net_hw *hw; struct rte_eth_dev *eth_dev; - struct nfp_eth_table *nfp_eth_table = NULL; - int ret = 0; - int i; + struct nfp_eth_table *nfp_eth_table; nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp); - if (!nfp_eth_table) { + if (nfp_eth_table == NULL) { PMD_INIT_LOG(ERR, "Error reading NFP ethernet table"); - ret = -EIO; - goto error; + return -EIO; } /* Loop through all physical ports on PF */ @@ -726,7 +722,7 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) /* Allocate a eth_dev for this phyport */ eth_dev = rte_eth_dev_allocate(port_name); - if (!eth_dev) { + if (eth_dev == NULL) { ret = -ENODEV; goto port_cleanup; } @@ -734,8 +730,8 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) /* Allocate memory for this phyport */ eth_dev->data->dev_private = rte_zmalloc_socket(port_name, sizeof(struct nfp_net_hw), - RTE_CACHE_LINE_SIZE, numa_node); - if (!eth_dev->data->dev_private) { + RTE_CACHE_LINE_SIZE, numa_node); + if (eth_dev->data->dev_private == NULL) { ret = -ENOMEM; rte_eth_dev_release_port(eth_dev); goto port_cleanup; @@ -759,7 +755,6 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) * nfp_net_init */ ret = nfp_net_init(eth_dev); - if (ret) { ret = -ENODEV; goto port_cleanup; @@ -782,24 +777,25 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev) } eth_table_cleanup: free(nfp_eth_table); -error: + return ret; } -static int nfp_pf_init(struct rte_pci_device *pci_dev) +static int +nfp_pf_init(struct rte_pci_device *pci_dev) { - struct nfp_pf_dev *pf_dev = NULL; + int err; + int ret = 0; + int total_ports; struct nfp_cpp *cpp; + struct nfp_pf_dev *pf_dev; struct nfp_hwinfo *hwinfo; - struct nfp_rtsym_table *sym_tbl; - struct nfp_eth_table *nfp_eth_table = NULL; char name[RTE_ETH_NAME_MAX_LEN]; - int total_ports; - int ret = -ENODEV; - int err; + struct nfp_rtsym_table *sym_tbl; + struct nfp_eth_table *nfp_eth_table; - if (!pci_dev) - return ret; + if (pci_dev == NULL) + return -ENODEV; /* * When device bound to UIO, the device could be used, by mistake, @@ -813,21 +809,21 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) else cpp = nfp_cpp_from_device_name(pci_dev, 1); - if (!cpp) { + if (cpp == NULL) { PMD_INIT_LOG(ERR, "A CPP handle can not be obtained"); ret = -EIO; goto error; } hwinfo = nfp_hwinfo_read(cpp); - if (!hwinfo) { + if (hwinfo == NULL) { PMD_INIT_LOG(ERR, "Error reading hwinfo table"); ret = -EIO; goto error; } nfp_eth_table = nfp_eth_read_ports(cpp); - if (!nfp_eth_table) { + if (nfp_eth_table == NULL) { PMD_INIT_LOG(ERR, "Error reading NFP ethernet table"); ret = -EIO; goto hwinfo_cleanup; @@ -841,7 +837,7 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) /* Now the symbol table should be there */ sym_tbl = nfp_rtsym_table_read(cpp); - if (!sym_tbl) { + if (sym_tbl == NULL) { PMD_INIT_LOG(ERR, "Something is wrong with the firmware" " symbol table"); ret = -EIO; @@ -865,7 +861,7 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) /* Allocate memory for the PF "device" */ snprintf(name, sizeof(name), "nfp_pf%d", 0); pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0); - if (!pf_dev) { + if (pf_dev == NULL) { ret = -ENOMEM; goto sym_tbl_cleanup; } @@ -883,9 +879,8 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) /* Map the symbol table */ pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_bar0", - pf_dev->total_phyports * 32768, - &pf_dev->ctrl_area); - if (!pf_dev->ctrl_bar) { + pf_dev->total_phyports * 32768, &pf_dev->ctrl_area); + if (pf_dev->ctrl_bar == NULL) { PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _pf0_net_ctrl_bar"); ret = -EIO; goto pf_cleanup; @@ -895,10 +890,9 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) /* configure access to tx/rx vNIC BARs */ pf_dev->hw_queues = nfp_cpp_map_area(pf_dev->cpp, 0, 0, - NFP_PCIE_QUEUE(0), - NFP_QCP_QUEUE_AREA_SZ, - &pf_dev->hwqueues_area); - if (!pf_dev->hw_queues) { + NFP_PCIE_QUEUE(0), NFP_QCP_QUEUE_AREA_SZ, + &pf_dev->hwqueues_area); + if (pf_dev->hw_queues == NULL) { PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for net.qc"); ret = -EIO; goto ctrl_area_cleanup; @@ -906,7 +900,8 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) PMD_INIT_LOG(DEBUG, "tx/rx bar address: 0x%p", pf_dev->hw_queues); - /* Initialize and prep physical ports now + /* + * Initialize and prep physical ports now * This will loop through all physical ports */ ret = nfp_init_phyports(pf_dev); @@ -941,15 +936,16 @@ static int nfp_pf_init(struct rte_pci_device *pci_dev) * is no need to initialise the PF again. Only minimal work is required * here */ -static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) +static int +nfp_pf_secondary_init(struct rte_pci_device *pci_dev) { - struct nfp_cpp *cpp; - struct nfp_rtsym_table *sym_tbl; - int total_ports; int i; int err; + int total_ports; + struct nfp_cpp *cpp; + struct nfp_rtsym_table *sym_tbl; - if (!pci_dev) + if (pci_dev == NULL) return -ENODEV; /* @@ -964,7 +960,7 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) else cpp = nfp_cpp_from_device_name(pci_dev, 1); - if (!cpp) { + if (cpp == NULL) { PMD_INIT_LOG(ERR, "A CPP handle can not be obtained"); return -EIO; } @@ -974,7 +970,7 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) * here so we have to read the number of ports from firmware */ sym_tbl = nfp_rtsym_table_read(cpp); - if (!sym_tbl) { + if (sym_tbl == NULL) { PMD_INIT_LOG(ERR, "Something is wrong with the firmware" " symbol table"); return -EIO; @@ -989,13 +985,11 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) snprintf(port_name, sizeof(port_name), "%s_port%d", pci_dev->device.name, i); - PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", - port_name); + PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", port_name); eth_dev = rte_eth_dev_attach_secondary(port_name); - if (!eth_dev) { + if (eth_dev == NULL) { RTE_LOG(ERR, EAL, - "secondary process attach failed, " - "ethdev doesn't exist"); + "secondary process attach failed, ethdev doesn't exist"); return -ENODEV; } eth_dev->process_private = cpp; @@ -1012,8 +1006,9 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) return 0; } -static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *dev) +static int +nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *dev) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) return nfp_pf_init(dev); @@ -1035,7 +1030,8 @@ static const struct rte_pci_id pci_id_nfp_pf_net_map[] = { }, }; -static int nfp_pci_uninit(struct rte_eth_dev *eth_dev) +static int +nfp_pci_uninit(struct rte_eth_dev *eth_dev) { struct rte_pci_device *pci_dev; uint16_t port_id; @@ -1052,7 +1048,8 @@ static int nfp_pci_uninit(struct rte_eth_dev *eth_dev) return -ENOTSUP; } -static int eth_nfp_pci_remove(struct rte_pci_device *pci_dev) +static int +eth_nfp_pci_remove(struct rte_pci_device *pci_dev) { return rte_eth_dev_pci_generic_remove(pci_dev, nfp_pci_uninit); } diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index 0034d68ea6..381a25c03c 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -296,11 +296,11 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) /* NFP can not handle DMA addresses requiring more than 40 bits */ if (rte_mem_check_dma_mask(40)) { - RTE_LOG(ERR, PMD, "device %s can not be used:", - pci_dev->device.name); - RTE_LOG(ERR, PMD, "\trestricted dma mask to 40 bits!\n"); + RTE_LOG(ERR, PMD, + "device %s can not be used: restricted dma mask to 40 bits!\n", + pci_dev->device.name); return -ENODEV; - }; + } hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); -- 2.27.0