X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fwindows%2Fmlx5_ethdev_os.c;h=f97526580d8e36ec1d2e877af332866d6a0375ea;hb=0a94d6bc5daf9b474ed05f3a36bf2d9dc2e3df82;hp=1b68a7b6e821d104e02d4891665a7924eaf403f9;hpb=99d7c45cf8daa50f095168a5962d73b48569b117;p=dpdk.git diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c index 1b68a7b6e8..f97526580d 100644 --- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -38,11 +38,75 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]) return -rte_errno; } priv = dev->data->dev_private; - context_obj = (mlx5_context_st *)priv->sh->ctx; + context_obj = (mlx5_context_st *)priv->sh->cdev->ctx; memcpy(mac, context_obj->mlx5_dev.eth_mac, RTE_ETHER_ADDR_LEN); 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->cdev->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) +{ + int err; + uint32_t curr_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->cdev->ctx; + + err = mlx5_glue->devx_get_mtu(context_obj, &curr_mtu); + if (err != 0) { + DRV_LOG(WARNING, "Could not get the MTU!"); + return err; + } + *mtu = (uint16_t)curr_mtu; + + return 0; +} + /** * Set device MTU. * @@ -57,9 +121,23 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]) int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) { - RTE_SET_USED(dev); - RTE_SET_USED(mtu); - return -ENOTSUP; + int err; + 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->cdev->ctx; + + err = mlx5_glue->devx_set_mtu(context_obj, mtu); + if (err != 0) { + DRV_LOG(WARNING, "Could not set the MTU!"); + return err; + } + return 0; } /* @@ -148,7 +226,16 @@ mlx5_os_get_stats_n(struct rte_eth_dev *dev) void mlx5_os_stats_init(struct rte_eth_dev *dev) { - RTE_SET_USED(dev); + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl; + int ret; + + /* Copy to base at first time. */ + ret = mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base); + if (ret) + DRV_LOG(ERR, "port %u cannot read device counters: %s", + dev->data->port_id, strerror(rte_errno)); + stats_ctrl->imissed = 0; } /** @@ -198,8 +285,8 @@ mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) return -rte_errno; } priv = dev->data->dev_private; - context_obj = (mlx5_context_st *)priv->sh->ctx; - dev_link.link_speed = context_obj->mlx5_dev.link_speed / (1024 * 1024); + context_obj = (mlx5_context_st *)priv->sh->cdev->ctx; + dev_link.link_speed = context_obj->mlx5_dev.link_speed / (1000 * 1000); dev_link.link_status = (context_obj->mlx5_dev.link_state == 1 && !mlx5_is_removed(dev)) ? 1 : 0; @@ -304,7 +391,7 @@ 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; + mlx5_context_st *context_obj = (mlx5_context_st *)priv->sh->cdev->ctx; err = mlx5_glue->query_rt_values(context_obj, &mlx5_clock); if (err != 0) { @@ -314,3 +401,40 @@ mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock) *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->cdev->ctx; + + if (*context_obj->shutdown_event_obj.p_flag) + return 1; + return 0; +} + +/* + * Query dropless_rq private flag value provided by ETHTOOL. + * + * @param dev + * Pointer to Ethernet device. + * + * @return + * - 0 on success, flag is not set. + * - 1 on success, flag is set. + * - negative errno value otherwise and rte_errno is set. + */ +int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev) +{ + RTE_SET_USED(dev); + return -ENOTSUP; +}