diff options
Diffstat (limited to 'drivers/net/r8169.c')
| -rw-r--r-- | drivers/net/r8169.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 9d3ebf3e975e..dbb1f5a1824c 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
| @@ -186,8 +186,13 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { | |||
| 186 | 186 | ||
| 187 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); | 187 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); |
| 188 | 188 | ||
| 189 | static int rx_copybreak = 200; | 189 | /* |
| 190 | static int use_dac = -1; | 190 | * we set our copybreak very high so that we don't have |
| 191 | * to allocate 16k frames all the time (see note in | ||
| 192 | * rtl8169_open() | ||
| 193 | */ | ||
| 194 | static int rx_copybreak = 16383; | ||
| 195 | static int use_dac; | ||
| 191 | static struct { | 196 | static struct { |
| 192 | u32 msg_enable; | 197 | u32 msg_enable; |
| 193 | } debug = { -1 }; | 198 | } debug = { -1 }; |
| @@ -511,8 +516,7 @@ MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); | |||
| 511 | module_param(rx_copybreak, int, 0); | 516 | module_param(rx_copybreak, int, 0); |
| 512 | MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); | 517 | MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); |
| 513 | module_param(use_dac, int, 0); | 518 | module_param(use_dac, int, 0); |
| 514 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. -1 defaults on for PCI Express only." | 519 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); |
| 515 | " Unsafe on 32 bit PCI slot."); | ||
| 516 | module_param_named(debug, debug.msg_enable, int, 0); | 520 | module_param_named(debug, debug.msg_enable, int, 0); |
| 517 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); | 521 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); |
| 518 | MODULE_LICENSE("GPL"); | 522 | MODULE_LICENSE("GPL"); |
| @@ -2821,8 +2825,8 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) | |||
| 2821 | spin_lock_irq(&tp->lock); | 2825 | spin_lock_irq(&tp->lock); |
| 2822 | 2826 | ||
| 2823 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 2827 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
| 2824 | RTL_W32(MAC0, low); | ||
| 2825 | RTL_W32(MAC4, high); | 2828 | RTL_W32(MAC4, high); |
| 2829 | RTL_W32(MAC0, low); | ||
| 2826 | RTL_W8(Cfg9346, Cfg9346_Lock); | 2830 | RTL_W8(Cfg9346, Cfg9346_Lock); |
| 2827 | 2831 | ||
| 2828 | spin_unlock_irq(&tp->lock); | 2832 | spin_unlock_irq(&tp->lock); |
| @@ -2974,7 +2978,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2974 | void __iomem *ioaddr; | 2978 | void __iomem *ioaddr; |
| 2975 | unsigned int i; | 2979 | unsigned int i; |
| 2976 | int rc; | 2980 | int rc; |
| 2977 | int this_use_dac = use_dac; | ||
| 2978 | 2981 | ||
| 2979 | if (netif_msg_drv(&debug)) { | 2982 | if (netif_msg_drv(&debug)) { |
| 2980 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", | 2983 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", |
| @@ -3040,17 +3043,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3040 | 3043 | ||
| 3041 | tp->cp_cmd = PCIMulRW | RxChkSum; | 3044 | tp->cp_cmd = PCIMulRW | RxChkSum; |
| 3042 | 3045 | ||
| 3043 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | ||
| 3044 | if (!tp->pcie_cap) | ||
| 3045 | netif_info(tp, probe, dev, "no PCI Express capability\n"); | ||
| 3046 | |||
| 3047 | if (this_use_dac < 0) | ||
| 3048 | this_use_dac = tp->pcie_cap != 0; | ||
| 3049 | |||
| 3050 | if ((sizeof(dma_addr_t) > 4) && | 3046 | if ((sizeof(dma_addr_t) > 4) && |
| 3051 | this_use_dac && | 3047 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { |
| 3052 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | ||
| 3053 | netif_info(tp, probe, dev, "using 64-bit DMA\n"); | ||
| 3054 | tp->cp_cmd |= PCIDAC; | 3048 | tp->cp_cmd |= PCIDAC; |
| 3055 | dev->features |= NETIF_F_HIGHDMA; | 3049 | dev->features |= NETIF_F_HIGHDMA; |
| 3056 | } else { | 3050 | } else { |
| @@ -3069,6 +3063,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3069 | goto err_out_free_res_4; | 3063 | goto err_out_free_res_4; |
| 3070 | } | 3064 | } |
| 3071 | 3065 | ||
| 3066 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | ||
| 3067 | if (!tp->pcie_cap) | ||
| 3068 | netif_info(tp, probe, dev, "no PCI Express capability\n"); | ||
| 3069 | |||
| 3072 | RTL_W16(IntrMask, 0x0000); | 3070 | RTL_W16(IntrMask, 0x0000); |
| 3073 | 3071 | ||
| 3074 | /* Soft reset the chip. */ | 3072 | /* Soft reset the chip. */ |
| @@ -3224,9 +3222,13 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
| 3224 | } | 3222 | } |
| 3225 | 3223 | ||
| 3226 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, | 3224 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, |
| 3227 | struct net_device *dev) | 3225 | unsigned int mtu) |
| 3228 | { | 3226 | { |
| 3229 | unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; | 3227 | unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; |
| 3228 | |||
| 3229 | if (max_frame != 16383) | ||
| 3230 | printk(KERN_WARNING PFX "WARNING! Changing of MTU on this " | ||
| 3231 | "NIC may lead to frame reception errors!\n"); | ||
| 3230 | 3232 | ||
| 3231 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; | 3233 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; |
| 3232 | } | 3234 | } |
| @@ -3238,7 +3240,17 @@ static int rtl8169_open(struct net_device *dev) | |||
| 3238 | int retval = -ENOMEM; | 3240 | int retval = -ENOMEM; |
| 3239 | 3241 | ||
| 3240 | 3242 | ||
| 3241 | rtl8169_set_rxbufsize(tp, dev); | 3243 | /* |
| 3244 | * Note that we use a magic value here, its wierd I know | ||
| 3245 | * its done because, some subset of rtl8169 hardware suffers from | ||
| 3246 | * a problem in which frames received that are longer than | ||
| 3247 | * the size set in RxMaxSize register return garbage sizes | ||
| 3248 | * when received. To avoid this we need to turn off filtering, | ||
| 3249 | * which is done by setting a value of 16383 in the RxMaxSize register | ||
| 3250 | * and allocating 16k frames to handle the largest possible rx value | ||
| 3251 | * thats what the magic math below does. | ||
| 3252 | */ | ||
| 3253 | rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN); | ||
| 3242 | 3254 | ||
| 3243 | /* | 3255 | /* |
| 3244 | * Rx and Tx desscriptors needs 256 bytes alignment. | 3256 | * Rx and Tx desscriptors needs 256 bytes alignment. |
| @@ -3891,7 +3903,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
| 3891 | 3903 | ||
| 3892 | rtl8169_down(dev); | 3904 | rtl8169_down(dev); |
| 3893 | 3905 | ||
| 3894 | rtl8169_set_rxbufsize(tp, dev); | 3906 | rtl8169_set_rxbufsize(tp, dev->mtu); |
| 3895 | 3907 | ||
| 3896 | ret = rtl8169_init_ring(dev); | 3908 | ret = rtl8169_init_ring(dev); |
| 3897 | if (ret < 0) | 3909 | if (ret < 0) |
| @@ -4754,8 +4766,8 @@ static void rtl_set_rx_mode(struct net_device *dev) | |||
| 4754 | mc_filter[1] = swab32(data); | 4766 | mc_filter[1] = swab32(data); |
| 4755 | } | 4767 | } |
| 4756 | 4768 | ||
| 4757 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
| 4758 | RTL_W32(MAR0 + 4, mc_filter[1]); | 4769 | RTL_W32(MAR0 + 4, mc_filter[1]); |
| 4770 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
| 4759 | 4771 | ||
| 4760 | RTL_W32(RxConfig, tmp); | 4772 | RTL_W32(RxConfig, tmp); |
| 4761 | 4773 | ||
