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