bnx2x.h 51 KB

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