net: Elaborate output of net_nbuf_print_frags() to be more useful.
Following changes are made: 1. Output using NET_INFO logging level. This function is not part of automatic logging, and must be called explicitly by a user application. But if it outputs using NET_DEBUG, then DEBUG level needs to be enabled, and the output of this function will be drowned in logging spam. So, let user to enable just INFO level. 2. Show entire structure of the fragment chain, *including* the head net_buf which holds net_nbuf structure. It is numbered as -1 in the output to preserve existing order (and not change existing size calculations). 3. Show owning pool (and its properties, like buffer size/user_data size) for each buffer. 4. Check for NULL pointer, e.g. for convenience of calling directly from net_context receive callback (which will be called with NULL on TCP peer closed connection event). With these changes, a newcomer from one look at the output of this function will be able to have a clear basic picture of network buffer management in Zephyr, and recurring user will be able to recall any details at once. Change-Id: I8f9562748329d749f765cc6af7989a448256d7e0 Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
2a00f418f0
commit
a745832dc4
|
@ -300,13 +300,18 @@ void net_nbuf_print_frags(struct net_buf *buf)
|
|||
{
|
||||
struct net_buf *frag;
|
||||
size_t total = 0;
|
||||
int count = 0, frag_size = 0, ll_overhead = 0;
|
||||
int count = -1, frag_size = 0, ll_overhead = 0;
|
||||
|
||||
NET_DBG("Buf %p frags %p", buf, buf->frags);
|
||||
if (!buf) {
|
||||
NET_INFO("Buf %p", buf);
|
||||
return;
|
||||
}
|
||||
|
||||
NET_INFO("Buf %p frags %p", buf, buf->frags);
|
||||
|
||||
NET_ASSERT(buf->frags);
|
||||
|
||||
frag = buf->frags;
|
||||
frag = buf;
|
||||
|
||||
while (frag) {
|
||||
total += frag->len;
|
||||
|
@ -314,15 +319,18 @@ void net_nbuf_print_frags(struct net_buf *buf)
|
|||
frag_size = frag->size;
|
||||
ll_overhead = net_buf_headroom(frag);
|
||||
|
||||
NET_DBG("[%d] frag %p len %d size %d reserve %d",
|
||||
count, frag, frag->len, frag_size, ll_overhead);
|
||||
NET_INFO("[%d] frag %p len %d size %d reserve %d "
|
||||
"pool %p [sz %d ud_sz %d]",
|
||||
count, frag, frag->len, frag_size, ll_overhead,
|
||||
frag->pool, frag->pool->buf_size,
|
||||
frag->pool->user_data_size);
|
||||
|
||||
count++;
|
||||
|
||||
frag = frag->frags;
|
||||
}
|
||||
|
||||
NET_DBG("Total data size %zu, occupied %d bytes, ll overhead %d, "
|
||||
NET_INFO("Total data size %zu, occupied %d bytes, ll overhead %d, "
|
||||
"utilization %zu%%",
|
||||
total, count * frag_size - count * ll_overhead,
|
||||
count * ll_overhead, (total * 100) / (count * frag_size));
|
||||
|
|
Loading…
Reference in a new issue