lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Question regarding recent change for bug #3031/task #78


From: Axel Lin
Subject: Re: [lwip-devel] Question regarding recent change for bug #3031/task #7896
Date: Wed, 24 May 2017 15:28:21 +0800

2017-05-24 14:34 GMT+08:00 Simon Goldschmidt <address@hidden>:
> Axel Lin wrote:
>> I have below changes for my device.
>> i.e. a dedicated pbuf pool for tx.
>>
>> I add PBUF_POOL_TX in pbuf_type:
>> PBUF_POOL = (PBUF_ALLOC_FLAG_RX | PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS | 
>> PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL),
>> PBUF_POOL_TX = (PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS | 
>> PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL)
>
> Maybe the documentation on the flags isn't clear enough, but this change 
> should explicitly help to cleanly solve
> situations like yours: Your new pool type should use a new SRC_MASK (i.e. not 
> PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL
> but one of 
> [PBUF_TYPE_ALLOC_SRC_MASK_APP_MIN..PBUF_TYPE_ALLOC_SRC_MASK_APP_MAX]).
ok

>
> As the documentation says, PBUF_ALLOC_FLAG_RX is used as a marker to 
> implement different levels for TX and RX on the same pool!
I misunderstood the meaning of PBUF_ALLOC_FLAG_RX.

>
> However, pbuf_free does indeed not yet support freeing such pbufs, I'll have 
> to implement that soon.
>
> How do you allocate your new pbuf anyway? Have you changed pbuf_alloc() for 
> that?

In my previous code, the PBUF_POOL_TX is the same as PBUF_POOL. It's
just a separate pool.

So in pbuf_alloc():

  case PBUF_POOL:
  case PBUF_POOL_TX:
 {
 .....
        if ( type == PBUF_POOL_TX ) {
          q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL_TX);
        } else {
          q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL);
        }

in pbuf_free():

        if (type == PBUF_POOL_TX) {
          memp_free(MEMP_PBUF_POOL_TX, p);
        } else if( type == PBUF_POOL) {
            memp_free(MEMP_PBUF_POOL, p);
        }

Thanks,
Axel



reply via email to

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