fman_port.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright 2008 - 2015 Freescale Semiconductor Inc.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of Freescale Semiconductor nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. *
  16. * ALTERNATIVELY, this software may be distributed under the terms of the
  17. * GNU General Public License ("GPL") as published by the Free Software
  18. * Foundation, either version 2 of that License or (at your option) any
  19. * later version.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
  22. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
  25. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef __FMAN_PORT_H
  33. #define __FMAN_PORT_H
  34. #include "fman.h"
  35. /* FM Port API
  36. * The FM uses a general module called "port" to represent a Tx port (MAC),
  37. * an Rx port (MAC).
  38. * The number of ports in an FM varies between SOCs.
  39. * The SW driver manages these ports as sub-modules of the FM,i.e. after an
  40. * FM is initialized, its ports may be initialized and operated upon.
  41. * The port is initialized aware of its type, but other functions on a port
  42. * may be indifferent to its type. When necessary, the driver verifies
  43. * coherence and returns error if applicable.
  44. * On initialization, user specifies the port type and it's index (relative
  45. * to the port's type) - always starting at 0.
  46. */
  47. /* FM Frame error */
  48. /* Frame Descriptor errors */
  49. /* Not for Rx-Port! Unsupported Format */
  50. #define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT FM_FD_ERR_UNSUPPORTED_FORMAT
  51. /* Not for Rx-Port! Length Error */
  52. #define FM_PORT_FRM_ERR_LENGTH FM_FD_ERR_LENGTH
  53. /* DMA Data error */
  54. #define FM_PORT_FRM_ERR_DMA FM_FD_ERR_DMA
  55. /* non Frame-Manager error; probably come from SEC that was chained to FM */
  56. #define FM_PORT_FRM_ERR_NON_FM FM_FD_RX_STATUS_ERR_NON_FM
  57. /* IPR error */
  58. #define FM_PORT_FRM_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR)
  59. /* IPR non-consistent-sp */
  60. #define FM_PORT_FRM_ERR_IPR_NCSP (FM_FD_ERR_IPR_NCSP & \
  61. ~FM_FD_IPR)
  62. /* Rx FIFO overflow, FCS error, code error, running disparity
  63. * error (SGMII and TBI modes), FIFO parity error.
  64. * PHY Sequence error, PHY error control character detected.
  65. */
  66. #define FM_PORT_FRM_ERR_PHYSICAL FM_FD_ERR_PHYSICAL
  67. /* Frame too long OR Frame size exceeds max_length_frame */
  68. #define FM_PORT_FRM_ERR_SIZE FM_FD_ERR_SIZE
  69. /* indicates a classifier "drop" operation */
  70. #define FM_PORT_FRM_ERR_CLS_DISCARD FM_FD_ERR_CLS_DISCARD
  71. /* Extract Out of Frame */
  72. #define FM_PORT_FRM_ERR_EXTRACTION FM_FD_ERR_EXTRACTION
  73. /* No Scheme Selected */
  74. #define FM_PORT_FRM_ERR_NO_SCHEME FM_FD_ERR_NO_SCHEME
  75. /* Keysize Overflow */
  76. #define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW FM_FD_ERR_KEYSIZE_OVERFLOW
  77. /* Frame color is red */
  78. #define FM_PORT_FRM_ERR_COLOR_RED FM_FD_ERR_COLOR_RED
  79. /* Frame color is yellow */
  80. #define FM_PORT_FRM_ERR_COLOR_YELLOW FM_FD_ERR_COLOR_YELLOW
  81. /* Parser Time out Exceed */
  82. #define FM_PORT_FRM_ERR_PRS_TIMEOUT FM_FD_ERR_PRS_TIMEOUT
  83. /* Invalid Soft Parser instruction */
  84. #define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT FM_FD_ERR_PRS_ILL_INSTRUCT
  85. /* Header error was identified during parsing */
  86. #define FM_PORT_FRM_ERR_PRS_HDR_ERR FM_FD_ERR_PRS_HDR_ERR
  87. /* Frame parsed beyind 256 first bytes */
  88. #define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED FM_FD_ERR_BLOCK_LIMIT_EXCEEDED
  89. /* FPM Frame Processing Timeout Exceeded */
  90. #define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001
  91. struct fman_port;
  92. /* A structure for additional Rx port parameters */
  93. struct fman_port_rx_params {
  94. u32 err_fqid; /* Error Queue Id. */
  95. u32 dflt_fqid; /* Default Queue Id. */
  96. u32 pcd_base_fqid; /* PCD base Queue Id. */
  97. u32 pcd_fqs_count; /* Number of PCD FQs. */
  98. /* Which external buffer pools are used
  99. * (up to FMAN_PORT_MAX_EXT_POOLS_NUM), and their sizes.
  100. */
  101. struct fman_ext_pools ext_buf_pools;
  102. };
  103. /* A structure for additional non-Rx port parameters */
  104. struct fman_port_non_rx_params {
  105. /* Error Queue Id. */
  106. u32 err_fqid;
  107. /* For Tx - Default Confirmation queue, 0 means no Tx confirmation
  108. * for processed frames. For OP port - default Rx queue.
  109. */
  110. u32 dflt_fqid;
  111. };
  112. /* A union for additional parameters depending on port type */
  113. union fman_port_specific_params {
  114. /* Rx port parameters structure */
  115. struct fman_port_rx_params rx_params;
  116. /* Non-Rx port parameters structure */
  117. struct fman_port_non_rx_params non_rx_params;
  118. };
  119. /* A structure representing FM initialization parameters */
  120. struct fman_port_params {
  121. /* Virtual Address of memory mapped FM Port registers. */
  122. void *fm;
  123. union fman_port_specific_params specific_params;
  124. /* Additional parameters depending on port type. */
  125. };
  126. int fman_port_config(struct fman_port *port, struct fman_port_params *params);
  127. void fman_port_use_kg_hash(struct fman_port *port, bool enable);
  128. int fman_port_init(struct fman_port *port);
  129. int fman_port_cfg_buf_prefix_content(struct fman_port *port,
  130. struct fman_buffer_prefix_content
  131. *buffer_prefix_content);
  132. int fman_port_disable(struct fman_port *port);
  133. int fman_port_enable(struct fman_port *port);
  134. u32 fman_port_get_qman_channel_id(struct fman_port *port);
  135. int fman_port_get_hash_result_offset(struct fman_port *port, u32 *offset);
  136. int fman_port_get_tstamp(struct fman_port *port, const void *data, u64 *tstamp);
  137. struct fman_port *fman_port_bind(struct device *dev);
  138. #endif /* __FMAN_PORT_H */