Skip to content

Commit

Permalink
e1000: convert to build_skb
Browse files Browse the repository at this point in the history
Instead of preallocating Rx skbs, allocate them right before sending
inbound packet up the stack.

e1000-kvm, mtu1500, netperf TCP_STREAM:
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec
old: 87380  16384  16384    60.00    4532.40
new: 87380  16384  16384    60.00    4599.05

Signed-off-by: Florian Westphal <fw@strlen.de>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
Florian Westphal authored and Jeff Kirsher committed Sep 12, 2014
1 parent 580f321 commit 1380960
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 120 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/intel/e1000/e1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ struct e1000_tx_buffer {
};

struct e1000_rx_buffer {
struct sk_buff *skb;
union {
struct page *page; /* jumbo: alloc_page */
u8 *data; /* else, netdev_alloc_frag */
} rxbuf;
dma_addr_t dma;
struct page *page;
};

struct e1000_tx_ring {
Expand Down
29 changes: 15 additions & 14 deletions drivers/net/ethernet/intel/e1000/e1000_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
rxdr->buffer_info[i].dma,
E1000_RXBUFFER_2048,
DMA_FROM_DEVICE);
if (rxdr->buffer_info[i].skb)
dev_kfree_skb(rxdr->buffer_info[i].skb);
kfree(rxdr->buffer_info[i].rxbuf.data);
}
}

Expand Down Expand Up @@ -1095,24 +1094,25 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)

for (i = 0; i < rxdr->count; i++) {
struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
struct sk_buff *skb;
u8 *buf;

skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, GFP_KERNEL);
if (!skb) {
buf = kzalloc(E1000_RXBUFFER_2048 + NET_SKB_PAD + NET_IP_ALIGN,
GFP_KERNEL);
if (!buf) {
ret_val = 7;
goto err_nomem;
}
skb_reserve(skb, NET_IP_ALIGN);
rxdr->buffer_info[i].skb = skb;
rxdr->buffer_info[i].rxbuf.data = buf;

rxdr->buffer_info[i].dma =
dma_map_single(&pdev->dev, skb->data,
dma_map_single(&pdev->dev,
buf + NET_SKB_PAD + NET_IP_ALIGN,
E1000_RXBUFFER_2048, DMA_FROM_DEVICE);
if (dma_mapping_error(&pdev->dev, rxdr->buffer_info[i].dma)) {
ret_val = 8;
goto err_nomem;
}
rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
memset(skb->data, 0x00, skb->len);
}

return 0;
Expand Down Expand Up @@ -1385,13 +1385,13 @@ static void e1000_create_lbtest_frame(struct sk_buff *skb,
memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
}

static int e1000_check_lbtest_frame(struct sk_buff *skb,
static int e1000_check_lbtest_frame(const unsigned char *data,
unsigned int frame_size)
{
frame_size &= ~1;
if (skb->data[3] == 0xFF) {
if (skb->data[frame_size / 2 + 10] == 0xBE &&
skb->data[frame_size / 2 + 12] == 0xAF) {
if (*(data + 3) == 0xFF) {
if ((*(data + frame_size / 2 + 10) == 0xBE) &&
(*(data + frame_size / 2 + 12) == 0xAF)) {
return 0;
}
}
Expand Down Expand Up @@ -1443,7 +1443,8 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
DMA_FROM_DEVICE);

ret_val = e1000_check_lbtest_frame(
rxdr->buffer_info[l].skb,
rxdr->buffer_info[l].rxbuf.data +
NET_SKB_PAD + NET_IP_ALIGN,
1024);
if (!ret_val)
good_cnt++;
Expand Down
Loading

0 comments on commit 1380960

Please sign in to comment.