Commit b066b6e7 authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Grzegorz Daniluk

SNMP: fixed/updated wrsPtpDataTable

The fields in this table were not really filled in after
substantial changes to the PPSi architecture regarding
servo (HA-related). Filling in of the fields in this
table had to be redone. This commit fixes filling in
most of the fields that were field before. There are still
some fields that are not filled in, tbd.
parent 9aa0e854
......@@ -1753,7 +1753,8 @@ WrsPtpDataEntry ::=
wrsPtpServoStateErrCnt Counter32,
wrsPtpClockOffsetErrCnt Counter32,
wrsPtpRTTErrCnt Counter32,
wrsPtpServoUpdateTime Counter64
wrsPtpServoUpdateTime Counter64,
wrsPtpServoExt INTEGER
}
wrsPtpDataIndex OBJECT-TYPE
......@@ -1956,6 +1957,19 @@ wrsPtpServoUpdateTime OBJECT-TYPE
"TAI Nanosecond of the last servo's update"
::= { wrsPtpDataEntry 23 }
wrsPtpServoExt OBJECT-TYPE
SYNTAX INTEGER {
na(0),
none(1),
wr(2),
l1Sync(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Extension with which the servo runs."
::= { wrsPtpDataEntry 24 }
-- wrsPortStatusTable (.7.6)
wrsPortStatusTable OBJECT-TYPE
SYNTAX SEQUENCE OF WrsPortStatusEntry
......
......@@ -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];
......
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