Retrieve the hardware states if available

These 3 states: "oper-state", "admin-state", "availability-state" are optional,
but shall be checked in order to activate the carriers. If an O-RU doesn't support it,
we assume the expected values:
- "oper-state" = "enabled"
- "admin-state" = "unlocked"
- "availability-state" = "NORMAL"

Implement retrieval of the hardware states if O-RU supports, i.e. Benetel release v1.4.1.
This commit is contained in:
Teodora
2025-10-30 17:22:40 +01:00
parent d4b5291c62
commit d542021f86
4 changed files with 100 additions and 1 deletions
+13 -1
View File
@@ -158,11 +158,23 @@ static void init_ru_notif(ru_session_t *ru_session, const char* buffer)
ru_session->ru_notif.config_change = false;
}
char *oper_state = get_ru_xml_node(buffer, "oper-state");
ru_session->ru_notif.hardware.oper_state = (str_to_enum_oper(oper_state) != OPER_COUNT) ? str_to_enum_oper(oper_state) : ENABLED_OPER;
char *admin_state = get_ru_xml_node(buffer, "admin-state");
ru_session->ru_notif.hardware.admin_state = (str_to_enum_admin(admin_state) != ADMIN_COUNT) ? str_to_enum_admin(admin_state) : UNLOCKED_ADMIN;
char *avail_state = get_ru_xml_node(buffer, "availability-state");
ru_session->ru_notif.hardware.avail_state = (str_to_enum_avail(avail_state) != AVAIL_COUNT) ? str_to_enum_avail(avail_state) : NORMAL_AVAIL;
char *ptp_state = get_ru_xml_node(buffer, "sync-state");
ru_session->ru_notif.ptp_state = str_to_enum_ptp(ptp_state);
MP_LOG_I("RU is in \"%s\" sync state.\n", ptp_state);
free(usage_state);
free(oper_state);
free(admin_state);
free(avail_state);
free(ptp_state);
}
@@ -211,7 +223,7 @@ bool manage_ru(ru_session_t *ru_session, const openair0_config_t *oai, const siz
while (1) {
sleep(5);
if (!ru_session->ru_notif.ptp_state) {
if (!ru_session->ru_notif.ptp_state && !ru_session->ru_notif.hardware.oper_state && !ru_session->ru_notif.hardware.admin_state && !ru_session->ru_notif.hardware.avail_state) {
char *content = NULL;
success = configure_ru_from_yang(ru_session, oai, num_rus, &content);
AssertError(success, return false, "[MPLANE] Unable to create content for <edit-config> RPC for start-up procedure.\n");
+21
View File
@@ -25,6 +25,27 @@
#include <string.h>
oper_state_e str_to_enum_oper(const char* value) {
#define X(name, str) if (value != NULL && strcmp(value, str) == 0) return name;
OPER_STATE
#undef X
return OPER_COUNT;
};
admin_state_e str_to_enum_admin(const char* value) {
#define X(name, str) if (value != NULL && strcmp(value, str) == 0) return name;
ADMIN_STATE
#undef X
return ADMIN_COUNT;
};
avail_state_e str_to_enum_avail(const char* value) {
#define X(name, str) if (value != NULL && strcmp(value, str) == 0) return name;
AVAIL_STATE
#undef X
return AVAIL_COUNT;
};
ptp_state_e str_to_enum_ptp(const char* value) {
#define X(name, str) if (value != NULL && strcmp(value, str) == 0) return name;
PTP_STATE
+48
View File
@@ -31,6 +31,53 @@
#define MP_LOG_I(x, args...) LOG_I(HW, "[MPLANE] " x, ##args)
#define MP_LOG_W(x, args...) LOG_W(HW, "[MPLANE] " x, ##args)
#define OPER_STATE \
X(ENABLED_OPER, "enabled") \
X(DISABLED_OPER, "disabled")
typedef enum {
#define X(name, str) name,
OPER_STATE
#undef X
OPER_COUNT
} oper_state_e;
oper_state_e str_to_enum_oper(const char* value);
#define ADMIN_STATE \
X(UNLOCKED_ADMIN, "unlocked") \
X(SHUTTING_DOWN_ADMIN, "shutting-down") \
X(LOCKED_ADMIN, "locked")
typedef enum {
#define X(name, str) name,
ADMIN_STATE
#undef X
ADMIN_COUNT
} admin_state_e;
admin_state_e str_to_enum_admin(const char* value);
#define AVAIL_STATE \
X(NORMAL_AVAIL, "NORMAL") \
X(DEGRADED_AVAIL, "DEGRADED") \
X(FAULTY_AVAIL, "FAULTY")
typedef enum {
#define X(name, str) name,
AVAIL_STATE
#undef X
AVAIL_COUNT
} avail_state_e;
avail_state_e str_to_enum_avail(const char* value);
typedef struct {
oper_state_e oper_state; // "enabled", "disabled"
admin_state_e admin_state; // "unlocked", "shutting-down", "locked"
avail_state_e avail_state; // "NORMAL", "DEGRADED", "FAULTY"
} hardware_notif_t;
#define PTP_STATE \
X(LOCKED_PTP, "LOCKED") \
X(FREERUN_PTP, "FREERUN") \
@@ -60,6 +107,7 @@ typedef enum {
carrier_state_e str_to_enum_carrier(const char* value);
typedef struct {
hardware_notif_t hardware;
ptp_state_e ptp_state; // "LOCKED", "FREERUN", "HOLDOVER"
carrier_state_e rx_carrier_state; // "READY", "DISABLED", "BUSY"
carrier_state_e tx_carrier_state; // "READY", "DISABLED", "BUSY"
+18
View File
@@ -80,6 +80,18 @@ static void log_v2_pm_info(const char *ru_ip_add, struct lyd_node_inner *stats)
meas_list[7], count_list[7]);
}
static void get_hardware_states(struct lyd_node_inner *op, ru_notif_t *answer)
{
struct lyd_node *child = NULL;
LY_LIST_FOR(op->child, child) {
if (strcmp(child->schema->name, "admin-state") == 0) {
answer->hardware.admin_state = str_to_enum_admin(lyd_get_value(child));
} else if (strcmp(child->schema->name, "availability-state") == 0) {
answer->hardware.avail_state = str_to_enum_avail(lyd_get_value(child));
}
}
}
static void recv_notif_v2(struct lyd_node_inner *op, ru_notif_t *answer)
{
const char *notif = op->schema->name;
@@ -92,6 +104,12 @@ static void recv_notif_v2(struct lyd_node_inner *op, ru_notif_t *answer)
answer->tx_carrier_state = str_to_enum_carrier(lyd_get_value(lyd_child(op->child)->next));
} else if (strcmp(notif, "netconf-config-change") == 0) {
answer->config_change = true;
} else if (strcmp(notif, "hardware-state-oper-enabled") == 0) {
answer->hardware.oper_state = ENABLED_OPER;
get_hardware_states(op, answer);
} else if (strcmp(notif, "hardware-state-oper-disabled") == 0) {
answer->hardware.oper_state = DISABLED_OPER;
get_hardware_states(op, answer);
}
}