All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-core] vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag
@ 2017-08-30 23:34 Adit Ranadive
       [not found] ` <1504136041-3070-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Adit Ranadive @ 2017-08-30 23:34 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Adit Ranadive, pv-drivers-pghWNbHTmq7QT0dZR+AlfA

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.

Reviewed-by: Aditya Sarwade <asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
Pull request:
https://github.com/linux-rdma/rdma-core/pull/205

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

diff --git a/providers/vmw_pvrdma/verbs.c b/providers/vmw_pvrdma/verbs.c
index 852aced..a32046b 100644
--- a/providers/vmw_pvrdma/verbs.c
+++ b/providers/vmw_pvrdma/verbs.c
@@ -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)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH rdma-core] vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag
       [not found] ` <1504136041-3070-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2017-08-31  9:06   ` Leon Romanovsky
  2017-08-31 14:06   ` [Pv-drivers] " Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2017-08-31  9:06 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

On Wed, Aug 30, 2017 at 04:34:01PM -0700, Adit Ranadive wrote:
> 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.
>
> Reviewed-by: Aditya Sarwade <asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
> ---
> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [Pv-drivers] [PATCH rdma-core] vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag
       [not found] ` <1504136041-3070-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  2017-08-31  9:06   ` Leon Romanovsky
@ 2017-08-31 14:06   ` Steven Rostedt
       [not found]     ` <20170831100438.4e90516f-pVyPKaU+gKZOHLTnHDQRgA@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2017-08-31 14:06 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA

On Wed, 30 Aug 2017 16:34:01 -0700
Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> wrote:


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

Could this have been simplified to:

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

> +		return &ah->ibv_ah;

>  	}

-- Steve

>  
> -	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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [Pv-drivers] [PATCH rdma-core] vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag
       [not found]     ` <20170831100438.4e90516f-pVyPKaU+gKZOHLTnHDQRgA@public.gmane.org>
@ 2017-08-31 17:42       ` Adit Ranadive
  0 siblings, 0 replies; 4+ messages in thread
From: Adit Ranadive @ 2017-08-31 17:42 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA

On Thu, Aug 31, 2017 at 10:06:02AM -0400, Steven Rostedt wrote:
> On Wed, 30 Aug 2017 16:34:01 -0700
> Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> wrote:
> 
> 
> >  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))
> 
> Could this have been simplified to:
> 
> 	} else if (!set_mac_from_gid(...)) {
> 
> > +		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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-08-31 17:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 23:34 [PATCH rdma-core] vmw_pvrdma: Explicitly check for IP_BASED_GIDS port flag Adit Ranadive
     [not found] ` <1504136041-3070-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-08-31  9:06   ` Leon Romanovsky
2017-08-31 14:06   ` [Pv-drivers] " Steven Rostedt
     [not found]     ` <20170831100438.4e90516f-pVyPKaU+gKZOHLTnHDQRgA@public.gmane.org>
2017-08-31 17:42       ` Adit Ranadive

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.