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