net: tracing: Add net_send_data function tracing
Trace when a network packet is sent. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
ea2ff40558
commit
4911a4f8de
8 changed files with 115 additions and 6 deletions
|
|
@ -2049,6 +2049,19 @@
|
|||
*/
|
||||
#define sys_port_trace_net_recv_data_exit(iface, pkt, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace network data send
|
||||
* @param pkt Network packet to send
|
||||
*/
|
||||
#define sys_port_trace_net_send_data_enter(pkt)
|
||||
|
||||
/**
|
||||
* @brief Trace network data send attempt
|
||||
* @param pkt Received network packet
|
||||
* @param ret Return value
|
||||
*/
|
||||
#define sys_port_trace_net_send_data_exit(pkt, ret)
|
||||
|
||||
/** @} */ /* end of subsys_tracing_apis_net */
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -380,13 +380,18 @@ drop:
|
|||
int net_send_data(struct net_pkt *pkt)
|
||||
{
|
||||
int status;
|
||||
int ret;
|
||||
|
||||
SYS_PORT_TRACING_FUNC_ENTER(net, send_data, pkt);
|
||||
|
||||
if (!pkt || !pkt->frags) {
|
||||
return -ENODATA;
|
||||
ret = -ENODATA;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!net_pkt_iface(pkt)) {
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
net_pkt_trim_buffer(pkt);
|
||||
|
|
@ -400,7 +405,8 @@ int net_send_data(struct net_pkt *pkt)
|
|||
* we just silently drop the packet by returning 0.
|
||||
*/
|
||||
if (status == -ENOMSG) {
|
||||
return 0;
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
@ -410,11 +416,13 @@ int net_send_data(struct net_pkt *pkt)
|
|||
*/
|
||||
NET_DBG("Loopback pkt %p back to us", pkt);
|
||||
processing_data(pkt, true);
|
||||
return 0;
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (net_if_send_data(net_pkt_iface(pkt), pkt) == NET_DROP) {
|
||||
return -EIO;
|
||||
ret = -EIO;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_STATISTICS)) {
|
||||
|
|
@ -428,7 +436,12 @@ int net_send_data(struct net_pkt *pkt)
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
|
||||
err:
|
||||
SYS_PORT_TRACING_FUNC_EXIT(net, send_data, pkt, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void net_rx(struct net_if *iface, struct net_pkt *pkt)
|
||||
|
|
|
|||
|
|
@ -654,3 +654,39 @@ void sys_trace_net_recv_data_exit(struct net_if *iface, struct net_pkt *pkt, int
|
|||
(uint32_t)(uintptr_t)pkt,
|
||||
(int32_t)ret);
|
||||
}
|
||||
|
||||
void sys_trace_net_send_data_enter(struct net_pkt *pkt)
|
||||
{
|
||||
struct net_if *iface;
|
||||
int ifindex;
|
||||
|
||||
iface = net_pkt_iface(pkt);
|
||||
if (iface == NULL) {
|
||||
ifindex = -1;
|
||||
} else {
|
||||
ifindex = net_if_get_by_iface(iface);
|
||||
}
|
||||
|
||||
ctf_top_net_send_data_enter((int32_t)ifindex,
|
||||
(uint32_t)(uintptr_t)iface,
|
||||
(uint32_t)(uintptr_t)pkt,
|
||||
(uint32_t)net_pkt_get_len(pkt));
|
||||
}
|
||||
|
||||
void sys_trace_net_send_data_exit(struct net_pkt *pkt, int ret)
|
||||
{
|
||||
struct net_if *iface;
|
||||
int ifindex;
|
||||
|
||||
iface = net_pkt_iface(pkt);
|
||||
if (iface == NULL) {
|
||||
ifindex = -1;
|
||||
} else {
|
||||
ifindex = net_if_get_by_iface(iface);
|
||||
}
|
||||
|
||||
ctf_top_net_send_data_exit((int32_t)ifindex,
|
||||
(uint32_t)(uintptr_t)iface,
|
||||
(uint32_t)(uintptr_t)pkt,
|
||||
(int32_t)ret);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,6 +153,8 @@ typedef enum {
|
|||
CTF_EVENT_SOCKET_SOCKETPAIR_EXIT = 0x5B,
|
||||
CTF_EVENT_NET_RECV_DATA_ENTER = 0x5C,
|
||||
CTF_EVENT_NET_RECV_DATA_EXIT = 0x5D,
|
||||
CTF_EVENT_NET_SEND_DATA_ENTER = 0x5E,
|
||||
CTF_EVENT_NET_SEND_DATA_EXIT = 0x5F,
|
||||
|
||||
} ctf_event_t;
|
||||
|
||||
|
|
@ -626,5 +628,18 @@ static inline void ctf_top_net_recv_data_exit(int32_t if_index, uint32_t iface,
|
|||
if_index, iface, pkt, ret);
|
||||
}
|
||||
|
||||
static inline void ctf_top_net_send_data_enter(int32_t if_index, uint32_t iface, uint32_t pkt,
|
||||
uint32_t len)
|
||||
{
|
||||
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_SEND_DATA_ENTER),
|
||||
if_index, iface, pkt, len);
|
||||
}
|
||||
|
||||
static inline void ctf_top_net_send_data_exit(int32_t if_index, uint32_t iface, uint32_t pkt,
|
||||
int32_t ret)
|
||||
{
|
||||
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_SEND_DATA_EXIT),
|
||||
if_index, iface, pkt, ret);
|
||||
}
|
||||
|
||||
#endif /* SUBSYS_DEBUG_TRACING_CTF_TOP_H */
|
||||
|
|
|
|||
|
|
@ -573,12 +573,18 @@ void sys_trace_socket_socketpair_exit(int sock_A, int sock_B, int ret);
|
|||
sys_trace_net_recv_data_enter(iface, pkt)
|
||||
#define sys_port_trace_net_recv_data_exit(iface, pkt, ret) \
|
||||
sys_trace_net_recv_data_exit(iface, pkt, ret)
|
||||
#define sys_port_trace_net_send_data_enter(pkt) \
|
||||
sys_trace_net_send_data_enter(pkt)
|
||||
#define sys_port_trace_net_send_data_exit(pkt, ret) \
|
||||
sys_trace_net_send_data_exit(pkt, ret)
|
||||
|
||||
struct net_if;
|
||||
struct net_pkt;
|
||||
|
||||
void sys_trace_net_recv_data_enter(struct net_if *iface, struct net_pkt *pkt);
|
||||
void sys_trace_net_recv_data_exit(struct net_if *iface, struct net_pkt *pkt, int ret);
|
||||
void sys_trace_net_send_data_enter(struct net_pkt *pkt);
|
||||
void sys_trace_net_send_data_exit(struct net_pkt *pkt, int ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -729,3 +729,25 @@ event {
|
|||
int32_t result;
|
||||
};
|
||||
};
|
||||
|
||||
event {
|
||||
name = net_send_data_enter;
|
||||
id = 0x5E;
|
||||
fields := struct {
|
||||
int32_t if_index;
|
||||
uint32_t iface;
|
||||
uint32_t pkt;
|
||||
uint32_t pkt_len;
|
||||
};
|
||||
};
|
||||
|
||||
event {
|
||||
name = net_send_data_exit;
|
||||
id = 0x5F;
|
||||
fields := struct {
|
||||
int32_t if_index;
|
||||
uint32_t iface;
|
||||
uint32_t pkt;
|
||||
int32_t result;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -734,6 +734,8 @@ void sys_trace_k_event_init(struct k_event *event);
|
|||
|
||||
#define sys_port_trace_net_recv_data_enter(iface, pkt)
|
||||
#define sys_port_trace_net_recv_data_exit(iface, pkt, ret)
|
||||
#define sys_port_trace_net_send_data_enter(pkt)
|
||||
#define sys_port_trace_net_send_data_exit(pkt, ret)
|
||||
|
||||
#define sys_trace_sys_init_enter(...)
|
||||
#define sys_trace_sys_init_exit(...)
|
||||
|
|
|
|||
|
|
@ -385,6 +385,8 @@ void sys_trace_sys_init_exit(const struct init_entry *entry, int level, int resu
|
|||
|
||||
#define sys_port_trace_net_recv_data_enter(iface, pkt)
|
||||
#define sys_port_trace_net_recv_data_exit(iface, pkt, ret)
|
||||
#define sys_port_trace_net_send_data_enter(pkt)
|
||||
#define sys_port_trace_net_send_data_exit(pkt, ret)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue