4 * @author Intel Corporation
5 * @date 08 January 2002
7 * @brief This file contains the implementation of the public API for the
8 * IXP425 NPE Downloader component
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
31 * Put the user defined include files required
34 #include "IxNpeDlImageMgr_p.h"
35 #include "IxNpeDlNpeMgr_p.h"
36 #include "IxNpeDlMacros_p.h"
37 #include "IxFeatureCtrl.h"
40 * #defines used in this file
42 #define IMAGEID_MAJOR_NUMBER_DEFAULT 0
43 #define IMAGEID_MINOR_NUMBER_DEFAULT 0
46 * Typedefs whose scope is limited to this file.
51 IxNpeDlImageId imageId;
54 /* module statistics counters */
57 UINT32 attemptedDownloads;
58 UINT32 successfulDownloads;
59 UINT32 criticalFailDownloads;
63 * Variable declarations global to this file only. Externs are followed
64 * by static variables.
66 static IxNpeDlNpeState ixNpeDlNpeState[IX_NPEDL_NPEID_MAX] =
68 {false, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
69 {false, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
70 {false, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}
73 static IxNpeDlStats ixNpeDlStats;
76 * Software guard to prevent NPE from being started multiple times.
78 static BOOL ixNpeDlNpeStarted[IX_NPEDL_NPEID_MAX] ={false, false, false} ;
82 * static function prototypes.
85 ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary, UINT32 imageId);
88 * Function definition: ixNpeDlImageDownload
91 ixNpeDlImageDownload (IxNpeDlImageId *imageIdPtr,
95 UINT32 *imageCodePtr = NULL;
97 IxNpeDlNpeId npeId = imageIdPtr->npeId;
99 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
100 "Entering ixNpeDlImageDownload\n");
102 ixNpeDlStats.attemptedDownloads++;
104 /* Check input parameters */
105 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
107 status = IX_NPEDL_PARAM_ERR;
108 IX_NPEDL_ERROR_REPORT ("ixNpeDlImageDownload - invalid parameter\n");
112 /* Ensure initialisation has been completed */
115 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
116 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
117 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
118 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
120 if (npeId == IX_NPEDL_NPEID_NPEA)
122 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
123 IX_FEATURE_CTRL_COMPONENT_DISABLED)
125 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
129 } /* end of if(npeId) */
130 else if (npeId == IX_NPEDL_NPEID_NPEB)
132 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
133 IX_FEATURE_CTRL_COMPONENT_DISABLED)
135 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
136 " does not exist\n");
139 } /* end of elseif(npeId) */
140 else if (npeId == IX_NPEDL_NPEID_NPEC)
142 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
143 IX_FEATURE_CTRL_COMPONENT_DISABLED)
145 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
146 " does not exist\n");
149 } /* end of elseif(npeId) */
150 } /* end of if(IX_FEATURE_CTRL_SILICON_TYPE_B0) */ /*End of Silicon Type Check*/
152 /* stop and reset the NPE */
153 if (IX_SUCCESS != ixNpeDlNpeStopAndReset (npeId))
155 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
160 status = ixNpeDlImageMgrImageLocate (imageIdPtr, &imageCodePtr,
162 if (IX_SUCCESS == status)
165 * If download was successful, store image Id in list of
166 * currently loaded images. If a critical error occured
167 * during download, record that the NPE has an invalid image
169 status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr,
171 if (IX_SUCCESS == status)
173 ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
174 ixNpeDlNpeState[npeId].validImage = true;
175 ixNpeDlStats.successfulDownloads++;
177 status = ixNpeDlNpeExecutionStart (npeId);
179 else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
180 (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
182 ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
183 ixNpeDlNpeState[npeId].validImage = false;
184 ixNpeDlStats.criticalFailDownloads++;
186 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
187 } /* end of if-else(npeId) */ /* condition: parameter checks ok */
189 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
190 "Exiting ixNpeDlImageDownload : status = %d\n", status);
195 * Function definition: ixNpeDlAvailableImagesCountGet
198 ixNpeDlAvailableImagesCountGet (UINT32 *numImagesPtr)
202 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
203 "Entering ixNpeDlAvailableImagesCountGet\n");
205 /* Check input parameters */
206 if (numImagesPtr == NULL)
208 status = IX_NPEDL_PARAM_ERR;
209 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesCountGet - "
210 "invalid parameter\n");
215 * Use ImageMgr module to get no. of images listed in Image Library Header.
216 * If NULL is passed as imageListPtr parameter to following function,
217 * it will only fill number of images into numImagesPtr
219 status = ixNpeDlImageMgrImageListExtract (NULL, numImagesPtr);
220 } /* end of if-else(numImagesPtr) */
222 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
223 "Exiting ixNpeDlAvailableImagesCountGet : "
224 "status = %d\n", status);
229 * Function definition: ixNpeDlAvailableImagesListGet
232 ixNpeDlAvailableImagesListGet (IxNpeDlImageId *imageIdListPtr,
237 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
238 "Entering ixNpeDlAvailableImagesListGet\n");
240 /* Check input parameters */
241 if ((imageIdListPtr == NULL) || (listSizePtr == NULL))
243 status = IX_NPEDL_PARAM_ERR;
244 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesListGet - "
245 "invalid parameter\n");
249 /* Call ImageMgr to get list of images listed in Image Library Header */
250 status = ixNpeDlImageMgrImageListExtract (imageIdListPtr,
252 } /* end of if-else(imageIdListPtr) */
254 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
255 "Exiting ixNpeDlAvailableImagesListGet : status = %d\n",
261 * Function definition: ixNpeDlLoadedImageGet
264 ixNpeDlLoadedImageGet (IxNpeDlNpeId npeId,
265 IxNpeDlImageId *imageIdPtr)
267 IX_STATUS status = IX_SUCCESS;
269 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
270 "Entering ixNpeDlLoadedImageGet\n");
272 /* Check input parameters */
273 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0) || (imageIdPtr == NULL))
275 status = IX_NPEDL_PARAM_ERR;
276 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageGet - invalid parameter\n");
281 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
282 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
283 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
284 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
286 if (npeId == IX_NPEDL_NPEID_NPEA &&
287 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
288 IX_FEATURE_CTRL_COMPONENT_DISABLED))
290 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
293 } /* end of if(npeId) */
295 if (npeId == IX_NPEDL_NPEID_NPEB &&
296 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
297 IX_FEATURE_CTRL_COMPONENT_DISABLED))
299 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
302 } /* end of if(npeId) */
304 if (npeId == IX_NPEDL_NPEID_NPEC &&
305 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
306 IX_FEATURE_CTRL_COMPONENT_DISABLED))
308 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
311 } /* end of if(npeId) */
312 } /* end of if not IXP42x-A0 silicon */
314 if (ixNpeDlNpeState[npeId].validImage)
316 /* use npeId to get imageId from list of currently loaded
318 *imageIdPtr = ixNpeDlNpeState[npeId].imageId;
323 } /* end of if-else(ixNpeDlNpeState) */
324 } /* end of if-else(npeId) */
326 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
327 "Exiting ixNpeDlLoadedImageGet : status = %d\n",
333 * Function definition: ixNpeDlLatestImageGet
336 ixNpeDlLatestImageGet (
338 IxNpeDlFunctionalityId functionalityId,
339 IxNpeDlImageId *imageIdPtr)
343 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
344 "Entering ixNpeDlLatestImageGet\n");
346 /* Check input parameters */
347 if ((npeId >= IX_NPEDL_NPEID_MAX) ||
349 (imageIdPtr == NULL))
351 status = IX_NPEDL_PARAM_ERR;
352 IX_NPEDL_ERROR_REPORT ("ixNpeDlLatestImageGet - "
353 "invalid parameter\n");
354 } /* end of if(npeId) */
358 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
359 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
360 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
361 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
363 if (npeId == IX_NPEDL_NPEID_NPEA &&
364 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
365 IX_FEATURE_CTRL_COMPONENT_DISABLED))
367 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
370 } /* end of if(npeId) */
372 if (npeId == IX_NPEDL_NPEID_NPEB &&
373 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
374 IX_FEATURE_CTRL_COMPONENT_DISABLED))
376 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
379 } /* end of if(npeId) */
381 if (npeId == IX_NPEDL_NPEID_NPEC &&
382 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
383 IX_FEATURE_CTRL_COMPONENT_DISABLED))
385 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
388 } /* end of if(npeId) */
389 } /* end of if not IXP42x-A0 silicon */
391 imageIdPtr->npeId = npeId;
392 imageIdPtr->functionalityId = functionalityId;
393 imageIdPtr->major = IMAGEID_MAJOR_NUMBER_DEFAULT;
394 imageIdPtr->minor = IMAGEID_MINOR_NUMBER_DEFAULT;
395 /* Call ImageMgr to get list of images listed in Image Library Header */
396 status = ixNpeDlImageMgrLatestImageExtract(imageIdPtr);
397 } /* end of if-else(npeId) */
399 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
400 "Exiting ixNpeDlLatestImageGet : status = %d\n",
407 * Function definition: ixNpeDlNpeStopAndReset
410 ixNpeDlNpeStopAndReset (IxNpeDlNpeId npeId)
412 IX_STATUS status = IX_SUCCESS;
414 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
415 "Entering ixNpeDlNpeStopAndReset\n");
417 /* Ensure initialisation has been completed */
420 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
421 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
422 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
423 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
426 * Check whether NPE is present
428 if (IX_NPEDL_NPEID_NPEA == npeId)
430 /* Check whether NPE A is present */
431 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
432 IX_FEATURE_CTRL_COMPONENT_DISABLED)
434 /* NPE A does not present */
435 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEA does not present.\n");
438 } /* end of if(IX_NPEDL_NPEID_NPEA) */
439 else if (IX_NPEDL_NPEID_NPEB == npeId)
441 /* Check whether NPE B is present */
442 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
443 IX_FEATURE_CTRL_COMPONENT_DISABLED)
445 /* NPE B does not present */
446 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEB does not present.\n");
449 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
450 else if (IX_NPEDL_NPEID_NPEC == npeId)
452 /* Check whether NPE C is present */
453 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
454 IX_FEATURE_CTRL_COMPONENT_DISABLED)
456 /* NPE C does not present */
457 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEC does not present.\n");
460 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
464 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeStopAndReset - invalid Npe ID\n");
465 status = IX_NPEDL_PARAM_ERR;
466 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
467 } /* end of if not IXP42x-A0 Silicon */
469 if (status == IX_SUCCESS)
471 /* call NpeMgr function to stop the NPE */
472 status = ixNpeDlNpeMgrNpeStop (npeId);
473 if (status == IX_SUCCESS)
475 /* call NpeMgr function to reset the NPE */
476 status = ixNpeDlNpeMgrNpeReset (npeId);
478 } /* end of if(status) */
480 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
481 "Exiting ixNpeDlNpeStopAndReset : status = %d\n", status);
483 if (IX_SUCCESS == status)
485 /* Indicate NPE has been stopped */
486 ixNpeDlNpeStarted[npeId] = false ;
493 * Function definition: ixNpeDlNpeExecutionStart
496 ixNpeDlNpeExecutionStart (IxNpeDlNpeId npeId)
498 IX_STATUS status = IX_SUCCESS;
500 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
501 "Entering ixNpeDlNpeExecutionStart\n");
503 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
504 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
505 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
506 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
509 * Check whether NPE is present
511 if (IX_NPEDL_NPEID_NPEA == npeId)
513 /* Check whether NPE A is present */
514 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
515 IX_FEATURE_CTRL_COMPONENT_DISABLED)
517 /* NPE A does not present */
518 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEA does not present.\n");
521 } /* end of if(IX_NPEDL_NPEID_NPEA) */
522 else if (IX_NPEDL_NPEID_NPEB == npeId)
524 /* Check whether NPE B is present */
525 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
526 IX_FEATURE_CTRL_COMPONENT_DISABLED)
528 /* NPE B does not present */
529 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEB does not present.\n");
532 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
533 else if (IX_NPEDL_NPEID_NPEC == npeId)
535 /* Check whether NPE C is present */
536 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
537 IX_FEATURE_CTRL_COMPONENT_DISABLED)
539 /* NPE C does not present */
540 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEC does not present.\n");
543 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
547 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStart - invalid Npe ID\n");
548 return IX_NPEDL_PARAM_ERR;
549 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
550 } /* end of if not IXP42x-A0 Silicon */
552 if (true == ixNpeDlNpeStarted[npeId])
554 /* NPE has been started. */
558 /* Ensure initialisation has been completed */
561 /* call NpeMgr function to start the NPE */
562 status = ixNpeDlNpeMgrNpeStart (npeId);
564 if (IX_SUCCESS == status)
566 /* Indicate NPE has started */
567 ixNpeDlNpeStarted[npeId] = true ;
570 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
571 "Exiting ixNpeDlNpeExecutionStart : status = %d\n",
578 * Function definition: ixNpeDlNpeExecutionStop
581 ixNpeDlNpeExecutionStop (IxNpeDlNpeId npeId)
583 IX_STATUS status = IX_SUCCESS;
585 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
586 "Entering ixNpeDlNpeExecutionStop\n");
588 /* Ensure initialisation has been completed */
591 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
592 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
593 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
594 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
597 * Check whether NPE is present
599 if (IX_NPEDL_NPEID_NPEA == npeId)
601 /* Check whether NPE A is present */
602 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
603 IX_FEATURE_CTRL_COMPONENT_DISABLED)
605 /* NPE A does not present */
606 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEA does not present.\n");
609 } /* end of if(IX_NPEDL_NPEID_NPEA) */
610 else if (IX_NPEDL_NPEID_NPEB == npeId)
612 /* Check whether NPE B is present */
613 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
614 IX_FEATURE_CTRL_COMPONENT_DISABLED)
616 /* NPE B does not present */
617 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEB does not present.\n");
620 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
621 else if (IX_NPEDL_NPEID_NPEC == npeId)
623 /* Check whether NPE C is present */
624 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
625 IX_FEATURE_CTRL_COMPONENT_DISABLED)
627 /* NPE C does not present */
628 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEC does not present.\n");
631 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
635 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStop - invalid Npe ID\n");
636 status = IX_NPEDL_PARAM_ERR;
637 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
638 } /* end of if not IXP42X-AO Silicon */
640 if (status == IX_SUCCESS)
642 /* call NpeMgr function to stop the NPE */
643 status = ixNpeDlNpeMgrNpeStop (npeId);
646 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
647 "Exiting ixNpeDlNpeExecutionStop : status = %d\n",
650 if (IX_SUCCESS == status)
652 /* Indicate NPE has been stopped */
653 ixNpeDlNpeStarted[npeId] = false ;
660 * Function definition: ixNpeDlUnload
667 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
668 "Entering ixNpeDlUnload\n");
670 status = ixNpeDlNpeMgrUninit();
672 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
673 "Exiting ixNpeDlUnload : status = %d\n",
679 * Function definition: ixNpeDlStatsShow
682 ixNpeDlStatsShow (void)
684 ixOsalLog (IX_OSAL_LOG_LVL_USER,
685 IX_OSAL_LOG_DEV_STDOUT,
686 "\nixNpeDlStatsShow:\n"
687 "\tDownloads Attempted by user: %u\n"
688 "\tSuccessful Downloads: %u\n"
689 "\tFailed Downloads (due to Critical Error): %u\n\n",
690 ixNpeDlStats.attemptedDownloads,
691 ixNpeDlStats.successfulDownloads,
692 ixNpeDlStats.criticalFailDownloads,
695 ixNpeDlImageMgrStatsShow ();
696 ixNpeDlNpeMgrStatsShow ();
700 * Function definition: ixNpeDlStatsReset
703 ixNpeDlStatsReset (void)
705 ixNpeDlStats.attemptedDownloads = 0;
706 ixNpeDlStats.successfulDownloads = 0;
707 ixNpeDlStats.criticalFailDownloads = 0;
709 ixNpeDlImageMgrStatsReset ();
710 ixNpeDlNpeMgrStatsReset ();
714 * Function definition: ixNpeDlNpeInitAndStartInternal
717 ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary,
721 UINT32 *imageCodePtr = NULL;
723 IxNpeDlNpeId npeId = IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId);
724 IxFeatureCtrlDeviceId deviceId = IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId);
726 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
727 "Entering ixNpeDlNpeInitAndStartInternal\n");
729 ixNpeDlStats.attemptedDownloads++;
731 /* Check input parameter device correctness */
732 if ((deviceId >= IX_FEATURE_CTRL_DEVICE_TYPE_MAX) ||
733 (deviceId < IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X))
735 status = IX_NPEDL_PARAM_ERR;
736 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
737 "invalid parameter\n");
738 } /* End valid device id checking */
740 /* Check input parameters */
741 else if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
743 status = IX_NPEDL_PARAM_ERR;
744 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
745 "invalid parameter\n");
750 /* Ensure initialisation has been completed */
753 /* Checking if image being loaded is meant for device that is running.
754 * Image is forward compatible. i.e Image built for IXP42X should run
755 * on IXP46X but not vice versa.*/
756 if (deviceId > (ixFeatureCtrlDeviceRead() & IX_FEATURE_CTRL_DEVICE_TYPE_MASK))
758 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
759 "Device type mismatch. NPE Image not "
760 "meant for device in use \n");
761 return IX_NPEDL_DEVICE_ERR;
762 }/* if statement - matching image device and current device */
764 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
765 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
766 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
767 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
769 if (npeId == IX_NPEDL_NPEID_NPEA)
771 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
772 IX_FEATURE_CTRL_COMPONENT_DISABLED)
774 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
778 } /* end of if(npeId) */
779 else if (npeId == IX_NPEDL_NPEID_NPEB)
781 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
782 IX_FEATURE_CTRL_COMPONENT_DISABLED)
784 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
785 " does not exist\n");
788 } /* end of elseif(npeId) */
789 else if (npeId == IX_NPEDL_NPEID_NPEC)
791 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
792 IX_FEATURE_CTRL_COMPONENT_DISABLED)
794 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
795 " does not exist\n");
798 } /* end of elseif(npeId) */
799 } /* end of if not IXP42X-A0 Silicon */
801 /* stop and reset the NPE */
802 status = ixNpeDlNpeStopAndReset (npeId);
803 if (IX_SUCCESS != status)
805 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
810 status = ixNpeDlImageMgrImageFind (imageLibrary, imageId,
811 &imageCodePtr, &imageSize);
812 if (IX_SUCCESS == status)
815 * If download was successful, store image Id in list of
816 * currently loaded images. If a critical error occured
817 * during download, record that the NPE has an invalid image
819 status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr, true);
820 if (IX_SUCCESS == status)
822 ixNpeDlNpeState[npeId].validImage = true;
823 ixNpeDlStats.successfulDownloads++;
825 status = ixNpeDlNpeExecutionStart (npeId);
827 else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
828 (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
830 ixNpeDlNpeState[npeId].validImage = false;
831 ixNpeDlStats.criticalFailDownloads++;
834 /* NOTE - The following section of code is here to support
835 * a deprecated function ixNpeDlLoadedImageGet(). When that
836 * function is removed from the API, this code should be revised.
838 ixNpeDlNpeState[npeId].imageId.npeId = npeId;
839 ixNpeDlNpeState[npeId].imageId.functionalityId =
840 IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId);
841 ixNpeDlNpeState[npeId].imageId.major =
842 IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId);
843 ixNpeDlNpeState[npeId].imageId.minor =
844 IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId);
845 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
846 } /* end of if-else(npeId-deviceId) */ /* condition: parameter checks ok */
848 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
849 "Exiting ixNpeDlNpeInitAndStartInternal : "
850 "status = %d\n", status);
855 * Function definition: ixNpeDlCustomImageNpeInitAndStart
858 ixNpeDlCustomImageNpeInitAndStart (UINT32 *imageLibrary,
863 if (imageLibrary == NULL)
865 status = IX_NPEDL_PARAM_ERR;
866 IX_NPEDL_ERROR_REPORT ("ixNpeDlCustomImageNpeInitAndStart "
867 "- invalid parameter\n");
871 status = ixNpeDlNpeInitAndStartInternal (imageLibrary, imageId);
872 } /* end of if-else(imageLibrary) */
878 * Function definition: ixNpeDlNpeInitAndStart
881 ixNpeDlNpeInitAndStart (UINT32 imageId)
883 return ixNpeDlNpeInitAndStartInternal (NULL, imageId);
887 * Function definition: ixNpeDlLoadedImageFunctionalityGet
890 ixNpeDlLoadedImageFunctionalityGet (IxNpeDlNpeId npeId,
891 UINT8 *functionalityId)
893 /* Check input parameters */
894 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
896 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
897 "- invalid parameter\n");
898 return IX_NPEDL_PARAM_ERR;
900 if (functionalityId == NULL)
902 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
903 "- invalid parameter\n");
904 return IX_NPEDL_PARAM_ERR;
907 if (ixNpeDlNpeState[npeId].validImage)
909 *functionalityId = ixNpeDlNpeState[npeId].imageId.functionalityId;