1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef __MLX5_ACCEL_H__
35#define __MLX5_ACCEL_H__
36
37#include <linux/mlx5/driver.h>
38
39enum mlx5_accel_esp_aes_gcm_keymat_iv_algo {
40 MLX5_ACCEL_ESP_AES_GCM_IV_ALGO_SEQ,
41};
42
43enum mlx5_accel_esp_flags {
44 MLX5_ACCEL_ESP_FLAGS_TUNNEL = 0,
45 MLX5_ACCEL_ESP_FLAGS_TRANSPORT = 1UL << 0,
46 MLX5_ACCEL_ESP_FLAGS_ESN_TRIGGERED = 1UL << 1,
47 MLX5_ACCEL_ESP_FLAGS_ESN_STATE_OVERLAP = 1UL << 2,
48};
49
50enum mlx5_accel_esp_action {
51 MLX5_ACCEL_ESP_ACTION_DECRYPT,
52 MLX5_ACCEL_ESP_ACTION_ENCRYPT,
53};
54
55enum mlx5_accel_esp_keymats {
56 MLX5_ACCEL_ESP_KEYMAT_AES_NONE,
57 MLX5_ACCEL_ESP_KEYMAT_AES_GCM,
58};
59
60enum mlx5_accel_esp_replay {
61 MLX5_ACCEL_ESP_REPLAY_NONE,
62 MLX5_ACCEL_ESP_REPLAY_BMP,
63};
64
65struct aes_gcm_keymat {
66 u64 seq_iv;
67 enum mlx5_accel_esp_aes_gcm_keymat_iv_algo iv_algo;
68
69 u32 salt;
70 u32 icv_len;
71
72 u32 key_len;
73 u32 aes_key[256 / 32];
74};
75
76struct mlx5_accel_esp_xfrm_attrs {
77 enum mlx5_accel_esp_action action;
78 u32 esn;
79 u32 spi;
80 u32 seq;
81 u32 tfc_pad;
82 u32 flags;
83 u32 sa_handle;
84 enum mlx5_accel_esp_replay replay_type;
85 union {
86 struct {
87 u32 size;
88
89 } bmp;
90 } replay;
91 enum mlx5_accel_esp_keymats keymat_type;
92 union {
93 struct aes_gcm_keymat aes_gcm;
94 } keymat;
95};
96
97struct mlx5_accel_esp_xfrm {
98 struct mlx5_core_dev *mdev;
99 struct mlx5_accel_esp_xfrm_attrs attrs;
100};
101
102enum {
103 MLX5_ACCEL_XFRM_FLAG_REQUIRE_METADATA = 1UL << 0,
104};
105
106enum mlx5_accel_ipsec_cap {
107 MLX5_ACCEL_IPSEC_CAP_DEVICE = 1 << 0,
108 MLX5_ACCEL_IPSEC_CAP_REQUIRED_METADATA = 1 << 1,
109 MLX5_ACCEL_IPSEC_CAP_ESP = 1 << 2,
110 MLX5_ACCEL_IPSEC_CAP_IPV6 = 1 << 3,
111 MLX5_ACCEL_IPSEC_CAP_LSO = 1 << 4,
112 MLX5_ACCEL_IPSEC_CAP_RX_NO_TRAILER = 1 << 5,
113 MLX5_ACCEL_IPSEC_CAP_ESN = 1 << 6,
114 MLX5_ACCEL_IPSEC_CAP_TX_IV_IS_ESN = 1 << 7,
115};
116
117#ifdef CONFIG_MLX5_FPGA_IPSEC
118
119u32 mlx5_accel_ipsec_device_caps(struct mlx5_core_dev *mdev);
120
121struct mlx5_accel_esp_xfrm *
122mlx5_accel_esp_create_xfrm(struct mlx5_core_dev *mdev,
123 const struct mlx5_accel_esp_xfrm_attrs *attrs,
124 u32 flags);
125void mlx5_accel_esp_destroy_xfrm(struct mlx5_accel_esp_xfrm *xfrm);
126int mlx5_accel_esp_modify_xfrm(struct mlx5_accel_esp_xfrm *xfrm,
127 const struct mlx5_accel_esp_xfrm_attrs *attrs);
128
129#else
130
131static inline u32 mlx5_accel_ipsec_device_caps(struct mlx5_core_dev *mdev) { return 0; }
132
133static inline struct mlx5_accel_esp_xfrm *
134mlx5_accel_esp_create_xfrm(struct mlx5_core_dev *mdev,
135 const struct mlx5_accel_esp_xfrm_attrs *attrs,
136 u32 flags) { return ERR_PTR(-EOPNOTSUPP); }
137static inline void
138mlx5_accel_esp_destroy_xfrm(struct mlx5_accel_esp_xfrm *xfrm) {}
139static inline int
140mlx5_accel_esp_modify_xfrm(struct mlx5_accel_esp_xfrm *xfrm,
141 const struct mlx5_accel_esp_xfrm_attrs *attrs) { return -EOPNOTSUPP; }
142
143#endif
144#endif
145