All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] IB/mlx4: Update HW GID table while adding vlan GID
@ 2019-11-15 15:44 Leon Romanovsky
  2019-11-19 20:04 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2019-11-15 15:44 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Danit Goldberg, RDMA mailing list, Parav Pandit, Leon Romanovsky

From: Danit Goldberg <danitg@mellanox.com>

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.

Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c    | 9 ++++++++-
 drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 211df0287f57..34055cbab38c 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -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;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 0d846fea8fdc..d188573187fa 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -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 {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH rdma-next] IB/mlx4: Update HW GID table while adding vlan GID
  2019-11-15 15:44 [PATCH rdma-next] IB/mlx4: Update HW GID table while adding vlan GID Leon Romanovsky
@ 2019-11-19 20:04 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2019-11-19 20:04 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Danit Goldberg, RDMA mailing list, Parav Pandit,
	Leon Romanovsky

On Fri, Nov 15, 2019 at 05:44:57PM +0200, Leon Romanovsky wrote:
> From: Danit Goldberg <danitg@mellanox.com>
> 
> 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.
> 
> Signed-off-by: Danit Goldberg <danitg@mellanox.com>
> Reviewed-by: Parav Pandit <parav@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-19 20:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 15:44 [PATCH rdma-next] IB/mlx4: Update HW GID table while adding vlan GID Leon Romanovsky
2019-11-19 20:04 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.