Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
ca1cee2b
Commit
ca1cee2b
authored
Nov 28, 2014
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel/wr_pstats: print pstats counters' description in sysctl
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
b8ca02f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
23 deletions
+111
-23
wr_pstats.c
kernel/wr_pstats/wr_pstats.c
+42
-1
wr_pstats.h
kernel/wr_pstats/wr_pstats.h
+69
-22
No files found.
kernel/wr_pstats/wr_pstats.c
View file @
ca1cee2b
...
...
@@ -236,6 +236,27 @@ static int pstats_rd_cntrs(int port)
return
0
;
}
/* SYSCTL handler, pass description of counters */
static
int
pstats_desc_handler
(
ctl_table
*
ctl
,
int
write
,
void
*
buffer
,
size_t
*
lenp
,
loff_t
*
ppos
)
{
unsigned
int
data
;
unsigned
int
version
;
if
(
!
write
)
{
/* get version number */
data
=
pstats_readl
(
pstats_dev
,
INFO
);
version
=
PSTATS_INFO_VER_R
(
data
);
if
(
version
>=
PSTATS_NAMES_ARRAY_SIZE
)
{
version
=
0
;
}
ctl
->
data
=
(
void
*
)
pstats_names
[
version
];
ctl
->
maxlen
=
strlen
(
pstats_names
[
version
]);
}
return
proc_dostring
(
ctl
,
0
,
buffer
,
lenp
,
ppos
);
}
/* SYSCTL handler, reads counters from hw and passes to sysfs */
static
int
pstats_handler
(
ctl_table
*
ctl
,
int
write
,
void
*
buffer
,
size_t
*
lenp
,
loff_t
*
ppos
)
...
...
@@ -260,7 +281,7 @@ static int pstats_handler(ctl_table *ctl, int write, void *buffer,
return
ret
;
}
static
ctl_table
pstats_ctl_table
[
2
0
];
/* initialized in _init function */
static
ctl_table
pstats_ctl_table
[
2
1
];
/* initialized in _init function */
static
ctl_table
proc_table
[]
=
{
{
...
...
@@ -290,6 +311,8 @@ static struct ctl_table_header *pstats_header;
static
int
__init
pstats_init
(
void
)
{
int
i
,
err
=
0
;
unsigned
int
data
;
unsigned
int
version
;
/*convert nports to one-hot port mask (for enabling IRQs*/
printk
(
KERN_INFO
"nports=%u
\n
"
,
pstats_nports
);
...
...
@@ -313,6 +336,16 @@ static int __init pstats_init(void)
pstats_ctl_table
[
i
].
proc_handler
=
pstats_handler
;
pstats_ctl_table
[
i
].
extra1
=
(
void
*
)
i
;
i
++
;
/* fill data and maxlen at open time, so we can replace FPGA
* without reloading kernel module */
pstats_ctl_table
[
i
].
procname
=
"description"
;
pstats_ctl_table
[
i
].
data
=
NULL
;
pstats_ctl_table
[
i
].
maxlen
=
0
;
pstats_ctl_table
[
i
].
mode
=
0444
;
pstats_ctl_table
[
i
].
proc_handler
=
pstats_desc_handler
;
pstats_ctl_table
[
i
].
extra1
=
(
void
*
)
i
;
pstats_header
=
register_sysctl_table
(
proc_table
);
if
(
!
pstats_header
)
{
...
...
@@ -348,6 +381,14 @@ static int __init pstats_init(void)
wr_nic_pstats_callback
=
pstats_callback
;
/* get version number */
data
=
pstats_readl
(
pstats_dev
,
INFO
);
version
=
PSTATS_INFO_VER_R
(
data
);
if
(
version
>=
PSTATS_NAMES_ARRAY_SIZE
)
printk
(
KERN_INFO
"port stats version %d not supported
\n
"
,
version
);
printk
(
KERN_INFO
"%s: initialized
\n
"
,
KBUILD_MODNAME
);
return
0
;
...
...
kernel/wr_pstats/wr_pstats.h
View file @
ca1cee2b
...
...
@@ -7,28 +7,6 @@
#define WRVIC_BASE_IRQ (NR_AIC_IRQS + (5 * 32))
/*****/
#define PSTATS_NPORTS 18
/* how many eth ports are in the switch */
#define PSTATS_CNT_PP 39
/* how many counters per port */
#define PSTATS_ADR_PP ((PSTATS_CNT_PP+3)/4)
/* how many address words are
* there per counter (each of
* them stores the state of 4
* counters) */
#define PSTATS_MSB_SHIFT 16
/*how many bits are stored in hw*/
#define PSTATS_LSB_MSK 0x0000ffff
#define PSTATS_MSB_MSK 0xffff0000
#define PSTATS_ALL_MSK 0xffffffff
#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
]);
enum
{
/* names for values, from page 14 of hw/gw document */
PSTATS_C_T_UNDERRUN
=
0
,
PSTATS_C_R_OVERRUN
,
...
...
@@ -69,6 +47,75 @@ enum { /* names for values, from page 14 of hw/gw document */
PSTATS_C_RTU_FULL
,
PSTATS_C_RTU_FWD
,
PSTATS_C_RTU_RSP
,
/* number of counters, add new entries before this line */
PSTATS_NUM_OF_COUNTERS
,
};
#define PSTATS_NPORTS 18
/* how many eth ports are in the switch */
#define PSTATS_CNT_PP PSTATS_NUM_OF_COUNTERS
/* how many counters per port */
#define PSTATS_ADR_PP ((PSTATS_CNT_PP+3)/4)
/* how many address words are
* there per counter (each of
* them stores the state of 4
* counters) */
#define PSTATS_MSB_SHIFT 16
/*how many bits are stored in hw*/
#define PSTATS_LSB_MSK 0x0000ffff
#define PSTATS_MSB_MSK 0xffff0000
#define PSTATS_ALL_MSK 0xffffffff
#define PSTATS_IRQBUFSZ 16
#define PSTATS_NAMES_ARRAY_SIZE 2
#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
]);
static
char
*
pstats_names
[
PSTATS_NAMES_ARRAY_SIZE
]
=
{
[
0
]
=
"Inv pstats ver reported by FPGA"
,
[
1
]
=
"TX Underrun
\n
"
"RX Overrun
\n
"
"RX Invalid Code
\n
"
"RX Sync Lost
\n
"
"RX Pause Frames
\n
"
"RX Pfilter Dropped
\n
"
"RX PCS Errors
\n
"
"RX Giant Frames
\n
"
"RX Runt Frames
\n
"
"RX CRC Errors
\n
"
"RX Pclass 0
\n
"
"RX Pclass 1
\n
"
"RX Pclass 2
\n
"
"RX Pclass 3
\n
"
"RX Pclass 4
\n
"
"RX Pclass 5
\n
"
"RX Pclass 6
\n
"
"RX Pclass 7
\n
"
"TX Frames
\n
"
"RX Frames
\n
"
"RX Drop RTU Full
\n
"
"RX PRIO 0
\n
"
"RX PRIO 1
\n
"
"RX PRIO 2
\n
"
"RX PRIO 3
\n
"
"RX PRIO 4
\n
"
"RX PRIO 5
\n
"
"RX PRIO 6
\n
"
"RX PRIO 7
\n
"
"RTU Valid
\n
"
"RTU Responses
\n
"
"RTU Dropped
\n
"
"FastMatch: Priority
\n
"
"FastMatch: FastForward
\n
"
"FastMatch: NonForward
\n
"
"FastMatch: Resp Valid
\n
"
"FullMatch: Resp Valid
\n
"
"Forwarded
\n
"
"TRU Resp Valid"
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment