Skip to content

Commit

Permalink
fix the type for SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE (#1942)
Browse files Browse the repository at this point in the history
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 [email protected]

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
  • Loading branch information
alpeshspatel authored Oct 11, 2021
1 parent b592ad7 commit ef6b5d4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion orchagent/pfcactionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef6b5d4

Please sign in to comment.