unsolicited_frame_control.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * * Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. * * Redistributions in binary form must reproduce the above copyright
  36. * notice, this list of conditions and the following disclaimer in
  37. * the documentation and/or other materials provided with the
  38. * distribution.
  39. * * Neither the name of Intel Corporation nor the names of its
  40. * contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  46. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  47. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  49. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
  56. #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
  57. #include "isci.h"
  58. #include "scu_unsolicited_frame.h"
  59. /**
  60. * enum unsolicited_frame_state -
  61. *
  62. * This enumeration represents the current unsolicited frame state. The
  63. * controller object can not updtate the hardware unsolicited frame put pointer
  64. * unless it has already processed the priror unsolicited frames.
  65. */
  66. enum unsolicited_frame_state {
  67. /**
  68. * This state is when the frame is empty and not in use. It is
  69. * different from the released state in that the hardware could DMA
  70. * data to this frame buffer.
  71. */
  72. UNSOLICITED_FRAME_EMPTY,
  73. /**
  74. * This state is set when the frame buffer is in use by by some
  75. * object in the system.
  76. */
  77. UNSOLICITED_FRAME_IN_USE,
  78. /**
  79. * This state is set when the frame is returned to the free pool
  80. * but one or more frames prior to this one are still in use.
  81. * Once all of the frame before this one are freed it will go to
  82. * the empty state.
  83. */
  84. UNSOLICITED_FRAME_RELEASED,
  85. UNSOLICITED_FRAME_MAX_STATES
  86. };
  87. /**
  88. * struct scic_sds_unsolicited_frame -
  89. *
  90. * This is the unsolicited frame data structure it acts as the container for
  91. * the current frame state, frame header and frame buffer.
  92. */
  93. struct scic_sds_unsolicited_frame {
  94. /**
  95. * This field contains the current frame state
  96. */
  97. enum unsolicited_frame_state state;
  98. /**
  99. * This field points to the frame header data.
  100. */
  101. struct scu_unsolicited_frame_header *header;
  102. /**
  103. * This field points to the frame buffer data.
  104. */
  105. void *buffer;
  106. };
  107. /**
  108. * struct scic_sds_uf_header_array -
  109. *
  110. * This structure contains all of the unsolicited frame header information.
  111. */
  112. struct scic_sds_uf_header_array {
  113. /**
  114. * This field is represents a virtual pointer to the start
  115. * address of the UF address table. The table contains
  116. * 64-bit pointers as required by the hardware.
  117. */
  118. struct scu_unsolicited_frame_header *array;
  119. /**
  120. * This field specifies the physical address location for the UF
  121. * buffer array.
  122. */
  123. dma_addr_t physical_address;
  124. };
  125. /**
  126. * struct scic_sds_uf_buffer_array -
  127. *
  128. * This structure contains all of the unsolicited frame buffer (actual payload)
  129. * information.
  130. */
  131. struct scic_sds_uf_buffer_array {
  132. /**
  133. * This field is the minimum number of unsolicited frames supported by the
  134. * hardware and the number of unsolicited frames requested by the software.
  135. */
  136. u32 count;
  137. /**
  138. * This field is the SCIC_UNSOLICITED_FRAME data its used to manage
  139. * the data for the unsolicited frame requests. It also represents
  140. * the virtual address location that corresponds to the
  141. * physical_address field.
  142. */
  143. struct scic_sds_unsolicited_frame array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE];
  144. /**
  145. * This field specifies the physical address location for the UF
  146. * buffer array.
  147. */
  148. dma_addr_t physical_address;
  149. };
  150. /**
  151. * struct scic_sds_uf_address_table_array -
  152. *
  153. * This object maintains all of the unsolicited frame address table specific
  154. * data. The address table is a collection of 64-bit pointers that point to
  155. * 1KB buffers into which the silicon will DMA unsolicited frames.
  156. */
  157. struct scic_sds_uf_address_table_array {
  158. /**
  159. * This field specifies the actual programmed size of the
  160. * unsolicited frame buffer address table. The size of the table
  161. * can be larger than the actual number of UF buffers, but it must
  162. * be a power of 2 and the last entry in the table is not allowed
  163. * to be NULL.
  164. */
  165. u32 count;
  166. /**
  167. * This field represents a virtual pointer that refers to the
  168. * starting address of the UF address table.
  169. * 64-bit pointers are required by the hardware.
  170. */
  171. dma_addr_t *array;
  172. /**
  173. * This field specifies the physical address location for the UF
  174. * address table.
  175. */
  176. dma_addr_t physical_address;
  177. };
  178. /**
  179. * struct scic_sds_unsolicited_frame_control -
  180. *
  181. * This object contains all of the data necessary to handle unsolicited frames.
  182. */
  183. struct scic_sds_unsolicited_frame_control {
  184. /**
  185. * This field is the software copy of the unsolicited frame queue
  186. * get pointer. The controller object writes this value to the
  187. * hardware to let the hardware put more unsolicited frame entries.
  188. */
  189. u32 get;
  190. /**
  191. * This field contains all of the unsolicited frame header
  192. * specific fields.
  193. */
  194. struct scic_sds_uf_header_array headers;
  195. /**
  196. * This field contains all of the unsolicited frame buffer
  197. * specific fields.
  198. */
  199. struct scic_sds_uf_buffer_array buffers;
  200. /**
  201. * This field contains all of the unsolicited frame address table
  202. * specific fields.
  203. */
  204. struct scic_sds_uf_address_table_array address_table;
  205. };
  206. struct scic_sds_controller;
  207. int scic_sds_unsolicited_frame_control_construct(struct scic_sds_controller *scic);
  208. enum sci_status scic_sds_unsolicited_frame_control_get_header(
  209. struct scic_sds_unsolicited_frame_control *uf_control,
  210. u32 frame_index,
  211. void **frame_header);
  212. enum sci_status scic_sds_unsolicited_frame_control_get_buffer(
  213. struct scic_sds_unsolicited_frame_control *uf_control,
  214. u32 frame_index,
  215. void **frame_buffer);
  216. bool scic_sds_unsolicited_frame_control_release_frame(
  217. struct scic_sds_unsolicited_frame_control *uf_control,
  218. u32 frame_index);
  219. #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */