2 * @file IxNpeMhUnsolicitedCbMgr.c
4 * @author Intel Corporation
7 * @brief This file contains the implementation of the private API for
8 * the Unsolicited Callback Manager module.
12 * IXP400 SW Release version 2.0
14 * -- Copyright Notice --
17 * Copyright 2001-2005, Intel Corporation.
18 * All rights reserved.
21 * SPDX-License-Identifier: BSD-3-Clause
23 * -- End of Copyright Notice --
27 * Put the system defined include files required.
32 * Put the user defined include files required.
36 #include "IxNpeMhMacros_p.h"
38 #include "IxNpeMhUnsolicitedCbMgr_p.h"
42 * #defines and macros used in this file.
46 * Typedefs whose scope is limited to this file.
50 * @struct IxNpeMhUnsolicitedCallbackTable
52 * @brief This structure is used to maintain the list of registered
53 * callbacks. One entry exists for each message ID, and a NULL entry will
54 * signify that no callback has been registered for that ID.
59 /** array of entries */
60 IxNpeMhCallback entries[IX_NPEMH_MAX_MESSAGE_ID + 1];
61 } IxNpeMhUnsolicitedCallbackTable;
64 * @struct IxNpeMhUnsolicitedCbMgrStats
66 * @brief This structure is used to maintain statistics for the Unsolicited
67 * Callback Manager module.
72 UINT32 saves; /**< callback table saves */
73 UINT32 overwrites; /**< callback table overwrites */
74 } IxNpeMhUnsolicitedCbMgrStats;
77 * Variable declarations global to this file only. Externs are followed by
81 PRIVATE IxNpeMhUnsolicitedCallbackTable
82 ixNpeMhUnsolicitedCallbackTables[IX_NPEMH_NUM_NPES];
84 PRIVATE IxNpeMhUnsolicitedCbMgrStats
85 ixNpeMhUnsolicitedCbMgrStats[IX_NPEMH_NUM_NPES];
88 * Extern function prototypes.
92 * Static function prototypes.
96 * Function definition: ixNpeMhUnsolicitedCbMgrInitialize
99 void ixNpeMhUnsolicitedCbMgrInitialize (void)
101 IxNpeMhNpeId npeId = 0;
102 IxNpeMhUnsolicitedCallbackTable *table = NULL;
103 IxNpeMhMessageId messageId = 0;
105 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
106 "ixNpeMhUnsolicitedCbMgrInitialize\n");
108 /* for each NPE ... */
109 for (npeId = 0; npeId < IX_NPEMH_NUM_NPES; npeId++)
111 /* initialise a pointer to the table for convenience */
112 table = &ixNpeMhUnsolicitedCallbackTables[npeId];
114 /* for each message ID ... */
115 for (messageId = IX_NPEMH_MIN_MESSAGE_ID;
116 messageId <= IX_NPEMH_MAX_MESSAGE_ID; messageId++)
118 /* initialise the callback for this message ID to NULL */
119 table->entries[messageId] = NULL;
123 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
124 "ixNpeMhUnsolicitedCbMgrInitialize\n");
128 * Function definition: ixNpeMhUnsolicitedCbMgrCallbackSave
131 void ixNpeMhUnsolicitedCbMgrCallbackSave (
133 IxNpeMhMessageId unsolicitedMessageId,
134 IxNpeMhCallback unsolicitedCallback)
136 IxNpeMhUnsolicitedCallbackTable *table = NULL;
138 /* initialise a pointer to the table for convenience */
139 table = &ixNpeMhUnsolicitedCallbackTables[npeId];
141 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
142 "ixNpeMhUnsolicitedCbMgrCallbackSave\n");
144 /* update statistical info */
145 ixNpeMhUnsolicitedCbMgrStats[npeId].saves++;
147 /* check if there is a callback already registered for this NPE and */
149 if (table->entries[unsolicitedMessageId] != NULL)
151 /* if we are overwriting an existing callback */
152 if (unsolicitedCallback != NULL)
154 IX_NPEMH_TRACE2 (IX_NPEMH_DEBUG, "Unsolicited callback "
155 "overwriting existing callback for NPE ID %d "
156 "message ID 0x%02X\n", npeId, unsolicitedMessageId);
158 else /* if we are clearing an existing callback */
160 IX_NPEMH_TRACE2 (IX_NPEMH_DEBUG, "NULL unsolicited callback "
161 "clearing existing callback for NPE ID %d "
162 "message ID 0x%02X\n", npeId, unsolicitedMessageId);
165 /* update statistical info */
166 ixNpeMhUnsolicitedCbMgrStats[npeId].overwrites++;
169 /* save the callback into the table */
170 table->entries[unsolicitedMessageId] = unsolicitedCallback;
172 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
173 "ixNpeMhUnsolicitedCbMgrCallbackSave\n");
177 * Function definition: ixNpeMhUnsolicitedCbMgrCallbackRetrieve
180 void ixNpeMhUnsolicitedCbMgrCallbackRetrieve (
182 IxNpeMhMessageId unsolicitedMessageId,
183 IxNpeMhCallback *unsolicitedCallback)
185 IxNpeMhUnsolicitedCallbackTable *table = NULL;
187 /* initialise a pointer to the table for convenience */
188 table = &ixNpeMhUnsolicitedCallbackTables[npeId];
190 /* retrieve the callback from the table */
191 *unsolicitedCallback = table->entries[unsolicitedMessageId];
195 * Function definition: ixNpeMhUnsolicitedCbMgrShow
198 void ixNpeMhUnsolicitedCbMgrShow (
201 /* show the unsolicited callback table save counter */
202 IX_NPEMH_SHOW ("Unsolicited callback table saves",
203 ixNpeMhUnsolicitedCbMgrStats[npeId].saves);
205 /* show the unsolicited callback table overwrite counter */
206 IX_NPEMH_SHOW ("Unsolicited callback table overwrites",
207 ixNpeMhUnsolicitedCbMgrStats[npeId].overwrites);
211 * Function definition: ixNpeMhUnsolicitedCbMgrShowReset
214 void ixNpeMhUnsolicitedCbMgrShowReset (
217 /* reset the unsolicited callback table save counter */
218 ixNpeMhUnsolicitedCbMgrStats[npeId].saves = 0;
220 /* reset the unsolicited callback table overwrite counter */
221 ixNpeMhUnsolicitedCbMgrStats[npeId].overwrites = 0;