Commit 8ff7b4d6 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk Committed by Alessandro Rubini

kernel/wr_pstats: requires updated HDL, create info file in sysfs

File provides information about pstats version, number of counters per word
stored in memory and number of counters per each port.
parent b01abc5b
/*
Register definitions for slave core: WR Switch Per-Port Statistic Counters
* File : pstats_regs.h
* File : pstats-regs.h
* Author : auto-generated by wbgen2 from wrsw_pstats.wb
* Created : Tue Feb 26 09:43:21 2013
* Created : Tue Jun 24 16:21:37 2014
* Standard : ANSI C
THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wrsw_pstats.wb
......@@ -59,37 +59,25 @@
/* definitions for register: L2 Counter Value */
/* definitions for register: Debug register */
/* definitions for register: PSTATS info register */
/* definitions for field: Events overflow in reg: Debug register */
#define PSTATS_DBG_EVT_OV_MASK WBGEN2_GEN_MASK(0, 8)
#define PSTATS_DBG_EVT_OV_SHIFT 0
#define PSTATS_DBG_EVT_OV_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define PSTATS_DBG_EVT_OV_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for field: Version in reg: PSTATS info register */
#define PSTATS_INFO_VER_MASK WBGEN2_GEN_MASK(0, 8)
#define PSTATS_INFO_VER_SHIFT 0
#define PSTATS_INFO_VER_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define PSTATS_INFO_VER_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for field: Counters overflow in reg: Debug register */
#define PSTATS_DBG_CNT_OV_MASK WBGEN2_GEN_MASK(8, 8)
#define PSTATS_DBG_CNT_OV_SHIFT 8
#define PSTATS_DBG_CNT_OV_W(value) WBGEN2_GEN_WRITE(value, 8, 8)
#define PSTATS_DBG_CNT_OV_R(reg) WBGEN2_GEN_READ(reg, 8, 8)
/* definitions for field: Counters per word in reg: PSTATS info register */
#define PSTATS_INFO_CPW_MASK WBGEN2_GEN_MASK(8, 8)
#define PSTATS_INFO_CPW_SHIFT 8
#define PSTATS_INFO_CPW_W(value) WBGEN2_GEN_WRITE(value, 8, 8)
#define PSTATS_INFO_CPW_R(reg) WBGEN2_GEN_READ(reg, 8, 8)
/* definitions for field: L2 Events overflow in reg: Debug register */
#define PSTATS_DBG_L2_EVT_OV_MASK WBGEN2_GEN_MASK(16, 1)
#define PSTATS_DBG_L2_EVT_OV_SHIFT 16
#define PSTATS_DBG_L2_EVT_OV_W(value) WBGEN2_GEN_WRITE(value, 16, 1)
#define PSTATS_DBG_L2_EVT_OV_R(reg) WBGEN2_GEN_READ(reg, 16, 1)
/* definitions for field: L2 Counters overflow in reg: Debug register */
#define PSTATS_DBG_L2_CNT_OV_MASK WBGEN2_GEN_MASK(17, 1)
#define PSTATS_DBG_L2_CNT_OV_SHIFT 17
#define PSTATS_DBG_L2_CNT_OV_W(value) WBGEN2_GEN_WRITE(value, 17, 1)
#define PSTATS_DBG_L2_CNT_OV_R(reg) WBGEN2_GEN_READ(reg, 17, 1)
/* definitions for field: L2 Clear flags in reg: Debug register */
#define PSTATS_DBG_L2_CLR WBGEN2_GEN_MASK(30, 1)
/* definitions for field: Clear flags in reg: Debug register */
#define PSTATS_DBG_CLR WBGEN2_GEN_MASK(31, 1)
/* definitions for field: Counters per port in reg: PSTATS info register */
#define PSTATS_INFO_CPP_MASK WBGEN2_GEN_MASK(16, 16)
#define PSTATS_INFO_CPP_SHIFT 16
#define PSTATS_INFO_CPP_W(value) WBGEN2_GEN_WRITE(value, 16, 16)
#define PSTATS_INFO_CPP_R(reg) WBGEN2_GEN_READ(reg, 16, 16)
/* definitions for register: Interrupt disable register */
......@@ -322,8 +310,8 @@ PACKED struct PSTATS_WB {
uint32_t L1_CNT_VAL;
/* [0x8]: REG L2 Counter Value */
uint32_t L2_CNT_VAL;
/* [0xc]: REG Debug register */
uint32_t DBG;
/* [0xc]: REG PSTATS info register */
uint32_t INFO;
/* padding to: 8 words */
uint32_t __padding_0[4];
/* [0x20]: REG Interrupt disable register */
......
......@@ -59,6 +59,9 @@ struct cntrs_dev {
static struct cntrs_dev pstats_dev; /*static data cleared at build time*/
/* pstats info for sysfs */
static int pstats_info[PINFO_SIZE];
static unsigned int *cntr_idx(unsigned int *tab, int port, int idx)
{
return &tab[port*PSTATS_CNT_PP+idx];
......@@ -214,17 +217,26 @@ static int pstats_handler(ctl_table *ctl, int write, void *buffer,
{
int ret;
int port;
unsigned int data;
port = (int)ctl->extra1;
if (!write)
pstats_rd_cntrs(port);
if( port < pstats_nports && !write ) {
pstats_rd_cntrs(port);
}
else if( !write ) {
/* read stuff for info file */
data = pstats_readl(pstats_dev, INFO);
pstats_info[PINFO_VER] = PSTATS_INFO_VER_R(data);
pstats_info[PINFO_CNTPW] = PSTATS_INFO_CPW_R(data);
pstats_info[PINFO_CNTPP] = PSTATS_INFO_CPP_R(data);
}
ret = proc_dointvec(ctl, 0, buffer, lenp, ppos);
return ret;
}
static ctl_table pstats_ctl_table[19]; /* initialized in _init function */
static ctl_table pstats_ctl_table[20]; /* initialized in _init function */
static ctl_table proc_table[] = {
{
......@@ -269,6 +281,13 @@ static int __init pstats_init(void)
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = (void *)i;
}
/* the last one with info about pstats */
pstats_ctl_table[i].procname = "info";
pstats_ctl_table[i].data = pstats_info;
pstats_ctl_table[i].maxlen = PINFO_SIZE * sizeof(int);
pstats_ctl_table[i].mode = 0444;
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = (void *)i;
pstats_header = register_sysctl_table(proc_table);
......
......@@ -21,6 +21,11 @@
#define PSTATS_IRQBUFSZ 16
#define PINFO_SIZE 3
#define PINFO_VER 0
#define PINFO_CNTPW 1
#define PINFO_CNTPP 2
extern int (*wr_nic_pstats_callback)(int epnum,
unsigned int ctr[PSTATS_CNT_PP]);
......
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