source: SVN/cambria/redboot/packages/devs/eth/intel/npe/npeMh/current/src/IxNpeMhSend.c @ 1

Last change on this file since 1 was 1, checked in by Tim Harvey, 2 years ago

restored latest version of files from server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 8.5 KB
Line 
1/**
2 * @file IxNpeMhSend.c
3 *
4 * @author Intel Corporation
5 * @date 18 Jan 2002
6 *
7 * @brief This file contains the implementation of the private API for the
8 * Send module.
9 *
10 *
11 * @par
12 * IXP400 SW Release version 2.3
13 *
14 * -- Copyright Notice --
15 *
16 * @par
17 * Copyright (c) 2001-2005, Intel Corporation.
18 * All rights reserved.
19 *
20 * @par
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
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.
32 *
33 *
34 * @par
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
36 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 *
47 *
48 * @par
49 * -- End of Copyright Notice --
50*/
51
52/*
53 * Put the system defined include files required.
54 */
55
56
57/*
58 * Put the user defined include files required.
59 */
60
61#include "IxNpeMhMacros_p.h"
62
63#include "IxNpeMhConfig_p.h"
64#include "IxNpeMhSend_p.h"
65#include "IxNpeMhSolicitedCbMgr_p.h"
66
67/*
68 * #defines and macros used in this file.
69 */
70
71/**
72 * @def IX_NPEMH_INFIFO_RETRY_DELAY_US
73 *
74 * @brief Amount of time (uSecs) to delay between retries
75 * while inFIFO is Full when attempting to send a message
76 */
77#define IX_NPEMH_INFIFO_RETRY_DELAY_US (1)
78
79
80/*
81 * Typedefs whose scope is limited to this file.
82 */
83
84/**
85 * @struct IxNpeMhSendStats
86 *
87 * @brief This structure is used to maintain statistics for the Send
88 * module.
89 */
90
91typedef struct
92{
93    UINT32 sends;             /**< send invocations */
94    UINT32 sendWithResponses; /**< send with response invocations */
95    UINT32 queueFulls;        /**< fifo queue full occurrences */
96    UINT32 queueFullRetries;  /**< fifo queue full retry occurrences */
97    UINT32 maxQueueFullRetries; /**< max fifo queue full retries */
98    UINT32 callbackFulls;     /**< callback list full occurrences */
99} IxNpeMhSendStats;
100
101/*
102 * Variable declarations global to this file only.  Externs are followed by
103 * static variables.
104 */
105
106PRIVATE IxNpeMhSendStats ixNpeMhSendStats[IX_NPEMH_NUM_NPES];
107
108/*
109 * Extern function prototypes.
110 */
111
112/*
113 * Static function prototypes.
114 */
115PRIVATE
116BOOL ixNpeMhSendInFifoIsFull(
117    IxNpeMhNpeId npeId,
118    UINT32 maxSendRetries);
119
120/*
121 * Function definition: ixNpeMhSendInFifoIsFull
122 */
123
124PRIVATE
125BOOL ixNpeMhSendInFifoIsFull(
126    IxNpeMhNpeId npeId,
127    UINT32 maxSendRetries)
128{
129    BOOL isFull = FALSE;
130    UINT32 numRetries = 0;
131
132    /* check the NPE's inFIFO */
133    isFull = ixNpeMhConfigInFifoIsFull (npeId);
134
135    /* we retry a few times, just to give the NPE a chance to read from */
136    /* the FIFO if the FIFO is currently full */
137    while (isFull && (numRetries++ < maxSendRetries))
138    {
139        if (numRetries >= IX_NPEMH_SEND_RETRIES_DEFAULT)
140        {
141            /* Delay here for as short a time as possible (1 us). */
142            /* Adding a delay here should ensure we are not hogging */
143            /* the AHB bus while we are retrying                    */
144            ixOsalBusySleep (IX_NPEMH_INFIFO_RETRY_DELAY_US);
145        }
146
147        /* re-check the NPE's inFIFO */
148        isFull = ixNpeMhConfigInFifoIsFull (npeId);
149
150        /* update statistical info */
151        ixNpeMhSendStats[npeId].queueFullRetries++;
152    }
153
154    /* record the highest number of retries that occurred */
155    if (ixNpeMhSendStats[npeId].maxQueueFullRetries < numRetries)
156    {
157        ixNpeMhSendStats[npeId].maxQueueFullRetries = numRetries;
158    }
159
160    if (isFull)
161    {
162        /* update statistical info */
163        ixNpeMhSendStats[npeId].queueFulls++;
164    }
165
166    return isFull;
167}
168
169/*
170 * Function definition: ixNpeMhSendMessageSend
171 */
172
173IX_STATUS ixNpeMhSendMessageSend (
174    IxNpeMhNpeId npeId,
175    IxNpeMhMessage message,
176    UINT32 maxSendRetries)
177{
178    IX_STATUS status;
179   
180    IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
181                     "ixNpeMhSendMessageSend\n");
182
183    /* update statistical info */
184    ixNpeMhSendStats[npeId].sends++;
185
186    /* check if the NPE's inFIFO is full - if so return an error */
187    if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
188    {
189        IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
190        return IX_FAIL;
191    }
192
193    /* write the message to the NPE's inFIFO */
194    status = ixNpeMhConfigInFifoWrite (npeId, message);
195
196    IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
197                     "ixNpeMhSendMessageSend\n");
198
199    return status;
200}
201
202/*
203 * Function definition: ixNpeMhSendMessageWithResponseSend
204 */
205
206IX_STATUS ixNpeMhSendMessageWithResponseSend (
207    IxNpeMhNpeId npeId,
208    IxNpeMhMessage message,
209    IxNpeMhMessageId solicitedMessageId,
210    IxNpeMhCallback solicitedCallback,
211    UINT32 maxSendRetries)
212{
213    IX_STATUS status = IX_SUCCESS;
214
215    IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Entering "
216                     "ixNpeMhSendMessageWithResponseSend\n");
217
218    /* update statistical info */
219    ixNpeMhSendStats[npeId].sendWithResponses++;
220
221    /* check if the NPE's inFIFO is full - if so return an error */
222    if (ixNpeMhSendInFifoIsFull (npeId, maxSendRetries))
223    {
224        IX_NPEMH_TRACE0 (IX_NPEMH_WARNING, "NPE's inFIFO is full\n");
225        return IX_FAIL;
226    }
227
228    /* save the solicited callback */
229    status = ixNpeMhSolicitedCbMgrCallbackSave (
230        npeId, solicitedMessageId, solicitedCallback);
231    if (status != IX_SUCCESS)
232    {
233        IX_NPEMH_ERROR_REPORT ("Failed to save solicited callback\n");
234
235        /* update statistical info */
236        ixNpeMhSendStats[npeId].callbackFulls++;
237
238        return status;
239    }
240
241    /* write the message to the NPE's inFIFO */
242    status = ixNpeMhConfigInFifoWrite (npeId, message);
243   
244    IX_NPEMH_TRACE0 (IX_NPEMH_FN_ENTRY_EXIT, "Exiting "
245                     "ixNpeMhSendMessageWithResponseSend\n");
246
247    return status;
248}
249
250/*
251 * Function definition: ixNpeMhSendShow
252 */
253
254void ixNpeMhSendShow (
255    IxNpeMhNpeId npeId)
256{
257    /* show the message send invocation counter */
258    IX_NPEMH_SHOW ("Send invocations",
259                   ixNpeMhSendStats[npeId].sends);
260
261    /* show the message send with response invocation counter */
262    IX_NPEMH_SHOW ("Send with response invocations",
263                   ixNpeMhSendStats[npeId].sendWithResponses);
264
265    /* show the fifo queue full occurrence counter */
266    IX_NPEMH_SHOW ("Fifo queue full occurrences",
267                   ixNpeMhSendStats[npeId].queueFulls);
268
269    /* show the fifo queue full retry occurrence counter */
270    IX_NPEMH_SHOW ("Fifo queue full retry occurrences",
271                   ixNpeMhSendStats[npeId].queueFullRetries);
272
273    /* show the fifo queue full maximum retries counter */
274    IX_NPEMH_SHOW ("Maximum fifo queue full retries",
275                   ixNpeMhSendStats[npeId].maxQueueFullRetries);
276
277    /* show the callback list full occurrence counter */
278    IX_NPEMH_SHOW ("Solicited callback list full occurrences",
279                   ixNpeMhSendStats[npeId].callbackFulls);
280}
281
282/*
283 * Function definition: ixNpeMhSendShowReset
284 */
285
286void ixNpeMhSendShowReset (
287    IxNpeMhNpeId npeId)
288{
289    /* reset the message send invocation counter */
290    ixNpeMhSendStats[npeId].sends = 0;
291
292    /* reset the message send with response invocation counter */
293    ixNpeMhSendStats[npeId].sendWithResponses = 0;
294
295    /* reset the fifo queue full occurrence counter */
296    ixNpeMhSendStats[npeId].queueFulls = 0;
297
298    /* reset the fifo queue full retry occurrence counter */
299    ixNpeMhSendStats[npeId].queueFullRetries = 0;
300
301    /* reset the max fifo queue full retries counter */
302    ixNpeMhSendStats[npeId].maxQueueFullRetries = 0;
303
304    /* reset the callback list full occurrence counter */
305    ixNpeMhSendStats[npeId].callbackFulls = 0;
306}
Note: See TracBrowser for help on using the repository browser.