6 * @brief This file contains the public API of IxQMgr component.
8 * Some functions contained in this module are inline to achieve better
9 * data-path performance. For this to work, the function definitions are
10 * contained in this header file. The "normal" use of inline functions
11 * is to use the inline functions in the module in which they are
12 * defined. In this case these inline functions are used in external
13 * modules and therefore the use of "inline extern". What this means
14 * is as follows: if a function foo is declared as "inline extern" this
15 * definition is only used for inlining, in no case is the function
16 * compiled on its own. If the compiler cannot inline the function it
17 * becomes an external reference. Therefore in IxQMgrQAccess.c all
18 * inline functions are defined without the "inline extern" specifier
19 * and so define the external references. In all other source files
20 * including this header file, these funtions are defined as "inline
25 * IXP400 SW Release version 2.0
27 * -- Copyright Notice --
30 * Copyright 2001-2005, Intel Corporation.
31 * All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. Neither the name of the Intel Corporation nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * -- End of Copyright Notice --
63 /* ------------------------------------------------------
64 Doxygen group definitions
65 ------------------------------------------------------ */
67 * @defgroup IxQMgrAPI IXP400 Queue Manager (IxQMgr) API
69 * @brief The public API for the IXP400 QMgr component.
71 * IxQMgr is a low level interface to the AHB Queue Manager
80 * User defined include files
86 * Define QMgr's IoMem macros, in DC mode if in LE
87 * regular if in BE. (Note: For Linux LSP gold release
88 * may need to adjust mode.
90 #if defined (__BIG_ENDIAN)
92 #define IX_QMGR_INLINE_READ_LONG IX_OSAL_READ_LONG_BE
93 #define IX_QMGR_INLINE_WRITE_LONG IX_OSAL_WRITE_LONG_BE
97 #define IX_QMGR_INLINE_READ_LONG IX_OSAL_READ_LONG_LE_DC
98 #define IX_QMGR_INLINE_WRITE_LONG IX_OSAL_WRITE_LONG_LE_DC
103 * #defines and macros
110 * @def IX_QMGR_INLINE
112 * @brief Inline definition, for inlining of Queue Access functions on API
114 * Please read the header information in this file for more details on the
115 * use of function inlining in this component.
121 #ifdef IXQMGRQACCESS_C
122 /* If IXQMGRQACCESS_C is set then the IxQmgrQAccess.c is including this file
123 and must instantiate a concrete definition for each inlineable API function
124 whether or not that function actually gets inlined. */
125 # ifdef NO_INLINE_APIS
126 # undef NO_INLINE_APIS
128 # define IX_QMGR_INLINE /* Empty Define */
130 # ifndef NO_INLINE_APIS
131 # define IX_QMGR_INLINE IX_OSAL_INLINE_EXTERN
133 # define IX_QMGR_INLINE /* Empty Define */
137 #else /* ndef __wince */
139 # ifndef NO_INLINE_APIS
140 # define NO_INLINE_APIS
142 # define IX_QMGR_INLINE
151 * @def IX_QMGR_MAX_NUM_QUEUES
153 * @brief Number of queues supported by the AQM.
155 * This constant is used to indicate the number of AQM queues
158 #define IX_QMGR_MAX_NUM_QUEUES 64
164 * @def IX_QMGR_MIN_QID
166 * @brief Minimum queue identifier.
168 * This constant is used to indicate the smallest queue identifier
171 #define IX_QMGR_MIN_QID IX_QMGR_QUEUE_0
177 * @def IX_QMGR_MAX_QID
179 * @brief Maximum queue identifier.
181 * This constant is used to indicate the largest queue identifier
184 #define IX_QMGR_MAX_QID IX_QMGR_QUEUE_63
190 * @def IX_QMGR_MIN_QUEUPP_QID
192 * @brief Minimum queue identifier for reduced functionality queues.
194 * This constant is used to indicate Minimum queue identifier for reduced
195 * functionality queues
198 #define IX_QMGR_MIN_QUEUPP_QID 32
204 * @def IX_QMGR_MAX_QNAME_LEN
206 * @brief Maximum queue name length.
208 * This constant is used to indicate the maximum null terminated string length
209 * (excluding '\0') for a queue name
212 #define IX_QMGR_MAX_QNAME_LEN 16
218 * @def IX_QMGR_WARNING
220 * @brief Warning return code.
222 * Execution complete, but there is a special case to handle
225 #define IX_QMGR_WARNING 2
231 * @def IX_QMGR_PARAMETER_ERROR
233 * @brief Parameter error return code (NULL pointer etc..).
235 * parameter error out of range/invalid
238 #define IX_QMGR_PARAMETER_ERROR 3
244 * @def IX_QMGR_INVALID_Q_ENTRY_SIZE
246 * @brief Invalid entry size return code.
248 * Invalid queue entry size for a queue read/write
251 #define IX_QMGR_INVALID_Q_ENTRY_SIZE 4
257 * @def IX_QMGR_INVALID_Q_ID
259 * @brief Invalid queue identifier return code.
261 * Invalid queue id, not in range 0-63
264 #define IX_QMGR_INVALID_Q_ID 5
270 * @def IX_QMGR_INVALID_CB_ID
272 * @brief Invalid callback identifier return code.
274 * Invalid callback id
276 #define IX_QMGR_INVALID_CB_ID 6
282 * @def IX_QMGR_CB_ALREADY_SET
284 * @brief Callback set error return code.
286 * The specified callback has already been for this queue
289 #define IX_QMGR_CB_ALREADY_SET 7
295 * @def IX_QMGR_NO_AVAILABLE_SRAM
297 * @brief Sram consumed return code.
299 * All AQM Sram is consumed by queue configuration
302 #define IX_QMGR_NO_AVAILABLE_SRAM 8
308 * @def IX_QMGR_INVALID_INT_SOURCE_ID
310 * @brief Invalid queue interrupt source identifier return code.
312 * Invalid queue interrupt source given for notification enable
314 #define IX_QMGR_INVALID_INT_SOURCE_ID 9
320 * @def IX_QMGR_INVALID_QSIZE
322 * @brief Invalid queue size error code.
324 * Invalid queue size not one of 16,32, 64, 128
328 #define IX_QMGR_INVALID_QSIZE 10
334 * @def IX_QMGR_INVALID_Q_WM
336 * @brief Invalid queue watermark return code.
338 * Invalid queue watermark given for watermark set
340 #define IX_QMGR_INVALID_Q_WM 11
346 * @def IX_QMGR_Q_NOT_CONFIGURED
348 * @brief Queue not configured return code.
350 * Returned to the client when a function has been called on an unconfigured
354 #define IX_QMGR_Q_NOT_CONFIGURED 12
360 * @def IX_QMGR_Q_ALREADY_CONFIGURED
362 * @brief Queue already configured return code.
364 * Returned to client to indicate that a queue has already been configured
366 #define IX_QMGR_Q_ALREADY_CONFIGURED 13
372 * @def IX_QMGR_Q_UNDERFLOW
374 * @brief Underflow return code.
376 * Underflow on a queue read has occurred
379 #define IX_QMGR_Q_UNDERFLOW 14
385 * @def IX_QMGR_Q_OVERFLOW
387 * @brief Overflow return code.
389 * Overflow on a queue write has occurred
392 #define IX_QMGR_Q_OVERFLOW 15
398 * @def IX_QMGR_Q_INVALID_PRIORITY
400 * @brief Invalid priority return code.
402 * Invalid priority, not one of 0,1,2
404 #define IX_QMGR_Q_INVALID_PRIORITY 16
410 * @def IX_QMGR_ENTRY_INDEX_OUT_OF_BOUNDS
412 * @brief Entry index out of bounds return code.
414 * Entry index is greater than number of entries in queue.
416 #define IX_QMGR_ENTRY_INDEX_OUT_OF_BOUNDS 17
422 * @def ixQMgrDispatcherLoopRun
424 * @brief Map old function name ixQMgrDispatcherLoopRun ()
425 * to @ref ixQMgrDispatcherLoopRunA0 ().
428 #define ixQMgrDispatcherLoopRun ixQMgrDispatcherLoopRunA0
437 * @brief Definition of AQM queue numbers
440 #define IX_QMGR_QUEUE_0 (0) /**< Queue Number 0 */
441 #define IX_QMGR_QUEUE_1 (1) /**< Queue Number 1 */
442 #define IX_QMGR_QUEUE_2 (2) /**< Queue Number 2 */
443 #define IX_QMGR_QUEUE_3 (3) /**< Queue Number 3 */
444 #define IX_QMGR_QUEUE_4 (4) /**< Queue Number 4 */
445 #define IX_QMGR_QUEUE_5 (5) /**< Queue Number 5 */
446 #define IX_QMGR_QUEUE_6 (6) /**< Queue Number 6 */
447 #define IX_QMGR_QUEUE_7 (7) /**< Queue Number 7 */
448 #define IX_QMGR_QUEUE_8 (8) /**< Queue Number 8 */
449 #define IX_QMGR_QUEUE_9 (9) /**< Queue Number 9 */
450 #define IX_QMGR_QUEUE_10 (10) /**< Queue Number 10 */
451 #define IX_QMGR_QUEUE_11 (11) /**< Queue Number 11 */
452 #define IX_QMGR_QUEUE_12 (12) /**< Queue Number 12 */
453 #define IX_QMGR_QUEUE_13 (13) /**< Queue Number 13 */
454 #define IX_QMGR_QUEUE_14 (14) /**< Queue Number 14 */
455 #define IX_QMGR_QUEUE_15 (15) /**< Queue Number 15 */
456 #define IX_QMGR_QUEUE_16 (16) /**< Queue Number 16 */
457 #define IX_QMGR_QUEUE_17 (17) /**< Queue Number 17 */
458 #define IX_QMGR_QUEUE_18 (18) /**< Queue Number 18 */
459 #define IX_QMGR_QUEUE_19 (19) /**< Queue Number 19 */
460 #define IX_QMGR_QUEUE_20 (20) /**< Queue Number 20 */
461 #define IX_QMGR_QUEUE_21 (21) /**< Queue Number 21 */
462 #define IX_QMGR_QUEUE_22 (22) /**< Queue Number 22 */
463 #define IX_QMGR_QUEUE_23 (23) /**< Queue Number 23 */
464 #define IX_QMGR_QUEUE_24 (24) /**< Queue Number 24 */
465 #define IX_QMGR_QUEUE_25 (25) /**< Queue Number 25 */
466 #define IX_QMGR_QUEUE_26 (26) /**< Queue Number 26 */
467 #define IX_QMGR_QUEUE_27 (27) /**< Queue Number 27 */
468 #define IX_QMGR_QUEUE_28 (28) /**< Queue Number 28 */
469 #define IX_QMGR_QUEUE_29 (29) /**< Queue Number 29 */
470 #define IX_QMGR_QUEUE_30 (30) /**< Queue Number 30 */
471 #define IX_QMGR_QUEUE_31 (31) /**< Queue Number 31 */
472 #define IX_QMGR_QUEUE_32 (32) /**< Queue Number 32 */
473 #define IX_QMGR_QUEUE_33 (33) /**< Queue Number 33 */
474 #define IX_QMGR_QUEUE_34 (34) /**< Queue Number 34 */
475 #define IX_QMGR_QUEUE_35 (35) /**< Queue Number 35 */
476 #define IX_QMGR_QUEUE_36 (36) /**< Queue Number 36 */
477 #define IX_QMGR_QUEUE_37 (37) /**< Queue Number 37 */
478 #define IX_QMGR_QUEUE_38 (38) /**< Queue Number 38 */
479 #define IX_QMGR_QUEUE_39 (39) /**< Queue Number 39 */
480 #define IX_QMGR_QUEUE_40 (40) /**< Queue Number 40 */
481 #define IX_QMGR_QUEUE_41 (41) /**< Queue Number 41 */
482 #define IX_QMGR_QUEUE_42 (42) /**< Queue Number 42 */
483 #define IX_QMGR_QUEUE_43 (43) /**< Queue Number 43 */
484 #define IX_QMGR_QUEUE_44 (44) /**< Queue Number 44 */
485 #define IX_QMGR_QUEUE_45 (45) /**< Queue Number 45 */
486 #define IX_QMGR_QUEUE_46 (46) /**< Queue Number 46 */
487 #define IX_QMGR_QUEUE_47 (47) /**< Queue Number 47 */
488 #define IX_QMGR_QUEUE_48 (48) /**< Queue Number 48 */
489 #define IX_QMGR_QUEUE_49 (49) /**< Queue Number 49 */
490 #define IX_QMGR_QUEUE_50 (50) /**< Queue Number 50 */
491 #define IX_QMGR_QUEUE_51 (51) /**< Queue Number 51 */
492 #define IX_QMGR_QUEUE_52 (52) /**< Queue Number 52 */
493 #define IX_QMGR_QUEUE_53 (53) /**< Queue Number 53 */
494 #define IX_QMGR_QUEUE_54 (54) /**< Queue Number 54 */
495 #define IX_QMGR_QUEUE_55 (55) /**< Queue Number 55 */
496 #define IX_QMGR_QUEUE_56 (56) /**< Queue Number 56 */
497 #define IX_QMGR_QUEUE_57 (57) /**< Queue Number 57 */
498 #define IX_QMGR_QUEUE_58 (58) /**< Queue Number 58 */
499 #define IX_QMGR_QUEUE_59 (59) /**< Queue Number 59 */
500 #define IX_QMGR_QUEUE_60 (60) /**< Queue Number 60 */
501 #define IX_QMGR_QUEUE_61 (61) /**< Queue Number 61 */
502 #define IX_QMGR_QUEUE_62 (62) /**< Queue Number 62 */
503 #define IX_QMGR_QUEUE_63 (63) /**< Queue Number 63 */
504 #define IX_QMGR_QUEUE_INVALID (64) /**< AQM Queue Number Delimiter */
516 * @brief Used in the API to identify the AQM queues.
519 typedef int IxQMgrQId;
522 * @typedef IxQMgrQStatus
526 * @brief Queue status.
528 * A queues status is defined by its relative fullness or relative emptiness.
529 * Each of the queues 0-31 have Nearly Empty, Nearly Full, Empty, Full,
530 * Underflow and Overflow status flags. Queues 32-63 have just Nearly Empty and
532 * The flags bit positions are outlined below:
542 typedef UINT32 IxQMgrQStatus;
545 * @enum IxQMgrQStatusMask
549 * @brief Queue status mask.
551 * Masks for extracting the individual status flags from the IxQMgrStatus
557 IX_QMGR_Q_STATUS_E_BIT_MASK = 0x1,
558 IX_QMGR_Q_STATUS_NE_BIT_MASK = 0x2,
559 IX_QMGR_Q_STATUS_NF_BIT_MASK = 0x4,
560 IX_QMGR_Q_STATUS_F_BIT_MASK = 0x8,
561 IX_QMGR_Q_STATUS_UF_BIT_MASK = 0x10,
562 IX_QMGR_Q_STATUS_OF_BIT_MASK = 0x20
566 * @enum IxQMgrSourceId
570 * @brief Queue interrupt source select.
572 * This enum defines the different source conditions on a queue that result in
573 * an interrupt being fired by the AQM. Interrupt source is configurable for
574 * queues 0-31 only. The interrupt source for queues 32-63 is hardwired to the
575 * NE(Nearly Empty) status flag.
580 IX_QMGR_Q_SOURCE_ID_E = 0, /**< Queue Empty due to last read */
581 IX_QMGR_Q_SOURCE_ID_NE, /**< Queue Nearly Empty due to last read */
582 IX_QMGR_Q_SOURCE_ID_NF, /**< Queue Nearly Full due to last write */
583 IX_QMGR_Q_SOURCE_ID_F, /**< Queue Full due to last write */
584 IX_QMGR_Q_SOURCE_ID_NOT_E, /**< Queue Not Empty due to last write */
585 IX_QMGR_Q_SOURCE_ID_NOT_NE, /**< Queue Not Nearly Empty due to last write */
586 IX_QMGR_Q_SOURCE_ID_NOT_NF, /**< Queue Not Nearly Full due to last read */
587 IX_QMGR_Q_SOURCE_ID_NOT_F /**< Queue Not Full due to last read */
591 * @enum IxQMgrQEntrySizeInWords
595 * @brief QMgr queue entry sizes.
597 * The entry size of a queue specifies the size of a queues entry in words.
602 IX_QMGR_Q_ENTRY_SIZE1 = 1, /**< 1 word entry */
603 IX_QMGR_Q_ENTRY_SIZE2 = 2, /**< 2 word entry */
604 IX_QMGR_Q_ENTRY_SIZE4 = 4 /**< 4 word entry */
605 } IxQMgrQEntrySizeInWords;
608 * @enum IxQMgrQSizeInWords
612 * @brief QMgr queue sizes.
614 * These values define the allowed queue sizes for AQM queue. The sizes are
615 * specified in words.
620 IX_QMGR_Q_SIZE16 = 16, /**< 16 word buffer */
621 IX_QMGR_Q_SIZE32 = 32, /**< 32 word buffer */
622 IX_QMGR_Q_SIZE64 = 64, /**< 64 word buffer */
623 IX_QMGR_Q_SIZE128 = 128, /**< 128 word buffer */
624 IX_QMGR_Q_SIZE_INVALID = 129 /**< Insure that this is greater than largest
625 * queue size supported by the hardware
627 } IxQMgrQSizeInWords;
630 * @enum IxQMgrWMLevel
634 * @brief QMgr watermark levels.
636 * These values define the valid watermark levels(in ENTRIES) for queues. Each
637 * queue 0-63 have configurable Nearly full and Nearly empty watermarks. For
638 * queues 32-63 the Nearly full watermark has NO EFFECT.
639 * If the Nearly full watermark is set to IX_QMGR_Q_WM_LEVEL16 this means that
640 * the nearly full flag will be set by the hardware when there are >= 16 empty
641 * entries in the specified queue.
642 * If the Nearly empty watermark is set to IX_QMGR_Q_WM_LEVEL16 this means that
643 * the Nearly empty flag will be set by the hardware when there are <= 16 full
644 * entries in the specified queue.
648 IX_QMGR_Q_WM_LEVEL0 = 0, /**< 0 entry watermark */
649 IX_QMGR_Q_WM_LEVEL1 = 1, /**< 1 entry watermark */
650 IX_QMGR_Q_WM_LEVEL2 = 2, /**< 2 entry watermark */
651 IX_QMGR_Q_WM_LEVEL4 = 4, /**< 4 entry watermark */
652 IX_QMGR_Q_WM_LEVEL8 = 8, /**< 8 entry watermark */
653 IX_QMGR_Q_WM_LEVEL16 = 16, /**< 16 entry watermark */
654 IX_QMGR_Q_WM_LEVEL32 = 32, /**< 32 entry watermark */
655 IX_QMGR_Q_WM_LEVEL64 = 64 /**< 64 entry watermark */
661 * @enum IxQMgrDispatchGroup
663 * @brief QMgr dispatch group select identifiers.
665 * This enum defines the groups over which the dispatcher will process when
666 * called. One of the enum values must be used as a input to
667 * @a ixQMgrDispatcherLoopRunA0, @a ixQMgrDispatcherLoopRunB0
668 * or @a ixQMgrDispatcherLoopRunB0LLP.
673 IX_QMGR_QUELOW_GROUP = 0, /**< Queues 0-31 */
674 IX_QMGR_QUEUPP_GROUP /**< Queues 32-63 */
675 } IxQMgrDispatchGroup;
680 * @enum IxQMgrPriority
682 * @brief Dispatcher priority levels.
684 * This enum defines the different queue dispatch priority levels.
685 * The lowest priority number (0) is the highest priority level.
690 IX_QMGR_Q_PRIORITY_0 = 0, /**< Priority level 0 */
691 IX_QMGR_Q_PRIORITY_1, /**< Priority level 1 */
692 IX_QMGR_Q_PRIORITY_2, /**< Priority level 2 */
693 IX_QMGR_Q_PRIORITY_INVALID /**< Invalid Priority level */
701 * @brief Callback types as used with livelock prevention
703 * This enum defines the different callback types.
704 * These types are only used when Livelock prevention is enabled.
705 * The default is IX_QMGR_TYPE_REALTIME_OTHER.
711 IX_QMGR_TYPE_REALTIME_OTHER = 0, /**< Real time callbacks-always allowed run*/
712 IX_QMGR_TYPE_REALTIME_PERIODIC, /**< Periodic callbacks-always allowed run */
713 IX_QMGR_TYPE_REALTIME_SPORADIC /**< Sporadic callbacks-only run if no
714 periodic callbacks are in progress */
721 * @typedef IxQMgrCallbackId
723 * @brief Uniquely identifies a callback function.
725 * A unique callback identifier associated with each callback
726 * registered by clients.
729 typedef unsigned IxQMgrCallbackId;
732 * @typedef IxQMgrCallback
734 * @brief QMgr notification callback type.
736 * This defines the interface to all client callback functions.
738 * @param qId @ref IxQMgrQId [in] - the queue identifier
739 * @param cbId @ref IxQMgrCallbackId [in] - the callback identifier
741 typedef void (*IxQMgrCallback)(IxQMgrQId qId,
742 IxQMgrCallbackId cbId);
747 * @typedef IxQMgrDispatcherFuncPtr
749 * @brief QMgr Dispatcher Loop function pointer.
751 * This defines the interface for QMgr Dispather functions.
753 * @param group @ref IxQMgrDispatchGroup [in] - the group of the
754 * queue of which the dispatcher will run
756 typedef void (*IxQMgrDispatcherFuncPtr)(IxQMgrDispatchGroup group);
759 * Function Prototypes
762 /* ------------------------------------------------------------
763 Initialisation related functions
764 ---------------------------------------------------------- */
770 * @fn ixQMgrInit (void)
772 * @brief Initialise the QMgr.
774 * This function must be called before and other QMgr function. It
775 * sets up internal data structures.
777 * @return @li IX_SUCCESS, the IxQMgr successfully initialised
778 * @return @li IX_FAIL, failed to initialize the Qmgr
788 * @fn ixQMgrUnload (void)
790 * @brief Uninitialise the QMgr.
792 * This function will perform the tasks required to unload the QMgr component
793 * cleanly. This includes unmapping kernel memory.
794 * This should be called before a soft reboot or unloading of a kernel module.
796 * @pre It should only be called if @ref ixQMgrInit has already been called.
798 * @post No QMgr functions should be called until ixQMgrInit is called again.
800 * @return @li IX_SUCCESS, the IxQMgr successfully uninitialised
801 * @return @li IX_FAIL, failed to uninitialize the Qmgr
811 * @fn ixQMgrShow (void)
813 * @brief Describe queue configuration and statistics for active queues.
815 * This function shows active queues, their configurations and statistics.
827 * @fn ixQMgrQShow (IxQMgrQId qId)
829 * @brief Display aqueue configuration and statistics for a queue.
831 * This function shows queue configuration and statistics for a queue.
833 * @param qId @ref IxQMgrQId [in] - the queue identifier.
835 * @return @li IX_SUCCESS, success
836 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
840 ixQMgrQShow (IxQMgrQId qId);
843 /* ------------------------------------------------------------
844 Configuration related functions
845 ---------------------------------------------------------- */
851 * @fn ixQMgrQConfig (char *qName,
853 IxQMgrQSizeInWords qSizeInWords,
854 IxQMgrQEntrySizeInWords qEntrySizeInWords)
856 * @brief Configure an AQM queue.
858 * This function is called by a client to setup a queue. The size and entrySize
859 * qId and qName(NULL pointer) are checked for valid values. This function must
860 * be called for each queue, before any queue accesses are made and after
861 * ixQMgrInit() has been called. qName is assumed to be a '\0' terminated array
862 * of 16 charachters or less.
864 * @param *qName char [in] - is the name provided by the client and is associated
865 * with a QId by the QMgr.
866 * @param qId @ref IxQMgrQId [in] - the qId of this queue
867 * @param qSizeInWords @ref IxQMgrQSize [in] - the size of the queue can be one of 16,32
869 * @param qEntrySizeInWords @ref IxQMgrQEntrySizeInWords [in] - the size of a queue entry
870 * can be one of 1,2,4 words.
872 * @return @li IX_SUCCESS, a specified queue has been successfully configured.
873 * @return @li IX_FAIL, IxQMgr has not been initialised.
874 * @return @li IX_QMGR_PARAMETER_ERROR, invalid parameter(s).
875 * @return @li IX_QMGR_INVALID_QSIZE, invalid queue size
876 * @return @li IX_QMGR_INVALID_Q_ID, invalid queue id
877 * @return @li IX_QMGR_INVALID_Q_ENTRY_SIZE, invalid queue entry size
878 * @return @li IX_QMGR_Q_ALREADY_CONFIGURED, queue already configured
882 ixQMgrQConfig (char *qName,
884 IxQMgrQSizeInWords qSizeInWords,
885 IxQMgrQEntrySizeInWords qEntrySizeInWords);
890 * @fn ixQMgrQSizeInEntriesGet (IxQMgrQId qId,
891 unsigned *qSizeInEntries)
893 * @brief Return the size of a queue in entries.
895 * This function returns the the size of the queue in entriese.
897 * @param qId @ref IxQMgrQId [in] - the queue identifier
898 * @param *qSizeInEntries @ref IxQMgrQSize [out] - queue size in entries
900 * @return @li IX_SUCCESS, successfully retrieved the number of full entrie
901 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
902 * @return @li IX_QMGR_PARAMETER_ERROR, invalid parameter(s).
906 ixQMgrQSizeInEntriesGet (IxQMgrQId qId,
907 unsigned *qSizeInEntries);
913 * @fn ixQMgrWatermarkSet (IxQMgrQId qId,
917 * @brief Set the Nearly Empty and Nearly Full Watermarks fo a queue.
919 * This function is called by a client to set the watermarks NE and NF for the
920 * queue specified by qId.
921 * The queue must be empty at the time this function is called, it is the clients
922 * responsibility to ensure that the queue is empty.
923 * This function will read the status of the queue before the watermarks are set
924 * and again after the watermarks are set. If the status register has changed,
925 * due to a queue access by an NPE for example, a warning is returned.
926 * Queues 32-63 only support the NE flag, therefore the value of nf will be ignored
929 * @param qId @ref IxQMgrQId [in] - the QId of the queue.
930 * @param ne @ref IxQMgrWMLevel [in] - the NE(Nearly Empty) watermark for this
931 * queue. Valid values are 0,1,2,4,8,16,32 and
933 * @param nf @ref IxQMgrWMLevel [in] - the NF(Nearly Full) watermark for this queue.
934 * Valid values are 0,1,2,4,8,16,32 and 64
937 * @return @li IX_SUCCESS, watermarks have been set for the queu
938 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
939 * @return @li IX_QMGR_INVALID_Q_WM, invalid watermark
940 * @return @li IX_QMGR_WARNING, the status register may not be constistent
944 ixQMgrWatermarkSet (IxQMgrQId qId,
951 * @fn ixQMgrAvailableSramAddressGet (UINT32 *address,
952 unsigned *sizeOfFreeSram)
954 * @brief Return the address of available AQM SRAM.
956 * This function returns the starting address in AQM SRAM not used by the
957 * current queue configuration and should only be called after all queues
958 * have been configured.
959 * Calling this function before all queues have been configured will will return
960 * the currently available SRAM. A call to configure another queue will use some
961 * of the available SRAM.
962 * The amount of SRAM available is specified in sizeOfFreeSram. The address is the
963 * address of the bottom of available SRAM. Available SRAM extends from address
964 * from address to address + sizeOfFreeSram.
966 * @param **address UINT32 [out] - the address of the available SRAM, NULL if
968 * @param *sizeOfFreeSram unsigned [out]- the size in words of available SRAM
970 * @return @li IX_SUCCESS, there is available SRAM and is pointed to by address
971 * @return @li IX_QMGR_PARAMETER_ERROR, invalid parameter(s)
972 * @return @li IX_QMGR_NO_AVAILABLE_SRAM, all AQM SRAM is consumed by the queue
977 ixQMgrAvailableSramAddressGet (UINT32 *address,
978 unsigned *sizeOfFreeSram);
981 /* ------------------------------------------------------------
982 Queue access related functions
983 ---------------------------------------------------------- */
989 * @fn ixQMgrQReadWithChecks (IxQMgrQId qId,
992 * @brief Read an entry from a queue.
994 * This function reads an entire entry from a queue returning it in entry. The
995 * queue configuration word is read to determine what entry size this queue is
996 * configured for and then the number of words specified by the entry size is
997 * read. entry must be a pointer to a previously allocated array of sufficient
998 * size to hold an entry.
1000 * @note - IX_QMGR_Q_UNDERFLOW is only returned for queues 0-31 as queues 32-63
1001 * do not have an underflow status maintained.
1003 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1004 * @param *entry UINT32 [out] - pointer to the entry word(s).
1006 * @return @li IX_SUCCESS, entry was successfully read.
1007 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter(s).
1008 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
1009 * @return @li IX_QMGR_Q_UNDERFLOW, attempt to read from an empty queue
1013 ixQMgrQReadWithChecks (IxQMgrQId qId,
1019 * @brief Internal structure to facilitate inlining functions in IxQMgr.h
1023 /* fields related to write functions */
1024 UINT32 qOflowStatBitMask; /**< overflow status mask */
1025 UINT32 qWriteCount; /**< queue write count */
1027 /* fields related to read and write functions */
1028 volatile UINT32 *qAccRegAddr; /**< access register */
1029 volatile UINT32 *qUOStatRegAddr; /**< status register */
1030 volatile UINT32 *qConfigRegAddr; /**< config register */
1031 UINT32 qEntrySizeInWords; /**< queue entry size in words */
1032 UINT32 qSizeInEntries; /**< queue size in entries */
1034 /* fields related to read functions */
1035 UINT32 qUflowStatBitMask; /**< underflow status mask */
1036 UINT32 qReadCount; /**< queue read count */
1037 } IxQMgrQInlinedReadWriteInfo;
1042 * @ingroup IxQMgrAPI
1044 * @fn ixQMgrQReadMWordsMinus1 (IxQMgrQId qId,
1047 * @brief This function reads the remaining of the q entry
1048 * for queues configured with many words.
1049 * (the first word of the entry is already read
1050 * in the inlined function and the entry pointer already
1053 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1054 * @param *entry UINT32 [out] - pointer to the entry word(s).
1056 * @return @li IX_SUCCESS, entry was successfully read.
1057 * @return @li IX_QMGR_Q_UNDERFLOW, attempt to read from an empty queue
1061 ixQMgrQReadMWordsMinus1 (IxQMgrQId qId,
1068 * @ingroup IxQMgrAPI
1070 * @fn ixQMgrQRead (IxQMgrQId qId,
1073 * @brief Fast read of an entry from a queue.
1075 * This function is a heavily streamlined version of ixQMgrQReadWithChecks(),
1076 * but performs essentially the same task. It reads an entire entry from a
1077 * queue, returning it in entry which must be a pointer to a previously
1078 * allocated array of sufficient size to hold an entry.
1080 * @note - This function is inlined, to reduce unnecessary function call
1081 * overhead. It does not perform any parameter checks, or update any statistics.
1082 * Also, it does not check that the queue specified by qId has been configured.
1083 * or is in range. It simply reads an entry from the queue, and checks for
1086 * @note - IX_QMGR_Q_UNDERFLOW is only returned for queues 0-31 as queues 32-63
1087 * do not have an underflow status maintained.
1089 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1090 * @param *entry UINT32 [out] - pointer to the entry word(s).
1092 * @return @li IX_SUCCESS, entry was successfully read.
1093 * @return @li IX_QMGR_Q_UNDERFLOW, attempt to read from an empty queue
1096 #ifdef NO_INLINE_APIS
1098 ixQMgrQRead (IxQMgrQId qId,
1101 extern IxQMgrQInlinedReadWriteInfo ixQMgrQInlinedReadWriteInfo[];
1102 extern IX_STATUS ixQMgrQReadMWordsMinus1 (IxQMgrQId qId, UINT32 *entryPtr);
1104 IX_QMGR_INLINE PUBLIC IX_STATUS
1105 ixQMgrQRead (IxQMgrQId qId,
1109 IX_QMGR_INLINE PUBLIC IX_STATUS
1110 ixQMgrQRead (IxQMgrQId qId,
1112 #ifdef NO_INLINE_APIS
1116 IxQMgrQInlinedReadWriteInfo *infoPtr = &ixQMgrQInlinedReadWriteInfo[qId];
1117 UINT32 entry, entrySize;
1119 /* get a new entry */
1120 entrySize = infoPtr->qEntrySizeInWords;
1121 entry = IX_QMGR_INLINE_READ_LONG(infoPtr->qAccRegAddr);
1123 if (entrySize != IX_QMGR_Q_ENTRY_SIZE1)
1126 /* process the remaining part of the entry */
1127 return ixQMgrQReadMWordsMinus1(qId, entryPtr);
1130 /* underflow is available for lower queues only */
1131 if (qId < IX_QMGR_MIN_QUEUPP_QID)
1133 /* the counter of queue entries is decremented. In happy
1134 * day scenario there are many entries in the queue
1135 * and the counter does not reach zero.
1137 if (infoPtr->qReadCount-- == 0)
1139 /* There is maybe no entry in the queue
1140 * qReadCount is now negative, but will be corrected before
1141 * the function returns.
1143 UINT32 qPtrs; /* queue internal pointers */
1145 /* when a queue is empty, the hw guarantees to return
1146 * a null value. If the value is not null, the queue is
1151 /* get the queue status */
1152 UINT32 status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr);
1154 /* check the underflow status */
1155 if (status & infoPtr->qUflowStatBitMask)
1157 /* the queue is empty
1158 * clear the underflow status bit if it was set
1160 IX_QMGR_INLINE_WRITE_LONG(infoPtr->qUOStatRegAddr,
1161 status & ~infoPtr->qUflowStatBitMask);
1163 infoPtr->qReadCount = 0;
1164 return IX_QMGR_Q_UNDERFLOW;
1167 /* store the result */
1170 /* No underflow occured : someone is filling the queue
1171 * or the queue contains null entries.
1172 * The current counter needs to be
1173 * updated from the current number of entries in the queue
1176 /* get snapshot of queue pointers */
1177 qPtrs = IX_QMGR_INLINE_READ_LONG(infoPtr->qConfigRegAddr);
1179 /* Mod subtraction of pointers to get number of words in Q. */
1180 qPtrs = (qPtrs - (qPtrs >> 7)) & 0x7f;
1184 /* no entry in the queue */
1185 infoPtr->qReadCount = 0;
1189 /* convert the number of words inside the queue
1190 * to a number of entries
1192 infoPtr->qReadCount = qPtrs & (infoPtr->qSizeInEntries - 1);
1204 * @ingroup IxQMgrAPI
1206 * @fn ixQMgrQBurstRead (IxQMgrQId qId,
1210 * @brief Read a number of entries from an AQM queue.
1212 * This function will burst read a number of entries from the specified queue.
1213 * The entry size of queue is auto-detected. The function will attempt to
1214 * read as many entries as specified by the numEntries parameter and will
1215 * return an UNDERFLOW if any one of the individual entry reads fail.
1218 * IX_QMGR_Q_UNDERFLOW is only returned for queues 0-31 as queues 32-63
1219 * do not have an underflow status maintained, hence there is a potential for
1220 * silent failure here. This function must be used with caution.
1223 * This function is intended for fast draining of queues, so to make it
1224 * as efficient as possible, it has the following features:
1225 * - This function is inlined, to reduce unnecessary function call overhead.
1226 * - It does not perform any parameter checks, or update any statistics.
1227 * - It does not check that the queue specified by qId has been configured.
1228 * - It does not check that the queue has the number of full entries that
1229 * have been specified to be read. It will read until it finds a NULL entry or
1230 * until the number of specified entries have been read. It always checks for
1231 * underflow after all the reads have been performed.
1232 * Therefore, the client should ensure before calling this function that there
1233 * are enough entries in the queue to read. ixQMgrQNumEntriesGet() will
1234 * provide the number of full entries in a queue.
1235 * ixQMgrQRead() or ixQMgrQReadWithChecks(), which only reads
1236 * a single queue entry per call, should be used instead if the user requires
1237 * checks for UNDERFLOW after each entry read.
1239 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1240 * @param numEntries unsigned [in] - the number of entries to read.
1241 * This number should be greater than 0
1242 * @param *entries UINT32 [out] - the word(s) read.
1244 * @return @li IX_SUCCESS, entries were successfully read.
1245 * @return @li IX_QMGR_Q_UNDERFLOW, attempt to read from an empty queue
1248 #ifdef NO_INLINE_APIS
1250 ixQMgrQBurstRead (IxQMgrQId qId,
1254 IX_QMGR_INLINE PUBLIC IX_STATUS
1255 ixQMgrQBurstRead (IxQMgrQId qId,
1258 #endif /* endif NO_INLINE_APIS */
1260 IX_QMGR_INLINE PUBLIC IX_STATUS
1261 ixQMgrQBurstRead (IxQMgrQId qId,
1264 #ifdef NO_INLINE_APIS
1268 IxQMgrQInlinedReadWriteInfo *infoPtr = &ixQMgrQInlinedReadWriteInfo[qId];
1269 UINT32 nullCheckEntry;
1271 if (infoPtr->qEntrySizeInWords == IX_QMGR_Q_ENTRY_SIZE1)
1273 volatile UINT32 *qAccRegAddr = infoPtr->qAccRegAddr;
1275 /* the code is optimized to take care of data dependencies:
1276 * Durig a read, there are a few cycles needed to get the
1277 * read complete. During these cycles, it is poossible to
1278 * do some CPU, e.g. increment pointers and decrement
1282 /* fetch a queue entry */
1283 nullCheckEntry = IX_QMGR_INLINE_READ_LONG(infoPtr->qAccRegAddr);
1285 /* iterate the specified number of queue entries */
1286 while (--numEntries)
1288 /* check the result of the previous read */
1289 if (nullCheckEntry == 0)
1291 /* if we read a NULL entry, stop. We have underflowed */
1296 /* write the entry */
1297 *entries = nullCheckEntry;
1298 /* fetch next entry */
1299 nullCheckEntry = IX_QMGR_INLINE_READ_LONG(qAccRegAddr);
1300 /* increment the write address */
1304 /* write the pre-fetched entry */
1305 *entries = nullCheckEntry;
1309 IxQMgrQEntrySizeInWords entrySizeInWords = infoPtr->qEntrySizeInWords;
1310 /* read the specified number of queue entries */
1312 while (numEntries--)
1316 for (i = 0; i < (UINT32)entrySizeInWords; i++)
1318 *entries = IX_QMGR_INLINE_READ_LONG(infoPtr->qAccRegAddr + i);
1319 nullCheckEntry |= *entries++;
1322 /* if we read a NULL entry, stop. We have underflowed */
1323 if (nullCheckEntry == 0)
1331 /* reset the current read count : next access to the read function
1332 * will force a underflow status check
1334 infoPtr->qReadCount = 0;
1336 /* Check if underflow occurred on the read */
1337 if (nullCheckEntry == 0 && qId < IX_QMGR_MIN_QUEUPP_QID)
1339 /* get the queue status */
1340 UINT32 status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr);
1342 if (status & infoPtr->qUflowStatBitMask)
1344 /* clear the underflow status bit if it was set */
1345 IX_QMGR_INLINE_WRITE_LONG(infoPtr->qUOStatRegAddr,
1346 status & ~infoPtr->qUflowStatBitMask);
1347 return IX_QMGR_Q_UNDERFLOW;
1356 * @ingroup IxQMgrAPI
1358 * @fn ixQMgrQPeek (IxQMgrQId qId,
1359 unsigned int entryIndex,
1362 * @brief Read an entry from a queue without moving the read pointer.
1364 * This function inspects an entry in a queue. The entry is inspected directly
1365 * in AQM SRAM and is not read from queue access registers. The entry is NOT removed
1366 * from the queue and the read/write pointers are unchanged.
1367 * N.B: The queue should not be accessed when this function is called.
1369 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1370 * @param entryIndex unsigned int [in] - index of entry in queue in the range
1371 * [0].......[current number of entries in queue].
1372 * @param *entry UINT32 [out] - pointer to the entry word(s).
1374 * @return @li IX_SUCCESS, entry was successfully inspected.
1375 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter(s).
1376 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId.
1377 * @return @li IX_QMGR_ENTRY_INDEX_OUT_OF_BOUNDS, an entry does not exist at
1379 * @return @li IX_FAIL, failed to inpected the queue entry.
1382 ixQMgrQPeek (IxQMgrQId qId,
1383 unsigned int entryIndex,
1388 * @ingroup IxQMgrAPI
1390 * @fn ixQMgrQWriteWithChecks (IxQMgrQId qId,
1393 * @brief Write an entry to an AQM queue.
1395 * This function will write the entry size number of words pointed to by entry to
1396 * the queue specified by qId. The queue configuration word is read to
1397 * determine the entry size of queue and the corresponding number of words is
1398 * then written to the queue.
1400 * @note - IX_QMGR_Q_OVERFLOW is only returned for queues 0-31 as queues 32-63
1401 * do not have an overflow status maintained.
1403 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1404 * @param *entry UINT32 [in] - the word(s) to write.
1406 * @return @li IX_SUCCESS, value was successfully written.
1407 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter(s).
1408 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
1409 * @return @li IX_QMGR_Q_OVERFLOW, attempt to write to a full queue
1413 ixQMgrQWriteWithChecks (IxQMgrQId qId,
1418 * @ingroup IxQMgrAPI
1420 * @fn ixQMgrQWrite (IxQMgrQId qId,
1423 * @brief Fast write of an entry to a queue.
1425 * This function is a heavily streamlined version of ixQMgrQWriteWithChecks(),
1426 * but performs essentially the same task. It will write the entry size number
1427 * of words pointed to by entry to the queue specified by qId.
1429 * @note - This function is inlined, to reduce unnecessary function call
1430 * overhead. It does not perform any parameter checks, or update any
1431 * statistics. Also, it does not check that the queue specified by qId has
1432 * been configured. It simply writes an entry to the queue, and checks for
1435 * @note - IX_QMGR_Q_OVERFLOW is only returned for queues 0-31 as queues 32-63
1436 * do not have an overflow status maintained.
1438 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1439 * @param *entry UINT32 [in] - pointer to the entry word(s).
1441 * @return @li IX_SUCCESS, entry was successfully read.
1442 * @return @li IX_QMGR_Q_OVERFLOW, attempt to write to a full queue
1445 #ifdef NO_INLINE_APIS
1447 ixQMgrQWrite (IxQMgrQId qId,
1450 IX_QMGR_INLINE PUBLIC IX_STATUS
1451 ixQMgrQWrite (IxQMgrQId qId,
1453 #endif /* NO_INLINE_APIS */
1455 IX_QMGR_INLINE PUBLIC IX_STATUS
1456 ixQMgrQWrite (IxQMgrQId qId,
1458 #ifdef NO_INLINE_APIS
1462 IxQMgrQInlinedReadWriteInfo *infoPtr = &ixQMgrQInlinedReadWriteInfo[qId];
1465 /* write the entry */
1466 IX_QMGR_INLINE_WRITE_LONG(infoPtr->qAccRegAddr, *entry);
1467 entrySize = infoPtr->qEntrySizeInWords;
1469 if (entrySize != IX_QMGR_Q_ENTRY_SIZE1)
1471 /* process the remaining part of the entry */
1472 volatile UINT32 *qAccRegAddr = infoPtr->qAccRegAddr;
1476 IX_QMGR_INLINE_WRITE_LONG(++qAccRegAddr, *entry);
1478 entrySize = infoPtr->qEntrySizeInWords;
1481 /* overflow is available for lower queues only */
1482 if (qId < IX_QMGR_MIN_QUEUPP_QID)
1484 UINT32 qSize = infoPtr->qSizeInEntries;
1485 /* increment the current number of entries in the queue
1486 * and check for overflow
1488 if (infoPtr->qWriteCount++ == qSize)
1490 /* the queue may have overflow */
1491 UINT32 qPtrs; /* queue internal pointers */
1493 /* get the queue status */
1494 UINT32 status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr);
1496 /* read the status twice because the status may
1497 * not be immediately ready after the write operation
1499 if ((status & infoPtr->qOflowStatBitMask) ||
1500 ((status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr))
1501 & infoPtr->qOflowStatBitMask))
1503 /* the queue is full, clear the overflow status
1506 IX_QMGR_INLINE_WRITE_LONG(infoPtr->qUOStatRegAddr,
1507 status & ~infoPtr->qOflowStatBitMask);
1508 infoPtr->qWriteCount = infoPtr->qSizeInEntries;
1509 return IX_QMGR_Q_OVERFLOW;
1511 /* No overflow occured : someone is draining the queue
1512 * and the current counter needs to be
1513 * updated from the current number of entries in the queue
1516 /* get q pointer snapshot */
1517 qPtrs = IX_QMGR_INLINE_READ_LONG(infoPtr->qConfigRegAddr);
1519 /* Mod subtraction of pointers to get number of words in Q. */
1520 qPtrs = (qPtrs - (qPtrs >> 7)) & 0x7f;
1524 /* the queue may be full at the time of the
1525 * snapshot. Next access will check
1526 * the overflow status again.
1528 infoPtr->qWriteCount = qSize;
1532 /* convert the number of words to a number of entries */
1533 if (entrySize == IX_QMGR_Q_ENTRY_SIZE1)
1535 infoPtr->qWriteCount = qPtrs & (qSize - 1);
1539 infoPtr->qWriteCount = (qPtrs / entrySize) & (qSize - 1);
1550 * @ingroup IxQMgrAPI
1552 * @fn ixQMgrQBurstWrite (IxQMgrQId qId,
1553 unsigned numEntries,
1556 * @brief Write a number of entries to an AQM queue.
1558 * This function will burst write a number of entries to the specified queue.
1559 * The entry size of queue is auto-detected. The function will attempt to
1560 * write as many entries as specified by the numEntries parameter and will
1561 * return an OVERFLOW if any one of the individual entry writes fail.
1564 * IX_QMGR_Q_OVERFLOW is only returned for queues 0-31 as queues 32-63
1565 * do not have an overflow status maintained, hence there is a potential for
1566 * silent failure here. This function must be used with caution.
1569 * This function is intended for fast population of queues, so to make it
1570 * as efficient as possible, it has the following features:
1571 * - This function is inlined, to reduce unnecessary function call overhead.
1572 * - It does not perform any parameter checks, or update any statistics.
1573 * - It does not check that the queue specified by qId has been configured.
1574 * - It does not check that the queue has enough free space to hold the entries
1575 * before writing, and only checks for overflow after all writes have been
1576 * performed. Therefore, the client should ensure before calling this function
1577 * that there is enough free space in the queue to hold the number of entries
1578 * to be written. ixQMgrQWrite() or ixQMgrQWriteWithChecks(), which only writes
1579 * a single queue entry per call, should be used instead if the user requires
1580 * checks for OVERFLOW after each entry written.
1582 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1583 * @param numEntries unsigned [in] - the number of entries to write.
1584 * @param *entries UINT32 [in] - the word(s) to write.
1586 * @return @li IX_SUCCESS, value was successfully written.
1587 * @return @li IX_QMGR_Q_OVERFLOW, attempt to write to a full queue
1590 #ifdef NO_INLINE_APIS
1592 ixQMgrQBurstWrite (IxQMgrQId qId,
1593 unsigned numEntries,
1596 IX_QMGR_INLINE PUBLIC IX_STATUS
1597 ixQMgrQBurstWrite (IxQMgrQId qId,
1598 unsigned numEntries,
1600 #endif /* NO_INLINE_APIS */
1602 IX_QMGR_INLINE PUBLIC IX_STATUS
1603 ixQMgrQBurstWrite (IxQMgrQId qId,
1604 unsigned numEntries,
1606 #ifdef NO_INLINE_APIS
1610 IxQMgrQInlinedReadWriteInfo *infoPtr = &ixQMgrQInlinedReadWriteInfo[qId];
1613 /* update the current write count */
1614 infoPtr->qWriteCount += numEntries;
1616 if (infoPtr->qEntrySizeInWords == IX_QMGR_Q_ENTRY_SIZE1)
1618 volatile UINT32 *qAccRegAddr = infoPtr->qAccRegAddr;
1619 while (numEntries--)
1621 IX_QMGR_INLINE_WRITE_LONG(qAccRegAddr, *entries);
1627 IxQMgrQEntrySizeInWords entrySizeInWords = infoPtr->qEntrySizeInWords;
1630 /* write each queue entry */
1631 while (numEntries--)
1633 /* write the queueEntrySize number of words for each entry */
1634 for (i = 0; i < (UINT32)entrySizeInWords; i++)
1636 IX_QMGR_INLINE_WRITE_LONG((infoPtr->qAccRegAddr + i), *entries);
1642 /* check if the write count overflows */
1643 if (infoPtr->qWriteCount > infoPtr->qSizeInEntries)
1645 /* reset the current write count */
1646 infoPtr->qWriteCount = infoPtr->qSizeInEntries;
1649 /* Check if overflow occurred on the write operation */
1650 if (qId < IX_QMGR_MIN_QUEUPP_QID)
1652 /* get the queue status */
1653 status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr);
1655 /* read the status twice because the status may
1656 * not be ready at the time of the write
1658 if ((status & infoPtr->qOflowStatBitMask) ||
1659 ((status = IX_QMGR_INLINE_READ_LONG(infoPtr->qUOStatRegAddr))
1660 & infoPtr->qOflowStatBitMask))
1662 /* clear the underflow status bit if it was set */
1663 IX_QMGR_INLINE_WRITE_LONG(infoPtr->qUOStatRegAddr,
1664 status & ~infoPtr->qOflowStatBitMask);
1665 return IX_QMGR_Q_OVERFLOW;
1674 * @ingroup IxQMgrAPI
1676 * @fn ixQMgrQPoke (IxQMgrQId qId,
1677 unsigned int entryIndex,
1680 * @brief Write an entry to a queue without moving the write pointer.
1682 * This function modifies an entry in a queue. The entry is modified directly
1683 * in AQM SRAM and not using the queue access registers. The entry is NOT added to the
1684 * queue and the read/write pointers are unchanged.
1685 * N.B: The queue should not be accessed when this function is called.
1687 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1688 * @param entryIndex unsigned int [in] - index of entry in queue in the range
1689 * [0].......[current number of entries in queue].
1690 * @param *entry UINT32 [in] - pointer to the entry word(s).
1692 * @return @li IX_SUCCESS, entry was successfully modified.
1693 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter(s).
1694 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId.
1695 * @return @li IX_QMGR_ENTRY_INDEX_OUT_OF_BOUNDS, an entry does not exist at
1697 * @return @li IX_FAIL, failed to modify the queue entry.
1700 ixQMgrQPoke (IxQMgrQId qId,
1701 unsigned int entryIndex,
1706 * @ingroup IxQMgrAPI
1708 * @fn ixQMgrQNumEntriesGet (IxQMgrQId qId,
1709 unsigned *numEntries)
1711 * @brief Get a snapshot of the number of entries in a queue.
1713 * This function gets the number of entries in a queue.
1715 * @param qId @ref IxQMgrQId [in] qId - the queue idenfifier
1716 * @param *numEntries unsigned [out] - the number of entries in a queue
1718 * @return @li IX_SUCCESS, got the number of entries for the queue
1719 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter(s).
1720 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
1721 * @return @li IX_QMGR_WARNING, could not determine num entries at this time
1725 ixQMgrQNumEntriesGet (IxQMgrQId qId,
1726 unsigned *numEntries);
1730 * @ingroup IxQMgrAPI
1732 * @fn ixQMgrQStatusGetWithChecks (IxQMgrQId qId,
1733 IxQMgrQStatus *qStatus)
1735 * @brief Get a queues status.
1737 * This function reads the specified queues status. A queues status is defined
1738 * by its status flags. For queues 0-31 these flags are E,NE,NF,F. For
1739 * queues 32-63 these flags are NE and F.
1741 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1742 * @param &qStatus @ref IxQMgrQStatus [out] - the status of the specified queue.
1744 * @return @li IX_SUCCESS, queue status was successfully read.
1745 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
1746 * @return @li IX_QMGR_PARAMETER_ERROR, invalid paramter.
1750 ixQMgrQStatusGetWithChecks (IxQMgrQId qId,
1751 IxQMgrQStatus *qStatus);
1755 * @ingroup IxQMgrAPI
1757 * @fn ixQMgrQStatusGet (IxQMgrQId qId,
1758 IxQMgrQStatus *qStatus)
1760 * @brief Fast get of a queue's status.
1762 * This function is a streamlined version of ixQMgrQStatusGetWithChecks(), but
1763 * performs essentially the same task. It reads the specified queue's status.
1764 * A queues status is defined by its status flags. For queues 0-31 these flags
1765 * are E,NE,NF,F. For queues 32-63 these flags are NE and F.
1767 * @note - This function is inlined, to reduce unnecessary function call
1768 * overhead. It does not perform any parameter checks, or update any
1769 * statistics. Also, it does not check that the queue specified by qId has
1770 * been configured. It simply reads the specified queue's status.
1772 * @param qId @ref IxQMgrQId [in] - the queue identifier.
1773 * @param *qStatus @ref IxQMgrQStatus [out] - the status of the specified queue.
1779 #ifdef NO_INLINE_APIS
1781 ixQMgrQStatusGet (IxQMgrQId qId,
1782 IxQMgrQStatus *qStatus);
1784 extern UINT32 ixQMgrAqmIfQueLowStatRegAddr[];
1785 extern UINT32 ixQMgrAqmIfQueLowStatBitsOffset[];
1786 extern UINT32 ixQMgrAqmIfQueLowStatBitsMask;
1787 extern UINT32 ixQMgrAqmIfQueUppStat0RegAddr;
1788 extern UINT32 ixQMgrAqmIfQueUppStat1RegAddr;
1789 extern UINT32 ixQMgrAqmIfQueUppStat0BitMask[];
1790 extern UINT32 ixQMgrAqmIfQueUppStat1BitMask[];
1792 IX_QMGR_INLINE PUBLIC IX_STATUS
1793 ixQMgrQStatusGet (IxQMgrQId qId,
1794 IxQMgrQStatus *qStatus);
1795 #endif /* endif NO_INLINE_APIS */
1797 IX_QMGR_INLINE PUBLIC IX_STATUS
1798 ixQMgrQStatusGet (IxQMgrQId qId,
1799 IxQMgrQStatus *qStatus)
1800 #ifdef NO_INLINE_APIS
1804 /* read the status of a queue in the range 0-31 */
1805 if (qId < IX_QMGR_MIN_QUEUPP_QID)
1807 volatile UINT32 *lowStatRegAddr = (UINT32*)ixQMgrAqmIfQueLowStatRegAddr[qId];
1809 UINT32 lowStatBitsOffset = ixQMgrAqmIfQueLowStatBitsOffset[qId];
1810 UINT32 lowStatBitsMask = ixQMgrAqmIfQueLowStatBitsMask;
1812 /* read the status register for this queue */
1813 *qStatus = IX_QMGR_INLINE_READ_LONG(lowStatRegAddr);
1815 /* mask out the status bits relevant only to this queue */
1816 *qStatus = (*qStatus >> lowStatBitsOffset) & lowStatBitsMask;
1819 else /* read status of a queue in the range 32-63 */
1822 volatile UINT32 *qNearEmptyStatRegAddr = (UINT32*)ixQMgrAqmIfQueUppStat0RegAddr;
1823 volatile UINT32 *qFullStatRegAddr = (UINT32*)ixQMgrAqmIfQueUppStat1RegAddr;
1824 int maskIndex = qId - IX_QMGR_MIN_QUEUPP_QID;
1825 UINT32 qNearEmptyStatBitMask = ixQMgrAqmIfQueUppStat0BitMask[maskIndex];
1826 UINT32 qFullStatBitMask = ixQMgrAqmIfQueUppStat1BitMask[maskIndex];
1828 /* Reset the status bits */
1831 /* Check if the queue is nearly empty */
1832 if (IX_QMGR_INLINE_READ_LONG(qNearEmptyStatRegAddr) & qNearEmptyStatBitMask)
1834 *qStatus |= IX_QMGR_Q_STATUS_NE_BIT_MASK;
1837 /* Check if the queue is full */
1838 if (IX_QMGR_INLINE_READ_LONG(qFullStatRegAddr) & qFullStatBitMask)
1840 *qStatus |= IX_QMGR_Q_STATUS_F_BIT_MASK;
1847 /* ------------------------------------------------------------
1848 Queue dispatch related functions
1849 ---------------------------------------------------------- */
1853 * @ingroup IxQMgrAPI
1855 * @fn ixQMgrDispatcherPrioritySet (IxQMgrQId qId,
1856 IxQMgrPriority priority)
1858 * @brief Set the dispatch priority of a queue.
1860 * This function is called to set the dispatch priority of queue. The effect of
1861 * this function is to add a priority change request to a queue. This queue is
1862 * serviced by @a ixQMgrDispatcherLoopRunA0, @a ixQMgrDispatcherLoopRunB0 or
1863 * @a ixQMgrDispatcherLoopRunB0LLP.
1865 * This function is re-entrant. and can be used from an interrupt context
1867 * @param qId @ref IxQMgrQId [in] - the queue identifier
1868 * @param priority @ref IxQMgrPriority [in] - the new queue dispatch priority
1870 * @return @li IX_SUCCESS, priority change request is queued
1871 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
1872 * @return @li IX_QMGR_Q_INVALID_PRIORITY, specified priority is invalid
1876 ixQMgrDispatcherPrioritySet (IxQMgrQId qId,
1877 IxQMgrPriority priority);
1880 * @ingroup IxQMgrAPI
1882 * @fn ixQMgrNotificationEnable (IxQMgrQId qId,
1883 IxQMgrSourceId sourceId)
1885 * @brief Enable notification on a queue for a specified queue source flag.
1887 * This function is called by a client of the QMgr to enable notifications on a
1888 * specified condition.
1889 * If the condition for the notification is set after the client has called this
1890 * function but before the function has enabled the interrupt source, then the
1891 * notification will not occur.
1892 * For queues 32-63 the notification source is fixed to the NE(Nearly Empty) flag
1893 * and cannot be changed so the sourceId parameter is ignored for these queues.
1894 * The status register is read before the notofication is enabled and is read again
1895 * after the notification has been enabled, if they differ then the warning status
1898 * This function is re-entrant. and can be used from an interrupt context
1900 * @param qId @ref IxQMgrQId [in] - the queue identifier
1901 * @param sourceId @ref IxQMgrSourceId [in] - the interrupt src condition identifier
1903 * @return @li IX_SUCCESS, the interrupt has been enabled for the specified source
1904 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
1905 * @return @li IX_QMGR_INVALID_INT_SOURCE_ID, interrupt source invalid for this queue
1906 * @return @li IX_QMGR_WARNING, the status register may not be constistent
1910 ixQMgrNotificationEnable (IxQMgrQId qId,
1911 IxQMgrSourceId sourceId);
1914 * @ingroup IxQMgrAPI
1916 * @fn ixQMgrNotificationDisable (IxQMgrQId qId)
1918 * @brief Disable notifications on a queue.
1920 * This function is called to disable notifications on a specified queue.
1922 * This function is re-entrant. and can be used from an interrupt context
1924 * @param qId @ref IxQMgrQId [in] - the queue identifier
1926 * @return @li IX_SUCCESS, the interrupt has been disabled
1927 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
1931 ixQMgrNotificationDisable (IxQMgrQId qId);
1935 * @ingroup IxQMgrAPI
1937 * @fn ixQMgrDispatcherLoopRunA0 (IxQMgrDispatchGroup group)
1939 * @brief Run the callback dispatcher.
1941 * This function runs the dispatcher for a group of queues.
1942 * Callbacks are made for interrupts that have occurred on queues within
1943 * the group that have registered callbacks. The order in which queues are
1944 * serviced depends on the queue priorities set by the client.
1945 * This function may be called from interrupt or task context.
1946 * For optimisations that were introduced in IXP42X B0 and supported IXP46X
1947 * the @a ixQMgrDispatcherLoopRunB0, or @a ixQMgrDispatcherLoopRunB0LLP
1950 * This function is not re-entrant.
1952 * @param group @ref IxQMgrDispatchGroup [in] - the group of queues over which the
1953 * dispatcher will run
1957 * @note This function may be called from interrupt or task context.
1958 * However, for optimal performance the choice of context depends also on the
1959 * operating system used.
1963 ixQMgrDispatcherLoopRunA0 (IxQMgrDispatchGroup group);
1967 * @ingroup IxQMgrAPI
1969 * @fn ixQMgrDispatcherLoopRunB0 (IxQMgrDispatchGroup group)
1971 * @brief Run the callback dispatcher.
1973 * The enhanced version of @a ixQMgrDispatcherLoopRunA0 that is optimised for
1974 * features introduced in IXP42X B0 silicon and supported on IXP46X.
1975 * This is the default dispatcher for IXP42X B0 and IXP46X silicon.
1976 * The function runs the dispatcher for a group of queues.
1977 * Callbacks are made for interrupts that have occurred on queues within
1978 * the group that have registered callbacks. The order in which queues are
1979 * serviced depends on the queue priorities set by the client.
1980 * This function may be called from interrupt or task context.
1982 * This function is not re-entrant.
1984 * @param group @ref IxQMgrDispatchGroup [in] - the group of queues over which the
1985 * dispatcher will run
1990 * @note This function may be called from interrupt or task context.
1991 * However, for optimal performance the choice of context depends also on the
1992 * operating system used.
1996 ixQMgrDispatcherLoopRunB0 (IxQMgrDispatchGroup group);
2000 * @ingroup IxQMgrAPI
2002 * @fn ixQMgrDispatcherLoopRunB0LLP (IxQMgrDispatchGroup group)
2004 * @brief Run the callback dispatcher.
2006 * This is a version of the optimised dispatcher for IXP42X B0 and IXP46X,
2007 * @a ixQMgrDispatcherLoopRunB0, with added support for livelock prevention.
2008 * This dispatcher will only be used for the IXP42X B0 or IXP46X silicon if
2009 * feature control indicates that IX_FEATURECTRL_ORIGB0_DISPATCHER is set to
2010 * IX_FEATURE_CTRL_SWCONFIG_DISABLED. Otherwise the @a ixQMgrDispatcherLoopRunB0
2011 * dispatcher will be used (Default).
2013 * When this dispatcher notifies for a queue that is type
2014 * IX_QMGR_TYPE_REALTIME_PERIODIC, notifications for queues that are set
2015 * as type IX_QMGR_REALTIME_SPORADIC are not processed and disabled.
2016 * This helps prevent any tasks resulting from the notification of the
2017 * IX_QMGR_TYPE_REALTIME_PERIODIC type queue to being subject to livelock.
2018 * The function runs the dispatcher for a group of queues.
2019 * Callbacks are made for interrupts that have occurred on queues within
2020 * the group that have registered callbacks. The order in which queues are
2021 * serviced depends on their type along with the queue priorities set by the
2022 * client. This function may be called from interrupt or task context.
2024 * This function is not re-entrant.
2026 * @param group @ref IxQMgrDispatchGroup [in] - the group of queues over which
2027 * the dispatcher will run
2031 * @note This function may be called from interrupt or task context.
2032 * However, for optimal performance the choice of context depends also on the
2033 * operating system used.
2037 ixQMgrDispatcherLoopRunB0LLP (IxQMgrDispatchGroup group);
2041 * @ingroup IxQMgrAPI
2043 * @fn ixQMgrNotificationCallbackSet (IxQMgrQId qId,
2044 IxQMgrCallback callback,
2045 IxQMgrCallbackId callbackId)
2047 * @brief Set the notification callback for a queue.
2049 * This function sets the callback for the specified queue. This callback will
2050 * be called by the dispatcher, and may be called in the context of a interrupt
2051 * If callback has a value of NULL the previously registered callback, if one
2052 * exists will be unregistered.
2054 * @param qId @ref IxQMgrQId [in] - the queue idenfifier
2055 * @param callback @ref IxQMgrCallback [in] - the callback registered for this queue
2056 * @param callbackId @ref IxQMgrCallbackId [in] - the callback identifier
2058 * @return @li IX_SUCCESS, the callback for the specified queue has been set
2059 * @return @li IX_QMGR_Q_NOT_CONFIGURED, the specified qId has not been configured
2063 ixQMgrNotificationCallbackSet (IxQMgrQId qId,
2064 IxQMgrCallback callback,
2065 IxQMgrCallbackId callbackId);
2069 * @ingroup IxQMgrAPI
2071 * @fn ixQMgrDispatcherLoopGet (IxQMgrDispatcherFuncPtr *qDispatcherFuncPtr)
2073 * @brief Get QMgr DispatcherLoopRun for respective silicon device
2075 * This function gets a function pointer to ixQMgrDispatcherLoopRunA0() for IXP42X A0
2076 * Silicon. If the IXP42X B0 or 46X Silicon, the default is the ixQMgrDispatcherLoopRunB0()
2077 * function, however if live lock prevention is enabled a function pointer to
2078 * ixQMgrDispatcherLoopRunB0LLP() is given.
2080 * @param *qDispatchFuncPtr @ref IxQMgrDispatcherFuncPtr [out] -
2081 * the function pointer of QMgr Dispatcher
2085 ixQMgrDispatcherLoopGet (IxQMgrDispatcherFuncPtr *qDispatcherFuncPtr);
2089 * @ingroup IxQMgrAPI
2091 * @fn ixQMgrStickyInterruptRegEnable(void)
2093 * @brief Enable AQM's sticky interrupt register behaviour only available
2096 * When AQM's sticky interrupt register is enabled, interrupt register bit will
2097 * only be cleared when a '1' is written to interrupt register bit and the
2098 * interrupting condition is satisfied, i.e.queue condition does not exist.
2100 * @note This function must be called before any queue is enabled.
2101 * Calling this function after queue is enabled will cause
2102 * undefined results.
2108 ixQMgrStickyInterruptRegEnable(void);
2112 * @ingroup IxQMgrAPI
2114 * @fn ixQMgrCallbackTypeSet(IxQMgrQId qId,
2117 * @brief Set the Callback Type of a queue.
2119 * This function is only used for live lock prevention.
2120 * This function allows the callback type of a queue to be set. The default for
2121 * all queues is IX_QMGR_TYPE_REALTIME_OTHER. Setting the type to
2122 * IX_QMGR_TYPE_REALTIME_SPORADIC means that this queue will have it's
2123 * notifications disabled while there is a task associated with a
2124 * queue of type IX_QMGR_TYPE_REALTIME_PERIODIC running. As live lock
2125 * prevention operates on lower queues, this function should
2126 * be called for lower queues only.
2127 * This function is not re-entrant.
2129 * @param qId @ref IxQMgrQId [in] - the queue identifier
2130 * @param type @ref IxQMgrType [in] - the type of callback
2132 * @return @li IX_SUCCESS, successfully set callback type for the queue entry
2133 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
2134 * @return @li IX_QMGR_PARAMETER_ERROR, invalid parameter(s).
2138 ixQMgrCallbackTypeSet(IxQMgrQId qId,
2142 * @ingroup IxQMgrAPI
2144 * @fn ixQMgrCallbackTypeGet(IxQMgrQId qId,
2147 * @brief Get the Callback Type of a queue.
2149 * This function allows the callback type of a queue to be got. As live lock
2150 * prevention operates on lower queues, this function should
2151 * be called for lower queues only.
2152 * This function is re-entrant.
2154 * @param qId @ref IxQMgrQId [in] - the queue identifier
2155 * @param *type @ref IxQMgrType [out] - the type of callback
2157 * @return @li IX_SUCCESS, successfully set callback type for the queue entry
2158 * @return @li IX_QMGR_Q_NOT_CONFIGURED, queue not configured for this QId
2159 * @return @li IX_QMGR_PARAMETER_ERROR, invalid parameter(s)
2163 ixQMgrCallbackTypeGet(IxQMgrQId qId,
2167 * @ingroup IxQMgrAPI
2169 * @fn ixQMgrPeriodicDone(void)
2171 * @brief Indicate that the Periodic task is completed for LLP
2173 * This function is used as part of live lock prevention.
2174 * A periodic task is a task that results from a queue that
2175 * is set as type IX_QMGR_TYPE_REALTIME_PERIODIC. This function
2176 * should be called to indicate to the dispatcher that the
2177 * the periodic task is completed. This ensures that the notifications
2178 * for queues set as type sporadic queues are re-enabled.
2179 * This function is re-entrant.
2183 ixQMgrPeriodicDone(void);
2187 * @ingroup IxQMgrAPI
2189 * @fn ixQMgrLLPShow(int resetStats)
2191 * @brief Print out the live lock prevention statistics when in debug mode.
2193 * This function prints out statistics related to the livelock. These
2194 * statistics are only collected in debug mode.
2195 * This function is not re-entrant.
2197 * @param resetStats @ref int [in] - if set the the stats are reset.
2201 ixQMgrLLPShow(int resetStats);
2204 #endif /* IXQMGR_H */
2207 * @} defgroup IxQMgrAPI