Re: [PATCH net-next] of_mdio: move of_mdio_parse_addr to header file

2017-06-15 Thread Liviu Dudau
On Tue, Jun 13, 2017 at 10:56:08AM -0400, Jon Mason wrote:
> The of_mdio_parse_addr() helper function is useful to other code, but
> the module dependency chain causes issues.  To work around this, we can
> move of_mdio_parse_addr() to be an inline function in the header file.
> This gets rid of the dependencies and still allows for the reuse of
> code.

This patch fixes the modules_install issue I was seeing with module
dependency cycle.

You can add my:

Tested-by: Liviu Dudau <li...@dudau.co.uk>

Thanks,
Liviu

> 
> Reported-by: Liviu Dudau <li...@dudau.co.uk>
> Signed-off-by: Jon Mason <jon.ma...@broadcom.com>
> Fixes: 342fa1964439 ("mdio: mux: make child bus walking more permissive and 
> errors more verbose")
> ---
>  drivers/of/of_mdio.c| 22 --
>  include/linux/of_mdio.h | 24 +++-
>  2 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 7e4c80f9b6cd..057963f2b74f 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -119,28 +119,6 @@ static void of_mdiobus_register_device(struct mii_bus 
> *mdio,
>   child->name, addr);
>  }
>  
> -int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
> -{
> - u32 addr;
> - int ret;
> -
> - ret = of_property_read_u32(np, "reg", );
> - if (ret < 0) {
> - dev_err(dev, "%s has invalid PHY address\n", np->full_name);
> - return ret;
> - }
> -
> - /* A PHY must have a reg property in the range [0-31] */
> - if (addr >= PHY_MAX_ADDR) {
> - dev_err(dev, "%s PHY address %i is too large\n",
> - np->full_name, addr);
> - return -EINVAL;
> - }
> -
> - return addr;
> -}
> -EXPORT_SYMBOL(of_mdio_parse_addr);
> -
>  /* The following is a list of PHY compatible strings which appear in
>   * some DTBs. The compatible string is never matched against a PHY
>   * driver, so is pointless. We only expect devices which are not PHYs
> diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> index ba35ba520487..f5db93bcd069 100644
> --- a/include/linux/of_mdio.h
> +++ b/include/linux/of_mdio.h
> @@ -27,11 +27,33 @@ struct phy_device *of_phy_attach(struct net_device *dev,
>phy_interface_t iface);
>  
>  extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
> -extern int of_mdio_parse_addr(struct device *dev, const struct device_node 
> *np);
>  extern int of_phy_register_fixed_link(struct device_node *np);
>  extern void of_phy_deregister_fixed_link(struct device_node *np);
>  extern bool of_phy_is_fixed_link(struct device_node *np);
>  
> +
> +static inline int of_mdio_parse_addr(struct device *dev,
> +  const struct device_node *np)
> +{
> + u32 addr;
> + int ret;
> +
> + ret = of_property_read_u32(np, "reg", );
> + if (ret < 0) {
> + dev_err(dev, "%s has invalid PHY address\n", np->full_name);
> + return ret;
> + }
> +
> + /* A PHY must have a reg property in the range [0-31] */
> + if (addr >= PHY_MAX_ADDR) {
> + dev_err(dev, "%s PHY address %i is too large\n",
> + np->full_name, addr);
> + return -EINVAL;
> + }
> +
> + return addr;
> +}
> +
>  #else /* CONFIG_OF_MDIO */
>  static inline int of_mdiobus_register(struct mii_bus *mdio, struct 
> device_node *np)
>  {
> -- 
> 2.7.4
> 

-- 
   _
 _|_|_
 ('_')
 (⊃  )⊃
 |_|_|


Re: [PATCH net-next] net: phy: use of_mdio_parse_addr

2017-06-07 Thread Liviu Dudau
On Fri, Jun 02, 2017 at 02:22:51PM -0400, David Miller wrote:
> From: Jon Mason 
> Date: Wed, 31 May 2017 15:43:30 -0400
> 
> > use of_mdio_parse_addr() in place of an OF read of reg and a bounds
> > check (which is litterally the exact same thing that
> > of_mdio_parse_addr() does)
> > 
> > Signed-off-by: Jon Mason 
> 
> Applied, thanks Jon.

This makes linux-next fail the modules_install target as depmod detects 2 
circular
dependencies. Reverting this patch fixes the issue.

depmod: ERROR: Cycle detected: libphy -> of_mdio -> fixed_phy -> libphy
depmod: ERROR: Cycle detected: libphy -> of_mdio -> libphy
depmod: ERROR: Found 3 modules in dependency cycles!
make[1]: *** [/home/dliviu/devel/kernel/Makefile:1245: _modinst_post] Error 1

This is on an ARCH=arm build, build I doubt it makes a difference. Let me know 
if
you need some .config values in order to reproduce.

Best regards,
Liviu



RESEND: [PATCH v3 net-next] sky2: use random address if EEPROM is bad

2015-09-28 Thread Liviu Dudau
On some embedded systems the EEPROM does not contain a valid MAC address.
In that case it is better to fallback to a generated mac address and
let init scripts fix the value later.

Reported-by: Liviu Dudau <liviu.du...@arm.com>
Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
[Changed handcoded setup to use eth_hw_addr_random() and to save new address 
into HW]
Signed-off-by: Liviu Dudau <liviu.du...@arm.com>
---
 drivers/net/ethernet/marvell/sky2.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..5606a04 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4819,6 +4819,18 @@ static struct net_device *sky2_init_netdev(struct 
sky2_hw *hw, unsigned port,
memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
  ETH_ALEN);
 
+   /* if the address is invalid, use a random value */
+   if (!is_valid_ether_addr(dev->dev_addr)) {
+   struct sockaddr sa = { AF_UNSPEC };
+
+   netdev_warn(dev,
+   "Invalid MAC address, defaulting to random\n");
+   eth_hw_addr_random(dev);
+   memcpy(sa.sa_data, dev->dev_addr, ETH_ALEN);
+   if (sky2_set_mac_address(dev, ))
+   netdev_warn(dev, "Failed to set MAC address.\n");
+   }
+
return dev;
 }
 
-- 
2.5.1

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


[PATCH v3] sky2: use random address if EEPROM is bad

2015-09-23 Thread Liviu Dudau
On some embedded systems the EEPROM does not contain a valid MAC address.
In that case it is better to fallback to a generated mac address and
let init scripts fix the value later.

Reported-by: Liviu Dudau <liviu.du...@arm.com>
Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
[Changed handcoded setup to use eth_hw_addr_random() and to save new address 
into HW]
Signed-off-by: Liviu Dudau <liviu.du...@arm.com>
---
 drivers/net/ethernet/marvell/sky2.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..5606a04 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4819,6 +4819,18 @@ static struct net_device *sky2_init_netdev(struct 
sky2_hw *hw, unsigned port,
memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
  ETH_ALEN);
 
+   /* if the address is invalid, use a random value */
+   if (!is_valid_ether_addr(dev->dev_addr)) {
+   struct sockaddr sa = { AF_UNSPEC };
+
+   netdev_warn(dev,
+   "Invalid MAC address, defaulting to random\n");
+   eth_hw_addr_random(dev);
+   memcpy(sa.sa_data, dev->dev_addr, ETH_ALEN);
+   if (sky2_set_mac_address(dev, ))
+   netdev_warn(dev, "Failed to set MAC address.\n");
+   }
+
return dev;
 }
 
-- 
2.5.1

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


Re: [PATCH v2 net-next] sky2: use random address if EEPROM is bad

2015-08-12 Thread Liviu Dudau
On Tue, Aug 11, 2015 at 06:01:32PM +0100, Stephen Hemminger wrote:
 On Tue, 11 Aug 2015 15:35:56 +0100
 Liviu Dudau liviu.du...@arm.com wrote:
 
  On some embedded systems the EEPROM does not contain a valid MAC address.
  In that case it is better to fallback to a generated mac address and
  let init scripts fix the value later.
  
  Reported-by: Liviu Dudau liviu.du...@arm.com
  Signed-off-by: Stephen Hemminger step...@networkplumber.org
  [Changed handcoded setup to use eth_hw_addr_random() instead]
  Signed-off-by: Liviu Dudau liviu.du...@arm.com
  ---
  I have tested this on my Juno platform and I can successfully do an nfsroot 
  boot.
  
  Best regards,
  Liviu
  
   drivers/net/ethernet/marvell/sky2.c | 7 +++
   1 file changed, 7 insertions(+)
  
  diff --git a/drivers/net/ethernet/marvell/sky2.c 
  b/drivers/net/ethernet/marvell/sky2.c
  index d9f4498..c309879 100644
  --- a/drivers/net/ethernet/marvell/sky2.c
  +++ b/drivers/net/ethernet/marvell/sky2.c
  @@ -4819,6 +4819,13 @@ static struct net_device *sky2_init_netdev(struct 
  sky2_hw *hw, unsigned port,
  memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port * 8,
ETH_ALEN);
   
  +   /* if the address is invalid, use a random value */
  +   if (!is_valid_ether_addr(dev-dev_addr)) {
  +   netdev_warn(dev,
  +   Invalid MAC address, defaulting to random\n);
  +   eth_hw_addr_random(dev);
  +   }
  +
  return dev;
   }
   
 
 This is not enough, you need to program the hardware with the new random MAC
 address. The easiest way is calling sky2_set_mac_address, but you need to 
 convert
 the address from array back to sockaddr.
 

OK, I am a bit confused as to why sky2_set_mac_address is needed here, as this 
was not
required by the existing function. Given that in my tests I get a random MAC 
address
assigned every time to the device and I can see the same MAC address with 
ifconfig, how
can I test the effect of sky2_set_mac_address if I add it?

Best regards,
Liviu

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 net-next] sky2: use random address if EEPROM is bad

2015-08-12 Thread Liviu Dudau
On Tue, Aug 11, 2015 at 07:56:06PM +0100, Sergei Shtylyov wrote:
 Hello.
 
 On 08/11/2015 05:35 PM, Liviu Dudau wrote:
 
  On some embedded systems the EEPROM does not contain a valid MAC address.
  In that case it is better to fallback to a generated mac address and
  let init scripts fix the value later.
 
  Reported-by: Liviu Dudau liviu.du...@arm.com
  Signed-off-by: Stephen Hemminger step...@networkplumber.org
  [Changed handcoded setup to use eth_hw_addr_random() instead]
  Signed-off-by: Liviu Dudau liviu.du...@arm.com
  ---
  I have tested this on my Juno platform and I can successfully do an nfsroot 
  boot.
 
  Best regards,
  Liviu
 
drivers/net/ethernet/marvell/sky2.c | 7 +++
1 file changed, 7 insertions(+)
 
  diff --git a/drivers/net/ethernet/marvell/sky2.c 
  b/drivers/net/ethernet/marvell/sky2.c
  index d9f4498..c309879 100644
  --- a/drivers/net/ethernet/marvell/sky2.c
  +++ b/drivers/net/ethernet/marvell/sky2.c
  @@ -4819,6 +4819,13 @@ static struct net_device *sky2_init_netdev(struct 
  sky2_hw *hw, unsigned port,
  memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port * 8,
ETH_ALEN);
 
  +   /* if the address is invalid, use a random value */
  +   if (!is_valid_ether_addr(dev-dev_addr)) {
  +   netdev_warn(dev,
  +   Invalid MAC address, defaulting to random\n);
 
 Please start the continuation line right under 'dev' on the borken up 
 line.

OK, I will make the changes for v3.

 
  +   eth_hw_addr_random(dev);
  +   }
  +
  return dev;
}
 
 MBR, Sergei
 

Thanks for reviewing this!

Best regards,
Liviu

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 net-next] sky2: use random address if EEPROM is bad

2015-08-12 Thread Liviu Dudau
On Wed, Aug 12, 2015 at 04:28:23PM +0100, Stephen Hemminger wrote:
 On Wed, 12 Aug 2015 10:30:05 +0100
 Liviu Dudau liviu.du...@arm.com wrote:
 
  On Tue, Aug 11, 2015 at 06:01:32PM +0100, Stephen Hemminger wrote:
   On Tue, 11 Aug 2015 15:35:56 +0100
   Liviu Dudau liviu.du...@arm.com wrote:
   
On some embedded systems the EEPROM does not contain a valid MAC 
address.
In that case it is better to fallback to a generated mac address and
let init scripts fix the value later.

Reported-by: Liviu Dudau liviu.du...@arm.com
Signed-off-by: Stephen Hemminger step...@networkplumber.org
[Changed handcoded setup to use eth_hw_addr_random() instead]
Signed-off-by: Liviu Dudau liviu.du...@arm.com
---
I have tested this on my Juno platform and I can successfully do an 
nfsroot boot.

Best regards,
Liviu

 drivers/net/ethernet/marvell/sky2.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..c309879 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4819,6 +4819,13 @@ static struct net_device 
*sky2_init_netdev(struct sky2_hw *hw, unsigned port,
memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port 
* 8,
  ETH_ALEN);
 
+   /* if the address is invalid, use a random value */
+   if (!is_valid_ether_addr(dev-dev_addr)) {
+   netdev_warn(dev,
+   Invalid MAC address, defaulting to random\n);
+   eth_hw_addr_random(dev);
+   }
+
return dev;
 }
 
   
   This is not enough, you need to program the hardware with the new random 
   MAC
   address. The easiest way is calling sky2_set_mac_address, but you need to 
   convert
   the address from array back to sockaddr.
   
  
  OK, I am a bit confused as to why sky2_set_mac_address is needed here, as 
  this was not
  required by the existing function. Given that in my tests I get a random 
  MAC address
  assigned every time to the device and I can see the same MAC address with 
  ifconfig, how
  can I test the effect of sky2_set_mac_address if I add it?
 
 The network device address is stored in two places. One is in the
 kernel (dev-dev_addr) and is  used by networking stack.
 The other is the hardware (actually two places) and is used filtering 
 received packets
 in the PHY and for sending hardware generated pause frames.
 
 When a random address is generated, you need to tell the hardware
 to use that address as well. I suspect your hardware maybe limited in 
 functionality
 and not do the normal filtering.
 

I understand now, thanks for explaining it. I admit my tests were very limited 
and I did not
try to capture any packets using the interface. I thought the DHCP discovery 
requires the
MAC address to be correct in the hardware to work, but it might be that the 
kernel's DHCP
client is more thorough than userspace.

I will add the setting of the MAC address in v3.

Best regards,
Liviu

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 net-next] sky2: use random address if EEPROM is bad

2015-08-11 Thread Liviu Dudau
On some embedded systems the EEPROM does not contain a valid MAC address.
In that case it is better to fallback to a generated mac address and
let init scripts fix the value later.

Reported-by: Liviu Dudau liviu.du...@arm.com
Signed-off-by: Stephen Hemminger step...@networkplumber.org
[Changed handcoded setup to use eth_hw_addr_random() instead]
Signed-off-by: Liviu Dudau liviu.du...@arm.com
---
I have tested this on my Juno platform and I can successfully do an nfsroot 
boot.

Best regards,
Liviu

 drivers/net/ethernet/marvell/sky2.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..c309879 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4819,6 +4819,13 @@ static struct net_device *sky2_init_netdev(struct 
sky2_hw *hw, unsigned port,
memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port * 8,
  ETH_ALEN);
 
+   /* if the address is invalid, use a random value */
+   if (!is_valid_ether_addr(dev-dev_addr)) {
+   netdev_warn(dev,
+   Invalid MAC address, defaulting to random\n);
+   eth_hw_addr_random(dev);
+   }
+
return dev;
 }
 
-- 
2.4.6

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] sky2: Add module parameter for passing the MAC address

2015-08-06 Thread Liviu Dudau
On Thu, Aug 06, 2015 at 01:32:33AM +0100, David Miller wrote:
 From: Liviu Dudau liviu.du...@arm.com
 Date: Wed,  5 Aug 2015 16:50:54 +0100
 
  For designs where EEPROMs are not connected to PCI Yukon2
  chips we need to get the MAC address from the firmware.
  Add a module parameter called 'mac_address' for this. It
  will be used if no DT node can be found and the B2_MAC
  register holds an invalid value.
  
  Signed-off-by: Liviu Dudau liviu.du...@arm.com
 
 Sorry, such module options are absolutely not allowed.

Please clarify if this is a drivers/net/ethernet policy or 
that is true for the larger subsystem. There are a few
networking drivers that have a mac_addr module parameter. I
personally used drivers/net/ethernet/8390/pcnet_cs.c as inspiration
for my patch.

 
 If an invalid MAC is present, it should be set to a random
 one via eth_random_addr().
 

Understood. Stephen Hemminger has provided a patch that I can try
and I will report back with the results.

Best regards,
Liviu

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] sky2: Add module parameter for passing the MAC address

2015-08-05 Thread Liviu Dudau
For designs where EEPROMs are not connected to PCI Yukon2
chips we need to get the MAC address from the firmware.
Add a module parameter called 'mac_address' for this. It
will be used if no DT node can be found and the B2_MAC
register holds an invalid value.

Signed-off-by: Liviu Dudau liviu.du...@arm.com
---
 drivers/net/ethernet/marvell/sky2.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..a977d95 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -101,6 +101,10 @@ static int legacy_pme = 0;
 module_param(legacy_pme, int, 0);
 MODULE_PARM_DESC(legacy_pme, Legacy power management);
 
+/* Ugh!  Let the firmware tell us the hardware address */
+static int mac_address[ETH_ALEN] = { 0, };
+module_param_array(mac_address, int, NULL, 0);
+
 static const struct pci_device_id sky2_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
@@ -4811,13 +4815,21 @@ static struct net_device *sky2_init_netdev(struct 
sky2_hw *hw, unsigned port,
/* try to get mac address in the following order:
 * 1) from device tree data
 * 2) from internal registers set by bootloader
+* 3) from the command line parameter
 */
iap = of_get_mac_address(hw-pdev-dev.of_node);
if (iap)
memcpy(dev-dev_addr, iap, ETH_ALEN);
-   else
+   else {
memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port * 8,
  ETH_ALEN);
+   if (!is_valid_ether_addr(dev-dev_addr[0])) {
+   int i;
+
+   for (i = 0; i  ETH_ALEN; i++)
+   dev-dev_addr[i] = mac_address[i];
+   }
+   }
 
return dev;
 }
-- 
2.4.6

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] sky2: Add module parameter for passing the MAC address

2015-08-05 Thread Liviu Dudau
On Wed, Aug 05, 2015 at 05:40:57PM +0100, Stephen Hemminger wrote:
 On Wed,  5 Aug 2015 16:50:54 +0100
 Liviu Dudau liviu.du...@arm.com wrote:
 
  For designs where EEPROMs are not connected to PCI Yukon2
  chips we need to get the MAC address from the firmware.
  Add a module parameter called 'mac_address' for this. It
  will be used if no DT node can be found and the B2_MAC
  register holds an invalid value.
  
  Signed-off-by: Liviu Dudau liviu.du...@arm.com
 
 Yes, I can see that this can be a real problem, and other drivers
 solve the problem. The standard method is to assign a random mac address
 (and then let scripts overwrite) rather than introducing module parameter.
 Module parameters are discouraged because they are device specific.
 

I agree. However, in my case, the boards people have assigned MAC addresses
to the chip, they just didn't built the board in such a way as to allow one
to store that MAC address in a permanent way :( And no, I can't use the DT
because the chip is actually on the PCIe bus.

Even with the generation of a random address, it still needs to be copied
into the device, so I would guess that a version of the patch I've sent is
still relevant?

Best regards,
Liviu

  
 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] sky2: Add module parameter for passing the MAC address

2015-08-05 Thread Liviu Dudau
On Wed, Aug 05, 2015 at 06:15:37PM +0100, Ryan Harkin wrote:
On 5 August 2015 at 16:50, Liviu Dudau [1]liviu.du...@arm.com wrote:
 
  For designs where EEPROMs are not connected to PCI Yukon2
  chips we need to get the MAC address from the firmware.
  Add a module parameter called 'mac_address' for this. It
  will be used if no DT node can be found and the B2_MAC
  register holds an invalid value.
 
  Signed-off-by: Liviu Dudau [2]liviu.du...@arm.com
 
Looks good to me.  FWIW, you can have a tested or reviewed-by at your 
 preference:
Tested-by: Ryan Harkin [3]ryan.har...@linaro.org
Reviewed-by: Ryan Harkin [4]ryan.har...@linaro.org
 

Thanks Ryan, I think one can provide both tags, so I will use them together.

Best regards,
Liviu

 
 
  ---
   drivers/net/ethernet/marvell/sky2.c | 14 +-
   1 file changed, 13 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/net/ethernet/marvell/sky2.c 
 b/drivers/net/ethernet/marvell/sky2.c
  index d9f4498..a977d95 100644
  --- a/drivers/net/ethernet/marvell/sky2.c
  +++ b/drivers/net/ethernet/marvell/sky2.c
  @@ -101,6 +101,10 @@ static int legacy_pme = 0;
   module_param(legacy_pme, int, 0);
   MODULE_PARM_DESC(legacy_pme, Legacy power management);
 
  +/* Ugh!  Let the firmware tell us the hardware address */
  +static int mac_address[ETH_ALEN] = { 0, };
  +module_param_array(mac_address, int, NULL, 0);
  +
   static const struct pci_device_id sky2_id_table[] = {
          { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
          { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
  @@ -4811,13 +4815,21 @@ static struct net_device 
 *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
          /* try to get mac address in the following order:
           * 1) from device tree data
           * 2) from internal registers set by bootloader
  +        * 3) from the command line parameter
           */
          iap = of_get_mac_address(hw-pdev-dev.of_node);
          if (iap)
                  memcpy(dev-dev_addr, iap, ETH_ALEN);
  -       else
  +       else {
                  memcpy_fromio(dev-dev_addr, hw-regs + B2_MAC_1 + port 
 * 8,
                                ETH_ALEN);
  +               if (!is_valid_ether_addr(dev-dev_addr[0])) {
  +                       int i;
  +
  +                       for (i = 0; i  ETH_ALEN; i++)
  +                               dev-dev_addr[i] = mac_address[i];
  +               }
  +       }
 
          return dev;
   }
  --
  2.4.6
 
 References
 
Visible links
1. mailto:liviu.du...@arm.com
2. mailto:liviu.du...@arm.com
3. mailto:ryan.har...@linaro.org
4. mailto:ryan.har...@linaro.org

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html