mm/iob: add iob_init method to support external buffer init as iob structure
Build Documentation / build-html (push) Has been cancelled

This interface allows different protocol modules to use their own unique IOB
buffer sources and allocation strategies without interfering with each other.
Representative examples are the IP protocol and the CAN protocol. The IP
protocol generally transmits packets of varying lengths and requires
relatively high peak throughput. In this case, to ensure higher performance,
IOB_BUFSIZE is often configured to be relatively large, such as greater than
500. The CAN protocol generally transmits short packets of fixed length.
In this case, to improve memory utilization, IOB_BUFSIZE is often configured
to be relatively small, such as 16 or 64. To optimize the memory utilization
when the IP protocol and the CAN protocol share the same core,
this interface was added.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-04-15 22:32:24 +08:00
committed by Donny(董九柱)
parent c5bb75441c
commit 6ad864ff0c
4 changed files with 89 additions and 3 deletions
+27
View File
@@ -266,6 +266,33 @@ FAR struct iob_s *iob_alloc_dynamic(uint16_t size);
FAR struct iob_s *iob_alloc_with_data(FAR void *data, uint16_t size,
iob_free_cb_t free_cb);
/****************************************************************************
* Name: iob_init_with_data
*
* Description:
* Initialize an I/O buffer and playload
*
* Input Parameters:
* data - Make io_data point to a specific address, the caller is
* responsible for the memory management. The caller should
* ensure that the memory is not freed before the iob is freed,
* and caller need to reserve space for alignment.
* size - The size of the data parameter
* free_cb - Notify the caller when the iob is freed. The caller can
* perform additional operations on the data before it is freed.
*
* +---------+
* | IOB |
* | io_data |--+
* | buffer |<-+
* +---------+
*
****************************************************************************/
FAR struct iob_s *iob_init_with_data(FAR void *data, uint16_t size,
iob_free_cb_t free_cb);
#endif
/****************************************************************************