DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: Akhil Goyal <akhil.goyal@nxp.com>
Subject: [dpdk-dev] [PATCH v2 07/16] bus/dpaa: implement new of API to get MAC address
Date: Wed,  4 Jul 2018 15:13:42 +0530	[thread overview]
Message-ID: <1530697431-1244-7-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1530697431-1244-1-git-send-email-hemant.agrawal@nxp.com>

From: Akhil Goyal <akhil.goyal@nxp.com>

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 drivers/bus/dpaa/base/fman/of.c           | 39 +++++++++++++++++++++++++++++++
 drivers/bus/dpaa/include/of.h             |  2 ++
 drivers/bus/dpaa/rte_bus_dpaa_version.map |  8 +++++++
 3 files changed, 49 insertions(+)

diff --git a/drivers/bus/dpaa/base/fman/of.c b/drivers/bus/dpaa/base/fman/of.c
index eb55cb9..a7f3174 100644
--- a/drivers/bus/dpaa/base/fman/of.c
+++ b/drivers/bus/dpaa/base/fman/of.c
@@ -546,3 +546,42 @@ of_device_is_compatible(const struct device_node *dev_node,
 		return true;
 	return false;
 }
+
+static const void *of_get_mac_addr(const struct device_node *np,
+		const char *name)
+{
+	return of_get_property(np, name, NULL);
+}
+
+/**
+ * Search the device tree for the best MAC address to use.  'mac-address' is
+ * checked first, because that is supposed to contain to "most recent" MAC
+ * address. If that isn't set, then 'local-mac-address' is checked next,
+ * because that is the default address.  If that isn't set, then the obsolete
+ * 'address' is checked, just in case we're using an old device tree.
+ *
+ * Note that the 'address' property is supposed to contain a virtual address of
+ * the register set, but some DTS files have redefined that property to be the
+ * MAC address.
+ *
+ * All-zero MAC addresses are rejected, because those could be properties that
+ * exist in the device tree, but were not set by U-Boot.  For example, the
+ * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
+ * addresses.  Some older U-Boots only initialized 'local-mac-address'.  In
+ * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
+ * but is all zeros.
+ */
+const void *of_get_mac_address(const struct device_node *np)
+{
+	const void *addr;
+
+	addr = of_get_mac_addr(np, "mac-address");
+	if (addr)
+		return addr;
+
+	addr = of_get_mac_addr(np, "local-mac-address");
+	if (addr)
+		return addr;
+
+	return of_get_mac_addr(np, "address");
+}
diff --git a/drivers/bus/dpaa/include/of.h b/drivers/bus/dpaa/include/of.h
index 151be5a..7ea7608 100644
--- a/drivers/bus/dpaa/include/of.h
+++ b/drivers/bus/dpaa/include/of.h
@@ -109,6 +109,8 @@ const struct device_node *of_get_parent(const struct device_node *dev_node);
 const struct device_node *of_get_next_child(const struct device_node *dev_node,
 					    const struct device_node *prev);
 
+const void *of_get_mac_address(const struct device_node *np);
+
 #define for_each_child_node(parent, child) \
 	for (child = of_get_next_child(parent, NULL); child != NULL; \
 			child = of_get_next_child(parent, child))
diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map
index 8d90285..e00c911 100644
--- a/drivers/bus/dpaa/rte_bus_dpaa_version.map
+++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map
@@ -92,3 +92,11 @@ DPDK_18.02 {
 
 	local: *;
 } DPDK_17.11;
+
+DPDK_18.08 {
+	global:
+
+	of_get_mac_address;
+
+	local: *;
+} DPDK_18.02;
-- 
2.7.4

  parent reply	other threads:[~2018-07-04  9:45 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21  9:43 [dpdk-dev] [PATCH 01/10] bus/dpaa: fix phandle support for kernel 4.16 Hemant Agrawal
2018-06-21  9:43 ` [dpdk-dev] [PATCH 02/10] bus/dpaa: fix svr id fetch location Hemant Agrawal
2018-06-21  9:43 ` [dpdk-dev] [PATCH 03/10] bus/dpaa: optimize the fq callback routine Hemant Agrawal
2018-06-21  9:43 ` [dpdk-dev] [PATCH 04/10] bus/dpaa: implement new of API to get MAC address Hemant Agrawal
2018-06-21  9:43 ` [dpdk-dev] [PATCH 05/10] bus/dpaa: make vdqcr configurable Hemant Agrawal
2018-06-21  9:44 ` [dpdk-dev] [PATCH 06/10] net/dpaa: support default queue mode Hemant Agrawal
2018-06-21  9:44 ` [dpdk-dev] [PATCH 07/10] net/dpaa: remove experimental tag from PMD APIs Hemant Agrawal
2018-06-21  9:44 ` [dpdk-dev] [PATCH 08/10] net/dpaa2: fix the prefetch Rx to honor nb pkts Hemant Agrawal
2018-06-21  9:44 ` [dpdk-dev] [PATCH 09/10] bus/dpaa: cleanup unnecessary global variables Hemant Agrawal
2018-06-21  9:44 ` [dpdk-dev] [PATCH 10/10] bus/fslmc: " Hemant Agrawal
2018-07-04  9:43 ` [dpdk-dev] [PATCH v2 01/16] bus/dpaa: fix phandle support for kernel 4.16 Hemant Agrawal
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 02/16] bus/dpaa: fix svr id fetch location Hemant Agrawal
2018-07-06  4:44     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 03/16] bus/dpaa: fix the buffer offset setting in FMAN Hemant Agrawal
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 04/16] net/dpaa: fix the queue err handling and logs Hemant Agrawal
2018-07-06  4:56     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 05/16] net/dpaa2: fix the prefetch Rx to honor nb pkts Hemant Agrawal
2018-07-06  5:01     ` Shreyansh Jain
2018-07-06  8:13       ` Hemant Agrawal
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 06/16] bus/dpaa: optimize the fq callback routine Hemant Agrawal
2018-07-06  5:07     ` Shreyansh Jain
2018-07-04  9:43   ` Hemant Agrawal [this message]
2018-07-06  5:24     ` [dpdk-dev] [PATCH v2 07/16] bus/dpaa: implement new of API to get MAC address Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 08/16] bus/dpaa: make vdqcr configurable Hemant Agrawal
2018-07-06  5:24     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 09/16] net/dpaa: support default queue mode Hemant Agrawal
2018-07-06  5:28     ` Shreyansh Jain
2018-07-06  8:13       ` Hemant Agrawal
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 10/16] net/dpaa: remove experimental tag from PMD APIs Hemant Agrawal
2018-07-06  5:29     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 11/16] bus/dpaa: cleanup unnecessary global variables Hemant Agrawal
2018-07-06  4:36     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 12/16] bus/fslmc: " Hemant Agrawal
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 13/16] drivers: support function name in logs trace Hemant Agrawal
2018-07-06  6:34     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 14/16] net/dpaa: move the push queue set to global init Hemant Agrawal
2018-07-06  6:35     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 15/16] bus/dpaa: add support for SG config Hemant Agrawal
2018-07-06  4:38     ` Shreyansh Jain
2018-07-04  9:43   ` [dpdk-dev] [PATCH v2 16/16] net/dpaa: implement scatter offload support Hemant Agrawal
2018-07-06  6:41     ` Shreyansh Jain
2018-07-04 10:59   ` [dpdk-dev] [PATCH v2 01/16] bus/dpaa: fix phandle support for kernel 4.16 Shreyansh Jain
2018-07-06  8:09   ` [dpdk-dev] [PATCH v3 " Hemant Agrawal
2018-07-06  8:09     ` [dpdk-dev] [PATCH v3 02/16] bus/dpaa: fix svr id fetch location Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 03/16] bus/dpaa: fix the buffer offset setting in FMAN Hemant Agrawal
2018-07-06 12:28       ` Shreyansh Jain
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 04/16] net/dpaa: fix the queue err handling and logs Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 05/16] net/dpaa2: fix the prefetch Rx to honor nb pkts Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 06/16] bus/dpaa: optimize the fq callback routine Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 07/16] bus/dpaa: implement new of API to get MAC address Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 08/16] bus/dpaa: make vdqcr configurable Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 09/16] net/dpaa: support default queue mode Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 10/16] net/dpaa: remove experimental tag from PMD APIs Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 11/16] bus/dpaa: cleanup unnecessary global variables Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 12/16] bus/fslmc: " Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 13/16] drivers: support function name in logs trace Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 14/16] net/dpaa: move the push queue set to global init Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 15/16] bus/dpaa: add support for SG config Hemant Agrawal
2018-07-06  8:10     ` [dpdk-dev] [PATCH v3 16/16] net/dpaa: implement scatter offload support Hemant Agrawal
2018-07-12 12:23       ` Thomas Monjalon
2018-07-13  6:32         ` Shreyansh Jain
2018-07-12 12:49     ` [dpdk-dev] [PATCH v3 01/16] bus/dpaa: fix phandle support for kernel 4.16 Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1530697431-1244-7-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).