Commit ced80b13 authored by Henrik Brix Andersen's avatar Henrik Brix Andersen Committed by Mahesh Mahadevan
Browse files

lib: net_buf: move the network buffer implementation to lib



Move the net_buf implementation from the networking subsystem to a library
as they have no dependency on the networking subsystem.

Network buffers are used in subsystems outside of networking
(e.g. Bluetooth, USB).

Fixes: #36374

Signed-off-by: default avatarHenrik Brix Andersen <henrik@brixandersen.dk>
parent cfc010ff
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2803,7 +2803,6 @@ Networking:
    - samples/net/lwm2m_client/
    - samples/net/wifi/
    - samples/net/dhcpv4_client/
    - subsys/net/buf*.c
    - subsys/net/l2/ethernet/gptp/
    - subsys/net/l2/ieee802154/
    - subsys/net/l2/wifi/
@@ -2846,7 +2845,7 @@ Networking:
    - jukkar
  files:
    - include/zephyr/net/buf.h
    - subsys/net/buf*.c
    - lib/net_buf/
    - tests/net/buf/
  labels:
    - "area: Networking Buffers"
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ add_subdirectory_ifdef(CONFIG_CPP cpp)
add_subdirectory(hash)
add_subdirectory(heap)
add_subdirectory(mem_blocks)
add_subdirectory_ifdef(CONFIG_NET_BUF net_buf)
add_subdirectory(os)
add_subdirectory(utils)
add_subdirectory_ifdef(CONFIG_SMF smf)
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ source "lib/heap/Kconfig"

source "lib/mem_blocks/Kconfig"

source "lib/net_buf/Kconfig"

source "lib/os/Kconfig"

source "lib/posix/Kconfig"
+8 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources_ifdef(
  CONFIG_NET_BUF
  buf.c
  buf_simple.c
  )

lib/net_buf/Kconfig

0 → 100644
+62 −0
Original line number Diff line number Diff line
# Network buffer configuration options

# Copyright (c) 2015 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

menuconfig NET_BUF
	bool "Network buffer support"
	help
	  This option enables support for generic network protocol
	  buffers.

if NET_BUF

config NET_BUF_LOG
	bool "Network buffer logging"
	select LOG
	help
	  Enable logs and checks for the generic network buffers.

module = NET_BUF
module-str = net_buf
source "subsys/logging/Kconfig.template.log_config"

if NET_BUF_LOG

config NET_BUF_WARN_ALLOC_INTERVAL
	int "Interval of Network buffer allocation warnings"
	default 1
	range 0 60
	help
	  Interval in seconds of Network buffer allocation warnings which are
	  generated when a buffer cannot immediately be allocated with K_FOREVER
	  which may lead to deadlocks. Setting it to 0 makes warnings to be
	  printed only once per allocation.

config NET_BUF_SIMPLE_LOG
	bool "Network buffer memory debugging"
	select LOG
	help
	  Enable extra debug logs and checks for the generic network buffers.

endif # NET_BUF_LOG

config NET_BUF_POOL_USAGE
	bool "Network buffer pool usage tracking"
	help
	  Enable network buffer pool tracking. This means that:
	  * amount of free buffers in the pool is remembered
	  * total size of the pool is calculated
	  * pool name is stored and can be shown in debugging prints

config NET_BUF_ALIGNMENT
	int "Network buffer alignment restriction"
	default 0
	help
	  Alignment restriction for network buffers. This is useful for
	  some hardware IP with DMA that requires the buffers to be aligned
	  to a certain byte boundary, or dealing with cache line restrictions.
	  Default value of 0 means the alignment will be the size of a void pointer,
	  any other value will force the alignment of a net buffer in bytes.

endif # NET_BUF
Loading