bnx2x.h 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521
  1. /* bnx2x.h: QLogic Everest network driver.
  2. *
  3. * Copyright (c) 2007-2013 Broadcom Corporation
  4. * Copyright (c) 2014 QLogic Corporation
  5. * All rights reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation.
  10. *
  11. * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
  12. * Written by: Eliezer Tamir
  13. * Based on code from Michael Chan's bnx2 driver
  14. */
  15. #ifndef BNX2X_H
  16. #define BNX2X_H
  17. #include <linux/pci.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/dma-mapping.h>
  20. #include <linux/types.h>
  21. #include <linux/pci_regs.h>
  22. #include <linux/ptp_clock_kernel.h>
  23. #include <linux/net_tstamp.h>
  24. #include <linux/timecounter.h>
  25. /* compilation time flags */
  26. /* define this to make the driver freeze on error to allow getting debug info
  27. * (you will need to reboot afterwards) */
  28. /* #define BNX2X_STOP_ON_ERROR */
  29. #define DRV_MODULE_VERSION "1.712.30-0"
  30. #define DRV_MODULE_RELDATE "2014/02/10"
  31. #define BNX2X_BC_VER 0x040200
  32. #if defined(CONFIG_DCB)
  33. #define BCM_DCBNL
  34. #endif
  35. #include "bnx2x_hsi.h"
  36. #include "../cnic_if.h"
  37. #define BNX2X_MIN_MSIX_VEC_CNT(bp) ((bp)->min_msix_vec_cnt)
  38. #include <linux/mdio.h>
  39. #include "bnx2x_reg.h"
  40. #include "bnx2x_fw_defs.h"
  41. #include "bnx2x_mfw_req.h"
  42. #include "bnx2x_link.h"
  43. #include "bnx2x_sp.h"
  44. #include "bnx2x_dcb.h"
  45. #include "bnx2x_stats.h"
  46. #include "bnx2x_vfpf.h"
  47. enum bnx2x_int_mode {
  48. BNX2X_INT_MODE_MSIX,
  49. BNX2X_INT_MODE_INTX,
  50. BNX2X_INT_MODE_MSI
  51. };
  52. /* error/debug prints */
  53. #define DRV_MODULE_NAME "bnx2x"
  54. /* for messages that are currently off */
  55. #define BNX2X_MSG_OFF 0x0
  56. #define BNX2X_MSG_MCP 0x0010000 /* was: NETIF_MSG_HW */
  57. #define BNX2X_MSG_STATS 0x0020000 /* was: NETIF_MSG_TIMER */
  58. #define BNX2X_MSG_NVM 0x0040000 /* was: NETIF_MSG_HW */
  59. #define BNX2X_MSG_DMAE 0x0080000 /* was: NETIF_MSG_HW */
  60. #define BNX2X_MSG_SP 0x0100000 /* was: NETIF_MSG_INTR */
  61. #define BNX2X_MSG_FP 0x0200000 /* was: NETIF_MSG_INTR */
  62. #define BNX2X_MSG_IOV 0x0800000
  63. #define BNX2X_MSG_PTP 0x1000000
  64. #define BNX2X_MSG_IDLE 0x2000000 /* used for idle check*/
  65. #define BNX2X_MSG_ETHTOOL 0x4000000
  66. #define BNX2X_MSG_DCB 0x8000000
  67. /* regular debug print */
  68. #define DP_INNER(fmt, ...) \
  69. pr_notice("[%s:%d(%s)]" fmt, \
  70. __func__, __LINE__, \
  71. bp->dev ? (bp->dev->name) : "?", \
  72. ##__VA_ARGS__);
  73. #define DP(__mask, fmt, ...) \
  74. do { \
  75. if (unlikely(bp->msg_enable & (__mask))) \
  76. DP_INNER(fmt, ##__VA_ARGS__); \
  77. } while (0)
  78. #define DP_AND(__mask, fmt, ...) \
  79. do { \
  80. if (unlikely((bp->msg_enable & (__mask)) == __mask)) \
  81. DP_INNER(fmt, ##__VA_ARGS__); \
  82. } while (0)
  83. #define DP_CONT(__mask, fmt, ...) \
  84. do { \
  85. if (unlikely(bp->msg_enable & (__mask))) \
  86. pr_cont(fmt, ##__VA_ARGS__); \
  87. } while (0)
  88. /* errors debug print */
  89. #define BNX2X_DBG_ERR(fmt, ...) \
  90. do { \
  91. if (unlikely(netif_msg_probe(bp))) \
  92. pr_err("[%s:%d(%s)]" fmt, \
  93. __func__, __LINE__, \
  94. bp->dev ? (bp->dev->name) : "?", \
  95. ##__VA_ARGS__); \
  96. } while (0)
  97. /* for errors (never masked) */
  98. #define BNX2X_ERR(fmt, ...) \
  99. do { \
  100. pr_err("[%s:%d(%s)]" fmt, \
  101. __func__, __LINE__, \
  102. bp->dev ? (bp->dev->name) : "?", \
  103. ##__VA_ARGS__); \
  104. } while (0)
  105. #define BNX2X_ERROR(fmt, ...) \
  106. pr_err("[%s:%d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
  107. /* before we have a dev->name use dev_info() */
  108. #define BNX2X_DEV_INFO(fmt, ...) \
  109. do { \
  110. if (unlikely(netif_msg_probe(bp))) \
  111. dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__); \
  112. } while (0)
  113. /* Error handling */
  114. void bnx2x_panic_dump(struct bnx2x *bp, bool disable_int);
  115. #ifdef BNX2X_STOP_ON_ERROR
  116. #define bnx2x_panic() \
  117. do { \
  118. bp->panic = 1; \
  119. BNX2X_ERR("driver assert\n"); \
  120. bnx2x_panic_dump(bp, true); \
  121. } while (0)
  122. #else
  123. #define bnx2x_panic() \
  124. do { \
  125. bp->panic = 1; \
  126. BNX2X_ERR("driver assert\n"); \
  127. bnx2x_panic_dump(bp, false); \
  128. } while (0)
  129. #endif
  130. #define bnx2x_mc_addr(ha) ((ha)->addr)
  131. #define bnx2x_uc_addr(ha) ((ha)->addr)
  132. #define U64_LO(x) ((u32)(((u64)(x)) & 0xffffffff))
  133. #define U64_HI(x) ((u32)(((u64)(x)) >> 32))
  134. #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
  135. #define REG_ADDR(bp, offset) ((bp->regview) + (offset))
  136. #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
  137. #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
  138. #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset))
  139. #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset))
  140. #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset))
  141. #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset))
  142. #define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset)
  143. #define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val)
  144. #define REG_RD_DMAE(bp, offset, valp, len32) \
  145. do { \
  146. bnx2x_read_dmae(bp, offset, len32);\
  147. memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
  148. } while (0)
  149. #define REG_WR_DMAE(bp, offset, valp, len32) \
  150. do { \
  151. memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
  152. bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
  153. offset, len32); \
  154. } while (0)
  155. #define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
  156. REG_WR_DMAE(bp, offset, valp, len32)
  157. #define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
  158. do { \
  159. memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
  160. bnx2x_write_big_buf_wb(bp, addr, len32); \
  161. } while (0)
  162. #define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \
  163. offsetof(struct shmem_region, field))
  164. #define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field))
  165. #define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val)
  166. #define SHMEM2_ADDR(bp, field) (bp->common.shmem2_base + \
  167. offsetof(struct shmem2_region, field))
  168. #define SHMEM2_RD(bp, field) REG_RD(bp, SHMEM2_ADDR(bp, field))
  169. #define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val)
  170. #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \
  171. offsetof(struct mf_cfg, field))
  172. #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \
  173. offsetof(struct mf2_cfg, field))
  174. #define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field))
  175. #define MF_CFG_WR(bp, field, val) REG_WR(bp,\
  176. MF_CFG_ADDR(bp, field), (val))
  177. #define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field))
  178. #define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \
  179. (SHMEM2_RD((bp), size) > \
  180. offsetof(struct shmem2_region, field)))
  181. #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg)
  182. #define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val)
  183. /* SP SB indices */
  184. /* General SP events - stats query, cfc delete, etc */
  185. #define HC_SP_INDEX_ETH_DEF_CONS 3
  186. /* EQ completions */
  187. #define HC_SP_INDEX_EQ_CONS 7
  188. /* FCoE L2 connection completions */
  189. #define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS 6
  190. #define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS 4
  191. /* iSCSI L2 */
  192. #define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5
  193. #define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1
  194. /* Special clients parameters */
  195. /* SB indices */
  196. /* FCoE L2 */
  197. #define BNX2X_FCOE_L2_RX_INDEX \
  198. (&bp->def_status_blk->sp_sb.\
  199. index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS])
  200. #define BNX2X_FCOE_L2_TX_INDEX \
  201. (&bp->def_status_blk->sp_sb.\
  202. index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS])
  203. /**
  204. * CIDs and CLIDs:
  205. * CLIDs below is a CLID for func 0, then the CLID for other
  206. * functions will be calculated by the formula:
  207. *
  208. * FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X
  209. *
  210. */
  211. enum {
  212. BNX2X_ISCSI_ETH_CL_ID_IDX,
  213. BNX2X_FCOE_ETH_CL_ID_IDX,
  214. BNX2X_MAX_CNIC_ETH_CL_ID_IDX,
  215. };
  216. /* use a value high enough to be above all the PFs, which has least significant
  217. * nibble as 8, so when cnic needs to come up with a CID for UIO to use to
  218. * calculate doorbell address according to old doorbell configuration scheme
  219. * (db_msg_sz 1 << 7 * cid + 0x40 DPM offset) it can come up with a valid number
  220. * We must avoid coming up with cid 8 for iscsi since according to this method
  221. * the designated UIO cid will come out 0 and it has a special handling for that
  222. * case which doesn't suit us. Therefore will will cieling to closes cid which
  223. * has least signigifcant nibble 8 and if it is 8 we will move forward to 0x18.
  224. */
  225. #define BNX2X_1st_NON_L2_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * \
  226. (bp)->max_cos)
  227. /* amount of cids traversed by UIO's DPM addition to doorbell */
  228. #define UIO_DPM 8
  229. /* roundup to DPM offset */
  230. #define UIO_ROUNDUP(bp) (roundup(BNX2X_1st_NON_L2_ETH_CID(bp), \
  231. UIO_DPM))
  232. /* offset to nearest value which has lsb nibble matching DPM */
  233. #define UIO_CID_OFFSET(bp) ((UIO_ROUNDUP(bp) + UIO_DPM) % \
  234. (UIO_DPM * 2))
  235. /* add offset to rounded-up cid to get a value which could be used with UIO */
  236. #define UIO_DPM_ALIGN(bp) (UIO_ROUNDUP(bp) + UIO_CID_OFFSET(bp))
  237. /* but wait - avoid UIO special case for cid 0 */
  238. #define UIO_DPM_CID0_OFFSET(bp) ((UIO_DPM * 2) * \
  239. (UIO_DPM_ALIGN(bp) == UIO_DPM))
  240. /* Properly DPM aligned CID dajusted to cid 0 secal case */
  241. #define BNX2X_CNIC_START_ETH_CID(bp) (UIO_DPM_ALIGN(bp) + \
  242. (UIO_DPM_CID0_OFFSET(bp)))
  243. /* how many cids were wasted - need this value for cid allocation */
  244. #define UIO_CID_PAD(bp) (BNX2X_CNIC_START_ETH_CID(bp) - \
  245. BNX2X_1st_NON_L2_ETH_CID(bp))
  246. /* iSCSI L2 */
  247. #define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp))
  248. /* FCoE L2 */
  249. #define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1)
  250. #define CNIC_SUPPORT(bp) ((bp)->cnic_support)
  251. #define CNIC_ENABLED(bp) ((bp)->cnic_enabled)
  252. #define CNIC_LOADED(bp) ((bp)->cnic_loaded)
  253. #define FCOE_INIT(bp) ((bp)->fcoe_init)
  254. #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
  255. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
  256. #define SM_RX_ID 0
  257. #define SM_TX_ID 1
  258. /* defines for multiple tx priority indices */
  259. #define FIRST_TX_ONLY_COS_INDEX 1
  260. #define FIRST_TX_COS_INDEX 0
  261. /* rules for calculating the cids of tx-only connections */
  262. #define CID_TO_FP(cid, bp) ((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp))
  263. #define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \
  264. (cid + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
  265. /* fp index inside class of service range */
  266. #define FP_COS_TO_TXQ(fp, cos, bp) \
  267. ((fp)->index + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
  268. /* Indexes for transmission queues array:
  269. * txdata for RSS i CoS j is at location i + (j * num of RSS)
  270. * txdata for FCoE (if exist) is at location max cos * num of RSS
  271. * txdata for FWD (if exist) is one location after FCoE
  272. * txdata for OOO (if exist) is one location after FWD
  273. */
  274. enum {
  275. FCOE_TXQ_IDX_OFFSET,
  276. FWD_TXQ_IDX_OFFSET,
  277. OOO_TXQ_IDX_OFFSET,
  278. };
  279. #define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
  280. #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
  281. /* fast path */
  282. /*
  283. * This driver uses new build_skb() API :
  284. * RX ring buffer contains pointer to kmalloc() data only,
  285. * skb are built only after Hardware filled the frame.
  286. */
  287. struct sw_rx_bd {
  288. u8 *data;
  289. DEFINE_DMA_UNMAP_ADDR(mapping);
  290. };
  291. struct sw_tx_bd {
  292. struct sk_buff *skb;
  293. u16 first_bd;
  294. u8 flags;
  295. /* Set on the first BD descriptor when there is a split BD */
  296. #define BNX2X_TSO_SPLIT_BD (1<<0)
  297. #define BNX2X_HAS_SECOND_PBD (1<<1)
  298. };
  299. struct sw_rx_page {
  300. struct page *page;
  301. DEFINE_DMA_UNMAP_ADDR(mapping);
  302. unsigned int offset;
  303. };
  304. union db_prod {
  305. struct doorbell_set_prod data;
  306. u32 raw;
  307. };
  308. /* dropless fc FW/HW related params */
  309. #define BRB_SIZE(bp) (CHIP_IS_E3(bp) ? 1024 : 512)
  310. #define MAX_AGG_QS(bp) (CHIP_IS_E1(bp) ? \
  311. ETH_MAX_AGGREGATION_QUEUES_E1 :\
  312. ETH_MAX_AGGREGATION_QUEUES_E1H_E2)
  313. #define FW_DROP_LEVEL(bp) (3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp))
  314. #define FW_PREFETCH_CNT 16
  315. #define DROPLESS_FC_HEADROOM 100
  316. /* MC hsi */
  317. #define BCM_PAGE_SHIFT 12
  318. #define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT)
  319. #define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1))
  320. #define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
  321. #define PAGES_PER_SGE_SHIFT 0
  322. #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
  323. #define SGE_PAGE_SHIFT 12
  324. #define SGE_PAGE_SIZE (1 << SGE_PAGE_SHIFT)
  325. #define SGE_PAGE_MASK (~(SGE_PAGE_SIZE - 1))
  326. #define SGE_PAGE_ALIGN(addr) (((addr) + SGE_PAGE_SIZE - 1) & SGE_PAGE_MASK)
  327. #define SGE_PAGES (SGE_PAGE_SIZE * PAGES_PER_SGE)
  328. #define TPA_AGG_SIZE min_t(u32, (min_t(u32, 8, MAX_SKB_FRAGS) * \
  329. SGE_PAGES), 0xffff)
  330. /* SGE ring related macros */
  331. #define NUM_RX_SGE_PAGES 2
  332. #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
  333. #define NEXT_PAGE_SGE_DESC_CNT 2
  334. #define MAX_RX_SGE_CNT (RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT)
  335. /* RX_SGE_CNT is promised to be a power of 2 */
  336. #define RX_SGE_MASK (RX_SGE_CNT - 1)
  337. #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES)
  338. #define MAX_RX_SGE (NUM_RX_SGE - 1)
  339. #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \
  340. (MAX_RX_SGE_CNT - 1)) ? \
  341. (x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \
  342. (x) + 1)
  343. #define RX_SGE(x) ((x) & MAX_RX_SGE)
  344. /*
  345. * Number of required SGEs is the sum of two:
  346. * 1. Number of possible opened aggregations (next packet for
  347. * these aggregations will probably consume SGE immediately)
  348. * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only
  349. * after placement on BD for new TPA aggregation)
  350. *
  351. * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page
  352. */
  353. #define NUM_SGE_REQ (MAX_AGG_QS(bp) + \
  354. (BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2)
  355. #define NUM_SGE_PG_REQ ((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \
  356. MAX_RX_SGE_CNT)
  357. #define SGE_TH_LO(bp) (NUM_SGE_REQ + \
  358. NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT)
  359. #define SGE_TH_HI(bp) (SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM)
  360. /* Manipulate a bit vector defined as an array of u64 */
  361. /* Number of bits in one sge_mask array element */
  362. #define BIT_VEC64_ELEM_SZ 64
  363. #define BIT_VEC64_ELEM_SHIFT 6
  364. #define BIT_VEC64_ELEM_MASK ((u64)BIT_VEC64_ELEM_SZ - 1)
  365. #define __BIT_VEC64_SET_BIT(el, bit) \
  366. do { \
  367. el = ((el) | ((u64)0x1 << (bit))); \
  368. } while (0)
  369. #define __BIT_VEC64_CLEAR_BIT(el, bit) \
  370. do { \
  371. el = ((el) & (~((u64)0x1 << (bit)))); \
  372. } while (0)
  373. #define BIT_VEC64_SET_BIT(vec64, idx) \
  374. __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
  375. (idx) & BIT_VEC64_ELEM_MASK)
  376. #define BIT_VEC64_CLEAR_BIT(vec64, idx) \
  377. __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
  378. (idx) & BIT_VEC64_ELEM_MASK)
  379. #define BIT_VEC64_TEST_BIT(vec64, idx) \
  380. (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
  381. ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
  382. /* Creates a bitmask of all ones in less significant bits.
  383. idx - index of the most significant bit in the created mask */
  384. #define BIT_VEC64_ONES_MASK(idx) \
  385. (((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
  386. #define BIT_VEC64_ELEM_ONE_MASK ((u64)(~0))
  387. /*******************************************************/
  388. /* Number of u64 elements in SGE mask array */
  389. #define RX_SGE_MASK_LEN (NUM_RX_SGE / BIT_VEC64_ELEM_SZ)
  390. #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1)
  391. #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK)
  392. union host_hc_status_block {
  393. /* pointer to fp status block e1x */
  394. struct host_hc_status_block_e1x *e1x_sb;
  395. /* pointer to fp status block e2 */
  396. struct host_hc_status_block_e2 *e2_sb;
  397. };
  398. struct bnx2x_agg_info {
  399. /*
  400. * First aggregation buffer is a data buffer, the following - are pages.
  401. * We will preallocate the data buffer for each aggregation when
  402. * we open the interface and will replace the BD at the consumer
  403. * with this one when we receive the TPA_START CQE in order to
  404. * keep the Rx BD ring consistent.
  405. */
  406. struct sw_rx_bd first_buf;
  407. u8 tpa_state;
  408. #define BNX2X_TPA_START 1
  409. #define BNX2X_TPA_STOP 2
  410. #define BNX2X_TPA_ERROR 3
  411. u8 placement_offset;
  412. u16 parsing_flags;
  413. u16 vlan_tag;
  414. u16 len_on_bd;
  415. u32 rxhash;
  416. enum pkt_hash_types rxhash_type;
  417. u16 gro_size;
  418. u16 full_page;
  419. };
  420. #define Q_STATS_OFFSET32(stat_name) \
  421. (offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
  422. struct bnx2x_fp_txdata {
  423. struct sw_tx_bd *tx_buf_ring;
  424. union eth_tx_bd_types *tx_desc_ring;
  425. dma_addr_t tx_desc_mapping;
  426. u32 cid;
  427. union db_prod tx_db;
  428. u16 tx_pkt_prod;
  429. u16 tx_pkt_cons;
  430. u16 tx_bd_prod;
  431. u16 tx_bd_cons;
  432. unsigned long tx_pkt;
  433. __le16 *tx_cons_sb;
  434. int txq_index;
  435. struct bnx2x_fastpath *parent_fp;
  436. int tx_ring_size;
  437. };
  438. enum bnx2x_tpa_mode_t {
  439. TPA_MODE_DISABLED,
  440. TPA_MODE_LRO,
  441. TPA_MODE_GRO
  442. };
  443. struct bnx2x_alloc_pool {
  444. struct page *page;
  445. unsigned int offset;
  446. };
  447. struct bnx2x_fastpath {
  448. struct bnx2x *bp; /* parent */
  449. struct napi_struct napi;
  450. union host_hc_status_block status_blk;
  451. /* chip independent shortcuts into sb structure */
  452. __le16 *sb_index_values;
  453. __le16 *sb_running_index;
  454. /* chip independent shortcut into rx_prods_offset memory */
  455. u32 ustorm_rx_prods_offset;
  456. u32 rx_buf_size;
  457. u32 rx_frag_size; /* 0 if kmalloced(), or rx_buf_size + NET_SKB_PAD */
  458. dma_addr_t status_blk_mapping;
  459. enum bnx2x_tpa_mode_t mode;
  460. u8 max_cos; /* actual number of active tx coses */
  461. struct bnx2x_fp_txdata *txdata_ptr[BNX2X_MULTI_TX_COS];
  462. struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */
  463. struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */
  464. struct eth_rx_bd *rx_desc_ring;
  465. dma_addr_t rx_desc_mapping;
  466. union eth_rx_cqe *rx_comp_ring;
  467. dma_addr_t rx_comp_mapping;
  468. /* SGE ring */
  469. struct eth_rx_sge *rx_sge_ring;
  470. dma_addr_t rx_sge_mapping;
  471. u64 sge_mask[RX_SGE_MASK_LEN];
  472. u32 cid;
  473. __le16 fp_hc_idx;
  474. u8 index; /* number in fp array */
  475. u8 rx_queue; /* index for skb_record */
  476. u8 cl_id; /* eth client id */
  477. u8 cl_qzone_id;
  478. u8 fw_sb_id; /* status block number in FW */
  479. u8 igu_sb_id; /* status block number in HW */
  480. u16 rx_bd_prod;
  481. u16 rx_bd_cons;
  482. u16 rx_comp_prod;
  483. u16 rx_comp_cons;
  484. u16 rx_sge_prod;
  485. /* The last maximal completed SGE */
  486. u16 last_max_sge;
  487. __le16 *rx_cons_sb;
  488. /* TPA related */
  489. struct bnx2x_agg_info *tpa_info;
  490. #ifdef BNX2X_STOP_ON_ERROR
  491. u64 tpa_queue_used;
  492. #endif
  493. /* The size is calculated using the following:
  494. sizeof name field from netdev structure +
  495. 4 ('-Xx-' string) +
  496. 4 (for the digits and to make it DWORD aligned) */
  497. #define FP_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
  498. char name[FP_NAME_SIZE];
  499. struct bnx2x_alloc_pool page_pool;
  500. };
  501. #define bnx2x_fp(bp, nr, var) ((bp)->fp[(nr)].var)
  502. #define bnx2x_sp_obj(bp, fp) ((bp)->sp_objs[(fp)->index])
  503. #define bnx2x_fp_stats(bp, fp) (&((bp)->fp_stats[(fp)->index]))
  504. #define bnx2x_fp_qstats(bp, fp) (&((bp)->fp_stats[(fp)->index].eth_q_stats))
  505. /* Use 2500 as a mini-jumbo MTU for FCoE */
  506. #define BNX2X_FCOE_MINI_JUMBO_MTU 2500
  507. #define FCOE_IDX_OFFSET 0
  508. #define FCOE_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) + \
  509. FCOE_IDX_OFFSET)
  510. #define bnx2x_fcoe_fp(bp) (&bp->fp[FCOE_IDX(bp)])
  511. #define bnx2x_fcoe(bp, var) (bnx2x_fcoe_fp(bp)->var)
  512. #define bnx2x_fcoe_inner_sp_obj(bp) (&bp->sp_objs[FCOE_IDX(bp)])
  513. #define bnx2x_fcoe_sp_obj(bp, var) (bnx2x_fcoe_inner_sp_obj(bp)->var)
  514. #define bnx2x_fcoe_tx(bp, var) (bnx2x_fcoe_fp(bp)-> \
  515. txdata_ptr[FIRST_TX_COS_INDEX] \
  516. ->var)
  517. #define IS_ETH_FP(fp) ((fp)->index < BNX2X_NUM_ETH_QUEUES((fp)->bp))
  518. #define IS_FCOE_FP(fp) ((fp)->index == FCOE_IDX((fp)->bp))
  519. #define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX(bp))
  520. /* MC hsi */
  521. #define MAX_FETCH_BD 13 /* HW max BDs per packet */
  522. #define RX_COPY_THRESH 92
  523. #define NUM_TX_RINGS 16
  524. #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
  525. #define NEXT_PAGE_TX_DESC_CNT 1
  526. #define MAX_TX_DESC_CNT (TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT)
  527. #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS)
  528. #define MAX_TX_BD (NUM_TX_BD - 1)
  529. #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
  530. #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \
  531. (MAX_TX_DESC_CNT - 1)) ? \
  532. (x) + 1 + NEXT_PAGE_TX_DESC_CNT : \
  533. (x) + 1)
  534. #define TX_BD(x) ((x) & MAX_TX_BD)
  535. #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT)
  536. /* number of NEXT_PAGE descriptors may be required during placement */
  537. #define NEXT_CNT_PER_TX_PKT(bds) \
  538. (((bds) + MAX_TX_DESC_CNT - 1) / \
  539. MAX_TX_DESC_CNT * NEXT_PAGE_TX_DESC_CNT)
  540. /* max BDs per tx packet w/o next_pages:
  541. * START_BD - describes packed
  542. * START_BD(splitted) - includes unpaged data segment for GSO
  543. * PARSING_BD - for TSO and CSUM data
  544. * PARSING_BD2 - for encapsulation data
  545. * Frag BDs - describes pages for frags
  546. */
  547. #define BDS_PER_TX_PKT 4
  548. #define MAX_BDS_PER_TX_PKT (MAX_SKB_FRAGS + BDS_PER_TX_PKT)
  549. /* max BDs per tx packet including next pages */
  550. #define MAX_DESC_PER_TX_PKT (MAX_BDS_PER_TX_PKT + \
  551. NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))
  552. /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
  553. #define NUM_RX_RINGS 8
  554. #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
  555. #define NEXT_PAGE_RX_DESC_CNT 2
  556. #define MAX_RX_DESC_CNT (RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT)
  557. #define RX_DESC_MASK (RX_DESC_CNT - 1)
  558. #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS)
  559. #define MAX_RX_BD (NUM_RX_BD - 1)
  560. #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
  561. /* dropless fc calculations for BDs
  562. *
  563. * Number of BDs should as number of buffers in BRB:
  564. * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT
  565. * "next" elements on each page
  566. */
  567. #define NUM_BD_REQ BRB_SIZE(bp)
  568. #define NUM_BD_PG_REQ ((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \
  569. MAX_RX_DESC_CNT)
  570. #define BD_TH_LO(bp) (NUM_BD_REQ + \
  571. NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \
  572. FW_DROP_LEVEL(bp))
  573. #define BD_TH_HI(bp) (BD_TH_LO(bp) + DROPLESS_FC_HEADROOM)
  574. #define MIN_RX_AVAIL ((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128)
  575. #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \
  576. ETH_MIN_RX_CQES_WITH_TPA_E1 : \
  577. ETH_MIN_RX_CQES_WITH_TPA_E1H_E2)
  578. #define MIN_RX_SIZE_NONTPA_HW ETH_MIN_RX_CQES_WITHOUT_TPA
  579. #define MIN_RX_SIZE_TPA (max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL))
  580. #define MIN_RX_SIZE_NONTPA (max_t(u32, MIN_RX_SIZE_NONTPA_HW,\
  581. MIN_RX_AVAIL))
  582. #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \
  583. (MAX_RX_DESC_CNT - 1)) ? \
  584. (x) + 1 + NEXT_PAGE_RX_DESC_CNT : \
  585. (x) + 1)
  586. #define RX_BD(x) ((x) & MAX_RX_BD)
  587. /*
  588. * As long as CQE is X times bigger than BD entry we have to allocate X times
  589. * more pages for CQ ring in order to keep it balanced with BD ring
  590. */
  591. #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
  592. #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL)
  593. #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
  594. #define NEXT_PAGE_RCQ_DESC_CNT 1
  595. #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT)
  596. #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS)
  597. #define MAX_RCQ_BD (NUM_RCQ_BD - 1)
  598. #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
  599. #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \
  600. (MAX_RCQ_DESC_CNT - 1)) ? \
  601. (x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \
  602. (x) + 1)
  603. #define RCQ_BD(x) ((x) & MAX_RCQ_BD)
  604. /* dropless fc calculations for RCQs
  605. *
  606. * Number of RCQs should be as number of buffers in BRB:
  607. * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT
  608. * "next" elements on each page
  609. */
  610. #define NUM_RCQ_REQ BRB_SIZE(bp)
  611. #define NUM_RCQ_PG_REQ ((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \
  612. MAX_RCQ_DESC_CNT)
  613. #define RCQ_TH_LO(bp) (NUM_RCQ_REQ + \
  614. NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \
  615. FW_DROP_LEVEL(bp))
  616. #define RCQ_TH_HI(bp) (RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM)
  617. /* This is needed for determining of last_max */
  618. #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b))
  619. #define SUB_S32(a, b) (s32)((s32)(a) - (s32)(b))
  620. #define BNX2X_SWCID_SHIFT 17
  621. #define BNX2X_SWCID_MASK ((0x1 << BNX2X_SWCID_SHIFT) - 1)
  622. /* used on a CID received from the HW */
  623. #define SW_CID(x) (le32_to_cpu(x) & BNX2X_SWCID_MASK)
  624. #define CQE_CMD(x) (le32_to_cpu(x) >> \
  625. COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
  626. #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \
  627. le32_to_cpu((bd)->addr_lo))
  628. #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
  629. #define BNX2X_DB_MIN_SHIFT 3 /* 8 bytes */
  630. #define BNX2X_DB_SHIFT 3 /* 8 bytes*/
  631. #if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT)
  632. #error "Min DB doorbell stride is 8"
  633. #endif
  634. #define DOORBELL(bp, cid, val) \
  635. do { \
  636. writel((u32)(val), bp->doorbells + (bp->db_size * (cid))); \
  637. } while (0)
  638. /* TX CSUM helpers */
  639. #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \
  640. skb->csum_offset)
  641. #define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \
  642. skb->csum_offset))
  643. #define pbd_tcp_flags(tcp_hdr) (ntohl(tcp_flag_word(tcp_hdr))>>16 & 0xff)
  644. #define XMIT_PLAIN 0
  645. #define XMIT_CSUM_V4 (1 << 0)
  646. #define XMIT_CSUM_V6 (1 << 1)
  647. #define XMIT_CSUM_TCP (1 << 2)
  648. #define XMIT_GSO_V4 (1 << 3)
  649. #define XMIT_GSO_V6 (1 << 4)
  650. #define XMIT_CSUM_ENC_V4 (1 << 5)
  651. #define XMIT_CSUM_ENC_V6 (1 << 6)
  652. #define XMIT_GSO_ENC_V4 (1 << 7)
  653. #define XMIT_GSO_ENC_V6 (1 << 8)
  654. #define XMIT_CSUM_ENC (XMIT_CSUM_ENC_V4 | XMIT_CSUM_ENC_V6)
  655. #define XMIT_GSO_ENC (XMIT_GSO_ENC_V4 | XMIT_GSO_ENC_V6)
  656. #define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6 | XMIT_CSUM_ENC)
  657. #define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6 | XMIT_GSO_ENC)
  658. /* stuff added to make the code fit 80Col */
  659. #define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
  660. #define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG)
  661. #define CQE_TYPE_STOP(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG)
  662. #define CQE_TYPE_SLOW(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD)
  663. #define CQE_TYPE_FAST(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH)
  664. #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
  665. #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
  666. (((le16_to_cpu(flags) & \
  667. PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
  668. PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
  669. == PRS_FLAG_OVERETH_IPV4)
  670. #define BNX2X_RX_SUM_FIX(cqe) \
  671. BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
  672. #define FP_USB_FUNC_OFF \
  673. offsetof(struct cstorm_status_block_u, func)
  674. #define FP_CSB_FUNC_OFF \
  675. offsetof(struct cstorm_status_block_c, func)
  676. #define HC_INDEX_ETH_RX_CQ_CONS 1
  677. #define HC_INDEX_OOO_TX_CQ_CONS 4
  678. #define HC_INDEX_ETH_TX_CQ_CONS_COS0 5
  679. #define HC_INDEX_ETH_TX_CQ_CONS_COS1 6
  680. #define HC_INDEX_ETH_TX_CQ_CONS_COS2 7
  681. #define HC_INDEX_ETH_FIRST_TX_CQ_CONS HC_INDEX_ETH_TX_CQ_CONS_COS0
  682. #define BNX2X_RX_SB_INDEX \
  683. (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
  684. #define BNX2X_TX_SB_INDEX_BASE BNX2X_TX_SB_INDEX_COS0
  685. #define BNX2X_TX_SB_INDEX_COS0 \
  686. (&fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0])
  687. /* end of fast path */
  688. /* common */
  689. struct bnx2x_common {
  690. u32 chip_id;
  691. /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
  692. #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0)
  693. #define CHIP_NUM(bp) (bp->common.chip_id >> 16)
  694. #define CHIP_NUM_57710 0x164e
  695. #define CHIP_NUM_57711 0x164f
  696. #define CHIP_NUM_57711E 0x1650
  697. #define CHIP_NUM_57712 0x1662
  698. #define CHIP_NUM_57712_MF 0x1663
  699. #define CHIP_NUM_57712_VF 0x166f
  700. #define CHIP_NUM_57713 0x1651
  701. #define CHIP_NUM_57713E 0x1652
  702. #define CHIP_NUM_57800 0x168a
  703. #define CHIP_NUM_57800_MF 0x16a5
  704. #define CHIP_NUM_57800_VF 0x16a9
  705. #define CHIP_NUM_57810 0x168e
  706. #define CHIP_NUM_57810_MF 0x16ae
  707. #define CHIP_NUM_57810_VF 0x16af
  708. #define CHIP_NUM_57811 0x163d
  709. #define CHIP_NUM_57811_MF 0x163e
  710. #define CHIP_NUM_57811_VF 0x163f
  711. #define CHIP_NUM_57840_OBSOLETE 0x168d
  712. #define CHIP_NUM_57840_MF_OBSOLETE 0x16ab
  713. #define CHIP_NUM_57840_4_10 0x16a1
  714. #define CHIP_NUM_57840_2_20 0x16a2
  715. #define CHIP_NUM_57840_MF 0x16a4
  716. #define CHIP_NUM_57840_VF 0x16ad
  717. #define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710)
  718. #define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711)
  719. #define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E)
  720. #define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712)
  721. #define CHIP_IS_57712_VF(bp) (CHIP_NUM(bp) == CHIP_NUM_57712_VF)
  722. #define CHIP_IS_57712_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57712_MF)
  723. #define CHIP_IS_57800(bp) (CHIP_NUM(bp) == CHIP_NUM_57800)
  724. #define CHIP_IS_57800_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57800_MF)
  725. #define CHIP_IS_57800_VF(bp) (CHIP_NUM(bp) == CHIP_NUM_57800_VF)
  726. #define CHIP_IS_57810(bp) (CHIP_NUM(bp) == CHIP_NUM_57810)
  727. #define CHIP_IS_57810_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57810_MF)
  728. #define CHIP_IS_57810_VF(bp) (CHIP_NUM(bp) == CHIP_NUM_57810_VF)
  729. #define CHIP_IS_57811(bp) (CHIP_NUM(bp) == CHIP_NUM_57811)
  730. #define CHIP_IS_57811_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57811_MF)
  731. #define CHIP_IS_57811_VF(bp) (CHIP_NUM(bp) == CHIP_NUM_57811_VF)
  732. #define CHIP_IS_57840(bp) \
  733. ((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) || \
  734. (CHIP_NUM(bp) == CHIP_NUM_57840_2_20) || \
  735. (CHIP_NUM(bp) == CHIP_NUM_57840_OBSOLETE))
  736. #define CHIP_IS_57840_MF(bp) ((CHIP_NUM(bp) == CHIP_NUM_57840_MF) || \
  737. (CHIP_NUM(bp) == CHIP_NUM_57840_MF_OBSOLETE))
  738. #define CHIP_IS_57840_VF(bp) (CHIP_NUM(bp) == CHIP_NUM_57840_VF)
  739. #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \
  740. CHIP_IS_57711E(bp))
  741. #define CHIP_IS_57811xx(bp) (CHIP_IS_57811(bp) || \
  742. CHIP_IS_57811_MF(bp) || \
  743. CHIP_IS_57811_VF(bp))
  744. #define CHIP_IS_E2(bp) (CHIP_IS_57712(bp) || \
  745. CHIP_IS_57712_MF(bp) || \
  746. CHIP_IS_57712_VF(bp))
  747. #define CHIP_IS_E3(bp) (CHIP_IS_57800(bp) || \
  748. CHIP_IS_57800_MF(bp) || \
  749. CHIP_IS_57800_VF(bp) || \
  750. CHIP_IS_57810(bp) || \
  751. CHIP_IS_57810_MF(bp) || \
  752. CHIP_IS_57810_VF(bp) || \
  753. CHIP_IS_57811xx(bp) || \
  754. CHIP_IS_57840(bp) || \
  755. CHIP_IS_57840_MF(bp) || \
  756. CHIP_IS_57840_VF(bp))
  757. #define CHIP_IS_E1x(bp) (CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
  758. #define USES_WARPCORE(bp) (CHIP_IS_E3(bp))
  759. #define IS_E1H_OFFSET (!CHIP_IS_E1(bp))
  760. #define CHIP_REV_SHIFT 12
  761. #define CHIP_REV_MASK (0xF << CHIP_REV_SHIFT)
  762. #define CHIP_REV_VAL(bp) (bp->common.chip_id & CHIP_REV_MASK)
  763. #define CHIP_REV_Ax (0x0 << CHIP_REV_SHIFT)
  764. #define CHIP_REV_Bx (0x1 << CHIP_REV_SHIFT)
  765. /* assume maximum 5 revisions */
  766. #define CHIP_REV_IS_SLOW(bp) (CHIP_REV_VAL(bp) > 0x00005000)
  767. /* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */
  768. #define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \
  769. !(CHIP_REV_VAL(bp) & 0x00001000))
  770. /* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */
  771. #define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \
  772. (CHIP_REV_VAL(bp) & 0x00001000))
  773. #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
  774. ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
  775. #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0)
  776. #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f)
  777. #define CHIP_REV_SIM(bp) (((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\
  778. (CHIP_REV_SHIFT + 1)) \
  779. << CHIP_REV_SHIFT)
  780. #define CHIP_REV(bp) (CHIP_REV_IS_SLOW(bp) ? \
  781. CHIP_REV_SIM(bp) :\
  782. CHIP_REV_VAL(bp))
  783. #define CHIP_IS_E3B0(bp) (CHIP_IS_E3(bp) && \
  784. (CHIP_REV(bp) == CHIP_REV_Bx))
  785. #define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \
  786. (CHIP_REV(bp) == CHIP_REV_Ax))
  787. /* This define is used in two main places:
  788. * 1. In the early stages of nic_load, to know if to configure Parser / Searcher
  789. * to nic-only mode or to offload mode. Offload mode is configured if either the
  790. * chip is E1x (where MIC_MODE register is not applicable), or if cnic already
  791. * registered for this port (which means that the user wants storage services).
  792. * 2. During cnic-related load, to know if offload mode is already configured in
  793. * the HW or needs to be configured.
  794. * Since the transition from nic-mode to offload-mode in HW causes traffic
  795. * corruption, nic-mode is configured only in ports on which storage services
  796. * where never requested.
  797. */
  798. #define CONFIGURE_NIC_MODE(bp) (!CHIP_IS_E1x(bp) && !CNIC_ENABLED(bp))
  799. int flash_size;
  800. #define BNX2X_NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */
  801. #define BNX2X_NVRAM_TIMEOUT_COUNT 30000
  802. #define BNX2X_NVRAM_PAGE_SIZE 256
  803. u32 shmem_base;
  804. u32 shmem2_base;
  805. u32 mf_cfg_base;
  806. u32 mf2_cfg_base;
  807. u32 hw_config;
  808. u32 bc_ver;
  809. u8 int_block;
  810. #define INT_BLOCK_HC 0
  811. #define INT_BLOCK_IGU 1
  812. #define INT_BLOCK_MODE_NORMAL 0
  813. #define INT_BLOCK_MODE_BW_COMP 2
  814. #define CHIP_INT_MODE_IS_NBC(bp) \
  815. (!CHIP_IS_E1x(bp) && \
  816. !((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
  817. #define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
  818. u8 chip_port_mode;
  819. #define CHIP_4_PORT_MODE 0x0
  820. #define CHIP_2_PORT_MODE 0x1
  821. #define CHIP_PORT_MODE_NONE 0x2
  822. #define CHIP_MODE(bp) (bp->common.chip_port_mode)
  823. #define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
  824. u32 boot_mode;
  825. };
  826. /* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
  827. #define BNX2X_IGU_STAS_MSG_VF_CNT 64
  828. #define BNX2X_IGU_STAS_MSG_PF_CNT 4
  829. #define MAX_IGU_ATTN_ACK_TO 100
  830. /* end of common */
  831. /* port */
  832. struct bnx2x_port {
  833. u32 pmf;
  834. u32 link_config[LINK_CONFIG_SIZE];
  835. u32 supported[LINK_CONFIG_SIZE];
  836. u32 advertising[LINK_CONFIG_SIZE];
  837. u32 phy_addr;
  838. /* used to synchronize phy accesses */
  839. struct mutex phy_mutex;
  840. u32 port_stx;
  841. struct nig_stats old_nig_stats;
  842. };
  843. /* end of port */
  844. #define STATS_OFFSET32(stat_name) \
  845. (offsetof(struct bnx2x_eth_stats, stat_name) / 4)
  846. /* slow path */
  847. #define BNX2X_MAX_NUM_OF_VFS 64
  848. #define BNX2X_VF_CID_WND 4 /* log num of queues per VF. HW config. */
  849. #define BNX2X_CIDS_PER_VF (1 << BNX2X_VF_CID_WND)
  850. /* We need to reserve doorbell addresses for all VF and queue combinations */
  851. #define BNX2X_VF_CIDS (BNX2X_MAX_NUM_OF_VFS * BNX2X_CIDS_PER_VF)
  852. /* The doorbell is configured to have the same number of CIDs for PFs and for
  853. * VFs. For this reason the PF CID zone is as large as the VF zone.
  854. */
  855. #define BNX2X_FIRST_VF_CID BNX2X_VF_CIDS
  856. #define BNX2X_MAX_NUM_VF_QUEUES 64
  857. #define BNX2X_VF_ID_INVALID 0xFF
  858. /* the number of VF CIDS multiplied by the amount of bytes reserved for each
  859. * cid must not exceed the size of the VF doorbell
  860. */
  861. #define BNX2X_VF_BAR_SIZE 512
  862. #if (BNX2X_VF_BAR_SIZE < BNX2X_CIDS_PER_VF * (1 << BNX2X_DB_SHIFT))
  863. #error "VF doorbell bar size is 512"
  864. #endif
  865. /*
  866. * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is
  867. * control by the number of fast-path status blocks supported by the
  868. * device (HW/FW). Each fast-path status block (FP-SB) aka non-default
  869. * status block represents an independent interrupts context that can
  870. * serve a regular L2 networking queue. However special L2 queues such
  871. * as the FCoE queue do not require a FP-SB and other components like
  872. * the CNIC may consume FP-SB reducing the number of possible L2 queues
  873. *
  874. * If the maximum number of FP-SB available is X then:
  875. * a. If CNIC is supported it consumes 1 FP-SB thus the max number of
  876. * regular L2 queues is Y=X-1
  877. * b. In MF mode the actual number of L2 queues is Y= (X-1/MF_factor)
  878. * c. If the FCoE L2 queue is supported the actual number of L2 queues
  879. * is Y+1
  880. * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for
  881. * slow-path interrupts) or Y+2 if CNIC is supported (one additional
  882. * FP interrupt context for the CNIC).
  883. * e. The number of HW context (CID count) is always X or X+1 if FCoE
  884. * L2 queue is supported. The cid for the FCoE L2 queue is always X.
  885. */
  886. /* fast-path interrupt contexts E1x */
  887. #define FP_SB_MAX_E1x 16
  888. /* fast-path interrupt contexts E2 */
  889. #define FP_SB_MAX_E2 HC_SB_MAX_SB_E2
  890. union cdu_context {
  891. struct eth_context eth;
  892. char pad[1024];
  893. };
  894. /* CDU host DB constants */
  895. #define CDU_ILT_PAGE_SZ_HW 2
  896. #define CDU_ILT_PAGE_SZ (8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */
  897. #define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
  898. #define CNIC_ISCSI_CID_MAX 256
  899. #define CNIC_FCOE_CID_MAX 2048
  900. #define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
  901. #define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
  902. #define QM_ILT_PAGE_SZ_HW 0
  903. #define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
  904. #define QM_CID_ROUND 1024
  905. /* TM (timers) host DB constants */
  906. #define TM_ILT_PAGE_SZ_HW 0
  907. #define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
  908. #define TM_CONN_NUM (BNX2X_FIRST_VF_CID + \
  909. BNX2X_VF_CIDS + \
  910. CNIC_ISCSI_CID_MAX)
  911. #define TM_ILT_SZ (8 * TM_CONN_NUM)
  912. #define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
  913. /* SRC (Searcher) host DB constants */
  914. #define SRC_ILT_PAGE_SZ_HW 0
  915. #define SRC_ILT_PAGE_SZ (4096 << SRC_ILT_PAGE_SZ_HW) /* 4K */
  916. #define SRC_HASH_BITS 10
  917. #define SRC_CONN_NUM (1 << SRC_HASH_BITS) /* 1024 */
  918. #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)
  919. #define SRC_T2_SZ SRC_ILT_SZ
  920. #define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
  921. #define MAX_DMAE_C 8
  922. /* DMA memory not used in fastpath */
  923. struct bnx2x_slowpath {
  924. union {
  925. struct mac_configuration_cmd e1x;
  926. struct eth_classify_rules_ramrod_data e2;
  927. } mac_rdata;
  928. union {
  929. struct eth_classify_rules_ramrod_data e2;
  930. } vlan_rdata;
  931. union {
  932. struct tstorm_eth_mac_filter_config e1x;
  933. struct eth_filter_rules_ramrod_data e2;
  934. } rx_mode_rdata;
  935. union {
  936. struct mac_configuration_cmd e1;
  937. struct eth_multicast_rules_ramrod_data e2;
  938. } mcast_rdata;
  939. struct eth_rss_update_ramrod_data rss_rdata;
  940. /* Queue State related ramrods are always sent under rtnl_lock */
  941. union {
  942. struct client_init_ramrod_data init_data;
  943. struct client_update_ramrod_data update_data;
  944. struct tpa_update_ramrod_data tpa_data;
  945. } q_rdata;
  946. union {
  947. struct function_start_data func_start;
  948. /* pfc configuration for DCBX ramrod */
  949. struct flow_control_configuration pfc_config;
  950. } func_rdata;
  951. /* afex ramrod can not be a part of func_rdata union because these
  952. * events might arrive in parallel to other events from func_rdata.
  953. * Therefore, if they would have been defined in the same union,
  954. * data can get corrupted.
  955. */
  956. union {
  957. struct afex_vif_list_ramrod_data viflist_data;
  958. struct function_update_data func_update;
  959. } func_afex_rdata;
  960. /* used by dmae command executer */
  961. struct dmae_command dmae[MAX_DMAE_C];
  962. u32 stats_comp;
  963. union mac_stats mac_stats;
  964. struct nig_stats nig_stats;
  965. struct host_port_stats port_stats;
  966. struct host_func_stats func_stats;
  967. u32 wb_comp;
  968. u32 wb_data[4];
  969. union drv_info_to_mcp drv_info_to_mcp;
  970. };
  971. #define bnx2x_sp(bp, var) (&bp->slowpath->var)
  972. #define bnx2x_sp_mapping(bp, var) \
  973. (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
  974. /* attn group wiring */
  975. #define MAX_DYNAMIC_ATTN_GRPS 8
  976. struct attn_route {
  977. u32 sig[5];
  978. };
  979. struct iro {
  980. u32 base;
  981. u16 m1;
  982. u16 m2;
  983. u16 m3;
  984. u16 size;
  985. };
  986. struct hw_context {
  987. union cdu_context *vcxt;
  988. dma_addr_t cxt_mapping;
  989. size_t size;
  990. };
  991. /* forward */
  992. struct bnx2x_ilt;
  993. struct bnx2x_vfdb;
  994. enum bnx2x_recovery_state {
  995. BNX2X_RECOVERY_DONE,
  996. BNX2X_RECOVERY_INIT,
  997. BNX2X_RECOVERY_WAIT,
  998. BNX2X_RECOVERY_FAILED,
  999. BNX2X_RECOVERY_NIC_LOADING
  1000. };
  1001. /*
  1002. * Event queue (EQ or event ring) MC hsi
  1003. * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2
  1004. */
  1005. #define NUM_EQ_PAGES 1
  1006. #define EQ_DESC_CNT_PAGE (BCM_PAGE_SIZE / sizeof(union event_ring_elem))
  1007. #define EQ_DESC_MAX_PAGE (EQ_DESC_CNT_PAGE - 1)
  1008. #define NUM_EQ_DESC (EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
  1009. #define EQ_DESC_MASK (NUM_EQ_DESC - 1)
  1010. #define MAX_EQ_AVAIL (EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
  1011. /* depends on EQ_DESC_CNT_PAGE being a power of 2 */
  1012. #define NEXT_EQ_IDX(x) ((((x) & EQ_DESC_MAX_PAGE) == \
  1013. (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
  1014. /* depends on the above and on NUM_EQ_PAGES being a power of 2 */
  1015. #define EQ_DESC(x) ((x) & EQ_DESC_MASK)
  1016. #define BNX2X_EQ_INDEX \
  1017. (&bp->def_status_blk->sp_sb.\
  1018. index_values[HC_SP_INDEX_EQ_CONS])
  1019. /* This is a data that will be used to create a link report message.
  1020. * We will keep the data used for the last link report in order
  1021. * to prevent reporting the same link parameters twice.
  1022. */
  1023. struct bnx2x_link_report_data {
  1024. u16 line_speed; /* Effective line speed */
  1025. unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */
  1026. };
  1027. enum {
  1028. BNX2X_LINK_REPORT_FD, /* Full DUPLEX */
  1029. BNX2X_LINK_REPORT_LINK_DOWN,
  1030. BNX2X_LINK_REPORT_RX_FC_ON,
  1031. BNX2X_LINK_REPORT_TX_FC_ON,
  1032. };
  1033. enum {
  1034. BNX2X_PORT_QUERY_IDX,
  1035. BNX2X_PF_QUERY_IDX,
  1036. BNX2X_FCOE_QUERY_IDX,
  1037. BNX2X_FIRST_QUEUE_QUERY_IDX,
  1038. };
  1039. struct bnx2x_fw_stats_req {
  1040. struct stats_query_header hdr;
  1041. struct stats_query_entry query[FP_SB_MAX_E1x+
  1042. BNX2X_FIRST_QUEUE_QUERY_IDX];
  1043. };
  1044. struct bnx2x_fw_stats_data {
  1045. struct stats_counter storm_counters;
  1046. struct per_port_stats port;
  1047. struct per_pf_stats pf;
  1048. struct fcoe_statistics_params fcoe;
  1049. struct per_queue_stats queue_stats[1];
  1050. };
  1051. /* Public slow path states */
  1052. enum sp_rtnl_flag {
  1053. BNX2X_SP_RTNL_SETUP_TC,
  1054. BNX2X_SP_RTNL_TX_TIMEOUT,
  1055. BNX2X_SP_RTNL_FAN_FAILURE,
  1056. BNX2X_SP_RTNL_AFEX_F_UPDATE,
  1057. BNX2X_SP_RTNL_ENABLE_SRIOV,
  1058. BNX2X_SP_RTNL_VFPF_MCAST,
  1059. BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
  1060. BNX2X_SP_RTNL_RX_MODE,
  1061. BNX2X_SP_RTNL_HYPERVISOR_VLAN,
  1062. BNX2X_SP_RTNL_TX_STOP,
  1063. BNX2X_SP_RTNL_GET_DRV_VERSION,
  1064. BNX2X_SP_RTNL_CHANGE_UDP_PORT,
  1065. };
  1066. enum bnx2x_iov_flag {
  1067. BNX2X_IOV_HANDLE_VF_MSG,
  1068. BNX2X_IOV_HANDLE_FLR,
  1069. };
  1070. struct bnx2x_prev_path_list {
  1071. struct list_head list;
  1072. u8 bus;
  1073. u8 slot;
  1074. u8 path;
  1075. u8 aer;
  1076. u8 undi;
  1077. };
  1078. struct bnx2x_sp_objs {
  1079. /* MACs object */
  1080. struct bnx2x_vlan_mac_obj mac_obj;
  1081. /* Queue State object */
  1082. struct bnx2x_queue_sp_obj q_obj;
  1083. /* VLANs object */
  1084. struct bnx2x_vlan_mac_obj vlan_obj;
  1085. };
  1086. struct bnx2x_fp_stats {
  1087. struct tstorm_per_queue_stats old_tclient;
  1088. struct ustorm_per_queue_stats old_uclient;
  1089. struct xstorm_per_queue_stats old_xclient;
  1090. struct bnx2x_eth_q_stats eth_q_stats;
  1091. struct bnx2x_eth_q_stats_old eth_q_stats_old;
  1092. };
  1093. enum {
  1094. SUB_MF_MODE_UNKNOWN = 0,
  1095. SUB_MF_MODE_UFP,
  1096. SUB_MF_MODE_NPAR1_DOT_5,
  1097. SUB_MF_MODE_BD,
  1098. };
  1099. struct bnx2x_vlan_entry {
  1100. struct list_head link;
  1101. u16 vid;
  1102. bool hw;
  1103. };
  1104. enum bnx2x_udp_port_type {
  1105. BNX2X_UDP_PORT_VXLAN,
  1106. BNX2X_UDP_PORT_GENEVE,
  1107. BNX2X_UDP_PORT_MAX,
  1108. };
  1109. struct bnx2x_udp_tunnel {
  1110. u16 dst_port;
  1111. u8 count;
  1112. };
  1113. struct bnx2x {
  1114. /* Fields used in the tx and intr/napi performance paths
  1115. * are grouped together in the beginning of the structure
  1116. */
  1117. struct bnx2x_fastpath *fp;
  1118. struct bnx2x_sp_objs *sp_objs;
  1119. struct bnx2x_fp_stats *fp_stats;
  1120. struct bnx2x_fp_txdata *bnx2x_txq;
  1121. void __iomem *regview;
  1122. void __iomem *doorbells;
  1123. u16 db_size;
  1124. u8 pf_num; /* absolute PF number */
  1125. u8 pfid; /* per-path PF number */
  1126. int base_fw_ndsb; /**/
  1127. #define BP_PATH(bp) (CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1))
  1128. #define BP_PORT(bp) (bp->pfid & 1)
  1129. #define BP_FUNC(bp) (bp->pfid)
  1130. #define BP_ABS_FUNC(bp) (bp->pf_num)
  1131. #define BP_VN(bp) ((bp)->pfid >> 1)
  1132. #define BP_MAX_VN_NUM(bp) (CHIP_MODE_IS_4_PORT(bp) ? 2 : 4)
  1133. #define BP_L_ID(bp) (BP_VN(bp) << 2)
  1134. #define BP_FW_MB_IDX_VN(bp, vn) (BP_PORT(bp) +\
  1135. (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1))
  1136. #define BP_FW_MB_IDX(bp) BP_FW_MB_IDX_VN(bp, BP_VN(bp))
  1137. #ifdef CONFIG_BNX2X_SRIOV
  1138. /* protects vf2pf mailbox from simultaneous access */
  1139. struct mutex vf2pf_mutex;
  1140. /* vf pf channel mailbox contains request and response buffers */
  1141. struct bnx2x_vf_mbx_msg *vf2pf_mbox;
  1142. dma_addr_t vf2pf_mbox_mapping;
  1143. /* we set aside a copy of the acquire response */
  1144. struct pfvf_acquire_resp_tlv acquire_resp;
  1145. /* bulletin board for messages from pf to vf */
  1146. union pf_vf_bulletin *pf2vf_bulletin;
  1147. dma_addr_t pf2vf_bulletin_mapping;
  1148. union pf_vf_bulletin shadow_bulletin;
  1149. struct pf_vf_bulletin_content old_bulletin;
  1150. u16 requested_nr_virtfn;
  1151. #endif /* CONFIG_BNX2X_SRIOV */
  1152. struct net_device *dev;
  1153. struct pci_dev *pdev;
  1154. const struct iro *iro_arr;
  1155. #define IRO (bp->iro_arr)
  1156. enum bnx2x_recovery_state recovery_state;
  1157. int is_leader;
  1158. struct msix_entry *msix_table;
  1159. int tx_ring_size;
  1160. /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
  1161. #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
  1162. #define ETH_MIN_PACKET_SIZE 60
  1163. #define ETH_MAX_PACKET_SIZE 1500
  1164. #define ETH_MAX_JUMBO_PACKET_SIZE 9600
  1165. /* TCP with Timestamp Option (32) + IPv6 (40) */
  1166. #define ETH_MAX_TPA_HEADER_SIZE 72
  1167. /* Max supported alignment is 256 (8 shift)
  1168. * minimal alignment shift 6 is optimal for 57xxx HW performance
  1169. */
  1170. #define BNX2X_RX_ALIGN_SHIFT max(6, min(8, L1_CACHE_SHIFT))
  1171. /* FW uses 2 Cache lines Alignment for start packet and size
  1172. *
  1173. * We assume skb_build() uses sizeof(struct skb_shared_info) bytes
  1174. * at the end of skb->data, to avoid wasting a full cache line.
  1175. * This reduces memory use (skb->truesize).
  1176. */
  1177. #define BNX2X_FW_RX_ALIGN_START (1UL << BNX2X_RX_ALIGN_SHIFT)
  1178. #define BNX2X_FW_RX_ALIGN_END \
  1179. max_t(u64, 1UL << BNX2X_RX_ALIGN_SHIFT, \
  1180. SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
  1181. #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5)
  1182. struct host_sp_status_block *def_status_blk;
  1183. #define DEF_SB_IGU_ID 16
  1184. #define DEF_SB_ID HC_SP_SB_ID
  1185. __le16 def_idx;
  1186. __le16 def_att_idx;
  1187. u32 attn_state;
  1188. struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS];
  1189. /* slow path ring */
  1190. struct eth_spe *spq;
  1191. dma_addr_t spq_mapping;
  1192. u16 spq_prod_idx;
  1193. struct eth_spe *spq_prod_bd;
  1194. struct eth_spe *spq_last_bd;
  1195. __le16 *dsb_sp_prod;
  1196. atomic_t cq_spq_left; /* ETH_XXX ramrods credit */
  1197. /* used to synchronize spq accesses */
  1198. spinlock_t spq_lock;
  1199. /* event queue */
  1200. union event_ring_elem *eq_ring;
  1201. dma_addr_t eq_mapping;
  1202. u16 eq_prod;
  1203. u16 eq_cons;
  1204. __le16 *eq_cons_sb;
  1205. atomic_t eq_spq_left; /* COMMON_XXX ramrods credit */
  1206. /* Counter for marking that there is a STAT_QUERY ramrod pending */
  1207. u16 stats_pending;
  1208. /* Counter for completed statistics ramrods */
  1209. u16 stats_comp;
  1210. /* End of fields used in the performance code paths */
  1211. int panic;
  1212. int msg_enable;
  1213. u32 flags;
  1214. #define PCIX_FLAG (1 << 0)
  1215. #define PCI_32BIT_FLAG (1 << 1)
  1216. #define ONE_PORT_FLAG (1 << 2)
  1217. #define NO_WOL_FLAG (1 << 3)
  1218. #define USING_MSIX_FLAG (1 << 5)
  1219. #define USING_MSI_FLAG (1 << 6)
  1220. #define DISABLE_MSI_FLAG (1 << 7)
  1221. #define NO_MCP_FLAG (1 << 9)
  1222. #define MF_FUNC_DIS (1 << 11)
  1223. #define OWN_CNIC_IRQ (1 << 12)
  1224. #define NO_ISCSI_OOO_FLAG (1 << 13)
  1225. #define NO_ISCSI_FLAG (1 << 14)
  1226. #define NO_FCOE_FLAG (1 << 15)
  1227. #define BC_SUPPORTS_PFC_STATS (1 << 17)
  1228. #define TX_SWITCHING (1 << 18)
  1229. #define BC_SUPPORTS_FCOE_FEATURES (1 << 19)
  1230. #define USING_SINGLE_MSIX_FLAG (1 << 20)
  1231. #define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21)
  1232. #define IS_VF_FLAG (1 << 22)
  1233. #define BC_SUPPORTS_RMMOD_CMD (1 << 23)
  1234. #define HAS_PHYS_PORT_ID (1 << 24)
  1235. #define AER_ENABLED (1 << 25)
  1236. #define PTP_SUPPORTED (1 << 26)
  1237. #define TX_TIMESTAMPING_EN (1 << 27)
  1238. #define BP_NOMCP(bp) ((bp)->flags & NO_MCP_FLAG)
  1239. #ifdef CONFIG_BNX2X_SRIOV
  1240. #define IS_VF(bp) ((bp)->flags & IS_VF_FLAG)
  1241. #define IS_PF(bp) (!((bp)->flags & IS_VF_FLAG))
  1242. #else
  1243. #define IS_VF(bp) false
  1244. #define IS_PF(bp) true
  1245. #endif
  1246. #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG)
  1247. #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
  1248. #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG)
  1249. u8 cnic_support;
  1250. bool cnic_enabled;
  1251. bool cnic_loaded;
  1252. struct cnic_eth_dev *(*cnic_probe)(struct net_device *);
  1253. /* Flag that indicates that we can start looking for FCoE L2 queue
  1254. * completions in the default status block.
  1255. */
  1256. bool fcoe_init;
  1257. int mrrs;
  1258. struct delayed_work sp_task;
  1259. struct delayed_work iov_task;
  1260. atomic_t interrupt_occurred;
  1261. struct delayed_work sp_rtnl_task;
  1262. struct delayed_work period_task;
  1263. struct timer_list timer;
  1264. int current_interval;
  1265. u16 fw_seq;
  1266. u16 fw_drv_pulse_wr_seq;
  1267. u32 func_stx;
  1268. struct link_params link_params;
  1269. struct link_vars link_vars;
  1270. u32 link_cnt;
  1271. struct bnx2x_link_report_data last_reported_link;
  1272. struct mdio_if_info mdio;
  1273. struct bnx2x_common common;
  1274. struct bnx2x_port port;
  1275. struct cmng_init cmng;
  1276. u32 mf_config[E1HVN_MAX];
  1277. u32 mf_ext_config;
  1278. u32 path_has_ovlan; /* E3 */
  1279. u16 mf_ov;
  1280. u8 mf_mode;
  1281. #define IS_MF(bp) (bp->mf_mode != 0)
  1282. #define IS_MF_SI(bp) (bp->mf_mode == MULTI_FUNCTION_SI)
  1283. #define IS_MF_SD(bp) (bp->mf_mode == MULTI_FUNCTION_SD)
  1284. #define IS_MF_AFEX(bp) (bp->mf_mode == MULTI_FUNCTION_AFEX)
  1285. u8 mf_sub_mode;
  1286. #define IS_MF_UFP(bp) (IS_MF_SD(bp) && \
  1287. bp->mf_sub_mode == SUB_MF_MODE_UFP)
  1288. #define IS_MF_BD(bp) (IS_MF_SD(bp) && \
  1289. bp->mf_sub_mode == SUB_MF_MODE_BD)
  1290. u8 wol;
  1291. int rx_ring_size;
  1292. u16 tx_quick_cons_trip_int;
  1293. u16 tx_quick_cons_trip;
  1294. u16 tx_ticks_int;
  1295. u16 tx_ticks;
  1296. u16 rx_quick_cons_trip_int;
  1297. u16 rx_quick_cons_trip;
  1298. u16 rx_ticks_int;
  1299. u16 rx_ticks;
  1300. /* Maximal coalescing timeout in us */
  1301. #define BNX2X_MAX_COALESCE_TOUT (0xff*BNX2X_BTR)
  1302. u32 lin_cnt;
  1303. u16 state;
  1304. #define BNX2X_STATE_CLOSED 0
  1305. #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000
  1306. #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000
  1307. #define BNX2X_STATE_OPEN 0x3000
  1308. #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
  1309. #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
  1310. #define BNX2X_STATE_DIAG 0xe000
  1311. #define BNX2X_STATE_ERROR 0xf000
  1312. #define BNX2X_MAX_PRIORITY 8
  1313. int num_queues;
  1314. uint num_ethernet_queues;
  1315. uint num_cnic_queues;
  1316. int disable_tpa;
  1317. u32 rx_mode;
  1318. #define BNX2X_RX_MODE_NONE 0
  1319. #define BNX2X_RX_MODE_NORMAL 1
  1320. #define BNX2X_RX_MODE_ALLMULTI 2
  1321. #define BNX2X_RX_MODE_PROMISC 3
  1322. #define BNX2X_MAX_MULTICAST 64
  1323. u8 igu_dsb_id;
  1324. u8 igu_base_sb;
  1325. u8 igu_sb_cnt;
  1326. u8 min_msix_vec_cnt;
  1327. u32 igu_base_addr;
  1328. dma_addr_t def_status_blk_mapping;
  1329. struct bnx2x_slowpath *slowpath;
  1330. dma_addr_t slowpath_mapping;
  1331. /* Mechanism protecting the drv_info_to_mcp */
  1332. struct mutex drv_info_mutex;
  1333. bool drv_info_mng_owner;
  1334. /* Total number of FW statistics requests */
  1335. u8 fw_stats_num;
  1336. /*
  1337. * This is a memory buffer that will contain both statistics
  1338. * ramrod request and data.
  1339. */
  1340. void *fw_stats;
  1341. dma_addr_t fw_stats_mapping;
  1342. /*
  1343. * FW statistics request shortcut (points at the
  1344. * beginning of fw_stats buffer).
  1345. */
  1346. struct bnx2x_fw_stats_req *fw_stats_req;
  1347. dma_addr_t fw_stats_req_mapping;
  1348. int fw_stats_req_sz;
  1349. /*
  1350. * FW statistics data shortcut (points at the beginning of
  1351. * fw_stats buffer + fw_stats_req_sz).
  1352. */
  1353. struct bnx2x_fw_stats_data *fw_stats_data;
  1354. dma_addr_t fw_stats_data_mapping;
  1355. int fw_stats_data_sz;
  1356. /* For max 1024 cids (VF RSS), 32KB ILT page size and 1KB
  1357. * context size we need 8 ILT entries.
  1358. */
  1359. #define ILT_MAX_L2_LINES 32
  1360. struct hw_context context[ILT_MAX_L2_LINES];
  1361. struct bnx2x_ilt *ilt;
  1362. #define BP_ILT(bp) ((bp)->ilt)
  1363. #define ILT_MAX_LINES 256
  1364. /*
  1365. * Maximum supported number of RSS queues: number of IGU SBs minus one that goes
  1366. * to CNIC.
  1367. */
  1368. #define BNX2X_MAX_RSS_COUNT(bp) ((bp)->igu_sb_cnt - CNIC_SUPPORT(bp))
  1369. /*
  1370. * Maximum CID count that might be required by the bnx2x:
  1371. * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
  1372. */
  1373. #define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
  1374. + CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
  1375. #define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
  1376. + CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
  1377. #define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
  1378. ILT_PAGE_CIDS))
  1379. int qm_cid_count;
  1380. bool dropless_fc;
  1381. void *t2;
  1382. dma_addr_t t2_mapping;
  1383. struct cnic_ops __rcu *cnic_ops;
  1384. void *cnic_data;
  1385. u32 cnic_tag;
  1386. struct cnic_eth_dev cnic_eth_dev;
  1387. union host_hc_status_block cnic_sb;
  1388. dma_addr_t cnic_sb_mapping;
  1389. struct eth_spe *cnic_kwq;
  1390. struct eth_spe *cnic_kwq_prod;
  1391. struct eth_spe *cnic_kwq_cons;
  1392. struct eth_spe *cnic_kwq_last;
  1393. u16 cnic_kwq_pending;
  1394. u16 cnic_spq_pending;
  1395. u8 fip_mac[ETH_ALEN];
  1396. struct mutex cnic_mutex;
  1397. struct bnx2x_vlan_mac_obj iscsi_l2_mac_obj;
  1398. /* Start index of the "special" (CNIC related) L2 clients */
  1399. u8 cnic_base_cl_id;
  1400. int dmae_ready;
  1401. /* used to synchronize dmae accesses */
  1402. spinlock_t dmae_lock;
  1403. /* used to protect the FW mail box */
  1404. struct mutex fw_mb_mutex;
  1405. /* used to synchronize stats collecting */
  1406. int stats_state;
  1407. /* used for synchronization of concurrent threads statistics handling */
  1408. struct semaphore stats_lock;
  1409. /* used by dmae command loader */
  1410. struct dmae_command stats_dmae;
  1411. int executer_idx;
  1412. u16 stats_counter;
  1413. struct bnx2x_eth_stats eth_stats;
  1414. struct host_func_stats func_stats;
  1415. struct bnx2x_eth_stats_old eth_stats_old;
  1416. struct bnx2x_net_stats_old net_stats_old;
  1417. struct bnx2x_fw_port_stats_old fw_stats_old;
  1418. bool stats_init;
  1419. struct z_stream_s *strm;
  1420. void *gunzip_buf;
  1421. dma_addr_t gunzip_mapping;
  1422. int gunzip_outlen;
  1423. #define FW_BUF_SIZE 0x8000
  1424. #define GUNZIP_BUF(bp) (bp->gunzip_buf)
  1425. #define GUNZIP_PHYS(bp) (bp->gunzip_mapping)
  1426. #define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen)
  1427. struct raw_op *init_ops;
  1428. /* Init blocks offsets inside init_ops */
  1429. u16 *init_ops_offsets;
  1430. /* Data blob - has 32 bit granularity */
  1431. u32 *init_data;
  1432. u32 init_mode_flags;
  1433. #define INIT_MODE_FLAGS(bp) (bp->init_mode_flags)
  1434. /* Zipped PRAM blobs - raw data */
  1435. const u8 *tsem_int_table_data;
  1436. const u8 *tsem_pram_data;
  1437. const u8 *usem_int_table_data;
  1438. const u8 *usem_pram_data;
  1439. const u8 *xsem_int_table_data;
  1440. const u8 *xsem_pram_data;
  1441. const u8 *csem_int_table_data;
  1442. const u8 *csem_pram_data;
  1443. #define INIT_OPS(bp) (bp->init_ops)
  1444. #define INIT_OPS_OFFSETS(bp) (bp->init_ops_offsets)
  1445. #define INIT_DATA(bp) (bp->init_data)
  1446. #define INIT_TSEM_INT_TABLE_DATA(bp) (bp->tsem_int_table_data)
  1447. #define INIT_TSEM_PRAM_DATA(bp) (bp->tsem_pram_data)
  1448. #define INIT_USEM_INT_TABLE_DATA(bp) (bp->usem_int_table_data)
  1449. #define INIT_USEM_PRAM_DATA(bp) (bp->usem_pram_data)
  1450. #define INIT_XSEM_INT_TABLE_DATA(bp) (bp->xsem_int_table_data)
  1451. #define INIT_XSEM_PRAM_DATA(bp) (bp->xsem_pram_data)
  1452. #define INIT_CSEM_INT_TABLE_DATA(bp) (bp->csem_int_table_data)
  1453. #define INIT_CSEM_PRAM_DATA(bp) (bp->csem_pram_data)
  1454. #define PHY_FW_VER_LEN 20
  1455. char fw_ver[32];
  1456. const struct firmware *firmware;
  1457. struct bnx2x_vfdb *vfdb;
  1458. #define IS_SRIOV(bp) ((bp)->vfdb)
  1459. /* DCB support on/off */
  1460. u16 dcb_state;
  1461. #define BNX2X_DCB_STATE_OFF 0
  1462. #define BNX2X_DCB_STATE_ON 1
  1463. /* DCBX engine mode */
  1464. int dcbx_enabled;
  1465. #define BNX2X_DCBX_ENABLED_OFF 0
  1466. #define BNX2X_DCBX_ENABLED_ON_NEG_OFF 1
  1467. #define BNX2X_DCBX_ENABLED_ON_NEG_ON 2
  1468. #define BNX2X_DCBX_ENABLED_INVALID (-1)
  1469. bool dcbx_mode_uset;
  1470. struct bnx2x_config_dcbx_params dcbx_config_params;
  1471. struct bnx2x_dcbx_port_params dcbx_port_params;
  1472. int dcb_version;
  1473. /* CAM credit pools */
  1474. struct bnx2x_credit_pool_obj vlans_pool;
  1475. struct bnx2x_credit_pool_obj macs_pool;
  1476. /* RX_MODE object */
  1477. struct bnx2x_rx_mode_obj rx_mode_obj;
  1478. /* MCAST object */
  1479. struct bnx2x_mcast_obj mcast_obj;
  1480. /* RSS configuration object */
  1481. struct bnx2x_rss_config_obj rss_conf_obj;
  1482. /* Function State controlling object */
  1483. struct bnx2x_func_sp_obj func_obj;
  1484. unsigned long sp_state;
  1485. /* operation indication for the sp_rtnl task */
  1486. unsigned long sp_rtnl_state;
  1487. /* Indication of the IOV tasks */
  1488. unsigned long iov_task_state;
  1489. /* DCBX Negotiation results */
  1490. struct dcbx_features dcbx_local_feat;
  1491. u32 dcbx_error;
  1492. #ifdef BCM_DCBNL
  1493. struct dcbx_features dcbx_remote_feat;
  1494. u32 dcbx_remote_flags;
  1495. #endif
  1496. /* AFEX: store default vlan used */
  1497. int afex_def_vlan_tag;
  1498. enum mf_cfg_afex_vlan_mode afex_vlan_mode;
  1499. u32 pending_max;
  1500. /* multiple tx classes of service */
  1501. u8 max_cos;
  1502. /* priority to cos mapping */
  1503. u8 prio_to_cos[8];
  1504. int fp_array_size;
  1505. u32 dump_preset_idx;
  1506. u8 phys_port_id[ETH_ALEN];
  1507. /* PTP related context */
  1508. struct ptp_clock *ptp_clock;
  1509. struct ptp_clock_info ptp_clock_info;
  1510. struct work_struct ptp_task;
  1511. struct cyclecounter cyclecounter;
  1512. struct timecounter timecounter;
  1513. bool timecounter_init_done;
  1514. struct sk_buff *ptp_tx_skb;
  1515. unsigned long ptp_tx_start;
  1516. bool hwtstamp_ioctl_called;
  1517. u16 tx_type;
  1518. u16 rx_filter;
  1519. struct bnx2x_link_report_data vf_link_vars;
  1520. struct list_head vlan_reg;
  1521. u16 vlan_cnt;
  1522. u16 vlan_credit;
  1523. bool accept_any_vlan;
  1524. /* Vxlan/Geneve related information */
  1525. struct bnx2x_udp_tunnel udp_tunnel_ports[BNX2X_UDP_PORT_MAX];
  1526. };
  1527. /* Tx queues may be less or equal to Rx queues */
  1528. extern int num_queues;
  1529. #define BNX2X_NUM_QUEUES(bp) (bp->num_queues)
  1530. #define BNX2X_NUM_ETH_QUEUES(bp) ((bp)->num_ethernet_queues)
  1531. #define BNX2X_NUM_NON_CNIC_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - \
  1532. (bp)->num_cnic_queues)
  1533. #define BNX2X_NUM_RX_QUEUES(bp) BNX2X_NUM_QUEUES(bp)
  1534. #define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1)
  1535. #define BNX2X_MAX_QUEUES(bp) BNX2X_MAX_RSS_COUNT(bp)
  1536. /* #define is_eth_multi(bp) (BNX2X_NUM_ETH_QUEUES(bp) > 1) */
  1537. #define RSS_IPV4_CAP_MASK \
  1538. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
  1539. #define RSS_IPV4_TCP_CAP_MASK \
  1540. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
  1541. #define RSS_IPV6_CAP_MASK \
  1542. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
  1543. #define RSS_IPV6_TCP_CAP_MASK \
  1544. TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
  1545. struct bnx2x_func_init_params {
  1546. /* dma */
  1547. bool spq_active;
  1548. dma_addr_t spq_map;
  1549. u16 spq_prod;
  1550. u16 func_id; /* abs fid */
  1551. u16 pf_id;
  1552. };
  1553. #define for_each_cnic_queue(bp, var) \
  1554. for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
  1555. (var)++) \
  1556. if (skip_queue(bp, var)) \
  1557. continue; \
  1558. else
  1559. #define for_each_eth_queue(bp, var) \
  1560. for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
  1561. #define for_each_nondefault_eth_queue(bp, var) \
  1562. for ((var) = 1; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
  1563. #define for_each_queue(bp, var) \
  1564. for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
  1565. if (skip_queue(bp, var)) \
  1566. continue; \
  1567. else
  1568. /* Skip forwarding FP */
  1569. #define for_each_valid_rx_queue(bp, var) \
  1570. for ((var) = 0; \
  1571. (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) : \
  1572. BNX2X_NUM_ETH_QUEUES(bp)); \
  1573. (var)++) \
  1574. if (skip_rx_queue(bp, var)) \
  1575. continue; \
  1576. else
  1577. #define for_each_rx_queue_cnic(bp, var) \
  1578. for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
  1579. (var)++) \
  1580. if (skip_rx_queue(bp, var)) \
  1581. continue; \
  1582. else
  1583. #define for_each_rx_queue(bp, var) \
  1584. for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
  1585. if (skip_rx_queue(bp, var)) \
  1586. continue; \
  1587. else
  1588. /* Skip OOO FP */
  1589. #define for_each_valid_tx_queue(bp, var) \
  1590. for ((var) = 0; \
  1591. (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) : \
  1592. BNX2X_NUM_ETH_QUEUES(bp)); \
  1593. (var)++) \
  1594. if (skip_tx_queue(bp, var)) \
  1595. continue; \
  1596. else
  1597. #define for_each_tx_queue_cnic(bp, var) \
  1598. for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
  1599. (var)++) \
  1600. if (skip_tx_queue(bp, var)) \
  1601. continue; \
  1602. else
  1603. #define for_each_tx_queue(bp, var) \
  1604. for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
  1605. if (skip_tx_queue(bp, var)) \
  1606. continue; \
  1607. else
  1608. #define for_each_nondefault_queue(bp, var) \
  1609. for ((var) = 1; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
  1610. if (skip_queue(bp, var)) \
  1611. continue; \
  1612. else
  1613. #define for_each_cos_in_tx_queue(fp, var) \
  1614. for ((var) = 0; (var) < (fp)->max_cos; (var)++)
  1615. /* skip rx queue
  1616. * if FCOE l2 support is disabled and this is the fcoe L2 queue
  1617. */
  1618. #define skip_rx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1619. /* skip tx queue
  1620. * if FCOE l2 support is disabled and this is the fcoe L2 queue
  1621. */
  1622. #define skip_tx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1623. #define skip_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
  1624. /**
  1625. * bnx2x_set_mac_one - configure a single MAC address
  1626. *
  1627. * @bp: driver handle
  1628. * @mac: MAC to configure
  1629. * @obj: MAC object handle
  1630. * @set: if 'true' add a new MAC, otherwise - delete
  1631. * @mac_type: the type of the MAC to configure (e.g. ETH, UC list)
  1632. * @ramrod_flags: RAMROD_XXX flags (e.g. RAMROD_CONT, RAMROD_COMP_WAIT)
  1633. *
  1634. * Configures one MAC according to provided parameters or continues the
  1635. * execution of previously scheduled commands if RAMROD_CONT is set in
  1636. * ramrod_flags.
  1637. *
  1638. * Returns zero if operation has successfully completed, a positive value if the
  1639. * operation has been successfully scheduled and a negative - if a requested
  1640. * operations has failed.
  1641. */
  1642. int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
  1643. struct bnx2x_vlan_mac_obj *obj, bool set,
  1644. int mac_type, unsigned long *ramrod_flags);
  1645. int bnx2x_set_vlan_one(struct bnx2x *bp, u16 vlan,
  1646. struct bnx2x_vlan_mac_obj *obj, bool set,
  1647. unsigned long *ramrod_flags);
  1648. /**
  1649. * bnx2x_del_all_macs - delete all MACs configured for the specific MAC object
  1650. *
  1651. * @bp: driver handle
  1652. * @mac_obj: MAC object handle
  1653. * @mac_type: type of the MACs to clear (BNX2X_XXX_MAC)
  1654. * @wait_for_comp: if 'true' block until completion
  1655. *
  1656. * Deletes all MACs of the specific type (e.g. ETH, UC list).
  1657. *
  1658. * Returns zero if operation has successfully completed, a positive value if the
  1659. * operation has been successfully scheduled and a negative - if a requested
  1660. * operations has failed.
  1661. */
  1662. int bnx2x_del_all_macs(struct bnx2x *bp,
  1663. struct bnx2x_vlan_mac_obj *mac_obj,
  1664. int mac_type, bool wait_for_comp);
  1665. /* Init Function API */
  1666. void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p);
  1667. void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
  1668. u8 vf_valid, int fw_sb_id, int igu_sb_id);
  1669. int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
  1670. int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
  1671. int bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode);
  1672. int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
  1673. void bnx2x_read_mf_cfg(struct bnx2x *bp);
  1674. int bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val);
  1675. /* dmae */
  1676. void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
  1677. void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
  1678. u32 len32);
  1679. void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
  1680. u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
  1681. u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
  1682. u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
  1683. bool with_comp, u8 comp_type);
  1684. void bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
  1685. u8 src_type, u8 dst_type);
  1686. int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
  1687. u32 *comp);
  1688. /* FLR related routines */
  1689. u32 bnx2x_flr_clnup_poll_count(struct bnx2x *bp);
  1690. void bnx2x_tx_hw_flushed(struct bnx2x *bp, u32 poll_count);
  1691. int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, u32 poll_cnt);
  1692. u8 bnx2x_is_pcie_pending(struct pci_dev *dev);
  1693. int bnx2x_flr_clnup_poll_hw_counter(struct bnx2x *bp, u32 reg,
  1694. char *msg, u32 poll_cnt);
  1695. void bnx2x_calc_fc_adv(struct bnx2x *bp);
  1696. int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
  1697. u32 data_hi, u32 data_lo, int cmd_type);
  1698. void bnx2x_update_coalesce(struct bnx2x *bp);
  1699. int bnx2x_get_cur_phy_idx(struct bnx2x *bp);
  1700. bool bnx2x_port_after_undi(struct bnx2x *bp);
  1701. static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
  1702. int wait)
  1703. {
  1704. u32 val;
  1705. do {
  1706. val = REG_RD(bp, reg);
  1707. if (val == expected)
  1708. break;
  1709. ms -= wait;
  1710. msleep(wait);
  1711. } while (ms > 0);
  1712. return val;
  1713. }
  1714. void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
  1715. bool is_pf);
  1716. #define BNX2X_ILT_ZALLOC(x, y, size) \
  1717. x = dma_zalloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL)
  1718. #define BNX2X_ILT_FREE(x, y, size) \
  1719. do { \
  1720. if (x) { \
  1721. dma_free_coherent(&bp->pdev->dev, size, x, y); \
  1722. x = NULL; \
  1723. y = 0; \
  1724. } \
  1725. } while (0)
  1726. #define ILOG2(x) (ilog2((x)))
  1727. #define ILT_NUM_PAGE_ENTRIES (3072)
  1728. /* In 57710/11 we use whole table since we have 8 func
  1729. * In 57712 we have only 4 func, but use same size per func, then only half of
  1730. * the table in use
  1731. */
  1732. #define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8)
  1733. #define FUNC_ILT_BASE(func) (func * ILT_PER_FUNC)
  1734. /*
  1735. * the phys address is shifted right 12 bits and has an added
  1736. * 1=valid bit added to the 53rd bit
  1737. * then since this is a wide register(TM)
  1738. * we split it into two 32 bit writes
  1739. */
  1740. #define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
  1741. #define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
  1742. /* load/unload mode */
  1743. #define LOAD_NORMAL 0
  1744. #define LOAD_OPEN 1
  1745. #define LOAD_DIAG 2
  1746. #define LOAD_LOOPBACK_EXT 3
  1747. #define UNLOAD_NORMAL 0
  1748. #define UNLOAD_CLOSE 1
  1749. #define UNLOAD_RECOVERY 2
  1750. /* DMAE command defines */
  1751. #define DMAE_TIMEOUT -1
  1752. #define DMAE_PCI_ERROR -2 /* E2 and onward */
  1753. #define DMAE_NOT_RDY -3
  1754. #define DMAE_PCI_ERR_FLAG 0x80000000
  1755. #define DMAE_SRC_PCI 0
  1756. #define DMAE_SRC_GRC 1
  1757. #define DMAE_DST_NONE 0
  1758. #define DMAE_DST_PCI 1
  1759. #define DMAE_DST_GRC 2
  1760. #define DMAE_COMP_PCI 0
  1761. #define DMAE_COMP_GRC 1
  1762. /* E2 and onward - PCI error handling in the completion */
  1763. #define DMAE_COMP_REGULAR 0
  1764. #define DMAE_COM_SET_ERR 1
  1765. #define DMAE_CMD_SRC_PCI (DMAE_SRC_PCI << \
  1766. DMAE_COMMAND_SRC_SHIFT)
  1767. #define DMAE_CMD_SRC_GRC (DMAE_SRC_GRC << \
  1768. DMAE_COMMAND_SRC_SHIFT)
  1769. #define DMAE_CMD_DST_PCI (DMAE_DST_PCI << \
  1770. DMAE_COMMAND_DST_SHIFT)
  1771. #define DMAE_CMD_DST_GRC (DMAE_DST_GRC << \
  1772. DMAE_COMMAND_DST_SHIFT)
  1773. #define DMAE_CMD_C_DST_PCI (DMAE_COMP_PCI << \
  1774. DMAE_COMMAND_C_DST_SHIFT)
  1775. #define DMAE_CMD_C_DST_GRC (DMAE_COMP_GRC << \
  1776. DMAE_COMMAND_C_DST_SHIFT)
  1777. #define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE
  1778. #define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1779. #define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1780. #define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1781. #define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT)
  1782. #define DMAE_CMD_PORT_0 0
  1783. #define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT
  1784. #define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET
  1785. #define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET
  1786. #define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT
  1787. #define DMAE_SRC_PF 0
  1788. #define DMAE_SRC_VF 1
  1789. #define DMAE_DST_PF 0
  1790. #define DMAE_DST_VF 1
  1791. #define DMAE_C_SRC 0
  1792. #define DMAE_C_DST 1
  1793. #define DMAE_LEN32_RD_MAX 0x80
  1794. #define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000)
  1795. #define DMAE_COMP_VAL 0x60d0d0ae /* E2 and on - upper bit
  1796. * indicates error
  1797. */
  1798. #define MAX_DMAE_C_PER_PORT 8
  1799. #define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
  1800. BP_VN(bp))
  1801. #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
  1802. E1HVN_MAX)
  1803. /* PCIE link and speed */
  1804. #define PCICFG_LINK_WIDTH 0x1f00000
  1805. #define PCICFG_LINK_WIDTH_SHIFT 20
  1806. #define PCICFG_LINK_SPEED 0xf0000
  1807. #define PCICFG_LINK_SPEED_SHIFT 16
  1808. #define BNX2X_NUM_TESTS_SF 7
  1809. #define BNX2X_NUM_TESTS_MF 3
  1810. #define BNX2X_NUM_TESTS(bp) (IS_MF(bp) ? BNX2X_NUM_TESTS_MF : \
  1811. IS_VF(bp) ? 0 : BNX2X_NUM_TESTS_SF)
  1812. #define BNX2X_PHY_LOOPBACK 0
  1813. #define BNX2X_MAC_LOOPBACK 1
  1814. #define BNX2X_EXT_LOOPBACK 2
  1815. #define BNX2X_PHY_LOOPBACK_FAILED 1
  1816. #define BNX2X_MAC_LOOPBACK_FAILED 2
  1817. #define BNX2X_EXT_LOOPBACK_FAILED 3
  1818. #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \
  1819. BNX2X_PHY_LOOPBACK_FAILED)
  1820. #define STROM_ASSERT_ARRAY_SIZE 50
  1821. /* must be used on a CID before placing it on a HW ring */
  1822. #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \
  1823. (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \
  1824. (x))
  1825. #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe))
  1826. #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1)
  1827. #define BNX2X_BTR 4
  1828. #define MAX_SPQ_PENDING 8
  1829. /* CMNG constants, as derived from system spec calculations */
  1830. /* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */
  1831. #define DEF_MIN_RATE 100
  1832. /* resolution of the rate shaping timer - 400 usec */
  1833. #define RS_PERIODIC_TIMEOUT_USEC 400
  1834. /* number of bytes in single QM arbitration cycle -
  1835. * coefficient for calculating the fairness timer */
  1836. #define QM_ARB_BYTES 160000
  1837. /* resolution of Min algorithm 1:100 */
  1838. #define MIN_RES 100
  1839. /* how many bytes above threshold for the minimal credit of Min algorithm*/
  1840. #define MIN_ABOVE_THRESH 32768
  1841. /* Fairness algorithm integration time coefficient -
  1842. * for calculating the actual Tfair */
  1843. #define T_FAIR_COEF ((MIN_ABOVE_THRESH + QM_ARB_BYTES) * 8 * MIN_RES)
  1844. /* Memory of fairness algorithm . 2 cycles */
  1845. #define FAIR_MEM 2
  1846. #define ATTN_NIG_FOR_FUNC (1L << 8)
  1847. #define ATTN_SW_TIMER_4_FUNC (1L << 9)
  1848. #define GPIO_2_FUNC (1L << 10)
  1849. #define GPIO_3_FUNC (1L << 11)
  1850. #define GPIO_4_FUNC (1L << 12)
  1851. #define ATTN_GENERAL_ATTN_1 (1L << 13)
  1852. #define ATTN_GENERAL_ATTN_2 (1L << 14)
  1853. #define ATTN_GENERAL_ATTN_3 (1L << 15)
  1854. #define ATTN_GENERAL_ATTN_4 (1L << 13)
  1855. #define ATTN_GENERAL_ATTN_5 (1L << 14)
  1856. #define ATTN_GENERAL_ATTN_6 (1L << 15)
  1857. #define ATTN_HARD_WIRED_MASK 0xff00
  1858. #define ATTENTION_ID 4
  1859. #define IS_MF_STORAGE_ONLY(bp) (IS_MF_STORAGE_PERSONALITY_ONLY(bp) || \
  1860. IS_MF_FCOE_AFEX(bp))
  1861. /* stuff added to make the code fit 80Col */
  1862. #define BNX2X_PMF_LINK_ASSERT \
  1863. GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
  1864. #define BNX2X_MC_ASSERT_BITS \
  1865. (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1866. GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1867. GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
  1868. GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
  1869. #define BNX2X_MCP_ASSERT \
  1870. GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
  1871. #define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
  1872. #define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
  1873. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
  1874. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
  1875. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
  1876. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
  1877. GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
  1878. #define HW_INTERRUT_ASSERT_SET_0 \
  1879. (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
  1880. AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
  1881. AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
  1882. AEU_INPUTS_ATTN_BITS_BRB_HW_INTERRUPT | \
  1883. AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT)
  1884. #define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
  1885. AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
  1886. AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
  1887. AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
  1888. AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\
  1889. AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\
  1890. AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR)
  1891. #define HW_INTERRUT_ASSERT_SET_1 \
  1892. (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
  1893. AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
  1894. AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
  1895. AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
  1896. AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
  1897. AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
  1898. AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
  1899. AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
  1900. AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
  1901. AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
  1902. AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
  1903. #define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\
  1904. AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
  1905. AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\
  1906. AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
  1907. AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\
  1908. AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
  1909. AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
  1910. AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\
  1911. AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
  1912. AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
  1913. AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
  1914. AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\
  1915. AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
  1916. AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
  1917. AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\
  1918. AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR)
  1919. #define HW_INTERRUT_ASSERT_SET_2 \
  1920. (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
  1921. AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
  1922. AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
  1923. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
  1924. AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
  1925. #define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
  1926. AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
  1927. AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
  1928. AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
  1929. AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
  1930. AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\
  1931. AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
  1932. AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
  1933. #define HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD \
  1934. (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
  1935. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
  1936. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY)
  1937. #define HW_PRTY_ASSERT_SET_3 (HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD | \
  1938. AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
  1939. #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \
  1940. AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)
  1941. #define MULTI_MASK 0x7f
  1942. #define DEF_USB_FUNC_OFF offsetof(struct cstorm_def_status_block_u, func)
  1943. #define DEF_CSB_FUNC_OFF offsetof(struct cstorm_def_status_block_c, func)
  1944. #define DEF_XSB_FUNC_OFF offsetof(struct xstorm_def_status_block, func)
  1945. #define DEF_TSB_FUNC_OFF offsetof(struct tstorm_def_status_block, func)
  1946. #define DEF_USB_IGU_INDEX_OFF \
  1947. offsetof(struct cstorm_def_status_block_u, igu_index)
  1948. #define DEF_CSB_IGU_INDEX_OFF \
  1949. offsetof(struct cstorm_def_status_block_c, igu_index)
  1950. #define DEF_XSB_IGU_INDEX_OFF \
  1951. offsetof(struct xstorm_def_status_block, igu_index)
  1952. #define DEF_TSB_IGU_INDEX_OFF \
  1953. offsetof(struct tstorm_def_status_block, igu_index)
  1954. #define DEF_USB_SEGMENT_OFF \
  1955. offsetof(struct cstorm_def_status_block_u, segment)
  1956. #define DEF_CSB_SEGMENT_OFF \
  1957. offsetof(struct cstorm_def_status_block_c, segment)
  1958. #define DEF_XSB_SEGMENT_OFF \
  1959. offsetof(struct xstorm_def_status_block, segment)
  1960. #define DEF_TSB_SEGMENT_OFF \
  1961. offsetof(struct tstorm_def_status_block, segment)
  1962. #define BNX2X_SP_DSB_INDEX \
  1963. (&bp->def_status_blk->sp_sb.\
  1964. index_values[HC_SP_INDEX_ETH_DEF_CONS])
  1965. #define CAM_IS_INVALID(x) \
  1966. (GET_FLAG(x.flags, \
  1967. MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
  1968. (T_ETH_MAC_COMMAND_INVALIDATE))
  1969. /* Number of u32 elements in MC hash array */
  1970. #define MC_HASH_SIZE 8
  1971. #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \
  1972. TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
  1973. #ifndef PXP2_REG_PXP2_INT_STS
  1974. #define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0
  1975. #endif
  1976. #ifndef ETH_MAX_RX_CLIENTS_E2
  1977. #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
  1978. #endif
  1979. #define BNX2X_VPD_LEN 128
  1980. #define VENDOR_ID_LEN 4
  1981. #define VF_ACQUIRE_THRESH 3
  1982. #define VF_ACQUIRE_MAC_FILTERS 1
  1983. #define VF_ACQUIRE_MC_FILTERS 10
  1984. #define VF_ACQUIRE_VLAN_FILTERS 2 /* VLAN0 + 'real' VLAN */
  1985. #define GOOD_ME_REG(me_reg) (((me_reg) & ME_REG_VF_VALID) && \
  1986. (!((me_reg) & ME_REG_VF_ERR)))
  1987. int bnx2x_compare_fw_ver(struct bnx2x *bp, u32 load_code, bool print_err);
  1988. /* Congestion management fairness mode */
  1989. #define CMNG_FNS_NONE 0
  1990. #define CMNG_FNS_MINMAX 1
  1991. #define HC_SEG_ACCESS_DEF 0 /*Driver decision 0-3*/
  1992. #define HC_SEG_ACCESS_ATTN 4
  1993. #define HC_SEG_ACCESS_NORM 0 /*Driver decision 0-1*/
  1994. static const u32 dmae_reg_go_c[] = {
  1995. DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
  1996. DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
  1997. DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
  1998. DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
  1999. };
  2000. void bnx2x_set_ethtool_ops(struct bnx2x *bp, struct net_device *netdev);
  2001. void bnx2x_notify_link_changed(struct bnx2x *bp);
  2002. #define BNX2X_MF_SD_PROTOCOL(bp) \
  2003. ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
  2004. #define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
  2005. (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
  2006. #define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \
  2007. (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE)
  2008. #define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp))
  2009. #define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))
  2010. #define IS_MF_ISCSI_SI(bp) (IS_MF_SI(bp) && BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp))
  2011. #define IS_MF_ISCSI_ONLY(bp) (IS_MF_ISCSI_SD(bp) || IS_MF_ISCSI_SI(bp))
  2012. #define BNX2X_MF_EXT_PROTOCOL_MASK \
  2013. (MACP_FUNC_CFG_FLAGS_ETHERNET | \
  2014. MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD | \
  2015. MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
  2016. #define BNX2X_MF_EXT_PROT(bp) ((bp)->mf_ext_config & \
  2017. BNX2X_MF_EXT_PROTOCOL_MASK)
  2018. #define BNX2X_HAS_MF_EXT_PROTOCOL_FCOE(bp) \
  2019. (BNX2X_MF_EXT_PROT(bp) & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
  2020. #define BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp) \
  2021. (BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
  2022. #define BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp) \
  2023. (BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD)
  2024. #define IS_MF_FCOE_AFEX(bp) \
  2025. (IS_MF_AFEX(bp) && BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp))
  2026. #define IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp) \
  2027. (IS_MF_SD(bp) && \
  2028. (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \
  2029. BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
  2030. #define IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp) \
  2031. (IS_MF_SI(bp) && \
  2032. (BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp) || \
  2033. BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp)))
  2034. #define IS_MF_STORAGE_PERSONALITY_ONLY(bp) \
  2035. (IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp) || \
  2036. IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp))
  2037. /* Determines whether BW configuration arrives in 100Mb units or in
  2038. * percentages from actual physical link speed.
  2039. */
  2040. #define IS_MF_PERCENT_BW(bp) (IS_MF_SI(bp) || IS_MF_UFP(bp) || IS_MF_BD(bp))
  2041. #define SET_FLAG(value, mask, flag) \
  2042. do {\
  2043. (value) &= ~(mask);\
  2044. (value) |= ((flag) << (mask##_SHIFT));\
  2045. } while (0)
  2046. #define GET_FLAG(value, mask) \
  2047. (((value) & (mask)) >> (mask##_SHIFT))
  2048. #define GET_FIELD(value, fname) \
  2049. (((value) & (fname##_MASK)) >> (fname##_SHIFT))
  2050. enum {
  2051. SWITCH_UPDATE,
  2052. AFEX_UPDATE,
  2053. };
  2054. #define NUM_MACS 8
  2055. void bnx2x_set_local_cmng(struct bnx2x *bp);
  2056. void bnx2x_update_mng_version(struct bnx2x *bp);
  2057. void bnx2x_update_mfw_dump(struct bnx2x *bp);
  2058. #define MCPR_SCRATCH_BASE(bp) \
  2059. (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
  2060. #define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
  2061. void bnx2x_init_ptp(struct bnx2x *bp);
  2062. int bnx2x_configure_ptp_filters(struct bnx2x *bp);
  2063. void bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb);
  2064. #define BNX2X_MAX_PHC_DRIFT 31000000
  2065. #define BNX2X_PTP_TX_TIMEOUT
  2066. /* Re-configure all previously configured vlan filters.
  2067. * Meant for implicit re-load flows.
  2068. */
  2069. int bnx2x_vlan_reconfigure_vid(struct bnx2x *bp);
  2070. #endif /* bnx2x.h */