qede_ethtool.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /* QLogic qede NIC Driver
  2. * Copyright (c) 2015 QLogic Corporation
  3. *
  4. * This software is available under the terms of the GNU General Public License
  5. * (GPL) Version 2, available from the file COPYING in the main directory of
  6. * this source tree.
  7. */
  8. #include <linux/version.h>
  9. #include <linux/types.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/ethtool.h>
  12. #include <linux/string.h>
  13. #include <linux/pci.h>
  14. #include <linux/capability.h>
  15. #include "qede.h"
  16. #define QEDE_STAT_OFFSET(stat_name) (offsetof(struct qede_stats, stat_name))
  17. #define QEDE_STAT_STRING(stat_name) (#stat_name)
  18. #define _QEDE_STAT(stat_name, pf_only) \
  19. {QEDE_STAT_OFFSET(stat_name), QEDE_STAT_STRING(stat_name), pf_only}
  20. #define QEDE_PF_STAT(stat_name) _QEDE_STAT(stat_name, true)
  21. #define QEDE_STAT(stat_name) _QEDE_STAT(stat_name, false)
  22. #define QEDE_RQSTAT_OFFSET(stat_name) \
  23. (offsetof(struct qede_rx_queue, stat_name))
  24. #define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
  25. #define QEDE_RQSTAT(stat_name) \
  26. {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
  27. static const struct {
  28. u64 offset;
  29. char string[ETH_GSTRING_LEN];
  30. } qede_rqstats_arr[] = {
  31. QEDE_RQSTAT(rx_hw_errors),
  32. QEDE_RQSTAT(rx_alloc_errors),
  33. };
  34. #define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
  35. #define QEDE_RQSTATS_DATA(dev, sindex, rqindex) \
  36. (*((u64 *)(((char *)(dev->fp_array[(rqindex)].rxq)) +\
  37. qede_rqstats_arr[(sindex)].offset)))
  38. static const struct {
  39. u64 offset;
  40. char string[ETH_GSTRING_LEN];
  41. bool pf_only;
  42. } qede_stats_arr[] = {
  43. QEDE_STAT(rx_ucast_bytes),
  44. QEDE_STAT(rx_mcast_bytes),
  45. QEDE_STAT(rx_bcast_bytes),
  46. QEDE_STAT(rx_ucast_pkts),
  47. QEDE_STAT(rx_mcast_pkts),
  48. QEDE_STAT(rx_bcast_pkts),
  49. QEDE_STAT(tx_ucast_bytes),
  50. QEDE_STAT(tx_mcast_bytes),
  51. QEDE_STAT(tx_bcast_bytes),
  52. QEDE_STAT(tx_ucast_pkts),
  53. QEDE_STAT(tx_mcast_pkts),
  54. QEDE_STAT(tx_bcast_pkts),
  55. QEDE_PF_STAT(rx_64_byte_packets),
  56. QEDE_PF_STAT(rx_127_byte_packets),
  57. QEDE_PF_STAT(rx_255_byte_packets),
  58. QEDE_PF_STAT(rx_511_byte_packets),
  59. QEDE_PF_STAT(rx_1023_byte_packets),
  60. QEDE_PF_STAT(rx_1518_byte_packets),
  61. QEDE_PF_STAT(rx_1522_byte_packets),
  62. QEDE_PF_STAT(rx_2047_byte_packets),
  63. QEDE_PF_STAT(rx_4095_byte_packets),
  64. QEDE_PF_STAT(rx_9216_byte_packets),
  65. QEDE_PF_STAT(rx_16383_byte_packets),
  66. QEDE_PF_STAT(tx_64_byte_packets),
  67. QEDE_PF_STAT(tx_65_to_127_byte_packets),
  68. QEDE_PF_STAT(tx_128_to_255_byte_packets),
  69. QEDE_PF_STAT(tx_256_to_511_byte_packets),
  70. QEDE_PF_STAT(tx_512_to_1023_byte_packets),
  71. QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
  72. QEDE_PF_STAT(tx_1519_to_2047_byte_packets),
  73. QEDE_PF_STAT(tx_2048_to_4095_byte_packets),
  74. QEDE_PF_STAT(tx_4096_to_9216_byte_packets),
  75. QEDE_PF_STAT(tx_9217_to_16383_byte_packets),
  76. QEDE_PF_STAT(rx_mac_crtl_frames),
  77. QEDE_PF_STAT(tx_mac_ctrl_frames),
  78. QEDE_PF_STAT(rx_pause_frames),
  79. QEDE_PF_STAT(tx_pause_frames),
  80. QEDE_PF_STAT(rx_pfc_frames),
  81. QEDE_PF_STAT(tx_pfc_frames),
  82. QEDE_PF_STAT(rx_crc_errors),
  83. QEDE_PF_STAT(rx_align_errors),
  84. QEDE_PF_STAT(rx_carrier_errors),
  85. QEDE_PF_STAT(rx_oversize_packets),
  86. QEDE_PF_STAT(rx_jabbers),
  87. QEDE_PF_STAT(rx_undersize_packets),
  88. QEDE_PF_STAT(rx_fragments),
  89. QEDE_PF_STAT(tx_lpi_entry_count),
  90. QEDE_PF_STAT(tx_total_collisions),
  91. QEDE_PF_STAT(brb_truncates),
  92. QEDE_PF_STAT(brb_discards),
  93. QEDE_STAT(no_buff_discards),
  94. QEDE_PF_STAT(mftag_filter_discards),
  95. QEDE_PF_STAT(mac_filter_discards),
  96. QEDE_STAT(tx_err_drop_pkts),
  97. QEDE_STAT(coalesced_pkts),
  98. QEDE_STAT(coalesced_events),
  99. QEDE_STAT(coalesced_aborts_num),
  100. QEDE_STAT(non_coalesced_pkts),
  101. QEDE_STAT(coalesced_bytes),
  102. };
  103. #define QEDE_STATS_DATA(dev, index) \
  104. (*((u64 *)(((char *)(dev)) + offsetof(struct qede_dev, stats) \
  105. + qede_stats_arr[(index)].offset)))
  106. #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
  107. static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
  108. {
  109. int i, j, k;
  110. for (i = 0, j = 0; i < QEDE_NUM_STATS; i++) {
  111. strcpy(buf + j * ETH_GSTRING_LEN,
  112. qede_stats_arr[i].string);
  113. j++;
  114. }
  115. for (k = 0; k < QEDE_NUM_RQSTATS; k++, j++)
  116. strcpy(buf + j * ETH_GSTRING_LEN,
  117. qede_rqstats_arr[k].string);
  118. }
  119. static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
  120. {
  121. struct qede_dev *edev = netdev_priv(dev);
  122. switch (stringset) {
  123. case ETH_SS_STATS:
  124. qede_get_strings_stats(edev, buf);
  125. break;
  126. default:
  127. DP_VERBOSE(edev, QED_MSG_DEBUG,
  128. "Unsupported stringset 0x%08x\n", stringset);
  129. }
  130. }
  131. static void qede_get_ethtool_stats(struct net_device *dev,
  132. struct ethtool_stats *stats, u64 *buf)
  133. {
  134. struct qede_dev *edev = netdev_priv(dev);
  135. int sidx, cnt = 0;
  136. int qid;
  137. qede_fill_by_demand_stats(edev);
  138. mutex_lock(&edev->qede_lock);
  139. for (sidx = 0; sidx < QEDE_NUM_STATS; sidx++)
  140. buf[cnt++] = QEDE_STATS_DATA(edev, sidx);
  141. for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++) {
  142. buf[cnt] = 0;
  143. for (qid = 0; qid < edev->num_rss; qid++)
  144. buf[cnt] += QEDE_RQSTATS_DATA(edev, sidx, qid);
  145. cnt++;
  146. }
  147. mutex_unlock(&edev->qede_lock);
  148. }
  149. static int qede_get_sset_count(struct net_device *dev, int stringset)
  150. {
  151. struct qede_dev *edev = netdev_priv(dev);
  152. int num_stats = QEDE_NUM_STATS;
  153. switch (stringset) {
  154. case ETH_SS_STATS:
  155. return num_stats + QEDE_NUM_RQSTATS;
  156. default:
  157. DP_VERBOSE(edev, QED_MSG_DEBUG,
  158. "Unsupported stringset 0x%08x\n", stringset);
  159. return -EINVAL;
  160. }
  161. }
  162. static int qede_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  163. {
  164. struct qede_dev *edev = netdev_priv(dev);
  165. struct qed_link_output current_link;
  166. memset(&current_link, 0, sizeof(current_link));
  167. edev->ops->common->get_link(edev->cdev, &current_link);
  168. cmd->supported = current_link.supported_caps;
  169. cmd->advertising = current_link.advertised_caps;
  170. if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
  171. ethtool_cmd_speed_set(cmd, current_link.speed);
  172. cmd->duplex = current_link.duplex;
  173. } else {
  174. cmd->duplex = DUPLEX_UNKNOWN;
  175. ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
  176. }
  177. cmd->port = current_link.port;
  178. cmd->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
  179. AUTONEG_DISABLE;
  180. cmd->lp_advertising = current_link.lp_caps;
  181. return 0;
  182. }
  183. static int qede_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  184. {
  185. struct qede_dev *edev = netdev_priv(dev);
  186. struct qed_link_output current_link;
  187. struct qed_link_params params;
  188. u32 speed;
  189. if (!edev->dev_info.common.is_mf_default) {
  190. DP_INFO(edev,
  191. "Link parameters can not be changed in non-default mode\n");
  192. return -EOPNOTSUPP;
  193. }
  194. memset(&current_link, 0, sizeof(current_link));
  195. memset(&params, 0, sizeof(params));
  196. edev->ops->common->get_link(edev->cdev, &current_link);
  197. speed = ethtool_cmd_speed(cmd);
  198. params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
  199. params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
  200. if (cmd->autoneg == AUTONEG_ENABLE) {
  201. params.autoneg = true;
  202. params.forced_speed = 0;
  203. params.adv_speeds = cmd->advertising;
  204. } else { /* forced speed */
  205. params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
  206. params.autoneg = false;
  207. params.forced_speed = speed;
  208. switch (speed) {
  209. case SPEED_10000:
  210. if (!(current_link.supported_caps &
  211. SUPPORTED_10000baseKR_Full)) {
  212. DP_INFO(edev, "10G speed not supported\n");
  213. return -EINVAL;
  214. }
  215. params.adv_speeds = SUPPORTED_10000baseKR_Full;
  216. break;
  217. case SPEED_40000:
  218. if (!(current_link.supported_caps &
  219. SUPPORTED_40000baseLR4_Full)) {
  220. DP_INFO(edev, "40G speed not supported\n");
  221. return -EINVAL;
  222. }
  223. params.adv_speeds = SUPPORTED_40000baseLR4_Full;
  224. break;
  225. default:
  226. DP_INFO(edev, "Unsupported speed %u\n", speed);
  227. return -EINVAL;
  228. }
  229. }
  230. params.link_up = true;
  231. edev->ops->common->set_link(edev->cdev, &params);
  232. return 0;
  233. }
  234. static void qede_get_drvinfo(struct net_device *ndev,
  235. struct ethtool_drvinfo *info)
  236. {
  237. char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
  238. struct qede_dev *edev = netdev_priv(ndev);
  239. strlcpy(info->driver, "qede", sizeof(info->driver));
  240. strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
  241. snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
  242. edev->dev_info.common.fw_major,
  243. edev->dev_info.common.fw_minor,
  244. edev->dev_info.common.fw_rev,
  245. edev->dev_info.common.fw_eng);
  246. snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
  247. (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
  248. (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
  249. (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
  250. edev->dev_info.common.mfw_rev & 0xFF);
  251. if ((strlen(storm) + strlen(mfw) + strlen("mfw storm ")) <
  252. sizeof(info->fw_version)) {
  253. snprintf(info->fw_version, sizeof(info->fw_version),
  254. "mfw %s storm %s", mfw, storm);
  255. } else {
  256. snprintf(info->fw_version, sizeof(info->fw_version),
  257. "%s %s", mfw, storm);
  258. }
  259. strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
  260. }
  261. static u32 qede_get_msglevel(struct net_device *ndev)
  262. {
  263. struct qede_dev *edev = netdev_priv(ndev);
  264. return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) |
  265. edev->dp_module;
  266. }
  267. static void qede_set_msglevel(struct net_device *ndev, u32 level)
  268. {
  269. struct qede_dev *edev = netdev_priv(ndev);
  270. u32 dp_module = 0;
  271. u8 dp_level = 0;
  272. qede_config_debug(level, &dp_module, &dp_level);
  273. edev->dp_level = dp_level;
  274. edev->dp_module = dp_module;
  275. edev->ops->common->update_msglvl(edev->cdev,
  276. dp_module, dp_level);
  277. }
  278. static int qede_nway_reset(struct net_device *dev)
  279. {
  280. struct qede_dev *edev = netdev_priv(dev);
  281. struct qed_link_output current_link;
  282. struct qed_link_params link_params;
  283. if (!netif_running(dev))
  284. return 0;
  285. memset(&current_link, 0, sizeof(current_link));
  286. edev->ops->common->get_link(edev->cdev, &current_link);
  287. if (!current_link.link_up)
  288. return 0;
  289. /* Toggle the link */
  290. memset(&link_params, 0, sizeof(link_params));
  291. link_params.link_up = false;
  292. edev->ops->common->set_link(edev->cdev, &link_params);
  293. link_params.link_up = true;
  294. edev->ops->common->set_link(edev->cdev, &link_params);
  295. return 0;
  296. }
  297. static u32 qede_get_link(struct net_device *dev)
  298. {
  299. struct qede_dev *edev = netdev_priv(dev);
  300. struct qed_link_output current_link;
  301. memset(&current_link, 0, sizeof(current_link));
  302. edev->ops->common->get_link(edev->cdev, &current_link);
  303. return current_link.link_up;
  304. }
  305. static void qede_get_ringparam(struct net_device *dev,
  306. struct ethtool_ringparam *ering)
  307. {
  308. struct qede_dev *edev = netdev_priv(dev);
  309. ering->rx_max_pending = NUM_RX_BDS_MAX;
  310. ering->rx_pending = edev->q_num_rx_buffers;
  311. ering->tx_max_pending = NUM_TX_BDS_MAX;
  312. ering->tx_pending = edev->q_num_tx_buffers;
  313. }
  314. static int qede_set_ringparam(struct net_device *dev,
  315. struct ethtool_ringparam *ering)
  316. {
  317. struct qede_dev *edev = netdev_priv(dev);
  318. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  319. "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
  320. ering->rx_pending, ering->tx_pending);
  321. /* Validate legality of configuration */
  322. if (ering->rx_pending > NUM_RX_BDS_MAX ||
  323. ering->rx_pending < NUM_RX_BDS_MIN ||
  324. ering->tx_pending > NUM_TX_BDS_MAX ||
  325. ering->tx_pending < NUM_TX_BDS_MIN) {
  326. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  327. "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
  328. NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
  329. NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
  330. return -EINVAL;
  331. }
  332. /* Change ring size and re-load */
  333. edev->q_num_rx_buffers = ering->rx_pending;
  334. edev->q_num_tx_buffers = ering->tx_pending;
  335. if (netif_running(edev->ndev))
  336. qede_reload(edev, NULL, NULL);
  337. return 0;
  338. }
  339. static void qede_get_pauseparam(struct net_device *dev,
  340. struct ethtool_pauseparam *epause)
  341. {
  342. struct qede_dev *edev = netdev_priv(dev);
  343. struct qed_link_output current_link;
  344. memset(&current_link, 0, sizeof(current_link));
  345. edev->ops->common->get_link(edev->cdev, &current_link);
  346. if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
  347. epause->autoneg = true;
  348. if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
  349. epause->rx_pause = true;
  350. if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
  351. epause->tx_pause = true;
  352. DP_VERBOSE(edev, QED_MSG_DEBUG,
  353. "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
  354. epause->cmd, epause->autoneg, epause->rx_pause,
  355. epause->tx_pause);
  356. }
  357. static int qede_set_pauseparam(struct net_device *dev,
  358. struct ethtool_pauseparam *epause)
  359. {
  360. struct qede_dev *edev = netdev_priv(dev);
  361. struct qed_link_params params;
  362. struct qed_link_output current_link;
  363. if (!edev->dev_info.common.is_mf_default) {
  364. DP_INFO(edev,
  365. "Pause parameters can not be updated in non-default mode\n");
  366. return -EOPNOTSUPP;
  367. }
  368. memset(&current_link, 0, sizeof(current_link));
  369. edev->ops->common->get_link(edev->cdev, &current_link);
  370. memset(&params, 0, sizeof(params));
  371. params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
  372. if (epause->autoneg) {
  373. if (!(current_link.supported_caps & SUPPORTED_Autoneg)) {
  374. DP_INFO(edev, "autoneg not supported\n");
  375. return -EINVAL;
  376. }
  377. params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
  378. }
  379. if (epause->rx_pause)
  380. params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
  381. if (epause->tx_pause)
  382. params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
  383. params.link_up = true;
  384. edev->ops->common->set_link(edev->cdev, &params);
  385. return 0;
  386. }
  387. static void qede_update_mtu(struct qede_dev *edev, union qede_reload_args *args)
  388. {
  389. edev->ndev->mtu = args->mtu;
  390. }
  391. /* Netdevice NDOs */
  392. #define ETH_MAX_JUMBO_PACKET_SIZE 9600
  393. #define ETH_MIN_PACKET_SIZE 60
  394. int qede_change_mtu(struct net_device *ndev, int new_mtu)
  395. {
  396. struct qede_dev *edev = netdev_priv(ndev);
  397. union qede_reload_args args;
  398. if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) ||
  399. ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) {
  400. DP_ERR(edev, "Can't support requested MTU size\n");
  401. return -EINVAL;
  402. }
  403. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  404. "Configuring MTU size of %d\n", new_mtu);
  405. /* Set the mtu field and re-start the interface if needed*/
  406. args.mtu = new_mtu;
  407. if (netif_running(edev->ndev))
  408. qede_reload(edev, &qede_update_mtu, &args);
  409. qede_update_mtu(edev, &args);
  410. return 0;
  411. }
  412. static void qede_get_channels(struct net_device *dev,
  413. struct ethtool_channels *channels)
  414. {
  415. struct qede_dev *edev = netdev_priv(dev);
  416. channels->max_combined = QEDE_MAX_RSS_CNT(edev);
  417. channels->combined_count = QEDE_RSS_CNT(edev);
  418. }
  419. static int qede_set_channels(struct net_device *dev,
  420. struct ethtool_channels *channels)
  421. {
  422. struct qede_dev *edev = netdev_priv(dev);
  423. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  424. "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
  425. channels->rx_count, channels->tx_count,
  426. channels->other_count, channels->combined_count);
  427. /* We don't support separate rx / tx, nor `other' channels. */
  428. if (channels->rx_count || channels->tx_count ||
  429. channels->other_count || (channels->combined_count == 0) ||
  430. (channels->combined_count > QEDE_MAX_RSS_CNT(edev))) {
  431. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  432. "command parameters not supported\n");
  433. return -EINVAL;
  434. }
  435. /* Check if there was a change in the active parameters */
  436. if (channels->combined_count == QEDE_RSS_CNT(edev)) {
  437. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  438. "No change in active parameters\n");
  439. return 0;
  440. }
  441. /* We need the number of queues to be divisible between the hwfns */
  442. if (channels->combined_count % edev->dev_info.common.num_hwfns) {
  443. DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
  444. "Number of channels must be divisable by %04x\n",
  445. edev->dev_info.common.num_hwfns);
  446. return -EINVAL;
  447. }
  448. /* Set number of queues and reload if necessary */
  449. edev->req_rss = channels->combined_count;
  450. if (netif_running(dev))
  451. qede_reload(edev, NULL, NULL);
  452. return 0;
  453. }
  454. static int qede_set_phys_id(struct net_device *dev,
  455. enum ethtool_phys_id_state state)
  456. {
  457. struct qede_dev *edev = netdev_priv(dev);
  458. u8 led_state = 0;
  459. switch (state) {
  460. case ETHTOOL_ID_ACTIVE:
  461. return 1; /* cycle on/off once per second */
  462. case ETHTOOL_ID_ON:
  463. led_state = QED_LED_MODE_ON;
  464. break;
  465. case ETHTOOL_ID_OFF:
  466. led_state = QED_LED_MODE_OFF;
  467. break;
  468. case ETHTOOL_ID_INACTIVE:
  469. led_state = QED_LED_MODE_RESTORE;
  470. break;
  471. }
  472. edev->ops->common->set_led(edev->cdev, led_state);
  473. return 0;
  474. }
  475. static const struct ethtool_ops qede_ethtool_ops = {
  476. .get_settings = qede_get_settings,
  477. .set_settings = qede_set_settings,
  478. .get_drvinfo = qede_get_drvinfo,
  479. .get_msglevel = qede_get_msglevel,
  480. .set_msglevel = qede_set_msglevel,
  481. .nway_reset = qede_nway_reset,
  482. .get_link = qede_get_link,
  483. .get_ringparam = qede_get_ringparam,
  484. .set_ringparam = qede_set_ringparam,
  485. .get_pauseparam = qede_get_pauseparam,
  486. .set_pauseparam = qede_set_pauseparam,
  487. .get_strings = qede_get_strings,
  488. .set_phys_id = qede_set_phys_id,
  489. .get_ethtool_stats = qede_get_ethtool_stats,
  490. .get_sset_count = qede_get_sset_count,
  491. .get_channels = qede_get_channels,
  492. .set_channels = qede_set_channels,
  493. };
  494. void qede_set_ethtool_ops(struct net_device *dev)
  495. {
  496. dev->ethtool_ops = &qede_ethtool_ops;
  497. }