From: Jason Gunthorpe <jgg@ziepe.ca>
To: Selvin Xavier <selvin.xavier@broadcom.com>
Cc: dledford@redhat.com, linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next v3 1/2] RDMA/core: Add helper function to retrieve driver gid context from gid attr
Date: Tue, 18 Feb 2020 11:42:37 -0400 [thread overview]
Message-ID: <20200218154237.GE31668@ziepe.ca> (raw)
In-Reply-To: <1582006810-32174-2-git-send-email-selvin.xavier@broadcom.com>
On Mon, Feb 17, 2020 at 10:20:09PM -0800, Selvin Xavier wrote:
> Adding a helper function to retrieve the driver gid context
> from the gid attr.
>
> Suggested-by: Jason Gunthorpe <jgg@mellanox.com>
> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
> drivers/infiniband/core/cache.c | 41 +++++++++++++++++++++++++++++++++++++++++
> include/rdma/ib_cache.h | 1 +
> 2 files changed, 42 insertions(+)
>
> diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
> index 17bfedd..1b73a71 100644
> +++ b/drivers/infiniband/core/cache.c
> @@ -973,6 +973,47 @@ 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 vendor drivers GID HW
> + * context corresponding to SGID attr. It takes reference to the GID
> + * attribute and this need to be released by the caller using
> + * rdma_put_gid_attr
> + *
> + * Returns HW context on success or NULL on error
> + *
> + */
> +void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr)
> +{
> + struct ib_gid_table_entry *entry =
> + container_of(attr, struct ib_gid_table_entry, attr);
> + struct ib_device *device = entry->attr.device;
> + u8 port_num = entry->attr.port_num;
> + struct ib_gid_table *table;
> + unsigned long flags;
> + void *context = NULL;
> +
> + if (!rdma_is_port_valid(device, port_num))
> + return NULL;
> +
> + table = rdma_gid_table(device, port_num);
> + read_lock_irqsave(&table->rwlock, flags);
> +
> + if (attr->index < 0 || attr->index >= table->sz ||
> + !is_gid_entry_valid(table->data_vec[attr->index]))
> + goto done;
Why all this validation and locking? ib_gid_attrs are only created by
the core code..
> + get_gid_entry(entry);
And why a get? Surely it is invalid to call this function without a
get already held?
Jason
next prev parent reply other threads:[~2020-02-18 15:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 6:20 [PATCH for-next v3 0/2] Retrieve HW GID context from ib_gid_attr Selvin Xavier
2020-02-18 6:20 ` [PATCH for-next v3 1/2] RDMA/core: Add helper function to retrieve driver gid context from gid attr Selvin Xavier
2020-02-18 15:42 ` Jason Gunthorpe [this message]
2020-02-18 16:42 ` Selvin Xavier
2020-02-18 20:03 ` Jason Gunthorpe
2020-02-19 6:13 ` Selvin Xavier
2020-02-18 6:20 ` [PATCH for-next v3 2/2] RDMA/bnxt_re: Use rdma_read_gid_hw_context to retrieve HW gid index Selvin Xavier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200218154237.GE31668@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=dledford@redhat.com \
--cc=linux-rdma@vger.kernel.org \
--cc=selvin.xavier@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.