From f00648c655997297e5db9bb164843d924477025c Mon Sep 17 00:00:00 2001 From: Mukesh MV Date: Wed, 21 Feb 2024 12:56:53 -0800 Subject: [PATCH] DASH HA --- experimental/saiexperimentaldashdevice.h | 195 ++++++++++++++++++ experimental/saiexperimentaldasheni.h | 21 ++ experimental/saiexperimentaldashha.h | 248 +++++++++++++++++++++++ experimental/saiextensions.h | 2 + experimental/saitypesextensions.h | 2 + inc/saitypes.h | 62 ++++++ meta/aspell.en.pws | 5 + meta/saimetadatatypes.h | 10 + meta/style.pm | 3 +- 9 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 experimental/saiexperimentaldashdevice.h create mode 100644 experimental/saiexperimentaldashha.h diff --git a/experimental/saiexperimentaldashdevice.h b/experimental/saiexperimentaldashdevice.h new file mode 100644 index 0000000000..d19a65a4ee --- /dev/null +++ b/experimental/saiexperimentaldashdevice.h @@ -0,0 +1,195 @@ +/** + * Copyright (c) 2024 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 saiexperimentaldashdevice.h + * + * @brief This module defines SAI P4 extension interface + */ + +#if !defined (__SAIEXPERIMENTALDASHDEVICE_H_) +#define __SAIEXPERIMENTALDASHDEVICE_H_ + +#include + +/** + * @defgroup SAIEXPERIMENTALDASH_DEVICE SAI - Extension specific API definitions + * + * @{ + */ + +/** + * @brief Attribute ID for DASH device + */ +typedef enum _sai_dash_device_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_DASH_DEVICE_ATTR_START, + + /** + * @brief Any non-VNET VNI or GRE keys that need to be allowed + * + * @par PrivateLink GRE key is an example + * + * @type sai_vni_range_list_t + * @flags CREATE_ONLY + * @default empty + */ + SAI_DASH_DEVICE_ATTR_TRUSTED_VNI_LIST = SAI_DASH_DEVICE_ATTR_START, + + /** + * @brief HA Local IP for control traffic + * + * @type sai_ip_address_t + * @flags CREATE_AND_SET + * @default empty + */ + SAI_DASH_DEVICE_ATTR_HA_CONTROL_LOCAL_IP, + + /** + * @brief HA Peer IP for control traffic + * + * @type sai_ip_address_t + * @flags CREATE_AND_SET + * @default empty + */ + SAI_DASH_DEVICE_ATTR_HA_CONTROL_PEER_IP, + + /** + * @brief List of HA VIPs + * + * @type sai_dash_vip_info_list_t + * @flags CREATE_AND_SET + * @default empty + */ + SAI_DASH_DEVICE_ATTR_HA_VIP_INFO_LIST, + + /** + * @brief HA heartbeat interval time in ms + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_DASH_DEVICE_ATTR_HA_HEARTBEAT_INTERVAL, + + /** + * @brief Number of HA heartbeats missed before declaring Peer unreachable + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_DASH_DEVICE_ATTR_HA_HEARTBEAT_COUNT, + + /** + * @brief Time in ms required for network to converge after switchover + * + * @par Any traffic directed to wrong DPU after this time will be blackholed + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default 100 + */ + SAI_DASH_DEVICE_ATTR_VIP_CONVERGENCE_TIMEOUT, + +#if 0 + + /** + * @brief Allow automatic flow reconcile on transition to Standalone + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_DASH_DEVICE_ATTR_HA_AUTO_FLOW_RECONCILE_ENABLE, +#endif + + /** + * @brief End of attributes + */ + SAI_DASH_DEVICE_ATTR_END, +} sai_dash_device_attr_t; + +/** + * @brief Create and return a DASH device object + * + * @param[out] dash_device_id Device id + * @param[in] switch_id Switch 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_dash_device_fn)( + _Out_ sai_object_id_t *dash_device_id, + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Remove DASH device object + * + * @param[in] dash_device_id Device id + * + * @return #SAI_STATUS_SUCCESS on success Failure status code on error + */ +typedef sai_status_t (*sai_remove_dash_device_fn)( + _In_ sai_object_id_t dash_device_id); + +/** + * @brief Set DASH device attribute + * + * @param[in] dash_device_id Entry id + * @param[in] attr Attribute + * + * @return #SAI_STATUS_SUCCESS on success Failure status code on error + */ +typedef sai_status_t (*sai_set_dash_device_attribute_fn)( + _In_ sai_object_id_t dash_device_id, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get DASH device attribute + * + * @param[in] dash_device_id Entry 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_dash_device_attribute_fn)( + _In_ sai_object_id_t dash_device_id, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +typedef struct _sai_dash_device_api_t +{ + sai_create_dash_device_fn create_dash_device; + sai_remove_dash_device_fn remove_dash_device; + sai_set_dash_device_attribute_fn set_dash_device_attribute; + sai_get_dash_device_attribute_fn get_dash_device_attribute; + +} sai_dash_device_api_t; + +/** + * @} + */ +#endif /** __SAIEXPERIMENTALDASHDEVICE_H_ */ diff --git a/experimental/saiexperimentaldasheni.h b/experimental/saiexperimentaldasheni.h index a215559162..798a144883 100644 --- a/experimental/saiexperimentaldasheni.h +++ b/experimental/saiexperimentaldasheni.h @@ -430,6 +430,27 @@ typedef enum _sai_eni_attr_t */ SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID, + /** + * @brief Owner of ENI, when DPU participates in HA + * + * @par Irrespective of the DPU in the HA pair where traffic actually lands, + * only the DASH ACL rules configured on the owner DPU will be evaluated + * for all flows belonging to this ENI. + * + * @type bool + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + */ + SAI_ENI_ATTR_HA_OWNER, + + /** + * @brief VIP associated with this ENI, when DPU participates in HA + * + * @type sai_uint32_t + * @flags CREATE_ONLY + * @default 0 + */ + SAI_ENI_ATTR_HA_VIP_ID, + /** * @brief End of attributes */ diff --git a/experimental/saiexperimentaldashha.h b/experimental/saiexperimentaldashha.h new file mode 100644 index 0000000000..33258a3368 --- /dev/null +++ b/experimental/saiexperimentaldashha.h @@ -0,0 +1,248 @@ +/** + * Copyright (c) 2024 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 saiexperimentaldashha.h + * + * @brief This module defines SAI P4 extension interface + */ + +#if !defined (__SAIEXPERIMENTALDASHHA_H_) +#define __SAIEXPERIMENTALDASHHA_H_ + +#include + +/** + * @defgroup SAIEXPERIMENTALDASH_HA SAI - Extension specific API definitions + * + * @{ + */ + +/** + * @brief Key for DASH HA APIs + */ +typedef struct _sai_dash_ha_entry_t +{ + /** + * @brief Switch ID + * + * @objects SAI_OBJECT_TYPE_SWITCH + */ + sai_object_id_t switch_id; + + /** + * @brief Optionally specify the VIP ID to which this API applies + * + * @par If VIP ID is not specified then this applies to all VIP IDs + * on the DPU + */ + uint32_t vip_id; +} sai_dash_ha_entry_t; + +/** + * @brief Attribute ID for DASH HA start + */ +typedef enum _sai_dash_ha_start_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_DASH_HA_START_ATTR_START, + + /** + * @brief Force HA start + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_DASH_HA_START_ATTR_FORCE = SAI_DASH_HA_START_ATTR_START, + + /** + * @brief End of attributes + */ + SAI_DASH_HA_START_ATTR_END, +} sai_dash_ha_start_attr_t; + +/** + * @brief Attribute ID for DASH HA stop + */ +typedef enum _sai_dash_ha_stop_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_DASH_HA_STOP_ATTR_START, + + /** + * @brief Force HA stop + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_DASH_HA_STOP_ATTR_FORCE_STOP = SAI_DASH_HA_STOP_ATTR_START, + + /** + * @brief End of attributes + */ + SAI_DASH_HA_STOP_ATTR_END, +} sai_dash_ha_stop_attr_t; + +/** + * @brief Attribute ID for DASH HA switchover start + */ +typedef enum _sai_dash_ha_switchover_start_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_DASH_HA_SWITCHOVER_START_ATTR_START, + + /** + * @brief Force HA switchover + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_DASH_HA_SWITCHOVER_START_ATTR_FORCE_SWITCHOVER = SAI_DASH_HA_SWITCHOVER_START_ATTR_START, + + /** + * @brief End of attributes + */ + SAI_DASH_HA_SWITCHOVER_START_ATTR_END, +} sai_dash_ha_switchover_start_attr_t; + +/** + * @brief Attribute ID for DASH HA flow reconcile + */ +typedef enum _sai_dash_ha_flow_reconcile_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_DASH_HA_FLOW_RECONCILE_ATTR_START, + + /** + * @brief Ignore optimizations and cause every flow to be re-evaluated + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_DASH_HA_FLOW_RECONCILE_ATTR_FORCE_RECONCILE = SAI_DASH_HA_FLOW_RECONCILE_ATTR_START, + + /** + * @brief End of attributes + */ + SAI_DASH_HA_FLOW_RECONCILE_ATTR_END, +} sai_dash_ha_flow_reconcile_attr_t; + +/** + * @brief Kick-start the HA finite state machine after HA configuration + * has been pushed + * + * @param[in] ha_entry 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 + * #SAI_STATUS_OBJECT_IN_USE will be returned if this operation could + * cause traffic disruption. Retry with Force attribute set to go + * ahead with start. + */ +typedef sai_status_t (*sai_dash_ha_start_fn)( + _In_ const sai_dash_ha_entry_t *ha_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Shutdown the HA finite state machine to take out a DPU from HA pairing + * + * @param[in] ha_entry 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 + * #SAI_STATUS_OBJECT_IN_USE will be returned if its not in a safe state + * for shutdown. Retry with Force attribute set to go ahead with stop. + */ +typedef sai_status_t (*sai_dash_ha_stop_fn)( + _In_ const sai_dash_ha_entry_t *ha_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Activate the HA admin role + * + * @param[in] ha_entry 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_dash_ha_admin_role_activate_fn)( + _In_ const sai_dash_ha_entry_t *ha_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Initiate controlled switchover to the HA peer + * + * @param[in] ha_entry 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 + * #SAI_STATUS_OBJECT_IN_USE will be returned if this operation could + * cause traffic disruption. Retry with Force attribute set to go + * ahead with switchover. + */ +typedef sai_status_t (*sai_dash_ha_switchover_start_fn)( + _In_ const sai_dash_ha_entry_t *ha_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Reconcile synced flows with current local configuration + * + * @param[in] ha_entry 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_dash_ha_flow_reconcile_fn)( + _In_ const sai_dash_ha_entry_t *ha_entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +typedef struct _sai_dash_ha_api_t +{ + sai_dash_ha_start_fn dash_ha_start; + sai_dash_ha_stop_fn dash_ha_stop; + sai_dash_ha_admin_role_activate_fn dash_ha_admin_role_activate; + sai_dash_ha_switchover_start_fn dash_ha_switchover_start; + sai_dash_ha_flow_reconcile_fn dash_ha_flow_reconcile; +} + +/** + * @} + */ +#endif /** __SAIEXPERIMENTALDASHHA_H_ */ diff --git a/experimental/saiextensions.h b/experimental/saiextensions.h index 7664ea26e7..9e931c83ad 100644 --- a/experimental/saiextensions.h +++ b/experimental/saiextensions.h @@ -77,6 +77,8 @@ typedef enum _sai_api_extensions_t SAI_API_DASH_VIP, + SAI_API_DASH_DEVICE, + /* Add new experimental APIs above this line */ SAI_API_EXTENSIONS_RANGE_END diff --git a/experimental/saitypesextensions.h b/experimental/saitypesextensions.h index 03a943b1dd..689687b6fd 100644 --- a/experimental/saitypesextensions.h +++ b/experimental/saitypesextensions.h @@ -70,6 +70,8 @@ typedef enum _sai_object_type_extensions_t SAI_OBJECT_TYPE_VIP_ENTRY, + SAI_OBJECT_TYPE_DASH_DEVICE, + /* Add new experimental object types above this line */ SAI_OBJECT_TYPE_EXTENSIONS_RANGE_END diff --git a/inc/saitypes.h b/inc/saitypes.h index dd5d25abcd..1ac48564a0 100644 --- a/inc/saitypes.h +++ b/inc/saitypes.h @@ -1528,6 +1528,12 @@ typedef union _sai_attribute_value_t /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PORT_SNR_LIST */ sai_port_snr_list_t portsnrlist; + + /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_VNI_RANGE_LIST */ + sai_vni_range_list_t vnirangelist; + + /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_DASH_VIP_INFO_LIST */ + sai_dash_vip_info_list_t dashvipinfolist; } sai_attribute_value_t; /** @@ -1732,6 +1738,62 @@ typedef struct _sai_switch_health_data_t } sai_switch_health_data_t; +typedef struct _sai_vni_range_t +{ + uint32_t min; + uint32_t max; + +} sai_vni_range_t; + +typedef struct _sai_vni_range_list_t +{ + uint32_t count; + sai_vni_range_t *list; + +} sai_vni_range_list_t; + +#if 0 // check if needed + +/** + * @brief Attribute data for HA_ROLE parameter + */ +typedef enum _sai_dash_ha_role_t +{ + SAI_DASH_HA_ROLE_NONE, + SAI_DASH_HA_ROLE_ACTIVE, + SAI_DASH_HA_ROLE_STANDBY, +} sai_dash_ha_role_t; +#endif + +/** + * @brief DASH VIP pair identified by a VIP ID + */ +typedef struct _sai_dash_vip_info_t +{ + /** VIP ID */ + uint32_t vip_id; + + /** + * @brief VIP IPv4 and IPv6 address pair + */ + sai_ip4_t vip_ipv4; + sai_ip6_t vip_ipv6; + + /** + * @brief HA role for this VIP pair + */ +#if 0 + sai_dash_ha_role_t ha_role; +#endif +} sai_dash_vip_info_t; + +typedef struct _sai_dash_vip_info_list_t +{ + uint32_t count; + sai_dash_vip_info_t *list; + +} sai_dash_vip_info_list_t; + /** * @} */ diff --git a/meta/aspell.en.pws b/meta/aspell.en.pws index 92517d781d..4d982d00cc 100644 --- a/meta/aspell.en.pws +++ b/meta/aspell.en.pws @@ -213,3 +213,8 @@ Wildcard www xconnect TWAMP +DPU +ENI +PrivateLink +VNET +blackholed diff --git a/meta/saimetadatatypes.h b/meta/saimetadatatypes.h index b6b81f4236..e78833ae38 100644 --- a/meta/saimetadatatypes.h +++ b/meta/saimetadatatypes.h @@ -490,6 +490,16 @@ typedef enum _sai_attr_value_type_t * @brief Attribute value is statistics data. */ SAI_ATTR_VALUE_TYPE_TWAMP_STATS_DATA, + + /** + * @brief Attribute value is VNI range list. + */ + SAI_ATTR_VALUE_TYPE_VNI_RANGE_LIST, + + /** + * @brief Attribute value is DASH VIP info list + */ + SAI_ATTR_VALUE_TYPE_DASH_VIP_INFO_LIST, } sai_attr_value_type_t; /** diff --git a/meta/style.pm b/meta/style.pm index 6cdaf542c7..693e28418b 100644 --- a/meta/style.pm +++ b/meta/style.pm @@ -453,7 +453,8 @@ sub CheckFunctionNaming switch_mdio_cl22_read switch_mdio_cl22_write switch_register_read - switch_register_write); + switch_register_write + dash_ha_\(\\w+\)); my $REG = "(" . (join"|",@listex) . ")";