From ef6b5d48297f7f19a8ec57e2d7b997fd0919bb9d Mon Sep 17 00:00:00 2001 From: Alpesh Patel Date: Mon, 11 Oct 2021 11:08:57 -0400 Subject: [PATCH] fix the type for SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE (#1942) Fixing the type for SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE It is incorrectly set to u32 and is not clearing the higher 32 bits in the union Sample code: attr.id = SAI_BUFFER_PROFILE_ATTR_POOL_ID; attr.value.oid = getPool(ingress); <<<<-- the higher order 32 bits were retrieved for BUFFER_PROFILE_ATTR_BUFFER_SIZE attribs.push_back(attr); attr.id = SAI_BUFFER_PROFILE_ATTR_THRESHOLD_MODE; attr.value.u32 = SAI_BUFFER_PROFILE_THRESHOLD_MODE_DYNAMIC; attribs.push_back(attr); attr.id = SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE; attr.value.u64 = 0; <<<<-------------------------------- This was u32 earlier attribs.push_back(attr); Signed-off-by: Alpesh S Patel alpesh@cisco.com What I did Change the attribute value type from u32 to u64 as in SAI header file - https://github.com/opencomputeproject/SAI/blob/v1.7/inc/saibuffer.h /** * @brief Reserved buffer size in bytes * * @type sai_uint64_t * @flags MANDATORY_ON_CREATE | CREATE_AND_SET */ SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE, /** @ignore - for backward compatibility */ SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE = SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE, Why I did it since u32 was getting set and the actual data type is u64, at SAI layer, when the value is retrieved as u64, the upper 32 bits are read from the previously written attribute value (pool oid) How I verified it Made this change in sonic and verified it on the hardware platform via debug and correct operation --- orchagent/pfcactionhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/pfcactionhandler.cpp b/orchagent/pfcactionhandler.cpp index 12072480f5..0a24b1ba01 100644 --- a/orchagent/pfcactionhandler.cpp +++ b/orchagent/pfcactionhandler.cpp @@ -784,7 +784,7 @@ void PfcWdZeroBufferHandler::ZeroBufferProfile::createZeroBufferProfile(bool ing attribs.push_back(attr); attr.id = SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE; - attr.value.u32 = 0; + attr.value.u64 = 0; attribs.push_back(attr); attr.id = SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH;