1f844a0eaSJeff Kirsher /* 22732ba56SRasesh Mody * Linux network driver for QLogic BR-series Converged Network Adapter. 3f844a0eaSJeff Kirsher * 4f844a0eaSJeff Kirsher * This program is free software; you can redistribute it and/or modify it 5f844a0eaSJeff Kirsher * under the terms of the GNU General Public License (GPL) Version 2 as 6f844a0eaSJeff Kirsher * published by the Free Software Foundation 7f844a0eaSJeff Kirsher * 8f844a0eaSJeff Kirsher * This program is distributed in the hope that it will be useful, but 9f844a0eaSJeff Kirsher * WITHOUT ANY WARRANTY; without even the implied warranty of 10f844a0eaSJeff Kirsher * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11f844a0eaSJeff Kirsher * General Public License for more details. 12f844a0eaSJeff Kirsher */ 13f844a0eaSJeff Kirsher /* 142732ba56SRasesh Mody * Copyright (c) 2005-2014 Brocade Communications Systems, Inc. 152732ba56SRasesh Mody * Copyright (c) 2014-2015 QLogic Corporation 16f844a0eaSJeff Kirsher * All rights reserved 172732ba56SRasesh Mody * www.qlogic.com 18f844a0eaSJeff Kirsher */ 19f844a0eaSJeff Kirsher #ifndef __BFI_H__ 20f844a0eaSJeff Kirsher #define __BFI_H__ 21f844a0eaSJeff Kirsher 22f844a0eaSJeff Kirsher #include "bfa_defs.h" 23f844a0eaSJeff Kirsher 241aa8b471SBen Hutchings /* BFI FW image type */ 25f844a0eaSJeff Kirsher #define BFI_FLASH_CHUNK_SZ 256 /*!< Flash chunk size */ 26f844a0eaSJeff Kirsher #define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32)) 27c107ba17SRasesh Mody #define BFI_FLASH_IMAGE_SZ 0x100000 28f844a0eaSJeff Kirsher 291aa8b471SBen Hutchings /* Msg header common to all msgs */ 30f844a0eaSJeff Kirsher struct bfi_mhdr { 31f844a0eaSJeff Kirsher u8 msg_class; /*!< @ref enum bfi_mclass */ 32f844a0eaSJeff Kirsher u8 msg_id; /*!< msg opcode with in the class */ 33f844a0eaSJeff Kirsher union { 34f844a0eaSJeff Kirsher struct { 35078086f3SRasesh Mody u8 qid; 36078086f3SRasesh Mody u8 fn_lpu; /*!< msg destination */ 37*e423c856SIvan Vecera } __packed h2i; 38f844a0eaSJeff Kirsher u16 i2htok; /*!< token in msgs to host */ 39*e423c856SIvan Vecera } __packed mtag; 40*e423c856SIvan Vecera } __packed; 41f844a0eaSJeff Kirsher 42078086f3SRasesh Mody #define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu)) 43078086f3SRasesh Mody #define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1) 44078086f3SRasesh Mody #define bfi_mhdr_2_qid(_mh) ((_mh)->mtag.h2i.qid) 45078086f3SRasesh Mody 46078086f3SRasesh Mody #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \ 47f844a0eaSJeff Kirsher (_mh).msg_class = (_mc); \ 48f844a0eaSJeff Kirsher (_mh).msg_id = (_op); \ 49078086f3SRasesh Mody (_mh).mtag.h2i.fn_lpu = (_fn_lpu); \ 50f844a0eaSJeff Kirsher } while (0) 51f844a0eaSJeff Kirsher 52f844a0eaSJeff Kirsher #define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \ 53f844a0eaSJeff Kirsher (_mh).msg_class = (_mc); \ 54f844a0eaSJeff Kirsher (_mh).msg_id = (_op); \ 55f844a0eaSJeff Kirsher (_mh).mtag.i2htok = (_i2htok); \ 56f844a0eaSJeff Kirsher } while (0) 57f844a0eaSJeff Kirsher 58f844a0eaSJeff Kirsher /* 59f844a0eaSJeff Kirsher * Message opcodes: 0-127 to firmware, 128-255 to host 60f844a0eaSJeff Kirsher */ 61f844a0eaSJeff Kirsher #define BFI_I2H_OPCODE_BASE 128 62f844a0eaSJeff Kirsher #define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE) 63f844a0eaSJeff Kirsher 641aa8b471SBen Hutchings /**************************************************************************** 65f844a0eaSJeff Kirsher * 66f844a0eaSJeff Kirsher * Scatter Gather Element and Page definition 67f844a0eaSJeff Kirsher * 68f844a0eaSJeff Kirsher **************************************************************************** 69f844a0eaSJeff Kirsher */ 70f844a0eaSJeff Kirsher 711aa8b471SBen Hutchings /* DMA addresses */ 72f844a0eaSJeff Kirsher union bfi_addr_u { 73f844a0eaSJeff Kirsher struct { 74f844a0eaSJeff Kirsher u32 addr_lo; 75f844a0eaSJeff Kirsher u32 addr_hi; 76*e423c856SIvan Vecera } __packed a32; 77*e423c856SIvan Vecera } __packed; 78f844a0eaSJeff Kirsher 791aa8b471SBen Hutchings /* Generic DMA addr-len pair. */ 8072a9730bSKrishna Gudipati struct bfi_alen { 8172a9730bSKrishna Gudipati union bfi_addr_u al_addr; /* DMA addr of buffer */ 8272a9730bSKrishna Gudipati u32 al_len; /* length of buffer */ 83*e423c856SIvan Vecera } __packed; 8472a9730bSKrishna Gudipati 85f844a0eaSJeff Kirsher /* 86f844a0eaSJeff Kirsher * Large Message structure - 128 Bytes size Msgs 87f844a0eaSJeff Kirsher */ 88f844a0eaSJeff Kirsher #define BFI_LMSG_SZ 128 89f844a0eaSJeff Kirsher #define BFI_LMSG_PL_WSZ \ 90f844a0eaSJeff Kirsher ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr)) / 4) 91f844a0eaSJeff Kirsher 921aa8b471SBen Hutchings /* Mailbox message structure */ 93f844a0eaSJeff Kirsher #define BFI_MBMSG_SZ 7 94f844a0eaSJeff Kirsher struct bfi_mbmsg { 95f844a0eaSJeff Kirsher struct bfi_mhdr mh; 96f844a0eaSJeff Kirsher u32 pl[BFI_MBMSG_SZ]; 97*e423c856SIvan Vecera } __packed; 98f844a0eaSJeff Kirsher 991aa8b471SBen Hutchings /* Supported PCI function class codes (personality) */ 100078086f3SRasesh Mody enum bfi_pcifn_class { 101078086f3SRasesh Mody BFI_PCIFN_CLASS_FC = 0x0c04, 102078086f3SRasesh Mody BFI_PCIFN_CLASS_ETH = 0x0200, 103078086f3SRasesh Mody }; 104078086f3SRasesh Mody 1051aa8b471SBen Hutchings /* Message Classes */ 106f844a0eaSJeff Kirsher enum bfi_mclass { 107f844a0eaSJeff Kirsher BFI_MC_IOC = 1, /*!< IO Controller (IOC) */ 108f844a0eaSJeff Kirsher BFI_MC_DIAG = 2, /*!< Diagnostic Msgs */ 109f844a0eaSJeff Kirsher BFI_MC_FLASH = 3, /*!< Flash message class */ 110f844a0eaSJeff Kirsher BFI_MC_CEE = 4, /*!< CEE */ 111f844a0eaSJeff Kirsher BFI_MC_FCPORT = 5, /*!< FC port */ 112f844a0eaSJeff Kirsher BFI_MC_IOCFC = 6, /*!< FC - IO Controller (IOC) */ 113f844a0eaSJeff Kirsher BFI_MC_LL = 7, /*!< Link Layer */ 114f844a0eaSJeff Kirsher BFI_MC_UF = 8, /*!< Unsolicited frame receive */ 115f844a0eaSJeff Kirsher BFI_MC_FCXP = 9, /*!< FC Transport */ 116f844a0eaSJeff Kirsher BFI_MC_LPS = 10, /*!< lport fc login services */ 117f844a0eaSJeff Kirsher BFI_MC_RPORT = 11, /*!< Remote port */ 118f844a0eaSJeff Kirsher BFI_MC_ITNIM = 12, /*!< I-T nexus (Initiator mode) */ 119f844a0eaSJeff Kirsher BFI_MC_IOIM_READ = 13, /*!< read IO (Initiator mode) */ 120f844a0eaSJeff Kirsher BFI_MC_IOIM_WRITE = 14, /*!< write IO (Initiator mode) */ 121f844a0eaSJeff Kirsher BFI_MC_IOIM_IO = 15, /*!< IO (Initiator mode) */ 122f844a0eaSJeff Kirsher BFI_MC_IOIM = 16, /*!< IO (Initiator mode) */ 123f844a0eaSJeff Kirsher BFI_MC_IOIM_IOCOM = 17, /*!< good IO completion */ 124f844a0eaSJeff Kirsher BFI_MC_TSKIM = 18, /*!< Initiator Task management */ 125f844a0eaSJeff Kirsher BFI_MC_SBOOT = 19, /*!< SAN boot services */ 126f844a0eaSJeff Kirsher BFI_MC_IPFC = 20, /*!< IP over FC Msgs */ 127f844a0eaSJeff Kirsher BFI_MC_PORT = 21, /*!< Physical port */ 128f844a0eaSJeff Kirsher BFI_MC_SFP = 22, /*!< SFP module */ 129f844a0eaSJeff Kirsher BFI_MC_MSGQ = 23, /*!< MSGQ */ 130f844a0eaSJeff Kirsher BFI_MC_ENET = 24, /*!< ENET commands/responses */ 131aafd5c2cSRasesh Mody BFI_MC_PHY = 25, /*!< External PHY message class */ 132aafd5c2cSRasesh Mody BFI_MC_NBOOT = 26, /*!< Network Boot */ 133aafd5c2cSRasesh Mody BFI_MC_TIO_READ = 27, /*!< read IO (Target mode) */ 134aafd5c2cSRasesh Mody BFI_MC_TIO_WRITE = 28, /*!< write IO (Target mode) */ 135aafd5c2cSRasesh Mody BFI_MC_TIO_DATA_XFERED = 29, /*!< ds transferred (target mode) */ 136aafd5c2cSRasesh Mody BFI_MC_TIO_IO = 30, /*!< IO (Target mode) */ 137aafd5c2cSRasesh Mody BFI_MC_TIO = 31, /*!< IO (target mode) */ 138aafd5c2cSRasesh Mody BFI_MC_MFG = 32, /*!< MFG/ASIC block commands */ 139aafd5c2cSRasesh Mody BFI_MC_EDMA = 33, /*!< EDMA copy commands */ 140aafd5c2cSRasesh Mody BFI_MC_MAX = 34 141f844a0eaSJeff Kirsher }; 142f844a0eaSJeff Kirsher 143f844a0eaSJeff Kirsher #define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */ 144f844a0eaSJeff Kirsher 145af027a34SRasesh Mody #define BFI_FWBOOT_ENV_OS 0 146af027a34SRasesh Mody 1471aa8b471SBen Hutchings /*---------------------------------------------------------------------- 148f844a0eaSJeff Kirsher * IOC 149f844a0eaSJeff Kirsher *---------------------------------------------------------------------- 150f844a0eaSJeff Kirsher */ 151f844a0eaSJeff Kirsher 1521aa8b471SBen Hutchings /* Different asic generations */ 153078086f3SRasesh Mody enum bfi_asic_gen { 154078086f3SRasesh Mody BFI_ASIC_GEN_CB = 1, 155078086f3SRasesh Mody BFI_ASIC_GEN_CT = 2, 1561bf9fd70SRasesh Mody BFI_ASIC_GEN_CT2 = 3, 157078086f3SRasesh Mody }; 158078086f3SRasesh Mody 159078086f3SRasesh Mody enum bfi_asic_mode { 160078086f3SRasesh Mody BFI_ASIC_MODE_FC = 1, /* FC up to 8G speed */ 161078086f3SRasesh Mody BFI_ASIC_MODE_FC16 = 2, /* FC up to 16G speed */ 162078086f3SRasesh Mody BFI_ASIC_MODE_ETH = 3, /* Ethernet ports */ 163078086f3SRasesh Mody BFI_ASIC_MODE_COMBO = 4, /* FC 16G and Ethernet 10G port */ 164078086f3SRasesh Mody }; 165078086f3SRasesh Mody 166f844a0eaSJeff Kirsher enum bfi_ioc_h2i_msgs { 167f844a0eaSJeff Kirsher BFI_IOC_H2I_ENABLE_REQ = 1, 168f844a0eaSJeff Kirsher BFI_IOC_H2I_DISABLE_REQ = 2, 169f844a0eaSJeff Kirsher BFI_IOC_H2I_GETATTR_REQ = 3, 170f844a0eaSJeff Kirsher BFI_IOC_H2I_DBG_SYNC = 4, 171f844a0eaSJeff Kirsher BFI_IOC_H2I_DBG_DUMP = 5, 172f844a0eaSJeff Kirsher }; 173f844a0eaSJeff Kirsher 174f844a0eaSJeff Kirsher enum bfi_ioc_i2h_msgs { 175f844a0eaSJeff Kirsher BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1), 176f844a0eaSJeff Kirsher BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2), 177f844a0eaSJeff Kirsher BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3), 178078086f3SRasesh Mody BFI_IOC_I2H_HBEAT = BFA_I2HM(4), 179f844a0eaSJeff Kirsher }; 180f844a0eaSJeff Kirsher 1811aa8b471SBen Hutchings /* BFI_IOC_H2I_GETATTR_REQ message */ 182f844a0eaSJeff Kirsher struct bfi_ioc_getattr_req { 183f844a0eaSJeff Kirsher struct bfi_mhdr mh; 184f844a0eaSJeff Kirsher union bfi_addr_u attr_addr; 185*e423c856SIvan Vecera } __packed; 186f844a0eaSJeff Kirsher 187f844a0eaSJeff Kirsher struct bfi_ioc_attr { 188f844a0eaSJeff Kirsher u64 mfg_pwwn; /*!< Mfg port wwn */ 189f844a0eaSJeff Kirsher u64 mfg_nwwn; /*!< Mfg node wwn */ 190d6b30598SIvan Vecera u8 mfg_mac[ETH_ALEN]; /*!< Mfg mac */ 191078086f3SRasesh Mody u8 port_mode; /* enum bfi_port_mode */ 192078086f3SRasesh Mody u8 rsvd_a; 193f844a0eaSJeff Kirsher u64 pwwn; 194f844a0eaSJeff Kirsher u64 nwwn; 195d6b30598SIvan Vecera u8 mac[ETH_ALEN]; /*!< PBC or Mfg mac */ 196f844a0eaSJeff Kirsher u16 rsvd_b; 197d6b30598SIvan Vecera u8 fcoe_mac[ETH_ALEN]; 198f844a0eaSJeff Kirsher u16 rsvd_c; 199f844a0eaSJeff Kirsher char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)]; 200f844a0eaSJeff Kirsher u8 pcie_gen; 201f844a0eaSJeff Kirsher u8 pcie_lanes_orig; 202f844a0eaSJeff Kirsher u8 pcie_lanes; 203f844a0eaSJeff Kirsher u8 rx_bbcredit; /*!< receive buffer credits */ 204f844a0eaSJeff Kirsher u32 adapter_prop; /*!< adapter properties */ 205f844a0eaSJeff Kirsher u16 maxfrsize; /*!< max receive frame size */ 206f844a0eaSJeff Kirsher char asic_rev; 207f844a0eaSJeff Kirsher u8 rsvd_d; 208f844a0eaSJeff Kirsher char fw_version[BFA_VERSION_LEN]; 209f844a0eaSJeff Kirsher char optrom_version[BFA_VERSION_LEN]; 210f844a0eaSJeff Kirsher struct bfa_mfg_vpd vpd; 211f844a0eaSJeff Kirsher u32 card_type; /*!< card type */ 212*e423c856SIvan Vecera } __packed; 213f844a0eaSJeff Kirsher 2141aa8b471SBen Hutchings /* BFI_IOC_I2H_GETATTR_REPLY message */ 215f844a0eaSJeff Kirsher struct bfi_ioc_getattr_reply { 216f844a0eaSJeff Kirsher struct bfi_mhdr mh; /*!< Common msg header */ 217f844a0eaSJeff Kirsher u8 status; /*!< cfg reply status */ 218f844a0eaSJeff Kirsher u8 rsvd[3]; 219*e423c856SIvan Vecera } __packed; 220f844a0eaSJeff Kirsher 2211aa8b471SBen Hutchings /* Firmware memory page offsets */ 222f844a0eaSJeff Kirsher #define BFI_IOC_SMEM_PG0_CB (0x40) 223f844a0eaSJeff Kirsher #define BFI_IOC_SMEM_PG0_CT (0x180) 224f844a0eaSJeff Kirsher 2251aa8b471SBen Hutchings /* Firmware statistic offset */ 226f844a0eaSJeff Kirsher #define BFI_IOC_FWSTATS_OFF (0x6B40) 227f844a0eaSJeff Kirsher #define BFI_IOC_FWSTATS_SZ (4096) 228f844a0eaSJeff Kirsher 2291aa8b471SBen Hutchings /* Firmware trace offset */ 230f844a0eaSJeff Kirsher #define BFI_IOC_TRC_OFF (0x4b00) 231f844a0eaSJeff Kirsher #define BFI_IOC_TRC_ENTS 256 2327afc5dbdSKrishna Gudipati #define BFI_IOC_TRC_ENT_SZ 16 2337afc5dbdSKrishna Gudipati #define BFI_IOC_TRC_HDR_SZ 32 234f844a0eaSJeff Kirsher 235f844a0eaSJeff Kirsher #define BFI_IOC_FW_SIGNATURE (0xbfadbfad) 236c107ba17SRasesh Mody #define BFI_IOC_FW_INV_SIGN (0xdeaddead) 237f844a0eaSJeff Kirsher #define BFI_IOC_MD5SUM_SZ 4 238c107ba17SRasesh Mody 239c107ba17SRasesh Mody struct bfi_ioc_fwver { 240c107ba17SRasesh Mody #ifdef __BIG_ENDIAN 241c107ba17SRasesh Mody u8 patch; 242c107ba17SRasesh Mody u8 maint; 243c107ba17SRasesh Mody u8 minor; 244c107ba17SRasesh Mody u8 major; 245c107ba17SRasesh Mody u8 rsvd[2]; 246c107ba17SRasesh Mody u8 build; 247c107ba17SRasesh Mody u8 phase; 248c107ba17SRasesh Mody #else 249c107ba17SRasesh Mody u8 major; 250c107ba17SRasesh Mody u8 minor; 251c107ba17SRasesh Mody u8 maint; 252c107ba17SRasesh Mody u8 patch; 253c107ba17SRasesh Mody u8 phase; 254c107ba17SRasesh Mody u8 build; 255c107ba17SRasesh Mody u8 rsvd[2]; 256c107ba17SRasesh Mody #endif 257*e423c856SIvan Vecera } __packed; 258c107ba17SRasesh Mody 259f844a0eaSJeff Kirsher struct bfi_ioc_image_hdr { 260f844a0eaSJeff Kirsher u32 signature; /*!< constant signature */ 261078086f3SRasesh Mody u8 asic_gen; /*!< asic generation */ 262078086f3SRasesh Mody u8 asic_mode; 263078086f3SRasesh Mody u8 port0_mode; /*!< device mode for port 0 */ 264078086f3SRasesh Mody u8 port1_mode; /*!< device mode for port 1 */ 265f844a0eaSJeff Kirsher u32 exec; /*!< exec vector */ 266078086f3SRasesh Mody u32 bootenv; /*!< firmware boot env */ 267c107ba17SRasesh Mody u32 rsvd_b[2]; 268c107ba17SRasesh Mody struct bfi_ioc_fwver fwver; 269f844a0eaSJeff Kirsher u32 md5sum[BFI_IOC_MD5SUM_SZ]; 270*e423c856SIvan Vecera } __packed; 271f844a0eaSJeff Kirsher 272c107ba17SRasesh Mody enum bfi_ioc_img_ver_cmp { 273c107ba17SRasesh Mody BFI_IOC_IMG_VER_INCOMP, 274c107ba17SRasesh Mody BFI_IOC_IMG_VER_OLD, 275c107ba17SRasesh Mody BFI_IOC_IMG_VER_SAME, 276c107ba17SRasesh Mody BFI_IOC_IMG_VER_BETTER 277c107ba17SRasesh Mody }; 278c107ba17SRasesh Mody 279078086f3SRasesh Mody #define BFI_FWBOOT_DEVMODE_OFF 4 280078086f3SRasesh Mody #define BFI_FWBOOT_TYPE_OFF 8 281078086f3SRasesh Mody #define BFI_FWBOOT_ENV_OFF 12 282078086f3SRasesh Mody #define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \ 283078086f3SRasesh Mody (((u32)(__asic_gen)) << 24 | \ 284078086f3SRasesh Mody ((u32)(__asic_mode)) << 16 | \ 285078086f3SRasesh Mody ((u32)(__p0_mode)) << 8 | \ 286078086f3SRasesh Mody ((u32)(__p1_mode))) 287078086f3SRasesh Mody 288f844a0eaSJeff Kirsher enum bfi_fwboot_type { 289f844a0eaSJeff Kirsher BFI_FWBOOT_TYPE_NORMAL = 0, 290f844a0eaSJeff Kirsher BFI_FWBOOT_TYPE_FLASH = 1, 291f844a0eaSJeff Kirsher BFI_FWBOOT_TYPE_MEMTEST = 2, 292f844a0eaSJeff Kirsher }; 293f844a0eaSJeff Kirsher 294078086f3SRasesh Mody enum bfi_port_mode { 295078086f3SRasesh Mody BFI_PORT_MODE_FC = 1, 296078086f3SRasesh Mody BFI_PORT_MODE_ETH = 2, 297078086f3SRasesh Mody }; 298078086f3SRasesh Mody 299f844a0eaSJeff Kirsher struct bfi_ioc_hbeat { 300f844a0eaSJeff Kirsher struct bfi_mhdr mh; /*!< common msg header */ 301f844a0eaSJeff Kirsher u32 hb_count; /*!< current heart beat count */ 302*e423c856SIvan Vecera } __packed; 303f844a0eaSJeff Kirsher 3041aa8b471SBen Hutchings /* IOC hardware/firmware state */ 305f844a0eaSJeff Kirsher enum bfi_ioc_state { 306f844a0eaSJeff Kirsher BFI_IOC_UNINIT = 0, /*!< not initialized */ 307f844a0eaSJeff Kirsher BFI_IOC_INITING = 1, /*!< h/w is being initialized */ 308f844a0eaSJeff Kirsher BFI_IOC_HWINIT = 2, /*!< h/w is initialized */ 309f844a0eaSJeff Kirsher BFI_IOC_CFG = 3, /*!< IOC configuration in progress */ 310f844a0eaSJeff Kirsher BFI_IOC_OP = 4, /*!< IOC is operational */ 311f844a0eaSJeff Kirsher BFI_IOC_DISABLING = 5, /*!< IOC is being disabled */ 312f844a0eaSJeff Kirsher BFI_IOC_DISABLED = 6, /*!< IOC is disabled */ 313f844a0eaSJeff Kirsher BFI_IOC_CFG_DISABLED = 7, /*!< IOC is being disabled;transient */ 314f844a0eaSJeff Kirsher BFI_IOC_FAIL = 8, /*!< IOC heart-beat failure */ 315f844a0eaSJeff Kirsher BFI_IOC_MEMTEST = 9, /*!< IOC is doing memtest */ 316f844a0eaSJeff Kirsher }; 317f844a0eaSJeff Kirsher 318f844a0eaSJeff Kirsher #define BFI_IOC_ENDIAN_SIG 0x12345678 319f844a0eaSJeff Kirsher 320f844a0eaSJeff Kirsher enum { 321f844a0eaSJeff Kirsher BFI_ADAPTER_TYPE_FC = 0x01, /*!< FC adapters */ 322f844a0eaSJeff Kirsher BFI_ADAPTER_TYPE_MK = 0x0f0000, /*!< adapter type mask */ 323f844a0eaSJeff Kirsher BFI_ADAPTER_TYPE_SH = 16, /*!< adapter type shift */ 324f844a0eaSJeff Kirsher BFI_ADAPTER_NPORTS_MK = 0xff00, /*!< number of ports mask */ 325f844a0eaSJeff Kirsher BFI_ADAPTER_NPORTS_SH = 8, /*!< number of ports shift */ 326f844a0eaSJeff Kirsher BFI_ADAPTER_SPEED_MK = 0xff, /*!< adapter speed mask */ 327f844a0eaSJeff Kirsher BFI_ADAPTER_SPEED_SH = 0, /*!< adapter speed shift */ 328f844a0eaSJeff Kirsher BFI_ADAPTER_PROTO = 0x100000, /*!< prototype adapaters */ 329f844a0eaSJeff Kirsher BFI_ADAPTER_TTV = 0x200000, /*!< TTV debug capable */ 330f844a0eaSJeff Kirsher BFI_ADAPTER_UNSUPP = 0x400000, /*!< unknown adapter type */ 331f844a0eaSJeff Kirsher }; 332f844a0eaSJeff Kirsher 333f844a0eaSJeff Kirsher #define BFI_ADAPTER_GETP(__prop, __adap_prop) \ 334f844a0eaSJeff Kirsher (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \ 335f844a0eaSJeff Kirsher BFI_ADAPTER_ ## __prop ## _SH) 336f844a0eaSJeff Kirsher #define BFI_ADAPTER_SETP(__prop, __val) \ 337f844a0eaSJeff Kirsher ((__val) << BFI_ADAPTER_ ## __prop ## _SH) 338f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_PROTO(__adap_type) \ 339f844a0eaSJeff Kirsher ((__adap_type) & BFI_ADAPTER_PROTO) 340f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_TTV(__adap_type) \ 341f844a0eaSJeff Kirsher ((__adap_type) & BFI_ADAPTER_TTV) 342f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_UNSUPP(__adap_type) \ 343f844a0eaSJeff Kirsher ((__adap_type) & BFI_ADAPTER_UNSUPP) 344f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_SPECIAL(__adap_type) \ 345f844a0eaSJeff Kirsher ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \ 346f844a0eaSJeff Kirsher BFI_ADAPTER_UNSUPP)) 347f844a0eaSJeff Kirsher 3481aa8b471SBen Hutchings /* BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages */ 349f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_req { 350f844a0eaSJeff Kirsher struct bfi_mhdr mh; 351078086f3SRasesh Mody u16 clscode; 352078086f3SRasesh Mody u16 rsvd; 353f844a0eaSJeff Kirsher u32 tv_sec; 354*e423c856SIvan Vecera } __packed; 355f844a0eaSJeff Kirsher 3561aa8b471SBen Hutchings /* BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages */ 357f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_reply { 358f844a0eaSJeff Kirsher struct bfi_mhdr mh; /*!< Common msg header */ 359f844a0eaSJeff Kirsher u8 status; /*!< enable/disable status */ 360078086f3SRasesh Mody u8 port_mode; /*!< enum bfa_mode */ 361078086f3SRasesh Mody u8 cap_bm; /*!< capability bit mask */ 362078086f3SRasesh Mody u8 rsvd; 363*e423c856SIvan Vecera } __packed; 364f844a0eaSJeff Kirsher 365f844a0eaSJeff Kirsher #define BFI_IOC_MSGSZ 8 3661aa8b471SBen Hutchings /* H2I Messages */ 367f844a0eaSJeff Kirsher union bfi_ioc_h2i_msg_u { 368f844a0eaSJeff Kirsher struct bfi_mhdr mh; 369f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_req enable_req; 370f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_req disable_req; 371f844a0eaSJeff Kirsher struct bfi_ioc_getattr_req getattr_req; 372f844a0eaSJeff Kirsher u32 mboxmsg[BFI_IOC_MSGSZ]; 373*e423c856SIvan Vecera } __packed; 374f844a0eaSJeff Kirsher 3751aa8b471SBen Hutchings /* I2H Messages */ 376f844a0eaSJeff Kirsher union bfi_ioc_i2h_msg_u { 377f844a0eaSJeff Kirsher struct bfi_mhdr mh; 378078086f3SRasesh Mody struct bfi_ioc_ctrl_reply fw_event; 379f844a0eaSJeff Kirsher u32 mboxmsg[BFI_IOC_MSGSZ]; 380*e423c856SIvan Vecera } __packed; 381f844a0eaSJeff Kirsher 3821aa8b471SBen Hutchings /*---------------------------------------------------------------------- 383af027a34SRasesh Mody * MSGQ 384af027a34SRasesh Mody *---------------------------------------------------------------------- 385af027a34SRasesh Mody */ 386af027a34SRasesh Mody 387af027a34SRasesh Mody enum bfi_msgq_h2i_msgs { 388af027a34SRasesh Mody BFI_MSGQ_H2I_INIT_REQ = 1, 389af027a34SRasesh Mody BFI_MSGQ_H2I_DOORBELL_PI = 2, 390af027a34SRasesh Mody BFI_MSGQ_H2I_DOORBELL_CI = 3, 391af027a34SRasesh Mody BFI_MSGQ_H2I_CMDQ_COPY_RSP = 4, 392af027a34SRasesh Mody }; 393af027a34SRasesh Mody 394af027a34SRasesh Mody enum bfi_msgq_i2h_msgs { 395af027a34SRasesh Mody BFI_MSGQ_I2H_INIT_RSP = BFA_I2HM(BFI_MSGQ_H2I_INIT_REQ), 396af027a34SRasesh Mody BFI_MSGQ_I2H_DOORBELL_PI = BFA_I2HM(BFI_MSGQ_H2I_DOORBELL_PI), 397af027a34SRasesh Mody BFI_MSGQ_I2H_DOORBELL_CI = BFA_I2HM(BFI_MSGQ_H2I_DOORBELL_CI), 398af027a34SRasesh Mody BFI_MSGQ_I2H_CMDQ_COPY_REQ = BFA_I2HM(BFI_MSGQ_H2I_CMDQ_COPY_RSP), 399af027a34SRasesh Mody }; 400af027a34SRasesh Mody 401af027a34SRasesh Mody /* Messages(commands/responsed/AENS will have the following header */ 402af027a34SRasesh Mody struct bfi_msgq_mhdr { 403af027a34SRasesh Mody u8 msg_class; 404af027a34SRasesh Mody u8 msg_id; 405af027a34SRasesh Mody u16 msg_token; 406af027a34SRasesh Mody u16 num_entries; 407af027a34SRasesh Mody u8 enet_id; 408af027a34SRasesh Mody u8 rsvd[1]; 409*e423c856SIvan Vecera } __packed; 410af027a34SRasesh Mody 411af027a34SRasesh Mody #define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \ 412af027a34SRasesh Mody (_mh).msg_class = (_mc); \ 413af027a34SRasesh Mody (_mh).msg_id = (_mid); \ 414af027a34SRasesh Mody (_mh).msg_token = (_tok); \ 415af027a34SRasesh Mody (_mh).enet_id = (_enet_id); \ 416af027a34SRasesh Mody } while (0) 417af027a34SRasesh Mody 418af027a34SRasesh Mody /* 419af027a34SRasesh Mody * Mailbox for messaging interface 420af027a34SRasesh Mody */ 421af027a34SRasesh Mody #define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */ 422af027a34SRasesh Mody #define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */ 423af027a34SRasesh Mody 424af027a34SRasesh Mody #define bfi_msgq_num_cmd_entries(_size) \ 425af027a34SRasesh Mody (((_size) + BFI_MSGQ_CMD_ENTRY_SIZE - 1) / BFI_MSGQ_CMD_ENTRY_SIZE) 426af027a34SRasesh Mody 427af027a34SRasesh Mody struct bfi_msgq { 428af027a34SRasesh Mody union bfi_addr_u addr; 429af027a34SRasesh Mody u16 q_depth; /* Total num of entries in the queue */ 430af027a34SRasesh Mody u8 rsvd[2]; 431*e423c856SIvan Vecera } __packed; 432af027a34SRasesh Mody 433af027a34SRasesh Mody /* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */ 434af027a34SRasesh Mody struct bfi_msgq_cfg_req { 435af027a34SRasesh Mody struct bfi_mhdr mh; 436af027a34SRasesh Mody struct bfi_msgq cmdq; 437af027a34SRasesh Mody struct bfi_msgq rspq; 438*e423c856SIvan Vecera } __packed; 439af027a34SRasesh Mody 440af027a34SRasesh Mody /* BFI_ENET_MSGQ_CFG_RSP */ 441af027a34SRasesh Mody struct bfi_msgq_cfg_rsp { 442af027a34SRasesh Mody struct bfi_mhdr mh; 443af027a34SRasesh Mody u8 cmd_status; 444af027a34SRasesh Mody u8 rsvd[3]; 445*e423c856SIvan Vecera } __packed; 446af027a34SRasesh Mody 447af027a34SRasesh Mody /* BFI_MSGQ_H2I_DOORBELL */ 448af027a34SRasesh Mody struct bfi_msgq_h2i_db { 449af027a34SRasesh Mody struct bfi_mhdr mh; 450af027a34SRasesh Mody union { 451af027a34SRasesh Mody u16 cmdq_pi; 452af027a34SRasesh Mody u16 rspq_ci; 453*e423c856SIvan Vecera } __packed idx; 454*e423c856SIvan Vecera } __packed; 455af027a34SRasesh Mody 456af027a34SRasesh Mody /* BFI_MSGQ_I2H_DOORBELL */ 457af027a34SRasesh Mody struct bfi_msgq_i2h_db { 458af027a34SRasesh Mody struct bfi_mhdr mh; 459af027a34SRasesh Mody union { 460af027a34SRasesh Mody u16 rspq_pi; 461af027a34SRasesh Mody u16 cmdq_ci; 462*e423c856SIvan Vecera } __packed idx; 463*e423c856SIvan Vecera } __packed; 464af027a34SRasesh Mody 465af027a34SRasesh Mody #define BFI_CMD_COPY_SZ 28 466af027a34SRasesh Mody 467af027a34SRasesh Mody /* BFI_MSGQ_H2I_CMD_COPY_RSP */ 468af027a34SRasesh Mody struct bfi_msgq_h2i_cmdq_copy_rsp { 469af027a34SRasesh Mody struct bfi_mhdr mh; 470af027a34SRasesh Mody u8 data[BFI_CMD_COPY_SZ]; 471*e423c856SIvan Vecera } __packed; 472af027a34SRasesh Mody 473af027a34SRasesh Mody /* BFI_MSGQ_I2H_CMD_COPY_REQ */ 474af027a34SRasesh Mody struct bfi_msgq_i2h_cmdq_copy_req { 475af027a34SRasesh Mody struct bfi_mhdr mh; 476af027a34SRasesh Mody u16 offset; 477af027a34SRasesh Mody u16 len; 478*e423c856SIvan Vecera } __packed; 479af027a34SRasesh Mody 48072a9730bSKrishna Gudipati /* 48172a9730bSKrishna Gudipati * FLASH module specific 48272a9730bSKrishna Gudipati */ 48372a9730bSKrishna Gudipati enum bfi_flash_h2i_msgs { 48472a9730bSKrishna Gudipati BFI_FLASH_H2I_QUERY_REQ = 1, 48572a9730bSKrishna Gudipati BFI_FLASH_H2I_ERASE_REQ = 2, 48672a9730bSKrishna Gudipati BFI_FLASH_H2I_WRITE_REQ = 3, 48772a9730bSKrishna Gudipati BFI_FLASH_H2I_READ_REQ = 4, 48872a9730bSKrishna Gudipati BFI_FLASH_H2I_BOOT_VER_REQ = 5, 48972a9730bSKrishna Gudipati }; 49072a9730bSKrishna Gudipati 49172a9730bSKrishna Gudipati enum bfi_flash_i2h_msgs { 49272a9730bSKrishna Gudipati BFI_FLASH_I2H_QUERY_RSP = BFA_I2HM(1), 49372a9730bSKrishna Gudipati BFI_FLASH_I2H_ERASE_RSP = BFA_I2HM(2), 49472a9730bSKrishna Gudipati BFI_FLASH_I2H_WRITE_RSP = BFA_I2HM(3), 49572a9730bSKrishna Gudipati BFI_FLASH_I2H_READ_RSP = BFA_I2HM(4), 49672a9730bSKrishna Gudipati BFI_FLASH_I2H_BOOT_VER_RSP = BFA_I2HM(5), 49772a9730bSKrishna Gudipati BFI_FLASH_I2H_EVENT = BFA_I2HM(127), 49872a9730bSKrishna Gudipati }; 49972a9730bSKrishna Gudipati 50072a9730bSKrishna Gudipati /* 50172a9730bSKrishna Gudipati * Flash query request 50272a9730bSKrishna Gudipati */ 50372a9730bSKrishna Gudipati struct bfi_flash_query_req { 50472a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 50572a9730bSKrishna Gudipati struct bfi_alen alen; 506*e423c856SIvan Vecera } __packed; 50772a9730bSKrishna Gudipati 50872a9730bSKrishna Gudipati /* 50972a9730bSKrishna Gudipati * Flash write request 51072a9730bSKrishna Gudipati */ 51172a9730bSKrishna Gudipati struct bfi_flash_write_req { 51272a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 51372a9730bSKrishna Gudipati struct bfi_alen alen; 51472a9730bSKrishna Gudipati u32 type; /* partition type */ 51572a9730bSKrishna Gudipati u8 instance; /* partition instance */ 51672a9730bSKrishna Gudipati u8 last; 51772a9730bSKrishna Gudipati u8 rsv[2]; 51872a9730bSKrishna Gudipati u32 offset; 51972a9730bSKrishna Gudipati u32 length; 520*e423c856SIvan Vecera } __packed; 52172a9730bSKrishna Gudipati 52272a9730bSKrishna Gudipati /* 52372a9730bSKrishna Gudipati * Flash read request 52472a9730bSKrishna Gudipati */ 52572a9730bSKrishna Gudipati struct bfi_flash_read_req { 52672a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 52772a9730bSKrishna Gudipati u32 type; /* partition type */ 52872a9730bSKrishna Gudipati u8 instance; /* partition instance */ 52972a9730bSKrishna Gudipati u8 rsv[3]; 53072a9730bSKrishna Gudipati u32 offset; 53172a9730bSKrishna Gudipati u32 length; 53272a9730bSKrishna Gudipati struct bfi_alen alen; 533*e423c856SIvan Vecera } __packed; 53472a9730bSKrishna Gudipati 53572a9730bSKrishna Gudipati /* 53672a9730bSKrishna Gudipati * Flash query response 53772a9730bSKrishna Gudipati */ 53872a9730bSKrishna Gudipati struct bfi_flash_query_rsp { 53972a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 54072a9730bSKrishna Gudipati u32 status; 541*e423c856SIvan Vecera } __packed; 54272a9730bSKrishna Gudipati 54372a9730bSKrishna Gudipati /* 54472a9730bSKrishna Gudipati * Flash read response 54572a9730bSKrishna Gudipati */ 54672a9730bSKrishna Gudipati struct bfi_flash_read_rsp { 54772a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 54872a9730bSKrishna Gudipati u32 type; /* partition type */ 54972a9730bSKrishna Gudipati u8 instance; /* partition instance */ 55072a9730bSKrishna Gudipati u8 rsv[3]; 55172a9730bSKrishna Gudipati u32 status; 55272a9730bSKrishna Gudipati u32 length; 553*e423c856SIvan Vecera } __packed; 55472a9730bSKrishna Gudipati 55572a9730bSKrishna Gudipati /* 55672a9730bSKrishna Gudipati * Flash write response 55772a9730bSKrishna Gudipati */ 55872a9730bSKrishna Gudipati struct bfi_flash_write_rsp { 55972a9730bSKrishna Gudipati struct bfi_mhdr mh; /* Common msg header */ 56072a9730bSKrishna Gudipati u32 type; /* partition type */ 56172a9730bSKrishna Gudipati u8 instance; /* partition instance */ 56272a9730bSKrishna Gudipati u8 rsv[3]; 56372a9730bSKrishna Gudipati u32 status; 56472a9730bSKrishna Gudipati u32 length; 565*e423c856SIvan Vecera } __packed; 566f844a0eaSJeff Kirsher 567f844a0eaSJeff Kirsher #endif /* __BFI_H__ */ 568