X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx4%2Fmlx4_ethdev.c;h=9ff05c6738831fcb0dae28ff829626b044e1b54b;hb=25ae7f1a5d9d127a46f8d62d1d689f77a78138fd;hp=3d18aa4fce04f17985abc87198959fc15926c23b;hpb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;p=dpdk.git diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 3d18aa4fce..9ff05c6738 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -8,7 +8,6 @@ * Miscellaneous control operations for mlx4 driver. */ -#include #include #include #include @@ -341,13 +340,17 @@ enum rxmode_toggle { * Pointer to Ethernet device structure. * @param toggle * Toggle to set. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static void +static int mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle toggle) { struct mlx4_priv *priv = dev->data->dev_private; const char *mode; struct rte_flow_error error; + int ret; switch (toggle) { case RXMODE_TOGGLE_PROMISC_OFF: @@ -363,12 +366,16 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle toggle) default: mode = "undefined"; } - if (!mlx4_flow_sync(priv, &error)) - return; + + ret = mlx4_flow_sync(priv, &error); + if (!ret) + return 0; + ERROR("cannot toggle %s mode (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", mode, rte_errno, strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); + return ret; } /** @@ -376,11 +383,14 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle toggle) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx4_promiscuous_enable(struct rte_eth_dev *dev) { - mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_ON); + return mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_ON); } /** @@ -388,11 +398,14 @@ mlx4_promiscuous_enable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx4_promiscuous_disable(struct rte_eth_dev *dev) { - mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_OFF); + return mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_PROMISC_OFF); } /** @@ -400,11 +413,14 @@ mlx4_promiscuous_disable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx4_allmulticast_enable(struct rte_eth_dev *dev) { - mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_ALLMULTI_ON); + return mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_ALLMULTI_ON); } /** @@ -412,11 +428,14 @@ mlx4_allmulticast_enable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx4_allmulticast_disable(struct rte_eth_dev *dev) { - mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_ALLMULTI_OFF); + return mlx4_rxmode_toggle(dev, RXMODE_TOGGLE_ALLMULTI_OFF); } /** @@ -611,12 +630,11 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) * @param[out] info * Info structure output buffer. */ -void +int mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) { struct mlx4_priv *priv = dev->data->dev_private; unsigned int max; - char ifname[IF_NAMESIZE]; /* FIXME: we should ask the device for these values. */ info->min_rx_bufsize = 32; @@ -627,9 +645,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) */ max = ((priv->device_attr.max_cq > priv->device_attr.max_qp) ? priv->device_attr.max_qp : priv->device_attr.max_cq); - /* If max >= 65535 then max = 0, max_rx_queues is uint16_t. */ - if (max >= 65535) - max = 65535; + /* max_rx_queues is uint16_t. */ + max = RTE_MIN(max, (unsigned int)UINT16_MAX); info->max_rx_queues = max; info->max_tx_queues = max; info->max_mac_addrs = RTE_DIM(priv->mac); @@ -637,8 +654,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) info->rx_queue_offload_capa = mlx4_get_rx_queue_offloads(priv); info->rx_offload_capa = (mlx4_get_rx_port_offloads(priv) | info->rx_queue_offload_capa); - if (mlx4_get_ifname(priv, &ifname) == 0) - info->if_index = if_nametoindex(ifname); + info->if_index = priv->if_index; info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE; info->speed_capa = ETH_LINK_SPEED_1G | @@ -647,6 +663,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) ETH_LINK_SPEED_40G | ETH_LINK_SPEED_56G; info->flow_type_rss_offloads = mlx4_conv_rss_types(priv, 0, 1); + + return 0; } /** @@ -718,7 +736,6 @@ mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) if (idx < RTE_ETHDEV_QUEUE_STAT_CNTRS) { tmp.q_opackets[idx] += txq->stats.opackets; tmp.q_obytes[idx] += txq->stats.obytes; - tmp.q_errors[idx] += txq->stats.odropped; } tmp.opackets += txq->stats.opackets; tmp.obytes += txq->stats.obytes; @@ -733,8 +750,11 @@ mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * alwasy 0 on success */ -void +int mlx4_stats_reset(struct rte_eth_dev *dev) { unsigned int i; @@ -755,6 +775,8 @@ mlx4_stats_reset(struct rte_eth_dev *dev) .idx = txq->stats.idx, }; } + + return 0; } /** @@ -850,7 +872,7 @@ mlx4_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) fc_conf->mode = RTE_FC_NONE; ret = 0; out: - assert(ret >= 0); + MLX4_ASSERT(ret >= 0); return -ret; } @@ -896,7 +918,7 @@ mlx4_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) } ret = 0; out: - assert(ret >= 0); + MLX4_ASSERT(ret >= 0); return -ret; }