mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
netdev: remove layer2 netstats from netdev drivers
Removing usage of netdev->stats in all net drivers, as it is handled by gnrc_netif.
This commit is contained in:
parent
a0324bdb43
commit
6183d5f5c5
@ -283,10 +283,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += pkt_len;
|
||||
#endif
|
||||
rfcore_read_fifo(buf, pkt_len);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -169,10 +169,6 @@ static int _esp_eth_init(netdev_t *netdev)
|
||||
LOG_TAG_ERROR("esp_eth", "enable failed");
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
mutex_unlock(&dev->dev_lock);
|
||||
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
else {
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_failed++;
|
||||
#endif
|
||||
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);
|
||||
dev->rx_len = 0;
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += size;
|
||||
#endif
|
||||
|
||||
mutex_unlock(&dev->dev_lock);
|
||||
return size;
|
||||
}
|
||||
|
@ -271,10 +271,6 @@ static int _esp_wifi_init(netdev_t *netdev)
|
||||
{
|
||||
DEBUG("%s: %p\n", __func__, netdev);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0x00, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
else {
|
||||
DEBUG("%s: sending WiFi packet failed\n", __func__);
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_failed++;
|
||||
#endif
|
||||
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);
|
||||
dev->rx_len = 0;
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += size;
|
||||
#endif
|
||||
|
||||
mutex_unlock(&dev->dev_lock);
|
||||
return size;
|
||||
}
|
||||
|
@ -466,10 +466,6 @@ static int _init(netdev_t *netdev)
|
||||
{
|
||||
DEBUG("%s: %p\n", __func__, netdev);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0x00, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -542,9 +538,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
while (_esp_now_sending > 0) {
|
||||
thread_yield_higher();
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += data_len;
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||
#endif
|
||||
|
||||
@ -552,10 +546,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
return data_len;
|
||||
} else {
|
||||
_esp_now_sending = 0;
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_failed++;
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += size;
|
||||
#endif
|
||||
|
||||
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);
|
||||
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:
|
||||
DEBUG("%s: %s not supported\n", __func__, netopt2str(opt));
|
||||
break;
|
||||
|
@ -254,10 +254,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
|
||||
_continue_reading(dev);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += nread;
|
||||
#endif
|
||||
return nread;
|
||||
}
|
||||
else if (nread == -1) {
|
||||
@ -284,14 +280,10 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
struct iovec iov[iolist_count(iolist)];
|
||||
|
||||
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);
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += bytes;
|
||||
#else
|
||||
(void)bytes;
|
||||
#endif
|
||||
|
||||
if (netdev->event_callback) {
|
||||
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_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");
|
||||
return 0;
|
||||
}
|
||||
|
@ -103,11 +103,10 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
socket_zep_t *dev = (socket_zep_t *)netdev;
|
||||
unsigned n = iolist_count(iolist);
|
||||
struct iovec v[n + 2];
|
||||
size_t bytes;
|
||||
int res;
|
||||
|
||||
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);
|
||||
/* simulate TX_STARTED interrupt */
|
||||
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);
|
||||
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;
|
||||
}
|
||||
@ -258,10 +252,7 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
}
|
||||
}
|
||||
_continue_reading(dev);
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += size;
|
||||
#endif
|
||||
|
||||
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];
|
||||
native_async_read_setup();
|
||||
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)
|
||||
|
@ -230,9 +230,6 @@ netdev_t *nrfble_setup(void)
|
||||
_nrfble_dev.driver = &netdev_driver;
|
||||
_nrfble_dev.event_callback = NULL;
|
||||
_nrfble_dev.context = NULL;
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&_nrfble_dev.stats, 0, sizeof(netstats_t));;
|
||||
#endif
|
||||
return &_nrfble_dev;
|
||||
}
|
||||
|
||||
|
@ -178,9 +178,6 @@ void nrfmin_setup(void)
|
||||
nrfmin_dev.driver = &nrfmin_netdev;
|
||||
nrfmin_dev.event_callback = NULL;
|
||||
nrfmin_dev.context = NULL;
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&nrfmin_dev.stats, 0, sizeof(netstats_t));;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t nrfmin_get_addr(void)
|
||||
|
@ -88,10 +88,6 @@ static int _init(netdev_t *netdev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -110,9 +106,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
(unsigned)len + 2);
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += len;
|
||||
#endif
|
||||
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);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += pkt_len;
|
||||
#endif
|
||||
/* copy payload */
|
||||
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),
|
||||
};
|
||||
|
||||
#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");
|
||||
res = netif->dev->driver->send(netif->dev, &iolist);
|
||||
|
||||
|
@ -137,10 +137,6 @@ static int _init(netdev_t *netdev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&netdev->stats, 0, sizeof(netstats_t));
|
||||
#endif
|
||||
|
||||
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 */
|
||||
dev->tx_time = xtimer_now_usec();
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += c;
|
||||
#endif
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
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);
|
||||
|
||||
if (buf != NULL) {
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += size;
|
||||
#endif
|
||||
/* read packet content into the supplied buffer */
|
||||
if (size <= max_len) {
|
||||
cmd_rbm(dev, (uint8_t *)buf, size);
|
||||
@ -454,9 +446,6 @@ static int nd_init(netdev_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->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,11 +33,6 @@
|
||||
#include "net/eui64.h"
|
||||
#include "net/ethernet.h"
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
#include <string.h>
|
||||
#include "net/netstats.h"
|
||||
#endif
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
@ -285,9 +280,6 @@ static int _init(netdev_t *encdev)
|
||||
|
||||
unlock(dev);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
memset(&encdev->stats, 0, sizeof(netstats_t));
|
||||
#endif
|
||||
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) */
|
||||
/*while ((reg_get(dev, ENC_ECON1) & ENC_TXRTS)) {}*/
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += len;
|
||||
#endif
|
||||
|
||||
unlock(dev);
|
||||
|
||||
return len;
|
||||
@ -367,10 +355,6 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
||||
unlock(dev);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += payload_len;
|
||||
#endif
|
||||
/* read packet (without 4 bytes checksum) */
|
||||
sram_op(dev, ENC_RRXDATA, 0xFFFF, buf, payload_len);
|
||||
|
||||
|
@ -81,10 +81,6 @@ static int _init(netdev_t *netdev)
|
||||
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 */
|
||||
kw2xrf_reset_phy(dev);
|
||||
|
||||
@ -169,9 +165,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
_send_last_fcf = dev->buf[1];
|
||||
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.rx_count++;
|
||||
netdev->stats.rx_bytes += pkt_len;
|
||||
#endif
|
||||
|
||||
if (pkt_len > len) {
|
||||
/* not enough space in buf */
|
||||
return -ENOBUFS;
|
||||
|
@ -57,9 +57,6 @@ static int _init(netdev_t *netdev)
|
||||
gpio_set(dev->params.reset_pin);
|
||||
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 */
|
||||
mrf24j40_reset(dev);
|
||||
return 0;
|
||||
@ -80,10 +77,6 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
||||
(unsigned)len + 2);
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netdev->stats.tx_bytes += len;
|
||||
#endif
|
||||
len = mrf24j40_tx_load(dev, iol->iol_base, iol->iol_len, len);
|
||||
/* only on first iteration: */
|
||||
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);
|
||||
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;
|
||||
}
|
||||
/* Turn on reception of packets off the air */
|
||||
|
@ -151,14 +151,6 @@ static int xbee_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||
.iol_len = res
|
||||
};
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
if (hdr->flags & BCAST) {
|
||||
netif->stats.tx_mcast_count++;
|
||||
}
|
||||
else {
|
||||
netif->stats.tx_unicast_count++;
|
||||
}
|
||||
#endif
|
||||
DEBUG("[xbee-gnrc] send: triggering the drivers send function\n");
|
||||
res = netif->dev->driver->send(netif->dev, &iolist);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user