From cb28e4a08e542a54e5ba3301e87a28b78c15b9f3 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Sat, 18 Aug 2018 12:38:44 -0700 Subject: [PATCH] Support ecn on/off on a queue (#577) * Use "[WRED_PROFILE|]" as a CLI signal to unbind wred profile from a queue or a list of queues; Add the parsing and processing logic in qosorch to support such an operation Signed-off-by: Wenda * Add print out for debugging purpose modified: orchagent/qosorch.cpp * Adjust log level Signed-off-by: Wenda * Change to use "[]" as a signal to unbind wred profile from a queue or a list of queues Signed-off-by: Wenda * Remove logs for debugging * Adjust code format * Address comments Signed-off-by: Wenda --- orchagent/orch.cpp | 22 +++++++++++++++++++++- orchagent/orch.h | 1 + orchagent/qosorch.cpp | 23 +++++++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 3645f9d913f7..4825d82d6cb0 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -260,13 +260,18 @@ bool Orch::bake() - Validates reference has proper format which is [table_name:object_name] - validates table_name exists - validates object with object_name exists + +- Special case: +- Deem reference format [] as valid, and return true. But in such a case, +- both type_name and object_name are cleared to empty strings as an +- indication to the caller of the special case */ bool Orch::parseReference(type_map &type_maps, string &ref_in, string &type_name, string &object_name) { SWSS_LOG_ENTER(); SWSS_LOG_DEBUG("input:%s", ref_in.c_str()); - if (ref_in.size() < 3) + if (ref_in.size() < 2) { SWSS_LOG_ERROR("invalid reference received:%s\n", ref_in.c_str()); return false; @@ -276,6 +281,17 @@ bool Orch::parseReference(type_map &type_maps, string &ref_in, string &type_name SWSS_LOG_ERROR("malformed reference:%s. Must be surrounded by [ ]\n", ref_in.c_str()); return false; } + if (ref_in.size() == 2) + { + // value set by user is "[]" + // Deem it as a valid format + // clear both type_name and object_name + // as an indication to the caller that + // such a case has been encountered + type_name.clear(); + object_name.clear(); + return true; + } string ref_content = ref_in.substr(1, ref_in.size() - 2); vector tokens; tokens = tokenize(ref_content, delimiter); @@ -331,6 +347,10 @@ ref_resolve_status Orch::resolveFieldRefValue( { return ref_resolve_status::not_resolved; } + else if (ref_type_name.empty() && object_name.empty()) + { + return ref_resolve_status::empty; + } sai_object = (*(type_maps[ref_type_name]))[object_name]; hit = true; } diff --git a/orchagent/orch.h b/orchagent/orch.h index 48239af82377..dfbadb62bff3 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -155,6 +155,7 @@ typedef enum field_not_found, multiple_instances, not_resolved, + empty, failure } ref_resolve_status; diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index e8489d703abb..e4c5c96d16cf 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1182,13 +1182,28 @@ task_process_status QosOrch::handleQueueTable(Consumer& consumer) } else if (resolve_result != ref_resolve_status::field_not_found) { - if(ref_resolve_status::not_resolved == resolve_result) + if (ref_resolve_status::empty == resolve_result) { - SWSS_LOG_INFO("Missing or invalid wred reference"); + SWSS_LOG_INFO("Missing wred reference. Unbind wred profile from queue"); + // NOTE: The wred profile is un-bound from the port. But the wred profile itself still exists + // and stays untouched. + result = applyWredProfileToQueue(port, queue_ind, SAI_NULL_OBJECT_ID); + if (!result) + { + SWSS_LOG_ERROR("Failed unbinding field:%s from port:%s, queue:%zd, line:%d", wred_profile_field_name.c_str(), port.m_alias.c_str(), queue_ind, __LINE__); + return task_process_status::task_failed; + } + } + else if (ref_resolve_status::not_resolved == resolve_result) + { + SWSS_LOG_INFO("Invalid wred reference"); return task_process_status::task_need_retry; } - SWSS_LOG_ERROR("Resolving wred reference failed"); - return task_process_status::task_failed; + else + { + SWSS_LOG_ERROR("Resolving wred reference failed"); + return task_process_status::task_failed; + } } } }