net: buf: POOL_VAR_DEFINE explicit user data

Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2021-11-21 11:58:30 +10:00 committed by Johan Hedberg
commit 8236b600f7
5 changed files with 17 additions and 17 deletions

View file

@ -1178,10 +1178,11 @@ extern const struct net_buf_data_cb net_buf_var_cb;
* @param _name Name of the pool variable. * @param _name Name of the pool variable.
* @param _count Number of buffers in the pool. * @param _count Number of buffers in the pool.
* @param _data_size Total amount of memory available for data payloads. * @param _data_size Total amount of memory available for data payloads.
* @param _ud_size User data space to reserve per buffer.
* @param _destroy Optional destroy callback when buffer is freed. * @param _destroy Optional destroy callback when buffer is freed.
*/ */
#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _destroy) \ #define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
_NET_BUF_ARRAY_DEFINE(_name, _count, CONFIG_NET_BUF_USER_DATA_SIZE); \ _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \ K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \ static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
.cb = &net_buf_var_cb, \ .cb = &net_buf_var_cb, \
@ -1190,8 +1191,7 @@ extern const struct net_buf_data_cb net_buf_var_cb;
static struct net_buf_pool _name __net_buf_align \ static struct net_buf_pool _name __net_buf_align \
__in_section(_net_buf_pool, static, _name) = \ __in_section(_net_buf_pool, static, _name) = \
NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \ NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
_net_buf_##_name, _count, \ _net_buf_##_name, _count, _ud_size, \
CONFIG_NET_BUF_USER_DATA_SIZE, \
_destroy) _destroy)
/** /**

View file

@ -36,7 +36,7 @@ static struct isotp_global_ctx global_ctx = {
#ifdef CONFIG_ISOTP_USE_TX_BUF #ifdef CONFIG_ISOTP_USE_TX_BUF
NET_BUF_POOL_VAR_DEFINE(isotp_tx_pool, CONFIG_ISOTP_TX_BUF_COUNT, NET_BUF_POOL_VAR_DEFINE(isotp_tx_pool, CONFIG_ISOTP_TX_BUF_COUNT,
CONFIG_ISOTP_BUF_TX_DATA_POOL_SIZE, NULL); CONFIG_ISOTP_BUF_TX_DATA_POOL_SIZE, 0, NULL);
#endif #endif
static void receive_state_machine(struct isotp_recv_ctx *ctx); static void receive_state_machine(struct isotp_recv_ctx *ctx);

View file

@ -126,9 +126,9 @@ NET_BUF_POOL_FIXED_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT,
#else /* !CONFIG_NET_BUF_FIXED_DATA_SIZE */ #else /* !CONFIG_NET_BUF_FIXED_DATA_SIZE */
NET_BUF_POOL_VAR_DEFINE(rx_bufs, CONFIG_NET_BUF_RX_COUNT, NET_BUF_POOL_VAR_DEFINE(rx_bufs, CONFIG_NET_BUF_RX_COUNT,
CONFIG_NET_BUF_DATA_POOL_SIZE, NULL); CONFIG_NET_BUF_DATA_POOL_SIZE, 4, NULL);
NET_BUF_POOL_VAR_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT, NET_BUF_POOL_VAR_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT,
CONFIG_NET_BUF_DATA_POOL_SIZE, NULL); CONFIG_NET_BUF_DATA_POOL_SIZE, 4, NULL);
#endif /* CONFIG_NET_BUF_FIXED_DATA_SIZE */ #endif /* CONFIG_NET_BUF_FIXED_DATA_SIZE */

View file

@ -45,7 +45,7 @@ NET_BUF_POOL_FIXED_DEFINE(capture_bufs, CONFIG_NET_CAPTURE_BUF_COUNT,
CONFIG_NET_BUF_DATA_SIZE, NULL); CONFIG_NET_BUF_DATA_SIZE, NULL);
#else #else
NET_BUF_POOL_VAR_DEFINE(capture_bufs, CONFIG_NET_CAPTURE_BUF_COUNT, NET_BUF_POOL_VAR_DEFINE(capture_bufs, CONFIG_NET_CAPTURE_BUF_COUNT,
CONFIG_NET_BUF_DATA_POOL_SIZE, NULL); CONFIG_NET_BUF_DATA_POOL_SIZE, 4, NULL);
#endif #endif
static sys_slist_t net_capture_devlist; static sys_slist_t net_capture_devlist;

View file

@ -65,7 +65,7 @@ static void var_destroy(struct net_buf *buf);
NET_BUF_POOL_HEAP_DEFINE(bufs_pool, 10, buf_destroy); NET_BUF_POOL_HEAP_DEFINE(bufs_pool, 10, buf_destroy);
NET_BUF_POOL_FIXED_DEFINE(fixed_pool, 10, 128, fixed_destroy); NET_BUF_POOL_FIXED_DEFINE(fixed_pool, 10, 128, fixed_destroy);
NET_BUF_POOL_VAR_DEFINE(var_pool, 10, 1024, var_destroy); NET_BUF_POOL_VAR_DEFINE(var_pool, 10, 1024, 0, var_destroy);
static void buf_destroy(struct net_buf *buf) static void buf_destroy(struct net_buf *buf)
{ {