buglwIP - A Lightweight TCP/IP stack - Bugs: bug #47092, Tag memory buffers like...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #47092: Tag memory buffers like memp_memory_xxx and ram_heap with a macro so that attributes can be attached to teir definitions

Submitter:  David Fernandez <david0fc>
Submitted:  Mon 08 Feb 2016 04:23:25 PM UTC
   
 
Category:  Platform ports Severity:  3 - Normal
Item Group:  Feature Request Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  2.0.0 Beta2
lwIP version:  git head

Jump to the original submission

Thu 07 Jul 2016 11:41:48 AM UTC, comment #7: 

New LWIP_DECLARE_MEMORY_ALIGNED macro should suit your needs

Dirk Ziegelmeier <dziegel>
Group administrator
Thu 18 Feb 2016 08:19:19 PM UTC, comment #6: 


> David, you're not the first wanting to put the pools into a different section. So far, everyone seems to have succeeded with what we provide (unless the recent memp changes have broken this).


Sure, I can manage as is... that is what I'm doing, but seems ugly enough to suggest a standard way to do it in line with other lwIP features like the packing and the like.

> Being like that, I'm reluctant to add a 2nd method to do the same thing.


The "first" method does not work with standard pools... You can't define the macro for them.

>> I need to be able to apply the attributes to existing standard pools, that are considered private...



> Could you please provide an example of which pool you try to move? I think we need to have an example instead of staying too general in this discussion.


All the ones defined in src/include/lwip/priv/memp_std.h:

Which src/include/lwip/memp.h declares (for no MEMP_MEM_MALLOC) as:

#else /* MEMP_MEM_MALLOC */

#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
    [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; \
    \
  static struct memp *memp_tab_ ## name; \
    \
  const struct memp_desc memp_ ## name = { \
    LWIP_MEM_ALIGN_SIZE(size), \
    (num), \
    DECLARE_LWIP_MEMPOOL_DESC(desc) \
    memp_memory_ ## name ## _base, \
    &memp_tab_ ## name \
  };

Note that the declaration of the pool memory is the first line:
u8_t memp_memory_ ## name ## _base \
    [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; \

Which does not allow for any attribute or the like, and cannot be circunvented inside src/core/memp.c unless we inject an include file with the right extern declaration to all lwip files when building, as I show at the end of the original submission message.

Sure it can be made to work, but a standard way would be better... If you see it as a good thing, of course.


>> Similarly for ram_heap


> Using GCC, add this line to your lwipopts.h:
> extern unsigned char attribute((section(".onchip_mem"))) ram_heap[];


Sure, it is what I'm doing at the moment, but again, I respectfully suggest that having a standard way through configuration options would be better.




Anyway,  do it as you see fit. Just let me know if anything is still not clear.

David Fernandez <david0fc>
Thu 18 Feb 2016 06:27:05 PM UTC, comment #5: 

David, you're not the first wanting to put the pools into a different section. So far, everyone seems to have succeeded with what we provide (unless the recent memp changes have broken this).

Being like that, I'm reluctant to add a 2nd method to do the same thing.

> I need to be able to apply the attributes to existing standard pools, that are considered private...


Could you please provide an example of which pool you try to move? I think we need to have an example instead of staying too general in this discussion.

> Similarly for ram_heap


Using GCC, add this line to your lwipopts.h:
extern unsigned char attribute((section(".onchip_mem"))) ram_heap[];

Simon Goldschmidt <goldsimon>
Group administrator
Wed 17 Feb 2016 12:08:46 PM UTC, comment #4: 

In response to your comment #2:


Something like LWIP_MEMPOOL_ATTRIBUTES in memp.h (and mem.c for ram_heap) would suffice.

> Did you see there is an explanation how to do it for GCC in memp.h?


> "To relocate a pool, declare it as extern in cc.h. Example for GCC: extern u8_t attribute((section(".onchip_mem"))) memp_memory_my_private_pool[];"


That is fine for privete pools, but not that good for standard pools, that are "private" to lwIP users.

David Fernandez <david0fc>
Wed 17 Feb 2016 12:02:05 PM UTC, comment #3: 

Sorrr fro the late reply, Google decided to put this in the spam folder.

In response to comment #1:

> Is a #define like this:
>
> #define LWIP_MEMPOOL_DECLARE(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
> [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] LWIP_MEMPOOL_ATTRIBUTES; \
>
> sufficient for your needs?


I need to be able to apply the attributes to existing standard pools, that are considered private... I think what you offer works only for new additional pools.

As you can see, I'm doing a bit of a trick in memp_extra.h (see the end of the "original submission"), passing -includememp_extra.h as a gcc option when compiling lwIP, to achieve that, but lwIP should provide a proper way to do that.

Similarly for ram_heap.

Not sure what is not clear from my comments. All I'm asking is to have a mechanism, simila to the macros PACK_STRUCT_BEGIN/END to apply attributes about sections to things like memp_memory_xxx and ram_heap.

David Fernandez <david0fc>
Tue 09 Feb 2016 02:00:39 PM UTC, comment #2: 

Just to clarify: We do understand that you want to be able to put memory into different sections. We just do not clearly understand which changes you need to be done for this, e.g. is something like LWIP_MEMPOOL_ATTRIBUTES in memp.h sufficient for you, or do you need more changes to be portable to your system?

If you provide a patch, it would clarify your requirements.

Did you see there is an explanation how to do it for GCC in memp.h?

"To relocate a pool, declare it as extern in cc.h. Example for GCC: extern u8_t _attribute_((section(".onchip_mem"))) memp_memory_my_private_pool[];"

Dirk

Dirk Ziegelmeier <dziegel>
Group administrator
Tue 09 Feb 2016 11:44:01 AM UTC, comment #1: 

Simon and I have problems to understand what you really require.

Is a #define like this:

#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
    [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))] LWIP_MEMPOOL_ATTRIBUTES; \

sufficient for your needs?

Alternatively, can you provide a patch that performs the modifications you request?

Dirk (and Simon)

Dirk Ziegelmeier <dziegel>
Group administrator
Mon 08 Feb 2016 04:23:25 PM UTC, original submission:  

In a similar way as it is done for alignment, sometimes, build systems and platforms have to, or would benefit from, putting memory pools and heaps in a special section.

So what is requested here is to have a configuration option to specify attributes for those definitions and/or declarations, or specific configuration options to specify a section, and also an oveeride of a weak symbol e.g. _asm_("<symbol-to-override>").

Despit this might seem not that necessary for ram_heap, it is when you consider than LWIP_RAW_HEAP_POINTER won't have easy access to MEM_SIZE definition if you don't want to modify the lwIP codebase.

Currently I do this in cc.h:

+/* Rather than using LWIP_RAW_HEAP_POINTER, force the default lwIP heap to go
+ * into our .extra section and override our default __heap_start.
+ * That will provide the configured heap size to be taken into account for the
+ sizewatch.pl script in our build system. /
+#include <mc/mem_layout.h>
+extern u8_t ram_heap[] _asm_("__heap_start") _attribute_((section(".heap")));
+

so that I could still use MEM_SIZE and the alignment options and macros as they are in mem.c

For the memory pools I have to resort to -include<special-hdr.h> for lwIP, with:

#ifndef MEMP_EXTRA_H
#define MEMP_EXTRA_H

/* Non orthodox way to put all pools in .extra section... as there is no

  • abstraction defined to tag them seamlessly. */


#include <mc/mem_layout.h>

#include "lwip/opt.h"
#include "lwip/memp.h"
#define LWIP_MEMPOOL_TOSECTION(name,num,size,desc)
extern u8_t memp_memory_ ## name ## _base[] EXTRA_DATA_SECTION("");
#define LWIP_MEMPOOL(name,num,size,desc)
LWIP_MEMPOOL_TOSECTION(name,num,size,desc)
#include "lwip/priv/memp_std.h"

#endif/*MEMP_EXTRA_H*/

which is not that good either.

As an example, ecOS has a tagging macro to define attributes for stack definitions... something similar could be done here.

David Fernandez <david0fc>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by dziegel (Posted a comment)
  • -email is unavailable- added by david0fc (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-07 dziegel StatusNone Fixed
        Open/ClosedOpen Closed
    2016-06-30 goldsimon Planned ReleaseNone 2.0.0 Beta2
    2016-06-27 goldsimon Planned Release 2.0.0 Beta2

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code