bnx2x_init.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /* bnx2x_init.h: Broadcom Everest network driver.
  2. * Structures and macroes needed during the initialization.
  3. *
  4. * Copyright (c) 2007-2009 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. #define COMMON 0x1
  17. #define PORT0 0x2
  18. #define PORT1 0x4
  19. #define INIT_EMULATION 0x1
  20. #define INIT_FPGA 0x2
  21. #define INIT_ASIC 0x4
  22. #define INIT_HARDWARE 0x7
  23. #define TSTORM_INTMEM_ADDR TSEM_REG_FAST_MEMORY
  24. #define CSTORM_INTMEM_ADDR CSEM_REG_FAST_MEMORY
  25. #define XSTORM_INTMEM_ADDR XSEM_REG_FAST_MEMORY
  26. #define USTORM_INTMEM_ADDR USEM_REG_FAST_MEMORY
  27. /* RAM0 size in bytes */
  28. #define STORM_INTMEM_SIZE_E1 0x5800
  29. #define STORM_INTMEM_SIZE_E1H 0x10000
  30. #define STORM_INTMEM_SIZE(bp) ((CHIP_IS_E1H(bp) ? STORM_INTMEM_SIZE_E1H : \
  31. STORM_INTMEM_SIZE_E1) / 4)
  32. /* Init operation types and structures */
  33. /* Common for both E1 and E1H */
  34. #define OP_RD 0x1 /* read single register */
  35. #define OP_WR 0x2 /* write single register */
  36. #define OP_IW 0x3 /* write single register using mailbox */
  37. #define OP_SW 0x4 /* copy a string to the device */
  38. #define OP_SI 0x5 /* copy a string using mailbox */
  39. #define OP_ZR 0x6 /* clear memory */
  40. #define OP_ZP 0x7 /* unzip then copy with DMAE */
  41. #define OP_WR_64 0x8 /* write 64 bit pattern */
  42. #define OP_WB 0x9 /* copy a string using DMAE */
  43. /* FPGA and EMUL specific operations */
  44. #define OP_WR_EMUL 0xa /* write single register on Emulation */
  45. #define OP_WR_FPGA 0xb /* write single register on FPGA */
  46. #define OP_WR_ASIC 0xc /* write single register on ASIC */
  47. /* Init stages */
  48. #define COMMON_STAGE 0
  49. #define PORT0_STAGE 1
  50. #define PORT1_STAGE 2
  51. /* Never reorder FUNCx stages !!! */
  52. #define FUNC0_STAGE 3
  53. #define FUNC1_STAGE 4
  54. #define FUNC2_STAGE 5
  55. #define FUNC3_STAGE 6
  56. #define FUNC4_STAGE 7
  57. #define FUNC5_STAGE 8
  58. #define FUNC6_STAGE 9
  59. #define FUNC7_STAGE 10
  60. #define STAGE_IDX_MAX 11
  61. #define STAGE_START 0
  62. #define STAGE_END 1
  63. /* Indices of blocks */
  64. #define PRS_BLOCK 0
  65. #define SRCH_BLOCK 1
  66. #define TSDM_BLOCK 2
  67. #define TCM_BLOCK 3
  68. #define BRB1_BLOCK 4
  69. #define TSEM_BLOCK 5
  70. #define PXPCS_BLOCK 6
  71. #define EMAC0_BLOCK 7
  72. #define EMAC1_BLOCK 8
  73. #define DBU_BLOCK 9
  74. #define MISC_BLOCK 10
  75. #define DBG_BLOCK 11
  76. #define NIG_BLOCK 12
  77. #define MCP_BLOCK 13
  78. #define UPB_BLOCK 14
  79. #define CSDM_BLOCK 15
  80. #define USDM_BLOCK 16
  81. #define CCM_BLOCK 17
  82. #define UCM_BLOCK 18
  83. #define USEM_BLOCK 19
  84. #define CSEM_BLOCK 20
  85. #define XPB_BLOCK 21
  86. #define DQ_BLOCK 22
  87. #define TIMERS_BLOCK 23
  88. #define XSDM_BLOCK 24
  89. #define QM_BLOCK 25
  90. #define PBF_BLOCK 26
  91. #define XCM_BLOCK 27
  92. #define XSEM_BLOCK 28
  93. #define CDU_BLOCK 29
  94. #define DMAE_BLOCK 30
  95. #define PXP_BLOCK 31
  96. #define CFC_BLOCK 32
  97. #define HC_BLOCK 33
  98. #define PXP2_BLOCK 34
  99. #define MISC_AEU_BLOCK 35
  100. /* Returns the index of start or end of a specific block stage in ops array*/
  101. #define BLOCK_OPS_IDX(block, stage, end) \
  102. (2*(((block)*STAGE_IDX_MAX) + (stage)) + (end))
  103. struct raw_op {
  104. u32 op:8;
  105. u32 offset:24;
  106. u32 raw_data;
  107. };
  108. struct op_read {
  109. u32 op:8;
  110. u32 offset:24;
  111. u32 pad;
  112. };
  113. struct op_write {
  114. u32 op:8;
  115. u32 offset:24;
  116. u32 val;
  117. };
  118. struct op_string_write {
  119. u32 op:8;
  120. u32 offset:24;
  121. #ifdef __LITTLE_ENDIAN
  122. u16 data_off;
  123. u16 data_len;
  124. #else /* __BIG_ENDIAN */
  125. u16 data_len;
  126. u16 data_off;
  127. #endif
  128. };
  129. struct op_zero {
  130. u32 op:8;
  131. u32 offset:24;
  132. u32 len;
  133. };
  134. union init_op {
  135. struct op_read read;
  136. struct op_write write;
  137. struct op_string_write str_wr;
  138. struct op_zero zero;
  139. struct raw_op raw;
  140. };
  141. /****************************************************************************
  142. * PXP
  143. ****************************************************************************/
  144. /*
  145. * This code configures the PCI read/write arbiter
  146. * which implements a weighted round robin
  147. * between the virtual queues in the chip.
  148. *
  149. * The values were derived for each PCI max payload and max request size.
  150. * since max payload and max request size are only known at run time,
  151. * this is done as a separate init stage.
  152. */
  153. #define NUM_WR_Q 13
  154. #define NUM_RD_Q 29
  155. #define MAX_RD_ORD 3
  156. #define MAX_WR_ORD 2
  157. /* configuration for one arbiter queue */
  158. struct arb_line {
  159. int l;
  160. int add;
  161. int ubound;
  162. };
  163. /* derived configuration for each read queue for each max request size */
  164. static const struct arb_line read_arb_data[NUM_RD_Q][MAX_RD_ORD + 1] = {
  165. /* 1 */ { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
  166. { {4, 8, 4}, {4, 8, 4}, {4, 8, 4}, {4, 8, 4} },
  167. { {4, 3, 3}, {4, 3, 3}, {4, 3, 3}, {4, 3, 3} },
  168. { {8, 3, 6}, {16, 3, 11}, {16, 3, 11}, {16, 3, 11} },
  169. { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
  170. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
  171. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
  172. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
  173. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
  174. /* 10 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  175. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  176. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  177. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  178. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  179. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  180. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  181. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  182. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  183. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  184. /* 20 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  185. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  186. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  187. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  188. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  189. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  190. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  191. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  192. { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
  193. { {8, 64, 25}, {16, 64, 41}, {32, 64, 81}, {64, 64, 120} }
  194. };
  195. /* derived configuration for each write queue for each max request size */
  196. static const struct arb_line write_arb_data[NUM_WR_Q][MAX_WR_ORD + 1] = {
  197. /* 1 */ { {4, 6, 3}, {4, 6, 3}, {4, 6, 3} },
  198. { {4, 2, 3}, {4, 2, 3}, {4, 2, 3} },
  199. { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
  200. { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
  201. { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
  202. { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
  203. { {8, 64, 25}, {16, 64, 25}, {32, 64, 25} },
  204. { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
  205. { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
  206. /* 10 */{ {8, 9, 6}, {16, 9, 11}, {32, 9, 21} },
  207. { {8, 47, 19}, {16, 47, 19}, {32, 47, 21} },
  208. { {8, 9, 6}, {16, 9, 11}, {16, 9, 11} },
  209. { {8, 64, 25}, {16, 64, 41}, {32, 64, 81} }
  210. };
  211. /* register addresses for read queues */
  212. static const struct arb_line read_arb_addr[NUM_RD_Q-1] = {
  213. /* 1 */ {PXP2_REG_RQ_BW_RD_L0, PXP2_REG_RQ_BW_RD_ADD0,
  214. PXP2_REG_RQ_BW_RD_UBOUND0},
  215. {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
  216. PXP2_REG_PSWRQ_BW_UB1},
  217. {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
  218. PXP2_REG_PSWRQ_BW_UB2},
  219. {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
  220. PXP2_REG_PSWRQ_BW_UB3},
  221. {PXP2_REG_RQ_BW_RD_L4, PXP2_REG_RQ_BW_RD_ADD4,
  222. PXP2_REG_RQ_BW_RD_UBOUND4},
  223. {PXP2_REG_RQ_BW_RD_L5, PXP2_REG_RQ_BW_RD_ADD5,
  224. PXP2_REG_RQ_BW_RD_UBOUND5},
  225. {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
  226. PXP2_REG_PSWRQ_BW_UB6},
  227. {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
  228. PXP2_REG_PSWRQ_BW_UB7},
  229. {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
  230. PXP2_REG_PSWRQ_BW_UB8},
  231. /* 10 */{PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
  232. PXP2_REG_PSWRQ_BW_UB9},
  233. {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
  234. PXP2_REG_PSWRQ_BW_UB10},
  235. {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
  236. PXP2_REG_PSWRQ_BW_UB11},
  237. {PXP2_REG_RQ_BW_RD_L12, PXP2_REG_RQ_BW_RD_ADD12,
  238. PXP2_REG_RQ_BW_RD_UBOUND12},
  239. {PXP2_REG_RQ_BW_RD_L13, PXP2_REG_RQ_BW_RD_ADD13,
  240. PXP2_REG_RQ_BW_RD_UBOUND13},
  241. {PXP2_REG_RQ_BW_RD_L14, PXP2_REG_RQ_BW_RD_ADD14,
  242. PXP2_REG_RQ_BW_RD_UBOUND14},
  243. {PXP2_REG_RQ_BW_RD_L15, PXP2_REG_RQ_BW_RD_ADD15,
  244. PXP2_REG_RQ_BW_RD_UBOUND15},
  245. {PXP2_REG_RQ_BW_RD_L16, PXP2_REG_RQ_BW_RD_ADD16,
  246. PXP2_REG_RQ_BW_RD_UBOUND16},
  247. {PXP2_REG_RQ_BW_RD_L17, PXP2_REG_RQ_BW_RD_ADD17,
  248. PXP2_REG_RQ_BW_RD_UBOUND17},
  249. {PXP2_REG_RQ_BW_RD_L18, PXP2_REG_RQ_BW_RD_ADD18,
  250. PXP2_REG_RQ_BW_RD_UBOUND18},
  251. /* 20 */{PXP2_REG_RQ_BW_RD_L19, PXP2_REG_RQ_BW_RD_ADD19,
  252. PXP2_REG_RQ_BW_RD_UBOUND19},
  253. {PXP2_REG_RQ_BW_RD_L20, PXP2_REG_RQ_BW_RD_ADD20,
  254. PXP2_REG_RQ_BW_RD_UBOUND20},
  255. {PXP2_REG_RQ_BW_RD_L22, PXP2_REG_RQ_BW_RD_ADD22,
  256. PXP2_REG_RQ_BW_RD_UBOUND22},
  257. {PXP2_REG_RQ_BW_RD_L23, PXP2_REG_RQ_BW_RD_ADD23,
  258. PXP2_REG_RQ_BW_RD_UBOUND23},
  259. {PXP2_REG_RQ_BW_RD_L24, PXP2_REG_RQ_BW_RD_ADD24,
  260. PXP2_REG_RQ_BW_RD_UBOUND24},
  261. {PXP2_REG_RQ_BW_RD_L25, PXP2_REG_RQ_BW_RD_ADD25,
  262. PXP2_REG_RQ_BW_RD_UBOUND25},
  263. {PXP2_REG_RQ_BW_RD_L26, PXP2_REG_RQ_BW_RD_ADD26,
  264. PXP2_REG_RQ_BW_RD_UBOUND26},
  265. {PXP2_REG_RQ_BW_RD_L27, PXP2_REG_RQ_BW_RD_ADD27,
  266. PXP2_REG_RQ_BW_RD_UBOUND27},
  267. {PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
  268. PXP2_REG_PSWRQ_BW_UB28}
  269. };
  270. /* register addresses for write queues */
  271. static const struct arb_line write_arb_addr[NUM_WR_Q-1] = {
  272. /* 1 */ {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
  273. PXP2_REG_PSWRQ_BW_UB1},
  274. {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
  275. PXP2_REG_PSWRQ_BW_UB2},
  276. {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
  277. PXP2_REG_PSWRQ_BW_UB3},
  278. {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
  279. PXP2_REG_PSWRQ_BW_UB6},
  280. {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
  281. PXP2_REG_PSWRQ_BW_UB7},
  282. {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
  283. PXP2_REG_PSWRQ_BW_UB8},
  284. {PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
  285. PXP2_REG_PSWRQ_BW_UB9},
  286. {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
  287. PXP2_REG_PSWRQ_BW_UB10},
  288. {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
  289. PXP2_REG_PSWRQ_BW_UB11},
  290. /* 10 */{PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
  291. PXP2_REG_PSWRQ_BW_UB28},
  292. {PXP2_REG_RQ_BW_WR_L29, PXP2_REG_RQ_BW_WR_ADD29,
  293. PXP2_REG_RQ_BW_WR_UBOUND29},
  294. {PXP2_REG_RQ_BW_WR_L30, PXP2_REG_RQ_BW_WR_ADD30,
  295. PXP2_REG_RQ_BW_WR_UBOUND30}
  296. };
  297. /****************************************************************************
  298. * CDU
  299. ****************************************************************************/
  300. #define CDU_REGION_NUMBER_XCM_AG 2
  301. #define CDU_REGION_NUMBER_UCM_AG 4
  302. /**
  303. * String-to-compress [31:8] = CID (all 24 bits)
  304. * String-to-compress [7:4] = Region
  305. * String-to-compress [3:0] = Type
  306. */
  307. #define CDU_VALID_DATA(_cid, _region, _type) \
  308. (((_cid) << 8) | (((_region) & 0xf) << 4) | (((_type) & 0xf)))
  309. #define CDU_CRC8(_cid, _region, _type) \
  310. calc_crc8(CDU_VALID_DATA(_cid, _region, _type), 0xff)
  311. #define CDU_RSRVD_VALUE_TYPE_A(_cid, _region, _type) \
  312. (0x80 | (CDU_CRC8(_cid, _region, _type) & 0x7f))
  313. #define CDU_RSRVD_VALUE_TYPE_B(_crc, _type) \
  314. (0x80 | ((_type) & 0xf << 3) | (CDU_CRC8(_cid, _region, _type) & 0x7))
  315. #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
  316. /* registers addresses are not in order
  317. so these arrays help simplify the code */
  318. static const int cm_blocks[9] = {
  319. MISC_BLOCK, TCM_BLOCK, UCM_BLOCK, CCM_BLOCK, XCM_BLOCK,
  320. TSEM_BLOCK, USEM_BLOCK, CSEM_BLOCK, XSEM_BLOCK
  321. };
  322. #endif /* BNX2X_INIT_H */