Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cpu/native/netdev2_tap/netdev2_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ static int _send(netdev2_t *netdev, const struct iovec *vector, int n)
}
netdev->stats.tx_bytes += bytes;
#endif
netdev->event_callback(netdev, NETDEV2_EVENT_TX_COMPLETE, NULL);
if (netdev->event_callback) {
netdev->event_callback(netdev, NETDEV2_EVENT_TX_COMPLETE, NULL);
}
return res;
}

Expand Down
7 changes: 4 additions & 3 deletions drivers/enc28j60/enc28j60.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ static int nd_send(netdev2_t *netdev, const struct iovec *data, int count)
#ifdef MODULE_NETSTATS_L2
netdev->stats.tx_bytes += count;
#endif

/* set write pointer */
cmd_w_addr(dev, ADDR_WRITE_PTR, BUF_TX_START);
/* write control byte and the actual data into the buffer */
Expand Down Expand Up @@ -380,6 +381,9 @@ static int nd_init(netdev2_t *netdev)
/* allow receiving bytes from now on */
cmd_bfs(dev, REG_ECON1, -1, ECON1_RXEN);

#ifdef MODULE_NETSTATS_L2
memset(&netdev->stats, 0, sizeof(netstats_t));
#endif
mutex_unlock(&dev->devlock);
return 0;
}
Expand Down Expand Up @@ -424,9 +428,6 @@ static void nd_isr(netdev2_t *netdev)
}
eir = cmd_rcr(dev, REG_EIR, -1);
}
#ifdef MODULE_NETSTATS_L2
memset(&netdev->stats, 0, sizeof(netstats_t));
#endif
}

static int nd_get(netdev2_t *netdev, netopt_t opt, void *value, size_t max_len)
Expand Down
13 changes: 12 additions & 1 deletion drivers/encx24j600/encx24j600.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "net/netdev2/eth.h"
#include "net/eui64.h"
#include "net/ethernet.h"
//#include "net/ethernet/hdr.h"
#include "net/netstats.h"

#define ENABLE_DEBUG (0)
#include "debug.h"
Expand Down Expand Up @@ -298,13 +298,20 @@ static int _init(netdev2_t *encdev)

unlock(dev);

#ifdef MODULE_NETSTATS_L2
memset(&netdev->stats, 0, sizeof(netstats_t));
#endif
return 0;
}

static int _send(netdev2_t *netdev, const struct iovec *vector, int count) {
encx24j600_t * dev = (encx24j600_t *) netdev;
lock(dev);

#ifdef MODULE_NETSTATS_L2
netdev->stats.tx_bytes += count;
#endif

/* wait until previous packet has been sent */
while ((reg_get(dev, ECON1) & TXRTS));

Expand Down Expand Up @@ -367,6 +374,10 @@ static int _recv(netdev2_t *netdev, char* buf, int len, void *info)
size_t payload_len = hdr.frame_len - 4;

if (buf) {
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev2->stats.rx_bytes += len;
#endif
/* read packet (without 4 bytes checksum) */
sram_op(dev, RRXDATA, 0xFFFF, buf, payload_len);

Expand Down