Lines Matching refs:tx_queue

17 static unsigned int efx_tx_cb_page_count(struct efx_tx_queue *tx_queue)  in efx_tx_cb_page_count()  argument
19 return DIV_ROUND_UP(tx_queue->ptr_mask + 1, in efx_tx_cb_page_count()
23 int efx_siena_probe_tx_queue(struct efx_tx_queue *tx_queue) in efx_siena_probe_tx_queue() argument
25 struct efx_nic *efx = tx_queue->efx; in efx_siena_probe_tx_queue()
32 tx_queue->ptr_mask = entries - 1; in efx_siena_probe_tx_queue()
36 tx_queue->queue, efx->txq_entries, tx_queue->ptr_mask); in efx_siena_probe_tx_queue()
39 tx_queue->buffer = kcalloc(entries, sizeof(*tx_queue->buffer), in efx_siena_probe_tx_queue()
41 if (!tx_queue->buffer) in efx_siena_probe_tx_queue()
44 tx_queue->cb_page = kcalloc(efx_tx_cb_page_count(tx_queue), in efx_siena_probe_tx_queue()
45 sizeof(tx_queue->cb_page[0]), GFP_KERNEL); in efx_siena_probe_tx_queue()
46 if (!tx_queue->cb_page) { in efx_siena_probe_tx_queue()
52 rc = efx_nic_probe_tx(tx_queue); in efx_siena_probe_tx_queue()
56 tx_queue->channel->tx_queue_by_type[tx_queue->type] = tx_queue; in efx_siena_probe_tx_queue()
60 kfree(tx_queue->cb_page); in efx_siena_probe_tx_queue()
61 tx_queue->cb_page = NULL; in efx_siena_probe_tx_queue()
63 kfree(tx_queue->buffer); in efx_siena_probe_tx_queue()
64 tx_queue->buffer = NULL; in efx_siena_probe_tx_queue()
68 void efx_siena_init_tx_queue(struct efx_tx_queue *tx_queue) in efx_siena_init_tx_queue() argument
70 struct efx_nic *efx = tx_queue->efx; in efx_siena_init_tx_queue()
73 "initialising TX queue %d\n", tx_queue->queue); in efx_siena_init_tx_queue()
75 tx_queue->insert_count = 0; in efx_siena_init_tx_queue()
76 tx_queue->notify_count = 0; in efx_siena_init_tx_queue()
77 tx_queue->write_count = 0; in efx_siena_init_tx_queue()
78 tx_queue->packet_write_count = 0; in efx_siena_init_tx_queue()
79 tx_queue->old_write_count = 0; in efx_siena_init_tx_queue()
80 tx_queue->read_count = 0; in efx_siena_init_tx_queue()
81 tx_queue->old_read_count = 0; in efx_siena_init_tx_queue()
82 tx_queue->empty_read_count = 0 | EFX_EMPTY_COUNT_VALID; in efx_siena_init_tx_queue()
83 tx_queue->xmit_pending = false; in efx_siena_init_tx_queue()
84 tx_queue->timestamping = (efx_siena_ptp_use_mac_tx_timestamps(efx) && in efx_siena_init_tx_queue()
85 tx_queue->channel == efx_siena_ptp_channel(efx)); in efx_siena_init_tx_queue()
86 tx_queue->completed_timestamp_major = 0; in efx_siena_init_tx_queue()
87 tx_queue->completed_timestamp_minor = 0; in efx_siena_init_tx_queue()
89 tx_queue->xdp_tx = efx_channel_is_xdp_tx(tx_queue->channel); in efx_siena_init_tx_queue()
90 tx_queue->tso_version = 0; in efx_siena_init_tx_queue()
93 efx_nic_init_tx(tx_queue); in efx_siena_init_tx_queue()
95 tx_queue->initialised = true; in efx_siena_init_tx_queue()
98 void efx_siena_remove_tx_queue(struct efx_tx_queue *tx_queue) in efx_siena_remove_tx_queue() argument
102 if (!tx_queue->buffer) in efx_siena_remove_tx_queue()
105 netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, in efx_siena_remove_tx_queue()
106 "destroying TX queue %d\n", tx_queue->queue); in efx_siena_remove_tx_queue()
107 efx_nic_remove_tx(tx_queue); in efx_siena_remove_tx_queue()
109 if (tx_queue->cb_page) { in efx_siena_remove_tx_queue()
110 for (i = 0; i < efx_tx_cb_page_count(tx_queue); i++) in efx_siena_remove_tx_queue()
111 efx_siena_free_buffer(tx_queue->efx, in efx_siena_remove_tx_queue()
112 &tx_queue->cb_page[i]); in efx_siena_remove_tx_queue()
113 kfree(tx_queue->cb_page); in efx_siena_remove_tx_queue()
114 tx_queue->cb_page = NULL; in efx_siena_remove_tx_queue()
117 kfree(tx_queue->buffer); in efx_siena_remove_tx_queue()
118 tx_queue->buffer = NULL; in efx_siena_remove_tx_queue()
119 tx_queue->channel->tx_queue_by_type[tx_queue->type] = NULL; in efx_siena_remove_tx_queue()
122 static void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, in efx_dequeue_buffer() argument
128 struct device *dma_dev = &tx_queue->efx->pci_dev->dev; in efx_dequeue_buffer()
146 if (tx_queue->timestamping && in efx_dequeue_buffer()
147 (tx_queue->completed_timestamp_major || in efx_dequeue_buffer()
148 tx_queue->completed_timestamp_minor)) { in efx_dequeue_buffer()
152 efx_siena_ptp_nic_to_kernel_time(tx_queue); in efx_dequeue_buffer()
155 tx_queue->completed_timestamp_major = 0; in efx_dequeue_buffer()
156 tx_queue->completed_timestamp_minor = 0; in efx_dequeue_buffer()
159 netif_vdbg(tx_queue->efx, tx_done, tx_queue->efx->net_dev, in efx_dequeue_buffer()
161 tx_queue->queue, tx_queue->read_count); in efx_dequeue_buffer()
170 void efx_siena_fini_tx_queue(struct efx_tx_queue *tx_queue) in efx_siena_fini_tx_queue() argument
174 netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, in efx_siena_fini_tx_queue()
175 "shutting down TX queue %d\n", tx_queue->queue); in efx_siena_fini_tx_queue()
177 if (!tx_queue->buffer) in efx_siena_fini_tx_queue()
181 while (tx_queue->read_count != tx_queue->write_count) { in efx_siena_fini_tx_queue()
184 buffer = &tx_queue->buffer[tx_queue->read_count & tx_queue->ptr_mask]; in efx_siena_fini_tx_queue()
185 efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl); in efx_siena_fini_tx_queue()
187 ++tx_queue->read_count; in efx_siena_fini_tx_queue()
189 tx_queue->xmit_pending = false; in efx_siena_fini_tx_queue()
190 netdev_tx_reset_queue(tx_queue->core_txq); in efx_siena_fini_tx_queue()
198 static void efx_dequeue_buffers(struct efx_tx_queue *tx_queue, in efx_dequeue_buffers() argument
203 struct efx_nic *efx = tx_queue->efx; in efx_dequeue_buffers()
206 stop_index = (index + 1) & tx_queue->ptr_mask; in efx_dequeue_buffers()
207 read_ptr = tx_queue->read_count & tx_queue->ptr_mask; in efx_dequeue_buffers()
210 struct efx_tx_buffer *buffer = &tx_queue->buffer[read_ptr]; in efx_dequeue_buffers()
215 tx_queue->queue, read_ptr); in efx_dequeue_buffers()
220 efx_dequeue_buffer(tx_queue, buffer, pkts_compl, bytes_compl); in efx_dequeue_buffers()
222 ++tx_queue->read_count; in efx_dequeue_buffers()
223 read_ptr = tx_queue->read_count & tx_queue->ptr_mask; in efx_dequeue_buffers()
227 void efx_siena_xmit_done_check_empty(struct efx_tx_queue *tx_queue) in efx_siena_xmit_done_check_empty() argument
229 if ((int)(tx_queue->read_count - tx_queue->old_write_count) >= 0) { in efx_siena_xmit_done_check_empty()
230 tx_queue->old_write_count = READ_ONCE(tx_queue->write_count); in efx_siena_xmit_done_check_empty()
231 if (tx_queue->read_count == tx_queue->old_write_count) { in efx_siena_xmit_done_check_empty()
234 tx_queue->empty_read_count = in efx_siena_xmit_done_check_empty()
235 tx_queue->read_count | EFX_EMPTY_COUNT_VALID; in efx_siena_xmit_done_check_empty()
240 void efx_siena_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) in efx_siena_xmit_done() argument
243 struct efx_nic *efx = tx_queue->efx; in efx_siena_xmit_done()
245 EFX_WARN_ON_ONCE_PARANOID(index > tx_queue->ptr_mask); in efx_siena_xmit_done()
247 efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl); in efx_siena_xmit_done()
248 tx_queue->pkts_compl += pkts_compl; in efx_siena_xmit_done()
249 tx_queue->bytes_compl += bytes_compl; in efx_siena_xmit_done()
252 ++tx_queue->merge_events; in efx_siena_xmit_done()
259 if (unlikely(netif_tx_queue_stopped(tx_queue->core_txq)) && in efx_siena_xmit_done()
262 fill_level = efx_channel_tx_fill_level(tx_queue->channel); in efx_siena_xmit_done()
264 netif_tx_wake_queue(tx_queue->core_txq); in efx_siena_xmit_done()
267 efx_siena_xmit_done_check_empty(tx_queue); in efx_siena_xmit_done()
273 void efx_siena_enqueue_unwind(struct efx_tx_queue *tx_queue, in efx_siena_enqueue_unwind() argument
281 while (tx_queue->insert_count != insert_count) { in efx_siena_enqueue_unwind()
282 --tx_queue->insert_count; in efx_siena_enqueue_unwind()
283 buffer = __efx_tx_queue_get_insert_buffer(tx_queue); in efx_siena_enqueue_unwind()
284 efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl); in efx_siena_enqueue_unwind()
288 struct efx_tx_buffer *efx_siena_tx_map_chunk(struct efx_tx_queue *tx_queue, in efx_siena_tx_map_chunk() argument
291 const struct efx_nic_type *nic_type = tx_queue->efx->type; in efx_siena_tx_map_chunk()
297 buffer = efx_tx_queue_get_insert_buffer(tx_queue); in efx_siena_tx_map_chunk()
300 dma_len = nic_type->tx_limit_len(tx_queue, dma_addr, len); in efx_siena_tx_map_chunk()
309 ++tx_queue->insert_count; in efx_siena_tx_map_chunk()
329 int efx_siena_tx_map_data(struct efx_tx_queue *tx_queue, struct sk_buff *skb, in efx_siena_tx_map_data() argument
332 struct efx_nic *efx = tx_queue->efx; in efx_siena_tx_map_data()
359 tx_queue->tso_long_headers++; in efx_siena_tx_map_data()
360 efx_siena_tx_map_chunk(tx_queue, dma_addr, header_len); in efx_siena_tx_map_data()
371 buffer = efx_siena_tx_map_chunk(tx_queue, dma_addr, len); in efx_siena_tx_map_data()
431 int efx_siena_tx_tso_fallback(struct efx_tx_queue *tx_queue, in efx_siena_tx_tso_fallback() argument
444 efx_enqueue_skb(tx_queue, skb); in efx_siena_tx_tso_fallback()