drivers encx24j600: introduce netstats

This driver was missing netstats completely so far.
This commit is contained in:
Oleg Hahm 2016-04-03 18:05:07 +02:00
parent 4ba73928ac
commit aa043a50bf

View File

@ -32,7 +32,7 @@
#include "net/netdev2/eth.h" #include "net/netdev2/eth.h"
#include "net/eui64.h" #include "net/eui64.h"
#include "net/ethernet.h" #include "net/ethernet.h"
//#include "net/ethernet/hdr.h" #include "net/netstats.h"
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
@ -298,6 +298,9 @@ static int _init(netdev2_t *encdev)
unlock(dev); unlock(dev);
#ifdef MODULE_NETSTATS_L2
memset(&netdev->stats, 0, sizeof(netstats_t));
#endif
return 0; return 0;
} }
@ -305,6 +308,10 @@ static int _send(netdev2_t *netdev, const struct iovec *vector, int count) {
encx24j600_t * dev = (encx24j600_t *) netdev; encx24j600_t * dev = (encx24j600_t *) netdev;
lock(dev); lock(dev);
#ifdef MODULE_NETSTATS_L2
netdev->stats.tx_bytes += count;
#endif
/* wait until previous packet has been sent */ /* wait until previous packet has been sent */
while ((reg_get(dev, ECON1) & TXRTS)); while ((reg_get(dev, ECON1) & TXRTS));
@ -367,6 +374,10 @@ static int _recv(netdev2_t *netdev, char* buf, int len, void *info)
size_t payload_len = hdr.frame_len - 4; size_t payload_len = hdr.frame_len - 4;
if (buf) { if (buf) {
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev2->stats.rx_bytes += len;
#endif
/* read packet (without 4 bytes checksum) */ /* read packet (without 4 bytes checksum) */
sram_op(dev, RRXDATA, 0xFFFF, buf, payload_len); sram_op(dev, RRXDATA, 0xFFFF, buf, payload_len);