tree-wide: Assorted spelling fixes
[linux-2.6-block.git] / drivers / net / qlge / qlge_ethtool.c
CommitLineData
c4e84bde
RM
1#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/types.h>
4#include <linux/module.h>
5#include <linux/list.h>
6#include <linux/pci.h>
7#include <linux/dma-mapping.h>
8#include <linux/pagemap.h>
9#include <linux/sched.h>
10#include <linux/slab.h>
11#include <linux/dmapool.h>
12#include <linux/mempool.h>
13#include <linux/spinlock.h>
14#include <linux/kthread.h>
15#include <linux/interrupt.h>
16#include <linux/errno.h>
17#include <linux/ioport.h>
18#include <linux/in.h>
19#include <linux/ip.h>
20#include <linux/ipv6.h>
21#include <net/ipv6.h>
22#include <linux/tcp.h>
23#include <linux/udp.h>
24#include <linux/if_arp.h>
25#include <linux/if_ether.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/ethtool.h>
29#include <linux/skbuff.h>
30#include <linux/rtnetlink.h>
31#include <linux/if_vlan.h>
c4e84bde
RM
32#include <linux/delay.h>
33#include <linux/mm.h>
34#include <linux/vmalloc.h>
35
c4e84bde
RM
36
37#include "qlge.h"
38
9dfbbaa6
RM
39static const char ql_gstrings_test[][ETH_GSTRING_LEN] = {
40 "Loopback test (offline)"
41};
42#define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN)
43
c4e84bde
RM
44static int ql_update_ring_coalescing(struct ql_adapter *qdev)
45{
46 int i, status = 0;
47 struct rx_ring *rx_ring;
48 struct cqicb *cqicb;
49
50 if (!netif_running(qdev->ndev))
51 return status;
52
c4e84bde
RM
53 /* Skip the default queue, and update the outbound handler
54 * queues if they changed.
55 */
b2014ff8 56 cqicb = (struct cqicb *)&qdev->rx_ring[qdev->rss_ring_count];
c4e84bde 57 if (le16_to_cpu(cqicb->irq_delay) != qdev->tx_coalesce_usecs ||
b2014ff8
RM
58 le16_to_cpu(cqicb->pkt_delay) !=
59 qdev->tx_max_coalesced_frames) {
60 for (i = qdev->rss_ring_count; i < qdev->rx_ring_count; i++) {
c4e84bde
RM
61 rx_ring = &qdev->rx_ring[i];
62 cqicb = (struct cqicb *)rx_ring;
8306c952 63 cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs);
c4e84bde 64 cqicb->pkt_delay =
8306c952 65 cpu_to_le16(qdev->tx_max_coalesced_frames);
c4e84bde 66 cqicb->flags = FLAGS_LI;
e332471c 67 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
c4e84bde
RM
68 CFG_LCQ, rx_ring->cq_id);
69 if (status) {
70 QPRINTK(qdev, IFUP, ERR,
71 "Failed to load CQICB.\n");
72 goto exit;
73 }
74 }
75 }
76
77 /* Update the inbound (RSS) handler queues if they changed. */
b2014ff8 78 cqicb = (struct cqicb *)&qdev->rx_ring[0];
c4e84bde 79 if (le16_to_cpu(cqicb->irq_delay) != qdev->rx_coalesce_usecs ||
b2014ff8
RM
80 le16_to_cpu(cqicb->pkt_delay) !=
81 qdev->rx_max_coalesced_frames) {
82 for (i = 0; i < qdev->rss_ring_count; i++, rx_ring++) {
c4e84bde
RM
83 rx_ring = &qdev->rx_ring[i];
84 cqicb = (struct cqicb *)rx_ring;
8306c952 85 cqicb->irq_delay = cpu_to_le16(qdev->rx_coalesce_usecs);
c4e84bde 86 cqicb->pkt_delay =
8306c952 87 cpu_to_le16(qdev->rx_max_coalesced_frames);
c4e84bde 88 cqicb->flags = FLAGS_LI;
e332471c 89 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
c4e84bde
RM
90 CFG_LCQ, rx_ring->cq_id);
91 if (status) {
92 QPRINTK(qdev, IFUP, ERR,
93 "Failed to load CQICB.\n");
94 goto exit;
95 }
96 }
97 }
98exit:
c4e84bde
RM
99 return status;
100}
101
2f22d22e 102static void ql_update_stats(struct ql_adapter *qdev)
c4e84bde
RM
103{
104 u32 i;
105 u64 data;
106 u64 *iter = &qdev->nic_stats.tx_pkts;
107
108 spin_lock(&qdev->stats_lock);
109 if (ql_sem_spinlock(qdev, qdev->xg_sem_mask)) {
110 QPRINTK(qdev, DRV, ERR,
111 "Couldn't get xgmac sem.\n");
112 goto quit;
113 }
114 /*
115 * Get TX statistics.
116 */
117 for (i = 0x200; i < 0x280; i += 8) {
118 if (ql_read_xgmac_reg64(qdev, i, &data)) {
119 QPRINTK(qdev, DRV, ERR,
120 "Error reading status register 0x%.04x.\n", i);
121 goto end;
122 } else
123 *iter = data;
124 iter++;
125 }
126
127 /*
128 * Get RX statistics.
129 */
130 for (i = 0x300; i < 0x3d0; i += 8) {
131 if (ql_read_xgmac_reg64(qdev, i, &data)) {
132 QPRINTK(qdev, DRV, ERR,
133 "Error reading status register 0x%.04x.\n", i);
134 goto end;
135 } else
136 *iter = data;
137 iter++;
138 }
139
6abd2346
RM
140 /*
141 * Get Per-priority TX pause frame counter statistics.
142 */
143 for (i = 0x500; i < 0x540; i += 8) {
144 if (ql_read_xgmac_reg64(qdev, i, &data)) {
145 QPRINTK(qdev, DRV, ERR,
146 "Error reading status register 0x%.04x.\n", i);
147 goto end;
148 } else
149 *iter = data;
150 iter++;
151 }
152
153 /*
154 * Get Per-priority RX pause frame counter statistics.
155 */
156 for (i = 0x568; i < 0x5a8; i += 8) {
157 if (ql_read_xgmac_reg64(qdev, i, &data)) {
158 QPRINTK(qdev, DRV, ERR,
159 "Error reading status register 0x%.04x.\n", i);
160 goto end;
161 } else
162 *iter = data;
163 iter++;
164 }
165
166 /*
167 * Get RX NIC FIFO DROP statistics.
168 */
169 if (ql_read_xgmac_reg64(qdev, 0x5b8, &data)) {
170 QPRINTK(qdev, DRV, ERR,
171 "Error reading status register 0x%.04x.\n", i);
172 goto end;
173 } else
174 *iter = data;
c4e84bde
RM
175end:
176 ql_sem_unlock(qdev, qdev->xg_sem_mask);
177quit:
178 spin_unlock(&qdev->stats_lock);
179
180 QL_DUMP_STAT(qdev);
181
182 return;
183}
184
185static char ql_stats_str_arr[][ETH_GSTRING_LEN] = {
186 {"tx_pkts"},
187 {"tx_bytes"},
188 {"tx_mcast_pkts"},
189 {"tx_bcast_pkts"},
190 {"tx_ucast_pkts"},
191 {"tx_ctl_pkts"},
192 {"tx_pause_pkts"},
193 {"tx_64_pkts"},
194 {"tx_65_to_127_pkts"},
195 {"tx_128_to_255_pkts"},
196 {"tx_256_511_pkts"},
197 {"tx_512_to_1023_pkts"},
198 {"tx_1024_to_1518_pkts"},
199 {"tx_1519_to_max_pkts"},
200 {"tx_undersize_pkts"},
201 {"tx_oversize_pkts"},
202 {"rx_bytes"},
203 {"rx_bytes_ok"},
204 {"rx_pkts"},
205 {"rx_pkts_ok"},
206 {"rx_bcast_pkts"},
207 {"rx_mcast_pkts"},
208 {"rx_ucast_pkts"},
209 {"rx_undersize_pkts"},
210 {"rx_oversize_pkts"},
211 {"rx_jabber_pkts"},
212 {"rx_undersize_fcerr_pkts"},
213 {"rx_drop_events"},
214 {"rx_fcerr_pkts"},
215 {"rx_align_err"},
216 {"rx_symbol_err"},
217 {"rx_mac_err"},
218 {"rx_ctl_pkts"},
219 {"rx_pause_pkts"},
220 {"rx_64_pkts"},
221 {"rx_65_to_127_pkts"},
222 {"rx_128_255_pkts"},
223 {"rx_256_511_pkts"},
224 {"rx_512_to_1023_pkts"},
225 {"rx_1024_to_1518_pkts"},
226 {"rx_1519_to_max_pkts"},
227 {"rx_len_err_pkts"},
6abd2346
RM
228 {"tx_cbfc_pause_frames0"},
229 {"tx_cbfc_pause_frames1"},
230 {"tx_cbfc_pause_frames2"},
231 {"tx_cbfc_pause_frames3"},
232 {"tx_cbfc_pause_frames4"},
233 {"tx_cbfc_pause_frames5"},
234 {"tx_cbfc_pause_frames6"},
235 {"tx_cbfc_pause_frames7"},
236 {"rx_cbfc_pause_frames0"},
237 {"rx_cbfc_pause_frames1"},
238 {"rx_cbfc_pause_frames2"},
239 {"rx_cbfc_pause_frames3"},
240 {"rx_cbfc_pause_frames4"},
241 {"rx_cbfc_pause_frames5"},
242 {"rx_cbfc_pause_frames6"},
243 {"rx_cbfc_pause_frames7"},
244 {"rx_nic_fifo_drop"},
c4e84bde
RM
245};
246
247static void ql_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
248{
249 switch (stringset) {
250 case ETH_SS_STATS:
251 memcpy(buf, ql_stats_str_arr, sizeof(ql_stats_str_arr));
252 break;
253 }
254}
255
256static int ql_get_sset_count(struct net_device *dev, int sset)
257{
258 switch (sset) {
9dfbbaa6
RM
259 case ETH_SS_TEST:
260 return QLGE_TEST_LEN;
c4e84bde
RM
261 case ETH_SS_STATS:
262 return ARRAY_SIZE(ql_stats_str_arr);
263 default:
264 return -EOPNOTSUPP;
265 }
266}
267
268static void
269ql_get_ethtool_stats(struct net_device *ndev,
270 struct ethtool_stats *stats, u64 *data)
271{
272 struct ql_adapter *qdev = netdev_priv(ndev);
273 struct nic_stats *s = &qdev->nic_stats;
274
275 ql_update_stats(qdev);
276
277 *data++ = s->tx_pkts;
278 *data++ = s->tx_bytes;
279 *data++ = s->tx_mcast_pkts;
280 *data++ = s->tx_bcast_pkts;
281 *data++ = s->tx_ucast_pkts;
282 *data++ = s->tx_ctl_pkts;
283 *data++ = s->tx_pause_pkts;
284 *data++ = s->tx_64_pkt;
285 *data++ = s->tx_65_to_127_pkt;
286 *data++ = s->tx_128_to_255_pkt;
287 *data++ = s->tx_256_511_pkt;
288 *data++ = s->tx_512_to_1023_pkt;
289 *data++ = s->tx_1024_to_1518_pkt;
290 *data++ = s->tx_1519_to_max_pkt;
291 *data++ = s->tx_undersize_pkt;
292 *data++ = s->tx_oversize_pkt;
293 *data++ = s->rx_bytes;
294 *data++ = s->rx_bytes_ok;
295 *data++ = s->rx_pkts;
296 *data++ = s->rx_pkts_ok;
297 *data++ = s->rx_bcast_pkts;
298 *data++ = s->rx_mcast_pkts;
299 *data++ = s->rx_ucast_pkts;
300 *data++ = s->rx_undersize_pkts;
301 *data++ = s->rx_oversize_pkts;
302 *data++ = s->rx_jabber_pkts;
303 *data++ = s->rx_undersize_fcerr_pkts;
304 *data++ = s->rx_drop_events;
305 *data++ = s->rx_fcerr_pkts;
306 *data++ = s->rx_align_err;
307 *data++ = s->rx_symbol_err;
308 *data++ = s->rx_mac_err;
309 *data++ = s->rx_ctl_pkts;
310 *data++ = s->rx_pause_pkts;
311 *data++ = s->rx_64_pkts;
312 *data++ = s->rx_65_to_127_pkts;
313 *data++ = s->rx_128_255_pkts;
314 *data++ = s->rx_256_511_pkts;
315 *data++ = s->rx_512_to_1023_pkts;
316 *data++ = s->rx_1024_to_1518_pkts;
317 *data++ = s->rx_1519_to_max_pkts;
318 *data++ = s->rx_len_err_pkts;
6abd2346
RM
319 *data++ = s->tx_cbfc_pause_frames0;
320 *data++ = s->tx_cbfc_pause_frames1;
321 *data++ = s->tx_cbfc_pause_frames2;
322 *data++ = s->tx_cbfc_pause_frames3;
323 *data++ = s->tx_cbfc_pause_frames4;
324 *data++ = s->tx_cbfc_pause_frames5;
325 *data++ = s->tx_cbfc_pause_frames6;
326 *data++ = s->tx_cbfc_pause_frames7;
327 *data++ = s->rx_cbfc_pause_frames0;
328 *data++ = s->rx_cbfc_pause_frames1;
329 *data++ = s->rx_cbfc_pause_frames2;
330 *data++ = s->rx_cbfc_pause_frames3;
331 *data++ = s->rx_cbfc_pause_frames4;
332 *data++ = s->rx_cbfc_pause_frames5;
333 *data++ = s->rx_cbfc_pause_frames6;
334 *data++ = s->rx_cbfc_pause_frames7;
335 *data++ = s->rx_nic_fifo_drop;
c4e84bde
RM
336}
337
338static int ql_get_settings(struct net_device *ndev,
339 struct ethtool_cmd *ecmd)
340{
341 struct ql_adapter *qdev = netdev_priv(ndev);
342
343 ecmd->supported = SUPPORTED_10000baseT_Full;
344 ecmd->advertising = ADVERTISED_10000baseT_Full;
345 ecmd->autoneg = AUTONEG_ENABLE;
346 ecmd->transceiver = XCVR_EXTERNAL;
b82808b7
RM
347 if ((qdev->link_status & STS_LINK_TYPE_MASK) ==
348 STS_LINK_TYPE_10GBASET) {
c4e84bde
RM
349 ecmd->supported |= (SUPPORTED_TP | SUPPORTED_Autoneg);
350 ecmd->advertising |= (ADVERTISED_TP | ADVERTISED_Autoneg);
351 ecmd->port = PORT_TP;
352 } else {
353 ecmd->supported |= SUPPORTED_FIBRE;
354 ecmd->advertising |= ADVERTISED_FIBRE;
355 ecmd->port = PORT_FIBRE;
356 }
357
358 ecmd->speed = SPEED_10000;
359 ecmd->duplex = DUPLEX_FULL;
360
361 return 0;
362}
363
364static void ql_get_drvinfo(struct net_device *ndev,
365 struct ethtool_drvinfo *drvinfo)
366{
367 struct ql_adapter *qdev = netdev_priv(ndev);
368 strncpy(drvinfo->driver, qlge_driver_name, 32);
369 strncpy(drvinfo->version, qlge_driver_version, 32);
cfec0cbc
RM
370 snprintf(drvinfo->fw_version, 32, "v%d.%d.%d",
371 (qdev->fw_rev_id & 0x00ff0000) >> 16,
372 (qdev->fw_rev_id & 0x0000ff00) >> 8,
373 (qdev->fw_rev_id & 0x000000ff));
c4e84bde
RM
374 strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32);
375 drvinfo->n_stats = 0;
376 drvinfo->testinfo_len = 0;
377 drvinfo->regdump_len = 0;
378 drvinfo->eedump_len = 0;
379}
380
bc083ce9
RM
381static void ql_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
382{
383 struct ql_adapter *qdev = netdev_priv(ndev);
384 /* What we support. */
385 wol->supported = WAKE_MAGIC;
386 /* What we've currently got set. */
387 wol->wolopts = qdev->wol;
388}
389
390static int ql_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
391{
392 struct ql_adapter *qdev = netdev_priv(ndev);
393 int status;
394
395 if (wol->wolopts & ~WAKE_MAGIC)
396 return -EINVAL;
397 qdev->wol = wol->wolopts;
398
399 QPRINTK(qdev, DRV, INFO, "Set wol option 0x%x on %s\n",
400 qdev->wol, ndev->name);
401 if (!qdev->wol) {
402 u32 wol = 0;
403 status = ql_mb_wol_mode(qdev, wol);
404 QPRINTK(qdev, DRV, ERR, "WOL %s (wol code 0x%x) on %s\n",
3ad2f3fb 405 (status == 0) ? "cleared successfully" : "clear failed",
bc083ce9
RM
406 wol, qdev->ndev->name);
407 }
408
409 return 0;
410}
d8eb59dc
RM
411
412static int ql_phys_id(struct net_device *ndev, u32 data)
413{
414 struct ql_adapter *qdev = netdev_priv(ndev);
415 u32 led_reg, i;
416 int status;
417
418 /* Save the current LED settings */
419 status = ql_mb_get_led_cfg(qdev);
420 if (status)
421 return status;
422 led_reg = qdev->led_config;
423
424 /* Start blinking the led */
425 if (!data || data > 300)
426 data = 300;
427
428 for (i = 0; i < (data * 10); i++)
429 ql_mb_set_led_cfg(qdev, QL_LED_BLINK);
430
431 /* Restore LED settings */
432 status = ql_mb_set_led_cfg(qdev, led_reg);
433 if (status)
434 return status;
435
436 return 0;
437}
a61f8026 438
9dfbbaa6
RM
439static int ql_start_loopback(struct ql_adapter *qdev)
440{
441 if (netif_carrier_ok(qdev->ndev)) {
442 set_bit(QL_LB_LINK_UP, &qdev->flags);
443 netif_carrier_off(qdev->ndev);
444 } else
445 clear_bit(QL_LB_LINK_UP, &qdev->flags);
446 qdev->link_config |= CFG_LOOPBACK_PCS;
447 return ql_mb_set_port_cfg(qdev);
448}
449
450static void ql_stop_loopback(struct ql_adapter *qdev)
451{
452 qdev->link_config &= ~CFG_LOOPBACK_PCS;
453 ql_mb_set_port_cfg(qdev);
454 if (test_bit(QL_LB_LINK_UP, &qdev->flags)) {
455 netif_carrier_on(qdev->ndev);
456 clear_bit(QL_LB_LINK_UP, &qdev->flags);
457 }
458}
459
460static void ql_create_lb_frame(struct sk_buff *skb,
461 unsigned int frame_size)
462{
463 memset(skb->data, 0xFF, frame_size);
464 frame_size &= ~1;
465 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
466 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
467 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
468}
469
470void ql_check_lb_frame(struct ql_adapter *qdev,
471 struct sk_buff *skb)
472{
473 unsigned int frame_size = skb->len;
474
475 if ((*(skb->data + 3) == 0xFF) &&
476 (*(skb->data + frame_size / 2 + 10) == 0xBE) &&
477 (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
478 atomic_dec(&qdev->lb_count);
479 return;
480 }
481}
482
483static int ql_run_loopback_test(struct ql_adapter *qdev)
484{
485 int i;
486 netdev_tx_t rc;
487 struct sk_buff *skb;
488 unsigned int size = SMALL_BUF_MAP_SIZE;
489
490 for (i = 0; i < 64; i++) {
491 skb = netdev_alloc_skb(qdev->ndev, size);
492 if (!skb)
493 return -ENOMEM;
494
495 skb->queue_mapping = 0;
496 skb_put(skb, size);
497 ql_create_lb_frame(skb, size);
498 rc = ql_lb_send(skb, qdev->ndev);
499 if (rc != NETDEV_TX_OK)
500 return -EPIPE;
501 atomic_inc(&qdev->lb_count);
502 }
503
504 ql_clean_lb_rx_ring(&qdev->rx_ring[0], 128);
505 return atomic_read(&qdev->lb_count) ? -EIO : 0;
506}
507
508static int ql_loopback_test(struct ql_adapter *qdev, u64 *data)
509{
510 *data = ql_start_loopback(qdev);
511 if (*data)
512 goto out;
513 *data = ql_run_loopback_test(qdev);
514out:
515 ql_stop_loopback(qdev);
516 return *data;
517}
518
519static void ql_self_test(struct net_device *ndev,
520 struct ethtool_test *eth_test, u64 *data)
521{
522 struct ql_adapter *qdev = netdev_priv(ndev);
523
524 if (netif_running(ndev)) {
525 set_bit(QL_SELFTEST, &qdev->flags);
526 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
527 /* Offline tests */
528 if (ql_loopback_test(qdev, &data[0]))
529 eth_test->flags |= ETH_TEST_FL_FAILED;
530
531 } else {
532 /* Online tests */
533 data[0] = 0;
534 }
535 clear_bit(QL_SELFTEST, &qdev->flags);
536 } else {
537 QPRINTK(qdev, DRV, ERR,
538 "%s: is down, Loopback test will fail.\n", ndev->name);
539 eth_test->flags |= ETH_TEST_FL_FAILED;
540 }
541}
542
a61f8026
RM
543static int ql_get_regs_len(struct net_device *ndev)
544{
545 return sizeof(struct ql_reg_dump);
546}
547
548static void ql_get_regs(struct net_device *ndev,
549 struct ethtool_regs *regs, void *p)
550{
551 struct ql_adapter *qdev = netdev_priv(ndev);
552
553 ql_gen_reg_dump(qdev, p);
554}
555
c4e84bde
RM
556static int ql_get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
557{
558 struct ql_adapter *qdev = netdev_priv(dev);
559
560 c->rx_coalesce_usecs = qdev->rx_coalesce_usecs;
561 c->tx_coalesce_usecs = qdev->tx_coalesce_usecs;
562
563 /* This chip coalesces as follows:
564 * If a packet arrives, hold off interrupts until
565 * cqicb->int_delay expires, but if no other packets arrive don't
566 * wait longer than cqicb->pkt_int_delay. But ethtool doesn't use a
567 * timer to coalesce on a frame basis. So, we have to take ethtool's
568 * max_coalesced_frames value and convert it to a delay in microseconds.
569 * We do this by using a basic thoughput of 1,000,000 frames per
570 * second @ (1024 bytes). This means one frame per usec. So it's a
571 * simple one to one ratio.
572 */
573 c->rx_max_coalesced_frames = qdev->rx_max_coalesced_frames;
574 c->tx_max_coalesced_frames = qdev->tx_max_coalesced_frames;
575
576 return 0;
577}
578
579static int ql_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *c)
580{
581 struct ql_adapter *qdev = netdev_priv(ndev);
582
583 /* Validate user parameters. */
584 if (c->rx_coalesce_usecs > qdev->rx_ring_size / 2)
585 return -EINVAL;
586 /* Don't wait more than 10 usec. */
587 if (c->rx_max_coalesced_frames > MAX_INTER_FRAME_WAIT)
588 return -EINVAL;
589 if (c->tx_coalesce_usecs > qdev->tx_ring_size / 2)
590 return -EINVAL;
591 if (c->tx_max_coalesced_frames > MAX_INTER_FRAME_WAIT)
592 return -EINVAL;
593
594 /* Verify a change took place before updating the hardware. */
595 if (qdev->rx_coalesce_usecs == c->rx_coalesce_usecs &&
596 qdev->tx_coalesce_usecs == c->tx_coalesce_usecs &&
597 qdev->rx_max_coalesced_frames == c->rx_max_coalesced_frames &&
598 qdev->tx_max_coalesced_frames == c->tx_max_coalesced_frames)
599 return 0;
600
601 qdev->rx_coalesce_usecs = c->rx_coalesce_usecs;
602 qdev->tx_coalesce_usecs = c->tx_coalesce_usecs;
603 qdev->rx_max_coalesced_frames = c->rx_max_coalesced_frames;
604 qdev->tx_max_coalesced_frames = c->tx_max_coalesced_frames;
605
606 return ql_update_ring_coalescing(qdev);
607}
608
1d30df24
RM
609static void ql_get_pauseparam(struct net_device *netdev,
610 struct ethtool_pauseparam *pause)
611{
612 struct ql_adapter *qdev = netdev_priv(netdev);
613
614 ql_mb_get_port_cfg(qdev);
615 if (qdev->link_config & CFG_PAUSE_STD) {
616 pause->rx_pause = 1;
617 pause->tx_pause = 1;
618 }
619}
620
621static int ql_set_pauseparam(struct net_device *netdev,
622 struct ethtool_pauseparam *pause)
623{
624 struct ql_adapter *qdev = netdev_priv(netdev);
625 int status = 0;
626
627 if ((pause->rx_pause) && (pause->tx_pause))
628 qdev->link_config |= CFG_PAUSE_STD;
629 else if (!pause->rx_pause && !pause->tx_pause)
630 qdev->link_config &= ~CFG_PAUSE_STD;
631 else
632 return -EINVAL;
633
634 status = ql_mb_set_port_cfg(qdev);
635 if (status)
636 return status;
637 return status;
638}
639
c4e84bde
RM
640static u32 ql_get_rx_csum(struct net_device *netdev)
641{
642 struct ql_adapter *qdev = netdev_priv(netdev);
643 return qdev->rx_csum;
644}
645
646static int ql_set_rx_csum(struct net_device *netdev, uint32_t data)
647{
648 struct ql_adapter *qdev = netdev_priv(netdev);
649 qdev->rx_csum = data;
650 return 0;
651}
652
653static int ql_set_tso(struct net_device *ndev, uint32_t data)
654{
655
656 if (data) {
657 ndev->features |= NETIF_F_TSO;
658 ndev->features |= NETIF_F_TSO6;
659 } else {
660 ndev->features &= ~NETIF_F_TSO;
661 ndev->features &= ~NETIF_F_TSO6;
662 }
663 return 0;
664}
665
666static u32 ql_get_msglevel(struct net_device *ndev)
667{
668 struct ql_adapter *qdev = netdev_priv(ndev);
669 return qdev->msg_enable;
670}
671
672static void ql_set_msglevel(struct net_device *ndev, u32 value)
673{
674 struct ql_adapter *qdev = netdev_priv(ndev);
675 qdev->msg_enable = value;
676}
677
678const struct ethtool_ops qlge_ethtool_ops = {
679 .get_settings = ql_get_settings,
680 .get_drvinfo = ql_get_drvinfo,
bc083ce9
RM
681 .get_wol = ql_get_wol,
682 .set_wol = ql_set_wol,
a61f8026
RM
683 .get_regs_len = ql_get_regs_len,
684 .get_regs = ql_get_regs,
c4e84bde
RM
685 .get_msglevel = ql_get_msglevel,
686 .set_msglevel = ql_set_msglevel,
687 .get_link = ethtool_op_get_link,
d8eb59dc 688 .phys_id = ql_phys_id,
9dfbbaa6 689 .self_test = ql_self_test,
1d30df24
RM
690 .get_pauseparam = ql_get_pauseparam,
691 .set_pauseparam = ql_set_pauseparam,
c4e84bde
RM
692 .get_rx_csum = ql_get_rx_csum,
693 .set_rx_csum = ql_set_rx_csum,
694 .get_tx_csum = ethtool_op_get_tx_csum,
00acd0d2 695 .set_tx_csum = ethtool_op_set_tx_csum,
c4e84bde
RM
696 .get_sg = ethtool_op_get_sg,
697 .set_sg = ethtool_op_set_sg,
698 .get_tso = ethtool_op_get_tso,
699 .set_tso = ql_set_tso,
700 .get_coalesce = ql_get_coalesce,
701 .set_coalesce = ql_set_coalesce,
702 .get_sset_count = ql_get_sset_count,
703 .get_strings = ql_get_strings,
704 .get_ethtool_stats = ql_get_ethtool_stats,
705};
706