Commit db86a97f authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add three objects to wrsNetworkingStatusGroup

Objects added:
--wrsEndpointStatus
--wrsSwcoreStatus
--wrsRTUStatus

--update MIB
--add parameters to Kconfig
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 6075b68e
......@@ -396,6 +396,25 @@ config SNMP_TEMP_THOLD_PSR
WR-SWITCH-MIB::wrsTemperatureWarning
Require hal restart after change
config SNMP_SWCORESTATUS_HP_FRAME_RATE
int "Maximum allowed rate of HP frames on a port"
default "0"
help
Error via SNMP if rate of HP frames on any port exceed given value.
config SNMP_SWCORESTATUS_RX_FRAME_RATE
int "Maximum allowed rate of RX frames on a port"
default "0"
help
Error via SNMP if rate of RX frames on any port exceed given value.
config SNMP_SWCORESTATUS_RX_PRIO_FRAME_RATE
int "Maximum allowed rate of any RX priority"
default "0"
help
Error if frame rate of any RX priority exceed given value.
endmenu
config PTP_CUSTOM_FILENAME
......
......@@ -138,6 +138,57 @@ wrsSFPsStatus OBJECT-TYPE
bug - bug in checking conditions of SFPs, please report"
::= { wrsNetworkingStatusGroup 1 }
wrsEndpointStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
firstRead(1),
ok(2),
error(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Check itmes described in 2.2.2 Fault in the Endpoint's transmission/reception
path in wrs_failures document.
firstRead - cannot derermine change rate from olny one read
ok - parameters below limits
error - parameters above limits"
::= { wrsNetworkingStatusGroup 2 }
wrsSwcoreStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
firstRead(1),
ok(2),
error(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Check itmes described in 2.2.3 Problem with the SwCore or Endpoint HDL
module and 2.2.5 Too much HP traffic / Per-priority queue full
in wrs_failures document.
firstRead - cannot derermine change rate from olny one read
ok - parameters below limits
error - parameters above limits"
::= { wrsNetworkingStatusGroup 3 }
wrsRTUStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
firstRead(1),
ok(2),
error(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Check itmes described in 2.2.4 RTU is full and cannot accept more requests
in wrs_failures document.
firstRead - cannot derermine change rate from olny one read
ok - parameters below limits
error - parameters above limits"
::= { wrsNetworkingStatusGroup 4 }
-- wrsVersionGroup (.6.3)
wrsVersionGroup OBJECT IDENTIFIER ::= { wrsStatus 3 }
......
#include "wrsSnmp.h"
#include "wrsPortStatusTable.h"
#include "wrsPstatsTable.h"
#include "wrsNetworkingStatusGroup.h"
#include <libwr/config.h>
static struct pickinfo wrsNetworkingStatus_pickinfo[] = {
FIELD(wrsNetworkingStatus_s, ASN_INTEGER, wrsSFPsStatus),
FIELD(wrsNetworkingStatus_s, ASN_INTEGER, wrsEndpointStatus),
FIELD(wrsNetworkingStatus_s, ASN_INTEGER, wrsSwcoreStatus),
FIELD(wrsNetworkingStatus_s, ASN_INTEGER, wrsRTUStatus),
};
struct wrsNetworkingStatus_s wrsNetworkingStatus_s;
static struct wrsNetworkingStatus_config ns_dotconfig;
static struct ns_pstats ns_pstats_copy[WRS_N_PORTS];
static void copy_pstats(struct ns_pstats *copy, struct wrsPstatsTable_s *org,
unsigned int rows)
{
int i;
for (i = 0; i < rows; i++) {
/* wrsEndpointStatus */
copy->TXUnderrun = org->TXUnderrun;
copy->RXOverrun = org->RXOverrun;
copy->RXInvalidCode = org->RXInvalidCode;
copy->RXSyncLost = org->RXSyncLost;
copy->RXPfilterDropped = org->RXPfilterDropped;
copy->RXPCSErrors = org->RXPCSErrors;
copy->RXCRCErrors = org->RXCRCErrors;
/* wrsSwcoreStatus */
copy->RXFrames = org->RXFrames;
copy->RXPrio0 = org->RXPrio0;
copy->RXPrio1 = org->RXPrio1;
copy->RXPrio2 = org->RXPrio2;
copy->RXPrio3 = org->RXPrio3;
copy->RXPrio4 = org->RXPrio4;
copy->RXPrio5 = org->RXPrio5;
copy->RXPrio6 = org->RXPrio6;
copy->RXPrio7 = org->RXPrio7;
copy->FastMatchPriority = org->FastMatchPriority;
/* wrsRTUStatus */
copy->RXDropRTUFull = org->RXDropRTUFull;
copy++;
org++;
}
}
static int get_endpoint_status(struct ns_pstats *old,
struct wrsPstatsTable_s *new, unsigned int rows,
float t_delta)
{
int i;
int ret;
ret = 0;
/* values from 2.2.2 "Fault in the Endpoint’s transmission/reception
* path" in wrs_failures document shouldn't change faster than 1
* per second */
for (i = 0; i < rows; i++) {
if (
((new[i].TXUnderrun - old[i].TXUnderrun)/t_delta > 1.0)
|| ((new[i].RXOverrun - old[i].RXOverrun)/t_delta > 1.0)
|| ((new[i].RXInvalidCode - old[i].RXInvalidCode)/t_delta > 1.0)
|| ((new[i].RXSyncLost - old[i].RXSyncLost)/t_delta > 1.0)
|| ((new[i].RXPfilterDropped - old[i].RXPfilterDropped)/t_delta > 1.0)
|| ((new[i].RXPCSErrors - old[i].RXPCSErrors)/t_delta > 1.0)
|| ((new[i].RXCRCErrors - old[i].RXCRCErrors)/t_delta > 1.0)
) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d\n", i);
}
}
return ret;
}
static int get_swcore_status(struct ns_pstats *old,
struct wrsPstatsTable_s *new, unsigned int rows,
float t_delta)
{
int i;
int ret;
ret = 0;
for (i = 0; i < rows; i++) {
/* TXFrames and Forwarded described in 2.2.3 "Problem with the
* SwCore or Endpoint HDL module" in wrs_failures document
* shouldn't differ more than FORWARD_DELTA in total */
/* counter Forwarded (38) is not implemented in HDL!!! */
#if 0
if ( /* shouldn't differ more than FORWARD_DELTA */
((new[i].TXFrames - new[i].Forwarded) > FORWARD_DELTA)
|| ((new[i].Forwarded - new[i].TXFrames) > FORWARD_DELTA)
) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for "
"port %d\n", i);
}
#endif
/* values from 2.2.5 "Too much HP traffic / Per-priority queue
* full" in wrs_failures document shouldn't change faster
* than parameters defined in dotconfig per second */
if ( /* shouldn't differ more than FORWARD_DELTA */
((new[i].RXFrames - old[i].RXFrames)/t_delta >= ns_dotconfig.rx_frame_rate)
|| ((new[i].RXPrio0 - old[i].RXPrio0)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio1 - old[i].RXPrio1)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio2 - old[i].RXPrio2)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio3 - old[i].RXPrio3)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio4 - old[i].RXPrio4)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio5 - old[i].RXPrio5)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio6 - old[i].RXPrio6)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].RXPrio7 - old[i].RXPrio7)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].FastMatchPriority - old[i].FastMatchPriority)/t_delta >= ns_dotconfig.hp_frame_rate)
) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for "
"port %d\n", i);
}
}
return ret;
}
static int get_rtu_status(struct ns_pstats *old,
struct wrsPstatsTable_s *new, unsigned int rows,
float t_delta)
{
int i;
int ret;
ret = 0;
/* values from 2.2.4 "RTU is full and cannot accept more requests" in
* wrs_failures document shouldn't increase */
for (i = 0; i < rows; i++) {
if ((new[i].TXUnderrun - old[i].TXUnderrun) > 0) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d\n", i);
}
}
/* TODO: add 2.2.7 "Network loop - two or more identical MACs on two or
* more ports" when implemented */
return ret;
}
/* read configuration from dotconfig */
static void load_dot_config(void)
{
char *tmp;
tmp = libwr_cfg_get("SNMP_SWCORESTATUS_HP_FRAME_RATE");
if (tmp)
ns_dotconfig.hp_frame_rate = atoi(tmp);
tmp = libwr_cfg_get("SNMP_SWCORESTATUS_RX_FRAME_RATE");
if (tmp)
ns_dotconfig.rx_frame_rate = atoi(tmp);
tmp = libwr_cfg_get("SNMP_SWCORESTATUS_RX_PRIO_FRAME_RATE");
if (tmp)
ns_dotconfig.rx_prio_frame_rate = atoi(tmp);
}
time_t wrsNetworkingStatus_data_fill(void)
{
static time_t time_update; /* time of last update */
time_t time_port_status; /* time when port status table was updated */
time_t time_pstats; /* time when pstats table was updated */
float time_pstats_delta; /* seconds since last update */
static time_t time_pstats_prev; /* time when previous state of pstats
* table was updated */
unsigned int port_status_nrows; /* number of rows in PortStatusTable */
unsigned int pstats_nrows; /* number of rows in PstatsTable */
unsigned int port_status_n_ok; /* number of ok ports */
unsigned int port_status_n_error; /* number of error ports */
unsigned int port_status_n_down; /* number of down ports */
unsigned int port_status_n_na; /* number of N/A ports */
int i;
int ret;
struct wrsPortStatusTable_s *p_a;
static int run_once = 1;
time_port_status = wrsPortStatusTable_data_fill(&port_status_nrows);
time_pstats = wrsPstatsTable_data_fill(&pstats_nrows);
if (time_port_status <= time_update) {
if (time_port_status <= time_update
&& time_pstats <= time_update) {
/* cache not updated, return last update time */
return time_update;
}
time_update = time(NULL);
if (run_once) {
run_once = 0;
/* read configuration from dotconfig */
load_dot_config();
}
time_pstats_delta = time_pstats - time_pstats_prev;
memset(&wrsNetworkingStatus_s, 0, sizeof(wrsNetworkingStatus_s));
/*********************************************************************\
......@@ -76,6 +253,66 @@ time_t wrsNetworkingStatus_data_fill(void)
wrsNetworkingStatus_s.wrsSFPsStatus = WRS_SFPS_STATUS_BUG;
}
/*********************************************************************\
|************************* wrsEndpointStatus *************************|
\*********************************************************************/
if (time_pstats_prev) { /* never generate error during first check */
ret = get_endpoint_status(ns_pstats_copy, pstats_array,
pstats_nrows, time_pstats_delta);
if (ret == 0)
wrsNetworkingStatus_s.wrsEndpointStatus =
WRS_ENDPOINT_STATUS_OK;
else
wrsNetworkingStatus_s.wrsEndpointStatus =
WRS_ENDPOINT_STATUS_ERROR;
} else {
/* first read */
wrsNetworkingStatus_s.wrsEndpointStatus =
WRS_ENDPOINT_STATUS_FR;
}
/*********************************************************************\
|************************** wrsSwcoreStatus **************************|
\*********************************************************************/
if (time_pstats_prev) { /* never generate error during first check */
ret = get_swcore_status(ns_pstats_copy, pstats_array,
pstats_nrows, time_pstats_delta);
if (ret == 0)
wrsNetworkingStatus_s.wrsSwcoreStatus =
WRS_SWCORE_STATUS_OK;
else
wrsNetworkingStatus_s.wrsSwcoreStatus =
WRS_SWCORE_STATUS_ERROR;
} else {
/* first read */
wrsNetworkingStatus_s.wrsSwcoreStatus = WRS_SWCORE_STATUS_FR;
}
/*********************************************************************\
|*************************** wrsRTUStatus ***************************|
\*********************************************************************/
if (time_pstats_prev) { /* never generate error during first check */
ret = get_rtu_status(ns_pstats_copy, pstats_array,
pstats_nrows, time_pstats_delta);
if (ret == 0)
wrsNetworkingStatus_s.wrsRTUStatus =
WRS_RTU_STATUS_OK;
else
wrsNetworkingStatus_s.wrsRTUStatus =
WRS_RTU_STATUS_ERROR;
} else {
/* first read */
wrsNetworkingStatus_s.wrsRTUStatus = WRS_RTU_STATUS_FR;
}
/* save time of pstats copy */
time_pstats_prev = time_pstats;
/* copy current set of pstats */
copy_pstats(ns_pstats_copy, pstats_array, pstats_nrows);
/* there was an update, return current time */
return time_update;
}
......
......@@ -3,6 +3,8 @@
#define WRSNETWORKINGSTATUS_OID WRS_OID, 6, 2, 3
#define FORWARD_DELTA 5
#define WRS_SFPS_STATUS_OK 1 /* ok */
#define WRS_SFPS_STATUS_ERROR 2 /* error */
#define WRS_SFPS_STATUS_WARNING 3 /* warning, not used */
......@@ -11,12 +13,59 @@
* normal operation */
#define WRS_SFPS_STATUS_BUG 5 /* warning */
#define WRS_ENDPOINT_STATUS_FR 1 /* ok, first read */
#define WRS_ENDPOINT_STATUS_OK 2 /* ok */
#define WRS_ENDPOINT_STATUS_ERROR 3 /* error */
#define WRS_SWCORE_STATUS_FR 1 /* ok, first read */
#define WRS_SWCORE_STATUS_OK 2 /* ok */
#define WRS_SWCORE_STATUS_ERROR 3 /* error */
#define WRS_RTU_STATUS_FR 1 /* ok, first read */
#define WRS_RTU_STATUS_OK 2 /* ok */
#define WRS_RTU_STATUS_ERROR 3 /* error */
struct wrsNetworkingStatus_s {
int wrsSFPsStatus;
int wrsEndpointStatus;
int wrsSwcoreStatus;
int wrsRTUStatus;
};
extern struct wrsNetworkingStatus_s wrsNetworkingStatus_s;
time_t wrsNetworkingStatus_data_fill(void);
void init_wrsNetworkingStatusGroup(void);
struct ns_pstats {
/* wrsEndpointStatus */
uint32_t TXUnderrun; /* 1 */
uint32_t RXOverrun; /* 2 */
uint32_t RXInvalidCode; /* 3 */
uint32_t RXSyncLost; /* 4 */
uint32_t RXPfilterDropped; /* 6 */
uint32_t RXPCSErrors; /* 7 */
uint32_t RXCRCErrors; /* 10 */
/* wrsSwcoreStatus */
/* Too much HP traffic / Per-priority queue full */
uint32_t RXFrames; /* 20 */
uint32_t RXPrio0; /* 22 */
uint32_t RXPrio1; /* 23 */
uint32_t RXPrio2; /* 24 */
uint32_t RXPrio3; /* 25 */
uint32_t RXPrio4; /* 26 */
uint32_t RXPrio5; /* 27 */
uint32_t RXPrio6; /* 28 */
uint32_t RXPrio7; /* 29 */
uint32_t FastMatchPriority; /* 33 */
/* wrsRTUStatus */
uint32_t RXDropRTUFull; /* 21 */
};
/* parameters read from dot-config */
struct wrsNetworkingStatus_config {
int hp_frame_rate;
int rx_frame_rate;
int rx_prio_frame_rate;
};
#endif /* WRS_NETWORKING_STATUS_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