Skip to contentSkip to conversation

RDMA/cma: Fix incorrect Packet Lifetime calculation

PATCH Superseded Håkon Bugge 2 participants 4 messages Jun 21, 2021 – Jun 22, 2021 InfiniBand

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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. 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")

---

* 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(-)
drivers/infiniband/core/cma.c +5 -3
index 6759889..b1512ca 100644
@@ -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;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Håkon Bugge

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")
Quoted 8 lines

---

* 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,

#2 lore raw
Quoted 24 lines · Leon Romanovsky
Quoted 10 lines · Håkon Bugge

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")
Quoted 8 lines

---

* 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(-)
Quoted 2 lines

Thanks,

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

#3 lore raw
Quoted 24 lines · Haakon Bugge
Quoted 24 lines · Leon Romanovsky
Quoted 18 lines · Håkon Bugge

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")

---

* 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(-)
Quoted 4 lines
Quoted 2 lines

Thanks,

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.

Quoted 7 lines

Thxs, Håkon