diff options
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 88d5826ce93d..20deeeaab5d9 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -3974,12 +3974,12 @@ static inline void *rtl8169_align(void *data) | |||
3974 | return (void *)ALIGN((long)data, 16); | 3974 | return (void *)ALIGN((long)data, 16); |
3975 | } | 3975 | } |
3976 | 3976 | ||
3977 | static struct sk_buff *rtl8169_alloc_rx_data(struct pci_dev *pdev, | 3977 | static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp, |
3978 | struct net_device *dev, | 3978 | struct RxDesc *desc) |
3979 | struct RxDesc *desc) | ||
3980 | { | 3979 | { |
3981 | void *data; | 3980 | void *data; |
3982 | dma_addr_t mapping; | 3981 | dma_addr_t mapping; |
3982 | struct net_device *dev = tp->dev; | ||
3983 | int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; | 3983 | int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; |
3984 | 3984 | ||
3985 | data = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); | 3985 | data = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); |
@@ -3993,9 +3993,9 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct pci_dev *pdev, | |||
3993 | return NULL; | 3993 | return NULL; |
3994 | } | 3994 | } |
3995 | 3995 | ||
3996 | mapping = dma_map_single(&pdev->dev, rtl8169_align(data), rx_buf_sz, | 3996 | mapping = dma_map_single(&tp->pci_dev->dev, rtl8169_align(data), rx_buf_sz, |
3997 | PCI_DMA_FROMDEVICE); | 3997 | PCI_DMA_FROMDEVICE); |
3998 | if (unlikely(dma_mapping_error(&pdev->dev, mapping))) | 3998 | if (unlikely(dma_mapping_error(&tp->pci_dev->dev, mapping))) |
3999 | goto err_out; | 3999 | goto err_out; |
4000 | 4000 | ||
4001 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); | 4001 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); |
@@ -4018,34 +4018,35 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp) | |||
4018 | } | 4018 | } |
4019 | } | 4019 | } |
4020 | 4020 | ||
4021 | static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, | 4021 | static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc) |
4022 | u32 start, u32 end, gfp_t gfp) | ||
4023 | { | 4022 | { |
4024 | u32 cur; | 4023 | desc->opts1 |= cpu_to_le32(RingEnd); |
4024 | } | ||
4025 | 4025 | ||
4026 | for (cur = start; end - cur != 0; cur++) { | 4026 | static int rtl8169_rx_fill(struct rtl8169_private *tp) |
4027 | void *data; | 4027 | { |
4028 | unsigned int i = cur % NUM_RX_DESC; | 4028 | unsigned int i; |
4029 | 4029 | ||
4030 | WARN_ON((s32)(end - cur) < 0); | 4030 | for (i = 0; i < NUM_RX_DESC; i++) { |
4031 | void *data; | ||
4031 | 4032 | ||
4032 | if (tp->Rx_databuff[i]) | 4033 | if (tp->Rx_databuff[i]) |
4033 | continue; | 4034 | continue; |
4034 | 4035 | ||
4035 | data = rtl8169_alloc_rx_data(tp->pci_dev, dev, | 4036 | data = rtl8169_alloc_rx_data(tp, tp->RxDescArray + i); |
4036 | tp->RxDescArray + i); | ||
4037 | if (!data) { | 4037 | if (!data) { |
4038 | rtl8169_make_unusable_by_asic(tp->RxDescArray + i); | 4038 | rtl8169_make_unusable_by_asic(tp->RxDescArray + i); |
4039 | break; | 4039 | goto err_out; |
4040 | } | 4040 | } |
4041 | tp->Rx_databuff[i] = data; | 4041 | tp->Rx_databuff[i] = data; |
4042 | } | 4042 | } |
4043 | return cur - start; | ||
4044 | } | ||
4045 | 4043 | ||
4046 | static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc) | 4044 | rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1); |
4047 | { | 4045 | return 0; |
4048 | desc->opts1 |= cpu_to_le32(RingEnd); | 4046 | |
4047 | err_out: | ||
4048 | rtl8169_rx_clear(tp); | ||
4049 | return -ENOMEM; | ||
4049 | } | 4050 | } |
4050 | 4051 | ||
4051 | static void rtl8169_init_ring_indexes(struct rtl8169_private *tp) | 4052 | static void rtl8169_init_ring_indexes(struct rtl8169_private *tp) |
@@ -4062,16 +4063,7 @@ static int rtl8169_init_ring(struct net_device *dev) | |||
4062 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); | 4063 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); |
4063 | memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *)); | 4064 | memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *)); |
4064 | 4065 | ||
4065 | if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC) | 4066 | return rtl8169_rx_fill(tp); |
4066 | goto err_out; | ||
4067 | |||
4068 | rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1); | ||
4069 | |||
4070 | return 0; | ||
4071 | |||
4072 | err_out: | ||
4073 | rtl8169_rx_clear(tp); | ||
4074 | return -ENOMEM; | ||
4075 | } | 4067 | } |
4076 | 4068 | ||
4077 | static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb, | 4069 | static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb, |