net/mlx4_core: Initialize IB port capabilities for all slaves
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Tue, 19 Jun 2012 08:21:41 +0000 (11:21 +0300)
committerRoland Dreier <roland@purestorage.com>
Tue, 10 Jul 2012 16:57:06 +0000 (09:57 -0700)
With IB SR-IOV, each slave has its own separate copy of the port
capabilities flags.  For example, the master can run a subnet manager
(which causes the IsSM bit to be set in the master's port
capabilities) without affecting the port capabilities seen by the
slaves (the IsSM bit will be seen as cleared in the slaves).

Also add a static inline mlx4_master_func_num() to enhance readability
of the code.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/net/ethernet/mellanox/mlx4/main.c
include/linux/mlx4/device.h

index a0313de122de2338684035d51f29bbc5a8ae4e34..83afb1541a746511fe4ba662fd23a6685188ac0b 100644 (file)
@@ -1477,6 +1477,17 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
                                          "with caps = 0\n", port, err);
                        dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
 
+                       /* initialize per-slave default ib port capabilities */
+                       if (mlx4_is_master(dev)) {
+                               int i;
+                               for (i = 0; i < dev->num_slaves; i++) {
+                                       if (i == mlx4_master_func_num(dev))
+                                               continue;
+                                       priv->mfunc.master.slave_state[i].ib_cap_mask[port] =
+                                                       ib_port_default_caps;
+                               }
+                       }
+
                        if (mlx4_is_mfunc(dev))
                                dev->caps.port_ib_mtu[port] = IB_MTU_2048;
                        else
index 560b2201519f0216986bcf6858e4bb1c028f2d3b..7fbdc89de495bdacbde05dfa2f3a964095d65c4e 100644 (file)
@@ -633,6 +633,11 @@ struct mlx4_init_port_param {
 
 void handle_port_mgmt_change_event(struct work_struct *work);
 
+static inline int mlx4_master_func_num(struct mlx4_dev *dev)
+{
+       return dev->caps.function;
+}
+
 static inline int mlx4_is_master(struct mlx4_dev *dev)
 {
        return dev->flags & MLX4_FLAG_MASTER;