ixgbe_82599.c 77 KB

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