net/mlx5e: Add missing sanity checks for max TX WQE size
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_tx.c
index 6adca01fbdc9dda097591722244e5f1555026351..f7897ddb29c52667c52eafcee83314a765ad1f6e 100644 (file)
@@ -305,6 +305,8 @@ static void mlx5e_sq_calc_wqe_attr(struct sk_buff *skb, const struct mlx5e_tx_at
        u16 ds_cnt_inl = 0;
        u16 ds_cnt_ids = 0;
 
+       /* Sync the calculation with MLX5E_MAX_TX_WQEBBS. */
+
        if (attr->insz)
                ds_cnt_ids = DIV_ROUND_UP(sizeof(struct mlx5_wqe_inline_seg) + attr->insz,
                                          MLX5_SEND_WQE_DS);
@@ -317,6 +319,9 @@ static void mlx5e_sq_calc_wqe_attr(struct sk_buff *skb, const struct mlx5e_tx_at
                        inl += VLAN_HLEN;
 
                ds_cnt_inl = DIV_ROUND_UP(inl, MLX5_SEND_WQE_DS);
+               if (WARN_ON_ONCE(ds_cnt_inl > MLX5E_MAX_TX_INLINE_DS))
+                       netdev_warn(skb->dev, "ds_cnt_inl = %u > max %u\n", ds_cnt_inl,
+                                   (u16)MLX5E_MAX_TX_INLINE_DS);
                ds_cnt += ds_cnt_inl;
        }