Skip to content

Commit fb3bfdf

Browse files
cjubranSaeed Mahameed
authored andcommitted
net/mlx5e: XSK, Exclude tailroom from non-linear SKBs memory calculations
Packet data buffers lack reserved headroom or tailroom, and SKBs are allocated on a side memory when needed. Exclude the tailroom from the SKB size calculations. Signed-off-by: Carolina Jubran <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 917d1e7 commit fb3bfdf

File tree

1 file changed

+11
-4
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+11
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/params.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,14 @@ static u32 mlx5e_rx_get_linear_sz_xsk(struct mlx5e_params *params,
240240
return xsk->headroom + hw_mtu;
241241
}
242242

243-
static u32 mlx5e_rx_get_linear_sz_skb(struct mlx5e_params *params, bool xsk)
243+
static u32 mlx5e_rx_get_linear_sz_skb(struct mlx5e_params *params, bool no_head_tail_room)
244244
{
245-
/* SKBs built on XDP_PASS on XSK RQs don't have headroom. */
246-
u16 headroom = xsk ? 0 : mlx5e_get_linear_rq_headroom(params, NULL);
247245
u32 hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
246+
u16 headroom;
247+
248+
if (no_head_tail_room)
249+
return SKB_DATA_ALIGN(hw_mtu);
250+
headroom = mlx5e_get_linear_rq_headroom(params, NULL);
248251

249252
return MLX5_SKB_FRAG_SZ(headroom + hw_mtu);
250253
}
@@ -289,7 +292,11 @@ bool mlx5e_rx_is_linear_skb(struct mlx5_core_dev *mdev,
289292
if (params->packet_merge.type != MLX5E_PACKET_MERGE_NONE)
290293
return false;
291294

292-
/* Both XSK and non-XSK cases allocate an SKB on XDP_PASS. Packet data
295+
/* Call mlx5e_rx_get_linear_sz_skb with the no_head_tail_room parameter set
296+
* to exclude headroom and tailroom from calculations.
297+
* no_head_tail_room is true when SKB is built on XDP_PASS on XSK RQs
298+
* since packet data buffers don't have headroom and tailroom resreved for the SKB.
299+
* Both XSK and non-XSK cases allocate an SKB on XDP_PASS. Packet data
293300
* must fit into a CPU page.
294301
*/
295302
if (mlx5e_rx_get_linear_sz_skb(params, xsk) > PAGE_SIZE)

0 commit comments

Comments
 (0)