From: Cosmin Ratiu Flush SHAMPO session on PSP status change (no PSP -> PSP or vice-versa) or on SPI/version mismatch. HW aggregates by 5-tuple but is unaware of PSP fields, so sessions must be terminated when security parameters change to avoid mixing packets from different PSP associations. The session is also forcefully flushed if non-decapsulated packets are received. This could happen if, for example, the decap table could not be created so HW GRO is active but there's no decapsulation. Signed-off-by: Cosmin Ratiu Reviewed-by: Dragos Tatulea Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index fb7110b1b683..c7eaab3f7967 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -2221,6 +2221,33 @@ static bool mlx5e_hw_gro_skb_has_enough_space(struct sk_buff *skb, return page_size * nr_frags + data_bcnt <= GRO_LEGACY_MAX_SIZE; } +static bool mlx5e_hw_gro_psp_match(struct sk_buff *skb, struct mlx5_cqe64 *cqe) +{ +#ifdef CONFIG_MLX5_EN_PSP + struct psp_skb_ext *pse = skb_ext_find(skb, SKB_EXT_PSP); + bool is_psp = mlx5e_psp_is_rx_flow(cqe); + + if (likely(!is_psp && !pse)) + return true; + + /* No match on PSP status change (no crypto -> crypto or vice-versa). */ + if (unlikely(is_psp != !!pse)) + return false; + + /* SPI and version are only available in CQE metadata for decap flows. + * Non-decap PSP cannot be matched here, force a flush. + */ + if (unlikely(!mlx5e_psp_is_decap(cqe))) + return false; + + /* No match on security parameters change. */ + return pse->spi == mlx5e_psp_get_spi(cqe) && + pse->version == mlx5e_psp_get_version(cqe); +#else + return true; +#endif +} + static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) { u16 data_bcnt = mpwrq_get_cqe_byte_cnt(cqe) - cqe->shampo.header_size; @@ -2258,8 +2285,9 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq data_offset = wqe_offset & (page_size - 1); page_idx = wqe_offset >> rq->mpwqe.page_shift; if (*skb && - !(match && mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, - page_size))) { + !(match && + mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) && + mlx5e_hw_gro_psp_match(*skb, cqe))) { match = false; mlx5e_shampo_flush_skb(rq, cqe, match); } -- 2.44.0