MLX5_ASSERT(priv);
MLX5_ASSERT(priv->sh);
+ if (priv->bond_ifindex > 0) {
+ memcpy(ifname, priv->bond_name, IF_NAMESIZE);
+ return 0;
+ }
ifindex = mlx5_ifindex(dev);
if (!ifindex) {
if (!priv->representor)
return 0;
}
+/**
+ * Get bond information associated with network interface.
+ *
+ * @param pf_ifindex
+ * Network interface index of bond slave interface
+ * @param[out] ifindex
+ * Pointer to bond ifindex.
+ * @param[out] ifname
+ * Pointer to bond ifname.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_sysfs_bond_info(unsigned int pf_ifindex, unsigned int *ifindex,
+ char *ifname)
+{
+ char name[IF_NAMESIZE];
+ FILE *file;
+ unsigned int index;
+ int ret;
+
+ if (!if_indextoname(pf_ifindex, name) || !strlen(name)) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ MKSTR(bond_if, "/sys/class/net/%s/master/ifindex", name);
+ /* read bond ifindex */
+ file = fopen(bond_if, "rb");
+ if (file == NULL) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ ret = fscanf(file, "%u", &index);
+ fclose(file);
+ if (ret <= 0) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ if (ifindex)
+ *ifindex = index;
+
+ /* read bond device name from symbol link */
+ if (ifname) {
+ if (!if_indextoname(index, ifname)) {
+ rte_errno = errno;
+ return -rte_errno;
+ }
+ }
+ return 0;
+}
+
/**
* DPDK callback to retrieve plug-in module EEPROM information (type and size).
*
*/
MLX5_ASSERT(spawn->ifindex);
priv->if_index = spawn->ifindex;
+ if (priv->pf_bond >= 0 && priv->master) {
+ /* Get bond interface info */
+ err = mlx5_sysfs_bond_info(priv->if_index,
+ &priv->bond_ifindex,
+ priv->bond_name);
+ if (err)
+ DRV_LOG(ERR, "unable to get bond info: %s",
+ strerror(rte_errno));
+ else
+ DRV_LOG(INFO, "PF device %u, bond device %u(%s)",
+ priv->if_index, priv->bond_ifindex,
+ priv->bond_name);
+ }
eth_dev->data->dev_private = priv;
priv->dev_data = eth_dev->data;
eth_dev->data->mac_addrs = priv->mac;
int32_t representor_id; /* Port representor identifier. */
int32_t pf_bond; /* >=0 means PF index in bonding configuration. */
unsigned int if_index; /* Associated kernel network device index. */
+ uint32_t bond_ifindex; /**< Bond interface index. */
+ char bond_name[IF_NAMESIZE]; /**< Bond interface name. */
/* RX/TX queues. */
unsigned int rxqs_n; /* RX queues array size. */
unsigned int txqs_n; /* TX queues array size. */
struct mlx5_switch_info *port_info_out);
void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
rte_intr_callback_fn cb_fn, void *cb_arg);
+int mlx5_sysfs_bond_info(unsigned int pf_ifindex, unsigned int *ifindex,
+ char *ifname);
int mlx5_get_module_info(struct rte_eth_dev *dev,
struct rte_eth_dev_module_info *modinfo);
int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
MLX5_ASSERT(priv);
MLX5_ASSERT(priv->if_index);
- ifindex = priv->if_index;
+ ifindex = priv->bond_ifindex > 0 ? priv->bond_ifindex : priv->if_index;
if (!ifindex)
rte_errno = ENXIO;
return ifindex;