|
| 1 | +/** |
| 2 | + * Copyright (c) 2014 Microsoft Open Technologies, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | + * not use this file except in compliance with the License. You may obtain |
| 6 | + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | + * |
| 8 | + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR |
| 9 | + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
| 10 | + * LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS |
| 11 | + * FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. |
| 12 | + * |
| 13 | + * See the Apache Version 2.0 License for specific language governing |
| 14 | + * permissions and limitations under the License. |
| 15 | + * |
| 16 | + * Microsoft would like to thank the following companies for their review and |
| 17 | + * assistance with these files: Intel Corporation, Mellanox Technologies Ltd, |
| 18 | + * Dell Products, L.P., Facebook, Inc., Marvell International Ltd. |
| 19 | + * |
| 20 | + * @file saiexperimentalotnattenuator.h |
| 21 | + * |
| 22 | + * @brief This module defines SAI extensions for optical attenuator. |
| 23 | + * It is derived from openconfig-optical-attenuator.yang, revision 2024-07-10. |
| 24 | + * |
| 25 | + * @warning This module is a SAI experimental module |
| 26 | + */ |
| 27 | + |
| 28 | +#if !defined (__SAIEXPERIMENTALOTNATTENUATOR_H_) |
| 29 | +#define __SAIEXPERIMENTALOTNATTENUATOR_H_ |
| 30 | + |
| 31 | +#include <saitypes.h> |
| 32 | + |
| 33 | +/** |
| 34 | + * @defgroup SAIEXPERIMENTALOTNATTENUATOR SAI - Experimental: Attenuator specific API definitions |
| 35 | + * |
| 36 | + * @{ |
| 37 | + */ |
| 38 | + |
| 39 | +/** |
| 40 | + * @brief Type definition for different types of optical attenuator operating modes |
| 41 | + */ |
| 42 | +typedef enum _sai_otn_attenuator_mode_t |
| 43 | +{ |
| 44 | + SAI_OTN_ATTENUATOR_MODE_CONSTANT_POWER, |
| 45 | + SAI_OTN_ATTENUATOR_MODE_CONSTANT_ATTENUATION, |
| 46 | + SAI_OTN_ATTENUATOR_MODE_SYSTEM_CONTROLLED, |
| 47 | +} sai_otn_attenuator_mode_t; |
| 48 | + |
| 49 | +/** |
| 50 | + * @brief Attenuator attribute IDs |
| 51 | + */ |
| 52 | +typedef enum _sai_otn_attenuator_attr_t |
| 53 | +{ |
| 54 | + /** |
| 55 | + * @brief Start of attributes. |
| 56 | + */ |
| 57 | + SAI_OTN_ATTENUATOR_ATTR_START, |
| 58 | + |
| 59 | + /** |
| 60 | + * @brief User-defined name assigned to identify a specific attenuator in the device. |
| 61 | + * |
| 62 | + * @type char |
| 63 | + * @flags MANDATORY_ON_CREATE | CREATE_ONLY |
| 64 | + */ |
| 65 | + SAI_OTN_ATTENUATOR_ATTR_NAME = SAI_OTN_ATTENUATOR_ATTR_START, |
| 66 | + |
| 67 | + /** |
| 68 | + * @brief The operating mode of the attenuator. |
| 69 | + * |
| 70 | + * @type sai_otn_attenuator_mode_t |
| 71 | + * @flags CREATE_AND_SET |
| 72 | + * @default SAI_OTN_ATTENUATOR_MODE_CONSTANT_ATTENUATION |
| 73 | + */ |
| 74 | + SAI_OTN_ATTENUATOR_ATTR_ATTENUATION_MODE, |
| 75 | + |
| 76 | + /** |
| 77 | + * @brief Power level set on the output of attenuator in units of 0.01dBm. |
| 78 | + * This leaf is only relevant when in CONSTANT_POWER mode. |
| 79 | + * |
| 80 | + * @type sai_int32_t |
| 81 | + * @flags CREATE_AND_SET |
| 82 | + * @default 0 |
| 83 | + * @precision 2 |
| 84 | + */ |
| 85 | + SAI_OTN_ATTENUATOR_ATTR_TARGET_OUTPUT_POWER, |
| 86 | + |
| 87 | + /** |
| 88 | + * @brief Attenuation applied by the attenuator in units of 0.01dB. |
| 89 | + * This leaf is only relevant when in CONSTANT_ATTENUATION mode. |
| 90 | + * |
| 91 | + * @type sai_uint32_t |
| 92 | + * @flags CREATE_AND_SET |
| 93 | + * @default 500 |
| 94 | + * @precision 2 |
| 95 | + */ |
| 96 | + SAI_OTN_ATTENUATOR_ATTR_ATTENUATION, |
| 97 | + |
| 98 | + /** |
| 99 | + * @brief When true, attenuator is set to specified attenuation or varies to |
| 100 | + * maintain constant output power. When false, the attenuator is set |
| 101 | + * max attenuation or blocked. |
| 102 | + * |
| 103 | + * @type bool |
| 104 | + * @flags CREATE_AND_SET |
| 105 | + * @default true |
| 106 | + */ |
| 107 | + SAI_OTN_ATTENUATOR_ATTR_ENABLED, |
| 108 | + |
| 109 | + /** |
| 110 | + * @brief The max power level allowed on the output of attenuator in units of 0.01dBm. |
| 111 | + * This leaf is optional when in SYSTEM_CONTROLLED mode. |
| 112 | + * |
| 113 | + * @type sai_int32_t |
| 114 | + * @flags CREATE_AND_SET |
| 115 | + * @default 0 |
| 116 | + * @precision 2 |
| 117 | + */ |
| 118 | + SAI_OTN_ATTENUATOR_ATTR_MAX_OUTPUT_POWER, |
| 119 | + |
| 120 | + /** |
| 121 | + * @brief A device alarm will be raised within /system/alarms when |
| 122 | + * system-derived-target-output-power >= max-output-power + max-output-power-threshold. |
| 123 | + * This leaf is only relevant when in SYSTEM_CONTROLLED mode. |
| 124 | + * |
| 125 | + * @type sai_int32_t |
| 126 | + * @flags CREATE_AND_SET |
| 127 | + * @default 300 |
| 128 | + * @precision 2 |
| 129 | + */ |
| 130 | + SAI_OTN_ATTENUATOR_ATTR_MAX_OUTPUT_POWER_THRESHOLD, |
| 131 | + |
| 132 | + /** |
| 133 | + * @brief Reference to system-supplied name of the attenuator ingress port. |
| 134 | + * This leaf is only valid for ports of type INGRESS. |
| 135 | + * |
| 136 | + * @type char |
| 137 | + * @flags READ_ONLY |
| 138 | + */ |
| 139 | + SAI_OTN_ATTENUATOR_ATTR_INGRESS_PORT, |
| 140 | + |
| 141 | + /** |
| 142 | + * @brief Reference to system-supplied name of the attenuator egress port. |
| 143 | + * This leaf is only valid for ports of type EGRESS. |
| 144 | + * |
| 145 | + * @type char |
| 146 | + * @flags READ_ONLY |
| 147 | + */ |
| 148 | + SAI_OTN_ATTENUATOR_ATTR_EGRESS_PORT, |
| 149 | + |
| 150 | + /** |
| 151 | + * @brief The target output power as determined by the device in units of 0.01dBm. |
| 152 | + * This leaf is only relevant when in SYSTEM_CONTROLLED mode. |
| 153 | + * |
| 154 | + * @type sai_int32_t |
| 155 | + * @flags READ_ONLY |
| 156 | + * @precision 2 |
| 157 | + */ |
| 158 | + SAI_OTN_ATTENUATOR_ATTR_SYSTEM_DERIVED_TARGET_OUTPUT_POWER, |
| 159 | + |
| 160 | + /** |
| 161 | + * @brief The actual attenuation applied by the attenuator in units of 0.01dB. |
| 162 | + * |
| 163 | + * @type sai_int32_t |
| 164 | + * @flags READ_ONLY |
| 165 | + * @precision 2 |
| 166 | + */ |
| 167 | + SAI_OTN_ATTENUATOR_ATTR_ACTUAL_ATTENUATION, |
| 168 | + |
| 169 | + /** |
| 170 | + * @brief The total output optical power of this port in units of 0.01dBm. |
| 171 | + * |
| 172 | + * @type sai_int32_t |
| 173 | + * @flags READ_ONLY |
| 174 | + * @precision 2 |
| 175 | + */ |
| 176 | + SAI_OTN_ATTENUATOR_ATTR_OUTPUT_POWER_TOTAL, |
| 177 | + |
| 178 | + /** |
| 179 | + * @brief The optical return loss (ORL) is the ratio of the light |
| 180 | + * reflected back into the port to the light launched out of the port. |
| 181 | + * ORL is in units of 0.01dB. |
| 182 | + * |
| 183 | + * @type sai_int32_t |
| 184 | + * @flags READ_ONLY |
| 185 | + * @precision 2 |
| 186 | + */ |
| 187 | + SAI_OTN_ATTENUATOR_ATTR_OPTICAL_RETURN_LOSS, |
| 188 | + |
| 189 | + /** |
| 190 | + * @brief End of attributes |
| 191 | + */ |
| 192 | + SAI_OTN_ATTENUATOR_ATTR_END, |
| 193 | + |
| 194 | + /** Custom range base value */ |
| 195 | + SAI_OTN_ATTENUATOR_ATTR_CUSTOM_RANGE_START = 0x10000000, |
| 196 | + |
| 197 | + /** End of custom range base */ |
| 198 | + SAI_OTN_ATTENUATOR_ATTR_CUSTOM_RANGE_END |
| 199 | + |
| 200 | +} sai_otn_attenuator_attr_t; |
| 201 | + |
| 202 | +/** |
| 203 | + * @brief Create attenuator. |
| 204 | + * |
| 205 | + * Allocates and initializes an attenuator. |
| 206 | + * |
| 207 | + * @param[out] otn_attenuator_id Attenuator id |
| 208 | + * @param[in] switch_id Switch id on which the attenuator exists |
| 209 | + * @param[in] attr_count Number of attributes |
| 210 | + * @param[in] attr_list Array of attributes |
| 211 | + * |
| 212 | + * @return #SAI_STATUS_SUCCESS on success, failure status code on error |
| 213 | + */ |
| 214 | +typedef sai_status_t (*sai_create_otn_attenuator_fn)( |
| 215 | + _Out_ sai_object_id_t *otn_attenuator_id, |
| 216 | + _In_ sai_object_id_t switch_id, |
| 217 | + _In_ uint32_t attr_count, |
| 218 | + _In_ const sai_attribute_t *attr_list); |
| 219 | + |
| 220 | +/** |
| 221 | + * @brief Remove attenuator |
| 222 | + * |
| 223 | + * @param[in] otn_attenuator_id Attenuator id |
| 224 | + * |
| 225 | + * @return #SAI_STATUS_SUCCESS on success, failure status code on error |
| 226 | + */ |
| 227 | +typedef sai_status_t (*sai_remove_otn_attenuator_fn)( |
| 228 | + _In_ sai_object_id_t otn_attenuator_id); |
| 229 | + |
| 230 | +/** |
| 231 | + * @brief Set attenuator attribute |
| 232 | + * |
| 233 | + * @param[in] otn_attenuator_id Attenuator id |
| 234 | + * @param[in] attr Attribute |
| 235 | + * |
| 236 | + * @return #SAI_STATUS_SUCCESS on success, failure status code on error |
| 237 | + */ |
| 238 | +typedef sai_status_t (*sai_set_otn_attenuator_attribute_fn)( |
| 239 | + _In_ sai_object_id_t otn_attenuator_id, |
| 240 | + _In_ const sai_attribute_t *attr); |
| 241 | + |
| 242 | +/** |
| 243 | + * @brief Get attenuator attribute |
| 244 | + * |
| 245 | + * @param[in] otn_attenuator_id Attenuator id |
| 246 | + * @param[in] attr_count Number of attributes |
| 247 | + * @param[inout] attr_list Array of attributes |
| 248 | + * |
| 249 | + * @return #SAI_STATUS_SUCCESS on success, failure status code on error |
| 250 | + */ |
| 251 | +typedef sai_status_t (*sai_get_otn_attenuator_attribute_fn)( |
| 252 | + _In_ sai_object_id_t otn_attenuator_id, |
| 253 | + _In_ uint32_t attr_count, |
| 254 | + _Inout_ sai_attribute_t *attr_list); |
| 255 | + |
| 256 | +/** |
| 257 | + * @brief Routing interface methods table retrieved with sai_api_query() |
| 258 | + */ |
| 259 | +typedef struct _sai_otn_attenuator_api_t |
| 260 | +{ |
| 261 | + sai_create_otn_attenuator_fn create_otn_attenuator; |
| 262 | + sai_remove_otn_attenuator_fn remove_otn_attenuator; |
| 263 | + sai_set_otn_attenuator_attribute_fn set_otn_attenuator_attribute; |
| 264 | + sai_get_otn_attenuator_attribute_fn get_otn_attenuator_attribute; |
| 265 | +} sai_otn_attenuator_api_t; |
| 266 | + |
| 267 | +/** |
| 268 | + * @} |
| 269 | + */ |
| 270 | +#endif /** __SAIEXPERIMENTALOTNATTENUATOR_H_ */ |
0 commit comments