1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009-2012 Emulex. All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 
  28 
  29 /*
  30  * Header file containing the command structures for Hardware
  31  */
  32 
  33 #ifndef _OCE_HW_H_
  34 #define _OCE_HW_H_
  35 
  36 #ifdef __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 #include <sys/types.h>
  41 #include "oce_sli4.h"
  42 
  43 #pragma pack(1)
  44 
  45 #define OC_CNA_GEN2                     0x2
  46 #define OC_CNA_GEN3                     0x3
  47 enum {
  48         ASIC_REV_A0 = 0x0,
  49         ASIC_REV_A1 = 0x1,
  50         ASIC_REV_A2 = 0x2
  51 };
  52 #define BE3_ASIC_REV_A0 ((OC_CNA_GEN3<<8)| ASIC_REV_A0)
  53 #define BE3_ASIC_REV_A1 ((OC_CNA_GEN3<<8)| ASIC_REV_A1)
  54 #define BE3_ASIC_REV_A2 ((OC_CNA_GEN3<<8)| ASIC_REV_A2)
  55 
  56 #define BE3_A1(dev)     (dev->asic_revision == BE3_ASIC_REV_A0 ||\
  57     dev->asic_revision == BE3_ASIC_REV_A1)
  58 
  59 #define DEVID_TIGERSHARK                0x700
  60 #define DEVID_TOMCAT                    0x710
  61 #define DEVID_LANCER                    0xe220
  62 
  63 #define LANCER_CHIP(device)             (device->device_id == DEVID_LANCER)
  64 
  65 
  66 /* PCI CSR offsets */
  67 #define PCICFG_F1_CSR           0x0 /* F1 for NIC */
  68 #define PCICFG_SEMAPHORE        0xbc
  69 #define PCICFG_SOFT_RESET       0x5c
  70 #define PCICFG_UE_STATUS_LO     0xA0    /* UE status low offset  */
  71 #define PCICFG_UE_STATUS_HI     0xA4    /* UE status high offset */
  72 #define PCICFG_UE_STATUS_LO_MASK        0xa8 /* Error mask - low */
  73 #define PCICFG_UE_STATUS_HI_MASK        0xac /* Error mask - high */
  74 #define PCICFG_ONLINE0          0xb0
  75 #define PCICFG_ONLINE1          0xb4
  76 #define INTR_EN                         0x20000000
  77 #define IMAGE_TRANSFER_SIZE             (32 * 1024) /* 32K at a time */
  78 
  79 /* CSR register offsets */
  80 #define MPU_EP_CONTROL                  0
  81 #define MPU_EP_SEMAPHORE                0xac
  82 #define PCICFG_INTR_CTRL                0xfc
  83 #define HOSTINTR_MASK                   (1 << 29)
  84 #define HOSTINTR_PFUNC_SHIFT            26
  85 #define HOSTINTR_PFUNC_MASK             7
  86 
  87 /*  Link Status CSR */
  88 #define PCICFG_PCIE_LINK_STATUS_OFFSET                  0xd0
  89 #define PCIE_LINK_STATUS_SPEED_MASK                             0xFF
  90 #define PCIE_LINK_STATUS_SPEED_SHIFT                    16
  91 #define PCIE_LINK_STATUS_NEG_WIDTH_MASK                 0x3F
  92 #define PCIE_LINK_STATUS_NEG_WIDTH_SHIFT                20
  93 
  94 /*  Link Capability CSR */
  95 #define PCICFG_PCIE_LINK_CAP_OFFSET                             0xcc
  96 #define PCIE_LINK_CAP_MAX_SPEED_MASK                    0xFF
  97 #define PCIE_LINK_CAP_MAX_SPEED_SHIFT                   0
  98 #define PCIE_LINK_CAP_MAX_WIDTH_MASK                    0x3F
  99 #define PCIE_LINK_CAP_MAX_WIDTH_SHIFT                   4
 100 
 101 /* POST status reg struct */
 102 #define POST_STAGE_POWER_ON_RESET       0x00
 103 #define POST_STAGE_AWAITING_HOST_RDY    0x01
 104 #define POST_STAGE_HOST_RDY             0x02
 105 #define POST_STAGE_CHIP_RESET           0x03
 106 #define POST_STAGE_ARMFW_READY          0xc000
 107 #define POST_STAGE_ARMFW_UE             0xf000
 108 
 109 /* DOORBELL registers */
 110 #define PD_RXULP_DB                     0x0100
 111 #define PD_TXULP_DB                     0x0060
 112 #define DB_RQ_ID_MASK                   0x3FF
 113 
 114 #define PD_CQ_DB                        0x0120
 115 #define PD_EQ_DB                        PD_CQ_DB
 116 #define PD_MPU_MBOX_DB                  0x0160
 117 #define PD_MQ_DB                        0x0140
 118 
 119 /* EQE completion types */
 120 #define EQ_MINOR_CODE_COMPLETION        0x00
 121 #define EQ_MINOR_CODE_OTHER             0x01
 122 #define EQ_MAJOR_CODE_COMPLETION        0x00
 123 
 124 /* Link Status field values */
 125 #define PHY_LINK_FAULT_NONE             0x0
 126 #define PHY_LINK_FAULT_LOCAL            0x01
 127 #define PHY_LINK_FAULT_REMOTE           0x02
 128 
 129 #define PHY_LINK_SPEED_ZERO             0x0 /* No link */
 130 #define PHY_LINK_SPEED_10MBPS           0x1 /* (10 Mbps) */
 131 #define PHY_LINK_SPEED_100MBPS          0x2 /* (100 Mbps) */
 132 #define PHY_LINK_SPEED_1GBPS            0x3 /* (1 Gbps) */
 133 #define PHY_LINK_SPEED_10GBPS           0x4 /* (10 Gbps) */
 134 
 135 #define PHY_LINK_DUPLEX_NONE            0x0
 136 #define PHY_LINK_DUPLEX_HALF            0x1
 137 #define PHY_LINK_DUPLEX_FULL            0x2
 138 
 139 #define NTWK_PORT_A                     0x0 /* (Port A) */
 140 #define NTWK_PORT_B                     0x1 /* (Port B) */
 141 
 142 #define PHY_LINK_SPEED_ZERO                     0x0 /* (No link.) */
 143 #define PHY_LINK_SPEED_10MBPS           0x1 /* (10 Mbps) */
 144 #define PHY_LINK_SPEED_100MBPS          0x2 /* (100 Mbps) */
 145 #define PHY_LINK_SPEED_1GBPS            0x3 /* (1 Gbps) */
 146 #define PHY_LINK_SPEED_10GBPS           0x4 /* (10 Gbps) */
 147 
 148 /* Hardware Address types */
 149 #define MAC_ADDRESS_TYPE_STORAGE        0x0 /* (Storage MAC Address) */
 150 #define MAC_ADDRESS_TYPE_NETWORK        0x1 /* (Network MAC Address) */
 151 #define MAC_ADDRESS_TYPE_PD             0x2 /* (Protection Domain MAC Addr) */
 152 #define MAC_ADDRESS_TYPE_MANAGEMENT     0x3 /* (Management MAC Address) */
 153 #define MAC_ADDRESS_TYPE_FCOE           0x4 /* (FCoE MAC Address) */
 154 
 155 /* CREATE_IFACE capability and cap_en flags */
 156 #define MBX_RX_IFACE_FLAGS_RSS          0x4
 157 #define MBX_RX_IFACE_FLAGS_PROMISCUOUS  0x8
 158 #define MBX_RX_IFACE_FLAGS_BROADCAST    0x10
 159 #define MBX_RX_IFACE_FLAGS_UNTAGGED     0x20
 160 #define MBX_RX_IFACE_FLAGS_ULP          0x40
 161 #define MBX_RX_IFACE_FLAGS_VLAN_PROMISCUOUS     0x80
 162 #define MBX_RX_IFACE_FLAGS_VLAN                 0x100
 163 #define MBX_RX_IFACE_FLAGS_MCAST_PROMISCUOUS    0x200
 164 #define MBX_RX_IFACE_FLAGS_PASS_L2      0x400
 165 #define MBX_RX_IFACE_FLAGS_PASS_L3L4    0x800
 166 #define MBX_RX_IFACE_FLAGS_MCAST        0x1000
 167 
 168 #define MQ_RING_CONTEXT_SIZE_16         0x5 /* (16 entries) */
 169 #define MQ_RING_CONTEXT_SIZE_32         0x6 /* (32 entries) */
 170 #define MQ_RING_CONTEXT_SIZE_64         0x7 /* (64 entries) */
 171 #define MQ_RING_CONTEXT_SIZE_128        0x8 /* (128 entries) */
 172 
 173 
 174 #define MBX_DB_READY_BIT                0x1
 175 #define MBX_DB_HI_BIT                   0x2
 176 /* Event bit map registered with mq */
 177 enum {
 178         ASYNC_EVENT_CODE_LINK_STATE = 0x1,
 179         ASYNC_EVENT_CODE_FCOE_FIP = 0x2,
 180         ASYNC_EVENT_CODE_DCBX = 0x3,
 181         ASYNC_EVENT_CODE_ISCSI = 0x4,
 182         ASYNC_EVENT_CODE_GRP_5 = 0x5,
 183         ASYNC_EVENT_CODE_DEBUG = 0x6
 184 };
 185 
 186 /* Link events */
 187 enum {
 188         ASYNC_EVENT_LINK_DOWN   = 0x0,
 189         ASYNC_EVENT_LINK_UP     = 0x1,
 190         ASYNC_EVENT_LOGICAL     = 0x02
 191 };
 192 
 193 /* GRP5 Events */
 194 enum {
 195         ASYNC_EVENT_QOS_SPEED   =       0x1,
 196         ASYNC_EVENT_COS_PRIORITY =      0x2,
 197         ASYNC_EVENT_PVID_STATE   =      0x3
 198 };
 199 
 200 /* Event Mask */
 201 #define ASYNC_TRAILER_EVENT_CODE_SHIFT  8
 202 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT  16
 203 #define ASYNC_TRAILER_EVENT_CODE_MASK   0xFF
 204 #define ASYNC_TRAILER_EVENT_TYPE_MASK   0xFF
 205 
 206 /* Logical Link Status */
 207 #define NTWK_LOGICAL_LINK_DOWN          0
 208 #define NTWK_LOGICAL_LINK_UP            1
 209 
 210 /* Rx filter bits */
 211 #define NTWK_RX_FILTER_IP_CKSUM         0x1
 212 #define NTWK_RX_FILTER_TCP_CKSUM        0x2
 213 #define NTWK_RX_FILTER_UDP_CKSUM        0x4
 214 #define NTWK_RX_FILTER_STRIP_CRC        0x8
 215 
 216 /* driver_function_capabilities */
 217 #define DRVFN_CAPAB_SW_TIMESTAMPS       0x2
 218 #define DRVFN_CAPAB_BE3_NATIVE          0x4
 219 
 220 /* Function Capabilities */
 221 #define BE_FUNCTION_CAPS_UNCLASSIFIED_STATS     0x1
 222 #define BE_FUNCTION_CAPS_RSS                    0x2
 223 #define BE_FUNCTION_CAPS_PROMISCUOUS            0x4
 224 #define BE_FUNCTION_CAPS_LEGACY_MODE            0x8
 225 
 226 /* max SGE per mbx */
 227 #define MAX_MBX_SGE                     19
 228 
 229 /* max RSS rings */
 230 #define MAX_RING_PER_GROUP_LEGACY       5
 231 #define MAX_RING_PER_GROUP_NATIVE       16
 232 
 233 /* MCCQ LEN */
 234 #define MCC_Q_LEN 128
 235 #define MCC_CQ_LEN 256
 236 
 237 /* RSS PARAMETERS */
 238 #define MAX_TBL_SIZE            64
 239 #define MAX_HKEY_SIZE           40
 240 
 241 /* ULP */
 242 #define BE_ULP1_NUM                     1
 243 
 244 /* physical address structure to be used in MBX */
 245 struct phys_addr {
 246         /* dw0 */
 247         uint32_t lo;
 248         /* dw1 */
 249         uint32_t hi;
 250 };
 251 
 252 typedef union pcicfg_intr_ctl_u {
 253         uint32_t dw0;
 254         struct {
 255 #ifdef _BIG_ENDIAN
 256                 uint32_t winselect:2;
 257                 uint32_t hostintr:1;
 258                 uint32_t pfnum:3;
 259                 uint32_t vf_cev_int_line_en:1;
 260                 uint32_t winaddr:23;
 261                 uint32_t membarwinen:1;
 262 #else
 263                 uint32_t membarwinen:1;
 264                 uint32_t winaddr:23;
 265                 uint32_t vf_cev_int_line_en:1;
 266                 uint32_t pfnum:3;
 267                 uint32_t hostintr:1;
 268                 uint32_t winselect:2;
 269 #endif
 270         } bits;
 271 }pcicfg_intr_ctl_t;
 272 
 273 typedef union  pcicfg_semaphore_u {
 274         uint32_t dw0;
 275         struct {
 276 #ifdef _BIG_ENDIAN
 277                 uint32_t rsvd:31;
 278                 uint32_t lock:1;
 279 #else
 280                 uint32_t lock:1;
 281                 uint32_t rsvd:31;
 282 #endif
 283         }bits;
 284 }pcicfg_semaphore_t;
 285 
 286 typedef union pcicfg_soft_reset_u {
 287         uint32_t dw0;
 288         struct {
 289 #ifdef _BIG_ENDIAN
 290                 uint32_t nec_ll_rcvdetect:8;
 291                 uint32_t dbg_all_reqs_62_49:14;
 292                 uint32_t scratchpad0:1;
 293                 uint32_t exception_oe:1;
 294                 uint32_t soft_reset:1;
 295                 uint32_t rsvd0:7;
 296 #else
 297                 uint32_t rsvd0:7;
 298                 uint32_t soft_reset:1;
 299                 uint32_t exception_oe:1;
 300                 uint32_t scratchpad0:1;
 301                 uint32_t dbg_all_reqs_62_49:14;
 302                 uint32_t nec_ll_rcvdetect:8;
 303 #endif
 304         }bits;
 305 }pcicfg_soft_reset_t;
 306 
 307 typedef union pcicfg_online1_u {
 308         uint32_t dw0;
 309         struct {
 310 #ifdef _BIG_ENDIAN
 311                 uint32_t host8_online:1;
 312                 uint32_t host7_online:1;
 313                 uint32_t host6_online:1;
 314                 uint32_t host5_online:1;
 315                 uint32_t host4_online:1;
 316                 uint32_t host3_online:1;
 317                 uint32_t host2_online:1;
 318                 uint32_t ipc_online:1;
 319                 uint32_t arm_online:1;
 320                 uint32_t txp_online:1;
 321                 uint32_t xaui_online:1;
 322                 uint32_t rxpp_online:1;
 323                 uint32_t txpb_online:1;
 324                 uint32_t rr_online:1;
 325                 uint32_t pmem_online:1;
 326                 uint32_t pctl1_online:1;
 327                 uint32_t pctl0_online:1;
 328                 uint32_t pcs1online_online:1;
 329                 uint32_t mpu_iram_online:1;
 330                 uint32_t pcs0online_online:1;
 331                 uint32_t mgmt_mac_online:1;
 332                 uint32_t lpcmemhost_online:1;
 333 #else
 334                 uint32_t lpcmemhost_online:1;
 335                 uint32_t mgmt_mac_online:1;
 336                 uint32_t pcs0online_online:1;
 337                 uint32_t mpu_iram_online:1;
 338                 uint32_t pcs1online_online:1;
 339                 uint32_t pctl0_online:1;
 340                 uint32_t pctl1_online:1;
 341                 uint32_t pmem_online:1;
 342                 uint32_t rr_online:1;
 343                 uint32_t txpb_online:1;
 344                 uint32_t rxpp_online:1;
 345                 uint32_t xaui_online:1;
 346                 uint32_t txp_online:1;
 347                 uint32_t arm_online:1;
 348                 uint32_t ipc_online:1;
 349                 uint32_t host2_online:1;
 350                 uint32_t host3_online:1;
 351                 uint32_t host4_online:1;
 352                 uint32_t host5_online:1;
 353                 uint32_t host6_online:1;
 354                 uint32_t host7_online:1;
 355                 uint32_t host8_online:1;
 356 #endif
 357         }bits;
 358 }pcicfg_online1_t;
 359 
 360 typedef union mpu_ep_semaphore_u {
 361         uint32_t dw0;
 362         struct {
 363 #ifdef _BIG_ENDIAN
 364                 uint32_t error:1;
 365                 uint32_t backup_fw:1;
 366                 uint32_t iscsi_no_ip:1;
 367                 uint32_t iscsi_ip_conflict:1;
 368                 uint32_t option_rom_installed:1;
 369                 uint32_t iscsi_drv_loaded:1;
 370                 uint32_t rsvd0:10;
 371                 uint32_t stage:16;
 372 #else
 373                 uint32_t stage:16;
 374                 uint32_t rsvd0:10;
 375                 uint32_t iscsi_drv_loaded:1;
 376                 uint32_t option_rom_installed:1;
 377                 uint32_t iscsi_ip_conflict:1;
 378                 uint32_t iscsi_no_ip:1;
 379                 uint32_t backup_fw:1;
 380                 uint32_t error:1;
 381 #endif
 382         }bits;
 383 }mpu_ep_semaphore_t;
 384 
 385 typedef union mpu_ep_control_u {
 386         uint32_t dw0;
 387         struct {
 388 #ifdef _BIG_ENDIAN
 389                 uint32_t cpu_reset:1;
 390                 uint32_t rsvd1:15;
 391                 uint32_t ep_ram_init_status:1;
 392                 uint32_t rsvd0:12;
 393                 uint32_t m2_rxpbuf:1;
 394                 uint32_t m1_rxpbuf:1;
 395                 uint32_t m0_rxpbuf:1;
 396 #else
 397                 uint32_t m0_rxpbuf:1;
 398                 uint32_t m1_rxpbuf:1;
 399                 uint32_t m2_rxpbuf:1;
 400                 uint32_t rsvd0:12;
 401                 uint32_t ep_ram_init_status:1;
 402                 uint32_t rsvd1:15;
 403                 uint32_t cpu_reset:1;
 404 #endif
 405         }bits;
 406 }mpu_ep_control_t;
 407 
 408 /* RX doorbell */
 409 typedef union pd_rxulp_db_u {
 410         uint32_t dw0;
 411         struct {
 412 #ifdef _BIG_ENDIAN
 413                 uint32_t num_posted:8;
 414                 uint32_t invalidate:1;
 415                 uint32_t rsvd1:13;
 416                 uint32_t qid:10;
 417 #else
 418                 uint32_t qid:10;
 419                 uint32_t rsvd1:13;
 420                 uint32_t invalidate:1;
 421                 uint32_t num_posted:8;
 422 #endif
 423         }bits;
 424 }pd_rxulp_db_t;
 425 
 426 /* TX doorbell */
 427 typedef union pd_txulp_db_u {
 428         uint32_t dw0;
 429         struct {
 430 #ifdef _BIG_ENDIAN
 431                 uint32_t rsvd1:2;
 432                 uint32_t num_posted:14;
 433                 uint32_t rsvd0:6;
 434                 uint32_t qid:10;
 435 #else
 436                 uint32_t qid:10;
 437                 uint32_t rsvd0:6;
 438                 uint32_t num_posted:14;
 439                 uint32_t rsvd1:2;
 440 #endif
 441         }bits;
 442 }pd_txulp_db_t;
 443 
 444 /* CQ doorbell */
 445 typedef union cq_db_u {
 446         uint32_t dw0;
 447         struct {
 448 #ifdef _BIG_ENDIAN
 449                 uint32_t rsvd1:2;
 450                 uint32_t rearm:1;
 451                 uint32_t num_popped:13;
 452                 uint32_t eq_cq_extid:5;
 453                 uint32_t event:1;
 454                 uint32_t qid:10;
 455 #else
 456                 uint32_t qid:10;
 457                 uint32_t event:1;
 458                 uint32_t eq_cq_extid:5;
 459                 uint32_t num_popped:13;
 460                 uint32_t rearm:1;
 461                 uint32_t rsvd1:2;
 462 #endif
 463         }bits;
 464 }cq_db_t;
 465 
 466 /* EQ doorbell */
 467 typedef union eq_db_u {
 468         uint32_t dw0;
 469         struct {
 470 #ifdef _BIG_ENDIAN
 471                 uint32_t rsvd1:2;
 472                 uint32_t rearm:1;
 473                 uint32_t num_popped:13;
 474                 uint32_t eq_cq_extid:5;
 475                 uint32_t event:1;
 476                 uint32_t clrint:1;
 477                 uint32_t qid:9;
 478 #else
 479                 uint32_t qid:9;
 480                 uint32_t clrint:1;
 481                 uint32_t event:1;
 482                 uint32_t eq_cq_extid:5;
 483                 uint32_t num_popped:13;
 484                 uint32_t rearm:1;
 485                 uint32_t rsvd1:2;
 486 #endif
 487         }bits;
 488 }eq_db_t;
 489 
 490 /* bootstrap mbox doorbell */
 491 typedef union pd_mpu_mbox_db_u {
 492         uint32_t dw0;
 493         struct {
 494 #ifdef _BIG_ENDIAN
 495                 uint32_t address:30;
 496                 uint32_t hi:1;
 497                 uint32_t ready:1;
 498 #else
 499                 uint32_t ready:1;
 500                 uint32_t hi:1;
 501                 uint32_t address:30;
 502 #endif
 503         }bits;
 504 }pd_mpu_mbox_db_t;
 505 
 506 
 507 /* MQ ring doorbell */
 508 typedef union pd_mq_db_u {
 509         uint32_t dw0;
 510         struct {
 511 #ifdef _BIG_ENDIAN
 512                 uint32_t rsvd1:2;
 513                 uint32_t num_posted:14;
 514                 uint32_t rsvd0:5;
 515                 uint32_t mq_id:11;
 516 #else
 517                 uint32_t mq_id:11;
 518                 uint32_t rsvd0:5;
 519                 uint32_t num_posted:14;
 520                 uint32_t rsvd1:2;
 521 #endif
 522         }bits;
 523 }pd_mq_db_t;
 524 
 525 /*
 526  * Event Queue Entry
 527  */
 528 struct oce_eqe {
 529         union {
 530                 struct {
 531 #ifdef _BIG_ENDIAN
 532                         uint32_t resource_id:16;
 533                         uint32_t minor_code:12;
 534                         uint32_t major_code:3;
 535                         uint32_t valid:1;
 536 #else
 537                         uint32_t valid:1;
 538                         uint32_t major_code:3;
 539                         uint32_t minor_code:12;
 540                         uint32_t resource_id:16;
 541 #endif
 542                 }s;
 543                 uint32_t dw0;
 544         }u0;
 545 };
 546 
 547 /* MQ scatter gather entry. Array of these make an SGL */
 548 struct oce_mq_sge {
 549         uint32_t pa_lo;
 550         uint32_t pa_hi;
 551         uint32_t length;
 552 };
 553 
 554 /*
 555  * payload can contain an SGL or an embedded array of upto 59 dwords
 556  */
 557 struct oce_mbx_payload {
 558         union {
 559                 union {
 560                         struct oce_mq_sge sgl[MAX_MBX_SGE];
 561                         uint32_t embedded[59];
 562                 }u1;
 563                 uint32_t dw[59];
 564         }u0;
 565 };
 566 
 567 /*
 568  * MQ MBX structure
 569  */
 570 struct oce_mbx {
 571         union {
 572                 struct {
 573 #ifdef _BIG_ENDIAN
 574                         uint32_t special : 8;
 575                         uint32_t rsvd1 : 16;
 576                         uint32_t sge_count : 5;
 577                         uint32_t rsvd0 : 2;
 578                         uint32_t embedded : 1;
 579 #else
 580                         uint32_t embedded:1;
 581                         uint32_t rsvd0:2;
 582                         uint32_t sge_count:5;
 583                         uint32_t rsvd1:16;
 584                         uint32_t special:8;
 585 #endif
 586                 }s;
 587                 uint32_t dw0;
 588         }u0;
 589 
 590         uint32_t payload_length;
 591         uint32_t tag[2];
 592         uint32_t rsvd2[1];
 593         struct oce_mbx_payload payload;
 594 };
 595 
 596 #define MQ_CQE_VALID_MASK       (1 << 31)
 597 #define MQ_CQE_ASYNC_MASK       (1 << 30)
 598 #define MQ_CQE_COMPLETED_MASK   (1 << 28)
 599 #define MQ_CQE_CONSUMED_MASK    (1 << 27)
 600 #define MQ_CQE_VALID(_cqe)      (_cqe->u0.dw[3])
 601 #define MQ_CQE_INVALIDATE(_cqe) (_cqe->u0.dw[3] = 0)
 602 
 603 /* Macros for handling extra bytes in EQ-CQ IDs */
 604 #define DB_CQ_RING_ID_EXT_MASK          0x7C00  /* bits 10-14 */
 605 #define DB_CQ_RING_ID_EXT_MASK_SHIFT    (1)
 606                                                 /*
 607                                                  * qid bits 10-14
 608                                                  * placing at 11-15
 609                                                  */
 610 #define DB_EQ_RING_ID_EXT_MASK          0x3e00  /* bits 9-13 */
 611 #define DB_EQ_RING_ID_EXT_MASK_SHIFT    (2) /* qid bits 9-13 placing at 11-15 */
 612 
 613 /* completion queue entry for MQ */
 614 struct oce_mq_cqe {
 615         union {
 616                 struct {
 617 #ifdef _BIG_ENDIAN
 618                         /* dw0 */
 619                         uint32_t extended_status:16;
 620                         uint32_t completion_status:16;
 621                         /* dw1 dw2 */
 622                         uint32_t mq_tag[2];
 623                         /* dw3 */
 624                         uint32_t valid:1;
 625                         uint32_t async_event:1;
 626                         uint32_t rsvd:1;
 627                         uint32_t completed:1;
 628                         uint32_t consumed:1;
 629                         uint32_t rsvd0:27;
 630 #else
 631                         /* dw0 */
 632                         uint32_t completion_status:16;
 633                         uint32_t extended_status:16;
 634                         /* dw1 dw2 */
 635                         uint32_t mq_tag[2];
 636                         /* dw3 */
 637                         uint32_t rsvd0:27;
 638                         uint32_t consumed:1;
 639                         uint32_t completed:1;
 640                         uint32_t rsvd:1;
 641                         uint32_t async_event:1;
 642                         uint32_t valid:1;
 643 #endif
 644                 }s;
 645                 uint32_t dw[4];
 646         }u0;
 647 };
 648 
 649 struct oce_async_event_trailer {
 650         union {
 651                 struct {
 652 #ifdef _BIG_ENDIAN
 653                         uint32_t valid:1;
 654                         uint32_t async_event:1;
 655                         uint32_t rsvd2:6;
 656                         uint32_t event_type:8;
 657                         uint32_t event_code:8;
 658                         uint32_t rsvd1:8;
 659 #else
 660                         uint32_t rsvd1:8;
 661                         uint32_t event_code:8;
 662                         uint32_t event_type:8;
 663                         uint32_t rsvd2:6;
 664                         uint32_t async_event:1;
 665                         uint32_t valid:1;
 666 #endif
 667                 } bits;
 668                 uint32_t code;
 669         } u0;
 670 };
 671 
 672 
 673 /* Async Debug Event Types */
 674 #define ASYNC_DEBUG_EVENT_TYPE_QNQ      1
 675 
 676 struct async_event_qnq {
 677         uint8_t enabled;
 678         uint8_t rsvd0;
 679         uint16_t vlan_tag;
 680         uint32_t event_tag;
 681         uint32_t rsvd1[1];
 682         struct oce_async_event_trailer trailer;
 683 };
 684 
 685 
 686 struct oce_async_cqe_link_state {
 687         uint8_t phy_port;
 688         uint8_t link_status;
 689         uint8_t duplex;
 690         uint8_t speed;
 691         uint8_t fault;
 692         uint8_t reason;
 693         uint16_t qos_link_speed;
 694         uint32_t event_tag;
 695         struct oce_async_event_trailer trailer;
 696 };
 697 
 698 struct oce_async_event_grp5_qos_link_speed {
 699         uint8_t physical_port;
 700         uint8_t rsvd[5];
 701         uint16_t qos_link_speed;
 702         uint32_t event_tag;
 703         struct oce_async_event_trailer trailer;
 704 };
 705 
 706 
 707 struct oce_async_event_grp5_cos_priority {
 708         uint8_t physical_port;
 709         uint8_t available_priority_bmap;
 710         uint8_t reco_default_priority;
 711         uint8_t valid;
 712         uint8_t rsvd0;
 713         uint32_t event_tag;
 714         struct oce_async_event_trailer trailer;
 715 };
 716 
 717 struct oce_async_event_grp5_pvid_state {
 718         uint8_t enabled;
 719         uint8_t rsvd0;
 720         uint16_t tag;
 721         uint32_t event_tag;
 722         uint32_t rsvd1;
 723         struct oce_async_event_trailer trailer;
 724 };
 725 
 726 struct oce_event_grp_5_priority_class_queue_map {
 727         uint8_t priority0_classq;
 728         uint8_t priority1_classq;
 729         uint8_t priority2_classq;
 730         uint8_t priority3_classq;
 731         uint8_t priority4_classq;
 732         uint8_t priority5_classq;
 733         uint8_t priority6_classq;
 734         uint8_t priority7_classq;
 735         uint32_t        event_tag;
 736         struct oce_async_event_trailer trailer;
 737 };
 738 
 739 
 740 /* MQ mailbox structure */
 741 struct oce_bmbx {
 742         struct oce_mbx mbx;
 743         struct oce_mq_cqe cqe;
 744 };
 745 
 746 /* ---[ MBXs start here ]---------------------------------------------- */
 747 /* MBXs sub system codes */
 748 enum {
 749         MBX_SUBSYSTEM_RSVD = 0,
 750         MBX_SUBSYSTEM_COMMON = 1,
 751         MBX_SUBSYSTEM_COMMON_ISCSI = 2,
 752         MBX_SUBSYSTEM_NIC = 3,
 753         MBX_SUBSYSTEM_TOE = 4,
 754         MBX_SUBSYSTEM_PXE_UNDI = 5,
 755         MBX_SUBSYSTEM_ISCSI_INI = 6,
 756         MBX_SUBSYSTEM_ISCSI_TGT = 7,
 757         MBX_SUBSYSTEM_MILI_PTL = 8,
 758         MBX_SUBSYSTEM_MILI_TMD = 9,
 759         MBX_SUBSYSTEM_RDMA = 10,
 760         MBX_SUBSYSTEM_LOWLEVEL = 11,
 761         MBX_SUBSYSTEM_LRO = 13,
 762         IOCBMBX_SUBSYSTEM_DCBX = 15,
 763         IOCBMBX_SUBSYSTEM_DIAG = 16,
 764         IOCBMBX_SUBSYSTEM_VENDOR = 17
 765 };
 766 
 767 /* common ioctl opcodes */
 768 enum {
 769         OPCODE_QUERY_COMMON_IFACE_MAC = 1,
 770         OPCODE_SET_COMMON_IFACE_MAC = 2,
 771         OPCODE_SET_COMMON_IFACE_MULTICAST = 3,
 772         OPCODE_COMMON_NTWK_VLAN_CONFIG  = 4,
 773         OPCODE_QUERY_COMMON_LINK_STATUS = 5,
 774         OPCODE_READ_COMMON_FLASHROM = 6,
 775         OPCODE_WRITE_COMMON_FLASHROM = 7,
 776         OPCODE_QUERY_COMMON_MAX_MBX_BUFFER_SIZE = 8,
 777         OPCODE_ADD_COMMON_PAGE_TABLES = 9,
 778         OPCODE_REMOVE_COMMON_PAGE_TABLES = 10,
 779         OPCODE_CREATE_COMMON_CQ = 12,
 780         OPCODE_CREATE_COMMON_EQ = 13,
 781         OPCODE_CREATE_COMMON_MQ = 21,
 782         OPCODE_COMMON_JELL_CONFIG = 22,
 783         OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS = 24,
 784         OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS = 25,
 785         OPCODE_COMMON_POST_ZERO_BUFFER = 26,
 786         OPCODE_COMMON_GET_QOS = 27,
 787         OPCODE_COMMON_SET_QOS = 28,
 788         OPCODE_COMMON_TCP_GET_STATISTICS = 29,
 789         OPCODE_READ_COMMON_SEEPROM = 30,
 790         OPCODE_COMMON_TCP_STATE_QUERY = 31,
 791         OPCODE_GET_COMMON_CNTL_ATTRIBUTES = 32,
 792         OPCODE_COMMON_NOP = 33,
 793         OPCODE_COMMON_NTWK_RX_FILTER = 34,
 794         OPCODE_GET_COMMON_FW_VERSION = 35,
 795         OPCODE_SET_COMMON_FLOW_CONTROL = 36,
 796         OPCODE_GET_COMMON_FLOW_CONTROL = 37,
 797         OPCODE_COMMON_SET_TCP_PARAMETERS = 38,
 798         OPCODE_SET_COMMON_FRAME_SIZE = 39,
 799         OPCODE_COMMON_GET_FAT = 40,
 800         OPCODE_MODIFY_COMMON_EQ_DELAY = 41,
 801         OPCODE_COMMON_FIRMWARE_CONFIG = 42,
 802         OPCODE_COMMON_ENABLE_DISABLE_DOMAINS = 43,
 803         OPCODE_COMMON_GET_DOMAIN_CONFIG = 44,
 804         OPCODE_COMMON_GET_PORT_EQUALIZATION = 47,
 805         OPCODE_COMMON_SET_PORT_EQUALIZATION = 48,
 806         OPCODE_COMMON_RED_CONFIG = 49,
 807         OPCODE_CREATE_COMMON_IFACE = 50,
 808         OPCODE_DESTROY_COMMON_IFACE = 51,
 809         OPCODE_COMMON_CEV_MODIFY_MSI_MESSAGES = 52,
 810         OPCODE_DESTROY_COMMON_MQ = 53,
 811         OPCODE_DESTROY_COMMON_CQ = 54,
 812         OPCODE_DESTROY_COMMON_EQ = 55,
 813         OPCODE_COMMON_TCP_UPL_OAD = 56,
 814         OPCODE_SET_COMMON_LINK_SPEED = 57,
 815         OPCODE_QUERY_COMMON_FIRMWARE_CONFIG = 58,
 816         OPCODE_ADD_COMMON_IFACE_MAC = 59,
 817         OPCODE_DEL_COMMON_IFACE_MAC = 60,
 818         OPCODE_COMMON_FUNCTION_RESET = 61,
 819         OPCODE_COMMON_FUNCTION_LINK_CONFIG = 80,
 820         OPCODE_CREATE_COMMON_MQ_EXT = 90,
 821         OPCODE_COMMON_SET_DRIVER_FUNCTION_CAPABILITIES = 103
 822 };
 823 
 824 /* Management status error code in Response header */
 825 enum {
 826         MGMT_STATUS_SUCCESS     = 0, /* The IOCTL completed without errors. */
 827         MGMT_STATUS_FAILED      = 1,    /*      Generic error status */
 828         MGMT_STATUS_ILLEGAL_REQUEST     = 2, /* Invalid IOCTL opcode. */
 829         MGMT_STATUS_ILLEGAL_FIELD       = 3, /* Invalid param in IOCTL pyld */
 830         MGMT_STATUS_INSUFFICIENT_BUFFER = 4, /* Insufficient buf for response */
 831         MGMT_STATUS_UNAUTHORIZED_REQUEST = 5 /* Domain invalid access rights */
 832 };
 833 
 834 /* Additional status error codes */
 835 enum {
 836         MGMT_ADDI_STATUS_NO_STATUS = 0, /* IOCTL completed successfully */
 837     MGMT_ADDI_STATUS_INVALID_SUBSYSTEM = 29, /* Invalid subsystem id */
 838     MGMT_ADDI_STATUS_INVALID_OPCODE = 30, /* Opcode Invalid */
 839     MGMT_ADDI_STATUS_INVALID_DOMAIN = 35, /* Invalid domain id */
 840     MGMT_ADDI_STATUS_INVALID_EXTENDED_TIMEOUT = 64 /* Invalid timeout */
 841 };
 842 
 843 /* common ioctl header */
 844 struct mbx_hdr {
 845         union {
 846                 struct {
 847 #ifdef _BIG_ENDIAN
 848                         uint8_t domain;
 849                         uint8_t port_number;
 850                         uint8_t subsystem;
 851                         uint8_t opcode;
 852                         uint32_t timeout;
 853                         uint32_t request_length;
 854                         uint8_t rsvd0[3];
 855                         uint8_t version;
 856 #else
 857                         uint8_t opcode;
 858                         uint8_t subsystem;
 859                         uint8_t port_number;
 860                         uint8_t domain;
 861                         uint32_t timeout;
 862                         uint32_t request_length;
 863                         uint8_t  version;
 864                         uint8_t  rsvd0[3];
 865 #endif
 866                 }req;
 867 
 868                 struct {
 869                         /* dw 0 */
 870                         uint8_t opcode;
 871                         uint8_t subsystem;
 872                         uint8_t rsvd0;
 873                         uint8_t domain;
 874                         /* dw 1 */
 875                         uint8_t status;
 876                         uint8_t additional_status;
 877                         uint16_t rsvd1;
 878 
 879                         uint32_t rsp_length;
 880                         uint32_t actual_rsp_length;
 881                 }rsp;
 882                 uint32_t dw[4];
 883         }u0;
 884 };
 885 #define OCE_BMBX_RHDR_SZ 20
 886 #define OCE_MBX_RRHDR_SZ sizeof (struct mbx_hdr)
 887 #define OCE_MBX_ADDL_STATUS(_MHDR) \
 888                 (((struct mbx_hdr *)_MHDR)->u0.rsp.additional_status)
 889 #define OCE_MBX_STATUS(_MHDR) (((struct mbx_hdr *)_MHDR)->u0.rsp.status)
 890 
 891 /* [05] OPCODE_QUERY_COMMON_LINK_STATUS */
 892 struct mbx_query_common_link_status {
 893         struct mbx_hdr hdr;
 894         union {
 895                 struct {
 896                         uint32_t rsvd0;
 897                 }req;
 898 
 899                 struct {
 900                         /* dw 0 */
 901                         uint8_t physical_port;
 902                         uint8_t mac_duplex;
 903                         uint8_t mac_speed;
 904                         uint8_t mac_fault;
 905                         /* dw 1 */
 906                         uint8_t mgmt_mac_duplex;
 907                         uint8_t mgmt_mac_speed;
 908                         uint16_t qos_link_speed;
 909                         uint32_t logical_link_status;
 910                 }rsp;
 911         }params;
 912 };
 913 
 914 /* [57] OPCODE_SET_COMMON_LINK_SPEED */
 915 struct mbx_set_common_link_speed {
 916         struct mbx_hdr hdr;
 917         union {
 918                 struct {
 919 #ifdef _BIG_ENDIAN
 920                         uint8_t rsvd0;
 921                         uint8_t mac_speed;
 922                         uint8_t virtual_port;
 923                         uint8_t physical_port;
 924 #else
 925                         uint8_t physical_port;
 926                         uint8_t virtual_port;
 927                         uint8_t mac_speed;
 928                         uint8_t rsvd0;
 929 #endif
 930                 }req;
 931 
 932                 struct {
 933                         uint32_t rsvd0;
 934                 }rsp;
 935 
 936                 uint32_t dw;
 937         }params;
 938 };
 939 
 940 struct mac_address_format {
 941         uint16_t size_of_struct;
 942         uint8_t mac_addr[6];
 943 };
 944 
 945 /* [01] OPCODE_QUERY_COMMON_IFACE_MAC */
 946 struct mbx_query_common_iface_mac {
 947         struct mbx_hdr hdr;
 948         union {
 949                 struct {
 950 #ifdef _BIG_ENDIAN
 951                         uint16_t if_id;
 952                         uint8_t permanent;
 953                         uint8_t type;
 954 #else
 955                         uint8_t type;
 956                         uint8_t permanent;
 957                         uint16_t if_id;
 958 #endif
 959 
 960                 }req;
 961 
 962                 struct {
 963                         struct mac_address_format mac;
 964                 }rsp;
 965         }params;
 966 };
 967 
 968 /* [02] OPCODE_SET_COMMON_IFACE_MAC */
 969 struct mbx_set_common_iface_mac {
 970         struct mbx_hdr hdr;
 971         union {
 972                 struct {
 973 #ifdef _BIG_ENDIAN
 974                         /* dw 0 */
 975                         uint16_t if_id;
 976                         uint8_t invalidate;
 977                         uint8_t type;
 978 #else
 979                         /* dw 0 */
 980                         uint8_t type;
 981                         uint8_t invalidate;
 982                         uint16_t if_id;
 983 #endif
 984                         /* dw 1 */
 985                         struct mac_address_format mac;
 986                 }req;
 987 
 988                 struct {
 989                         uint32_t rsvd0;
 990                 }rsp;
 991 
 992                 uint32_t dw[2];
 993         }params;
 994 };
 995 
 996 /* [03] OPCODE_SET_COMMON_IFACE_MULTICAST */
 997 struct mbx_set_common_iface_multicast {
 998         struct mbx_hdr hdr;
 999         union {
1000                 struct {
1001                         /* dw 0 */
1002                         uint16_t num_mac;
1003                         uint8_t promiscuous;
1004                         uint8_t if_id;
1005                         /* dw 1-48 */
1006                         struct {
1007                                 uint8_t byte[6];
1008                         } mac[32];
1009 
1010                 }req;
1011 
1012                 struct {
1013                         uint32_t rsvd0;
1014                 }rsp;
1015 
1016                 uint32_t dw[49];
1017         }params;
1018 };
1019 
1020 struct qinq_vlan {
1021 #ifdef _BIG_ENDIAN
1022         uint16_t inner;
1023         uint16_t outer;
1024 #else
1025         uint16_t outer;
1026         uint16_t inner;
1027 #endif
1028 };
1029 
1030 struct normal_vlan {
1031         uint16_t vtag;
1032 };
1033 
1034 struct ntwk_if_vlan_tag {
1035         union {
1036                 struct normal_vlan normal;
1037                 struct qinq_vlan qinq;
1038         }u0;
1039 };
1040 
1041 /* [50] OPCODE_CREATE_COMMON_IFACE */
1042 struct mbx_create_common_iface {
1043         struct mbx_hdr hdr;
1044         union {
1045                 struct {
1046                         uint32_t version;
1047                         uint32_t cap_flags;
1048                         uint32_t enable_flags;
1049                         uint8_t mac_addr[6];
1050                         uint8_t rsvd0;
1051                         uint8_t mac_invalid;
1052                         struct ntwk_if_vlan_tag vlan_tag;
1053                 }req;
1054 
1055                 struct {
1056                         uint32_t if_id;
1057                         uint32_t pmac_id;
1058                 }rsp;
1059                 uint32_t dw[4];
1060         }params;
1061 };
1062 
1063 /* [51] OPCODE_DESTROY_COMMON_IFACE */
1064 struct mbx_destroy_common_iface {
1065         struct mbx_hdr hdr;
1066         union {
1067                 struct {
1068                         uint32_t if_id;
1069                 }req;
1070 
1071                 struct {
1072                         uint32_t rsvd0;
1073                 }rsp;
1074 
1075                 uint32_t dw;
1076         }params;
1077 };
1078 
1079 struct mbx_set_common_iface_rx_filter {
1080         struct mbx_hdr hdr;
1081         union {
1082                 struct {
1083                         uint32_t gflags_mask;
1084                         uint32_t gflags;
1085                         uint32_t if_flags_mask;
1086                         uint32_t if_flags;
1087                         uint32_t if_id;
1088                         uint32_t multicast_num;
1089                         struct ether_addr mac[32];
1090                 }req;
1091                 struct {
1092                         uint32_t gflags_mask;
1093                         uint32_t gflags;
1094                         uint32_t if_flags_mask;
1095                         uint32_t if_flags;
1096                         uint32_t if_id;
1097                         uint32_t multicast_num;
1098                         struct ether_addr mac[32];
1099                 }rsp;
1100         }params;
1101 };
1102 
1103 /* event queue context structure */
1104 struct   oce_eq_ctx {
1105 #ifdef _BIG_ENDIAN
1106         /* dw0 */
1107         uint32_t size:1;
1108         uint32_t rsvd1:1;
1109         uint32_t valid:1;
1110         uint32_t epidx:13;
1111         uint32_t rsvd0:3;
1112         uint32_t cidx:13;
1113 
1114         /* dw1 */
1115         uint32_t armed:1;
1116         uint32_t stalled:1;
1117         uint32_t sol_event:1;
1118         uint32_t count:3;
1119         uint32_t pd:10;
1120         uint32_t rsvd2:3;
1121         uint32_t pidx:13;
1122 
1123         /* dw2 */
1124         uint32_t rsvd6:4;
1125         uint32_t nodelay:1;
1126         uint32_t phase:2;
1127         uint32_t rsvd5:2;
1128         uint32_t delay_mult:10;
1129         uint32_t rsvd4:1;
1130         uint32_t function:8;
1131         uint32_t rsvd3:4;
1132 
1133         /* dw 3 */
1134         uint32_t rsvd7;
1135 #else
1136         /* dw0 */
1137         uint32_t cidx:13;
1138         uint32_t rsvd0:3;
1139         uint32_t epidx:13;
1140         uint32_t valid:1;
1141         uint32_t rsvd1:1;
1142         uint32_t size:1;
1143 
1144         /* dw1 */
1145         uint32_t pidx:13;
1146         uint32_t rsvd2:3;
1147         uint32_t pd:10;
1148         uint32_t count:3;
1149         uint32_t sol_event:1;
1150         uint32_t stalled:1;
1151         uint32_t armed:1;
1152 
1153         /* dw2 */
1154         uint32_t rsvd3:4;
1155         uint32_t function:8;
1156         uint32_t rsvd4:1;
1157         uint32_t delay_mult:10;
1158         uint32_t rsvd5:2;
1159         uint32_t phase:2;
1160         uint32_t nodelay:1;
1161         uint32_t rsvd6:4;
1162 
1163         /* dw3 */
1164         uint32_t rsvd7;
1165 #endif
1166 };
1167 
1168 /* [13] OPCODE_CREATE_COMMON_EQ */
1169 struct mbx_create_common_eq {
1170         struct mbx_hdr hdr;
1171         union {
1172                 struct {
1173 #ifdef _BIG_ENDIAN
1174                         uint16_t rsvd0;
1175                         uint16_t num_pages;
1176 #else
1177                         uint16_t num_pages;
1178                         uint16_t rsvd0;
1179 #endif
1180                         struct oce_eq_ctx eq_ctx;
1181                         struct phys_addr pages[8];
1182                 }req;
1183 
1184                 struct {
1185                         uint16_t eq_id;
1186                         uint16_t rsvd0;
1187                 }rsp;
1188         }params;
1189 };
1190 
1191 /* [55] OPCODE_DESTROY_COMMON_EQ */
1192 struct mbx_destroy_common_eq {
1193         struct mbx_hdr hdr;
1194         union {
1195                 struct {
1196 #ifdef _BIG_ENDIAN
1197                         uint16_t rsvd0;
1198                         uint16_t id;
1199 #else
1200                         uint16_t id;
1201                         uint16_t rsvd0;
1202 #endif
1203                 }req;
1204 
1205                 struct {
1206                         uint32_t rsvd0;
1207                 }rsp;
1208         }params;
1209 };
1210 
1211 struct oce_cq_ctx_v0 {
1212 #ifdef _BIG_ENDIAN
1213         /* dw0 */
1214         uint32_t eventable:1;
1215         uint32_t sol_event:1;
1216         uint32_t valid:1;
1217         uint32_t count:2;
1218         uint32_t rsvd1:1;
1219         uint32_t epidx:11;
1220         uint32_t nodelay:1;
1221         uint32_t coalesce_wm:2;
1222         uint32_t rsvd0:1;
1223         uint32_t cidx:11;
1224 
1225         /* dw1 */
1226         uint32_t armed:1;
1227         uint32_t stalled:1;
1228         uint32_t eq_id:8;
1229         uint32_t pd:10;
1230         uint32_t rsvd2:1;
1231         uint32_t pidx:11;
1232 
1233         /* dw2 */
1234         uint32_t rsvd4:20;
1235         uint32_t function:8;
1236         uint32_t rsvd3:4;
1237 #else
1238         /* dw0 */
1239         uint32_t cidx:11;
1240         uint32_t rsvd0:1;
1241         uint32_t coalesce_wm:2;
1242         uint32_t nodelay:1;
1243         uint32_t epidx:11;
1244         uint32_t rsvd1:1;
1245         uint32_t count:2;
1246         uint32_t valid:1;
1247         uint32_t sol_event:1;
1248         uint32_t eventable:1;
1249 
1250         /* dw1 */
1251         uint32_t pidx:11;
1252         uint32_t rsvd2:1;
1253         uint32_t pd:10;
1254         uint32_t eq_id:8;
1255         uint32_t stalled:1;
1256         uint32_t armed:1;
1257 
1258         /* dw2 */
1259         uint32_t rsvd3:4;
1260         uint32_t function:8;
1261         uint32_t rsvd4:20;
1262 #endif
1263         uint32_t rsvd5;
1264 };
1265 
1266 /* [12] OPCODE_CREATE_COMMON_CQ V0 */
1267 struct mbx_create_common_cq_v0 {
1268         struct mbx_hdr hdr;
1269         union {
1270                 struct {
1271 #ifdef _BIG_ENDIAN
1272                         uint16_t rsvd0;
1273                         uint16_t num_pages;
1274 #else
1275                         uint16_t num_pages;
1276                         uint16_t rsvd0;
1277 #endif
1278                         struct oce_cq_ctx_v0 cq_ctx;
1279                         struct phys_addr pages[4];
1280                 }req;
1281 
1282                 struct {
1283                         uint16_t cq_id;
1284                         uint16_t rsvd0;
1285                 }rsp;
1286         }params;
1287 };
1288 
1289 struct oce_cq_ctx_v2 {
1290 #ifdef _BIG_ENDIAN
1291         /* dw0 */
1292         uint32_t eventable:1;
1293         uint32_t rsvd2:1;
1294         uint32_t valid:1;
1295         uint32_t count:2;
1296         uint32_t rsvd1:11;
1297         uint32_t auto_valid:1;
1298         uint32_t nodelay:1;
1299         uint32_t coalesce_wm:2;
1300         uint32_t rsvd0:12;
1301 
1302         /* dw1 */
1303         uint32_t armed:1;
1304         uint32_t rsvd3:15;
1305         uint32_t eq_id:16;
1306 
1307         /* dw2 */
1308         uint32_t rsvd4:16;
1309         uint32_t cqe_count:16;
1310 #else
1311         /* dw0 */
1312         uint32_t rsvd0:12;
1313         uint32_t coalesce_wm:2;
1314         uint32_t nodelay:1;
1315         uint32_t auto_valid:1;
1316         uint32_t rsvd1:11;
1317         uint32_t count:2;
1318         uint32_t valid:1;
1319         uint32_t rsvd2:1;
1320         uint32_t eventable:1;
1321 
1322         /* dw1 */
1323         uint32_t eq_id:16;
1324         uint32_t rsvd3:15;
1325         uint32_t armed:1;
1326 
1327         /* dw2 */
1328         uint32_t cqe_count:16;
1329         uint32_t rsvd4:16;
1330 #endif
1331         uint32_t rsvd5;
1332 };
1333 
1334 /* [12] OPCODE_CREATE_COMMON_CQ V2 */
1335 struct mbx_create_common_cq_v2 {
1336         struct mbx_hdr hdr;
1337         union {
1338                 struct {
1339 #ifdef _BIG_ENDIAN
1340                         uint8_t rsvd0;
1341                         uint8_t page_size;
1342                         uint16_t num_pages;
1343 #else
1344                         uint16_t num_pages;
1345                         uint8_t page_size;
1346                         uint8_t rsvd0;
1347 #endif
1348                         struct oce_cq_ctx_v2 cq_ctx;
1349                         struct phys_addr pages[8];
1350                 }req;
1351 
1352                 struct {
1353                         uint16_t cq_id;
1354                         uint16_t rsvd0;
1355                 }rsp;
1356         }params;
1357 };
1358 
1359 /* [54] OPCODE_DESTROY_COMMON_CQ */
1360 struct mbx_destroy_common_cq {
1361         struct mbx_hdr hdr;
1362         union {
1363                 struct {
1364 #ifdef _BIG_ENDIAN
1365                         uint16_t rsvd0;
1366                         uint16_t id;
1367 #else
1368                         uint16_t id;
1369                         uint16_t rsvd0;
1370 #endif
1371                 }req;
1372 
1373                 struct {
1374                         uint32_t rsvd0;
1375                 }rsp;
1376         }params;
1377 };
1378 
1379 struct mq_ring_ctx_v0 {
1380         union {
1381                 struct {
1382 #ifdef _BIG_ENDIAN
1383                         /* dw 0 */
1384                         uint32_t cq_id:10;
1385                         uint32_t fetch_r2t:1;
1386                         uint32_t fetch_wrb:1;
1387                         uint32_t ring_size:4;
1388                         uint32_t rsvd0:2;
1389                         uint32_t con_index:14;
1390 
1391                         /* dw1 */
1392                         uint32_t valid:1;
1393                         uint32_t pdid:9;
1394                         uint32_t fid:8;
1395                         uint32_t prod_index:14;
1396 
1397                         /* dw 2 */
1398                         uint32_t rsvd1:21;
1399                         uint32_t async_cq_id:10;
1400                         uint32_t async_cq_valid:1;
1401 #else
1402                         /* dw 0 */
1403                         uint32_t con_index:14;
1404                         uint32_t rsvd0:2;
1405                         uint32_t ring_size:4;
1406                         uint32_t fetch_wrb:1;
1407                         uint32_t fetch_r2t:1;
1408                         uint32_t cq_id:10;
1409 
1410                         /* dw1 */
1411                         uint32_t prod_index:14;
1412                         uint32_t fid:8;
1413                         uint32_t pdid:9;
1414                         uint32_t valid:1;
1415 
1416                         /* dw 2 */
1417                         uint32_t async_cq_valid:1;
1418                         uint32_t async_cq_id:10;
1419                         uint32_t rsvd1:21;
1420 #endif
1421                         /* dw3 */
1422                         uint32_t rsvd3;
1423                 }s;
1424                 uint32_t dw[4];
1425         }u0;
1426 };
1427 
1428 /* [21] OPCODE_CREATE_COMMON_MQ V0 */
1429 struct mbx_create_common_mq {
1430         struct mbx_hdr hdr;
1431         union {
1432                 struct {
1433 #ifdef _BIG_ENDIAN
1434                         uint16_t rsvd0;
1435                         uint16_t num_pages;
1436 #else
1437                         uint16_t num_pages;
1438                         uint16_t rsvd0;
1439 #endif
1440                         struct mq_ring_ctx_v0 context;
1441                         struct phys_addr pages[8];
1442                 }req;
1443 
1444                 struct {
1445                         uint32_t mq_id:16;
1446                         uint32_t rsvd0:16;
1447                 }rsp;
1448         }params;
1449 };
1450 
1451 /* [90] OPCODE_COMMON_MCC_CREATE_EXT V0 */
1452 struct mbx_create_common_mq_ext_v0 {
1453         struct mbx_hdr hdr;
1454         union {
1455                 struct {
1456 #ifdef _BIG_ENDIAN
1457                         uint16_t rsvd0;
1458                         uint16_t num_pages;
1459 #else
1460                         uint16_t num_pages;
1461                         uint16_t rsvd0;
1462 #endif
1463                         uint32_t async_event_bitmap[1];
1464                         struct mq_ring_ctx_v0 context;
1465                         struct phys_addr pages[8];
1466                 }req;
1467 
1468                 struct {
1469                         uint32_t mq_id:16;
1470                         uint32_t rsvd0:16;
1471                 }rsp;
1472         }params;
1473 };
1474 
1475 struct mq_ring_ctx_v1 {
1476         union {
1477                 struct {
1478 #ifdef _BIG_ENDIAN
1479                         /* dw 0 */
1480                         uint32_t rsrvd0:12;
1481                         uint32_t ring_size:4;
1482                         uint32_t async_cq_id:16;
1483 
1484                         /* dw1 */
1485                         uint32_t valid:1;
1486                         uint32_t rsrvd1:31;
1487 
1488                         /* dw 2 */
1489                         uint32_t rsvd2:31;
1490                         uint32_t async_cq_valid:1;
1491 #else
1492                         /* dw 0 */
1493                         uint32_t async_cq_id:16;
1494                         uint32_t ring_size:4;
1495                         uint32_t rsrvd0:12;
1496 
1497                         /* dw1 */
1498                         uint32_t rsrvd1:31;
1499                         uint32_t valid:1;
1500 
1501                         /* dw 2 */
1502                         uint32_t async_cq_valid:1;
1503                         uint32_t rsvd2:31;
1504 #endif
1505                         /* dw3 */
1506                         uint32_t rsvd3;
1507                 }s;
1508                 uint32_t dw[4];
1509         }u0;
1510 };
1511 
1512 /* [90] OPCODE_COMMON_MCC_CREATE_EXT V1 */
1513 struct mbx_create_common_mq_ext_v1 {
1514         struct mbx_hdr hdr;
1515         union {
1516                 struct {
1517 #ifdef _BIG_ENDIAN
1518                         uint16_t cq_id;
1519                         uint16_t num_pages;
1520 #else
1521                         uint16_t num_pages;
1522                         uint16_t cq_id;
1523 #endif
1524                         uint32_t async_event_bitmap[1];
1525                         struct mq_ring_ctx_v1 context;
1526                         struct phys_addr pages[8];
1527                 }req;
1528 
1529                 struct {
1530                         uint32_t mq_id:16;
1531                         uint32_t rsvd0:16;
1532                 }rsp;
1533         }params;
1534 };
1535 
1536 /* [53] OPCODE_DESTROY_COMMON_MQ */
1537 struct mbx_destroy_common_mq {
1538         struct mbx_hdr hdr;
1539         union {
1540                 struct {
1541 #ifdef _BIG_ENDIAN
1542                         uint16_t rsvd0;
1543                         uint16_t id;
1544 #else
1545                         uint16_t id;
1546                         uint16_t rsvd0;
1547 #endif
1548                 }req;
1549 
1550                 struct {
1551                         uint32_t rsvd0;
1552                 }rsp;
1553         }params;
1554 };
1555 
1556 /* [35] OPCODE_GET_COMMON_ FW_VERSION */
1557 struct mbx_get_common_fw_version {
1558         struct mbx_hdr hdr;
1559         union {
1560                 struct {
1561                         uint32_t rsvd0;
1562                 }req;
1563 
1564                 struct {
1565                         uint8_t fw_ver_str[32];
1566                         uint8_t fw_on_flash_ver_str[32];
1567                 }rsp;
1568         }params;
1569 };
1570 
1571 /* [52] OPCODE_COMMON_CEV_MODIFY_MSI_MESSAGES */
1572 struct mbx_common_cev_modify_msi_messages {
1573         struct mbx_hdr hdr;
1574         union {
1575                 struct {
1576                         uint32_t num_msi_msgs;
1577                 }req;
1578 
1579                 struct {
1580                         uint32_t rsvd0;
1581                 }rsp;
1582         }params;
1583 };
1584 
1585 /* [36] OPCODE_SET_COMMON_FLOW_CONTROL */
1586 /* [37] OPCODE_GET_COMMON_FLOW_CONTROL */
1587 struct mbx_common_get_set_flow_control {
1588         struct mbx_hdr hdr;
1589 #ifdef _BIG_ENDIAN
1590         uint16_t tx_flow_control;
1591         uint16_t rx_flow_control;
1592 #else
1593         uint16_t rx_flow_control;
1594         uint16_t tx_flow_control;
1595 #endif
1596 };
1597 
1598 enum e_flash_opcode {
1599         MGMT_FLASHROM_OPCODE_FLASH = 1,
1600         MGMT_FLASHROM_OPCODE_SAVE = 2
1601 };
1602 
1603 /* [06] OPCODE_READ_COMMON_FLASHROM */
1604 /* [07] OPCODE_WRITE_COMMON_FLASHROM */
1605 
1606 struct mbx_common_read_write_flashrom {
1607         struct mbx_hdr hdr;
1608         uint32_t    flash_op_code;
1609         uint32_t    flash_op_type;
1610         uint32_t    data_buffer_size;
1611         uint32_t    data_offset;
1612         uint8_t         data_buffer[4];  /* + IMAGE_TRANSFER_SIZE */
1613 };
1614 
1615 /* ULP MODE SUPPORTED */
1616 enum {
1617         ULP_TOE_MODE = 0x1,
1618         ULP_NIC_MODE = 0x2,
1619         ULP_RDMA_MODE = 0x4,
1620         ULP_ISCSI_INI_MODE = 0x10,
1621         ULP_ISCSI_TGT_MODE = 0x20,
1622         ULP_FCOE_INI_MODE = 0x40,
1623         ULP_FCOE_TGT_MODE = 0x80,
1624         ULP_DAL_MODE = 0x100,
1625         ULP_LRO_MODE = 0x200
1626 };
1627 
1628 /* Function Mode Supported */
1629 enum {
1630         TOE_MODE = 0x1, /* TCP offload  */
1631         NIC_MODE = 0x2, /* Raw Ethernet  */
1632         RDMA_MODE = 0x4, /*  RDMA  */
1633         VM_MODE = 0x8,   /* VM  */
1634         ISCSI_INI_MODE = 0x10, /*  iSCSI initiator */
1635         ISCSI_TGT_MODE = 0x20, /* iSCSI target plus initiator */
1636         FCOE_INI_MODE = 0x40, /* FCoE Initiator */
1637         FCOE_TGT_MODE = 0x80, /* FCoE target */
1638         DAL_MODE = 0x100, /* DAL */
1639         LRO_MODE = 0x200, /* LRO */
1640         FLEX10_MODE = 0x400, /*  FLEX-10  or VNIC */
1641         NCSI_MODE = 0x800, /* NCSI */
1642         INVALID_MODE = 0x8000 /* Invalid */
1643 };
1644 
1645 struct mbx_common_query_fw_config {
1646         struct mbx_hdr hdr;
1647         union {
1648                 struct {
1649                         uint32_t rsvd0[30];
1650                 }req;
1651 
1652                 struct {
1653                         uint32_t    config_number;
1654                         uint32_t    asic_revision;
1655                         uint32_t    port_id; /* used for stats retrieval */
1656                         uint32_t    function_mode;
1657                         struct {
1658 
1659                                 uint32_t    mode;
1660                                 uint32_t    wq_base;
1661                                 uint32_t    wq_count;
1662                                 uint32_t    sq_base;
1663                                 uint32_t    sq_count;
1664                                 uint32_t    rq_base;
1665                                 uint32_t    rq_count;
1666                                 uint32_t    dq_base;
1667                                 uint32_t    dq_count;
1668                                 uint32_t    lro_base;
1669                                 uint32_t    lro_count;
1670                                 uint32_t    icd_base;
1671                                 uint32_t    icd_count;
1672                         } ulp[2];
1673                         uint32_t function_caps;
1674                 }rsp;
1675         }params;
1676 };
1677 
1678 struct mbx_common_config_vlan {
1679         struct mbx_hdr hdr;
1680         union {
1681                 struct {
1682 #ifdef _BIG_ENDIAN
1683                         uint8_t num_vlans;
1684                         uint8_t untagged;
1685                         uint8_t promisc;
1686                         uint8_t if_id;
1687 #else
1688                         uint8_t if_id;
1689                         uint8_t promisc;
1690                         uint8_t untagged;
1691                         uint8_t num_vlans;
1692 #endif
1693                         union {
1694                                 struct normal_vlan normal_vlans[64];
1695                                 struct qinq_vlan  qinq_vlans[32];
1696                         }tags;
1697                 }req;
1698 
1699                 struct {
1700                         uint32_t rsvd;
1701                 }rsp;
1702         }params;
1703 };
1704 
1705 /* [34] OPCODE_COMMON_NTWK_RX_FILTER */
1706 struct mbx_set_common_ntwk_rx_filter {
1707         struct mbx_hdr hdr;
1708         uint32_t global_flags_mask;
1709         uint32_t global_flags;
1710         uint32_t iface_flags_mask;
1711         uint32_t iface_flags;
1712         uint32_t if_id;
1713         uint32_t num_mcast;
1714         struct {
1715                 uint8_t byte[6];
1716         }mac[32];
1717 };
1718 /* [41] OPCODE_MODIFY_COMMON_EQ_DELAY */
1719 struct mbx_modify_common_eq_delay {
1720         struct mbx_hdr hdr;
1721         union {
1722                 struct {
1723                         uint32_t num_eq;
1724                         struct {
1725                                 uint32_t eq_id;
1726                                 uint32_t phase;
1727                                 uint32_t dm;
1728                         }delay[8];
1729                 }req;
1730 
1731                 struct {
1732                         uint32_t rsvd0;
1733                 }rsp;
1734         }params;
1735 };
1736 /* [59] OPCODE_ADD_COMMON_IFACE_MAC */
1737 struct mbx_add_common_iface_mac {
1738         struct mbx_hdr hdr;
1739         union {
1740                 struct {
1741                         uint32_t if_id;
1742                         uint8_t mac_address[6];
1743                         uint8_t rsvd0[2];
1744                 }req;
1745                 struct {
1746                         uint32_t pmac_id;
1747                 }rsp;
1748         } params;
1749 };
1750 
1751 /* [60] OPCODE_DEL_COMMON_IFACE_MAC */
1752 struct mbx_del_common_iface_mac {
1753         struct mbx_hdr hdr;
1754         union {
1755                 struct {
1756                         uint32_t if_id;
1757                         uint32_t pmac_id;
1758                 }req;
1759                 struct {
1760                         uint32_t rsvd0;
1761                 }rsp;
1762         } params;
1763 };
1764 
1765 /* [8] OPCODE_QUERY_COMMON_MAX_MBX_BUFFER_SIZE */
1766 struct mbx_query_common_max_mbx_buffer_size {
1767         struct mbx_hdr hdr;
1768         struct {
1769                 uint32_t max_ioctl_bufsz;
1770         } rsp;
1771 };
1772 
1773 /* [61] OPCODE_COMMON_FUNCTION_RESET */
1774 struct ioctl_common_function_reset {
1775         struct mbx_hdr hdr;
1776 };
1777 
1778 /* [80] OPCODE_COMMON_FUNCTION_LINK_CONFIG */
1779 struct mbx_common_func_link_cfg {
1780         struct mbx_hdr hdr;
1781         union {
1782                 struct {
1783                         uint32_t enable;
1784                 }req;
1785                 struct {
1786                         uint32_t rsvd0;
1787                 }rsp;
1788         } params;
1789 };
1790 
1791 /* [103] OPCODE_COMMON_SET_DRIVER_FUNCTION_CAPABILITIES */
1792 struct mbx_common_set_drvfn_capab {
1793         struct mbx_hdr hdr;
1794         union {
1795                 struct {
1796                         uint32_t valid_capability_flags;
1797                         uint32_t capability_flags;
1798                         uint8_t sbz[212];
1799                 } request;
1800                 struct {
1801                         uint32_t valid_capability_flags;
1802                         uint32_t capability_flags;
1803                         uint8_t sbz[212];
1804                 } response;
1805         } params;
1806 };
1807 
1808 #pragma pack()
1809 
1810 #ifdef __cplusplus
1811 }
1812 #endif
1813 
1814 #endif /* _OCE_HW_H_ */