* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-01-29 22:11 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-01-29 22:11 UTC (permalink / raw)
To: intel-wired-lan, netdev, jotihojr
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
Signed-off-by: John Holland <jotihojr@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 30
++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
b/drivers/net/ethernet/intel/igb/igb_main.c
index 31e5f39..9c92443 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -56,6 +56,11 @@
#include <linux/i2c.h>
#include "igb.h"
+#ifdef defined(CONFIG_OF)
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
#define MAJ 5
#define MIN 3
#define BUILD 0
@@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
}
/**
+ * igb_read_mac_addr_dts - Read mac addres from the device tree blob.
+ * @hw: pointer to the e1000 hardware structure
+ **/
+#ifdef defined(CONFIG_OF)
+static void igb_read_mac_addr_dts(struct e1000_hw *hw)
+{
+ const u8 *mac;
+ struct device_node *dn;
+
+ dn = of_find_compatible_node(NULL, NULL, "intel,i211");
+ if (!dn)
+ return;
+
+ mac = of_get_mac_address(dn);
+ if (mac)
+ ether_addr_copy(hw->mac.addr, mac);
+}
+#endif
+
+/**
* igb_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in igb_pci_tbl
@@ -2420,6 +2445,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 defined(CONFIG_OF)
+ if (!is_valid_ether_addr(hw->mac.addr))
+ igb_read_mac_addr_dts(hw);
+#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] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-01-29 22:11 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-01-29 22:11 UTC (permalink / raw)
To: intel-wired-lan
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
Signed-off-by: John Holland <jotihojr@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 30
++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
b/drivers/net/ethernet/intel/igb/igb_main.c
index 31e5f39..9c92443 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -56,6 +56,11 @@
#include <linux/i2c.h>
#include "igb.h"
+#ifdef defined(CONFIG_OF)
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
#define MAJ 5
#define MIN 3
#define BUILD 0
@@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
}
/**
+ * igb_read_mac_addr_dts - Read mac addres from the device tree blob.
+ * @hw: pointer to the e1000 hardware structure
+ **/
+#ifdef defined(CONFIG_OF)
+static void igb_read_mac_addr_dts(struct e1000_hw *hw)
+{
+ const u8 *mac;
+ struct device_node *dn;
+
+ dn = of_find_compatible_node(NULL, NULL, "intel,i211");
+ if (!dn)
+ return;
+
+ mac = of_get_mac_address(dn);
+ if (mac)
+ ether_addr_copy(hw->mac.addr, mac);
+}
+#endif
+
+/**
* igb_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in igb_pci_tbl
@@ -2420,6 +2445,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 defined(CONFIG_OF)
+ if (!is_valid_ether_addr(hw->mac.addr))
+ igb_read_mac_addr_dts(hw);
+#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] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-01-29 22:11 ` John Holland
@ 2016-02-09 11:02 ` Jeff Kirsher
-1 siblings, 0 replies; 22+ messages in thread
From: Jeff Kirsher @ 2016-02-09 11:02 UTC (permalink / raw)
To: John Holland, intel-wired-lan, netdev
[-- Attachment #1: Type: text/plain, Size: 2889 bytes --]
On Fri, 2016-01-29 at 23:11 +0100, John Holland wrote:
> 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/i
> 211-ethernet-controller-datasheet.html
>
> Signed-off-by: John Holland <jotihojr@gmail.com>
> ---
> drivers/net/ethernet/intel/igb/igb_main.c | 30
> ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
> b/drivers/net/ethernet/intel/igb/igb_main.c
> index 31e5f39..9c92443 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -56,6 +56,11 @@
> #include <linux/i2c.h>
> #include "igb.h"
>
> +#ifdef defined(CONFIG_OF)
> +#include <linux/of_net.h>
> +#include <linux/etherdevice.h>
> +#endif
> +
> #define MAJ 5
> #define MIN 3
> #define BUILD 0
> @@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter
> *adapter)
> }
>
> /**
> + * igb_read_mac_addr_dts - Read mac addres from the device tree
> blob.
Address is mis-spelled above
> + * @hw: pointer to the e1000 hardware structure
> + **/
> +#ifdef defined(CONFIG_OF)
Minor nitpick, you should have the function comment header wrapped in
the #ifdef as well.
> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> +{
> + const u8 *mac;
> + struct device_node *dn;
> +
> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
> + if (!dn)
> + return;
> +
> + mac = of_get_mac_address(dn);
> + if (mac)
> + ether_addr_copy(hw->mac.addr, mac);
> +}
> +#endif
> +
> +/**
> * igb_probe - Device Initialization Routine
> * @pdev: PCI device information struct
> * @ent: entry in igb_pci_tbl
> @@ -2420,6 +2445,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 defined(CONFIG_OF)
> + if (!is_valid_ether_addr(hw->mac.addr))
> + igb_read_mac_addr_dts(hw);
> +#endif
> +
> memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
>
> if (!is_valid_ether_addr(netdev->dev_addr)) {
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@lists.osuosl.org
> http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-09 11:02 ` Jeff Kirsher
0 siblings, 0 replies; 22+ messages in thread
From: Jeff Kirsher @ 2016-02-09 11:02 UTC (permalink / raw)
To: intel-wired-lan
On Fri, 2016-01-29 at 23:11 +0100, John Holland wrote:
> 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/i
> 211-ethernet-controller-datasheet.html
>
> Signed-off-by: John Holland <jotihojr@gmail.com>
> ---
> ? drivers/net/ethernet/intel/igb/igb_main.c | 30?
> ++++++++++++++++++++++++++++++
> ? 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c?
> b/drivers/net/ethernet/intel/igb/igb_main.c
> index 31e5f39..9c92443 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -56,6 +56,11 @@
> ? #include <linux/i2c.h>
> ? #include "igb.h"
>
> +#ifdef defined(CONFIG_OF)
> +#include <linux/of_net.h>
> +#include <linux/etherdevice.h>
> +#endif
> +
> ? #define MAJ 5
> ? #define MIN 3
> ? #define BUILD 0
> @@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter
> *adapter)
> ? }
>
> ? /**
> + *??igb_read_mac_addr_dts - Read mac addres from the device tree
> blob.
Address is mis-spelled above
> + *??@hw: pointer to the e1000 hardware structure
> + **/
> +#ifdef defined(CONFIG_OF)
Minor nitpick, you should have the function comment header wrapped in
the #ifdef as well.
> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> +{
> +???????const u8 *mac;
> +???????struct device_node *dn;
> +
> +???????dn = of_find_compatible_node(NULL, NULL, "intel,i211");
> +???????if (!dn)
> +???????????????return;
> +
> +???????mac = of_get_mac_address(dn);
> +???????if (mac)
> +???????????????ether_addr_copy(hw->mac.addr, mac);
> +}
> +#endif
> +
> +/**
> ???*??igb_probe - Device Initialization Routine
> ???*??@pdev: PCI device information struct
> ???*??@ent: entry in igb_pci_tbl
> @@ -2420,6 +2445,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 defined(CONFIG_OF)
> +???????if (!is_valid_ether_addr(hw->mac.addr))
> +???????????????igb_read_mac_addr_dts(hw);
> +#endif
> +
> ?????????memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
>
> ?????????if (!is_valid_ether_addr(netdev->dev_addr)) {
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan at lists.osuosl.org
> http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
-------------- 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/20160209/9680d9a7/attachment.asc>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:02 ` Jeff Kirsher
@ 2016-02-09 11:54 ` Andrew Lunn
-1 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-09 11:54 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: John Holland, intel-wired-lan, netdev
> > +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> > +{
> > + const u8 *mac;
> > + struct device_node *dn;
> > +
> > + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
Hi John
Would this also work for the i210?
If so, you normally use the compatible string for the first device
this works with. So maybe this should be changed to intel,i210?
Thanks
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-09 11:54 ` Andrew Lunn
0 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-09 11:54 UTC (permalink / raw)
To: intel-wired-lan
> > +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> > +{
> > +???????const u8 *mac;
> > +???????struct device_node *dn;
> > +
> > +???????dn = of_find_compatible_node(NULL, NULL, "intel,i211");
Hi John
Would this also work for the i210?
If so, you normally use the compatible string for the first device
this works with. So maybe this should be changed to intel,i210?
Thanks
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:02 ` Jeff Kirsher
@ 2016-02-09 11:59 ` Andrew Lunn
-1 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-09 11:59 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: John Holland, intel-wired-lan, netdev
> > + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
Humm, NULL, NULL. That means find the first node anywhere in the
device tree which matches. This is not going to work too well when you
have multiple i211s.
There is a way so specify a DT node is attached to a specific PCIe
bus/slot. I think you should search only there, so solving the
multiple device issue.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-09 11:59 ` Andrew Lunn
0 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-09 11:59 UTC (permalink / raw)
To: intel-wired-lan
> > +???????dn = of_find_compatible_node(NULL, NULL, "intel,i211");
Humm, NULL, NULL. That means find the first node anywhere in the
device tree which matches. This is not going to work too well when you
have multiple i211s.
There is a way so specify a DT node is attached to a specific PCIe
bus/slot. I think you should search only there, so solving the
multiple device issue.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:59 ` Andrew Lunn
@ 2016-02-09 17:42 ` Shannon Nelson
-1 siblings, 0 replies; 22+ messages in thread
From: Shannon Nelson @ 2016-02-09 17:42 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Jeff Kirsher, John Holland, intel-wired-lan, netdev
It seem to me this should be using eth_platform_get_mac_address(), a
slightly more generic method to do this. See the i40e driver for an
example, commit d9a84324e6 I believe.
sln
On Tue, Feb 9, 2016 at 3:59 AM, Andrew Lunn <andrew@lunn.ch> wrote:
>> > + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Humm, NULL, NULL. That means find the first node anywhere in the
> device tree which matches. This is not going to work too well when you
> have multiple i211s.
>
> There is a way so specify a DT node is attached to a specific PCIe
> bus/slot. I think you should search only there, so solving the
> multiple device issue.
>
> Andrew
--
==============================================
Mr. Shannon Nelson Network Division, Intel Corp.
Shannon.Nelson@intel.com I don't speak for Intel
Parents can't afford to be squeamish
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-09 17:42 ` Shannon Nelson
0 siblings, 0 replies; 22+ messages in thread
From: Shannon Nelson @ 2016-02-09 17:42 UTC (permalink / raw)
To: intel-wired-lan
It seem to me this should be using eth_platform_get_mac_address(), a
slightly more generic method to do this. See the i40e driver for an
example, commit d9a84324e6 I believe.
sln
On Tue, Feb 9, 2016 at 3:59 AM, Andrew Lunn <andrew@lunn.ch> wrote:
>> > + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Humm, NULL, NULL. That means find the first node anywhere in the
> device tree which matches. This is not going to work too well when you
> have multiple i211s.
>
> There is a way so specify a DT node is attached to a specific PCIe
> bus/slot. I think you should search only there, so solving the
> multiple device issue.
>
> Andrew
--
==============================================
Mr. Shannon Nelson Network Division, Intel Corp.
Shannon.Nelson at intel.com I don't speak for Intel
Parents can't afford to be squeamish
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 17:42 ` Shannon Nelson
@ 2016-02-09 22:10 ` David Miller
-1 siblings, 0 replies; 22+ messages in thread
From: David Miller @ 2016-02-09 22:10 UTC (permalink / raw)
To: shannon.nelson
Cc: andrew, jeffrey.t.kirsher, jotihojr, intel-wired-lan, netdev
From: Shannon Nelson <shannon.nelson@intel.com>
Date: Tue, 9 Feb 2016 09:42:45 -0800
> It seem to me this should be using eth_platform_get_mac_address(), a
> slightly more generic method to do this. See the i40e driver for an
> example, commit d9a84324e6 I believe.
+1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-09 22:10 ` David Miller
0 siblings, 0 replies; 22+ messages in thread
From: David Miller @ 2016-02-09 22:10 UTC (permalink / raw)
To: intel-wired-lan
From: Shannon Nelson <shannon.nelson@intel.com>
Date: Tue, 9 Feb 2016 09:42:45 -0800
> It seem to me this should be using eth_platform_get_mac_address(), a
> slightly more generic method to do this. See the i40e driver for an
> example, commit d9a84324e6 I believe.
+1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 17:42 ` Shannon Nelson
@ 2016-02-10 8:50 ` John Holland
-1 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 8:50 UTC (permalink / raw)
To: Shannon Nelson; +Cc: Andrew Lunn, Jeff Kirsher, intel-wired-lan, netdev
> On Feb 9, 2016, at 18:42, Shannon Nelson <shannon.nelson@intel.com> wrote:
>
> It seem to me this should be using eth_platform_get_mac_address(), a
> slightly more generic method to do this. See the i40e driver for an
> example, commit d9a84324e6 I believe.
>
I believe you are referring to https://patchwork.ozlabs.org/patch/566806. Haven't seen this used upstream yet. And, does that not mandate CONFIG_OF?
John
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-10 8:50 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 8:50 UTC (permalink / raw)
To: intel-wired-lan
> On Feb 9, 2016, at 18:42, Shannon Nelson <shannon.nelson@intel.com> wrote:
>
> It seem to me this should be using eth_platform_get_mac_address(), a
> slightly more generic method to do this. See the i40e driver for an
> example, commit d9a84324e6 I believe.
>
I believe you are referring to https://patchwork.ozlabs.org/patch/566806. Haven't seen this used upstream yet. And, does that not mandate CONFIG_OF?
John
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:02 ` Jeff Kirsher
@ 2016-02-10 8:52 ` John Holland
-1 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 8:52 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: intel-wired-lan, netdev
> On Feb 9, 2016, at 12:02, Jeff Kirsher <jeffrey.t.kirsher@intel.com> wrote:
>
>> On Fri, 2016-01-29 at 23:11 +0100, John Holland wrote:
>> 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/i
>> 211-ethernet-controller-datasheet.html
>>
>> Signed-off-by: John Holland <jotihojr@gmail.com>
>> ---
>> drivers/net/ethernet/intel/igb/igb_main.c | 30
>> ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
>> b/drivers/net/ethernet/intel/igb/igb_main.c
>> index 31e5f39..9c92443 100644
>> --- a/drivers/net/ethernet/intel/igb/igb_main.c
>> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
>> @@ -56,6 +56,11 @@
>> #include <linux/i2c.h>
>> #include "igb.h"
>>
>> +#ifdef defined(CONFIG_OF)
>> +#include <linux/of_net.h>
>> +#include <linux/etherdevice.h>
>> +#endif
>> +
>> #define MAJ 5
>> #define MIN 3
>> #define BUILD 0
>> @@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter
>> *adapter)
>> }
>>
>> /**
>> + * igb_read_mac_addr_dts - Read mac addres from the device tree
>> blob.
>
> Address is mis-spelled above
Correct. Will fix this.
>
>> + * @hw: pointer to the e1000 hardware structure
>> + **/
>> +#ifdef defined(CONFIG_OF)
>
> Minor nitpick, you should have the function comment header wrapped in
> the #ifdef as well.
No problem...
I'll do that right too.
>
>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
>> +{
>> + const u8 *mac;
>> + struct device_node *dn;
>> +
>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>> + if (!dn)
>> + return;
>> +
>> + mac = of_get_mac_address(dn);
>> + if (mac)
>> + ether_addr_copy(hw->mac.addr, mac);
>> +}
>> +#endif
>> +
>> +/**
>> * igb_probe - Device Initialization Routine
>> * @pdev: PCI device information struct
>> * @ent: entry in igb_pci_tbl
>> @@ -2420,6 +2445,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 defined(CONFIG_OF)
>> + if (!is_valid_ether_addr(hw->mac.addr))
>> + igb_read_mac_addr_dts(hw);
>> +#endif
>> +
>> memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
>>
>> if (!is_valid_ether_addr(netdev->dev_addr)) {
>> _______________________________________________
>> Intel-wired-lan mailing list
>> Intel-wired-lan@lists.osuosl.org
>> http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-10 8:52 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 8:52 UTC (permalink / raw)
To: intel-wired-lan
> On Feb 9, 2016, at 12:02, Jeff Kirsher <jeffrey.t.kirsher@intel.com> wrote:
>
>> On Fri, 2016-01-29 at 23:11 +0100, John Holland wrote:
>> 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/i
>> 211-ethernet-controller-datasheet.html
>>
>> Signed-off-by: John Holland <jotihojr@gmail.com>
>> ---
>> drivers/net/ethernet/intel/igb/igb_main.c | 30
>> ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
>> b/drivers/net/ethernet/intel/igb/igb_main.c
>> index 31e5f39..9c92443 100644
>> --- a/drivers/net/ethernet/intel/igb/igb_main.c
>> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
>> @@ -56,6 +56,11 @@
>> #include <linux/i2c.h>
>> #include "igb.h"
>>
>> +#ifdef defined(CONFIG_OF)
>> +#include <linux/of_net.h>
>> +#include <linux/etherdevice.h>
>> +#endif
>> +
>> #define MAJ 5
>> #define MIN 3
>> #define BUILD 0
>> @@ -2217,6 +2222,26 @@ static s32 igb_init_i2c(struct igb_adapter
>> *adapter)
>> }
>>
>> /**
>> + * igb_read_mac_addr_dts - Read mac addres from the device tree
>> blob.
>
> Address is mis-spelled above
Correct. Will fix this.
>
>> + * @hw: pointer to the e1000 hardware structure
>> + **/
>> +#ifdef defined(CONFIG_OF)
>
> Minor nitpick, you should have the function comment header wrapped in
> the #ifdef as well.
No problem...
I'll do that right too.
>
>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
>> +{
>> + const u8 *mac;
>> + struct device_node *dn;
>> +
>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>> + if (!dn)
>> + return;
>> +
>> + mac = of_get_mac_address(dn);
>> + if (mac)
>> + ether_addr_copy(hw->mac.addr, mac);
>> +}
>> +#endif
>> +
>> +/**
>> * igb_probe - Device Initialization Routine
>> * @pdev: PCI device information struct
>> * @ent: entry in igb_pci_tbl
>> @@ -2420,6 +2445,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 defined(CONFIG_OF)
>> + if (!is_valid_ether_addr(hw->mac.addr))
>> + igb_read_mac_addr_dts(hw);
>> +#endif
>> +
>> memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
>>
>> if (!is_valid_ether_addr(netdev->dev_addr)) {
>> _______________________________________________
>> Intel-wired-lan mailing list
>> Intel-wired-lan at lists.osuosl.org
>> http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:54 ` Andrew Lunn
@ 2016-02-10 9:13 ` John Holland
-1 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 9:13 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Jeff Kirsher, intel-wired-lan, netdev
Sent from my iPad
On Feb 9, 2016, at 12:54, Andrew Lunn <andrew@lunn.ch> wrote:
>>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
>>> +{
>>> + const u8 *mac;
>>> + struct device_node *dn;
>>> +
>>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Hi John
>
> Would this also work for the i210?
The usability scenario of i210 and i211 seem similar enough. Although, I will not be able to test the i210, I will use it as the compatible keyword.
>
> If so, you normally use the compatible string for the first device
> this works with. So maybe this should be changed to intel,i210?
>
> Thanks
> Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-10 9:13 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 9:13 UTC (permalink / raw)
To: intel-wired-lan
Sent from my iPad
On Feb 9, 2016, at 12:54, Andrew Lunn <andrew@lunn.ch> wrote:
>>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
>>> +{
>>> + const u8 *mac;
>>> + struct device_node *dn;
>>> +
>>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Hi John
>
> Would this also work for the i210?
The usability scenario of i210 and i211 seem similar enough. Although, I will not be able to test the i210, I will use it as the compatible keyword.
>
> If so, you normally use the compatible string for the first device
> this works with. So maybe this should be changed to intel,i210?
>
> Thanks
> Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-09 11:59 ` Andrew Lunn
@ 2016-02-10 9:16 ` John Holland
-1 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 9:16 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Jeff Kirsher, intel-wired-lan, netdev
On Feb 9, 2016, at 12:59, Andrew Lunn <andrew@lunn.ch> wrote:
>>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Humm, NULL, NULL. That means find the first node anywhere in the
> device tree which matches. This is not going to work too well when you
> have multiple i211s.
>
> There is a way so specify a DT node is attached to a specific PCIe
> bus/slot. I think you should search only there, so solving the
> multiple device issue.
>
Good point. Will specify the current PCIe node.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-10 9:16 ` John Holland
0 siblings, 0 replies; 22+ messages in thread
From: John Holland @ 2016-02-10 9:16 UTC (permalink / raw)
To: intel-wired-lan
On Feb 9, 2016, at 12:59, Andrew Lunn <andrew@lunn.ch> wrote:
>>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
>
> Humm, NULL, NULL. That means find the first node anywhere in the
> device tree which matches. This is not going to work too well when you
> have multiple i211s.
>
> There is a way so specify a DT node is attached to a specific PCIe
> bus/slot. I think you should search only there, so solving the
> multiple device issue.
>
Good point. Will specify the current PCIe node.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
2016-02-10 9:13 ` John Holland
@ 2016-02-10 16:59 ` Andrew Lunn
-1 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-10 16:59 UTC (permalink / raw)
To: John Holland; +Cc: Jeff Kirsher, intel-wired-lan, netdev
On Wed, Feb 10, 2016 at 10:13:56AM +0100, John Holland wrote:
>
>
>
> Sent from my iPad
> On Feb 9, 2016, at 12:54, Andrew Lunn <andrew@lunn.ch> wrote:
>
> >>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> >>> +{
> >>> + const u8 *mac;
> >>> + struct device_node *dn;
> >>> +
> >>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
> >
> > Hi John
> >
> > Would this also work for the i210?
>
> The usability scenario of i210 and i211 seem similar
> enough. Although, I will not be able to test the i210, I will use it
> as the compatible keyword.
I can test on i210.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob
@ 2016-02-10 16:59 ` Andrew Lunn
0 siblings, 0 replies; 22+ messages in thread
From: Andrew Lunn @ 2016-02-10 16:59 UTC (permalink / raw)
To: intel-wired-lan
On Wed, Feb 10, 2016 at 10:13:56AM +0100, John Holland wrote:
>
>
>
> Sent from my iPad
> On Feb 9, 2016, at 12:54, Andrew Lunn <andrew@lunn.ch> wrote:
>
> >>> +static void igb_read_mac_addr_dts(struct e1000_hw *hw)
> >>> +{
> >>> + const u8 *mac;
> >>> + struct device_node *dn;
> >>> +
> >>> + dn = of_find_compatible_node(NULL, NULL, "intel,i211");
> >
> > Hi John
> >
> > Would this also work for the i210?
>
> The usability scenario of i210 and i211 seem similar
> enough. Although, I will not be able to test the i210, I will use it
> as the compatible keyword.
I can test on i210.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2016-02-10 16:59 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29 22:11 [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob John Holland
2016-01-29 22:11 ` John Holland
2016-02-09 11:02 ` Jeff Kirsher
2016-02-09 11:02 ` Jeff Kirsher
2016-02-09 11:54 ` Andrew Lunn
2016-02-09 11:54 ` Andrew Lunn
2016-02-10 9:13 ` John Holland
2016-02-10 9:13 ` John Holland
2016-02-10 16:59 ` Andrew Lunn
2016-02-10 16:59 ` Andrew Lunn
2016-02-09 11:59 ` Andrew Lunn
2016-02-09 11:59 ` Andrew Lunn
2016-02-09 17:42 ` Shannon Nelson
2016-02-09 17:42 ` Shannon Nelson
2016-02-09 22:10 ` David Miller
2016-02-09 22:10 ` David Miller
2016-02-10 8:50 ` John Holland
2016-02-10 8:50 ` John Holland
2016-02-10 9:16 ` John Holland
2016-02-10 9:16 ` John Holland
2016-02-10 8:52 ` John Holland
2016-02-10 8:52 ` 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.