ixgbe_82598.c 35 KB

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