Merge branch 'keys-asym-keyctl' into keys-next
[deliverable/linux.git] / drivers / net / ethernet / qlogic / qede / qede_ethtool.c
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
9 #include <linux/version.h>
10 #include <linux/types.h>
11 #include <linux/netdevice.h>
12 #include <linux/etherdevice.h>
13 #include <linux/ethtool.h>
14 #include <linux/string.h>
15 #include <linux/pci.h>
16 #include <linux/capability.h>
17 #include "qede.h"
18
19 #define QEDE_STAT_OFFSET(stat_name) (offsetof(struct qede_stats, stat_name))
20 #define QEDE_STAT_STRING(stat_name) (#stat_name)
21 #define _QEDE_STAT(stat_name, pf_only) \
22 {QEDE_STAT_OFFSET(stat_name), QEDE_STAT_STRING(stat_name), pf_only}
23 #define QEDE_PF_STAT(stat_name) _QEDE_STAT(stat_name, true)
24 #define QEDE_STAT(stat_name) _QEDE_STAT(stat_name, false)
25
26 #define QEDE_RQSTAT_OFFSET(stat_name) \
27 (offsetof(struct qede_rx_queue, stat_name))
28 #define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
29 #define QEDE_RQSTAT(stat_name) \
30 {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
31
32 #define QEDE_SELFTEST_POLL_COUNT 100
33
34 static const struct {
35 u64 offset;
36 char string[ETH_GSTRING_LEN];
37 } qede_rqstats_arr[] = {
38 QEDE_RQSTAT(rx_hw_errors),
39 QEDE_RQSTAT(rx_alloc_errors),
40 QEDE_RQSTAT(rx_ip_frags),
41 };
42
43 #define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
44 #define QEDE_RQSTATS_DATA(dev, sindex, rqindex) \
45 (*((u64 *)(((char *)(dev->fp_array[(rqindex)].rxq)) +\
46 qede_rqstats_arr[(sindex)].offset)))
47 static const struct {
48 u64 offset;
49 char string[ETH_GSTRING_LEN];
50 bool pf_only;
51 } qede_stats_arr[] = {
52 QEDE_STAT(rx_ucast_bytes),
53 QEDE_STAT(rx_mcast_bytes),
54 QEDE_STAT(rx_bcast_bytes),
55 QEDE_STAT(rx_ucast_pkts),
56 QEDE_STAT(rx_mcast_pkts),
57 QEDE_STAT(rx_bcast_pkts),
58
59 QEDE_STAT(tx_ucast_bytes),
60 QEDE_STAT(tx_mcast_bytes),
61 QEDE_STAT(tx_bcast_bytes),
62 QEDE_STAT(tx_ucast_pkts),
63 QEDE_STAT(tx_mcast_pkts),
64 QEDE_STAT(tx_bcast_pkts),
65
66 QEDE_PF_STAT(rx_64_byte_packets),
67 QEDE_PF_STAT(rx_65_to_127_byte_packets),
68 QEDE_PF_STAT(rx_128_to_255_byte_packets),
69 QEDE_PF_STAT(rx_256_to_511_byte_packets),
70 QEDE_PF_STAT(rx_512_to_1023_byte_packets),
71 QEDE_PF_STAT(rx_1024_to_1518_byte_packets),
72 QEDE_PF_STAT(rx_1519_to_1522_byte_packets),
73 QEDE_PF_STAT(rx_1519_to_2047_byte_packets),
74 QEDE_PF_STAT(rx_2048_to_4095_byte_packets),
75 QEDE_PF_STAT(rx_4096_to_9216_byte_packets),
76 QEDE_PF_STAT(rx_9217_to_16383_byte_packets),
77 QEDE_PF_STAT(tx_64_byte_packets),
78 QEDE_PF_STAT(tx_65_to_127_byte_packets),
79 QEDE_PF_STAT(tx_128_to_255_byte_packets),
80 QEDE_PF_STAT(tx_256_to_511_byte_packets),
81 QEDE_PF_STAT(tx_512_to_1023_byte_packets),
82 QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
83 QEDE_PF_STAT(tx_1519_to_2047_byte_packets),
84 QEDE_PF_STAT(tx_2048_to_4095_byte_packets),
85 QEDE_PF_STAT(tx_4096_to_9216_byte_packets),
86 QEDE_PF_STAT(tx_9217_to_16383_byte_packets),
87
88 QEDE_PF_STAT(rx_mac_crtl_frames),
89 QEDE_PF_STAT(tx_mac_ctrl_frames),
90 QEDE_PF_STAT(rx_pause_frames),
91 QEDE_PF_STAT(tx_pause_frames),
92 QEDE_PF_STAT(rx_pfc_frames),
93 QEDE_PF_STAT(tx_pfc_frames),
94
95 QEDE_PF_STAT(rx_crc_errors),
96 QEDE_PF_STAT(rx_align_errors),
97 QEDE_PF_STAT(rx_carrier_errors),
98 QEDE_PF_STAT(rx_oversize_packets),
99 QEDE_PF_STAT(rx_jabbers),
100 QEDE_PF_STAT(rx_undersize_packets),
101 QEDE_PF_STAT(rx_fragments),
102 QEDE_PF_STAT(tx_lpi_entry_count),
103 QEDE_PF_STAT(tx_total_collisions),
104 QEDE_PF_STAT(brb_truncates),
105 QEDE_PF_STAT(brb_discards),
106 QEDE_STAT(no_buff_discards),
107 QEDE_PF_STAT(mftag_filter_discards),
108 QEDE_PF_STAT(mac_filter_discards),
109 QEDE_STAT(tx_err_drop_pkts),
110
111 QEDE_STAT(coalesced_pkts),
112 QEDE_STAT(coalesced_events),
113 QEDE_STAT(coalesced_aborts_num),
114 QEDE_STAT(non_coalesced_pkts),
115 QEDE_STAT(coalesced_bytes),
116 };
117
118 #define QEDE_STATS_DATA(dev, index) \
119 (*((u64 *)(((char *)(dev)) + offsetof(struct qede_dev, stats) \
120 + qede_stats_arr[(index)].offset)))
121
122 #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
123
124 enum {
125 QEDE_PRI_FLAG_CMT,
126 QEDE_PRI_FLAG_LEN,
127 };
128
129 static const char qede_private_arr[QEDE_PRI_FLAG_LEN][ETH_GSTRING_LEN] = {
130 "Coupled-Function",
131 };
132
133 enum qede_ethtool_tests {
134 QEDE_ETHTOOL_INT_LOOPBACK,
135 QEDE_ETHTOOL_INTERRUPT_TEST,
136 QEDE_ETHTOOL_MEMORY_TEST,
137 QEDE_ETHTOOL_REGISTER_TEST,
138 QEDE_ETHTOOL_CLOCK_TEST,
139 QEDE_ETHTOOL_TEST_MAX
140 };
141
142 static const char qede_tests_str_arr[QEDE_ETHTOOL_TEST_MAX][ETH_GSTRING_LEN] = {
143 "Internal loopback (offline)",
144 "Interrupt (online)\t",
145 "Memory (online)\t\t",
146 "Register (online)\t",
147 "Clock (online)\t\t",
148 };
149
150 static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
151 {
152 int i, j, k;
153
154 for (i = 0, j = 0; i < QEDE_NUM_STATS; i++) {
155 if (IS_VF(edev) && qede_stats_arr[i].pf_only)
156 continue;
157 strcpy(buf + j * ETH_GSTRING_LEN,
158 qede_stats_arr[i].string);
159 j++;
160 }
161
162 for (k = 0; k < QEDE_NUM_RQSTATS; k++, j++)
163 strcpy(buf + j * ETH_GSTRING_LEN,
164 qede_rqstats_arr[k].string);
165 }
166
167 static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
168 {
169 struct qede_dev *edev = netdev_priv(dev);
170
171 switch (stringset) {
172 case ETH_SS_STATS:
173 qede_get_strings_stats(edev, buf);
174 break;
175 case ETH_SS_PRIV_FLAGS:
176 memcpy(buf, qede_private_arr,
177 ETH_GSTRING_LEN * QEDE_PRI_FLAG_LEN);
178 break;
179 case ETH_SS_TEST:
180 memcpy(buf, qede_tests_str_arr,
181 ETH_GSTRING_LEN * QEDE_ETHTOOL_TEST_MAX);
182 break;
183 default:
184 DP_VERBOSE(edev, QED_MSG_DEBUG,
185 "Unsupported stringset 0x%08x\n", stringset);
186 }
187 }
188
189 static void qede_get_ethtool_stats(struct net_device *dev,
190 struct ethtool_stats *stats, u64 *buf)
191 {
192 struct qede_dev *edev = netdev_priv(dev);
193 int sidx, cnt = 0;
194 int qid;
195
196 qede_fill_by_demand_stats(edev);
197
198 mutex_lock(&edev->qede_lock);
199
200 for (sidx = 0; sidx < QEDE_NUM_STATS; sidx++) {
201 if (IS_VF(edev) && qede_stats_arr[sidx].pf_only)
202 continue;
203 buf[cnt++] = QEDE_STATS_DATA(edev, sidx);
204 }
205
206 for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++) {
207 buf[cnt] = 0;
208 for (qid = 0; qid < edev->num_rss; qid++)
209 buf[cnt] += QEDE_RQSTATS_DATA(edev, sidx, qid);
210 cnt++;
211 }
212
213 mutex_unlock(&edev->qede_lock);
214 }
215
216 static int qede_get_sset_count(struct net_device *dev, int stringset)
217 {
218 struct qede_dev *edev = netdev_priv(dev);
219 int num_stats = QEDE_NUM_STATS;
220
221 switch (stringset) {
222 case ETH_SS_STATS:
223 if (IS_VF(edev)) {
224 int i;
225
226 for (i = 0; i < QEDE_NUM_STATS; i++)
227 if (qede_stats_arr[i].pf_only)
228 num_stats--;
229 }
230 return num_stats + QEDE_NUM_RQSTATS;
231 case ETH_SS_PRIV_FLAGS:
232 return QEDE_PRI_FLAG_LEN;
233 case ETH_SS_TEST:
234 if (!IS_VF(edev))
235 return QEDE_ETHTOOL_TEST_MAX;
236 else
237 return 0;
238 default:
239 DP_VERBOSE(edev, QED_MSG_DEBUG,
240 "Unsupported stringset 0x%08x\n", stringset);
241 return -EINVAL;
242 }
243 }
244
245 static u32 qede_get_priv_flags(struct net_device *dev)
246 {
247 struct qede_dev *edev = netdev_priv(dev);
248
249 return (!!(edev->dev_info.common.num_hwfns > 1)) << QEDE_PRI_FLAG_CMT;
250 }
251
252 static int qede_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
253 {
254 struct qede_dev *edev = netdev_priv(dev);
255 struct qed_link_output current_link;
256
257 memset(&current_link, 0, sizeof(current_link));
258 edev->ops->common->get_link(edev->cdev, &current_link);
259
260 cmd->supported = current_link.supported_caps;
261 cmd->advertising = current_link.advertised_caps;
262 if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
263 ethtool_cmd_speed_set(cmd, current_link.speed);
264 cmd->duplex = current_link.duplex;
265 } else {
266 cmd->duplex = DUPLEX_UNKNOWN;
267 ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
268 }
269 cmd->port = current_link.port;
270 cmd->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
271 AUTONEG_DISABLE;
272 cmd->lp_advertising = current_link.lp_caps;
273
274 return 0;
275 }
276
277 static int qede_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
278 {
279 struct qede_dev *edev = netdev_priv(dev);
280 struct qed_link_output current_link;
281 struct qed_link_params params;
282 u32 speed;
283
284 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
285 DP_INFO(edev,
286 "Link settings are not allowed to be changed\n");
287 return -EOPNOTSUPP;
288 }
289
290 memset(&current_link, 0, sizeof(current_link));
291 memset(&params, 0, sizeof(params));
292 edev->ops->common->get_link(edev->cdev, &current_link);
293
294 speed = ethtool_cmd_speed(cmd);
295 params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
296 params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
297 if (cmd->autoneg == AUTONEG_ENABLE) {
298 params.autoneg = true;
299 params.forced_speed = 0;
300 params.adv_speeds = cmd->advertising;
301 } else { /* forced speed */
302 params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
303 params.autoneg = false;
304 params.forced_speed = speed;
305 switch (speed) {
306 case SPEED_10000:
307 if (!(current_link.supported_caps &
308 SUPPORTED_10000baseKR_Full)) {
309 DP_INFO(edev, "10G speed not supported\n");
310 return -EINVAL;
311 }
312 params.adv_speeds = SUPPORTED_10000baseKR_Full;
313 break;
314 case SPEED_40000:
315 if (!(current_link.supported_caps &
316 SUPPORTED_40000baseLR4_Full)) {
317 DP_INFO(edev, "40G speed not supported\n");
318 return -EINVAL;
319 }
320 params.adv_speeds = SUPPORTED_40000baseLR4_Full;
321 break;
322 default:
323 DP_INFO(edev, "Unsupported speed %u\n", speed);
324 return -EINVAL;
325 }
326 }
327
328 params.link_up = true;
329 edev->ops->common->set_link(edev->cdev, &params);
330
331 return 0;
332 }
333
334 static void qede_get_drvinfo(struct net_device *ndev,
335 struct ethtool_drvinfo *info)
336 {
337 char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
338 struct qede_dev *edev = netdev_priv(ndev);
339
340 strlcpy(info->driver, "qede", sizeof(info->driver));
341 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
342
343 snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
344 edev->dev_info.common.fw_major,
345 edev->dev_info.common.fw_minor,
346 edev->dev_info.common.fw_rev,
347 edev->dev_info.common.fw_eng);
348
349 snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
350 (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
351 (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
352 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
353 edev->dev_info.common.mfw_rev & 0xFF);
354
355 if ((strlen(storm) + strlen(mfw) + strlen("mfw storm ")) <
356 sizeof(info->fw_version)) {
357 snprintf(info->fw_version, sizeof(info->fw_version),
358 "mfw %s storm %s", mfw, storm);
359 } else {
360 snprintf(info->fw_version, sizeof(info->fw_version),
361 "%s %s", mfw, storm);
362 }
363
364 strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
365 }
366
367 static u32 qede_get_msglevel(struct net_device *ndev)
368 {
369 struct qede_dev *edev = netdev_priv(ndev);
370
371 return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) |
372 edev->dp_module;
373 }
374
375 static void qede_set_msglevel(struct net_device *ndev, u32 level)
376 {
377 struct qede_dev *edev = netdev_priv(ndev);
378 u32 dp_module = 0;
379 u8 dp_level = 0;
380
381 qede_config_debug(level, &dp_module, &dp_level);
382
383 edev->dp_level = dp_level;
384 edev->dp_module = dp_module;
385 edev->ops->common->update_msglvl(edev->cdev,
386 dp_module, dp_level);
387 }
388
389 static int qede_nway_reset(struct net_device *dev)
390 {
391 struct qede_dev *edev = netdev_priv(dev);
392 struct qed_link_output current_link;
393 struct qed_link_params link_params;
394
395 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
396 DP_INFO(edev,
397 "Link settings are not allowed to be changed\n");
398 return -EOPNOTSUPP;
399 }
400
401 if (!netif_running(dev))
402 return 0;
403
404 memset(&current_link, 0, sizeof(current_link));
405 edev->ops->common->get_link(edev->cdev, &current_link);
406 if (!current_link.link_up)
407 return 0;
408
409 /* Toggle the link */
410 memset(&link_params, 0, sizeof(link_params));
411 link_params.link_up = false;
412 edev->ops->common->set_link(edev->cdev, &link_params);
413 link_params.link_up = true;
414 edev->ops->common->set_link(edev->cdev, &link_params);
415
416 return 0;
417 }
418
419 static u32 qede_get_link(struct net_device *dev)
420 {
421 struct qede_dev *edev = netdev_priv(dev);
422 struct qed_link_output current_link;
423
424 memset(&current_link, 0, sizeof(current_link));
425 edev->ops->common->get_link(edev->cdev, &current_link);
426
427 return current_link.link_up;
428 }
429
430 static int qede_get_coalesce(struct net_device *dev,
431 struct ethtool_coalesce *coal)
432 {
433 struct qede_dev *edev = netdev_priv(dev);
434 u16 rxc, txc;
435
436 memset(coal, 0, sizeof(struct ethtool_coalesce));
437 edev->ops->common->get_coalesce(edev->cdev, &rxc, &txc);
438
439 coal->rx_coalesce_usecs = rxc;
440 coal->tx_coalesce_usecs = txc;
441
442 return 0;
443 }
444
445 static int qede_set_coalesce(struct net_device *dev,
446 struct ethtool_coalesce *coal)
447 {
448 struct qede_dev *edev = netdev_priv(dev);
449 int i, rc = 0;
450 u16 rxc, txc;
451 u8 sb_id;
452
453 if (!netif_running(dev)) {
454 DP_INFO(edev, "Interface is down\n");
455 return -EINVAL;
456 }
457
458 if (coal->rx_coalesce_usecs > QED_COALESCE_MAX ||
459 coal->tx_coalesce_usecs > QED_COALESCE_MAX) {
460 DP_INFO(edev,
461 "Can't support requested %s coalesce value [max supported value %d]\n",
462 coal->rx_coalesce_usecs > QED_COALESCE_MAX ? "rx"
463 : "tx",
464 QED_COALESCE_MAX);
465 return -EINVAL;
466 }
467
468 rxc = (u16)coal->rx_coalesce_usecs;
469 txc = (u16)coal->tx_coalesce_usecs;
470 for_each_rss(i) {
471 sb_id = edev->fp_array[i].sb_info->igu_sb_id;
472 rc = edev->ops->common->set_coalesce(edev->cdev, rxc, txc,
473 (u8)i, sb_id);
474 if (rc) {
475 DP_INFO(edev, "Set coalesce error, rc = %d\n", rc);
476 return rc;
477 }
478 }
479
480 return rc;
481 }
482
483 static void qede_get_ringparam(struct net_device *dev,
484 struct ethtool_ringparam *ering)
485 {
486 struct qede_dev *edev = netdev_priv(dev);
487
488 ering->rx_max_pending = NUM_RX_BDS_MAX;
489 ering->rx_pending = edev->q_num_rx_buffers;
490 ering->tx_max_pending = NUM_TX_BDS_MAX;
491 ering->tx_pending = edev->q_num_tx_buffers;
492 }
493
494 static int qede_set_ringparam(struct net_device *dev,
495 struct ethtool_ringparam *ering)
496 {
497 struct qede_dev *edev = netdev_priv(dev);
498
499 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
500 "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
501 ering->rx_pending, ering->tx_pending);
502
503 /* Validate legality of configuration */
504 if (ering->rx_pending > NUM_RX_BDS_MAX ||
505 ering->rx_pending < NUM_RX_BDS_MIN ||
506 ering->tx_pending > NUM_TX_BDS_MAX ||
507 ering->tx_pending < NUM_TX_BDS_MIN) {
508 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
509 "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
510 NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
511 NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
512 return -EINVAL;
513 }
514
515 /* Change ring size and re-load */
516 edev->q_num_rx_buffers = ering->rx_pending;
517 edev->q_num_tx_buffers = ering->tx_pending;
518
519 if (netif_running(edev->ndev))
520 qede_reload(edev, NULL, NULL);
521
522 return 0;
523 }
524
525 static void qede_get_pauseparam(struct net_device *dev,
526 struct ethtool_pauseparam *epause)
527 {
528 struct qede_dev *edev = netdev_priv(dev);
529 struct qed_link_output current_link;
530
531 memset(&current_link, 0, sizeof(current_link));
532 edev->ops->common->get_link(edev->cdev, &current_link);
533
534 if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
535 epause->autoneg = true;
536 if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
537 epause->rx_pause = true;
538 if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
539 epause->tx_pause = true;
540
541 DP_VERBOSE(edev, QED_MSG_DEBUG,
542 "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
543 epause->cmd, epause->autoneg, epause->rx_pause,
544 epause->tx_pause);
545 }
546
547 static int qede_set_pauseparam(struct net_device *dev,
548 struct ethtool_pauseparam *epause)
549 {
550 struct qede_dev *edev = netdev_priv(dev);
551 struct qed_link_params params;
552 struct qed_link_output current_link;
553
554 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
555 DP_INFO(edev,
556 "Pause settings are not allowed to be changed\n");
557 return -EOPNOTSUPP;
558 }
559
560 memset(&current_link, 0, sizeof(current_link));
561 edev->ops->common->get_link(edev->cdev, &current_link);
562
563 memset(&params, 0, sizeof(params));
564 params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
565 if (epause->autoneg) {
566 if (!(current_link.supported_caps & SUPPORTED_Autoneg)) {
567 DP_INFO(edev, "autoneg not supported\n");
568 return -EINVAL;
569 }
570 params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
571 }
572 if (epause->rx_pause)
573 params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
574 if (epause->tx_pause)
575 params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
576
577 params.link_up = true;
578 edev->ops->common->set_link(edev->cdev, &params);
579
580 return 0;
581 }
582
583 static void qede_update_mtu(struct qede_dev *edev, union qede_reload_args *args)
584 {
585 edev->ndev->mtu = args->mtu;
586 }
587
588 /* Netdevice NDOs */
589 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
590 #define ETH_MIN_PACKET_SIZE 60
591 int qede_change_mtu(struct net_device *ndev, int new_mtu)
592 {
593 struct qede_dev *edev = netdev_priv(ndev);
594 union qede_reload_args args;
595
596 if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) ||
597 ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) {
598 DP_ERR(edev, "Can't support requested MTU size\n");
599 return -EINVAL;
600 }
601
602 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
603 "Configuring MTU size of %d\n", new_mtu);
604
605 /* Set the mtu field and re-start the interface if needed*/
606 args.mtu = new_mtu;
607
608 if (netif_running(edev->ndev))
609 qede_reload(edev, &qede_update_mtu, &args);
610
611 qede_update_mtu(edev, &args);
612
613 return 0;
614 }
615
616 static void qede_get_channels(struct net_device *dev,
617 struct ethtool_channels *channels)
618 {
619 struct qede_dev *edev = netdev_priv(dev);
620
621 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
622 channels->combined_count = QEDE_RSS_CNT(edev);
623 }
624
625 static int qede_set_channels(struct net_device *dev,
626 struct ethtool_channels *channels)
627 {
628 struct qede_dev *edev = netdev_priv(dev);
629
630 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
631 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
632 channels->rx_count, channels->tx_count,
633 channels->other_count, channels->combined_count);
634
635 /* We don't support separate rx / tx, nor `other' channels. */
636 if (channels->rx_count || channels->tx_count ||
637 channels->other_count || (channels->combined_count == 0) ||
638 (channels->combined_count > QEDE_MAX_RSS_CNT(edev))) {
639 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
640 "command parameters not supported\n");
641 return -EINVAL;
642 }
643
644 /* Check if there was a change in the active parameters */
645 if (channels->combined_count == QEDE_RSS_CNT(edev)) {
646 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
647 "No change in active parameters\n");
648 return 0;
649 }
650
651 /* We need the number of queues to be divisible between the hwfns */
652 if (channels->combined_count % edev->dev_info.common.num_hwfns) {
653 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
654 "Number of channels must be divisable by %04x\n",
655 edev->dev_info.common.num_hwfns);
656 return -EINVAL;
657 }
658
659 /* Set number of queues and reload if necessary */
660 edev->req_rss = channels->combined_count;
661 if (netif_running(dev))
662 qede_reload(edev, NULL, NULL);
663
664 return 0;
665 }
666
667 static int qede_set_phys_id(struct net_device *dev,
668 enum ethtool_phys_id_state state)
669 {
670 struct qede_dev *edev = netdev_priv(dev);
671 u8 led_state = 0;
672
673 switch (state) {
674 case ETHTOOL_ID_ACTIVE:
675 return 1; /* cycle on/off once per second */
676
677 case ETHTOOL_ID_ON:
678 led_state = QED_LED_MODE_ON;
679 break;
680
681 case ETHTOOL_ID_OFF:
682 led_state = QED_LED_MODE_OFF;
683 break;
684
685 case ETHTOOL_ID_INACTIVE:
686 led_state = QED_LED_MODE_RESTORE;
687 break;
688 }
689
690 edev->ops->common->set_led(edev->cdev, led_state);
691
692 return 0;
693 }
694
695 static int qede_get_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
696 {
697 info->data = RXH_IP_SRC | RXH_IP_DST;
698
699 switch (info->flow_type) {
700 case TCP_V4_FLOW:
701 case TCP_V6_FLOW:
702 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
703 break;
704 case UDP_V4_FLOW:
705 if (edev->rss_params.rss_caps & QED_RSS_IPV4_UDP)
706 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
707 break;
708 case UDP_V6_FLOW:
709 if (edev->rss_params.rss_caps & QED_RSS_IPV6_UDP)
710 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
711 break;
712 case IPV4_FLOW:
713 case IPV6_FLOW:
714 break;
715 default:
716 info->data = 0;
717 break;
718 }
719
720 return 0;
721 }
722
723 static int qede_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
724 u32 *rules __always_unused)
725 {
726 struct qede_dev *edev = netdev_priv(dev);
727
728 switch (info->cmd) {
729 case ETHTOOL_GRXRINGS:
730 info->data = edev->num_rss;
731 return 0;
732 case ETHTOOL_GRXFH:
733 return qede_get_rss_flags(edev, info);
734 default:
735 DP_ERR(edev, "Command parameters not supported\n");
736 return -EOPNOTSUPP;
737 }
738 }
739
740 static int qede_set_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
741 {
742 struct qed_update_vport_params vport_update_params;
743 u8 set_caps = 0, clr_caps = 0;
744
745 DP_VERBOSE(edev, QED_MSG_DEBUG,
746 "Set rss flags command parameters: flow type = %d, data = %llu\n",
747 info->flow_type, info->data);
748
749 switch (info->flow_type) {
750 case TCP_V4_FLOW:
751 case TCP_V6_FLOW:
752 /* For TCP only 4-tuple hash is supported */
753 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST |
754 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
755 DP_INFO(edev, "Command parameters not supported\n");
756 return -EINVAL;
757 }
758 return 0;
759 case UDP_V4_FLOW:
760 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
761 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
762 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
763 set_caps = QED_RSS_IPV4_UDP;
764 DP_VERBOSE(edev, QED_MSG_DEBUG,
765 "UDP 4-tuple enabled\n");
766 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
767 clr_caps = QED_RSS_IPV4_UDP;
768 DP_VERBOSE(edev, QED_MSG_DEBUG,
769 "UDP 4-tuple disabled\n");
770 } else {
771 return -EINVAL;
772 }
773 break;
774 case UDP_V6_FLOW:
775 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
776 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
777 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
778 set_caps = QED_RSS_IPV6_UDP;
779 DP_VERBOSE(edev, QED_MSG_DEBUG,
780 "UDP 4-tuple enabled\n");
781 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
782 clr_caps = QED_RSS_IPV6_UDP;
783 DP_VERBOSE(edev, QED_MSG_DEBUG,
784 "UDP 4-tuple disabled\n");
785 } else {
786 return -EINVAL;
787 }
788 break;
789 case IPV4_FLOW:
790 case IPV6_FLOW:
791 /* For IP only 2-tuple hash is supported */
792 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST)) {
793 DP_INFO(edev, "Command parameters not supported\n");
794 return -EINVAL;
795 }
796 return 0;
797 case SCTP_V4_FLOW:
798 case AH_ESP_V4_FLOW:
799 case AH_V4_FLOW:
800 case ESP_V4_FLOW:
801 case SCTP_V6_FLOW:
802 case AH_ESP_V6_FLOW:
803 case AH_V6_FLOW:
804 case ESP_V6_FLOW:
805 case IP_USER_FLOW:
806 case ETHER_FLOW:
807 /* RSS is not supported for these protocols */
808 if (info->data) {
809 DP_INFO(edev, "Command parameters not supported\n");
810 return -EINVAL;
811 }
812 return 0;
813 default:
814 return -EINVAL;
815 }
816
817 /* No action is needed if there is no change in the rss capability */
818 if (edev->rss_params.rss_caps == ((edev->rss_params.rss_caps &
819 ~clr_caps) | set_caps))
820 return 0;
821
822 /* Update internal configuration */
823 edev->rss_params.rss_caps = (edev->rss_params.rss_caps & ~clr_caps) |
824 set_caps;
825 edev->rss_params_inited |= QEDE_RSS_CAPS_INITED;
826
827 /* Re-configure if possible */
828 if (netif_running(edev->ndev)) {
829 memset(&vport_update_params, 0, sizeof(vport_update_params));
830 vport_update_params.update_rss_flg = 1;
831 vport_update_params.vport_id = 0;
832 memcpy(&vport_update_params.rss_params, &edev->rss_params,
833 sizeof(vport_update_params.rss_params));
834 return edev->ops->vport_update(edev->cdev,
835 &vport_update_params);
836 }
837
838 return 0;
839 }
840
841 static int qede_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
842 {
843 struct qede_dev *edev = netdev_priv(dev);
844
845 switch (info->cmd) {
846 case ETHTOOL_SRXFH:
847 return qede_set_rss_flags(edev, info);
848 default:
849 DP_INFO(edev, "Command parameters not supported\n");
850 return -EOPNOTSUPP;
851 }
852 }
853
854 static u32 qede_get_rxfh_indir_size(struct net_device *dev)
855 {
856 return QED_RSS_IND_TABLE_SIZE;
857 }
858
859 static u32 qede_get_rxfh_key_size(struct net_device *dev)
860 {
861 struct qede_dev *edev = netdev_priv(dev);
862
863 return sizeof(edev->rss_params.rss_key);
864 }
865
866 static int qede_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc)
867 {
868 struct qede_dev *edev = netdev_priv(dev);
869 int i;
870
871 if (hfunc)
872 *hfunc = ETH_RSS_HASH_TOP;
873
874 if (!indir)
875 return 0;
876
877 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
878 indir[i] = edev->rss_params.rss_ind_table[i];
879
880 if (key)
881 memcpy(key, edev->rss_params.rss_key,
882 qede_get_rxfh_key_size(dev));
883
884 return 0;
885 }
886
887 static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
888 const u8 *key, const u8 hfunc)
889 {
890 struct qed_update_vport_params vport_update_params;
891 struct qede_dev *edev = netdev_priv(dev);
892 int i;
893
894 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
895 return -EOPNOTSUPP;
896
897 if (!indir && !key)
898 return 0;
899
900 if (indir) {
901 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
902 edev->rss_params.rss_ind_table[i] = indir[i];
903 edev->rss_params_inited |= QEDE_RSS_INDIR_INITED;
904 }
905
906 if (key) {
907 memcpy(&edev->rss_params.rss_key, key,
908 qede_get_rxfh_key_size(dev));
909 edev->rss_params_inited |= QEDE_RSS_KEY_INITED;
910 }
911
912 if (netif_running(edev->ndev)) {
913 memset(&vport_update_params, 0, sizeof(vport_update_params));
914 vport_update_params.update_rss_flg = 1;
915 vport_update_params.vport_id = 0;
916 memcpy(&vport_update_params.rss_params, &edev->rss_params,
917 sizeof(vport_update_params.rss_params));
918 return edev->ops->vport_update(edev->cdev,
919 &vport_update_params);
920 }
921
922 return 0;
923 }
924
925 /* This function enables the interrupt generation and the NAPI on the device */
926 static void qede_netif_start(struct qede_dev *edev)
927 {
928 int i;
929
930 if (!netif_running(edev->ndev))
931 return;
932
933 for_each_rss(i) {
934 /* Update and reenable interrupts */
935 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_ENABLE, 1);
936 napi_enable(&edev->fp_array[i].napi);
937 }
938 }
939
940 /* This function disables the NAPI and the interrupt generation on the device */
941 static void qede_netif_stop(struct qede_dev *edev)
942 {
943 int i;
944
945 for_each_rss(i) {
946 napi_disable(&edev->fp_array[i].napi);
947 /* Disable interrupts */
948 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_DISABLE, 0);
949 }
950 }
951
952 static int qede_selftest_transmit_traffic(struct qede_dev *edev,
953 struct sk_buff *skb)
954 {
955 struct qede_tx_queue *txq = &edev->fp_array[0].txqs[0];
956 struct eth_tx_1st_bd *first_bd;
957 dma_addr_t mapping;
958 int i, idx, val;
959
960 /* Fill the entry in the SW ring and the BDs in the FW ring */
961 idx = txq->sw_tx_prod & NUM_TX_BDS_MAX;
962 txq->sw_tx_ring[idx].skb = skb;
963 first_bd = qed_chain_produce(&txq->tx_pbl);
964 memset(first_bd, 0, sizeof(*first_bd));
965 val = 1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT;
966 first_bd->data.bd_flags.bitfields = val;
967 val = skb->len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK;
968 first_bd->data.bitfields |= (val << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT);
969
970 /* Map skb linear data for DMA and set in the first BD */
971 mapping = dma_map_single(&edev->pdev->dev, skb->data,
972 skb_headlen(skb), DMA_TO_DEVICE);
973 if (unlikely(dma_mapping_error(&edev->pdev->dev, mapping))) {
974 DP_NOTICE(edev, "SKB mapping failed\n");
975 return -ENOMEM;
976 }
977 BD_SET_UNMAP_ADDR_LEN(first_bd, mapping, skb_headlen(skb));
978
979 /* update the first BD with the actual num BDs */
980 first_bd->data.nbds = 1;
981 txq->sw_tx_prod++;
982 /* 'next page' entries are counted in the producer value */
983 val = cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl));
984 txq->tx_db.data.bd_prod = val;
985
986 /* wmb makes sure that the BDs data is updated before updating the
987 * producer, otherwise FW may read old data from the BDs.
988 */
989 wmb();
990 barrier();
991 writel(txq->tx_db.raw, txq->doorbell_addr);
992
993 /* mmiowb is needed to synchronize doorbell writes from more than one
994 * processor. It guarantees that the write arrives to the device before
995 * the queue lock is released and another start_xmit is called (possibly
996 * on another CPU). Without this barrier, the next doorbell can bypass
997 * this doorbell. This is applicable to IA64/Altix systems.
998 */
999 mmiowb();
1000
1001 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1002 if (qede_txq_has_work(txq))
1003 break;
1004 usleep_range(100, 200);
1005 }
1006
1007 if (!qede_txq_has_work(txq)) {
1008 DP_NOTICE(edev, "Tx completion didn't happen\n");
1009 return -1;
1010 }
1011
1012 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl);
1013 dma_unmap_page(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
1014 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE);
1015 txq->sw_tx_cons++;
1016 txq->sw_tx_ring[idx].skb = NULL;
1017
1018 return 0;
1019 }
1020
1021 static int qede_selftest_receive_traffic(struct qede_dev *edev)
1022 {
1023 struct qede_rx_queue *rxq = edev->fp_array[0].rxq;
1024 u16 hw_comp_cons, sw_comp_cons, sw_rx_index, len;
1025 struct eth_fast_path_rx_reg_cqe *fp_cqe;
1026 struct sw_rx_data *sw_rx_data;
1027 union eth_rx_cqe *cqe;
1028 u8 *data_ptr;
1029 int i;
1030
1031 /* The packet is expected to receive on rx-queue 0 even though RSS is
1032 * enabled. This is because the queue 0 is configured as the default
1033 * queue and that the loopback traffic is not IP.
1034 */
1035 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1036 if (qede_has_rx_work(rxq))
1037 break;
1038 usleep_range(100, 200);
1039 }
1040
1041 if (!qede_has_rx_work(rxq)) {
1042 DP_NOTICE(edev, "Failed to receive the traffic\n");
1043 return -1;
1044 }
1045
1046 hw_comp_cons = le16_to_cpu(*rxq->hw_cons_ptr);
1047 sw_comp_cons = qed_chain_get_cons_idx(&rxq->rx_comp_ring);
1048
1049 /* Memory barrier to prevent the CPU from doing speculative reads of CQE
1050 * / BD before reading hw_comp_cons. If the CQE is read before it is
1051 * written by FW, then FW writes CQE and SB, and then the CPU reads the
1052 * hw_comp_cons, it will use an old CQE.
1053 */
1054 rmb();
1055
1056 /* Get the CQE from the completion ring */
1057 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1058
1059 /* Get the data from the SW ring */
1060 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1061 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1062 fp_cqe = &cqe->fast_path_regular;
1063 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1064 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1065 fp_cqe->placement_offset + sw_rx_data->page_offset);
1066 for (i = ETH_HLEN; i < len; i++)
1067 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1068 DP_NOTICE(edev, "Loopback test failed\n");
1069 qede_recycle_rx_bd_ring(rxq, edev, 1);
1070 return -1;
1071 }
1072
1073 qede_recycle_rx_bd_ring(rxq, edev, 1);
1074
1075 return 0;
1076 }
1077
1078 static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
1079 {
1080 struct qed_link_params link_params;
1081 struct sk_buff *skb = NULL;
1082 int rc = 0, i;
1083 u32 pkt_size;
1084 u8 *packet;
1085
1086 if (!netif_running(edev->ndev)) {
1087 DP_NOTICE(edev, "Interface is down\n");
1088 return -EINVAL;
1089 }
1090
1091 qede_netif_stop(edev);
1092
1093 /* Bring up the link in Loopback mode */
1094 memset(&link_params, 0, sizeof(link_params));
1095 link_params.link_up = true;
1096 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1097 link_params.loopback_mode = loopback_mode;
1098 edev->ops->common->set_link(edev->cdev, &link_params);
1099
1100 /* Wait for loopback configuration to apply */
1101 msleep_interruptible(500);
1102
1103 /* prepare the loopback packet */
1104 pkt_size = edev->ndev->mtu + ETH_HLEN;
1105
1106 skb = netdev_alloc_skb(edev->ndev, pkt_size);
1107 if (!skb) {
1108 DP_INFO(edev, "Can't allocate skb\n");
1109 rc = -ENOMEM;
1110 goto test_loopback_exit;
1111 }
1112 packet = skb_put(skb, pkt_size);
1113 ether_addr_copy(packet, edev->ndev->dev_addr);
1114 ether_addr_copy(packet + ETH_ALEN, edev->ndev->dev_addr);
1115 memset(packet + (2 * ETH_ALEN), 0x77, (ETH_HLEN - (2 * ETH_ALEN)));
1116 for (i = ETH_HLEN; i < pkt_size; i++)
1117 packet[i] = (unsigned char)(i & 0xff);
1118
1119 rc = qede_selftest_transmit_traffic(edev, skb);
1120 if (rc)
1121 goto test_loopback_exit;
1122
1123 rc = qede_selftest_receive_traffic(edev);
1124 if (rc)
1125 goto test_loopback_exit;
1126
1127 DP_VERBOSE(edev, NETIF_MSG_RX_STATUS, "Loopback test successful\n");
1128
1129 test_loopback_exit:
1130 dev_kfree_skb(skb);
1131
1132 /* Bring up the link in Normal mode */
1133 memset(&link_params, 0, sizeof(link_params));
1134 link_params.link_up = true;
1135 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1136 link_params.loopback_mode = QED_LINK_LOOPBACK_NONE;
1137 edev->ops->common->set_link(edev->cdev, &link_params);
1138
1139 /* Wait for loopback configuration to apply */
1140 msleep_interruptible(500);
1141
1142 qede_netif_start(edev);
1143
1144 return rc;
1145 }
1146
1147 static void qede_self_test(struct net_device *dev,
1148 struct ethtool_test *etest, u64 *buf)
1149 {
1150 struct qede_dev *edev = netdev_priv(dev);
1151
1152 DP_VERBOSE(edev, QED_MSG_DEBUG,
1153 "Self-test command parameters: offline = %d, external_lb = %d\n",
1154 (etest->flags & ETH_TEST_FL_OFFLINE),
1155 (etest->flags & ETH_TEST_FL_EXTERNAL_LB) >> 2);
1156
1157 memset(buf, 0, sizeof(u64) * QEDE_ETHTOOL_TEST_MAX);
1158
1159 if (etest->flags & ETH_TEST_FL_OFFLINE) {
1160 if (qede_selftest_run_loopback(edev,
1161 QED_LINK_LOOPBACK_INT_PHY)) {
1162 buf[QEDE_ETHTOOL_INT_LOOPBACK] = 1;
1163 etest->flags |= ETH_TEST_FL_FAILED;
1164 }
1165 }
1166
1167 if (edev->ops->common->selftest->selftest_interrupt(edev->cdev)) {
1168 buf[QEDE_ETHTOOL_INTERRUPT_TEST] = 1;
1169 etest->flags |= ETH_TEST_FL_FAILED;
1170 }
1171
1172 if (edev->ops->common->selftest->selftest_memory(edev->cdev)) {
1173 buf[QEDE_ETHTOOL_MEMORY_TEST] = 1;
1174 etest->flags |= ETH_TEST_FL_FAILED;
1175 }
1176
1177 if (edev->ops->common->selftest->selftest_register(edev->cdev)) {
1178 buf[QEDE_ETHTOOL_REGISTER_TEST] = 1;
1179 etest->flags |= ETH_TEST_FL_FAILED;
1180 }
1181
1182 if (edev->ops->common->selftest->selftest_clock(edev->cdev)) {
1183 buf[QEDE_ETHTOOL_CLOCK_TEST] = 1;
1184 etest->flags |= ETH_TEST_FL_FAILED;
1185 }
1186 }
1187
1188 static int qede_set_tunable(struct net_device *dev,
1189 const struct ethtool_tunable *tuna,
1190 const void *data)
1191 {
1192 struct qede_dev *edev = netdev_priv(dev);
1193 u32 val;
1194
1195 switch (tuna->id) {
1196 case ETHTOOL_RX_COPYBREAK:
1197 val = *(u32 *)data;
1198 if (val < QEDE_MIN_PKT_LEN || val > QEDE_RX_HDR_SIZE) {
1199 DP_VERBOSE(edev, QED_MSG_DEBUG,
1200 "Invalid rx copy break value, range is [%u, %u]",
1201 QEDE_MIN_PKT_LEN, QEDE_RX_HDR_SIZE);
1202 return -EINVAL;
1203 }
1204
1205 edev->rx_copybreak = *(u32 *)data;
1206 break;
1207 default:
1208 return -EOPNOTSUPP;
1209 }
1210
1211 return 0;
1212 }
1213
1214 static int qede_get_tunable(struct net_device *dev,
1215 const struct ethtool_tunable *tuna, void *data)
1216 {
1217 struct qede_dev *edev = netdev_priv(dev);
1218
1219 switch (tuna->id) {
1220 case ETHTOOL_RX_COPYBREAK:
1221 *(u32 *)data = edev->rx_copybreak;
1222 break;
1223 default:
1224 return -EOPNOTSUPP;
1225 }
1226
1227 return 0;
1228 }
1229
1230 static const struct ethtool_ops qede_ethtool_ops = {
1231 .get_settings = qede_get_settings,
1232 .set_settings = qede_set_settings,
1233 .get_drvinfo = qede_get_drvinfo,
1234 .get_msglevel = qede_get_msglevel,
1235 .set_msglevel = qede_set_msglevel,
1236 .nway_reset = qede_nway_reset,
1237 .get_link = qede_get_link,
1238 .get_coalesce = qede_get_coalesce,
1239 .set_coalesce = qede_set_coalesce,
1240 .get_ringparam = qede_get_ringparam,
1241 .set_ringparam = qede_set_ringparam,
1242 .get_pauseparam = qede_get_pauseparam,
1243 .set_pauseparam = qede_set_pauseparam,
1244 .get_strings = qede_get_strings,
1245 .set_phys_id = qede_set_phys_id,
1246 .get_ethtool_stats = qede_get_ethtool_stats,
1247 .get_priv_flags = qede_get_priv_flags,
1248 .get_sset_count = qede_get_sset_count,
1249 .get_rxnfc = qede_get_rxnfc,
1250 .set_rxnfc = qede_set_rxnfc,
1251 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
1252 .get_rxfh_key_size = qede_get_rxfh_key_size,
1253 .get_rxfh = qede_get_rxfh,
1254 .set_rxfh = qede_set_rxfh,
1255 .get_channels = qede_get_channels,
1256 .set_channels = qede_set_channels,
1257 .self_test = qede_self_test,
1258 .get_tunable = qede_get_tunable,
1259 .set_tunable = qede_set_tunable,
1260 };
1261
1262 static const struct ethtool_ops qede_vf_ethtool_ops = {
1263 .get_settings = qede_get_settings,
1264 .get_drvinfo = qede_get_drvinfo,
1265 .get_msglevel = qede_get_msglevel,
1266 .set_msglevel = qede_set_msglevel,
1267 .get_link = qede_get_link,
1268 .get_ringparam = qede_get_ringparam,
1269 .set_ringparam = qede_set_ringparam,
1270 .get_strings = qede_get_strings,
1271 .get_ethtool_stats = qede_get_ethtool_stats,
1272 .get_priv_flags = qede_get_priv_flags,
1273 .get_sset_count = qede_get_sset_count,
1274 .get_rxnfc = qede_get_rxnfc,
1275 .set_rxnfc = qede_set_rxnfc,
1276 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
1277 .get_rxfh_key_size = qede_get_rxfh_key_size,
1278 .get_rxfh = qede_get_rxfh,
1279 .set_rxfh = qede_set_rxfh,
1280 .get_channels = qede_get_channels,
1281 .set_channels = qede_set_channels,
1282 .get_tunable = qede_get_tunable,
1283 .set_tunable = qede_set_tunable,
1284 };
1285
1286 void qede_set_ethtool_ops(struct net_device *dev)
1287 {
1288 struct qede_dev *edev = netdev_priv(dev);
1289
1290 if (IS_VF(edev))
1291 dev->ethtool_ops = &qede_vf_ethtool_ops;
1292 else
1293 dev->ethtool_ops = &qede_ethtool_ops;
1294 }
This page took 0.10014 seconds and 5 git commands to generate.