From: Leon Romanovsky <leon@kernel.org>
To: "Håkon Bugge" <haakon.bugge@oracle.com>
Cc: Santosh Shilimkar <santosh.shilimkar@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
linux-rdma@vger.kernel.org, Parav Pandit <parav@nvidia.com>,
netdev@vger.kernel.org, rds-devel@oss.oracle.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-next v3 1/2] IB/cma: Introduce rdma_set_min_rnr_timer()
Date: Thu, 1 Apr 2021 13:54:16 +0300 [thread overview]
Message-ID: <YGWmWPx71CqNRSKZ@unreal> (raw)
In-Reply-To: <1617216194-12890-2-git-send-email-haakon.bugge@oracle.com>
On Wed, Mar 31, 2021 at 08:43:13PM +0200, Håkon Bugge wrote:
> Introduce the ability for kernel ULPs to adjust the minimum RNR Retry
> timer. The INIT -> RTR transition executed by RDMA CM will be used for
> this adjustment. This avoids an additional ib_modify_qp() call.
>
> rdma_set_min_rnr_timer() must be called before the call to
> rdma_connect() on the active side and before the call to rdma_accept()
> on the passive side.
>
> The default value of RNR Retry timer is zero, which translates to 655
> ms. When the receiver is not ready to accept a send messages, it
> encodes the RNR Retry timer value in the NAK. The requestor will then
> wait at least the specified time value before retrying the send.
>
> The 5-bit value to be supplied to the rdma_set_min_rnr_timer() is
> documented in IBTA Table 45: "Encoding for RNR NAK Timer Field".
>
> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> Acked-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/infiniband/core/cma.c | 41 ++++++++++++++++++++++++++++++++++++++
> drivers/infiniband/core/cma_priv.h | 2 ++
> include/rdma/rdma_cm.h | 2 ++
> 3 files changed, 45 insertions(+)
>
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 9409651..5ce097d 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -852,6 +852,7 @@ static void cma_id_put(struct rdma_id_private *id_priv)
> id_priv->id.qp_type = qp_type;
> id_priv->tos_set = false;
> id_priv->timeout_set = false;
> + id_priv->min_rnr_timer_set = false;
> id_priv->gid_type = IB_GID_TYPE_IB;
> spin_lock_init(&id_priv->lock);
> mutex_init(&id_priv->qp_mutex);
> @@ -1141,6 +1142,9 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
> if ((*qp_attr_mask & IB_QP_TIMEOUT) && id_priv->timeout_set)
> qp_attr->timeout = id_priv->timeout;
>
> + if ((*qp_attr_mask & IB_QP_MIN_RNR_TIMER) && id_priv->min_rnr_timer_set)
> + qp_attr->min_rnr_timer = id_priv->min_rnr_timer;
> +
> return ret;
> }
> EXPORT_SYMBOL(rdma_init_qp_attr);
> @@ -2615,6 +2619,43 @@ int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout)
> }
> EXPORT_SYMBOL(rdma_set_ack_timeout);
>
> +/**
> + * rdma_set_min_rnr_timer() - Set the minimum RNR Retry timer of the
> + * QP associated with a connection identifier.
> + * @id: Communication identifier to associated with service type.
> + * @min_rnr_timer: 5-bit value encoded as Table 45: "Encoding for RNR NAK
> + * Timer Field" in the IBTA specification.
> + *
> + * This function should be called before rdma_connect() on active
> + * side, and on passive side before rdma_accept(). The timer value
> + * will be associated with the local QP. When it receives a send it is
> + * not read to handle, typically if the receive queue is empty, an RNR
> + * Retry NAK is returned to the requester with the min_rnr_timer
> + * encoded. The requester will then wait at least the time specified
> + * in the NAK before retrying. The default is zero, which translates
> + * to a minimum RNR Timer value of 655 ms.
> + *
> + * Return: 0 for success
> + */
> +int rdma_set_min_rnr_timer(struct rdma_cm_id *id, u8 min_rnr_timer)
> +{
> + struct rdma_id_private *id_priv;
> +
> + /* It is a five-bit value */
> + if (min_rnr_timer & 0xe0)
> + return -EINVAL;
> +
> + if (id->qp_type != IB_QPT_RC && id->qp_type != IB_QPT_XRC_TGT)
> + return -EINVAL;
This is in-kernel API and safe to use WARN_ON() instead of returning
error which RDS is not checking anyway.
Thanks
next prev parent reply other threads:[~2021-04-01 10:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 18:43 [PATCH for-next v3 0/2] Introduce rdma_set_min_rnr_timer() and use it in RDS Håkon Bugge
2021-03-31 18:43 ` [PATCH for-next v3 1/2] IB/cma: Introduce rdma_set_min_rnr_timer() Håkon Bugge
2021-04-01 10:54 ` Leon Romanovsky [this message]
2021-03-31 18:43 ` [PATCH for-next v3 2/2] rds: ib: Remove two ib_modify_qp() calls Håkon Bugge
2021-03-31 19:54 ` [PATCH for-next v3 0/2] Introduce rdma_set_min_rnr_timer() and use it in RDS Santosh Shilimkar
2021-04-01 17:51 ` Jason Gunthorpe
2021-04-07 16:41 ` Haakon Bugge
2021-04-12 18:35 ` Haakon Bugge
2021-04-12 18:45 ` Jason Gunthorpe
2021-04-12 22:58 ` Jason Gunthorpe
2021-04-13 6:29 ` Leon Romanovsky
2021-04-13 11:13 ` Haakon Bugge
2021-04-13 11:37 ` Leon Romanovsky
2021-04-13 13:51 ` 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=YGWmWPx71CqNRSKZ@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=dledford@redhat.com \
--cc=haakon.bugge@oracle.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=parav@nvidia.com \
--cc=rds-devel@oss.oracle.com \
--cc=santosh.shilimkar@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).