From 470eb7d9ae26dca793c10ff8403dd41bf197c2c6 Mon Sep 17 00:00:00 2001 From: Itai Baz Date: Tue, 26 Jun 2018 18:38:05 -0700 Subject: [PATCH 1/2] Add PTP support PTP traps + RX/TX meatadata --- inc/saihostif.h | 24 +++++++++++++++++++++++- inc/saitypes.h | 11 +++++++++++ meta/acronyms.txt | 1 + meta/aspell.en.pws | 1 + meta/saimetadatatypes.h | 5 +++++ meta/saisanitycheck.c | 3 +++ 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/inc/saihostif.h b/inc/saihostif.h index ff441497c..b01cc98df 100644 --- a/inc/saihostif.h +++ b/inc/saihostif.h @@ -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, @@ -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 @@ -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 */ diff --git a/inc/saitypes.h b/inc/saitypes.h index 7c3085a01..99de239be 100644 --- a/inc/saitypes.h +++ b/inc/saitypes.h @@ -56,6 +56,12 @@ typedef UINT8 sai_ip6_t[16]; typedef UINT32 sai_switch_hash_seed_t; typedef UINT32 sai_label_id_t; +typedef struct timespec +{ + uint64_t tv_sec; + uint32_t tv_nsec; +} timespec_t; + #include #include @@ -82,6 +88,7 @@ typedef enum #include #include #include +#include typedef int32_t sai_status_t; typedef uint32_t sai_switch_profile_id_t; @@ -118,6 +125,7 @@ typedef int8_t sai_int8_t; typedef size_t sai_size_t; typedef uint64_t sai_object_id_t; typedef void *sai_pointer_t; +typedef struct timespec sai_timespec_t; /** * @def SAI_NULL_OBJECT_ID @@ -1001,6 +1009,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; /** diff --git a/meta/acronyms.txt b/meta/acronyms.txt index 27d19da22..2084aca33 100644 --- a/meta/acronyms.txt +++ b/meta/acronyms.txt @@ -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 diff --git a/meta/aspell.en.pws b/meta/aspell.en.pws index 6ce03ab37..e90a3edd6 100644 --- a/meta/aspell.en.pws +++ b/meta/aspell.en.pws @@ -113,6 +113,7 @@ struct sublayer subnet subnets +timespec timestamp tx uBurst diff --git a/meta/saimetadatatypes.h b/meta/saimetadatatypes.h index 608879b38..0a54b9e8d 100644 --- a/meta/saimetadatatypes.h +++ b/meta/saimetadatatypes.h @@ -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; /** diff --git a/meta/saisanitycheck.c b/meta/saisanitycheck.c index c8905c63f..2f58fc085 100644 --- a/meta/saisanitycheck.c +++ b/meta/saisanitycheck.c @@ -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: @@ -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: @@ -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) { From 51a7df3dc58a5a38461bfe9e605011298335fdb3 Mon Sep 17 00:00:00 2001 From: Itai Baz Date: Fri, 29 Jun 2018 11:39:16 -0700 Subject: [PATCH 2/2] modify struct definitions --- inc/saitypes.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/inc/saitypes.h b/inc/saitypes.h index 99de239be..f00306b1b 100644 --- a/inc/saitypes.h +++ b/inc/saitypes.h @@ -56,12 +56,6 @@ typedef UINT8 sai_ip6_t[16]; typedef UINT32 sai_switch_hash_seed_t; typedef UINT32 sai_label_id_t; -typedef struct timespec -{ - uint64_t tv_sec; - uint32_t tv_nsec; -} timespec_t; - #include #include @@ -88,7 +82,6 @@ typedef enum #include #include #include -#include typedef int32_t sai_status_t; typedef uint32_t sai_switch_profile_id_t; @@ -125,7 +118,12 @@ typedef int8_t sai_int8_t; typedef size_t sai_size_t; typedef uint64_t sai_object_id_t; typedef void *sai_pointer_t; -typedef struct timespec sai_timespec_t; + +typedef struct _sai_timespec_t +{ + uint64_t tv_sec; + uint32_t tv_nsec; +} sai_timespec_t; /** * @def SAI_NULL_OBJECT_ID