1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015-2017  QLogic Corporation
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and /or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef __TCP_COMMON__
34 #define __TCP_COMMON__
35 
36 /********************/
37 /* TCP FW CONSTANTS */
38 /********************/
39 
40 #define TCP_INVALID_TIMEOUT_VAL	-1
41 
42 /* OOO opaque data received from LL2 */
43 struct ooo_opaque {
44 	__le32 cid;
45 	u8 drop_isle;
46 	u8 drop_size;
47 	u8 ooo_opcode;
48 	u8 ooo_isle;
49 };
50 
51 /* tcp connect mode enum */
52 enum tcp_connect_mode {
53 	TCP_CONNECT_ACTIVE,
54 	TCP_CONNECT_PASSIVE,
55 	MAX_TCP_CONNECT_MODE
56 };
57 
58 /* tcp function init parameters */
59 struct tcp_init_params {
60 	__le32 two_msl_timer;
61 	__le16 tx_sws_timer;
62 	u8 max_fin_rt;
63 	u8 reserved[9];
64 };
65 
66 /* tcp IPv4/IPv6 enum */
67 enum tcp_ip_version {
68 	TCP_IPV4,
69 	TCP_IPV6,
70 	MAX_TCP_IP_VERSION
71 };
72 
73 /* tcp offload parameters */
74 struct tcp_offload_params {
75 	__le16 local_mac_addr_lo;
76 	__le16 local_mac_addr_mid;
77 	__le16 local_mac_addr_hi;
78 	__le16 remote_mac_addr_lo;
79 	__le16 remote_mac_addr_mid;
80 	__le16 remote_mac_addr_hi;
81 	__le16 vlan_id;
82 	__le16 flags;
83 #define TCP_OFFLOAD_PARAMS_TS_EN_MASK			0x1
84 #define TCP_OFFLOAD_PARAMS_TS_EN_SHIFT			0
85 #define TCP_OFFLOAD_PARAMS_DA_EN_MASK			0x1
86 #define TCP_OFFLOAD_PARAMS_DA_EN_SHIFT			1
87 #define TCP_OFFLOAD_PARAMS_KA_EN_MASK			0x1
88 #define TCP_OFFLOAD_PARAMS_KA_EN_SHIFT			2
89 #define TCP_OFFLOAD_PARAMS_ECN_SENDER_EN_MASK		0x1
90 #define TCP_OFFLOAD_PARAMS_ECN_SENDER_EN_SHIFT		3
91 #define TCP_OFFLOAD_PARAMS_ECN_RECEIVER_EN_MASK		0x1
92 #define TCP_OFFLOAD_PARAMS_ECN_RECEIVER_EN_SHIFT	4
93 #define TCP_OFFLOAD_PARAMS_NAGLE_EN_MASK		0x1
94 #define TCP_OFFLOAD_PARAMS_NAGLE_EN_SHIFT		5
95 #define TCP_OFFLOAD_PARAMS_DA_CNT_EN_MASK		0x1
96 #define TCP_OFFLOAD_PARAMS_DA_CNT_EN_SHIFT		6
97 #define TCP_OFFLOAD_PARAMS_FIN_SENT_MASK		0x1
98 #define TCP_OFFLOAD_PARAMS_FIN_SENT_SHIFT		7
99 #define TCP_OFFLOAD_PARAMS_FIN_RECEIVED_MASK		0x1
100 #define TCP_OFFLOAD_PARAMS_FIN_RECEIVED_SHIFT		8
101 #define TCP_OFFLOAD_PARAMS_RESERVED_MASK		0x7F
102 #define TCP_OFFLOAD_PARAMS_RESERVED_SHIFT		9
103 	u8 ip_version;
104 	u8 reserved0[3];
105 	__le32 remote_ip[4];
106 	__le32 local_ip[4];
107 	__le32 flow_label;
108 	u8 ttl;
109 	u8 tos_or_tc;
110 	__le16 remote_port;
111 	__le16 local_port;
112 	__le16 mss;
113 	u8 rcv_wnd_scale;
114 	u8 connect_mode;
115 	__le16 srtt;
116 	__le32 ss_thresh;
117 	__le32 rcv_wnd;
118 	__le32 cwnd;
119 	u8 ka_max_probe_cnt;
120 	u8 dup_ack_theshold;
121 	__le16 reserved1;
122 	__le32 ka_timeout;
123 	__le32 ka_interval;
124 	__le32 max_rt_time;
125 	__le32 initial_rcv_wnd;
126 	__le32 rcv_next;
127 	__le32 snd_una;
128 	__le32 snd_next;
129 	__le32 snd_max;
130 	__le32 snd_wnd;
131 	__le32 snd_wl1;
132 	__le32 ts_recent;
133 	__le32 ts_recent_age;
134 	__le32 total_rt;
135 	__le32 ka_timeout_delta;
136 	__le32 rt_timeout_delta;
137 	u8 dup_ack_cnt;
138 	u8 snd_wnd_probe_cnt;
139 	u8 ka_probe_cnt;
140 	u8 rt_cnt;
141 	__le16 rtt_var;
142 	__le16 fw_internal;
143 	u8 snd_wnd_scale;
144 	u8 ack_frequency;
145 	__le16 da_timeout_value;
146 	__le32 reserved3;
147 };
148 
149 /* tcp offload parameters */
150 struct tcp_offload_params_opt2 {
151 	__le16 local_mac_addr_lo;
152 	__le16 local_mac_addr_mid;
153 	__le16 local_mac_addr_hi;
154 	__le16 remote_mac_addr_lo;
155 	__le16 remote_mac_addr_mid;
156 	__le16 remote_mac_addr_hi;
157 	__le16 vlan_id;
158 	__le16 flags;
159 #define TCP_OFFLOAD_PARAMS_OPT2_TS_EN_MASK	0x1
160 #define TCP_OFFLOAD_PARAMS_OPT2_TS_EN_SHIFT	0
161 #define TCP_OFFLOAD_PARAMS_OPT2_DA_EN_MASK	0x1
162 #define TCP_OFFLOAD_PARAMS_OPT2_DA_EN_SHIFT	1
163 #define TCP_OFFLOAD_PARAMS_OPT2_KA_EN_MASK	0x1
164 #define TCP_OFFLOAD_PARAMS_OPT2_KA_EN_SHIFT	2
165 #define TCP_OFFLOAD_PARAMS_OPT2_ECN_EN_MASK	0x1
166 #define TCP_OFFLOAD_PARAMS_OPT2_ECN_EN_SHIFT	3
167 #define TCP_OFFLOAD_PARAMS_OPT2_RESERVED0_MASK	0xFFF
168 #define TCP_OFFLOAD_PARAMS_OPT2_RESERVED0_SHIFT	4
169 	u8 ip_version;
170 	u8 reserved1[3];
171 	__le32 remote_ip[4];
172 	__le32 local_ip[4];
173 	__le32 flow_label;
174 	u8 ttl;
175 	u8 tos_or_tc;
176 	__le16 remote_port;
177 	__le16 local_port;
178 	__le16 mss;
179 	u8 rcv_wnd_scale;
180 	u8 connect_mode;
181 	__le16 syn_ip_payload_length;
182 	__le32 syn_phy_addr_lo;
183 	__le32 syn_phy_addr_hi;
184 	__le32 cwnd;
185 	u8 ka_max_probe_cnt;
186 	u8 reserved2[3];
187 	__le32 ka_timeout;
188 	__le32 ka_interval;
189 	__le32 max_rt_time;
190 	__le32 reserved3[16];
191 };
192 
193 /* tcp IPv4/IPv6 enum */
194 enum tcp_seg_placement_event {
195 	TCP_EVENT_ADD_PEN,
196 	TCP_EVENT_ADD_NEW_ISLE,
197 	TCP_EVENT_ADD_ISLE_RIGHT,
198 	TCP_EVENT_ADD_ISLE_LEFT,
199 	TCP_EVENT_JOIN,
200 	TCP_EVENT_DELETE_ISLES,
201 	TCP_EVENT_NOP,
202 	MAX_TCP_SEG_PLACEMENT_EVENT
203 };
204 
205 /* tcp init parameters */
206 struct tcp_update_params {
207 	__le16 flags;
208 #define TCP_UPDATE_PARAMS_REMOTE_MAC_ADDR_CHANGED_MASK		0x1
209 #define TCP_UPDATE_PARAMS_REMOTE_MAC_ADDR_CHANGED_SHIFT		0
210 #define TCP_UPDATE_PARAMS_MSS_CHANGED_MASK			0x1
211 #define TCP_UPDATE_PARAMS_MSS_CHANGED_SHIFT			1
212 #define TCP_UPDATE_PARAMS_TTL_CHANGED_MASK			0x1
213 #define TCP_UPDATE_PARAMS_TTL_CHANGED_SHIFT			2
214 #define TCP_UPDATE_PARAMS_TOS_OR_TC_CHANGED_MASK		0x1
215 #define TCP_UPDATE_PARAMS_TOS_OR_TC_CHANGED_SHIFT		3
216 #define TCP_UPDATE_PARAMS_KA_TIMEOUT_CHANGED_MASK		0x1
217 #define TCP_UPDATE_PARAMS_KA_TIMEOUT_CHANGED_SHIFT		4
218 #define TCP_UPDATE_PARAMS_KA_INTERVAL_CHANGED_MASK		0x1
219 #define TCP_UPDATE_PARAMS_KA_INTERVAL_CHANGED_SHIFT		5
220 #define TCP_UPDATE_PARAMS_MAX_RT_TIME_CHANGED_MASK		0x1
221 #define TCP_UPDATE_PARAMS_MAX_RT_TIME_CHANGED_SHIFT		6
222 #define TCP_UPDATE_PARAMS_FLOW_LABEL_CHANGED_MASK		0x1
223 #define TCP_UPDATE_PARAMS_FLOW_LABEL_CHANGED_SHIFT		7
224 #define TCP_UPDATE_PARAMS_INITIAL_RCV_WND_CHANGED_MASK		0x1
225 #define TCP_UPDATE_PARAMS_INITIAL_RCV_WND_CHANGED_SHIFT		8
226 #define TCP_UPDATE_PARAMS_KA_MAX_PROBE_CNT_CHANGED_MASK		0x1
227 #define TCP_UPDATE_PARAMS_KA_MAX_PROBE_CNT_CHANGED_SHIFT	9
228 #define TCP_UPDATE_PARAMS_KA_EN_CHANGED_MASK			0x1
229 #define TCP_UPDATE_PARAMS_KA_EN_CHANGED_SHIFT			10
230 #define TCP_UPDATE_PARAMS_NAGLE_EN_CHANGED_MASK			0x1
231 #define TCP_UPDATE_PARAMS_NAGLE_EN_CHANGED_SHIFT		11
232 #define TCP_UPDATE_PARAMS_KA_EN_MASK				0x1
233 #define TCP_UPDATE_PARAMS_KA_EN_SHIFT				12
234 #define TCP_UPDATE_PARAMS_NAGLE_EN_MASK				0x1
235 #define TCP_UPDATE_PARAMS_NAGLE_EN_SHIFT			13
236 #define TCP_UPDATE_PARAMS_KA_RESTART_MASK			0x1
237 #define TCP_UPDATE_PARAMS_KA_RESTART_SHIFT			14
238 #define TCP_UPDATE_PARAMS_RETRANSMIT_RESTART_MASK		0x1
239 #define TCP_UPDATE_PARAMS_RETRANSMIT_RESTART_SHIFT		15
240 	__le16 remote_mac_addr_lo;
241 	__le16 remote_mac_addr_mid;
242 	__le16 remote_mac_addr_hi;
243 	__le16 mss;
244 	u8 ttl;
245 	u8 tos_or_tc;
246 	__le32 ka_timeout;
247 	__le32 ka_interval;
248 	__le32 max_rt_time;
249 	__le32 flow_label;
250 	__le32 initial_rcv_wnd;
251 	u8 ka_max_probe_cnt;
252 	u8 reserved1[7];
253 };
254 
255 /* toe upload parameters */
256 struct tcp_upload_params {
257 	__le32 rcv_next;
258 	__le32 snd_una;
259 	__le32 snd_next;
260 	__le32 snd_max;
261 	__le32 snd_wnd;
262 	__le32 rcv_wnd;
263 	__le32 snd_wl1;
264 	__le32 cwnd;
265 	__le32 ss_thresh;
266 	__le16 srtt;
267 	__le16 rtt_var;
268 	__le32 ts_time;
269 	__le32 ts_recent;
270 	__le32 ts_recent_age;
271 	__le32 total_rt;
272 	__le32 ka_timeout_delta;
273 	__le32 rt_timeout_delta;
274 	u8 dup_ack_cnt;
275 	u8 snd_wnd_probe_cnt;
276 	u8 ka_probe_cnt;
277 	u8 rt_cnt;
278 	__le32 reserved;
279 };
280 
281 #endif /* __TCP_COMMON__ */
282