bnx2x_init.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. /* bnx2x_init.h: Broadcom Everest network driver.
  2. * Structures and macroes needed during the initialization.
  3. *
  4. * Copyright (c) 2007-2011 Broadcom Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation.
  9. *
  10. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  11. * Written by: Eliezer Tamir
  12. * Modified by: Vladislav Zolotarov <vladz@broadcom.com>
  13. */
  14. #ifndef BNX2X_INIT_H
  15. #define BNX2X_INIT_H
  16. /* Init operation types and structures */
  17. enum {
  18. OP_RD = 0x1, /* read a single register */
  19. OP_WR, /* write a single register */
  20. OP_SW, /* copy a string to the device */
  21. OP_ZR, /* clear memory */
  22. OP_ZP, /* unzip then copy with DMAE */
  23. OP_WR_64, /* write 64 bit pattern */
  24. OP_WB, /* copy a string using DMAE */
  25. OP_WB_ZR, /* Clear a string using DMAE or indirect-wr */
  26. /* Skip the following ops if all of the init modes don't match */
  27. OP_IF_MODE_OR,
  28. /* Skip the following ops if any of the init modes don't match */
  29. OP_IF_MODE_AND,
  30. OP_MAX
  31. };
  32. enum {
  33. STAGE_START,
  34. STAGE_END,
  35. };
  36. /* Returns the index of start or end of a specific block stage in ops array*/
  37. #define BLOCK_OPS_IDX(block, stage, end) \
  38. (2*(((block)*NUM_OF_INIT_PHASES) + (stage)) + (end))
  39. /* structs for the various opcodes */
  40. struct raw_op {
  41. u32 op:8;
  42. u32 offset:24;
  43. u32 raw_data;
  44. };
  45. struct op_read {
  46. u32 op:8;
  47. u32 offset:24;
  48. u32 val;
  49. };
  50. struct op_write {
  51. u32 op:8;
  52. u32 offset:24;
  53. u32 val;
  54. };
  55. struct op_arr_write {
  56. u32 op:8;
  57. u32 offset:24;
  58. #ifdef __BIG_ENDIAN
  59. u16 data_len;
  60. u16 data_off;
  61. #else /* __LITTLE_ENDIAN */
  62. u16 data_off;
  63. u16 data_len;
  64. #endif
  65. };
  66. struct op_zero {
  67. u32 op:8;
  68. u32 offset:24;
  69. u32 len;
  70. };
  71. struct op_if_mode {
  72. u32 op:8;
  73. u32 cmd_offset:24;
  74. u32 mode_bit_map;
  75. };
  76. union init_op {
  77. struct op_read read;
  78. struct op_write write;
  79. struct op_arr_write arr_wr;
  80. struct op_zero zero;
  81. struct raw_op raw;
  82. struct op_if_mode if_mode;
  83. };
  84. /* Init Phases */
  85. enum {
  86. PHASE_COMMON,
  87. PHASE_PORT0,
  88. PHASE_PORT1,
  89. PHASE_PF0,
  90. PHASE_PF1,
  91. PHASE_PF2,
  92. PHASE_PF3,
  93. PHASE_PF4,
  94. PHASE_PF5,
  95. PHASE_PF6,
  96. PHASE_PF7,
  97. NUM_OF_INIT_PHASES
  98. };
  99. /* Init Modes */
  100. enum {
  101. MODE_ASIC = 0x00000001,
  102. MODE_FPGA = 0x00000002,
  103. MODE_EMUL = 0x00000004,
  104. MODE_E2 = 0x00000008,
  105. MODE_E3 = 0x00000010,
  106. MODE_PORT2 = 0x00000020,
  107. MODE_PORT4 = 0x00000040,
  108. MODE_SF = 0x00000080,
  109. MODE_MF = 0x00000100,
  110. MODE_MF_SD = 0x00000200,
  111. MODE_MF_SI = 0x00000400,
  112. MODE_MF_NIV = 0x00000800,
  113. MODE_E3_A0 = 0x00001000,
  114. MODE_E3_B0 = 0x00002000,
  115. MODE_COS3 = 0x00004000,
  116. MODE_COS6 = 0x00008000,
  117. MODE_LITTLE_ENDIAN = 0x00010000,
  118. MODE_BIG_ENDIAN = 0x00020000,
  119. };
  120. /* Init Blocks */
  121. enum {
  122. BLOCK_ATC,
  123. BLOCK_BRB1,
  124. BLOCK_CCM,
  125. BLOCK_CDU,
  126. BLOCK_CFC,
  127. BLOCK_CSDM,
  128. BLOCK_CSEM,
  129. BLOCK_DBG,
  130. BLOCK_DMAE,
  131. BLOCK_DORQ,
  132. BLOCK_HC,
  133. BLOCK_IGU,
  134. BLOCK_MISC,
  135. BLOCK_NIG,
  136. BLOCK_PBF,
  137. BLOCK_PGLUE_B,
  138. BLOCK_PRS,
  139. BLOCK_PXP2,
  140. BLOCK_PXP,
  141. BLOCK_QM,
  142. BLOCK_SRC,
  143. BLOCK_TCM,
  144. BLOCK_TM,
  145. BLOCK_TSDM,
  146. BLOCK_TSEM,
  147. BLOCK_UCM,
  148. BLOCK_UPB,
  149. BLOCK_USDM,
  150. BLOCK_USEM,
  151. BLOCK_XCM,
  152. BLOCK_XPB,
  153. BLOCK_XSDM,
  154. BLOCK_XSEM,
  155. BLOCK_MISC_AEU,
  156. NUM_OF_INIT_BLOCKS
  157. };
  158. /* QM queue numbers */
  159. #define BNX2X_ETH_Q 0
  160. #define BNX2X_TOE_Q 3
  161. #define BNX2X_TOE_ACK_Q 6
  162. #define BNX2X_ISCSI_Q 9
  163. #define BNX2X_ISCSI_ACK_Q 11
  164. #define BNX2X_FCOE_Q 10
  165. /* Vnics per mode */
  166. #define BNX2X_PORT2_MODE_NUM_VNICS 4
  167. #define BNX2X_PORT4_MODE_NUM_VNICS 2
  168. /* COS offset for port1 in E3 B0 4port mode */
  169. #define BNX2X_E3B0_PORT1_COS_OFFSET 3
  170. /* QM Register addresses */
  171. #define BNX2X_Q_VOQ_REG_ADDR(pf_q_num)\
  172. (QM_REG_QVOQIDX_0 + 4 * (pf_q_num))
  173. #define BNX2X_VOQ_Q_REG_ADDR(cos, pf_q_num)\
  174. (QM_REG_VOQQMASK_0_LSB + 4 * ((cos) * 2 + ((pf_q_num) >> 5)))
  175. #define BNX2X_Q_CMDQ_REG_ADDR(pf_q_num)\
  176. (QM_REG_BYTECRDCMDQ_0 + 4 * ((pf_q_num) >> 4))
  177. /* extracts the QM queue number for the specified port and vnic */
  178. #define BNX2X_PF_Q_NUM(q_num, port, vnic)\
  179. ((((port) << 1) | (vnic)) * 16 + (q_num))
  180. /* Maps the specified queue to the specified COS */
  181. static inline void bnx2x_map_q_cos(struct bnx2x *bp, u32 q_num, u32 new_cos)
  182. {
  183. /* find current COS mapping */
  184. u32 curr_cos = REG_RD(bp, QM_REG_QVOQIDX_0 + q_num * 4);
  185. /* check if queue->COS mapping has changed */
  186. if (curr_cos != new_cos) {
  187. u32 num_vnics = BNX2X_PORT2_MODE_NUM_VNICS;
  188. u32 reg_addr, reg_bit_map, vnic;
  189. /* update parameters for 4port mode */
  190. if (INIT_MODE_FLAGS(bp) & MODE_PORT4) {
  191. num_vnics = BNX2X_PORT4_MODE_NUM_VNICS;
  192. if (BP_PORT(bp)) {
  193. curr_cos += BNX2X_E3B0_PORT1_COS_OFFSET;
  194. new_cos += BNX2X_E3B0_PORT1_COS_OFFSET;
  195. }
  196. }
  197. /* change queue mapping for each VNIC */
  198. for (vnic = 0; vnic < num_vnics; vnic++) {
  199. u32 pf_q_num =
  200. BNX2X_PF_Q_NUM(q_num, BP_PORT(bp), vnic);
  201. u32 q_bit_map = 1 << (pf_q_num & 0x1f);
  202. /* overwrite queue->VOQ mapping */
  203. REG_WR(bp, BNX2X_Q_VOQ_REG_ADDR(pf_q_num), new_cos);
  204. /* clear queue bit from current COS bit map */
  205. reg_addr = BNX2X_VOQ_Q_REG_ADDR(curr_cos, pf_q_num);
  206. reg_bit_map = REG_RD(bp, reg_addr);
  207. REG_WR(bp, reg_addr, reg_bit_map & (~q_bit_map));
  208. /* set queue bit in new COS bit map */
  209. reg_addr = BNX2X_VOQ_Q_REG_ADDR(new_cos, pf_q_num);
  210. reg_bit_map = REG_RD(bp, reg_addr);
  211. REG_WR(bp, reg_addr, reg_bit_map | q_bit_map);
  212. /* set/clear queue bit in command-queue bit map
  213. (E2/E3A0 only, valid COS values are 0/1) */
  214. if (!(INIT_MODE_FLAGS(bp) & MODE_E3_B0)) {
  215. reg_addr = BNX2X_Q_CMDQ_REG_ADDR(pf_q_num);
  216. reg_bit_map = REG_RD(bp, reg_addr);
  217. q_bit_map = 1 << (2 * (pf_q_num & 0xf));
  218. reg_bit_map = new_cos ?
  219. (reg_bit_map | q_bit_map) :
  220. (reg_bit_map & (~q_bit_map));
  221. REG_WR(bp, reg_addr, reg_bit_map);
  222. }
  223. }
  224. }
  225. }
  226. /* Configures the QM according to the specified per-traffic-type COSes */
  227. static inline void bnx2x_dcb_config_qm(struct bnx2x *bp, enum cos_mode mode,
  228. struct priority_cos *traffic_cos)
  229. {
  230. bnx2x_map_q_cos(bp, BNX2X_FCOE_Q,
  231. traffic_cos[LLFC_TRAFFIC_TYPE_FCOE].cos);
  232. bnx2x_map_q_cos(bp, BNX2X_ISCSI_Q,
  233. traffic_cos[LLFC_TRAFFIC_TYPE_ISCSI].cos);
  234. bnx2x_map_q_cos(bp, BNX2X_ISCSI_ACK_Q,
  235. traffic_cos[LLFC_TRAFFIC_TYPE_ISCSI].cos);
  236. if (mode != STATIC_COS) {
  237. /* required only in backward compatible COS mode */
  238. bnx2x_map_q_cos(bp, BNX2X_ETH_Q,
  239. traffic_cos[LLFC_TRAFFIC_TYPE_NW].cos);
  240. bnx2x_map_q_cos(bp, BNX2X_TOE_Q,
  241. traffic_cos[LLFC_TRAFFIC_TYPE_NW].cos);
  242. bnx2x_map_q_cos(bp, BNX2X_TOE_ACK_Q,
  243. traffic_cos[LLFC_TRAFFIC_TYPE_NW].cos);
  244. }
  245. }
  246. /* Returns the index of start or end of a specific block stage in ops array*/
  247. #define BLOCK_OPS_IDX(block, stage, end) \
  248. (2*(((block)*NUM_OF_INIT_PHASES) + (stage)) + (end))
  249. #define INITOP_SET 0 /* set the HW directly */
  250. #define INITOP_CLEAR 1 /* clear the HW directly */
  251. #define INITOP_INIT 2 /* set the init-value array */
  252. /****************************************************************************
  253. * ILT management
  254. ****************************************************************************/
  255. struct ilt_line {
  256. dma_addr_t page_mapping;
  257. void *page;
  258. u32 size;
  259. };
  260. struct ilt_client_info {
  261. u32 page_size;
  262. u16 start;
  263. u16 end;
  264. u16 client_num;
  265. u16 flags;
  266. #define ILT_CLIENT_SKIP_INIT 0x1
  267. #define ILT_CLIENT_SKIP_MEM 0x2
  268. };
  269. struct bnx2x_ilt {
  270. u32 start_line;
  271. struct ilt_line *lines;
  272. struct ilt_client_info clients[4];
  273. #define ILT_CLIENT_CDU 0
  274. #define ILT_CLIENT_QM 1
  275. #define ILT_CLIENT_SRC 2
  276. #define ILT_CLIENT_TM 3
  277. };
  278. /****************************************************************************
  279. * SRC configuration
  280. ****************************************************************************/
  281. struct src_ent {
  282. u8 opaque[56];
  283. u64 next;
  284. };
  285. /****************************************************************************
  286. * Parity configuration
  287. ****************************************************************************/
  288. #define BLOCK_PRTY_INFO(block, en_mask, m1, m1h, m2, m3) \
  289. { \
  290. block##_REG_##block##_PRTY_MASK, \
  291. block##_REG_##block##_PRTY_STS_CLR, \
  292. en_mask, {m1, m1h, m2, m3}, #block \
  293. }
  294. #define BLOCK_PRTY_INFO_0(block, en_mask, m1, m1h, m2, m3) \
  295. { \
  296. block##_REG_##block##_PRTY_MASK_0, \
  297. block##_REG_##block##_PRTY_STS_CLR_0, \
  298. en_mask, {m1, m1h, m2, m3}, #block"_0" \
  299. }
  300. #define BLOCK_PRTY_INFO_1(block, en_mask, m1, m1h, m2, m3) \
  301. { \
  302. block##_REG_##block##_PRTY_MASK_1, \
  303. block##_REG_##block##_PRTY_STS_CLR_1, \
  304. en_mask, {m1, m1h, m2, m3}, #block"_1" \
  305. }
  306. static const struct {
  307. u32 mask_addr;
  308. u32 sts_clr_addr;
  309. u32 en_mask; /* Mask to enable parity attentions */
  310. struct {
  311. u32 e1; /* 57710 */
  312. u32 e1h; /* 57711 */
  313. u32 e2; /* 57712 */
  314. u32 e3; /* 578xx */
  315. } reg_mask; /* Register mask (all valid bits) */
  316. char name[7]; /* Block's longest name is 6 characters long
  317. * (name + suffix)
  318. */
  319. } bnx2x_blocks_parity_data[] = {
  320. /* bit 19 masked */
  321. /* REG_WR(bp, PXP_REG_PXP_PRTY_MASK, 0x80000); */
  322. /* bit 5,18,20-31 */
  323. /* REG_WR(bp, PXP2_REG_PXP2_PRTY_MASK_0, 0xfff40020); */
  324. /* bit 5 */
  325. /* REG_WR(bp, PXP2_REG_PXP2_PRTY_MASK_1, 0x20); */
  326. /* REG_WR(bp, HC_REG_HC_PRTY_MASK, 0x0); */
  327. /* REG_WR(bp, MISC_REG_MISC_PRTY_MASK, 0x0); */
  328. /* Block IGU, MISC, PXP and PXP2 parity errors as long as we don't
  329. * want to handle "system kill" flow at the moment.
  330. */
  331. BLOCK_PRTY_INFO(PXP, 0x7ffffff, 0x3ffffff, 0x3ffffff, 0x7ffffff,
  332. 0x7ffffff),
  333. BLOCK_PRTY_INFO_0(PXP2, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  334. 0xffffffff),
  335. BLOCK_PRTY_INFO_1(PXP2, 0x1ffffff, 0x7f, 0x7f, 0x7ff, 0x1ffffff),
  336. BLOCK_PRTY_INFO(HC, 0x7, 0x7, 0x7, 0, 0),
  337. BLOCK_PRTY_INFO(NIG, 0xffffffff, 0x3fffffff, 0xffffffff, 0, 0),
  338. BLOCK_PRTY_INFO_0(NIG, 0xffffffff, 0, 0, 0xffffffff, 0xffffffff),
  339. BLOCK_PRTY_INFO_1(NIG, 0xffff, 0, 0, 0xff, 0xffff),
  340. BLOCK_PRTY_INFO(IGU, 0x7ff, 0, 0, 0x7ff, 0x7ff),
  341. BLOCK_PRTY_INFO(MISC, 0x1, 0x1, 0x1, 0x1, 0x1),
  342. BLOCK_PRTY_INFO(QM, 0, 0x1ff, 0xfff, 0xfff, 0xfff),
  343. BLOCK_PRTY_INFO(ATC, 0x1f, 0, 0, 0x1f, 0x1f),
  344. BLOCK_PRTY_INFO(PGLUE_B, 0x3, 0, 0, 0x3, 0x3),
  345. BLOCK_PRTY_INFO(DORQ, 0, 0x3, 0x3, 0x3, 0x3),
  346. {GRCBASE_UPB + PB_REG_PB_PRTY_MASK,
  347. GRCBASE_UPB + PB_REG_PB_PRTY_STS_CLR, 0xf,
  348. {0xf, 0xf, 0xf, 0xf}, "UPB"},
  349. {GRCBASE_XPB + PB_REG_PB_PRTY_MASK,
  350. GRCBASE_XPB + PB_REG_PB_PRTY_STS_CLR, 0,
  351. {0xf, 0xf, 0xf, 0xf}, "XPB"},
  352. BLOCK_PRTY_INFO(SRC, 0x4, 0x7, 0x7, 0x7, 0x7),
  353. BLOCK_PRTY_INFO(CDU, 0, 0x1f, 0x1f, 0x1f, 0x1f),
  354. BLOCK_PRTY_INFO(CFC, 0, 0xf, 0xf, 0xf, 0x3f),
  355. BLOCK_PRTY_INFO(DBG, 0, 0x1, 0x1, 0x1, 0x1),
  356. BLOCK_PRTY_INFO(DMAE, 0, 0xf, 0xf, 0xf, 0xf),
  357. BLOCK_PRTY_INFO(BRB1, 0, 0xf, 0xf, 0xf, 0xf),
  358. BLOCK_PRTY_INFO(PRS, (1<<6), 0xff, 0xff, 0xff, 0xff),
  359. BLOCK_PRTY_INFO(PBF, 0, 0, 0x3ffff, 0xfffff, 0xfffffff),
  360. BLOCK_PRTY_INFO(TM, 0, 0, 0x7f, 0x7f, 0x7f),
  361. BLOCK_PRTY_INFO(TSDM, 0x18, 0x7ff, 0x7ff, 0x7ff, 0x7ff),
  362. BLOCK_PRTY_INFO(CSDM, 0x8, 0x7ff, 0x7ff, 0x7ff, 0x7ff),
  363. BLOCK_PRTY_INFO(USDM, 0x38, 0x7ff, 0x7ff, 0x7ff, 0x7ff),
  364. BLOCK_PRTY_INFO(XSDM, 0x8, 0x7ff, 0x7ff, 0x7ff, 0x7ff),
  365. BLOCK_PRTY_INFO(TCM, 0, 0, 0x7ffffff, 0x7ffffff, 0x7ffffff),
  366. BLOCK_PRTY_INFO(CCM, 0, 0, 0x7ffffff, 0x7ffffff, 0x7ffffff),
  367. BLOCK_PRTY_INFO(UCM, 0, 0, 0x7ffffff, 0x7ffffff, 0x7ffffff),
  368. BLOCK_PRTY_INFO(XCM, 0, 0, 0x3fffffff, 0x3fffffff, 0x3fffffff),
  369. BLOCK_PRTY_INFO_0(TSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff,
  370. 0xffffffff),
  371. BLOCK_PRTY_INFO_1(TSEM, 0, 0x3, 0x1f, 0x3f, 0x3f),
  372. BLOCK_PRTY_INFO_0(USEM, 0, 0xffffffff, 0xffffffff, 0xffffffff,
  373. 0xffffffff),
  374. BLOCK_PRTY_INFO_1(USEM, 0, 0x3, 0x1f, 0x1f, 0x1f),
  375. BLOCK_PRTY_INFO_0(CSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff,
  376. 0xffffffff),
  377. BLOCK_PRTY_INFO_1(CSEM, 0, 0x3, 0x1f, 0x1f, 0x1f),
  378. BLOCK_PRTY_INFO_0(XSEM, 0, 0xffffffff, 0xffffffff, 0xffffffff,
  379. 0xffffffff),
  380. BLOCK_PRTY_INFO_1(XSEM, 0, 0x3, 0x1f, 0x3f, 0x3f),
  381. };
  382. /* [28] MCP Latched rom_parity
  383. * [29] MCP Latched ump_rx_parity
  384. * [30] MCP Latched ump_tx_parity
  385. * [31] MCP Latched scpad_parity
  386. */
  387. #define MISC_AEU_ENABLE_MCP_PRTY_BITS \
  388. (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
  389. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
  390. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \
  391. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
  392. /* Below registers control the MCP parity attention output. When
  393. * MISC_AEU_ENABLE_MCP_PRTY_BITS are set - attentions are
  394. * enabled, when cleared - disabled.
  395. */
  396. static const u32 mcp_attn_ctl_regs[] = {
  397. MISC_REG_AEU_ENABLE4_FUNC_0_OUT_0,
  398. MISC_REG_AEU_ENABLE4_NIG_0,
  399. MISC_REG_AEU_ENABLE4_PXP_0,
  400. MISC_REG_AEU_ENABLE4_FUNC_1_OUT_0,
  401. MISC_REG_AEU_ENABLE4_NIG_1,
  402. MISC_REG_AEU_ENABLE4_PXP_1
  403. };
  404. static inline void bnx2x_set_mcp_parity(struct bnx2x *bp, u8 enable)
  405. {
  406. int i;
  407. u32 reg_val;
  408. for (i = 0; i < ARRAY_SIZE(mcp_attn_ctl_regs); i++) {
  409. reg_val = REG_RD(bp, mcp_attn_ctl_regs[i]);
  410. if (enable)
  411. reg_val |= MISC_AEU_ENABLE_MCP_PRTY_BITS;
  412. else
  413. reg_val &= ~MISC_AEU_ENABLE_MCP_PRTY_BITS;
  414. REG_WR(bp, mcp_attn_ctl_regs[i], reg_val);
  415. }
  416. }
  417. static inline u32 bnx2x_parity_reg_mask(struct bnx2x *bp, int idx)
  418. {
  419. if (CHIP_IS_E1(bp))
  420. return bnx2x_blocks_parity_data[idx].reg_mask.e1;
  421. else if (CHIP_IS_E1H(bp))
  422. return bnx2x_blocks_parity_data[idx].reg_mask.e1h;
  423. else if (CHIP_IS_E2(bp))
  424. return bnx2x_blocks_parity_data[idx].reg_mask.e2;
  425. else /* CHIP_IS_E3 */
  426. return bnx2x_blocks_parity_data[idx].reg_mask.e3;
  427. }
  428. static inline void bnx2x_disable_blocks_parity(struct bnx2x *bp)
  429. {
  430. int i;
  431. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  432. u32 dis_mask = bnx2x_parity_reg_mask(bp, i);
  433. if (dis_mask) {
  434. REG_WR(bp, bnx2x_blocks_parity_data[i].mask_addr,
  435. dis_mask);
  436. DP(NETIF_MSG_HW, "Setting parity mask "
  437. "for %s to\t\t0x%x\n",
  438. bnx2x_blocks_parity_data[i].name, dis_mask);
  439. }
  440. }
  441. /* Disable MCP parity attentions */
  442. bnx2x_set_mcp_parity(bp, false);
  443. }
  444. /**
  445. * Clear the parity error status registers.
  446. */
  447. static inline void bnx2x_clear_blocks_parity(struct bnx2x *bp)
  448. {
  449. int i;
  450. u32 reg_val, mcp_aeu_bits =
  451. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY |
  452. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY |
  453. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY |
  454. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY;
  455. /* Clear SEM_FAST parities */
  456. REG_WR(bp, XSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  457. REG_WR(bp, TSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  458. REG_WR(bp, USEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  459. REG_WR(bp, CSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
  460. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  461. u32 reg_mask = bnx2x_parity_reg_mask(bp, i);
  462. if (reg_mask) {
  463. reg_val = REG_RD(bp, bnx2x_blocks_parity_data[i].
  464. sts_clr_addr);
  465. if (reg_val & reg_mask)
  466. DP(NETIF_MSG_HW,
  467. "Parity errors in %s: 0x%x\n",
  468. bnx2x_blocks_parity_data[i].name,
  469. reg_val & reg_mask);
  470. }
  471. }
  472. /* Check if there were parity attentions in MCP */
  473. reg_val = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_4_MCP);
  474. if (reg_val & mcp_aeu_bits)
  475. DP(NETIF_MSG_HW, "Parity error in MCP: 0x%x\n",
  476. reg_val & mcp_aeu_bits);
  477. /* Clear parity attentions in MCP:
  478. * [7] clears Latched rom_parity
  479. * [8] clears Latched ump_rx_parity
  480. * [9] clears Latched ump_tx_parity
  481. * [10] clears Latched scpad_parity (both ports)
  482. */
  483. REG_WR(bp, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0x780);
  484. }
  485. static inline void bnx2x_enable_blocks_parity(struct bnx2x *bp)
  486. {
  487. int i;
  488. for (i = 0; i < ARRAY_SIZE(bnx2x_blocks_parity_data); i++) {
  489. u32 reg_mask = bnx2x_parity_reg_mask(bp, i);
  490. if (reg_mask)
  491. REG_WR(bp, bnx2x_blocks_parity_data[i].mask_addr,
  492. bnx2x_blocks_parity_data[i].en_mask & reg_mask);
  493. }
  494. /* Enable MCP parity attentions */
  495. bnx2x_set_mcp_parity(bp, true);
  496. }
  497. #endif /* BNX2X_INIT_H */