ixgbe_82598.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2009 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. #include <linux/pci.h>
  21. #include <linux/delay.h>
  22. #include <linux/sched.h>
  23. #include "ixgbe.h"
  24. #include "ixgbe_phy.h"
  25. #define IXGBE_82598_MAX_TX_QUEUES 32
  26. #define IXGBE_82598_MAX_RX_QUEUES 64
  27. #define IXGBE_82598_RAR_ENTRIES 16
  28. #define IXGBE_82598_MC_TBL_SIZE 128
  29. #define IXGBE_82598_VFT_TBL_SIZE 128
  30. static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
  31. ixgbe_link_speed *speed,
  32. bool *autoneg);
  33. static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw);
  34. static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
  35. ixgbe_link_speed speed,
  36. bool autoneg,
  37. bool autoneg_wait_to_complete);
  38. static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
  39. u8 *eeprom_data);
  40. /**
  41. * ixgbe_get_pcie_msix_count_82598 - Gets MSI-X vector count
  42. * @hw: pointer to hardware structure
  43. *
  44. * Read PCIe configuration space, and get the MSI-X vector count from
  45. * the capabilities table.
  46. **/
  47. u16 ixgbe_get_pcie_msix_count_82598(struct ixgbe_hw *hw)
  48. {
  49. struct ixgbe_adapter *adapter = hw->back;
  50. u16 msix_count;
  51. pci_read_config_word(adapter->pdev, IXGBE_PCIE_MSIX_82598_CAPS,
  52. &msix_count);
  53. msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;
  54. /* MSI-X count is zero-based in HW, so increment to give proper value */
  55. msix_count++;
  56. return msix_count;
  57. }
  58. /**
  59. */
  60. static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
  61. {
  62. struct ixgbe_mac_info *mac = &hw->mac;
  63. struct ixgbe_phy_info *phy = &hw->phy;
  64. s32 ret_val = 0;
  65. u16 list_offset, data_offset;
  66. /* Call PHY identify routine to get the phy type */
  67. ixgbe_identify_phy_generic(hw);
  68. /* PHY Init */
  69. switch (phy->type) {
  70. case ixgbe_phy_tn:
  71. phy->ops.check_link = &ixgbe_check_phy_link_tnx;
  72. phy->ops.get_firmware_version =
  73. &ixgbe_get_phy_firmware_version_tnx;
  74. break;
  75. case ixgbe_phy_nl:
  76. phy->ops.reset = &ixgbe_reset_phy_nl;
  77. /* Call SFP+ identify routine to get the SFP+ module type */
  78. ret_val = phy->ops.identify_sfp(hw);
  79. if (ret_val != 0)
  80. goto out;
  81. else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) {
  82. ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
  83. goto out;
  84. }
  85. /* Check to see if SFP+ module is supported */
  86. ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
  87. &list_offset,
  88. &data_offset);
  89. if (ret_val != 0) {
  90. ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
  91. goto out;
  92. }
  93. break;
  94. default:
  95. break;
  96. }
  97. if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
  98. mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
  99. mac->ops.setup_link_speed =
  100. &ixgbe_setup_copper_link_speed_82598;
  101. mac->ops.get_link_capabilities =
  102. &ixgbe_get_copper_link_capabilities_82598;
  103. }
  104. mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
  105. mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
  106. mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
  107. mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
  108. mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
  109. mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw);
  110. out:
  111. return ret_val;
  112. }
  113. /**
  114. * ixgbe_get_link_capabilities_82598 - Determines link capabilities
  115. * @hw: pointer to hardware structure
  116. * @speed: pointer to link speed
  117. * @autoneg: boolean auto-negotiation value
  118. *
  119. * Determines the link capabilities by reading the AUTOC register.
  120. **/
  121. static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
  122. ixgbe_link_speed *speed,
  123. bool *autoneg)
  124. {
  125. s32 status = 0;
  126. /*
  127. * Determine link capabilities based on the stored value of AUTOC,
  128. * which represents EEPROM defaults.
  129. */
  130. switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) {
  131. case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
  132. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  133. *autoneg = false;
  134. break;
  135. case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
  136. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  137. *autoneg = false;
  138. break;
  139. case IXGBE_AUTOC_LMS_1G_AN:
  140. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  141. *autoneg = true;
  142. break;
  143. case IXGBE_AUTOC_LMS_KX4_AN:
  144. case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
  145. *speed = IXGBE_LINK_SPEED_UNKNOWN;
  146. if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP)
  147. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  148. if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP)
  149. *speed |= IXGBE_LINK_SPEED_1GB_FULL;
  150. *autoneg = true;
  151. break;
  152. default:
  153. status = IXGBE_ERR_LINK_SETUP;
  154. break;
  155. }
  156. return status;
  157. }
  158. /**
  159. * ixgbe_get_copper_link_capabilities_82598 - Determines link capabilities
  160. * @hw: pointer to hardware structure
  161. * @speed: pointer to link speed
  162. * @autoneg: boolean auto-negotiation value
  163. *
  164. * Determines the link capabilities by reading the AUTOC register.
  165. **/
  166. static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
  167. ixgbe_link_speed *speed,
  168. bool *autoneg)
  169. {
  170. s32 status = IXGBE_ERR_LINK_SETUP;
  171. u16 speed_ability;
  172. *speed = 0;
  173. *autoneg = true;
  174. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
  175. IXGBE_MDIO_PMA_PMD_DEV_TYPE,
  176. &speed_ability);
  177. if (status == 0) {
  178. if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
  179. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  180. if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
  181. *speed |= IXGBE_LINK_SPEED_1GB_FULL;
  182. }
  183. return status;
  184. }
  185. /**
  186. * ixgbe_get_media_type_82598 - Determines media type
  187. * @hw: pointer to hardware structure
  188. *
  189. * Returns the media type (fiber, copper, backplane)
  190. **/
  191. static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
  192. {
  193. enum ixgbe_media_type media_type;
  194. /* Media type for I82598 is based on device ID */
  195. switch (hw->device_id) {
  196. case IXGBE_DEV_ID_82598:
  197. case IXGBE_DEV_ID_82598_BX:
  198. media_type = ixgbe_media_type_backplane;
  199. break;
  200. case IXGBE_DEV_ID_82598AF_DUAL_PORT:
  201. case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
  202. case IXGBE_DEV_ID_82598EB_CX4:
  203. case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
  204. case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
  205. case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
  206. case IXGBE_DEV_ID_82598EB_XF_LR:
  207. case IXGBE_DEV_ID_82598EB_SFP_LOM:
  208. media_type = ixgbe_media_type_fiber;
  209. break;
  210. case IXGBE_DEV_ID_82598AT:
  211. media_type = ixgbe_media_type_copper;
  212. break;
  213. default:
  214. media_type = ixgbe_media_type_unknown;
  215. break;
  216. }
  217. return media_type;
  218. }
  219. /**
  220. * ixgbe_fc_enable_82598 - Enable flow control
  221. * @hw: pointer to hardware structure
  222. * @packetbuf_num: packet buffer number (0-7)
  223. *
  224. * Enable flow control according to the current settings.
  225. **/
  226. static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
  227. {
  228. s32 ret_val = 0;
  229. u32 fctrl_reg;
  230. u32 rmcs_reg;
  231. u32 reg;
  232. fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
  233. fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
  234. rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
  235. rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
  236. /*
  237. * The possible values of fc.current_mode are:
  238. * 0: Flow control is completely disabled
  239. * 1: Rx flow control is enabled (we can receive pause frames,
  240. * but not send pause frames).
  241. * 2: Tx flow control is enabled (we can send pause frames but
  242. * we do not support receiving pause frames).
  243. * 3: Both Rx and Tx flow control (symmetric) are enabled.
  244. * other: Invalid.
  245. */
  246. switch (hw->fc.current_mode) {
  247. case ixgbe_fc_none:
  248. /* Flow control completely disabled by software override. */
  249. break;
  250. case ixgbe_fc_rx_pause:
  251. /*
  252. * Rx Flow control is enabled and Tx Flow control is
  253. * disabled by software override. Since there really
  254. * isn't a way to advertise that we are capable of RX
  255. * Pause ONLY, we will advertise that we support both
  256. * symmetric and asymmetric Rx PAUSE. Later, we will
  257. * disable the adapter's ability to send PAUSE frames.
  258. */
  259. fctrl_reg |= IXGBE_FCTRL_RFCE;
  260. break;
  261. case ixgbe_fc_tx_pause:
  262. /*
  263. * Tx Flow control is enabled, and Rx Flow control is
  264. * disabled by software override.
  265. */
  266. rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
  267. break;
  268. case ixgbe_fc_full:
  269. /* Flow control (both Rx and Tx) is enabled by SW override. */
  270. fctrl_reg |= IXGBE_FCTRL_RFCE;
  271. rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
  272. break;
  273. default:
  274. hw_dbg(hw, "Flow control param set incorrectly\n");
  275. ret_val = -IXGBE_ERR_CONFIG;
  276. goto out;
  277. break;
  278. }
  279. /* Enable 802.3x based flow control settings. */
  280. IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
  281. IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
  282. /* Set up and enable Rx high/low water mark thresholds, enable XON. */
  283. if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
  284. if (hw->fc.send_xon) {
  285. IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
  286. (hw->fc.low_water | IXGBE_FCRTL_XONE));
  287. } else {
  288. IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
  289. hw->fc.low_water);
  290. }
  291. IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),
  292. (hw->fc.high_water | IXGBE_FCRTH_FCEN));
  293. }
  294. /* Configure pause time (2 TCs per register) */
  295. reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num));
  296. if ((packetbuf_num & 1) == 0)
  297. reg = (reg & 0xFFFF0000) | hw->fc.pause_time;
  298. else
  299. reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16);
  300. IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg);
  301. IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1));
  302. out:
  303. return ret_val;
  304. }
  305. /**
  306. * ixgbe_setup_fc_82598 - Configure flow control settings
  307. * @hw: pointer to hardware structure
  308. * @packetbuf_num: packet buffer number (0-7)
  309. *
  310. * Configures the flow control settings based on SW configuration. This
  311. * function is used for 802.3x flow control configuration only.
  312. **/
  313. static s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
  314. {
  315. s32 ret_val = 0;
  316. ixgbe_link_speed speed;
  317. bool link_up;
  318. /* Validate the packetbuf configuration */
  319. if (packetbuf_num < 0 || packetbuf_num > 7) {
  320. hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"
  321. " 0-7\n", packetbuf_num);
  322. ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
  323. goto out;
  324. }
  325. /*
  326. * Validate the water mark configuration. Zero water marks are invalid
  327. * because it causes the controller to just blast out fc packets.
  328. */
  329. if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
  330. hw_dbg(hw, "Invalid water mark configuration\n");
  331. ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
  332. goto out;
  333. }
  334. /*
  335. * Validate the requested mode. Strict IEEE mode does not allow
  336. * ixgbe_fc_rx_pause because it will cause testing anomalies.
  337. */
  338. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  339. hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  340. ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
  341. goto out;
  342. }
  343. /*
  344. * 10gig parts do not have a word in the EEPROM to determine the
  345. * default flow control setting, so we explicitly set it to full.
  346. */
  347. if (hw->fc.requested_mode == ixgbe_fc_default)
  348. hw->fc.requested_mode = ixgbe_fc_full;
  349. /*
  350. * Save off the requested flow control mode for use later. Depending
  351. * on the link partner's capabilities, we may or may not use this mode.
  352. */
  353. hw->fc.current_mode = hw->fc.requested_mode;
  354. /* Decide whether to use autoneg or not. */
  355. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  356. if (hw->phy.multispeed_fiber && (speed == IXGBE_LINK_SPEED_1GB_FULL))
  357. ret_val = ixgbe_fc_autoneg(hw);
  358. if (ret_val)
  359. goto out;
  360. ret_val = ixgbe_fc_enable_82598(hw, packetbuf_num);
  361. out:
  362. return ret_val;
  363. }
  364. /**
  365. * ixgbe_setup_mac_link_82598 - Configures MAC link settings
  366. * @hw: pointer to hardware structure
  367. *
  368. * Configures link settings based on values in the ixgbe_hw struct.
  369. * Restarts the link. Performs autonegotiation if needed.
  370. **/
  371. static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
  372. {
  373. u32 autoc_reg;
  374. u32 links_reg;
  375. u32 i;
  376. s32 status = 0;
  377. /* Restart link */
  378. autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  379. autoc_reg |= IXGBE_AUTOC_AN_RESTART;
  380. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
  381. /* Only poll for autoneg to complete if specified to do so */
  382. if (hw->phy.autoneg_wait_to_complete) {
  383. if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
  384. IXGBE_AUTOC_LMS_KX4_AN ||
  385. (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
  386. IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
  387. links_reg = 0; /* Just in case Autoneg time = 0 */
  388. for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
  389. links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
  390. if (links_reg & IXGBE_LINKS_KX_AN_COMP)
  391. break;
  392. msleep(100);
  393. }
  394. if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
  395. status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
  396. hw_dbg(hw, "Autonegotiation did not complete.\n");
  397. }
  398. }
  399. }
  400. /*
  401. * We want to save off the original Flow Control configuration just in
  402. * case we get disconnected and then reconnected into a different hub
  403. * or switch with different Flow Control capabilities.
  404. */
  405. ixgbe_setup_fc_82598(hw, 0);
  406. /* Add delay to filter out noises during initial link setup */
  407. msleep(50);
  408. return status;
  409. }
  410. /**
  411. * ixgbe_check_mac_link_82598 - Get link/speed status
  412. * @hw: pointer to hardware structure
  413. * @speed: pointer to link speed
  414. * @link_up: true is link is up, false otherwise
  415. * @link_up_wait_to_complete: bool used to wait for link up or not
  416. *
  417. * Reads the links register to determine if link is up and the current speed
  418. **/
  419. static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
  420. ixgbe_link_speed *speed, bool *link_up,
  421. bool link_up_wait_to_complete)
  422. {
  423. u32 links_reg;
  424. u32 i;
  425. u16 link_reg, adapt_comp_reg;
  426. /*
  427. * SERDES PHY requires us to read link status from register 0xC79F.
  428. * Bit 0 set indicates link is up/ready; clear indicates link down.
  429. * 0xC00C is read to check that the XAUI lanes are active. Bit 0
  430. * clear indicates active; set indicates inactive.
  431. */
  432. if (hw->phy.type == ixgbe_phy_nl) {
  433. hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
  434. hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
  435. hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV,
  436. &adapt_comp_reg);
  437. if (link_up_wait_to_complete) {
  438. for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
  439. if ((link_reg & 1) &&
  440. ((adapt_comp_reg & 1) == 0)) {
  441. *link_up = true;
  442. break;
  443. } else {
  444. *link_up = false;
  445. }
  446. msleep(100);
  447. hw->phy.ops.read_reg(hw, 0xC79F,
  448. IXGBE_TWINAX_DEV,
  449. &link_reg);
  450. hw->phy.ops.read_reg(hw, 0xC00C,
  451. IXGBE_TWINAX_DEV,
  452. &adapt_comp_reg);
  453. }
  454. } else {
  455. if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0))
  456. *link_up = true;
  457. else
  458. *link_up = false;
  459. }
  460. if (*link_up == false)
  461. goto out;
  462. }
  463. links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
  464. if (link_up_wait_to_complete) {
  465. for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
  466. if (links_reg & IXGBE_LINKS_UP) {
  467. *link_up = true;
  468. break;
  469. } else {
  470. *link_up = false;
  471. }
  472. msleep(100);
  473. links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
  474. }
  475. } else {
  476. if (links_reg & IXGBE_LINKS_UP)
  477. *link_up = true;
  478. else
  479. *link_up = false;
  480. }
  481. if (links_reg & IXGBE_LINKS_SPEED)
  482. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  483. else
  484. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  485. out:
  486. return 0;
  487. }
  488. /**
  489. * ixgbe_setup_mac_link_speed_82598 - Set MAC link speed
  490. * @hw: pointer to hardware structure
  491. * @speed: new link speed
  492. * @autoneg: true if auto-negotiation enabled
  493. * @autoneg_wait_to_complete: true if waiting is needed to complete
  494. *
  495. * Set the link speed in the AUTOC register and restarts link.
  496. **/
  497. static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
  498. ixgbe_link_speed speed, bool autoneg,
  499. bool autoneg_wait_to_complete)
  500. {
  501. s32 status = 0;
  502. ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
  503. u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  504. u32 autoc = curr_autoc;
  505. u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
  506. /* Check to see if speed passed in is supported. */
  507. ixgbe_get_link_capabilities_82598(hw, &link_capabilities, &autoneg);
  508. speed &= link_capabilities;
  509. if (speed == IXGBE_LINK_SPEED_UNKNOWN)
  510. status = IXGBE_ERR_LINK_SETUP;
  511. /* Set KX4/KX support according to speed requested */
  512. else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN ||
  513. link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
  514. autoc &= ~IXGBE_AUTOC_KX4_KX_SUPP_MASK;
  515. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  516. autoc |= IXGBE_AUTOC_KX4_SUPP;
  517. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  518. autoc |= IXGBE_AUTOC_KX_SUPP;
  519. if (autoc != curr_autoc)
  520. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
  521. }
  522. if (status == 0) {
  523. hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete;
  524. /*
  525. * Setup and restart the link based on the new values in
  526. * ixgbe_hw This will write the AUTOC register based on the new
  527. * stored values
  528. */
  529. status = ixgbe_setup_mac_link_82598(hw);
  530. }
  531. return status;
  532. }
  533. /**
  534. * ixgbe_setup_copper_link_82598 - Setup copper link settings
  535. * @hw: pointer to hardware structure
  536. *
  537. * Configures link settings based on values in the ixgbe_hw struct.
  538. * Restarts the link. Performs autonegotiation if needed. Restart
  539. * phy and wait for autonegotiate to finish. Then synchronize the
  540. * MAC and PHY.
  541. **/
  542. static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)
  543. {
  544. s32 status;
  545. /* Restart autonegotiation on PHY */
  546. status = hw->phy.ops.setup_link(hw);
  547. /* Set up MAC */
  548. ixgbe_setup_mac_link_82598(hw);
  549. return status;
  550. }
  551. /**
  552. * ixgbe_setup_copper_link_speed_82598 - Set the PHY autoneg advertised field
  553. * @hw: pointer to hardware structure
  554. * @speed: new link speed
  555. * @autoneg: true if autonegotiation enabled
  556. * @autoneg_wait_to_complete: true if waiting is needed to complete
  557. *
  558. * Sets the link speed in the AUTOC register in the MAC and restarts link.
  559. **/
  560. static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
  561. ixgbe_link_speed speed,
  562. bool autoneg,
  563. bool autoneg_wait_to_complete)
  564. {
  565. s32 status;
  566. /* Setup the PHY according to input speed */
  567. status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
  568. autoneg_wait_to_complete);
  569. /* Set up MAC */
  570. ixgbe_setup_mac_link_82598(hw);
  571. return status;
  572. }
  573. /**
  574. * ixgbe_reset_hw_82598 - Performs hardware reset
  575. * @hw: pointer to hardware structure
  576. *
  577. * Resets the hardware by resetting the transmit and receive units, masks and
  578. * clears all interrupts, performing a PHY reset, and performing a link (MAC)
  579. * reset.
  580. **/
  581. static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
  582. {
  583. s32 status = 0;
  584. u32 ctrl;
  585. u32 gheccr;
  586. u32 i;
  587. u32 autoc;
  588. u8 analog_val;
  589. /* Call adapter stop to disable tx/rx and clear interrupts */
  590. hw->mac.ops.stop_adapter(hw);
  591. /*
  592. * Power up the Atlas Tx lanes if they are currently powered down.
  593. * Atlas Tx lanes are powered down for MAC loopback tests, but
  594. * they are not automatically restored on reset.
  595. */
  596. hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);
  597. if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {
  598. /* Enable Tx Atlas so packets can be transmitted again */
  599. hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
  600. &analog_val);
  601. analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
  602. hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
  603. analog_val);
  604. hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
  605. &analog_val);
  606. analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
  607. hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
  608. analog_val);
  609. hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
  610. &analog_val);
  611. analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
  612. hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
  613. analog_val);
  614. hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
  615. &analog_val);
  616. analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
  617. hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
  618. analog_val);
  619. }
  620. /* Reset PHY */
  621. if (hw->phy.reset_disable == false)
  622. hw->phy.ops.reset(hw);
  623. /*
  624. * Prevent the PCI-E bus from from hanging by disabling PCI-E master
  625. * access and verify no pending requests before reset
  626. */
  627. if (ixgbe_disable_pcie_master(hw) != 0) {
  628. status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
  629. hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
  630. }
  631. /*
  632. * Issue global reset to the MAC. This needs to be a SW reset.
  633. * If link reset is used, it might reset the MAC when mng is using it
  634. */
  635. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  636. IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
  637. IXGBE_WRITE_FLUSH(hw);
  638. /* Poll for reset bit to self-clear indicating reset is complete */
  639. for (i = 0; i < 10; i++) {
  640. udelay(1);
  641. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  642. if (!(ctrl & IXGBE_CTRL_RST))
  643. break;
  644. }
  645. if (ctrl & IXGBE_CTRL_RST) {
  646. status = IXGBE_ERR_RESET_FAILED;
  647. hw_dbg(hw, "Reset polling failed to complete.\n");
  648. }
  649. msleep(50);
  650. gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
  651. gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
  652. IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
  653. /*
  654. * Store the original AUTOC value if it has not been
  655. * stored off yet. Otherwise restore the stored original
  656. * AUTOC value since the reset operation sets back to deaults.
  657. */
  658. autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  659. if (hw->mac.orig_link_settings_stored == false) {
  660. hw->mac.orig_autoc = autoc;
  661. hw->mac.orig_link_settings_stored = true;
  662. } else if (autoc != hw->mac.orig_autoc) {
  663. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
  664. }
  665. /* Store the permanent mac address */
  666. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  667. return status;
  668. }
  669. /**
  670. * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address
  671. * @hw: pointer to hardware struct
  672. * @rar: receive address register index to associate with a VMDq index
  673. * @vmdq: VMDq set index
  674. **/
  675. static s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
  676. {
  677. u32 rar_high;
  678. rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
  679. rar_high &= ~IXGBE_RAH_VIND_MASK;
  680. rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
  681. IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
  682. return 0;
  683. }
  684. /**
  685. * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address
  686. * @hw: pointer to hardware struct
  687. * @rar: receive address register index to associate with a VMDq index
  688. * @vmdq: VMDq clear index (not used in 82598, but elsewhere)
  689. **/
  690. static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
  691. {
  692. u32 rar_high;
  693. u32 rar_entries = hw->mac.num_rar_entries;
  694. if (rar < rar_entries) {
  695. rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
  696. if (rar_high & IXGBE_RAH_VIND_MASK) {
  697. rar_high &= ~IXGBE_RAH_VIND_MASK;
  698. IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
  699. }
  700. } else {
  701. hw_dbg(hw, "RAR index %d is out of range.\n", rar);
  702. }
  703. return 0;
  704. }
  705. /**
  706. * ixgbe_set_vfta_82598 - Set VLAN filter table
  707. * @hw: pointer to hardware structure
  708. * @vlan: VLAN id to write to VLAN filter
  709. * @vind: VMDq output index that maps queue to VLAN id in VFTA
  710. * @vlan_on: boolean flag to turn on/off VLAN in VFTA
  711. *
  712. * Turn on/off specified VLAN in the VLAN filter table.
  713. **/
  714. static s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
  715. bool vlan_on)
  716. {
  717. u32 regindex;
  718. u32 bitindex;
  719. u32 bits;
  720. u32 vftabyte;
  721. if (vlan > 4095)
  722. return IXGBE_ERR_PARAM;
  723. /* Determine 32-bit word position in array */
  724. regindex = (vlan >> 5) & 0x7F; /* upper seven bits */
  725. /* Determine the location of the (VMD) queue index */
  726. vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
  727. bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */
  728. /* Set the nibble for VMD queue index */
  729. bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));
  730. bits &= (~(0x0F << bitindex));
  731. bits |= (vind << bitindex);
  732. IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);
  733. /* Determine the location of the bit for this VLAN id */
  734. bitindex = vlan & 0x1F; /* lower five bits */
  735. bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
  736. if (vlan_on)
  737. /* Turn on this VLAN id */
  738. bits |= (1 << bitindex);
  739. else
  740. /* Turn off this VLAN id */
  741. bits &= ~(1 << bitindex);
  742. IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
  743. return 0;
  744. }
  745. /**
  746. * ixgbe_clear_vfta_82598 - Clear VLAN filter table
  747. * @hw: pointer to hardware structure
  748. *
  749. * Clears the VLAN filer table, and the VMDq index associated with the filter
  750. **/
  751. static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)
  752. {
  753. u32 offset;
  754. u32 vlanbyte;
  755. for (offset = 0; offset < hw->mac.vft_size; offset++)
  756. IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
  757. for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
  758. for (offset = 0; offset < hw->mac.vft_size; offset++)
  759. IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),
  760. 0);
  761. return 0;
  762. }
  763. /**
  764. * ixgbe_blink_led_start_82598 - Blink LED based on index.
  765. * @hw: pointer to hardware structure
  766. * @index: led number to blink
  767. **/
  768. static s32 ixgbe_blink_led_start_82598(struct ixgbe_hw *hw, u32 index)
  769. {
  770. ixgbe_link_speed speed = 0;
  771. bool link_up = 0;
  772. u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  773. u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
  774. /*
  775. * Link must be up to auto-blink the LEDs on the 82598EB MAC;
  776. * force it if link is down.
  777. */
  778. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  779. if (!link_up) {
  780. autoc_reg |= IXGBE_AUTOC_FLU;
  781. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
  782. msleep(10);
  783. }
  784. led_reg &= ~IXGBE_LED_MODE_MASK(index);
  785. led_reg |= IXGBE_LED_BLINK(index);
  786. IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
  787. IXGBE_WRITE_FLUSH(hw);
  788. return 0;
  789. }
  790. /**
  791. * ixgbe_blink_led_stop_82598 - Stop blinking LED based on index.
  792. * @hw: pointer to hardware structure
  793. * @index: led number to stop blinking
  794. **/
  795. static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index)
  796. {
  797. u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  798. u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
  799. autoc_reg &= ~IXGBE_AUTOC_FLU;
  800. autoc_reg |= IXGBE_AUTOC_AN_RESTART;
  801. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
  802. led_reg &= ~IXGBE_LED_MODE_MASK(index);
  803. led_reg &= ~IXGBE_LED_BLINK(index);
  804. led_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);
  805. IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
  806. IXGBE_WRITE_FLUSH(hw);
  807. return 0;
  808. }
  809. /**
  810. * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register
  811. * @hw: pointer to hardware structure
  812. * @reg: analog register to read
  813. * @val: read value
  814. *
  815. * Performs read operation to Atlas analog register specified.
  816. **/
  817. static s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
  818. {
  819. u32 atlas_ctl;
  820. IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
  821. IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
  822. IXGBE_WRITE_FLUSH(hw);
  823. udelay(10);
  824. atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
  825. *val = (u8)atlas_ctl;
  826. return 0;
  827. }
  828. /**
  829. * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register
  830. * @hw: pointer to hardware structure
  831. * @reg: atlas register to write
  832. * @val: value to write
  833. *
  834. * Performs write operation to Atlas analog register specified.
  835. **/
  836. static s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
  837. {
  838. u32 atlas_ctl;
  839. atlas_ctl = (reg << 8) | val;
  840. IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
  841. IXGBE_WRITE_FLUSH(hw);
  842. udelay(10);
  843. return 0;
  844. }
  845. /**
  846. * ixgbe_read_i2c_eeprom_82598 - Read 8 bit EEPROM word of an SFP+ module
  847. * over I2C interface through an intermediate phy.
  848. * @hw: pointer to hardware structure
  849. * @byte_offset: EEPROM byte offset to read
  850. * @eeprom_data: value read
  851. *
  852. * Performs byte read operation to SFP module's EEPROM over I2C interface.
  853. **/
  854. static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
  855. u8 *eeprom_data)
  856. {
  857. s32 status = 0;
  858. u16 sfp_addr = 0;
  859. u16 sfp_data = 0;
  860. u16 sfp_stat = 0;
  861. u32 i;
  862. if (hw->phy.type == ixgbe_phy_nl) {
  863. /*
  864. * phy SDA/SCL registers are at addresses 0xC30A to
  865. * 0xC30D. These registers are used to talk to the SFP+
  866. * module's EEPROM through the SDA/SCL (I2C) interface.
  867. */
  868. sfp_addr = (IXGBE_I2C_EEPROM_DEV_ADDR << 8) + byte_offset;
  869. sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
  870. hw->phy.ops.write_reg(hw,
  871. IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
  872. IXGBE_MDIO_PMA_PMD_DEV_TYPE,
  873. sfp_addr);
  874. /* Poll status */
  875. for (i = 0; i < 100; i++) {
  876. hw->phy.ops.read_reg(hw,
  877. IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
  878. IXGBE_MDIO_PMA_PMD_DEV_TYPE,
  879. &sfp_stat);
  880. sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
  881. if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
  882. break;
  883. msleep(10);
  884. }
  885. if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_PASS) {
  886. hw_dbg(hw, "EEPROM read did not pass.\n");
  887. status = IXGBE_ERR_SFP_NOT_PRESENT;
  888. goto out;
  889. }
  890. /* Read data */
  891. hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
  892. IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data);
  893. *eeprom_data = (u8)(sfp_data >> 8);
  894. } else {
  895. status = IXGBE_ERR_PHY;
  896. goto out;
  897. }
  898. out:
  899. return status;
  900. }
  901. /**
  902. * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
  903. * @hw: pointer to hardware structure
  904. *
  905. * Determines physical layer capabilities of the current configuration.
  906. **/
  907. static s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
  908. {
  909. s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
  910. switch (hw->device_id) {
  911. case IXGBE_DEV_ID_82598:
  912. /* Default device ID is mezzanine card KX/KX4 */
  913. physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
  914. IXGBE_PHYSICAL_LAYER_1000BASE_KX);
  915. break;
  916. case IXGBE_DEV_ID_82598_BX:
  917. physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
  918. case IXGBE_DEV_ID_82598EB_CX4:
  919. case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
  920. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
  921. break;
  922. case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
  923. physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
  924. break;
  925. case IXGBE_DEV_ID_82598AF_DUAL_PORT:
  926. case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
  927. case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
  928. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
  929. break;
  930. case IXGBE_DEV_ID_82598EB_XF_LR:
  931. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
  932. break;
  933. case IXGBE_DEV_ID_82598AT:
  934. physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T |
  935. IXGBE_PHYSICAL_LAYER_1000BASE_T);
  936. break;
  937. case IXGBE_DEV_ID_82598EB_SFP_LOM:
  938. hw->phy.ops.identify_sfp(hw);
  939. switch (hw->phy.sfp_type) {
  940. case ixgbe_sfp_type_da_cu:
  941. physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
  942. break;
  943. case ixgbe_sfp_type_sr:
  944. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
  945. break;
  946. case ixgbe_sfp_type_lr:
  947. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
  948. break;
  949. default:
  950. physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
  951. break;
  952. }
  953. break;
  954. default:
  955. physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
  956. break;
  957. }
  958. return physical_layer;
  959. }
  960. static struct ixgbe_mac_operations mac_ops_82598 = {
  961. .init_hw = &ixgbe_init_hw_generic,
  962. .reset_hw = &ixgbe_reset_hw_82598,
  963. .start_hw = &ixgbe_start_hw_generic,
  964. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
  965. .get_media_type = &ixgbe_get_media_type_82598,
  966. .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,
  967. .get_mac_addr = &ixgbe_get_mac_addr_generic,
  968. .stop_adapter = &ixgbe_stop_adapter_generic,
  969. .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,
  970. .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,
  971. .setup_link = &ixgbe_setup_mac_link_82598,
  972. .setup_link_speed = &ixgbe_setup_mac_link_speed_82598,
  973. .check_link = &ixgbe_check_mac_link_82598,
  974. .get_link_capabilities = &ixgbe_get_link_capabilities_82598,
  975. .led_on = &ixgbe_led_on_generic,
  976. .led_off = &ixgbe_led_off_generic,
  977. .blink_led_start = &ixgbe_blink_led_start_82598,
  978. .blink_led_stop = &ixgbe_blink_led_stop_82598,
  979. .set_rar = &ixgbe_set_rar_generic,
  980. .clear_rar = &ixgbe_clear_rar_generic,
  981. .set_vmdq = &ixgbe_set_vmdq_82598,
  982. .clear_vmdq = &ixgbe_clear_vmdq_82598,
  983. .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
  984. .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
  985. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
  986. .enable_mc = &ixgbe_enable_mc_generic,
  987. .disable_mc = &ixgbe_disable_mc_generic,
  988. .clear_vfta = &ixgbe_clear_vfta_82598,
  989. .set_vfta = &ixgbe_set_vfta_82598,
  990. .setup_fc = &ixgbe_setup_fc_82598,
  991. };
  992. static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
  993. .init_params = &ixgbe_init_eeprom_params_generic,
  994. .read = &ixgbe_read_eeprom_generic,
  995. .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
  996. .update_checksum = &ixgbe_update_eeprom_checksum_generic,
  997. };
  998. static struct ixgbe_phy_operations phy_ops_82598 = {
  999. .identify = &ixgbe_identify_phy_generic,
  1000. .identify_sfp = &ixgbe_identify_sfp_module_generic,
  1001. .reset = &ixgbe_reset_phy_generic,
  1002. .read_reg = &ixgbe_read_phy_reg_generic,
  1003. .write_reg = &ixgbe_write_phy_reg_generic,
  1004. .setup_link = &ixgbe_setup_phy_link_generic,
  1005. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
  1006. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598,
  1007. };
  1008. struct ixgbe_info ixgbe_82598_info = {
  1009. .mac = ixgbe_mac_82598EB,
  1010. .get_invariants = &ixgbe_get_invariants_82598,
  1011. .mac_ops = &mac_ops_82598,
  1012. .eeprom_ops = &eeprom_ops_82598,
  1013. .phy_ops = &phy_ops_82598,
  1014. };