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