net/mlx5: support a device removal check operation
authorMatan Azrad <matan@mellanox.com>
Sat, 20 Jan 2018 21:12:21 +0000 (21:12 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sun, 21 Jan 2018 20:09:41 +0000 (21:09 +0100)
Add support to get removal status of mlx5 device.
It is not supported in secondary process.

Signed-off-by: Matan Azrad <matan@mellanox.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_ethdev.c

index fc2d59f..abf0261 100644 (file)
@@ -284,6 +284,7 @@ const struct eth_dev_ops mlx5_dev_ops = {
        .tx_descriptor_status = mlx5_tx_descriptor_status,
        .rx_queue_intr_enable = mlx5_rx_intr_enable,
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
+       .is_removed = mlx5_is_removed,
 };
 
 static const struct eth_dev_ops mlx5_dev_sec_ops = {
@@ -331,6 +332,7 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = {
        .tx_descriptor_status = mlx5_tx_descriptor_status,
        .rx_queue_intr_enable = mlx5_rx_intr_enable,
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
+       .is_removed = mlx5_is_removed,
 };
 
 static struct {
index 9a4a59b..2594480 100644 (file)
@@ -238,6 +238,7 @@ void priv_dev_interrupt_handler_uninstall(struct priv *, struct rte_eth_dev *);
 void priv_dev_interrupt_handler_install(struct priv *, struct rte_eth_dev *);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
+int mlx5_is_removed(struct rte_eth_dev *dev);
 eth_tx_burst_t priv_select_tx_function(struct priv *, struct rte_eth_dev *);
 eth_rx_burst_t priv_select_rx_function(struct priv *, struct rte_eth_dev *);
 
index 9a2ebd8..9226f1a 100644 (file)
@@ -1515,3 +1515,23 @@ priv_select_rx_function(struct priv *priv, __rte_unused struct rte_eth_dev *dev)
        }
        return rx_pkt_burst;
 }
+
+/**
+ * Check if mlx5 device was removed.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   1 when device is removed, otherwise 0.
+ */
+int
+mlx5_is_removed(struct rte_eth_dev *dev)
+{
+       struct ibv_device_attr device_attr;
+       struct priv *priv = dev->data->dev_private;
+
+       if (ibv_query_device(priv->ctx, &device_attr) == EIO)
+               return 1;
+       return 0;
+}