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