summaryrefslogtreecommitdiff
path: root/drivers/net/npe/IxQMgrInit.c
blob: 14687e61afb9692404fa4a679b3c39ba6183c1bf (plain)
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
/**
 * @file    IxQMgrInit.c
 *
 * @author Intel Corporation
 * @date    30-Oct-2001
 *
 * @brief:  Provided initialization of the QMgr component and its subcomponents.
 *
 * 
 * @par
 * IXP400 SW Release version 2.0
 * 
 * -- Copyright Notice --
 * 
 * @par
 * Copyright 2001-2005, Intel Corporation.
 * All rights reserved.
 * 
 * @par
 * SPDX-License-Identifier:	BSD-3-Clause
 * @par
 * -- End of Copyright Notice --
*/

/*
 * System defined include files.
 */

/*
 * User defined include files.
 */
#include "IxOsal.h"
#include "IxQMgr.h"
#include "IxQMgrQCfg_p.h"
#include "IxQMgrDispatcher_p.h"
#include "IxQMgrLog_p.h"
#include "IxQMgrQAccess_p.h"
#include "IxQMgrDefines_p.h"
#include "IxQMgrAqmIf_p.h"

/*
 * Set to true if initialized
 * N.B. global so integration/unit tests can reinitialize
 */
BOOL qMgrIsInitialized = false;

/*
 * Function definitions.
 */
IX_STATUS
ixQMgrInit (void)
{
    if (qMgrIsInitialized)
    {
	IX_QMGR_LOG0("ixQMgrInit: IxQMgr already initialised\n");
	return IX_FAIL;
    }

    /* Initialise the QCfg component */
    ixQMgrQCfgInit ();

    /* Initialise the Dispatcher component */
    ixQMgrDispatcherInit ();

    /* Initialise the Access component */
    ixQMgrQAccessInit ();

    /* Initialization complete */
    qMgrIsInitialized = true;

    return IX_SUCCESS;
}

IX_STATUS
ixQMgrUnload (void)
{
    if (!qMgrIsInitialized)
    {
	return IX_FAIL;
    }

    /* Uninitialise the QCfg component */
    ixQMgrQCfgUninit ();

    /* Uninitialization complete */
    qMgrIsInitialized = false;

    return IX_SUCCESS;
}

void
ixQMgrShow (void)
{
    IxQMgrQCfgStats *qCfgStats = NULL;
    IxQMgrDispatcherStats *dispatcherStats = NULL;
    int i;
    UINT32 lowIntRegRead, upIntRegRead;

    qCfgStats = ixQMgrQCfgStatsGet ();
    dispatcherStats = ixQMgrDispatcherStatsGet ();
    ixQMgrAqmIfQInterruptRegRead (IX_QMGR_QUELOW_GROUP, &lowIntRegRead);
    ixQMgrAqmIfQInterruptRegRead (IX_QMGR_QUEUPP_GROUP, &upIntRegRead);
    printf("Generic Stats........\n");
    printf("=====================\n");
    printf("Loop Run Count..........%u\n",dispatcherStats->loopRunCnt);
    printf("Watermark set count.....%d\n", qCfgStats->wmSetCnt);
    printf("===========================================\n");
    printf("On the fly Interrupt Register Stats........\n");
    printf("===========================================\n");
    printf("Lower Interrupt Register............0x%08x\n",lowIntRegRead);
    printf("Upper Interrupt Register............0x%08x\n",upIntRegRead);
    printf("==============================================\n");
    printf("Queue Specific Stats........\n");
    printf("============================\n");

    for (i=0; i<IX_QMGR_MAX_NUM_QUEUES; i++)
    {
	if (ixQMgrQIsConfigured(i))
	{
	    ixQMgrQShow(i);
	}
    }

    printf("============================\n");
}

IX_STATUS
ixQMgrQShow (IxQMgrQId qId)
{
    IxQMgrQCfgStats *qCfgStats = NULL;
    IxQMgrDispatcherStats *dispatcherStats = NULL; 

    if (!ixQMgrQIsConfigured(qId))
    {
	return IX_QMGR_Q_NOT_CONFIGURED;
    }
    
    dispatcherStats = ixQMgrDispatcherStatsGet ();
    qCfgStats = ixQMgrQCfgQStatsGet (qId);

    printf("QId %d\n", qId);
    printf("======\n");
    printf("  IxQMgrQCfg Stats\n");
    printf("    Name..................... \"%s\"\n", qCfgStats->qStats[qId].qName);
    printf("    Size in words............ %u\n", qCfgStats->qStats[qId].qSizeInWords);
    printf("    Entry size in words...... %u\n", qCfgStats->qStats[qId].qEntrySizeInWords);
    printf("    Nearly empty watermark... %u\n", qCfgStats->qStats[qId].ne);
    printf("    Nearly full watermark.... %u\n", qCfgStats->qStats[qId].nf);
    printf("    Number of full entries... %u\n", qCfgStats->qStats[qId].numEntries);
    printf("    Sram base address........ 0x%X\n", qCfgStats->qStats[qId].baseAddress);
    printf("    Read pointer............. 0x%X\n", qCfgStats->qStats[qId].readPtr);
    printf("    Write pointer............ 0x%X\n", qCfgStats->qStats[qId].writePtr);

#ifndef NDEBUG
    if (dispatcherStats->queueStats[qId].notificationEnabled)
    {
        char *localEvent = "none ????";
        switch (dispatcherStats->queueStats[qId].srcSel)
        {
            case IX_QMGR_Q_SOURCE_ID_E:
                localEvent = "Empty";
                break;
            case IX_QMGR_Q_SOURCE_ID_NE:
                localEvent = "Nearly Empty";
                break;
            case IX_QMGR_Q_SOURCE_ID_NF:
                localEvent = "Nearly Full";
                break;
            case IX_QMGR_Q_SOURCE_ID_F:
                localEvent = "Full";
                break;
            case IX_QMGR_Q_SOURCE_ID_NOT_E:
                localEvent = "Not Empty";
                break;
            case IX_QMGR_Q_SOURCE_ID_NOT_NE:
                localEvent = "Not Nearly Empty";
                break;
            case IX_QMGR_Q_SOURCE_ID_NOT_NF:
                localEvent = "Not Nearly Full";
                break;
            case IX_QMGR_Q_SOURCE_ID_NOT_F:
                localEvent = "Not Full";
                break;
            default :
                break;
        }
        printf("    Notifications localEvent...... %s\n", localEvent);
    }
    else
    {
        printf("    Notifications............ not enabled\n");
    }
    printf("  IxQMgrDispatcher Stats\n");
    printf("    Callback count................%d\n",
	  dispatcherStats->queueStats[qId].callbackCnt);
    printf("    Priority change count.........%d\n",
	  dispatcherStats->queueStats[qId].priorityChangeCnt);
    printf("    Interrupt no callback count...%d\n",
	  dispatcherStats->queueStats[qId].intNoCallbackCnt);
    printf("    Interrupt lost callback count...%d\n",
	  dispatcherStats->queueStats[qId].intLostCallbackCnt);
#endif

    return IX_SUCCESS;
}