All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Avihai Horon <avihaih@nvidia.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next 3/4] RDMA/core: Introduce new GID table query API
Date: Sun, 13 Sep 2020 11:02:33 +0300	[thread overview]
Message-ID: <20200913080233.GE35718@unreal> (raw)
In-Reply-To: <20200911195221.GS904879@nvidia.com>

On Fri, Sep 11, 2020 at 04:52:21PM -0300, Jason Gunthorpe wrote:
> On Thu, Sep 10, 2020 at 05:22:03PM +0300, Leon Romanovsky wrote:
> > From: Avihai Horon <avihaih@nvidia.com>
> >
> > Introduce rdma_query_gid_table which enables querying all the GID tables
> > of a given device and copying the attributes of all valid GID entries to
> > a provided buffer.
> >
> > This API provides a faster way to query a GID table using single call and
> > will be used in libibverbs to improve current approach that requires
> > multiple calls to open, close and read multiple sysfs files for a single
> > GID table entry.
> >
> > Signed-off-by: Avihai Horon <avihaih@nvidia.com>
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> >  drivers/infiniband/core/cache.c         | 93 +++++++++++++++++++++++++
> >  include/rdma/ib_cache.h                 |  5 ++
> >  include/uapi/rdma/ib_user_ioctl_verbs.h |  8 +++
> >  3 files changed, 106 insertions(+)
> >
> > diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
> > index cf49ac0b0aa6..175e229eccd3 100644
> > +++ b/drivers/infiniband/core/cache.c
> > @@ -1247,6 +1247,99 @@ rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index)
> >  }
> >  EXPORT_SYMBOL(rdma_get_gid_attr);
> >
> > +/**
> > + * rdma_get_ndev_ifindex - Reads ndev ifindex of the given gid attr.
> > + * @gid_attr: Pointer to the GID attribute.
> > + * @ndev_ifindex: Pointer through which the ndev ifindex is returned.
> > + *
> > + * Returns 0 on success or appropriate error code. The netdevice must be in UP
> > + * state.
> > + */
> > +int rdma_get_ndev_ifindex(const struct ib_gid_attr *gid_attr, u32 *ndev_ifindex)
> > +{
> > +	struct net_device *ndev;
> > +	int ret = 0;
> > +
> > +	if (rdma_protocol_ib(gid_attr->device, gid_attr->port_num)) {
> > +		*ndev_ifindex = 0;
> > +		return 0;
> > +	}
> > +
> > +	rcu_read_lock();
> > +	ndev = rcu_dereference(gid_attr->ndev);
> > +	if (!ndev || (READ_ONCE(ndev->flags) & IFF_UP) == 0) {
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
>
> None of this is necessary to read the ifindex, especially since the
> read_lock is being held.

I see same rcu_read_lock->rcu_dereference->rcu_read_unlock pattern in
rdma_read_gid_l2_fields(), why this function is different?

>
> > +/**
> > + * rdma_query_gid_table - Reads GID table entries of all the ports of a device up to max_entries.
> > + * @device: The device to query.
> > + * @entries: Entries where GID entries are returned.
> > + * @max_entries: Maximum number of entries that can be returned.
> > + * Entries array must be allocated to hold max_entries number of entries.
> > + * @num_entries: Updated to the number of entries that were successfully read.
> > + *
> > + * Returns 0 on success or appropriate error code.
> > + */
> > +int rdma_query_gid_table(struct ib_device *device,
> > +			 struct ib_uverbs_gid_entry *entries,
> > +			 size_t max_entries, size_t *num_entries)
>
> return ssize_t instead of the output pointer

I'll change.

>
> > +{
> > +	const struct ib_gid_attr *gid_attr;
> > +	struct ib_gid_table *table;
> > +	unsigned int port_num;
> > +	unsigned long flags;
> > +	int ret;
> > +	int i;
>
> i is unsigned

"i" is used as an iterator till table->sz while "sz" is declared as int.
I'll change it to be unsigned int, but it is not needed.

Thanks

>
> Jason

  reply	other threads:[~2020-09-13  8:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 14:22 [PATCH rdma-next 0/4] Query GID table API Leon Romanovsky
2020-09-10 14:22 ` [PATCH rdma-next 1/4] RDMA/core: Change rdma_get_gid_attr returned error code Leon Romanovsky
2020-09-10 14:22 ` [PATCH rdma-next 2/4] RDMA/core: Modify enum ib_gid_type and enum rdma_network_type Leon Romanovsky
2020-09-11 19:11   ` Jason Gunthorpe
2020-09-13  7:42     ` Leon Romanovsky
2020-09-10 14:22 ` [PATCH rdma-next 3/4] RDMA/core: Introduce new GID table query API Leon Romanovsky
2020-09-11 19:52   ` Jason Gunthorpe
2020-09-13  8:02     ` Leon Romanovsky [this message]
2020-09-14 15:50       ` Jason Gunthorpe
2020-09-10 14:22 ` [PATCH rdma-next 4/4] RDMA/uverbs: Expose the new GID query API to user space Leon Romanovsky
2020-09-11 19:59   ` Jason Gunthorpe
2020-09-13  9:13     ` Leon Romanovsky
2020-09-14 15:55       ` Jason Gunthorpe
2020-09-15 11:47         ` Leon Romanovsky
2020-09-15 19:06           ` Jason Gunthorpe
2020-09-16 10:37             ` Leon Romanovsky
2020-09-16 12:04               ` Jason Gunthorpe
2020-09-16 12:44                 ` Leon Romanovsky
2020-09-16 14:12                   ` Jason Gunthorpe
2020-09-16 14:34                     ` Leon Romanovsky
2020-09-16 14:36                       ` Jason Gunthorpe

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=20200913080233.GE35718@unreal \
    --to=leon@kernel.org \
    --cc=avihaih@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    /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.