blob: 4670af80d61271938a5bcb7b9f88d33cc729f877 [file] [log] [blame]
Thomas Falcon032c5e82015-12-21 11:26:06 -06001/**************************************************************************/
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"
Thomas Falcon9fa2f2c2016-10-17 15:56:29 -050030#define IBMVNIC_DRIVER_VERSION "1.0.1"
Thomas Falcon032c5e82015-12-21 11:26:06 -060031#define IBMVNIC_INVALID_MAP -1
32#define IBMVNIC_STATS_TIMEOUT 1
John Allen2a1bf512017-10-26 16:24:15 -050033#define IBMVNIC_INIT_FAILED 2
34
Thomas Falcon032c5e82015-12-21 11:26:06 -060035/* 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_TX_QUEUES 5
43
Thomas Falconfdb06102017-10-17 12:36:55 -050044#define IBMVNIC_TSO_BUF_SZ 65536
45#define IBMVNIC_TSO_BUFS 64
46
John Allenc26eba02017-10-26 16:23:25 -050047#define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
48#define IBMVNIC_BUFFER_HLEN 500
49
Thomas Falcon032c5e82015-12-21 11:26:06 -060050struct 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} __packed __aligned(8);
61
62struct ibmvnic_login_rsp_buffer {
63 __be32 len;
64 __be32 version;
65#define INITIAL_VERSION_LRB 1
66 __be32 num_txsubm_subcrqs;
67 __be32 off_txsubm_subcrqs;
68 __be32 num_rxadd_subcrqs;
69 __be32 off_rxadd_subcrqs;
70 __be32 off_rxadd_buff_size;
71 __be32 num_supp_tx_desc;
72 __be32 off_supp_tx_desc;
73} __packed __aligned(8);
74
75struct ibmvnic_query_ip_offload_buffer {
76 __be32 len;
77 __be32 version;
78#define INITIAL_VERSION_IOB 1
79 u8 ipv4_chksum;
80 u8 ipv6_chksum;
81 u8 tcp_ipv4_chksum;
82 u8 tcp_ipv6_chksum;
83 u8 udp_ipv4_chksum;
84 u8 udp_ipv6_chksum;
85 u8 large_tx_ipv4;
86 u8 large_tx_ipv6;
87 u8 large_rx_ipv4;
88 u8 large_rx_ipv6;
89 u8 reserved1[14];
90 __be16 max_ipv4_header_size;
91 __be16 max_ipv6_header_size;
92 __be16 max_tcp_header_size;
93 __be16 max_udp_header_size;
94 __be32 max_large_tx_size;
95 __be32 max_large_rx_size;
96 u8 reserved2[16];
97 u8 ipv6_extension_header;
98#define IPV6_EH_NOT_SUPPORTED 0x00
99#define IPV6_EH_SUPPORTED_LIM 0x01
100#define IPV6_EH_SUPPORTED 0xFF
101 u8 tcp_pseudosum_req;
102#define TCP_PS_NOT_REQUIRED 0x00
103#define TCP_PS_REQUIRED 0x01
104 u8 reserved3[30];
105 __be16 num_ipv6_ext_headers;
106 __be32 off_ipv6_ext_headers;
107 u8 reserved4[154];
108} __packed __aligned(8);
109
110struct ibmvnic_control_ip_offload_buffer {
111 __be32 len;
112 __be32 version;
113#define INITIAL_VERSION_IOB 1
114 u8 ipv4_chksum;
115 u8 ipv6_chksum;
116 u8 tcp_ipv4_chksum;
117 u8 tcp_ipv6_chksum;
118 u8 udp_ipv4_chksum;
119 u8 udp_ipv6_chksum;
120 u8 large_tx_ipv4;
121 u8 large_tx_ipv6;
122 u8 bad_packet_rx;
123 u8 large_rx_ipv4;
124 u8 large_rx_ipv6;
125 u8 reserved4[111];
126} __packed __aligned(8);
127
128struct ibmvnic_fw_component {
129 u8 name[48];
130 __be32 trace_buff_size;
131 u8 correlator;
132 u8 trace_level;
133 u8 parent_correlator;
134 u8 error_check_level;
135 u8 trace_on;
136 u8 reserved[7];
137 u8 description[192];
138} __packed __aligned(8);
139
140struct ibmvnic_fw_trace_entry {
141 __be32 trace_id;
142 u8 num_valid_data;
143 u8 reserved[3];
144 __be64 pmc_registers;
145 __be64 timebase;
146 __be64 trace_data[5];
147} __packed __aligned(8);
148
149struct ibmvnic_statistics {
150 __be32 version;
151 __be32 promiscuous;
152 __be64 rx_packets;
153 __be64 rx_bytes;
154 __be64 tx_packets;
155 __be64 tx_bytes;
156 __be64 ucast_tx_packets;
157 __be64 ucast_rx_packets;
158 __be64 mcast_tx_packets;
159 __be64 mcast_rx_packets;
160 __be64 bcast_tx_packets;
161 __be64 bcast_rx_packets;
162 __be64 align_errors;
163 __be64 fcs_errors;
164 __be64 single_collision_frames;
165 __be64 multi_collision_frames;
166 __be64 sqe_test_errors;
167 __be64 deferred_tx;
168 __be64 late_collisions;
169 __be64 excess_collisions;
170 __be64 internal_mac_tx_errors;
171 __be64 carrier_sense;
172 __be64 too_long_frames;
173 __be64 internal_mac_rx_errors;
174 u8 reserved[72];
175} __packed __aligned(8);
176
John Allen3d52b592017-08-02 16:44:14 -0500177#define NUM_TX_STATS 3
178struct ibmvnic_tx_queue_stats {
179 u64 packets;
180 u64 bytes;
181 u64 dropped_packets;
182};
183
184#define NUM_RX_STATS 3
185struct ibmvnic_rx_queue_stats {
186 u64 packets;
187 u64 bytes;
188 u64 interrupts;
189};
190
Thomas Falcon032c5e82015-12-21 11:26:06 -0600191struct ibmvnic_acl_buffer {
192 __be32 len;
193 __be32 version;
194#define INITIAL_VERSION_IOB 1
195 u8 mac_acls_restrict;
196 u8 vlan_acls_restrict;
197 u8 reserved1[22];
198 __be32 num_mac_addrs;
199 __be32 offset_mac_addrs;
200 __be32 num_vlan_ids;
201 __be32 offset_vlan_ids;
202 u8 reserved2[80];
203} __packed __aligned(8);
204
205/* descriptors have been changed, how should this be defined? 1? 4? */
206
207#define IBMVNIC_TX_DESC_VERSIONS 3
208
209/* is this still needed? */
210struct ibmvnic_tx_comp_desc {
211 u8 first;
212 u8 num_comps;
213 __be16 rcs[5];
214 __be32 correlators[5];
215} __packed __aligned(8);
216
217/* some flags that included in v0 descriptor, which is gone
218 * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
219 * and only in some offload_flags variable that doesn't seem
220 * to be used anywhere, can probably be removed?
221 */
222
223#define IBMVNIC_TCP_CHKSUM 0x20
224#define IBMVNIC_UDP_CHKSUM 0x08
225
226#define IBMVNIC_MAX_FRAGS_PER_CRQ 3
227
228struct ibmvnic_tx_desc {
229 u8 first;
230 u8 type;
231
232#define IBMVNIC_TX_DESC 0x10
233 u8 n_crq_elem;
234 u8 n_sge;
235 u8 flags1;
236#define IBMVNIC_TX_COMP_NEEDED 0x80
237#define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
238#define IBMVNIC_TX_LSO 0x20
239#define IBMVNIC_TX_PROT_TCP 0x10
240#define IBMVNIC_TX_PROT_UDP 0x08
241#define IBMVNIC_TX_PROT_IPV4 0x04
242#define IBMVNIC_TX_PROT_IPV6 0x02
243#define IBMVNIC_TX_VLAN_PRESENT 0x01
244 u8 flags2;
245#define IBMVNIC_TX_VLAN_INSERT 0x80
246 __be16 mss;
247 u8 reserved[4];
248 __be32 correlator;
249 __be16 vlan_id;
250 __be16 dma_reg;
251 __be32 sge_len;
252 __be64 ioba;
253} __packed __aligned(8);
254
255struct ibmvnic_hdr_desc {
256 u8 first;
257 u8 type;
258#define IBMVNIC_HDR_DESC 0x11
259 u8 len;
260 u8 l2_len;
261 __be16 l3_len;
262 u8 l4_len;
263 u8 flag;
264 u8 data[24];
265} __packed __aligned(8);
266
267struct ibmvnic_hdr_ext_desc {
268 u8 first;
269 u8 type;
270#define IBMVNIC_HDR_EXT_DESC 0x12
271 u8 len;
272 u8 data[29];
273} __packed __aligned(8);
274
275struct ibmvnic_sge_desc {
276 u8 first;
277 u8 type;
278#define IBMVNIC_SGE_DESC 0x30
279 __be16 sge1_dma_reg;
280 __be32 sge1_len;
281 __be64 sge1_ioba;
282 __be16 reserved;
283 __be16 sge2_dma_reg;
284 __be32 sge2_len;
285 __be64 sge2_ioba;
286} __packed __aligned(8);
287
288struct ibmvnic_rx_comp_desc {
289 u8 first;
290 u8 flags;
291#define IBMVNIC_IP_CHKSUM_GOOD 0x80
292#define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
293#define IBMVNIC_END_FRAME 0x20
294#define IBMVNIC_EXACT_MC 0x10
295#define IBMVNIC_VLAN_STRIPPED 0x08
296 __be16 off_frame_data;
297 __be32 len;
298 __be64 correlator;
299 __be16 vlan_tci;
300 __be16 rc;
301 u8 reserved[12];
302} __packed __aligned(8);
303
304struct ibmvnic_generic_scrq {
305 u8 first;
306 u8 reserved[31];
307} __packed __aligned(8);
308
309struct ibmvnic_rx_buff_add_desc {
310 u8 first;
311 u8 reserved[7];
312 __be64 correlator;
313 __be32 ioba;
314 u8 map_id;
315 __be32 len:24;
316 u8 reserved2[8];
317} __packed __aligned(8);
318
319struct ibmvnic_rc {
320 u8 code; /* one of enum ibmvnic_rc_codes */
321 u8 detailed_data[3];
322} __packed __aligned(4);
323
324struct ibmvnic_generic_crq {
325 u8 first;
326 u8 cmd;
327 u8 params[10];
328 struct ibmvnic_rc rc;
329} __packed __aligned(8);
330
331struct ibmvnic_version_exchange {
332 u8 first;
333 u8 cmd;
334 __be16 version;
335#define IBMVNIC_INITIAL_VERSION 1
336 u8 reserved[8];
337 struct ibmvnic_rc rc;
338} __packed __aligned(8);
339
340struct ibmvnic_capability {
341 u8 first;
342 u8 cmd;
343 __be16 capability; /* one of ibmvnic_capabilities */
Thomas Falconde89e852016-03-01 10:20:09 -0600344 __be64 number;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600345 struct ibmvnic_rc rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600346} __packed __aligned(8);
347
348struct ibmvnic_login {
349 u8 first;
350 u8 cmd;
351 u8 reserved[6];
352 __be32 ioba;
353 __be32 len;
354} __packed __aligned(8);
355
356struct ibmvnic_phys_parms {
357 u8 first;
358 u8 cmd;
359 u8 flags1;
360#define IBMVNIC_EXTERNAL_LOOPBACK 0x80
361#define IBMVNIC_INTERNAL_LOOPBACK 0x40
362#define IBMVNIC_PROMISC 0x20
363#define IBMVNIC_PHYS_LINK_ACTIVE 0x10
364#define IBMVNIC_AUTONEG_DUPLEX 0x08
365#define IBMVNIC_FULL_DUPLEX 0x04
366#define IBMVNIC_HALF_DUPLEX 0x02
367#define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
368 u8 flags2;
369#define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
370 __be32 speed;
371#define IBMVNIC_AUTONEG 0x80
372#define IBMVNIC_10MBPS 0x40
373#define IBMVNIC_100MBPS 0x20
374#define IBMVNIC_1GBPS 0x10
375#define IBMVNIC_10GBPS 0x08
376 __be32 mtu;
377 struct ibmvnic_rc rc;
378} __packed __aligned(8);
379
380struct ibmvnic_logical_link_state {
381 u8 first;
382 u8 cmd;
383 u8 link_state;
384#define IBMVNIC_LOGICAL_LNK_DN 0x00
385#define IBMVNIC_LOGICAL_LNK_UP 0x01
386#define IBMVNIC_LOGICAL_LNK_QUERY 0xff
387 u8 reserved[9];
388 struct ibmvnic_rc rc;
389} __packed __aligned(8);
390
391struct ibmvnic_query_ip_offload {
392 u8 first;
393 u8 cmd;
394 u8 reserved[2];
395 __be32 len;
396 __be32 ioba;
397 struct ibmvnic_rc rc;
398} __packed __aligned(8);
399
400struct ibmvnic_control_ip_offload {
401 u8 first;
402 u8 cmd;
403 u8 reserved[2];
404 __be32 ioba;
405 __be32 len;
406 struct ibmvnic_rc rc;
407} __packed __aligned(8);
408
409struct ibmvnic_request_dump_size {
410 u8 first;
411 u8 cmd;
412 u8 reserved[6];
413 __be32 len;
414 struct ibmvnic_rc rc;
415} __packed __aligned(8);
416
417struct ibmvnic_request_dump {
418 u8 first;
419 u8 cmd;
420 u8 reserved1[2];
421 __be32 ioba;
422 __be32 len;
423 u8 reserved2[4];
424} __packed __aligned(8);
425
426struct ibmvnic_request_dump_rsp {
427 u8 first;
428 u8 cmd;
429 u8 reserved[6];
430 __be32 dumped_len;
431 struct ibmvnic_rc rc;
432} __packed __aligned(8);
433
434struct ibmvnic_request_ras_comp_num {
435 u8 first;
436 u8 cmd;
437 u8 reserved1[2];
438 __be32 num_components;
439 u8 reserved2[4];
440 struct ibmvnic_rc rc;
441} __packed __aligned(8);
442
443struct ibmvnic_request_ras_comps {
444 u8 first;
445 u8 cmd;
446 u8 reserved[2];
447 __be32 ioba;
448 __be32 len;
449 struct ibmvnic_rc rc;
450} __packed __aligned(8);
451
452struct ibmvnic_control_ras {
453 u8 first;
454 u8 cmd;
455 u8 correlator;
456 u8 level;
457 u8 op;
458#define IBMVNIC_TRACE_LEVEL 1
459#define IBMVNIC_ERROR_LEVEL 2
460#define IBMVNIC_TRACE_PAUSE 3
461#define IBMVNIC_TRACE_RESUME 4
462#define IBMVNIC_TRACE_ON 5
463#define IBMVNIC_TRACE_OFF 6
464#define IBMVNIC_CHG_TRACE_BUFF_SZ 7
465 u8 trace_buff_sz[3];
466 u8 reserved[4];
467 struct ibmvnic_rc rc;
468} __packed __aligned(8);
469
470struct ibmvnic_collect_fw_trace {
471 u8 first;
472 u8 cmd;
473 u8 correlator;
474 u8 reserved;
475 __be32 ioba;
476 __be32 len;
477 struct ibmvnic_rc rc;
478} __packed __aligned(8);
479
480struct ibmvnic_request_statistics {
481 u8 first;
482 u8 cmd;
483 u8 flags;
484#define IBMVNIC_PHYSICAL_PORT 0x80
485 u8 reserved1;
486 __be32 ioba;
487 __be32 len;
488 u8 reserved[4];
489} __packed __aligned(8);
490
491struct ibmvnic_request_debug_stats {
492 u8 first;
493 u8 cmd;
494 u8 reserved[2];
495 __be32 ioba;
496 __be32 len;
497 struct ibmvnic_rc rc;
498} __packed __aligned(8);
499
500struct ibmvnic_error_indication {
501 u8 first;
502 u8 cmd;
503 u8 flags;
504#define IBMVNIC_FATAL_ERROR 0x80
505 u8 reserved1;
506 __be32 error_id;
507 __be32 detail_error_sz;
508 __be16 error_cause;
509 u8 reserved2[2];
510} __packed __aligned(8);
511
512struct ibmvnic_request_error_info {
513 u8 first;
514 u8 cmd;
515 u8 reserved[2];
516 __be32 ioba;
517 __be32 len;
518 __be32 error_id;
519} __packed __aligned(8);
520
521struct ibmvnic_request_error_rsp {
522 u8 first;
523 u8 cmd;
524 u8 reserved[2];
525 __be32 error_id;
526 __be32 len;
527 struct ibmvnic_rc rc;
528} __packed __aligned(8);
529
530struct ibmvnic_link_state_indication {
531 u8 first;
532 u8 cmd;
533 u8 reserved1[2];
534 u8 phys_link_state;
535 u8 logical_link_state;
536 u8 reserved2[10];
537} __packed __aligned(8);
538
539struct ibmvnic_change_mac_addr {
540 u8 first;
541 u8 cmd;
542 u8 mac_addr[6];
Thomas Falcon032c5e82015-12-21 11:26:06 -0600543 u8 reserved[4];
Murilo Fossa Vicentini993a82b2017-04-19 13:44:35 -0400544 struct ibmvnic_rc rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600545} __packed __aligned(8);
546
547struct ibmvnic_multicast_ctrl {
548 u8 first;
549 u8 cmd;
550 u8 mac_addr[6];
551 u8 flags;
552#define IBMVNIC_ENABLE_MC 0x80
553#define IBMVNIC_DISABLE_MC 0x40
554#define IBMVNIC_ENABLE_ALL 0x20
555#define IBMVNIC_DISABLE_ALL 0x10
556 u8 reserved1;
557 __be16 reserved2; /* was num_enabled_mc_addr; */
558 struct ibmvnic_rc rc;
559} __packed __aligned(8);
560
561struct ibmvnic_get_vpd_size_rsp {
562 u8 first;
563 u8 cmd;
564 u8 reserved[2];
565 __be64 len;
566 struct ibmvnic_rc rc;
567} __packed __aligned(8);
568
569struct ibmvnic_get_vpd {
570 u8 first;
571 u8 cmd;
572 u8 reserved1[2];
573 __be32 ioba;
574 __be32 len;
575 u8 reserved[4];
576} __packed __aligned(8);
577
578struct ibmvnic_acl_change_indication {
579 u8 first;
580 u8 cmd;
581 __be16 change_type;
582#define IBMVNIC_MAC_ACL 0
583#define IBMVNIC_VLAN_ACL 1
584 u8 reserved[12];
585} __packed __aligned(8);
586
587struct ibmvnic_acl_query {
588 u8 first;
589 u8 cmd;
590 u8 reserved1[2];
591 __be32 ioba;
592 __be32 len;
593 u8 reserved2[4];
594} __packed __aligned(8);
595
596struct ibmvnic_tune {
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_request_map {
606 u8 first;
607 u8 cmd;
608 u8 reserved1;
609 u8 map_id;
610 __be32 ioba;
611 __be32 len;
612 u8 reserved2[4];
613} __packed __aligned(8);
614
615struct ibmvnic_request_map_rsp {
616 u8 first;
617 u8 cmd;
618 u8 reserved1;
619 u8 map_id;
Thomas Falcon288ccb72017-06-21 14:53:00 -0500620 u8 reserved2[8];
Thomas Falcon032c5e82015-12-21 11:26:06 -0600621 struct ibmvnic_rc rc;
622} __packed __aligned(8);
623
624struct ibmvnic_request_unmap {
625 u8 first;
626 u8 cmd;
627 u8 reserved1;
628 u8 map_id;
629 u8 reserved2[12];
630} __packed __aligned(8);
631
632struct ibmvnic_request_unmap_rsp {
633 u8 first;
634 u8 cmd;
635 u8 reserved1;
636 u8 map_id;
637 u8 reserved2[8];
638 struct ibmvnic_rc rc;
639} __packed __aligned(8);
640
641struct ibmvnic_query_map {
642 u8 first;
643 u8 cmd;
644 u8 reserved[14];
645} __packed __aligned(8);
646
647struct ibmvnic_query_map_rsp {
648 u8 first;
649 u8 cmd;
650 u8 reserved;
651 u8 page_size;
652 __be32 tot_pages;
653 __be32 free_pages;
654 struct ibmvnic_rc rc;
655} __packed __aligned(8);
656
657union ibmvnic_crq {
658 struct ibmvnic_generic_crq generic;
659 struct ibmvnic_version_exchange version_exchange;
660 struct ibmvnic_version_exchange version_exchange_rsp;
661 struct ibmvnic_capability query_capability;
662 struct ibmvnic_capability query_capability_rsp;
663 struct ibmvnic_capability request_capability;
664 struct ibmvnic_capability request_capability_rsp;
665 struct ibmvnic_login login;
666 struct ibmvnic_generic_crq login_rsp;
667 struct ibmvnic_phys_parms query_phys_parms;
668 struct ibmvnic_phys_parms query_phys_parms_rsp;
669 struct ibmvnic_phys_parms query_phys_capabilities;
670 struct ibmvnic_phys_parms query_phys_capabilities_rsp;
671 struct ibmvnic_phys_parms set_phys_parms;
672 struct ibmvnic_phys_parms set_phys_parms_rsp;
673 struct ibmvnic_logical_link_state logical_link_state;
674 struct ibmvnic_logical_link_state logical_link_state_rsp;
675 struct ibmvnic_query_ip_offload query_ip_offload;
676 struct ibmvnic_query_ip_offload query_ip_offload_rsp;
677 struct ibmvnic_control_ip_offload control_ip_offload;
678 struct ibmvnic_control_ip_offload control_ip_offload_rsp;
679 struct ibmvnic_request_dump_size request_dump_size;
680 struct ibmvnic_request_dump_size request_dump_size_rsp;
681 struct ibmvnic_request_dump request_dump;
682 struct ibmvnic_request_dump_rsp request_dump_rsp;
683 struct ibmvnic_request_ras_comp_num request_ras_comp_num;
684 struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
685 struct ibmvnic_request_ras_comps request_ras_comps;
686 struct ibmvnic_request_ras_comps request_ras_comps_rsp;
687 struct ibmvnic_control_ras control_ras;
688 struct ibmvnic_control_ras control_ras_rsp;
689 struct ibmvnic_collect_fw_trace collect_fw_trace;
690 struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
691 struct ibmvnic_request_statistics request_statistics;
692 struct ibmvnic_generic_crq request_statistics_rsp;
693 struct ibmvnic_request_debug_stats request_debug_stats;
694 struct ibmvnic_request_debug_stats request_debug_stats_rsp;
695 struct ibmvnic_error_indication error_indication;
696 struct ibmvnic_request_error_info request_error_info;
697 struct ibmvnic_request_error_rsp request_error_rsp;
698 struct ibmvnic_link_state_indication link_state_indication;
699 struct ibmvnic_change_mac_addr change_mac_addr;
700 struct ibmvnic_change_mac_addr change_mac_addr_rsp;
701 struct ibmvnic_multicast_ctrl multicast_ctrl;
702 struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
703 struct ibmvnic_generic_crq get_vpd_size;
704 struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
705 struct ibmvnic_get_vpd get_vpd;
706 struct ibmvnic_generic_crq get_vpd_rsp;
707 struct ibmvnic_acl_change_indication acl_change_indication;
708 struct ibmvnic_acl_query acl_query;
709 struct ibmvnic_generic_crq acl_query_rsp;
710 struct ibmvnic_tune tune;
711 struct ibmvnic_generic_crq tune_rsp;
712 struct ibmvnic_request_map request_map;
713 struct ibmvnic_request_map_rsp request_map_rsp;
714 struct ibmvnic_request_unmap request_unmap;
715 struct ibmvnic_request_unmap_rsp request_unmap_rsp;
716 struct ibmvnic_query_map query_map;
717 struct ibmvnic_query_map_rsp query_map_rsp;
718};
719
720enum ibmvnic_rc_codes {
721 SUCCESS = 0,
722 PARTIALSUCCESS = 1,
723 PERMISSION = 2,
724 NOMEMORY = 3,
725 PARAMETER = 4,
726 UNKNOWNCOMMAND = 5,
727 ABORTED = 6,
728 INVALIDSTATE = 7,
729 INVALIDIOBA = 8,
730 INVALIDLENGTH = 9,
731 UNSUPPORTEDOPTION = 10,
732};
733
734enum ibmvnic_capabilities {
735 MIN_TX_QUEUES = 1,
736 MIN_RX_QUEUES = 2,
737 MIN_RX_ADD_QUEUES = 3,
738 MAX_TX_QUEUES = 4,
739 MAX_RX_QUEUES = 5,
740 MAX_RX_ADD_QUEUES = 6,
741 REQ_TX_QUEUES = 7,
742 REQ_RX_QUEUES = 8,
743 REQ_RX_ADD_QUEUES = 9,
744 MIN_TX_ENTRIES_PER_SUBCRQ = 10,
745 MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
746 MAX_TX_ENTRIES_PER_SUBCRQ = 12,
747 MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
748 REQ_TX_ENTRIES_PER_SUBCRQ = 14,
749 REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
750 TCP_IP_OFFLOAD = 16,
751 PROMISC_REQUESTED = 17,
752 PROMISC_SUPPORTED = 18,
753 MIN_MTU = 19,
754 MAX_MTU = 20,
755 REQ_MTU = 21,
756 MAX_MULTICAST_FILTERS = 22,
757 VLAN_HEADER_INSERTION = 23,
Murilo Fossa Vicentini6052d5e2017-04-21 15:38:46 -0400758 RX_VLAN_HEADER_INSERTION = 24,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600759 MAX_TX_SG_ENTRIES = 25,
760 RX_SG_SUPPORTED = 26,
761 RX_SG_REQUESTED = 27,
762 OPT_TX_COMP_SUB_QUEUES = 28,
763 OPT_RX_COMP_QUEUES = 29,
764 OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
765 OPT_TX_ENTRIES_PER_SUBCRQ = 31,
766 OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
767 TX_RX_DESC_REQ = 33,
768};
769
770enum ibmvnic_error_cause {
771 ADAPTER_PROBLEM = 0,
772 BUS_PROBLEM = 1,
773 FW_PROBLEM = 2,
774 DD_PROBLEM = 3,
775 EEH_RECOVERY = 4,
776 FW_UPDATED = 5,
777 LOW_MEMORY = 6,
778};
779
780enum ibmvnic_commands {
781 VERSION_EXCHANGE = 0x01,
782 VERSION_EXCHANGE_RSP = 0x81,
783 QUERY_CAPABILITY = 0x02,
784 QUERY_CAPABILITY_RSP = 0x82,
785 REQUEST_CAPABILITY = 0x03,
786 REQUEST_CAPABILITY_RSP = 0x83,
787 LOGIN = 0x04,
788 LOGIN_RSP = 0x84,
789 QUERY_PHYS_PARMS = 0x05,
790 QUERY_PHYS_PARMS_RSP = 0x85,
791 QUERY_PHYS_CAPABILITIES = 0x06,
792 QUERY_PHYS_CAPABILITIES_RSP = 0x86,
793 SET_PHYS_PARMS = 0x07,
794 SET_PHYS_PARMS_RSP = 0x87,
795 ERROR_INDICATION = 0x08,
796 REQUEST_ERROR_INFO = 0x09,
797 REQUEST_ERROR_RSP = 0x89,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600798 LOGICAL_LINK_STATE = 0x0C,
799 LOGICAL_LINK_STATE_RSP = 0x8C,
800 REQUEST_STATISTICS = 0x0D,
801 REQUEST_STATISTICS_RSP = 0x8D,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600802 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,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600822 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
832enum 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
840enum ibmvfc_crq_format {
841 IBMVNIC_CRQ_INIT = 0x01,
842 IBMVNIC_CRQ_INIT_COMPLETE = 0x02,
843 IBMVNIC_PARTITION_MIGRATED = 0x06,
Thomas Falcondfad09a2016-08-18 11:37:51 -0500844 IBMVNIC_DEVICE_FAILOVER = 0x08,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600845};
846
847struct ibmvnic_crq_queue {
848 union ibmvnic_crq *msgs;
849 int size, cur;
850 dma_addr_t msg_token;
851 spinlock_t lock;
852};
853
854union sub_crq {
855 struct ibmvnic_generic_scrq generic;
856 struct ibmvnic_tx_comp_desc tx_comp;
857 struct ibmvnic_tx_desc v1;
858 struct ibmvnic_hdr_desc hdr;
859 struct ibmvnic_hdr_ext_desc hdr_ext;
860 struct ibmvnic_sge_desc sge;
861 struct ibmvnic_rx_comp_desc rx_comp;
862 struct ibmvnic_rx_buff_add_desc rx_add;
863};
864
865struct ibmvnic_sub_crq_queue {
866 union sub_crq *msgs;
867 int size, cur;
868 dma_addr_t msg_token;
869 unsigned long crq_num;
870 unsigned long hw_irq;
871 unsigned int irq;
872 unsigned int pool_index;
873 int scrq_num;
874 spinlock_t lock;
875 struct sk_buff *rx_skb_top;
876 struct ibmvnic_adapter *adapter;
Thomas Falcon142c0ac2017-03-05 12:18:41 -0600877 atomic_t used;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600878};
879
880struct ibmvnic_long_term_buff {
881 unsigned char *buff;
882 dma_addr_t addr;
883 u64 size;
884 u8 map_id;
885};
886
887struct ibmvnic_tx_buff {
888 struct sk_buff *skb;
889 dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
890 unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
891 int index;
892 int pool_index;
893 bool last_frag;
Thomas Falconad7775d2016-04-01 17:20:34 -0500894 union sub_crq indir_arr[6];
895 u8 hdr_data[140];
896 dma_addr_t indir_dma;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600897};
898
899struct ibmvnic_tx_pool {
900 struct ibmvnic_tx_buff *tx_buff;
901 int *free_map;
902 int consumer_index;
903 int producer_index;
904 wait_queue_head_t ibmvnic_tx_comp_q;
905 struct task_struct *work_thread;
906 struct ibmvnic_long_term_buff long_term_buff;
Thomas Falconfdb06102017-10-17 12:36:55 -0500907 struct ibmvnic_long_term_buff tso_ltb;
908 int tso_index;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600909};
910
911struct 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
919struct 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
932struct ibmvnic_error_buff {
933 char *buff;
934 dma_addr_t dma;
935 int len;
936 struct list_head list;
937 __be32 error_id;
938};
939
Nathan Fontenot90c80142017-05-03 14:04:32 -0400940enum vnic_state {VNIC_PROBING = 1,
941 VNIC_PROBED,
942 VNIC_OPENING,
943 VNIC_OPEN,
944 VNIC_CLOSING,
945 VNIC_CLOSED,
946 VNIC_REMOVING,
947 VNIC_REMOVED};
948
Nathan Fontenoted651a12017-05-03 14:04:38 -0400949enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
950 VNIC_RESET_MOBILITY,
951 VNIC_RESET_FATAL,
John Allen8cb31cf2017-05-26 10:30:37 -0400952 VNIC_RESET_NON_FATAL,
John Allenc26eba02017-10-26 16:23:25 -0500953 VNIC_RESET_TIMEOUT,
954 VNIC_RESET_CHANGE_PARAM};
Nathan Fontenoted651a12017-05-03 14:04:38 -0400955
956struct ibmvnic_rwi {
957 enum ibmvnic_reset_reason reset_reason;
958 struct list_head list;
959};
960
John Allenc26eba02017-10-26 16:23:25 -0500961struct ibmvnic_tunables {
962 u64 rx_queues;
963 u64 tx_queues;
964 u64 rx_entries;
965 u64 tx_entries;
966 u64 mtu;
967 struct sockaddr mac;
968};
969
Thomas Falcon032c5e82015-12-21 11:26:06 -0600970struct ibmvnic_adapter {
971 struct vio_dev *vdev;
972 struct net_device *netdev;
973 struct ibmvnic_crq_queue crq;
974 u8 mac_addr[ETH_ALEN];
975 struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
976 dma_addr_t ip_offload_tok;
977 struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
978 dma_addr_t ip_offload_ctrl_tok;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600979 u32 msg_enable;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600980
981 /* Statistics */
Thomas Falcon032c5e82015-12-21 11:26:06 -0600982 struct ibmvnic_statistics stats;
983 dma_addr_t stats_token;
984 struct completion stats_done;
985 spinlock_t stats_lock;
986 int replenish_no_mem;
987 int replenish_add_buff_success;
988 int replenish_add_buff_failure;
989 int replenish_task_cycles;
990 int tx_send_failed;
991 int tx_map_failed;
992
John Allen3d52b592017-08-02 16:44:14 -0500993 struct ibmvnic_tx_queue_stats *tx_stats_buffers;
994 struct ibmvnic_rx_queue_stats *rx_stats_buffers;
995
Thomas Falcon032c5e82015-12-21 11:26:06 -0600996 int phys_link_state;
997 int logical_link_state;
998
999 /* login data */
1000 struct ibmvnic_login_buffer *login_buf;
1001 dma_addr_t login_buf_token;
1002 int login_buf_sz;
1003
1004 struct ibmvnic_login_rsp_buffer *login_rsp_buf;
1005 dma_addr_t login_rsp_buf_token;
1006 int login_rsp_buf_sz;
1007
Thomas Falcon901e0402017-02-15 12:17:59 -06001008 atomic_t running_cap_crqs;
Thomas Falcon249168a2017-02-15 12:18:00 -06001009 bool wait_capability;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001010
1011 struct ibmvnic_sub_crq_queue **tx_scrq;
1012 struct ibmvnic_sub_crq_queue **rx_scrq;
John Allen498cd8e2016-04-06 11:49:55 -05001013 bool renegotiate;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001014
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;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001021 struct completion init_done;
Nathan Fontenot53da09e2017-04-21 15:39:04 -04001022 int init_done_rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001023
1024 struct list_head errors;
1025 spinlock_t error_list_lock;
1026
Thomas Falcon032c5e82015-12-21 11:26:06 -06001027 struct completion fw_done;
Thomas Falconf3be0cb2017-06-21 14:53:01 -05001028 int fw_done_rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001029
John Allenc26eba02017-10-26 16:23:25 -05001030 struct completion reset_done;
1031 int reset_done_rc;
1032 bool wait_for_reset;
1033
Thomas Falcon032c5e82015-12-21 11:26:06 -06001034 /* 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;
Murilo Fossa Vicentini6052d5e2017-04-21 15:38:46 -04001058 u64 rx_vlan_header_insertion;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001059 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;
Thomas Falcon65dc6892016-07-06 15:35:18 -05001069
Thomas Falcon6c267b32017-02-15 12:17:58 -06001070 struct tasklet_struct tasklet;
Nathan Fontenot90c80142017-05-03 14:04:32 -04001071 enum vnic_state state;
Nathan Fontenoted651a12017-05-03 14:04:38 -04001072 enum ibmvnic_reset_reason reset_reason;
1073 struct mutex reset_lock, rwi_lock;
1074 struct list_head rwi_list;
1075 struct work_struct ibmvnic_reset;
1076 bool resetting;
John Allen017892c12017-05-26 10:30:19 -04001077 bool napi_enabled, from_passive_init;
John Allenc26eba02017-10-26 16:23:25 -05001078
1079 bool mac_change_pending;
1080
1081 struct ibmvnic_tunables desired;
1082 struct ibmvnic_tunables fallback;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001083};