How to add a custom attribute in SAI

85 views
Skip to first unread message

Lei Shi

unread,
Jan 26, 2021, 3:03:09 AM1/26/21
to sonicproject
Hi, dear SONiC folks,

I want to add a custom attribute in SAI, what i did as follows:
I add my own attribute between of the CUSTOM_RANGE_START and CUSTOM_RANGE_END, and I got a error when compiled it:
/**
 * @brief Attributes for L2MC group
 */
typedef enum _sai_l2mc_group_attr_t
{
    /**
     * @brief Start of attributes
     */
    SAI_L2MC_GROUP_ATTR_START,

    /**
     * @brief Number of L2MC output in the group
     *
     * @type sai_uint32_t
     * @flags READ_ONLY
     */
    SAI_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT = SAI_L2MC_GROUP_ATTR_START,

    /**
     * @brief L2MC member list
     *
     * @type sai_object_list_t
     * @flags READ_ONLY
     * @objects SAI_OBJECT_TYPE_L2MC_GROUP_MEMBER
     */
    SAI_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST,

    /**
     * @brief End of attributes
     */
    SAI_L2MC_GROUP_ATTR_END,

    /** Custom range base value */
    SAI_L2MC_GROUP_ATTR_CUSTOM_RANGE_START = 0x10000000,

    /**
     * @brief L2MC Container default bridge id
     *
     * @type sai_object_id_t
     * @flags CREATE_ONLY
     * @objects SAI_OBJECT_TYPE_BRIDGE
     * @allownull true
     * @default SAI_NULL_OBJECT_ID
     */
    SAI_L2MC_GROUP_ATTR_CUSTOM_L2MC_CONTAINER_BRIDGE_ID,

    /** End of custom range base */
    SAI_L2MC_GROUP_ATTR_CUSTOM_RANGE_END

} sai_l2mc_group_attr_t;

The gray codes is what I added, and the error is:
ASSERT FAILED (on line 217): sai_l2mc_group_attr_t: values are not increasing by 1: last: 1 current: 268435457, should be marked as @flags?

I changed the gray code to different position in sai_l2mc_group_attr_t and got differnet errors... I'll be very appreciate for your help!!

Best Regards,
Lei

jyhe...@gmail.com

unread,
Jan 26, 2021, 7:25:34 PM1/26/21
to sonicproject
You put the "@flags" at wrong place.

Add the gray codes shown below.

/**
 * @brief Attributes for L2MC group
 * @flags Contains flags
 */
typedef enum _sai_l2mc_group_attr_t
{
    /**
     * @brief Start of attributes
     */
    SAI_L2MC_GROUP_ATTR_START,

lifepion...@gmail.com 在 2021年1月26日 星期二下午4:03:09 [UTC+8] 的信中寫道:

Lei Shi

unread,
Jan 28, 2021, 2:02:55 AM1/28/21
to sonicproject
Thanks a lot, jyhe!
Reply all
Reply to author
Forward
0 new messages