net: ppp: consume ringbuf until it is empty
ringbuf claim API returns pointer to contiguous area. In cases when data in ringbuf wraps the end of internal buffer, then single call to claim data is not enough to get all data - there is remaining part on the beginning of internal buffer. Those remaining bytes will need to wait for next ISR handler to trigger workqueue. Theoretically this means that data on the beginning of ringbuf can wait there forever, or simply to the next timeout in PPP stack when data traffic continues. Consume data from ringbuf in a loop, stopping only when claiming results in empty buffer. This will make sure that there is no stale data in the ringbuf. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
a470d9deba
commit
67f106820b
1 changed files with 15 additions and 4 deletions
|
@ -632,10 +632,8 @@ static int ppp_send(struct device *dev, struct net_pkt *pkt)
|
|||
}
|
||||
|
||||
#if !defined(CONFIG_NET_TEST)
|
||||
static void ppp_isr_cb_work(struct k_work *work)
|
||||
static int ppp_consume_ringbuf(struct ppp_driver_context *ppp)
|
||||
{
|
||||
struct ppp_driver_context *ppp =
|
||||
CONTAINER_OF(work, struct ppp_driver_context, cb_work);
|
||||
uint8_t *data;
|
||||
size_t len, tmp;
|
||||
int ret;
|
||||
|
@ -644,7 +642,7 @@ static void ppp_isr_cb_work(struct k_work *work)
|
|||
CONFIG_NET_PPP_RINGBUF_SIZE);
|
||||
if (len == 0) {
|
||||
LOG_DBG("Ringbuf %p is empty!", &ppp->rx_ringbuf);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This will print too much data, enable only if really needed */
|
||||
|
@ -667,6 +665,19 @@ static void ppp_isr_cb_work(struct k_work *work)
|
|||
if (ret < 0) {
|
||||
LOG_DBG("Cannot flush ring buffer (%d)", ret);
|
||||
}
|
||||
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
static void ppp_isr_cb_work(struct k_work *work)
|
||||
{
|
||||
struct ppp_driver_context *ppp =
|
||||
CONTAINER_OF(work, struct ppp_driver_context, cb_work);
|
||||
int ret = -EAGAIN;
|
||||
|
||||
while (ret == -EAGAIN) {
|
||||
ret = ppp_consume_ringbuf(ppp);
|
||||
}
|
||||
}
|
||||
#endif /* !CONFIG_NET_TEST */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue