// SPDX-License-Identifier: GPL-2.0-only /**************************************************************************** * Driver for Solarflare network controllers and boards * Copyright 2018 Solarflare Communications Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation, incorporated herein by reference.
*/
if (tx_queue->cb_page) { for (i = 0; i < efx_tx_cb_page_count(tx_queue); i++)
efx_nic_free_buffer(tx_queue->efx,
&tx_queue->cb_page[i]);
kfree(tx_queue->cb_page);
tx_queue->cb_page = NULL;
}
/* Remove packets from the TX queue * * This removes packets from the TX queue, up to and including the * specified index.
*/ staticvoid efx_dequeue_buffers(struct efx_tx_queue *tx_queue, unsignedint index, unsignedint *pkts_compl, unsignedint *bytes_compl, unsignedint *efv_pkts_compl, unsignedint *xdp_pkts, unsignedint *xdp_bytes)
{ struct efx_nic *efx = tx_queue->efx; unsignedint stop_index, read_ptr;
if (pkts_compl + efv_pkts_compl > 1)
++tx_queue->merge_events;
/* See if we need to restart the netif queue. This memory * barrier ensures that we write read_count (inside * efx_dequeue_buffers()) before reading the queue status.
*/
smp_mb(); if (unlikely(netif_tx_queue_stopped(tx_queue->core_txq)) &&
likely(efx->port_enabled) &&
likely(netif_device_present(efx->net_dev))) {
fill_level = efx_channel_tx_fill_level(tx_queue->channel); if (fill_level <= efx->txq_wake_thresh)
netif_tx_wake_queue(tx_queue->core_txq);
}
efx_xmit_done_check_empty(tx_queue);
return pkts_compl + efv_pkts_compl;
}
/* Remove buffers put into a tx_queue for the current packet. * None of the buffers must have an skb attached.
*/ void efx_enqueue_unwind(struct efx_tx_queue *tx_queue, unsignedint insert_count)
{ unsignedint xdp_bytes_compl = 0; unsignedint xdp_pkts_compl = 0; unsignedint efv_pkts_compl = 0; struct efx_tx_buffer *buffer; unsignedint bytes_compl = 0; unsignedint pkts_compl = 0;
/* Work backwards until we hit the original insert pointer value */ while (tx_queue->insert_count != insert_count) {
--tx_queue->insert_count;
buffer = __efx_tx_queue_get_insert_buffer(tx_queue);
efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl,
&efv_pkts_compl, &xdp_pkts_compl,
&xdp_bytes_compl);
}
}
if (unlikely(dma_mapping_error(dma_dev, dma_addr))) return -EIO;
if (segment_count) { /* For TSO we need to put the header in to a separate * descriptor. Map this separately if necessary.
*/
size_t header_len = efx_tx_tso_header_length(skb);
if (header_len != len) {
tx_queue->tso_long_headers++;
efx_tx_map_chunk(tx_queue, dma_addr, header_len);
len -= header_len;
dma_addr += header_len;
}
}
/* Add descriptors for each fragment. */ do { struct efx_tx_buffer *buffer;
skb_frag_t *fragment;
/* The final descriptor for a fragment is responsible for * unmapping the whole fragment.
*/
buffer->flags = EFX_TX_BUF_CONT | dma_flags;
buffer->unmap_len = unmap_len;
buffer->dma_offset = buffer->dma_addr - unmap_addr;
if (frag_index >= nr_frags) { /* Store SKB details with the final buffer for * the completion.
*/
buffer->skb = skb;
buffer->flags = EFX_TX_BUF_SKB | dma_flags; return 0;
}
/* Move on to the next fragment. */
fragment = &skb_shinfo(skb)->frags[frag_index++];
len = skb_frag_size(fragment);
dma_addr = skb_frag_dma_map(dma_dev, fragment, 0, len,
DMA_TO_DEVICE);
dma_flags = 0;
unmap_len = len;
unmap_addr = dma_addr;
if (unlikely(dma_mapping_error(dma_dev, dma_addr))) return -EIO;
} while (1);
}
unsignedint efx_tx_max_skb_descs(struct efx_nic *efx)
{ /* Header and payload descriptor for each output segment, plus * one for every input fragment boundary within a segment
*/ unsignedint max_descs = EFX_TSO_MAX_SEGS * 2 + MAX_SKB_FRAGS;
/* Possibly one more per segment for option descriptors */ if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
max_descs += EFX_TSO_MAX_SEGS;
/* Possibly more for PCIe page boundaries within input fragments */ if (PAGE_SIZE > EFX_PAGE_SIZE)
max_descs += max_t(unsignedint, MAX_SKB_FRAGS,
DIV_ROUND_UP(GSO_LEGACY_MAX_SIZE,
EFX_PAGE_SIZE));
return max_descs;
}
/* * Fallback to software TSO. * * This is used if we are unable to send a GSO packet through hardware TSO. * This should only ever happen due to per-queue restrictions - unsupported * packets should first be filtered by the feature flags. * * Returns 0 on success, error code otherwise.
*/ int efx_tx_tso_fallback(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
{ struct sk_buff *segments, *next;
segments = skb_gso_segment(skb, 0); if (IS_ERR(segments)) return PTR_ERR(segments);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.