ixgbe_82598.c 35 KB

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