From bbf4b86e67dd73cfdb249c3a539f23652246d94d Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Wed, 8 May 2024 01:41:51 +0800 Subject: [PATCH] [yang] Support ASIC/SDK health event (#17879) Support ASIC/SDK health event - Suppress ASIC/SDK health event configuration - New event Signed-off-by: Stephen Sun --- src/sonic-yang-models/doc/Configuration.md | 22 +++++ src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 6 ++ .../tests/sonic-events-swss.json | 14 +++ .../tests/suppress_asic_sdk_health_event.json | 23 +++++ .../tests_config/sonic-events-swss.json | 45 ++++++++- .../suppress_asic_sdk_health_event.json | 93 +++++++++++++++++++ .../yang-models/sonic-events-swss.yang | 36 +++++++ .../sonic-suppress-asic-sdk-health-event.yang | 59 ++++++++++++ 9 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/suppress_asic_sdk_health_event.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/suppress_asic_sdk_health_event.json create mode 100644 src/sonic-yang-models/yang-models/sonic-suppress-asic-sdk-health-event.yang diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index bb0b2f87c630..37f193e1c5b9 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -13,6 +13,7 @@ Table of Contents * [ACL and Mirroring](#acl-and-mirroring) * [BGP BBR](#bgp-bbr) + * [ASIC SDK health event](#asic-sdk-health-event) * [BGP Device Global](#bgp-device-global) * [BGP Sessions](#bgp-sessions) * [BUFFER_PG](#buffer_pg) @@ -383,6 +384,27 @@ The **BGP_BBR** table contains device-level BBR state. } } ``` +### ASIC SDK health event + +ASIC/SDK health event related configuration is defined in **SUPPRESS_ASIC_SDK_HEALTH_EVENT** table. + +``` +"SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "notice": { + "categories": [ + "asic_hw" + ], + "max_events": "1000" + }, + "warning": { + "categories": [ + "software", + "cpu_hw" + ] + } +} +``` + ### BGP Device Global The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index b1257f6eacab..6748bb137848 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -160,6 +160,7 @@ def run(self): './yang-models/sonic-routing-policy-sets.yang', './yang-models/sonic-sflow.yang', './yang-models/sonic-snmp.yang', + './yang-models/sonic-suppress-asic-sdk-health-event.yang', './yang-models/sonic-syslog.yang', './yang-models/sonic-system-aaa.yang', './yang-models/sonic-system-tacacs.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 33c9c265ad2d..71c957a545f9 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2539,6 +2539,12 @@ } }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "notice": { + "categories": ["firmware", "asic_hw"], + "max_events": "1024" + } + }, "SYSTEM_DEFAULTS": { "tunnel_qos_remap": { "status": "enabled" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-swss.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-swss.json index 56a05d1736b3..a6c3d9332c08 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-swss.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-swss.json @@ -92,5 +92,19 @@ }, "SONIC_EVENTS_SWSS_SELECT_OPERATION_FAILURE_VALID": { "desc": "VALID SELECT_OPERATION_FAILURE EVENT." + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_VALID": { + "desc": "VALID ASIC_SDK_HEALTH EVENT." + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_VALID_MASIC": { + "desc": "VALID ASIC_SDK_HEALTH EVENT." + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_INVALID_SEVERITY": { + "desc": "ASIC_SDK_HEALTH_INVALID_SEVERITY failure.", + "eStrKey": "InvalidValue" + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_INVALID_CATEGORY": { + "desc": "ASIC_SDK_HEALTH_INVALID_CATEGORY failure.", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/suppress_asic_sdk_health_event.json b/src/sonic-yang-models/tests/yang_model_tests/tests/suppress_asic_sdk_health_event.json new file mode 100644 index 000000000000..a96a95deb280 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/suppress_asic_sdk_health_event.json @@ -0,0 +1,23 @@ +{ + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_FATAL": { + "desc": "Load suppress ASIC/SDK health event list for fatal." + }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_WARNING": { + "desc": "Load suppress ASIC/SDK health event list for warning." + }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_NOTICE": { + "desc": "Load suppress ASIC/SDK health event list for notice." + }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_INVALID_SEVERITY": { + "desc": "Load suppress ASIC/SDK health event list for notice.", + "eStrKey": "InvalidValue" + }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_NEGATIVE_MAX_EVENTS": { + "desc": "Load suppress ASIC/SDK health event list missing name.", + "eStrKey": "InvalidValue" + }, + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_INVALID_MAX_EVENTS": { + "desc": "Load suppress ASIC/SDK health event list missing name.", + "eStrKey": "InvalidValue" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-swss.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-swss.json index 919468dcbc7d..1c2dcaa4ce7e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-swss.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-swss.json @@ -244,7 +244,7 @@ } } }, - "SONIC_EVENTS_SWSS_SELECT_OPERATION_FAILURE_VALID": { + "SONIC_EVENTS_SWSS_SELECT_OPERATION_FAILURE_VALID": { "sonic-events-swss:sonic-events-swss": { "sonic-events-swss:select-operation-failure": { "operation_result": "operation_result", @@ -252,5 +252,48 @@ "timestamp": "1985-04-12T23:20:50.52Z" } } + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_VALID": { + "sonic-events-swss:sonic-events-swss": { + "sonic-events-swss:asic-sdk-health-event": { + "severity": "fatal", + "category": "asic_hw", + "description": "\ndescription\n", + "timestamp": "1985-04-12T23:20:50.52Z", + "sai_timestamp": "1985-04-12 23:20:50" + } + } + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_VALID_MASIC": { + "sonic-events-swss:sonic-events-swss": { + "sonic-events-swss:asic-sdk-health-event": { + "severity": "fatal", + "category": "asic_hw", + "asic_name": "asic0", + "description": "\ndescription\n", + "timestamp": "1985-04-12T23:20:50.52Z", + "sai_timestamp": "1985-04-12 23:20:50" + } + } + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_INVALID_SEVERITY": { + "sonic-events-swss:sonic-events-swss": { + "sonic-events-swss:asic-sdk-health-event": { + "severity": "unknown", + "category": "asic_hw", + "description": "\ndescription\n", + "timestamp": "1985-04-12T23:20:50.52Z" + } + } + }, + "SONIC_EVENTS_SWSS_ASIC_SDK_HEALTH_INVALID_CATEGORY": { + "sonic-events-swss:sonic-events-swss": { + "sonic-events-swss:asic-sdk-health-event": { + "severity": "fatal", + "category": "unknown", + "description": "\ndescription\n", + "timestamp": "1985-04-12T23:20:50.52Z" + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/suppress_asic_sdk_health_event.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/suppress_asic_sdk_health_event.json new file mode 100644 index 000000000000..452d12f10530 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/suppress_asic_sdk_health_event.json @@ -0,0 +1,93 @@ +{ + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_FATAL": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "fatal", + "categories": ["software","firmware"] + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_WARNING": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "warning", + "categories": ["asic_hw","cpu_hw"] + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_VALID_NOTICE": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "notice", + "categories": ["software","firmware","cpu_hw","asic_hw"], + "max_events": "100" + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_INVALID_SEVERITY": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "unknown", + "categories": ["software","firmware","cpu_hw","asic_hw"] + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_INVALID_CATEGORY": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "notice", + "categories": ["software","unknown","cpu_hw","asic_hw"] + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_NEGATIVE_MAX_EVENTS": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "notice", + "max_events": "-1" + } + ] + } + } + }, + + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST_INVALID_MAX_EVENTS": { + "sonic-suppress-asic-sdk-health-event:sonic-suppress-asic-sdk-health-event": { + "sonic-suppress-asic-sdk-health-event:SUPPRESS_ASIC_SDK_HEALTH_EVENT": { + "SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST": [ + { + "severity": "notice", + "max_events": "NaN" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-events-swss.yang b/src/sonic-yang-models/yang-models/sonic-events-swss.yang index 4092fe42d2f6..66242d2ecd78 100644 --- a/src/sonic-yang-models/yang-models/sonic-events-swss.yang +++ b/src/sonic-yang-models/yang-models/sonic-events-swss.yang @@ -148,5 +148,41 @@ module sonic-events-swss { uses evtcmn:sonic-events-cmn; } + + container asic-sdk-health-event { + evtcmn:ALARM_SEVERITY_MAJOR; + description + "Declares an event for ASIC/SDK health event."; + leaf asic_name { + type string { + pattern 'asic[0-9]{1,2}'; + } + } + leaf severity { + type enumeration { + enum fatal; + enum warning; + enum notice; + } + } + leaf category { + type enumeration { + enum software; + enum firmware; + enum cpu_hw; + enum asic_hw; + } + } + leaf description { + type string; + } + leaf sai_timestamp { + type string { + pattern '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}'; + } + } + + uses evtcmn:sonic-events-cmn; + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-suppress-asic-sdk-health-event.yang b/src/sonic-yang-models/yang-models/sonic-suppress-asic-sdk-health-event.yang new file mode 100644 index 000000000000..650911cc8261 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-suppress-asic-sdk-health-event.yang @@ -0,0 +1,59 @@ +module sonic-suppress-asic-sdk-health-event { + + yang-version 1.1; + + namespace "http://github.com/sonic-net/sonic-suppress-asic-sdk-health-event"; + + prefix sch; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "Suppress ASIC/SDK health event yang Module for SONiC OS"; + + revision 2023-11-29 { + description + "Initial revision"; + } + + container sonic-suppress-asic-sdk-health-event { + + container SUPPRESS_ASIC_SDK_HEALTH_EVENT { + + description "SUPPRESS_ASIC_SDK_HEALTH_EVENT part of config_db.json"; + + list SUPPRESS_ASIC_SDK_HEALTH_EVENT_LIST { + + key "severity"; + + leaf severity { + type enumeration { + enum fatal; + enum warning; + enum notice; + } + description "Severity of the ASIC/SDK health event to suppress"; + } + + leaf max_events { + type uint32; + description "Maximum of events that can be stored in the database"; + } + + leaf-list categories { + type enumeration { + enum software; + enum firmware; + enum cpu_hw; + enum asic_hw; + } + description "Category of the ASIC/SDK health event to suppress"; + } + } + } + } +}