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

Add PTP support #841

Merged
merged 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion inc/saihostif.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ typedef enum _sai_hostif_trap_type_t
/** Default action is drop */
SAI_HOSTIF_TRAP_TYPE_PAGP = 0x0000000f,

/**
* @brief PTP traffic (EtherType = 0x88F7 or UDP dst port == 319 or UDP dst port == 320)
* (default packet action is drop)
*/
SAI_HOSTIF_TRAP_TYPE_PTP = 0x00000010,

/**
* @brief PTP packet sent from CPU with updated TX timestamp
* (default packet action is drop)
*/
SAI_HOSTIF_TRAP_TYPE_PTP_TX_EVENT = 0x00000011,

/** Switch traps custom range start */
SAI_HOSTIF_TRAP_TYPE_SWITCH_CUSTOM_RANGE_BASE = 0x00001000,

Expand Down Expand Up @@ -1060,7 +1072,7 @@ typedef enum _sai_hostif_packet_attr_t
*
* For receive case, filled with the egress destination port for unicast packets.
* Egress LAG member port id to be filled for the LAG destination case.
* Applicable for use-case like samplepacket traps.
* Applicable for use-case like samplepacket traps or PTP TX event
*
* @type sai_object_id_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
Expand All @@ -1080,6 +1092,16 @@ typedef enum _sai_hostif_packet_attr_t
*/
SAI_HOSTIF_PACKET_ATTR_BRIDGE_ID,

/**
* @brief Timestamp
*
* The timestamp on which the packet was received, or sent for PTP TX event.
*
* @type sai_timespec_t
* @flags READ_ONLY
*/
SAI_HOSTIF_PACKET_ATTR_TIMESTAMP,

/**
* @brief End of attributes
*/
Expand Down
9 changes: 9 additions & 0 deletions inc/saitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ typedef size_t sai_size_t;
typedef uint64_t sai_object_id_t;
typedef void *sai_pointer_t;

typedef struct _sai_timespec_t
{
uint64_t tv_sec;
uint32_t tv_nsec;
} sai_timespec_t;

/**
* @def SAI_NULL_OBJECT_ID
* SAI NULL object ID
Expand Down Expand Up @@ -1001,6 +1007,9 @@ typedef union _sai_attribute_value_t

/** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PORT_EYE_VALUES_LIST */
sai_port_eye_values_list_t porteyevalues;

/** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_TIMESPEC */
sai_timespec_t timespec;
} sai_attribute_value_t;

/**
Expand Down
1 change: 1 addition & 0 deletions meta/acronyms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PBS - Peak Burst Size
PCI - Peripheral Component Interconnect
PFC - Priority Flow Control
PIR - Peak Information Rate
PTP - Precision time protocol
QOS - Quality of Service
RARP - Reverse Address Resolution Protocol
RFC - Request For Comment
Expand Down
1 change: 1 addition & 0 deletions meta/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct
sublayer
subnet
subnets
timespec
timestamp
tx
uBurst
Expand Down
5 changes: 5 additions & 0 deletions meta/saimetadatatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ typedef enum _sai_attr_value_type_t
*/
SAI_ATTR_VALUE_TYPE_PORT_EYE_VALUES_LIST,

/**
* @brief Attribute value is timespec.
*/
SAI_ATTR_VALUE_TYPE_TIMESPEC,

} sai_attr_value_type_t;

/**
Expand Down
3 changes: 3 additions & 0 deletions meta/saisanitycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ void check_attr_object_type_provided(
case SAI_ATTR_VALUE_TYPE_SEGMENT_LIST:
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS_LIST:
case SAI_ATTR_VALUE_TYPE_PORT_EYE_VALUES_LIST:
case SAI_ATTR_VALUE_TYPE_TIMESPEC:

case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_BOOL:
case SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_UINT8:
Expand Down Expand Up @@ -833,6 +834,7 @@ void check_attr_default_required(
case SAI_ATTR_VALUE_TYPE_MAC:
case SAI_ATTR_VALUE_TYPE_IP_ADDRESS:
case SAI_ATTR_VALUE_TYPE_IP_PREFIX:
case SAI_ATTR_VALUE_TYPE_TIMESPEC:
break;

case SAI_ATTR_VALUE_TYPE_CHARDATA:
Expand Down Expand Up @@ -2392,6 +2394,7 @@ void check_attr_is_primitive(
case SAI_ATTR_VALUE_TYPE_UINT32_RANGE:
case SAI_ATTR_VALUE_TYPE_UINT64:
case SAI_ATTR_VALUE_TYPE_UINT8:
case SAI_ATTR_VALUE_TYPE_TIMESPEC:

if (!md->isprimitive)
{
Expand Down