Skip holes in GID table
cover Skip holes in GID table
From: Leon Romanovsky <[email protected]>
Changelog:
v1:
* Removed variable assignment in rdma_query_gid
* Changed special error code handling of return value from rdma_query_gid to continue search.
v0: https://lore.kernel.org/all/[email protected]
---------------------------------------------------------------------
Hi,
This short series extends rdma_query_gid() callers to skip holes in GID tables.
Thanks
Avihai Horon (3):
RDMA/core: Modify rdma_query_gid() to return accurate error codes RDMA/core: Let ib_find_gid() continue search even after empty entry RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty
entry
drivers/infiniband/core/cache.c | 12 +++++++++--- drivers/infiniband/core/cma.c | 12 +++++++++--- drivers/infiniband/core/device.c | 3 ++- 3 files changed, 20 insertions(+), 7 deletions(-)
Signature · 1 line
2.33.1
PATCH 1/3 RDMA/core: Modify rdma_query_gid() to return accurate error codes
From: Avihai Horon <[email protected]>
Modify rdma_query_gid() to return -ENOENT for empty entries. This will make error reporting more accurate and will be used in next patches.
--- drivers/infiniband/core/cache.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/infiniband/core/cache.c +9 -3
@@ -955,7 +955,7 @@ int rdma_query_gid(struct ib_device *device, u32 port_num, {struct ib_gid_table *table;unsigned long flags; -int res = -EINVAL ; +int res;if (!rdma_is_port_valid (device, port_num))return -EINVAL ;
@@ -963,9 +963,15 @@ int rdma_query_gid(struct ib_device *device, u32 port_num, table =rdma_gid_table (device, port_num);read_lock_irqsave (&table->rwlock, flags); -if (index <0 || index >= table->sz || - !is_gid_entry_valid (table->data_vec[index])) +if (index <0 || index >= table->sz) { + res = -EINVAL goto done; + } + +if (!is_gid_entry_valid (table->data_vec[index])) { + res = -ENOENT ; + goto done; + }memcpy (gid, &table->data_vec[index]->attr.gid,sizeof (*gid)); res =0 ;
Signature · 1 line
2.33.1
PATCH 2/3 RDMA/core: Let ib_find_gid() continue search even after empty entry
In reply to Leon RomanovskyFrom: Avihai Horon <[email protected]>
Currently, ib_find_gid() will stop searching after encountering the first empty GID table entry. This behavior is wrong since neither IB nor RoCE spec enforce tightly packed GID tables.
For example, when a valid GID entry exists at index N, and if a GID entry is empty at index N-1, ib_find_gid() will fail to find the valid entry.
Fix it by making ib_find_gid() continue searching even after encountering missing entries.
--- drivers/infiniband/core/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +2 -1
@@ -2461,7 +2461,8 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid, ++i) { ret =rdma_query_gid (device, port, i, &tmp_gid);if (ret) -return ret; +continue ; +if (!memcmp (&tmp_gid, gid,sizeof *gid)) { *port_num = port;if (index)
Signature · 1 line
2.33.1
PATCH 3/3 RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry
In reply to Leon RomanovskyFrom: Avihai Horon <[email protected]>
Currently, when cma_resolve_ib_dev() searches for a matching GID it will stop searching after encountering the first empty GID table entry. This behavior is wrong since neither IB nor RoCE spec enforce tightly packed GID tables.
For example, when the matching valid GID entry exists at index N, and if a GID entry is empty at index N-1, cma_resolve_ib_dev() will fail to find the matching valid entry.
Fix it by making cma_resolve_ib_dev() continue searching even after encountering missing entries.
--- drivers/infiniband/core/cma.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/infiniband/core/cma.c +9 -3
@@ -766,6 +766,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)unsigned int p;u16 pkey, index;enum ib_port_state port_state; +int ret;int i; cma_dev =NULL ;
@@ -784,9 +785,14 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)if (ib_get_cached_port_state (cur_dev->device, p, &port_state))continue ; -for (i =0 ; !rdma_query_gid (cur_dev->device, - p, i, &gid); - i++) { + +for (i =0 ; i < cur_dev->device->port_data[p].immutable.gid_tbl_len; + ++i) { + ret =rdma_query_gid (cur_dev->device, p, i, + &gid); +if (ret) +continue ; +if (!memcmp (&gid, dgid,sizeof (gid))) { cma_dev = cur_dev; sgid = gid;
Signature · 1 line
2.33.1
Re: [PATCH rdma-next v1 1/3] RDMA/core: Modify rdma_query_gid() to return accurate error codes
In reply to Leon RomanovskyQuoted 26 lines · Leon Romanovsky
From: Avihai Horon <[email protected]>
Modify
rdma_query_gid()to return-ENOENTfor empty entries. This will make error reporting more accurate and will be used in next patches.Signed-off-by Avihai Horon <[email protected]>Reviewed-by Mark Zhang <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/core/cache.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/infiniband/core/cache.c +1
-1@@ -955,7 +955,7 @@ int rdma_query_gid(struct ib_device *device, u32 port_num, {struct ib_gid_table *table;unsigned long flags; -int res = -EINVAL ; +int res;if (!rdma_is_port_valid (device, port_num))return -EINVAL ;
drivers/infiniband/core/cache.c int rdma_query_gid(struct ib_device *device, u32 port_num, · line 967
Quoted 7 lines
drivers/infiniband/core/cache.c +2
-2@@ -963,9 +963,15 @@ int rdma_query_gid(struct ib_device *device, u32 port_num, table =rdma_gid_table (device, port_num);read_lock_irqsave (&table->rwlock, flags); -if (index <0 || index >= table->sz || - !is_gid_entry_valid (table->data_vec[index])) +if (index <0 || index >= table->sz) { + res = -EINVAL
Jason,
I made stupid mistake here, and missed ";".
Can you fix it locally?
Thanks
Quoted 13 lines
drivers/infiniband/core/cache.c +6
-0goto done; + } + +if (!is_gid_entry_valid (table->data_vec[index])) { + res = -ENOENT ; + goto done; + }memcpy (gid, &table->data_vec[index]->attr.gid,sizeof (*gid)); res =0 ;Signature · 1 line
2.33.1
Quoted 16 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Changelog:
v1:
* Removed variable assignment inrdma_query_gid
* Changed special error code handling of return value fromrdma_query_gidto continue search.
v0: https://lore.kernel.org/all/[email protected]---------------------------------------------------------------------
Hi,
This short series extends
rdma_query_gid()callers to skip holes in GID tables.
Quoted 7 lines
Thanks
Avihai Horon (3):
RDMA/core: Modifyrdma_query_gid()to return accurate error codes RDMA/core: Letib_find_gid()continue search even after empty entry RDMA/cma: Letcma_resolve_ib_dev()continue search even after empty
entry
Applied to for-next, thanks
Jason