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