IxNpeMh.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /**
  2. * @file IxNpeMh.h
  3. *
  4. * @date 14 Dec 2001
  5. *
  6. * @brief This file contains the public API for the IXP400 NPE Message
  7. * Handler component.
  8. *
  9. *
  10. * @par
  11. * IXP400 SW Release version 2.0
  12. *
  13. * -- Copyright Notice --
  14. *
  15. * @par
  16. * Copyright 2001-2005, Intel Corporation.
  17. * All rights reserved.
  18. *
  19. * @par
  20. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions
  22. * are met:
  23. * 1. Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. * 2. Redistributions in binary form must reproduce the above copyright
  26. * notice, this list of conditions and the following disclaimer in the
  27. * documentation and/or other materials provided with the distribution.
  28. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  29. * may be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * @par
  33. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  34. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  35. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  36. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  37. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  38. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  39. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  40. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  41. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  42. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  43. * SUCH DAMAGE.
  44. *
  45. * @par
  46. * -- End of Copyright Notice --
  47. */
  48. /**
  49. * @defgroup IxNpeMh IXP400 NPE Message Handler (IxNpeMh) API
  50. *
  51. * @brief The public API for the IXP400 NPE Message Handler component.
  52. *
  53. * @{
  54. */
  55. #ifndef IXNPEMH_H
  56. #define IXNPEMH_H
  57. #include "IxOsalTypes.h"
  58. /*
  59. * #defines for function return types, etc.
  60. */
  61. #define IX_NPEMH_MIN_MESSAGE_ID (0x00) /**< minimum valid message ID */
  62. #define IX_NPEMH_MAX_MESSAGE_ID (0xFF) /**< maximum valid message ID */
  63. #define IX_NPEMH_SEND_RETRIES_DEFAULT (3) /**< default msg send retries */
  64. /**
  65. * @def IX_NPEMH_CRITICAL_NPE_ERR
  66. *
  67. * @brief NpeMH function return value for a Critical NPE error occuring during
  68. sending/receiving message. Assume NPE hang / halt if this value is
  69. returned.
  70. */
  71. #define IX_NPEMH_CRITICAL_NPE_ERR 2
  72. /**
  73. * @enum IxNpeMhNpeId
  74. *
  75. * @brief The ID of a particular NPE.
  76. * @note In this context, for IXP425 Silicon (B0):<br>
  77. * - NPE-A has HDLC, HSS, AAL and UTOPIA Coprocessors.<br>
  78. * - NPE-B has Ethernet Coprocessor.<br>
  79. * - NPE-C has Ethernet, AES, DES and HASH Coprocessors.<br>
  80. * - IXP400 Product Line have different combinations of coprocessors.
  81. */
  82. typedef enum
  83. {
  84. IX_NPEMH_NPEID_NPEA = 0, /**< ID for NPE-A */
  85. IX_NPEMH_NPEID_NPEB, /**< ID for NPE-B */
  86. IX_NPEMH_NPEID_NPEC, /**< ID for NPE-C */
  87. IX_NPEMH_NUM_NPES /**< Number of NPEs */
  88. } IxNpeMhNpeId;
  89. /**
  90. * @enum IxNpeMhNpeInterrupts
  91. *
  92. * @brief Indicator specifying whether or not NPE interrupts should drive
  93. * receiving of messages from the NPEs.
  94. */
  95. typedef enum
  96. {
  97. IX_NPEMH_NPEINTERRUPTS_NO = 0, /**< Don't use NPE interrupts */
  98. IX_NPEMH_NPEINTERRUPTS_YES /**< Do use NPE interrupts */
  99. } IxNpeMhNpeInterrupts;
  100. /**
  101. * @brief The 2-word message structure to send to and receive from the
  102. * NPEs.
  103. */
  104. typedef struct
  105. {
  106. UINT32 data[2]; /**< the actual data of the message */
  107. } IxNpeMhMessage;
  108. /** message ID */
  109. typedef UINT32 IxNpeMhMessageId;
  110. /**
  111. * @typedef IxNpeMhCallback
  112. *
  113. * @brief This prototype shows the format of a message callback function.
  114. *
  115. * This prototype shows the format of a message callback function. The
  116. * message callback will be passed the message to be handled and will also
  117. * be told from which NPE the message was received. The message callback
  118. * will either be registered by ixNpeMhUnsolicitedCallbackRegister() or
  119. * passed as a parameter to ixNpeMhMessageWithResponseSend(). It will be
  120. * called from within an ISR triggered by the NPE's "outFIFO not empty"
  121. * interrupt (see ixNpeMhInitialize()). The parameters passed are the ID
  122. * of the NPE that the message was received from, and the message to be
  123. * handled.<P><B>Re-entrancy:</B> This function is only a prototype, and
  124. * will be implemented by the client. It does not need to be re-entrant.
  125. */
  126. typedef void (*IxNpeMhCallback) (IxNpeMhNpeId, IxNpeMhMessage);
  127. /*
  128. * Prototypes for interface functions.
  129. */
  130. /**
  131. * @ingroup IxNpeMh
  132. *
  133. * @fn IX_STATUS ixNpeMhInitialize (
  134. IxNpeMhNpeInterrupts npeInterrupts)
  135. *
  136. * @brief This function will initialise the IxNpeMh component.
  137. *
  138. * @param npeInterrupts @ref IxNpeMhNpeInterrupts [in] - This parameter
  139. * dictates whether or not the IxNpeMh component will service NPE "outFIFO
  140. * not empty" interrupts to trigger receiving and processing of messages
  141. * from the NPEs. If not then the client must use ixNpeMhMessagesReceive()
  142. * to control message receiving and processing.
  143. *
  144. * This function will initialise the IxNpeMh component. It should only be
  145. * called once, prior to using the IxNpeMh component. The following
  146. * actions will be performed by this function:<OL><LI>Initialization of
  147. * internal data structures (e.g. solicited and unsolicited callback
  148. * tables).</LI><LI>Configuration of the interface with the NPEs (e.g.
  149. * enabling of NPE "outFIFO not empty" interrupts).</LI><LI>Registration of
  150. * ISRs that will receive and handle messages when the NPEs' "outFIFO not
  151. * empty" interrupts fire (if npeInterrupts equals
  152. * IX_NPEMH_NPEINTERRUPTS_YES).</LI></OL>
  153. *
  154. * @return The function returns a status indicating success or failure.
  155. */
  156. PUBLIC IX_STATUS ixNpeMhInitialize (
  157. IxNpeMhNpeInterrupts npeInterrupts);
  158. /**
  159. * @ingroup IxNpeMh
  160. *
  161. * @fn IX_STATUS ixNpeMhUnload (void)
  162. *
  163. * @brief This function will uninitialise the IxNpeMh component.
  164. *
  165. * This function will uninitialise the IxNpeMh component. It should only be
  166. * called once, and only if the IxNpeMh component has already been initialised.
  167. * No other IxNpeMh API functions should be called until @ref ixNpeMhInitialize
  168. * is called again.
  169. * If possible, this function should be called before a soft reboot or unloading
  170. * a kernel module to perform any clean up operations required for IxNpeMh.
  171. *
  172. * The following actions will be performed by this function:
  173. * <OL><LI>Unmapping of kernel memory mapped by the function
  174. * @ref ixNpeMhInitialize.</LI></OL>
  175. *
  176. * @return The function returns a status indicating success or failure.
  177. */
  178. PUBLIC IX_STATUS ixNpeMhUnload (void);
  179. /**
  180. * @ingroup IxNpeMh
  181. *
  182. * @fn IX_STATUS ixNpeMhUnsolicitedCallbackRegister (
  183. IxNpeMhNpeId npeId,
  184. IxNpeMhMessageId messageId,
  185. IxNpeMhCallback unsolicitedCallback)
  186. *
  187. * @brief This function will register an unsolicited callback for a
  188. * particular NPE and message ID.
  189. *
  190. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE whose messages
  191. * the unsolicited callback will handle.
  192. * @param messageId @ref IxNpeMhMessageId [in] - The ID of the messages the
  193. * unsolicited callback will handle.
  194. * @param unsolicitedCallback @ref IxNpeMhCallback [in] - The unsolicited
  195. * callback function. A value of NULL will deregister any previously
  196. * registered callback for this NPE and message ID.
  197. *
  198. * This function will register an unsolicited message callback for a
  199. * particular NPE and message ID.<P>If an unsolicited callback is already
  200. * registered for the specified NPE and message ID then the callback will
  201. * be overwritten. Only one client will be responsible for handling a
  202. * particular message ID associated with a NPE. Registering a NULL
  203. * unsolicited callback will deregister any previously registered
  204. * callback.<P>The callback function will be called from an ISR that will
  205. * be triggered by the NPE's "outFIFO not empty" interrupt (see
  206. * ixNpeMhInitialize()) to handle any unsolicited messages of the specific
  207. * message ID received from the NPE. Unsolicited messages will be handled
  208. * in the order they are received.<P>If no unsolicited callback can be
  209. * found for a received message then it is assumed that the message is
  210. * solicited.<P>If more than one client may be interested in a particular
  211. * unsolicited message then the suggested strategy is to register a
  212. * callback for the message that can itself distribute the message to
  213. * multiple clients as necessary.<P>See also
  214. * ixNpeMhUnsolicitedCallbackForRangeRegister().<P><B>Re-entrancy:</B> This
  215. * function will be callable from any thread at any time. IxOsal
  216. * will be used for any necessary resource protection.
  217. *
  218. * @return The function returns a status indicating success or failure.
  219. */
  220. PUBLIC IX_STATUS ixNpeMhUnsolicitedCallbackRegister (
  221. IxNpeMhNpeId npeId,
  222. IxNpeMhMessageId messageId,
  223. IxNpeMhCallback unsolicitedCallback);
  224. /**
  225. * @ingroup IxNpeMh
  226. *
  227. * @fn IX_STATUS ixNpeMhUnsolicitedCallbackForRangeRegister (
  228. IxNpeMhNpeId npeId,
  229. IxNpeMhMessageId minMessageId,
  230. IxNpeMhMessageId maxMessageId,
  231. IxNpeMhCallback unsolicitedCallback)
  232. *
  233. * @brief This function will register an unsolicited callback for a
  234. * particular NPE and range of message IDs.
  235. *
  236. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE whose messages the
  237. * unsolicited callback will handle.
  238. * @param minMessageId @ref IxNpeMhMessageId [in] - The minimum message ID in
  239. * the range of message IDs the unsolicited callback will handle.
  240. * @param maxMessageId @ref IxNpeMhMessageId [in] - The maximum message ID in
  241. * the range of message IDs the unsolicited callback will handle.
  242. * @param unsolicitedCallback @ref IxNpeMhCallback [in] - The unsolicited
  243. * callback function. A value of NULL will deregister any previously
  244. * registered callback(s) for this NPE and range of message IDs.
  245. *
  246. * This function will register an unsolicited callback for a particular NPE
  247. * and range of message IDs. It is a convenience function that is
  248. * effectively the same as calling ixNpeMhUnsolicitedCallbackRegister() for
  249. * each ID in the specified range. See
  250. * ixNpeMhUnsolicitedCallbackRegister() for more
  251. * information.<P><B>Re-entrancy:</B> This function will be callable from
  252. * any thread at any time. IxOsal will be used for any necessary
  253. * resource protection.
  254. *
  255. * @return The function returns a status indicating success or failure.
  256. */
  257. PUBLIC IX_STATUS ixNpeMhUnsolicitedCallbackForRangeRegister (
  258. IxNpeMhNpeId npeId,
  259. IxNpeMhMessageId minMessageId,
  260. IxNpeMhMessageId maxMessageId,
  261. IxNpeMhCallback unsolicitedCallback);
  262. /**
  263. * @ingroup IxNpeMh
  264. *
  265. * @fn IX_STATUS ixNpeMhMessageSend (
  266. IxNpeMhNpeId npeId,
  267. IxNpeMhMessage message,
  268. UINT32 maxSendRetries)
  269. *
  270. * @brief This function will send a message to a particular NPE.
  271. *
  272. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE to send the message
  273. * to.
  274. * @param message @ref IxNpeMhMessage [in] - The message to send.
  275. * @param maxSendRetries UINT32 [in] - Max num. of retries to perform
  276. * if the NPE's inFIFO is full.
  277. *
  278. * This function will send a message to a particular NPE. It will be the
  279. * client's responsibility to ensure that the message is properly formed.
  280. * The return status will signify to the client if the message was
  281. * successfully sent or not.<P>If the message is sent to the NPE then this
  282. * function will return a status of success. Note that this will only mean
  283. * the message has been placed in the NPE's inFIFO. There will be no way
  284. * of knowing that the NPE has actually read the message, but once in the
  285. * incoming message queue it will be safe to assume that the NPE will
  286. * process it.
  287. * <P>The inFIFO may fill up sometimes if the Xscale is sending messages
  288. * faster than the NPE can handle them. This forces us to retry attempts
  289. * to send the message until the NPE services the inFIFO. The client should
  290. * specify a ceiling value for the number of retries suitable to their
  291. * needs. IX_NPEMH_SEND_RETRIES_DEFAULT can be used as a default value for
  292. * the <i>maxSendRetries</i> parameter for this function. Each retry
  293. * exceeding this default number will incur a blocking delay of 1 microsecond,
  294. * to avoid consuming too much AHB bus bandwidth while performing retries.
  295. * <P>Note this function <B>must</B> only be used for messages.
  296. * that do not solicit responses. If the message being sent will solicit a
  297. * response then the ixNpeMhMessageWithResponseSend() function <B>must</B>
  298. * be used to ensure that the response is correctly
  299. * handled. <P> This function will return timeout status if NPE hang / halt
  300. * while sending message. The timeout error is not related to the
  301. * <i>maxSendRetries</i> as mentioned above. The timeout error will only occur
  302. * if the first word of the message has been sent to NPE (not exceeding
  303. * <i>maxSendRetries</i> when sending 1st message word), but the second word of
  304. * the message can't be written to NPE's inFIFO due to NPE hang / halt after
  305. * maximum waiting time (IX_NPE_MH_MAX_NUM_OF_RETRIES).
  306. * <P><B>Re-entrancy:</B> This function will be callable from any
  307. * thread at any time. IxOsal will be used for any necessary
  308. * resource protection.
  309. *
  310. * @return The function returns a status indicating success, failure or timeout.
  311. */
  312. PUBLIC IX_STATUS ixNpeMhMessageSend (
  313. IxNpeMhNpeId npeId,
  314. IxNpeMhMessage message,
  315. UINT32 maxSendRetries);
  316. /**
  317. * @ingroup IxNpeMh
  318. *
  319. * @fn IX_STATUS ixNpeMhMessageWithResponseSend (
  320. IxNpeMhNpeId npeId,
  321. IxNpeMhMessage message,
  322. IxNpeMhMessageId solicitedMessageId,
  323. IxNpeMhCallback solicitedCallback,
  324. UINT32 maxSendRetries)
  325. *
  326. * @brief This function is equivalent to the ixNpeMhMessageSend() function,
  327. * but must be used when the message being sent will solicited a response.
  328. *
  329. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE to send the message
  330. * to.
  331. * @param message @ref IxNpeMhMessage [in] - The message to send.
  332. * @param solicitedMessageId @ref IxNpeMhMessageId [in] - The ID of the
  333. * solicited response message.
  334. * @param solicitedCallback @ref IxNpeMhCallback [in] - The function to use to
  335. * pass the response message back to the client. A value of NULL will
  336. * cause the response message to be discarded.
  337. * @param maxSendRetries UINT32 [in] - Max num. of retries to perform
  338. * if the NPE's inFIFO is full.
  339. *
  340. * This function is equivalent to the ixNpeMhMessageSend() function, but
  341. * must be used when the message being sent will solicited a
  342. * response.<P>The client must specify the ID of the solicited response
  343. * message to allow the response to be recognised when it is received. The
  344. * client must also specify a callback function to handle the received
  345. * response. The IxNpeMh component will not offer the facility to send a
  346. * message to a NPE and receive a response within the same context.<P>Note
  347. * if the client is not interested in the response, specifying a NULL
  348. * callback will cause the response message to be discarded.<P>The
  349. * solicited callback will be stored and called some time later from an ISR
  350. * that will be triggered by the NPE's "outFIFO not empty" interrupt (see
  351. * ixNpeMhInitialize()) to handle the response message corresponding to the
  352. * message sent. Response messages will be handled in the order they are
  353. * received.<P>
  354. * <P>The inFIFO may fill up sometimes if the Xscale is sending messages
  355. * faster than the NPE can handle them. This forces us to retry attempts
  356. * to send the message until the NPE services the inFIFO. The client should
  357. * specify a ceiling value for the number of retries suitable to their
  358. * needs. IX_NPEMH_SEND_RETRIES_DEFAULT can be used as a default value for
  359. * the <i>maxSendRetries</i> parameter for this function. Each retry
  360. * exceeding this default number will incur a blocking delay of 1 microsecond,
  361. * to avoid consuming too much AHB bus bandwidth while performing retries.
  362. * <P> This function will return timeout status if NPE hang / halt
  363. * while sending message. The timeout error is not related to the
  364. * <i>maxSendRetries</i> as mentioned above. The timeout error will only occur
  365. * if the first word of the message has been sent to NPE (not exceeding
  366. * <i>maxSendRetries</i> when sending 1st message word), but the second word of
  367. * the message can't be written to NPE's inFIFO due to NPE hang / halt after
  368. * maximum waiting time (IX_NPE_MH_MAX_NUM_OF_RETRIES).
  369. * <P><B>Re-entrancy:</B> This function will be callable from any
  370. * thread at any time. IxOsal will be used for any necessary
  371. * resource protection.
  372. *
  373. * @return The function returns a status indicating success or failure.
  374. */
  375. PUBLIC IX_STATUS ixNpeMhMessageWithResponseSend (
  376. IxNpeMhNpeId npeId,
  377. IxNpeMhMessage message,
  378. IxNpeMhMessageId solicitedMessageId,
  379. IxNpeMhCallback solicitedCallback,
  380. UINT32 maxSendRetries);
  381. /**
  382. * @ingroup IxNpeMh
  383. *
  384. * @fn IX_STATUS ixNpeMhMessagesReceive (
  385. IxNpeMhNpeId npeId)
  386. *
  387. * @brief This function will receive messages from a particular NPE and
  388. * pass each message to the client via a solicited callback (for solicited
  389. * messages) or an unsolicited callback (for unsolicited messages).
  390. *
  391. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE to receive and
  392. * process messages from.
  393. *
  394. * This function will receive messages from a particular NPE and pass each
  395. * message to the client via a solicited callback (for solicited messages)
  396. * or an unsolicited callback (for unsolicited messages).<P>If the IxNpeMh
  397. * component is initialised to service NPE "outFIFO not empty" interrupts
  398. * (see ixNpeMhInitialize()) then there is no need to call this function.
  399. * This function is only provided as an alternative mechanism to control
  400. * the receiving and processing of messages from the NPEs.<P> This function
  401. * will return timeout status if NPE hang / halt while receiving message. The
  402. * timeout error will only occur if this function has read the first word of
  403. * the message and can't read second word of the message from NPE's outFIFO
  404. * after maximum retries (IX_NPE_MH_MAX_NUM_OF_RETRIES).
  405. * <P>Note this function cannot be called from within
  406. * an ISR as it will use resource protection mechanisms.<P><B>Re-entrancy:</B>
  407. * This function will be callable from any thread at any time. IxOsal will be
  408. * used for any necessary resource protection.
  409. *
  410. * @return The function returns a status indicating success, failure or timeout.
  411. */
  412. PUBLIC IX_STATUS ixNpeMhMessagesReceive (
  413. IxNpeMhNpeId npeId);
  414. /**
  415. * @ingroup IxNpeMh
  416. *
  417. * @fn IX_STATUS ixNpeMhShow (
  418. IxNpeMhNpeId npeId)
  419. *
  420. * @brief This function will display the current state of the IxNpeMh
  421. * component.
  422. *
  423. * <B>Re-entrancy:</B> This function will be callable from
  424. * any thread at any time. However, no resource protection will be used
  425. * so as not to impact system performance. As this function is only
  426. * reading statistical information then this is acceptable.
  427. *
  428. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE to display state
  429. * information for.
  430. *
  431. * @return The function returns a status indicating success or failure.
  432. */
  433. PUBLIC IX_STATUS ixNpeMhShow (
  434. IxNpeMhNpeId npeId);
  435. /**
  436. * @ingroup IxNpeMh
  437. *
  438. * @fn IX_STATUS ixNpeMhShowReset (
  439. IxNpeMhNpeId npeId)
  440. *
  441. * @brief This function will reset the current state of the IxNpeMh
  442. * component.
  443. *
  444. * <B>Re-entrancy:</B> This function will be callable from
  445. * any thread at any time. However, no resource protection will be used
  446. * so as not to impact system performance. As this function is only
  447. * writing statistical information then this is acceptable.
  448. *
  449. * @param npeId @ref IxNpeMhNpeId [in] - The ID of the NPE to reset state
  450. * information for.
  451. *
  452. * @return The function returns a status indicating success or failure.
  453. */
  454. PUBLIC IX_STATUS ixNpeMhShowReset (
  455. IxNpeMhNpeId npeId);
  456. #endif /* IXNPEMH_H */
  457. /**
  458. * @} defgroup IxNpeMh
  459. */