unsolicited_frame_control.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. #define SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS 15
  59. /**
  60. * struct scu_unsolicited_frame_header -
  61. *
  62. * This structure delineates the format of an unsolicited frame header. The
  63. * first DWORD are UF attributes defined by the silicon architecture. The data
  64. * depicts actual header information received on the link.
  65. */
  66. struct scu_unsolicited_frame_header {
  67. /**
  68. * This field indicates if there is an Initiator Index Table entry with
  69. * which this header is associated.
  70. */
  71. u32 iit_exists:1;
  72. /**
  73. * This field simply indicates the protocol type (i.e. SSP, STP, SMP).
  74. */
  75. u32 protocol_type:3;
  76. /**
  77. * This field indicates if the frame is an address frame (IAF or OAF)
  78. * or if it is a information unit frame.
  79. */
  80. u32 is_address_frame:1;
  81. /**
  82. * This field simply indicates the connection rate at which the frame
  83. * was received.
  84. */
  85. u32 connection_rate:4;
  86. u32 reserved:23;
  87. /**
  88. * This field represents the actual header data received on the link.
  89. */
  90. u32 data[SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS];
  91. };
  92. /**
  93. * enum unsolicited_frame_state -
  94. *
  95. * This enumeration represents the current unsolicited frame state. The
  96. * controller object can not updtate the hardware unsolicited frame put pointer
  97. * unless it has already processed the priror unsolicited frames.
  98. */
  99. enum unsolicited_frame_state {
  100. /**
  101. * This state is when the frame is empty and not in use. It is
  102. * different from the released state in that the hardware could DMA
  103. * data to this frame buffer.
  104. */
  105. UNSOLICITED_FRAME_EMPTY,
  106. /**
  107. * This state is set when the frame buffer is in use by by some
  108. * object in the system.
  109. */
  110. UNSOLICITED_FRAME_IN_USE,
  111. /**
  112. * This state is set when the frame is returned to the free pool
  113. * but one or more frames prior to this one are still in use.
  114. * Once all of the frame before this one are freed it will go to
  115. * the empty state.
  116. */
  117. UNSOLICITED_FRAME_RELEASED,
  118. UNSOLICITED_FRAME_MAX_STATES
  119. };
  120. /**
  121. * struct sci_unsolicited_frame -
  122. *
  123. * This is the unsolicited frame data structure it acts as the container for
  124. * the current frame state, frame header and frame buffer.
  125. */
  126. struct sci_unsolicited_frame {
  127. /**
  128. * This field contains the current frame state
  129. */
  130. enum unsolicited_frame_state state;
  131. /**
  132. * This field points to the frame header data.
  133. */
  134. struct scu_unsolicited_frame_header *header;
  135. /**
  136. * This field points to the frame buffer data.
  137. */
  138. void *buffer;
  139. };
  140. /**
  141. * struct sci_uf_header_array -
  142. *
  143. * This structure contains all of the unsolicited frame header information.
  144. */
  145. struct sci_uf_header_array {
  146. /**
  147. * This field is represents a virtual pointer to the start
  148. * address of the UF address table. The table contains
  149. * 64-bit pointers as required by the hardware.
  150. */
  151. struct scu_unsolicited_frame_header *array;
  152. /**
  153. * This field specifies the physical address location for the UF
  154. * buffer array.
  155. */
  156. dma_addr_t physical_address;
  157. };
  158. /**
  159. * struct sci_uf_buffer_array -
  160. *
  161. * This structure contains all of the unsolicited frame buffer (actual payload)
  162. * information.
  163. */
  164. struct sci_uf_buffer_array {
  165. /**
  166. * This field is the unsolicited frame data its used to manage
  167. * the data for the unsolicited frame requests. It also represents
  168. * the virtual address location that corresponds to the
  169. * physical_address field.
  170. */
  171. struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES];
  172. /**
  173. * This field specifies the physical address location for the UF
  174. * buffer array.
  175. */
  176. dma_addr_t physical_address;
  177. };
  178. /**
  179. * struct sci_uf_address_table_array -
  180. *
  181. * This object maintains all of the unsolicited frame address table specific
  182. * data. The address table is a collection of 64-bit pointers that point to
  183. * 1KB buffers into which the silicon will DMA unsolicited frames.
  184. */
  185. struct sci_uf_address_table_array {
  186. /**
  187. * This field represents a virtual pointer that refers to the
  188. * starting address of the UF address table.
  189. * 64-bit pointers are required by the hardware.
  190. */
  191. u64 *array;
  192. /**
  193. * This field specifies the physical address location for the UF
  194. * address table.
  195. */
  196. dma_addr_t physical_address;
  197. };
  198. /**
  199. * struct sci_unsolicited_frame_control -
  200. *
  201. * This object contains all of the data necessary to handle unsolicited frames.
  202. */
  203. struct sci_unsolicited_frame_control {
  204. /**
  205. * This field is the software copy of the unsolicited frame queue
  206. * get pointer. The controller object writes this value to the
  207. * hardware to let the hardware put more unsolicited frame entries.
  208. */
  209. u32 get;
  210. /**
  211. * This field contains all of the unsolicited frame header
  212. * specific fields.
  213. */
  214. struct sci_uf_header_array headers;
  215. /**
  216. * This field contains all of the unsolicited frame buffer
  217. * specific fields.
  218. */
  219. struct sci_uf_buffer_array buffers;
  220. /**
  221. * This field contains all of the unsolicited frame address table
  222. * specific fields.
  223. */
  224. struct sci_uf_address_table_array address_table;
  225. };
  226. #define SCI_UFI_BUF_SIZE (SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE)
  227. #define SCI_UFI_HDR_SIZE (SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header))
  228. #define SCI_UFI_TOTAL_SIZE (SCI_UFI_BUF_SIZE + SCI_UFI_HDR_SIZE + SCU_MAX_UNSOLICITED_FRAMES * sizeof(u64))
  229. struct isci_host;
  230. void sci_unsolicited_frame_control_construct(struct isci_host *ihost);
  231. enum sci_status sci_unsolicited_frame_control_get_header(
  232. struct sci_unsolicited_frame_control *uf_control,
  233. u32 frame_index,
  234. void **frame_header);
  235. enum sci_status sci_unsolicited_frame_control_get_buffer(
  236. struct sci_unsolicited_frame_control *uf_control,
  237. u32 frame_index,
  238. void **frame_buffer);
  239. bool sci_unsolicited_frame_control_release_frame(
  240. struct sci_unsolicited_frame_control *uf_control,
  241. u32 frame_index);
  242. #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */