From 901439211c67e21eab1204b46e73d85fc76ab2cc Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 8 Apr 2013 12:25:50 +0200 Subject: [PATCH] net: net_stat instrumented version of usb_drv --- dde_linux/lib/mk/platform_arndale/usb-stat.mk | 4 ++++ dde_linux/lib/mk/platform_panda/usb-stat.mk | 4 ++++ dde_linux/src/drivers/usb_net_stat/main.cc | 12 ++++++++++++ dde_linux/src/drivers/usb_net_stat/target.mk | 3 +++ dde_linux/src/lib/usb/nic/nic.cc | 13 +++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 dde_linux/lib/mk/platform_arndale/usb-stat.mk create mode 100644 dde_linux/lib/mk/platform_panda/usb-stat.mk create mode 100644 dde_linux/src/drivers/usb_net_stat/main.cc create mode 100644 dde_linux/src/drivers/usb_net_stat/target.mk diff --git a/dde_linux/lib/mk/platform_arndale/usb-stat.mk b/dde_linux/lib/mk/platform_arndale/usb-stat.mk new file mode 100644 index 0000000000..afc80f7643 --- /dev/null +++ b/dde_linux/lib/mk/platform_arndale/usb-stat.mk @@ -0,0 +1,4 @@ +LIBS += net-stat +CC_OPT += -DGENODE_NET_STAT + +include $(REP_DIR)/lib/mk/platform_arndale/usb.mk diff --git a/dde_linux/lib/mk/platform_panda/usb-stat.mk b/dde_linux/lib/mk/platform_panda/usb-stat.mk new file mode 100644 index 0000000000..e36522b91d --- /dev/null +++ b/dde_linux/lib/mk/platform_panda/usb-stat.mk @@ -0,0 +1,4 @@ +LIBS += net-stat +CC_OPT += -DGENODE_NET_STAT + +include $(REP_DIR)/lib/mk/platform_panda/usb.mk diff --git a/dde_linux/src/drivers/usb_net_stat/main.cc b/dde_linux/src/drivers/usb_net_stat/main.cc new file mode 100644 index 0000000000..40c156903a --- /dev/null +++ b/dde_linux/src/drivers/usb_net_stat/main.cc @@ -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; +} diff --git a/dde_linux/src/drivers/usb_net_stat/target.mk b/dde_linux/src/drivers/usb_net_stat/target.mk new file mode 100644 index 0000000000..91e471e747 --- /dev/null +++ b/dde_linux/src/drivers/usb_net_stat/target.mk @@ -0,0 +1,3 @@ +TARGET = usb_drv_net_stat +SRC_CC = main.cc +LIBS = usb-stat diff --git a/dde_linux/src/lib/usb/nic/nic.cc b/dde_linux/src/lib/usb/nic/nic.cc index 61f53b2082..2d4eaf27b9 100644 --- a/dde_linux/src/lib/usb/nic/nic.cc +++ b/dde_linux/src/lib/usb/nic/nic.cc @@ -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 + 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 }