X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Flinux%2Fmlx5_ethdev_os.c;h=593b0d08acf43194f7869141b08b5ce9a7875a83;hb=bd885ab120e2335f978a28ee0aa4303017390e15;hp=e79d576c6c380767befd33ee328a9e376569a10d;hpb=98c4b12afae7973fb7ab0956687adc6645815623;p=dpdk.git diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index e79d576c6c..593b0d08ac 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -151,6 +151,10 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]) 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) @@ -732,7 +736,7 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh) 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); } } @@ -808,7 +812,7 @@ mlx5_dev_interrupt_handler(void *cb_arg) usleep(0); continue; } - _rte_eth_dev_callback_process + rte_eth_dev_callback_process (dev, RTE_ETH_EVENT_INTR_LSC, NULL); continue; } @@ -972,6 +976,57 @@ mlx5_is_removed(struct rte_eth_dev *dev) 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. * @@ -1016,7 +1071,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) 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); @@ -1051,54 +1106,55 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) } /** - * 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; } /**