Commit 03ba9e4a authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'rubi-140613'

This merges the last commits I made on my laptop last weekq, and I
forgot to push.  Thanks greg for testing wrsw_vlans and thus finding
I miseed some bits.

Conflicts:
	userspace/tools/wrsw_vlans.c
parents ca09272c f447cc06
......@@ -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;
}
......
......@@ -229,7 +229,19 @@ static ctl_table proc_table[] = {
{0,}
};
/*
* This module is optional, in a way, and if there it is loaded after
* wr_nic. So it must register itself to wr_nic, to export this.
*/
int pstats_callback(int epnum, unsigned int cntr[PSTATS_CNT_PP])
{
int i;
pstats_rd_cntrs(epnum);
for (i = 0; i < PSTATS_CNT_PP; i++)
cntr[i] = *cntr_idx(pstats_dev.cntrs, epnum, i);
return 0;
}
static struct ctl_table_header *pstats_header;
......@@ -249,7 +261,7 @@ static int __init pstats_init(void)
pstats_ctl_table[i].maxlen = PSTATS_CNT_PP*sizeof(unsigned int);
pstats_ctl_table[i].mode = 0444;
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = i;
pstats_ctl_table[i].extra1 = (void *)i;
}
pstats_header = register_sysctl_table(proc_table);
......@@ -285,6 +297,8 @@ static int __init pstats_init(void)
spin_lock_init(&pstats_dev.port_mutex[i]);
pstats_irq_enable(portmsk);
wr_nic_pstats_callback = pstats_callback;
printk(KERN_INFO "%s: initialized\n", KBUILD_MODNAME);
return 0;
......@@ -298,6 +312,8 @@ static void __exit pstats_exit(void)
pstats_irq_disable(PSTATS_ALL_MSK);
free_irq(WRVIC_BASE_IRQ+WR_PSTATS_IRQ, &pstats_dev);
wr_nic_pstats_callback = NULL;
iounmap(pstats_dev.regs);
unregister_sysctl_table(pstats_header);
......
......@@ -21,5 +21,49 @@
#define PSTATS_IRQBUFSZ 16
extern int (*wr_nic_pstats_callback)(int epnum,
unsigned int ctr[PSTATS_CNT_PP]);
enum { /* names for values, from page 14 of hw/gw document */
PSTATS_C_T_UNDERRUN = 0,
PSTATS_C_R_OVERRUN,
PSTATS_C_R_INVALID_CODE,
PSTATS_C_R_SYNC_LOST,
PSTATS_C_R_PAUSE,
PSTATS_C_R_PFILTER_DROP,
PSTATS_C_R_PCS_ERROR,
PSTATS_C_R_GIANT,
PSTATS_C_R_RUNT,
PSTATS_C_R_CRC_ERROR,
PSTATS_C_R_PCLASS_0,
PSTATS_C_R_PCLASS_1,
PSTATS_C_R_PCLASS_2,
PSTATS_C_R_PCLASS_3,
PSTATS_C_R_PCLASS_4,
PSTATS_C_R_PCLASS_5,
PSTATS_C_R_PCLASS_6,
PSTATS_C_R_PCLASS_7,
PSTATS_C_T_FRAME,
PSTATS_C_R_FRAME,
PSTATS_C_RTU_REQ_FLAG,
PSTATS_C_R_PRI_0,
PSTATS_C_R_PRI_1,
PSTATS_C_R_PRI_2,
PSTATS_C_R_PRI_3,
PSTATS_C_R_PRI_4,
PSTATS_C_R_PRI_5,
PSTATS_C_R_PRI_6,
PSTATS_C_R_PRI_7,
PSTATS_C_RTU_REQ,
PSTATS_C_RTU_RESP,
PSTATS_C_RTU_DROPS,
PSTATS_C_RTU_HP,
PSTATS_C_RTU_FF,
PSTATS_C_RTU_NF,
PSTATS_C_RTU_FST,
PSTATS_C_RTU_FULL,
PSTATS_C_RTU_FWD,
PSTATS_C_RTU_RSP,
};
#endif
......@@ -425,17 +425,16 @@ void list_ep_vlans(void)
int ep;
static char *names[] = {"ACCESS", "TRUNK", "disabled", "unqualified"};
printf("# QMODE FIX_PRIO PRIO PVID MAC\n");
printf("#--------------------------------------\n");
printf("# QMODE FIX_PRIO PRIO PVID MAC\n");
printf("#---------------------------------------------\n");
for (ep = 0; ep < NPORTS; ep++) {
r = offsetof(struct EP_WB, VCR0);
v = ep_read(ep, r);
printf(" %i %6s %i %i %4i %08x%04x\n",
r & 3,
names[r & 3],
r & EP_VCR0_FIX_PRIO ? 1 : 0,
EP_VCR0_PRIO_VAL_R(r),
EP_VCR0_PVID_R(r),
printf(" %2i %i %6.6s %i %i %4i %04x%08x\n",
ep, v & 3, names[v & 3],
v & EP_VCR0_FIX_PRIO ? 1 : 0,
EP_VCR0_PRIO_VAL_R(v),
EP_VCR0_PVID_R(v),
(int)ep_read(ep, offsetof(struct EP_WB, MACH)),
(int)ep_read(ep, offsetof(struct EP_WB, MACL)));
}
......
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