ethdev: close device
[dpdk.git] / lib / librte_ether / rte_ethdev.h
index cce1a53..cea230e 100644 (file)
@@ -1451,6 +1451,7 @@ struct rte_eth_dev {
         * received packets before passing them to the driver for transmission.
         */
        struct rte_eth_rxtx_callback **pre_tx_burst_cbs;
+       uint8_t attached; /**< Flag indicating the port is attached */
 };
 
 struct rte_eth_dev_sriov {
@@ -1515,7 +1516,11 @@ extern struct rte_eth_dev rte_eth_devices[];
  * Get the total number of Ethernet devices that have been successfully
  * initialized by the [matching] Ethernet driver during the PCI probing phase.
  * All devices whose port identifier is in the range
- * [0,  rte_eth_dev_count() - 1] can be operated on by network applications.
+ * [0,  rte_eth_dev_count() - 1] can be operated on by network applications
+ * immediately after invoking rte_eal_init().
+ * If the application unplugs a port using hotplug function, The enabled port
+ * numbers may be noncontiguous. In the case, the applications need to manage
+ * enabled port by themselves.
  *
  * @return
  *   - The total number of usable Ethernet devices.
@@ -1534,6 +1539,18 @@ extern uint8_t rte_eth_dev_count(void);
  */
 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
 
+/**
+ * Function for internal use by dummy drivers primarily, e.g. ring-based
+ * driver.
+ * Release the specified ethdev port.
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @return
+ *   - 0 on success, negative on error
+ */
+int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
+
 struct eth_driver;
 /**
  * @internal
@@ -1569,6 +1586,27 @@ struct eth_driver;
 typedef int (*eth_dev_init_t)(struct eth_driver  *eth_drv,
                              struct rte_eth_dev *eth_dev);
 
+/**
+ * @internal
+ * Finalization function of an Ethernet driver invoked for each matching
+ * Ethernet PCI device detected during the PCI closing phase.
+ *
+ * @param eth_drv
+ *   The pointer to the [matching] Ethernet driver structure supplied by
+ *   the PMD when it registered itself.
+ * @param eth_dev
+ *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
+ *   associated with the matching device and which have been [automatically]
+ *   allocated in the *rte_eth_devices* array.
+ * @return
+ *   - 0: Success, the device is properly finalized by the driver.
+ *        In particular, the driver MUST free the *dev_ops* pointer
+ *        of the *eth_dev* structure.
+ *   - <0: Error code of the device initialization failure.
+ */
+typedef int (*eth_dev_uninit_t)(const struct eth_driver  *eth_drv,
+                                 struct rte_eth_dev *eth_dev);
+
 /**
  * @internal
  * The structure associated with a PMD Ethernet driver.
@@ -1580,11 +1618,14 @@ typedef int (*eth_dev_init_t)(struct eth_driver  *eth_drv,
  *
  * - The *eth_dev_init* function invoked for each matching PCI device.
  *
+ * - The *eth_dev_uninit* function invoked for each matching PCI device.
+ *
  * - The size of the private data to allocate for each matching device.
  */
 struct eth_driver {
        struct rte_pci_driver pci_drv;    /**< The PMD is also a PCI driver. */
        eth_dev_init_t eth_dev_init;      /**< Device init function. */
+       eth_dev_uninit_t eth_dev_uninit;  /**< Device uninit function. */
        unsigned int dev_private_size;    /**< Size of device private data. */
 };