]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/net/npe/IxQMgrInit.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / drivers / net / npe / IxQMgrInit.c
1 /**
2  * @file    IxQMgrInit.c
3  *
4  * @author Intel Corporation
5  * @date    30-Oct-2001
6  *
7  * @brief:  Provided initialization of the QMgr component and its subcomponents.
8  *
9  * 
10  * @par
11  * IXP400 SW Release version 2.0
12  * 
13  * -- Copyright Notice --
14  * 
15  * @par
16  * Copyright 2001-2005, Intel Corporation.
17  * All rights reserved.
18  * 
19  * @par
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  * 1. Redistributions of source code must retain the above copyright
24  *    notice, this list of conditions and the following disclaimer.
25  * 2. Redistributions in binary form must reproduce the above copyright
26  *    notice, this list of conditions and the following disclaimer in the
27  *    documentation and/or other materials provided with the distribution.
28  * 3. Neither the name of the Intel Corporation nor the names of its contributors
29  *    may be used to endorse or promote products derived from this software
30  *    without specific prior written permission.
31  * 
32  * @par
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
34  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
37  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43  * SUCH DAMAGE.
44  * 
45  * @par
46  * -- End of Copyright Notice --
47 */
48
49 /*
50  * System defined include files.
51  */
52
53 /*
54  * User defined include files.
55  */
56 #include "IxOsal.h"
57 #include "IxQMgr.h"
58 #include "IxQMgrQCfg_p.h"
59 #include "IxQMgrDispatcher_p.h"
60 #include "IxQMgrLog_p.h"
61 #include "IxQMgrQAccess_p.h"
62 #include "IxQMgrDefines_p.h"
63 #include "IxQMgrAqmIf_p.h"
64
65 /*
66  * Set to true if initialized
67  * N.B. global so integration/unit tests can reinitialize
68  */
69 BOOL qMgrIsInitialized = false;
70
71 /*
72  * Function definitions.
73  */
74 IX_STATUS
75 ixQMgrInit (void)
76 {
77     if (qMgrIsInitialized)
78     {
79         IX_QMGR_LOG0("ixQMgrInit: IxQMgr already initialised\n");
80         return IX_FAIL;
81     }
82
83     /* Initialise the QCfg component */
84     ixQMgrQCfgInit ();
85
86     /* Initialise the Dispatcher component */
87     ixQMgrDispatcherInit ();
88
89     /* Initialise the Access component */
90     ixQMgrQAccessInit ();
91
92     /* Initialization complete */
93     qMgrIsInitialized = true;
94
95     return IX_SUCCESS;
96 }
97
98 IX_STATUS
99 ixQMgrUnload (void)
100 {
101     if (!qMgrIsInitialized)
102     {
103         return IX_FAIL;
104     }
105
106     /* Uninitialise the QCfg component */
107     ixQMgrQCfgUninit ();
108
109     /* Uninitialization complete */
110     qMgrIsInitialized = false;
111
112     return IX_SUCCESS;
113 }
114
115 void
116 ixQMgrShow (void)
117 {
118     IxQMgrQCfgStats *qCfgStats = NULL;
119     IxQMgrDispatcherStats *dispatcherStats = NULL;
120     int i;
121     UINT32 lowIntRegRead, upIntRegRead;
122
123     qCfgStats = ixQMgrQCfgStatsGet ();
124     dispatcherStats = ixQMgrDispatcherStatsGet ();
125     ixQMgrAqmIfQInterruptRegRead (IX_QMGR_QUELOW_GROUP, &lowIntRegRead);
126     ixQMgrAqmIfQInterruptRegRead (IX_QMGR_QUEUPP_GROUP, &upIntRegRead);
127     printf("Generic Stats........\n");
128     printf("=====================\n");
129     printf("Loop Run Count..........%u\n",dispatcherStats->loopRunCnt);
130     printf("Watermark set count.....%d\n", qCfgStats->wmSetCnt);
131     printf("===========================================\n");
132     printf("On the fly Interrupt Register Stats........\n");
133     printf("===========================================\n");
134     printf("Lower Interrupt Register............0x%08x\n",lowIntRegRead);
135     printf("Upper Interrupt Register............0x%08x\n",upIntRegRead);
136     printf("==============================================\n");
137     printf("Queue Specific Stats........\n");
138     printf("============================\n");
139
140     for (i=0; i<IX_QMGR_MAX_NUM_QUEUES; i++)
141     {
142         if (ixQMgrQIsConfigured(i))
143         {
144             ixQMgrQShow(i);
145         }
146     }
147
148     printf("============================\n");
149 }
150
151 IX_STATUS
152 ixQMgrQShow (IxQMgrQId qId)
153 {
154     IxQMgrQCfgStats *qCfgStats = NULL;
155     IxQMgrDispatcherStats *dispatcherStats = NULL; 
156
157     if (!ixQMgrQIsConfigured(qId))
158     {
159         return IX_QMGR_Q_NOT_CONFIGURED;
160     }
161     
162     dispatcherStats = ixQMgrDispatcherStatsGet ();
163     qCfgStats = ixQMgrQCfgQStatsGet (qId);
164
165     printf("QId %d\n", qId);
166     printf("======\n");
167     printf("  IxQMgrQCfg Stats\n");
168     printf("    Name..................... \"%s\"\n", qCfgStats->qStats[qId].qName);
169     printf("    Size in words............ %u\n", qCfgStats->qStats[qId].qSizeInWords);
170     printf("    Entry size in words...... %u\n", qCfgStats->qStats[qId].qEntrySizeInWords);
171     printf("    Nearly empty watermark... %u\n", qCfgStats->qStats[qId].ne);
172     printf("    Nearly full watermark.... %u\n", qCfgStats->qStats[qId].nf);
173     printf("    Number of full entries... %u\n", qCfgStats->qStats[qId].numEntries);
174     printf("    Sram base address........ 0x%X\n", qCfgStats->qStats[qId].baseAddress);
175     printf("    Read pointer............. 0x%X\n", qCfgStats->qStats[qId].readPtr);
176     printf("    Write pointer............ 0x%X\n", qCfgStats->qStats[qId].writePtr);
177
178 #ifndef NDEBUG
179     if (dispatcherStats->queueStats[qId].notificationEnabled)
180     {
181         char *localEvent = "none ????";
182         switch (dispatcherStats->queueStats[qId].srcSel)
183         {
184             case IX_QMGR_Q_SOURCE_ID_E:
185                 localEvent = "Empty";
186                 break;
187             case IX_QMGR_Q_SOURCE_ID_NE:
188                 localEvent = "Nearly Empty";
189                 break;
190             case IX_QMGR_Q_SOURCE_ID_NF:
191                 localEvent = "Nearly Full";
192                 break;
193             case IX_QMGR_Q_SOURCE_ID_F:
194                 localEvent = "Full";
195                 break;
196             case IX_QMGR_Q_SOURCE_ID_NOT_E:
197                 localEvent = "Not Empty";
198                 break;
199             case IX_QMGR_Q_SOURCE_ID_NOT_NE:
200                 localEvent = "Not Nearly Empty";
201                 break;
202             case IX_QMGR_Q_SOURCE_ID_NOT_NF:
203                 localEvent = "Not Nearly Full";
204                 break;
205             case IX_QMGR_Q_SOURCE_ID_NOT_F:
206                 localEvent = "Not Full";
207                 break;
208             default :
209                 break;
210         }
211         printf("    Notifications localEvent...... %s\n", localEvent);
212     }
213     else
214     {
215         printf("    Notifications............ not enabled\n");
216     }
217     printf("  IxQMgrDispatcher Stats\n");
218     printf("    Callback count................%d\n",
219           dispatcherStats->queueStats[qId].callbackCnt);
220     printf("    Priority change count.........%d\n",
221           dispatcherStats->queueStats[qId].priorityChangeCnt);
222     printf("    Interrupt no callback count...%d\n",
223           dispatcherStats->queueStats[qId].intNoCallbackCnt);
224     printf("    Interrupt lost callback count...%d\n",
225           dispatcherStats->queueStats[qId].intLostCallbackCnt);
226 #endif
227
228     return IX_SUCCESS;
229 }
230
231
232
233