Skip to content

Commit 779820c

Browse files
selvintxavierjgunthorpe
authored andcommitted
RDMA/core: Add helper function to retrieve driver gid context from gid attr
Adding a helper function to retrieve the driver gid context from the gid attr. Link: https://lore.kernel.org/r/[email protected] Suggested-by: Jason Gunthorpe <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 167b95e commit 779820c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/infiniband/core/cache.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,23 @@ int rdma_query_gid(struct ib_device *device, u8 port_num,
972972
}
973973
EXPORT_SYMBOL(rdma_query_gid);
974974

975+
/**
976+
* rdma_read_gid_hw_context - Read the HW GID context from GID attribute
977+
* @attr: Potinter to the GID attribute
978+
*
979+
* rdma_read_gid_hw_context() reads the drivers GID HW context corresponding
980+
* to the SGID attr. Callers are required to already be holding the reference
981+
* to an existing GID entry.
982+
*
983+
* Returns the HW GID context
984+
*
985+
*/
986+
void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr)
987+
{
988+
return container_of(attr, struct ib_gid_table_entry, attr)->context;
989+
}
990+
EXPORT_SYMBOL(rdma_read_gid_hw_context);
991+
975992
/**
976993
* rdma_find_gid - Returns SGID attributes if the matching GID is found.
977994
* @device: The device to query.

include/rdma/ib_cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
int rdma_query_gid(struct ib_device *device, u8 port_num, int index,
4141
union ib_gid *gid);
42+
void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
4243
const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
4344
const union ib_gid *gid,
4445
enum ib_gid_type gid_type,

0 commit comments

Comments
 (0)