cq_enet_desc.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright 2008-2010 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. */
  19. #ifndef _CQ_ENET_DESC_H_
  20. #define _CQ_ENET_DESC_H_
  21. #include "cq_desc.h"
  22. /* Ethernet completion queue descriptor: 16B */
  23. struct cq_enet_wq_desc {
  24. __le16 completed_index;
  25. __le16 q_number;
  26. u8 reserved[11];
  27. u8 type_color;
  28. };
  29. static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc,
  30. u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
  31. {
  32. cq_desc_dec((struct cq_desc *)desc, type,
  33. color, q_number, completed_index);
  34. }
  35. /* Completion queue descriptor: Ethernet receive queue, 16B */
  36. struct cq_enet_rq_desc {
  37. __le16 completed_index_flags;
  38. __le16 q_number_rss_type_flags;
  39. __le32 rss_hash;
  40. __le16 bytes_written_flags;
  41. __le16 vlan;
  42. __le16 checksum_fcoe;
  43. u8 flags;
  44. u8 type_color;
  45. };
  46. #define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12)
  47. #define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13)
  48. #define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14)
  49. #define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15)
  50. #define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4
  51. #define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \
  52. ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1)
  53. #define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0
  54. #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1
  55. #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2
  56. #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3
  57. #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4
  58. #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5
  59. #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6
  60. #define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14)
  61. #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14
  62. #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \
  63. ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1)
  64. #define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14)
  65. #define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15)
  66. #define CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_BITS 12
  67. #define CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_MASK \
  68. ((1 << CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_BITS) - 1)
  69. #define CQ_ENET_RQ_DESC_VLAN_TCI_CFI_MASK (0x1 << 12)
  70. #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_BITS 3
  71. #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_MASK \
  72. ((1 << CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_BITS) - 1)
  73. #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_SHIFT 13
  74. #define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 8
  75. #define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \
  76. ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1)
  77. #define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8
  78. #define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \
  79. ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1)
  80. #define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8
  81. #define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0)
  82. #define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0)
  83. #define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1)
  84. #define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1)
  85. #define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2)
  86. #define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3)
  87. #define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4)
  88. #define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5)
  89. #define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6)
  90. #define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7)
  91. static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
  92. u8 *type, u8 *color, u16 *q_number, u16 *completed_index,
  93. u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type,
  94. u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error,
  95. u8 *vlan_stripped, u16 *vlan_tci, u16 *checksum, u8 *fcoe_sof,
  96. u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof,
  97. u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
  98. u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
  99. {
  100. u16 completed_index_flags;
  101. u16 q_number_rss_type_flags;
  102. u16 bytes_written_flags;
  103. cq_desc_dec((struct cq_desc *)desc, type,
  104. color, q_number, completed_index);
  105. completed_index_flags = le16_to_cpu(desc->completed_index_flags);
  106. q_number_rss_type_flags =
  107. le16_to_cpu(desc->q_number_rss_type_flags);
  108. bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
  109. *ingress_port = (completed_index_flags &
  110. CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
  111. *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
  112. 1 : 0;
  113. *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ?
  114. 1 : 0;
  115. *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ?
  116. 1 : 0;
  117. *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) &
  118. CQ_ENET_RQ_DESC_RSS_TYPE_MASK);
  119. *csum_not_calc = (q_number_rss_type_flags &
  120. CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0;
  121. *rss_hash = le32_to_cpu(desc->rss_hash);
  122. *bytes_written = bytes_written_flags &
  123. CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
  124. *packet_error = (bytes_written_flags &
  125. CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0;
  126. *vlan_stripped = (bytes_written_flags &
  127. CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0;
  128. /*
  129. * Tag Control Information(16) = user_priority(3) + cfi(1) + vlan(12)
  130. */
  131. *vlan_tci = le16_to_cpu(desc->vlan);
  132. if (*fcoe) {
  133. *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) &
  134. CQ_ENET_RQ_DESC_FCOE_SOF_MASK);
  135. *fcoe_fc_crc_ok = (desc->flags &
  136. CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
  137. *fcoe_enc_error = (desc->flags &
  138. CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
  139. *fcoe_eof = (u8)((le16_to_cpu(desc->checksum_fcoe) >>
  140. CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
  141. CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
  142. *checksum = 0;
  143. } else {
  144. *fcoe_sof = 0;
  145. *fcoe_fc_crc_ok = 0;
  146. *fcoe_enc_error = 0;
  147. *fcoe_eof = 0;
  148. *checksum = le16_to_cpu(desc->checksum_fcoe);
  149. }
  150. *tcp_udp_csum_ok =
  151. (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0;
  152. *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0;
  153. *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0;
  154. *ipv4_csum_ok =
  155. (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0;
  156. *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0;
  157. *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0;
  158. *ipv4_fragment =
  159. (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0;
  160. *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0;
  161. }
  162. #endif /* _CQ_ENET_DESC_H_ */