bnxt.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. /* Broadcom NetXtreme-C/E network driver.
  2. *
  3. * Copyright (c) 2014-2016 Broadcom Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. */
  9. #ifndef BNXT_H
  10. #define BNXT_H
  11. #define DRV_MODULE_NAME "bnxt_en"
  12. #define DRV_MODULE_VERSION "1.5.0"
  13. #define DRV_VER_MAJ 1
  14. #define DRV_VER_MIN 5
  15. #define DRV_VER_UPD 0
  16. struct tx_bd {
  17. __le32 tx_bd_len_flags_type;
  18. #define TX_BD_TYPE (0x3f << 0)
  19. #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0)
  20. #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0)
  21. #define TX_BD_FLAGS_PACKET_END (1 << 6)
  22. #define TX_BD_FLAGS_NO_CMPL (1 << 7)
  23. #define TX_BD_FLAGS_BD_CNT (0x1f << 8)
  24. #define TX_BD_FLAGS_BD_CNT_SHIFT 8
  25. #define TX_BD_FLAGS_LHINT (3 << 13)
  26. #define TX_BD_FLAGS_LHINT_SHIFT 13
  27. #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13)
  28. #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13)
  29. #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13)
  30. #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13)
  31. #define TX_BD_FLAGS_COAL_NOW (1 << 15)
  32. #define TX_BD_LEN (0xffff << 16)
  33. #define TX_BD_LEN_SHIFT 16
  34. u32 tx_bd_opaque;
  35. __le64 tx_bd_haddr;
  36. } __packed;
  37. struct tx_bd_ext {
  38. __le32 tx_bd_hsize_lflags;
  39. #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)
  40. #define TX_BD_FLAGS_IP_CKSUM (1 << 1)
  41. #define TX_BD_FLAGS_NO_CRC (1 << 2)
  42. #define TX_BD_FLAGS_STAMP (1 << 3)
  43. #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4)
  44. #define TX_BD_FLAGS_LSO (1 << 5)
  45. #define TX_BD_FLAGS_IPID_FMT (1 << 6)
  46. #define TX_BD_FLAGS_T_IPID (1 << 7)
  47. #define TX_BD_HSIZE (0xff << 16)
  48. #define TX_BD_HSIZE_SHIFT 16
  49. __le32 tx_bd_mss;
  50. __le32 tx_bd_cfa_action;
  51. #define TX_BD_CFA_ACTION (0xffff << 16)
  52. #define TX_BD_CFA_ACTION_SHIFT 16
  53. __le32 tx_bd_cfa_meta;
  54. #define TX_BD_CFA_META_MASK 0xfffffff
  55. #define TX_BD_CFA_META_VID_MASK 0xfff
  56. #define TX_BD_CFA_META_PRI_MASK (0xf << 12)
  57. #define TX_BD_CFA_META_PRI_SHIFT 12
  58. #define TX_BD_CFA_META_TPID_MASK (3 << 16)
  59. #define TX_BD_CFA_META_TPID_SHIFT 16
  60. #define TX_BD_CFA_META_KEY (0xf << 28)
  61. #define TX_BD_CFA_META_KEY_SHIFT 28
  62. #define TX_BD_CFA_META_KEY_VLAN (1 << 28)
  63. };
  64. struct rx_bd {
  65. __le32 rx_bd_len_flags_type;
  66. #define RX_BD_TYPE (0x3f << 0)
  67. #define RX_BD_TYPE_RX_PACKET_BD 0x4
  68. #define RX_BD_TYPE_RX_BUFFER_BD 0x5
  69. #define RX_BD_TYPE_RX_AGG_BD 0x6
  70. #define RX_BD_TYPE_16B_BD_SIZE (0 << 4)
  71. #define RX_BD_TYPE_32B_BD_SIZE (1 << 4)
  72. #define RX_BD_TYPE_48B_BD_SIZE (2 << 4)
  73. #define RX_BD_TYPE_64B_BD_SIZE (3 << 4)
  74. #define RX_BD_FLAGS_SOP (1 << 6)
  75. #define RX_BD_FLAGS_EOP (1 << 7)
  76. #define RX_BD_FLAGS_BUFFERS (3 << 8)
  77. #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8)
  78. #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8)
  79. #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8)
  80. #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8)
  81. #define RX_BD_LEN (0xffff << 16)
  82. #define RX_BD_LEN_SHIFT 16
  83. u32 rx_bd_opaque;
  84. __le64 rx_bd_haddr;
  85. };
  86. struct tx_cmp {
  87. __le32 tx_cmp_flags_type;
  88. #define CMP_TYPE (0x3f << 0)
  89. #define CMP_TYPE_TX_L2_CMP 0
  90. #define CMP_TYPE_RX_L2_CMP 17
  91. #define CMP_TYPE_RX_AGG_CMP 18
  92. #define CMP_TYPE_RX_L2_TPA_START_CMP 19
  93. #define CMP_TYPE_RX_L2_TPA_END_CMP 21
  94. #define CMP_TYPE_STATUS_CMP 32
  95. #define CMP_TYPE_REMOTE_DRIVER_REQ 34
  96. #define CMP_TYPE_REMOTE_DRIVER_RESP 36
  97. #define CMP_TYPE_ERROR_STATUS 48
  98. #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL
  99. #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL
  100. #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
  101. #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL
  102. #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL
  103. #define TX_CMP_FLAGS_ERROR (1 << 6)
  104. #define TX_CMP_FLAGS_PUSH (1 << 7)
  105. u32 tx_cmp_opaque;
  106. __le32 tx_cmp_errors_v;
  107. #define TX_CMP_V (1 << 0)
  108. #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1)
  109. #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0
  110. #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2
  111. #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4
  112. #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5
  113. #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4)
  114. #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5)
  115. #define TX_CMP_ERRORS_DMA_ERROR (1 << 6)
  116. #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7)
  117. __le32 tx_cmp_unsed_3;
  118. };
  119. struct rx_cmp {
  120. __le32 rx_cmp_len_flags_type;
  121. #define RX_CMP_CMP_TYPE (0x3f << 0)
  122. #define RX_CMP_FLAGS_ERROR (1 << 6)
  123. #define RX_CMP_FLAGS_PLACEMENT (7 << 7)
  124. #define RX_CMP_FLAGS_RSS_VALID (1 << 10)
  125. #define RX_CMP_FLAGS_UNUSED (1 << 11)
  126. #define RX_CMP_FLAGS_ITYPES_SHIFT 12
  127. #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
  128. #define RX_CMP_FLAGS_ITYPE_IP (1 << 12)
  129. #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12)
  130. #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)
  131. #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)
  132. #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12)
  133. #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)
  134. #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)
  135. #define RX_CMP_LEN (0xffff << 16)
  136. #define RX_CMP_LEN_SHIFT 16
  137. u32 rx_cmp_opaque;
  138. __le32 rx_cmp_misc_v1;
  139. #define RX_CMP_V1 (1 << 0)
  140. #define RX_CMP_AGG_BUFS (0x1f << 1)
  141. #define RX_CMP_AGG_BUFS_SHIFT 1
  142. #define RX_CMP_RSS_HASH_TYPE (0x7f << 9)
  143. #define RX_CMP_RSS_HASH_TYPE_SHIFT 9
  144. #define RX_CMP_PAYLOAD_OFFSET (0xff << 16)
  145. #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16
  146. __le32 rx_cmp_rss_hash;
  147. };
  148. #define RX_CMP_HASH_VALID(rxcmp) \
  149. ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
  150. #define RSS_PROFILE_ID_MASK 0x1f
  151. #define RX_CMP_HASH_TYPE(rxcmp) \
  152. (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
  153. RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
  154. struct rx_cmp_ext {
  155. __le32 rx_cmp_flags2;
  156. #define RX_CMP_FLAGS2_IP_CS_CALC 0x1
  157. #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
  158. #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
  159. #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
  160. #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4)
  161. __le32 rx_cmp_meta_data;
  162. #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
  163. #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000
  164. #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16
  165. __le32 rx_cmp_cfa_code_errors_v2;
  166. #define RX_CMP_V (1 << 0)
  167. #define RX_CMPL_ERRORS_MASK (0x7fff << 1)
  168. #define RX_CMPL_ERRORS_SFT 1
  169. #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1)
  170. #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
  171. #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1)
  172. #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1)
  173. #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
  174. #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4)
  175. #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5)
  176. #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6)
  177. #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7)
  178. #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8)
  179. #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9)
  180. #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9)
  181. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9)
  182. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9)
  183. #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9)
  184. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9)
  185. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9)
  186. #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9)
  187. #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12)
  188. #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12)
  189. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12)
  190. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12)
  191. #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12)
  192. #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12)
  193. #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12)
  194. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12)
  195. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12)
  196. #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12)
  197. #define RX_CMPL_CFA_CODE_MASK (0xffff << 16)
  198. #define RX_CMPL_CFA_CODE_SFT 16
  199. __le32 rx_cmp_unused3;
  200. };
  201. #define RX_CMP_L2_ERRORS \
  202. cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR)
  203. #define RX_CMP_L4_CS_BITS \
  204. (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC))
  205. #define RX_CMP_L4_CS_ERR_BITS \
  206. (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR))
  207. #define RX_CMP_L4_CS_OK(rxcmp1) \
  208. (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \
  209. !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS))
  210. #define RX_CMP_ENCAP(rxcmp1) \
  211. ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \
  212. RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3)
  213. struct rx_agg_cmp {
  214. __le32 rx_agg_cmp_len_flags_type;
  215. #define RX_AGG_CMP_TYPE (0x3f << 0)
  216. #define RX_AGG_CMP_LEN (0xffff << 16)
  217. #define RX_AGG_CMP_LEN_SHIFT 16
  218. u32 rx_agg_cmp_opaque;
  219. __le32 rx_agg_cmp_v;
  220. #define RX_AGG_CMP_V (1 << 0)
  221. __le32 rx_agg_cmp_unused;
  222. };
  223. struct rx_tpa_start_cmp {
  224. __le32 rx_tpa_start_cmp_len_flags_type;
  225. #define RX_TPA_START_CMP_TYPE (0x3f << 0)
  226. #define RX_TPA_START_CMP_FLAGS (0x3ff << 6)
  227. #define RX_TPA_START_CMP_FLAGS_SHIFT 6
  228. #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7)
  229. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7
  230. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
  231. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
  232. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
  233. #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
  234. #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10)
  235. #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12)
  236. #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12
  237. #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
  238. #define RX_TPA_START_CMP_LEN (0xffff << 16)
  239. #define RX_TPA_START_CMP_LEN_SHIFT 16
  240. u32 rx_tpa_start_cmp_opaque;
  241. __le32 rx_tpa_start_cmp_misc_v1;
  242. #define RX_TPA_START_CMP_V1 (0x1 << 0)
  243. #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9)
  244. #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9
  245. #define RX_TPA_START_CMP_AGG_ID (0x7f << 25)
  246. #define RX_TPA_START_CMP_AGG_ID_SHIFT 25
  247. __le32 rx_tpa_start_cmp_rss_hash;
  248. };
  249. #define TPA_START_HASH_VALID(rx_tpa_start) \
  250. ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \
  251. cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
  252. #define TPA_START_HASH_TYPE(rx_tpa_start) \
  253. (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
  254. RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
  255. RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
  256. #define TPA_START_AGG_ID(rx_tpa_start) \
  257. ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
  258. RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT)
  259. struct rx_tpa_start_cmp_ext {
  260. __le32 rx_tpa_start_cmp_flags2;
  261. #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0)
  262. #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
  263. #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
  264. #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
  265. #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8)
  266. __le32 rx_tpa_start_cmp_metadata;
  267. __le32 rx_tpa_start_cmp_cfa_code_v2;
  268. #define RX_TPA_START_CMP_V2 (0x1 << 0)
  269. #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16)
  270. #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16
  271. __le32 rx_tpa_start_cmp_hdr_info;
  272. };
  273. struct rx_tpa_end_cmp {
  274. __le32 rx_tpa_end_cmp_len_flags_type;
  275. #define RX_TPA_END_CMP_TYPE (0x3f << 0)
  276. #define RX_TPA_END_CMP_FLAGS (0x3ff << 6)
  277. #define RX_TPA_END_CMP_FLAGS_SHIFT 6
  278. #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7)
  279. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7
  280. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
  281. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
  282. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
  283. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
  284. #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10)
  285. #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12)
  286. #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12
  287. #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
  288. #define RX_TPA_END_CMP_LEN (0xffff << 16)
  289. #define RX_TPA_END_CMP_LEN_SHIFT 16
  290. u32 rx_tpa_end_cmp_opaque;
  291. __le32 rx_tpa_end_cmp_misc_v1;
  292. #define RX_TPA_END_CMP_V1 (0x1 << 0)
  293. #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1)
  294. #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1
  295. #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8)
  296. #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8
  297. #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16)
  298. #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16
  299. #define RX_TPA_END_CMP_AGG_ID (0x7f << 25)
  300. #define RX_TPA_END_CMP_AGG_ID_SHIFT 25
  301. __le32 rx_tpa_end_cmp_tsdelta;
  302. #define RX_TPA_END_GRO_TS (0x1 << 31)
  303. };
  304. #define TPA_END_AGG_ID(rx_tpa_end) \
  305. ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
  306. RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT)
  307. #define TPA_END_TPA_SEGS(rx_tpa_end) \
  308. ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
  309. RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
  310. #define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \
  311. cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \
  312. RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS)
  313. #define TPA_END_GRO(rx_tpa_end) \
  314. ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \
  315. RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO)
  316. #define TPA_END_GRO_TS(rx_tpa_end) \
  317. (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \
  318. cpu_to_le32(RX_TPA_END_GRO_TS)))
  319. struct rx_tpa_end_cmp_ext {
  320. __le32 rx_tpa_end_cmp_dup_acks;
  321. #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0)
  322. __le32 rx_tpa_end_cmp_seg_len;
  323. #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0)
  324. __le32 rx_tpa_end_cmp_errors_v2;
  325. #define RX_TPA_END_CMP_V2 (0x1 << 0)
  326. #define RX_TPA_END_CMP_ERRORS (0x7fff << 1)
  327. #define RX_TPA_END_CMPL_ERRORS_SHIFT 1
  328. u32 rx_tpa_end_cmp_start_opaque;
  329. };
  330. #define DB_IDX_MASK 0xffffff
  331. #define DB_IDX_VALID (0x1 << 26)
  332. #define DB_IRQ_DIS (0x1 << 27)
  333. #define DB_KEY_TX (0x0 << 28)
  334. #define DB_KEY_RX (0x1 << 28)
  335. #define DB_KEY_CP (0x2 << 28)
  336. #define DB_KEY_ST (0x3 << 28)
  337. #define DB_KEY_TX_PUSH (0x4 << 28)
  338. #define DB_LONG_TX_PUSH (0x2 << 24)
  339. #define INVALID_HW_RING_ID ((u16)-1)
  340. /* The hardware supports certain page sizes. Use the supported page sizes
  341. * to allocate the rings.
  342. */
  343. #if (PAGE_SHIFT < 12)
  344. #define BNXT_PAGE_SHIFT 12
  345. #elif (PAGE_SHIFT <= 13)
  346. #define BNXT_PAGE_SHIFT PAGE_SHIFT
  347. #elif (PAGE_SHIFT < 16)
  348. #define BNXT_PAGE_SHIFT 13
  349. #else
  350. #define BNXT_PAGE_SHIFT 16
  351. #endif
  352. #define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT)
  353. /* The RXBD length is 16-bit so we can only support page sizes < 64K */
  354. #if (PAGE_SHIFT > 15)
  355. #define BNXT_RX_PAGE_SHIFT 15
  356. #else
  357. #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT
  358. #endif
  359. #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
  360. #define BNXT_MIN_PKT_SIZE 52
  361. #define BNXT_NUM_TESTS(bp) 0
  362. #define BNXT_DEFAULT_RX_RING_SIZE 511
  363. #define BNXT_DEFAULT_TX_RING_SIZE 511
  364. #define MAX_TPA 64
  365. #if (BNXT_PAGE_SHIFT == 16)
  366. #define MAX_RX_PAGES 1
  367. #define MAX_RX_AGG_PAGES 4
  368. #define MAX_TX_PAGES 1
  369. #define MAX_CP_PAGES 8
  370. #else
  371. #define MAX_RX_PAGES 8
  372. #define MAX_RX_AGG_PAGES 32
  373. #define MAX_TX_PAGES 8
  374. #define MAX_CP_PAGES 64
  375. #endif
  376. #define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd))
  377. #define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd))
  378. #define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp))
  379. #define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT)
  380. #define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
  381. #define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT)
  382. #define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT)
  383. #define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
  384. #define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT)
  385. #define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1)
  386. #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
  387. #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1)
  388. #define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  389. #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1))
  390. #define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  391. #define TX_IDX(x) ((x) & (TX_DESC_CNT - 1))
  392. #define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
  393. #define CP_IDX(x) ((x) & (CP_DESC_CNT - 1))
  394. #define TX_CMP_VALID(txcmp, raw_cons) \
  395. (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \
  396. !((raw_cons) & bp->cp_bit))
  397. #define RX_CMP_VALID(rxcmp1, raw_cons) \
  398. (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
  399. !((raw_cons) & bp->cp_bit))
  400. #define RX_AGG_CMP_VALID(agg, raw_cons) \
  401. (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \
  402. !((raw_cons) & bp->cp_bit))
  403. #define TX_CMP_TYPE(txcmp) \
  404. (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
  405. #define RX_CMP_TYPE(rxcmp) \
  406. (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE)
  407. #define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask)
  408. #define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask)
  409. #define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask)
  410. #define ADV_RAW_CMP(idx, n) ((idx) + (n))
  411. #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
  412. #define RING_CMP(idx) ((idx) & bp->cp_ring_mask)
  413. #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
  414. #define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
  415. #define DFLT_HWRM_CMD_TIMEOUT 500
  416. #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
  417. #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
  418. #define HWRM_RESP_ERR_CODE_MASK 0xffff
  419. #define HWRM_RESP_LEN_OFFSET 4
  420. #define HWRM_RESP_LEN_MASK 0xffff0000
  421. #define HWRM_RESP_LEN_SFT 16
  422. #define HWRM_RESP_VALID_MASK 0xff000000
  423. #define HWRM_SEQ_ID_INVALID -1
  424. #define BNXT_HWRM_REQ_MAX_SIZE 128
  425. #define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
  426. BNXT_HWRM_REQ_MAX_SIZE)
  427. struct bnxt_sw_tx_bd {
  428. struct sk_buff *skb;
  429. DEFINE_DMA_UNMAP_ADDR(mapping);
  430. u8 is_gso;
  431. u8 is_push;
  432. unsigned short nr_frags;
  433. };
  434. struct bnxt_sw_rx_bd {
  435. u8 *data;
  436. DEFINE_DMA_UNMAP_ADDR(mapping);
  437. };
  438. struct bnxt_sw_rx_agg_bd {
  439. struct page *page;
  440. unsigned int offset;
  441. dma_addr_t mapping;
  442. };
  443. struct bnxt_ring_struct {
  444. int nr_pages;
  445. int page_size;
  446. void **pg_arr;
  447. dma_addr_t *dma_arr;
  448. __le64 *pg_tbl;
  449. dma_addr_t pg_tbl_map;
  450. int vmem_size;
  451. void **vmem;
  452. u16 fw_ring_id; /* Ring id filled by Chimp FW */
  453. u8 queue_id;
  454. };
  455. struct tx_push_bd {
  456. __le32 doorbell;
  457. __le32 tx_bd_len_flags_type;
  458. u32 tx_bd_opaque;
  459. struct tx_bd_ext txbd2;
  460. };
  461. struct tx_push_buffer {
  462. struct tx_push_bd push_bd;
  463. u32 data[25];
  464. };
  465. struct bnxt_tx_ring_info {
  466. struct bnxt_napi *bnapi;
  467. u16 tx_prod;
  468. u16 tx_cons;
  469. void __iomem *tx_doorbell;
  470. struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
  471. struct bnxt_sw_tx_bd *tx_buf_ring;
  472. dma_addr_t tx_desc_mapping[MAX_TX_PAGES];
  473. struct tx_push_buffer *tx_push;
  474. dma_addr_t tx_push_mapping;
  475. __le64 data_mapping;
  476. #define BNXT_DEV_STATE_CLOSING 0x1
  477. u32 dev_state;
  478. struct bnxt_ring_struct tx_ring_struct;
  479. };
  480. struct bnxt_tpa_info {
  481. u8 *data;
  482. dma_addr_t mapping;
  483. u16 len;
  484. unsigned short gso_type;
  485. u32 flags2;
  486. u32 metadata;
  487. enum pkt_hash_types hash_type;
  488. u32 rss_hash;
  489. u32 hdr_info;
  490. #define BNXT_TPA_L4_SIZE(hdr_info) \
  491. (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32)
  492. #define BNXT_TPA_INNER_L3_OFF(hdr_info) \
  493. (((hdr_info) >> 18) & 0x1ff)
  494. #define BNXT_TPA_INNER_L2_OFF(hdr_info) \
  495. (((hdr_info) >> 9) & 0x1ff)
  496. #define BNXT_TPA_OUTER_L3_OFF(hdr_info) \
  497. ((hdr_info) & 0x1ff)
  498. };
  499. struct bnxt_rx_ring_info {
  500. struct bnxt_napi *bnapi;
  501. u16 rx_prod;
  502. u16 rx_agg_prod;
  503. u16 rx_sw_agg_prod;
  504. u16 rx_next_cons;
  505. void __iomem *rx_doorbell;
  506. void __iomem *rx_agg_doorbell;
  507. struct rx_bd *rx_desc_ring[MAX_RX_PAGES];
  508. struct bnxt_sw_rx_bd *rx_buf_ring;
  509. struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES];
  510. struct bnxt_sw_rx_agg_bd *rx_agg_ring;
  511. unsigned long *rx_agg_bmap;
  512. u16 rx_agg_bmap_size;
  513. struct page *rx_page;
  514. unsigned int rx_page_offset;
  515. dma_addr_t rx_desc_mapping[MAX_RX_PAGES];
  516. dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES];
  517. struct bnxt_tpa_info *rx_tpa;
  518. struct bnxt_ring_struct rx_ring_struct;
  519. struct bnxt_ring_struct rx_agg_ring_struct;
  520. };
  521. struct bnxt_cp_ring_info {
  522. u32 cp_raw_cons;
  523. void __iomem *cp_doorbell;
  524. struct tx_cmp *cp_desc_ring[MAX_CP_PAGES];
  525. dma_addr_t cp_desc_mapping[MAX_CP_PAGES];
  526. struct ctx_hw_stats *hw_stats;
  527. dma_addr_t hw_stats_map;
  528. u32 hw_stats_ctx_id;
  529. u64 rx_l4_csum_errors;
  530. struct bnxt_ring_struct cp_ring_struct;
  531. };
  532. struct bnxt_napi {
  533. struct napi_struct napi;
  534. struct bnxt *bp;
  535. int index;
  536. struct bnxt_cp_ring_info cp_ring;
  537. struct bnxt_rx_ring_info *rx_ring;
  538. struct bnxt_tx_ring_info *tx_ring;
  539. #ifdef CONFIG_NET_RX_BUSY_POLL
  540. atomic_t poll_state;
  541. #endif
  542. bool in_reset;
  543. };
  544. #ifdef CONFIG_NET_RX_BUSY_POLL
  545. enum bnxt_poll_state_t {
  546. BNXT_STATE_IDLE = 0,
  547. BNXT_STATE_NAPI,
  548. BNXT_STATE_POLL,
  549. BNXT_STATE_DISABLE,
  550. };
  551. #endif
  552. struct bnxt_irq {
  553. irq_handler_t handler;
  554. unsigned int vector;
  555. u8 requested;
  556. char name[IFNAMSIZ + 2];
  557. };
  558. #define HWRM_RING_ALLOC_TX 0x1
  559. #define HWRM_RING_ALLOC_RX 0x2
  560. #define HWRM_RING_ALLOC_AGG 0x4
  561. #define HWRM_RING_ALLOC_CMPL 0x8
  562. #define INVALID_STATS_CTX_ID -1
  563. struct bnxt_ring_grp_info {
  564. u16 fw_stats_ctx;
  565. u16 fw_grp_id;
  566. u16 rx_fw_ring_id;
  567. u16 agg_fw_ring_id;
  568. u16 cp_fw_ring_id;
  569. };
  570. struct bnxt_vnic_info {
  571. u16 fw_vnic_id; /* returned by Chimp during alloc */
  572. #define BNXT_MAX_CTX_PER_VNIC 2
  573. u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC];
  574. u16 fw_l2_ctx_id;
  575. #define BNXT_MAX_UC_ADDRS 4
  576. __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS];
  577. /* index 0 always dev_addr */
  578. u16 uc_filter_count;
  579. u8 *uc_list;
  580. u16 *fw_grp_ids;
  581. u16 hash_type;
  582. dma_addr_t rss_table_dma_addr;
  583. __le16 *rss_table;
  584. dma_addr_t rss_hash_key_dma_addr;
  585. u64 *rss_hash_key;
  586. u32 rx_mask;
  587. u8 *mc_list;
  588. int mc_list_size;
  589. int mc_list_count;
  590. dma_addr_t mc_list_mapping;
  591. #define BNXT_MAX_MC_ADDRS 16
  592. u32 flags;
  593. #define BNXT_VNIC_RSS_FLAG 1
  594. #define BNXT_VNIC_RFS_FLAG 2
  595. #define BNXT_VNIC_MCAST_FLAG 4
  596. #define BNXT_VNIC_UCAST_FLAG 8
  597. };
  598. #if defined(CONFIG_BNXT_SRIOV)
  599. struct bnxt_vf_info {
  600. u16 fw_fid;
  601. u8 mac_addr[ETH_ALEN];
  602. u16 max_rsscos_ctxs;
  603. u16 max_cp_rings;
  604. u16 max_tx_rings;
  605. u16 max_rx_rings;
  606. u16 max_hw_ring_grps;
  607. u16 max_l2_ctxs;
  608. u16 max_irqs;
  609. u16 max_vnics;
  610. u16 max_stat_ctxs;
  611. u16 vlan;
  612. u32 flags;
  613. #define BNXT_VF_QOS 0x1
  614. #define BNXT_VF_SPOOFCHK 0x2
  615. #define BNXT_VF_LINK_FORCED 0x4
  616. #define BNXT_VF_LINK_UP 0x8
  617. u32 func_flags; /* func cfg flags */
  618. u32 min_tx_rate;
  619. u32 max_tx_rate;
  620. void *hwrm_cmd_req_addr;
  621. dma_addr_t hwrm_cmd_req_dma_addr;
  622. };
  623. #endif
  624. struct bnxt_pf_info {
  625. #define BNXT_FIRST_PF_FID 1
  626. #define BNXT_FIRST_VF_FID 128
  627. u16 fw_fid;
  628. u16 port_id;
  629. u8 mac_addr[ETH_ALEN];
  630. u16 max_rsscos_ctxs;
  631. u16 max_cp_rings;
  632. u16 max_tx_rings; /* HW assigned max tx rings for this PF */
  633. u16 max_rx_rings; /* HW assigned max rx rings for this PF */
  634. u16 max_hw_ring_grps;
  635. u16 max_irqs;
  636. u16 max_l2_ctxs;
  637. u16 max_vnics;
  638. u16 max_stat_ctxs;
  639. u32 first_vf_id;
  640. u16 active_vfs;
  641. u16 max_vfs;
  642. u32 max_encap_records;
  643. u32 max_decap_records;
  644. u32 max_tx_em_flows;
  645. u32 max_tx_wm_flows;
  646. u32 max_rx_em_flows;
  647. u32 max_rx_wm_flows;
  648. unsigned long *vf_event_bmap;
  649. u16 hwrm_cmd_req_pages;
  650. void *hwrm_cmd_req_addr[4];
  651. dma_addr_t hwrm_cmd_req_dma_addr[4];
  652. struct bnxt_vf_info *vf;
  653. };
  654. struct bnxt_ntuple_filter {
  655. struct hlist_node hash;
  656. u8 dst_mac_addr[ETH_ALEN];
  657. u8 src_mac_addr[ETH_ALEN];
  658. struct flow_keys fkeys;
  659. __le64 filter_id;
  660. u16 sw_id;
  661. u8 l2_fltr_idx;
  662. u16 rxq;
  663. u32 flow_id;
  664. unsigned long state;
  665. #define BNXT_FLTR_VALID 0
  666. #define BNXT_FLTR_UPDATE 1
  667. };
  668. struct bnxt_link_info {
  669. u8 phy_type;
  670. u8 media_type;
  671. u8 transceiver;
  672. u8 phy_addr;
  673. u8 phy_link_status;
  674. #define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK
  675. #define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL
  676. #define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK
  677. u8 wire_speed;
  678. u8 loop_back;
  679. u8 link_up;
  680. u8 duplex;
  681. #define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_HALF
  682. #define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_FULL
  683. u8 pause;
  684. #define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX
  685. #define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX
  686. #define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \
  687. PORT_PHY_QCFG_RESP_PAUSE_TX)
  688. u8 lp_pause;
  689. u8 auto_pause_setting;
  690. u8 force_pause_setting;
  691. u8 duplex_setting;
  692. u8 auto_mode;
  693. #define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \
  694. (mode) <= BNXT_LINK_AUTO_MSK)
  695. #define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE
  696. #define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
  697. #define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
  698. #define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
  699. #define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
  700. #define PHY_VER_LEN 3
  701. u8 phy_ver[PHY_VER_LEN];
  702. u16 link_speed;
  703. #define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB
  704. #define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB
  705. #define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB
  706. #define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB
  707. #define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB
  708. #define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB
  709. #define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB
  710. #define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB
  711. #define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB
  712. u16 support_speeds;
  713. u16 auto_link_speeds;
  714. #define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB
  715. #define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB
  716. #define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB
  717. #define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB
  718. #define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB
  719. #define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB
  720. #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
  721. #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
  722. #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
  723. u16 support_auto_speeds;
  724. u16 lp_auto_link_speeds;
  725. u16 force_link_speed;
  726. u32 preemphasis;
  727. u8 module_status;
  728. /* copy of requested setting from ethtool cmd */
  729. u8 autoneg;
  730. #define BNXT_AUTONEG_SPEED 1
  731. #define BNXT_AUTONEG_FLOW_CTRL 2
  732. u8 req_duplex;
  733. u8 req_flow_ctrl;
  734. u16 req_link_speed;
  735. u32 advertising;
  736. bool force_link_chng;
  737. /* a copy of phy_qcfg output used to report link
  738. * info to VF
  739. */
  740. struct hwrm_port_phy_qcfg_output phy_qcfg_resp;
  741. };
  742. #define BNXT_MAX_QUEUE 8
  743. struct bnxt_queue_info {
  744. u8 queue_id;
  745. u8 queue_profile;
  746. };
  747. #define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400
  748. #define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
  749. #define BNXT_CAG_REG_BASE 0x300000
  750. struct bnxt {
  751. void __iomem *bar0;
  752. void __iomem *bar1;
  753. void __iomem *bar2;
  754. u32 reg_base;
  755. u16 chip_num;
  756. #define CHIP_NUM_57301 0x16c8
  757. #define CHIP_NUM_57302 0x16c9
  758. #define CHIP_NUM_57304 0x16ca
  759. #define CHIP_NUM_58700 0x16cd
  760. #define CHIP_NUM_57402 0x16d0
  761. #define CHIP_NUM_57404 0x16d1
  762. #define CHIP_NUM_57406 0x16d2
  763. #define CHIP_NUM_57311 0x16ce
  764. #define CHIP_NUM_57312 0x16cf
  765. #define CHIP_NUM_57314 0x16df
  766. #define CHIP_NUM_57412 0x16d6
  767. #define CHIP_NUM_57414 0x16d7
  768. #define CHIP_NUM_57416 0x16d8
  769. #define CHIP_NUM_57417 0x16d9
  770. #define BNXT_CHIP_NUM_5730X(chip_num) \
  771. ((chip_num) >= CHIP_NUM_57301 && \
  772. (chip_num) <= CHIP_NUM_57304)
  773. #define BNXT_CHIP_NUM_5740X(chip_num) \
  774. ((chip_num) >= CHIP_NUM_57402 && \
  775. (chip_num) <= CHIP_NUM_57406)
  776. #define BNXT_CHIP_NUM_5731X(chip_num) \
  777. ((chip_num) == CHIP_NUM_57311 || \
  778. (chip_num) == CHIP_NUM_57312 || \
  779. (chip_num) == CHIP_NUM_57314)
  780. #define BNXT_CHIP_NUM_5741X(chip_num) \
  781. ((chip_num) >= CHIP_NUM_57412 && \
  782. (chip_num) <= CHIP_NUM_57417)
  783. #define BNXT_CHIP_NUM_57X0X(chip_num) \
  784. (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num))
  785. #define BNXT_CHIP_NUM_57X1X(chip_num) \
  786. (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num))
  787. struct net_device *dev;
  788. struct pci_dev *pdev;
  789. atomic_t intr_sem;
  790. u32 flags;
  791. #define BNXT_FLAG_DCB_ENABLED 0x1
  792. #define BNXT_FLAG_VF 0x2
  793. #define BNXT_FLAG_LRO 0x4
  794. #ifdef CONFIG_INET
  795. #define BNXT_FLAG_GRO 0x8
  796. #else
  797. /* Cannot support hardware GRO if CONFIG_INET is not set */
  798. #define BNXT_FLAG_GRO 0x0
  799. #endif
  800. #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO)
  801. #define BNXT_FLAG_JUMBO 0x10
  802. #define BNXT_FLAG_STRIP_VLAN 0x20
  803. #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
  804. BNXT_FLAG_LRO)
  805. #define BNXT_FLAG_USING_MSIX 0x40
  806. #define BNXT_FLAG_MSIX_CAP 0x80
  807. #define BNXT_FLAG_RFS 0x100
  808. #define BNXT_FLAG_SHARED_RINGS 0x200
  809. #define BNXT_FLAG_PORT_STATS 0x400
  810. #define BNXT_FLAG_EEE_CAP 0x1000
  811. #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000
  812. #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
  813. BNXT_FLAG_RFS | \
  814. BNXT_FLAG_STRIP_VLAN)
  815. #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
  816. #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
  817. #define BNXT_NPAR(bp) ((bp)->port_partition_type)
  818. #define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp))
  819. #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
  820. struct bnxt_napi **bnapi;
  821. struct bnxt_rx_ring_info *rx_ring;
  822. struct bnxt_tx_ring_info *tx_ring;
  823. struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int,
  824. struct sk_buff *);
  825. u32 rx_buf_size;
  826. u32 rx_buf_use_size; /* useable size */
  827. u32 rx_ring_size;
  828. u32 rx_agg_ring_size;
  829. u32 rx_copy_thresh;
  830. u32 rx_ring_mask;
  831. u32 rx_agg_ring_mask;
  832. int rx_nr_pages;
  833. int rx_agg_nr_pages;
  834. int rx_nr_rings;
  835. int rsscos_nr_ctxs;
  836. u32 tx_ring_size;
  837. u32 tx_ring_mask;
  838. int tx_nr_pages;
  839. int tx_nr_rings;
  840. int tx_nr_rings_per_tc;
  841. int tx_wake_thresh;
  842. int tx_push_thresh;
  843. int tx_push_size;
  844. u32 cp_ring_size;
  845. u32 cp_ring_mask;
  846. u32 cp_bit;
  847. int cp_nr_pages;
  848. int cp_nr_rings;
  849. int num_stat_ctxs;
  850. /* grp_info indexed by completion ring index */
  851. struct bnxt_ring_grp_info *grp_info;
  852. struct bnxt_vnic_info *vnic_info;
  853. int nr_vnics;
  854. u8 max_tc;
  855. struct bnxt_queue_info q_info[BNXT_MAX_QUEUE];
  856. unsigned int current_interval;
  857. #define BNXT_TIMER_INTERVAL HZ
  858. struct timer_list timer;
  859. unsigned long state;
  860. #define BNXT_STATE_OPEN 0
  861. #define BNXT_STATE_IN_SP_TASK 1
  862. #define BNXT_STATE_FN_RST_DONE 2
  863. struct bnxt_irq *irq_tbl;
  864. u8 mac_addr[ETH_ALEN];
  865. u32 msg_enable;
  866. u32 hwrm_spec_code;
  867. u16 hwrm_cmd_seq;
  868. u32 hwrm_intr_seq_id;
  869. void *hwrm_cmd_resp_addr;
  870. dma_addr_t hwrm_cmd_resp_dma_addr;
  871. void *hwrm_dbg_resp_addr;
  872. dma_addr_t hwrm_dbg_resp_dma_addr;
  873. #define HWRM_DBG_REG_BUF_SIZE 128
  874. struct rx_port_stats *hw_rx_port_stats;
  875. struct tx_port_stats *hw_tx_port_stats;
  876. dma_addr_t hw_rx_port_stats_map;
  877. dma_addr_t hw_tx_port_stats_map;
  878. int hw_port_stats_size;
  879. u16 hwrm_max_req_len;
  880. int hwrm_cmd_timeout;
  881. struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
  882. struct hwrm_ver_get_output ver_resp;
  883. #define FW_VER_STR_LEN 32
  884. #define BC_HWRM_STR_LEN 21
  885. #define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
  886. char fw_ver_str[FW_VER_STR_LEN];
  887. __be16 vxlan_port;
  888. u8 vxlan_port_cnt;
  889. __le16 vxlan_fw_dst_port_id;
  890. __be16 nge_port;
  891. u8 nge_port_cnt;
  892. __le16 nge_fw_dst_port_id;
  893. u8 port_partition_type;
  894. u16 rx_coal_ticks;
  895. u16 rx_coal_ticks_irq;
  896. u16 rx_coal_bufs;
  897. u16 rx_coal_bufs_irq;
  898. u16 tx_coal_ticks;
  899. u16 tx_coal_ticks_irq;
  900. u16 tx_coal_bufs;
  901. u16 tx_coal_bufs_irq;
  902. #define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
  903. u32 stats_coal_ticks;
  904. #define BNXT_DEF_STATS_COAL_TICKS 1000000
  905. #define BNXT_MIN_STATS_COAL_TICKS 250000
  906. #define BNXT_MAX_STATS_COAL_TICKS 1000000
  907. struct work_struct sp_task;
  908. unsigned long sp_event;
  909. #define BNXT_RX_MASK_SP_EVENT 0
  910. #define BNXT_RX_NTP_FLTR_SP_EVENT 1
  911. #define BNXT_LINK_CHNG_SP_EVENT 2
  912. #define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3
  913. #define BNXT_VXLAN_ADD_PORT_SP_EVENT 4
  914. #define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
  915. #define BNXT_RESET_TASK_SP_EVENT 6
  916. #define BNXT_RST_RING_SP_EVENT 7
  917. #define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
  918. #define BNXT_PERIODIC_STATS_SP_EVENT 9
  919. #define BNXT_HWRM_PORT_MODULE_SP_EVENT 10
  920. #define BNXT_RESET_TASK_SILENT_SP_EVENT 11
  921. #define BNXT_GENEVE_ADD_PORT_SP_EVENT 12
  922. #define BNXT_GENEVE_DEL_PORT_SP_EVENT 13
  923. #define BNXT_LINK_SPEED_CHNG_SP_EVENT 14
  924. struct bnxt_pf_info pf;
  925. #ifdef CONFIG_BNXT_SRIOV
  926. int nr_vfs;
  927. struct bnxt_vf_info vf;
  928. wait_queue_head_t sriov_cfg_wait;
  929. bool sriov_cfg;
  930. #define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000)
  931. #endif
  932. #define BNXT_NTP_FLTR_MAX_FLTR 4096
  933. #define BNXT_NTP_FLTR_HASH_SIZE 512
  934. #define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1)
  935. struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE];
  936. spinlock_t ntp_fltr_lock; /* for hash table add, del */
  937. unsigned long *ntp_fltr_bmap;
  938. int ntp_fltr_count;
  939. struct bnxt_link_info link_info;
  940. struct ethtool_eee eee;
  941. u32 lpi_tmr_lo;
  942. u32 lpi_tmr_hi;
  943. };
  944. #ifdef CONFIG_NET_RX_BUSY_POLL
  945. static inline void bnxt_enable_poll(struct bnxt_napi *bnapi)
  946. {
  947. atomic_set(&bnapi->poll_state, BNXT_STATE_IDLE);
  948. }
  949. /* called from the NAPI poll routine to get ownership of a bnapi */
  950. static inline bool bnxt_lock_napi(struct bnxt_napi *bnapi)
  951. {
  952. int rc = atomic_cmpxchg(&bnapi->poll_state, BNXT_STATE_IDLE,
  953. BNXT_STATE_NAPI);
  954. return rc == BNXT_STATE_IDLE;
  955. }
  956. static inline void bnxt_unlock_napi(struct bnxt_napi *bnapi)
  957. {
  958. atomic_set(&bnapi->poll_state, BNXT_STATE_IDLE);
  959. }
  960. /* called from the busy poll routine to get ownership of a bnapi */
  961. static inline bool bnxt_lock_poll(struct bnxt_napi *bnapi)
  962. {
  963. int rc = atomic_cmpxchg(&bnapi->poll_state, BNXT_STATE_IDLE,
  964. BNXT_STATE_POLL);
  965. return rc == BNXT_STATE_IDLE;
  966. }
  967. static inline void bnxt_unlock_poll(struct bnxt_napi *bnapi)
  968. {
  969. atomic_set(&bnapi->poll_state, BNXT_STATE_IDLE);
  970. }
  971. static inline bool bnxt_busy_polling(struct bnxt_napi *bnapi)
  972. {
  973. return atomic_read(&bnapi->poll_state) == BNXT_STATE_POLL;
  974. }
  975. static inline void bnxt_disable_poll(struct bnxt_napi *bnapi)
  976. {
  977. int old;
  978. while (1) {
  979. old = atomic_cmpxchg(&bnapi->poll_state, BNXT_STATE_IDLE,
  980. BNXT_STATE_DISABLE);
  981. if (old == BNXT_STATE_IDLE)
  982. break;
  983. usleep_range(500, 5000);
  984. }
  985. }
  986. #else
  987. static inline void bnxt_enable_poll(struct bnxt_napi *bnapi)
  988. {
  989. }
  990. static inline bool bnxt_lock_napi(struct bnxt_napi *bnapi)
  991. {
  992. return true;
  993. }
  994. static inline void bnxt_unlock_napi(struct bnxt_napi *bnapi)
  995. {
  996. }
  997. static inline bool bnxt_lock_poll(struct bnxt_napi *bnapi)
  998. {
  999. return false;
  1000. }
  1001. static inline void bnxt_unlock_poll(struct bnxt_napi *bnapi)
  1002. {
  1003. }
  1004. static inline bool bnxt_busy_polling(struct bnxt_napi *bnapi)
  1005. {
  1006. return false;
  1007. }
  1008. static inline void bnxt_disable_poll(struct bnxt_napi *bnapi)
  1009. {
  1010. }
  1011. #endif
  1012. #define I2C_DEV_ADDR_A0 0xa0
  1013. #define I2C_DEV_ADDR_A2 0xa2
  1014. #define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e
  1015. #define SFP_EEPROM_SFF_8472_COMP_SIZE 1
  1016. #define SFF_MODULE_ID_SFP 0x3
  1017. #define SFF_MODULE_ID_QSFP 0xc
  1018. #define SFF_MODULE_ID_QSFP_PLUS 0xd
  1019. #define SFF_MODULE_ID_QSFP28 0x11
  1020. #define BNXT_MAX_PHY_I2C_RESP_SIZE 64
  1021. void bnxt_set_ring_params(struct bnxt *);
  1022. void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
  1023. int _hwrm_send_message(struct bnxt *, void *, u32, int);
  1024. int hwrm_send_message(struct bnxt *, void *, u32, int);
  1025. int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
  1026. int bnxt_hwrm_set_coal(struct bnxt *);
  1027. int bnxt_hwrm_func_qcaps(struct bnxt *);
  1028. int bnxt_hwrm_set_pause(struct bnxt *);
  1029. int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
  1030. int bnxt_hwrm_fw_set_time(struct bnxt *);
  1031. int bnxt_open_nic(struct bnxt *, bool, bool);
  1032. int bnxt_close_nic(struct bnxt *, bool, bool);
  1033. int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
  1034. #endif