Skip to content

Commit

Permalink
RDMA/core: Add helper function to retrieve driver gid context from gi…
Browse files Browse the repository at this point in the history
…d attr

Adding a helper function to retrieve the driver gid context from the gid
attr.

Link: https://lore.kernel.org/r/1582107594-5180-2-git-send-email-selvin.xavier@broadcom.com
Suggested-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Selvin Xavier authored and Jason Gunthorpe committed Feb 19, 2020
1 parent 167b95e commit 779820c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/infiniband/core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,23 @@ int rdma_query_gid(struct ib_device *device, u8 port_num,
}
EXPORT_SYMBOL(rdma_query_gid);

/**
* rdma_read_gid_hw_context - Read the HW GID context from GID attribute
* @attr: Potinter to the GID attribute
*
* rdma_read_gid_hw_context() reads the drivers GID HW context corresponding
* to the SGID attr. Callers are required to already be holding the reference
* to an existing GID entry.
*
* Returns the HW GID context
*
*/
void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr)
{
return container_of(attr, struct ib_gid_table_entry, attr)->context;
}
EXPORT_SYMBOL(rdma_read_gid_hw_context);

/**
* rdma_find_gid - Returns SGID attributes if the matching GID is found.
* @device: The device to query.
Expand Down
1 change: 1 addition & 0 deletions include/rdma/ib_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

int rdma_query_gid(struct ib_device *device, u8 port_num, int index,
union ib_gid *gid);
void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
const union ib_gid *gid,
enum ib_gid_type gid_type,
Expand Down

0 comments on commit 779820c

Please sign in to comment.