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