92 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
94 #define DRV_NAME "8139too"
95 #define DRV_VERSION "0.9.28"
98 #include <linux/module.h>
99 #include <linux/kernel.h>
100 #include <linux/compiler.h>
101 #include <linux/pci.h>
104 #include <linux/netdevice.h>
106 #include <linux/rtnetlink.h>
108 #include <linux/ethtool.h>
109 #include <linux/mii.h>
117 #define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
120 #define RTL8139_DEF_MSG_ENABLE (NETIF_MSG_DRV | \
126 #define RTL8139_DEBUG 0
129 #undef RTL8139_NDEBUG
132 #ifdef RTL8139_NDEBUG
133 # define assert(expr) do {} while (0)
135 # define assert(expr) \
136 if (unlikely(!(expr))) { \
137 pr_err("Assertion failed! %s,%s,%s,line=%d\n", \
138 #expr, __FILE__, __func__, __LINE__); \
146 static int media[
MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
147 static int full_duplex[
MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
150 #ifdef CONFIG_8139TOO_PIO
151 static bool use_io =
true;
153 static bool use_io =
false;
158 static int multicast_filter_limit = 32;
161 static int debug = -1;
167 #if defined(CONFIG_SH_DREAMCAST)
172 #define RX_BUF_LEN (8192 << RX_BUF_IDX)
173 #define RX_BUF_PAD 16
174 #define RX_BUF_WRAP_PAD 2048
176 #if RX_BUF_LEN == 65536
177 #define RX_BUF_TOT_LEN RX_BUF_LEN
179 #define RX_BUF_TOT_LEN (RX_BUF_LEN + RX_BUF_PAD + RX_BUF_WRAP_PAD)
183 #define NUM_TX_DESC 4
186 #define MAX_ETH_FRAME_SIZE 1536
189 #define TX_BUF_SIZE MAX_ETH_FRAME_SIZE
190 #define TX_BUF_TOT_LEN (TX_BUF_SIZE * NUM_TX_DESC)
194 #define TX_FIFO_THRESH 256
197 #define RX_FIFO_THRESH 7
198 #define RX_DMA_BURST 7
199 #define TX_DMA_BURST 6
204 #define TX_TIMEOUT (6*HZ)
213 #define RTL_NUM_STATS 4
214 #define RTL_REGS_VER 1
215 #define RTL_MIN_IO_SIZE 0x80
216 #define RTL8139B_IO_SIZE 256
218 #define RTL8129_CAPS HAS_MII_XCVR
219 #define RTL8139_CAPS (HAS_CHIP_XCVR|HAS_LNK_CHNG)
228 static const struct {
258 #ifdef CONFIG_SH_SECUREEDGE5410
262 #ifdef CONFIG_8139TOO_8129
280 } ethtool_stats_keys[] = {
284 {
"rx_lost_in_ring" },
499 #define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
500 (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22)
501 #define HW_REVID_MASK HW_REVID(1, 1, 1, 1, 1, 1, 1)
504 static const struct {
508 } rtl_chip_info[] = {
630 MODULE_PARM_DESC (multicast_filter_limit,
"8139too maximum number of filtered multicast addresses");
631 MODULE_PARM_DESC (media,
"8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
644 #ifdef CONFIG_NET_POLL_CONTROLLER
647 static int rtl8139_set_mac_address(
struct net_device *
dev,
void *
p);
649 static irqreturn_t rtl8139_interrupt (
int irq,
void *dev_instance);
660 static const struct ethtool_ops rtl8139_ethtool_ops;
664 #define RTL_W8_F(reg, val8) do { iowrite8 ((val8), ioaddr + (reg)); ioread8 (ioaddr + (reg)); } while (0)
665 #define RTL_W16_F(reg, val16) do { iowrite16 ((val16), ioaddr + (reg)); ioread16 (ioaddr + (reg)); } while (0)
666 #define RTL_W32_F(reg, val32) do { iowrite32 ((val32), ioaddr + (reg)); ioread32 (ioaddr + (reg)); } while (0)
669 #define RTL_W8(reg, val8) iowrite8 ((val8), ioaddr + (reg))
670 #define RTL_W16(reg, val16) iowrite16 ((val16), ioaddr + (reg))
671 #define RTL_W32(reg, val32) iowrite32 ((val32), ioaddr + (reg))
674 #define RTL_R8(reg) ioread8 (ioaddr + (reg))
675 #define RTL_R16(reg) ioread16 (ioaddr + (reg))
676 #define RTL_R32(reg) ioread32 (ioaddr + (reg))
679 static const u16 rtl8139_intr_mask =
683 static const u16 rtl8139_norx_intr_mask =
688 static const unsigned int rtl8139_rx_config =
692 #elif RX_BUF_IDX == 1
693 static const unsigned int rtl8139_rx_config =
697 #elif RX_BUF_IDX == 2
698 static const unsigned int rtl8139_rx_config =
702 #elif RX_BUF_IDX == 3
703 static const unsigned int rtl8139_rx_config =
708 #error "Invalid configuration for 8139_RXBUF_IDX"
711 static const unsigned int rtl8139_tx_config =
730 pci_set_drvdata (pdev,
NULL);
734 static void rtl8139_chip_reset (
void __iomem *ioaddr)
742 for (i = 1000; i > 0; i--) {
758 int rc, disable_dev_on_err = 0;
760 unsigned long io_len;
762 static const struct {
773 dev = alloc_etherdev (
sizeof (*tp));
779 tp = netdev_priv(dev);
790 disable_dev_on_err = 1;
803 dev_err(d,
"region #%d not a %s resource, aborting\n", bar,
809 dev_err(d,
"Invalid PCI %s region size(s), aborting\n",
815 ioaddr = pci_iomap(pdev, bar, 0);
833 dev_err(&pdev->
dev,
"Chip not responding, ignoring board\n");
840 for (i = 0; i <
ARRAY_SIZE (rtl_chip_info); i++)
841 if (version == rtl_chip_info[i].version) {
848 dev_dbg(&pdev->
dev,
"unknown chip version, assuming RTL-8139\n");
853 pr_debug(
"chipset id (%d) == index %d, '%s'\n",
854 version, i, rtl_chip_info[i].
name);
863 if (new_tmp8 != tmp8) {
868 if (rtl_chip_info[tp->
chipset].flags & HasLWake) {
883 rtl8139_chip_reset (ioaddr);
888 __rtl8139_cleanup_dev (dev);
889 if (disable_dev_on_err)
908 if (features & NETIF_F_RXALL)
912 tp->
rx_config = rtl8139_rx_config | rx_mode;
916 spin_unlock_irqrestore(&tp->
lock, flags);
922 .ndo_open = rtl8139_open,
923 .ndo_stop = rtl8139_close,
924 .ndo_get_stats64 = rtl8139_get_stats64,
927 .ndo_set_mac_address = rtl8139_set_mac_address,
928 .ndo_start_xmit = rtl8139_start_xmit,
929 .ndo_set_rx_mode = rtl8139_set_rx_mode,
930 .ndo_do_ioctl = netdev_ioctl,
931 .ndo_tx_timeout = rtl8139_tx_timeout,
932 #ifdef CONFIG_NET_POLL_CONTROLLER
933 .ndo_poll_controller = rtl8139_poll_controller,
935 .ndo_set_features = rtl8139_set_features,
945 static int board_idx = -1;
957 static int printed_version;
958 if (!printed_version++)
966 "This (id %04x:%04x rev %02x) is an enhanced 8139C+ chip, use 8139cp\n",
975 pr_info(
"OQO Model 2 detected. Forcing PIO\n");
979 dev = rtl8139_init_board (pdev);
984 tp = netdev_priv(dev);
990 addr_len =
read_eeprom (ioaddr, 0, 8) == 0x8129 ? 8 : 6;
991 for (i = 0; i < 3; i++)
1013 tp = netdev_priv(dev);
1024 tp->
mii.mdio_read = mdio_read;
1025 tp->
mii.mdio_write = mdio_write;
1026 tp->
mii.phy_id_mask = 0x3f;
1027 tp->
mii.reg_num_mask = 0x1f;
1030 pr_debug(
"about to register device named %s (%p)...\n",
1033 if (i)
goto err_out;
1035 pci_set_drvdata (pdev, dev);
1037 netdev_info(dev,
"%s at 0x%p, %pM, IRQ %d\n",
1041 netdev_dbg(dev,
"Identified 8139 chip type '%s'\n",
1047 #ifdef CONFIG_8139TOO_8129
1049 int phy, phy_idx = 0;
1050 for (phy = 0; phy < 32 && phy_idx <
sizeof(tp->
phys); phy++) {
1051 int mii_status = mdio_read(dev, phy, 1);
1052 if (mii_status != 0xffff && mii_status != 0x0000) {
1053 u16 advertising = mdio_read(dev, phy, 4);
1055 netdev_info(dev,
"MII transceiver %d status 0x%04x advertising %04x\n",
1056 phy, mii_status, advertising);
1060 netdev_info(dev,
"No MII transceivers found! Assuming SYM transceiver\n");
1069 option = (board_idx >=
MAX_UNITS) ? 0 : media[board_idx];
1071 tp->
mii.full_duplex = (option & 0x210) ? 1 : 0;
1074 tp->
mii.force_media = 1;
1076 if (board_idx <
MAX_UNITS && full_duplex[board_idx] > 0)
1077 tp->
mii.full_duplex = full_duplex[board_idx];
1078 if (tp->
mii.full_duplex) {
1079 netdev_info(dev,
"Media type forced to Full Duplex\n");
1082 tp->
mii.force_media = 1;
1085 netdev_info(dev,
" Forcing %dMbps %s-duplex operation\n",
1086 (option & 0x20 ? 100 : 10),
1087 (option & 0x10 ?
"full" :
"half"));
1088 mdio_write(dev, tp->
phys[0], 0,
1089 ((option & 0x20) ? 0x2000 : 0) |
1090 ((option & 0x10) ? 0x0100 : 0));
1100 __rtl8139_cleanup_dev (dev);
1108 struct net_device *dev = pci_get_drvdata (pdev);
1117 __rtl8139_cleanup_dev (dev);
1125 #define EE_SHIFT_CLK 0x04
1127 #define EE_DATA_WRITE 0x02
1128 #define EE_WRITE_0 0x00
1129 #define EE_WRITE_1 0x02
1130 #define EE_DATA_READ 0x01
1131 #define EE_ENB (0x80 | EE_CS)
1137 #define eeprom_delay() (void)RTL_R8(Cfg9346)
1140 #define EE_WRITE_CMD (5)
1141 #define EE_READ_CMD (6)
1142 #define EE_ERASE_CMD (7)
1148 int read_cmd = location | (
EE_READ_CMD << addr_len);
1155 for (i = 4 + addr_len; i >= 0; i--) {
1165 for (i = 16; i > 0; i--) {
1188 #define MDIO_DIR 0x80
1189 #define MDIO_DATA_OUT 0x04
1190 #define MDIO_DATA_IN 0x02
1191 #define MDIO_CLK 0x01
1192 #define MDIO_WRITE0 (MDIO_DIR)
1193 #define MDIO_WRITE1 (MDIO_DIR | MDIO_DATA_OUT)
1195 #define mdio_delay() RTL_R8(Config4)
1198 static const char mii_2_8139_map[8] = {
1210 #ifdef CONFIG_8139TOO_8129
1212 static void mdio_sync (
void __iomem *ioaddr)
1216 for (i = 32; i >= 0; i--) {
1229 #ifdef CONFIG_8139TOO_8129
1231 int mii_cmd = (0xf6 << 10) | (phy_id << 5) |
location;
1237 return location < 8 && mii_2_8139_map[
location] ?
1238 RTL_R16 (mii_2_8139_map[location]) : 0;
1241 #ifdef CONFIG_8139TOO_8129
1244 for (i = 15; i >= 0; i--) {
1254 for (i = 19; i > 0; i--) {
1263 return (retval >> 1) & 0xffff;
1267 static void mdio_write (
struct net_device *dev,
int phy_id,
int location,
1271 #ifdef CONFIG_8139TOO_8129
1273 int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location << 18) | value;
1279 if (location == 0) {
1283 }
else if (location < 8 && mii_2_8139_map[location])
1284 RTL_W16 (mii_2_8139_map[location], value);
1288 #ifdef CONFIG_8139TOO_8129
1292 for (i = 31; i >= 0; i--) {
1301 for (i = 2; i > 0; i--) {
1311 static int rtl8139_open (
struct net_device *dev)
1340 napi_enable(&tp->
napi);
1342 tp->
mii.full_duplex = tp->
mii.force_media;
1345 rtl8139_init_ring (dev);
1346 rtl8139_hw_start (dev);
1347 netif_start_queue (dev);
1350 "%s() ioaddr %#llx IRQ %d GP Pins %02x %s-duplex\n",
1354 tp->
mii.full_duplex ?
"full" :
"half");
1356 rtl8139_start_thread(tp);
1362 static void rtl_check_media (
struct net_device *dev,
unsigned int init_media)
1366 if (tp->
phys[0] >= 0) {
1372 static void rtl8139_hw_start (
struct net_device *dev)
1383 rtl8139_chip_reset (ioaddr);
1403 rtl_check_media (dev, 1);
1423 rtl8139_set_rx_mode (dev);
1439 static void rtl8139_init_ring (
struct net_device *dev)
1454 static int next_tick = 3 *
HZ;
1456 #ifndef CONFIG_8139TOO_TUNE_TWISTER
1457 static inline void rtl8139_tune_twister (
struct net_device *dev,
1460 enum TwisterParamVals {
1461 PARA78_default = 0x78fa8388,
1462 PARA7c_default = 0xcb38de43,
1463 PARA7c_xxx = 0xcb38de43,
1466 static const unsigned long param[4][4] = {
1467 {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
1468 {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
1469 {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
1470 {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
1473 static void rtl8139_tune_twister (
struct net_device *dev,
1489 next_tick =
HZ / 10;
1502 if (linkcase == 0x7000)
1504 else if (linkcase == 0x3000)
1506 else if (linkcase == 0x1000)
1512 next_tick =
HZ / 10;
1520 next_tick =
HZ / 10;
1537 next_tick =
HZ / 10;
1549 next_tick =
HZ / 10;
1559 static inline void rtl8139_thread_iter (
struct net_device *dev,
1567 if (!tp->
mii.force_media && mii_lpa != 0xffff) {
1569 (mii_lpa & 0x01C0) == 0x0040);
1570 if (tp->
mii.full_duplex != duplex) {
1574 netdev_info(dev,
"Setting %s-duplex based on MII #%d link partner ability of %04x\n",
1575 tp->
mii.full_duplex ?
"full" :
"half",
1576 tp->
phys[0], mii_lpa);
1578 netdev_info(dev,
"media is unconnected, link down, or incompatible connection\n");
1588 next_tick =
HZ * 60;
1590 rtl8139_tune_twister (dev, tp);
1592 netdev_dbg(dev,
"Media selection tick, Link partner %04x\n",
1594 netdev_dbg(dev,
"Other registers are IntMask %04x IntStatus %04x\n",
1605 unsigned long thr_delay = next_tick;
1609 if (!netif_running(dev))
1614 rtl8139_tx_timeout_task(work);
1616 rtl8139_thread_iter(dev, tp, tp->
mmio_addr);
1646 static void rtl8139_tx_timeout_task (
struct work_struct *work)
1655 netdev_dbg(dev,
"Transmit timeout, status %02x %04x %04x media %02x\n",
1659 netdev_dbg(dev,
"Tx queue start entry %ld dirty entry %ld\n",
1662 netdev_dbg(dev,
"Tx descriptor %d is %08x%s\n",
1665 " (queue head)" :
"");
1667 tp->
xstats.tx_timeouts++;
1679 spin_lock_irq(&tp->
lock);
1680 rtl8139_tx_clear (tp);
1681 spin_unlock_irq(&tp->
lock);
1684 if (netif_running(dev)) {
1685 rtl8139_hw_start (dev);
1686 netif_wake_queue (dev);
1691 static void rtl8139_tx_timeout (
struct net_device *dev)
1708 unsigned int len = skb->
len;
1709 unsigned long flags;
1722 dev->
stats.tx_dropped++;
1739 netif_stop_queue (dev);
1740 spin_unlock_irqrestore(&tp->
lock, flags);
1742 netif_dbg(tp, tx_queued, dev,
"Queued Tx packet size %u to slot %d\n",
1749 static void rtl8139_tx_interrupt (
struct net_device *dev,
1760 while (tx_left > 0) {
1772 netif_dbg(tp, tx_err, dev,
"Transmit error, Tx status %08x\n",
1774 dev->
stats.tx_errors++;
1776 dev->
stats.tx_aborted_errors++;
1782 dev->
stats.tx_carrier_errors++;
1784 dev->
stats.tx_window_errors++;
1790 dev->
stats.tx_fifo_errors++;
1792 dev->
stats.collisions += (txstatus >> 24) & 15;
1793 u64_stats_update_begin(&tp->
tx_stats.syncp);
1795 tp->
tx_stats.bytes += txstatus & 0x7ff;
1796 u64_stats_update_end(&tp->
tx_stats.syncp);
1803 #ifndef RTL8139_NDEBUG
1804 if (tp->
cur_tx - dirty_tx > NUM_TX_DESC) {
1805 netdev_err(dev,
"Out-of-sync dirty pointer, %ld vs. %ld\n",
1815 netif_wake_queue (dev);
1825 #ifdef CONFIG_8139_OLD_RX_RESET
1829 netif_dbg(tp, rx_err, dev,
"Ethernet frame had errors, status %08x\n",
1831 dev->
stats.rx_errors++;
1834 netdev_dbg(dev,
"Oversized Ethernet frame, status %04x!\n",
1839 dev->
stats.rx_frame_errors++;
1840 if (rx_status & (
RxRunt | RxTooLong))
1841 dev->
stats.rx_length_errors++;
1843 dev->
stats.rx_crc_errors++;
1845 tp->
xstats.rx_lost_in_ring++;
1848 #ifndef CONFIG_8139_OLD_RX_RESET
1860 while (--tmp_work > 0) {
1863 if (!(tmp8 & CmdRxEnb))
1867 netdev_warn(dev,
"rx stop wait too long\n");
1870 while (--tmp_work > 0) {
1874 if ((tmp8 & CmdRxEnb) && (tmp8 & CmdTxEnb))
1878 netdev_warn(dev,
"tx/rx enable wait too long\n");
1898 __set_rx_mode (dev);
1903 static inline void wrap_copy(
struct sk_buff *skb,
const unsigned char *
ring,
1909 skb_copy_to_linear_data(skb, ring + offset, left);
1910 skb_copy_to_linear_data_offset(skb, left, ring, size - left);
1912 skb_copy_to_linear_data(skb, ring + offset, size);
1924 if (
likely(status != 0)) {
1926 tp->
dev->stats.rx_errors++;
1928 tp->
dev->stats.rx_fifo_errors++;
1941 unsigned int rx_size = 0;
1943 netdev_dbg(dev,
"In %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
1944 __func__, (
u16)cur_rx,
1947 while (netif_running(dev) && received < budget &&
1951 unsigned int pkt_size;
1958 rx_size = rx_status >> 16;
1960 pkt_size = rx_size - 4;
1964 netif_dbg(tp, rx_status, dev,
"%s() status %04x, size %04x, cur %04x\n",
1965 __func__, rx_status, rx_size, cur_rx);
1966 #if RTL8139_DEBUG > 2
1967 print_hex_dump(
KERN_DEBUG,
"Frame contents: ",
1969 &rx_ring[ring_offset], 70,
true);
1999 (!(rx_status & RxStatusOK)))) {
2000 if ((dev->
features & NETIF_F_RXALL) &&
2003 (!(rx_status & RxStatusOK))) {
2008 dev->
stats.rx_errors++;
2010 dev->
stats.rx_crc_errors++;
2013 if (rx_status &
RxRunt) {
2014 dev->
stats.rx_length_errors++;
2018 rtl8139_rx_err (rx_status, dev, tp, ioaddr);
2027 skb = netdev_alloc_skb_ip_align(dev, pkt_size);
2030 wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
2032 skb_copy_to_linear_data (skb, &rx_ring[ring_offset + 4], pkt_size);
2038 u64_stats_update_begin(&tp->
rx_stats.syncp);
2041 u64_stats_update_end(&tp->
rx_stats.syncp);
2046 netdev_warn(dev,
"Memory squeeze, dropping packet\n");
2047 dev->
stats.rx_dropped++;
2051 cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
2054 rtl8139_isr_ack(tp);
2057 if (
unlikely(!received || rx_size == 0xfff0))
2058 rtl8139_isr_ack(tp);
2060 netdev_dbg(dev,
"Done %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
2078 static void rtl8139_weird_interrupt (
struct net_device *dev,
2081 int status,
int link_changed)
2083 netdev_dbg(dev,
"Abnormal interrupt, status %08x\n", status);
2095 rtl_check_media(dev, 0);
2096 status &= ~RxUnderrun;
2099 if (status & (RxUnderrun |
RxErr))
2100 dev->
stats.rx_errors++;
2103 dev->
stats.rx_length_errors++;
2104 if (status & RxUnderrun)
2105 dev->
stats.rx_fifo_errors++;
2111 netdev_err(dev,
"PCI Bus error %04x\n", pci_cmd_status);
2125 work_done += rtl8139_rx(dev, tp, budget);
2127 if (work_done < budget) {
2128 unsigned long flags;
2136 spin_unlock_irqrestore(&tp->
lock, flags);
2145 static irqreturn_t rtl8139_interrupt (
int irq,
void *dev_instance)
2151 int link_changed = 0;
2154 spin_lock (&tp->
lock);
2158 if (
unlikely((status & rtl8139_intr_mask) == 0))
2168 if (
unlikely(!netif_running(dev))) {
2178 ackstat = status & ~(RxAckBits |
TxErr);
2184 if (status & RxAckBits){
2185 if (napi_schedule_prep(&tp->
napi)) {
2193 rtl8139_weird_interrupt (dev, tp, ioaddr,
2194 status, link_changed);
2197 rtl8139_tx_interrupt (dev, tp, ioaddr);
2202 spin_unlock (&tp->
lock);
2204 netdev_dbg(dev,
"exiting interrupt, intr_status=%#4.4x\n",
2209 #ifdef CONFIG_NET_POLL_CONTROLLER
2214 static void rtl8139_poll_controller(
struct net_device *dev)
2217 const int irq = tp->
pci_dev->irq;
2220 rtl8139_interrupt(irq, dev);
2225 static int rtl8139_set_mac_address(
struct net_device *dev,
void *
p)
2231 if (!is_valid_ether_addr(addr->
sa_data))
2236 spin_lock_irq(&tp->
lock);
2243 spin_unlock_irq(&tp->
lock);
2248 static int rtl8139_close (
struct net_device *dev)
2252 unsigned long flags;
2254 netif_stop_queue(dev);
2255 napi_disable(&tp->
napi);
2257 netif_dbg(tp, ifdown, dev,
"Shutting down ethercard, status was 0x%04x\n",
2272 spin_unlock_irqrestore (&tp->
lock, flags);
2276 rtl8139_tx_clear (tp);
2288 if (rtl_chip_info[tp->
chipset].flags & HasHltClk)
2303 spin_lock_irq(&tp->
lock);
2304 if (rtl_chip_info[tp->
chipset].flags & HasLWake) {
2325 spin_unlock_irq(&tp->
lock);
2346 spin_lock_irq(&tp->
lock);
2367 spin_unlock_irq(&tp->
lock);
2384 spin_lock_irq(&tp->
lock);
2386 spin_unlock_irq(&tp->
lock);
2394 spin_lock_irq(&tp->
lock);
2396 spin_unlock_irq(&tp->
lock);
2400 static int rtl8139_nway_reset(
struct net_device *dev)
2418 static void rtl8139_set_msglevel(
struct net_device *dev,
u32 datum)
2424 static int rtl8139_get_regs_len(
struct net_device *dev)
2430 tp = netdev_priv(dev);
2441 tp = netdev_priv(dev);
2445 spin_lock_irq(&tp->
lock);
2447 spin_unlock_irq(&tp->
lock);
2450 static int rtl8139_get_sset_count(
struct net_device *dev,
int sset)
2464 data[0] = tp->
xstats.early_rx;
2465 data[1] = tp->
xstats.tx_buf_mapped;
2466 data[2] = tp->
xstats.tx_timeouts;
2467 data[3] = tp->
xstats.rx_lost_in_ring;
2472 memcpy(data, ethtool_stats_keys,
sizeof(ethtool_stats_keys));
2475 static const struct ethtool_ops rtl8139_ethtool_ops = {
2476 .get_drvinfo = rtl8139_get_drvinfo,
2477 .get_settings = rtl8139_get_settings,
2478 .set_settings = rtl8139_set_settings,
2479 .get_regs_len = rtl8139_get_regs_len,
2480 .get_regs = rtl8139_get_regs,
2481 .nway_reset = rtl8139_nway_reset,
2482 .get_link = rtl8139_get_link,
2483 .get_msglevel = rtl8139_get_msglevel,
2484 .set_msglevel = rtl8139_set_msglevel,
2485 .get_wol = rtl8139_get_wol,
2486 .set_wol = rtl8139_set_wol,
2487 .get_strings = rtl8139_get_strings,
2488 .get_sset_count = rtl8139_get_sset_count,
2489 .get_ethtool_stats = rtl8139_get_ethtool_stats,
2497 if (!netif_running(dev))
2500 spin_lock_irq(&tp->
lock);
2502 spin_unlock_irq(&tp->
lock);
2513 unsigned long flags;
2516 if (netif_running(dev)) {
2520 spin_unlock_irqrestore (&tp->
lock, flags);
2526 start = u64_stats_fetch_begin_bh(&tp->
rx_stats.syncp);
2529 }
while (u64_stats_fetch_retry_bh(&tp->
rx_stats.syncp, start));
2532 start = u64_stats_fetch_begin_bh(&tp->
tx_stats.syncp);
2535 }
while (u64_stats_fetch_retry_bh(&tp->
tx_stats.syncp, start));
2543 static void __set_rx_mode (
struct net_device *dev)
2551 netdev_dbg(dev,
"rtl8139_set_rx_mode(%04x) done -- Rx config %08x\n",
2559 mc_filter[1] = mc_filter[0] = 0xffffffff;
2564 mc_filter[1] = mc_filter[0] = 0xffffffff;
2568 mc_filter[1] = mc_filter[0] = 0;
2572 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
2581 tmp = rtl8139_rx_config | rx_mode;
2590 static void rtl8139_set_rx_mode (
struct net_device *dev)
2592 unsigned long flags;
2597 spin_unlock_irqrestore (&tp->
lock, flags);
2604 struct net_device *dev = pci_get_drvdata (pdev);
2607 unsigned long flags;
2611 if (!netif_running (dev))
2626 spin_unlock_irqrestore (&tp->
lock, flags);
2634 static int rtl8139_resume (
struct pci_dev *pdev)
2636 struct net_device *dev = pci_get_drvdata (pdev);
2639 if (!netif_running (dev))
2642 rtl8139_init_ring (dev);
2643 rtl8139_hw_start (dev);
2651 static struct pci_driver rtl8139_pci_driver = {
2653 .id_table = rtl8139_pci_tbl,
2654 .probe = rtl8139_init_one,
2657 .suspend = rtl8139_suspend,
2658 .resume = rtl8139_resume,
2663 static int __init rtl8139_init_module (
void)
2672 return pci_register_driver(&rtl8139_pci_driver);
2676 static void __exit rtl8139_cleanup_module (
void)