net/mlx4: support a device removal check operation
authorMatan Azrad <matan@mellanox.com>
Sat, 20 Jan 2018 21:12:20 +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 mlx4 device.

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

index 61c5bf4..703513e 100644 (file)
@@ -256,6 +256,7 @@ static const struct eth_dev_ops mlx4_dev_ops = {
        .filter_ctrl = mlx4_filter_ctrl,
        .rx_queue_intr_enable = mlx4_rx_intr_enable,
        .rx_queue_intr_disable = mlx4_rx_intr_disable,
+       .is_removed = mlx4_is_removed,
 };
 
 /**
index 99dc335..2ab2988 100644 (file)
@@ -171,6 +171,7 @@ int mlx4_flow_ctrl_get(struct rte_eth_dev *dev,
 int mlx4_flow_ctrl_set(struct rte_eth_dev *dev,
                       struct rte_eth_fc_conf *fc_conf);
 const uint32_t *mlx4_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+int mlx4_is_removed(struct rte_eth_dev *dev);
 
 /* mlx4_intr.c */
 
index c80eab5..5318b56 100644 (file)
@@ -1052,3 +1052,23 @@ mlx4_dev_supported_ptypes_get(struct rte_eth_dev *dev)
        }
        return NULL;
 }
+
+/**
+ * Check if mlx4 device was removed.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   1 when device is removed, otherwise 0.
+ */
+int
+mlx4_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;
+}