@@ -1963,20 +1963,7 @@ static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index)
index);
}
-static struct sk_buff *
-lan743x_alloc_skb(struct net_device *netdev, int length, bool can_fail)
-{
- static int rx_alloc;
- int counter = rx_alloc++ % 100;
-
- if (can_fail && counter >= 20 && counter < 30)
- return NULL;
-
- return __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA);
-}
-
-static int
-lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, bool can_fail)
+static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index)
{
struct net_device *netdev = rx->adapter->netdev;
struct device *dev = &rx->adapter->pdev->dev;
@@ -1990,7 +1977,7 @@ lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, bool can_fail)
descriptor = &rx->ring_cpu_ptr[index];
buffer_info = &rx->buffer_info[index];
- skb = lan743x_alloc_skb(netdev, buffer_length, can_fail);
+ skb = __netdev_alloc_skb(netdev, buffer_length, GFP_ATOMIC | GFP_DMA);
if (!skb)
return -ENOMEM;
dma_ptr = dma_map_single(dev, skb->data, buffer_length, DMA_FROM_DEVICE);
@@ -2075,6 +2062,13 @@ static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index)
static struct sk_buff *
lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length)
{
+ static int trim_cnt;
+
+ if ((trim_cnt++ % 100) == 77) {
+ dev_kfree_skb_irq(skb);
+ return NULL;
+ }
+
if (skb_linearize(skb)) {
dev_kfree_skb_irq(skb);
return NULL;
@@ -2150,7 +2144,7 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx)
/* save existing skb, allocate new skb and map to dma */
skb = buffer_info->skb;
- if (lan743x_rx_init_ring_element(rx, rx->last_head, true)) {
+ if (lan743x_rx_init_ring_element(rx, rx->last_head)) {
/* failed to allocate next skb.
* Memory is very low.
* Drop this packet and reuse buffer.
@@ -2355,7 +2349,7 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
rx->last_head = 0;
for (index = 0; index < rx->ring_size; index++) {
- ret = lan743x_rx_init_ring_element(rx, index, false);
+ ret = lan743x_rx_init_ring_element(rx, index);
if (ret)
goto cleanup;
}