ixgbe_82598.c 35 KB

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