IxEthAccDataPlane_p.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /**
  2. * @file IxEthAccDataPlane_p.h
  3. *
  4. * @author Intel Corporation
  5. * @date 12-Feb-2002
  6. *
  7. * @brief Internal Header file for IXP425 Ethernet Access component.
  8. *
  9. * Design Notes:
  10. *
  11. *
  12. * @par
  13. * IXP400 SW Release version 2.0
  14. *
  15. * -- Copyright Notice --
  16. *
  17. * @par
  18. * Copyright 2001-2005, Intel Corporation.
  19. * All rights reserved.
  20. *
  21. * @par
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the above copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  31. * may be used to endorse or promote products derived from this software
  32. * without specific prior written permission.
  33. *
  34. * @par
  35. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  36. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  38. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  39. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  40. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  41. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  43. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  44. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  45. * SUCH DAMAGE.
  46. *
  47. * @par
  48. * -- End of Copyright Notice --
  49. */
  50. #ifndef IxEthAccDataPlane_p_H
  51. #define IxEthAccDataPlane_p_H
  52. #include <IxOsal.h>
  53. #include <IxQMgr.h>
  54. /**
  55. * @addtogroup IxEthAccPri
  56. *@{
  57. */
  58. /* typedefs global to this file*/
  59. typedef struct
  60. {
  61. IX_OSAL_MBUF *pHead;
  62. IX_OSAL_MBUF *pTail;
  63. }IxEthAccDataPlaneQList;
  64. /**
  65. * @struct IxEthAccDataPlaneStats
  66. * @brief Statistics data structure associated with the data plane
  67. *
  68. */
  69. typedef struct
  70. {
  71. UINT32 addToSwQ;
  72. UINT32 removeFromSwQ;
  73. UINT32 unchainedTxMBufs;
  74. UINT32 chainedTxMBufs;
  75. UINT32 unchainedTxDoneMBufs;
  76. UINT32 chainedTxDoneMBufs;
  77. UINT32 unchainedRxMBufs;
  78. UINT32 chainedRxMBufs;
  79. UINT32 unchainedRxFreeMBufs;
  80. UINT32 chainedRxFreeMBufs;
  81. UINT32 rxCallbackCounter;
  82. UINT32 rxCallbackBurstRead;
  83. UINT32 txDoneCallbackCounter;
  84. UINT32 unexpectedError;
  85. } IxEthAccDataPlaneStats;
  86. /**
  87. * @fn ixEthAccMbufFromSwQ
  88. * @brief used during disable steps to convert mbufs from
  89. * swq format, ready to be pushed into hw queues for NPE,
  90. * back into XScale format
  91. */
  92. IX_OSAL_MBUF *ixEthAccMbufFromSwQ(IX_OSAL_MBUF *mbuf);
  93. /**
  94. * @fn ixEthAccDataPlaneShow
  95. * @brief Show function (for data plane statistics
  96. */
  97. void ixEthAccDataPlaneShow(void);
  98. /*
  99. * lock dataplane when atomic operation is required
  100. */
  101. #define IX_ETH_ACC_DATA_PLANE_LOCK(arg) arg = ixOsalIrqLock();
  102. #define IX_ETH_ACC_DATA_PLANE_UNLOCK(arg) ixOsalIrqUnlock(arg);
  103. /*
  104. * Use MBUF fields
  105. */
  106. #define IX_ETHACC_NE_SHARED(mBufPtr) \
  107. ((IxEthAccNe *)&((mBufPtr)->ix_ne))
  108. #if 1
  109. #define IX_ETHACC_NE_NEXT(mBufPtr) (mBufPtr)->ix_ne.reserved[0]
  110. /* tm - wrong!! len and pkt_len are in the second word - #define IX_ETHACC_NE_LEN(mBufPtr) (mBufPtr)->ix_ne.reserved[3] */
  111. #define IX_ETHACC_NE_LEN(mBufPtr) (mBufPtr)->ix_ne.reserved[1]
  112. #define IX_ETHACC_NE_DATA(mBufPtr)(mBufPtr)->ix_ne.reserved[2]
  113. #else
  114. #define IX_ETHACC_NE_NEXT(mBufPtr) \
  115. IX_ETHACC_NE_SHARED(mBufPtr)->ixReserved_next
  116. #define IX_ETHACC_NE_LEN(mBufPtr) \
  117. IX_ETHACC_NE_SHARED(mBufPtr)->ixReserved_lengths
  118. #define IX_ETHACC_NE_DATA(mBufPtr) \
  119. IX_ETHACC_NE_SHARED(mBufPtr)->ixReserved_data
  120. #endif
  121. /*
  122. * Use MBUF next pointer field to chain data.
  123. */
  124. #define IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER(mbuf) (mbuf)->ix_ctrl.ix_chain
  125. #define IX_ETH_ACC_DATAPLANE_IS_Q_EMPTY(mbuf_list) ((mbuf_list.pHead) == NULL)
  126. #define IX_ETH_ACC_DATAPLANE_ADD_MBUF_TO_Q_HEAD(mbuf_list,mbuf_to_add) \
  127. do { \
  128. int lockVal; \
  129. IX_ETH_ACC_DATA_PLANE_LOCK(lockVal); \
  130. IX_ETH_ACC_STATS_INC(ixEthAccDataStats.addToSwQ); \
  131. if ( (mbuf_list.pHead) != NULL ) \
  132. { \
  133. (IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_to_add))) = (mbuf_list.pHead);\
  134. (mbuf_list.pHead) = (mbuf_to_add); \
  135. } \
  136. else { \
  137. (mbuf_list.pTail) = (mbuf_list.pHead) = (mbuf_to_add); \
  138. IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_to_add)) = NULL; \
  139. } \
  140. IX_ETH_ACC_DATA_PLANE_UNLOCK(lockVal); \
  141. } while(0)
  142. #define IX_ETH_ACC_DATAPLANE_ADD_MBUF_TO_Q_TAIL(mbuf_list,mbuf_to_add) \
  143. do { \
  144. int lockVal; \
  145. IX_ETH_ACC_DATA_PLANE_LOCK(lockVal); \
  146. IX_ETH_ACC_STATS_INC(ixEthAccDataStats.addToSwQ); \
  147. if ( (mbuf_list.pHead) == NULL ) \
  148. { \
  149. (mbuf_list.pHead) = mbuf_to_add; \
  150. IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_to_add)) = NULL; \
  151. } \
  152. else { \
  153. IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_list.pTail)) = (mbuf_to_add); \
  154. IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_to_add)) = NULL; \
  155. } \
  156. (mbuf_list.pTail) = mbuf_to_add; \
  157. IX_ETH_ACC_DATA_PLANE_UNLOCK(lockVal); \
  158. } while (0)
  159. #define IX_ETH_ACC_DATAPLANE_REMOVE_MBUF_FROM_Q_HEAD(mbuf_list,mbuf_to_rem) \
  160. do { \
  161. int lockVal; \
  162. IX_ETH_ACC_DATA_PLANE_LOCK(lockVal); \
  163. if ( (mbuf_list.pHead) != NULL ) \
  164. { \
  165. IX_ETH_ACC_STATS_INC(ixEthAccDataStats.removeFromSwQ); \
  166. (mbuf_to_rem) = (mbuf_list.pHead) ; \
  167. (mbuf_list.pHead) = (IX_ETH_ACC_MBUF_NEXT_PKT_CHAIN_MEMBER((mbuf_to_rem)));\
  168. } \
  169. else { \
  170. (mbuf_to_rem) = NULL; \
  171. } \
  172. IX_ETH_ACC_DATA_PLANE_UNLOCK(lockVal); \
  173. } while (0)
  174. /**
  175. * @brief message handler QManager entries for NPE id => port ID conversion (NPE_B => 0, NPE_C => 1)
  176. */
  177. #define IX_ETH_ACC_PORT_TO_NPE_ID(port) \
  178. ixEthAccPortData[(port)].npeId
  179. #define IX_ETH_ACC_NPE_TO_PORT_ID(npe) ((npe == 0 ? 2 : (npe == 1 ? 0 : ( npe == 2 ? 1 : -1 ))))
  180. #define IX_ETH_ACC_PORT_TO_TX_Q_ID(port) \
  181. ixEthAccPortData[(port)].ixEthAccTxData.txQueue
  182. #define IX_ETH_ACC_PORT_TO_RX_FREE_Q_ID(port) \
  183. ixEthAccPortData[(port)].ixEthAccRxData.rxFreeQueue
  184. #define IX_ETH_ACC_PORT_TO_TX_Q_SOURCE(port) (port == IX_ETH_PORT_1 ? IX_ETH_ACC_TX_FRAME_ENET0_Q_SOURCE : (port == IX_ETH_PORT_2 ? IX_ETH_ACC_TX_FRAME_ENET1_Q_SOURCE : IX_ETH_ACC_TX_FRAME_ENET2_Q_SOURCE))
  185. #define IX_ETH_ACC_PORT_TO_RX_FREE_Q_SOURCE(port) (port == IX_ETH_PORT_1 ? IX_ETH_ACC_RX_FREE_BUFF_ENET0_Q_SOURCE : (port == IX_ETH_PORT_2 ? IX_ETH_ACC_RX_FREE_BUFF_ENET1_Q_SOURCE : IX_ETH_ACC_RX_FREE_BUFF_ENET2_Q_SOURCE ))
  186. /* Flush the mbufs chain and all data pointed to by the mbuf */
  187. #ifndef NDEBUG
  188. #define IX_ETH_ACC_STATS_INC(x) (x++)
  189. #else
  190. #define IX_ETH_ACC_STATS_INC(x)
  191. #endif
  192. #define IX_ETH_ACC_MAX_TX_FRAMES_TO_SUBMIT 128
  193. void ixEthRxFrameQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId);
  194. void ixEthRxMultiBufferQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId);
  195. void ixEthTxFrameDoneQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId);
  196. #endif /* IxEthAccDataPlane_p_H */
  197. /**
  198. *@}
  199. */