adf_pf2vf_msg.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. GPL LICENSE SUMMARY
  5. Copyright(c) 2015 Intel Corporation.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License as
  8. published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. Contact Information:
  14. qat-linux@intel.com
  15. BSD LICENSE
  16. Copyright(c) 2015 Intel Corporation.
  17. Redistribution and use in source and binary forms, with or without
  18. modification, are permitted provided that the following conditions
  19. are met:
  20. * Redistributions of source code must retain the above copyright
  21. notice, this list of conditions and the following disclaimer.
  22. * Redistributions in binary form must reproduce the above copyright
  23. notice, this list of conditions and the following disclaimer in
  24. the documentation and/or other materials provided with the
  25. distribution.
  26. * Neither the name of Intel Corporation nor the names of its
  27. contributors may be used to endorse or promote products derived
  28. from this software without specific prior written permission.
  29. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. */
  41. #ifndef ADF_PF2VF_MSG_H
  42. #define ADF_PF2VF_MSG_H
  43. /*
  44. * PF<->VF Messaging
  45. * The PF has an array of 32-bit PF2VF registers, one for each VF. The
  46. * PF can access all these registers; each VF can access only the one
  47. * register associated with that particular VF.
  48. *
  49. * The register functionally is split into two parts:
  50. * The bottom half is for PF->VF messages. In particular when the first
  51. * bit of this register (bit 0) gets set an interrupt will be triggered
  52. * in the respective VF.
  53. * The top half is for VF->PF messages. In particular when the first bit
  54. * of this half of register (bit 16) gets set an interrupt will be triggered
  55. * in the PF.
  56. *
  57. * The remaining bits within this register are available to encode messages.
  58. * and implement a collision control mechanism to prevent concurrent use of
  59. * the PF2VF register by both the PF and VF.
  60. *
  61. * 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  62. * _______________________________________________
  63. * | | | | | | | | | | | | | | | | |
  64. * +-----------------------------------------------+
  65. * \___________________________/ \_________/ ^ ^
  66. * ^ ^ | |
  67. * | | | VF2PF Int
  68. * | | Message Origin
  69. * | Message Type
  70. * Message-specific Data/Reserved
  71. *
  72. * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
  73. * _______________________________________________
  74. * | | | | | | | | | | | | | | | | |
  75. * +-----------------------------------------------+
  76. * \___________________________/ \_________/ ^ ^
  77. * ^ ^ | |
  78. * | | | PF2VF Int
  79. * | | Message Origin
  80. * | Message Type
  81. * Message-specific Data/Reserved
  82. *
  83. * Message Origin (Should always be 1)
  84. * A legacy out-of-tree QAT driver allowed for a set of messages not supported
  85. * by this driver; these had a Msg Origin of 0 and are ignored by this driver.
  86. *
  87. * When a PF or VF attempts to send a message in the lower or upper 16 bits,
  88. * respectively, the other 16 bits are written to first with a defined
  89. * IN_USE_BY pattern as part of a collision control scheme (see adf_iov_putmsg).
  90. */
  91. #define ADF_PFVF_COMPATIBILITY_VERSION 0x1 /* PF<->VF compat */
  92. /* PF->VF messages */
  93. #define ADF_PF2VF_INT BIT(0)
  94. #define ADF_PF2VF_MSGORIGIN_SYSTEM BIT(1)
  95. #define ADF_PF2VF_MSGTYPE_MASK 0x0000003C
  96. #define ADF_PF2VF_MSGTYPE_SHIFT 2
  97. #define ADF_PF2VF_MSGTYPE_RESTARTING 0x01
  98. #define ADF_PF2VF_MSGTYPE_VERSION_RESP 0x02
  99. #define ADF_PF2VF_IN_USE_BY_PF 0x6AC20000
  100. #define ADF_PF2VF_IN_USE_BY_PF_MASK 0xFFFE0000
  101. /* PF->VF Version Response */
  102. #define ADF_PF2VF_VERSION_RESP_VERS_MASK 0x00003FC0
  103. #define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 6
  104. #define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x0000C000
  105. #define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 14
  106. #define ADF_PF2VF_MINORVERSION_SHIFT 6
  107. #define ADF_PF2VF_MAJORVERSION_SHIFT 10
  108. #define ADF_PF2VF_VF_COMPATIBLE 1
  109. #define ADF_PF2VF_VF_INCOMPATIBLE 2
  110. #define ADF_PF2VF_VF_COMPAT_UNKNOWN 3
  111. /* VF->PF messages */
  112. #define ADF_VF2PF_IN_USE_BY_VF 0x00006AC2
  113. #define ADF_VF2PF_IN_USE_BY_VF_MASK 0x0000FFFE
  114. #define ADF_VF2PF_INT BIT(16)
  115. #define ADF_VF2PF_MSGORIGIN_SYSTEM BIT(17)
  116. #define ADF_VF2PF_MSGTYPE_MASK 0x003C0000
  117. #define ADF_VF2PF_MSGTYPE_SHIFT 18
  118. #define ADF_VF2PF_MSGTYPE_INIT 0x3
  119. #define ADF_VF2PF_MSGTYPE_SHUTDOWN 0x4
  120. #define ADF_VF2PF_MSGTYPE_VERSION_REQ 0x5
  121. #define ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ 0x6
  122. /* VF->PF Compatible Version Request */
  123. #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22
  124. /* Collision detection */
  125. #define ADF_IOV_MSG_COLLISION_DETECT_DELAY 10
  126. #define ADF_IOV_MSG_ACK_DELAY 2
  127. #define ADF_IOV_MSG_ACK_MAX_RETRY 100
  128. #define ADF_IOV_MSG_RETRY_DELAY 5
  129. #define ADF_IOV_MSG_MAX_RETRIES 3
  130. #define ADF_IOV_MSG_RESP_TIMEOUT (ADF_IOV_MSG_ACK_DELAY * \
  131. ADF_IOV_MSG_ACK_MAX_RETRY + \
  132. ADF_IOV_MSG_COLLISION_DETECT_DELAY)
  133. #endif /* ADF_IOV_MSG_H */