Skip to contentSkip to conversation

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

PATCH In review Leon Romanovsky 2 participants 2 messages Nov 15, 2019 – Nov 19, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Danit Goldberg <[email protected]>

While adding new GID, besides comparing GID and type, compare also vlan id, so vlan GIDs will also be updated in HW GID table although they have same GID as the default GID.

---
 drivers/infiniband/hw/mlx4/main.c    | 9 ++++++++-
 drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/main.c +8 -1
index 211df0287f57..34055cbab38c 100644
@@ -256,6 +256,8 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
 	int hw_update = 0;
 	int i;
 	struct gid_entry *gids = NULL;
+	u16 vlan_id = 0xffff;
+	u8 mac[ETH_ALEN];
 
 	if (!rdma_cap_roce_gid_table(attr->device, attr->port_num))
 		return -EINVAL;
@@ -266,12 +268,16 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
 	if (!context)
 		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];
 	spin_lock_bh(&iboe->lock);
 	for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) {
 		if (!memcmp(&port_gid_table->gids[i].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;
 			break;
 		}
@@ -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,
 				       &attr->gid, sizeof(attr->gid));
 				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->refcount = 1;
 				hw_update = 1;
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -0
index 0d846fea8fdc..d188573187fa 100644
@@ -508,6 +508,7 @@ struct gid_entry {
 	union ib_gid	gid;
 	enum ib_gid_type gid_type;
 	struct gid_cache_context *ctx;
+	u16 vlan_id;
 };
 
 struct mlx4_port_gid_table {
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Leon Romanovsky

From: Danit Goldberg <[email protected]>

While adding new GID, besides comparing GID and type, compare also vlan id, so vlan GIDs will also be updated in HW GID table although they have same GID as the default GID.

Quoted 7 lines
---
 drivers/infiniband/hw/mlx4/main.c    | 9 ++++++++-
 drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

I'm going to apply this because of the bug fix, but this design in mlx4 looks wrong to me? The core gid cache is supposed to manage the gid table completely, and the driver should not be doing searching when the core says to change a table entry. What is going on here?

The core code already removes duplicates

Parav?

Jason