lb.h (13645B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_LB_H__ 11 #define __BCM_LB_H__ 12 13 #include <bcm/types.h> 14 15 /* Link bonding module flags. */ 16 #define BCM_LB_FLAG_GLOBAL (1 << 0) /* Global configuration. */ 17 #define BCM_LB_FLAG_UNMAP (1 << 1) /* Unmap operation. */ 18 #define BCM_LB_FLAG_FLUSH_GLOBAL (1 << 2) /* flush for all lbg. */ 19 #define BCM_LB_FLAG_MODEM_SHAPER_SEGMENT (1 << 3) /* set modem segment 20 shaper. */ 21 22 /* LBG ID type */ 23 typedef uint32 bcm_lbg_t; 24 25 /* MODEM ID type */ 26 typedef uint32 bcm_modem_t; 27 28 /* Link bonding direction type eumerations */ 29 typedef enum bcm_lb_direction_type_e { 30 bcmLbDirectionRx = 0, /* Link bonding in receive side */ 31 bcmLbDirectionTx = 1, /* Link bonding in transmit side */ 32 bcmLbDirectionBoth = 2, /* Link bonding in both receive and transmit side */ 33 bcmLbDirectionCount = 3 /* Always Last. Not a usable value. */ 34 } bcm_lb_direction_type_t; 35 36 /* Link bonding control type */ 37 typedef enum bcm_lb_control_e { 38 bcmLbControlSegmentationMode = 0, /* Global configuration in TX side */ 39 bcmLbControlPacketCrcEnable = 1, /* Global configuration in TX side */ 40 bcmLbControlTimeoutThreshold = 2, /* Per LBG configuration in RX side */ 41 bcmLbControlMaxOutOfOrder = 3, /* Per LBG configuration in RX side */ 42 bcmLbControlMaxBuffer = 4, /* Per LBG configuration in RX side */ 43 bcmLbControlExpectedSequenceNumber = 5, /* Per LBG configuration in RX side */ 44 bcmLbControlNofTotalSharedBuffers = 6, /* Total shared buffers */ 45 bcmLbControlNofGuaranteedBuffers = 7, /* Guaranteed buffers the link bonding 46 group can acquire */ 47 bcmLbControlCount = 8 /* Always Last. Not a usable value. */ 48 } bcm_lb_control_t; 49 50 /* Link bonding modem control type */ 51 typedef enum bcm_lb_modem_control_e { 52 bcmLbModemControlHeaderCompensation = 0, /* Modem configuration in TX side */ 53 bcmLbModemControlCount = 1 /* Always Last. Not a usable value. */ 54 } bcm_lb_modem_control_t; 55 56 /* Link bonding format type */ 57 typedef enum bcm_lb_format_type_e { 58 bcmLbFormatTypeBypass = 0, /* LB bypss */ 59 bcmLbFormatTypeNonChannelize = 1, /* LB non channelize */ 60 bcmLbFormatTypechannelize = 2, /* LB channelize */ 61 bcmLbFormatCount = 3 /* Always Last. Not a usable value. */ 62 } bcm_lb_format_type_t; 63 64 /* Link bonding status */ 65 typedef enum bcm_lb_status_type_e { 66 bcmLbStatusIsInSync = 0, /* Is expected sequence number in sync state */ 67 bcmLbStatusIsEmptyFifo = 1, /* LBG FIFOs empty indication */ 68 bcmLbStatusCount = 2 /* Always Last. Not a usable value. */ 69 } bcm_lb_status_type_t; 70 71 /* Link bonding Modem status */ 72 typedef enum bcm_lb_modem_status_type_e { 73 bcmLbModemStatusIsEmptyFifo = 0, /* Modem FIFO empty indication */ 74 bcmLbModemStatusCount = 1 /* Always Last. Not a usable value. */ 75 } bcm_lb_modem_status_type_t; 76 77 /* Link bonding stat */ 78 typedef enum bcm_lb_stat_val_e { 79 bcmLbStatsUnicastPkts = 0, /* Unicast packets */ 80 bcmLbStatsMulticastPkts = 1, /* Multicast packets */ 81 bcmLbStatsBroadcastPkts = 2, /* Broadcast packets */ 82 bcmLbStatsPkts64Octets = 3, 83 bcmLbStatsPkts65to127Octets = 4, 84 bcmLbStatsPkts128to255Octets = 5, 85 bcmLbStatsPkts256to511Octets = 6, 86 bcmLbStatsPkts512to1023Octets = 7, 87 bcmLbStatsPkts1024to1518Octets = 8, 88 bcmLbStatsPkts1519Octets = 9, 89 bcmLbStatsPkts = 10, 90 bcmLbStatsOctets = 11, 91 bcmLbStatsDiscardFragments = 12, 92 bcmLbStatsErrorPkts = 13, 93 bcmLbStatsCount = 14 /* Always Last. Not a usable value. */ 94 } bcm_lb_stat_val_t; 95 96 /* Link bonding Modem stat */ 97 typedef enum bcm_lb_modem_stat_val_e { 98 bcmLbModemStatsPkts = 0, 99 bcmLbModemStatsOctets = 1, 100 bcmLbModemStatsCount = 2 /* Always Last. Not a usable value. */ 101 } bcm_lb_modem_stat_val_t; 102 103 /* Link bonding Segment Mode */ 104 typedef enum bcm_lb_segment_mode_e { 105 bcmLbSegmentMode128 = 0, 106 bcmLbSegmentMode192 = 1, 107 bcmLbSegmentMode192Enhanced = 2, 108 bcmLbSegmentMode128Enhanced = 3, 109 bcmLbSegmentModeCount = 4 /* Always Last. Not a usable value. */ 110 } bcm_lb_segment_mode_t; 111 112 /* Link bonding flush operation type */ 113 typedef enum bcm_lb_flush_type_e { 114 bcmLbFlushTypeForceFlush = 0, /* For debug only. Should not be used in 115 normal operation */ 116 bcmLbFlushTypeFlushOnGroupOverflow = 1, 117 bcmLbFlushTypeFlushOnFifoOverflow = 2, 118 bcmLbFlushTypeFlushOnSharedOverflow = 3, 119 bcmLbFlushTypeCount = 4 /* Always Last. Not a usable value. */ 120 } bcm_lb_flush_type_t; 121 122 /* Index of mapping traffic to modem */ 123 typedef struct bcm_lb_rx_modem_map_index_s { 124 bcm_gport_t port; 125 bcm_vlan_t vlan; 126 } bcm_lb_rx_modem_map_index_t; 127 128 /* Modem info */ 129 typedef struct bcm_lb_rx_modem_map_config_s { 130 bcm_lb_format_type_t lbg_type; 131 bcm_modem_t modem_id; 132 } bcm_lb_rx_modem_map_config_t; 133 134 /* packet info */ 135 typedef struct bcm_lb_packet_config_s { 136 uint16 outer_vlan_tpid; 137 uint16 lbg_tpid; 138 } bcm_lb_packet_config_t; 139 140 /* packet info */ 141 typedef struct bcm_lb_modem_packet_config_s { 142 bcm_lb_format_type_t pkt_format; 143 bcm_mac_t dst_mac; 144 bcm_mac_t src_mac; 145 uint16 vlan; 146 int use_global_priority_map; 147 } bcm_lb_modem_packet_config_t; 148 149 /* tc dp info */ 150 typedef struct bcm_lb_tc_dp_s { 151 uint32 tc; 152 uint32 dp; 153 } bcm_lb_tc_dp_t; 154 155 /* packet priority info */ 156 typedef struct bcm_lb_pkt_pri_s { 157 uint32 pkt_pri; 158 uint32 pkt_cfi; 159 uint32 pkt_dp; 160 } bcm_lb_pkt_pri_t; 161 162 /* LBG weight info */ 163 typedef struct bcm_lb_lbg_weight_s { 164 bcm_lbg_t lbg_id; 165 int lbg_weight; 166 } bcm_lb_lbg_weight_t; 167 168 /* packet priority info */ 169 typedef struct bcm_lb_modem_shaper_config_s { 170 uint32 enable; 171 uint32 rate; 172 uint32 max_burst; 173 } bcm_lb_modem_shaper_config_t; 174 175 /* Initialize a bcm_lb_rx_modem_map_index_t structure. */ 176 extern void bcm_lb_rx_modem_map_index_t_init( 177 bcm_lb_rx_modem_map_index_t *map_index); 178 179 /* Initialize a bcm_lb_rx_modem_map_config_t structure. */ 180 extern void bcm_lb_rx_modem_map_config_t_init( 181 bcm_lb_rx_modem_map_config_t *map_config); 182 183 /* Initialize a bcm_lb_packet_config_t structure. */ 184 extern void bcm_lb_packet_config_t_init( 185 bcm_lb_packet_config_t *packet_config); 186 187 /* Initialize a bcm_lb_modem_packet_config_t structure. */ 188 extern void bcm_lb_modem_packet_config_t_init( 189 bcm_lb_modem_packet_config_t *packet_config); 190 191 /* Initialize a bcm_lb_tc_dp_t structure. */ 192 extern void bcm_lb_tc_dp_t_init( 193 bcm_lb_tc_dp_t *tc_dp); 194 195 /* Initialize a bcm_lb_pkt_pri_t structure. */ 196 extern void bcm_lb_pkt_pri_t_init( 197 bcm_lb_pkt_pri_t *pkt_pri); 198 199 /* Initialize a bcm_lb_lbg_weight_t structure. */ 200 extern void bcm_lb_lbg_weight_t_init( 201 bcm_lb_lbg_weight_t *lbg_weights); 202 203 /* Initialize a bcm_lb_modem_shaper_config_t structure. */ 204 extern void bcm_lb_modem_shaper_config_t_init( 205 bcm_lb_modem_shaper_config_t *shaper); 206 207 #ifndef BCM_HIDE_DISPATCHABLE 208 209 /* 210 * (for "_set") Connect modem to port. 211 * (for "_get") Get info of which port the modem is connectted to. 212 */ 213 extern int bcm_lb_modem_to_port_map_set( 214 int unit, 215 bcm_modem_t modem_id, 216 uint32 flags, 217 bcm_gport_t port); 218 219 /* 220 * (for "_set") Connect modem to port. 221 * (for "_get") Get info of which port the modem is connectted to. 222 */ 223 extern int bcm_lb_modem_to_port_map_get( 224 int unit, 225 bcm_modem_t modem_id, 226 uint32 flags, 227 bcm_gport_t *port); 228 229 /* 230 * (for "_set") enable LBG. 231 * (for "_get") Get info of whether LBG is enabled 232 */ 233 extern int bcm_lb_enable_set( 234 int unit, 235 bcm_lbg_t lbg_id, 236 uint32 flags, 237 uint32 enable); 238 239 /* 240 * (for "_set") enable LBG. 241 * (for "_get") Get info of whether LBG is enabled 242 */ 243 extern int bcm_lb_enable_get( 244 int unit, 245 bcm_lbg_t lbg_id, 246 uint32 flags, 247 uint32 *enable); 248 249 /* 250 * (for "_set") Connect modem to lbg. 251 * (for "_get") Get info of which lbg the modem is connectted to 252 */ 253 extern int bcm_lb_modem_to_lbg_map_set( 254 int unit, 255 bcm_modem_t modem_id, 256 bcm_lb_direction_type_t direction, 257 uint32 flags, 258 bcm_lbg_t lbg_id); 259 260 /* 261 * (for "_set") Connect modem to lbg. 262 * (for "_get") Get info of which lbg the modem is connectted to 263 */ 264 extern int bcm_lb_modem_to_lbg_map_get( 265 int unit, 266 bcm_modem_t modem_id, 267 bcm_lb_direction_type_t direction, 268 uint32 flags, 269 bcm_lbg_t *lbg_id); 270 271 /* Set/get sequence number width. */ 272 extern int bcm_lb_sequence_number_width_set( 273 int unit, 274 bcm_lbg_t lbg_id, 275 bcm_lb_direction_type_t direction, 276 uint32 flags, 277 int number_width); 278 279 /* Set/get sequence number width. */ 280 extern int bcm_lb_sequence_number_width_get( 281 int unit, 282 bcm_lbg_t lbg_id, 283 bcm_lb_direction_type_t direction, 284 uint32 flags, 285 int *number_width); 286 287 /* Set/get configuration at LBG or global level. */ 288 extern int bcm_lb_control_set( 289 int unit, 290 bcm_lbg_t lbg_id, 291 bcm_lb_direction_type_t direction, 292 uint32 flags, 293 bcm_lb_control_t lb_control, 294 int arg); 295 296 /* Set/get configuration at LBG or global level. */ 297 extern int bcm_lb_control_get( 298 int unit, 299 bcm_lbg_t lbg_id, 300 bcm_lb_direction_type_t direction, 301 uint32 flags, 302 bcm_lb_control_t lb_control, 303 int *arg); 304 305 /* Set/get configuration at modem level. */ 306 extern int bcm_lb_modem_control_set( 307 int unit, 308 bcm_modem_t modem_id, 309 bcm_lb_direction_type_t direction, 310 uint32 flags, 311 bcm_lb_modem_control_t modem_control, 312 int arg); 313 314 /* Set/get configuration at modem level. */ 315 extern int bcm_lb_modem_control_get( 316 int unit, 317 bcm_modem_t modem_id, 318 bcm_lb_direction_type_t direction, 319 uint32 flags, 320 bcm_lb_modem_control_t modem_control, 321 int *arg); 322 323 /* Get Status of LBG or global. */ 324 extern int bcm_lb_status_get( 325 int unit, 326 bcm_lbg_t lbg_id, 327 bcm_lb_direction_type_t direction, 328 uint32 flags, 329 bcm_lb_status_type_t status_type, 330 int *value); 331 332 /* Get Status of modem. */ 333 extern int bcm_lb_modem_status_get( 334 int unit, 335 bcm_modem_t modem_id, 336 bcm_lb_direction_type_t direction, 337 uint32 flags, 338 bcm_lb_modem_status_type_t status_type, 339 int *value); 340 341 /* Get statistic of LBG or global. */ 342 extern int bcm_lb_stat_get( 343 int unit, 344 bcm_lbg_t lbg_id, 345 bcm_lb_direction_type_t direction, 346 uint32 flags, 347 bcm_lb_stat_val_t type, 348 uint64 *value); 349 350 /* Get statistic of modem. */ 351 extern int bcm_lb_modem_stat_get( 352 int unit, 353 bcm_modem_t modem_id, 354 bcm_lb_direction_type_t direction, 355 uint32 flags, 356 bcm_lb_modem_stat_val_t type, 357 uint64 *value); 358 359 /* Set/get mapping of {port+vlan} to modem. */ 360 extern int bcm_lb_rx_modem_map_set( 361 int unit, 362 bcm_lb_rx_modem_map_index_t *map_index, 363 uint32 flags, 364 bcm_lb_rx_modem_map_config_t *map_config); 365 366 /* Set/get mapping of {port+vlan} to modem. */ 367 extern int bcm_lb_rx_modem_map_get( 368 int unit, 369 bcm_lb_rx_modem_map_index_t *map_index, 370 uint32 flags, 371 bcm_lb_rx_modem_map_config_t *map_config); 372 373 /* Set/get packet format at global level. */ 374 extern int bcm_lb_packet_config_set( 375 int unit, 376 uint32 flags, 377 bcm_lb_packet_config_t *packet_config); 378 379 /* Set/get packet format at global level. */ 380 extern int bcm_lb_packet_config_get( 381 int unit, 382 uint32 flags, 383 bcm_lb_packet_config_t *packet_config); 384 385 /* Set/get packet format at modem level. */ 386 extern int bcm_lb_modem_packet_config_set( 387 int unit, 388 bcm_modem_t modem_id, 389 uint32 flags, 390 bcm_lb_modem_packet_config_t *packet_config); 391 392 /* Set/get packet format at modem level. */ 393 extern int bcm_lb_modem_packet_config_get( 394 int unit, 395 bcm_modem_t modem_id, 396 uint32 flags, 397 bcm_lb_modem_packet_config_t *packet_config); 398 399 /* Set/get mapping of {tc+dp} to packet priority. */ 400 extern int bcm_lb_tc_dp_to_priority_config_set( 401 int unit, 402 uint32 flags, 403 bcm_lb_tc_dp_t *tc_dp, 404 bcm_lb_pkt_pri_t *pkt_pri); 405 406 /* Set/get mapping of {tc+dp} to packet priority. */ 407 extern int bcm_lb_tc_dp_to_priority_config_get( 408 int unit, 409 uint32 flags, 410 bcm_lb_tc_dp_t *tc_dp, 411 bcm_lb_pkt_pri_t *pkt_pri); 412 413 /* Set/get scheduler between lbg. */ 414 extern int bcm_lb_tx_sched_set( 415 int unit, 416 uint32 flags, 417 int lbg_count, 418 bcm_lb_lbg_weight_t *lbg_weights); 419 420 /* Set/get scheduler between lbg. */ 421 extern int bcm_lb_tx_sched_get( 422 int unit, 423 uint32 flags, 424 int max_lbg_count, 425 bcm_lb_lbg_weight_t *lbg_weights, 426 int *lbg_count); 427 428 /* Set/get modem shaper. */ 429 extern int bcm_lb_modem_shaper_set( 430 int unit, 431 bcm_modem_t modem_id, 432 uint32 flags, 433 bcm_lb_modem_shaper_config_t *shaper); 434 435 /* Set/get modem shaper. */ 436 extern int bcm_lb_modem_shaper_get( 437 int unit, 438 bcm_modem_t modem_id, 439 uint32 flags, 440 bcm_lb_modem_shaper_config_t *shaper); 441 442 /* Set/get flush configuration at LBG or global level. */ 443 extern int bcm_lb_flush_configure_set( 444 int unit, 445 bcm_lbg_t lbg_id, 446 uint32 flags, 447 bcm_lb_flush_type_t type, 448 int arg); 449 450 /* Set/get flush configuration at LBG or global level. */ 451 extern int bcm_lb_flush_configure_get( 452 int unit, 453 bcm_lbg_t lbg_id, 454 uint32 flags, 455 bcm_lb_flush_type_t type, 456 int *arg); 457 458 #endif /* BCM_HIDE_DISPATCHABLE */ 459 460 #endif /* __BCM_LB_H__ */