Skip to content
Snippets Groups Projects
Commit aa9ca1c2 authored by Adam Wujek's avatar Adam Wujek
Browse files

userspace/snmpd/wrsPtpDataTable: don't return unused OIDs


Some OIDs are not used if l1sync is used, then don't return them since
a value e.g. 0 can have a valid meaning.

Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent 8de421c7
Branches
Tags
No related merge requests found
...@@ -34,6 +34,10 @@ wrSwitchMIB MODULE-IDENTITY ...@@ -34,6 +34,10 @@ wrSwitchMIB MODULE-IDENTITY
Improved description of: Improved description of:
- wrsPtpRTT - wrsPtpRTT
- wrsPtpLinkLength - wrsPtpLinkLength
- wrsPtpDeltaTxM
- wrsPtpDeltaRxM
- wrsPtpDeltaTxS
- wrsPtpDeltaRxS
" "
REVISION "202303260000Z" REVISION "202303260000Z"
...@@ -2108,8 +2112,8 @@ wrsPtpRTT OBJECT-TYPE ...@@ -2108,8 +2112,8 @@ wrsPtpRTT OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"For WR extension the round-trip-time, from master, in picoseconds "For WR extension the round-trip-time from master, in picoseconds.
For l1Sync extension 0." For l1Sync, read of this OID returns an error."
::= { wrsPtpDataEntry 13 } ::= { wrsPtpDataEntry 13 }
wrsPtpLinkLength OBJECT-TYPE wrsPtpLinkLength OBJECT-TYPE
...@@ -2135,7 +2139,8 @@ wrsPtpDeltaTxM OBJECT-TYPE ...@@ -2135,7 +2139,8 @@ wrsPtpDeltaTxM OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"Fixed Tx latency on Master side" "For WR extension, Fixed Tx latency on Master side, in picoseconds.
For l1Sync, read of this OID returns an error."
::= { wrsPtpDataEntry 16 } ::= { wrsPtpDataEntry 16 }
wrsPtpDeltaRxM OBJECT-TYPE wrsPtpDeltaRxM OBJECT-TYPE
...@@ -2143,7 +2148,8 @@ wrsPtpDeltaRxM OBJECT-TYPE ...@@ -2143,7 +2148,8 @@ wrsPtpDeltaRxM OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"Fixed Rx latency on Master side" "For WR extension, Fixed Rx latency on Master side, in picoseconds.
For l1Sync, read of this OID returns an error."
::= { wrsPtpDataEntry 17 } ::= { wrsPtpDataEntry 17 }
wrsPtpDeltaTxS OBJECT-TYPE wrsPtpDeltaTxS OBJECT-TYPE
...@@ -2151,7 +2157,8 @@ wrsPtpDeltaTxS OBJECT-TYPE ...@@ -2151,7 +2157,8 @@ wrsPtpDeltaTxS OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"Fixed Tx latency on Slave side" "For WR extension, Fixed Tx latency on Slave side, in picoseconds.
For l1Sync, read of this OID returns an error."
::= { wrsPtpDataEntry 18 } ::= { wrsPtpDataEntry 18 }
wrsPtpDeltaRxS OBJECT-TYPE wrsPtpDeltaRxS OBJECT-TYPE
...@@ -2159,7 +2166,8 @@ wrsPtpDeltaRxS OBJECT-TYPE ...@@ -2159,7 +2166,8 @@ wrsPtpDeltaRxS OBJECT-TYPE
MAX-ACCESS read-only MAX-ACCESS read-only
STATUS current STATUS current
DESCRIPTION DESCRIPTION
"Fixed Rx latency on Slave side" "For WR extension, Fixed Rx latency on Slave side, in picoseconds.
For l1Sync, read of this OID returns an error."
::= { wrsPtpDataEntry 19 } ::= { wrsPtpDataEntry 19 }
wrsPtpServoStateErrCnt OBJECT-TYPE wrsPtpServoStateErrCnt OBJECT-TYPE
......
...@@ -5,6 +5,18 @@ ...@@ -5,6 +5,18 @@
struct wrsPtpDataTable_s wrsPtpDataTable_array[WRS_MAX_N_SERVO_INSTANCES]; struct wrsPtpDataTable_s wrsPtpDataTable_array[WRS_MAX_N_SERVO_INSTANCES];
/* Save pointers to the types of some OIDs.
* If a type of these OIDs is set to SNMP_NOSUCHINSTANCE, then an OID is not
* returned during a query. */
static int *wrsPtpRTT_type_p = NULL;
static int *wrsPtpDeltaTxM_type_p = NULL;
static int *wrsPtpDeltaRxM_type_p = NULL;
static int *wrsPtpDeltaTxS_type_p = NULL;
static int *wrsPtpDeltaRxS_type_p = NULL;
#define WRSPTPRTT_ASN_TYPE ASN_COUNTER64
#define WRSPTPDELTA_ASN_TYPE ASN_INTEGER
static struct pickinfo wrsPtpDataTable_pickinfo[] = { static struct pickinfo wrsPtpDataTable_pickinfo[] = {
/* Warning: strings are a special case for snmp format */ /* Warning: strings are a special case for snmp format */
FIELD(wrsPtpDataTable_s, ASN_UNSIGNED, wrsPtpDataIndex), /* not reported */ FIELD(wrsPtpDataTable_s, ASN_UNSIGNED, wrsPtpDataIndex), /* not reported */
...@@ -19,13 +31,13 @@ static struct pickinfo wrsPtpDataTable_pickinfo[] = { ...@@ -19,13 +31,13 @@ static struct pickinfo wrsPtpDataTable_pickinfo[] = {
FIELD(wrsPtpDataTable_s, ASN_COUNTER64, wrsPtpClockOffsetPs), FIELD(wrsPtpDataTable_s, ASN_COUNTER64, wrsPtpClockOffsetPs),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpClockOffsetPsHR), FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpClockOffsetPsHR),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpSkew), FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpSkew),
FIELD(wrsPtpDataTable_s, ASN_COUNTER64, wrsPtpRTT), FIELD(wrsPtpDataTable_s, WRSPTPRTT_ASN_TYPE, wrsPtpRTT),
FIELD(wrsPtpDataTable_s, ASN_UNSIGNED, wrsPtpLinkLength), FIELD(wrsPtpDataTable_s, ASN_UNSIGNED, wrsPtpLinkLength),
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpServoUpdates), FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpServoUpdates),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpDeltaTxM), FIELD(wrsPtpDataTable_s, WRSPTPDELTA_ASN_TYPE, wrsPtpDeltaTxM),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpDeltaRxM), FIELD(wrsPtpDataTable_s, WRSPTPDELTA_ASN_TYPE, wrsPtpDeltaRxM),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpDeltaTxS), FIELD(wrsPtpDataTable_s, WRSPTPDELTA_ASN_TYPE, wrsPtpDeltaTxS),
FIELD(wrsPtpDataTable_s, ASN_INTEGER, wrsPtpDeltaRxS), FIELD(wrsPtpDataTable_s, WRSPTPDELTA_ASN_TYPE, wrsPtpDeltaRxS),
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpServoStateErrCnt), FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpServoStateErrCnt),
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpClockOffsetErrCnt), FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpClockOffsetErrCnt),
FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpRTTErrCnt), FIELD(wrsPtpDataTable_s, ASN_COUNTER, wrsPtpRTTErrCnt),
...@@ -46,10 +58,10 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -46,10 +58,10 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
struct wrsPtpDataTable_s *ptp_a; struct wrsPtpDataTable_s *ptp_a;
struct pp_instance *ppsi_i; struct pp_instance *ppsi_i;
struct pp_servo *ppsi_servo; struct pp_servo *ppsi_servo;
struct wr_data *wr_d; struct wr_data *wr_d = NULL;
struct l1e_data *l1e_d; struct l1e_data *l1e_d = NULL;
struct wr_servo_ext *wr_servo; struct wr_servo_ext *wr_servo = NULL;
struct wrh_servo_t *wrh_servo; struct wrh_servo_t *wrh_servo = NULL;
char *tmp_name; char *tmp_name;
static int servoStateMapping[]={ static int servoStateMapping[]={
[WRH_UNINITIALIZED]= PTP_SERVO_STATE_N_UNINTIALIZED, [WRH_UNINITIALIZED]= PTP_SERVO_STATE_N_UNINTIALIZED,
...@@ -229,6 +241,17 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -229,6 +241,17 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
/* wrsPtpDeltaRxS */ /* wrsPtpDeltaRxS */
ptp_a[si].wrsPtpDeltaRxS = ptp_a[si].wrsPtpDeltaRxS =
pp_time_to_picos(&wr_servo->delta_rxs); pp_time_to_picos(&wr_servo->delta_rxs);
*wrsPtpDeltaTxM_type_p = WRSPTPDELTA_ASN_TYPE;
*wrsPtpDeltaRxM_type_p = WRSPTPDELTA_ASN_TYPE;
*wrsPtpDeltaTxS_type_p = WRSPTPDELTA_ASN_TYPE;
*wrsPtpDeltaRxS_type_p = WRSPTPDELTA_ASN_TYPE;
} else {
/* Deltas are not available */
*wrsPtpDeltaTxM_type_p = SNMP_NOSUCHINSTANCE;
*wrsPtpDeltaRxM_type_p = SNMP_NOSUCHINSTANCE;
*wrsPtpDeltaTxS_type_p = SNMP_NOSUCHINSTANCE;
*wrsPtpDeltaRxS_type_p = SNMP_NOSUCHINSTANCE;
} }
/* wrsPtpServoStateErrCnt */ /* wrsPtpServoStateErrCnt */
...@@ -244,9 +267,13 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -244,9 +267,13 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
wrh_servo->n_err_delta_rtt; wrh_servo->n_err_delta_rtt;
/* wrsPtpRTT */ /* wrsPtpRTT */
if (wr_servo) if (wr_servo) {
*wrsPtpRTT_type_p = WRSPTPRTT_ASN_TYPE;
ptp_a[si].wrsPtpRTT = pp_time_to_picos(&wr_servo->rawDelayMM); ptp_a[si].wrsPtpRTT = pp_time_to_picos(&wr_servo->rawDelayMM);
} else {
/* wrsPtpRTT is not available */
*wrsPtpRTT_type_p = SNMP_NOSUCHINSTANCE;
}
} else { } else {
memset(ptp_a[si].wrsPtpSyncSource, memset(ptp_a[si].wrsPtpSyncSource,
0, 32 * sizeof(char)); 0, 32 * sizeof(char));
...@@ -284,6 +311,26 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -284,6 +311,26 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
return time_update; return time_update;
} }
static void post_init_wrsPtpDataTable(void)
{
int i;
struct pickinfo *p_pickinfo = wrsPtpDataTable_pickinfo;
for (i = 0; i < ARRAY_SIZE(wrsPtpDataTable_pickinfo); i++, p_pickinfo++) {
/* Save pointers to OIDs' type fields. */
if (p_pickinfo->offset == offsetof(struct wrsPtpDataTable_s, wrsPtpRTT))
wrsPtpRTT_type_p = &p_pickinfo->type;
if (p_pickinfo->offset == offsetof(struct wrsPtpDataTable_s, wrsPtpDeltaTxM))
wrsPtpDeltaTxM_type_p = &p_pickinfo->type;
if (p_pickinfo->offset == offsetof(struct wrsPtpDataTable_s, wrsPtpDeltaRxM))
wrsPtpDeltaRxM_type_p = &p_pickinfo->type;
if (p_pickinfo->offset == offsetof(struct wrsPtpDataTable_s, wrsPtpDeltaTxS))
wrsPtpDeltaTxS_type_p = &p_pickinfo->type;
if (p_pickinfo->offset == offsetof(struct wrsPtpDataTable_s, wrsPtpDeltaRxS))
wrsPtpDeltaRxS_type_p = &p_pickinfo->type;
}
}
#define TT_OID WRSPTPDATATABLE_OID #define TT_OID WRSPTPDATATABLE_OID
#define TT_PICKINFO wrsPtpDataTable_pickinfo #define TT_PICKINFO wrsPtpDataTable_pickinfo
#define TT_DATA_FILL_FUNC wrsPtpDataTable_data_fill #define TT_DATA_FILL_FUNC wrsPtpDataTable_data_fill
...@@ -291,5 +338,6 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -291,5 +338,6 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
#define TT_GROUP_NAME "wrsPtpDataTable" #define TT_GROUP_NAME "wrsPtpDataTable"
#define TT_INIT_FUNC init_wrsPtpDataTable #define TT_INIT_FUNC init_wrsPtpDataTable
#define TT_CACHE_TIMEOUT WRSPTPDATATABLE_CACHE_TIMEOUT #define TT_CACHE_TIMEOUT WRSPTPDATATABLE_CACHE_TIMEOUT
#define TT_POST_INIT_FUNC post_init_wrsPtpDataTable
#include "wrsTableTemplate.h" #include "wrsTableTemplate.h"
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