zbus: rework buffer allocation Kconfig options
Add a name for the Kconfig choice symbol indicating the Zbus subscriber buffer allocation and adjust the name of the existing choices. Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
This commit is contained in:
parent
407e9a4c74
commit
ce812c1b25
|
@ -158,6 +158,11 @@ Other Subsystems
|
|||
respective ``reset-gpios``. This has been fixed so those signals now have to
|
||||
be flagged as :c:macro:`GPIO_ACTIVE_LOW` in the devicetree. (:github:`64800`)
|
||||
|
||||
* The :kconfig:option:`ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC`
|
||||
and :kconfig:option:`ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC`
|
||||
zbus options are renamed. Instead, the new :kconfig:option:`ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC`
|
||||
and :kconfig:option:`ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC` options should be used.
|
||||
|
||||
Recommended Changes
|
||||
*******************
|
||||
|
||||
|
|
|
@ -272,6 +272,11 @@ Libraries / Subsystems
|
|||
|
||||
* ZBus
|
||||
|
||||
* Renamed :kconfig:option:`ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC` and
|
||||
:kconfig:option:`ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC`
|
||||
with :kconfig:option:`ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC` and
|
||||
:kconfig:option:`ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC`
|
||||
|
||||
HALs
|
||||
****
|
||||
|
||||
|
|
|
@ -823,9 +823,9 @@ Related configuration options:
|
|||
* :kconfig:option:`CONFIG_ZBUS_OBSERVER_NAME` enables the name of observers to be available inside
|
||||
the channels metadata;
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER` enables the message subscriber observer type;
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC` uses the heap to allocate message
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC` uses the heap to allocate message
|
||||
buffers;
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC` uses the stack to allocate message
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC` uses the stack to allocate message
|
||||
buffers;
|
||||
* :kconfig:option:`CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_SIZE` the available number of message
|
||||
buffers to be used simultaneously;
|
||||
|
|
|
@ -95,7 +95,7 @@ tests:
|
|||
harness: console
|
||||
extra_configs:
|
||||
- CONFIG_ZBUS_LOG_LEVEL_DBG=y
|
||||
- CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC=y
|
||||
- CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC=y
|
||||
- CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC_DATA_SIZE=16
|
||||
harness_config:
|
||||
type: multi_line
|
||||
|
|
|
@ -26,14 +26,14 @@ void on_heap_free(uintptr_t heap_id, void *mem, size_t bytes)
|
|||
(unsigned int)total_allocated);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC)
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC)
|
||||
|
||||
HEAP_LISTENER_ALLOC_DEFINE(my_heap_listener_alloc, HEAP_ID_FROM_POINTER(&_system_heap),
|
||||
on_heap_alloc);
|
||||
|
||||
HEAP_LISTENER_FREE_DEFINE(my_heap_listener_free, HEAP_ID_FROM_POINTER(&_system_heap), on_heap_free);
|
||||
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC */
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC */
|
||||
struct acc_msg {
|
||||
int x;
|
||||
int y;
|
||||
|
@ -173,12 +173,12 @@ int main(void)
|
|||
|
||||
total_allocated = 0;
|
||||
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC)
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC)
|
||||
|
||||
heap_listener_register(&my_heap_listener_alloc);
|
||||
heap_listener_register(&my_heap_listener_free);
|
||||
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC */
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC */
|
||||
|
||||
while (1) {
|
||||
LOG_INF("----> Publishing to %s channel", zbus_chan_name(&acc_data_chan));
|
||||
|
|
|
@ -25,13 +25,14 @@ config ZBUS_MSG_SUBSCRIBER
|
|||
|
||||
if ZBUS_MSG_SUBSCRIBER
|
||||
|
||||
choice
|
||||
choice ZBUS_MSG_SUBSCRIBER_BUF_ALLOC
|
||||
prompt "ZBus msg_subscribers buffer allocation"
|
||||
default ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC
|
||||
|
||||
config ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC
|
||||
config ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC
|
||||
bool "Use heap to allocate msg_subscriber buffers data"
|
||||
|
||||
config ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC
|
||||
config ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC
|
||||
bool "Use fixed data size for msg_subscriber buffers pool"
|
||||
|
||||
endchoice
|
||||
|
@ -40,12 +41,12 @@ config ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_SIZE
|
|||
default 16
|
||||
int "The count of net_buf available to be used simutaneously."
|
||||
|
||||
if ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC
|
||||
if ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC
|
||||
|
||||
config ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC_DATA_SIZE
|
||||
int "The size of the biggest message used with ZBus."
|
||||
|
||||
endif # ZBUS_MSG_SUBSCRIBER_NET_BUF_STATIC
|
||||
endif # ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_STATIC
|
||||
|
||||
endif # ZBUS_MSG_SUBSCRIBER
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(zbus, CONFIG_ZBUS_LOG_LEVEL);
|
|||
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER)
|
||||
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC)
|
||||
#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC)
|
||||
|
||||
NET_BUF_POOL_HEAP_DEFINE(_zbus_msg_subscribers_pool, CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_SIZE,
|
||||
sizeof(struct zbus_channel *), NULL);
|
||||
|
@ -42,7 +42,7 @@ static inline struct net_buf *_zbus_create_net_buf(struct net_buf_pool *pool, si
|
|||
(int)size);
|
||||
return net_buf_alloc(&_zbus_msg_subscribers_pool, timeout);
|
||||
}
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_DYNAMIC */
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER_BUF_ALLOC_DYNAMIC */
|
||||
|
||||
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER */
|
||||
|
||||
|
|
Loading…
Reference in a new issue