src/dpdk/drivers/net/mlx4/mlx4_ethdev.c
int
mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete)
{
	const struct mlx4_priv *priv = dev->data->dev_private;
	struct ethtool_cmd edata = {
		.cmd = ETHTOOL_GSET,
	};
	struct ifreq ifr;
	struct rte_eth_link dev_link;
	int link_speed = 0;

	if (priv == NULL) {
		rte_errno = EINVAL;
		return -rte_errno;
	}
	(void)wait_to_complete;
	if (mlx4_ifreq(priv, SIOCGIFFLAGS, &ifr)) {
		WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(rte_errno));
		return -rte_errno;
	}
	memset(&dev_link, 0, sizeof(dev_link));
	dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
				(ifr.ifr_flags & IFF_RUNNING));
	ifr.ifr_data = (void *)&edata;
	if (mlx4_ifreq(priv, SIOCETHTOOL, &ifr)) {
		WARN("ioctl(SIOCETHTOOL, ETHTOOL_GSET) failed: %s",
		     strerror(rte_errno));
		return -rte_errno;
	}
	link_speed = ethtool_cmd_speed(&edata);
	if (link_speed == -1)
		dev_link.link_speed = ETH_SPEED_NUM_NONE;
	else
		dev_link.link_speed = link_speed;
	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
				  ETH_LINK_SPEED_FIXED);
	dev->data->dev_link = dev_link;
	return 0;
}
/**
 * DPDK callback to retrieve physical link information.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param wait_to_complete
 *   Wait for request completion (ignored).
 *
 * @return
 *   0 on success, negative errno value otherwise and rte_errno is set.
 */
DPDK callback to retrieve physical link information.
@param dev
Pointer to Ethernet device structure.
@param wait_to_complete
Wait for request completion (ignored).

@return
0 on success, negative errno value otherwise and rte_errno is set.
DPDK callback to retrieve physical link information . @param dev Pointer to Ethernet device structure . @param wait_to_complete Wait for request completion ( ignored ) . @return 0 on success negative errno value otherwise and rte_errno is set .
int
mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete)
{
	const struct mlx4_priv *priv = dev->data->dev_private;
	struct ethtool_cmd edata = {
		.cmd = ETHTOOL_GSET,
	};
	struct ifreq ifr;
	struct rte_eth_link dev_link;
	int link_speed = 0;
	if (priv == NULL) {
		rte_errno = EINVAL;
		return -rte_errno;
	}
	(void)wait_to_complete;
	if (mlx4_ifreq(priv, SIOCGIFFLAGS, &ifr)) {
		WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(rte_errno));
		return -rte_errno;
	}
	memset(&dev_link, 0, sizeof(dev_link));
	dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
				(ifr.ifr_flags & IFF_RUNNING));
	ifr.ifr_data = (void *)&edata;
	if (mlx4_ifreq(priv, SIOCETHTOOL, &ifr)) {
		WARN("ioctl(SIOCETHTOOL, ETHTOOL_GSET) failed: %s",
		     strerror(rte_errno));
		return -rte_errno;
	}
	link_speed = ethtool_cmd_speed(&edata);
	if (link_speed == -1)
		dev_link.link_speed = ETH_SPEED_NUM_NONE;
	else
		dev_link.link_speed = link_speed;
	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
				  ETH_LINK_SPEED_FIXED);
	dev->data->dev_link = dev_link;
	return 0;
}
int mlx4_link_update ( struct rte_eth_dev * dev , int wait_to_complete ) { const struct mlx4_priv * priv = dev -> data -> dev_private ; struct ethtool_cmd edata = { . cmd = ETHTOOL_GSET , } ; struct ifreq ifr ; struct rte_eth_link dev_link ; int link_speed = 0 ; if ( priv == NULL ) { rte_errno = EINVAL ; return - rte_errno ; } ( void ) wait_to_complete ; if ( mlx4_ifreq ( priv , SIOCGIFFLAGS , & ifr ) ) { WARN ( " " , strerror ( rte_errno ) ) ; return - rte_errno ; } memset ( & dev_link , 0 , sizeof ( dev_link ) ) ; dev_link . link_status = ( ( ifr . ifr_flags & IFF_UP ) && ( ifr . ifr_flags & IFF_RUNNING ) ) ; ifr . ifr_data = ( void * ) & edata ; if ( mlx4_ifreq ( priv , SIOCETHTOOL , & ifr ) ) { WARN ( " " , strerror ( rte_errno ) ) ; return - rte_errno ; } link_speed = ethtool_cmd_speed ( & edata ) ; if ( link_speed == -1 ) dev_link . link_speed = ETH_SPEED_NUM_NONE ; else dev_link . link_speed = link_speed ; dev_link . link_duplex = ( ( edata . duplex == DUPLEX_HALF ) ? ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX ) ; dev_link . link_autoneg = ! ( dev -> data -> dev_conf . link_speeds & ETH_LINK_SPEED_FIXED ) ; dev -> data -> dev_link = dev_link ; return 0 ; }
DPDK callback to retrieve physical link information.
DPDK callback to retrieve physical link information .