falcon_xmac.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. /****************************************************************************
  2. * Driver for Solarflare Solarstorm network controllers and boards
  3. * Copyright 2005-2006 Fen Systems Ltd.
  4. * Copyright 2006-2008 Solarflare Communications Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation, incorporated herein by reference.
  9. */
  10. #include <linux/delay.h>
  11. #include "net_driver.h"
  12. #include "efx.h"
  13. #include "falcon.h"
  14. #include "falcon_hwdefs.h"
  15. #include "falcon_io.h"
  16. #include "mac.h"
  17. #include "gmii.h"
  18. #include "mdio_10g.h"
  19. #include "phy.h"
  20. #include "boards.h"
  21. #include "workarounds.h"
  22. /**************************************************************************
  23. *
  24. * MAC operations
  25. *
  26. *************************************************************************/
  27. static int falcon_reset_xmac(struct efx_nic *efx)
  28. {
  29. efx_oword_t reg;
  30. int count;
  31. EFX_POPULATE_OWORD_1(reg, XM_CORE_RST, 1);
  32. falcon_write(efx, &reg, XM_GLB_CFG_REG);
  33. for (count = 0; count < 10000; count++) { /* wait upto 100ms */
  34. falcon_read(efx, &reg, XM_GLB_CFG_REG);
  35. if (EFX_OWORD_FIELD(reg, XM_CORE_RST) == 0)
  36. return 0;
  37. udelay(10);
  38. }
  39. EFX_ERR(efx, "timed out waiting for XMAC core reset\n");
  40. return -ETIMEDOUT;
  41. }
  42. /* Configure the XAUI driver that is an output from Falcon */
  43. static void falcon_setup_xaui(struct efx_nic *efx)
  44. {
  45. efx_oword_t sdctl, txdrv;
  46. /* Move the XAUI into low power, unless there is no PHY, in
  47. * which case the XAUI will have to drive a cable. */
  48. if (efx->phy_type == PHY_TYPE_NONE)
  49. return;
  50. falcon_read(efx, &sdctl, XX_SD_CTL_REG);
  51. EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVD, XX_SD_CTL_DRV_DEFAULT);
  52. EFX_SET_OWORD_FIELD(sdctl, XX_LODRVD, XX_SD_CTL_DRV_DEFAULT);
  53. EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVC, XX_SD_CTL_DRV_DEFAULT);
  54. EFX_SET_OWORD_FIELD(sdctl, XX_LODRVC, XX_SD_CTL_DRV_DEFAULT);
  55. EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVB, XX_SD_CTL_DRV_DEFAULT);
  56. EFX_SET_OWORD_FIELD(sdctl, XX_LODRVB, XX_SD_CTL_DRV_DEFAULT);
  57. EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVA, XX_SD_CTL_DRV_DEFAULT);
  58. EFX_SET_OWORD_FIELD(sdctl, XX_LODRVA, XX_SD_CTL_DRV_DEFAULT);
  59. falcon_write(efx, &sdctl, XX_SD_CTL_REG);
  60. EFX_POPULATE_OWORD_8(txdrv,
  61. XX_DEQD, XX_TXDRV_DEQ_DEFAULT,
  62. XX_DEQC, XX_TXDRV_DEQ_DEFAULT,
  63. XX_DEQB, XX_TXDRV_DEQ_DEFAULT,
  64. XX_DEQA, XX_TXDRV_DEQ_DEFAULT,
  65. XX_DTXD, XX_TXDRV_DTX_DEFAULT,
  66. XX_DTXC, XX_TXDRV_DTX_DEFAULT,
  67. XX_DTXB, XX_TXDRV_DTX_DEFAULT,
  68. XX_DTXA, XX_TXDRV_DTX_DEFAULT);
  69. falcon_write(efx, &txdrv, XX_TXDRV_CTL_REG);
  70. }
  71. int falcon_reset_xaui(struct efx_nic *efx)
  72. {
  73. efx_oword_t reg;
  74. int count;
  75. EFX_POPULATE_DWORD_1(reg, XX_RST_XX_EN, 1);
  76. falcon_write(efx, &reg, XX_PWR_RST_REG);
  77. /* Give some time for the link to establish */
  78. for (count = 0; count < 1000; count++) { /* wait upto 10ms */
  79. falcon_read(efx, &reg, XX_PWR_RST_REG);
  80. if (EFX_OWORD_FIELD(reg, XX_RST_XX_EN) == 0) {
  81. falcon_setup_xaui(efx);
  82. return 0;
  83. }
  84. udelay(10);
  85. }
  86. EFX_ERR(efx, "timed out waiting for XAUI/XGXS reset\n");
  87. return -ETIMEDOUT;
  88. }
  89. static bool falcon_xgmii_status(struct efx_nic *efx)
  90. {
  91. efx_oword_t reg;
  92. if (falcon_rev(efx) < FALCON_REV_B0)
  93. return true;
  94. /* The ISR latches, so clear it and re-read */
  95. falcon_read(efx, &reg, XM_MGT_INT_REG_B0);
  96. falcon_read(efx, &reg, XM_MGT_INT_REG_B0);
  97. if (EFX_OWORD_FIELD(reg, XM_LCLFLT) ||
  98. EFX_OWORD_FIELD(reg, XM_RMTFLT)) {
  99. EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg));
  100. return false;
  101. }
  102. return true;
  103. }
  104. static void falcon_mask_status_intr(struct efx_nic *efx, bool enable)
  105. {
  106. efx_oword_t reg;
  107. if ((falcon_rev(efx) < FALCON_REV_B0) || LOOPBACK_INTERNAL(efx))
  108. return;
  109. /* Flush the ISR */
  110. if (enable)
  111. falcon_read(efx, &reg, XM_MGT_INT_REG_B0);
  112. EFX_POPULATE_OWORD_2(reg,
  113. XM_MSK_RMTFLT, !enable,
  114. XM_MSK_LCLFLT, !enable);
  115. falcon_write(efx, &reg, XM_MGT_INT_MSK_REG_B0);
  116. }
  117. int falcon_init_xmac(struct efx_nic *efx)
  118. {
  119. int rc;
  120. /* Initialize the PHY first so the clock is around */
  121. rc = efx->phy_op->init(efx);
  122. if (rc)
  123. goto fail1;
  124. rc = falcon_reset_xaui(efx);
  125. if (rc)
  126. goto fail2;
  127. /* Wait again. Give the PHY and MAC time to come back */
  128. schedule_timeout_uninterruptible(HZ / 10);
  129. rc = falcon_reset_xmac(efx);
  130. if (rc)
  131. goto fail2;
  132. falcon_mask_status_intr(efx, true);
  133. return 0;
  134. fail2:
  135. efx->phy_op->fini(efx);
  136. fail1:
  137. return rc;
  138. }
  139. bool falcon_xaui_link_ok(struct efx_nic *efx)
  140. {
  141. efx_oword_t reg;
  142. bool align_done, link_ok = false;
  143. int sync_status;
  144. if (LOOPBACK_INTERNAL(efx))
  145. return true;
  146. /* Read link status */
  147. falcon_read(efx, &reg, XX_CORE_STAT_REG);
  148. align_done = EFX_OWORD_FIELD(reg, XX_ALIGN_DONE);
  149. sync_status = EFX_OWORD_FIELD(reg, XX_SYNC_STAT);
  150. if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED))
  151. link_ok = true;
  152. /* Clear link status ready for next read */
  153. EFX_SET_OWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET);
  154. EFX_SET_OWORD_FIELD(reg, XX_CHARERR, XX_CHARERR_RESET);
  155. EFX_SET_OWORD_FIELD(reg, XX_DISPERR, XX_DISPERR_RESET);
  156. falcon_write(efx, &reg, XX_CORE_STAT_REG);
  157. /* If the link is up, then check the phy side of the xaui link
  158. * (error conditions from the wire side propoagate back through
  159. * the phy to the xaui side). */
  160. if (efx->link_up && link_ok) {
  161. if (efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS))
  162. link_ok = mdio_clause45_phyxgxs_lane_sync(efx);
  163. }
  164. /* If the PHY and XAUI links are up, then check the mac's xgmii
  165. * fault state */
  166. if (efx->link_up && link_ok)
  167. link_ok = falcon_xgmii_status(efx);
  168. return link_ok;
  169. }
  170. static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
  171. {
  172. unsigned int max_frame_len;
  173. efx_oword_t reg;
  174. bool rx_fc = !!(efx->flow_control & EFX_FC_RX);
  175. /* Configure MAC - cut-thru mode is hard wired on */
  176. EFX_POPULATE_DWORD_3(reg,
  177. XM_RX_JUMBO_MODE, 1,
  178. XM_TX_STAT_EN, 1,
  179. XM_RX_STAT_EN, 1);
  180. falcon_write(efx, &reg, XM_GLB_CFG_REG);
  181. /* Configure TX */
  182. EFX_POPULATE_DWORD_6(reg,
  183. XM_TXEN, 1,
  184. XM_TX_PRMBL, 1,
  185. XM_AUTO_PAD, 1,
  186. XM_TXCRC, 1,
  187. XM_FCNTL, 1,
  188. XM_IPG, 0x3);
  189. falcon_write(efx, &reg, XM_TX_CFG_REG);
  190. /* Configure RX */
  191. EFX_POPULATE_DWORD_5(reg,
  192. XM_RXEN, 1,
  193. XM_AUTO_DEPAD, 0,
  194. XM_ACPT_ALL_MCAST, 1,
  195. XM_ACPT_ALL_UCAST, efx->promiscuous,
  196. XM_PASS_CRC_ERR, 1);
  197. falcon_write(efx, &reg, XM_RX_CFG_REG);
  198. /* Set frame length */
  199. max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu);
  200. EFX_POPULATE_DWORD_1(reg, XM_MAX_RX_FRM_SIZE, max_frame_len);
  201. falcon_write(efx, &reg, XM_RX_PARAM_REG);
  202. EFX_POPULATE_DWORD_2(reg,
  203. XM_MAX_TX_FRM_SIZE, max_frame_len,
  204. XM_TX_JUMBO_MODE, 1);
  205. falcon_write(efx, &reg, XM_TX_PARAM_REG);
  206. EFX_POPULATE_DWORD_2(reg,
  207. XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */
  208. XM_DIS_FCNTL, !rx_fc);
  209. falcon_write(efx, &reg, XM_FC_REG);
  210. /* Set MAC address */
  211. EFX_POPULATE_DWORD_4(reg,
  212. XM_ADR_0, efx->net_dev->dev_addr[0],
  213. XM_ADR_1, efx->net_dev->dev_addr[1],
  214. XM_ADR_2, efx->net_dev->dev_addr[2],
  215. XM_ADR_3, efx->net_dev->dev_addr[3]);
  216. falcon_write(efx, &reg, XM_ADR_LO_REG);
  217. EFX_POPULATE_DWORD_2(reg,
  218. XM_ADR_4, efx->net_dev->dev_addr[4],
  219. XM_ADR_5, efx->net_dev->dev_addr[5]);
  220. falcon_write(efx, &reg, XM_ADR_HI_REG);
  221. }
  222. static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
  223. {
  224. efx_oword_t reg;
  225. bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS);
  226. bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI);
  227. bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII);
  228. /* XGXS block is flaky and will need to be reset if moving
  229. * into our out of XGMII, XGXS or XAUI loopbacks. */
  230. if (EFX_WORKAROUND_5147(efx)) {
  231. bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback;
  232. bool reset_xgxs;
  233. falcon_read(efx, &reg, XX_CORE_STAT_REG);
  234. old_xgxs_loopback = EFX_OWORD_FIELD(reg, XX_XGXS_LB_EN);
  235. old_xgmii_loopback = EFX_OWORD_FIELD(reg, XX_XGMII_LB_EN);
  236. falcon_read(efx, &reg, XX_SD_CTL_REG);
  237. old_xaui_loopback = EFX_OWORD_FIELD(reg, XX_LPBKA);
  238. /* The PHY driver may have turned XAUI off */
  239. reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) ||
  240. (xaui_loopback != old_xaui_loopback) ||
  241. (xgmii_loopback != old_xgmii_loopback));
  242. if (reset_xgxs)
  243. falcon_reset_xaui(efx);
  244. }
  245. falcon_read(efx, &reg, XX_CORE_STAT_REG);
  246. EFX_SET_OWORD_FIELD(reg, XX_FORCE_SIG,
  247. (xgxs_loopback || xaui_loopback) ?
  248. XX_FORCE_SIG_DECODE_FORCED : 0);
  249. EFX_SET_OWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback);
  250. EFX_SET_OWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback);
  251. falcon_write(efx, &reg, XX_CORE_STAT_REG);
  252. falcon_read(efx, &reg, XX_SD_CTL_REG);
  253. EFX_SET_OWORD_FIELD(reg, XX_LPBKD, xaui_loopback);
  254. EFX_SET_OWORD_FIELD(reg, XX_LPBKC, xaui_loopback);
  255. EFX_SET_OWORD_FIELD(reg, XX_LPBKB, xaui_loopback);
  256. EFX_SET_OWORD_FIELD(reg, XX_LPBKA, xaui_loopback);
  257. falcon_write(efx, &reg, XX_SD_CTL_REG);
  258. }
  259. /* Try and bring the Falcon side of the Falcon-Phy XAUI link fails
  260. * to come back up. Bash it until it comes back up */
  261. static bool falcon_check_xaui_link_up(struct efx_nic *efx)
  262. {
  263. int max_tries, tries;
  264. tries = EFX_WORKAROUND_5147(efx) ? 5 : 1;
  265. max_tries = tries;
  266. if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
  267. (efx->phy_type == PHY_TYPE_NONE) ||
  268. efx_phy_mode_disabled(efx->phy_mode))
  269. return false;
  270. while (tries) {
  271. if (falcon_xaui_link_ok(efx))
  272. return true;
  273. EFX_LOG(efx, "%s Clobbering XAUI (%d tries left).\n",
  274. __func__, tries);
  275. falcon_reset_xaui(efx);
  276. udelay(200);
  277. tries--;
  278. }
  279. EFX_LOG(efx, "Failed to bring XAUI link back up in %d tries!\n",
  280. max_tries);
  281. return false;
  282. }
  283. void falcon_reconfigure_xmac(struct efx_nic *efx)
  284. {
  285. bool xaui_link_ok;
  286. falcon_mask_status_intr(efx, false);
  287. falcon_deconfigure_mac_wrapper(efx);
  288. /* Reconfigure the PHY, disabling transmit in mac level loopback. */
  289. if (LOOPBACK_INTERNAL(efx))
  290. efx->phy_mode |= PHY_MODE_TX_DISABLED;
  291. else
  292. efx->phy_mode &= ~PHY_MODE_TX_DISABLED;
  293. efx->phy_op->reconfigure(efx);
  294. falcon_reconfigure_xgxs_core(efx);
  295. falcon_reconfigure_xmac_core(efx);
  296. falcon_reconfigure_mac_wrapper(efx);
  297. /* Ensure XAUI link is up */
  298. xaui_link_ok = falcon_check_xaui_link_up(efx);
  299. if (xaui_link_ok && efx->link_up)
  300. falcon_mask_status_intr(efx, true);
  301. }
  302. void falcon_fini_xmac(struct efx_nic *efx)
  303. {
  304. /* Isolate the MAC - PHY */
  305. falcon_deconfigure_mac_wrapper(efx);
  306. /* Potentially power down the PHY */
  307. efx->phy_op->fini(efx);
  308. }
  309. void falcon_update_stats_xmac(struct efx_nic *efx)
  310. {
  311. struct efx_mac_stats *mac_stats = &efx->mac_stats;
  312. int rc;
  313. rc = falcon_dma_stats(efx, XgDmaDone_offset);
  314. if (rc)
  315. return;
  316. /* Update MAC stats from DMAed values */
  317. FALCON_STAT(efx, XgRxOctets, rx_bytes);
  318. FALCON_STAT(efx, XgRxOctetsOK, rx_good_bytes);
  319. FALCON_STAT(efx, XgRxPkts, rx_packets);
  320. FALCON_STAT(efx, XgRxPktsOK, rx_good);
  321. FALCON_STAT(efx, XgRxBroadcastPkts, rx_broadcast);
  322. FALCON_STAT(efx, XgRxMulticastPkts, rx_multicast);
  323. FALCON_STAT(efx, XgRxUnicastPkts, rx_unicast);
  324. FALCON_STAT(efx, XgRxUndersizePkts, rx_lt64);
  325. FALCON_STAT(efx, XgRxOversizePkts, rx_gtjumbo);
  326. FALCON_STAT(efx, XgRxJabberPkts, rx_bad_gtjumbo);
  327. FALCON_STAT(efx, XgRxUndersizeFCSerrorPkts, rx_bad_lt64);
  328. FALCON_STAT(efx, XgRxDropEvents, rx_overflow);
  329. FALCON_STAT(efx, XgRxFCSerrorPkts, rx_bad);
  330. FALCON_STAT(efx, XgRxAlignError, rx_align_error);
  331. FALCON_STAT(efx, XgRxSymbolError, rx_symbol_error);
  332. FALCON_STAT(efx, XgRxInternalMACError, rx_internal_error);
  333. FALCON_STAT(efx, XgRxControlPkts, rx_control);
  334. FALCON_STAT(efx, XgRxPausePkts, rx_pause);
  335. FALCON_STAT(efx, XgRxPkts64Octets, rx_64);
  336. FALCON_STAT(efx, XgRxPkts65to127Octets, rx_65_to_127);
  337. FALCON_STAT(efx, XgRxPkts128to255Octets, rx_128_to_255);
  338. FALCON_STAT(efx, XgRxPkts256to511Octets, rx_256_to_511);
  339. FALCON_STAT(efx, XgRxPkts512to1023Octets, rx_512_to_1023);
  340. FALCON_STAT(efx, XgRxPkts1024to15xxOctets, rx_1024_to_15xx);
  341. FALCON_STAT(efx, XgRxPkts15xxtoMaxOctets, rx_15xx_to_jumbo);
  342. FALCON_STAT(efx, XgRxLengthError, rx_length_error);
  343. FALCON_STAT(efx, XgTxPkts, tx_packets);
  344. FALCON_STAT(efx, XgTxOctets, tx_bytes);
  345. FALCON_STAT(efx, XgTxMulticastPkts, tx_multicast);
  346. FALCON_STAT(efx, XgTxBroadcastPkts, tx_broadcast);
  347. FALCON_STAT(efx, XgTxUnicastPkts, tx_unicast);
  348. FALCON_STAT(efx, XgTxControlPkts, tx_control);
  349. FALCON_STAT(efx, XgTxPausePkts, tx_pause);
  350. FALCON_STAT(efx, XgTxPkts64Octets, tx_64);
  351. FALCON_STAT(efx, XgTxPkts65to127Octets, tx_65_to_127);
  352. FALCON_STAT(efx, XgTxPkts128to255Octets, tx_128_to_255);
  353. FALCON_STAT(efx, XgTxPkts256to511Octets, tx_256_to_511);
  354. FALCON_STAT(efx, XgTxPkts512to1023Octets, tx_512_to_1023);
  355. FALCON_STAT(efx, XgTxPkts1024to15xxOctets, tx_1024_to_15xx);
  356. FALCON_STAT(efx, XgTxPkts1519toMaxOctets, tx_15xx_to_jumbo);
  357. FALCON_STAT(efx, XgTxUndersizePkts, tx_lt64);
  358. FALCON_STAT(efx, XgTxOversizePkts, tx_gtjumbo);
  359. FALCON_STAT(efx, XgTxNonTcpUdpPkt, tx_non_tcpudp);
  360. FALCON_STAT(efx, XgTxMacSrcErrPkt, tx_mac_src_error);
  361. FALCON_STAT(efx, XgTxIpSrcErrPkt, tx_ip_src_error);
  362. /* Update derived statistics */
  363. mac_stats->tx_good_bytes =
  364. (mac_stats->tx_bytes - mac_stats->tx_bad_bytes -
  365. mac_stats->tx_control * 64);
  366. mac_stats->rx_bad_bytes =
  367. (mac_stats->rx_bytes - mac_stats->rx_good_bytes -
  368. mac_stats->rx_control * 64);
  369. }
  370. int falcon_check_xmac(struct efx_nic *efx)
  371. {
  372. bool xaui_link_ok;
  373. int rc;
  374. if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
  375. efx_phy_mode_disabled(efx->phy_mode))
  376. return 0;
  377. falcon_mask_status_intr(efx, false);
  378. xaui_link_ok = falcon_xaui_link_ok(efx);
  379. if (EFX_WORKAROUND_5147(efx) && !xaui_link_ok)
  380. falcon_reset_xaui(efx);
  381. /* Call the PHY check_hw routine */
  382. rc = efx->phy_op->check_hw(efx);
  383. /* Unmask interrupt if everything was (and still is) ok */
  384. if (xaui_link_ok && efx->link_up)
  385. falcon_mask_status_intr(efx, true);
  386. return rc;
  387. }
  388. /* Simulate a PHY event */
  389. void falcon_xmac_sim_phy_event(struct efx_nic *efx)
  390. {
  391. efx_qword_t phy_event;
  392. EFX_POPULATE_QWORD_2(phy_event,
  393. EV_CODE, GLOBAL_EV_DECODE,
  394. XG_PHY_INTR, 1);
  395. falcon_generate_event(&efx->channel[0], &phy_event);
  396. }
  397. int falcon_xmac_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
  398. {
  399. mdio_clause45_get_settings(efx, ecmd);
  400. ecmd->transceiver = XCVR_INTERNAL;
  401. ecmd->phy_address = efx->mii.phy_id;
  402. ecmd->autoneg = AUTONEG_DISABLE;
  403. ecmd->duplex = DUPLEX_FULL;
  404. return 0;
  405. }
  406. int falcon_xmac_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
  407. {
  408. if (ecmd->transceiver != XCVR_INTERNAL)
  409. return -EINVAL;
  410. if (ecmd->autoneg != AUTONEG_DISABLE)
  411. return -EINVAL;
  412. if (ecmd->duplex != DUPLEX_FULL)
  413. return -EINVAL;
  414. return mdio_clause45_set_settings(efx, ecmd);
  415. }
  416. int falcon_xmac_set_pause(struct efx_nic *efx, enum efx_fc_type flow_control)
  417. {
  418. bool reset;
  419. if (flow_control & EFX_FC_AUTO) {
  420. EFX_LOG(efx, "10G does not support flow control "
  421. "autonegotiation\n");
  422. return -EINVAL;
  423. }
  424. if ((flow_control & EFX_FC_TX) && !(flow_control & EFX_FC_RX))
  425. return -EINVAL;
  426. /* TX flow control may automatically turn itself off if the
  427. * link partner (intermittently) stops responding to pause
  428. * frames. There isn't any indication that this has happened,
  429. * so the best we do is leave it up to the user to spot this
  430. * and fix it be cycling transmit flow control on this end. */
  431. reset = ((flow_control & EFX_FC_TX) &&
  432. !(efx->flow_control & EFX_FC_TX));
  433. if (EFX_WORKAROUND_11482(efx) && reset) {
  434. if (falcon_rev(efx) >= FALCON_REV_B0) {
  435. /* Recover by resetting the EM block */
  436. if (efx->link_up)
  437. falcon_drain_tx_fifo(efx);
  438. } else {
  439. /* Schedule a reset to recover */
  440. efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
  441. }
  442. }
  443. efx->flow_control = flow_control;
  444. return 0;
  445. }