-
Notifications
You must be signed in to change notification settings - Fork 2k
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
netdev ethernet: deal with too small packet buffer #5229
Conversation
This breaks if multiple modules define a minimum size. |
Any better idea? |
Could you elaborate why?
Define an ethernet pseudomodule, make all ethernet drivers depend on it (same with other network device types), then use those pseudomodules to fix minimum pktbuf size. |
Because the Ethernet drivers always allocate a full Ethernet frame in the beginning and only reallocate later. |
Because the Ethernet drivers always allocate a full Ethernet frame in
the beginning and only reallocate later.
Ah, I remember. ;)
|
I don't see why I need a pseudomodule if we have already |
yeah, just use that.
Why not exactly where you put with this PR? |
So, then you propose to leave this PR as it is? |
No, I meant instead of checking for "GNRC_PKTBUF_MIN_SIZE" in pktbuf.h, check for "MODULE_NETDEV2_ETH" and if true, set ethernet's minimum size. |
Ah, but I was actually looking for a way to avoid more ifdefs and particular ifdefs checking for particular modules. Imagine we have hundred of network drivers with different requirements on the minimum packetbuffer size. IMO the ideal solution would be to define this size somewhere in the device's header, but I don't know how to make sure that this headers gets included before |
I imagine. Ugly. But currently we have one, and a handful would be manageable.
Reminds me of my snippets PR. |
Another solution would be to only allocate the maximum pktsnip size within the ethernet drivers (or a little bit less). |
Instead of allocating it in the packet buffer, you mean? Might be somewhat cleaner and would allow us to get rid of this realloc-call. On 2 April 2016 09:16:43 CEST, Kaspar Schleiser notifications@github.com wrote:
Join the RIOT |
Instead of allocating it in the packet buffer, you mean? Might be
somewhat cleaner and would allow us to get rid of this realloc-call.
No, I meant something like setting an MTU dependent on pktbuf size, or
checking the minimum pktbuffer size before allocating, or sth like that.
|
Hm, why not simply using a temporary static buffer inside the driver? Would simplify the code and fail at bukd time if not enough memory is available. MTU is not a fixed value in GNRC. On 2 April 2016 10:14:23 CEST, Kaspar Schleiser notifications@github.com wrote:
Join the RIOT |
How about this solution? |
|
Ah, no, my mistake. It should work. Forget the previous comment. |
But this allocates the needed space again in the pktbuf, right? Then it essentially doubles the needed space. |
If it just wraps the buffer, it needs to be locked, and only one ethernet packet can be in flight at one time. |
It allocates the spaced that is actual need in the pktbuffer, yes. I think if we waste 1.5kB in the driver anyway, that doesn't make things much worse. Can you explain (once again) why this alloc-realloc mechanism is required for the Ethernet driver but not for other radio drivers? Maybe we can get completely rid of this hack? |
What was the rationale again of lowering the default pktbuf size? IMHO we should just up it again, all our MCU's have that memory. |
Just another idea: Since this is a native related issue, how about fixing it there: We are on native, so why not use a temporary buffer that we can |
@kaspar030 was against this. |
else | ||
CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DGNRC_IPV6_NC_SIZE=0 | ||
endif | ||
CFLAGS += -DGNRC_IPV6_NETIF_ADDR_NUMOF=4 -DGNRC_IPV6_NC_SIZE=1 |
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.
the NC_SIZE is different than before, is that a problem?
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.
solved offline
pls squash |
98c97ef
to
977920f
Compare
Removed reverted (and reverting) commits. |
There were two small glitches revealed by the CI. Can I squash directly? |
yes, please |
Rationale: the netdev2_tap Ethernet driver for native requires to temporarily store at least a maximum sized Ethernet frame.
The workaround for the pktbuf size is not longer needed, since native itself assures a big enough buffer. Using a neighbor cache size of 1 is mandatory for all platforms when compiling pedantically.
1c23df1
to
26cf46c
Compare
Squashed. |
restarted Murdock |
ACK once Murdock agrees. |
Please provide a backport. |
Rationale: some drivers, e.g. the Ethernet drivers, require a minimum size for the packet buffer. This commit introduces an optional minimal size that can be overwritten from the application.I reworked this PR to introduce a temporary buffer inside the Ethernet drivers themselves, instead of reallocating on the packet buffer. IMO that's a cleaner solution as it reduces the lines of code and makes it simpler. It introduces more statically allocated memory, but this memory is necessary with the current implementation anyway (it just moves from pktbuf to the driver), but at least fails at build time if not available.Let the native port check for a too small pktbuf size and adjust it.
Additionally this PR removes the (now not longer needed) hack from
gnrc_minimal_networking
's Makefile and handle native the same as any other platform.Without this PR the default example won't work on native (or other boards with an Ethernet device). Thanks for reporting, @LudwigKnuepfer.