Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp386631pxf; Thu, 1 Apr 2021 03:56:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNNw8kyhSzorwgv4NOWMn3xDaRwqWSDUUVnnPra1kJ8GliQbZX8oBrEip1ZQEH7ifqsKVK X-Received: by 2002:a17:906:154f:: with SMTP id c15mr8608489ejd.142.1617274615183; Thu, 01 Apr 2021 03:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617274615; cv=none; d=google.com; s=arc-20160816; b=XGmFJpsgG0pdSw3lMdgvKIRMXMGmpkk4mOQCtIgx7l0Zi1WDKW90Po/IVjiAQAG8pu gacfRmbw05EqjWwJjQm0HpCQ6bob/ZLDZB8ofeyZq/IwVK2Z1dHJXO2e66Cni+jV9B5l aNcu0lOqm0YJWkc3lWycoAdUiYhFFNJKNVRQ09ab1AzNUW5VMFOMxPVpMoonseFhTaVj sa2Muv2eJzP1qvJXWvJDrbjmiKxxSNwcqvA6Ja6zDYvotWbI71n01f4lX1lktEm85+K+ 6j0YVh9/dqLb3sgg4Ilm8OtG8HXUc2lP2uR8Am9FMLkd9bbWA+dxs8pMWxf2AUOZ6k+U h/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ilASfeRC0W3icu1xI2kQxFC5XipulYlzAfRG4ND/HBw=; b=tGaaKlByOS5VxDWSHh4tExuvX7RKnwK/uHlTON8OiAoNZoZ7HYu3+E7uX6D//5WN+Q sQ3mxS8ZqSaEsrLbzEk4DdoJrrGwQzLt0/DIsmgnQ5sMthDus/hzj1eeGspmD8+UySxi MrdVxeR1ByhmGsiHnqsPYL72CDlDWfDt3d63RQsYK4WDABjg8Ub6vIFxVAUZzd9/F/nR oQs7ATCXLZ9usAR5WKCQN7G6PMZLfz5C/BXBBck01cULyMysa9DpXA6lmSmIOAUfGw6+ UCMG5VWFdf2LOyu5CfogNuOR6523itthf0Wdidtd9JaAxrlE+V/7hedobEDua5FV1j0y Vraw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yrt3ghRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh9si4242021ejb.113.2021.04.01.03.56.32; Thu, 01 Apr 2021 03:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yrt3ghRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbhDAKz2 (ORCPT + 99 others); Thu, 1 Apr 2021 06:55:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhDAKy4 (ORCPT ); Thu, 1 Apr 2021 06:54:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47C8D60FE8; Thu, 1 Apr 2021 10:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617274460; bh=LA75qGjL7UJw7E44jyn84WVVIzJMfOiXhPebs8eNjHc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yrt3ghRSgrfMP5zoFkZWkHThnDJsyuv8M8M+ts37a+z2kbHroNiO46EExzl5+BAUV Epx+I5nyMf1iBTSqBjBZvGcf75GQm/Ixawn1yBuEi+17gs76xYPAZXq2yHogJNcIBm Rtj0SRlV/JUvfdugX+77+9z7kVoiijjljn6v2PulNaBH4ZA6bedwkrKLv2MS+nyNm5 FHd1PTTwluwFE1ikC9r+cwNW8Ijrny7bbBp+CiN/0Vp7VQM01A47aDcpI5uC3MDnCB Zy088J+v91XU4t4JCQF6xIoD7keHV491APyQOKhmczc+2aNcKruXZwXP7ZR944+GXR gLclVDMEFS72w== Date: Thu, 1 Apr 2021 13:54:16 +0300 From: Leon Romanovsky To: =?iso-8859-1?Q?H=E5kon?= Bugge Cc: Santosh Shilimkar , "David S. Miller" , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, Parav Pandit , 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() Message-ID: References: <1617216194-12890-1-git-send-email-haakon.bugge@oracle.com> <1617216194-12890-2-git-send-email-haakon.bugge@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1617216194-12890-2-git-send-email-haakon.bugge@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Acked-by: Jason Gunthorpe > --- > 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