cq_exch_desc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. */
  18. #ifndef _CQ_EXCH_DESC_H_
  19. #define _CQ_EXCH_DESC_H_
  20. #include "cq_desc.h"
  21. /* Exchange completion queue descriptor: 16B */
  22. struct cq_exch_wq_desc {
  23. u16 completed_index;
  24. u16 q_number;
  25. u16 exchange_id;
  26. u8 tmpl;
  27. u8 reserved0;
  28. u32 reserved1;
  29. u8 exch_status;
  30. u8 reserved2[2];
  31. u8 type_color;
  32. };
  33. #define CQ_EXCH_WQ_STATUS_BITS 2
  34. #define CQ_EXCH_WQ_STATUS_MASK ((1 << CQ_EXCH_WQ_STATUS_BITS) - 1)
  35. enum cq_exch_status_types {
  36. CQ_EXCH_WQ_STATUS_TYPE_COMPLETE = 0,
  37. CQ_EXCH_WQ_STATUS_TYPE_ABORT = 1,
  38. CQ_EXCH_WQ_STATUS_TYPE_SGL_EOF = 2,
  39. CQ_EXCH_WQ_STATUS_TYPE_TMPL_ERR = 3,
  40. };
  41. static inline void cq_exch_wq_desc_dec(struct cq_exch_wq_desc *desc_ptr,
  42. u8 *type,
  43. u8 *color,
  44. u16 *q_number,
  45. u16 *completed_index,
  46. u8 *exch_status)
  47. {
  48. cq_desc_dec((struct cq_desc *)desc_ptr, type,
  49. color, q_number, completed_index);
  50. *exch_status = desc_ptr->exch_status & CQ_EXCH_WQ_STATUS_MASK;
  51. }
  52. struct cq_fcp_rq_desc {
  53. u16 completed_index_eop_sop_prt;
  54. u16 q_number;
  55. u16 exchange_id;
  56. u16 tmpl;
  57. u16 bytes_written;
  58. u16 vlan;
  59. u8 sof;
  60. u8 eof;
  61. u8 fcs_fer_fck;
  62. u8 type_color;
  63. };
  64. #define CQ_FCP_RQ_DESC_FLAGS_SOP (1 << 15)
  65. #define CQ_FCP_RQ_DESC_FLAGS_EOP (1 << 14)
  66. #define CQ_FCP_RQ_DESC_FLAGS_PRT (1 << 12)
  67. #define CQ_FCP_RQ_DESC_TMPL_MASK 0x1f
  68. #define CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK 0x3fff
  69. #define CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT 14
  70. #define CQ_FCP_RQ_DESC_PACKET_ERR_MASK (1 << CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT)
  71. #define CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT 15
  72. #define CQ_FCP_RQ_DESC_VS_STRIPPED_MASK (1 << CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT)
  73. #define CQ_FCP_RQ_DESC_FC_CRC_OK_MASK 0x1
  74. #define CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT 1
  75. #define CQ_FCP_RQ_DESC_FCOE_ERR_MASK (1 << CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT)
  76. #define CQ_FCP_RQ_DESC_FCS_OK_SHIFT 7
  77. #define CQ_FCP_RQ_DESC_FCS_OK_MASK (1 << CQ_FCP_RQ_DESC_FCS_OK_SHIFT)
  78. static inline void cq_fcp_rq_desc_dec(struct cq_fcp_rq_desc *desc_ptr,
  79. u8 *type,
  80. u8 *color,
  81. u16 *q_number,
  82. u16 *completed_index,
  83. u8 *eop,
  84. u8 *sop,
  85. u8 *fck,
  86. u16 *exchange_id,
  87. u16 *tmpl,
  88. u32 *bytes_written,
  89. u8 *sof,
  90. u8 *eof,
  91. u8 *ingress_port,
  92. u8 *packet_err,
  93. u8 *fcoe_err,
  94. u8 *fcs_ok,
  95. u8 *vlan_stripped,
  96. u16 *vlan)
  97. {
  98. cq_desc_dec((struct cq_desc *)desc_ptr, type,
  99. color, q_number, completed_index);
  100. *eop = (desc_ptr->completed_index_eop_sop_prt &
  101. CQ_FCP_RQ_DESC_FLAGS_EOP) ? 1 : 0;
  102. *sop = (desc_ptr->completed_index_eop_sop_prt &
  103. CQ_FCP_RQ_DESC_FLAGS_SOP) ? 1 : 0;
  104. *ingress_port =
  105. (desc_ptr->completed_index_eop_sop_prt &
  106. CQ_FCP_RQ_DESC_FLAGS_PRT) ? 1 : 0;
  107. *exchange_id = desc_ptr->exchange_id;
  108. *tmpl = desc_ptr->tmpl & CQ_FCP_RQ_DESC_TMPL_MASK;
  109. *bytes_written =
  110. desc_ptr->bytes_written & CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK;
  111. *packet_err =
  112. (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_PACKET_ERR_MASK) >>
  113. CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT;
  114. *vlan_stripped =
  115. (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_VS_STRIPPED_MASK) >>
  116. CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT;
  117. *vlan = desc_ptr->vlan;
  118. *sof = desc_ptr->sof;
  119. *fck = desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FC_CRC_OK_MASK;
  120. *fcoe_err = (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCOE_ERR_MASK) >>
  121. CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT;
  122. *eof = desc_ptr->eof;
  123. *fcs_ok =
  124. (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCS_OK_MASK) >>
  125. CQ_FCP_RQ_DESC_FCS_OK_SHIFT;
  126. }
  127. struct cq_sgl_desc {
  128. u16 exchange_id;
  129. u16 q_number;
  130. u32 active_burst_offset;
  131. u32 tot_data_bytes;
  132. u16 tmpl;
  133. u8 sgl_err;
  134. u8 type_color;
  135. };
  136. enum cq_sgl_err_types {
  137. CQ_SGL_ERR_NO_ERROR = 0,
  138. CQ_SGL_ERR_OVERFLOW, /* data ran beyond end of SGL */
  139. CQ_SGL_ERR_SGL_LCL_ADDR_ERR, /* sgl access to local vnic addr illegal*/
  140. CQ_SGL_ERR_ADDR_RSP_ERR, /* sgl address error */
  141. CQ_SGL_ERR_DATA_RSP_ERR, /* sgl data rsp error */
  142. CQ_SGL_ERR_CNT_ZERO_ERR, /* SGL count is 0 */
  143. CQ_SGL_ERR_CNT_MAX_ERR, /* SGL count is larger than supported */
  144. CQ_SGL_ERR_ORDER_ERR, /* frames recv on both ports, order err */
  145. CQ_SGL_ERR_DATA_LCL_ADDR_ERR,/* sgl data buf to local vnic addr ill */
  146. CQ_SGL_ERR_HOST_CQ_ERR, /* host cq entry to local vnic addr ill */
  147. };
  148. #define CQ_SGL_SGL_ERR_MASK 0x1f
  149. #define CQ_SGL_TMPL_MASK 0x1f
  150. static inline void cq_sgl_desc_dec(struct cq_sgl_desc *desc_ptr,
  151. u8 *type,
  152. u8 *color,
  153. u16 *q_number,
  154. u16 *exchange_id,
  155. u32 *active_burst_offset,
  156. u32 *tot_data_bytes,
  157. u16 *tmpl,
  158. u8 *sgl_err)
  159. {
  160. /* Cheat a little by assuming exchange_id is the same as completed
  161. index */
  162. cq_desc_dec((struct cq_desc *)desc_ptr, type, color, q_number,
  163. exchange_id);
  164. *active_burst_offset = desc_ptr->active_burst_offset;
  165. *tot_data_bytes = desc_ptr->tot_data_bytes;
  166. *tmpl = desc_ptr->tmpl & CQ_SGL_TMPL_MASK;
  167. *sgl_err = desc_ptr->sgl_err & CQ_SGL_SGL_ERR_MASK;
  168. }
  169. #endif /* _CQ_EXCH_DESC_H_ */