Commit ee7d3b30 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Miguel Jimenez Lopez

kernel: make wr_pstats and wr_nic talk

wr_nic now exports wr_nic_pstats_callback as a pointer. When wr_pstats
is loaded it writes its own pointer in there.

wr_nic can thus ask for statistics and updated net_device_stats with
the proper numbers.   The statistics on snmp reflect this, because
snmpd uses the standard device ioctl commands -- but very few of our
counters actually end up all the way to snmp.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9e7a8f2e
......@@ -5,9 +5,11 @@ wr-nic-objs := module.o device.o nic-core.o endpoint.o ethtool.o \
# accept WRN_DEBUG from the environment. It turns pr_debug() into printk.
ifdef WRN_DEBUG
EXTRA_CFLAGS += -DDEBUG
ccflags-y += -DDEBUG
endif
ccflags-y += -I$(src)/../wr_pstats
# What follows is standard stuff
export ARCH ?= arm
export CROSS_COMPILE ?= $(CROSS_COMPILE_ARM)
......
......@@ -20,6 +20,7 @@
#include <asm/unaligned.h>
#include "wr-nic.h"
#include "wr_pstats.h"
#include "nic-mem.h"
/*
......@@ -219,11 +220,46 @@ static int wrn_start_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}
int (*wr_nic_pstats_callback)(int epnum,
unsigned int ctr[PSTATS_CNT_PP]);
EXPORT_SYMBOL(wr_nic_pstats_callback);
static unsigned int nic_counters[PSTATS_CNT_PP];
static DEFINE_SPINLOCK(nic_counters_lock);
struct net_device_stats *wrn_get_stats(struct net_device *dev)
{
struct wrn_ep *ep = netdev_priv(dev);
/* FIXME: we should get the RMON information from endpoint */
if (wr_nic_pstats_callback) {
int i;
spin_lock(&nic_counters_lock);
wr_nic_pstats_callback(ep->ep_number, nic_counters);
if (0) {
/* A stupid diagnostics, happens oh so often... */
printk(KERN_INFO "counters for %i:", ep->ep_number);
for (i = 0; i < PSTATS_CNT_PP; i++)
printk(KERN_CONT " %u", nic_counters[i]);
printk(KERN_CONT "\n");
} else {
/* Recover values in the kernel structure */
ep->stats.rx_packets =
nic_counters[PSTATS_C_R_FRAME];
ep->stats.tx_packets =
nic_counters[PSTATS_C_T_FRAME];
ep->stats.rx_length_errors =
nic_counters[PSTATS_C_R_GIANT];
ep->stats.rx_crc_errors =
nic_counters[PSTATS_C_R_CRC_ERROR];
ep->stats.rx_fifo_errors =
nic_counters[PSTATS_C_R_OVERRUN];
ep->stats.tx_fifo_errors =
nic_counters[PSTATS_C_T_UNDERRUN];
}
spin_unlock(&nic_counters_lock);
}
return &ep->stats;
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment