Commit 57d02a71 authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Grzegorz Daniluk

SNMP: started getting rid of wrsPortStatusConfiguredMode, not easy...

parent 709fc237
......@@ -12,7 +12,6 @@ static struct pickinfo wrsPortStatusTable_pickinfo[] = {
FIELD(wrsPortStatusTable_s, ASN_UNSIGNED, index), /* not reported */
FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusPortName),
FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusLink),
FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusConfiguredMode),
FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusLocked),
FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusPeer),
FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusSfpVN),
......@@ -178,7 +177,6 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* If info about wrsPortStatusSfpGbE is not filled skip further
* checking. NOTE: there is no need to check the fill of others
* like:
* - wrsPortStatusConfiguredMode
* - wrsPortStatusSfpInDB
*/
/* Don't check if WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN */
......@@ -199,9 +197,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
"SFP in port %d (wri%d) is not for Gigabit Ethernet\n",
slog_obj_name, i + 1, i + 1);
}
if ((wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
&& (wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NONE)
&& (wrsPortStatusTable_array[i].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE)
if ((wrsPortStatusTable_array[i].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE)
&& (wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE)) {
/* error, port is not non-wr mode and sfp not in data base */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
......@@ -213,10 +209,9 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
snmp_log(LOG_DEBUG, "SNMP: " SL_DEBUG
" reading ports name %s link %d, "
"mode %d, locked %d\n",
"locked %d\n",
wrsPortStatusTable_array[i].wrsPortStatusPortName,
wrsPortStatusTable_array[i].wrsPortStatusLink,
wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode,
wrsPortStatusTable_array[i].wrsPortStatusLocked);
}
......
......@@ -37,7 +37,6 @@ struct wrsPortStatusTable_s {
ClockIdentity wrsPortStatusPeer;
/* These can't be "unsigned char" because we scanf a %i in there */
unsigned wrsPortStatusLink;
unsigned wrsPortStatusConfiguredMode;
unsigned wrsPortStatusLocked;
char wrsPortStatusSfpVN[16]; /* vendor name */
char wrsPortStatusSfpPN[16]; /* part name */
......
#include "wrsSnmp.h"
#include "snmp_shmem.h"
#include "wrsPortStatusTable.h"
#include "wrsPtpInstanceTable.h"
struct wrsPtpInstanceTable_s wrsPtpInstanceTable_array[PP_MAX_LINKS];
......@@ -43,7 +44,10 @@ static struct pickinfo wrsPtpInstanceTable_pickinfo[] = {
FIELD(wrsPtpInstanceTable_s, ASN_INTEGER, wrsPtpInstanceVlanNum),
FIELD(wrsPtpInstanceTable_s, ASN_OCTET_STR, wrsPtpInstanceVlanListStr),
FIELD(wrsPtpInstanceTable_s, ASN_INTEGER, wrsPtpInstanceStatusError),
};
static char *slog_obj_name;
static char *wrsPtpInstanceStatusError_str = "wrsPtpInstanceStatusError";
static inline struct hal_port_state *pp_wrs_lookup_port(char *name)
{
......@@ -64,6 +68,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
static int n_rows_local = 0;
struct wrsPtpInstanceTable_s *i_a;
struct pp_instance *ppsi_i;
struct wrsPortStatusTable_s *p_a;
char *tmp_name;
portDS_t *portDS_i;
struct hal_port_state *p;
......@@ -73,6 +78,8 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
char *tmpstr_p;
int vlan_i;
float tmp_f;
int bc_has_slave = 0;
slog_obj_name = wrsPtpInstanceStatusError_str;
/* number of rows does not change for wrsPortStatusTable */
if (n_rows)
......@@ -89,6 +96,7 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
memset(&wrsPtpInstanceTable_array, 0, sizeof(wrsPtpInstanceTable_array));
i_a = wrsPtpInstanceTable_array;
p_a = wrsPortStatusTable_array;
/* check whether shmem is available */
if (!shmem_ready_ppsi() && !ppsi_ppi_nlinks) {
......@@ -195,6 +203,72 @@ time_t wrsPtpInstanceTable_data_fill(unsigned int *n_rows)
if (*last_char == ',')
*last_char = 0;
}
if (shmem_ready_hald())
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_OK;
if ((p_a[phys_port].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE) &&
(p_a[phys_port].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP))
{
if ((i_a[i].wrsPtpInstanceState == PPS_SLAVE ||
i_a[i].wrsPtpInstanceState == PPS_UNCALIBRATED) &&
(hal_shmem->hal_mode == HAL_TIMING_MODE_GRAND_MASTER))
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Grand Master mode, instance %d on port %d (%s) "
"is in SLAVE or UNCALIBRATED state.\n",
slog_obj_name, i, phys_port, i_a[i].wrsPtpInstancePortName);
}
if ((i_a[i].wrsPtpInstanceState == PPS_SLAVE ||
i_a[i].wrsPtpInstanceState == PPS_UNCALIBRATED) &&
(hal_shmem->hal_mode == HAL_TIMING_MODE_FREE_MASTER)) // THIS is wrogn
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Free Running mode, instance %d on port %d (%s) "
"is in SLAVE or UNCALIBRATED state.\n",
slog_obj_name, i, phys_port, i_a[i].wrsPtpInstancePortName);
}
}
if((p_a[phys_port].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP) &&
(i_a[i].wrsPtpInstanceState == PPS_SLAVE))
{
bc_has_slave = 1;
}
if ((p_a[phys_port].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE) &&
(hal_shmem->hal_mode == HAL_TIMING_MODE_BC) &&
(i_a[i].wrsPtpInstanceExtPortCfgDesSt == PPS_SLAVE))
{
if(i_a[i].wrsPtpInstanceState != PPS_DISABLED &&
i_a[i].wrsPtpInstanceState != PPS_SLAVE)
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Boundary Clock mode, External Port Configuration is enabled "
"and desiredState is set to SLAVE but instance %d on port %d (%s) "
"is not in SLAVE state.\n",
slog_obj_name, i, phys_port, i_a[i].wrsPtpInstancePortName);
}
if(p_a[phys_port].wrsPortStatusLink == WRS_PORT_STATUS_LINK_DOWN)
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Boundary Clock mode, External Port Configuration is enabled "
"and desiredState is set to SLAVE on instance %d, yet port %d (%s) "
"is DOWN.\n",
slog_obj_name, i, phys_port, i_a[i].wrsPtpInstancePortName);
}
}
}
}
if(hal_shmem->hal_mode == HAL_TIMING_MODE_BC && bc_has_slave == 0)
{
i_a[i].wrsPtpInstanceStatusError = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Boundary Clock mode, there is no port in SLAVE state\n",
slog_obj_name);
}
retries++;
......
......@@ -9,6 +9,12 @@
*/
#define WRSPTPINSTANCEVLANLISTSTRLEN (CONFIG_VLAN_ARRAY_SIZE * 5)
#define WRS_SLAVE_LINK_STATUS_OK 1 /* ok */
#define WRS_SLAVE_LINK_STATUS_ERROR 2 /* error */
#define WRS_SLAVE_LINK_STATUS_WARNING_NA 4 /* warning, at least one field is
* equal to 0 (NA),shouldn't happen in
* normal operation */
struct wrsPtpInstanceTable_s {
uint32_t wrsPtpInstancePortIndex; /* not reported, index fields has t o be marked
......@@ -44,6 +50,7 @@ struct wrsPtpInstanceTable_s {
/* wrsPtpInstanceVlanListStr is implemented as a comma separated list
* because SNMP does not allow table within table */
char wrsPtpInstanceVlanListStr[WRSPTPINSTANCEVLANLISTSTRLEN];
int wrsPtpInstanceStatusError;
};
extern struct wrsPtpInstanceTable_s wrsPtpInstanceTable_array[PP_MAX_LINKS];
......
......@@ -329,76 +329,6 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
t = &wrsTimingStatus_s;
slog_obj_name = wrsSlaveLinksStatus_str;
/* check whether hal_shmem is available */
if (shmem_ready_hald()) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_OK;
for (i = 0; i < port_status_nrows; i++) {
/* wrsPortStatusMonitor value is ignored for this oid on this port */
/* warning N/A */
if (p_a[i].wrsPortStatusConfiguredMode == 0) {
if (t->wrsSlaveLinksStatus != WRS_SLAVE_LINK_STATUS_ERROR) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA;
}
/* Log always for every port */
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusConfiguredMode not available "
"for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1);
}
if (p_a[i].wrsPortStatusLink == 0){
if (t->wrsSlaveLinksStatus != WRS_SLAVE_LINK_STATUS_ERROR) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA;
}
/* Log always for every port */
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusLink not available "
"for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1);
}
/* error when slave port is down when switch is in slave mode
*/
if (hal_shmem->hal_mode == HAL_TIMING_MODE_BC
&& (p_a[i].wrsPortStatusConfiguredMode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)) {
if (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_DOWN) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Boundary Clock mode, port %d (wri%d) configured as slave is down\n",
slog_obj_name, i + 1, i + 1);
}
if (s->wrsSpllMode != WRS_SPLL_MODE_SLAVE) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Boundary Clock mode, port %d (wri%d) configured as slave, "
"wrsSpllMode not slave (%d), but %d\n",
slog_obj_name, i + 1, i + 1, WRS_SPLL_MODE_SLAVE, s->wrsSpllMode);
}
}
/* error when slave port is up when switch is in master or
* grandmaster mode */
if ((p_a[i].wrsPortStatusConfiguredMode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)
&& (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP)) {
if (hal_shmem->hal_mode == HAL_TIMING_MODE_GRAND_MASTER) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Grand Master mode, port %d (wri%d) configured as slave is up\n",
slog_obj_name, i + 1, i + 1);
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Grand Master mode slave ports cannot be used\n",
slog_obj_name);
}
if (hal_shmem->hal_mode == HAL_TIMING_MODE_FREE_MASTER) {
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Free-running Master mode, port %d (wri%d) configured as slave is up\n",
slog_obj_name, i + 1, i + 1);
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"In Free-running Master mode slave ports cannot be used\n",
slog_obj_name);
}
}
}
}
}
static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
......@@ -435,9 +365,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
/* Error when there is no increase in TX/RX PTP counters.
Check only when port is not (non-wr and none) and port is down */
}
if ((p_a[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
&& (p_a[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NONE)
&& (p_a[i].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE)
if ((p_a[i].wrsPortStatusMonitor != WRS_PORT_STATUS_MONITOR_DISABLE)
&& (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP)) {
if (wrsPortStatusPtpTxFrames_prev[i] == p_a[i].wrsPortStatusPtpTxFrames) {
t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_ERROR;
......@@ -455,19 +383,6 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
/* Warning N/A, skip when already error. Will not reach this
* point for first read */
}
if (p_a[i].wrsPortStatusConfiguredMode == 0) {
/* assign if not error */
if (t->wrsPTPFramesFlowing != WRS_PTP_FRAMES_FLOWING_ERROR) {
t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_WARNING_NA;
}
/* Log always for every port */
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusConfiguredMode not available "
"for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1);
/* continue with other ports, somewhere may be an
* error */
}
if (p_a[i].wrsPortStatusLink == 0){
/* assign if not error */
if (t->wrsPTPFramesFlowing != WRS_PTP_FRAMES_FLOWING_ERROR) {
......
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