i40e_ethtool.c 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2015 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. /* ethtool support for i40e */
  27. #include "i40e.h"
  28. #include "i40e_diag.h"
  29. struct i40e_stats {
  30. char stat_string[ETH_GSTRING_LEN];
  31. int sizeof_stat;
  32. int stat_offset;
  33. };
  34. #define I40E_STAT(_type, _name, _stat) { \
  35. .stat_string = _name, \
  36. .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
  37. .stat_offset = offsetof(_type, _stat) \
  38. }
  39. #define I40E_NETDEV_STAT(_net_stat) \
  40. I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
  41. #define I40E_PF_STAT(_name, _stat) \
  42. I40E_STAT(struct i40e_pf, _name, _stat)
  43. #define I40E_VSI_STAT(_name, _stat) \
  44. I40E_STAT(struct i40e_vsi, _name, _stat)
  45. #define I40E_VEB_STAT(_name, _stat) \
  46. I40E_STAT(struct i40e_veb, _name, _stat)
  47. static const struct i40e_stats i40e_gstrings_net_stats[] = {
  48. I40E_NETDEV_STAT(rx_packets),
  49. I40E_NETDEV_STAT(tx_packets),
  50. I40E_NETDEV_STAT(rx_bytes),
  51. I40E_NETDEV_STAT(tx_bytes),
  52. I40E_NETDEV_STAT(rx_errors),
  53. I40E_NETDEV_STAT(tx_errors),
  54. I40E_NETDEV_STAT(rx_dropped),
  55. I40E_NETDEV_STAT(tx_dropped),
  56. I40E_NETDEV_STAT(collisions),
  57. I40E_NETDEV_STAT(rx_length_errors),
  58. I40E_NETDEV_STAT(rx_crc_errors),
  59. };
  60. static const struct i40e_stats i40e_gstrings_veb_stats[] = {
  61. I40E_VEB_STAT("rx_bytes", stats.rx_bytes),
  62. I40E_VEB_STAT("tx_bytes", stats.tx_bytes),
  63. I40E_VEB_STAT("rx_unicast", stats.rx_unicast),
  64. I40E_VEB_STAT("tx_unicast", stats.tx_unicast),
  65. I40E_VEB_STAT("rx_multicast", stats.rx_multicast),
  66. I40E_VEB_STAT("tx_multicast", stats.tx_multicast),
  67. I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast),
  68. I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast),
  69. I40E_VEB_STAT("rx_discards", stats.rx_discards),
  70. I40E_VEB_STAT("tx_discards", stats.tx_discards),
  71. I40E_VEB_STAT("tx_errors", stats.tx_errors),
  72. I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol),
  73. };
  74. static const struct i40e_stats i40e_gstrings_misc_stats[] = {
  75. I40E_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
  76. I40E_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
  77. I40E_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
  78. I40E_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
  79. I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
  80. I40E_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
  81. I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
  82. };
  83. static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
  84. struct ethtool_rxnfc *cmd);
  85. /* These PF_STATs might look like duplicates of some NETDEV_STATs,
  86. * but they are separate. This device supports Virtualization, and
  87. * as such might have several netdevs supporting VMDq and FCoE going
  88. * through a single port. The NETDEV_STATs are for individual netdevs
  89. * seen at the top of the stack, and the PF_STATs are for the physical
  90. * function at the bottom of the stack hosting those netdevs.
  91. *
  92. * The PF_STATs are appended to the netdev stats only when ethtool -S
  93. * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
  94. */
  95. static struct i40e_stats i40e_gstrings_stats[] = {
  96. I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
  97. I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
  98. I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast),
  99. I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast),
  100. I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast),
  101. I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast),
  102. I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast),
  103. I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast),
  104. I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
  105. I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
  106. I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
  107. I40E_PF_STAT("crc_errors", stats.crc_errors),
  108. I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
  109. I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
  110. I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
  111. I40E_PF_STAT("tx_timeout", tx_timeout_count),
  112. I40E_PF_STAT("rx_csum_bad", hw_csum_rx_error),
  113. I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
  114. I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
  115. I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
  116. I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
  117. I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
  118. I40E_PF_STAT("rx_size_64", stats.rx_size_64),
  119. I40E_PF_STAT("rx_size_127", stats.rx_size_127),
  120. I40E_PF_STAT("rx_size_255", stats.rx_size_255),
  121. I40E_PF_STAT("rx_size_511", stats.rx_size_511),
  122. I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
  123. I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
  124. I40E_PF_STAT("rx_size_big", stats.rx_size_big),
  125. I40E_PF_STAT("tx_size_64", stats.tx_size_64),
  126. I40E_PF_STAT("tx_size_127", stats.tx_size_127),
  127. I40E_PF_STAT("tx_size_255", stats.tx_size_255),
  128. I40E_PF_STAT("tx_size_511", stats.tx_size_511),
  129. I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
  130. I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
  131. I40E_PF_STAT("tx_size_big", stats.tx_size_big),
  132. I40E_PF_STAT("rx_undersize", stats.rx_undersize),
  133. I40E_PF_STAT("rx_fragments", stats.rx_fragments),
  134. I40E_PF_STAT("rx_oversize", stats.rx_oversize),
  135. I40E_PF_STAT("rx_jabber", stats.rx_jabber),
  136. I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
  137. I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
  138. I40E_PF_STAT("fdir_flush_cnt", fd_flush_cnt),
  139. I40E_PF_STAT("fdir_atr_match", stats.fd_atr_match),
  140. I40E_PF_STAT("fdir_sb_match", stats.fd_sb_match),
  141. /* LPI stats */
  142. I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
  143. I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
  144. I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
  145. I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
  146. };
  147. #ifdef I40E_FCOE
  148. static const struct i40e_stats i40e_gstrings_fcoe_stats[] = {
  149. I40E_VSI_STAT("fcoe_bad_fccrc", fcoe_stats.fcoe_bad_fccrc),
  150. I40E_VSI_STAT("rx_fcoe_dropped", fcoe_stats.rx_fcoe_dropped),
  151. I40E_VSI_STAT("rx_fcoe_packets", fcoe_stats.rx_fcoe_packets),
  152. I40E_VSI_STAT("rx_fcoe_dwords", fcoe_stats.rx_fcoe_dwords),
  153. I40E_VSI_STAT("fcoe_ddp_count", fcoe_stats.fcoe_ddp_count),
  154. I40E_VSI_STAT("fcoe_last_error", fcoe_stats.fcoe_last_error),
  155. I40E_VSI_STAT("tx_fcoe_packets", fcoe_stats.tx_fcoe_packets),
  156. I40E_VSI_STAT("tx_fcoe_dwords", fcoe_stats.tx_fcoe_dwords),
  157. };
  158. #endif /* I40E_FCOE */
  159. #define I40E_QUEUE_STATS_LEN(n) \
  160. (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \
  161. * 2 /* Tx and Rx together */ \
  162. * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
  163. #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
  164. #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
  165. #define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats)
  166. #ifdef I40E_FCOE
  167. #define I40E_FCOE_STATS_LEN ARRAY_SIZE(i40e_gstrings_fcoe_stats)
  168. #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
  169. I40E_FCOE_STATS_LEN + \
  170. I40E_MISC_STATS_LEN + \
  171. I40E_QUEUE_STATS_LEN((n)))
  172. #else
  173. #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
  174. I40E_MISC_STATS_LEN + \
  175. I40E_QUEUE_STATS_LEN((n)))
  176. #endif /* I40E_FCOE */
  177. #define I40E_PFC_STATS_LEN ( \
  178. (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
  179. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
  180. FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
  181. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
  182. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
  183. / sizeof(u64))
  184. #define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
  185. #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
  186. I40E_PFC_STATS_LEN + \
  187. I40E_VSI_STATS_LEN((n)))
  188. enum i40e_ethtool_test_id {
  189. I40E_ETH_TEST_REG = 0,
  190. I40E_ETH_TEST_EEPROM,
  191. I40E_ETH_TEST_INTR,
  192. I40E_ETH_TEST_LOOPBACK,
  193. I40E_ETH_TEST_LINK,
  194. };
  195. static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
  196. "Register test (offline)",
  197. "Eeprom test (offline)",
  198. "Interrupt test (offline)",
  199. "Loopback test (offline)",
  200. "Link test (on/offline)"
  201. };
  202. #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
  203. static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = {
  204. "NPAR",
  205. };
  206. #define I40E_PRIV_FLAGS_STR_LEN \
  207. (sizeof(i40e_priv_flags_strings) / ETH_GSTRING_LEN)
  208. /**
  209. * i40e_partition_setting_complaint - generic complaint for MFP restriction
  210. * @pf: the PF struct
  211. **/
  212. static void i40e_partition_setting_complaint(struct i40e_pf *pf)
  213. {
  214. dev_info(&pf->pdev->dev,
  215. "The link settings are allowed to be changed only from the first partition of a given port. Please switch to the first partition in order to change the setting.\n");
  216. }
  217. /**
  218. * i40e_get_settings_link_up - Get the Link settings for when link is up
  219. * @hw: hw structure
  220. * @ecmd: ethtool command to fill in
  221. * @netdev: network interface device structure
  222. *
  223. **/
  224. static void i40e_get_settings_link_up(struct i40e_hw *hw,
  225. struct ethtool_cmd *ecmd,
  226. struct net_device *netdev)
  227. {
  228. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  229. u32 link_speed = hw_link_info->link_speed;
  230. /* Initialize supported and advertised settings based on phy settings */
  231. switch (hw_link_info->phy_type) {
  232. case I40E_PHY_TYPE_40GBASE_CR4:
  233. case I40E_PHY_TYPE_40GBASE_CR4_CU:
  234. ecmd->supported = SUPPORTED_Autoneg |
  235. SUPPORTED_40000baseCR4_Full;
  236. ecmd->advertising = ADVERTISED_Autoneg |
  237. ADVERTISED_40000baseCR4_Full;
  238. break;
  239. case I40E_PHY_TYPE_XLAUI:
  240. case I40E_PHY_TYPE_XLPPI:
  241. case I40E_PHY_TYPE_40GBASE_AOC:
  242. ecmd->supported = SUPPORTED_40000baseCR4_Full;
  243. break;
  244. case I40E_PHY_TYPE_40GBASE_KR4:
  245. ecmd->supported = SUPPORTED_Autoneg |
  246. SUPPORTED_40000baseKR4_Full;
  247. ecmd->advertising = ADVERTISED_Autoneg |
  248. ADVERTISED_40000baseKR4_Full;
  249. break;
  250. case I40E_PHY_TYPE_40GBASE_SR4:
  251. ecmd->supported = SUPPORTED_40000baseSR4_Full;
  252. break;
  253. case I40E_PHY_TYPE_40GBASE_LR4:
  254. ecmd->supported = SUPPORTED_40000baseLR4_Full;
  255. break;
  256. case I40E_PHY_TYPE_10GBASE_KX4:
  257. ecmd->supported = SUPPORTED_Autoneg |
  258. SUPPORTED_10000baseKX4_Full;
  259. ecmd->advertising = ADVERTISED_Autoneg |
  260. ADVERTISED_10000baseKX4_Full;
  261. break;
  262. case I40E_PHY_TYPE_10GBASE_KR:
  263. ecmd->supported = SUPPORTED_Autoneg |
  264. SUPPORTED_10000baseKR_Full;
  265. ecmd->advertising = ADVERTISED_Autoneg |
  266. ADVERTISED_10000baseKR_Full;
  267. break;
  268. case I40E_PHY_TYPE_10GBASE_SR:
  269. case I40E_PHY_TYPE_10GBASE_LR:
  270. case I40E_PHY_TYPE_1000BASE_SX:
  271. case I40E_PHY_TYPE_1000BASE_LX:
  272. ecmd->supported = SUPPORTED_10000baseT_Full |
  273. SUPPORTED_1000baseT_Full;
  274. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
  275. ecmd->advertising |= ADVERTISED_10000baseT_Full;
  276. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
  277. ecmd->advertising |= ADVERTISED_1000baseT_Full;
  278. break;
  279. case I40E_PHY_TYPE_1000BASE_KX:
  280. ecmd->supported = SUPPORTED_Autoneg |
  281. SUPPORTED_1000baseKX_Full;
  282. ecmd->advertising = ADVERTISED_Autoneg |
  283. ADVERTISED_1000baseKX_Full;
  284. break;
  285. case I40E_PHY_TYPE_10GBASE_T:
  286. case I40E_PHY_TYPE_1000BASE_T:
  287. case I40E_PHY_TYPE_100BASE_TX:
  288. ecmd->supported = SUPPORTED_Autoneg |
  289. SUPPORTED_10000baseT_Full |
  290. SUPPORTED_1000baseT_Full |
  291. SUPPORTED_100baseT_Full;
  292. ecmd->advertising = ADVERTISED_Autoneg;
  293. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
  294. ecmd->advertising |= ADVERTISED_10000baseT_Full;
  295. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
  296. ecmd->advertising |= ADVERTISED_1000baseT_Full;
  297. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
  298. ecmd->advertising |= ADVERTISED_100baseT_Full;
  299. break;
  300. case I40E_PHY_TYPE_10GBASE_CR1_CU:
  301. case I40E_PHY_TYPE_10GBASE_CR1:
  302. ecmd->supported = SUPPORTED_Autoneg |
  303. SUPPORTED_10000baseT_Full;
  304. ecmd->advertising = ADVERTISED_Autoneg |
  305. ADVERTISED_10000baseT_Full;
  306. break;
  307. case I40E_PHY_TYPE_XAUI:
  308. case I40E_PHY_TYPE_XFI:
  309. case I40E_PHY_TYPE_SFI:
  310. case I40E_PHY_TYPE_10GBASE_SFPP_CU:
  311. case I40E_PHY_TYPE_10GBASE_AOC:
  312. ecmd->supported = SUPPORTED_10000baseT_Full;
  313. break;
  314. case I40E_PHY_TYPE_SGMII:
  315. ecmd->supported = SUPPORTED_Autoneg |
  316. SUPPORTED_1000baseT_Full |
  317. SUPPORTED_100baseT_Full;
  318. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
  319. ecmd->advertising |= ADVERTISED_1000baseT_Full;
  320. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
  321. ecmd->advertising |= ADVERTISED_100baseT_Full;
  322. break;
  323. default:
  324. /* if we got here and link is up something bad is afoot */
  325. netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized.\n",
  326. hw_link_info->phy_type);
  327. }
  328. /* Set speed and duplex */
  329. switch (link_speed) {
  330. case I40E_LINK_SPEED_40GB:
  331. /* need a SPEED_40000 in ethtool.h */
  332. ethtool_cmd_speed_set(ecmd, 40000);
  333. break;
  334. case I40E_LINK_SPEED_10GB:
  335. ethtool_cmd_speed_set(ecmd, SPEED_10000);
  336. break;
  337. case I40E_LINK_SPEED_1GB:
  338. ethtool_cmd_speed_set(ecmd, SPEED_1000);
  339. break;
  340. case I40E_LINK_SPEED_100MB:
  341. ethtool_cmd_speed_set(ecmd, SPEED_100);
  342. break;
  343. default:
  344. break;
  345. }
  346. ecmd->duplex = DUPLEX_FULL;
  347. }
  348. /**
  349. * i40e_get_settings_link_down - Get the Link settings for when link is down
  350. * @hw: hw structure
  351. * @ecmd: ethtool command to fill in
  352. *
  353. * Reports link settings that can be determined when link is down
  354. **/
  355. static void i40e_get_settings_link_down(struct i40e_hw *hw,
  356. struct ethtool_cmd *ecmd)
  357. {
  358. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  359. /* link is down and the driver needs to fall back on
  360. * device ID to determine what kinds of info to display,
  361. * it's mostly a guess that may change when link is up
  362. */
  363. switch (hw->device_id) {
  364. case I40E_DEV_ID_QSFP_A:
  365. case I40E_DEV_ID_QSFP_B:
  366. case I40E_DEV_ID_QSFP_C:
  367. /* pluggable QSFP */
  368. ecmd->supported = SUPPORTED_40000baseSR4_Full |
  369. SUPPORTED_40000baseCR4_Full |
  370. SUPPORTED_40000baseLR4_Full;
  371. ecmd->advertising = ADVERTISED_40000baseSR4_Full |
  372. ADVERTISED_40000baseCR4_Full |
  373. ADVERTISED_40000baseLR4_Full;
  374. break;
  375. case I40E_DEV_ID_KX_B:
  376. /* backplane 40G */
  377. ecmd->supported = SUPPORTED_40000baseKR4_Full;
  378. ecmd->advertising = ADVERTISED_40000baseKR4_Full;
  379. break;
  380. case I40E_DEV_ID_KX_C:
  381. /* backplane 10G */
  382. ecmd->supported = SUPPORTED_10000baseKR_Full;
  383. ecmd->advertising = ADVERTISED_10000baseKR_Full;
  384. break;
  385. case I40E_DEV_ID_10G_BASE_T:
  386. ecmd->supported = SUPPORTED_10000baseT_Full |
  387. SUPPORTED_1000baseT_Full |
  388. SUPPORTED_100baseT_Full;
  389. /* Figure out what has been requested */
  390. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
  391. ecmd->advertising |= ADVERTISED_10000baseT_Full;
  392. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
  393. ecmd->advertising |= ADVERTISED_1000baseT_Full;
  394. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
  395. ecmd->advertising |= ADVERTISED_100baseT_Full;
  396. break;
  397. default:
  398. /* all the rest are 10G/1G */
  399. ecmd->supported = SUPPORTED_10000baseT_Full |
  400. SUPPORTED_1000baseT_Full;
  401. /* Figure out what has been requested */
  402. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
  403. ecmd->advertising |= ADVERTISED_10000baseT_Full;
  404. if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
  405. ecmd->advertising |= ADVERTISED_1000baseT_Full;
  406. break;
  407. }
  408. /* With no link speed and duplex are unknown */
  409. ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
  410. ecmd->duplex = DUPLEX_UNKNOWN;
  411. }
  412. /**
  413. * i40e_get_settings - Get Link Speed and Duplex settings
  414. * @netdev: network interface device structure
  415. * @ecmd: ethtool command
  416. *
  417. * Reports speed/duplex settings based on media_type
  418. **/
  419. static int i40e_get_settings(struct net_device *netdev,
  420. struct ethtool_cmd *ecmd)
  421. {
  422. struct i40e_netdev_priv *np = netdev_priv(netdev);
  423. struct i40e_pf *pf = np->vsi->back;
  424. struct i40e_hw *hw = &pf->hw;
  425. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  426. bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
  427. if (link_up)
  428. i40e_get_settings_link_up(hw, ecmd, netdev);
  429. else
  430. i40e_get_settings_link_down(hw, ecmd);
  431. /* Now set the settings that don't rely on link being up/down */
  432. /* Set autoneg settings */
  433. ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
  434. AUTONEG_ENABLE : AUTONEG_DISABLE);
  435. switch (hw->phy.media_type) {
  436. case I40E_MEDIA_TYPE_BACKPLANE:
  437. ecmd->supported |= SUPPORTED_Autoneg |
  438. SUPPORTED_Backplane;
  439. ecmd->advertising |= ADVERTISED_Autoneg |
  440. ADVERTISED_Backplane;
  441. ecmd->port = PORT_NONE;
  442. break;
  443. case I40E_MEDIA_TYPE_BASET:
  444. ecmd->supported |= SUPPORTED_TP;
  445. ecmd->advertising |= ADVERTISED_TP;
  446. ecmd->port = PORT_TP;
  447. break;
  448. case I40E_MEDIA_TYPE_DA:
  449. case I40E_MEDIA_TYPE_CX4:
  450. ecmd->supported |= SUPPORTED_FIBRE;
  451. ecmd->advertising |= ADVERTISED_FIBRE;
  452. ecmd->port = PORT_DA;
  453. break;
  454. case I40E_MEDIA_TYPE_FIBER:
  455. ecmd->supported |= SUPPORTED_FIBRE;
  456. ecmd->port = PORT_FIBRE;
  457. break;
  458. case I40E_MEDIA_TYPE_UNKNOWN:
  459. default:
  460. ecmd->port = PORT_OTHER;
  461. break;
  462. }
  463. /* Set transceiver */
  464. ecmd->transceiver = XCVR_EXTERNAL;
  465. /* Set flow control settings */
  466. ecmd->supported |= SUPPORTED_Pause;
  467. switch (hw->fc.requested_mode) {
  468. case I40E_FC_FULL:
  469. ecmd->advertising |= ADVERTISED_Pause;
  470. break;
  471. case I40E_FC_TX_PAUSE:
  472. ecmd->advertising |= ADVERTISED_Asym_Pause;
  473. break;
  474. case I40E_FC_RX_PAUSE:
  475. ecmd->advertising |= (ADVERTISED_Pause |
  476. ADVERTISED_Asym_Pause);
  477. break;
  478. default:
  479. ecmd->advertising &= ~(ADVERTISED_Pause |
  480. ADVERTISED_Asym_Pause);
  481. break;
  482. }
  483. return 0;
  484. }
  485. /**
  486. * i40e_set_settings - Set Speed and Duplex
  487. * @netdev: network interface device structure
  488. * @ecmd: ethtool command
  489. *
  490. * Set speed/duplex per media_types advertised/forced
  491. **/
  492. static int i40e_set_settings(struct net_device *netdev,
  493. struct ethtool_cmd *ecmd)
  494. {
  495. struct i40e_netdev_priv *np = netdev_priv(netdev);
  496. struct i40e_aq_get_phy_abilities_resp abilities;
  497. struct i40e_aq_set_phy_config config;
  498. struct i40e_pf *pf = np->vsi->back;
  499. struct i40e_vsi *vsi = np->vsi;
  500. struct i40e_hw *hw = &pf->hw;
  501. struct ethtool_cmd safe_ecmd;
  502. i40e_status status = 0;
  503. bool change = false;
  504. int err = 0;
  505. u8 autoneg;
  506. u32 advertise;
  507. /* Changing port settings is not supported if this isn't the
  508. * port's controlling PF
  509. */
  510. if (hw->partition_id != 1) {
  511. i40e_partition_setting_complaint(pf);
  512. return -EOPNOTSUPP;
  513. }
  514. if (vsi != pf->vsi[pf->lan_vsi])
  515. return -EOPNOTSUPP;
  516. if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
  517. hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
  518. hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE &&
  519. hw->phy.link_info.link_info & I40E_AQ_LINK_UP)
  520. return -EOPNOTSUPP;
  521. /* get our own copy of the bits to check against */
  522. memset(&safe_ecmd, 0, sizeof(struct ethtool_cmd));
  523. i40e_get_settings(netdev, &safe_ecmd);
  524. /* save autoneg and speed out of ecmd */
  525. autoneg = ecmd->autoneg;
  526. advertise = ecmd->advertising;
  527. /* set autoneg and speed back to what they currently are */
  528. ecmd->autoneg = safe_ecmd.autoneg;
  529. ecmd->advertising = safe_ecmd.advertising;
  530. ecmd->cmd = safe_ecmd.cmd;
  531. /* If ecmd and safe_ecmd are not the same now, then they are
  532. * trying to set something that we do not support
  533. */
  534. if (memcmp(ecmd, &safe_ecmd, sizeof(struct ethtool_cmd)))
  535. return -EOPNOTSUPP;
  536. while (test_bit(__I40E_CONFIG_BUSY, &vsi->state))
  537. usleep_range(1000, 2000);
  538. /* Get the current phy config */
  539. status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
  540. NULL);
  541. if (status)
  542. return -EAGAIN;
  543. /* Copy abilities to config in case autoneg is not
  544. * set below
  545. */
  546. memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
  547. config.abilities = abilities.abilities;
  548. /* Check autoneg */
  549. if (autoneg == AUTONEG_ENABLE) {
  550. /* If autoneg is not supported, return error */
  551. if (!(safe_ecmd.supported & SUPPORTED_Autoneg)) {
  552. netdev_info(netdev, "Autoneg not supported on this phy\n");
  553. return -EINVAL;
  554. }
  555. /* If autoneg was not already enabled */
  556. if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) {
  557. config.abilities = abilities.abilities |
  558. I40E_AQ_PHY_ENABLE_AN;
  559. change = true;
  560. }
  561. } else {
  562. /* If autoneg is supported 10GBASE_T is the only phy that
  563. * can disable it, so otherwise return error
  564. */
  565. if (safe_ecmd.supported & SUPPORTED_Autoneg &&
  566. hw->phy.link_info.phy_type != I40E_PHY_TYPE_10GBASE_T) {
  567. netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
  568. return -EINVAL;
  569. }
  570. /* If autoneg is currently enabled */
  571. if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) {
  572. config.abilities = abilities.abilities &
  573. ~I40E_AQ_PHY_ENABLE_AN;
  574. change = true;
  575. }
  576. }
  577. if (advertise & ~safe_ecmd.supported)
  578. return -EINVAL;
  579. if (advertise & ADVERTISED_100baseT_Full)
  580. config.link_speed |= I40E_LINK_SPEED_100MB;
  581. if (advertise & ADVERTISED_1000baseT_Full ||
  582. advertise & ADVERTISED_1000baseKX_Full)
  583. config.link_speed |= I40E_LINK_SPEED_1GB;
  584. if (advertise & ADVERTISED_10000baseT_Full ||
  585. advertise & ADVERTISED_10000baseKX4_Full ||
  586. advertise & ADVERTISED_10000baseKR_Full)
  587. config.link_speed |= I40E_LINK_SPEED_10GB;
  588. if (advertise & ADVERTISED_40000baseKR4_Full ||
  589. advertise & ADVERTISED_40000baseCR4_Full ||
  590. advertise & ADVERTISED_40000baseSR4_Full ||
  591. advertise & ADVERTISED_40000baseLR4_Full)
  592. config.link_speed |= I40E_LINK_SPEED_40GB;
  593. if (change || (abilities.link_speed != config.link_speed)) {
  594. /* copy over the rest of the abilities */
  595. config.phy_type = abilities.phy_type;
  596. config.eee_capability = abilities.eee_capability;
  597. config.eeer = abilities.eeer_val;
  598. config.low_power_ctrl = abilities.d3_lpan;
  599. /* save the requested speeds */
  600. hw->phy.link_info.requested_speeds = config.link_speed;
  601. /* set link and auto negotiation so changes take effect */
  602. config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
  603. /* If link is up put link down */
  604. if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) {
  605. /* Tell the OS link is going down, the link will go
  606. * back up when fw says it is ready asynchronously
  607. */
  608. netdev_info(netdev, "PHY settings change requested, NIC Link is going down.\n");
  609. netif_carrier_off(netdev);
  610. netif_tx_stop_all_queues(netdev);
  611. }
  612. /* make the aq call */
  613. status = i40e_aq_set_phy_config(hw, &config, NULL);
  614. if (status) {
  615. netdev_info(netdev, "Set phy config failed with error %d.\n",
  616. status);
  617. return -EAGAIN;
  618. }
  619. status = i40e_aq_get_link_info(hw, true, NULL, NULL);
  620. if (status)
  621. netdev_info(netdev, "Updating link info failed with error %d\n",
  622. status);
  623. } else {
  624. netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
  625. }
  626. return err;
  627. }
  628. static int i40e_nway_reset(struct net_device *netdev)
  629. {
  630. /* restart autonegotiation */
  631. struct i40e_netdev_priv *np = netdev_priv(netdev);
  632. struct i40e_pf *pf = np->vsi->back;
  633. struct i40e_hw *hw = &pf->hw;
  634. bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
  635. i40e_status ret = 0;
  636. ret = i40e_aq_set_link_restart_an(hw, link_up, NULL);
  637. if (ret) {
  638. netdev_info(netdev, "link restart failed, aq_err=%d\n",
  639. pf->hw.aq.asq_last_status);
  640. return -EIO;
  641. }
  642. return 0;
  643. }
  644. /**
  645. * i40e_get_pauseparam - Get Flow Control status
  646. * Return tx/rx-pause status
  647. **/
  648. static void i40e_get_pauseparam(struct net_device *netdev,
  649. struct ethtool_pauseparam *pause)
  650. {
  651. struct i40e_netdev_priv *np = netdev_priv(netdev);
  652. struct i40e_pf *pf = np->vsi->back;
  653. struct i40e_hw *hw = &pf->hw;
  654. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  655. struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
  656. pause->autoneg =
  657. ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
  658. AUTONEG_ENABLE : AUTONEG_DISABLE);
  659. /* PFC enabled so report LFC as off */
  660. if (dcbx_cfg->pfc.pfcenable) {
  661. pause->rx_pause = 0;
  662. pause->tx_pause = 0;
  663. return;
  664. }
  665. if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
  666. pause->rx_pause = 1;
  667. } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
  668. pause->tx_pause = 1;
  669. } else if (hw->fc.current_mode == I40E_FC_FULL) {
  670. pause->rx_pause = 1;
  671. pause->tx_pause = 1;
  672. }
  673. }
  674. /**
  675. * i40e_set_pauseparam - Set Flow Control parameter
  676. * @netdev: network interface device structure
  677. * @pause: return tx/rx flow control status
  678. **/
  679. static int i40e_set_pauseparam(struct net_device *netdev,
  680. struct ethtool_pauseparam *pause)
  681. {
  682. struct i40e_netdev_priv *np = netdev_priv(netdev);
  683. struct i40e_pf *pf = np->vsi->back;
  684. struct i40e_vsi *vsi = np->vsi;
  685. struct i40e_hw *hw = &pf->hw;
  686. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  687. struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
  688. bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
  689. i40e_status status;
  690. u8 aq_failures;
  691. int err = 0;
  692. /* Changing the port's flow control is not supported if this isn't the
  693. * port's controlling PF
  694. */
  695. if (hw->partition_id != 1) {
  696. i40e_partition_setting_complaint(pf);
  697. return -EOPNOTSUPP;
  698. }
  699. if (vsi != pf->vsi[pf->lan_vsi])
  700. return -EOPNOTSUPP;
  701. if (pause->autoneg != ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
  702. AUTONEG_ENABLE : AUTONEG_DISABLE)) {
  703. netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
  704. return -EOPNOTSUPP;
  705. }
  706. /* If we have link and don't have autoneg */
  707. if (!test_bit(__I40E_DOWN, &pf->state) &&
  708. !(hw_link_info->an_info & I40E_AQ_AN_COMPLETED)) {
  709. /* Send message that it might not necessarily work*/
  710. netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
  711. }
  712. if (dcbx_cfg->pfc.pfcenable) {
  713. netdev_info(netdev,
  714. "Priority flow control enabled. Cannot set link flow control.\n");
  715. return -EOPNOTSUPP;
  716. }
  717. if (pause->rx_pause && pause->tx_pause)
  718. hw->fc.requested_mode = I40E_FC_FULL;
  719. else if (pause->rx_pause && !pause->tx_pause)
  720. hw->fc.requested_mode = I40E_FC_RX_PAUSE;
  721. else if (!pause->rx_pause && pause->tx_pause)
  722. hw->fc.requested_mode = I40E_FC_TX_PAUSE;
  723. else if (!pause->rx_pause && !pause->tx_pause)
  724. hw->fc.requested_mode = I40E_FC_NONE;
  725. else
  726. return -EINVAL;
  727. /* Tell the OS link is going down, the link will go back up when fw
  728. * says it is ready asynchronously
  729. */
  730. netdev_info(netdev, "Flow control settings change requested, NIC Link is going down.\n");
  731. netif_carrier_off(netdev);
  732. netif_tx_stop_all_queues(netdev);
  733. /* Set the fc mode and only restart an if link is up*/
  734. status = i40e_set_fc(hw, &aq_failures, link_up);
  735. if (aq_failures & I40E_SET_FC_AQ_FAIL_GET) {
  736. netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with error %d and status %d\n",
  737. status, hw->aq.asq_last_status);
  738. err = -EAGAIN;
  739. }
  740. if (aq_failures & I40E_SET_FC_AQ_FAIL_SET) {
  741. netdev_info(netdev, "Set fc failed on the set_phy_config call with error %d and status %d\n",
  742. status, hw->aq.asq_last_status);
  743. err = -EAGAIN;
  744. }
  745. if (aq_failures & I40E_SET_FC_AQ_FAIL_UPDATE) {
  746. netdev_info(netdev, "Set fc failed on the get_link_info call with error %d and status %d\n",
  747. status, hw->aq.asq_last_status);
  748. err = -EAGAIN;
  749. }
  750. if (!test_bit(__I40E_DOWN, &pf->state)) {
  751. /* Give it a little more time to try to come back */
  752. msleep(75);
  753. if (!test_bit(__I40E_DOWN, &pf->state))
  754. return i40e_nway_reset(netdev);
  755. }
  756. return err;
  757. }
  758. static u32 i40e_get_msglevel(struct net_device *netdev)
  759. {
  760. struct i40e_netdev_priv *np = netdev_priv(netdev);
  761. struct i40e_pf *pf = np->vsi->back;
  762. return pf->msg_enable;
  763. }
  764. static void i40e_set_msglevel(struct net_device *netdev, u32 data)
  765. {
  766. struct i40e_netdev_priv *np = netdev_priv(netdev);
  767. struct i40e_pf *pf = np->vsi->back;
  768. if (I40E_DEBUG_USER & data)
  769. pf->hw.debug_mask = data;
  770. pf->msg_enable = data;
  771. }
  772. static int i40e_get_regs_len(struct net_device *netdev)
  773. {
  774. int reg_count = 0;
  775. int i;
  776. for (i = 0; i40e_reg_list[i].offset != 0; i++)
  777. reg_count += i40e_reg_list[i].elements;
  778. return reg_count * sizeof(u32);
  779. }
  780. static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
  781. void *p)
  782. {
  783. struct i40e_netdev_priv *np = netdev_priv(netdev);
  784. struct i40e_pf *pf = np->vsi->back;
  785. struct i40e_hw *hw = &pf->hw;
  786. u32 *reg_buf = p;
  787. int i, j, ri;
  788. u32 reg;
  789. /* Tell ethtool which driver-version-specific regs output we have.
  790. *
  791. * At some point, if we have ethtool doing special formatting of
  792. * this data, it will rely on this version number to know how to
  793. * interpret things. Hence, this needs to be updated if/when the
  794. * diags register table is changed.
  795. */
  796. regs->version = 1;
  797. /* loop through the diags reg table for what to print */
  798. ri = 0;
  799. for (i = 0; i40e_reg_list[i].offset != 0; i++) {
  800. for (j = 0; j < i40e_reg_list[i].elements; j++) {
  801. reg = i40e_reg_list[i].offset
  802. + (j * i40e_reg_list[i].stride);
  803. reg_buf[ri++] = rd32(hw, reg);
  804. }
  805. }
  806. }
  807. static int i40e_get_eeprom(struct net_device *netdev,
  808. struct ethtool_eeprom *eeprom, u8 *bytes)
  809. {
  810. struct i40e_netdev_priv *np = netdev_priv(netdev);
  811. struct i40e_hw *hw = &np->vsi->back->hw;
  812. struct i40e_pf *pf = np->vsi->back;
  813. int ret_val = 0, len, offset;
  814. u8 *eeprom_buff;
  815. u16 i, sectors;
  816. bool last;
  817. u32 magic;
  818. #define I40E_NVM_SECTOR_SIZE 4096
  819. if (eeprom->len == 0)
  820. return -EINVAL;
  821. /* check for NVMUpdate access method */
  822. magic = hw->vendor_id | (hw->device_id << 16);
  823. if (eeprom->magic && eeprom->magic != magic) {
  824. struct i40e_nvm_access *cmd;
  825. int errno;
  826. /* make sure it is the right magic for NVMUpdate */
  827. if ((eeprom->magic >> 16) != hw->device_id)
  828. return -EINVAL;
  829. cmd = (struct i40e_nvm_access *)eeprom;
  830. ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
  831. if (ret_val &&
  832. ((hw->aq.asq_last_status != I40E_AQ_RC_EACCES) ||
  833. (hw->debug_mask & I40E_DEBUG_NVM)))
  834. dev_info(&pf->pdev->dev,
  835. "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
  836. ret_val, hw->aq.asq_last_status, errno,
  837. (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
  838. cmd->offset, cmd->data_size);
  839. return errno;
  840. }
  841. /* normal ethtool get_eeprom support */
  842. eeprom->magic = hw->vendor_id | (hw->device_id << 16);
  843. eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL);
  844. if (!eeprom_buff)
  845. return -ENOMEM;
  846. ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
  847. if (ret_val) {
  848. dev_info(&pf->pdev->dev,
  849. "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
  850. ret_val, hw->aq.asq_last_status);
  851. goto free_buff;
  852. }
  853. sectors = eeprom->len / I40E_NVM_SECTOR_SIZE;
  854. sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0;
  855. len = I40E_NVM_SECTOR_SIZE;
  856. last = false;
  857. for (i = 0; i < sectors; i++) {
  858. if (i == (sectors - 1)) {
  859. len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
  860. last = true;
  861. }
  862. offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
  863. ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
  864. (u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
  865. last, NULL);
  866. if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
  867. dev_info(&pf->pdev->dev,
  868. "read NVM failed, invalid offset 0x%x\n",
  869. offset);
  870. break;
  871. } else if (ret_val &&
  872. hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
  873. dev_info(&pf->pdev->dev,
  874. "read NVM failed, access, offset 0x%x\n",
  875. offset);
  876. break;
  877. } else if (ret_val) {
  878. dev_info(&pf->pdev->dev,
  879. "read NVM failed offset %d err=%d status=0x%x\n",
  880. offset, ret_val, hw->aq.asq_last_status);
  881. break;
  882. }
  883. }
  884. i40e_release_nvm(hw);
  885. memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
  886. free_buff:
  887. kfree(eeprom_buff);
  888. return ret_val;
  889. }
  890. static int i40e_get_eeprom_len(struct net_device *netdev)
  891. {
  892. struct i40e_netdev_priv *np = netdev_priv(netdev);
  893. struct i40e_hw *hw = &np->vsi->back->hw;
  894. u32 val;
  895. val = (rd32(hw, I40E_GLPCI_LBARCTRL)
  896. & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
  897. >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
  898. /* register returns value in power of 2, 64Kbyte chunks. */
  899. val = (64 * 1024) * (1 << val);
  900. return val;
  901. }
  902. static int i40e_set_eeprom(struct net_device *netdev,
  903. struct ethtool_eeprom *eeprom, u8 *bytes)
  904. {
  905. struct i40e_netdev_priv *np = netdev_priv(netdev);
  906. struct i40e_hw *hw = &np->vsi->back->hw;
  907. struct i40e_pf *pf = np->vsi->back;
  908. struct i40e_nvm_access *cmd;
  909. int ret_val = 0;
  910. int errno;
  911. u32 magic;
  912. /* normal ethtool set_eeprom is not supported */
  913. magic = hw->vendor_id | (hw->device_id << 16);
  914. if (eeprom->magic == magic)
  915. return -EOPNOTSUPP;
  916. /* check for NVMUpdate access method */
  917. if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
  918. return -EINVAL;
  919. if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
  920. test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
  921. return -EBUSY;
  922. cmd = (struct i40e_nvm_access *)eeprom;
  923. ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
  924. if (ret_val &&
  925. ((hw->aq.asq_last_status != I40E_AQ_RC_EPERM &&
  926. hw->aq.asq_last_status != I40E_AQ_RC_EBUSY) ||
  927. (hw->debug_mask & I40E_DEBUG_NVM)))
  928. dev_info(&pf->pdev->dev,
  929. "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
  930. ret_val, hw->aq.asq_last_status, errno,
  931. (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
  932. cmd->offset, cmd->data_size);
  933. return errno;
  934. }
  935. static void i40e_get_drvinfo(struct net_device *netdev,
  936. struct ethtool_drvinfo *drvinfo)
  937. {
  938. struct i40e_netdev_priv *np = netdev_priv(netdev);
  939. struct i40e_vsi *vsi = np->vsi;
  940. struct i40e_pf *pf = vsi->back;
  941. strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
  942. strlcpy(drvinfo->version, i40e_driver_version_str,
  943. sizeof(drvinfo->version));
  944. strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
  945. sizeof(drvinfo->fw_version));
  946. strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
  947. sizeof(drvinfo->bus_info));
  948. drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
  949. }
  950. static void i40e_get_ringparam(struct net_device *netdev,
  951. struct ethtool_ringparam *ring)
  952. {
  953. struct i40e_netdev_priv *np = netdev_priv(netdev);
  954. struct i40e_pf *pf = np->vsi->back;
  955. struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
  956. ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
  957. ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
  958. ring->rx_mini_max_pending = 0;
  959. ring->rx_jumbo_max_pending = 0;
  960. ring->rx_pending = vsi->rx_rings[0]->count;
  961. ring->tx_pending = vsi->tx_rings[0]->count;
  962. ring->rx_mini_pending = 0;
  963. ring->rx_jumbo_pending = 0;
  964. }
  965. static int i40e_set_ringparam(struct net_device *netdev,
  966. struct ethtool_ringparam *ring)
  967. {
  968. struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
  969. struct i40e_netdev_priv *np = netdev_priv(netdev);
  970. struct i40e_vsi *vsi = np->vsi;
  971. struct i40e_pf *pf = vsi->back;
  972. u32 new_rx_count, new_tx_count;
  973. int i, err = 0;
  974. if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
  975. return -EINVAL;
  976. if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
  977. ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
  978. ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
  979. ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
  980. netdev_info(netdev,
  981. "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
  982. ring->tx_pending, ring->rx_pending,
  983. I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
  984. return -EINVAL;
  985. }
  986. new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
  987. new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
  988. /* if nothing to do return success */
  989. if ((new_tx_count == vsi->tx_rings[0]->count) &&
  990. (new_rx_count == vsi->rx_rings[0]->count))
  991. return 0;
  992. while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
  993. usleep_range(1000, 2000);
  994. if (!netif_running(vsi->netdev)) {
  995. /* simple case - set for the next time the netdev is started */
  996. for (i = 0; i < vsi->num_queue_pairs; i++) {
  997. vsi->tx_rings[i]->count = new_tx_count;
  998. vsi->rx_rings[i]->count = new_rx_count;
  999. }
  1000. goto done;
  1001. }
  1002. /* We can't just free everything and then setup again,
  1003. * because the ISRs in MSI-X mode get passed pointers
  1004. * to the Tx and Rx ring structs.
  1005. */
  1006. /* alloc updated Tx resources */
  1007. if (new_tx_count != vsi->tx_rings[0]->count) {
  1008. netdev_info(netdev,
  1009. "Changing Tx descriptor count from %d to %d.\n",
  1010. vsi->tx_rings[0]->count, new_tx_count);
  1011. tx_rings = kcalloc(vsi->alloc_queue_pairs,
  1012. sizeof(struct i40e_ring), GFP_KERNEL);
  1013. if (!tx_rings) {
  1014. err = -ENOMEM;
  1015. goto done;
  1016. }
  1017. for (i = 0; i < vsi->num_queue_pairs; i++) {
  1018. /* clone ring and setup updated count */
  1019. tx_rings[i] = *vsi->tx_rings[i];
  1020. tx_rings[i].count = new_tx_count;
  1021. err = i40e_setup_tx_descriptors(&tx_rings[i]);
  1022. if (err) {
  1023. while (i) {
  1024. i--;
  1025. i40e_free_tx_resources(&tx_rings[i]);
  1026. }
  1027. kfree(tx_rings);
  1028. tx_rings = NULL;
  1029. goto done;
  1030. }
  1031. }
  1032. }
  1033. /* alloc updated Rx resources */
  1034. if (new_rx_count != vsi->rx_rings[0]->count) {
  1035. netdev_info(netdev,
  1036. "Changing Rx descriptor count from %d to %d\n",
  1037. vsi->rx_rings[0]->count, new_rx_count);
  1038. rx_rings = kcalloc(vsi->alloc_queue_pairs,
  1039. sizeof(struct i40e_ring), GFP_KERNEL);
  1040. if (!rx_rings) {
  1041. err = -ENOMEM;
  1042. goto free_tx;
  1043. }
  1044. for (i = 0; i < vsi->num_queue_pairs; i++) {
  1045. /* clone ring and setup updated count */
  1046. rx_rings[i] = *vsi->rx_rings[i];
  1047. rx_rings[i].count = new_rx_count;
  1048. err = i40e_setup_rx_descriptors(&rx_rings[i]);
  1049. if (err) {
  1050. while (i) {
  1051. i--;
  1052. i40e_free_rx_resources(&rx_rings[i]);
  1053. }
  1054. kfree(rx_rings);
  1055. rx_rings = NULL;
  1056. goto free_tx;
  1057. }
  1058. }
  1059. }
  1060. /* Bring interface down, copy in the new ring info,
  1061. * then restore the interface
  1062. */
  1063. i40e_down(vsi);
  1064. if (tx_rings) {
  1065. for (i = 0; i < vsi->num_queue_pairs; i++) {
  1066. i40e_free_tx_resources(vsi->tx_rings[i]);
  1067. *vsi->tx_rings[i] = tx_rings[i];
  1068. }
  1069. kfree(tx_rings);
  1070. tx_rings = NULL;
  1071. }
  1072. if (rx_rings) {
  1073. for (i = 0; i < vsi->num_queue_pairs; i++) {
  1074. i40e_free_rx_resources(vsi->rx_rings[i]);
  1075. *vsi->rx_rings[i] = rx_rings[i];
  1076. }
  1077. kfree(rx_rings);
  1078. rx_rings = NULL;
  1079. }
  1080. i40e_up(vsi);
  1081. free_tx:
  1082. /* error cleanup if the Rx allocations failed after getting Tx */
  1083. if (tx_rings) {
  1084. for (i = 0; i < vsi->num_queue_pairs; i++)
  1085. i40e_free_tx_resources(&tx_rings[i]);
  1086. kfree(tx_rings);
  1087. tx_rings = NULL;
  1088. }
  1089. done:
  1090. clear_bit(__I40E_CONFIG_BUSY, &pf->state);
  1091. return err;
  1092. }
  1093. static int i40e_get_sset_count(struct net_device *netdev, int sset)
  1094. {
  1095. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1096. struct i40e_vsi *vsi = np->vsi;
  1097. struct i40e_pf *pf = vsi->back;
  1098. switch (sset) {
  1099. case ETH_SS_TEST:
  1100. return I40E_TEST_LEN;
  1101. case ETH_SS_STATS:
  1102. if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) {
  1103. int len = I40E_PF_STATS_LEN(netdev);
  1104. if (pf->lan_veb != I40E_NO_VEB)
  1105. len += I40E_VEB_STATS_LEN;
  1106. return len;
  1107. } else {
  1108. return I40E_VSI_STATS_LEN(netdev);
  1109. }
  1110. case ETH_SS_PRIV_FLAGS:
  1111. return I40E_PRIV_FLAGS_STR_LEN;
  1112. default:
  1113. return -EOPNOTSUPP;
  1114. }
  1115. }
  1116. static void i40e_get_ethtool_stats(struct net_device *netdev,
  1117. struct ethtool_stats *stats, u64 *data)
  1118. {
  1119. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1120. struct i40e_ring *tx_ring, *rx_ring;
  1121. struct i40e_vsi *vsi = np->vsi;
  1122. struct i40e_pf *pf = vsi->back;
  1123. int i = 0;
  1124. char *p;
  1125. int j;
  1126. struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
  1127. unsigned int start;
  1128. i40e_update_stats(vsi);
  1129. for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
  1130. p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
  1131. data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
  1132. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  1133. }
  1134. for (j = 0; j < I40E_MISC_STATS_LEN; j++) {
  1135. p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset;
  1136. data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat ==
  1137. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  1138. }
  1139. #ifdef I40E_FCOE
  1140. for (j = 0; j < I40E_FCOE_STATS_LEN; j++) {
  1141. p = (char *)vsi + i40e_gstrings_fcoe_stats[j].stat_offset;
  1142. data[i++] = (i40e_gstrings_fcoe_stats[j].sizeof_stat ==
  1143. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  1144. }
  1145. #endif
  1146. rcu_read_lock();
  1147. for (j = 0; j < vsi->num_queue_pairs; j++) {
  1148. tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
  1149. if (!tx_ring)
  1150. continue;
  1151. /* process Tx ring statistics */
  1152. do {
  1153. start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
  1154. data[i] = tx_ring->stats.packets;
  1155. data[i + 1] = tx_ring->stats.bytes;
  1156. } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
  1157. i += 2;
  1158. /* Rx ring is the 2nd half of the queue pair */
  1159. rx_ring = &tx_ring[1];
  1160. do {
  1161. start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
  1162. data[i] = rx_ring->stats.packets;
  1163. data[i + 1] = rx_ring->stats.bytes;
  1164. } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
  1165. i += 2;
  1166. }
  1167. rcu_read_unlock();
  1168. if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
  1169. return;
  1170. if (pf->lan_veb != I40E_NO_VEB) {
  1171. struct i40e_veb *veb = pf->veb[pf->lan_veb];
  1172. for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
  1173. p = (char *)veb;
  1174. p += i40e_gstrings_veb_stats[j].stat_offset;
  1175. data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
  1176. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  1177. }
  1178. }
  1179. for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
  1180. p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
  1181. data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
  1182. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  1183. }
  1184. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
  1185. data[i++] = pf->stats.priority_xon_tx[j];
  1186. data[i++] = pf->stats.priority_xoff_tx[j];
  1187. }
  1188. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
  1189. data[i++] = pf->stats.priority_xon_rx[j];
  1190. data[i++] = pf->stats.priority_xoff_rx[j];
  1191. }
  1192. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
  1193. data[i++] = pf->stats.priority_xon_2_xoff[j];
  1194. }
  1195. static void i40e_get_strings(struct net_device *netdev, u32 stringset,
  1196. u8 *data)
  1197. {
  1198. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1199. struct i40e_vsi *vsi = np->vsi;
  1200. struct i40e_pf *pf = vsi->back;
  1201. char *p = (char *)data;
  1202. int i;
  1203. switch (stringset) {
  1204. case ETH_SS_TEST:
  1205. for (i = 0; i < I40E_TEST_LEN; i++) {
  1206. memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
  1207. data += ETH_GSTRING_LEN;
  1208. }
  1209. break;
  1210. case ETH_SS_STATS:
  1211. for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
  1212. snprintf(p, ETH_GSTRING_LEN, "%s",
  1213. i40e_gstrings_net_stats[i].stat_string);
  1214. p += ETH_GSTRING_LEN;
  1215. }
  1216. for (i = 0; i < I40E_MISC_STATS_LEN; i++) {
  1217. snprintf(p, ETH_GSTRING_LEN, "%s",
  1218. i40e_gstrings_misc_stats[i].stat_string);
  1219. p += ETH_GSTRING_LEN;
  1220. }
  1221. #ifdef I40E_FCOE
  1222. for (i = 0; i < I40E_FCOE_STATS_LEN; i++) {
  1223. snprintf(p, ETH_GSTRING_LEN, "%s",
  1224. i40e_gstrings_fcoe_stats[i].stat_string);
  1225. p += ETH_GSTRING_LEN;
  1226. }
  1227. #endif
  1228. for (i = 0; i < vsi->num_queue_pairs; i++) {
  1229. snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
  1230. p += ETH_GSTRING_LEN;
  1231. snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
  1232. p += ETH_GSTRING_LEN;
  1233. snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
  1234. p += ETH_GSTRING_LEN;
  1235. snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
  1236. p += ETH_GSTRING_LEN;
  1237. }
  1238. if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
  1239. return;
  1240. if (pf->lan_veb != I40E_NO_VEB) {
  1241. for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
  1242. snprintf(p, ETH_GSTRING_LEN, "veb.%s",
  1243. i40e_gstrings_veb_stats[i].stat_string);
  1244. p += ETH_GSTRING_LEN;
  1245. }
  1246. }
  1247. for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
  1248. snprintf(p, ETH_GSTRING_LEN, "port.%s",
  1249. i40e_gstrings_stats[i].stat_string);
  1250. p += ETH_GSTRING_LEN;
  1251. }
  1252. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  1253. snprintf(p, ETH_GSTRING_LEN,
  1254. "port.tx_priority_%u_xon", i);
  1255. p += ETH_GSTRING_LEN;
  1256. snprintf(p, ETH_GSTRING_LEN,
  1257. "port.tx_priority_%u_xoff", i);
  1258. p += ETH_GSTRING_LEN;
  1259. }
  1260. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  1261. snprintf(p, ETH_GSTRING_LEN,
  1262. "port.rx_priority_%u_xon", i);
  1263. p += ETH_GSTRING_LEN;
  1264. snprintf(p, ETH_GSTRING_LEN,
  1265. "port.rx_priority_%u_xoff", i);
  1266. p += ETH_GSTRING_LEN;
  1267. }
  1268. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  1269. snprintf(p, ETH_GSTRING_LEN,
  1270. "port.rx_priority_%u_xon_2_xoff", i);
  1271. p += ETH_GSTRING_LEN;
  1272. }
  1273. /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
  1274. break;
  1275. case ETH_SS_PRIV_FLAGS:
  1276. for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
  1277. memcpy(data, i40e_priv_flags_strings[i],
  1278. ETH_GSTRING_LEN);
  1279. data += ETH_GSTRING_LEN;
  1280. }
  1281. break;
  1282. default:
  1283. break;
  1284. }
  1285. }
  1286. static int i40e_get_ts_info(struct net_device *dev,
  1287. struct ethtool_ts_info *info)
  1288. {
  1289. struct i40e_pf *pf = i40e_netdev_to_pf(dev);
  1290. /* only report HW timestamping if PTP is enabled */
  1291. if (!(pf->flags & I40E_FLAG_PTP))
  1292. return ethtool_op_get_ts_info(dev, info);
  1293. info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
  1294. SOF_TIMESTAMPING_RX_SOFTWARE |
  1295. SOF_TIMESTAMPING_SOFTWARE |
  1296. SOF_TIMESTAMPING_TX_HARDWARE |
  1297. SOF_TIMESTAMPING_RX_HARDWARE |
  1298. SOF_TIMESTAMPING_RAW_HARDWARE;
  1299. if (pf->ptp_clock)
  1300. info->phc_index = ptp_clock_index(pf->ptp_clock);
  1301. else
  1302. info->phc_index = -1;
  1303. info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
  1304. info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
  1305. (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
  1306. (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
  1307. (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
  1308. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  1309. (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
  1310. (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
  1311. (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
  1312. (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
  1313. (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
  1314. (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
  1315. (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ);
  1316. return 0;
  1317. }
  1318. static int i40e_link_test(struct net_device *netdev, u64 *data)
  1319. {
  1320. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1321. struct i40e_pf *pf = np->vsi->back;
  1322. netif_info(pf, hw, netdev, "link test\n");
  1323. if (i40e_get_link_status(&pf->hw))
  1324. *data = 0;
  1325. else
  1326. *data = 1;
  1327. return *data;
  1328. }
  1329. static int i40e_reg_test(struct net_device *netdev, u64 *data)
  1330. {
  1331. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1332. struct i40e_pf *pf = np->vsi->back;
  1333. netif_info(pf, hw, netdev, "register test\n");
  1334. *data = i40e_diag_reg_test(&pf->hw);
  1335. return *data;
  1336. }
  1337. static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
  1338. {
  1339. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1340. struct i40e_pf *pf = np->vsi->back;
  1341. netif_info(pf, hw, netdev, "eeprom test\n");
  1342. *data = i40e_diag_eeprom_test(&pf->hw);
  1343. /* forcebly clear the NVM Update state machine */
  1344. pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT;
  1345. return *data;
  1346. }
  1347. static int i40e_intr_test(struct net_device *netdev, u64 *data)
  1348. {
  1349. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1350. struct i40e_pf *pf = np->vsi->back;
  1351. u16 swc_old = pf->sw_int_count;
  1352. netif_info(pf, hw, netdev, "interrupt test\n");
  1353. wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
  1354. (I40E_PFINT_DYN_CTL0_INTENA_MASK |
  1355. I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK |
  1356. I40E_PFINT_DYN_CTL0_ITR_INDX_MASK |
  1357. I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK |
  1358. I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK));
  1359. usleep_range(1000, 2000);
  1360. *data = (swc_old == pf->sw_int_count);
  1361. return *data;
  1362. }
  1363. static int i40e_loopback_test(struct net_device *netdev, u64 *data)
  1364. {
  1365. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1366. struct i40e_pf *pf = np->vsi->back;
  1367. netif_info(pf, hw, netdev, "loopback test not implemented\n");
  1368. *data = 0;
  1369. return *data;
  1370. }
  1371. static void i40e_diag_test(struct net_device *netdev,
  1372. struct ethtool_test *eth_test, u64 *data)
  1373. {
  1374. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1375. bool if_running = netif_running(netdev);
  1376. struct i40e_pf *pf = np->vsi->back;
  1377. if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
  1378. /* Offline tests */
  1379. netif_info(pf, drv, netdev, "offline testing starting\n");
  1380. set_bit(__I40E_TESTING, &pf->state);
  1381. /* If the device is online then take it offline */
  1382. if (if_running)
  1383. /* indicate we're in test mode */
  1384. dev_close(netdev);
  1385. else
  1386. i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
  1387. /* Link test performed before hardware reset
  1388. * so autoneg doesn't interfere with test result
  1389. */
  1390. if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
  1391. eth_test->flags |= ETH_TEST_FL_FAILED;
  1392. if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
  1393. eth_test->flags |= ETH_TEST_FL_FAILED;
  1394. if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
  1395. eth_test->flags |= ETH_TEST_FL_FAILED;
  1396. if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
  1397. eth_test->flags |= ETH_TEST_FL_FAILED;
  1398. /* run reg test last, a reset is required after it */
  1399. if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
  1400. eth_test->flags |= ETH_TEST_FL_FAILED;
  1401. clear_bit(__I40E_TESTING, &pf->state);
  1402. i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
  1403. if (if_running)
  1404. dev_open(netdev);
  1405. } else {
  1406. /* Online tests */
  1407. netif_info(pf, drv, netdev, "online testing starting\n");
  1408. if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
  1409. eth_test->flags |= ETH_TEST_FL_FAILED;
  1410. /* Offline only tests, not run in online; pass by default */
  1411. data[I40E_ETH_TEST_REG] = 0;
  1412. data[I40E_ETH_TEST_EEPROM] = 0;
  1413. data[I40E_ETH_TEST_INTR] = 0;
  1414. data[I40E_ETH_TEST_LOOPBACK] = 0;
  1415. }
  1416. netif_info(pf, drv, netdev, "testing finished\n");
  1417. }
  1418. static void i40e_get_wol(struct net_device *netdev,
  1419. struct ethtool_wolinfo *wol)
  1420. {
  1421. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1422. struct i40e_pf *pf = np->vsi->back;
  1423. struct i40e_hw *hw = &pf->hw;
  1424. u16 wol_nvm_bits;
  1425. /* NVM bit on means WoL disabled for the port */
  1426. i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
  1427. if ((1 << hw->port) & wol_nvm_bits || hw->partition_id != 1) {
  1428. wol->supported = 0;
  1429. wol->wolopts = 0;
  1430. } else {
  1431. wol->supported = WAKE_MAGIC;
  1432. wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0);
  1433. }
  1434. }
  1435. /**
  1436. * i40e_set_wol - set the WakeOnLAN configuration
  1437. * @netdev: the netdev in question
  1438. * @wol: the ethtool WoL setting data
  1439. **/
  1440. static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
  1441. {
  1442. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1443. struct i40e_pf *pf = np->vsi->back;
  1444. struct i40e_vsi *vsi = np->vsi;
  1445. struct i40e_hw *hw = &pf->hw;
  1446. u16 wol_nvm_bits;
  1447. /* WoL not supported if this isn't the controlling PF on the port */
  1448. if (hw->partition_id != 1) {
  1449. i40e_partition_setting_complaint(pf);
  1450. return -EOPNOTSUPP;
  1451. }
  1452. if (vsi != pf->vsi[pf->lan_vsi])
  1453. return -EOPNOTSUPP;
  1454. /* NVM bit on means WoL disabled for the port */
  1455. i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
  1456. if (((1 << hw->port) & wol_nvm_bits))
  1457. return -EOPNOTSUPP;
  1458. /* only magic packet is supported */
  1459. if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
  1460. return -EOPNOTSUPP;
  1461. /* is this a new value? */
  1462. if (pf->wol_en != !!wol->wolopts) {
  1463. pf->wol_en = !!wol->wolopts;
  1464. device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en);
  1465. }
  1466. return 0;
  1467. }
  1468. static int i40e_set_phys_id(struct net_device *netdev,
  1469. enum ethtool_phys_id_state state)
  1470. {
  1471. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1472. struct i40e_pf *pf = np->vsi->back;
  1473. struct i40e_hw *hw = &pf->hw;
  1474. int blink_freq = 2;
  1475. switch (state) {
  1476. case ETHTOOL_ID_ACTIVE:
  1477. pf->led_status = i40e_led_get(hw);
  1478. return blink_freq;
  1479. case ETHTOOL_ID_ON:
  1480. i40e_led_set(hw, 0xF, false);
  1481. break;
  1482. case ETHTOOL_ID_OFF:
  1483. i40e_led_set(hw, 0x0, false);
  1484. break;
  1485. case ETHTOOL_ID_INACTIVE:
  1486. i40e_led_set(hw, pf->led_status, false);
  1487. break;
  1488. default:
  1489. break;
  1490. }
  1491. return 0;
  1492. }
  1493. /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
  1494. * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
  1495. * 125us (8000 interrupts per second) == ITR(62)
  1496. */
  1497. static int i40e_get_coalesce(struct net_device *netdev,
  1498. struct ethtool_coalesce *ec)
  1499. {
  1500. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1501. struct i40e_vsi *vsi = np->vsi;
  1502. ec->tx_max_coalesced_frames_irq = vsi->work_limit;
  1503. ec->rx_max_coalesced_frames_irq = vsi->work_limit;
  1504. if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
  1505. ec->use_adaptive_rx_coalesce = 1;
  1506. if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
  1507. ec->use_adaptive_tx_coalesce = 1;
  1508. ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC;
  1509. ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC;
  1510. return 0;
  1511. }
  1512. static int i40e_set_coalesce(struct net_device *netdev,
  1513. struct ethtool_coalesce *ec)
  1514. {
  1515. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1516. struct i40e_q_vector *q_vector;
  1517. struct i40e_vsi *vsi = np->vsi;
  1518. struct i40e_pf *pf = vsi->back;
  1519. struct i40e_hw *hw = &pf->hw;
  1520. u16 vector;
  1521. int i;
  1522. if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
  1523. vsi->work_limit = ec->tx_max_coalesced_frames_irq;
  1524. vector = vsi->base_vector;
  1525. if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
  1526. (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
  1527. vsi->rx_itr_setting = ec->rx_coalesce_usecs;
  1528. } else if (ec->rx_coalesce_usecs == 0) {
  1529. vsi->rx_itr_setting = ec->rx_coalesce_usecs;
  1530. if (ec->use_adaptive_rx_coalesce)
  1531. netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
  1532. } else {
  1533. netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
  1534. return -EINVAL;
  1535. }
  1536. if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
  1537. (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
  1538. vsi->tx_itr_setting = ec->tx_coalesce_usecs;
  1539. } else if (ec->tx_coalesce_usecs == 0) {
  1540. vsi->tx_itr_setting = ec->tx_coalesce_usecs;
  1541. if (ec->use_adaptive_tx_coalesce)
  1542. netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
  1543. } else {
  1544. netif_info(pf, drv, netdev,
  1545. "Invalid value, tx-usecs range is 0-8160\n");
  1546. return -EINVAL;
  1547. }
  1548. if (ec->use_adaptive_rx_coalesce)
  1549. vsi->rx_itr_setting |= I40E_ITR_DYNAMIC;
  1550. else
  1551. vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
  1552. if (ec->use_adaptive_tx_coalesce)
  1553. vsi->tx_itr_setting |= I40E_ITR_DYNAMIC;
  1554. else
  1555. vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
  1556. for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
  1557. q_vector = vsi->q_vectors[i];
  1558. q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
  1559. wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
  1560. q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
  1561. wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
  1562. i40e_flush(hw);
  1563. }
  1564. return 0;
  1565. }
  1566. /**
  1567. * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
  1568. * @pf: pointer to the physical function struct
  1569. * @cmd: ethtool rxnfc command
  1570. *
  1571. * Returns Success if the flow is supported, else Invalid Input.
  1572. **/
  1573. static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
  1574. {
  1575. cmd->data = 0;
  1576. if (pf->vsi[pf->lan_vsi]->rxnfc.data != 0) {
  1577. cmd->data = pf->vsi[pf->lan_vsi]->rxnfc.data;
  1578. cmd->flow_type = pf->vsi[pf->lan_vsi]->rxnfc.flow_type;
  1579. return 0;
  1580. }
  1581. /* Report default options for RSS on i40e */
  1582. switch (cmd->flow_type) {
  1583. case TCP_V4_FLOW:
  1584. case UDP_V4_FLOW:
  1585. cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  1586. /* fall through to add IP fields */
  1587. case SCTP_V4_FLOW:
  1588. case AH_ESP_V4_FLOW:
  1589. case AH_V4_FLOW:
  1590. case ESP_V4_FLOW:
  1591. case IPV4_FLOW:
  1592. cmd->data |= RXH_IP_SRC | RXH_IP_DST;
  1593. break;
  1594. case TCP_V6_FLOW:
  1595. case UDP_V6_FLOW:
  1596. cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  1597. /* fall through to add IP fields */
  1598. case SCTP_V6_FLOW:
  1599. case AH_ESP_V6_FLOW:
  1600. case AH_V6_FLOW:
  1601. case ESP_V6_FLOW:
  1602. case IPV6_FLOW:
  1603. cmd->data |= RXH_IP_SRC | RXH_IP_DST;
  1604. break;
  1605. default:
  1606. return -EINVAL;
  1607. }
  1608. return 0;
  1609. }
  1610. /**
  1611. * i40e_get_ethtool_fdir_all - Populates the rule count of a command
  1612. * @pf: Pointer to the physical function struct
  1613. * @cmd: The command to get or set Rx flow classification rules
  1614. * @rule_locs: Array of used rule locations
  1615. *
  1616. * This function populates both the total and actual rule count of
  1617. * the ethtool flow classification command
  1618. *
  1619. * Returns 0 on success or -EMSGSIZE if entry not found
  1620. **/
  1621. static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
  1622. struct ethtool_rxnfc *cmd,
  1623. u32 *rule_locs)
  1624. {
  1625. struct i40e_fdir_filter *rule;
  1626. struct hlist_node *node2;
  1627. int cnt = 0;
  1628. /* report total rule count */
  1629. cmd->data = i40e_get_fd_cnt_all(pf);
  1630. hlist_for_each_entry_safe(rule, node2,
  1631. &pf->fdir_filter_list, fdir_node) {
  1632. if (cnt == cmd->rule_cnt)
  1633. return -EMSGSIZE;
  1634. rule_locs[cnt] = rule->fd_id;
  1635. cnt++;
  1636. }
  1637. cmd->rule_cnt = cnt;
  1638. return 0;
  1639. }
  1640. /**
  1641. * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
  1642. * @pf: Pointer to the physical function struct
  1643. * @cmd: The command to get or set Rx flow classification rules
  1644. *
  1645. * This function looks up a filter based on the Rx flow classification
  1646. * command and fills the flow spec info for it if found
  1647. *
  1648. * Returns 0 on success or -EINVAL if filter not found
  1649. **/
  1650. static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
  1651. struct ethtool_rxnfc *cmd)
  1652. {
  1653. struct ethtool_rx_flow_spec *fsp =
  1654. (struct ethtool_rx_flow_spec *)&cmd->fs;
  1655. struct i40e_fdir_filter *rule = NULL;
  1656. struct hlist_node *node2;
  1657. hlist_for_each_entry_safe(rule, node2,
  1658. &pf->fdir_filter_list, fdir_node) {
  1659. if (fsp->location <= rule->fd_id)
  1660. break;
  1661. }
  1662. if (!rule || fsp->location != rule->fd_id)
  1663. return -EINVAL;
  1664. fsp->flow_type = rule->flow_type;
  1665. if (fsp->flow_type == IP_USER_FLOW) {
  1666. fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
  1667. fsp->h_u.usr_ip4_spec.proto = 0;
  1668. fsp->m_u.usr_ip4_spec.proto = 0;
  1669. }
  1670. /* Reverse the src and dest notion, since the HW views them from
  1671. * Tx perspective where as the user expects it from Rx filter view.
  1672. */
  1673. fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port;
  1674. fsp->h_u.tcp_ip4_spec.pdst = rule->src_port;
  1675. fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0];
  1676. fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0];
  1677. if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)
  1678. fsp->ring_cookie = RX_CLS_FLOW_DISC;
  1679. else
  1680. fsp->ring_cookie = rule->q_index;
  1681. return 0;
  1682. }
  1683. /**
  1684. * i40e_get_rxnfc - command to get RX flow classification rules
  1685. * @netdev: network interface device structure
  1686. * @cmd: ethtool rxnfc command
  1687. *
  1688. * Returns Success if the command is supported.
  1689. **/
  1690. static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
  1691. u32 *rule_locs)
  1692. {
  1693. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1694. struct i40e_vsi *vsi = np->vsi;
  1695. struct i40e_pf *pf = vsi->back;
  1696. int ret = -EOPNOTSUPP;
  1697. switch (cmd->cmd) {
  1698. case ETHTOOL_GRXRINGS:
  1699. cmd->data = vsi->alloc_queue_pairs;
  1700. ret = 0;
  1701. break;
  1702. case ETHTOOL_GRXFH:
  1703. ret = i40e_get_rss_hash_opts(pf, cmd);
  1704. break;
  1705. case ETHTOOL_GRXCLSRLCNT:
  1706. cmd->rule_cnt = pf->fdir_pf_active_filters;
  1707. /* report total rule count */
  1708. cmd->data = i40e_get_fd_cnt_all(pf);
  1709. ret = 0;
  1710. break;
  1711. case ETHTOOL_GRXCLSRULE:
  1712. ret = i40e_get_ethtool_fdir_entry(pf, cmd);
  1713. break;
  1714. case ETHTOOL_GRXCLSRLALL:
  1715. ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
  1716. break;
  1717. default:
  1718. break;
  1719. }
  1720. return ret;
  1721. }
  1722. /**
  1723. * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
  1724. * @pf: pointer to the physical function struct
  1725. * @cmd: ethtool rxnfc command
  1726. *
  1727. * Returns Success if the flow input set is supported.
  1728. **/
  1729. static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
  1730. {
  1731. struct i40e_hw *hw = &pf->hw;
  1732. u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
  1733. ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
  1734. /* RSS does not support anything other than hashing
  1735. * to queues on src and dst IPs and ports
  1736. */
  1737. if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
  1738. RXH_L4_B_0_1 | RXH_L4_B_2_3))
  1739. return -EINVAL;
  1740. /* We need at least the IP SRC and DEST fields for hashing */
  1741. if (!(nfc->data & RXH_IP_SRC) ||
  1742. !(nfc->data & RXH_IP_DST))
  1743. return -EINVAL;
  1744. switch (nfc->flow_type) {
  1745. case TCP_V4_FLOW:
  1746. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  1747. case 0:
  1748. hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
  1749. break;
  1750. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  1751. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
  1752. break;
  1753. default:
  1754. return -EINVAL;
  1755. }
  1756. break;
  1757. case TCP_V6_FLOW:
  1758. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  1759. case 0:
  1760. hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
  1761. break;
  1762. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  1763. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
  1764. break;
  1765. default:
  1766. return -EINVAL;
  1767. }
  1768. break;
  1769. case UDP_V4_FLOW:
  1770. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  1771. case 0:
  1772. hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
  1773. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
  1774. break;
  1775. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  1776. hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
  1777. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
  1778. break;
  1779. default:
  1780. return -EINVAL;
  1781. }
  1782. break;
  1783. case UDP_V6_FLOW:
  1784. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  1785. case 0:
  1786. hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
  1787. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
  1788. break;
  1789. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  1790. hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
  1791. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
  1792. break;
  1793. default:
  1794. return -EINVAL;
  1795. }
  1796. break;
  1797. case AH_ESP_V4_FLOW:
  1798. case AH_V4_FLOW:
  1799. case ESP_V4_FLOW:
  1800. case SCTP_V4_FLOW:
  1801. if ((nfc->data & RXH_L4_B_0_1) ||
  1802. (nfc->data & RXH_L4_B_2_3))
  1803. return -EINVAL;
  1804. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
  1805. break;
  1806. case AH_ESP_V6_FLOW:
  1807. case AH_V6_FLOW:
  1808. case ESP_V6_FLOW:
  1809. case SCTP_V6_FLOW:
  1810. if ((nfc->data & RXH_L4_B_0_1) ||
  1811. (nfc->data & RXH_L4_B_2_3))
  1812. return -EINVAL;
  1813. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
  1814. break;
  1815. case IPV4_FLOW:
  1816. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
  1817. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4);
  1818. break;
  1819. case IPV6_FLOW:
  1820. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
  1821. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
  1822. break;
  1823. default:
  1824. return -EINVAL;
  1825. }
  1826. wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
  1827. wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
  1828. i40e_flush(hw);
  1829. /* Save setting for future output/update */
  1830. pf->vsi[pf->lan_vsi]->rxnfc = *nfc;
  1831. return 0;
  1832. }
  1833. /**
  1834. * i40e_match_fdir_input_set - Match a new filter against an existing one
  1835. * @rule: The filter already added
  1836. * @input: The new filter to comapre against
  1837. *
  1838. * Returns true if the two input set match
  1839. **/
  1840. static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
  1841. struct i40e_fdir_filter *input)
  1842. {
  1843. if ((rule->dst_ip[0] != input->dst_ip[0]) ||
  1844. (rule->src_ip[0] != input->src_ip[0]) ||
  1845. (rule->dst_port != input->dst_port) ||
  1846. (rule->src_port != input->src_port))
  1847. return false;
  1848. return true;
  1849. }
  1850. /**
  1851. * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
  1852. * @vsi: Pointer to the targeted VSI
  1853. * @input: The filter to update or NULL to indicate deletion
  1854. * @sw_idx: Software index to the filter
  1855. * @cmd: The command to get or set Rx flow classification rules
  1856. *
  1857. * This function updates (or deletes) a Flow Director entry from
  1858. * the hlist of the corresponding PF
  1859. *
  1860. * Returns 0 on success
  1861. **/
  1862. static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
  1863. struct i40e_fdir_filter *input,
  1864. u16 sw_idx,
  1865. struct ethtool_rxnfc *cmd)
  1866. {
  1867. struct i40e_fdir_filter *rule, *parent;
  1868. struct i40e_pf *pf = vsi->back;
  1869. struct hlist_node *node2;
  1870. int err = -EINVAL;
  1871. parent = NULL;
  1872. rule = NULL;
  1873. hlist_for_each_entry_safe(rule, node2,
  1874. &pf->fdir_filter_list, fdir_node) {
  1875. /* hash found, or no matching entry */
  1876. if (rule->fd_id >= sw_idx)
  1877. break;
  1878. parent = rule;
  1879. }
  1880. /* if there is an old rule occupying our place remove it */
  1881. if (rule && (rule->fd_id == sw_idx)) {
  1882. if (input && !i40e_match_fdir_input_set(rule, input))
  1883. err = i40e_add_del_fdir(vsi, rule, false);
  1884. else if (!input)
  1885. err = i40e_add_del_fdir(vsi, rule, false);
  1886. hlist_del(&rule->fdir_node);
  1887. kfree(rule);
  1888. pf->fdir_pf_active_filters--;
  1889. }
  1890. /* If no input this was a delete, err should be 0 if a rule was
  1891. * successfully found and removed from the list else -EINVAL
  1892. */
  1893. if (!input)
  1894. return err;
  1895. /* initialize node and set software index */
  1896. INIT_HLIST_NODE(&input->fdir_node);
  1897. /* add filter to the list */
  1898. if (parent)
  1899. hlist_add_behind(&input->fdir_node, &parent->fdir_node);
  1900. else
  1901. hlist_add_head(&input->fdir_node,
  1902. &pf->fdir_filter_list);
  1903. /* update counts */
  1904. pf->fdir_pf_active_filters++;
  1905. return 0;
  1906. }
  1907. /**
  1908. * i40e_del_fdir_entry - Deletes a Flow Director filter entry
  1909. * @vsi: Pointer to the targeted VSI
  1910. * @cmd: The command to get or set Rx flow classification rules
  1911. *
  1912. * The function removes a Flow Director filter entry from the
  1913. * hlist of the corresponding PF
  1914. *
  1915. * Returns 0 on success
  1916. */
  1917. static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
  1918. struct ethtool_rxnfc *cmd)
  1919. {
  1920. struct ethtool_rx_flow_spec *fsp =
  1921. (struct ethtool_rx_flow_spec *)&cmd->fs;
  1922. struct i40e_pf *pf = vsi->back;
  1923. int ret = 0;
  1924. if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
  1925. test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
  1926. return -EBUSY;
  1927. if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
  1928. return -EBUSY;
  1929. ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
  1930. i40e_fdir_check_and_reenable(pf);
  1931. return ret;
  1932. }
  1933. /**
  1934. * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
  1935. * @vsi: pointer to the targeted VSI
  1936. * @cmd: command to get or set RX flow classification rules
  1937. *
  1938. * Add Flow Director filters for a specific flow spec based on their
  1939. * protocol. Returns 0 if the filters were successfully added.
  1940. **/
  1941. static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
  1942. struct ethtool_rxnfc *cmd)
  1943. {
  1944. struct ethtool_rx_flow_spec *fsp;
  1945. struct i40e_fdir_filter *input;
  1946. struct i40e_pf *pf;
  1947. int ret = -EINVAL;
  1948. if (!vsi)
  1949. return -EINVAL;
  1950. pf = vsi->back;
  1951. if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
  1952. return -EOPNOTSUPP;
  1953. if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)
  1954. return -ENOSPC;
  1955. if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
  1956. test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
  1957. return -EBUSY;
  1958. if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
  1959. return -EBUSY;
  1960. fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
  1961. if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
  1962. pf->hw.func_caps.fd_filters_guaranteed)) {
  1963. return -EINVAL;
  1964. }
  1965. if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
  1966. (fsp->ring_cookie >= vsi->num_queue_pairs))
  1967. return -EINVAL;
  1968. input = kzalloc(sizeof(*input), GFP_KERNEL);
  1969. if (!input)
  1970. return -ENOMEM;
  1971. input->fd_id = fsp->location;
  1972. if (fsp->ring_cookie == RX_CLS_FLOW_DISC)
  1973. input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET;
  1974. else
  1975. input->dest_ctl =
  1976. I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
  1977. input->q_index = fsp->ring_cookie;
  1978. input->flex_off = 0;
  1979. input->pctype = 0;
  1980. input->dest_vsi = vsi->id;
  1981. input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
  1982. input->cnt_index = pf->fd_sb_cnt_idx;
  1983. input->flow_type = fsp->flow_type;
  1984. input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
  1985. /* Reverse the src and dest notion, since the HW expects them to be from
  1986. * Tx perspective where as the input from user is from Rx filter view.
  1987. */
  1988. input->dst_port = fsp->h_u.tcp_ip4_spec.psrc;
  1989. input->src_port = fsp->h_u.tcp_ip4_spec.pdst;
  1990. input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
  1991. input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
  1992. ret = i40e_add_del_fdir(vsi, input, true);
  1993. if (ret)
  1994. kfree(input);
  1995. else
  1996. i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
  1997. return ret;
  1998. }
  1999. /**
  2000. * i40e_set_rxnfc - command to set RX flow classification rules
  2001. * @netdev: network interface device structure
  2002. * @cmd: ethtool rxnfc command
  2003. *
  2004. * Returns Success if the command is supported.
  2005. **/
  2006. static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
  2007. {
  2008. struct i40e_netdev_priv *np = netdev_priv(netdev);
  2009. struct i40e_vsi *vsi = np->vsi;
  2010. struct i40e_pf *pf = vsi->back;
  2011. int ret = -EOPNOTSUPP;
  2012. switch (cmd->cmd) {
  2013. case ETHTOOL_SRXFH:
  2014. ret = i40e_set_rss_hash_opt(pf, cmd);
  2015. break;
  2016. case ETHTOOL_SRXCLSRLINS:
  2017. ret = i40e_add_fdir_ethtool(vsi, cmd);
  2018. break;
  2019. case ETHTOOL_SRXCLSRLDEL:
  2020. ret = i40e_del_fdir_entry(vsi, cmd);
  2021. break;
  2022. default:
  2023. break;
  2024. }
  2025. return ret;
  2026. }
  2027. /**
  2028. * i40e_max_channels - get Max number of combined channels supported
  2029. * @vsi: vsi pointer
  2030. **/
  2031. static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
  2032. {
  2033. /* TODO: This code assumes DCB and FD is disabled for now. */
  2034. return vsi->alloc_queue_pairs;
  2035. }
  2036. /**
  2037. * i40e_get_channels - Get the current channels enabled and max supported etc.
  2038. * @netdev: network interface device structure
  2039. * @ch: ethtool channels structure
  2040. *
  2041. * We don't support separate tx and rx queues as channels. The other count
  2042. * represents how many queues are being used for control. max_combined counts
  2043. * how many queue pairs we can support. They may not be mapped 1 to 1 with
  2044. * q_vectors since we support a lot more queue pairs than q_vectors.
  2045. **/
  2046. static void i40e_get_channels(struct net_device *dev,
  2047. struct ethtool_channels *ch)
  2048. {
  2049. struct i40e_netdev_priv *np = netdev_priv(dev);
  2050. struct i40e_vsi *vsi = np->vsi;
  2051. struct i40e_pf *pf = vsi->back;
  2052. /* report maximum channels */
  2053. ch->max_combined = i40e_max_channels(vsi);
  2054. /* report info for other vector */
  2055. ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0;
  2056. ch->max_other = ch->other_count;
  2057. /* Note: This code assumes DCB is disabled for now. */
  2058. ch->combined_count = vsi->num_queue_pairs;
  2059. }
  2060. /**
  2061. * i40e_set_channels - Set the new channels count.
  2062. * @netdev: network interface device structure
  2063. * @ch: ethtool channels structure
  2064. *
  2065. * The new channels count may not be the same as requested by the user
  2066. * since it gets rounded down to a power of 2 value.
  2067. **/
  2068. static int i40e_set_channels(struct net_device *dev,
  2069. struct ethtool_channels *ch)
  2070. {
  2071. struct i40e_netdev_priv *np = netdev_priv(dev);
  2072. unsigned int count = ch->combined_count;
  2073. struct i40e_vsi *vsi = np->vsi;
  2074. struct i40e_pf *pf = vsi->back;
  2075. int new_count;
  2076. /* We do not support setting channels for any other VSI at present */
  2077. if (vsi->type != I40E_VSI_MAIN)
  2078. return -EINVAL;
  2079. /* verify they are not requesting separate vectors */
  2080. if (!count || ch->rx_count || ch->tx_count)
  2081. return -EINVAL;
  2082. /* verify other_count has not changed */
  2083. if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0))
  2084. return -EINVAL;
  2085. /* verify the number of channels does not exceed hardware limits */
  2086. if (count > i40e_max_channels(vsi))
  2087. return -EINVAL;
  2088. /* update feature limits from largest to smallest supported values */
  2089. /* TODO: Flow director limit, DCB etc */
  2090. /* use rss_reconfig to rebuild with new queue count and update traffic
  2091. * class queue mapping
  2092. */
  2093. new_count = i40e_reconfig_rss_queues(pf, count);
  2094. if (new_count > 0)
  2095. return 0;
  2096. else
  2097. return -EINVAL;
  2098. }
  2099. #define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4)
  2100. /**
  2101. * i40e_get_rxfh_key_size - get the RSS hash key size
  2102. * @netdev: network interface device structure
  2103. *
  2104. * Returns the table size.
  2105. **/
  2106. static u32 i40e_get_rxfh_key_size(struct net_device *netdev)
  2107. {
  2108. return I40E_HKEY_ARRAY_SIZE;
  2109. }
  2110. /**
  2111. * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
  2112. * @netdev: network interface device structure
  2113. *
  2114. * Returns the table size.
  2115. **/
  2116. static u32 i40e_get_rxfh_indir_size(struct net_device *netdev)
  2117. {
  2118. return I40E_HLUT_ARRAY_SIZE;
  2119. }
  2120. static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
  2121. u8 *hfunc)
  2122. {
  2123. struct i40e_netdev_priv *np = netdev_priv(netdev);
  2124. struct i40e_vsi *vsi = np->vsi;
  2125. struct i40e_pf *pf = vsi->back;
  2126. struct i40e_hw *hw = &pf->hw;
  2127. u32 reg_val;
  2128. int i, j;
  2129. if (hfunc)
  2130. *hfunc = ETH_RSS_HASH_TOP;
  2131. if (!indir)
  2132. return 0;
  2133. for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
  2134. reg_val = rd32(hw, I40E_PFQF_HLUT(i));
  2135. indir[j++] = reg_val & 0xff;
  2136. indir[j++] = (reg_val >> 8) & 0xff;
  2137. indir[j++] = (reg_val >> 16) & 0xff;
  2138. indir[j++] = (reg_val >> 24) & 0xff;
  2139. }
  2140. if (key) {
  2141. for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
  2142. reg_val = rd32(hw, I40E_PFQF_HKEY(i));
  2143. key[j++] = (u8)(reg_val & 0xff);
  2144. key[j++] = (u8)((reg_val >> 8) & 0xff);
  2145. key[j++] = (u8)((reg_val >> 16) & 0xff);
  2146. key[j++] = (u8)((reg_val >> 24) & 0xff);
  2147. }
  2148. }
  2149. return 0;
  2150. }
  2151. /**
  2152. * i40e_set_rxfh - set the rx flow hash indirection table
  2153. * @netdev: network interface device structure
  2154. * @indir: indirection table
  2155. * @key: hash key
  2156. *
  2157. * Returns -EINVAL if the table specifies an inavlid queue id, otherwise
  2158. * returns 0 after programming the table.
  2159. **/
  2160. static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
  2161. const u8 *key, const u8 hfunc)
  2162. {
  2163. struct i40e_netdev_priv *np = netdev_priv(netdev);
  2164. struct i40e_vsi *vsi = np->vsi;
  2165. struct i40e_pf *pf = vsi->back;
  2166. struct i40e_hw *hw = &pf->hw;
  2167. u32 reg_val;
  2168. int i, j;
  2169. if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
  2170. return -EOPNOTSUPP;
  2171. if (!indir)
  2172. return 0;
  2173. for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
  2174. reg_val = indir[j++];
  2175. reg_val |= indir[j++] << 8;
  2176. reg_val |= indir[j++] << 16;
  2177. reg_val |= indir[j++] << 24;
  2178. wr32(hw, I40E_PFQF_HLUT(i), reg_val);
  2179. }
  2180. if (key) {
  2181. for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
  2182. reg_val = key[j++];
  2183. reg_val |= key[j++] << 8;
  2184. reg_val |= key[j++] << 16;
  2185. reg_val |= key[j++] << 24;
  2186. wr32(hw, I40E_PFQF_HKEY(i), reg_val);
  2187. }
  2188. }
  2189. return 0;
  2190. }
  2191. /**
  2192. * i40e_get_priv_flags - report device private flags
  2193. * @dev: network interface device structure
  2194. *
  2195. * The get string set count and the string set should be matched for each
  2196. * flag returned. Add new strings for each flag to the i40e_priv_flags_strings
  2197. * array.
  2198. *
  2199. * Returns a u32 bitmap of flags.
  2200. **/
  2201. static u32 i40e_get_priv_flags(struct net_device *dev)
  2202. {
  2203. struct i40e_netdev_priv *np = netdev_priv(dev);
  2204. struct i40e_vsi *vsi = np->vsi;
  2205. struct i40e_pf *pf = vsi->back;
  2206. u32 ret_flags = 0;
  2207. ret_flags |= pf->hw.func_caps.npar_enable ?
  2208. I40E_PRIV_FLAGS_NPAR_FLAG : 0;
  2209. return ret_flags;
  2210. }
  2211. static const struct ethtool_ops i40e_ethtool_ops = {
  2212. .get_settings = i40e_get_settings,
  2213. .set_settings = i40e_set_settings,
  2214. .get_drvinfo = i40e_get_drvinfo,
  2215. .get_regs_len = i40e_get_regs_len,
  2216. .get_regs = i40e_get_regs,
  2217. .nway_reset = i40e_nway_reset,
  2218. .get_link = ethtool_op_get_link,
  2219. .get_wol = i40e_get_wol,
  2220. .set_wol = i40e_set_wol,
  2221. .set_eeprom = i40e_set_eeprom,
  2222. .get_eeprom_len = i40e_get_eeprom_len,
  2223. .get_eeprom = i40e_get_eeprom,
  2224. .get_ringparam = i40e_get_ringparam,
  2225. .set_ringparam = i40e_set_ringparam,
  2226. .get_pauseparam = i40e_get_pauseparam,
  2227. .set_pauseparam = i40e_set_pauseparam,
  2228. .get_msglevel = i40e_get_msglevel,
  2229. .set_msglevel = i40e_set_msglevel,
  2230. .get_rxnfc = i40e_get_rxnfc,
  2231. .set_rxnfc = i40e_set_rxnfc,
  2232. .self_test = i40e_diag_test,
  2233. .get_strings = i40e_get_strings,
  2234. .set_phys_id = i40e_set_phys_id,
  2235. .get_sset_count = i40e_get_sset_count,
  2236. .get_ethtool_stats = i40e_get_ethtool_stats,
  2237. .get_coalesce = i40e_get_coalesce,
  2238. .set_coalesce = i40e_set_coalesce,
  2239. .get_rxfh_key_size = i40e_get_rxfh_key_size,
  2240. .get_rxfh_indir_size = i40e_get_rxfh_indir_size,
  2241. .get_rxfh = i40e_get_rxfh,
  2242. .set_rxfh = i40e_set_rxfh,
  2243. .get_channels = i40e_get_channels,
  2244. .set_channels = i40e_set_channels,
  2245. .get_ts_info = i40e_get_ts_info,
  2246. .get_priv_flags = i40e_get_priv_flags,
  2247. };
  2248. void i40e_set_ethtool_ops(struct net_device *netdev)
  2249. {
  2250. netdev->ethtool_ops = &i40e_ethtool_ops;
  2251. }