int mlx5_get_master_ifname(const struct rte_eth_dev *dev,
char (*ifname)[IF_NAMESIZE]);
int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
-int mlx5_ifindex(const struct rte_eth_dev *dev);
+unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr,
int master);
int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
* Pointer to Ethernet device.
*
* @return
- * Interface index on success, a negative errno value otherwise and
- * rte_errno is set.
+ * Nonzero interface index on success, zero otherwise and rte_errno is set.
*/
-int
+unsigned int
mlx5_ifindex(const struct rte_eth_dev *dev)
{
char ifname[IF_NAMESIZE];
- unsigned int ret;
+ unsigned int ifindex;
- ret = mlx5_get_ifname(dev, &ifname);
- if (ret)
- return ret;
- ret = if_nametoindex(ifname);
- if (ret == 0) {
+ if (mlx5_get_ifname(dev, &ifname))
+ return 0;
+ ifindex = if_nametoindex(ifname);
+ if (!ifindex)
rte_errno = errno;
- return -rte_errno;
- }
- return ret;
+ return ifindex;
}
/**
int *mac_n)
{
struct priv *priv = dev->data->dev_private;
- int iface_idx = mlx5_ifindex(dev);
+ unsigned int iface_idx = mlx5_ifindex(dev);
struct {
struct nlmsghdr hdr;
struct ifinfomsg ifm;
int add)
{
struct priv *priv = dev->data->dev_private;
- int iface_idx = mlx5_ifindex(dev);
+ unsigned int iface_idx = mlx5_ifindex(dev);
struct {
struct nlmsghdr hdr;
struct ndmsg ndm;
mlx5_nl_device_flags(struct rte_eth_dev *dev, uint32_t flags, int enable)
{
struct priv *priv = dev->data->dev_private;
- int iface_idx = mlx5_ifindex(dev);
+ unsigned int iface_idx = mlx5_ifindex(dev);
struct {
struct nlmsghdr hdr;
struct ifinfomsg ifi;