bnx2x.h 61 KB

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