1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef __CARD_DDCB_H__
3 #define __CARD_DDCB_H__
6 * IBM Accelerator Family 'GenWQE'
8 * (C) Copyright IBM Corp. 2013
10 * Author: Frank Haverkamp <haver@linux.vnet.ibm.com>
11 * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
12 * Author: Michael Jung <mijung@gmx.net>
13 * Author: Michael Ruettger <michael@ibmra.de>
16 #include <linux/types.h>
17 #include <asm/byteorder.h>
19 #include "genwqe_driver.h"
20 #include "card_base.h"
23 * struct ddcb - Device Driver Control Block DDCB
24 * @hsi: Hardware software interlock
25 * @shi: Software hardware interlock. Hsi and shi are used to interlock
26 * software and hardware activities. We are using a compare and
27 * swap operation to ensure that there are no races when
28 * activating new DDCBs on the queue, or when we need to
29 * purge a DDCB from a running queue.
30 * @acfunc: Accelerator function addresses a unit within the chip
31 * @cmd: Command to work on
32 * @cmdopts_16: Options for the command
36 * The DDCB data format is big endian. Multiple consequtive DDBCs form
39 #define ASIV_LENGTH 104 /* Old specification without ATS field */
40 #define ASIV_LENGTH_ATS 96 /* New specification with ATS field */
45 __be32 icrc_hsi_shi_32; /* iCRC, Hardware/SW interlock */
52 u8 pre; /* Preamble */
53 u8 xdir; /* Execution Directives */
54 __be16 seqnum_16; /* Sequence Number */
56 u8 acfunc; /* Accelerator Function.. */
57 u8 cmd; /* Command. */
58 __be16 cmdopts_16; /* Command Options */
59 u8 sur; /* Status Update Rate */
60 u8 psp; /* Protection Section Pointer */
61 __be16 rsvd_0e_16; /* Reserved invariant */
63 __be64 fwiv_64; /* Firmware Invariant. */
67 __be64 ats_64; /* Address Translation Spec */
68 u8 asiv[ASIV_LENGTH_ATS]; /* New ASIV */
70 u8 __asiv[ASIV_LENGTH]; /* obsolete */
72 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 */
78 __be64 deque_ts_64; /* Deque Time Stamp. */
80 __be16 retc_16; /* Return Code */
81 __be16 attn_16; /* Attention/Extended Error Codes */
82 __be32 progress_32; /* Progress indicator. */
84 __be64 cmplt_ts_64; /* Completion Time Stamp. */
86 /* The following layout matches the new service layer format */
87 __be32 ibdc_32; /* Inbound Data Count (* 256) */
88 __be32 obdc_32; /* Outbound Data Count (* 256) */
90 __be64 rsvd_SLH_64; /* Reserved for hardware */
91 union { /* private data for driver */
95 __be64 disp_ts_64; /* Dispatch TimeStamp */
96 } __attribute__((__packed__));
98 /* CRC polynomials for DDCB */
99 #define CRC16_POLYNOMIAL 0x1021
102 * SHI: Software to Hardware Interlock
103 * This 1 byte field is written by software to interlock the
104 * movement of one queue entry to another with the hardware in the
107 #define DDCB_SHI_INTR 0x04 /* Bit 2 */
108 #define DDCB_SHI_PURGE 0x02 /* Bit 1 */
109 #define DDCB_SHI_NEXT 0x01 /* Bit 0 */
112 * HSI: Hardware to Software interlock
113 * This 1 byte field is written by hardware to interlock the movement
114 * of one queue entry to another with the software in the chip.
116 #define DDCB_HSI_COMPLETED 0x40 /* Bit 6 */
117 #define DDCB_HSI_FETCHED 0x04 /* Bit 2 */
120 * Accessing HSI/SHI is done 32-bit wide
121 * Normally 16-bit access would work too, but on some platforms the
122 * 16 compare and swap operation is not supported. Therefore
123 * switching to 32-bit such that those platforms will work too.
127 #define DDCB_INTR_BE32 cpu_to_be32(0x00000004)
128 #define DDCB_PURGE_BE32 cpu_to_be32(0x00000002)
129 #define DDCB_NEXT_BE32 cpu_to_be32(0x00000001)
130 #define DDCB_COMPLETED_BE32 cpu_to_be32(0x00004000)
131 #define DDCB_FETCHED_BE32 cpu_to_be32(0x00000400)
133 /* Definitions of DDCB presets */
134 #define DDCB_PRESET_PRE 0x80
135 #define ICRC_LENGTH(n) ((n) + 8 + 8 + 8) /* used ASIV + hdr fields */
136 #define VCRC_LENGTH(n) ((n)) /* used ASV */
139 * Genwqe Scatter Gather list
140 * Each element has up to 8 entries.
141 * The chaining element is element 0 cause of prefetching needs.
145 * 0b0110 Chained descriptor. The descriptor is describing the next
148 #define SG_CHAINED (0x6)
151 * 0b0010 First entry of a descriptor list. Start from a Buffer-Empty
154 #define SG_DATA (0x2)
157 * 0b0000 Early terminator. This is the last entry on the list
158 * irregardless of the length indicated.
160 #define SG_END_LIST (0x0)
163 * struct sglist - Scatter gather list
164 * @target_addr: Either a dma addr of memory to work on or a
165 * dma addr or a subsequent sglist block.
166 * @len: Length of the data block.
169 * Depending on the command the GenWQE card can use a scatter gather
170 * list to describe the memory it works on. Always 8 sg_entry's form
179 #endif /* __CARD_DDCB_H__ */