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: l2: ppp: ppp uart usage fixes #61147

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/net/ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,14 +1046,15 @@ static int ppp_start(const struct device *dev)
}
#endif /* !CONFIG_NET_TEST */

ARG_UNUSED(context);
net_if_carrier_on(context->iface);
return 0;
}

static int ppp_stop(const struct device *dev)
{
struct ppp_driver_context *context = dev->data;

net_if_carrier_off(context->iface);
context->modem_init_done = false;
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions include/zephyr/net/ppp.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ struct ppp_context {
/** Is PPP ready to receive packets */
uint16_t is_ready_to_serve : 1;

/** Is PPP L2 enabled or not */
uint16_t is_enabled : 1;

/** PPP enable pending */
uint16_t is_enable_done : 1;

Expand Down
2 changes: 0 additions & 2 deletions subsys/net/l2/ppp/ppp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,3 @@ static inline bool ppp_my_option_is_acked(struct ppp_fsm *fsm,
{
return ppp_my_option_flags(fsm, code) & PPP_MY_OPTION_ACKED;
}

void ppp_if_carrier_down(struct net_if *iface);
27 changes: 25 additions & 2 deletions subsys/net/l2/ppp/ppp_l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ LOG_MODULE_REGISTER(net_l2_ppp, CONFIG_NET_L2_PPP_LOG_LEVEL);
#include <zephyr/sys/iterable_sections.h>

#include "net_private.h"
#include "ipv4_autoconf_internal.h"

#include "ppp_stats.h"
#include "ppp_internal.h"
Expand Down Expand Up @@ -218,7 +217,31 @@ static enum net_l2_flags ppp_flags(struct net_if *iface)
return ctx->ppp_l2_flags;
}

NET_L2_INIT(PPP_L2, ppp_recv, ppp_send, NULL, ppp_flags);
static int ppp_enable(struct net_if *iface, bool state)
{
const struct ppp_api *ppp =
net_if_get_device(iface)->api;
struct ppp_context *ctx = net_if_l2_data(iface);

if (ctx->is_enabled == state) {
return 0;
}

ctx->is_enabled = state;

if (!state) {
if (ppp->stop) {
ppp->stop(net_if_get_device(iface));
}
} else {
if (ppp->start) {
ppp->start(net_if_get_device(iface));
}
}
return 0;
}

NET_L2_INIT(PPP_L2, ppp_recv, ppp_send, ppp_enable, ppp_flags);

#if defined(CONFIG_NET_SHELL)
static int get_ppp_context(int idx, struct ppp_context **ctx,
Expand Down