sdk56580.asm (10438B)
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-2019 Broadcom Inc. All rights reserved. 7 ; 8 ; 9 ; This is the default program for the (4 + 16) BCM56580 SDKs. 10 ; To start it, use the following commands from BCM: 11 ; 12 ; led load sdk56580.hex 13 ; led auto on 14 ; led start 15 ; 16 ; The are 2 LEDs per Gig port one for Link(Left) and one for activity(Right). 17 ; 18 ; There are two bits per gigabit Ethernet LED with the following colors: 19 ; ZERO, ZERO Black 20 ; ZERO, ONE Amber 21 ; ONE, ZERO Green 22 ; 23 ; Each chip drives only its own LEDs and needs to write them in the order: 24 ; A01, L01, A02, L02, ..., A16, L16, L17, A17, L18, A18, L19, A19, L20, A20 25 ; 26 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 27 ; processor does not always have access to link status. This program 28 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum). 29 ; Generally, a program running on the main CPU must update these 30 ; locations on link change; see linkscan callback in 31 ; $SDK/src/appl/diag/ledproc.c. 32 ; 33 ; Link activity info for Higig/XE ports are not updated by LED processor in 34 ; 56580_a0. The counter DMA task report the activities of Higig/Xe ports 35 ; in bit 1-3 of RAM byte (0x80 + portnum). Bit 1 indicates that the link 36 ; activity is high. Bit 2 indicates that the link activity is medium. Bit 37 ; 3 indicates that the link activity is low. If all three bits are clear, there 38 ; is no activity on the link. See counter DMA task in $SDK/src/soc/counter.c 39 ; 40 ; Current implementation: 41 ; 42 ; L01 reflects port 1 link status: 43 ; Black: no link 44 ; Alternating green/amber: 1000 Mb/s 45 ; Green: 10 Gb/s and above 46 ; Very brief flashes of black at 1 Hz: half duplex 47 ; Longer periods of black: collisions in progress 48 ; 49 ; A01 reflects port 1 activity (even if port is down) 50 ; when port speed is 2.5G and less, 51 ; Black: idle 52 ; Green: RX (pulse extended to 1/3 sec) 53 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 54 ; Green/Amber alternating at 6 Hz: both RX and TX 55 ; when port speed is higher than 2.5G, 56 ; Black: idle 57 ; Green/Amber alternating at approximately 2 Hz (low activity) 58 ; Green/Amber alternating at approximately 4 Hz (medium activity) 59 ; Green/Amber alternating at approximately 8 Hz (high activity) 60 ; 61 ; Note: 62 ; To provide consistent behavior, the gigabit LED patterns match 63 ; those in sdk5605.asm. 64 ; 65 66 SECOND_TICKS EQU 30 67 68 MIN_PORT EQU 0 69 MAX_PORT EQU 19 70 NUM_PORT EQU 20 71 MAX_GE_PORT EQU 16 72 73 HI_ACT EQU 2 ; Hi activity bit mask 74 ME_ACT EQU 4 ; Medium activity bit mask 75 LO_ACT EQU 8 ; Low activity bit mask 76 77 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 78 ; so they will be more visible. 79 80 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 81 GIG_ALT_TICKS EQU (SECOND_TICKS/2) 82 HD_OFF_TICKS EQU (SECOND_TICKS/20) 83 HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 84 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 85 86 ; 87 ; Main Update Routine 88 ; 89 ; This routine is called once per tick. 90 ; 91 92 update: 93 sub a,a ; ld a,MIN_PORT (but only one instr) 94 95 up1: 96 port a 97 ld (PORT_NUM),a 98 99 cmp a, MAX_GE_PORT ; If GE port, we send activity followed by 100 jnc higig ; link status to LED latches. If Higig/XE port, 101 ; we send link status followed by link activity 102 ; to the LED latches. 103 104 call activity 105 call link_status 106 jmp up2 107 108 higig: 109 call link_status 110 call activity 111 112 up2: 113 ld a,(PORT_NUM) 114 inc a 115 116 cmp a,NUM_PORT 117 jnz up1 118 119 ; Update various timers 120 121 inc (HIGIG_ALT_COUNT) 122 123 ld b,GIG_ALT_COUNT 124 inc (b) 125 ld a,(b) 126 cmp a,GIG_ALT_TICKS 127 jc up3 128 ld (b),0 129 130 up3: 131 ld b,HD_COUNT 132 inc (b) 133 ld a,(b) 134 cmp a,HD_ON_TICKS+HD_OFF_TICKS 135 jc up4 136 ld (b),0 137 138 up4: 139 ld b,TXRX_ALT_COUNT 140 inc (b) 141 ld a,(b) 142 cmp a,TXRX_ALT_TICKS 143 jc up5 144 ld (b),0 145 146 up5: 147 send 80 ; 2 * 2 * 20 148 149 ; 150 ; activity 151 ; 152 ; This routine calculates the activity LED for the current port. 153 ; It extends the activity lights using timers (new activity overrides 154 ; and resets the timers). 155 ; 156 ; Inputs: (PORT_NUM) 157 ; Outputs: Two bits sent to LED stream 158 ; 159 160 activity: 161 162 pushst RX 163 pop 164 jnc act1 165 166 ld b,RX_TIMERS ; Start RX LED extension timer 167 add b,(PORT_NUM) 168 ld a,ACT_EXT_TICKS 169 ld (b),a 170 171 act1: 172 pushst TX 173 pop 174 jnc act2 175 176 ld b,TX_TIMERS ; Start TX LED extension timer 177 add b,(PORT_NUM) 178 ld a,ACT_EXT_TICKS 179 ld (b),a 180 181 act2: 182 ld b,TX_TIMERS ; Check TX LED extension timer 183 add b,(PORT_NUM) 184 185 dec (b) 186 jnc act3 ; TX active? 187 inc (b) 188 189 ld b,RX_TIMERS ; Check RX LED extension timer 190 add b,(PORT_NUM) 191 192 dec (b) ; Extend LED green if only RX active 193 jnc led_green 194 inc (b) 195 196 jmp xaui_activity ; If LED processor status indicates no 197 ; activity, we check the activity status 198 ; reported by counter thread. 199 200 act3: ; TX is active, see if RX also active 201 ld b,RX_TIMERS 202 add b,(PORT_NUM) 203 204 dec (b) ; RX also active? 205 jnc act4 206 inc (b) 207 208 jmp led_amber ; Only TX active 209 210 act4: ; Both TX and RX active 211 ld b,(TXRX_ALT_COUNT) 212 cmp b,TXRX_ALT_TICKS/2 213 jc led_amber ; Fast alternation of green/amber 214 jmp led_green 215 216 xaui_activity: 217 ld a, (PORT_NUM) 218 ld b, ACT_DATA 219 add b, a 220 ld b, (b) 221 222 ld a, HI_ACT 223 and a, b 224 jnz xaui_active 225 226 ld a, ME_ACT 227 and a, b 228 jnz xaui_active 229 230 ld a, LO_ACT 231 and a, b 232 jnz xaui_active 233 234 jmp led_black ; No activity 235 236 xaui_active: 237 and a, (HIGIG_ALT_COUNT) 238 jnz led_green 239 jmp led_amber 240 241 242 ; 243 ; link_status 244 ; 245 ; This routine calculates the link status LED for the current port. 246 ; 247 ; Inputs: (PORT_NUM) 248 ; Outputs: Two bits sent to LED stream 249 ; Destroys: a, b 250 ; 251 252 link_status: 253 ld a,(PORT_NUM) ; Check for link down 254 call get_link 255 jnc led_black 256 257 258 pushst SPEED_M 259 jnc led_black ; Goldwing port does not support speed < 1G 260 261 pushst SPEED_C 262 pop 263 jc led_green ; speed >= 10G 264 265 ld a,(GIG_ALT_COUNT) ; 1G <= speed < 10G 266 cmp a,GIG_ALT_TICKS/2 267 jc led_amber 268 269 jmp led_green 270 271 ; 272 ; get_link 273 ; 274 ; This routine finds the link status LED for a port. 275 ; Link info is in bit 0 of the byte read from PORTDATA[port] 276 ; 277 ; Inputs: Port number in a 278 ; Outputs: Carry flag set if link is up, clear if link is down. 279 ; Destroys: a, b 280 ; 281 get_link: 282 ld b,LNK_DATA 283 add b,a 284 ld b,(b) 285 tst b,0 286 ret 287 288 ; 289 ; led_black, led_amber, led_green 290 ; 291 ; Inputs: None 292 ; Outputs: Two bits to the LED stream indicating color 293 ; Destroys: None 294 ; 295 296 led_black: 297 pushst ZERO 298 pack 299 pushst ZERO 300 pack 301 ret 302 303 led_amber: 304 pushst ZERO 305 pack 306 pushst ONE 307 pack 308 ret 309 310 led_green: 311 pushst ONE 312 pack 313 pushst ZERO 314 pack 315 ret 316 317 ; 318 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 319 ; 320 321 TXRX_ALT_COUNT equ 0xf0 322 HD_COUNT equ 0xf1 323 GIG_ALT_COUNT equ 0xf2 324 PORT_NUM equ 0xf3 325 HIGIG_ALT_COUNT equ 0xf4 ; HIGIG_ALT_COUNT holds the higig activity 326 ; LED blinking rate. Bit 1 corresponds to 327 ; to high activity, bit 2 corresponds to 328 ; medium activity, and bit 3 corresponds to 329 ; low activity. The high activity blinks twice 330 ; the speed of medium activity and the medium 331 ; activity blinks twice the speed of low 332 ; activity. This counter is incremented 333 ; every LED refresh cycle. 334 335 ; 336 ; Port data, which must be updated continually by main CPU's 337 ; linkscan and counter DMA tasks. 338 ; See $SDK/src/appl/diag/ledproc.c and $SDK/src/soc/counter.c for examples. 339 ; In this program, 340 ; Bit 341 ; 0 - If set, the link is up. Otherwise, the link is down. 342 ; 1 - If set, the link activity is more than 70% of line rate. 343 ; 2 - If set, the link activity is between 40 to 70% of line rate. 344 ; 3 - If set, the link activity is between 2 to 40% of line rate. 345 ; If bit 1, 2, and 3 are all clear, there is no activity on the link. 346 347 348 LNK_DATA equ 0x80 ; Size 20 bytes 349 ACT_DATA equ 0x80+0x14 ; Size 20 bytes 350 351 ; 352 ; LED extension timers 353 ; 354 355 RX_TIMERS equ ACT_DATA+0x14 ; NUM_PORT bytes 356 TX_TIMERS equ RX_TIMERS+NUM_PORT ; NUM_PORT bytes 357 358 ; 359 ; Symbolic names for the bits of the port status fields 360 ; 361 362 RX equ 0x0 ; received packet 363 TX equ 0x1 ; transmitted packet 364 COLL equ 0x2 ; collision indicator 365 SPEED_C equ 0x3 ; 100 Mbps 366 SPEED_M equ 0x4 ; 1000 Mbps 367 DUPLEX equ 0x5 ; half/full duplex 368 FLOW equ 0x6 ; flow control capable 369 LINKUP equ 0x7 ; link down/up status 370 LINKEN equ 0x8 ; link disabled/enabled status 371 ZERO equ 0xE ; always 0 372 ONE equ 0xF ; always 1