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

userspace/snmpd: add counters of PTP tx and rx packets to wrsPortStatusTable

Add wrsPortStatusPtpTxFrames and wrsPortStatusPtpRxFrames to wrsPortStatusTable

Additionally:
--follow pointer to pp_instances in snmp_shmem.c
--update MIB
--uplift ppsi
--shmem dump with new variables (ptp_tx_count and ptp_rx_count)
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 96974d3d
ppsi @ 623dcf31
Subproject commit 34c57cba5b27cec87848ad00c312137f3e69ff17
Subproject commit 623dcf3116f87d3f5ae6c51c05239b0229d8f1a1
......@@ -1485,7 +1485,9 @@ WrsPortStatusEntry ::=
wrsPortStatusSfpVS DisplayString,
wrsPortStatusSfpInDB INTEGER,
wrsPortStatusSfpGbE INTEGER,
wrsPortStatusSfpError INTEGER
wrsPortStatusSfpError INTEGER,
wrsPortStatusPtpTxFrames Counter32,
wrsPortStatusPtpRxFrames Counter32,
}
wrsPortStatusIndex OBJECT-TYPE
......@@ -1603,6 +1605,24 @@ wrsPortStatusSfpError OBJECT-TYPE
"Problem with SFP configuration. Port has to be always 1GbE. Port has to be in data base as long as support WR."
::= { wrsPortStatusEntry 12 }
wrsPortStatusPtpTxFrames OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Number of transmitted PTP frames per port (for all PPSI instances
running on particular port"
::= { wrsPortStatusEntry 13 }
wrsPortStatusPtpRxFrames OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Number of received PTP frames per port (for all PPSI instances
running on particular port"
::= { wrsPortStatusEntry 14 }
--wrsNetworking
--Configuration
......
......@@ -11,6 +11,8 @@ int hal_nports_local;
struct wrs_shm_head *ppsi_head;
static struct pp_globals *ppg;
struct wr_servo_state *ppsi_servo;
struct pp_instance *ppsi_ppi;
int *ppsi_ppi_nlinks;
/* RTUd */
struct wrs_shm_head *rtud_head;
......@@ -74,6 +76,13 @@ static void init_shm_ppsi(void)
exit(-1);
}
ppsi_ppi = wrs_shm_follow(ppsi_head, ppg->pp_instances);
if (!ppsi_ppi) {
snmp_log(LOG_ERR, "Cannot follow ppsi_ppi in shmem.\n");
exit(-1);
}
/* use pointer instead of copying */
ppsi_ppi_nlinks = &(ppg->nlinks);
}
static void init_shm_rtud(void)
......
......@@ -16,6 +16,8 @@ extern int hal_nports_local;
/* PPSI */
extern struct wrs_shm_head *ppsi_head;
extern struct wr_servo_state *ppsi_servo;
extern struct pp_instance *ppsi_ppi;
extern int *ppsi_ppi_nlinks;
/* RTUd */
struct wrs_shm_head *rtud_head;
......
......@@ -18,15 +18,18 @@ static struct pickinfo wrsPortStatusTable_pickinfo[] = {
FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_in_db),
FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_GbE),
FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_error),
FIELD(wrsPortStatusTable_s, ASN_COUNTER, ptp_tx_count),
FIELD(wrsPortStatusTable_s, ASN_COUNTER, ptp_rx_count),
};
time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
{
unsigned ii, i;
unsigned ii, i, ppi_i;
unsigned retries = 0;
static time_t time_update;
time_t time_cur;
char *ppsi_iface_name;
/* number of rows does not change for wrsPortStatusTable */
if (n_rows)
......@@ -120,6 +123,49 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
usleep(1000);
}
retries = 0;
/* fill ptp_tx_count and ptp_tx_count
* ptp_tx_count and ptp_tx_count statistics in PPSI are collected per
* ppi instance. Since there can be more than one instance per physical
* port, proper counters has to be added. */
while (1) {
ii = wrs_shm_seqbegin(ppsi_head);
/* Match port name with interface name of ppsi instance.
* More than one ppsi_iface_name can match to
* wrsPortStatusTable_array[i].port_name, but only one can
* match way round */
for (ppi_i = 0; ppi_i < *ppsi_ppi_nlinks; ppi_i++) {
/* (ppsi_ppi + ppi_i)->iface_name is a pointer in
* shmem, so we have to follow it
* NOTE: ppi->cfg.port_name cannot be used instead,
* because it is not used when ppsi is configured from
* cmdline */
ppsi_iface_name = (char *) wrs_shm_follow(ppsi_head,
(ppsi_ppi + ppi_i)->iface_name);
for (i = 0; i < hal_nports_local; ++i) {
if (!strncmp(wrsPortStatusTable_array[i].port_name,
ppsi_iface_name, 12)) {
wrsPortStatusTable_array[i].ptp_tx_count +=
(ppsi_ppi + ppi_i)->ptp_tx_count;
wrsPortStatusTable_array[i].ptp_rx_count +=
(ppsi_ppi + ppi_i)->ptp_rx_count;
/* speed up a little, break here */
break;
}
}
}
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read PPSI "
"shmem\n", __func__);
retries = 0;
break;
}
if (!wrs_shm_seqretry(ppsi_head, ii))
break; /* consistent read */
usleep(1000);
}
/* there was an update, return current time */
return time_cur;
}
......
......@@ -32,6 +32,8 @@ struct wrsPortStatusTable_s {
int sfp_in_db;
int sfp_GbE;
int sfp_error;
unsigned long ptp_tx_count;
unsigned long ptp_rx_count;
};
......
......@@ -567,6 +567,8 @@ struct dump_info ppi_info [] = {
DUMP_FIELD_SIZE(char, cfg.port_name, 16),
DUMP_FIELD_SIZE(char, cfg.iface_name, 16),
DUMP_FIELD(int, cfg.ext),
DUMP_FIELD(UInteger32, ptp_tx_count),
DUMP_FIELD(UInteger32, ptp_rx_count),
};
int dump_ppsi_mem(struct wrs_shm_head *head)
......
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