qlge_dbg.c 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043
  1. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  2. #include <linux/slab.h>
  3. #include "qlge.h"
  4. /* Read a NIC register from the alternate function. */
  5. static u32 ql_read_other_func_reg(struct ql_adapter *qdev,
  6. u32 reg)
  7. {
  8. u32 register_to_read;
  9. u32 reg_val;
  10. unsigned int status = 0;
  11. register_to_read = MPI_NIC_REG_BLOCK
  12. | MPI_NIC_READ
  13. | (qdev->alt_func << MPI_NIC_FUNCTION_SHIFT)
  14. | reg;
  15. status = ql_read_mpi_reg(qdev, register_to_read, &reg_val);
  16. if (status != 0)
  17. return 0xffffffff;
  18. return reg_val;
  19. }
  20. /* Write a NIC register from the alternate function. */
  21. static int ql_write_other_func_reg(struct ql_adapter *qdev,
  22. u32 reg, u32 reg_val)
  23. {
  24. u32 register_to_read;
  25. int status = 0;
  26. register_to_read = MPI_NIC_REG_BLOCK
  27. | MPI_NIC_READ
  28. | (qdev->alt_func << MPI_NIC_FUNCTION_SHIFT)
  29. | reg;
  30. status = ql_write_mpi_reg(qdev, register_to_read, reg_val);
  31. return status;
  32. }
  33. static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg,
  34. u32 bit, u32 err_bit)
  35. {
  36. u32 temp;
  37. int count = 10;
  38. while (count) {
  39. temp = ql_read_other_func_reg(qdev, reg);
  40. /* check for errors */
  41. if (temp & err_bit)
  42. return -1;
  43. else if (temp & bit)
  44. return 0;
  45. mdelay(10);
  46. count--;
  47. }
  48. return -1;
  49. }
  50. static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg,
  51. u32 *data)
  52. {
  53. int status;
  54. /* wait for reg to come ready */
  55. status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
  56. XG_SERDES_ADDR_RDY, 0);
  57. if (status)
  58. goto exit;
  59. /* set up for reg read */
  60. ql_write_other_func_reg(qdev, XG_SERDES_ADDR/4, reg | PROC_ADDR_R);
  61. /* wait for reg to come ready */
  62. status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
  63. XG_SERDES_ADDR_RDY, 0);
  64. if (status)
  65. goto exit;
  66. /* get the data */
  67. *data = ql_read_other_func_reg(qdev, (XG_SERDES_DATA / 4));
  68. exit:
  69. return status;
  70. }
  71. /* Read out the SERDES registers */
  72. static int ql_read_serdes_reg(struct ql_adapter *qdev, u32 reg, u32 *data)
  73. {
  74. int status;
  75. /* wait for reg to come ready */
  76. status = ql_wait_reg_rdy(qdev, XG_SERDES_ADDR, XG_SERDES_ADDR_RDY, 0);
  77. if (status)
  78. goto exit;
  79. /* set up for reg read */
  80. ql_write32(qdev, XG_SERDES_ADDR, reg | PROC_ADDR_R);
  81. /* wait for reg to come ready */
  82. status = ql_wait_reg_rdy(qdev, XG_SERDES_ADDR, XG_SERDES_ADDR_RDY, 0);
  83. if (status)
  84. goto exit;
  85. /* get the data */
  86. *data = ql_read32(qdev, XG_SERDES_DATA);
  87. exit:
  88. return status;
  89. }
  90. static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr,
  91. u32 *direct_ptr, u32 *indirect_ptr,
  92. unsigned int direct_valid, unsigned int indirect_valid)
  93. {
  94. unsigned int status;
  95. status = 1;
  96. if (direct_valid)
  97. status = ql_read_serdes_reg(qdev, addr, direct_ptr);
  98. /* Dead fill any failures or invalids. */
  99. if (status)
  100. *direct_ptr = 0xDEADBEEF;
  101. status = 1;
  102. if (indirect_valid)
  103. status = ql_read_other_func_serdes_reg(
  104. qdev, addr, indirect_ptr);
  105. /* Dead fill any failures or invalids. */
  106. if (status)
  107. *indirect_ptr = 0xDEADBEEF;
  108. }
  109. static int ql_get_serdes_regs(struct ql_adapter *qdev,
  110. struct ql_mpi_coredump *mpi_coredump)
  111. {
  112. int status;
  113. unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid;
  114. unsigned int xaui_indirect_valid, i;
  115. u32 *direct_ptr, temp;
  116. u32 *indirect_ptr;
  117. xfi_direct_valid = xfi_indirect_valid = 0;
  118. xaui_direct_valid = xaui_indirect_valid = 1;
  119. /* The XAUI needs to be read out per port */
  120. if (qdev->func & 1) {
  121. /* We are NIC 2 */
  122. status = ql_read_other_func_serdes_reg(qdev,
  123. XG_SERDES_XAUI_HSS_PCS_START, &temp);
  124. if (status)
  125. temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
  126. if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
  127. XG_SERDES_ADDR_XAUI_PWR_DOWN)
  128. xaui_indirect_valid = 0;
  129. status = ql_read_serdes_reg(qdev,
  130. XG_SERDES_XAUI_HSS_PCS_START, &temp);
  131. if (status)
  132. temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
  133. if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
  134. XG_SERDES_ADDR_XAUI_PWR_DOWN)
  135. xaui_direct_valid = 0;
  136. } else {
  137. /* We are NIC 1 */
  138. status = ql_read_other_func_serdes_reg(qdev,
  139. XG_SERDES_XAUI_HSS_PCS_START, &temp);
  140. if (status)
  141. temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
  142. if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
  143. XG_SERDES_ADDR_XAUI_PWR_DOWN)
  144. xaui_indirect_valid = 0;
  145. status = ql_read_serdes_reg(qdev,
  146. XG_SERDES_XAUI_HSS_PCS_START, &temp);
  147. if (status)
  148. temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
  149. if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
  150. XG_SERDES_ADDR_XAUI_PWR_DOWN)
  151. xaui_direct_valid = 0;
  152. }
  153. /*
  154. * XFI register is shared so only need to read one
  155. * functions and then check the bits.
  156. */
  157. status = ql_read_serdes_reg(qdev, XG_SERDES_ADDR_STS, &temp);
  158. if (status)
  159. temp = 0;
  160. if ((temp & XG_SERDES_ADDR_XFI1_PWR_UP) ==
  161. XG_SERDES_ADDR_XFI1_PWR_UP) {
  162. /* now see if i'm NIC 1 or NIC 2 */
  163. if (qdev->func & 1)
  164. /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
  165. xfi_indirect_valid = 1;
  166. else
  167. xfi_direct_valid = 1;
  168. }
  169. if ((temp & XG_SERDES_ADDR_XFI2_PWR_UP) ==
  170. XG_SERDES_ADDR_XFI2_PWR_UP) {
  171. /* now see if i'm NIC 1 or NIC 2 */
  172. if (qdev->func & 1)
  173. /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
  174. xfi_direct_valid = 1;
  175. else
  176. xfi_indirect_valid = 1;
  177. }
  178. /* Get XAUI_AN register block. */
  179. if (qdev->func & 1) {
  180. /* Function 2 is direct */
  181. direct_ptr = mpi_coredump->serdes2_xaui_an;
  182. indirect_ptr = mpi_coredump->serdes_xaui_an;
  183. } else {
  184. /* Function 1 is direct */
  185. direct_ptr = mpi_coredump->serdes_xaui_an;
  186. indirect_ptr = mpi_coredump->serdes2_xaui_an;
  187. }
  188. for (i = 0; i <= 0x000000034; i += 4, direct_ptr++, indirect_ptr++)
  189. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  190. xaui_direct_valid, xaui_indirect_valid);
  191. /* Get XAUI_HSS_PCS register block. */
  192. if (qdev->func & 1) {
  193. direct_ptr =
  194. mpi_coredump->serdes2_xaui_hss_pcs;
  195. indirect_ptr =
  196. mpi_coredump->serdes_xaui_hss_pcs;
  197. } else {
  198. direct_ptr =
  199. mpi_coredump->serdes_xaui_hss_pcs;
  200. indirect_ptr =
  201. mpi_coredump->serdes2_xaui_hss_pcs;
  202. }
  203. for (i = 0x800; i <= 0x880; i += 4, direct_ptr++, indirect_ptr++)
  204. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  205. xaui_direct_valid, xaui_indirect_valid);
  206. /* Get XAUI_XFI_AN register block. */
  207. if (qdev->func & 1) {
  208. direct_ptr = mpi_coredump->serdes2_xfi_an;
  209. indirect_ptr = mpi_coredump->serdes_xfi_an;
  210. } else {
  211. direct_ptr = mpi_coredump->serdes_xfi_an;
  212. indirect_ptr = mpi_coredump->serdes2_xfi_an;
  213. }
  214. for (i = 0x1000; i <= 0x1034; i += 4, direct_ptr++, indirect_ptr++)
  215. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  216. xfi_direct_valid, xfi_indirect_valid);
  217. /* Get XAUI_XFI_TRAIN register block. */
  218. if (qdev->func & 1) {
  219. direct_ptr = mpi_coredump->serdes2_xfi_train;
  220. indirect_ptr =
  221. mpi_coredump->serdes_xfi_train;
  222. } else {
  223. direct_ptr = mpi_coredump->serdes_xfi_train;
  224. indirect_ptr =
  225. mpi_coredump->serdes2_xfi_train;
  226. }
  227. for (i = 0x1050; i <= 0x107c; i += 4, direct_ptr++, indirect_ptr++)
  228. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  229. xfi_direct_valid, xfi_indirect_valid);
  230. /* Get XAUI_XFI_HSS_PCS register block. */
  231. if (qdev->func & 1) {
  232. direct_ptr =
  233. mpi_coredump->serdes2_xfi_hss_pcs;
  234. indirect_ptr =
  235. mpi_coredump->serdes_xfi_hss_pcs;
  236. } else {
  237. direct_ptr =
  238. mpi_coredump->serdes_xfi_hss_pcs;
  239. indirect_ptr =
  240. mpi_coredump->serdes2_xfi_hss_pcs;
  241. }
  242. for (i = 0x1800; i <= 0x1838; i += 4, direct_ptr++, indirect_ptr++)
  243. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  244. xfi_direct_valid, xfi_indirect_valid);
  245. /* Get XAUI_XFI_HSS_TX register block. */
  246. if (qdev->func & 1) {
  247. direct_ptr =
  248. mpi_coredump->serdes2_xfi_hss_tx;
  249. indirect_ptr =
  250. mpi_coredump->serdes_xfi_hss_tx;
  251. } else {
  252. direct_ptr = mpi_coredump->serdes_xfi_hss_tx;
  253. indirect_ptr =
  254. mpi_coredump->serdes2_xfi_hss_tx;
  255. }
  256. for (i = 0x1c00; i <= 0x1c1f; i++, direct_ptr++, indirect_ptr++)
  257. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  258. xfi_direct_valid, xfi_indirect_valid);
  259. /* Get XAUI_XFI_HSS_RX register block. */
  260. if (qdev->func & 1) {
  261. direct_ptr =
  262. mpi_coredump->serdes2_xfi_hss_rx;
  263. indirect_ptr =
  264. mpi_coredump->serdes_xfi_hss_rx;
  265. } else {
  266. direct_ptr = mpi_coredump->serdes_xfi_hss_rx;
  267. indirect_ptr =
  268. mpi_coredump->serdes2_xfi_hss_rx;
  269. }
  270. for (i = 0x1c40; i <= 0x1c5f; i++, direct_ptr++, indirect_ptr++)
  271. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  272. xfi_direct_valid, xfi_indirect_valid);
  273. /* Get XAUI_XFI_HSS_PLL register block. */
  274. if (qdev->func & 1) {
  275. direct_ptr =
  276. mpi_coredump->serdes2_xfi_hss_pll;
  277. indirect_ptr =
  278. mpi_coredump->serdes_xfi_hss_pll;
  279. } else {
  280. direct_ptr =
  281. mpi_coredump->serdes_xfi_hss_pll;
  282. indirect_ptr =
  283. mpi_coredump->serdes2_xfi_hss_pll;
  284. }
  285. for (i = 0x1e00; i <= 0x1e1f; i++, direct_ptr++, indirect_ptr++)
  286. ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
  287. xfi_direct_valid, xfi_indirect_valid);
  288. return 0;
  289. }
  290. static int ql_read_other_func_xgmac_reg(struct ql_adapter *qdev, u32 reg,
  291. u32 *data)
  292. {
  293. int status = 0;
  294. /* wait for reg to come ready */
  295. status = ql_wait_other_func_reg_rdy(qdev, XGMAC_ADDR / 4,
  296. XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
  297. if (status)
  298. goto exit;
  299. /* set up for reg read */
  300. ql_write_other_func_reg(qdev, XGMAC_ADDR / 4, reg | XGMAC_ADDR_R);
  301. /* wait for reg to come ready */
  302. status = ql_wait_other_func_reg_rdy(qdev, XGMAC_ADDR / 4,
  303. XGMAC_ADDR_RDY, XGMAC_ADDR_XME);
  304. if (status)
  305. goto exit;
  306. /* get the data */
  307. *data = ql_read_other_func_reg(qdev, XGMAC_DATA / 4);
  308. exit:
  309. return status;
  310. }
  311. /* Read the 400 xgmac control/statistics registers
  312. * skipping unused locations.
  313. */
  314. static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 *buf,
  315. unsigned int other_function)
  316. {
  317. int status = 0;
  318. int i;
  319. for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) {
  320. /* We're reading 400 xgmac registers, but we filter out
  321. * serveral locations that are non-responsive to reads.
  322. */
  323. if ((i == 0x00000114) ||
  324. (i == 0x00000118) ||
  325. (i == 0x0000013c) ||
  326. (i == 0x00000140) ||
  327. (i > 0x00000150 && i < 0x000001fc) ||
  328. (i > 0x00000278 && i < 0x000002a0) ||
  329. (i > 0x000002c0 && i < 0x000002cf) ||
  330. (i > 0x000002dc && i < 0x000002f0) ||
  331. (i > 0x000003c8 && i < 0x00000400) ||
  332. (i > 0x00000400 && i < 0x00000410) ||
  333. (i > 0x00000410 && i < 0x00000420) ||
  334. (i > 0x00000420 && i < 0x00000430) ||
  335. (i > 0x00000430 && i < 0x00000440) ||
  336. (i > 0x00000440 && i < 0x00000450) ||
  337. (i > 0x00000450 && i < 0x00000500) ||
  338. (i > 0x0000054c && i < 0x00000568) ||
  339. (i > 0x000005c8 && i < 0x00000600)) {
  340. if (other_function)
  341. status =
  342. ql_read_other_func_xgmac_reg(qdev, i, buf);
  343. else
  344. status = ql_read_xgmac_reg(qdev, i, buf);
  345. if (status)
  346. *buf = 0xdeadbeef;
  347. break;
  348. }
  349. }
  350. return status;
  351. }
  352. static int ql_get_ets_regs(struct ql_adapter *qdev, u32 *buf)
  353. {
  354. int status = 0;
  355. int i;
  356. for (i = 0; i < 8; i++, buf++) {
  357. ql_write32(qdev, NIC_ETS, i << 29 | 0x08000000);
  358. *buf = ql_read32(qdev, NIC_ETS);
  359. }
  360. for (i = 0; i < 2; i++, buf++) {
  361. ql_write32(qdev, CNA_ETS, i << 29 | 0x08000000);
  362. *buf = ql_read32(qdev, CNA_ETS);
  363. }
  364. return status;
  365. }
  366. static void ql_get_intr_states(struct ql_adapter *qdev, u32 *buf)
  367. {
  368. int i;
  369. for (i = 0; i < qdev->rx_ring_count; i++, buf++) {
  370. ql_write32(qdev, INTR_EN,
  371. qdev->intr_context[i].intr_read_mask);
  372. *buf = ql_read32(qdev, INTR_EN);
  373. }
  374. }
  375. static int ql_get_cam_entries(struct ql_adapter *qdev, u32 *buf)
  376. {
  377. int i, status;
  378. u32 value[3];
  379. status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
  380. if (status)
  381. return status;
  382. for (i = 0; i < 16; i++) {
  383. status = ql_get_mac_addr_reg(qdev,
  384. MAC_ADDR_TYPE_CAM_MAC, i, value);
  385. if (status) {
  386. netif_err(qdev, drv, qdev->ndev,
  387. "Failed read of mac index register\n");
  388. goto err;
  389. }
  390. *buf++ = value[0]; /* lower MAC address */
  391. *buf++ = value[1]; /* upper MAC address */
  392. *buf++ = value[2]; /* output */
  393. }
  394. for (i = 0; i < 32; i++) {
  395. status = ql_get_mac_addr_reg(qdev,
  396. MAC_ADDR_TYPE_MULTI_MAC, i, value);
  397. if (status) {
  398. netif_err(qdev, drv, qdev->ndev,
  399. "Failed read of mac index register\n");
  400. goto err;
  401. }
  402. *buf++ = value[0]; /* lower Mcast address */
  403. *buf++ = value[1]; /* upper Mcast address */
  404. }
  405. err:
  406. ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
  407. return status;
  408. }
  409. static int ql_get_routing_entries(struct ql_adapter *qdev, u32 *buf)
  410. {
  411. int status;
  412. u32 value, i;
  413. status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
  414. if (status)
  415. return status;
  416. for (i = 0; i < 16; i++) {
  417. status = ql_get_routing_reg(qdev, i, &value);
  418. if (status) {
  419. netif_err(qdev, drv, qdev->ndev,
  420. "Failed read of routing index register\n");
  421. goto err;
  422. } else {
  423. *buf++ = value;
  424. }
  425. }
  426. err:
  427. ql_sem_unlock(qdev, SEM_RT_IDX_MASK);
  428. return status;
  429. }
  430. /* Read the MPI Processor shadow registers */
  431. static int ql_get_mpi_shadow_regs(struct ql_adapter *qdev, u32 *buf)
  432. {
  433. u32 i;
  434. int status;
  435. for (i = 0; i < MPI_CORE_SH_REGS_CNT; i++, buf++) {
  436. status = ql_write_mpi_reg(qdev, RISC_124,
  437. (SHADOW_OFFSET | i << SHADOW_REG_SHIFT));
  438. if (status)
  439. goto end;
  440. status = ql_read_mpi_reg(qdev, RISC_127, buf);
  441. if (status)
  442. goto end;
  443. }
  444. end:
  445. return status;
  446. }
  447. /* Read the MPI Processor core registers */
  448. static int ql_get_mpi_regs(struct ql_adapter *qdev, u32 *buf,
  449. u32 offset, u32 count)
  450. {
  451. int i, status = 0;
  452. for (i = 0; i < count; i++, buf++) {
  453. status = ql_read_mpi_reg(qdev, offset + i, buf);
  454. if (status)
  455. return status;
  456. }
  457. return status;
  458. }
  459. /* Read the ASIC probe dump */
  460. static unsigned int *ql_get_probe(struct ql_adapter *qdev, u32 clock,
  461. u32 valid, u32 *buf)
  462. {
  463. u32 module, mux_sel, probe, lo_val, hi_val;
  464. for (module = 0; module < PRB_MX_ADDR_MAX_MODS; module++) {
  465. if (!((valid >> module) & 1))
  466. continue;
  467. for (mux_sel = 0; mux_sel < PRB_MX_ADDR_MAX_MUX; mux_sel++) {
  468. probe = clock
  469. | PRB_MX_ADDR_ARE
  470. | mux_sel
  471. | (module << PRB_MX_ADDR_MOD_SEL_SHIFT);
  472. ql_write32(qdev, PRB_MX_ADDR, probe);
  473. lo_val = ql_read32(qdev, PRB_MX_DATA);
  474. if (mux_sel == 0) {
  475. *buf = probe;
  476. buf++;
  477. }
  478. probe |= PRB_MX_ADDR_UP;
  479. ql_write32(qdev, PRB_MX_ADDR, probe);
  480. hi_val = ql_read32(qdev, PRB_MX_DATA);
  481. *buf = lo_val;
  482. buf++;
  483. *buf = hi_val;
  484. buf++;
  485. }
  486. }
  487. return buf;
  488. }
  489. static int ql_get_probe_dump(struct ql_adapter *qdev, unsigned int *buf)
  490. {
  491. /* First we have to enable the probe mux */
  492. ql_write_mpi_reg(qdev, MPI_TEST_FUNC_PRB_CTL, MPI_TEST_FUNC_PRB_EN);
  493. buf = ql_get_probe(qdev, PRB_MX_ADDR_SYS_CLOCK,
  494. PRB_MX_ADDR_VALID_SYS_MOD, buf);
  495. buf = ql_get_probe(qdev, PRB_MX_ADDR_PCI_CLOCK,
  496. PRB_MX_ADDR_VALID_PCI_MOD, buf);
  497. buf = ql_get_probe(qdev, PRB_MX_ADDR_XGM_CLOCK,
  498. PRB_MX_ADDR_VALID_XGM_MOD, buf);
  499. buf = ql_get_probe(qdev, PRB_MX_ADDR_FC_CLOCK,
  500. PRB_MX_ADDR_VALID_FC_MOD, buf);
  501. return 0;
  502. }
  503. /* Read out the routing index registers */
  504. static int ql_get_routing_index_registers(struct ql_adapter *qdev, u32 *buf)
  505. {
  506. int status;
  507. u32 type, index, index_max;
  508. u32 result_index;
  509. u32 result_data;
  510. u32 val;
  511. status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
  512. if (status)
  513. return status;
  514. for (type = 0; type < 4; type++) {
  515. if (type < 2)
  516. index_max = 8;
  517. else
  518. index_max = 16;
  519. for (index = 0; index < index_max; index++) {
  520. val = RT_IDX_RS
  521. | (type << RT_IDX_TYPE_SHIFT)
  522. | (index << RT_IDX_IDX_SHIFT);
  523. ql_write32(qdev, RT_IDX, val);
  524. result_index = 0;
  525. while ((result_index & RT_IDX_MR) == 0)
  526. result_index = ql_read32(qdev, RT_IDX);
  527. result_data = ql_read32(qdev, RT_DATA);
  528. *buf = type;
  529. buf++;
  530. *buf = index;
  531. buf++;
  532. *buf = result_index;
  533. buf++;
  534. *buf = result_data;
  535. buf++;
  536. }
  537. }
  538. ql_sem_unlock(qdev, SEM_RT_IDX_MASK);
  539. return status;
  540. }
  541. /* Read out the MAC protocol registers */
  542. static void ql_get_mac_protocol_registers(struct ql_adapter *qdev, u32 *buf)
  543. {
  544. u32 result_index, result_data;
  545. u32 type;
  546. u32 index;
  547. u32 offset;
  548. u32 val;
  549. u32 initial_val = MAC_ADDR_RS;
  550. u32 max_index;
  551. u32 max_offset;
  552. for (type = 0; type < MAC_ADDR_TYPE_COUNT; type++) {
  553. switch (type) {
  554. case 0: /* CAM */
  555. initial_val |= MAC_ADDR_ADR;
  556. max_index = MAC_ADDR_MAX_CAM_ENTRIES;
  557. max_offset = MAC_ADDR_MAX_CAM_WCOUNT;
  558. break;
  559. case 1: /* Multicast MAC Address */
  560. max_index = MAC_ADDR_MAX_CAM_WCOUNT;
  561. max_offset = MAC_ADDR_MAX_CAM_WCOUNT;
  562. break;
  563. case 2: /* VLAN filter mask */
  564. case 3: /* MC filter mask */
  565. max_index = MAC_ADDR_MAX_CAM_WCOUNT;
  566. max_offset = MAC_ADDR_MAX_CAM_WCOUNT;
  567. break;
  568. case 4: /* FC MAC addresses */
  569. max_index = MAC_ADDR_MAX_FC_MAC_ENTRIES;
  570. max_offset = MAC_ADDR_MAX_FC_MAC_WCOUNT;
  571. break;
  572. case 5: /* Mgmt MAC addresses */
  573. max_index = MAC_ADDR_MAX_MGMT_MAC_ENTRIES;
  574. max_offset = MAC_ADDR_MAX_MGMT_MAC_WCOUNT;
  575. break;
  576. case 6: /* Mgmt VLAN addresses */
  577. max_index = MAC_ADDR_MAX_MGMT_VLAN_ENTRIES;
  578. max_offset = MAC_ADDR_MAX_MGMT_VLAN_WCOUNT;
  579. break;
  580. case 7: /* Mgmt IPv4 address */
  581. max_index = MAC_ADDR_MAX_MGMT_V4_ENTRIES;
  582. max_offset = MAC_ADDR_MAX_MGMT_V4_WCOUNT;
  583. break;
  584. case 8: /* Mgmt IPv6 address */
  585. max_index = MAC_ADDR_MAX_MGMT_V6_ENTRIES;
  586. max_offset = MAC_ADDR_MAX_MGMT_V6_WCOUNT;
  587. break;
  588. case 9: /* Mgmt TCP/UDP Dest port */
  589. max_index = MAC_ADDR_MAX_MGMT_TU_DP_ENTRIES;
  590. max_offset = MAC_ADDR_MAX_MGMT_TU_DP_WCOUNT;
  591. break;
  592. default:
  593. pr_err("Bad type!!! 0x%08x\n", type);
  594. max_index = 0;
  595. max_offset = 0;
  596. break;
  597. }
  598. for (index = 0; index < max_index; index++) {
  599. for (offset = 0; offset < max_offset; offset++) {
  600. val = initial_val
  601. | (type << MAC_ADDR_TYPE_SHIFT)
  602. | (index << MAC_ADDR_IDX_SHIFT)
  603. | (offset);
  604. ql_write32(qdev, MAC_ADDR_IDX, val);
  605. result_index = 0;
  606. while ((result_index & MAC_ADDR_MR) == 0) {
  607. result_index = ql_read32(qdev,
  608. MAC_ADDR_IDX);
  609. }
  610. result_data = ql_read32(qdev, MAC_ADDR_DATA);
  611. *buf = result_index;
  612. buf++;
  613. *buf = result_data;
  614. buf++;
  615. }
  616. }
  617. }
  618. }
  619. static void ql_get_sem_registers(struct ql_adapter *qdev, u32 *buf)
  620. {
  621. u32 func_num, reg, reg_val;
  622. int status;
  623. for (func_num = 0; func_num < MAX_SEMAPHORE_FUNCTIONS ; func_num++) {
  624. reg = MPI_NIC_REG_BLOCK
  625. | (func_num << MPI_NIC_FUNCTION_SHIFT)
  626. | (SEM / 4);
  627. status = ql_read_mpi_reg(qdev, reg, &reg_val);
  628. *buf = reg_val;
  629. /* if the read failed then dead fill the element. */
  630. if (!status)
  631. *buf = 0xdeadbeef;
  632. buf++;
  633. }
  634. }
  635. /* Create a coredump segment header */
  636. static void ql_build_coredump_seg_header(
  637. struct mpi_coredump_segment_header *seg_hdr,
  638. u32 seg_number, u32 seg_size, u8 *desc)
  639. {
  640. memset(seg_hdr, 0, sizeof(struct mpi_coredump_segment_header));
  641. seg_hdr->cookie = MPI_COREDUMP_COOKIE;
  642. seg_hdr->segNum = seg_number;
  643. seg_hdr->segSize = seg_size;
  644. strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
  645. }
  646. /*
  647. * This function should be called when a coredump / probedump
  648. * is to be extracted from the HBA. It is assumed there is a
  649. * qdev structure that contains the base address of the register
  650. * space for this function as well as a coredump structure that
  651. * will contain the dump.
  652. */
  653. int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump)
  654. {
  655. int status;
  656. int i;
  657. if (!mpi_coredump) {
  658. netif_err(qdev, drv, qdev->ndev, "No memory allocated\n");
  659. return -EINVAL;
  660. }
  661. /* Try to get the spinlock, but dont worry if
  662. * it isn't available. If the firmware died it
  663. * might be holding the sem.
  664. */
  665. ql_sem_spinlock(qdev, SEM_PROC_REG_MASK);
  666. status = ql_pause_mpi_risc(qdev);
  667. if (status) {
  668. netif_err(qdev, drv, qdev->ndev,
  669. "Failed RISC pause. Status = 0x%.08x\n", status);
  670. goto err;
  671. }
  672. /* Insert the global header */
  673. memset(&(mpi_coredump->mpi_global_header), 0,
  674. sizeof(struct mpi_coredump_global_header));
  675. mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE;
  676. mpi_coredump->mpi_global_header.headerSize =
  677. sizeof(struct mpi_coredump_global_header);
  678. mpi_coredump->mpi_global_header.imageSize =
  679. sizeof(struct ql_mpi_coredump);
  680. strncpy(mpi_coredump->mpi_global_header.idString, "MPI Coredump",
  681. sizeof(mpi_coredump->mpi_global_header.idString));
  682. /* Get generic NIC reg dump */
  683. ql_build_coredump_seg_header(&mpi_coredump->nic_regs_seg_hdr,
  684. NIC1_CONTROL_SEG_NUM,
  685. sizeof(struct mpi_coredump_segment_header) +
  686. sizeof(mpi_coredump->nic_regs), "NIC1 Registers");
  687. ql_build_coredump_seg_header(&mpi_coredump->nic2_regs_seg_hdr,
  688. NIC2_CONTROL_SEG_NUM,
  689. sizeof(struct mpi_coredump_segment_header) +
  690. sizeof(mpi_coredump->nic2_regs), "NIC2 Registers");
  691. /* Get XGMac registers. (Segment 18, Rev C. step 21) */
  692. ql_build_coredump_seg_header(&mpi_coredump->xgmac1_seg_hdr,
  693. NIC1_XGMAC_SEG_NUM,
  694. sizeof(struct mpi_coredump_segment_header) +
  695. sizeof(mpi_coredump->xgmac1), "NIC1 XGMac Registers");
  696. ql_build_coredump_seg_header(&mpi_coredump->xgmac2_seg_hdr,
  697. NIC2_XGMAC_SEG_NUM,
  698. sizeof(struct mpi_coredump_segment_header) +
  699. sizeof(mpi_coredump->xgmac2), "NIC2 XGMac Registers");
  700. if (qdev->func & 1) {
  701. /* Odd means our function is NIC 2 */
  702. for (i = 0; i < NIC_REGS_DUMP_WORD_COUNT; i++)
  703. mpi_coredump->nic2_regs[i] =
  704. ql_read32(qdev, i * sizeof(u32));
  705. for (i = 0; i < NIC_REGS_DUMP_WORD_COUNT; i++)
  706. mpi_coredump->nic_regs[i] =
  707. ql_read_other_func_reg(qdev, (i * sizeof(u32)) / 4);
  708. ql_get_xgmac_regs(qdev, &mpi_coredump->xgmac2[0], 0);
  709. ql_get_xgmac_regs(qdev, &mpi_coredump->xgmac1[0], 1);
  710. } else {
  711. /* Even means our function is NIC 1 */
  712. for (i = 0; i < NIC_REGS_DUMP_WORD_COUNT; i++)
  713. mpi_coredump->nic_regs[i] =
  714. ql_read32(qdev, i * sizeof(u32));
  715. for (i = 0; i < NIC_REGS_DUMP_WORD_COUNT; i++)
  716. mpi_coredump->nic2_regs[i] =
  717. ql_read_other_func_reg(qdev, (i * sizeof(u32)) / 4);
  718. ql_get_xgmac_regs(qdev, &mpi_coredump->xgmac1[0], 0);
  719. ql_get_xgmac_regs(qdev, &mpi_coredump->xgmac2[0], 1);
  720. }
  721. /* Rev C. Step 20a */
  722. ql_build_coredump_seg_header(&mpi_coredump->xaui_an_hdr,
  723. XAUI_AN_SEG_NUM,
  724. sizeof(struct mpi_coredump_segment_header) +
  725. sizeof(mpi_coredump->serdes_xaui_an),
  726. "XAUI AN Registers");
  727. /* Rev C. Step 20b */
  728. ql_build_coredump_seg_header(&mpi_coredump->xaui_hss_pcs_hdr,
  729. XAUI_HSS_PCS_SEG_NUM,
  730. sizeof(struct mpi_coredump_segment_header) +
  731. sizeof(mpi_coredump->serdes_xaui_hss_pcs),
  732. "XAUI HSS PCS Registers");
  733. ql_build_coredump_seg_header(&mpi_coredump->xfi_an_hdr, XFI_AN_SEG_NUM,
  734. sizeof(struct mpi_coredump_segment_header) +
  735. sizeof(mpi_coredump->serdes_xfi_an),
  736. "XFI AN Registers");
  737. ql_build_coredump_seg_header(&mpi_coredump->xfi_train_hdr,
  738. XFI_TRAIN_SEG_NUM,
  739. sizeof(struct mpi_coredump_segment_header) +
  740. sizeof(mpi_coredump->serdes_xfi_train),
  741. "XFI TRAIN Registers");
  742. ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_pcs_hdr,
  743. XFI_HSS_PCS_SEG_NUM,
  744. sizeof(struct mpi_coredump_segment_header) +
  745. sizeof(mpi_coredump->serdes_xfi_hss_pcs),
  746. "XFI HSS PCS Registers");
  747. ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_tx_hdr,
  748. XFI_HSS_TX_SEG_NUM,
  749. sizeof(struct mpi_coredump_segment_header) +
  750. sizeof(mpi_coredump->serdes_xfi_hss_tx),
  751. "XFI HSS TX Registers");
  752. ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_rx_hdr,
  753. XFI_HSS_RX_SEG_NUM,
  754. sizeof(struct mpi_coredump_segment_header) +
  755. sizeof(mpi_coredump->serdes_xfi_hss_rx),
  756. "XFI HSS RX Registers");
  757. ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_pll_hdr,
  758. XFI_HSS_PLL_SEG_NUM,
  759. sizeof(struct mpi_coredump_segment_header) +
  760. sizeof(mpi_coredump->serdes_xfi_hss_pll),
  761. "XFI HSS PLL Registers");
  762. ql_build_coredump_seg_header(&mpi_coredump->xaui2_an_hdr,
  763. XAUI2_AN_SEG_NUM,
  764. sizeof(struct mpi_coredump_segment_header) +
  765. sizeof(mpi_coredump->serdes2_xaui_an),
  766. "XAUI2 AN Registers");
  767. ql_build_coredump_seg_header(&mpi_coredump->xaui2_hss_pcs_hdr,
  768. XAUI2_HSS_PCS_SEG_NUM,
  769. sizeof(struct mpi_coredump_segment_header) +
  770. sizeof(mpi_coredump->serdes2_xaui_hss_pcs),
  771. "XAUI2 HSS PCS Registers");
  772. ql_build_coredump_seg_header(&mpi_coredump->xfi2_an_hdr,
  773. XFI2_AN_SEG_NUM,
  774. sizeof(struct mpi_coredump_segment_header) +
  775. sizeof(mpi_coredump->serdes2_xfi_an),
  776. "XFI2 AN Registers");
  777. ql_build_coredump_seg_header(&mpi_coredump->xfi2_train_hdr,
  778. XFI2_TRAIN_SEG_NUM,
  779. sizeof(struct mpi_coredump_segment_header) +
  780. sizeof(mpi_coredump->serdes2_xfi_train),
  781. "XFI2 TRAIN Registers");
  782. ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_pcs_hdr,
  783. XFI2_HSS_PCS_SEG_NUM,
  784. sizeof(struct mpi_coredump_segment_header) +
  785. sizeof(mpi_coredump->serdes2_xfi_hss_pcs),
  786. "XFI2 HSS PCS Registers");
  787. ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_tx_hdr,
  788. XFI2_HSS_TX_SEG_NUM,
  789. sizeof(struct mpi_coredump_segment_header) +
  790. sizeof(mpi_coredump->serdes2_xfi_hss_tx),
  791. "XFI2 HSS TX Registers");
  792. ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_rx_hdr,
  793. XFI2_HSS_RX_SEG_NUM,
  794. sizeof(struct mpi_coredump_segment_header) +
  795. sizeof(mpi_coredump->serdes2_xfi_hss_rx),
  796. "XFI2 HSS RX Registers");
  797. ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_pll_hdr,
  798. XFI2_HSS_PLL_SEG_NUM,
  799. sizeof(struct mpi_coredump_segment_header) +
  800. sizeof(mpi_coredump->serdes2_xfi_hss_pll),
  801. "XFI2 HSS PLL Registers");
  802. status = ql_get_serdes_regs(qdev, mpi_coredump);
  803. if (status) {
  804. netif_err(qdev, drv, qdev->ndev,
  805. "Failed Dump of Serdes Registers. Status = 0x%.08x\n",
  806. status);
  807. goto err;
  808. }
  809. ql_build_coredump_seg_header(&mpi_coredump->core_regs_seg_hdr,
  810. CORE_SEG_NUM,
  811. sizeof(mpi_coredump->core_regs_seg_hdr) +
  812. sizeof(mpi_coredump->mpi_core_regs) +
  813. sizeof(mpi_coredump->mpi_core_sh_regs),
  814. "Core Registers");
  815. /* Get the MPI Core Registers */
  816. status = ql_get_mpi_regs(qdev, &mpi_coredump->mpi_core_regs[0],
  817. MPI_CORE_REGS_ADDR, MPI_CORE_REGS_CNT);
  818. if (status)
  819. goto err;
  820. /* Get the 16 MPI shadow registers */
  821. status = ql_get_mpi_shadow_regs(qdev,
  822. &mpi_coredump->mpi_core_sh_regs[0]);
  823. if (status)
  824. goto err;
  825. /* Get the Test Logic Registers */
  826. ql_build_coredump_seg_header(&mpi_coredump->test_logic_regs_seg_hdr,
  827. TEST_LOGIC_SEG_NUM,
  828. sizeof(struct mpi_coredump_segment_header)
  829. + sizeof(mpi_coredump->test_logic_regs),
  830. "Test Logic Regs");
  831. status = ql_get_mpi_regs(qdev, &mpi_coredump->test_logic_regs[0],
  832. TEST_REGS_ADDR, TEST_REGS_CNT);
  833. if (status)
  834. goto err;
  835. /* Get the RMII Registers */
  836. ql_build_coredump_seg_header(&mpi_coredump->rmii_regs_seg_hdr,
  837. RMII_SEG_NUM,
  838. sizeof(struct mpi_coredump_segment_header)
  839. + sizeof(mpi_coredump->rmii_regs),
  840. "RMII Registers");
  841. status = ql_get_mpi_regs(qdev, &mpi_coredump->rmii_regs[0],
  842. RMII_REGS_ADDR, RMII_REGS_CNT);
  843. if (status)
  844. goto err;
  845. /* Get the FCMAC1 Registers */
  846. ql_build_coredump_seg_header(&mpi_coredump->fcmac1_regs_seg_hdr,
  847. FCMAC1_SEG_NUM,
  848. sizeof(struct mpi_coredump_segment_header)
  849. + sizeof(mpi_coredump->fcmac1_regs),
  850. "FCMAC1 Registers");
  851. status = ql_get_mpi_regs(qdev, &mpi_coredump->fcmac1_regs[0],
  852. FCMAC1_REGS_ADDR, FCMAC_REGS_CNT);
  853. if (status)
  854. goto err;
  855. /* Get the FCMAC2 Registers */
  856. ql_build_coredump_seg_header(&mpi_coredump->fcmac2_regs_seg_hdr,
  857. FCMAC2_SEG_NUM,
  858. sizeof(struct mpi_coredump_segment_header)
  859. + sizeof(mpi_coredump->fcmac2_regs),
  860. "FCMAC2 Registers");
  861. status = ql_get_mpi_regs(qdev, &mpi_coredump->fcmac2_regs[0],
  862. FCMAC2_REGS_ADDR, FCMAC_REGS_CNT);
  863. if (status)
  864. goto err;
  865. /* Get the FC1 MBX Registers */
  866. ql_build_coredump_seg_header(&mpi_coredump->fc1_mbx_regs_seg_hdr,
  867. FC1_MBOX_SEG_NUM,
  868. sizeof(struct mpi_coredump_segment_header)
  869. + sizeof(mpi_coredump->fc1_mbx_regs),
  870. "FC1 MBox Regs");
  871. status = ql_get_mpi_regs(qdev, &mpi_coredump->fc1_mbx_regs[0],
  872. FC1_MBX_REGS_ADDR, FC_MBX_REGS_CNT);
  873. if (status)
  874. goto err;
  875. /* Get the IDE Registers */
  876. ql_build_coredump_seg_header(&mpi_coredump->ide_regs_seg_hdr,
  877. IDE_SEG_NUM,
  878. sizeof(struct mpi_coredump_segment_header)
  879. + sizeof(mpi_coredump->ide_regs),
  880. "IDE Registers");
  881. status = ql_get_mpi_regs(qdev, &mpi_coredump->ide_regs[0],
  882. IDE_REGS_ADDR, IDE_REGS_CNT);
  883. if (status)
  884. goto err;
  885. /* Get the NIC1 MBX Registers */
  886. ql_build_coredump_seg_header(&mpi_coredump->nic1_mbx_regs_seg_hdr,
  887. NIC1_MBOX_SEG_NUM,
  888. sizeof(struct mpi_coredump_segment_header)
  889. + sizeof(mpi_coredump->nic1_mbx_regs),
  890. "NIC1 MBox Regs");
  891. status = ql_get_mpi_regs(qdev, &mpi_coredump->nic1_mbx_regs[0],
  892. NIC1_MBX_REGS_ADDR, NIC_MBX_REGS_CNT);
  893. if (status)
  894. goto err;
  895. /* Get the SMBus Registers */
  896. ql_build_coredump_seg_header(&mpi_coredump->smbus_regs_seg_hdr,
  897. SMBUS_SEG_NUM,
  898. sizeof(struct mpi_coredump_segment_header)
  899. + sizeof(mpi_coredump->smbus_regs),
  900. "SMBus Registers");
  901. status = ql_get_mpi_regs(qdev, &mpi_coredump->smbus_regs[0],
  902. SMBUS_REGS_ADDR, SMBUS_REGS_CNT);
  903. if (status)
  904. goto err;
  905. /* Get the FC2 MBX Registers */
  906. ql_build_coredump_seg_header(&mpi_coredump->fc2_mbx_regs_seg_hdr,
  907. FC2_MBOX_SEG_NUM,
  908. sizeof(struct mpi_coredump_segment_header)
  909. + sizeof(mpi_coredump->fc2_mbx_regs),
  910. "FC2 MBox Regs");
  911. status = ql_get_mpi_regs(qdev, &mpi_coredump->fc2_mbx_regs[0],
  912. FC2_MBX_REGS_ADDR, FC_MBX_REGS_CNT);
  913. if (status)
  914. goto err;
  915. /* Get the NIC2 MBX Registers */
  916. ql_build_coredump_seg_header(&mpi_coredump->nic2_mbx_regs_seg_hdr,
  917. NIC2_MBOX_SEG_NUM,
  918. sizeof(struct mpi_coredump_segment_header)
  919. + sizeof(mpi_coredump->nic2_mbx_regs),
  920. "NIC2 MBox Regs");
  921. status = ql_get_mpi_regs(qdev, &mpi_coredump->nic2_mbx_regs[0],
  922. NIC2_MBX_REGS_ADDR, NIC_MBX_REGS_CNT);
  923. if (status)
  924. goto err;
  925. /* Get the I2C Registers */
  926. ql_build_coredump_seg_header(&mpi_coredump->i2c_regs_seg_hdr,
  927. I2C_SEG_NUM,
  928. sizeof(struct mpi_coredump_segment_header)
  929. + sizeof(mpi_coredump->i2c_regs),
  930. "I2C Registers");
  931. status = ql_get_mpi_regs(qdev, &mpi_coredump->i2c_regs[0],
  932. I2C_REGS_ADDR, I2C_REGS_CNT);
  933. if (status)
  934. goto err;
  935. /* Get the MEMC Registers */
  936. ql_build_coredump_seg_header(&mpi_coredump->memc_regs_seg_hdr,
  937. MEMC_SEG_NUM,
  938. sizeof(struct mpi_coredump_segment_header)
  939. + sizeof(mpi_coredump->memc_regs),
  940. "MEMC Registers");
  941. status = ql_get_mpi_regs(qdev, &mpi_coredump->memc_regs[0],
  942. MEMC_REGS_ADDR, MEMC_REGS_CNT);
  943. if (status)
  944. goto err;
  945. /* Get the PBus Registers */
  946. ql_build_coredump_seg_header(&mpi_coredump->pbus_regs_seg_hdr,
  947. PBUS_SEG_NUM,
  948. sizeof(struct mpi_coredump_segment_header)
  949. + sizeof(mpi_coredump->pbus_regs),
  950. "PBUS Registers");
  951. status = ql_get_mpi_regs(qdev, &mpi_coredump->pbus_regs[0],
  952. PBUS_REGS_ADDR, PBUS_REGS_CNT);
  953. if (status)
  954. goto err;
  955. /* Get the MDE Registers */
  956. ql_build_coredump_seg_header(&mpi_coredump->mde_regs_seg_hdr,
  957. MDE_SEG_NUM,
  958. sizeof(struct mpi_coredump_segment_header)
  959. + sizeof(mpi_coredump->mde_regs),
  960. "MDE Registers");
  961. status = ql_get_mpi_regs(qdev, &mpi_coredump->mde_regs[0],
  962. MDE_REGS_ADDR, MDE_REGS_CNT);
  963. if (status)
  964. goto err;
  965. ql_build_coredump_seg_header(&mpi_coredump->misc_nic_seg_hdr,
  966. MISC_NIC_INFO_SEG_NUM,
  967. sizeof(struct mpi_coredump_segment_header)
  968. + sizeof(mpi_coredump->misc_nic_info),
  969. "MISC NIC INFO");
  970. mpi_coredump->misc_nic_info.rx_ring_count = qdev->rx_ring_count;
  971. mpi_coredump->misc_nic_info.tx_ring_count = qdev->tx_ring_count;
  972. mpi_coredump->misc_nic_info.intr_count = qdev->intr_count;
  973. mpi_coredump->misc_nic_info.function = qdev->func;
  974. /* Segment 31 */
  975. /* Get indexed register values. */
  976. ql_build_coredump_seg_header(&mpi_coredump->intr_states_seg_hdr,
  977. INTR_STATES_SEG_NUM,
  978. sizeof(struct mpi_coredump_segment_header)
  979. + sizeof(mpi_coredump->intr_states),
  980. "INTR States");
  981. ql_get_intr_states(qdev, &mpi_coredump->intr_states[0]);
  982. ql_build_coredump_seg_header(&mpi_coredump->cam_entries_seg_hdr,
  983. CAM_ENTRIES_SEG_NUM,
  984. sizeof(struct mpi_coredump_segment_header)
  985. + sizeof(mpi_coredump->cam_entries),
  986. "CAM Entries");
  987. status = ql_get_cam_entries(qdev, &mpi_coredump->cam_entries[0]);
  988. if (status)
  989. goto err;
  990. ql_build_coredump_seg_header(&mpi_coredump->nic_routing_words_seg_hdr,
  991. ROUTING_WORDS_SEG_NUM,
  992. sizeof(struct mpi_coredump_segment_header)
  993. + sizeof(mpi_coredump->nic_routing_words),
  994. "Routing Words");
  995. status = ql_get_routing_entries(qdev,
  996. &mpi_coredump->nic_routing_words[0]);
  997. if (status)
  998. goto err;
  999. /* Segment 34 (Rev C. step 23) */
  1000. ql_build_coredump_seg_header(&mpi_coredump->ets_seg_hdr,
  1001. ETS_SEG_NUM,
  1002. sizeof(struct mpi_coredump_segment_header)
  1003. + sizeof(mpi_coredump->ets),
  1004. "ETS Registers");
  1005. status = ql_get_ets_regs(qdev, &mpi_coredump->ets[0]);
  1006. if (status)
  1007. goto err;
  1008. ql_build_coredump_seg_header(&mpi_coredump->probe_dump_seg_hdr,
  1009. PROBE_DUMP_SEG_NUM,
  1010. sizeof(struct mpi_coredump_segment_header)
  1011. + sizeof(mpi_coredump->probe_dump),
  1012. "Probe Dump");
  1013. ql_get_probe_dump(qdev, &mpi_coredump->probe_dump[0]);
  1014. ql_build_coredump_seg_header(&mpi_coredump->routing_reg_seg_hdr,
  1015. ROUTING_INDEX_SEG_NUM,
  1016. sizeof(struct mpi_coredump_segment_header)
  1017. + sizeof(mpi_coredump->routing_regs),
  1018. "Routing Regs");
  1019. status = ql_get_routing_index_registers(qdev,
  1020. &mpi_coredump->routing_regs[0]);
  1021. if (status)
  1022. goto err;
  1023. ql_build_coredump_seg_header(&mpi_coredump->mac_prot_reg_seg_hdr,
  1024. MAC_PROTOCOL_SEG_NUM,
  1025. sizeof(struct mpi_coredump_segment_header)
  1026. + sizeof(mpi_coredump->mac_prot_regs),
  1027. "MAC Prot Regs");
  1028. ql_get_mac_protocol_registers(qdev, &mpi_coredump->mac_prot_regs[0]);
  1029. /* Get the semaphore registers for all 5 functions */
  1030. ql_build_coredump_seg_header(&mpi_coredump->sem_regs_seg_hdr,
  1031. SEM_REGS_SEG_NUM,
  1032. sizeof(struct mpi_coredump_segment_header) +
  1033. sizeof(mpi_coredump->sem_regs), "Sem Registers");
  1034. ql_get_sem_registers(qdev, &mpi_coredump->sem_regs[0]);
  1035. /* Prevent the mpi restarting while we dump the memory.*/
  1036. ql_write_mpi_reg(qdev, MPI_TEST_FUNC_RST_STS, MPI_TEST_FUNC_RST_FRC);
  1037. /* clear the pause */
  1038. status = ql_unpause_mpi_risc(qdev);
  1039. if (status) {
  1040. netif_err(qdev, drv, qdev->ndev,
  1041. "Failed RISC unpause. Status = 0x%.08x\n", status);
  1042. goto err;
  1043. }
  1044. /* Reset the RISC so we can dump RAM */
  1045. status = ql_hard_reset_mpi_risc(qdev);
  1046. if (status) {
  1047. netif_err(qdev, drv, qdev->ndev,
  1048. "Failed RISC reset. Status = 0x%.08x\n", status);
  1049. goto err;
  1050. }
  1051. ql_build_coredump_seg_header(&mpi_coredump->code_ram_seg_hdr,
  1052. WCS_RAM_SEG_NUM,
  1053. sizeof(struct mpi_coredump_segment_header)
  1054. + sizeof(mpi_coredump->code_ram),
  1055. "WCS RAM");
  1056. status = ql_dump_risc_ram_area(qdev, &mpi_coredump->code_ram[0],
  1057. CODE_RAM_ADDR, CODE_RAM_CNT);
  1058. if (status) {
  1059. netif_err(qdev, drv, qdev->ndev,
  1060. "Failed Dump of CODE RAM. Status = 0x%.08x\n",
  1061. status);
  1062. goto err;
  1063. }
  1064. /* Insert the segment header */
  1065. ql_build_coredump_seg_header(&mpi_coredump->memc_ram_seg_hdr,
  1066. MEMC_RAM_SEG_NUM,
  1067. sizeof(struct mpi_coredump_segment_header)
  1068. + sizeof(mpi_coredump->memc_ram),
  1069. "MEMC RAM");
  1070. status = ql_dump_risc_ram_area(qdev, &mpi_coredump->memc_ram[0],
  1071. MEMC_RAM_ADDR, MEMC_RAM_CNT);
  1072. if (status) {
  1073. netif_err(qdev, drv, qdev->ndev,
  1074. "Failed Dump of MEMC RAM. Status = 0x%.08x\n",
  1075. status);
  1076. goto err;
  1077. }
  1078. err:
  1079. ql_sem_unlock(qdev, SEM_PROC_REG_MASK); /* does flush too */
  1080. return status;
  1081. }
  1082. static void ql_get_core_dump(struct ql_adapter *qdev)
  1083. {
  1084. if (!ql_own_firmware(qdev)) {
  1085. netif_err(qdev, drv, qdev->ndev, "Don't own firmware!\n");
  1086. return;
  1087. }
  1088. if (!netif_running(qdev->ndev)) {
  1089. netif_err(qdev, ifup, qdev->ndev,
  1090. "Force Coredump can only be done from interface that is up\n");
  1091. return;
  1092. }
  1093. ql_queue_fw_error(qdev);
  1094. }
  1095. static void ql_gen_reg_dump(struct ql_adapter *qdev,
  1096. struct ql_reg_dump *mpi_coredump)
  1097. {
  1098. int i, status;
  1099. memset(&(mpi_coredump->mpi_global_header), 0,
  1100. sizeof(struct mpi_coredump_global_header));
  1101. mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE;
  1102. mpi_coredump->mpi_global_header.headerSize =
  1103. sizeof(struct mpi_coredump_global_header);
  1104. mpi_coredump->mpi_global_header.imageSize =
  1105. sizeof(struct ql_reg_dump);
  1106. strncpy(mpi_coredump->mpi_global_header.idString, "MPI Coredump",
  1107. sizeof(mpi_coredump->mpi_global_header.idString));
  1108. /* segment 16 */
  1109. ql_build_coredump_seg_header(&mpi_coredump->misc_nic_seg_hdr,
  1110. MISC_NIC_INFO_SEG_NUM,
  1111. sizeof(struct mpi_coredump_segment_header)
  1112. + sizeof(mpi_coredump->misc_nic_info),
  1113. "MISC NIC INFO");
  1114. mpi_coredump->misc_nic_info.rx_ring_count = qdev->rx_ring_count;
  1115. mpi_coredump->misc_nic_info.tx_ring_count = qdev->tx_ring_count;
  1116. mpi_coredump->misc_nic_info.intr_count = qdev->intr_count;
  1117. mpi_coredump->misc_nic_info.function = qdev->func;
  1118. /* Segment 16, Rev C. Step 18 */
  1119. ql_build_coredump_seg_header(&mpi_coredump->nic_regs_seg_hdr,
  1120. NIC1_CONTROL_SEG_NUM,
  1121. sizeof(struct mpi_coredump_segment_header)
  1122. + sizeof(mpi_coredump->nic_regs),
  1123. "NIC Registers");
  1124. /* Get generic reg dump */
  1125. for (i = 0; i < 64; i++)
  1126. mpi_coredump->nic_regs[i] = ql_read32(qdev, i * sizeof(u32));
  1127. /* Segment 31 */
  1128. /* Get indexed register values. */
  1129. ql_build_coredump_seg_header(&mpi_coredump->intr_states_seg_hdr,
  1130. INTR_STATES_SEG_NUM,
  1131. sizeof(struct mpi_coredump_segment_header)
  1132. + sizeof(mpi_coredump->intr_states),
  1133. "INTR States");
  1134. ql_get_intr_states(qdev, &mpi_coredump->intr_states[0]);
  1135. ql_build_coredump_seg_header(&mpi_coredump->cam_entries_seg_hdr,
  1136. CAM_ENTRIES_SEG_NUM,
  1137. sizeof(struct mpi_coredump_segment_header)
  1138. + sizeof(mpi_coredump->cam_entries),
  1139. "CAM Entries");
  1140. status = ql_get_cam_entries(qdev, &mpi_coredump->cam_entries[0]);
  1141. if (status)
  1142. return;
  1143. ql_build_coredump_seg_header(&mpi_coredump->nic_routing_words_seg_hdr,
  1144. ROUTING_WORDS_SEG_NUM,
  1145. sizeof(struct mpi_coredump_segment_header)
  1146. + sizeof(mpi_coredump->nic_routing_words),
  1147. "Routing Words");
  1148. status = ql_get_routing_entries(qdev,
  1149. &mpi_coredump->nic_routing_words[0]);
  1150. if (status)
  1151. return;
  1152. /* Segment 34 (Rev C. step 23) */
  1153. ql_build_coredump_seg_header(&mpi_coredump->ets_seg_hdr,
  1154. ETS_SEG_NUM,
  1155. sizeof(struct mpi_coredump_segment_header)
  1156. + sizeof(mpi_coredump->ets),
  1157. "ETS Registers");
  1158. status = ql_get_ets_regs(qdev, &mpi_coredump->ets[0]);
  1159. if (status)
  1160. return;
  1161. }
  1162. void ql_get_dump(struct ql_adapter *qdev, void *buff)
  1163. {
  1164. /*
  1165. * If the dump has already been taken and is stored
  1166. * in our internal buffer and if force dump is set then
  1167. * just start the spool to dump it to the log file
  1168. * and also, take a snapshot of the general regs to
  1169. * to the user's buffer or else take complete dump
  1170. * to the user's buffer if force is not set.
  1171. */
  1172. if (!test_bit(QL_FRC_COREDUMP, &qdev->flags)) {
  1173. if (!ql_core_dump(qdev, buff))
  1174. ql_soft_reset_mpi_risc(qdev);
  1175. else
  1176. netif_err(qdev, drv, qdev->ndev, "coredump failed!\n");
  1177. } else {
  1178. ql_gen_reg_dump(qdev, buff);
  1179. ql_get_core_dump(qdev);
  1180. }
  1181. }
  1182. /* Coredump to messages log file using separate worker thread */
  1183. void ql_mpi_core_to_log(struct work_struct *work)
  1184. {
  1185. struct ql_adapter *qdev =
  1186. container_of(work, struct ql_adapter, mpi_core_to_log.work);
  1187. u32 *tmp, count;
  1188. int i;
  1189. count = sizeof(struct ql_mpi_coredump) / sizeof(u32);
  1190. tmp = (u32 *)qdev->mpi_coredump;
  1191. netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev,
  1192. "Core is dumping to log file!\n");
  1193. for (i = 0; i < count; i += 8) {
  1194. pr_err("%.08x: %.08x %.08x %.08x %.08x %.08x "
  1195. "%.08x %.08x %.08x\n", i,
  1196. tmp[i + 0],
  1197. tmp[i + 1],
  1198. tmp[i + 2],
  1199. tmp[i + 3],
  1200. tmp[i + 4],
  1201. tmp[i + 5],
  1202. tmp[i + 6],
  1203. tmp[i + 7]);
  1204. msleep(5);
  1205. }
  1206. }
  1207. #ifdef QL_REG_DUMP
  1208. static void ql_dump_intr_states(struct ql_adapter *qdev)
  1209. {
  1210. int i;
  1211. u32 value;
  1212. for (i = 0; i < qdev->intr_count; i++) {
  1213. ql_write32(qdev, INTR_EN, qdev->intr_context[i].intr_read_mask);
  1214. value = ql_read32(qdev, INTR_EN);
  1215. pr_err("%s: Interrupt %d is %s\n",
  1216. qdev->ndev->name, i,
  1217. (value & INTR_EN_EN ? "enabled" : "disabled"));
  1218. }
  1219. }
  1220. #define DUMP_XGMAC(qdev, reg) \
  1221. do { \
  1222. u32 data; \
  1223. ql_read_xgmac_reg(qdev, reg, &data); \
  1224. pr_err("%s: %s = 0x%.08x\n", qdev->ndev->name, #reg, data); \
  1225. } while (0)
  1226. void ql_dump_xgmac_control_regs(struct ql_adapter *qdev)
  1227. {
  1228. if (ql_sem_spinlock(qdev, qdev->xg_sem_mask)) {
  1229. pr_err("%s: Couldn't get xgmac sem\n", __func__);
  1230. return;
  1231. }
  1232. DUMP_XGMAC(qdev, PAUSE_SRC_LO);
  1233. DUMP_XGMAC(qdev, PAUSE_SRC_HI);
  1234. DUMP_XGMAC(qdev, GLOBAL_CFG);
  1235. DUMP_XGMAC(qdev, TX_CFG);
  1236. DUMP_XGMAC(qdev, RX_CFG);
  1237. DUMP_XGMAC(qdev, FLOW_CTL);
  1238. DUMP_XGMAC(qdev, PAUSE_OPCODE);
  1239. DUMP_XGMAC(qdev, PAUSE_TIMER);
  1240. DUMP_XGMAC(qdev, PAUSE_FRM_DEST_LO);
  1241. DUMP_XGMAC(qdev, PAUSE_FRM_DEST_HI);
  1242. DUMP_XGMAC(qdev, MAC_TX_PARAMS);
  1243. DUMP_XGMAC(qdev, MAC_RX_PARAMS);
  1244. DUMP_XGMAC(qdev, MAC_SYS_INT);
  1245. DUMP_XGMAC(qdev, MAC_SYS_INT_MASK);
  1246. DUMP_XGMAC(qdev, MAC_MGMT_INT);
  1247. DUMP_XGMAC(qdev, MAC_MGMT_IN_MASK);
  1248. DUMP_XGMAC(qdev, EXT_ARB_MODE);
  1249. ql_sem_unlock(qdev, qdev->xg_sem_mask);
  1250. }
  1251. static void ql_dump_ets_regs(struct ql_adapter *qdev)
  1252. {
  1253. }
  1254. static void ql_dump_cam_entries(struct ql_adapter *qdev)
  1255. {
  1256. int i;
  1257. u32 value[3];
  1258. i = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
  1259. if (i)
  1260. return;
  1261. for (i = 0; i < 4; i++) {
  1262. if (ql_get_mac_addr_reg(qdev, MAC_ADDR_TYPE_CAM_MAC, i, value)) {
  1263. pr_err("%s: Failed read of mac index register\n",
  1264. __func__);
  1265. return;
  1266. } else {
  1267. if (value[0])
  1268. pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n",
  1269. qdev->ndev->name, i, value[1], value[0],
  1270. value[2]);
  1271. }
  1272. }
  1273. for (i = 0; i < 32; i++) {
  1274. if (ql_get_mac_addr_reg
  1275. (qdev, MAC_ADDR_TYPE_MULTI_MAC, i, value)) {
  1276. pr_err("%s: Failed read of mac index register\n",
  1277. __func__);
  1278. return;
  1279. } else {
  1280. if (value[0])
  1281. pr_err("%s: MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n",
  1282. qdev->ndev->name, i, value[1], value[0]);
  1283. }
  1284. }
  1285. ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
  1286. }
  1287. void ql_dump_routing_entries(struct ql_adapter *qdev)
  1288. {
  1289. int i;
  1290. u32 value;
  1291. i = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
  1292. if (i)
  1293. return;
  1294. for (i = 0; i < 16; i++) {
  1295. value = 0;
  1296. if (ql_get_routing_reg(qdev, i, &value)) {
  1297. pr_err("%s: Failed read of routing index register\n",
  1298. __func__);
  1299. return;
  1300. } else {
  1301. if (value)
  1302. pr_err("%s: Routing Mask %d = 0x%.08x\n",
  1303. qdev->ndev->name, i, value);
  1304. }
  1305. }
  1306. ql_sem_unlock(qdev, SEM_RT_IDX_MASK);
  1307. }
  1308. #define DUMP_REG(qdev, reg) \
  1309. pr_err("%-32s= 0x%x\n", #reg, ql_read32(qdev, reg))
  1310. void ql_dump_regs(struct ql_adapter *qdev)
  1311. {
  1312. pr_err("reg dump for function #%d\n", qdev->func);
  1313. DUMP_REG(qdev, SYS);
  1314. DUMP_REG(qdev, RST_FO);
  1315. DUMP_REG(qdev, FSC);
  1316. DUMP_REG(qdev, CSR);
  1317. DUMP_REG(qdev, ICB_RID);
  1318. DUMP_REG(qdev, ICB_L);
  1319. DUMP_REG(qdev, ICB_H);
  1320. DUMP_REG(qdev, CFG);
  1321. DUMP_REG(qdev, BIOS_ADDR);
  1322. DUMP_REG(qdev, STS);
  1323. DUMP_REG(qdev, INTR_EN);
  1324. DUMP_REG(qdev, INTR_MASK);
  1325. DUMP_REG(qdev, ISR1);
  1326. DUMP_REG(qdev, ISR2);
  1327. DUMP_REG(qdev, ISR3);
  1328. DUMP_REG(qdev, ISR4);
  1329. DUMP_REG(qdev, REV_ID);
  1330. DUMP_REG(qdev, FRC_ECC_ERR);
  1331. DUMP_REG(qdev, ERR_STS);
  1332. DUMP_REG(qdev, RAM_DBG_ADDR);
  1333. DUMP_REG(qdev, RAM_DBG_DATA);
  1334. DUMP_REG(qdev, ECC_ERR_CNT);
  1335. DUMP_REG(qdev, SEM);
  1336. DUMP_REG(qdev, GPIO_1);
  1337. DUMP_REG(qdev, GPIO_2);
  1338. DUMP_REG(qdev, GPIO_3);
  1339. DUMP_REG(qdev, XGMAC_ADDR);
  1340. DUMP_REG(qdev, XGMAC_DATA);
  1341. DUMP_REG(qdev, NIC_ETS);
  1342. DUMP_REG(qdev, CNA_ETS);
  1343. DUMP_REG(qdev, FLASH_ADDR);
  1344. DUMP_REG(qdev, FLASH_DATA);
  1345. DUMP_REG(qdev, CQ_STOP);
  1346. DUMP_REG(qdev, PAGE_TBL_RID);
  1347. DUMP_REG(qdev, WQ_PAGE_TBL_LO);
  1348. DUMP_REG(qdev, WQ_PAGE_TBL_HI);
  1349. DUMP_REG(qdev, CQ_PAGE_TBL_LO);
  1350. DUMP_REG(qdev, CQ_PAGE_TBL_HI);
  1351. DUMP_REG(qdev, COS_DFLT_CQ1);
  1352. DUMP_REG(qdev, COS_DFLT_CQ2);
  1353. DUMP_REG(qdev, SPLT_HDR);
  1354. DUMP_REG(qdev, FC_PAUSE_THRES);
  1355. DUMP_REG(qdev, NIC_PAUSE_THRES);
  1356. DUMP_REG(qdev, FC_ETHERTYPE);
  1357. DUMP_REG(qdev, FC_RCV_CFG);
  1358. DUMP_REG(qdev, NIC_RCV_CFG);
  1359. DUMP_REG(qdev, FC_COS_TAGS);
  1360. DUMP_REG(qdev, NIC_COS_TAGS);
  1361. DUMP_REG(qdev, MGMT_RCV_CFG);
  1362. DUMP_REG(qdev, XG_SERDES_ADDR);
  1363. DUMP_REG(qdev, XG_SERDES_DATA);
  1364. DUMP_REG(qdev, PRB_MX_ADDR);
  1365. DUMP_REG(qdev, PRB_MX_DATA);
  1366. ql_dump_intr_states(qdev);
  1367. ql_dump_xgmac_control_regs(qdev);
  1368. ql_dump_ets_regs(qdev);
  1369. ql_dump_cam_entries(qdev);
  1370. ql_dump_routing_entries(qdev);
  1371. }
  1372. #endif
  1373. #ifdef QL_STAT_DUMP
  1374. #define DUMP_STAT(qdev, stat) \
  1375. pr_err("%s = %ld\n", #stat, (unsigned long)qdev->nic_stats.stat)
  1376. void ql_dump_stat(struct ql_adapter *qdev)
  1377. {
  1378. pr_err("%s: Enter\n", __func__);
  1379. DUMP_STAT(qdev, tx_pkts);
  1380. DUMP_STAT(qdev, tx_bytes);
  1381. DUMP_STAT(qdev, tx_mcast_pkts);
  1382. DUMP_STAT(qdev, tx_bcast_pkts);
  1383. DUMP_STAT(qdev, tx_ucast_pkts);
  1384. DUMP_STAT(qdev, tx_ctl_pkts);
  1385. DUMP_STAT(qdev, tx_pause_pkts);
  1386. DUMP_STAT(qdev, tx_64_pkt);
  1387. DUMP_STAT(qdev, tx_65_to_127_pkt);
  1388. DUMP_STAT(qdev, tx_128_to_255_pkt);
  1389. DUMP_STAT(qdev, tx_256_511_pkt);
  1390. DUMP_STAT(qdev, tx_512_to_1023_pkt);
  1391. DUMP_STAT(qdev, tx_1024_to_1518_pkt);
  1392. DUMP_STAT(qdev, tx_1519_to_max_pkt);
  1393. DUMP_STAT(qdev, tx_undersize_pkt);
  1394. DUMP_STAT(qdev, tx_oversize_pkt);
  1395. DUMP_STAT(qdev, rx_bytes);
  1396. DUMP_STAT(qdev, rx_bytes_ok);
  1397. DUMP_STAT(qdev, rx_pkts);
  1398. DUMP_STAT(qdev, rx_pkts_ok);
  1399. DUMP_STAT(qdev, rx_bcast_pkts);
  1400. DUMP_STAT(qdev, rx_mcast_pkts);
  1401. DUMP_STAT(qdev, rx_ucast_pkts);
  1402. DUMP_STAT(qdev, rx_undersize_pkts);
  1403. DUMP_STAT(qdev, rx_oversize_pkts);
  1404. DUMP_STAT(qdev, rx_jabber_pkts);
  1405. DUMP_STAT(qdev, rx_undersize_fcerr_pkts);
  1406. DUMP_STAT(qdev, rx_drop_events);
  1407. DUMP_STAT(qdev, rx_fcerr_pkts);
  1408. DUMP_STAT(qdev, rx_align_err);
  1409. DUMP_STAT(qdev, rx_symbol_err);
  1410. DUMP_STAT(qdev, rx_mac_err);
  1411. DUMP_STAT(qdev, rx_ctl_pkts);
  1412. DUMP_STAT(qdev, rx_pause_pkts);
  1413. DUMP_STAT(qdev, rx_64_pkts);
  1414. DUMP_STAT(qdev, rx_65_to_127_pkts);
  1415. DUMP_STAT(qdev, rx_128_255_pkts);
  1416. DUMP_STAT(qdev, rx_256_511_pkts);
  1417. DUMP_STAT(qdev, rx_512_to_1023_pkts);
  1418. DUMP_STAT(qdev, rx_1024_to_1518_pkts);
  1419. DUMP_STAT(qdev, rx_1519_to_max_pkts);
  1420. DUMP_STAT(qdev, rx_len_err_pkts);
  1421. };
  1422. #endif
  1423. #ifdef QL_DEV_DUMP
  1424. #define DUMP_QDEV_FIELD(qdev, type, field) \
  1425. pr_err("qdev->%-24s = " type "\n", #field, qdev->field)
  1426. #define DUMP_QDEV_DMA_FIELD(qdev, field) \
  1427. pr_err("qdev->%-24s = %llx\n", #field, (unsigned long long)qdev->field)
  1428. #define DUMP_QDEV_ARRAY(qdev, type, array, index, field) \
  1429. pr_err("%s[%d].%s = " type "\n", \
  1430. #array, index, #field, qdev->array[index].field);
  1431. void ql_dump_qdev(struct ql_adapter *qdev)
  1432. {
  1433. int i;
  1434. DUMP_QDEV_FIELD(qdev, "%lx", flags);
  1435. DUMP_QDEV_FIELD(qdev, "%p", vlgrp);
  1436. DUMP_QDEV_FIELD(qdev, "%p", pdev);
  1437. DUMP_QDEV_FIELD(qdev, "%p", ndev);
  1438. DUMP_QDEV_FIELD(qdev, "%d", chip_rev_id);
  1439. DUMP_QDEV_FIELD(qdev, "%p", reg_base);
  1440. DUMP_QDEV_FIELD(qdev, "%p", doorbell_area);
  1441. DUMP_QDEV_FIELD(qdev, "%d", doorbell_area_size);
  1442. DUMP_QDEV_FIELD(qdev, "%x", msg_enable);
  1443. DUMP_QDEV_FIELD(qdev, "%p", rx_ring_shadow_reg_area);
  1444. DUMP_QDEV_DMA_FIELD(qdev, rx_ring_shadow_reg_dma);
  1445. DUMP_QDEV_FIELD(qdev, "%p", tx_ring_shadow_reg_area);
  1446. DUMP_QDEV_DMA_FIELD(qdev, tx_ring_shadow_reg_dma);
  1447. DUMP_QDEV_FIELD(qdev, "%d", intr_count);
  1448. if (qdev->msi_x_entry)
  1449. for (i = 0; i < qdev->intr_count; i++) {
  1450. DUMP_QDEV_ARRAY(qdev, "%d", msi_x_entry, i, vector);
  1451. DUMP_QDEV_ARRAY(qdev, "%d", msi_x_entry, i, entry);
  1452. }
  1453. for (i = 0; i < qdev->intr_count; i++) {
  1454. DUMP_QDEV_ARRAY(qdev, "%p", intr_context, i, qdev);
  1455. DUMP_QDEV_ARRAY(qdev, "%d", intr_context, i, intr);
  1456. DUMP_QDEV_ARRAY(qdev, "%d", intr_context, i, hooked);
  1457. DUMP_QDEV_ARRAY(qdev, "0x%08x", intr_context, i, intr_en_mask);
  1458. DUMP_QDEV_ARRAY(qdev, "0x%08x", intr_context, i, intr_dis_mask);
  1459. DUMP_QDEV_ARRAY(qdev, "0x%08x", intr_context, i, intr_read_mask);
  1460. }
  1461. DUMP_QDEV_FIELD(qdev, "%d", tx_ring_count);
  1462. DUMP_QDEV_FIELD(qdev, "%d", rx_ring_count);
  1463. DUMP_QDEV_FIELD(qdev, "%d", ring_mem_size);
  1464. DUMP_QDEV_FIELD(qdev, "%p", ring_mem);
  1465. DUMP_QDEV_FIELD(qdev, "%d", intr_count);
  1466. DUMP_QDEV_FIELD(qdev, "%p", tx_ring);
  1467. DUMP_QDEV_FIELD(qdev, "%d", rss_ring_count);
  1468. DUMP_QDEV_FIELD(qdev, "%p", rx_ring);
  1469. DUMP_QDEV_FIELD(qdev, "%d", default_rx_queue);
  1470. DUMP_QDEV_FIELD(qdev, "0x%08x", xg_sem_mask);
  1471. DUMP_QDEV_FIELD(qdev, "0x%08x", port_link_up);
  1472. DUMP_QDEV_FIELD(qdev, "0x%08x", port_init);
  1473. }
  1474. #endif
  1475. #ifdef QL_CB_DUMP
  1476. void ql_dump_wqicb(struct wqicb *wqicb)
  1477. {
  1478. pr_err("Dumping wqicb stuff...\n");
  1479. pr_err("wqicb->len = 0x%x\n", le16_to_cpu(wqicb->len));
  1480. pr_err("wqicb->flags = %x\n", le16_to_cpu(wqicb->flags));
  1481. pr_err("wqicb->cq_id_rss = %d\n",
  1482. le16_to_cpu(wqicb->cq_id_rss));
  1483. pr_err("wqicb->rid = 0x%x\n", le16_to_cpu(wqicb->rid));
  1484. pr_err("wqicb->wq_addr = 0x%llx\n",
  1485. (unsigned long long) le64_to_cpu(wqicb->addr));
  1486. pr_err("wqicb->wq_cnsmr_idx_addr = 0x%llx\n",
  1487. (unsigned long long) le64_to_cpu(wqicb->cnsmr_idx_addr));
  1488. }
  1489. void ql_dump_tx_ring(struct tx_ring *tx_ring)
  1490. {
  1491. if (tx_ring == NULL)
  1492. return;
  1493. pr_err("===================== Dumping tx_ring %d ===============\n",
  1494. tx_ring->wq_id);
  1495. pr_err("tx_ring->base = %p\n", tx_ring->wq_base);
  1496. pr_err("tx_ring->base_dma = 0x%llx\n",
  1497. (unsigned long long) tx_ring->wq_base_dma);
  1498. pr_err("tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d\n",
  1499. tx_ring->cnsmr_idx_sh_reg,
  1500. tx_ring->cnsmr_idx_sh_reg
  1501. ? ql_read_sh_reg(tx_ring->cnsmr_idx_sh_reg) : 0);
  1502. pr_err("tx_ring->size = %d\n", tx_ring->wq_size);
  1503. pr_err("tx_ring->len = %d\n", tx_ring->wq_len);
  1504. pr_err("tx_ring->prod_idx_db_reg = %p\n", tx_ring->prod_idx_db_reg);
  1505. pr_err("tx_ring->valid_db_reg = %p\n", tx_ring->valid_db_reg);
  1506. pr_err("tx_ring->prod_idx = %d\n", tx_ring->prod_idx);
  1507. pr_err("tx_ring->cq_id = %d\n", tx_ring->cq_id);
  1508. pr_err("tx_ring->wq_id = %d\n", tx_ring->wq_id);
  1509. pr_err("tx_ring->q = %p\n", tx_ring->q);
  1510. pr_err("tx_ring->tx_count = %d\n", atomic_read(&tx_ring->tx_count));
  1511. }
  1512. void ql_dump_ricb(struct ricb *ricb)
  1513. {
  1514. int i;
  1515. pr_err("===================== Dumping ricb ===============\n");
  1516. pr_err("Dumping ricb stuff...\n");
  1517. pr_err("ricb->base_cq = %d\n", ricb->base_cq & 0x1f);
  1518. pr_err("ricb->flags = %s%s%s%s%s%s%s%s%s\n",
  1519. ricb->base_cq & RSS_L4K ? "RSS_L4K " : "",
  1520. ricb->flags & RSS_L6K ? "RSS_L6K " : "",
  1521. ricb->flags & RSS_LI ? "RSS_LI " : "",
  1522. ricb->flags & RSS_LB ? "RSS_LB " : "",
  1523. ricb->flags & RSS_LM ? "RSS_LM " : "",
  1524. ricb->flags & RSS_RI4 ? "RSS_RI4 " : "",
  1525. ricb->flags & RSS_RT4 ? "RSS_RT4 " : "",
  1526. ricb->flags & RSS_RI6 ? "RSS_RI6 " : "",
  1527. ricb->flags & RSS_RT6 ? "RSS_RT6 " : "");
  1528. pr_err("ricb->mask = 0x%.04x\n", le16_to_cpu(ricb->mask));
  1529. for (i = 0; i < 16; i++)
  1530. pr_err("ricb->hash_cq_id[%d] = 0x%.08x\n", i,
  1531. le32_to_cpu(ricb->hash_cq_id[i]));
  1532. for (i = 0; i < 10; i++)
  1533. pr_err("ricb->ipv6_hash_key[%d] = 0x%.08x\n", i,
  1534. le32_to_cpu(ricb->ipv6_hash_key[i]));
  1535. for (i = 0; i < 4; i++)
  1536. pr_err("ricb->ipv4_hash_key[%d] = 0x%.08x\n", i,
  1537. le32_to_cpu(ricb->ipv4_hash_key[i]));
  1538. }
  1539. void ql_dump_cqicb(struct cqicb *cqicb)
  1540. {
  1541. pr_err("Dumping cqicb stuff...\n");
  1542. pr_err("cqicb->msix_vect = %d\n", cqicb->msix_vect);
  1543. pr_err("cqicb->flags = %x\n", cqicb->flags);
  1544. pr_err("cqicb->len = %d\n", le16_to_cpu(cqicb->len));
  1545. pr_err("cqicb->addr = 0x%llx\n",
  1546. (unsigned long long) le64_to_cpu(cqicb->addr));
  1547. pr_err("cqicb->prod_idx_addr = 0x%llx\n",
  1548. (unsigned long long) le64_to_cpu(cqicb->prod_idx_addr));
  1549. pr_err("cqicb->pkt_delay = 0x%.04x\n",
  1550. le16_to_cpu(cqicb->pkt_delay));
  1551. pr_err("cqicb->irq_delay = 0x%.04x\n",
  1552. le16_to_cpu(cqicb->irq_delay));
  1553. pr_err("cqicb->lbq_addr = 0x%llx\n",
  1554. (unsigned long long) le64_to_cpu(cqicb->lbq_addr));
  1555. pr_err("cqicb->lbq_buf_size = 0x%.04x\n",
  1556. le16_to_cpu(cqicb->lbq_buf_size));
  1557. pr_err("cqicb->lbq_len = 0x%.04x\n",
  1558. le16_to_cpu(cqicb->lbq_len));
  1559. pr_err("cqicb->sbq_addr = 0x%llx\n",
  1560. (unsigned long long) le64_to_cpu(cqicb->sbq_addr));
  1561. pr_err("cqicb->sbq_buf_size = 0x%.04x\n",
  1562. le16_to_cpu(cqicb->sbq_buf_size));
  1563. pr_err("cqicb->sbq_len = 0x%.04x\n",
  1564. le16_to_cpu(cqicb->sbq_len));
  1565. }
  1566. void ql_dump_rx_ring(struct rx_ring *rx_ring)
  1567. {
  1568. if (rx_ring == NULL)
  1569. return;
  1570. pr_err("===================== Dumping rx_ring %d ===============\n",
  1571. rx_ring->cq_id);
  1572. pr_err("Dumping rx_ring %d, type = %s%s%s\n",
  1573. rx_ring->cq_id, rx_ring->type == DEFAULT_Q ? "DEFAULT" : "",
  1574. rx_ring->type == TX_Q ? "OUTBOUND COMPLETIONS" : "",
  1575. rx_ring->type == RX_Q ? "INBOUND_COMPLETIONS" : "");
  1576. pr_err("rx_ring->cqicb = %p\n", &rx_ring->cqicb);
  1577. pr_err("rx_ring->cq_base = %p\n", rx_ring->cq_base);
  1578. pr_err("rx_ring->cq_base_dma = %llx\n",
  1579. (unsigned long long) rx_ring->cq_base_dma);
  1580. pr_err("rx_ring->cq_size = %d\n", rx_ring->cq_size);
  1581. pr_err("rx_ring->cq_len = %d\n", rx_ring->cq_len);
  1582. pr_err("rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d\n",
  1583. rx_ring->prod_idx_sh_reg,
  1584. rx_ring->prod_idx_sh_reg
  1585. ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0);
  1586. pr_err("rx_ring->prod_idx_sh_reg_dma = %llx\n",
  1587. (unsigned long long) rx_ring->prod_idx_sh_reg_dma);
  1588. pr_err("rx_ring->cnsmr_idx_db_reg = %p\n",
  1589. rx_ring->cnsmr_idx_db_reg);
  1590. pr_err("rx_ring->cnsmr_idx = %d\n", rx_ring->cnsmr_idx);
  1591. pr_err("rx_ring->curr_entry = %p\n", rx_ring->curr_entry);
  1592. pr_err("rx_ring->valid_db_reg = %p\n", rx_ring->valid_db_reg);
  1593. pr_err("rx_ring->lbq_base = %p\n", rx_ring->lbq_base);
  1594. pr_err("rx_ring->lbq_base_dma = %llx\n",
  1595. (unsigned long long) rx_ring->lbq_base_dma);
  1596. pr_err("rx_ring->lbq_base_indirect = %p\n",
  1597. rx_ring->lbq_base_indirect);
  1598. pr_err("rx_ring->lbq_base_indirect_dma = %llx\n",
  1599. (unsigned long long) rx_ring->lbq_base_indirect_dma);
  1600. pr_err("rx_ring->lbq = %p\n", rx_ring->lbq);
  1601. pr_err("rx_ring->lbq_len = %d\n", rx_ring->lbq_len);
  1602. pr_err("rx_ring->lbq_size = %d\n", rx_ring->lbq_size);
  1603. pr_err("rx_ring->lbq_prod_idx_db_reg = %p\n",
  1604. rx_ring->lbq_prod_idx_db_reg);
  1605. pr_err("rx_ring->lbq_prod_idx = %d\n", rx_ring->lbq_prod_idx);
  1606. pr_err("rx_ring->lbq_curr_idx = %d\n", rx_ring->lbq_curr_idx);
  1607. pr_err("rx_ring->lbq_clean_idx = %d\n", rx_ring->lbq_clean_idx);
  1608. pr_err("rx_ring->lbq_free_cnt = %d\n", rx_ring->lbq_free_cnt);
  1609. pr_err("rx_ring->lbq_buf_size = %d\n", rx_ring->lbq_buf_size);
  1610. pr_err("rx_ring->sbq_base = %p\n", rx_ring->sbq_base);
  1611. pr_err("rx_ring->sbq_base_dma = %llx\n",
  1612. (unsigned long long) rx_ring->sbq_base_dma);
  1613. pr_err("rx_ring->sbq_base_indirect = %p\n",
  1614. rx_ring->sbq_base_indirect);
  1615. pr_err("rx_ring->sbq_base_indirect_dma = %llx\n",
  1616. (unsigned long long) rx_ring->sbq_base_indirect_dma);
  1617. pr_err("rx_ring->sbq = %p\n", rx_ring->sbq);
  1618. pr_err("rx_ring->sbq_len = %d\n", rx_ring->sbq_len);
  1619. pr_err("rx_ring->sbq_size = %d\n", rx_ring->sbq_size);
  1620. pr_err("rx_ring->sbq_prod_idx_db_reg addr = %p\n",
  1621. rx_ring->sbq_prod_idx_db_reg);
  1622. pr_err("rx_ring->sbq_prod_idx = %d\n", rx_ring->sbq_prod_idx);
  1623. pr_err("rx_ring->sbq_curr_idx = %d\n", rx_ring->sbq_curr_idx);
  1624. pr_err("rx_ring->sbq_clean_idx = %d\n", rx_ring->sbq_clean_idx);
  1625. pr_err("rx_ring->sbq_free_cnt = %d\n", rx_ring->sbq_free_cnt);
  1626. pr_err("rx_ring->sbq_buf_size = %d\n", rx_ring->sbq_buf_size);
  1627. pr_err("rx_ring->cq_id = %d\n", rx_ring->cq_id);
  1628. pr_err("rx_ring->irq = %d\n", rx_ring->irq);
  1629. pr_err("rx_ring->cpu = %d\n", rx_ring->cpu);
  1630. pr_err("rx_ring->qdev = %p\n", rx_ring->qdev);
  1631. }
  1632. void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id)
  1633. {
  1634. void *ptr;
  1635. pr_err("%s: Enter\n", __func__);
  1636. ptr = kmalloc(size, GFP_ATOMIC);
  1637. if (ptr == NULL)
  1638. return;
  1639. if (ql_write_cfg(qdev, ptr, size, bit, q_id)) {
  1640. pr_err("%s: Failed to upload control block!\n", __func__);
  1641. goto fail_it;
  1642. }
  1643. switch (bit) {
  1644. case CFG_DRQ:
  1645. ql_dump_wqicb((struct wqicb *)ptr);
  1646. break;
  1647. case CFG_DCQ:
  1648. ql_dump_cqicb((struct cqicb *)ptr);
  1649. break;
  1650. case CFG_DR:
  1651. ql_dump_ricb((struct ricb *)ptr);
  1652. break;
  1653. default:
  1654. pr_err("%s: Invalid bit value = %x\n", __func__, bit);
  1655. break;
  1656. }
  1657. fail_it:
  1658. kfree(ptr);
  1659. }
  1660. #endif
  1661. #ifdef QL_OB_DUMP
  1662. void ql_dump_tx_desc(struct tx_buf_desc *tbd)
  1663. {
  1664. pr_err("tbd->addr = 0x%llx\n",
  1665. le64_to_cpu((u64) tbd->addr));
  1666. pr_err("tbd->len = %d\n",
  1667. le32_to_cpu(tbd->len & TX_DESC_LEN_MASK));
  1668. pr_err("tbd->flags = %s %s\n",
  1669. tbd->len & TX_DESC_C ? "C" : ".",
  1670. tbd->len & TX_DESC_E ? "E" : ".");
  1671. tbd++;
  1672. pr_err("tbd->addr = 0x%llx\n",
  1673. le64_to_cpu((u64) tbd->addr));
  1674. pr_err("tbd->len = %d\n",
  1675. le32_to_cpu(tbd->len & TX_DESC_LEN_MASK));
  1676. pr_err("tbd->flags = %s %s\n",
  1677. tbd->len & TX_DESC_C ? "C" : ".",
  1678. tbd->len & TX_DESC_E ? "E" : ".");
  1679. tbd++;
  1680. pr_err("tbd->addr = 0x%llx\n",
  1681. le64_to_cpu((u64) tbd->addr));
  1682. pr_err("tbd->len = %d\n",
  1683. le32_to_cpu(tbd->len & TX_DESC_LEN_MASK));
  1684. pr_err("tbd->flags = %s %s\n",
  1685. tbd->len & TX_DESC_C ? "C" : ".",
  1686. tbd->len & TX_DESC_E ? "E" : ".");
  1687. }
  1688. void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb)
  1689. {
  1690. struct ob_mac_tso_iocb_req *ob_mac_tso_iocb =
  1691. (struct ob_mac_tso_iocb_req *)ob_mac_iocb;
  1692. struct tx_buf_desc *tbd;
  1693. u16 frame_len;
  1694. pr_err("%s\n", __func__);
  1695. pr_err("opcode = %s\n",
  1696. (ob_mac_iocb->opcode == OPCODE_OB_MAC_IOCB) ? "MAC" : "TSO");
  1697. pr_err("flags1 = %s %s %s %s %s\n",
  1698. ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_OI ? "OI" : "",
  1699. ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_I ? "I" : "",
  1700. ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_D ? "D" : "",
  1701. ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP4 ? "IP4" : "",
  1702. ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP6 ? "IP6" : "");
  1703. pr_err("flags2 = %s %s %s\n",
  1704. ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_LSO ? "LSO" : "",
  1705. ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_UC ? "UC" : "",
  1706. ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_TC ? "TC" : "");
  1707. pr_err("flags3 = %s %s %s\n",
  1708. ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_IC ? "IC" : "",
  1709. ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_DFP ? "DFP" : "",
  1710. ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_V ? "V" : "");
  1711. pr_err("tid = %x\n", ob_mac_iocb->tid);
  1712. pr_err("txq_idx = %d\n", ob_mac_iocb->txq_idx);
  1713. pr_err("vlan_tci = %x\n", ob_mac_tso_iocb->vlan_tci);
  1714. if (ob_mac_iocb->opcode == OPCODE_OB_MAC_TSO_IOCB) {
  1715. pr_err("frame_len = %d\n",
  1716. le32_to_cpu(ob_mac_tso_iocb->frame_len));
  1717. pr_err("mss = %d\n",
  1718. le16_to_cpu(ob_mac_tso_iocb->mss));
  1719. pr_err("prot_hdr_len = %d\n",
  1720. le16_to_cpu(ob_mac_tso_iocb->total_hdrs_len));
  1721. pr_err("hdr_offset = 0x%.04x\n",
  1722. le16_to_cpu(ob_mac_tso_iocb->net_trans_offset));
  1723. frame_len = le32_to_cpu(ob_mac_tso_iocb->frame_len);
  1724. } else {
  1725. pr_err("frame_len = %d\n",
  1726. le16_to_cpu(ob_mac_iocb->frame_len));
  1727. frame_len = le16_to_cpu(ob_mac_iocb->frame_len);
  1728. }
  1729. tbd = &ob_mac_iocb->tbd[0];
  1730. ql_dump_tx_desc(tbd);
  1731. }
  1732. void ql_dump_ob_mac_rsp(struct ob_mac_iocb_rsp *ob_mac_rsp)
  1733. {
  1734. pr_err("%s\n", __func__);
  1735. pr_err("opcode = %d\n", ob_mac_rsp->opcode);
  1736. pr_err("flags = %s %s %s %s %s %s %s\n",
  1737. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_OI ? "OI" : ".",
  1738. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_I ? "I" : ".",
  1739. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_E ? "E" : ".",
  1740. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_S ? "S" : ".",
  1741. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_L ? "L" : ".",
  1742. ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_P ? "P" : ".",
  1743. ob_mac_rsp->flags2 & OB_MAC_IOCB_RSP_B ? "B" : ".");
  1744. pr_err("tid = %x\n", ob_mac_rsp->tid);
  1745. }
  1746. #endif
  1747. #ifdef QL_IB_DUMP
  1748. void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
  1749. {
  1750. pr_err("%s\n", __func__);
  1751. pr_err("opcode = 0x%x\n", ib_mac_rsp->opcode);
  1752. pr_err("flags1 = %s%s%s%s%s%s\n",
  1753. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_OI ? "OI " : "",
  1754. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_I ? "I " : "",
  1755. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_TE ? "TE " : "",
  1756. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_NU ? "NU " : "",
  1757. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_IE ? "IE " : "",
  1758. ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_B ? "B " : "");
  1759. if (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK)
  1760. pr_err("%s%s%s Multicast\n",
  1761. (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
  1762. IB_MAC_IOCB_RSP_M_HASH ? "Hash" : "",
  1763. (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
  1764. IB_MAC_IOCB_RSP_M_REG ? "Registered" : "",
  1765. (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
  1766. IB_MAC_IOCB_RSP_M_PROM ? "Promiscuous" : "");
  1767. pr_err("flags2 = %s%s%s%s%s\n",
  1768. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_P) ? "P " : "",
  1769. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V) ? "V " : "",
  1770. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) ? "U " : "",
  1771. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T) ? "T " : "",
  1772. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_FO) ? "FO " : "");
  1773. if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK)
  1774. pr_err("%s%s%s%s%s error\n",
  1775. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) ==
  1776. IB_MAC_IOCB_RSP_ERR_OVERSIZE ? "oversize" : "",
  1777. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) ==
  1778. IB_MAC_IOCB_RSP_ERR_UNDERSIZE ? "undersize" : "",
  1779. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) ==
  1780. IB_MAC_IOCB_RSP_ERR_PREAMBLE ? "preamble" : "",
  1781. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) ==
  1782. IB_MAC_IOCB_RSP_ERR_FRAME_LEN ? "frame length" : "",
  1783. (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) ==
  1784. IB_MAC_IOCB_RSP_ERR_CRC ? "CRC" : "");
  1785. pr_err("flags3 = %s%s\n",
  1786. ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS ? "DS " : "",
  1787. ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL ? "DL " : "");
  1788. if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK)
  1789. pr_err("RSS flags = %s%s%s%s\n",
  1790. ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) ==
  1791. IB_MAC_IOCB_RSP_M_IPV4) ? "IPv4 RSS" : "",
  1792. ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) ==
  1793. IB_MAC_IOCB_RSP_M_IPV6) ? "IPv6 RSS " : "",
  1794. ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) ==
  1795. IB_MAC_IOCB_RSP_M_TCP_V4) ? "TCP/IPv4 RSS" : "",
  1796. ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) ==
  1797. IB_MAC_IOCB_RSP_M_TCP_V6) ? "TCP/IPv6 RSS" : "");
  1798. pr_err("data_len = %d\n",
  1799. le32_to_cpu(ib_mac_rsp->data_len));
  1800. pr_err("data_addr = 0x%llx\n",
  1801. (unsigned long long) le64_to_cpu(ib_mac_rsp->data_addr));
  1802. if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK)
  1803. pr_err("rss = %x\n",
  1804. le32_to_cpu(ib_mac_rsp->rss));
  1805. if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V)
  1806. pr_err("vlan_id = %x\n",
  1807. le16_to_cpu(ib_mac_rsp->vlan_id));
  1808. pr_err("flags4 = %s%s%s\n",
  1809. ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "",
  1810. ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "",
  1811. ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : "");
  1812. if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
  1813. pr_err("hdr length = %d\n",
  1814. le32_to_cpu(ib_mac_rsp->hdr_len));
  1815. pr_err("hdr addr = 0x%llx\n",
  1816. (unsigned long long) le64_to_cpu(ib_mac_rsp->hdr_addr));
  1817. }
  1818. }
  1819. #endif
  1820. #ifdef QL_ALL_DUMP
  1821. void ql_dump_all(struct ql_adapter *qdev)
  1822. {
  1823. int i;
  1824. QL_DUMP_REGS(qdev);
  1825. QL_DUMP_QDEV(qdev);
  1826. for (i = 0; i < qdev->tx_ring_count; i++) {
  1827. QL_DUMP_TX_RING(&qdev->tx_ring[i]);
  1828. QL_DUMP_WQICB((struct wqicb *)&qdev->tx_ring[i]);
  1829. }
  1830. for (i = 0; i < qdev->rx_ring_count; i++) {
  1831. QL_DUMP_RX_RING(&qdev->rx_ring[i]);
  1832. QL_DUMP_CQICB((struct cqicb *)&qdev->rx_ring[i]);
  1833. }
  1834. }
  1835. #endif