1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
11 #include <linux/netdevice.h>
12 #include <linux/ethtool.h>
13 #include <linux/rtnetlink.h>
14 #include "net_driver.h"
21 const char *efx_loopback_mode_names
[] = {
22 [LOOPBACK_NONE
] = "NONE",
23 [LOOPBACK_GMAC
] = "GMAC",
24 [LOOPBACK_XGMII
] = "XGMII",
25 [LOOPBACK_XGXS
] = "XGXS",
26 [LOOPBACK_XAUI
] = "XAUI",
27 [LOOPBACK_GPHY
] = "GPHY",
28 [LOOPBACK_PHYXS
] = "PHYXS",
29 [LOOPBACK_PCS
] = "PCS",
30 [LOOPBACK_PMAPMD
] = "PMA/PMD",
31 [LOOPBACK_NETWORK
] = "NETWORK",
34 struct ethtool_string
{
35 char name
[ETH_GSTRING_LEN
];
38 struct efx_ethtool_stat
{
41 EFX_ETHTOOL_STAT_SOURCE_mac_stats
,
42 EFX_ETHTOOL_STAT_SOURCE_nic
,
43 EFX_ETHTOOL_STAT_SOURCE_channel
46 u64(*get_stat
) (void *field
); /* Reader function */
49 /* Initialiser for a struct #efx_ethtool_stat with type-checking */
50 #define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
51 get_stat_function) { \
53 .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
54 .offset = ((((field_type *) 0) == \
55 &((struct efx_##source_name *)0)->field) ? \
56 offsetof(struct efx_##source_name, field) : \
57 offsetof(struct efx_##source_name, field)), \
58 .get_stat = get_stat_function, \
61 static u64
efx_get_uint_stat(void *field
)
63 return *(unsigned int *)field
;
66 static u64
efx_get_ulong_stat(void *field
)
68 return *(unsigned long *)field
;
71 static u64
efx_get_u64_stat(void *field
)
73 return *(u64
*) field
;
76 static u64
efx_get_atomic_stat(void *field
)
78 return atomic_read((atomic_t
*) field
);
81 #define EFX_ETHTOOL_ULONG_MAC_STAT(field) \
82 EFX_ETHTOOL_STAT(field, mac_stats, field, \
83 unsigned long, efx_get_ulong_stat)
85 #define EFX_ETHTOOL_U64_MAC_STAT(field) \
86 EFX_ETHTOOL_STAT(field, mac_stats, field, \
87 u64, efx_get_u64_stat)
89 #define EFX_ETHTOOL_UINT_NIC_STAT(name) \
90 EFX_ETHTOOL_STAT(name, nic, n_##name, \
91 unsigned int, efx_get_uint_stat)
93 #define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
94 EFX_ETHTOOL_STAT(field, nic, field, \
95 atomic_t, efx_get_atomic_stat)
97 #define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
98 EFX_ETHTOOL_STAT(field, channel, n_##field, \
99 unsigned int, efx_get_uint_stat)
101 static struct efx_ethtool_stat efx_ethtool_stats
[] = {
102 EFX_ETHTOOL_U64_MAC_STAT(tx_bytes
),
103 EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes
),
104 EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes
),
105 EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets
),
106 EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad
),
107 EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause
),
108 EFX_ETHTOOL_ULONG_MAC_STAT(tx_control
),
109 EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast
),
110 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast
),
111 EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast
),
112 EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64
),
113 EFX_ETHTOOL_ULONG_MAC_STAT(tx_64
),
114 EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127
),
115 EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255
),
116 EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511
),
117 EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023
),
118 EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx
),
119 EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo
),
120 EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo
),
121 EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision
),
122 EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision
),
123 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision
),
124 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision
),
125 EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred
),
126 EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision
),
127 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred
),
128 EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp
),
129 EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error
),
130 EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error
),
131 EFX_ETHTOOL_U64_MAC_STAT(rx_bytes
),
132 EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes
),
133 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes
),
134 EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets
),
135 EFX_ETHTOOL_ULONG_MAC_STAT(rx_good
),
136 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad
),
137 EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause
),
138 EFX_ETHTOOL_ULONG_MAC_STAT(rx_control
),
139 EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast
),
140 EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast
),
141 EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast
),
142 EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64
),
143 EFX_ETHTOOL_ULONG_MAC_STAT(rx_64
),
144 EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127
),
145 EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255
),
146 EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511
),
147 EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023
),
148 EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx
),
149 EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo
),
150 EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo
),
151 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64
),
152 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx
),
153 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo
),
154 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo
),
155 EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow
),
156 EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed
),
157 EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier
),
158 EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error
),
159 EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error
),
160 EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error
),
161 EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error
),
162 EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt
),
163 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset
),
164 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc
),
165 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err
),
166 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err
),
167 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc
),
170 /* Number of ethtool statistics */
171 #define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
173 #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
175 /**************************************************************************
179 **************************************************************************
182 /* Identify device by flashing LEDs */
183 static int efx_ethtool_phys_id(struct net_device
*net_dev
, u32 count
)
185 struct efx_nic
*efx
= netdev_priv(net_dev
);
187 efx
->board_info
.blink(efx
, 1);
188 set_current_state(TASK_INTERRUPTIBLE
);
190 schedule_timeout(count
* HZ
);
193 efx
->board_info
.blink(efx
, 0);
197 /* This must be called with rtnl_lock held. */
198 int efx_ethtool_get_settings(struct net_device
*net_dev
,
199 struct ethtool_cmd
*ecmd
)
201 struct efx_nic
*efx
= netdev_priv(net_dev
);
203 mutex_lock(&efx
->mac_lock
);
204 efx
->phy_op
->get_settings(efx
, ecmd
);
205 mutex_unlock(&efx
->mac_lock
);
207 /* Falcon GMAC does not support 1000Mbps HD */
208 ecmd
->supported
&= ~SUPPORTED_1000baseT_Half
;
213 /* This must be called with rtnl_lock held. */
214 int efx_ethtool_set_settings(struct net_device
*net_dev
,
215 struct ethtool_cmd
*ecmd
)
217 struct efx_nic
*efx
= netdev_priv(net_dev
);
220 /* Falcon GMAC does not support 1000Mbps HD */
221 if (ecmd
->speed
== SPEED_1000
&& ecmd
->duplex
!= DUPLEX_FULL
) {
222 EFX_LOG(efx
, "rejecting unsupported 1000Mbps HD"
227 mutex_lock(&efx
->mac_lock
);
228 rc
= efx
->phy_op
->set_settings(efx
, ecmd
);
229 mutex_unlock(&efx
->mac_lock
);
231 efx_reconfigure_port(efx
);
236 static void efx_ethtool_get_drvinfo(struct net_device
*net_dev
,
237 struct ethtool_drvinfo
*info
)
239 struct efx_nic
*efx
= netdev_priv(net_dev
);
241 strlcpy(info
->driver
, EFX_DRIVER_NAME
, sizeof(info
->driver
));
242 strlcpy(info
->version
, EFX_DRIVER_VERSION
, sizeof(info
->version
));
243 strlcpy(info
->bus_info
, pci_name(efx
->pci_dev
), sizeof(info
->bus_info
));
247 * efx_fill_test - fill in an individual self-test entry
248 * @test_index: Index of the test
249 * @strings: Ethtool strings, or %NULL
250 * @data: Ethtool test results, or %NULL
251 * @test: Pointer to test result (used only if data != %NULL)
252 * @unit_format: Unit name format (e.g. "chan\%d")
253 * @unit_id: Unit id (e.g. 0 for "chan0")
254 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
255 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
257 * Fill in an individual self-test entry.
259 static void efx_fill_test(unsigned int test_index
,
260 struct ethtool_string
*strings
, u64
*data
,
261 int *test
, const char *unit_format
, int unit_id
,
262 const char *test_format
, const char *test_id
)
264 struct ethtool_string unit_str
, test_str
;
266 /* Fill data value, if applicable */
268 data
[test_index
] = *test
;
270 /* Fill string, if applicable */
272 snprintf(unit_str
.name
, sizeof(unit_str
.name
),
273 unit_format
, unit_id
);
274 snprintf(test_str
.name
, sizeof(test_str
.name
),
275 test_format
, test_id
);
276 snprintf(strings
[test_index
].name
,
277 sizeof(strings
[test_index
].name
),
278 "%-6s %-24s", unit_str
.name
, test_str
.name
);
282 #define EFX_PORT_NAME "port%d", 0
283 #define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
284 #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
285 #define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
286 #define EFX_LOOPBACK_NAME(_mode, _counter) \
287 "loopback.%s." _counter, LOOPBACK_MODE_NAME(mode)
290 * efx_fill_loopback_test - fill in a block of loopback self-test entries
292 * @lb_tests: Efx loopback self-test results structure
293 * @mode: Loopback test mode
294 * @test_index: Starting index of the test
295 * @strings: Ethtool strings, or %NULL
296 * @data: Ethtool test results, or %NULL
298 static int efx_fill_loopback_test(struct efx_nic
*efx
,
299 struct efx_loopback_self_tests
*lb_tests
,
300 enum efx_loopback_mode mode
,
301 unsigned int test_index
,
302 struct ethtool_string
*strings
, u64
*data
)
304 struct efx_tx_queue
*tx_queue
;
306 efx_for_each_tx_queue(tx_queue
, efx
) {
307 efx_fill_test(test_index
++, strings
, data
,
308 &lb_tests
->tx_sent
[tx_queue
->queue
],
309 EFX_TX_QUEUE_NAME(tx_queue
),
310 EFX_LOOPBACK_NAME(mode
, "tx_sent"));
311 efx_fill_test(test_index
++, strings
, data
,
312 &lb_tests
->tx_done
[tx_queue
->queue
],
313 EFX_TX_QUEUE_NAME(tx_queue
),
314 EFX_LOOPBACK_NAME(mode
, "tx_done"));
316 efx_fill_test(test_index
++, strings
, data
,
319 EFX_LOOPBACK_NAME(mode
, "rx_good"));
320 efx_fill_test(test_index
++, strings
, data
,
323 EFX_LOOPBACK_NAME(mode
, "rx_bad"));
329 * efx_ethtool_fill_self_tests - get self-test details
331 * @tests: Efx self-test results structure, or %NULL
332 * @strings: Ethtool strings, or %NULL
333 * @data: Ethtool test results, or %NULL
335 static int efx_ethtool_fill_self_tests(struct efx_nic
*efx
,
336 struct efx_self_tests
*tests
,
337 struct ethtool_string
*strings
,
340 struct efx_channel
*channel
;
342 enum efx_loopback_mode mode
;
344 efx_fill_test(n
++, strings
, data
, &tests
->mii
,
345 "core", 0, "mii", NULL
);
346 efx_fill_test(n
++, strings
, data
, &tests
->nvram
,
347 "core", 0, "nvram", NULL
);
348 efx_fill_test(n
++, strings
, data
, &tests
->interrupt
,
349 "core", 0, "interrupt", NULL
);
352 efx_for_each_channel(channel
, efx
) {
353 efx_fill_test(n
++, strings
, data
,
354 &tests
->eventq_dma
[channel
->channel
],
355 EFX_CHANNEL_NAME(channel
),
357 efx_fill_test(n
++, strings
, data
,
358 &tests
->eventq_int
[channel
->channel
],
359 EFX_CHANNEL_NAME(channel
),
361 efx_fill_test(n
++, strings
, data
,
362 &tests
->eventq_poll
[channel
->channel
],
363 EFX_CHANNEL_NAME(channel
),
364 "eventq.poll", NULL
);
367 efx_fill_test(n
++, strings
, data
, &tests
->registers
,
368 "core", 0, "registers", NULL
);
369 efx_fill_test(n
++, strings
, data
, &tests
->phy
,
370 EFX_PORT_NAME
, "phy", NULL
);
373 for (mode
= LOOPBACK_NONE
; mode
<= LOOPBACK_TEST_MAX
; mode
++) {
374 if (!(efx
->loopback_modes
& (1 << mode
)))
376 n
= efx_fill_loopback_test(efx
,
377 &tests
->loopback
[mode
], mode
, n
,
384 static int efx_ethtool_get_sset_count(struct net_device
*net_dev
,
387 switch (string_set
) {
389 return EFX_ETHTOOL_NUM_STATS
;
391 return efx_ethtool_fill_self_tests(netdev_priv(net_dev
),
398 static void efx_ethtool_get_strings(struct net_device
*net_dev
,
399 u32 string_set
, u8
*strings
)
401 struct efx_nic
*efx
= netdev_priv(net_dev
);
402 struct ethtool_string
*ethtool_strings
=
403 (struct ethtool_string
*)strings
;
406 switch (string_set
) {
408 for (i
= 0; i
< EFX_ETHTOOL_NUM_STATS
; i
++)
409 strncpy(ethtool_strings
[i
].name
,
410 efx_ethtool_stats
[i
].name
,
411 sizeof(ethtool_strings
[i
].name
));
414 efx_ethtool_fill_self_tests(efx
, NULL
,
415 ethtool_strings
, NULL
);
418 /* No other string sets */
423 static void efx_ethtool_get_stats(struct net_device
*net_dev
,
424 struct ethtool_stats
*stats
,
427 struct efx_nic
*efx
= netdev_priv(net_dev
);
428 struct efx_mac_stats
*mac_stats
= &efx
->mac_stats
;
429 struct efx_ethtool_stat
*stat
;
430 struct efx_channel
*channel
;
433 EFX_BUG_ON_PARANOID(stats
->n_stats
!= EFX_ETHTOOL_NUM_STATS
);
435 /* Update MAC and NIC statistics */
436 dev_get_stats(net_dev
);
438 /* Fill detailed statistics buffer */
439 for (i
= 0; i
< EFX_ETHTOOL_NUM_STATS
; i
++) {
440 stat
= &efx_ethtool_stats
[i
];
441 switch (stat
->source
) {
442 case EFX_ETHTOOL_STAT_SOURCE_mac_stats
:
443 data
[i
] = stat
->get_stat((void *)mac_stats
+
446 case EFX_ETHTOOL_STAT_SOURCE_nic
:
447 data
[i
] = stat
->get_stat((void *)efx
+ stat
->offset
);
449 case EFX_ETHTOOL_STAT_SOURCE_channel
:
451 efx_for_each_channel(channel
, efx
)
452 data
[i
] += stat
->get_stat((void *)channel
+
459 static int efx_ethtool_set_rx_csum(struct net_device
*net_dev
, u32 enable
)
461 struct efx_nic
*efx
= netdev_priv(net_dev
);
463 /* No way to stop the hardware doing the checks; we just
466 efx
->rx_checksum_enabled
= !!enable
;
471 static u32
efx_ethtool_get_rx_csum(struct net_device
*net_dev
)
473 struct efx_nic
*efx
= netdev_priv(net_dev
);
475 return efx
->rx_checksum_enabled
;
478 static void efx_ethtool_self_test(struct net_device
*net_dev
,
479 struct ethtool_test
*test
, u64
*data
)
481 struct efx_nic
*efx
= netdev_priv(net_dev
);
482 struct efx_self_tests efx_tests
;
483 int offline
, already_up
;
487 if (efx
->state
!= STATE_RUNNING
) {
492 /* We need rx buffers and interrupts. */
493 already_up
= (efx
->net_dev
->flags
& IFF_UP
);
495 rc
= dev_open(efx
->net_dev
);
497 EFX_ERR(efx
, "failed opening device.\n");
502 memset(&efx_tests
, 0, sizeof(efx_tests
));
503 offline
= (test
->flags
& ETH_TEST_FL_OFFLINE
);
505 /* Perform online self tests first */
506 rc
= efx_online_test(efx
, &efx_tests
);
510 /* Perform offline tests only if online tests passed */
512 rc
= efx_offline_test(efx
, &efx_tests
,
513 efx
->loopback_modes
);
517 dev_close(efx
->net_dev
);
519 EFX_LOG(efx
, "%s all %sline self-tests\n",
520 rc
== 0 ? "passed" : "failed", offline
? "off" : "on");
524 /* Fill ethtool results structures */
525 efx_ethtool_fill_self_tests(efx
, &efx_tests
, NULL
, data
);
527 test
->flags
|= ETH_TEST_FL_FAILED
;
530 /* Restart autonegotiation */
531 static int efx_ethtool_nway_reset(struct net_device
*net_dev
)
533 struct efx_nic
*efx
= netdev_priv(net_dev
);
535 return mii_nway_restart(&efx
->mii
);
538 static u32
efx_ethtool_get_link(struct net_device
*net_dev
)
540 struct efx_nic
*efx
= netdev_priv(net_dev
);
545 static int efx_ethtool_get_eeprom_len(struct net_device
*net_dev
)
547 struct efx_nic
*efx
= netdev_priv(net_dev
);
548 struct efx_spi_device
*spi
= efx
->spi_eeprom
;
552 return min(spi
->size
, EFX_EEPROM_BOOTCONFIG_END
) -
553 min(spi
->size
, EFX_EEPROM_BOOTCONFIG_START
);
556 static int efx_ethtool_get_eeprom(struct net_device
*net_dev
,
557 struct ethtool_eeprom
*eeprom
, u8
*buf
)
559 struct efx_nic
*efx
= netdev_priv(net_dev
);
560 struct efx_spi_device
*spi
= efx
->spi_eeprom
;
564 mutex_lock(&efx
->spi_lock
);
565 rc
= falcon_spi_read(spi
, eeprom
->offset
+ EFX_EEPROM_BOOTCONFIG_START
,
566 eeprom
->len
, &len
, buf
);
567 mutex_unlock(&efx
->spi_lock
);
568 eeprom
->magic
= EFX_ETHTOOL_EEPROM_MAGIC
;
573 static int efx_ethtool_set_eeprom(struct net_device
*net_dev
,
574 struct ethtool_eeprom
*eeprom
, u8
*buf
)
576 struct efx_nic
*efx
= netdev_priv(net_dev
);
577 struct efx_spi_device
*spi
= efx
->spi_eeprom
;
581 if (eeprom
->magic
!= EFX_ETHTOOL_EEPROM_MAGIC
)
584 mutex_lock(&efx
->spi_lock
);
585 rc
= falcon_spi_write(spi
, eeprom
->offset
+ EFX_EEPROM_BOOTCONFIG_START
,
586 eeprom
->len
, &len
, buf
);
587 mutex_unlock(&efx
->spi_lock
);
592 static int efx_ethtool_get_coalesce(struct net_device
*net_dev
,
593 struct ethtool_coalesce
*coalesce
)
595 struct efx_nic
*efx
= netdev_priv(net_dev
);
596 struct efx_tx_queue
*tx_queue
;
597 struct efx_rx_queue
*rx_queue
;
598 struct efx_channel
*channel
;
600 memset(coalesce
, 0, sizeof(*coalesce
));
602 /* Find lowest IRQ moderation across all used TX queues */
603 coalesce
->tx_coalesce_usecs_irq
= ~((u32
) 0);
604 efx_for_each_tx_queue(tx_queue
, efx
) {
605 channel
= tx_queue
->channel
;
606 if (channel
->irq_moderation
< coalesce
->tx_coalesce_usecs_irq
) {
607 if (channel
->used_flags
!= EFX_USED_BY_RX_TX
)
608 coalesce
->tx_coalesce_usecs_irq
=
609 channel
->irq_moderation
;
611 coalesce
->tx_coalesce_usecs_irq
= 0;
615 /* Find lowest IRQ moderation across all used RX queues */
616 coalesce
->rx_coalesce_usecs_irq
= ~((u32
) 0);
617 efx_for_each_rx_queue(rx_queue
, efx
) {
618 channel
= rx_queue
->channel
;
619 if (channel
->irq_moderation
< coalesce
->rx_coalesce_usecs_irq
)
620 coalesce
->rx_coalesce_usecs_irq
=
621 channel
->irq_moderation
;
627 /* Set coalescing parameters
628 * The difficulties occur for shared channels
630 static int efx_ethtool_set_coalesce(struct net_device
*net_dev
,
631 struct ethtool_coalesce
*coalesce
)
633 struct efx_nic
*efx
= netdev_priv(net_dev
);
634 struct efx_channel
*channel
;
635 struct efx_tx_queue
*tx_queue
;
636 unsigned tx_usecs
, rx_usecs
;
638 if (coalesce
->use_adaptive_rx_coalesce
||
639 coalesce
->use_adaptive_tx_coalesce
)
642 if (coalesce
->rx_coalesce_usecs
|| coalesce
->tx_coalesce_usecs
) {
643 EFX_ERR(efx
, "invalid coalescing setting. "
644 "Only rx/tx_coalesce_usecs_irq are supported\n");
648 rx_usecs
= coalesce
->rx_coalesce_usecs_irq
;
649 tx_usecs
= coalesce
->tx_coalesce_usecs_irq
;
651 /* If the channel is shared only allow RX parameters to be set */
652 efx_for_each_tx_queue(tx_queue
, efx
) {
653 if ((tx_queue
->channel
->used_flags
== EFX_USED_BY_RX_TX
) &&
655 EFX_ERR(efx
, "Channel is shared. "
656 "Only RX coalescing may be set\n");
661 efx_init_irq_moderation(efx
, tx_usecs
, rx_usecs
);
663 /* Reset channel to pick up new moderation value. Note that
664 * this may change the value of the irq_moderation field
665 * (e.g. to allow for hardware timer granularity).
667 efx_for_each_channel(channel
, efx
)
668 falcon_set_int_moderation(channel
);
673 static int efx_ethtool_set_pauseparam(struct net_device
*net_dev
,
674 struct ethtool_pauseparam
*pause
)
676 struct efx_nic
*efx
= netdev_priv(net_dev
);
677 enum efx_fc_type flow_control
= efx
->flow_control
;
679 flow_control
&= ~(EFX_FC_RX
| EFX_FC_TX
| EFX_FC_AUTO
);
680 flow_control
|= pause
->rx_pause
? EFX_FC_RX
: 0;
681 flow_control
|= pause
->tx_pause
? EFX_FC_TX
: 0;
682 flow_control
|= pause
->autoneg
? EFX_FC_AUTO
: 0;
684 efx_reconfigure_port(efx
);
688 static void efx_ethtool_get_pauseparam(struct net_device
*net_dev
,
689 struct ethtool_pauseparam
*pause
)
691 struct efx_nic
*efx
= netdev_priv(net_dev
);
693 pause
->rx_pause
= !!(efx
->flow_control
& EFX_FC_RX
);
694 pause
->tx_pause
= !!(efx
->flow_control
& EFX_FC_TX
);
695 pause
->autoneg
= !!(efx
->flow_control
& EFX_FC_AUTO
);
699 struct ethtool_ops efx_ethtool_ops
= {
700 .get_settings
= efx_ethtool_get_settings
,
701 .set_settings
= efx_ethtool_set_settings
,
702 .get_drvinfo
= efx_ethtool_get_drvinfo
,
703 .nway_reset
= efx_ethtool_nway_reset
,
704 .get_link
= efx_ethtool_get_link
,
705 .get_eeprom_len
= efx_ethtool_get_eeprom_len
,
706 .get_eeprom
= efx_ethtool_get_eeprom
,
707 .set_eeprom
= efx_ethtool_set_eeprom
,
708 .get_coalesce
= efx_ethtool_get_coalesce
,
709 .set_coalesce
= efx_ethtool_set_coalesce
,
710 .get_pauseparam
= efx_ethtool_get_pauseparam
,
711 .set_pauseparam
= efx_ethtool_set_pauseparam
,
712 .get_rx_csum
= efx_ethtool_get_rx_csum
,
713 .set_rx_csum
= efx_ethtool_set_rx_csum
,
714 .get_tx_csum
= ethtool_op_get_tx_csum
,
715 .set_tx_csum
= ethtool_op_set_tx_csum
,
716 .get_sg
= ethtool_op_get_sg
,
717 .set_sg
= ethtool_op_set_sg
,
718 .get_tso
= ethtool_op_get_tso
,
719 .set_tso
= ethtool_op_set_tso
,
720 .get_flags
= ethtool_op_get_flags
,
721 .set_flags
= ethtool_op_set_flags
,
722 .get_sset_count
= efx_ethtool_get_sset_count
,
723 .self_test
= efx_ethtool_self_test
,
724 .get_strings
= efx_ethtool_get_strings
,
725 .phys_id
= efx_ethtool_phys_id
,
726 .get_ethtool_stats
= efx_ethtool_get_stats
,