diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-04-13 08:33:49 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-04-13 08:33:49 +0000 |
commit | 644d59c8aec1887fccbe79682c2526f9effbbc9c (patch) | |
tree | a3e0aef3b7292893e93bd7b89147e94dcc69c7b7 | |
parent | 9c75837402cef1e0043977f2e11e44513556b2e1 (diff) | |
download | src-test2-644d59c8aec1887fccbe79682c2526f9effbbc9c.tar.gz src-test2-644d59c8aec1887fccbe79682c2526f9effbbc9c.zip |
MFC r359654:
Ensure a minimum inline size of 16 bytes in mlx5en(4).
This includes 14 bytes of ethernet header and 2 bytes of VLAN header.
This allows for making assumptions about the inline size limit
in the fast transmit path later on.
Use a signed integer variable to catch underflow.
Sponsored by: Mellanox Technologies
Notes
Notes:
svn path=/stable/10/; revision=359847
-rw-r--r-- | sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 64f59acc9a1b..23bb3f788c1e 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -2880,11 +2880,19 @@ mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev) static u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev) { - int bf_buf_size = (1 << MLX5_CAP_GEN(mdev, log_bf_reg_size)) / 2; - - return bf_buf_size - - sizeof(struct mlx5e_tx_wqe) + - 2 /*sizeof(mlx5e_tx_wqe.inline_hdr_start)*/; + const int min_size = ETHER_VLAN_ENCAP_LEN + ETHER_HDR_LEN; + const int max_size = MLX5E_MAX_TX_INLINE; + const int bf_buf_size = + ((1U << MLX5_CAP_GEN(mdev, log_bf_reg_size)) / 2U) - + (sizeof(struct mlx5e_tx_wqe) - 2); + + /* verify against driver limits */ + if (bf_buf_size > max_size) + return (max_size); + else if (bf_buf_size < min_size) + return (min_size); + else + return (bf_buf_size); } static void |