1 /* QLogic qede NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
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
9 #include <linux/version.h>
10 #include <linux/types.h>
11 #include <linux/netdevice.h>
12 #include <linux/ethtool.h>
13 #include <linux/string.h>
14 #include <linux/pci.h>
15 #include <linux/capability.h>
18 #define QEDE_STAT_OFFSET(stat_name) (offsetof(struct qede_stats, stat_name))
19 #define QEDE_STAT_STRING(stat_name) (#stat_name)
20 #define _QEDE_STAT(stat_name, pf_only) \
21 {QEDE_STAT_OFFSET(stat_name), QEDE_STAT_STRING(stat_name), pf_only}
22 #define QEDE_PF_STAT(stat_name) _QEDE_STAT(stat_name, true)
23 #define QEDE_STAT(stat_name) _QEDE_STAT(stat_name, false)
25 #define QEDE_RQSTAT_OFFSET(stat_name) \
26 (offsetof(struct qede_rx_queue, stat_name))
27 #define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
28 #define QEDE_RQSTAT(stat_name) \
29 {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
32 char string[ETH_GSTRING_LEN];
33 } qede_rqstats_arr[] = {
34 QEDE_RQSTAT(rx_hw_errors),
35 QEDE_RQSTAT(rx_alloc_errors),
38 #define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
39 #define QEDE_RQSTATS_DATA(dev, sindex, rqindex) \
40 (*((u64 *)(((char *)(dev->fp_array[(rqindex)].rxq)) +\
41 qede_rqstats_arr[(sindex)].offset)))
44 char string[ETH_GSTRING_LEN];
46 } qede_stats_arr[] = {
47 QEDE_STAT(rx_ucast_bytes),
48 QEDE_STAT(rx_mcast_bytes),
49 QEDE_STAT(rx_bcast_bytes),
50 QEDE_STAT(rx_ucast_pkts),
51 QEDE_STAT(rx_mcast_pkts),
52 QEDE_STAT(rx_bcast_pkts),
54 QEDE_STAT(tx_ucast_bytes),
55 QEDE_STAT(tx_mcast_bytes),
56 QEDE_STAT(tx_bcast_bytes),
57 QEDE_STAT(tx_ucast_pkts),
58 QEDE_STAT(tx_mcast_pkts),
59 QEDE_STAT(tx_bcast_pkts),
61 QEDE_PF_STAT(rx_64_byte_packets),
62 QEDE_PF_STAT(rx_65_to_127_byte_packets),
63 QEDE_PF_STAT(rx_128_to_255_byte_packets),
64 QEDE_PF_STAT(rx_256_to_511_byte_packets),
65 QEDE_PF_STAT(rx_512_to_1023_byte_packets),
66 QEDE_PF_STAT(rx_1024_to_1518_byte_packets),
67 QEDE_PF_STAT(rx_1519_to_1522_byte_packets),
68 QEDE_PF_STAT(rx_1519_to_2047_byte_packets),
69 QEDE_PF_STAT(rx_2048_to_4095_byte_packets),
70 QEDE_PF_STAT(rx_4096_to_9216_byte_packets),
71 QEDE_PF_STAT(rx_9217_to_16383_byte_packets),
72 QEDE_PF_STAT(tx_64_byte_packets),
73 QEDE_PF_STAT(tx_65_to_127_byte_packets),
74 QEDE_PF_STAT(tx_128_to_255_byte_packets),
75 QEDE_PF_STAT(tx_256_to_511_byte_packets),
76 QEDE_PF_STAT(tx_512_to_1023_byte_packets),
77 QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
78 QEDE_PF_STAT(tx_1519_to_2047_byte_packets),
79 QEDE_PF_STAT(tx_2048_to_4095_byte_packets),
80 QEDE_PF_STAT(tx_4096_to_9216_byte_packets),
81 QEDE_PF_STAT(tx_9217_to_16383_byte_packets),
83 QEDE_PF_STAT(rx_mac_crtl_frames),
84 QEDE_PF_STAT(tx_mac_ctrl_frames),
85 QEDE_PF_STAT(rx_pause_frames),
86 QEDE_PF_STAT(tx_pause_frames),
87 QEDE_PF_STAT(rx_pfc_frames),
88 QEDE_PF_STAT(tx_pfc_frames),
90 QEDE_PF_STAT(rx_crc_errors),
91 QEDE_PF_STAT(rx_align_errors),
92 QEDE_PF_STAT(rx_carrier_errors),
93 QEDE_PF_STAT(rx_oversize_packets),
94 QEDE_PF_STAT(rx_jabbers),
95 QEDE_PF_STAT(rx_undersize_packets),
96 QEDE_PF_STAT(rx_fragments),
97 QEDE_PF_STAT(tx_lpi_entry_count),
98 QEDE_PF_STAT(tx_total_collisions),
99 QEDE_PF_STAT(brb_truncates),
100 QEDE_PF_STAT(brb_discards),
101 QEDE_STAT(no_buff_discards),
102 QEDE_PF_STAT(mftag_filter_discards),
103 QEDE_PF_STAT(mac_filter_discards),
104 QEDE_STAT(tx_err_drop_pkts),
106 QEDE_STAT(coalesced_pkts),
107 QEDE_STAT(coalesced_events),
108 QEDE_STAT(coalesced_aborts_num),
109 QEDE_STAT(non_coalesced_pkts),
110 QEDE_STAT(coalesced_bytes),
113 #define QEDE_STATS_DATA(dev, index) \
114 (*((u64 *)(((char *)(dev)) + offsetof(struct qede_dev, stats) \
115 + qede_stats_arr[(index)].offset)))
117 #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
119 static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
123 for (i = 0, j = 0; i < QEDE_NUM_STATS; i++) {
124 strcpy(buf + j * ETH_GSTRING_LEN,
125 qede_stats_arr[i].string);
129 for (k = 0; k < QEDE_NUM_RQSTATS; k++, j++)
130 strcpy(buf + j * ETH_GSTRING_LEN,
131 qede_rqstats_arr[k].string);
134 static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
136 struct qede_dev *edev = netdev_priv(dev);
140 qede_get_strings_stats(edev, buf);
143 DP_VERBOSE(edev, QED_MSG_DEBUG,
144 "Unsupported stringset 0x%08x\n", stringset);
148 static void qede_get_ethtool_stats(struct net_device *dev,
149 struct ethtool_stats *stats, u64 *buf)
151 struct qede_dev *edev = netdev_priv(dev);
155 qede_fill_by_demand_stats(edev);
157 mutex_lock(&edev->qede_lock);
159 for (sidx = 0; sidx < QEDE_NUM_STATS; sidx++)
160 buf[cnt++] = QEDE_STATS_DATA(edev, sidx);
162 for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++) {
164 for (qid = 0; qid < edev->num_rss; qid++)
165 buf[cnt] += QEDE_RQSTATS_DATA(edev, sidx, qid);
169 mutex_unlock(&edev->qede_lock);
172 static int qede_get_sset_count(struct net_device *dev, int stringset)
174 struct qede_dev *edev = netdev_priv(dev);
175 int num_stats = QEDE_NUM_STATS;
179 return num_stats + QEDE_NUM_RQSTATS;
182 DP_VERBOSE(edev, QED_MSG_DEBUG,
183 "Unsupported stringset 0x%08x\n", stringset);
188 static int qede_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
190 struct qede_dev *edev = netdev_priv(dev);
191 struct qed_link_output current_link;
193 memset(¤t_link, 0, sizeof(current_link));
194 edev->ops->common->get_link(edev->cdev, ¤t_link);
196 cmd->supported = current_link.supported_caps;
197 cmd->advertising = current_link.advertised_caps;
198 if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
199 ethtool_cmd_speed_set(cmd, current_link.speed);
200 cmd->duplex = current_link.duplex;
202 cmd->duplex = DUPLEX_UNKNOWN;
203 ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
205 cmd->port = current_link.port;
206 cmd->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
208 cmd->lp_advertising = current_link.lp_caps;
213 static int qede_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
215 struct qede_dev *edev = netdev_priv(dev);
216 struct qed_link_output current_link;
217 struct qed_link_params params;
220 if (!edev->dev_info.common.is_mf_default) {
222 "Link parameters can not be changed in non-default mode\n");
226 memset(¤t_link, 0, sizeof(current_link));
227 memset(¶ms, 0, sizeof(params));
228 edev->ops->common->get_link(edev->cdev, ¤t_link);
230 speed = ethtool_cmd_speed(cmd);
231 params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
232 params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
233 if (cmd->autoneg == AUTONEG_ENABLE) {
234 params.autoneg = true;
235 params.forced_speed = 0;
236 params.adv_speeds = cmd->advertising;
237 } else { /* forced speed */
238 params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
239 params.autoneg = false;
240 params.forced_speed = speed;
243 if (!(current_link.supported_caps &
244 SUPPORTED_10000baseKR_Full)) {
245 DP_INFO(edev, "10G speed not supported\n");
248 params.adv_speeds = SUPPORTED_10000baseKR_Full;
251 if (!(current_link.supported_caps &
252 SUPPORTED_40000baseLR4_Full)) {
253 DP_INFO(edev, "40G speed not supported\n");
256 params.adv_speeds = SUPPORTED_40000baseLR4_Full;
259 DP_INFO(edev, "Unsupported speed %u\n", speed);
264 params.link_up = true;
265 edev->ops->common->set_link(edev->cdev, ¶ms);
270 static void qede_get_drvinfo(struct net_device *ndev,
271 struct ethtool_drvinfo *info)
273 char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
274 struct qede_dev *edev = netdev_priv(ndev);
276 strlcpy(info->driver, "qede", sizeof(info->driver));
277 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
279 snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
280 edev->dev_info.common.fw_major,
281 edev->dev_info.common.fw_minor,
282 edev->dev_info.common.fw_rev,
283 edev->dev_info.common.fw_eng);
285 snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
286 (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
287 (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
288 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
289 edev->dev_info.common.mfw_rev & 0xFF);
291 if ((strlen(storm) + strlen(mfw) + strlen("mfw storm ")) <
292 sizeof(info->fw_version)) {
293 snprintf(info->fw_version, sizeof(info->fw_version),
294 "mfw %s storm %s", mfw, storm);
296 snprintf(info->fw_version, sizeof(info->fw_version),
297 "%s %s", mfw, storm);
300 strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
303 static u32 qede_get_msglevel(struct net_device *ndev)
305 struct qede_dev *edev = netdev_priv(ndev);
307 return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) |
311 static void qede_set_msglevel(struct net_device *ndev, u32 level)
313 struct qede_dev *edev = netdev_priv(ndev);
317 qede_config_debug(level, &dp_module, &dp_level);
319 edev->dp_level = dp_level;
320 edev->dp_module = dp_module;
321 edev->ops->common->update_msglvl(edev->cdev,
322 dp_module, dp_level);
325 static int qede_nway_reset(struct net_device *dev)
327 struct qede_dev *edev = netdev_priv(dev);
328 struct qed_link_output current_link;
329 struct qed_link_params link_params;
331 if (!netif_running(dev))
334 memset(¤t_link, 0, sizeof(current_link));
335 edev->ops->common->get_link(edev->cdev, ¤t_link);
336 if (!current_link.link_up)
339 /* Toggle the link */
340 memset(&link_params, 0, sizeof(link_params));
341 link_params.link_up = false;
342 edev->ops->common->set_link(edev->cdev, &link_params);
343 link_params.link_up = true;
344 edev->ops->common->set_link(edev->cdev, &link_params);
349 static u32 qede_get_link(struct net_device *dev)
351 struct qede_dev *edev = netdev_priv(dev);
352 struct qed_link_output current_link;
354 memset(¤t_link, 0, sizeof(current_link));
355 edev->ops->common->get_link(edev->cdev, ¤t_link);
357 return current_link.link_up;
360 static void qede_get_ringparam(struct net_device *dev,
361 struct ethtool_ringparam *ering)
363 struct qede_dev *edev = netdev_priv(dev);
365 ering->rx_max_pending = NUM_RX_BDS_MAX;
366 ering->rx_pending = edev->q_num_rx_buffers;
367 ering->tx_max_pending = NUM_TX_BDS_MAX;
368 ering->tx_pending = edev->q_num_tx_buffers;
371 static int qede_set_ringparam(struct net_device *dev,
372 struct ethtool_ringparam *ering)
374 struct qede_dev *edev = netdev_priv(dev);
376 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
377 "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
378 ering->rx_pending, ering->tx_pending);
380 /* Validate legality of configuration */
381 if (ering->rx_pending > NUM_RX_BDS_MAX ||
382 ering->rx_pending < NUM_RX_BDS_MIN ||
383 ering->tx_pending > NUM_TX_BDS_MAX ||
384 ering->tx_pending < NUM_TX_BDS_MIN) {
385 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
386 "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
387 NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
388 NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
392 /* Change ring size and re-load */
393 edev->q_num_rx_buffers = ering->rx_pending;
394 edev->q_num_tx_buffers = ering->tx_pending;
396 if (netif_running(edev->ndev))
397 qede_reload(edev, NULL, NULL);
402 static void qede_get_pauseparam(struct net_device *dev,
403 struct ethtool_pauseparam *epause)
405 struct qede_dev *edev = netdev_priv(dev);
406 struct qed_link_output current_link;
408 memset(¤t_link, 0, sizeof(current_link));
409 edev->ops->common->get_link(edev->cdev, ¤t_link);
411 if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
412 epause->autoneg = true;
413 if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
414 epause->rx_pause = true;
415 if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
416 epause->tx_pause = true;
418 DP_VERBOSE(edev, QED_MSG_DEBUG,
419 "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
420 epause->cmd, epause->autoneg, epause->rx_pause,
424 static int qede_set_pauseparam(struct net_device *dev,
425 struct ethtool_pauseparam *epause)
427 struct qede_dev *edev = netdev_priv(dev);
428 struct qed_link_params params;
429 struct qed_link_output current_link;
431 if (!edev->dev_info.common.is_mf_default) {
433 "Pause parameters can not be updated in non-default mode\n");
437 memset(¤t_link, 0, sizeof(current_link));
438 edev->ops->common->get_link(edev->cdev, ¤t_link);
440 memset(¶ms, 0, sizeof(params));
441 params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
442 if (epause->autoneg) {
443 if (!(current_link.supported_caps & SUPPORTED_Autoneg)) {
444 DP_INFO(edev, "autoneg not supported\n");
447 params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
449 if (epause->rx_pause)
450 params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
451 if (epause->tx_pause)
452 params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
454 params.link_up = true;
455 edev->ops->common->set_link(edev->cdev, ¶ms);
460 static void qede_update_mtu(struct qede_dev *edev, union qede_reload_args *args)
462 edev->ndev->mtu = args->mtu;
466 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
467 #define ETH_MIN_PACKET_SIZE 60
468 int qede_change_mtu(struct net_device *ndev, int new_mtu)
470 struct qede_dev *edev = netdev_priv(ndev);
471 union qede_reload_args args;
473 if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) ||
474 ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) {
475 DP_ERR(edev, "Can't support requested MTU size\n");
479 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
480 "Configuring MTU size of %d\n", new_mtu);
482 /* Set the mtu field and re-start the interface if needed*/
485 if (netif_running(edev->ndev))
486 qede_reload(edev, &qede_update_mtu, &args);
488 qede_update_mtu(edev, &args);
493 static void qede_get_channels(struct net_device *dev,
494 struct ethtool_channels *channels)
496 struct qede_dev *edev = netdev_priv(dev);
498 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
499 channels->combined_count = QEDE_RSS_CNT(edev);
502 static int qede_set_channels(struct net_device *dev,
503 struct ethtool_channels *channels)
505 struct qede_dev *edev = netdev_priv(dev);
507 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
508 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
509 channels->rx_count, channels->tx_count,
510 channels->other_count, channels->combined_count);
512 /* We don't support separate rx / tx, nor `other' channels. */
513 if (channels->rx_count || channels->tx_count ||
514 channels->other_count || (channels->combined_count == 0) ||
515 (channels->combined_count > QEDE_MAX_RSS_CNT(edev))) {
516 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
517 "command parameters not supported\n");
521 /* Check if there was a change in the active parameters */
522 if (channels->combined_count == QEDE_RSS_CNT(edev)) {
523 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
524 "No change in active parameters\n");
528 /* We need the number of queues to be divisible between the hwfns */
529 if (channels->combined_count % edev->dev_info.common.num_hwfns) {
530 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
531 "Number of channels must be divisable by %04x\n",
532 edev->dev_info.common.num_hwfns);
536 /* Set number of queues and reload if necessary */
537 edev->req_rss = channels->combined_count;
538 if (netif_running(dev))
539 qede_reload(edev, NULL, NULL);
544 static int qede_set_phys_id(struct net_device *dev,
545 enum ethtool_phys_id_state state)
547 struct qede_dev *edev = netdev_priv(dev);
551 case ETHTOOL_ID_ACTIVE:
552 return 1; /* cycle on/off once per second */
555 led_state = QED_LED_MODE_ON;
559 led_state = QED_LED_MODE_OFF;
562 case ETHTOOL_ID_INACTIVE:
563 led_state = QED_LED_MODE_RESTORE;
567 edev->ops->common->set_led(edev->cdev, led_state);
572 static int qede_get_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
574 info->data = RXH_IP_SRC | RXH_IP_DST;
576 switch (info->flow_type) {
579 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
582 if (edev->rss_params.rss_caps & QED_RSS_IPV4_UDP)
583 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
586 if (edev->rss_params.rss_caps & QED_RSS_IPV6_UDP)
587 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
600 static int qede_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
601 u32 *rules __always_unused)
603 struct qede_dev *edev = netdev_priv(dev);
606 case ETHTOOL_GRXRINGS:
607 info->data = edev->num_rss;
610 return qede_get_rss_flags(edev, info);
612 DP_ERR(edev, "Command parameters not supported\n");
617 static int qede_set_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
619 struct qed_update_vport_params vport_update_params;
620 u8 set_caps = 0, clr_caps = 0;
622 DP_VERBOSE(edev, QED_MSG_DEBUG,
623 "Set rss flags command parameters: flow type = %d, data = %llu\n",
624 info->flow_type, info->data);
626 switch (info->flow_type) {
629 /* For TCP only 4-tuple hash is supported */
630 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST |
631 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
632 DP_INFO(edev, "Command parameters not supported\n");
637 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
638 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
639 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
640 set_caps = QED_RSS_IPV4_UDP;
641 DP_VERBOSE(edev, QED_MSG_DEBUG,
642 "UDP 4-tuple enabled\n");
643 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
644 clr_caps = QED_RSS_IPV4_UDP;
645 DP_VERBOSE(edev, QED_MSG_DEBUG,
646 "UDP 4-tuple disabled\n");
652 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
653 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
654 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
655 set_caps = QED_RSS_IPV6_UDP;
656 DP_VERBOSE(edev, QED_MSG_DEBUG,
657 "UDP 4-tuple enabled\n");
658 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
659 clr_caps = QED_RSS_IPV6_UDP;
660 DP_VERBOSE(edev, QED_MSG_DEBUG,
661 "UDP 4-tuple disabled\n");
668 /* For IP only 2-tuple hash is supported */
669 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST)) {
670 DP_INFO(edev, "Command parameters not supported\n");
684 /* RSS is not supported for these protocols */
686 DP_INFO(edev, "Command parameters not supported\n");
694 /* No action is needed if there is no change in the rss capability */
695 if (edev->rss_params.rss_caps == ((edev->rss_params.rss_caps &
696 ~clr_caps) | set_caps))
699 /* Update internal configuration */
700 edev->rss_params.rss_caps = (edev->rss_params.rss_caps & ~clr_caps) |
702 edev->rss_params_inited |= QEDE_RSS_CAPS_INITED;
704 /* Re-configure if possible */
705 if (netif_running(edev->ndev)) {
706 memset(&vport_update_params, 0, sizeof(vport_update_params));
707 vport_update_params.update_rss_flg = 1;
708 vport_update_params.vport_id = 0;
709 memcpy(&vport_update_params.rss_params, &edev->rss_params,
710 sizeof(vport_update_params.rss_params));
711 return edev->ops->vport_update(edev->cdev,
712 &vport_update_params);
718 static int qede_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
720 struct qede_dev *edev = netdev_priv(dev);
724 return qede_set_rss_flags(edev, info);
726 DP_INFO(edev, "Command parameters not supported\n");
731 static u32 qede_get_rxfh_indir_size(struct net_device *dev)
733 return QED_RSS_IND_TABLE_SIZE;
736 static u32 qede_get_rxfh_key_size(struct net_device *dev)
738 struct qede_dev *edev = netdev_priv(dev);
740 return sizeof(edev->rss_params.rss_key);
743 static int qede_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc)
745 struct qede_dev *edev = netdev_priv(dev);
749 *hfunc = ETH_RSS_HASH_TOP;
754 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
755 indir[i] = edev->rss_params.rss_ind_table[i];
758 memcpy(key, edev->rss_params.rss_key,
759 qede_get_rxfh_key_size(dev));
764 static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
765 const u8 *key, const u8 hfunc)
767 struct qed_update_vport_params vport_update_params;
768 struct qede_dev *edev = netdev_priv(dev);
771 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
778 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
779 edev->rss_params.rss_ind_table[i] = indir[i];
780 edev->rss_params_inited |= QEDE_RSS_INDIR_INITED;
784 memcpy(&edev->rss_params.rss_key, key,
785 qede_get_rxfh_key_size(dev));
786 edev->rss_params_inited |= QEDE_RSS_KEY_INITED;
789 if (netif_running(edev->ndev)) {
790 memset(&vport_update_params, 0, sizeof(vport_update_params));
791 vport_update_params.update_rss_flg = 1;
792 vport_update_params.vport_id = 0;
793 memcpy(&vport_update_params.rss_params, &edev->rss_params,
794 sizeof(vport_update_params.rss_params));
795 return edev->ops->vport_update(edev->cdev,
796 &vport_update_params);
802 static const struct ethtool_ops qede_ethtool_ops = {
803 .get_settings = qede_get_settings,
804 .set_settings = qede_set_settings,
805 .get_drvinfo = qede_get_drvinfo,
806 .get_msglevel = qede_get_msglevel,
807 .set_msglevel = qede_set_msglevel,
808 .nway_reset = qede_nway_reset,
809 .get_link = qede_get_link,
810 .get_ringparam = qede_get_ringparam,
811 .set_ringparam = qede_set_ringparam,
812 .get_pauseparam = qede_get_pauseparam,
813 .set_pauseparam = qede_set_pauseparam,
814 .get_strings = qede_get_strings,
815 .set_phys_id = qede_set_phys_id,
816 .get_ethtool_stats = qede_get_ethtool_stats,
817 .get_sset_count = qede_get_sset_count,
818 .get_rxnfc = qede_get_rxnfc,
819 .set_rxnfc = qede_set_rxnfc,
820 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
821 .get_rxfh_key_size = qede_get_rxfh_key_size,
822 .get_rxfh = qede_get_rxfh,
823 .set_rxfh = qede_set_rxfh,
824 .get_channels = qede_get_channels,
825 .set_channels = qede_set_channels,
828 void qede_set_ethtool_ops(struct net_device *dev)
830 dev->ethtool_ops = &qede_ethtool_ops;