bnx2x.h 59 KB

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