Lines Matching +full:fpga +full:- +full:2
1 /*-
6 * General Public License (GPL) Version 2, available from the file
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
45 MLX5_IPSEC_RESPONSE_SADB_ISSUE = 2,
80 if (!mdev->fpga || !MLX5_CAP_GEN(mdev, fpga)) in mlx5_fpga_is_ipsec_device()
106 context->status = MLX5_FPGA_IPSEC_SACMD_SEND_FAIL; in mlx5_fpga_ipsec_send_complete()
107 complete(&context->complete); in mlx5_fpga_ipsec_send_complete()
117 return -EEXIST; in syndrome_to_errno()
119 return -EINVAL; in syndrome_to_errno()
121 return -EIO; in syndrome_to_errno()
123 return -EIO; in syndrome_to_errno()
128 struct mlx5_ipsec_sadb_resp *resp = buf->sg[0].data; in mlx5_fpga_ipsec_recv()
134 if (buf->sg[0].size < sizeof(*resp)) { in mlx5_fpga_ipsec_recv()
135 mlx5_fpga_warn(fdev, "Short receive from FPGA IPSec: %u < %zu bytes\n", in mlx5_fpga_ipsec_recv()
136 buf->sg[0].size, sizeof(*resp)); in mlx5_fpga_ipsec_recv()
141 ntohl(resp->syndrome), ntohl(resp->sw_sa_handle)); in mlx5_fpga_ipsec_recv()
143 spin_lock_irqsave(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_recv()
144 context = list_first_entry_or_null(&fdev->ipsec->pending_cmds, in mlx5_fpga_ipsec_recv()
148 list_del(&context->list); in mlx5_fpga_ipsec_recv()
149 spin_unlock_irqrestore(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_recv()
157 if (context->sa.sw_sa_handle != resp->sw_sa_handle) { in mlx5_fpga_ipsec_recv()
159 ntohl(context->sa.sw_sa_handle), in mlx5_fpga_ipsec_recv()
160 ntohl(resp->sw_sa_handle)); in mlx5_fpga_ipsec_recv()
164 syndrome = ntohl(resp->syndrome); in mlx5_fpga_ipsec_recv()
165 context->status_code = syndrome_to_errno(syndrome); in mlx5_fpga_ipsec_recv()
166 context->status = MLX5_FPGA_IPSEC_SACMD_COMPLETE; in mlx5_fpga_ipsec_recv()
168 if (context->status_code) in mlx5_fpga_ipsec_recv()
171 complete(&context->complete); in mlx5_fpga_ipsec_recv()
178 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_sa_cmd_exec()
183 if (!fdev || !fdev->ipsec) in mlx5_fpga_ipsec_sa_cmd_exec()
184 return ERR_PTR(-EOPNOTSUPP); in mlx5_fpga_ipsec_sa_cmd_exec()
188 return ERR_PTR(-ENOMEM); in mlx5_fpga_ipsec_sa_cmd_exec()
190 memcpy(&context->sa, cmd, sizeof(*cmd)); in mlx5_fpga_ipsec_sa_cmd_exec()
191 context->buf.complete = mlx5_fpga_ipsec_send_complete; in mlx5_fpga_ipsec_sa_cmd_exec()
192 context->buf.sg[0].size = sizeof(context->sa); in mlx5_fpga_ipsec_sa_cmd_exec()
193 context->buf.sg[0].data = &context->sa; in mlx5_fpga_ipsec_sa_cmd_exec()
194 init_completion(&context->complete); in mlx5_fpga_ipsec_sa_cmd_exec()
195 context->dev = fdev; in mlx5_fpga_ipsec_sa_cmd_exec()
196 spin_lock_irqsave(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_sa_cmd_exec()
197 list_add_tail(&context->list, &fdev->ipsec->pending_cmds); in mlx5_fpga_ipsec_sa_cmd_exec()
198 spin_unlock_irqrestore(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_sa_cmd_exec()
200 context->status = MLX5_FPGA_IPSEC_SACMD_PENDING; in mlx5_fpga_ipsec_sa_cmd_exec()
202 res = mlx5_fpga_sbu_conn_sendmsg(fdev->ipsec->conn, &context->buf); in mlx5_fpga_ipsec_sa_cmd_exec()
206 spin_lock_irqsave(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_sa_cmd_exec()
207 list_del(&context->list); in mlx5_fpga_ipsec_sa_cmd_exec()
208 spin_unlock_irqrestore(&fdev->ipsec->pending_cmds_lock, flags); in mlx5_fpga_ipsec_sa_cmd_exec()
221 res = wait_for_completion/*_killable XXXKIB*/(&context->complete); in mlx5_fpga_ipsec_sa_cmd_wait()
223 mlx5_fpga_warn(context->dev, "Failure waiting for IPSec command response\n"); in mlx5_fpga_ipsec_sa_cmd_wait()
224 return -EINTR; in mlx5_fpga_ipsec_sa_cmd_wait()
227 if (context->status == MLX5_FPGA_IPSEC_SACMD_COMPLETE) in mlx5_fpga_ipsec_sa_cmd_wait()
228 res = context->status_code; in mlx5_fpga_ipsec_sa_cmd_wait()
230 res = -EIO; in mlx5_fpga_ipsec_sa_cmd_wait()
238 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_device_caps()
246 if (!fdev->ipsec) in mlx5_fpga_ipsec_device_caps()
249 if (MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, esp)) in mlx5_fpga_ipsec_device_caps()
252 if (MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, ipv6)) in mlx5_fpga_ipsec_device_caps()
255 if (MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, lso)) in mlx5_fpga_ipsec_device_caps()
263 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_counters_count()
265 if (!fdev || !fdev->ipsec) in mlx5_fpga_ipsec_counters_count()
268 return MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, in mlx5_fpga_ipsec_counters_count()
275 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_counters_read()
282 if (!fdev || !fdev->ipsec) in mlx5_fpga_ipsec_counters_read()
285 addr = (u64)MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, in mlx5_fpga_ipsec_counters_read()
287 ((u64)MLX5_GET(ipsec_extended_cap, fdev->ipsec->caps, in mlx5_fpga_ipsec_counters_read()
292 data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL); in mlx5_fpga_ipsec_counters_read()
294 ret = -ENOMEM; in mlx5_fpga_ipsec_counters_read()
310 /* Each counter is low word, then high. But each word is big-endian */ in mlx5_fpga_ipsec_counters_read()
312 counters[i] = (u64)ntohl(data[i * 2]) | in mlx5_fpga_ipsec_counters_read()
313 ((u64)ntohl(data[i * 2 + 1]) << 32); in mlx5_fpga_ipsec_counters_read()
323 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_init()
330 fdev->ipsec = kzalloc(sizeof(*fdev->ipsec), GFP_KERNEL); in mlx5_fpga_ipsec_init()
331 if (!fdev->ipsec) in mlx5_fpga_ipsec_init()
332 return -ENOMEM; in mlx5_fpga_ipsec_init()
334 err = mlx5_fpga_get_sbu_caps(fdev, sizeof(fdev->ipsec->caps), in mlx5_fpga_ipsec_init()
335 fdev->ipsec->caps); in mlx5_fpga_ipsec_init()
342 INIT_LIST_HEAD(&fdev->ipsec->pending_cmds); in mlx5_fpga_ipsec_init()
343 spin_lock_init(&fdev->ipsec->pending_cmds_lock); in mlx5_fpga_ipsec_init()
356 fdev->ipsec->conn = conn; in mlx5_fpga_ipsec_init()
360 kfree(fdev->ipsec); in mlx5_fpga_ipsec_init()
361 fdev->ipsec = NULL; in mlx5_fpga_ipsec_init()
367 struct mlx5_fpga_device *fdev = mdev->fpga; in mlx5_fpga_ipsec_cleanup()
372 mlx5_fpga_sbu_conn_destroy(fdev->ipsec->conn); in mlx5_fpga_ipsec_cleanup()
373 kfree(fdev->ipsec); in mlx5_fpga_ipsec_cleanup()
374 fdev->ipsec = NULL; in mlx5_fpga_ipsec_cleanup()