drivers/enc28j60: register with netdev#15083
Conversation
30992a9 to
b1a8b3c
Compare
|
Like this. But getting a bit confused ... A hack we've used sets EUI48 from the EUI64 to get: Comment? |
|
The EUI64 chip only provides an EUI64, no EUI48. static inline int _at24mac_get_eui48_hack(const void *arg, eui48_t *addr)
{
eui64_t eui64;
int res = at24mac_get_eui64((uintptr_t)arg, eui64);
memcpy(addr, &eui64, sizeof(eui48_t));
return res;
}
#define EUI48_PROVIDER_FUNC _at24mac_get_eui48_hack
#define EUI48_PROVIDER_TYPE NETDEV_ANY
#define EUI48_PROVIDER_INDEX 0in your This will discard the lower bytes of the EUI-64. But keep in mind that now it's no longer unique. |
|
I was cherry-picking bits to reuse vendor and use most volatile bits, |
|
so that would be static inline int _at24mac_get_eui48_hack(const void *arg, eui48_t *addr)
{
eui64_t eui64;
int res = at24mac_get_eui64((uintptr_t)arg, eui64);
/* Mangle the EUI64 into a 48-bit Ethernet address. */
memcpy(&addr->uint8[0], &eui64.uint8[0], 3); /* Preserve vendor id */
memcpy(&addr->uint8[3], &eui64.uint8[5], 3); /* Use most volatile bits */
return res;
} |
|
Yes would prefer that. At least from unique a EUI64 where we double it's use and also stick it to Ethernet module. The volatile bits should give pretty good protection from collisions, |
|
I think reusing the EUI-64 to also provide EUI-48 might be something we could provide as module, provided we set the bit indicating locally/globally unique address to only locally unique. |
The EUI-64 is for the radio, right? Then using that one for the Ethernet device seems dangerous in terms of the global uniqueness of the Ethernet device's MAC address. See also https://www.avrfreaks.net/comment/2614676#comment-2614676. |
|
Right. ip6 as 6lowpan uses EUI64 The chip can be used for both. Devices that leaves MAC to users are challenging there is a risk unless we buy an address and put on devices. So how mitigate this situation? IMO in the end it's the network administrator or user that is responsible. OS can only give options/tools. In this case we preserve the vendor id. So so no clashes with other vendors. Also one can meditate a bit over the need for global uniqueness at least nowadays where we partition networks hard and limit link sizes. We mostly keep the link where we have the weak MCU w. ethernet extra isolated/small not be vulnerable from internet. Maribu suggestion mark as locally unique seems correct. We've found this scheme attractive to easily map 802.15.4 and ip4 addresses. Yes including maribu suggestions to make it locally unique and a module. This particular chip has unique 128 bit and 64 bits but not 48 bits. :( |
b1a8b3c to
1afe72a
Compare
maribu
left a comment
There was a problem hiding this comment.
ACK. Code looks good and testing result provided in #15083 (comment)
Contribution description
Register
enc28j60so we can useeui_providerto assign the module a MAC address.Testing procedure
Issues/PRs references
#14634 (comment)