net: buf: Change NET_BUF_DEBUG to NET_BUF_LOG and add a level option
It will be thus possible to enable only the error logging, or the other sys_log levels. Change-Id: I0c0ed789f7cfbb4811320e8f8249151288274873 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
6158dfdda6
commit
0a1617365f
|
@ -526,7 +526,7 @@ struct net_buf_pool {
|
|||
*
|
||||
* @return New buffer or NULL if out of buffers.
|
||||
*/
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_alloc_debug(struct net_buf_pool *pool, int32_t timeout,
|
||||
const char *func, int line);
|
||||
#define net_buf_alloc(_pool, _timeout) \
|
||||
|
@ -548,7 +548,7 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, int32_t timeout);
|
|||
*
|
||||
* @return New buffer or NULL if the FIFO is empty.
|
||||
*/
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_get_debug(struct k_fifo *fifo, int32_t timeout,
|
||||
const char *func, int line);
|
||||
#define net_buf_get(_fifo, _timeout) \
|
||||
|
@ -602,7 +602,7 @@ void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
|
|||
*
|
||||
* @param buf A valid pointer on a buffer
|
||||
*/
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
|
||||
#define net_buf_unref(_buf) \
|
||||
net_buf_unref_debug(_buf, __func__, __LINE__)
|
||||
|
|
|
@ -33,8 +33,6 @@ CONFIG_NET_DEBUG_ICMPV6=y
|
|||
CONFIG_NET_DEBUG_CONN=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
|
||||
#CONFIG_NET_BUF_DEBUG=y
|
||||
|
||||
CONFIG_NET_L2_IEEE802154=y
|
||||
CONFIG_NET_DEBUG_L2_IEEE802154=y
|
||||
CONFIG_NET_L2_IEEE802154_ORFD=y
|
||||
|
|
|
@ -30,7 +30,6 @@ CONFIG_NET_DEBUG_IF=y
|
|||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
CONFIG_NET_DEBUG_CONN=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
#CONFIG_NET_BUF_DEBUG=y
|
||||
|
||||
CONFIG_NET_L2_IEEE802154=y
|
||||
CONFIG_NET_DEBUG_L2_IEEE802154=y
|
||||
|
|
|
@ -16,7 +16,6 @@ CONFIG_IP_BUF_TX_SIZE=4
|
|||
|
||||
#CONFIG_NETWORKING_WITH_LOGGING=y
|
||||
#CONFIG_NETWORK_IP_STACK_DEBUG_NET_BUF=y
|
||||
#CONFIG_NET_BUF_DEBUG=y
|
||||
#CONFIG_NETWORK_IP_STACK_DEBUG_CONTEXT=y
|
||||
#CONFIG_NETWORK_IP_STACK_DEBUG_TCP_PSOCK=y
|
||||
|
||||
|
|
|
@ -25,18 +25,33 @@ config NET_BUF
|
|||
This option enables support for generic network protocol
|
||||
buffers.
|
||||
|
||||
config NET_BUF_DEBUG
|
||||
bool "Network buffer debugging"
|
||||
config NET_BUF_LOG
|
||||
bool "Network buffer logging"
|
||||
depends on NET_BUF
|
||||
select STDOUT_CONSOLE
|
||||
select SYS_LOG
|
||||
default n
|
||||
help
|
||||
Enable debug logs and checks for the generic network buffers.
|
||||
Enable logs and checks for the generic network buffers.
|
||||
|
||||
config NET_BUF_SIMPLE_DEBUG
|
||||
config SYS_LOG_NET_BUF_LEVEL
|
||||
int
|
||||
prompt "Network buffer Logging level"
|
||||
depends on NET_BUF_LOG
|
||||
default 1
|
||||
range 0 4
|
||||
help
|
||||
Sets log level for network buffers.
|
||||
Levels are:
|
||||
0 OFF, do not write
|
||||
1 ERROR, only write SYS_LOG_ERR
|
||||
2 WARNING, write SYS_LOG_WRN in adition to previous level
|
||||
3 INFO, write SYS_LOG_INF in adition to previous levels
|
||||
4 DEBUG, write SYS_LOG_DBG in adition to previous levels
|
||||
|
||||
config NET_BUF_SIMPLE_LOG
|
||||
bool "Network buffer memory debugging"
|
||||
depends on NET_BUF_DEBUG
|
||||
depends on NET_BUF_LOG
|
||||
select STDOUT_CONSOLE
|
||||
select SYS_LOG
|
||||
default n
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
#include <net/buf.h>
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
#define SYS_LOG_DOMAIN "net/buf"
|
||||
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
|
||||
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_NET_BUF_LEVEL
|
||||
#include <logging/sys_log.h>
|
||||
|
||||
#define NET_BUF_DBG(fmt, ...) SYS_LOG_DBG("(%p) " fmt, k_current_get(), \
|
||||
|
@ -44,7 +44,7 @@
|
|||
#define NET_BUF_WARN(fmt, ...)
|
||||
#define NET_BUF_INFO(fmt, ...)
|
||||
#define NET_BUF_ASSERT(cond)
|
||||
#endif /* CONFIG_NET_BUF_DEBUG */
|
||||
#endif /* CONFIG_NET_BUF_LOG */
|
||||
|
||||
/* Helpers to access the storage array, since we don't have access to its
|
||||
* type at this point anymore.
|
||||
|
@ -68,7 +68,7 @@ static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
|
|||
return buf;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_alloc_debug(struct net_buf_pool *pool, int32_t timeout,
|
||||
const char *func, int line)
|
||||
#else
|
||||
|
@ -114,7 +114,7 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, int32_t timeout)
|
|||
|
||||
irq_unlock(key);
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG) && SYS_LOG_LEVEL >= SYS_LOG_LEVEL_WARNING
|
||||
if (timeout == K_FOREVER) {
|
||||
buf = k_lifo_get(&pool->free, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
|
@ -145,7 +145,7 @@ success:
|
|||
return buf;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_get_debug(struct k_fifo *fifo, int32_t timeout,
|
||||
const char *func, int line)
|
||||
#else
|
||||
|
@ -202,7 +202,7 @@ void net_buf_put(struct k_fifo *fifo, struct net_buf *buf)
|
|||
k_fifo_put_list(fifo, buf, tail);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line)
|
||||
#else
|
||||
void net_buf_unref(struct net_buf *buf)
|
||||
|
@ -213,7 +213,7 @@ void net_buf_unref(struct net_buf *buf)
|
|||
while (buf) {
|
||||
struct net_buf *frags = buf->frags;
|
||||
|
||||
#if defined(CONFIG_NET_BUF_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
if (!buf->ref) {
|
||||
NET_BUF_ERR("%s():%d: buf %p double free", func, line,
|
||||
buf);
|
||||
|
@ -324,7 +324,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
|
|||
return next_frag;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_BUF_SIMPLE_DEBUG)
|
||||
#if defined(CONFIG_NET_BUF_SIMPLE_LOG)
|
||||
#define NET_BUF_SIMPLE_DBG(fmt, ...) NET_BUF_DBG(fmt, ##__VA_ARGS__)
|
||||
#define NET_BUF_SIMPLE_ERR(fmt, ...) NET_BUF_ERR(fmt, ##__VA_ARGS__)
|
||||
#define NET_BUF_SIMPLE_WARN(fmt, ...) NET_BUF_WARN(fmt, ##__VA_ARGS__)
|
||||
|
@ -336,7 +336,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
|
|||
#define NET_BUF_SIMPLE_WARN(fmt, ...)
|
||||
#define NET_BUF_SIMPLE_INFO(fmt, ...)
|
||||
#define NET_BUF_SIMPLE_ASSERT(cond)
|
||||
#endif /* CONFIG_NET_BUF_SIMPLE_DEBUG */
|
||||
#endif /* CONFIG_NET_BUF_SIMPLE_LOG */
|
||||
|
||||
void *net_buf_simple_add(struct net_buf_simple *buf, size_t len)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,6 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_CORE=y
|
||||
CONFIG_NET_6LO_DEBUG=n
|
||||
CONFIG_NET_BUF_DEBUG=n
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
|
||||
CONFIG_NET_6LO_CONTEXT=y
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
CONFIG_NET_BUF=y
|
||||
#CONFIG_NET_BUF_DEBUG=y
|
||||
#CONFIG_NET_BUF_LOG=y
|
||||
#CONFIG_SYS_LOG_NET_BUF_LEVEL=4
|
||||
CONFIG_ZTEST=y
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_BUF=y
|
||||
#CONFIG_NET_BUF_DEBUG=y
|
||||
#CONFIG_NET_BUF_LOG=y
|
||||
#CONFIG_SYS_LOG_NET_BUF_LEVEL=4
|
||||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
|
|
Loading…
Reference in a new issue