Skip to content

Commit

Permalink
mlx4: reduce rx ring page_cache size
Browse files Browse the repository at this point in the history
We only need to store the page and dma address.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Mar 9, 2017
1 parent d85f6c1 commit acd7628
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions drivers/net/ethernet/mellanox/mlx4/en_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv,
(index << priv->log_rx_info);

if (ring->page_cache.index > 0) {
frags[0] = ring->page_cache.buf[--ring->page_cache.index];
ring->page_cache.index--;
frags[0].page = ring->page_cache.buf[ring->page_cache.index].page;
frags[0].dma = ring->page_cache.buf[ring->page_cache.index].dma;
frags[0].page_offset = XDP_PACKET_HEADROOM;
rx_desc->data[0].addr = cpu_to_be64(frags[0].dma +
frags[0].page_offset);
return 0;
Expand Down Expand Up @@ -537,7 +540,9 @@ bool mlx4_en_rx_recycle(struct mlx4_en_rx_ring *ring,
if (cache->index >= MLX4_EN_CACHE_SIZE)
return false;

cache->buf[cache->index++] = *frame;
cache->buf[cache->index].page = frame->page;
cache->buf[cache->index].dma = frame->dma;
cache->index++;
return true;
}

Expand Down Expand Up @@ -567,11 +572,9 @@ void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
int i;

for (i = 0; i < ring->page_cache.index; i++) {
struct mlx4_en_rx_alloc *frame = &ring->page_cache.buf[i];

dma_unmap_page(priv->ddev, frame->dma, frame->page_size,
priv->dma_dir);
put_page(frame->page);
dma_unmap_page(priv->ddev, ring->page_cache.buf[i].dma,
PAGE_SIZE, priv->dma_dir);
put_page(ring->page_cache.buf[i].page);
}
ring->page_cache.index = 0;
mlx4_en_free_rx_buf(priv, ring);
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/mellanox/mlx4/en_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ u32 mlx4_en_recycle_tx_desc(struct mlx4_en_priv *priv,
struct mlx4_en_rx_alloc frame = {
.page = tx_info->page,
.dma = tx_info->map0_dma,
.page_offset = XDP_PACKET_HEADROOM,
.page_size = PAGE_SIZE,
};

if (!mlx4_en_rx_recycle(ring->recycle_ring, &frame)) {
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,13 @@ struct mlx4_en_rx_alloc {
};

#define MLX4_EN_CACHE_SIZE (2 * NAPI_POLL_WEIGHT)

struct mlx4_en_page_cache {
u32 index;
struct mlx4_en_rx_alloc buf[MLX4_EN_CACHE_SIZE];
struct {
struct page *page;
dma_addr_t dma;
} buf[MLX4_EN_CACHE_SIZE];
};

struct mlx4_en_priv;
Expand Down

0 comments on commit acd7628

Please sign in to comment.