stack.h (10143B)
1 /*! \file stack.h 2 * 3 * BCM STACK module APIs and Structures used only internally. 4 */ 5 /* 6 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 7 * 8 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 9 */ 10 11 #ifndef BCMI_LTSW_MBCM_STACK_H 12 #define BCMI_LTSW_MBCM_STACK_H 13 14 #include <sal/sal_types.h> 15 #include <bcm/types.h> 16 17 18 /*! 19 * \brief Set the module id of a unit. 20 * 21 * \param [in] unit Unit Number. 22 * \param [in] modid - module id. 23 * 24 * \retval SHR_E_NONE No errors. 25 * \retval !SHR_E_NONE Failure. 26 */ 27 typedef int (*stack_set_f)(int unit, 28 int my_modid); 29 30 /*! 31 * \brief Set the port in PORT_SYSTEM_DESTINATION entry for modid. 32 * 33 * \param [in] unit Unit Number. 34 * \param [in] modid - module id. 35 * \param [in] dest_port - destination port number. 36 * \param [in] port - port number. 37 * 38 * \retval SHR_E_NONE No errors. 39 * \retval !SHR_E_NONE Failure. 40 */ 41 typedef int (*stack_modport_set_f)(int unit, 42 int modid, 43 bcm_port_t dest_port, 44 bcm_port_t gport); 45 46 /*! 47 * \brief Get the port in PORT_SYSTEM_DESTINATION entry for modid. 48 * 49 * \param [in] unit Unit Number. 50 * \param [in] modid - module id. 51 * \param [in] dest_port - destination port number. 52 * \param [in] port - port number. 53 * 54 * \retval SHR_E_NONE No errors. 55 * \retval !SHR_E_NONE Failure. 56 */ 57 typedef int (*stack_modport_get_f)(int unit, 58 int modid, 59 bcm_port_t dest_port, 60 bcm_port_t *gport); 61 62 /*! 63 * \brief Cleat the port in PORT_SYSTEM_DESTINATION entry for modid. 64 * 65 * \param [in] unit Unit Number. 66 * \param [in] modid - module id. 67 * \param [in] dest_port - destination port number. 68 * 69 * \retval SHR_E_NONE No errors. 70 * \retval !SHR_E_NONE Failure. 71 */ 72 typedef int (*stack_modport_clear_f)(int unit, 73 int modid, 74 bcm_port_t dest_port); 75 76 /*! 77 * \brief Map the l2_if for the remote port. 78 * 79 * \param [in] unit Unit Number. 80 * \param [in] modid - module id. 81 * \param [in] dest_port - destination port number. 82 * 83 * \retval SHR_E_NONE No errors. 84 * \retval !SHR_E_NONE Failure. 85 */ 86 typedef int (*stack_l2_if_map_f)(int unit, 87 int modid, 88 bcm_port_t dest_port); 89 90 /*! 91 * \brief Cleat the l2_if attach to remote port. 92 * 93 * \param [in] unit Unit Number. 94 * \param [in] modid - module id. 95 * \param [in] dest_port - destination port number. 96 * 97 * \retval SHR_E_NONE No errors. 98 * \retval !SHR_E_NONE Failure. 99 */ 100 typedef int (*stack_l2_if_clear_f)(int unit, 101 int modid, 102 bcm_port_t dest_port); 103 104 /*! 105 * \brief Init the stack system. 106 * 107 * \param [in] unit Unit Number. 108 * 109 * \retval SHR_E_NONE No errors. 110 * \retval !SHR_E_NONE Failure. 111 */ 112 typedef int (*stack_init_f)(int unit); 113 114 /*! 115 * \brief Transform modport into system port. 116 * 117 * \param [in] unit Unit Number. 118 * \param [in] modid - module id. 119 * \param [in] port - port identifier. 120 * \param [out] sys_port - system port. 121 * 122 * \retval SHR_E_NONE No errors. 123 * \retval !SHR_E_NONE Failure. 124 */ 125 typedef int (*stack_sys_port_get_f)(int unit, 126 int modid, 127 bcm_port_t port, 128 int *sys_port); 129 130 /*! 131 * \brief Transform system port into modport. 132 * 133 * \param [in] unit Unit Number. 134 * \param [in] sys_port - system port. 135 * \param [out] modid - module id. 136 * \param [out] port - port identifier. 137 * 138 * \retval SHR_E_NONE No errors. 139 * \retval !SHR_E_NONE Failure. 140 */ 141 typedef int (*stack_sys_port_to_modport_get_f)(int unit, 142 int sys_port, 143 int *modid, 144 bcm_port_t *port); 145 /*! 146 * \brief Allocate available IFA 1.0 system_source. 147 * 148 * \param [in] unit Unit Number. 149 * \param [in] sys_source_ifa_probe_copy - system port. 150 * 151 * \retval SHR_E_NONE No errors. 152 * \retval !SHR_E_NONE Failure. 153 */ 154 typedef int (*stack_ifa_system_source_alloc_f)(int unit, 155 int *sys_source_ifa_probe_copy); 156 157 /*! 158 * \brief Destroy IFA 1.0 system_source. 159 * 160 * \param [in] unit Unit Number. 161 * 162 * \retval SHR_E_NONE No errors. 163 * \retval !SHR_E_NONE Failure. 164 */ 165 typedef int (*stack_ifa_system_source_destroy_f)(int unit); 166 167 /*! Stack driver structure. */ 168 typedef struct mbcm_ltsw_stack_drv_s { 169 170 /*! Set the module id of a unit. */ 171 stack_set_f stack_set; 172 /* Set the port in PORT_SYSTEM_DESTINATION entry for modid. */ 173 stack_modport_set_f stack_modport_set; 174 /* Get the port in PORT_SYSTEM_DESTINATION entry for modid. */ 175 stack_modport_get_f stack_modport_get; 176 /* Clear the port in PORT_SYSTEM_DESTINATION entry for modid. */ 177 stack_modport_clear_f stack_modport_clear; 178 /* Map the L2_IF for the remote port. */ 179 stack_l2_if_map_f stack_l2_if_map; 180 /* Clear the L2_IF attached to remote port. */ 181 stack_l2_if_clear_f stack_l2_if_clear; 182 /* Init the stack system. */ 183 stack_init_f stack_init; 184 /* Transform modport into system port. */ 185 stack_sys_port_get_f stack_sys_port_get; 186 /* Transform system port into modport. */ 187 stack_sys_port_to_modport_get_f stack_sys_port_to_modport_get; 188 /* Allocate available IFA 1.0 system_source. */ 189 stack_ifa_system_source_alloc_f stack_ifa_system_source_alloc; 190 /* Destroy IFA 1.0 system_source. */ 191 stack_ifa_system_source_destroy_f stack_ifa_system_source_destroy; 192 } mbcm_ltsw_stack_drv_t; 193 /*! 194 * \brief Set the stack driver of the device. 195 * 196 * \param [in] unit Unit Number. 197 * \param [in] drv Failover driver to set. 198 * 199 * \retval SHR_E_NONE No errors. 200 * \retval !SHR_E_NONE Failure. 201 */ 202 extern int 203 mbcm_ltsw_stack_drv_set(int unit, mbcm_ltsw_stack_drv_t *drv); 204 205 206 /*! 207 * \brief Set the module id of a unit. 208 * 209 * \param [in] unit Unit Number. 210 * \param [in] modid - module id. 211 * 212 * \retval SHR_E_NONE No errors. 213 * \retval !SHR_E_NONE Failure. 214 */ 215 extern int 216 mbcm_ltsw_stack_set(int unit, 217 int my_modid); 218 219 /*! 220 * \brief Set the port in PORT_SYSTEM_DESTINATION entry for modid. 221 * 222 * \param [in] unit Unit Number. 223 * \param [in] modid - module id. 224 * \param [in] port - port number. 225 * 226 * \retval SHR_E_NONE No errors. 227 * \retval !SHR_E_NONE Failure. 228 */ 229 extern int 230 mbcm_ltsw_stack_modport_set(int unit, 231 int my_modid, 232 bcm_port_t dest_port, 233 bcm_port_t gport); 234 235 236 /*! 237 * \brief Get the port in PORT_SYSTEM_DESTINATION entry for modid. 238 * 239 * \param [in] unit Unit Number. 240 * \param [in] modid - module id. 241 * \param [in] port - port number. 242 * 243 * \retval SHR_E_NONE No errors. 244 * \retval !SHR_E_NONE Failure. 245 */ 246 extern int 247 mbcm_ltsw_stack_modport_get(int unit, 248 int my_modid, 249 bcm_port_t dest_port, 250 bcm_port_t *gport); 251 252 253 /*! 254 * \brief Cleat the port in PORT_SYSTEM_DESTINATION entry for modid. 255 * 256 * \param [in] unit Unit Number. 257 * \param [in] modid - module id. 258 * 259 * \retval SHR_E_NONE No errors. 260 * \retval !SHR_E_NONE Failure. 261 */ 262 extern int 263 mbcm_ltsw_stack_modport_clear(int unit, 264 int my_modid, 265 bcm_port_t dest_port); 266 267 /*! 268 * \brief Map the l2_if for the remote port. 269 * 270 * \param [in] unit Unit Number. 271 * \param [in] modid - module id. 272 * \param [in] dest_port - destination port number. 273 * 274 * \retval SHR_E_NONE No errors. 275 * \retval !SHR_E_NONE Failure. 276 */ 277 extern int 278 mbcm_ltsw_stack_l2_if_map(int unit, 279 int my_modid, 280 bcm_port_t dest_port); 281 282 /*! 283 * \brief Cleat the l2_if attach to remote port. 284 * 285 * \param [in] unit Unit Number. 286 * \param [in] modid - module id. 287 * \param [in] dest_port - destination port number. 288 * 289 * \retval SHR_E_NONE No errors. 290 * \retval !SHR_E_NONE Failure. 291 */ 292 extern int 293 mbcm_ltsw_stack_l2_if_clear(int unit, 294 int my_modid, 295 bcm_port_t dest_port); 296 297 /*! 298 * \brief Init the stack system. 299 * 300 * \param [in] unit Unit Number. 301 * 302 * \retval SHR_E_NONE No errors. 303 * \retval !SHR_E_NONE Failure. 304 */ 305 extern int 306 mbcm_ltsw_stack_init(int unit); 307 308 /*! 309 * \brief Transform modport into system port. 310 * 311 * \param [in] unit Unit Number. 312 * \param [in] modid - module id. 313 * \param [in] port - port identifier. 314 * \param [out] sys_port - system port. 315 * 316 * \retval SHR_E_NONE No errors. 317 * \retval !SHR_E_NONE Failure. 318 */ 319 extern int 320 mbcm_ltsw_stack_sys_port_get(int unit, 321 int modid, 322 bcm_port_t port, 323 int *sys_port); 324 325 /*! 326 * \brief Transform system port into modport. 327 * 328 * \param [in] unit Unit Number. 329 * \param [in] sys_port - system port. 330 * \param [out] modid - module id. 331 * \param [out] port - port identifier. 332 * 333 * \retval SHR_E_NONE No errors. 334 * \retval !SHR_E_NONE Failure. 335 */ 336 extern int 337 mbcm_ltsw_stack_sys_port_to_modport_get(int unit, 338 int sys_port, 339 int *modid, 340 bcm_port_t *port); 341 342 /*! 343 * \brief Allocate IFA 1.0 system_source. 344 * 345 * \param [in] unit Unit Number. 346 * \param [in] sys_source_ifa_probe_copy - system port. 347 * 348 * \retval SHR_E_NONE No errors. 349 * \retval !SHR_E_NONE Failure. 350 */ 351 extern int 352 mbcm_ltsw_stack_ifa_system_source_alloc(int unit, 353 int *sys_source_ifa_probe_copy); 354 355 /*! 356 * \brief Destroy IFA 1.0 system_source. 357 * 358 * \param [in] unit Unit Number. 359 * 360 * \retval SHR_E_NONE No errors. 361 * \retval !SHR_E_NONE Failure. 362 */ 363 extern int 364 mbcm_ltsw_stack_ifa_system_source_destroy(int unit); 365 #endif /* BCMI_LTSW_MBCM_STACK_H */