56 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
58 #include <linux/pci.h>
60 #include <linux/module.h>
61 #include <linux/types.h>
62 #include <linux/kernel.h>
64 #include <linux/sched.h>
65 #include <linux/ptrace.h>
66 #include <linux/slab.h>
67 #include <linux/ctype.h>
68 #include <linux/string.h>
73 #include <linux/bitops.h>
76 #include <linux/netdevice.h>
79 #include <linux/if_arp.h>
82 #include <linux/random.h>
90 MODULE_DESCRIPTION(
"10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere Systems");
93 #define MAX_NUM_REGISTER_POLLS 1000
94 #define MAX_NUM_WRITE_RETRIES 2
97 #define COUNTER_WRAP_16_BIT 0x10000
98 #define COUNTER_WRAP_12_BIT 0x1000
101 #define INTERNAL_MEM_SIZE 0x400
102 #define INTERNAL_MEM_RX_OFFSET 0x1FF
114 #define INT_MASK_DISABLE 0xffffffff
120 #define INT_MASK_ENABLE 0xfffebf17
121 #define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7
125 #define NIC_MIN_PACKET_SIZE 60
128 #define NIC_MAX_MCAST_LIST 128
131 #define ET131X_PACKET_TYPE_DIRECTED 0x0001
132 #define ET131X_PACKET_TYPE_MULTICAST 0x0002
133 #define ET131X_PACKET_TYPE_BROADCAST 0x0004
134 #define ET131X_PACKET_TYPE_PROMISCUOUS 0x0008
135 #define ET131X_PACKET_TYPE_ALL_MULTICAST 0x0010
138 #define ET131X_TX_TIMEOUT (1 * HZ)
139 #define NIC_SEND_HANG_THRESHOLD 0
142 #define fMP_DEST_MULTI 0x00000001
143 #define fMP_DEST_BROAD 0x00000002
146 #define fMP_ADAPTER_RECV_LOOKASIDE 0x00000004
147 #define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008
150 #define fMP_ADAPTER_LOWER_POWER 0x00200000
152 #define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000
153 #define fMP_ADAPTER_HARDWARE_ERROR 0x04000000
155 #define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000
158 #define ET1310_PCI_MAC_ADDRESS 0xA4
159 #define ET1310_PCI_EEPROM_STATUS 0xB2
160 #define ET1310_PCI_ACK_NACK 0xC0
161 #define ET1310_PCI_REPLAY 0xC2
162 #define ET1310_PCI_L0L1LATENCY 0xCF
165 #define ET131X_PCI_DEVICE_ID_GIG 0xED00
166 #define ET131X_PCI_DEVICE_ID_FAST 0xED01
169 #define NANO_IN_A_MICRO 1000
171 #define PARM_RX_NUM_BUFS_DEF 4
172 #define PARM_RX_TIME_INT_DEF 10
173 #define PARM_RX_MEM_END_DEF 0x2bc
174 #define PARM_TX_TIME_INT_DEF 40
175 #define PARM_TX_NUM_BUFS_DEF 4
176 #define PARM_DMA_CACHE_DEF 0
180 #define FBR_CHUNKS 32
181 #define MAX_DESC_PER_RING_RX 1024
185 #define RFD_LOW_WATER_MARK 40
186 #define NIC_DEFAULT_NUM_RFD 1024
189 #define RFD_LOW_WATER_MARK 20
190 #define NIC_DEFAULT_NUM_RFD 256
194 #define NIC_MIN_NUM_RFD 64
195 #define NUM_PACKETS_HANDLED 256
197 #define ALCATEL_MULTICAST_PKT 0x01000000
198 #define ALCATEL_BROADCAST_PKT 0x02000000
430 #define NUM_DESC_PER_RING_TX 512
438 #define TX_ERROR_PERIOD 1000
440 #define LO_MARK_PERCENT_FOR_PSR 15
441 #define LO_MARK_PERCENT_FOR_RX 15
454 #define FLOW_TXONLY 1
455 #define FLOW_RXONLY 2
592 if ((reg & 0x3000) == 0x3000) {
630 err = eeprom_wait_ready(pdev,
NULL);
666 err = eeprom_wait_ready(pdev, &status);
676 && adapter->
pdev->revision == 0)
716 pci_write_config_dword(pdev,
720 pci_read_config_dword(pdev,
722 }
while ((val & 0x00010000) == 0);
723 }
while (val & 0x00040000);
725 if ((val & 0xFF00) != 0xC000 || index == 10000)
729 return writeok ? 0 : -
EIO;
753 err = eeprom_wait_ready(pdev,
NULL);
776 err = eeprom_wait_ready(pdev, &status);
810 "Could not read PCI config space for EEPROM Status\n");
817 if (eestatus & 0x4C) {
818 int write_failed = 0;
821 static const u8 eedata[4] = { 0xFE, 0x13, 0x10, 0xFF };
827 for (i = 0; i < 3; i++)
828 if (eeprom_write(adapter, i, eedata[i]) < 0)
831 if (pdev->
revision != 0x01 || write_failed) {
833 "Fatal EEPROM Status Error - 0x%04x\n", eestatus);
850 eeprom_read(adapter, 0x70, &adapter->
eeprom_data[0]);
851 eeprom_read(adapter, 0x71, &adapter->
eeprom_data[1]);
869 if (adapter->
rx_ring.fbr[0]->buffsize == 4096)
871 else if (adapter->
rx_ring.fbr[0]->buffsize == 8192)
873 else if (adapter->
rx_ring.fbr[0]->buffsize == 16384)
877 if (adapter->
rx_ring.fbr[1]->buffsize == 256)
879 else if (adapter->
rx_ring.fbr[1]->buffsize == 512)
881 else if (adapter->
rx_ring.fbr[1]->buffsize == 1024)
887 if ((csr & 0x00020000) != 0) {
890 if ((csr & 0x00020000) != 0) {
892 "RX Dma failed to exit halt state. CSR 0x%08x\n",
906 writel(0x00002001, &adapter->
regs->rxdma.csr);
908 if ((csr & 0x00020000) == 0) {
911 if ((csr & 0x00020000) == 0)
913 "RX Dma failed to enter halt state. CSR 0x%08x\n",
930 &adapter->
regs->txdma.csr);
933 static inline void add_10bit(
u32 *
v,
int n)
938 static inline void add_12bit(
u32 *
v,
int n)
947 static void et1310_config_mac_regs1(
struct et131x_adapter *adapter)
1007 static void et1310_config_mac_regs2(
struct et131x_adapter *adapter)
1027 ifctrl &= ~(1 << 24);
1030 ifctrl |= (1 << 24);
1052 ifctrl &= ~(1 << 26);
1063 }
while ((cfg1 &
CFG1_WAIT) != CFG1_WAIT && delay < 100);
1067 "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
1077 et131x_rx_dma_enable(adapter);
1078 et131x_tx_dma_enable(adapter);
1092 pmcsr =
readl(&adapter->
regs->global.pm_csr);
1097 static void et1310_setup_device_for_multicast(
struct et131x_adapter *adapter)
1120 result = (result & 0x3F800000) >> 23;
1124 }
else if ((31 < result) && (result < 64)) {
1127 }
else if ((63 < result) && (result < 96)) {
1138 pm_csr =
readl(&adapter->
regs->global.pm_csr);
1139 if (!et1310_in_phy_coma(adapter)) {
1147 static void et1310_setup_device_for_unicast(
struct et131x_adapter *adapter)
1179 pm_csr =
readl(&adapter->
regs->global.pm_csr);
1180 if (!et1310_in_phy_coma(adapter)) {
1187 static void et1310_config_rxmac_regs(
struct et131x_adapter *adapter)
1248 et1310_setup_device_for_unicast(adapter);
1259 et1310_setup_device_for_multicast(adapter);
1318 static void et1310_config_txmac_regs(
struct et131x_adapter *adapter)
1332 static void et1310_config_macstat_regs(
struct et131x_adapter *adapter)
1335 &adapter->
regs->macstat;
1434 }
while ((mii_indicator &
MGMT_WAIT) && delay < 50);
1439 "reg 0x%08x could not be read\n", reg);
1469 return et131x_phy_mii_read(adapter, phydev->
addr, reg, value);
1496 addr = phydev->
addr;
1517 }
while ((mii_indicator &
MGMT_BUSY) && delay < 100);
1524 "reg 0x%08x could not be written", reg);
1530 et131x_mii_read(adapter, reg, &tmp);
1548 static void et1310_phy_access_mii_bit(
struct et131x_adapter *adapter,
1556 et131x_mii_read(adapter, regnum, ®);
1560 *value = (reg &
mask) >> bitnum;
1564 et131x_mii_write(adapter, regnum, reg | mask);
1568 et131x_mii_write(adapter, regnum, reg & ~mask);
1576 static void et1310_config_flow_control(
struct et131x_adapter *adapter)
1583 char remote_pause, remote_async_pause;
1585 et1310_phy_access_mii_bit(adapter,
1587 et1310_phy_access_mii_bit(adapter,
1589 &remote_async_pause);
1617 static void et1310_update_macstat_host_counters(
struct et131x_adapter *adapter)
1621 &adapter->
regs->macstat;
1649 static void et1310_handle_macstat_interrupt(
struct et131x_adapter *adapter)
1657 carry_reg1 =
readl(&adapter->
regs->macstat.carry_reg1);
1658 carry_reg2 =
readl(&adapter->
regs->macstat.carry_reg2);
1660 writel(carry_reg1, &adapter->
regs->macstat.carry_reg1);
1661 writel(carry_reg2, &adapter->
regs->macstat.carry_reg2);
1669 if (carry_reg1 & (1 << 14))
1671 if (carry_reg1 & (1 << 8))
1673 if (carry_reg1 & (1 << 7))
1675 if (carry_reg1 & (1 << 2))
1677 if (carry_reg1 & (1 << 6))
1679 if (carry_reg1 & (1 << 3))
1681 if (carry_reg1 & (1 << 0))
1683 if (carry_reg2 & (1 << 16))
1685 if (carry_reg2 & (1 << 15))
1687 if (carry_reg2 & (1 << 6))
1689 if (carry_reg2 & (1 << 8))
1691 if (carry_reg2 & (1 << 5))
1693 if (carry_reg2 & (1 << 4))
1695 if (carry_reg2 & (1 << 2))
1699 static int et131x_mdio_read(
struct mii_bus *
bus,
int phy_addr,
int reg)
1706 ret = et131x_phy_mii_read(adapter, phy_addr, reg, &value);
1714 static int et131x_mdio_write(
struct mii_bus *bus,
int phy_addr,
1720 return et131x_mii_write(adapter, reg, value);
1723 static int et131x_mdio_reset(
struct mii_bus *bus)
1747 et131x_mii_read(adapter,
MII_BMCR, &data);
1751 et131x_mii_write(adapter,
MII_BMCR, data);
1786 et131x_mii_read(adapter,
PHY_LED_2, &lcr2);
1796 et131x_mii_write(adapter,
PHY_LED_2, lcr2);
1806 static void et131x_configure_global_regs(
struct et131x_adapter *adapter)
1851 static void et131x_config_rx_dma_regs(
struct et131x_adapter *adapter)
1858 unsigned long flags;
1861 et131x_rx_dma_disable(adapter);
1895 fbr_entry = (
struct fbr_desc *) rx_local->
fbr[0]->ring_virtaddr;
1896 for (entry = 0; entry < rx_local->
fbr[0]->num_entries; entry++) {
1922 fbr_entry = (
struct fbr_desc *) rx_local->
fbr[1]->ring_virtaddr;
1923 for (entry = 0; entry < rx_local->
fbr[1]->num_entries; entry++) {
1959 spin_unlock_irqrestore(&adapter->
rcv_lock, flags);
1969 static void et131x_config_tx_dma_regs(
struct et131x_adapter *adapter)
1987 *adapter->
tx_ring.tx_status = 0;
1990 adapter->
tx_ring.send_idx = 0;
2002 et131x_configure_global_regs(adapter);
2004 et1310_config_mac_regs1(adapter);
2010 et1310_config_rxmac_regs(adapter);
2011 et1310_config_txmac_regs(adapter);
2013 et131x_config_rx_dma_regs(adapter);
2014 et131x_config_tx_dma_regs(adapter);
2016 et1310_config_macstat_regs(adapter);
2018 et1310_phy_power_down(adapter, 0);
2019 et131x_xcvr_init(adapter);
2029 writel(0xc00f0000, &adapter->
regs->mac.cfg1);
2032 writel(0x7F, &adapter->
regs->global.sw_reset);
2033 writel(0x000f0000, &adapter->
regs->mac.cfg1);
2034 writel(0x00000000, &adapter->
regs->mac.cfg1);
2044 static void et131x_enable_interrupts(
struct et131x_adapter *adapter)
2055 writel(mask, &adapter->
regs->global.int_mask);
2064 static void et131x_disable_interrupts(
struct et131x_adapter *adapter)
2074 static void et131x_tx_dma_disable(
struct et131x_adapter *adapter)
2078 &adapter->
regs->txdma.csr);
2085 static void et131x_enable_txrx(
struct net_device *netdev)
2090 et131x_rx_dma_enable(adapter);
2091 et131x_tx_dma_enable(adapter);
2095 et131x_enable_interrupts(adapter);
2098 netif_start_queue(netdev);
2105 static void et131x_disable_txrx(
struct net_device *netdev)
2110 netif_stop_queue(netdev);
2113 et131x_rx_dma_disable(adapter);
2114 et131x_tx_dma_disable(adapter);
2117 et131x_disable_interrupts(adapter);
2132 tcb = adapter->
tx_ring.tcb_ring;
2139 for (ct = 0; ct++ <
NUM_TCB; tcb++)
2143 tcb->
next = tcb + 1;
2174 static void et1310_enable_phy_coma(
struct et131x_adapter *adapter)
2176 unsigned long flags;
2179 pmcsr =
readl(&adapter->
regs->global.pm_csr);
2198 et131x_disable_txrx(adapter->
netdev);
2202 writel(pmcsr, &adapter->
regs->global.pm_csr);
2206 writel(pmcsr, &adapter->
regs->global.pm_csr);
2213 static void et1310_disable_phy_coma(
struct et131x_adapter *adapter)
2217 pmcsr =
readl(&adapter->
regs->global.pm_csr);
2222 writel(pmcsr, &adapter->
regs->global.pm_csr);
2234 et131x_init_send(adapter);
2240 et131x_soft_reset(adapter);
2243 et131x_adapter_setup(adapter);
2248 et131x_enable_txrx(adapter->
netdev);
2251 static inline u32 bump_free_buff_ring(
u32 *free_buff_ring,
u32 limit)
2253 u32 tmp_free_buff_ring = *free_buff_ring;
2254 tmp_free_buff_ring++;
2260 tmp_free_buff_ring &= ~ET_DMA10_MASK;
2265 *free_buff_ring = tmp_free_buff_ring;
2266 return tmp_free_buff_ring;
2276 static void et131x_align_allocated_memory(
struct et131x_adapter *adapter,
2280 u64 new_addr = *phys_addr & ~mask;
2284 if (new_addr != *phys_addr) {
2286 new_addr += mask + 1;
2290 *phys_addr = new_addr;
2303 static int et131x_rx_dma_memory_alloc(
struct et131x_adapter *adapter)
2307 u32 pktstat_ringsize, fbr_chunksize;
2339 rx_ring->
fbr[1]->buffsize = 256;
2340 rx_ring->
fbr[1]->num_entries = 512;
2342 rx_ring->
fbr[0]->buffsize = 2048;
2343 rx_ring->
fbr[0]->num_entries = 512;
2346 rx_ring->
fbr[1]->buffsize = 512;
2347 rx_ring->
fbr[1]->num_entries = 1024;
2349 rx_ring->
fbr[0]->buffsize = 4096;
2350 rx_ring->
fbr[0]->num_entries = 512;
2353 rx_ring->
fbr[1]->buffsize = 1024;
2354 rx_ring->
fbr[1]->num_entries = 768;
2356 rx_ring->
fbr[0]->buffsize = 16384;
2357 rx_ring->
fbr[0]->num_entries = 128;
2361 adapter->
rx_ring.psr_num_entries =
2362 adapter->
rx_ring.fbr[1]->num_entries +
2363 adapter->
rx_ring.fbr[0]->num_entries;
2365 adapter->
rx_ring.psr_num_entries = adapter->
rx_ring.fbr[0]->num_entries;
2369 bufsize = (
sizeof(
struct fbr_desc) * rx_ring->
fbr[0]->num_entries) +
2373 &rx_ring->
fbr[0]->ring_physaddr,
2375 if (!rx_ring->
fbr[0]->ring_virtaddr) {
2377 "Cannot alloc memory for Free Buffer Ring 1\n");
2388 rx_ring->
fbr[0]->real_physaddr = rx_ring->
fbr[0]->ring_physaddr;
2391 et131x_align_allocated_memory(adapter,
2392 &rx_ring->
fbr[0]->real_physaddr,
2393 &rx_ring->
fbr[0]->offset, 0x0FFF);
2395 rx_ring->
fbr[0]->ring_virtaddr =
2396 (
void *)((
u8 *) rx_ring->
fbr[0]->ring_virtaddr +
2397 rx_ring->
fbr[0]->offset);
2401 bufsize = (
sizeof(
struct fbr_desc) * rx_ring->
fbr[1]->num_entries) +
2405 &rx_ring->
fbr[1]->ring_physaddr,
2407 if (!rx_ring->
fbr[1]->ring_virtaddr) {
2409 "Cannot alloc memory for Free Buffer Ring 0\n");
2420 rx_ring->
fbr[1]->real_physaddr = rx_ring->
fbr[1]->ring_physaddr;
2423 et131x_align_allocated_memory(adapter,
2424 &rx_ring->
fbr[1]->real_physaddr,
2425 &rx_ring->
fbr[1]->offset, 0x0FFF);
2427 rx_ring->
fbr[1]->ring_virtaddr =
2428 (
void *)((
u8 *) rx_ring->
fbr[1]->ring_virtaddr +
2429 rx_ring->
fbr[1]->offset);
2431 for (i = 0; i < (rx_ring->
fbr[0]->num_entries /
FBR_CHUNKS); i++) {
2432 u64 fbr1_tmp_physaddr;
2443 if (rx_ring->
fbr[0]->buffsize > 4096)
2446 fbr1_align = rx_ring->
fbr[0]->buffsize;
2450 rx_ring->
fbr[0]->mem_virtaddrs[
i] =
2452 &rx_ring->
fbr[0]->mem_physaddrs[i],
2455 if (!rx_ring->
fbr[0]->mem_virtaddrs[i]) {
2457 "Could not alloc memory\n");
2462 fbr1_tmp_physaddr = rx_ring->
fbr[0]->mem_physaddrs[
i];
2464 et131x_align_allocated_memory(adapter,
2466 &fbr1_offset, (fbr1_align - 1));
2475 (
u8 *) rx_ring->
fbr[0]->mem_virtaddrs[i] +
2476 (j * rx_ring->
fbr[0]->buffsize) + fbr1_offset;
2482 (
u32) (fbr1_tmp_physaddr >> 32);
2484 (
u32) fbr1_tmp_physaddr;
2486 fbr1_tmp_physaddr += rx_ring->
fbr[0]->buffsize;
2497 for (i = 0; i < (rx_ring->
fbr[1]->num_entries /
FBR_CHUNKS); i++) {
2498 u64 fbr0_tmp_physaddr;
2502 ((FBR_CHUNKS + 1) * rx_ring->
fbr[1]->buffsize) - 1;
2503 rx_ring->
fbr[1]->mem_virtaddrs[
i] =
2505 &rx_ring->
fbr[1]->mem_physaddrs[i],
2508 if (!rx_ring->
fbr[1]->mem_virtaddrs[i]) {
2510 "Could not alloc memory\n");
2515 fbr0_tmp_physaddr = rx_ring->
fbr[1]->mem_physaddrs[
i];
2517 et131x_align_allocated_memory(adapter,
2520 rx_ring->
fbr[1]->buffsize - 1);
2526 (
u8 *) rx_ring->
fbr[1]->mem_virtaddrs[i] +
2527 (j * rx_ring->
fbr[1]->buffsize) + fbr0_offset;
2530 (
u32) (fbr0_tmp_physaddr >> 32);
2532 (
u32) fbr0_tmp_physaddr;
2534 fbr0_tmp_physaddr += rx_ring->
fbr[1]->buffsize;
2555 "Cannot alloc memory for Packet Status Ring\n");
2558 pr_info(
"Packet Status Ring %llx\n",
2575 "Cannot alloc memory for Status Block\n");
2607 static void et131x_rx_dma_memory_free(
struct et131x_adapter *adapter)
2611 u32 pktstat_ringsize;
2621 while (!list_empty(&rx_ring->
recv_list)) {
2631 if (rx_ring->
fbr[0]->ring_virtaddr) {
2633 for (index = 0; index <
2635 if (rx_ring->
fbr[0]->mem_virtaddrs[index]) {
2638 if (rx_ring->
fbr[0]->buffsize > 4096)
2641 fbr1_align = rx_ring->
fbr[0]->buffsize;
2649 rx_ring->
fbr[0]->mem_virtaddrs[index],
2650 rx_ring->
fbr[0]->mem_physaddrs[index]);
2657 rx_ring->
fbr[0]->ring_virtaddr = (
void *)((
u8 *)
2658 rx_ring->
fbr[0]->ring_virtaddr - rx_ring->
fbr[0]->offset);
2661 (
sizeof(
struct fbr_desc) * rx_ring->
fbr[0]->num_entries) +
2665 rx_ring->
fbr[0]->ring_virtaddr,
2666 rx_ring->
fbr[0]->ring_physaddr);
2668 rx_ring->
fbr[0]->ring_virtaddr =
NULL;
2673 if (rx_ring->
fbr[1]->ring_virtaddr) {
2675 for (index = 0; index <
2677 if (rx_ring->
fbr[1]->mem_virtaddrs[index]) {
2679 (rx_ring->
fbr[1]->buffsize *
2680 (FBR_CHUNKS + 1)) - 1;
2684 rx_ring->
fbr[1]->mem_virtaddrs[index],
2685 rx_ring->
fbr[1]->mem_physaddrs[index]);
2692 rx_ring->
fbr[1]->ring_virtaddr = (
void *)((
u8 *)
2693 rx_ring->
fbr[1]->ring_virtaddr - rx_ring->
fbr[1]->offset);
2696 (
sizeof(
struct fbr_desc) * rx_ring->
fbr[1]->num_entries) +
2701 rx_ring->
fbr[1]->ring_virtaddr,
2702 rx_ring->
fbr[1]->ring_physaddr);
2704 rx_ring->
fbr[1]->ring_virtaddr =
NULL;
2712 adapter->
rx_ring.psr_num_entries;
2755 struct rfd *rfd =
NULL;
2764 for (rfdct = 0; rfdct < rx_ring->
num_rfd; rfdct++) {
2770 "Couldn't alloc RFD out of kmem_cache\n");
2793 "Allocation problems in et131x_init_recv\n");
2802 static void et131x_set_rx_dma_timer(
struct et131x_adapter *adapter)
2813 writel(0, &adapter->
regs->rxdma.max_pkt_time);
2814 writel(1, &adapter->
regs->rxdma.num_pkt_done);
2823 static void nic_return_rfd(
struct et131x_adapter *adapter,
struct rfd *rfd)
2825 struct rx_ring *rx_local = &adapter->
rx_ring;
2829 unsigned long flags;
2836 (ring_index == 0 && buff_index < rx_local->fbr[1]->
num_entries) ||
2838 (ring_index == 1 && buff_index < rx_local->fbr[0]->
num_entries)) {
2841 if (ring_index == 1) {
2843 (rx_local->
fbr[0]->ring_virtaddr) +
2850 next->
addr_hi = rx_local->
fbr[0]->bus_high[buff_index];
2851 next->
addr_lo = rx_local->
fbr[0]->bus_low[buff_index];
2852 next->
word2 = buff_index;
2854 writel(bump_free_buff_ring(
2855 &rx_local->
fbr[0]->local_full,
2856 rx_local->
fbr[0]->num_entries - 1),
2862 rx_local->
fbr[1]->ring_virtaddr +
2869 next->
addr_hi = rx_local->
fbr[1]->bus_high[buff_index];
2870 next->
addr_lo = rx_local->
fbr[1]->bus_low[buff_index];
2871 next->
word2 = buff_index;
2873 writel(bump_free_buff_ring(
2874 &rx_local->
fbr[1]->local_full,
2875 rx_local->
fbr[1]->num_entries - 1),
2879 spin_unlock_irqrestore(&adapter->
fbr_lock, flags);
2882 "%s illegal Buffer Index returned\n", __func__);
2891 spin_unlock_irqrestore(&adapter->
rcv_lock, flags);
2909 struct rx_ring *rx_local = &adapter->
rx_ring;
2915 unsigned long flags;
2928 word1 = status->
word1 >> 16;
2943 len = psr->
word1 & 0xFFFF;
2944 ring_index = (psr->
word1 >> 26) & 0x03;
2945 buff_index = (psr->
word1 >> 16) & 0x3FF;
2959 &adapter->
regs->rxdma.psr_full_offset);
2962 if (ring_index != 1)
2967 if (ring_index > 1 ||
2969 buff_index > rx_local->
fbr[1]->num_entries - 1) ||
2971 buff_index > rx_local->
fbr[0]->num_entries - 1)) {
2973 if (ring_index != 1 || buff_index > rx_local->
fbr[0]->num_entries - 1) {
2977 "NICRxPkts PSR Entry %d indicates "
2978 "length of %d and/or bad bi(%d)\n",
2992 spin_unlock_irqrestore(&adapter->
rcv_lock, flags);
2999 spin_unlock_irqrestore(&adapter->
rcv_lock, flags);
3010 adapter->
stats.rx_other_errs++;
3035 buf = rx_local->
fbr[(ring_index == 0 ? 1 : 0)]->
3073 adapter->
stats.multicast_pkts_rcvd++;
3074 }
else if (word0 & ALCATEL_BROADCAST_PKT)
3075 adapter->
stats.broadcast_pkts_rcvd++;
3082 adapter->
stats.unicast_pkts_rcvd++;
3091 skb = dev_alloc_skb(rfd->
len + 2);
3094 "Couldn't alloc an SKB for Rx\n");
3105 rx_local->
fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index],
3117 nic_return_rfd(adapter, rfd);
3127 static void et131x_handle_recv_interrupt(
struct et131x_adapter *adapter)
3129 struct rfd *rfd =
NULL;
3135 if (list_empty(&adapter->
rx_ring.recv_list)) {
3141 rfd = nic_rx_pkts(adapter);
3152 !netif_carrier_ok(adapter->
netdev) ||
3162 "RFD's are running out\n");
3168 adapter->
rx_ring.unfinished_receives =
true;
3170 &adapter->
regs->global.watchdog_timer);
3173 adapter->
rx_ring.unfinished_receives =
false;
3188 static int et131x_tx_dma_memory_alloc(
struct et131x_adapter *adapter)
3191 struct tx_ring *tx_ring = &adapter->
tx_ring;
3196 if (!adapter->
tx_ring.tcb_ring) {
3197 dev_err(&adapter->
pdev->dev,
"Cannot alloc memory for TCBs\n");
3210 if (!adapter->
tx_ring.tx_desc_ring) {
3212 "Cannot alloc memory for Tx Ring\n");
3228 if (!adapter->
tx_ring.tx_status_pa) {
3230 "Cannot alloc memory for Tx status block\n");
3242 static void et131x_tx_dma_memory_free(
struct et131x_adapter *adapter)
3246 if (adapter->
tx_ring.tx_desc_ring) {
3252 adapter->
tx_ring.tx_desc_ring,
3253 adapter->
tx_ring.tx_desc_ring_pa);
3258 if (adapter->
tx_ring.tx_status) {
3262 adapter->
tx_ring.tx_status_pa);
3277 static int nic_send_packet(
struct et131x_adapter *adapter,
struct tcb *tcb)
3282 u32 thiscopy, remainder;
3284 u32 nr_frags = skb_shinfo(skb)->nr_frags + 1;
3286 unsigned long flags;
3302 for (i = 0; i < nr_frags; i++) {
3331 desc[frag++].addr_lo =
3350 desc[frag++].addr_lo =
3369 desc[frag++].addr_lo =
3389 desc[frag++].addr_lo = skb_frag_dma_map(
3390 &adapter->
pdev->dev,
3402 adapter->
tx_ring.since_irq = 0;
3419 if (thiscopy >= frag) {
3423 remainder = frag - thiscopy;
3428 sizeof(
struct tx_desc) * thiscopy);
3430 add_10bit(&adapter->
tx_ring.send_idx, thiscopy);
3441 sizeof(
struct tx_desc) * remainder);
3443 add_10bit(&adapter->
tx_ring.send_idx, remainder);
3447 if (adapter->
tx_ring.send_idx)
3456 if (adapter->
tx_ring.send_tail)
3457 adapter->
tx_ring.send_tail->next = tcb;
3459 adapter->
tx_ring.send_head = tcb;
3461 adapter->
tx_ring.send_tail = tcb;
3471 &adapter->
regs->txdma.service_request);
3478 &adapter->
regs->global.watchdog_timer);
3497 struct tcb *tcb =
NULL;
3499 unsigned long flags;
3508 tcb = adapter->
tx_ring.tcb_qhead;
3527 if ((shbufva[0] == 0xffff) &&
3528 (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) {
3530 }
else if ((shbufva[0] & 0x3) == 0x0001) {
3538 status = nic_send_packet(adapter, tcb);
3543 if (adapter->
tx_ring.tcb_qtail)
3544 adapter->
tx_ring.tcb_qtail->next = tcb;
3547 adapter->
tx_ring.tcb_qhead = tcb;
3549 adapter->
tx_ring.tcb_qtail = tcb;
3587 !netif_carrier_ok(netdev)) {
3594 if (status != 0 && status != -
ENOMEM) {
3615 static inline void free_send_packet(
struct et131x_adapter *adapter,
3618 unsigned long flags;
3638 (adapter->
tx_ring.tx_desc_ring +
3651 }
while (desc != (adapter->
tx_ring.tx_desc_ring +
3657 memset(tcb, 0,
sizeof(
struct tcb));
3664 if (adapter->
tx_ring.tcb_qtail)
3665 adapter->
tx_ring.tcb_qtail->next = tcb;
3668 adapter->
tx_ring.tcb_qhead = tcb;
3670 adapter->
tx_ring.tcb_qtail = tcb;
3682 static void et131x_free_busy_send_packets(
struct et131x_adapter *adapter)
3685 unsigned long flags;
3691 tcb = adapter->
tx_ring.send_head;
3694 struct tcb *next = tcb->
next;
3706 free_send_packet(adapter, tcb);
3710 tcb = adapter->
tx_ring.send_head;
3729 static void et131x_handle_send_interrupt(
struct et131x_adapter *adapter)
3731 unsigned long flags;
3736 serviced =
readl(&adapter->
regs->txdma.new_service_complete);
3744 tcb = adapter->
tx_ring.send_head;
3755 free_send_packet(adapter, tcb);
3759 tcb = adapter->
tx_ring.send_head;
3762 !((serviced ^ tcb->
index) & ET_DMA10_WRAP)
3770 free_send_packet(adapter, tcb);
3774 tcb = adapter->
tx_ring.send_head;
3779 netif_wake_queue(adapter->
netdev);
3784 static int et131x_get_settings(
struct net_device *netdev,
3792 static int et131x_set_settings(
struct net_device *netdev,
3800 static int et131x_get_regs_len(
struct net_device *netdev)
3802 #define ET131X_REGS_LEN 256
3806 static void et131x_get_regs(
struct net_device *netdev,
3811 u32 *regs_buff = regs_data;
3814 memset(regs_data, 0, et131x_get_regs_len(netdev));
3816 regs->
version = (1 << 24) | (adapter->
pdev->revision << 16) |
3817 adapter->
pdev->device;
3820 et131x_mii_read(adapter,
MII_BMCR, (
u16 *)®s_buff[num++]);
3821 et131x_mii_read(adapter,
MII_BMSR, (
u16 *)®s_buff[num++]);
3825 et131x_mii_read(adapter,
MII_LPA, (
u16 *)®s_buff[num++]);
3828 et131x_mii_read(adapter, 0x07, (
u16 *)®s_buff[num++]);
3830 et131x_mii_read(adapter, 0x08, (
u16 *)®s_buff[num++]);
3837 (
u16 *)®s_buff[num++]);
3839 (
u16 *)®s_buff[num++]);
3841 (
u16 *)®s_buff[num++]);
3843 (
u16 *)®s_buff[num++]);
3844 et131x_mii_read(adapter,
PHY_CONFIG, (
u16 *)®s_buff[num++]);
3848 (
u16 *)®s_buff[num++]);
3850 et131x_mii_read(adapter,
PHY_LED_1, (
u16 *)®s_buff[num++]);
3851 et131x_mii_read(adapter,
PHY_LED_2, (
u16 *)®s_buff[num++]);
3854 regs_buff[num++] =
readl(&aregs->
global.txq_start_addr);
3855 regs_buff[num++] =
readl(&aregs->
global.txq_end_addr);
3856 regs_buff[num++] =
readl(&aregs->
global.rxq_start_addr);
3857 regs_buff[num++] =
readl(&aregs->
global.rxq_end_addr);
3859 regs_buff[num++] = adapter->
stats.interrupt_status;
3860 regs_buff[num++] =
readl(&aregs->
global.int_mask);
3861 regs_buff[num++] =
readl(&aregs->
global.int_alias_clr_en);
3862 regs_buff[num++] =
readl(&aregs->
global.int_status_alias);
3863 regs_buff[num++] =
readl(&aregs->
global.sw_reset);
3864 regs_buff[num++] =
readl(&aregs->
global.slv_timer);
3865 regs_buff[num++] =
readl(&aregs->
global.msi_config);
3866 regs_buff[num++] =
readl(&aregs->
global.loopback);
3867 regs_buff[num++] =
readl(&aregs->
global.watchdog_timer);
3871 regs_buff[num++] =
readl(&aregs->
txdma.pr_base_hi);
3872 regs_buff[num++] =
readl(&aregs->
txdma.pr_base_lo);
3873 regs_buff[num++] =
readl(&aregs->
txdma.pr_num_des);
3874 regs_buff[num++] =
readl(&aregs->
txdma.txq_wr_addr);
3875 regs_buff[num++] =
readl(&aregs->
txdma.txq_wr_addr_ext);
3876 regs_buff[num++] =
readl(&aregs->
txdma.txq_rd_addr);
3877 regs_buff[num++] =
readl(&aregs->
txdma.dma_wb_base_hi);
3878 regs_buff[num++] =
readl(&aregs->
txdma.dma_wb_base_lo);
3879 regs_buff[num++] =
readl(&aregs->
txdma.service_request);
3880 regs_buff[num++] =
readl(&aregs->
txdma.service_complete);
3881 regs_buff[num++] =
readl(&aregs->
txdma.cache_rd_index);
3882 regs_buff[num++] =
readl(&aregs->
txdma.cache_wr_index);
3883 regs_buff[num++] =
readl(&aregs->
txdma.tx_dma_error);
3884 regs_buff[num++] =
readl(&aregs->
txdma.desc_abort_cnt);
3885 regs_buff[num++] =
readl(&aregs->
txdma.payload_abort_cnt);
3886 regs_buff[num++] =
readl(&aregs->
txdma.writeback_abort_cnt);
3887 regs_buff[num++] =
readl(&aregs->
txdma.desc_timeout_cnt);
3888 regs_buff[num++] =
readl(&aregs->
txdma.payload_timeout_cnt);
3889 regs_buff[num++] =
readl(&aregs->
txdma.writeback_timeout_cnt);
3890 regs_buff[num++] =
readl(&aregs->
txdma.desc_error_cnt);
3891 regs_buff[num++] =
readl(&aregs->
txdma.payload_error_cnt);
3892 regs_buff[num++] =
readl(&aregs->
txdma.writeback_error_cnt);
3893 regs_buff[num++] =
readl(&aregs->
txdma.dropped_tlp_cnt);
3894 regs_buff[num++] =
readl(&aregs->
txdma.new_service_complete);
3895 regs_buff[num++] =
readl(&aregs->
txdma.ethernet_packet_cnt);
3899 regs_buff[num++] =
readl(&aregs->
rxdma.dma_wb_base_hi);
3900 regs_buff[num++] =
readl(&aregs->
rxdma.dma_wb_base_lo);
3901 regs_buff[num++] =
readl(&aregs->
rxdma.num_pkt_done);
3902 regs_buff[num++] =
readl(&aregs->
rxdma.max_pkt_time);
3903 regs_buff[num++] =
readl(&aregs->
rxdma.rxq_rd_addr);
3904 regs_buff[num++] =
readl(&aregs->
rxdma.rxq_rd_addr_ext);
3905 regs_buff[num++] =
readl(&aregs->
rxdma.rxq_wr_addr);
3906 regs_buff[num++] =
readl(&aregs->
rxdma.psr_base_hi);
3907 regs_buff[num++] =
readl(&aregs->
rxdma.psr_base_lo);
3908 regs_buff[num++] =
readl(&aregs->
rxdma.psr_num_des);
3909 regs_buff[num++] =
readl(&aregs->
rxdma.psr_avail_offset);
3910 regs_buff[num++] =
readl(&aregs->
rxdma.psr_full_offset);
3911 regs_buff[num++] =
readl(&aregs->
rxdma.psr_access_index);
3912 regs_buff[num++] =
readl(&aregs->
rxdma.psr_min_des);
3913 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_base_lo);
3914 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_base_hi);
3915 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_num_des);
3916 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_avail_offset);
3917 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_full_offset);
3918 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_rd_index);
3919 regs_buff[num++] =
readl(&aregs->
rxdma.fbr0_min_des);
3920 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_base_lo);
3921 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_base_hi);
3922 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_num_des);
3923 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_avail_offset);
3924 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_full_offset);
3925 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_rd_index);
3926 regs_buff[num++] =
readl(&aregs->
rxdma.fbr1_min_des);
3929 #define ET131X_DRVINFO_LEN 32
3930 static void et131x_get_drvinfo(
struct net_device *netdev,
3941 .get_settings = et131x_get_settings,
3942 .set_settings = et131x_set_settings,
3943 .get_drvinfo = et131x_get_drvinfo,
3944 .get_regs_len = et131x_get_regs_len,
3945 .get_regs = et131x_get_regs,
3958 if (is_zero_ether_addr(adapter->
rom_addr)) {
3996 rc = et131x_init_eeprom(adapter);
4000 if (!pci_is_pcie(pdev)) {
4001 dev_err(&pdev->
dev,
"Missing PCIe capabilities\n");
4010 "Could not read PCI config space for Max Payload Size\n");
4015 max_payload &= 0x07;
4017 if (max_payload < 2) {
4018 static const u16 acknak[2] = { 0x76, 0xD0 };
4019 static const u16 replay[2] = { 0x1E0, 0x2ED };
4022 acknak[max_payload])) {
4024 "Could not write PCI config space for ACK/NAK\n");
4028 replay[max_payload])) {
4030 "Could not write PCI config space for Replay Timer\n");
4040 "Could not write PCI config space for Latency Timers\n");
4048 "Couldn't change PCI config space for Max read size\n");
4056 et131x_hwaddr_init(adapter);
4063 dev_err(&pdev->
dev,
"Could not read PCI config space for MAC address\n");
4082 static void et131x_error_timer_handler(
unsigned long data)
4087 if (et1310_in_phy_coma(adapter)) {
4091 et1310_disable_phy_coma(adapter);
4094 et1310_update_macstat_host_counters(adapter);
4101 if (!phydev->
link) {
4102 if (!et1310_in_phy_coma(adapter)) {
4106 et131x_enable_interrupts(adapter);
4107 et1310_enable_phy_coma(adapter);
4125 static int et131x_adapter_memory_alloc(
struct et131x_adapter *adapter)
4130 status = et131x_tx_dma_memory_alloc(adapter);
4133 "et131x_tx_dma_memory_alloc FAILED\n");
4137 status = et131x_rx_dma_memory_alloc(adapter);
4140 "et131x_rx_dma_memory_alloc FAILED\n");
4141 et131x_tx_dma_memory_free(adapter);
4146 status = et131x_init_recv(adapter);
4149 "et131x_init_recv FAILED\n");
4150 et131x_tx_dma_memory_free(adapter);
4151 et131x_rx_dma_memory_free(adapter);
4160 static void et131x_adapter_memory_free(
struct et131x_adapter *adapter)
4163 et131x_tx_dma_memory_free(adapter);
4164 et131x_rx_dma_memory_free(adapter);
4167 static void et131x_adjust_link(
struct net_device *netdev)
4172 if (netif_carrier_ok(netdev)) {
4189 register18 | 0x8402);
4196 et1310_config_flow_control(adapter);
4208 et131x_set_rx_dma_timer(adapter);
4209 et1310_config_mac_regs2(adapter);
4212 if (phydev && phydev->
link != adapter->
link) {
4218 if (et1310_in_phy_coma(adapter))
4219 et1310_disable_phy_coma(adapter);
4225 "Link down - cable problem ?\n");
4241 register18 | 0x8402);
4249 et131x_free_busy_send_packets(adapter);
4252 et131x_init_send(adapter);
4260 et131x_soft_reset(adapter);
4263 et131x_adapter_setup(adapter);
4266 et131x_disable_txrx(netdev);
4267 et131x_enable_txrx(netdev);
4276 static int et131x_mii_probe(
struct net_device *netdev)
4290 if (IS_ERR(phydev)) {
4291 dev_err(&adapter->
pdev->dev,
"Could not attach to PHY\n");
4292 return PTR_ERR(phydev);
4307 adapter->
phydev = phydev;
4309 dev_info(&adapter->
pdev->dev,
"attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
4310 phydev->
drv->name, dev_name(&phydev->
dev));
4326 static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 };
4331 adapter = netdev_priv(netdev);
4348 memcpy(adapter->
addr, default_mac, ETH_ALEN);
4363 struct net_device *netdev = pci_get_drvdata(pdev);
4372 et131x_adapter_memory_free(adapter);
4385 static void et131x_up(
struct net_device *netdev)
4389 et131x_enable_txrx(netdev);
4397 static void et131x_down(
struct net_device *netdev)
4405 et131x_disable_txrx(netdev);
4408 #ifdef CONFIG_PM_SLEEP
4409 static int et131x_suspend(
struct device *
dev)
4412 struct net_device *netdev = pci_get_drvdata(pdev);
4414 if (netif_running(netdev)) {
4416 et131x_down(netdev);
4423 static int et131x_resume(
struct device *dev)
4426 struct net_device *netdev = pci_get_drvdata(pdev);
4428 if (netif_running(netdev)) {
4438 #define ET131X_PM_OPS (&et131x_pm_ops)
4440 #define ET131X_PM_OPS NULL
4452 bool handled =
true;
4457 if (!netif_device_present(netdev)) {
4462 adapter = netdev_priv(netdev);
4469 et131x_disable_interrupts(adapter);
4474 status =
readl(&adapter->
regs->global.int_status);
4486 et131x_enable_interrupts(adapter);
4493 struct tcb *tcb = adapter->
tx_ring.send_head;
4496 if (++tcb->
stale > 1)
4499 if (adapter->
rx_ring.unfinished_receives)
4501 else if (tcb ==
NULL)
4502 writel(0, &adapter->
regs->global.watchdog_timer);
4504 status &= ~ET_INTR_WATCHDOG;
4513 et131x_enable_interrupts(adapter);
4543 u32 status = adapter->
stats.interrupt_status;
4553 et131x_handle_send_interrupt(adapter);
4557 et131x_handle_recv_interrupt(adapter);
4559 status &= 0xffffffd7;
4567 txdma_err =
readl(&iomem->
txdma.tx_dma_error);
4570 "TXDMA_ERR interrupt, error = %d\n",
4604 if (!et1310_in_phy_coma(adapter))
4646 "RxDMA_ERR interrupt, error %x\n",
4659 dev_err(&adapter->
pdev->dev,
"WAKE_ON_LAN interrupt\n");
4677 "TXMAC interrupt, error 0x%08x\n",
4698 "RXMAC interrupt, error 0x%08x. Requesting reset\n",
4702 "Enable 0x%08x, Diag 0x%08x\n",
4721 et1310_handle_macstat_interrupt(adapter);
4737 et131x_enable_interrupts(adapter);
4793 static int et131x_open(
struct net_device *netdev)
4797 unsigned int irq = pdev->
irq;
4803 adapter->
error_timer.function = et131x_error_timer_handler;
4810 dev_err(&pdev->
dev,
"could not register IRQ %d\n", irq);
4827 static int et131x_close(
struct net_device *netdev)
4831 et131x_down(netdev);
4848 static int et131x_ioctl(
struct net_device *netdev,
struct ifreq *reqbuf,
4867 static int et131x_set_packet_filter(
struct et131x_adapter *adapter)
4874 ctrl =
readl(&adapter->
regs->rxmac.ctrl);
4875 pf_ctrl =
readl(&adapter->
regs->rxmac.pf_ctrl);
4896 et1310_setup_device_for_multicast(adapter);
4903 et1310_setup_device_for_unicast(adapter);
4919 writel(pf_ctrl, &adapter->
regs->rxmac.pf_ctrl);
4929 static void et131x_multicast(
struct net_device *netdev)
4933 unsigned long flags;
4968 adapter->
packet_filter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST;
4990 et131x_set_packet_filter(adapter);
4992 spin_unlock_irqrestore(&adapter->
lock, flags);
5009 !netif_queue_stopped(netdev))
5010 netif_stop_queue(netdev);
5016 status = et131x_send_packets(skb, netdev);
5036 static void et131x_tx_timeout(
struct net_device *netdev)
5040 unsigned long flags;
5054 dev_err(&adapter->
pdev->dev,
"hardware error - reset\n");
5061 tcb = adapter->
tx_ring.send_head;
5071 "Send stuck - reset. tcb->WrIndex %x, flags 0x%08x\n",
5078 et131x_disable_txrx(netdev);
5079 et131x_enable_txrx(netdev);
5094 static int et131x_change_mtu(
struct net_device *netdev,
int new_mtu)
5100 if (new_mtu < 64 || new_mtu > 9216)
5103 et131x_disable_txrx(netdev);
5104 et131x_handle_send_interrupt(adapter);
5105 et131x_handle_recv_interrupt(adapter);
5108 netdev->
mtu = new_mtu;
5111 et131x_adapter_memory_free(adapter);
5115 et131x_soft_reset(adapter);
5118 result = et131x_adapter_memory_alloc(adapter);
5121 "Change MTU failed; couldn't re-alloc DMA memory\n");
5125 et131x_init_send(adapter);
5127 et131x_hwaddr_init(adapter);
5131 et131x_adapter_setup(adapter);
5133 et131x_enable_txrx(netdev);
5147 static int et131x_set_mac_addr(
struct net_device *netdev,
void *new_mac)
5155 if (adapter ==
NULL)
5159 if (!is_valid_ether_addr(address->
sa_data))
5162 et131x_disable_txrx(netdev);
5163 et131x_handle_send_interrupt(adapter);
5164 et131x_handle_recv_interrupt(adapter);
5171 netdev_info(netdev,
"Setting MAC address to %pM\n",
5175 et131x_adapter_memory_free(adapter);
5177 et131x_soft_reset(adapter);
5180 result = et131x_adapter_memory_alloc(adapter);
5183 "Change MAC failed; couldn't re-alloc DMA memory\n");
5187 et131x_init_send(adapter);
5189 et131x_hwaddr_init(adapter);
5192 et131x_adapter_setup(adapter);
5194 et131x_enable_txrx(netdev);
5200 .ndo_open = et131x_open,
5201 .ndo_stop = et131x_close,
5202 .ndo_start_xmit = et131x_tx,
5203 .ndo_set_rx_mode = et131x_multicast,
5204 .ndo_tx_timeout = et131x_tx_timeout,
5205 .ndo_change_mtu = et131x_change_mtu,
5206 .ndo_set_mac_address = et131x_set_mac_addr,
5208 .ndo_get_stats = et131x_stats,
5209 .ndo_do_ioctl = et131x_ioctl,
5234 dev_err(&pdev->
dev,
"pci_enable_device() failed\n");
5240 dev_err(&pdev->
dev,
"Can't find PCI device's base address\n");
5247 dev_err(&pdev->
dev,
"Can't get PCI resources\n");
5258 "Unable to obtain 64 bit DMA for consistent allocations\n");
5259 goto err_release_res;
5265 "Unable to obtain 32 bit DMA for consistent allocations\n");
5266 goto err_release_res;
5269 dev_err(&pdev->
dev,
"No usable DMA addressing method\n");
5271 goto err_release_res;
5277 dev_err(&pdev->
dev,
"Couldn't alloc netdev struct\n");
5279 goto err_release_res;
5288 adapter = et131x_adapter_init(netdev, pdev);
5290 rc = et131x_pci_init(adapter, pdev);
5296 if (!adapter->
regs) {
5297 dev_err(&pdev->
dev,
"Cannot map device registers\n");
5306 et131x_soft_reset(adapter);
5309 et131x_disable_interrupts(adapter);
5312 rc = et131x_adapter_memory_alloc(adapter);
5314 dev_err(&pdev->
dev,
"Could not alloc adapater memory (DMA)\n");
5319 et131x_init_send(adapter);
5329 et1310_disable_phy_coma(adapter);
5334 adapter->
mii_bus = mdiobus_alloc();
5336 dev_err(&pdev->
dev,
"Alloc of mii_bus struct failed\n");
5340 adapter->
mii_bus->name =
"et131x_eth_mii";
5342 (adapter->
pdev->bus->number << 8) | adapter->
pdev->devfn);
5344 adapter->
mii_bus->read = et131x_mdio_read;
5345 adapter->
mii_bus->write = et131x_mdio_write;
5346 adapter->
mii_bus->reset = et131x_mdio_reset;
5349 dev_err(&pdev->
dev,
"mii_bus irq allocation failed\n");
5358 dev_err(&pdev->
dev,
"failed to register MII bus\n");
5359 goto err_mdio_free_irq;
5362 rc = et131x_mii_probe(netdev);
5364 dev_err(&pdev->
dev,
"failed to probe MII bus\n");
5365 goto err_mdio_unregister;
5369 et131x_adapter_setup(adapter);
5381 dev_err(&pdev->
dev,
"register_netdev() failed\n");
5382 goto err_phy_disconnect;
5389 pci_set_drvdata(pdev, netdev);
5395 err_mdio_unregister:
5402 et131x_adapter_memory_free(adapter);
5424 .id_table = et131x_pci_table,
5425 .probe = et131x_pci_setup,