aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/main.c
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2012-06-19 04:21:44 -0400
committerRoland Dreier <roland@purestorage.com>2012-07-11 14:52:23 -0400
commit6634961c14d38ef64ec284c07aecb03d3dd03b4a (patch)
treea91bc4fa44848799c3035a9bfea1b288c2edac82 /drivers/net/ethernet/mellanox/mlx4/main.c
parent105c320f6ac37af30252577d419e47b39edb5843 (diff)
mlx4: Put physical GID and P_Key table sizes in mlx4_phys_caps struct and paravirtualize them
To allow easy paravirtualization of P_Key and GID table sizes, keep paravirtualized sizes in mlx4_dev->caps, but save the actual physical sizes from FW in struct: mlx4_dev->phys_cap. In addition, in SR-IOV mode, do the following: 1. Reduce reported P_Key table size by 1. This is done to reserve the highest P_Key index for internal use, for declaring an invalid P_Key in P_Key paravirtualization. We require a P_Key index which always contain an invalid P_Key value for this purpose (i.e., one which cannot be modified by the subnet manager). The way to do this is to reduce the P_Key table size reported to the subnet manager by 1, so that it will not attempt to access the P_Key at index #127. 2. Paravirtualize the GID table size to 1. Thus, each guest sees only a single GID (at its paravirtualized index 0). In addition, since we are paravirtualizing the GID table size to 1, we add paravirtualization of the master GID event here (i.e., we do not do ib_dispatch_event() for the GUID change event on the master, since its (only) GUID never changes). Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/main.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 58544b72bacb..5df3ac40a490 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -215,6 +215,10 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
215 for (i = 1; i <= dev->caps.num_ports; ++i) { 215 for (i = 1; i <= dev->caps.num_ports; ++i) {
216 dev->caps.vl_cap[i] = dev_cap->max_vl[i]; 216 dev->caps.vl_cap[i] = dev_cap->max_vl[i];
217 dev->caps.ib_mtu_cap[i] = dev_cap->ib_mtu[i]; 217 dev->caps.ib_mtu_cap[i] = dev_cap->ib_mtu[i];
218 dev->phys_caps.gid_phys_table_len[i] = dev_cap->max_gids[i];
219 dev->phys_caps.pkey_phys_table_len[i] = dev_cap->max_pkeys[i];
220 /* set gid and pkey table operating lengths by default
221 * to non-sriov values */
218 dev->caps.gid_table_len[i] = dev_cap->max_gids[i]; 222 dev->caps.gid_table_len[i] = dev_cap->max_gids[i];
219 dev->caps.pkey_table_len[i] = dev_cap->max_pkeys[i]; 223 dev->caps.pkey_table_len[i] = dev_cap->max_pkeys[i];
220 dev->caps.port_width_cap[i] = dev_cap->max_port_width[i]; 224 dev->caps.port_width_cap[i] = dev_cap->max_port_width[i];
@@ -498,8 +502,13 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
498 return -ENODEV; 502 return -ENODEV;
499 } 503 }
500 504
501 for (i = 1; i <= dev->caps.num_ports; ++i) 505 for (i = 1; i <= dev->caps.num_ports; ++i) {
502 dev->caps.port_mask[i] = dev->caps.port_type[i]; 506 dev->caps.port_mask[i] = dev->caps.port_type[i];
507 if (mlx4_get_slave_pkey_gid_tbl_len(dev, i,
508 &dev->caps.gid_table_len[i],
509 &dev->caps.pkey_table_len[i]))
510 return -ENODEV;
511 }
503 512
504 if (dev->caps.uar_page_size * (dev->caps.num_uars - 513 if (dev->caps.uar_page_size * (dev->caps.num_uars -
505 dev->caps.reserved_uars) > 514 dev->caps.reserved_uars) >
@@ -536,7 +545,7 @@ int mlx4_change_port_types(struct mlx4_dev *dev,
536 for (port = 1; port <= dev->caps.num_ports; port++) { 545 for (port = 1; port <= dev->caps.num_ports; port++) {
537 mlx4_CLOSE_PORT(dev, port); 546 mlx4_CLOSE_PORT(dev, port);
538 dev->caps.port_type[port] = port_types[port - 1]; 547 dev->caps.port_type[port] = port_types[port - 1];
539 err = mlx4_SET_PORT(dev, port); 548 err = mlx4_SET_PORT(dev, port, -1);
540 if (err) { 549 if (err) {
541 mlx4_err(dev, "Failed to set port %d, " 550 mlx4_err(dev, "Failed to set port %d, "
542 "aborting\n", port); 551 "aborting\n", port);
@@ -722,7 +731,7 @@ static ssize_t set_port_ib_mtu(struct device *dev,
722 mlx4_unregister_device(mdev); 731 mlx4_unregister_device(mdev);
723 for (port = 1; port <= mdev->caps.num_ports; port++) { 732 for (port = 1; port <= mdev->caps.num_ports; port++) {
724 mlx4_CLOSE_PORT(mdev, port); 733 mlx4_CLOSE_PORT(mdev, port);
725 err = mlx4_SET_PORT(mdev, port); 734 err = mlx4_SET_PORT(mdev, port, -1);
726 if (err) { 735 if (err) {
727 mlx4_err(mdev, "Failed to set port %d, " 736 mlx4_err(mdev, "Failed to set port %d, "
728 "aborting\n", port); 737 "aborting\n", port);
@@ -1173,6 +1182,17 @@ err:
1173 return -EIO; 1182 return -EIO;
1174} 1183}
1175 1184
1185static void mlx4_parav_master_pf_caps(struct mlx4_dev *dev)
1186{
1187 int i;
1188
1189 for (i = 1; i <= dev->caps.num_ports; i++) {
1190 dev->caps.gid_table_len[i] = 1;
1191 dev->caps.pkey_table_len[i] =
1192 dev->phys_caps.pkey_phys_table_len[i] - 1;
1193 }
1194}
1195
1176static int mlx4_init_hca(struct mlx4_dev *dev) 1196static int mlx4_init_hca(struct mlx4_dev *dev)
1177{ 1197{
1178 struct mlx4_priv *priv = mlx4_priv(dev); 1198 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -1212,6 +1232,9 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1212 goto err_stop_fw; 1232 goto err_stop_fw;
1213 } 1233 }
1214 1234
1235 if (mlx4_is_master(dev))
1236 mlx4_parav_master_pf_caps(dev);
1237
1215 profile = default_profile; 1238 profile = default_profile;
1216 1239
1217 icm_size = mlx4_make_profile(dev, &profile, &dev_cap, 1240 icm_size = mlx4_make_profile(dev, &profile, &dev_cap,
@@ -1500,7 +1523,8 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
1500 else 1523 else
1501 dev->caps.port_ib_mtu[port] = IB_MTU_4096; 1524 dev->caps.port_ib_mtu[port] = IB_MTU_4096;
1502 1525
1503 err = mlx4_SET_PORT(dev, port); 1526 err = mlx4_SET_PORT(dev, port, mlx4_is_master(dev) ?
1527 dev->caps.pkey_table_len[port] : -1);
1504 if (err) { 1528 if (err) {
1505 mlx4_err(dev, "Failed to set port %d, aborting\n", 1529 mlx4_err(dev, "Failed to set port %d, aborting\n",
1506 port); 1530 port);