diff options
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/cmd.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 65a4a0f88ea0..02a2e90d581a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -2389,6 +2389,22 @@ struct mlx4_slaves_pport mlx4_phys_to_slaves_pport_actv( | |||
2389 | } | 2389 | } |
2390 | EXPORT_SYMBOL_GPL(mlx4_phys_to_slaves_pport_actv); | 2390 | EXPORT_SYMBOL_GPL(mlx4_phys_to_slaves_pport_actv); |
2391 | 2391 | ||
2392 | static int mlx4_slaves_closest_port(struct mlx4_dev *dev, int slave, int port) | ||
2393 | { | ||
2394 | struct mlx4_active_ports actv_ports = mlx4_get_active_ports(dev, slave); | ||
2395 | int min_port = find_first_bit(actv_ports.ports, dev->caps.num_ports) | ||
2396 | + 1; | ||
2397 | int max_port = min_port + | ||
2398 | bitmap_weight(actv_ports.ports, dev->caps.num_ports); | ||
2399 | |||
2400 | if (port < min_port) | ||
2401 | port = min_port; | ||
2402 | else if (port >= max_port) | ||
2403 | port = max_port - 1; | ||
2404 | |||
2405 | return port; | ||
2406 | } | ||
2407 | |||
2392 | int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac) | 2408 | int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac) |
2393 | { | 2409 | { |
2394 | struct mlx4_priv *priv = mlx4_priv(dev); | 2410 | struct mlx4_priv *priv = mlx4_priv(dev); |
@@ -2402,6 +2418,7 @@ int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac) | |||
2402 | if (slave < 0) | 2418 | if (slave < 0) |
2403 | return -EINVAL; | 2419 | return -EINVAL; |
2404 | 2420 | ||
2421 | port = mlx4_slaves_closest_port(dev, slave, port); | ||
2405 | s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; | 2422 | s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; |
2406 | s_info->mac = mac; | 2423 | s_info->mac = mac; |
2407 | mlx4_info(dev, "default mac on vf %d port %d to %llX will take afect only after vf restart\n", | 2424 | mlx4_info(dev, "default mac on vf %d port %d to %llX will take afect only after vf restart\n", |
@@ -2428,6 +2445,7 @@ int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos) | |||
2428 | if (slave < 0) | 2445 | if (slave < 0) |
2429 | return -EINVAL; | 2446 | return -EINVAL; |
2430 | 2447 | ||
2448 | port = mlx4_slaves_closest_port(dev, slave, port); | ||
2431 | vf_admin = &priv->mfunc.master.vf_admin[slave].vport[port]; | 2449 | vf_admin = &priv->mfunc.master.vf_admin[slave].vport[port]; |
2432 | 2450 | ||
2433 | if ((0 == vlan) && (0 == qos)) | 2451 | if ((0 == vlan) && (0 == qos)) |
@@ -2455,6 +2473,7 @@ bool mlx4_get_slave_default_vlan(struct mlx4_dev *dev, int port, int slave, | |||
2455 | struct mlx4_priv *priv; | 2473 | struct mlx4_priv *priv; |
2456 | 2474 | ||
2457 | priv = mlx4_priv(dev); | 2475 | priv = mlx4_priv(dev); |
2476 | port = mlx4_slaves_closest_port(dev, slave, port); | ||
2458 | vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; | 2477 | vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; |
2459 | 2478 | ||
2460 | if (MLX4_VGT != vp_oper->state.default_vlan) { | 2479 | if (MLX4_VGT != vp_oper->state.default_vlan) { |
@@ -2482,6 +2501,7 @@ int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting) | |||
2482 | if (slave < 0) | 2501 | if (slave < 0) |
2483 | return -EINVAL; | 2502 | return -EINVAL; |
2484 | 2503 | ||
2504 | port = mlx4_slaves_closest_port(dev, slave, port); | ||
2485 | s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; | 2505 | s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; |
2486 | s_info->spoofchk = setting; | 2506 | s_info->spoofchk = setting; |
2487 | 2507 | ||
@@ -2535,6 +2555,7 @@ int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_stat | |||
2535 | if (slave < 0) | 2555 | if (slave < 0) |
2536 | return -EINVAL; | 2556 | return -EINVAL; |
2537 | 2557 | ||
2558 | port = mlx4_slaves_closest_port(dev, slave, port); | ||
2538 | switch (link_state) { | 2559 | switch (link_state) { |
2539 | case IFLA_VF_LINK_STATE_AUTO: | 2560 | case IFLA_VF_LINK_STATE_AUTO: |
2540 | /* get current link state */ | 2561 | /* get current link state */ |