lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Low-level interface error handling - request/suggestion


From: Mike Fleetwood
Subject: Re: [lwip-users] Low-level interface error handling - request/suggestion
Date: Fri, 29 Jul 2016 12:02:19 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi Simon,

thanks for speedy reply!

I could easily modify ST's driver to return ERR_IF instead. That would also prove once-for-all that the problem does lie in the driver (or not!).

You say it "shouldn't" be fatal - that's what I thought from looking through the code. Surely it should only result in a lost Tx packet, next call the DMA should have drained and all be OK. This is the bit that doesn't make sense - it seems more like the DMA (or MAC) just stops after a random interval. I did wonder about hardware, but I have two units exhibit the same problem.

I did try comparing the STM32F427 "ethernetif.c" with the STM32F107 "stm32-eth.c" that I used previously, but the format is changed completely, with the newer version much more embedded in LWIP (the old one just got a pointer to data and a length to send).

Many thanks,

Mike.

P.S. I cannot recall that I changed anything significant, but the software is working better today! I left it running last night but it had failed by this morning. I ran the "udp_test" (my one!), increased the packet data size to 200bytes and rate to 10mS and sent 750k+ packets without error. Currently returned to my original RTP audio code, sending 190 words dummy data + dummy RTP header (total packet "on wire" 434 bytes) and sent 128k packets so far at 10mS without errors!


On 29/07/2016 11:32, Simon Goldschmidt wrote:
Mike Fleetwood wrote:
I am using ST's ethernetif.c driver for STM23F427, which occasionally
returns ERR_USE. The reason this return code is used, rather than any
other is explained by ST in the function header:
So STM decided to return "Address in use" (ERR_USE) when they cannot enqueue a 
tx packet
in the DMA ring. That's a bogus error code for this error condition. This might 
be a valid
approach as ERR_MEM indeed has some other side effects (e.g. the http server 
retries
writing less bytes, etc).

However, ERR_USE is clearly the wrong error here, since it does not point to 
the error
source at all.
ERR_IF might have been better, but this is marked as fatal in the lwIP version 
they ship,
so this is not an option as well.
ERR_BUF might have been better, but in the end there is not a real difference 
to using ERR_USE,
as the stack does not check error return values other than ERR_MEM and 
ERR_IS_FATAL().

So, my request is: is it possible for future versions of LWIP detect
this return from the low level driver and either impliment some recovery
(presumably short wait, then re-try would allow the DMA buffer to
clear),
I could imagine that for TCP (some kind of trigger callback that results in 
calling tcp_output()
on all pcbs), but there's no way to do that for UDP (we do not have cached 
pbufs to retry).

Instead, the netif driver might want to keep a list of pbufs to transmit and 
queue them in
a software queue if the (hardware-) DMA queue is not big enough.

or, at least report the error in a meaningful way to the higher
layers?
That's easy: make the netif driver implementation return a meaningful error.
ERR_IF would be correct, but that doesn't work until fatal error handling has 
been fixed.
ERR_BUF would be OK for now, I guess.

Currently, this error would appear to be fatal.
No, it's not (unless you use a pre 1.4.0 version of lwIP).
It should continue working once there's room in the DMA ring again. That makes 
me think there's
some kind of race condition in the driver.

As to why it should happen in the first place - that is another problem!
That, too, makes me think of a bug in the driver, given the timings you 
discribed in your last mail.


Simon

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
FACE Systems Ltd
The Old Boat House
Cadgwith
Cornwall TR12 7JX
T:01326 291031
M:07831 401464




reply via email to

[Prev in Thread] Current Thread [Next in Thread]