-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth_nxp_enet_qos_mac: implement the nxp,unique-mac address feature #83549
eth_nxp_enet_qos_mac: implement the nxp,unique-mac address feature #83549
Conversation
8c09952
to
9d6e4a1
Compare
I found the Kconfig where to setup the dependencies. |
da238fd
to
4c4fe91
Compare
@@ -23,6 +23,14 @@ config ETH_NXP_ENET_QOS_MAC | |||
|
|||
if ETH_NXP_ENET_QOS_MAC | |||
|
|||
config ETH_NXP_ENET_QOS_MAC_UNIQUE_MAC_ADDRESS | |||
bool "Unique MAC address support" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add default y
and depends on $(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe default y if $(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I can make it default "Y" but I struggle to depend on property "nxp,unique-mac" because it parses this as two arguments (the property and the value),
default y if $(dt_compat_any_has_prop,$(DT_COMPAT_NXP_ENET_QOS_MAC),nxp,unique-mac)
This never evaluates to true.
I searched all Kconfig for samples but there is none "grep has_prop Kconfig"
Any advice?
I would just prefer to make default y
unconditionally so it can be removed on demand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tested:
DT_PROP_NXP_ENET_QOS_MAC_UNIQUE_MAC := nxp,unique-mac
config ETH_NXP_ENET_QOS_MAC_UNIQUE_MAC_ADDRESS
bool "Unique MAC address support"
default y if $(dt_compat_any_has_prop,$(DT_COMPAT_NXP_ENET_QOS_MAC),$(DT_PROP_NXP_ENET_QOS_MAC_UNIQUE_MAC))
which always evaluates to true. :-O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are closer with the more recent comment, the issue is you need to give the value argument (for a boolean if the value is false the property is still present just invisible). If you are just checking if the property exists and not that it has a certain value, then for a boolean property it will always be true that it exists.
0743664
to
7f1070e
Compare
Hello @decsny the value thing is doing the trick. Thanks for pointing out.
|
MAC_ADDR_SOURCE_LOCAL, | ||
MAC_ADDR_SOURCE_RANDOM, | ||
MAC_ADDR_SOURCE_UNIQUE, | ||
MAC_ADDR_SOURCE_FUSED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when or how does the fused option get used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping that NXP has an predefined position in the "OTP" space.
Derek.Snell in discord answered "No" meanwhile (for the MCXN).
"Fused" will fall back to "random" address.
I am not sure if other MCU that use that driver module have such predefined space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I remove it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the enum is only used internally by this driver, it should be removed, can be added if needed later.
You may also want to consider renaming the enum to something with a prefix of the driver like the other structs in that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done so.
if (config->random_mac) { | ||
if (config->mac_addr_source == MAC_ADDR_SOURCE_LOCAL) { | ||
/* Use the mac address provided in the devicetree */ | ||
#if defined(CONFIG_ETH_NXP_ENET_QOS_MAC_UNIQUE_MAC_ADDRESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, prefer to #else #define nxp_enet_unique_mac(...) as an empty macro above and remove this inline #if from this spot, if that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep a nondestructive fallback rather than generate an all zero MAC ADDRESS as in the eth_nxp_enet.c driver.
Even this is not what the user has asked for.
If you agree ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if I understand correctly, this code would never be reached in the case that there is no "unique" address option in the DT. If you are really concern about it maybe the alternative definition would return an error, but that will add an instruction or two to image, but which is fine to me. I found over many cases that having inline #if tends to cause configuration and dependency problems down the line when maintaining the files, and makes it harder to read, that's why I want to avoid it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. implemented as empty macro causing lesser #if defined() in the code.
746039d
to
733709e
Compare
This implements to generate the MAC address of the device UUID. The UUID is hashed to reduce the size to 3 bytes. Ideas taken from eth_nxp_enet.c Adding dependencies on: HWInfo and CRC Signed-off-by: Adib Taraben <theadib@gmail.com>
733709e
to
9b9ea46
Compare
This implements to generate the MAC address of the device UUID. The UUID is hashed to reduce the size to 3 bytes.
Ideas taken from eth_nxp_enet.c
It does not implement fused MAC address.
Adding dependencies on: HWInfo and CRC
Help needed:
currently I do not know how to register the dependencies in the driver.
That will cause to fail compilation without adding HWInfo and CRC manually.
Adib.