* [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c
@ 2015-11-05 8:42 Thomas Chou
2015-11-05 16:16 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Chou @ 2015-11-05 8:42 UTC (permalink / raw)
To: u-boot
Do not allocate rx buf in net.c, because altera_tse allocates
its own rx buf in driver. This can save 6KB memory.
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
include/configs/nios2-generic.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 4569de8..856c836 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -33,8 +33,9 @@
#define CONFIG_SYS_MAX_FLASH_SECT 512
/*
- * MII/PHY
+ * NET options
*/
+#define CONFIG_SYS_RX_ETH_BUFFER 0
#define CONFIG_CMD_MII
#define CONFIG_PHY_GIGE
#define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c
2015-11-05 8:42 [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c Thomas Chou
@ 2015-11-05 16:16 ` Marek Vasut
2015-11-05 23:47 ` Thomas Chou
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2015-11-05 16:16 UTC (permalink / raw)
To: u-boot
On Thursday, November 05, 2015 at 09:42:43 AM, Thomas Chou wrote:
> Do not allocate rx buf in net.c, because altera_tse allocates
> its own rx buf in driver. This can save 6KB memory.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Shouldn't we instead fix the altera driver to use the pre-allocated
buffer ?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c
2015-11-05 16:16 ` Marek Vasut
@ 2015-11-05 23:47 ` Thomas Chou
2015-11-06 1:40 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Chou @ 2015-11-05 23:47 UTC (permalink / raw)
To: u-boot
Hi Marek,
On 2015?11?06? 00:16, Marek Vasut wrote:
> On Thursday, November 05, 2015 at 09:42:43 AM, Thomas Chou wrote:
>> Do not allocate rx buf in net.c, because altera_tse allocates
>> its own rx buf in driver. This can save 6KB memory.
>>
>> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>
> Shouldn't we instead fix the altera driver to use the pre-allocated
> buffer ?
It should not. The drivers and devices are dynamically binding in driver
model. The buffers used by devices should be allocated per device. Eg,
there may be multiple ethernet devices and they should not use the same
pre-allocated rx bufs.
Best regards,
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c
2015-11-05 23:47 ` Thomas Chou
@ 2015-11-06 1:40 ` Marek Vasut
2015-11-06 4:52 ` Thomas Chou
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2015-11-06 1:40 UTC (permalink / raw)
To: u-boot
On Friday, November 06, 2015 at 12:47:13 AM, Thomas Chou wrote:
> Hi Marek,
Hi!
> On 2015?11?06? 00:16, Marek Vasut wrote:
> > On Thursday, November 05, 2015 at 09:42:43 AM, Thomas Chou wrote:
> >> Do not allocate rx buf in net.c, because altera_tse allocates
> >> its own rx buf in driver. This can save 6KB memory.
> >>
> >> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> >
> > Shouldn't we instead fix the altera driver to use the pre-allocated
> > buffer ?
>
> It should not. The drivers and devices are dynamically binding in driver
> model. The buffers used by devices should be allocated per device. Eg,
> there may be multiple ethernet devices and they should not use the same
> pre-allocated rx bufs.
Oh ok, I see your point now. But then, this allocation of buffers in the
ethernet drivers becomes a boilerplate code, right ? So maybe there should
be some mechanism in the network stack to allocate the buffers for the drivers
to prevent duplication of code.
What do you think?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c
2015-11-06 1:40 ` Marek Vasut
@ 2015-11-06 4:52 ` Thomas Chou
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Chou @ 2015-11-06 4:52 UTC (permalink / raw)
To: u-boot
Hi Marek,
On 2015?11?06? 09:40, Marek Vasut wrote:
> On Friday, November 06, 2015 at 12:47:13 AM, Thomas Chou wrote:
>> Hi Marek,
>
> Hi!
>
>> On 2015?11?06? 00:16, Marek Vasut wrote:
>>> On Thursday, November 05, 2015 at 09:42:43 AM, Thomas Chou wrote:
>>>> Do not allocate rx buf in net.c, because altera_tse allocates
>>>> its own rx buf in driver. This can save 6KB memory.
>>>>
>>>> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>>>
>>> Shouldn't we instead fix the altera driver to use the pre-allocated
>>> buffer ?
>>
>> It should not. The drivers and devices are dynamically binding in driver
>> model. The buffers used by devices should be allocated per device. Eg,
>> there may be multiple ethernet devices and they should not use the same
>> pre-allocated rx bufs.
>
> Oh ok, I see your point now. But then, this allocation of buffers in the
> ethernet drivers becomes a boilerplate code, right ? So maybe there should
> be some mechanism in the network stack to allocate the buffers for the drivers
> to prevent duplication of code.
The pre-alloacted tx_buf is still in use by net/ . But most ethernet
drivers allocate their own rx_buf (perhaps as ring buffer). Most of them
use memalign(PKTSIZE_ALIGN), which is the same as
malloc_cache_aligned(PKTSIZE_ALIGN). Each driver may have different
requirement of size/number of the rx buf.
The driver passes the rx buf to net/ . And the net/ return the rx buf
with free_pkt() to the driver after use.
I think this scheme works fine. There not much duplication of code for
rx_buf allocation, which might be only a malloc_cache_aligned().
Best regards,
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-06 4:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-05 8:42 [U-Boot] [PATCH] nios2: nios2-generic: do not allocate rx buf in net.c Thomas Chou
2015-11-05 16:16 ` Marek Vasut
2015-11-05 23:47 ` Thomas Chou
2015-11-06 1:40 ` Marek Vasut
2015-11-06 4:52 ` Thomas Chou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox