Commit 386471f1 authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

net/mlx5e: RX, Dedicate a function for copying SKB header

Get the logic of copying the packet header into the SKB linear part
into a generic function. Function does copy length alignment
and dma buffer sync.

It is currently called only within the MPWQE flow.
In a downstream patch, it will be called within the legacy RQ flow
as well.
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent fa698366
...@@ -324,6 +324,20 @@ mlx5e_add_skb_frag(struct mlx5e_rq *rq, struct sk_buff *skb, ...@@ -324,6 +324,20 @@ mlx5e_add_skb_frag(struct mlx5e_rq *rq, struct sk_buff *skb,
di->page, frag_offset, len, truesize); di->page, frag_offset, len, truesize);
} }
static inline void
mlx5e_copy_skb_header(struct device *pdev, struct sk_buff *skb,
struct mlx5e_dma_info *dma_info,
int offset_from, int offset_to, u32 headlen)
{
const void *from = page_address(dma_info->page) + offset_from;
/* Aligning len to sizeof(long) optimizes memcpy performance */
unsigned int len = ALIGN(headlen, sizeof(long));
dma_sync_single_for_cpu(pdev, dma_info->addr + offset_from, len,
DMA_FROM_DEVICE);
skb_copy_to_linear_data_offset(skb, offset_to, from, len);
}
static inline void static inline void
mlx5e_copy_skb_header_mpwqe(struct device *pdev, mlx5e_copy_skb_header_mpwqe(struct device *pdev,
struct sk_buff *skb, struct sk_buff *skb,
...@@ -331,23 +345,13 @@ mlx5e_copy_skb_header_mpwqe(struct device *pdev, ...@@ -331,23 +345,13 @@ mlx5e_copy_skb_header_mpwqe(struct device *pdev,
u32 offset, u32 headlen) u32 offset, u32 headlen)
{ {
u16 headlen_pg = min_t(u32, headlen, PAGE_SIZE - offset); u16 headlen_pg = min_t(u32, headlen, PAGE_SIZE - offset);
unsigned int len;
/* Aligning len to sizeof(long) optimizes memcpy performance */ mlx5e_copy_skb_header(pdev, skb, dma_info, offset, 0, headlen_pg);
len = ALIGN(headlen_pg, sizeof(long));
dma_sync_single_for_cpu(pdev, dma_info->addr + offset, len,
DMA_FROM_DEVICE);
skb_copy_to_linear_data(skb, page_address(dma_info->page) + offset, len);
if (unlikely(offset + headlen > PAGE_SIZE)) { if (unlikely(offset + headlen > PAGE_SIZE)) {
dma_info++; dma_info++;
headlen_pg = len; mlx5e_copy_skb_header(pdev, skb, dma_info, 0, headlen_pg,
len = ALIGN(headlen - headlen_pg, sizeof(long)); headlen - headlen_pg);
dma_sync_single_for_cpu(pdev, dma_info->addr, len,
DMA_FROM_DEVICE);
skb_copy_to_linear_data_offset(skb, headlen_pg,
page_address(dma_info->page),
len);
} }
} }
......
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