cq_enet_desc.h 5.6 KB

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