ixgbe_82598.c 34 KB

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