net/ionic: complete release on close
authorAndrew Boyer <aboyer@pensando.io>
Wed, 16 Dec 2020 21:12:54 +0000 (13:12 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 13 Jan 2021 17:51:58 +0000 (18:51 +0100)
ionic_dev_close() is responsible for destroying the ethdev, lif, and
adapter. eth_ionic_dev_remove() calls ionic_dev_close().

Remove-on-close is now required behavior for a PMD.
Remove the UNMAINTAINED flag.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
MAINTAINERS
drivers/net/ionic/ionic_ethdev.c
drivers/net/ionic/ionic_lif.c
drivers/net/ionic/ionic_lif.h

index 6787b15..76ed473 100644 (file)
@@ -841,7 +841,7 @@ F: doc/guides/nics/pfe.rst
 F: drivers/net/pfe/
 F: doc/guides/nics/features/pfe.ini
 
-Pensando ionic - UNMAINTAINED
+Pensando ionic
 M: Andrew Boyer <aboyer@pensando.io>
 F: drivers/net/ionic/
 F: doc/guides/nics/ionic.rst
index 54d7a6c..7ab32a0 100644 (file)
@@ -955,6 +955,8 @@ ionic_dev_stop(struct rte_eth_dev *eth_dev)
        return err;
 }
 
+static void ionic_unconfigure_intr(struct ionic_adapter *adapter);
+
 /*
  * Reset and stop device.
  */
@@ -962,6 +964,7 @@ static int
 ionic_dev_close(struct rte_eth_dev *eth_dev)
 {
        struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
+       struct ionic_adapter *adapter = lif->adapter;
        int err;
 
        IONIC_PRINT_CALL();
@@ -974,11 +977,17 @@ ionic_dev_close(struct rte_eth_dev *eth_dev)
                return -1;
        }
 
-       err = eth_ionic_dev_uninit(eth_dev);
-       if (err) {
-               IONIC_PRINT(ERR, "Cannot destroy LIF: %d", err);
-               return -1;
-       }
+       ionic_lif_free_queues(lif);
+
+       IONIC_PRINT(NOTICE, "Removing device %s", eth_dev->device->name);
+       ionic_unconfigure_intr(adapter);
+
+       rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit);
+
+       ionic_port_reset(adapter);
+       ionic_reset(adapter);
+
+       rte_free(adapter);
 
        return 0;
 }
@@ -1270,29 +1279,20 @@ err:
 }
 
 static int
-eth_ionic_pci_remove(struct rte_pci_device *pci_dev __rte_unused)
+eth_ionic_pci_remove(struct rte_pci_device *pci_dev)
 {
        char name[RTE_ETH_NAME_MAX_LEN];
-       struct ionic_adapter *adapter = NULL;
        struct rte_eth_dev *eth_dev;
-       struct ionic_lif *lif;
 
        /* Adapter lookup is using the eth_dev name */
        snprintf(name, sizeof(name), "%s_lif", pci_dev->device.name);
 
        eth_dev = rte_eth_dev_allocated(name);
-       if (eth_dev) {
-               lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
-               adapter = lif->adapter;
-       }
-
-       if (adapter) {
-               ionic_unconfigure_intr(adapter);
-
-               rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit);
-
-               rte_free(adapter);
-       }
+       if (eth_dev)
+               ionic_dev_close(eth_dev);
+       else
+               IONIC_PRINT(DEBUG, "Cannot find device %s",
+                       pci_dev->device.name);
 
        return 0;
 }
index 4b5221b..9b11e63 100644 (file)
@@ -920,6 +920,21 @@ ionic_lif_free(struct ionic_lif *lif)
        }
 }
 
+void
+ionic_lif_free_queues(struct ionic_lif *lif)
+{
+       uint32_t i;
+
+       for (i = 0; i < lif->ntxqcqs; i++) {
+               ionic_dev_tx_queue_release(lif->eth_dev->data->tx_queues[i]);
+               lif->eth_dev->data->tx_queues[i] = NULL;
+       }
+       for (i = 0; i < lif->nrxqcqs; i++) {
+               ionic_dev_rx_queue_release(lif->eth_dev->data->rx_queues[i]);
+               lif->eth_dev->data->rx_queues[i] = NULL;
+       }
+}
+
 int
 ionic_lif_rss_config(struct ionic_lif *lif,
                const uint16_t types, const uint8_t *key, const uint32_t *indir)
index c1d15dc..cc0e4f0 100644 (file)
@@ -121,6 +121,7 @@ int ionic_lifs_size(struct ionic_adapter *ionic);
 
 int ionic_lif_alloc(struct ionic_lif *lif);
 void ionic_lif_free(struct ionic_lif *lif);
+void ionic_lif_free_queues(struct ionic_lif *lif);
 
 int ionic_lif_init(struct ionic_lif *lif);
 void ionic_lif_deinit(struct ionic_lif *lif);