Commit 1b9cb6f3 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

Merge branch 'ML-SNMP-improvments' into greg-proposed_master

parents eec4846d b066b6e7
......@@ -622,7 +622,7 @@
\snmpentrye{WR-SWITCH-MIB}{wrsPtpDataTable}{wrsPtpServoUpdateTime.<n>}{
TAI Nanosecond of the last servo's update.}
\snmpentrye{WR-SWITCH-MIB}{}{wrsPortStatusTable}{Table with a row per port.}
\snmpentrye{WR-SWITCH-MIB}{}{wrsPortStatusTable}{Table with a port per row.}
\snmpentrye{WR-SWITCH-MIB}{wrsPortStatusTable}{wrsPortStatusIndex.<n>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPortStatusTable}{wrsPortStatusPortName.<n>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPortStatusTable}{wrsPortStatusLink.<n>}{}
......@@ -645,6 +645,27 @@
\snmpentrye{WR-SWITCH-MIB}{wrsPortStatusTable}{wrsPortStatusSfpTxPower.<n>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPortStatusTable}{wrsPortStatusSfpRxPower.<n>}{}
\snmpentrye{WR-SWITCH-MIB}{}{wrsPtpInstanceTable}{Table with all PTP instances.
This table has two indexes. The first one \textit{n}, corresponds to port
number to which a particular instance is assigned, the second index \textit{m},
is a serial number of an instance on particular port.}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePortIndex.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceOnPortIndex.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceName.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePort.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePortInstance.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePortName.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceState.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceStateNext.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceRole.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceMechanism.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceProto.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceExt.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePeerMac.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstancePeerVid.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceVlanNum.<n>.<m>}{}
\snmpentrye{WR-SWITCH-MIB}{wrsPtpInstanceTable}{wrsPtpInstanceVlanListStr.<n>.<m>}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add entries from other MIBs.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
......@@ -57,7 +57,7 @@
#define ALIGN_STATE_WAIT_CLKIN 9
#define ALIGN_STATE_WAIT_PLOCK 10
#define SPLL_STATS_VER 2
#define SPLL_STATS_VER 3
/* info reported through .stat section */
/* due to endiannes problem strings has to be 4 bytes alligned */
......
......@@ -51,6 +51,7 @@ SOURCES = \
wrsPstatsHCTable.c \
wrsPtpDataTable.c \
wrsPortStatusTable.c \
wrsPtpInstanceTable.c \
init.c \
MIBS = WR-SWITCH-MIB.txt
......
This diff is collapsed.
......@@ -26,6 +26,7 @@
#include "wrsPtpDataTable.h"
#include "wrsPortStatusTable.h"
#include "wrsPstatsHCTable.h"
#include "wrsPtpInstanceTable.h"
#define DOTCONFIG_FILE "/wr/etc/dot-config"
......@@ -59,6 +60,7 @@ void init_wrsSnmp(void)
init_wrsPtpDataTable();
init_wrsPortStatusTable();
init_wrsPstatsHCTable();
init_wrsPtpInstanceTable();
/* perform first reads, needed to calculate deltas later */
wrsTimingStatus_data_fill();
......
......@@ -10,8 +10,6 @@ int hal_nports_local;
/* PPSI */
struct wrs_shm_head *ppsi_head;
static struct pp_globals *ppg;
struct pp_servo *ppsi_servo;
struct wr_servo_state *ppsi_wr_servo;
struct pp_instance *ppsi_ppi;
int *ppsi_ppi_nlinks;
......@@ -122,15 +120,6 @@ static int init_shm_ppsi(void)
}
ppg = (void *)ppsi_head + ppsi_head->data_off;
/* TODO JCB Servo is part of an instance now */
ppsi_servo=NULL;
// ppsi_servo = wrs_shm_follow(ppsi_head, ppg->servo);
// if (!ppsi_servo) {
// snmp_log(LOG_ERR, "SNMP: " SL_ER
// "Cannot follow ppsi_servo in shmem.\n");
// return 4;
// }
ppsi_ppi = wrs_shm_follow(ppsi_head, ppg->pp_instances);
if (!ppsi_ppi) {
snmp_log(LOG_ERR, "SNMP: " SL_ER
......
......@@ -15,7 +15,6 @@ extern int hal_nports_local;
/* PPSI */
extern struct wrs_shm_head *ppsi_head;
extern struct pp_servo *ppsi_servo;
extern struct pp_instance *ppsi_ppi;
extern int *ppsi_ppi_nlinks;
......
......@@ -29,9 +29,18 @@ static struct pickinfo wrsPtpDataTable_pickinfo[] = {
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpClockOffsetErrCnt),
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpRTTErrCnt),
FIELD(wrsPtpDataTable_s, ASN_COUNTER64, wrsPtpServoUpdateTime),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpServoExt),
};
//FIXME: make a library in ppsi with all such functions, use it all around
int64_t pp_time_to_picos(struct pp_time *ts)
{
return ts->secs * PP_NSEC_PER_SEC
+ ((ts->scaled_nsecs * 1000 + 0x8000) >> TIME_INTERVAL_FRACBITS);
}
static int32_t int_saturate(int64_t value)
{
if (value >= INT32_MAX)
......@@ -49,6 +58,15 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
static time_t time_update;
time_t time_cur;
static int n_rows_local = 0;
int si = 0;
int i;
struct wrsPtpDataTable_s *ptp_a;
struct pp_instance *ppsi_i;
struct pp_servo *ppsi_servo;
struct wr_data *wr_d;
struct wr_servo_ext *wr_servo;
struct wrh_servo_t *wrh_servo;
char *tmp_name;
/* number of rows does not change for wrsPortStatusTable */
if (n_rows)
......@@ -80,37 +98,154 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
if (n_rows)
*n_rows = n_rows_local;
ptp_a = wrsPtpDataTable_array;
/* servo/slave instance counter */
si = 0;
/* assume that there is only one servo, will change when switchover is
* implemented */
while (1) {
ii = wrs_shm_seqbegin(ppsi_head);
for (i = 0; i < *ppsi_ppi_nlinks; i++)
{
/* report not more than max number of servo instances */
if( si >= WRS_MAX_N_SERVO_INSTANCES)
break;
ppsi_i = ppsi_ppi + i;
if (ppsi_i->state == PPS_SLAVE)
{
/*********** from ppsi instance ***************/
/* wrsPtpPortName */
tmp_name = (char *) wrs_shm_follow(ppsi_head,
ppsi_i->iface_name);
strncpy(ptp_a[si].wrsPtpPortName, tmp_name, 12);
ptp_a[si].wrsPtpPortName[11] = '\0';
/*********** from standard servo ***************/
/* get servo for ptp instance in Slave state*/
ppsi_servo = wrs_shm_follow(ppsi_head,
ppsi_i->servo);
/* wrsPtpGrandmasterID */
//TODO
/* wrsPtpOwnID */
//TODO
/* wrsPtpMode */
//TODO
/* wrsPtpServoState */
strncpy(ptp_a[si].wrsPtpServoState,
ppsi_servo->servo_state_name,
sizeof(ppsi_servo->servo_state_name));
/* wrsPtpServoStateN */
ptp_a[si].wrsPtpServoStateN = ppsi_servo->state;
/* wrsPtpClockOffsetPs */
ptp_a[si].wrsPtpClockOffsetPs =
pp_time_to_picos(&ppsi_servo->offsetFromMaster);
/* wrsPtpClockOffsetPsHR */
ptp_a[si].wrsPtpClockOffsetPsHR =
int_saturate(ptp_a[si].wrsPtpClockOffsetPs);
/* wrsPtpRTT */
ptp_a[si].wrsPtpRTT = 2*
pp_time_to_picos(&ppsi_servo->meanDelay);
/* wrsPtpLinkLength */
ptp_a[si].wrsPtpLinkLength =
(uint32_t)(pp_time_to_picos(&ppsi_servo->delayMS)
/1e12 * 300e6 / 1.55);
/* wrsPtpServoUpdates */
ptp_a[si].wrsPtpServoUpdates =
ppsi_servo->update_count;
/* wrsPtpServoUpdateTime */
ptp_a[si].wrsPtpServoUpdateTime =
ppsi_servo->update_time.secs * 1000 * 1000 * 1000
+ (ppsi_servo->update_time.scaled_nsecs >> 16);
/* wrsPtpServoExt */
ptp_a[si].wrsPtpServoExt = 1+
ppsi_i->protocol_extension;
/******** from extensions-specific ************/
if (ppsi_i->protocol_extension == PPSI_EXT_WR)
{
wr_d = (struct wr_data *)
wrs_shm_follow(ppsi_head,
ppsi_i->ext_data);
wr_servo = &wr_d->servo_ext;
wrh_servo = &wr_d->servo;
/* wrsPtpPhaseTracking */
ptp_a[si].wrsPtpPhaseTracking =
1 + wrh_servo->tracking_enabled;
/* wrsPtpSyncSource */
// TODO
/* wrsPtpSkew */
ptp_a[si].wrsPtpSkew =
int_saturate(wrh_servo->skew_ps);
/* wrsPtpDeltaTxM */
ptp_a[si].wrsPtpDeltaTxM =
pp_time_to_picos(&wr_servo->delta_txm);
/* wrsPtpDeltaRxM */
ptp_a[si].wrsPtpDeltaRxM =
pp_time_to_picos(&wr_servo->delta_rxm);
/* wrsPtpDeltaTxS */
ptp_a[si].wrsPtpDeltaTxS =
pp_time_to_picos(&wr_servo->delta_txs);
/* wrsPtpDeltaRxS */
ptp_a[si].wrsPtpDeltaRxS =
pp_time_to_picos(&wr_servo->delta_rxs);
/* wrsPtpServoStateErrCnt */
ptp_a[si].wrsPtpServoStateErrCnt =
wrh_servo->n_err_state;
/* wrsPtpClockOffsetErrCnt */
ptp_a[si].wrsPtpClockOffsetErrCnt =
wrh_servo->n_err_offset;
/* wrsPtpRTTErrCnt */
ptp_a[si].wrsPtpRTTErrCnt =
wrh_servo->n_err_delta_rtt;
}
else
{
memset(ptp_a[si].wrsPtpSyncSource,
0, 32 * sizeof(char));
ptp_a[si].wrsPtpPhaseTracking = 0;
ptp_a[si].wrsPtpSkew = 0;
ptp_a[si].wrsPtpDeltaTxM = 0;
ptp_a[si].wrsPtpDeltaRxM = 0;
ptp_a[si].wrsPtpDeltaTxS = 0;
ptp_a[si].wrsPtpDeltaRxS = 0;
ptp_a[si].wrsPtpServoStateErrCnt = 0;
ptp_a[si].wrsPtpClockOffsetErrCnt = 0;
ptp_a[si].wrsPtpRTTErrCnt = 0;
}
/* look for next PTP Instance in Slave state*/
si++;
}
}
//TODO JCB : Search servo instance to display
// strncpy(wrsPtpDataTable_array[0].wrsPtpServoState,
// ppsi_servo->servo_state_name,
// sizeof(ppsi_servo->servo_state_name));
// wrsPtpDataTable_array[0].wrsPtpServoStateN = ppsi_servo->state;
// /* Keep value 0 for Not available */
// wrsPtpDataTable_array[0].wrsPtpPhaseTracking = 0; //JCB TODO 1 + ppsi_servo->tracking_enabled;
// wrsPtpDataTable_array[0].wrsPtpRTT = 0; //JCB TODO ppsi_servo->picos_mu;
// wrsPtpDataTable_array[0].wrsPtpClockOffsetPs = pp_time_to_picos(&ppsi_servo->offsetFromMaster);
// wrsPtpDataTable_array[0].wrsPtpClockOffsetPsHR =
// int_saturate(wrsPtpDataTable_array[0].wrsPtpClockOffsetPs);
// wrsPtpDataTable_array[0].wrsPtpSkew = 0; //JCB TODO int_saturate(ppsi_servo->skew);
// wrsPtpDataTable_array[0].wrsPtpLinkLength =
// (uint32_t)(pp_time_to_picos(&ppsi_servo->delayMS)/1e12 * 300e6 / 1.55);
// wrsPtpDataTable_array[0].wrsPtpServoUpdates =
// ppsi_servo->update_count;
// wrsPtpDataTable_array[0].wrsPtpDeltaTxM = 0;//JCB TODO ppsi_servo->delta_txm_ps;
// wrsPtpDataTable_array[0].wrsPtpDeltaRxM = 0;//JCB TODO ppsi_servo->delta_rxm_ps;
// wrsPtpDataTable_array[0].wrsPtpDeltaTxS = 0;//JCB TODO ppsi_servo->delta_txs_ps;
// wrsPtpDataTable_array[0].wrsPtpDeltaRxS = 0;//JCB TODO ppsi_servo->delta_rxs_ps;
// wrsPtpDataTable_array[0].wrsPtpServoStateErrCnt = 0;//JCB TODO ppsi_servo->n_err_state;
// wrsPtpDataTable_array[0].wrsPtpClockOffsetErrCnt = 0;//JCB TODO ppsi_servo->n_err_offset;
// wrsPtpDataTable_array[0].wrsPtpRTTErrCnt = 0;//JCB TODO ppsi_servo->n_err_delta_rtt;
// wrsPtpDataTable_array[0].wrsPtpServoUpdateTime = 0;
// //JCB TODO ppsi_servo->update_time.secs * 1000 * 1000 * 1000
// //JCB TODO + (ppsi_servo->update_time.scaled_nsecs >> 16);
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "SNMP: " SL_ER
......
......@@ -34,6 +34,7 @@ struct wrsPtpDataTable_s {
uint32_t wrsPtpClockOffsetErrCnt;
uint32_t wrsPtpRTTErrCnt;
uint64_t wrsPtpServoUpdateTime;
int wrsPtpServoExt;
};
extern struct wrsPtpDataTable_s wrsPtpDataTable_array[WRS_MAX_N_SERVO_INSTANCES];
......
This diff is collapsed.
#ifndef WRS_PTP_INSTANCE_TABLE_H
#define WRS_PTP_INSTANCE_TABLE_H
#define WRSPTPINSTANCETABLE_CACHE_TIMEOUT 5
#define WRSPTPINSTANCETABLE_OID WRS_OID, 7, 8
/* Maximum lenth of vlans list. The worst case is the maximum number of vlans
* for the instance times the maximum lenght of a vlan (4) + 1 for coma
*/
#define WRSPTPINSTANCEVLANLISTSTRLEN (CONFIG_VLAN_ARRAY_SIZE * 5)
struct wrsPtpInstanceTable_s {
uint32_t wrsPtpInstancePortIndex; /* not reported, index fields has t o be marked
* as not-accessible in MIB */
uint32_t wrsPtpInstanceOnPortIndex; /* port on which ptp instance is running (index+1) */
char wrsPtpInstanceName[16]; /* Instance name */
int wrsPtpInstancePort; /* port on which ptp instance is running (index+1) */
int wrsPtpInstancePortInstance; /* serial of instance running on a given port */
char wrsPtpInstancePortName[16];/* port name on which ptp instance is running (wriX) */
int wrsPtpInstanceState;
int wrsPtpInstanceMasterOnly;
int wrsPtpInstanceExtPortCfg;
int wrsPtpInstanceExtPortCfgDesSt;
int wrsPtpInstanceMechanism; /* ENDelayMechanism */
int wrsPtpInstanceProfile;
int wrsPtpInstanceExtension;
int wrsPtpInstanceAsymEnabled;
int64_t wrsPtpInstanceAsymConstAsym;
int64_t wrsPtpInstanceAsymConstAsymPS;
int64_t wrsPtpInstanceAsymScDelayCoef;
char wrsPtpInstanceAsymScDelayCoefHR[64];
int64_t wrsPtpInstanceTSCorrEgressLat;
int64_t wrsPtpInstanceTSCorrEgressLatPS;
int64_t wrsPtpInstanceTSCorrIngLat;
int64_t wrsPtpInstanceTSCorrIngLatPS;
int64_t wrsPtpInstanceTSCorrSemistLat;
int64_t wrsPtpInstanceTSCorrSemistLatPS;
int wrsPtpInstanceExtState;
int wrsPtpInstanceProtoDetectState;
char wrsPtpInstancePeerMac[ETH_ALEN];
int wrsPtpInstancePeerVid;
int wrsPtpInstanceVlanNum;
/* wrsPtpInstanceVlanListStr is implemented as a comma separated list
* because SNMP does not allow table within table */
char wrsPtpInstanceVlanListStr[WRSPTPINSTANCEVLANLISTSTRLEN];
};
extern struct wrsPtpInstanceTable_s wrsPtpInstanceTable_array[PP_MAX_LINKS];
time_t wrsPtpInstanceTable_data_fill(unsigned int *rows);
void init_wrsPtpInstanceTable(void);
#endif /* WRS_PTP_INSTANCE_TABLE_H */
......@@ -49,7 +49,8 @@ time_t wrsSpllStatus_data_fill(void)
return time_update;
}
/* check version of SPLL's stat structure, versions 1 and 2 are ok */
if ((spll_stats_p->ver == 1) || (spll_stats_p->ver == 2)) {
if ((spll_stats_p->ver == 1) || (spll_stats_p->ver == 2) ||
(spll_stats_p->ver == 3)) {
wrsSpllStatus_s.wrsSpllMode = spll_stats_p->mode;
wrsSpllStatus_s.wrsSpllIrqCnt = spll_stats_p->irq_cnt;
wrsSpllStatus_s.wrsSpllSeqState = spll_stats_p->seq_state;
......@@ -60,6 +61,13 @@ time_t wrsSpllStatus_data_fill(void)
wrsSpllStatus_s.wrsSpllMY = spll_stats_p->M_y;
wrsSpllStatus_s.wrsSpllDelCnt = spll_stats_p->del_cnt;
}
else
{
snmp_log(LOG_ERR, "SNMP: " SL_ER
"wrsSpllStatusGroup unsupported version of spll_stats "
"registers (reading ver %d, supported 1, 2 and 3) \n",
spll_stats_p->ver);
}
/* there was an update, return current time */
return time_update;
}
......
......@@ -54,6 +54,13 @@ time_t wrsSpllVersion_data_fill(void)
/* add time after added space at the end of string */
strncpy_e(&wrsSpllVersion_s.wrsSpllBuildDate[len + 1], spll_stats_p->build_time, 16 - 1);
}
else
{
snmp_log(LOG_ERR, "SNMP: " SL_ER
"wrsSpllVersionGroup unsupported version of spll_stats "
"registers (reading ver %d, supported 2 and 3) \n",
spll_stats_p->ver);
}
/* buil_by was introduced in version 3 */
if (spll_stats_p->ver == 3) {
strncpy_e(wrsSpllVersion_s.wrsSpllBuildBy, spll_stats_p->build_by, 32);
......
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