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
36ef7963
Commit
36ef7963
authored
Sep 15, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace: add new hwinfo to MIB, wrs_version and snmpd
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
9a77f753
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
10 deletions
+134
-10
WR-SWITCH-MIB.txt
userspace/snmpd/WR-SWITCH-MIB.txt
+26
-2
wrsVersion.c
userspace/snmpd/wrsVersion.c
+5
-2
wrs_version.c
userspace/tools/wrs_version.c
+103
-6
No files found.
userspace/snmpd/WR-SWITCH-MIB.txt
View file @
36ef7963
...
...
@@ -402,7 +402,7 @@ portPeer OBJECT-TYPE
::= { ppsiPort 4 }
-- Versions (4) are all just strings,
6
of them
-- Versions (4) are all just strings,
several
of them
wrsVersionSw OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..64))
...
...
@@ -441,7 +441,7 @@ wrsVersionHw1 OBJECT-TYPE
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The hardware version: PCB"
"The hardware version:
minibackplane
PCB"
::= { wrsVersion 5 }
wrsVersionHw2 OBJECT-TYPE
...
...
@@ -452,6 +452,30 @@ wrsVersionHw2 OBJECT-TYPE
"The hardware version: FPGA"
::= { wrsVersion 6 }
wrsManufacturer OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The name of the manufacturing company"
::= { wrsVersion 7 }
wrsSerialNumber OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The serial number (or string) of the switch"
::= { wrsVersion 8 }
wrsScbVersion OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The version of the SCB (motherboard)"
::= { wrsVersion 9 }
-- Date (5), to quickly check wr status
wrsDateTAI OBJECT-TYPE
...
...
userspace/snmpd/wrsVersion.c
View file @
36ef7963
...
...
@@ -12,7 +12,7 @@
#include "wrsSnmp.h"
/* Our structure for caching data */
#define VERSION_N_STRINGS
6
/* sw, 3 gw, 2 hw
*/
#define VERSION_N_STRINGS
9
/* sw, 3 gw, 2 hw, 3 added later
*/
struct
wrs_v_item
{
char
*
key
;
...
...
@@ -25,8 +25,11 @@ static struct wrs_v_item wrs_version[] = {
[
1
]
=
{
"wr_switch_hdl-commit:"
},
[
2
]
=
{
"general-cores-commit:"
},
[
3
]
=
{
"wr-cores-commit:"
},
[
4
]
=
{
"
pcb
-version:"
},
[
4
]
=
{
"
backplane
-version:"
},
[
5
]
=
{
"fpga-type:"
},
[
6
]
=
{
"manufacturer:"
},
[
7
]
=
{
"serial-number:"
},
[
8
]
=
{
"scb-version:"
},
};
...
...
userspace/tools/wrs_version.c
View file @
36ef7963
...
...
@@ -26,7 +26,9 @@
#include <shw_io.h>
#include <hwiu.h>
#include "switch_hw.h"
#include "libsdbfs.h"
#define SDBFS_NAME "/dev/mtd5"
#ifndef __GIT_VER__
#define __GIT_VER__ "x.x"
...
...
@@ -53,6 +55,97 @@ void help(const char* pgrname)
exit
(
1
);
}
/*
* This is the backend of sdb access, using the sdb library. I don't run
* sdb-read because it pretends to mmap the file, and mtd can't be mapped
* (this I'll fix in fpga-config-space); and it would add overhead
*/
struct
drvdata
{
FILE
*
f
;
};
static
struct
drvdata
drvdata
;
static
int
sdb_read
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
struct
drvdata
*
dd
=
fs
->
drvdata
;
FILE
*
f
=
dd
->
f
;
if
(
fseek
(
f
,
offset
,
SEEK_SET
)
<
0
)
return
-
1
;
return
fread
(
buf
,
1
,
count
,
f
);
}
static
struct
sdbfs
sdb_instance
=
{
.
drvdata
=
&
drvdata
,
.
entrypoint
=
0
,
/* unfortunately: to be fixed */
.
read
=
sdb_read
,
};
/* This uses the sdb library, with backend above */
static
char
*
sdb_get
(
char
*
fname
,
char
*
tagname
)
{
static
char
buf
[
0x420
];
static
char
result
[
64
];
char
*
unknown
=
"UNKNOWN"
;
static
FILE
*
f
=
(
FILE
*
)
-
1
;
int
i
,
j
;
char
*
s
;
if
(
f
==
(
FILE
*
)
-
1
)
{
f
=
fopen
(
SDBFS_NAME
,
"r"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"%s: %s
\n
"
,
SDBFS_NAME
,
strerror
(
errno
));
return
unknown
;
}
drvdata
.
f
=
f
;
i
=
sdbfs_dev_create
(
&
sdb_instance
,
0
/* verbose */
);
if
(
i
!=
0
)
{
printf
(
"Error accessing SDB filesystem in
\"
%s
\"\n
"
,
SDBFS_NAME
);
f
=
NULL
;
return
unknown
;
}
}
if
(
!
f
)
/* already failed, already reported */
return
unknown
;
i
=
sdbfs_open_name
(
&
sdb_instance
,
fname
);
if
(
i
<
0
)
{
fprintf
(
stderr
,
"Can't open
\"
%s
\"
in
\"
%s
\"\n
"
,
fname
,
SDBFS_NAME
);
return
unknown
;
}
i
=
sdbfs_fread
(
&
sdb_instance
,
-
1
,
buf
,
sizeof
(
buf
)
-
1
);
if
(
i
<=
0
)
return
unknown
;
j
=
i
-
1
;
/* trim trailing garbage as the file is assumed to be text */
while
(
j
>=
0
&&
(
buf
[
j
]
==
0xff
||
buf
[
j
]
==
0x00
))
j
--
;
if
(
j
>=
0
&&
buf
[
j
]
==
'\n'
)
j
--
;
/* trailing newline too */
buf
[
j
+
1
]
=
'\0'
;
if
(
!
tagname
)
{
strncpy
(
result
,
buf
,
sizeof
(
result
));
return
result
;
}
/* Look for the tag */
s
=
strstr
(
buf
,
tagname
);
sscanf
(
s
,
"%*[^:]:%*c%[^
\n
]"
,
result
);
return
result
;
}
static
char
*
get_fpga
(
void
)
{
return
sdb_get
(
"hw_info"
,
"fpga"
);
}
/* Previous stuff follows */
static
void
print_gw_info
(
void
)
{
struct
gw_info
info
;
...
...
@@ -82,8 +175,11 @@ static void wrsw_tagged_versions(void)
printf
(
"software-version: %s
\n
"
,
__GIT_VER__
);
/* see Makefile */
printf
(
"bult-by: %s
\n
"
,
__GIT_USR__
);
/* see Makefile */
printf
(
"build-date: %s %s
\n
"
,
__DATE__
,
__TIME__
);
printf
(
"pcb-version: %s
\n
"
,
get_shw_info
(
'p'
));
printf
(
"fpga-type: %s
\n
"
,
get_shw_info
(
'f'
));
printf
(
"backplane-version: %s
\n
"
,
get_shw_info
(
'p'
));
printf
(
"fpga-type: %s
\n
"
,
get_fpga
());
printf
(
"manufacturer: %s
\n
"
,
sdb_get
(
"manufacturer"
,
NULL
));
printf
(
"serial-number: %s
\n
"
,
sdb_get
(
"hw_info"
,
"scb_serial"
));
printf
(
"scb-version: %s
\n
"
,
sdb_get
(
"scb_version"
,
NULL
));
print_gw_info
();
/* This is already tagged */
}
...
...
@@ -114,9 +210,10 @@ int main(int argc, char **argv)
}
func
=
'f'
;
/* fall through */
case
'p'
:
case
'f'
:
/* Warning: this -p and -f is used by the web interface */
case
'f'
:
/* Warning: this -p and -f is used by the web interface */
printf
(
"%s
\n
"
,
get_fpga
());
break
;
case
'p'
:
/* Warning: this -p and -f is used by the web interface */
printf
(
"%s
\n
"
,
get_shw_info
(
func
));
break
;
case
'g'
:
...
...
@@ -135,7 +232,7 @@ int main(int argc, char **argv)
case
'a'
:
/* Warning: this with "awk '{print $4}'" is ued by the web if */
printf
(
"PCB:%s, FPGA:%s; version: %s (%s); compiled at %s %s
\n
"
,
get_shw_info
(
'p'
),
get_
shw_info
(
'f'
),
get_shw_info
(
'p'
),
get_
fpga
(
),
__GIT_VER__
,
__GIT_USR__
,
__DATE__
,
__TIME__
);
break
;
case
'h'
:
...
...
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