• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
3 
4 #ifndef __MLX5_IPSEC_OFFLOAD_H__
5 #define __MLX5_IPSEC_OFFLOAD_H__
6 
7 #include <linux/mlx5/driver.h>
8 #include "accel/ipsec.h"
9 
10 #ifdef CONFIG_MLX5_IPSEC
11 
12 const struct mlx5_accel_ipsec_ops *mlx5_ipsec_offload_ops(struct mlx5_core_dev *mdev);
mlx5_is_ipsec_device(struct mlx5_core_dev * mdev)13 static inline bool mlx5_is_ipsec_device(struct mlx5_core_dev *mdev)
14 {
15 	if (!MLX5_CAP_GEN(mdev, ipsec_offload))
16 		return false;
17 
18 	if (!MLX5_CAP_GEN(mdev, log_max_dek))
19 		return false;
20 
21 	if (!(MLX5_CAP_GEN_64(mdev, general_obj_types) &
22 	    MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_IPSEC))
23 		return false;
24 
25 	return MLX5_CAP_IPSEC(mdev, ipsec_crypto_offload) &&
26 		MLX5_CAP_ETH(mdev, insert_trailer);
27 }
28 
29 #else
30 static inline const struct mlx5_accel_ipsec_ops *
mlx5_ipsec_offload_ops(struct mlx5_core_dev * mdev)31 mlx5_ipsec_offload_ops(struct mlx5_core_dev *mdev) { return NULL; }
mlx5_is_ipsec_device(struct mlx5_core_dev * mdev)32 static inline bool mlx5_is_ipsec_device(struct mlx5_core_dev *mdev)
33 {
34 	return false;
35 }
36 
37 #endif /* CONFIG_MLX5_IPSEC */
38 #endif /* __MLX5_IPSEC_OFFLOAD_H__ */
39