bnxt.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511
  1. /* Broadcom NetXtreme-C/E network driver.
  2. *
  3. * Copyright (c) 2014-2016 Broadcom Corporation
  4. * Copyright (c) 2016-2018 Broadcom Limited
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation.
  9. */
  10. #ifndef BNXT_H
  11. #define BNXT_H
  12. #define DRV_MODULE_NAME "bnxt_en"
  13. #define DRV_MODULE_VERSION "1.9.2"
  14. #define DRV_VER_MAJ 1
  15. #define DRV_VER_MIN 9
  16. #define DRV_VER_UPD 2
  17. #include <linux/interrupt.h>
  18. #include <linux/rhashtable.h>
  19. #include <net/devlink.h>
  20. #include <net/dst_metadata.h>
  21. #include <net/switchdev.h>
  22. #include <net/xdp.h>
  23. #include <linux/net_dim.h>
  24. struct tx_bd {
  25. __le32 tx_bd_len_flags_type;
  26. #define TX_BD_TYPE (0x3f << 0)
  27. #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0)
  28. #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0)
  29. #define TX_BD_FLAGS_PACKET_END (1 << 6)
  30. #define TX_BD_FLAGS_NO_CMPL (1 << 7)
  31. #define TX_BD_FLAGS_BD_CNT (0x1f << 8)
  32. #define TX_BD_FLAGS_BD_CNT_SHIFT 8
  33. #define TX_BD_FLAGS_LHINT (3 << 13)
  34. #define TX_BD_FLAGS_LHINT_SHIFT 13
  35. #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13)
  36. #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13)
  37. #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13)
  38. #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13)
  39. #define TX_BD_FLAGS_COAL_NOW (1 << 15)
  40. #define TX_BD_LEN (0xffff << 16)
  41. #define TX_BD_LEN_SHIFT 16
  42. u32 tx_bd_opaque;
  43. __le64 tx_bd_haddr;
  44. } __packed;
  45. struct tx_bd_ext {
  46. __le32 tx_bd_hsize_lflags;
  47. #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)
  48. #define TX_BD_FLAGS_IP_CKSUM (1 << 1)
  49. #define TX_BD_FLAGS_NO_CRC (1 << 2)
  50. #define TX_BD_FLAGS_STAMP (1 << 3)
  51. #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4)
  52. #define TX_BD_FLAGS_LSO (1 << 5)
  53. #define TX_BD_FLAGS_IPID_FMT (1 << 6)
  54. #define TX_BD_FLAGS_T_IPID (1 << 7)
  55. #define TX_BD_HSIZE (0xff << 16)
  56. #define TX_BD_HSIZE_SHIFT 16
  57. __le32 tx_bd_mss;
  58. __le32 tx_bd_cfa_action;
  59. #define TX_BD_CFA_ACTION (0xffff << 16)
  60. #define TX_BD_CFA_ACTION_SHIFT 16
  61. __le32 tx_bd_cfa_meta;
  62. #define TX_BD_CFA_META_MASK 0xfffffff
  63. #define TX_BD_CFA_META_VID_MASK 0xfff
  64. #define TX_BD_CFA_META_PRI_MASK (0xf << 12)
  65. #define TX_BD_CFA_META_PRI_SHIFT 12
  66. #define TX_BD_CFA_META_TPID_MASK (3 << 16)
  67. #define TX_BD_CFA_META_TPID_SHIFT 16
  68. #define TX_BD_CFA_META_KEY (0xf << 28)
  69. #define TX_BD_CFA_META_KEY_SHIFT 28
  70. #define TX_BD_CFA_META_KEY_VLAN (1 << 28)
  71. };
  72. struct rx_bd {
  73. __le32 rx_bd_len_flags_type;
  74. #define RX_BD_TYPE (0x3f << 0)
  75. #define RX_BD_TYPE_RX_PACKET_BD 0x4
  76. #define RX_BD_TYPE_RX_BUFFER_BD 0x5
  77. #define RX_BD_TYPE_RX_AGG_BD 0x6
  78. #define RX_BD_TYPE_16B_BD_SIZE (0 << 4)
  79. #define RX_BD_TYPE_32B_BD_SIZE (1 << 4)
  80. #define RX_BD_TYPE_48B_BD_SIZE (2 << 4)
  81. #define RX_BD_TYPE_64B_BD_SIZE (3 << 4)
  82. #define RX_BD_FLAGS_SOP (1 << 6)
  83. #define RX_BD_FLAGS_EOP (1 << 7)
  84. #define RX_BD_FLAGS_BUFFERS (3 << 8)
  85. #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8)
  86. #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8)
  87. #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8)
  88. #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8)
  89. #define RX_BD_LEN (0xffff << 16)
  90. #define RX_BD_LEN_SHIFT 16
  91. u32 rx_bd_opaque;
  92. __le64 rx_bd_haddr;
  93. };
  94. struct tx_cmp {
  95. __le32 tx_cmp_flags_type;
  96. #define CMP_TYPE (0x3f << 0)
  97. #define CMP_TYPE_TX_L2_CMP 0
  98. #define CMP_TYPE_RX_L2_CMP 17
  99. #define CMP_TYPE_RX_AGG_CMP 18
  100. #define CMP_TYPE_RX_L2_TPA_START_CMP 19
  101. #define CMP_TYPE_RX_L2_TPA_END_CMP 21
  102. #define CMP_TYPE_STATUS_CMP 32
  103. #define CMP_TYPE_REMOTE_DRIVER_REQ 34
  104. #define CMP_TYPE_REMOTE_DRIVER_RESP 36
  105. #define CMP_TYPE_ERROR_STATUS 48
  106. #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL
  107. #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL
  108. #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
  109. #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL
  110. #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL
  111. #define TX_CMP_FLAGS_ERROR (1 << 6)
  112. #define TX_CMP_FLAGS_PUSH (1 << 7)
  113. u32 tx_cmp_opaque;
  114. __le32 tx_cmp_errors_v;
  115. #define TX_CMP_V (1 << 0)
  116. #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1)
  117. #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0
  118. #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2
  119. #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4
  120. #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5
  121. #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4)
  122. #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5)
  123. #define TX_CMP_ERRORS_DMA_ERROR (1 << 6)
  124. #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7)
  125. __le32 tx_cmp_unsed_3;
  126. };
  127. struct rx_cmp {
  128. __le32 rx_cmp_len_flags_type;
  129. #define RX_CMP_CMP_TYPE (0x3f << 0)
  130. #define RX_CMP_FLAGS_ERROR (1 << 6)
  131. #define RX_CMP_FLAGS_PLACEMENT (7 << 7)
  132. #define RX_CMP_FLAGS_RSS_VALID (1 << 10)
  133. #define RX_CMP_FLAGS_UNUSED (1 << 11)
  134. #define RX_CMP_FLAGS_ITYPES_SHIFT 12
  135. #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
  136. #define RX_CMP_FLAGS_ITYPE_IP (1 << 12)
  137. #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12)
  138. #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)
  139. #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)
  140. #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12)
  141. #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)
  142. #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)
  143. #define RX_CMP_LEN (0xffff << 16)
  144. #define RX_CMP_LEN_SHIFT 16
  145. u32 rx_cmp_opaque;
  146. __le32 rx_cmp_misc_v1;
  147. #define RX_CMP_V1 (1 << 0)
  148. #define RX_CMP_AGG_BUFS (0x1f << 1)
  149. #define RX_CMP_AGG_BUFS_SHIFT 1
  150. #define RX_CMP_RSS_HASH_TYPE (0x7f << 9)
  151. #define RX_CMP_RSS_HASH_TYPE_SHIFT 9
  152. #define RX_CMP_PAYLOAD_OFFSET (0xff << 16)
  153. #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16
  154. __le32 rx_cmp_rss_hash;
  155. };
  156. #define RX_CMP_HASH_VALID(rxcmp) \
  157. ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
  158. #define RSS_PROFILE_ID_MASK 0x1f
  159. #define RX_CMP_HASH_TYPE(rxcmp) \
  160. (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
  161. RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
  162. struct rx_cmp_ext {
  163. __le32 rx_cmp_flags2;
  164. #define RX_CMP_FLAGS2_IP_CS_CALC 0x1
  165. #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
  166. #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
  167. #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
  168. #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4)
  169. __le32 rx_cmp_meta_data;
  170. #define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff
  171. #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
  172. #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000
  173. #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16
  174. __le32 rx_cmp_cfa_code_errors_v2;
  175. #define RX_CMP_V (1 << 0)
  176. #define RX_CMPL_ERRORS_MASK (0x7fff << 1)
  177. #define RX_CMPL_ERRORS_SFT 1
  178. #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1)
  179. #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
  180. #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1)
  181. #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1)
  182. #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
  183. #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4)
  184. #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5)
  185. #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6)
  186. #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7)
  187. #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8)
  188. #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9)
  189. #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9)
  190. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9)
  191. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9)
  192. #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9)
  193. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9)
  194. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9)
  195. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9)
  196. #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12)
  197. #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12)
  198. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12)
  199. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12)
  200. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12)
  201. #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12)
  202. #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12)
  203. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12)
  204. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12)
  205. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12)
  206. #define RX_CMPL_CFA_CODE_MASK (0xffff << 16)
  207. #define RX_CMPL_CFA_CODE_SFT 16
  208. __le32 rx_cmp_unused3;
  209. };
  210. #define RX_CMP_L2_ERRORS \
  211. cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR)
  212. #define RX_CMP_L4_CS_BITS \
  213. (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC))
  214. #define RX_CMP_L4_CS_ERR_BITS \
  215. (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR))
  216. #define RX_CMP_L4_CS_OK(rxcmp1) \
  217. (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \
  218. !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS))
  219. #define RX_CMP_ENCAP(rxcmp1) \
  220. ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \
  221. RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3)
  222. #define RX_CMP_CFA_CODE(rxcmpl1) \
  223. ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \
  224. RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT)
  225. struct rx_agg_cmp {
  226. __le32 rx_agg_cmp_len_flags_type;
  227. #define RX_AGG_CMP_TYPE (0x3f << 0)
  228. #define RX_AGG_CMP_LEN (0xffff << 16)
  229. #define RX_AGG_CMP_LEN_SHIFT 16
  230. u32 rx_agg_cmp_opaque;
  231. __le32 rx_agg_cmp_v;
  232. #define RX_AGG_CMP_V (1 << 0)
  233. __le32 rx_agg_cmp_unused;
  234. };
  235. struct rx_tpa_start_cmp {
  236. __le32 rx_tpa_start_cmp_len_flags_type;
  237. #define RX_TPA_START_CMP_TYPE (0x3f << 0)
  238. #define RX_TPA_START_CMP_FLAGS (0x3ff << 6)
  239. #define RX_TPA_START_CMP_FLAGS_SHIFT 6
  240. #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7)
  241. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7
  242. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
  243. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
  244. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
  245. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
  246. #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10)
  247. #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12)
  248. #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12
  249. #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
  250. #define RX_TPA_START_CMP_LEN (0xffff << 16)
  251. #define RX_TPA_START_CMP_LEN_SHIFT 16
  252. u32 rx_tpa_start_cmp_opaque;
  253. __le32 rx_tpa_start_cmp_misc_v1;
  254. #define RX_TPA_START_CMP_V1 (0x1 << 0)
  255. #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9)
  256. #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9
  257. #define RX_TPA_START_CMP_AGG_ID (0x7f << 25)
  258. #define RX_TPA_START_CMP_AGG_ID_SHIFT 25
  259. __le32 rx_tpa_start_cmp_rss_hash;
  260. };
  261. #define TPA_START_HASH_VALID(rx_tpa_start) \
  262. ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \
  263. cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
  264. #define TPA_START_HASH_TYPE(rx_tpa_start) \
  265. (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
  266. RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
  267. RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
  268. #define TPA_START_AGG_ID(rx_tpa_start) \
  269. ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
  270. RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT)
  271. struct rx_tpa_start_cmp_ext {
  272. __le32 rx_tpa_start_cmp_flags2;
  273. #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0)
  274. #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
  275. #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
  276. #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
  277. #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8)
  278. __le32 rx_tpa_start_cmp_metadata;
  279. __le32 rx_tpa_start_cmp_cfa_code_v2;
  280. #define RX_TPA_START_CMP_V2 (0x1 << 0)
  281. #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16)
  282. #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16
  283. __le32 rx_tpa_start_cmp_hdr_info;
  284. };
  285. #define TPA_START_CFA_CODE(rx_tpa_start) \
  286. ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \
  287. RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT)
  288. #define TPA_START_IS_IPV6(rx_tpa_start) \
  289. (!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 & \
  290. cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE)))
  291. struct rx_tpa_end_cmp {
  292. __le32 rx_tpa_end_cmp_len_flags_type;
  293. #define RX_TPA_END_CMP_TYPE (0x3f << 0)
  294. #define RX_TPA_END_CMP_FLAGS (0x3ff << 6)
  295. #define RX_TPA_END_CMP_FLAGS_SHIFT 6
  296. #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7)
  297. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7
  298. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
  299. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
  300. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
  301. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
  302. #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10)
  303. #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12)
  304. #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12
  305. #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
  306. #define RX_TPA_END_CMP_LEN (0xffff << 16)
  307. #define RX_TPA_END_CMP_LEN_SHIFT 16
  308. u32 rx_tpa_end_cmp_opaque;
  309. __le32 rx_tpa_end_cmp_misc_v1;
  310. #define RX_TPA_END_CMP_V1 (0x1 << 0)
  311. #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1)
  312. #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1
  313. #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8)
  314. #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8
  315. #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16)
  316. #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16
  317. #define RX_TPA_END_CMP_AGG_ID (0x7f << 25)
  318. #define RX_TPA_END_CMP_AGG_ID_SHIFT 25
  319. __le32 rx_tpa_end_cmp_tsdelta;
  320. #define RX_TPA_END_GRO_TS (0x1 << 31)
  321. };
  322. #define TPA_END_AGG_ID(rx_tpa_end) \
  323. ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
  324. RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT)
  325. #define TPA_END_TPA_SEGS(rx_tpa_end) \
  326. ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
  327. RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
  328. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \
  329. cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \
  330. RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS)
  331. #define TPA_END_GRO(rx_tpa_end) \
  332. ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \
  333. RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO)
  334. #define TPA_END_GRO_TS(rx_tpa_end) \
  335. (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \
  336. cpu_to_le32(RX_TPA_END_GRO_TS)))
  337. struct rx_tpa_end_cmp_ext {
  338. __le32 rx_tpa_end_cmp_dup_acks;
  339. #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0)
  340. __le32 rx_tpa_end_cmp_seg_len;
  341. #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0)
  342. __le32 rx_tpa_end_cmp_errors_v2;
  343. #define RX_TPA_END_CMP_V2 (0x1 << 0)
  344. #define RX_TPA_END_CMP_ERRORS (0x3 << 1)
  345. #define RX_TPA_END_CMPL_ERRORS_SHIFT 1
  346. u32 rx_tpa_end_cmp_start_opaque;
  347. };
  348. #define TPA_END_ERRORS(rx_tpa_end_ext) \
  349. ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \
  350. cpu_to_le32(RX_TPA_END_CMP_ERRORS))
  351. #define DB_IDX_MASK 0xffffff
  352. #define DB_IDX_VALID (0x1 << 26)
  353. #define DB_IRQ_DIS (0x1 << 27)
  354. #define DB_KEY_TX (0x0 << 28)
  355. #define DB_KEY_RX (0x1 << 28)
  356. #define DB_KEY_CP (0x2 << 28)
  357. #define DB_KEY_ST (0x3 << 28)
  358. #define DB_KEY_TX_PUSH (0x4 << 28)
  359. #define DB_LONG_TX_PUSH (0x2 << 24)
  360. #define BNXT_MIN_ROCE_CP_RINGS 2
  361. #define BNXT_MIN_ROCE_STAT_CTXS 1
  362. #define INVALID_HW_RING_ID ((u16)-1)
  363. /* The hardware supports certain page sizes. Use the supported page sizes
  364. * to allocate the rings.
  365. */
  366. #if (PAGE_SHIFT < 12)
  367. #define BNXT_PAGE_SHIFT 12
  368. #elif (PAGE_SHIFT <= 13)
  369. #define BNXT_PAGE_SHIFT PAGE_SHIFT
  370. #elif (PAGE_SHIFT < 16)
  371. #define BNXT_PAGE_SHIFT 13
  372. #else
  373. #define BNXT_PAGE_SHIFT 16
  374. #endif
  375. #define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT)
  376. /* The RXBD length is 16-bit so we can only support page sizes < 64K */
  377. #if (PAGE_SHIFT > 15)
  378. #define BNXT_RX_PAGE_SHIFT 15
  379. #else
  380. #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT
  381. #endif
  382. #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
  383. #define BNXT_MAX_MTU 9500
  384. #define BNXT_MAX_PAGE_MODE_MTU \
  385. ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \
  386. XDP_PACKET_HEADROOM)
  387. #define BNXT_MIN_PKT_SIZE 52
  388. #define BNXT_DEFAULT_RX_RING_SIZE 511
  389. #define BNXT_DEFAULT_TX_RING_SIZE 511
  390. #define MAX_TPA 64
  391. #if (BNXT_PAGE_SHIFT == 16)
  392. #define MAX_RX_PAGES 1
  393. #define MAX_RX_AGG_PAGES 4
  394. #define MAX_TX_PAGES 1
  395. #define MAX_CP_PAGES 8
  396. #else
  397. #define MAX_RX_PAGES 8
  398. #define MAX_RX_AGG_PAGES 32
  399. #define MAX_TX_PAGES 8
  400. #define MAX_CP_PAGES 64
  401. #endif
  402. #define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd))
  403. #define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd))
  404. #define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp))
  405. #define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT)
  406. #define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
  407. #define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT)
  408. #define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT)
  409. #define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
  410. #define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT)
  411. #define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1)
  412. #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
  413. #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1)
  414. #define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  415. #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1))
  416. #define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  417. #define TX_IDX(x) ((x) & (TX_DESC_CNT - 1))
  418. #define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  419. #define CP_IDX(x) ((x) & (CP_DESC_CNT - 1))
  420. #define TX_CMP_VALID(txcmp, raw_cons) \
  421. (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \
  422. !((raw_cons) & bp->cp_bit))
  423. #define RX_CMP_VALID(rxcmp1, raw_cons) \
  424. (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
  425. !((raw_cons) & bp->cp_bit))
  426. #define RX_AGG_CMP_VALID(agg, raw_cons) \
  427. (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \
  428. !((raw_cons) & bp->cp_bit))
  429. #define TX_CMP_TYPE(txcmp) \
  430. (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
  431. #define RX_CMP_TYPE(rxcmp) \
  432. (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE)
  433. #define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask)
  434. #define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask)
  435. #define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask)
  436. #define ADV_RAW_CMP(idx, n) ((idx) + (n))
  437. #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
  438. #define RING_CMP(idx) ((idx) & bp->cp_ring_mask)
  439. #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
  440. #define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
  441. #define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input)
  442. #define DFLT_HWRM_CMD_TIMEOUT 500
  443. #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
  444. #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
  445. #define HWRM_COREDUMP_TIMEOUT ((HWRM_CMD_TIMEOUT) * 12)
  446. #define HWRM_RESP_ERR_CODE_MASK 0xffff
  447. #define HWRM_RESP_LEN_OFFSET 4
  448. #define HWRM_RESP_LEN_MASK 0xffff0000
  449. #define HWRM_RESP_LEN_SFT 16
  450. #define HWRM_RESP_VALID_MASK 0xff000000
  451. #define HWRM_SEQ_ID_INVALID -1
  452. #define BNXT_HWRM_REQ_MAX_SIZE 128
  453. #define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
  454. BNXT_HWRM_REQ_MAX_SIZE)
  455. #define HWRM_SHORT_MIN_TIMEOUT 3
  456. #define HWRM_SHORT_MAX_TIMEOUT 10
  457. #define HWRM_SHORT_TIMEOUT_COUNTER 5
  458. #define HWRM_MIN_TIMEOUT 25
  459. #define HWRM_MAX_TIMEOUT 40
  460. #define HWRM_TOTAL_TIMEOUT(n) (((n) <= HWRM_SHORT_TIMEOUT_COUNTER) ? \
  461. ((n) * HWRM_SHORT_MIN_TIMEOUT) : \
  462. (HWRM_SHORT_TIMEOUT_COUNTER * HWRM_SHORT_MIN_TIMEOUT + \
  463. ((n) - HWRM_SHORT_TIMEOUT_COUNTER) * HWRM_MIN_TIMEOUT))
  464. #define HWRM_VALID_BIT_DELAY_USEC 150
  465. #define BNXT_RX_EVENT 1
  466. #define BNXT_AGG_EVENT 2
  467. #define BNXT_TX_EVENT 4
  468. struct bnxt_sw_tx_bd {
  469. struct sk_buff *skb;
  470. DEFINE_DMA_UNMAP_ADDR(mapping);
  471. u8 is_gso;
  472. u8 is_push;
  473. union {
  474. unsigned short nr_frags;
  475. u16 rx_prod;
  476. };
  477. };
  478. struct bnxt_sw_rx_bd {
  479. void *data;
  480. u8 *data_ptr;
  481. dma_addr_t mapping;
  482. };
  483. struct bnxt_sw_rx_agg_bd {
  484. struct page *page;
  485. unsigned int offset;
  486. dma_addr_t mapping;
  487. };
  488. struct bnxt_ring_struct {
  489. int nr_pages;
  490. int page_size;
  491. void **pg_arr;
  492. dma_addr_t *dma_arr;
  493. __le64 *pg_tbl;
  494. dma_addr_t pg_tbl_map;
  495. int vmem_size;
  496. void **vmem;
  497. u16 fw_ring_id; /* Ring id filled by Chimp FW */
  498. union {
  499. u16 grp_idx;
  500. u16 map_idx; /* Used by cmpl rings */
  501. };
  502. u8 queue_id;
  503. };
  504. struct tx_push_bd {
  505. __le32 doorbell;
  506. __le32 tx_bd_len_flags_type;
  507. u32 tx_bd_opaque;
  508. struct tx_bd_ext txbd2;
  509. };
  510. struct tx_push_buffer {
  511. struct tx_push_bd push_bd;
  512. u32 data[25];
  513. };
  514. struct bnxt_tx_ring_info {
  515. struct bnxt_napi *bnapi;
  516. u16 tx_prod;
  517. u16 tx_cons;
  518. u16 txq_index;
  519. void __iomem *tx_doorbell;
  520. struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
  521. struct bnxt_sw_tx_bd *tx_buf_ring;
  522. dma_addr_t tx_desc_mapping[MAX_TX_PAGES];
  523. struct tx_push_buffer *tx_push;
  524. dma_addr_t tx_push_mapping;
  525. __le64 data_mapping;
  526. #define BNXT_DEV_STATE_CLOSING 0x1
  527. u32 dev_state;
  528. struct bnxt_ring_struct tx_ring_struct;
  529. };
  530. struct bnxt_coal {
  531. u16 coal_ticks;
  532. u16 coal_ticks_irq;
  533. u16 coal_bufs;
  534. u16 coal_bufs_irq;
  535. /* RING_IDLE enabled when coal ticks < idle_thresh */
  536. u16 idle_thresh;
  537. u8 bufs_per_record;
  538. u8 budget;
  539. };
  540. struct bnxt_tpa_info {
  541. void *data;
  542. u8 *data_ptr;
  543. dma_addr_t mapping;
  544. u16 len;
  545. unsigned short gso_type;
  546. u32 flags2;
  547. u32 metadata;
  548. enum pkt_hash_types hash_type;
  549. u32 rss_hash;
  550. u32 hdr_info;
  551. #define BNXT_TPA_L4_SIZE(hdr_info) \
  552. (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32)
  553. #define BNXT_TPA_INNER_L3_OFF(hdr_info) \
  554. (((hdr_info) >> 18) & 0x1ff)
  555. #define BNXT_TPA_INNER_L2_OFF(hdr_info) \
  556. (((hdr_info) >> 9) & 0x1ff)
  557. #define BNXT_TPA_OUTER_L3_OFF(hdr_info) \
  558. ((hdr_info) & 0x1ff)
  559. u16 cfa_code; /* cfa_code in TPA start compl */
  560. };
  561. struct bnxt_rx_ring_info {
  562. struct bnxt_napi *bnapi;
  563. u16 rx_prod;
  564. u16 rx_agg_prod;
  565. u16 rx_sw_agg_prod;
  566. u16 rx_next_cons;
  567. void __iomem *rx_doorbell;
  568. void __iomem *rx_agg_doorbell;
  569. struct bpf_prog *xdp_prog;
  570. struct rx_bd *rx_desc_ring[MAX_RX_PAGES];
  571. struct bnxt_sw_rx_bd *rx_buf_ring;
  572. struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES];
  573. struct bnxt_sw_rx_agg_bd *rx_agg_ring;
  574. unsigned long *rx_agg_bmap;
  575. u16 rx_agg_bmap_size;
  576. struct page *rx_page;
  577. unsigned int rx_page_offset;
  578. dma_addr_t rx_desc_mapping[MAX_RX_PAGES];
  579. dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES];
  580. struct bnxt_tpa_info *rx_tpa;
  581. struct bnxt_ring_struct rx_ring_struct;
  582. struct bnxt_ring_struct rx_agg_ring_struct;
  583. struct xdp_rxq_info xdp_rxq;
  584. };
  585. struct bnxt_cp_ring_info {
  586. u32 cp_raw_cons;
  587. void __iomem *cp_doorbell;
  588. struct bnxt_coal rx_ring_coal;
  589. u64 rx_packets;
  590. u64 rx_bytes;
  591. u64 event_ctr;
  592. struct net_dim dim;
  593. struct tx_cmp *cp_desc_ring[MAX_CP_PAGES];
  594. dma_addr_t cp_desc_mapping[MAX_CP_PAGES];
  595. struct ctx_hw_stats *hw_stats;
  596. dma_addr_t hw_stats_map;
  597. u32 hw_stats_ctx_id;
  598. u64 rx_l4_csum_errors;
  599. struct bnxt_ring_struct cp_ring_struct;
  600. };
  601. struct bnxt_napi {
  602. struct napi_struct napi;
  603. struct bnxt *bp;
  604. int index;
  605. struct bnxt_cp_ring_info cp_ring;
  606. struct bnxt_rx_ring_info *rx_ring;
  607. struct bnxt_tx_ring_info *tx_ring;
  608. void (*tx_int)(struct bnxt *, struct bnxt_napi *,
  609. int);
  610. u32 flags;
  611. #define BNXT_NAPI_FLAG_XDP 0x1
  612. bool in_reset;
  613. };
  614. struct bnxt_irq {
  615. irq_handler_t handler;
  616. unsigned int vector;
  617. u8 requested:1;
  618. u8 have_cpumask:1;
  619. char name[IFNAMSIZ + 2];
  620. cpumask_var_t cpu_mask;
  621. };
  622. #define HWRM_RING_ALLOC_TX 0x1
  623. #define HWRM_RING_ALLOC_RX 0x2
  624. #define HWRM_RING_ALLOC_AGG 0x4
  625. #define HWRM_RING_ALLOC_CMPL 0x8
  626. #define INVALID_STATS_CTX_ID -1
  627. struct bnxt_ring_grp_info {
  628. u16 fw_stats_ctx;
  629. u16 fw_grp_id;
  630. u16 rx_fw_ring_id;
  631. u16 agg_fw_ring_id;
  632. u16 cp_fw_ring_id;
  633. };
  634. struct bnxt_vnic_info {
  635. u16 fw_vnic_id; /* returned by Chimp during alloc */
  636. #define BNXT_MAX_CTX_PER_VNIC 2
  637. u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC];
  638. u16 fw_l2_ctx_id;
  639. #define BNXT_MAX_UC_ADDRS 4
  640. __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS];
  641. /* index 0 always dev_addr */
  642. u16 uc_filter_count;
  643. u8 *uc_list;
  644. u16 *fw_grp_ids;
  645. dma_addr_t rss_table_dma_addr;
  646. __le16 *rss_table;
  647. dma_addr_t rss_hash_key_dma_addr;
  648. u64 *rss_hash_key;
  649. u32 rx_mask;
  650. u8 *mc_list;
  651. int mc_list_size;
  652. int mc_list_count;
  653. dma_addr_t mc_list_mapping;
  654. #define BNXT_MAX_MC_ADDRS 16
  655. u32 flags;
  656. #define BNXT_VNIC_RSS_FLAG 1
  657. #define BNXT_VNIC_RFS_FLAG 2
  658. #define BNXT_VNIC_MCAST_FLAG 4
  659. #define BNXT_VNIC_UCAST_FLAG 8
  660. #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10
  661. };
  662. struct bnxt_hw_resc {
  663. u16 min_rsscos_ctxs;
  664. u16 max_rsscos_ctxs;
  665. u16 min_cp_rings;
  666. u16 max_cp_rings;
  667. u16 resv_cp_rings;
  668. u16 min_tx_rings;
  669. u16 max_tx_rings;
  670. u16 resv_tx_rings;
  671. u16 max_tx_sch_inputs;
  672. u16 min_rx_rings;
  673. u16 max_rx_rings;
  674. u16 resv_rx_rings;
  675. u16 min_hw_ring_grps;
  676. u16 max_hw_ring_grps;
  677. u16 resv_hw_ring_grps;
  678. u16 min_l2_ctxs;
  679. u16 max_l2_ctxs;
  680. u16 min_vnics;
  681. u16 max_vnics;
  682. u16 resv_vnics;
  683. u16 min_stat_ctxs;
  684. u16 max_stat_ctxs;
  685. u16 max_irqs;
  686. };
  687. #if defined(CONFIG_BNXT_SRIOV)
  688. struct bnxt_vf_info {
  689. u16 fw_fid;
  690. u8 mac_addr[ETH_ALEN]; /* PF assigned MAC Address */
  691. u8 vf_mac_addr[ETH_ALEN]; /* VF assigned MAC address, only
  692. * stored by PF.
  693. */
  694. u16 vlan;
  695. u32 flags;
  696. #define BNXT_VF_QOS 0x1
  697. #define BNXT_VF_SPOOFCHK 0x2
  698. #define BNXT_VF_LINK_FORCED 0x4
  699. #define BNXT_VF_LINK_UP 0x8
  700. #define BNXT_VF_TRUST 0x10
  701. u32 func_flags; /* func cfg flags */
  702. u32 min_tx_rate;
  703. u32 max_tx_rate;
  704. void *hwrm_cmd_req_addr;
  705. dma_addr_t hwrm_cmd_req_dma_addr;
  706. };
  707. #endif
  708. struct bnxt_pf_info {
  709. #define BNXT_FIRST_PF_FID 1
  710. #define BNXT_FIRST_VF_FID 128
  711. u16 fw_fid;
  712. u16 port_id;
  713. u8 mac_addr[ETH_ALEN];
  714. u32 first_vf_id;
  715. u16 active_vfs;
  716. u16 max_vfs;
  717. u32 max_encap_records;
  718. u32 max_decap_records;
  719. u32 max_tx_em_flows;
  720. u32 max_tx_wm_flows;
  721. u32 max_rx_em_flows;
  722. u32 max_rx_wm_flows;
  723. unsigned long *vf_event_bmap;
  724. u16 hwrm_cmd_req_pages;
  725. u8 vf_resv_strategy;
  726. #define BNXT_VF_RESV_STRATEGY_MAXIMAL 0
  727. #define BNXT_VF_RESV_STRATEGY_MINIMAL 1
  728. #define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC 2
  729. void *hwrm_cmd_req_addr[4];
  730. dma_addr_t hwrm_cmd_req_dma_addr[4];
  731. struct bnxt_vf_info *vf;
  732. };
  733. struct bnxt_ntuple_filter {
  734. struct hlist_node hash;
  735. u8 dst_mac_addr[ETH_ALEN];
  736. u8 src_mac_addr[ETH_ALEN];
  737. struct flow_keys fkeys;
  738. __le64 filter_id;
  739. u16 sw_id;
  740. u8 l2_fltr_idx;
  741. u16 rxq;
  742. u32 flow_id;
  743. unsigned long state;
  744. #define BNXT_FLTR_VALID 0
  745. #define BNXT_FLTR_UPDATE 1
  746. };
  747. struct bnxt_link_info {
  748. u8 phy_type;
  749. u8 media_type;
  750. u8 transceiver;
  751. u8 phy_addr;
  752. u8 phy_link_status;
  753. #define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK
  754. #define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL
  755. #define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK
  756. u8 wire_speed;
  757. u8 loop_back;
  758. u8 link_up;
  759. u8 duplex;
  760. #define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF
  761. #define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL
  762. u8 pause;
  763. #define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX
  764. #define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX
  765. #define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \
  766. PORT_PHY_QCFG_RESP_PAUSE_TX)
  767. u8 lp_pause;
  768. u8 auto_pause_setting;
  769. u8 force_pause_setting;
  770. u8 duplex_setting;
  771. u8 auto_mode;
  772. #define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \
  773. (mode) <= BNXT_LINK_AUTO_MSK)
  774. #define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE
  775. #define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
  776. #define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
  777. #define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
  778. #define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
  779. #define PHY_VER_LEN 3
  780. u8 phy_ver[PHY_VER_LEN];
  781. u16 link_speed;
  782. #define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB
  783. #define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB
  784. #define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB
  785. #define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB
  786. #define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB
  787. #define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB
  788. #define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB
  789. #define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB
  790. #define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB
  791. #define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB
  792. u16 support_speeds;
  793. u16 auto_link_speeds; /* fw adv setting */
  794. #define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB
  795. #define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB
  796. #define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB
  797. #define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB
  798. #define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB
  799. #define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB
  800. #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
  801. #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
  802. #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
  803. #define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB
  804. u16 support_auto_speeds;
  805. u16 lp_auto_link_speeds;
  806. u16 force_link_speed;
  807. u32 preemphasis;
  808. u8 module_status;
  809. u16 fec_cfg;
  810. #define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED
  811. #define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED
  812. #define BNXT_FEC_ENC_RS PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED
  813. /* copy of requested setting from ethtool cmd */
  814. u8 autoneg;
  815. #define BNXT_AUTONEG_SPEED 1
  816. #define BNXT_AUTONEG_FLOW_CTRL 2
  817. u8 req_duplex;
  818. u8 req_flow_ctrl;
  819. u16 req_link_speed;
  820. u16 advertising; /* user adv setting */
  821. bool force_link_chng;
  822. bool phy_retry;
  823. unsigned long phy_retry_expires;
  824. /* a copy of phy_qcfg output used to report link
  825. * info to VF
  826. */
  827. struct hwrm_port_phy_qcfg_output phy_qcfg_resp;
  828. };
  829. #define BNXT_MAX_QUEUE 8
  830. struct bnxt_queue_info {
  831. u8 queue_id;
  832. u8 queue_profile;
  833. };
  834. #define BNXT_MAX_LED 4
  835. struct bnxt_led_info {
  836. u8 led_id;
  837. u8 led_type;
  838. u8 led_group_id;
  839. u8 unused;
  840. __le16 led_state_caps;
  841. #define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \
  842. cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED))
  843. __le16 led_color_caps;
  844. };
  845. #define BNXT_MAX_TEST 8
  846. struct bnxt_test_info {
  847. u8 offline_mask;
  848. u8 flags;
  849. #define BNXT_TEST_FL_EXT_LPBK 0x1
  850. u16 timeout;
  851. char string[BNXT_MAX_TEST][ETH_GSTRING_LEN];
  852. };
  853. #define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400
  854. #define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
  855. #define BNXT_CAG_REG_BASE 0x300000
  856. struct bnxt_tc_flow_stats {
  857. u64 packets;
  858. u64 bytes;
  859. };
  860. struct bnxt_tc_info {
  861. bool enabled;
  862. /* hash table to store TC offloaded flows */
  863. struct rhashtable flow_table;
  864. struct rhashtable_params flow_ht_params;
  865. /* hash table to store L2 keys of TC flows */
  866. struct rhashtable l2_table;
  867. struct rhashtable_params l2_ht_params;
  868. /* hash table to store L2 keys for TC tunnel decap */
  869. struct rhashtable decap_l2_table;
  870. struct rhashtable_params decap_l2_ht_params;
  871. /* hash table to store tunnel decap entries */
  872. struct rhashtable decap_table;
  873. struct rhashtable_params decap_ht_params;
  874. /* hash table to store tunnel encap entries */
  875. struct rhashtable encap_table;
  876. struct rhashtable_params encap_ht_params;
  877. /* lock to atomically add/del an l2 node when a flow is
  878. * added or deleted.
  879. */
  880. struct mutex lock;
  881. /* Fields used for batching stats query */
  882. struct rhashtable_iter iter;
  883. #define BNXT_FLOW_STATS_BATCH_MAX 10
  884. struct bnxt_tc_stats_batch {
  885. void *flow_node;
  886. struct bnxt_tc_flow_stats hw_stats;
  887. } stats_batch[BNXT_FLOW_STATS_BATCH_MAX];
  888. /* Stat counter mask (width) */
  889. u64 bytes_mask;
  890. u64 packets_mask;
  891. };
  892. struct bnxt_vf_rep_stats {
  893. u64 packets;
  894. u64 bytes;
  895. u64 dropped;
  896. };
  897. struct bnxt_vf_rep {
  898. struct bnxt *bp;
  899. struct net_device *dev;
  900. struct metadata_dst *dst;
  901. u16 vf_idx;
  902. u16 tx_cfa_action;
  903. u16 rx_cfa_code;
  904. struct bnxt_vf_rep_stats rx_stats;
  905. struct bnxt_vf_rep_stats tx_stats;
  906. };
  907. struct bnxt {
  908. void __iomem *bar0;
  909. void __iomem *bar1;
  910. void __iomem *bar2;
  911. u32 reg_base;
  912. u16 chip_num;
  913. #define CHIP_NUM_57301 0x16c8
  914. #define CHIP_NUM_57302 0x16c9
  915. #define CHIP_NUM_57304 0x16ca
  916. #define CHIP_NUM_58700 0x16cd
  917. #define CHIP_NUM_57402 0x16d0
  918. #define CHIP_NUM_57404 0x16d1
  919. #define CHIP_NUM_57406 0x16d2
  920. #define CHIP_NUM_57407 0x16d5
  921. #define CHIP_NUM_57311 0x16ce
  922. #define CHIP_NUM_57312 0x16cf
  923. #define CHIP_NUM_57314 0x16df
  924. #define CHIP_NUM_57317 0x16e0
  925. #define CHIP_NUM_57412 0x16d6
  926. #define CHIP_NUM_57414 0x16d7
  927. #define CHIP_NUM_57416 0x16d8
  928. #define CHIP_NUM_57417 0x16d9
  929. #define CHIP_NUM_57412L 0x16da
  930. #define CHIP_NUM_57414L 0x16db
  931. #define CHIP_NUM_5745X 0xd730
  932. #define CHIP_NUM_58802 0xd802
  933. #define CHIP_NUM_58804 0xd804
  934. #define CHIP_NUM_58808 0xd808
  935. #define BNXT_CHIP_NUM_5730X(chip_num) \
  936. ((chip_num) >= CHIP_NUM_57301 && \
  937. (chip_num) <= CHIP_NUM_57304)
  938. #define BNXT_CHIP_NUM_5740X(chip_num) \
  939. (((chip_num) >= CHIP_NUM_57402 && \
  940. (chip_num) <= CHIP_NUM_57406) || \
  941. (chip_num) == CHIP_NUM_57407)
  942. #define BNXT_CHIP_NUM_5731X(chip_num) \
  943. ((chip_num) == CHIP_NUM_57311 || \
  944. (chip_num) == CHIP_NUM_57312 || \
  945. (chip_num) == CHIP_NUM_57314 || \
  946. (chip_num) == CHIP_NUM_57317)
  947. #define BNXT_CHIP_NUM_5741X(chip_num) \
  948. ((chip_num) >= CHIP_NUM_57412 && \
  949. (chip_num) <= CHIP_NUM_57414L)
  950. #define BNXT_CHIP_NUM_58700(chip_num) \
  951. ((chip_num) == CHIP_NUM_58700)
  952. #define BNXT_CHIP_NUM_5745X(chip_num) \
  953. ((chip_num) == CHIP_NUM_5745X)
  954. #define BNXT_CHIP_NUM_57X0X(chip_num) \
  955. (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num))
  956. #define BNXT_CHIP_NUM_57X1X(chip_num) \
  957. (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num))
  958. #define BNXT_CHIP_NUM_588XX(chip_num) \
  959. ((chip_num) == CHIP_NUM_58802 || \
  960. (chip_num) == CHIP_NUM_58804 || \
  961. (chip_num) == CHIP_NUM_58808)
  962. struct net_device *dev;
  963. struct pci_dev *pdev;
  964. atomic_t intr_sem;
  965. u32 flags;
  966. #define BNXT_FLAG_VF 0x2
  967. #define BNXT_FLAG_LRO 0x4
  968. #ifdef CONFIG_INET
  969. #define BNXT_FLAG_GRO 0x8
  970. #else
  971. /* Cannot support hardware GRO if CONFIG_INET is not set */
  972. #define BNXT_FLAG_GRO 0x0
  973. #endif
  974. #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO)
  975. #define BNXT_FLAG_JUMBO 0x10
  976. #define BNXT_FLAG_STRIP_VLAN 0x20
  977. #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
  978. BNXT_FLAG_LRO)
  979. #define BNXT_FLAG_USING_MSIX 0x40
  980. #define BNXT_FLAG_MSIX_CAP 0x80
  981. #define BNXT_FLAG_RFS 0x100
  982. #define BNXT_FLAG_SHARED_RINGS 0x200
  983. #define BNXT_FLAG_PORT_STATS 0x400
  984. #define BNXT_FLAG_UDP_RSS_CAP 0x800
  985. #define BNXT_FLAG_EEE_CAP 0x1000
  986. #define BNXT_FLAG_NEW_RSS_CAP 0x2000
  987. #define BNXT_FLAG_WOL_CAP 0x4000
  988. #define BNXT_FLAG_ROCEV1_CAP 0x8000
  989. #define BNXT_FLAG_ROCEV2_CAP 0x10000
  990. #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \
  991. BNXT_FLAG_ROCEV2_CAP)
  992. #define BNXT_FLAG_NO_AGG_RINGS 0x20000
  993. #define BNXT_FLAG_RX_PAGE_MODE 0x40000
  994. #define BNXT_FLAG_MULTI_HOST 0x100000
  995. #define BNXT_FLAG_DOUBLE_DB 0x400000
  996. #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000
  997. #define BNXT_FLAG_DIM 0x2000000
  998. #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000
  999. #define BNXT_FLAG_PORT_STATS_EXT 0x10000000
  1000. #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
  1001. BNXT_FLAG_RFS | \
  1002. BNXT_FLAG_STRIP_VLAN)
  1003. #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
  1004. #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
  1005. #define BNXT_NPAR(bp) ((bp)->port_partition_type)
  1006. #define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST)
  1007. #define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
  1008. #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
  1009. #define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)
  1010. /* Chip class phase 4 and later */
  1011. #define BNXT_CHIP_P4_PLUS(bp) \
  1012. (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \
  1013. BNXT_CHIP_NUM_5745X((bp)->chip_num) || \
  1014. BNXT_CHIP_NUM_588XX((bp)->chip_num) || \
  1015. (BNXT_CHIP_NUM_58700((bp)->chip_num) && \
  1016. !BNXT_CHIP_TYPE_NITRO_A0(bp)))
  1017. struct bnxt_en_dev *edev;
  1018. struct bnxt_en_dev * (*ulp_probe)(struct net_device *);
  1019. struct bnxt_napi **bnapi;
  1020. struct bnxt_rx_ring_info *rx_ring;
  1021. struct bnxt_tx_ring_info *tx_ring;
  1022. u16 *tx_ring_map;
  1023. struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int,
  1024. struct sk_buff *);
  1025. struct sk_buff * (*rx_skb_func)(struct bnxt *,
  1026. struct bnxt_rx_ring_info *,
  1027. u16, void *, u8 *, dma_addr_t,
  1028. unsigned int);
  1029. u32 rx_buf_size;
  1030. u32 rx_buf_use_size; /* useable size */
  1031. u16 rx_offset;
  1032. u16 rx_dma_offset;
  1033. enum dma_data_direction rx_dir;
  1034. u32 rx_ring_size;
  1035. u32 rx_agg_ring_size;
  1036. u32 rx_copy_thresh;
  1037. u32 rx_ring_mask;
  1038. u32 rx_agg_ring_mask;
  1039. int rx_nr_pages;
  1040. int rx_agg_nr_pages;
  1041. int rx_nr_rings;
  1042. int rsscos_nr_ctxs;
  1043. u32 tx_ring_size;
  1044. u32 tx_ring_mask;
  1045. int tx_nr_pages;
  1046. int tx_nr_rings;
  1047. int tx_nr_rings_per_tc;
  1048. int tx_nr_rings_xdp;
  1049. int tx_wake_thresh;
  1050. int tx_push_thresh;
  1051. int tx_push_size;
  1052. u32 cp_ring_size;
  1053. u32 cp_ring_mask;
  1054. u32 cp_bit;
  1055. int cp_nr_pages;
  1056. int cp_nr_rings;
  1057. int num_stat_ctxs;
  1058. /* grp_info indexed by completion ring index */
  1059. struct bnxt_ring_grp_info *grp_info;
  1060. struct bnxt_vnic_info *vnic_info;
  1061. int nr_vnics;
  1062. u32 rss_hash_cfg;
  1063. u16 max_mtu;
  1064. u8 max_tc;
  1065. u8 max_lltc; /* lossless TCs */
  1066. struct bnxt_queue_info q_info[BNXT_MAX_QUEUE];
  1067. u8 tc_to_qidx[BNXT_MAX_QUEUE];
  1068. unsigned int current_interval;
  1069. #define BNXT_TIMER_INTERVAL HZ
  1070. struct timer_list timer;
  1071. unsigned long state;
  1072. #define BNXT_STATE_OPEN 0
  1073. #define BNXT_STATE_IN_SP_TASK 1
  1074. #define BNXT_STATE_READ_STATS 2
  1075. struct bnxt_irq *irq_tbl;
  1076. int total_irqs;
  1077. u8 mac_addr[ETH_ALEN];
  1078. #ifdef CONFIG_BNXT_DCB
  1079. struct ieee_pfc *ieee_pfc;
  1080. struct ieee_ets *ieee_ets;
  1081. u8 dcbx_cap;
  1082. u8 default_pri;
  1083. u8 max_dscp_value;
  1084. #endif /* CONFIG_BNXT_DCB */
  1085. u32 msg_enable;
  1086. u32 fw_cap;
  1087. #define BNXT_FW_CAP_SHORT_CMD 0x00000001
  1088. #define BNXT_FW_CAP_LLDP_AGENT 0x00000002
  1089. #define BNXT_FW_CAP_DCBX_AGENT 0x00000004
  1090. #define BNXT_FW_CAP_NEW_RM 0x00000008
  1091. #define BNXT_FW_CAP_IF_CHANGE 0x00000010
  1092. #define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
  1093. u32 hwrm_spec_code;
  1094. u16 hwrm_cmd_seq;
  1095. u32 hwrm_intr_seq_id;
  1096. void *hwrm_short_cmd_req_addr;
  1097. dma_addr_t hwrm_short_cmd_req_dma_addr;
  1098. void *hwrm_cmd_resp_addr;
  1099. dma_addr_t hwrm_cmd_resp_dma_addr;
  1100. struct rtnl_link_stats64 net_stats_prev;
  1101. struct rx_port_stats *hw_rx_port_stats;
  1102. struct tx_port_stats *hw_tx_port_stats;
  1103. struct rx_port_stats_ext *hw_rx_port_stats_ext;
  1104. dma_addr_t hw_rx_port_stats_map;
  1105. dma_addr_t hw_tx_port_stats_map;
  1106. dma_addr_t hw_rx_port_stats_ext_map;
  1107. int hw_port_stats_size;
  1108. u16 hwrm_max_req_len;
  1109. int hwrm_cmd_timeout;
  1110. struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
  1111. struct hwrm_ver_get_output ver_resp;
  1112. #define FW_VER_STR_LEN 32
  1113. #define BC_HWRM_STR_LEN 21
  1114. #define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
  1115. char fw_ver_str[FW_VER_STR_LEN];
  1116. __be16 vxlan_port;
  1117. u8 vxlan_port_cnt;
  1118. __le16 vxlan_fw_dst_port_id;
  1119. __be16 nge_port;
  1120. u8 nge_port_cnt;
  1121. __le16 nge_fw_dst_port_id;
  1122. u8 port_partition_type;
  1123. u8 port_count;
  1124. u16 br_mode;
  1125. struct bnxt_coal rx_coal;
  1126. struct bnxt_coal tx_coal;
  1127. #define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
  1128. u32 stats_coal_ticks;
  1129. #define BNXT_DEF_STATS_COAL_TICKS 1000000
  1130. #define BNXT_MIN_STATS_COAL_TICKS 250000
  1131. #define BNXT_MAX_STATS_COAL_TICKS 1000000
  1132. struct work_struct sp_task;
  1133. unsigned long sp_event;
  1134. #define BNXT_RX_MASK_SP_EVENT 0
  1135. #define BNXT_RX_NTP_FLTR_SP_EVENT 1
  1136. #define BNXT_LINK_CHNG_SP_EVENT 2
  1137. #define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3
  1138. #define BNXT_VXLAN_ADD_PORT_SP_EVENT 4
  1139. #define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
  1140. #define BNXT_RESET_TASK_SP_EVENT 6
  1141. #define BNXT_RST_RING_SP_EVENT 7
  1142. #define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
  1143. #define BNXT_PERIODIC_STATS_SP_EVENT 9
  1144. #define BNXT_HWRM_PORT_MODULE_SP_EVENT 10
  1145. #define BNXT_RESET_TASK_SILENT_SP_EVENT 11
  1146. #define BNXT_GENEVE_ADD_PORT_SP_EVENT 12
  1147. #define BNXT_GENEVE_DEL_PORT_SP_EVENT 13
  1148. #define BNXT_LINK_SPEED_CHNG_SP_EVENT 14
  1149. #define BNXT_FLOW_STATS_SP_EVENT 15
  1150. #define BNXT_UPDATE_PHY_SP_EVENT 16
  1151. struct bnxt_hw_resc hw_resc;
  1152. struct bnxt_pf_info pf;
  1153. #ifdef CONFIG_BNXT_SRIOV
  1154. int nr_vfs;
  1155. struct bnxt_vf_info vf;
  1156. wait_queue_head_t sriov_cfg_wait;
  1157. bool sriov_cfg;
  1158. #define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000)
  1159. /* lock to protect VF-rep creation/cleanup via
  1160. * multiple paths such as ->sriov_configure() and
  1161. * devlink ->eswitch_mode_set()
  1162. */
  1163. struct mutex sriov_lock;
  1164. #endif
  1165. #define BNXT_NTP_FLTR_MAX_FLTR 4096
  1166. #define BNXT_NTP_FLTR_HASH_SIZE 512
  1167. #define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1)
  1168. struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE];
  1169. spinlock_t ntp_fltr_lock; /* for hash table add, del */
  1170. unsigned long *ntp_fltr_bmap;
  1171. int ntp_fltr_count;
  1172. /* To protect link related settings during link changes and
  1173. * ethtool settings changes.
  1174. */
  1175. struct mutex link_lock;
  1176. struct bnxt_link_info link_info;
  1177. struct ethtool_eee eee;
  1178. u32 lpi_tmr_lo;
  1179. u32 lpi_tmr_hi;
  1180. u8 num_tests;
  1181. struct bnxt_test_info *test_info;
  1182. u8 wol_filter_id;
  1183. u8 wol;
  1184. u8 num_leds;
  1185. struct bnxt_led_info leds[BNXT_MAX_LED];
  1186. struct bpf_prog *xdp_prog;
  1187. /* devlink interface and vf-rep structs */
  1188. struct devlink *dl;
  1189. enum devlink_eswitch_mode eswitch_mode;
  1190. struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */
  1191. u16 *cfa_code_map; /* cfa_code -> vf_idx map */
  1192. u8 switch_id[8];
  1193. struct bnxt_tc_info *tc_info;
  1194. struct dentry *debugfs_pdev;
  1195. struct dentry *debugfs_dim;
  1196. struct device *hwmon_dev;
  1197. };
  1198. #define BNXT_RX_STATS_OFFSET(counter) \
  1199. (offsetof(struct rx_port_stats, counter) / 8)
  1200. #define BNXT_TX_STATS_OFFSET(counter) \
  1201. ((offsetof(struct tx_port_stats, counter) + \
  1202. sizeof(struct rx_port_stats) + 512) / 8)
  1203. #define BNXT_RX_STATS_EXT_OFFSET(counter) \
  1204. (offsetof(struct rx_port_stats_ext, counter) / 8)
  1205. #define I2C_DEV_ADDR_A0 0xa0
  1206. #define I2C_DEV_ADDR_A2 0xa2
  1207. #define SFF_DIAG_SUPPORT_OFFSET 0x5c
  1208. #define SFF_MODULE_ID_SFP 0x3
  1209. #define SFF_MODULE_ID_QSFP 0xc
  1210. #define SFF_MODULE_ID_QSFP_PLUS 0xd
  1211. #define SFF_MODULE_ID_QSFP28 0x11
  1212. #define BNXT_MAX_PHY_I2C_RESP_SIZE 64
  1213. static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
  1214. {
  1215. /* Tell compiler to fetch tx indices from memory. */
  1216. barrier();
  1217. return bp->tx_ring_size -
  1218. ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask);
  1219. }
  1220. /* For TX and RX ring doorbells with no ordering guarantee*/
  1221. static inline void bnxt_db_write_relaxed(struct bnxt *bp, void __iomem *db,
  1222. u32 val)
  1223. {
  1224. writel_relaxed(val, db);
  1225. if (bp->flags & BNXT_FLAG_DOUBLE_DB)
  1226. writel_relaxed(val, db);
  1227. }
  1228. /* For TX and RX ring doorbells */
  1229. static inline void bnxt_db_write(struct bnxt *bp, void __iomem *db, u32 val)
  1230. {
  1231. writel(val, db);
  1232. if (bp->flags & BNXT_FLAG_DOUBLE_DB)
  1233. writel(val, db);
  1234. }
  1235. extern const u16 bnxt_lhint_arr[];
  1236. int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
  1237. u16 prod, gfp_t gfp);
  1238. void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data);
  1239. void bnxt_set_tpa_flags(struct bnxt *bp);
  1240. void bnxt_set_ring_params(struct bnxt *);
  1241. int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
  1242. void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
  1243. int _hwrm_send_message(struct bnxt *, void *, u32, int);
  1244. int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
  1245. int hwrm_send_message(struct bnxt *, void *, u32, int);
  1246. int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
  1247. int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
  1248. int bmap_size);
  1249. int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
  1250. int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
  1251. int bnxt_hwrm_set_coal(struct bnxt *);
  1252. unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
  1253. void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
  1254. unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
  1255. unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp);
  1256. int bnxt_get_avail_msix(struct bnxt *bp, int num);
  1257. int bnxt_reserve_rings(struct bnxt *bp);
  1258. void bnxt_tx_disable(struct bnxt *bp);
  1259. void bnxt_tx_enable(struct bnxt *bp);
  1260. int bnxt_hwrm_set_pause(struct bnxt *);
  1261. int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
  1262. int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
  1263. int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
  1264. int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);
  1265. int bnxt_hwrm_fw_set_time(struct bnxt *);
  1266. int bnxt_open_nic(struct bnxt *, bool, bool);
  1267. int bnxt_half_open_nic(struct bnxt *bp);
  1268. void bnxt_half_close_nic(struct bnxt *bp);
  1269. int bnxt_close_nic(struct bnxt *, bool, bool);
  1270. int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
  1271. int tx_xdp);
  1272. int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
  1273. int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
  1274. int bnxt_restore_pf_fw_resources(struct bnxt *bp);
  1275. int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr);
  1276. void bnxt_dim_work(struct work_struct *work);
  1277. int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
  1278. #endif