From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
Avihai Horon <avihaih@nvidia.com>,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next v1 1/2] RDMA: Enable Relaxed Ordering by default for kernel ULPs
Date: Fri, 28 May 2021 15:27:46 -0300 [thread overview]
Message-ID: <20210528182746.GA3645229@nvidia.com> (raw)
In-Reply-To: <73af770234656d5f884ead5b8d40132d9ed289d6.1621505111.git.leonro@nvidia.com>
On Thu, May 20, 2021 at 01:13:35PM +0300, Leon Romanovsky wrote:
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 05dbc216eb64..b7bda44e9189 100644
> +++ b/include/rdma/ib_verbs.h
> @@ -1440,7 +1440,7 @@ enum ib_access_flags {
> IB_ZERO_BASED = IB_UVERBS_ACCESS_ZERO_BASED,
> IB_ACCESS_ON_DEMAND = IB_UVERBS_ACCESS_ON_DEMAND,
> IB_ACCESS_HUGETLB = IB_UVERBS_ACCESS_HUGETLB,
> - IB_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_RELAXED_ORDERING,
> + IB_ACCESS_DISABLE_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
>
> IB_ACCESS_OPTIONAL = IB_UVERBS_ACCESS_OPTIONAL_RANGE,
> IB_ACCESS_SUPPORTED =
IB_ACCESS_SUPPORTED should be deleted too
> - IB_ACCESS_SUPPORTED);
> + ((IB_UVERBS_ACCESS_HUGETLB << 1) - 1) |
> + IB_UVERBS_ACCESS_OPTIONAL_RANGE);
This would do well as a IB_UVERBS_ACCESS_MR_SUPPORTED constant
> @@ -4679,4 +4679,70 @@ static inline u32 rdma_calc_flow_label(u32 lqpn, u32 rqpn)
>
> const struct ib_port_immutable*
> ib_port_immutable_read(struct ib_device *dev, unsigned int port);
> +
> +static inline void process_access_flag(unsigned int *dest_flags,
> + unsigned int out_flag,
> + unsigned int *src_flags,
> + unsigned int in_flag)
> +{
> + if (!(*src_flags & in_flag))
> + return;
> +
> + *dest_flags |= out_flag;
> + *src_flags &= ~in_flag;
> +}
> +
> +static inline void process_access_flag_inv(unsigned int *dest_flags,
> + unsigned int out_flag,
> + unsigned int *src_flags,
> + unsigned int in_flag)
> +{
> + if (*src_flags & in_flag) {
> + *dest_flags &= ~out_flag;
> + *src_flags &= ~in_flag;
> + return;
> + }
> +
> + *dest_flags |= out_flag;
> +}
> +
> +static inline int copy_mr_access_flags(unsigned int *dest_flags,
> + unsigned int src_flags)
> +{
> + *dest_flags = 0;
> +
> + process_access_flag(dest_flags, IB_ACCESS_LOCAL_WRITE, &src_flags,
> + IB_UVERBS_ACCESS_LOCAL_WRITE);
> +
> + process_access_flag(dest_flags, IB_ACCESS_REMOTE_WRITE, &src_flags,
> + IB_UVERBS_ACCESS_REMOTE_WRITE);
> +
> + process_access_flag(dest_flags, IB_ACCESS_REMOTE_READ, &src_flags,
> + IB_UVERBS_ACCESS_REMOTE_READ);
> +
> + process_access_flag(dest_flags, IB_ACCESS_REMOTE_ATOMIC, &src_flags,
> + IB_UVERBS_ACCESS_REMOTE_ATOMIC);
> +
> + process_access_flag(dest_flags, IB_ACCESS_MW_BIND, &src_flags,
> + IB_UVERBS_ACCESS_MW_BIND);
> +
> + process_access_flag(dest_flags, IB_ZERO_BASED, &src_flags,
> + IB_UVERBS_ACCESS_ZERO_BASED);
> +
> + process_access_flag(dest_flags, IB_ACCESS_ON_DEMAND, &src_flags,
> + IB_UVERBS_ACCESS_ON_DEMAND);
> +
> + process_access_flag(dest_flags, IB_ACCESS_HUGETLB, &src_flags,
> + IB_UVERBS_ACCESS_HUGETLB);
> +
> + process_access_flag_inv(dest_flags, IB_ACCESS_DISABLE_RELAXED_ORDERING,
> + &src_flags, IB_UVERBS_ACCESS_RELAXED_ORDERING);
This seems over complicated, why not just:
dst_flags = IB_ACCESS_DISABLE_RELAXED_ORDERING
if (src_flags & IB_UVERBS_ACCESS_LOCAL_WRITE)
dst_flags |= IB_ACCESS_LOCAL_WRITE;
if (src_flags & IB_UVERBS_ACCESS_RELAXED_ORDERING)
dst_flags &= ~IB_ACCESS_DISABLE_RELAXED_ORDERING;
if (src_flags & ~IB_UVERBS_ACCESS_MR_SUPPORTED)
return -EINVAL;
And the QP version is the same as the MR, just with a different
supported flags check
Jason
next prev parent reply other threads:[~2021-05-28 18:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 10:13 [PATCH rdma-next v1 0/2] Enable relaxed ordering for ULPs Leon Romanovsky
2021-05-20 10:13 ` [PATCH rdma-next v1 1/2] RDMA: Enable Relaxed Ordering by default for kernel ULPs Leon Romanovsky
2021-05-27 10:28 ` Christoph Hellwig
2021-05-28 18:27 ` Jason Gunthorpe [this message]
2021-05-20 10:13 ` [PATCH rdma-next v1 2/2] RDMA/mlx5: Allow modifying Relaxed Ordering via fast registration Leon Romanovsky
2021-05-26 19:49 ` Jason Gunthorpe
2021-05-27 11:09 ` Christoph Hellwig
2021-05-27 14:57 ` Jason Gunthorpe
2021-05-27 15:06 ` Christoph Hellwig
2021-06-02 12:16 ` Leon Romanovsky
2021-05-26 19:30 ` [PATCH rdma-next v1 0/2] Enable relaxed ordering for ULPs Jason Gunthorpe
2021-05-27 8:11 ` David Laight
2021-05-31 18:13 ` Jason Gunthorpe
2021-05-31 21:45 ` David Laight
2021-05-31 22:44 ` 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=20210528182746.GA3645229@nvidia.com \
--to=jgg@nvidia.com \
--cc=avihaih@nvidia.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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.