[dpdk-dev,v2,3/4] net/mlx5: support a device removal check operation
Checks
Commit Message
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 | 2 ++
drivers/net/mlx5/mlx5.h | 1 +
drivers/net/mlx5/mlx5_ethdev.c | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+)
@@ -303,6 +303,7 @@ struct mlx5_args {
.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 = {
@@ -350,6 +351,7 @@ struct mlx5_args {
.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 {
@@ -208,6 +208,7 @@ int mlx5_ibv_device_to_pci_addr(const struct ibv_device *,
int mlx5_set_link_up(struct rte_eth_dev *dev);
void priv_dev_select_tx_function(struct priv *priv, struct rte_eth_dev *dev);
void priv_dev_select_rx_function(struct priv *priv, struct rte_eth_dev *dev);
+int mlx5_is_removed(struct rte_eth_dev *dev);
/* mlx5_mac.c */
@@ -1474,3 +1474,23 @@ struct priv *
dev->rx_pkt_burst = mlx5_rx_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;
+}