i40e_ethtool.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 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 with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * The full GNU General Public License is included in this distribution in
  20. * the file called "COPYING".
  21. *
  22. * Contact Information:
  23. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  24. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  25. *
  26. ******************************************************************************/
  27. /* ethtool support for i40e */
  28. #include "i40e.h"
  29. #include "i40e_diag.h"
  30. struct i40e_stats {
  31. char stat_string[ETH_GSTRING_LEN];
  32. int sizeof_stat;
  33. int stat_offset;
  34. };
  35. #define I40E_STAT(_type, _name, _stat) { \
  36. .stat_string = _name, \
  37. .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
  38. .stat_offset = offsetof(_type, _stat) \
  39. }
  40. #define I40E_NETDEV_STAT(_net_stat) \
  41. I40E_STAT(struct net_device_stats, #_net_stat, _net_stat)
  42. #define I40E_PF_STAT(_name, _stat) \
  43. I40E_STAT(struct i40e_pf, _name, _stat)
  44. #define I40E_VSI_STAT(_name, _stat) \
  45. I40E_STAT(struct i40e_vsi, _name, _stat)
  46. static const struct i40e_stats i40e_gstrings_net_stats[] = {
  47. I40E_NETDEV_STAT(rx_packets),
  48. I40E_NETDEV_STAT(tx_packets),
  49. I40E_NETDEV_STAT(rx_bytes),
  50. I40E_NETDEV_STAT(tx_bytes),
  51. I40E_NETDEV_STAT(rx_errors),
  52. I40E_NETDEV_STAT(tx_errors),
  53. I40E_NETDEV_STAT(rx_dropped),
  54. I40E_NETDEV_STAT(tx_dropped),
  55. I40E_NETDEV_STAT(multicast),
  56. I40E_NETDEV_STAT(collisions),
  57. I40E_NETDEV_STAT(rx_length_errors),
  58. I40E_NETDEV_STAT(rx_crc_errors),
  59. };
  60. /* These PF_STATs might look like duplicates of some NETDEV_STATs,
  61. * but they are separate. This device supports Virtualization, and
  62. * as such might have several netdevs supporting VMDq and FCoE going
  63. * through a single port. The NETDEV_STATs are for individual netdevs
  64. * seen at the top of the stack, and the PF_STATs are for the physical
  65. * function at the bottom of the stack hosting those netdevs.
  66. *
  67. * The PF_STATs are appended to the netdev stats only when ethtool -S
  68. * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
  69. */
  70. static struct i40e_stats i40e_gstrings_stats[] = {
  71. I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
  72. I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
  73. I40E_PF_STAT("rx_errors", stats.eth.rx_errors),
  74. I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
  75. I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
  76. I40E_PF_STAT("tx_dropped", stats.eth.tx_discards),
  77. I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
  78. I40E_PF_STAT("crc_errors", stats.crc_errors),
  79. I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
  80. I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
  81. I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
  82. I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
  83. I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
  84. I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
  85. I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
  86. I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
  87. I40E_PF_STAT("rx_size_64", stats.rx_size_64),
  88. I40E_PF_STAT("rx_size_127", stats.rx_size_127),
  89. I40E_PF_STAT("rx_size_255", stats.rx_size_255),
  90. I40E_PF_STAT("rx_size_511", stats.rx_size_511),
  91. I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
  92. I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
  93. I40E_PF_STAT("rx_size_big", stats.rx_size_big),
  94. I40E_PF_STAT("tx_size_64", stats.tx_size_64),
  95. I40E_PF_STAT("tx_size_127", stats.tx_size_127),
  96. I40E_PF_STAT("tx_size_255", stats.tx_size_255),
  97. I40E_PF_STAT("tx_size_511", stats.tx_size_511),
  98. I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
  99. I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
  100. I40E_PF_STAT("tx_size_big", stats.tx_size_big),
  101. I40E_PF_STAT("rx_undersize", stats.rx_undersize),
  102. I40E_PF_STAT("rx_fragments", stats.rx_fragments),
  103. I40E_PF_STAT("rx_oversize", stats.rx_oversize),
  104. I40E_PF_STAT("rx_jabber", stats.rx_jabber),
  105. I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
  106. };
  107. #define I40E_QUEUE_STATS_LEN(n) \
  108. ((((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs + \
  109. ((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs) * 2)
  110. #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
  111. #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
  112. #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
  113. I40E_QUEUE_STATS_LEN((n)))
  114. #define I40E_PFC_STATS_LEN ( \
  115. (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
  116. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
  117. FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
  118. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
  119. FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
  120. / sizeof(u64))
  121. #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
  122. I40E_PFC_STATS_LEN + \
  123. I40E_VSI_STATS_LEN((n)))
  124. enum i40e_ethtool_test_id {
  125. I40E_ETH_TEST_REG = 0,
  126. I40E_ETH_TEST_EEPROM,
  127. I40E_ETH_TEST_INTR,
  128. I40E_ETH_TEST_LOOPBACK,
  129. I40E_ETH_TEST_LINK,
  130. };
  131. static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
  132. "Register test (offline)",
  133. "Eeprom test (offline)",
  134. "Interrupt test (offline)",
  135. "Loopback test (offline)",
  136. "Link test (on/offline)"
  137. };
  138. #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
  139. /**
  140. * i40e_get_settings - Get Link Speed and Duplex settings
  141. * @netdev: network interface device structure
  142. * @ecmd: ethtool command
  143. *
  144. * Reports speed/duplex settings based on media_type
  145. **/
  146. static int i40e_get_settings(struct net_device *netdev,
  147. struct ethtool_cmd *ecmd)
  148. {
  149. struct i40e_netdev_priv *np = netdev_priv(netdev);
  150. struct i40e_pf *pf = np->vsi->back;
  151. struct i40e_hw *hw = &pf->hw;
  152. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  153. bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
  154. u32 link_speed = hw_link_info->link_speed;
  155. /* hardware is either in 40G mode or 10G mode
  156. * NOTE: this section initializes supported and advertising
  157. */
  158. switch (hw_link_info->phy_type) {
  159. case I40E_PHY_TYPE_40GBASE_CR4:
  160. case I40E_PHY_TYPE_40GBASE_CR4_CU:
  161. ecmd->supported = SUPPORTED_40000baseCR4_Full;
  162. ecmd->advertising = ADVERTISED_40000baseCR4_Full;
  163. break;
  164. case I40E_PHY_TYPE_40GBASE_KR4:
  165. ecmd->supported = SUPPORTED_40000baseKR4_Full;
  166. ecmd->advertising = ADVERTISED_40000baseKR4_Full;
  167. break;
  168. case I40E_PHY_TYPE_40GBASE_SR4:
  169. ecmd->supported = SUPPORTED_40000baseSR4_Full;
  170. ecmd->advertising = ADVERTISED_40000baseSR4_Full;
  171. break;
  172. case I40E_PHY_TYPE_40GBASE_LR4:
  173. ecmd->supported = SUPPORTED_40000baseLR4_Full;
  174. ecmd->advertising = ADVERTISED_40000baseLR4_Full;
  175. break;
  176. case I40E_PHY_TYPE_10GBASE_KX4:
  177. ecmd->supported = SUPPORTED_10000baseKX4_Full;
  178. ecmd->advertising = ADVERTISED_10000baseKX4_Full;
  179. break;
  180. case I40E_PHY_TYPE_10GBASE_KR:
  181. ecmd->supported = SUPPORTED_10000baseKR_Full;
  182. ecmd->advertising = ADVERTISED_10000baseKR_Full;
  183. break;
  184. default:
  185. if (i40e_is_40G_device(hw->device_id)) {
  186. ecmd->supported = SUPPORTED_40000baseSR4_Full;
  187. ecmd->advertising = ADVERTISED_40000baseSR4_Full;
  188. } else {
  189. ecmd->supported = SUPPORTED_10000baseT_Full;
  190. ecmd->advertising = ADVERTISED_10000baseT_Full;
  191. }
  192. break;
  193. }
  194. ecmd->supported |= SUPPORTED_Autoneg;
  195. ecmd->advertising |= ADVERTISED_Autoneg;
  196. ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
  197. AUTONEG_ENABLE : AUTONEG_DISABLE);
  198. switch (hw->phy.media_type) {
  199. case I40E_MEDIA_TYPE_BACKPLANE:
  200. ecmd->supported |= SUPPORTED_Backplane;
  201. ecmd->advertising |= ADVERTISED_Backplane;
  202. ecmd->port = PORT_NONE;
  203. break;
  204. case I40E_MEDIA_TYPE_BASET:
  205. ecmd->supported |= SUPPORTED_TP;
  206. ecmd->advertising |= ADVERTISED_TP;
  207. ecmd->port = PORT_TP;
  208. break;
  209. case I40E_MEDIA_TYPE_DA:
  210. case I40E_MEDIA_TYPE_CX4:
  211. ecmd->supported |= SUPPORTED_FIBRE;
  212. ecmd->advertising |= ADVERTISED_FIBRE;
  213. ecmd->port = PORT_DA;
  214. break;
  215. case I40E_MEDIA_TYPE_FIBER:
  216. ecmd->supported |= SUPPORTED_FIBRE;
  217. ecmd->advertising |= ADVERTISED_FIBRE;
  218. ecmd->port = PORT_FIBRE;
  219. break;
  220. case I40E_MEDIA_TYPE_UNKNOWN:
  221. default:
  222. ecmd->port = PORT_OTHER;
  223. break;
  224. }
  225. ecmd->transceiver = XCVR_EXTERNAL;
  226. if (link_up) {
  227. switch (link_speed) {
  228. case I40E_LINK_SPEED_40GB:
  229. /* need a SPEED_40000 in ethtool.h */
  230. ethtool_cmd_speed_set(ecmd, 40000);
  231. break;
  232. case I40E_LINK_SPEED_10GB:
  233. ethtool_cmd_speed_set(ecmd, SPEED_10000);
  234. break;
  235. default:
  236. break;
  237. }
  238. ecmd->duplex = DUPLEX_FULL;
  239. } else {
  240. ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
  241. ecmd->duplex = DUPLEX_UNKNOWN;
  242. }
  243. return 0;
  244. }
  245. /**
  246. * i40e_get_pauseparam - Get Flow Control status
  247. * Return tx/rx-pause status
  248. **/
  249. static void i40e_get_pauseparam(struct net_device *netdev,
  250. struct ethtool_pauseparam *pause)
  251. {
  252. struct i40e_netdev_priv *np = netdev_priv(netdev);
  253. struct i40e_pf *pf = np->vsi->back;
  254. struct i40e_hw *hw = &pf->hw;
  255. struct i40e_link_status *hw_link_info = &hw->phy.link_info;
  256. pause->autoneg =
  257. ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
  258. AUTONEG_ENABLE : AUTONEG_DISABLE);
  259. if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
  260. pause->rx_pause = 1;
  261. } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
  262. pause->tx_pause = 1;
  263. } else if (hw->fc.current_mode == I40E_FC_FULL) {
  264. pause->rx_pause = 1;
  265. pause->tx_pause = 1;
  266. }
  267. }
  268. static u32 i40e_get_msglevel(struct net_device *netdev)
  269. {
  270. struct i40e_netdev_priv *np = netdev_priv(netdev);
  271. struct i40e_pf *pf = np->vsi->back;
  272. return pf->msg_enable;
  273. }
  274. static void i40e_set_msglevel(struct net_device *netdev, u32 data)
  275. {
  276. struct i40e_netdev_priv *np = netdev_priv(netdev);
  277. struct i40e_pf *pf = np->vsi->back;
  278. if (I40E_DEBUG_USER & data)
  279. pf->hw.debug_mask = data;
  280. pf->msg_enable = data;
  281. }
  282. static int i40e_get_regs_len(struct net_device *netdev)
  283. {
  284. int reg_count = 0;
  285. int i;
  286. for (i = 0; i40e_reg_list[i].offset != 0; i++)
  287. reg_count += i40e_reg_list[i].elements;
  288. return reg_count * sizeof(u32);
  289. }
  290. static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
  291. void *p)
  292. {
  293. struct i40e_netdev_priv *np = netdev_priv(netdev);
  294. struct i40e_pf *pf = np->vsi->back;
  295. struct i40e_hw *hw = &pf->hw;
  296. u32 *reg_buf = p;
  297. int i, j, ri;
  298. u32 reg;
  299. /* Tell ethtool which driver-version-specific regs output we have.
  300. *
  301. * At some point, if we have ethtool doing special formatting of
  302. * this data, it will rely on this version number to know how to
  303. * interpret things. Hence, this needs to be updated if/when the
  304. * diags register table is changed.
  305. */
  306. regs->version = 1;
  307. /* loop through the diags reg table for what to print */
  308. ri = 0;
  309. for (i = 0; i40e_reg_list[i].offset != 0; i++) {
  310. for (j = 0; j < i40e_reg_list[i].elements; j++) {
  311. reg = i40e_reg_list[i].offset
  312. + (j * i40e_reg_list[i].stride);
  313. reg_buf[ri++] = rd32(hw, reg);
  314. }
  315. }
  316. }
  317. static int i40e_get_eeprom(struct net_device *netdev,
  318. struct ethtool_eeprom *eeprom, u8 *bytes)
  319. {
  320. struct i40e_netdev_priv *np = netdev_priv(netdev);
  321. struct i40e_hw *hw = &np->vsi->back->hw;
  322. int first_word, last_word;
  323. u16 i, eeprom_len;
  324. u16 *eeprom_buff;
  325. int ret_val = 0;
  326. if (eeprom->len == 0)
  327. return -EINVAL;
  328. eeprom->magic = hw->vendor_id | (hw->device_id << 16);
  329. first_word = eeprom->offset >> 1;
  330. last_word = (eeprom->offset + eeprom->len - 1) >> 1;
  331. eeprom_len = last_word - first_word + 1;
  332. eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL);
  333. if (!eeprom_buff)
  334. return -ENOMEM;
  335. ret_val = i40e_read_nvm_buffer(hw, first_word, &eeprom_len,
  336. eeprom_buff);
  337. if (eeprom_len == 0) {
  338. kfree(eeprom_buff);
  339. return -EACCES;
  340. }
  341. /* Device's eeprom is always little-endian, word addressable */
  342. for (i = 0; i < eeprom_len; i++)
  343. le16_to_cpus(&eeprom_buff[i]);
  344. memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
  345. kfree(eeprom_buff);
  346. return ret_val;
  347. }
  348. static int i40e_get_eeprom_len(struct net_device *netdev)
  349. {
  350. struct i40e_netdev_priv *np = netdev_priv(netdev);
  351. struct i40e_hw *hw = &np->vsi->back->hw;
  352. return hw->nvm.sr_size * 2;
  353. }
  354. static void i40e_get_drvinfo(struct net_device *netdev,
  355. struct ethtool_drvinfo *drvinfo)
  356. {
  357. struct i40e_netdev_priv *np = netdev_priv(netdev);
  358. struct i40e_vsi *vsi = np->vsi;
  359. struct i40e_pf *pf = vsi->back;
  360. strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
  361. strlcpy(drvinfo->version, i40e_driver_version_str,
  362. sizeof(drvinfo->version));
  363. strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
  364. sizeof(drvinfo->fw_version));
  365. strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
  366. sizeof(drvinfo->bus_info));
  367. }
  368. static void i40e_get_ringparam(struct net_device *netdev,
  369. struct ethtool_ringparam *ring)
  370. {
  371. struct i40e_netdev_priv *np = netdev_priv(netdev);
  372. struct i40e_pf *pf = np->vsi->back;
  373. struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
  374. ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
  375. ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
  376. ring->rx_mini_max_pending = 0;
  377. ring->rx_jumbo_max_pending = 0;
  378. ring->rx_pending = vsi->rx_rings[0]->count;
  379. ring->tx_pending = vsi->tx_rings[0]->count;
  380. ring->rx_mini_pending = 0;
  381. ring->rx_jumbo_pending = 0;
  382. }
  383. static int i40e_set_ringparam(struct net_device *netdev,
  384. struct ethtool_ringparam *ring)
  385. {
  386. struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
  387. struct i40e_netdev_priv *np = netdev_priv(netdev);
  388. struct i40e_vsi *vsi = np->vsi;
  389. struct i40e_pf *pf = vsi->back;
  390. u32 new_rx_count, new_tx_count;
  391. int i, err = 0;
  392. if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
  393. return -EINVAL;
  394. if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
  395. ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
  396. ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
  397. ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
  398. netdev_info(netdev,
  399. "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
  400. ring->tx_pending, ring->rx_pending,
  401. I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
  402. return -EINVAL;
  403. }
  404. new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
  405. new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
  406. /* if nothing to do return success */
  407. if ((new_tx_count == vsi->tx_rings[0]->count) &&
  408. (new_rx_count == vsi->rx_rings[0]->count))
  409. return 0;
  410. while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
  411. usleep_range(1000, 2000);
  412. if (!netif_running(vsi->netdev)) {
  413. /* simple case - set for the next time the netdev is started */
  414. for (i = 0; i < vsi->num_queue_pairs; i++) {
  415. vsi->tx_rings[i]->count = new_tx_count;
  416. vsi->rx_rings[i]->count = new_rx_count;
  417. }
  418. goto done;
  419. }
  420. /* We can't just free everything and then setup again,
  421. * because the ISRs in MSI-X mode get passed pointers
  422. * to the Tx and Rx ring structs.
  423. */
  424. /* alloc updated Tx resources */
  425. if (new_tx_count != vsi->tx_rings[0]->count) {
  426. netdev_info(netdev,
  427. "Changing Tx descriptor count from %d to %d.\n",
  428. vsi->tx_rings[0]->count, new_tx_count);
  429. tx_rings = kcalloc(vsi->alloc_queue_pairs,
  430. sizeof(struct i40e_ring), GFP_KERNEL);
  431. if (!tx_rings) {
  432. err = -ENOMEM;
  433. goto done;
  434. }
  435. for (i = 0; i < vsi->num_queue_pairs; i++) {
  436. /* clone ring and setup updated count */
  437. tx_rings[i] = *vsi->tx_rings[i];
  438. tx_rings[i].count = new_tx_count;
  439. err = i40e_setup_tx_descriptors(&tx_rings[i]);
  440. if (err) {
  441. while (i) {
  442. i--;
  443. i40e_free_tx_resources(&tx_rings[i]);
  444. }
  445. kfree(tx_rings);
  446. tx_rings = NULL;
  447. goto done;
  448. }
  449. }
  450. }
  451. /* alloc updated Rx resources */
  452. if (new_rx_count != vsi->rx_rings[0]->count) {
  453. netdev_info(netdev,
  454. "Changing Rx descriptor count from %d to %d\n",
  455. vsi->rx_rings[0]->count, new_rx_count);
  456. rx_rings = kcalloc(vsi->alloc_queue_pairs,
  457. sizeof(struct i40e_ring), GFP_KERNEL);
  458. if (!rx_rings) {
  459. err = -ENOMEM;
  460. goto free_tx;
  461. }
  462. for (i = 0; i < vsi->num_queue_pairs; i++) {
  463. /* clone ring and setup updated count */
  464. rx_rings[i] = *vsi->rx_rings[i];
  465. rx_rings[i].count = new_rx_count;
  466. err = i40e_setup_rx_descriptors(&rx_rings[i]);
  467. if (err) {
  468. while (i) {
  469. i--;
  470. i40e_free_rx_resources(&rx_rings[i]);
  471. }
  472. kfree(rx_rings);
  473. rx_rings = NULL;
  474. goto free_tx;
  475. }
  476. }
  477. }
  478. /* Bring interface down, copy in the new ring info,
  479. * then restore the interface
  480. */
  481. i40e_down(vsi);
  482. if (tx_rings) {
  483. for (i = 0; i < vsi->num_queue_pairs; i++) {
  484. i40e_free_tx_resources(vsi->tx_rings[i]);
  485. *vsi->tx_rings[i] = tx_rings[i];
  486. }
  487. kfree(tx_rings);
  488. tx_rings = NULL;
  489. }
  490. if (rx_rings) {
  491. for (i = 0; i < vsi->num_queue_pairs; i++) {
  492. i40e_free_rx_resources(vsi->rx_rings[i]);
  493. *vsi->rx_rings[i] = rx_rings[i];
  494. }
  495. kfree(rx_rings);
  496. rx_rings = NULL;
  497. }
  498. i40e_up(vsi);
  499. free_tx:
  500. /* error cleanup if the Rx allocations failed after getting Tx */
  501. if (tx_rings) {
  502. for (i = 0; i < vsi->num_queue_pairs; i++)
  503. i40e_free_tx_resources(&tx_rings[i]);
  504. kfree(tx_rings);
  505. tx_rings = NULL;
  506. }
  507. done:
  508. clear_bit(__I40E_CONFIG_BUSY, &pf->state);
  509. return err;
  510. }
  511. static int i40e_get_sset_count(struct net_device *netdev, int sset)
  512. {
  513. struct i40e_netdev_priv *np = netdev_priv(netdev);
  514. struct i40e_vsi *vsi = np->vsi;
  515. struct i40e_pf *pf = vsi->back;
  516. switch (sset) {
  517. case ETH_SS_TEST:
  518. return I40E_TEST_LEN;
  519. case ETH_SS_STATS:
  520. if (vsi == pf->vsi[pf->lan_vsi])
  521. return I40E_PF_STATS_LEN(netdev);
  522. else
  523. return I40E_VSI_STATS_LEN(netdev);
  524. default:
  525. return -EOPNOTSUPP;
  526. }
  527. }
  528. static void i40e_get_ethtool_stats(struct net_device *netdev,
  529. struct ethtool_stats *stats, u64 *data)
  530. {
  531. struct i40e_netdev_priv *np = netdev_priv(netdev);
  532. struct i40e_vsi *vsi = np->vsi;
  533. struct i40e_pf *pf = vsi->back;
  534. int i = 0;
  535. char *p;
  536. int j;
  537. struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
  538. unsigned int start;
  539. i40e_update_stats(vsi);
  540. for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
  541. p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
  542. data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
  543. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  544. }
  545. rcu_read_lock();
  546. for (j = 0; j < vsi->num_queue_pairs; j++, i += 4) {
  547. struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
  548. struct i40e_ring *rx_ring;
  549. if (!tx_ring)
  550. continue;
  551. /* process Tx ring statistics */
  552. do {
  553. start = u64_stats_fetch_begin_bh(&tx_ring->syncp);
  554. data[i] = tx_ring->stats.packets;
  555. data[i + 1] = tx_ring->stats.bytes;
  556. } while (u64_stats_fetch_retry_bh(&tx_ring->syncp, start));
  557. /* Rx ring is the 2nd half of the queue pair */
  558. rx_ring = &tx_ring[1];
  559. do {
  560. start = u64_stats_fetch_begin_bh(&rx_ring->syncp);
  561. data[i + 2] = rx_ring->stats.packets;
  562. data[i + 3] = rx_ring->stats.bytes;
  563. } while (u64_stats_fetch_retry_bh(&rx_ring->syncp, start));
  564. }
  565. rcu_read_unlock();
  566. if (vsi == pf->vsi[pf->lan_vsi]) {
  567. for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
  568. p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
  569. data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
  570. sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
  571. }
  572. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
  573. data[i++] = pf->stats.priority_xon_tx[j];
  574. data[i++] = pf->stats.priority_xoff_tx[j];
  575. }
  576. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
  577. data[i++] = pf->stats.priority_xon_rx[j];
  578. data[i++] = pf->stats.priority_xoff_rx[j];
  579. }
  580. for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
  581. data[i++] = pf->stats.priority_xon_2_xoff[j];
  582. }
  583. }
  584. static void i40e_get_strings(struct net_device *netdev, u32 stringset,
  585. u8 *data)
  586. {
  587. struct i40e_netdev_priv *np = netdev_priv(netdev);
  588. struct i40e_vsi *vsi = np->vsi;
  589. struct i40e_pf *pf = vsi->back;
  590. char *p = (char *)data;
  591. int i;
  592. switch (stringset) {
  593. case ETH_SS_TEST:
  594. for (i = 0; i < I40E_TEST_LEN; i++) {
  595. memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
  596. data += ETH_GSTRING_LEN;
  597. }
  598. break;
  599. case ETH_SS_STATS:
  600. for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
  601. snprintf(p, ETH_GSTRING_LEN, "%s",
  602. i40e_gstrings_net_stats[i].stat_string);
  603. p += ETH_GSTRING_LEN;
  604. }
  605. for (i = 0; i < vsi->num_queue_pairs; i++) {
  606. snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
  607. p += ETH_GSTRING_LEN;
  608. snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
  609. p += ETH_GSTRING_LEN;
  610. snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
  611. p += ETH_GSTRING_LEN;
  612. snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
  613. p += ETH_GSTRING_LEN;
  614. }
  615. if (vsi == pf->vsi[pf->lan_vsi]) {
  616. for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
  617. snprintf(p, ETH_GSTRING_LEN, "port.%s",
  618. i40e_gstrings_stats[i].stat_string);
  619. p += ETH_GSTRING_LEN;
  620. }
  621. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  622. snprintf(p, ETH_GSTRING_LEN,
  623. "port.tx_priority_%u_xon", i);
  624. p += ETH_GSTRING_LEN;
  625. snprintf(p, ETH_GSTRING_LEN,
  626. "port.tx_priority_%u_xoff", i);
  627. p += ETH_GSTRING_LEN;
  628. }
  629. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  630. snprintf(p, ETH_GSTRING_LEN,
  631. "port.rx_priority_%u_xon", i);
  632. p += ETH_GSTRING_LEN;
  633. snprintf(p, ETH_GSTRING_LEN,
  634. "port.rx_priority_%u_xoff", i);
  635. p += ETH_GSTRING_LEN;
  636. }
  637. for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
  638. snprintf(p, ETH_GSTRING_LEN,
  639. "port.rx_priority_%u_xon_2_xoff", i);
  640. p += ETH_GSTRING_LEN;
  641. }
  642. }
  643. /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
  644. break;
  645. }
  646. }
  647. static int i40e_get_ts_info(struct net_device *dev,
  648. struct ethtool_ts_info *info)
  649. {
  650. return ethtool_op_get_ts_info(dev, info);
  651. }
  652. static int i40e_link_test(struct net_device *netdev, u64 *data)
  653. {
  654. struct i40e_netdev_priv *np = netdev_priv(netdev);
  655. struct i40e_pf *pf = np->vsi->back;
  656. netif_info(pf, hw, netdev, "link test\n");
  657. if (i40e_get_link_status(&pf->hw))
  658. *data = 0;
  659. else
  660. *data = 1;
  661. return *data;
  662. }
  663. static int i40e_reg_test(struct net_device *netdev, u64 *data)
  664. {
  665. struct i40e_netdev_priv *np = netdev_priv(netdev);
  666. struct i40e_pf *pf = np->vsi->back;
  667. netif_info(pf, hw, netdev, "register test\n");
  668. *data = i40e_diag_reg_test(&pf->hw);
  669. return *data;
  670. }
  671. static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
  672. {
  673. struct i40e_netdev_priv *np = netdev_priv(netdev);
  674. struct i40e_pf *pf = np->vsi->back;
  675. netif_info(pf, hw, netdev, "eeprom test\n");
  676. *data = i40e_diag_eeprom_test(&pf->hw);
  677. return *data;
  678. }
  679. static int i40e_intr_test(struct net_device *netdev, u64 *data)
  680. {
  681. struct i40e_netdev_priv *np = netdev_priv(netdev);
  682. struct i40e_pf *pf = np->vsi->back;
  683. u16 swc_old = pf->sw_int_count;
  684. netif_info(pf, hw, netdev, "interrupt test\n");
  685. wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
  686. (I40E_PFINT_DYN_CTL0_INTENA_MASK |
  687. I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK));
  688. usleep_range(1000, 2000);
  689. *data = (swc_old == pf->sw_int_count);
  690. return *data;
  691. }
  692. static int i40e_loopback_test(struct net_device *netdev, u64 *data)
  693. {
  694. struct i40e_netdev_priv *np = netdev_priv(netdev);
  695. struct i40e_pf *pf = np->vsi->back;
  696. netif_info(pf, hw, netdev, "loopback test not implemented\n");
  697. *data = 0;
  698. return *data;
  699. }
  700. static void i40e_diag_test(struct net_device *netdev,
  701. struct ethtool_test *eth_test, u64 *data)
  702. {
  703. struct i40e_netdev_priv *np = netdev_priv(netdev);
  704. struct i40e_pf *pf = np->vsi->back;
  705. if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
  706. /* Offline tests */
  707. netif_info(pf, drv, netdev, "offline testing starting\n");
  708. set_bit(__I40E_TESTING, &pf->state);
  709. /* Link test performed before hardware reset
  710. * so autoneg doesn't interfere with test result
  711. */
  712. if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
  713. eth_test->flags |= ETH_TEST_FL_FAILED;
  714. if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
  715. eth_test->flags |= ETH_TEST_FL_FAILED;
  716. if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
  717. eth_test->flags |= ETH_TEST_FL_FAILED;
  718. if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
  719. eth_test->flags |= ETH_TEST_FL_FAILED;
  720. /* run reg test last, a reset is required after it */
  721. if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
  722. eth_test->flags |= ETH_TEST_FL_FAILED;
  723. clear_bit(__I40E_TESTING, &pf->state);
  724. i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
  725. } else {
  726. /* Online tests */
  727. netif_info(pf, drv, netdev, "online testing starting\n");
  728. if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
  729. eth_test->flags |= ETH_TEST_FL_FAILED;
  730. /* Offline only tests, not run in online; pass by default */
  731. data[I40E_ETH_TEST_REG] = 0;
  732. data[I40E_ETH_TEST_EEPROM] = 0;
  733. data[I40E_ETH_TEST_INTR] = 0;
  734. data[I40E_ETH_TEST_LOOPBACK] = 0;
  735. }
  736. netif_info(pf, drv, netdev, "testing finished\n");
  737. }
  738. static void i40e_get_wol(struct net_device *netdev,
  739. struct ethtool_wolinfo *wol)
  740. {
  741. wol->supported = 0;
  742. wol->wolopts = 0;
  743. }
  744. static int i40e_nway_reset(struct net_device *netdev)
  745. {
  746. /* restart autonegotiation */
  747. struct i40e_netdev_priv *np = netdev_priv(netdev);
  748. struct i40e_pf *pf = np->vsi->back;
  749. struct i40e_hw *hw = &pf->hw;
  750. i40e_status ret = 0;
  751. ret = i40e_aq_set_link_restart_an(hw, NULL);
  752. if (ret) {
  753. netdev_info(netdev, "link restart failed, aq_err=%d\n",
  754. pf->hw.aq.asq_last_status);
  755. return -EIO;
  756. }
  757. return 0;
  758. }
  759. static int i40e_set_phys_id(struct net_device *netdev,
  760. enum ethtool_phys_id_state state)
  761. {
  762. struct i40e_netdev_priv *np = netdev_priv(netdev);
  763. struct i40e_pf *pf = np->vsi->back;
  764. struct i40e_hw *hw = &pf->hw;
  765. int blink_freq = 2;
  766. switch (state) {
  767. case ETHTOOL_ID_ACTIVE:
  768. pf->led_status = i40e_led_get(hw);
  769. return blink_freq;
  770. case ETHTOOL_ID_ON:
  771. i40e_led_set(hw, 0xF);
  772. break;
  773. case ETHTOOL_ID_OFF:
  774. i40e_led_set(hw, 0x0);
  775. break;
  776. case ETHTOOL_ID_INACTIVE:
  777. i40e_led_set(hw, pf->led_status);
  778. break;
  779. }
  780. return 0;
  781. }
  782. /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
  783. * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
  784. * 125us (8000 interrupts per second) == ITR(62)
  785. */
  786. static int i40e_get_coalesce(struct net_device *netdev,
  787. struct ethtool_coalesce *ec)
  788. {
  789. struct i40e_netdev_priv *np = netdev_priv(netdev);
  790. struct i40e_vsi *vsi = np->vsi;
  791. ec->tx_max_coalesced_frames_irq = vsi->work_limit;
  792. ec->rx_max_coalesced_frames_irq = vsi->work_limit;
  793. if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
  794. ec->rx_coalesce_usecs = 1;
  795. else
  796. ec->rx_coalesce_usecs = vsi->rx_itr_setting;
  797. if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
  798. ec->tx_coalesce_usecs = 1;
  799. else
  800. ec->tx_coalesce_usecs = vsi->tx_itr_setting;
  801. return 0;
  802. }
  803. static int i40e_set_coalesce(struct net_device *netdev,
  804. struct ethtool_coalesce *ec)
  805. {
  806. struct i40e_netdev_priv *np = netdev_priv(netdev);
  807. struct i40e_q_vector *q_vector;
  808. struct i40e_vsi *vsi = np->vsi;
  809. struct i40e_pf *pf = vsi->back;
  810. struct i40e_hw *hw = &pf->hw;
  811. u16 vector;
  812. int i;
  813. if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
  814. vsi->work_limit = ec->tx_max_coalesced_frames_irq;
  815. switch (ec->rx_coalesce_usecs) {
  816. case 0:
  817. vsi->rx_itr_setting = 0;
  818. break;
  819. case 1:
  820. vsi->rx_itr_setting = (I40E_ITR_DYNAMIC |
  821. ITR_REG_TO_USEC(I40E_ITR_RX_DEF));
  822. break;
  823. default:
  824. if ((ec->rx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
  825. (ec->rx_coalesce_usecs > (I40E_MAX_ITR << 1)))
  826. return -EINVAL;
  827. vsi->rx_itr_setting = ec->rx_coalesce_usecs;
  828. break;
  829. }
  830. switch (ec->tx_coalesce_usecs) {
  831. case 0:
  832. vsi->tx_itr_setting = 0;
  833. break;
  834. case 1:
  835. vsi->tx_itr_setting = (I40E_ITR_DYNAMIC |
  836. ITR_REG_TO_USEC(I40E_ITR_TX_DEF));
  837. break;
  838. default:
  839. if ((ec->tx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
  840. (ec->tx_coalesce_usecs > (I40E_MAX_ITR << 1)))
  841. return -EINVAL;
  842. vsi->tx_itr_setting = ec->tx_coalesce_usecs;
  843. break;
  844. }
  845. vector = vsi->base_vector;
  846. for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
  847. q_vector = vsi->q_vectors[i];
  848. q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
  849. wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
  850. q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
  851. wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
  852. i40e_flush(hw);
  853. }
  854. return 0;
  855. }
  856. /**
  857. * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
  858. * @pf: pointer to the physical function struct
  859. * @cmd: ethtool rxnfc command
  860. *
  861. * Returns Success if the flow is supported, else Invalid Input.
  862. **/
  863. static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
  864. {
  865. cmd->data = 0;
  866. /* Report default options for RSS on i40e */
  867. switch (cmd->flow_type) {
  868. case TCP_V4_FLOW:
  869. case UDP_V4_FLOW:
  870. cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  871. /* fall through to add IP fields */
  872. case SCTP_V4_FLOW:
  873. case AH_ESP_V4_FLOW:
  874. case AH_V4_FLOW:
  875. case ESP_V4_FLOW:
  876. case IPV4_FLOW:
  877. cmd->data |= RXH_IP_SRC | RXH_IP_DST;
  878. break;
  879. case TCP_V6_FLOW:
  880. case UDP_V6_FLOW:
  881. cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  882. /* fall through to add IP fields */
  883. case SCTP_V6_FLOW:
  884. case AH_ESP_V6_FLOW:
  885. case AH_V6_FLOW:
  886. case ESP_V6_FLOW:
  887. case IPV6_FLOW:
  888. cmd->data |= RXH_IP_SRC | RXH_IP_DST;
  889. break;
  890. default:
  891. return -EINVAL;
  892. }
  893. return 0;
  894. }
  895. /**
  896. * i40e_get_rxnfc - command to get RX flow classification rules
  897. * @netdev: network interface device structure
  898. * @cmd: ethtool rxnfc command
  899. *
  900. * Returns Success if the command is supported.
  901. **/
  902. static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
  903. u32 *rule_locs)
  904. {
  905. struct i40e_netdev_priv *np = netdev_priv(netdev);
  906. struct i40e_vsi *vsi = np->vsi;
  907. struct i40e_pf *pf = vsi->back;
  908. int ret = -EOPNOTSUPP;
  909. switch (cmd->cmd) {
  910. case ETHTOOL_GRXRINGS:
  911. cmd->data = vsi->alloc_queue_pairs;
  912. ret = 0;
  913. break;
  914. case ETHTOOL_GRXFH:
  915. ret = i40e_get_rss_hash_opts(pf, cmd);
  916. break;
  917. case ETHTOOL_GRXCLSRLCNT:
  918. ret = 0;
  919. break;
  920. case ETHTOOL_GRXCLSRULE:
  921. ret = 0;
  922. break;
  923. case ETHTOOL_GRXCLSRLALL:
  924. cmd->data = 500;
  925. ret = 0;
  926. default:
  927. break;
  928. }
  929. return ret;
  930. }
  931. /**
  932. * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
  933. * @pf: pointer to the physical function struct
  934. * @cmd: ethtool rxnfc command
  935. *
  936. * Returns Success if the flow input set is supported.
  937. **/
  938. static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
  939. {
  940. struct i40e_hw *hw = &pf->hw;
  941. u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
  942. ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
  943. /* RSS does not support anything other than hashing
  944. * to queues on src and dst IPs and ports
  945. */
  946. if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
  947. RXH_L4_B_0_1 | RXH_L4_B_2_3))
  948. return -EINVAL;
  949. /* We need at least the IP SRC and DEST fields for hashing */
  950. if (!(nfc->data & RXH_IP_SRC) ||
  951. !(nfc->data & RXH_IP_DST))
  952. return -EINVAL;
  953. switch (nfc->flow_type) {
  954. case TCP_V4_FLOW:
  955. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  956. case 0:
  957. hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
  958. break;
  959. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  960. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
  961. break;
  962. default:
  963. return -EINVAL;
  964. }
  965. break;
  966. case TCP_V6_FLOW:
  967. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  968. case 0:
  969. hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
  970. break;
  971. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  972. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
  973. break;
  974. default:
  975. return -EINVAL;
  976. }
  977. break;
  978. case UDP_V4_FLOW:
  979. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  980. case 0:
  981. hena &=
  982. ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) |
  983. ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) |
  984. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
  985. break;
  986. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  987. hena |=
  988. (((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) |
  989. ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) |
  990. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
  991. break;
  992. default:
  993. return -EINVAL;
  994. }
  995. break;
  996. case UDP_V6_FLOW:
  997. switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
  998. case 0:
  999. hena &=
  1000. ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) |
  1001. ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) |
  1002. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
  1003. break;
  1004. case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
  1005. hena |=
  1006. (((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) |
  1007. ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) |
  1008. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
  1009. break;
  1010. default:
  1011. return -EINVAL;
  1012. }
  1013. break;
  1014. case AH_ESP_V4_FLOW:
  1015. case AH_V4_FLOW:
  1016. case ESP_V4_FLOW:
  1017. case SCTP_V4_FLOW:
  1018. if ((nfc->data & RXH_L4_B_0_1) ||
  1019. (nfc->data & RXH_L4_B_2_3))
  1020. return -EINVAL;
  1021. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
  1022. break;
  1023. case AH_ESP_V6_FLOW:
  1024. case AH_V6_FLOW:
  1025. case ESP_V6_FLOW:
  1026. case SCTP_V6_FLOW:
  1027. if ((nfc->data & RXH_L4_B_0_1) ||
  1028. (nfc->data & RXH_L4_B_2_3))
  1029. return -EINVAL;
  1030. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
  1031. break;
  1032. case IPV4_FLOW:
  1033. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
  1034. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4);
  1035. break;
  1036. case IPV6_FLOW:
  1037. hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
  1038. ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
  1039. break;
  1040. default:
  1041. return -EINVAL;
  1042. }
  1043. wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
  1044. wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
  1045. i40e_flush(hw);
  1046. return 0;
  1047. }
  1048. #define IP_HEADER_OFFSET 14
  1049. /**
  1050. * i40e_add_del_fdir_udpv4 - Add/Remove UDPv4 Flow Director filters for
  1051. * a specific flow spec
  1052. * @vsi: pointer to the targeted VSI
  1053. * @fd_data: the flow director data required from the FDir descriptor
  1054. * @ethtool_rx_flow_spec: the flow spec
  1055. * @add: true adds a filter, false removes it
  1056. *
  1057. * Returns 0 if the filters were successfully added or removed
  1058. **/
  1059. static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,
  1060. struct i40e_fdir_data *fd_data,
  1061. struct ethtool_rx_flow_spec *fsp, bool add)
  1062. {
  1063. struct i40e_pf *pf = vsi->back;
  1064. struct udphdr *udp;
  1065. struct iphdr *ip;
  1066. bool err = false;
  1067. int ret;
  1068. int i;
  1069. ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
  1070. udp = (struct udphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
  1071. + sizeof(struct iphdr));
  1072. ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
  1073. ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
  1074. udp->source = fsp->h_u.tcp_ip4_spec.psrc;
  1075. udp->dest = fsp->h_u.tcp_ip4_spec.pdst;
  1076. for (i = I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP;
  1077. i <= I40E_FILTER_PCTYPE_NONF_IPV4_UDP; i++) {
  1078. fd_data->pctype = i;
  1079. ret = i40e_program_fdir_filter(fd_data, pf, add);
  1080. if (ret) {
  1081. dev_info(&pf->pdev->dev,
  1082. "Filter command send failed for PCTYPE %d (ret = %d)\n",
  1083. fd_data->pctype, ret);
  1084. err = true;
  1085. } else {
  1086. dev_info(&pf->pdev->dev,
  1087. "Filter OK for PCTYPE %d (ret = %d)\n",
  1088. fd_data->pctype, ret);
  1089. }
  1090. }
  1091. return err ? -EOPNOTSUPP : 0;
  1092. }
  1093. /**
  1094. * i40e_add_del_fdir_tcpv4 - Add/Remove TCPv4 Flow Director filters for
  1095. * a specific flow spec
  1096. * @vsi: pointer to the targeted VSI
  1097. * @fd_data: the flow director data required from the FDir descriptor
  1098. * @ethtool_rx_flow_spec: the flow spec
  1099. * @add: true adds a filter, false removes it
  1100. *
  1101. * Returns 0 if the filters were successfully added or removed
  1102. **/
  1103. static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,
  1104. struct i40e_fdir_data *fd_data,
  1105. struct ethtool_rx_flow_spec *fsp, bool add)
  1106. {
  1107. struct i40e_pf *pf = vsi->back;
  1108. struct tcphdr *tcp;
  1109. struct iphdr *ip;
  1110. bool err = false;
  1111. int ret;
  1112. ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
  1113. tcp = (struct tcphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
  1114. + sizeof(struct iphdr));
  1115. ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
  1116. tcp->dest = fsp->h_u.tcp_ip4_spec.pdst;
  1117. fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN;
  1118. ret = i40e_program_fdir_filter(fd_data, pf, add);
  1119. if (ret) {
  1120. dev_info(&pf->pdev->dev,
  1121. "Filter command send failed for PCTYPE %d (ret = %d)\n",
  1122. fd_data->pctype, ret);
  1123. err = true;
  1124. } else {
  1125. dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
  1126. fd_data->pctype, ret);
  1127. }
  1128. ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
  1129. tcp->source = fsp->h_u.tcp_ip4_spec.psrc;
  1130. fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
  1131. ret = i40e_program_fdir_filter(fd_data, pf, add);
  1132. if (ret) {
  1133. dev_info(&pf->pdev->dev,
  1134. "Filter command send failed for PCTYPE %d (ret = %d)\n",
  1135. fd_data->pctype, ret);
  1136. err = true;
  1137. } else {
  1138. dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
  1139. fd_data->pctype, ret);
  1140. }
  1141. return err ? -EOPNOTSUPP : 0;
  1142. }
  1143. /**
  1144. * i40e_add_del_fdir_sctpv4 - Add/Remove SCTPv4 Flow Director filters for
  1145. * a specific flow spec
  1146. * @vsi: pointer to the targeted VSI
  1147. * @fd_data: the flow director data required from the FDir descriptor
  1148. * @ethtool_rx_flow_spec: the flow spec
  1149. * @add: true adds a filter, false removes it
  1150. *
  1151. * Returns 0 if the filters were successfully added or removed
  1152. **/
  1153. static int i40e_add_del_fdir_sctpv4(struct i40e_vsi *vsi,
  1154. struct i40e_fdir_data *fd_data,
  1155. struct ethtool_rx_flow_spec *fsp, bool add)
  1156. {
  1157. return -EOPNOTSUPP;
  1158. }
  1159. /**
  1160. * i40e_add_del_fdir_ipv4 - Add/Remove IPv4 Flow Director filters for
  1161. * a specific flow spec
  1162. * @vsi: pointer to the targeted VSI
  1163. * @fd_data: the flow director data required for the FDir descriptor
  1164. * @fsp: the ethtool flow spec
  1165. * @add: true adds a filter, false removes it
  1166. *
  1167. * Returns 0 if the filters were successfully added or removed
  1168. **/
  1169. static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi,
  1170. struct i40e_fdir_data *fd_data,
  1171. struct ethtool_rx_flow_spec *fsp, bool add)
  1172. {
  1173. struct i40e_pf *pf = vsi->back;
  1174. struct iphdr *ip;
  1175. bool err = false;
  1176. int ret;
  1177. int i;
  1178. ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
  1179. ip->saddr = fsp->h_u.usr_ip4_spec.ip4src;
  1180. ip->daddr = fsp->h_u.usr_ip4_spec.ip4dst;
  1181. ip->protocol = fsp->h_u.usr_ip4_spec.proto;
  1182. for (i = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;
  1183. i <= I40E_FILTER_PCTYPE_FRAG_IPV4; i++) {
  1184. fd_data->pctype = i;
  1185. ret = i40e_program_fdir_filter(fd_data, pf, add);
  1186. if (ret) {
  1187. dev_info(&pf->pdev->dev,
  1188. "Filter command send failed for PCTYPE %d (ret = %d)\n",
  1189. fd_data->pctype, ret);
  1190. err = true;
  1191. } else {
  1192. dev_info(&pf->pdev->dev,
  1193. "Filter OK for PCTYPE %d (ret = %d)\n",
  1194. fd_data->pctype, ret);
  1195. }
  1196. }
  1197. return err ? -EOPNOTSUPP : 0;
  1198. }
  1199. /**
  1200. * i40e_add_del_fdir_ethtool - Add/Remove Flow Director filters for
  1201. * a specific flow spec based on their protocol
  1202. * @vsi: pointer to the targeted VSI
  1203. * @cmd: command to get or set RX flow classification rules
  1204. * @add: true adds a filter, false removes it
  1205. *
  1206. * Returns 0 if the filters were successfully added or removed
  1207. **/
  1208. static int i40e_add_del_fdir_ethtool(struct i40e_vsi *vsi,
  1209. struct ethtool_rxnfc *cmd, bool add)
  1210. {
  1211. struct i40e_fdir_data fd_data;
  1212. int ret = -EINVAL;
  1213. struct i40e_pf *pf;
  1214. struct ethtool_rx_flow_spec *fsp =
  1215. (struct ethtool_rx_flow_spec *)&cmd->fs;
  1216. if (!vsi)
  1217. return -EINVAL;
  1218. pf = vsi->back;
  1219. if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
  1220. (fsp->ring_cookie >= vsi->num_queue_pairs))
  1221. return -EINVAL;
  1222. /* Populate the Flow Director that we have at the moment
  1223. * and allocate the raw packet buffer for the calling functions
  1224. */
  1225. fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
  1226. GFP_KERNEL);
  1227. if (!fd_data.raw_packet) {
  1228. dev_info(&pf->pdev->dev, "Could not allocate memory\n");
  1229. return -ENOMEM;
  1230. }
  1231. fd_data.q_index = fsp->ring_cookie;
  1232. fd_data.flex_off = 0;
  1233. fd_data.pctype = 0;
  1234. fd_data.dest_vsi = vsi->id;
  1235. fd_data.dest_ctl = 0;
  1236. fd_data.fd_status = 0;
  1237. fd_data.cnt_index = 0;
  1238. fd_data.fd_id = 0;
  1239. switch (fsp->flow_type & ~FLOW_EXT) {
  1240. case TCP_V4_FLOW:
  1241. ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add);
  1242. break;
  1243. case UDP_V4_FLOW:
  1244. ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add);
  1245. break;
  1246. case SCTP_V4_FLOW:
  1247. ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add);
  1248. break;
  1249. case IPV4_FLOW:
  1250. ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add);
  1251. break;
  1252. case IP_USER_FLOW:
  1253. switch (fsp->h_u.usr_ip4_spec.proto) {
  1254. case IPPROTO_TCP:
  1255. ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add);
  1256. break;
  1257. case IPPROTO_UDP:
  1258. ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add);
  1259. break;
  1260. case IPPROTO_SCTP:
  1261. ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add);
  1262. break;
  1263. default:
  1264. ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add);
  1265. break;
  1266. }
  1267. break;
  1268. default:
  1269. dev_info(&pf->pdev->dev, "Could not specify spec type\n");
  1270. ret = -EINVAL;
  1271. }
  1272. kfree(fd_data.raw_packet);
  1273. fd_data.raw_packet = NULL;
  1274. return ret;
  1275. }
  1276. /**
  1277. * i40e_set_rxnfc - command to set RX flow classification rules
  1278. * @netdev: network interface device structure
  1279. * @cmd: ethtool rxnfc command
  1280. *
  1281. * Returns Success if the command is supported.
  1282. **/
  1283. static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
  1284. {
  1285. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1286. struct i40e_vsi *vsi = np->vsi;
  1287. struct i40e_pf *pf = vsi->back;
  1288. int ret = -EOPNOTSUPP;
  1289. switch (cmd->cmd) {
  1290. case ETHTOOL_SRXFH:
  1291. ret = i40e_set_rss_hash_opt(pf, cmd);
  1292. break;
  1293. case ETHTOOL_SRXCLSRLINS:
  1294. ret = i40e_add_del_fdir_ethtool(vsi, cmd, true);
  1295. break;
  1296. case ETHTOOL_SRXCLSRLDEL:
  1297. ret = i40e_add_del_fdir_ethtool(vsi, cmd, false);
  1298. break;
  1299. default:
  1300. break;
  1301. }
  1302. return ret;
  1303. }
  1304. /**
  1305. * i40e_max_channels - get Max number of combined channels supported
  1306. * @vsi: vsi pointer
  1307. **/
  1308. static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
  1309. {
  1310. /* TODO: This code assumes DCB and FD is disabled for now. */
  1311. return vsi->alloc_queue_pairs;
  1312. }
  1313. /**
  1314. * i40e_get_channels - Get the current channels enabled and max supported etc.
  1315. * @netdev: network interface device structure
  1316. * @ch: ethtool channels structure
  1317. *
  1318. * We don't support separate tx and rx queues as channels. The other count
  1319. * represents how many queues are being used for control. max_combined counts
  1320. * how many queue pairs we can support. They may not be mapped 1 to 1 with
  1321. * q_vectors since we support a lot more queue pairs than q_vectors.
  1322. **/
  1323. static void i40e_get_channels(struct net_device *dev,
  1324. struct ethtool_channels *ch)
  1325. {
  1326. struct i40e_netdev_priv *np = netdev_priv(dev);
  1327. struct i40e_vsi *vsi = np->vsi;
  1328. struct i40e_pf *pf = vsi->back;
  1329. /* report maximum channels */
  1330. ch->max_combined = i40e_max_channels(vsi);
  1331. /* report info for other vector */
  1332. ch->other_count = (pf->flags & I40E_FLAG_FDIR_ENABLED) ? 1 : 0;
  1333. ch->max_other = ch->other_count;
  1334. /* Note: This code assumes DCB is disabled for now. */
  1335. ch->combined_count = vsi->num_queue_pairs;
  1336. }
  1337. /**
  1338. * i40e_set_channels - Set the new channels count.
  1339. * @netdev: network interface device structure
  1340. * @ch: ethtool channels structure
  1341. *
  1342. * The new channels count may not be the same as requested by the user
  1343. * since it gets rounded down to a power of 2 value.
  1344. **/
  1345. static int i40e_set_channels(struct net_device *dev,
  1346. struct ethtool_channels *ch)
  1347. {
  1348. struct i40e_netdev_priv *np = netdev_priv(dev);
  1349. unsigned int count = ch->combined_count;
  1350. struct i40e_vsi *vsi = np->vsi;
  1351. struct i40e_pf *pf = vsi->back;
  1352. int new_count;
  1353. /* We do not support setting channels for any other VSI at present */
  1354. if (vsi->type != I40E_VSI_MAIN)
  1355. return -EINVAL;
  1356. /* verify they are not requesting separate vectors */
  1357. if (!count || ch->rx_count || ch->tx_count)
  1358. return -EINVAL;
  1359. /* verify other_count has not changed */
  1360. if (ch->other_count != ((pf->flags & I40E_FLAG_FDIR_ENABLED) ? 1 : 0))
  1361. return -EINVAL;
  1362. /* verify the number of channels does not exceed hardware limits */
  1363. if (count > i40e_max_channels(vsi))
  1364. return -EINVAL;
  1365. /* update feature limits from largest to smallest supported values */
  1366. /* TODO: Flow director limit, DCB etc */
  1367. /* cap RSS limit */
  1368. if (count > pf->rss_size_max)
  1369. count = pf->rss_size_max;
  1370. /* use rss_reconfig to rebuild with new queue count and update traffic
  1371. * class queue mapping
  1372. */
  1373. new_count = i40e_reconfig_rss_queues(pf, count);
  1374. if (new_count > 1)
  1375. return 0;
  1376. else
  1377. return -EINVAL;
  1378. }
  1379. static const struct ethtool_ops i40e_ethtool_ops = {
  1380. .get_settings = i40e_get_settings,
  1381. .get_drvinfo = i40e_get_drvinfo,
  1382. .get_regs_len = i40e_get_regs_len,
  1383. .get_regs = i40e_get_regs,
  1384. .nway_reset = i40e_nway_reset,
  1385. .get_link = ethtool_op_get_link,
  1386. .get_wol = i40e_get_wol,
  1387. .get_eeprom_len = i40e_get_eeprom_len,
  1388. .get_eeprom = i40e_get_eeprom,
  1389. .get_ringparam = i40e_get_ringparam,
  1390. .set_ringparam = i40e_set_ringparam,
  1391. .get_pauseparam = i40e_get_pauseparam,
  1392. .get_msglevel = i40e_get_msglevel,
  1393. .set_msglevel = i40e_set_msglevel,
  1394. .get_rxnfc = i40e_get_rxnfc,
  1395. .set_rxnfc = i40e_set_rxnfc,
  1396. .self_test = i40e_diag_test,
  1397. .get_strings = i40e_get_strings,
  1398. .set_phys_id = i40e_set_phys_id,
  1399. .get_sset_count = i40e_get_sset_count,
  1400. .get_ethtool_stats = i40e_get_ethtool_stats,
  1401. .get_coalesce = i40e_get_coalesce,
  1402. .set_coalesce = i40e_set_coalesce,
  1403. .get_channels = i40e_get_channels,
  1404. .set_channels = i40e_set_channels,
  1405. .get_ts_info = i40e_get_ts_info,
  1406. };
  1407. void i40e_set_ethtool_ops(struct net_device *netdev)
  1408. {
  1409. SET_ETHTOOL_OPS(netdev, &i40e_ethtool_ops);
  1410. }