IxQMgrAqmIf_p.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  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
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. * 1. Redistributions of source code must retain the above copyright
  39. * notice, this list of conditions and the following disclaimer.
  40. * 2. Redistributions in binary form must reproduce the above copyright
  41. * notice, this list of conditions and the following disclaimer in the
  42. * documentation and/or other materials provided with the distribution.
  43. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  44. * may be used to endorse or promote products derived from this software
  45. * without specific prior written permission.
  46. *
  47. * @par
  48. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  49. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  51. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  52. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  53. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  54. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  56. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  57. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  58. * SUCH DAMAGE.
  59. *
  60. * @par
  61. * -- End of Copyright Notice --
  62. */
  63. #ifndef IXQMGRAQMIF_P_H
  64. #define IXQMGRAQMIF_P_H
  65. #include "IxOsalTypes.h"
  66. /*
  67. * inline definition
  68. */
  69. #ifdef IX_OSAL_INLINE_ALL
  70. /* If IX_OSAL_INLINE_ALL is set then each inlineable API functions will be defined as
  71. inline functions */
  72. #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN
  73. #else
  74. #ifdef IXQMGRAQMIF_C
  75. #ifndef IX_QMGR_AQMIF_INLINE
  76. #define IX_QMGR_AQMIF_INLINE
  77. #endif
  78. #else
  79. #ifndef IX_QMGR_AQMIF_INLINE
  80. #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN
  81. #endif
  82. #endif /* IXQMGRAQMIF_C */
  83. #endif /* IX_OSAL_INLINE */
  84. /*
  85. * User defined include files.
  86. */
  87. #include "IxQMgr.h"
  88. #include "IxQMgrLog_p.h"
  89. #include "IxQMgrQCfg_p.h"
  90. /* Because this file contains inline functions which will be compiled into
  91. * other components, we need to ensure that the IX_COMPONENT_NAME define
  92. * is set to ix_qmgr while this code is being compiled. This will ensure
  93. * that the correct implementation is provided for the memory access macros
  94. * IX_OSAL_READ_LONG and IX_OSAL_WRITE_LONG which are used in this file.
  95. * This must be done before including "IxOsalMemAccess.h"
  96. */
  97. #define IX_QMGR_AQMIF_SAVED_COMPONENT_NAME IX_COMPONENT_NAME
  98. #undef IX_COMPONENT_NAME
  99. #define IX_COMPONENT_NAME ix_qmgr
  100. #include "IxOsal.h"
  101. /*
  102. * #defines and macros used in this file.
  103. */
  104. /* Number of bytes per word */
  105. #define IX_QMGR_NUM_BYTES_PER_WORD 4
  106. /* Underflow bit mask */
  107. #define IX_QMGR_UNDERFLOW_BIT_OFFSET 0x0
  108. /* Overflow bit mask */
  109. #define IX_QMGR_OVERFLOW_BIT_OFFSET 0x1
  110. /* Queue access register, queue 0 */
  111. #define IX_QMGR_QUEACC0_OFFSET 0x0000
  112. /* Size of queue access register in words */
  113. #define IX_QMGR_QUEACC_SIZE 0x4/*words*/
  114. /* Queue status register, queues 0-7 */
  115. #define IX_QMGR_QUELOWSTAT0_OFFSET (IX_QMGR_QUEACC0_OFFSET +\
  116. (IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD))
  117. /* Queue status register, queues 8-15 */
  118. #define IX_QMGR_QUELOWSTAT1_OFFSET (IX_QMGR_QUELOWSTAT0_OFFSET +\
  119. IX_QMGR_NUM_BYTES_PER_WORD)
  120. /* Queue status register, queues 16-23 */
  121. #define IX_QMGR_QUELOWSTAT2_OFFSET (IX_QMGR_QUELOWSTAT1_OFFSET +\
  122. IX_QMGR_NUM_BYTES_PER_WORD)
  123. /* Queue status register, queues 24-31 */
  124. #define IX_QMGR_QUELOWSTAT3_OFFSET (IX_QMGR_QUELOWSTAT2_OFFSET +\
  125. IX_QMGR_NUM_BYTES_PER_WORD)
  126. /* Queue status register Q status bits mask */
  127. #define IX_QMGR_QUELOWSTAT_QUE_STS_BITS_MASK 0xF
  128. /* Size of queue 0-31 status register */
  129. #define IX_QMGR_QUELOWSTAT_SIZE 0x4 /*words*/
  130. /* The number of queues' status specified per word */
  131. #define IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD 0x8
  132. /* Queue UF/OF status register queues 0-15 */
  133. #define IX_QMGR_QUEUOSTAT0_OFFSET (IX_QMGR_QUELOWSTAT3_OFFSET +\
  134. IX_QMGR_NUM_BYTES_PER_WORD)
  135. /* Queue UF/OF status register queues 16-31 */
  136. #define IX_QMGR_QUEUOSTAT1_OFFSET (IX_QMGR_QUEUOSTAT0_OFFSET +\
  137. IX_QMGR_NUM_BYTES_PER_WORD)
  138. /* The number of queues' underflow/overflow status specified per word */
  139. #define IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD 0x10
  140. /* Queue NE status register, queues 32-63 */
  141. #define IX_QMGR_QUEUPPSTAT0_OFFSET (IX_QMGR_QUEUOSTAT1_OFFSET +\
  142. IX_QMGR_NUM_BYTES_PER_WORD)
  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. /* Size of queue 32-63 status register */
  147. #define IX_QMGR_QUEUPPSTAT_SIZE 0x2 /*words*/
  148. /* The number of queues' status specified per word */
  149. #define IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD 0x20
  150. /* Queue INT source select register, queues 0-7 */
  151. #define IX_QMGR_INT0SRCSELREG0_OFFSET (IX_QMGR_QUEUPPSTAT1_OFFSET +\
  152. IX_QMGR_NUM_BYTES_PER_WORD)
  153. /* Queue INT source select register, queues 8-15 */
  154. #define IX_QMGR_INT0SRCSELREG1_OFFSET (IX_QMGR_INT0SRCSELREG0_OFFSET+\
  155. IX_QMGR_NUM_BYTES_PER_WORD)
  156. /* Queue INT source select register, queues 16-23 */
  157. #define IX_QMGR_INT0SRCSELREG2_OFFSET (IX_QMGR_INT0SRCSELREG1_OFFSET+\
  158. IX_QMGR_NUM_BYTES_PER_WORD)
  159. /* Queue INT source select register, queues 24-31 */
  160. #define IX_QMGR_INT0SRCSELREG3_OFFSET (IX_QMGR_INT0SRCSELREG2_OFFSET+\
  161. IX_QMGR_NUM_BYTES_PER_WORD)
  162. /* Size of interrupt source select reegister */
  163. #define IX_QMGR_INT0SRCSELREG_SIZE 0x4 /*words*/
  164. /* The number of queues' interrupt source select specified per word*/
  165. #define IX_QMGR_INTSRC_NUM_QUE_PER_WORD 0x8
  166. /* Queue INT enable register, queues 0-31 */
  167. #define IX_QMGR_QUEIEREG0_OFFSET (IX_QMGR_INT0SRCSELREG3_OFFSET +\
  168. IX_QMGR_NUM_BYTES_PER_WORD)
  169. /* Queue INT enable register, queues 32-63 */
  170. #define IX_QMGR_QUEIEREG1_OFFSET (IX_QMGR_QUEIEREG0_OFFSET +\
  171. IX_QMGR_NUM_BYTES_PER_WORD)
  172. /* Queue INT register, queues 0-31 */
  173. #define IX_QMGR_QINTREG0_OFFSET (IX_QMGR_QUEIEREG1_OFFSET +\
  174. IX_QMGR_NUM_BYTES_PER_WORD)
  175. /* Queue INT register, queues 32-63 */
  176. #define IX_QMGR_QINTREG1_OFFSET (IX_QMGR_QINTREG0_OFFSET +\
  177. IX_QMGR_NUM_BYTES_PER_WORD)
  178. /* Size of interrupt register */
  179. #define IX_QMGR_QINTREG_SIZE 0x2 /*words*/
  180. /* Number of queues' status specified per word */
  181. #define IX_QMGR_QINTREG_NUM_QUE_PER_WORD 0x20
  182. /* Number of bits per queue interrupt status */
  183. #define IX_QMGR_QINTREG_BITS_PER_QUEUE 0x1
  184. #define IX_QMGR_QINTREG_BIT_OFFSET 0x1
  185. /* Size of address space not used by AQM */
  186. #define IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES 0x1bC0
  187. /* Queue config register, queue 0 */
  188. #define IX_QMGR_QUECONFIG_BASE_OFFSET (IX_QMGR_QINTREG1_OFFSET +\
  189. IX_QMGR_NUM_BYTES_PER_WORD +\
  190. IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES)
  191. /* Total size of configuration words */
  192. #define IX_QMGR_QUECONFIG_SIZE 0x100
  193. /* Start of SRAM queue buffer space */
  194. #define IX_QMGR_QUEBUFFER_SPACE_OFFSET (IX_QMGR_QUECONFIG_BASE_OFFSET +\
  195. IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_NUM_BYTES_PER_WORD)
  196. /* Total bits in a word */
  197. #define BITS_PER_WORD 32
  198. /* Size of queue buffer space */
  199. #define IX_QMGR_QUE_BUFFER_SPACE_SIZE 0x1F00
  200. /*
  201. * This macro will return the address of the access register for the
  202. * queue specified by qId
  203. */
  204. #define IX_QMGR_Q_ACCESS_ADDR_GET(qId)\
  205. (((qId) * (IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD))\
  206. + IX_QMGR_QUEACC0_OFFSET)
  207. /*
  208. * Bit location of bit-3 of INT0SRCSELREG0 register to enabled
  209. * sticky interrupt register.
  210. */
  211. #define IX_QMGR_INT0SRCSELREG0_BIT3 3
  212. /*
  213. * Variable declerations global to this file. Externs are followed by
  214. * statics.
  215. */
  216. extern UINT32 aqmBaseAddress;
  217. /*
  218. * Function declarations.
  219. */
  220. void
  221. ixQMgrAqmIfInit (void);
  222. void
  223. ixQMgrAqmIfUninit (void);
  224. unsigned
  225. ixQMgrAqmIfLog2 (unsigned number);
  226. void
  227. ixQMgrAqmIfQRegisterBitsWrite (IxQMgrQId qId,
  228. UINT32 registerBaseAddrOffset,
  229. unsigned queuesPerRegWord,
  230. UINT32 value);
  231. void
  232. ixQMgrAqmIfQStatusCheckValsCalc (IxQMgrQId qId,
  233. IxQMgrSourceId srcSel,
  234. unsigned int *statusWordOffset,
  235. UINT32 *checkValue,
  236. UINT32 *mask);
  237. /*
  238. * The Xscale software allways deals with logical addresses and so the
  239. * base address of the AQM memory space is not a hardcoded value. This
  240. * function must be called before any other function in this component.
  241. * NO CHECKING is performed to ensure that the base address has been
  242. * set.
  243. */
  244. void
  245. ixQMgrAqmIfBaseAddressSet (UINT32 address);
  246. /*
  247. * Get the base address of the AQM memory space.
  248. */
  249. void
  250. ixQMgrAqmIfBaseAddressGet (UINT32 *address);
  251. /*
  252. * Get the sram base address
  253. */
  254. void
  255. ixQMgrAqmIfSramBaseAddressGet (UINT32 *address);
  256. /*
  257. * Read a queue status
  258. */
  259. void
  260. ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
  261. IxQMgrQStatus* status);
  262. /*
  263. * Set INT0SRCSELREG0 Bit3
  264. */
  265. void ixQMgrAqmIfIntSrcSelReg0Bit3Set (void);
  266. /*
  267. * Set the interrupt source
  268. */
  269. void
  270. ixQMgrAqmIfIntSrcSelWrite (IxQMgrQId qId,
  271. IxQMgrSourceId sourceId);
  272. /*
  273. * Enable interruptson a queue
  274. */
  275. void
  276. ixQMgrAqmIfQInterruptEnable (IxQMgrQId qId);
  277. /*
  278. * Disable interrupt on a quee
  279. */
  280. void
  281. ixQMgrAqmIfQInterruptDisable (IxQMgrQId qId);
  282. /*
  283. * Write the config register of the specified queue
  284. */
  285. void
  286. ixQMgrAqmIfQueCfgWrite (IxQMgrQId qId,
  287. IxQMgrQSizeInWords qSizeInWords,
  288. IxQMgrQEntrySizeInWords entrySizeInWords,
  289. UINT32 freeSRAMAddress);
  290. /*
  291. * read fields from the config of the specified queue.
  292. */
  293. void
  294. ixQMgrAqmIfQueCfgRead (IxQMgrQId qId,
  295. unsigned int numEntries,
  296. UINT32 *baseAddress,
  297. unsigned int *ne,
  298. unsigned int *nf,
  299. UINT32 *readPtr,
  300. UINT32 *writePtr);
  301. /*
  302. * Set the ne and nf watermark level on a queue.
  303. */
  304. void
  305. ixQMgrAqmIfWatermarkSet (IxQMgrQId qId,
  306. unsigned ne,
  307. unsigned nf);
  308. /* Inspect an entry without moving the read pointer */
  309. IX_STATUS
  310. ixQMgrAqmIfQPeek (IxQMgrQId qId,
  311. unsigned int entryIndex,
  312. unsigned int *entry);
  313. /* Modify an entry without moving the write pointer */
  314. IX_STATUS
  315. ixQMgrAqmIfQPoke (IxQMgrQId qId,
  316. unsigned int entryIndex,
  317. unsigned int *entry);
  318. /*
  319. * Function prototype for inline functions. For description refers to
  320. * the functions defintion below.
  321. */
  322. IX_QMGR_AQMIF_INLINE void
  323. ixQMgrAqmIfWordWrite (VUINT32 *address,
  324. UINT32 word);
  325. IX_QMGR_AQMIF_INLINE void
  326. ixQMgrAqmIfWordRead (VUINT32 *address,
  327. UINT32 *word);
  328. IX_QMGR_AQMIF_INLINE void
  329. ixQMgrAqmIfQPop (IxQMgrQId qId,
  330. IxQMgrQEntrySizeInWords numWords,
  331. UINT32 *entry);
  332. IX_QMGR_AQMIF_INLINE void
  333. ixQMgrAqmIfQPush (IxQMgrQId qId,
  334. IxQMgrQEntrySizeInWords numWords,
  335. UINT32 *entry);
  336. IX_QMGR_AQMIF_INLINE void
  337. ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group,
  338. UINT32 *qStatusWords);
  339. IX_QMGR_AQMIF_INLINE BOOL
  340. ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords,
  341. UINT32 *newQStatusWords,
  342. unsigned int statusWordOffset,
  343. UINT32 checkValue,
  344. UINT32 mask);
  345. IX_QMGR_AQMIF_INLINE BOOL
  346. ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId,
  347. UINT32 registerBaseAddrOffset,
  348. unsigned queuesPerRegWord,
  349. unsigned relativeBitOffset,
  350. BOOL reset);
  351. IX_QMGR_AQMIF_INLINE BOOL
  352. ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId);
  353. IX_QMGR_AQMIF_INLINE BOOL
  354. ixQMgrAqmIfOverflowCheck (IxQMgrQId qId);
  355. IX_QMGR_AQMIF_INLINE UINT32
  356. ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId,
  357. UINT32 registerBaseAddrOffset,
  358. unsigned queuesPerRegWord);
  359. IX_QMGR_AQMIF_INLINE void
  360. ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group,
  361. UINT32 reg);
  362. IX_QMGR_AQMIF_INLINE void
  363. ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group,
  364. UINT32 *regVal);
  365. IX_QMGR_AQMIF_INLINE void
  366. ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId,
  367. IxQMgrQStatus *status);
  368. IX_QMGR_AQMIF_INLINE void
  369. ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId,
  370. IxQMgrQStatus *status);
  371. IX_QMGR_AQMIF_INLINE void
  372. ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
  373. IxQMgrQStatus *qStatus);
  374. IX_QMGR_AQMIF_INLINE unsigned
  375. ixQMgrAqmIfPow2NumDivide (unsigned numerator,
  376. unsigned denominator);
  377. IX_QMGR_AQMIF_INLINE void
  378. ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group,
  379. UINT32 *regVal);
  380. /*
  381. * Inline functions
  382. */
  383. /*
  384. * This inline function is used by other QMgr components to write one
  385. * word to the specified address.
  386. */
  387. IX_QMGR_AQMIF_INLINE void
  388. ixQMgrAqmIfWordWrite (VUINT32 *address,
  389. UINT32 word)
  390. {
  391. IX_OSAL_WRITE_LONG(address, word);
  392. }
  393. /*
  394. * This inline function is used by other QMgr components to read a
  395. * word from the specified address.
  396. */
  397. IX_QMGR_AQMIF_INLINE void
  398. ixQMgrAqmIfWordRead (VUINT32 *address,
  399. UINT32 *word)
  400. {
  401. *word = IX_OSAL_READ_LONG(address);
  402. }
  403. /*
  404. * This inline function is used by other QMgr components to pop an
  405. * entry off the specified queue.
  406. */
  407. IX_QMGR_AQMIF_INLINE void
  408. ixQMgrAqmIfQPop (IxQMgrQId qId,
  409. IxQMgrQEntrySizeInWords numWords,
  410. UINT32 *entry)
  411. {
  412. volatile UINT32 *accRegAddr;
  413. accRegAddr = (UINT32*)(aqmBaseAddress +
  414. IX_QMGR_Q_ACCESS_ADDR_GET(qId));
  415. switch (numWords)
  416. {
  417. case IX_QMGR_Q_ENTRY_SIZE1:
  418. ixQMgrAqmIfWordRead (accRegAddr, entry);
  419. break;
  420. case IX_QMGR_Q_ENTRY_SIZE2:
  421. ixQMgrAqmIfWordRead (accRegAddr++, entry++);
  422. ixQMgrAqmIfWordRead (accRegAddr, entry);
  423. break;
  424. case IX_QMGR_Q_ENTRY_SIZE4:
  425. ixQMgrAqmIfWordRead (accRegAddr++, entry++);
  426. ixQMgrAqmIfWordRead (accRegAddr++, entry++);
  427. ixQMgrAqmIfWordRead (accRegAddr++, entry++);
  428. ixQMgrAqmIfWordRead (accRegAddr, entry);
  429. break;
  430. default:
  431. IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPop");
  432. break;
  433. }
  434. }
  435. /*
  436. * This inline function is used by other QMgr components to push an
  437. * entry to the specified queue.
  438. */
  439. IX_QMGR_AQMIF_INLINE void
  440. ixQMgrAqmIfQPush (IxQMgrQId qId,
  441. IxQMgrQEntrySizeInWords numWords,
  442. UINT32 *entry)
  443. {
  444. volatile UINT32 *accRegAddr;
  445. accRegAddr = (UINT32*)(aqmBaseAddress +
  446. IX_QMGR_Q_ACCESS_ADDR_GET(qId));
  447. switch (numWords)
  448. {
  449. case IX_QMGR_Q_ENTRY_SIZE1:
  450. ixQMgrAqmIfWordWrite (accRegAddr, *entry);
  451. break;
  452. case IX_QMGR_Q_ENTRY_SIZE2:
  453. ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
  454. ixQMgrAqmIfWordWrite (accRegAddr, *entry);
  455. break;
  456. case IX_QMGR_Q_ENTRY_SIZE4:
  457. ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
  458. ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
  459. ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
  460. ixQMgrAqmIfWordWrite (accRegAddr, *entry);
  461. break;
  462. default:
  463. IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPush");
  464. break;
  465. }
  466. }
  467. /*
  468. * The AQM interrupt registers contains a bit for each AQM queue
  469. * specifying the queue (s) that cause an interrupt to fire. This
  470. * function is called by IxQMGrDispatcher component.
  471. */
  472. IX_QMGR_AQMIF_INLINE void
  473. ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group,
  474. UINT32 *qStatusWords)
  475. {
  476. volatile UINT32 *regAddress = NULL;
  477. if (group == IX_QMGR_QUELOW_GROUP)
  478. {
  479. regAddress = (UINT32*)(aqmBaseAddress +
  480. IX_QMGR_QUELOWSTAT0_OFFSET);
  481. ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
  482. ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
  483. ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
  484. ixQMgrAqmIfWordRead (regAddress, qStatusWords);
  485. }
  486. else /* We have the upper queues */
  487. {
  488. /* Only need to read the Nearly Empty status register for
  489. * queues 32-63 as for therse queues the interrtupt source
  490. * condition is fixed to Nearly Empty
  491. */
  492. regAddress = (UINT32*)(aqmBaseAddress +
  493. IX_QMGR_QUEUPPSTAT0_OFFSET);
  494. ixQMgrAqmIfWordRead (regAddress, qStatusWords);
  495. }
  496. }
  497. /*
  498. * This function check if the status for a queue has changed between
  499. * 2 snapshots and if it has, that the status matches a particular
  500. * value after masking.
  501. */
  502. IX_QMGR_AQMIF_INLINE BOOL
  503. ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords,
  504. UINT32 *newQStatusWords,
  505. unsigned int statusWordOffset,
  506. UINT32 checkValue,
  507. UINT32 mask)
  508. {
  509. if (((oldQStatusWords[statusWordOffset] & mask) !=
  510. (newQStatusWords[statusWordOffset] & mask)) &&
  511. ((newQStatusWords[statusWordOffset] & mask) == checkValue))
  512. {
  513. return TRUE;
  514. }
  515. return FALSE;
  516. }
  517. /*
  518. * The AQM interrupt register contains a bit for each AQM queue
  519. * specifying the queue (s) that cause an interrupt to fire. This
  520. * function is called by IxQMgrDispatcher component.
  521. */
  522. IX_QMGR_AQMIF_INLINE void
  523. ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group,
  524. UINT32 *regVal)
  525. {
  526. volatile UINT32 *regAddress;
  527. if (group == IX_QMGR_QUELOW_GROUP)
  528. {
  529. regAddress = (UINT32*)(aqmBaseAddress +
  530. IX_QMGR_QINTREG0_OFFSET);
  531. }
  532. else
  533. {
  534. regAddress = (UINT32*)(aqmBaseAddress +
  535. IX_QMGR_QINTREG1_OFFSET);
  536. }
  537. ixQMgrAqmIfWordRead (regAddress, regVal);
  538. }
  539. /*
  540. * The AQM interrupt enable register contains a bit for each AQM queue.
  541. * This function reads the interrupt enable register. This
  542. * function is called by IxQMgrDispatcher component.
  543. */
  544. IX_QMGR_AQMIF_INLINE void
  545. ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group,
  546. UINT32 *regVal)
  547. {
  548. volatile UINT32 *regAddress;
  549. if (group == IX_QMGR_QUELOW_GROUP)
  550. {
  551. regAddress = (UINT32*)(aqmBaseAddress +
  552. IX_QMGR_QUEIEREG0_OFFSET);
  553. }
  554. else
  555. {
  556. regAddress = (UINT32*)(aqmBaseAddress +
  557. IX_QMGR_QUEIEREG1_OFFSET);
  558. }
  559. ixQMgrAqmIfWordRead (regAddress, regVal);
  560. }
  561. /*
  562. * This inline function will read the status bit of a queue
  563. * specified by qId. If reset is TRUE the bit is cleared.
  564. */
  565. IX_QMGR_AQMIF_INLINE BOOL
  566. ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId,
  567. UINT32 registerBaseAddrOffset,
  568. unsigned queuesPerRegWord,
  569. unsigned relativeBitOffset,
  570. BOOL reset)
  571. {
  572. UINT32 actualBitOffset;
  573. volatile UINT32 *registerAddress;
  574. UINT32 registerWord;
  575. /*
  576. * Calculate the registerAddress
  577. * multiple queues split accross registers
  578. */
  579. registerAddress = (UINT32*)(aqmBaseAddress +
  580. registerBaseAddrOffset +
  581. ((qId / queuesPerRegWord) *
  582. IX_QMGR_NUM_BYTES_PER_WORD));
  583. /*
  584. * Get the status word
  585. */
  586. ixQMgrAqmIfWordRead (registerAddress, &registerWord);
  587. /*
  588. * Calculate the actualBitOffset
  589. * status for multiple queues stored in one register
  590. */
  591. actualBitOffset = (relativeBitOffset + 1) <<
  592. ((qId & (queuesPerRegWord - 1)) * (BITS_PER_WORD / queuesPerRegWord));
  593. /* Check if the status bit is set */
  594. if (registerWord & actualBitOffset)
  595. {
  596. /* Clear the bit if reset */
  597. if (reset)
  598. {
  599. ixQMgrAqmIfWordWrite (registerAddress, registerWord & (~actualBitOffset));
  600. }
  601. return TRUE;
  602. }
  603. /* Bit not set */
  604. return FALSE;
  605. }
  606. /*
  607. * @ingroup IxQmgrAqmIfAPI
  608. *
  609. * @brief Read the underflow status of a queue
  610. *
  611. * This inline function will read the underflow status of a queue
  612. * specified by qId.
  613. *
  614. */
  615. IX_QMGR_AQMIF_INLINE BOOL
  616. ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId)
  617. {
  618. if (qId < IX_QMGR_MIN_QUEUPP_QID)
  619. {
  620. return (ixQMgrAqmIfRegisterBitCheck (qId,
  621. IX_QMGR_QUEUOSTAT0_OFFSET,
  622. IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD,
  623. IX_QMGR_UNDERFLOW_BIT_OFFSET,
  624. TRUE/*reset*/));
  625. }
  626. else
  627. {
  628. /* Qs 32-63 have no underflow status */
  629. return FALSE;
  630. }
  631. }
  632. /*
  633. * This inline function will read the overflow status of a queue
  634. * specified by qId.
  635. */
  636. IX_QMGR_AQMIF_INLINE BOOL
  637. ixQMgrAqmIfOverflowCheck (IxQMgrQId qId)
  638. {
  639. if (qId < IX_QMGR_MIN_QUEUPP_QID)
  640. {
  641. return (ixQMgrAqmIfRegisterBitCheck (qId,
  642. IX_QMGR_QUEUOSTAT0_OFFSET,
  643. IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD,
  644. IX_QMGR_OVERFLOW_BIT_OFFSET,
  645. TRUE/*reset*/));
  646. }
  647. else
  648. {
  649. /* Qs 32-63 have no overflow status */
  650. return FALSE;
  651. }
  652. }
  653. /*
  654. * This inline function will read the status bits of a queue
  655. * specified by qId.
  656. */
  657. IX_QMGR_AQMIF_INLINE UINT32
  658. ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId,
  659. UINT32 registerBaseAddrOffset,
  660. unsigned queuesPerRegWord)
  661. {
  662. volatile UINT32 *registerAddress;
  663. UINT32 registerWord;
  664. UINT32 statusBitsMask;
  665. UINT32 bitsPerQueue;
  666. bitsPerQueue = BITS_PER_WORD / queuesPerRegWord;
  667. /*
  668. * Calculate the registerAddress
  669. * multiple queues split accross registers
  670. */
  671. registerAddress = (UINT32*)(aqmBaseAddress +
  672. registerBaseAddrOffset +
  673. ((qId / queuesPerRegWord) *
  674. IX_QMGR_NUM_BYTES_PER_WORD));
  675. /*
  676. * Read the status word
  677. */
  678. ixQMgrAqmIfWordRead (registerAddress, &registerWord);
  679. /*
  680. * Calculate the mask for the status bits for this queue.
  681. */
  682. statusBitsMask = ((1 << bitsPerQueue) - 1);
  683. /*
  684. * Shift the status word so it is right justified
  685. */
  686. registerWord >>= ((qId & (queuesPerRegWord - 1)) * bitsPerQueue);
  687. /*
  688. * Mask out all bar the status bits for this queue
  689. */
  690. return (registerWord &= statusBitsMask);
  691. }
  692. /*
  693. * This function is called by IxQMgrDispatcher to set the contents of
  694. * the AQM interrupt register.
  695. */
  696. IX_QMGR_AQMIF_INLINE void
  697. ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group,
  698. UINT32 reg)
  699. {
  700. volatile UINT32 *address;
  701. if (group == IX_QMGR_QUELOW_GROUP)
  702. {
  703. address = (UINT32*)(aqmBaseAddress +
  704. IX_QMGR_QINTREG0_OFFSET);
  705. }
  706. else
  707. {
  708. address = (UINT32*)(aqmBaseAddress +
  709. IX_QMGR_QINTREG1_OFFSET);
  710. }
  711. ixQMgrAqmIfWordWrite (address, reg);
  712. }
  713. /*
  714. * Read the status of a queue in the range 0-31.
  715. *
  716. * This function is used by other QMgr components to read the
  717. * status of the queue specified by qId.
  718. */
  719. IX_QMGR_AQMIF_INLINE void
  720. ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId,
  721. IxQMgrQStatus *status)
  722. {
  723. /* Read the general status bits */
  724. *status = ixQMgrAqmIfQRegisterBitsRead (qId,
  725. IX_QMGR_QUELOWSTAT0_OFFSET,
  726. IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD);
  727. }
  728. /*
  729. * This function will read the status of the queue specified
  730. * by qId.
  731. */
  732. IX_QMGR_AQMIF_INLINE void
  733. ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId,
  734. IxQMgrQStatus *status)
  735. {
  736. /* Reset the status bits */
  737. *status = 0;
  738. /*
  739. * Check if the queue is nearly empty,
  740. * N.b. QUPP stat register contains status for regs 32-63 at each
  741. * bit position so subtract 32 to get bit offset
  742. */
  743. if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID),
  744. IX_QMGR_QUEUPPSTAT0_OFFSET,
  745. IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD,
  746. 0/*relativeBitOffset*/,
  747. FALSE/*!reset*/))
  748. {
  749. *status |= IX_QMGR_Q_STATUS_NE_BIT_MASK;
  750. }
  751. /*
  752. * Check if the queue is full,
  753. * N.b. QUPP stat register contains status for regs 32-63 at each
  754. * bit position so subtract 32 to get bit offset
  755. */
  756. if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID),
  757. IX_QMGR_QUEUPPSTAT1_OFFSET,
  758. IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD,
  759. 0/*relativeBitOffset*/,
  760. FALSE/*!reset*/))
  761. {
  762. *status |= IX_QMGR_Q_STATUS_F_BIT_MASK;
  763. }
  764. }
  765. /*
  766. * This function is used by other QMgr components to read the
  767. * status of the queue specified by qId.
  768. */
  769. IX_QMGR_AQMIF_INLINE void
  770. ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
  771. IxQMgrQStatus *qStatus)
  772. {
  773. if (qId < IX_QMGR_MIN_QUEUPP_QID)
  774. {
  775. ixQMgrAqmIfQueLowStatRead (qId, qStatus);
  776. }
  777. else
  778. {
  779. ixQMgrAqmIfQueUppStatRead (qId, qStatus);
  780. }
  781. }
  782. /*
  783. * This function performs a mod division
  784. */
  785. IX_QMGR_AQMIF_INLINE unsigned
  786. ixQMgrAqmIfPow2NumDivide (unsigned numerator,
  787. unsigned denominator)
  788. {
  789. /* Number is evenly divisable by 2 */
  790. return (numerator >> ixQMgrAqmIfLog2 (denominator));
  791. }
  792. /* Restore IX_COMPONENT_NAME */
  793. #undef IX_COMPONENT_NAME
  794. #define IX_COMPONENT_NAME IX_QMGR_AQMIF_SAVED_COMPONENT_NAME
  795. #endif/*IXQMGRAQMIF_P_H*/