xref: /dpdk/drivers/common/qat/qat_adf/adf_pf2vf_msg.h (revision b17d16fb47b49919725436b731405ab32a0c02f2)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  * Copyright(c) 2021 Intel Corporation
3  */
4 #ifndef ADF_PF2VF_MSG_H_
5 #define ADF_PF2VF_MSG_H_
6 
7 /* VF/PF compatibility version. */
8 /* ADF_PFVF_COMPATIBILITY_EXT_CAP: Support for extended capabilities */
9 #define ADF_PFVF_COMPATIBILITY_CAPABILITIES	2
10 /* ADF_PFVF_COMPATIBILITY_FAST_ACK: In-use pattern cleared by receiver */
11 #define ADF_PFVF_COMPATIBILITY_FAST_ACK		3
12 #define ADF_PFVF_COMPATIBILITY_RING_TO_SVC_MAP	4
13 #define ADF_PFVF_COMPATIBILITY_VERSION		4	/* PF<->VF compat */
14 
15 #define ADF_PFVF_INT				    1
16 #define ADF_PFVF_MSGORIGIN_SYSTEM		2
17 #define ADF_PFVF_1X_MSGTYPE_SHIFT		2
18 #define ADF_PFVF_1X_MSGTYPE_MASK		0xF
19 #define ADF_PFVF_1X_MSGDATA_SHIFT		6
20 #define ADF_PFVF_1X_MSGDATA_MASK		0x3FF
21 #define ADF_PFVF_2X_MSGTYPE_SHIFT		2
22 #define ADF_PFVF_2X_MSGTYPE_MASK		0x3F
23 #define ADF_PFVF_2X_MSGDATA_SHIFT		8
24 #define ADF_PFVF_2X_MSGDATA_MASK		0xFFFFFF
25 
26 #define ADF_PFVF_IN_USE				0x6AC2
27 #define ADF_PFVF_IN_USE_MASK			0xFFFE
28 #define ADF_PFVF_VF_MSG_SHIFT			16
29 
30 /* PF->VF messages */
31 #define ADF_PF2VF_MSGTYPE_RESTARTING		0x01
32 #define ADF_PF2VF_MSGTYPE_VERSION_RESP		0x02
33 #define ADF_PF2VF_MSGTYPE_BLOCK_RESP		0x03
34 #define ADF_PF2VF_MSGTYPE_FATAL_ERROR		0x04
35 /* Do not use messages which start from 0x10 to 1.x as 1.x only use
36  * 4 bits as message types. Hence they are only applicable to 2.0
37  */
38 #define ADF_PF2VF_MSGTYPE_RP_RESET_RESP		0x10
39 
40 /* PF->VF Version Response - ADF_PF2VF_MSGTYPE_VERSION_RESP */
41 #define ADF_PF2VF_VERSION_RESP_VERS_MASK	0xFF
42 #define ADF_PF2VF_VERSION_RESP_VERS_SHIFT	0
43 #define ADF_PF2VF_VERSION_RESP_RESULT_MASK	0x03
44 #define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT	8
45 #define ADF_PF2VF_MINORVERSION_SHIFT		0
46 #define ADF_PF2VF_MAJORVERSION_SHIFT		4
47 #define ADF_PF2VF_VF_COMPATIBLE			1
48 #define ADF_PF2VF_VF_INCOMPATIBLE		2
49 #define ADF_PF2VF_VF_COMPAT_UNKNOWN		3
50 
51 /* PF->VF Block Response Type - ADF_PF2VF_MSGTYPE_BLOCK_RESP */
52 #define ADF_PF2VF_BLOCK_RESP_TYPE_DATA		0x0
53 #define ADF_PF2VF_BLOCK_RESP_TYPE_CRC		0x1
54 #define ADF_PF2VF_BLOCK_RESP_TYPE_ERROR		0x2
55 #define ADF_PF2VF_BLOCK_RESP_TYPE_MASK		0x03
56 #define ADF_PF2VF_BLOCK_RESP_TYPE_SHIFT		0
57 #define ADF_PF2VF_BLOCK_RESP_DATA_MASK		0xFF
58 #define ADF_PF2VF_BLOCK_RESP_DATA_SHIFT		2
59 
60 /*
61  * PF->VF Block Error Code - Returned in data field when the
62  * response type indicates an error
63  */
64 #define ADF_PF2VF_INVALID_BLOCK_TYPE		0x0
65 #define ADF_PF2VF_INVALID_BYTE_NUM_REQ		0x1
66 #define ADF_PF2VF_PAYLOAD_TRUNCATED		0x2
67 #define ADF_PF2VF_UNSPECIFIED_ERROR		0x3
68 
69 /* VF->PF messages */
70 #define ADF_VF2PF_MSGTYPE_INIT			0x3
71 #define ADF_VF2PF_MSGTYPE_SHUTDOWN		0x4
72 #define ADF_VF2PF_MSGTYPE_VERSION_REQ		0x5
73 #define ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ	0x6
74 #define ADF_VF2PF_MSGTYPE_GET_LARGE_BLOCK_REQ	0x7
75 #define ADF_VF2PF_MSGTYPE_GET_MEDIUM_BLOCK_REQ	0x8
76 #define ADF_VF2PF_MSGTYPE_GET_SMALL_BLOCK_REQ	0x9
77 /* Do not use messages which start from 0x10 to 1.x as 1.x only use
78  * 4 bits as message types. Hence they are only applicable to 2.0
79  */
80 #define ADF_VF2PF_MSGTYPE_RP_RESET		0x10
81 
82 /* VF->PF Block Request Type - ADF_VF2PF_MSGTYPE_GET_xxx_BLOCK_REQ  */
83 #define ADF_VF2PF_MIN_SMALL_MESSAGE_TYPE	0
84 #define ADF_VF2PF_MAX_SMALL_MESSAGE_TYPE \
85 		(ADF_VF2PF_MIN_SMALL_MESSAGE_TYPE + 15)
86 #define ADF_VF2PF_MIN_MEDIUM_MESSAGE_TYPE \
87 		(ADF_VF2PF_MAX_SMALL_MESSAGE_TYPE + 1)
88 #define ADF_VF2PF_MAX_MEDIUM_MESSAGE_TYPE \
89 		(ADF_VF2PF_MIN_MEDIUM_MESSAGE_TYPE + 7)
90 #define ADF_VF2PF_MIN_LARGE_MESSAGE_TYPE \
91 		(ADF_VF2PF_MAX_MEDIUM_MESSAGE_TYPE + 1)
92 #define ADF_VF2PF_MAX_LARGE_MESSAGE_TYPE \
93 		(ADF_VF2PF_MIN_LARGE_MESSAGE_TYPE + 3)
94 #define ADF_VF2PF_SMALL_PAYLOAD_SIZE		30
95 #define ADF_VF2PF_MEDIUM_PAYLOAD_SIZE		62
96 #define ADF_VF2PF_LARGE_PAYLOAD_SIZE		126
97 
98 #define ADF_VF2PF_BLOCK_REQ_TYPE_SHIFT		0
99 #define ADF_VF2PF_LARGE_BLOCK_REQ_TYPE_MASK	0x3
100 #define ADF_VF2PF_MEDIUM_BLOCK_REQ_TYPE_MASK	0x7
101 #define ADF_VF2PF_SMALL_BLOCK_REQ_TYPE_MASK	0xF
102 
103 #define ADF_VF2PF_LARGE_BLOCK_BYTE_NUM_SHIFT	2
104 #define ADF_VF2PF_LARGE_BLOCK_BYTE_NUM_MASK	0x7F
105 #define ADF_VF2PF_MEDIUM_BLOCK_BYTE_NUM_SHIFT	3
106 #define ADF_VF2PF_MEDIUM_BLOCK_BYTE_NUM_MASK	0x3F
107 #define ADF_VF2PF_SMALL_BLOCK_BYTE_NUM_SHIFT	4
108 #define ADF_VF2PF_SMALL_BLOCK_BYTE_NUM_MASK	0x1F
109 #define ADF_VF2PF_BLOCK_REQ_CRC_SHIFT		9
110 
111 /* PF-VF block message header bytes */
112 #define ADF_VF2PF_BLOCK_VERSION_BYTE		0
113 #define ADF_VF2PF_BLOCK_LEN_BYTE                1
114 #define ADF_VF2PF_BLOCK_DATA	                2
115 
116 /* Block message types
117  *  0..15 - 32 byte message
118  * 16..23 - 64 byte message
119  * 24..27 - 128 byte message
120  * 2 - Get Capability Request message
121  */
122 #define ADF_VF2PF_BLOCK_MSG_CAP_SUMMARY         0x2
123 #define ADF_VF2PF_BLOCK_MSG_GET_RING_TO_SVC_REQ 0x3
124 
125 /* VF->PF Compatible Version Request - ADF_VF2PF_MSGTYPE_VERSION_REQ */
126 #define ADF_VF2PF_COMPAT_VER_SHIFT		0
127 #define ADF_VF2PF_COMPAT_VER_MASK		0xFF
128 
129 /* How long to wait for far side to acknowledge receipt */
130 #define ADF_IOV_MSG_ACK_DELAY_US		5
131 #define ADF_IOV_MSG_ACK_MAX_RETRY	(100 * 1000 / ADF_IOV_MSG_ACK_DELAY_US)
132 /* If CSR is busy, how long to delay before retrying */
133 #define ADF_IOV_MSG_RETRY_DELAY			5
134 #define ADF_IOV_MSG_MAX_RETRIES			3
135 /* How long to wait for a response from the other side */
136 #define ADF_IOV_MSG_RESP_TIMEOUT		100
137 /* How often to retry when there is no response */
138 #define ADF_IOV_MSG_RESP_RETRIES		5
139 
140 #define ADF_IOV_RATELIMIT_INTERVAL		8
141 #define ADF_IOV_RATELIMIT_BURST			130
142 /* PF VF message byte shift */
143 #define ADF_PFVF_DATA_SHIFT                     8
144 #define ADF_PFVF_DATA_MASK                      0xFF
145 
146 /* CRC Calculation */
147 #define ADF_CRC8_INIT_VALUE 0xFF
148 
149 /* Per device register offsets */
150 /* GEN 4 */
151 #define ADF_4XXXIOV_PF2VM_OFFSET	0x1008
152 #define ADF_4XXXIOV_VM2PF_OFFSET	0x100C
153 
154 #endif /* ADF_IOV_MSG_H */
155