r8169: init rx ring cleanup
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3eafe50708
commit
0ecbe1cadd
|
@ -3974,12 +3974,12 @@ static inline void *rtl8169_align(void *data)
|
||||||
return (void *)ALIGN((long)data, 16);
|
return (void *)ALIGN((long)data, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sk_buff *rtl8169_alloc_rx_data(struct pci_dev *pdev,
|
static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
|
||||||
struct net_device *dev,
|
struct RxDesc *desc)
|
||||||
struct RxDesc *desc)
|
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
dma_addr_t mapping;
|
dma_addr_t mapping;
|
||||||
|
struct net_device *dev = tp->dev;
|
||||||
int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
|
int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
|
||||||
|
|
||||||
data = kmalloc_node(rx_buf_sz, GFP_KERNEL, node);
|
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,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapping = dma_map_single(&pdev->dev, rtl8169_align(data), rx_buf_sz,
|
mapping = dma_map_single(&tp->pci_dev->dev, rtl8169_align(data), rx_buf_sz,
|
||||||
PCI_DMA_FROMDEVICE);
|
PCI_DMA_FROMDEVICE);
|
||||||
if (unlikely(dma_mapping_error(&pdev->dev, mapping)))
|
if (unlikely(dma_mapping_error(&tp->pci_dev->dev, mapping)))
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
rtl8169_map_to_asic(desc, mapping, rx_buf_sz);
|
rtl8169_map_to_asic(desc, mapping, rx_buf_sz);
|
||||||
|
@ -4018,34 +4018,35 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev,
|
static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc)
|
||||||
u32 start, u32 end, gfp_t gfp)
|
|
||||||
{
|
{
|
||||||
u32 cur;
|
desc->opts1 |= cpu_to_le32(RingEnd);
|
||||||
|
}
|
||||||
|
|
||||||
for (cur = start; end - cur != 0; cur++) {
|
static int rtl8169_rx_fill(struct rtl8169_private *tp)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_RX_DESC; i++) {
|
||||||
void *data;
|
void *data;
|
||||||
unsigned int i = cur % NUM_RX_DESC;
|
|
||||||
|
|
||||||
WARN_ON((s32)(end - cur) < 0);
|
|
||||||
|
|
||||||
if (tp->Rx_databuff[i])
|
if (tp->Rx_databuff[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
data = rtl8169_alloc_rx_data(tp->pci_dev, dev,
|
data = rtl8169_alloc_rx_data(tp, tp->RxDescArray + i);
|
||||||
tp->RxDescArray + i);
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
rtl8169_make_unusable_by_asic(tp->RxDescArray + i);
|
rtl8169_make_unusable_by_asic(tp->RxDescArray + i);
|
||||||
break;
|
goto err_out;
|
||||||
}
|
}
|
||||||
tp->Rx_databuff[i] = data;
|
tp->Rx_databuff[i] = data;
|
||||||
}
|
}
|
||||||
return cur - start;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc)
|
rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
|
||||||
{
|
return 0;
|
||||||
desc->opts1 |= cpu_to_le32(RingEnd);
|
|
||||||
|
err_out:
|
||||||
|
rtl8169_rx_clear(tp);
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
|
static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
|
||||||
|
@ -4062,16 +4063,7 @@ static int rtl8169_init_ring(struct net_device *dev)
|
||||||
memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info));
|
memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info));
|
||||||
memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *));
|
memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *));
|
||||||
|
|
||||||
if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC)
|
return rtl8169_rx_fill(tp);
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_out:
|
|
||||||
rtl8169_rx_clear(tp);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb,
|
static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb,
|
||||||
|
|
Loading…
Reference in New Issue