4 * @author Intel Corporation
7 * @brief This file contains the implementation of the private API for the
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.
35 #include "IxNpeMhMacros_p.h"
37 #include "IxNpeMhConfig_p.h"
38 #include "IxNpeMhSend_p.h"
39 #include "IxNpeMhSolicitedCbMgr_p.h"
42 * #defines and macros used in this file.
46 * @def IX_NPEMH_INFIFO_RETRY_DELAY_US
48 * @brief Amount of time (uSecs) to delay between retries
49 * while inFIFO is Full when attempting to send a message
51 #define IX_NPEMH_INFIFO_RETRY_DELAY_US (1)
55 * Typedefs whose scope is limited to this file.
59 * @struct IxNpeMhSendStats
61 * @brief This structure is used to maintain statistics for the Send
67 UINT32 sends; /**< send invocations */
68 UINT32 sendWithResponses; /**< send with response invocations */
69 UINT32 queueFulls; /**< fifo queue full occurrences */
70 UINT32 queueFullRetries; /**< fifo queue full retry occurrences */
71 UINT32 maxQueueFullRetries; /**< max fifo queue full retries */
72 UINT32 callbackFulls; /**< callback list full occurrences */
76 * Variable declarations global to this file only. Externs are followed by
80 PRIVATE IxNpeMhSendStats ixNpeMhSendStats[IX_NPEMH_NUM_NPES];
83 * Extern function prototypes.
87 * Static function prototypes.
90 BOOL ixNpeMhSendInFifoIsFull(
92 UINT32 maxSendRetries);
95 * Function definition: ixNpeMhSendInFifoIsFull
99 BOOL ixNpeMhSendInFifoIsFull(
101 UINT32 maxSendRetries)
104 UINT32 numRetries = 0;
106 /* check the NPE's inFIFO */
107 isFull = ixNpeMhConfigInFifoIsFull (npeId);
109 /* we retry a few times, just to give the NPE a chance to read from */
110 /* the FIFO if the FIFO is currently full */
111 while (isFull && (numRetries++ < maxSendRetries))
113 if (numRetries >= IX_NPEMH_SEND_RETRIES_DEFAULT)
115 /* Delay here for as short a time as possible (1 us). */
116 /* Adding a delay here should ensure we are not hogging */
117 /* the AHB bus while we are retrying */
118 ixOsalBusySleep (IX_NPEMH_INFIFO_RETRY_DELAY_US);
121 /* re-check the NPE's inFIFO */
122 isFull = ixNpeMhConfigInFifoIsFull (npeId);
124 /* update statistical info */
125 ixNpeMhSendStats[npeId].queueFullRetries++;
128 /* record the highest number of retries that occurred */
129 if (ixNpeMhSendStats[npeId].maxQueueFullRetries < numRetries)
131 ixNpeMhSendStats[npeId].maxQueueFullRetries = numRetries;
136 /* update statistical info */
137 ixNpeMhSendStats[npeId].queueFulls++;
144 * Function definition: ixNpeMhSendMessageSend
147 IX_STATUS ixNpeMhSendMessageSend (
149 IxNpeMhMessage message,
150 UINT32 maxSendRetries)
154 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
155 "ixNpeMhSendMessageSend\n");
157 /* update statistical info */
158 ixNpeMhSendStats[npeId].sends++;
160 /* check if the NPE's inFIFO is full - if so return an error */
161 if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
163 IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
167 /* write the message to the NPE's inFIFO */
168 status = ixNpeMhConfigInFifoWrite (npeId, message);
170 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
171 "ixNpeMhSendMessageSend\n");
177 * Function definition: ixNpeMhSendMessageWithResponseSend
180 IX_STATUS ixNpeMhSendMessageWithResponseSend (
182 IxNpeMhMessage message,
183 IxNpeMhMessageId solicitedMessageId,
184 IxNpeMhCallback solicitedCallback,
185 UINT32 maxSendRetries)
187 IX_STATUS status = IX_SUCCESS;
189 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
190 "ixNpeMhSendMessageWithResponseSend\n");
192 /* update statistical info */
193 ixNpeMhSendStats[npeId].sendWithResponses++;
195 /* sr: this sleep will call the receive routine (no interrupts used!!!) */
196 ixOsalSleep (IX_NPEMH_INFIFO_RETRY_DELAY_US);
198 /* check if the NPE's inFIFO is full - if so return an error */
199 if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
201 IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
205 /* save the solicited callback */
206 status = ixNpeMhSolicitedCbMgrCallbackSave (
207 npeId, solicitedMessageId, solicitedCallback);
208 if (status != IX_SUCCESS)
210 IX_NPEMH_ERROR_REPORT ("Failed to save solicited callback\n");
212 /* update statistical info */
213 ixNpeMhSendStats[npeId].callbackFulls++;
218 /* write the message to the NPE's inFIFO */
219 status = ixNpeMhConfigInFifoWrite (npeId, message);
221 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
222 "ixNpeMhSendMessageWithResponseSend\n");
228 * Function definition: ixNpeMhSendShow
231 void ixNpeMhSendShow (
234 /* show the message send invocation counter */
235 IX_NPEMH_SHOW ("Send invocations",
236 ixNpeMhSendStats[npeId].sends);
238 /* show the message send with response invocation counter */
239 IX_NPEMH_SHOW ("Send with response invocations",
240 ixNpeMhSendStats[npeId].sendWithResponses);
242 /* show the fifo queue full occurrence counter */
243 IX_NPEMH_SHOW ("Fifo queue full occurrences",
244 ixNpeMhSendStats[npeId].queueFulls);
246 /* show the fifo queue full retry occurrence counter */
247 IX_NPEMH_SHOW ("Fifo queue full retry occurrences",
248 ixNpeMhSendStats[npeId].queueFullRetries);
250 /* show the fifo queue full maximum retries counter */
251 IX_NPEMH_SHOW ("Maximum fifo queue full retries",
252 ixNpeMhSendStats[npeId].maxQueueFullRetries);
254 /* show the callback list full occurrence counter */
255 IX_NPEMH_SHOW ("Solicited callback list full occurrences",
256 ixNpeMhSendStats[npeId].callbackFulls);
260 * Function definition: ixNpeMhSendShowReset
263 void ixNpeMhSendShowReset (
266 /* reset the message send invocation counter */
267 ixNpeMhSendStats[npeId].sends = 0;
269 /* reset the message send with response invocation counter */
270 ixNpeMhSendStats[npeId].sendWithResponses = 0;
272 /* reset the fifo queue full occurrence counter */
273 ixNpeMhSendStats[npeId].queueFulls = 0;
275 /* reset the fifo queue full retry occurrence counter */
276 ixNpeMhSendStats[npeId].queueFullRetries = 0;
278 /* reset the max fifo queue full retries counter */
279 ixNpeMhSendStats[npeId].maxQueueFullRetries = 0;
281 /* reset the callback list full occurrence counter */
282 ixNpeMhSendStats[npeId].callbackFulls = 0;