* [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem
@ 2021-04-09 8:37 Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 1/3] dt-bindings: " Joakim Zhang
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 8:37 UTC (permalink / raw)
To: davem, kuba, robh+dt, andrew, hkallweit1, linux, frowand.list
Cc: netdev, devicetree, linux-kernel
This patch set adds new properties for of_get_mac_address from nvmem.
Fugang Duan (3):
dt-bindings: net: add new properties for of_get_mac_address from nvmem
net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes
order
of_net: add property "nvmem-mac-address" for of_get_mac_addr()
.../bindings/net/ethernet-controller.yaml | 14 +++++++++++
drivers/of/of_net.c | 4 +++
net/ethernet/eth.c | 25 +++++++++++++++----
3 files changed, 38 insertions(+), 5 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 1/3] dt-bindings: net: add new properties for of_get_mac_address from nvmem
2021-04-09 8:37 [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
@ 2021-04-09 8:37 ` Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order Joakim Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 8:37 UTC (permalink / raw)
To: davem, kuba, robh+dt, andrew, hkallweit1, linux, frowand.list
Cc: netdev, devicetree, linux-kernel
From: Fugang Duan <fugang.duan@nxp.com>
Currently, of_get_mac_address supports NVMEM, some platforms
MAC address that read from NVMEM efuse requires to swap bytes
order, so add new property "nvmem_macaddr_swap" to specify the
behavior. If the MAC address is valid from NVMEM, add new property
"nvmem-mac-address" in ethernet node.
Update these two properties in the binding documentation.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
.../bindings/net/ethernet-controller.yaml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index e8f04687a3e0..c868c295aabf 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -32,6 +32,15 @@ properties:
- minItems: 6
maxItems: 6
+ nvmem-mac-address:
+ allOf:
+ - $ref: /schemas/types.yaml#definitions/uint8-array
+ - minItems: 6
+ maxItems: 6
+ description:
+ Specifies the MAC address that was read from nvmem-cells and dynamically
+ add the property in device node;
+
max-frame-size:
$ref: /schemas/types.yaml#/definitions/uint32
description:
@@ -52,6 +61,11 @@ properties:
nvmem-cell-names:
const: mac-address
+ nvmem_macaddr_swap:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description:
+ swap bytes order for the 6 bytes of MAC address
+
phy-connection-type:
description:
Specifies interface type between the Ethernet device and a physical
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order
2021-04-09 8:37 [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 1/3] dt-bindings: " Joakim Zhang
@ 2021-04-09 8:37 ` Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr() Joakim Zhang
2021-04-09 9:05 ` [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
3 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 8:37 UTC (permalink / raw)
To: davem, kuba, robh+dt, andrew, hkallweit1, linux, frowand.list
Cc: netdev, devicetree, linux-kernel
From: Fugang Duan <fugang.duan@nxp.com>
ethernet controller driver call .of_get_mac_address() to get
the mac address from devictree tree, if these properties are
not present, then try to read from nvmem.
For example, read MAC address from nvmem:
of_get_mac_address()
of_get_mac_addr_nvmem()
nvmem_get_mac_address()
i.MX6x/7D/8MQ/8MM platforms ethernet MAC address read from
nvmem ocotp eFuses, but it requires to swap the six bytes
order.
The patch add optional property "nvmem_macaddr_swap" to swap
macaddr bytes order.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
net/ethernet/eth.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 4106373180c6..11057671a9d6 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -534,8 +534,10 @@ EXPORT_SYMBOL(eth_platform_get_mac_address);
int nvmem_get_mac_address(struct device *dev, void *addrbuf)
{
struct nvmem_cell *cell;
- const void *mac;
+ const unsigned char *mac;
+ unsigned char macaddr[ETH_ALEN];
size_t len;
+ int i = 0;
cell = nvmem_cell_get(dev, "mac-address");
if (IS_ERR(cell))
@@ -547,14 +549,27 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf)
if (IS_ERR(mac))
return PTR_ERR(mac);
- if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
- kfree(mac);
- return -EINVAL;
+ if (len != ETH_ALEN)
+ goto invalid_addr;
+
+ if (dev->of_node &&
+ of_property_read_bool(dev->of_node, "nvmem_macaddr_swap")) {
+ for (i = 0; i < ETH_ALEN; i++)
+ macaddr[i] = mac[ETH_ALEN - i - 1];
+ } else {
+ ether_addr_copy(macaddr, mac);
}
- ether_addr_copy(addrbuf, mac);
+ if (!is_valid_ether_addr(macaddr))
+ goto invalid_addr;
+
+ ether_addr_copy(addrbuf, macaddr);
kfree(mac);
return 0;
+
+invalid_addr:
+ kfree(mac);
+ return -EINVAL;
}
EXPORT_SYMBOL(nvmem_get_mac_address);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr()
2021-04-09 8:37 [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 1/3] dt-bindings: " Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order Joakim Zhang
@ 2021-04-09 8:37 ` Joakim Zhang
2021-04-09 9:05 ` [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
3 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 8:37 UTC (permalink / raw)
To: davem, kuba, robh+dt, andrew, hkallweit1, linux, frowand.list
Cc: netdev, devicetree, linux-kernel
From: Fugang Duan <fugang.duan@nxp.com>
If MAC address read from nvmem cell and it is valid mac address,
.of_get_mac_addr_nvmem() add new property "nvmem-mac-address" in
ethernet node. Once user call .of_get_mac_address() to get MAC
address again, it can read valid MAC address from device tree in
directly.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
drivers/of/of_net.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index 6e411821583e..20c3ae17f95f 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -116,6 +116,10 @@ const void *of_get_mac_address(struct device_node *np)
if (addr)
return addr;
+ addr = of_get_mac_addr(np, "nvmem-mac-address");
+ if (addr)
+ return addr;
+
return of_get_mac_addr_nvmem(np);
}
EXPORT_SYMBOL(of_get_mac_address);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem
2021-04-09 8:37 [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
` (2 preceding siblings ...)
2021-04-09 8:37 ` [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr() Joakim Zhang
@ 2021-04-09 9:05 ` Joakim Zhang
3 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 9:05 UTC (permalink / raw)
To: Joakim Zhang, davem, kuba, robh+dt, andrew, hkallweit1, linux,
frowand.list
Cc: netdev, devicetree, linux-kernel
Hi,
Please ignore this patch set version, I will resend it, sorry.
Best Regards,
Joakim Zhang
> -----Original Message-----
> From: Joakim Zhang <qiangqing.zhang@nxp.com>
> Sent: 2021年4月9日 16:38
> To: davem@davemloft.net; kuba@kernel.org; robh+dt@kernel.org;
> andrew@lunn.ch; hkallweit1@gmail.com; linux@armlinux.org.uk;
> frowand.list@gmail.com
> Cc: netdev@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: [PATCH net-next 0/3] net: add new properties for of_get_mac_address
> from nvmem
>
> This patch set adds new properties for of_get_mac_address from nvmem.
>
> Fugang Duan (3):
> dt-bindings: net: add new properties for of_get_mac_address from nvmem
> net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr
> bytes
> order
> of_net: add property "nvmem-mac-address" for of_get_mac_addr()
>
> .../bindings/net/ethernet-controller.yaml | 14 +++++++++++
> drivers/of/of_net.c | 4 +++
> net/ethernet/eth.c | 25
> +++++++++++++++----
> 3 files changed, 38 insertions(+), 5 deletions(-)
>
> --
> 2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem
2021-04-09 18:43 ` Jakub Kicinski
@ 2021-04-12 6:41 ` Joakim Zhang
0 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2021-04-12 6:41 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, robh+dt, andrew, hkallweit1, linux, frowand.list, netdev,
devicetree, linux-kernel, dl-linux-imx
Hi Jabuk,
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: 2021年4月10日 2:44
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: davem@davemloft.net; robh+dt@kernel.org; andrew@lunn.ch;
> hkallweit1@gmail.com; linux@armlinux.org.uk; frowand.list@gmail.com;
> netdev@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH net-next 0/3] net: add new properties for
> of_get_mac_address from nvmem
>
> On Fri, 9 Apr 2021 17:07:08 +0800 Joakim Zhang wrote:
> > This patch set adds new properties for of_get_mac_address from nvmem.
>
> Apart from addressing Rob's (and potentially other comments to come) please
> also make sure to rebase before posting. This series doesn't seem to apply to
> net-next.
This patch set can be applied to latest net-next branch, the top commits as below, not sure where is the issue from, sorry.
5b489fea977c (origin/master, origin/HEAD) Merge branch 'ipa-next'
927c5043459e net: ipa: add IPA v4.11 configuration data
fbb763e7e736 net: ipa: add IPA v4.5 configuration data
Best Regards,
Joakim Zhang
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem
2021-04-09 9:07 Joakim Zhang
@ 2021-04-09 18:43 ` Jakub Kicinski
2021-04-12 6:41 ` Joakim Zhang
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2021-04-09 18:43 UTC (permalink / raw)
To: Joakim Zhang
Cc: davem, robh+dt, andrew, hkallweit1, linux, frowand.list, netdev,
devicetree, linux-kernel, linux-imx
On Fri, 9 Apr 2021 17:07:08 +0800 Joakim Zhang wrote:
> This patch set adds new properties for of_get_mac_address from nvmem.
Apart from addressing Rob's (and potentially other comments to come)
please also make sure to rebase before posting. This series doesn't
seem to apply to net-next.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem
@ 2021-04-09 9:07 Joakim Zhang
2021-04-09 18:43 ` Jakub Kicinski
0 siblings, 1 reply; 8+ messages in thread
From: Joakim Zhang @ 2021-04-09 9:07 UTC (permalink / raw)
To: davem, kuba, robh+dt, andrew, hkallweit1, linux, frowand.list
Cc: netdev, devicetree, linux-kernel, linux-imx
This patch set adds new properties for of_get_mac_address from nvmem.
Fugang Duan (3):
dt-bindings: net: add new properties for of_get_mac_address from nvmem
net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes
order
of_net: add property "nvmem-mac-address" for of_get_mac_addr()
.../bindings/net/ethernet-controller.yaml | 14 +++++++++++
drivers/of/of_net.c | 4 +++
net/ethernet/eth.c | 25 +++++++++++++++----
3 files changed, 38 insertions(+), 5 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-04-12 6:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 8:37 [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 1/3] dt-bindings: " Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order Joakim Zhang
2021-04-09 8:37 ` [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr() Joakim Zhang
2021-04-09 9:05 ` [PATCH net-next 0/3] net: add new properties for of_get_mac_address from nvmem Joakim Zhang
2021-04-09 9:07 Joakim Zhang
2021-04-09 18:43 ` Jakub Kicinski
2021-04-12 6:41 ` Joakim Zhang
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).