Merge pull request #9793 from smlng/pr/netstats_l2
net stats: move layer 2 netstats from netdev driver to gnrc_netif
This commit is contained in:
commit
49f2715986
@ -283,10 +283,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
rfcore_write_fifo(iol->iol_base, iol->iol_len);
|
rfcore_write_fifo(iol->iol_base, iol->iol_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += pkt_len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set first byte of TX FIFO to the packet length */
|
/* Set first byte of TX FIFO to the packet length */
|
||||||
rfcore_poke_tx_fifo(0, pkt_len + CC2538_AUTOCRC_LEN);
|
rfcore_poke_tx_fifo(0, pkt_len + CC2538_AUTOCRC_LEN);
|
||||||
|
|
||||||
@ -333,10 +329,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
pkt_len = len;
|
pkt_len = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += pkt_len;
|
|
||||||
#endif
|
|
||||||
rfcore_read_fifo(buf, pkt_len);
|
rfcore_read_fifo(buf, pkt_len);
|
||||||
|
|
||||||
if (info != NULL && RFCORE->XREG_RSSISTATbits.RSSI_VALID) {
|
if (info != NULL && RFCORE->XREG_RSSISTATbits.RSSI_VALID) {
|
||||||
@ -397,10 +389,6 @@ static int _init(netdev_t *netdev)
|
|||||||
|
|
||||||
cc2538_set_state(dev, NETOPT_STATE_IDLE);
|
cc2538_set_state(dev, NETOPT_STATE_IDLE);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -169,10 +169,6 @@ static int _esp_eth_init(netdev_t *netdev)
|
|||||||
LOG_TAG_ERROR("esp_eth", "enable failed");
|
LOG_TAG_ERROR("esp_eth", "enable failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mutex_unlock(&dev->dev_lock);
|
mutex_unlock(&dev->dev_lock);
|
||||||
|
|
||||||
return (ret == ESP_OK) ? 0 : -1;
|
return (ret == ESP_OK) ? 0 : -1;
|
||||||
@ -215,16 +211,9 @@ static int _esp_eth_send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
|
|
||||||
/* send the the packet to the peer(s) mac address */
|
/* send the the packet to the peer(s) mac address */
|
||||||
if (esp_eth_tx(dev->tx_buf, dev->tx_len) == ESP_OK) {
|
if (esp_eth_tx(dev->tx_buf, dev->tx_len) == ESP_OK) {
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_success++;
|
|
||||||
netdev->stats.tx_bytes += dev->tx_len;
|
|
||||||
#endif
|
|
||||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_failed++;
|
|
||||||
#endif
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,11 +260,6 @@ static int _esp_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
memcpy(buf, dev->rx_buf, dev->rx_len);
|
memcpy(buf, dev->rx_buf, dev->rx_len);
|
||||||
dev->rx_len = 0;
|
dev->rx_len = 0;
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mutex_unlock(&dev->dev_lock);
|
mutex_unlock(&dev->dev_lock);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -271,10 +271,6 @@ static int _esp_wifi_init(netdev_t *netdev)
|
|||||||
{
|
{
|
||||||
DEBUG("%s: %p\n", __func__, netdev);
|
DEBUG("%s: %p\n", __func__, netdev);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0x00, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,17 +311,10 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
|
|
||||||
/* send the the packet to the peer(s) mac address */
|
/* send the the packet to the peer(s) mac address */
|
||||||
if (esp_wifi_internal_tx(ESP_IF_WIFI_STA, dev->tx_buf, dev->tx_len) == ESP_OK) {
|
if (esp_wifi_internal_tx(ESP_IF_WIFI_STA, dev->tx_buf, dev->tx_len) == ESP_OK) {
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_success++;
|
|
||||||
netdev->stats.tx_bytes += dev->tx_len;
|
|
||||||
#endif
|
|
||||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("%s: sending WiFi packet failed\n", __func__);
|
DEBUG("%s: sending WiFi packet failed\n", __func__);
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_failed++;
|
|
||||||
#endif
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,11 +363,6 @@ static int _esp_wifi_recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
memcpy(buf, dev->rx_buf, dev->rx_len);
|
memcpy(buf, dev->rx_buf, dev->rx_len);
|
||||||
dev->rx_len = 0;
|
dev->rx_len = 0;
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mutex_unlock(&dev->dev_lock);
|
mutex_unlock(&dev->dev_lock);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -466,10 +466,6 @@ static int _init(netdev_t *netdev)
|
|||||||
{
|
{
|
||||||
DEBUG("%s: %p\n", __func__, netdev);
|
DEBUG("%s: %p\n", __func__, netdev);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0x00, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,9 +538,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
while (_esp_now_sending > 0) {
|
while (_esp_now_sending > 0) {
|
||||||
thread_yield_higher();
|
thread_yield_higher();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
netdev->stats.tx_bytes += data_len;
|
|
||||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -552,10 +546,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
return data_len;
|
return data_len;
|
||||||
} else {
|
} else {
|
||||||
_esp_now_sending = 0;
|
_esp_now_sending = 0;
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_failed++;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->dev_lock);
|
mutex_unlock(&dev->dev_lock);
|
||||||
@ -608,12 +598,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
_esp_now_add_peer(mac, esp_now_params.channel, esp_now_params.key);
|
_esp_now_add_peer(mac, esp_now_params.channel, esp_now_params.key);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,14 +646,6 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
|
|||||||
res = sizeof(dev->addr);
|
res = sizeof(dev->addr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
case NETOPT_STATS:
|
|
||||||
CHECK_PARAM_RET(max_len == sizeof(uintptr_t), -EOVERFLOW);
|
|
||||||
*((netstats_t **)val) = &netdev->stats;
|
|
||||||
res = sizeof(uintptr_t);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG("%s: %s not supported\n", __func__, netopt2str(opt));
|
DEBUG("%s: %s not supported\n", __func__, netopt2str(opt));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -254,10 +254,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
|
|
||||||
_continue_reading(dev);
|
_continue_reading(dev);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += nread;
|
|
||||||
#endif
|
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
else if (nread == -1) {
|
else if (nread == -1) {
|
||||||
@ -284,14 +280,10 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
struct iovec iov[iolist_count(iolist)];
|
struct iovec iov[iolist_count(iolist)];
|
||||||
|
|
||||||
unsigned n;
|
unsigned n;
|
||||||
size_t bytes = iolist_to_iovec(iolist, iov, &n);
|
iolist_to_iovec(iolist, iov, &n);
|
||||||
|
|
||||||
int res = _native_writev(dev->tap_fd, iov, n);
|
int res = _native_writev(dev->tap_fd, iov, n);
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += bytes;
|
|
||||||
#else
|
|
||||||
(void)bytes;
|
|
||||||
#endif
|
|
||||||
if (netdev->event_callback) {
|
if (netdev->event_callback) {
|
||||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||||
}
|
}
|
||||||
@ -392,9 +384,6 @@ static int _init(netdev_t *netdev)
|
|||||||
native_async_read_setup();
|
native_async_read_setup();
|
||||||
native_async_read_add_handler(dev->tap_fd, netdev, _tap_isr);
|
native_async_read_add_handler(dev->tap_fd, netdev, _tap_isr);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
DEBUG("gnrc_tapnet: initialized.\n");
|
DEBUG("gnrc_tapnet: initialized.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,11 +103,10 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
socket_zep_t *dev = (socket_zep_t *)netdev;
|
socket_zep_t *dev = (socket_zep_t *)netdev;
|
||||||
unsigned n = iolist_count(iolist);
|
unsigned n = iolist_count(iolist);
|
||||||
struct iovec v[n + 2];
|
struct iovec v[n + 2];
|
||||||
size_t bytes;
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
assert((dev != NULL) && (dev->sock_fd != 0));
|
assert((dev != NULL) && (dev->sock_fd != 0));
|
||||||
bytes = _prep_vector(dev, iolist, n, v);
|
_prep_vector(dev, iolist, n, v);
|
||||||
DEBUG("socket_zep::send(%p, %p, %u)\n", (void *)netdev, (void *)iolist, n);
|
DEBUG("socket_zep::send(%p, %p, %u)\n", (void *)netdev, (void *)iolist, n);
|
||||||
/* simulate TX_STARTED interrupt */
|
/* simulate TX_STARTED interrupt */
|
||||||
if (netdev->event_callback) {
|
if (netdev->event_callback) {
|
||||||
@ -126,11 +125,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
netdev->event_callback(netdev, NETDEV_EVENT_ISR);
|
||||||
thread_yield();
|
thread_yield();
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += bytes;
|
|
||||||
#else
|
|
||||||
(void)bytes;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return res - v[0].iov_len - v[n + 1].iov_len;
|
return res - v[0].iov_len - v[n + 1].iov_len;
|
||||||
}
|
}
|
||||||
@ -258,10 +252,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_continue_reading(dev);
|
_continue_reading(dev);
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += size;
|
|
||||||
#endif
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,9 +395,6 @@ void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params)
|
|||||||
dev->netdev.short_addr[1] = dev->netdev.long_addr[7];
|
dev->netdev.short_addr[1] = dev->netdev.long_addr[7];
|
||||||
native_async_read_setup();
|
native_async_read_setup();
|
||||||
native_async_read_add_handler(dev->sock_fd, dev, _socket_isr);
|
native_async_read_add_handler(dev->sock_fd, dev, _socket_isr);
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&dev->netdev.netdev.stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_zep_cleanup(socket_zep_t *dev)
|
void socket_zep_cleanup(socket_zep_t *dev)
|
||||||
|
|||||||
@ -230,9 +230,6 @@ netdev_t *nrfble_setup(void)
|
|||||||
_nrfble_dev.driver = &netdev_driver;
|
_nrfble_dev.driver = &netdev_driver;
|
||||||
_nrfble_dev.event_callback = NULL;
|
_nrfble_dev.event_callback = NULL;
|
||||||
_nrfble_dev.context = NULL;
|
_nrfble_dev.context = NULL;
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&_nrfble_dev.stats, 0, sizeof(netstats_t));;
|
|
||||||
#endif
|
|
||||||
return &_nrfble_dev;
|
return &_nrfble_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -178,9 +178,6 @@ void nrfmin_setup(void)
|
|||||||
nrfmin_dev.driver = &nrfmin_netdev;
|
nrfmin_dev.driver = &nrfmin_netdev;
|
||||||
nrfmin_dev.event_callback = NULL;
|
nrfmin_dev.event_callback = NULL;
|
||||||
nrfmin_dev.context = NULL;
|
nrfmin_dev.context = NULL;
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&nrfmin_dev.stats, 0, sizeof(netstats_t));;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t nrfmin_get_addr(void)
|
uint16_t nrfmin_get_addr(void)
|
||||||
|
|||||||
@ -88,10 +88,6 @@ static int _init(netdev_t *netdev)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +106,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
(unsigned)len + 2);
|
(unsigned)len + 2);
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += len;
|
|
||||||
#endif
|
|
||||||
len = at86rf2xx_tx_load(dev, iol->iol_base, iol->iol_len, len);
|
len = at86rf2xx_tx_load(dev, iol->iol_base, iol->iol_len, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,10 +160,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
at86rf2xx_set_state(dev, dev->idle_state);
|
at86rf2xx_set_state(dev, dev->idle_state);
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += pkt_len;
|
|
||||||
#endif
|
|
||||||
/* copy payload */
|
/* copy payload */
|
||||||
at86rf2xx_fb_read(dev, (uint8_t *)buf, pkt_len);
|
at86rf2xx_fb_read(dev, (uint8_t *)buf, pkt_len);
|
||||||
|
|
||||||
|
|||||||
@ -139,14 +139,6 @@ static int cc1xxx_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
.iol_len = sizeof(l2hdr),
|
.iol_len = sizeof(l2hdr),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
if (netif_hdr->flags & BCAST) {
|
|
||||||
netif->dev->stats.tx_mcast_count++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
netif->dev->stats.tx_unicast_count++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
DEBUG("[cc1xxx-gnrc] send: triggering the drivers send function\n");
|
DEBUG("[cc1xxx-gnrc] send: triggering the drivers send function\n");
|
||||||
res = netif->dev->driver->send(netif->dev, &iolist);
|
res = netif->dev->driver->send(netif->dev, &iolist);
|
||||||
|
|
||||||
|
|||||||
@ -137,10 +137,6 @@ static int _init(netdev_t *netdev)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return cc2420_init((cc2420_t *)dev);
|
return cc2420_init((cc2420_t *)dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -299,10 +299,6 @@ static int nd_send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
/* set last transmission time for timeout handling */
|
/* set last transmission time for timeout handling */
|
||||||
dev->tx_time = xtimer_now_usec();
|
dev->tx_time = xtimer_now_usec();
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += c;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -340,10 +336,6 @@ static int nd_recv(netdev_t *netdev, void *buf, size_t max_len, void *info)
|
|||||||
(int)size, (int)next, buf, max_len);
|
(int)size, (int)next, buf, max_len);
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += size;
|
|
||||||
#endif
|
|
||||||
/* read packet content into the supplied buffer */
|
/* read packet content into the supplied buffer */
|
||||||
if (size <= max_len) {
|
if (size <= max_len) {
|
||||||
cmd_rbm(dev, (uint8_t *)buf, size);
|
cmd_rbm(dev, (uint8_t *)buf, size);
|
||||||
@ -454,9 +446,6 @@ static int nd_init(netdev_t *netdev)
|
|||||||
/* allow receiving bytes from now on */
|
/* allow receiving bytes from now on */
|
||||||
cmd_bfs(dev, REG_ECON1, -1, ECON1_RXEN);
|
cmd_bfs(dev, REG_ECON1, -1, ECON1_RXEN);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,11 +33,6 @@
|
|||||||
#include "net/eui64.h"
|
#include "net/eui64.h"
|
||||||
#include "net/ethernet.h"
|
#include "net/ethernet.h"
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
#include <string.h>
|
|
||||||
#include "net/netstats.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
@ -285,9 +280,6 @@ static int _init(netdev_t *encdev)
|
|||||||
|
|
||||||
unlock(dev);
|
unlock(dev);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&encdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,10 +309,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist) {
|
|||||||
/* (not sure if it is needed, keeping the line uncommented) */
|
/* (not sure if it is needed, keeping the line uncommented) */
|
||||||
/*while ((reg_get(dev, ENC_ECON1) & ENC_TXRTS)) {}*/
|
/*while ((reg_get(dev, ENC_ECON1) & ENC_TXRTS)) {}*/
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unlock(dev);
|
unlock(dev);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
@ -367,10 +355,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
unlock(dev);
|
unlock(dev);
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += payload_len;
|
|
||||||
#endif
|
|
||||||
/* read packet (without 4 bytes checksum) */
|
/* read packet (without 4 bytes checksum) */
|
||||||
sram_op(dev, ENC_RRXDATA, 0xFFFF, buf, payload_len);
|
sram_op(dev, ENC_RRXDATA, 0xFFFF, buf, payload_len);
|
||||||
|
|
||||||
|
|||||||
@ -200,9 +200,6 @@ extern "C" {
|
|||||||
#include "iolist.h"
|
#include "iolist.h"
|
||||||
#include "net/netopt.h"
|
#include "net/netopt.h"
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
#include "net/netstats.h"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_L2FILTER
|
#ifdef MODULE_L2FILTER
|
||||||
#include "net/l2filter.h"
|
#include "net/l2filter.h"
|
||||||
#endif
|
#endif
|
||||||
@ -281,9 +278,6 @@ struct netdev {
|
|||||||
#ifdef MODULE_NETDEV_LAYER
|
#ifdef MODULE_NETDEV_LAYER
|
||||||
netdev_t *lower; /**< ptr to the lower netdev layer */
|
netdev_t *lower; /**< ptr to the lower netdev layer */
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netstats_t stats; /**< transceiver's statistics */
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_L2FILTER
|
#ifdef MODULE_L2FILTER
|
||||||
l2filter_t filter[L2FILTER_LISTSIZE]; /**< link layer address filters */
|
l2filter_t filter[L2FILTER_LISTSIZE]; /**< link layer address filters */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -131,9 +131,6 @@ typedef struct {
|
|||||||
const struct netdev_driver *driver; /**< ptr to that driver's interface. */
|
const struct netdev_driver *driver; /**< ptr to that driver's interface. */
|
||||||
netdev_event_cb_t event_callback; /**< callback for device events */
|
netdev_event_cb_t event_callback; /**< callback for device events */
|
||||||
void* context; /**< ptr to network stack context */
|
void* context; /**< ptr to network stack context */
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netstats_t stats; /**< transceiver's statistics */
|
|
||||||
#endif
|
|
||||||
/* device driver specific fields */
|
/* device driver specific fields */
|
||||||
xbee_params_t p; /**< configuration parameters */
|
xbee_params_t p; /**< configuration parameters */
|
||||||
uint8_t options; /**< options field */
|
uint8_t options; /**< options field */
|
||||||
|
|||||||
@ -81,10 +81,6 @@ static int _init(netdev_t *netdev)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* reset device to default values and put it into RX state */
|
/* reset device to default values and put it into RX state */
|
||||||
kw2xrf_reset_phy(dev);
|
kw2xrf_reset_phy(dev);
|
||||||
|
|
||||||
@ -169,9 +165,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
_send_last_fcf = dev->buf[1];
|
_send_last_fcf = dev->buf[1];
|
||||||
|
|
||||||
kw2xrf_write_fifo(dev, dev->buf, dev->buf[0]);
|
kw2xrf_write_fifo(dev, dev->buf, dev->buf[0]);
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* send data out directly if pre-loading id disabled */
|
/* send data out directly if pre-loading id disabled */
|
||||||
if (!(dev->netdev.flags & KW2XRF_OPT_PRELOADING)) {
|
if (!(dev->netdev.flags & KW2XRF_OPT_PRELOADING)) {
|
||||||
@ -194,11 +187,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
return pkt_len + 1;
|
return pkt_len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += pkt_len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pkt_len > len) {
|
if (pkt_len > len) {
|
||||||
/* not enough space in buf */
|
/* not enough space in buf */
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|||||||
@ -57,9 +57,6 @@ static int _init(netdev_t *netdev)
|
|||||||
gpio_set(dev->params.reset_pin);
|
gpio_set(dev->params.reset_pin);
|
||||||
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, _irq_handler, dev);
|
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, _irq_handler, dev);
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
|
||||||
#endif
|
|
||||||
/* reset device to default values and put it into RX state */
|
/* reset device to default values and put it into RX state */
|
||||||
mrf24j40_reset(dev);
|
mrf24j40_reset(dev);
|
||||||
return 0;
|
return 0;
|
||||||
@ -80,10 +77,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
(unsigned)len + 2);
|
(unsigned)len + 2);
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.tx_bytes += len;
|
|
||||||
#endif
|
|
||||||
len = mrf24j40_tx_load(dev, iol->iol_base, iol->iol_len, len);
|
len = mrf24j40_tx_load(dev, iol->iol_base, iol->iol_len, len);
|
||||||
/* only on first iteration: */
|
/* only on first iteration: */
|
||||||
if (iol == iolist) {
|
if (iol == iolist) {
|
||||||
@ -136,10 +129,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
mrf24j40_rx_fifo_read(dev, phr + 2, &(rssi_scalar), 1);
|
mrf24j40_rx_fifo_read(dev, phr + 2, &(rssi_scalar), 1);
|
||||||
radio_info->rssi = mrf24j40_dbm_from_reg(rssi_scalar);
|
radio_info->rssi = mrf24j40_dbm_from_reg(rssi_scalar);
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
netdev->stats.rx_count++;
|
|
||||||
netdev->stats.rx_bytes += pkt_len;
|
|
||||||
#endif
|
|
||||||
res = pkt_len;
|
res = pkt_len;
|
||||||
}
|
}
|
||||||
/* Turn on reception of packets off the air */
|
/* Turn on reception of packets off the air */
|
||||||
|
|||||||
@ -80,15 +80,6 @@ int netdev_eth_get(netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
|||||||
{
|
{
|
||||||
return _get_iid(dev, value, max_len);
|
return _get_iid(dev, value, max_len);
|
||||||
}
|
}
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
case NETOPT_STATS:
|
|
||||||
{
|
|
||||||
assert(max_len >= sizeof(uintptr_t));
|
|
||||||
*((netstats_t**)value) = &dev->stats;
|
|
||||||
res = sizeof(uintptr_t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_L2FILTER
|
#ifdef MODULE_L2FILTER
|
||||||
case NETOPT_L2FILTER:
|
case NETOPT_L2FILTER:
|
||||||
{
|
{
|
||||||
|
|||||||
@ -143,13 +143,6 @@ int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value,
|
|||||||
case NETOPT_IPV6_IID:
|
case NETOPT_IPV6_IID:
|
||||||
res = _get_iid(dev, value, max_len);
|
res = _get_iid(dev, value, max_len);
|
||||||
break;
|
break;
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
case NETOPT_STATS:
|
|
||||||
assert(max_len == sizeof(uintptr_t));
|
|
||||||
*((netstats_t **)value) = &dev->netdev.stats;
|
|
||||||
res = sizeof(uintptr_t);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_L2FILTER
|
#ifdef MODULE_L2FILTER
|
||||||
case NETOPT_L2FILTER:
|
case NETOPT_L2FILTER:
|
||||||
assert(max_len >= sizeof(l2filter_t **));
|
assert(max_len >= sizeof(l2filter_t **));
|
||||||
|
|||||||
@ -151,14 +151,6 @@ static int xbee_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
.iol_len = res
|
.iol_len = res
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
|
||||||
if (hdr->flags & BCAST) {
|
|
||||||
netif->dev->stats.tx_mcast_count++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
netif->dev->stats.tx_unicast_count++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
DEBUG("[xbee-gnrc] send: triggering the drivers send function\n");
|
DEBUG("[xbee-gnrc] send: triggering the drivers send function\n");
|
||||||
res = netif->dev->driver->send(netif->dev, &iolist);
|
res = netif->dev->driver->send(netif->dev, &iolist);
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,9 @@
|
|||||||
#include "net/ndp.h"
|
#include "net/ndp.h"
|
||||||
#include "net/netdev.h"
|
#include "net/netdev.h"
|
||||||
#include "net/netopt.h"
|
#include "net/netopt.h"
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
#include "net/netstats.h"
|
||||||
|
#endif
|
||||||
#include "rmutex.h"
|
#include "rmutex.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -65,6 +68,9 @@ typedef struct {
|
|||||||
const gnrc_netif_ops_t *ops; /**< Operations of the network interface */
|
const gnrc_netif_ops_t *ops; /**< Operations of the network interface */
|
||||||
netdev_t *dev; /**< Network device of the network interface */
|
netdev_t *dev; /**< Network device of the network interface */
|
||||||
rmutex_t mutex; /**< Mutex of the interface */
|
rmutex_t mutex; /**< Mutex of the interface */
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
netstats_t stats; /**< transceiver's statistics */
|
||||||
|
#endif
|
||||||
#if defined(MODULE_GNRC_IPV6) || DOXYGEN
|
#if defined(MODULE_GNRC_IPV6) || DOXYGEN
|
||||||
gnrc_netif_ipv6_t ipv6; /**< IPv6 component */
|
gnrc_netif_ipv6_t ipv6; /**< IPv6 component */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -103,10 +103,10 @@ int _gnrc_gomach_transmit(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
if (netif_hdr->flags &
|
if (netif_hdr->flags &
|
||||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||||
netif->dev->stats.tx_mcast_count++;
|
netif->stats.tx_mcast_count++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
netif->dev->stats.tx_unicast_count++;
|
netif->stats.tx_unicast_count++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_GNRC_MAC
|
#ifdef MODULE_GNRC_MAC
|
||||||
@ -343,8 +343,8 @@ int gnrc_gomach_send_preamble_ack(gnrc_netif_t *netif, gnrc_gomach_packet_info_t
|
|||||||
assert(netif != NULL);
|
assert(netif != NULL);
|
||||||
assert(info != NULL);
|
assert(info != NULL);
|
||||||
|
|
||||||
|
gnrc_pktsnip_t *pkt;
|
||||||
gnrc_pktsnip_t *gomach_pkt = NULL;
|
gnrc_pktsnip_t *gomach_pkt = NULL;
|
||||||
gnrc_pktsnip_t *pkt = NULL;
|
|
||||||
gnrc_netif_hdr_t *nethdr_preamble_ack = NULL;
|
gnrc_netif_hdr_t *nethdr_preamble_ack = NULL;
|
||||||
|
|
||||||
/* Start assemble the preamble-ACK packet according to preamble packet info. */
|
/* Start assemble the preamble-ACK packet according to preamble packet info. */
|
||||||
|
|||||||
@ -90,10 +90,10 @@ int _gnrc_lwmac_transmit(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
if (netif_hdr->flags &
|
if (netif_hdr->flags &
|
||||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||||
netif->dev->stats.tx_mcast_count++;
|
netif->stats.tx_mcast_count++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
netif->dev->stats.tx_unicast_count++;
|
netif->stats.tx_unicast_count++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_GNRC_MAC
|
#ifdef MODULE_GNRC_MAC
|
||||||
|
|||||||
@ -145,10 +145,10 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
if ((netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) ||
|
if ((netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) ||
|
||||||
(netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
(netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||||
dev->stats.tx_mcast_count++;
|
netif->stats.tx_mcast_count++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dev->stats.tx_unicast_count++;
|
netif->stats.tx_unicast_count++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
res = dev->driver->send(dev, &iolist);
|
res = dev->driver->send(dev, &iolist);
|
||||||
@ -183,6 +183,10 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
|||||||
DEBUG("gnrc_netif_ethernet: read error.\n");
|
DEBUG("gnrc_netif_ethernet: read error.\n");
|
||||||
goto safe_out;
|
goto safe_out;
|
||||||
}
|
}
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
netif->stats.rx_count++;
|
||||||
|
netif->stats.rx_bytes += nread;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nread < bytes_expected) {
|
if (nread < bytes_expected) {
|
||||||
/* we've got less than the expected packet size,
|
/* we've got less than the expected packet size,
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include "net/gnrc/ipv6/nib.h"
|
#include "net/gnrc/ipv6/nib.h"
|
||||||
#include "net/gnrc/ipv6.h"
|
#include "net/gnrc/ipv6.h"
|
||||||
#endif /* MODULE_GNRC_IPV6_NIB */
|
#endif /* MODULE_GNRC_IPV6_NIB */
|
||||||
#ifdef MODULE_NETSTATS_IPV6
|
#ifdef MODULE_NETSTATS
|
||||||
#include "net/netstats.h"
|
#include "net/netstats.h"
|
||||||
#endif
|
#endif
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
@ -126,6 +126,13 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
|
|||||||
*((netstats_t **)opt->data) = &netif->ipv6.stats;
|
*((netstats_t **)opt->data) = &netif->ipv6.stats;
|
||||||
res = sizeof(&netif->ipv6.stats);
|
res = sizeof(&netif->ipv6.stats);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
case NETSTATS_LAYER2:
|
||||||
|
assert(opt->data_len == sizeof(netstats_t *));
|
||||||
|
*((netstats_t **)opt->data) = &netif->stats;
|
||||||
|
res = sizeof(&netif->stats);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
/* take from device */
|
/* take from device */
|
||||||
@ -1196,6 +1203,9 @@ static void *_gnrc_netif_thread(void *args)
|
|||||||
if (netif->ops->init) {
|
if (netif->ops->init) {
|
||||||
netif->ops->init(netif);
|
netif->ops->init(netif);
|
||||||
}
|
}
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
memset(&netif->stats, 0, sizeof(netstats_t));
|
||||||
|
#endif
|
||||||
/* now let rest of GNRC use the interface */
|
/* now let rest of GNRC use the interface */
|
||||||
gnrc_netif_release(netif);
|
gnrc_netif_release(netif);
|
||||||
|
|
||||||
@ -1215,6 +1225,11 @@ static void *_gnrc_netif_thread(void *args)
|
|||||||
DEBUG("gnrc_netif: error sending packet %p (code: %u)\n",
|
DEBUG("gnrc_netif: error sending packet %p (code: %u)\n",
|
||||||
msg.content.ptr, res);
|
msg.content.ptr, res);
|
||||||
}
|
}
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
else {
|
||||||
|
netif->stats.tx_bytes += res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||||
opt = msg.content.ptr;
|
opt = msg.content.ptr;
|
||||||
@ -1287,25 +1302,24 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("gnrc_netif: event triggered -> %i\n", event);
|
DEBUG("gnrc_netif: event triggered -> %i\n", event);
|
||||||
|
gnrc_pktsnip_t *pkt = NULL;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case NETDEV_EVENT_RX_COMPLETE: {
|
case NETDEV_EVENT_RX_COMPLETE:
|
||||||
gnrc_pktsnip_t *pkt = netif->ops->recv(netif);
|
pkt = netif->ops->recv(netif);
|
||||||
|
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
_pass_on_packet(pkt);
|
_pass_on_packet(pkt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
case NETDEV_EVENT_TX_MEDIUM_BUSY:
|
case NETDEV_EVENT_TX_MEDIUM_BUSY:
|
||||||
/* we are the only ones supposed to touch this variable,
|
/* we are the only ones supposed to touch this variable,
|
||||||
* so no acquire necessary */
|
* so no acquire necessary */
|
||||||
dev->stats.tx_failed++;
|
netif->stats.tx_failed++;
|
||||||
break;
|
break;
|
||||||
case NETDEV_EVENT_TX_COMPLETE:
|
case NETDEV_EVENT_TX_COMPLETE:
|
||||||
/* we are the only ones supposed to touch this variable,
|
/* we are the only ones supposed to touch this variable,
|
||||||
* so no acquire necessary */
|
* so no acquire necessary */
|
||||||
dev->stats.tx_success++;
|
netif->stats.tx_success++;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -70,6 +70,11 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
|||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
netif->stats.rx_count++;
|
||||||
|
netif->stats.rx_bytes += nread;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nread < bytes_expected) {
|
if (nread < bytes_expected) {
|
||||||
/* we've got less then the expected packet size,
|
/* we've got less then the expected packet size,
|
||||||
* so free the unused space.*/
|
* so free the unused space.*/
|
||||||
@ -102,7 +107,7 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
netdev_t *dev = netif->dev;
|
netdev_t *dev = netif->dev;
|
||||||
|
|
||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
dev->stats.tx_unicast_count++;
|
netif->stats.tx_unicast_count++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = dev->driver->send(dev, (iolist_t *)pkt);
|
res = dev->driver->send(dev, (iolist_t *)pkt);
|
||||||
|
|||||||
@ -95,6 +95,11 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
|||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef MODULE_NETSTATS_L2
|
||||||
|
netif->stats.rx_count++;
|
||||||
|
netif->stats.rx_bytes += nread;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (netif->flags & GNRC_NETIF_FLAGS_RAWMODE) {
|
if (netif->flags & GNRC_NETIF_FLAGS_RAWMODE) {
|
||||||
/* Raw mode, skip packet processing, but provide rx_info via
|
/* Raw mode, skip packet processing, but provide rx_info via
|
||||||
* GNRC_NETTYPE_NETIF */
|
* GNRC_NETTYPE_NETIF */
|
||||||
@ -241,10 +246,10 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
|||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
if (netif_hdr->flags &
|
if (netif_hdr->flags &
|
||||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||||
netif->dev->stats.tx_mcast_count++;
|
netif->stats.tx_mcast_count++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
netif->dev->stats.tx_unicast_count++;
|
netif->stats.tx_unicast_count++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_GNRC_MAC
|
#ifdef MODULE_GNRC_MAC
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user