ixgbe_x550.c 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085
  1. /*******************************************************************************
  2. *
  3. * Intel 10 Gigabit PCI Express Linux driver
  4. * Copyright(c) 1999 - 2016 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Contact Information:
  19. * Linux NICS <linux.nics@intel.com>
  20. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  21. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  22. *
  23. ******************************************************************************/
  24. #include "ixgbe_x540.h"
  25. #include "ixgbe_type.h"
  26. #include "ixgbe_common.h"
  27. #include "ixgbe_phy.h"
  28. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *, ixgbe_link_speed);
  29. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *);
  30. static void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *);
  31. static void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *);
  32. static s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *);
  33. static s32 ixgbe_get_invariants_X550_x(struct ixgbe_hw *hw)
  34. {
  35. struct ixgbe_mac_info *mac = &hw->mac;
  36. struct ixgbe_phy_info *phy = &hw->phy;
  37. struct ixgbe_link_info *link = &hw->link;
  38. /* Start with X540 invariants, since so simular */
  39. ixgbe_get_invariants_X540(hw);
  40. if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
  41. phy->ops.set_phy_power = NULL;
  42. link->addr = IXGBE_CS4227;
  43. return 0;
  44. }
  45. static s32 ixgbe_get_invariants_X550_x_fw(struct ixgbe_hw *hw)
  46. {
  47. struct ixgbe_phy_info *phy = &hw->phy;
  48. /* Start with X540 invariants, since so similar */
  49. ixgbe_get_invariants_X540(hw);
  50. phy->ops.set_phy_power = NULL;
  51. return 0;
  52. }
  53. static s32 ixgbe_get_invariants_X550_a(struct ixgbe_hw *hw)
  54. {
  55. struct ixgbe_mac_info *mac = &hw->mac;
  56. struct ixgbe_phy_info *phy = &hw->phy;
  57. /* Start with X540 invariants, since so simular */
  58. ixgbe_get_invariants_X540(hw);
  59. if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
  60. phy->ops.set_phy_power = NULL;
  61. return 0;
  62. }
  63. static s32 ixgbe_get_invariants_X550_a_fw(struct ixgbe_hw *hw)
  64. {
  65. struct ixgbe_phy_info *phy = &hw->phy;
  66. /* Start with X540 invariants, since so similar */
  67. ixgbe_get_invariants_X540(hw);
  68. phy->ops.set_phy_power = NULL;
  69. return 0;
  70. }
  71. /** ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
  72. * @hw: pointer to hardware structure
  73. **/
  74. static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  75. {
  76. u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  77. if (hw->bus.lan_id) {
  78. esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
  79. esdp |= IXGBE_ESDP_SDP1_DIR;
  80. }
  81. esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
  82. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  83. IXGBE_WRITE_FLUSH(hw);
  84. }
  85. /**
  86. * ixgbe_read_cs4227 - Read CS4227 register
  87. * @hw: pointer to hardware structure
  88. * @reg: register number to write
  89. * @value: pointer to receive value read
  90. *
  91. * Returns status code
  92. */
  93. static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
  94. {
  95. return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
  96. }
  97. /**
  98. * ixgbe_write_cs4227 - Write CS4227 register
  99. * @hw: pointer to hardware structure
  100. * @reg: register number to write
  101. * @value: value to write to register
  102. *
  103. * Returns status code
  104. */
  105. static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
  106. {
  107. return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
  108. }
  109. /**
  110. * ixgbe_read_pe - Read register from port expander
  111. * @hw: pointer to hardware structure
  112. * @reg: register number to read
  113. * @value: pointer to receive read value
  114. *
  115. * Returns status code
  116. */
  117. static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
  118. {
  119. s32 status;
  120. status = ixgbe_read_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE, value);
  121. if (status)
  122. hw_err(hw, "port expander access failed with %d\n", status);
  123. return status;
  124. }
  125. /**
  126. * ixgbe_write_pe - Write register to port expander
  127. * @hw: pointer to hardware structure
  128. * @reg: register number to write
  129. * @value: value to write
  130. *
  131. * Returns status code
  132. */
  133. static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
  134. {
  135. s32 status;
  136. status = ixgbe_write_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE,
  137. value);
  138. if (status)
  139. hw_err(hw, "port expander access failed with %d\n", status);
  140. return status;
  141. }
  142. /**
  143. * ixgbe_reset_cs4227 - Reset CS4227 using port expander
  144. * @hw: pointer to hardware structure
  145. *
  146. * This function assumes that the caller has acquired the proper semaphore.
  147. * Returns error code
  148. */
  149. static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
  150. {
  151. s32 status;
  152. u32 retry;
  153. u16 value;
  154. u8 reg;
  155. /* Trigger hard reset. */
  156. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  157. if (status)
  158. return status;
  159. reg |= IXGBE_PE_BIT1;
  160. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  161. if (status)
  162. return status;
  163. status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, &reg);
  164. if (status)
  165. return status;
  166. reg &= ~IXGBE_PE_BIT1;
  167. status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
  168. if (status)
  169. return status;
  170. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  171. if (status)
  172. return status;
  173. reg &= ~IXGBE_PE_BIT1;
  174. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  175. if (status)
  176. return status;
  177. usleep_range(IXGBE_CS4227_RESET_HOLD, IXGBE_CS4227_RESET_HOLD + 100);
  178. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  179. if (status)
  180. return status;
  181. reg |= IXGBE_PE_BIT1;
  182. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  183. if (status)
  184. return status;
  185. /* Wait for the reset to complete. */
  186. msleep(IXGBE_CS4227_RESET_DELAY);
  187. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  188. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
  189. &value);
  190. if (!status && value == IXGBE_CS4227_EEPROM_LOAD_OK)
  191. break;
  192. msleep(IXGBE_CS4227_CHECK_DELAY);
  193. }
  194. if (retry == IXGBE_CS4227_RETRIES) {
  195. hw_err(hw, "CS4227 reset did not complete\n");
  196. return IXGBE_ERR_PHY;
  197. }
  198. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
  199. if (status || !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
  200. hw_err(hw, "CS4227 EEPROM did not load successfully\n");
  201. return IXGBE_ERR_PHY;
  202. }
  203. return 0;
  204. }
  205. /**
  206. * ixgbe_check_cs4227 - Check CS4227 and reset as needed
  207. * @hw: pointer to hardware structure
  208. */
  209. static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
  210. {
  211. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  212. s32 status;
  213. u16 value;
  214. u8 retry;
  215. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  216. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  217. if (status) {
  218. hw_err(hw, "semaphore failed with %d\n", status);
  219. msleep(IXGBE_CS4227_CHECK_DELAY);
  220. continue;
  221. }
  222. /* Get status of reset flow. */
  223. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
  224. if (!status && value == IXGBE_CS4227_RESET_COMPLETE)
  225. goto out;
  226. if (status || value != IXGBE_CS4227_RESET_PENDING)
  227. break;
  228. /* Reset is pending. Wait and check again. */
  229. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  230. msleep(IXGBE_CS4227_CHECK_DELAY);
  231. }
  232. /* If still pending, assume other instance failed. */
  233. if (retry == IXGBE_CS4227_RETRIES) {
  234. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  235. if (status) {
  236. hw_err(hw, "semaphore failed with %d\n", status);
  237. return;
  238. }
  239. }
  240. /* Reset the CS4227. */
  241. status = ixgbe_reset_cs4227(hw);
  242. if (status) {
  243. hw_err(hw, "CS4227 reset failed: %d", status);
  244. goto out;
  245. }
  246. /* Reset takes so long, temporarily release semaphore in case the
  247. * other driver instance is waiting for the reset indication.
  248. */
  249. ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  250. IXGBE_CS4227_RESET_PENDING);
  251. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  252. usleep_range(10000, 12000);
  253. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  254. if (status) {
  255. hw_err(hw, "semaphore failed with %d", status);
  256. return;
  257. }
  258. /* Record completion for next time. */
  259. status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  260. IXGBE_CS4227_RESET_COMPLETE);
  261. out:
  262. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  263. msleep(hw->eeprom.semaphore_delay);
  264. }
  265. /** ixgbe_identify_phy_x550em - Get PHY type based on device id
  266. * @hw: pointer to hardware structure
  267. *
  268. * Returns error code
  269. */
  270. static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
  271. {
  272. switch (hw->device_id) {
  273. case IXGBE_DEV_ID_X550EM_A_SFP:
  274. if (hw->bus.lan_id)
  275. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  276. else
  277. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  278. return ixgbe_identify_module_generic(hw);
  279. case IXGBE_DEV_ID_X550EM_X_SFP:
  280. /* set up for CS4227 usage */
  281. hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  282. ixgbe_setup_mux_ctl(hw);
  283. ixgbe_check_cs4227(hw);
  284. /* Fallthrough */
  285. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  286. return ixgbe_identify_module_generic(hw);
  287. case IXGBE_DEV_ID_X550EM_X_KX4:
  288. hw->phy.type = ixgbe_phy_x550em_kx4;
  289. break;
  290. case IXGBE_DEV_ID_X550EM_X_XFI:
  291. hw->phy.type = ixgbe_phy_x550em_xfi;
  292. break;
  293. case IXGBE_DEV_ID_X550EM_X_KR:
  294. case IXGBE_DEV_ID_X550EM_A_KR:
  295. case IXGBE_DEV_ID_X550EM_A_KR_L:
  296. hw->phy.type = ixgbe_phy_x550em_kr;
  297. break;
  298. case IXGBE_DEV_ID_X550EM_A_10G_T:
  299. if (hw->bus.lan_id)
  300. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  301. else
  302. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  303. /* Fallthrough */
  304. case IXGBE_DEV_ID_X550EM_X_10G_T:
  305. return ixgbe_identify_phy_generic(hw);
  306. case IXGBE_DEV_ID_X550EM_X_1G_T:
  307. hw->phy.type = ixgbe_phy_ext_1g_t;
  308. break;
  309. case IXGBE_DEV_ID_X550EM_A_1G_T:
  310. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  311. hw->phy.type = ixgbe_phy_fw;
  312. hw->phy.ops.read_reg = NULL;
  313. hw->phy.ops.write_reg = NULL;
  314. if (hw->bus.lan_id)
  315. hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
  316. else
  317. hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
  318. break;
  319. default:
  320. break;
  321. }
  322. return 0;
  323. }
  324. static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  325. u32 device_type, u16 *phy_data)
  326. {
  327. return IXGBE_NOT_IMPLEMENTED;
  328. }
  329. static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  330. u32 device_type, u16 phy_data)
  331. {
  332. return IXGBE_NOT_IMPLEMENTED;
  333. }
  334. /**
  335. * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
  336. * @hw: pointer to the hardware structure
  337. * @addr: I2C bus address to read from
  338. * @reg: I2C device register to read from
  339. * @val: pointer to location to receive read value
  340. *
  341. * Returns an error code on error.
  342. **/
  343. static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
  344. u16 reg, u16 *val)
  345. {
  346. return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
  347. }
  348. /**
  349. * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
  350. * @hw: pointer to the hardware structure
  351. * @addr: I2C bus address to read from
  352. * @reg: I2C device register to read from
  353. * @val: pointer to location to receive read value
  354. *
  355. * Returns an error code on error.
  356. **/
  357. static s32
  358. ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
  359. u16 reg, u16 *val)
  360. {
  361. return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
  362. }
  363. /**
  364. * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
  365. * @hw: pointer to the hardware structure
  366. * @addr: I2C bus address to write to
  367. * @reg: I2C device register to write to
  368. * @val: value to write
  369. *
  370. * Returns an error code on error.
  371. **/
  372. static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
  373. u8 addr, u16 reg, u16 val)
  374. {
  375. return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
  376. }
  377. /**
  378. * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
  379. * @hw: pointer to the hardware structure
  380. * @addr: I2C bus address to write to
  381. * @reg: I2C device register to write to
  382. * @val: value to write
  383. *
  384. * Returns an error code on error.
  385. **/
  386. static s32
  387. ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  388. u8 addr, u16 reg, u16 val)
  389. {
  390. return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
  391. }
  392. /**
  393. * ixgbe_fw_phy_activity - Perform an activity on a PHY
  394. * @hw: pointer to hardware structure
  395. * @activity: activity to perform
  396. * @data: Pointer to 4 32-bit words of data
  397. */
  398. s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
  399. u32 (*data)[FW_PHY_ACT_DATA_COUNT])
  400. {
  401. union {
  402. struct ixgbe_hic_phy_activity_req cmd;
  403. struct ixgbe_hic_phy_activity_resp rsp;
  404. } hic;
  405. u16 retries = FW_PHY_ACT_RETRIES;
  406. s32 rc;
  407. u32 i;
  408. do {
  409. memset(&hic, 0, sizeof(hic));
  410. hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
  411. hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
  412. hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  413. hic.cmd.port_number = hw->bus.lan_id;
  414. hic.cmd.activity_id = cpu_to_le16(activity);
  415. for (i = 0; i < ARRAY_SIZE(hic.cmd.data); ++i)
  416. hic.cmd.data[i] = cpu_to_be32((*data)[i]);
  417. rc = ixgbe_host_interface_command(hw, &hic.cmd, sizeof(hic.cmd),
  418. IXGBE_HI_COMMAND_TIMEOUT,
  419. true);
  420. if (rc)
  421. return rc;
  422. if (hic.rsp.hdr.cmd_or_resp.ret_status ==
  423. FW_CEM_RESP_STATUS_SUCCESS) {
  424. for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
  425. (*data)[i] = be32_to_cpu(hic.rsp.data[i]);
  426. return 0;
  427. }
  428. usleep_range(20, 30);
  429. --retries;
  430. } while (retries > 0);
  431. return IXGBE_ERR_HOST_INTERFACE_COMMAND;
  432. }
  433. static const struct {
  434. u16 fw_speed;
  435. ixgbe_link_speed phy_speed;
  436. } ixgbe_fw_map[] = {
  437. { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
  438. { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
  439. { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
  440. { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
  441. { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
  442. { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
  443. };
  444. /**
  445. * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
  446. * @hw: pointer to hardware structure
  447. *
  448. * Returns error code
  449. */
  450. static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
  451. {
  452. u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
  453. u16 phy_speeds;
  454. u16 phy_id_lo;
  455. s32 rc;
  456. u16 i;
  457. if (hw->phy.id)
  458. return 0;
  459. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
  460. if (rc)
  461. return rc;
  462. hw->phy.speeds_supported = 0;
  463. phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
  464. for (i = 0; i < ARRAY_SIZE(ixgbe_fw_map); ++i) {
  465. if (phy_speeds & ixgbe_fw_map[i].fw_speed)
  466. hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
  467. }
  468. hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
  469. phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
  470. hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
  471. hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
  472. if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
  473. return IXGBE_ERR_PHY_ADDR_INVALID;
  474. hw->phy.autoneg_advertised = hw->phy.speeds_supported;
  475. hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
  476. IXGBE_LINK_SPEED_1GB_FULL;
  477. hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
  478. return 0;
  479. }
  480. /**
  481. * ixgbe_identify_phy_fw - Get PHY type based on firmware command
  482. * @hw: pointer to hardware structure
  483. *
  484. * Returns error code
  485. */
  486. static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
  487. {
  488. if (hw->bus.lan_id)
  489. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  490. else
  491. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  492. hw->phy.type = ixgbe_phy_fw;
  493. hw->phy.ops.read_reg = NULL;
  494. hw->phy.ops.write_reg = NULL;
  495. return ixgbe_get_phy_id_fw(hw);
  496. }
  497. /**
  498. * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
  499. * @hw: pointer to hardware structure
  500. *
  501. * Returns error code
  502. */
  503. static s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
  504. {
  505. u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
  506. setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
  507. return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
  508. }
  509. /**
  510. * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
  511. * @hw: pointer to hardware structure
  512. */
  513. static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
  514. {
  515. u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
  516. s32 rc;
  517. u16 i;
  518. if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
  519. return 0;
  520. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  521. hw_err(hw, "rx_pause not valid in strict IEEE mode\n");
  522. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  523. }
  524. switch (hw->fc.requested_mode) {
  525. case ixgbe_fc_full:
  526. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
  527. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  528. break;
  529. case ixgbe_fc_rx_pause:
  530. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
  531. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  532. break;
  533. case ixgbe_fc_tx_pause:
  534. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
  535. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  536. break;
  537. default:
  538. break;
  539. }
  540. for (i = 0; i < ARRAY_SIZE(ixgbe_fw_map); ++i) {
  541. if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
  542. setup[0] |= ixgbe_fw_map[i].fw_speed;
  543. }
  544. setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
  545. if (hw->phy.eee_speeds_advertised)
  546. setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
  547. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
  548. if (rc)
  549. return rc;
  550. if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
  551. return IXGBE_ERR_OVERTEMP;
  552. return 0;
  553. }
  554. /**
  555. * ixgbe_fc_autoneg_fw - Set up flow control for FW-controlled PHYs
  556. * @hw: pointer to hardware structure
  557. *
  558. * Called at init time to set up flow control.
  559. */
  560. static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
  561. {
  562. if (hw->fc.requested_mode == ixgbe_fc_default)
  563. hw->fc.requested_mode = ixgbe_fc_full;
  564. return ixgbe_setup_fw_link(hw);
  565. }
  566. /** ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
  567. * @hw: pointer to hardware structure
  568. *
  569. * Initializes the EEPROM parameters ixgbe_eeprom_info within the
  570. * ixgbe_hw struct in order to set up EEPROM access.
  571. **/
  572. static s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  573. {
  574. struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
  575. u32 eec;
  576. u16 eeprom_size;
  577. if (eeprom->type == ixgbe_eeprom_uninitialized) {
  578. eeprom->semaphore_delay = 10;
  579. eeprom->type = ixgbe_flash;
  580. eec = IXGBE_READ_REG(hw, IXGBE_EEC(hw));
  581. eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
  582. IXGBE_EEC_SIZE_SHIFT);
  583. eeprom->word_size = BIT(eeprom_size +
  584. IXGBE_EEPROM_WORD_SIZE_SHIFT);
  585. hw_dbg(hw, "Eeprom params: type = %d, size = %d\n",
  586. eeprom->type, eeprom->word_size);
  587. }
  588. return 0;
  589. }
  590. /**
  591. * ixgbe_iosf_wait - Wait for IOSF command completion
  592. * @hw: pointer to hardware structure
  593. * @ctrl: pointer to location to receive final IOSF control value
  594. *
  595. * Return: failing status on timeout
  596. *
  597. * Note: ctrl can be NULL if the IOSF control register value is not needed
  598. */
  599. static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
  600. {
  601. u32 i, command;
  602. /* Check every 10 usec to see if the address cycle completed.
  603. * The SB IOSF BUSY bit will clear when the operation is
  604. * complete.
  605. */
  606. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  607. command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
  608. if (!(command & IXGBE_SB_IOSF_CTRL_BUSY))
  609. break;
  610. udelay(10);
  611. }
  612. if (ctrl)
  613. *ctrl = command;
  614. if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
  615. hw_dbg(hw, "IOSF wait timed out\n");
  616. return IXGBE_ERR_PHY;
  617. }
  618. return 0;
  619. }
  620. /** ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the
  621. * IOSF device
  622. * @hw: pointer to hardware structure
  623. * @reg_addr: 32 bit PHY register to write
  624. * @device_type: 3 bit device type
  625. * @phy_data: Pointer to read data from the register
  626. **/
  627. static s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  628. u32 device_type, u32 *data)
  629. {
  630. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  631. u32 command, error;
  632. s32 ret;
  633. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  634. if (ret)
  635. return ret;
  636. ret = ixgbe_iosf_wait(hw, NULL);
  637. if (ret)
  638. goto out;
  639. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  640. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  641. /* Write IOSF control register */
  642. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  643. ret = ixgbe_iosf_wait(hw, &command);
  644. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  645. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  646. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  647. hw_dbg(hw, "Failed to read, error %x\n", error);
  648. return IXGBE_ERR_PHY;
  649. }
  650. if (!ret)
  651. *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
  652. out:
  653. hw->mac.ops.release_swfw_sync(hw, gssr);
  654. return ret;
  655. }
  656. /**
  657. * ixgbe_get_phy_token - Get the token for shared PHY access
  658. * @hw: Pointer to hardware structure
  659. */
  660. static s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
  661. {
  662. struct ixgbe_hic_phy_token_req token_cmd;
  663. s32 status;
  664. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  665. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  666. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  667. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  668. token_cmd.port_number = hw->bus.lan_id;
  669. token_cmd.command_type = FW_PHY_TOKEN_REQ;
  670. token_cmd.pad = 0;
  671. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  672. IXGBE_HI_COMMAND_TIMEOUT,
  673. true);
  674. if (status)
  675. return status;
  676. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  677. return 0;
  678. if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
  679. return IXGBE_ERR_FW_RESP_INVALID;
  680. return IXGBE_ERR_TOKEN_RETRY;
  681. }
  682. /**
  683. * ixgbe_put_phy_token - Put the token for shared PHY access
  684. * @hw: Pointer to hardware structure
  685. */
  686. static s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  687. {
  688. struct ixgbe_hic_phy_token_req token_cmd;
  689. s32 status;
  690. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  691. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  692. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  693. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  694. token_cmd.port_number = hw->bus.lan_id;
  695. token_cmd.command_type = FW_PHY_TOKEN_REL;
  696. token_cmd.pad = 0;
  697. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  698. IXGBE_HI_COMMAND_TIMEOUT,
  699. true);
  700. if (status)
  701. return status;
  702. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  703. return 0;
  704. return IXGBE_ERR_FW_RESP_INVALID;
  705. }
  706. /**
  707. * ixgbe_write_iosf_sb_reg_x550a - Write to IOSF PHY register
  708. * @hw: pointer to hardware structure
  709. * @reg_addr: 32 bit PHY register to write
  710. * @device_type: 3 bit device type
  711. * @data: Data to write to the register
  712. **/
  713. static s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  714. __always_unused u32 device_type,
  715. u32 data)
  716. {
  717. struct ixgbe_hic_internal_phy_req write_cmd;
  718. memset(&write_cmd, 0, sizeof(write_cmd));
  719. write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  720. write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  721. write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  722. write_cmd.port_number = hw->bus.lan_id;
  723. write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
  724. write_cmd.address = cpu_to_be16(reg_addr);
  725. write_cmd.write_data = cpu_to_be32(data);
  726. return ixgbe_host_interface_command(hw, &write_cmd, sizeof(write_cmd),
  727. IXGBE_HI_COMMAND_TIMEOUT, false);
  728. }
  729. /**
  730. * ixgbe_read_iosf_sb_reg_x550a - Read from IOSF PHY register
  731. * @hw: pointer to hardware structure
  732. * @reg_addr: 32 bit PHY register to write
  733. * @device_type: 3 bit device type
  734. * @data: Pointer to read data from the register
  735. **/
  736. static s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  737. __always_unused u32 device_type,
  738. u32 *data)
  739. {
  740. union {
  741. struct ixgbe_hic_internal_phy_req cmd;
  742. struct ixgbe_hic_internal_phy_resp rsp;
  743. } hic;
  744. s32 status;
  745. memset(&hic, 0, sizeof(hic));
  746. hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  747. hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  748. hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  749. hic.cmd.port_number = hw->bus.lan_id;
  750. hic.cmd.command_type = FW_INT_PHY_REQ_READ;
  751. hic.cmd.address = cpu_to_be16(reg_addr);
  752. status = ixgbe_host_interface_command(hw, &hic.cmd, sizeof(hic.cmd),
  753. IXGBE_HI_COMMAND_TIMEOUT, true);
  754. /* Extract the register value from the response. */
  755. *data = be32_to_cpu(hic.rsp.read_data);
  756. return status;
  757. }
  758. /** ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
  759. * @hw: pointer to hardware structure
  760. * @offset: offset of word in the EEPROM to read
  761. * @words: number of words
  762. * @data: word(s) read from the EEPROM
  763. *
  764. * Reads a 16 bit word(s) from the EEPROM using the hostif.
  765. **/
  766. static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  767. u16 offset, u16 words, u16 *data)
  768. {
  769. const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
  770. struct ixgbe_hic_read_shadow_ram buffer;
  771. u32 current_word = 0;
  772. u16 words_to_read;
  773. s32 status;
  774. u32 i;
  775. /* Take semaphore for the entire operation. */
  776. status = hw->mac.ops.acquire_swfw_sync(hw, mask);
  777. if (status) {
  778. hw_dbg(hw, "EEPROM read buffer - semaphore failed\n");
  779. return status;
  780. }
  781. while (words) {
  782. if (words > FW_MAX_READ_BUFFER_SIZE / 2)
  783. words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
  784. else
  785. words_to_read = words;
  786. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  787. buffer.hdr.req.buf_lenh = 0;
  788. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  789. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  790. /* convert offset from words to bytes */
  791. buffer.address = cpu_to_be32((offset + current_word) * 2);
  792. buffer.length = cpu_to_be16(words_to_read * 2);
  793. buffer.pad2 = 0;
  794. buffer.pad3 = 0;
  795. status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
  796. IXGBE_HI_COMMAND_TIMEOUT);
  797. if (status) {
  798. hw_dbg(hw, "Host interface command failed\n");
  799. goto out;
  800. }
  801. for (i = 0; i < words_to_read; i++) {
  802. u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
  803. 2 * i;
  804. u32 value = IXGBE_READ_REG(hw, reg);
  805. data[current_word] = (u16)(value & 0xffff);
  806. current_word++;
  807. i++;
  808. if (i < words_to_read) {
  809. value >>= 16;
  810. data[current_word] = (u16)(value & 0xffff);
  811. current_word++;
  812. }
  813. }
  814. words -= words_to_read;
  815. }
  816. out:
  817. hw->mac.ops.release_swfw_sync(hw, mask);
  818. return status;
  819. }
  820. /** ixgbe_checksum_ptr_x550 - Checksum one pointer region
  821. * @hw: pointer to hardware structure
  822. * @ptr: pointer offset in eeprom
  823. * @size: size of section pointed by ptr, if 0 first word will be used as size
  824. * @csum: address of checksum to update
  825. *
  826. * Returns error status for any failure
  827. **/
  828. static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
  829. u16 size, u16 *csum, u16 *buffer,
  830. u32 buffer_size)
  831. {
  832. u16 buf[256];
  833. s32 status;
  834. u16 length, bufsz, i, start;
  835. u16 *local_buffer;
  836. bufsz = sizeof(buf) / sizeof(buf[0]);
  837. /* Read a chunk at the pointer location */
  838. if (!buffer) {
  839. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
  840. if (status) {
  841. hw_dbg(hw, "Failed to read EEPROM image\n");
  842. return status;
  843. }
  844. local_buffer = buf;
  845. } else {
  846. if (buffer_size < ptr)
  847. return IXGBE_ERR_PARAM;
  848. local_buffer = &buffer[ptr];
  849. }
  850. if (size) {
  851. start = 0;
  852. length = size;
  853. } else {
  854. start = 1;
  855. length = local_buffer[0];
  856. /* Skip pointer section if length is invalid. */
  857. if (length == 0xFFFF || length == 0 ||
  858. (ptr + length) >= hw->eeprom.word_size)
  859. return 0;
  860. }
  861. if (buffer && ((u32)start + (u32)length > buffer_size))
  862. return IXGBE_ERR_PARAM;
  863. for (i = start; length; i++, length--) {
  864. if (i == bufsz && !buffer) {
  865. ptr += bufsz;
  866. i = 0;
  867. if (length < bufsz)
  868. bufsz = length;
  869. /* Read a chunk at the pointer location */
  870. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
  871. bufsz, buf);
  872. if (status) {
  873. hw_dbg(hw, "Failed to read EEPROM image\n");
  874. return status;
  875. }
  876. }
  877. *csum += local_buffer[i];
  878. }
  879. return 0;
  880. }
  881. /** ixgbe_calc_checksum_X550 - Calculates and returns the checksum
  882. * @hw: pointer to hardware structure
  883. * @buffer: pointer to buffer containing calculated checksum
  884. * @buffer_size: size of buffer
  885. *
  886. * Returns a negative error code on error, or the 16-bit checksum
  887. **/
  888. static s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer,
  889. u32 buffer_size)
  890. {
  891. u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
  892. u16 *local_buffer;
  893. s32 status;
  894. u16 checksum = 0;
  895. u16 pointer, i, size;
  896. hw->eeprom.ops.init_params(hw);
  897. if (!buffer) {
  898. /* Read pointer area */
  899. status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
  900. IXGBE_EEPROM_LAST_WORD + 1,
  901. eeprom_ptrs);
  902. if (status) {
  903. hw_dbg(hw, "Failed to read EEPROM image\n");
  904. return status;
  905. }
  906. local_buffer = eeprom_ptrs;
  907. } else {
  908. if (buffer_size < IXGBE_EEPROM_LAST_WORD)
  909. return IXGBE_ERR_PARAM;
  910. local_buffer = buffer;
  911. }
  912. /* For X550 hardware include 0x0-0x41 in the checksum, skip the
  913. * checksum word itself
  914. */
  915. for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
  916. if (i != IXGBE_EEPROM_CHECKSUM)
  917. checksum += local_buffer[i];
  918. /* Include all data from pointers 0x3, 0x6-0xE. This excludes the
  919. * FW, PHY module, and PCIe Expansion/Option ROM pointers.
  920. */
  921. for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
  922. if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
  923. continue;
  924. pointer = local_buffer[i];
  925. /* Skip pointer section if the pointer is invalid. */
  926. if (pointer == 0xFFFF || pointer == 0 ||
  927. pointer >= hw->eeprom.word_size)
  928. continue;
  929. switch (i) {
  930. case IXGBE_PCIE_GENERAL_PTR:
  931. size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
  932. break;
  933. case IXGBE_PCIE_CONFIG0_PTR:
  934. case IXGBE_PCIE_CONFIG1_PTR:
  935. size = IXGBE_PCIE_CONFIG_SIZE;
  936. break;
  937. default:
  938. size = 0;
  939. break;
  940. }
  941. status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
  942. buffer, buffer_size);
  943. if (status)
  944. return status;
  945. }
  946. checksum = (u16)IXGBE_EEPROM_SUM - checksum;
  947. return (s32)checksum;
  948. }
  949. /** ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
  950. * @hw: pointer to hardware structure
  951. *
  952. * Returns a negative error code on error, or the 16-bit checksum
  953. **/
  954. static s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
  955. {
  956. return ixgbe_calc_checksum_X550(hw, NULL, 0);
  957. }
  958. /** ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
  959. * @hw: pointer to hardware structure
  960. * @offset: offset of word in the EEPROM to read
  961. * @data: word read from the EEPROM
  962. *
  963. * Reads a 16 bit word from the EEPROM using the hostif.
  964. **/
  965. static s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
  966. {
  967. const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
  968. struct ixgbe_hic_read_shadow_ram buffer;
  969. s32 status;
  970. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  971. buffer.hdr.req.buf_lenh = 0;
  972. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  973. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  974. /* convert offset from words to bytes */
  975. buffer.address = cpu_to_be32(offset * 2);
  976. /* one word */
  977. buffer.length = cpu_to_be16(sizeof(u16));
  978. status = hw->mac.ops.acquire_swfw_sync(hw, mask);
  979. if (status)
  980. return status;
  981. status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
  982. IXGBE_HI_COMMAND_TIMEOUT);
  983. if (!status) {
  984. *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
  985. FW_NVM_DATA_OFFSET);
  986. }
  987. hw->mac.ops.release_swfw_sync(hw, mask);
  988. return status;
  989. }
  990. /** ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
  991. * @hw: pointer to hardware structure
  992. * @checksum_val: calculated checksum
  993. *
  994. * Performs checksum calculation and validates the EEPROM checksum. If the
  995. * caller does not need checksum_val, the value can be NULL.
  996. **/
  997. static s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw,
  998. u16 *checksum_val)
  999. {
  1000. s32 status;
  1001. u16 checksum;
  1002. u16 read_checksum = 0;
  1003. /* Read the first word from the EEPROM. If this times out or fails, do
  1004. * not continue or we could be in for a very long wait while every
  1005. * EEPROM read fails
  1006. */
  1007. status = hw->eeprom.ops.read(hw, 0, &checksum);
  1008. if (status) {
  1009. hw_dbg(hw, "EEPROM read failed\n");
  1010. return status;
  1011. }
  1012. status = hw->eeprom.ops.calc_checksum(hw);
  1013. if (status < 0)
  1014. return status;
  1015. checksum = (u16)(status & 0xffff);
  1016. status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  1017. &read_checksum);
  1018. if (status)
  1019. return status;
  1020. /* Verify read checksum from EEPROM is the same as
  1021. * calculated checksum
  1022. */
  1023. if (read_checksum != checksum) {
  1024. status = IXGBE_ERR_EEPROM_CHECKSUM;
  1025. hw_dbg(hw, "Invalid EEPROM checksum");
  1026. }
  1027. /* If the user cares, return the calculated checksum */
  1028. if (checksum_val)
  1029. *checksum_val = checksum;
  1030. return status;
  1031. }
  1032. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  1033. * @hw: pointer to hardware structure
  1034. * @offset: offset of word in the EEPROM to write
  1035. * @data: word write to the EEPROM
  1036. *
  1037. * Write a 16 bit word to the EEPROM using the hostif.
  1038. **/
  1039. static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
  1040. u16 data)
  1041. {
  1042. s32 status;
  1043. struct ixgbe_hic_write_shadow_ram buffer;
  1044. buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
  1045. buffer.hdr.req.buf_lenh = 0;
  1046. buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
  1047. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  1048. /* one word */
  1049. buffer.length = cpu_to_be16(sizeof(u16));
  1050. buffer.data = data;
  1051. buffer.address = cpu_to_be32(offset * 2);
  1052. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  1053. IXGBE_HI_COMMAND_TIMEOUT, false);
  1054. return status;
  1055. }
  1056. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  1057. * @hw: pointer to hardware structure
  1058. * @offset: offset of word in the EEPROM to write
  1059. * @data: word write to the EEPROM
  1060. *
  1061. * Write a 16 bit word to the EEPROM using the hostif.
  1062. **/
  1063. static s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 data)
  1064. {
  1065. s32 status = 0;
  1066. if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
  1067. status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
  1068. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1069. } else {
  1070. hw_dbg(hw, "write ee hostif failed to get semaphore");
  1071. status = IXGBE_ERR_SWFW_SYNC;
  1072. }
  1073. return status;
  1074. }
  1075. /** ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
  1076. * @hw: pointer to hardware structure
  1077. *
  1078. * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
  1079. **/
  1080. static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
  1081. {
  1082. s32 status = 0;
  1083. union ixgbe_hic_hdr2 buffer;
  1084. buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
  1085. buffer.req.buf_lenh = 0;
  1086. buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
  1087. buffer.req.checksum = FW_DEFAULT_CHECKSUM;
  1088. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  1089. IXGBE_HI_COMMAND_TIMEOUT, false);
  1090. return status;
  1091. }
  1092. /**
  1093. * ixgbe_get_bus_info_X550em - Set PCI bus info
  1094. * @hw: pointer to hardware structure
  1095. *
  1096. * Sets bus link width and speed to unknown because X550em is
  1097. * not a PCI device.
  1098. **/
  1099. static s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
  1100. {
  1101. hw->bus.type = ixgbe_bus_type_internal;
  1102. hw->bus.width = ixgbe_bus_width_unknown;
  1103. hw->bus.speed = ixgbe_bus_speed_unknown;
  1104. hw->mac.ops.set_lan_id(hw);
  1105. return 0;
  1106. }
  1107. /** ixgbe_disable_rx_x550 - Disable RX unit
  1108. *
  1109. * Enables the Rx DMA unit for x550
  1110. **/
  1111. static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
  1112. {
  1113. u32 rxctrl, pfdtxgswc;
  1114. s32 status;
  1115. struct ixgbe_hic_disable_rxen fw_cmd;
  1116. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  1117. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  1118. pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
  1119. if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
  1120. pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
  1121. IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
  1122. hw->mac.set_lben = true;
  1123. } else {
  1124. hw->mac.set_lben = false;
  1125. }
  1126. fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
  1127. fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
  1128. fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  1129. fw_cmd.port_number = hw->bus.lan_id;
  1130. status = ixgbe_host_interface_command(hw, &fw_cmd,
  1131. sizeof(struct ixgbe_hic_disable_rxen),
  1132. IXGBE_HI_COMMAND_TIMEOUT, true);
  1133. /* If we fail - disable RX using register write */
  1134. if (status) {
  1135. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  1136. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  1137. rxctrl &= ~IXGBE_RXCTRL_RXEN;
  1138. IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
  1139. }
  1140. }
  1141. }
  1142. }
  1143. /** ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
  1144. * @hw: pointer to hardware structure
  1145. *
  1146. * After writing EEPROM to shadow RAM using EEWR register, software calculates
  1147. * checksum and updates the EEPROM and instructs the hardware to update
  1148. * the flash.
  1149. **/
  1150. static s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
  1151. {
  1152. s32 status;
  1153. u16 checksum = 0;
  1154. /* Read the first word from the EEPROM. If this times out or fails, do
  1155. * not continue or we could be in for a very long wait while every
  1156. * EEPROM read fails
  1157. */
  1158. status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
  1159. if (status) {
  1160. hw_dbg(hw, "EEPROM read failed\n");
  1161. return status;
  1162. }
  1163. status = ixgbe_calc_eeprom_checksum_X550(hw);
  1164. if (status < 0)
  1165. return status;
  1166. checksum = (u16)(status & 0xffff);
  1167. status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  1168. checksum);
  1169. if (status)
  1170. return status;
  1171. status = ixgbe_update_flash_X550(hw);
  1172. return status;
  1173. }
  1174. /** ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
  1175. * @hw: pointer to hardware structure
  1176. * @offset: offset of word in the EEPROM to write
  1177. * @words: number of words
  1178. * @data: word(s) write to the EEPROM
  1179. *
  1180. *
  1181. * Write a 16 bit word(s) to the EEPROM using the hostif.
  1182. **/
  1183. static s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  1184. u16 offset, u16 words,
  1185. u16 *data)
  1186. {
  1187. s32 status = 0;
  1188. u32 i = 0;
  1189. /* Take semaphore for the entire operation. */
  1190. status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1191. if (status) {
  1192. hw_dbg(hw, "EEPROM write buffer - semaphore failed\n");
  1193. return status;
  1194. }
  1195. for (i = 0; i < words; i++) {
  1196. status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
  1197. data[i]);
  1198. if (status) {
  1199. hw_dbg(hw, "Eeprom buffered write failed\n");
  1200. break;
  1201. }
  1202. }
  1203. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1204. return status;
  1205. }
  1206. /** ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the
  1207. * IOSF device
  1208. *
  1209. * @hw: pointer to hardware structure
  1210. * @reg_addr: 32 bit PHY register to write
  1211. * @device_type: 3 bit device type
  1212. * @data: Data to write to the register
  1213. **/
  1214. static s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  1215. u32 device_type, u32 data)
  1216. {
  1217. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  1218. u32 command, error;
  1219. s32 ret;
  1220. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  1221. if (ret)
  1222. return ret;
  1223. ret = ixgbe_iosf_wait(hw, NULL);
  1224. if (ret)
  1225. goto out;
  1226. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  1227. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  1228. /* Write IOSF control register */
  1229. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  1230. /* Write IOSF data register */
  1231. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
  1232. ret = ixgbe_iosf_wait(hw, &command);
  1233. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  1234. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  1235. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  1236. hw_dbg(hw, "Failed to write, error %x\n", error);
  1237. return IXGBE_ERR_PHY;
  1238. }
  1239. out:
  1240. hw->mac.ops.release_swfw_sync(hw, gssr);
  1241. return ret;
  1242. }
  1243. /**
  1244. * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
  1245. * @hw: pointer to hardware structure
  1246. *
  1247. * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
  1248. **/
  1249. static s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
  1250. {
  1251. s32 status;
  1252. u32 reg_val;
  1253. /* Disable training protocol FSM. */
  1254. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1255. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1256. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1257. if (status)
  1258. return status;
  1259. reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
  1260. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1261. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1262. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1263. if (status)
  1264. return status;
  1265. /* Disable Flex from training TXFFE. */
  1266. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1267. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1268. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1269. if (status)
  1270. return status;
  1271. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1272. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1273. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1274. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1275. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1276. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1277. if (status)
  1278. return status;
  1279. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1280. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1281. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1282. if (status)
  1283. return status;
  1284. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1285. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1286. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1287. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1288. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1289. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1290. if (status)
  1291. return status;
  1292. /* Enable override for coefficients. */
  1293. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1294. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1295. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1296. if (status)
  1297. return status;
  1298. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
  1299. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
  1300. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
  1301. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
  1302. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1303. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1304. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1305. return status;
  1306. }
  1307. /**
  1308. * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
  1309. * internal PHY
  1310. * @hw: pointer to hardware structure
  1311. **/
  1312. static s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
  1313. {
  1314. s32 status;
  1315. u32 link_ctrl;
  1316. /* Restart auto-negotiation. */
  1317. status = hw->mac.ops.read_iosf_sb_reg(hw,
  1318. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1319. IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
  1320. if (status) {
  1321. hw_dbg(hw, "Auto-negotiation did not complete\n");
  1322. return status;
  1323. }
  1324. link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
  1325. status = hw->mac.ops.write_iosf_sb_reg(hw,
  1326. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1327. IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
  1328. if (hw->mac.type == ixgbe_mac_x550em_a) {
  1329. u32 flx_mask_st20;
  1330. /* Indicate to FW that AN restart has been asserted */
  1331. status = hw->mac.ops.read_iosf_sb_reg(hw,
  1332. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1333. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
  1334. if (status) {
  1335. hw_dbg(hw, "Auto-negotiation did not complete\n");
  1336. return status;
  1337. }
  1338. flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
  1339. status = hw->mac.ops.write_iosf_sb_reg(hw,
  1340. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1341. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
  1342. }
  1343. return status;
  1344. }
  1345. /** ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
  1346. * @hw: pointer to hardware structure
  1347. * @speed: the link speed to force
  1348. *
  1349. * Configures the integrated KR PHY to use iXFI mode. Used to connect an
  1350. * internal and external PHY at a specific speed, without autonegotiation.
  1351. **/
  1352. static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
  1353. {
  1354. struct ixgbe_mac_info *mac = &hw->mac;
  1355. s32 status;
  1356. u32 reg_val;
  1357. /* iXFI is only supported with X552 */
  1358. if (mac->type != ixgbe_mac_X550EM_x)
  1359. return IXGBE_ERR_LINK_SETUP;
  1360. /* Disable AN and force speed to 10G Serial. */
  1361. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1362. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1363. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1364. if (status)
  1365. return status;
  1366. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1367. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1368. /* Select forced link speed for internal PHY. */
  1369. switch (*speed) {
  1370. case IXGBE_LINK_SPEED_10GB_FULL:
  1371. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
  1372. break;
  1373. case IXGBE_LINK_SPEED_1GB_FULL:
  1374. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1375. break;
  1376. default:
  1377. /* Other link speeds are not supported by internal KR PHY. */
  1378. return IXGBE_ERR_LINK_SETUP;
  1379. }
  1380. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1381. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1382. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1383. if (status)
  1384. return status;
  1385. /* Additional configuration needed for x550em_x */
  1386. if (hw->mac.type == ixgbe_mac_X550EM_x) {
  1387. status = ixgbe_setup_ixfi_x550em_x(hw);
  1388. if (status)
  1389. return status;
  1390. }
  1391. /* Toggle port SW reset by AN reset. */
  1392. status = ixgbe_restart_an_internal_phy_x550em(hw);
  1393. return status;
  1394. }
  1395. /**
  1396. * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
  1397. * @hw: pointer to hardware structure
  1398. * @linear: true if SFP module is linear
  1399. */
  1400. static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
  1401. {
  1402. switch (hw->phy.sfp_type) {
  1403. case ixgbe_sfp_type_not_present:
  1404. return IXGBE_ERR_SFP_NOT_PRESENT;
  1405. case ixgbe_sfp_type_da_cu_core0:
  1406. case ixgbe_sfp_type_da_cu_core1:
  1407. *linear = true;
  1408. break;
  1409. case ixgbe_sfp_type_srlr_core0:
  1410. case ixgbe_sfp_type_srlr_core1:
  1411. case ixgbe_sfp_type_da_act_lmt_core0:
  1412. case ixgbe_sfp_type_da_act_lmt_core1:
  1413. case ixgbe_sfp_type_1g_sx_core0:
  1414. case ixgbe_sfp_type_1g_sx_core1:
  1415. case ixgbe_sfp_type_1g_lx_core0:
  1416. case ixgbe_sfp_type_1g_lx_core1:
  1417. *linear = false;
  1418. break;
  1419. case ixgbe_sfp_type_unknown:
  1420. case ixgbe_sfp_type_1g_cu_core0:
  1421. case ixgbe_sfp_type_1g_cu_core1:
  1422. default:
  1423. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1424. }
  1425. return 0;
  1426. }
  1427. /**
  1428. * ixgbe_setup_mac_link_sfp_x550em - Configure the KR PHY for SFP.
  1429. * @hw: pointer to hardware structure
  1430. *
  1431. * Configures the extern PHY and the integrated KR PHY for SFP support.
  1432. */
  1433. static s32
  1434. ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
  1435. ixgbe_link_speed speed,
  1436. __always_unused bool autoneg_wait_to_complete)
  1437. {
  1438. s32 status;
  1439. u16 reg_slice, reg_val;
  1440. bool setup_linear = false;
  1441. /* Check if SFP module is supported and linear */
  1442. status = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1443. /* If no SFP module present, then return success. Return success since
  1444. * there is no reason to configure CS4227 and SFP not present error is
  1445. * not accepted in the setup MAC link flow.
  1446. */
  1447. if (status == IXGBE_ERR_SFP_NOT_PRESENT)
  1448. return 0;
  1449. if (status)
  1450. return status;
  1451. /* Configure internal PHY for KR/KX. */
  1452. ixgbe_setup_kr_speed_x550em(hw, speed);
  1453. /* Configure CS4227 LINE side to proper mode. */
  1454. reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
  1455. if (setup_linear)
  1456. reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
  1457. else
  1458. reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
  1459. status = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
  1460. reg_val);
  1461. return status;
  1462. }
  1463. /**
  1464. * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
  1465. * @hw: pointer to hardware structure
  1466. * @speed: the link speed to force
  1467. *
  1468. * Configures the integrated PHY for native SFI mode. Used to connect the
  1469. * internal PHY directly to an SFP cage, without autonegotiation.
  1470. **/
  1471. static s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
  1472. {
  1473. struct ixgbe_mac_info *mac = &hw->mac;
  1474. s32 status;
  1475. u32 reg_val;
  1476. /* Disable all AN and force speed to 10G Serial. */
  1477. status = mac->ops.read_iosf_sb_reg(hw,
  1478. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1479. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1480. if (status)
  1481. return status;
  1482. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1483. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1484. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1485. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1486. /* Select forced link speed for internal PHY. */
  1487. switch (*speed) {
  1488. case IXGBE_LINK_SPEED_10GB_FULL:
  1489. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
  1490. break;
  1491. case IXGBE_LINK_SPEED_1GB_FULL:
  1492. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
  1493. break;
  1494. default:
  1495. /* Other link speeds are not supported by internal PHY. */
  1496. return IXGBE_ERR_LINK_SETUP;
  1497. }
  1498. status = mac->ops.write_iosf_sb_reg(hw,
  1499. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1500. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1501. /* Toggle port SW reset by AN reset. */
  1502. status = ixgbe_restart_an_internal_phy_x550em(hw);
  1503. return status;
  1504. }
  1505. /**
  1506. * ixgbe_setup_mac_link_sfp_n - Setup internal PHY for native SFP
  1507. * @hw: pointer to hardware structure
  1508. *
  1509. * Configure the the integrated PHY for native SFP support.
  1510. */
  1511. static s32
  1512. ixgbe_setup_mac_link_sfp_n(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1513. __always_unused bool autoneg_wait_to_complete)
  1514. {
  1515. bool setup_linear = false;
  1516. u32 reg_phy_int;
  1517. s32 ret_val;
  1518. /* Check if SFP module is supported and linear */
  1519. ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1520. /* If no SFP module present, then return success. Return success since
  1521. * SFP not present error is not excepted in the setup MAC link flow.
  1522. */
  1523. if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
  1524. return 0;
  1525. if (ret_val)
  1526. return ret_val;
  1527. /* Configure internal PHY for native SFI based on module type */
  1528. ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
  1529. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1530. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_phy_int);
  1531. if (ret_val)
  1532. return ret_val;
  1533. reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
  1534. if (!setup_linear)
  1535. reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
  1536. ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
  1537. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1538. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
  1539. if (ret_val)
  1540. return ret_val;
  1541. /* Setup SFI internal link. */
  1542. return ixgbe_setup_sfi_x550a(hw, &speed);
  1543. }
  1544. /**
  1545. * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
  1546. * @hw: pointer to hardware structure
  1547. *
  1548. * Configure the the integrated PHY for SFP support.
  1549. */
  1550. static s32
  1551. ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1552. __always_unused bool autoneg_wait_to_complete)
  1553. {
  1554. u32 reg_slice, slice_offset;
  1555. bool setup_linear = false;
  1556. u16 reg_phy_ext;
  1557. s32 ret_val;
  1558. /* Check if SFP module is supported and linear */
  1559. ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1560. /* If no SFP module present, then return success. Return success since
  1561. * SFP not present error is not excepted in the setup MAC link flow.
  1562. */
  1563. if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
  1564. return 0;
  1565. if (ret_val)
  1566. return ret_val;
  1567. /* Configure internal PHY for KR/KX. */
  1568. ixgbe_setup_kr_speed_x550em(hw, speed);
  1569. if (hw->phy.mdio.prtad == MDIO_PRTAD_NONE)
  1570. return IXGBE_ERR_PHY_ADDR_INVALID;
  1571. /* Get external PHY SKU id */
  1572. ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
  1573. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1574. if (ret_val)
  1575. return ret_val;
  1576. /* When configuring quad port CS4223, the MAC instance is part
  1577. * of the slice offset.
  1578. */
  1579. if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
  1580. slice_offset = (hw->bus.lan_id +
  1581. (hw->bus.instance_id << 1)) << 12;
  1582. else
  1583. slice_offset = hw->bus.lan_id << 12;
  1584. /* Configure CS4227/CS4223 LINE side to proper mode. */
  1585. reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
  1586. ret_val = hw->phy.ops.read_reg(hw, reg_slice,
  1587. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1588. if (ret_val)
  1589. return ret_val;
  1590. reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
  1591. (IXGBE_CS4227_EDC_MODE_SR << 1));
  1592. if (setup_linear)
  1593. reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
  1594. else
  1595. reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1596. ret_val = hw->phy.ops.write_reg(hw, reg_slice,
  1597. IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
  1598. if (ret_val)
  1599. return ret_val;
  1600. /* Flush previous write with a read */
  1601. return hw->phy.ops.read_reg(hw, reg_slice,
  1602. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1603. }
  1604. /**
  1605. * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
  1606. * @hw: pointer to hardware structure
  1607. * @speed: new link speed
  1608. * @autoneg_wait_to_complete: true when waiting for completion is needed
  1609. *
  1610. * Setup internal/external PHY link speed based on link speed, then set
  1611. * external PHY auto advertised link speed.
  1612. *
  1613. * Returns error status for any failure
  1614. **/
  1615. static s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
  1616. ixgbe_link_speed speed,
  1617. bool autoneg_wait)
  1618. {
  1619. s32 status;
  1620. ixgbe_link_speed force_speed;
  1621. /* Setup internal/external PHY link speed to iXFI (10G), unless
  1622. * only 1G is auto advertised then setup KX link.
  1623. */
  1624. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  1625. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  1626. else
  1627. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  1628. /* If X552 and internal link mode is XFI, then setup XFI internal link.
  1629. */
  1630. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  1631. !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
  1632. status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
  1633. if (status)
  1634. return status;
  1635. }
  1636. return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
  1637. }
  1638. /** ixgbe_check_link_t_X550em - Determine link and speed status
  1639. * @hw: pointer to hardware structure
  1640. * @speed: pointer to link speed
  1641. * @link_up: true when link is up
  1642. * @link_up_wait_to_complete: bool used to wait for link up or not
  1643. *
  1644. * Check that both the MAC and X557 external PHY have link.
  1645. **/
  1646. static s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw,
  1647. ixgbe_link_speed *speed,
  1648. bool *link_up,
  1649. bool link_up_wait_to_complete)
  1650. {
  1651. u32 status;
  1652. u16 i, autoneg_status;
  1653. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  1654. return IXGBE_ERR_CONFIG;
  1655. status = ixgbe_check_mac_link_generic(hw, speed, link_up,
  1656. link_up_wait_to_complete);
  1657. /* If check link fails or MAC link is not up, then return */
  1658. if (status || !(*link_up))
  1659. return status;
  1660. /* MAC link is up, so check external PHY link.
  1661. * Link status is latching low, and can only be used to detect link
  1662. * drop, and not the current status of the link without performing
  1663. * back-to-back reads.
  1664. */
  1665. for (i = 0; i < 2; i++) {
  1666. status = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  1667. &autoneg_status);
  1668. if (status)
  1669. return status;
  1670. }
  1671. /* If external PHY link is not up, then indicate link not up */
  1672. if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
  1673. *link_up = false;
  1674. return 0;
  1675. }
  1676. /**
  1677. * ixgbe_setup_sgmii - Set up link for sgmii
  1678. * @hw: pointer to hardware structure
  1679. */
  1680. static s32
  1681. ixgbe_setup_sgmii(struct ixgbe_hw *hw, __always_unused ixgbe_link_speed speed,
  1682. __always_unused bool autoneg_wait_to_complete)
  1683. {
  1684. struct ixgbe_mac_info *mac = &hw->mac;
  1685. u32 lval, sval, flx_val;
  1686. s32 rc;
  1687. rc = mac->ops.read_iosf_sb_reg(hw,
  1688. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1689. IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
  1690. if (rc)
  1691. return rc;
  1692. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1693. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1694. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
  1695. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
  1696. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1697. rc = mac->ops.write_iosf_sb_reg(hw,
  1698. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1699. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1700. if (rc)
  1701. return rc;
  1702. rc = mac->ops.read_iosf_sb_reg(hw,
  1703. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1704. IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
  1705. if (rc)
  1706. return rc;
  1707. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
  1708. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
  1709. rc = mac->ops.write_iosf_sb_reg(hw,
  1710. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1711. IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
  1712. if (rc)
  1713. return rc;
  1714. rc = mac->ops.read_iosf_sb_reg(hw,
  1715. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1716. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1717. if (rc)
  1718. return rc;
  1719. rc = mac->ops.read_iosf_sb_reg(hw,
  1720. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1721. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1722. if (rc)
  1723. return rc;
  1724. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1725. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
  1726. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1727. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1728. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1729. rc = mac->ops.write_iosf_sb_reg(hw,
  1730. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1731. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
  1732. if (rc)
  1733. return rc;
  1734. rc = ixgbe_restart_an_internal_phy_x550em(hw);
  1735. return rc;
  1736. }
  1737. /**
  1738. * ixgbe_setup_sgmii_fw - Set up link for sgmii with firmware-controlled PHYs
  1739. * @hw: pointer to hardware structure
  1740. */
  1741. static s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1742. bool autoneg_wait)
  1743. {
  1744. struct ixgbe_mac_info *mac = &hw->mac;
  1745. u32 lval, sval, flx_val;
  1746. s32 rc;
  1747. rc = mac->ops.read_iosf_sb_reg(hw,
  1748. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1749. IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
  1750. if (rc)
  1751. return rc;
  1752. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1753. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1754. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
  1755. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
  1756. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1757. rc = mac->ops.write_iosf_sb_reg(hw,
  1758. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1759. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1760. if (rc)
  1761. return rc;
  1762. rc = mac->ops.read_iosf_sb_reg(hw,
  1763. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1764. IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
  1765. if (rc)
  1766. return rc;
  1767. sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
  1768. sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
  1769. rc = mac->ops.write_iosf_sb_reg(hw,
  1770. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1771. IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
  1772. if (rc)
  1773. return rc;
  1774. rc = mac->ops.write_iosf_sb_reg(hw,
  1775. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1776. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1777. if (rc)
  1778. return rc;
  1779. rc = mac->ops.read_iosf_sb_reg(hw,
  1780. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1781. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1782. if (rc)
  1783. return rc;
  1784. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1785. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
  1786. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1787. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1788. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1789. rc = mac->ops.write_iosf_sb_reg(hw,
  1790. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1791. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
  1792. if (rc)
  1793. return rc;
  1794. ixgbe_restart_an_internal_phy_x550em(hw);
  1795. return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
  1796. }
  1797. /**
  1798. * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
  1799. * @hw: pointer to hardware structure
  1800. *
  1801. * Enable flow control according to IEEE clause 37.
  1802. */
  1803. static void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
  1804. {
  1805. s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  1806. u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
  1807. ixgbe_link_speed speed;
  1808. bool link_up;
  1809. /* AN should have completed when the cable was plugged in.
  1810. * Look for reasons to bail out. Bail out if:
  1811. * - FC autoneg is disabled, or if
  1812. * - link is not up.
  1813. */
  1814. if (hw->fc.disable_fc_autoneg)
  1815. goto out;
  1816. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  1817. if (!link_up)
  1818. goto out;
  1819. /* Check if auto-negotiation has completed */
  1820. status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
  1821. if (status || !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
  1822. status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  1823. goto out;
  1824. }
  1825. /* Negotiate the flow control */
  1826. status = ixgbe_negotiate_fc(hw, info[0], info[0],
  1827. FW_PHY_ACT_GET_LINK_INFO_FC_RX,
  1828. FW_PHY_ACT_GET_LINK_INFO_FC_TX,
  1829. FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
  1830. FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
  1831. out:
  1832. if (!status) {
  1833. hw->fc.fc_was_autonegged = true;
  1834. } else {
  1835. hw->fc.fc_was_autonegged = false;
  1836. hw->fc.current_mode = hw->fc.requested_mode;
  1837. }
  1838. }
  1839. /** ixgbe_init_mac_link_ops_X550em_a - Init mac link function pointers
  1840. * @hw: pointer to hardware structure
  1841. **/
  1842. static void ixgbe_init_mac_link_ops_X550em_a(struct ixgbe_hw *hw)
  1843. {
  1844. struct ixgbe_mac_info *mac = &hw->mac;
  1845. switch (mac->ops.get_media_type(hw)) {
  1846. case ixgbe_media_type_fiber:
  1847. mac->ops.setup_fc = NULL;
  1848. mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
  1849. break;
  1850. case ixgbe_media_type_copper:
  1851. if (hw->device_id != IXGBE_DEV_ID_X550EM_A_1G_T &&
  1852. hw->device_id != IXGBE_DEV_ID_X550EM_A_1G_T_L) {
  1853. mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
  1854. break;
  1855. }
  1856. mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
  1857. mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
  1858. mac->ops.setup_link = ixgbe_setup_sgmii_fw;
  1859. mac->ops.check_link = ixgbe_check_mac_link_generic;
  1860. break;
  1861. case ixgbe_media_type_backplane:
  1862. mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
  1863. mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
  1864. break;
  1865. default:
  1866. break;
  1867. }
  1868. }
  1869. /** ixgbe_init_mac_link_ops_X550em - init mac link function pointers
  1870. * @hw: pointer to hardware structure
  1871. **/
  1872. static void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
  1873. {
  1874. struct ixgbe_mac_info *mac = &hw->mac;
  1875. mac->ops.setup_fc = ixgbe_setup_fc_x550em;
  1876. switch (mac->ops.get_media_type(hw)) {
  1877. case ixgbe_media_type_fiber:
  1878. /* CS4227 does not support autoneg, so disable the laser control
  1879. * functions for SFP+ fiber
  1880. */
  1881. mac->ops.disable_tx_laser = NULL;
  1882. mac->ops.enable_tx_laser = NULL;
  1883. mac->ops.flap_tx_laser = NULL;
  1884. mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
  1885. switch (hw->device_id) {
  1886. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  1887. mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_n;
  1888. break;
  1889. case IXGBE_DEV_ID_X550EM_A_SFP:
  1890. mac->ops.setup_mac_link =
  1891. ixgbe_setup_mac_link_sfp_x550a;
  1892. break;
  1893. default:
  1894. mac->ops.setup_mac_link =
  1895. ixgbe_setup_mac_link_sfp_x550em;
  1896. break;
  1897. }
  1898. mac->ops.set_rate_select_speed =
  1899. ixgbe_set_soft_rate_select_speed;
  1900. break;
  1901. case ixgbe_media_type_copper:
  1902. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
  1903. break;
  1904. mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
  1905. mac->ops.setup_fc = ixgbe_setup_fc_generic;
  1906. mac->ops.check_link = ixgbe_check_link_t_X550em;
  1907. break;
  1908. case ixgbe_media_type_backplane:
  1909. if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
  1910. hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
  1911. mac->ops.setup_link = ixgbe_setup_sgmii;
  1912. break;
  1913. default:
  1914. break;
  1915. }
  1916. /* Additional modification for X550em_a devices */
  1917. if (hw->mac.type == ixgbe_mac_x550em_a)
  1918. ixgbe_init_mac_link_ops_X550em_a(hw);
  1919. }
  1920. /** ixgbe_setup_sfp_modules_X550em - Setup SFP module
  1921. * @hw: pointer to hardware structure
  1922. */
  1923. static s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  1924. {
  1925. s32 status;
  1926. bool linear;
  1927. /* Check if SFP module is supported */
  1928. status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
  1929. if (status)
  1930. return status;
  1931. ixgbe_init_mac_link_ops_X550em(hw);
  1932. hw->phy.ops.reset = NULL;
  1933. return 0;
  1934. }
  1935. /** ixgbe_get_link_capabilities_x550em - Determines link capabilities
  1936. * @hw: pointer to hardware structure
  1937. * @speed: pointer to link speed
  1938. * @autoneg: true when autoneg or autotry is enabled
  1939. **/
  1940. static s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
  1941. ixgbe_link_speed *speed,
  1942. bool *autoneg)
  1943. {
  1944. if (hw->phy.type == ixgbe_phy_fw) {
  1945. *autoneg = true;
  1946. *speed = hw->phy.speeds_supported;
  1947. return 0;
  1948. }
  1949. /* SFP */
  1950. if (hw->phy.media_type == ixgbe_media_type_fiber) {
  1951. /* CS4227 SFP must not enable auto-negotiation */
  1952. *autoneg = false;
  1953. if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  1954. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
  1955. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1956. return 0;
  1957. }
  1958. /* Link capabilities are based on SFP */
  1959. if (hw->phy.multispeed_fiber)
  1960. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1961. IXGBE_LINK_SPEED_1GB_FULL;
  1962. else
  1963. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  1964. } else {
  1965. switch (hw->phy.type) {
  1966. case ixgbe_phy_x550em_kx4:
  1967. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1968. IXGBE_LINK_SPEED_2_5GB_FULL |
  1969. IXGBE_LINK_SPEED_10GB_FULL;
  1970. break;
  1971. case ixgbe_phy_x550em_xfi:
  1972. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1973. IXGBE_LINK_SPEED_10GB_FULL;
  1974. break;
  1975. case ixgbe_phy_ext_1g_t:
  1976. case ixgbe_phy_sgmii:
  1977. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1978. break;
  1979. case ixgbe_phy_x550em_kr:
  1980. if (hw->mac.type == ixgbe_mac_x550em_a) {
  1981. /* check different backplane modes */
  1982. if (hw->phy.nw_mng_if_sel &
  1983. IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
  1984. *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
  1985. break;
  1986. } else if (hw->device_id ==
  1987. IXGBE_DEV_ID_X550EM_A_KR_L) {
  1988. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1989. break;
  1990. }
  1991. }
  1992. /* fall through */
  1993. default:
  1994. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1995. IXGBE_LINK_SPEED_1GB_FULL;
  1996. break;
  1997. }
  1998. *autoneg = true;
  1999. }
  2000. return 0;
  2001. }
  2002. /**
  2003. * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
  2004. * @hw: pointer to hardware structure
  2005. * @lsc: pointer to boolean flag which indicates whether external Base T
  2006. * PHY interrupt is lsc
  2007. *
  2008. * Determime if external Base T PHY interrupt cause is high temperature
  2009. * failure alarm or link status change.
  2010. *
  2011. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2012. * failure alarm, else return PHY access status.
  2013. **/
  2014. static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  2015. {
  2016. u32 status;
  2017. u16 reg;
  2018. *lsc = false;
  2019. /* Vendor alarm triggered */
  2020. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2021. MDIO_MMD_VEND1,
  2022. &reg);
  2023. if (status || !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
  2024. return status;
  2025. /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
  2026. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
  2027. MDIO_MMD_VEND1,
  2028. &reg);
  2029. if (status || !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2030. IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
  2031. return status;
  2032. /* Global alarm triggered */
  2033. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
  2034. MDIO_MMD_VEND1,
  2035. &reg);
  2036. if (status)
  2037. return status;
  2038. /* If high temperature failure, then return over temp error and exit */
  2039. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
  2040. /* power down the PHY in case the PHY FW didn't already */
  2041. ixgbe_set_copper_phy_power(hw, false);
  2042. return IXGBE_ERR_OVERTEMP;
  2043. }
  2044. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
  2045. /* device fault alarm triggered */
  2046. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
  2047. MDIO_MMD_VEND1,
  2048. &reg);
  2049. if (status)
  2050. return status;
  2051. /* if device fault was due to high temp alarm handle and exit */
  2052. if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
  2053. /* power down the PHY in case the PHY FW didn't */
  2054. ixgbe_set_copper_phy_power(hw, false);
  2055. return IXGBE_ERR_OVERTEMP;
  2056. }
  2057. }
  2058. /* Vendor alarm 2 triggered */
  2059. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2060. MDIO_MMD_AN, &reg);
  2061. if (status || !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
  2062. return status;
  2063. /* link connect/disconnect event occurred */
  2064. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
  2065. MDIO_MMD_AN, &reg);
  2066. if (status)
  2067. return status;
  2068. /* Indicate LSC */
  2069. if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
  2070. *lsc = true;
  2071. return 0;
  2072. }
  2073. /**
  2074. * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
  2075. * @hw: pointer to hardware structure
  2076. *
  2077. * Enable link status change and temperature failure alarm for the external
  2078. * Base T PHY
  2079. *
  2080. * Returns PHY access status
  2081. **/
  2082. static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2083. {
  2084. u32 status;
  2085. u16 reg;
  2086. bool lsc;
  2087. /* Clear interrupt flags */
  2088. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2089. /* Enable link status change alarm */
  2090. /* Enable the LASI interrupts on X552 devices to receive notifications
  2091. * of the link configurations of the external PHY and correspondingly
  2092. * support the configuration of the internal iXFI link, since iXFI does
  2093. * not support auto-negotiation. This is not required for X553 devices
  2094. * having KR support, which performs auto-negotiations and which is used
  2095. * as the internal link to the external PHY. Hence adding a check here
  2096. * to avoid enabling LASI interrupts for X553 devices.
  2097. */
  2098. if (hw->mac.type != ixgbe_mac_x550em_a) {
  2099. status = hw->phy.ops.read_reg(hw,
  2100. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2101. MDIO_MMD_AN, &reg);
  2102. if (status)
  2103. return status;
  2104. reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
  2105. status = hw->phy.ops.write_reg(hw,
  2106. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2107. MDIO_MMD_AN, reg);
  2108. if (status)
  2109. return status;
  2110. }
  2111. /* Enable high temperature failure and global fault alarms */
  2112. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2113. MDIO_MMD_VEND1,
  2114. &reg);
  2115. if (status)
  2116. return status;
  2117. reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
  2118. IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
  2119. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2120. MDIO_MMD_VEND1,
  2121. reg);
  2122. if (status)
  2123. return status;
  2124. /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
  2125. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2126. MDIO_MMD_VEND1,
  2127. &reg);
  2128. if (status)
  2129. return status;
  2130. reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2131. IXGBE_MDIO_GLOBAL_ALARM_1_INT);
  2132. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2133. MDIO_MMD_VEND1,
  2134. reg);
  2135. if (status)
  2136. return status;
  2137. /* Enable chip-wide vendor alarm */
  2138. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2139. MDIO_MMD_VEND1,
  2140. &reg);
  2141. if (status)
  2142. return status;
  2143. reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
  2144. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2145. MDIO_MMD_VEND1,
  2146. reg);
  2147. return status;
  2148. }
  2149. /**
  2150. * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  2151. * @hw: pointer to hardware structure
  2152. *
  2153. * Handle external Base T PHY interrupt. If high temperature
  2154. * failure alarm then return error, else if link status change
  2155. * then setup internal/external PHY link
  2156. *
  2157. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2158. * failure alarm, else return PHY access status.
  2159. **/
  2160. static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2161. {
  2162. struct ixgbe_phy_info *phy = &hw->phy;
  2163. bool lsc;
  2164. u32 status;
  2165. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2166. if (status)
  2167. return status;
  2168. if (lsc && phy->ops.setup_internal_link)
  2169. return phy->ops.setup_internal_link(hw);
  2170. return 0;
  2171. }
  2172. /**
  2173. * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
  2174. * @hw: pointer to hardware structure
  2175. * @speed: link speed
  2176. *
  2177. * Configures the integrated KR PHY.
  2178. **/
  2179. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
  2180. ixgbe_link_speed speed)
  2181. {
  2182. s32 status;
  2183. u32 reg_val;
  2184. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2185. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2186. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2187. if (status)
  2188. return status;
  2189. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  2190. reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
  2191. IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
  2192. /* Advertise 10G support. */
  2193. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  2194. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
  2195. /* Advertise 1G support. */
  2196. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  2197. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
  2198. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2199. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2200. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2201. if (hw->mac.type == ixgbe_mac_x550em_a) {
  2202. /* Set lane mode to KR auto negotiation */
  2203. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2204. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2205. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2206. if (status)
  2207. return status;
  2208. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  2209. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
  2210. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  2211. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  2212. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  2213. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2214. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2215. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2216. }
  2217. return ixgbe_restart_an_internal_phy_x550em(hw);
  2218. }
  2219. /**
  2220. * ixgbe_setup_kr_x550em - Configure the KR PHY
  2221. * @hw: pointer to hardware structure
  2222. **/
  2223. static s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
  2224. {
  2225. /* leave link alone for 2.5G */
  2226. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
  2227. return 0;
  2228. if (ixgbe_check_reset_blocked(hw))
  2229. return 0;
  2230. return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
  2231. }
  2232. /** ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
  2233. * @hw: address of hardware structure
  2234. * @link_up: address of boolean to indicate link status
  2235. *
  2236. * Returns error code if unable to get link status.
  2237. **/
  2238. static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
  2239. {
  2240. u32 ret;
  2241. u16 autoneg_status;
  2242. *link_up = false;
  2243. /* read this twice back to back to indicate current status */
  2244. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2245. &autoneg_status);
  2246. if (ret)
  2247. return ret;
  2248. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2249. &autoneg_status);
  2250. if (ret)
  2251. return ret;
  2252. *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
  2253. return 0;
  2254. }
  2255. /** ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
  2256. * @hw: point to hardware structure
  2257. *
  2258. * Configures the link between the integrated KR PHY and the external X557 PHY
  2259. * The driver will call this function when it gets a link status change
  2260. * interrupt from the X557 PHY. This function configures the link speed
  2261. * between the PHYs to match the link speed of the BASE-T link.
  2262. *
  2263. * A return of a non-zero value indicates an error, and the base driver should
  2264. * not report link up.
  2265. **/
  2266. static s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
  2267. {
  2268. ixgbe_link_speed force_speed;
  2269. bool link_up;
  2270. u32 status;
  2271. u16 speed;
  2272. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  2273. return IXGBE_ERR_CONFIG;
  2274. if (!(hw->mac.type == ixgbe_mac_X550EM_x &&
  2275. !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))) {
  2276. speed = IXGBE_LINK_SPEED_10GB_FULL |
  2277. IXGBE_LINK_SPEED_1GB_FULL;
  2278. return ixgbe_setup_kr_speed_x550em(hw, speed);
  2279. }
  2280. /* If link is not up, then there is no setup necessary so return */
  2281. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2282. if (status)
  2283. return status;
  2284. if (!link_up)
  2285. return 0;
  2286. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2287. MDIO_MMD_AN,
  2288. &speed);
  2289. if (status)
  2290. return status;
  2291. /* If link is not still up, then no setup is necessary so return */
  2292. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2293. if (status)
  2294. return status;
  2295. if (!link_up)
  2296. return 0;
  2297. /* clear everything but the speed and duplex bits */
  2298. speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
  2299. switch (speed) {
  2300. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
  2301. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2302. break;
  2303. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
  2304. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2305. break;
  2306. default:
  2307. /* Internal PHY does not support anything else */
  2308. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2309. }
  2310. return ixgbe_setup_ixfi_x550em(hw, &force_speed);
  2311. }
  2312. /** ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
  2313. * @hw: pointer to hardware structure
  2314. **/
  2315. static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
  2316. {
  2317. s32 status;
  2318. status = ixgbe_reset_phy_generic(hw);
  2319. if (status)
  2320. return status;
  2321. /* Configure Link Status Alarm and Temperature Threshold interrupts */
  2322. return ixgbe_enable_lasi_ext_t_x550em(hw);
  2323. }
  2324. /**
  2325. * ixgbe_led_on_t_x550em - Turns on the software controllable LEDs.
  2326. * @hw: pointer to hardware structure
  2327. * @led_idx: led number to turn on
  2328. **/
  2329. static s32 ixgbe_led_on_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2330. {
  2331. u16 phy_data;
  2332. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2333. return IXGBE_ERR_PARAM;
  2334. /* To turn on the LED, set mode to ON. */
  2335. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2336. MDIO_MMD_VEND1, &phy_data);
  2337. phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
  2338. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2339. MDIO_MMD_VEND1, phy_data);
  2340. return 0;
  2341. }
  2342. /**
  2343. * ixgbe_led_off_t_x550em - Turns off the software controllable LEDs.
  2344. * @hw: pointer to hardware structure
  2345. * @led_idx: led number to turn off
  2346. **/
  2347. static s32 ixgbe_led_off_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2348. {
  2349. u16 phy_data;
  2350. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2351. return IXGBE_ERR_PARAM;
  2352. /* To turn on the LED, set mode to ON. */
  2353. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2354. MDIO_MMD_VEND1, &phy_data);
  2355. phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
  2356. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2357. MDIO_MMD_VEND1, phy_data);
  2358. return 0;
  2359. }
  2360. /**
  2361. * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
  2362. * @hw: pointer to the HW structure
  2363. * @maj: driver version major number
  2364. * @min: driver version minor number
  2365. * @build: driver version build number
  2366. * @sub: driver version sub build number
  2367. * @len: length of driver_ver string
  2368. * @driver_ver: driver string
  2369. *
  2370. * Sends driver version number to firmware through the manageability
  2371. * block. On success return 0
  2372. * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
  2373. * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  2374. **/
  2375. static s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
  2376. u8 build, u8 sub, u16 len,
  2377. const char *driver_ver)
  2378. {
  2379. struct ixgbe_hic_drv_info2 fw_cmd;
  2380. s32 ret_val;
  2381. int i;
  2382. if (!len || !driver_ver || (len > sizeof(fw_cmd.driver_string)))
  2383. return IXGBE_ERR_INVALID_ARGUMENT;
  2384. fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
  2385. fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
  2386. fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
  2387. fw_cmd.port_num = (u8)hw->bus.func;
  2388. fw_cmd.ver_maj = maj;
  2389. fw_cmd.ver_min = min;
  2390. fw_cmd.ver_build = build;
  2391. fw_cmd.ver_sub = sub;
  2392. fw_cmd.hdr.checksum = 0;
  2393. memcpy(fw_cmd.driver_string, driver_ver, len);
  2394. fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
  2395. (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
  2396. for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
  2397. ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
  2398. sizeof(fw_cmd),
  2399. IXGBE_HI_COMMAND_TIMEOUT,
  2400. true);
  2401. if (ret_val)
  2402. continue;
  2403. if (fw_cmd.hdr.cmd_or_resp.ret_status !=
  2404. FW_CEM_RESP_STATUS_SUCCESS)
  2405. return IXGBE_ERR_HOST_INTERFACE_COMMAND;
  2406. return 0;
  2407. }
  2408. return ret_val;
  2409. }
  2410. /** ixgbe_get_lcd_x550em - Determine lowest common denominator
  2411. * @hw: pointer to hardware structure
  2412. * @lcd_speed: pointer to lowest common link speed
  2413. *
  2414. * Determine lowest common link speed with link partner.
  2415. **/
  2416. static s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw,
  2417. ixgbe_link_speed *lcd_speed)
  2418. {
  2419. u16 an_lp_status;
  2420. s32 status;
  2421. u16 word = hw->eeprom.ctrl_word_3;
  2422. *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
  2423. status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
  2424. MDIO_MMD_AN,
  2425. &an_lp_status);
  2426. if (status)
  2427. return status;
  2428. /* If link partner advertised 1G, return 1G */
  2429. if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
  2430. *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2431. return status;
  2432. }
  2433. /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
  2434. if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
  2435. (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
  2436. return status;
  2437. /* Link partner not capable of lower speeds, return 10G */
  2438. *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2439. return status;
  2440. }
  2441. /**
  2442. * ixgbe_setup_fc_x550em - Set up flow control
  2443. * @hw: pointer to hardware structure
  2444. */
  2445. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *hw)
  2446. {
  2447. bool pause, asm_dir;
  2448. u32 reg_val;
  2449. s32 rc = 0;
  2450. /* Validate the requested mode */
  2451. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  2452. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  2453. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2454. }
  2455. /* 10gig parts do not have a word in the EEPROM to determine the
  2456. * default flow control setting, so we explicitly set it to full.
  2457. */
  2458. if (hw->fc.requested_mode == ixgbe_fc_default)
  2459. hw->fc.requested_mode = ixgbe_fc_full;
  2460. /* Determine PAUSE and ASM_DIR bits. */
  2461. switch (hw->fc.requested_mode) {
  2462. case ixgbe_fc_none:
  2463. pause = false;
  2464. asm_dir = false;
  2465. break;
  2466. case ixgbe_fc_tx_pause:
  2467. pause = false;
  2468. asm_dir = true;
  2469. break;
  2470. case ixgbe_fc_rx_pause:
  2471. /* Rx Flow control is enabled and Tx Flow control is
  2472. * disabled by software override. Since there really
  2473. * isn't a way to advertise that we are capable of RX
  2474. * Pause ONLY, we will advertise that we support both
  2475. * symmetric and asymmetric Rx PAUSE, as such we fall
  2476. * through to the fc_full statement. Later, we will
  2477. * disable the adapter's ability to send PAUSE frames.
  2478. */
  2479. /* Fallthrough */
  2480. case ixgbe_fc_full:
  2481. pause = true;
  2482. asm_dir = true;
  2483. break;
  2484. default:
  2485. hw_err(hw, "Flow control param set incorrectly\n");
  2486. return IXGBE_ERR_CONFIG;
  2487. }
  2488. switch (hw->device_id) {
  2489. case IXGBE_DEV_ID_X550EM_X_KR:
  2490. case IXGBE_DEV_ID_X550EM_A_KR:
  2491. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2492. rc = hw->mac.ops.read_iosf_sb_reg(hw,
  2493. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2494. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2495. &reg_val);
  2496. if (rc)
  2497. return rc;
  2498. reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  2499. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  2500. if (pause)
  2501. reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  2502. if (asm_dir)
  2503. reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  2504. rc = hw->mac.ops.write_iosf_sb_reg(hw,
  2505. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2506. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2507. reg_val);
  2508. /* This device does not fully support AN. */
  2509. hw->fc.disable_fc_autoneg = true;
  2510. break;
  2511. case IXGBE_DEV_ID_X550EM_X_XFI:
  2512. hw->fc.disable_fc_autoneg = true;
  2513. break;
  2514. default:
  2515. break;
  2516. }
  2517. return rc;
  2518. }
  2519. /**
  2520. * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
  2521. * @hw: pointer to hardware structure
  2522. **/
  2523. static void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
  2524. {
  2525. u32 link_s1, lp_an_page_low, an_cntl_1;
  2526. s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2527. ixgbe_link_speed speed;
  2528. bool link_up;
  2529. /* AN should have completed when the cable was plugged in.
  2530. * Look for reasons to bail out. Bail out if:
  2531. * - FC autoneg is disabled, or if
  2532. * - link is not up.
  2533. */
  2534. if (hw->fc.disable_fc_autoneg) {
  2535. hw_err(hw, "Flow control autoneg is disabled");
  2536. goto out;
  2537. }
  2538. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  2539. if (!link_up) {
  2540. hw_err(hw, "The link is down");
  2541. goto out;
  2542. }
  2543. /* Check at auto-negotiation has completed */
  2544. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2545. IXGBE_KRM_LINK_S1(hw->bus.lan_id),
  2546. IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
  2547. if (status || (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
  2548. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2549. status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2550. goto out;
  2551. }
  2552. /* Read the 10g AN autoc and LP ability registers and resolve
  2553. * local flow control settings accordingly
  2554. */
  2555. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2556. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2557. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
  2558. if (status) {
  2559. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2560. goto out;
  2561. }
  2562. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2563. IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
  2564. IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
  2565. if (status) {
  2566. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2567. goto out;
  2568. }
  2569. status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
  2570. IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
  2571. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
  2572. IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
  2573. IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
  2574. out:
  2575. if (!status) {
  2576. hw->fc.fc_was_autonegged = true;
  2577. } else {
  2578. hw->fc.fc_was_autonegged = false;
  2579. hw->fc.current_mode = hw->fc.requested_mode;
  2580. }
  2581. }
  2582. /**
  2583. * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
  2584. * @hw: pointer to hardware structure
  2585. **/
  2586. static void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
  2587. {
  2588. hw->fc.fc_was_autonegged = false;
  2589. hw->fc.current_mode = hw->fc.requested_mode;
  2590. }
  2591. /** ixgbe_enter_lplu_x550em - Transition to low power states
  2592. * @hw: pointer to hardware structure
  2593. *
  2594. * Configures Low Power Link Up on transition to low power states
  2595. * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting
  2596. * the X557 PHY immediately prior to entering LPLU.
  2597. **/
  2598. static s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
  2599. {
  2600. u16 an_10g_cntl_reg, autoneg_reg, speed;
  2601. s32 status;
  2602. ixgbe_link_speed lcd_speed;
  2603. u32 save_autoneg;
  2604. bool link_up;
  2605. /* If blocked by MNG FW, then don't restart AN */
  2606. if (ixgbe_check_reset_blocked(hw))
  2607. return 0;
  2608. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2609. if (status)
  2610. return status;
  2611. status = hw->eeprom.ops.read(hw, NVM_INIT_CTRL_3,
  2612. &hw->eeprom.ctrl_word_3);
  2613. if (status)
  2614. return status;
  2615. /* If link is down, LPLU disabled in NVM, WoL disabled, or
  2616. * manageability disabled, then force link down by entering
  2617. * low power mode.
  2618. */
  2619. if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
  2620. !(hw->wol_enabled || ixgbe_mng_present(hw)))
  2621. return ixgbe_set_copper_phy_power(hw, false);
  2622. /* Determine LCD */
  2623. status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
  2624. if (status)
  2625. return status;
  2626. /* If no valid LCD link speed, then force link down and exit. */
  2627. if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
  2628. return ixgbe_set_copper_phy_power(hw, false);
  2629. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2630. MDIO_MMD_AN,
  2631. &speed);
  2632. if (status)
  2633. return status;
  2634. /* If no link now, speed is invalid so take link down */
  2635. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2636. if (status)
  2637. return ixgbe_set_copper_phy_power(hw, false);
  2638. /* clear everything but the speed bits */
  2639. speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
  2640. /* If current speed is already LCD, then exit. */
  2641. if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
  2642. (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
  2643. ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
  2644. (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
  2645. return status;
  2646. /* Clear AN completed indication */
  2647. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
  2648. MDIO_MMD_AN,
  2649. &autoneg_reg);
  2650. if (status)
  2651. return status;
  2652. status = hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL,
  2653. MDIO_MMD_AN,
  2654. &an_10g_cntl_reg);
  2655. if (status)
  2656. return status;
  2657. status = hw->phy.ops.read_reg(hw,
  2658. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  2659. MDIO_MMD_AN,
  2660. &autoneg_reg);
  2661. if (status)
  2662. return status;
  2663. save_autoneg = hw->phy.autoneg_advertised;
  2664. /* Setup link at least common link speed */
  2665. status = hw->mac.ops.setup_link(hw, lcd_speed, false);
  2666. /* restore autoneg from before setting lplu speed */
  2667. hw->phy.autoneg_advertised = save_autoneg;
  2668. return status;
  2669. }
  2670. /**
  2671. * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
  2672. * @hw: pointer to hardware structure
  2673. */
  2674. static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
  2675. {
  2676. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2677. s32 rc;
  2678. if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
  2679. return 0;
  2680. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
  2681. if (rc)
  2682. return rc;
  2683. memset(store, 0, sizeof(store));
  2684. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
  2685. if (rc)
  2686. return rc;
  2687. return ixgbe_setup_fw_link(hw);
  2688. }
  2689. /**
  2690. * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
  2691. * @hw: pointer to hardware structure
  2692. */
  2693. static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
  2694. {
  2695. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2696. s32 rc;
  2697. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
  2698. if (rc)
  2699. return rc;
  2700. if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
  2701. ixgbe_shutdown_fw_phy(hw);
  2702. return IXGBE_ERR_OVERTEMP;
  2703. }
  2704. return 0;
  2705. }
  2706. /**
  2707. * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
  2708. * @hw: pointer to hardware structure
  2709. *
  2710. * Read NW_MNG_IF_SEL register and save field values.
  2711. */
  2712. static void ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
  2713. {
  2714. /* Save NW management interface connected on board. This is used
  2715. * to determine internal PHY mode.
  2716. */
  2717. hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2718. /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
  2719. * PHY address. This register field was has only been used for X552.
  2720. */
  2721. if (hw->mac.type == ixgbe_mac_x550em_a &&
  2722. hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
  2723. hw->phy.mdio.prtad = (hw->phy.nw_mng_if_sel &
  2724. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
  2725. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
  2726. }
  2727. }
  2728. /** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  2729. * @hw: pointer to hardware structure
  2730. *
  2731. * Initialize any function pointers that were not able to be
  2732. * set during init_shared_code because the PHY/SFP type was
  2733. * not known. Perform the SFP init if necessary.
  2734. **/
  2735. static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
  2736. {
  2737. struct ixgbe_phy_info *phy = &hw->phy;
  2738. s32 ret_val;
  2739. hw->mac.ops.set_lan_id(hw);
  2740. ixgbe_read_mng_if_sel_x550em(hw);
  2741. if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
  2742. phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  2743. ixgbe_setup_mux_ctl(hw);
  2744. }
  2745. /* Identify the PHY or SFP module */
  2746. ret_val = phy->ops.identify(hw);
  2747. if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2748. ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
  2749. return ret_val;
  2750. /* Setup function pointers based on detected hardware */
  2751. ixgbe_init_mac_link_ops_X550em(hw);
  2752. if (phy->sfp_type != ixgbe_sfp_type_unknown)
  2753. phy->ops.reset = NULL;
  2754. /* Set functions pointers based on phy type */
  2755. switch (hw->phy.type) {
  2756. case ixgbe_phy_x550em_kx4:
  2757. phy->ops.setup_link = NULL;
  2758. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2759. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2760. break;
  2761. case ixgbe_phy_x550em_kr:
  2762. phy->ops.setup_link = ixgbe_setup_kr_x550em;
  2763. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2764. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2765. break;
  2766. case ixgbe_phy_x550em_xfi:
  2767. /* link is managed by HW */
  2768. phy->ops.setup_link = NULL;
  2769. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2770. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2771. break;
  2772. case ixgbe_phy_x550em_ext_t:
  2773. /* Save NW management interface connected on board. This is used
  2774. * to determine internal PHY mode
  2775. */
  2776. phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2777. /* If internal link mode is XFI, then setup iXFI internal link,
  2778. * else setup KR now.
  2779. */
  2780. phy->ops.setup_internal_link =
  2781. ixgbe_setup_internal_phy_t_x550em;
  2782. /* setup SW LPLU only for first revision */
  2783. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  2784. !(IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)) &
  2785. IXGBE_FUSES0_REV_MASK))
  2786. phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
  2787. phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
  2788. phy->ops.reset = ixgbe_reset_phy_t_X550em;
  2789. break;
  2790. case ixgbe_phy_sgmii:
  2791. phy->ops.setup_link = NULL;
  2792. break;
  2793. case ixgbe_phy_fw:
  2794. phy->ops.setup_link = ixgbe_setup_fw_link;
  2795. phy->ops.reset = ixgbe_reset_phy_fw;
  2796. break;
  2797. case ixgbe_phy_ext_1g_t:
  2798. phy->ops.setup_link = NULL;
  2799. phy->ops.read_reg = NULL;
  2800. phy->ops.write_reg = NULL;
  2801. phy->ops.reset = NULL;
  2802. break;
  2803. default:
  2804. break;
  2805. }
  2806. return ret_val;
  2807. }
  2808. /** ixgbe_get_media_type_X550em - Get media type
  2809. * @hw: pointer to hardware structure
  2810. *
  2811. * Returns the media type (fiber, copper, backplane)
  2812. *
  2813. */
  2814. static enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
  2815. {
  2816. enum ixgbe_media_type media_type;
  2817. /* Detect if there is a copper PHY attached. */
  2818. switch (hw->device_id) {
  2819. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2820. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2821. hw->phy.type = ixgbe_phy_sgmii;
  2822. /* Fallthrough */
  2823. case IXGBE_DEV_ID_X550EM_X_KR:
  2824. case IXGBE_DEV_ID_X550EM_X_KX4:
  2825. case IXGBE_DEV_ID_X550EM_X_XFI:
  2826. case IXGBE_DEV_ID_X550EM_A_KR:
  2827. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2828. media_type = ixgbe_media_type_backplane;
  2829. break;
  2830. case IXGBE_DEV_ID_X550EM_X_SFP:
  2831. case IXGBE_DEV_ID_X550EM_A_SFP:
  2832. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  2833. media_type = ixgbe_media_type_fiber;
  2834. break;
  2835. case IXGBE_DEV_ID_X550EM_X_1G_T:
  2836. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2837. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2838. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2839. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2840. media_type = ixgbe_media_type_copper;
  2841. break;
  2842. default:
  2843. media_type = ixgbe_media_type_unknown;
  2844. break;
  2845. }
  2846. return media_type;
  2847. }
  2848. /** ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
  2849. ** @hw: pointer to hardware structure
  2850. **/
  2851. static s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  2852. {
  2853. s32 status;
  2854. u16 reg;
  2855. status = hw->phy.ops.read_reg(hw,
  2856. IXGBE_MDIO_TX_VENDOR_ALARMS_3,
  2857. MDIO_MMD_PMAPMD,
  2858. &reg);
  2859. if (status)
  2860. return status;
  2861. /* If PHY FW reset completed bit is set then this is the first
  2862. * SW instance after a power on so the PHY FW must be un-stalled.
  2863. */
  2864. if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
  2865. status = hw->phy.ops.read_reg(hw,
  2866. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2867. MDIO_MMD_VEND1,
  2868. &reg);
  2869. if (status)
  2870. return status;
  2871. reg &= ~IXGBE_MDIO_POWER_UP_STALL;
  2872. status = hw->phy.ops.write_reg(hw,
  2873. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2874. MDIO_MMD_VEND1,
  2875. reg);
  2876. if (status)
  2877. return status;
  2878. }
  2879. return status;
  2880. }
  2881. /**
  2882. * ixgbe_set_mdio_speed - Set MDIO clock speed
  2883. * @hw: pointer to hardware structure
  2884. */
  2885. static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
  2886. {
  2887. u32 hlreg0;
  2888. switch (hw->device_id) {
  2889. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2890. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2891. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2892. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2893. case IXGBE_DEV_ID_X550EM_A_SFP:
  2894. /* Config MDIO clock speed before the first MDIO PHY access */
  2895. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2896. hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
  2897. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2898. break;
  2899. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2900. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2901. /* Select fast MDIO clock speed for these devices */
  2902. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2903. hlreg0 |= IXGBE_HLREG0_MDCSPD;
  2904. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2905. break;
  2906. default:
  2907. break;
  2908. }
  2909. }
  2910. /** ixgbe_reset_hw_X550em - Perform hardware reset
  2911. ** @hw: pointer to hardware structure
  2912. **
  2913. ** Resets the hardware by resetting the transmit and receive units, masks
  2914. ** and clears all interrupts, perform a PHY reset, and perform a link (MAC)
  2915. ** reset.
  2916. **/
  2917. static s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
  2918. {
  2919. ixgbe_link_speed link_speed;
  2920. s32 status;
  2921. u32 ctrl = 0;
  2922. u32 i;
  2923. bool link_up = false;
  2924. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  2925. /* Call adapter stop to disable Tx/Rx and clear interrupts */
  2926. status = hw->mac.ops.stop_adapter(hw);
  2927. if (status)
  2928. return status;
  2929. /* flush pending Tx transactions */
  2930. ixgbe_clear_tx_pending(hw);
  2931. /* PHY ops must be identified and initialized prior to reset */
  2932. status = hw->phy.ops.init(hw);
  2933. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2934. status == IXGBE_ERR_PHY_ADDR_INVALID)
  2935. return status;
  2936. /* start the external PHY */
  2937. if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
  2938. status = ixgbe_init_ext_t_x550em(hw);
  2939. if (status)
  2940. return status;
  2941. }
  2942. /* Setup SFP module if there is one present. */
  2943. if (hw->phy.sfp_setup_needed) {
  2944. status = hw->mac.ops.setup_sfp(hw);
  2945. hw->phy.sfp_setup_needed = false;
  2946. }
  2947. /* Reset PHY */
  2948. if (!hw->phy.reset_disable && hw->phy.ops.reset)
  2949. hw->phy.ops.reset(hw);
  2950. mac_reset_top:
  2951. /* Issue global reset to the MAC. Needs to be SW reset if link is up.
  2952. * If link reset is used when link is up, it might reset the PHY when
  2953. * mng is using it. If link is down or the flag to force full link
  2954. * reset is set, then perform link reset.
  2955. */
  2956. ctrl = IXGBE_CTRL_LNK_RST;
  2957. if (!hw->force_full_reset) {
  2958. hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
  2959. if (link_up)
  2960. ctrl = IXGBE_CTRL_RST;
  2961. }
  2962. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  2963. if (status) {
  2964. hw_dbg(hw, "semaphore failed with %d", status);
  2965. return IXGBE_ERR_SWFW_SYNC;
  2966. }
  2967. ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
  2968. IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
  2969. IXGBE_WRITE_FLUSH(hw);
  2970. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  2971. usleep_range(1000, 1200);
  2972. /* Poll for reset bit to self-clear meaning reset is complete */
  2973. for (i = 0; i < 10; i++) {
  2974. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  2975. if (!(ctrl & IXGBE_CTRL_RST_MASK))
  2976. break;
  2977. udelay(1);
  2978. }
  2979. if (ctrl & IXGBE_CTRL_RST_MASK) {
  2980. status = IXGBE_ERR_RESET_FAILED;
  2981. hw_dbg(hw, "Reset polling failed to complete.\n");
  2982. }
  2983. msleep(50);
  2984. /* Double resets are required for recovery from certain error
  2985. * clear the multicast table. Also reset num_rar_entries to 128,
  2986. * since we modify this value when programming the SAN MAC address.
  2987. */
  2988. if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
  2989. hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  2990. goto mac_reset_top;
  2991. }
  2992. /* Store the permanent mac address */
  2993. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  2994. /* Store MAC address from RAR0, clear receive address registers, and
  2995. * clear the multicast table. Also reset num_rar_entries to 128,
  2996. * since we modify this value when programming the SAN MAC address.
  2997. */
  2998. hw->mac.num_rar_entries = 128;
  2999. hw->mac.ops.init_rx_addrs(hw);
  3000. ixgbe_set_mdio_speed(hw);
  3001. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
  3002. ixgbe_setup_mux_ctl(hw);
  3003. return status;
  3004. }
  3005. /** ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype
  3006. * anti-spoofing
  3007. * @hw: pointer to hardware structure
  3008. * @enable: enable or disable switch for Ethertype anti-spoofing
  3009. * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
  3010. **/
  3011. static void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
  3012. bool enable, int vf)
  3013. {
  3014. int vf_target_reg = vf >> 3;
  3015. int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
  3016. u32 pfvfspoof;
  3017. pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
  3018. if (enable)
  3019. pfvfspoof |= BIT(vf_target_shift);
  3020. else
  3021. pfvfspoof &= ~BIT(vf_target_shift);
  3022. IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
  3023. }
  3024. /** ixgbe_set_source_address_pruning_X550 - Enable/Disbale src address pruning
  3025. * @hw: pointer to hardware structure
  3026. * @enable: enable or disable source address pruning
  3027. * @pool: Rx pool to set source address pruning for
  3028. **/
  3029. static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
  3030. bool enable,
  3031. unsigned int pool)
  3032. {
  3033. u64 pfflp;
  3034. /* max rx pool is 63 */
  3035. if (pool > 63)
  3036. return;
  3037. pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
  3038. pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
  3039. if (enable)
  3040. pfflp |= (1ULL << pool);
  3041. else
  3042. pfflp &= ~(1ULL << pool);
  3043. IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
  3044. IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
  3045. }
  3046. /**
  3047. * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
  3048. * @hw: pointer to hardware structure
  3049. *
  3050. * Called at init time to set up flow control.
  3051. **/
  3052. static s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
  3053. {
  3054. s32 status = 0;
  3055. u32 an_cntl = 0;
  3056. /* Validate the requested mode */
  3057. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  3058. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  3059. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  3060. }
  3061. if (hw->fc.requested_mode == ixgbe_fc_default)
  3062. hw->fc.requested_mode = ixgbe_fc_full;
  3063. /* Set up the 1G and 10G flow control advertisement registers so the
  3064. * HW will be able to do FC autoneg once the cable is plugged in. If
  3065. * we link at 10G, the 1G advertisement is harmless and vice versa.
  3066. */
  3067. status = hw->mac.ops.read_iosf_sb_reg(hw,
  3068. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3069. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
  3070. if (status) {
  3071. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  3072. return status;
  3073. }
  3074. /* The possible values of fc.requested_mode are:
  3075. * 0: Flow control is completely disabled
  3076. * 1: Rx flow control is enabled (we can receive pause frames,
  3077. * but not send pause frames).
  3078. * 2: Tx flow control is enabled (we can send pause frames but
  3079. * we do not support receiving pause frames).
  3080. * 3: Both Rx and Tx flow control (symmetric) are enabled.
  3081. * other: Invalid.
  3082. */
  3083. switch (hw->fc.requested_mode) {
  3084. case ixgbe_fc_none:
  3085. /* Flow control completely disabled by software override. */
  3086. an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3087. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  3088. break;
  3089. case ixgbe_fc_tx_pause:
  3090. /* Tx Flow control is enabled, and Rx Flow control is
  3091. * disabled by software override.
  3092. */
  3093. an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3094. an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  3095. break;
  3096. case ixgbe_fc_rx_pause:
  3097. /* Rx Flow control is enabled and Tx Flow control is
  3098. * disabled by software override. Since there really
  3099. * isn't a way to advertise that we are capable of RX
  3100. * Pause ONLY, we will advertise that we support both
  3101. * symmetric and asymmetric Rx PAUSE, as such we fall
  3102. * through to the fc_full statement. Later, we will
  3103. * disable the adapter's ability to send PAUSE frames.
  3104. */
  3105. case ixgbe_fc_full:
  3106. /* Flow control (both Rx and Tx) is enabled by SW override. */
  3107. an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3108. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3109. break;
  3110. default:
  3111. hw_err(hw, "Flow control param set incorrectly\n");
  3112. return IXGBE_ERR_CONFIG;
  3113. }
  3114. status = hw->mac.ops.write_iosf_sb_reg(hw,
  3115. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3116. IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
  3117. /* Restart auto-negotiation. */
  3118. status = ixgbe_restart_an_internal_phy_x550em(hw);
  3119. return status;
  3120. }
  3121. /**
  3122. * ixgbe_set_mux - Set mux for port 1 access with CS4227
  3123. * @hw: pointer to hardware structure
  3124. * @state: set mux if 1, clear if 0
  3125. */
  3126. static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
  3127. {
  3128. u32 esdp;
  3129. if (!hw->bus.lan_id)
  3130. return;
  3131. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  3132. if (state)
  3133. esdp |= IXGBE_ESDP_SDP1;
  3134. else
  3135. esdp &= ~IXGBE_ESDP_SDP1;
  3136. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  3137. IXGBE_WRITE_FLUSH(hw);
  3138. }
  3139. /**
  3140. * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
  3141. * @hw: pointer to hardware structure
  3142. * @mask: Mask to specify which semaphore to acquire
  3143. *
  3144. * Acquires the SWFW semaphore and sets the I2C MUX
  3145. */
  3146. static s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3147. {
  3148. s32 status;
  3149. status = ixgbe_acquire_swfw_sync_X540(hw, mask);
  3150. if (status)
  3151. return status;
  3152. if (mask & IXGBE_GSSR_I2C_MASK)
  3153. ixgbe_set_mux(hw, 1);
  3154. return 0;
  3155. }
  3156. /**
  3157. * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
  3158. * @hw: pointer to hardware structure
  3159. * @mask: Mask to specify which semaphore to release
  3160. *
  3161. * Releases the SWFW semaphore and sets the I2C MUX
  3162. */
  3163. static void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3164. {
  3165. if (mask & IXGBE_GSSR_I2C_MASK)
  3166. ixgbe_set_mux(hw, 0);
  3167. ixgbe_release_swfw_sync_X540(hw, mask);
  3168. }
  3169. /**
  3170. * ixgbe_acquire_swfw_sync_x550em_a - Acquire SWFW semaphore
  3171. * @hw: pointer to hardware structure
  3172. * @mask: Mask to specify which semaphore to acquire
  3173. *
  3174. * Acquires the SWFW semaphore and get the shared PHY token as needed
  3175. */
  3176. static s32 ixgbe_acquire_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3177. {
  3178. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3179. int retries = FW_PHY_TOKEN_RETRIES;
  3180. s32 status;
  3181. while (--retries) {
  3182. status = 0;
  3183. if (hmask)
  3184. status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
  3185. if (status)
  3186. return status;
  3187. if (!(mask & IXGBE_GSSR_TOKEN_SM))
  3188. return 0;
  3189. status = ixgbe_get_phy_token(hw);
  3190. if (!status)
  3191. return 0;
  3192. if (hmask)
  3193. ixgbe_release_swfw_sync_X540(hw, hmask);
  3194. if (status != IXGBE_ERR_TOKEN_RETRY)
  3195. return status;
  3196. msleep(FW_PHY_TOKEN_DELAY);
  3197. }
  3198. return status;
  3199. }
  3200. /**
  3201. * ixgbe_release_swfw_sync_x550em_a - Release SWFW semaphore
  3202. * @hw: pointer to hardware structure
  3203. * @mask: Mask to specify which semaphore to release
  3204. *
  3205. * Release the SWFW semaphore and puts the shared PHY token as needed
  3206. */
  3207. static void ixgbe_release_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3208. {
  3209. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3210. if (mask & IXGBE_GSSR_TOKEN_SM)
  3211. ixgbe_put_phy_token(hw);
  3212. if (hmask)
  3213. ixgbe_release_swfw_sync_X540(hw, hmask);
  3214. }
  3215. /**
  3216. * ixgbe_read_phy_reg_x550a - Reads specified PHY register
  3217. * @hw: pointer to hardware structure
  3218. * @reg_addr: 32 bit address of PHY register to read
  3219. * @phy_data: Pointer to read data from PHY register
  3220. *
  3221. * Reads a value from a specified PHY register using the SWFW lock and PHY
  3222. * Token. The PHY Token is needed since the MDIO is shared between to MAC
  3223. * instances.
  3224. */
  3225. static s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3226. u32 device_type, u16 *phy_data)
  3227. {
  3228. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3229. s32 status;
  3230. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3231. return IXGBE_ERR_SWFW_SYNC;
  3232. status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
  3233. hw->mac.ops.release_swfw_sync(hw, mask);
  3234. return status;
  3235. }
  3236. /**
  3237. * ixgbe_write_phy_reg_x550a - Writes specified PHY register
  3238. * @hw: pointer to hardware structure
  3239. * @reg_addr: 32 bit PHY register to write
  3240. * @device_type: 5 bit device type
  3241. * @phy_data: Data to write to the PHY register
  3242. *
  3243. * Writes a value to specified PHY register using the SWFW lock and PHY Token.
  3244. * The PHY Token is needed since the MDIO is shared between to MAC instances.
  3245. */
  3246. static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3247. u32 device_type, u16 phy_data)
  3248. {
  3249. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3250. s32 status;
  3251. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3252. return IXGBE_ERR_SWFW_SYNC;
  3253. status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type, phy_data);
  3254. hw->mac.ops.release_swfw_sync(hw, mask);
  3255. return status;
  3256. }
  3257. #define X550_COMMON_MAC \
  3258. .init_hw = &ixgbe_init_hw_generic, \
  3259. .start_hw = &ixgbe_start_hw_X540, \
  3260. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, \
  3261. .enable_rx_dma = &ixgbe_enable_rx_dma_generic, \
  3262. .get_mac_addr = &ixgbe_get_mac_addr_generic, \
  3263. .get_device_caps = &ixgbe_get_device_caps_generic, \
  3264. .stop_adapter = &ixgbe_stop_adapter_generic, \
  3265. .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
  3266. .read_analog_reg8 = NULL, \
  3267. .write_analog_reg8 = NULL, \
  3268. .set_rxpba = &ixgbe_set_rxpba_generic, \
  3269. .check_link = &ixgbe_check_mac_link_generic, \
  3270. .blink_led_start = &ixgbe_blink_led_start_X540, \
  3271. .blink_led_stop = &ixgbe_blink_led_stop_X540, \
  3272. .set_rar = &ixgbe_set_rar_generic, \
  3273. .clear_rar = &ixgbe_clear_rar_generic, \
  3274. .set_vmdq = &ixgbe_set_vmdq_generic, \
  3275. .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic, \
  3276. .clear_vmdq = &ixgbe_clear_vmdq_generic, \
  3277. .init_rx_addrs = &ixgbe_init_rx_addrs_generic, \
  3278. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic, \
  3279. .enable_mc = &ixgbe_enable_mc_generic, \
  3280. .disable_mc = &ixgbe_disable_mc_generic, \
  3281. .clear_vfta = &ixgbe_clear_vfta_generic, \
  3282. .set_vfta = &ixgbe_set_vfta_generic, \
  3283. .fc_enable = &ixgbe_fc_enable_generic, \
  3284. .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_x550, \
  3285. .init_uta_tables = &ixgbe_init_uta_tables_generic, \
  3286. .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, \
  3287. .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, \
  3288. .set_source_address_pruning = \
  3289. &ixgbe_set_source_address_pruning_X550, \
  3290. .set_ethertype_anti_spoofing = \
  3291. &ixgbe_set_ethertype_anti_spoofing_X550, \
  3292. .disable_rx_buff = &ixgbe_disable_rx_buff_generic, \
  3293. .enable_rx_buff = &ixgbe_enable_rx_buff_generic, \
  3294. .get_thermal_sensor_data = NULL, \
  3295. .init_thermal_sensor_thresh = NULL, \
  3296. .enable_rx = &ixgbe_enable_rx_generic, \
  3297. .disable_rx = &ixgbe_disable_rx_x550, \
  3298. static const struct ixgbe_mac_operations mac_ops_X550 = {
  3299. X550_COMMON_MAC
  3300. .led_on = ixgbe_led_on_generic,
  3301. .led_off = ixgbe_led_off_generic,
  3302. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3303. .reset_hw = &ixgbe_reset_hw_X540,
  3304. .get_media_type = &ixgbe_get_media_type_X540,
  3305. .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
  3306. .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
  3307. .setup_link = &ixgbe_setup_mac_link_X540,
  3308. .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
  3309. .get_bus_info = &ixgbe_get_bus_info_generic,
  3310. .setup_sfp = NULL,
  3311. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540,
  3312. .release_swfw_sync = &ixgbe_release_swfw_sync_X540,
  3313. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3314. .prot_autoc_read = prot_autoc_read_generic,
  3315. .prot_autoc_write = prot_autoc_write_generic,
  3316. .setup_fc = ixgbe_setup_fc_generic,
  3317. .fc_autoneg = ixgbe_fc_autoneg,
  3318. };
  3319. static const struct ixgbe_mac_operations mac_ops_X550EM_x = {
  3320. X550_COMMON_MAC
  3321. .led_on = ixgbe_led_on_t_x550em,
  3322. .led_off = ixgbe_led_off_t_x550em,
  3323. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3324. .reset_hw = &ixgbe_reset_hw_X550em,
  3325. .get_media_type = &ixgbe_get_media_type_X550em,
  3326. .get_san_mac_addr = NULL,
  3327. .get_wwn_prefix = NULL,
  3328. .setup_link = &ixgbe_setup_mac_link_X540,
  3329. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3330. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3331. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3332. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3333. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3334. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3335. .setup_fc = NULL, /* defined later */
  3336. .fc_autoneg = ixgbe_fc_autoneg,
  3337. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3338. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3339. };
  3340. static const struct ixgbe_mac_operations mac_ops_X550EM_x_fw = {
  3341. X550_COMMON_MAC
  3342. .led_on = NULL,
  3343. .led_off = NULL,
  3344. .init_led_link_act = NULL,
  3345. .reset_hw = &ixgbe_reset_hw_X550em,
  3346. .get_media_type = &ixgbe_get_media_type_X550em,
  3347. .get_san_mac_addr = NULL,
  3348. .get_wwn_prefix = NULL,
  3349. .setup_link = &ixgbe_setup_mac_link_X540,
  3350. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3351. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3352. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3353. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3354. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3355. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3356. .setup_fc = NULL,
  3357. .fc_autoneg = ixgbe_fc_autoneg,
  3358. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3359. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3360. };
  3361. static const struct ixgbe_mac_operations mac_ops_x550em_a = {
  3362. X550_COMMON_MAC
  3363. .led_on = ixgbe_led_on_t_x550em,
  3364. .led_off = ixgbe_led_off_t_x550em,
  3365. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3366. .reset_hw = ixgbe_reset_hw_X550em,
  3367. .get_media_type = ixgbe_get_media_type_X550em,
  3368. .get_san_mac_addr = NULL,
  3369. .get_wwn_prefix = NULL,
  3370. .setup_link = &ixgbe_setup_mac_link_X540,
  3371. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3372. .get_bus_info = ixgbe_get_bus_info_X550em,
  3373. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3374. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3375. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3376. .setup_fc = ixgbe_setup_fc_x550em,
  3377. .fc_autoneg = ixgbe_fc_autoneg,
  3378. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3379. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3380. };
  3381. static const struct ixgbe_mac_operations mac_ops_x550em_a_fw = {
  3382. X550_COMMON_MAC
  3383. .led_on = ixgbe_led_on_generic,
  3384. .led_off = ixgbe_led_off_generic,
  3385. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3386. .reset_hw = ixgbe_reset_hw_X550em,
  3387. .get_media_type = ixgbe_get_media_type_X550em,
  3388. .get_san_mac_addr = NULL,
  3389. .get_wwn_prefix = NULL,
  3390. .setup_link = NULL, /* defined later */
  3391. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3392. .get_bus_info = ixgbe_get_bus_info_X550em,
  3393. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3394. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3395. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3396. .setup_fc = ixgbe_setup_fc_x550em,
  3397. .fc_autoneg = ixgbe_fc_autoneg,
  3398. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3399. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3400. };
  3401. #define X550_COMMON_EEP \
  3402. .read = &ixgbe_read_ee_hostif_X550, \
  3403. .read_buffer = &ixgbe_read_ee_hostif_buffer_X550, \
  3404. .write = &ixgbe_write_ee_hostif_X550, \
  3405. .write_buffer = &ixgbe_write_ee_hostif_buffer_X550, \
  3406. .validate_checksum = &ixgbe_validate_eeprom_checksum_X550, \
  3407. .update_checksum = &ixgbe_update_eeprom_checksum_X550, \
  3408. .calc_checksum = &ixgbe_calc_eeprom_checksum_X550, \
  3409. static const struct ixgbe_eeprom_operations eeprom_ops_X550 = {
  3410. X550_COMMON_EEP
  3411. .init_params = &ixgbe_init_eeprom_params_X550,
  3412. };
  3413. static const struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
  3414. X550_COMMON_EEP
  3415. .init_params = &ixgbe_init_eeprom_params_X540,
  3416. };
  3417. #define X550_COMMON_PHY \
  3418. .identify_sfp = &ixgbe_identify_module_generic, \
  3419. .reset = NULL, \
  3420. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, \
  3421. .read_i2c_byte = &ixgbe_read_i2c_byte_generic, \
  3422. .write_i2c_byte = &ixgbe_write_i2c_byte_generic, \
  3423. .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic, \
  3424. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, \
  3425. .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, \
  3426. .setup_link = &ixgbe_setup_phy_link_generic, \
  3427. .set_phy_power = NULL,
  3428. static const struct ixgbe_phy_operations phy_ops_X550 = {
  3429. X550_COMMON_PHY
  3430. .check_overtemp = &ixgbe_tn_check_overtemp,
  3431. .init = NULL,
  3432. .identify = &ixgbe_identify_phy_generic,
  3433. .read_reg = &ixgbe_read_phy_reg_generic,
  3434. .write_reg = &ixgbe_write_phy_reg_generic,
  3435. };
  3436. static const struct ixgbe_phy_operations phy_ops_X550EM_x = {
  3437. X550_COMMON_PHY
  3438. .check_overtemp = &ixgbe_tn_check_overtemp,
  3439. .init = &ixgbe_init_phy_ops_X550em,
  3440. .identify = &ixgbe_identify_phy_x550em,
  3441. .read_reg = &ixgbe_read_phy_reg_generic,
  3442. .write_reg = &ixgbe_write_phy_reg_generic,
  3443. };
  3444. static const struct ixgbe_phy_operations phy_ops_x550em_x_fw = {
  3445. X550_COMMON_PHY
  3446. .check_overtemp = NULL,
  3447. .init = ixgbe_init_phy_ops_X550em,
  3448. .identify = ixgbe_identify_phy_x550em,
  3449. .read_reg = NULL,
  3450. .write_reg = NULL,
  3451. .read_reg_mdi = NULL,
  3452. .write_reg_mdi = NULL,
  3453. };
  3454. static const struct ixgbe_phy_operations phy_ops_x550em_a = {
  3455. X550_COMMON_PHY
  3456. .check_overtemp = &ixgbe_tn_check_overtemp,
  3457. .init = &ixgbe_init_phy_ops_X550em,
  3458. .identify = &ixgbe_identify_phy_x550em,
  3459. .read_reg = &ixgbe_read_phy_reg_x550a,
  3460. .write_reg = &ixgbe_write_phy_reg_x550a,
  3461. .read_reg_mdi = &ixgbe_read_phy_reg_mdi,
  3462. .write_reg_mdi = &ixgbe_write_phy_reg_mdi,
  3463. };
  3464. static const struct ixgbe_phy_operations phy_ops_x550em_a_fw = {
  3465. X550_COMMON_PHY
  3466. .check_overtemp = ixgbe_check_overtemp_fw,
  3467. .init = ixgbe_init_phy_ops_X550em,
  3468. .identify = ixgbe_identify_phy_fw,
  3469. .read_reg = NULL,
  3470. .write_reg = NULL,
  3471. .read_reg_mdi = NULL,
  3472. .write_reg_mdi = NULL,
  3473. };
  3474. static const struct ixgbe_link_operations link_ops_x550em_x = {
  3475. .read_link = &ixgbe_read_i2c_combined_generic,
  3476. .read_link_unlocked = &ixgbe_read_i2c_combined_generic_unlocked,
  3477. .write_link = &ixgbe_write_i2c_combined_generic,
  3478. .write_link_unlocked = &ixgbe_write_i2c_combined_generic_unlocked,
  3479. };
  3480. static const u32 ixgbe_mvals_X550[IXGBE_MVALS_IDX_LIMIT] = {
  3481. IXGBE_MVALS_INIT(X550)
  3482. };
  3483. static const u32 ixgbe_mvals_X550EM_x[IXGBE_MVALS_IDX_LIMIT] = {
  3484. IXGBE_MVALS_INIT(X550EM_x)
  3485. };
  3486. static const u32 ixgbe_mvals_x550em_a[IXGBE_MVALS_IDX_LIMIT] = {
  3487. IXGBE_MVALS_INIT(X550EM_a)
  3488. };
  3489. const struct ixgbe_info ixgbe_X550_info = {
  3490. .mac = ixgbe_mac_X550,
  3491. .get_invariants = &ixgbe_get_invariants_X540,
  3492. .mac_ops = &mac_ops_X550,
  3493. .eeprom_ops = &eeprom_ops_X550,
  3494. .phy_ops = &phy_ops_X550,
  3495. .mbx_ops = &mbx_ops_generic,
  3496. .mvals = ixgbe_mvals_X550,
  3497. };
  3498. const struct ixgbe_info ixgbe_X550EM_x_info = {
  3499. .mac = ixgbe_mac_X550EM_x,
  3500. .get_invariants = &ixgbe_get_invariants_X550_x,
  3501. .mac_ops = &mac_ops_X550EM_x,
  3502. .eeprom_ops = &eeprom_ops_X550EM_x,
  3503. .phy_ops = &phy_ops_X550EM_x,
  3504. .mbx_ops = &mbx_ops_generic,
  3505. .mvals = ixgbe_mvals_X550EM_x,
  3506. .link_ops = &link_ops_x550em_x,
  3507. };
  3508. const struct ixgbe_info ixgbe_x550em_x_fw_info = {
  3509. .mac = ixgbe_mac_X550EM_x,
  3510. .get_invariants = ixgbe_get_invariants_X550_x_fw,
  3511. .mac_ops = &mac_ops_X550EM_x_fw,
  3512. .eeprom_ops = &eeprom_ops_X550EM_x,
  3513. .phy_ops = &phy_ops_x550em_x_fw,
  3514. .mbx_ops = &mbx_ops_generic,
  3515. .mvals = ixgbe_mvals_X550EM_x,
  3516. };
  3517. const struct ixgbe_info ixgbe_x550em_a_info = {
  3518. .mac = ixgbe_mac_x550em_a,
  3519. .get_invariants = &ixgbe_get_invariants_X550_a,
  3520. .mac_ops = &mac_ops_x550em_a,
  3521. .eeprom_ops = &eeprom_ops_X550EM_x,
  3522. .phy_ops = &phy_ops_x550em_a,
  3523. .mbx_ops = &mbx_ops_generic,
  3524. .mvals = ixgbe_mvals_x550em_a,
  3525. };
  3526. const struct ixgbe_info ixgbe_x550em_a_fw_info = {
  3527. .mac = ixgbe_mac_x550em_a,
  3528. .get_invariants = ixgbe_get_invariants_X550_a_fw,
  3529. .mac_ops = &mac_ops_x550em_a_fw,
  3530. .eeprom_ops = &eeprom_ops_X550EM_x,
  3531. .phy_ops = &phy_ops_x550em_a_fw,
  3532. .mbx_ops = &mbx_ops_generic,
  3533. .mvals = ixgbe_mvals_x550em_a,
  3534. };