]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/mlx4: Generate alias GUID for slaves
authorYuval Shaia <yuval.shaia@oracle.com>
Thu, 26 May 2016 16:25:19 +0000 (09:25 -0700)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Tue, 31 May 2016 16:03:35 +0000 (09:03 -0700)
Generate alias GUID by changing the fourth byte to be the GUID index in the
port GUID table.

This is porting of a work done in uek2 for Oracle purpose only.

Orabug: 23292164

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
drivers/infiniband/hw/mlx4/alias_GUID.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/mlx4_ib.h

index 0f00204d2ecea0e19f0a9917431e4bb8cbbdfa49..5ed29772ba6a367eb038f23b9d025a7d281084ef 100644 (file)
@@ -72,6 +72,45 @@ struct mlx4_next_alias_guid_work {
 static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port,
                                     int *resched_delay_sec);
 
+/*
+ * Generate GUID by changing the fourth byte to be the GUID index in the
+ * port GUID table.
+ *
+ * For example:
+ *     00:02:C9:03:YY:XX:XX:XX
+ * Where:
+ *     00:02:C9:03 - Mellanox prefix GUID
+ *     YY          - is the GUID index in the GUID table
+ *     XX:XX:XX    - rest of the original GUID
+ */
+__be64 generate_guid(struct mlx4_ib_dev *dev, int port_num, int record_index)
+{
+       static union ib_gid gid = {.raw={0}};
+       __be64 gen_guid = 0;
+       static int queried_port = 1;
+
+       /* If the gid of this port was not already queried -
+          query and act accordingly */
+       if ((!gid.global.interface_id || (queried_port != port_num)) &&
+           dev->ib_dev.query_gid(&dev->ib_dev, port_num, 0, &gid))
+               goto exit;
+
+       if (mlx4_ib_guid_gen_magic < 0x64)
+               goto exit;
+
+       queried_port = port_num;
+       gen_guid = gid.global.interface_id;
+       ((u8 *)(&gen_guid))[4] = mlx4_ib_guid_gen_magic +
+                                (record_index % NUM_ALIAS_GUID_IN_REC);
+
+       pr_debug("record: %d, port_guid: 0x%llx generated: 0x%llx",
+                record_index, be64_to_cpu(gid.global.interface_id),
+                be64_to_cpu(gen_guid));
+
+exit:
+       return gen_guid;
+}
+
 void mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev, int block_num,
                                         u8 port_num, u8 *p_data)
 {
@@ -832,6 +871,7 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
        int ret = 0;
        int i, j;
        union ib_gid gid;
+       __be64 gen_guid;
 
        if (!mlx4_is_master(dev->dev))
                return 0;
@@ -868,6 +908,19 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
                if (mlx4_ib_sm_guid_assign)
                        for (j = 1; j < NUM_ALIAS_GUID_PER_PORT; j++)
                                mlx4_set_admin_guid(dev->dev, 0, j, i + 1);
+               else {
+                       for (j = 0; j < NUM_ALIAS_GUID_PER_PORT; j++) {
+                               gen_guid = generate_guid(dev, i + 1, j);
+                               if (!gen_guid)
+                                       continue;
+                               mlx4_set_admin_guid(dev->dev, gen_guid, j,
+                                                   i + 1);
+                               *(__be64 *)&dev->sriov.alias_guid.ports_guid[i].
+                                       all_rec_per_port[j].
+                                       all_recs[(j % 8) * GUID_REC_SIZE] =
+                                               gen_guid;
+                       }
+               }
                for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT; j++)
                        invalidate_guid_record(dev, i + 1, j);
 
index 4feb311d4eaef57c2e678192c887fe5a67d27674..c0a5c532049ed020815ea3659d59e772d8d4b816 100644 (file)
@@ -71,6 +71,11 @@ int mlx4_ib_sm_guid_assign = 0;
 module_param_named(sm_guid_assign, mlx4_ib_sm_guid_assign, int, 0444);
 MODULE_PARM_DESC(sm_guid_assign, "Enable SM alias_GUID assignment if sm_guid_assign > 0 (Default: 0)");
 
+int mlx4_ib_guid_gen_magic = 90;
+module_param_named(guid_gen_magic, mlx4_ib_guid_gen_magic, int, 0444);
+MODULE_PARM_DESC(guid_gen_magic,
+                "Magic num to add to the generated guid, default is 100.");
+
 static const char mlx4_ib_version[] =
        DRV_NAME ": Mellanox ConnectX InfiniBand driver v"
        DRV_VERSION " (" DRV_RELDATE ")\n";
index 31ea8862c2b06bfcdfbfa7330fcf1837360d3895..7b6c11bd59d45ca7d4bb766487ff23e15dc77d1c 100644 (file)
@@ -71,6 +71,9 @@ enum {
 /*module param to indicate if SM assigns the alias_GUID*/
 extern int mlx4_ib_sm_guid_assign;
 
+/*module param for generating even GUIDs, Oracle only*/
+extern int mlx4_ib_guid_gen_magic;
+
 #define MLX4_IB_UC_STEER_QPN_ALIGN 1
 #define MLX4_IB_UC_MAX_NUM_QPS     (256 * 1024)
 struct mlx4_ib_ucontext {