src/dpdk/drivers/net/mlx5/mlx5_mac.c
static int
mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
			   uint32_t index)
{
	unsigned int i;
	int ret;

	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
	if (rte_is_zero_ether_addr(mac)) {
		rte_errno = EINVAL;
		return -rte_errno;
	}
	/* First, make sure this address isn't already configured. */
	for (i = 0; (i != MLX5_MAX_MAC_ADDRESSES); ++i) {
		/* Skip this index, it's going to be reconfigured. */
		if (i == index)
			continue;
		if (memcmp(&dev->data->mac_addrs[i], mac, sizeof(*mac)))
			continue;
		/* Address already configured elsewhere, return with error. */
		rte_errno = EADDRINUSE;
		return -rte_errno;
	}
	ret = mlx5_os_mac_addr_add(dev, mac, index);
	if (ret)
		return ret;

	dev->data->mac_addrs[index] = *mac;
	return 0;
}
/**
 * Adds a MAC address to the internal array.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param mac_addr
 *   MAC address to register.
 * @param index
 *   MAC address index.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Adds a MAC address to the internal array.
@param dev
Pointer to Ethernet device structure.
@param mac_addr
MAC address to register.
@param index
MAC address index.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Adds a MAC address to the internal array . @param dev Pointer to Ethernet device structure . @param mac_addr MAC address to register . @param index MAC address index . @return 0 on success a negative errno value otherwise and rte_errno is set .
static int
mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
			   uint32_t index)
{
	unsigned int i;
	int ret;
	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
	if (rte_is_zero_ether_addr(mac)) {
		rte_errno = EINVAL;
		return -rte_errno;
	}
	for (i = 0; (i != MLX5_MAX_MAC_ADDRESSES); ++i) {
		if (i == index)
			continue;
		if (memcmp(&dev->data->mac_addrs[i], mac, sizeof(*mac)))
			continue;
		rte_errno = EADDRINUSE;
		return -rte_errno;
	}
	ret = mlx5_os_mac_addr_add(dev, mac, index);
	if (ret)
		return ret;
	dev->data->mac_addrs[index] = *mac;
	return 0;
}
static int mlx5_internal_mac_addr_add ( struct rte_eth_dev * dev , struct rte_ether_addr * mac , uint32_t index ) { unsigned int i ; int ret ; MLX5_ASSERT ( index < MLX5_MAX_MAC_ADDRESSES ) ; if ( rte_is_zero_ether_addr ( mac ) ) { rte_errno = EINVAL ; return - rte_errno ; } for ( i = 0 ; ( i != MLX5_MAX_MAC_ADDRESSES ) ; ++ i ) { if ( i == index ) continue ; if ( memcmp ( & dev -> data -> mac_addrs [ i ] , mac , sizeof ( * mac ) ) ) continue ; rte_errno = EADDRINUSE ; return - rte_errno ; } ret = mlx5_os_mac_addr_add ( dev , mac , index ) ; if ( ret ) return ret ; dev -> data -> mac_addrs [ index ] = * mac ; return 0 ; }
Adds a MAC address to the internal array.
Adds a MAC address to the internal array .
/* First, make sure this address isn't already configured. */ /* Skip this index, it's going to be reconfigured. */ /* Address already configured elsewhere, return with error. */