Adding a helper function to retrieve the driver gid context from the gid index. Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Signed-off-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx> --- drivers/infiniband/core/cache.c | 18 ++++++++++++++++++ include/rdma/ib_cache.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index e9a409d..f336467 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -859,6 +859,24 @@ int ib_find_cached_gid(struct ib_device *device, } EXPORT_SYMBOL(ib_find_cached_gid); +void *ib_get_gid_context_by_index(struct ib_device *device, + u8 port_num, + u16 index) +{ + struct ib_gid_table *table; + + if (!rdma_is_port_valid(device, port_num)) + return NULL; + + table = device->cache.ports[port_num - rdma_start_port(device)].gid; + + if (index < 0 || index >= table->sz) + return NULL; + + return table->data_vec[index].context; +} +EXPORT_SYMBOL(ib_get_gid_context_by_index); + int ib_find_gid_by_filter(struct ib_device *device, const union ib_gid *gid, u8 port_num, diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h index 385ec88..e5727e9 100644 --- a/include/rdma/ib_cache.h +++ b/include/rdma/ib_cache.h @@ -105,6 +105,19 @@ int ib_find_gid_by_filter(struct ib_device *device, const struct ib_gid_attr *, void *), void *context, u16 *index); + +/** + * ib_get_gid_context_by_index - Returns HW driver's GID context for the + * specified gid index + * @device: The device to query + * @port_num: The port number of the device where the GID value belongs + * @index: The index into the cached GID table + */ + +void *ib_get_gid_context_by_index(struct ib_device *device, + u8 port_num, + u16 index); + /** * ib_get_cached_pkey - Returns a cached PKey table entry * @device: The device to query. -- 2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html