ibmvnic: Report actual backing device speed and duplex values
[linux-2.6-block.git] / drivers / net / ethernet / ibm / ibmvnic.h
CommitLineData
032c5e82
TF
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"
9fa2f2cc 30#define IBMVNIC_DRIVER_VERSION "1.0.1"
032c5e82
TF
31#define IBMVNIC_INVALID_MAP -1
32#define IBMVNIC_STATS_TIMEOUT 1
2a1bf511
JA
33#define IBMVNIC_INIT_FAILED 2
34
032c5e82
TF
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
ad95a240 42#define IBMVNIC_MAX_QUEUES 16
20b5ba1f 43#define IBMVNIC_MAX_QUEUE_SZ 4096
032c5e82 44
fdb06105
TF
45#define IBMVNIC_TSO_BUF_SZ 65536
46#define IBMVNIC_TSO_BUFS 64
06b3e357 47#define IBMVNIC_TSO_POOL_MASK 0x80000000
fdb06105 48
c26eba03
JA
49#define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
50#define IBMVNIC_BUFFER_HLEN 500
51
723ad916
TF
52static const char ibmvnic_priv_flags[][ETH_GSTRING_LEN] = {
53#define IBMVNIC_USE_SERVER_MAXES 0x1
54 "use-server-maxes"
55};
56
032c5e82
TF
57struct 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;
37798d02
NF
67 __be32 client_data_offset;
68 __be32 client_data_len;
032c5e82
TF
69} __packed __aligned(8);
70
71struct 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
84struct 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
119struct 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
137struct 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
149struct 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
158struct 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
3d52b594
JA
186#define NUM_TX_STATS 3
187struct ibmvnic_tx_queue_stats {
188 u64 packets;
189 u64 bytes;
190 u64 dropped_packets;
191};
192
193#define NUM_RX_STATS 3
194struct ibmvnic_rx_queue_stats {
195 u64 packets;
196 u64 bytes;
197 u64 interrupts;
198};
199
032c5e82
TF
200struct 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? */
219struct 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
237struct 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
264struct 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
276struct 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
284struct 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
297struct 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
313struct ibmvnic_generic_scrq {
314 u8 first;
315 u8 reserved[31];
316} __packed __aligned(8);
317
318struct 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
328struct ibmvnic_rc {
329 u8 code; /* one of enum ibmvnic_rc_codes */
330 u8 detailed_data[3];
331} __packed __aligned(4);
332
333struct ibmvnic_generic_crq {
334 u8 first;
335 u8 cmd;
336 u8 params[10];
337 struct ibmvnic_rc rc;
338} __packed __aligned(8);
339
340struct 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
349struct ibmvnic_capability {
350 u8 first;
351 u8 cmd;
352 __be16 capability; /* one of ibmvnic_capabilities */
de89e854 353 __be64 number;
032c5e82 354 struct ibmvnic_rc rc;
032c5e82
TF
355} __packed __aligned(8);
356
357struct ibmvnic_login {
358 u8 first;
359 u8 cmd;
360 u8 reserved[6];
361 __be32 ioba;
362 __be32 len;
363} __packed __aligned(8);
364
365struct 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;
f8d6ae0d
MFV
380#define IBMVNIC_AUTONEG 0x80000000
381#define IBMVNIC_10MBPS 0x40000000
382#define IBMVNIC_100MBPS 0x20000000
383#define IBMVNIC_1GBPS 0x10000000
384#define IBMVNIC_10GBP 0x08000000
385#define IBMVNIC_40GBPS 0x04000000
386#define IBMVNIC_100GBPS 0x02000000
387#define IBMVNIC_25GBPS 0x01000000
388#define IBMVNIC_50GBPS 0x00800000
389#define IBMVNIC_200GBPS 0x00400000
032c5e82
TF
390 __be32 mtu;
391 struct ibmvnic_rc rc;
392} __packed __aligned(8);
393
394struct ibmvnic_logical_link_state {
395 u8 first;
396 u8 cmd;
397 u8 link_state;
398#define IBMVNIC_LOGICAL_LNK_DN 0x00
399#define IBMVNIC_LOGICAL_LNK_UP 0x01
400#define IBMVNIC_LOGICAL_LNK_QUERY 0xff
401 u8 reserved[9];
402 struct ibmvnic_rc rc;
403} __packed __aligned(8);
404
405struct ibmvnic_query_ip_offload {
406 u8 first;
407 u8 cmd;
408 u8 reserved[2];
409 __be32 len;
410 __be32 ioba;
411 struct ibmvnic_rc rc;
412} __packed __aligned(8);
413
414struct ibmvnic_control_ip_offload {
415 u8 first;
416 u8 cmd;
417 u8 reserved[2];
418 __be32 ioba;
419 __be32 len;
420 struct ibmvnic_rc rc;
421} __packed __aligned(8);
422
423struct ibmvnic_request_dump_size {
424 u8 first;
425 u8 cmd;
426 u8 reserved[6];
427 __be32 len;
428 struct ibmvnic_rc rc;
429} __packed __aligned(8);
430
431struct ibmvnic_request_dump {
432 u8 first;
433 u8 cmd;
434 u8 reserved1[2];
435 __be32 ioba;
436 __be32 len;
437 u8 reserved2[4];
438} __packed __aligned(8);
439
440struct ibmvnic_request_dump_rsp {
441 u8 first;
442 u8 cmd;
443 u8 reserved[6];
444 __be32 dumped_len;
445 struct ibmvnic_rc rc;
446} __packed __aligned(8);
447
448struct ibmvnic_request_ras_comp_num {
449 u8 first;
450 u8 cmd;
451 u8 reserved1[2];
452 __be32 num_components;
453 u8 reserved2[4];
454 struct ibmvnic_rc rc;
455} __packed __aligned(8);
456
457struct ibmvnic_request_ras_comps {
458 u8 first;
459 u8 cmd;
460 u8 reserved[2];
461 __be32 ioba;
462 __be32 len;
463 struct ibmvnic_rc rc;
464} __packed __aligned(8);
465
466struct ibmvnic_control_ras {
467 u8 first;
468 u8 cmd;
469 u8 correlator;
470 u8 level;
471 u8 op;
472#define IBMVNIC_TRACE_LEVEL 1
473#define IBMVNIC_ERROR_LEVEL 2
474#define IBMVNIC_TRACE_PAUSE 3
475#define IBMVNIC_TRACE_RESUME 4
476#define IBMVNIC_TRACE_ON 5
477#define IBMVNIC_TRACE_OFF 6
478#define IBMVNIC_CHG_TRACE_BUFF_SZ 7
479 u8 trace_buff_sz[3];
480 u8 reserved[4];
481 struct ibmvnic_rc rc;
482} __packed __aligned(8);
483
484struct ibmvnic_collect_fw_trace {
485 u8 first;
486 u8 cmd;
487 u8 correlator;
488 u8 reserved;
489 __be32 ioba;
490 __be32 len;
491 struct ibmvnic_rc rc;
492} __packed __aligned(8);
493
494struct ibmvnic_request_statistics {
495 u8 first;
496 u8 cmd;
497 u8 flags;
498#define IBMVNIC_PHYSICAL_PORT 0x80
499 u8 reserved1;
500 __be32 ioba;
501 __be32 len;
502 u8 reserved[4];
503} __packed __aligned(8);
504
505struct ibmvnic_request_debug_stats {
506 u8 first;
507 u8 cmd;
508 u8 reserved[2];
509 __be32 ioba;
510 __be32 len;
511 struct ibmvnic_rc rc;
512} __packed __aligned(8);
513
514struct ibmvnic_error_indication {
515 u8 first;
516 u8 cmd;
517 u8 flags;
518#define IBMVNIC_FATAL_ERROR 0x80
519 u8 reserved1;
520 __be32 error_id;
521 __be32 detail_error_sz;
522 __be16 error_cause;
523 u8 reserved2[2];
524} __packed __aligned(8);
525
032c5e82
TF
526struct ibmvnic_link_state_indication {
527 u8 first;
528 u8 cmd;
529 u8 reserved1[2];
530 u8 phys_link_state;
531 u8 logical_link_state;
532 u8 reserved2[10];
533} __packed __aligned(8);
534
535struct ibmvnic_change_mac_addr {
536 u8 first;
537 u8 cmd;
538 u8 mac_addr[6];
032c5e82 539 u8 reserved[4];
993a82b0 540 struct ibmvnic_rc rc;
032c5e82
TF
541} __packed __aligned(8);
542
543struct ibmvnic_multicast_ctrl {
544 u8 first;
545 u8 cmd;
546 u8 mac_addr[6];
547 u8 flags;
548#define IBMVNIC_ENABLE_MC 0x80
549#define IBMVNIC_DISABLE_MC 0x40
550#define IBMVNIC_ENABLE_ALL 0x20
551#define IBMVNIC_DISABLE_ALL 0x10
552 u8 reserved1;
553 __be16 reserved2; /* was num_enabled_mc_addr; */
554 struct ibmvnic_rc rc;
555} __packed __aligned(8);
556
4e6759be
DANR
557struct ibmvnic_get_vpd_size {
558 u8 first;
559 u8 cmd;
560 u8 reserved[14];
561} __packed __aligned(8);
562
032c5e82
TF
563struct ibmvnic_get_vpd_size_rsp {
564 u8 first;
565 u8 cmd;
566 u8 reserved[2];
567 __be64 len;
568 struct ibmvnic_rc rc;
569} __packed __aligned(8);
570
571struct ibmvnic_get_vpd {
572 u8 first;
573 u8 cmd;
574 u8 reserved1[2];
575 __be32 ioba;
576 __be32 len;
577 u8 reserved[4];
578} __packed __aligned(8);
579
4e6759be
DANR
580struct ibmvnic_get_vpd_rsp {
581 u8 first;
582 u8 cmd;
583 u8 reserved[10];
584 struct ibmvnic_rc rc;
585} __packed __aligned(8);
586
032c5e82
TF
587struct ibmvnic_acl_change_indication {
588 u8 first;
589 u8 cmd;
590 __be16 change_type;
591#define IBMVNIC_MAC_ACL 0
592#define IBMVNIC_VLAN_ACL 1
593 u8 reserved[12];
594} __packed __aligned(8);
595
596struct ibmvnic_acl_query {
597 u8 first;
598 u8 cmd;
599 u8 reserved1[2];
600 __be32 ioba;
601 __be32 len;
602 u8 reserved2[4];
603} __packed __aligned(8);
604
605struct ibmvnic_tune {
606 u8 first;
607 u8 cmd;
608 u8 reserved1[2];
609 __be32 ioba;
610 __be32 len;
611 u8 reserved2[4];
612} __packed __aligned(8);
613
614struct ibmvnic_request_map {
615 u8 first;
616 u8 cmd;
617 u8 reserved1;
618 u8 map_id;
619 __be32 ioba;
620 __be32 len;
621 u8 reserved2[4];
622} __packed __aligned(8);
623
624struct ibmvnic_request_map_rsp {
625 u8 first;
626 u8 cmd;
627 u8 reserved1;
628 u8 map_id;
288ccb75 629 u8 reserved2[8];
032c5e82
TF
630 struct ibmvnic_rc rc;
631} __packed __aligned(8);
632
633struct ibmvnic_request_unmap {
634 u8 first;
635 u8 cmd;
636 u8 reserved1;
637 u8 map_id;
638 u8 reserved2[12];
639} __packed __aligned(8);
640
641struct ibmvnic_request_unmap_rsp {
642 u8 first;
643 u8 cmd;
644 u8 reserved1;
645 u8 map_id;
646 u8 reserved2[8];
647 struct ibmvnic_rc rc;
648} __packed __aligned(8);
649
650struct ibmvnic_query_map {
651 u8 first;
652 u8 cmd;
653 u8 reserved[14];
654} __packed __aligned(8);
655
656struct ibmvnic_query_map_rsp {
657 u8 first;
658 u8 cmd;
659 u8 reserved;
660 u8 page_size;
661 __be32 tot_pages;
662 __be32 free_pages;
663 struct ibmvnic_rc rc;
664} __packed __aligned(8);
665
666union ibmvnic_crq {
667 struct ibmvnic_generic_crq generic;
668 struct ibmvnic_version_exchange version_exchange;
669 struct ibmvnic_version_exchange version_exchange_rsp;
670 struct ibmvnic_capability query_capability;
671 struct ibmvnic_capability query_capability_rsp;
672 struct ibmvnic_capability request_capability;
673 struct ibmvnic_capability request_capability_rsp;
674 struct ibmvnic_login login;
675 struct ibmvnic_generic_crq login_rsp;
676 struct ibmvnic_phys_parms query_phys_parms;
677 struct ibmvnic_phys_parms query_phys_parms_rsp;
678 struct ibmvnic_phys_parms query_phys_capabilities;
679 struct ibmvnic_phys_parms query_phys_capabilities_rsp;
680 struct ibmvnic_phys_parms set_phys_parms;
681 struct ibmvnic_phys_parms set_phys_parms_rsp;
682 struct ibmvnic_logical_link_state logical_link_state;
683 struct ibmvnic_logical_link_state logical_link_state_rsp;
684 struct ibmvnic_query_ip_offload query_ip_offload;
685 struct ibmvnic_query_ip_offload query_ip_offload_rsp;
686 struct ibmvnic_control_ip_offload control_ip_offload;
687 struct ibmvnic_control_ip_offload control_ip_offload_rsp;
688 struct ibmvnic_request_dump_size request_dump_size;
689 struct ibmvnic_request_dump_size request_dump_size_rsp;
690 struct ibmvnic_request_dump request_dump;
691 struct ibmvnic_request_dump_rsp request_dump_rsp;
692 struct ibmvnic_request_ras_comp_num request_ras_comp_num;
693 struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
694 struct ibmvnic_request_ras_comps request_ras_comps;
695 struct ibmvnic_request_ras_comps request_ras_comps_rsp;
696 struct ibmvnic_control_ras control_ras;
697 struct ibmvnic_control_ras control_ras_rsp;
698 struct ibmvnic_collect_fw_trace collect_fw_trace;
699 struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
700 struct ibmvnic_request_statistics request_statistics;
701 struct ibmvnic_generic_crq request_statistics_rsp;
702 struct ibmvnic_request_debug_stats request_debug_stats;
703 struct ibmvnic_request_debug_stats request_debug_stats_rsp;
704 struct ibmvnic_error_indication error_indication;
032c5e82
TF
705 struct ibmvnic_link_state_indication link_state_indication;
706 struct ibmvnic_change_mac_addr change_mac_addr;
707 struct ibmvnic_change_mac_addr change_mac_addr_rsp;
708 struct ibmvnic_multicast_ctrl multicast_ctrl;
709 struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
4e6759be 710 struct ibmvnic_get_vpd_size get_vpd_size;
032c5e82
TF
711 struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
712 struct ibmvnic_get_vpd get_vpd;
4e6759be 713 struct ibmvnic_get_vpd_rsp get_vpd_rsp;
032c5e82
TF
714 struct ibmvnic_acl_change_indication acl_change_indication;
715 struct ibmvnic_acl_query acl_query;
716 struct ibmvnic_generic_crq acl_query_rsp;
717 struct ibmvnic_tune tune;
718 struct ibmvnic_generic_crq tune_rsp;
719 struct ibmvnic_request_map request_map;
720 struct ibmvnic_request_map_rsp request_map_rsp;
721 struct ibmvnic_request_unmap request_unmap;
722 struct ibmvnic_request_unmap_rsp request_unmap_rsp;
723 struct ibmvnic_query_map query_map;
724 struct ibmvnic_query_map_rsp query_map_rsp;
725};
726
727enum ibmvnic_rc_codes {
728 SUCCESS = 0,
729 PARTIALSUCCESS = 1,
730 PERMISSION = 2,
731 NOMEMORY = 3,
732 PARAMETER = 4,
733 UNKNOWNCOMMAND = 5,
734 ABORTED = 6,
735 INVALIDSTATE = 7,
736 INVALIDIOBA = 8,
737 INVALIDLENGTH = 9,
738 UNSUPPORTEDOPTION = 10,
739};
740
741enum ibmvnic_capabilities {
742 MIN_TX_QUEUES = 1,
743 MIN_RX_QUEUES = 2,
744 MIN_RX_ADD_QUEUES = 3,
745 MAX_TX_QUEUES = 4,
746 MAX_RX_QUEUES = 5,
747 MAX_RX_ADD_QUEUES = 6,
748 REQ_TX_QUEUES = 7,
749 REQ_RX_QUEUES = 8,
750 REQ_RX_ADD_QUEUES = 9,
751 MIN_TX_ENTRIES_PER_SUBCRQ = 10,
752 MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
753 MAX_TX_ENTRIES_PER_SUBCRQ = 12,
754 MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
755 REQ_TX_ENTRIES_PER_SUBCRQ = 14,
756 REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
757 TCP_IP_OFFLOAD = 16,
758 PROMISC_REQUESTED = 17,
759 PROMISC_SUPPORTED = 18,
760 MIN_MTU = 19,
761 MAX_MTU = 20,
762 REQ_MTU = 21,
763 MAX_MULTICAST_FILTERS = 22,
764 VLAN_HEADER_INSERTION = 23,
6052d5e2 765 RX_VLAN_HEADER_INSERTION = 24,
032c5e82
TF
766 MAX_TX_SG_ENTRIES = 25,
767 RX_SG_SUPPORTED = 26,
768 RX_SG_REQUESTED = 27,
769 OPT_TX_COMP_SUB_QUEUES = 28,
770 OPT_RX_COMP_QUEUES = 29,
771 OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
772 OPT_TX_ENTRIES_PER_SUBCRQ = 31,
773 OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
774 TX_RX_DESC_REQ = 33,
775};
776
777enum ibmvnic_error_cause {
778 ADAPTER_PROBLEM = 0,
779 BUS_PROBLEM = 1,
780 FW_PROBLEM = 2,
781 DD_PROBLEM = 3,
782 EEH_RECOVERY = 4,
783 FW_UPDATED = 5,
784 LOW_MEMORY = 6,
785};
786
787enum ibmvnic_commands {
788 VERSION_EXCHANGE = 0x01,
789 VERSION_EXCHANGE_RSP = 0x81,
790 QUERY_CAPABILITY = 0x02,
791 QUERY_CAPABILITY_RSP = 0x82,
792 REQUEST_CAPABILITY = 0x03,
793 REQUEST_CAPABILITY_RSP = 0x83,
794 LOGIN = 0x04,
795 LOGIN_RSP = 0x84,
796 QUERY_PHYS_PARMS = 0x05,
797 QUERY_PHYS_PARMS_RSP = 0x85,
798 QUERY_PHYS_CAPABILITIES = 0x06,
799 QUERY_PHYS_CAPABILITIES_RSP = 0x86,
800 SET_PHYS_PARMS = 0x07,
801 SET_PHYS_PARMS_RSP = 0x87,
802 ERROR_INDICATION = 0x08,
032c5e82
TF
803 LOGICAL_LINK_STATE = 0x0C,
804 LOGICAL_LINK_STATE_RSP = 0x8C,
805 REQUEST_STATISTICS = 0x0D,
806 REQUEST_STATISTICS_RSP = 0x8D,
032c5e82
TF
807 COLLECT_FW_TRACE = 0x11,
808 COLLECT_FW_TRACE_RSP = 0x91,
809 LINK_STATE_INDICATION = 0x12,
810 CHANGE_MAC_ADDR = 0x13,
811 CHANGE_MAC_ADDR_RSP = 0x93,
812 MULTICAST_CTRL = 0x14,
813 MULTICAST_CTRL_RSP = 0x94,
814 GET_VPD_SIZE = 0x15,
815 GET_VPD_SIZE_RSP = 0x95,
816 GET_VPD = 0x16,
817 GET_VPD_RSP = 0x96,
818 TUNE = 0x17,
819 TUNE_RSP = 0x97,
820 QUERY_IP_OFFLOAD = 0x18,
821 QUERY_IP_OFFLOAD_RSP = 0x98,
822 CONTROL_IP_OFFLOAD = 0x19,
823 CONTROL_IP_OFFLOAD_RSP = 0x99,
824 ACL_CHANGE_INDICATION = 0x1A,
825 ACL_QUERY = 0x1B,
826 ACL_QUERY_RSP = 0x9B,
032c5e82
TF
827 QUERY_MAP = 0x1D,
828 QUERY_MAP_RSP = 0x9D,
829 REQUEST_MAP = 0x1E,
830 REQUEST_MAP_RSP = 0x9E,
831 REQUEST_UNMAP = 0x1F,
832 REQUEST_UNMAP_RSP = 0x9F,
833 VLAN_CTRL = 0x20,
834 VLAN_CTRL_RSP = 0xA0,
835};
836
837enum ibmvnic_crq_type {
838 IBMVNIC_CRQ_CMD = 0x80,
839 IBMVNIC_CRQ_CMD_RSP = 0x80,
840 IBMVNIC_CRQ_INIT_CMD = 0xC0,
841 IBMVNIC_CRQ_INIT_RSP = 0xC0,
842 IBMVNIC_CRQ_XPORT_EVENT = 0xFF,
843};
844
845enum ibmvfc_crq_format {
846 IBMVNIC_CRQ_INIT = 0x01,
847 IBMVNIC_CRQ_INIT_COMPLETE = 0x02,
848 IBMVNIC_PARTITION_MIGRATED = 0x06,
dfad09a6 849 IBMVNIC_DEVICE_FAILOVER = 0x08,
032c5e82
TF
850};
851
852struct ibmvnic_crq_queue {
853 union ibmvnic_crq *msgs;
854 int size, cur;
855 dma_addr_t msg_token;
856 spinlock_t lock;
5153698e 857 bool active;
032c5e82
TF
858};
859
860union sub_crq {
861 struct ibmvnic_generic_scrq generic;
862 struct ibmvnic_tx_comp_desc tx_comp;
863 struct ibmvnic_tx_desc v1;
864 struct ibmvnic_hdr_desc hdr;
865 struct ibmvnic_hdr_ext_desc hdr_ext;
866 struct ibmvnic_sge_desc sge;
867 struct ibmvnic_rx_comp_desc rx_comp;
868 struct ibmvnic_rx_buff_add_desc rx_add;
869};
870
871struct ibmvnic_sub_crq_queue {
872 union sub_crq *msgs;
873 int size, cur;
874 dma_addr_t msg_token;
875 unsigned long crq_num;
876 unsigned long hw_irq;
877 unsigned int irq;
878 unsigned int pool_index;
879 int scrq_num;
880 spinlock_t lock;
881 struct sk_buff *rx_skb_top;
882 struct ibmvnic_adapter *adapter;
142c0ac4 883 atomic_t used;
032c5e82
TF
884};
885
886struct ibmvnic_long_term_buff {
887 unsigned char *buff;
888 dma_addr_t addr;
889 u64 size;
890 u8 map_id;
891};
892
893struct ibmvnic_tx_buff {
894 struct sk_buff *skb;
895 dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
896 unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
897 int index;
898 int pool_index;
899 bool last_frag;
ad7775dc
TF
900 union sub_crq indir_arr[6];
901 u8 hdr_data[140];
902 dma_addr_t indir_dma;
ffc385b9 903 int num_entries;
032c5e82
TF
904};
905
906struct ibmvnic_tx_pool {
907 struct ibmvnic_tx_buff *tx_buff;
908 int *free_map;
909 int consumer_index;
910 int producer_index;
032c5e82 911 struct ibmvnic_long_term_buff long_term_buff;
4bd95a51
TF
912 int num_buffers;
913 int buf_size;
032c5e82
TF
914};
915
916struct ibmvnic_rx_buff {
917 struct sk_buff *skb;
918 dma_addr_t dma;
919 unsigned char *data;
920 int size;
921 int pool_index;
922};
923
924struct ibmvnic_rx_pool {
925 struct ibmvnic_rx_buff *rx_buff;
926 int size;
927 int index;
928 int buff_size;
929 atomic_t available;
930 int *free_map;
931 int next_free;
932 int next_alloc;
933 int active;
934 struct ibmvnic_long_term_buff long_term_buff;
935};
936
4e6759be
DANR
937struct ibmvnic_vpd {
938 unsigned char *buff;
939 dma_addr_t dma_addr;
940 u64 len;
941};
942
90c8014c
NF
943enum vnic_state {VNIC_PROBING = 1,
944 VNIC_PROBED,
945 VNIC_OPENING,
946 VNIC_OPEN,
947 VNIC_CLOSING,
948 VNIC_CLOSED,
949 VNIC_REMOVING,
950 VNIC_REMOVED};
951
ed651a10
NF
952enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
953 VNIC_RESET_MOBILITY,
954 VNIC_RESET_FATAL,
8cb31cfc 955 VNIC_RESET_NON_FATAL,
c26eba03
JA
956 VNIC_RESET_TIMEOUT,
957 VNIC_RESET_CHANGE_PARAM};
ed651a10
NF
958
959struct ibmvnic_rwi {
960 enum ibmvnic_reset_reason reset_reason;
961 struct list_head list;
962};
963
c26eba03
JA
964struct ibmvnic_tunables {
965 u64 rx_queues;
966 u64 tx_queues;
967 u64 rx_entries;
968 u64 tx_entries;
969 u64 mtu;
970 struct sockaddr mac;
971};
972
032c5e82
TF
973struct ibmvnic_adapter {
974 struct vio_dev *vdev;
975 struct net_device *netdev;
976 struct ibmvnic_crq_queue crq;
977 u8 mac_addr[ETH_ALEN];
978 struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
979 dma_addr_t ip_offload_tok;
980 struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
981 dma_addr_t ip_offload_ctrl_tok;
032c5e82 982 u32 msg_enable;
723ad916 983 u32 priv_flags;
032c5e82 984
4e6759be
DANR
985 /* Vital Product Data (VPD) */
986 struct ibmvnic_vpd *vpd;
987 char fw_version[32];
988
032c5e82 989 /* Statistics */
032c5e82
TF
990 struct ibmvnic_statistics stats;
991 dma_addr_t stats_token;
992 struct completion stats_done;
993 spinlock_t stats_lock;
994 int replenish_no_mem;
995 int replenish_add_buff_success;
996 int replenish_add_buff_failure;
997 int replenish_task_cycles;
998 int tx_send_failed;
999 int tx_map_failed;
1000
3d52b594
JA
1001 struct ibmvnic_tx_queue_stats *tx_stats_buffers;
1002 struct ibmvnic_rx_queue_stats *rx_stats_buffers;
1003
032c5e82
TF
1004 int phys_link_state;
1005 int logical_link_state;
1006
f8d6ae0d
MFV
1007 u32 speed;
1008 u8 duplex;
1009
032c5e82
TF
1010 /* login data */
1011 struct ibmvnic_login_buffer *login_buf;
1012 dma_addr_t login_buf_token;
1013 int login_buf_sz;
1014
1015 struct ibmvnic_login_rsp_buffer *login_rsp_buf;
1016 dma_addr_t login_rsp_buf_token;
1017 int login_rsp_buf_sz;
1018
901e040a 1019 atomic_t running_cap_crqs;
249168ad 1020 bool wait_capability;
032c5e82
TF
1021
1022 struct ibmvnic_sub_crq_queue **tx_scrq;
1023 struct ibmvnic_sub_crq_queue **rx_scrq;
032c5e82
TF
1024
1025 /* rx structs */
1026 struct napi_struct *napi;
1027 struct ibmvnic_rx_pool *rx_pool;
1028 u64 promisc;
1029
1030 struct ibmvnic_tx_pool *tx_pool;
4bd95a51 1031 struct ibmvnic_tx_pool *tso_pool;
032c5e82 1032 struct completion init_done;
53da09e9 1033 int init_done_rc;
032c5e82 1034
032c5e82 1035 struct completion fw_done;
f3be0cbc 1036 int fw_done_rc;
032c5e82 1037
c26eba03
JA
1038 struct completion reset_done;
1039 int reset_done_rc;
1040 bool wait_for_reset;
1041
032c5e82
TF
1042 /* partner capabilities */
1043 u64 min_tx_queues;
1044 u64 min_rx_queues;
1045 u64 min_rx_add_queues;
1046 u64 max_tx_queues;
1047 u64 max_rx_queues;
1048 u64 max_rx_add_queues;
1049 u64 req_tx_queues;
1050 u64 req_rx_queues;
1051 u64 req_rx_add_queues;
1052 u64 min_tx_entries_per_subcrq;
1053 u64 min_rx_add_entries_per_subcrq;
1054 u64 max_tx_entries_per_subcrq;
1055 u64 max_rx_add_entries_per_subcrq;
1056 u64 req_tx_entries_per_subcrq;
1057 u64 req_rx_add_entries_per_subcrq;
1058 u64 tcp_ip_offload;
1059 u64 promisc_requested;
1060 u64 promisc_supported;
1061 u64 min_mtu;
1062 u64 max_mtu;
1063 u64 req_mtu;
1064 u64 max_multicast_filters;
1065 u64 vlan_header_insertion;
6052d5e2 1066 u64 rx_vlan_header_insertion;
032c5e82
TF
1067 u64 max_tx_sg_entries;
1068 u64 rx_sg_supported;
1069 u64 rx_sg_requested;
1070 u64 opt_tx_comp_sub_queues;
1071 u64 opt_rx_comp_queues;
1072 u64 opt_rx_bufadd_q_per_rx_comp_q;
1073 u64 opt_tx_entries_per_subcrq;
1074 u64 opt_rxba_entries_per_subcrq;
1075 __be64 tx_rx_desc_req;
1076 u8 map_id;
82e3be32
NF
1077 u32 num_active_rx_scrqs;
1078 u32 num_active_rx_pools;
1079 u32 num_active_rx_napi;
1080 u32 num_active_tx_scrqs;
1081 u32 num_active_tx_pools;
65dc6891 1082
6c267b3d 1083 struct tasklet_struct tasklet;
90c8014c 1084 enum vnic_state state;
ed651a10 1085 enum ibmvnic_reset_reason reset_reason;
6c5c7489 1086 spinlock_t rwi_lock;
ed651a10
NF
1087 struct list_head rwi_list;
1088 struct work_struct ibmvnic_reset;
1089 bool resetting;
017892c1 1090 bool napi_enabled, from_passive_init;
c26eba03
JA
1091
1092 bool mac_change_pending;
5a18e1e0 1093 bool failover_pending;
2770a798 1094 bool force_reset_recovery;
c26eba03
JA
1095
1096 struct ibmvnic_tunables desired;
1097 struct ibmvnic_tunables fallback;
032c5e82 1098};