aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2014-03-19 12:11:52 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-20 16:18:30 -0400
commit449fc48866f7d84b0d9a19201de18a4dd4d3488c (patch)
tree20db12e2dd676c6c824a8173601c9023632d3c37 /drivers/infiniband
parentf74462acf8f390528c8b7937f227c6c90d017f3b (diff)
net/mlx4: Adapt code for N-Port VF
Adds support for N-Port VFs, this includes: 1. Adding support in the wrapped FW command In wrapped commands, we need to verify and convert the slave's port into the real physical port. Furthermore, when sending the response back to the slave, a reverse conversion should be made. 2. Adjusting sqpn for QP1 para-virtualization The slave assumes that sqpn is used for QP1 communication. If the slave is assigned to a port != (first port), we need to adjust the sqpn that will direct its QP1 packets into the correct endpoint. 3. Adjusting gid[5] to modify the port for raw ethernet In B0 steering, gid[5] contains the port. It needs to be adjusted into the physical port. 4. Adjusting number of ports in the query / ports caps in the FW commands When a slave queries the hardware, it needs to view only the physical ports it's assigned to. 5. Adjusting the sched_qp according to the port number The QP port is encoded in the sched_qp, thus in modify_qp we need to encode the correct port in sched_qp. 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>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c29
-rw-r--r--drivers/infiniband/hw/mlx4/main.c15
-rw-r--r--drivers/infiniband/hw/mlx4/sysfs.c5
3 files changed, 31 insertions, 18 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 2c572aed3f6f..fd36ec672632 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1245,21 +1245,9 @@ out:
1245 1245
1246static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port) 1246static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
1247{ 1247{
1248 int gids;
1249 int vfs;
1250
1251 if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND) 1248 if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
1252 return slave; 1249 return slave;
1253 1250 return mlx4_get_base_gid_ix(dev->dev, slave, port);
1254 gids = MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS;
1255 vfs = dev->dev->num_vfs;
1256
1257 if (slave == 0)
1258 return 0;
1259 if (slave <= gids % vfs)
1260 return MLX4_ROCE_PF_GIDS + ((gids / vfs) + 1) * (slave - 1);
1261
1262 return MLX4_ROCE_PF_GIDS + (gids % vfs) + ((gids / vfs) * (slave - 1));
1263} 1251}
1264 1252
1265static void fill_in_real_sgid_index(struct mlx4_ib_dev *dev, int slave, int port, 1253static void fill_in_real_sgid_index(struct mlx4_ib_dev *dev, int slave, int port,
@@ -1281,6 +1269,7 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
1281 struct ib_ah_attr ah_attr; 1269 struct ib_ah_attr ah_attr;
1282 u8 *slave_id; 1270 u8 *slave_id;
1283 int slave; 1271 int slave;
1272 int port;
1284 1273
1285 /* Get slave that sent this packet */ 1274 /* Get slave that sent this packet */
1286 if (wc->src_qp < dev->dev->phys_caps.base_proxy_sqpn || 1275 if (wc->src_qp < dev->dev->phys_caps.base_proxy_sqpn ||
@@ -1360,6 +1349,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
1360 if (ah_attr.ah_flags & IB_AH_GRH) 1349 if (ah_attr.ah_flags & IB_AH_GRH)
1361 fill_in_real_sgid_index(dev, slave, ctx->port, &ah_attr); 1350 fill_in_real_sgid_index(dev, slave, ctx->port, &ah_attr);
1362 1351
1352 port = mlx4_slave_convert_port(dev->dev, slave, ah_attr.port_num);
1353 if (port < 0)
1354 return;
1355 ah_attr.port_num = port;
1363 memcpy(ah_attr.dmac, tunnel->hdr.mac, 6); 1356 memcpy(ah_attr.dmac, tunnel->hdr.mac, 6);
1364 ah_attr.vlan_id = be16_to_cpu(tunnel->hdr.vlan); 1357 ah_attr.vlan_id = be16_to_cpu(tunnel->hdr.vlan);
1365 /* if slave have default vlan use it */ 1358 /* if slave have default vlan use it */
@@ -1949,7 +1942,15 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
1949 ctx->port = port; 1942 ctx->port = port;
1950 ctx->ib_dev = &dev->ib_dev; 1943 ctx->ib_dev = &dev->ib_dev;
1951 1944
1952 for (i = 0; i < dev->dev->caps.sqp_demux; i++) { 1945 for (i = 0;
1946 i < min(dev->dev->caps.sqp_demux, (u16)(dev->dev->num_vfs + 1));
1947 i++) {
1948 struct mlx4_active_ports actv_ports =
1949 mlx4_get_active_ports(dev->dev, i);
1950
1951 if (!test_bit(port - 1, actv_ports.ports))
1952 continue;
1953
1953 ret = alloc_pv_object(dev, i, port, &ctx->tun[i]); 1954 ret = alloc_pv_object(dev, i, port, &ctx->tun[i]);
1954 if (ret) { 1955 if (ret) {
1955 ret = -ENOMEM; 1956 ret = -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 2ff428b17088..6cb85467dde7 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2323,17 +2323,24 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
2323 struct mlx4_dev *dev = ibdev->dev; 2323 struct mlx4_dev *dev = ibdev->dev;
2324 int i; 2324 int i;
2325 unsigned long flags; 2325 unsigned long flags;
2326 struct mlx4_active_ports actv_ports;
2327 unsigned int ports;
2328 unsigned int first_port;
2326 2329
2327 if (!mlx4_is_master(dev)) 2330 if (!mlx4_is_master(dev))
2328 return; 2331 return;
2329 2332
2330 dm = kcalloc(dev->caps.num_ports, sizeof *dm, GFP_ATOMIC); 2333 actv_ports = mlx4_get_active_ports(dev, slave);
2334 ports = bitmap_weight(actv_ports.ports, dev->caps.num_ports);
2335 first_port = find_first_bit(actv_ports.ports, dev->caps.num_ports);
2336
2337 dm = kcalloc(ports, sizeof(*dm), GFP_ATOMIC);
2331 if (!dm) { 2338 if (!dm) {
2332 pr_err("failed to allocate memory for tunneling qp update\n"); 2339 pr_err("failed to allocate memory for tunneling qp update\n");
2333 goto out; 2340 goto out;
2334 } 2341 }
2335 2342
2336 for (i = 0; i < dev->caps.num_ports; i++) { 2343 for (i = 0; i < ports; i++) {
2337 dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC); 2344 dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
2338 if (!dm[i]) { 2345 if (!dm[i]) {
2339 pr_err("failed to allocate memory for tunneling qp update work struct\n"); 2346 pr_err("failed to allocate memory for tunneling qp update work struct\n");
@@ -2345,9 +2352,9 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
2345 } 2352 }
2346 } 2353 }
2347 /* initialize or tear down tunnel QPs for the slave */ 2354 /* initialize or tear down tunnel QPs for the slave */
2348 for (i = 0; i < dev->caps.num_ports; i++) { 2355 for (i = 0; i < ports; i++) {
2349 INIT_WORK(&dm[i]->work, mlx4_ib_tunnels_update_work); 2356 INIT_WORK(&dm[i]->work, mlx4_ib_tunnels_update_work);
2350 dm[i]->port = i + 1; 2357 dm[i]->port = first_port + i + 1;
2351 dm[i]->slave = slave; 2358 dm[i]->slave = slave;
2352 dm[i]->do_init = do_init; 2359 dm[i]->do_init = do_init;
2353 dm[i]->dev = ibdev; 2360 dm[i]->dev = ibdev;
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index db2ea31df832..5a38e43eca65 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -627,6 +627,7 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave)
627 int port; 627 int port;
628 struct kobject *p, *t; 628 struct kobject *p, *t;
629 struct mlx4_port *mport; 629 struct mlx4_port *mport;
630 struct mlx4_active_ports actv_ports;
630 631
631 get_name(dev, name, slave, sizeof name); 632 get_name(dev, name, slave, sizeof name);
632 633
@@ -649,7 +650,11 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave)
649 goto err_ports; 650 goto err_ports;
650 } 651 }
651 652
653 actv_ports = mlx4_get_active_ports(dev->dev, slave);
654
652 for (port = 1; port <= dev->dev->caps.num_ports; ++port) { 655 for (port = 1; port <= dev->dev->caps.num_ports; ++port) {
656 if (!test_bit(port - 1, actv_ports.ports))
657 continue;
653 err = add_port(dev, port, slave); 658 err = add_port(dev, port, slave);
654 if (err) 659 if (err)
655 goto err_add; 660 goto err_add;