diff options
author | Dragos Tatulea <dtatulea@nvidia.com> | 2023-01-27 18:06:12 +0300 |
---|---|---|
committer | Saeed Mahameed <saeedm@nvidia.com> | 2023-03-28 23:43:56 +0300 |
commit | 09df037017799b723d03a97c3f0de069bae9f625 (patch) | |
tree | 8f9abc5cb5db8df1e4f8514851a19052d7d3d45c /drivers/net | |
parent | 86e2eca4ddedc07d639c44c990e1c220cac3741e (diff) | |
download | linux-09df037017799b723d03a97c3f0de069bae9f625.tar.xz |
net/mlx5e: RX, Remove mlx5e_alloc_unit argument in page allocation
Change internal page cache and page pool api to use a struct page **
instead of a mlx5e_alloc_unit *.
This is the first change in a series which is meant to remove the
mlx5e_alloc_unit altogether.
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 3f7b63d6616b..36300118b6e4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -292,7 +292,7 @@ static inline bool mlx5e_rx_cache_put(struct mlx5e_rq *rq, struct page *page) return true; } -static inline bool mlx5e_rx_cache_get(struct mlx5e_rq *rq, union mlx5e_alloc_unit *au) +static inline bool mlx5e_rx_cache_get(struct mlx5e_rq *rq, struct page **pagep) { struct mlx5e_page_cache *cache = &rq->page_cache; struct mlx5e_rq_stats *stats = rq->stats; @@ -308,35 +308,35 @@ static inline bool mlx5e_rx_cache_get(struct mlx5e_rq *rq, union mlx5e_alloc_uni return false; } - au->page = cache->page_cache[cache->head]; + *pagep = cache->page_cache[cache->head]; cache->head = (cache->head + 1) & (MLX5E_CACHE_SIZE - 1); stats->cache_reuse++; - addr = page_pool_get_dma_addr(au->page); + addr = page_pool_get_dma_addr(*pagep); /* Non-XSK always uses PAGE_SIZE. */ dma_sync_single_for_device(rq->pdev, addr, PAGE_SIZE, rq->buff.map_dir); return true; } -static inline int mlx5e_page_alloc_pool(struct mlx5e_rq *rq, union mlx5e_alloc_unit *au) +static inline int mlx5e_page_alloc_pool(struct mlx5e_rq *rq, struct page **pagep) { dma_addr_t addr; - if (mlx5e_rx_cache_get(rq, au)) + if (mlx5e_rx_cache_get(rq, pagep)) return 0; - au->page = page_pool_dev_alloc_pages(rq->page_pool); - if (unlikely(!au->page)) + *pagep = page_pool_dev_alloc_pages(rq->page_pool); + if (unlikely(!*pagep)) return -ENOMEM; /* Non-XSK always uses PAGE_SIZE. */ - addr = dma_map_page(rq->pdev, au->page, 0, PAGE_SIZE, rq->buff.map_dir); + addr = dma_map_page(rq->pdev, *pagep, 0, PAGE_SIZE, rq->buff.map_dir); if (unlikely(dma_mapping_error(rq->pdev, addr))) { - page_pool_recycle_direct(rq->page_pool, au->page); - au->page = NULL; + page_pool_recycle_direct(rq->page_pool, *pagep); + *pagep = NULL; return -ENOMEM; } - page_pool_set_dma_addr(au->page, addr); + page_pool_set_dma_addr(*pagep, addr); return 0; } @@ -376,7 +376,7 @@ static inline int mlx5e_get_rx_frag(struct mlx5e_rq *rq, * offset) should just use the new one without replenishing again * by themselves. */ - err = mlx5e_page_alloc_pool(rq, frag->au); + err = mlx5e_page_alloc_pool(rq, &frag->au->page); return err; } @@ -605,13 +605,14 @@ static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq, header_offset = (index & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)) << MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE; if (!(header_offset & (PAGE_SIZE - 1))) { - union mlx5e_alloc_unit au; - err = mlx5e_page_alloc_pool(rq, &au); + err = mlx5e_page_alloc_pool(rq, &page); if (unlikely(err)) goto err_unmap; - page = dma_info->page = au.page; - addr = dma_info->addr = page_pool_get_dma_addr(au.page); + + addr = page_pool_get_dma_addr(page); + dma_info->addr = addr; + dma_info->page = page; } else { dma_info->addr = addr + header_offset; dma_info->page = page; @@ -715,7 +716,7 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) for (i = 0; i < rq->mpwqe.pages_per_wqe; i++, au++) { dma_addr_t addr; - err = mlx5e_page_alloc_pool(rq, au); + err = mlx5e_page_alloc_pool(rq, &au->page); if (unlikely(err)) goto err_unmap; addr = page_pool_get_dma_addr(au->page); |