diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2012-05-17 13:40:54 -0400 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-08-24 15:10:11 -0400 |
commit | f7251a9ce936f1006fbfdef63dbe42ae5e0fee7c (patch) | |
tree | e0187036af8587b61f4f492a31f3429b33dc0ffb /drivers/net/ethernet/sfc/net_driver.h | |
parent | 14bf718fb97efe9ff649c317e7d87a3617b13e7c (diff) |
sfc: Simplify TSO header buffer allocation
TSO header buffers contain a control structure immediately followed by
the packet headers, and are kept on a free list when not in use. This
complicates buffer management and tends to result in cache read misses
when we recycle such buffers (particularly if DMA-coherent memory
requires caches to be disabled).
Replace the free list with a simple mapping by descriptor index. We
know that there is always a payload descriptor between any two
descriptors with TSO header buffers, so we can allocate only one
such buffer for each two descriptors.
While we're at it, use a standard error code for allocation failure,
not -1.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc/net_driver.h')
-rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 28a6d6258692..a4fe9a786ef8 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -94,7 +94,8 @@ struct efx_special_buffer { | |||
94 | * struct efx_tx_buffer - buffer state for a TX descriptor | 94 | * struct efx_tx_buffer - buffer state for a TX descriptor |
95 | * @skb: When @flags & %EFX_TX_BUF_SKB, the associated socket buffer to be | 95 | * @skb: When @flags & %EFX_TX_BUF_SKB, the associated socket buffer to be |
96 | * freed when descriptor completes | 96 | * freed when descriptor completes |
97 | * @tsoh: When @flags & %EFX_TX_BUF_TSOH, the associated TSO header structure. | 97 | * @heap_buf: When @flags & %EFX_TX_BUF_HEAP, the associated heap buffer to be |
98 | * freed when descriptor completes. | ||
98 | * @dma_addr: DMA address of the fragment. | 99 | * @dma_addr: DMA address of the fragment. |
99 | * @flags: Flags for allocation and DMA mapping type | 100 | * @flags: Flags for allocation and DMA mapping type |
100 | * @len: Length of this fragment. | 101 | * @len: Length of this fragment. |
@@ -104,7 +105,7 @@ struct efx_special_buffer { | |||
104 | struct efx_tx_buffer { | 105 | struct efx_tx_buffer { |
105 | union { | 106 | union { |
106 | const struct sk_buff *skb; | 107 | const struct sk_buff *skb; |
107 | struct efx_tso_header *tsoh; | 108 | void *heap_buf; |
108 | }; | 109 | }; |
109 | dma_addr_t dma_addr; | 110 | dma_addr_t dma_addr; |
110 | unsigned short flags; | 111 | unsigned short flags; |
@@ -113,7 +114,7 @@ struct efx_tx_buffer { | |||
113 | }; | 114 | }; |
114 | #define EFX_TX_BUF_CONT 1 /* not last descriptor of packet */ | 115 | #define EFX_TX_BUF_CONT 1 /* not last descriptor of packet */ |
115 | #define EFX_TX_BUF_SKB 2 /* buffer is last part of skb */ | 116 | #define EFX_TX_BUF_SKB 2 /* buffer is last part of skb */ |
116 | #define EFX_TX_BUF_TSOH 4 /* buffer is TSO header */ | 117 | #define EFX_TX_BUF_HEAP 4 /* buffer was allocated with kmalloc() */ |
117 | #define EFX_TX_BUF_MAP_SINGLE 8 /* buffer was mapped with dma_map_single() */ | 118 | #define EFX_TX_BUF_MAP_SINGLE 8 /* buffer was mapped with dma_map_single() */ |
118 | 119 | ||
119 | /** | 120 | /** |
@@ -134,6 +135,7 @@ struct efx_tx_buffer { | |||
134 | * @channel: The associated channel | 135 | * @channel: The associated channel |
135 | * @core_txq: The networking core TX queue structure | 136 | * @core_txq: The networking core TX queue structure |
136 | * @buffer: The software buffer ring | 137 | * @buffer: The software buffer ring |
138 | * @tsoh_page: Array of pages of TSO header buffers | ||
137 | * @txd: The hardware descriptor ring | 139 | * @txd: The hardware descriptor ring |
138 | * @ptr_mask: The size of the ring minus 1. | 140 | * @ptr_mask: The size of the ring minus 1. |
139 | * @initialised: Has hardware queue been initialised? | 141 | * @initialised: Has hardware queue been initialised? |
@@ -157,9 +159,6 @@ struct efx_tx_buffer { | |||
157 | * variable indicates that the queue is full. This is to | 159 | * variable indicates that the queue is full. This is to |
158 | * avoid cache-line ping-pong between the xmit path and the | 160 | * avoid cache-line ping-pong between the xmit path and the |
159 | * completion path. | 161 | * completion path. |
160 | * @tso_headers_free: A list of TSO headers allocated for this TX queue | ||
161 | * that are not in use, and so available for new TSO sends. The list | ||
162 | * is protected by the TX queue lock. | ||
163 | * @tso_bursts: Number of times TSO xmit invoked by kernel | 162 | * @tso_bursts: Number of times TSO xmit invoked by kernel |
164 | * @tso_long_headers: Number of packets with headers too long for standard | 163 | * @tso_long_headers: Number of packets with headers too long for standard |
165 | * blocks | 164 | * blocks |
@@ -176,6 +175,7 @@ struct efx_tx_queue { | |||
176 | struct efx_channel *channel; | 175 | struct efx_channel *channel; |
177 | struct netdev_queue *core_txq; | 176 | struct netdev_queue *core_txq; |
178 | struct efx_tx_buffer *buffer; | 177 | struct efx_tx_buffer *buffer; |
178 | struct efx_buffer *tsoh_page; | ||
179 | struct efx_special_buffer txd; | 179 | struct efx_special_buffer txd; |
180 | unsigned int ptr_mask; | 180 | unsigned int ptr_mask; |
181 | bool initialised; | 181 | bool initialised; |
@@ -188,7 +188,6 @@ struct efx_tx_queue { | |||
188 | unsigned int insert_count ____cacheline_aligned_in_smp; | 188 | unsigned int insert_count ____cacheline_aligned_in_smp; |
189 | unsigned int write_count; | 189 | unsigned int write_count; |
190 | unsigned int old_read_count; | 190 | unsigned int old_read_count; |
191 | struct efx_tso_header *tso_headers_free; | ||
192 | unsigned int tso_bursts; | 191 | unsigned int tso_bursts; |
193 | unsigned int tso_long_headers; | 192 | unsigned int tso_long_headers; |
194 | unsigned int tso_packets; | 193 | unsigned int tso_packets; |