1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 #ifndef ADF_PF2VF_MSG_H
5 #define ADF_PF2VF_MSG_H
6
7 /*
8 * PF<->VF Messaging
9 * The PF has an array of 32-bit PF2VF registers, one for each VF. The
10 * PF can access all these registers; each VF can access only the one
11 * register associated with that particular VF.
12 *
13 * The register functionally is split into two parts:
14 * The bottom half is for PF->VF messages. In particular when the first
15 * bit of this register (bit 0) gets set an interrupt will be triggered
16 * in the respective VF.
17 * The top half is for VF->PF messages. In particular when the first bit
18 * of this half of register (bit 16) gets set an interrupt will be triggered
19 * in the PF.
20 *
21 * The remaining bits within this register are available to encode messages.
22 * and implement a collision control mechanism to prevent concurrent use of
23 * the PF2VF register by both the PF and VF.
24 *
25 * 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
26 * _______________________________________________
27 * | | | | | | | | | | | | | | | | |
28 * +-----------------------------------------------+
29 * \___________________________/ \_________/ ^ ^
30 * ^ ^ | |
31 * | | | VF2PF Int
32 * | | Message Origin
33 * | Message Type
34 * Message-specific Data/Reserved
35 *
36 * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
37 * _______________________________________________
38 * | | | | | | | | | | | | | | | | |
39 * +-----------------------------------------------+
40 * \___________________________/ \_________/ ^ ^
41 * ^ ^ | |
42 * | | | PF2VF Int
43 * | | Message Origin
44 * | Message Type
45 * Message-specific Data/Reserved
46 *
47 * Message Origin (Should always be 1)
48 * A legacy out-of-tree QAT driver allowed for a set of messages not supported
49 * by this driver; these had a Msg Origin of 0 and are ignored by this driver.
50 *
51 * When a PF or VF attempts to send a message in the lower or upper 16 bits,
52 * respectively, the other 16 bits are written to first with a defined
53 * IN_USE_BY pattern as part of a collision control scheme (see adf_iov_putmsg).
54 */
55
56 /* VF/PF compatibility version. */
57 /* ADF_PFVF_COMPATIBILITY_EXT_CAP: Support for extended capabilities */
58 #define ADF_PFVF_COMPATIBILITY_CAPABILITIES 2
59 /* ADF_PFVF_COMPATIBILITY_FAST_ACK: In-use pattern cleared by receiver */
60 #define ADF_PFVF_COMPATIBILITY_FAST_ACK 3
61 #define ADF_PFVF_COMPATIBILITY_RING_TO_SVC_MAP 4
62 #define ADF_PFVF_COMPATIBILITY_VERSION 4 /* PF<->VF compat */
63
64 /* PF->VF messages */
65 #define ADF_PF2VF_INT BIT(0)
66 #define ADF_PF2VF_MSGORIGIN_SYSTEM BIT(1)
67 #define ADF_PF2VF_MSGTYPE_MASK 0x0000003C
68 #define ADF_PF2VF_MSGTYPE_SHIFT 2
69 #define ADF_PF2VF_MSGTYPE_RESTARTING 0x01
70 #define ADF_PF2VF_MSGTYPE_VERSION_RESP 0x02
71 #define ADF_PF2VF_MSGTYPE_BLOCK_RESP 0x03
72 #define ADF_PF2VF_MSGTYPE_FATAL_ERROR 0x04
73 #define ADF_PF2VF_IN_USE_BY_PF 0x6AC20000
74 #define ADF_PF2VF_IN_USE_BY_PF_MASK 0xFFFE0000
75
76 /* PF->VF Version Response */
77 #define ADF_PF2VF_VERSION_RESP_VERS_MASK 0x00003FC0
78 #define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 6
79 #define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x0000C000
80 #define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 14
81 #define ADF_PF2VF_MINORVERSION_SHIFT 6
82 #define ADF_PF2VF_MAJORVERSION_SHIFT 10
83 #define ADF_PF2VF_VF_COMPATIBLE 1
84 #define ADF_PF2VF_VF_INCOMPATIBLE 2
85 #define ADF_PF2VF_VF_COMPAT_UNKNOWN 3
86
87 /* PF->VF Block Request Type */
88 #define ADF_VF2PF_MIN_SMALL_MESSAGE_TYPE 0
89 #define ADF_VF2PF_MAX_SMALL_MESSAGE_TYPE (ADF_VF2PF_MIN_SMALL_MESSAGE_TYPE + 15)
90 #define ADF_VF2PF_MIN_MEDIUM_MESSAGE_TYPE (ADF_VF2PF_MAX_SMALL_MESSAGE_TYPE + 1)
91 #define ADF_VF2PF_MAX_MEDIUM_MESSAGE_TYPE \
92 (ADF_VF2PF_MIN_MEDIUM_MESSAGE_TYPE + 7)
93 #define ADF_VF2PF_MIN_LARGE_MESSAGE_TYPE (ADF_VF2PF_MAX_MEDIUM_MESSAGE_TYPE + 1)
94 #define ADF_VF2PF_MAX_LARGE_MESSAGE_TYPE (ADF_VF2PF_MIN_LARGE_MESSAGE_TYPE + 3)
95 #define ADF_VF2PF_SMALL_PAYLOAD_SIZE 30
96 #define ADF_VF2PF_MEDIUM_PAYLOAD_SIZE 62
97 #define ADF_VF2PF_LARGE_PAYLOAD_SIZE 126
98
99 #define ADF_VF2PF_MAX_BLOCK_TYPE 3
100 #define ADF_VF2PF_BLOCK_REQ_TYPE_SHIFT 22
101 #define ADF_VF2PF_LARGE_BLOCK_BYTE_NUM_SHIFT 24
102 #define ADF_VF2PF_MEDIUM_BLOCK_BYTE_NUM_SHIFT 25
103 #define ADF_VF2PF_SMALL_BLOCK_BYTE_NUM_SHIFT 26
104 #define ADF_VF2PF_BLOCK_REQ_CRC_SHIFT 31
105 #define ADF_VF2PF_LARGE_BLOCK_BYTE_NUM_MASK 0x7F000000
106 #define ADF_VF2PF_MEDIUM_BLOCK_BYTE_NUM_MASK 0x7E000000
107 #define ADF_VF2PF_SMALL_BLOCK_BYTE_NUM_MASK 0x7C000000
108 #define ADF_VF2PF_LARGE_BLOCK_REQ_TYPE_MASK 0xC00000
109 #define ADF_VF2PF_MEDIUM_BLOCK_REQ_TYPE_MASK 0x1C00000
110 #define ADF_VF2PF_SMALL_BLOCK_REQ_TYPE_MASK 0x3C00000
111
112 /* PF->VF Block Response Type */
113 #define ADF_PF2VF_BLOCK_RESP_TYPE_DATA 0x0
114 #define ADF_PF2VF_BLOCK_RESP_TYPE_CRC 0x1
115 #define ADF_PF2VF_BLOCK_RESP_TYPE_ERROR 0x2
116 #define ADF_PF2VF_BLOCK_RESP_TYPE_SHIFT 6
117 #define ADF_PF2VF_BLOCK_RESP_DATA_SHIFT 8
118 #define ADF_PF2VF_BLOCK_RESP_TYPE_MASK 0x000000C0
119 #define ADF_PF2VF_BLOCK_RESP_DATA_MASK 0x0000FF00
120
121 /* PF-VF block message header bytes */
122 #define ADF_VF2PF_BLOCK_VERSION_BYTE 0
123 #define ADF_VF2PF_BLOCK_LEN_BYTE 1
124 #define ADF_VF2PF_BLOCK_DATA 2
125
126 /* PF->VF Block Error Code */
127 #define ADF_PF2VF_INVALID_BLOCK_TYPE 0x0
128 #define ADF_PF2VF_INVALID_BYTE_NUM_REQ 0x1
129 #define ADF_PF2VF_PAYLOAD_TRUNCATED 0x2
130 #define ADF_PF2VF_UNSPECIFIED_ERROR 0x3
131
132 /* VF->PF messages */
133 #define ADF_VF2PF_IN_USE_BY_VF 0x00006AC2
134 #define ADF_VF2PF_IN_USE_BY_VF_MASK 0x0000FFFE
135 #define ADF_VF2PF_INT BIT(16)
136 #define ADF_VF2PF_MSGORIGIN_SYSTEM BIT(17)
137 #define ADF_VF2PF_MSGTYPE_MASK 0x003C0000
138 #define ADF_VF2PF_MSGTYPE_SHIFT 18
139 #define ADF_VF2PF_MSGTYPE_INIT 0x3
140 #define ADF_VF2PF_MSGTYPE_SHUTDOWN 0x4
141 #define ADF_VF2PF_MSGTYPE_VERSION_REQ 0x5
142 #define ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ 0x6
143 #define ADF_VF2PF_MSGTYPE_GET_LARGE_BLOCK_REQ 0x7
144 #define ADF_VF2PF_MSGTYPE_GET_MEDIUM_BLOCK_REQ 0x8
145 #define ADF_VF2PF_MSGTYPE_GET_SMALL_BLOCK_REQ 0x9
146 #define ADF_VF2PF_MSGTYPE_NOTIFY 0xa
147 #define ADF_VF2PF_MSGGENC_RESTARTING_COMPLETE 0x0
148
149 /* Block message types
150 * 0..15 - 32 byte message
151 * 16..23 - 64 byte message
152 * 24..27 - 128 byte message
153 * 2 - Get Capability Request message
154 */
155 #define ADF_VF2PF_BLOCK_MSG_CAP_SUMMARY 2
156 #define ADF_VF2PF_BLOCK_MSG_GET_RING_TO_SVC_REQ 0x3
157
158 /* VF->PF Compatible Version Request */
159 #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22
160
161 /* How long to wait for far side to acknowledge receipt */
162 #define ADF_IOV_MSG_ACK_DELAY_US 5
163 #define ADF_IOV_MSG_ACK_EXP_MAX_DELAY_US (5 * 1000)
164 #define ADF_IOV_MSG_ACK_DELAY_MS 5
165 #define ADF_IOV_MSG_ACK_LIN_MAX_DELAY_US (2 * 1000 * 1000)
166 /* If CSR is busy, how long to delay before retrying */
167 #define ADF_IOV_MSG_RETRY_DELAY 5
168 #define ADF_IOV_MSG_MAX_RETRIES 10
169 /* How long to wait for a response from the other side */
170 #define ADF_IOV_MSG_RESP_TIMEOUT 100
171 /* How often to retry when there is no response */
172 #define ADF_IOV_MSG_RESP_RETRIES 5
173
174 #define ADF_IOV_RATELIMIT_INTERVAL 8
175 #define ADF_IOV_RATELIMIT_BURST 130
176
177 /* CRC Calculation */
178 #define ADF_CRC8_INIT_VALUE 0xFF
179 /* PF VF message byte shift */
180 #define ADF_PFVF_DATA_SHIFT 8
181 #define ADF_PFVF_DATA_MASK 0xFF
182 #endif /* ADF_IOV_MSG_H */
Cache object: df1707447c7413065b7087f93cd2cb01
|