Commit 4c07c132 authored by Tariq Toukan's avatar Tariq Toukan Committed by David S. Miller

net/mlx4_en: Refactor mlx4_en_free_tx_desc

Some code re-ordering, functionally equivalent.

- The !tx_info->inl check is evaluated anyway in both flows
  (common case/end case). Run it first, this might finish
  the flows earlier.
- dma_unmap calls are identical in both flows, get it out
  of the if block into the common area.

Performance tests:
Tested on ConnectX3Pro, Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz

Gain is too small to be measurable, no degradation sensed.
Results are similar for IPv4 and IPv6.
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Reviewed-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Cc: kernel-team@fb.com
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9573e0d3
...@@ -289,20 +289,20 @@ u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, ...@@ -289,20 +289,20 @@ u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
skb_tstamp_tx(skb, &hwts); skb_tstamp_tx(skb, &hwts);
} }
/* Optimize the common case when there are no wraparounds */ if (!tx_info->inl) {
if (likely((void *)tx_desc + if (tx_info->linear)
(tx_info->nr_txbb << LOG_TXBB_SIZE) <= end)) { dma_unmap_single(priv->ddev,
if (!tx_info->inl) { tx_info->map0_dma,
if (tx_info->linear) tx_info->map0_byte_count,
dma_unmap_single(priv->ddev, PCI_DMA_TODEVICE);
tx_info->map0_dma, else
tx_info->map0_byte_count, dma_unmap_page(priv->ddev,
PCI_DMA_TODEVICE); tx_info->map0_dma,
else tx_info->map0_byte_count,
dma_unmap_page(priv->ddev, PCI_DMA_TODEVICE);
tx_info->map0_dma, /* Optimize the common case when there are no wraparounds */
tx_info->map0_byte_count, if (likely((void *)tx_desc +
PCI_DMA_TODEVICE); (tx_info->nr_txbb << LOG_TXBB_SIZE) <= end)) {
for (i = 1; i < nr_maps; i++) { for (i = 1; i < nr_maps; i++) {
data++; data++;
dma_unmap_page(priv->ddev, dma_unmap_page(priv->ddev,
...@@ -310,23 +310,10 @@ u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, ...@@ -310,23 +310,10 @@ u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
be32_to_cpu(data->byte_count), be32_to_cpu(data->byte_count),
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
} }
} } else {
} else { if ((void *)data >= end)
if (!tx_info->inl) {
if ((void *) data >= end) {
data = ring->buf + ((void *)data - end); data = ring->buf + ((void *)data - end);
}
if (tx_info->linear)
dma_unmap_single(priv->ddev,
tx_info->map0_dma,
tx_info->map0_byte_count,
PCI_DMA_TODEVICE);
else
dma_unmap_page(priv->ddev,
tx_info->map0_dma,
tx_info->map0_byte_count,
PCI_DMA_TODEVICE);
for (i = 1; i < nr_maps; i++) { for (i = 1; i < nr_maps; i++) {
data++; data++;
/* Check for wraparound before unmapping */ /* Check for wraparound before unmapping */
......
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