Commit 73242ab3 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add new wrsSpllVersionGroup

Add following spll version info:
--wrsSpllVersion
--wrsSpllBuildDate

Additionally:
--update Makefile
--update MIB
--update init.c
--increase version number of spll_stat structure due to new fields
--support version 2 of spll_stat structure in wrsSpllStatusGroup

Please note that this commit requires changes done in wrpc-sw commit:
revision: report build information via spll_stats structure
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent f9578dcb
......@@ -39,6 +39,7 @@ SOURCES = \
wrsBootStatusGroup.c \
wrsTemperatureGroup.c \
wrsStartCntGroup.c \
wrsSpllVersionGroup.c \
wrsSpllStatusGroup.c \
wrsPstatsTable.c \
wrsPtpDataTable.c \
......
......@@ -723,6 +723,26 @@ wrsStartCntSyslogd OBJECT-TYPE
::= { wrsStartCntGroup 7 }
wrsSpllState OBJECT IDENTIFIER ::= { wrsExpertStatus 3 }
-- wrsSpllVersionGroup (.7.3.1)
wrsSpllVersionGroup OBJECT IDENTIFIER ::= { wrsSpllState 1 }
wrsSpllVersion OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The spll version, as returned from 'git describe' at build time"
::= { wrsSpllVersionGroup 1 }
wrsSpllBuildDate OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The build date of the spll, '__DATE__' at build time"
::= { wrsSpllVersionGroup 2 }
-- wrsSpllStatusGroup (.7.3.2)
wrsSpllStatusGroup OBJECT IDENTIFIER ::= { wrsSpllState 2 }
......
......@@ -18,6 +18,7 @@
#include "wrsBootStatusGroup.h"
#include "wrsTemperatureGroup.h"
#include "wrsStartCntGroup.h"
#include "wrsSpllVersionGroup.h"
#include "wrsSpllStatusGroup.h"
#include "wrsPstatsTable.h"
#include "wrsPtpDataTable.h"
......@@ -46,6 +47,7 @@ void init_wrsSnmp(void)
init_wrsBootStatusGroup();
init_wrsTemperatureGroup();
init_wrsStartCntGroup();
init_wrsSpllVersionGroup();
init_wrsSpllStatusGroup();
init_wrsPstatsTable();
init_wrsPtpDataTable();
......
......@@ -129,7 +129,10 @@ int spll_get_dac(int out_channel);
void check_vco_frequencies();
#define SPLL_STATS_VER 2
/* info reported through .stat section */
/* due to endiannes problem strings has to be 4 bytes alligned */
struct spll_stats {
int magic; /* 0x5b1157a7 = SPLLSTAT ?;)*/
int ver; /* version of the structure */
......@@ -142,6 +145,10 @@ struct spll_stats {
int M_lock;
int H_y, M_y;
int del_cnt;
int start_cnt;
char commit_id[32];
char build_date[16];
char build_time[16];
};
/* This only exists in wr-switch, but we should use it always */
......
......@@ -51,8 +51,8 @@ time_t wrsSpllStatus_data_fill(void)
"wrsSpllStatusGroup Wrong SPLL magic number\n");
return time_update;
}
/* check version of SPLL's stat structure */
if (spll_stats_p->ver == 1) {
/* check version of SPLL's stat structure, versions 1 and 2 are ok */
if ((spll_stats_p->ver == 1) || (spll_stats_p->ver == 2)) {
wrsSpllStatus_s.wrsSpllMode = spll_stats_p->mode;
wrsSpllStatus_s.wrsSpllIrqCnt = spll_stats_p->irq_cnt;
wrsSpllStatus_s.wrsSpllSeqState = spll_stats_p->seq_state;
......
#include "wrsSnmp.h"
#include "wrsSpllVersionGroup.h"
#include "softpll_ng.h"
#include "snmp_mmap.h"
#define FPGA_SPLL_STAT 0x10006800
#define SPLL_MAGIC 0x5b1157a7
static struct spll_stats *spll_stats_p;
static struct pickinfo wrsSpllVersion_pickinfo[] = {
FIELD(wrsSpllVersion_s, ASN_OCTET_STR, commit_id),
FIELD(wrsSpllVersion_s, ASN_OCTET_STR, build_date),
};
struct wrsSpllVersion_s wrsSpllVersion_s;
/* change endianess of the string */
static void strncpy_e(char *d, char *s, int len)
{
int i;
int len_4;
uint32_t *s_i, *d_i;
s_i = (uint32_t *)s;
d_i = (uint32_t *)d;
len_4 = (len+3)/4; /* ceil len to word lenth (4) */
for (i = 0; i < len_4; i++)
d_i[i] = ntohl(s_i[i]);
}
time_t wrsSpllVersion_data_fill(void)
{
static time_t time_update;
time_t time_cur;
time_cur = time(NULL);
if (time_update
&& time_cur - time_update < WRSSPLLVERSION_CACHE_TIMEOUT) {
/* cache not updated, return last update time */
return time_update;
}
time_update = time_cur;
memset(&wrsSpllVersion_s, 0, sizeof(wrsSpllVersion_s));
if (!spll_stats_p) /* first time, map the fpga space */
spll_stats_p = create_map(FPGA_SPLL_STAT,
sizeof(*spll_stats_p));
if (!spll_stats_p) {
/* unable to mmap */
return time_update;
}
/* check magic number in SPLL stat memory */
if (spll_stats_p->magic != SPLL_MAGIC) {
/* wrong magic */
snmp_log(LOG_ERR,
"wrsSpllVersionGroup Wrong SPLL magic number\n");
return time_update;
}
/* check version of SPLL's stat structure, version fields are from
* version 2 */
if (spll_stats_p->ver == 2) {
int len;
strncpy_e(wrsSpllVersion_s.commit_id, spll_stats_p->commit_id, 32);
/* concatenate date and time */
strncpy_e(wrsSpllVersion_s.build_date, spll_stats_p->build_date, 16);
len = strnlen(wrsSpllVersion_s.build_date, 32);
wrsSpllVersion_s.build_date[len] = ' '; /* put space instead of null */
/* add time after added space at the end of string */
strncpy_e(&wrsSpllVersion_s.build_date[len + 1], spll_stats_p->build_time, 16 - 1);
}
/* there was an update, return current time */
return time_update;
}
#define GT_OID WRSSPLLVERSION_OID
#define GT_PICKINFO wrsSpllVersion_pickinfo
#define GT_DATA_FILL_FUNC wrsSpllVersion_data_fill
#define GT_DATA_STRUCT wrsSpllVersion_s
#define GT_GROUP_NAME "wrsSpllVersionGroup"
#define GT_INIT_FUNC init_wrsSpllVersionGroup
#include "wrsGroupTemplate.h"
#ifndef WRS_SPLL_VERSION_GROUP_H
#define WRS_SPLL_VERSION_GROUP_H
#define WRSSPLLVERSION_CACHE_TIMEOUT 5
#define WRSSPLLVERSION_OID WRS_OID, 7, 3, 1
struct wrsSpllVersion_s {
char commit_id[32];
char build_date[32];
};
extern struct wrsSpllVersion_s wrsSpllVersion_s;
time_t wrsSpllVersion_data_fill(void);
void init_wrsSpllVersionGroup(void);
#endif /* WRS_SPLL_VERSION_GROUP_H */
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