card_ddcb.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #ifndef __CARD_DDCB_H__
  2. #define __CARD_DDCB_H__
  3. /**
  4. * IBM Accelerator Family 'GenWQE'
  5. *
  6. * (C) Copyright IBM Corp. 2013
  7. *
  8. * Author: Frank Haverkamp <haver@linux.vnet.ibm.com>
  9. * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
  10. * Author: Michael Jung <mijung@gmx.net>
  11. * Author: Michael Ruettger <michael@ibmra.de>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2, or (at your option)
  16. * any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. */
  23. #include <linux/types.h>
  24. #include <asm/byteorder.h>
  25. #include "genwqe_driver.h"
  26. #include "card_base.h"
  27. /**
  28. * struct ddcb - Device Driver Control Block DDCB
  29. * @hsi: Hardware software interlock
  30. * @shi: Software hardware interlock. Hsi and shi are used to interlock
  31. * software and hardware activities. We are using a compare and
  32. * swap operation to ensure that there are no races when
  33. * activating new DDCBs on the queue, or when we need to
  34. * purge a DDCB from a running queue.
  35. * @acfunc: Accelerator function addresses a unit within the chip
  36. * @cmd: Command to work on
  37. * @cmdopts_16: Options for the command
  38. * @asiv: Input data
  39. * @asv: Output data
  40. *
  41. * The DDCB data format is big endian. Multiple consequtive DDBCs form
  42. * a DDCB queue.
  43. */
  44. #define ASIV_LENGTH 104 /* Old specification without ATS field */
  45. #define ASIV_LENGTH_ATS 96 /* New specification with ATS field */
  46. #define ASV_LENGTH 64
  47. struct ddcb {
  48. union {
  49. __be32 icrc_hsi_shi_32; /* iCRC, Hardware/SW interlock */
  50. struct {
  51. __be16 icrc_16;
  52. u8 hsi;
  53. u8 shi;
  54. };
  55. };
  56. u8 pre; /* Preamble */
  57. u8 xdir; /* Execution Directives */
  58. __be16 seqnum_16; /* Sequence Number */
  59. u8 acfunc; /* Accelerator Function.. */
  60. u8 cmd; /* Command. */
  61. __be16 cmdopts_16; /* Command Options */
  62. u8 sur; /* Status Update Rate */
  63. u8 psp; /* Protection Section Pointer */
  64. __be16 rsvd_0e_16; /* Reserved invariant */
  65. __be64 fwiv_64; /* Firmware Invariant. */
  66. union {
  67. struct {
  68. __be64 ats_64; /* Address Translation Spec */
  69. u8 asiv[ASIV_LENGTH_ATS]; /* New ASIV */
  70. } n;
  71. u8 __asiv[ASIV_LENGTH]; /* obsolete */
  72. };
  73. u8 asv[ASV_LENGTH]; /* Appl Spec Variant */
  74. __be16 rsvd_c0_16; /* Reserved Variant */
  75. __be16 vcrc_16; /* Variant CRC */
  76. __be32 rsvd_32; /* Reserved unprotected */
  77. __be64 deque_ts_64; /* Deque Time Stamp. */
  78. __be16 retc_16; /* Return Code */
  79. __be16 attn_16; /* Attention/Extended Error Codes */
  80. __be32 progress_32; /* Progress indicator. */
  81. __be64 cmplt_ts_64; /* Completion Time Stamp. */
  82. /* The following layout matches the new service layer format */
  83. __be32 ibdc_32; /* Inbound Data Count (* 256) */
  84. __be32 obdc_32; /* Outbound Data Count (* 256) */
  85. __be64 rsvd_SLH_64; /* Reserved for hardware */
  86. union { /* private data for driver */
  87. u8 priv[8];
  88. __be64 priv_64;
  89. };
  90. __be64 disp_ts_64; /* Dispatch TimeStamp */
  91. } __attribute__((__packed__));
  92. /* CRC polynomials for DDCB */
  93. #define CRC16_POLYNOMIAL 0x1021
  94. /*
  95. * SHI: Software to Hardware Interlock
  96. * This 1 byte field is written by software to interlock the
  97. * movement of one queue entry to another with the hardware in the
  98. * chip.
  99. */
  100. #define DDCB_SHI_INTR 0x04 /* Bit 2 */
  101. #define DDCB_SHI_PURGE 0x02 /* Bit 1 */
  102. #define DDCB_SHI_NEXT 0x01 /* Bit 0 */
  103. /*
  104. * HSI: Hardware to Software interlock
  105. * This 1 byte field is written by hardware to interlock the movement
  106. * of one queue entry to another with the software in the chip.
  107. */
  108. #define DDCB_HSI_COMPLETED 0x40 /* Bit 6 */
  109. #define DDCB_HSI_FETCHED 0x04 /* Bit 2 */
  110. /*
  111. * Accessing HSI/SHI is done 32-bit wide
  112. * Normally 16-bit access would work too, but on some platforms the
  113. * 16 compare and swap operation is not supported. Therefore
  114. * switching to 32-bit such that those platforms will work too.
  115. *
  116. * iCRC HSI/SHI
  117. */
  118. #define DDCB_INTR_BE32 cpu_to_be32(0x00000004)
  119. #define DDCB_PURGE_BE32 cpu_to_be32(0x00000002)
  120. #define DDCB_NEXT_BE32 cpu_to_be32(0x00000001)
  121. #define DDCB_COMPLETED_BE32 cpu_to_be32(0x00004000)
  122. #define DDCB_FETCHED_BE32 cpu_to_be32(0x00000400)
  123. /* Definitions of DDCB presets */
  124. #define DDCB_PRESET_PRE 0x80
  125. #define ICRC_LENGTH(n) ((n) + 8 + 8 + 8) /* used ASIV + hdr fields */
  126. #define VCRC_LENGTH(n) ((n)) /* used ASV */
  127. /*
  128. * Genwqe Scatter Gather list
  129. * Each element has up to 8 entries.
  130. * The chaining element is element 0 cause of prefetching needs.
  131. */
  132. /*
  133. * 0b0110 Chained descriptor. The descriptor is describing the next
  134. * descriptor list.
  135. */
  136. #define SG_CHAINED (0x6)
  137. /*
  138. * 0b0010 First entry of a descriptor list. Start from a Buffer-Empty
  139. * condition.
  140. */
  141. #define SG_DATA (0x2)
  142. /*
  143. * 0b0000 Early terminator. This is the last entry on the list
  144. * irregardless of the length indicated.
  145. */
  146. #define SG_END_LIST (0x0)
  147. /**
  148. * struct sglist - Scatter gather list
  149. * @target_addr: Either a dma addr of memory to work on or a
  150. * dma addr or a subsequent sglist block.
  151. * @len: Length of the data block.
  152. * @flags: See above.
  153. *
  154. * Depending on the command the GenWQE card can use a scatter gather
  155. * list to describe the memory it works on. Always 8 sg_entry's form
  156. * a block.
  157. */
  158. struct sg_entry {
  159. __be64 target_addr;
  160. __be32 len;
  161. __be32 flags;
  162. };
  163. #endif /* __CARD_DDCB_H__ */