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