[ 
https://issues.apache.org/jira/browse/MYNEWT-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15658683#comment-15658683
 ] 

William San Filippo commented on MYNEWT-336:
--------------------------------------------

Changes have been made so that smaller mbufs can be defined. However, there is 
still a fair amount of work that needs to be done in regards to mbufs, msys and 
how the nimble stack uses mbufs. Here are the current limitations:

1) The controller sill uses msys to get certain mbufs. For LL control PDUs and 
advertising PDUs, an mbuf must still be large enough to hold a maximum 
contiguous packet. The largest of these packets are advertising channel PDUs, 
which can be a maximum of 37 bytes in length. NOTE: these PDU's do not contain 
the LL PDU header of 2 bytes. The LL PDU header is not placed in the data 
portion of the mbuf. Thus, msys should not be allowed to have a pool that is 
less than 37 bytes plus the BLE overhead of 32 bytes (or 69 bytes).

2) Currently, the kernel/os package defines the pools and pool sizes for msys 
mbufs. Only one pool of one size is currently defined. The size of the elements 
in this pool can be overridden in an app, bsp or target, so if smaller mbufs 
are desired the syscfg value MSYS_1_BLOCK_SIZE should be overridden. Again, 
this value should not be less than 69.

3) The controller using msys for mbufs is probably not a good idea all things 
considered. Either we need to modify the code to not use msys or we need to add 
a msys routine that will guarantee an mbuf of minimum size X.  For now, just 
make sure you dont add any mbuf pools to msys that are smaller than the minimum 
size mentioned above.

4) The blehci project uses a separate pool for ACL data packets. These are 
packets sent from a host to the controller over the HCI interface. The size of 
these mbufs can be modified by changing the syscfg value BLE_LL_ACL_PKT_SIZE. 
This is currently defined to be 256 and is in net/nimble/controller/syscfg.yml. 
This value can also be overridden in the app, bsp or target.

5) The controller in the blehci project still allocates mbufs from the msys 
pool so the caveats mentioned above apply. I just wanted to point out that 
there was a separate syscfg value that can be modified to decrease the amount 
of memory used by the blehci project. There is also a count of mbufs called 
BLE_LL_ACL_PKT_COUNT. Depending on the application, these values can be 
modified to save quite a bit of memory and/or increase the ACL data buffers 
available to the host.

> Allow smaller mbufs for data frames
> -----------------------------------
>
>                 Key: MYNEWT-336
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-336
>             Project: Mynewt
>          Issue Type: Improvement
>          Components: Nimble
>            Reporter: Christopher Collins
>            Assignee: William San Filippo
>             Fix For: v1_1_beta1
>
>
> When the host sends a data packet, it fills an mbuf with the payload and 
> passes it to the controller.
> The controller expects the mbuf to consist of a single contiguous buffer.  To 
> support this requirement, a nimble application needs to allocate large mbufs 
> (>= 260 bytes) to permit large data packets to be sent.  This is wasteful 
> because many data frames are likely quite a bit smaller than this.  
> Reliability would improve if an application could allocate more, smaller, 
> mbufs.
> The fix is for the controller to accept mbufs that consist of several chained 
> buffers.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to