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