aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2012-08-03 04:40:56 -0400
committerRoland Dreier <roland@purestorage.com>2012-09-30 23:33:43 -0400
commitafa8fd1db9f295a0c4130bc6d87bf8b05bdd0523 (patch)
tree725c4a2c6a9044ff9ac79e4f6a863393756953f0 /drivers
parent026149cbaada391d98f1cbec47c488cb548f753a (diff)
mlx4: Paravirtualize Node Guids for slaves
This is necessary in order to support > 1 VF/PF in a VM for software that uses the node guid as a discriminator, such as librdmacm. Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c14
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h1
5 files changed, 51 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index b91b4865d635..603a114b3dfe 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -35,6 +35,7 @@
35#include <rdma/ib_sa.h> 35#include <rdma/ib_sa.h>
36#include <rdma/ib_cache.h> 36#include <rdma/ib_cache.h>
37 37
38#include <linux/random.h>
38#include <linux/mlx4/cmd.h> 39#include <linux/mlx4/cmd.h>
39#include <linux/gfp.h> 40#include <linux/gfp.h>
40#include <rdma/ib_pma.h> 41#include <rdma/ib_pma.h>
@@ -89,6 +90,12 @@ static void handle_lid_change_event(struct mlx4_ib_dev *dev, u8 port_num);
89static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num, 90static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
90 int block, u32 change_bitmap); 91 int block, u32 change_bitmap);
91 92
93__be64 mlx4_ib_gen_node_guid(void)
94{
95#define NODE_GUID_HI ((u64) (((u64)IB_OPENIB_OUI) << 40))
96 return cpu_to_be64(NODE_GUID_HI | random32());
97}
98
92__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx) 99__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
93{ 100{
94 return cpu_to_be64(atomic_inc_return(&ctx->tid)) | 101 return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
@@ -1962,6 +1969,13 @@ int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
1962 return 0; 1969 return 0;
1963 } 1970 }
1964 1971
1972 for (i = 0; i < dev->dev->caps.sqp_demux; i++) {
1973 if (i == mlx4_master_func_num(dev->dev))
1974 mlx4_put_slave_node_guid(dev->dev, i, dev->ib_dev.node_guid);
1975 else
1976 mlx4_put_slave_node_guid(dev->dev, i, mlx4_ib_gen_node_guid());
1977 }
1978
1965 err = mlx4_ib_init_alias_guid_service(dev); 1979 err = mlx4_ib_init_alias_guid_service(dev);
1966 if (err) { 1980 if (err) {
1967 mlx4_ib_warn(&dev->ib_dev, "Failed init alias guid process.\n"); 1981 mlx4_ib_warn(&dev->ib_dev, "Failed init alias guid process.\n");
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index e57a220a4d55..e04cbc9a54a5 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -723,4 +723,7 @@ int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *device) ;
723 723
724void mlx4_ib_device_unregister_sysfs(struct mlx4_ib_dev *device); 724void mlx4_ib_device_unregister_sysfs(struct mlx4_ib_dev *device);
725 725
726__be64 mlx4_ib_gen_node_guid(void);
727
728
726#endif /* MLX4_IB_H */ 729#endif /* MLX4_IB_H */
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 78fdbd653fa9..90774b7e47a4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -696,6 +696,7 @@ static int mlx4_MAD_IFC_wrapper(struct mlx4_dev *dev, int slave,
696 struct ib_smp *outsmp = outbox->buf; 696 struct ib_smp *outsmp = outbox->buf;
697 __be16 *outtab = (__be16 *)(outsmp->data); 697 __be16 *outtab = (__be16 *)(outsmp->data);
698 __be32 slave_cap_mask; 698 __be32 slave_cap_mask;
699 __be64 slave_node_guid;
699 port = vhcr->in_modifier; 700 port = vhcr->in_modifier;
700 701
701 if (smp->base_version == 1 && 702 if (smp->base_version == 1 &&
@@ -755,6 +756,16 @@ static int mlx4_MAD_IFC_wrapper(struct mlx4_dev *dev, int slave,
755 } 756 }
756 return err; 757 return err;
757 } 758 }
759 if (smp->attr_id == IB_SMP_ATTR_NODE_INFO) {
760 err = mlx4_cmd_box(dev, inbox->dma, outbox->dma,
761 vhcr->in_modifier, vhcr->op_modifier,
762 vhcr->op, MLX4_CMD_TIME_CLASS_C, MLX4_CMD_NATIVE);
763 if (!err) {
764 slave_node_guid = mlx4_get_slave_node_guid(dev, slave);
765 memcpy(outsmp->data + 12, &slave_node_guid, 8);
766 }
767 return err;
768 }
758 } 769 }
759 } 770 }
760 if (slave != mlx4_master_func_num(dev) && 771 if (slave != mlx4_master_func_num(dev) &&
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 2294b7173180..76f69fdd01d5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -435,6 +435,28 @@ void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port, int i, int
435} 435}
436EXPORT_SYMBOL(mlx4_sync_pkey_table); 436EXPORT_SYMBOL(mlx4_sync_pkey_table);
437 437
438void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid)
439{
440 struct mlx4_priv *priv = container_of(dev, struct mlx4_priv, dev);
441
442 if (!mlx4_is_master(dev))
443 return;
444
445 priv->slave_node_guids[slave] = guid;
446}
447EXPORT_SYMBOL(mlx4_put_slave_node_guid);
448
449__be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave)
450{
451 struct mlx4_priv *priv = container_of(dev, struct mlx4_priv, dev);
452
453 if (!mlx4_is_master(dev))
454 return 0;
455
456 return priv->slave_node_guids[slave];
457}
458EXPORT_SYMBOL(mlx4_get_slave_node_guid);
459
438int mlx4_is_slave_active(struct mlx4_dev *dev, int slave) 460int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
439{ 461{
440 struct mlx4_priv *priv = mlx4_priv(dev); 462 struct mlx4_priv *priv = mlx4_priv(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 399793a23457..4b1fbd84a68f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -810,6 +810,7 @@ struct mlx4_priv {
810 int reserved_mtts; 810 int reserved_mtts;
811 int fs_hash_mode; 811 int fs_hash_mode;
812 u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS]; 812 u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
813 __be64 slave_node_guids[MLX4_MFUNC_MAX];
813 814
814}; 815};
815 816