ethdev: add devop to check removal status
[dpdk.git] / lib / librte_ether / rte_ethdev.h
index f0eeefe..0bc6a3a 100644 (file)
@@ -152,6 +152,7 @@ extern "C" {
 #include <rte_devargs.h>
 #include <rte_errno.h>
 #include <rte_common.h>
+#include <rte_config.h>
 
 #include "rte_ether.h"
 #include "rte_eth_ctrl.h"
@@ -945,6 +946,11 @@ struct rte_eth_conf {
                             DEV_RX_OFFLOAD_VLAN_FILTER | \
                             DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+/*
+ * If new Rx offload capabilities are defined, they also must be
+ * mentioned in rte_rx_offload_names in rte_ethdev.c file.
+ */
+
 /**
  * TX offload capabilities of a device.
  */
@@ -975,6 +981,11 @@ struct rte_eth_conf {
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
 
+/*
+ * If new Tx offload capabilities are defined, they also must be
+ * mentioned in rte_tx_offload_names in rte_ethdev.c file.
+ */
+
 struct rte_pci_device;
 
 /**
@@ -1169,6 +1180,9 @@ typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
 /** <@internal Function used to reset a configured Ethernet device. */
 
+typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to detect an Ethernet device removal. */
+
 typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
 /**< @internal Function used to enable the RX promiscuous mode of an Ethernet device. */
 
@@ -1498,6 +1512,8 @@ struct eth_dev_ops {
        eth_dev_close_t            dev_close;     /**< Close device. */
        eth_dev_reset_t            dev_reset;     /**< Reset device. */
        eth_link_update_t          link_update;   /**< Get device link state. */
+       eth_is_removed_t           is_removed;
+       /**< Check if the device was physically removed. */
 
        eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
        eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
@@ -1684,6 +1700,7 @@ enum rte_eth_dev_state {
        RTE_ETH_DEV_UNUSED = 0,
        RTE_ETH_DEV_ATTACHED,
        RTE_ETH_DEV_DEFERRED,
+       RTE_ETH_DEV_REMOVED,
 };
 
 /**
@@ -1720,9 +1737,6 @@ struct rte_eth_dev {
        void *security_ctx; /**< Context for security ops */
 } __rte_cache_aligned;
 
-void *
-rte_eth_dev_get_sec_ctx(uint8_t port_id);
-
 struct rte_eth_dev_sriov {
        uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
        uint8_t nb_q_per_pool;        /**< rx queue number per pool */
@@ -1921,6 +1935,32 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname);
  */
 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_RX_OFFLOAD_* flag name.
+ *
+ * @param offload
+ *   Offload flag.
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
+ */
+const char *rte_eth_dev_rx_offload_name(uint64_t offload);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_TX_OFFLOAD_* flag name.
+ *
+ * @param offload
+ *   Offload flag.
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
+ */
+const char *rte_eth_dev_tx_offload_name(uint64_t offload);
+
 /**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
@@ -1969,6 +2009,20 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
  */
 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Check if an Ethernet device was physically removed.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   1 when the Ethernet device is removed, otherwise 0.
+ */
+int
+rte_eth_dev_is_removed(uint16_t port_id);
+
 /**
  * Allocate and set up a receive queue for an Ethernet device.
  *
@@ -4581,6 +4635,18 @@ int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
 int
 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
 
+/**
+ * Get the security context for the Ethernet device.
+ *
+ * @param port_id
+ *   Port identifier of the Ethernet device
+ * @return
+ *   - NULL on error.
+ *   - pointer to security context on success.
+ */
+void *
+rte_eth_dev_get_sec_ctx(uint8_t port_id);
+
 #ifdef __cplusplus
 }
 #endif