Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_rxintr_utils.vr | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | #include <vera_defines.vrh> | |
36 | #include "niu_rx_descp.vrh" | |
37 | #include "niu_int_dev.vrh" | |
38 | #include "niu_int_mgr.vrh" | |
39 | ||
40 | extern Mesg be_msg; | |
41 | extern niu_gen_pio gen_pio_drv; | |
42 | extern CNiuIntrMgr NiuIntrMgr; | |
43 | ||
44 | class CNiuIntrDevRxDMAm extends RxDMAChannel { | |
45 | event isr_done; | |
46 | ||
47 | task new(integer i, integer dev_id) { | |
48 | super.new(i,"RXDMA",dev_id); | |
49 | trigger(OFF, isr_done); | |
50 | } | |
51 | function integer isr( ( bit[1:0] ldf_flags = 0) ) { | |
52 | bit[63:0] rd_data, rd_mask, wr_data; | |
53 | integer ii; | |
54 | string s; | |
55 | bit fatal=0; | |
56 | rxdma_ctl_stat_reg ctlstat_reg; | |
57 | SetPendingFlag(); | |
58 | ||
59 | ctlstat_reg = new(); | |
60 | ||
61 | printf("rxISR Start id=%0d LDF Flags=0x%0h time=%0d\n", dev_id, ldf_flags, get_time(LO)); | |
62 | gen_pio_drv.pio_rd(RX_DMA_CTL_STAT_START+(RXDMA_STEP*dev_id), rd_data); | |
63 | gen_pio_drv.pio_rd(RX_DMA_ENT_MSK_START+(RXDMA_STEP*dev_id), rd_mask); | |
64 | printf("rxISR id=%0d stat[53:32]=0x%h mask=0x%h\n", dev_id, rd_data[53:32], rd_mask[21:0]); | |
65 | for(ii=0; ii<22; ii++) { | |
66 | fatal=0; | |
67 | if(rd_data[ii+32]==1 && rd_mask[ii]==0) { | |
68 | case(ii) { | |
69 | 0: {s="CFIG_LOGPAGE"; fatal=1;} | |
70 | 1: {s="RBR_LOGPAGE"; fatal=1;} | |
71 | 2: {s="RBR_FULL"; fatal=1;} | |
72 | 3: s="RBR_EMPTY"; | |
73 | 4: {s="RCR_FULL"; fatal=1;} | |
74 | 5: {s="RCR_INCON"; fatal=1;} | |
75 | 6: {s="CONFIG_ERR"; fatal=1;} | |
76 | 7: s="RCR_SHADOW_FULL"; | |
77 | 8: s="RBR_PRE_EMTY"; | |
78 | 9: s="WRED_DROP"; | |
79 | 10: s="PORT_DROP_PKT"; | |
80 | 11: {s="RBR_PRE_PAR"; fatal=1;} | |
81 | 12: {s="RBR_SHA_PAR"; fatal=1;} | |
82 | 13: s="RCR_TO"; | |
83 | 14: s="RCR_THRES"; | |
84 | 15: s="MEX"; | |
85 | 16: s="DC_FIFO_ERR"; | |
86 | 17: {s="RCR_ACK_ERR"; fatal=1;} | |
87 | 18: {s="RSP_DAT_ERR"; fatal=1;} | |
88 | 19: {s="BYTE_EN_BUS"; fatal=1;} | |
89 | 20: {s="RSP_CNT_ERR"; fatal=1;} | |
90 | 21: {s="RBR_TMOUT"; fatal=1;} | |
91 | } | |
92 | printf("rxISR id=%0d int active=%0d %s %s\n", dev_id, ii, s, fatal?"FATAL":""); | |
93 | if(s=="RCR_THRES" || s=="RCR_TO") | |
94 | CheckCR_Entries(); | |
95 | if(fatal) { | |
96 | resetRxDmaCh(dev_id); | |
97 | } | |
98 | else { | |
99 | ||
100 | // Step 1: Clear the status bit of whichever event has occured | |
101 | if (s=="RCR_THRES") { | |
102 | ctlstat_reg.status_RCRTHRES = 1; | |
103 | printf("rxISR id=%0d clear RX_DMA_CTL_STAT_RCRTHRES interrupt time=%0d\n", dev_id, get_time(LO)); | |
104 | } | |
105 | else if (s=="RCR_TO") { | |
106 | ctlstat_reg.status_RCRTO = 1; | |
107 | printf("rxISR id=%0d clear RX_DMA_CTL_STAT_RCRTO interrupt time=%0d\n", dev_id, get_time(LO)); | |
108 | } | |
109 | else if (s=="PORT_DROP_PKT") { | |
110 | ctlstat_reg.status_PORT_DROP_PKT = 1; | |
111 | printf("rxISR id=%0d clear RX_DMA_CTL_STAT_RCRTO interrupt time=%0d\n", dev_id, get_time(LO)); | |
112 | } | |
113 | else if (s=="WRED_DROP") { | |
114 | ctlstat_reg.status_WRED_DROP = 1; | |
115 | printf("rxISR id=%0d clear RX_DMA_CTL_STAT_RCRTO interrupt time=%0d\n", dev_id, get_time(LO)); | |
116 | } | |
117 | ||
118 | rxdma_ctl_stat_update(1 /* mode */, ctlstat_reg); | |
119 | ||
120 | // Step 2: Re-enable the MEX bit so hardware can interrupt us again | |
121 | ctlstat_reg = new(); | |
122 | ctlstat_reg.MEX_bit = 1; | |
123 | rxdma_ctl_stat_update(0 /* mode */, ctlstat_reg); | |
124 | printf("rxISR id=%0d Enable MEX bit for next interrupt time=%0d\n", dev_id, get_time(LO)); | |
125 | ||
126 | } | |
127 | } | |
128 | } | |
129 | ClrPendingFlag(); | |
130 | } | |
131 | task resetRxDmaCh(integer dma_num) { | |
132 | setRxDmaCfig_1(64'h0000_0000_4000_0000,1'b0); //Bit30 DMA_RST | |
133 | repeat(100) @(posedge CLOCK); | |
134 | } | |
135 | } |