lport.h (7728B)
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 * DO NOT EDIT THIS FILE! 9 * This file is auto-generated. 10 * Edits to this file will be lost when it is regenerated. 11 */ 12 13 #ifndef __BCMX_LPORT_H__ 14 #define __BCMX_LPORT_H__ 15 16 #include <bcm/types.h> 17 #include <bcm/error.h> 18 #include <bcmx/types.h> 19 #include <bcmx/lplist.h> 20 #include <bcmx_int/lport.h> 21 22 /* BCMX Application Logical Port (User Port) definitions. */ 23 #define BCMX_UPORT_CAST(val) INT_TO_PTR(val) 24 #define BCMX_UPORT_EQ(a, b) ((a) == (b)) 25 #define BCMX_UPORT_SET(dst, src) ((dst) = (src)) 26 27 /* 28 * Special BCMX logical port definitions. 29 * 30 * INVALID: Explicitly invalid logical port. 31 * NO_SUCH_LPORT: Alias for INVALID. 32 * LOCAL_CPU: Special marker requiring a unit context; 33 * Given a unit, this is the CPU port associated 34 * with that unit. 35 * ETHER_ALL: Indicates all ethernet ports (FE, GE, XE, CE), 36 * as defined in the soc driver file. 37 */ 38 #define BCMX_LPORT_INVALID ((bcmx_lport_t)(BCM_GPORT_INVALID)) 39 #define BCMX_NO_SUCH_LPORT BCMX_LPORT_INVALID /* Compatibility */ 40 #define BCMX_LPORT_LOCAL_CPU ((bcmx_lport_t)(BCM_GPORT_LOCAL_CPU)) 41 #define BCMX_LPORT_ETHER_ALL \ 42 ((bcmx_lport_t)(BCM_GPORT_SPECIAL(BCMX_GPORT_SPECIAL_ETHER_ALL))) 43 44 /* BCMX Port Flags. */ 45 #define BCMX_PORT_F_VALID 0x1 /* This port is active. */ 46 #define BCMX_PORT_F_STACK_INT 0x2 /* Internal stack port. */ 47 #define BCMX_PORT_F_STACK_EXT 0x4 /* External stack port. */ 48 #define BCMX_PORT_F_CPU 0x8 /* CPU port. */ 49 #define BCMX_PORT_F_HG 0x10 /* HiGig port. */ 50 #define BCMX_PORT_F_FE 0x20 /* 10/100 port. */ 51 #define BCMX_PORT_F_GE 0x40 /* 1000 port. */ 52 #define BCMX_PORT_F_XE 0x80 /* 10000 port. */ 53 #define BCMX_PORT_F_CE 0x100 /* 100000 port. */ 54 #define BCMX_PORT_F_IS_STACK_PORT(_flags) \ 55 ((_flags) & (BCMX_PORT_F_STACK_INT | BCMX_PORT_F_STACK_EXT)) 56 57 /* Mapping Macros lports -> unit, port, modid, modport, flags. */ 58 #define BCMX_LPORT_BOUNDS(_lport) (BCM_GPORT_IS_SET(_lport)) 59 #define BCMX_LPORT_VALID(_lport) (bcmx_lport_valid(_lport)) 60 #define BCMX_LPORT_BCM_UNIT(_lport) (bcmx_lport_bcm_unit(_lport)) 61 #define BCMX_LPORT_BCM_PORT(_lport) (bcmx_lport_bcm_port(_lport)) 62 #define BCMX_LPORT_MODID(_lport) (bcmx_lport_modid(_lport)) 63 #define BCMX_LPORT_MODPORT(_lport) (bcmx_lport_modport(_lport)) 64 #define BCMX_LPORT_FLAGS(_lport) (bcmx_lport_flags(_lport)) 65 66 /* 67 * LPORT Iterator. 68 * 69 * For running thru all lports. 70 * 71 * NOTE: Order of ports is based on the order in which ports were added 72 * in BCMX. 73 */ 74 #define BCMX_LPORT_FIRST (bcmx_lport_first()) 75 #define BCMX_LPORT_NEXT(_lport) (bcmx_lport_next(_lport)) 76 #define BCMX_FOREACH_LPORT(_lport) \ 77 for (_lport = BCMX_LPORT_FIRST; _lport != BCMX_LPORT_INVALID; \ 78 _lport = BCMX_LPORT_NEXT(_lport)) 79 #define BCMX_FOREACH_QUALIFIED_LPORT(_lport, _flag) \ 80 BCMX_FOREACH_LPORT(_lport) if (BCMX_LPORT_FLAGS(_lport) & (_flag)) 81 82 /* Mapping Macros uports <--> lports. */ 83 #define BCMX_UPORT_TO_LPORT(_uport) bcmx_uport_to_lport(_uport) 84 #define BCMX_LPORT_TO_UPORT(_lport) bcmx_uport_get(_lport) 85 #define BCMX_UPORT_GET(_lport) BCMX_LPORT_TO_UPORT(_lport) 86 #define BCMX_UPORT_INVALID ((bcmx_uport_t) (-1)) 87 #define BCMX_UPORT_INVALID_DEFAULT BCMX_UPORT_INVALID /* Deprecated. Use 88 BCMX_UPORT_INVALID_DEFAULT. */ 89 90 /* 91 * bcmx_uport_create: 92 * 93 * This is the callback made by BCMX when a logical port is added to the 94 * configuration. BCMX uses this call to determine the application 95 * logical port name for the port. The application may use this as an 96 * indication that a port has been added to the system, or it may have 97 * already been notified by the stack task. 98 * 99 * The BCM Dispatch layer will already be set up at this point, so the 100 * application can query it for additional information about the port or 101 * system configuration if needed. However, the application should not 102 * make any BCMX calls inside this callback. 103 * 104 * The logical port reference is also provided in case the application 105 * wants to record that. 106 * 107 * The application is responsible for setting the flags variable properly 108 * to indicate whether this is a stack port, etc. 109 */ 110 typedef bcmx_uport_t (*bcmx_uport_create_f)( 111 bcmx_lport_t lport, 112 int unit, 113 bcm_port_t port, 114 uint32 flags); 115 116 typedef void (*bcmx_lport_remove_notify_f)( 117 bcmx_lport_t lport, 118 bcmx_uport_t uport); 119 120 extern bcmx_uport_create_f bcmx_uport_create; 121 122 extern bcmx_lport_remove_notify_f bcmx_lport_remove_notify; 123 124 /* Initialize the BCMX Logical Port information. */ 125 extern int bcmx_lport_init(void); 126 127 /* BCMX local CPU port reference. */ 128 extern int bcmx_lport_local_cpu_get( 129 int bcm_unit, 130 bcmx_lport_t *lport); 131 132 /* Get the uport associated with a BCMX lport. */ 133 extern bcmx_uport_t bcmx_uport_get( 134 bcmx_lport_t lport); 135 136 /* Set the uport associated with a BCMX lport. */ 137 extern int bcmx_uport_set( 138 bcmx_lport_t lport, 139 bcmx_uport_t uport); 140 141 /* Map a BCMX lport to a BCM dispatch unit and physical port. */ 142 extern int bcmx_lport_to_unit_port( 143 bcmx_lport_t lport, 144 int *unit, 145 bcm_port_t *port); 146 147 /* Map a BCMX lport to a BCM device module ID and port. */ 148 extern int bcmx_lport_to_modid_port( 149 bcmx_lport_t lport, 150 int *modid, 151 bcm_port_t *modport); 152 153 /* Map a BCMX lport to its BCM device module id, if appropriate. */ 154 extern int bcmx_lport_to_modid( 155 bcmx_lport_t lport, 156 int *modid); 157 158 /* Map a BCM unit and port number to a BCMX lport. */ 159 extern bcmx_lport_t bcmx_unit_port_to_lport( 160 int unit, 161 bcm_port_t port); 162 163 /* Map a BCM device module ID and port to a BCMX lport. */ 164 extern bcmx_lport_t bcmx_modid_port_to_lport( 165 int modid, 166 bcm_port_t port); 167 168 /* Map a user port to a BCMX lport. */ 169 extern bcmx_lport_t bcmx_uport_to_lport( 170 bcmx_uport_t uport); 171 172 /* Get the device unit number associated with given module id. */ 173 extern int bcmx_modid_to_bcm_unit( 174 int modid, 175 int *bcm_unit); 176 177 /* Map a user port to BCM unit and port pair. */ 178 extern int bcmx_uport_to_unit_port( 179 bcmx_uport_t uport, 180 int *bcm_unit, 181 bcm_port_t *bcm_port); 182 183 /* Deprecated. Use bcmx_lport_to_unit_port. */ 184 extern int bcmx_lport_bcm_unit( 185 bcmx_lport_t lport); 186 187 /* Deprecated. Use bcmx_lport_to_unit_port. */ 188 extern bcm_port_t bcmx_lport_bcm_port( 189 bcmx_lport_t lport); 190 191 /* Deprecated. Use bcmx_lport_to_modid_port. */ 192 extern int bcmx_lport_modid( 193 bcmx_lport_t lport); 194 195 /* Deprecated. Use bcmx_lport_to_modid_port. */ 196 extern bcm_port_t bcmx_lport_modport( 197 bcmx_lport_t lport); 198 199 /* Deprecated. Use BCMX_LPORT_FLAGS */ 200 extern uint32 bcmx_lport_flags( 201 bcmx_lport_t lport); 202 203 /* Deprecated. BCMX_LPORT_FIRST. */ 204 extern bcmx_lport_t bcmx_lport_first(void); 205 206 /* Deprecated. Use BCMX_LPORT_NEXT. */ 207 extern bcmx_lport_t bcmx_lport_next( 208 bcmx_lport_t lport); 209 210 /* Deprecated. Use BCMX_LPORT_VALID. */ 211 extern int bcmx_lport_valid( 212 bcmx_lport_t lport); 213 214 /* 215 * Deprecated 216 * Applications should no longer use the following definitions. 217 */ 218 #define BCMX_LPORT(_lport) (NULL) 219 #define BCMX_LPORT_MAX_DEFAULT 0 /* Was 1024 */ 220 #define bcmx_lport_map_init(_lport_max) bcmx_lport_init() 221 #define _bcmx_lport_next bcmx_lport_next 222 #define _bcmx_uport_to_lport bcmx_uport_to_lport 223 224 #endif /* __BCMX_LPORT_H__ */