summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/cma.c
diff options
context:
space:
mode:
authorHåkon Bugge <haakon.bugge@oracle.com>2021-06-22 17:13:27 +0300
committerJason Gunthorpe <jgg@nvidia.com>2021-06-25 16:54:34 +0300
commite84045eab69c625bc0b0bf24d8e05bc65da1eed1 (patch)
treed62909844be0f9a4dd830dc718d83a3ef12ae7bf /drivers/infiniband/core/cma.c
parentca0c448d2b9f43e3175835d536853854ef544e22 (diff)
downloadlinux-e84045eab69c625bc0b0bf24d8e05bc65da1eed1.tar.xz
RDMA/cma: Fix incorrect Packet Lifetime calculation
An approximation for the PacketLifeTime is half the local ACK timeout. The encoding for both timers are logarithmic. If the local ACK timeout is set, but zero, it means the timer is disabled. In this case, we choose the CMA_IBOE_PACKET_LIFETIME value, since 50% of infinite makes no sense. Before this commit, the PacketLifeTime became 255 if local ACK timeout was zero (not running). Fixed by explicitly testing for timeout being zero. Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime") Link: https://lore.kernel.org/r/1624371207-26710-1-git-send-email-haakon.bugge@oracle.com Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband/core/cma.c')
-rw-r--r--drivers/infiniband/core/cma.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6b6fa82e7943..9dfb07a16ab1 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3081,8 +3081,10 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
* as a reasonable approximation for RoCE networks.
*/
mutex_lock(&id_priv->qp_mutex);
- route->path_rec->packet_life_time = id_priv->timeout_set ?
- id_priv->timeout - 1 : CMA_IBOE_PACKET_LIFETIME;
+ if (id_priv->timeout_set && id_priv->timeout)
+ route->path_rec->packet_life_time = id_priv->timeout - 1;
+ else
+ route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME;
mutex_unlock(&id_priv->qp_mutex);
if (!route->path_rec->mtu) {