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