Skip to content

Commit e128c5b

Browse files
authored
SAI switch attribute to enable PTP on all ports (opencomputeproject#2148)
Signed-off-by: Rich Sugarman <[email protected]>
1 parent f9b1ddd commit e128c5b

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Global PTP Configuration in SAI Switch
2+
3+
Title | Global PTP Configuration in SAI Switch
4+
------------|----------------------------------------
5+
Authors | Open
6+
Status | Draft
7+
Type | Standards track
8+
Created | 2024-03-03
9+
SAI-Version | 1.15
10+
11+
## Overview
12+
Introducing a PTP (Precision Time Protocol) attribute to the SAI switch object, allowing for switch-wide PTP mode settings that affect all ports on the switch.
13+
14+
A switch that does not set this attribute will observe no change in behavior.
15+
16+
## Motivation
17+
Currently, PTP configuration in SAI is port-based, and many switches only support configuration of PTP on a global basis.
18+
In addition, many existing switches have a configuration model which allows global configuration of PTP, and then override on a port level. SAI should follow this flexible example.
19+
20+
## Technical Specification
21+
22+
### Updated description of existing PORT PTP type - the main comment is new
23+
```c
24+
/**
25+
* @brief PTP mode
26+
*
27+
* These modes can be used at the port and switch level.
28+
* All ports use the value set at the switch level unless explicitly configured
29+
* at the port level to a value other than SAI_PORT_PTP_MODE_NONE.
30+
*/
31+
typedef enum _sai_port_ptp_mode_t
32+
{
33+
/** No special processing for PTP packets */
34+
SAI_PORT_PTP_MODE_NONE,
35+
36+
/** Single-step Timestamp mode for the PTP packets */
37+
SAI_PORT_PTP_MODE_SINGLE_STEP_TIMESTAMP,
38+
39+
/** Two-step Timestamp mode for the PTP packets */
40+
SAI_PORT_PTP_MODE_TWO_STEP_TIMESTAMP,
41+
42+
} sai_port_ptp_mode_t;
43+
44+
45+
### New Switch Attribute
46+
```c
47+
typedef enum _sai_switch_attr_t
48+
{
49+
// ... existing attributes ...
50+
51+
/**
52+
* @brief Global PTP mode configuration
53+
*
54+
* Global PTP mode configuration for the switch.
55+
* Applies to all ports unless overridden by port-specific settings.
56+
*
57+
* @type sai_port_ptp_mode_t
58+
* @flags CREATE_AND_SET
59+
* @default SAI_PORT_PTP_MODE_NONE
60+
*/
61+
SAI_SWITCH_ATTR_PORT_PTP_MODE,
62+
63+
// ... existing attributes ...
64+
} sai_switch_attr_t;
65+
```
66+
67+
## Usage Example
68+
```c
69+
// Set global PTP configuration at switch level
70+
sai_attribute_t attr;
71+
attr.id = SAI_SWITCH_ATTR_PORT_PTP_MODE;
72+
attr.value.s32 = SAI_PORT_PTP_MODE_SINGLE_STEP_TIMESTAMP;
73+
74+
sai_status_t status = sai_switch_api->set_switch_attribute(
75+
switch_id,
76+
&attr);
77+
78+
// Get global PTP configuration
79+
attr.id = SAI_SWITCH_ATTR_PORT_PTP_MODE;
80+
status = sai_switch_api->get_switch_attribute(
81+
switch_id,
82+
1,
83+
&attr);
84+
```
85+
86+
## References
87+
1. IEEE 1588-2008 Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems
88+
2. IEEE 1588-2019 Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems

inc/saiport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ typedef enum _sai_port_priority_flow_control_mode_t
397397

398398
/**
399399
* @brief PTP mode
400+
* These modes can be used at the port and switch level.
401+
* All ports use the value set at the switch level unless explicitly configured
402+
* at the port level to a value other than SAI_PORT_PTP_MODE_NONE.
400403
*/
401404
typedef enum _sai_port_ptp_mode_t
402405
{

inc/saiswitch.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,18 @@ typedef enum _sai_switch_attr_t
32033203
*/
32043204
SAI_SWITCH_ATTR_SHARED_BUFFER_CELL_SIZE,
32053205

3206+
/**
3207+
* @brief Global PTP mode configuration
3208+
*
3209+
* Global PTP mode configuration for the switch.
3210+
* Applies to all ports unless overridden by port-specific settings.
3211+
*
3212+
* @type sai_port_ptp_mode_t
3213+
* @flags CREATE_AND_SET
3214+
* @default SAI_PORT_PTP_MODE_NONE
3215+
*/
3216+
SAI_SWITCH_ATTR_PORT_PTP_MODE,
3217+
32063218
/**
32073219
* @brief End of attributes
32083220
*/

0 commit comments

Comments
 (0)