card_ddcb.h 5.2 KB

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