ionic_ethtool.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
  3. #include <linux/module.h>
  4. #include <linux/netdevice.h>
  5. #include <linux/sfp.h>
  6. #include "ionic.h"
  7. #include "ionic_bus.h"
  8. #include "ionic_lif.h"
  9. #include "ionic_ethtool.h"
  10. #include "ionic_stats.h"
  11. #define IONIC_MAX_RX_COPYBREAK min(U16_MAX, IONIC_MAX_BUF_LEN)
  12. static void ionic_get_stats_strings(struct ionic_lif *lif, u8 *buf)
  13. {
  14. u32 i;
  15. for (i = 0; i < ionic_num_stats_grps; i++)
  16. ionic_stats_groups[i].get_strings(lif, &buf);
  17. }
  18. static void ionic_get_stats(struct net_device *netdev,
  19. struct ethtool_stats *stats, u64 *buf)
  20. {
  21. struct ionic_lif *lif = netdev_priv(netdev);
  22. u32 i;
  23. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  24. return;
  25. memset(buf, 0, stats->n_stats * sizeof(*buf));
  26. for (i = 0; i < ionic_num_stats_grps; i++)
  27. ionic_stats_groups[i].get_values(lif, &buf);
  28. }
  29. static int ionic_get_stats_count(struct ionic_lif *lif)
  30. {
  31. int i, num_stats = 0;
  32. for (i = 0; i < ionic_num_stats_grps; i++)
  33. num_stats += ionic_stats_groups[i].get_count(lif);
  34. return num_stats;
  35. }
  36. static int ionic_get_sset_count(struct net_device *netdev, int sset)
  37. {
  38. struct ionic_lif *lif = netdev_priv(netdev);
  39. int count = 0;
  40. switch (sset) {
  41. case ETH_SS_STATS:
  42. count = ionic_get_stats_count(lif);
  43. break;
  44. }
  45. return count;
  46. }
  47. static void ionic_get_strings(struct net_device *netdev,
  48. u32 sset, u8 *buf)
  49. {
  50. struct ionic_lif *lif = netdev_priv(netdev);
  51. switch (sset) {
  52. case ETH_SS_STATS:
  53. ionic_get_stats_strings(lif, buf);
  54. break;
  55. }
  56. }
  57. static void ionic_get_drvinfo(struct net_device *netdev,
  58. struct ethtool_drvinfo *drvinfo)
  59. {
  60. struct ionic_lif *lif = netdev_priv(netdev);
  61. struct ionic *ionic = lif->ionic;
  62. strscpy(drvinfo->driver, IONIC_DRV_NAME, sizeof(drvinfo->driver));
  63. strscpy(drvinfo->fw_version, ionic->idev.dev_info.fw_version,
  64. sizeof(drvinfo->fw_version));
  65. strscpy(drvinfo->bus_info, ionic_bus_info(ionic),
  66. sizeof(drvinfo->bus_info));
  67. }
  68. static int ionic_get_regs_len(struct net_device *netdev)
  69. {
  70. return (IONIC_DEV_INFO_REG_COUNT + IONIC_DEV_CMD_REG_COUNT) * sizeof(u32);
  71. }
  72. static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
  73. void *p)
  74. {
  75. struct ionic_lif *lif = netdev_priv(netdev);
  76. struct ionic_dev *idev;
  77. unsigned int offset;
  78. unsigned int size;
  79. regs->version = IONIC_DEV_CMD_REG_VERSION;
  80. idev = &lif->ionic->idev;
  81. if (!idev->dev_info_regs)
  82. return;
  83. offset = 0;
  84. size = IONIC_DEV_INFO_REG_COUNT * sizeof(u32);
  85. memcpy_fromio(p + offset, lif->ionic->idev.dev_info_regs->words, size);
  86. offset += size;
  87. size = IONIC_DEV_CMD_REG_COUNT * sizeof(u32);
  88. memcpy_fromio(p + offset, idev->dev_cmd_regs->words, size);
  89. }
  90. static void ionic_get_link_ext_stats(struct net_device *netdev,
  91. struct ethtool_link_ext_stats *stats)
  92. {
  93. struct ionic_lif *lif = netdev_priv(netdev);
  94. if (lif->ionic->pdev->is_physfn)
  95. stats->link_down_events = lif->link_down_count;
  96. }
  97. static int ionic_get_link_ksettings(struct net_device *netdev,
  98. struct ethtool_link_ksettings *ks)
  99. {
  100. struct ionic_lif *lif = netdev_priv(netdev);
  101. struct ionic_dev *idev = &lif->ionic->idev;
  102. int copper_seen = 0;
  103. ethtool_link_ksettings_zero_link_mode(ks, supported);
  104. if (!idev->port_info) {
  105. netdev_err(netdev, "port_info not initialized\n");
  106. return -EOPNOTSUPP;
  107. }
  108. /* The port_info data is found in a DMA space that the NIC keeps
  109. * up-to-date, so there's no need to request the data from the
  110. * NIC, we already have it in our memory space.
  111. */
  112. switch (le16_to_cpu(idev->port_info->status.xcvr.pid)) {
  113. /* Copper */
  114. case IONIC_XCVR_PID_QSFP_100G_CR4:
  115. ethtool_link_ksettings_add_link_mode(ks, supported,
  116. 100000baseCR4_Full);
  117. copper_seen++;
  118. break;
  119. case IONIC_XCVR_PID_QSFP_40GBASE_CR4:
  120. ethtool_link_ksettings_add_link_mode(ks, supported,
  121. 40000baseCR4_Full);
  122. copper_seen++;
  123. break;
  124. case IONIC_XCVR_PID_SFP_25GBASE_CR_S:
  125. case IONIC_XCVR_PID_SFP_25GBASE_CR_L:
  126. case IONIC_XCVR_PID_SFP_25GBASE_CR_N:
  127. ethtool_link_ksettings_add_link_mode(ks, supported,
  128. 25000baseCR_Full);
  129. copper_seen++;
  130. break;
  131. case IONIC_XCVR_PID_SFP_10GBASE_AOC:
  132. case IONIC_XCVR_PID_SFP_10GBASE_CU:
  133. ethtool_link_ksettings_add_link_mode(ks, supported,
  134. 10000baseCR_Full);
  135. copper_seen++;
  136. break;
  137. /* Fibre */
  138. case IONIC_XCVR_PID_QSFP_100G_SR4:
  139. case IONIC_XCVR_PID_QSFP_100G_AOC:
  140. ethtool_link_ksettings_add_link_mode(ks, supported,
  141. 100000baseSR4_Full);
  142. break;
  143. case IONIC_XCVR_PID_QSFP_100G_CWDM4:
  144. case IONIC_XCVR_PID_QSFP_100G_PSM4:
  145. case IONIC_XCVR_PID_QSFP_100G_LR4:
  146. ethtool_link_ksettings_add_link_mode(ks, supported,
  147. 100000baseLR4_ER4_Full);
  148. break;
  149. case IONIC_XCVR_PID_QSFP_100G_ER4:
  150. ethtool_link_ksettings_add_link_mode(ks, supported,
  151. 100000baseLR4_ER4_Full);
  152. break;
  153. case IONIC_XCVR_PID_QSFP_40GBASE_SR4:
  154. case IONIC_XCVR_PID_QSFP_40GBASE_AOC:
  155. ethtool_link_ksettings_add_link_mode(ks, supported,
  156. 40000baseSR4_Full);
  157. break;
  158. case IONIC_XCVR_PID_QSFP_40GBASE_LR4:
  159. ethtool_link_ksettings_add_link_mode(ks, supported,
  160. 40000baseLR4_Full);
  161. break;
  162. case IONIC_XCVR_PID_SFP_25GBASE_SR:
  163. case IONIC_XCVR_PID_SFP_25GBASE_AOC:
  164. case IONIC_XCVR_PID_SFP_25GBASE_ACC:
  165. ethtool_link_ksettings_add_link_mode(ks, supported,
  166. 25000baseSR_Full);
  167. break;
  168. case IONIC_XCVR_PID_SFP_10GBASE_SR:
  169. ethtool_link_ksettings_add_link_mode(ks, supported,
  170. 10000baseSR_Full);
  171. break;
  172. case IONIC_XCVR_PID_SFP_10GBASE_LR:
  173. ethtool_link_ksettings_add_link_mode(ks, supported,
  174. 10000baseLR_Full);
  175. break;
  176. case IONIC_XCVR_PID_SFP_10GBASE_LRM:
  177. ethtool_link_ksettings_add_link_mode(ks, supported,
  178. 10000baseLRM_Full);
  179. break;
  180. case IONIC_XCVR_PID_SFP_10GBASE_ER:
  181. ethtool_link_ksettings_add_link_mode(ks, supported,
  182. 10000baseER_Full);
  183. break;
  184. case IONIC_XCVR_PID_SFP_10GBASE_T:
  185. ethtool_link_ksettings_add_link_mode(ks, supported,
  186. 10000baseT_Full);
  187. break;
  188. case IONIC_XCVR_PID_SFP_1000BASE_T:
  189. ethtool_link_ksettings_add_link_mode(ks, supported,
  190. 1000baseT_Full);
  191. break;
  192. case IONIC_XCVR_PID_UNKNOWN:
  193. /* This means there's no module plugged in */
  194. break;
  195. default:
  196. dev_info(lif->ionic->dev, "unknown xcvr type pid=%d / 0x%x\n",
  197. idev->port_info->status.xcvr.pid,
  198. idev->port_info->status.xcvr.pid);
  199. break;
  200. }
  201. linkmode_copy(ks->link_modes.advertising, ks->link_modes.supported);
  202. ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);
  203. ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);
  204. if (idev->port_info->config.fec_type == IONIC_PORT_FEC_TYPE_FC)
  205. ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_BASER);
  206. else if (idev->port_info->config.fec_type == IONIC_PORT_FEC_TYPE_RS)
  207. ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);
  208. ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
  209. ethtool_link_ksettings_add_link_mode(ks, supported, Pause);
  210. if (idev->port_info->status.xcvr.phy == IONIC_PHY_TYPE_COPPER ||
  211. copper_seen)
  212. ks->base.port = PORT_DA;
  213. else if (idev->port_info->status.xcvr.phy == IONIC_PHY_TYPE_FIBER)
  214. ks->base.port = PORT_FIBRE;
  215. else
  216. ks->base.port = PORT_NONE;
  217. if (ks->base.port != PORT_NONE) {
  218. ks->base.speed = le32_to_cpu(lif->info->status.link_speed);
  219. if (le16_to_cpu(lif->info->status.link_status))
  220. ks->base.duplex = DUPLEX_FULL;
  221. else
  222. ks->base.duplex = DUPLEX_UNKNOWN;
  223. ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
  224. if (idev->port_info->config.an_enable) {
  225. ethtool_link_ksettings_add_link_mode(ks, advertising,
  226. Autoneg);
  227. ks->base.autoneg = AUTONEG_ENABLE;
  228. }
  229. }
  230. return 0;
  231. }
  232. static int ionic_set_link_ksettings(struct net_device *netdev,
  233. const struct ethtool_link_ksettings *ks)
  234. {
  235. struct ionic_lif *lif = netdev_priv(netdev);
  236. struct ionic_dev *idev = &lif->ionic->idev;
  237. struct ionic *ionic = lif->ionic;
  238. int err = 0;
  239. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  240. return -EBUSY;
  241. /* set autoneg */
  242. if (ks->base.autoneg != idev->port_info->config.an_enable) {
  243. mutex_lock(&ionic->dev_cmd_lock);
  244. ionic_dev_cmd_port_autoneg(idev, ks->base.autoneg);
  245. err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
  246. mutex_unlock(&ionic->dev_cmd_lock);
  247. if (err)
  248. return err;
  249. }
  250. /* set speed */
  251. if (ks->base.speed != le32_to_cpu(idev->port_info->config.speed)) {
  252. mutex_lock(&ionic->dev_cmd_lock);
  253. ionic_dev_cmd_port_speed(idev, ks->base.speed);
  254. err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
  255. mutex_unlock(&ionic->dev_cmd_lock);
  256. if (err)
  257. return err;
  258. }
  259. return 0;
  260. }
  261. static void ionic_get_pauseparam(struct net_device *netdev,
  262. struct ethtool_pauseparam *pause)
  263. {
  264. struct ionic_lif *lif = netdev_priv(netdev);
  265. u8 pause_type;
  266. pause->autoneg = 0;
  267. pause_type = lif->ionic->idev.port_info->config.pause_type;
  268. if (pause_type) {
  269. pause->rx_pause = (pause_type & IONIC_PAUSE_F_RX) ? 1 : 0;
  270. pause->tx_pause = (pause_type & IONIC_PAUSE_F_TX) ? 1 : 0;
  271. }
  272. }
  273. static int ionic_set_pauseparam(struct net_device *netdev,
  274. struct ethtool_pauseparam *pause)
  275. {
  276. struct ionic_lif *lif = netdev_priv(netdev);
  277. struct ionic *ionic = lif->ionic;
  278. u32 requested_pause;
  279. int err;
  280. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  281. return -EBUSY;
  282. if (pause->autoneg)
  283. return -EOPNOTSUPP;
  284. /* change both at the same time */
  285. requested_pause = IONIC_PORT_PAUSE_TYPE_LINK;
  286. if (pause->rx_pause)
  287. requested_pause |= IONIC_PAUSE_F_RX;
  288. if (pause->tx_pause)
  289. requested_pause |= IONIC_PAUSE_F_TX;
  290. if (requested_pause == lif->ionic->idev.port_info->config.pause_type)
  291. return 0;
  292. mutex_lock(&ionic->dev_cmd_lock);
  293. ionic_dev_cmd_port_pause(&lif->ionic->idev, requested_pause);
  294. err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
  295. mutex_unlock(&ionic->dev_cmd_lock);
  296. if (err)
  297. return err;
  298. return 0;
  299. }
  300. static int ionic_get_fecparam(struct net_device *netdev,
  301. struct ethtool_fecparam *fec)
  302. {
  303. struct ionic_lif *lif = netdev_priv(netdev);
  304. switch (lif->ionic->idev.port_info->config.fec_type) {
  305. case IONIC_PORT_FEC_TYPE_NONE:
  306. fec->active_fec = ETHTOOL_FEC_OFF;
  307. break;
  308. case IONIC_PORT_FEC_TYPE_RS:
  309. fec->active_fec = ETHTOOL_FEC_RS;
  310. break;
  311. case IONIC_PORT_FEC_TYPE_FC:
  312. fec->active_fec = ETHTOOL_FEC_BASER;
  313. break;
  314. }
  315. fec->fec = ETHTOOL_FEC_OFF | ETHTOOL_FEC_RS | ETHTOOL_FEC_BASER;
  316. return 0;
  317. }
  318. static int ionic_set_fecparam(struct net_device *netdev,
  319. struct ethtool_fecparam *fec)
  320. {
  321. struct ionic_lif *lif = netdev_priv(netdev);
  322. u8 fec_type;
  323. int ret = 0;
  324. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  325. return -EBUSY;
  326. if (lif->ionic->idev.port_info->config.an_enable) {
  327. netdev_err(netdev, "FEC request not allowed while autoneg is enabled\n");
  328. return -EINVAL;
  329. }
  330. switch (fec->fec) {
  331. case ETHTOOL_FEC_NONE:
  332. fec_type = IONIC_PORT_FEC_TYPE_NONE;
  333. break;
  334. case ETHTOOL_FEC_OFF:
  335. fec_type = IONIC_PORT_FEC_TYPE_NONE;
  336. break;
  337. case ETHTOOL_FEC_RS:
  338. fec_type = IONIC_PORT_FEC_TYPE_RS;
  339. break;
  340. case ETHTOOL_FEC_BASER:
  341. fec_type = IONIC_PORT_FEC_TYPE_FC;
  342. break;
  343. case ETHTOOL_FEC_AUTO:
  344. default:
  345. netdev_err(netdev, "FEC request 0x%04x not supported\n",
  346. fec->fec);
  347. return -EINVAL;
  348. }
  349. if (fec_type != lif->ionic->idev.port_info->config.fec_type) {
  350. mutex_lock(&lif->ionic->dev_cmd_lock);
  351. ionic_dev_cmd_port_fec(&lif->ionic->idev, fec_type);
  352. ret = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT);
  353. mutex_unlock(&lif->ionic->dev_cmd_lock);
  354. }
  355. return ret;
  356. }
  357. static int ionic_get_coalesce(struct net_device *netdev,
  358. struct ethtool_coalesce *coalesce,
  359. struct kernel_ethtool_coalesce *kernel_coal,
  360. struct netlink_ext_ack *extack)
  361. {
  362. struct ionic_lif *lif = netdev_priv(netdev);
  363. coalesce->tx_coalesce_usecs = lif->tx_coalesce_usecs;
  364. coalesce->rx_coalesce_usecs = lif->rx_coalesce_usecs;
  365. if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
  366. coalesce->use_adaptive_tx_coalesce = test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state);
  367. else
  368. coalesce->use_adaptive_tx_coalesce = 0;
  369. coalesce->use_adaptive_rx_coalesce = test_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state);
  370. return 0;
  371. }
  372. static int ionic_set_coalesce(struct net_device *netdev,
  373. struct ethtool_coalesce *coalesce,
  374. struct kernel_ethtool_coalesce *kernel_coal,
  375. struct netlink_ext_ack *extack)
  376. {
  377. struct ionic_lif *lif = netdev_priv(netdev);
  378. struct ionic_identity *ident;
  379. u32 rx_coal, rx_dim;
  380. u32 tx_coal, tx_dim;
  381. unsigned int i;
  382. ident = &lif->ionic->ident;
  383. if (ident->dev.intr_coal_div == 0) {
  384. netdev_warn(netdev, "bad HW value in dev.intr_coal_div = %d\n",
  385. ident->dev.intr_coal_div);
  386. return -EIO;
  387. }
  388. /* Tx normally shares Rx interrupt, so only change Rx if not split */
  389. if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state) &&
  390. (coalesce->tx_coalesce_usecs != lif->rx_coalesce_usecs ||
  391. coalesce->use_adaptive_tx_coalesce)) {
  392. netdev_warn(netdev, "only rx parameters can be changed\n");
  393. return -EINVAL;
  394. }
  395. /* Convert the usec request to a HW usable value. If they asked
  396. * for non-zero and it resolved to zero, bump it up
  397. */
  398. rx_coal = ionic_coal_usec_to_hw(lif->ionic, coalesce->rx_coalesce_usecs);
  399. if (!rx_coal && coalesce->rx_coalesce_usecs)
  400. rx_coal = 1;
  401. tx_coal = ionic_coal_usec_to_hw(lif->ionic, coalesce->tx_coalesce_usecs);
  402. if (!tx_coal && coalesce->tx_coalesce_usecs)
  403. tx_coal = 1;
  404. if (rx_coal > IONIC_INTR_CTRL_COAL_MAX ||
  405. tx_coal > IONIC_INTR_CTRL_COAL_MAX)
  406. return -ERANGE;
  407. /* Save the new values */
  408. lif->rx_coalesce_usecs = coalesce->rx_coalesce_usecs;
  409. lif->rx_coalesce_hw = rx_coal;
  410. if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
  411. lif->tx_coalesce_usecs = coalesce->tx_coalesce_usecs;
  412. else
  413. lif->tx_coalesce_usecs = coalesce->rx_coalesce_usecs;
  414. lif->tx_coalesce_hw = tx_coal;
  415. if (coalesce->use_adaptive_rx_coalesce) {
  416. set_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state);
  417. rx_dim = rx_coal;
  418. } else {
  419. clear_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state);
  420. rx_dim = 0;
  421. }
  422. if (coalesce->use_adaptive_tx_coalesce) {
  423. set_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state);
  424. tx_dim = tx_coal;
  425. } else {
  426. clear_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state);
  427. tx_dim = 0;
  428. }
  429. if (test_bit(IONIC_LIF_F_UP, lif->state)) {
  430. for (i = 0; i < lif->nxqs; i++) {
  431. if (lif->rxqcqs[i]->flags & IONIC_QCQ_F_INTR) {
  432. ionic_intr_coal_init(lif->ionic->idev.intr_ctrl,
  433. lif->rxqcqs[i]->intr.index,
  434. lif->rx_coalesce_hw);
  435. lif->rxqcqs[i]->intr.dim_coal_hw = rx_dim;
  436. }
  437. if (lif->txqcqs[i]->flags & IONIC_QCQ_F_INTR) {
  438. ionic_intr_coal_init(lif->ionic->idev.intr_ctrl,
  439. lif->txqcqs[i]->intr.index,
  440. lif->tx_coalesce_hw);
  441. lif->txqcqs[i]->intr.dim_coal_hw = tx_dim;
  442. }
  443. }
  444. }
  445. return 0;
  446. }
  447. static int ionic_validate_cmb_config(struct ionic_lif *lif,
  448. struct ionic_queue_params *qparam)
  449. {
  450. int pages_have, pages_required = 0;
  451. unsigned long sz;
  452. if (!lif->ionic->idev.cmb_inuse &&
  453. (qparam->cmb_tx || qparam->cmb_rx)) {
  454. netdev_info(lif->netdev, "CMB rings are not supported on this device\n");
  455. return -EOPNOTSUPP;
  456. }
  457. if (qparam->cmb_tx) {
  458. if (!(lif->qtype_info[IONIC_QTYPE_TXQ].features & IONIC_QIDENT_F_CMB)) {
  459. netdev_info(lif->netdev,
  460. "CMB rings for tx-push are not supported on this device\n");
  461. return -EOPNOTSUPP;
  462. }
  463. sz = sizeof(struct ionic_txq_desc) * qparam->ntxq_descs * qparam->nxqs;
  464. pages_required += ALIGN(sz, PAGE_SIZE) / PAGE_SIZE;
  465. }
  466. if (qparam->cmb_rx) {
  467. if (!(lif->qtype_info[IONIC_QTYPE_RXQ].features & IONIC_QIDENT_F_CMB)) {
  468. netdev_info(lif->netdev,
  469. "CMB rings for rx-push are not supported on this device\n");
  470. return -EOPNOTSUPP;
  471. }
  472. sz = sizeof(struct ionic_rxq_desc) * qparam->nrxq_descs * qparam->nxqs;
  473. pages_required += ALIGN(sz, PAGE_SIZE) / PAGE_SIZE;
  474. }
  475. pages_have = lif->ionic->bars[IONIC_PCI_BAR_CMB].len / PAGE_SIZE;
  476. if (pages_required > pages_have) {
  477. netdev_info(lif->netdev,
  478. "Not enough CMB pages for number of queues and size of descriptor rings, need %d have %d",
  479. pages_required, pages_have);
  480. return -ENOMEM;
  481. }
  482. return pages_required;
  483. }
  484. static int ionic_cmb_rings_toggle(struct ionic_lif *lif, bool cmb_tx, bool cmb_rx)
  485. {
  486. struct ionic_queue_params qparam;
  487. int pages_used;
  488. if (netif_running(lif->netdev)) {
  489. netdev_info(lif->netdev, "Please stop device to toggle CMB for tx/rx-push\n");
  490. return -EBUSY;
  491. }
  492. ionic_init_queue_params(lif, &qparam);
  493. qparam.cmb_tx = cmb_tx;
  494. qparam.cmb_rx = cmb_rx;
  495. pages_used = ionic_validate_cmb_config(lif, &qparam);
  496. if (pages_used < 0)
  497. return pages_used;
  498. if (cmb_tx)
  499. set_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state);
  500. else
  501. clear_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state);
  502. if (cmb_rx)
  503. set_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state);
  504. else
  505. clear_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state);
  506. if (cmb_tx || cmb_rx)
  507. netdev_info(lif->netdev, "Enabling CMB %s %s rings - %d pages\n",
  508. cmb_tx ? "TX" : "", cmb_rx ? "RX" : "", pages_used);
  509. else
  510. netdev_info(lif->netdev, "Disabling CMB rings\n");
  511. return 0;
  512. }
  513. static void ionic_get_ringparam(struct net_device *netdev,
  514. struct ethtool_ringparam *ring,
  515. struct kernel_ethtool_ringparam *kernel_ring,
  516. struct netlink_ext_ack *extack)
  517. {
  518. struct ionic_lif *lif = netdev_priv(netdev);
  519. ring->tx_max_pending = IONIC_MAX_TX_DESC;
  520. ring->tx_pending = lif->ntxq_descs;
  521. ring->rx_max_pending = IONIC_MAX_RX_DESC;
  522. ring->rx_pending = lif->nrxq_descs;
  523. kernel_ring->tx_push = test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state);
  524. kernel_ring->rx_push = test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state);
  525. }
  526. static int ionic_set_ringparam(struct net_device *netdev,
  527. struct ethtool_ringparam *ring,
  528. struct kernel_ethtool_ringparam *kernel_ring,
  529. struct netlink_ext_ack *extack)
  530. {
  531. struct ionic_lif *lif = netdev_priv(netdev);
  532. struct ionic_queue_params qparam;
  533. int err;
  534. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  535. return -EBUSY;
  536. ionic_init_queue_params(lif, &qparam);
  537. if (ring->rx_mini_pending || ring->rx_jumbo_pending) {
  538. netdev_info(netdev, "Changing jumbo or mini descriptors not supported\n");
  539. return -EINVAL;
  540. }
  541. if (!is_power_of_2(ring->tx_pending) ||
  542. !is_power_of_2(ring->rx_pending)) {
  543. netdev_info(netdev, "Descriptor count must be a power of 2\n");
  544. return -EINVAL;
  545. }
  546. /* if nothing to do return success */
  547. if (ring->tx_pending == lif->ntxq_descs &&
  548. ring->rx_pending == lif->nrxq_descs &&
  549. kernel_ring->tx_push == test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state) &&
  550. kernel_ring->rx_push == test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state))
  551. return 0;
  552. qparam.ntxq_descs = ring->tx_pending;
  553. qparam.nrxq_descs = ring->rx_pending;
  554. qparam.cmb_tx = kernel_ring->tx_push;
  555. qparam.cmb_rx = kernel_ring->rx_push;
  556. err = ionic_validate_cmb_config(lif, &qparam);
  557. if (err < 0)
  558. return err;
  559. if (kernel_ring->tx_push != test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state) ||
  560. kernel_ring->rx_push != test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state)) {
  561. err = ionic_cmb_rings_toggle(lif, kernel_ring->tx_push,
  562. kernel_ring->rx_push);
  563. if (err < 0)
  564. return err;
  565. }
  566. if (ring->tx_pending != lif->ntxq_descs)
  567. netdev_info(netdev, "Changing Tx ring size from %d to %d\n",
  568. lif->ntxq_descs, ring->tx_pending);
  569. if (ring->rx_pending != lif->nrxq_descs)
  570. netdev_info(netdev, "Changing Rx ring size from %d to %d\n",
  571. lif->nrxq_descs, ring->rx_pending);
  572. /* if we're not running, just set the values and return */
  573. if (!netif_running(lif->netdev)) {
  574. lif->ntxq_descs = ring->tx_pending;
  575. lif->nrxq_descs = ring->rx_pending;
  576. return 0;
  577. }
  578. mutex_lock(&lif->queue_lock);
  579. err = ionic_reconfigure_queues(lif, &qparam);
  580. mutex_unlock(&lif->queue_lock);
  581. if (err)
  582. netdev_info(netdev, "Ring reconfiguration failed, changes canceled: %d\n", err);
  583. return err;
  584. }
  585. static void ionic_get_channels(struct net_device *netdev,
  586. struct ethtool_channels *ch)
  587. {
  588. struct ionic_lif *lif = netdev_priv(netdev);
  589. /* report maximum channels */
  590. ch->max_combined = lif->ionic->ntxqs_per_lif;
  591. ch->max_rx = lif->ionic->ntxqs_per_lif / 2;
  592. ch->max_tx = lif->ionic->ntxqs_per_lif / 2;
  593. /* report current channels */
  594. if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) {
  595. ch->rx_count = lif->nxqs;
  596. ch->tx_count = lif->nxqs;
  597. } else {
  598. ch->combined_count = lif->nxqs;
  599. }
  600. }
  601. static int ionic_set_channels(struct net_device *netdev,
  602. struct ethtool_channels *ch)
  603. {
  604. struct ionic_lif *lif = netdev_priv(netdev);
  605. struct ionic_queue_params qparam;
  606. int max_cnt;
  607. int err;
  608. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  609. return -EBUSY;
  610. ionic_init_queue_params(lif, &qparam);
  611. if ((ch->rx_count || ch->tx_count) && lif->xdp_prog) {
  612. netdev_info(lif->netdev, "Split Tx/Rx interrupts not available when using XDP\n");
  613. return -EOPNOTSUPP;
  614. }
  615. if (ch->rx_count != ch->tx_count) {
  616. netdev_info(netdev, "The rx and tx count must be equal\n");
  617. return -EINVAL;
  618. }
  619. if (ch->combined_count && ch->rx_count) {
  620. netdev_info(netdev, "Use either combined or rx and tx, not both\n");
  621. return -EINVAL;
  622. }
  623. max_cnt = lif->ionic->ntxqs_per_lif;
  624. if (ch->combined_count) {
  625. if (ch->combined_count > max_cnt)
  626. return -EINVAL;
  627. if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
  628. netdev_info(lif->netdev, "Sharing queue interrupts\n");
  629. else if (ch->combined_count == lif->nxqs)
  630. return 0;
  631. if (lif->nxqs != ch->combined_count)
  632. netdev_info(netdev, "Changing queue count from %d to %d\n",
  633. lif->nxqs, ch->combined_count);
  634. qparam.nxqs = ch->combined_count;
  635. qparam.intr_split = false;
  636. } else {
  637. max_cnt /= 2;
  638. if (ch->rx_count > max_cnt)
  639. return -EINVAL;
  640. if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
  641. netdev_info(lif->netdev, "Splitting queue interrupts\n");
  642. else if (ch->rx_count == lif->nxqs)
  643. return 0;
  644. if (lif->nxqs != ch->rx_count)
  645. netdev_info(netdev, "Changing queue count from %d to %d\n",
  646. lif->nxqs, ch->rx_count);
  647. qparam.nxqs = ch->rx_count;
  648. qparam.intr_split = true;
  649. }
  650. err = ionic_validate_cmb_config(lif, &qparam);
  651. if (err < 0)
  652. return err;
  653. /* if we're not running, just set the values and return */
  654. if (!netif_running(lif->netdev)) {
  655. lif->nxqs = qparam.nxqs;
  656. if (qparam.intr_split) {
  657. set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
  658. } else {
  659. clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
  660. lif->tx_coalesce_usecs = lif->rx_coalesce_usecs;
  661. lif->tx_coalesce_hw = lif->rx_coalesce_hw;
  662. }
  663. return 0;
  664. }
  665. mutex_lock(&lif->queue_lock);
  666. err = ionic_reconfigure_queues(lif, &qparam);
  667. mutex_unlock(&lif->queue_lock);
  668. if (err)
  669. netdev_info(netdev, "Queue reconfiguration failed, changes canceled: %d\n", err);
  670. return err;
  671. }
  672. static int ionic_get_rxnfc(struct net_device *netdev,
  673. struct ethtool_rxnfc *info, u32 *rules)
  674. {
  675. struct ionic_lif *lif = netdev_priv(netdev);
  676. int err = 0;
  677. switch (info->cmd) {
  678. case ETHTOOL_GRXRINGS:
  679. info->data = lif->nxqs;
  680. break;
  681. default:
  682. netdev_dbg(netdev, "Command parameter %d is not supported\n",
  683. info->cmd);
  684. err = -EOPNOTSUPP;
  685. }
  686. return err;
  687. }
  688. static u32 ionic_get_rxfh_indir_size(struct net_device *netdev)
  689. {
  690. struct ionic_lif *lif = netdev_priv(netdev);
  691. return le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz);
  692. }
  693. static u32 ionic_get_rxfh_key_size(struct net_device *netdev)
  694. {
  695. return IONIC_RSS_HASH_KEY_SIZE;
  696. }
  697. static int ionic_get_rxfh(struct net_device *netdev,
  698. struct ethtool_rxfh_param *rxfh)
  699. {
  700. struct ionic_lif *lif = netdev_priv(netdev);
  701. unsigned int i, tbl_sz;
  702. if (rxfh->indir) {
  703. tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz);
  704. for (i = 0; i < tbl_sz; i++)
  705. rxfh->indir[i] = lif->rss_ind_tbl[i];
  706. }
  707. if (rxfh->key)
  708. memcpy(rxfh->key, lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE);
  709. rxfh->hfunc = ETH_RSS_HASH_TOP;
  710. return 0;
  711. }
  712. static int ionic_set_rxfh(struct net_device *netdev,
  713. struct ethtool_rxfh_param *rxfh,
  714. struct netlink_ext_ack *extack)
  715. {
  716. struct ionic_lif *lif = netdev_priv(netdev);
  717. if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
  718. rxfh->hfunc != ETH_RSS_HASH_TOP)
  719. return -EOPNOTSUPP;
  720. return ionic_lif_rss_config(lif, lif->rss_types,
  721. rxfh->key, rxfh->indir);
  722. }
  723. static int ionic_set_tunable(struct net_device *dev,
  724. const struct ethtool_tunable *tuna,
  725. const void *data)
  726. {
  727. struct ionic_lif *lif = netdev_priv(dev);
  728. u32 rx_copybreak;
  729. switch (tuna->id) {
  730. case ETHTOOL_RX_COPYBREAK:
  731. rx_copybreak = *(u32 *)data;
  732. if (rx_copybreak > IONIC_MAX_RX_COPYBREAK) {
  733. netdev_err(dev, "Max supported rx_copybreak size: %u\n",
  734. IONIC_MAX_RX_COPYBREAK);
  735. return -EINVAL;
  736. }
  737. lif->rx_copybreak = (u16)rx_copybreak;
  738. break;
  739. default:
  740. return -EOPNOTSUPP;
  741. }
  742. return 0;
  743. }
  744. static int ionic_get_tunable(struct net_device *netdev,
  745. const struct ethtool_tunable *tuna, void *data)
  746. {
  747. struct ionic_lif *lif = netdev_priv(netdev);
  748. switch (tuna->id) {
  749. case ETHTOOL_RX_COPYBREAK:
  750. *(u32 *)data = lif->rx_copybreak;
  751. break;
  752. default:
  753. return -EOPNOTSUPP;
  754. }
  755. return 0;
  756. }
  757. static int ionic_get_module_info(struct net_device *netdev,
  758. struct ethtool_modinfo *modinfo)
  759. {
  760. struct ionic_lif *lif = netdev_priv(netdev);
  761. struct ionic_dev *idev = &lif->ionic->idev;
  762. struct ionic_xcvr_status *xcvr;
  763. struct sfp_eeprom_base *sfp;
  764. xcvr = &idev->port_info->status.xcvr;
  765. sfp = (struct sfp_eeprom_base *) xcvr->sprom;
  766. /* report the module data type and length */
  767. switch (sfp->phys_id) {
  768. case SFF8024_ID_SFP:
  769. modinfo->type = ETH_MODULE_SFF_8079;
  770. modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
  771. break;
  772. case SFF8024_ID_QSFP_8436_8636:
  773. case SFF8024_ID_QSFP28_8636:
  774. modinfo->type = ETH_MODULE_SFF_8436;
  775. modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
  776. break;
  777. default:
  778. netdev_info(netdev, "unknown xcvr type 0x%02x\n",
  779. xcvr->sprom[0]);
  780. modinfo->type = 0;
  781. modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
  782. break;
  783. }
  784. return 0;
  785. }
  786. static int ionic_get_module_eeprom(struct net_device *netdev,
  787. struct ethtool_eeprom *ee,
  788. u8 *data)
  789. {
  790. struct ionic_lif *lif = netdev_priv(netdev);
  791. struct ionic_dev *idev = &lif->ionic->idev;
  792. struct ionic_xcvr_status *xcvr;
  793. char tbuf[sizeof(xcvr->sprom)];
  794. int count = 10;
  795. u32 len;
  796. /* The NIC keeps the module prom up-to-date in the DMA space
  797. * so we can simply copy the module bytes into the data buffer.
  798. */
  799. xcvr = &idev->port_info->status.xcvr;
  800. len = min_t(u32, sizeof(xcvr->sprom), ee->len);
  801. do {
  802. memcpy(data, &xcvr->sprom[ee->offset], len);
  803. memcpy(tbuf, &xcvr->sprom[ee->offset], len);
  804. /* Let's make sure we got a consistent copy */
  805. if (!memcmp(data, tbuf, len))
  806. break;
  807. } while (--count);
  808. if (!count)
  809. return -ETIMEDOUT;
  810. return 0;
  811. }
  812. static int ionic_get_ts_info(struct net_device *netdev,
  813. struct kernel_ethtool_ts_info *info)
  814. {
  815. struct ionic_lif *lif = netdev_priv(netdev);
  816. struct ionic *ionic = lif->ionic;
  817. __le64 mask;
  818. if (!lif->phc || !lif->phc->ptp)
  819. return ethtool_op_get_ts_info(netdev, info);
  820. info->phc_index = ptp_clock_index(lif->phc->ptp);
  821. info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
  822. SOF_TIMESTAMPING_TX_HARDWARE |
  823. SOF_TIMESTAMPING_RX_HARDWARE |
  824. SOF_TIMESTAMPING_RAW_HARDWARE;
  825. /* tx modes */
  826. info->tx_types = BIT(HWTSTAMP_TX_OFF) |
  827. BIT(HWTSTAMP_TX_ON);
  828. mask = cpu_to_le64(BIT_ULL(IONIC_TXSTAMP_ONESTEP_SYNC));
  829. if (ionic->ident.lif.eth.hwstamp_tx_modes & mask)
  830. info->tx_types |= BIT(HWTSTAMP_TX_ONESTEP_SYNC);
  831. mask = cpu_to_le64(BIT_ULL(IONIC_TXSTAMP_ONESTEP_P2P));
  832. if (ionic->ident.lif.eth.hwstamp_tx_modes & mask)
  833. info->tx_types |= BIT(HWTSTAMP_TX_ONESTEP_P2P);
  834. /* rx filters */
  835. info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
  836. BIT(HWTSTAMP_FILTER_ALL);
  837. mask = cpu_to_le64(IONIC_PKT_CLS_NTP_ALL);
  838. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  839. info->rx_filters |= BIT(HWTSTAMP_FILTER_NTP_ALL);
  840. mask = cpu_to_le64(IONIC_PKT_CLS_PTP1_SYNC);
  841. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  842. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC);
  843. mask = cpu_to_le64(IONIC_PKT_CLS_PTP1_DREQ);
  844. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  845. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ);
  846. mask = cpu_to_le64(IONIC_PKT_CLS_PTP1_ALL);
  847. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  848. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT);
  849. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L4_SYNC);
  850. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  851. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L4_SYNC);
  852. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L4_DREQ);
  853. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  854. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ);
  855. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L4_ALL);
  856. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  857. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
  858. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L2_SYNC);
  859. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  860. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L2_SYNC);
  861. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L2_DREQ);
  862. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  863. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ);
  864. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_L2_ALL);
  865. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  866. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT);
  867. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_SYNC);
  868. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  869. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_SYNC);
  870. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_DREQ);
  871. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  872. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
  873. mask = cpu_to_le64(IONIC_PKT_CLS_PTP2_ALL);
  874. if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) == mask)
  875. info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
  876. return 0;
  877. }
  878. static int ionic_nway_reset(struct net_device *netdev)
  879. {
  880. struct ionic_lif *lif = netdev_priv(netdev);
  881. struct ionic *ionic = lif->ionic;
  882. int err = 0;
  883. if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
  884. return -EBUSY;
  885. /* flap the link to force auto-negotiation */
  886. mutex_lock(&ionic->dev_cmd_lock);
  887. ionic_dev_cmd_port_state(&ionic->idev, IONIC_PORT_ADMIN_STATE_DOWN);
  888. err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
  889. if (!err) {
  890. ionic_dev_cmd_port_state(&ionic->idev, IONIC_PORT_ADMIN_STATE_UP);
  891. err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
  892. }
  893. mutex_unlock(&ionic->dev_cmd_lock);
  894. return err;
  895. }
  896. static const struct ethtool_ops ionic_ethtool_ops = {
  897. .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
  898. ETHTOOL_COALESCE_USE_ADAPTIVE_RX |
  899. ETHTOOL_COALESCE_USE_ADAPTIVE_TX,
  900. .supported_ring_params = ETHTOOL_RING_USE_TX_PUSH |
  901. ETHTOOL_RING_USE_RX_PUSH,
  902. .get_drvinfo = ionic_get_drvinfo,
  903. .get_regs_len = ionic_get_regs_len,
  904. .get_regs = ionic_get_regs,
  905. .get_link = ethtool_op_get_link,
  906. .get_link_ext_stats = ionic_get_link_ext_stats,
  907. .get_link_ksettings = ionic_get_link_ksettings,
  908. .set_link_ksettings = ionic_set_link_ksettings,
  909. .get_coalesce = ionic_get_coalesce,
  910. .set_coalesce = ionic_set_coalesce,
  911. .get_ringparam = ionic_get_ringparam,
  912. .set_ringparam = ionic_set_ringparam,
  913. .get_channels = ionic_get_channels,
  914. .set_channels = ionic_set_channels,
  915. .get_strings = ionic_get_strings,
  916. .get_ethtool_stats = ionic_get_stats,
  917. .get_sset_count = ionic_get_sset_count,
  918. .get_rxnfc = ionic_get_rxnfc,
  919. .get_rxfh_indir_size = ionic_get_rxfh_indir_size,
  920. .get_rxfh_key_size = ionic_get_rxfh_key_size,
  921. .get_rxfh = ionic_get_rxfh,
  922. .set_rxfh = ionic_set_rxfh,
  923. .get_tunable = ionic_get_tunable,
  924. .set_tunable = ionic_set_tunable,
  925. .get_module_info = ionic_get_module_info,
  926. .get_module_eeprom = ionic_get_module_eeprom,
  927. .get_pauseparam = ionic_get_pauseparam,
  928. .set_pauseparam = ionic_set_pauseparam,
  929. .get_fecparam = ionic_get_fecparam,
  930. .set_fecparam = ionic_set_fecparam,
  931. .get_ts_info = ionic_get_ts_info,
  932. .nway_reset = ionic_nway_reset,
  933. };
  934. void ionic_ethtool_set_ops(struct net_device *netdev)
  935. {
  936. netdev->ethtool_ops = &ionic_ethtool_ops;
  937. }