bnx2x.h 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947
  1. /* bnx2x.h: Broadcom Everest network driver.
  2. *
  3. * Copyright (c) 2007-2011 Broadcom Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. *
  9. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  10. * Written by: Eliezer Tamir
  11. * Based on code from Michael Chan's bnx2 driver
  12. */
  13. #ifndef BNX2X_H
  14. #define BNX2X_H
  15. #include <linux/netdevice.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/types.h>
  18. /* compilation time flags */
  19. /* define this to make the driver freeze on error to allow getting debug info
  20. * (you will need to reboot afterwards) */
  21. /* #define BNX2X_STOP_ON_ERROR */
  22. #define DRV_MODULE_VERSION "1.70.00-0"
  23. #define DRV_MODULE_RELDATE "2011/06/13"
  24. #define BNX2X_BC_VER 0x040200
  25. #if defined(CONFIG_DCB)
  26. #define BCM_DCBNL
  27. #endif
  28. #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
  29. #define BCM_CNIC 1
  30. #include "../cnic_if.h"
  31. #endif
  32. #ifdef BCM_CNIC
  33. #define BNX2X_MIN_MSIX_VEC_CNT 3
  34. #define BNX2X_MSIX_VEC_FP_START 2
  35. #else
  36. #define BNX2X_MIN_MSIX_VEC_CNT 2
  37. #define BNX2X_MSIX_VEC_FP_START 1
  38. #endif
  39. #include <linux/mdio.h>
  40. #include "bnx2x_reg.h"
  41. #include "bnx2x_fw_defs.h"
  42. #include "bnx2x_hsi.h"
  43. #include "bnx2x_link.h"
  44. #include "bnx2x_sp.h"
  45. #include "bnx2x_dcb.h"
  46. #include "bnx2x_stats.h"
  47. /* error/debug prints */
  48. #define DRV_MODULE_NAME "bnx2x"
  49. /* for messages that are currently off */
  50. #define BNX2X_MSG_OFF 0
  51. #define BNX2X_MSG_MCP 0x010000 /* was: NETIF_MSG_HW */
  52. #define BNX2X_MSG_STATS 0x020000 /* was: NETIF_MSG_TIMER */
  53. #define BNX2X_MSG_NVM 0x040000 /* was: NETIF_MSG_HW */
  54. #define BNX2X_MSG_DMAE 0x080000 /* was: NETIF_MSG_HW */
  55. #define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */
  56. #define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */
  57. #define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */
  58. /* regular debug print */
  59. #define DP(__mask, __fmt, __args...) \
  60. do { \
  61. if (bp->msg_enable & (__mask)) \
  62. printk(DP_LEVEL "[%s:%d(%s)]" __fmt, \
  63. __func__, __LINE__, \
  64. bp->dev ? (bp->dev->name) : "?", \
  65. ##__args); \
  66. } while (0)
  67. #define DP_CONT(__mask, __fmt, __args...) \
  68. do { \
  69. if (bp->msg_enable & (__mask)) \
  70. pr_cont(__fmt, ##__args); \
  71. } while (0)
  72. /* errors debug print */
  73. #define BNX2X_DBG_ERR(__fmt, __args...) \
  74. do { \
  75. if (netif_msg_probe(bp)) \
  76. pr_err("[%s:%d(%s)]" __fmt, \
  77. __func__, __LINE__, \
  78. bp->dev ? (bp->dev->name) : "?", \
  79. ##__args); \
  80. } while (0)
  81. /* for errors (never masked) */
  82. #define BNX2X_ERR(__fmt, __args...) \
  83. do { \
  84. pr_err("[%s:%d(%s)]" __fmt, \
  85. __func__, __LINE__, \
  86. bp->dev ? (bp->dev->name) : "?", \
  87. ##__args); \
  88. } while (0)
  89. #define BNX2X_ERROR(__fmt, __args...) do { \
  90. pr_err("[%s:%d]" __fmt, __func__, __LINE__, ##__args); \
  91. } while (0)
  92. /* before we have a dev->name use dev_info() */
  93. #define BNX2X_DEV_INFO(__fmt, __args...) \
  94. do { \
  95. if (netif_msg_probe(bp)) \
  96. dev_info(&bp->pdev->dev, __fmt, ##__args); \
  97. } while (0)
  98. #define BNX2X_MAC_FMT "%pM"
  99. #define BNX2X_MAC_PRN_LIST(mac) (mac)
  100. #ifdef BNX2X_STOP_ON_ERROR
  101. #define bnx2x_panic() do { \
  102. bp->panic = 1; \
  103. BNX2X_ERR("driver assert\n"); \
  104. bnx2x_int_disable(bp); \
  105. bnx2x_panic_dump(bp); \
  106. } while (0)
  107. #else
  108. #define bnx2x_panic() do { \
  109. bp->panic = 1; \
  110. BNX2X_ERR("driver assert\n"); \
  111. bnx2x_panic_dump(bp); \
  112. } while (0)
  113. #endif
  114. #define bnx2x_mc_addr(ha) ((ha)->addr)
  115. #define bnx2x_uc_addr(ha) ((ha)->addr)
  116. #define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff)
  117. #define U64_HI(x) (u32)(((u64)(x)) >> 32)
  118. #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
  119. #define REG_ADDR(bp, offset) ((bp->regview) + (offset))
  120. #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
  121. #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
  122. #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset))
  123. #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset))
  124. #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset))
  125. #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset))
  126. #define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset)
  127. #define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val)
  128. #define REG_RD_DMAE(bp, offset, valp, len32) \
  129. do { \
  130. bnx2x_read_dmae(bp, offset, len32);\
  131. memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
  132. } while (0)
  133. #define REG_WR_DMAE(bp, offset, valp, len32) \
  134. do { \
  135. memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
  136. bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
  137. offset, len32); \
  138. } while (0)
  139. #define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
  140. REG_WR_DMAE(bp, offset, valp, len32)
  141. #define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
  142. do { \
  143. memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
  144. bnx2x_write_big_buf_wb(bp, addr, len32); \
  145. } while (0)
  146. #define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \
  147. offsetof(struct shmem_region, field))
  148. #define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field))
  149. #define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val)
  150. #define SHMEM2_ADDR(bp, field) (bp->common.shmem2_base + \
  151. offsetof(struct shmem2_region, field))
  152. #define SHMEM2_RD(bp, field) REG_RD(bp, SHMEM2_ADDR(bp, field))
  153. #define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val)
  154. #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \
  155. offsetof(struct mf_cfg, field))
  156. #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \
  157. offsetof(struct mf2_cfg, field))
  158. #define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field))
  159. #define MF_CFG_WR(bp, field, val) REG_WR(bp,\
  160. MF_CFG_ADDR(bp, field), (val))
  161. #define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field))
  162. #define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \
  163. (SHMEM2_RD((bp), size) > \
  164. offsetof(struct shmem2_region, field)))
  165. #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg)
  166. #define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val)
  167. /* SP SB indices */
  168. /* General SP events - stats query, cfc delete, etc */
  169. #define HC_SP_INDEX_ETH_DEF_CONS 3
  170. /* EQ completions */
  171. #define HC_SP_INDEX_EQ_CONS 7
  172. /* FCoE L2 connection completions */
  173. #define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS 6
  174. #define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS 4
  175. /* iSCSI L2 */
  176. #define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5
  177. #define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1
  178. /* Special clients parameters */
  179. /* SB indices */
  180. /* FCoE L2 */
  181. #define BNX2X_FCOE_L2_RX_INDEX \
  182. (&bp->def_status_blk->sp_sb.\
  183. index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS])
  184. #define BNX2X_FCOE_L2_TX_INDEX \
  185. (&bp->def_status_blk->sp_sb.\
  186. index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS])
  187. /**
  188. * CIDs and CLIDs:
  189. * CLIDs below is a CLID for func 0, then the CLID for other
  190. * functions will be calculated by the formula:
  191. *
  192. * FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X
  193. *
  194. */
  195. /* iSCSI L2 */
  196. #define BNX2X_ISCSI_ETH_CL_ID_IDX 1
  197. #define BNX2X_ISCSI_ETH_CID 17
  198. /* FCoE L2 */
  199. #define BNX2X_FCOE_ETH_CL_ID_IDX 2
  200. #define BNX2X_FCOE_ETH_CID 18
  201. /** Additional rings budgeting */
  202. #ifdef BCM_CNIC
  203. #define CNIC_CONTEXT_USE 1
  204. #define FCOE_CONTEXT_USE 1
  205. #else
  206. #define CNIC_CONTEXT_USE 0
  207. #define FCOE_CONTEXT_USE 0
  208. #endif /* BCM_CNIC */
  209. #define NONE_ETH_CONTEXT_USE (FCOE_CONTEXT_USE)
  210. #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
  211. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
  212. #define SM_RX_ID 0
  213. #define SM_TX_ID 1
  214. /* fast path */
  215. struct sw_rx_bd {
  216. struct sk_buff *skb;
  217. DEFINE_DMA_UNMAP_ADDR(mapping);
  218. };
  219. struct sw_tx_bd {
  220. struct sk_buff *skb;
  221. u16 first_bd;
  222. u8 flags;
  223. /* Set on the first BD descriptor when there is a split BD */
  224. #define BNX2X_TSO_SPLIT_BD (1<<0)
  225. };
  226. struct sw_rx_page {
  227. struct page *page;
  228. DEFINE_DMA_UNMAP_ADDR(mapping);
  229. };
  230. union db_prod {
  231. struct doorbell_set_prod data;
  232. u32 raw;
  233. };
  234. /* MC hsi */
  235. #define BCM_PAGE_SHIFT 12
  236. #define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT)
  237. #define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1))
  238. #define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
  239. #define PAGES_PER_SGE_SHIFT 0
  240. #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
  241. #define SGE_PAGE_SIZE PAGE_SIZE
  242. #define SGE_PAGE_SHIFT PAGE_SHIFT
  243. #define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr))
  244. /* SGE ring related macros */
  245. #define NUM_RX_SGE_PAGES 2
  246. #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
  247. #define MAX_RX_SGE_CNT (RX_SGE_CNT - 2)
  248. /* RX_SGE_CNT is promised to be a power of 2 */
  249. #define RX_SGE_MASK (RX_SGE_CNT - 1)
  250. #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES)
  251. #define MAX_RX_SGE (NUM_RX_SGE - 1)
  252. #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \
  253. (MAX_RX_SGE_CNT - 1)) ? (x) + 3 : (x) + 1)
  254. #define RX_SGE(x) ((x) & MAX_RX_SGE)
  255. /* Manipulate a bit vector defined as an array of u64 */
  256. /* Number of bits in one sge_mask array element */
  257. #define BIT_VEC64_ELEM_SZ 64
  258. #define BIT_VEC64_ELEM_SHIFT 6
  259. #define BIT_VEC64_ELEM_MASK ((u64)BIT_VEC64_ELEM_SZ - 1)
  260. #define __BIT_VEC64_SET_BIT(el, bit) \
  261. do { \
  262. el = ((el) | ((u64)0x1 << (bit))); \
  263. } while (0)
  264. #define __BIT_VEC64_CLEAR_BIT(el, bit) \
  265. do { \
  266. el = ((el) & (~((u64)0x1 << (bit)))); \
  267. } while (0)
  268. #define BIT_VEC64_SET_BIT(vec64, idx) \
  269. __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
  270. (idx) & BIT_VEC64_ELEM_MASK)
  271. #define BIT_VEC64_CLEAR_BIT(vec64, idx) \
  272. __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
  273. (idx) & BIT_VEC64_ELEM_MASK)
  274. #define BIT_VEC64_TEST_BIT(vec64, idx) \
  275. (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
  276. ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
  277. /* Creates a bitmask of all ones in less significant bits.
  278. idx - index of the most significant bit in the created mask */
  279. #define BIT_VEC64_ONES_MASK(idx) \
  280. (((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
  281. #define BIT_VEC64_ELEM_ONE_MASK ((u64)(~0))
  282. /*******************************************************/
  283. /* Number of u64 elements in SGE mask array */
  284. #define RX_SGE_MASK_LEN ((NUM_RX_SGE_PAGES * RX_SGE_CNT) / \
  285. BIT_VEC64_ELEM_SZ)
  286. #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1)
  287. #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK)
  288. union host_hc_status_block {
  289. /* pointer to fp status block e1x */
  290. struct host_hc_status_block_e1x *e1x_sb;
  291. /* pointer to fp status block e2 */
  292. struct host_hc_status_block_e2 *e2_sb;
  293. };
  294. struct bnx2x_agg_info {
  295. /*
  296. * First aggregation buffer is an skb, the following - are pages.
  297. * We will preallocate the skbs for each aggregation when
  298. * we open the interface and will replace the BD at the consumer
  299. * with this one when we receive the TPA_START CQE in order to
  300. * keep the Rx BD ring consistent.
  301. */
  302. struct sw_rx_bd first_buf;
  303. u8 tpa_state;
  304. #define BNX2X_TPA_START 1
  305. #define BNX2X_TPA_STOP 2
  306. #define BNX2X_TPA_ERROR 3
  307. u8 placement_offset;
  308. u16 parsing_flags;
  309. u16 vlan_tag;
  310. u16 len_on_bd;
  311. };
  312. #define Q_STATS_OFFSET32(stat_name) \
  313. (offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
  314. struct bnx2x_fastpath {
  315. struct bnx2x *bp; /* parent */
  316. #define BNX2X_NAPI_WEIGHT 128
  317. struct napi_struct napi;
  318. union host_hc_status_block status_blk;
  319. /* chip independed shortcuts into sb structure */
  320. __le16 *sb_index_values;
  321. __le16 *sb_running_index;
  322. /* chip independed shortcut into rx_prods_offset memory */
  323. u32 ustorm_rx_prods_offset;
  324. u32 rx_buf_size;
  325. dma_addr_t status_blk_mapping;
  326. struct sw_tx_bd *tx_buf_ring;
  327. union eth_tx_bd_types *tx_desc_ring;
  328. dma_addr_t tx_desc_mapping;
  329. struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */
  330. struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */
  331. struct eth_rx_bd *rx_desc_ring;
  332. dma_addr_t rx_desc_mapping;
  333. union eth_rx_cqe *rx_comp_ring;
  334. dma_addr_t rx_comp_mapping;
  335. /* SGE ring */
  336. struct eth_rx_sge *rx_sge_ring;
  337. dma_addr_t rx_sge_mapping;
  338. u64 sge_mask[RX_SGE_MASK_LEN];
  339. u32 cid;
  340. u8 index; /* number in fp array */
  341. u8 cl_id; /* eth client id */
  342. u8 cl_qzone_id;
  343. u8 fw_sb_id; /* status block number in FW */
  344. u8 igu_sb_id; /* status block number in HW */
  345. union db_prod tx_db;
  346. u16 tx_pkt_prod;
  347. u16 tx_pkt_cons;
  348. u16 tx_bd_prod;
  349. u16 tx_bd_cons;
  350. __le16 *tx_cons_sb;
  351. __le16 fp_hc_idx;
  352. u16 rx_bd_prod;
  353. u16 rx_bd_cons;
  354. u16 rx_comp_prod;
  355. u16 rx_comp_cons;
  356. u16 rx_sge_prod;
  357. /* The last maximal completed SGE */
  358. u16 last_max_sge;
  359. __le16 *rx_cons_sb;
  360. unsigned long tx_pkt,
  361. rx_pkt,
  362. rx_calls;
  363. /* TPA related */
  364. struct bnx2x_agg_info tpa_info[ETH_MAX_AGGREGATION_QUEUES_E1H_E2];
  365. u8 disable_tpa;
  366. #ifdef BNX2X_STOP_ON_ERROR
  367. u64 tpa_queue_used;
  368. #endif
  369. struct tstorm_per_queue_stats old_tclient;
  370. struct ustorm_per_queue_stats old_uclient;
  371. struct xstorm_per_queue_stats old_xclient;
  372. struct bnx2x_eth_q_stats eth_q_stats;
  373. /* The size is calculated using the following:
  374. sizeof name field from netdev structure +
  375. 4 ('-Xx-' string) +
  376. 4 (for the digits and to make it DWORD aligned) */
  377. #define FP_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
  378. char name[FP_NAME_SIZE];
  379. /* MACs object */
  380. struct bnx2x_vlan_mac_obj mac_obj;
  381. /* Queue State object */
  382. struct bnx2x_queue_sp_obj q_obj;
  383. };
  384. #define bnx2x_fp(bp, nr, var) (bp->fp[nr].var)
  385. /* Use 2500 as a mini-jumbo MTU for FCoE */
  386. #define BNX2X_FCOE_MINI_JUMBO_MTU 2500
  387. /* FCoE L2 `fastpath' entry is right after the eth entries */
  388. #define FCOE_IDX BNX2X_NUM_ETH_QUEUES(bp)
  389. #define bnx2x_fcoe_fp(bp) (&bp->fp[FCOE_IDX])
  390. #define bnx2x_fcoe(bp, var) (bnx2x_fcoe_fp(bp)->var)
  391. #ifdef BCM_CNIC
  392. #define IS_FCOE_FP(fp) (fp->index == FCOE_IDX)
  393. #define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX)
  394. #else
  395. #define IS_FCOE_FP(fp) false
  396. #define IS_FCOE_IDX(idx) false
  397. #endif
  398. /* MC hsi */
  399. #define MAX_FETCH_BD 13 /* HW max BDs per packet */
  400. #define RX_COPY_THRESH 92
  401. #define NUM_TX_RINGS 16
  402. #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
  403. #define MAX_TX_DESC_CNT (TX_DESC_CNT - 1)
  404. #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS)
  405. #define MAX_TX_BD (NUM_TX_BD - 1)
  406. #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
  407. #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \
  408. (MAX_TX_DESC_CNT - 1)) ? (x) + 2 : (x) + 1)
  409. #define TX_BD(x) ((x) & MAX_TX_BD)
  410. #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT)
  411. /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
  412. #define NUM_RX_RINGS 8
  413. #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
  414. #define MAX_RX_DESC_CNT (RX_DESC_CNT - 2)
  415. #define RX_DESC_MASK (RX_DESC_CNT - 1)
  416. #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS)
  417. #define MAX_RX_BD (NUM_RX_BD - 1)
  418. #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
  419. #define MIN_RX_AVAIL 128
  420. #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \
  421. ETH_MIN_RX_CQES_WITH_TPA_E1 : \
  422. ETH_MIN_RX_CQES_WITH_TPA_E1H_E2)
  423. #define MIN_RX_SIZE_NONTPA_HW ETH_MIN_RX_CQES_WITHOUT_TPA
  424. #define MIN_RX_SIZE_TPA (max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL))
  425. #define MIN_RX_SIZE_NONTPA (max_t(u32, MIN_RX_SIZE_NONTPA_HW,\
  426. MIN_RX_AVAIL))
  427. #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \
  428. (MAX_RX_DESC_CNT - 1)) ? (x) + 3 : (x) + 1)
  429. #define RX_BD(x) ((x) & MAX_RX_BD)
  430. /*
  431. * As long as CQE is X times bigger than BD entry we have to allocate X times
  432. * more pages for CQ ring in order to keep it balanced with BD ring
  433. */
  434. #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
  435. #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL)
  436. #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
  437. #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - 1)
  438. #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS)
  439. #define MAX_RCQ_BD (NUM_RCQ_BD - 1)
  440. #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
  441. #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \
  442. (MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1)
  443. #define RCQ_BD(x) ((x) & MAX_RCQ_BD)
  444. /* This is needed for determining of last_max */
  445. #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b))
  446. #define SUB_S32(a, b) (s32)((s32)(a) - (s32)(b))
  447. #define BNX2X_SWCID_SHIFT 17
  448. #define BNX2X_SWCID_MASK ((0x1 << BNX2X_SWCID_SHIFT) - 1)
  449. /* used on a CID received from the HW */
  450. #define SW_CID(x) (le32_to_cpu(x) & BNX2X_SWCID_MASK)
  451. #define CQE_CMD(x) (le32_to_cpu(x) >> \
  452. COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
  453. #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \
  454. le32_to_cpu((bd)->addr_lo))
  455. #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
  456. #define BNX2X_DB_MIN_SHIFT 3 /* 8 bytes */
  457. #define BNX2X_DB_SHIFT 7 /* 128 bytes*/
  458. #if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT)
  459. #error "Min DB doorbell stride is 8"
  460. #endif
  461. #define DPM_TRIGER_TYPE 0x40
  462. #define DOORBELL(bp, cid, val) \
  463. do { \
  464. writel((u32)(val), bp->doorbells + (bp->db_size * (cid)) + \
  465. DPM_TRIGER_TYPE); \
  466. } while (0)
  467. /* TX CSUM helpers */
  468. #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \
  469. skb->csum_offset)
  470. #define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \
  471. skb->csum_offset))
  472. #define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff)
  473. #define XMIT_PLAIN 0
  474. #define XMIT_CSUM_V4 0x1
  475. #define XMIT_CSUM_V6 0x2
  476. #define XMIT_CSUM_TCP 0x4
  477. #define XMIT_GSO_V4 0x8
  478. #define XMIT_GSO_V6 0x10
  479. #define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6)
  480. #define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6)
  481. /* stuff added to make the code fit 80Col */
  482. #define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
  483. #define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG)
  484. #define CQE_TYPE_STOP(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG)
  485. #define CQE_TYPE_SLOW(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD)
  486. #define CQE_TYPE_FAST(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH)
  487. #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
  488. #define BNX2X_IP_CSUM_ERR(cqe) \
  489. (!((cqe)->fast_path_cqe.status_flags & \
  490. ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG) && \
  491. ((cqe)->fast_path_cqe.type_error_flags & \
  492. ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG))
  493. #define BNX2X_L4_CSUM_ERR(cqe) \
  494. (!((cqe)->fast_path_cqe.status_flags & \
  495. ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG) && \
  496. ((cqe)->fast_path_cqe.type_error_flags & \
  497. ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG))
  498. #define BNX2X_RX_CSUM_OK(cqe) \
  499. (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe)))
  500. #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
  501. (((le16_to_cpu(flags) & \
  502. PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
  503. PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
  504. == PRS_FLAG_OVERETH_IPV4)
  505. #define BNX2X_RX_SUM_FIX(cqe) \
  506. BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
  507. #define FP_USB_FUNC_OFF \
  508. offsetof(struct cstorm_status_block_u, func)
  509. #define FP_CSB_FUNC_OFF \
  510. offsetof(struct cstorm_status_block_c, func)
  511. #define HC_INDEX_TOE_RX_CQ_CONS 0 /* Formerly Ustorm TOE CQ index */
  512. /* (HC_INDEX_U_TOE_RX_CQ_CONS) */
  513. #define HC_INDEX_ETH_RX_CQ_CONS 1 /* Formerly Ustorm ETH CQ index */
  514. /* (HC_INDEX_U_ETH_RX_CQ_CONS) */
  515. #define HC_INDEX_ETH_RX_BD_CONS 2 /* Formerly Ustorm ETH BD index */
  516. /* (HC_INDEX_U_ETH_RX_BD_CONS) */
  517. #define HC_INDEX_TOE_TX_CQ_CONS 4 /* Formerly Cstorm TOE CQ index */
  518. /* (HC_INDEX_C_TOE_TX_CQ_CONS) */
  519. #define HC_INDEX_ETH_TX_CQ_CONS 5 /* Formerly Cstorm ETH CQ index */
  520. /* (HC_INDEX_C_ETH_TX_CQ_CONS) */
  521. #define U_SB_ETH_RX_CQ_INDEX HC_INDEX_ETH_RX_CQ_CONS
  522. #define U_SB_ETH_RX_BD_INDEX HC_INDEX_ETH_RX_BD_CONS
  523. #define C_SB_ETH_TX_CQ_INDEX HC_INDEX_ETH_TX_CQ_CONS
  524. #define BNX2X_RX_SB_INDEX \
  525. (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
  526. #define BNX2X_TX_SB_INDEX \
  527. (&fp->sb_index_values[C_SB_ETH_TX_CQ_INDEX])
  528. /* end of fast path */
  529. /* common */
  530. struct bnx2x_common {
  531. u32 chip_id;
  532. /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
  533. #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0)
  534. #define CHIP_NUM(bp) (bp->common.chip_id >> 16)
  535. #define CHIP_NUM_57710 0x164e
  536. #define CHIP_NUM_57711 0x164f
  537. #define CHIP_NUM_57711E 0x1650
  538. #define CHIP_NUM_57712 0x1662
  539. #define CHIP_NUM_57712_MF 0x1663
  540. #define CHIP_NUM_57713 0x1651
  541. #define CHIP_NUM_57713E 0x1652
  542. #define CHIP_NUM_57800 0x168a
  543. #define CHIP_NUM_57800_MF 0x16a5
  544. #define CHIP_NUM_57810 0x168e
  545. #define CHIP_NUM_57810_MF 0x16ae
  546. #define CHIP_NUM_57840 0x168d
  547. #define CHIP_NUM_57840_MF 0x16ab
  548. #define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710)
  549. #define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711)
  550. #define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E)
  551. #define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712)
  552. #define CHIP_IS_57712_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57712_MF)
  553. #define CHIP_IS_57800(bp) (CHIP_NUM(bp) == CHIP_NUM_57800)
  554. #define CHIP_IS_57800_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57800_MF)
  555. #define CHIP_IS_57810(bp) (CHIP_NUM(bp) == CHIP_NUM_57810)
  556. #define CHIP_IS_57810_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57810_MF)
  557. #define CHIP_IS_57840(bp) (CHIP_NUM(bp) == CHIP_NUM_57840)
  558. #define CHIP_IS_57840_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57840_MF)
  559. #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \
  560. CHIP_IS_57711E(bp))
  561. #define CHIP_IS_E2(bp) (CHIP_IS_57712(bp) || \
  562. CHIP_IS_57712_MF(bp))
  563. #define CHIP_IS_E3(bp) (CHIP_IS_57800(bp) || \
  564. CHIP_IS_57800_MF(bp) || \
  565. CHIP_IS_57810(bp) || \
  566. CHIP_IS_57810_MF(bp) || \
  567. CHIP_IS_57840(bp) || \
  568. CHIP_IS_57840_MF(bp))
  569. #define CHIP_IS_E1x(bp) (CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
  570. #define USES_WARPCORE(bp) (CHIP_IS_E3(bp))
  571. #define IS_E1H_OFFSET (!CHIP_IS_E1(bp))
  572. #define CHIP_REV_SHIFT 12
  573. #define CHIP_REV_MASK (0xF << CHIP_REV_SHIFT)
  574. #define CHIP_REV_VAL(bp) (bp->common.chip_id & CHIP_REV_MASK)
  575. #define CHIP_REV_Ax (0x0 << CHIP_REV_SHIFT)
  576. #define CHIP_REV_Bx (0x1 << CHIP_REV_SHIFT)
  577. /* assume maximum 5 revisions */
  578. #define CHIP_REV_IS_SLOW(bp) (CHIP_REV_VAL(bp) > 0x00005000)
  579. /* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */
  580. #define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \
  581. !(CHIP_REV_VAL(bp) & 0x00001000))
  582. /* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */
  583. #define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \
  584. (CHIP_REV_VAL(bp) & 0x00001000))
  585. #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
  586. ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
  587. #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0)
  588. #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f)
  589. #define CHIP_REV_SIM(bp) (((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\
  590. (CHIP_REV_SHIFT + 1)) \
  591. << CHIP_REV_SHIFT)
  592. #define CHIP_REV(bp) (CHIP_REV_IS_SLOW(bp) ? \
  593. CHIP_REV_SIM(bp) :\
  594. CHIP_REV_VAL(bp))
  595. #define CHIP_IS_E3B0(bp) (CHIP_IS_E3(bp) && \
  596. (CHIP_REV(bp) == CHIP_REV_Bx))
  597. #define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \
  598. (CHIP_REV(bp) == CHIP_REV_Ax))
  599. int flash_size;
  600. #define BNX2X_NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */
  601. #define BNX2X_NVRAM_TIMEOUT_COUNT 30000
  602. #define BNX2X_NVRAM_PAGE_SIZE 256
  603. u32 shmem_base;
  604. u32 shmem2_base;
  605. u32 mf_cfg_base;
  606. u32 mf2_cfg_base;
  607. u32 hw_config;
  608. u32 bc_ver;
  609. u8 int_block;
  610. #define INT_BLOCK_HC 0
  611. #define INT_BLOCK_IGU 1
  612. #define INT_BLOCK_MODE_NORMAL 0
  613. #define INT_BLOCK_MODE_BW_COMP 2
  614. #define CHIP_INT_MODE_IS_NBC(bp) \
  615. (!CHIP_IS_E1x(bp) && \
  616. !((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
  617. #define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
  618. u8 chip_port_mode;
  619. #define CHIP_4_PORT_MODE 0x0
  620. #define CHIP_2_PORT_MODE 0x1
  621. #define CHIP_PORT_MODE_NONE 0x2
  622. #define CHIP_MODE(bp) (bp->common.chip_port_mode)
  623. #define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
  624. };
  625. /* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
  626. #define BNX2X_IGU_STAS_MSG_VF_CNT 64
  627. #define BNX2X_IGU_STAS_MSG_PF_CNT 4
  628. /* end of common */
  629. /* port */
  630. struct bnx2x_port {
  631. u32 pmf;
  632. u32 link_config[LINK_CONFIG_SIZE];
  633. u32 supported[LINK_CONFIG_SIZE];
  634. /* link settings - missing defines */
  635. #define SUPPORTED_2500baseX_Full (1 << 15)
  636. u32 advertising[LINK_CONFIG_SIZE];
  637. /* link settings - missing defines */
  638. #define ADVERTISED_2500baseX_Full (1 << 15)
  639. u32 phy_addr;
  640. /* used to synchronize phy accesses */
  641. struct mutex phy_mutex;
  642. int need_hw_lock;
  643. u32 port_stx;
  644. struct nig_stats old_nig_stats;
  645. };
  646. /* end of port */
  647. #define STATS_OFFSET32(stat_name) \
  648. (offsetof(struct bnx2x_eth_stats, stat_name) / 4)
  649. /* slow path */
  650. /* slow path work-queue */
  651. extern struct workqueue_struct *bnx2x_wq;
  652. #define BNX2X_MAX_NUM_OF_VFS 64
  653. #define BNX2X_VF_ID_INVALID 0xFF
  654. /*
  655. * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is
  656. * control by the number of fast-path status blocks supported by the
  657. * device (HW/FW). Each fast-path status block (FP-SB) aka non-default
  658. * status block represents an independent interrupts context that can
  659. * serve a regular L2 networking queue. However special L2 queues such
  660. * as the FCoE queue do not require a FP-SB and other components like
  661. * the CNIC may consume FP-SB reducing the number of possible L2 queues
  662. *
  663. * If the maximum number of FP-SB available is X then:
  664. * a. If CNIC is supported it consumes 1 FP-SB thus the max number of
  665. * regular L2 queues is Y=X-1
  666. * b. in MF mode the actual number of L2 queues is Y= (X-1/MF_factor)
  667. * c. If the FCoE L2 queue is supported the actual number of L2 queues
  668. * is Y+1
  669. * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for
  670. * slow-path interrupts) or Y+2 if CNIC is supported (one additional
  671. * FP interrupt context for the CNIC).
  672. * e. The number of HW context (CID count) is always X or X+1 if FCoE
  673. * L2 queue is supported. the cid for the FCoE L2 queue is always X.
  674. */
  675. /* fast-path interrupt contexts E1x */
  676. #define FP_SB_MAX_E1x 16
  677. /* fast-path interrupt contexts E2 */
  678. #define FP_SB_MAX_E2 HC_SB_MAX_SB_E2
  679. /*
  680. * cid_cnt paramter below refers to the value returned by
  681. * 'bnx2x_get_l2_cid_count()' routine
  682. */
  683. /*
  684. * The number of FP context allocated by the driver == max number of regular
  685. * L2 queues + 1 for the FCoE L2 queue
  686. */
  687. #define L2_FP_COUNT(cid_cnt) ((cid_cnt) - FCOE_CONTEXT_USE)
  688. /*
  689. * The number of FP-SB allocated by the driver == max number of regular L2
  690. * queues + 1 for the CNIC which also consumes an FP-SB
  691. */
  692. #define FP_SB_COUNT(cid_cnt) ((cid_cnt) - CNIC_CONTEXT_USE)
  693. #define NUM_IGU_SB_REQUIRED(cid_cnt) \
  694. (FP_SB_COUNT(cid_cnt) - NONE_ETH_CONTEXT_USE)
  695. union cdu_context {
  696. struct eth_context eth;
  697. char pad[1024];
  698. };
  699. /* CDU host DB constants */
  700. #define CDU_ILT_PAGE_SZ_HW 3
  701. #define CDU_ILT_PAGE_SZ (4096 << CDU_ILT_PAGE_SZ_HW) /* 32K */
  702. #define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
  703. #ifdef BCM_CNIC
  704. #define CNIC_ISCSI_CID_MAX 256
  705. #define CNIC_FCOE_CID_MAX 2048
  706. #define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
  707. #define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
  708. #endif
  709. #define QM_ILT_PAGE_SZ_HW 0
  710. #define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
  711. #define QM_CID_ROUND 1024
  712. #ifdef BCM_CNIC
  713. /* TM (timers) host DB constants */
  714. #define TM_ILT_PAGE_SZ_HW 0
  715. #define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
  716. /* #define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */
  717. #define TM_CONN_NUM 1024
  718. #define TM_ILT_SZ (8 * TM_CONN_NUM)
  719. #define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
  720. /* SRC (Searcher) host DB constants */
  721. #define SRC_ILT_PAGE_SZ_HW 0
  722. #define SRC_ILT_PAGE_SZ (4096 << SRC_ILT_PAGE_SZ_HW) /* 4K */
  723. #define SRC_HASH_BITS 10
  724. #define SRC_CONN_NUM (1 << SRC_HASH_BITS) /* 1024 */
  725. #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)
  726. #define SRC_T2_SZ SRC_ILT_SZ
  727. #define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
  728. #endif
  729. #define MAX_DMAE_C 8
  730. /* DMA memory not used in fastpath */
  731. struct bnx2x_slowpath {
  732. union {
  733. struct mac_configuration_cmd e1x;
  734. struct eth_classify_rules_ramrod_data e2;
  735. } mac_rdata;
  736. union {
  737. struct tstorm_eth_mac_filter_config e1x;
  738. struct eth_filter_rules_ramrod_data e2;
  739. } rx_mode_rdata;
  740. union {
  741. struct mac_configuration_cmd e1;
  742. struct eth_multicast_rules_ramrod_data e2;
  743. } mcast_rdata;
  744. struct eth_rss_update_ramrod_data rss_rdata;
  745. /* Queue State related ramrods are always sent under rtnl_lock */
  746. union {
  747. struct client_init_ramrod_data init_data;
  748. struct client_update_ramrod_data update_data;
  749. } q_rdata;
  750. union {
  751. struct function_start_data func_start;
  752. } func_rdata;
  753. /* used by dmae command executer */
  754. struct dmae_command dmae[MAX_DMAE_C];
  755. u32 stats_comp;
  756. union mac_stats mac_stats;
  757. struct nig_stats nig_stats;
  758. struct host_port_stats port_stats;
  759. struct host_func_stats func_stats;
  760. struct host_func_stats func_stats_base;
  761. u32 wb_comp;
  762. u32 wb_data[4];
  763. /* pfc configuration for DCBX ramrod */
  764. struct flow_control_configuration pfc_config;
  765. };
  766. #define bnx2x_sp(bp, var) (&bp->slowpath->var)
  767. #define bnx2x_sp_mapping(bp, var) \
  768. (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
  769. /* attn group wiring */
  770. #define MAX_DYNAMIC_ATTN_GRPS 8
  771. struct attn_route {
  772. u32 sig[5];
  773. };
  774. struct iro {
  775. u32 base;
  776. u16 m1;
  777. u16 m2;
  778. u16 m3;
  779. u16 size;
  780. };
  781. struct hw_context {
  782. union cdu_context *vcxt;
  783. dma_addr_t cxt_mapping;
  784. size_t size;
  785. };
  786. /* forward */
  787. struct bnx2x_ilt;
  788. enum bnx2x_recovery_state {
  789. BNX2X_RECOVERY_DONE,
  790. BNX2X_RECOVERY_INIT,
  791. BNX2X_RECOVERY_WAIT,
  792. BNX2X_RECOVERY_FAILED
  793. };
  794. /*
  795. * Event queue (EQ or event ring) MC hsi
  796. * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2
  797. */
  798. #define NUM_EQ_PAGES 1
  799. #define EQ_DESC_CNT_PAGE (BCM_PAGE_SIZE / sizeof(union event_ring_elem))
  800. #define EQ_DESC_MAX_PAGE (EQ_DESC_CNT_PAGE - 1)
  801. #define NUM_EQ_DESC (EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
  802. #define EQ_DESC_MASK (NUM_EQ_DESC - 1)
  803. #define MAX_EQ_AVAIL (EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
  804. /* depends on EQ_DESC_CNT_PAGE being a power of 2 */
  805. #define NEXT_EQ_IDX(x) ((((x) & EQ_DESC_MAX_PAGE) == \
  806. (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
  807. /* depends on the above and on NUM_EQ_PAGES being a power of 2 */
  808. #define EQ_DESC(x) ((x) & EQ_DESC_MASK)
  809. #define BNX2X_EQ_INDEX \
  810. (&bp->def_status_blk->sp_sb.\
  811. index_values[HC_SP_INDEX_EQ_CONS])
  812. /* This is a data that will be used to create a link report message.
  813. * We will keep the data used for the last link report in order
  814. * to prevent reporting the same link parameters twice.
  815. */
  816. struct bnx2x_link_report_data {
  817. u16 line_speed; /* Effective line speed */
  818. unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */
  819. };
  820. enum {
  821. BNX2X_LINK_REPORT_FD, /* Full DUPLEX */
  822. BNX2X_LINK_REPORT_LINK_DOWN,
  823. BNX2X_LINK_REPORT_RX_FC_ON,
  824. BNX2X_LINK_REPORT_TX_FC_ON,
  825. };
  826. enum {
  827. BNX2X_PORT_QUERY_IDX,
  828. BNX2X_PF_QUERY_IDX,
  829. BNX2X_FIRST_QUEUE_QUERY_IDX,
  830. };
  831. struct bnx2x_fw_stats_req {
  832. struct stats_query_header hdr;
  833. struct stats_query_entry query[STATS_QUERY_CMD_COUNT];
  834. };
  835. struct bnx2x_fw_stats_data {
  836. struct stats_counter storm_counters;
  837. struct per_port_stats port;
  838. struct per_pf_stats pf;
  839. struct per_queue_stats queue_stats[1];
  840. };
  841. struct bnx2x {
  842. /* Fields used in the tx and intr/napi performance paths
  843. * are grouped together in the beginning of the structure
  844. */
  845. struct bnx2x_fastpath *fp;
  846. void __iomem *regview;
  847. void __iomem *doorbells;
  848. u16 db_size;
  849. u8 pf_num; /* absolute PF number */
  850. u8 pfid; /* per-path PF number */
  851. int base_fw_ndsb; /**/
  852. #define BP_PATH(bp) (CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1))
  853. #define BP_PORT(bp) (bp->pfid & 1)
  854. #define BP_FUNC(bp) (bp->pfid)
  855. #define BP_ABS_FUNC(bp) (bp->pf_num)
  856. #define BP_E1HVN(bp) (bp->pfid >> 1)
  857. #define BP_VN(bp) (BP_E1HVN(bp)) /*remove when approved*/
  858. #define BP_L_ID(bp) (BP_E1HVN(bp) << 2)
  859. #define BP_FW_MB_IDX(bp) (BP_PORT(bp) +\
  860. BP_VN(bp) * (CHIP_IS_E1x(bp) ? 2 : 1))
  861. struct net_device *dev;
  862. struct pci_dev *pdev;
  863. const struct iro *iro_arr;
  864. #define IRO (bp->iro_arr)
  865. enum bnx2x_recovery_state recovery_state;
  866. int is_leader;
  867. struct msix_entry *msix_table;
  868. int tx_ring_size;
  869. /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
  870. #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
  871. #define ETH_MIN_PACKET_SIZE 60
  872. #define ETH_MAX_PACKET_SIZE 1500
  873. #define ETH_MAX_JUMBO_PACKET_SIZE 9600
  874. /* Max supported alignment is 256 (8 shift) */
  875. #define BNX2X_RX_ALIGN_SHIFT ((L1_CACHE_SHIFT < 8) ? \
  876. L1_CACHE_SHIFT : 8)
  877. /* FW use 2 Cache lines Alignment for start packet and size */
  878. #define BNX2X_FW_RX_ALIGN (2 << BNX2X_RX_ALIGN_SHIFT)
  879. #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5)
  880. struct host_sp_status_block *def_status_blk;
  881. #define DEF_SB_IGU_ID 16
  882. #define DEF_SB_ID HC_SP_SB_ID
  883. __le16 def_idx;
  884. __le16 def_att_idx;
  885. u32 attn_state;
  886. struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS];
  887. /* slow path ring */
  888. struct eth_spe *spq;
  889. dma_addr_t spq_mapping;
  890. u16 spq_prod_idx;
  891. struct eth_spe *spq_prod_bd;
  892. struct eth_spe *spq_last_bd;
  893. __le16 *dsb_sp_prod;
  894. atomic_t cq_spq_left; /* ETH_XXX ramrods credit */
  895. /* used to synchronize spq accesses */
  896. spinlock_t spq_lock;
  897. /* event queue */
  898. union event_ring_elem *eq_ring;
  899. dma_addr_t eq_mapping;
  900. u16 eq_prod;
  901. u16 eq_cons;
  902. __le16 *eq_cons_sb;
  903. atomic_t eq_spq_left; /* COMMON_XXX ramrods credit */
  904. /* Counter for marking that there is a STAT_QUERY ramrod pending */
  905. u16 stats_pending;
  906. /* Counter for completed statistics ramrods */
  907. u16 stats_comp;
  908. /* End of fields used in the performance code paths */
  909. int panic;
  910. int msg_enable;
  911. u32 flags;
  912. #define PCIX_FLAG (1 << 0)
  913. #define PCI_32BIT_FLAG (1 << 1)
  914. #define ONE_PORT_FLAG (1 << 2)
  915. #define NO_WOL_FLAG (1 << 3)
  916. #define USING_DAC_FLAG (1 << 4)
  917. #define USING_MSIX_FLAG (1 << 5)
  918. #define USING_MSI_FLAG (1 << 6)
  919. #define DISABLE_MSI_FLAG (1 << 7)
  920. #define TPA_ENABLE_FLAG (1 << 8)
  921. #define NO_MCP_FLAG (1 << 9)
  922. #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
  923. #define MF_FUNC_DIS (1 << 11)
  924. #define OWN_CNIC_IRQ (1 << 12)
  925. #define NO_ISCSI_OOO_FLAG (1 << 13)
  926. #define NO_ISCSI_FLAG (1 << 14)
  927. #define NO_FCOE_FLAG (1 << 15)
  928. #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG)
  929. #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
  930. #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG)
  931. int pm_cap;
  932. int pcie_cap;
  933. int mrrs;
  934. struct delayed_work sp_task;
  935. struct delayed_work reset_task;
  936. struct delayed_work period_task;
  937. struct timer_list timer;
  938. int current_interval;
  939. u16 fw_seq;
  940. u16 fw_drv_pulse_wr_seq;
  941. u32 func_stx;
  942. struct link_params link_params;
  943. struct link_vars link_vars;
  944. u32 link_cnt;
  945. struct bnx2x_link_report_data last_reported_link;
  946. struct mdio_if_info mdio;
  947. struct bnx2x_common common;
  948. struct bnx2x_port port;
  949. struct cmng_struct_per_port cmng;
  950. u32 vn_weight_sum;
  951. u32 mf_config[E1HVN_MAX];
  952. u32 mf2_config[E2_FUNC_MAX];
  953. u32 path_has_ovlan; /* E3 */
  954. u16 mf_ov;
  955. u8 mf_mode;
  956. #define IS_MF(bp) (bp->mf_mode != 0)
  957. #define IS_MF_SI(bp) (bp->mf_mode == MULTI_FUNCTION_SI)
  958. #define IS_MF_SD(bp) (bp->mf_mode == MULTI_FUNCTION_SD)
  959. u8 wol;
  960. int rx_ring_size;
  961. u16 tx_quick_cons_trip_int;
  962. u16 tx_quick_cons_trip;
  963. u16 tx_ticks_int;
  964. u16 tx_ticks;
  965. u16 rx_quick_cons_trip_int;
  966. u16 rx_quick_cons_trip;
  967. u16 rx_ticks_int;
  968. u16 rx_ticks;
  969. /* Maximal coalescing timeout in us */
  970. #define BNX2X_MAX_COALESCE_TOUT (0xf0*12)
  971. u32 lin_cnt;
  972. u16 state;
  973. #define BNX2X_STATE_CLOSED 0
  974. #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000
  975. #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000
  976. #define BNX2X_STATE_OPEN 0x3000
  977. #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
  978. #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
  979. #define BNX2X_STATE_DIAG 0xe000
  980. #define BNX2X_STATE_ERROR 0xf000
  981. int multi_mode;
  982. int num_queues;
  983. int disable_tpa;
  984. u32 rx_mode;
  985. #define BNX2X_RX_MODE_NONE 0
  986. #define BNX2X_RX_MODE_NORMAL 1
  987. #define BNX2X_RX_MODE_ALLMULTI 2
  988. #define BNX2X_RX_MODE_PROMISC 3
  989. #define BNX2X_MAX_MULTICAST 64
  990. u8 igu_dsb_id;
  991. u8 igu_base_sb;
  992. u8 igu_sb_cnt;
  993. dma_addr_t def_status_blk_mapping;
  994. struct bnx2x_slowpath *slowpath;
  995. dma_addr_t slowpath_mapping;
  996. /* Total number of FW statistics requests */
  997. u8 fw_stats_num;
  998. /*
  999. * This is a memory buffer that will contain both statistics
  1000. * ramrod request and data.
  1001. */
  1002. void *fw_stats;
  1003. dma_addr_t fw_stats_mapping;
  1004. /*
  1005. * FW statistics request shortcut (points at the
  1006. * beginning of fw_stats buffer).
  1007. */
  1008. struct bnx2x_fw_stats_req *fw_stats_req;
  1009. dma_addr_t fw_stats_req_mapping;
  1010. int fw_stats_req_sz;
  1011. /*
  1012. * FW statistics data shortcut (points at the begining of
  1013. * fw_stats buffer + fw_stats_req_sz).
  1014. */
  1015. struct bnx2x_fw_stats_data *fw_stats_data;
  1016. dma_addr_t fw_stats_data_mapping;
  1017. int fw_stats_data_sz;
  1018. struct hw_context context;
  1019. struct bnx2x_ilt *ilt;
  1020. #define BP_ILT(bp) ((bp)->ilt)
  1021. #define ILT_MAX_LINES 256
  1022. int l2_cid_count;
  1023. #define L2_ILT_LINES(bp) (DIV_ROUND_UP((bp)->l2_cid_count, \
  1024. ILT_PAGE_CIDS))
  1025. #define BNX2X_DB_SIZE(bp) ((bp)->l2_cid_count * (1 << BNX2X_DB_SHIFT))
  1026. int qm_cid_count;
  1027. int dropless_fc;
  1028. #ifdef BCM_CNIC
  1029. u32 cnic_flags;
  1030. #define BNX2X_CNIC_FLAG_MAC_SET 1
  1031. void *t2;
  1032. dma_addr_t t2_mapping;
  1033. struct cnic_ops __rcu *cnic_ops;
  1034. void *cnic_data;
  1035. u32 cnic_tag;
  1036. struct cnic_eth_dev cnic_eth_dev;
  1037. union host_hc_status_block cnic_sb;
  1038. dma_addr_t cnic_sb_mapping;
  1039. struct eth_spe *cnic_kwq;
  1040. struct eth_spe *cnic_kwq_prod;
  1041. struct eth_spe *cnic_kwq_cons;
  1042. struct eth_spe *cnic_kwq_last;
  1043. u16 cnic_kwq_pending;
  1044. u16 cnic_spq_pending;
  1045. u8 fip_mac[ETH_ALEN];
  1046. struct mutex cnic_mutex;
  1047. struct bnx2x_vlan_mac_obj iscsi_l2_mac_obj;
  1048. /* Start index of the "special" (CNIC related) L2 cleints */
  1049. u8 cnic_base_cl_id;
  1050. #endif
  1051. int dmae_ready;
  1052. /* used to synchronize dmae accesses */
  1053. spinlock_t dmae_lock;
  1054. /* used to protect the FW mail box */
  1055. struct mutex fw_mb_mutex;
  1056. /* used to synchronize stats collecting */
  1057. int stats_state;
  1058. /* used for synchronization of concurrent threads statistics handling */
  1059. spinlock_t stats_lock;
  1060. /* used by dmae command loader */
  1061. struct dmae_command stats_dmae;
  1062. int executer_idx;
  1063. u16 stats_counter;
  1064. struct bnx2x_eth_stats eth_stats;
  1065. struct z_stream_s *strm;
  1066. void *gunzip_buf;
  1067. dma_addr_t gunzip_mapping;
  1068. int gunzip_outlen;
  1069. #define FW_BUF_SIZE 0x8000
  1070. #define GUNZIP_BUF(bp) (bp->gunzip_buf)
  1071. #define GUNZIP_PHYS(bp) (bp->gunzip_mapping)
  1072. #define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen)
  1073. struct raw_op *init_ops;
  1074. /* Init blocks offsets inside init_ops */
  1075. u16 *init_ops_offsets;
  1076. /* Data blob - has 32 bit granularity */
  1077. u32 *init_data;
  1078. u32 init_mode_flags;
  1079. #define INIT_MODE_FLAGS(bp) (bp->init_mode_flags)
  1080. /* Zipped PRAM blobs - raw data */
  1081. const u8 *tsem_int_table_data;
  1082. const u8 *tsem_pram_data;
  1083. const u8 *usem_int_table_data;
  1084. const u8 *usem_pram_data;
  1085. const u8 *xsem_int_table_data;
  1086. const u8 *xsem_pram_data;
  1087. const u8 *csem_int_table_data;
  1088. const u8 *csem_pram_data;
  1089. #define INIT_OPS(bp) (bp->init_ops)
  1090. #define INIT_OPS_OFFSETS(bp) (bp->init_ops_offsets)
  1091. #define INIT_DATA(bp) (bp->init_data)
  1092. #define INIT_TSEM_INT_TABLE_DATA(bp) (bp->tsem_int_table_data)
  1093. #define INIT_TSEM_PRAM_DATA(bp) (bp->tsem_pram_data)
  1094. #define INIT_USEM_INT_TABLE_DATA(bp) (bp->usem_int_table_data)
  1095. #define INIT_USEM_PRAM_DATA(bp) (bp->usem_pram_data)
  1096. #define INIT_XSEM_INT_TABLE_DATA(bp) (bp->xsem_int_table_data)
  1097. #define INIT_XSEM_PRAM_DATA(bp) (bp->xsem_pram_data)
  1098. #define INIT_CSEM_INT_TABLE_DATA(bp) (bp->csem_int_table_data)
  1099. #define INIT_CSEM_PRAM_DATA(bp) (bp->csem_pram_data)
  1100. #define PHY_FW_VER_LEN 20
  1101. char fw_ver[32];
  1102. const struct firmware *firmware;
  1103. /* LLDP params */
  1104. struct bnx2x_config_lldp_params lldp_config_params;
  1105. /* DCB support on/off */
  1106. u16 dcb_state;
  1107. #define BNX2X_DCB_STATE_OFF 0
  1108. #define BNX2X_DCB_STATE_ON 1
  1109. /* DCBX engine mode */
  1110. int dcbx_enabled;
  1111. #define BNX2X_DCBX_ENABLED_OFF 0
  1112. #define BNX2X_DCBX_ENABLED_ON_NEG_OFF 1
  1113. #define BNX2X_DCBX_ENABLED_ON_NEG_ON 2
  1114. #define BNX2X_DCBX_ENABLED_INVALID (-1)
  1115. bool dcbx_mode_uset;
  1116. struct bnx2x_config_dcbx_params dcbx_config_params;
  1117. struct bnx2x_dcbx_port_params dcbx_port_params;
  1118. int dcb_version;
  1119. /* CAM credit pools */
  1120. struct bnx2x_credit_pool_obj macs_pool;
  1121. /* RX_MODE object */
  1122. struct bnx2x_rx_mode_obj rx_mode_obj;
  1123. /* MCAST object */
  1124. struct bnx2x_mcast_obj mcast_obj;
  1125. /* RSS configuration object */
  1126. struct bnx2x_rss_config_obj rss_conf_obj;
  1127. /* Function State controlling object */
  1128. struct bnx2x_func_sp_obj func_obj;
  1129. unsigned long sp_state;
  1130. /* DCBX Negotation results */
  1131. struct dcbx_features dcbx_local_feat;
  1132. u32 dcbx_error;
  1133. #ifdef BCM_DCBNL
  1134. struct dcbx_features dcbx_remote_feat;
  1135. u32 dcbx_remote_flags;
  1136. #endif
  1137. u32 pending_max;
  1138. };
  1139. /* Tx queues may be less or equal to Rx queues */
  1140. extern int num_queues;
  1141. #define BNX2X_NUM_QUEUES(bp) (bp->num_queues)
  1142. #define BNX2X_NUM_ETH_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - NONE_ETH_CONTEXT_USE)
  1143. #define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1)
  1144. #define BNX2X_MAX_QUEUES(bp) (bp->igu_sb_cnt - CNIC_CONTEXT_USE)
  1145. #define RSS_IPV4_CAP_MASK \
  1146. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
  1147. #define RSS_IPV4_TCP_CAP_MASK \
  1148. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
  1149. #define RSS_IPV6_CAP_MASK \
  1150. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
  1151. #define RSS_IPV6_TCP_CAP_MASK \
  1152. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
  1153. /* func init flags */
  1154. #define FUNC_FLG_RSS 0x0001
  1155. #define FUNC_FLG_STATS 0x0002
  1156. /* removed FUNC_FLG_UNMATCHED 0x0004 */
  1157. #define FUNC_FLG_TPA 0x0008
  1158. #define FUNC_FLG_SPQ 0x0010
  1159. #define FUNC_FLG_LEADING 0x0020 /* PF only */
  1160. struct bnx2x_func_init_params {
  1161. /* dma */
  1162. dma_addr_t fw_stat_map; /* valid iff FUNC_FLG_STATS */
  1163. dma_addr_t spq_map; /* valid iff FUNC_FLG_SPQ */
  1164. u16 func_flgs;
  1165. u16 func_id; /* abs fid */
  1166. u16 pf_id;
  1167. u16 spq_prod; /* valid iff FUNC_FLG_SPQ */
  1168. };
  1169. #define for_each_eth_queue(bp, var) \
  1170. for (var = 0; var < BNX2X_NUM_ETH_QUEUES(bp); var++)
  1171. #define for_each_nondefault_eth_queue(bp, var) \
  1172. for (var = 1; var < BNX2X_NUM_ETH_QUEUES(bp); var++)
  1173. #define for_each_queue(bp, var) \
  1174. for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++) \
  1175. if (skip_queue(bp, var)) \
  1176. continue; \
  1177. else
  1178. #define for_each_rx_queue(bp, var) \
  1179. for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++) \
  1180. if (skip_rx_queue(bp, var)) \
  1181. continue; \
  1182. else
  1183. #define for_each_tx_queue(bp, var) \
  1184. for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++) \
  1185. if (skip_tx_queue(bp, var)) \
  1186. continue; \
  1187. else
  1188. #define for_each_nondefault_queue(bp, var) \
  1189. for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++) \
  1190. if (skip_queue(bp, var)) \
  1191. continue; \
  1192. else
  1193. /* skip rx queue
  1194. * if FCOE l2 support is disabled and this is the fcoe L2 queue
  1195. */
  1196. #define skip_rx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1197. /* skip tx queue
  1198. * if FCOE l2 support is disabled and this is the fcoe L2 queue
  1199. */
  1200. #define skip_tx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1201. #define skip_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1202. /**
  1203. * bnx2x_set_mac_one - configure a single MAC address
  1204. *
  1205. * @bp: driver handle
  1206. * @mac: MAC to configure
  1207. * @obj: MAC object handle
  1208. * @set: if 'true' add a new MAC, otherwise - delete
  1209. * @mac_type: the type of the MAC to configure (e.g. ETH, UC list)
  1210. * @ramrod_flags: RAMROD_XXX flags (e.g. RAMROD_CONT, RAMROD_COMP_WAIT)
  1211. *
  1212. * Configures one MAC according to provided parameters or continues the
  1213. * execution of previously scheduled commands if RAMROD_CONT is set in
  1214. * ramrod_flags.
  1215. *
  1216. * Returns zero if operation has successfully completed, a positive value if the
  1217. * operation has been successfully scheduled and a negative - if a requested
  1218. * operations has failed.
  1219. */
  1220. int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
  1221. struct bnx2x_vlan_mac_obj *obj, bool set,
  1222. int mac_type, unsigned long *ramrod_flags);
  1223. /**
  1224. * Deletes all MACs configured for the specific MAC object.
  1225. *
  1226. * @param bp Function driver instance
  1227. * @param mac_obj MAC object to cleanup
  1228. *
  1229. * @return zero if all MACs were cleaned
  1230. */
  1231. /**
  1232. * bnx2x_del_all_macs - delete all MACs configured for the specific MAC object
  1233. *
  1234. * @bp: driver handle
  1235. * @mac_obj: MAC object handle
  1236. * @mac_type: type of the MACs to clear (BNX2X_XXX_MAC)
  1237. * @wait_for_comp: if 'true' block until completion
  1238. *
  1239. * Deletes all MACs of the specific type (e.g. ETH, UC list).
  1240. *
  1241. * Returns zero if operation has successfully completed, a positive value if the
  1242. * operation has been successfully scheduled and a negative - if a requested
  1243. * operations has failed.
  1244. */
  1245. int bnx2x_del_all_macs(struct bnx2x *bp,
  1246. struct bnx2x_vlan_mac_obj *mac_obj,
  1247. int mac_type, bool wait_for_comp);
  1248. /* Init Function API */
  1249. void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p);
  1250. int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
  1251. int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
  1252. int bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode);
  1253. int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
  1254. void bnx2x_read_mf_cfg(struct bnx2x *bp);
  1255. /* dmae */
  1256. void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
  1257. void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
  1258. u32 len32);
  1259. void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
  1260. u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
  1261. u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
  1262. u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
  1263. bool with_comp, u8 comp_type);
  1264. void bnx2x_calc_fc_adv(struct bnx2x *bp);
  1265. int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
  1266. u32 data_hi, u32 data_lo, int cmd_type);
  1267. void bnx2x_update_coalesce(struct bnx2x *bp);
  1268. int bnx2x_get_cur_phy_idx(struct bnx2x *bp);
  1269. static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
  1270. int wait)
  1271. {
  1272. u32 val;
  1273. do {
  1274. val = REG_RD(bp, reg);
  1275. if (val == expected)
  1276. break;
  1277. ms -= wait;
  1278. msleep(wait);
  1279. } while (ms > 0);
  1280. return val;
  1281. }
  1282. #define BNX2X_ILT_ZALLOC(x, y, size) \
  1283. do { \
  1284. x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
  1285. if (x) \
  1286. memset(x, 0, size); \
  1287. } while (0)
  1288. #define BNX2X_ILT_FREE(x, y, size) \
  1289. do { \
  1290. if (x) { \
  1291. dma_free_coherent(&bp->pdev->dev, size, x, y); \
  1292. x = NULL; \
  1293. y = 0; \
  1294. } \
  1295. } while (0)
  1296. #define ILOG2(x) (ilog2((x)))
  1297. #define ILT_NUM_PAGE_ENTRIES (3072)
  1298. /* In 57710/11 we use whole table since we have 8 func
  1299. * In 57712 we have only 4 func, but use same size per func, then only half of
  1300. * the table in use
  1301. */
  1302. #define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8)
  1303. #define FUNC_ILT_BASE(func) (func * ILT_PER_FUNC)
  1304. /*
  1305. * the phys address is shifted right 12 bits and has an added
  1306. * 1=valid bit added to the 53rd bit
  1307. * then since this is a wide register(TM)
  1308. * we split it into two 32 bit writes
  1309. */
  1310. #define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
  1311. #define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
  1312. /* load/unload mode */
  1313. #define LOAD_NORMAL 0
  1314. #define LOAD_OPEN 1
  1315. #define LOAD_DIAG 2
  1316. #define UNLOAD_NORMAL 0
  1317. #define UNLOAD_CLOSE 1
  1318. #define UNLOAD_RECOVERY 2
  1319. /* DMAE command defines */
  1320. #define DMAE_TIMEOUT -1
  1321. #define DMAE_PCI_ERROR -2 /* E2 and onward */
  1322. #define DMAE_NOT_RDY -3
  1323. #define DMAE_PCI_ERR_FLAG 0x80000000
  1324. #define DMAE_SRC_PCI 0
  1325. #define DMAE_SRC_GRC 1
  1326. #define DMAE_DST_NONE 0
  1327. #define DMAE_DST_PCI 1
  1328. #define DMAE_DST_GRC 2
  1329. #define DMAE_COMP_PCI 0
  1330. #define DMAE_COMP_GRC 1
  1331. /* E2 and onward - PCI error handling in the completion */
  1332. #define DMAE_COMP_REGULAR 0
  1333. #define DMAE_COM_SET_ERR 1
  1334. #define DMAE_CMD_SRC_PCI (DMAE_SRC_PCI << \
  1335. DMAE_COMMAND_SRC_SHIFT)
  1336. #define DMAE_CMD_SRC_GRC (DMAE_SRC_GRC << \
  1337. DMAE_COMMAND_SRC_SHIFT)
  1338. #define DMAE_CMD_DST_PCI (DMAE_DST_PCI << \
  1339. DMAE_COMMAND_DST_SHIFT)
  1340. #define DMAE_CMD_DST_GRC (DMAE_DST_GRC << \
  1341. DMAE_COMMAND_DST_SHIFT)
  1342. #define DMAE_CMD_C_DST_PCI (DMAE_COMP_PCI << \
  1343. DMAE_COMMAND_C_DST_SHIFT)
  1344. #define DMAE_CMD_C_DST_GRC (DMAE_COMP_GRC << \
  1345. DMAE_COMMAND_C_DST_SHIFT)
  1346. #define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE
  1347. #define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1348. #define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1349. #define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1350. #define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1351. #define DMAE_CMD_PORT_0 0
  1352. #define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT
  1353. #define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET
  1354. #define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET
  1355. #define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT
  1356. #define DMAE_SRC_PF 0
  1357. #define DMAE_SRC_VF 1
  1358. #define DMAE_DST_PF 0
  1359. #define DMAE_DST_VF 1
  1360. #define DMAE_C_SRC 0
  1361. #define DMAE_C_DST 1
  1362. #define DMAE_LEN32_RD_MAX 0x80
  1363. #define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000)
  1364. #define DMAE_COMP_VAL 0x60d0d0ae /* E2 and on - upper bit
  1365. indicates eror */
  1366. #define MAX_DMAE_C_PER_PORT 8
  1367. #define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
  1368. BP_E1HVN(bp))
  1369. #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
  1370. E1HVN_MAX)
  1371. /* PCIE link and speed */
  1372. #define PCICFG_LINK_WIDTH 0x1f00000
  1373. #define PCICFG_LINK_WIDTH_SHIFT 20
  1374. #define PCICFG_LINK_SPEED 0xf0000
  1375. #define PCICFG_LINK_SPEED_SHIFT 16
  1376. #define BNX2X_NUM_TESTS 7
  1377. #define BNX2X_PHY_LOOPBACK 0
  1378. #define BNX2X_MAC_LOOPBACK 1
  1379. #define BNX2X_PHY_LOOPBACK_FAILED 1
  1380. #define BNX2X_MAC_LOOPBACK_FAILED 2
  1381. #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \
  1382. BNX2X_PHY_LOOPBACK_FAILED)
  1383. #define STROM_ASSERT_ARRAY_SIZE 50
  1384. /* must be used on a CID before placing it on a HW ring */
  1385. #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \
  1386. (BP_E1HVN(bp) << BNX2X_SWCID_SHIFT) | \
  1387. (x))
  1388. #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe))
  1389. #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1)
  1390. #define BNX2X_BTR 4
  1391. #define MAX_SPQ_PENDING 8
  1392. /* CMNG constants, as derived from system spec calculations */
  1393. /* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */
  1394. #define DEF_MIN_RATE 100
  1395. /* resolution of the rate shaping timer - 400 usec */
  1396. #define RS_PERIODIC_TIMEOUT_USEC 400
  1397. /* number of bytes in single QM arbitration cycle -
  1398. * coefficient for calculating the fairness timer */
  1399. #define QM_ARB_BYTES 160000
  1400. /* resolution of Min algorithm 1:100 */
  1401. #define MIN_RES 100
  1402. /* how many bytes above threshold for the minimal credit of Min algorithm*/
  1403. #define MIN_ABOVE_THRESH 32768
  1404. /* Fairness algorithm integration time coefficient -
  1405. * for calculating the actual Tfair */
  1406. #define T_FAIR_COEF ((MIN_ABOVE_THRESH + QM_ARB_BYTES) * 8 * MIN_RES)
  1407. /* Memory of fairness algorithm . 2 cycles */
  1408. #define FAIR_MEM 2
  1409. #define ATTN_NIG_FOR_FUNC (1L << 8)
  1410. #define ATTN_SW_TIMER_4_FUNC (1L << 9)
  1411. #define GPIO_2_FUNC (1L << 10)
  1412. #define GPIO_3_FUNC (1L << 11)
  1413. #define GPIO_4_FUNC (1L << 12)
  1414. #define ATTN_GENERAL_ATTN_1 (1L << 13)
  1415. #define ATTN_GENERAL_ATTN_2 (1L << 14)
  1416. #define ATTN_GENERAL_ATTN_3 (1L << 15)
  1417. #define ATTN_GENERAL_ATTN_4 (1L << 13)
  1418. #define ATTN_GENERAL_ATTN_5 (1L << 14)
  1419. #define ATTN_GENERAL_ATTN_6 (1L << 15)
  1420. #define ATTN_HARD_WIRED_MASK 0xff00
  1421. #define ATTENTION_ID 4
  1422. /* stuff added to make the code fit 80Col */
  1423. #define BNX2X_PMF_LINK_ASSERT \
  1424. GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
  1425. #define BNX2X_MC_ASSERT_BITS \
  1426. (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1427. GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1428. GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1429. GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
  1430. #define BNX2X_MCP_ASSERT \
  1431. GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
  1432. #define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
  1433. #define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
  1434. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
  1435. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
  1436. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
  1437. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
  1438. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
  1439. #define HW_INTERRUT_ASSERT_SET_0 \
  1440. (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
  1441. AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
  1442. AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
  1443. AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT)
  1444. #define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
  1445. AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
  1446. AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
  1447. AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
  1448. AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\
  1449. AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\
  1450. AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR)
  1451. #define HW_INTERRUT_ASSERT_SET_1 \
  1452. (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
  1453. AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
  1454. AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
  1455. AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
  1456. AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
  1457. AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
  1458. AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
  1459. AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
  1460. AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
  1461. AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
  1462. AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
  1463. #define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\
  1464. AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
  1465. AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\
  1466. AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
  1467. AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\
  1468. AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
  1469. AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
  1470. AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\
  1471. AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
  1472. AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
  1473. AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
  1474. AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\
  1475. AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
  1476. AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
  1477. AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\
  1478. AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR)
  1479. #define HW_INTERRUT_ASSERT_SET_2 \
  1480. (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
  1481. AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
  1482. AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
  1483. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
  1484. AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
  1485. #define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
  1486. AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
  1487. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
  1488. AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
  1489. AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
  1490. AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\
  1491. AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
  1492. AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
  1493. #define HW_PRTY_ASSERT_SET_3 (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
  1494. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
  1495. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \
  1496. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
  1497. #define RSS_FLAGS(bp) \
  1498. (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \
  1499. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \
  1500. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \
  1501. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \
  1502. (bp->multi_mode << \
  1503. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT))
  1504. #define MULTI_MASK 0x7f
  1505. #define DEF_USB_FUNC_OFF offsetof(struct cstorm_def_status_block_u, func)
  1506. #define DEF_CSB_FUNC_OFF offsetof(struct cstorm_def_status_block_c, func)
  1507. #define DEF_XSB_FUNC_OFF offsetof(struct xstorm_def_status_block, func)
  1508. #define DEF_TSB_FUNC_OFF offsetof(struct tstorm_def_status_block, func)
  1509. #define DEF_USB_IGU_INDEX_OFF \
  1510. offsetof(struct cstorm_def_status_block_u, igu_index)
  1511. #define DEF_CSB_IGU_INDEX_OFF \
  1512. offsetof(struct cstorm_def_status_block_c, igu_index)
  1513. #define DEF_XSB_IGU_INDEX_OFF \
  1514. offsetof(struct xstorm_def_status_block, igu_index)
  1515. #define DEF_TSB_IGU_INDEX_OFF \
  1516. offsetof(struct tstorm_def_status_block, igu_index)
  1517. #define DEF_USB_SEGMENT_OFF \
  1518. offsetof(struct cstorm_def_status_block_u, segment)
  1519. #define DEF_CSB_SEGMENT_OFF \
  1520. offsetof(struct cstorm_def_status_block_c, segment)
  1521. #define DEF_XSB_SEGMENT_OFF \
  1522. offsetof(struct xstorm_def_status_block, segment)
  1523. #define DEF_TSB_SEGMENT_OFF \
  1524. offsetof(struct tstorm_def_status_block, segment)
  1525. #define BNX2X_SP_DSB_INDEX \
  1526. (&bp->def_status_blk->sp_sb.\
  1527. index_values[HC_SP_INDEX_ETH_DEF_CONS])
  1528. #define SET_FLAG(value, mask, flag) \
  1529. do {\
  1530. (value) &= ~(mask);\
  1531. (value) |= ((flag) << (mask##_SHIFT));\
  1532. } while (0)
  1533. #define GET_FLAG(value, mask) \
  1534. (((value) & (mask)) >> (mask##_SHIFT))
  1535. #define GET_FIELD(value, fname) \
  1536. (((value) & (fname##_MASK)) >> (fname##_SHIFT))
  1537. #define CAM_IS_INVALID(x) \
  1538. (GET_FLAG(x.flags, \
  1539. MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
  1540. (T_ETH_MAC_COMMAND_INVALIDATE))
  1541. /* Number of u32 elements in MC hash array */
  1542. #define MC_HASH_SIZE 8
  1543. #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \
  1544. TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
  1545. #ifndef PXP2_REG_PXP2_INT_STS
  1546. #define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0
  1547. #endif
  1548. #ifndef ETH_MAX_RX_CLIENTS_E2
  1549. #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
  1550. #endif
  1551. #define BNX2X_VPD_LEN 128
  1552. #define VENDOR_ID_LEN 4
  1553. /* Congestion management fairness mode */
  1554. #define CMNG_FNS_NONE 0
  1555. #define CMNG_FNS_MINMAX 1
  1556. #define HC_SEG_ACCESS_DEF 0 /*Driver decision 0-3*/
  1557. #define HC_SEG_ACCESS_ATTN 4
  1558. #define HC_SEG_ACCESS_NORM 0 /*Driver decision 0-1*/
  1559. static const u32 dmae_reg_go_c[] = {
  1560. DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
  1561. DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
  1562. DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
  1563. DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
  1564. };
  1565. void bnx2x_set_ethtool_ops(struct net_device *netdev);
  1566. void bnx2x_notify_link_changed(struct bnx2x *bp);
  1567. #endif /* bnx2x.h */