diff --git a/inc/sai.h b/inc/sai.h index d8f90c44b..f37e00aee 100644 --- a/inc/sai.h +++ b/inc/sai.h @@ -83,6 +83,8 @@ #include "saiicmpecho.h" #include "saisynce.h" #include "saivirtualchannel.h" +#include "saiofh.h" +#include "saiofhroute.h" /** * @defgroup SAI SAI - Entry point specific API definitions. @@ -155,6 +157,8 @@ typedef enum _sai_api_t SAI_API_PREFIX_COMPRESSION = 53, /**< sai_prefix_compression_api_t */ SAI_API_SYNCE = 54, /**< sai_synce_api_t */ SAI_API_VIRTUAL_CHANNEL = 55, /**< sai_virtual_channel_api_t */ + SAI_API_OFH = 56, /**< sai_ofh_api_t */ + SAI_API_OFH_ROUTE = 57, /**< sai_ofh_route_api_t */ SAI_API_MAX, /**< total number of APIs */ /** diff --git a/inc/saidebugcounter.h b/inc/saidebugcounter.h index cc9714e8e..76b07dfa8 100644 --- a/inc/saidebugcounter.h +++ b/inc/saidebugcounter.h @@ -331,6 +331,21 @@ typedef enum _sai_in_drop_reason_t /** IPv4 or IPv6 Routing table (LPM) unicast miss */ SAI_IN_DROP_REASON_LPM_MISS = 0x00000039, + /** OFH packet TTL expired */ + SAI_IN_DROP_REASON_OFH_TTL, + + /** OFH Routing table miss */ + SAI_IN_DROP_REASON_OFH_MISS, + + /** OFH Routing table action discard */ + SAI_IN_DROP_REASON_OFH_DISCARD, + + /** OFH VLAN drop */ + SAI_IN_DROP_REASON_OFH_VLAN_DROP, + + /** OFH VLAN to virtual router id drop */ + SAI_IN_DROP_REASON_OFH_VLAN_TO_VRID_DROP, + /** End of in drop reasons */ SAI_IN_DROP_REASON_END, @@ -377,6 +392,9 @@ typedef enum _sai_out_drop_reason_t */ SAI_OUT_DROP_REASON_TUNNEL_LOOPBACK_PACKET_DROP, + /** OFH VLAN drop */ + SAI_OUT_DROP_REASON_OFH_VLAN_DROP, + /** End of out drop reasons */ SAI_OUT_DROP_REASON_END, diff --git a/inc/saiobject.h b/inc/saiobject.h index 84dd67018..f99483a0f 100644 --- a/inc/saiobject.h +++ b/inc/saiobject.h @@ -36,6 +36,7 @@ #include #include #include +#include /* new experimental object type includes */ #include @@ -140,6 +141,9 @@ typedef union _sai_object_key_entry_t /** @validonly object_type == SAI_OBJECT_TYPE_ENI_TRUSTED_VNI_ENTRY */ sai_eni_trusted_vni_entry_t eni_trusted_vni_entry; + /** @validonly object_type == SAI_OBJECT_TYPE_OFH_ROUTE_ENTRY */ + sai_ofh_route_entry_t ofh_route_entry; + /* Add new experimental entries above this line */ } sai_object_key_entry_t; diff --git a/inc/saiofh.h b/inc/saiofh.h new file mode 100644 index 000000000..af73570cc --- /dev/null +++ b/inc/saiofh.h @@ -0,0 +1,404 @@ +/** + * Copyright (c) 2014 Microsoft Open Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT + * LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS + * FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing + * permissions and limitations under the License. + * + * Microsoft would like to thank the following companies for their review and + * assistance with these files: Intel Corporation, Mellanox Technologies Ltd, + * Dell Products, L.P., Facebook, Inc., Marvell International Ltd. + * + * @file saiofh.h + * + * @brief This module defines SAI Optimized Forwarding Header + */ + +#if !defined (__SAIOFH_H_) +#define __SAIOFH_H_ + +#include + +/** + * @defgroup SAIOFH SAI - OFH specific API definitions + * + * @{ + */ + +/** + * @brief OFH types + */ +typedef enum _sai_ofh_type_t +{ + /** + * @brief ESUN + */ + SAI_OFH_TYPE_ESUN, + + /** + * @brief AFH Type 1 + */ + SAI_OFH_TYPE_AFH_TYPE_1, + + /** + * @brief AFH Type 2 + */ + SAI_OFH_TYPE_AFH_TYPE_2, + + /** + * @brief UFH Type 1 + */ + SAI_OFH_TYPE_UFH_TYPE_1, + + /** + * @brief UFH Type 2 + */ + SAI_OFH_TYPE_UFH_TYPE_2, +} sai_ofh_type_t; + +/** + * @brief Attribute Id for SAI OFH object + */ +typedef enum _sai_ofh_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_OFH_ATTR_START, + + /** + * @brief Type of OFH header + * + * @type sai_ofh_type_t + * @flags CREATE_ONLY + * @default SAI_OFH_TYPE_AFH_TYPE_1 + */ + SAI_OFH_ATTR_TYPE = SAI_OFH_ATTR_START, + + /** + * @brief OFH ether type identifier + * + * @type sai_uint16_t + * @flags CREATE_AND_SET + * @isvlan false + * @default 0 + */ + SAI_OFH_ATTR_ETHERTYPE, + + /** + * @brief OFH Version Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_VER_OFFSET, + + /** + * @brief OFH Version Field Width in Bits. + * Value of 0 bits means that field is not configured. + * ESUN Version: 2 bits + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_VER_WIDTH, + + /** + * @brief OFH Flow Label Present Field Bit Offset + * This bit specifies the presence of flow label + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_F_OFFSET, + + /** + * @brief OFH Flow Label Present Field width in Bits. + * Value of 0 bits means that field is not configured. + * ESUN:1 bit AFH:1 bit + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_F_WIDTH, + + /** + * @brief OFH COS Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_COS_OFFSET, + + /** + * @brief OFH COS Field Width in Bits + * Number of bits are 6. Value of 0 bits means that field is not configured + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 6 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_COS_WIDTH, + + /** + * @brief OFH ECN Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_ECN_OFFSET, + + /** + * @brief OFH ECN Field Width in Bits + * Value of 0 bits means that field is not configured + * ESUN: 2 bits + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_ECN_WIDTH, + + /** + * @brief OFH Flow Label Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_FLOW_LABEL_OFFSET, + + /** + * @brief OFH Flow Label Field Width in Bits + * Value of 0 bits means that field is not configured + * ESUN: 16 bits + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_FLOW_LABEL_WIDTH, + + /** + * @brief OFH TTL Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_TTL_OFFSET, + + /** + * @brief OFH TTL Field Width in Bits + * Value of 0 bits means that field is not configured + * ESUN: 4 bits + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_TTL_WIDTH, + + /** + * @brief OFH User Defined Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_UD_OFFSET, + + /** + * @brief OFH User Define Field Width in Bits + * Value of 0 bits means that field is not configured + * ESUN: 2bit user defined + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_ESUN + */ + SAI_OFH_ATTR_UD_WIDTH, + + /** + * @brief OFH AR Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_AR_OFFSET, + + /** + * @brief OFH AR Field Width in Bits + * Number of bits are 1. Value of 0 bits means that field is not configured + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_AR_WIDTH, + + /** + * @brief OFH Congestion Notification Message Eligible Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_C_OFFSET, + + /** + * @brief OFH Congestion Notification Message Eligible Field Width in Bits + * Number of bits are 1. Value of 0 bits means that field is not configured + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_C_WIDTH, + + /** + * @brief OFH Congestion Notification Message Field Bit Offset + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_CNM_OFFSET, + + /** + * @brief OFH Congestion Notification Message Field Width in bits + * Number of bits are 1. Value of 0 bits means that field is not configured + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + * @validonly SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_1 or SAI_OFH_ATTR_TYPE == SAI_OFH_TYPE_AFH_TYPE_2 + */ + SAI_OFH_ATTR_CNM_WIDTH, + + /** + * @brief OFH header size + * + * @type sai_uint8_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_OFH_ATTR_HDR_SIZE, + + /** + * @brief End of attributes + */ + SAI_OFH_ATTR_END, + + /** Custom range base value */ + SAI_OFH_ATTR_CUSTOM_RANGE_START = 0x10000000, + + /** End of custom range base */ + SAI_OFH_ATTR_CUSTOM_RANGE_END + +} sai_ofh_attr_t; + +/** + * @brief Create and return a OFH object + * + * @param[out] ofh_id OFH object + * @param[in] switch_id Switch object id + * @param[in] attr_count Number of attributes + * @param[in] attr_list Array of attributes + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_create_ofh_fn)( + _Out_ sai_object_id_t *ofh_id, + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Deletes a specified OFH object. + * + * @param[in] ofh_id OFH object to be removed. + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_remove_ofh_fn)( + _In_ sai_object_id_t ofh_id); + +/** + * @brief Set OFH attribute value(s). + * + * @param[in] ofh_id TAM id + * @param[in] attr Attribute to set + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_set_ofh_attribute_fn)( + _In_ sai_object_id_t ofh_id, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get values for specified OFH attributes. + * + * @param[in] ofh_id OFH object id + * @param[in] attr_count Number of attributes + * @param[inout] attr_list Array of attributes + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_get_ofh_attribute_fn)( + _In_ sai_object_id_t ofh_id, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +/** + * @brief OFH methods table retrieved with sai_api_query() + */ +typedef struct _sai_ofh_api_t +{ + /** + * @brief SAI OFH API set + */ + sai_create_ofh_fn create_ofh; + sai_remove_ofh_fn remove_ofh; + sai_set_ofh_attribute_fn set_ofh_attribute; + sai_get_ofh_attribute_fn get_ofh_attribute; +} sai_ofh_api_t; + +/** + * @} + */ +#endif /** __SAIOFH_H_ */ diff --git a/inc/saiofhroute.h b/inc/saiofhroute.h new file mode 100644 index 000000000..1740203aa --- /dev/null +++ b/inc/saiofhroute.h @@ -0,0 +1,336 @@ +/** + * Copyright (c) 2014 Microsoft Open Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT + * LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS + * FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing + * permissions and limitations under the License. + * + * Microsoft would like to thank the following companies for their review and + * assistance with these files: Intel Corporation, Mellanox Technologies Ltd, + * Dell Products, L.P., Facebook, Inc., Marvell International Ltd. + * + * @file saiofhroute.h + * + * @brief This module defines SAI OFH Route Entry interface + */ + +#if !defined (__SAIOFHROUTE_H_) +#define __SAIOFHROUTE_H_ + +#include + +/** + * @defgroup SAIOFHROUTE SAI - OFH Route specific API definitions + * + * @{ + */ + +/** + * @brief Attribute Id for SAI OFH route object + */ +typedef enum _sai_ofh_route_entry_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_OFH_ROUTE_ENTRY_ATTR_START, + + /* READ-WRITE */ + + /** + * @brief Packet action + * + * @type sai_packet_action_t + * @flags CREATE_AND_SET + * @default SAI_PACKET_ACTION_FORWARD + */ + SAI_OFH_ROUTE_ENTRY_ATTR_PACKET_ACTION = SAI_OFH_ROUTE_ENTRY_ATTR_START, + + /** + * @brief Generate User Defined Trap ID for trap/log actions + * + * When it is SAI_NULL_OBJECT_ID, then packet will not be trapped. + * + * @type sai_object_id_t + * @flags CREATE_AND_SET + * @objects SAI_OBJECT_TYPE_HOSTIF_USER_DEFINED_TRAP + * @allownull true + * @default SAI_NULL_OBJECT_ID + */ + SAI_OFH_ROUTE_ENTRY_ATTR_USER_TRAP_ID, + + /** + * @brief Next hop or next hop group id for the packet, or a router interface + * in case of directly reachable route, or the CPU port in case of IP2ME route + * + * The next hop id is only effective when the packet action is one of the + * following: FORWARD, COPY, LOG, TRANSIT. + * + * The next hop id can be a generic next hop object, such as next hop, next + * hop group. Directly reachable routes are the IP subnets that are + * directly attached to the router. For such routes, fill the router + * interface id to which the subnet is attached. IP2ME route adds a local + * router IP address. For such routes, fill the CPU port + * (#SAI_SWITCH_ATTR_CPU_PORT). + * When pointing to a next hop group which is empty, the effective routing + * action will be DROP. + * + * When it is SAI_NULL_OBJECT_ID, then packet will be dropped. + * + * @type sai_object_id_t + * @flags CREATE_AND_SET + * @objects SAI_OBJECT_TYPE_NEXT_HOP, SAI_OBJECT_TYPE_NEXT_HOP_GROUP, SAI_OBJECT_TYPE_ROUTER_INTERFACE, SAI_OBJECT_TYPE_PORT + * @allownull true + * @default SAI_NULL_OBJECT_ID + */ + SAI_OFH_ROUTE_ENTRY_ATTR_NEXT_HOP_ID, + + /** + * @brief User based Meta Data + * + * Value Range #SAI_SWITCH_ATTR_ROUTE_DST_USER_META_DATA_RANGE + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_OFH_ROUTE_ENTRY_ATTR_META_DATA, + + /** READ-ONLY */ + + /** + * @brief OFH Route entry type + * + * @type sai_ip_addr_family_t + * @flags READ_ONLY + * @isresourcetype true + */ + SAI_OFH_ROUTE_ENTRY_ATTR_IP_ADDR_FAMILY, + + /** + * @brief Attach a counter + * + * When it is empty, then packet hits won't be counted + * + * @type sai_object_id_t + * @flags CREATE_AND_SET + * @objects SAI_OBJECT_TYPE_COUNTER + * @allownull true + * @default SAI_NULL_OBJECT_ID + */ + SAI_OFH_ROUTE_ENTRY_ATTR_COUNTER_ID, + + /** + * @brief End of attributes + */ + SAI_OFH_ROUTE_ENTRY_ATTR_END, + + /** Custom range base value */ + SAI_OFH_ROUTE_ENTRY_ATTR_CUSTOM_RANGE_START = 0x10000000, + + /** End of custom range base */ + SAI_OFH_ROUTE_ENTRY_ATTR_CUSTOM_RANGE_END + +} sai_ofh_route_entry_attr_t; + +/** + * @brief Unicast route entry + */ +typedef struct _sai_ofh_route_entry_t +{ + /** + * @brief Switch ID + * + * @objects SAI_OBJECT_TYPE_SWITCH + */ + sai_object_id_t switch_id; + + /** + * @brief Virtual Router ID + * + * @objects SAI_OBJECT_TYPE_VIRTUAL_ROUTER + */ + sai_object_id_t vr_id; + + /** + * @brief OFH Destination + */ + sai_ofh_addr_and_mask_t destination; + +} sai_ofh_route_entry_t; + +/** + * @brief Create OFH Route + * + * Note: OFH Destination ID/mask expected in Network Byte Order. + * + * @param[in] ofh_route_entry Route entry + * @param[in] attr_count Number of attributes + * @param[in] attr_list Array of attributes + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_create_ofh_route_entry_fn)( + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Remove OFH Route + * + * Note: Destination ID/mask expected in Network Byte Order. + * + * @param[in] ofh_route_entry Route entry + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_remove_ofh_route_entry_fn)( + _In_ const sai_ofh_route_entry_t *ofh_route_entry); + +/** + * @brief Set OFH route attribute value + * + * @param[in] ofh_route_entry Route entry + * @param[in] attr Attribute + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_set_ofh_route_entry_attribute_fn)( + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get OFH route attribute value + * + * @param[in] ofh_route_entry Route entry + * @param[in] attr_count Number of attributes + * @param[inout] attr_list Array of attributes + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_get_ofh_route_entry_attribute_fn)( + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +/** + * @brief Bulk create OFH route entry + * + * @param[in] object_count Number of objects to create + * @param[in] ofh_route_entry List of object to create + * @param[in] attr_count List of attr_count. Caller passes the number + * of attribute for each object to create. + * @param[in] attr_list List of attributes for every object. + * @param[in] mode Bulk operation error handling mode. + * @param[out] object_statuses List of status for every object. Caller needs to + * allocate the buffer + * + * @return #SAI_STATUS_SUCCESS on success when all objects are created or + * #SAI_STATUS_FAILURE when any of the objects fails to create. When there is + * failure, Caller is expected to go through the list of returned statuses to + * find out which fails and which succeeds. + */ +typedef sai_status_t (*sai_bulk_create_ofh_route_entry_fn)( + _In_ uint32_t object_count, + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ const uint32_t *attr_count, + _In_ const sai_attribute_t **attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + +/** + * @brief Bulk remove OFH route entry + * + * @param[in] object_count Number of objects to remove + * @param[in] ofh_route_entry List of objects to remove + * @param[in] mode Bulk operation error handling mode. + * @param[out] object_statuses List of status for every object. Caller needs to + * allocate the buffer + * + * @return #SAI_STATUS_SUCCESS on success when all objects are removed or + * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is + * failure, Caller is expected to go through the list of returned statuses to + * find out which fails and which succeeds. + */ +typedef sai_status_t (*sai_bulk_remove_ofh_route_entry_fn)( + _In_ uint32_t object_count, + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + +/** + * @brief Bulk set attribute on OFH route entry + * + * @param[in] object_count Number of objects to set attribute + * @param[in] ofh_route_entry List of objects to set attribute + * @param[in] attr_list List of attributes to set on objects, one attribute per object + * @param[in] mode Bulk operation error handling mode. + * @param[out] object_statuses List of status for every object. Caller needs to + * allocate the buffer + * + * @return #SAI_STATUS_SUCCESS on success when all objects are removed or + * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is + * failure, Caller is expected to go through the list of returned statuses to + * find out which fails and which succeeds. + */ +typedef sai_status_t (*sai_bulk_set_ofh_route_entry_attribute_fn)( + _In_ uint32_t object_count, + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ const sai_attribute_t *attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + +/** + * @brief Bulk get attribute on OFH route entry + * + * @param[in] object_count Number of objects to set attribute + * @param[in] ofh_route_entry List of objects to set attribute + * @param[in] attr_count List of attr_count. Caller passes the number + * of attribute for each object to get + * @param[inout] attr_list List of attributes to set on objects, one attribute per object + * @param[in] mode Bulk operation error handling mode + * @param[out] object_statuses List of status for every object. Caller needs to + * allocate the buffer + * + * @return #SAI_STATUS_SUCCESS on success when all objects are removed or + * #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is + * failure, Caller is expected to go through the list of returned statuses to + * find out which fails and which succeeds. + */ +typedef sai_status_t (*sai_bulk_get_ofh_route_entry_attribute_fn)( + _In_ uint32_t object_count, + _In_ const sai_ofh_route_entry_t *ofh_route_entry, + _In_ const uint32_t *attr_count, + _Inout_ sai_attribute_t **attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses); + +/** + * @brief OFH Router entry methods table retrieved with sai_api_query() + */ +typedef struct _sai_ofh_route_api_t +{ + sai_create_ofh_route_entry_fn create_ofh_route_entry; + sai_remove_ofh_route_entry_fn remove_ofh_route_entry; + sai_set_ofh_route_entry_attribute_fn set_ofh_route_entry_attribute; + sai_get_ofh_route_entry_attribute_fn get_ofh_route_entry_attribute; + + sai_bulk_create_ofh_route_entry_fn create_ofh_route_entries; + sai_bulk_remove_ofh_route_entry_fn remove_ofh_route_entries; + sai_bulk_set_ofh_route_entry_attribute_fn set_ofh_route_entries_attribute; + sai_bulk_get_ofh_route_entry_attribute_fn get_ofh_route_entries_attribute; + +} sai_ofh_route_api_t; + +/** + * @} + */ +#endif /** __SAIOFHROUTE_H_ */ diff --git a/inc/saiport.h b/inc/saiport.h index 8c14e8ad2..10a9e3b65 100644 --- a/inc/saiport.h +++ b/inc/saiport.h @@ -3327,6 +3327,16 @@ typedef enum _sai_port_attr_t */ SAI_PORT_ATTR_UNKNOWN_MULTICAST_STORM_CONTROL_POLICER_ID, + /** + * @brief OFH headers + * + * @type sai_object_list_t + * @flags CREATE_ONLY + * @objects SAI_OBJECT_TYPE_OFH + * @default empty + */ + SAI_PORT_ATTR_OFH, + /** * @brief End of attributes */ diff --git a/inc/saiswitch.h b/inc/saiswitch.h index cd5dde15f..40931d349 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -3607,6 +3607,40 @@ typedef enum _sai_switch_attr_t */ SAI_SWITCH_ATTR_NEXT_HOP_GROUP_HW_PROTECTION_SWITCHOVER_NOTIFY, + /** + * @brief OFH headers + * + * @type sai_object_list_t + * @flags CREATE_AND_SET + * @objects SAI_OBJECT_TYPE_OFH + * @default empty + */ + SAI_SWITCH_ATTR_OFH, + + /** + * @brief OFH header max size + * + * @type sai_int8_t + * @flags READ_ONLY + */ + SAI_SWITCH_ATTR_OFH_MAX_SIZE, + + /** + * @brief The OFH Route Table size + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_SWITCH_ATTR_OFH_ROUTE_TABLE_SIZE, + + /** + * @brief Available OFH routes + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_SWITCH_ATTR_AVAILABLE_OFH_ROUTE_ENTRY, + /** * @brief End of attributes */ diff --git a/inc/saitypes.h b/inc/saitypes.h index 287a9e0da..e208d95fe 100644 --- a/inc/saitypes.h +++ b/inc/saitypes.h @@ -306,6 +306,8 @@ typedef enum _sai_object_type_t SAI_OBJECT_TYPE_VIRTUAL_CHANNEL = 116, SAI_OBJECT_TYPE_CBFC_CREDIT_POOL = 117, SAI_OBJECT_TYPE_CBFC_CREDIT_PROFILE = 118, + SAI_OBJECT_TYPE_OFH = 119, + SAI_OBJECT_TYPE_OFH_ROUTE_ENTRY = 120, /** Must remain in last position */ SAI_OBJECT_TYPE_MAX, @@ -471,6 +473,51 @@ typedef struct _sai_ip_prefix_list_t sai_ip_prefix_t *list; } sai_ip_prefix_list_t; +typedef enum _sai_ofh_addr_family_t +{ + SAI_OFH_ADDR_FAMILY_ESUN, + + SAI_OFH_ADDR_FAMILY_AFH_T1, + + SAI_OFH_ADDR_FAMILY_AFH_T2, + + SAI_OFH_ADDR_FAMILY_UFH_T1, + + SAI_OFH_ADDR_FAMILY_UFH_T2, +} sai_ofh_addr_family_t; + +/** + * @extraparam sai_ofh_addr_family_t ofh_addr_family + */ +typedef union _sai_ofh_addr_t +{ + /** @validonly ofh_addr_family == SAI_OFH_ADDR_FAMILY_ESUN */ + sai_mac_t esun; + + /** @validonly ofh_addr_family == SAI_OFH_ADDR_FAMILY_AFH_T1 */ + sai_mac_t afh_t1; + + /** @validonly ofh_addr_family == SAI_OFH_ADDR_FAMILY_AFH_T2 */ + sai_mac_t afh_t2; + + /** @validonly ofh_addr_family == SAI_OFH_ADDR_FAMILY_UFH_T1 */ + sai_uint32_t ufh_t1; + + /** @validonly ofh_addr_family == SAI_OFH_ADDR_FAMILY_UFH_T2 */ + sai_uint16_t ufh_t2; +} sai_ofh_addr_t; + +typedef struct _sai_ofh_addr_and_mask_t +{ + sai_ofh_addr_family_t ofh_addr_family; + + /** @passparam ofh_addr_family */ + sai_ofh_addr_t ofh_addr; + + /** @passparam ofh_addr_family */ + sai_ofh_addr_t ofh_mask; +} sai_ofh_addr_and_mask_t; + /** * @brief Attribute data for #SAI_PORT_ATTR_PRBS_RX_STATUS */ diff --git a/inc/saivirtualrouter.h b/inc/saivirtualrouter.h index ea68a902c..56c0394e9 100644 --- a/inc/saivirtualrouter.h +++ b/inc/saivirtualrouter.h @@ -115,6 +115,15 @@ typedef enum _sai_virtual_router_attr_t */ SAI_VIRTUAL_ROUTER_ATTR_LABEL, + /** + * @brief Admin OFH state + * + * @type bool + * @flags CREATE_AND_SET + * @default true + */ + SAI_VIRTUAL_ROUTER_ATTR_ADMIN_OFH_STATE, + /** * @brief End of attributes */ diff --git a/meta/acronyms.txt b/meta/acronyms.txt index d940caaad..a8cf3bab6 100644 --- a/meta/acronyms.txt +++ b/meta/acronyms.txt @@ -2,6 +2,7 @@ ACK - Acknowledgement ACL - Access Control List AES - Advanced Encryption Standard +AFH - AI Fabric Header AN - Association Number AN - Auto Negotiation API - Application Program Interface @@ -56,6 +57,7 @@ EEPROM - Electrically erasable programmable read-only memory ENI - Elastic Network Interface ERSPAN - Encapsulated Remote SPAN ESN - Extended Sequence Number +ESUN - Ethernet for Scale Up Networks EWMA - Exponentially Weighted Moving Average FCS - Frame Check Sequence FD - File Descriptor @@ -117,6 +119,7 @@ NTPCLIENT - Network Time Protocol Client NTPSERVER - Network Time Protocol Server NVGRE - Network Virtualization using Generic Routing Encapsulation OAM - Operations Administration and Maintenance +OFH - Optimized Forwarding Header OUI - Organizationally Unique Identifier P4RT - Programming Protocol-independent Packet Processors Runtime PAM4 - Pulse Amplitude Modulation 4-level @@ -182,6 +185,7 @@ TWAMP - Two-Way Active Measurement Protocol UART - Universal Asynchronous Receiver/Transmitter UDF - User-Defined Field UDP - User Datagram Protocol +UFH - Unified Forwarding Header USD - Ultimate Segment Decapsulation USP - Ultimate Segment Pop USXGMII - Universal Serial 10 Gigabit Media Independent Interface diff --git a/meta/checkheaders.pl b/meta/checkheaders.pl index 037e11818..7ee2026c1 100755 --- a/meta/checkheaders.pl +++ b/meta/checkheaders.pl @@ -199,6 +199,7 @@ sub CheckHash next if $key eq "SAI_PORT_BREAKOUT_MODE_TYPE_MAX"; next if $key eq "SAI_HOSTIF_USER_DEFINED_TRAP_TYPE_CUSTOM_RANGE_BASE"; next if $key eq "SAI_HOSTIF_USER_DEFINED_TRAP_TYPE_END"; + next if $key eq "SAI_OUT_DROP_REASON_END"; # NOTE: some other attributes/enum with END range could be added } diff --git a/meta/parse.pl b/meta/parse.pl index 3b23e0766..8e8d86469 100755 --- a/meta/parse.pl +++ b/meta/parse.pl @@ -2699,6 +2699,7 @@ sub ProcessStructValueType return "SAI_ATTR_VALUE_TYPE_MAC" if $type eq "sai_mac_t"; return "SAI_ATTR_VALUE_TYPE_IP_ADDRESS" if $type eq "sai_ip_address_t"; return "SAI_ATTR_VALUE_TYPE_IP_PREFIX" if $type eq "sai_ip_prefix_t"; + return "SAI_ATTR_VALUE_TYPE_OFH_ADDR_AND_MASK" if $type eq "sai_ofh_addr_and_mask_t"; return "SAI_ATTR_VALUE_TYPE_PRBS_RX_STATE" if $type eq "sai_prbs_rx_state_t"; return "SAI_ATTR_VALUE_TYPE_UINT16" if $type eq "sai_vlan_id_t"; return "SAI_ATTR_VALUE_TYPE_UINT32" if $type eq "sai_label_id_t"; @@ -4173,7 +4174,7 @@ sub ProcessSingleNonObjectId # allowed entries on object structs - if (not $type =~ /^sai_(nat_entry_data|mac|object_id|object_list|vlan_id|ip_address|ip_prefix|acl_chain|label_id|ip6|uint8|uint16|uint32|u32_range|\w+_type)_t$/) + if (not $type =~ /^sai_(nat_entry_data|mac|object_id|object_list|vlan_id|ip_address|ip_prefix|ofh_addr_and_mask|acl_chain|label_id|ip6|uint8|uint16|uint32|u32_range|\w+_type)_t$/) { LogError "struct member $member type '$type' is not allowed on struct $structname"; next; diff --git a/meta/saimetadatatypes.h b/meta/saimetadatatypes.h index e332ff216..96de79444 100644 --- a/meta/saimetadatatypes.h +++ b/meta/saimetadatatypes.h @@ -539,7 +539,12 @@ typedef enum _sai_attr_value_type_t /** * @brief Attribute value is 64 bit unsigned integer range list. */ - SAI_ATTR_VALUE_TYPE_UINT64_RANGE_LIST + SAI_ATTR_VALUE_TYPE_UINT64_RANGE_LIST, + + /** + * @brief Attribute value is OFH prefix + */ + SAI_ATTR_VALUE_TYPE_OFH_ADDR_AND_MASK, } sai_attr_value_type_t; /** diff --git a/meta/saisanitycheck.c b/meta/saisanitycheck.c index ae1d23b22..0634acce6 100644 --- a/meta/saisanitycheck.c +++ b/meta/saisanitycheck.c @@ -786,6 +786,7 @@ void check_attr_object_type_provided( case SAI_ATTR_VALUE_TYPE_POINTER: case SAI_ATTR_VALUE_TYPE_IP_ADDRESS: case SAI_ATTR_VALUE_TYPE_IP_PREFIX: + case SAI_ATTR_VALUE_TYPE_OFH_ADDR_AND_MASK: case SAI_ATTR_VALUE_TYPE_PRBS_RX_STATE: case SAI_ATTR_VALUE_TYPE_CHARDATA: case SAI_ATTR_VALUE_TYPE_UINT32_RANGE: @@ -1077,6 +1078,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_OFH_ADDR_AND_MASK: case SAI_ATTR_VALUE_TYPE_PRBS_RX_STATE: case SAI_ATTR_VALUE_TYPE_TIMESPEC: case SAI_ATTR_VALUE_TYPE_IPV4: @@ -3044,6 +3046,7 @@ void check_attr_is_primitive( case SAI_ATTR_VALUE_TYPE_INT8: case SAI_ATTR_VALUE_TYPE_IP_ADDRESS: case SAI_ATTR_VALUE_TYPE_IP_PREFIX: + case SAI_ATTR_VALUE_TYPE_OFH_ADDR_AND_MASK: case SAI_ATTR_VALUE_TYPE_PRBS_RX_STATE: case SAI_ATTR_VALUE_TYPE_MAC: case SAI_ATTR_VALUE_TYPE_OBJECT_ID: @@ -4030,6 +4033,7 @@ void check_non_object_id_object_types() case SAI_ATTR_VALUE_TYPE_UINT32_RANGE: case SAI_ATTR_VALUE_TYPE_IP_ADDRESS: case SAI_ATTR_VALUE_TYPE_IP_PREFIX: + case SAI_ATTR_VALUE_TYPE_OFH_ADDR_AND_MASK: case SAI_ATTR_VALUE_TYPE_OBJECT_ID: case SAI_ATTR_VALUE_TYPE_NAT_ENTRY_DATA: case SAI_ATTR_VALUE_TYPE_ENCRYPT_KEY: