net/bnxt: support hotplug
authorAjit Khaparde <ajit.khaparde@broadcom.com>
Mon, 26 Sep 2016 16:18:52 +0000 (11:18 -0500)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 30 Sep 2016 10:27:18 +0000 (12:27 +0200)
This patch adds support for port hotplug framework.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_cpr.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_filter.c
drivers/net/bnxt/bnxt_vnic.c

index 60c277a..e9f9741 100644 (file)
@@ -124,6 +124,9 @@ void bnxt_free_def_cp_ring(struct bnxt *bp)
 {
        struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
 
+       if (cpr == NULL)
+               return;
+
        bnxt_free_ring(cpr->cp_ring_struct);
        rte_free(cpr->cp_ring_struct);
        rte_free(cpr);
index ae0e683..427aa69 100644 (file)
@@ -478,7 +478,14 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
        bnxt_free_tx_mbufs(bp);
        bnxt_free_rx_mbufs(bp);
        bnxt_free_mem(bp);
-       rte_free(eth_dev->data->mac_addrs);
+       if (eth_dev->data->mac_addrs != NULL) {
+               rte_free(eth_dev->data->mac_addrs);
+               eth_dev->data->mac_addrs = NULL;
+       }
+       if (bp->grp_info != NULL) {
+               rte_free(bp->grp_info);
+               bp->grp_info = NULL;
+       }
 }
 
 /* Unload the driver, release resources */
@@ -1084,19 +1091,28 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
        struct bnxt *bp = eth_dev->data->dev_private;
        int rc;
 
-       if (eth_dev->data->mac_addrs)
+       if (eth_dev->data->mac_addrs != NULL) {
                rte_free(eth_dev->data->mac_addrs);
-       if (bp->grp_info)
+               eth_dev->data->mac_addrs = NULL;
+       }
+       if (bp->grp_info != NULL) {
                rte_free(bp->grp_info);
+               bp->grp_info = NULL;
+       }
        rc = bnxt_hwrm_func_driver_unregister(bp, 0);
        bnxt_free_hwrm_resources(bp);
+       eth_dev->dev_ops = NULL;
+       eth_dev->rx_pkt_burst = NULL;
+       eth_dev->tx_pkt_burst = NULL;
+
        return rc;
 }
 
 static struct eth_driver bnxt_rte_pmd = {
        .pci_drv = {
                    .id_table = bnxt_pci_id_map,
-                   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+                   .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
+                           RTE_PCI_DRV_DETACHABLE,
                    .probe = rte_eth_dev_pci_probe,
                    .remove = rte_eth_dev_pci_remove
                    },
index f03a1dc..df1042c 100644 (file)
@@ -118,6 +118,9 @@ void bnxt_free_filter_mem(struct bnxt *bp)
        uint16_t max_filters, i;
        int rc = 0;
 
+       if (bp->filter_info == NULL)
+               return;
+
        /* Ensure that all filters are freed */
        if (BNXT_PF(bp)) {
                struct bnxt_pf_info *pf = &bp->pf;
index c04c4c7..6297e87 100644 (file)
@@ -229,6 +229,9 @@ void bnxt_free_vnic_mem(struct bnxt *bp)
        struct bnxt_vnic_info *vnic;
        uint16_t max_vnics, i;
 
+       if (bp->vnic_info == NULL)
+               return;
+
        if (BNXT_PF(bp)) {
                struct bnxt_pf_info *pf = &bp->pf;