diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 6568c63d37c7..fca324e5fb49 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -352,6 +352,27 @@ bool MirrorOrch::validateSrcPortList(const string& srcPortList) return true; } +bool MirrorOrch::isHwResourcesAvailable() +{ + uint64_t availCount = 0; + + sai_status_t status = sai_object_type_get_availability( + gSwitchId, SAI_OBJECT_TYPE_MIRROR_SESSION, 0, nullptr, &availCount + ); + if (status != SAI_STATUS_SUCCESS) + { + if (status == SAI_STATUS_NOT_SUPPORTED) + { + SWSS_LOG_WARN("Mirror session resource availability monitoring is not supported. Skipping ..."); + return true; + } + + return parseHandleSaiStatusFailure(handleSaiGetStatus(SAI_API_MIRROR, status)); + } + + return availCount > 0; +} + task_process_status MirrorOrch::createEntry(const string& key, const vector& data) { SWSS_LOG_ENTER(); @@ -359,8 +380,7 @@ task_process_status MirrorOrch::createEntry(const string& key, const vectorattach(this, entry.dstIp); } + SWSS_LOG_NOTICE("Created mirror session %s", key.c_str()); + return task_process_status::task_success; } diff --git a/orchagent/mirrororch.h b/orchagent/mirrororch.h index b31d58bff3d6..d498a7ef6c92 100644 --- a/orchagent/mirrororch.h +++ b/orchagent/mirrororch.h @@ -104,6 +104,8 @@ class MirrorOrch : public Orch, public Observer, public Subject // session_name -> VLAN | monitor_port_alias | next_hop_ip map m_recoverySessionMap; + bool isHwResourcesAvailable(); + task_process_status createEntry(const string&, const vector&); task_process_status deleteEntry(const string&);