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)
dev = &rte_eth_devices[sh->port[i].ih_port_id];
MLX5_ASSERT(dev);
if (dev->data->dev_conf.intr_conf.rmv)
- _rte_eth_dev_callback_process
+ rte_eth_dev_callback_process
(dev, RTE_ETH_EVENT_INTR_RMV, NULL);
}
}
usleep(0);
continue;
}
- _rte_eth_dev_callback_process
+ rte_eth_dev_callback_process
(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
continue;
}
return 0;
}
+/**
+ * Analyze gathered port parameters via sysfs to recognize master
+ * and representor devices for E-Switch configuration.
+ *
+ * @param[in] device_dir
+ * flag of presence of "device" directory under port device key.
+ * @param[inout] switch_info
+ * Port information, including port name as a number and port name
+ * type if recognized
+ *
+ * @return
+ * master and representor flags are set in switch_info according to
+ * recognized parameters (if any).
+ */
+static void
+mlx5_sysfs_check_switch_info(bool device_dir,
+ struct mlx5_switch_info *switch_info)
+{
+ switch (switch_info->name_type) {
+ case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
+ /*
+ * Name is not recognized, assume the master,
+ * check the device directory presence.
+ */
+ switch_info->master = device_dir;
+ break;
+ case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
+ /*
+ * Name is not set, this assumes the legacy naming
+ * schema for master, just check if there is
+ * a device directory.
+ */
+ switch_info->master = device_dir;
+ break;
+ case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
+ /* New uplink naming schema recognized. */
+ switch_info->master = 1;
+ break;
+ case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
+ /* Legacy representors naming schema. */
+ switch_info->representor = !device_dir;
+ break;
+ case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
+ /* Fallthrough */
+ case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
+ /* New representors naming schema. */
+ switch_info->representor = 1;
+ break;
+ }
+}
+
/**
* Get switch information associated with network interface.
*
file = fopen(phys_port_name, "rb");
if (file != NULL) {
- ret = fscanf(file, "%s", port_name);
+ ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name);
fclose(file);
if (ret == 1)
mlx5_translate_port_name(port_name, &data);
}
/**
- * Analyze gathered port parameters via sysfs to recognize master
- * and representor devices for E-Switch configuration.
+ * Get bond information associated with network interface.
*
- * @param[in] device_dir
- * flag of presence of "device" directory under port device key.
- * @param[inout] switch_info
- * Port information, including port name as a number and port name
- * type if recognized
+ * @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
- * master and representor flags are set in switch_info according to
- * recognized parameters (if any).
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
*/
-void
-mlx5_sysfs_check_switch_info(bool device_dir,
- struct mlx5_switch_info *switch_info)
+int
+mlx5_sysfs_bond_info(unsigned int pf_ifindex, unsigned int *ifindex,
+ char *ifname)
{
- switch (switch_info->name_type) {
- case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
- /*
- * Name is not recognized, assume the master,
- * check the device directory presence.
- */
- switch_info->master = device_dir;
- break;
- case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
- /*
- * Name is not set, this assumes the legacy naming
- * schema for master, just check if there is
- * a device directory.
- */
- switch_info->master = device_dir;
- break;
- case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
- /* New uplink naming schema recognized. */
- switch_info->master = 1;
- break;
- case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
- /* Legacy representors naming schema. */
- switch_info->representor = !device_dir;
- break;
- case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
- /* Fallthrough */
- case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
- /* New representors naming schema. */
- switch_info->representor = 1;
- break;
+ 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;
}
/**