Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1259105 > unrolled thread

[PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM

Started bySowmini Varadhan <sowmini.varadhan@oracle.com>
First post2015-10-30 00:40 +0100
Last post2015-10-30 14:40 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM Sowmini Varadhan <sowmini.varadhan@oracle.com> - 2015-10-30 00:40 +0100
    Re: [PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-10-30 01:20 +0100
      Re: [PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM Sowmini Varadhan <sowmini.varadhan@oracle.com> - 2015-10-30 12:30 +0100
        Re: [PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-10-30 14:40 +0100

#1259105 — [PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM

FromSowmini Varadhan <sowmini.varadhan@oracle.com>
Date2015-10-30 00:40 +0100
Subject[PATCH net] i40e: Look up MAC address in Open Firmware or IDPROM
Message-ID<qp4Xv-6IO-13@gated-at.bofh.it>

This is the i40e equivalent of commit c762dff24c06 ("ixgbe: Look up MAC
address in Open Firmware or IDPROM").

As with that fix, attempt to look up the MAC address in Open Firmware
on systems that uspport it, and use IDPROM on SPARC if no OF address
is found.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
 drivers/net/ethernet/intel/i40e/i40e_common.c |   36 +++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 2d74c6e..53f804a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -24,11 +24,23 @@
  *
  ******************************************************************************/
 
+#include <linux/etherdevice.h>
+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#endif
+#include <linux/pci.h>
+#include "i40e.h"
+
 #include "i40e_type.h"
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"
 #include "i40e_virtchnl.h"
 
+#ifdef CONFIG_SPARC
+#include <asm/idprom.h>
+#include <asm/prom.h>
+#endif
+
 /**
  * i40e_set_mac_type - Sets MAC type
  * @hw: pointer to the HW structure
@@ -1008,6 +1020,27 @@ i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw,
 	return status;
 }
 
+static int i40e_get_platform_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
+{
+#ifdef CONFIG_OF
+	struct i40e_pf *pf = hw->back;
+	struct device_node *dp = pci_device_to_OF_node(pf->pdev);
+	const unsigned char *addr;
+
+	addr = of_get_mac_address(dp);
+	if (addr) {
+		ether_addr_copy(mac_addr, addr);
+		return 0;
+	}
+#endif /* CONFIG_OF */
+
+#ifdef CONFIG_SPARC
+	ether_addr_copy(mac_addr, idprom->id_ethaddr);
+	return 0;
+#endif /* CONFIG_SPARC */
+	return 1;
+}
+
 /**
  * i40e_get_mac_addr - get MAC address
  * @hw: pointer to the HW structure
@@ -1021,6 +1054,9 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
 	i40e_status status;
 	u16 flags = 0;
 
+	if (!i40e_get_platform_mac_addr(hw, mac_addr))
+		return I40E_SUCCESS;
+
 	status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
 
 	if (flags & I40E_AQC_LAN_ADDR_VALID)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1259133

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-10-30 01:20 +0100
Message-ID<qp5Ae-7bw-1@gated-at.bofh.it>
In reply to#1259105
On Fri, Oct 30, 2015 at 1:34 AM, Sowmini Varadhan
<sowmini.varadhan@oracle.com> wrote:
>
>
> This is the i40e equivalent of commit c762dff24c06 ("ixgbe: Look up MAC
> address in Open Firmware or IDPROM").
>
> As with that fix, attempt to look up the MAC address in Open Firmware
> on systems that uspport it, and use IDPROM on SPARC if no OF address
> is found.

[]

> +#include <linux/etherdevice.h>

> +#ifdef CONFIG_OF

This seems redundant.

> +#include <linux/of_net.h>
> +#endif
> +#include <linux/pci.h>
> +#include "i40e.h"
> +
>  #include "i40e_type.h"
>  #include "i40e_adminq.h"
>  #include "i40e_prototype.h"
>  #include "i40e_virtchnl.h"
>
> +#ifdef CONFIG_SPARC
> +#include <asm/idprom.h>
> +#include <asm/prom.h>
> +#endif

Why not to put before local headers?

> +static int i40e_get_platform_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
> +{
> +#ifdef CONFIG_OF

Does the following has no stubs?

> +       struct i40e_pf *pf = hw->back;
> +       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
> +       const unsigned char *addr;
> +
> +       addr = of_get_mac_address(dp);

^^^

> +       if (addr) {
> +               ether_addr_copy(mac_addr, addr);
> +               return 0;
> +       }
> +#endif /* CONFIG_OF */
> +
> +#ifdef CONFIG_SPARC
> +       ether_addr_copy(mac_addr, idprom->id_ethaddr);
> +       return 0;
> +#endif /* CONFIG_SPARC */
> +       return 1;
> +}
> +
>  /**
>   * i40e_get_mac_addr - get MAC address
>   * @hw: pointer to the HW structure
> @@ -1021,6 +1054,9 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
>         i40e_status status;
>         u16 flags = 0;
>
> +       if (!i40e_get_platform_mac_addr(hw, mac_addr))
> +               return I40E_SUCCESS;


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1259409

FromSowmini Varadhan <sowmini.varadhan@oracle.com>
Date2015-10-30 12:30 +0100
Message-ID<qpg2C-5bX-5@gated-at.bofh.it>
In reply to#1259133
On (10/30/15 02:14), Andy Shevchenko wrote:
> 
> Does the following has no stubs?
> 
> > +       struct i40e_pf *pf = hw->back;
> > +       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
> > +       const unsigned char *addr;
> > +
> > +       addr = of_get_mac_address(dp);
> 
> ^^^

I was not able to find any.
I'm fixing up the rest and respinning V2 as a separate thread.

Thanks
--Sowmini
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1259495

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-10-30 14:40 +0100
Message-ID<qpi4r-6mR-21@gated-at.bofh.it>
In reply to#1259409
On Fri, Oct 30, 2015 at 1:26 PM, Sowmini Varadhan
<sowmini.varadhan@oracle.com> wrote:
> On (10/30/15 02:14), Andy Shevchenko wrote:
>>
>> Does the following has no stubs?
>>
>> > +       struct i40e_pf *pf = hw->back;
>> > +       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
>> > +       const unsigned char *addr;
>> > +
>> > +       addr = of_get_mac_address(dp);
>>
>> ^^^
>
> I was not able to find any.
> I'm fixing up the rest and respinning V2 as a separate thread.

of_net.h contains the stub of of_get_mac_addr() which means you don't
need to put ugly ifdefs in the function.

Have no idea about CONFIG_SPARC though.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web