Skip to contentSkip to conversation

vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag

PATCH Applied Adit Ranadive 3 participants 4 messages Aug 30, 2017 – Aug 31, 2017 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag

Rely on the IP_BASED_GIDS flag to use the ibv_resolve_eth_l2_from_gid function when creating the AH. Otherwise, fallback to the set_mac_from_gid function to set the DMAC.

---
Pull request:
https://github.com/linux-rdma/rdma-core/pull/205

 providers/vmw_pvrdma/verbs.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
providers/vmw_pvrdma/verbs.c +13 -7
index 852aced..a32046b 100644
@@ -166,7 +166,7 @@ static int is_ipv6_addr_v4mapped(const struct in6_addr *a)
 		 (a->s6_addr32[2] ^ htobe32(0x0000ffff))) == 0UL));
 }
 
-static void set_mac_from_gid(const union ibv_gid *gid,
+static int set_mac_from_gid(const union ibv_gid *gid,
 			     __u8 mac[6])
 {
 	if (is_link_local_gid(gid)) {
@@ -177,7 +177,11 @@ static void set_mac_from_gid(const union ibv_gid *gid,
 		memcpy(mac, gid->raw + 8, 3);
 		memcpy(mac + 3, gid->raw + 13, 3);
 		mac[0] ^= 2;
+
+		return 0;
 	}
+
+	return 1;
 }
 
 struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,
@@ -218,15 +222,17 @@ struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,
 				   attr->grh.flow_label;
 	memcpy(av->dgid, attr->grh.dgid.raw, 16);
 
-	if (ibv_resolve_eth_l2_from_gid(pd->context, attr,
-					av->dmac, &vlan_id)) {
-		free(ah);
-		return NULL;
+	if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) {
+		if (!ibv_resolve_eth_l2_from_gid(pd->context, attr,
+						 av->dmac, &vlan_id))
+			return &ah->ibv_ah;
 	} else {
-		set_mac_from_gid(&attr->grh.dgid, av->dmac);
+		if (!set_mac_from_gid(&attr->grh.dgid, av->dmac))
+			return &ah->ibv_ah;
 	}
 
-	return &ah->ibv_ah;
+	free(ah);
+	return NULL;
 }
 
 int pvrdma_destroy_ah(struct ibv_ah *ah)
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Adit Ranadive

Rely on the IP_BASED_GIDS flag to use the ibv_resolve_eth_l2_from_gid function when creating the AH. Otherwise, fallback to the set_mac_from_gid function to set the DMAC.

Quoted 9 lines

---
Pull request:
https://github.com/linux-rdma/rdma-core/pull/205

 providers/vmw_pvrdma/verbs.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Thanks, applied.

#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · On Wed, 30 Aug 2017 16:34:01 -0700 Adit Ranadive…

struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,

providers/vmw_pvrdma/verbs.c +0 -1
@@ -218,15 +222,17 @@ struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,
 				   attr->grh.flow_label;
 	memcpy(av->dgid, attr->grh.dgid.raw, 16);
 
-	if (ibv_resolve_eth_l2_from_gid(pd->context, attr,

providers/vmw_pvrdma/verbs.c struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, · line 230

Quoted 10 lines
providers/vmw_pvrdma/verbs.c +5 -4
-					av->dmac, &vlan_id)) {
-		free(ah);
-		return NULL;
+	if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) {
+		if (!ibv_resolve_eth_l2_from_gid(pd->context, attr,
+						 av->dmac, &vlan_id))
+			return &ah->ibv_ah;
 	} else {
-		set_mac_from_gid(&attr->grh.dgid, av->dmac);
+		if (!set_mac_from_gid(&attr->grh.dgid, av->dmac))

Could this have been simplified to:

	} else if (!set_mac_from_gid(...)) {

providers/vmw_pvrdma/verbs.c struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, · line 236

Quoted 3 lines
providers/vmw_pvrdma/verbs.c +1 -0
+		return &ah->ibv_ah;
 
 	}

-- Steve

providers/vmw_pvrdma/verbs.c struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, · line 238

Quoted 7 lines
providers/vmw_pvrdma/verbs.c +2 -1
-	return &ah->ibv_ah;
+	free(ah);
+	return NULL;
 }
 
 int pvrdma_destroy_ah(struct ibv_ah *ah)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to a message not in the archive
Quoted 23 lines · Steven Rostedt
Quoted 6 lines · On Wed, 30 Aug 2017 16:34:01 -0700 Adit Ranadive…

struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,

providers/vmw_pvrdma/verbs.c +0 -1
@@ -218,15 +222,17 @@ struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,
 				   attr->grh.flow_label;
 	memcpy(av->dgid, attr->grh.dgid.raw, 16);
 
-	if (ibv_resolve_eth_l2_from_gid(pd->context, attr,

providers/vmw_pvrdma/verbs.c struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, · line 230

Quoted 10 lines
providers/vmw_pvrdma/verbs.c +5 -4
-					av->dmac, &vlan_id)) {
-		free(ah);
-		return NULL;
+	if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) {
+		if (!ibv_resolve_eth_l2_from_gid(pd->context, attr,
+						 av->dmac, &vlan_id))
+			return &ah->ibv_ah;
 	} else {
-		set_mac_from_gid(&attr->grh.dgid, av->dmac);
+		if (!set_mac_from_gid(&attr->grh.dgid, av->dmac))

Could this have been simplified to:

Quoted 3 lines
	} else if (!set_mac_from_gid(...)) {

Review struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, · line 231

Quoted 1 line
(quoted diff) +1 -0
+		return &ah->ibv_ah;

Thanks, Steve. We can probably look at doing that in a future cleanup patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html