bnx2x_ethtool.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099
  1. /* bnx2x_ethtool.c: Broadcom Everest network driver.
  2. *
  3. * Copyright (c) 2007-2010 Broadcom Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. *
  9. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  10. * Written by: Eliezer Tamir
  11. * Based on code from Michael Chan's bnx2 driver
  12. * UDP CSUM errata workaround by Arik Gendelman
  13. * Slowpath and fastpath rework by Vladislav Zolotarov
  14. * Statistics and Link management by Yitchak Gertner
  15. *
  16. */
  17. #include <linux/ethtool.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/types.h>
  20. #include <linux/sched.h>
  21. #include <linux/crc32.h>
  22. #include "bnx2x.h"
  23. #include "bnx2x_cmn.h"
  24. #include "bnx2x_dump.h"
  25. static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  26. {
  27. struct bnx2x *bp = netdev_priv(dev);
  28. int cfg_idx = bnx2x_get_link_cfg_idx(bp);
  29. /* Dual Media boards present all available port types */
  30. cmd->supported = bp->port.supported[cfg_idx] |
  31. (bp->port.supported[cfg_idx ^ 1] &
  32. (SUPPORTED_TP | SUPPORTED_FIBRE));
  33. cmd->advertising = bp->port.advertising[cfg_idx];
  34. if ((bp->state == BNX2X_STATE_OPEN) &&
  35. !(bp->flags & MF_FUNC_DIS) &&
  36. (bp->link_vars.link_up)) {
  37. cmd->speed = bp->link_vars.line_speed;
  38. cmd->duplex = bp->link_vars.duplex;
  39. } else {
  40. cmd->speed = bp->link_params.req_line_speed[cfg_idx];
  41. cmd->duplex = bp->link_params.req_duplex[cfg_idx];
  42. }
  43. if (IS_MF(bp)) {
  44. u16 vn_max_rate = ((bp->mf_config[BP_VN(bp)] &
  45. FUNC_MF_CFG_MAX_BW_MASK) >> FUNC_MF_CFG_MAX_BW_SHIFT) *
  46. 100;
  47. if (vn_max_rate < cmd->speed)
  48. cmd->speed = vn_max_rate;
  49. }
  50. if (bp->port.supported[cfg_idx] & SUPPORTED_TP)
  51. cmd->port = PORT_TP;
  52. else if (bp->port.supported[cfg_idx] & SUPPORTED_FIBRE)
  53. cmd->port = PORT_FIBRE;
  54. else
  55. BNX2X_ERR("XGXS PHY Failure detected\n");
  56. cmd->phy_address = bp->mdio.prtad;
  57. cmd->transceiver = XCVR_INTERNAL;
  58. if (bp->link_params.req_line_speed[cfg_idx] == SPEED_AUTO_NEG)
  59. cmd->autoneg = AUTONEG_ENABLE;
  60. else
  61. cmd->autoneg = AUTONEG_DISABLE;
  62. cmd->maxtxpkt = 0;
  63. cmd->maxrxpkt = 0;
  64. DP(NETIF_MSG_LINK, "ethtool_cmd: cmd %d\n"
  65. DP_LEVEL " supported 0x%x advertising 0x%x speed %d\n"
  66. DP_LEVEL " duplex %d port %d phy_address %d transceiver %d\n"
  67. DP_LEVEL " autoneg %d maxtxpkt %d maxrxpkt %d\n",
  68. cmd->cmd, cmd->supported, cmd->advertising, cmd->speed,
  69. cmd->duplex, cmd->port, cmd->phy_address, cmd->transceiver,
  70. cmd->autoneg, cmd->maxtxpkt, cmd->maxrxpkt);
  71. return 0;
  72. }
  73. static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  74. {
  75. struct bnx2x *bp = netdev_priv(dev);
  76. u32 advertising, cfg_idx, old_multi_phy_config, new_multi_phy_config;
  77. if (IS_MF(bp))
  78. return 0;
  79. DP(NETIF_MSG_LINK, "ethtool_cmd: cmd %d\n"
  80. DP_LEVEL " supported 0x%x advertising 0x%x speed %d\n"
  81. DP_LEVEL " duplex %d port %d phy_address %d transceiver %d\n"
  82. DP_LEVEL " autoneg %d maxtxpkt %d maxrxpkt %d\n",
  83. cmd->cmd, cmd->supported, cmd->advertising, cmd->speed,
  84. cmd->duplex, cmd->port, cmd->phy_address, cmd->transceiver,
  85. cmd->autoneg, cmd->maxtxpkt, cmd->maxrxpkt);
  86. cfg_idx = bnx2x_get_link_cfg_idx(bp);
  87. old_multi_phy_config = bp->link_params.multi_phy_config;
  88. switch (cmd->port) {
  89. case PORT_TP:
  90. if (bp->port.supported[cfg_idx] & SUPPORTED_TP)
  91. break; /* no port change */
  92. if (!(bp->port.supported[0] & SUPPORTED_TP ||
  93. bp->port.supported[1] & SUPPORTED_TP)) {
  94. DP(NETIF_MSG_LINK, "Unsupported port type\n");
  95. return -EINVAL;
  96. }
  97. bp->link_params.multi_phy_config &=
  98. ~PORT_HW_CFG_PHY_SELECTION_MASK;
  99. if (bp->link_params.multi_phy_config &
  100. PORT_HW_CFG_PHY_SWAPPED_ENABLED)
  101. bp->link_params.multi_phy_config |=
  102. PORT_HW_CFG_PHY_SELECTION_SECOND_PHY;
  103. else
  104. bp->link_params.multi_phy_config |=
  105. PORT_HW_CFG_PHY_SELECTION_FIRST_PHY;
  106. break;
  107. case PORT_FIBRE:
  108. if (bp->port.supported[cfg_idx] & SUPPORTED_FIBRE)
  109. break; /* no port change */
  110. if (!(bp->port.supported[0] & SUPPORTED_FIBRE ||
  111. bp->port.supported[1] & SUPPORTED_FIBRE)) {
  112. DP(NETIF_MSG_LINK, "Unsupported port type\n");
  113. return -EINVAL;
  114. }
  115. bp->link_params.multi_phy_config &=
  116. ~PORT_HW_CFG_PHY_SELECTION_MASK;
  117. if (bp->link_params.multi_phy_config &
  118. PORT_HW_CFG_PHY_SWAPPED_ENABLED)
  119. bp->link_params.multi_phy_config |=
  120. PORT_HW_CFG_PHY_SELECTION_FIRST_PHY;
  121. else
  122. bp->link_params.multi_phy_config |=
  123. PORT_HW_CFG_PHY_SELECTION_SECOND_PHY;
  124. break;
  125. default:
  126. DP(NETIF_MSG_LINK, "Unsupported port type\n");
  127. return -EINVAL;
  128. }
  129. /* Save new config in case command complete successuly */
  130. new_multi_phy_config = bp->link_params.multi_phy_config;
  131. /* Get the new cfg_idx */
  132. cfg_idx = bnx2x_get_link_cfg_idx(bp);
  133. /* Restore old config in case command failed */
  134. bp->link_params.multi_phy_config = old_multi_phy_config;
  135. DP(NETIF_MSG_LINK, "cfg_idx = %x\n", cfg_idx);
  136. if (cmd->autoneg == AUTONEG_ENABLE) {
  137. if (!(bp->port.supported[cfg_idx] & SUPPORTED_Autoneg)) {
  138. DP(NETIF_MSG_LINK, "Autoneg not supported\n");
  139. return -EINVAL;
  140. }
  141. /* advertise the requested speed and duplex if supported */
  142. cmd->advertising &= bp->port.supported[cfg_idx];
  143. bp->link_params.req_line_speed[cfg_idx] = SPEED_AUTO_NEG;
  144. bp->link_params.req_duplex[cfg_idx] = DUPLEX_FULL;
  145. bp->port.advertising[cfg_idx] |= (ADVERTISED_Autoneg |
  146. cmd->advertising);
  147. } else { /* forced speed */
  148. /* advertise the requested speed and duplex if supported */
  149. u32 speed = cmd->speed;
  150. speed |= (cmd->speed_hi << 16);
  151. switch (speed) {
  152. case SPEED_10:
  153. if (cmd->duplex == DUPLEX_FULL) {
  154. if (!(bp->port.supported[cfg_idx] &
  155. SUPPORTED_10baseT_Full)) {
  156. DP(NETIF_MSG_LINK,
  157. "10M full not supported\n");
  158. return -EINVAL;
  159. }
  160. advertising = (ADVERTISED_10baseT_Full |
  161. ADVERTISED_TP);
  162. } else {
  163. if (!(bp->port.supported[cfg_idx] &
  164. SUPPORTED_10baseT_Half)) {
  165. DP(NETIF_MSG_LINK,
  166. "10M half not supported\n");
  167. return -EINVAL;
  168. }
  169. advertising = (ADVERTISED_10baseT_Half |
  170. ADVERTISED_TP);
  171. }
  172. break;
  173. case SPEED_100:
  174. if (cmd->duplex == DUPLEX_FULL) {
  175. if (!(bp->port.supported[cfg_idx] &
  176. SUPPORTED_100baseT_Full)) {
  177. DP(NETIF_MSG_LINK,
  178. "100M full not supported\n");
  179. return -EINVAL;
  180. }
  181. advertising = (ADVERTISED_100baseT_Full |
  182. ADVERTISED_TP);
  183. } else {
  184. if (!(bp->port.supported[cfg_idx] &
  185. SUPPORTED_100baseT_Half)) {
  186. DP(NETIF_MSG_LINK,
  187. "100M half not supported\n");
  188. return -EINVAL;
  189. }
  190. advertising = (ADVERTISED_100baseT_Half |
  191. ADVERTISED_TP);
  192. }
  193. break;
  194. case SPEED_1000:
  195. if (cmd->duplex != DUPLEX_FULL) {
  196. DP(NETIF_MSG_LINK, "1G half not supported\n");
  197. return -EINVAL;
  198. }
  199. if (!(bp->port.supported[cfg_idx] &
  200. SUPPORTED_1000baseT_Full)) {
  201. DP(NETIF_MSG_LINK, "1G full not supported\n");
  202. return -EINVAL;
  203. }
  204. advertising = (ADVERTISED_1000baseT_Full |
  205. ADVERTISED_TP);
  206. break;
  207. case SPEED_2500:
  208. if (cmd->duplex != DUPLEX_FULL) {
  209. DP(NETIF_MSG_LINK,
  210. "2.5G half not supported\n");
  211. return -EINVAL;
  212. }
  213. if (!(bp->port.supported[cfg_idx]
  214. & SUPPORTED_2500baseX_Full)) {
  215. DP(NETIF_MSG_LINK,
  216. "2.5G full not supported\n");
  217. return -EINVAL;
  218. }
  219. advertising = (ADVERTISED_2500baseX_Full |
  220. ADVERTISED_TP);
  221. break;
  222. case SPEED_10000:
  223. if (cmd->duplex != DUPLEX_FULL) {
  224. DP(NETIF_MSG_LINK, "10G half not supported\n");
  225. return -EINVAL;
  226. }
  227. if (!(bp->port.supported[cfg_idx]
  228. & SUPPORTED_10000baseT_Full)) {
  229. DP(NETIF_MSG_LINK, "10G full not supported\n");
  230. return -EINVAL;
  231. }
  232. advertising = (ADVERTISED_10000baseT_Full |
  233. ADVERTISED_FIBRE);
  234. break;
  235. default:
  236. DP(NETIF_MSG_LINK, "Unsupported speed %d\n", speed);
  237. return -EINVAL;
  238. }
  239. bp->link_params.req_line_speed[cfg_idx] = speed;
  240. bp->link_params.req_duplex[cfg_idx] = cmd->duplex;
  241. bp->port.advertising[cfg_idx] = advertising;
  242. }
  243. DP(NETIF_MSG_LINK, "req_line_speed %d\n"
  244. DP_LEVEL " req_duplex %d advertising 0x%x\n",
  245. bp->link_params.req_line_speed[cfg_idx],
  246. bp->link_params.req_duplex[cfg_idx],
  247. bp->port.advertising[cfg_idx]);
  248. /* Set new config */
  249. bp->link_params.multi_phy_config = new_multi_phy_config;
  250. if (netif_running(dev)) {
  251. bnx2x_stats_handle(bp, STATS_EVENT_STOP);
  252. bnx2x_link_set(bp);
  253. }
  254. return 0;
  255. }
  256. #define IS_E1_ONLINE(info) (((info) & RI_E1_ONLINE) == RI_E1_ONLINE)
  257. #define IS_E1H_ONLINE(info) (((info) & RI_E1H_ONLINE) == RI_E1H_ONLINE)
  258. #define IS_E2_ONLINE(info) (((info) & RI_E2_ONLINE) == RI_E2_ONLINE)
  259. static int bnx2x_get_regs_len(struct net_device *dev)
  260. {
  261. struct bnx2x *bp = netdev_priv(dev);
  262. int regdump_len = 0;
  263. int i;
  264. if (CHIP_IS_E1(bp)) {
  265. for (i = 0; i < REGS_COUNT; i++)
  266. if (IS_E1_ONLINE(reg_addrs[i].info))
  267. regdump_len += reg_addrs[i].size;
  268. for (i = 0; i < WREGS_COUNT_E1; i++)
  269. if (IS_E1_ONLINE(wreg_addrs_e1[i].info))
  270. regdump_len += wreg_addrs_e1[i].size *
  271. (1 + wreg_addrs_e1[i].read_regs_count);
  272. } else if (CHIP_IS_E1H(bp)) {
  273. for (i = 0; i < REGS_COUNT; i++)
  274. if (IS_E1H_ONLINE(reg_addrs[i].info))
  275. regdump_len += reg_addrs[i].size;
  276. for (i = 0; i < WREGS_COUNT_E1H; i++)
  277. if (IS_E1H_ONLINE(wreg_addrs_e1h[i].info))
  278. regdump_len += wreg_addrs_e1h[i].size *
  279. (1 + wreg_addrs_e1h[i].read_regs_count);
  280. } else if (CHIP_IS_E2(bp)) {
  281. for (i = 0; i < REGS_COUNT; i++)
  282. if (IS_E2_ONLINE(reg_addrs[i].info))
  283. regdump_len += reg_addrs[i].size;
  284. for (i = 0; i < WREGS_COUNT_E2; i++)
  285. if (IS_E2_ONLINE(wreg_addrs_e2[i].info))
  286. regdump_len += wreg_addrs_e2[i].size *
  287. (1 + wreg_addrs_e2[i].read_regs_count);
  288. }
  289. regdump_len *= 4;
  290. regdump_len += sizeof(struct dump_hdr);
  291. return regdump_len;
  292. }
  293. static inline void bnx2x_read_pages_regs_e2(struct bnx2x *bp, u32 *p)
  294. {
  295. u32 i, j, k, n;
  296. for (i = 0; i < PAGE_MODE_VALUES_E2; i++) {
  297. for (j = 0; j < PAGE_WRITE_REGS_E2; j++) {
  298. REG_WR(bp, page_write_regs_e2[j], page_vals_e2[i]);
  299. for (k = 0; k < PAGE_READ_REGS_E2; k++)
  300. if (IS_E2_ONLINE(page_read_regs_e2[k].info))
  301. for (n = 0; n <
  302. page_read_regs_e2[k].size; n++)
  303. *p++ = REG_RD(bp,
  304. page_read_regs_e2[k].addr + n*4);
  305. }
  306. }
  307. }
  308. static void bnx2x_get_regs(struct net_device *dev,
  309. struct ethtool_regs *regs, void *_p)
  310. {
  311. u32 *p = _p, i, j;
  312. struct bnx2x *bp = netdev_priv(dev);
  313. struct dump_hdr dump_hdr = {0};
  314. regs->version = 0;
  315. memset(p, 0, regs->len);
  316. if (!netif_running(bp->dev))
  317. return;
  318. dump_hdr.hdr_size = (sizeof(struct dump_hdr) / 4) - 1;
  319. dump_hdr.dump_sign = dump_sign_all;
  320. dump_hdr.xstorm_waitp = REG_RD(bp, XSTORM_WAITP_ADDR);
  321. dump_hdr.tstorm_waitp = REG_RD(bp, TSTORM_WAITP_ADDR);
  322. dump_hdr.ustorm_waitp = REG_RD(bp, USTORM_WAITP_ADDR);
  323. dump_hdr.cstorm_waitp = REG_RD(bp, CSTORM_WAITP_ADDR);
  324. if (CHIP_IS_E1(bp))
  325. dump_hdr.info = RI_E1_ONLINE;
  326. else if (CHIP_IS_E1H(bp))
  327. dump_hdr.info = RI_E1H_ONLINE;
  328. else if (CHIP_IS_E2(bp))
  329. dump_hdr.info = RI_E2_ONLINE |
  330. (BP_PATH(bp) ? RI_PATH1_DUMP : RI_PATH0_DUMP);
  331. memcpy(p, &dump_hdr, sizeof(struct dump_hdr));
  332. p += dump_hdr.hdr_size + 1;
  333. if (CHIP_IS_E1(bp)) {
  334. for (i = 0; i < REGS_COUNT; i++)
  335. if (IS_E1_ONLINE(reg_addrs[i].info))
  336. for (j = 0; j < reg_addrs[i].size; j++)
  337. *p++ = REG_RD(bp,
  338. reg_addrs[i].addr + j*4);
  339. } else if (CHIP_IS_E1H(bp)) {
  340. for (i = 0; i < REGS_COUNT; i++)
  341. if (IS_E1H_ONLINE(reg_addrs[i].info))
  342. for (j = 0; j < reg_addrs[i].size; j++)
  343. *p++ = REG_RD(bp,
  344. reg_addrs[i].addr + j*4);
  345. } else if (CHIP_IS_E2(bp)) {
  346. for (i = 0; i < REGS_COUNT; i++)
  347. if (IS_E2_ONLINE(reg_addrs[i].info))
  348. for (j = 0; j < reg_addrs[i].size; j++)
  349. *p++ = REG_RD(bp,
  350. reg_addrs[i].addr + j*4);
  351. bnx2x_read_pages_regs_e2(bp, p);
  352. }
  353. }
  354. #define PHY_FW_VER_LEN 20
  355. static void bnx2x_get_drvinfo(struct net_device *dev,
  356. struct ethtool_drvinfo *info)
  357. {
  358. struct bnx2x *bp = netdev_priv(dev);
  359. u8 phy_fw_ver[PHY_FW_VER_LEN];
  360. strcpy(info->driver, DRV_MODULE_NAME);
  361. strcpy(info->version, DRV_MODULE_VERSION);
  362. phy_fw_ver[0] = '\0';
  363. if (bp->port.pmf) {
  364. bnx2x_acquire_phy_lock(bp);
  365. bnx2x_get_ext_phy_fw_version(&bp->link_params,
  366. (bp->state != BNX2X_STATE_CLOSED),
  367. phy_fw_ver, PHY_FW_VER_LEN);
  368. bnx2x_release_phy_lock(bp);
  369. }
  370. strncpy(info->fw_version, bp->fw_ver, 32);
  371. snprintf(info->fw_version + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver),
  372. "bc %d.%d.%d%s%s",
  373. (bp->common.bc_ver & 0xff0000) >> 16,
  374. (bp->common.bc_ver & 0xff00) >> 8,
  375. (bp->common.bc_ver & 0xff),
  376. ((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver);
  377. strcpy(info->bus_info, pci_name(bp->pdev));
  378. info->n_stats = BNX2X_NUM_STATS;
  379. info->testinfo_len = BNX2X_NUM_TESTS;
  380. info->eedump_len = bp->common.flash_size;
  381. info->regdump_len = bnx2x_get_regs_len(dev);
  382. }
  383. static void bnx2x_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
  384. {
  385. struct bnx2x *bp = netdev_priv(dev);
  386. if (bp->flags & NO_WOL_FLAG) {
  387. wol->supported = 0;
  388. wol->wolopts = 0;
  389. } else {
  390. wol->supported = WAKE_MAGIC;
  391. if (bp->wol)
  392. wol->wolopts = WAKE_MAGIC;
  393. else
  394. wol->wolopts = 0;
  395. }
  396. memset(&wol->sopass, 0, sizeof(wol->sopass));
  397. }
  398. static int bnx2x_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
  399. {
  400. struct bnx2x *bp = netdev_priv(dev);
  401. if (wol->wolopts & ~WAKE_MAGIC)
  402. return -EINVAL;
  403. if (wol->wolopts & WAKE_MAGIC) {
  404. if (bp->flags & NO_WOL_FLAG)
  405. return -EINVAL;
  406. bp->wol = 1;
  407. } else
  408. bp->wol = 0;
  409. return 0;
  410. }
  411. static u32 bnx2x_get_msglevel(struct net_device *dev)
  412. {
  413. struct bnx2x *bp = netdev_priv(dev);
  414. return bp->msg_enable;
  415. }
  416. static void bnx2x_set_msglevel(struct net_device *dev, u32 level)
  417. {
  418. struct bnx2x *bp = netdev_priv(dev);
  419. if (capable(CAP_NET_ADMIN))
  420. bp->msg_enable = level;
  421. }
  422. static int bnx2x_nway_reset(struct net_device *dev)
  423. {
  424. struct bnx2x *bp = netdev_priv(dev);
  425. if (!bp->port.pmf)
  426. return 0;
  427. if (netif_running(dev)) {
  428. bnx2x_stats_handle(bp, STATS_EVENT_STOP);
  429. bnx2x_link_set(bp);
  430. }
  431. return 0;
  432. }
  433. static u32 bnx2x_get_link(struct net_device *dev)
  434. {
  435. struct bnx2x *bp = netdev_priv(dev);
  436. if (bp->flags & MF_FUNC_DIS || (bp->state != BNX2X_STATE_OPEN))
  437. return 0;
  438. return bp->link_vars.link_up;
  439. }
  440. static int bnx2x_get_eeprom_len(struct net_device *dev)
  441. {
  442. struct bnx2x *bp = netdev_priv(dev);
  443. return bp->common.flash_size;
  444. }
  445. static int bnx2x_acquire_nvram_lock(struct bnx2x *bp)
  446. {
  447. int port = BP_PORT(bp);
  448. int count, i;
  449. u32 val = 0;
  450. /* adjust timeout for emulation/FPGA */
  451. count = NVRAM_TIMEOUT_COUNT;
  452. if (CHIP_REV_IS_SLOW(bp))
  453. count *= 100;
  454. /* request access to nvram interface */
  455. REG_WR(bp, MCP_REG_MCPR_NVM_SW_ARB,
  456. (MCPR_NVM_SW_ARB_ARB_REQ_SET1 << port));
  457. for (i = 0; i < count*10; i++) {
  458. val = REG_RD(bp, MCP_REG_MCPR_NVM_SW_ARB);
  459. if (val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port))
  460. break;
  461. udelay(5);
  462. }
  463. if (!(val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port))) {
  464. DP(BNX2X_MSG_NVM, "cannot get access to nvram interface\n");
  465. return -EBUSY;
  466. }
  467. return 0;
  468. }
  469. static int bnx2x_release_nvram_lock(struct bnx2x *bp)
  470. {
  471. int port = BP_PORT(bp);
  472. int count, i;
  473. u32 val = 0;
  474. /* adjust timeout for emulation/FPGA */
  475. count = NVRAM_TIMEOUT_COUNT;
  476. if (CHIP_REV_IS_SLOW(bp))
  477. count *= 100;
  478. /* relinquish nvram interface */
  479. REG_WR(bp, MCP_REG_MCPR_NVM_SW_ARB,
  480. (MCPR_NVM_SW_ARB_ARB_REQ_CLR1 << port));
  481. for (i = 0; i < count*10; i++) {
  482. val = REG_RD(bp, MCP_REG_MCPR_NVM_SW_ARB);
  483. if (!(val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port)))
  484. break;
  485. udelay(5);
  486. }
  487. if (val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port)) {
  488. DP(BNX2X_MSG_NVM, "cannot free access to nvram interface\n");
  489. return -EBUSY;
  490. }
  491. return 0;
  492. }
  493. static void bnx2x_enable_nvram_access(struct bnx2x *bp)
  494. {
  495. u32 val;
  496. val = REG_RD(bp, MCP_REG_MCPR_NVM_ACCESS_ENABLE);
  497. /* enable both bits, even on read */
  498. REG_WR(bp, MCP_REG_MCPR_NVM_ACCESS_ENABLE,
  499. (val | MCPR_NVM_ACCESS_ENABLE_EN |
  500. MCPR_NVM_ACCESS_ENABLE_WR_EN));
  501. }
  502. static void bnx2x_disable_nvram_access(struct bnx2x *bp)
  503. {
  504. u32 val;
  505. val = REG_RD(bp, MCP_REG_MCPR_NVM_ACCESS_ENABLE);
  506. /* disable both bits, even after read */
  507. REG_WR(bp, MCP_REG_MCPR_NVM_ACCESS_ENABLE,
  508. (val & ~(MCPR_NVM_ACCESS_ENABLE_EN |
  509. MCPR_NVM_ACCESS_ENABLE_WR_EN)));
  510. }
  511. static int bnx2x_nvram_read_dword(struct bnx2x *bp, u32 offset, __be32 *ret_val,
  512. u32 cmd_flags)
  513. {
  514. int count, i, rc;
  515. u32 val;
  516. /* build the command word */
  517. cmd_flags |= MCPR_NVM_COMMAND_DOIT;
  518. /* need to clear DONE bit separately */
  519. REG_WR(bp, MCP_REG_MCPR_NVM_COMMAND, MCPR_NVM_COMMAND_DONE);
  520. /* address of the NVRAM to read from */
  521. REG_WR(bp, MCP_REG_MCPR_NVM_ADDR,
  522. (offset & MCPR_NVM_ADDR_NVM_ADDR_VALUE));
  523. /* issue a read command */
  524. REG_WR(bp, MCP_REG_MCPR_NVM_COMMAND, cmd_flags);
  525. /* adjust timeout for emulation/FPGA */
  526. count = NVRAM_TIMEOUT_COUNT;
  527. if (CHIP_REV_IS_SLOW(bp))
  528. count *= 100;
  529. /* wait for completion */
  530. *ret_val = 0;
  531. rc = -EBUSY;
  532. for (i = 0; i < count; i++) {
  533. udelay(5);
  534. val = REG_RD(bp, MCP_REG_MCPR_NVM_COMMAND);
  535. if (val & MCPR_NVM_COMMAND_DONE) {
  536. val = REG_RD(bp, MCP_REG_MCPR_NVM_READ);
  537. /* we read nvram data in cpu order
  538. * but ethtool sees it as an array of bytes
  539. * converting to big-endian will do the work */
  540. *ret_val = cpu_to_be32(val);
  541. rc = 0;
  542. break;
  543. }
  544. }
  545. return rc;
  546. }
  547. static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
  548. int buf_size)
  549. {
  550. int rc;
  551. u32 cmd_flags;
  552. __be32 val;
  553. if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
  554. DP(BNX2X_MSG_NVM,
  555. "Invalid parameter: offset 0x%x buf_size 0x%x\n",
  556. offset, buf_size);
  557. return -EINVAL;
  558. }
  559. if (offset + buf_size > bp->common.flash_size) {
  560. DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +"
  561. " buf_size (0x%x) > flash_size (0x%x)\n",
  562. offset, buf_size, bp->common.flash_size);
  563. return -EINVAL;
  564. }
  565. /* request access to nvram interface */
  566. rc = bnx2x_acquire_nvram_lock(bp);
  567. if (rc)
  568. return rc;
  569. /* enable access to nvram interface */
  570. bnx2x_enable_nvram_access(bp);
  571. /* read the first word(s) */
  572. cmd_flags = MCPR_NVM_COMMAND_FIRST;
  573. while ((buf_size > sizeof(u32)) && (rc == 0)) {
  574. rc = bnx2x_nvram_read_dword(bp, offset, &val, cmd_flags);
  575. memcpy(ret_buf, &val, 4);
  576. /* advance to the next dword */
  577. offset += sizeof(u32);
  578. ret_buf += sizeof(u32);
  579. buf_size -= sizeof(u32);
  580. cmd_flags = 0;
  581. }
  582. if (rc == 0) {
  583. cmd_flags |= MCPR_NVM_COMMAND_LAST;
  584. rc = bnx2x_nvram_read_dword(bp, offset, &val, cmd_flags);
  585. memcpy(ret_buf, &val, 4);
  586. }
  587. /* disable access to nvram interface */
  588. bnx2x_disable_nvram_access(bp);
  589. bnx2x_release_nvram_lock(bp);
  590. return rc;
  591. }
  592. static int bnx2x_get_eeprom(struct net_device *dev,
  593. struct ethtool_eeprom *eeprom, u8 *eebuf)
  594. {
  595. struct bnx2x *bp = netdev_priv(dev);
  596. int rc;
  597. if (!netif_running(dev))
  598. return -EAGAIN;
  599. DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n"
  600. DP_LEVEL " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n",
  601. eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset,
  602. eeprom->len, eeprom->len);
  603. /* parameters already validated in ethtool_get_eeprom */
  604. rc = bnx2x_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
  605. return rc;
  606. }
  607. static int bnx2x_nvram_write_dword(struct bnx2x *bp, u32 offset, u32 val,
  608. u32 cmd_flags)
  609. {
  610. int count, i, rc;
  611. /* build the command word */
  612. cmd_flags |= MCPR_NVM_COMMAND_DOIT | MCPR_NVM_COMMAND_WR;
  613. /* need to clear DONE bit separately */
  614. REG_WR(bp, MCP_REG_MCPR_NVM_COMMAND, MCPR_NVM_COMMAND_DONE);
  615. /* write the data */
  616. REG_WR(bp, MCP_REG_MCPR_NVM_WRITE, val);
  617. /* address of the NVRAM to write to */
  618. REG_WR(bp, MCP_REG_MCPR_NVM_ADDR,
  619. (offset & MCPR_NVM_ADDR_NVM_ADDR_VALUE));
  620. /* issue the write command */
  621. REG_WR(bp, MCP_REG_MCPR_NVM_COMMAND, cmd_flags);
  622. /* adjust timeout for emulation/FPGA */
  623. count = NVRAM_TIMEOUT_COUNT;
  624. if (CHIP_REV_IS_SLOW(bp))
  625. count *= 100;
  626. /* wait for completion */
  627. rc = -EBUSY;
  628. for (i = 0; i < count; i++) {
  629. udelay(5);
  630. val = REG_RD(bp, MCP_REG_MCPR_NVM_COMMAND);
  631. if (val & MCPR_NVM_COMMAND_DONE) {
  632. rc = 0;
  633. break;
  634. }
  635. }
  636. return rc;
  637. }
  638. #define BYTE_OFFSET(offset) (8 * (offset & 0x03))
  639. static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf,
  640. int buf_size)
  641. {
  642. int rc;
  643. u32 cmd_flags;
  644. u32 align_offset;
  645. __be32 val;
  646. if (offset + buf_size > bp->common.flash_size) {
  647. DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +"
  648. " buf_size (0x%x) > flash_size (0x%x)\n",
  649. offset, buf_size, bp->common.flash_size);
  650. return -EINVAL;
  651. }
  652. /* request access to nvram interface */
  653. rc = bnx2x_acquire_nvram_lock(bp);
  654. if (rc)
  655. return rc;
  656. /* enable access to nvram interface */
  657. bnx2x_enable_nvram_access(bp);
  658. cmd_flags = (MCPR_NVM_COMMAND_FIRST | MCPR_NVM_COMMAND_LAST);
  659. align_offset = (offset & ~0x03);
  660. rc = bnx2x_nvram_read_dword(bp, align_offset, &val, cmd_flags);
  661. if (rc == 0) {
  662. val &= ~(0xff << BYTE_OFFSET(offset));
  663. val |= (*data_buf << BYTE_OFFSET(offset));
  664. /* nvram data is returned as an array of bytes
  665. * convert it back to cpu order */
  666. val = be32_to_cpu(val);
  667. rc = bnx2x_nvram_write_dword(bp, align_offset, val,
  668. cmd_flags);
  669. }
  670. /* disable access to nvram interface */
  671. bnx2x_disable_nvram_access(bp);
  672. bnx2x_release_nvram_lock(bp);
  673. return rc;
  674. }
  675. static int bnx2x_nvram_write(struct bnx2x *bp, u32 offset, u8 *data_buf,
  676. int buf_size)
  677. {
  678. int rc;
  679. u32 cmd_flags;
  680. u32 val;
  681. u32 written_so_far;
  682. if (buf_size == 1) /* ethtool */
  683. return bnx2x_nvram_write1(bp, offset, data_buf, buf_size);
  684. if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
  685. DP(BNX2X_MSG_NVM,
  686. "Invalid parameter: offset 0x%x buf_size 0x%x\n",
  687. offset, buf_size);
  688. return -EINVAL;
  689. }
  690. if (offset + buf_size > bp->common.flash_size) {
  691. DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +"
  692. " buf_size (0x%x) > flash_size (0x%x)\n",
  693. offset, buf_size, bp->common.flash_size);
  694. return -EINVAL;
  695. }
  696. /* request access to nvram interface */
  697. rc = bnx2x_acquire_nvram_lock(bp);
  698. if (rc)
  699. return rc;
  700. /* enable access to nvram interface */
  701. bnx2x_enable_nvram_access(bp);
  702. written_so_far = 0;
  703. cmd_flags = MCPR_NVM_COMMAND_FIRST;
  704. while ((written_so_far < buf_size) && (rc == 0)) {
  705. if (written_so_far == (buf_size - sizeof(u32)))
  706. cmd_flags |= MCPR_NVM_COMMAND_LAST;
  707. else if (((offset + 4) % NVRAM_PAGE_SIZE) == 0)
  708. cmd_flags |= MCPR_NVM_COMMAND_LAST;
  709. else if ((offset % NVRAM_PAGE_SIZE) == 0)
  710. cmd_flags |= MCPR_NVM_COMMAND_FIRST;
  711. memcpy(&val, data_buf, 4);
  712. rc = bnx2x_nvram_write_dword(bp, offset, val, cmd_flags);
  713. /* advance to the next dword */
  714. offset += sizeof(u32);
  715. data_buf += sizeof(u32);
  716. written_so_far += sizeof(u32);
  717. cmd_flags = 0;
  718. }
  719. /* disable access to nvram interface */
  720. bnx2x_disable_nvram_access(bp);
  721. bnx2x_release_nvram_lock(bp);
  722. return rc;
  723. }
  724. static int bnx2x_set_eeprom(struct net_device *dev,
  725. struct ethtool_eeprom *eeprom, u8 *eebuf)
  726. {
  727. struct bnx2x *bp = netdev_priv(dev);
  728. int port = BP_PORT(bp);
  729. int rc = 0;
  730. u32 ext_phy_config;
  731. if (!netif_running(dev))
  732. return -EAGAIN;
  733. DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n"
  734. DP_LEVEL " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n",
  735. eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset,
  736. eeprom->len, eeprom->len);
  737. /* parameters already validated in ethtool_set_eeprom */
  738. /* PHY eeprom can be accessed only by the PMF */
  739. if ((eeprom->magic >= 0x50485900) && (eeprom->magic <= 0x504859FF) &&
  740. !bp->port.pmf)
  741. return -EINVAL;
  742. ext_phy_config =
  743. SHMEM_RD(bp,
  744. dev_info.port_hw_config[port].external_phy_config);
  745. if (eeprom->magic == 0x50485950) {
  746. /* 'PHYP' (0x50485950): prepare phy for FW upgrade */
  747. bnx2x_stats_handle(bp, STATS_EVENT_STOP);
  748. bnx2x_acquire_phy_lock(bp);
  749. rc |= bnx2x_link_reset(&bp->link_params,
  750. &bp->link_vars, 0);
  751. if (XGXS_EXT_PHY_TYPE(ext_phy_config) ==
  752. PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101)
  753. bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0,
  754. MISC_REGISTERS_GPIO_HIGH, port);
  755. bnx2x_release_phy_lock(bp);
  756. bnx2x_link_report(bp);
  757. } else if (eeprom->magic == 0x50485952) {
  758. /* 'PHYR' (0x50485952): re-init link after FW upgrade */
  759. if (bp->state == BNX2X_STATE_OPEN) {
  760. bnx2x_acquire_phy_lock(bp);
  761. rc |= bnx2x_link_reset(&bp->link_params,
  762. &bp->link_vars, 1);
  763. rc |= bnx2x_phy_init(&bp->link_params,
  764. &bp->link_vars);
  765. bnx2x_release_phy_lock(bp);
  766. bnx2x_calc_fc_adv(bp);
  767. }
  768. } else if (eeprom->magic == 0x53985943) {
  769. /* 'PHYC' (0x53985943): PHY FW upgrade completed */
  770. if (XGXS_EXT_PHY_TYPE(ext_phy_config) ==
  771. PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101) {
  772. /* DSP Remove Download Mode */
  773. bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0,
  774. MISC_REGISTERS_GPIO_LOW, port);
  775. bnx2x_acquire_phy_lock(bp);
  776. bnx2x_sfx7101_sp_sw_reset(bp,
  777. &bp->link_params.phy[EXT_PHY1]);
  778. /* wait 0.5 sec to allow it to run */
  779. msleep(500);
  780. bnx2x_ext_phy_hw_reset(bp, port);
  781. msleep(500);
  782. bnx2x_release_phy_lock(bp);
  783. }
  784. } else
  785. rc = bnx2x_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
  786. return rc;
  787. }
  788. static int bnx2x_get_coalesce(struct net_device *dev,
  789. struct ethtool_coalesce *coal)
  790. {
  791. struct bnx2x *bp = netdev_priv(dev);
  792. memset(coal, 0, sizeof(struct ethtool_coalesce));
  793. coal->rx_coalesce_usecs = bp->rx_ticks;
  794. coal->tx_coalesce_usecs = bp->tx_ticks;
  795. return 0;
  796. }
  797. static int bnx2x_set_coalesce(struct net_device *dev,
  798. struct ethtool_coalesce *coal)
  799. {
  800. struct bnx2x *bp = netdev_priv(dev);
  801. bp->rx_ticks = (u16)coal->rx_coalesce_usecs;
  802. if (bp->rx_ticks > BNX2X_MAX_COALESCE_TOUT)
  803. bp->rx_ticks = BNX2X_MAX_COALESCE_TOUT;
  804. bp->tx_ticks = (u16)coal->tx_coalesce_usecs;
  805. if (bp->tx_ticks > BNX2X_MAX_COALESCE_TOUT)
  806. bp->tx_ticks = BNX2X_MAX_COALESCE_TOUT;
  807. if (netif_running(dev))
  808. bnx2x_update_coalesce(bp);
  809. return 0;
  810. }
  811. static void bnx2x_get_ringparam(struct net_device *dev,
  812. struct ethtool_ringparam *ering)
  813. {
  814. struct bnx2x *bp = netdev_priv(dev);
  815. ering->rx_max_pending = MAX_RX_AVAIL;
  816. ering->rx_mini_max_pending = 0;
  817. ering->rx_jumbo_max_pending = 0;
  818. if (bp->rx_ring_size)
  819. ering->rx_pending = bp->rx_ring_size;
  820. else
  821. if (bp->state == BNX2X_STATE_OPEN && bp->num_queues)
  822. ering->rx_pending = MAX_RX_AVAIL/bp->num_queues;
  823. else
  824. ering->rx_pending = MAX_RX_AVAIL;
  825. ering->rx_mini_pending = 0;
  826. ering->rx_jumbo_pending = 0;
  827. ering->tx_max_pending = MAX_TX_AVAIL;
  828. ering->tx_pending = bp->tx_ring_size;
  829. }
  830. static int bnx2x_set_ringparam(struct net_device *dev,
  831. struct ethtool_ringparam *ering)
  832. {
  833. struct bnx2x *bp = netdev_priv(dev);
  834. int rc = 0;
  835. if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
  836. printk(KERN_ERR "Handling parity error recovery. Try again later\n");
  837. return -EAGAIN;
  838. }
  839. if ((ering->rx_pending > MAX_RX_AVAIL) ||
  840. (ering->rx_pending < MIN_RX_AVAIL) ||
  841. (ering->tx_pending > MAX_TX_AVAIL) ||
  842. (ering->tx_pending <= MAX_SKB_FRAGS + 4))
  843. return -EINVAL;
  844. bp->rx_ring_size = ering->rx_pending;
  845. bp->tx_ring_size = ering->tx_pending;
  846. if (netif_running(dev)) {
  847. bnx2x_nic_unload(bp, UNLOAD_NORMAL);
  848. rc = bnx2x_nic_load(bp, LOAD_NORMAL);
  849. }
  850. return rc;
  851. }
  852. static void bnx2x_get_pauseparam(struct net_device *dev,
  853. struct ethtool_pauseparam *epause)
  854. {
  855. struct bnx2x *bp = netdev_priv(dev);
  856. int cfg_idx = bnx2x_get_link_cfg_idx(bp);
  857. epause->autoneg = (bp->link_params.req_flow_ctrl[cfg_idx] ==
  858. BNX2X_FLOW_CTRL_AUTO);
  859. epause->rx_pause = ((bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_RX) ==
  860. BNX2X_FLOW_CTRL_RX);
  861. epause->tx_pause = ((bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX) ==
  862. BNX2X_FLOW_CTRL_TX);
  863. DP(NETIF_MSG_LINK, "ethtool_pauseparam: cmd %d\n"
  864. DP_LEVEL " autoneg %d rx_pause %d tx_pause %d\n",
  865. epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause);
  866. }
  867. static int bnx2x_set_pauseparam(struct net_device *dev,
  868. struct ethtool_pauseparam *epause)
  869. {
  870. struct bnx2x *bp = netdev_priv(dev);
  871. u32 cfg_idx = bnx2x_get_link_cfg_idx(bp);
  872. if (IS_MF(bp))
  873. return 0;
  874. DP(NETIF_MSG_LINK, "ethtool_pauseparam: cmd %d\n"
  875. DP_LEVEL " autoneg %d rx_pause %d tx_pause %d\n",
  876. epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause);
  877. bp->link_params.req_flow_ctrl[cfg_idx] = BNX2X_FLOW_CTRL_AUTO;
  878. if (epause->rx_pause)
  879. bp->link_params.req_flow_ctrl[cfg_idx] |= BNX2X_FLOW_CTRL_RX;
  880. if (epause->tx_pause)
  881. bp->link_params.req_flow_ctrl[cfg_idx] |= BNX2X_FLOW_CTRL_TX;
  882. if (bp->link_params.req_flow_ctrl[cfg_idx] == BNX2X_FLOW_CTRL_AUTO)
  883. bp->link_params.req_flow_ctrl[cfg_idx] = BNX2X_FLOW_CTRL_NONE;
  884. if (epause->autoneg) {
  885. if (!(bp->port.supported[cfg_idx] & SUPPORTED_Autoneg)) {
  886. DP(NETIF_MSG_LINK, "autoneg not supported\n");
  887. return -EINVAL;
  888. }
  889. if (bp->link_params.req_line_speed[cfg_idx] == SPEED_AUTO_NEG) {
  890. bp->link_params.req_flow_ctrl[cfg_idx] =
  891. BNX2X_FLOW_CTRL_AUTO;
  892. }
  893. }
  894. DP(NETIF_MSG_LINK,
  895. "req_flow_ctrl 0x%x\n", bp->link_params.req_flow_ctrl[cfg_idx]);
  896. if (netif_running(dev)) {
  897. bnx2x_stats_handle(bp, STATS_EVENT_STOP);
  898. bnx2x_link_set(bp);
  899. }
  900. return 0;
  901. }
  902. static int bnx2x_set_flags(struct net_device *dev, u32 data)
  903. {
  904. struct bnx2x *bp = netdev_priv(dev);
  905. int changed = 0;
  906. int rc = 0;
  907. if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
  908. printk(KERN_ERR "Handling parity error recovery. Try again later\n");
  909. return -EAGAIN;
  910. }
  911. if (!(data & ETH_FLAG_RXVLAN))
  912. return -EINVAL;
  913. if ((data & ETH_FLAG_LRO) && bp->rx_csum && bp->disable_tpa)
  914. return -EINVAL;
  915. rc = ethtool_op_set_flags(dev, data, ETH_FLAG_LRO | ETH_FLAG_RXVLAN |
  916. ETH_FLAG_TXVLAN | ETH_FLAG_RXHASH);
  917. if (rc)
  918. return rc;
  919. /* TPA requires Rx CSUM offloading */
  920. if ((data & ETH_FLAG_LRO) && bp->rx_csum) {
  921. if (!(bp->flags & TPA_ENABLE_FLAG)) {
  922. bp->flags |= TPA_ENABLE_FLAG;
  923. changed = 1;
  924. }
  925. } else if (bp->flags & TPA_ENABLE_FLAG) {
  926. dev->features &= ~NETIF_F_LRO;
  927. bp->flags &= ~TPA_ENABLE_FLAG;
  928. changed = 1;
  929. }
  930. if (changed && netif_running(dev)) {
  931. bnx2x_nic_unload(bp, UNLOAD_NORMAL);
  932. rc = bnx2x_nic_load(bp, LOAD_NORMAL);
  933. }
  934. return rc;
  935. }
  936. static u32 bnx2x_get_rx_csum(struct net_device *dev)
  937. {
  938. struct bnx2x *bp = netdev_priv(dev);
  939. return bp->rx_csum;
  940. }
  941. static int bnx2x_set_rx_csum(struct net_device *dev, u32 data)
  942. {
  943. struct bnx2x *bp = netdev_priv(dev);
  944. int rc = 0;
  945. if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
  946. printk(KERN_ERR "Handling parity error recovery. Try again later\n");
  947. return -EAGAIN;
  948. }
  949. bp->rx_csum = data;
  950. /* Disable TPA, when Rx CSUM is disabled. Otherwise all
  951. TPA'ed packets will be discarded due to wrong TCP CSUM */
  952. if (!data) {
  953. u32 flags = ethtool_op_get_flags(dev);
  954. rc = bnx2x_set_flags(dev, (flags & ~ETH_FLAG_LRO));
  955. }
  956. return rc;
  957. }
  958. static int bnx2x_set_tso(struct net_device *dev, u32 data)
  959. {
  960. if (data) {
  961. dev->features |= (NETIF_F_TSO | NETIF_F_TSO_ECN);
  962. dev->features |= NETIF_F_TSO6;
  963. } else {
  964. dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO_ECN);
  965. dev->features &= ~NETIF_F_TSO6;
  966. }
  967. return 0;
  968. }
  969. static const struct {
  970. char string[ETH_GSTRING_LEN];
  971. } bnx2x_tests_str_arr[BNX2X_NUM_TESTS] = {
  972. { "register_test (offline)" },
  973. { "memory_test (offline)" },
  974. { "loopback_test (offline)" },
  975. { "nvram_test (online)" },
  976. { "interrupt_test (online)" },
  977. { "link_test (online)" },
  978. { "idle check (online)" }
  979. };
  980. static int bnx2x_test_registers(struct bnx2x *bp)
  981. {
  982. int idx, i, rc = -ENODEV;
  983. u32 wr_val = 0;
  984. int port = BP_PORT(bp);
  985. static const struct {
  986. u32 offset0;
  987. u32 offset1;
  988. u32 mask;
  989. } reg_tbl[] = {
  990. /* 0 */ { BRB1_REG_PAUSE_LOW_THRESHOLD_0, 4, 0x000003ff },
  991. { DORQ_REG_DB_ADDR0, 4, 0xffffffff },
  992. { HC_REG_AGG_INT_0, 4, 0x000003ff },
  993. { PBF_REG_MAC_IF0_ENABLE, 4, 0x00000001 },
  994. { PBF_REG_P0_INIT_CRD, 4, 0x000007ff },
  995. { PRS_REG_CID_PORT_0, 4, 0x00ffffff },
  996. { PXP2_REG_PSWRQ_CDU0_L2P, 4, 0x000fffff },
  997. { PXP2_REG_RQ_CDU0_EFIRST_MEM_ADDR, 8, 0x0003ffff },
  998. { PXP2_REG_PSWRQ_TM0_L2P, 4, 0x000fffff },
  999. { PXP2_REG_RQ_USDM0_EFIRST_MEM_ADDR, 8, 0x0003ffff },
  1000. /* 10 */ { PXP2_REG_PSWRQ_TSDM0_L2P, 4, 0x000fffff },
  1001. { QM_REG_CONNNUM_0, 4, 0x000fffff },
  1002. { TM_REG_LIN0_MAX_ACTIVE_CID, 4, 0x0003ffff },
  1003. { SRC_REG_KEYRSS0_0, 40, 0xffffffff },
  1004. { SRC_REG_KEYRSS0_7, 40, 0xffffffff },
  1005. { XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 4, 0x00000001 },
  1006. { XCM_REG_WU_DA_CNT_CMD00, 4, 0x00000003 },
  1007. { XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 4, 0x000000ff },
  1008. { NIG_REG_LLH0_T_BIT, 4, 0x00000001 },
  1009. { NIG_REG_EMAC0_IN_EN, 4, 0x00000001 },
  1010. /* 20 */ { NIG_REG_BMAC0_IN_EN, 4, 0x00000001 },
  1011. { NIG_REG_XCM0_OUT_EN, 4, 0x00000001 },
  1012. { NIG_REG_BRB0_OUT_EN, 4, 0x00000001 },
  1013. { NIG_REG_LLH0_XCM_MASK, 4, 0x00000007 },
  1014. { NIG_REG_LLH0_ACPI_PAT_6_LEN, 68, 0x000000ff },
  1015. { NIG_REG_LLH0_ACPI_PAT_0_CRC, 68, 0xffffffff },
  1016. { NIG_REG_LLH0_DEST_MAC_0_0, 160, 0xffffffff },
  1017. { NIG_REG_LLH0_DEST_IP_0_1, 160, 0xffffffff },
  1018. { NIG_REG_LLH0_IPV4_IPV6_0, 160, 0x00000001 },
  1019. { NIG_REG_LLH0_DEST_UDP_0, 160, 0x0000ffff },
  1020. /* 30 */ { NIG_REG_LLH0_DEST_TCP_0, 160, 0x0000ffff },
  1021. { NIG_REG_LLH0_VLAN_ID_0, 160, 0x00000fff },
  1022. { NIG_REG_XGXS_SERDES0_MODE_SEL, 4, 0x00000001 },
  1023. { NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0, 4, 0x00000001 },
  1024. { NIG_REG_STATUS_INTERRUPT_PORT0, 4, 0x07ffffff },
  1025. { NIG_REG_XGXS0_CTRL_EXTREMOTEMDIOST, 24, 0x00000001 },
  1026. { NIG_REG_SERDES0_CTRL_PHY_ADDR, 16, 0x0000001f },
  1027. { 0xffffffff, 0, 0x00000000 }
  1028. };
  1029. if (!netif_running(bp->dev))
  1030. return rc;
  1031. /* Repeat the test twice:
  1032. First by writing 0x00000000, second by writing 0xffffffff */
  1033. for (idx = 0; idx < 2; idx++) {
  1034. switch (idx) {
  1035. case 0:
  1036. wr_val = 0;
  1037. break;
  1038. case 1:
  1039. wr_val = 0xffffffff;
  1040. break;
  1041. }
  1042. for (i = 0; reg_tbl[i].offset0 != 0xffffffff; i++) {
  1043. u32 offset, mask, save_val, val;
  1044. if (CHIP_IS_E2(bp) &&
  1045. reg_tbl[i].offset0 == HC_REG_AGG_INT_0)
  1046. continue;
  1047. offset = reg_tbl[i].offset0 + port*reg_tbl[i].offset1;
  1048. mask = reg_tbl[i].mask;
  1049. save_val = REG_RD(bp, offset);
  1050. REG_WR(bp, offset, (wr_val & mask));
  1051. val = REG_RD(bp, offset);
  1052. /* Restore the original register's value */
  1053. REG_WR(bp, offset, save_val);
  1054. /* verify value is as expected */
  1055. if ((val & mask) != (wr_val & mask)) {
  1056. DP(NETIF_MSG_PROBE,
  1057. "offset 0x%x: val 0x%x != 0x%x mask 0x%x\n",
  1058. offset, val, wr_val, mask);
  1059. goto test_reg_exit;
  1060. }
  1061. }
  1062. }
  1063. rc = 0;
  1064. test_reg_exit:
  1065. return rc;
  1066. }
  1067. static int bnx2x_test_memory(struct bnx2x *bp)
  1068. {
  1069. int i, j, rc = -ENODEV;
  1070. u32 val;
  1071. static const struct {
  1072. u32 offset;
  1073. int size;
  1074. } mem_tbl[] = {
  1075. { CCM_REG_XX_DESCR_TABLE, CCM_REG_XX_DESCR_TABLE_SIZE },
  1076. { CFC_REG_ACTIVITY_COUNTER, CFC_REG_ACTIVITY_COUNTER_SIZE },
  1077. { CFC_REG_LINK_LIST, CFC_REG_LINK_LIST_SIZE },
  1078. { DMAE_REG_CMD_MEM, DMAE_REG_CMD_MEM_SIZE },
  1079. { TCM_REG_XX_DESCR_TABLE, TCM_REG_XX_DESCR_TABLE_SIZE },
  1080. { UCM_REG_XX_DESCR_TABLE, UCM_REG_XX_DESCR_TABLE_SIZE },
  1081. { XCM_REG_XX_DESCR_TABLE, XCM_REG_XX_DESCR_TABLE_SIZE },
  1082. { 0xffffffff, 0 }
  1083. };
  1084. static const struct {
  1085. char *name;
  1086. u32 offset;
  1087. u32 e1_mask;
  1088. u32 e1h_mask;
  1089. u32 e2_mask;
  1090. } prty_tbl[] = {
  1091. { "CCM_PRTY_STS", CCM_REG_CCM_PRTY_STS, 0x3ffc0, 0, 0 },
  1092. { "CFC_PRTY_STS", CFC_REG_CFC_PRTY_STS, 0x2, 0x2, 0 },
  1093. { "DMAE_PRTY_STS", DMAE_REG_DMAE_PRTY_STS, 0, 0, 0 },
  1094. { "TCM_PRTY_STS", TCM_REG_TCM_PRTY_STS, 0x3ffc0, 0, 0 },
  1095. { "UCM_PRTY_STS", UCM_REG_UCM_PRTY_STS, 0x3ffc0, 0, 0 },
  1096. { "XCM_PRTY_STS", XCM_REG_XCM_PRTY_STS, 0x3ffc1, 0, 0 },
  1097. { NULL, 0xffffffff, 0, 0, 0 }
  1098. };
  1099. if (!netif_running(bp->dev))
  1100. return rc;
  1101. /* pre-Check the parity status */
  1102. for (i = 0; prty_tbl[i].offset != 0xffffffff; i++) {
  1103. val = REG_RD(bp, prty_tbl[i].offset);
  1104. if ((CHIP_IS_E1(bp) && (val & ~(prty_tbl[i].e1_mask))) ||
  1105. (CHIP_IS_E1H(bp) && (val & ~(prty_tbl[i].e1h_mask))) ||
  1106. (CHIP_IS_E2(bp) && (val & ~(prty_tbl[i].e2_mask)))) {
  1107. DP(NETIF_MSG_HW,
  1108. "%s is 0x%x\n", prty_tbl[i].name, val);
  1109. goto test_mem_exit;
  1110. }
  1111. }
  1112. /* Go through all the memories */
  1113. for (i = 0; mem_tbl[i].offset != 0xffffffff; i++)
  1114. for (j = 0; j < mem_tbl[i].size; j++)
  1115. REG_RD(bp, mem_tbl[i].offset + j*4);
  1116. /* Check the parity status */
  1117. for (i = 0; prty_tbl[i].offset != 0xffffffff; i++) {
  1118. val = REG_RD(bp, prty_tbl[i].offset);
  1119. if ((CHIP_IS_E1(bp) && (val & ~(prty_tbl[i].e1_mask))) ||
  1120. (CHIP_IS_E1H(bp) && (val & ~(prty_tbl[i].e1h_mask))) ||
  1121. (CHIP_IS_E2(bp) && (val & ~(prty_tbl[i].e2_mask)))) {
  1122. DP(NETIF_MSG_HW,
  1123. "%s is 0x%x\n", prty_tbl[i].name, val);
  1124. goto test_mem_exit;
  1125. }
  1126. }
  1127. rc = 0;
  1128. test_mem_exit:
  1129. return rc;
  1130. }
  1131. static void bnx2x_wait_for_link(struct bnx2x *bp, u8 link_up, u8 is_serdes)
  1132. {
  1133. int cnt = 1400;
  1134. if (link_up)
  1135. while (bnx2x_link_test(bp, is_serdes) && cnt--)
  1136. msleep(10);
  1137. }
  1138. static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
  1139. {
  1140. unsigned int pkt_size, num_pkts, i;
  1141. struct sk_buff *skb;
  1142. unsigned char *packet;
  1143. struct bnx2x_fastpath *fp_rx = &bp->fp[0];
  1144. struct bnx2x_fastpath *fp_tx = &bp->fp[0];
  1145. u16 tx_start_idx, tx_idx;
  1146. u16 rx_start_idx, rx_idx;
  1147. u16 pkt_prod, bd_prod;
  1148. struct sw_tx_bd *tx_buf;
  1149. struct eth_tx_start_bd *tx_start_bd;
  1150. struct eth_tx_parse_bd_e1x *pbd_e1x = NULL;
  1151. struct eth_tx_parse_bd_e2 *pbd_e2 = NULL;
  1152. dma_addr_t mapping;
  1153. union eth_rx_cqe *cqe;
  1154. u8 cqe_fp_flags;
  1155. struct sw_rx_bd *rx_buf;
  1156. u16 len;
  1157. int rc = -ENODEV;
  1158. /* check the loopback mode */
  1159. switch (loopback_mode) {
  1160. case BNX2X_PHY_LOOPBACK:
  1161. if (bp->link_params.loopback_mode != LOOPBACK_XGXS)
  1162. return -EINVAL;
  1163. break;
  1164. case BNX2X_MAC_LOOPBACK:
  1165. bp->link_params.loopback_mode = LOOPBACK_BMAC;
  1166. bnx2x_phy_init(&bp->link_params, &bp->link_vars);
  1167. break;
  1168. default:
  1169. return -EINVAL;
  1170. }
  1171. /* prepare the loopback packet */
  1172. pkt_size = (((bp->dev->mtu < ETH_MAX_PACKET_SIZE) ?
  1173. bp->dev->mtu : ETH_MAX_PACKET_SIZE) + ETH_HLEN);
  1174. skb = netdev_alloc_skb(bp->dev, bp->rx_buf_size);
  1175. if (!skb) {
  1176. rc = -ENOMEM;
  1177. goto test_loopback_exit;
  1178. }
  1179. packet = skb_put(skb, pkt_size);
  1180. memcpy(packet, bp->dev->dev_addr, ETH_ALEN);
  1181. memset(packet + ETH_ALEN, 0, ETH_ALEN);
  1182. memset(packet + 2*ETH_ALEN, 0x77, (ETH_HLEN - 2*ETH_ALEN));
  1183. for (i = ETH_HLEN; i < pkt_size; i++)
  1184. packet[i] = (unsigned char) (i & 0xff);
  1185. /* send the loopback packet */
  1186. num_pkts = 0;
  1187. tx_start_idx = le16_to_cpu(*fp_tx->tx_cons_sb);
  1188. rx_start_idx = le16_to_cpu(*fp_rx->rx_cons_sb);
  1189. pkt_prod = fp_tx->tx_pkt_prod++;
  1190. tx_buf = &fp_tx->tx_buf_ring[TX_BD(pkt_prod)];
  1191. tx_buf->first_bd = fp_tx->tx_bd_prod;
  1192. tx_buf->skb = skb;
  1193. tx_buf->flags = 0;
  1194. bd_prod = TX_BD(fp_tx->tx_bd_prod);
  1195. tx_start_bd = &fp_tx->tx_desc_ring[bd_prod].start_bd;
  1196. mapping = dma_map_single(&bp->pdev->dev, skb->data,
  1197. skb_headlen(skb), DMA_TO_DEVICE);
  1198. tx_start_bd->addr_hi = cpu_to_le32(U64_HI(mapping));
  1199. tx_start_bd->addr_lo = cpu_to_le32(U64_LO(mapping));
  1200. tx_start_bd->nbd = cpu_to_le16(2); /* start + pbd */
  1201. tx_start_bd->nbytes = cpu_to_le16(skb_headlen(skb));
  1202. tx_start_bd->vlan_or_ethertype = cpu_to_le16(pkt_prod);
  1203. tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
  1204. SET_FLAG(tx_start_bd->general_data,
  1205. ETH_TX_START_BD_ETH_ADDR_TYPE,
  1206. UNICAST_ADDRESS);
  1207. SET_FLAG(tx_start_bd->general_data,
  1208. ETH_TX_START_BD_HDR_NBDS,
  1209. 1);
  1210. /* turn on parsing and get a BD */
  1211. bd_prod = TX_BD(NEXT_TX_IDX(bd_prod));
  1212. pbd_e1x = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e1x;
  1213. pbd_e2 = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e2;
  1214. memset(pbd_e2, 0, sizeof(struct eth_tx_parse_bd_e2));
  1215. memset(pbd_e1x, 0, sizeof(struct eth_tx_parse_bd_e1x));
  1216. wmb();
  1217. fp_tx->tx_db.data.prod += 2;
  1218. barrier();
  1219. DOORBELL(bp, fp_tx->index, fp_tx->tx_db.raw);
  1220. mmiowb();
  1221. num_pkts++;
  1222. fp_tx->tx_bd_prod += 2; /* start + pbd */
  1223. udelay(100);
  1224. tx_idx = le16_to_cpu(*fp_tx->tx_cons_sb);
  1225. if (tx_idx != tx_start_idx + num_pkts)
  1226. goto test_loopback_exit;
  1227. /* Unlike HC IGU won't generate an interrupt for status block
  1228. * updates that have been performed while interrupts were
  1229. * disabled.
  1230. */
  1231. if (bp->common.int_block == INT_BLOCK_IGU)
  1232. bnx2x_tx_int(fp_tx);
  1233. rx_idx = le16_to_cpu(*fp_rx->rx_cons_sb);
  1234. if (rx_idx != rx_start_idx + num_pkts)
  1235. goto test_loopback_exit;
  1236. cqe = &fp_rx->rx_comp_ring[RCQ_BD(fp_rx->rx_comp_cons)];
  1237. cqe_fp_flags = cqe->fast_path_cqe.type_error_flags;
  1238. if (CQE_TYPE(cqe_fp_flags) || (cqe_fp_flags & ETH_RX_ERROR_FALGS))
  1239. goto test_loopback_rx_exit;
  1240. len = le16_to_cpu(cqe->fast_path_cqe.pkt_len);
  1241. if (len != pkt_size)
  1242. goto test_loopback_rx_exit;
  1243. rx_buf = &fp_rx->rx_buf_ring[RX_BD(fp_rx->rx_bd_cons)];
  1244. skb = rx_buf->skb;
  1245. skb_reserve(skb, cqe->fast_path_cqe.placement_offset);
  1246. for (i = ETH_HLEN; i < pkt_size; i++)
  1247. if (*(skb->data + i) != (unsigned char) (i & 0xff))
  1248. goto test_loopback_rx_exit;
  1249. rc = 0;
  1250. test_loopback_rx_exit:
  1251. fp_rx->rx_bd_cons = NEXT_RX_IDX(fp_rx->rx_bd_cons);
  1252. fp_rx->rx_bd_prod = NEXT_RX_IDX(fp_rx->rx_bd_prod);
  1253. fp_rx->rx_comp_cons = NEXT_RCQ_IDX(fp_rx->rx_comp_cons);
  1254. fp_rx->rx_comp_prod = NEXT_RCQ_IDX(fp_rx->rx_comp_prod);
  1255. /* Update producers */
  1256. bnx2x_update_rx_prod(bp, fp_rx, fp_rx->rx_bd_prod, fp_rx->rx_comp_prod,
  1257. fp_rx->rx_sge_prod);
  1258. test_loopback_exit:
  1259. bp->link_params.loopback_mode = LOOPBACK_NONE;
  1260. return rc;
  1261. }
  1262. static int bnx2x_test_loopback(struct bnx2x *bp, u8 link_up)
  1263. {
  1264. int rc = 0, res;
  1265. if (BP_NOMCP(bp))
  1266. return rc;
  1267. if (!netif_running(bp->dev))
  1268. return BNX2X_LOOPBACK_FAILED;
  1269. bnx2x_netif_stop(bp, 1);
  1270. bnx2x_acquire_phy_lock(bp);
  1271. res = bnx2x_run_loopback(bp, BNX2X_PHY_LOOPBACK, link_up);
  1272. if (res) {
  1273. DP(NETIF_MSG_PROBE, " PHY loopback failed (res %d)\n", res);
  1274. rc |= BNX2X_PHY_LOOPBACK_FAILED;
  1275. }
  1276. res = bnx2x_run_loopback(bp, BNX2X_MAC_LOOPBACK, link_up);
  1277. if (res) {
  1278. DP(NETIF_MSG_PROBE, " MAC loopback failed (res %d)\n", res);
  1279. rc |= BNX2X_MAC_LOOPBACK_FAILED;
  1280. }
  1281. bnx2x_release_phy_lock(bp);
  1282. bnx2x_netif_start(bp);
  1283. return rc;
  1284. }
  1285. #define CRC32_RESIDUAL 0xdebb20e3
  1286. static int bnx2x_test_nvram(struct bnx2x *bp)
  1287. {
  1288. static const struct {
  1289. int offset;
  1290. int size;
  1291. } nvram_tbl[] = {
  1292. { 0, 0x14 }, /* bootstrap */
  1293. { 0x14, 0xec }, /* dir */
  1294. { 0x100, 0x350 }, /* manuf_info */
  1295. { 0x450, 0xf0 }, /* feature_info */
  1296. { 0x640, 0x64 }, /* upgrade_key_info */
  1297. { 0x6a4, 0x64 },
  1298. { 0x708, 0x70 }, /* manuf_key_info */
  1299. { 0x778, 0x70 },
  1300. { 0, 0 }
  1301. };
  1302. __be32 buf[0x350 / 4];
  1303. u8 *data = (u8 *)buf;
  1304. int i, rc;
  1305. u32 magic, crc;
  1306. if (BP_NOMCP(bp))
  1307. return 0;
  1308. rc = bnx2x_nvram_read(bp, 0, data, 4);
  1309. if (rc) {
  1310. DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc);
  1311. goto test_nvram_exit;
  1312. }
  1313. magic = be32_to_cpu(buf[0]);
  1314. if (magic != 0x669955aa) {
  1315. DP(NETIF_MSG_PROBE, "magic value (0x%08x)\n", magic);
  1316. rc = -ENODEV;
  1317. goto test_nvram_exit;
  1318. }
  1319. for (i = 0; nvram_tbl[i].size; i++) {
  1320. rc = bnx2x_nvram_read(bp, nvram_tbl[i].offset, data,
  1321. nvram_tbl[i].size);
  1322. if (rc) {
  1323. DP(NETIF_MSG_PROBE,
  1324. "nvram_tbl[%d] read data (rc %d)\n", i, rc);
  1325. goto test_nvram_exit;
  1326. }
  1327. crc = ether_crc_le(nvram_tbl[i].size, data);
  1328. if (crc != CRC32_RESIDUAL) {
  1329. DP(NETIF_MSG_PROBE,
  1330. "nvram_tbl[%d] crc value (0x%08x)\n", i, crc);
  1331. rc = -ENODEV;
  1332. goto test_nvram_exit;
  1333. }
  1334. }
  1335. test_nvram_exit:
  1336. return rc;
  1337. }
  1338. static int bnx2x_test_intr(struct bnx2x *bp)
  1339. {
  1340. struct mac_configuration_cmd *config = bnx2x_sp(bp, mac_config);
  1341. int i, rc;
  1342. if (!netif_running(bp->dev))
  1343. return -ENODEV;
  1344. config->hdr.length = 0;
  1345. if (CHIP_IS_E1(bp))
  1346. config->hdr.offset = (BP_PORT(bp) ? 32 : 0);
  1347. else
  1348. config->hdr.offset = BP_FUNC(bp);
  1349. config->hdr.client_id = bp->fp->cl_id;
  1350. config->hdr.reserved1 = 0;
  1351. bp->set_mac_pending++;
  1352. smp_wmb();
  1353. rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_SET_MAC, 0,
  1354. U64_HI(bnx2x_sp_mapping(bp, mac_config)),
  1355. U64_LO(bnx2x_sp_mapping(bp, mac_config)), 1);
  1356. if (rc == 0) {
  1357. for (i = 0; i < 10; i++) {
  1358. if (!bp->set_mac_pending)
  1359. break;
  1360. smp_rmb();
  1361. msleep_interruptible(10);
  1362. }
  1363. if (i == 10)
  1364. rc = -ENODEV;
  1365. }
  1366. return rc;
  1367. }
  1368. static void bnx2x_self_test(struct net_device *dev,
  1369. struct ethtool_test *etest, u64 *buf)
  1370. {
  1371. struct bnx2x *bp = netdev_priv(dev);
  1372. u8 is_serdes;
  1373. if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
  1374. printk(KERN_ERR "Handling parity error recovery. Try again later\n");
  1375. etest->flags |= ETH_TEST_FL_FAILED;
  1376. return;
  1377. }
  1378. memset(buf, 0, sizeof(u64) * BNX2X_NUM_TESTS);
  1379. if (!netif_running(dev))
  1380. return;
  1381. /* offline tests are not supported in MF mode */
  1382. if (IS_MF(bp))
  1383. etest->flags &= ~ETH_TEST_FL_OFFLINE;
  1384. is_serdes = (bp->link_vars.link_status & LINK_STATUS_SERDES_LINK) > 0;
  1385. if (etest->flags & ETH_TEST_FL_OFFLINE) {
  1386. int port = BP_PORT(bp);
  1387. u32 val;
  1388. u8 link_up;
  1389. /* save current value of input enable for TX port IF */
  1390. val = REG_RD(bp, NIG_REG_EGRESS_UMP0_IN_EN + port*4);
  1391. /* disable input for TX port IF */
  1392. REG_WR(bp, NIG_REG_EGRESS_UMP0_IN_EN + port*4, 0);
  1393. link_up = bp->link_vars.link_up;
  1394. bnx2x_nic_unload(bp, UNLOAD_NORMAL);
  1395. bnx2x_nic_load(bp, LOAD_DIAG);
  1396. /* wait until link state is restored */
  1397. bnx2x_wait_for_link(bp, link_up, is_serdes);
  1398. if (bnx2x_test_registers(bp) != 0) {
  1399. buf[0] = 1;
  1400. etest->flags |= ETH_TEST_FL_FAILED;
  1401. }
  1402. if (bnx2x_test_memory(bp) != 0) {
  1403. buf[1] = 1;
  1404. etest->flags |= ETH_TEST_FL_FAILED;
  1405. }
  1406. buf[2] = bnx2x_test_loopback(bp, link_up);
  1407. if (buf[2] != 0)
  1408. etest->flags |= ETH_TEST_FL_FAILED;
  1409. bnx2x_nic_unload(bp, UNLOAD_NORMAL);
  1410. /* restore input for TX port IF */
  1411. REG_WR(bp, NIG_REG_EGRESS_UMP0_IN_EN + port*4, val);
  1412. bnx2x_nic_load(bp, LOAD_NORMAL);
  1413. /* wait until link state is restored */
  1414. bnx2x_wait_for_link(bp, link_up, is_serdes);
  1415. }
  1416. if (bnx2x_test_nvram(bp) != 0) {
  1417. buf[3] = 1;
  1418. etest->flags |= ETH_TEST_FL_FAILED;
  1419. }
  1420. if (bnx2x_test_intr(bp) != 0) {
  1421. buf[4] = 1;
  1422. etest->flags |= ETH_TEST_FL_FAILED;
  1423. }
  1424. if (bp->port.pmf)
  1425. if (bnx2x_link_test(bp, is_serdes) != 0) {
  1426. buf[5] = 1;
  1427. etest->flags |= ETH_TEST_FL_FAILED;
  1428. }
  1429. #ifdef BNX2X_EXTRA_DEBUG
  1430. bnx2x_panic_dump(bp);
  1431. #endif
  1432. }
  1433. static const struct {
  1434. long offset;
  1435. int size;
  1436. u8 string[ETH_GSTRING_LEN];
  1437. } bnx2x_q_stats_arr[BNX2X_NUM_Q_STATS] = {
  1438. /* 1 */ { Q_STATS_OFFSET32(total_bytes_received_hi), 8, "[%d]: rx_bytes" },
  1439. { Q_STATS_OFFSET32(error_bytes_received_hi),
  1440. 8, "[%d]: rx_error_bytes" },
  1441. { Q_STATS_OFFSET32(total_unicast_packets_received_hi),
  1442. 8, "[%d]: rx_ucast_packets" },
  1443. { Q_STATS_OFFSET32(total_multicast_packets_received_hi),
  1444. 8, "[%d]: rx_mcast_packets" },
  1445. { Q_STATS_OFFSET32(total_broadcast_packets_received_hi),
  1446. 8, "[%d]: rx_bcast_packets" },
  1447. { Q_STATS_OFFSET32(no_buff_discard_hi), 8, "[%d]: rx_discards" },
  1448. { Q_STATS_OFFSET32(rx_err_discard_pkt),
  1449. 4, "[%d]: rx_phy_ip_err_discards"},
  1450. { Q_STATS_OFFSET32(rx_skb_alloc_failed),
  1451. 4, "[%d]: rx_skb_alloc_discard" },
  1452. { Q_STATS_OFFSET32(hw_csum_err), 4, "[%d]: rx_csum_offload_errors" },
  1453. /* 10 */{ Q_STATS_OFFSET32(total_bytes_transmitted_hi), 8, "[%d]: tx_bytes" },
  1454. { Q_STATS_OFFSET32(total_unicast_packets_transmitted_hi),
  1455. 8, "[%d]: tx_ucast_packets" },
  1456. { Q_STATS_OFFSET32(total_multicast_packets_transmitted_hi),
  1457. 8, "[%d]: tx_mcast_packets" },
  1458. { Q_STATS_OFFSET32(total_broadcast_packets_transmitted_hi),
  1459. 8, "[%d]: tx_bcast_packets" }
  1460. };
  1461. static const struct {
  1462. long offset;
  1463. int size;
  1464. u32 flags;
  1465. #define STATS_FLAGS_PORT 1
  1466. #define STATS_FLAGS_FUNC 2
  1467. #define STATS_FLAGS_BOTH (STATS_FLAGS_FUNC | STATS_FLAGS_PORT)
  1468. u8 string[ETH_GSTRING_LEN];
  1469. } bnx2x_stats_arr[BNX2X_NUM_STATS] = {
  1470. /* 1 */ { STATS_OFFSET32(total_bytes_received_hi),
  1471. 8, STATS_FLAGS_BOTH, "rx_bytes" },
  1472. { STATS_OFFSET32(error_bytes_received_hi),
  1473. 8, STATS_FLAGS_BOTH, "rx_error_bytes" },
  1474. { STATS_OFFSET32(total_unicast_packets_received_hi),
  1475. 8, STATS_FLAGS_BOTH, "rx_ucast_packets" },
  1476. { STATS_OFFSET32(total_multicast_packets_received_hi),
  1477. 8, STATS_FLAGS_BOTH, "rx_mcast_packets" },
  1478. { STATS_OFFSET32(total_broadcast_packets_received_hi),
  1479. 8, STATS_FLAGS_BOTH, "rx_bcast_packets" },
  1480. { STATS_OFFSET32(rx_stat_dot3statsfcserrors_hi),
  1481. 8, STATS_FLAGS_PORT, "rx_crc_errors" },
  1482. { STATS_OFFSET32(rx_stat_dot3statsalignmenterrors_hi),
  1483. 8, STATS_FLAGS_PORT, "rx_align_errors" },
  1484. { STATS_OFFSET32(rx_stat_etherstatsundersizepkts_hi),
  1485. 8, STATS_FLAGS_PORT, "rx_undersize_packets" },
  1486. { STATS_OFFSET32(etherstatsoverrsizepkts_hi),
  1487. 8, STATS_FLAGS_PORT, "rx_oversize_packets" },
  1488. /* 10 */{ STATS_OFFSET32(rx_stat_etherstatsfragments_hi),
  1489. 8, STATS_FLAGS_PORT, "rx_fragments" },
  1490. { STATS_OFFSET32(rx_stat_etherstatsjabbers_hi),
  1491. 8, STATS_FLAGS_PORT, "rx_jabbers" },
  1492. { STATS_OFFSET32(no_buff_discard_hi),
  1493. 8, STATS_FLAGS_BOTH, "rx_discards" },
  1494. { STATS_OFFSET32(mac_filter_discard),
  1495. 4, STATS_FLAGS_PORT, "rx_filtered_packets" },
  1496. { STATS_OFFSET32(xxoverflow_discard),
  1497. 4, STATS_FLAGS_PORT, "rx_fw_discards" },
  1498. { STATS_OFFSET32(brb_drop_hi),
  1499. 8, STATS_FLAGS_PORT, "rx_brb_discard" },
  1500. { STATS_OFFSET32(brb_truncate_hi),
  1501. 8, STATS_FLAGS_PORT, "rx_brb_truncate" },
  1502. { STATS_OFFSET32(pause_frames_received_hi),
  1503. 8, STATS_FLAGS_PORT, "rx_pause_frames" },
  1504. { STATS_OFFSET32(rx_stat_maccontrolframesreceived_hi),
  1505. 8, STATS_FLAGS_PORT, "rx_mac_ctrl_frames" },
  1506. { STATS_OFFSET32(nig_timer_max),
  1507. 4, STATS_FLAGS_PORT, "rx_constant_pause_events" },
  1508. /* 20 */{ STATS_OFFSET32(rx_err_discard_pkt),
  1509. 4, STATS_FLAGS_BOTH, "rx_phy_ip_err_discards"},
  1510. { STATS_OFFSET32(rx_skb_alloc_failed),
  1511. 4, STATS_FLAGS_BOTH, "rx_skb_alloc_discard" },
  1512. { STATS_OFFSET32(hw_csum_err),
  1513. 4, STATS_FLAGS_BOTH, "rx_csum_offload_errors" },
  1514. { STATS_OFFSET32(total_bytes_transmitted_hi),
  1515. 8, STATS_FLAGS_BOTH, "tx_bytes" },
  1516. { STATS_OFFSET32(tx_stat_ifhcoutbadoctets_hi),
  1517. 8, STATS_FLAGS_PORT, "tx_error_bytes" },
  1518. { STATS_OFFSET32(total_unicast_packets_transmitted_hi),
  1519. 8, STATS_FLAGS_BOTH, "tx_ucast_packets" },
  1520. { STATS_OFFSET32(total_multicast_packets_transmitted_hi),
  1521. 8, STATS_FLAGS_BOTH, "tx_mcast_packets" },
  1522. { STATS_OFFSET32(total_broadcast_packets_transmitted_hi),
  1523. 8, STATS_FLAGS_BOTH, "tx_bcast_packets" },
  1524. { STATS_OFFSET32(tx_stat_dot3statsinternalmactransmiterrors_hi),
  1525. 8, STATS_FLAGS_PORT, "tx_mac_errors" },
  1526. { STATS_OFFSET32(rx_stat_dot3statscarriersenseerrors_hi),
  1527. 8, STATS_FLAGS_PORT, "tx_carrier_errors" },
  1528. /* 30 */{ STATS_OFFSET32(tx_stat_dot3statssinglecollisionframes_hi),
  1529. 8, STATS_FLAGS_PORT, "tx_single_collisions" },
  1530. { STATS_OFFSET32(tx_stat_dot3statsmultiplecollisionframes_hi),
  1531. 8, STATS_FLAGS_PORT, "tx_multi_collisions" },
  1532. { STATS_OFFSET32(tx_stat_dot3statsdeferredtransmissions_hi),
  1533. 8, STATS_FLAGS_PORT, "tx_deferred" },
  1534. { STATS_OFFSET32(tx_stat_dot3statsexcessivecollisions_hi),
  1535. 8, STATS_FLAGS_PORT, "tx_excess_collisions" },
  1536. { STATS_OFFSET32(tx_stat_dot3statslatecollisions_hi),
  1537. 8, STATS_FLAGS_PORT, "tx_late_collisions" },
  1538. { STATS_OFFSET32(tx_stat_etherstatscollisions_hi),
  1539. 8, STATS_FLAGS_PORT, "tx_total_collisions" },
  1540. { STATS_OFFSET32(tx_stat_etherstatspkts64octets_hi),
  1541. 8, STATS_FLAGS_PORT, "tx_64_byte_packets" },
  1542. { STATS_OFFSET32(tx_stat_etherstatspkts65octetsto127octets_hi),
  1543. 8, STATS_FLAGS_PORT, "tx_65_to_127_byte_packets" },
  1544. { STATS_OFFSET32(tx_stat_etherstatspkts128octetsto255octets_hi),
  1545. 8, STATS_FLAGS_PORT, "tx_128_to_255_byte_packets" },
  1546. { STATS_OFFSET32(tx_stat_etherstatspkts256octetsto511octets_hi),
  1547. 8, STATS_FLAGS_PORT, "tx_256_to_511_byte_packets" },
  1548. /* 40 */{ STATS_OFFSET32(tx_stat_etherstatspkts512octetsto1023octets_hi),
  1549. 8, STATS_FLAGS_PORT, "tx_512_to_1023_byte_packets" },
  1550. { STATS_OFFSET32(etherstatspkts1024octetsto1522octets_hi),
  1551. 8, STATS_FLAGS_PORT, "tx_1024_to_1522_byte_packets" },
  1552. { STATS_OFFSET32(etherstatspktsover1522octets_hi),
  1553. 8, STATS_FLAGS_PORT, "tx_1523_to_9022_byte_packets" },
  1554. { STATS_OFFSET32(pause_frames_sent_hi),
  1555. 8, STATS_FLAGS_PORT, "tx_pause_frames" }
  1556. };
  1557. #define IS_PORT_STAT(i) \
  1558. ((bnx2x_stats_arr[i].flags & STATS_FLAGS_BOTH) == STATS_FLAGS_PORT)
  1559. #define IS_FUNC_STAT(i) (bnx2x_stats_arr[i].flags & STATS_FLAGS_FUNC)
  1560. #define IS_MF_MODE_STAT(bp) \
  1561. (IS_MF(bp) && !(bp->msg_enable & BNX2X_MSG_STATS))
  1562. static int bnx2x_get_sset_count(struct net_device *dev, int stringset)
  1563. {
  1564. struct bnx2x *bp = netdev_priv(dev);
  1565. int i, num_stats;
  1566. switch (stringset) {
  1567. case ETH_SS_STATS:
  1568. if (is_multi(bp)) {
  1569. num_stats = BNX2X_NUM_Q_STATS * bp->num_queues;
  1570. if (!IS_MF_MODE_STAT(bp))
  1571. num_stats += BNX2X_NUM_STATS;
  1572. } else {
  1573. if (IS_MF_MODE_STAT(bp)) {
  1574. num_stats = 0;
  1575. for (i = 0; i < BNX2X_NUM_STATS; i++)
  1576. if (IS_FUNC_STAT(i))
  1577. num_stats++;
  1578. } else
  1579. num_stats = BNX2X_NUM_STATS;
  1580. }
  1581. return num_stats;
  1582. case ETH_SS_TEST:
  1583. return BNX2X_NUM_TESTS;
  1584. default:
  1585. return -EINVAL;
  1586. }
  1587. }
  1588. static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
  1589. {
  1590. struct bnx2x *bp = netdev_priv(dev);
  1591. int i, j, k;
  1592. switch (stringset) {
  1593. case ETH_SS_STATS:
  1594. if (is_multi(bp)) {
  1595. k = 0;
  1596. for_each_queue(bp, i) {
  1597. for (j = 0; j < BNX2X_NUM_Q_STATS; j++)
  1598. sprintf(buf + (k + j)*ETH_GSTRING_LEN,
  1599. bnx2x_q_stats_arr[j].string, i);
  1600. k += BNX2X_NUM_Q_STATS;
  1601. }
  1602. if (IS_MF_MODE_STAT(bp))
  1603. break;
  1604. for (j = 0; j < BNX2X_NUM_STATS; j++)
  1605. strcpy(buf + (k + j)*ETH_GSTRING_LEN,
  1606. bnx2x_stats_arr[j].string);
  1607. } else {
  1608. for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
  1609. if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i))
  1610. continue;
  1611. strcpy(buf + j*ETH_GSTRING_LEN,
  1612. bnx2x_stats_arr[i].string);
  1613. j++;
  1614. }
  1615. }
  1616. break;
  1617. case ETH_SS_TEST:
  1618. memcpy(buf, bnx2x_tests_str_arr, sizeof(bnx2x_tests_str_arr));
  1619. break;
  1620. }
  1621. }
  1622. static void bnx2x_get_ethtool_stats(struct net_device *dev,
  1623. struct ethtool_stats *stats, u64 *buf)
  1624. {
  1625. struct bnx2x *bp = netdev_priv(dev);
  1626. u32 *hw_stats, *offset;
  1627. int i, j, k;
  1628. if (is_multi(bp)) {
  1629. k = 0;
  1630. for_each_queue(bp, i) {
  1631. hw_stats = (u32 *)&bp->fp[i].eth_q_stats;
  1632. for (j = 0; j < BNX2X_NUM_Q_STATS; j++) {
  1633. if (bnx2x_q_stats_arr[j].size == 0) {
  1634. /* skip this counter */
  1635. buf[k + j] = 0;
  1636. continue;
  1637. }
  1638. offset = (hw_stats +
  1639. bnx2x_q_stats_arr[j].offset);
  1640. if (bnx2x_q_stats_arr[j].size == 4) {
  1641. /* 4-byte counter */
  1642. buf[k + j] = (u64) *offset;
  1643. continue;
  1644. }
  1645. /* 8-byte counter */
  1646. buf[k + j] = HILO_U64(*offset, *(offset + 1));
  1647. }
  1648. k += BNX2X_NUM_Q_STATS;
  1649. }
  1650. if (IS_MF_MODE_STAT(bp))
  1651. return;
  1652. hw_stats = (u32 *)&bp->eth_stats;
  1653. for (j = 0; j < BNX2X_NUM_STATS; j++) {
  1654. if (bnx2x_stats_arr[j].size == 0) {
  1655. /* skip this counter */
  1656. buf[k + j] = 0;
  1657. continue;
  1658. }
  1659. offset = (hw_stats + bnx2x_stats_arr[j].offset);
  1660. if (bnx2x_stats_arr[j].size == 4) {
  1661. /* 4-byte counter */
  1662. buf[k + j] = (u64) *offset;
  1663. continue;
  1664. }
  1665. /* 8-byte counter */
  1666. buf[k + j] = HILO_U64(*offset, *(offset + 1));
  1667. }
  1668. } else {
  1669. hw_stats = (u32 *)&bp->eth_stats;
  1670. for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
  1671. if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i))
  1672. continue;
  1673. if (bnx2x_stats_arr[i].size == 0) {
  1674. /* skip this counter */
  1675. buf[j] = 0;
  1676. j++;
  1677. continue;
  1678. }
  1679. offset = (hw_stats + bnx2x_stats_arr[i].offset);
  1680. if (bnx2x_stats_arr[i].size == 4) {
  1681. /* 4-byte counter */
  1682. buf[j] = (u64) *offset;
  1683. j++;
  1684. continue;
  1685. }
  1686. /* 8-byte counter */
  1687. buf[j] = HILO_U64(*offset, *(offset + 1));
  1688. j++;
  1689. }
  1690. }
  1691. }
  1692. static int bnx2x_phys_id(struct net_device *dev, u32 data)
  1693. {
  1694. struct bnx2x *bp = netdev_priv(dev);
  1695. int i;
  1696. if (!netif_running(dev))
  1697. return 0;
  1698. if (!bp->port.pmf)
  1699. return 0;
  1700. if (data == 0)
  1701. data = 2;
  1702. for (i = 0; i < (data * 2); i++) {
  1703. if ((i % 2) == 0)
  1704. bnx2x_set_led(&bp->link_params, &bp->link_vars,
  1705. LED_MODE_OPER, SPEED_1000);
  1706. else
  1707. bnx2x_set_led(&bp->link_params, &bp->link_vars,
  1708. LED_MODE_OFF, 0);
  1709. msleep_interruptible(500);
  1710. if (signal_pending(current))
  1711. break;
  1712. }
  1713. if (bp->link_vars.link_up)
  1714. bnx2x_set_led(&bp->link_params, &bp->link_vars, LED_MODE_OPER,
  1715. bp->link_vars.line_speed);
  1716. return 0;
  1717. }
  1718. static const struct ethtool_ops bnx2x_ethtool_ops = {
  1719. .get_settings = bnx2x_get_settings,
  1720. .set_settings = bnx2x_set_settings,
  1721. .get_drvinfo = bnx2x_get_drvinfo,
  1722. .get_regs_len = bnx2x_get_regs_len,
  1723. .get_regs = bnx2x_get_regs,
  1724. .get_wol = bnx2x_get_wol,
  1725. .set_wol = bnx2x_set_wol,
  1726. .get_msglevel = bnx2x_get_msglevel,
  1727. .set_msglevel = bnx2x_set_msglevel,
  1728. .nway_reset = bnx2x_nway_reset,
  1729. .get_link = bnx2x_get_link,
  1730. .get_eeprom_len = bnx2x_get_eeprom_len,
  1731. .get_eeprom = bnx2x_get_eeprom,
  1732. .set_eeprom = bnx2x_set_eeprom,
  1733. .get_coalesce = bnx2x_get_coalesce,
  1734. .set_coalesce = bnx2x_set_coalesce,
  1735. .get_ringparam = bnx2x_get_ringparam,
  1736. .set_ringparam = bnx2x_set_ringparam,
  1737. .get_pauseparam = bnx2x_get_pauseparam,
  1738. .set_pauseparam = bnx2x_set_pauseparam,
  1739. .get_rx_csum = bnx2x_get_rx_csum,
  1740. .set_rx_csum = bnx2x_set_rx_csum,
  1741. .get_tx_csum = ethtool_op_get_tx_csum,
  1742. .set_tx_csum = ethtool_op_set_tx_hw_csum,
  1743. .set_flags = bnx2x_set_flags,
  1744. .get_flags = ethtool_op_get_flags,
  1745. .get_sg = ethtool_op_get_sg,
  1746. .set_sg = ethtool_op_set_sg,
  1747. .get_tso = ethtool_op_get_tso,
  1748. .set_tso = bnx2x_set_tso,
  1749. .self_test = bnx2x_self_test,
  1750. .get_sset_count = bnx2x_get_sset_count,
  1751. .get_strings = bnx2x_get_strings,
  1752. .phys_id = bnx2x_phys_id,
  1753. .get_ethtool_stats = bnx2x_get_ethtool_stats,
  1754. };
  1755. void bnx2x_set_ethtool_ops(struct net_device *netdev)
  1756. {
  1757. SET_ETHTOOL_OPS(netdev, &bnx2x_ethtool_ops);
  1758. }