From ccf713c5adc6be059c66b585050f5905667e7ad6 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 19 Jun 2019 14:50:31 +0200 Subject: [PATCH] drivers/cc1xxx_common: L2 netstats & cleanups - Added required logic to provide correct L2 netstats when the module netstats_l2 is used. - Refactored code to use gnrc_netif_hdr_set_netif() over manually setting the pid to ease future refactoring. --- drivers/cc1xxx_common/gnrc_netif_cc1xxx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/cc1xxx_common/gnrc_netif_cc1xxx.c b/drivers/cc1xxx_common/gnrc_netif_cc1xxx.c index 2c55bc11b6..0c4498427e 100644 --- a/drivers/cc1xxx_common/gnrc_netif_cc1xxx.c +++ b/drivers/cc1xxx_common/gnrc_netif_cc1xxx.c @@ -86,7 +86,7 @@ static gnrc_pktsnip_t *cc1xxx_adpt_recv(gnrc_netif_t *netif) return NULL; } netif_hdr = (gnrc_netif_hdr_t *)hdr->data; - netif_hdr->if_pid = netif->pid; + gnrc_netif_hdr_set_netif(netif_hdr, netif); netif_hdr->rssi = rx_info.rssi; netif_hdr->lqi = rx_info.lqi; if (l2hdr.dest_addr == CC1XXX_BCAST_ADDR) { @@ -98,6 +98,11 @@ static gnrc_pktsnip_t *cc1xxx_adpt_recv(gnrc_netif_t *netif) /* and append the netif header */ LL_APPEND(payload, hdr); +#ifdef MODULE_NETSTATS_L2 + netif->stats.rx_count++; + netif->stats.rx_bytes += pktlen; +#endif + return payload; } @@ -122,6 +127,9 @@ static int cc1xxx_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) if (netif_hdr->flags & BCAST) { l2hdr.dest_addr = CC1XXX_BCAST_ADDR; DEBUG("[cc1xxx-gnrc] send: preparing to send broadcast\n"); +#ifdef MODULE_NETSTATS_L2 + netif->stats.tx_mcast_count++; +#endif } else { /* check that destination address is valid */ @@ -130,6 +138,9 @@ static int cc1xxx_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) l2hdr.dest_addr = addr[0]; DEBUG("[cc1xxx-gnrc] send: preparing to send unicast %02x --> %02x\n", (int)l2hdr.src_addr, (int)l2hdr.dest_addr); +#ifdef MODULE_NETSTATS_L2 + netif->stats.tx_unicast_count++; +#endif } /* now let's send out the stuff */