2 * @file IxNpeMhConfig_p.h
4 * @author Intel Corporation
7 * @brief This file contains the private API for the Configuration module.
11 * IXP400 SW Release version 2.0
13 * -- Copyright Notice --
16 * Copyright 2001-2005, Intel Corporation.
17 * All rights reserved.
20 * SPDX-License-Identifier: BSD-3-Clause
22 * -- End of Copyright Notice --
26 * @defgroup IxNpeMhConfig_p IxNpeMhConfig_p
28 * @brief The private API for the Configuration module.
33 #ifndef IXNPEMHCONFIG_P_H
34 #define IXNPEMHCONFIG_P_H
39 #include "IxNpeMhMacros_p.h"
44 /* enable function inlining for performances */
45 #ifdef IXNPEMHSOLICITEDCBMGR_C
46 /* Non-inline functions will be defined in this translation unit.
47 Reason is that in GNU Compiler, if the Optimization is turn off, all extern inline
48 functions will not be compiled.
51 # ifndef IXNPEMHCONFIG_INLINE
52 # define IXNPEMHCONFIG_INLINE
55 # ifndef IXNPEMHCONFIG_INLINE
56 # define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
62 # ifndef IXNPEMHCONFIG_INLINE
63 # define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
64 # endif /* IXNPEMHCONFIG_INLINE */
65 #endif /* IXNPEMHSOLICITEDCBMGR_C */
67 * Typedefs and #defines, etc.
70 typedef void (*IxNpeMhConfigIsr) (int); /**< ISR function pointer */
73 * @struct IxNpeMhConfigNpeInfo
75 * @brief This structure is used to maintain the configuration information
76 * associated with an NPE.
81 IxOsalMutex mutex; /**< mutex */
82 UINT32 interruptId; /**< interrupt ID */
83 UINT32 virtualRegisterBase; /**< register virtual base address */
84 UINT32 statusRegister; /**< status register virtual address */
85 UINT32 controlRegister; /**< control register virtual address */
86 UINT32 inFifoRegister; /**< inFIFO register virutal address */
87 UINT32 outFifoRegister; /**< outFIFO register virtual address */
88 IxNpeMhConfigIsr isr; /**< isr routine for handling interrupt */
89 BOOL oldInterruptState; /**< old interrupt state (true => enabled) */
90 } IxNpeMhConfigNpeInfo;
94 * #defines for function return types, etc.
97 /**< NPE register base address */
98 #define IX_NPEMH_NPE_BASE (IX_OSAL_IXP400_PERIPHERAL_PHYS_BASE)
100 #define IX_NPEMH_NPEA_OFFSET (0x6000) /**< NPE-A register base offset */
101 #define IX_NPEMH_NPEB_OFFSET (0x7000) /**< NPE-B register base offset */
102 #define IX_NPEMH_NPEC_OFFSET (0x8000) /**< NPE-C register base offset */
104 #define IX_NPEMH_NPESTAT_OFFSET (0x002C) /**< NPE status register offset */
105 #define IX_NPEMH_NPECTL_OFFSET (0x0030) /**< NPE control register offset */
106 #define IX_NPEMH_NPEFIFO_OFFSET (0x0038) /**< NPE FIFO register offset */
108 /** NPE-A register base address */
109 #define IX_NPEMH_NPEA_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEA_OFFSET)
110 /** NPE-B register base address */
111 #define IX_NPEMH_NPEB_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEB_OFFSET)
112 /** NPE-C register base address */
113 #define IX_NPEMH_NPEC_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEC_OFFSET)
115 /* NPE-A configuration */
117 /** NPE-A interrupt */
118 #define IX_NPEMH_NPEA_INT (IX_OSAL_IXP400_NPEA_IRQ_LVL)
119 /** NPE-A FIFO register */
120 #define IX_NPEMH_NPEA_FIFO (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPEFIFO_OFFSET)
121 /** NPE-A control register */
122 #define IX_NPEMH_NPEA_CTL (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPECTL_OFFSET)
123 /** NPE-A status register */
124 #define IX_NPEMH_NPEA_STAT (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPESTAT_OFFSET)
126 /* NPE-B configuration */
128 /** NPE-B interrupt */
129 #define IX_NPEMH_NPEB_INT (IX_OSAL_IXP400_NPEB_IRQ_LVL)
130 /** NPE-B FIFO register */
131 #define IX_NPEMH_NPEB_FIFO (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPEFIFO_OFFSET)
132 /** NPE-B control register */
133 #define IX_NPEMH_NPEB_CTL (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPECTL_OFFSET)
134 /** NPE-B status register */
135 #define IX_NPEMH_NPEB_STAT (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPESTAT_OFFSET)
137 /* NPE-C configuration */
139 /** NPE-C interrupt */
140 #define IX_NPEMH_NPEC_INT (IX_OSAL_IXP400_NPEC_IRQ_LVL)
141 /** NPE-C FIFO register */
142 #define IX_NPEMH_NPEC_FIFO (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPEFIFO_OFFSET)
143 /** NPE-C control register */
144 #define IX_NPEMH_NPEC_CTL (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPECTL_OFFSET)
145 /** NPE-C status register */
146 #define IX_NPEMH_NPEC_STAT (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPESTAT_OFFSET)
148 /* NPE control register bit definitions */
149 #define IX_NPEMH_NPE_CTL_OFE (1 << 16) /**< OutFifoEnable */
150 #define IX_NPEMH_NPE_CTL_IFE (1 << 17) /**< InFifoEnable */
151 #define IX_NPEMH_NPE_CTL_OFEWE (1 << 24) /**< OutFifoEnableWriteEnable */
152 #define IX_NPEMH_NPE_CTL_IFEWE (1 << 25) /**< InFifoEnableWriteEnable */
154 /* NPE status register bit definitions */
155 #define IX_NPEMH_NPE_STAT_OFNE (1 << 16) /**< OutFifoNotEmpty */
156 #define IX_NPEMH_NPE_STAT_IFNF (1 << 17) /**< InFifoNotFull */
157 #define IX_NPEMH_NPE_STAT_OFNF (1 << 18) /**< OutFifoNotFull */
158 #define IX_NPEMH_NPE_STAT_IFNE (1 << 19) /**< InFifoNotEmpty */
159 #define IX_NPEMH_NPE_STAT_MBINT (1 << 20) /**< Mailbox interrupt */
160 #define IX_NPEMH_NPE_STAT_IFINT (1 << 21) /**< InFifo interrupt */
161 #define IX_NPEMH_NPE_STAT_OFINT (1 << 22) /**< OutFifo interrupt */
162 #define IX_NPEMH_NPE_STAT_WFINT (1 << 23) /**< WatchFifo interrupt */
166 * Variable declarations. Externs are followed by static variables.
168 extern IxNpeMhConfigNpeInfo ixNpeMhConfigNpeInfo[IX_NPEMH_NUM_NPES];
172 * Prototypes for interface functions.
176 * @fn void ixNpeMhConfigInitialize (
177 IxNpeMhNpeInterrupts npeInterrupts)
179 * @brief This function initialises the Configuration module.
181 * @param IxNpeMhNpeInterrupts npeInterrupts (in) - whether or not to
182 * service the NPE "outFIFO not empty" interrupts.
184 * @return No return value.
187 void ixNpeMhConfigInitialize (
188 IxNpeMhNpeInterrupts npeInterrupts);
191 * @fn void ixNpeMhConfigUninit (void)
193 * @brief This function uninitialises the Configuration module.
195 * @return No return value.
198 void ixNpeMhConfigUninit (void);
201 * @fn void ixNpeMhConfigIsrRegister (
203 IxNpeMhConfigIsr isr)
205 * @brief This function registers an ISR to handle NPE "outFIFO not
208 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
210 * @param IxNpeMhConfigIsr isr (in) - the ISR function pointer that the
211 * interrupt will trigger.
213 * @return No return value.
216 void ixNpeMhConfigIsrRegister (
218 IxNpeMhConfigIsr isr);
221 * @fn BOOL ixNpeMhConfigNpeInterruptEnable (
224 * @brief This function enables a NPE's "outFIFO not empty" interrupt.
226 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
229 * @return Returns the previous state of the interrupt (true => enabled).
232 BOOL ixNpeMhConfigNpeInterruptEnable (
236 * @fn BOOL ixNpeMhConfigNpeInterruptDisable (
239 * @brief This function disables a NPE's "outFIFO not empty" interrupt
241 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
244 * @return Returns the previous state of the interrupt (true => enabled).
247 BOOL ixNpeMhConfigNpeInterruptDisable (
251 * @fn IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
252 IxNpeMhMessage message)
254 * @brief This function gets the ID of a message.
256 * @param IxNpeMhMessage message (in) - the message to get the ID of.
258 * @return the ID of the message
261 IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
262 IxNpeMhMessage message);
265 * @fn BOOL ixNpeMhConfigNpeIdIsValid (
268 * @brief This function checks to see if a NPE ID is valid.
270 * @param IxNpeMhNpeId npeId (in) - the NPE ID to validate.
272 * @return true if the NPE ID is valid, otherwise false.
275 BOOL ixNpeMhConfigNpeIdIsValid (
279 * @fn void ixNpeMhConfigLockGet (
282 * @brief This function gets a lock for exclusive NPE interaction, and
283 * disables the NPE's "outFIFO not empty" interrupt.
285 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to get the
286 * lock and disable its interrupt.
288 * @return No return value.
291 void ixNpeMhConfigLockGet (
295 * @fn void ixNpeMhConfigLockRelease (
298 * @brief This function releases a lock for exclusive NPE interaction, and
299 * enables the NPE's "outFIFO not empty" interrupt.
301 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to release
302 * the lock and enable its interrupt.
304 * @return No return value.
307 void ixNpeMhConfigLockRelease (
311 * @fn BOOL ixNpeMhConfigInFifoIsEmpty (
314 * @brief This inline function checks if a NPE's inFIFO is empty.
316 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
319 * @return true if the inFIFO is empty, otherwise false.
322 IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsEmpty (
326 * @fn BOOL ixNpeMhConfigInFifoIsFull (
329 * @brief This inline function checks if a NPE's inFIFO is full.
331 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
334 * @return true if the inFIFO is full, otherwise false.
337 IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsFull (
341 * @fn BOOL ixNpeMhConfigOutFifoIsEmpty (
344 * @brief This inline function checks if a NPE's outFIFO is empty.
346 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
349 * @return true if the outFIFO is empty, otherwise false.
352 IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsEmpty (
356 * @fn BOOL ixNpeMhConfigOutFifoIsFull (
359 * @brief This inline function checks if a NPE's outFIFO is full.
361 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
364 * @return true if the outFIFO is full, otherwise false.
367 IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsFull (
371 * @fn IX_STATUS ixNpeMhConfigInFifoWrite (
373 IxNpeMhMessage message)
375 * @brief This function writes a message to a NPE's inFIFO. The caller
376 * must first check that the NPE's inFifo is not full. After writing the first
377 * word of the message, this function will keep polling NPE's inFIFO is not
378 * full to write the second word. If inFIFO is not available after maximum
379 * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
380 * status to indicate NPE hang / halt.
382 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
383 * will be written to.
384 * @param IxNpeMhMessage message (in) - The message to write.
386 * @return The function returns a status indicating success, failure or timeout.
389 IX_STATUS ixNpeMhConfigInFifoWrite (
391 IxNpeMhMessage message);
394 * @fn IX_STATUS ixNpeMhConfigOutFifoRead (
396 IxNpeMhMessage *message)
398 * @brief This function reads a message from a NPE's outFIFO. The caller
399 * must first check that the NPE's outFifo is not empty. After reading the first
400 * word of the message, this function will keep polling NPE's outFIFO is not
401 * empty to read the second word. If outFIFO is empty after maximum
402 * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
403 * status to indicate NPE hang / halt.
405 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
407 * @param IxNpeMhMessage message (out) - The message read.
409 * @return The function returns a status indicating success, failure or timeout.
412 IX_STATUS ixNpeMhConfigOutFifoRead (
414 IxNpeMhMessage *message);
417 * @fn void ixNpeMhConfigShow (
420 * @brief This function will display the current state of the Configuration
423 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to display state
426 * @return No return value.
429 void ixNpeMhConfigShow (
433 * @fn void ixNpeMhConfigShowReset (
436 * @brief This function will reset the current state of the Configuration
439 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to reset state
442 * @return No return value.
445 void ixNpeMhConfigShowReset (
453 * This inline function checks if a NPE's inFIFO is empty.
457 BOOL ixNpeMhConfigInFifoIsEmpty (
461 volatile UINT32 *statusReg =
462 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
464 /* get the IFNE (InFifoNotEmpty) bit of the status register */
465 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifne, IX_NPEMH_NPE_STAT_IFNE);
467 /* if the IFNE status bit is unset then the inFIFO is empty */
473 * This inline function checks if a NPE's inFIFO is full.
476 BOOL ixNpeMhConfigInFifoIsFull (
480 volatile UINT32 *statusReg =
481 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
483 /* get the IFNF (InFifoNotFull) bit of the status register */
484 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifnf, IX_NPEMH_NPE_STAT_IFNF);
486 /* if the IFNF status bit is unset then the inFIFO is full */
492 * This inline function checks if a NPE's outFIFO is empty.
495 BOOL ixNpeMhConfigOutFifoIsEmpty (
499 volatile UINT32 *statusReg =
500 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
502 /* get the OFNE (OutFifoNotEmpty) bit of the status register */
503 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofne, IX_NPEMH_NPE_STAT_OFNE);
505 /* if the OFNE status bit is unset then the outFIFO is empty */
510 * This inline function checks if a NPE's outFIFO is full.
513 BOOL ixNpeMhConfigOutFifoIsFull (
517 volatile UINT32 *statusReg =
518 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
520 /* get the OFNF (OutFifoNotFull) bit of the status register */
521 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofnf, IX_NPEMH_NPE_STAT_OFNF);
523 /* if the OFNF status bit is unset then the outFIFO is full */
527 #endif /* IXNPEMHCONFIG_P_H */
530 * @} defgroup IxNpeMhConfig_p