Skip to content

Commit

Permalink
Rename chunk size
Browse files Browse the repository at this point in the history
Signed-off-by: Ze Gan <ganze718@gmail.com>
  • Loading branch information
Pterosaur committed Nov 26, 2024
1 parent 37a6584 commit 5160f2d
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 180 deletions.
257 changes: 148 additions & 109 deletions doc/TAM/SAI-Proposal-TAM-stream-telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
- [Netlink message](#netlink-message)
- [Bandwidth Estimation](#bandwidth-estimation)
- [SAI API](#sai-api)
- [TAM Telemetry state machine](#tam-telemetry-state-machine)
- [Initialize TAM cache count for Switch](#initialize-tam-cache-count-for-switch)
- [TAM Telemetry type state machine](#tam-telemetry-type-state-machine)
- [Initialize TAM global configuration for Switch](#initialize-tam-global-configuration-for-switch)
- [Creating HOSTIF object](#creating-hostif-object)
- [Creating HOSTIF trap group](#creating-hostif-trap-group)
- [Creating HOSTIF user defined trap](#creating-hostif-user-defined-trap)
Expand All @@ -29,12 +29,14 @@
- [Creating TAM collector object](#creating-tam-collector-object)
- [Creating TAM report object](#creating-tam-report-object)
- [Creating TAM telemetry type object](#creating-tam-telemetry-type-object)
- [Generating TAM telemetry type configuration](#generating-tam-telemetry-type-configuration)
- [Creating TAM telemetry object](#creating-tam-telemetry-object)
- [Creating TAM counter subscription objects](#creating-tam-counter-subscription-objects)
- [Creating TAM object](#creating-tam-object)
- [Query IPFIX template](#query-ipfix-template)
- [Bound telemetry stream](#bound-telemetry-stream)
- [Query stream telemetry capability](#query-stream-telemetry-capability)
- [Query telemetry type capability](#query-telemetry-type-capability)

## Revision

Expand Down Expand Up @@ -397,8 +399,8 @@ erDiagram
SAI_ID SAI_VALUE "Comments"
SAI_SWITCH_ATTR_TAM_OBJECT_ID sai_tam_obj
SAI_SWITCH_ATTR_TAM_BUFFER_SIZE buffer_size
SAI_SWITCH_ATTR_TAM_CHUNK_SIZE chunk_size
SAI_SWITCH_ATTR_TAM_TELEMETRY_STATE_CHANGE_NOTIFY on_tam_telemetry_state_change
SAI_SWITCH_ATTR_TAM_REPORT_CHUNK_SIZE chunk_size
SAI_SWITCH_ATTR_TAM_TELEMETRY_TYPE_STATE_CHANGE_NOTIFY on_tam_telemetry_state_change
}
host_table_entry |o--|| hostif: binds
Expand Down Expand Up @@ -428,40 +430,40 @@ erDiagram
| TAM_report | per profile / per type of one profile |
| TAM_counter_subscription | per stats of object |

#### TAM Telemetry state machine
#### TAM Telemetry type state machine

``` mermaid
---
title: TAM Telemetry state machine
title: TAM Telemetry type state machine
---
stateDiagram-v2
direction LR
state "Stop TAM Stream" as stop
state "Start TAM Stream" as start
state "Commit configure" as commit
state "Stop TAM type Stream" as stop
state "Start TAM type Stream" as start
state "Generate configure" as generate
state "Config ready" as ready
state join_commit <<join>>
[*] --> stop: Object create
stop --> start: NOS set
stop --> join_commit: NOS set
[*] --> stop: <0> Object create
stop --> start: <6> NOS set
stop --> generate: <1> NOS set
start --> join_commit: NOS set (The record stream will not stop and original templates will still be used)
join_commit --> commit: Vendor start preparing templates based on bounded telemetry types
start --> stop: NOS set
start --> generate: <4> NOS set (The record stream will not stop and original templates will still be used)
start --> stop: <5> NOS set
commit --> ready: Vendor set (callback via notification)
generate --> ready: <2> Vendor set (callback via notification)
ready --> start: NOS set (New templates will be applied to generate the new record streaming)
ready --> stop: NOS set
ready --> start: <3> NOS set (New templates will be applied to generate the new record streaming)
ready --> stop: <7> NOS set
stop --> [*]: Object remove
stop --> [*]: <8> Object remove
note right of generate: Vendor start preparing templates based on bounded reports
```

#### Initialize TAM cache count for Switch
#### Initialize TAM global configuration for Switch

``` c++
/**
Expand Down Expand Up @@ -499,29 +501,29 @@ typedef enum _sai_switch_attr_t
* @flags CREATE_AND_SET
* @default 65535
*/
SAI_SWITCH_ATTR_TAM_CHUNK_SIZE,
SAI_SWITCH_ATTR_TAM_REPORT_CHUNK_SIZE,

/**
* @brief Set TAM telemetry state change event notification callback function passed to the adapter.
*
* Use sai_tam_telemetry_state_change_notification_fn as notification function.
* Use sai_tam_tel_type_state_change_notification_fn as notification function.
*
* @type sai_pointer_t sai_tam_telemetry_state_change_notification_fn
* @type sai_pointer_t sai_tam_tel_type_state_change_notification_fn
* @flags CREATE_AND_SET
* @default NULL
*/
SAI_SWITCH_ATTR_TAM_TELEMETRY_STATE_CHANGE_NOTIFY,
SAI_SWITCH_ATTR_TAM_TELEMETRY_TYPE_STATE_CHANGE_NOTIFY,

// ...
} sai_switch_attr_t;

sai_attr_list[0].id = SAI_SWITCH_ATTR_TAM_BUFFER_SIZE;
sai_attr_list[0].value.u32 = buffer_size;

sai_attr_list[1].id = SAI_SWITCH_ATTR_TAM_CHUNK_SIZE;
sai_attr_list[1].id = SAI_SWITCH_ATTR_TAM_REPORT_CHUNK_SIZE;
sai_attr_list[1].value.u32 = chunk_size;

sai_attr_list[2].id = SAI_SWITCH_ATTR_TAM_TELEMETRY_STATE_CHANGE_NOTIFY;
sai_attr_list[2].id = SAI_SWITCH_ATTR_TAM_TELEMETRY_TYPE_STATE_CHANGE_NOTIFY;
sai_attr_list[2].value.u32 = on_tam_telemetry_state_change;

// ...
Expand Down Expand Up @@ -659,25 +661,96 @@ create_tam_report(&sai_tam_report_obj, switch_id, attr_count, sai_attr_list);

``` c++

typedef enum _sai_tam_tel_type_mode_t
/**
* @brief TAM telemetry type state of state machine
*/
typedef enum _sai_tam_tel_type_state_t
{
/**
* @brief This TAM telemetry type supports to bound multiple counter types
* @brief Telemetry type is stopped
*/
SAI_TAM_TEL_TYPE_MODE_MIXED_TYPE,
SAI_TAM_TEL_TYPE_STATE_STOPPED,

/**
* @brief This TAM telemetry type supports to bound only one counter type
* @brief Telemetry type is started
*/
SAI_TAM_TEL_TYPE_MODE_SINGLE_TYPE,
SAI_TAM_TEL_TYPE_STATE_STARTED,

} sai_tam_tel_type_mode_t;
/**
* @brief Telemetry type config is generating
*/
SAI_TAM_TEL_TYPE_STATE_CONFIG_GENERATING,

/**
* @brief Telemetry type config is ready
*/
SAI_TAM_TEL_TYPE_STATE_CONFIG_READY,

} sai_tam_tel_type_state_t;

// Check the capability of telemetry type mode
sai_s32_list_t mode[2] = {-1, -1};
/**
* @brief Attributes for TAM report
*/
typedef enum _sai_tam_tel_type_attr_t
{

sai_query_attribute_enum_values_capability(switch_id, SAI_OBJECT_TYPE_TAM_TEL_TYPE, SAI_TAM_TEL_TYPE_ATTR_MODE, mode)
// ...

/**
* @brief The mode of TAM telemetry type
*
* @type sai_tam_tel_type_mode_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_TAM_TEL_TYPE_ATTR_MODE,

/**
* @brief TAM telemetry type state
*
* @type sai_tam_tel_type_state_t
* @flags CREATE_AND_SET
* @default SAI_TAM_TELEMETRY_STATE_STOPPED
*/
SAI_TAM_TEL_TYPE_ATTR_STATE,

/**
* @brief Current state of TAM telemetry type
*
* @type sai_tam_tel_type_state_t
* @flags READ_ONLY
*/
SAI_TAM_TEL_TYPE_ATTR_CURRENT_STATE,

/**
* @brief Query IPFIX template
* SAI adapter will return error if COUNTER_SUBSCRIPTION_LIST and REPORT_ID is not configured.
* Return the IPFIX template for this telemetry type object
*
* @type sai_u8_list_t
* @flags READ_ONLY
*/
SAI_TAM_TEL_TYPE_ATTR_IPFIX_TEMPLATES,

// ...

} sai_tam_tel_type_attr_t;


/**
* @brief TAM telemetry state change callback
*
* @count data[count]
*
* @param[in] tam_tel_id Create Telemetry Object ID
* @param[in] state The state of the telemetry object
*/
typedef void (*sai_tam_tel_type_state_change_notification_fn)(
_In_ sai_object_id_t tam_tel_id,
_In_ sai_tam_tel_type_state_t state);

```
``` c++
sai_attr_list[0].id = SAI_TAM_TEL_TYPE_ATTR_TAM_TELEMETRY_TYPE;
sai_attr_list[0].value.s32 = SAI_TAM_TELEMETRY_TYPE_COUNTER_SUBSCRIPTION;
Expand All @@ -690,7 +763,7 @@ sai_attr_list[1].value.boolean = true;
// sai_attr_list[2].value.boolean = true;
sai_attr_list[2].id = SAI_TAM_TEL_TYPE_ATTR_MODE ;
sai_attr_list[2].value.boolean = mode[0]; // SAI_TAM_TEL_TYPE_MODE_SINGLE_TYPE or SAI_TAM_TEL_TYPE_MODE_MIXED_TYPE
sai_attr_list[2].value.boolean = tel_type_mode[0]; // SAI_TAM_TEL_TYPE_MODE_SINGLE_TYPE or SAI_TAM_TEL_TYPE_MODE_MIXED_TYPE
// ...
Expand All @@ -702,6 +775,17 @@ create_tam_tel_type(&sai_tam_tel_type_obj, switch_id, attr_count, sai_attr_list)
```

#### Generating TAM telemetry type configuration

``` c++

sai_attr.id = SAI_TAM_TEL_TYPE_ATTR_STATE;
sai_attr.value.s32 = SAI_TAM_TEL_TYPE_STATE_CONFIG_GENERATING;

set_tam_tel_type_attribute(&sai_tam_tel_type_obj, &sai_attr);

```
#### Creating TAM telemetry object
``` c++
Expand Down Expand Up @@ -814,77 +898,6 @@ create_tam(&sai_tam_obj, switch_id, attr_count, sai_attr_list);

``` c++

/**
* @brief TAM telemetry state of state machine
*/
typedef enum _sai_tam_telemetry_state_t
{
/**
* @brief Telemetry is stopped
*/
SAI_TAM_TELEMETRY_STATE_STOPPED,

/**
* @brief Telemetry is started
*/
SAI_TAM_TELEMETRY_STATE_STARTED,

/**
* @brief Telemetry config is committed
*/
SAI_TAM_TELEMETRY_STATE_CONFIG_COMMITTED,

/**
* @brief Telemetry config is ready
*/
SAI_TAM_TELEMETRY_STATE_CONFIG_READY,

} sai_tam_telemetry_state_t;

/**
* @brief Attributes for TAM report
*/
typedef enum _sai_tam_telemetry_attr_t
{

// ...

/**
* @brief TAM telemetry state
*
* @type sai_tam_telemetry_state_t
* @flags CREATE_AND_SET
* @default SAI_TAM_TELEMETRY_STATE_STOPPED
*/
SAI_TAM_TELEMETRY_ATTR_STATE,

/**
* @brief Current state of TAM telemetry
*
* @type sai_tam_telemetry_state_t
* @flags READ_ONLY
*/
SAI_TAM_TELEMETRY_ATTR_CURRENT_STATE,

/**
* @brief Query IPFIX template
*
* Return a list of IPFIX templates
*
* @type sai_u8_list_t
* @flags READ_ONLY
*/
SAI_TAM_TELEMETRY_ATTR_IPFIX_TEMPLATES,


// ...

} sai_tam_telemetry_attr_t;

```

``` c++

std::vector<uint8_t> template_buffer(64*1024*10, 0);

sai_attribute_t sai_attr_list;
Expand All @@ -893,7 +906,7 @@ sai_attr_list[0].id = SAI_TAM_TELEMETRY_ATTR_IPFIX_TEMPLATES;
sai_attr_list[0].value.u8list.list = template_buffer.data();
sai_attr_list[0].value.u8list.count = template_buffer.size();

get_tam_telemetry_attribute(&sai_tam_report_obj, 1, &sai_attr_list);
get_tam_tel_type_attribute(&sai_tam_report_obj, 1, &sai_attr_list);

```
Expand Down Expand Up @@ -965,3 +978,29 @@ typedef struct _sai_stat_st_capability_list_t
} sai_stat_st_capability_list_t;

```
#### Query telemetry type capability
```c++
typedef enum _sai_tam_tel_type_mode_t
{
/**
* @brief This TAM telemetry type supports to bound multiple counter types
*/
SAI_TAM_TEL_TYPE_MODE_MIXED_TYPE,
/**
* @brief This TAM telemetry type supports to bound only one counter type
*/
SAI_TAM_TEL_TYPE_MODE_SINGLE_TYPE,
} sai_tam_tel_type_mode_t;
// Check the capability of telemetry type mode
sai_s32_list_t tel_type_mode[2] = {-1, -1};
sai_query_attribute_enum_values_capability(switch_id, SAI_OBJECT_TYPE_TAM_TEL_TYPE, SAI_TAM_TEL_TYPE_ATTR_MODE, tel_type_mode)
```
Loading

0 comments on commit 5160f2d

Please sign in to comment.