Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
| 3 | * All rights reserved |
| 4 | * www.brocade.com |
| 5 | * |
| 6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License (GPL) Version 2 as |
| 10 | * published by the Free Software Foundation |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __BFI_H__ |
| 19 | #define __BFI_H__ |
| 20 | |
| 21 | #include "bfa_defs.h" |
| 22 | #include "bfa_defs_svc.h" |
| 23 | |
| 24 | #pragma pack(1) |
| 25 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 26 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 27 | * BFI FW image type |
| 28 | */ |
| 29 | #define BFI_FLASH_CHUNK_SZ 256 /* Flash chunk size */ |
| 30 | #define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32)) |
| 31 | enum { |
| 32 | BFI_IMAGE_CB_FC, |
| 33 | BFI_IMAGE_CT_FC, |
| 34 | BFI_IMAGE_CT_CNA, |
| 35 | BFI_IMAGE_MAX, |
| 36 | }; |
| 37 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 38 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 39 | * Msg header common to all msgs |
| 40 | */ |
| 41 | struct bfi_mhdr_s { |
| 42 | u8 msg_class; /* @ref bfi_mclass_t */ |
| 43 | u8 msg_id; /* msg opcode with in the class */ |
| 44 | union { |
| 45 | struct { |
Krishna Gudipati | d37779f | 2011-06-13 15:42:10 -0700 | [diff] [blame^] | 46 | u8 qid; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 47 | u8 lpu_id; /* msg destination */ |
| 48 | } h2i; |
| 49 | u16 i2htok; /* token in msgs to host */ |
| 50 | } mtag; |
| 51 | }; |
| 52 | |
Krishna Gudipati | d37779f | 2011-06-13 15:42:10 -0700 | [diff] [blame^] | 53 | #define bfi_mhdr_2_qid(_mh) (_mh)->mtag.h2i.qid |
| 54 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 55 | #define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \ |
| 56 | (_mh).msg_class = (_mc); \ |
| 57 | (_mh).msg_id = (_op); \ |
| 58 | (_mh).mtag.h2i.lpu_id = (_lpuid); \ |
| 59 | } while (0) |
| 60 | |
| 61 | #define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \ |
| 62 | (_mh).msg_class = (_mc); \ |
| 63 | (_mh).msg_id = (_op); \ |
| 64 | (_mh).mtag.i2htok = (_i2htok); \ |
| 65 | } while (0) |
| 66 | |
| 67 | /* |
| 68 | * Message opcodes: 0-127 to firmware, 128-255 to host |
| 69 | */ |
| 70 | #define BFI_I2H_OPCODE_BASE 128 |
| 71 | #define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE) |
| 72 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 73 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 74 | **************************************************************************** |
| 75 | * |
| 76 | * Scatter Gather Element and Page definition |
| 77 | * |
| 78 | **************************************************************************** |
| 79 | */ |
| 80 | |
| 81 | #define BFI_SGE_INLINE 1 |
| 82 | #define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1) |
| 83 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 84 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 85 | * SG Flags |
| 86 | */ |
| 87 | enum { |
| 88 | BFI_SGE_DATA = 0, /* data address, not last */ |
| 89 | BFI_SGE_DATA_CPL = 1, /* data addr, last in current page */ |
| 90 | BFI_SGE_DATA_LAST = 3, /* data address, last */ |
| 91 | BFI_SGE_LINK = 2, /* link address */ |
| 92 | BFI_SGE_PGDLEN = 2, /* cumulative data length for page */ |
| 93 | }; |
| 94 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 95 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 96 | * DMA addresses |
| 97 | */ |
| 98 | union bfi_addr_u { |
| 99 | struct { |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 100 | __be32 addr_lo; |
| 101 | __be32 addr_hi; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 102 | } a32; |
| 103 | }; |
| 104 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 105 | /* |
Krishna Gudipati | 85ce928 | 2011-06-13 15:39:36 -0700 | [diff] [blame] | 106 | * Scatter Gather Element used for fast-path IO requests |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 107 | */ |
| 108 | struct bfi_sge_s { |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 109 | #ifdef __BIG_ENDIAN |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 110 | u32 flags:2, |
| 111 | rsvd:2, |
| 112 | sg_len:28; |
| 113 | #else |
| 114 | u32 sg_len:28, |
| 115 | rsvd:2, |
| 116 | flags:2; |
| 117 | #endif |
| 118 | union bfi_addr_u sga; |
| 119 | }; |
| 120 | |
Krishna Gudipati | 85ce928 | 2011-06-13 15:39:36 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Generic DMA addr-len pair. |
| 123 | */ |
| 124 | struct bfi_alen_s { |
| 125 | union bfi_addr_u al_addr; /* DMA addr of buffer */ |
| 126 | u32 al_len; /* length of buffer */ |
| 127 | }; |
| 128 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 129 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 130 | * Scatter Gather Page |
| 131 | */ |
| 132 | #define BFI_SGPG_DATA_SGES 7 |
| 133 | #define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1) |
| 134 | #define BFI_SGPG_RSVD_WD_LEN 8 |
| 135 | struct bfi_sgpg_s { |
| 136 | struct bfi_sge_s sges[BFI_SGPG_SGES_MAX]; |
| 137 | u32 rsvd[BFI_SGPG_RSVD_WD_LEN]; |
| 138 | }; |
| 139 | |
| 140 | /* |
| 141 | * Large Message structure - 128 Bytes size Msgs |
| 142 | */ |
| 143 | #define BFI_LMSG_SZ 128 |
| 144 | #define BFI_LMSG_PL_WSZ \ |
| 145 | ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr_s)) / 4) |
| 146 | |
| 147 | struct bfi_msg_s { |
| 148 | struct bfi_mhdr_s mhdr; |
| 149 | u32 pl[BFI_LMSG_PL_WSZ]; |
| 150 | }; |
| 151 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 152 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 153 | * Mailbox message structure |
| 154 | */ |
| 155 | #define BFI_MBMSG_SZ 7 |
| 156 | struct bfi_mbmsg_s { |
| 157 | struct bfi_mhdr_s mh; |
| 158 | u32 pl[BFI_MBMSG_SZ]; |
| 159 | }; |
| 160 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 161 | /* |
Krishna Gudipati | d37779f | 2011-06-13 15:42:10 -0700 | [diff] [blame^] | 162 | * Supported PCI function class codes (personality) |
| 163 | */ |
| 164 | enum bfi_pcifn_class { |
| 165 | BFI_PCIFN_CLASS_FC = 0x0c04, |
| 166 | BFI_PCIFN_CLASS_ETH = 0x0200, |
| 167 | }; |
| 168 | |
| 169 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 170 | * Message Classes |
| 171 | */ |
| 172 | enum bfi_mclass { |
| 173 | BFI_MC_IOC = 1, /* IO Controller (IOC) */ |
| 174 | BFI_MC_FCPORT = 5, /* FC port */ |
| 175 | BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */ |
| 176 | BFI_MC_LL = 7, /* Link Layer */ |
| 177 | BFI_MC_UF = 8, /* Unsolicited frame receive */ |
| 178 | BFI_MC_FCXP = 9, /* FC Transport */ |
| 179 | BFI_MC_LPS = 10, /* lport fc login services */ |
| 180 | BFI_MC_RPORT = 11, /* Remote port */ |
| 181 | BFI_MC_ITNIM = 12, /* I-T nexus (Initiator mode) */ |
| 182 | BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */ |
| 183 | BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */ |
| 184 | BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */ |
| 185 | BFI_MC_IOIM = 16, /* IO (Initiator mode) */ |
| 186 | BFI_MC_IOIM_IOCOM = 17, /* good IO completion */ |
| 187 | BFI_MC_TSKIM = 18, /* Initiator Task management */ |
| 188 | BFI_MC_PORT = 21, /* Physical port */ |
| 189 | BFI_MC_MAX = 32 |
| 190 | }; |
| 191 | |
| 192 | #define BFI_IOC_MAX_CQS 4 |
| 193 | #define BFI_IOC_MAX_CQS_ASIC 8 |
| 194 | #define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */ |
| 195 | |
| 196 | #define BFI_BOOT_TYPE_OFF 8 |
| 197 | #define BFI_BOOT_LOADER_OFF 12 |
| 198 | |
| 199 | #define BFI_BOOT_TYPE_NORMAL 0 |
| 200 | #define BFI_BOOT_TYPE_FLASH 1 |
| 201 | #define BFI_BOOT_TYPE_MEMTEST 2 |
| 202 | |
| 203 | #define BFI_BOOT_LOADER_OS 0 |
| 204 | #define BFI_BOOT_LOADER_BIOS 1 |
| 205 | #define BFI_BOOT_LOADER_UEFI 2 |
| 206 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 207 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 208 | *---------------------------------------------------------------------- |
| 209 | * IOC |
| 210 | *---------------------------------------------------------------------- |
| 211 | */ |
| 212 | |
| 213 | enum bfi_ioc_h2i_msgs { |
| 214 | BFI_IOC_H2I_ENABLE_REQ = 1, |
| 215 | BFI_IOC_H2I_DISABLE_REQ = 2, |
| 216 | BFI_IOC_H2I_GETATTR_REQ = 3, |
| 217 | BFI_IOC_H2I_DBG_SYNC = 4, |
| 218 | BFI_IOC_H2I_DBG_DUMP = 5, |
| 219 | }; |
| 220 | |
| 221 | enum bfi_ioc_i2h_msgs { |
| 222 | BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1), |
| 223 | BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2), |
| 224 | BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3), |
| 225 | BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4), |
| 226 | BFI_IOC_I2H_HBEAT = BFA_I2HM(5), |
| 227 | }; |
| 228 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 229 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 230 | * BFI_IOC_H2I_GETATTR_REQ message |
| 231 | */ |
| 232 | struct bfi_ioc_getattr_req_s { |
| 233 | struct bfi_mhdr_s mh; |
| 234 | union bfi_addr_u attr_addr; |
| 235 | }; |
| 236 | |
| 237 | struct bfi_ioc_attr_s { |
| 238 | wwn_t mfg_pwwn; /* Mfg port wwn */ |
| 239 | wwn_t mfg_nwwn; /* Mfg node wwn */ |
| 240 | mac_t mfg_mac; /* Mfg mac */ |
| 241 | u16 rsvd_a; |
| 242 | wwn_t pwwn; |
| 243 | wwn_t nwwn; |
| 244 | mac_t mac; /* PBC or Mfg mac */ |
| 245 | u16 rsvd_b; |
| 246 | mac_t fcoe_mac; |
| 247 | u16 rsvd_c; |
| 248 | char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)]; |
| 249 | u8 pcie_gen; |
| 250 | u8 pcie_lanes_orig; |
| 251 | u8 pcie_lanes; |
| 252 | u8 rx_bbcredit; /* receive buffer credits */ |
| 253 | u32 adapter_prop; /* adapter properties */ |
| 254 | u16 maxfrsize; /* max receive frame size */ |
| 255 | char asic_rev; |
| 256 | u8 rsvd_d; |
| 257 | char fw_version[BFA_VERSION_LEN]; |
| 258 | char optrom_version[BFA_VERSION_LEN]; |
| 259 | struct bfa_mfg_vpd_s vpd; |
| 260 | u32 card_type; /* card type */ |
| 261 | }; |
| 262 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 263 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 264 | * BFI_IOC_I2H_GETATTR_REPLY message |
| 265 | */ |
| 266 | struct bfi_ioc_getattr_reply_s { |
| 267 | struct bfi_mhdr_s mh; /* Common msg header */ |
| 268 | u8 status; /* cfg reply status */ |
| 269 | u8 rsvd[3]; |
| 270 | }; |
| 271 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 272 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 273 | * Firmware memory page offsets |
| 274 | */ |
| 275 | #define BFI_IOC_SMEM_PG0_CB (0x40) |
| 276 | #define BFI_IOC_SMEM_PG0_CT (0x180) |
| 277 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 278 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 279 | * Firmware statistic offset |
| 280 | */ |
| 281 | #define BFI_IOC_FWSTATS_OFF (0x6B40) |
| 282 | #define BFI_IOC_FWSTATS_SZ (4096) |
| 283 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 284 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 285 | * Firmware trace offset |
| 286 | */ |
| 287 | #define BFI_IOC_TRC_OFF (0x4b00) |
| 288 | #define BFI_IOC_TRC_ENTS 256 |
| 289 | |
| 290 | #define BFI_IOC_FW_SIGNATURE (0xbfadbfad) |
| 291 | #define BFI_IOC_MD5SUM_SZ 4 |
| 292 | struct bfi_ioc_image_hdr_s { |
| 293 | u32 signature; /* constant signature */ |
| 294 | u32 rsvd_a; |
| 295 | u32 exec; /* exec vector */ |
| 296 | u32 param; /* parameters */ |
| 297 | u32 rsvd_b[4]; |
| 298 | u32 md5sum[BFI_IOC_MD5SUM_SZ]; |
| 299 | }; |
| 300 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 301 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 302 | * BFI_IOC_I2H_READY_EVENT message |
| 303 | */ |
| 304 | struct bfi_ioc_rdy_event_s { |
| 305 | struct bfi_mhdr_s mh; /* common msg header */ |
| 306 | u8 init_status; /* init event status */ |
| 307 | u8 rsvd[3]; |
| 308 | }; |
| 309 | |
| 310 | struct bfi_ioc_hbeat_s { |
| 311 | struct bfi_mhdr_s mh; /* common msg header */ |
| 312 | u32 hb_count; /* current heart beat count */ |
| 313 | }; |
| 314 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 315 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 316 | * IOC hardware/firmware state |
| 317 | */ |
| 318 | enum bfi_ioc_state { |
| 319 | BFI_IOC_UNINIT = 0, /* not initialized */ |
| 320 | BFI_IOC_INITING = 1, /* h/w is being initialized */ |
| 321 | BFI_IOC_HWINIT = 2, /* h/w is initialized */ |
| 322 | BFI_IOC_CFG = 3, /* IOC configuration in progress */ |
| 323 | BFI_IOC_OP = 4, /* IOC is operational */ |
| 324 | BFI_IOC_DISABLING = 5, /* IOC is being disabled */ |
| 325 | BFI_IOC_DISABLED = 6, /* IOC is disabled */ |
| 326 | BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */ |
| 327 | BFI_IOC_FAIL = 8, /* IOC heart-beat failure */ |
| 328 | BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */ |
| 329 | }; |
| 330 | |
| 331 | #define BFI_IOC_ENDIAN_SIG 0x12345678 |
| 332 | |
| 333 | enum { |
| 334 | BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */ |
| 335 | BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */ |
| 336 | BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */ |
| 337 | BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */ |
| 338 | BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */ |
| 339 | BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */ |
| 340 | BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */ |
| 341 | BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */ |
| 342 | BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */ |
| 343 | BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */ |
| 344 | }; |
| 345 | |
| 346 | #define BFI_ADAPTER_GETP(__prop, __adap_prop) \ |
| 347 | (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \ |
| 348 | BFI_ADAPTER_ ## __prop ## _SH) |
| 349 | #define BFI_ADAPTER_SETP(__prop, __val) \ |
| 350 | ((__val) << BFI_ADAPTER_ ## __prop ## _SH) |
| 351 | #define BFI_ADAPTER_IS_PROTO(__adap_type) \ |
| 352 | ((__adap_type) & BFI_ADAPTER_PROTO) |
| 353 | #define BFI_ADAPTER_IS_TTV(__adap_type) \ |
| 354 | ((__adap_type) & BFI_ADAPTER_TTV) |
| 355 | #define BFI_ADAPTER_IS_UNSUPP(__adap_type) \ |
| 356 | ((__adap_type) & BFI_ADAPTER_UNSUPP) |
| 357 | #define BFI_ADAPTER_IS_SPECIAL(__adap_type) \ |
| 358 | ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \ |
| 359 | BFI_ADAPTER_UNSUPP)) |
| 360 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 361 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 362 | * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages |
| 363 | */ |
| 364 | struct bfi_ioc_ctrl_req_s { |
| 365 | struct bfi_mhdr_s mh; |
Krishna Gudipati | d37779f | 2011-06-13 15:42:10 -0700 | [diff] [blame^] | 366 | u16 clscode; |
| 367 | u16 rsvd; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 368 | u32 tv_sec; |
| 369 | }; |
| 370 | #define bfi_ioc_enable_req_t struct bfi_ioc_ctrl_req_s; |
| 371 | #define bfi_ioc_disable_req_t struct bfi_ioc_ctrl_req_s; |
| 372 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 373 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 374 | * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages |
| 375 | */ |
| 376 | struct bfi_ioc_ctrl_reply_s { |
| 377 | struct bfi_mhdr_s mh; /* Common msg header */ |
| 378 | u8 status; /* enable/disable status */ |
| 379 | u8 rsvd[3]; |
| 380 | }; |
| 381 | #define bfi_ioc_enable_reply_t struct bfi_ioc_ctrl_reply_s; |
| 382 | #define bfi_ioc_disable_reply_t struct bfi_ioc_ctrl_reply_s; |
| 383 | |
| 384 | #define BFI_IOC_MSGSZ 8 |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 385 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 386 | * H2I Messages |
| 387 | */ |
| 388 | union bfi_ioc_h2i_msg_u { |
| 389 | struct bfi_mhdr_s mh; |
| 390 | struct bfi_ioc_ctrl_req_s enable_req; |
| 391 | struct bfi_ioc_ctrl_req_s disable_req; |
| 392 | struct bfi_ioc_getattr_req_s getattr_req; |
| 393 | u32 mboxmsg[BFI_IOC_MSGSZ]; |
| 394 | }; |
| 395 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 396 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 397 | * I2H Messages |
| 398 | */ |
| 399 | union bfi_ioc_i2h_msg_u { |
| 400 | struct bfi_mhdr_s mh; |
| 401 | struct bfi_ioc_rdy_event_s rdy_event; |
| 402 | u32 mboxmsg[BFI_IOC_MSGSZ]; |
| 403 | }; |
| 404 | |
| 405 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 406 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 407 | *---------------------------------------------------------------------- |
| 408 | * PBC |
| 409 | *---------------------------------------------------------------------- |
| 410 | */ |
| 411 | |
| 412 | #define BFI_PBC_MAX_BLUNS 8 |
| 413 | #define BFI_PBC_MAX_VPORTS 16 |
| 414 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 415 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 416 | * PBC boot lun configuration |
| 417 | */ |
| 418 | struct bfi_pbc_blun_s { |
| 419 | wwn_t tgt_pwwn; |
Maggie Zhang | f314878 | 2010-12-09 19:11:39 -0800 | [diff] [blame] | 420 | struct scsi_lun tgt_lun; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 421 | }; |
| 422 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 423 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 424 | * PBC virtual port configuration |
| 425 | */ |
| 426 | struct bfi_pbc_vport_s { |
| 427 | wwn_t vp_pwwn; |
| 428 | wwn_t vp_nwwn; |
| 429 | }; |
| 430 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 431 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 432 | * BFI pre-boot configuration information |
| 433 | */ |
| 434 | struct bfi_pbc_s { |
| 435 | u8 port_enabled; |
| 436 | u8 boot_enabled; |
| 437 | u8 nbluns; |
| 438 | u8 nvports; |
| 439 | u8 port_speed; |
| 440 | u8 rsvd_a; |
| 441 | u16 hss; |
| 442 | wwn_t pbc_pwwn; |
| 443 | wwn_t pbc_nwwn; |
| 444 | struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS]; |
| 445 | struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS]; |
| 446 | }; |
| 447 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 448 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 449 | *---------------------------------------------------------------------- |
| 450 | * MSGQ |
| 451 | *---------------------------------------------------------------------- |
| 452 | */ |
| 453 | #define BFI_MSGQ_FULL(_q) (((_q->pi + 1) % _q->q_depth) == _q->ci) |
| 454 | #define BFI_MSGQ_EMPTY(_q) (_q->pi == _q->ci) |
| 455 | #define BFI_MSGQ_UPDATE_CI(_q) (_q->ci = (_q->ci + 1) % _q->q_depth) |
| 456 | #define BFI_MSGQ_UPDATE_PI(_q) (_q->pi = (_q->pi + 1) % _q->q_depth) |
| 457 | |
| 458 | /* q_depth must be power of 2 */ |
| 459 | #define BFI_MSGQ_FREE_CNT(_q) ((_q->ci - _q->pi - 1) & (_q->q_depth - 1)) |
| 460 | |
| 461 | enum bfi_msgq_h2i_msgs_e { |
| 462 | BFI_MSGQ_H2I_INIT_REQ = 1, |
| 463 | BFI_MSGQ_H2I_DOORBELL = 2, |
| 464 | BFI_MSGQ_H2I_SHUTDOWN = 3, |
| 465 | }; |
| 466 | |
| 467 | enum bfi_msgq_i2h_msgs_e { |
| 468 | BFI_MSGQ_I2H_INIT_RSP = 1, |
| 469 | BFI_MSGQ_I2H_DOORBELL = 2, |
| 470 | }; |
| 471 | |
| 472 | |
| 473 | /* Messages(commands/responsed/AENS will have the following header */ |
| 474 | struct bfi_msgq_mhdr_s { |
| 475 | u8 msg_class; |
| 476 | u8 msg_id; |
| 477 | u16 msg_token; |
| 478 | u16 num_entries; |
| 479 | u8 enet_id; |
| 480 | u8 rsvd[1]; |
| 481 | }; |
| 482 | |
| 483 | #define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \ |
| 484 | (_mh).msg_class = (_mc); \ |
| 485 | (_mh).msg_id = (_mid); \ |
| 486 | (_mh).msg_token = (_tok); \ |
| 487 | (_mh).enet_id = (_enet_id); \ |
| 488 | } while (0) |
| 489 | |
| 490 | /* |
| 491 | * Mailbox for messaging interface |
| 492 | * |
| 493 | */ |
| 494 | #define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */ |
| 495 | #define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */ |
| 496 | #define BFI_MSGQ_MSG_SIZE_MAX (2048) /* TBD */ |
| 497 | |
| 498 | struct bfi_msgq_s { |
| 499 | union bfi_addr_u addr; |
| 500 | u16 q_depth; /* Total num of entries in the queue */ |
| 501 | u8 rsvd[2]; |
| 502 | }; |
| 503 | |
| 504 | /* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */ |
| 505 | struct bfi_msgq_cfg_req_s { |
| 506 | struct bfi_mhdr_s mh; |
| 507 | struct bfi_msgq_s cmdq; |
| 508 | struct bfi_msgq_s rspq; |
| 509 | }; |
| 510 | |
| 511 | /* BFI_ENET_MSGQ_CFG_RSP */ |
| 512 | struct bfi_msgq_cfg_rsp_s { |
| 513 | struct bfi_mhdr_s mh; |
| 514 | u8 cmd_status; |
| 515 | u8 rsvd[3]; |
| 516 | }; |
| 517 | |
| 518 | |
| 519 | /* BFI_MSGQ_H2I_DOORBELL */ |
| 520 | struct bfi_msgq_h2i_db_s { |
| 521 | struct bfi_mhdr_s mh; |
| 522 | u16 cmdq_pi; |
| 523 | u16 rspq_ci; |
| 524 | }; |
| 525 | |
| 526 | /* BFI_MSGQ_I2H_DOORBELL */ |
| 527 | struct bfi_msgq_i2h_db_s { |
| 528 | struct bfi_mhdr_s mh; |
| 529 | u16 rspq_pi; |
| 530 | u16 cmdq_ci; |
| 531 | }; |
| 532 | |
| 533 | #pragma pack() |
| 534 | |
| 535 | /* BFI port specific */ |
| 536 | #pragma pack(1) |
| 537 | |
| 538 | enum bfi_port_h2i { |
| 539 | BFI_PORT_H2I_ENABLE_REQ = (1), |
| 540 | BFI_PORT_H2I_DISABLE_REQ = (2), |
| 541 | BFI_PORT_H2I_GET_STATS_REQ = (3), |
| 542 | BFI_PORT_H2I_CLEAR_STATS_REQ = (4), |
| 543 | }; |
| 544 | |
| 545 | enum bfi_port_i2h { |
| 546 | BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1), |
| 547 | BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2), |
| 548 | BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3), |
| 549 | BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4), |
| 550 | }; |
| 551 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 552 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 553 | * Generic REQ type |
| 554 | */ |
| 555 | struct bfi_port_generic_req_s { |
| 556 | struct bfi_mhdr_s mh; /* msg header */ |
| 557 | u32 msgtag; /* msgtag for reply */ |
| 558 | u32 rsvd; |
| 559 | }; |
| 560 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 561 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 562 | * Generic RSP type |
| 563 | */ |
| 564 | struct bfi_port_generic_rsp_s { |
| 565 | struct bfi_mhdr_s mh; /* common msg header */ |
| 566 | u8 status; /* port enable status */ |
| 567 | u8 rsvd[3]; |
| 568 | u32 msgtag; /* msgtag for reply */ |
| 569 | }; |
| 570 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 571 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 572 | * BFI_PORT_H2I_GET_STATS_REQ |
| 573 | */ |
| 574 | struct bfi_port_get_stats_req_s { |
| 575 | struct bfi_mhdr_s mh; /* common msg header */ |
| 576 | union bfi_addr_u dma_addr; |
| 577 | }; |
| 578 | |
| 579 | union bfi_port_h2i_msg_u { |
| 580 | struct bfi_mhdr_s mh; |
| 581 | struct bfi_port_generic_req_s enable_req; |
| 582 | struct bfi_port_generic_req_s disable_req; |
| 583 | struct bfi_port_get_stats_req_s getstats_req; |
| 584 | struct bfi_port_generic_req_s clearstats_req; |
| 585 | }; |
| 586 | |
| 587 | union bfi_port_i2h_msg_u { |
| 588 | struct bfi_mhdr_s mh; |
| 589 | struct bfi_port_generic_rsp_s enable_rsp; |
| 590 | struct bfi_port_generic_rsp_s disable_rsp; |
| 591 | struct bfi_port_generic_rsp_s getstats_rsp; |
| 592 | struct bfi_port_generic_rsp_s clearstats_rsp; |
| 593 | }; |
| 594 | |
| 595 | #pragma pack() |
| 596 | |
| 597 | #endif /* __BFI_H__ */ |