1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
|
/* $Id$
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1992 - 1997, 2000 Silicon Graphics, Inc.
* Copyright (C) 2000 by Colin Ngam
*/
#ifndef _ASM_SN_SN1_ROUTER_H
#define _ASM_SN_SN1_ROUTER_H
/*
* Router Register definitions
*
* Macro argument _L always stands for a link number (1 to 8, inclusive).
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
#include <asm/sn/vector.h>
#include <asm/sn/slotnum.h>
#include <asm/sn/arch.h>
typedef uint64_t router_reg_t;
#define MAX_ROUTERS 64
#define MAX_ROUTER_PATH 80
#define ROUTER_REG_CAST (volatile router_reg_t *)
#define PS_UINT_CAST (__psunsigned_t)
#define UINT64_CAST (uint64_t)
typedef signed char port_no_t; /* Type for router port number */
#elif _LANGUAGE_ASSEMBLY
#define ROUTERREG_CAST
#define PS_UINT_CAST
#define UINT64_CAST
#endif /* _LANGUAGE_C || _LANGUAGE_C_PLUS_PLUS */
#define MAX_ROUTER_PORTS (8) /* Max. number of ports on a router */
#define ALL_PORTS ((1 << MAX_ROUTER_PORTS) - 1) /* for 0 based references */
#define PORT_INVALID (-1) /* Invalid port number */
#define IS_META(_rp) ((_rp)->flags & PCFG_ROUTER_META)
#define IS_REPEATER(_rp)((_rp)->flags & PCFG_ROUTER_REPEATER)
/*
* RR_TURN makes a given number of clockwise turns (0 to 7) from an inport
* port to generate an output port.
*
* RR_DISTANCE returns the number of turns necessary (0 to 7) to go from
* an input port (_L1 = 1 to 8) to an output port ( _L2 = 1 to 8).
*
* These are written to work on unsigned data.
*/
#define RR_TURN(_L, count) ((_L) + (count) > MAX_ROUTER_PORTS ? \
(_L) + (count) - MAX_ROUTER_PORTS : \
(_L) + (count))
#define RR_DISTANCE(_LS, _LD) ((_LD) >= (_LS) ? \
(_LD) - (_LS) : \
(_LD) + MAX_ROUTER_PORTS - (_LS))
/* Router register addresses */
#define RR_STATUS_REV_ID 0x00000 /* Status register and Revision ID */
#define RR_PORT_RESET 0x00008 /* Multiple port reset */
#define RR_PROT_CONF 0x00010 /* Inter-partition protection conf. */
#define RR_GLOBAL_PORT_DEF 0x00018 /* Global Port definitions */
#define RR_GLOBAL_PARMS0 0x00020 /* Parameters shared by all 8 ports */
#define RR_GLOBAL_PARMS1 0x00028 /* Parameters shared by all 8 ports */
#define RR_DIAG_PARMS 0x00030 /* Parameters for diag. testing */
#define RR_DEBUG_ADDR 0x00038 /* Debug address select - debug port*/
#define RR_LB_TO_L2 0x00040 /* Local Block to L2 cntrl intf reg */
#define RR_L2_TO_LB 0x00048 /* L2 cntrl intf to Local Block reg */
#define RR_JBUS_CONTROL 0x00050 /* read/write timing for JBUS intf */
#define RR_SCRATCH_REG0 0x00100 /* Scratch 0 is 64 bits */
#define RR_SCRATCH_REG1 0x00108 /* Scratch 1 is 64 bits */
#define RR_SCRATCH_REG2 0x00110 /* Scratch 2 is 64 bits */
#define RR_SCRATCH_REG3 0x00118 /* Scratch 3 is 1 bit */
#define RR_SCRATCH_REG4 0x00120 /* Scratch 4 is 1 bit */
#define RR_JBUS0(_D) (((_D) & 0x7) << 3 | 0x00200) /* JBUS0 addresses */
#define RR_JBUS1(_D) (((_D) & 0x7) << 3 | 0x00240) /* JBUS1 addresses */
#define RR_SCRATCH_REG0_WZ 0x00500 /* Scratch 0 is 64 bits */
#define RR_SCRATCH_REG1_WZ 0x00508 /* Scratch 1 is 64 bits */
#define RR_SCRATCH_REG2_WZ 0x00510 /* Scratch 2 is 64 bits */
#define RR_SCRATCH_REG3_SZ 0x00518 /* Scratch 3 is 1 bit */
#define RR_SCRATCH_REG4_SZ 0x00520 /* Scratch 4 is 1 bit */
#define RR_VECTOR_HW_BAR(context) (0x08000 | (context)<<3) /* barrier config registers */
/* Port-specific registers (_L is the link number from 1 to 8) */
#define RR_PORT_PARMS(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0000) /* LLP parameters */
#define RR_STATUS_ERROR(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0008) /* Port-related errs */
#define RR_CHANNEL_TEST(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0010) /* Port LLP chan test */
#define RR_RESET_MASK(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0018) /* Remote reset mask */
#define RR_HISTOGRAM0(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0020) /* Port usage histgrm */
#define RR_HISTOGRAM1(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0028) /* Port usage histgrm */
#define RR_HISTOGRAM0_WC(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0030) /* Port usage histgrm */
#define RR_HISTOGRAM1_WC(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0038) /* Port usage histgrm */
#define RR_ERROR_CLEAR(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0088) /* Read/clear errors */
#define RR_GLOBAL_TABLE0(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0100) /* starting address of global table for this port */
#define RR_GLOBAL_TABLE(_L, _x) (RR_GLOBAL_TABLE0(_L) + ((_x) << 3))
#define RR_LOCAL_TABLE0(_L) (((_L+1) & 0xe) << 15 | ((_L+1) & 0x1) << 11 | 0x0200) /* starting address of local table for this port */
#define RR_LOCAL_TABLE(_L, _x) (RR_LOCAL_TABLE0(_L) + ((_x) << 3))
#define RR_META_ENTRIES 16
#define RR_LOCAL_ENTRIES 128
/*
* RR_STATUS_REV_ID mask and shift definitions
*/
#define RSRI_INPORT_SHFT 52
#define RSRI_INPORT_MASK (UINT64_CAST 0xf << 52)
#define RSRI_LINKWORKING_BIT(_L) (35 + 2 * (_L))
#define RSRI_LINKWORKING(_L) (UINT64_CAST 1 << (35 + 2 * (_L)))
#define RSRI_LINKRESETFAIL(_L) (UINT64_CAST 1 << (34 + 2 * (_L)))
#define RSRI_LSTAT_SHFT(_L) (34 + 2 * (_L))
#define RSRI_LSTAT_MASK(_L) (UINT64_CAST 0x3 << 34 + 2 * (_L))
#define RSRI_LOCALSBERROR (UINT64_CAST 1 << 35)
#define RSRI_LOCALSTUCK (UINT64_CAST 1 << 34)
#define RSRI_LOCALBADVEC (UINT64_CAST 1 << 33)
#define RSRI_LOCALTAILERR (UINT64_CAST 1 << 32)
#define RSRI_LOCAL_SHFT 32
#define RSRI_LOCAL_MASK (UINT64_CAST 0xf << 32)
#define RSRI_CHIPREV_SHFT 28
#define RSRI_CHIPREV_MASK (UINT64_CAST 0xf << 28)
#define RSRI_CHIPID_SHFT 12
#define RSRI_CHIPID_MASK (UINT64_CAST 0xffff << 12)
#define RSRI_MFGID_SHFT 1
#define RSRI_MFGID_MASK (UINT64_CAST 0x7ff << 1)
#define RSRI_LSTAT_WENTDOWN 0
#define RSRI_LSTAT_RESETFAIL 1
#define RSRI_LSTAT_LINKUP 2
#define RSRI_LSTAT_NOTUSED 3
/*
* RR_PORT_RESET mask definitions
*/
#define RPRESET_WARM (UINT64_CAST 1 << 9)
#define RPRESET_LINK(_L) (UINT64_CAST 1 << (_L))
#define RPRESET_LOCAL (UINT64_CAST 1)
/*
* RR_PROT_CONF mask and shift definitions
*/
#define RPCONF_DIRCMPDIS_SHFT 13
#define RPCONF_DIRCMPDIS_MASK (UINT64_CAST 1 << 13)
#define RPCONF_FORCELOCAL (UINT64_CAST 1 << 12)
#define RPCONF_FLOCAL_SHFT 12
#define RPCONF_METAID_SHFT 8
#define RPCONF_METAID_MASK (UINT64_CAST 0xf << 8)
#define RPCONF_RESETOK(_L) (UINT64_CAST 1 << ((_L) - 1))
/*
* RR_GLOBAL_PORT_DEF mask and shift definitions
*/
#define RGPD_MGLBLNHBR_ID_SHFT 12 /* -global neighbor ID */
#define RGPD_MGLBLNHBR_ID_MASK (UINT64_CAST 0xf << 12)
#define RGPD_MGLBLNHBR_VLD_SHFT 11 /* -global neighbor Valid */
#define RGPD_MGLBLNHBR_VLD_MASK (UINT64_CAST 0x1 << 11)
#define RGPD_MGLBLPORT_SHFT 8 /* -global neighbor Port */
#define RGPD_MGLBLPORT_MASK (UINT64_CAST 0x7 << 8)
#define RGPD_PGLBLNHBR_ID_SHFT 4 /* +global neighbor ID */
#define RGPD_PGLBLNHBR_ID_MASK (UINT64_CAST 0xf << 4)
#define RGPD_PGLBLNHBR_VLD_SHFT 3 /* +global neighbor Valid */
#define RGPD_PGLBLNHBR_VLD_MASK (UINT64_CAST 0x1 << 3)
#define RGPD_PGLBLPORT_SHFT 0 /* +global neighbor Port */
#define RGPD_PGLBLPORT_MASK (UINT64_CAST 0x7 << 0)
#define GLBL_PARMS_REGS 2 /* Two Global Parms registers */
/*
* RR_GLOBAL_PARMS0 mask and shift definitions
*/
#define RGPARM0_ARB_VALUE_SHFT 54 /* Local Block Arbitration State */
#define RGPARM0_ARB_VALUE_MASK (UINT64_CAST 0x7 << 54)
#define RGPARM0_ROTATEARB_SHFT 53 /* Rotate Local Block Arbitration */
#define RGPARM0_ROTATEARB_MASK (UINT64_CAST 0x1 << 53)
#define RGPARM0_FAIREN_SHFT 52 /* Fairness logic Enable */
#define RGPARM0_FAIREN_MASK (UINT64_CAST 0x1 << 52)
#define RGPARM0_LOCGNTTO_SHFT 40 /* Local grant timeout */
#define RGPARM0_LOCGNTTO_MASK (UINT64_CAST 0xfff << 40)
#define RGPARM0_DATELINE_SHFT 38 /* Dateline crossing router */
#define RGPARM0_DATELINE_MASK (UINT64_CAST 0x1 << 38)
#define RGPARM0_MAXRETRY_SHFT 28 /* Max retry count */
#define RGPARM0_MAXRETRY_MASK (UINT64_CAST 0x3ff << 28)
#define RGPARM0_URGWRAP_SHFT 20 /* Urgent wrap */
#define RGPARM0_URGWRAP_MASK (UINT64_CAST 0xff << 20)
#define RGPARM0_DEADLKTO_SHFT 16 /* Deadlock timeout */
#define RGPARM0_DEADLKTO_MASK (UINT64_CAST 0xf << 16)
#define RGPARM0_URGVAL_SHFT 12 /* Urgent value */
#define RGPARM0_URGVAL_MASK (UINT64_CAST 0xf << 12)
#define RGPARM0_VCHSELEN_SHFT 11 /* VCH_SEL_EN */
#define RGPARM0_VCHSELEN_MASK (UINT64_CAST 0x1 << 11)
#define RGPARM0_LOCURGTO_SHFT 9 /* Local urgent timeout */
#define RGPARM0_LOCURGTO_MASK (UINT64_CAST 0x3 << 9)
#define RGPARM0_TAILVAL_SHFT 5 /* Tail value */
#define RGPARM0_TAILVAL_MASK (UINT64_CAST 0xf << 5)
#define RGPARM0_CLOCK_SHFT 1 /* Global clock select */
#define RGPARM0_CLOCK_MASK (UINT64_CAST 0xf << 1)
#define RGPARM0_BYPEN_SHFT 0
#define RGPARM0_BYPEN_MASK (UINT64_CAST 1) /* Bypass enable */
/*
* RR_GLOBAL_PARMS1 shift and mask definitions
*/
#define RGPARM1_TTOWRAP_SHFT 12 /* Tail timeout wrap */
#define RGPARM1_TTOWRAP_MASK (UINT64_CAST 0xfffff << 12)
#define RGPARM1_AGERATE_SHFT 8 /* Age rate */
#define RGPARM1_AGERATE_MASK (UINT64_CAST 0xf << 8)
#define RGPARM1_JSWSTAT_SHFT 0 /* JTAG Sw Register bits */
#define RGPARM1_JSWSTAT_MASK (UINT64_CAST 0xff << 0)
/*
* RR_DIAG_PARMS mask and shift definitions
*/
#define RDPARM_ABSHISTOGRAM (UINT64_CAST 1 << 17) /* Absolute histgrm */
#define RDPARM_DEADLOCKRESET (UINT64_CAST 1 << 16) /* Reset on deadlck */
#define RDPARM_DISABLE(_L) (UINT64_CAST 1 << ((_L) + 7))
#define RDPARM_SENDERROR(_L) (UINT64_CAST 1 << ((_L) - 1))
/*
* RR_DEBUG_ADDR mask and shift definitions
*/
#define RDA_DATA_SHFT 10 /* Observed debug data */
#define RDA_DATA_MASK (UINT64_CAST 0xffff << 10)
#define RDA_ADDR_SHFT 0 /* debug address for data */
#define RDA_ADDR_MASK (UINT64_CAST 0x3ff << 0)
/*
* RR_LB_TO_L2 mask and shift definitions
*/
#define RLBTOL2_DATA_VLD_SHFT 32 /* data is valid for JTAG controller */
#define RLBTOL2_DATA_VLD_MASK (UINT64_CAST 0x1 << 32)
#define RLBTOL2_DATA_SHFT 0 /* data bits for JTAG controller */
#define RLBTOL2_DATA_MASK (UINT64_CAST 0xffffffff)
/*
* RR_L2_TO_LB mask and shift definitions
*/
#define RL2TOLB_DATA_VLD_SHFT 33 /* data is valid from JTAG controller */
#define RL2TOLB_DATA_VLD_MASK (UINT64_CAST 0x1 << 33)
#define RL2TOLB_PARITY_SHFT 32 /* sw implemented parity for data */
#define RL2TOLB_PARITY_MASK (UINT64_CAST 0x1 << 32)
#define RL2TOLB_DATA_SHFT 0 /* data bits from JTAG controller */
#define RL2TOLB_DATA_MASK (UINT64_CAST 0xffffffff)
/*
* RR_JBUS_CONTROL mask and shift definitions
*/
#define RJC_POS_BITS_SHFT 20 /* Router position bits */
#define RJC_POS_BITS_MASK (UINT64_CAST 0xf << 20)
#define RJC_RD_DATA_STROBE_SHFT 16 /* count when read data is strobed in */
#define RJC_RD_DATA_STROBE_MASK (UINT64_CAST 0xf << 16)
#define RJC_WE_OE_HOLD_SHFT 8 /* time OE or WE is held */
#define RJC_WE_OE_HOLD_MASK (UINT64_CAST 0xff << 8)
#define RJC_ADDR_SET_HLD_SHFT 0 /* time address driven around OE/WE */
#define RJC_ADDR_SET_HLD_MASK (UINT64_CAST 0xff)
/*
* RR_SCRATCH_REGx mask and shift definitions
* note: these fields represent a software convention, and are not
* understood/interpreted by the hardware.
*/
#define RSCR0_BOOTED_SHFT 63
#define RSCR0_BOOTED_MASK (UINT64_CAST 0x1 << RSCR0_BOOTED_SHFT)
#define RSCR0_LOCALID_SHFT 56
#define RSCR0_LOCALID_MASK (UINT64_CAST 0x7f << RSCR0_LOCALID_SHFT)
#define RSCR0_UNUSED_SHFT 48
#define RSCR0_UNUSED_MASK (UINT64_CAST 0xff << RSCR0_UNUSED_SHFT)
#define RSCR0_NIC_SHFT 0
#define RSCR0_NIC_MASK (UINT64_CAST 0xffffffffffff)
#define RSCR1_MODID_SHFT 0
#define RSCR1_MODID_MASK (UINT64_CAST 0xffff)
/*
* RR_VECTOR_HW_BAR mask and shift definitions
*/
#define BAR_TX_SHFT 27 /* Barrier in trans(m)it when read */
#define BAR_TX_MASK (UINT64_CAST 1 << BAR_TX_SHFT)
#define BAR_VLD_SHFT 26 /* Valid Configuration */
#define BAR_VLD_MASK (UINT64_CAST 1 << BAR_VLD_SHFT)
#define BAR_SEQ_SHFT 24 /* Sequence number */
#define BAR_SEQ_MASK (UINT64_CAST 3 << BAR_SEQ_SHFT)
#define BAR_LEAFSTATE_SHFT 18 /* Leaf State */
#define BAR_LEAFSTATE_MASK (UINT64_CAST 0x3f << BAR_LEAFSTATE_SHFT)
#define BAR_PARENT_SHFT 14 /* Parent Port */
#define BAR_PARENT_MASK (UINT64_CAST 0xf << BAR_PARENT_SHFT)
#define BAR_CHILDREN_SHFT 6 /* Child Select port bits */
#define BAR_CHILDREN_MASK (UINT64_CAST 0xff << BAR_CHILDREN_SHFT)
#define BAR_LEAFCOUNT_SHFT 0 /* Leaf Count to trigger parent */
#define BAR_LEAFCOUNT_MASK (UINT64_CAST 0x3f)
/*
* RR_PORT_PARMS(_L) mask and shift definitions
*/
#define RPPARM_MIPRESETEN_SHFT 29 /* Message In Progress reset enable */
#define RPPARM_MIPRESETEN_MASK (UINT64_CAST 0x1 << 29)
#define RPPARM_UBAREN_SHFT 28 /* Enable user barrier requests */
#define RPPARM_UBAREN_MASK (UINT64_CAST 0x1 << 28)
#define RPPARM_OUTPDTO_SHFT 24 /* Output Port Deadlock TO value */
#define RPPARM_OUTPDTO_MASK (UINT64_CAST 0xf << 24)
#define RPPARM_PORTMATE_SHFT 21 /* Port Mate for the port */
#define RPPARM_PORTMATE_MASK (UINT64_CAST 0x7 << 21)
#define RPPARM_HISTEN_SHFT 20 /* Histogram counter enable */
#define RPPARM_HISTEN_MASK (UINT64_CAST 0x1 << 20)
#define RPPARM_HISTSEL_SHFT 18
#define RPPARM_HISTSEL_MASK (UINT64_CAST 0x3 << 18)
#define RPPARM_DAMQHS_SHFT 16
#define RPPARM_DAMQHS_MASK (UINT64_CAST 0x3 << 16)
#define RPPARM_NULLTO_SHFT 10
#define RPPARM_NULLTO_MASK (UINT64_CAST 0x3f << 10)
#define RPPARM_MAXBURST_SHFT 0
#define RPPARM_MAXBURST_MASK (UINT64_CAST 0x3ff)
/*
* NOTE: Normally the kernel tracks only UTILIZATION statistics.
* The other 2 should not be used, except during any experimentation
* with the router.
*/
#define RPPARM_HISTSEL_AGE 0 /* Histogram age characterization. */
#define RPPARM_HISTSEL_UTIL 1 /* Histogram link utilization */
#define RPPARM_HISTSEL_DAMQ 2 /* Histogram DAMQ characterization. */
/*
* RR_STATUS_ERROR(_L) and RR_ERROR_CLEAR(_L) mask and shift definitions
*/
#define RSERR_POWERNOK (UINT64_CAST 1 << 38)
#define RSERR_PORT_DEADLOCK (UINT64_CAST 1 << 37)
#define RSERR_WARMRESET (UINT64_CAST 1 << 36)
#define RSERR_LINKRESET (UINT64_CAST 1 << 35)
#define RSERR_RETRYTIMEOUT (UINT64_CAST 1 << 34)
#define RSERR_FIFOOVERFLOW (UINT64_CAST 1 << 33)
#define RSERR_ILLEGALPORT (UINT64_CAST 1 << 32)
#define RSERR_DEADLOCKTO_SHFT 28
#define RSERR_DEADLOCKTO_MASK (UINT64_CAST 0xf << 28)
#define RSERR_RECVTAILTO_SHFT 24
#define RSERR_RECVTAILTO_MASK (UINT64_CAST 0xf << 24)
#define RSERR_RETRYCNT_SHFT 16
#define RSERR_RETRYCNT_MASK (UINT64_CAST 0xff << 16)
#define RSERR_CBERRCNT_SHFT 8
#define RSERR_CBERRCNT_MASK (UINT64_CAST 0xff << 8)
#define RSERR_SNERRCNT_SHFT 0
#define RSERR_SNERRCNT_MASK (UINT64_CAST 0xff << 0)
#define PORT_STATUS_UP (1 << 0) /* Router link up */
#define PORT_STATUS_FENCE (1 << 1) /* Router link fenced */
#define PORT_STATUS_RESETFAIL (1 << 2) /* Router link didnot
* come out of reset */
#define PORT_STATUS_DISCFAIL (1 << 3) /* Router link failed after
* out of reset but before
* router tables were
* programmed
*/
#define PORT_STATUS_KERNFAIL (1 << 4) /* Router link failed
* after reset and the
* router tables were
* programmed
*/
#define PORT_STATUS_UNDEF (1 << 5) /* Unable to pinpoint
* why the router link
* went down
*/
#define PROBE_RESULT_BAD (-1) /* Set if any of the router
* links failed after reset
*/
#define PROBE_RESULT_GOOD (0) /* Set if all the router links
* which came out of reset
* are up
*/
/* Should be enough for 256 CPUs */
#define MAX_RTR_BREADTH 64 /* Max # of routers possible */
/* Get the require set of bits in a var. corr to a sequence of bits */
#define GET_FIELD(var, fname) \
((var) >> fname##_SHFT & fname##_MASK >> fname##_SHFT)
/* Set the require set of bits in a var. corr to a sequence of bits */
#define SET_FIELD(var, fname, fval) \
((var) = (var) & ~fname##_MASK | (uint64_t) (fval) << fname##_SHFT)
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
typedef struct router_map_ent_s {
uint64_t nic;
moduleid_t module;
slotid_t slot;
} router_map_ent_t;
struct rr_status_error_fmt {
uint64_t rserr_unused : 30,
rserr_fifooverflow : 1,
rserr_illegalport : 1,
rserr_deadlockto : 4,
rserr_recvtailto : 4,
rserr_retrycnt : 8,
rserr_cberrcnt : 8,
rserr_snerrcnt : 8;
};
/*
* This type is used to store "absolute" counts of router events
*/
typedef int router_count_t;
/* All utilizations are on a scale from 0 - 1023. */
#define RP_BYPASS_UTIL 0
#define RP_RCV_UTIL 1
#define RP_SEND_UTIL 2
#define RP_TOTAL_PKTS 3 /* Free running clock/packet counter */
#define RP_NUM_UTILS 3
#define RP_HIST_REGS 2
#define RP_NUM_BUCKETS 4
#define RP_HIST_TYPES 3
#define RP_AGE0 0
#define RP_AGE1 1
#define RP_AGE2 2
#define RP_AGE3 3
#define RR_UTIL_SCALE 1024
/*
* Router port-oriented information
*/
typedef struct router_port_info_s {
router_reg_t rp_histograms[RP_HIST_REGS];/* Port usage info */
router_reg_t rp_port_error; /* Port error info */
router_count_t rp_retry_errors; /* Total retry errors */
router_count_t rp_sn_errors; /* Total sn errors */
router_count_t rp_cb_errors; /* Total cb errors */
int rp_overflows; /* Total count overflows */
int rp_excess_err; /* Port has excessive errors */
ushort rp_util[RP_NUM_BUCKETS];/* Port utilization */
} router_port_info_t;
#define ROUTER_INFO_VERSION 7
struct lboard_s;
/*
* Router information
*/
typedef struct router_info_s {
char ri_version; /* structure version */
cnodeid_t ri_cnode; /* cnode of its legal guardian hub */
nasid_t ri_nasid; /* Nasid of same */
char ri_ledcache; /* Last LED bitmap */
char ri_leds; /* Current LED bitmap */
char ri_portmask; /* Active port bitmap */
router_reg_t ri_stat_rev_id; /* Status rev ID value */
net_vec_t ri_vector; /* vector from guardian to router */
int ri_writeid; /* router's vector write ID */
int64_t ri_timebase; /* Time of first sample */
int64_t ri_timestamp; /* Time of last sample */
router_port_info_t ri_port[MAX_ROUTER_PORTS]; /* per port info */
moduleid_t ri_module; /* Which module are we in? */
slotid_t ri_slotnum; /* Which slot are we in? */
router_reg_t ri_glbl_parms[GLBL_PARMS_REGS];
/* Global parms0&1 register contents*/
devfs_handle_t ri_vertex; /* hardware graph vertex */
router_reg_t ri_prot_conf; /* protection config. register */
int64_t ri_per_minute; /* Ticks per minute */
/*
* Everything below here is for kernel use only and may change at
* at any time with or without a change in teh revision number
*
* Any pointers or things that come and go with DEBUG must go at
* the bottom of the structure, below the user stuff.
*/
char ri_hist_type; /* histogram type */
devfs_handle_t ri_guardian; /* guardian node for the router */
int64_t ri_last_print; /* When did we last print */
char ri_print; /* Should we print */
char ri_just_blink; /* Should we blink the LEDs */
#ifdef DEBUG
int64_t ri_deltatime; /* Time it took to sample */
#endif
lock_t ri_lock; /* Lock for access to router info */
net_vec_t *ri_vecarray; /* Pointer to array of vectors */
struct lboard_s *ri_brd; /* Pointer to board structure */
char * ri_name; /* This board's hwg path */
unsigned char ri_port_maint[MAX_ROUTER_PORTS]; /* should we send a
message to availmon */
} router_info_t;
/* Router info location specifiers */
#define RIP_PROMLOG 2 /* Router info in promlog */
#define RIP_CONSOLE 4 /* Router info on console */
#define ROUTER_INFO_PRINT(_rip,_where) (_rip->ri_print |= _where)
/* Set the field used to check if a
* router info can be printed
*/
#define IS_ROUTER_INFO_PRINTED(_rip,_where) \
(_rip->ri_print & _where)
/* Was the router info printed to
* the given location (_where) ?
* Mainly used to prevent duplicate
* router error states.
*/
#define ROUTER_INFO_LOCK(_rip,_s) _s = mutex_spinlock(&(_rip->ri_lock))
/* Take the lock on router info
* to gain exclusive access
*/
#define ROUTER_INFO_UNLOCK(_rip,_s) mutex_spinunlock(&(_rip->ri_lock),_s)
/* Release the lock on router info */
/*
* Router info hanging in the nodepda
*/
typedef struct nodepda_router_info_s {
devfs_handle_t router_vhdl; /* vertex handle of the router */
short router_port; /* port thru which we entered */
short router_portmask;
moduleid_t router_module; /* module in which router is there */
slotid_t router_slot; /* router slot */
unsigned char router_type; /* kind of router */
net_vec_t router_vector; /* vector from the guardian node */
router_info_t *router_infop; /* info hanging off the hwg vertex */
struct nodepda_router_info_s *router_next;
/* pointer to next element */
} nodepda_router_info_t;
#define ROUTER_NAME_SIZE 20 /* Max size of a router name */
#define NORMAL_ROUTER_NAME "normal_router"
#define NULL_ROUTER_NAME "null_router"
#define META_ROUTER_NAME "meta_router"
#define UNKNOWN_ROUTER_NAME "unknown_router"
/* The following definitions are needed by the router traversing
* code either using the hardware graph or using vector operations.
*/
/* Structure of the router queue element */
typedef struct router_elt_s {
union {
/* queue element structure during router probing */
struct {
/* number-in-a-can (unique) for the router */
nic_t nic;
/* vector route from the master hub to
* this router.
*/
net_vec_t vec;
/* port status */
uint64_t status;
char port_status[MAX_ROUTER_PORTS + 1];
} r_elt;
/* queue element structure during router guardian
* assignment
*/
struct {
/* vertex handle for the router */
devfs_handle_t vhdl;
/* guardian for this router */
devfs_handle_t guard;
/* vector router from the guardian to the router */
net_vec_t vec;
} k_elt;
} u;
/* easy to use port status interpretation */
} router_elt_t;
/* structure of the router queue */
typedef struct router_queue_s {
char head; /* Point where a queue element is inserted */
char tail; /* Point where a queue element is removed */
int type;
router_elt_t array[MAX_RTR_BREADTH];
/* Entries for queue elements */
} router_queue_t;
#endif /* _LANGUAGE_C || _LANGUAGE_C_PLUS_PLUS */
/*
* RR_HISTOGRAM(_L) mask and shift definitions
* There are two 64 bit histogram registers, so the following macros take
* into account dealing with an array of 4 32 bit values indexed by _x
*/
#define RHIST_BUCKET_SHFT(_x) (32 * ((_x) & 0x1))
#define RHIST_BUCKET_MASK(_x) (UINT64_CAST 0xffffffff << RHIST_BUCKET_SHFT((_x) & 0x1))
#define RHIST_GET_BUCKET(_x, _reg) \
((RHIST_BUCKET_MASK(_x) & ((_reg)[(_x) >> 1])) >> RHIST_BUCKET_SHFT(_x))
/*
* RR_RESET_MASK(_L) mask and shift definitions
*/
#define RRM_RESETOK(_L) (UINT64_CAST 1 << ((_L) - 1))
#define RRM_RESETOK_ALL (UINT64_CAST 0x3f)
/*
* RR_META_TABLE(_x) and RR_LOCAL_TABLE(_x) mask and shift definitions
*/
#define RTABLE_SHFT(_L) (4 * ((_L) - 1))
#define RTABLE_MASK(_L) (UINT64_CAST 0x7 << RTABLE_SHFT(_L))
#define ROUTERINFO_STKSZ 4096
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
#if defined(_LANGUAGE_C_PLUS_PLUS)
extern "C" {
#endif
int router_reg_read(router_info_t *rip, int regno, router_reg_t *val);
int router_reg_write(router_info_t *rip, int regno, router_reg_t val);
int router_get_info(devfs_handle_t routerv, router_info_t *, int);
int router_init(cnodeid_t cnode,int writeid, nodepda_router_info_t *npda_rip);
int router_set_leds(router_info_t *rip);
void router_print_state(router_info_t *rip, int level,
void (*pf)(int, char *, ...),int print_where);
void capture_router_stats(router_info_t *rip);
int probe_routers(void);
void get_routername(unsigned char brd_type,char *rtrname);
void router_guardians_set(devfs_handle_t hwgraph_root);
int router_hist_reselect(router_info_t *, int64_t);
#if defined(_LANGUAGE_C_PLUS_PLUS)
}
#endif
#endif /* _LANGUAGE_C || _LANGUAGE_C_PLUS_PLUS */
#endif /* _ASM_SN_SN1_ROUTER_H */
|