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
84
Issues
84
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
66eebbb3
Commit
66eebbb3
authored
Dec 11, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'adam-pstats'
parents
b41e8354
c6c904a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
325 additions
and
233 deletions
+325
-233
wrs-todo.in
doc/wrs-todo.in
+0
-10
nic-core.c
kernel/wr_nic/nic-core.c
+2
-26
wr_pstats.c
kernel/wr_pstats/wr_pstats.c
+247
-84
wr_pstats.h
kernel/wr_pstats/wr_pstats.h
+17
-48
wrsDate.c
userspace/snmpd/wrsDate.c
+3
-3
wrsPpsi.c
userspace/snmpd/wrsPpsi.c
+5
-7
wrsPstats.c
userspace/snmpd/wrsPstats.c
+50
-54
wrsSnmp.h
userspace/snmpd/wrsSnmp.h
+1
-1
No files found.
doc/wrs-todo.in
View file @
66eebbb3
...
...
@@ -155,10 +155,6 @@ completed (a similar branch exists in @i{spec-sw}, changing the
like increasing @t
{
NR
_
IRQ
}
and exporting symbols for externally-loaded
@t
{
irq
_
chip
}
drivers.
@item We'd benefit from having ``pstats'' names in @t
{
/proc/sys
}
where
the counters are. This would make the @sc
{
snmp
}
code generic, so
no change there would be needed if and when the counters change.
@end itemize
@c ##########################################################################
...
...
@@ -170,12 +166,6 @@ no change there would be needed if and when the counters change.
@item We should have SDB in the switch gateware, to simplify a number
of things and avoid explicit addresses in so many places.
@item The ``pstats'' counters should export a version (even before SDB
is used). (@b
{
Update
}
: it is there, it just not used yet -- thanks Greg).
Thus, the kernel driver will know what the counters are, and
we could run different gateware images with the same filesystem, because
the driver will support the various versions counter sets.
@end itemize
@c ##########################################################################
...
...
kernel/wr_nic/nic-core.c
View file @
66eebbb3
...
...
@@ -228,10 +228,9 @@ static int wrn_start_xmit(struct sk_buff *skb, struct net_device *dev)
#if WR_IS_SWITCH
int
(
*
wr_nic_pstats_callback
)(
int
epnum
,
unsigned
int
ctr
[
PSTATS_CNT_PP
]
);
struct
net_device_stats
*
stats
);
EXPORT_SYMBOL
(
wr_nic_pstats_callback
);
static
unsigned
int
nic_counters
[
PSTATS_CNT_PP
];
static
DEFINE_SPINLOCK
(
nic_counters_lock
);
#endif
...
...
@@ -241,31 +240,8 @@ struct net_device_stats *wrn_get_stats(struct net_device *dev)
#if WR_IS_SWITCH
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
];
}
wr_nic_pstats_callback
(
ep
->
ep_number
,
&
(
ep
->
stats
));
spin_unlock
(
&
nic_counters_lock
);
}
#endif
...
...
kernel/wr_pstats/wr_pstats.c
View file @
66eebbb3
This diff is collapsed.
Click to expand it.
kernel/wr_pstats/wr_pstats.h
View file @
66eebbb3
...
...
@@ -7,13 +7,14 @@
#define WRVIC_BASE_IRQ (NR_AIC_IRQS + (5 * 32))
/*****/
#define PSTATS_MAX_NUM_OF_COUNTERS 39
/* Maximum number of counters
* supported by the driver */
#define PSTATS_MAX_NPORTS 18
/* Maximum number of ports
* supported by the driver */
#define PSTATS_DEFAULT_NPORTS PSTATS_MAX_NPORTS
/* how many eth ports are
* in the switch */
#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
...
...
@@ -27,48 +28,16 @@
#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
,
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
,
struct
net_device_stats
*
stats
);
struct
pstats_version_description
{
unsigned
int
rx_packets
;
unsigned
int
tx_packets
;
unsigned
int
rx_length_errors
;
unsigned
int
rx_crc_errors
;
unsigned
int
rx_fifo_errors
;
unsigned
int
tx_fifo_errors
;
char
*
cnt_names
;
};
#endif
userspace/snmpd/wrsDate.c
View file @
66eebbb3
...
...
@@ -37,8 +37,8 @@ void *create_map(unsigned long address, unsigned long size)
if
(
fd
<
0
)
return
NULL
;
offset
=
address
&
~
(
ps
-
1
);
fragment
=
address
&
(
ps
-
1
);
offset
=
address
&
~
(
ps
-
1
);
fragment
=
address
&
(
ps
-
1
);
len
=
address
+
size
-
offset
;
mapaddr
=
mmap
(
0
,
len
,
PROT_READ
|
PROT_WRITE
,
...
...
@@ -68,7 +68,7 @@ static void wrs_d_get(void)
utcl
=
pps
->
CNTR_UTCLO
;
tmp1
=
pps
->
CNTR_UTCHI
;
tmp2
=
pps
->
CNTR_UTCLO
;
}
while
((
tmp1
!=
utch
)
||
(
tmp2
!=
utcl
));
}
while
((
tmp1
!=
utch
)
||
(
tmp2
!=
utcl
));
wrs_d_current_64
=
(
uint64_t
)(
utch
)
<<
32
|
utcl
;
t
=
wrs_d_current_64
;
...
...
userspace/snmpd/wrsPpsi.c
View file @
66eebbb3
...
...
@@ -116,7 +116,7 @@ static void wrs_ppsi_parse_line(char *line, void *baseaddr,
addr
=
baseaddr
+
pi
->
offset
;
/* Here I'm lazy in error checking, let's hope it's ok */
switch
(
pi
->
type
)
{
switch
(
pi
->
type
)
{
case
ASN_UNSIGNED
:
/*
* our unsigned is line length, definitely less than 2G,
...
...
@@ -276,7 +276,7 @@ static int ppsi_g_group(netsnmp_mib_handler *handler,
/* For the per-port table we use an iterator like in wrsPstats.c */
static
netsnmp_variable_list
*
ppsi_p_next_entry
(
void
**
loop_context
,
ppsi_p_next_entry
(
void
**
loop_context
,
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
...
...
@@ -290,7 +290,7 @@ ppsi_p_next_entry( void **loop_context,
return
NULL
;
/* no more */
i
++
;
/* Create the row OID: only the counter index */
snmp_set_var_value
(
index
,
(
u_char
*
)
&
i
,
sizeof
(
i
));
snmp_set_var_value
(
index
,
(
u_char
*
)
&
i
,
sizeof
(
i
));
/* Set the data context (1..4 -> 0..3) */
*
data_context
=
(
void
*
)(
intptr_t
)(
i
-
1
);
...
...
@@ -306,7 +306,7 @@ ppsi_p_first_entry(void **loop_context,
netsnmp_iterator_info
*
data
)
{
/* reset internal position, so "next" is "first" */
*
loop_context
=
(
void
*
)
0
;
/* first counter */
*
loop_context
=
(
void
*
)
0
;
/* first counter */
return
ppsi_p_next_entry
(
loop_context
,
data_context
,
index
,
data
);
}
...
...
@@ -353,7 +353,7 @@ ppsi_p_handler(netsnmp_mib_handler *handler,
}
for
(
request
=
requests
;
request
;
request
=
request
->
next
)
{
for
(
request
=
requests
;
request
;
request
=
request
->
next
)
{
requestvb
=
request
->
requestvb
;
//logmsg("%s: %i\n", __func__, __LINE__);
...
...
@@ -424,6 +424,4 @@ init_wrsPpsi(void)
ppsi_p_load
,
NULL
,
wrsPpsiP_oid
,
OID_LENGTH
(
wrsPpsiP_oid
)));
}
userspace/snmpd/wrsPstats.c
View file @
66eebbb3
...
...
@@ -13,59 +13,23 @@
#define PSTATS_CACHE_TIMEOUT 5
/* seconds */
/* Our structure for caching data */
#define PSTATS_
N_COUNTERS 39
#define PSTATS_
MAX_N_COUNTERS 50
/* Maximum number of counters */
#define PSTATS_N_PORTS 18
/* this hardwired in the mib too */
#define PSTATS_MAX_COUNTERS_NAME_LEN 35
/* maximum length of counter's name */
#define PSTATS_SYSCTL_PATH "/proc/sys/pstats/"
/* Path to sysclt entries */
#define PSTATS_SYSCTL_DESCRIPTION_FILE "description"
/* file with counters' descriptions */
struct
pstats_per_port
{
uint32_t
val
[
PSTATS_N_COUNTERS
];
uint32_t
val
[
PSTATS_
MAX_
N_COUNTERS
];
};
static
struct
pstats_global_data
{
struct
pstats_per_port
port
[
PSTATS_N_PORTS
];
char
*
pname
[
PSTATS_N_PORTS
];
char
counter_name
[
PSTATS_MAX_N_COUNTERS
][
PSTATS_MAX_COUNTERS_NAME_LEN
];
int
n_counters
;
}
pstats_global_data
;
static
char
*
pstats_names
[]
=
{
[
0
]
=
"TX Underrun"
,
[
1
]
=
"RX Overrun"
,
[
2
]
=
"RX Invalid Code"
,
[
3
]
=
"RX Sync Lost"
,
[
4
]
=
"RX Pause Frames"
,
[
5
]
=
"RX Pfilter Dropped"
,
[
6
]
=
"RX PCS Errors"
,
[
7
]
=
"RX Giant Frames"
,
[
8
]
=
"RX Runt Frames"
,
[
9
]
=
"RX CRC Errors"
,
[
10
]
=
"RX Pclass 0"
,
[
11
]
=
"RX Pclass 1"
,
[
12
]
=
"RX Pclass 2"
,
[
13
]
=
"RX Pclass 3"
,
[
14
]
=
"RX Pclass 4"
,
[
15
]
=
"RX Pclass 5"
,
[
16
]
=
"RX Pclass 6"
,
[
17
]
=
"RX Pclass 7"
,
[
18
]
=
"TX Frames"
,
[
19
]
=
"RX Frames"
,
[
20
]
=
"RX Drop RTU Full"
,
[
21
]
=
"RX PRIO 0"
,
[
22
]
=
"RX PRIO 1"
,
[
23
]
=
"RX PRIO 2"
,
[
24
]
=
"RX PRIO 3"
,
[
25
]
=
"RX PRIO 4"
,
[
26
]
=
"RX PRIO 5"
,
[
27
]
=
"RX PRIO 6"
,
[
28
]
=
"RX PRIO 7"
,
[
29
]
=
"RTU Valid"
,
[
30
]
=
"RTU Responses"
,
[
31
]
=
"RTU Dropped"
,
[
32
]
=
"FastMatch: Priority"
,
[
33
]
=
"FastMatch: FastForward"
,
[
34
]
=
"FastMatch: NonForward"
,
[
35
]
=
"FastMatch: Resp Valid"
,
[
36
]
=
"FullMatch: Resp Valid"
,
[
37
]
=
"Forwarded"
,
[
38
]
=
"TRU Resp Valid"
};
/* FIXME: build error if ARRAY_SIZE(pstats_names) != PSTATS_N_COUNTERS */
...
...
@@ -87,7 +51,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
logmsg
(
"%s: %i
\n
"
,
__func__
,
__LINE__
);
switch
(
reqinfo
->
mode
)
{
case
MODE_GET
:
for
(
request
=
requests
;
request
;
request
=
request
->
next
)
{
for
(
request
=
requests
;
request
;
request
=
request
->
next
)
{
requestvb
=
request
->
requestvb
;
logmsg
(
"%s: %i
\n
"
,
__func__
,
__LINE__
);
...
...
@@ -99,7 +63,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
logmsg
(
"counter %i, port %i
\n
"
,
counter
,
wrport
);
if
(
wrport
<
0
)
{
char
*
s
=
pstats_
names
[
counter
];
char
*
s
=
pstats_
global_data
.
counter_name
[
counter
];
snmp_set_var_typed_value
(
requestvb
,
ASN_OCTET_STR
,
s
,
strlen
(
s
));
continue
;
}
...
...
@@ -130,7 +94,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
static
netsnmp_variable_list
*
wrsPstats_next_entry
(
void
**
loop_context
,
wrsPstats_next_entry
(
void
**
loop_context
,
void
**
data_context
,
netsnmp_variable_list
*
index
,
netsnmp_iterator_info
*
data
)
...
...
@@ -140,11 +104,11 @@ wrsPstats_next_entry( void **loop_context,
/* create the line ID from counter number */
i
=
(
intptr_t
)
*
loop_context
;
//logmsg("%s: %i (i = %i)\n", __func__, __LINE__, i);
if
(
i
>=
PSTATS_N_COUNTERS
)
if
(
i
>=
pstats_global_data
.
n_counters
)
return
NULL
;
/* no more */
i
++
;
/* Create the row OID: only the counter index */
snmp_set_var_value
(
index
,
(
u_char
*
)
&
i
,
sizeof
(
i
));
snmp_set_var_value
(
index
,
(
u_char
*
)
&
i
,
sizeof
(
i
));
/* Set the data context (1..39 -> 0..38) */
*
data_context
=
(
void
*
)(
intptr_t
)(
i
-
1
);
...
...
@@ -162,7 +126,7 @@ wrsPstats_first_entry(void **loop_context,
logmsg
(
"%s: %i
\n
"
,
__func__
,
__LINE__
);
/* reset internal position, so "next" is "first" */
*
loop_context
=
(
void
*
)
0
;
/* first counter */
*
loop_context
=
(
void
*
)
0
;
/* first counter */
return
wrsPstats_next_entry
(
loop_context
,
data_context
,
index
,
data
);
}
...
...
@@ -173,22 +137,54 @@ wrsPstats_load(netsnmp_cache *cache, void *vmagic)
char
fname
[
32
];
int
wrport
,
counter
;
struct
pstats_per_port
*
stat
;
char
*
p
;
/* fill names of counters */
f
=
fopen
(
PSTATS_SYSCTL_PATH
PSTATS_SYSCTL_DESCRIPTION_FILE
,
"r"
);
if
(
f
)
{
for
(
counter
=
0
;
counter
<
PSTATS_MAX_N_COUNTERS
;
counter
++
)
{
/* parse new line delimited file */
p
=
fgets
(
pstats_global_data
.
counter_name
[
counter
],
PSTATS_MAX_COUNTERS_NAME_LEN
,
f
);
if
(
p
==
NULL
)
break
;
/* fgets usualy returns strings with newline, return
string shall contain maximum one newline character */
p
=
strchr
(
pstats_global_data
.
counter_name
[
counter
],
'\n'
);
if
(
p
!=
NULL
)
*
p
=
'\0'
;
}
pstats_global_data
.
n_counters
=
counter
;
fclose
(
f
);
}
else
{
/* use PSTATS_MAX_N_COUNTERS as number of counters */
pstats_global_data
.
n_counters
=
PSTATS_MAX_N_COUNTERS
;
/* fill counters' names */
for
(
counter
=
0
;
counter
<
PSTATS_MAX_N_COUNTERS
;
counter
++
)
{
snprintf
(
pstats_global_data
.
counter_name
[
counter
],
PSTATS_MAX_COUNTERS_NAME_LEN
,
"pstats counter %d"
,
counter
);
}
}
for
(
wrport
=
0
;
wrport
<
PSTATS_N_PORTS
;
wrport
++
)
{
sprintf
(
fname
,
"/proc/sys/pstats/
port%i"
,
wrport
);
sprintf
(
fname
,
PSTATS_SYSCTL_PATH
"
port%i"
,
wrport
);
stat
=
pstats_global_data
.
port
+
wrport
;
f
=
fopen
(
fname
,
"r"
);
if
(
!
f
)
{
memset
(
stat
,
0x7f
,
sizeof
(
*
stat
));
continue
;
}
for
(
counter
=
0
;
counter
<
PSTATS_N_COUNTERS
;
counter
++
)
{
for
(
counter
=
0
;
counter
<
pstats_global_data
.
n_counters
;
counter
++
)
{
if
(
fscanf
(
f
,
"%u"
,
stat
->
val
+
counter
)
!=
1
)
stat
->
val
[
counter
]
=
0xffffff
;
stat
->
val
[
counter
]
=
0xffffff
ff
;
}
fclose
(
f
);
}
//dumpstruct(logf, "global data", &pstats_global_data, sizeof(pstats_global_data));
return
0
;
}
...
...
userspace/snmpd/wrsSnmp.h
View file @
66eebbb3
...
...
@@ -66,7 +66,7 @@ static inline int dumpstruct(FILE *dest, char *name, void *ptr, int size)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
(type *)( (char *)__mptr - offsetof(type,
member) );})
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
...
...
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