1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (C) 2018 Microchip Technology Inc. */
4 #include <linux/netdevice.h>
5 #include "lan743x_main.h"
6 #include "lan743x_ethtool.h"
7 #include <linux/net_tstamp.h>
12 #define LAN743X_EEPROM_MAGIC (0x74A5)
13 #define LAN743X_OTP_MAGIC (0x74F3)
14 #define EEPROM_INDICATOR_1 (0xA5)
15 #define EEPROM_INDICATOR_2 (0xAA)
16 #define EEPROM_MAC_OFFSET (0x01)
17 #define MAX_EEPROM_SIZE (512)
18 #define MAX_OTP_SIZE (1024)
19 #define OTP_INDICATOR_1 (0xF3)
20 #define OTP_INDICATOR_2 (0xF7)
22 static int lan743x_otp_power_up(struct lan743x_adapter
*adapter
)
26 reg_value
= lan743x_csr_read(adapter
, OTP_PWR_DN
);
28 if (reg_value
& OTP_PWR_DN_PWRDN_N_
) {
29 /* clear it and wait to be cleared */
30 reg_value
&= ~OTP_PWR_DN_PWRDN_N_
;
31 lan743x_csr_write(adapter
, OTP_PWR_DN
, reg_value
);
33 usleep_range(100, 20000);
39 static void lan743x_otp_power_down(struct lan743x_adapter
*adapter
)
43 reg_value
= lan743x_csr_read(adapter
, OTP_PWR_DN
);
44 if (!(reg_value
& OTP_PWR_DN_PWRDN_N_
)) {
45 /* set power down bit */
46 reg_value
|= OTP_PWR_DN_PWRDN_N_
;
47 lan743x_csr_write(adapter
, OTP_PWR_DN
, reg_value
);
51 static void lan743x_otp_set_address(struct lan743x_adapter
*adapter
,
54 lan743x_csr_write(adapter
, OTP_ADDR_HIGH
, (address
>> 8) & 0x03);
55 lan743x_csr_write(adapter
, OTP_ADDR_LOW
, address
& 0xFF);
58 static void lan743x_otp_read_go(struct lan743x_adapter
*adapter
)
60 lan743x_csr_write(adapter
, OTP_FUNC_CMD
, OTP_FUNC_CMD_READ_
);
61 lan743x_csr_write(adapter
, OTP_CMD_GO
, OTP_CMD_GO_GO_
);
64 static int lan743x_otp_wait_till_not_busy(struct lan743x_adapter
*adapter
)
66 unsigned long timeout
;
69 timeout
= jiffies
+ HZ
;
71 if (time_after(jiffies
, timeout
)) {
72 netif_warn(adapter
, drv
, adapter
->netdev
,
73 "Timeout on OTP_STATUS completion\n");
77 reg_val
= lan743x_csr_read(adapter
, OTP_STATUS
);
78 } while (reg_val
& OTP_STATUS_BUSY_
);
83 static int lan743x_otp_read(struct lan743x_adapter
*adapter
, u32 offset
,
89 if (offset
+ length
> MAX_OTP_SIZE
)
92 ret
= lan743x_otp_power_up(adapter
);
96 ret
= lan743x_otp_wait_till_not_busy(adapter
);
100 for (i
= 0; i
< length
; i
++) {
101 lan743x_otp_set_address(adapter
, offset
+ i
);
103 lan743x_otp_read_go(adapter
);
104 ret
= lan743x_otp_wait_till_not_busy(adapter
);
107 data
[i
] = lan743x_csr_read(adapter
, OTP_READ_DATA
);
110 lan743x_otp_power_down(adapter
);
115 static int lan743x_otp_write(struct lan743x_adapter
*adapter
, u32 offset
,
116 u32 length
, u8
*data
)
121 if (offset
+ length
> MAX_OTP_SIZE
)
124 ret
= lan743x_otp_power_up(adapter
);
128 ret
= lan743x_otp_wait_till_not_busy(adapter
);
132 /* set to BYTE program mode */
133 lan743x_csr_write(adapter
, OTP_PRGM_MODE
, OTP_PRGM_MODE_BYTE_
);
135 for (i
= 0; i
< length
; i
++) {
136 lan743x_otp_set_address(adapter
, offset
+ i
);
138 lan743x_csr_write(adapter
, OTP_PRGM_DATA
, data
[i
]);
139 lan743x_csr_write(adapter
, OTP_TST_CMD
, OTP_TST_CMD_PRGVRFY_
);
140 lan743x_csr_write(adapter
, OTP_CMD_GO
, OTP_CMD_GO_GO_
);
142 ret
= lan743x_otp_wait_till_not_busy(adapter
);
147 lan743x_otp_power_down(adapter
);
152 static int lan743x_eeprom_wait(struct lan743x_adapter
*adapter
)
154 unsigned long start_time
= jiffies
;
158 val
= lan743x_csr_read(adapter
, E2P_CMD
);
160 if (!(val
& E2P_CMD_EPC_BUSY_
) ||
161 (val
& E2P_CMD_EPC_TIMEOUT_
))
163 usleep_range(40, 100);
164 } while (!time_after(jiffies
, start_time
+ HZ
));
166 if (val
& (E2P_CMD_EPC_TIMEOUT_
| E2P_CMD_EPC_BUSY_
)) {
167 netif_warn(adapter
, drv
, adapter
->netdev
,
168 "EEPROM read operation timeout\n");
175 static int lan743x_eeprom_confirm_not_busy(struct lan743x_adapter
*adapter
)
177 unsigned long start_time
= jiffies
;
181 val
= lan743x_csr_read(adapter
, E2P_CMD
);
183 if (!(val
& E2P_CMD_EPC_BUSY_
))
186 usleep_range(40, 100);
187 } while (!time_after(jiffies
, start_time
+ HZ
));
189 netif_warn(adapter
, drv
, adapter
->netdev
, "EEPROM is busy\n");
193 static int lan743x_eeprom_read(struct lan743x_adapter
*adapter
,
194 u32 offset
, u32 length
, u8
*data
)
200 if (offset
+ length
> MAX_EEPROM_SIZE
)
203 retval
= lan743x_eeprom_confirm_not_busy(adapter
);
207 for (i
= 0; i
< length
; i
++) {
208 val
= E2P_CMD_EPC_BUSY_
| E2P_CMD_EPC_CMD_READ_
;
209 val
|= (offset
& E2P_CMD_EPC_ADDR_MASK_
);
210 lan743x_csr_write(adapter
, E2P_CMD
, val
);
212 retval
= lan743x_eeprom_wait(adapter
);
216 val
= lan743x_csr_read(adapter
, E2P_DATA
);
217 data
[i
] = val
& 0xFF;
224 static int lan743x_eeprom_write(struct lan743x_adapter
*adapter
,
225 u32 offset
, u32 length
, u8
*data
)
231 if (offset
+ length
> MAX_EEPROM_SIZE
)
234 retval
= lan743x_eeprom_confirm_not_busy(adapter
);
238 /* Issue write/erase enable command */
239 val
= E2P_CMD_EPC_BUSY_
| E2P_CMD_EPC_CMD_EWEN_
;
240 lan743x_csr_write(adapter
, E2P_CMD
, val
);
242 retval
= lan743x_eeprom_wait(adapter
);
246 for (i
= 0; i
< length
; i
++) {
247 /* Fill data register */
249 lan743x_csr_write(adapter
, E2P_DATA
, val
);
251 /* Send "write" command */
252 val
= E2P_CMD_EPC_BUSY_
| E2P_CMD_EPC_CMD_WRITE_
;
253 val
|= (offset
& E2P_CMD_EPC_ADDR_MASK_
);
254 lan743x_csr_write(adapter
, E2P_CMD
, val
);
256 retval
= lan743x_eeprom_wait(adapter
);
266 static void lan743x_ethtool_get_drvinfo(struct net_device
*netdev
,
267 struct ethtool_drvinfo
*info
)
269 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
271 strlcpy(info
->driver
, DRIVER_NAME
, sizeof(info
->driver
));
272 strlcpy(info
->bus_info
,
273 pci_name(adapter
->pdev
), sizeof(info
->bus_info
));
276 static u32
lan743x_ethtool_get_msglevel(struct net_device
*netdev
)
278 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
280 return adapter
->msg_enable
;
283 static void lan743x_ethtool_set_msglevel(struct net_device
*netdev
,
286 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
288 adapter
->msg_enable
= msglevel
;
291 static int lan743x_ethtool_get_eeprom_len(struct net_device
*netdev
)
293 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
295 if (adapter
->flags
& LAN743X_ADAPTER_FLAG_OTP
)
298 return MAX_EEPROM_SIZE
;
301 static int lan743x_ethtool_get_eeprom(struct net_device
*netdev
,
302 struct ethtool_eeprom
*ee
, u8
*data
)
304 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
307 if (adapter
->flags
& LAN743X_ADAPTER_FLAG_OTP
)
308 ret
= lan743x_otp_read(adapter
, ee
->offset
, ee
->len
, data
);
310 ret
= lan743x_eeprom_read(adapter
, ee
->offset
, ee
->len
, data
);
315 static int lan743x_ethtool_set_eeprom(struct net_device
*netdev
,
316 struct ethtool_eeprom
*ee
, u8
*data
)
318 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
321 if (adapter
->flags
& LAN743X_ADAPTER_FLAG_OTP
) {
322 /* Beware! OTP is One Time Programming ONLY! */
323 if (ee
->magic
== LAN743X_OTP_MAGIC
) {
324 ret
= lan743x_otp_write(adapter
, ee
->offset
,
328 if (ee
->magic
== LAN743X_EEPROM_MAGIC
) {
329 ret
= lan743x_eeprom_write(adapter
, ee
->offset
,
337 static const char lan743x_set0_hw_cnt_strings
[][ETH_GSTRING_LEN
] = {
339 "RX Alignment Errors",
340 "Rx Fragment Errors",
342 "RX Undersize Frame Errors",
343 "RX Oversize Frame Errors",
345 "RX Unicast Byte Count",
346 "RX Broadcast Byte Count",
347 "RX Multicast Byte Count",
349 "RX Broadcast Frames",
350 "RX Multicast Frames",
353 "RX 65 - 127 Byte Frames",
354 "RX 128 - 255 Byte Frames",
355 "RX 256 - 511 Bytes Frames",
356 "RX 512 - 1023 Byte Frames",
357 "RX 1024 - 1518 Byte Frames",
358 "RX Greater 1518 Byte Frames",
361 static const char lan743x_set1_sw_cnt_strings
[][ETH_GSTRING_LEN
] = {
368 static const char lan743x_set2_hw_cnt_strings
[][ETH_GSTRING_LEN
] = {
370 "EEE RX LPI Transitions",
372 "RX Counter Rollover Status",
374 "TX Excess Deferral Errors",
377 "TX Single Collisions",
378 "TX Multiple Collisions",
379 "TX Excessive Collision",
380 "TX Late Collisions",
381 "TX Unicast Byte Count",
382 "TX Broadcast Byte Count",
383 "TX Multicast Byte Count",
385 "TX Broadcast Frames",
386 "TX Multicast Frames",
389 "TX 65 - 127 Byte Frames",
390 "TX 128 - 255 Byte Frames",
391 "TX 256 - 511 Bytes Frames",
392 "TX 512 - 1023 Byte Frames",
393 "TX 1024 - 1518 Byte Frames",
394 "TX Greater 1518 Byte Frames",
396 "EEE TX LPI Transitions",
398 "TX Counter Rollover Status",
401 static const u32 lan743x_set0_hw_cnt_addr
[] = {
403 STAT_RX_ALIGNMENT_ERRORS
,
404 STAT_RX_FRAGMENT_ERRORS
,
405 STAT_RX_JABBER_ERRORS
,
406 STAT_RX_UNDERSIZE_FRAME_ERRORS
,
407 STAT_RX_OVERSIZE_FRAME_ERRORS
,
408 STAT_RX_DROPPED_FRAMES
,
409 STAT_RX_UNICAST_BYTE_COUNT
,
410 STAT_RX_BROADCAST_BYTE_COUNT
,
411 STAT_RX_MULTICAST_BYTE_COUNT
,
412 STAT_RX_UNICAST_FRAMES
,
413 STAT_RX_BROADCAST_FRAMES
,
414 STAT_RX_MULTICAST_FRAMES
,
415 STAT_RX_PAUSE_FRAMES
,
416 STAT_RX_64_BYTE_FRAMES
,
417 STAT_RX_65_127_BYTE_FRAMES
,
418 STAT_RX_128_255_BYTE_FRAMES
,
419 STAT_RX_256_511_BYTES_FRAMES
,
420 STAT_RX_512_1023_BYTE_FRAMES
,
421 STAT_RX_1024_1518_BYTE_FRAMES
,
422 STAT_RX_GREATER_1518_BYTE_FRAMES
,
425 static const u32 lan743x_set2_hw_cnt_addr
[] = {
426 STAT_RX_TOTAL_FRAMES
,
427 STAT_EEE_RX_LPI_TRANSITIONS
,
428 STAT_EEE_RX_LPI_TIME
,
429 STAT_RX_COUNTER_ROLLOVER_STATUS
,
431 STAT_TX_EXCESS_DEFERRAL_ERRORS
,
432 STAT_TX_CARRIER_ERRORS
,
433 STAT_TX_BAD_BYTE_COUNT
,
434 STAT_TX_SINGLE_COLLISIONS
,
435 STAT_TX_MULTIPLE_COLLISIONS
,
436 STAT_TX_EXCESSIVE_COLLISION
,
437 STAT_TX_LATE_COLLISIONS
,
438 STAT_TX_UNICAST_BYTE_COUNT
,
439 STAT_TX_BROADCAST_BYTE_COUNT
,
440 STAT_TX_MULTICAST_BYTE_COUNT
,
441 STAT_TX_UNICAST_FRAMES
,
442 STAT_TX_BROADCAST_FRAMES
,
443 STAT_TX_MULTICAST_FRAMES
,
444 STAT_TX_PAUSE_FRAMES
,
445 STAT_TX_64_BYTE_FRAMES
,
446 STAT_TX_65_127_BYTE_FRAMES
,
447 STAT_TX_128_255_BYTE_FRAMES
,
448 STAT_TX_256_511_BYTES_FRAMES
,
449 STAT_TX_512_1023_BYTE_FRAMES
,
450 STAT_TX_1024_1518_BYTE_FRAMES
,
451 STAT_TX_GREATER_1518_BYTE_FRAMES
,
452 STAT_TX_TOTAL_FRAMES
,
453 STAT_EEE_TX_LPI_TRANSITIONS
,
454 STAT_EEE_TX_LPI_TIME
,
455 STAT_TX_COUNTER_ROLLOVER_STATUS
458 static const char lan743x_priv_flags_strings
[][ETH_GSTRING_LEN
] = {
462 static void lan743x_ethtool_get_strings(struct net_device
*netdev
,
463 u32 stringset
, u8
*data
)
467 memcpy(data
, lan743x_set0_hw_cnt_strings
,
468 sizeof(lan743x_set0_hw_cnt_strings
));
469 memcpy(&data
[sizeof(lan743x_set0_hw_cnt_strings
)],
470 lan743x_set1_sw_cnt_strings
,
471 sizeof(lan743x_set1_sw_cnt_strings
));
472 memcpy(&data
[sizeof(lan743x_set0_hw_cnt_strings
) +
473 sizeof(lan743x_set1_sw_cnt_strings
)],
474 lan743x_set2_hw_cnt_strings
,
475 sizeof(lan743x_set2_hw_cnt_strings
));
477 case ETH_SS_PRIV_FLAGS
:
478 memcpy(data
, lan743x_priv_flags_strings
,
479 sizeof(lan743x_priv_flags_strings
));
484 static void lan743x_ethtool_get_ethtool_stats(struct net_device
*netdev
,
485 struct ethtool_stats
*stats
,
488 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
493 for (i
= 0; i
< ARRAY_SIZE(lan743x_set0_hw_cnt_addr
); i
++) {
494 buf
= lan743x_csr_read(adapter
, lan743x_set0_hw_cnt_addr
[i
]);
495 data
[data_index
++] = (u64
)buf
;
497 for (i
= 0; i
< ARRAY_SIZE(adapter
->rx
); i
++)
498 data
[data_index
++] = (u64
)(adapter
->rx
[i
].frame_count
);
499 for (i
= 0; i
< ARRAY_SIZE(lan743x_set2_hw_cnt_addr
); i
++) {
500 buf
= lan743x_csr_read(adapter
, lan743x_set2_hw_cnt_addr
[i
]);
501 data
[data_index
++] = (u64
)buf
;
505 static u32
lan743x_ethtool_get_priv_flags(struct net_device
*netdev
)
507 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
509 return adapter
->flags
;
512 static int lan743x_ethtool_set_priv_flags(struct net_device
*netdev
, u32 flags
)
514 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
516 adapter
->flags
= flags
;
521 static int lan743x_ethtool_get_sset_count(struct net_device
*netdev
, int sset
)
528 ret
= ARRAY_SIZE(lan743x_set0_hw_cnt_strings
);
529 ret
+= ARRAY_SIZE(lan743x_set1_sw_cnt_strings
);
530 ret
+= ARRAY_SIZE(lan743x_set2_hw_cnt_strings
);
533 case ETH_SS_PRIV_FLAGS
:
534 return ARRAY_SIZE(lan743x_priv_flags_strings
);
540 static int lan743x_ethtool_get_rxnfc(struct net_device
*netdev
,
541 struct ethtool_rxnfc
*rxnfc
,
544 switch (rxnfc
->cmd
) {
547 switch (rxnfc
->flow_type
) {
548 case TCP_V4_FLOW
:case UDP_V4_FLOW
:
549 case TCP_V6_FLOW
:case UDP_V6_FLOW
:
550 rxnfc
->data
|= RXH_L4_B_0_1
| RXH_L4_B_2_3
;
552 case IPV4_FLOW
: case IPV6_FLOW
:
553 rxnfc
->data
|= RXH_IP_SRC
| RXH_IP_DST
;
557 case ETHTOOL_GRXRINGS
:
558 rxnfc
->data
= LAN743X_USED_RX_CHANNELS
;
564 static u32
lan743x_ethtool_get_rxfh_key_size(struct net_device
*netdev
)
569 static u32
lan743x_ethtool_get_rxfh_indir_size(struct net_device
*netdev
)
574 static int lan743x_ethtool_get_rxfh(struct net_device
*netdev
,
575 u32
*indir
, u8
*key
, u8
*hfunc
)
577 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
583 for (dw_index
= 0; dw_index
< 32; dw_index
++) {
585 lan743x_csr_read(adapter
, RFE_INDX(dw_index
));
587 byte_index
= dw_index
<< 2;
588 indir
[byte_index
+ 0] =
589 ((four_entries
>> 0) & 0x000000FF);
590 indir
[byte_index
+ 1] =
591 ((four_entries
>> 8) & 0x000000FF);
592 indir
[byte_index
+ 2] =
593 ((four_entries
>> 16) & 0x000000FF);
594 indir
[byte_index
+ 3] =
595 ((four_entries
>> 24) & 0x000000FF);
602 for (dword_index
= 0; dword_index
< 10; dword_index
++) {
604 lan743x_csr_read(adapter
,
605 RFE_HASH_KEY(dword_index
));
607 byte_index
= dword_index
<< 2;
608 key
[byte_index
+ 0] =
609 ((four_entries
>> 0) & 0x000000FF);
610 key
[byte_index
+ 1] =
611 ((four_entries
>> 8) & 0x000000FF);
612 key
[byte_index
+ 2] =
613 ((four_entries
>> 16) & 0x000000FF);
614 key
[byte_index
+ 3] =
615 ((four_entries
>> 24) & 0x000000FF);
619 (*hfunc
) = ETH_RSS_HASH_TOP
;
623 static int lan743x_ethtool_set_rxfh(struct net_device
*netdev
,
624 const u32
*indir
, const u8
*key
,
627 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
629 if (hfunc
!= ETH_RSS_HASH_NO_CHANGE
&& hfunc
!= ETH_RSS_HASH_TOP
)
637 for (dword_index
= 0; dword_index
< 32; dword_index
++) {
638 byte_index
= dword_index
<< 2;
640 (((indir
[byte_index
+ 0] & 0x000000FF) << 0) |
641 ((indir
[byte_index
+ 1] & 0x000000FF) << 8) |
642 ((indir
[byte_index
+ 2] & 0x000000FF) << 16) |
643 ((indir
[byte_index
+ 3] & 0x000000FF) << 24));
644 lan743x_csr_write(adapter
, RFE_INDX(dword_index
),
653 for (dword_index
= 0; dword_index
< 10; dword_index
++) {
654 byte_index
= dword_index
<< 2;
656 ((((u32
)(key
[byte_index
+ 0])) << 0) |
657 (((u32
)(key
[byte_index
+ 1])) << 8) |
658 (((u32
)(key
[byte_index
+ 2])) << 16) |
659 (((u32
)(key
[byte_index
+ 3])) << 24));
660 lan743x_csr_write(adapter
, RFE_HASH_KEY(dword_index
),
667 static int lan743x_ethtool_get_ts_info(struct net_device
*netdev
,
668 struct ethtool_ts_info
*ts_info
)
670 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
672 ts_info
->so_timestamping
= SOF_TIMESTAMPING_TX_SOFTWARE
|
673 SOF_TIMESTAMPING_RX_SOFTWARE
|
674 SOF_TIMESTAMPING_SOFTWARE
|
675 SOF_TIMESTAMPING_TX_HARDWARE
|
676 SOF_TIMESTAMPING_RX_HARDWARE
|
677 SOF_TIMESTAMPING_RAW_HARDWARE
;
679 if (adapter
->ptp
.ptp_clock
)
680 ts_info
->phc_index
= ptp_clock_index(adapter
->ptp
.ptp_clock
);
682 ts_info
->phc_index
= -1;
684 ts_info
->tx_types
= BIT(HWTSTAMP_TX_OFF
) |
685 BIT(HWTSTAMP_TX_ON
) |
686 BIT(HWTSTAMP_TX_ONESTEP_SYNC
);
687 ts_info
->rx_filters
= BIT(HWTSTAMP_FILTER_NONE
) |
688 BIT(HWTSTAMP_FILTER_ALL
);
692 static int lan743x_ethtool_get_eee(struct net_device
*netdev
,
693 struct ethtool_eee
*eee
)
695 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
696 struct phy_device
*phydev
= netdev
->phydev
;
703 netif_err(adapter
, drv
, adapter
->netdev
,
704 "Missing PHY Driver\n");
708 ret
= phy_ethtool_get_eee(phydev
, eee
);
712 buf
= lan743x_csr_read(adapter
, MAC_CR
);
713 if (buf
& MAC_CR_EEE_EN_
) {
714 eee
->eee_enabled
= true;
715 eee
->eee_active
= !!(eee
->advertised
& eee
->lp_advertised
);
716 eee
->tx_lpi_enabled
= true;
717 /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */
718 buf
= lan743x_csr_read(adapter
, MAC_EEE_TX_LPI_REQ_DLY_CNT
);
719 eee
->tx_lpi_timer
= buf
;
721 eee
->eee_enabled
= false;
722 eee
->eee_active
= false;
723 eee
->tx_lpi_enabled
= false;
724 eee
->tx_lpi_timer
= 0;
730 static int lan743x_ethtool_set_eee(struct net_device
*netdev
,
731 struct ethtool_eee
*eee
)
733 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
734 struct phy_device
*phydev
= NULL
;
740 adapter
= netdev_priv(netdev
);
743 phydev
= netdev
->phydev
;
747 netif_err(adapter
, drv
, adapter
->netdev
,
748 "Missing PHY Driver\n");
752 if (eee
->eee_enabled
) {
753 ret
= phy_init_eee(phydev
, 0);
755 netif_err(adapter
, drv
, adapter
->netdev
,
756 "EEE initialization failed\n");
760 buf
= (u32
)eee
->tx_lpi_timer
;
761 lan743x_csr_write(adapter
, MAC_EEE_TX_LPI_REQ_DLY_CNT
, buf
);
763 buf
= lan743x_csr_read(adapter
, MAC_CR
);
764 buf
|= MAC_CR_EEE_EN_
;
765 lan743x_csr_write(adapter
, MAC_CR
, buf
);
767 buf
= lan743x_csr_read(adapter
, MAC_CR
);
768 buf
&= ~MAC_CR_EEE_EN_
;
769 lan743x_csr_write(adapter
, MAC_CR
, buf
);
772 return phy_ethtool_set_eee(phydev
, eee
);
776 static void lan743x_ethtool_get_wol(struct net_device
*netdev
,
777 struct ethtool_wolinfo
*wol
)
779 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
783 phy_ethtool_get_wol(netdev
->phydev
, wol
);
785 wol
->supported
|= WAKE_BCAST
| WAKE_UCAST
| WAKE_MCAST
|
786 WAKE_MAGIC
| WAKE_PHY
| WAKE_ARP
;
788 wol
->wolopts
|= adapter
->wolopts
;
791 static int lan743x_ethtool_set_wol(struct net_device
*netdev
,
792 struct ethtool_wolinfo
*wol
)
794 struct lan743x_adapter
*adapter
= netdev_priv(netdev
);
796 adapter
->wolopts
= 0;
797 if (wol
->wolopts
& WAKE_UCAST
)
798 adapter
->wolopts
|= WAKE_UCAST
;
799 if (wol
->wolopts
& WAKE_MCAST
)
800 adapter
->wolopts
|= WAKE_MCAST
;
801 if (wol
->wolopts
& WAKE_BCAST
)
802 adapter
->wolopts
|= WAKE_BCAST
;
803 if (wol
->wolopts
& WAKE_MAGIC
)
804 adapter
->wolopts
|= WAKE_MAGIC
;
805 if (wol
->wolopts
& WAKE_PHY
)
806 adapter
->wolopts
|= WAKE_PHY
;
807 if (wol
->wolopts
& WAKE_ARP
)
808 adapter
->wolopts
|= WAKE_ARP
;
810 device_set_wakeup_enable(&adapter
->pdev
->dev
, (bool)wol
->wolopts
);
812 phy_ethtool_set_wol(netdev
->phydev
, wol
);
816 #endif /* CONFIG_PM */
818 const struct ethtool_ops lan743x_ethtool_ops
= {
819 .get_drvinfo
= lan743x_ethtool_get_drvinfo
,
820 .get_msglevel
= lan743x_ethtool_get_msglevel
,
821 .set_msglevel
= lan743x_ethtool_set_msglevel
,
822 .get_link
= ethtool_op_get_link
,
824 .get_eeprom_len
= lan743x_ethtool_get_eeprom_len
,
825 .get_eeprom
= lan743x_ethtool_get_eeprom
,
826 .set_eeprom
= lan743x_ethtool_set_eeprom
,
827 .get_strings
= lan743x_ethtool_get_strings
,
828 .get_ethtool_stats
= lan743x_ethtool_get_ethtool_stats
,
829 .get_priv_flags
= lan743x_ethtool_get_priv_flags
,
830 .set_priv_flags
= lan743x_ethtool_set_priv_flags
,
831 .get_sset_count
= lan743x_ethtool_get_sset_count
,
832 .get_rxnfc
= lan743x_ethtool_get_rxnfc
,
833 .get_rxfh_key_size
= lan743x_ethtool_get_rxfh_key_size
,
834 .get_rxfh_indir_size
= lan743x_ethtool_get_rxfh_indir_size
,
835 .get_rxfh
= lan743x_ethtool_get_rxfh
,
836 .set_rxfh
= lan743x_ethtool_set_rxfh
,
837 .get_ts_info
= lan743x_ethtool_get_ts_info
,
838 .get_eee
= lan743x_ethtool_get_eee
,
839 .set_eee
= lan743x_ethtool_set_eee
,
840 .get_link_ksettings
= phy_ethtool_get_link_ksettings
,
841 .set_link_ksettings
= phy_ethtool_set_link_ksettings
,
843 .get_wol
= lan743x_ethtool_get_wol
,
844 .set_wol
= lan743x_ethtool_set_wol
,