diff options
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 108 |
1 files changed, 68 insertions, 40 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 9d3ebf3e975e..dd8106ff35aa 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"); |
@@ -1038,14 +1042,14 @@ static void rtl8169_vlan_rx_register(struct net_device *dev, | |||
1038 | } | 1042 | } |
1039 | 1043 | ||
1040 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | 1044 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, |
1041 | struct sk_buff *skb) | 1045 | struct sk_buff *skb, int polling) |
1042 | { | 1046 | { |
1043 | u32 opts2 = le32_to_cpu(desc->opts2); | 1047 | u32 opts2 = le32_to_cpu(desc->opts2); |
1044 | struct vlan_group *vlgrp = tp->vlgrp; | 1048 | struct vlan_group *vlgrp = tp->vlgrp; |
1045 | int ret; | 1049 | int ret; |
1046 | 1050 | ||
1047 | if (vlgrp && (opts2 & RxVlanTag)) { | 1051 | if (vlgrp && (opts2 & RxVlanTag)) { |
1048 | vlan_hwaccel_receive_skb(skb, vlgrp, swab16(opts2 & 0xffff)); | 1052 | __vlan_hwaccel_rx(skb, vlgrp, swab16(opts2 & 0xffff), polling); |
1049 | ret = 0; | 1053 | ret = 0; |
1050 | } else | 1054 | } else |
1051 | ret = -1; | 1055 | ret = -1; |
@@ -1062,7 +1066,7 @@ static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, | |||
1062 | } | 1066 | } |
1063 | 1067 | ||
1064 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | 1068 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, |
1065 | struct sk_buff *skb) | 1069 | struct sk_buff *skb, int polling) |
1066 | { | 1070 | { |
1067 | return -1; | 1071 | return -1; |
1068 | } | 1072 | } |
@@ -2755,6 +2759,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, | |||
2755 | { | 2759 | { |
2756 | iounmap(ioaddr); | 2760 | iounmap(ioaddr); |
2757 | pci_release_regions(pdev); | 2761 | pci_release_regions(pdev); |
2762 | pci_clear_mwi(pdev); | ||
2758 | pci_disable_device(pdev); | 2763 | pci_disable_device(pdev); |
2759 | free_netdev(dev); | 2764 | free_netdev(dev); |
2760 | } | 2765 | } |
@@ -2821,8 +2826,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) | |||
2821 | spin_lock_irq(&tp->lock); | 2826 | spin_lock_irq(&tp->lock); |
2822 | 2827 | ||
2823 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 2828 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
2824 | RTL_W32(MAC0, low); | 2829 | |
2825 | RTL_W32(MAC4, high); | 2830 | RTL_W32(MAC4, high); |
2831 | RTL_R32(MAC4); | ||
2832 | |||
2833 | RTL_W32(MAC0, low); | ||
2834 | RTL_R32(MAC0); | ||
2835 | |||
2826 | RTL_W8(Cfg9346, Cfg9346_Lock); | 2836 | RTL_W8(Cfg9346, Cfg9346_Lock); |
2827 | 2837 | ||
2828 | spin_unlock_irq(&tp->lock); | 2838 | spin_unlock_irq(&tp->lock); |
@@ -2974,7 +2984,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2974 | void __iomem *ioaddr; | 2984 | void __iomem *ioaddr; |
2975 | unsigned int i; | 2985 | unsigned int i; |
2976 | int rc; | 2986 | int rc; |
2977 | int this_use_dac = use_dac; | ||
2978 | 2987 | ||
2979 | if (netif_msg_drv(&debug)) { | 2988 | if (netif_msg_drv(&debug)) { |
2980 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", | 2989 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", |
@@ -3011,9 +3020,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3011 | goto err_out_free_dev_1; | 3020 | goto err_out_free_dev_1; |
3012 | } | 3021 | } |
3013 | 3022 | ||
3014 | rc = pci_set_mwi(pdev); | 3023 | if (pci_set_mwi(pdev) < 0) |
3015 | if (rc < 0) | 3024 | netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); |
3016 | goto err_out_disable_2; | ||
3017 | 3025 | ||
3018 | /* make sure PCI base addr 1 is MMIO */ | 3026 | /* make sure PCI base addr 1 is MMIO */ |
3019 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { | 3027 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { |
@@ -3021,7 +3029,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3021 | "region #%d not an MMIO resource, aborting\n", | 3029 | "region #%d not an MMIO resource, aborting\n", |
3022 | region); | 3030 | region); |
3023 | rc = -ENODEV; | 3031 | rc = -ENODEV; |
3024 | goto err_out_mwi_3; | 3032 | goto err_out_mwi_2; |
3025 | } | 3033 | } |
3026 | 3034 | ||
3027 | /* check for weird/broken PCI region reporting */ | 3035 | /* check for weird/broken PCI region reporting */ |
@@ -3029,35 +3037,26 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3029 | netif_err(tp, probe, dev, | 3037 | netif_err(tp, probe, dev, |
3030 | "Invalid PCI region size(s), aborting\n"); | 3038 | "Invalid PCI region size(s), aborting\n"); |
3031 | rc = -ENODEV; | 3039 | rc = -ENODEV; |
3032 | goto err_out_mwi_3; | 3040 | goto err_out_mwi_2; |
3033 | } | 3041 | } |
3034 | 3042 | ||
3035 | rc = pci_request_regions(pdev, MODULENAME); | 3043 | rc = pci_request_regions(pdev, MODULENAME); |
3036 | if (rc < 0) { | 3044 | if (rc < 0) { |
3037 | netif_err(tp, probe, dev, "could not request regions\n"); | 3045 | netif_err(tp, probe, dev, "could not request regions\n"); |
3038 | goto err_out_mwi_3; | 3046 | goto err_out_mwi_2; |
3039 | } | 3047 | } |
3040 | 3048 | ||
3041 | tp->cp_cmd = PCIMulRW | RxChkSum; | 3049 | tp->cp_cmd = PCIMulRW | RxChkSum; |
3042 | 3050 | ||
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) && | 3051 | if ((sizeof(dma_addr_t) > 4) && |
3051 | this_use_dac && | 3052 | !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; | 3053 | tp->cp_cmd |= PCIDAC; |
3055 | dev->features |= NETIF_F_HIGHDMA; | 3054 | dev->features |= NETIF_F_HIGHDMA; |
3056 | } else { | 3055 | } else { |
3057 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 3056 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
3058 | if (rc < 0) { | 3057 | if (rc < 0) { |
3059 | netif_err(tp, probe, dev, "DMA configuration failed\n"); | 3058 | netif_err(tp, probe, dev, "DMA configuration failed\n"); |
3060 | goto err_out_free_res_4; | 3059 | goto err_out_free_res_3; |
3061 | } | 3060 | } |
3062 | } | 3061 | } |
3063 | 3062 | ||
@@ -3066,9 +3065,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3066 | if (!ioaddr) { | 3065 | if (!ioaddr) { |
3067 | netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); | 3066 | netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); |
3068 | rc = -EIO; | 3067 | rc = -EIO; |
3069 | goto err_out_free_res_4; | 3068 | goto err_out_free_res_3; |
3070 | } | 3069 | } |
3071 | 3070 | ||
3071 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | ||
3072 | if (!tp->pcie_cap) | ||
3073 | netif_info(tp, probe, dev, "no PCI Express capability\n"); | ||
3074 | |||
3072 | RTL_W16(IntrMask, 0x0000); | 3075 | RTL_W16(IntrMask, 0x0000); |
3073 | 3076 | ||
3074 | /* Soft reset the chip. */ | 3077 | /* Soft reset the chip. */ |
@@ -3104,7 +3107,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3104 | if (i == ARRAY_SIZE(rtl_chip_info)) { | 3107 | if (i == ARRAY_SIZE(rtl_chip_info)) { |
3105 | dev_err(&pdev->dev, | 3108 | dev_err(&pdev->dev, |
3106 | "driver bug, MAC version not found in rtl_chip_info\n"); | 3109 | "driver bug, MAC version not found in rtl_chip_info\n"); |
3107 | goto err_out_msi_5; | 3110 | goto err_out_msi_4; |
3108 | } | 3111 | } |
3109 | tp->chipset = i; | 3112 | tp->chipset = i; |
3110 | 3113 | ||
@@ -3169,7 +3172,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3169 | 3172 | ||
3170 | rc = register_netdev(dev); | 3173 | rc = register_netdev(dev); |
3171 | if (rc < 0) | 3174 | if (rc < 0) |
3172 | goto err_out_msi_5; | 3175 | goto err_out_msi_4; |
3173 | 3176 | ||
3174 | pci_set_drvdata(pdev, dev); | 3177 | pci_set_drvdata(pdev, dev); |
3175 | 3178 | ||
@@ -3192,14 +3195,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3192 | out: | 3195 | out: |
3193 | return rc; | 3196 | return rc; |
3194 | 3197 | ||
3195 | err_out_msi_5: | 3198 | err_out_msi_4: |
3196 | rtl_disable_msi(pdev, tp); | 3199 | rtl_disable_msi(pdev, tp); |
3197 | iounmap(ioaddr); | 3200 | iounmap(ioaddr); |
3198 | err_out_free_res_4: | 3201 | err_out_free_res_3: |
3199 | pci_release_regions(pdev); | 3202 | pci_release_regions(pdev); |
3200 | err_out_mwi_3: | 3203 | err_out_mwi_2: |
3201 | pci_clear_mwi(pdev); | 3204 | pci_clear_mwi(pdev); |
3202 | err_out_disable_2: | ||
3203 | pci_disable_device(pdev); | 3205 | pci_disable_device(pdev); |
3204 | err_out_free_dev_1: | 3206 | err_out_free_dev_1: |
3205 | free_netdev(dev); | 3207 | free_netdev(dev); |
@@ -3224,9 +3226,13 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3224 | } | 3226 | } |
3225 | 3227 | ||
3226 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, | 3228 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, |
3227 | struct net_device *dev) | 3229 | unsigned int mtu) |
3228 | { | 3230 | { |
3229 | unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; | 3231 | unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; |
3232 | |||
3233 | if (max_frame != 16383) | ||
3234 | printk(KERN_WARNING PFX "WARNING! Changing of MTU on this " | ||
3235 | "NIC may lead to frame reception errors!\n"); | ||
3230 | 3236 | ||
3231 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; | 3237 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; |
3232 | } | 3238 | } |
@@ -3238,7 +3244,17 @@ static int rtl8169_open(struct net_device *dev) | |||
3238 | int retval = -ENOMEM; | 3244 | int retval = -ENOMEM; |
3239 | 3245 | ||
3240 | 3246 | ||
3241 | rtl8169_set_rxbufsize(tp, dev); | 3247 | /* |
3248 | * Note that we use a magic value here, its wierd I know | ||
3249 | * its done because, some subset of rtl8169 hardware suffers from | ||
3250 | * a problem in which frames received that are longer than | ||
3251 | * the size set in RxMaxSize register return garbage sizes | ||
3252 | * when received. To avoid this we need to turn off filtering, | ||
3253 | * which is done by setting a value of 16383 in the RxMaxSize register | ||
3254 | * and allocating 16k frames to handle the largest possible rx value | ||
3255 | * thats what the magic math below does. | ||
3256 | */ | ||
3257 | rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN); | ||
3242 | 3258 | ||
3243 | /* | 3259 | /* |
3244 | * Rx and Tx desscriptors needs 256 bytes alignment. | 3260 | * Rx and Tx desscriptors needs 256 bytes alignment. |
@@ -3891,7 +3907,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
3891 | 3907 | ||
3892 | rtl8169_down(dev); | 3908 | rtl8169_down(dev); |
3893 | 3909 | ||
3894 | rtl8169_set_rxbufsize(tp, dev); | 3910 | rtl8169_set_rxbufsize(tp, dev->mtu); |
3895 | 3911 | ||
3896 | ret = rtl8169_init_ring(dev); | 3912 | ret = rtl8169_init_ring(dev); |
3897 | if (ret < 0) | 3913 | if (ret < 0) |
@@ -4429,12 +4445,20 @@ out: | |||
4429 | return done; | 4445 | return done; |
4430 | } | 4446 | } |
4431 | 4447 | ||
4448 | /* | ||
4449 | * Warning : rtl8169_rx_interrupt() might be called : | ||
4450 | * 1) from NAPI (softirq) context | ||
4451 | * (polling = 1 : we should call netif_receive_skb()) | ||
4452 | * 2) from process context (rtl8169_reset_task()) | ||
4453 | * (polling = 0 : we must call netif_rx() instead) | ||
4454 | */ | ||
4432 | static int rtl8169_rx_interrupt(struct net_device *dev, | 4455 | static int rtl8169_rx_interrupt(struct net_device *dev, |
4433 | struct rtl8169_private *tp, | 4456 | struct rtl8169_private *tp, |
4434 | void __iomem *ioaddr, u32 budget) | 4457 | void __iomem *ioaddr, u32 budget) |
4435 | { | 4458 | { |
4436 | unsigned int cur_rx, rx_left; | 4459 | unsigned int cur_rx, rx_left; |
4437 | unsigned int delta, count; | 4460 | unsigned int delta, count; |
4461 | int polling = (budget != ~(u32)0) ? 1 : 0; | ||
4438 | 4462 | ||
4439 | cur_rx = tp->cur_rx; | 4463 | cur_rx = tp->cur_rx; |
4440 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; | 4464 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; |
@@ -4496,8 +4520,12 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4496 | skb_put(skb, pkt_size); | 4520 | skb_put(skb, pkt_size); |
4497 | skb->protocol = eth_type_trans(skb, dev); | 4521 | skb->protocol = eth_type_trans(skb, dev); |
4498 | 4522 | ||
4499 | if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) | 4523 | if (rtl8169_rx_vlan_skb(tp, desc, skb, polling) < 0) { |
4500 | netif_receive_skb(skb); | 4524 | if (likely(polling)) |
4525 | netif_receive_skb(skb); | ||
4526 | else | ||
4527 | netif_rx(skb); | ||
4528 | } | ||
4501 | 4529 | ||
4502 | dev->stats.rx_bytes += pkt_size; | 4530 | dev->stats.rx_bytes += pkt_size; |
4503 | dev->stats.rx_packets++; | 4531 | dev->stats.rx_packets++; |
@@ -4754,8 +4782,8 @@ static void rtl_set_rx_mode(struct net_device *dev) | |||
4754 | mc_filter[1] = swab32(data); | 4782 | mc_filter[1] = swab32(data); |
4755 | } | 4783 | } |
4756 | 4784 | ||
4757 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
4758 | RTL_W32(MAR0 + 4, mc_filter[1]); | 4785 | RTL_W32(MAR0 + 4, mc_filter[1]); |
4786 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
4759 | 4787 | ||
4760 | RTL_W32(RxConfig, tmp); | 4788 | RTL_W32(RxConfig, tmp); |
4761 | 4789 | ||