Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAI Proposal for Counter enhancement. #1941

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

rajkumar38
Copy link
Contributor

@rajkumar38 rajkumar38 commented Jan 7, 2024

Within the current framework of SAI, objects such as vlan, router-interface, tunnel, queue, port, and others come with built-in statistical enumeration. The expectation is that these statistics will be counted by default upon the creation of objects.
With this proposal,

  • User has flexibility to decide which object and what stat-ids should support counting.
  • Helps to optimally use the hardware counting resources.

@kcudnik
Copy link
Collaborator

kcudnik commented Jan 16, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rlhui
Copy link
Collaborator

rlhui commented Jan 25, 2024

@JaiOCP , @srikrishnagopu will review this.

@rck-innovium
Copy link
Contributor

@JaiOCP , @srikrishnagopu will review this.

@JaiOCP @srikrishnagopu Can you please review as well as let us know about your preference among the two approaches. We can then do the required SAI .h file additions to the PR.

Copy link
Contributor

@srikrishnagopu srikrishnagopu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments/questions.

Overall, Option 1 looks to be a better approach than Option 2. I will have @JaiOCP also weigh in.

/** Counting is disabled */
SAI_STATS_COUNT_MODE_NONE

} sai_stats_count_mode_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leverage sai_counter_stat_t and add these new enums to sai_counter_stat_t ? This enum is similar to sai_counter_stat_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not mix count mode with sai_counter_stat_t.

* @flags CREATE_AND_SET
* @default SAI_STATS_COUNT_MODE_PACKET_AND_BYTE
*/
SAI_PORT_ATTR_STAT_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename it to SAI_PORT_ATTR_STAT_MODE or SAI_PORT_ATTR_COUNTER_MODE ?

Stat mode SAI_STATS_COUNT_MODE_NONE should indicate that counter has been disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the doc with "SAI_PORT_ATTR_STAT_MODE " . Since Option 2 is suggested, this change will not be applicable.

* @default SAI_NULL_OBJECT_ID
*/

SAI_ROUTER_INTERFACE_ATTR_IN_COUNTER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this mode be any better if we define something

 * @type sai_object_list_t
 * @flags CREATE_AND_SET
 * @objects SAI_OBJECT_TYPE_COUNTER
 * @allownull true
 * @default SAI_NULL_OBJECT_ID
 */

SAI_ROUTER_INTERFACE_ATTR_COUNTER_IDS

and enforce the list size as SAI_ROUTER_INTERFACE_STAT_MAX and indexing based on the stat ID ?

Copy link
Contributor Author

@rajkumar38 rajkumar38 Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below are the CONs of using list indexed with stat ID,

  • Need to add new stats enum (SAI_XXX_STAT_END)to identify the max number ( saivlan, sairouterinterface, saitunnel).
  • Enforce stats id enum to be contiguous.
  • How to handle existing disjoint sets in the stat-id enum. Adjusting existing enums to determine MAX_STAT index may not be backward compatible.
    For example, in saiport.h, "SAI_PORT_STAT_END" is last enum and debug counters are part of stats enum list. How to arrive the max id in such scenario ? Can we move "SAI_PORT_STAT_END" before "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE = 0x00001000". This will break backward compatibility.
  • Irrespective of supported enum set, application and SAI must manage the state for SAI_ROUTER_INTERFACE_STAT_MAX stat-ids.

@JaiOCP
Copy link
Contributor

JaiOCP commented Feb 27, 2024

Quick comment regarding choice of Option 1 and Option 2.
Option 1:
Doesn't provide granularity of enabling and disabling at granular level. This approach also means that all the counters will be oneof [packet, packet/byte, byte, none]. This does not tend to usecase well as the graluarity of packet or byte count changes for a given counter type.
Last problem and probably the deal breaker for this approach is that it doesn't tend well to modern approach of flex counters, where counter as a generic pool can be allocated on a per type basis.

My input will be to go with Option 2. This is more work but is forward looking and works well with flex counter pool HW design.

@rajkumar38
Copy link
Contributor Author

Quick comment regarding choice of Option 1 and Option 2. Option 1: Doesn't provide granularity of enabling and disabling at granular level. This approach also means that all the counters will be oneof [packet, packet/byte, byte, none]. This does not tend to usecase well as the graluarity of packet or byte count changes for a given counter type. Last problem and probably the deal breaker for this approach is that it doesn't tend well to modern approach of flex counters, where counter as a generic pool can be allocated on a per type basis.

My input will be to go with Option 2. This is more work but is forward looking and works well with flex counter pool HW design.

Thanks @JaiOCP for the inputs. One of the challenge with Option 2 to minimize the number of attributes. To address this, We came up with option 3. Below is the highlight of option 3 and doc is updated with same. Pls review and let know for any comments.

Option 3 Introduce a new attribute value type holding list of stat_id to counter object.

saitypes.h

typedef struct 
{
      /** Object type of the stat enum*/
      sai_object_type_t  object_type;

      /** Stat enum value */
      sai_stat_id_t      stat_enum;

      /** Counter ObjectId associated with stat enum */
      sai_object_id_t    counter_id;

} sai_counter_id_t;

typedef struct _sai_counter_list_t
{
    /** Number of stats */
    uint32_t count;

    /** List of stat-id to counter object */
    sai_counter_id_t *list;

} sai_counter_list_t;


typedef union _sai_attribute_value_t
{
 

    /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_STATID_COUNTER_LIST */
    sai_counter_list_t statidcounterlist;

} sai_attribute_value_t;


saimetadatypes.h

typedef enum _sai_attr_value_type_t
{

    /**
     * @brief Attribute value is STAT enum to COUNTER object list.
     */
    SAI_ATTR_VALUE_TYPE_STATID_COUNTER_LIST
  
} sai_attr_value_type_t;

Introduce an attribute for stat-id counter object list in each of the object file.

sairouterinterface.h Query and update the list only for supported stat enum

 * @brief Router interface counter objects
 * Counter Object list for supported router interface stats enum 
 * @type sai_counter_list_t
 * @flags CREATE_AND_SET
 * @allownull true
 * @default SAI_NULL_OBJECT_ID
 */
 SAI_ROUTER_INTERFACE_ATTR_COUNTER_IDS

@kcudnik
Copy link
Collaborator

kcudnik commented Mar 17, 2024

there will be problem withh sai_counter_id_t, since it contains sai_object_id_t, which cant't be tracked for object dependency if used in list as attribute, this will not pass validation and sanity checks

sai_stat_id_t stat_enum;

/** Counter ObjectId associated with stat enum */
sai_object_id_t counter_id;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be a problem when making it a struct there is no easy way to track dependencies on that, it would need to be an attribute

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can discuss this on SAI community meeting

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe converting this entire structure to new object type and each field to separate attributee taht would solve the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the inputs, @kcudnik . I have replaced option 3 and defined new attributes as part of saicounter.h to realize the functionality. Pls review and let know for any comments.

@kcudnik
Copy link
Collaborator

kcudnik commented Apr 24, 2024

please fix build errors

inc/saiport.h Outdated Show resolved Hide resolved
@tjchadaga
Copy link
Collaborator

@JaiOCP, @srikrishnagopu - could you please help complete the review on this?

Copy link
Contributor

@JaiOCP JaiOCP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final review going on with internal team.

* @default empty
*/
SAI_PORT_ATTR_SELECTIVE_COUNTER_LIST,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to provide port object level control for enabling/disabling packet or bye count.
With the current proposal 1 port can have multiple stats object (of type selective) where each stats object can be enabled independently for only packet, only byte or both. This though provides a fine grain control but do not allow coarse control where all the stats object for a given port can be consistently enabled for either packet or byte or both

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JaiOCP for the review comments. As suggested, I have added new attribute to control counting of supported PKT/BYTE/Both stats at object level.
Also I have updated the HLD with work flow. Pls review option 3.
PR is updated with other SAI modules which can use this functionality.

* @default empty
*/
SAI_QUEUE_ATTR_SELECTIVE_COUNTER_LIST,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for port. Need a queue level control for all the stats object

* @default empty
*/
SAI_ROUTER_INTERFACE_ATTR_SELECTIVE_COUNTER_LIST,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for port/queue. Need a RIF level control

* @default empty
*/
SAI_TUNNEL_ATTR_SELECTIVE_COUNTER_LIST,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a tunnel a level control

* @default empty
*/
SAI_VLAN_ATTR_SELECTIVE_COUNTER_LIST,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a vlan level control

@kcudnik
Copy link
Collaborator

kcudnik commented Jul 19, 2024

Instead od adding same attributes for all objects would it be better to add global API for this ?

@rajkumar38
Copy link
Contributor Author

Instead od adding same attributes for all objects would it be better to add global API for this ?

Hi @kcudnik, If we have to manage this by global API, we may have to define attribute in saicounter.h to store the list of OIDs using a specific counter object. IMO this doesn't look correct. May be we can discuss this in next weekly meeting.

@tjchadaga
Copy link
Collaborator

@kcudnik - could you please help clarify the proposed change or help sign off on the current one?

@kcudnik
Copy link
Collaborator

kcudnik commented Aug 23, 2024

Instead of adding 2 attributes to all objects add global API that will query those values, no need for definig which objects support that, if some will not support API will retire not supported

@rajkumar38
Copy link
Contributor Author

Instead of adding 2 attributes to all objects add global API that will query those values, no need for definig which objects support that, if some will not support API will retire not supported

This proposal is not about about query. Here the primary requirement is to let user select on which of the objects ( say router interfaces) or which stat-id's per object , they need statistics to be enabled/disabled.
Note that it is not at object type level but at per object instance (OID). NOS can enable/disable the counting and accordingly set these two attributes to pass the configuration to vendor SAI.
Without attributes defined, we are not able to visualize how to achieve this using global API.
If needed we discuss and go over the proposal again in the community meeting.

Copy link
Contributor

@JaiOCP JaiOCP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tjchadaga
Copy link
Collaborator

Instead of adding 2 attributes to all objects add global API that will query those values, no need for definig which objects support that, if some will not support API will retire not supported

This proposal is not about about query. Here the primary requirement is to let user select on which of the objects ( say router interfaces) or which stat-id's per object , they need statistics to be enabled/disabled. Note that it is not at object type level but at per object instance (OID). NOS can enable/disable the counting and accordingly set these two attributes to pass the configuration to vendor SAI. Without attributes defined, we are not able to visualize how to achieve this using global API. If needed we discuss and go over the proposal again in the community meeting.

@kcudnik - Could you please help clarify further? This comment has been discussed a few times in the community meeting, but there does not seem to be a clear way of achieving this with global API.

@rlhui rlhui added the reviewed PR is discussed in SAI Meeting label Sep 19, 2024
@kcudnik
Copy link
Collaborator

kcudnik commented Oct 2, 2024

Instead of adding 2 attributes to all objects add global API that will query those values, no need for definig which objects support that, if some will not support API will retire not supported

This proposal is not about about query. Here the primary requirement is to let user select on which of the objects ( say router interfaces) or which stat-id's per object , they need statistics to be enabled/disabled. Note that it is not at object type level but at per object instance (OID). NOS can enable/disable the counting and accordingly set these two attributes to pass the configuration to vendor SAI. Without attributes defined, we are not able to visualize how to achieve this using global API. If needed we discuss and go over the proposal again in the community meeting.

@kcudnik - Could you please help clarify further? This comment has been discussed a few times in the community meeting, but there does not seem to be a clear way of achieving this with global API.

please clarify which part you have trouble to understand, i think global API for this would be enough, also please resolve conflicts

Signed-off-by: Rajkumar P R <rpennadamram@marvell.com>
@tjchadaga
Copy link
Collaborator

@kcudnik - please help sign off on this, as discussed in the community meeting.

@tjchadaga tjchadaga merged commit f23185d into opencomputeproject:master Oct 7, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed PR is discussed in SAI Meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants