Commit 93f0afe9 authored by Florian Westphal's avatar Florian Westphal Committed by Jeff Kirsher

e1000: add and use e1000_rx_buffer info for Rx

e1000 uses the same metadata struct for Rx and Tx.  But Tx and Rx have
different requirements.

For Rx, we only need to store a buffer and a DMA address.

Follow-up patch will remove skb for Rx, bringing rx_buffer_info down
to 16 bytes on x86_64.

[ buffer_info is 48 bytes ]
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 2b294b18
...@@ -160,6 +160,12 @@ struct e1000_buffer { ...@@ -160,6 +160,12 @@ struct e1000_buffer {
u16 mapped_as_page; u16 mapped_as_page;
}; };
struct e1000_rx_buffer {
struct sk_buff *skb;
dma_addr_t dma;
struct page *page;
};
struct e1000_tx_ring { struct e1000_tx_ring {
/* pointer to the descriptor ring memory */ /* pointer to the descriptor ring memory */
void *desc; void *desc;
...@@ -195,7 +201,7 @@ struct e1000_rx_ring { ...@@ -195,7 +201,7 @@ struct e1000_rx_ring {
/* next descriptor to check for DD status bit */ /* next descriptor to check for DD status bit */
unsigned int next_to_clean; unsigned int next_to_clean;
/* array of buffer information structs */ /* array of buffer information structs */
struct e1000_buffer *buffer_info; struct e1000_rx_buffer *buffer_info;
struct sk_buff *rx_skb_top; struct sk_buff *rx_skb_top;
/* cpu for rx queue */ /* cpu for rx queue */
......
...@@ -968,7 +968,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter) ...@@ -968,7 +968,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
if (rxdr->buffer_info[i].dma) if (rxdr->buffer_info[i].dma)
dma_unmap_single(&pdev->dev, dma_unmap_single(&pdev->dev,
rxdr->buffer_info[i].dma, rxdr->buffer_info[i].dma,
rxdr->buffer_info[i].length, E1000_RXBUFFER_2048,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (rxdr->buffer_info[i].skb) if (rxdr->buffer_info[i].skb)
dev_kfree_skb(rxdr->buffer_info[i].skb); dev_kfree_skb(rxdr->buffer_info[i].skb);
...@@ -1065,7 +1065,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) ...@@ -1065,7 +1065,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
if (!rxdr->count) if (!rxdr->count)
rxdr->count = E1000_DEFAULT_RXD; rxdr->count = E1000_DEFAULT_RXD;
rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_buffer), rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_rx_buffer),
GFP_KERNEL); GFP_KERNEL);
if (!rxdr->buffer_info) { if (!rxdr->buffer_info) {
ret_val = 5; ret_val = 5;
...@@ -1104,7 +1104,6 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) ...@@ -1104,7 +1104,6 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
} }
skb_reserve(skb, NET_IP_ALIGN); skb_reserve(skb, NET_IP_ALIGN);
rxdr->buffer_info[i].skb = skb; rxdr->buffer_info[i].skb = skb;
rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
rxdr->buffer_info[i].dma = rxdr->buffer_info[i].dma =
dma_map_single(&pdev->dev, skb->data, dma_map_single(&pdev->dev, skb->data,
E1000_RXBUFFER_2048, DMA_FROM_DEVICE); E1000_RXBUFFER_2048, DMA_FROM_DEVICE);
...@@ -1440,7 +1439,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter) ...@@ -1440,7 +1439,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
do { /* receive the sent packets */ do { /* receive the sent packets */
dma_sync_single_for_cpu(&pdev->dev, dma_sync_single_for_cpu(&pdev->dev,
rxdr->buffer_info[l].dma, rxdr->buffer_info[l].dma,
rxdr->buffer_info[l].length, E1000_RXBUFFER_2048,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
ret_val = e1000_check_lbtest_frame( ret_val = e1000_check_lbtest_frame(
......
...@@ -1687,7 +1687,7 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter, ...@@ -1687,7 +1687,7 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
int size, desc_len; int size, desc_len;
size = sizeof(struct e1000_buffer) * rxdr->count; size = sizeof(struct e1000_rx_buffer) * rxdr->count;
rxdr->buffer_info = vzalloc(size); rxdr->buffer_info = vzalloc(size);
if (!rxdr->buffer_info) if (!rxdr->buffer_info)
return -ENOMEM; return -ENOMEM;
...@@ -2062,7 +2062,7 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, ...@@ -2062,7 +2062,7 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
struct e1000_rx_ring *rx_ring) struct e1000_rx_ring *rx_ring)
{ {
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
struct e1000_buffer *buffer_info; struct e1000_rx_buffer *buffer_info;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
unsigned long size; unsigned long size;
unsigned int i; unsigned int i;
...@@ -2073,12 +2073,12 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, ...@@ -2073,12 +2073,12 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
if (buffer_info->dma && if (buffer_info->dma &&
adapter->clean_rx == e1000_clean_rx_irq) { adapter->clean_rx == e1000_clean_rx_irq) {
dma_unmap_single(&pdev->dev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
buffer_info->length, adapter->rx_buffer_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
} else if (buffer_info->dma && } else if (buffer_info->dma &&
adapter->clean_rx == e1000_clean_jumbo_rx_irq) { adapter->clean_rx == e1000_clean_jumbo_rx_irq) {
dma_unmap_page(&pdev->dev, buffer_info->dma, dma_unmap_page(&pdev->dev, buffer_info->dma,
buffer_info->length, adapter->rx_buffer_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
} }
...@@ -2099,7 +2099,7 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, ...@@ -2099,7 +2099,7 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
rx_ring->rx_skb_top = NULL; rx_ring->rx_skb_top = NULL;
} }
size = sizeof(struct e1000_buffer) * rx_ring->count; size = sizeof(struct e1000_rx_buffer) * rx_ring->count;
memset(rx_ring->buffer_info, 0, size); memset(rx_ring->buffer_info, 0, size);
/* Zero out the descriptor ring */ /* Zero out the descriptor ring */
...@@ -3415,7 +3415,7 @@ static void e1000_dump(struct e1000_adapter *adapter) ...@@ -3415,7 +3415,7 @@ static void e1000_dump(struct e1000_adapter *adapter)
for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) { for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i); struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i);
struct e1000_buffer *buffer_info = &rx_ring->buffer_info[i]; struct e1000_rx_buffer *buffer_info = &rx_ring->buffer_info[i];
struct my_u { __le64 a; __le64 b; }; struct my_u { __le64 a; __le64 b; };
struct my_u *u = (struct my_u *)rx_desc; struct my_u *u = (struct my_u *)rx_desc;
const char *type; const char *type;
...@@ -3951,7 +3951,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, ...@@ -3951,7 +3951,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
/** /**
* e1000_consume_page - helper function * e1000_consume_page - helper function
**/ **/
static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, static void e1000_consume_page(struct e1000_rx_buffer *bi, struct sk_buff *skb,
u16 length) u16 length)
{ {
bi->page = NULL; bi->page = NULL;
...@@ -4104,7 +4104,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, ...@@ -4104,7 +4104,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct e1000_rx_desc *rx_desc, *next_rxd; struct e1000_rx_desc *rx_desc, *next_rxd;
struct e1000_buffer *buffer_info, *next_buffer; struct e1000_rx_buffer *buffer_info, *next_buffer;
u32 length; u32 length;
unsigned int i; unsigned int i;
int cleaned_count = 0; int cleaned_count = 0;
...@@ -4137,7 +4137,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, ...@@ -4137,7 +4137,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
cleaned = true; cleaned = true;
cleaned_count++; cleaned_count++;
dma_unmap_page(&pdev->dev, buffer_info->dma, dma_unmap_page(&pdev->dev, buffer_info->dma,
buffer_info->length, DMA_FROM_DEVICE); adapter->rx_buffer_len, DMA_FROM_DEVICE);
buffer_info->dma = 0; buffer_info->dma = 0;
length = le16_to_cpu(rx_desc->length); length = le16_to_cpu(rx_desc->length);
...@@ -4273,7 +4273,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, ...@@ -4273,7 +4273,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
* of reassembly being done in the stack * of reassembly being done in the stack
*/ */
static struct sk_buff *e1000_copybreak(struct e1000_adapter *adapter, static struct sk_buff *e1000_copybreak(struct e1000_adapter *adapter,
struct e1000_buffer *buffer_info, struct e1000_rx_buffer *buffer_info,
u32 length, const void *data) u32 length, const void *data)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -4307,7 +4307,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, ...@@ -4307,7 +4307,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct e1000_rx_desc *rx_desc, *next_rxd; struct e1000_rx_desc *rx_desc, *next_rxd;
struct e1000_buffer *buffer_info, *next_buffer; struct e1000_rx_buffer *buffer_info, *next_buffer;
u32 length; u32 length;
unsigned int i; unsigned int i;
int cleaned_count = 0; int cleaned_count = 0;
...@@ -4337,7 +4337,8 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, ...@@ -4337,7 +4337,8 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
skb = buffer_info->skb; skb = buffer_info->skb;
buffer_info->skb = NULL; buffer_info->skb = NULL;
dma_unmap_single(&pdev->dev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
buffer_info->length, DMA_FROM_DEVICE); adapter->rx_buffer_len,
DMA_FROM_DEVICE);
buffer_info->dma = 0; buffer_info->dma = 0;
} }
...@@ -4443,7 +4444,7 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, ...@@ -4443,7 +4444,7 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct e1000_rx_desc *rx_desc; struct e1000_rx_desc *rx_desc;
struct e1000_buffer *buffer_info; struct e1000_rx_buffer *buffer_info;
struct sk_buff *skb; struct sk_buff *skb;
unsigned int i; unsigned int i;
unsigned int bufsz = 256 - 16 /*for skb_reserve */ ; unsigned int bufsz = 256 - 16 /*for skb_reserve */ ;
...@@ -4466,7 +4467,6 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, ...@@ -4466,7 +4467,6 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
} }
buffer_info->skb = skb; buffer_info->skb = skb;
buffer_info->length = adapter->rx_buffer_len;
check_page: check_page:
/* allocate a new page if necessary */ /* allocate a new page if necessary */
if (!buffer_info->page) { if (!buffer_info->page) {
...@@ -4480,7 +4480,7 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, ...@@ -4480,7 +4480,7 @@ e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
if (!buffer_info->dma) { if (!buffer_info->dma) {
buffer_info->dma = dma_map_page(&pdev->dev, buffer_info->dma = dma_map_page(&pdev->dev,
buffer_info->page, 0, buffer_info->page, 0,
buffer_info->length, PAGE_SIZE,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
put_page(buffer_info->page); put_page(buffer_info->page);
...@@ -4528,7 +4528,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, ...@@ -4528,7 +4528,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct e1000_rx_desc *rx_desc; struct e1000_rx_desc *rx_desc;
struct e1000_buffer *buffer_info; struct e1000_rx_buffer *buffer_info;
struct sk_buff *skb; struct sk_buff *skb;
unsigned int i; unsigned int i;
unsigned int bufsz = adapter->rx_buffer_len; unsigned int bufsz = adapter->rx_buffer_len;
...@@ -4576,10 +4576,9 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, ...@@ -4576,10 +4576,9 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
dev_kfree_skb(oldskb); dev_kfree_skb(oldskb);
} }
buffer_info->skb = skb; buffer_info->skb = skb;
buffer_info->length = adapter->rx_buffer_len;
buffer_info->dma = dma_map_single(&pdev->dev, buffer_info->dma = dma_map_single(&pdev->dev,
skb->data, skb->data,
buffer_info->length, adapter->rx_buffer_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment