ixgbe_82599.c 77 KB

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