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