net: net_stat instrumented version of usb_drv

This commit is contained in:
Alexander Boettcher 2013-04-08 12:25:50 +02:00 committed by Norman Feske
parent 3ace475f2d
commit 901439211c
5 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,4 @@
LIBS += net-stat
CC_OPT += -DGENODE_NET_STAT
include $(REP_DIR)/lib/mk/platform_arndale/usb.mk

View File

@ -0,0 +1,4 @@
LIBS += net-stat
CC_OPT += -DGENODE_NET_STAT
include $(REP_DIR)/lib/mk/platform_panda/usb.mk

View File

@ -0,0 +1,12 @@
/*
* \brief Startup USB driver library
* \author Sebastian Sumpf
* \date 2013-02-20
*/
int main()
{
extern void start_usb_driver();
start_usb_driver();
return 0;
}

View File

@ -0,0 +1,3 @@
TARGET = usb_drv_net_stat
SRC_CC = main.cc
LIBS = usb-stat

View File

@ -320,12 +320,21 @@ int register_netdev(struct net_device *ndev)
int netif_running(const struct net_device *dev) { return dev->state & START; }
int netif_device_present(struct net_device *dev) { return 1; }
#ifdef GENODE_NET_STAT
#include <nic/stat.h>
static Timer::Connection _timer;
static Nic::Measurement _stat(_timer);
#endif
int netif_rx(struct sk_buff *skb)
{
if (_nic && _nic->session()) {
_nic->rx(skb);
}
#ifdef GENODE_NET_STAT
else if (_nic)
_stat.data(new (skb->data) Net::Ethernet_frame(skb->len), skb->len);
#endif
dev_kfree_skb(skb);
return NET_RX_SUCCESS;
@ -621,5 +630,9 @@ void random_ether_addr(u8 *addr)
Genode::memcpy(addr, mac.addr, ETH_ALEN);
snprint_mac(str, mac.addr);
PINF("Using configured mac: %s", str);
#ifdef GENODE_NET_STAT
_stat.set_mac(mac.addr);
#endif
}