xref: /openbmc/linux/drivers/net/ethernet/ibm/ibmvnic.h (revision 5a244f48)
1 /**************************************************************************/
2 /*                                                                        */
3 /*  IBM System i and System p Virtual NIC Device Driver                   */
4 /*  Copyright (C) 2014 IBM Corp.                                          */
5 /*  Santiago Leon (santi_leon@yahoo.com)                                  */
6 /*  Thomas Falcon (tlfalcon@linux.vnet.ibm.com)                           */
7 /*  John Allen (jallen@linux.vnet.ibm.com)                                */
8 /*                                                                        */
9 /*  This program is free software; you can redistribute it and/or modify  */
10 /*  it under the terms of the GNU General Public License as published by  */
11 /*  the Free Software Foundation; either version 2 of the License, or     */
12 /*  (at your option) any later version.                                   */
13 /*                                                                        */
14 /*  This program is distributed in the hope that it will be useful,       */
15 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
16 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
17 /*  GNU General Public License for more details.                          */
18 /*                                                                        */
19 /*  You should have received a copy of the GNU General Public License     */
20 /*  along with this program.                                              */
21 /*                                                                        */
22 /* This module contains the implementation of a virtual ethernet device   */
23 /* for use with IBM i/pSeries LPAR Linux.  It utilizes the logical LAN    */
24 /* option of the RS/6000 Platform Architecture to interface with virtual */
25 /* ethernet NICs that are presented to the partition by the hypervisor.   */
26 /*                                                                        */
27 /**************************************************************************/
28 
29 #define IBMVNIC_NAME		"ibmvnic"
30 #define IBMVNIC_DRIVER_VERSION	"1.0.1"
31 #define IBMVNIC_INVALID_MAP	-1
32 #define IBMVNIC_STATS_TIMEOUT	1
33 /* basic structures plus 100 2k buffers */
34 #define IBMVNIC_IO_ENTITLEMENT_DEFAULT	610305
35 
36 /* Initial module_parameters */
37 #define IBMVNIC_RX_WEIGHT		16
38 /* when changing this, update IBMVNIC_IO_ENTITLEMENT_DEFAULT */
39 #define IBMVNIC_BUFFS_PER_POOL	100
40 #define IBMVNIC_MAX_TX_QUEUES	5
41 
42 struct ibmvnic_login_buffer {
43 	__be32 len;
44 	__be32 version;
45 #define INITIAL_VERSION_LB 1
46 	__be32 num_txcomp_subcrqs;
47 	__be32 off_txcomp_subcrqs;
48 	__be32 num_rxcomp_subcrqs;
49 	__be32 off_rxcomp_subcrqs;
50 	__be32 login_rsp_ioba;
51 	__be32 login_rsp_len;
52 } __packed __aligned(8);
53 
54 struct ibmvnic_login_rsp_buffer {
55 	__be32 len;
56 	__be32 version;
57 #define INITIAL_VERSION_LRB 1
58 	__be32 num_txsubm_subcrqs;
59 	__be32 off_txsubm_subcrqs;
60 	__be32 num_rxadd_subcrqs;
61 	__be32 off_rxadd_subcrqs;
62 	__be32 off_rxadd_buff_size;
63 	__be32 num_supp_tx_desc;
64 	__be32 off_supp_tx_desc;
65 } __packed __aligned(8);
66 
67 struct ibmvnic_query_ip_offload_buffer {
68 	__be32 len;
69 	__be32 version;
70 #define INITIAL_VERSION_IOB 1
71 	u8 ipv4_chksum;
72 	u8 ipv6_chksum;
73 	u8 tcp_ipv4_chksum;
74 	u8 tcp_ipv6_chksum;
75 	u8 udp_ipv4_chksum;
76 	u8 udp_ipv6_chksum;
77 	u8 large_tx_ipv4;
78 	u8 large_tx_ipv6;
79 	u8 large_rx_ipv4;
80 	u8 large_rx_ipv6;
81 	u8 reserved1[14];
82 	__be16 max_ipv4_header_size;
83 	__be16 max_ipv6_header_size;
84 	__be16 max_tcp_header_size;
85 	__be16 max_udp_header_size;
86 	__be32 max_large_tx_size;
87 	__be32 max_large_rx_size;
88 	u8 reserved2[16];
89 	u8 ipv6_extension_header;
90 #define IPV6_EH_NOT_SUPPORTED	0x00
91 #define IPV6_EH_SUPPORTED_LIM	0x01
92 #define IPV6_EH_SUPPORTED	0xFF
93 	u8 tcp_pseudosum_req;
94 #define TCP_PS_NOT_REQUIRED	0x00
95 #define TCP_PS_REQUIRED		0x01
96 	u8 reserved3[30];
97 	__be16 num_ipv6_ext_headers;
98 	__be32 off_ipv6_ext_headers;
99 	u8 reserved4[154];
100 } __packed __aligned(8);
101 
102 struct ibmvnic_control_ip_offload_buffer {
103 	__be32 len;
104 	__be32 version;
105 #define INITIAL_VERSION_IOB 1
106 	u8 ipv4_chksum;
107 	u8 ipv6_chksum;
108 	u8 tcp_ipv4_chksum;
109 	u8 tcp_ipv6_chksum;
110 	u8 udp_ipv4_chksum;
111 	u8 udp_ipv6_chksum;
112 	u8 large_tx_ipv4;
113 	u8 large_tx_ipv6;
114 	u8 bad_packet_rx;
115 	u8 large_rx_ipv4;
116 	u8 large_rx_ipv6;
117 	u8 reserved4[111];
118 } __packed __aligned(8);
119 
120 struct ibmvnic_fw_component {
121 	u8 name[48];
122 	__be32 trace_buff_size;
123 	u8 correlator;
124 	u8 trace_level;
125 	u8 parent_correlator;
126 	u8 error_check_level;
127 	u8 trace_on;
128 	u8 reserved[7];
129 	u8 description[192];
130 } __packed __aligned(8);
131 
132 struct ibmvnic_fw_trace_entry {
133 	__be32 trace_id;
134 	u8 num_valid_data;
135 	u8 reserved[3];
136 	__be64 pmc_registers;
137 	__be64 timebase;
138 	__be64 trace_data[5];
139 } __packed __aligned(8);
140 
141 struct ibmvnic_statistics {
142 	__be32 version;
143 	__be32 promiscuous;
144 	__be64 rx_packets;
145 	__be64 rx_bytes;
146 	__be64 tx_packets;
147 	__be64 tx_bytes;
148 	__be64 ucast_tx_packets;
149 	__be64 ucast_rx_packets;
150 	__be64 mcast_tx_packets;
151 	__be64 mcast_rx_packets;
152 	__be64 bcast_tx_packets;
153 	__be64 bcast_rx_packets;
154 	__be64 align_errors;
155 	__be64 fcs_errors;
156 	__be64 single_collision_frames;
157 	__be64 multi_collision_frames;
158 	__be64 sqe_test_errors;
159 	__be64 deferred_tx;
160 	__be64 late_collisions;
161 	__be64 excess_collisions;
162 	__be64 internal_mac_tx_errors;
163 	__be64 carrier_sense;
164 	__be64 too_long_frames;
165 	__be64 internal_mac_rx_errors;
166 	u8 reserved[72];
167 } __packed __aligned(8);
168 
169 #define NUM_TX_STATS 3
170 struct ibmvnic_tx_queue_stats {
171 	u64 packets;
172 	u64 bytes;
173 	u64 dropped_packets;
174 };
175 
176 #define NUM_RX_STATS 3
177 struct ibmvnic_rx_queue_stats {
178 	u64 packets;
179 	u64 bytes;
180 	u64 interrupts;
181 };
182 
183 struct ibmvnic_acl_buffer {
184 	__be32 len;
185 	__be32 version;
186 #define INITIAL_VERSION_IOB 1
187 	u8 mac_acls_restrict;
188 	u8 vlan_acls_restrict;
189 	u8 reserved1[22];
190 	__be32 num_mac_addrs;
191 	__be32 offset_mac_addrs;
192 	__be32 num_vlan_ids;
193 	__be32 offset_vlan_ids;
194 	u8 reserved2[80];
195 } __packed __aligned(8);
196 
197 /* descriptors have been changed, how should this be defined?  1? 4? */
198 
199 #define IBMVNIC_TX_DESC_VERSIONS 3
200 
201 /* is this still needed? */
202 struct ibmvnic_tx_comp_desc {
203 	u8 first;
204 	u8 num_comps;
205 	__be16 rcs[5];
206 	__be32 correlators[5];
207 } __packed __aligned(8);
208 
209 /* some flags that included in v0 descriptor, which is gone
210  * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
211  * and only in some offload_flags variable that doesn't seem
212  * to be used anywhere, can probably be removed?
213  */
214 
215 #define IBMVNIC_TCP_CHKSUM		0x20
216 #define IBMVNIC_UDP_CHKSUM		0x08
217 
218 #define IBMVNIC_MAX_FRAGS_PER_CRQ 3
219 
220 struct ibmvnic_tx_desc {
221 	u8 first;
222 	u8 type;
223 
224 #define IBMVNIC_TX_DESC 0x10
225 	u8 n_crq_elem;
226 	u8 n_sge;
227 	u8 flags1;
228 #define IBMVNIC_TX_COMP_NEEDED		0x80
229 #define IBMVNIC_TX_CHKSUM_OFFLOAD	0x40
230 #define IBMVNIC_TX_LSO			0x20
231 #define IBMVNIC_TX_PROT_TCP		0x10
232 #define IBMVNIC_TX_PROT_UDP		0x08
233 #define IBMVNIC_TX_PROT_IPV4		0x04
234 #define IBMVNIC_TX_PROT_IPV6		0x02
235 #define IBMVNIC_TX_VLAN_PRESENT		0x01
236 	u8 flags2;
237 #define IBMVNIC_TX_VLAN_INSERT		0x80
238 	__be16 mss;
239 	u8 reserved[4];
240 	__be32 correlator;
241 	__be16 vlan_id;
242 	__be16 dma_reg;
243 	__be32 sge_len;
244 	__be64 ioba;
245 } __packed __aligned(8);
246 
247 struct ibmvnic_hdr_desc {
248 	u8 first;
249 	u8 type;
250 #define IBMVNIC_HDR_DESC		0x11
251 	u8 len;
252 	u8 l2_len;
253 	__be16 l3_len;
254 	u8 l4_len;
255 	u8 flag;
256 	u8 data[24];
257 } __packed __aligned(8);
258 
259 struct ibmvnic_hdr_ext_desc {
260 	u8 first;
261 	u8 type;
262 #define IBMVNIC_HDR_EXT_DESC		0x12
263 	u8 len;
264 	u8 data[29];
265 } __packed __aligned(8);
266 
267 struct ibmvnic_sge_desc {
268 	u8 first;
269 	u8 type;
270 #define IBMVNIC_SGE_DESC		0x30
271 	__be16 sge1_dma_reg;
272 	__be32 sge1_len;
273 	__be64 sge1_ioba;
274 	__be16 reserved;
275 	__be16 sge2_dma_reg;
276 	__be32 sge2_len;
277 	__be64 sge2_ioba;
278 } __packed __aligned(8);
279 
280 struct ibmvnic_rx_comp_desc {
281 	u8 first;
282 	u8 flags;
283 #define IBMVNIC_IP_CHKSUM_GOOD		0x80
284 #define IBMVNIC_TCP_UDP_CHKSUM_GOOD	0x40
285 #define IBMVNIC_END_FRAME			0x20
286 #define IBMVNIC_EXACT_MC			0x10
287 #define IBMVNIC_VLAN_STRIPPED			0x08
288 	__be16 off_frame_data;
289 	__be32 len;
290 	__be64 correlator;
291 	__be16 vlan_tci;
292 	__be16 rc;
293 	u8 reserved[12];
294 } __packed __aligned(8);
295 
296 struct ibmvnic_generic_scrq {
297 	u8 first;
298 	u8 reserved[31];
299 } __packed __aligned(8);
300 
301 struct ibmvnic_rx_buff_add_desc {
302 	u8 first;
303 	u8 reserved[7];
304 	__be64 correlator;
305 	__be32 ioba;
306 	u8 map_id;
307 	__be32 len:24;
308 	u8 reserved2[8];
309 } __packed __aligned(8);
310 
311 struct ibmvnic_rc {
312 	u8 code; /* one of enum ibmvnic_rc_codes */
313 	u8 detailed_data[3];
314 } __packed __aligned(4);
315 
316 struct ibmvnic_generic_crq {
317 	u8 first;
318 	u8 cmd;
319 	u8 params[10];
320 	struct ibmvnic_rc rc;
321 } __packed __aligned(8);
322 
323 struct ibmvnic_version_exchange {
324 	u8 first;
325 	u8 cmd;
326 	__be16 version;
327 #define IBMVNIC_INITIAL_VERSION 1
328 	u8 reserved[8];
329 	struct ibmvnic_rc rc;
330 } __packed __aligned(8);
331 
332 struct ibmvnic_capability {
333 	u8 first;
334 	u8 cmd;
335 	__be16 capability; /* one of ibmvnic_capabilities */
336 	__be64 number;
337 	struct ibmvnic_rc rc;
338 } __packed __aligned(8);
339 
340 struct ibmvnic_login {
341 	u8 first;
342 	u8 cmd;
343 	u8 reserved[6];
344 	__be32 ioba;
345 	__be32 len;
346 } __packed __aligned(8);
347 
348 struct ibmvnic_phys_parms {
349 	u8 first;
350 	u8 cmd;
351 	u8 flags1;
352 #define IBMVNIC_EXTERNAL_LOOPBACK	0x80
353 #define IBMVNIC_INTERNAL_LOOPBACK	0x40
354 #define IBMVNIC_PROMISC		0x20
355 #define IBMVNIC_PHYS_LINK_ACTIVE	0x10
356 #define IBMVNIC_AUTONEG_DUPLEX	0x08
357 #define IBMVNIC_FULL_DUPLEX	0x04
358 #define IBMVNIC_HALF_DUPLEX	0x02
359 #define IBMVNIC_CAN_CHG_PHYS_PARMS	0x01
360 	u8 flags2;
361 #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
362 	__be32 speed;
363 #define IBMVNIC_AUTONEG		0x80
364 #define IBMVNIC_10MBPS		0x40
365 #define IBMVNIC_100MBPS		0x20
366 #define IBMVNIC_1GBPS		0x10
367 #define IBMVNIC_10GBPS		0x08
368 	__be32 mtu;
369 	struct ibmvnic_rc rc;
370 } __packed __aligned(8);
371 
372 struct ibmvnic_logical_link_state {
373 	u8 first;
374 	u8 cmd;
375 	u8 link_state;
376 #define IBMVNIC_LOGICAL_LNK_DN 0x00
377 #define IBMVNIC_LOGICAL_LNK_UP 0x01
378 #define IBMVNIC_LOGICAL_LNK_QUERY 0xff
379 	u8 reserved[9];
380 	struct ibmvnic_rc rc;
381 } __packed __aligned(8);
382 
383 struct ibmvnic_query_ip_offload {
384 	u8 first;
385 	u8 cmd;
386 	u8 reserved[2];
387 	__be32 len;
388 	__be32 ioba;
389 	struct ibmvnic_rc rc;
390 } __packed __aligned(8);
391 
392 struct ibmvnic_control_ip_offload {
393 	u8 first;
394 	u8 cmd;
395 	u8 reserved[2];
396 	__be32 ioba;
397 	__be32 len;
398 	struct ibmvnic_rc rc;
399 } __packed __aligned(8);
400 
401 struct ibmvnic_request_dump_size {
402 	u8 first;
403 	u8 cmd;
404 	u8 reserved[6];
405 	__be32 len;
406 	struct ibmvnic_rc rc;
407 } __packed __aligned(8);
408 
409 struct ibmvnic_request_dump {
410 	u8 first;
411 	u8 cmd;
412 	u8 reserved1[2];
413 	__be32 ioba;
414 	__be32 len;
415 	u8 reserved2[4];
416 } __packed __aligned(8);
417 
418 struct ibmvnic_request_dump_rsp {
419 	u8 first;
420 	u8 cmd;
421 	u8 reserved[6];
422 	__be32 dumped_len;
423 	struct ibmvnic_rc rc;
424 } __packed __aligned(8);
425 
426 struct ibmvnic_request_ras_comp_num {
427 	u8 first;
428 	u8 cmd;
429 	u8 reserved1[2];
430 	__be32 num_components;
431 	u8 reserved2[4];
432 	struct ibmvnic_rc rc;
433 } __packed __aligned(8);
434 
435 struct ibmvnic_request_ras_comps {
436 	u8 first;
437 	u8 cmd;
438 	u8 reserved[2];
439 	__be32 ioba;
440 	__be32 len;
441 	struct ibmvnic_rc rc;
442 } __packed __aligned(8);
443 
444 struct ibmvnic_control_ras {
445 	u8 first;
446 	u8 cmd;
447 	u8 correlator;
448 	u8 level;
449 	u8 op;
450 #define IBMVNIC_TRACE_LEVEL	1
451 #define IBMVNIC_ERROR_LEVEL	2
452 #define IBMVNIC_TRACE_PAUSE	3
453 #define IBMVNIC_TRACE_RESUME	4
454 #define IBMVNIC_TRACE_ON		5
455 #define IBMVNIC_TRACE_OFF		6
456 #define IBMVNIC_CHG_TRACE_BUFF_SZ	7
457 	u8 trace_buff_sz[3];
458 	u8 reserved[4];
459 	struct ibmvnic_rc rc;
460 } __packed __aligned(8);
461 
462 struct ibmvnic_collect_fw_trace {
463 	u8 first;
464 	u8 cmd;
465 	u8 correlator;
466 	u8 reserved;
467 	__be32 ioba;
468 	__be32 len;
469 	struct ibmvnic_rc rc;
470 } __packed __aligned(8);
471 
472 struct ibmvnic_request_statistics {
473 	u8 first;
474 	u8 cmd;
475 	u8 flags;
476 #define IBMVNIC_PHYSICAL_PORT	0x80
477 	u8 reserved1;
478 	__be32 ioba;
479 	__be32 len;
480 	u8 reserved[4];
481 } __packed __aligned(8);
482 
483 struct ibmvnic_request_debug_stats {
484 	u8 first;
485 	u8 cmd;
486 	u8 reserved[2];
487 	__be32 ioba;
488 	__be32 len;
489 	struct ibmvnic_rc rc;
490 } __packed __aligned(8);
491 
492 struct ibmvnic_error_indication {
493 	u8 first;
494 	u8 cmd;
495 	u8 flags;
496 #define IBMVNIC_FATAL_ERROR	0x80
497 	u8 reserved1;
498 	__be32 error_id;
499 	__be32 detail_error_sz;
500 	__be16 error_cause;
501 	u8 reserved2[2];
502 } __packed __aligned(8);
503 
504 struct ibmvnic_request_error_info {
505 	u8 first;
506 	u8 cmd;
507 	u8 reserved[2];
508 	__be32 ioba;
509 	__be32 len;
510 	__be32 error_id;
511 } __packed __aligned(8);
512 
513 struct ibmvnic_request_error_rsp {
514 	u8 first;
515 	u8 cmd;
516 	u8 reserved[2];
517 	__be32 error_id;
518 	__be32 len;
519 	struct ibmvnic_rc rc;
520 } __packed __aligned(8);
521 
522 struct ibmvnic_link_state_indication {
523 	u8 first;
524 	u8 cmd;
525 	u8 reserved1[2];
526 	u8 phys_link_state;
527 	u8 logical_link_state;
528 	u8 reserved2[10];
529 } __packed __aligned(8);
530 
531 struct ibmvnic_change_mac_addr {
532 	u8 first;
533 	u8 cmd;
534 	u8 mac_addr[6];
535 	u8 reserved[4];
536 	struct ibmvnic_rc rc;
537 } __packed __aligned(8);
538 
539 struct ibmvnic_multicast_ctrl {
540 	u8 first;
541 	u8 cmd;
542 	u8 mac_addr[6];
543 	u8 flags;
544 #define IBMVNIC_ENABLE_MC		0x80
545 #define IBMVNIC_DISABLE_MC		0x40
546 #define IBMVNIC_ENABLE_ALL		0x20
547 #define IBMVNIC_DISABLE_ALL	0x10
548 	u8 reserved1;
549 	__be16 reserved2; /* was num_enabled_mc_addr; */
550 	struct ibmvnic_rc rc;
551 } __packed __aligned(8);
552 
553 struct ibmvnic_get_vpd_size_rsp {
554 	u8 first;
555 	u8 cmd;
556 	u8 reserved[2];
557 	__be64 len;
558 	struct ibmvnic_rc rc;
559 } __packed __aligned(8);
560 
561 struct ibmvnic_get_vpd {
562 	u8 first;
563 	u8 cmd;
564 	u8 reserved1[2];
565 	__be32 ioba;
566 	__be32 len;
567 	u8 reserved[4];
568 } __packed __aligned(8);
569 
570 struct ibmvnic_acl_change_indication {
571 	u8 first;
572 	u8 cmd;
573 	__be16 change_type;
574 #define IBMVNIC_MAC_ACL 0
575 #define IBMVNIC_VLAN_ACL 1
576 	u8 reserved[12];
577 } __packed __aligned(8);
578 
579 struct ibmvnic_acl_query {
580 	u8 first;
581 	u8 cmd;
582 	u8 reserved1[2];
583 	__be32 ioba;
584 	__be32 len;
585 	u8 reserved2[4];
586 } __packed __aligned(8);
587 
588 struct ibmvnic_tune {
589 	u8 first;
590 	u8 cmd;
591 	u8 reserved1[2];
592 	__be32 ioba;
593 	__be32 len;
594 	u8 reserved2[4];
595 } __packed __aligned(8);
596 
597 struct ibmvnic_request_map {
598 	u8 first;
599 	u8 cmd;
600 	u8 reserved1;
601 	u8 map_id;
602 	__be32 ioba;
603 	__be32 len;
604 	u8 reserved2[4];
605 } __packed __aligned(8);
606 
607 struct ibmvnic_request_map_rsp {
608 	u8 first;
609 	u8 cmd;
610 	u8 reserved1;
611 	u8 map_id;
612 	u8 reserved2[8];
613 	struct ibmvnic_rc rc;
614 } __packed __aligned(8);
615 
616 struct ibmvnic_request_unmap {
617 	u8 first;
618 	u8 cmd;
619 	u8 reserved1;
620 	u8 map_id;
621 	u8 reserved2[12];
622 } __packed __aligned(8);
623 
624 struct ibmvnic_request_unmap_rsp {
625 	u8 first;
626 	u8 cmd;
627 	u8 reserved1;
628 	u8 map_id;
629 	u8 reserved2[8];
630 	struct ibmvnic_rc rc;
631 } __packed __aligned(8);
632 
633 struct ibmvnic_query_map {
634 	u8 first;
635 	u8 cmd;
636 	u8 reserved[14];
637 } __packed __aligned(8);
638 
639 struct ibmvnic_query_map_rsp {
640 	u8 first;
641 	u8 cmd;
642 	u8 reserved;
643 	u8 page_size;
644 	__be32 tot_pages;
645 	__be32 free_pages;
646 	struct ibmvnic_rc rc;
647 } __packed __aligned(8);
648 
649 union ibmvnic_crq {
650 	struct ibmvnic_generic_crq generic;
651 	struct ibmvnic_version_exchange version_exchange;
652 	struct ibmvnic_version_exchange version_exchange_rsp;
653 	struct ibmvnic_capability query_capability;
654 	struct ibmvnic_capability query_capability_rsp;
655 	struct ibmvnic_capability request_capability;
656 	struct ibmvnic_capability request_capability_rsp;
657 	struct ibmvnic_login login;
658 	struct ibmvnic_generic_crq login_rsp;
659 	struct ibmvnic_phys_parms query_phys_parms;
660 	struct ibmvnic_phys_parms query_phys_parms_rsp;
661 	struct ibmvnic_phys_parms query_phys_capabilities;
662 	struct ibmvnic_phys_parms query_phys_capabilities_rsp;
663 	struct ibmvnic_phys_parms set_phys_parms;
664 	struct ibmvnic_phys_parms set_phys_parms_rsp;
665 	struct ibmvnic_logical_link_state logical_link_state;
666 	struct ibmvnic_logical_link_state logical_link_state_rsp;
667 	struct ibmvnic_query_ip_offload query_ip_offload;
668 	struct ibmvnic_query_ip_offload query_ip_offload_rsp;
669 	struct ibmvnic_control_ip_offload control_ip_offload;
670 	struct ibmvnic_control_ip_offload control_ip_offload_rsp;
671 	struct ibmvnic_request_dump_size request_dump_size;
672 	struct ibmvnic_request_dump_size request_dump_size_rsp;
673 	struct ibmvnic_request_dump request_dump;
674 	struct ibmvnic_request_dump_rsp request_dump_rsp;
675 	struct ibmvnic_request_ras_comp_num request_ras_comp_num;
676 	struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
677 	struct ibmvnic_request_ras_comps request_ras_comps;
678 	struct ibmvnic_request_ras_comps request_ras_comps_rsp;
679 	struct ibmvnic_control_ras control_ras;
680 	struct ibmvnic_control_ras control_ras_rsp;
681 	struct ibmvnic_collect_fw_trace collect_fw_trace;
682 	struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
683 	struct ibmvnic_request_statistics request_statistics;
684 	struct ibmvnic_generic_crq request_statistics_rsp;
685 	struct ibmvnic_request_debug_stats request_debug_stats;
686 	struct ibmvnic_request_debug_stats request_debug_stats_rsp;
687 	struct ibmvnic_error_indication error_indication;
688 	struct ibmvnic_request_error_info request_error_info;
689 	struct ibmvnic_request_error_rsp request_error_rsp;
690 	struct ibmvnic_link_state_indication link_state_indication;
691 	struct ibmvnic_change_mac_addr change_mac_addr;
692 	struct ibmvnic_change_mac_addr change_mac_addr_rsp;
693 	struct ibmvnic_multicast_ctrl multicast_ctrl;
694 	struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
695 	struct ibmvnic_generic_crq get_vpd_size;
696 	struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
697 	struct ibmvnic_get_vpd get_vpd;
698 	struct ibmvnic_generic_crq get_vpd_rsp;
699 	struct ibmvnic_acl_change_indication acl_change_indication;
700 	struct ibmvnic_acl_query acl_query;
701 	struct ibmvnic_generic_crq acl_query_rsp;
702 	struct ibmvnic_tune tune;
703 	struct ibmvnic_generic_crq tune_rsp;
704 	struct ibmvnic_request_map request_map;
705 	struct ibmvnic_request_map_rsp request_map_rsp;
706 	struct ibmvnic_request_unmap request_unmap;
707 	struct ibmvnic_request_unmap_rsp request_unmap_rsp;
708 	struct ibmvnic_query_map query_map;
709 	struct ibmvnic_query_map_rsp query_map_rsp;
710 };
711 
712 enum ibmvnic_rc_codes {
713 	SUCCESS = 0,
714 	PARTIALSUCCESS = 1,
715 	PERMISSION = 2,
716 	NOMEMORY = 3,
717 	PARAMETER = 4,
718 	UNKNOWNCOMMAND = 5,
719 	ABORTED = 6,
720 	INVALIDSTATE = 7,
721 	INVALIDIOBA = 8,
722 	INVALIDLENGTH = 9,
723 	UNSUPPORTEDOPTION = 10,
724 };
725 
726 enum ibmvnic_capabilities {
727 	MIN_TX_QUEUES = 1,
728 	MIN_RX_QUEUES = 2,
729 	MIN_RX_ADD_QUEUES = 3,
730 	MAX_TX_QUEUES = 4,
731 	MAX_RX_QUEUES = 5,
732 	MAX_RX_ADD_QUEUES = 6,
733 	REQ_TX_QUEUES = 7,
734 	REQ_RX_QUEUES = 8,
735 	REQ_RX_ADD_QUEUES = 9,
736 	MIN_TX_ENTRIES_PER_SUBCRQ = 10,
737 	MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
738 	MAX_TX_ENTRIES_PER_SUBCRQ = 12,
739 	MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
740 	REQ_TX_ENTRIES_PER_SUBCRQ = 14,
741 	REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
742 	TCP_IP_OFFLOAD = 16,
743 	PROMISC_REQUESTED = 17,
744 	PROMISC_SUPPORTED = 18,
745 	MIN_MTU = 19,
746 	MAX_MTU = 20,
747 	REQ_MTU = 21,
748 	MAX_MULTICAST_FILTERS = 22,
749 	VLAN_HEADER_INSERTION = 23,
750 	RX_VLAN_HEADER_INSERTION = 24,
751 	MAX_TX_SG_ENTRIES = 25,
752 	RX_SG_SUPPORTED = 26,
753 	RX_SG_REQUESTED = 27,
754 	OPT_TX_COMP_SUB_QUEUES = 28,
755 	OPT_RX_COMP_QUEUES = 29,
756 	OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
757 	OPT_TX_ENTRIES_PER_SUBCRQ = 31,
758 	OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
759 	TX_RX_DESC_REQ = 33,
760 };
761 
762 enum ibmvnic_error_cause {
763 	ADAPTER_PROBLEM = 0,
764 	BUS_PROBLEM = 1,
765 	FW_PROBLEM = 2,
766 	DD_PROBLEM = 3,
767 	EEH_RECOVERY = 4,
768 	FW_UPDATED = 5,
769 	LOW_MEMORY = 6,
770 };
771 
772 enum ibmvnic_commands {
773 	VERSION_EXCHANGE = 0x01,
774 	VERSION_EXCHANGE_RSP = 0x81,
775 	QUERY_CAPABILITY = 0x02,
776 	QUERY_CAPABILITY_RSP = 0x82,
777 	REQUEST_CAPABILITY = 0x03,
778 	REQUEST_CAPABILITY_RSP = 0x83,
779 	LOGIN = 0x04,
780 	LOGIN_RSP = 0x84,
781 	QUERY_PHYS_PARMS = 0x05,
782 	QUERY_PHYS_PARMS_RSP = 0x85,
783 	QUERY_PHYS_CAPABILITIES = 0x06,
784 	QUERY_PHYS_CAPABILITIES_RSP = 0x86,
785 	SET_PHYS_PARMS = 0x07,
786 	SET_PHYS_PARMS_RSP = 0x87,
787 	ERROR_INDICATION = 0x08,
788 	REQUEST_ERROR_INFO = 0x09,
789 	REQUEST_ERROR_RSP = 0x89,
790 	LOGICAL_LINK_STATE = 0x0C,
791 	LOGICAL_LINK_STATE_RSP = 0x8C,
792 	REQUEST_STATISTICS = 0x0D,
793 	REQUEST_STATISTICS_RSP = 0x8D,
794 	COLLECT_FW_TRACE = 0x11,
795 	COLLECT_FW_TRACE_RSP = 0x91,
796 	LINK_STATE_INDICATION = 0x12,
797 	CHANGE_MAC_ADDR = 0x13,
798 	CHANGE_MAC_ADDR_RSP = 0x93,
799 	MULTICAST_CTRL = 0x14,
800 	MULTICAST_CTRL_RSP = 0x94,
801 	GET_VPD_SIZE = 0x15,
802 	GET_VPD_SIZE_RSP = 0x95,
803 	GET_VPD = 0x16,
804 	GET_VPD_RSP = 0x96,
805 	TUNE = 0x17,
806 	TUNE_RSP = 0x97,
807 	QUERY_IP_OFFLOAD = 0x18,
808 	QUERY_IP_OFFLOAD_RSP = 0x98,
809 	CONTROL_IP_OFFLOAD = 0x19,
810 	CONTROL_IP_OFFLOAD_RSP = 0x99,
811 	ACL_CHANGE_INDICATION = 0x1A,
812 	ACL_QUERY = 0x1B,
813 	ACL_QUERY_RSP = 0x9B,
814 	QUERY_MAP = 0x1D,
815 	QUERY_MAP_RSP = 0x9D,
816 	REQUEST_MAP = 0x1E,
817 	REQUEST_MAP_RSP = 0x9E,
818 	REQUEST_UNMAP = 0x1F,
819 	REQUEST_UNMAP_RSP = 0x9F,
820 	VLAN_CTRL = 0x20,
821 	VLAN_CTRL_RSP = 0xA0,
822 };
823 
824 enum ibmvnic_crq_type {
825 	IBMVNIC_CRQ_CMD			= 0x80,
826 	IBMVNIC_CRQ_CMD_RSP		= 0x80,
827 	IBMVNIC_CRQ_INIT_CMD		= 0xC0,
828 	IBMVNIC_CRQ_INIT_RSP		= 0xC0,
829 	IBMVNIC_CRQ_XPORT_EVENT		= 0xFF,
830 };
831 
832 enum ibmvfc_crq_format {
833 	IBMVNIC_CRQ_INIT                 = 0x01,
834 	IBMVNIC_CRQ_INIT_COMPLETE        = 0x02,
835 	IBMVNIC_PARTITION_MIGRATED       = 0x06,
836 	IBMVNIC_DEVICE_FAILOVER          = 0x08,
837 };
838 
839 struct ibmvnic_crq_queue {
840 	union ibmvnic_crq *msgs;
841 	int size, cur;
842 	dma_addr_t msg_token;
843 	spinlock_t lock;
844 };
845 
846 union sub_crq {
847 	struct ibmvnic_generic_scrq generic;
848 	struct ibmvnic_tx_comp_desc tx_comp;
849 	struct ibmvnic_tx_desc v1;
850 	struct ibmvnic_hdr_desc hdr;
851 	struct ibmvnic_hdr_ext_desc hdr_ext;
852 	struct ibmvnic_sge_desc sge;
853 	struct ibmvnic_rx_comp_desc rx_comp;
854 	struct ibmvnic_rx_buff_add_desc rx_add;
855 };
856 
857 struct ibmvnic_sub_crq_queue {
858 	union sub_crq *msgs;
859 	int size, cur;
860 	dma_addr_t msg_token;
861 	unsigned long crq_num;
862 	unsigned long hw_irq;
863 	unsigned int irq;
864 	unsigned int pool_index;
865 	int scrq_num;
866 	spinlock_t lock;
867 	struct sk_buff *rx_skb_top;
868 	struct ibmvnic_adapter *adapter;
869 	atomic_t used;
870 };
871 
872 struct ibmvnic_long_term_buff {
873 	unsigned char *buff;
874 	dma_addr_t addr;
875 	u64 size;
876 	u8 map_id;
877 };
878 
879 struct ibmvnic_tx_buff {
880 	struct sk_buff *skb;
881 	dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
882 	unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
883 	int index;
884 	int pool_index;
885 	bool last_frag;
886 	union sub_crq indir_arr[6];
887 	u8 hdr_data[140];
888 	dma_addr_t indir_dma;
889 };
890 
891 struct ibmvnic_tx_pool {
892 	struct ibmvnic_tx_buff *tx_buff;
893 	int *free_map;
894 	int consumer_index;
895 	int producer_index;
896 	wait_queue_head_t ibmvnic_tx_comp_q;
897 	struct task_struct *work_thread;
898 	struct ibmvnic_long_term_buff long_term_buff;
899 };
900 
901 struct ibmvnic_rx_buff {
902 	struct sk_buff *skb;
903 	dma_addr_t dma;
904 	unsigned char *data;
905 	int size;
906 	int pool_index;
907 };
908 
909 struct ibmvnic_rx_pool {
910 	struct ibmvnic_rx_buff *rx_buff;
911 	int size;
912 	int index;
913 	int buff_size;
914 	atomic_t available;
915 	int *free_map;
916 	int next_free;
917 	int next_alloc;
918 	int active;
919 	struct ibmvnic_long_term_buff long_term_buff;
920 };
921 
922 struct ibmvnic_error_buff {
923 	char *buff;
924 	dma_addr_t dma;
925 	int len;
926 	struct list_head list;
927 	__be32 error_id;
928 };
929 
930 enum vnic_state {VNIC_PROBING = 1,
931 		 VNIC_PROBED,
932 		 VNIC_OPENING,
933 		 VNIC_OPEN,
934 		 VNIC_CLOSING,
935 		 VNIC_CLOSED,
936 		 VNIC_REMOVING,
937 		 VNIC_REMOVED};
938 
939 enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
940 			   VNIC_RESET_MOBILITY,
941 			   VNIC_RESET_FATAL,
942 			   VNIC_RESET_NON_FATAL,
943 			   VNIC_RESET_TIMEOUT};
944 
945 struct ibmvnic_rwi {
946 	enum ibmvnic_reset_reason reset_reason;
947 	struct list_head list;
948 };
949 
950 struct ibmvnic_adapter {
951 	struct vio_dev *vdev;
952 	struct net_device *netdev;
953 	struct ibmvnic_crq_queue crq;
954 	u8 mac_addr[ETH_ALEN];
955 	struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
956 	dma_addr_t ip_offload_tok;
957 	struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
958 	dma_addr_t ip_offload_ctrl_tok;
959 	u32 msg_enable;
960 
961 	/* Statistics */
962 	struct ibmvnic_statistics stats;
963 	dma_addr_t stats_token;
964 	struct completion stats_done;
965 	spinlock_t stats_lock;
966 	int replenish_no_mem;
967 	int replenish_add_buff_success;
968 	int replenish_add_buff_failure;
969 	int replenish_task_cycles;
970 	int tx_send_failed;
971 	int tx_map_failed;
972 
973 	struct ibmvnic_tx_queue_stats *tx_stats_buffers;
974 	struct ibmvnic_rx_queue_stats *rx_stats_buffers;
975 
976 	int phys_link_state;
977 	int logical_link_state;
978 
979 	/* login data */
980 	struct ibmvnic_login_buffer *login_buf;
981 	dma_addr_t login_buf_token;
982 	int login_buf_sz;
983 
984 	struct ibmvnic_login_rsp_buffer *login_rsp_buf;
985 	dma_addr_t login_rsp_buf_token;
986 	int login_rsp_buf_sz;
987 
988 	atomic_t running_cap_crqs;
989 	bool wait_capability;
990 
991 	struct ibmvnic_sub_crq_queue **tx_scrq;
992 	struct ibmvnic_sub_crq_queue **rx_scrq;
993 	bool renegotiate;
994 
995 	/* rx structs */
996 	struct napi_struct *napi;
997 	struct ibmvnic_rx_pool *rx_pool;
998 	u64 promisc;
999 
1000 	struct ibmvnic_tx_pool *tx_pool;
1001 	struct completion init_done;
1002 	int init_done_rc;
1003 
1004 	struct list_head errors;
1005 	spinlock_t error_list_lock;
1006 
1007 	struct completion fw_done;
1008 	int fw_done_rc;
1009 
1010 	/* partner capabilities */
1011 	u64 min_tx_queues;
1012 	u64 min_rx_queues;
1013 	u64 min_rx_add_queues;
1014 	u64 max_tx_queues;
1015 	u64 max_rx_queues;
1016 	u64 max_rx_add_queues;
1017 	u64 req_tx_queues;
1018 	u64 req_rx_queues;
1019 	u64 req_rx_add_queues;
1020 	u64 min_tx_entries_per_subcrq;
1021 	u64 min_rx_add_entries_per_subcrq;
1022 	u64 max_tx_entries_per_subcrq;
1023 	u64 max_rx_add_entries_per_subcrq;
1024 	u64 req_tx_entries_per_subcrq;
1025 	u64 req_rx_add_entries_per_subcrq;
1026 	u64 tcp_ip_offload;
1027 	u64 promisc_requested;
1028 	u64 promisc_supported;
1029 	u64 min_mtu;
1030 	u64 max_mtu;
1031 	u64 req_mtu;
1032 	u64 max_multicast_filters;
1033 	u64 vlan_header_insertion;
1034 	u64 rx_vlan_header_insertion;
1035 	u64 max_tx_sg_entries;
1036 	u64 rx_sg_supported;
1037 	u64 rx_sg_requested;
1038 	u64 opt_tx_comp_sub_queues;
1039 	u64 opt_rx_comp_queues;
1040 	u64 opt_rx_bufadd_q_per_rx_comp_q;
1041 	u64 opt_tx_entries_per_subcrq;
1042 	u64 opt_rxba_entries_per_subcrq;
1043 	__be64 tx_rx_desc_req;
1044 	u8 map_id;
1045 
1046 	struct tasklet_struct tasklet;
1047 	enum vnic_state state;
1048 	enum ibmvnic_reset_reason reset_reason;
1049 	struct mutex reset_lock, rwi_lock;
1050 	struct list_head rwi_list;
1051 	struct work_struct ibmvnic_reset;
1052 	bool resetting;
1053 	bool napi_enabled, from_passive_init;
1054 };
1055