Commit b699a859 authored by Moni Shoua's avatar Moni Shoua Committed by Doug Ledford

IB/mlx4: Add gid_type to GID properties

IB core driver adds a property of type to struct ib_gid_attr.
The mlx4 driver should take that in consideration when modifying or
querying the hardware gid table.
Signed-off-by: default avatarMoni Shoua <monis@mellanox.com>
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent d8ae9141
...@@ -215,7 +215,8 @@ static int mlx4_ib_add_gid(struct ib_device *device, ...@@ -215,7 +215,8 @@ static int mlx4_ib_add_gid(struct ib_device *device,
port_gid_table = &iboe->gids[port_num - 1]; port_gid_table = &iboe->gids[port_num - 1];
spin_lock_bh(&iboe->lock); spin_lock_bh(&iboe->lock);
for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) { for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) {
if (!memcmp(&port_gid_table->gids[i].gid, gid, sizeof(*gid))) { if (!memcmp(&port_gid_table->gids[i].gid, gid, sizeof(*gid)) &&
(port_gid_table->gids[i].gid_type == attr->gid_type)) {
found = i; found = i;
break; break;
} }
...@@ -233,6 +234,7 @@ static int mlx4_ib_add_gid(struct ib_device *device, ...@@ -233,6 +234,7 @@ static int mlx4_ib_add_gid(struct ib_device *device,
} else { } else {
*context = port_gid_table->gids[free].ctx; *context = port_gid_table->gids[free].ctx;
memcpy(&port_gid_table->gids[free].gid, gid, sizeof(*gid)); memcpy(&port_gid_table->gids[free].gid, gid, sizeof(*gid));
port_gid_table->gids[free].gid_type = attr->gid_type;
port_gid_table->gids[free].ctx->real_index = free; port_gid_table->gids[free].ctx->real_index = free;
port_gid_table->gids[free].ctx->refcount = 1; port_gid_table->gids[free].ctx->refcount = 1;
hw_update = 1; hw_update = 1;
...@@ -248,8 +250,10 @@ static int mlx4_ib_add_gid(struct ib_device *device, ...@@ -248,8 +250,10 @@ static int mlx4_ib_add_gid(struct ib_device *device,
if (!gids) { if (!gids) {
ret = -ENOMEM; ret = -ENOMEM;
} else { } else {
for (i = 0; i < MLX4_MAX_PORT_GIDS; i++) for (i = 0; i < MLX4_MAX_PORT_GIDS; i++) {
memcpy(&gids[i].gid, &port_gid_table->gids[i].gid, sizeof(union ib_gid)); memcpy(&gids[i].gid, &port_gid_table->gids[i].gid, sizeof(union ib_gid));
gids[i].gid_type = port_gid_table->gids[i].gid_type;
}
} }
} }
spin_unlock_bh(&iboe->lock); spin_unlock_bh(&iboe->lock);
...@@ -325,6 +329,7 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev, ...@@ -325,6 +329,7 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
int i; int i;
int ret; int ret;
unsigned long flags; unsigned long flags;
struct ib_gid_attr attr;
if (port_num > MLX4_MAX_PORTS) if (port_num > MLX4_MAX_PORTS)
return -EINVAL; return -EINVAL;
...@@ -335,10 +340,13 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev, ...@@ -335,10 +340,13 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
if (!rdma_cap_roce_gid_table(&ibdev->ib_dev, port_num)) if (!rdma_cap_roce_gid_table(&ibdev->ib_dev, port_num))
return index; return index;
ret = ib_get_cached_gid(&ibdev->ib_dev, port_num, index, &gid, NULL); ret = ib_get_cached_gid(&ibdev->ib_dev, port_num, index, &gid, &attr);
if (ret) if (ret)
return ret; return ret;
if (attr.ndev)
dev_put(attr.ndev);
if (!memcmp(&gid, &zgid, sizeof(gid))) if (!memcmp(&gid, &zgid, sizeof(gid)))
return -EINVAL; return -EINVAL;
...@@ -346,7 +354,8 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev, ...@@ -346,7 +354,8 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
port_gid_table = &iboe->gids[port_num - 1]; port_gid_table = &iboe->gids[port_num - 1];
for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i)
if (!memcmp(&port_gid_table->gids[i].gid, &gid, sizeof(gid))) { if (!memcmp(&port_gid_table->gids[i].gid, &gid, sizeof(gid)) &&
attr.gid_type == port_gid_table->gids[i].gid_type) {
ctx = port_gid_table->gids[i].ctx; ctx = port_gid_table->gids[i].ctx;
break; break;
} }
......
...@@ -478,6 +478,7 @@ struct gid_cache_context { ...@@ -478,6 +478,7 @@ struct gid_cache_context {
struct gid_entry { struct gid_entry {
union ib_gid gid; union ib_gid gid;
enum ib_gid_type gid_type;
struct gid_cache_context *ctx; struct gid_cache_context *ctx;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment