|
35 | 35 | #define __MLX5_ACCEL_IPSEC_H__
|
36 | 36 |
|
37 | 37 | #include <linux/mlx5/driver.h>
|
| 38 | +#include <linux/mlx5/accel.h> |
38 | 39 |
|
39 | 40 | #ifdef CONFIG_MLX5_ACCEL
|
40 | 41 |
|
41 |
| -enum { |
42 |
| - MLX5_ACCEL_IPSEC_DEVICE = BIT(1), |
43 |
| - MLX5_ACCEL_IPSEC_IPV6 = BIT(2), |
44 |
| - MLX5_ACCEL_IPSEC_ESP = BIT(3), |
45 |
| - MLX5_ACCEL_IPSEC_LSO = BIT(4), |
46 |
| -}; |
47 |
| - |
48 |
| -#define MLX5_IPSEC_SADB_IP_AH BIT(7) |
49 |
| -#define MLX5_IPSEC_SADB_IP_ESP BIT(6) |
50 |
| -#define MLX5_IPSEC_SADB_SA_VALID BIT(5) |
51 |
| -#define MLX5_IPSEC_SADB_SPI_EN BIT(4) |
52 |
| -#define MLX5_IPSEC_SADB_DIR_SX BIT(3) |
53 |
| -#define MLX5_IPSEC_SADB_IPV6 BIT(2) |
54 |
| - |
55 |
| -enum { |
56 |
| - MLX5_IPSEC_CMD_ADD_SA = 0, |
57 |
| - MLX5_IPSEC_CMD_DEL_SA = 1, |
58 |
| -}; |
59 |
| - |
60 |
| -enum mlx5_accel_ipsec_enc_mode { |
61 |
| - MLX5_IPSEC_SADB_MODE_NONE = 0, |
62 |
| - MLX5_IPSEC_SADB_MODE_AES_GCM_128_AUTH_128 = 1, |
63 |
| - MLX5_IPSEC_SADB_MODE_AES_GCM_256_AUTH_128 = 3, |
64 |
| -}; |
65 |
| - |
66 | 42 | #define MLX5_IPSEC_DEV(mdev) (mlx5_accel_ipsec_device_caps(mdev) & \
|
67 |
| - MLX5_ACCEL_IPSEC_DEVICE) |
68 |
| - |
69 |
| -struct mlx5_accel_ipsec_sa { |
70 |
| - __be32 cmd; |
71 |
| - u8 key_enc[32]; |
72 |
| - u8 key_auth[32]; |
73 |
| - __be32 sip[4]; |
74 |
| - __be32 dip[4]; |
75 |
| - union { |
76 |
| - struct { |
77 |
| - __be32 reserved; |
78 |
| - u8 salt_iv[8]; |
79 |
| - __be32 salt; |
80 |
| - } __packed gcm; |
81 |
| - struct { |
82 |
| - u8 salt[16]; |
83 |
| - } __packed cbc; |
84 |
| - }; |
85 |
| - __be32 spi; |
86 |
| - __be32 sw_sa_handle; |
87 |
| - __be16 tfclen; |
88 |
| - u8 enc_mode; |
89 |
| - u8 sip_masklen; |
90 |
| - u8 dip_masklen; |
91 |
| - u8 flags; |
92 |
| - u8 reserved[2]; |
93 |
| -} __packed; |
94 |
| - |
95 |
| -/** |
96 |
| - * mlx5_accel_ipsec_sa_cmd_exec - Execute an IPSec SADB command |
97 |
| - * @mdev: mlx5 device |
98 |
| - * @cmd: command to execute |
99 |
| - * May be called from atomic context. Returns context pointer, or error |
100 |
| - * Caller must eventually call mlx5_accel_ipsec_sa_cmd_wait from non-atomic |
101 |
| - * context, to cleanup the context pointer |
102 |
| - */ |
103 |
| -void *mlx5_accel_ipsec_sa_cmd_exec(struct mlx5_core_dev *mdev, |
104 |
| - struct mlx5_accel_ipsec_sa *cmd); |
105 |
| - |
106 |
| -/** |
107 |
| - * mlx5_accel_ipsec_sa_cmd_wait - Wait for command execution completion |
108 |
| - * @context: Context pointer returned from call to mlx5_accel_ipsec_sa_cmd_exec |
109 |
| - * Sleeps (killable) until command execution is complete. |
110 |
| - * Returns the command result, or -EINTR if killed |
111 |
| - */ |
112 |
| -int mlx5_accel_ipsec_sa_cmd_wait(void *context); |
113 |
| - |
114 |
| -u32 mlx5_accel_ipsec_device_caps(struct mlx5_core_dev *mdev); |
| 43 | + MLX5_ACCEL_IPSEC_CAP_DEVICE) |
115 | 44 |
|
116 | 45 | unsigned int mlx5_accel_ipsec_counters_count(struct mlx5_core_dev *mdev);
|
117 | 46 | int mlx5_accel_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
|
118 | 47 | unsigned int count);
|
119 | 48 |
|
| 49 | +void *mlx5_accel_esp_create_hw_context(struct mlx5_core_dev *mdev, |
| 50 | + struct mlx5_accel_esp_xfrm *xfrm, |
| 51 | + const __be32 saddr[4], |
| 52 | + const __be32 daddr[4], |
| 53 | + const __be32 spi, bool is_ipv6); |
| 54 | +void mlx5_accel_esp_free_hw_context(void *context); |
| 55 | + |
120 | 56 | int mlx5_accel_ipsec_init(struct mlx5_core_dev *mdev);
|
121 | 57 | void mlx5_accel_ipsec_cleanup(struct mlx5_core_dev *mdev);
|
122 | 58 |
|
123 | 59 | #else
|
124 | 60 |
|
125 | 61 | #define MLX5_IPSEC_DEV(mdev) false
|
126 | 62 |
|
| 63 | +static inline void * |
| 64 | +mlx5_accel_esp_create_hw_context(struct mlx5_core_dev *mdev, |
| 65 | + struct mlx5_accel_esp_xfrm *xfrm, |
| 66 | + const __be32 saddr[4], |
| 67 | + const __be32 daddr[4], |
| 68 | + const __be32 spi, bool is_ipv6) |
| 69 | +{ |
| 70 | + return NULL; |
| 71 | +} |
| 72 | + |
| 73 | +static inline void mlx5_accel_esp_free_hw_context(void *context) |
| 74 | +{ |
| 75 | +} |
| 76 | + |
127 | 77 | static inline int mlx5_accel_ipsec_init(struct mlx5_core_dev *mdev)
|
128 | 78 | {
|
129 | 79 | return 0;
|
|
0 commit comments