#include <rte_errno.h>
#include <rte_ether.h>
-#include <rte_ethdev_driver.h>
+#include <ethdev_driver.h>
#include <rte_interrupts.h>
#include <mlx5_glue.h>
#include <mlx5_win_ext.h>
#include <mlx5_malloc.h>
#include <mlx5.h>
+#include <mlx5_utils.h>
/**
* Get MAC address by querying netdevice.
return 0;
}
+/**
+ * Get interface name from private structure.
+ *
+ *
+ * @param[in] dev
+ * Pointer to Ethernet device.
+ * @param[out] ifname
+ * Interface name output buffer.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[MLX5_NAMESIZE])
+{
+ struct mlx5_priv *priv;
+ mlx5_context_st *context_obj;
+
+ if (!dev) {
+ rte_errno = EINVAL;
+ return -rte_errno;
+ }
+ priv = dev->data->dev_private;
+ context_obj = (mlx5_context_st *)priv->sh->ctx;
+ strncpy(*ifname, context_obj->mlx5_dev.name, MLX5_NAMESIZE);
+ return 0;
+}
+
+/**
+ * Get device MTU.
+ *
+ * @param dev
+ * Pointer to Ethernet device.
+ * @param[out] mtu
+ * MTU value output buffer.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu)
+{
+ struct mlx5_priv *priv;
+ mlx5_context_st *context_obj;
+
+ if (!dev) {
+ rte_errno = EINVAL;
+ return -rte_errno;
+ }
+ priv = dev->data->dev_private;
+ context_obj = (mlx5_context_st *)priv->sh->ctx;
+ *mtu = context_obj->mlx5_dev.mtu_bytes;
+ return 0;
+}
+
/**
* Set device MTU.
*
RTE_SET_USED(info);
return -ENOTSUP;
}
+
+/**
+ * Get device current raw clock counter
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param[out] time
+ * Current raw clock counter of the device.
+ *
+ * @return
+ * 0 if the clock has correctly been read
+ * The value of errno in case of error
+ */
+int
+mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
+{
+ int err;
+ struct mlx5_devx_clock mlx5_clock;
+ struct mlx5_priv *priv = dev->data->dev_private;
+ mlx5_context_st *context_obj = (mlx5_context_st *)priv->sh->ctx;
+
+ err = mlx5_glue->query_rt_values(context_obj, &mlx5_clock);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not query the clock");
+ return err;
+ }
+ *clock = *(uint64_t volatile *)mlx5_clock.p_iseg_internal_timer;
+ return 0;
+}
+
+/**
+ * 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 mlx5_priv *priv = dev->data->dev_private;
+ mlx5_context_st *context_obj = (mlx5_context_st *)priv->sh->ctx;
+
+ if (*context_obj->shutdown_event_obj.p_flag)
+ return 1;
+ return 0;
+}