ixgbe_82599.c 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2014 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. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. #include <linux/pci.h>
  22. #include <linux/delay.h>
  23. #include <linux/sched.h>
  24. #include "ixgbe.h"
  25. #include "ixgbe_phy.h"
  26. #include "ixgbe_mbx.h"
  27. #define IXGBE_82599_MAX_TX_QUEUES 128
  28. #define IXGBE_82599_MAX_RX_QUEUES 128
  29. #define IXGBE_82599_RAR_ENTRIES 128
  30. #define IXGBE_82599_MC_TBL_SIZE 128
  31. #define IXGBE_82599_VFT_TBL_SIZE 128
  32. #define IXGBE_82599_RX_PB_SIZE 512
  33. static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
  34. static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
  35. static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
  36. static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
  37. ixgbe_link_speed speed,
  38. bool autoneg_wait_to_complete);
  39. static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
  40. ixgbe_link_speed speed,
  41. bool autoneg_wait_to_complete);
  42. static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw);
  43. static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
  44. bool autoneg_wait_to_complete);
  45. static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
  46. ixgbe_link_speed speed,
  47. bool autoneg_wait_to_complete);
  48. static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
  49. ixgbe_link_speed speed,
  50. bool autoneg_wait_to_complete);
  51. static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
  52. static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
  53. u8 dev_addr, u8 *data);
  54. static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
  55. u8 dev_addr, u8 data);
  56. static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
  57. static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
  58. bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
  59. {
  60. u32 fwsm, manc, factps;
  61. fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
  62. if ((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT)
  63. return false;
  64. manc = IXGBE_READ_REG(hw, IXGBE_MANC);
  65. if (!(manc & IXGBE_MANC_RCV_TCO_EN))
  66. return false;
  67. factps = IXGBE_READ_REG(hw, IXGBE_FACTPS);
  68. if (factps & IXGBE_FACTPS_MNGCG)
  69. return false;
  70. return true;
  71. }
  72. static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
  73. {
  74. struct ixgbe_mac_info *mac = &hw->mac;
  75. /* enable the laser control functions for SFP+ fiber
  76. * and MNG not enabled
  77. */
  78. if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) &&
  79. !ixgbe_mng_enabled(hw)) {
  80. mac->ops.disable_tx_laser =
  81. &ixgbe_disable_tx_laser_multispeed_fiber;
  82. mac->ops.enable_tx_laser =
  83. &ixgbe_enable_tx_laser_multispeed_fiber;
  84. mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
  85. } else {
  86. mac->ops.disable_tx_laser = NULL;
  87. mac->ops.enable_tx_laser = NULL;
  88. mac->ops.flap_tx_laser = NULL;
  89. }
  90. if (hw->phy.multispeed_fiber) {
  91. /* Set up dual speed SFP+ support */
  92. mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
  93. } else {
  94. if ((mac->ops.get_media_type(hw) ==
  95. ixgbe_media_type_backplane) &&
  96. (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
  97. hw->phy.smart_speed == ixgbe_smart_speed_on) &&
  98. !ixgbe_verify_lesm_fw_enabled_82599(hw))
  99. mac->ops.setup_link = &ixgbe_setup_mac_link_smartspeed;
  100. else
  101. mac->ops.setup_link = &ixgbe_setup_mac_link_82599;
  102. }
  103. }
  104. static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
  105. {
  106. s32 ret_val = 0;
  107. u16 list_offset, data_offset, data_value;
  108. if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
  109. ixgbe_init_mac_link_ops_82599(hw);
  110. hw->phy.ops.reset = NULL;
  111. ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
  112. &data_offset);
  113. if (ret_val != 0)
  114. goto setup_sfp_out;
  115. /* PHY config will finish before releasing the semaphore */
  116. ret_val = hw->mac.ops.acquire_swfw_sync(hw,
  117. IXGBE_GSSR_MAC_CSR_SM);
  118. if (ret_val != 0) {
  119. ret_val = IXGBE_ERR_SWFW_SYNC;
  120. goto setup_sfp_out;
  121. }
  122. if (hw->eeprom.ops.read(hw, ++data_offset, &data_value))
  123. goto setup_sfp_err;
  124. while (data_value != 0xffff) {
  125. IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
  126. IXGBE_WRITE_FLUSH(hw);
  127. if (hw->eeprom.ops.read(hw, ++data_offset, &data_value))
  128. goto setup_sfp_err;
  129. }
  130. /* Release the semaphore */
  131. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
  132. /*
  133. * Delay obtaining semaphore again to allow FW access,
  134. * semaphore_delay is in ms usleep_range needs us.
  135. */
  136. usleep_range(hw->eeprom.semaphore_delay * 1000,
  137. hw->eeprom.semaphore_delay * 2000);
  138. /* Restart DSP and set SFI mode */
  139. ret_val = hw->mac.ops.prot_autoc_write(hw,
  140. hw->mac.orig_autoc | IXGBE_AUTOC_LMS_10G_SERIAL,
  141. false);
  142. if (ret_val) {
  143. hw_dbg(hw, " sfp module setup not complete\n");
  144. ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
  145. goto setup_sfp_out;
  146. }
  147. }
  148. setup_sfp_out:
  149. return ret_val;
  150. setup_sfp_err:
  151. /* Release the semaphore */
  152. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
  153. /* Delay obtaining semaphore again to allow FW access,
  154. * semaphore_delay is in ms usleep_range needs us.
  155. */
  156. usleep_range(hw->eeprom.semaphore_delay * 1000,
  157. hw->eeprom.semaphore_delay * 2000);
  158. hw_err(hw, "eeprom read at offset %d failed\n", data_offset);
  159. return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
  160. }
  161. /**
  162. * prot_autoc_read_82599 - Hides MAC differences needed for AUTOC read
  163. * @hw: pointer to hardware structure
  164. * @locked: Return the if we locked for this read.
  165. * @reg_val: Value we read from AUTOC
  166. *
  167. * For this part (82599) we need to wrap read-modify-writes with a possible
  168. * FW/SW lock. It is assumed this lock will be freed with the next
  169. * prot_autoc_write_82599(). Note, that locked can only be true in cases
  170. * where this function doesn't return an error.
  171. **/
  172. static s32 prot_autoc_read_82599(struct ixgbe_hw *hw, bool *locked,
  173. u32 *reg_val)
  174. {
  175. s32 ret_val;
  176. *locked = false;
  177. /* If LESM is on then we need to hold the SW/FW semaphore. */
  178. if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
  179. ret_val = hw->mac.ops.acquire_swfw_sync(hw,
  180. IXGBE_GSSR_MAC_CSR_SM);
  181. if (ret_val)
  182. return IXGBE_ERR_SWFW_SYNC;
  183. *locked = true;
  184. }
  185. *reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  186. return 0;
  187. }
  188. /**
  189. * prot_autoc_write_82599 - Hides MAC differences needed for AUTOC write
  190. * @hw: pointer to hardware structure
  191. * @reg_val: value to write to AUTOC
  192. * @locked: bool to indicate whether the SW/FW lock was already taken by
  193. * previous proc_autoc_read_82599.
  194. *
  195. * This part (82599) may need to hold a the SW/FW lock around all writes to
  196. * AUTOC. Likewise after a write we need to do a pipeline reset.
  197. **/
  198. static s32 prot_autoc_write_82599(struct ixgbe_hw *hw, u32 autoc, bool locked)
  199. {
  200. s32 ret_val = 0;
  201. /* Blocked by MNG FW so bail */
  202. if (ixgbe_check_reset_blocked(hw))
  203. goto out;
  204. /* We only need to get the lock if:
  205. * - We didn't do it already (in the read part of a read-modify-write)
  206. * - LESM is enabled.
  207. */
  208. if (!locked && ixgbe_verify_lesm_fw_enabled_82599(hw)) {
  209. ret_val = hw->mac.ops.acquire_swfw_sync(hw,
  210. IXGBE_GSSR_MAC_CSR_SM);
  211. if (ret_val)
  212. return IXGBE_ERR_SWFW_SYNC;
  213. locked = true;
  214. }
  215. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
  216. ret_val = ixgbe_reset_pipeline_82599(hw);
  217. out:
  218. /* Free the SW/FW semaphore as we either grabbed it here or
  219. * already had it when this function was called.
  220. */
  221. if (locked)
  222. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
  223. return ret_val;
  224. }
  225. static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
  226. {
  227. struct ixgbe_mac_info *mac = &hw->mac;
  228. ixgbe_init_mac_link_ops_82599(hw);
  229. mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
  230. mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
  231. mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
  232. mac->rx_pb_size = IXGBE_82599_RX_PB_SIZE;
  233. mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
  234. mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
  235. mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
  236. return 0;
  237. }
  238. /**
  239. * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
  240. * @hw: pointer to hardware structure
  241. *
  242. * Initialize any function pointers that were not able to be
  243. * set during get_invariants because the PHY/SFP type was
  244. * not known. Perform the SFP init if necessary.
  245. *
  246. **/
  247. static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
  248. {
  249. struct ixgbe_mac_info *mac = &hw->mac;
  250. struct ixgbe_phy_info *phy = &hw->phy;
  251. s32 ret_val = 0;
  252. u32 esdp;
  253. if (hw->device_id == IXGBE_DEV_ID_82599_QSFP_SF_QP) {
  254. /* Store flag indicating I2C bus access control unit. */
  255. hw->phy.qsfp_shared_i2c_bus = true;
  256. /* Initialize access to QSFP+ I2C bus */
  257. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  258. esdp |= IXGBE_ESDP_SDP0_DIR;
  259. esdp &= ~IXGBE_ESDP_SDP1_DIR;
  260. esdp &= ~IXGBE_ESDP_SDP0;
  261. esdp &= ~IXGBE_ESDP_SDP0_NATIVE;
  262. esdp &= ~IXGBE_ESDP_SDP1_NATIVE;
  263. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  264. IXGBE_WRITE_FLUSH(hw);
  265. phy->ops.read_i2c_byte = &ixgbe_read_i2c_byte_82599;
  266. phy->ops.write_i2c_byte = &ixgbe_write_i2c_byte_82599;
  267. }
  268. /* Identify the PHY or SFP module */
  269. ret_val = phy->ops.identify(hw);
  270. /* Setup function pointers based on detected SFP module and speeds */
  271. ixgbe_init_mac_link_ops_82599(hw);
  272. /* If copper media, overwrite with copper function pointers */
  273. if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
  274. mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
  275. mac->ops.get_link_capabilities =
  276. &ixgbe_get_copper_link_capabilities_generic;
  277. }
  278. /* Set necessary function pointers based on phy type */
  279. switch (hw->phy.type) {
  280. case ixgbe_phy_tn:
  281. phy->ops.check_link = &ixgbe_check_phy_link_tnx;
  282. phy->ops.setup_link = &ixgbe_setup_phy_link_tnx;
  283. phy->ops.get_firmware_version =
  284. &ixgbe_get_phy_firmware_version_tnx;
  285. break;
  286. default:
  287. break;
  288. }
  289. return ret_val;
  290. }
  291. /**
  292. * ixgbe_get_link_capabilities_82599 - Determines link capabilities
  293. * @hw: pointer to hardware structure
  294. * @speed: pointer to link speed
  295. * @autoneg: true when autoneg or autotry is enabled
  296. *
  297. * Determines the link capabilities by reading the AUTOC register.
  298. **/
  299. static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
  300. ixgbe_link_speed *speed,
  301. bool *autoneg)
  302. {
  303. s32 status = 0;
  304. u32 autoc = 0;
  305. /* Determine 1G link capabilities off of SFP+ type */
  306. if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
  307. hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
  308. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
  309. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
  310. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  311. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
  312. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  313. *autoneg = true;
  314. goto out;
  315. }
  316. /*
  317. * Determine link capabilities based on the stored value of AUTOC,
  318. * which represents EEPROM defaults. If AUTOC value has not been
  319. * stored, use the current register value.
  320. */
  321. if (hw->mac.orig_link_settings_stored)
  322. autoc = hw->mac.orig_autoc;
  323. else
  324. autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  325. switch (autoc & IXGBE_AUTOC_LMS_MASK) {
  326. case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
  327. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  328. *autoneg = false;
  329. break;
  330. case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
  331. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  332. *autoneg = false;
  333. break;
  334. case IXGBE_AUTOC_LMS_1G_AN:
  335. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  336. *autoneg = true;
  337. break;
  338. case IXGBE_AUTOC_LMS_10G_SERIAL:
  339. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  340. *autoneg = false;
  341. break;
  342. case IXGBE_AUTOC_LMS_KX4_KX_KR:
  343. case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
  344. *speed = IXGBE_LINK_SPEED_UNKNOWN;
  345. if (autoc & IXGBE_AUTOC_KR_SUPP)
  346. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  347. if (autoc & IXGBE_AUTOC_KX4_SUPP)
  348. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  349. if (autoc & IXGBE_AUTOC_KX_SUPP)
  350. *speed |= IXGBE_LINK_SPEED_1GB_FULL;
  351. *autoneg = true;
  352. break;
  353. case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
  354. *speed = IXGBE_LINK_SPEED_100_FULL;
  355. if (autoc & IXGBE_AUTOC_KR_SUPP)
  356. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  357. if (autoc & IXGBE_AUTOC_KX4_SUPP)
  358. *speed |= IXGBE_LINK_SPEED_10GB_FULL;
  359. if (autoc & IXGBE_AUTOC_KX_SUPP)
  360. *speed |= IXGBE_LINK_SPEED_1GB_FULL;
  361. *autoneg = true;
  362. break;
  363. case IXGBE_AUTOC_LMS_SGMII_1G_100M:
  364. *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
  365. *autoneg = false;
  366. break;
  367. default:
  368. status = IXGBE_ERR_LINK_SETUP;
  369. goto out;
  370. break;
  371. }
  372. if (hw->phy.multispeed_fiber) {
  373. *speed |= IXGBE_LINK_SPEED_10GB_FULL |
  374. IXGBE_LINK_SPEED_1GB_FULL;
  375. /* QSFP must not enable auto-negotiation */
  376. if (hw->phy.media_type == ixgbe_media_type_fiber_qsfp)
  377. *autoneg = false;
  378. else
  379. *autoneg = true;
  380. }
  381. out:
  382. return status;
  383. }
  384. /**
  385. * ixgbe_get_media_type_82599 - Get media type
  386. * @hw: pointer to hardware structure
  387. *
  388. * Returns the media type (fiber, copper, backplane)
  389. **/
  390. static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
  391. {
  392. enum ixgbe_media_type media_type;
  393. /* Detect if there is a copper PHY attached. */
  394. switch (hw->phy.type) {
  395. case ixgbe_phy_cu_unknown:
  396. case ixgbe_phy_tn:
  397. media_type = ixgbe_media_type_copper;
  398. goto out;
  399. default:
  400. break;
  401. }
  402. switch (hw->device_id) {
  403. case IXGBE_DEV_ID_82599_KX4:
  404. case IXGBE_DEV_ID_82599_KX4_MEZZ:
  405. case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
  406. case IXGBE_DEV_ID_82599_KR:
  407. case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
  408. case IXGBE_DEV_ID_82599_XAUI_LOM:
  409. /* Default device ID is mezzanine card KX/KX4 */
  410. media_type = ixgbe_media_type_backplane;
  411. break;
  412. case IXGBE_DEV_ID_82599_SFP:
  413. case IXGBE_DEV_ID_82599_SFP_FCOE:
  414. case IXGBE_DEV_ID_82599_SFP_EM:
  415. case IXGBE_DEV_ID_82599_SFP_SF2:
  416. case IXGBE_DEV_ID_82599_SFP_SF_QP:
  417. case IXGBE_DEV_ID_82599EN_SFP:
  418. media_type = ixgbe_media_type_fiber;
  419. break;
  420. case IXGBE_DEV_ID_82599_CX4:
  421. media_type = ixgbe_media_type_cx4;
  422. break;
  423. case IXGBE_DEV_ID_82599_T3_LOM:
  424. media_type = ixgbe_media_type_copper;
  425. break;
  426. case IXGBE_DEV_ID_82599_LS:
  427. media_type = ixgbe_media_type_fiber_lco;
  428. break;
  429. case IXGBE_DEV_ID_82599_QSFP_SF_QP:
  430. media_type = ixgbe_media_type_fiber_qsfp;
  431. break;
  432. default:
  433. media_type = ixgbe_media_type_unknown;
  434. break;
  435. }
  436. out:
  437. return media_type;
  438. }
  439. /**
  440. * ixgbe_stop_mac_link_on_d3_82599 - Disables link on D3
  441. * @hw: pointer to hardware structure
  442. *
  443. * Disables link, should be called during D3 power down sequence.
  444. *
  445. **/
  446. static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)
  447. {
  448. u32 autoc2_reg, fwsm;
  449. u16 ee_ctrl_2 = 0;
  450. hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2);
  451. /* Check to see if MNG FW could be enabled */
  452. fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
  453. if (((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT) &&
  454. !hw->wol_enabled &&
  455. ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {
  456. autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
  457. autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;
  458. IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
  459. }
  460. }
  461. /**
  462. * ixgbe_start_mac_link_82599 - Setup MAC link settings
  463. * @hw: pointer to hardware structure
  464. * @autoneg_wait_to_complete: true when waiting for completion is needed
  465. *
  466. * Configures link settings based on values in the ixgbe_hw struct.
  467. * Restarts the link. Performs autonegotiation if needed.
  468. **/
  469. static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
  470. bool autoneg_wait_to_complete)
  471. {
  472. u32 autoc_reg;
  473. u32 links_reg;
  474. u32 i;
  475. s32 status = 0;
  476. bool got_lock = false;
  477. if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
  478. status = hw->mac.ops.acquire_swfw_sync(hw,
  479. IXGBE_GSSR_MAC_CSR_SM);
  480. if (status)
  481. goto out;
  482. got_lock = true;
  483. }
  484. /* Restart link */
  485. ixgbe_reset_pipeline_82599(hw);
  486. if (got_lock)
  487. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
  488. /* Only poll for autoneg to complete if specified to do so */
  489. if (autoneg_wait_to_complete) {
  490. autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  491. if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
  492. IXGBE_AUTOC_LMS_KX4_KX_KR ||
  493. (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
  494. IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
  495. (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
  496. IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
  497. links_reg = 0; /* Just in case Autoneg time = 0 */
  498. for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
  499. links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
  500. if (links_reg & IXGBE_LINKS_KX_AN_COMP)
  501. break;
  502. msleep(100);
  503. }
  504. if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
  505. status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
  506. hw_dbg(hw, "Autoneg did not complete.\n");
  507. }
  508. }
  509. }
  510. /* Add delay to filter out noises during initial link setup */
  511. msleep(50);
  512. out:
  513. return status;
  514. }
  515. /**
  516. * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
  517. * @hw: pointer to hardware structure
  518. *
  519. * The base drivers may require better control over SFP+ module
  520. * PHY states. This includes selectively shutting down the Tx
  521. * laser on the PHY, effectively halting physical link.
  522. **/
  523. static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
  524. {
  525. u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
  526. /* Blocked by MNG FW so bail */
  527. if (ixgbe_check_reset_blocked(hw))
  528. return;
  529. /* Disable tx laser; allow 100us to go dark per spec */
  530. esdp_reg |= IXGBE_ESDP_SDP3;
  531. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
  532. IXGBE_WRITE_FLUSH(hw);
  533. udelay(100);
  534. }
  535. /**
  536. * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
  537. * @hw: pointer to hardware structure
  538. *
  539. * The base drivers may require better control over SFP+ module
  540. * PHY states. This includes selectively turning on the Tx
  541. * laser on the PHY, effectively starting physical link.
  542. **/
  543. static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
  544. {
  545. u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
  546. /* Enable tx laser; allow 100ms to light up */
  547. esdp_reg &= ~IXGBE_ESDP_SDP3;
  548. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
  549. IXGBE_WRITE_FLUSH(hw);
  550. msleep(100);
  551. }
  552. /**
  553. * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
  554. * @hw: pointer to hardware structure
  555. *
  556. * When the driver changes the link speeds that it can support,
  557. * it sets autotry_restart to true to indicate that we need to
  558. * initiate a new autotry session with the link partner. To do
  559. * so, we set the speed then disable and re-enable the tx laser, to
  560. * alert the link partner that it also needs to restart autotry on its
  561. * end. This is consistent with true clause 37 autoneg, which also
  562. * involves a loss of signal.
  563. **/
  564. static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
  565. {
  566. /* Blocked by MNG FW so bail */
  567. if (ixgbe_check_reset_blocked(hw))
  568. return;
  569. if (hw->mac.autotry_restart) {
  570. ixgbe_disable_tx_laser_multispeed_fiber(hw);
  571. ixgbe_enable_tx_laser_multispeed_fiber(hw);
  572. hw->mac.autotry_restart = false;
  573. }
  574. }
  575. /**
  576. * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
  577. * @hw: pointer to hardware structure
  578. * @speed: new link speed
  579. * @autoneg_wait_to_complete: true when waiting for completion is needed
  580. *
  581. * Set the link speed in the AUTOC register and restarts link.
  582. **/
  583. static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
  584. ixgbe_link_speed speed,
  585. bool autoneg_wait_to_complete)
  586. {
  587. s32 status = 0;
  588. ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
  589. ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
  590. u32 speedcnt = 0;
  591. u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
  592. u32 i = 0;
  593. bool link_up = false;
  594. bool autoneg = false;
  595. /* Mask off requested but non-supported speeds */
  596. status = hw->mac.ops.get_link_capabilities(hw, &link_speed,
  597. &autoneg);
  598. if (status != 0)
  599. return status;
  600. speed &= link_speed;
  601. /*
  602. * Try each speed one by one, highest priority first. We do this in
  603. * software because 10gb fiber doesn't support speed autonegotiation.
  604. */
  605. if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
  606. speedcnt++;
  607. highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
  608. /* If we already have link at this speed, just jump out */
  609. status = hw->mac.ops.check_link(hw, &link_speed, &link_up,
  610. false);
  611. if (status != 0)
  612. return status;
  613. if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
  614. goto out;
  615. /* Set the module link speed */
  616. switch (hw->phy.media_type) {
  617. case ixgbe_media_type_fiber:
  618. esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
  619. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
  620. IXGBE_WRITE_FLUSH(hw);
  621. break;
  622. case ixgbe_media_type_fiber_qsfp:
  623. /* QSFP module automatically detects MAC link speed */
  624. break;
  625. default:
  626. hw_dbg(hw, "Unexpected media type.\n");
  627. break;
  628. }
  629. /* Allow module to change analog characteristics (1G->10G) */
  630. msleep(40);
  631. status = ixgbe_setup_mac_link_82599(hw,
  632. IXGBE_LINK_SPEED_10GB_FULL,
  633. autoneg_wait_to_complete);
  634. if (status != 0)
  635. return status;
  636. /* Flap the tx laser if it has not already been done */
  637. if (hw->mac.ops.flap_tx_laser)
  638. hw->mac.ops.flap_tx_laser(hw);
  639. /*
  640. * Wait for the controller to acquire link. Per IEEE 802.3ap,
  641. * Section 73.10.2, we may have to wait up to 500ms if KR is
  642. * attempted. 82599 uses the same timing for 10g SFI.
  643. */
  644. for (i = 0; i < 5; i++) {
  645. /* Wait for the link partner to also set speed */
  646. msleep(100);
  647. /* If we have link, just jump out */
  648. status = hw->mac.ops.check_link(hw, &link_speed,
  649. &link_up, false);
  650. if (status != 0)
  651. return status;
  652. if (link_up)
  653. goto out;
  654. }
  655. }
  656. if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
  657. speedcnt++;
  658. if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
  659. highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
  660. /* If we already have link at this speed, just jump out */
  661. status = hw->mac.ops.check_link(hw, &link_speed, &link_up,
  662. false);
  663. if (status != 0)
  664. return status;
  665. if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
  666. goto out;
  667. /* Set the module link speed */
  668. switch (hw->phy.media_type) {
  669. case ixgbe_media_type_fiber:
  670. esdp_reg &= ~IXGBE_ESDP_SDP5;
  671. esdp_reg |= IXGBE_ESDP_SDP5_DIR;
  672. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
  673. IXGBE_WRITE_FLUSH(hw);
  674. break;
  675. case ixgbe_media_type_fiber_qsfp:
  676. /* QSFP module automatically detects MAC link speed */
  677. break;
  678. default:
  679. hw_dbg(hw, "Unexpected media type.\n");
  680. break;
  681. }
  682. /* Allow module to change analog characteristics (10G->1G) */
  683. msleep(40);
  684. status = ixgbe_setup_mac_link_82599(hw,
  685. IXGBE_LINK_SPEED_1GB_FULL,
  686. autoneg_wait_to_complete);
  687. if (status != 0)
  688. return status;
  689. /* Flap the tx laser if it has not already been done */
  690. if (hw->mac.ops.flap_tx_laser)
  691. hw->mac.ops.flap_tx_laser(hw);
  692. /* Wait for the link partner to also set speed */
  693. msleep(100);
  694. /* If we have link, just jump out */
  695. status = hw->mac.ops.check_link(hw, &link_speed, &link_up,
  696. false);
  697. if (status != 0)
  698. return status;
  699. if (link_up)
  700. goto out;
  701. }
  702. /*
  703. * We didn't get link. Configure back to the highest speed we tried,
  704. * (if there was more than one). We call ourselves back with just the
  705. * single highest speed that the user requested.
  706. */
  707. if (speedcnt > 1)
  708. status = ixgbe_setup_mac_link_multispeed_fiber(hw,
  709. highest_link_speed,
  710. autoneg_wait_to_complete);
  711. out:
  712. /* Set autoneg_advertised value based on input link speed */
  713. hw->phy.autoneg_advertised = 0;
  714. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  715. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
  716. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  717. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
  718. return status;
  719. }
  720. /**
  721. * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
  722. * @hw: pointer to hardware structure
  723. * @speed: new link speed
  724. * @autoneg_wait_to_complete: true when waiting for completion is needed
  725. *
  726. * Implements the Intel SmartSpeed algorithm.
  727. **/
  728. static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
  729. ixgbe_link_speed speed,
  730. bool autoneg_wait_to_complete)
  731. {
  732. s32 status = 0;
  733. ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
  734. s32 i, j;
  735. bool link_up = false;
  736. u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  737. /* Set autoneg_advertised value based on input link speed */
  738. hw->phy.autoneg_advertised = 0;
  739. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  740. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
  741. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  742. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
  743. if (speed & IXGBE_LINK_SPEED_100_FULL)
  744. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
  745. /*
  746. * Implement Intel SmartSpeed algorithm. SmartSpeed will reduce the
  747. * autoneg advertisement if link is unable to be established at the
  748. * highest negotiated rate. This can sometimes happen due to integrity
  749. * issues with the physical media connection.
  750. */
  751. /* First, try to get link with full advertisement */
  752. hw->phy.smart_speed_active = false;
  753. for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
  754. status = ixgbe_setup_mac_link_82599(hw, speed,
  755. autoneg_wait_to_complete);
  756. if (status != 0)
  757. goto out;
  758. /*
  759. * Wait for the controller to acquire link. Per IEEE 802.3ap,
  760. * Section 73.10.2, we may have to wait up to 500ms if KR is
  761. * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
  762. * Table 9 in the AN MAS.
  763. */
  764. for (i = 0; i < 5; i++) {
  765. mdelay(100);
  766. /* If we have link, just jump out */
  767. status = hw->mac.ops.check_link(hw, &link_speed,
  768. &link_up, false);
  769. if (status != 0)
  770. goto out;
  771. if (link_up)
  772. goto out;
  773. }
  774. }
  775. /*
  776. * We didn't get link. If we advertised KR plus one of KX4/KX
  777. * (or BX4/BX), then disable KR and try again.
  778. */
  779. if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
  780. ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
  781. goto out;
  782. /* Turn SmartSpeed on to disable KR support */
  783. hw->phy.smart_speed_active = true;
  784. status = ixgbe_setup_mac_link_82599(hw, speed,
  785. autoneg_wait_to_complete);
  786. if (status != 0)
  787. goto out;
  788. /*
  789. * Wait for the controller to acquire link. 600ms will allow for
  790. * the AN link_fail_inhibit_timer as well for multiple cycles of
  791. * parallel detect, both 10g and 1g. This allows for the maximum
  792. * connect attempts as defined in the AN MAS table 73-7.
  793. */
  794. for (i = 0; i < 6; i++) {
  795. mdelay(100);
  796. /* If we have link, just jump out */
  797. status = hw->mac.ops.check_link(hw, &link_speed,
  798. &link_up, false);
  799. if (status != 0)
  800. goto out;
  801. if (link_up)
  802. goto out;
  803. }
  804. /* We didn't get link. Turn SmartSpeed back off. */
  805. hw->phy.smart_speed_active = false;
  806. status = ixgbe_setup_mac_link_82599(hw, speed,
  807. autoneg_wait_to_complete);
  808. out:
  809. if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
  810. hw_dbg(hw, "Smartspeed has downgraded the link speed from the maximum advertised\n");
  811. return status;
  812. }
  813. /**
  814. * ixgbe_setup_mac_link_82599 - Set MAC link speed
  815. * @hw: pointer to hardware structure
  816. * @speed: new link speed
  817. * @autoneg_wait_to_complete: true when waiting for completion is needed
  818. *
  819. * Set the link speed in the AUTOC register and restarts link.
  820. **/
  821. static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
  822. ixgbe_link_speed speed,
  823. bool autoneg_wait_to_complete)
  824. {
  825. bool autoneg = false;
  826. s32 status = 0;
  827. u32 pma_pmd_1g, link_mode, links_reg, i;
  828. u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
  829. u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
  830. ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
  831. /* holds the value of AUTOC register at this current point in time */
  832. u32 current_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  833. /* holds the cached value of AUTOC register */
  834. u32 orig_autoc = 0;
  835. /* temporary variable used for comparison purposes */
  836. u32 autoc = current_autoc;
  837. /* Check to see if speed passed in is supported. */
  838. status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities,
  839. &autoneg);
  840. if (status != 0)
  841. goto out;
  842. speed &= link_capabilities;
  843. if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
  844. status = IXGBE_ERR_LINK_SETUP;
  845. goto out;
  846. }
  847. /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
  848. if (hw->mac.orig_link_settings_stored)
  849. orig_autoc = hw->mac.orig_autoc;
  850. else
  851. orig_autoc = autoc;
  852. link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
  853. pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
  854. if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
  855. link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
  856. link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
  857. /* Set KX4/KX/KR support according to speed requested */
  858. autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
  859. if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
  860. if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
  861. autoc |= IXGBE_AUTOC_KX4_SUPP;
  862. if ((orig_autoc & IXGBE_AUTOC_KR_SUPP) &&
  863. (hw->phy.smart_speed_active == false))
  864. autoc |= IXGBE_AUTOC_KR_SUPP;
  865. }
  866. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  867. autoc |= IXGBE_AUTOC_KX_SUPP;
  868. } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
  869. (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
  870. link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
  871. /* Switch from 1G SFI to 10G SFI if requested */
  872. if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
  873. (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
  874. autoc &= ~IXGBE_AUTOC_LMS_MASK;
  875. autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
  876. }
  877. } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
  878. (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
  879. /* Switch from 10G SFI to 1G SFI if requested */
  880. if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
  881. (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
  882. autoc &= ~IXGBE_AUTOC_LMS_MASK;
  883. if (autoneg)
  884. autoc |= IXGBE_AUTOC_LMS_1G_AN;
  885. else
  886. autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
  887. }
  888. }
  889. if (autoc != current_autoc) {
  890. /* Restart link */
  891. status = hw->mac.ops.prot_autoc_write(hw, autoc, false);
  892. if (status)
  893. goto out;
  894. /* Only poll for autoneg to complete if specified to do so */
  895. if (autoneg_wait_to_complete) {
  896. if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
  897. link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
  898. link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
  899. links_reg = 0; /*Just in case Autoneg time=0*/
  900. for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
  901. links_reg =
  902. IXGBE_READ_REG(hw, IXGBE_LINKS);
  903. if (links_reg & IXGBE_LINKS_KX_AN_COMP)
  904. break;
  905. msleep(100);
  906. }
  907. if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
  908. status =
  909. IXGBE_ERR_AUTONEG_NOT_COMPLETE;
  910. hw_dbg(hw, "Autoneg did not complete.\n");
  911. }
  912. }
  913. }
  914. /* Add delay to filter out noises during initial link setup */
  915. msleep(50);
  916. }
  917. out:
  918. return status;
  919. }
  920. /**
  921. * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
  922. * @hw: pointer to hardware structure
  923. * @speed: new link speed
  924. * @autoneg_wait_to_complete: true if waiting is needed to complete
  925. *
  926. * Restarts link on PHY and MAC based on settings passed in.
  927. **/
  928. static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
  929. ixgbe_link_speed speed,
  930. bool autoneg_wait_to_complete)
  931. {
  932. s32 status;
  933. /* Setup the PHY according to input speed */
  934. status = hw->phy.ops.setup_link_speed(hw, speed,
  935. autoneg_wait_to_complete);
  936. /* Set up MAC */
  937. ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
  938. return status;
  939. }
  940. /**
  941. * ixgbe_reset_hw_82599 - Perform hardware reset
  942. * @hw: pointer to hardware structure
  943. *
  944. * Resets the hardware by resetting the transmit and receive units, masks
  945. * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
  946. * reset.
  947. **/
  948. static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
  949. {
  950. ixgbe_link_speed link_speed;
  951. s32 status;
  952. u32 ctrl, i, autoc, autoc2;
  953. u32 curr_lms;
  954. bool link_up = false;
  955. /* Call adapter stop to disable tx/rx and clear interrupts */
  956. status = hw->mac.ops.stop_adapter(hw);
  957. if (status != 0)
  958. goto reset_hw_out;
  959. /* flush pending Tx transactions */
  960. ixgbe_clear_tx_pending(hw);
  961. /* PHY ops must be identified and initialized prior to reset */
  962. /* Identify PHY and related function pointers */
  963. status = hw->phy.ops.init(hw);
  964. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
  965. goto reset_hw_out;
  966. /* Setup SFP module if there is one present. */
  967. if (hw->phy.sfp_setup_needed) {
  968. status = hw->mac.ops.setup_sfp(hw);
  969. hw->phy.sfp_setup_needed = false;
  970. }
  971. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
  972. goto reset_hw_out;
  973. /* Reset PHY */
  974. if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
  975. hw->phy.ops.reset(hw);
  976. /* remember AUTOC from before we reset */
  977. curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) & IXGBE_AUTOC_LMS_MASK;
  978. mac_reset_top:
  979. /*
  980. * Issue global reset to the MAC. Needs to be SW reset if link is up.
  981. * If link reset is used when link is up, it might reset the PHY when
  982. * mng is using it. If link is down or the flag to force full link
  983. * reset is set, then perform link reset.
  984. */
  985. ctrl = IXGBE_CTRL_LNK_RST;
  986. if (!hw->force_full_reset) {
  987. hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
  988. if (link_up)
  989. ctrl = IXGBE_CTRL_RST;
  990. }
  991. ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
  992. IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
  993. IXGBE_WRITE_FLUSH(hw);
  994. /* Poll for reset bit to self-clear indicating reset is complete */
  995. for (i = 0; i < 10; i++) {
  996. udelay(1);
  997. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  998. if (!(ctrl & IXGBE_CTRL_RST_MASK))
  999. break;
  1000. }
  1001. if (ctrl & IXGBE_CTRL_RST_MASK) {
  1002. status = IXGBE_ERR_RESET_FAILED;
  1003. hw_dbg(hw, "Reset polling failed to complete.\n");
  1004. }
  1005. msleep(50);
  1006. /*
  1007. * Double resets are required for recovery from certain error
  1008. * conditions. Between resets, it is necessary to stall to allow time
  1009. * for any pending HW events to complete.
  1010. */
  1011. if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
  1012. hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  1013. goto mac_reset_top;
  1014. }
  1015. /*
  1016. * Store the original AUTOC/AUTOC2 values if they have not been
  1017. * stored off yet. Otherwise restore the stored original
  1018. * values since the reset operation sets back to defaults.
  1019. */
  1020. autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  1021. autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
  1022. /* Enable link if disabled in NVM */
  1023. if (autoc2 & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
  1024. autoc2 &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
  1025. IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
  1026. IXGBE_WRITE_FLUSH(hw);
  1027. }
  1028. if (hw->mac.orig_link_settings_stored == false) {
  1029. hw->mac.orig_autoc = autoc;
  1030. hw->mac.orig_autoc2 = autoc2;
  1031. hw->mac.orig_link_settings_stored = true;
  1032. } else {
  1033. /* If MNG FW is running on a multi-speed device that
  1034. * doesn't autoneg with out driver support we need to
  1035. * leave LMS in the state it was before we MAC reset.
  1036. * Likewise if we support WoL we don't want change the
  1037. * LMS state either.
  1038. */
  1039. if ((hw->phy.multispeed_fiber && ixgbe_mng_enabled(hw)) ||
  1040. hw->wol_enabled)
  1041. hw->mac.orig_autoc =
  1042. (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |
  1043. curr_lms;
  1044. if (autoc != hw->mac.orig_autoc) {
  1045. status = hw->mac.ops.prot_autoc_write(hw,
  1046. hw->mac.orig_autoc,
  1047. false);
  1048. if (status)
  1049. goto reset_hw_out;
  1050. }
  1051. if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
  1052. (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
  1053. autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
  1054. autoc2 |= (hw->mac.orig_autoc2 &
  1055. IXGBE_AUTOC2_UPPER_MASK);
  1056. IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
  1057. }
  1058. }
  1059. /* Store the permanent mac address */
  1060. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  1061. /*
  1062. * Store MAC address from RAR0, clear receive address registers, and
  1063. * clear the multicast table. Also reset num_rar_entries to 128,
  1064. * since we modify this value when programming the SAN MAC address.
  1065. */
  1066. hw->mac.num_rar_entries = 128;
  1067. hw->mac.ops.init_rx_addrs(hw);
  1068. /* Store the permanent SAN mac address */
  1069. hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
  1070. /* Add the SAN MAC address to the RAR only if it's a valid address */
  1071. if (is_valid_ether_addr(hw->mac.san_addr)) {
  1072. hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
  1073. hw->mac.san_addr, 0, IXGBE_RAH_AV);
  1074. /* Save the SAN MAC RAR index */
  1075. hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
  1076. /* Reserve the last RAR for the SAN MAC address */
  1077. hw->mac.num_rar_entries--;
  1078. }
  1079. /* Store the alternative WWNN/WWPN prefix */
  1080. hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
  1081. &hw->mac.wwpn_prefix);
  1082. reset_hw_out:
  1083. return status;
  1084. }
  1085. /**
  1086. * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
  1087. * @hw: pointer to hardware structure
  1088. **/
  1089. s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
  1090. {
  1091. int i;
  1092. u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
  1093. fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
  1094. /*
  1095. * Before starting reinitialization process,
  1096. * FDIRCMD.CMD must be zero.
  1097. */
  1098. for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
  1099. if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
  1100. IXGBE_FDIRCMD_CMD_MASK))
  1101. break;
  1102. udelay(10);
  1103. }
  1104. if (i >= IXGBE_FDIRCMD_CMD_POLL) {
  1105. hw_dbg(hw, "Flow Director previous command isn't complete, aborting table re-initialization.\n");
  1106. return IXGBE_ERR_FDIR_REINIT_FAILED;
  1107. }
  1108. IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
  1109. IXGBE_WRITE_FLUSH(hw);
  1110. /*
  1111. * 82599 adapters flow director init flow cannot be restarted,
  1112. * Workaround 82599 silicon errata by performing the following steps
  1113. * before re-writing the FDIRCTRL control register with the same value.
  1114. * - write 1 to bit 8 of FDIRCMD register &
  1115. * - write 0 to bit 8 of FDIRCMD register
  1116. */
  1117. IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
  1118. (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
  1119. IXGBE_FDIRCMD_CLEARHT));
  1120. IXGBE_WRITE_FLUSH(hw);
  1121. IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
  1122. (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
  1123. ~IXGBE_FDIRCMD_CLEARHT));
  1124. IXGBE_WRITE_FLUSH(hw);
  1125. /*
  1126. * Clear FDIR Hash register to clear any leftover hashes
  1127. * waiting to be programmed.
  1128. */
  1129. IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, 0x00);
  1130. IXGBE_WRITE_FLUSH(hw);
  1131. IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
  1132. IXGBE_WRITE_FLUSH(hw);
  1133. /* Poll init-done after we write FDIRCTRL register */
  1134. for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
  1135. if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
  1136. IXGBE_FDIRCTRL_INIT_DONE)
  1137. break;
  1138. usleep_range(1000, 2000);
  1139. }
  1140. if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
  1141. hw_dbg(hw, "Flow Director Signature poll time exceeded!\n");
  1142. return IXGBE_ERR_FDIR_REINIT_FAILED;
  1143. }
  1144. /* Clear FDIR statistics registers (read to clear) */
  1145. IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);
  1146. IXGBE_READ_REG(hw, IXGBE_FDIRFSTAT);
  1147. IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
  1148. IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
  1149. IXGBE_READ_REG(hw, IXGBE_FDIRLEN);
  1150. return 0;
  1151. }
  1152. /**
  1153. * ixgbe_fdir_enable_82599 - Initialize Flow Director control registers
  1154. * @hw: pointer to hardware structure
  1155. * @fdirctrl: value to write to flow director control register
  1156. **/
  1157. static void ixgbe_fdir_enable_82599(struct ixgbe_hw *hw, u32 fdirctrl)
  1158. {
  1159. int i;
  1160. /* Prime the keys for hashing */
  1161. IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY, IXGBE_ATR_BUCKET_HASH_KEY);
  1162. IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY, IXGBE_ATR_SIGNATURE_HASH_KEY);
  1163. /*
  1164. * Poll init-done after we write the register. Estimated times:
  1165. * 10G: PBALLOC = 11b, timing is 60us
  1166. * 1G: PBALLOC = 11b, timing is 600us
  1167. * 100M: PBALLOC = 11b, timing is 6ms
  1168. *
  1169. * Multiple these timings by 4 if under full Rx load
  1170. *
  1171. * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
  1172. * 1 msec per poll time. If we're at line rate and drop to 100M, then
  1173. * this might not finish in our poll time, but we can live with that
  1174. * for now.
  1175. */
  1176. IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
  1177. IXGBE_WRITE_FLUSH(hw);
  1178. for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
  1179. if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
  1180. IXGBE_FDIRCTRL_INIT_DONE)
  1181. break;
  1182. usleep_range(1000, 2000);
  1183. }
  1184. if (i >= IXGBE_FDIR_INIT_DONE_POLL)
  1185. hw_dbg(hw, "Flow Director poll time exceeded!\n");
  1186. }
  1187. /**
  1188. * ixgbe_init_fdir_signature_82599 - Initialize Flow Director signature filters
  1189. * @hw: pointer to hardware structure
  1190. * @fdirctrl: value to write to flow director control register, initially
  1191. * contains just the value of the Rx packet buffer allocation
  1192. **/
  1193. s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl)
  1194. {
  1195. /*
  1196. * Continue setup of fdirctrl register bits:
  1197. * Move the flexible bytes to use the ethertype - shift 6 words
  1198. * Set the maximum length per hash bucket to 0xA filters
  1199. * Send interrupt when 64 filters are left
  1200. */
  1201. fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT) |
  1202. (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT) |
  1203. (4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT);
  1204. /* write hashes and fdirctrl register, poll for completion */
  1205. ixgbe_fdir_enable_82599(hw, fdirctrl);
  1206. return 0;
  1207. }
  1208. /**
  1209. * ixgbe_init_fdir_perfect_82599 - Initialize Flow Director perfect filters
  1210. * @hw: pointer to hardware structure
  1211. * @fdirctrl: value to write to flow director control register, initially
  1212. * contains just the value of the Rx packet buffer allocation
  1213. **/
  1214. s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl)
  1215. {
  1216. /*
  1217. * Continue setup of fdirctrl register bits:
  1218. * Turn perfect match filtering on
  1219. * Report hash in RSS field of Rx wb descriptor
  1220. * Initialize the drop queue
  1221. * Move the flexible bytes to use the ethertype - shift 6 words
  1222. * Set the maximum length per hash bucket to 0xA filters
  1223. * Send interrupt when 64 (0x4 * 16) filters are left
  1224. */
  1225. fdirctrl |= IXGBE_FDIRCTRL_PERFECT_MATCH |
  1226. IXGBE_FDIRCTRL_REPORT_STATUS |
  1227. (IXGBE_FDIR_DROP_QUEUE << IXGBE_FDIRCTRL_DROP_Q_SHIFT) |
  1228. (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT) |
  1229. (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT) |
  1230. (4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT);
  1231. /* write hashes and fdirctrl register, poll for completion */
  1232. ixgbe_fdir_enable_82599(hw, fdirctrl);
  1233. return 0;
  1234. }
  1235. /*
  1236. * These defines allow us to quickly generate all of the necessary instructions
  1237. * in the function below by simply calling out IXGBE_COMPUTE_SIG_HASH_ITERATION
  1238. * for values 0 through 15
  1239. */
  1240. #define IXGBE_ATR_COMMON_HASH_KEY \
  1241. (IXGBE_ATR_BUCKET_HASH_KEY & IXGBE_ATR_SIGNATURE_HASH_KEY)
  1242. #define IXGBE_COMPUTE_SIG_HASH_ITERATION(_n) \
  1243. do { \
  1244. u32 n = (_n); \
  1245. if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << n)) \
  1246. common_hash ^= lo_hash_dword >> n; \
  1247. else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << n)) \
  1248. bucket_hash ^= lo_hash_dword >> n; \
  1249. else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << n)) \
  1250. sig_hash ^= lo_hash_dword << (16 - n); \
  1251. if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << (n + 16))) \
  1252. common_hash ^= hi_hash_dword >> n; \
  1253. else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \
  1254. bucket_hash ^= hi_hash_dword >> n; \
  1255. else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << (n + 16))) \
  1256. sig_hash ^= hi_hash_dword << (16 - n); \
  1257. } while (0)
  1258. /**
  1259. * ixgbe_atr_compute_sig_hash_82599 - Compute the signature hash
  1260. * @stream: input bitstream to compute the hash on
  1261. *
  1262. * This function is almost identical to the function above but contains
  1263. * several optomizations such as unwinding all of the loops, letting the
  1264. * compiler work out all of the conditional ifs since the keys are static
  1265. * defines, and computing two keys at once since the hashed dword stream
  1266. * will be the same for both keys.
  1267. **/
  1268. static u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
  1269. union ixgbe_atr_hash_dword common)
  1270. {
  1271. u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
  1272. u32 sig_hash = 0, bucket_hash = 0, common_hash = 0;
  1273. /* record the flow_vm_vlan bits as they are a key part to the hash */
  1274. flow_vm_vlan = ntohl(input.dword);
  1275. /* generate common hash dword */
  1276. hi_hash_dword = ntohl(common.dword);
  1277. /* low dword is word swapped version of common */
  1278. lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
  1279. /* apply flow ID/VM pool/VLAN ID bits to hash words */
  1280. hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
  1281. /* Process bits 0 and 16 */
  1282. IXGBE_COMPUTE_SIG_HASH_ITERATION(0);
  1283. /*
  1284. * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
  1285. * delay this because bit 0 of the stream should not be processed
  1286. * so we do not add the vlan until after bit 0 was processed
  1287. */
  1288. lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
  1289. /* Process remaining 30 bit of the key */
  1290. IXGBE_COMPUTE_SIG_HASH_ITERATION(1);
  1291. IXGBE_COMPUTE_SIG_HASH_ITERATION(2);
  1292. IXGBE_COMPUTE_SIG_HASH_ITERATION(3);
  1293. IXGBE_COMPUTE_SIG_HASH_ITERATION(4);
  1294. IXGBE_COMPUTE_SIG_HASH_ITERATION(5);
  1295. IXGBE_COMPUTE_SIG_HASH_ITERATION(6);
  1296. IXGBE_COMPUTE_SIG_HASH_ITERATION(7);
  1297. IXGBE_COMPUTE_SIG_HASH_ITERATION(8);
  1298. IXGBE_COMPUTE_SIG_HASH_ITERATION(9);
  1299. IXGBE_COMPUTE_SIG_HASH_ITERATION(10);
  1300. IXGBE_COMPUTE_SIG_HASH_ITERATION(11);
  1301. IXGBE_COMPUTE_SIG_HASH_ITERATION(12);
  1302. IXGBE_COMPUTE_SIG_HASH_ITERATION(13);
  1303. IXGBE_COMPUTE_SIG_HASH_ITERATION(14);
  1304. IXGBE_COMPUTE_SIG_HASH_ITERATION(15);
  1305. /* combine common_hash result with signature and bucket hashes */
  1306. bucket_hash ^= common_hash;
  1307. bucket_hash &= IXGBE_ATR_HASH_MASK;
  1308. sig_hash ^= common_hash << 16;
  1309. sig_hash &= IXGBE_ATR_HASH_MASK << 16;
  1310. /* return completed signature hash */
  1311. return sig_hash ^ bucket_hash;
  1312. }
  1313. /**
  1314. * ixgbe_atr_add_signature_filter_82599 - Adds a signature hash filter
  1315. * @hw: pointer to hardware structure
  1316. * @input: unique input dword
  1317. * @common: compressed common input dword
  1318. * @queue: queue index to direct traffic to
  1319. **/
  1320. s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
  1321. union ixgbe_atr_hash_dword input,
  1322. union ixgbe_atr_hash_dword common,
  1323. u8 queue)
  1324. {
  1325. u64 fdirhashcmd;
  1326. u32 fdircmd;
  1327. /*
  1328. * Get the flow_type in order to program FDIRCMD properly
  1329. * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6
  1330. */
  1331. switch (input.formatted.flow_type) {
  1332. case IXGBE_ATR_FLOW_TYPE_TCPV4:
  1333. case IXGBE_ATR_FLOW_TYPE_UDPV4:
  1334. case IXGBE_ATR_FLOW_TYPE_SCTPV4:
  1335. case IXGBE_ATR_FLOW_TYPE_TCPV6:
  1336. case IXGBE_ATR_FLOW_TYPE_UDPV6:
  1337. case IXGBE_ATR_FLOW_TYPE_SCTPV6:
  1338. break;
  1339. default:
  1340. hw_dbg(hw, " Error on flow type input\n");
  1341. return IXGBE_ERR_CONFIG;
  1342. }
  1343. /* configure FDIRCMD register */
  1344. fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
  1345. IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
  1346. fdircmd |= input.formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
  1347. fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
  1348. /*
  1349. * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
  1350. * is for FDIRCMD. Then do a 64-bit register write from FDIRHASH.
  1351. */
  1352. fdirhashcmd = (u64)fdircmd << 32;
  1353. fdirhashcmd |= ixgbe_atr_compute_sig_hash_82599(input, common);
  1354. IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
  1355. hw_dbg(hw, "Tx Queue=%x hash=%x\n", queue, (u32)fdirhashcmd);
  1356. return 0;
  1357. }
  1358. #define IXGBE_COMPUTE_BKT_HASH_ITERATION(_n) \
  1359. do { \
  1360. u32 n = (_n); \
  1361. if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << n)) \
  1362. bucket_hash ^= lo_hash_dword >> n; \
  1363. if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \
  1364. bucket_hash ^= hi_hash_dword >> n; \
  1365. } while (0)
  1366. /**
  1367. * ixgbe_atr_compute_perfect_hash_82599 - Compute the perfect filter hash
  1368. * @atr_input: input bitstream to compute the hash on
  1369. * @input_mask: mask for the input bitstream
  1370. *
  1371. * This function serves two main purposes. First it applys the input_mask
  1372. * to the atr_input resulting in a cleaned up atr_input data stream.
  1373. * Secondly it computes the hash and stores it in the bkt_hash field at
  1374. * the end of the input byte stream. This way it will be available for
  1375. * future use without needing to recompute the hash.
  1376. **/
  1377. void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
  1378. union ixgbe_atr_input *input_mask)
  1379. {
  1380. u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
  1381. u32 bucket_hash = 0, hi_dword = 0;
  1382. int i;
  1383. /* Apply masks to input data */
  1384. for (i = 0; i <= 10; i++)
  1385. input->dword_stream[i] &= input_mask->dword_stream[i];
  1386. /* record the flow_vm_vlan bits as they are a key part to the hash */
  1387. flow_vm_vlan = ntohl(input->dword_stream[0]);
  1388. /* generate common hash dword */
  1389. for (i = 1; i <= 10; i++)
  1390. hi_dword ^= input->dword_stream[i];
  1391. hi_hash_dword = ntohl(hi_dword);
  1392. /* low dword is word swapped version of common */
  1393. lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
  1394. /* apply flow ID/VM pool/VLAN ID bits to hash words */
  1395. hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
  1396. /* Process bits 0 and 16 */
  1397. IXGBE_COMPUTE_BKT_HASH_ITERATION(0);
  1398. /*
  1399. * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
  1400. * delay this because bit 0 of the stream should not be processed
  1401. * so we do not add the vlan until after bit 0 was processed
  1402. */
  1403. lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
  1404. /* Process remaining 30 bit of the key */
  1405. for (i = 1; i <= 15; i++)
  1406. IXGBE_COMPUTE_BKT_HASH_ITERATION(i);
  1407. /*
  1408. * Limit hash to 13 bits since max bucket count is 8K.
  1409. * Store result at the end of the input stream.
  1410. */
  1411. input->formatted.bkt_hash = bucket_hash & 0x1FFF;
  1412. }
  1413. /**
  1414. * ixgbe_get_fdirtcpm_82599 - generate a tcp port from atr_input_masks
  1415. * @input_mask: mask to be bit swapped
  1416. *
  1417. * The source and destination port masks for flow director are bit swapped
  1418. * in that bit 15 effects bit 0, 14 effects 1, 13, 2 etc. In order to
  1419. * generate a correctly swapped value we need to bit swap the mask and that
  1420. * is what is accomplished by this function.
  1421. **/
  1422. static u32 ixgbe_get_fdirtcpm_82599(union ixgbe_atr_input *input_mask)
  1423. {
  1424. u32 mask = ntohs(input_mask->formatted.dst_port);
  1425. mask <<= IXGBE_FDIRTCPM_DPORTM_SHIFT;
  1426. mask |= ntohs(input_mask->formatted.src_port);
  1427. mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
  1428. mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
  1429. mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
  1430. return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
  1431. }
  1432. /*
  1433. * These two macros are meant to address the fact that we have registers
  1434. * that are either all or in part big-endian. As a result on big-endian
  1435. * systems we will end up byte swapping the value to little-endian before
  1436. * it is byte swapped again and written to the hardware in the original
  1437. * big-endian format.
  1438. */
  1439. #define IXGBE_STORE_AS_BE32(_value) \
  1440. (((u32)(_value) >> 24) | (((u32)(_value) & 0x00FF0000) >> 8) | \
  1441. (((u32)(_value) & 0x0000FF00) << 8) | ((u32)(_value) << 24))
  1442. #define IXGBE_WRITE_REG_BE32(a, reg, value) \
  1443. IXGBE_WRITE_REG((a), (reg), IXGBE_STORE_AS_BE32(ntohl(value)))
  1444. #define IXGBE_STORE_AS_BE16(_value) \
  1445. ntohs(((u16)(_value) >> 8) | ((u16)(_value) << 8))
  1446. s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
  1447. union ixgbe_atr_input *input_mask)
  1448. {
  1449. /* mask IPv6 since it is currently not supported */
  1450. u32 fdirm = IXGBE_FDIRM_DIPv6;
  1451. u32 fdirtcpm;
  1452. /*
  1453. * Program the relevant mask registers. If src/dst_port or src/dst_addr
  1454. * are zero, then assume a full mask for that field. Also assume that
  1455. * a VLAN of 0 is unspecified, so mask that out as well. L4type
  1456. * cannot be masked out in this implementation.
  1457. *
  1458. * This also assumes IPv4 only. IPv6 masking isn't supported at this
  1459. * point in time.
  1460. */
  1461. /* verify bucket hash is cleared on hash generation */
  1462. if (input_mask->formatted.bkt_hash)
  1463. hw_dbg(hw, " bucket hash should always be 0 in mask\n");
  1464. /* Program FDIRM and verify partial masks */
  1465. switch (input_mask->formatted.vm_pool & 0x7F) {
  1466. case 0x0:
  1467. fdirm |= IXGBE_FDIRM_POOL;
  1468. case 0x7F:
  1469. break;
  1470. default:
  1471. hw_dbg(hw, " Error on vm pool mask\n");
  1472. return IXGBE_ERR_CONFIG;
  1473. }
  1474. switch (input_mask->formatted.flow_type & IXGBE_ATR_L4TYPE_MASK) {
  1475. case 0x0:
  1476. fdirm |= IXGBE_FDIRM_L4P;
  1477. if (input_mask->formatted.dst_port ||
  1478. input_mask->formatted.src_port) {
  1479. hw_dbg(hw, " Error on src/dst port mask\n");
  1480. return IXGBE_ERR_CONFIG;
  1481. }
  1482. case IXGBE_ATR_L4TYPE_MASK:
  1483. break;
  1484. default:
  1485. hw_dbg(hw, " Error on flow type mask\n");
  1486. return IXGBE_ERR_CONFIG;
  1487. }
  1488. switch (ntohs(input_mask->formatted.vlan_id) & 0xEFFF) {
  1489. case 0x0000:
  1490. /* mask VLAN ID, fall through to mask VLAN priority */
  1491. fdirm |= IXGBE_FDIRM_VLANID;
  1492. case 0x0FFF:
  1493. /* mask VLAN priority */
  1494. fdirm |= IXGBE_FDIRM_VLANP;
  1495. break;
  1496. case 0xE000:
  1497. /* mask VLAN ID only, fall through */
  1498. fdirm |= IXGBE_FDIRM_VLANID;
  1499. case 0xEFFF:
  1500. /* no VLAN fields masked */
  1501. break;
  1502. default:
  1503. hw_dbg(hw, " Error on VLAN mask\n");
  1504. return IXGBE_ERR_CONFIG;
  1505. }
  1506. switch (input_mask->formatted.flex_bytes & 0xFFFF) {
  1507. case 0x0000:
  1508. /* Mask Flex Bytes, fall through */
  1509. fdirm |= IXGBE_FDIRM_FLEX;
  1510. case 0xFFFF:
  1511. break;
  1512. default:
  1513. hw_dbg(hw, " Error on flexible byte mask\n");
  1514. return IXGBE_ERR_CONFIG;
  1515. }
  1516. /* Now mask VM pool and destination IPv6 - bits 5 and 2 */
  1517. IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
  1518. /* store the TCP/UDP port masks, bit reversed from port layout */
  1519. fdirtcpm = ixgbe_get_fdirtcpm_82599(input_mask);
  1520. /* write both the same so that UDP and TCP use the same mask */
  1521. IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
  1522. IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
  1523. /* store source and destination IP masks (big-enian) */
  1524. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
  1525. ~input_mask->formatted.src_ip[0]);
  1526. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
  1527. ~input_mask->formatted.dst_ip[0]);
  1528. return 0;
  1529. }
  1530. s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
  1531. union ixgbe_atr_input *input,
  1532. u16 soft_id, u8 queue)
  1533. {
  1534. u32 fdirport, fdirvlan, fdirhash, fdircmd;
  1535. /* currently IPv6 is not supported, must be programmed with 0 */
  1536. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(0),
  1537. input->formatted.src_ip[0]);
  1538. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(1),
  1539. input->formatted.src_ip[1]);
  1540. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(2),
  1541. input->formatted.src_ip[2]);
  1542. /* record the source address (big-endian) */
  1543. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[0]);
  1544. /* record the first 32 bits of the destination address (big-endian) */
  1545. IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
  1546. /* record source and destination port (little-endian)*/
  1547. fdirport = ntohs(input->formatted.dst_port);
  1548. fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
  1549. fdirport |= ntohs(input->formatted.src_port);
  1550. IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
  1551. /* record vlan (little-endian) and flex_bytes(big-endian) */
  1552. fdirvlan = IXGBE_STORE_AS_BE16(input->formatted.flex_bytes);
  1553. fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
  1554. fdirvlan |= ntohs(input->formatted.vlan_id);
  1555. IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
  1556. /* configure FDIRHASH register */
  1557. fdirhash = input->formatted.bkt_hash;
  1558. fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
  1559. IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
  1560. /*
  1561. * flush all previous writes to make certain registers are
  1562. * programmed prior to issuing the command
  1563. */
  1564. IXGBE_WRITE_FLUSH(hw);
  1565. /* configure FDIRCMD register */
  1566. fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
  1567. IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
  1568. if (queue == IXGBE_FDIR_DROP_QUEUE)
  1569. fdircmd |= IXGBE_FDIRCMD_DROP;
  1570. fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
  1571. fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
  1572. fdircmd |= (u32)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT;
  1573. IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
  1574. return 0;
  1575. }
  1576. s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
  1577. union ixgbe_atr_input *input,
  1578. u16 soft_id)
  1579. {
  1580. u32 fdirhash;
  1581. u32 fdircmd = 0;
  1582. u32 retry_count;
  1583. s32 err = 0;
  1584. /* configure FDIRHASH register */
  1585. fdirhash = input->formatted.bkt_hash;
  1586. fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
  1587. IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
  1588. /* flush hash to HW */
  1589. IXGBE_WRITE_FLUSH(hw);
  1590. /* Query if filter is present */
  1591. IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT);
  1592. for (retry_count = 10; retry_count; retry_count--) {
  1593. /* allow 10us for query to process */
  1594. udelay(10);
  1595. /* verify query completed successfully */
  1596. fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
  1597. if (!(fdircmd & IXGBE_FDIRCMD_CMD_MASK))
  1598. break;
  1599. }
  1600. if (!retry_count)
  1601. err = IXGBE_ERR_FDIR_REINIT_FAILED;
  1602. /* if filter exists in hardware then remove it */
  1603. if (fdircmd & IXGBE_FDIRCMD_FILTER_VALID) {
  1604. IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
  1605. IXGBE_WRITE_FLUSH(hw);
  1606. IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
  1607. IXGBE_FDIRCMD_CMD_REMOVE_FLOW);
  1608. }
  1609. return err;
  1610. }
  1611. /**
  1612. * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
  1613. * @hw: pointer to hardware structure
  1614. * @reg: analog register to read
  1615. * @val: read value
  1616. *
  1617. * Performs read operation to Omer analog register specified.
  1618. **/
  1619. static s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
  1620. {
  1621. u32 core_ctl;
  1622. IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
  1623. (reg << 8));
  1624. IXGBE_WRITE_FLUSH(hw);
  1625. udelay(10);
  1626. core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
  1627. *val = (u8)core_ctl;
  1628. return 0;
  1629. }
  1630. /**
  1631. * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
  1632. * @hw: pointer to hardware structure
  1633. * @reg: atlas register to write
  1634. * @val: value to write
  1635. *
  1636. * Performs write operation to Omer analog register specified.
  1637. **/
  1638. static s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
  1639. {
  1640. u32 core_ctl;
  1641. core_ctl = (reg << 8) | val;
  1642. IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
  1643. IXGBE_WRITE_FLUSH(hw);
  1644. udelay(10);
  1645. return 0;
  1646. }
  1647. /**
  1648. * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
  1649. * @hw: pointer to hardware structure
  1650. *
  1651. * Starts the hardware using the generic start_hw function
  1652. * and the generation start_hw function.
  1653. * Then performs revision-specific operations, if any.
  1654. **/
  1655. static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
  1656. {
  1657. s32 ret_val = 0;
  1658. ret_val = ixgbe_start_hw_generic(hw);
  1659. if (ret_val != 0)
  1660. goto out;
  1661. ret_val = ixgbe_start_hw_gen2(hw);
  1662. if (ret_val != 0)
  1663. goto out;
  1664. /* We need to run link autotry after the driver loads */
  1665. hw->mac.autotry_restart = true;
  1666. if (ret_val == 0)
  1667. ret_val = ixgbe_verify_fw_version_82599(hw);
  1668. out:
  1669. return ret_val;
  1670. }
  1671. /**
  1672. * ixgbe_identify_phy_82599 - Get physical layer module
  1673. * @hw: pointer to hardware structure
  1674. *
  1675. * Determines the physical layer module found on the current adapter.
  1676. * If PHY already detected, maintains current PHY type in hw struct,
  1677. * otherwise executes the PHY detection routine.
  1678. **/
  1679. static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
  1680. {
  1681. s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
  1682. /* Detect PHY if not unknown - returns success if already detected. */
  1683. status = ixgbe_identify_phy_generic(hw);
  1684. if (status != 0) {
  1685. /* 82599 10GBASE-T requires an external PHY */
  1686. if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)
  1687. goto out;
  1688. else
  1689. status = ixgbe_identify_module_generic(hw);
  1690. }
  1691. /* Set PHY type none if no PHY detected */
  1692. if (hw->phy.type == ixgbe_phy_unknown) {
  1693. hw->phy.type = ixgbe_phy_none;
  1694. status = 0;
  1695. }
  1696. /* Return error if SFP module has been detected but is not supported */
  1697. if (hw->phy.type == ixgbe_phy_sfp_unsupported)
  1698. status = IXGBE_ERR_SFP_NOT_SUPPORTED;
  1699. out:
  1700. return status;
  1701. }
  1702. /**
  1703. * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
  1704. * @hw: pointer to hardware structure
  1705. *
  1706. * Determines physical layer capabilities of the current configuration.
  1707. **/
  1708. static u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
  1709. {
  1710. u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
  1711. u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  1712. u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
  1713. u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
  1714. u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
  1715. u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
  1716. u16 ext_ability = 0;
  1717. u8 comp_codes_10g = 0;
  1718. u8 comp_codes_1g = 0;
  1719. hw->phy.ops.identify(hw);
  1720. switch (hw->phy.type) {
  1721. case ixgbe_phy_tn:
  1722. case ixgbe_phy_cu_unknown:
  1723. hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
  1724. &ext_ability);
  1725. if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
  1726. physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
  1727. if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
  1728. physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
  1729. if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
  1730. physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
  1731. goto out;
  1732. default:
  1733. break;
  1734. }
  1735. switch (autoc & IXGBE_AUTOC_LMS_MASK) {
  1736. case IXGBE_AUTOC_LMS_1G_AN:
  1737. case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
  1738. if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
  1739. physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
  1740. IXGBE_PHYSICAL_LAYER_1000BASE_BX;
  1741. goto out;
  1742. } else
  1743. /* SFI mode so read SFP module */
  1744. goto sfp_check;
  1745. break;
  1746. case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
  1747. if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
  1748. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
  1749. else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
  1750. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
  1751. else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
  1752. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
  1753. goto out;
  1754. break;
  1755. case IXGBE_AUTOC_LMS_10G_SERIAL:
  1756. if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
  1757. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
  1758. goto out;
  1759. } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
  1760. goto sfp_check;
  1761. break;
  1762. case IXGBE_AUTOC_LMS_KX4_KX_KR:
  1763. case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
  1764. if (autoc & IXGBE_AUTOC_KX_SUPP)
  1765. physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
  1766. if (autoc & IXGBE_AUTOC_KX4_SUPP)
  1767. physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
  1768. if (autoc & IXGBE_AUTOC_KR_SUPP)
  1769. physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
  1770. goto out;
  1771. break;
  1772. default:
  1773. goto out;
  1774. break;
  1775. }
  1776. sfp_check:
  1777. /* SFP check must be done last since DA modules are sometimes used to
  1778. * test KR mode - we need to id KR mode correctly before SFP module.
  1779. * Call identify_sfp because the pluggable module may have changed */
  1780. hw->phy.ops.identify_sfp(hw);
  1781. if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
  1782. goto out;
  1783. switch (hw->phy.type) {
  1784. case ixgbe_phy_sfp_passive_tyco:
  1785. case ixgbe_phy_sfp_passive_unknown:
  1786. case ixgbe_phy_qsfp_passive_unknown:
  1787. physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
  1788. break;
  1789. case ixgbe_phy_sfp_ftl_active:
  1790. case ixgbe_phy_sfp_active_unknown:
  1791. case ixgbe_phy_qsfp_active_unknown:
  1792. physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
  1793. break;
  1794. case ixgbe_phy_sfp_avago:
  1795. case ixgbe_phy_sfp_ftl:
  1796. case ixgbe_phy_sfp_intel:
  1797. case ixgbe_phy_sfp_unknown:
  1798. hw->phy.ops.read_i2c_eeprom(hw,
  1799. IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
  1800. hw->phy.ops.read_i2c_eeprom(hw,
  1801. IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
  1802. if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
  1803. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
  1804. else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
  1805. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
  1806. else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
  1807. physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
  1808. break;
  1809. case ixgbe_phy_qsfp_intel:
  1810. case ixgbe_phy_qsfp_unknown:
  1811. hw->phy.ops.read_i2c_eeprom(hw,
  1812. IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
  1813. if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
  1814. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
  1815. else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
  1816. physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
  1817. break;
  1818. default:
  1819. break;
  1820. }
  1821. out:
  1822. return physical_layer;
  1823. }
  1824. /**
  1825. * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
  1826. * @hw: pointer to hardware structure
  1827. * @regval: register value to write to RXCTRL
  1828. *
  1829. * Enables the Rx DMA unit for 82599
  1830. **/
  1831. static s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
  1832. {
  1833. /*
  1834. * Workaround for 82599 silicon errata when enabling the Rx datapath.
  1835. * If traffic is incoming before we enable the Rx unit, it could hang
  1836. * the Rx DMA unit. Therefore, make sure the security engine is
  1837. * completely disabled prior to enabling the Rx unit.
  1838. */
  1839. hw->mac.ops.disable_rx_buff(hw);
  1840. IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
  1841. hw->mac.ops.enable_rx_buff(hw);
  1842. return 0;
  1843. }
  1844. /**
  1845. * ixgbe_verify_fw_version_82599 - verify fw version for 82599
  1846. * @hw: pointer to hardware structure
  1847. *
  1848. * Verifies that installed the firmware version is 0.6 or higher
  1849. * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
  1850. *
  1851. * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
  1852. * if the FW version is not supported.
  1853. **/
  1854. static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
  1855. {
  1856. s32 status = IXGBE_ERR_EEPROM_VERSION;
  1857. u16 fw_offset, fw_ptp_cfg_offset;
  1858. u16 offset;
  1859. u16 fw_version = 0;
  1860. /* firmware check is only necessary for SFI devices */
  1861. if (hw->phy.media_type != ixgbe_media_type_fiber) {
  1862. status = 0;
  1863. goto fw_version_out;
  1864. }
  1865. /* get the offset to the Firmware Module block */
  1866. offset = IXGBE_FW_PTR;
  1867. if (hw->eeprom.ops.read(hw, offset, &fw_offset))
  1868. goto fw_version_err;
  1869. if ((fw_offset == 0) || (fw_offset == 0xFFFF))
  1870. goto fw_version_out;
  1871. /* get the offset to the Pass Through Patch Configuration block */
  1872. offset = fw_offset + IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR;
  1873. if (hw->eeprom.ops.read(hw, offset, &fw_ptp_cfg_offset))
  1874. goto fw_version_err;
  1875. if ((fw_ptp_cfg_offset == 0) || (fw_ptp_cfg_offset == 0xFFFF))
  1876. goto fw_version_out;
  1877. /* get the firmware version */
  1878. offset = fw_ptp_cfg_offset + IXGBE_FW_PATCH_VERSION_4;
  1879. if (hw->eeprom.ops.read(hw, offset, &fw_version))
  1880. goto fw_version_err;
  1881. if (fw_version > 0x5)
  1882. status = 0;
  1883. fw_version_out:
  1884. return status;
  1885. fw_version_err:
  1886. hw_err(hw, "eeprom read at offset %d failed\n", offset);
  1887. return IXGBE_ERR_EEPROM_VERSION;
  1888. }
  1889. /**
  1890. * ixgbe_verify_lesm_fw_enabled_82599 - Checks LESM FW module state.
  1891. * @hw: pointer to hardware structure
  1892. *
  1893. * Returns true if the LESM FW module is present and enabled. Otherwise
  1894. * returns false. Smart Speed must be disabled if LESM FW module is enabled.
  1895. **/
  1896. static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)
  1897. {
  1898. bool lesm_enabled = false;
  1899. u16 fw_offset, fw_lesm_param_offset, fw_lesm_state;
  1900. s32 status;
  1901. /* get the offset to the Firmware Module block */
  1902. status = hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset);
  1903. if ((status != 0) ||
  1904. (fw_offset == 0) || (fw_offset == 0xFFFF))
  1905. goto out;
  1906. /* get the offset to the LESM Parameters block */
  1907. status = hw->eeprom.ops.read(hw, (fw_offset +
  1908. IXGBE_FW_LESM_PARAMETERS_PTR),
  1909. &fw_lesm_param_offset);
  1910. if ((status != 0) ||
  1911. (fw_lesm_param_offset == 0) || (fw_lesm_param_offset == 0xFFFF))
  1912. goto out;
  1913. /* get the lesm state word */
  1914. status = hw->eeprom.ops.read(hw, (fw_lesm_param_offset +
  1915. IXGBE_FW_LESM_STATE_1),
  1916. &fw_lesm_state);
  1917. if ((status == 0) &&
  1918. (fw_lesm_state & IXGBE_FW_LESM_STATE_ENABLED))
  1919. lesm_enabled = true;
  1920. out:
  1921. return lesm_enabled;
  1922. }
  1923. /**
  1924. * ixgbe_read_eeprom_buffer_82599 - Read EEPROM word(s) using
  1925. * fastest available method
  1926. *
  1927. * @hw: pointer to hardware structure
  1928. * @offset: offset of word in EEPROM to read
  1929. * @words: number of words
  1930. * @data: word(s) read from the EEPROM
  1931. *
  1932. * Retrieves 16 bit word(s) read from EEPROM
  1933. **/
  1934. static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
  1935. u16 words, u16 *data)
  1936. {
  1937. struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
  1938. s32 ret_val = IXGBE_ERR_CONFIG;
  1939. /*
  1940. * If EEPROM is detected and can be addressed using 14 bits,
  1941. * use EERD otherwise use bit bang
  1942. */
  1943. if ((eeprom->type == ixgbe_eeprom_spi) &&
  1944. (offset + (words - 1) <= IXGBE_EERD_MAX_ADDR))
  1945. ret_val = ixgbe_read_eerd_buffer_generic(hw, offset, words,
  1946. data);
  1947. else
  1948. ret_val = ixgbe_read_eeprom_buffer_bit_bang_generic(hw, offset,
  1949. words,
  1950. data);
  1951. return ret_val;
  1952. }
  1953. /**
  1954. * ixgbe_read_eeprom_82599 - Read EEPROM word using
  1955. * fastest available method
  1956. *
  1957. * @hw: pointer to hardware structure
  1958. * @offset: offset of word in the EEPROM to read
  1959. * @data: word read from the EEPROM
  1960. *
  1961. * Reads a 16 bit word from the EEPROM
  1962. **/
  1963. static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
  1964. u16 offset, u16 *data)
  1965. {
  1966. struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
  1967. s32 ret_val = IXGBE_ERR_CONFIG;
  1968. /*
  1969. * If EEPROM is detected and can be addressed using 14 bits,
  1970. * use EERD otherwise use bit bang
  1971. */
  1972. if ((eeprom->type == ixgbe_eeprom_spi) &&
  1973. (offset <= IXGBE_EERD_MAX_ADDR))
  1974. ret_val = ixgbe_read_eerd_generic(hw, offset, data);
  1975. else
  1976. ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
  1977. return ret_val;
  1978. }
  1979. /**
  1980. * ixgbe_reset_pipeline_82599 - perform pipeline reset
  1981. *
  1982. * @hw: pointer to hardware structure
  1983. *
  1984. * Reset pipeline by asserting Restart_AN together with LMS change to ensure
  1985. * full pipeline reset. Note - We must hold the SW/FW semaphore before writing
  1986. * to AUTOC, so this function assumes the semaphore is held.
  1987. **/
  1988. static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
  1989. {
  1990. s32 ret_val;
  1991. u32 anlp1_reg = 0;
  1992. u32 i, autoc_reg, autoc2_reg;
  1993. /* Enable link if disabled in NVM */
  1994. autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
  1995. if (autoc2_reg & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
  1996. autoc2_reg &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
  1997. IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
  1998. IXGBE_WRITE_FLUSH(hw);
  1999. }
  2000. autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
  2001. autoc_reg |= IXGBE_AUTOC_AN_RESTART;
  2002. /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
  2003. IXGBE_WRITE_REG(hw, IXGBE_AUTOC,
  2004. autoc_reg ^ (0x4 << IXGBE_AUTOC_LMS_SHIFT));
  2005. /* Wait for AN to leave state 0 */
  2006. for (i = 0; i < 10; i++) {
  2007. usleep_range(4000, 8000);
  2008. anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
  2009. if (anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)
  2010. break;
  2011. }
  2012. if (!(anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)) {
  2013. hw_dbg(hw, "auto negotiation not completed\n");
  2014. ret_val = IXGBE_ERR_RESET_FAILED;
  2015. goto reset_pipeline_out;
  2016. }
  2017. ret_val = 0;
  2018. reset_pipeline_out:
  2019. /* Write AUTOC register with original LMS field and Restart_AN */
  2020. IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
  2021. IXGBE_WRITE_FLUSH(hw);
  2022. return ret_val;
  2023. }
  2024. /**
  2025. * ixgbe_read_i2c_byte_82599 - Reads 8 bit word over I2C
  2026. * @hw: pointer to hardware structure
  2027. * @byte_offset: byte offset to read
  2028. * @data: value read
  2029. *
  2030. * Performs byte read operation to SFP module's EEPROM over I2C interface at
  2031. * a specified device address.
  2032. **/
  2033. static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
  2034. u8 dev_addr, u8 *data)
  2035. {
  2036. u32 esdp;
  2037. s32 status;
  2038. s32 timeout = 200;
  2039. if (hw->phy.qsfp_shared_i2c_bus == true) {
  2040. /* Acquire I2C bus ownership. */
  2041. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2042. esdp |= IXGBE_ESDP_SDP0;
  2043. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  2044. IXGBE_WRITE_FLUSH(hw);
  2045. while (timeout) {
  2046. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2047. if (esdp & IXGBE_ESDP_SDP1)
  2048. break;
  2049. usleep_range(5000, 10000);
  2050. timeout--;
  2051. }
  2052. if (!timeout) {
  2053. hw_dbg(hw, "Driver can't access resource, acquiring I2C bus timeout.\n");
  2054. status = IXGBE_ERR_I2C;
  2055. goto release_i2c_access;
  2056. }
  2057. }
  2058. status = ixgbe_read_i2c_byte_generic(hw, byte_offset, dev_addr, data);
  2059. release_i2c_access:
  2060. if (hw->phy.qsfp_shared_i2c_bus == true) {
  2061. /* Release I2C bus ownership. */
  2062. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2063. esdp &= ~IXGBE_ESDP_SDP0;
  2064. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  2065. IXGBE_WRITE_FLUSH(hw);
  2066. }
  2067. return status;
  2068. }
  2069. /**
  2070. * ixgbe_write_i2c_byte_82599 - Writes 8 bit word over I2C
  2071. * @hw: pointer to hardware structure
  2072. * @byte_offset: byte offset to write
  2073. * @data: value to write
  2074. *
  2075. * Performs byte write operation to SFP module's EEPROM over I2C interface at
  2076. * a specified device address.
  2077. **/
  2078. static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
  2079. u8 dev_addr, u8 data)
  2080. {
  2081. u32 esdp;
  2082. s32 status;
  2083. s32 timeout = 200;
  2084. if (hw->phy.qsfp_shared_i2c_bus == true) {
  2085. /* Acquire I2C bus ownership. */
  2086. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2087. esdp |= IXGBE_ESDP_SDP0;
  2088. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  2089. IXGBE_WRITE_FLUSH(hw);
  2090. while (timeout) {
  2091. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2092. if (esdp & IXGBE_ESDP_SDP1)
  2093. break;
  2094. usleep_range(5000, 10000);
  2095. timeout--;
  2096. }
  2097. if (!timeout) {
  2098. hw_dbg(hw, "Driver can't access resource, acquiring I2C bus timeout.\n");
  2099. status = IXGBE_ERR_I2C;
  2100. goto release_i2c_access;
  2101. }
  2102. }
  2103. status = ixgbe_write_i2c_byte_generic(hw, byte_offset, dev_addr, data);
  2104. release_i2c_access:
  2105. if (hw->phy.qsfp_shared_i2c_bus == true) {
  2106. /* Release I2C bus ownership. */
  2107. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2108. esdp &= ~IXGBE_ESDP_SDP0;
  2109. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  2110. IXGBE_WRITE_FLUSH(hw);
  2111. }
  2112. return status;
  2113. }
  2114. static struct ixgbe_mac_operations mac_ops_82599 = {
  2115. .init_hw = &ixgbe_init_hw_generic,
  2116. .reset_hw = &ixgbe_reset_hw_82599,
  2117. .start_hw = &ixgbe_start_hw_82599,
  2118. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
  2119. .get_media_type = &ixgbe_get_media_type_82599,
  2120. .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
  2121. .enable_rx_dma = &ixgbe_enable_rx_dma_82599,
  2122. .disable_rx_buff = &ixgbe_disable_rx_buff_generic,
  2123. .enable_rx_buff = &ixgbe_enable_rx_buff_generic,
  2124. .get_mac_addr = &ixgbe_get_mac_addr_generic,
  2125. .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
  2126. .get_device_caps = &ixgbe_get_device_caps_generic,
  2127. .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
  2128. .stop_adapter = &ixgbe_stop_adapter_generic,
  2129. .get_bus_info = &ixgbe_get_bus_info_generic,
  2130. .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
  2131. .read_analog_reg8 = &ixgbe_read_analog_reg8_82599,
  2132. .write_analog_reg8 = &ixgbe_write_analog_reg8_82599,
  2133. .stop_link_on_d3 = &ixgbe_stop_mac_link_on_d3_82599,
  2134. .setup_link = &ixgbe_setup_mac_link_82599,
  2135. .set_rxpba = &ixgbe_set_rxpba_generic,
  2136. .check_link = &ixgbe_check_mac_link_generic,
  2137. .get_link_capabilities = &ixgbe_get_link_capabilities_82599,
  2138. .led_on = &ixgbe_led_on_generic,
  2139. .led_off = &ixgbe_led_off_generic,
  2140. .blink_led_start = &ixgbe_blink_led_start_generic,
  2141. .blink_led_stop = &ixgbe_blink_led_stop_generic,
  2142. .set_rar = &ixgbe_set_rar_generic,
  2143. .clear_rar = &ixgbe_clear_rar_generic,
  2144. .set_vmdq = &ixgbe_set_vmdq_generic,
  2145. .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic,
  2146. .clear_vmdq = &ixgbe_clear_vmdq_generic,
  2147. .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
  2148. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
  2149. .enable_mc = &ixgbe_enable_mc_generic,
  2150. .disable_mc = &ixgbe_disable_mc_generic,
  2151. .clear_vfta = &ixgbe_clear_vfta_generic,
  2152. .set_vfta = &ixgbe_set_vfta_generic,
  2153. .fc_enable = &ixgbe_fc_enable_generic,
  2154. .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic,
  2155. .init_uta_tables = &ixgbe_init_uta_tables_generic,
  2156. .setup_sfp = &ixgbe_setup_sfp_modules_82599,
  2157. .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing,
  2158. .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing,
  2159. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync,
  2160. .release_swfw_sync = &ixgbe_release_swfw_sync,
  2161. .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic,
  2162. .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic,
  2163. .prot_autoc_read = &prot_autoc_read_82599,
  2164. .prot_autoc_write = &prot_autoc_write_82599,
  2165. };
  2166. static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
  2167. .init_params = &ixgbe_init_eeprom_params_generic,
  2168. .read = &ixgbe_read_eeprom_82599,
  2169. .read_buffer = &ixgbe_read_eeprom_buffer_82599,
  2170. .write = &ixgbe_write_eeprom_generic,
  2171. .write_buffer = &ixgbe_write_eeprom_buffer_bit_bang_generic,
  2172. .calc_checksum = &ixgbe_calc_eeprom_checksum_generic,
  2173. .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
  2174. .update_checksum = &ixgbe_update_eeprom_checksum_generic,
  2175. };
  2176. static struct ixgbe_phy_operations phy_ops_82599 = {
  2177. .identify = &ixgbe_identify_phy_82599,
  2178. .identify_sfp = &ixgbe_identify_module_generic,
  2179. .init = &ixgbe_init_phy_ops_82599,
  2180. .reset = &ixgbe_reset_phy_generic,
  2181. .read_reg = &ixgbe_read_phy_reg_generic,
  2182. .write_reg = &ixgbe_write_phy_reg_generic,
  2183. .setup_link = &ixgbe_setup_phy_link_generic,
  2184. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
  2185. .read_i2c_byte = &ixgbe_read_i2c_byte_generic,
  2186. .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
  2187. .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic,
  2188. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
  2189. .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
  2190. .check_overtemp = &ixgbe_tn_check_overtemp,
  2191. };
  2192. struct ixgbe_info ixgbe_82599_info = {
  2193. .mac = ixgbe_mac_82599EB,
  2194. .get_invariants = &ixgbe_get_invariants_82599,
  2195. .mac_ops = &mac_ops_82599,
  2196. .eeprom_ops = &eeprom_ops_82599,
  2197. .phy_ops = &phy_ops_82599,
  2198. .mbx_ops = &mbx_ops_generic,
  2199. };