Commit ff3195b3 authored by Danit Goldberg's avatar Danit Goldberg Committed by Jason Gunthorpe

IB/mlx4: Update HW GID table while adding vlan GID

When adding a new GID compare the vlan along with the GID and type. This
allows vlan's to have GIDs that alias each other, such as the default
GID. Otherwise they the GID cache view can become inconsistent with the HW
view.

Link: https://lore.kernel.org/r/20191115154457.247763-1-leon@kernel.orgSigned-off-by: default avatarDanit Goldberg <danitg@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 9067f2f0
...@@ -256,6 +256,8 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context) ...@@ -256,6 +256,8 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
int hw_update = 0; int hw_update = 0;
int i; int i;
struct gid_entry *gids = NULL; struct gid_entry *gids = NULL;
u16 vlan_id = 0xffff;
u8 mac[ETH_ALEN];
if (!rdma_cap_roce_gid_table(attr->device, attr->port_num)) if (!rdma_cap_roce_gid_table(attr->device, attr->port_num))
return -EINVAL; return -EINVAL;
...@@ -266,12 +268,16 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context) ...@@ -266,12 +268,16 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
if (!context) if (!context)
return -EINVAL; return -EINVAL;
ret = rdma_read_gid_l2_fields(attr, &vlan_id, &mac[0]);
if (ret)
return ret;
port_gid_table = &iboe->gids[attr->port_num - 1]; port_gid_table = &iboe->gids[attr->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, if (!memcmp(&port_gid_table->gids[i].gid,
&attr->gid, sizeof(attr->gid)) && &attr->gid, sizeof(attr->gid)) &&
port_gid_table->gids[i].gid_type == attr->gid_type) { port_gid_table->gids[i].gid_type == attr->gid_type &&
port_gid_table->gids[i].vlan_id == vlan_id) {
found = i; found = i;
break; break;
} }
...@@ -291,6 +297,7 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context) ...@@ -291,6 +297,7 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
memcpy(&port_gid_table->gids[free].gid, memcpy(&port_gid_table->gids[free].gid,
&attr->gid, sizeof(attr->gid)); &attr->gid, sizeof(attr->gid));
port_gid_table->gids[free].gid_type = attr->gid_type; port_gid_table->gids[free].gid_type = attr->gid_type;
port_gid_table->gids[free].vlan_id = vlan_id;
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;
......
...@@ -508,6 +508,7 @@ struct gid_entry { ...@@ -508,6 +508,7 @@ struct gid_entry {
union ib_gid gid; union ib_gid gid;
enum ib_gid_type gid_type; enum ib_gid_type gid_type;
struct gid_cache_context *ctx; struct gid_cache_context *ctx;
u16 vlan_id;
}; };
struct mlx4_port_gid_table { struct mlx4_port_gid_table {
......
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