All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-17 23:49 ` John Holland
  0 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-17 23:49 UTC (permalink / raw)
  To: intel-wired-lan, netdev; +Cc: jeffrey.t.kirsher

Hello,

The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
and has no externel EEPROM interface [1]. The following allows the
driver to pickup the MAC address from a device tree blob when CONFIG_OF
has been enabled.

[1]http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html

Changes V2
- Restrict searching for compatible devices to current pci device.

Changes V3
- Add device tree binding documentation.

Changes V4
- Rebase patch.

Signed-off-by: John Holland<jotihojr@gmail.com>
---

  Documentation/devicetree/bindings/net/intel,i210.txt         | 36 
++++++++++++++++++++++
  drivers/net/ethernet/intel/igb/igb_main.c                    | 31 
+++++++++++++++++++
  2 files changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/intel,i210.txt 
b/Documentation/devicetree/bindings/net/intel,i210.txt
new file mode 100644
index 0000000..d6ac8d3
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/intel,i210.txt
@@ -0,0 +1,36 @@
+* Intel I210, I211 PCIe bus controller
+
+Required properties:
+- compatible: must be "intel,i210" as described in
+  Documentation/devicetree/bindings/net/phy.txt;
+
+Optional properties:
+- local-mac-address: as described in
+  Documentation/devicetree/bindings/net/ethernet.txt;
+- mac-address: as described in
+  Documentation/devicetree/bindings/net/ethernet.txt;
+
+Child nodes of this PCIe bus controller node are a subset
+of the standard Ethernet PHY device nodes.
+
+Example:
+
+/*
+ * Set a valid MAC address from the u-boot environment variable eth1addr.
+ * The resulting value may be viewed under
+ * <sysfs>/firmware/devicetree/base/soc/pcie@0x01000000/i211@bus1/
+ */
+
+#include "imx6q.dtsi";
+
+/ {
+	aliases {
+		ethernet1 = &eth1;
+	};
+};
+
+&pcie {
+	eth1: i211@bus1 {
+		compatible = "intel,i210";
+	};
+};
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index a98f418..a3203ec 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -57,6 +57,11 @@
  #include "igb.h"
  #include "igb_cdev.h"

+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
  #define MAJ 5
  #define MIN 3
  #define BUILD 0
@@ -2299,6 +2304,27 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
  	return status;
  }

+#ifdef CONFIG_OF
+/**
+ *  igb_read_mac_addr_dts - Read mac address from the device tree blob
+ *  @dev: pointer to device structure
+ *  @mac_addr: pointer to found mac address
+ **/
+static void igb_read_mac_addr_dts(const struct device *dev, u8 *mac_addr)
+{
+	const u8 *mac;
+	struct device_node *dn;
+
+	dn = of_find_compatible_node(dev->of_node, NULL, "intel,i210");
+	if (dn) {
+		mac = of_get_mac_address(dn);
+		if (mac)
+			ether_addr_copy(mac_addr, mac);
+	}
+}
+#endif
+
+
  /**
   *  igb_probe - Device Initialization Routine
   *  @pdev: PCI device information struct
@@ -2511,6 +2537,11 @@ static int igb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
  	if (hw->mac.ops.read_mac_addr(hw))
  		dev_err(&pdev->dev, "NVM Read Error\n");

+#ifdef CONFIG_OF
+	if (!is_valid_ether_addr(hw->mac.addr))
+		igb_read_mac_addr_dts(&pdev->dev, hw->mac.addr);
+#endif
+
  	memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);

  	if (!is_valid_ether_addr(netdev->dev_addr)) {

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-17 23:49 ` John Holland
  0 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-17 23:49 UTC (permalink / raw)
  To: intel-wired-lan

Hello,

The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
and has no externel EEPROM interface [1]. The following allows the
driver to pickup the MAC address from a device tree blob when CONFIG_OF
has been enabled.

[1]http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html

Changes V2
- Restrict searching for compatible devices to current pci device.

Changes V3
- Add device tree binding documentation.

Changes V4
- Rebase patch.

Signed-off-by: John Holland<jotihojr@gmail.com>
---

  Documentation/devicetree/bindings/net/intel,i210.txt         | 36 
++++++++++++++++++++++
  drivers/net/ethernet/intel/igb/igb_main.c                    | 31 
+++++++++++++++++++
  2 files changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/intel,i210.txt 
b/Documentation/devicetree/bindings/net/intel,i210.txt
new file mode 100644
index 0000000..d6ac8d3
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/intel,i210.txt
@@ -0,0 +1,36 @@
+* Intel I210, I211 PCIe bus controller
+
+Required properties:
+- compatible: must be "intel,i210" as described in
+  Documentation/devicetree/bindings/net/phy.txt;
+
+Optional properties:
+- local-mac-address: as described in
+  Documentation/devicetree/bindings/net/ethernet.txt;
+- mac-address: as described in
+  Documentation/devicetree/bindings/net/ethernet.txt;
+
+Child nodes of this PCIe bus controller node are a subset
+of the standard Ethernet PHY device nodes.
+
+Example:
+
+/*
+ * Set a valid MAC address from the u-boot environment variable eth1addr.
+ * The resulting value may be viewed under
+ * <sysfs>/firmware/devicetree/base/soc/pcie at 0x01000000/i211 at bus1/
+ */
+
+#include "imx6q.dtsi";
+
+/ {
+	aliases {
+		ethernet1 = &eth1;
+	};
+};
+
+&pcie {
+	eth1: i211 at bus1 {
+		compatible = "intel,i210";
+	};
+};
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index a98f418..a3203ec 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -57,6 +57,11 @@
  #include "igb.h"
  #include "igb_cdev.h"

+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
  #define MAJ 5
  #define MIN 3
  #define BUILD 0
@@ -2299,6 +2304,27 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
  	return status;
  }

+#ifdef CONFIG_OF
+/**
+ *  igb_read_mac_addr_dts - Read mac address from the device tree blob
+ *  @dev: pointer to device structure
+ *  @mac_addr: pointer to found mac address
+ **/
+static void igb_read_mac_addr_dts(const struct device *dev, u8 *mac_addr)
+{
+	const u8 *mac;
+	struct device_node *dn;
+
+	dn = of_find_compatible_node(dev->of_node, NULL, "intel,i210");
+	if (dn) {
+		mac = of_get_mac_address(dn);
+		if (mac)
+			ether_addr_copy(mac_addr, mac);
+	}
+}
+#endif
+
+
  /**
   *  igb_probe - Device Initialization Routine
   *  @pdev: PCI device information struct
@@ -2511,6 +2537,11 @@ static int igb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
  	if (hw->mac.ops.read_mac_addr(hw))
  		dev_err(&pdev->dev, "NVM Read Error\n");

+#ifdef CONFIG_OF
+	if (!is_valid_ether_addr(hw->mac.addr))
+		igb_read_mac_addr_dts(&pdev->dev, hw->mac.addr);
+#endif
+
  	memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);

  	if (!is_valid_ether_addr(netdev->dev_addr)) {

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

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
  2016-02-17 23:49 ` John Holland
@ 2016-02-18  2:29   ` David Miller
  -1 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-02-18  2:29 UTC (permalink / raw)
  To: jotihojr; +Cc: intel-wired-lan, netdev, jeffrey.t.kirsher

From: John Holland <jotihojr@gmail.com>
Date: Thu, 18 Feb 2016 00:49:17 +0100

> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
> and has no externel EEPROM interface [1]. The following allows the
> driver to pickup the MAC address from a device tree blob when
> CONFIG_OF
> has been enabled.

Please use the generic eth_platform_get_mac_address(), or
alternatively structure your code like the ixgbe and other cases so
that SPARC and other OF platforms get this support as well.

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-18  2:29   ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-02-18  2:29 UTC (permalink / raw)
  To: intel-wired-lan

From: John Holland <jotihojr@gmail.com>
Date: Thu, 18 Feb 2016 00:49:17 +0100

> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
> and has no externel EEPROM interface [1]. The following allows the
> driver to pickup the MAC address from a device tree blob when
> CONFIG_OF
> has been enabled.

Please use the generic eth_platform_get_mac_address(), or
alternatively structure your code like the ixgbe and other cases so
that SPARC and other OF platforms get this support as well.

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

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
  2016-02-18  2:29   ` David Miller
@ 2016-02-18  7:53     ` John Holland
  -1 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-18  7:53 UTC (permalink / raw)
  To: David Miller; +Cc: intel-wired-lan, netdev, jeffrey.t.kirsher


> On Feb 18, 2016, at 03:29, David Miller <davem@davemloft.net> wrote:
> 
> From: John Holland <jotihojr@gmail.com>
> Date: Thu, 18 Feb 2016 00:49:17 +0100
> 
>> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
>> and has no externel EEPROM interface [1]. The following allows the
>> driver to pickup the MAC address from a device tree blob when
>> CONFIG_OF
>> has been enabled.
> 
> Please use the generic eth_platform_get_mac_address(), or
> alternatively structure your code like the ixgbe and other cases so
> that SPARC and other OF platforms get this support as well.

Don't know what you mean. The PCI path in eth_platform_get_mac_address() didn't return a devicetree node and I can find no instance of of_<function> use in ixgbe.

John

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-18  7:53     ` John Holland
  0 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-18  7:53 UTC (permalink / raw)
  To: intel-wired-lan


> On Feb 18, 2016, at 03:29, David Miller <davem@davemloft.net> wrote:
> 
> From: John Holland <jotihojr@gmail.com>
> Date: Thu, 18 Feb 2016 00:49:17 +0100
> 
>> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP
>> and has no externel EEPROM interface [1]. The following allows the
>> driver to pickup the MAC address from a device tree blob when
>> CONFIG_OF
>> has been enabled.
> 
> Please use the generic eth_platform_get_mac_address(), or
> alternatively structure your code like the ixgbe and other cases so
> that SPARC and other OF platforms get this support as well.

Don't know what you mean. The PCI path in eth_platform_get_mac_address() didn't return a devicetree node and I can find no instance of of_<function> use in ixgbe.

John

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

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
  2016-02-18  7:53     ` John Holland
@ 2016-02-18  9:15       ` Jeff Kirsher
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeff Kirsher @ 2016-02-18  9:15 UTC (permalink / raw)
  To: John Holland, David Miller; +Cc: intel-wired-lan, netdev

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

On Thu, 2016-02-18 at 08:53 +0100, John Holland wrote:
> 
> > On Feb 18, 2016, at 03:29, David Miller <davem@davemloft.net>
> wrote:
> > 
> > From: John Holland <jotihojr@gmail.com>
> > Date: Thu, 18 Feb 2016 00:49:17 +0100
> > 
> >> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
> OTP
> >> and has no externel EEPROM interface [1]. The following allows the
> >> driver to pickup the MAC address from a device tree blob when
> >> CONFIG_OF
> >> has been enabled.
> > 
> > Please use the generic eth_platform_get_mac_address(), or
> > alternatively structure your code like the ixgbe and other cases so
> > that SPARC and other OF platforms get this support as well.
> 
> Don't know what you mean. The PCI path in
> eth_platform_get_mac_address() didn't return a devicetree node and I
> can find no instance of of_<function> use in ixgbe.

See commit e1be080f292eba2ef96af999057d1603cd50b473 in my dev-queue
branch.  Sowmini Varadhan provided a patch to
use eth_platform_get_mac_address() instead of the "CONFIG_SPARC"
solution.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-18  9:15       ` Jeff Kirsher
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff Kirsher @ 2016-02-18  9:15 UTC (permalink / raw)
  To: intel-wired-lan

On Thu, 2016-02-18 at 08:53 +0100, John Holland wrote:
> 
> > On Feb 18, 2016, at 03:29, David Miller <davem@davemloft.net>
> wrote:
> >?
> > From: John Holland <jotihojr@gmail.com>
> > Date: Thu, 18 Feb 2016 00:49:17 +0100
> >?
> >> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
> OTP
> >> and has no externel EEPROM interface [1]. The following allows the
> >> driver to pickup the MAC address from a device tree blob when
> >> CONFIG_OF
> >> has been enabled.
> >?
> > Please use the generic eth_platform_get_mac_address(), or
> > alternatively structure your code like the ixgbe and other cases so
> > that SPARC and other OF platforms get this support as well.
> 
> Don't know what you mean. The PCI path in
> eth_platform_get_mac_address() didn't return a devicetree node and I
> can find no instance of of_<function> use in ixgbe.

See commit?e1be080f292eba2ef96af999057d1603cd50b473 in my dev-queue
branch. ?Sowmini Varadhan provided a patch to
use?eth_platform_get_mac_address() instead of the "CONFIG_SPARC"
solution.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160218/9f38b301/attachment.asc>

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

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
  2016-02-18  7:53     ` John Holland
@ 2016-02-18 15:22       ` David Miller
  -1 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-02-18 15:22 UTC (permalink / raw)
  To: jotihojr; +Cc: intel-wired-lan, netdev, jeffrey.t.kirsher

From: John Holland <jotihojr@gmail.com>
Date: Thu, 18 Feb 2016 08:53:07 +0100

> The PCI path in eth_platform_get_mac_address() didn't return a devicetree node...

Then fix your platform such that pci_device_to_OF_node() works
properly instead of adding localized hacks to device drivers.

Jeff, do not apply this patch.

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-18 15:22       ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-02-18 15:22 UTC (permalink / raw)
  To: intel-wired-lan

From: John Holland <jotihojr@gmail.com>
Date: Thu, 18 Feb 2016 08:53:07 +0100

> The PCI path in eth_platform_get_mac_address() didn't return a devicetree node...

Then fix your platform such that pci_device_to_OF_node() works
properly instead of adding localized hacks to device drivers.

Jeff, do not apply this patch.

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

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
  2016-02-18 15:22       ` David Miller
@ 2016-02-18 15:47         ` John Holland
  -1 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-18 15:47 UTC (permalink / raw)
  To: David Miller; +Cc: intel-wired-lan, netdev, jeffrey.t.kirsher


> On Feb 18, 2016, at 16:22, David Miller <davem@davemloft.net> wrote:
> 
> From: John Holland <jotihojr@gmail.com>
> Date: Thu, 18 Feb 2016 08:53:07 +0100
> 
>> The PCI path in eth_platform_get_mac_address() didn't return a devicetree node...
> 
> Then fix your platform such that pci_device_to_OF_node() works
> properly instead of adding localized hacks to device drivers.
> 
> Jeff, do not apply this patch.

Please take a look at V5.

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

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4
@ 2016-02-18 15:47         ` John Holland
  0 siblings, 0 replies; 12+ messages in thread
From: John Holland @ 2016-02-18 15:47 UTC (permalink / raw)
  To: intel-wired-lan


> On Feb 18, 2016, at 16:22, David Miller <davem@davemloft.net> wrote:
> 
> From: John Holland <jotihojr@gmail.com>
> Date: Thu, 18 Feb 2016 08:53:07 +0100
> 
>> The PCI path in eth_platform_get_mac_address() didn't return a devicetree node...
> 
> Then fix your platform such that pci_device_to_OF_node() works
> properly instead of adding localized hacks to device drivers.
> 
> Jeff, do not apply this patch.

Please take a look at V5.

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

end of thread, other threads:[~2016-02-18 15:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17 23:49 [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V4 John Holland
2016-02-17 23:49 ` John Holland
2016-02-18  2:29 ` David Miller
2016-02-18  2:29   ` David Miller
2016-02-18  7:53   ` John Holland
2016-02-18  7:53     ` John Holland
2016-02-18  9:15     ` Jeff Kirsher
2016-02-18  9:15       ` Jeff Kirsher
2016-02-18 15:22     ` David Miller
2016-02-18 15:22       ` David Miller
2016-02-18 15:47       ` John Holland
2016-02-18 15:47         ` John Holland

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.