-
Notifications
You must be signed in to change notification settings - Fork 7k
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: l2: ppp: ppp uart usage fixes #61147
net: l2: ppp: ppp uart usage fixes #61147
Conversation
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.
In short, if you are using ppp.c, then you need to start it manually in your driver, before you call net_if_carrier_on() on the network interface, (or net_if_up() as is done from within the gsm_ppp.c driver). If you need an event when LCP has established the data link, add the NET_EVENT_PPP_PHASE_RUNNING and NET_EVENT_PPP_PHASE_DEAD events where you have moved the CARRIER_ON/OFF events.
This should solve your issues without adding complexity by mixing NET_PPP and NET_L2_PPP or changing the meaning of the CARRIER_ON/OFF events :)
This fixes 3 issues that came within PR zephyrproject-rtos#59124 for ppp uart usage. Earlier start/stop of ppp was done at enable() but that was removed in PR zephyrproject-rtos#59124. Now putting enable/disable() back and putting start/stop there. Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN. For that net_if_carrier_on/off is set in uart ppp.c driver. Also, maybe worth to be mentioned that after PR zephyrproject-rtos#59124 there is no ppp carrier off when lcp is disconnected, for workaround that change, application should use ppp dead/running events. Signed-off-by: Jani Hirsimäki <[email protected]>
fe239db
to
f573fc9
Compare
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.
Thanks @jhirsi for the time you put into investigating this.
@bjarki-trackunit Please revisit, it seems now that the changes should be not be affecting your use case, while making net/ppp.c
driver usable again.
The fundamental issue with this PR is that it is trying to make the L2 PPP subsystem adhere to some downstream code, instead of updating the downstream code to adhere to the L2 PPP subsystem.
Additionally, the carrier is not LCP, when LCP is dead, it does not mean the carrier is lost. If some downstream code is misusing the event, that again, should be fixed there, not altered in the L2 PPP subsystem which "accurately" fires the event (the event is not actually indicating the carrier status, it was just kept there for backwards compatibility). The changes in this PR simply do not adhere to the documentation and functionality of a L2 network interface and subsystem... If you could instead create an issue, where you accurately document how you are using the L2 PPP subsystem and which issues you are seeing, showing some logs, code examples etc. We may be able figure out how to align your code with the L2 PPP subsystem :) |
I'm sorry, but I almost totally disagree with your statement.
It's not "some downstream" code we want to adhere to, we want the PPP L2 to make use of the APIs defined in
This is simply not correct. Before changes in #59124, Zephyr was able to establish PPP link with Windows/Linux host w/o any other action needed, other than bringing the network interface up. This is no longer the case, because from some reason it is assumed that some other module is supposed to do the work that L2's
I don't see where does it requirement come from. We have
That's correct, and that's why we're no longer pushing for any changes related to how and when PPP_CARRIER events are generated. We're switching to RUNNING/DEAD events instead (although they also seem to have their own issues, like DEAD firing several times during link negotiation).
Can you provide us with the link to the documentation, where the behaviors that we "break" in the current proposal are described? Otherwise, it's hard to relate.
For reference: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/cellular/modem_shell/src/ppp/ppp_ctrl.c |
Thank you for the reference. The documentation is in this segment Network interface state management To summarize; enable() is called when a network interface is administratively brought up, not when it becomes operational.
If you tie the starting and stopping of the L2 driver to enable(), it will only be enabled if Once Here is the issue: start() and stop() were never called, to reinitialize The only part of the system which knows when the carrier was acquired, lost, and reacquired is the L2 driver, which is why it is the only logical place to keep that logic. I can not summarize the issue simpler than this. This PR provides a change which re-implements a fundamentally non-functional mechanism (while also adding If we really want to keep the start and stop: zephyr/subsys/net/l2/ppp/ppp_l2.c Line 387 in f573fc9
and stop here zephyr/subsys/net/l2/ppp/ppp_l2.c Line 392 in f573fc9
you do not need to add anything in addition to this. the carrier is set to on by default, so net_if_up() and net_if_down() will change the operational state unless the carrier is manually set to off using net_if_carrier_off() at some point.
|
Good, I'm pretty well aware of that part of the documentation, as I wrote it.
And that's when it's supposed to be called, there's no confusion about that. Application brings the interface up (admin up), and the L2 starts the underlying device: struct ppp_api {
...
/** Start the device */
int (*start)(const struct device *dev);
/** Stop the device */
int (*stop)(const struct device *dev);
} Don't you think that calling
Is that wrong? If you bring the interface down, you stop the underlying device. And if you bring it up, you start it. What's wrong with that? And it's not that you "tie" the API calls to
So if your particular modem driver needs to reboot the modem, do it, keep the logic there. But
Sorry, but even after reading all your comments here and in your previous PR that introduced the regression, I still don't understand what's non-fucntional about
I think we need to reconsider what a carrier means in terms of |
Adding @jukkar to the discussion, as the original author of the PPP subsys. |
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.
LGTM
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.
One last retort, the UART being initialized is not the carrier being ready, what if the UART is not physically connected to anything?
This fixes 3 issues that came within PR #59124 for ppp uart usage.
Earlier start/stop of ppp was done at enable() but that was removed in PR #59124.
Now putting enable/disable() back and putting start/stop there.
Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN. For that net_if_carrier_on/off is set in uart ppp.c driver. Also, worth to be mentioned that after PR #59124 there is no ppp carrier off when lcp is disconnected, for workaround that change, application that needs that information: should use ppp dead/running events instead.