netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
       [not found]     ` <20101229103014.GD19347@freescale.com>
@ 2010-12-29 10:37       ` Uwe Kleine-König
  2010-12-29 11:08         ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Uwe Kleine-König @ 2010-12-29 10:37 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hello,

On Wed, Dec 29, 2010 at 06:30:15PM +0800, Shawn Guo wrote:
> Sorry, Baruch.  I missed two comments in the last reply.
> 
> On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > Hi Shawn,
> > 
> > Please add netdev@vger.kernel.org to the Cc of all your fec driver patches.
> > 
> I was aware of this after I sent out the patch set last night.
> Can I just resend all the patches in v2 and get netdev@vger.kernel.org
> included?
[I just added netdev for this reply.  I think adding it for v2 is OK
then.  For those interested, the whole series can be found at

	http://thread.gmane.org/gmane.linux.ports.arm.kernel/100902

.]
 
> > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> [...]
> > > +	/*
> > > +	 * try to get mac address in following order:
> > > +	 *
> > > +	 * 1) kernel command line fec_mac=xx:xx:xx...
> > > +	 */
> > > +	iap = fec_mac_default;
> > > +
> > > +	/*
> > > +	 * 2) from flash or fuse (via platform data)
> > > +	 */
> > 
> > Again, how do you handle the dual MAC case?
> > 
> For the platform data case, the following patch reads both mac
> addresses.
> 
> [PATCH 09/10] ARM: mx28: read fec mac address from ocotp
> 
> +static int __init mx28evk_fec_get_mac(void)
> +{
> +       int i, ret;
> +       u32 val;
> +
> +       /*
> +        * OCOTP only stores the last 4 octets for each mac address,
> +        * so hard-coding the first two octets as Freescale OUI (00:04:9f)
> +        * is needed.
> +        */
> +       for (i = 0; i < 2; i++) {
> +               ret = mxs_read_ocotp(0x20 + i * 0x10, 1, &val);
> +               if (ret)
> +                       goto error;
> +
> +               mx28_fec_pdata[i].mac[0] = 0x00;
> +               mx28_fec_pdata[i].mac[1] = 0x04;
> +               mx28_fec_pdata[i].mac[2] = (val >> 24) & 0xff;
> +               mx28_fec_pdata[i].mac[3] = (val >> 16) & 0xff;
> +               mx28_fec_pdata[i].mac[4] = (val >> 8) & 0xff;
> +               mx28_fec_pdata[i].mac[5] = (val >> 0) & 0xff;
uuh.  Is ((val >> 24) & 0xff) supposed to be 0x9f?  If not this might
have unwanted effects (practical, don't know about legal ones).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-29 10:37       ` [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac Uwe Kleine-König
@ 2010-12-29 11:08         ` Shawn Guo
  2010-12-29 11:10           ` Uwe Kleine-König
  0 siblings, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2010-12-29 11:08 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Uwe,

On Wed, Dec 29, 2010 at 11:37:58AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Dec 29, 2010 at 06:30:15PM +0800, Shawn Guo wrote:
> > Sorry, Baruch.  I missed two comments in the last reply.
> > 
> > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > Hi Shawn,
> > > 
> > > Please add netdev@vger.kernel.org to the Cc of all your fec driver patches.
> > > 
> > I was aware of this after I sent out the patch set last night.
> > Can I just resend all the patches in v2 and get netdev@vger.kernel.org
> > included?
> [I just added netdev for this reply.  I think adding it for v2 is OK
> then.  For those interested, the whole series can be found at
> 
> 	http://thread.gmane.org/gmane.linux.ports.arm.kernel/100902
> 
> .]
>  
Thanks.

> > > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > [...]
> > > > +	/*
> > > > +	 * try to get mac address in following order:
> > > > +	 *
> > > > +	 * 1) kernel command line fec_mac=xx:xx:xx...
> > > > +	 */
> > > > +	iap = fec_mac_default;
> > > > +
> > > > +	/*
> > > > +	 * 2) from flash or fuse (via platform data)
> > > > +	 */
> > > 
> > > Again, how do you handle the dual MAC case?
> > > 
> > For the platform data case, the following patch reads both mac
> > addresses.
> > 
> > [PATCH 09/10] ARM: mx28: read fec mac address from ocotp
> > 
> > +static int __init mx28evk_fec_get_mac(void)
> > +{
> > +       int i, ret;
> > +       u32 val;
> > +
> > +       /*
> > +        * OCOTP only stores the last 4 octets for each mac address,
> > +        * so hard-coding the first two octets as Freescale OUI (00:04:9f)
> > +        * is needed.
> > +        */
> > +       for (i = 0; i < 2; i++) {
> > +               ret = mxs_read_ocotp(0x20 + i * 0x10, 1, &val);
> > +               if (ret)
> > +                       goto error;
> > +
> > +               mx28_fec_pdata[i].mac[0] = 0x00;
> > +               mx28_fec_pdata[i].mac[1] = 0x04;
> > +               mx28_fec_pdata[i].mac[2] = (val >> 24) & 0xff;
> > +               mx28_fec_pdata[i].mac[3] = (val >> 16) & 0xff;
> > +               mx28_fec_pdata[i].mac[4] = (val >> 8) & 0xff;
> > +               mx28_fec_pdata[i].mac[5] = (val >> 0) & 0xff;
> uuh.  Is ((val >> 24) & 0xff) supposed to be 0x9f?  If not this might
> have unwanted effects (practical, don't know about legal ones).
Yes, it is 0x9f.

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-29 11:08         ` Shawn Guo
@ 2010-12-29 11:10           ` Uwe Kleine-König
  2010-12-29 12:00             ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Uwe Kleine-König @ 2010-12-29 11:10 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Shawn,

On Wed, Dec 29, 2010 at 07:08:29PM +0800, Shawn Guo wrote:
> On Wed, Dec 29, 2010 at 11:37:58AM +0100, Uwe Kleine-König wrote:
> > On Wed, Dec 29, 2010 at 06:30:15PM +0800, Shawn Guo wrote:
> > > > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > > [...]
> > > > > +	/*
> > > > > +	 * try to get mac address in following order:
> > > > > +	 *
> > > > > +	 * 1) kernel command line fec_mac=xx:xx:xx...
> > > > > +	 */
> > > > > +	iap = fec_mac_default;
> > > > > +
> > > > > +	/*
> > > > > +	 * 2) from flash or fuse (via platform data)
> > > > > +	 */
> > > > 
> > > > Again, how do you handle the dual MAC case?
> > > > 
> > > For the platform data case, the following patch reads both mac
> > > addresses.
> > > 
> > > [PATCH 09/10] ARM: mx28: read fec mac address from ocotp
> > > 
> > > +static int __init mx28evk_fec_get_mac(void)
> > > +{
> > > +       int i, ret;
> > > +       u32 val;
> > > +
> > > +       /*
> > > +        * OCOTP only stores the last 4 octets for each mac address,
> > > +        * so hard-coding the first two octets as Freescale OUI (00:04:9f)
> > > +        * is needed.
> > > +        */
> > > +       for (i = 0; i < 2; i++) {
> > > +               ret = mxs_read_ocotp(0x20 + i * 0x10, 1, &val);
> > > +               if (ret)
> > > +                       goto error;
> > > +
> > > +               mx28_fec_pdata[i].mac[0] = 0x00;
> > > +               mx28_fec_pdata[i].mac[1] = 0x04;
> > > +               mx28_fec_pdata[i].mac[2] = (val >> 24) & 0xff;
> > > +               mx28_fec_pdata[i].mac[3] = (val >> 16) & 0xff;
> > > +               mx28_fec_pdata[i].mac[4] = (val >> 8) & 0xff;
> > > +               mx28_fec_pdata[i].mac[5] = (val >> 0) & 0xff;
> > uuh.  Is ((val >> 24) & 0xff) supposed to be 0x9f?  If not this might
> > have unwanted effects (practical, don't know about legal ones).
> Yes, it is 0x9f.
Then maybe hardcode that, or at least warn if it's not?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
       [not found]       ` <20101229103138.GT14221@pengutronix.de>
@ 2010-12-29 11:58         ` Shawn Guo
  2010-12-29 12:42           ` Uwe Kleine-König
  0 siblings, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2010-12-29 11:58 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Uwe,

On Wed, Dec 29, 2010 at 11:31:38AM +0100, Uwe Kleine-König wrote:
> Hello Shawn,
> 
> On Wed, Dec 29, 2010 at 06:05:21PM +0800, Shawn Guo wrote:
> > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > Hi Shawn,
> > > In the case of dual MAC that you later add support for, the address which one 
> > > is being set? Is there a way to set both in kernel command line?
> > > 
> > The fec0 gets fec_mac and fec1 gets fec_mac + 1. The following code
> > in function fec_get_mac takes care of it.
> > 
> > 	/* Adjust MAC if using default MAC address */
> default MAC address means the address passed via cmdline?  Sounds
> confusing to me.
Will change the comment and fec_mac_default name to address
the concern.

> 
> > 	if (iap == fec_mac_default)
> > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> Can this overflow?  (I didn't check the code, so my concern might be
> completely stupid here.)
No. dev->dev_addr points to netdev_hw_addr->addr, which is a 32 bytes array.

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-29 11:10           ` Uwe Kleine-König
@ 2010-12-29 12:00             ` Shawn Guo
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Guo @ 2010-12-29 12:00 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Uwe,

On Wed, Dec 29, 2010 at 12:10:19PM +0100, Uwe Kleine-König wrote:
> Hi Shawn,
> 
> On Wed, Dec 29, 2010 at 07:08:29PM +0800, Shawn Guo wrote:
> > On Wed, Dec 29, 2010 at 11:37:58AM +0100, Uwe Kleine-König wrote:
> > > On Wed, Dec 29, 2010 at 06:30:15PM +0800, Shawn Guo wrote:
> > > > > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > > > [...]
> > > > > > +	/*
> > > > > > +	 * try to get mac address in following order:
> > > > > > +	 *
> > > > > > +	 * 1) kernel command line fec_mac=xx:xx:xx...
> > > > > > +	 */
> > > > > > +	iap = fec_mac_default;
> > > > > > +
> > > > > > +	/*
> > > > > > +	 * 2) from flash or fuse (via platform data)
> > > > > > +	 */
> > > > > 
> > > > > Again, how do you handle the dual MAC case?
> > > > > 
> > > > For the platform data case, the following patch reads both mac
> > > > addresses.
> > > > 
> > > > [PATCH 09/10] ARM: mx28: read fec mac address from ocotp
> > > > 
> > > > +static int __init mx28evk_fec_get_mac(void)
> > > > +{
> > > > +       int i, ret;
> > > > +       u32 val;
> > > > +
> > > > +       /*
> > > > +        * OCOTP only stores the last 4 octets for each mac address,
> > > > +        * so hard-coding the first two octets as Freescale OUI (00:04:9f)
> > > > +        * is needed.
> > > > +        */
> > > > +       for (i = 0; i < 2; i++) {
> > > > +               ret = mxs_read_ocotp(0x20 + i * 0x10, 1, &val);
> > > > +               if (ret)
> > > > +                       goto error;
> > > > +
> > > > +               mx28_fec_pdata[i].mac[0] = 0x00;
> > > > +               mx28_fec_pdata[i].mac[1] = 0x04;
> > > > +               mx28_fec_pdata[i].mac[2] = (val >> 24) & 0xff;
> > > > +               mx28_fec_pdata[i].mac[3] = (val >> 16) & 0xff;
> > > > +               mx28_fec_pdata[i].mac[4] = (val >> 8) & 0xff;
> > > > +               mx28_fec_pdata[i].mac[5] = (val >> 0) & 0xff;
> > > uuh.  Is ((val >> 24) & 0xff) supposed to be 0x9f?  If not this might
> > > have unwanted effects (practical, don't know about legal ones).
> > Yes, it is 0x9f.
> Then maybe hardcode that, or at least warn if it's not?
> 
Will hard-code it.

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-29 11:58         ` Shawn Guo
@ 2010-12-29 12:42           ` Uwe Kleine-König
  2010-12-30  2:12             ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Uwe Kleine-König @ 2010-12-29 12:42 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hello Shawn,

On Wed, Dec 29, 2010 at 07:58:09PM +0800, Shawn Guo wrote:
> On Wed, Dec 29, 2010 at 11:31:38AM +0100, Uwe Kleine-König wrote:
> > On Wed, Dec 29, 2010 at 06:05:21PM +0800, Shawn Guo wrote:
> > > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > 	if (iap == fec_mac_default)
> > > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> > Can this overflow?  (I didn't check the code, so my concern might be
> > completely stupid here.)
> No. dev->dev_addr points to netdev_hw_addr->addr, which is a 32 bytes array.
I didn't mean an out-of-bound access, but what is if
fec_mac_default[ETH_ALEN-1] is 0xff and you add 1?  Does that result in
0x100 or 0?  What if id is <0?  For big ids you might even handle a
carry to indixes <ETH_ALEN-2.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-29 12:42           ` Uwe Kleine-König
@ 2010-12-30  2:12             ` Shawn Guo
  2010-12-30  8:04               ` Uwe Kleine-König
  0 siblings, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2010-12-30  2:12 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Uwe,

On Wed, Dec 29, 2010 at 01:42:21PM +0100, Uwe Kleine-König wrote:
> Hello Shawn,
> 
> On Wed, Dec 29, 2010 at 07:58:09PM +0800, Shawn Guo wrote:
> > On Wed, Dec 29, 2010 at 11:31:38AM +0100, Uwe Kleine-König wrote:
> > > On Wed, Dec 29, 2010 at 06:05:21PM +0800, Shawn Guo wrote:
> > > > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > > 	if (iap == fec_mac_default)
> > > > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> > > Can this overflow?  (I didn't check the code, so my concern might be
> > > completely stupid here.)
> > No. dev->dev_addr points to netdev_hw_addr->addr, which is a 32 bytes array.
> I didn't mean an out-of-bound access, but what is if
> fec_mac_default[ETH_ALEN-1] is 0xff and you add 1?  Does that result in
> 0x100 or 0?  What if id is <0?  For big ids you might even handle a
> carry to indixes <ETH_ALEN-2.
> 
First of all, all my patch did is changing fep->index to,
fep->pdev->id, which should not bring any problem you are concerned.

Secondly, I do not understand how the overflow on 
fec_mac_default[ETH_ALEN-1] can result in a carry on the next array
element. Here is what I'm seeing with fec_mac=00:04:9f:01:30:ff.

eth0      Link encap:Ethernet  HWaddr 00:04:9F:01:30:FF
eth1      Link encap:Ethernet  HWaddr 00:04:9F:01:30:00

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
       [not found]     ` <20101229100520.GB19347@freescale.com>
       [not found]       ` <20101229103138.GT14221@pengutronix.de>
@ 2010-12-30  4:29       ` Shawn Guo
  2010-12-30  5:29         ` Baruch Siach
  1 sibling, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2010-12-30  4:29 UTC (permalink / raw)
  To: Baruch Siach
  Cc: davem, gerg, eric, bryan.wu, r64343, B32542, u.kleine-koenig, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Baruch,

On Wed, Dec 29, 2010 at 06:05:20PM +0800, Shawn Guo wrote:
> Hi Baruch,
> 
> On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > Hi Shawn,
> > 
> > Please add netdev@vger.kernel.org to the Cc of all your fec driver patches.
> > 
> > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > > Add mac field into fec_platform_data and consolidate function
> > > fec_get_mac to get mac address in following order.
> > > 
> > >  1) kernel command line fec_mac=xx:xx:xx...
> > 
> > In the case of dual MAC that you later add support for, the address which one 
> > is being set? Is there a way to set both in kernel command line?
> > 
> The fec0 gets fec_mac and fec1 gets fec_mac + 1. The following code
> in function fec_get_mac takes care of it.
> 
> 	/* Adjust MAC if using default MAC address */
> 	if (iap == fec_mac_default)
> 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> 
> 
> > Also, instead of inventing another kernel command line parameter, it is better 
> > IMO to use the module parameters mechanism. The greth NIC driver already uses 
> > this method for setting MAC address. Look for 'macaddr' in 
> > drivers/net/greth.c, and the explanation at the beginning of 
> > Documentation/kernel-parameters.txt.
> > 
> Sounds good. Thanks.
> 
I just thought this over again. Module parameter might not be
the best here. fec is usually used to mount nfs during boot,
which requires a built-in driver other than module.

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-30  4:29       ` Shawn Guo
@ 2010-12-30  5:29         ` Baruch Siach
  2010-12-30  7:20           ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2010-12-30  5:29 UTC (permalink / raw)
  To: Shawn Guo
  Cc: davem, gerg, eric, bryan.wu, r64343, B32542, u.kleine-koenig, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hi Shawn,

On Thu, Dec 30, 2010 at 12:29:00PM +0800, Shawn Guo wrote:
> On Wed, Dec 29, 2010 at 06:05:20PM +0800, Shawn Guo wrote:
> > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > Please add netdev@vger.kernel.org to the Cc of all your fec driver 
> > > patches.
> > > 
> > > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > > > Add mac field into fec_platform_data and consolidate function
> > > > fec_get_mac to get mac address in following order.
> > > > 
> > > >  1) kernel command line fec_mac=xx:xx:xx...
> > > 
> > > In the case of dual MAC that you later add support for, the address which one 
> > > is being set? Is there a way to set both in kernel command line?
> > > 
> > The fec0 gets fec_mac and fec1 gets fec_mac + 1. The following code
> > in function fec_get_mac takes care of it.
> > 
> > 	/* Adjust MAC if using default MAC address */
> > 	if (iap == fec_mac_default)
> > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> > > Also, instead of inventing another kernel command line parameter, it is 
> > > better IMO to use the module parameters mechanism. The greth NIC driver 
> > > already uses this method for setting MAC address. Look for 'macaddr' in 
> > > drivers/net/greth.c, and the explanation at the beginning of 
> > > Documentation/kernel-parameters.txt.
> > > 
> > Sounds good. Thanks.
> > 
> I just thought this over again. Module parameter might not be
> the best here. fec is usually used to mount nfs during boot,
> which requires a built-in driver other than module.

See the explanation at the beginning of Documentation/kernel-parameters.txt.  
You can give module parameters at the kernel command line.

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-30  5:29         ` Baruch Siach
@ 2010-12-30  7:20           ` Shawn Guo
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Guo @ 2010-12-30  7:20 UTC (permalink / raw)
  To: Baruch Siach
  Cc: davem, gerg, eric, bryan.wu, r64343, B32542, u.kleine-koenig, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

On Thu, Dec 30, 2010 at 07:29:25AM +0200, Baruch Siach wrote:
> Hi Shawn,
> 
> On Thu, Dec 30, 2010 at 12:29:00PM +0800, Shawn Guo wrote:
> > On Wed, Dec 29, 2010 at 06:05:20PM +0800, Shawn Guo wrote:
> > > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > > Please add netdev@vger.kernel.org to the Cc of all your fec driver 
> > > > patches.
> > > > 
> > > > On Tue, Dec 28, 2010 at 10:55:48PM +0800, Shawn Guo wrote:
> > > > > Add mac field into fec_platform_data and consolidate function
> > > > > fec_get_mac to get mac address in following order.
> > > > > 
> > > > >  1) kernel command line fec_mac=xx:xx:xx...
> > > > 
> > > > In the case of dual MAC that you later add support for, the address which one 
> > > > is being set? Is there a way to set both in kernel command line?
> > > > 
> > > The fec0 gets fec_mac and fec1 gets fec_mac + 1. The following code
> > > in function fec_get_mac takes care of it.
> > > 
> > > 	/* Adjust MAC if using default MAC address */
> > > 	if (iap == fec_mac_default)
> > > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> > > > Also, instead of inventing another kernel command line parameter, it is 
> > > > better IMO to use the module parameters mechanism. The greth NIC driver 
> > > > already uses this method for setting MAC address. Look for 'macaddr' in 
> > > > drivers/net/greth.c, and the explanation at the beginning of 
> > > > Documentation/kernel-parameters.txt.
> > > > 
> > > Sounds good. Thanks.
> > > 
> > I just thought this over again. Module parameter might not be
> > the best here. fec is usually used to mount nfs during boot,
> > which requires a built-in driver other than module.
> 
> See the explanation at the beginning of Documentation/kernel-parameters.txt.  
> You can give module parameters at the kernel command line.
> 
Ah, my dumb.

Just tested, and it works.  Thanks, Baruch.

-- 
Regards,
Shawn


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

* Re: [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac
  2010-12-30  2:12             ` Shawn Guo
@ 2010-12-30  8:04               ` Uwe Kleine-König
  0 siblings, 0 replies; 11+ messages in thread
From: Uwe Kleine-König @ 2010-12-30  8:04 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Baruch Siach, davem, gerg, eric, bryan.wu, r64343, B32542, lw,
	w.sang, s.hauer, linux-arm-kernel, netdev

Hello Shawn,

On Thu, Dec 30, 2010 at 10:12:44AM +0800, Shawn Guo wrote:
> On Wed, Dec 29, 2010 at 01:42:21PM +0100, Uwe Kleine-König wrote:
> > On Wed, Dec 29, 2010 at 07:58:09PM +0800, Shawn Guo wrote:
> > > On Wed, Dec 29, 2010 at 11:31:38AM +0100, Uwe Kleine-König wrote:
> > > > On Wed, Dec 29, 2010 at 06:05:21PM +0800, Shawn Guo wrote:
> > > > > On Wed, Dec 29, 2010 at 08:53:30AM +0200, Baruch Siach wrote:
> > > > > 	if (iap == fec_mac_default)
> > > > > 		dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->pdev->id;
> > > > Can this overflow?  (I didn't check the code, so my concern might be
> > > > completely stupid here.)
> > > No. dev->dev_addr points to netdev_hw_addr->addr, which is a 32 bytes array.
> > I didn't mean an out-of-bound access, but what is if
> > fec_mac_default[ETH_ALEN-1] is 0xff and you add 1?  Does that result in
> > 0x100 or 0?  What if id is <0?  For big ids you might even handle a
> > carry to indixes <ETH_ALEN-2.
> > 
> First of all, all my patch did is changing fep->index to,
> fep->pdev->id, which should not bring any problem you are concerned.
> 
> Secondly, I do not understand how the overflow on 
> fec_mac_default[ETH_ALEN-1] can result in a carry on the next array
> element. Here is what I'm seeing with fec_mac=00:04:9f:01:30:ff.
There is no automatic carry to the next array element.  I just wondered
how overflow should be handled ...
 
> eth0      Link encap:Ethernet  HWaddr 00:04:9F:01:30:FF
> eth1      Link encap:Ethernet  HWaddr 00:04:9F:01:30:00
If this is intended, it's totally OK for me.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2010-12-30  8:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1293548155-16328-1-git-send-email-shawn.guo@freescale.com>
     [not found] ` <1293548155-16328-4-git-send-email-shawn.guo@freescale.com>
     [not found]   ` <20101229065329.GB31010@jasper.tkos.co.il>
     [not found]     ` <20101229103014.GD19347@freescale.com>
2010-12-29 10:37       ` [PATCH 03/10] net/fec: add mac field into platform data and consolidate fec_get_mac Uwe Kleine-König
2010-12-29 11:08         ` Shawn Guo
2010-12-29 11:10           ` Uwe Kleine-König
2010-12-29 12:00             ` Shawn Guo
     [not found]     ` <20101229100520.GB19347@freescale.com>
     [not found]       ` <20101229103138.GT14221@pengutronix.de>
2010-12-29 11:58         ` Shawn Guo
2010-12-29 12:42           ` Uwe Kleine-König
2010-12-30  2:12             ` Shawn Guo
2010-12-30  8:04               ` Uwe Kleine-König
2010-12-30  4:29       ` Shawn Guo
2010-12-30  5:29         ` Baruch Siach
2010-12-30  7:20           ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).