cq_enet_desc.h 6.2 KB

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