bfi.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  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. #ifndef __BFI_H__
  18. #define __BFI_H__
  19. #include "bfa_defs.h"
  20. #include "bfa_defs_svc.h"
  21. #pragma pack(1)
  22. /* Per dma segment max size */
  23. #define BFI_MEM_DMA_SEG_SZ (131072)
  24. /* Get number of dma segments required */
  25. #define BFI_MEM_DMA_NSEGS(_num_reqs, _req_sz) \
  26. ((u16)(((((_num_reqs) * (_req_sz)) + BFI_MEM_DMA_SEG_SZ - 1) & \
  27. ~(BFI_MEM_DMA_SEG_SZ - 1)) / BFI_MEM_DMA_SEG_SZ))
  28. /* Get num dma reqs - that fit in a segment */
  29. #define BFI_MEM_NREQS_SEG(_rqsz) (BFI_MEM_DMA_SEG_SZ / (_rqsz))
  30. /* Get segment num from tag */
  31. #define BFI_MEM_SEG_FROM_TAG(_tag, _rqsz) ((_tag) / BFI_MEM_NREQS_SEG(_rqsz))
  32. /* Get dma req offset in a segment */
  33. #define BFI_MEM_SEG_REQ_OFFSET(_tag, _sz) \
  34. ((_tag) - (BFI_MEM_SEG_FROM_TAG(_tag, _sz) * BFI_MEM_NREQS_SEG(_sz)))
  35. /*
  36. * BFI FW image type
  37. */
  38. #define BFI_FLASH_CHUNK_SZ 256 /* Flash chunk size */
  39. #define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
  40. /*
  41. * Msg header common to all msgs
  42. */
  43. struct bfi_mhdr_s {
  44. u8 msg_class; /* @ref bfi_mclass_t */
  45. u8 msg_id; /* msg opcode with in the class */
  46. union {
  47. struct {
  48. u8 qid;
  49. u8 fn_lpu; /* msg destination */
  50. } h2i;
  51. u16 i2htok; /* token in msgs to host */
  52. } mtag;
  53. };
  54. #define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu))
  55. #define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1)
  56. #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \
  57. (_mh).msg_class = (_mc); \
  58. (_mh).msg_id = (_op); \
  59. (_mh).mtag.h2i.fn_lpu = (_fn_lpu); \
  60. } while (0)
  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. * Message opcodes: 0-127 to firmware, 128-255 to host
  68. */
  69. #define BFI_I2H_OPCODE_BASE 128
  70. #define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
  71. /*
  72. ****************************************************************************
  73. *
  74. * Scatter Gather Element and Page definition
  75. *
  76. ****************************************************************************
  77. */
  78. #define BFI_SGE_INLINE 1
  79. #define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1)
  80. /*
  81. * SG Flags
  82. */
  83. enum {
  84. BFI_SGE_DATA = 0, /* data address, not last */
  85. BFI_SGE_DATA_CPL = 1, /* data addr, last in current page */
  86. BFI_SGE_DATA_LAST = 3, /* data address, last */
  87. BFI_SGE_LINK = 2, /* link address */
  88. BFI_SGE_PGDLEN = 2, /* cumulative data length for page */
  89. };
  90. /*
  91. * DMA addresses
  92. */
  93. union bfi_addr_u {
  94. struct {
  95. __be32 addr_lo;
  96. __be32 addr_hi;
  97. } a32;
  98. };
  99. /*
  100. * Scatter Gather Element used for fast-path IO requests
  101. */
  102. struct bfi_sge_s {
  103. #ifdef __BIG_ENDIAN
  104. u32 flags:2,
  105. rsvd:2,
  106. sg_len:28;
  107. #else
  108. u32 sg_len:28,
  109. rsvd:2,
  110. flags:2;
  111. #endif
  112. union bfi_addr_u sga;
  113. };
  114. /**
  115. * Generic DMA addr-len pair.
  116. */
  117. struct bfi_alen_s {
  118. union bfi_addr_u al_addr; /* DMA addr of buffer */
  119. u32 al_len; /* length of buffer */
  120. };
  121. /*
  122. * Scatter Gather Page
  123. */
  124. #define BFI_SGPG_DATA_SGES 7
  125. #define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1)
  126. #define BFI_SGPG_RSVD_WD_LEN 8
  127. struct bfi_sgpg_s {
  128. struct bfi_sge_s sges[BFI_SGPG_SGES_MAX];
  129. u32 rsvd[BFI_SGPG_RSVD_WD_LEN];
  130. };
  131. /* FCP module definitions */
  132. #define BFI_IO_MAX (2000)
  133. #define BFI_IOIM_SNSLEN (256)
  134. #define BFI_IOIM_SNSBUF_SEGS \
  135. BFI_MEM_DMA_NSEGS(BFI_IO_MAX, BFI_IOIM_SNSLEN)
  136. /*
  137. * Large Message structure - 128 Bytes size Msgs
  138. */
  139. #define BFI_LMSG_SZ 128
  140. #define BFI_LMSG_PL_WSZ \
  141. ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr_s)) / 4)
  142. struct bfi_msg_s {
  143. struct bfi_mhdr_s mhdr;
  144. u32 pl[BFI_LMSG_PL_WSZ];
  145. };
  146. /*
  147. * Mailbox message structure
  148. */
  149. #define BFI_MBMSG_SZ 7
  150. struct bfi_mbmsg_s {
  151. struct bfi_mhdr_s mh;
  152. u32 pl[BFI_MBMSG_SZ];
  153. };
  154. /*
  155. * Supported PCI function class codes (personality)
  156. */
  157. enum bfi_pcifn_class {
  158. BFI_PCIFN_CLASS_FC = 0x0c04,
  159. BFI_PCIFN_CLASS_ETH = 0x0200,
  160. };
  161. /*
  162. * Message Classes
  163. */
  164. enum bfi_mclass {
  165. BFI_MC_IOC = 1, /* IO Controller (IOC) */
  166. BFI_MC_DIAG = 2, /* Diagnostic Msgs */
  167. BFI_MC_FLASH = 3, /* Flash message class */
  168. BFI_MC_CEE = 4, /* CEE */
  169. BFI_MC_FCPORT = 5, /* FC port */
  170. BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */
  171. BFI_MC_ABLK = 7, /* ASIC block configuration */
  172. BFI_MC_UF = 8, /* Unsolicited frame receive */
  173. BFI_MC_FCXP = 9, /* FC Transport */
  174. BFI_MC_LPS = 10, /* lport fc login services */
  175. BFI_MC_RPORT = 11, /* Remote port */
  176. BFI_MC_ITN = 12, /* I-T nexus (Initiator mode) */
  177. BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */
  178. BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */
  179. BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */
  180. BFI_MC_IOIM = 16, /* IO (Initiator mode) */
  181. BFI_MC_IOIM_IOCOM = 17, /* good IO completion */
  182. BFI_MC_TSKIM = 18, /* Initiator Task management */
  183. BFI_MC_PORT = 21, /* Physical port */
  184. BFI_MC_SFP = 22, /* SFP module */
  185. BFI_MC_MAX = 32
  186. };
  187. #define BFI_IOC_MAX_CQS 4
  188. #define BFI_IOC_MAX_CQS_ASIC 8
  189. #define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
  190. /*
  191. *----------------------------------------------------------------------
  192. * IOC
  193. *----------------------------------------------------------------------
  194. */
  195. /*
  196. * Different asic generations
  197. */
  198. enum bfi_asic_gen {
  199. BFI_ASIC_GEN_CB = 1, /* crossbow 8G FC */
  200. BFI_ASIC_GEN_CT = 2, /* catapult 8G FC or 10G CNA */
  201. BFI_ASIC_GEN_CT2 = 3, /* catapult-2 16G FC or 10G CNA */
  202. };
  203. enum bfi_asic_mode {
  204. BFI_ASIC_MODE_FC = 1, /* FC upto 8G speed */
  205. BFI_ASIC_MODE_FC16 = 2, /* FC upto 16G speed */
  206. BFI_ASIC_MODE_ETH = 3, /* Ethernet ports */
  207. BFI_ASIC_MODE_COMBO = 4, /* FC 16G and Ethernet 10G port */
  208. };
  209. enum bfi_ioc_h2i_msgs {
  210. BFI_IOC_H2I_ENABLE_REQ = 1,
  211. BFI_IOC_H2I_DISABLE_REQ = 2,
  212. BFI_IOC_H2I_GETATTR_REQ = 3,
  213. BFI_IOC_H2I_DBG_SYNC = 4,
  214. BFI_IOC_H2I_DBG_DUMP = 5,
  215. };
  216. enum bfi_ioc_i2h_msgs {
  217. BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
  218. BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
  219. BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
  220. BFI_IOC_I2H_HBEAT = BFA_I2HM(4),
  221. BFI_IOC_I2H_ACQ_ADDR_REPLY = BFA_I2HM(5),
  222. };
  223. /*
  224. * BFI_IOC_H2I_GETATTR_REQ message
  225. */
  226. struct bfi_ioc_getattr_req_s {
  227. struct bfi_mhdr_s mh;
  228. union bfi_addr_u attr_addr;
  229. };
  230. struct bfi_ioc_attr_s {
  231. wwn_t mfg_pwwn; /* Mfg port wwn */
  232. wwn_t mfg_nwwn; /* Mfg node wwn */
  233. mac_t mfg_mac; /* Mfg mac */
  234. u8 port_mode; /* bfi_port_mode */
  235. u8 rsvd_a;
  236. wwn_t pwwn;
  237. wwn_t nwwn;
  238. mac_t mac; /* PBC or Mfg mac */
  239. u16 rsvd_b;
  240. mac_t fcoe_mac;
  241. u16 rsvd_c;
  242. char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
  243. u8 pcie_gen;
  244. u8 pcie_lanes_orig;
  245. u8 pcie_lanes;
  246. u8 rx_bbcredit; /* receive buffer credits */
  247. u32 adapter_prop; /* adapter properties */
  248. u16 maxfrsize; /* max receive frame size */
  249. char asic_rev;
  250. u8 rsvd_d;
  251. char fw_version[BFA_VERSION_LEN];
  252. char optrom_version[BFA_VERSION_LEN];
  253. struct bfa_mfg_vpd_s vpd;
  254. u32 card_type; /* card type */
  255. };
  256. /*
  257. * BFI_IOC_I2H_GETATTR_REPLY message
  258. */
  259. struct bfi_ioc_getattr_reply_s {
  260. struct bfi_mhdr_s mh; /* Common msg header */
  261. u8 status; /* cfg reply status */
  262. u8 rsvd[3];
  263. };
  264. /*
  265. * Firmware memory page offsets
  266. */
  267. #define BFI_IOC_SMEM_PG0_CB (0x40)
  268. #define BFI_IOC_SMEM_PG0_CT (0x180)
  269. /*
  270. * Firmware statistic offset
  271. */
  272. #define BFI_IOC_FWSTATS_OFF (0x6B40)
  273. #define BFI_IOC_FWSTATS_SZ (4096)
  274. /*
  275. * Firmware trace offset
  276. */
  277. #define BFI_IOC_TRC_OFF (0x4b00)
  278. #define BFI_IOC_TRC_ENTS 256
  279. #define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
  280. #define BFI_IOC_MD5SUM_SZ 4
  281. struct bfi_ioc_image_hdr_s {
  282. u32 signature; /* constant signature */
  283. u8 asic_gen; /* asic generation */
  284. u8 asic_mode;
  285. u8 port0_mode; /* device mode for port 0 */
  286. u8 port1_mode; /* device mode for port 1 */
  287. u32 exec; /* exec vector */
  288. u32 bootenv; /* fimware boot env */
  289. u32 rsvd_b[4];
  290. u32 md5sum[BFI_IOC_MD5SUM_SZ];
  291. };
  292. #define BFI_FWBOOT_DEVMODE_OFF 4
  293. #define BFI_FWBOOT_TYPE_OFF 8
  294. #define BFI_FWBOOT_ENV_OFF 12
  295. #define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \
  296. (((u32)(__asic_gen)) << 24 | \
  297. ((u32)(__asic_mode)) << 16 | \
  298. ((u32)(__p0_mode)) << 8 | \
  299. ((u32)(__p1_mode)))
  300. #define BFI_FWBOOT_TYPE_NORMAL 0
  301. #define BFI_FWBOOT_TYPE_MEMTEST 2
  302. #define BFI_FWBOOT_ENV_OS 0
  303. enum bfi_port_mode {
  304. BFI_PORT_MODE_FC = 1,
  305. BFI_PORT_MODE_ETH = 2,
  306. };
  307. struct bfi_ioc_hbeat_s {
  308. struct bfi_mhdr_s mh; /* common msg header */
  309. u32 hb_count; /* current heart beat count */
  310. };
  311. /*
  312. * IOC hardware/firmware state
  313. */
  314. enum bfi_ioc_state {
  315. BFI_IOC_UNINIT = 0, /* not initialized */
  316. BFI_IOC_INITING = 1, /* h/w is being initialized */
  317. BFI_IOC_HWINIT = 2, /* h/w is initialized */
  318. BFI_IOC_CFG = 3, /* IOC configuration in progress */
  319. BFI_IOC_OP = 4, /* IOC is operational */
  320. BFI_IOC_DISABLING = 5, /* IOC is being disabled */
  321. BFI_IOC_DISABLED = 6, /* IOC is disabled */
  322. BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */
  323. BFI_IOC_FAIL = 8, /* IOC heart-beat failure */
  324. BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */
  325. };
  326. #define BFI_IOC_ENDIAN_SIG 0x12345678
  327. enum {
  328. BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */
  329. BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */
  330. BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */
  331. BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */
  332. BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */
  333. BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */
  334. BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */
  335. BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */
  336. BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */
  337. BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */
  338. };
  339. #define BFI_ADAPTER_GETP(__prop, __adap_prop) \
  340. (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
  341. BFI_ADAPTER_ ## __prop ## _SH)
  342. #define BFI_ADAPTER_SETP(__prop, __val) \
  343. ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
  344. #define BFI_ADAPTER_IS_PROTO(__adap_type) \
  345. ((__adap_type) & BFI_ADAPTER_PROTO)
  346. #define BFI_ADAPTER_IS_TTV(__adap_type) \
  347. ((__adap_type) & BFI_ADAPTER_TTV)
  348. #define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
  349. ((__adap_type) & BFI_ADAPTER_UNSUPP)
  350. #define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
  351. ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
  352. BFI_ADAPTER_UNSUPP))
  353. /*
  354. * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
  355. */
  356. struct bfi_ioc_ctrl_req_s {
  357. struct bfi_mhdr_s mh;
  358. u16 clscode;
  359. u16 rsvd;
  360. u32 tv_sec;
  361. };
  362. #define bfi_ioc_enable_req_t struct bfi_ioc_ctrl_req_s;
  363. #define bfi_ioc_disable_req_t struct bfi_ioc_ctrl_req_s;
  364. /*
  365. * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
  366. */
  367. struct bfi_ioc_ctrl_reply_s {
  368. struct bfi_mhdr_s mh; /* Common msg header */
  369. u8 status; /* enable/disable status */
  370. u8 port_mode; /* bfa_mode_s */
  371. u8 cap_bm; /* capability bit mask */
  372. u8 rsvd;
  373. };
  374. #define bfi_ioc_enable_reply_t struct bfi_ioc_ctrl_reply_s;
  375. #define bfi_ioc_disable_reply_t struct bfi_ioc_ctrl_reply_s;
  376. #define BFI_IOC_MSGSZ 8
  377. /*
  378. * H2I Messages
  379. */
  380. union bfi_ioc_h2i_msg_u {
  381. struct bfi_mhdr_s mh;
  382. struct bfi_ioc_ctrl_req_s enable_req;
  383. struct bfi_ioc_ctrl_req_s disable_req;
  384. struct bfi_ioc_getattr_req_s getattr_req;
  385. u32 mboxmsg[BFI_IOC_MSGSZ];
  386. };
  387. /*
  388. * I2H Messages
  389. */
  390. union bfi_ioc_i2h_msg_u {
  391. struct bfi_mhdr_s mh;
  392. struct bfi_ioc_ctrl_reply_s fw_event;
  393. u32 mboxmsg[BFI_IOC_MSGSZ];
  394. };
  395. /*
  396. *----------------------------------------------------------------------
  397. * PBC
  398. *----------------------------------------------------------------------
  399. */
  400. #define BFI_PBC_MAX_BLUNS 8
  401. #define BFI_PBC_MAX_VPORTS 16
  402. #define BFI_PBC_PORT_DISABLED 2
  403. /*
  404. * PBC boot lun configuration
  405. */
  406. struct bfi_pbc_blun_s {
  407. wwn_t tgt_pwwn;
  408. struct scsi_lun tgt_lun;
  409. };
  410. /*
  411. * PBC virtual port configuration
  412. */
  413. struct bfi_pbc_vport_s {
  414. wwn_t vp_pwwn;
  415. wwn_t vp_nwwn;
  416. };
  417. /*
  418. * BFI pre-boot configuration information
  419. */
  420. struct bfi_pbc_s {
  421. u8 port_enabled;
  422. u8 boot_enabled;
  423. u8 nbluns;
  424. u8 nvports;
  425. u8 port_speed;
  426. u8 rsvd_a;
  427. u16 hss;
  428. wwn_t pbc_pwwn;
  429. wwn_t pbc_nwwn;
  430. struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS];
  431. struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS];
  432. };
  433. /*
  434. *----------------------------------------------------------------------
  435. * MSGQ
  436. *----------------------------------------------------------------------
  437. */
  438. #define BFI_MSGQ_FULL(_q) (((_q->pi + 1) % _q->q_depth) == _q->ci)
  439. #define BFI_MSGQ_EMPTY(_q) (_q->pi == _q->ci)
  440. #define BFI_MSGQ_UPDATE_CI(_q) (_q->ci = (_q->ci + 1) % _q->q_depth)
  441. #define BFI_MSGQ_UPDATE_PI(_q) (_q->pi = (_q->pi + 1) % _q->q_depth)
  442. /* q_depth must be power of 2 */
  443. #define BFI_MSGQ_FREE_CNT(_q) ((_q->ci - _q->pi - 1) & (_q->q_depth - 1))
  444. enum bfi_msgq_h2i_msgs_e {
  445. BFI_MSGQ_H2I_INIT_REQ = 1,
  446. BFI_MSGQ_H2I_DOORBELL = 2,
  447. BFI_MSGQ_H2I_SHUTDOWN = 3,
  448. };
  449. enum bfi_msgq_i2h_msgs_e {
  450. BFI_MSGQ_I2H_INIT_RSP = 1,
  451. BFI_MSGQ_I2H_DOORBELL = 2,
  452. };
  453. /* Messages(commands/responsed/AENS will have the following header */
  454. struct bfi_msgq_mhdr_s {
  455. u8 msg_class;
  456. u8 msg_id;
  457. u16 msg_token;
  458. u16 num_entries;
  459. u8 enet_id;
  460. u8 rsvd[1];
  461. };
  462. #define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \
  463. (_mh).msg_class = (_mc); \
  464. (_mh).msg_id = (_mid); \
  465. (_mh).msg_token = (_tok); \
  466. (_mh).enet_id = (_enet_id); \
  467. } while (0)
  468. /*
  469. * Mailbox for messaging interface
  470. *
  471. */
  472. #define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */
  473. #define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */
  474. #define BFI_MSGQ_MSG_SIZE_MAX (2048) /* TBD */
  475. struct bfi_msgq_s {
  476. union bfi_addr_u addr;
  477. u16 q_depth; /* Total num of entries in the queue */
  478. u8 rsvd[2];
  479. };
  480. /* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
  481. struct bfi_msgq_cfg_req_s {
  482. struct bfi_mhdr_s mh;
  483. struct bfi_msgq_s cmdq;
  484. struct bfi_msgq_s rspq;
  485. };
  486. /* BFI_ENET_MSGQ_CFG_RSP */
  487. struct bfi_msgq_cfg_rsp_s {
  488. struct bfi_mhdr_s mh;
  489. u8 cmd_status;
  490. u8 rsvd[3];
  491. };
  492. /* BFI_MSGQ_H2I_DOORBELL */
  493. struct bfi_msgq_h2i_db_s {
  494. struct bfi_mhdr_s mh;
  495. u16 cmdq_pi;
  496. u16 rspq_ci;
  497. };
  498. /* BFI_MSGQ_I2H_DOORBELL */
  499. struct bfi_msgq_i2h_db_s {
  500. struct bfi_mhdr_s mh;
  501. u16 rspq_pi;
  502. u16 cmdq_ci;
  503. };
  504. #pragma pack()
  505. /* BFI port specific */
  506. #pragma pack(1)
  507. enum bfi_port_h2i {
  508. BFI_PORT_H2I_ENABLE_REQ = (1),
  509. BFI_PORT_H2I_DISABLE_REQ = (2),
  510. BFI_PORT_H2I_GET_STATS_REQ = (3),
  511. BFI_PORT_H2I_CLEAR_STATS_REQ = (4),
  512. };
  513. enum bfi_port_i2h {
  514. BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1),
  515. BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2),
  516. BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3),
  517. BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4),
  518. };
  519. /*
  520. * Generic REQ type
  521. */
  522. struct bfi_port_generic_req_s {
  523. struct bfi_mhdr_s mh; /* msg header */
  524. u32 msgtag; /* msgtag for reply */
  525. u32 rsvd;
  526. };
  527. /*
  528. * Generic RSP type
  529. */
  530. struct bfi_port_generic_rsp_s {
  531. struct bfi_mhdr_s mh; /* common msg header */
  532. u8 status; /* port enable status */
  533. u8 rsvd[3];
  534. u32 msgtag; /* msgtag for reply */
  535. };
  536. /*
  537. * BFI_PORT_H2I_GET_STATS_REQ
  538. */
  539. struct bfi_port_get_stats_req_s {
  540. struct bfi_mhdr_s mh; /* common msg header */
  541. union bfi_addr_u dma_addr;
  542. };
  543. union bfi_port_h2i_msg_u {
  544. struct bfi_mhdr_s mh;
  545. struct bfi_port_generic_req_s enable_req;
  546. struct bfi_port_generic_req_s disable_req;
  547. struct bfi_port_get_stats_req_s getstats_req;
  548. struct bfi_port_generic_req_s clearstats_req;
  549. };
  550. union bfi_port_i2h_msg_u {
  551. struct bfi_mhdr_s mh;
  552. struct bfi_port_generic_rsp_s enable_rsp;
  553. struct bfi_port_generic_rsp_s disable_rsp;
  554. struct bfi_port_generic_rsp_s getstats_rsp;
  555. struct bfi_port_generic_rsp_s clearstats_rsp;
  556. };
  557. /*
  558. *----------------------------------------------------------------------
  559. * ABLK
  560. *----------------------------------------------------------------------
  561. */
  562. enum bfi_ablk_h2i_msgs_e {
  563. BFI_ABLK_H2I_QUERY = 1,
  564. BFI_ABLK_H2I_ADPT_CONFIG = 2,
  565. BFI_ABLK_H2I_PORT_CONFIG = 3,
  566. BFI_ABLK_H2I_PF_CREATE = 4,
  567. BFI_ABLK_H2I_PF_DELETE = 5,
  568. BFI_ABLK_H2I_PF_UPDATE = 6,
  569. BFI_ABLK_H2I_OPTROM_ENABLE = 7,
  570. BFI_ABLK_H2I_OPTROM_DISABLE = 8,
  571. };
  572. enum bfi_ablk_i2h_msgs_e {
  573. BFI_ABLK_I2H_QUERY = BFA_I2HM(BFI_ABLK_H2I_QUERY),
  574. BFI_ABLK_I2H_ADPT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_ADPT_CONFIG),
  575. BFI_ABLK_I2H_PORT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_PORT_CONFIG),
  576. BFI_ABLK_I2H_PF_CREATE = BFA_I2HM(BFI_ABLK_H2I_PF_CREATE),
  577. BFI_ABLK_I2H_PF_DELETE = BFA_I2HM(BFI_ABLK_H2I_PF_DELETE),
  578. BFI_ABLK_I2H_PF_UPDATE = BFA_I2HM(BFI_ABLK_H2I_PF_UPDATE),
  579. BFI_ABLK_I2H_OPTROM_ENABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_ENABLE),
  580. BFI_ABLK_I2H_OPTROM_DISABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_DISABLE),
  581. };
  582. /* BFI_ABLK_H2I_QUERY */
  583. struct bfi_ablk_h2i_query_s {
  584. struct bfi_mhdr_s mh;
  585. union bfi_addr_u addr;
  586. };
  587. /* BFI_ABL_H2I_ADPT_CONFIG, BFI_ABLK_H2I_PORT_CONFIG */
  588. struct bfi_ablk_h2i_cfg_req_s {
  589. struct bfi_mhdr_s mh;
  590. u8 mode;
  591. u8 port;
  592. u8 max_pf;
  593. u8 max_vf;
  594. };
  595. /*
  596. * BFI_ABLK_H2I_PF_CREATE, BFI_ABLK_H2I_PF_DELETE,
  597. */
  598. struct bfi_ablk_h2i_pf_req_s {
  599. struct bfi_mhdr_s mh;
  600. u8 pcifn;
  601. u8 port;
  602. u16 pers;
  603. u32 bw;
  604. };
  605. /* BFI_ABLK_H2I_OPTROM_ENABLE, BFI_ABLK_H2I_OPTROM_DISABLE */
  606. struct bfi_ablk_h2i_optrom_s {
  607. struct bfi_mhdr_s mh;
  608. };
  609. /*
  610. * BFI_ABLK_I2H_QUERY
  611. * BFI_ABLK_I2H_PORT_CONFIG
  612. * BFI_ABLK_I2H_PF_CREATE
  613. * BFI_ABLK_I2H_PF_DELETE
  614. * BFI_ABLK_I2H_PF_UPDATE
  615. * BFI_ABLK_I2H_OPTROM_ENABLE
  616. * BFI_ABLK_I2H_OPTROM_DISABLE
  617. */
  618. struct bfi_ablk_i2h_rsp_s {
  619. struct bfi_mhdr_s mh;
  620. u8 status;
  621. u8 pcifn;
  622. u8 port_mode;
  623. };
  624. /*
  625. * CEE module specific messages
  626. */
  627. /* Mailbox commands from host to firmware */
  628. enum bfi_cee_h2i_msgs_e {
  629. BFI_CEE_H2I_GET_CFG_REQ = 1,
  630. BFI_CEE_H2I_RESET_STATS = 2,
  631. BFI_CEE_H2I_GET_STATS_REQ = 3,
  632. };
  633. enum bfi_cee_i2h_msgs_e {
  634. BFI_CEE_I2H_GET_CFG_RSP = BFA_I2HM(1),
  635. BFI_CEE_I2H_RESET_STATS_RSP = BFA_I2HM(2),
  636. BFI_CEE_I2H_GET_STATS_RSP = BFA_I2HM(3),
  637. };
  638. /*
  639. * H2I command structure for resetting the stats
  640. */
  641. struct bfi_cee_reset_stats_s {
  642. struct bfi_mhdr_s mh;
  643. };
  644. /*
  645. * Get configuration command from host
  646. */
  647. struct bfi_cee_get_req_s {
  648. struct bfi_mhdr_s mh;
  649. union bfi_addr_u dma_addr;
  650. };
  651. /*
  652. * Reply message from firmware
  653. */
  654. struct bfi_cee_get_rsp_s {
  655. struct bfi_mhdr_s mh;
  656. u8 cmd_status;
  657. u8 rsvd[3];
  658. };
  659. /*
  660. * Reply message from firmware
  661. */
  662. struct bfi_cee_stats_rsp_s {
  663. struct bfi_mhdr_s mh;
  664. u8 cmd_status;
  665. u8 rsvd[3];
  666. };
  667. /* Mailbox message structures from firmware to host */
  668. union bfi_cee_i2h_msg_u {
  669. struct bfi_mhdr_s mh;
  670. struct bfi_cee_get_rsp_s get_rsp;
  671. struct bfi_cee_stats_rsp_s stats_rsp;
  672. };
  673. /*
  674. * SFP related
  675. */
  676. enum bfi_sfp_h2i_e {
  677. BFI_SFP_H2I_SHOW = 1,
  678. BFI_SFP_H2I_SCN = 2,
  679. };
  680. enum bfi_sfp_i2h_e {
  681. BFI_SFP_I2H_SHOW = BFA_I2HM(BFI_SFP_H2I_SHOW),
  682. BFI_SFP_I2H_SCN = BFA_I2HM(BFI_SFP_H2I_SCN),
  683. };
  684. /*
  685. * SFP state
  686. */
  687. enum bfa_sfp_stat_e {
  688. BFA_SFP_STATE_INIT = 0, /* SFP state is uninit */
  689. BFA_SFP_STATE_REMOVED = 1, /* SFP is removed */
  690. BFA_SFP_STATE_INSERTED = 2, /* SFP is inserted */
  691. BFA_SFP_STATE_VALID = 3, /* SFP is valid */
  692. BFA_SFP_STATE_UNSUPPORT = 4, /* SFP is unsupport */
  693. BFA_SFP_STATE_FAILED = 5, /* SFP i2c read fail */
  694. };
  695. /*
  696. * SFP memory access type
  697. */
  698. enum bfi_sfp_mem_e {
  699. BFI_SFP_MEM_ALL = 0x1, /* access all data field */
  700. BFI_SFP_MEM_DIAGEXT = 0x2, /* access diag ext data field only */
  701. };
  702. struct bfi_sfp_req_s {
  703. struct bfi_mhdr_s mh;
  704. u8 memtype;
  705. u8 rsvd[3];
  706. struct bfi_alen_s alen;
  707. };
  708. struct bfi_sfp_rsp_s {
  709. struct bfi_mhdr_s mh;
  710. u8 status;
  711. u8 state;
  712. u8 rsvd[2];
  713. };
  714. /*
  715. * FLASH module specific
  716. */
  717. enum bfi_flash_h2i_msgs {
  718. BFI_FLASH_H2I_QUERY_REQ = 1,
  719. BFI_FLASH_H2I_ERASE_REQ = 2,
  720. BFI_FLASH_H2I_WRITE_REQ = 3,
  721. BFI_FLASH_H2I_READ_REQ = 4,
  722. BFI_FLASH_H2I_BOOT_VER_REQ = 5,
  723. };
  724. enum bfi_flash_i2h_msgs {
  725. BFI_FLASH_I2H_QUERY_RSP = BFA_I2HM(1),
  726. BFI_FLASH_I2H_ERASE_RSP = BFA_I2HM(2),
  727. BFI_FLASH_I2H_WRITE_RSP = BFA_I2HM(3),
  728. BFI_FLASH_I2H_READ_RSP = BFA_I2HM(4),
  729. BFI_FLASH_I2H_BOOT_VER_RSP = BFA_I2HM(5),
  730. BFI_FLASH_I2H_EVENT = BFA_I2HM(127),
  731. };
  732. /*
  733. * Flash query request
  734. */
  735. struct bfi_flash_query_req_s {
  736. struct bfi_mhdr_s mh; /* Common msg header */
  737. struct bfi_alen_s alen;
  738. };
  739. /*
  740. * Flash erase request
  741. */
  742. struct bfi_flash_erase_req_s {
  743. struct bfi_mhdr_s mh; /* Common msg header */
  744. u32 type; /* partition type */
  745. u8 instance; /* partition instance */
  746. u8 rsv[3];
  747. };
  748. /*
  749. * Flash write request
  750. */
  751. struct bfi_flash_write_req_s {
  752. struct bfi_mhdr_s mh; /* Common msg header */
  753. struct bfi_alen_s alen;
  754. u32 type; /* partition type */
  755. u8 instance; /* partition instance */
  756. u8 last;
  757. u8 rsv[2];
  758. u32 offset;
  759. u32 length;
  760. };
  761. /*
  762. * Flash read request
  763. */
  764. struct bfi_flash_read_req_s {
  765. struct bfi_mhdr_s mh; /* Common msg header */
  766. u32 type; /* partition type */
  767. u8 instance; /* partition instance */
  768. u8 rsv[3];
  769. u32 offset;
  770. u32 length;
  771. struct bfi_alen_s alen;
  772. };
  773. /*
  774. * Flash query response
  775. */
  776. struct bfi_flash_query_rsp_s {
  777. struct bfi_mhdr_s mh; /* Common msg header */
  778. u32 status;
  779. };
  780. /*
  781. * Flash read response
  782. */
  783. struct bfi_flash_read_rsp_s {
  784. struct bfi_mhdr_s mh; /* Common msg header */
  785. u32 type; /* partition type */
  786. u8 instance; /* partition instance */
  787. u8 rsv[3];
  788. u32 status;
  789. u32 length;
  790. };
  791. /*
  792. * Flash write response
  793. */
  794. struct bfi_flash_write_rsp_s {
  795. struct bfi_mhdr_s mh; /* Common msg header */
  796. u32 type; /* partition type */
  797. u8 instance; /* partition instance */
  798. u8 rsv[3];
  799. u32 status;
  800. u32 length;
  801. };
  802. /*
  803. * Flash erase response
  804. */
  805. struct bfi_flash_erase_rsp_s {
  806. struct bfi_mhdr_s mh; /* Common msg header */
  807. u32 type; /* partition type */
  808. u8 instance; /* partition instance */
  809. u8 rsv[3];
  810. u32 status;
  811. };
  812. /*
  813. *----------------------------------------------------------------------
  814. * DIAG
  815. *----------------------------------------------------------------------
  816. */
  817. enum bfi_diag_h2i {
  818. BFI_DIAG_H2I_PORTBEACON = 1,
  819. BFI_DIAG_H2I_LOOPBACK = 2,
  820. BFI_DIAG_H2I_FWPING = 3,
  821. BFI_DIAG_H2I_TEMPSENSOR = 4,
  822. BFI_DIAG_H2I_LEDTEST = 5,
  823. BFI_DIAG_H2I_QTEST = 6,
  824. };
  825. enum bfi_diag_i2h {
  826. BFI_DIAG_I2H_PORTBEACON = BFA_I2HM(BFI_DIAG_H2I_PORTBEACON),
  827. BFI_DIAG_I2H_LOOPBACK = BFA_I2HM(BFI_DIAG_H2I_LOOPBACK),
  828. BFI_DIAG_I2H_FWPING = BFA_I2HM(BFI_DIAG_H2I_FWPING),
  829. BFI_DIAG_I2H_TEMPSENSOR = BFA_I2HM(BFI_DIAG_H2I_TEMPSENSOR),
  830. BFI_DIAG_I2H_LEDTEST = BFA_I2HM(BFI_DIAG_H2I_LEDTEST),
  831. BFI_DIAG_I2H_QTEST = BFA_I2HM(BFI_DIAG_H2I_QTEST),
  832. };
  833. #define BFI_DIAG_MAX_SGES 2
  834. #define BFI_DIAG_DMA_BUF_SZ (2 * 1024)
  835. #define BFI_BOOT_MEMTEST_RES_ADDR 0x900
  836. #define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3
  837. struct bfi_diag_lb_req_s {
  838. struct bfi_mhdr_s mh;
  839. u32 loopcnt;
  840. u32 pattern;
  841. u8 lb_mode; /*!< bfa_port_opmode_t */
  842. u8 speed; /*!< bfa_port_speed_t */
  843. u8 rsvd[2];
  844. };
  845. struct bfi_diag_lb_rsp_s {
  846. struct bfi_mhdr_s mh; /* 4 bytes */
  847. struct bfa_diag_loopback_result_s res; /* 16 bytes */
  848. };
  849. struct bfi_diag_fwping_req_s {
  850. struct bfi_mhdr_s mh; /* 4 bytes */
  851. struct bfi_alen_s alen; /* 12 bytes */
  852. u32 data; /* user input data pattern */
  853. u32 count; /* user input dma count */
  854. u8 qtag; /* track CPE vc */
  855. u8 rsv[3];
  856. };
  857. struct bfi_diag_fwping_rsp_s {
  858. struct bfi_mhdr_s mh; /* 4 bytes */
  859. u32 data; /* user input data pattern */
  860. u8 qtag; /* track CPE vc */
  861. u8 dma_status; /* dma status */
  862. u8 rsv[2];
  863. };
  864. /*
  865. * Temperature Sensor
  866. */
  867. struct bfi_diag_ts_req_s {
  868. struct bfi_mhdr_s mh; /* 4 bytes */
  869. u16 temp; /* 10-bit A/D value */
  870. u16 brd_temp; /* 9-bit board temp */
  871. u8 status;
  872. u8 ts_junc; /* show junction tempsensor */
  873. u8 ts_brd; /* show board tempsensor */
  874. u8 rsv;
  875. };
  876. #define bfi_diag_ts_rsp_t struct bfi_diag_ts_req_s
  877. struct bfi_diag_ledtest_req_s {
  878. struct bfi_mhdr_s mh; /* 4 bytes */
  879. u8 cmd;
  880. u8 color;
  881. u8 portid;
  882. u8 led; /* bitmap of LEDs to be tested */
  883. u16 freq; /* no. of blinks every 10 secs */
  884. u8 rsv[2];
  885. };
  886. /* notify host led operation is done */
  887. struct bfi_diag_ledtest_rsp_s {
  888. struct bfi_mhdr_s mh; /* 4 bytes */
  889. };
  890. struct bfi_diag_portbeacon_req_s {
  891. struct bfi_mhdr_s mh; /* 4 bytes */
  892. u32 period; /* beaconing period */
  893. u8 beacon; /* 1: beacon on */
  894. u8 rsvd[3];
  895. };
  896. /* notify host the beacon is off */
  897. struct bfi_diag_portbeacon_rsp_s {
  898. struct bfi_mhdr_s mh; /* 4 bytes */
  899. };
  900. struct bfi_diag_qtest_req_s {
  901. struct bfi_mhdr_s mh; /* 4 bytes */
  902. u32 data[BFI_LMSG_PL_WSZ]; /* fill up tcm prefetch area */
  903. };
  904. #define bfi_diag_qtest_rsp_t struct bfi_diag_qtest_req_s
  905. #pragma pack()
  906. #endif /* __BFI_H__ */