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 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. Neither the name of the Intel Corporation nor the names of its contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * -- End of Copyright Notice --
51 * Put the system defined include files required.
56 * Put the user defined include files required.
59 #include "IxNpeMhMacros_p.h"
61 #include "IxNpeMhConfig_p.h"
62 #include "IxNpeMhSend_p.h"
63 #include "IxNpeMhSolicitedCbMgr_p.h"
66 * #defines and macros used in this file.
70 * @def IX_NPEMH_INFIFO_RETRY_DELAY_US
72 * @brief Amount of time (uSecs) to delay between retries
73 * while inFIFO is Full when attempting to send a message
75 #define IX_NPEMH_INFIFO_RETRY_DELAY_US (1)
79 * Typedefs whose scope is limited to this file.
83 * @struct IxNpeMhSendStats
85 * @brief This structure is used to maintain statistics for the Send
91 UINT32 sends; /**< send invocations */
92 UINT32 sendWithResponses; /**< send with response invocations */
93 UINT32 queueFulls; /**< fifo queue full occurrences */
94 UINT32 queueFullRetries; /**< fifo queue full retry occurrences */
95 UINT32 maxQueueFullRetries; /**< max fifo queue full retries */
96 UINT32 callbackFulls; /**< callback list full occurrences */
100 * Variable declarations global to this file only. Externs are followed by
104 PRIVATE IxNpeMhSendStats ixNpeMhSendStats[IX_NPEMH_NUM_NPES];
107 * Extern function prototypes.
111 * Static function prototypes.
114 BOOL ixNpeMhSendInFifoIsFull(
116 UINT32 maxSendRetries);
119 * Function definition: ixNpeMhSendInFifoIsFull
123 BOOL ixNpeMhSendInFifoIsFull(
125 UINT32 maxSendRetries)
128 UINT32 numRetries = 0;
130 /* check the NPE's inFIFO */
131 isFull = ixNpeMhConfigInFifoIsFull (npeId);
133 /* we retry a few times, just to give the NPE a chance to read from */
134 /* the FIFO if the FIFO is currently full */
135 while (isFull && (numRetries++ < maxSendRetries))
137 if (numRetries >= IX_NPEMH_SEND_RETRIES_DEFAULT)
139 /* Delay here for as short a time as possible (1 us). */
140 /* Adding a delay here should ensure we are not hogging */
141 /* the AHB bus while we are retrying */
142 ixOsalBusySleep (IX_NPEMH_INFIFO_RETRY_DELAY_US);
145 /* re-check the NPE's inFIFO */
146 isFull = ixNpeMhConfigInFifoIsFull (npeId);
148 /* update statistical info */
149 ixNpeMhSendStats[npeId].queueFullRetries++;
152 /* record the highest number of retries that occurred */
153 if (ixNpeMhSendStats[npeId].maxQueueFullRetries < numRetries)
155 ixNpeMhSendStats[npeId].maxQueueFullRetries = numRetries;
160 /* update statistical info */
161 ixNpeMhSendStats[npeId].queueFulls++;
168 * Function definition: ixNpeMhSendMessageSend
171 IX_STATUS ixNpeMhSendMessageSend (
173 IxNpeMhMessage message,
174 UINT32 maxSendRetries)
178 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
179 "ixNpeMhSendMessageSend\n");
181 /* update statistical info */
182 ixNpeMhSendStats[npeId].sends++;
184 /* check if the NPE's inFIFO is full - if so return an error */
185 if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
187 IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
191 /* write the message to the NPE's inFIFO */
192 status = ixNpeMhConfigInFifoWrite (npeId, message);
194 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
195 "ixNpeMhSendMessageSend\n");
201 * Function definition: ixNpeMhSendMessageWithResponseSend
204 IX_STATUS ixNpeMhSendMessageWithResponseSend (
206 IxNpeMhMessage message,
207 IxNpeMhMessageId solicitedMessageId,
208 IxNpeMhCallback solicitedCallback,
209 UINT32 maxSendRetries)
211 IX_STATUS status = IX_SUCCESS;
213 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
214 "ixNpeMhSendMessageWithResponseSend\n");
216 /* update statistical info */
217 ixNpeMhSendStats[npeId].sendWithResponses++;
219 /* sr: this sleep will call the receive routine (no interrupts used!!!) */
220 ixOsalSleep (IX_NPEMH_INFIFO_RETRY_DELAY_US);
222 /* check if the NPE's inFIFO is full - if so return an error */
223 if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
225 IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
229 /* save the solicited callback */
230 status = ixNpeMhSolicitedCbMgrCallbackSave (
231 npeId, solicitedMessageId, solicitedCallback);
232 if (status != IX_SUCCESS)
234 IX_NPEMH_ERROR_REPORT ("Failed to save solicited callback\n");
236 /* update statistical info */
237 ixNpeMhSendStats[npeId].callbackFulls++;
242 /* write the message to the NPE's inFIFO */
243 status = ixNpeMhConfigInFifoWrite (npeId, message);
245 IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
246 "ixNpeMhSendMessageWithResponseSend\n");
252 * Function definition: ixNpeMhSendShow
255 void ixNpeMhSendShow (
258 /* show the message send invocation counter */
259 IX_NPEMH_SHOW ("Send invocations",
260 ixNpeMhSendStats[npeId].sends);
262 /* show the message send with response invocation counter */
263 IX_NPEMH_SHOW ("Send with response invocations",
264 ixNpeMhSendStats[npeId].sendWithResponses);
266 /* show the fifo queue full occurrence counter */
267 IX_NPEMH_SHOW ("Fifo queue full occurrences",
268 ixNpeMhSendStats[npeId].queueFulls);
270 /* show the fifo queue full retry occurrence counter */
271 IX_NPEMH_SHOW ("Fifo queue full retry occurrences",
272 ixNpeMhSendStats[npeId].queueFullRetries);
274 /* show the fifo queue full maximum retries counter */
275 IX_NPEMH_SHOW ("Maximum fifo queue full retries",
276 ixNpeMhSendStats[npeId].maxQueueFullRetries);
278 /* show the callback list full occurrence counter */
279 IX_NPEMH_SHOW ("Solicited callback list full occurrences",
280 ixNpeMhSendStats[npeId].callbackFulls);
284 * Function definition: ixNpeMhSendShowReset
287 void ixNpeMhSendShowReset (
290 /* reset the message send invocation counter */
291 ixNpeMhSendStats[npeId].sends = 0;
293 /* reset the message send with response invocation counter */
294 ixNpeMhSendStats[npeId].sendWithResponses = 0;
296 /* reset the fifo queue full occurrence counter */
297 ixNpeMhSendStats[npeId].queueFulls = 0;
299 /* reset the fifo queue full retry occurrence counter */
300 ixNpeMhSendStats[npeId].queueFullRetries = 0;
302 /* reset the max fifo queue full retries counter */
303 ixNpeMhSendStats[npeId].maxQueueFullRetries = 0;
305 /* reset the callback list full occurrence counter */
306 ixNpeMhSendStats[npeId].callbackFulls = 0;