Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file IxQMgrAqmIf_p.h |
| 3 | * |
| 4 | * @author Intel Corporation |
| 5 | * @date 30-Oct-2001 |
| 6 | * |
| 7 | * @brief The IxQMgrAqmIf sub-component provides a number of inline |
| 8 | * functions for performing I/O on the AQM. |
| 9 | * |
| 10 | * Because some functions contained in this module are inline and are |
| 11 | * used in other modules (within the QMgr component) the definitions are |
| 12 | * contained in this header file. The "normal" use of inline functions |
| 13 | * is to use the inline functions in the module in which they are |
| 14 | * defined. In this case these inline functions are used in external |
| 15 | * modules and therefore the use of "inline extern". What this means |
| 16 | * is as follows: if a function foo is declared as "inline extern"this |
| 17 | * definition is only used for inlining, in no case is the function |
| 18 | * compiled on its own. If the compiler cannot inline the function it |
| 19 | * becomes an external reference. Therefore in IxQMgrAqmIf.c all |
| 20 | * inline functions are defined without the "inline extern" specifier |
| 21 | * and so define the external references. In all other modules these |
| 22 | * funtions are defined as "inline extern". |
| 23 | * |
| 24 | * |
| 25 | * @par |
| 26 | * IXP400 SW Release version 2.0 |
| 27 | * |
| 28 | * -- Copyright Notice -- |
| 29 | * |
| 30 | * @par |
| 31 | * Copyright 2001-2005, Intel Corporation. |
| 32 | * All rights reserved. |
| 33 | * |
| 34 | * @par |
Wolfgang Denk | cb3761e | 2013-07-28 22:12:47 +0200 | [diff] [blame] | 35 | * SPDX-License-Identifier: BSD-3-Clause |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 36 | * @par |
| 37 | * -- End of Copyright Notice -- |
| 38 | */ |
| 39 | |
| 40 | #ifndef IXQMGRAQMIF_P_H |
| 41 | #define IXQMGRAQMIF_P_H |
| 42 | |
| 43 | #include "IxOsalTypes.h" |
| 44 | |
| 45 | /* |
| 46 | * inline definition |
| 47 | */ |
| 48 | |
| 49 | #ifdef IX_OSAL_INLINE_ALL |
| 50 | /* If IX_OSAL_INLINE_ALL is set then each inlineable API functions will be defined as |
| 51 | inline functions */ |
| 52 | #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN |
| 53 | #else |
| 54 | #ifdef IXQMGRAQMIF_C |
| 55 | #ifndef IX_QMGR_AQMIF_INLINE |
| 56 | #define IX_QMGR_AQMIF_INLINE |
| 57 | #endif |
| 58 | #else |
| 59 | #ifndef IX_QMGR_AQMIF_INLINE |
| 60 | #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN |
| 61 | #endif |
| 62 | #endif /* IXQMGRAQMIF_C */ |
| 63 | #endif /* IX_OSAL_INLINE */ |
| 64 | |
| 65 | |
| 66 | /* |
| 67 | * User defined include files. |
| 68 | */ |
| 69 | #include "IxQMgr.h" |
| 70 | #include "IxQMgrLog_p.h" |
| 71 | #include "IxQMgrQCfg_p.h" |
| 72 | |
| 73 | /* Because this file contains inline functions which will be compiled into |
| 74 | * other components, we need to ensure that the IX_COMPONENT_NAME define |
| 75 | * is set to ix_qmgr while this code is being compiled. This will ensure |
| 76 | * that the correct implementation is provided for the memory access macros |
| 77 | * IX_OSAL_READ_LONG and IX_OSAL_WRITE_LONG which are used in this file. |
| 78 | * This must be done before including "IxOsalMemAccess.h" |
| 79 | */ |
| 80 | #define IX_QMGR_AQMIF_SAVED_COMPONENT_NAME IX_COMPONENT_NAME |
| 81 | #undef IX_COMPONENT_NAME |
| 82 | #define IX_COMPONENT_NAME ix_qmgr |
| 83 | #include "IxOsal.h" |
| 84 | |
| 85 | /* |
| 86 | * #defines and macros used in this file. |
| 87 | */ |
| 88 | |
| 89 | /* Number of bytes per word */ |
| 90 | #define IX_QMGR_NUM_BYTES_PER_WORD 4 |
| 91 | |
| 92 | /* Underflow bit mask */ |
| 93 | #define IX_QMGR_UNDERFLOW_BIT_OFFSET 0x0 |
| 94 | |
| 95 | /* Overflow bit mask */ |
| 96 | #define IX_QMGR_OVERFLOW_BIT_OFFSET 0x1 |
| 97 | |
| 98 | /* Queue access register, queue 0 */ |
| 99 | #define IX_QMGR_QUEACC0_OFFSET 0x0000 |
| 100 | |
| 101 | /* Size of queue access register in words */ |
| 102 | #define IX_QMGR_QUEACC_SIZE 0x4/*words*/ |
| 103 | |
| 104 | /* Queue status register, queues 0-7 */ |
| 105 | #define IX_QMGR_QUELOWSTAT0_OFFSET (IX_QMGR_QUEACC0_OFFSET +\ |
| 106 | (IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD)) |
| 107 | |
| 108 | /* Queue status register, queues 8-15 */ |
| 109 | #define IX_QMGR_QUELOWSTAT1_OFFSET (IX_QMGR_QUELOWSTAT0_OFFSET +\ |
| 110 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 111 | |
| 112 | /* Queue status register, queues 16-23 */ |
| 113 | #define IX_QMGR_QUELOWSTAT2_OFFSET (IX_QMGR_QUELOWSTAT1_OFFSET +\ |
| 114 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 115 | |
| 116 | /* Queue status register, queues 24-31 */ |
| 117 | #define IX_QMGR_QUELOWSTAT3_OFFSET (IX_QMGR_QUELOWSTAT2_OFFSET +\ |
| 118 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 119 | |
| 120 | /* Queue status register Q status bits mask */ |
| 121 | #define IX_QMGR_QUELOWSTAT_QUE_STS_BITS_MASK 0xF |
| 122 | |
| 123 | /* Size of queue 0-31 status register */ |
| 124 | #define IX_QMGR_QUELOWSTAT_SIZE 0x4 /*words*/ |
| 125 | |
| 126 | /* The number of queues' status specified per word */ |
| 127 | #define IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD 0x8 |
| 128 | |
| 129 | /* Queue UF/OF status register queues 0-15 */ |
| 130 | #define IX_QMGR_QUEUOSTAT0_OFFSET (IX_QMGR_QUELOWSTAT3_OFFSET +\ |
| 131 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 132 | /* Queue UF/OF status register queues 16-31 */ |
| 133 | #define IX_QMGR_QUEUOSTAT1_OFFSET (IX_QMGR_QUEUOSTAT0_OFFSET +\ |
| 134 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 135 | |
| 136 | /* The number of queues' underflow/overflow status specified per word */ |
| 137 | #define IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD 0x10 |
| 138 | |
| 139 | /* Queue NE status register, queues 32-63 */ |
| 140 | #define IX_QMGR_QUEUPPSTAT0_OFFSET (IX_QMGR_QUEUOSTAT1_OFFSET +\ |
| 141 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 142 | |
| 143 | /* Queue F status register, queues 32-63 */ |
| 144 | #define IX_QMGR_QUEUPPSTAT1_OFFSET (IX_QMGR_QUEUPPSTAT0_OFFSET +\ |
| 145 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 146 | |
| 147 | /* Size of queue 32-63 status register */ |
| 148 | #define IX_QMGR_QUEUPPSTAT_SIZE 0x2 /*words*/ |
| 149 | |
| 150 | /* The number of queues' status specified per word */ |
| 151 | #define IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD 0x20 |
| 152 | |
| 153 | /* Queue INT source select register, queues 0-7 */ |
| 154 | #define IX_QMGR_INT0SRCSELREG0_OFFSET (IX_QMGR_QUEUPPSTAT1_OFFSET +\ |
| 155 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 156 | |
| 157 | /* Queue INT source select register, queues 8-15 */ |
| 158 | #define IX_QMGR_INT0SRCSELREG1_OFFSET (IX_QMGR_INT0SRCSELREG0_OFFSET+\ |
| 159 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 160 | |
| 161 | /* Queue INT source select register, queues 16-23 */ |
| 162 | #define IX_QMGR_INT0SRCSELREG2_OFFSET (IX_QMGR_INT0SRCSELREG1_OFFSET+\ |
| 163 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 164 | |
| 165 | /* Queue INT source select register, queues 24-31 */ |
| 166 | #define IX_QMGR_INT0SRCSELREG3_OFFSET (IX_QMGR_INT0SRCSELREG2_OFFSET+\ |
| 167 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 168 | |
| 169 | /* Size of interrupt source select reegister */ |
| 170 | #define IX_QMGR_INT0SRCSELREG_SIZE 0x4 /*words*/ |
| 171 | |
| 172 | /* The number of queues' interrupt source select specified per word*/ |
| 173 | #define IX_QMGR_INTSRC_NUM_QUE_PER_WORD 0x8 |
| 174 | |
| 175 | /* Queue INT enable register, queues 0-31 */ |
| 176 | #define IX_QMGR_QUEIEREG0_OFFSET (IX_QMGR_INT0SRCSELREG3_OFFSET +\ |
| 177 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 178 | |
| 179 | /* Queue INT enable register, queues 32-63 */ |
| 180 | #define IX_QMGR_QUEIEREG1_OFFSET (IX_QMGR_QUEIEREG0_OFFSET +\ |
| 181 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 182 | |
| 183 | /* Queue INT register, queues 0-31 */ |
| 184 | #define IX_QMGR_QINTREG0_OFFSET (IX_QMGR_QUEIEREG1_OFFSET +\ |
| 185 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 186 | |
| 187 | /* Queue INT register, queues 32-63 */ |
| 188 | #define IX_QMGR_QINTREG1_OFFSET (IX_QMGR_QINTREG0_OFFSET +\ |
| 189 | IX_QMGR_NUM_BYTES_PER_WORD) |
| 190 | |
| 191 | /* Size of interrupt register */ |
| 192 | #define IX_QMGR_QINTREG_SIZE 0x2 /*words*/ |
| 193 | |
| 194 | /* Number of queues' status specified per word */ |
| 195 | #define IX_QMGR_QINTREG_NUM_QUE_PER_WORD 0x20 |
| 196 | |
| 197 | /* Number of bits per queue interrupt status */ |
| 198 | #define IX_QMGR_QINTREG_BITS_PER_QUEUE 0x1 |
| 199 | #define IX_QMGR_QINTREG_BIT_OFFSET 0x1 |
| 200 | |
| 201 | /* Size of address space not used by AQM */ |
| 202 | #define IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES 0x1bC0 |
| 203 | |
| 204 | /* Queue config register, queue 0 */ |
| 205 | #define IX_QMGR_QUECONFIG_BASE_OFFSET (IX_QMGR_QINTREG1_OFFSET +\ |
| 206 | IX_QMGR_NUM_BYTES_PER_WORD +\ |
| 207 | IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES) |
| 208 | |
| 209 | /* Total size of configuration words */ |
| 210 | #define IX_QMGR_QUECONFIG_SIZE 0x100 |
| 211 | |
| 212 | /* Start of SRAM queue buffer space */ |
| 213 | #define IX_QMGR_QUEBUFFER_SPACE_OFFSET (IX_QMGR_QUECONFIG_BASE_OFFSET +\ |
| 214 | IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_NUM_BYTES_PER_WORD) |
| 215 | |
| 216 | /* Total bits in a word */ |
| 217 | #define BITS_PER_WORD 32 |
| 218 | |
| 219 | /* Size of queue buffer space */ |
| 220 | #define IX_QMGR_QUE_BUFFER_SPACE_SIZE 0x1F00 |
| 221 | |
| 222 | /* |
| 223 | * This macro will return the address of the access register for the |
| 224 | * queue specified by qId |
| 225 | */ |
| 226 | #define IX_QMGR_Q_ACCESS_ADDR_GET(qId)\ |
| 227 | (((qId) * (IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD))\ |
| 228 | + IX_QMGR_QUEACC0_OFFSET) |
| 229 | |
| 230 | /* |
| 231 | * Bit location of bit-3 of INT0SRCSELREG0 register to enabled |
| 232 | * sticky interrupt register. |
| 233 | */ |
| 234 | #define IX_QMGR_INT0SRCSELREG0_BIT3 3 |
| 235 | |
| 236 | /* |
| 237 | * Variable declerations global to this file. Externs are followed by |
| 238 | * statics. |
| 239 | */ |
| 240 | extern UINT32 aqmBaseAddress; |
| 241 | |
| 242 | /* |
| 243 | * Function declarations. |
| 244 | */ |
| 245 | void |
| 246 | ixQMgrAqmIfInit (void); |
| 247 | |
| 248 | void |
| 249 | ixQMgrAqmIfUninit (void); |
| 250 | |
| 251 | unsigned |
| 252 | ixQMgrAqmIfLog2 (unsigned number); |
| 253 | |
| 254 | void |
| 255 | ixQMgrAqmIfQRegisterBitsWrite (IxQMgrQId qId, |
| 256 | UINT32 registerBaseAddrOffset, |
| 257 | unsigned queuesPerRegWord, |
| 258 | UINT32 value); |
| 259 | |
| 260 | void |
| 261 | ixQMgrAqmIfQStatusCheckValsCalc (IxQMgrQId qId, |
| 262 | IxQMgrSourceId srcSel, |
| 263 | unsigned int *statusWordOffset, |
| 264 | UINT32 *checkValue, |
| 265 | UINT32 *mask); |
| 266 | /* |
| 267 | * The Xscale software allways deals with logical addresses and so the |
| 268 | * base address of the AQM memory space is not a hardcoded value. This |
| 269 | * function must be called before any other function in this component. |
| 270 | * NO CHECKING is performed to ensure that the base address has been |
| 271 | * set. |
| 272 | */ |
| 273 | void |
| 274 | ixQMgrAqmIfBaseAddressSet (UINT32 address); |
| 275 | |
| 276 | /* |
| 277 | * Get the base address of the AQM memory space. |
| 278 | */ |
| 279 | void |
| 280 | ixQMgrAqmIfBaseAddressGet (UINT32 *address); |
| 281 | |
| 282 | /* |
| 283 | * Get the sram base address |
| 284 | */ |
| 285 | void |
| 286 | ixQMgrAqmIfSramBaseAddressGet (UINT32 *address); |
| 287 | |
| 288 | /* |
| 289 | * Read a queue status |
| 290 | */ |
| 291 | void |
| 292 | ixQMgrAqmIfQueStatRead (IxQMgrQId qId, |
| 293 | IxQMgrQStatus* status); |
| 294 | |
| 295 | |
| 296 | /* |
| 297 | * Set INT0SRCSELREG0 Bit3 |
| 298 | */ |
| 299 | void ixQMgrAqmIfIntSrcSelReg0Bit3Set (void); |
| 300 | |
| 301 | |
| 302 | /* |
| 303 | * Set the interrupt source |
| 304 | */ |
| 305 | void |
| 306 | ixQMgrAqmIfIntSrcSelWrite (IxQMgrQId qId, |
| 307 | IxQMgrSourceId sourceId); |
| 308 | |
| 309 | /* |
| 310 | * Enable interruptson a queue |
| 311 | */ |
| 312 | void |
| 313 | ixQMgrAqmIfQInterruptEnable (IxQMgrQId qId); |
| 314 | |
| 315 | /* |
| 316 | * Disable interrupt on a quee |
| 317 | */ |
| 318 | void |
| 319 | ixQMgrAqmIfQInterruptDisable (IxQMgrQId qId); |
| 320 | |
| 321 | /* |
| 322 | * Write the config register of the specified queue |
| 323 | */ |
| 324 | void |
| 325 | ixQMgrAqmIfQueCfgWrite (IxQMgrQId qId, |
| 326 | IxQMgrQSizeInWords qSizeInWords, |
| 327 | IxQMgrQEntrySizeInWords entrySizeInWords, |
| 328 | UINT32 freeSRAMAddress); |
| 329 | |
| 330 | /* |
| 331 | * read fields from the config of the specified queue. |
| 332 | */ |
| 333 | void |
| 334 | ixQMgrAqmIfQueCfgRead (IxQMgrQId qId, |
| 335 | unsigned int numEntries, |
| 336 | UINT32 *baseAddress, |
| 337 | unsigned int *ne, |
| 338 | unsigned int *nf, |
| 339 | UINT32 *readPtr, |
| 340 | UINT32 *writePtr); |
| 341 | |
| 342 | /* |
| 343 | * Set the ne and nf watermark level on a queue. |
| 344 | */ |
| 345 | void |
| 346 | ixQMgrAqmIfWatermarkSet (IxQMgrQId qId, |
| 347 | unsigned ne, |
| 348 | unsigned nf); |
| 349 | |
| 350 | /* Inspect an entry without moving the read pointer */ |
| 351 | IX_STATUS |
| 352 | ixQMgrAqmIfQPeek (IxQMgrQId qId, |
| 353 | unsigned int entryIndex, |
| 354 | unsigned int *entry); |
| 355 | |
| 356 | /* Modify an entry without moving the write pointer */ |
| 357 | IX_STATUS |
| 358 | ixQMgrAqmIfQPoke (IxQMgrQId qId, |
| 359 | unsigned int entryIndex, |
| 360 | unsigned int *entry); |
| 361 | |
| 362 | /* |
| 363 | * Function prototype for inline functions. For description refers to |
| 364 | * the functions defintion below. |
| 365 | */ |
| 366 | IX_QMGR_AQMIF_INLINE void |
| 367 | ixQMgrAqmIfWordWrite (VUINT32 *address, |
| 368 | UINT32 word); |
| 369 | |
| 370 | IX_QMGR_AQMIF_INLINE void |
| 371 | ixQMgrAqmIfWordRead (VUINT32 *address, |
| 372 | UINT32 *word); |
| 373 | |
| 374 | IX_QMGR_AQMIF_INLINE void |
| 375 | ixQMgrAqmIfQPop (IxQMgrQId qId, |
| 376 | IxQMgrQEntrySizeInWords numWords, |
| 377 | UINT32 *entry); |
| 378 | |
| 379 | IX_QMGR_AQMIF_INLINE void |
| 380 | ixQMgrAqmIfQPush (IxQMgrQId qId, |
| 381 | IxQMgrQEntrySizeInWords numWords, |
| 382 | UINT32 *entry); |
| 383 | |
| 384 | IX_QMGR_AQMIF_INLINE void |
| 385 | ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group, |
| 386 | UINT32 *qStatusWords); |
| 387 | |
| 388 | IX_QMGR_AQMIF_INLINE BOOL |
| 389 | ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords, |
| 390 | UINT32 *newQStatusWords, |
| 391 | unsigned int statusWordOffset, |
| 392 | UINT32 checkValue, |
| 393 | UINT32 mask); |
| 394 | |
| 395 | IX_QMGR_AQMIF_INLINE BOOL |
| 396 | ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId, |
| 397 | UINT32 registerBaseAddrOffset, |
| 398 | unsigned queuesPerRegWord, |
| 399 | unsigned relativeBitOffset, |
| 400 | BOOL reset); |
| 401 | |
| 402 | IX_QMGR_AQMIF_INLINE BOOL |
| 403 | ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId); |
| 404 | |
| 405 | IX_QMGR_AQMIF_INLINE BOOL |
| 406 | ixQMgrAqmIfOverflowCheck (IxQMgrQId qId); |
| 407 | |
| 408 | IX_QMGR_AQMIF_INLINE UINT32 |
| 409 | ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId, |
| 410 | UINT32 registerBaseAddrOffset, |
| 411 | unsigned queuesPerRegWord); |
| 412 | IX_QMGR_AQMIF_INLINE void |
| 413 | ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group, |
| 414 | UINT32 reg); |
| 415 | IX_QMGR_AQMIF_INLINE void |
| 416 | ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group, |
| 417 | UINT32 *regVal); |
| 418 | |
| 419 | IX_QMGR_AQMIF_INLINE void |
| 420 | ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId, |
| 421 | IxQMgrQStatus *status); |
| 422 | |
| 423 | IX_QMGR_AQMIF_INLINE void |
| 424 | ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId, |
| 425 | IxQMgrQStatus *status); |
| 426 | |
| 427 | IX_QMGR_AQMIF_INLINE void |
| 428 | ixQMgrAqmIfQueStatRead (IxQMgrQId qId, |
| 429 | IxQMgrQStatus *qStatus); |
| 430 | |
| 431 | IX_QMGR_AQMIF_INLINE unsigned |
| 432 | ixQMgrAqmIfPow2NumDivide (unsigned numerator, |
| 433 | unsigned denominator); |
| 434 | |
| 435 | IX_QMGR_AQMIF_INLINE void |
| 436 | ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group, |
| 437 | UINT32 *regVal); |
| 438 | /* |
| 439 | * Inline functions |
| 440 | */ |
| 441 | |
| 442 | /* |
| 443 | * This inline function is used by other QMgr components to write one |
| 444 | * word to the specified address. |
| 445 | */ |
| 446 | IX_QMGR_AQMIF_INLINE void |
| 447 | ixQMgrAqmIfWordWrite (VUINT32 *address, |
| 448 | UINT32 word) |
| 449 | { |
| 450 | IX_OSAL_WRITE_LONG(address, word); |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * This inline function is used by other QMgr components to read a |
| 455 | * word from the specified address. |
| 456 | */ |
| 457 | IX_QMGR_AQMIF_INLINE void |
| 458 | ixQMgrAqmIfWordRead (VUINT32 *address, |
| 459 | UINT32 *word) |
| 460 | { |
| 461 | *word = IX_OSAL_READ_LONG(address); |
| 462 | } |
| 463 | |
| 464 | |
| 465 | /* |
| 466 | * This inline function is used by other QMgr components to pop an |
| 467 | * entry off the specified queue. |
| 468 | */ |
| 469 | IX_QMGR_AQMIF_INLINE void |
| 470 | ixQMgrAqmIfQPop (IxQMgrQId qId, |
| 471 | IxQMgrQEntrySizeInWords numWords, |
| 472 | UINT32 *entry) |
| 473 | { |
| 474 | volatile UINT32 *accRegAddr; |
| 475 | |
| 476 | accRegAddr = (UINT32*)(aqmBaseAddress + |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 477 | IX_QMGR_Q_ACCESS_ADDR_GET(qId)); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 478 | |
| 479 | switch (numWords) |
| 480 | { |
| 481 | case IX_QMGR_Q_ENTRY_SIZE1: |
| 482 | ixQMgrAqmIfWordRead (accRegAddr, entry); |
| 483 | break; |
| 484 | case IX_QMGR_Q_ENTRY_SIZE2: |
| 485 | ixQMgrAqmIfWordRead (accRegAddr++, entry++); |
| 486 | ixQMgrAqmIfWordRead (accRegAddr, entry); |
| 487 | break; |
| 488 | case IX_QMGR_Q_ENTRY_SIZE4: |
| 489 | ixQMgrAqmIfWordRead (accRegAddr++, entry++); |
| 490 | ixQMgrAqmIfWordRead (accRegAddr++, entry++); |
| 491 | ixQMgrAqmIfWordRead (accRegAddr++, entry++); |
| 492 | ixQMgrAqmIfWordRead (accRegAddr, entry); |
| 493 | break; |
| 494 | default: |
| 495 | IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPop"); |
| 496 | break; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | * This inline function is used by other QMgr components to push an |
| 502 | * entry to the specified queue. |
| 503 | */ |
| 504 | IX_QMGR_AQMIF_INLINE void |
| 505 | ixQMgrAqmIfQPush (IxQMgrQId qId, |
| 506 | IxQMgrQEntrySizeInWords numWords, |
| 507 | UINT32 *entry) |
| 508 | { |
| 509 | volatile UINT32 *accRegAddr; |
| 510 | |
| 511 | accRegAddr = (UINT32*)(aqmBaseAddress + |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 512 | IX_QMGR_Q_ACCESS_ADDR_GET(qId)); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 513 | |
| 514 | switch (numWords) |
| 515 | { |
| 516 | case IX_QMGR_Q_ENTRY_SIZE1: |
| 517 | ixQMgrAqmIfWordWrite (accRegAddr, *entry); |
| 518 | break; |
| 519 | case IX_QMGR_Q_ENTRY_SIZE2: |
| 520 | ixQMgrAqmIfWordWrite (accRegAddr++, *entry++); |
| 521 | ixQMgrAqmIfWordWrite (accRegAddr, *entry); |
| 522 | break; |
| 523 | case IX_QMGR_Q_ENTRY_SIZE4: |
| 524 | ixQMgrAqmIfWordWrite (accRegAddr++, *entry++); |
| 525 | ixQMgrAqmIfWordWrite (accRegAddr++, *entry++); |
| 526 | ixQMgrAqmIfWordWrite (accRegAddr++, *entry++); |
| 527 | ixQMgrAqmIfWordWrite (accRegAddr, *entry); |
| 528 | break; |
| 529 | default: |
| 530 | IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPush"); |
| 531 | break; |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | * The AQM interrupt registers contains a bit for each AQM queue |
| 537 | * specifying the queue (s) that cause an interrupt to fire. This |
| 538 | * function is called by IxQMGrDispatcher component. |
| 539 | */ |
| 540 | IX_QMGR_AQMIF_INLINE void |
| 541 | ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group, |
| 542 | UINT32 *qStatusWords) |
| 543 | { |
| 544 | volatile UINT32 *regAddress = NULL; |
| 545 | |
| 546 | if (group == IX_QMGR_QUELOW_GROUP) |
| 547 | { |
| 548 | regAddress = (UINT32*)(aqmBaseAddress + |
| 549 | IX_QMGR_QUELOWSTAT0_OFFSET); |
| 550 | |
| 551 | ixQMgrAqmIfWordRead (regAddress++, qStatusWords++); |
| 552 | ixQMgrAqmIfWordRead (regAddress++, qStatusWords++); |
| 553 | ixQMgrAqmIfWordRead (regAddress++, qStatusWords++); |
| 554 | ixQMgrAqmIfWordRead (regAddress, qStatusWords); |
| 555 | } |
| 556 | else /* We have the upper queues */ |
| 557 | { |
| 558 | /* Only need to read the Nearly Empty status register for |
| 559 | * queues 32-63 as for therse queues the interrtupt source |
| 560 | * condition is fixed to Nearly Empty |
| 561 | */ |
| 562 | regAddress = (UINT32*)(aqmBaseAddress + |
| 563 | IX_QMGR_QUEUPPSTAT0_OFFSET); |
| 564 | ixQMgrAqmIfWordRead (regAddress, qStatusWords); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | |
| 569 | /* |
| 570 | * This function check if the status for a queue has changed between |
| 571 | * 2 snapshots and if it has, that the status matches a particular |
| 572 | * value after masking. |
| 573 | */ |
| 574 | IX_QMGR_AQMIF_INLINE BOOL |
| 575 | ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords, |
| 576 | UINT32 *newQStatusWords, |
| 577 | unsigned int statusWordOffset, |
| 578 | UINT32 checkValue, |
| 579 | UINT32 mask) |
| 580 | { |
| 581 | if (((oldQStatusWords[statusWordOffset] & mask) != |
| 582 | (newQStatusWords[statusWordOffset] & mask)) && |
| 583 | ((newQStatusWords[statusWordOffset] & mask) == checkValue)) |
| 584 | { |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 585 | return true; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 586 | } |
| 587 | |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 588 | return false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | /* |
| 592 | * The AQM interrupt register contains a bit for each AQM queue |
| 593 | * specifying the queue (s) that cause an interrupt to fire. This |
| 594 | * function is called by IxQMgrDispatcher component. |
| 595 | */ |
| 596 | IX_QMGR_AQMIF_INLINE void |
| 597 | ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group, |
| 598 | UINT32 *regVal) |
| 599 | { |
| 600 | volatile UINT32 *regAddress; |
| 601 | |
| 602 | if (group == IX_QMGR_QUELOW_GROUP) |
| 603 | { |
| 604 | regAddress = (UINT32*)(aqmBaseAddress + |
| 605 | IX_QMGR_QINTREG0_OFFSET); |
| 606 | } |
| 607 | else |
| 608 | { |
| 609 | regAddress = (UINT32*)(aqmBaseAddress + |
| 610 | IX_QMGR_QINTREG1_OFFSET); |
| 611 | } |
| 612 | |
| 613 | ixQMgrAqmIfWordRead (regAddress, regVal); |
| 614 | } |
| 615 | |
| 616 | /* |
| 617 | * The AQM interrupt enable register contains a bit for each AQM queue. |
| 618 | * This function reads the interrupt enable register. This |
| 619 | * function is called by IxQMgrDispatcher component. |
| 620 | */ |
| 621 | IX_QMGR_AQMIF_INLINE void |
| 622 | ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group, |
| 623 | UINT32 *regVal) |
| 624 | { |
| 625 | volatile UINT32 *regAddress; |
| 626 | |
| 627 | if (group == IX_QMGR_QUELOW_GROUP) |
| 628 | { |
| 629 | regAddress = (UINT32*)(aqmBaseAddress + |
| 630 | IX_QMGR_QUEIEREG0_OFFSET); |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | regAddress = (UINT32*)(aqmBaseAddress + |
| 635 | IX_QMGR_QUEIEREG1_OFFSET); |
| 636 | } |
| 637 | |
| 638 | ixQMgrAqmIfWordRead (regAddress, regVal); |
| 639 | } |
| 640 | |
| 641 | |
| 642 | /* |
| 643 | * This inline function will read the status bit of a queue |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 644 | * specified by qId. If reset is true the bit is cleared. |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 645 | */ |
| 646 | IX_QMGR_AQMIF_INLINE BOOL |
| 647 | ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId, |
| 648 | UINT32 registerBaseAddrOffset, |
| 649 | unsigned queuesPerRegWord, |
| 650 | unsigned relativeBitOffset, |
| 651 | BOOL reset) |
| 652 | { |
| 653 | UINT32 actualBitOffset; |
| 654 | volatile UINT32 *registerAddress; |
| 655 | UINT32 registerWord; |
| 656 | |
| 657 | /* |
| 658 | * Calculate the registerAddress |
| 659 | * multiple queues split accross registers |
| 660 | */ |
| 661 | registerAddress = (UINT32*)(aqmBaseAddress + |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 662 | registerBaseAddrOffset + |
| 663 | ((qId / queuesPerRegWord) * |
| 664 | IX_QMGR_NUM_BYTES_PER_WORD)); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 665 | |
| 666 | /* |
| 667 | * Get the status word |
| 668 | */ |
| 669 | ixQMgrAqmIfWordRead (registerAddress, ®isterWord); |
| 670 | |
| 671 | /* |
| 672 | * Calculate the actualBitOffset |
| 673 | * status for multiple queues stored in one register |
| 674 | */ |
| 675 | actualBitOffset = (relativeBitOffset + 1) << |
| 676 | ((qId & (queuesPerRegWord - 1)) * (BITS_PER_WORD / queuesPerRegWord)); |
| 677 | |
| 678 | /* Check if the status bit is set */ |
| 679 | if (registerWord & actualBitOffset) |
| 680 | { |
| 681 | /* Clear the bit if reset */ |
| 682 | if (reset) |
| 683 | { |
| 684 | ixQMgrAqmIfWordWrite (registerAddress, registerWord & (~actualBitOffset)); |
| 685 | } |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 686 | return true; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | /* Bit not set */ |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 690 | return false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | |
| 694 | /* |
| 695 | * @ingroup IxQmgrAqmIfAPI |
| 696 | * |
| 697 | * @brief Read the underflow status of a queue |
| 698 | * |
| 699 | * This inline function will read the underflow status of a queue |
| 700 | * specified by qId. |
| 701 | * |
| 702 | */ |
| 703 | IX_QMGR_AQMIF_INLINE BOOL |
| 704 | ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId) |
| 705 | { |
| 706 | if (qId < IX_QMGR_MIN_QUEUPP_QID) |
| 707 | { |
| 708 | return (ixQMgrAqmIfRegisterBitCheck (qId, |
| 709 | IX_QMGR_QUEUOSTAT0_OFFSET, |
| 710 | IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD, |
| 711 | IX_QMGR_UNDERFLOW_BIT_OFFSET, |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 712 | true/*reset*/)); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 713 | } |
| 714 | else |
| 715 | { |
| 716 | /* Qs 32-63 have no underflow status */ |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 717 | return false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 718 | } |
| 719 | } |
| 720 | |
| 721 | /* |
| 722 | * This inline function will read the overflow status of a queue |
| 723 | * specified by qId. |
| 724 | */ |
| 725 | IX_QMGR_AQMIF_INLINE BOOL |
| 726 | ixQMgrAqmIfOverflowCheck (IxQMgrQId qId) |
| 727 | { |
| 728 | if (qId < IX_QMGR_MIN_QUEUPP_QID) |
| 729 | { |
| 730 | return (ixQMgrAqmIfRegisterBitCheck (qId, |
| 731 | IX_QMGR_QUEUOSTAT0_OFFSET, |
| 732 | IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD, |
| 733 | IX_QMGR_OVERFLOW_BIT_OFFSET, |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 734 | true/*reset*/)); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 735 | } |
| 736 | else |
| 737 | { |
| 738 | /* Qs 32-63 have no overflow status */ |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 739 | return false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 740 | } |
| 741 | } |
| 742 | |
| 743 | /* |
| 744 | * This inline function will read the status bits of a queue |
| 745 | * specified by qId. |
| 746 | */ |
| 747 | IX_QMGR_AQMIF_INLINE UINT32 |
| 748 | ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId, |
| 749 | UINT32 registerBaseAddrOffset, |
| 750 | unsigned queuesPerRegWord) |
| 751 | { |
| 752 | volatile UINT32 *registerAddress; |
| 753 | UINT32 registerWord; |
| 754 | UINT32 statusBitsMask; |
| 755 | UINT32 bitsPerQueue; |
| 756 | |
| 757 | bitsPerQueue = BITS_PER_WORD / queuesPerRegWord; |
| 758 | |
| 759 | /* |
| 760 | * Calculate the registerAddress |
| 761 | * multiple queues split accross registers |
| 762 | */ |
| 763 | registerAddress = (UINT32*)(aqmBaseAddress + |
| 764 | registerBaseAddrOffset + |
| 765 | ((qId / queuesPerRegWord) * |
| 766 | IX_QMGR_NUM_BYTES_PER_WORD)); |
| 767 | /* |
| 768 | * Read the status word |
| 769 | */ |
| 770 | ixQMgrAqmIfWordRead (registerAddress, ®isterWord); |
| 771 | |
| 772 | |
| 773 | /* |
| 774 | * Calculate the mask for the status bits for this queue. |
| 775 | */ |
| 776 | statusBitsMask = ((1 << bitsPerQueue) - 1); |
| 777 | |
| 778 | /* |
| 779 | * Shift the status word so it is right justified |
| 780 | */ |
| 781 | registerWord >>= ((qId & (queuesPerRegWord - 1)) * bitsPerQueue); |
| 782 | |
| 783 | /* |
| 784 | * Mask out all bar the status bits for this queue |
| 785 | */ |
| 786 | return (registerWord &= statusBitsMask); |
| 787 | } |
| 788 | |
| 789 | /* |
| 790 | * This function is called by IxQMgrDispatcher to set the contents of |
| 791 | * the AQM interrupt register. |
| 792 | */ |
| 793 | IX_QMGR_AQMIF_INLINE void |
| 794 | ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group, |
| 795 | UINT32 reg) |
| 796 | { |
| 797 | volatile UINT32 *address; |
| 798 | |
| 799 | if (group == IX_QMGR_QUELOW_GROUP) |
| 800 | { |
| 801 | address = (UINT32*)(aqmBaseAddress + |
| 802 | IX_QMGR_QINTREG0_OFFSET); |
| 803 | } |
| 804 | else |
| 805 | { |
| 806 | address = (UINT32*)(aqmBaseAddress + |
| 807 | IX_QMGR_QINTREG1_OFFSET); |
| 808 | } |
| 809 | |
| 810 | ixQMgrAqmIfWordWrite (address, reg); |
| 811 | } |
| 812 | |
| 813 | /* |
| 814 | * Read the status of a queue in the range 0-31. |
| 815 | * |
| 816 | * This function is used by other QMgr components to read the |
| 817 | * status of the queue specified by qId. |
| 818 | */ |
| 819 | IX_QMGR_AQMIF_INLINE void |
| 820 | ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId, |
| 821 | IxQMgrQStatus *status) |
| 822 | { |
| 823 | /* Read the general status bits */ |
| 824 | *status = ixQMgrAqmIfQRegisterBitsRead (qId, |
| 825 | IX_QMGR_QUELOWSTAT0_OFFSET, |
| 826 | IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD); |
| 827 | } |
| 828 | |
| 829 | /* |
| 830 | * This function will read the status of the queue specified |
| 831 | * by qId. |
| 832 | */ |
| 833 | IX_QMGR_AQMIF_INLINE void |
| 834 | ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId, |
| 835 | IxQMgrQStatus *status) |
| 836 | { |
| 837 | /* Reset the status bits */ |
| 838 | *status = 0; |
| 839 | |
| 840 | /* |
| 841 | * Check if the queue is nearly empty, |
| 842 | * N.b. QUPP stat register contains status for regs 32-63 at each |
| 843 | * bit position so subtract 32 to get bit offset |
| 844 | */ |
| 845 | if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID), |
| 846 | IX_QMGR_QUEUPPSTAT0_OFFSET, |
| 847 | IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD, |
| 848 | 0/*relativeBitOffset*/, |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 849 | false/*!reset*/)) |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 850 | { |
| 851 | *status |= IX_QMGR_Q_STATUS_NE_BIT_MASK; |
| 852 | } |
| 853 | |
| 854 | /* |
| 855 | * Check if the queue is full, |
| 856 | * N.b. QUPP stat register contains status for regs 32-63 at each |
| 857 | * bit position so subtract 32 to get bit offset |
| 858 | */ |
| 859 | if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID), |
| 860 | IX_QMGR_QUEUPPSTAT1_OFFSET, |
| 861 | IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD, |
| 862 | 0/*relativeBitOffset*/, |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 863 | false/*!reset*/)) |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 864 | { |
| 865 | *status |= IX_QMGR_Q_STATUS_F_BIT_MASK; |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | /* |
| 870 | * This function is used by other QMgr components to read the |
| 871 | * status of the queue specified by qId. |
| 872 | */ |
| 873 | IX_QMGR_AQMIF_INLINE void |
| 874 | ixQMgrAqmIfQueStatRead (IxQMgrQId qId, |
| 875 | IxQMgrQStatus *qStatus) |
| 876 | { |
| 877 | if (qId < IX_QMGR_MIN_QUEUPP_QID) |
| 878 | { |
| 879 | ixQMgrAqmIfQueLowStatRead (qId, qStatus); |
| 880 | } |
| 881 | else |
| 882 | { |
| 883 | ixQMgrAqmIfQueUppStatRead (qId, qStatus); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | |
| 888 | /* |
| 889 | * This function performs a mod division |
| 890 | */ |
| 891 | IX_QMGR_AQMIF_INLINE unsigned |
| 892 | ixQMgrAqmIfPow2NumDivide (unsigned numerator, |
| 893 | unsigned denominator) |
| 894 | { |
| 895 | /* Number is evenly divisable by 2 */ |
| 896 | return (numerator >> ixQMgrAqmIfLog2 (denominator)); |
| 897 | } |
| 898 | |
| 899 | /* Restore IX_COMPONENT_NAME */ |
| 900 | #undef IX_COMPONENT_NAME |
| 901 | #define IX_COMPONENT_NAME IX_QMGR_AQMIF_SAVED_COMPONENT_NAME |
| 902 | |
| 903 | #endif/*IXQMGRAQMIF_P_H*/ |