Skip to content
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

net/l2util: add eui_short/48/64_get() #12641

Closed
wants to merge 11 commits into from
Closed

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 4, 2019

Contribution description

Based on the discussion in #12592 the consensus seemed that there should be an additional layer on top of luid to dispatch L2 addresses.

Maybe it could be as simple as that?

If your board provides a EUI64, with this all you have to do is implement

size_t board_get_eui64(netdev_t *netdev, eui64_t *addr) {
    …
}

and then figure out a way to dispatch the address to the right netdev.
However, for the most common case where there is only one interface, you can simple ignore netdev.

Testing procedure

Nothing to test yet.

Issues/PRs references

depends on #12592
addresses #12616

@benpicco benpicco added Area: network Area: Networking State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Nov 4, 2019
@benpicco benpicco requested review from miri64 and maribu November 4, 2019 17:21
@benpicco benpicco changed the title net/l2util: add l2util_get_eui_short/48/64() net/l2util: add eui_short/48/64_get() Nov 7, 2019
@benpicco
Copy link
Contributor Author

benpicco commented Nov 7, 2019

Rebased & renamed the functions to better fit with the other functions in eui48.h/eui64.h

sys/include/net/eui48.h Outdated Show resolved Hide resolved
sys/include/net/eui64.h Outdated Show resolved Hide resolved
@benpicco benpicco removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Nov 8, 2019
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not happy about the naming and placement of these functions. IMHO they belong more to l2util than the type definitions for euiXX.

sys/include/net/eui48.h Outdated Show resolved Hide resolved
* @param[out] addr The dedicated address for the netdev
*
*/
size_t board_get_eui48(netdev_t *netdev, eui48_t *addr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eui48_get_from_board()?

* @param[out] addr The generated short address
*
*/
static inline void eui_short_get(netdev_t *netdev, uint16_t *addr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in eui64.h. Neither is the short address of IEEE 802.15.4 an EUI, nor has it anything to do with an EUI-64 (except that they are both used in IEEE 802.15.4 as addresses). This function and board_get_eui_short don't belong here. You've put the implementation for board_get_…() already in l2util (which given that l2util might not be compiled in in any case is somewhat of a bargain IMHO, but let's discuss this elsewhere), so why not put it there as l2util_generate_short_addr()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it should also be l2util_generate_euiXX() for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i wrote the other comments before I realized, that the other functions are also misplaced.

@benpicco
Copy link
Contributor Author

I moved them back to l2util once again.

sys/include/net/l2util.h Outdated Show resolved Hide resolved
@maribu
Copy link
Member

maribu commented Nov 19, 2019

Let's define what we expect as use cases by likelyhood. I'd say there are three scenarios:

  1. There are no EUIs provided at all, LUID has to be used
  2. There is a single EUI chip on the board
  3. There are multiple EUI chips on the board

I believe that this is also the order of likelihood. I think that this PR handles case 1. and 3. very well, but case 2. could be handled better: If only a single EUI driver is loaded, this could provide the custom EUI function as weak symbol, which returns the provided EUI on the first call and an error on all subsequent. This would require no board support (except for adding e.g. USEMODUE += at24mac). If multiple EUI chips are present, the board would need to provide the function as strong symbol that matches the driver name and index to the correct EUI provider.

@benpicco
Copy link
Contributor Author

benpicco commented Nov 20, 2019

As for 2., I could implement

size_t board_get_eui48(const char *driver, unsigned idx, eui48_t *addr) {
    (void) driver;
    /* Maybe at24mac_get_euiXX() should just return the size */
    if (at24mac_get_eui48(idx, addr)) {
        return 0;
    }
    return sizeof(*addr);
}

in #12746.
But If the board wants to also implement board_get_euiXX() to handle the driver name, we would have to introduce some define.

@benpicco benpicco requested a review from jia200x November 29, 2019 09:00
@benpicco
Copy link
Contributor Author

benpicco commented Dec 10, 2019

I think we should just drop that 'automatic' MAC chip <-> transceiver pairing idea and leave it to the board to implement board_get_euiXX().

If at some point we come up with a good solution we can still convert it to that, but let's start with the simple implementation first.

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this back to my attention. I have a question though...

*
* @warning Don't call this function directly, use @ref l2util_generate_short_addr() instead.
*
* @param[in] driver The driver name of the netdev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please relight my memory: What is the driver name of the netdev?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that a EUI would be assigned to a certain device/driver.
E.g. both samr21-xpro and same54-xpro contain a EUI-64 resp. EUI-48.
On samr21-xpro that should only be used for the first device of the at86rf2xx driver…

It's not pretty but so far we haven't come up with a better solution to assign IDs to netdevs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not pretty but so far we haven't come up with a better solution to assign IDs to netdevs.

Mhhhh its not just not pretty, it can be very costly. Both the string will cost memory, and string operations aren't the most efficient either. :-/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use NETDEV_TYPE_ here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the netdev allocations would be in an xfa this would be simpler :-/.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this we would have the migration benefit, that this could be done driver by driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not provide a board-unique ID with params btw?

  • we have to touch every board
  • we waste RAM and ROM for information that is already implicitly available

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* we waste RAM and ROM for information that is already implicitly available

I thought it is not. If it is why use the (more RAM heavy) name?

* we have to touch every board

If we don't use the current approach, I believe we don't have. Also: only every board that provides a netdev params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it is not. If it is why use the (more RAM heavy) name?

Well we just have to touch every netdev driver (to do the index -> params mapping inside the driver instead of auto_init). I just want to be sure that's the right way to go before I shave that Yak 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to be sure that's the right way to go before I shave that Yak wink

See #12641 (comment). As far as I understand board.c might not exist anymore in the near future :-/.

@miri64
Copy link
Member

miri64 commented Jan 30, 2020

Apparently, there is some rework to board.c waiting to be proposed. @kaspar030 could you maybe have a look, at the core idea of this PR is still relevant with your rework in mind.

@benpicco
Copy link
Contributor Author

I've converted at86rf2xx as an example and implemented board_get_eui64() for samr21-xpro.
The HWaddr should now match the one printed backside of the board.

@miri64
Copy link
Member

miri64 commented Jun 25, 2020

@benpicco can you give this a rebase and status update on the WIP state of this PR?

@benpicco
Copy link
Contributor Author

Requires #13746 for a proper solution, but I don't have time to shave that yak now.
If we want to solve the common 'board provides EUI, interface should use EUI' case and we don't care about the order for the multi-EUI / multi-Interface case, we can just implement board_get_eui…() as initially proposed here.

@miri64 miri64 added the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 25, 2020
@benpicco
Copy link
Contributor Author

superseded by #13746

@benpicco benpicco closed this Jul 24, 2020
@benpicco benpicco deleted the eui-get branch July 24, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants