All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
@ 2017-03-03 20:49 Yuval Shaia
       [not found] ` <1488574145-27179-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Yuval Shaia @ 2017-03-03 20:49 UTC (permalink / raw
  To: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

This logic seems to be duplicated in (at least) three separate files.
Move it to one place so code can be re-use.

Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
v0 -> v1:
	* Add missing #include
	* Rename to genaddrconf_ifid_eui48
---
 drivers/infiniband/hw/usnic/usnic_common_util.h | 11 +++--------
 drivers/infiniband/sw/rxe/rxe_net.c             | 11 ++---------
 include/net/addrconf.h                          | 18 ++++++++++++------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/infiniband/hw/usnic/usnic_common_util.h b/drivers/infiniband/hw/usnic/usnic_common_util.h
index b54986d..09871da 100644
--- a/drivers/infiniband/hw/usnic/usnic_common_util.h
+++ b/drivers/infiniband/hw/usnic/usnic_common_util.h
@@ -34,6 +34,8 @@
 #ifndef USNIC_CMN_UTIL_H
 #define USNIC_CMN_UTIL_H
 
+#include <net/addrconf.h>
+
 static inline void
 usnic_mac_to_gid(const char *const mac, char *raw_gid)
 {
@@ -57,14 +59,7 @@
 	raw_gid[1] = 0x80;
 	memset(&raw_gid[2], 0, 2);
 	memcpy(&raw_gid[4], &inaddr, 4);
-	raw_gid[8] = mac[0]^2;
-	raw_gid[9] = mac[1];
-	raw_gid[10] = mac[2];
-	raw_gid[11] = 0xff;
-	raw_gid[12] = 0xfe;
-	raw_gid[13] = mac[3];
-	raw_gid[14] = mac[4];
-	raw_gid[15] = mac[5];
+	genaddrconf_ifid_eui48(&raw_gid[8], mac);
 }
 
 static inline void
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 4abdeb3..23ba9e1 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -38,6 +38,7 @@
 #include <linux/if_vlan.h>
 #include <net/udp_tunnel.h>
 #include <net/sch_generic.h>
+#include <net/addrconf.h>
 #include <linux/netfilter.h>
 #include <rdma/ib_addr.h>
 
@@ -86,18 +87,10 @@ struct rxe_dev *get_rxe_by_name(const char *name)
 
 static __be64 rxe_mac_to_eui64(struct net_device *ndev)
 {
-	unsigned char *mac_addr = ndev->dev_addr;
 	__be64 eui64;
 	unsigned char *dst = (unsigned char *)&eui64;
 
-	dst[0] = mac_addr[0] ^ 2;
-	dst[1] = mac_addr[1];
-	dst[2] = mac_addr[2];
-	dst[3] = 0xff;
-	dst[4] = 0xfe;
-	dst[5] = mac_addr[3];
-	dst[6] = mac_addr[4];
-	dst[7] = mac_addr[5];
+	genaddrconf_ifid_eui48(dst, ndev->dev_addr);
 
 	return eui64;
 }
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 8f998af..07d0341 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -105,12 +105,21 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
 				 u32 addr_flags, bool sllao, bool tokenized,
 				 __u32 valid_lft, u32 prefered_lft);
 
+static inline void genaddrconf_ifid_eui48(u8 *eui, const char *const addr)
+{
+	memcpy(eui, addr, 3);
+	eui[0] ^= 2;
+	eui[3] = 0xFF;
+	eui[4] = 0xFE;
+	memcpy(eui + 5, addr + 3, 3);
+}
+
 static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
 {
 	if (dev->addr_len != ETH_ALEN)
 		return -1;
-	memcpy(eui, dev->dev_addr, 3);
-	memcpy(eui + 5, dev->dev_addr + 3, 3);
+
+	genaddrconf_ifid_eui48(eui, dev->dev_addr);
 
 	/*
 	 * The zSeries OSA network cards can be shared among various
@@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
 	if (dev->dev_id) {
 		eui[3] = (dev->dev_id >> 8) & 0xFF;
 		eui[4] = dev->dev_id & 0xFF;
-	} else {
-		eui[3] = 0xFF;
-		eui[4] = 0xFE;
-		eui[0] ^= 2;
 	}
+
 	return 0;
 }
 
-- 
1.8.3.1

--
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] 6+ messages in thread

* Re: [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
       [not found] ` <1488574145-27179-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-03-05  7:46   ` Leon Romanovsky
       [not found]     ` <20170305074650.GH14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2017-03-05  7:46 UTC (permalink / raw
  To: Yuval Shaia
  Cc: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

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

On Fri, Mar 03, 2017 at 10:49:05PM +0200, Yuval Shaia wrote:
> This logic seems to be duplicated in (at least) three separate files.
> Move it to one place so code can be re-use.
>
> Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
> v0 -> v1:
> 	* Add missing #include
> 	* Rename to genaddrconf_ifid_eui48
> ---
>  drivers/infiniband/hw/usnic/usnic_common_util.h | 11 +++--------
>  drivers/infiniband/sw/rxe/rxe_net.c             | 11 ++---------
>  include/net/addrconf.h                          | 18 ++++++++++++------
>  3 files changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/infiniband/hw/usnic/usnic_common_util.h b/drivers/infiniband/hw/usnic/usnic_common_util.h
> index b54986d..09871da 100644
> --- a/drivers/infiniband/hw/usnic/usnic_common_util.h
> +++ b/drivers/infiniband/hw/usnic/usnic_common_util.h
> @@ -34,6 +34,8 @@
>  #ifndef USNIC_CMN_UTIL_H
>  #define USNIC_CMN_UTIL_H
>
> +#include <net/addrconf.h>
> +
>  static inline void
>  usnic_mac_to_gid(const char *const mac, char *raw_gid)
>  {
> @@ -57,14 +59,7 @@
>  	raw_gid[1] = 0x80;
>  	memset(&raw_gid[2], 0, 2);
>  	memcpy(&raw_gid[4], &inaddr, 4);
> -	raw_gid[8] = mac[0]^2;
> -	raw_gid[9] = mac[1];
> -	raw_gid[10] = mac[2];
> -	raw_gid[11] = 0xff;
> -	raw_gid[12] = 0xfe;
> -	raw_gid[13] = mac[3];
> -	raw_gid[14] = mac[4];
> -	raw_gid[15] = mac[5];
> +	genaddrconf_ifid_eui48(&raw_gid[8], mac);
>  }
>
>  static inline void
> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> index 4abdeb3..23ba9e1 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> @@ -38,6 +38,7 @@
>  #include <linux/if_vlan.h>
>  #include <net/udp_tunnel.h>
>  #include <net/sch_generic.h>
> +#include <net/addrconf.h>
>  #include <linux/netfilter.h>
>  #include <rdma/ib_addr.h>
>
> @@ -86,18 +87,10 @@ struct rxe_dev *get_rxe_by_name(const char *name)
>
>  static __be64 rxe_mac_to_eui64(struct net_device *ndev)
>  {
> -	unsigned char *mac_addr = ndev->dev_addr;
>  	__be64 eui64;
>  	unsigned char *dst = (unsigned char *)&eui64;
>
> -	dst[0] = mac_addr[0] ^ 2;
> -	dst[1] = mac_addr[1];
> -	dst[2] = mac_addr[2];
> -	dst[3] = 0xff;
> -	dst[4] = 0xfe;
> -	dst[5] = mac_addr[3];
> -	dst[6] = mac_addr[4];
> -	dst[7] = mac_addr[5];
> +	genaddrconf_ifid_eui48(dst, ndev->dev_addr);
>
>  	return eui64;
>  }
> diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> index 8f998af..07d0341 100644
> --- a/include/net/addrconf.h
> +++ b/include/net/addrconf.h
> @@ -105,12 +105,21 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
>  				 u32 addr_flags, bool sllao, bool tokenized,
>  				 __u32 valid_lft, u32 prefered_lft);
>
> +static inline void genaddrconf_ifid_eui48(u8 *eui, const char *const addr)
> +{
> +	memcpy(eui, addr, 3);
> +	eui[0] ^= 2;
> +	eui[3] = 0xFF;
> +	eui[4] = 0xFE;
> +	memcpy(eui + 5, addr + 3, 3);
> +}
> +
>  static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
>  {
>  	if (dev->addr_len != ETH_ALEN)
>  		return -1;
> -	memcpy(eui, dev->dev_addr, 3);
> -	memcpy(eui + 5, dev->dev_addr + 3, 3);
> +
> +	genaddrconf_ifid_eui48(eui, dev->dev_addr);
>
>  	/*
>  	 * The zSeries OSA network cards can be shared among various
> @@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
>  	if (dev->dev_id) {
>  		eui[3] = (dev->dev_id >> 8) & 0xFF;
>  		eui[4] = dev->dev_id & 0xFF;
> -	} else {
> -		eui[3] = 0xFF;
> -		eui[4] = 0xFE;
> -		eui[0] ^= 2;

Sorry, but NAK.
You missed the assignment below. In original code it WASN'T for dev->dev_id != NULL, and now it is.

>  	}
> +
>  	return 0;
>  }
>
> --
> 1.8.3.1
>
> --
> 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

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

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

* Re: [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
       [not found]     ` <20170305074650.GH14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
@ 2017-03-05  8:12       ` Leon Romanovsky
       [not found]         ` <20170305081244.GJ14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2017-03-05  8:12 UTC (permalink / raw
  To: Yuval Shaia
  Cc: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

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

On Sun, Mar 05, 2017 at 09:46:50AM +0200, Leon Romanovsky wrote:
> On Fri, Mar 03, 2017 at 10:49:05PM +0200, Yuval Shaia wrote:
> > This logic seems to be duplicated in (at least) three separate files.
> > Move it to one place so code can be re-use.
> >
> > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > ---
> > v0 -> v1:
> > 	* Add missing #include
> > 	* Rename to genaddrconf_ifid_eui48
> > ---
> >  drivers/infiniband/hw/usnic/usnic_common_util.h | 11 +++--------
> >  drivers/infiniband/sw/rxe/rxe_net.c             | 11 ++---------
> >  include/net/addrconf.h                          | 18 ++++++++++++------
> >  3 files changed, 17 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/usnic/usnic_common_util.h b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > index b54986d..09871da 100644
> > --- a/drivers/infiniband/hw/usnic/usnic_common_util.h
> > +++ b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > @@ -34,6 +34,8 @@
> >  #ifndef USNIC_CMN_UTIL_H
> >  #define USNIC_CMN_UTIL_H
> >
> > +#include <net/addrconf.h>
> > +
> >  static inline void
> >  usnic_mac_to_gid(const char *const mac, char *raw_gid)
> >  {
> > @@ -57,14 +59,7 @@
> >  	raw_gid[1] = 0x80;
> >  	memset(&raw_gid[2], 0, 2);
> >  	memcpy(&raw_gid[4], &inaddr, 4);
> > -	raw_gid[8] = mac[0]^2;
> > -	raw_gid[9] = mac[1];
> > -	raw_gid[10] = mac[2];
> > -	raw_gid[11] = 0xff;
> > -	raw_gid[12] = 0xfe;
> > -	raw_gid[13] = mac[3];
> > -	raw_gid[14] = mac[4];
> > -	raw_gid[15] = mac[5];
> > +	genaddrconf_ifid_eui48(&raw_gid[8], mac);
> >  }
> >
> >  static inline void
> > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > index 4abdeb3..23ba9e1 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > @@ -38,6 +38,7 @@
> >  #include <linux/if_vlan.h>
> >  #include <net/udp_tunnel.h>
> >  #include <net/sch_generic.h>
> > +#include <net/addrconf.h>
> >  #include <linux/netfilter.h>
> >  #include <rdma/ib_addr.h>
> >
> > @@ -86,18 +87,10 @@ struct rxe_dev *get_rxe_by_name(const char *name)
> >
> >  static __be64 rxe_mac_to_eui64(struct net_device *ndev)
> >  {
> > -	unsigned char *mac_addr = ndev->dev_addr;
> >  	__be64 eui64;
> >  	unsigned char *dst = (unsigned char *)&eui64;
> >
> > -	dst[0] = mac_addr[0] ^ 2;
> > -	dst[1] = mac_addr[1];
> > -	dst[2] = mac_addr[2];
> > -	dst[3] = 0xff;
> > -	dst[4] = 0xfe;
> > -	dst[5] = mac_addr[3];
> > -	dst[6] = mac_addr[4];
> > -	dst[7] = mac_addr[5];
> > +	genaddrconf_ifid_eui48(dst, ndev->dev_addr);
> >
> >  	return eui64;
> >  }
> > diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> > index 8f998af..07d0341 100644
> > --- a/include/net/addrconf.h
> > +++ b/include/net/addrconf.h
> > @@ -105,12 +105,21 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
> >  				 u32 addr_flags, bool sllao, bool tokenized,
> >  				 __u32 valid_lft, u32 prefered_lft);
> >
> > +static inline void genaddrconf_ifid_eui48(u8 *eui, const char *const addr)
> > +{
> > +	memcpy(eui, addr, 3);
> > +	eui[0] ^= 2;
> > +	eui[3] = 0xFF;
> > +	eui[4] = 0xFE;
> > +	memcpy(eui + 5, addr + 3, 3);
> > +}
> > +
> >  static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> >  {
> >  	if (dev->addr_len != ETH_ALEN)
> >  		return -1;
> > -	memcpy(eui, dev->dev_addr, 3);
> > -	memcpy(eui + 5, dev->dev_addr + 3, 3);
> > +
> > +	genaddrconf_ifid_eui48(eui, dev->dev_addr);
> >
> >  	/*
> >  	 * The zSeries OSA network cards can be shared among various
> > @@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> >  	if (dev->dev_id) {
> >  		eui[3] = (dev->dev_id >> 8) & 0xFF;
> >  		eui[4] = dev->dev_id & 0xFF;
> > -	} else {
> > -		eui[3] = 0xFF;
> > -		eui[4] = 0xFE;
> > -		eui[0] ^= 2;
>
> Sorry, but NAK.
> You missed the assignment below. In original code it WASN'T for dev->dev_id != NULL, and now it is.

s/below/above

>
> >  	}
> > +
> >  	return 0;
> >  }
> >
> > --
> > 1.8.3.1
> >
> > --
> > 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



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

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

* Re: [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
       [not found]         ` <20170305081244.GJ14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
@ 2017-03-05 19:49           ` Yuval Shaia
  2017-03-06  5:15             ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Yuval Shaia @ 2017-03-05 19:49 UTC (permalink / raw
  To: Leon Romanovsky
  Cc: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Sun, Mar 05, 2017 at 10:12:44AM +0200, Leon Romanovsky wrote:
> On Sun, Mar 05, 2017 at 09:46:50AM +0200, Leon Romanovsky wrote:
> > On Fri, Mar 03, 2017 at 10:49:05PM +0200, Yuval Shaia wrote:
> > > This logic seems to be duplicated in (at least) three separate files.
> > > Move it to one place so code can be re-use.
> > >
> > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > > ---
> > > v0 -> v1:
> > > 	* Add missing #include
> > > 	* Rename to genaddrconf_ifid_eui48
> > > ---
> > >  drivers/infiniband/hw/usnic/usnic_common_util.h | 11 +++--------
> > >  drivers/infiniband/sw/rxe/rxe_net.c             | 11 ++---------
> > >  include/net/addrconf.h                          | 18 ++++++++++++------
> > >  3 files changed, 17 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/hw/usnic/usnic_common_util.h b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > index b54986d..09871da 100644
> > > --- a/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > +++ b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > @@ -34,6 +34,8 @@
> > >  #ifndef USNIC_CMN_UTIL_H
> > >  #define USNIC_CMN_UTIL_H
> > >
> > > +#include <net/addrconf.h>
> > > +
> > >  static inline void
> > >  usnic_mac_to_gid(const char *const mac, char *raw_gid)
> > >  {
> > > @@ -57,14 +59,7 @@
> > >  	raw_gid[1] = 0x80;
> > >  	memset(&raw_gid[2], 0, 2);
> > >  	memcpy(&raw_gid[4], &inaddr, 4);
> > > -	raw_gid[8] = mac[0]^2;
> > > -	raw_gid[9] = mac[1];
> > > -	raw_gid[10] = mac[2];
> > > -	raw_gid[11] = 0xff;
> > > -	raw_gid[12] = 0xfe;
> > > -	raw_gid[13] = mac[3];
> > > -	raw_gid[14] = mac[4];
> > > -	raw_gid[15] = mac[5];
> > > +	genaddrconf_ifid_eui48(&raw_gid[8], mac);
> > >  }
> > >
> > >  static inline void
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > > index 4abdeb3..23ba9e1 100644
> > > --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > > +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > > @@ -38,6 +38,7 @@
> > >  #include <linux/if_vlan.h>
> > >  #include <net/udp_tunnel.h>
> > >  #include <net/sch_generic.h>
> > > +#include <net/addrconf.h>
> > >  #include <linux/netfilter.h>
> > >  #include <rdma/ib_addr.h>
> > >
> > > @@ -86,18 +87,10 @@ struct rxe_dev *get_rxe_by_name(const char *name)
> > >
> > >  static __be64 rxe_mac_to_eui64(struct net_device *ndev)
> > >  {
> > > -	unsigned char *mac_addr = ndev->dev_addr;
> > >  	__be64 eui64;
> > >  	unsigned char *dst = (unsigned char *)&eui64;
> > >
> > > -	dst[0] = mac_addr[0] ^ 2;
> > > -	dst[1] = mac_addr[1];
> > > -	dst[2] = mac_addr[2];
> > > -	dst[3] = 0xff;
> > > -	dst[4] = 0xfe;
> > > -	dst[5] = mac_addr[3];
> > > -	dst[6] = mac_addr[4];
> > > -	dst[7] = mac_addr[5];
> > > +	genaddrconf_ifid_eui48(dst, ndev->dev_addr);
> > >
> > >  	return eui64;
> > >  }
> > > diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> > > index 8f998af..07d0341 100644
> > > --- a/include/net/addrconf.h
> > > +++ b/include/net/addrconf.h
> > > @@ -105,12 +105,21 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
> > >  				 u32 addr_flags, bool sllao, bool tokenized,
> > >  				 __u32 valid_lft, u32 prefered_lft);
> > >
> > > +static inline void genaddrconf_ifid_eui48(u8 *eui, const char *const addr)
> > > +{
> > > +	memcpy(eui, addr, 3);
> > > +	eui[0] ^= 2;
> > > +	eui[3] = 0xFF;
> > > +	eui[4] = 0xFE;
> > > +	memcpy(eui + 5, addr + 3, 3);
> > > +}
> > > +
> > >  static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> > >  {
> > >  	if (dev->addr_len != ETH_ALEN)
> > >  		return -1;
> > > -	memcpy(eui, dev->dev_addr, 3);
> > > -	memcpy(eui + 5, dev->dev_addr + 3, 3);
> > > +
> > > +	genaddrconf_ifid_eui48(eui, dev->dev_addr);
> > >
> > >  	/*
> > >  	 * The zSeries OSA network cards can be shared among various
> > > @@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> > >  	if (dev->dev_id) {
> > >  		eui[3] = (dev->dev_id >> 8) & 0xFF;
> > >  		eui[4] = dev->dev_id & 0xFF;
> > > -	} else {
> > > -		eui[3] = 0xFF;
> > > -		eui[4] = 0xFE;
> > > -		eui[0] ^= 2;
> >
> > Sorry, but NAK.
> > You missed the assignment below. In original code it WASN'T for dev->dev_id != NULL, and now it is.
> 
> s/below/above

I'm sorry but which assignment is missing? Default values for 0, 3 and 4
are set in genaddrconf_ifid_eui48 then override here in case dev->dev_id is
set.

> 
> >
> > >  	}
> > > +
> > >  	return 0;
> > >  }
> > >
> > > --
> > > 1.8.3.1
> > >
> > > --
> > > 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
> 
> 


--
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] 6+ messages in thread

* Re: [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
  2017-03-05 19:49           ` Yuval Shaia
@ 2017-03-06  5:15             ` Leon Romanovsky
       [not found]               ` <20170306051529.GN14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2017-03-06  5:15 UTC (permalink / raw
  To: Yuval Shaia
  Cc: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

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

On Sun, Mar 05, 2017 at 09:49:20PM +0200, Yuval Shaia wrote:
> On Sun, Mar 05, 2017 at 10:12:44AM +0200, Leon Romanovsky wrote:
> > On Sun, Mar 05, 2017 at 09:46:50AM +0200, Leon Romanovsky wrote:
> > > On Fri, Mar 03, 2017 at 10:49:05PM +0200, Yuval Shaia wrote:
> > > > This logic seems to be duplicated in (at least) three separate files.
> > > > Move it to one place so code can be re-use.
> > > >
> > > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > > > ---
> > > > v0 -> v1:
> > > > 	* Add missing #include
> > > > 	* Rename to genaddrconf_ifid_eui48
> > > > ---
> > > >  drivers/infiniband/hw/usnic/usnic_common_util.h | 11 +++--------
> > > >  drivers/infiniband/sw/rxe/rxe_net.c             | 11 ++---------
> > > >  include/net/addrconf.h                          | 18 ++++++++++++------
> > > >  3 files changed, 17 insertions(+), 23 deletions(-)
> > > >
> > > > diff --git a/drivers/infiniband/hw/usnic/usnic_common_util.h b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > > index b54986d..09871da 100644
> > > > --- a/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > > +++ b/drivers/infiniband/hw/usnic/usnic_common_util.h
> > > > @@ -34,6 +34,8 @@
> > > >  #ifndef USNIC_CMN_UTIL_H
> > > >  #define USNIC_CMN_UTIL_H
> > > >
> > > > +#include <net/addrconf.h>
> > > > +
> > > >  static inline void
> > > >  usnic_mac_to_gid(const char *const mac, char *raw_gid)
> > > >  {
> > > > @@ -57,14 +59,7 @@
> > > >  	raw_gid[1] = 0x80;
> > > >  	memset(&raw_gid[2], 0, 2);
> > > >  	memcpy(&raw_gid[4], &inaddr, 4);
> > > > -	raw_gid[8] = mac[0]^2;
> > > > -	raw_gid[9] = mac[1];
> > > > -	raw_gid[10] = mac[2];
> > > > -	raw_gid[11] = 0xff;
> > > > -	raw_gid[12] = 0xfe;
> > > > -	raw_gid[13] = mac[3];
> > > > -	raw_gid[14] = mac[4];
> > > > -	raw_gid[15] = mac[5];
> > > > +	genaddrconf_ifid_eui48(&raw_gid[8], mac);
> > > >  }
> > > >
> > > >  static inline void
> > > > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > > > index 4abdeb3..23ba9e1 100644
> > > > --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > > > +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > > > @@ -38,6 +38,7 @@
> > > >  #include <linux/if_vlan.h>
> > > >  #include <net/udp_tunnel.h>
> > > >  #include <net/sch_generic.h>
> > > > +#include <net/addrconf.h>
> > > >  #include <linux/netfilter.h>
> > > >  #include <rdma/ib_addr.h>
> > > >
> > > > @@ -86,18 +87,10 @@ struct rxe_dev *get_rxe_by_name(const char *name)
> > > >
> > > >  static __be64 rxe_mac_to_eui64(struct net_device *ndev)
> > > >  {
> > > > -	unsigned char *mac_addr = ndev->dev_addr;
> > > >  	__be64 eui64;
> > > >  	unsigned char *dst = (unsigned char *)&eui64;
> > > >
> > > > -	dst[0] = mac_addr[0] ^ 2;
> > > > -	dst[1] = mac_addr[1];
> > > > -	dst[2] = mac_addr[2];
> > > > -	dst[3] = 0xff;
> > > > -	dst[4] = 0xfe;
> > > > -	dst[5] = mac_addr[3];
> > > > -	dst[6] = mac_addr[4];
> > > > -	dst[7] = mac_addr[5];
> > > > +	genaddrconf_ifid_eui48(dst, ndev->dev_addr);
> > > >
> > > >  	return eui64;
> > > >  }
> > > > diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> > > > index 8f998af..07d0341 100644
> > > > --- a/include/net/addrconf.h
> > > > +++ b/include/net/addrconf.h
> > > > @@ -105,12 +105,21 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
> > > >  				 u32 addr_flags, bool sllao, bool tokenized,
> > > >  				 __u32 valid_lft, u32 prefered_lft);
> > > >
> > > > +static inline void genaddrconf_ifid_eui48(u8 *eui, const char *const addr)
> > > > +{
> > > > +	memcpy(eui, addr, 3);
> > > > +	eui[0] ^= 2;
> > > > +	eui[3] = 0xFF;
> > > > +	eui[4] = 0xFE;
> > > > +	memcpy(eui + 5, addr + 3, 3);
> > > > +}
> > > > +
> > > >  static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> > > >  {
> > > >  	if (dev->addr_len != ETH_ALEN)
> > > >  		return -1;
> > > > -	memcpy(eui, dev->dev_addr, 3);
> > > > -	memcpy(eui + 5, dev->dev_addr + 3, 3);
> > > > +
> > > > +	genaddrconf_ifid_eui48(eui, dev->dev_addr);
> > > >
> > > >  	/*
> > > >  	 * The zSeries OSA network cards can be shared among various
> > > > @@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> > > >  	if (dev->dev_id) {
> > > >  		eui[3] = (dev->dev_id >> 8) & 0xFF;
> > > >  		eui[4] = dev->dev_id & 0xFF;
> > > > -	} else {
> > > > -		eui[3] = 0xFF;
> > > > -		eui[4] = 0xFE;
> > > > -		eui[0] ^= 2;
> > >
> > > Sorry, but NAK.
> > > You missed the assignment below. In original code it WASN'T for dev->dev_id != NULL, and now it is.
> >
> > s/below/above
>
> I'm sorry but which assignment is missing? Default values for 0, 3 and 4
> are set in genaddrconf_ifid_eui48 then override here in case dev->dev_id is
> set.

Not really, in original code of addrconf_ifid_eui48(), the eui[0] is set
conditionally to be "eui[0] ^= 2" or stays without change. In your
proposed code, eui[0] will be always changed to be "eui[0] ^= 2".


>
> >
> > >
> > > >  	}
> > > > +
> > > >  	return 0;
> > > >  }
> > > >
> > > > --
> > > > 1.8.3.1
> > > >
> > > > --
> > > > 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
> >
> >
>
>

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

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

* Re: [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
       [not found]               ` <20170306051529.GN14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
@ 2017-03-06 11:54                 ` Yuval Shaia
  0 siblings, 0 replies; 6+ messages in thread
From: Yuval Shaia @ 2017-03-06 11:54 UTC (permalink / raw
  To: Leon Romanovsky
  Cc: benve-FYB4Gu1CFyUAvxtiuMwx3w, dgoodell-FYB4Gu1CFyUAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	monis-VPRAkNaXOzVWk0Htik3J/w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

> > > > >
> > > > >  	/*
> > > > >  	 * The zSeries OSA network cards can be shared among various
> > > > > @@ -128,11 +137,8 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
> > > > >  	if (dev->dev_id) {
> > > > >  		eui[3] = (dev->dev_id >> 8) & 0xFF;
> > > > >  		eui[4] = dev->dev_id & 0xFF;
> > > > > -	} else {
> > > > > -		eui[3] = 0xFF;
> > > > > -		eui[4] = 0xFE;
> > > > > -		eui[0] ^= 2;
> > > >
> > > > Sorry, but NAK.
> > > > You missed the assignment below. In original code it WASN'T for dev->dev_id != NULL, and now it is.
> > >
> > > s/below/above
> >
> > I'm sorry but which assignment is missing? Default values for 0, 3 and 4
> > are set in genaddrconf_ifid_eui48 then override here in case dev->dev_id is
> > set.
> 
> Not really, in original code of addrconf_ifid_eui48(), the eui[0] is set
> conditionally to be "eui[0] ^= 2" or stays without change. In your
> proposed code, eui[0] will be always changed to be "eui[0] ^= 2".

Thanks!
I was confused by the "missing", you should have used "extra assignment" or
even "wrong extra assignment" in your first comment.

Appreciate if you can review v2 which will reset eui[0] to default if
dev_id is used.

> 
> 
> >

--
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] 6+ messages in thread

end of thread, other threads:[~2017-03-06 11:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-03 20:49 [PATCH v1] {net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function Yuval Shaia
     [not found] ` <1488574145-27179-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-03-05  7:46   ` Leon Romanovsky
     [not found]     ` <20170305074650.GH14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-05  8:12       ` Leon Romanovsky
     [not found]         ` <20170305081244.GJ14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-05 19:49           ` Yuval Shaia
2017-03-06  5:15             ` Leon Romanovsky
     [not found]               ` <20170306051529.GN14379-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-06 11:54                 ` Yuval Shaia

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.