blob: f9a12e5843c4fbc04c196a8163bb59661013cd1e [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
Thomas Falconad95a242018-09-28 18:38:24 -050042#define IBMVNIC_MAX_QUEUES 16
Thomas Falcon20b5ba12018-09-28 18:38:25 -050043#define IBMVNIC_MAX_QUEUE_SZ 4096
Thomas Falcon032c5e82015-12-21 11:26:06 -060044
Thomas Falconfdb06102017-10-17 12:36:55 -050045#define IBMVNIC_TSO_BUF_SZ 65536
46#define IBMVNIC_TSO_BUFS 64
Thomas Falcon06b3e352018-03-16 20:00:28 -050047#define IBMVNIC_TSO_POOL_MASK 0x80000000
Thomas Falconfdb06102017-10-17 12:36:55 -050048
John Allenc26eba02017-10-26 16:23:25 -050049#define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
50#define IBMVNIC_BUFFER_HLEN 500
51
Thomas Falcon032c5e82015-12-21 11:26:06 -060052struct ibmvnic_login_buffer {
53 __be32 len;
54 __be32 version;
55#define INITIAL_VERSION_LB 1
56 __be32 num_txcomp_subcrqs;
57 __be32 off_txcomp_subcrqs;
58 __be32 num_rxcomp_subcrqs;
59 __be32 off_rxcomp_subcrqs;
60 __be32 login_rsp_ioba;
61 __be32 login_rsp_len;
Nathan Fontenot37798d02017-11-08 11:23:56 -060062 __be32 client_data_offset;
63 __be32 client_data_len;
Thomas Falcon032c5e82015-12-21 11:26:06 -060064} __packed __aligned(8);
65
66struct ibmvnic_login_rsp_buffer {
67 __be32 len;
68 __be32 version;
69#define INITIAL_VERSION_LRB 1
70 __be32 num_txsubm_subcrqs;
71 __be32 off_txsubm_subcrqs;
72 __be32 num_rxadd_subcrqs;
73 __be32 off_rxadd_subcrqs;
74 __be32 off_rxadd_buff_size;
75 __be32 num_supp_tx_desc;
76 __be32 off_supp_tx_desc;
77} __packed __aligned(8);
78
79struct ibmvnic_query_ip_offload_buffer {
80 __be32 len;
81 __be32 version;
82#define INITIAL_VERSION_IOB 1
83 u8 ipv4_chksum;
84 u8 ipv6_chksum;
85 u8 tcp_ipv4_chksum;
86 u8 tcp_ipv6_chksum;
87 u8 udp_ipv4_chksum;
88 u8 udp_ipv6_chksum;
89 u8 large_tx_ipv4;
90 u8 large_tx_ipv6;
91 u8 large_rx_ipv4;
92 u8 large_rx_ipv6;
93 u8 reserved1[14];
94 __be16 max_ipv4_header_size;
95 __be16 max_ipv6_header_size;
96 __be16 max_tcp_header_size;
97 __be16 max_udp_header_size;
98 __be32 max_large_tx_size;
99 __be32 max_large_rx_size;
100 u8 reserved2[16];
101 u8 ipv6_extension_header;
102#define IPV6_EH_NOT_SUPPORTED 0x00
103#define IPV6_EH_SUPPORTED_LIM 0x01
104#define IPV6_EH_SUPPORTED 0xFF
105 u8 tcp_pseudosum_req;
106#define TCP_PS_NOT_REQUIRED 0x00
107#define TCP_PS_REQUIRED 0x01
108 u8 reserved3[30];
109 __be16 num_ipv6_ext_headers;
110 __be32 off_ipv6_ext_headers;
111 u8 reserved4[154];
112} __packed __aligned(8);
113
114struct ibmvnic_control_ip_offload_buffer {
115 __be32 len;
116 __be32 version;
117#define INITIAL_VERSION_IOB 1
118 u8 ipv4_chksum;
119 u8 ipv6_chksum;
120 u8 tcp_ipv4_chksum;
121 u8 tcp_ipv6_chksum;
122 u8 udp_ipv4_chksum;
123 u8 udp_ipv6_chksum;
124 u8 large_tx_ipv4;
125 u8 large_tx_ipv6;
126 u8 bad_packet_rx;
127 u8 large_rx_ipv4;
128 u8 large_rx_ipv6;
129 u8 reserved4[111];
130} __packed __aligned(8);
131
132struct ibmvnic_fw_component {
133 u8 name[48];
134 __be32 trace_buff_size;
135 u8 correlator;
136 u8 trace_level;
137 u8 parent_correlator;
138 u8 error_check_level;
139 u8 trace_on;
140 u8 reserved[7];
141 u8 description[192];
142} __packed __aligned(8);
143
144struct ibmvnic_fw_trace_entry {
145 __be32 trace_id;
146 u8 num_valid_data;
147 u8 reserved[3];
148 __be64 pmc_registers;
149 __be64 timebase;
150 __be64 trace_data[5];
151} __packed __aligned(8);
152
153struct ibmvnic_statistics {
154 __be32 version;
155 __be32 promiscuous;
156 __be64 rx_packets;
157 __be64 rx_bytes;
158 __be64 tx_packets;
159 __be64 tx_bytes;
160 __be64 ucast_tx_packets;
161 __be64 ucast_rx_packets;
162 __be64 mcast_tx_packets;
163 __be64 mcast_rx_packets;
164 __be64 bcast_tx_packets;
165 __be64 bcast_rx_packets;
166 __be64 align_errors;
167 __be64 fcs_errors;
168 __be64 single_collision_frames;
169 __be64 multi_collision_frames;
170 __be64 sqe_test_errors;
171 __be64 deferred_tx;
172 __be64 late_collisions;
173 __be64 excess_collisions;
174 __be64 internal_mac_tx_errors;
175 __be64 carrier_sense;
176 __be64 too_long_frames;
177 __be64 internal_mac_rx_errors;
178 u8 reserved[72];
179} __packed __aligned(8);
180
John Allen3d52b592017-08-02 16:44:14 -0500181#define NUM_TX_STATS 3
182struct ibmvnic_tx_queue_stats {
183 u64 packets;
184 u64 bytes;
185 u64 dropped_packets;
186};
187
188#define NUM_RX_STATS 3
189struct ibmvnic_rx_queue_stats {
190 u64 packets;
191 u64 bytes;
192 u64 interrupts;
193};
194
Thomas Falcon032c5e82015-12-21 11:26:06 -0600195struct ibmvnic_acl_buffer {
196 __be32 len;
197 __be32 version;
198#define INITIAL_VERSION_IOB 1
199 u8 mac_acls_restrict;
200 u8 vlan_acls_restrict;
201 u8 reserved1[22];
202 __be32 num_mac_addrs;
203 __be32 offset_mac_addrs;
204 __be32 num_vlan_ids;
205 __be32 offset_vlan_ids;
206 u8 reserved2[80];
207} __packed __aligned(8);
208
209/* descriptors have been changed, how should this be defined? 1? 4? */
210
211#define IBMVNIC_TX_DESC_VERSIONS 3
212
213/* is this still needed? */
214struct ibmvnic_tx_comp_desc {
215 u8 first;
216 u8 num_comps;
217 __be16 rcs[5];
218 __be32 correlators[5];
219} __packed __aligned(8);
220
221/* some flags that included in v0 descriptor, which is gone
222 * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
223 * and only in some offload_flags variable that doesn't seem
224 * to be used anywhere, can probably be removed?
225 */
226
227#define IBMVNIC_TCP_CHKSUM 0x20
228#define IBMVNIC_UDP_CHKSUM 0x08
229
230#define IBMVNIC_MAX_FRAGS_PER_CRQ 3
231
232struct ibmvnic_tx_desc {
233 u8 first;
234 u8 type;
235
236#define IBMVNIC_TX_DESC 0x10
237 u8 n_crq_elem;
238 u8 n_sge;
239 u8 flags1;
240#define IBMVNIC_TX_COMP_NEEDED 0x80
241#define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
242#define IBMVNIC_TX_LSO 0x20
243#define IBMVNIC_TX_PROT_TCP 0x10
244#define IBMVNIC_TX_PROT_UDP 0x08
245#define IBMVNIC_TX_PROT_IPV4 0x04
246#define IBMVNIC_TX_PROT_IPV6 0x02
247#define IBMVNIC_TX_VLAN_PRESENT 0x01
248 u8 flags2;
249#define IBMVNIC_TX_VLAN_INSERT 0x80
250 __be16 mss;
251 u8 reserved[4];
252 __be32 correlator;
253 __be16 vlan_id;
254 __be16 dma_reg;
255 __be32 sge_len;
256 __be64 ioba;
257} __packed __aligned(8);
258
259struct ibmvnic_hdr_desc {
260 u8 first;
261 u8 type;
262#define IBMVNIC_HDR_DESC 0x11
263 u8 len;
264 u8 l2_len;
265 __be16 l3_len;
266 u8 l4_len;
267 u8 flag;
268 u8 data[24];
269} __packed __aligned(8);
270
271struct ibmvnic_hdr_ext_desc {
272 u8 first;
273 u8 type;
274#define IBMVNIC_HDR_EXT_DESC 0x12
275 u8 len;
276 u8 data[29];
277} __packed __aligned(8);
278
279struct ibmvnic_sge_desc {
280 u8 first;
281 u8 type;
282#define IBMVNIC_SGE_DESC 0x30
283 __be16 sge1_dma_reg;
284 __be32 sge1_len;
285 __be64 sge1_ioba;
286 __be16 reserved;
287 __be16 sge2_dma_reg;
288 __be32 sge2_len;
289 __be64 sge2_ioba;
290} __packed __aligned(8);
291
292struct ibmvnic_rx_comp_desc {
293 u8 first;
294 u8 flags;
295#define IBMVNIC_IP_CHKSUM_GOOD 0x80
296#define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
297#define IBMVNIC_END_FRAME 0x20
298#define IBMVNIC_EXACT_MC 0x10
299#define IBMVNIC_VLAN_STRIPPED 0x08
300 __be16 off_frame_data;
301 __be32 len;
302 __be64 correlator;
303 __be16 vlan_tci;
304 __be16 rc;
305 u8 reserved[12];
306} __packed __aligned(8);
307
308struct ibmvnic_generic_scrq {
309 u8 first;
310 u8 reserved[31];
311} __packed __aligned(8);
312
313struct ibmvnic_rx_buff_add_desc {
314 u8 first;
315 u8 reserved[7];
316 __be64 correlator;
317 __be32 ioba;
318 u8 map_id;
319 __be32 len:24;
320 u8 reserved2[8];
321} __packed __aligned(8);
322
323struct ibmvnic_rc {
324 u8 code; /* one of enum ibmvnic_rc_codes */
325 u8 detailed_data[3];
326} __packed __aligned(4);
327
328struct ibmvnic_generic_crq {
329 u8 first;
330 u8 cmd;
331 u8 params[10];
332 struct ibmvnic_rc rc;
333} __packed __aligned(8);
334
335struct ibmvnic_version_exchange {
336 u8 first;
337 u8 cmd;
338 __be16 version;
339#define IBMVNIC_INITIAL_VERSION 1
340 u8 reserved[8];
341 struct ibmvnic_rc rc;
342} __packed __aligned(8);
343
344struct ibmvnic_capability {
345 u8 first;
346 u8 cmd;
347 __be16 capability; /* one of ibmvnic_capabilities */
Thomas Falconde89e852016-03-01 10:20:09 -0600348 __be64 number;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600349 struct ibmvnic_rc rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600350} __packed __aligned(8);
351
352struct ibmvnic_login {
353 u8 first;
354 u8 cmd;
355 u8 reserved[6];
356 __be32 ioba;
357 __be32 len;
358} __packed __aligned(8);
359
360struct ibmvnic_phys_parms {
361 u8 first;
362 u8 cmd;
363 u8 flags1;
364#define IBMVNIC_EXTERNAL_LOOPBACK 0x80
365#define IBMVNIC_INTERNAL_LOOPBACK 0x40
366#define IBMVNIC_PROMISC 0x20
367#define IBMVNIC_PHYS_LINK_ACTIVE 0x10
368#define IBMVNIC_AUTONEG_DUPLEX 0x08
369#define IBMVNIC_FULL_DUPLEX 0x04
370#define IBMVNIC_HALF_DUPLEX 0x02
371#define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
372 u8 flags2;
373#define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
374 __be32 speed;
375#define IBMVNIC_AUTONEG 0x80
376#define IBMVNIC_10MBPS 0x40
377#define IBMVNIC_100MBPS 0x20
378#define IBMVNIC_1GBPS 0x10
379#define IBMVNIC_10GBPS 0x08
380 __be32 mtu;
381 struct ibmvnic_rc rc;
382} __packed __aligned(8);
383
384struct ibmvnic_logical_link_state {
385 u8 first;
386 u8 cmd;
387 u8 link_state;
388#define IBMVNIC_LOGICAL_LNK_DN 0x00
389#define IBMVNIC_LOGICAL_LNK_UP 0x01
390#define IBMVNIC_LOGICAL_LNK_QUERY 0xff
391 u8 reserved[9];
392 struct ibmvnic_rc rc;
393} __packed __aligned(8);
394
395struct ibmvnic_query_ip_offload {
396 u8 first;
397 u8 cmd;
398 u8 reserved[2];
399 __be32 len;
400 __be32 ioba;
401 struct ibmvnic_rc rc;
402} __packed __aligned(8);
403
404struct ibmvnic_control_ip_offload {
405 u8 first;
406 u8 cmd;
407 u8 reserved[2];
408 __be32 ioba;
409 __be32 len;
410 struct ibmvnic_rc rc;
411} __packed __aligned(8);
412
413struct ibmvnic_request_dump_size {
414 u8 first;
415 u8 cmd;
416 u8 reserved[6];
417 __be32 len;
418 struct ibmvnic_rc rc;
419} __packed __aligned(8);
420
421struct ibmvnic_request_dump {
422 u8 first;
423 u8 cmd;
424 u8 reserved1[2];
425 __be32 ioba;
426 __be32 len;
427 u8 reserved2[4];
428} __packed __aligned(8);
429
430struct ibmvnic_request_dump_rsp {
431 u8 first;
432 u8 cmd;
433 u8 reserved[6];
434 __be32 dumped_len;
435 struct ibmvnic_rc rc;
436} __packed __aligned(8);
437
438struct ibmvnic_request_ras_comp_num {
439 u8 first;
440 u8 cmd;
441 u8 reserved1[2];
442 __be32 num_components;
443 u8 reserved2[4];
444 struct ibmvnic_rc rc;
445} __packed __aligned(8);
446
447struct ibmvnic_request_ras_comps {
448 u8 first;
449 u8 cmd;
450 u8 reserved[2];
451 __be32 ioba;
452 __be32 len;
453 struct ibmvnic_rc rc;
454} __packed __aligned(8);
455
456struct ibmvnic_control_ras {
457 u8 first;
458 u8 cmd;
459 u8 correlator;
460 u8 level;
461 u8 op;
462#define IBMVNIC_TRACE_LEVEL 1
463#define IBMVNIC_ERROR_LEVEL 2
464#define IBMVNIC_TRACE_PAUSE 3
465#define IBMVNIC_TRACE_RESUME 4
466#define IBMVNIC_TRACE_ON 5
467#define IBMVNIC_TRACE_OFF 6
468#define IBMVNIC_CHG_TRACE_BUFF_SZ 7
469 u8 trace_buff_sz[3];
470 u8 reserved[4];
471 struct ibmvnic_rc rc;
472} __packed __aligned(8);
473
474struct ibmvnic_collect_fw_trace {
475 u8 first;
476 u8 cmd;
477 u8 correlator;
478 u8 reserved;
479 __be32 ioba;
480 __be32 len;
481 struct ibmvnic_rc rc;
482} __packed __aligned(8);
483
484struct ibmvnic_request_statistics {
485 u8 first;
486 u8 cmd;
487 u8 flags;
488#define IBMVNIC_PHYSICAL_PORT 0x80
489 u8 reserved1;
490 __be32 ioba;
491 __be32 len;
492 u8 reserved[4];
493} __packed __aligned(8);
494
495struct ibmvnic_request_debug_stats {
496 u8 first;
497 u8 cmd;
498 u8 reserved[2];
499 __be32 ioba;
500 __be32 len;
501 struct ibmvnic_rc rc;
502} __packed __aligned(8);
503
504struct ibmvnic_error_indication {
505 u8 first;
506 u8 cmd;
507 u8 flags;
508#define IBMVNIC_FATAL_ERROR 0x80
509 u8 reserved1;
510 __be32 error_id;
511 __be32 detail_error_sz;
512 __be16 error_cause;
513 u8 reserved2[2];
514} __packed __aligned(8);
515
Thomas Falcon032c5e82015-12-21 11:26:06 -0600516struct ibmvnic_link_state_indication {
517 u8 first;
518 u8 cmd;
519 u8 reserved1[2];
520 u8 phys_link_state;
521 u8 logical_link_state;
522 u8 reserved2[10];
523} __packed __aligned(8);
524
525struct ibmvnic_change_mac_addr {
526 u8 first;
527 u8 cmd;
528 u8 mac_addr[6];
Thomas Falcon032c5e82015-12-21 11:26:06 -0600529 u8 reserved[4];
Murilo Fossa Vicentini993a82b2017-04-19 13:44:35 -0400530 struct ibmvnic_rc rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600531} __packed __aligned(8);
532
533struct ibmvnic_multicast_ctrl {
534 u8 first;
535 u8 cmd;
536 u8 mac_addr[6];
537 u8 flags;
538#define IBMVNIC_ENABLE_MC 0x80
539#define IBMVNIC_DISABLE_MC 0x40
540#define IBMVNIC_ENABLE_ALL 0x20
541#define IBMVNIC_DISABLE_ALL 0x10
542 u8 reserved1;
543 __be16 reserved2; /* was num_enabled_mc_addr; */
544 struct ibmvnic_rc rc;
545} __packed __aligned(8);
546
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200547struct ibmvnic_get_vpd_size {
548 u8 first;
549 u8 cmd;
550 u8 reserved[14];
551} __packed __aligned(8);
552
Thomas Falcon032c5e82015-12-21 11:26:06 -0600553struct ibmvnic_get_vpd_size_rsp {
554 u8 first;
555 u8 cmd;
556 u8 reserved[2];
557 __be64 len;
558 struct ibmvnic_rc rc;
559} __packed __aligned(8);
560
561struct ibmvnic_get_vpd {
562 u8 first;
563 u8 cmd;
564 u8 reserved1[2];
565 __be32 ioba;
566 __be32 len;
567 u8 reserved[4];
568} __packed __aligned(8);
569
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200570struct ibmvnic_get_vpd_rsp {
571 u8 first;
572 u8 cmd;
573 u8 reserved[10];
574 struct ibmvnic_rc rc;
575} __packed __aligned(8);
576
Thomas Falcon032c5e82015-12-21 11:26:06 -0600577struct ibmvnic_acl_change_indication {
578 u8 first;
579 u8 cmd;
580 __be16 change_type;
581#define IBMVNIC_MAC_ACL 0
582#define IBMVNIC_VLAN_ACL 1
583 u8 reserved[12];
584} __packed __aligned(8);
585
586struct ibmvnic_acl_query {
587 u8 first;
588 u8 cmd;
589 u8 reserved1[2];
590 __be32 ioba;
591 __be32 len;
592 u8 reserved2[4];
593} __packed __aligned(8);
594
595struct ibmvnic_tune {
596 u8 first;
597 u8 cmd;
598 u8 reserved1[2];
599 __be32 ioba;
600 __be32 len;
601 u8 reserved2[4];
602} __packed __aligned(8);
603
604struct ibmvnic_request_map {
605 u8 first;
606 u8 cmd;
607 u8 reserved1;
608 u8 map_id;
609 __be32 ioba;
610 __be32 len;
611 u8 reserved2[4];
612} __packed __aligned(8);
613
614struct ibmvnic_request_map_rsp {
615 u8 first;
616 u8 cmd;
617 u8 reserved1;
618 u8 map_id;
Thomas Falcon288ccb72017-06-21 14:53:00 -0500619 u8 reserved2[8];
Thomas Falcon032c5e82015-12-21 11:26:06 -0600620 struct ibmvnic_rc rc;
621} __packed __aligned(8);
622
623struct ibmvnic_request_unmap {
624 u8 first;
625 u8 cmd;
626 u8 reserved1;
627 u8 map_id;
628 u8 reserved2[12];
629} __packed __aligned(8);
630
631struct ibmvnic_request_unmap_rsp {
632 u8 first;
633 u8 cmd;
634 u8 reserved1;
635 u8 map_id;
636 u8 reserved2[8];
637 struct ibmvnic_rc rc;
638} __packed __aligned(8);
639
640struct ibmvnic_query_map {
641 u8 first;
642 u8 cmd;
643 u8 reserved[14];
644} __packed __aligned(8);
645
646struct ibmvnic_query_map_rsp {
647 u8 first;
648 u8 cmd;
649 u8 reserved;
650 u8 page_size;
651 __be32 tot_pages;
652 __be32 free_pages;
653 struct ibmvnic_rc rc;
654} __packed __aligned(8);
655
656union ibmvnic_crq {
657 struct ibmvnic_generic_crq generic;
658 struct ibmvnic_version_exchange version_exchange;
659 struct ibmvnic_version_exchange version_exchange_rsp;
660 struct ibmvnic_capability query_capability;
661 struct ibmvnic_capability query_capability_rsp;
662 struct ibmvnic_capability request_capability;
663 struct ibmvnic_capability request_capability_rsp;
664 struct ibmvnic_login login;
665 struct ibmvnic_generic_crq login_rsp;
666 struct ibmvnic_phys_parms query_phys_parms;
667 struct ibmvnic_phys_parms query_phys_parms_rsp;
668 struct ibmvnic_phys_parms query_phys_capabilities;
669 struct ibmvnic_phys_parms query_phys_capabilities_rsp;
670 struct ibmvnic_phys_parms set_phys_parms;
671 struct ibmvnic_phys_parms set_phys_parms_rsp;
672 struct ibmvnic_logical_link_state logical_link_state;
673 struct ibmvnic_logical_link_state logical_link_state_rsp;
674 struct ibmvnic_query_ip_offload query_ip_offload;
675 struct ibmvnic_query_ip_offload query_ip_offload_rsp;
676 struct ibmvnic_control_ip_offload control_ip_offload;
677 struct ibmvnic_control_ip_offload control_ip_offload_rsp;
678 struct ibmvnic_request_dump_size request_dump_size;
679 struct ibmvnic_request_dump_size request_dump_size_rsp;
680 struct ibmvnic_request_dump request_dump;
681 struct ibmvnic_request_dump_rsp request_dump_rsp;
682 struct ibmvnic_request_ras_comp_num request_ras_comp_num;
683 struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
684 struct ibmvnic_request_ras_comps request_ras_comps;
685 struct ibmvnic_request_ras_comps request_ras_comps_rsp;
686 struct ibmvnic_control_ras control_ras;
687 struct ibmvnic_control_ras control_ras_rsp;
688 struct ibmvnic_collect_fw_trace collect_fw_trace;
689 struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
690 struct ibmvnic_request_statistics request_statistics;
691 struct ibmvnic_generic_crq request_statistics_rsp;
692 struct ibmvnic_request_debug_stats request_debug_stats;
693 struct ibmvnic_request_debug_stats request_debug_stats_rsp;
694 struct ibmvnic_error_indication error_indication;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600695 struct ibmvnic_link_state_indication link_state_indication;
696 struct ibmvnic_change_mac_addr change_mac_addr;
697 struct ibmvnic_change_mac_addr change_mac_addr_rsp;
698 struct ibmvnic_multicast_ctrl multicast_ctrl;
699 struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200700 struct ibmvnic_get_vpd_size get_vpd_size;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600701 struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
702 struct ibmvnic_get_vpd get_vpd;
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200703 struct ibmvnic_get_vpd_rsp get_vpd_rsp;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600704 struct ibmvnic_acl_change_indication acl_change_indication;
705 struct ibmvnic_acl_query acl_query;
706 struct ibmvnic_generic_crq acl_query_rsp;
707 struct ibmvnic_tune tune;
708 struct ibmvnic_generic_crq tune_rsp;
709 struct ibmvnic_request_map request_map;
710 struct ibmvnic_request_map_rsp request_map_rsp;
711 struct ibmvnic_request_unmap request_unmap;
712 struct ibmvnic_request_unmap_rsp request_unmap_rsp;
713 struct ibmvnic_query_map query_map;
714 struct ibmvnic_query_map_rsp query_map_rsp;
715};
716
717enum ibmvnic_rc_codes {
718 SUCCESS = 0,
719 PARTIALSUCCESS = 1,
720 PERMISSION = 2,
721 NOMEMORY = 3,
722 PARAMETER = 4,
723 UNKNOWNCOMMAND = 5,
724 ABORTED = 6,
725 INVALIDSTATE = 7,
726 INVALIDIOBA = 8,
727 INVALIDLENGTH = 9,
728 UNSUPPORTEDOPTION = 10,
729};
730
731enum ibmvnic_capabilities {
732 MIN_TX_QUEUES = 1,
733 MIN_RX_QUEUES = 2,
734 MIN_RX_ADD_QUEUES = 3,
735 MAX_TX_QUEUES = 4,
736 MAX_RX_QUEUES = 5,
737 MAX_RX_ADD_QUEUES = 6,
738 REQ_TX_QUEUES = 7,
739 REQ_RX_QUEUES = 8,
740 REQ_RX_ADD_QUEUES = 9,
741 MIN_TX_ENTRIES_PER_SUBCRQ = 10,
742 MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
743 MAX_TX_ENTRIES_PER_SUBCRQ = 12,
744 MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
745 REQ_TX_ENTRIES_PER_SUBCRQ = 14,
746 REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
747 TCP_IP_OFFLOAD = 16,
748 PROMISC_REQUESTED = 17,
749 PROMISC_SUPPORTED = 18,
750 MIN_MTU = 19,
751 MAX_MTU = 20,
752 REQ_MTU = 21,
753 MAX_MULTICAST_FILTERS = 22,
754 VLAN_HEADER_INSERTION = 23,
Murilo Fossa Vicentini6052d5e2017-04-21 15:38:46 -0400755 RX_VLAN_HEADER_INSERTION = 24,
Thomas Falcon032c5e82015-12-21 11:26:06 -0600756 MAX_TX_SG_ENTRIES = 25,
757 RX_SG_SUPPORTED = 26,
758 RX_SG_REQUESTED = 27,
759 OPT_TX_COMP_SUB_QUEUES = 28,
760 OPT_RX_COMP_QUEUES = 29,
761 OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
762 OPT_TX_ENTRIES_PER_SUBCRQ = 31,
763 OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
764 TX_RX_DESC_REQ = 33,
765};
766
767enum ibmvnic_error_cause {
768 ADAPTER_PROBLEM = 0,
769 BUS_PROBLEM = 1,
770 FW_PROBLEM = 2,
771 DD_PROBLEM = 3,
772 EEH_RECOVERY = 4,
773 FW_UPDATED = 5,
774 LOW_MEMORY = 6,
775};
776
777enum ibmvnic_commands {
778 VERSION_EXCHANGE = 0x01,
779 VERSION_EXCHANGE_RSP = 0x81,
780 QUERY_CAPABILITY = 0x02,
781 QUERY_CAPABILITY_RSP = 0x82,
782 REQUEST_CAPABILITY = 0x03,
783 REQUEST_CAPABILITY_RSP = 0x83,
784 LOGIN = 0x04,
785 LOGIN_RSP = 0x84,
786 QUERY_PHYS_PARMS = 0x05,
787 QUERY_PHYS_PARMS_RSP = 0x85,
788 QUERY_PHYS_CAPABILITIES = 0x06,
789 QUERY_PHYS_CAPABILITIES_RSP = 0x86,
790 SET_PHYS_PARMS = 0x07,
791 SET_PHYS_PARMS_RSP = 0x87,
792 ERROR_INDICATION = 0x08,
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;
Thomas Falcon51536982018-05-23 13:37:56 -0500847 bool active;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600848};
849
850union sub_crq {
851 struct ibmvnic_generic_scrq generic;
852 struct ibmvnic_tx_comp_desc tx_comp;
853 struct ibmvnic_tx_desc v1;
854 struct ibmvnic_hdr_desc hdr;
855 struct ibmvnic_hdr_ext_desc hdr_ext;
856 struct ibmvnic_sge_desc sge;
857 struct ibmvnic_rx_comp_desc rx_comp;
858 struct ibmvnic_rx_buff_add_desc rx_add;
859};
860
861struct ibmvnic_sub_crq_queue {
862 union sub_crq *msgs;
863 int size, cur;
864 dma_addr_t msg_token;
865 unsigned long crq_num;
866 unsigned long hw_irq;
867 unsigned int irq;
868 unsigned int pool_index;
869 int scrq_num;
870 spinlock_t lock;
871 struct sk_buff *rx_skb_top;
872 struct ibmvnic_adapter *adapter;
Thomas Falcon142c0ac2017-03-05 12:18:41 -0600873 atomic_t used;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600874};
875
876struct ibmvnic_long_term_buff {
877 unsigned char *buff;
878 dma_addr_t addr;
879 u64 size;
880 u8 map_id;
881};
882
883struct ibmvnic_tx_buff {
884 struct sk_buff *skb;
885 dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
886 unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
887 int index;
888 int pool_index;
889 bool last_frag;
Thomas Falconad7775d2016-04-01 17:20:34 -0500890 union sub_crq indir_arr[6];
891 u8 hdr_data[140];
892 dma_addr_t indir_dma;
Thomas Falconffc385b2018-02-18 10:08:41 -0600893 int num_entries;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600894};
895
896struct ibmvnic_tx_pool {
897 struct ibmvnic_tx_buff *tx_buff;
898 int *free_map;
899 int consumer_index;
900 int producer_index;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600901 struct ibmvnic_long_term_buff long_term_buff;
Thomas Falcon4bd95a52018-03-16 20:00:24 -0500902 int num_buffers;
903 int buf_size;
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
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200927struct ibmvnic_vpd {
928 unsigned char *buff;
929 dma_addr_t dma_addr;
930 u64 len;
931};
932
Nathan Fontenot90c80142017-05-03 14:04:32 -0400933enum vnic_state {VNIC_PROBING = 1,
934 VNIC_PROBED,
935 VNIC_OPENING,
936 VNIC_OPEN,
937 VNIC_CLOSING,
938 VNIC_CLOSED,
939 VNIC_REMOVING,
940 VNIC_REMOVED};
941
Nathan Fontenoted651a12017-05-03 14:04:38 -0400942enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
943 VNIC_RESET_MOBILITY,
944 VNIC_RESET_FATAL,
John Allen8cb31cf2017-05-26 10:30:37 -0400945 VNIC_RESET_NON_FATAL,
John Allenc26eba02017-10-26 16:23:25 -0500946 VNIC_RESET_TIMEOUT,
947 VNIC_RESET_CHANGE_PARAM};
Nathan Fontenoted651a12017-05-03 14:04:38 -0400948
949struct ibmvnic_rwi {
950 enum ibmvnic_reset_reason reset_reason;
951 struct list_head list;
952};
953
John Allenc26eba02017-10-26 16:23:25 -0500954struct ibmvnic_tunables {
955 u64 rx_queues;
956 u64 tx_queues;
957 u64 rx_entries;
958 u64 tx_entries;
959 u64 mtu;
960 struct sockaddr mac;
961};
962
Thomas Falcon032c5e82015-12-21 11:26:06 -0600963struct ibmvnic_adapter {
964 struct vio_dev *vdev;
965 struct net_device *netdev;
966 struct ibmvnic_crq_queue crq;
967 u8 mac_addr[ETH_ALEN];
968 struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
969 dma_addr_t ip_offload_tok;
970 struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
971 dma_addr_t ip_offload_ctrl_tok;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600972 u32 msg_enable;
Thomas Falcon032c5e82015-12-21 11:26:06 -0600973
Desnes Augusto Nunes do Rosario4e6759b2017-11-13 15:59:19 -0200974 /* Vital Product Data (VPD) */
975 struct ibmvnic_vpd *vpd;
976 char fw_version[32];
977
Thomas Falcon032c5e82015-12-21 11:26:06 -0600978 /* Statistics */
Thomas Falcon032c5e82015-12-21 11:26:06 -0600979 struct ibmvnic_statistics stats;
980 dma_addr_t stats_token;
981 struct completion stats_done;
982 spinlock_t stats_lock;
983 int replenish_no_mem;
984 int replenish_add_buff_success;
985 int replenish_add_buff_failure;
986 int replenish_task_cycles;
987 int tx_send_failed;
988 int tx_map_failed;
989
John Allen3d52b592017-08-02 16:44:14 -0500990 struct ibmvnic_tx_queue_stats *tx_stats_buffers;
991 struct ibmvnic_rx_queue_stats *rx_stats_buffers;
992
Thomas Falcon032c5e82015-12-21 11:26:06 -0600993 int phys_link_state;
994 int logical_link_state;
995
996 /* login data */
997 struct ibmvnic_login_buffer *login_buf;
998 dma_addr_t login_buf_token;
999 int login_buf_sz;
1000
1001 struct ibmvnic_login_rsp_buffer *login_rsp_buf;
1002 dma_addr_t login_rsp_buf_token;
1003 int login_rsp_buf_sz;
1004
Thomas Falcon901e0402017-02-15 12:17:59 -06001005 atomic_t running_cap_crqs;
Thomas Falcon249168a2017-02-15 12:18:00 -06001006 bool wait_capability;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001007
1008 struct ibmvnic_sub_crq_queue **tx_scrq;
1009 struct ibmvnic_sub_crq_queue **rx_scrq;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001010
1011 /* rx structs */
1012 struct napi_struct *napi;
1013 struct ibmvnic_rx_pool *rx_pool;
1014 u64 promisc;
1015
1016 struct ibmvnic_tx_pool *tx_pool;
Thomas Falcon4bd95a52018-03-16 20:00:24 -05001017 struct ibmvnic_tx_pool *tso_pool;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001018 struct completion init_done;
Nathan Fontenot53da09e2017-04-21 15:39:04 -04001019 int init_done_rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001020
Thomas Falcon032c5e82015-12-21 11:26:06 -06001021 struct completion fw_done;
Thomas Falconf3be0cb2017-06-21 14:53:01 -05001022 int fw_done_rc;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001023
John Allenc26eba02017-10-26 16:23:25 -05001024 struct completion reset_done;
1025 int reset_done_rc;
1026 bool wait_for_reset;
1027
Thomas Falcon032c5e82015-12-21 11:26:06 -06001028 /* partner capabilities */
1029 u64 min_tx_queues;
1030 u64 min_rx_queues;
1031 u64 min_rx_add_queues;
1032 u64 max_tx_queues;
1033 u64 max_rx_queues;
1034 u64 max_rx_add_queues;
1035 u64 req_tx_queues;
1036 u64 req_rx_queues;
1037 u64 req_rx_add_queues;
1038 u64 min_tx_entries_per_subcrq;
1039 u64 min_rx_add_entries_per_subcrq;
1040 u64 max_tx_entries_per_subcrq;
1041 u64 max_rx_add_entries_per_subcrq;
1042 u64 req_tx_entries_per_subcrq;
1043 u64 req_rx_add_entries_per_subcrq;
1044 u64 tcp_ip_offload;
1045 u64 promisc_requested;
1046 u64 promisc_supported;
1047 u64 min_mtu;
1048 u64 max_mtu;
1049 u64 req_mtu;
1050 u64 max_multicast_filters;
1051 u64 vlan_header_insertion;
Murilo Fossa Vicentini6052d5e2017-04-21 15:38:46 -04001052 u64 rx_vlan_header_insertion;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001053 u64 max_tx_sg_entries;
1054 u64 rx_sg_supported;
1055 u64 rx_sg_requested;
1056 u64 opt_tx_comp_sub_queues;
1057 u64 opt_rx_comp_queues;
1058 u64 opt_rx_bufadd_q_per_rx_comp_q;
1059 u64 opt_tx_entries_per_subcrq;
1060 u64 opt_rxba_entries_per_subcrq;
1061 __be64 tx_rx_desc_req;
1062 u8 map_id;
Nathan Fontenot82e3be32018-02-21 21:33:56 -06001063 u32 num_active_rx_scrqs;
1064 u32 num_active_rx_pools;
1065 u32 num_active_rx_napi;
1066 u32 num_active_tx_scrqs;
1067 u32 num_active_tx_pools;
Thomas Falcon65dc6892016-07-06 15:35:18 -05001068
Thomas Falcon6c267b32017-02-15 12:17:58 -06001069 struct tasklet_struct tasklet;
Nathan Fontenot90c80142017-05-03 14:04:32 -04001070 enum vnic_state state;
Nathan Fontenoted651a12017-05-03 14:04:38 -04001071 enum ibmvnic_reset_reason reset_reason;
1072 struct mutex reset_lock, rwi_lock;
1073 struct list_head rwi_list;
1074 struct work_struct ibmvnic_reset;
1075 bool resetting;
John Allen017892c12017-05-26 10:30:19 -04001076 bool napi_enabled, from_passive_init;
John Allenc26eba02017-10-26 16:23:25 -05001077
1078 bool mac_change_pending;
Thomas Falcon5a18e1e2018-04-06 18:37:05 -05001079 bool failover_pending;
Thomas Falcon2770a792018-05-23 13:38:02 -05001080 bool force_reset_recovery;
John Allenc26eba02017-10-26 16:23:25 -05001081
1082 struct ibmvnic_tunables desired;
1083 struct ibmvnic_tunables fallback;
Thomas Falcon032c5e82015-12-21 11:26:06 -06001084};