Commit 8035d140 authored by Jean-Claude BAU's avatar Jean-Claude BAU

SNMP: New MIB

acking branch 'origin/jcb-proposed_master' into proposed_master

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
parents 9ac14e9e c3d0461c
This diff is collapsed.
...@@ -318,6 +318,68 @@ wrsPTPFramesFlowing OBJECT-TYPE ...@@ -318,6 +318,68 @@ wrsPTPFramesFlowing OBJECT-TYPE
firstRead - cannot calculate value from only one read" firstRead - cannot calculate value from only one read"
::= { wrsTimingStatusGroup 4 } ::= { wrsTimingStatusGroup 4 }
wrsSystemClockStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
error(2),
errorMinor(3),
thresholdExceeded(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The system clock is compared to NTP time
ok - system clock is under the threshold value
thresholdExceeded - system clock has exceeded the threshold value
error - Unexpected status
warningNA - there is N/A in one of object used to calculate this value"
::= { wrsTimingStatusGroup 5 }
wrsLeapSecStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
error(2),
errorMinor(3),
warning(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Leap second status
ok - Everything ok
leapSecFileExpired - The current leap second file is out-dated
internalErrorDetected - Internal error detected (system,...)
taiReadError - Cannot read the TAI time
leaSecInserted - A leap second will be inserted at 00:00
leapSecDeleted - A leap second will be deleted at 00:00
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsTimingStatusGroup 6 }
wrsLeapSecSourceStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
error(2),
errorMinor(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Download status of the leap seconds file
ok - Everything is OK
updated - Local leap seconds file has been updated
dhcpError - DHCP error detected
invalidUrl - The URL is not reachable or invalid
invalidFile - The download file is invalid
downloadError - Error detected during the download
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsTimingStatusGroup 7 }
-- wrsNetworkingStatusGroup (.6.2.3) -- wrsNetworkingStatusGroup (.6.2.3)
wrsNetworkingStatusGroup OBJECT IDENTIFIER ::= { wrsDetailedStatusesGroup 3 } wrsNetworkingStatusGroup OBJECT IDENTIFIER ::= { wrsDetailedStatusesGroup 3 }
...@@ -526,6 +588,112 @@ wrsDateTAIString OBJECT-TYPE ...@@ -526,6 +588,112 @@ wrsDateTAIString OBJECT-TYPE
"The current TAI time, printed as %y-%m-%d-%H:%M:%S (no time zone)" "The current TAI time, printed as %y-%m-%d-%H:%M:%S (no time zone)"
::= { wrsCurrentTimeGroup 2 } ::= { wrsCurrentTimeGroup 2 }
wrsSystemClockStatusDetails OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
thresholdExceeded(2),
statusFileMissing(3),
unknownStatus(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The system clock is compared to NTP time
ok - system clock is under the threshold value
thresholdExceeded - system clock has exceeded the threshold value
error - Unexpected status
warningNA - there is N/A in one of object used to calculate this value"
::= { wrsCurrentTimeGroup 3 }
wrsSystemClockDrift OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Drift of system clock expressed in seconds"
::= { wrsCurrentTimeGroup 4 }
wrsLeapSecSource OBJECT-TYPE
SYNTAX INTEGER {
na(0),
error(1),
errorMinor(2),
local(3),
tryRemote(4),
forceRemote(5) }
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Source leap second file (leap-seconds.list)
local - The local file is used
tryRemote - Try to download the file, if it fails
do not propagate error
forceRemote - Try to download the file, if it fails
the error is propagated
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsCurrentTimeGroup 5 }
wrsLeapSecStatusDetails OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
statusFileMissing(2),
unknownStatus(3)
leapSecFileExpired(4),
internalErrorDetected(5),
taiReadError(6),
leaSecInserted(7),
leapSecDeleted(8)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Leap second status
ok - Everything ok
leapSecFileExpired - The current leap second file is out-dated
internalErrorDetected - Internal error detected (system,...)
taiReadError - Cannot read the TAI time
leaSecInserted - A leap second will be inserted at 00:00
leapSecDeleted - A leap second will be deleted at 00:00
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsCurrentTimeGroup 6 }
wrsLeapSecSourceStatusDetails OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
statusFileMissing(2),
unknownStatus(3)
updated(4),
dhcpError(5),
invalidUrl(6),
invalidFile(7),
downloadError(8)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Download status of the leap seconds file
ok - Everything is OK
updated - Local leap seconds file has been updated
dhcpError - DHCP error detected
invalidUrl - The URL is not reachable or invalid
invalidFile - The download file is invalid
downloadError - Error detected during the download
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsCurrentTimeGroup 7 }
wrsLeapSecSourceURL OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..128))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Url to the leap second file"
::= { wrsCurrentTimeGroup 8 }
--wrsBootStatusGroup (.7.1.2) --wrsBootStatusGroup (.7.1.2)
wrsBootStatusGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 2 } wrsBootStatusGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 2 }
...@@ -2968,9 +3136,10 @@ wrsPtpInstanceVlanListStr OBJECT-TYPE ...@@ -2968,9 +3136,10 @@ wrsPtpInstanceVlanListStr OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"Coma separated list of VLANs used by an instance" "Comma separated list of VLANs used by an instance"
::= { wrsPtpInstanceEntry 29 } ::= { wrsPtpInstanceEntry 29 }
--wrsNetworking --wrsNetworking
--Configuration --Configuration
......
...@@ -14,7 +14,7 @@ struct pp_instance *ppsi_ppi; ...@@ -14,7 +14,7 @@ struct pp_instance *ppsi_ppi;
parentDS_t *ppsi_parentDS; parentDS_t *ppsi_parentDS;
defaultDS_t *ppsi_defaultDS; defaultDS_t *ppsi_defaultDS;
int *ppsi_ppi_nlinks; int *ppsi_ppi_nlinks=NULL;
/* RTUd */ /* RTUd */
struct wrs_shm_head *rtud_head; struct wrs_shm_head *rtud_head;
......
This diff is collapsed.
#ifndef WRS_CURRENT_TIME_GROUP_H #ifndef WRS_CURRENT_TIME_GROUP_H
#define WRS_CURRENT_TIME_GROUP_H #define WRS_CURRENT_TIME_GROUP_H
#define WRSCURRENTTIME_CACHE_TIMEOUT 5 #define WRSCURRENTTIME_TAI_CACHE_TIMEOUT 5
#define WRSCURRENTTIME_OID WRS_OID, 7, 1, 1 #define WRSCURRENTTIME_OID WRS_OID, 7, 1, 1
#define WRS_LEAP_SECOND_SOURCE_URL_LEN 128
#define WRS_LEAP_SEC_SOURCE_ERROR 1 /* Error detected */
#define WRS_LEAP_SEC_SOURCE_IO_ERROR 2 /* Cannot acces local file */
#define WRS_LEAP_SEC_SOURCE_LOCAL 3 /* The local leap seconds file is used*/
#define WRS_LEAP_SEC_SOURCE_TRY_REMOTE 4 /* Try to download the file (No errors) */
#define WRS_LEAP_SEC_SOURCE_FORCE_REMOTE 5 /* Try to download the file (propagate errors) */
#define WRS_SYSTEM_CLOCK_STATUS_DETAILS_OK 1 /* ok */
#define WRS_SYSTEM_CLOCK_STATUS_DETAILS_IO_ERROR 2 /* Status file is missing */
#define WRS_SYSTEM_CLOCK_STATUS_DETAILS_UNKNOWN 3 /* Unknown status */
#define WRS_SYSTEM_CLOCK_STATUS_DETAILTS_THRESHOLD_EXCEEDED \
4 /* Threshold exceeded */
#define WRS_LEAP_SEC_STATUS_DETAILS_OK 1 /* Everything ok */
#define WRS_LEAP_SEC_STATUS_DETAILS_IO_ERROR 2 /* Status file is missing */
#define WRS_LEAP_SEC_STATUS_DETAILS_UNKNOWN 3 /* Unknown status */
#define WRS_LEAP_SEC_STATUS_DETAILS_FILE_EXPIRED 4 /* The current leap second file is out-dated */
#define WRS_LEAP_SEC_STATUS_DETAILS_INTERNAL_ERROR 5 /* Threshold exceeded */
#define WRS_LEAP_SEC_STATUS_DETAILS_TAI_READ_ERROR 6 /* Cannot read the TAI time */
#define WRS_LEAP_SEC_STATUS_DETAILS_SEC_INSERTED 7 /* A leap second will be inserted at 00:00*/
#define WRS_LEAP_SEC_STATUS_DETAILS_SEC_DELETED 8 /* A leap second will be deleted at 00:00*/
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_OK 1 /* Everything ok */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_IO_ERROR 2 /* Status file is missing */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_UNKNOWN 3 /* Unknown status */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_UPDATED 4 /* Local leap seconds file has been updated */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_DHCP_ERROR 5 /* DHCP error detected */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_INVALID_URL 6 /* The URL is not reachable or invalid */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_INVALID_FILE 7 /* The download file is invalid */
#define WRS_LEAP_SEC_SRC_STATUS_DETAILS_DOWNLOAD_ERROR 8 /* Error detected during the download */
struct wrsCurrentTime_s { struct wrsCurrentTime_s {
uint64_t wrsDateTAI; /* current time in TAI */ uint64_t wrsDateTAI; /* current time in TAI */
char wrsDateTAIString[32]; /* current time in TAI as string */ char wrsDateTAIString[32]; /* current time in TAI as string */
int wrsSystemClockStatusDetails; /* System clock status details*/
int wrsSystemClockDrift; /* System monitoring clock */
int wrsLeapSecStatusDetails; /* Leap seconds details */
int wrsLeapSecSourceStatusDetails; /* Leap second source status details*/
int wrsLeapSecSource; /* Source of the leap seconds file */
char wrsLeapSecSourceUrl[WRS_LEAP_SECOND_SOURCE_URL_LEN + 1]; /* URL to download leap second file */
}; };
extern struct wrsCurrentTime_s wrsCurrentTime_s; extern struct wrsCurrentTime_s wrsCurrentTime_s;
......
...@@ -97,12 +97,21 @@ time_t wrsGeneralStatus_data_fill(void) ...@@ -97,12 +97,21 @@ time_t wrsGeneralStatus_data_fill(void)
|| t->wrsSoftPLLStatus == WRS_SOFTPLL_STATUS_ERROR || t->wrsSoftPLLStatus == WRS_SOFTPLL_STATUS_ERROR
|| t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_ERROR || t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_ERROR
|| t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_ERROR || t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_ERROR
|| t->wrsSystemClockStatus == WRS_SYSTEM_CLOCK_STATUS_ERROR
|| t->wrsSystemClockStatus == WRS_SYSTEM_CLOCK_STATUS_THRESHOLD_EXCEEDED
|| t->wrsLeapSecStatus == WRS_LEAP_SEC_STATUS_ERROR
|| t->wrsLeapSecSourceStatus==WRS_LEAP_SEC_SRC_STATUS_ERROR
) { ) {
wrsGeneralStatus_s.wrsTimingStatus = wrsGeneralStatus_s.wrsTimingStatus =
WRS_TIMING_STATUS_ERROR; WRS_TIMING_STATUS_ERROR;
} else if ( /* check if warning */ } else if ( /* check if warning */
t->wrsSoftPLLStatus == WRS_SOFTPLL_STATUS_WARNING t->wrsSoftPLLStatus == WRS_SOFTPLL_STATUS_WARNING
|| t->wrsLeapSecStatus == WRS_LEAP_SEC_STATUS_ERROR_MINOR
|| t->wrsLeapSecSourceStatus == WRS_LEAP_SEC_SRC_STATUS_ERROR_MINOR
|| t->wrsLeapSecStatus == WRS_LEAP_SEC_STATUS_ERROR_MINOR
|| t->wrsLeapSecStatus == WRS_LEAP_SEC_STATUS_WARNING
|| t->wrsSystemClockStatus == WRS_SYSTEM_CLOCK_STATUS_ERROR_MINOR
) { /* warning */ ) { /* warning */
wrsGeneralStatus_s.wrsTimingStatus = wrsGeneralStatus_s.wrsTimingStatus =
WRS_TIMING_STATUS_WARNING; WRS_TIMING_STATUS_WARNING;
...@@ -115,6 +124,9 @@ time_t wrsGeneralStatus_data_fill(void) ...@@ -115,6 +124,9 @@ time_t wrsGeneralStatus_data_fill(void)
|| t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_WARNING_NA || t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_WARNING_NA
|| t->wrsPTPFramesFlowing == 0 || t->wrsPTPFramesFlowing == 0
|| t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_WARNING_NA || t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_WARNING_NA
|| t->wrsLeapSecStatus == 0
|| t->wrsSystemClockStatus == 0
|| t->wrsLeapSecSourceStatus == 0
) { /* warning NA */ ) { /* warning NA */
wrsGeneralStatus_s.wrsTimingStatus = wrsGeneralStatus_s.wrsTimingStatus =
WRS_TIMING_STATUS_WARNING_NA; WRS_TIMING_STATUS_WARNING_NA;
...@@ -126,6 +138,10 @@ time_t wrsGeneralStatus_data_fill(void) ...@@ -126,6 +138,10 @@ time_t wrsGeneralStatus_data_fill(void)
&& t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_OK && t->wrsSlaveLinksStatus == WRS_SLAVE_LINK_STATUS_OK
&& (t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_OK && (t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_OK
|| t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_FR) /* FR */ || t->wrsPTPFramesFlowing == WRS_PTP_FRAMES_FLOWING_FR) /* FR */
&& (t->wrsSystemClockStatus==WRS_SYSTEM_CLOCK_STATUS_OK)
&& t->wrsLeapSecStatus == WRS_LEAP_SEC_STATUS_OK
&& t->wrsLeapSecSourceStatus == WRS_LEAP_SEC_SRC_STATUS_OK
) { /* OK */ ) { /* OK */
wrsGeneralStatus_s.wrsTimingStatus = wrsGeneralStatus_s.wrsTimingStatus =
WRS_TIMING_STATUS_OK; WRS_TIMING_STATUS_OK;
......
...@@ -72,7 +72,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows) ...@@ -72,7 +72,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
char *tmp_name; char *tmp_name;
portDS_t *portDS_i; portDS_t *portDS_i;
struct hal_port_state *p; struct hal_port_state *p;
int phys_port; int phys_port=0;
int last_port = 0; int last_port = 0;
int instance_on_port = 0; int instance_on_port = 0;
char *tmpstr_p; char *tmpstr_p;
...@@ -98,7 +98,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows) ...@@ -98,7 +98,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
p_a = wrsPortStatusTable_array; p_a = wrsPortStatusTable_array;
/* check whether shmem is available */ /* check whether shmem is available */
if (!shmem_ready_ppsi() && !ppsi_ppi_nlinks) { if (!shmem_ready_ppsi() || ppsi_ppi_nlinks==NULL) {
snmp_log(LOG_ERR, "%s: Unable to read PPSI's shmem\n", __func__); snmp_log(LOG_ERR, "%s: Unable to read PPSI's shmem\n", __func__);
/* If set to 0 all PPSI related OIDs disappear */ /* If set to 0 all PPSI related OIDs disappear */
n_rows_local = 0; n_rows_local = 0;
...@@ -164,7 +164,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows) ...@@ -164,7 +164,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
i_a[i].wrsPtpInstanceAsymConstAsymPS = (int64_t)((((float)ppsi_i->asymmetryCorrectionPortDS.constantAsymmetry)/(1<<16))*1000); i_a[i].wrsPtpInstanceAsymConstAsymPS = (int64_t)((((float)ppsi_i->asymmetryCorrectionPortDS.constantAsymmetry)/(1<<16))*1000);
i_a[i].wrsPtpInstanceAsymScDelayCoef = ppsi_i->asymmetryCorrectionPortDS.scaledDelayCoefficient; i_a[i].wrsPtpInstanceAsymScDelayCoef = ppsi_i->asymmetryCorrectionPortDS.scaledDelayCoefficient;
tmpstr_p = i_a[i].wrsPtpInstanceAsymScDelayCoefHR; tmpstr_p = i_a[i].wrsPtpInstanceAsymScDelayCoefHR;
tmp_f = ((float)ppsi_i->asymmetryCorrectionPortDS.scaledDelayCoefficient)/((1<<62)); tmp_f = ((float)ppsi_i->asymmetryCorrectionPortDS.scaledDelayCoefficient)/(((uint64_t)1<<62));
snprintf(tmpstr_p, 64, "%f,", tmp_f); snprintf(tmpstr_p, 64, "%f,", tmp_f);
i_a[i].wrsPtpInstanceTSCorrEgressLat = ppsi_i->timestampCorrectionPortDS.egressLatency; i_a[i].wrsPtpInstanceTSCorrEgressLat = ppsi_i->timestampCorrectionPortDS.egressLatency;
......
#include "wrsSnmp.h" #include "wrsSnmp.h"
#include <libwr/util.h>
#include <libwr/config.h>
#include <snmp_shmem.h> #include <snmp_shmem.h>
#include "wrsPtpDataTable.h" #include "wrsPtpDataTable.h"
#include "wrsSpllStatusGroup.h" #include "wrsSpllStatusGroup.h"
#include "wrsPortStatusTable.h" #include "wrsPortStatusTable.h"
#include "wrsPtpInstanceTable.h" #include "wrsPtpInstanceTable.h"
#include "wrsTimingStatusGroup.h" #include "wrsTimingStatusGroup.h"
#include "wrsCurrentTimeGroup.h"
/* Macros for fscanf function to read line with maximum of "x" characters
* without new line. Macro expands to something like: "%10[^\n]" */
#define LINE_READ_LEN_HELPER(x) "%"#x"[^\n]"
#define LINE_READ_LEN(x) LINE_READ_LEN_HELPER(x)
#define WRS_SYSTEMCLOCK_STATUS_CACHE_TIMEOUT 20 /* 20 seconds */
#define WRS_LEAPSEC_STATUS_CACHE_TIMEOUT 20 /* 20 seconds */
#define WRS_LEAPSEC_DOWNLOAD_CACHE_TIMEOUT 20 /* 20 seconds */
static struct pickinfo wrsTimingStatus_pickinfo[] = { static struct pickinfo wrsTimingStatus_pickinfo[] = {
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsPTPStatus), FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsPTPStatus),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsSoftPLLStatus), FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsSoftPLLStatus),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsSlaveLinksStatus), FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsSlaveLinksStatus),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsPTPFramesFlowing), FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsPTPFramesFlowing),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsSystemClockStatus),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsLeapSecStatus),
FIELD(wrsTimingStatus_s, ASN_INTEGER, wrsLeapSecSourceStatus),
}; };
struct wrsTimingStatus_s wrsTimingStatus_s; struct wrsTimingStatus_s wrsTimingStatus_s;
...@@ -24,6 +39,9 @@ static void get_wrsPTPStatus(unsigned int ptp_data_nrows, int t_delta); ...@@ -24,6 +39,9 @@ static void get_wrsPTPStatus(unsigned int ptp_data_nrows, int t_delta);
static void get_wrsSoftPLLStatus(); static void get_wrsSoftPLLStatus();
static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows); static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows);
static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows); static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows);
static void get_wrsSystemClockStatus(void);
static void get_wrsLeapSecondStatus(void);
static void get_wrsLeapSecondSourceStatus(void);
time_t wrsTimingStatus_data_fill(void) time_t wrsTimingStatus_data_fill(void)
{ {
...@@ -34,6 +52,8 @@ time_t wrsTimingStatus_data_fill(void) ...@@ -34,6 +52,8 @@ time_t wrsTimingStatus_data_fill(void)
time_t time_ptp_instance; /* time when wrsPtpInstanceTable was updated */ time_t time_ptp_instance; /* time when wrsPtpInstanceTable was updated */
static time_t time_ptp_data_prev; /* time when previous wrsPtpDataTable static time_t time_ptp_data_prev; /* time when previous wrsPtpDataTable
* table was updated */ * table was updated */
static time_t time_current_time; /* time when previous wrsCurrentTime was updated */
unsigned int ptp_data_nrows; /* number of rows in wrsPtpDataTable */ unsigned int ptp_data_nrows; /* number of rows in wrsPtpDataTable */
unsigned int port_status_nrows; /* number of rows in PortStatusTable */ unsigned int port_status_nrows; /* number of rows in PortStatusTable */
unsigned int ptp_instance_nrows; unsigned int ptp_instance_nrows;
...@@ -42,6 +62,7 @@ time_t wrsTimingStatus_data_fill(void) ...@@ -42,6 +62,7 @@ time_t wrsTimingStatus_data_fill(void)
time_spll = wrsSpllStatus_data_fill(); time_spll = wrsSpllStatus_data_fill();
time_port_status = wrsPortStatusTable_data_fill(&port_status_nrows); time_port_status = wrsPortStatusTable_data_fill(&port_status_nrows);
time_ptp_instance = wrsPtpInstanceTable_data_fill(&ptp_instance_nrows); time_ptp_instance = wrsPtpInstanceTable_data_fill(&ptp_instance_nrows);
time_current_time = wrsCurrentTime_data_fill();
if (ptp_data_nrows > WRS_MAX_N_SERVO_INSTANCES) { if (ptp_data_nrows > WRS_MAX_N_SERVO_INSTANCES) {
snmp_log(LOG_ERR, "SNMP: wrsTimingStatusGroup too many PTP " snmp_log(LOG_ERR, "SNMP: wrsTimingStatusGroup too many PTP "
...@@ -60,7 +81,8 @@ time_t wrsTimingStatus_data_fill(void) ...@@ -60,7 +81,8 @@ time_t wrsTimingStatus_data_fill(void)
if (time_ptp_data <= time_update if (time_ptp_data <= time_update
&& time_spll <= time_update && time_spll <= time_update
&& time_port_status <= time_update && time_port_status <= time_update
&& time_ptp_instance <= time_update) { && time_ptp_instance <= time_update
&& time_current_time <= time_update) {
/* cache not updated, return last update time */ /* cache not updated, return last update time */
return time_update; return time_update;
} }
...@@ -86,11 +108,17 @@ time_t wrsTimingStatus_data_fill(void) ...@@ -86,11 +108,17 @@ time_t wrsTimingStatus_data_fill(void)
get_wrsPTPFramesFlowing(port_status_nrows); get_wrsPTPFramesFlowing(port_status_nrows);
} }
time_update = get_monotonic_sec(); if ( time_current_time > time_update) {
get_wrsLeapSecondStatus();
get_wrsSystemClockStatus();
get_wrsLeapSecondSourceStatus();
}
/* save the time of the last ptp_data copy */ /* save the time of the last ptp_data copy */
time_ptp_data_prev = time_ptp_data; time_ptp_data_prev = time_ptp_data;
/* there was an update, return current time */ /* there was an update, return current time */
return time_update; return time_update=get_monotonic_sec();
} }
static void get_wrsPTPStatus(unsigned int ptp_data_nrows, int t_delta) static void get_wrsPTPStatus(unsigned int ptp_data_nrows, int t_delta)
...@@ -314,13 +342,87 @@ static void get_wrsSoftPLLStatus(void) ...@@ -314,13 +342,87 @@ static void get_wrsSoftPLLStatus(void)
spll_DelCnt_prev = s->wrsSpllDelCnt; spll_DelCnt_prev = s->wrsSpllDelCnt;
} }
static void get_wrsSystemClockStatus(void){
struct wrsCurrentTime_s *t=&wrsCurrentTime_s;
int status=0;
switch (t->wrsSystemClockStatusDetails) {
case WRS_SYSTEM_CLOCK_STATUS_DETAILS_OK :
status=WRS_SYSTEM_CLOCK_STATUS_OK;
break;
case WRS_SYSTEM_CLOCK_STATUS_DETAILS_IO_ERROR :
status=WRS_SYSTEM_CLOCK_STATUS_ERROR_MINOR;
break;
case WRS_SYSTEM_CLOCK_STATUS_DETAILS_UNKNOWN :
status=WRS_SYSTEM_CLOCK_STATUS_ERROR;
break;
case WRS_SYSTEM_CLOCK_STATUS_DETAILTS_THRESHOLD_EXCEEDED :
status=WRS_SYSTEM_CLOCK_STATUS_THRESHOLD_EXCEEDED;
break;
}
wrsTimingStatus_s.wrsSystemClockStatus = status;
}
static void get_wrsLeapSecondStatus(void){
struct wrsCurrentTime_s *t=&wrsCurrentTime_s;
struct wrsSpllStatus_s *s=&wrsSpllStatus_s;
int status=0;
switch (t->wrsLeapSecStatusDetails ) {
case WRS_LEAP_SEC_STATUS_DETAILS_OK :
case WRS_LEAP_SEC_STATUS_DETAILS_SEC_INSERTED:
case WRS_LEAP_SEC_STATUS_DETAILS_SEC_DELETED:
status=WRS_LEAP_SEC_STATUS_OK;
break;
case WRS_LEAP_SEC_STATUS_DETAILS_IO_ERROR:
status=WRS_LEAP_SEC_STATUS_ERROR_MINOR;
break;
case WRS_LEAP_SEC_STATUS_DETAILS_UNKNOWN:
case WRS_LEAP_SEC_STATUS_DETAILS_INTERNAL_ERROR:
case WRS_LEAP_SEC_STATUS_DETAILS_TAI_READ_ERROR:
status=WRS_LEAP_SEC_STATUS_ERROR;
break;
case WRS_LEAP_SEC_STATUS_DETAILS_FILE_EXPIRED:
status = ( s->wrsSpllMode == WRS_SPLL_MODE_GRAND_MASTER
|| s->wrsSpllMode == WRS_SPLL_MODE_MASTER)
? WRS_LEAP_SEC_STATUS_WARNING : WRS_LEAP_SEC_STATUS_DETAILS_OK;
break;
}
wrsTimingStatus_s.wrsLeapSecStatus = status;
}
static void get_wrsLeapSecondSourceStatus(void){
struct wrsCurrentTime_s *t=&wrsCurrentTime_s;
int status=0;
switch (t->wrsLeapSecSourceStatusDetails ) {
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_OK :
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_UPDATED:
status = WRS_LEAP_SEC_SRC_STATUS_OK;
break;
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_IO_ERROR:
status = WRS_LEAP_SEC_SRC_STATUS_ERROR_MINOR;
break;
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_UNKNOWN:
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_DHCP_ERROR:
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_INVALID_URL:
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_INVALID_FILE:
case WRS_LEAP_SEC_SRC_STATUS_DETAILS_DOWNLOAD_ERROR:
status = WRS_LEAP_SEC_SRC_STATUS_ERROR;
break;
}
wrsTimingStatus_s.wrsLeapSecSourceStatus = status;
}
static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
{ {
struct wrsSpllStatus_s *s; // struct wrsSpllStatus_s *s;
struct wrsPortStatusTable_s *p_a; struct wrsPortStatusTable_s *p_a;
struct wrsPtpInstanceTable_s *i_a; struct wrsPtpInstanceTable_s *i_a;
struct wrsTimingStatus_s *t; struct wrsTimingStatus_s *t;
struct pp_instance *ppsi_i; // struct pp_instance *ppsi_i;
int phys_port; int phys_port;
int has_slave = 0; int has_slave = 0;
int i; int i;
...@@ -333,7 +435,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -333,7 +435,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
* and when every slave port is down when switch in master/grandmaster * and when every slave port is down when switch in master/grandmaster
* mode. Don't care about non-wr, none and auto ports. * mode. Don't care about non-wr, none and auto ports.
*/ */
s = &wrsSpllStatus_s; // s = &wrsSpllStatus_s;
p_a = wrsPortStatusTable_array; p_a = wrsPortStatusTable_array;
i_a = wrsPtpInstanceTable_array; i_a = wrsPtpInstanceTable_array;
t = &wrsTimingStatus_s; t = &wrsTimingStatus_s;
...@@ -341,14 +443,14 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -341,14 +443,14 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_OK; t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_OK;
if (!shmem_ready_hald()) { if (!shmem_ready_hald() || !shmem_ready_ppsi()) {
/* HAL shmem not available yet */ /* HAL shmem not available yet */
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA; t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA;
return; return;
} }
for (i = 0; i < *ppsi_ppi_nlinks; i++) { for (i = 0; i < *ppsi_ppi_nlinks; i++) {
ppsi_i = ppsi_ppi + i; // ppsi_i = ppsi_ppi + i;
/* wrsSlaveLinksStatus is ERROR if any of the instances are ERROR */ /* wrsSlaveLinksStatus is ERROR if any of the instances are ERROR */
if (i_a[i].wrsPtpInstanceStatusError == WRS_SLAVE_LINK_STATUS_ERROR) { if (i_a[i].wrsPtpInstanceStatusError == WRS_SLAVE_LINK_STATUS_ERROR) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR; t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR;
...@@ -452,6 +554,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows) ...@@ -452,6 +554,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
first_run = 0; first_run = 0;
} }
#define GT_OID WRSTIMINGSTATUS_OID #define GT_OID WRSTIMINGSTATUS_OID
#define GT_PICKINFO wrsTimingStatus_pickinfo #define GT_PICKINFO wrsTimingStatus_pickinfo
#define GT_DATA_FILL_FUNC wrsTimingStatus_data_fill #define GT_DATA_FILL_FUNC wrsTimingStatus_data_fill
......
...@@ -28,11 +28,28 @@ ...@@ -28,11 +28,28 @@
* normal operation */ * normal operation */
#define WRS_PTP_FRAMES_FLOWING_FR 6 /* ok, first run */ #define WRS_PTP_FRAMES_FLOWING_FR 6 /* ok, first run */
#define WRS_SYSTEM_CLOCK_STATUS_OK 1 /* ok */
#define WRS_SYSTEM_CLOCK_STATUS_ERROR 2 /* error */
#define WRS_SYSTEM_CLOCK_STATUS_ERROR_MINOR 3 /* error minor */
#define WRS_SYSTEM_CLOCK_STATUS_THRESHOLD_EXCEEDED 4 /* Threshold exceeded */
#define WRS_LEAP_SEC_STATUS_OK 1 /* Everything ok */
#define WRS_LEAP_SEC_STATUS_ERROR 2 /* Error detected */
#define WRS_LEAP_SEC_STATUS_ERROR_MINOR 3 /* Minor error detected */
#define WRS_LEAP_SEC_STATUS_WARNING 4 /* The current leap second file is out-dated */
#define WRS_LEAP_SEC_SRC_STATUS_OK 1 /* Everything ok */
#define WRS_LEAP_SEC_SRC_STATUS_ERROR 2 /* Error detected */
#define WRS_LEAP_SEC_SRC_STATUS_ERROR_MINOR 3 /* Minor error detected */
struct wrsTimingStatus_s { struct wrsTimingStatus_s {
int wrsPTPStatus; int wrsPTPStatus;
int wrsSoftPLLStatus; int wrsSoftPLLStatus;
int wrsSlaveLinksStatus; int wrsSlaveLinksStatus;
int wrsPTPFramesFlowing; int wrsPTPFramesFlowing;
int wrsSystemClockStatus;
int wrsLeapSecSourceStatus;
int wrsLeapSecStatus;
}; };
extern struct wrsTimingStatus_s wrsTimingStatus_s; extern struct wrsTimingStatus_s wrsTimingStatus_s;
......
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