Calling nfp_net_init() is only done for the corenic firmware flavor
and it is guaranteed to always be called from the primary process,
so the explicit check for RTE_PROC_PRIMARY can be dropped.

The calling graph of nfp_net_init() already guaranteed the free of
resources when it fail, so remove the necessary free logics inside it.

While at it remove the unused member is_phyport from struct nfp_net_hw.

Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderl...@corigine.com>
---
 drivers/net/nfp/nfp_common.h |  1 -
 drivers/net/nfp/nfp_ethdev.c | 40 +++++++++++-----------------------------
 2 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 2aaf1d6..b28ebc9 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -238,7 +238,6 @@ struct nfp_net_hw {
        uint8_t idx;
        /* Internal port number as seen from NFP */
        uint8_t nfp_idx;
-       bool    is_phyport;
 
        union eth_table_entry *eth_table;
 
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3c4b0ac..2c5607c 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -417,7 +417,6 @@
        uint32_t start_q;
        int stride = 4;
        int port = 0;
-       int err;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -452,10 +451,6 @@
        PMD_INIT_LOG(DEBUG, "Working with physical port number: %d, "
                        "NFP internal port number: %d", port, hw->nfp_idx);
 
-       /* For secondary processes, the primary has done all the work */
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
-
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
        hw->device_id = pci_dev->id.device_id;
@@ -506,8 +501,7 @@
                break;
        default:
                PMD_DRV_LOG(ERR, "nfp_net: no device ID matching");
-               err = -ENODEV;
-               goto dev_err_ctrl_map;
+               return -ENODEV;
        }
 
        PMD_INIT_LOG(DEBUG, "tx_bar_off: 0x%" PRIx64 "", tx_bar_off);
@@ -573,8 +567,7 @@
                                               RTE_ETHER_ADDR_LEN, 0);
        if (eth_dev->data->mac_addrs == NULL) {
                PMD_INIT_LOG(ERR, "Failed to space for MAC address");
-               err = -ENOMEM;
-               goto dev_err_queues_map;
+               return -ENOMEM;
        }
 
        nfp_net_pf_read_mac(app_nic, port);
@@ -604,24 +597,15 @@
                     hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2],
                     hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]);
 
-       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);
-               /* 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 */
-               nfp_net_stats_reset(eth_dev);
-       }
+       /* Registering LSC interrupt handler */
+       rte_intr_callback_register(pci_dev->intr_handle,
+                       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 */
+       nfp_net_stats_reset(eth_dev);
 
        return 0;
-
-dev_err_queues_map:
-               nfp_cpp_area_free(hw->hwqueues_area);
-dev_err_ctrl_map:
-               nfp_cpp_area_free(hw->ctrl_area);
-
-       return err;
 }
 
 #define DEFAULT_FW_PATH       "/lib/firmware/netronome"
@@ -818,7 +802,6 @@
                hw->eth_dev = eth_dev;
                hw->idx = i;
                hw->nfp_idx = nfp_eth_table->ports[i].index;
-               hw->is_phyport = true;
 
                eth_dev->device = &pf_dev->pci_dev->device;
 
@@ -884,8 +867,7 @@
 
        if (cpp == NULL) {
                PMD_INIT_LOG(ERR, "A CPP handle can not be obtained");
-               ret = -EIO;
-               goto error;
+               return -EIO;
        }
 
        hwinfo = nfp_hwinfo_read(cpp);
@@ -1005,7 +987,7 @@
        free(hwinfo);
 cpp_cleanup:
        nfp_cpp_free(cpp);
-error:
+
        return ret;
 }
 
-- 
1.8.3.1

Reply via email to