aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2014-09-10 09:41:53 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-10 18:21:34 -0400
commita91c772fa0275163508e1078ff6d474d423244fb (patch)
treec52dcd04f9912d257c686c7d461ea2ee253f51e0
parenta0e2c822bf0a1095dc250b5875e39ac0662a5df6 (diff)
net/mlx4: Correctly configure single ported VFs from the host
Single port VFs are seen PCI wise on both ports of the PF (we don't have single port PFs with ConnectX). With this in mind, it's possible for virtualization tools to try and configure a single ported VF through the "wrong" PF port. To handle that, we use the PF driver mapping of single port VFs to NIC ports and adjust the port value before calling into the low level code that does the actual VF configuration Fixes: 449fc48 ('net/mlx4: Adapt code for N-Port VF') Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c21
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}
2390EXPORT_SYMBOL_GPL(mlx4_phys_to_slaves_pport_actv); 2390EXPORT_SYMBOL_GPL(mlx4_phys_to_slaves_pport_actv);
2391 2391
2392static 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
2392int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac) 2408int 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 */