Commit c994ae17 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://gkernel.bkbits.net/net-drivers-2.6

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents 48273525 7667f5e4
Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
============================================================== ==============================================================
September 13, 2004 November 17, 2004
Contents Contents
...@@ -18,9 +18,7 @@ In This Release ...@@ -18,9 +18,7 @@ In This Release
=============== ===============
This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of
Adapters, version 3.2.x. This driver includes support for Itanium(TM)2 and Adapters, version 3.3.x. This driver supports 2.4.x and 2.6.x kernels.
EM64T systems.
Identifying Your Adapter Identifying Your Adapter
======================== ========================
...@@ -119,12 +117,6 @@ Additional Configurations ...@@ -119,12 +117,6 @@ Additional Configurations
The latest release of ethtool can be found at: The latest release of ethtool can be found at:
http://sf.net/projects/gkernel. http://sf.net/projects/gkernel.
After ethtool is installed, ethtool-copy.h must be copied and renamed to
ethtool.h in your kernel source tree at <linux_kernel_src>/include/linux.
Backup the original ethtool.h as needed before copying. The driver then
must be recompiled in order to take advantage of the latest ethtool
features.
NOTE: This driver uses mii support from the kernel. As a result, when NOTE: This driver uses mii support from the kernel. As a result, when
there is no link, ethtool will report speed/duplex to be 10/half. there is no link, ethtool will report speed/duplex to be 10/half.
......
Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters
=============================================================== ===============================================================
September 13, 2004 November 17, 2004
Contents Contents
...@@ -20,8 +20,7 @@ In This Release ...@@ -20,8 +20,7 @@ In This Release
=============== ===============
This file describes the Linux* Base Driver for the Intel(R) PRO/1000 Family This file describes the Linux* Base Driver for the Intel(R) PRO/1000 Family
of Adapters, version 5.x.x. This driver includes support for Itanium(TM)2 of Adapters, version 5.x.x.
and EM64T systems.
For questions related to hardware requirements, refer to the documentation For questions related to hardware requirements, refer to the documentation
supplied with your Intel PRO/1000 adapter. All hardware requirements listed supplied with your Intel PRO/1000 adapter. All hardware requirements listed
...@@ -145,9 +144,11 @@ Valid Range: 80-256 for 82542 and 82543-based adapters ...@@ -145,9 +144,11 @@ Valid Range: 80-256 for 82542 and 82543-based adapters
Default Value: 256 Default Value: 256
This value is the number of receive descriptors allocated by the driver. This value is the number of receive descriptors allocated by the driver.
Increasing this value allows the driver to buffer more incoming packets. Increasing this value allows the driver to buffer more incoming packets.
Each descriptor is 16 bytes. A receive buffer is also allocated for each Each descriptor is 16 bytes. A receive buffer is allocated for each
descriptor and can be either 2048, 4096, 8192, or 16384 bytes, depending descriptor and can either be 2048 or 4096 bytes long, depending on the MTU
on the MTU setting. The maximum MTU size is 16110.
setting. An incoming packet can span one or more receive descriptors.
The maximum MTU size is 16110.
NOTE: MTU designates the frame size. It only needs to be set for Jumbo NOTE: MTU designates the frame size. It only needs to be set for Jumbo
Frames. Frames.
...@@ -251,17 +252,16 @@ For copper-based boards, the keywords interact as follows: ...@@ -251,17 +252,16 @@ For copper-based boards, the keywords interact as follows:
also be forced. also be forced.
The AutoNeg parameter is used when more control is required over the auto- The AutoNeg parameter is used when more control is required over the auto-
negotiation process. When this parameter is used, Speed and Duplex must not negotiation process. When this parameter is used, Speed and Duplex parameters
be specified. This parameter is a bitmap that specifies which speed and must not be specified. The following table describes supported values for the
duplex settings are advertised to the link partner. AutoNeg parameter:
Bit 7 6 5 4 3 2 1 0 Speed (Mbps) 1000 100 100 10 10
Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10
Duplex Full Full Half Full Half Duplex Full Full Half Full Half
Value (in base 16) 0x20 0x08 0x04 0x02 0x01
For example to limit the negotiated speed/duplex on the interface to 10 Mbps Example: insmod e1000 AutoNeg=0x03, loads e1000 and specifies (10 full duplex,
Half or Full duplex, set AutoNeg to 0x02: 10 half duplex) for negotiation with the peer.
insmod e1000 AutoNeg=0x02
Note that setting AutoNeg does not guarantee that the board will link at the Note that setting AutoNeg does not guarantee that the board will link at the
highest specified speed or duplex mode, but the board will link at the highest specified speed or duplex mode, but the board will link at the
...@@ -333,11 +333,7 @@ Additional Configurations ...@@ -333,11 +333,7 @@ Additional Configurations
version 1.6 or later is required for this functionality. version 1.6 or later is required for this functionality.
The latest release of ethtool can be found from The latest release of ethtool can be found from
http://sf.net/projects/gkernel. After ethtool is installed, http://sf.net/projects/gkernel.
ethtool-copy.h must be copied and renamed to ethtool.h in your kernel
source tree at <linux_kernel_src>/include/linux. Backup the original
ethtool.h as needed before copying. The driver then must be recompiled
in order to take advantage of the latest ethtool features.
NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support
for a more complete ethtool feature set can be enabled by upgrading for a more complete ethtool feature set can be enabled by upgrading
......
...@@ -209,6 +209,9 @@ static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data); ...@@ -209,6 +209,9 @@ static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data);
#if defined(CONFIG_EISA) || defined(CONFIG_MCA) #if defined(CONFIG_EISA) || defined(CONFIG_MCA)
static int el3_device_remove (struct device *device); static int el3_device_remove (struct device *device);
#endif #endif
#ifdef CONFIG_NET_POLL_CONTROLLER
static void el3_poll_controller(struct net_device *dev);
#endif
#ifdef CONFIG_EISA #ifdef CONFIG_EISA
struct eisa_device_id el3_eisa_ids[] = { struct eisa_device_id el3_eisa_ids[] = {
...@@ -321,6 +324,9 @@ static int __init el3_common_init(struct net_device *dev) ...@@ -321,6 +324,9 @@ static int __init el3_common_init(struct net_device *dev)
dev->set_multicast_list = &set_multicast_list; dev->set_multicast_list = &set_multicast_list;
dev->tx_timeout = el3_tx_timeout; dev->tx_timeout = el3_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT; dev->watchdog_timeo = TX_TIMEOUT;
#ifdef CONFIG_NET_POLL_CONTROLLER
dev->poll_controller = el3_poll_controller;
#endif
SET_ETHTOOL_OPS(dev, &ethtool_ops); SET_ETHTOOL_OPS(dev, &ethtool_ops);
err = register_netdev(dev); err = register_netdev(dev);
...@@ -999,6 +1005,19 @@ el3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -999,6 +1005,19 @@ el3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
} }
#ifdef CONFIG_NET_POLL_CONTROLLER
/*
* Polling receive - used by netconsole and other diagnostic tools
* to allow network i/o with interrupts disabled.
*/
static void el3_poll_controller(struct net_device *dev)
{
disable_irq(dev->irq);
el3_interrupt(dev->irq, dev, NULL);
enable_irq(dev->irq);
}
#endif
static struct net_device_stats * static struct net_device_stats *
el3_get_stats(struct net_device *dev) el3_get_stats(struct net_device *dev)
{ {
......
...@@ -398,6 +398,8 @@ static void cp_clean_rings (struct cp_private *cp); ...@@ -398,6 +398,8 @@ static void cp_clean_rings (struct cp_private *cp);
static struct pci_device_id cp_pci_tbl[] = { static struct pci_device_id cp_pci_tbl[] = {
{ PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
{ PCI_VENDOR_ID_TTTECH, PCI_DEVICE_ID_TTTECH_MC322,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
{ }, { },
}; };
MODULE_DEVICE_TABLE(pci, cp_pci_tbl); MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
......
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
#define DRV_NAME "e100" #define DRV_NAME "e100"
#define DRV_EXT "-NAPI" #define DRV_EXT "-NAPI"
#define DRV_VERSION "3.2.3-k2"DRV_EXT #define DRV_VERSION "3.3.6-k2"DRV_EXT
#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
#define DRV_COPYRIGHT "Copyright(c) 1999-2004 Intel Corporation" #define DRV_COPYRIGHT "Copyright(c) 1999-2004 Intel Corporation"
#define PFX DRV_NAME ": " #define PFX DRV_NAME ": "
...@@ -201,6 +201,7 @@ static struct pci_device_id e100_id_table[] = { ...@@ -201,6 +201,7 @@ static struct pci_device_id e100_id_table[] = {
INTEL_8255X_ETHERNET_DEVICE(0x1055, 5), INTEL_8255X_ETHERNET_DEVICE(0x1055, 5),
INTEL_8255X_ETHERNET_DEVICE(0x1056, 5), INTEL_8255X_ETHERNET_DEVICE(0x1056, 5),
INTEL_8255X_ETHERNET_DEVICE(0x1057, 5), INTEL_8255X_ETHERNET_DEVICE(0x1057, 5),
INTEL_8255X_ETHERNET_DEVICE(0x1059, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1064, 6), INTEL_8255X_ETHERNET_DEVICE(0x1064, 6),
INTEL_8255X_ETHERNET_DEVICE(0x1065, 6), INTEL_8255X_ETHERNET_DEVICE(0x1065, 6),
INTEL_8255X_ETHERNET_DEVICE(0x1066, 6), INTEL_8255X_ETHERNET_DEVICE(0x1066, 6),
...@@ -209,7 +210,6 @@ static struct pci_device_id e100_id_table[] = { ...@@ -209,7 +210,6 @@ static struct pci_device_id e100_id_table[] = {
INTEL_8255X_ETHERNET_DEVICE(0x1069, 6), INTEL_8255X_ETHERNET_DEVICE(0x1069, 6),
INTEL_8255X_ETHERNET_DEVICE(0x106A, 6), INTEL_8255X_ETHERNET_DEVICE(0x106A, 6),
INTEL_8255X_ETHERNET_DEVICE(0x106B, 6), INTEL_8255X_ETHERNET_DEVICE(0x106B, 6),
INTEL_8255X_ETHERNET_DEVICE(0x1059, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1209, 0), INTEL_8255X_ETHERNET_DEVICE(0x1209, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1229, 0), INTEL_8255X_ETHERNET_DEVICE(0x1229, 0),
INTEL_8255X_ETHERNET_DEVICE(0x2449, 2), INTEL_8255X_ETHERNET_DEVICE(0x2449, 2),
...@@ -621,8 +621,7 @@ static int e100_self_test(struct nic *nic) ...@@ -621,8 +621,7 @@ static int e100_self_test(struct nic *nic)
writel(selftest | dma_addr, &nic->csr->port); writel(selftest | dma_addr, &nic->csr->port);
e100_write_flush(nic); e100_write_flush(nic);
/* Wait 10 msec for self-test to complete */ /* Wait 10 msec for self-test to complete */
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(HZ / 100 + 1);
/* Interrupts are enabled after self-test */ /* Interrupts are enabled after self-test */
e100_disable_irq(nic); e100_disable_irq(nic);
...@@ -670,8 +669,7 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, u16 data) ...@@ -670,8 +669,7 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, u16 data)
e100_write_flush(nic); udelay(4); e100_write_flush(nic); udelay(4);
} }
/* Wait 10 msec for cmd to complete */ /* Wait 10 msec for cmd to complete */
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(HZ / 100 + 1);
/* Chip deselect */ /* Chip deselect */
writeb(0, &nic->csr->eeprom_ctrl_lo); writeb(0, &nic->csr->eeprom_ctrl_lo);
...@@ -1760,8 +1758,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) ...@@ -1760,8 +1758,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
memset(skb->data, 0xFF, ETH_DATA_LEN); memset(skb->data, 0xFF, ETH_DATA_LEN);
e100_xmit_frame(skb, nic->netdev); e100_xmit_frame(skb, nic->netdev);
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(HZ / 100 + 1);
if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd),
skb->data, ETH_DATA_LEN)) skb->data, ETH_DATA_LEN))
...@@ -1847,8 +1844,7 @@ static void e100_get_regs(struct net_device *netdev, ...@@ -1847,8 +1844,7 @@ static void e100_get_regs(struct net_device *netdev,
mdio_read(netdev, nic->mii.phy_id, i); mdio_read(netdev, nic->mii.phy_id, i);
memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf));
e100_exec_cb(nic, NULL, e100_dump); e100_exec_cb(nic, NULL, e100_dump);
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(HZ / 100 + 1);
memcpy(&buff[2 + E100_PHY_REGS], nic->mem->dump_buf, memcpy(&buff[2 + E100_PHY_REGS], nic->mem->dump_buf,
sizeof(nic->mem->dump_buf)); sizeof(nic->mem->dump_buf));
} }
...@@ -2027,8 +2023,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data) ...@@ -2027,8 +2023,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data)
if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
mod_timer(&nic->blink_timer, jiffies); mod_timer(&nic->blink_timer, jiffies);
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(data * 1000);
schedule_timeout(data * HZ);
del_timer_sync(&nic->blink_timer); del_timer_sync(&nic->blink_timer);
mdio_write(netdev, nic->mii.phy_id, MII_LED_CONTROL, 0); mdio_write(netdev, nic->mii.phy_id, MII_LED_CONTROL, 0);
......
...@@ -776,7 +776,7 @@ static int ...@@ -776,7 +776,7 @@ static int
e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data) e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
uint32_t icr, mask, i=0, shared_int = TRUE; uint32_t mask, i=0, shared_int = TRUE;
uint32_t irq = adapter->pdev->irq; uint32_t irq = adapter->pdev->irq;
*data = 0; *data = 0;
...@@ -784,7 +784,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data) ...@@ -784,7 +784,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
/* Hook up test interrupt handler just for this test */ /* Hook up test interrupt handler just for this test */
if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) { if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) {
shared_int = FALSE; shared_int = FALSE;
} else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ, netdev->name, netdev)){ } else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ,
netdev->name, netdev)){
*data = 1; *data = 1;
return -1; return -1;
} }
...@@ -793,21 +794,6 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data) ...@@ -793,21 +794,6 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF); E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
msec_delay(10); msec_delay(10);
/* Interrupts are disabled, so read interrupt cause
* register (icr) twice to verify that there are no interrupts
* pending. icr is clear on read.
*/
icr = E1000_READ_REG(&adapter->hw, ICR);
icr = E1000_READ_REG(&adapter->hw, ICR);
if(icr != 0) {
/* if icr is non-zero, there is no point
* running other interrupt tests.
*/
*data = 2;
i = 10;
}
/* Test each interrupt */ /* Test each interrupt */
for(; i < 10; i++) { for(; i < 10; i++) {
...@@ -856,8 +842,10 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data) ...@@ -856,8 +842,10 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
* test failed. * test failed.
*/ */
adapter->test_icr = 0; adapter->test_icr = 0;
E1000_WRITE_REG(&adapter->hw, IMC, ~mask); E1000_WRITE_REG(&adapter->hw, IMC,
E1000_WRITE_REG(&adapter->hw, ICS, ~mask); (~mask & 0x00007FFF));
E1000_WRITE_REG(&adapter->hw, ICS,
(~mask & 0x00007FFF));
msec_delay(10); msec_delay(10);
if(adapter->test_icr) { if(adapter->test_icr) {
...@@ -1336,10 +1324,17 @@ e1000_run_loopback_test(struct e1000_adapter *adapter) ...@@ -1336,10 +1324,17 @@ e1000_run_loopback_test(struct e1000_adapter *adapter)
msec_delay(200); msec_delay(200);
pci_dma_sync_single_for_cpu(pdev, rxdr->buffer_info[0].dma, i = 0;
rxdr->buffer_info[0].length, PCI_DMA_FROMDEVICE); do {
pci_dma_sync_single_for_cpu(pdev, rxdr->buffer_info[i].dma,
rxdr->buffer_info[i].length,
PCI_DMA_FROMDEVICE);
return e1000_check_lbtest_frame(rxdr->buffer_info[0].skb, 1024); if (!e1000_check_lbtest_frame(rxdr->buffer_info[i++].skb, 1024))
return 0;
} while (i < 64);
return 13;
} }
static int static int
...@@ -1358,11 +1353,28 @@ static int ...@@ -1358,11 +1353,28 @@ static int
e1000_link_test(struct e1000_adapter *adapter, uint64_t *data) e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
{ {
*data = 0; *data = 0;
if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
int i = 0;
adapter->hw.serdes_link_down = TRUE;
/* on some blade server designs link establishment */
/* could take as long as 2-3 minutes. */
do {
e1000_check_for_link(&adapter->hw);
if (adapter->hw.serdes_link_down == FALSE)
return *data;
msec_delay(20);
} while (i++ < 3750);
*data = 1;
} else {
e1000_check_for_link(&adapter->hw); e1000_check_for_link(&adapter->hw);
if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) { if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
*data = 1; *data = 1;
} }
}
return *data; return *data;
} }
...@@ -1490,6 +1502,8 @@ e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) ...@@ -1490,6 +1502,8 @@ e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
case E1000_DEV_ID_82543GC_COPPER: case E1000_DEV_ID_82543GC_COPPER:
case E1000_DEV_ID_82544EI_FIBER: case E1000_DEV_ID_82544EI_FIBER:
case E1000_DEV_ID_82546EB_QUAD_COPPER: case E1000_DEV_ID_82546EB_QUAD_COPPER:
case E1000_DEV_ID_82545EM_FIBER:
case E1000_DEV_ID_82545EM_COPPER:
return wol->wolopts ? -EOPNOTSUPP : 0; return wol->wolopts ? -EOPNOTSUPP : 0;
case E1000_DEV_ID_82546EB_FIBER: case E1000_DEV_ID_82546EB_FIBER:
...@@ -1554,9 +1568,7 @@ e1000_phys_id(struct net_device *netdev, uint32_t data) ...@@ -1554,9 +1568,7 @@ e1000_phys_id(struct net_device *netdev, uint32_t data)
e1000_setup_led(&adapter->hw); e1000_setup_led(&adapter->hw);
mod_timer(&adapter->blink_timer, jiffies); mod_timer(&adapter->blink_timer, jiffies);
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(data * 1000);
schedule_timeout(data * HZ);
del_timer_sync(&adapter->blink_timer); del_timer_sync(&adapter->blink_timer);
e1000_led_off(&adapter->hw); e1000_led_off(&adapter->hw);
clear_bit(E1000_LED_ON, &adapter->led_status); clear_bit(E1000_LED_ON, &adapter->led_status);
......
...@@ -123,16 +123,31 @@ e1000_set_phy_type(struct e1000_hw *hw) ...@@ -123,16 +123,31 @@ e1000_set_phy_type(struct e1000_hw *hw)
static void static void
e1000_phy_init_script(struct e1000_hw *hw) e1000_phy_init_script(struct e1000_hw *hw)
{ {
uint32_t ret_val;
uint16_t phy_saved_data;
DEBUGFUNC("e1000_phy_init_script"); DEBUGFUNC("e1000_phy_init_script");
if(hw->phy_init_script) { if(hw->phy_init_script) {
msec_delay(20); msec_delay(20);
/* Save off the current value of register 0x2F5B to be restored at
* the end of this routine. */
ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
/* Disabled the PHY transmitter */
e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
msec_delay(20);
e1000_write_phy_reg(hw,0x0000,0x0140); e1000_write_phy_reg(hw,0x0000,0x0140);
msec_delay(5); msec_delay(5);
if(hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547) { switch(hw->mac_type) {
case e1000_82541:
case e1000_82547:
e1000_write_phy_reg(hw, 0x1F95, 0x0001); e1000_write_phy_reg(hw, 0x1F95, 0x0001);
e1000_write_phy_reg(hw, 0x1F71, 0xBD21); e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
...@@ -150,12 +165,23 @@ e1000_phy_init_script(struct e1000_hw *hw) ...@@ -150,12 +165,23 @@ e1000_phy_init_script(struct e1000_hw *hw)
e1000_write_phy_reg(hw, 0x1F96, 0x003F); e1000_write_phy_reg(hw, 0x1F96, 0x003F);
e1000_write_phy_reg(hw, 0x2010, 0x0008); e1000_write_phy_reg(hw, 0x2010, 0x0008);
} else { break;
case e1000_82541_rev_2:
case e1000_82547_rev_2:
e1000_write_phy_reg(hw, 0x1F73, 0x0099); e1000_write_phy_reg(hw, 0x1F73, 0x0099);
break;
default:
break;
} }
e1000_write_phy_reg(hw, 0x0000, 0x3300); e1000_write_phy_reg(hw, 0x0000, 0x3300);
msec_delay(20);
/* Now enable the transmitter */
e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
if(hw->mac_type == e1000_82547) { if(hw->mac_type == e1000_82547) {
uint16_t fused, fine, coarse; uint16_t fused, fine, coarse;
...@@ -244,6 +270,7 @@ e1000_set_mac_type(struct e1000_hw *hw) ...@@ -244,6 +270,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_82546GB_COPPER: case E1000_DEV_ID_82546GB_COPPER:
case E1000_DEV_ID_82546GB_FIBER: case E1000_DEV_ID_82546GB_FIBER:
case E1000_DEV_ID_82546GB_SERDES: case E1000_DEV_ID_82546GB_SERDES:
case E1000_DEV_ID_82546GB_PCIE:
hw->mac_type = e1000_82546_rev_3; hw->mac_type = e1000_82546_rev_3;
break; break;
case E1000_DEV_ID_82541EI: case E1000_DEV_ID_82541EI:
...@@ -967,7 +994,7 @@ e1000_setup_copper_link(struct e1000_hw *hw) ...@@ -967,7 +994,7 @@ e1000_setup_copper_link(struct e1000_hw *hw)
if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
hw->dsp_config_state = e1000_dsp_config_disabled; hw->dsp_config_state = e1000_dsp_config_disabled;
/* Force MDI for IGP B-0 PHY */ /* Force MDI for earlier revs of the IGP PHY */
phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX |
IGP01E1000_PSCR_FORCE_MDI_MDIX); IGP01E1000_PSCR_FORCE_MDI_MDIX);
hw->mdix = 1; hw->mdix = 1;
...@@ -2466,13 +2493,15 @@ e1000_read_phy_reg(struct e1000_hw *hw, ...@@ -2466,13 +2493,15 @@ e1000_read_phy_reg(struct e1000_hw *hw,
DEBUGFUNC("e1000_read_phy_reg"); DEBUGFUNC("e1000_read_phy_reg");
if(hw->phy_type == e1000_phy_igp && if(hw->phy_type == e1000_phy_igp &&
(reg_addr > MAX_PHY_MULTI_PAGE_REG)) { (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
(uint16_t)reg_addr); (uint16_t)reg_addr);
if(ret_val) if(ret_val) {
return ret_val; return ret_val;
} }
}
ret_val = e1000_read_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr, ret_val = e1000_read_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
phy_data); phy_data);
...@@ -2570,13 +2599,15 @@ e1000_write_phy_reg(struct e1000_hw *hw, ...@@ -2570,13 +2599,15 @@ e1000_write_phy_reg(struct e1000_hw *hw,
DEBUGFUNC("e1000_write_phy_reg"); DEBUGFUNC("e1000_write_phy_reg");
if(hw->phy_type == e1000_phy_igp && if(hw->phy_type == e1000_phy_igp &&
(reg_addr > MAX_PHY_MULTI_PAGE_REG)) { (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
(uint16_t)reg_addr); (uint16_t)reg_addr);
if(ret_val) if(ret_val) {
return ret_val; return ret_val;
} }
}
ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr, ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
phy_data); phy_data);
...@@ -3478,7 +3509,7 @@ e1000_read_eeprom(struct e1000_hw *hw, ...@@ -3478,7 +3509,7 @@ e1000_read_eeprom(struct e1000_hw *hw,
/* A check for invalid values: offset too large, too many words, and not /* A check for invalid values: offset too large, too many words, and not
* enough words. * enough words.
*/ */
if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) || if((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
(words == 0)) { (words == 0)) {
DEBUGOUT("\"words\" parameter out of bounds\n"); DEBUGOUT("\"words\" parameter out of bounds\n");
return -E1000_ERR_EEPROM; return -E1000_ERR_EEPROM;
...@@ -3626,7 +3657,7 @@ e1000_write_eeprom(struct e1000_hw *hw, ...@@ -3626,7 +3657,7 @@ e1000_write_eeprom(struct e1000_hw *hw,
/* A check for invalid values: offset too large, too many words, and not /* A check for invalid values: offset too large, too many words, and not
* enough words. * enough words.
*/ */
if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) || if((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
(words == 0)) { (words == 0)) {
DEBUGOUT("\"words\" parameter out of bounds\n"); DEBUGOUT("\"words\" parameter out of bounds\n");
return -E1000_ERR_EEPROM; return -E1000_ERR_EEPROM;
...@@ -4918,7 +4949,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw, ...@@ -4918,7 +4949,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
boolean_t link_up) boolean_t link_up)
{ {
int32_t ret_val; int32_t ret_val;
uint16_t phy_data, speed, duplex, i; uint16_t phy_data, phy_saved_data, speed, duplex, i;
uint16_t dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = uint16_t dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
{IGP01E1000_PHY_AGC_PARAM_A, {IGP01E1000_PHY_AGC_PARAM_A,
IGP01E1000_PHY_AGC_PARAM_B, IGP01E1000_PHY_AGC_PARAM_B,
...@@ -4999,6 +5030,21 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw, ...@@ -4999,6 +5030,21 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
} }
} else { } else {
if(hw->dsp_config_state == e1000_dsp_config_activated) { if(hw->dsp_config_state == e1000_dsp_config_activated) {
/* Save off the current value of register 0x2F5B to be restored at
* the end of the routines. */
ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
if(ret_val)
return ret_val;
/* Disable the PHY transmitter */
ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
if(ret_val)
return ret_val;
msec_delay(20);
ret_val = e1000_write_phy_reg(hw, 0x0000, ret_val = e1000_write_phy_reg(hw, 0x0000,
IGP01E1000_IEEE_FORCE_GIGA); IGP01E1000_IEEE_FORCE_GIGA);
if(ret_val) if(ret_val)
...@@ -5021,10 +5067,33 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw, ...@@ -5021,10 +5067,33 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
if(ret_val) if(ret_val)
return ret_val; return ret_val;
msec_delay(20);
/* Now enable the transmitter */
ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
if(ret_val)
return ret_val;
hw->dsp_config_state = e1000_dsp_config_enabled; hw->dsp_config_state = e1000_dsp_config_enabled;
} }
if(hw->ffe_config_state == e1000_ffe_config_active) { if(hw->ffe_config_state == e1000_ffe_config_active) {
/* Save off the current value of register 0x2F5B to be restored at
* the end of the routines. */
ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
if(ret_val)
return ret_val;
/* Disable the PHY transmitter */
ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
if(ret_val)
return ret_val;
msec_delay(20);
ret_val = e1000_write_phy_reg(hw, 0x0000, ret_val = e1000_write_phy_reg(hw, 0x0000,
IGP01E1000_IEEE_FORCE_GIGA); IGP01E1000_IEEE_FORCE_GIGA);
if(ret_val) if(ret_val)
...@@ -5038,6 +5107,15 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw, ...@@ -5038,6 +5107,15 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
IGP01E1000_IEEE_RESTART_AUTONEG); IGP01E1000_IEEE_RESTART_AUTONEG);
if(ret_val) if(ret_val)
return ret_val; return ret_val;
msec_delay(20);
/* Now enable the transmitter */
ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
if(ret_val)
return ret_val;
hw->ffe_config_state = e1000_ffe_config_enabled; hw->ffe_config_state = e1000_ffe_config_enabled;
} }
} }
...@@ -5126,14 +5204,29 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw, ...@@ -5126,14 +5204,29 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw,
* Dx states where the power conservation is most important. During * Dx states where the power conservation is most important. During
* driver activity we should enable SmartSpeed, so performance is * driver activity we should enable SmartSpeed, so performance is
* maintained. */ * maintained. */
ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data); if (hw->smart_speed == e1000_smart_speed_on) {
ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
&phy_data);
if(ret_val) if(ret_val)
return ret_val; return ret_val;
phy_data |= IGP01E1000_PSCFR_SMART_SPEED; phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data); ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
phy_data);
if(ret_val) if(ret_val)
return ret_val; return ret_val;
} else if (hw->smart_speed == e1000_smart_speed_off) {
ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
&phy_data);
if (ret_val)
return ret_val;
phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
phy_data);
if(ret_val)
return ret_val;
}
} else if((hw->autoneg_advertised == AUTONEG_ADVERTISE_SPEED_DEFAULT) || } else if((hw->autoneg_advertised == AUTONEG_ADVERTISE_SPEED_DEFAULT) ||
(hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) || (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) ||
......
...@@ -167,6 +167,12 @@ typedef enum { ...@@ -167,6 +167,12 @@ typedef enum {
e1000_downshift_undefined = 0xFF e1000_downshift_undefined = 0xFF
} e1000_downshift; } e1000_downshift;
typedef enum {
e1000_smart_speed_default = 0,
e1000_smart_speed_on,
e1000_smart_speed_off
} e1000_smart_speed;
typedef enum { typedef enum {
e1000_polarity_reversal_enabled = 0, e1000_polarity_reversal_enabled = 0,
e1000_polarity_reversal_disabled, e1000_polarity_reversal_disabled,
...@@ -361,6 +367,7 @@ int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active); ...@@ -361,6 +367,7 @@ int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
#define E1000_DEV_ID_82546GB_COPPER 0x1079 #define E1000_DEV_ID_82546GB_COPPER 0x1079
#define E1000_DEV_ID_82546GB_FIBER 0x107A #define E1000_DEV_ID_82546GB_FIBER 0x107A
#define E1000_DEV_ID_82546GB_SERDES 0x107B #define E1000_DEV_ID_82546GB_SERDES 0x107B
#define E1000_DEV_ID_82546GB_PCIE 0x108A
#define E1000_DEV_ID_82547EI 0x1019 #define E1000_DEV_ID_82547EI 0x1019
#define NODE_ADDRESS_SIZE 6 #define NODE_ADDRESS_SIZE 6
#define ETH_LENGTH_OF_ADDRESS 6 #define ETH_LENGTH_OF_ADDRESS 6
...@@ -1026,6 +1033,7 @@ struct e1000_hw { ...@@ -1026,6 +1033,7 @@ struct e1000_hw {
uint8_t perm_mac_addr[NODE_ADDRESS_SIZE]; uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
boolean_t disable_polarity_correction; boolean_t disable_polarity_correction;
boolean_t speed_downgraded; boolean_t speed_downgraded;
e1000_smart_speed smart_speed;
e1000_dsp_config dsp_config_state; e1000_dsp_config dsp_config_state;
boolean_t get_link_status; boolean_t get_link_status;
boolean_t serdes_link_down; boolean_t serdes_link_down;
......
This diff is collapsed.
...@@ -42,13 +42,8 @@ ...@@ -42,13 +42,8 @@
#include <linux/sched.h> #include <linux/sched.h>
#ifndef msec_delay #ifndef msec_delay
#define msec_delay(x) do { if(in_interrupt()) { \ #define msec_delay(x) msleep(x)
/* Don't mdelay in interrupt context! */ \
BUG(); \
} else { \
set_current_state(TASK_UNINTERRUPTIBLE); \
schedule_timeout((x * HZ)/1000 + 2); \
} } while(0)
/* Some workarounds require millisecond delays and are run during interrupt /* Some workarounds require millisecond delays and are run during interrupt
* context. Most notably, when establishing link, the phy may need tweaking * context. Most notably, when establishing link, the phy may need tweaking
* but cannot process phy register reads/writes faster than millisecond * but cannot process phy register reads/writes faster than millisecond
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#define E1000_PARAM(X, desc) \ #define E1000_PARAM(X, desc) \
static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
static int num_##X = 0; \ static int num_##X = 0; \
module_param_array(X, int, &num_##X, 0); \ module_param_array_named(X, X, int, &num_##X, 0); \
MODULE_PARM_DESC(X, desc); MODULE_PARM_DESC(X, desc);
/* Transmit Descriptor Count /* Transmit Descriptor Count
...@@ -470,9 +470,6 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -470,9 +470,6 @@ e1000_check_options(struct e1000_adapter *adapter)
if (num_InterruptThrottleRate > bd) { if (num_InterruptThrottleRate > bd) {
adapter->itr = InterruptThrottleRate[bd]; adapter->itr = InterruptThrottleRate[bd];
switch(adapter->itr) { switch(adapter->itr) {
case -1:
adapter->itr = 1;
break;
case 0: case 0:
DPRINTK(PROBE, INFO, "%s turned off\n", DPRINTK(PROBE, INFO, "%s turned off\n",
opt.name); opt.name);
...@@ -481,13 +478,14 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -481,13 +478,14 @@ e1000_check_options(struct e1000_adapter *adapter)
DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
opt.name); opt.name);
break; break;
case -1:
default: default:
e1000_validate_option(&adapter->itr, &opt, e1000_validate_option(&adapter->itr, &opt,
adapter); adapter);
break; break;
} }
} else { } else {
adapter->itr = 1; adapter->itr = opt.def;
} }
} }
......
This diff is collapsed.
...@@ -63,7 +63,6 @@ VERSION 1.6LK <2004/04/14> ...@@ -63,7 +63,6 @@ VERSION 1.6LK <2004/04/14>
#define RTL8169_VERSION "1.6LK" #define RTL8169_VERSION "1.6LK"
#define MODULENAME "r8169" #define MODULENAME "r8169"
#define RTL8169_DRIVER_NAME MODULENAME " Gigabit Ethernet driver " RTL8169_VERSION
#define PFX MODULENAME ": " #define PFX MODULENAME ": "
#ifdef RTL8169_DEBUG #ifdef RTL8169_DEBUG
...@@ -112,7 +111,8 @@ static int multicast_filter_limit = 32; ...@@ -112,7 +111,8 @@ static int multicast_filter_limit = 32;
#define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ #define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
#define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
#define EarlyTxThld 0x3F /* 0x3F means NO early transmit */ #define EarlyTxThld 0x3F /* 0x3F means NO early transmit */
#define RxPacketMaxSize 0x0800 /* Maximum size supported is 16K-1 */ #define RxPacketMaxSize 0x3FE8 /* 16K - 1 - ETH_HLEN - VLAN - CRC... */
#define SafeMtu 0x1c20 /* ... actually life sucks beyond ~7k */
#define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */ #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
#define R8169_REGS_SIZE 256 #define R8169_REGS_SIZE 256
...@@ -427,6 +427,9 @@ static void rtl8169_tx_timeout(struct net_device *dev); ...@@ -427,6 +427,9 @@ static void rtl8169_tx_timeout(struct net_device *dev);
static struct net_device_stats *rtl8169_get_stats(struct net_device *netdev); static struct net_device_stats *rtl8169_get_stats(struct net_device *netdev);
static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *,
void __iomem *); void __iomem *);
static int rtl8169_change_mtu(struct net_device *netdev, int new_mtu);
static void rtl8169_down(struct net_device *dev);
#ifdef CONFIG_R8169_NAPI #ifdef CONFIG_R8169_NAPI
static int rtl8169_poll(struct net_device *dev, int *budget); static int rtl8169_poll(struct net_device *dev, int *budget);
#endif #endif
...@@ -560,8 +563,8 @@ static void rtl8169_get_drvinfo(struct net_device *dev, ...@@ -560,8 +563,8 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
{ {
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
strcpy(info->driver, RTL8169_DRIVER_NAME); strcpy(info->driver, MODULENAME);
strcpy(info->version, RTL8169_VERSION ); strcpy(info->version, RTL8169_VERSION);
strcpy(info->bus_info, pci_name(tp->pci_dev)); strcpy(info->bus_info, pci_name(tp->pci_dev));
} }
...@@ -1238,8 +1241,6 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, ...@@ -1238,8 +1241,6 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
} }
tp->chipset = i; tp->chipset = i;
tp->rx_buf_sz = RX_BUF_SIZE;
*ioaddr_out = ioaddr; *ioaddr_out = ioaddr;
*dev_out = dev; *dev_out = dev;
out: out:
...@@ -1280,7 +1281,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1280,7 +1281,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
board_idx++; board_idx++;
if (!printed_version) { if (!printed_version) {
printk(KERN_INFO RTL8169_DRIVER_NAME " loaded\n"); printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
MODULENAME, RTL8169_VERSION);
printed_version = 1; printed_version = 1;
} }
...@@ -1321,6 +1323,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1321,6 +1323,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->watchdog_timeo = RTL8169_TX_TIMEOUT; dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
dev->irq = pdev->irq; dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr; dev->base_addr = (unsigned long) ioaddr;
dev->change_mtu = rtl8169_change_mtu;
#ifdef CONFIG_R8169_NAPI #ifdef CONFIG_R8169_NAPI
dev->poll = rtl8169_poll; dev->poll = rtl8169_poll;
...@@ -1449,13 +1452,22 @@ static int rtl8169_resume(struct pci_dev *pdev) ...@@ -1449,13 +1452,22 @@ static int rtl8169_resume(struct pci_dev *pdev)
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
static int static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
rtl8169_open(struct net_device *dev) struct net_device *dev)
{
unsigned int mtu = dev->mtu;
tp->rx_buf_sz = (mtu > RX_BUF_SIZE) ? mtu + ETH_HLEN + 8 : RX_BUF_SIZE;
}
static int rtl8169_open(struct net_device *dev)
{ {
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev; struct pci_dev *pdev = tp->pci_dev;
int retval; int retval;
rtl8169_set_rxbufsize(tp, dev);
retval = retval =
request_irq(dev->irq, rtl8169_interrupt, SA_SHIRQ, dev->name, dev); request_irq(dev->irq, rtl8169_interrupt, SA_SHIRQ, dev->name, dev);
if (retval < 0) if (retval < 0)
...@@ -1535,8 +1547,8 @@ rtl8169_hw_start(struct net_device *dev) ...@@ -1535,8 +1547,8 @@ rtl8169_hw_start(struct net_device *dev)
RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
RTL_W8(EarlyTxThres, EarlyTxThld); RTL_W8(EarlyTxThres, EarlyTxThld);
// For gigabit rtl8169 // For gigabit rtl8169, MTU + header + CRC + VLAN
RTL_W16(RxMaxSize, RxPacketMaxSize); RTL_W16(RxMaxSize, tp->rx_buf_sz);
// Set Rx Config register // Set Rx Config register
i = rtl8169_rx_config | i = rtl8169_rx_config |
...@@ -1577,6 +1589,37 @@ rtl8169_hw_start(struct net_device *dev) ...@@ -1577,6 +1589,37 @@ rtl8169_hw_start(struct net_device *dev)
netif_start_queue(dev); netif_start_queue(dev);
} }
static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
{
struct rtl8169_private *tp = netdev_priv(dev);
int ret = 0;
if (new_mtu < ETH_ZLEN || new_mtu > SafeMtu)
return -EINVAL;
dev->mtu = new_mtu;
if (!netif_running(dev))
goto out;
rtl8169_down(dev);
rtl8169_set_rxbufsize(tp, dev);
ret = rtl8169_init_ring(dev);
if (ret < 0)
goto out;
rtl8169_hw_start(dev);
netif_poll_enable(dev);
rtl8169_request_timer(dev);
out:
return ret;
}
static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc) static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc)
{ {
desc->addr = 0x0badbadbadbadbadull; desc->addr = 0x0badbadbadbadbadull;
...@@ -1743,10 +1786,19 @@ static void rtl8169_schedule_work(struct net_device *dev, void (*task)(void *)) ...@@ -1743,10 +1786,19 @@ static void rtl8169_schedule_work(struct net_device *dev, void (*task)(void *))
static void rtl8169_wait_for_quiescence(struct net_device *dev) static void rtl8169_wait_for_quiescence(struct net_device *dev)
{ {
struct rtl8169_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
synchronize_irq(dev->irq); synchronize_irq(dev->irq);
/* Wait for any pending NAPI task to complete */ /* Wait for any pending NAPI task to complete */
netif_poll_disable(dev); netif_poll_disable(dev);
RTL_W16(IntrMask, 0x0000);
RTL_W16(IntrStatus, 0xffff);
netif_poll_enable(dev);
} }
static void rtl8169_reinit_task(void *_data) static void rtl8169_reinit_task(void *_data)
...@@ -1970,7 +2022,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) ...@@ -1970,7 +2022,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_SIG_TARGET_ABORT)); PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_SIG_TARGET_ABORT));
/* The infamous DAC f*ckup only happens at boot time */ /* The infamous DAC f*ckup only happens at boot time */
if ((tp->cp_cmd & PCIDAC) && (tp->dirty_rx == tp->cur_rx == 0)) { if ((tp->cp_cmd & PCIDAC) && !tp->dirty_rx && !tp->cur_rx) {
printk(KERN_INFO PFX "%s: disabling PCI DAC.\n", dev->name); printk(KERN_INFO PFX "%s: disabling PCI DAC.\n", dev->name);
tp->cp_cmd &= ~PCIDAC; tp->cp_cmd &= ~PCIDAC;
RTL_W16(CPlusCmd, tp->cp_cmd); RTL_W16(CPlusCmd, tp->cp_cmd);
...@@ -2256,19 +2308,17 @@ static int rtl8169_poll(struct net_device *dev, int *budget) ...@@ -2256,19 +2308,17 @@ static int rtl8169_poll(struct net_device *dev, int *budget)
} }
#endif #endif
static int static void rtl8169_down(struct net_device *dev)
rtl8169_close(struct net_device *dev)
{ {
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
void __iomem *ioaddr = tp->mmio_addr; void __iomem *ioaddr = tp->mmio_addr;
rtl8169_delete_timer(dev);
netif_stop_queue(dev); netif_stop_queue(dev);
flush_scheduled_work(); flush_scheduled_work();
rtl8169_delete_timer(dev);
spin_lock_irq(&tp->lock); spin_lock_irq(&tp->lock);
/* Stop the chip's Tx and Rx DMA processes. */ /* Stop the chip's Tx and Rx DMA processes. */
...@@ -2283,13 +2333,27 @@ rtl8169_close(struct net_device *dev) ...@@ -2283,13 +2333,27 @@ rtl8169_close(struct net_device *dev)
spin_unlock_irq(&tp->lock); spin_unlock_irq(&tp->lock);
free_irq(dev->irq, dev); synchronize_irq(dev->irq);
netif_poll_disable(dev); netif_poll_disable(dev);
/* Give a racing hard_start_xmit a few cycles to complete. */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1);
rtl8169_tx_clear(tp); rtl8169_tx_clear(tp);
rtl8169_rx_clear(tp); rtl8169_rx_clear(tp);
}
static int rtl8169_close(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
rtl8169_down(dev);
free_irq(dev->irq, dev);
pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray, pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray,
tp->RxPhyAddr); tp->RxPhyAddr);
......
...@@ -61,7 +61,7 @@ typedef enum xena_max_outstanding_splits { ...@@ -61,7 +61,7 @@ typedef enum xena_max_outstanding_splits {
#define INTR_DBG 4 #define INTR_DBG 4
/* Global variable that defines the present debug level of the driver. */ /* Global variable that defines the present debug level of the driver. */
int debug_level = ERR_DBG; /* Default level. */ static int debug_level = ERR_DBG; /* Default level. */
/* DEBUG message print. */ /* DEBUG message print. */
#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) #define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args)
......
...@@ -81,6 +81,25 @@ int tulip_mdio_read(struct net_device *dev, int phy_id, int location) ...@@ -81,6 +81,25 @@ int tulip_mdio_read(struct net_device *dev, int phy_id, int location)
return retval & 0xffff; return retval & 0xffff;
} }
if(tp->chip_id == ULI526X && tp->revision >= 0x40) {
int value;
int i = 1000;
value = ioread32(ioaddr + CSR9);
iowrite32(value & 0xFFEFFFFF, ioaddr + CSR9);
value = (phy_id << 21) | (location << 16) | 0x80000000;
iowrite32(value, ioaddr + CSR10);
while(--i > 0) {
mdio_delay();
if(ioread32(ioaddr + CSR10) & 0x10000000)
break;
}
retval = ioread32(ioaddr + CSR10);
spin_unlock_irqrestore(&tp->mii_lock, flags);
return retval & 0xFFFF;
}
/* Establish sync by sending at least 32 logic ones. */ /* Establish sync by sending at least 32 logic ones. */
for (i = 32; i >= 0; i--) { for (i = 32; i >= 0; i--) {
iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr); iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
...@@ -140,6 +159,22 @@ void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val) ...@@ -140,6 +159,22 @@ void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val)
spin_unlock_irqrestore(&tp->mii_lock, flags); spin_unlock_irqrestore(&tp->mii_lock, flags);
return; return;
} }
if (tp->chip_id == ULI526X && tp->revision >= 0x40) {
int value;
int i = 1000;
value = ioread32(ioaddr + CSR9);
iowrite32(value & 0xFFEFFFFF, ioaddr + CSR9);
value = (phy_id << 21) | (location << 16) | 0x40000000 | (val & 0xFFFF);
iowrite32(value, ioaddr + CSR10);
while(--i > 0) {
if (ioread32(ioaddr + CSR10) & 0x10000000)
break;
}
spin_unlock_irqrestore(&tp->mii_lock, flags);
}
/* Establish sync by sending 32 logic ones. */ /* Establish sync by sending 32 logic ones. */
for (i = 32; i >= 0; i--) { for (i = 32; i >= 0; i--) {
......
...@@ -39,6 +39,7 @@ void tulip_timer(unsigned long data) ...@@ -39,6 +39,7 @@ void tulip_timer(unsigned long data)
case MX98713: case MX98713:
case COMPEX9881: case COMPEX9881:
case DM910X: case DM910X:
case ULI526X:
default: { default: {
struct medialeaf *mleaf; struct medialeaf *mleaf;
unsigned char *p; unsigned char *p;
......
...@@ -88,6 +88,7 @@ enum chips { ...@@ -88,6 +88,7 @@ enum chips {
I21145, I21145,
DM910X, DM910X,
CONEXANT, CONEXANT,
ULI526X
}; };
...@@ -481,8 +482,11 @@ static inline void tulip_stop_rxtx(struct tulip_private *tp) ...@@ -481,8 +482,11 @@ static inline void tulip_stop_rxtx(struct tulip_private *tp)
static inline void tulip_restart_rxtx(struct tulip_private *tp) static inline void tulip_restart_rxtx(struct tulip_private *tp)
{ {
if(!(tp->chip_id == ULI526X &&
(tp->revision == 0x40 || tp->revision == 0x50))) {
tulip_stop_rxtx(tp); tulip_stop_rxtx(tp);
udelay(5); udelay(5);
}
tulip_start_rxtx(tp); tulip_start_rxtx(tp);
} }
......
...@@ -88,9 +88,9 @@ static int rx_copybreak = 100; ...@@ -88,9 +88,9 @@ static int rx_copybreak = 100;
ToDo: Non-Intel setting could be better. ToDo: Non-Intel setting could be better.
*/ */
#if defined(__alpha__) || defined(__ia64__) || defined(__x86_64__) #if defined(__alpha__) || defined(__ia64__)
static int csr0 = 0x01A00000 | 0xE000; static int csr0 = 0x01A00000 | 0xE000;
#elif defined(__i386__) || defined(__powerpc__) #elif defined(__i386__) || defined(__powerpc__) || defined(__x86_64__)
static int csr0 = 0x01A00000 | 0x8000; static int csr0 = 0x01A00000 | 0x8000;
#elif defined(__sparc__) || defined(__hppa__) #elif defined(__sparc__) || defined(__hppa__)
/* The UltraSparc PCI controllers will disconnect at every 64-byte /* The UltraSparc PCI controllers will disconnect at every 64-byte
...@@ -198,6 +198,10 @@ struct tulip_chip_table tulip_tbl[] = { ...@@ -198,6 +198,10 @@ struct tulip_chip_table tulip_tbl[] = {
/* RS7112 */ /* RS7112 */
{ "Conexant LANfinity", 256, 0x0001ebef, { "Conexant LANfinity", 256, 0x0001ebef,
HAS_MII | HAS_ACPI, tulip_timer }, HAS_MII | HAS_ACPI, tulip_timer },
/* ULi526X */
{ "ULi M5261/M5263", 128, 0x0001ebef,
HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | HAS_ACPI, tulip_timer },
}; };
...@@ -229,12 +233,14 @@ static struct pci_device_id tulip_pci_tbl[] = { ...@@ -229,12 +233,14 @@ static struct pci_device_id tulip_pci_tbl[] = {
{ 0x1113, 0x9511, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1113, 0x9511, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x1186, 0x1541, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1186, 0x1541, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x1186, 0x1561, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1186, 0x1561, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x1186, 0x1591, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x14f1, 0x1803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CONEXANT }, { 0x14f1, 0x1803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CONEXANT },
{ 0x1626, 0x8410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1626, 0x8410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x1737, 0xAB09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1737, 0xAB09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x1737, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x1737, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x17B3, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, { 0x17B3, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
{ 0x10b9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DM910X }, /* ALi 1563 integrated ethernet */ { 0x10b9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */
{ 0x10b9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ULI526X }, /* ALi 1563 integrated ethernet */
{ 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */ { 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */
{ } /* terminate list */ { } /* terminate list */
}; };
...@@ -515,7 +521,7 @@ static void tulip_tx_timeout(struct net_device *dev) ...@@ -515,7 +521,7 @@ static void tulip_tx_timeout(struct net_device *dev)
dev->name); dev->name);
} else if (tp->chip_id == DC21140 || tp->chip_id == DC21142 } else if (tp->chip_id == DC21140 || tp->chip_id == DC21142
|| tp->chip_id == MX98713 || tp->chip_id == COMPEX9881 || tp->chip_id == MX98713 || tp->chip_id == COMPEX9881
|| tp->chip_id == DM910X) { || tp->chip_id == DM910X || tp->chip_id == ULI526X) {
printk(KERN_WARNING "%s: 21140 transmit timed out, status %8.8x, " printk(KERN_WARNING "%s: 21140 transmit timed out, status %8.8x, "
"SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n", "SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n",
dev->name, ioread32(ioaddr + CSR5), ioread32(ioaddr + CSR12), dev->name, ioread32(ioaddr + CSR5), ioread32(ioaddr + CSR12),
...@@ -1216,6 +1222,22 @@ static void __devinit tulip_mwi_config (struct pci_dev *pdev, ...@@ -1216,6 +1222,22 @@ static void __devinit tulip_mwi_config (struct pci_dev *pdev,
} }
#endif #endif
/*
* Chips that have the MRM/reserved bit quirk and the burst quirk. That
* is the DM910X and the on chip ULi devices
*/
static int tulip_uli_dm_quirk(struct pci_dev *pdev)
{
if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
return 1;
if (pdev->vendor == 0x10b9 && pdev->device == 0x5261)
return 1;
if (pdev->vendor == 0x10b9 && pdev->device == 0x5263)
return 1;
return 0;
}
static int __devinit tulip_init_one (struct pci_dev *pdev, static int __devinit tulip_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
...@@ -1304,17 +1326,12 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, ...@@ -1304,17 +1326,12 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
csr0 &= ~0xfff10000; /* zero reserved bits 31:20, 16 */ csr0 &= ~0xfff10000; /* zero reserved bits 31:20, 16 */
/* DM9102A has troubles with MRM & clear reserved bits 24:22, 20, 16, 7:1 */ /* DM9102A has troubles with MRM & clear reserved bits 24:22, 20, 16, 7:1 */
if ((pdev->vendor == 0x1282 && pdev->device == 0x9102) if (tulip_uli_dm_quirk(pdev)) {
|| (pdev->vendor == 0x10b9 && pdev->device == 0x5261))
csr0 &= ~0x01f100ff; csr0 &= ~0x01f100ff;
#if defined(__sparc__) #if defined(__sparc__)
/* DM9102A needs 32-dword alignment/burst length on sparc - chip bug? */
if ((pdev->vendor == 0x1282 && pdev->device == 0x9102)
|| (pdev->vendor == 0x10b9 && pdev->device == 0x5261))
csr0 = (csr0 & ~0xff00) | 0xe000; csr0 = (csr0 & ~0xff00) | 0xe000;
#endif #endif
}
/* /*
* And back to business * And back to business
*/ */
...@@ -1659,6 +1676,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, ...@@ -1659,6 +1676,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
switch (chip_idx) { switch (chip_idx) {
case DC21140: case DC21140:
case DM910X: case DM910X:
case ULI526X:
default: default:
if (tp->mtable) if (tp->mtable)
iowrite32(tp->mtable->csr12dir | 0x100, ioaddr + CSR12); iowrite32(tp->mtable->csr12dir | 0x100, ioaddr + CSR12);
......
...@@ -33,6 +33,13 @@ ...@@ -33,6 +33,13 @@
/* A few user-configurable values. */ /* A few user-configurable values. */
#define xircom_debug debug
#ifdef XIRCOM_DEBUG
static int xircom_debug = XIRCOM_DEBUG;
#else
static int xircom_debug = 1;
#endif
/* Maximum events (Rx packets, etc.) to handle at each interrupt. */ /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
static int max_interrupt_work = 25; static int max_interrupt_work = 25;
...@@ -124,19 +131,11 @@ module_param(max_interrupt_work, int, 0); ...@@ -124,19 +131,11 @@ module_param(max_interrupt_work, int, 0);
module_param(rx_copybreak, int, 0); module_param(rx_copybreak, int, 0);
module_param(csr0, int, 0); module_param(csr0, int, 0);
static int num_units; module_param_array(options, int, NULL, 0);
module_param_array(options, num_units, int, 0); module_param_array(full_duplex, int, NULL, 0);
module_param_array(full_duplex, num_units, int, 0);
#define RUN_AT(x) (jiffies + (x)) #define RUN_AT(x) (jiffies + (x))
#define xircom_debug debug
#ifdef XIRCOM_DEBUG
static int xircom_debug = XIRCOM_DEBUG;
#else
static int xircom_debug = 1;
#endif
/* /*
Theory of Operation Theory of Operation
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/if_tun.h> #include <linux/if_tun.h>
#include <linux/crc32.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -104,11 +105,42 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -104,11 +105,42 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
return 0; return 0;
} }
static void tun_net_mclist(struct net_device *dev) /** Add the specified Ethernet address to this multicast filter. */
static void
add_multi(u32* filter, const u8* addr)
{ {
/* Nothing to do for multicast filters. int bit_nr = ether_crc(ETH_ALEN, addr) >> 26;
* We always accept all frames. */ filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
return; }
/** Remove the specified Ethernet addres from this multicast filter. */
static void
del_multi(u32* filter, const u8* addr)
{
int bit_nr = ether_crc(ETH_ALEN, addr) >> 26;
filter[bit_nr >> 5] &= ~(1 << (bit_nr & 31));
}
/** Update the list of multicast groups to which the network device belongs.
* This list is used to filter packets being sent from the character device to
* the network device. */
static void
tun_net_mclist(struct net_device *dev)
{
struct tun_struct *tun = netdev_priv(dev);
const struct dev_mc_list *mclist;
int i;
DBG(KERN_DEBUG "%s: tun_net_mclist: mc_count %d\n",
dev->name, dev->mc_count);
memset(tun->chr_filter, 0, sizeof tun->chr_filter);
for (i = 0, mclist = dev->mc_list; i < dev->mc_count && mclist != NULL;
i++, mclist = mclist->next) {
add_multi(tun->net_filter, mclist->dmi_addr);
DBG(KERN_DEBUG "%s: tun_net_mclist: %x:%x:%x:%x:%x:%x\n",
dev->name,
mclist->dmi_addr[0], mclist->dmi_addr[1], mclist->dmi_addr[2],
mclist->dmi_addr[3], mclist->dmi_addr[4], mclist->dmi_addr[5]);
}
} }
static struct net_device_stats *tun_net_stats(struct net_device *dev) static struct net_device_stats *tun_net_stats(struct net_device *dev)
...@@ -301,6 +333,10 @@ static ssize_t tun_chr_readv(struct file *file, const struct iovec *iv, ...@@ -301,6 +333,10 @@ static ssize_t tun_chr_readv(struct file *file, const struct iovec *iv,
add_wait_queue(&tun->read_wait, &wait); add_wait_queue(&tun->read_wait, &wait);
while (len) { while (len) {
const u8 ones[ ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
u8 addr[ ETH_ALEN];
int bit_nr;
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
/* Read frames from the queue */ /* Read frames from the queue */
...@@ -320,10 +356,37 @@ static ssize_t tun_chr_readv(struct file *file, const struct iovec *iv, ...@@ -320,10 +356,37 @@ static ssize_t tun_chr_readv(struct file *file, const struct iovec *iv,
} }
netif_start_queue(tun->dev); netif_start_queue(tun->dev);
/** Decide whether to accept this packet. This code is designed to
* behave identically to an Ethernet interface. Accept the packet if
* - we are promiscuous.
* - the packet is addressed to us.
* - the packet is broadcast.
* - the packet is multicast and
* - we are multicast promiscous.
* - we belong to the multicast group.
*/
memcpy(addr, skb->data, min(sizeof addr, skb->len));
bit_nr = ether_crc(sizeof addr, addr) >> 26;
if ((tun->if_flags & IFF_PROMISC) ||
memcmp(addr, tun->dev_addr, sizeof addr) == 0 ||
memcmp(addr, ones, sizeof addr) == 0 ||
(((addr[0] == 1 && addr[1] == 0 && addr[2] == 0x5e) ||
(addr[0] == 0x33 && addr[1] == 0x33)) &&
((tun->if_flags & IFF_ALLMULTI) ||
(tun->chr_filter[bit_nr >> 5] & (1 << (bit_nr & 31)))))) {
DBG(KERN_DEBUG "%s: tun_chr_readv: accepted: %x:%x:%x:%x:%x:%x\n",
tun->dev->name, addr[0], addr[1], addr[2],
addr[3], addr[4], addr[5]);
ret = tun_put_user(tun, skb, (struct iovec *) iv, len); ret = tun_put_user(tun, skb, (struct iovec *) iv, len);
kfree_skb(skb); kfree_skb(skb);
break; break;
} else {
DBG(KERN_DEBUG "%s: tun_chr_readv: rejected: %x:%x:%x:%x:%x:%x\n",
tun->dev->name, addr[0], addr[1], addr[2],
addr[3], addr[4], addr[5]);
kfree_skb(skb);
continue;
}
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
...@@ -417,6 +480,12 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) ...@@ -417,6 +480,12 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
tun = netdev_priv(dev); tun = netdev_priv(dev);
tun->dev = dev; tun->dev = dev;
tun->flags = flags; tun->flags = flags;
/* Be promiscuous by default to maintain previous behaviour. */
tun->if_flags = IFF_PROMISC;
/* Generate random Ethernet address. */
*(u16 *)tun->dev_addr = htons(0x00FF);
get_random_bytes(tun->dev_addr + sizeof(u16), 4);
memset(tun->chr_filter, 0, sizeof tun->chr_filter);
tun_net_init(dev); tun_net_init(dev);
...@@ -457,13 +526,16 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, ...@@ -457,13 +526,16 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct tun_struct *tun = file->private_data; struct tun_struct *tun = file->private_data;
void __user* argp = (void __user*)arg;
struct ifreq ifr;
if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)
if (copy_from_user(&ifr, argp, sizeof ifr))
return -EFAULT;
if (cmd == TUNSETIFF && !tun) { if (cmd == TUNSETIFF && !tun) {
struct ifreq ifr;
int err; int err;
if (copy_from_user(&ifr, (void __user *)arg, sizeof(ifr)))
return -EFAULT;
ifr.ifr_name[IFNAMSIZ-1] = '\0'; ifr.ifr_name[IFNAMSIZ-1] = '\0';
rtnl_lock(); rtnl_lock();
...@@ -473,7 +545,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, ...@@ -473,7 +545,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
if (err) if (err)
return err; return err;
if (copy_to_user((void __user *)arg, &ifr, sizeof(ifr))) if (copy_to_user(argp, &ifr, sizeof(ifr)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -519,6 +591,61 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, ...@@ -519,6 +591,61 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
break; break;
#endif #endif
case SIOCGIFFLAGS:
ifr.ifr_flags = tun->if_flags;
if (copy_to_user( argp, &ifr, sizeof ifr))
return -EFAULT;
return 0;
case SIOCSIFFLAGS:
/** Set the character device's interface flags. Currently only
* IFF_PROMISC and IFF_ALLMULTI are used. */
tun->if_flags = ifr.ifr_flags;
DBG(KERN_INFO "%s: interface flags 0x%lx\n",
tun->dev->name, tun->if_flags);
return 0;
case SIOCGIFHWADDR:
memcpy(ifr.ifr_hwaddr.sa_data, tun->dev_addr,
min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr));
if (copy_to_user( argp, &ifr, sizeof ifr))
return -EFAULT;
return 0;
case SIOCSIFHWADDR:
/** Set the character device's hardware address. This is used when
* filtering packets being sent from the network device to the character
* device. */
memcpy(tun->dev_addr, ifr.ifr_hwaddr.sa_data,
min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr));
DBG(KERN_DEBUG "%s: set hardware address: %x:%x:%x:%x:%x:%x\n",
tun->dev->name,
tun->dev_addr[0], tun->dev_addr[1], tun->dev_addr[2],
tun->dev_addr[3], tun->dev_addr[4], tun->dev_addr[5]);
return 0;
case SIOCADDMULTI:
/** Add the specified group to the character device's multicast filter
* list. */
add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
DBG(KERN_DEBUG "%s: add multi: %x:%x:%x:%x:%x:%x\n",
tun->dev->name,
(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],
(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],
(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);
return 0;
case SIOCDELMULTI:
/** Remove the specified group from the character device's multicast
* filter list. */
del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
DBG(KERN_DEBUG "%s: del multi: %x:%x:%x:%x:%x:%x\n",
tun->dev->name,
(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],
(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],
(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);
return 0;
default: default:
return -EINVAL; return -EINVAL;
}; };
......
...@@ -859,7 +859,7 @@ static int __devinit rhine_init_one(struct pci_dev *pdev, ...@@ -859,7 +859,7 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
#ifdef USE_MMIO #ifdef USE_MMIO
memaddr memaddr
#else #else
ioaddr (long)ioaddr
#endif #endif
); );
......
...@@ -100,8 +100,8 @@ MODULE_LICENSE("GPL"); ...@@ -100,8 +100,8 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"); MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
#define VELOCITY_PARAM(N,D) \ #define VELOCITY_PARAM(N,D) \
static const int N[MAX_UNITS]=OPTION_DEFAULT;\ static int N[MAX_UNITS]=OPTION_DEFAULT;\
MODULE_PARM(N, "1-" __MODULE_STRING(MAX_UNITS) "i");\ module_param_array(N, int, NULL, 0); \
MODULE_PARM_DESC(N, D); MODULE_PARM_DESC(N, D);
#define RX_DESC_MIN 64 #define RX_DESC_MIN 64
...@@ -229,7 +229,7 @@ VELOCITY_PARAM(wol_opts, "Wake On Lan options"); ...@@ -229,7 +229,7 @@ VELOCITY_PARAM(wol_opts, "Wake On Lan options");
VELOCITY_PARAM(int_works, "Number of packets per interrupt services"); VELOCITY_PARAM(int_works, "Number of packets per interrupt services");
static int rx_copybreak = 200; static int rx_copybreak = 200;
MODULE_PARM(rx_copybreak, "i"); module_param(rx_copybreak, int, 0644);
MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info); static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info);
......
...@@ -45,6 +45,11 @@ struct tun_struct { ...@@ -45,6 +45,11 @@ struct tun_struct {
struct fasync_struct *fasync; struct fasync_struct *fasync;
unsigned long if_flags;
u8 dev_addr[ETH_ALEN];
u32 chr_filter[2];
u32 net_filter[2];
#ifdef TUN_DEBUG #ifdef TUN_DEBUG
int debug; int debug;
#endif #endif
......
...@@ -2397,6 +2397,9 @@ ...@@ -2397,6 +2397,9 @@
#define PCI_DEVICE_ID_TIGERJET_300 0x0001 #define PCI_DEVICE_ID_TIGERJET_300 0x0001
#define PCI_DEVICE_ID_TIGERJET_100 0x0002 #define PCI_DEVICE_ID_TIGERJET_100 0x0002
#define PCI_VENDOR_ID_TTTECH 0x0357
#define PCI_DEVICE_ID_TTTECH_MC322 0x000A
#define PCI_VENDOR_ID_ARK 0xedd8 #define PCI_VENDOR_ID_ARK 0xedd8
#define PCI_DEVICE_ID_ARK_STING 0xa091 #define PCI_DEVICE_ID_ARK_STING 0xa091
#define PCI_DEVICE_ID_ARK_STINGARK 0xa099 #define PCI_DEVICE_ID_ARK_STINGARK 0xa099
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment