All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation
@ 2021-06-21 13:18 Håkon Bugge
  2021-06-22  8:18 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Håkon Bugge @ 2021-06-21 13:18 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, Hans Westgaard Ry

An approximation for the PacketLifeTime is half the local ACK timeout.
The encoding for both timers are logarithmic. The PacketLifeTime
calculation is wrong when local ACK timeout is zero. In that case,
PacketLifeTime is set to the incorrect value 255.

Fixed by explicitly testing for timeout being zero.

Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime")
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>

---

	* Note: This commit must be merged after ("RDMA/cma: Replace
          RMW with atomic bit-ops")
---
 drivers/infiniband/core/cma.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6759889..b1512ca 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3096,9 +3096,11 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
 	 * PacketLifeTime = local ACK timeout/2
 	 * as a reasonable approximation for RoCE networks.
 	 */
-	route->path_rec->packet_life_time =
-		test_bit(TIMEOUT_SET, &id_priv->flags) ?
-		id_priv->timeout - 1 : CMA_IBOE_PACKET_LIFETIME;
+	if (test_bit(TIMEOUT_SET, &id_priv->flags))
+		route->path_rec->packet_life_time =
+			id_priv->timeout ? id_priv->timeout - 1 : 0;
+	else
+		route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME;
 
 	if (!route->path_rec->mtu) {
 		ret = -EINVAL;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation
  2021-06-21 13:18 [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation Håkon Bugge
@ 2021-06-22  8:18 ` Leon Romanovsky
  2021-06-22  9:32   ` Haakon Bugge
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-06-22  8:18 UTC (permalink / raw)
  To: Håkon Bugge
  Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, Hans Westgaard Ry

On Mon, Jun 21, 2021 at 03:18:57PM +0200, Håkon Bugge wrote:
> An approximation for the PacketLifeTime is half the local ACK timeout.
> The encoding for both timers are logarithmic. The PacketLifeTime
> calculation is wrong when local ACK timeout is zero. In that case,
> PacketLifeTime is set to the incorrect value 255.
> 
> Fixed by explicitly testing for timeout being zero.
> 
> Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime")
> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> 
> ---
> 
> 	* Note: This commit must be merged after ("RDMA/cma: Replace
>           RMW with atomic bit-ops")
> ---
>  drivers/infiniband/core/cma.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation
  2021-06-22  8:18 ` Leon Romanovsky
@ 2021-06-22  9:32   ` Haakon Bugge
  2021-06-22 12:17     ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Haakon Bugge @ 2021-06-22  9:32 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Doug Ledford, Jason Gunthorpe, OFED mailing list, Hans Ry



> On 22 Jun 2021, at 10:18, Leon Romanovsky <leon@kernel.org> wrote:
> 
> On Mon, Jun 21, 2021 at 03:18:57PM +0200, Håkon Bugge wrote:
>> An approximation for the PacketLifeTime is half the local ACK timeout.
>> The encoding for both timers are logarithmic. The PacketLifeTime
>> calculation is wrong when local ACK timeout is zero. In that case,
>> PacketLifeTime is set to the incorrect value 255.
>> 
>> Fixed by explicitly testing for timeout being zero.
>> 
>> Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime")
>> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
>> 
>> ---
>> 
>> 	* Note: This commit must be merged after ("RDMA/cma: Replace
>>          RMW with atomic bit-ops")
>> ---
>> drivers/infiniband/core/cma.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>> 
> 
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

Thanks for the review, Leon! I have to rebase on the tip of for-next, since the ("RDMA/cma: Replace RMW with atomic bit-ops") will not have the get_bit() stuff in cma_resolve_iboe_route() anymore. I assume I can retain your r-b after the rebase?


Thxs, Håkon





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation
  2021-06-22  9:32   ` Haakon Bugge
@ 2021-06-22 12:17     ` Leon Romanovsky
  0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-06-22 12:17 UTC (permalink / raw)
  To: Haakon Bugge; +Cc: Doug Ledford, Jason Gunthorpe, OFED mailing list, Hans Ry

On Tue, Jun 22, 2021 at 09:32:27AM +0000, Haakon Bugge wrote:
> 
> 
> > On 22 Jun 2021, at 10:18, Leon Romanovsky <leon@kernel.org> wrote:
> > 
> > On Mon, Jun 21, 2021 at 03:18:57PM +0200, Håkon Bugge wrote:
> >> An approximation for the PacketLifeTime is half the local ACK timeout.
> >> The encoding for both timers are logarithmic. The PacketLifeTime
> >> calculation is wrong when local ACK timeout is zero. In that case,
> >> PacketLifeTime is set to the incorrect value 255.
> >> 
> >> Fixed by explicitly testing for timeout being zero.
> >> 
> >> Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime")
> >> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> >> 
> >> ---
> >> 
> >> 	* Note: This commit must be merged after ("RDMA/cma: Replace
> >>          RMW with atomic bit-ops")
> >> ---
> >> drivers/infiniband/core/cma.c | 8 +++++---
> >> 1 file changed, 5 insertions(+), 3 deletions(-)
> >> 
> > 
> > Thanks,
> > Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> 
> Thanks for the review, Leon! I have to rebase on the tip of for-next, since the ("RDMA/cma: Replace RMW with atomic bit-ops") will not have the get_bit() stuff in cma_resolve_iboe_route() anymore. I assume I can retain your r-b after the rebase?

Yes, please.

> 
> 
> Thxs, Håkon
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-22 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 13:18 [PATCH for-next] RDMA/cma: Fix incorrect Packet Lifetime calculation Håkon Bugge
2021-06-22  8:18 ` Leon Romanovsky
2021-06-22  9:32   ` Haakon Bugge
2021-06-22 12:17     ` Leon Romanovsky

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.