xref: /freebsd/sys/dev/mlx5/mlx5_fpga/trans.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*e9dcd831SSlava Shwartsman /*-
2*e9dcd831SSlava Shwartsman  * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
3*e9dcd831SSlava Shwartsman  *
4*e9dcd831SSlava Shwartsman  * This software is available to you under a choice of one of two
5*e9dcd831SSlava Shwartsman  * licenses.  You may choose to be licensed under the terms of the GNU
6*e9dcd831SSlava Shwartsman  * General Public License (GPL) Version 2, available from the file
7*e9dcd831SSlava Shwartsman  * COPYING in the main directory of this source tree, or the
8*e9dcd831SSlava Shwartsman  * OpenIB.org BSD license below:
9*e9dcd831SSlava Shwartsman  *
10*e9dcd831SSlava Shwartsman  *     Redistribution and use in source and binary forms, with or
11*e9dcd831SSlava Shwartsman  *     without modification, are permitted provided that the following
12*e9dcd831SSlava Shwartsman  *     conditions are met:
13*e9dcd831SSlava Shwartsman  *
14*e9dcd831SSlava Shwartsman  *      - Redistributions of source code must retain the above
15*e9dcd831SSlava Shwartsman  *        copyright notice, this list of conditions and the following
16*e9dcd831SSlava Shwartsman  *        disclaimer.
17*e9dcd831SSlava Shwartsman  *
18*e9dcd831SSlava Shwartsman  *      - Redistributions in binary form must reproduce the above
19*e9dcd831SSlava Shwartsman  *        copyright notice, this list of conditions and the following
20*e9dcd831SSlava Shwartsman  *        disclaimer in the documentation and/or other materials
21*e9dcd831SSlava Shwartsman  *        provided with the distribution.
22*e9dcd831SSlava Shwartsman  *
23*e9dcd831SSlava Shwartsman  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24*e9dcd831SSlava Shwartsman  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25*e9dcd831SSlava Shwartsman  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26*e9dcd831SSlava Shwartsman  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27*e9dcd831SSlava Shwartsman  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28*e9dcd831SSlava Shwartsman  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29*e9dcd831SSlava Shwartsman  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30*e9dcd831SSlava Shwartsman  * SOFTWARE.
31*e9dcd831SSlava Shwartsman  */
32*e9dcd831SSlava Shwartsman 
33*e9dcd831SSlava Shwartsman #ifndef __MLX5_FPGA_TRANS_H__
34*e9dcd831SSlava Shwartsman #define __MLX5_FPGA_TRANS_H__
35*e9dcd831SSlava Shwartsman 
36*e9dcd831SSlava Shwartsman #include <dev/mlx5/mlx5_fpga/sdk.h>
37*e9dcd831SSlava Shwartsman #include <dev/mlx5/mlx5_fpga/core.h>
38*e9dcd831SSlava Shwartsman 
39*e9dcd831SSlava Shwartsman #define MLX5_FPGA_TRANSACTION_MAX_SIZE 1008
40*e9dcd831SSlava Shwartsman #define MLX5_FPGA_TRANSACTION_SEND_ALIGN_BITS 3
41*e9dcd831SSlava Shwartsman #define MLX5_FPGA_TRANSACTION_SEND_PAGE_BITS 12
42*e9dcd831SSlava Shwartsman #define MLX5_FPGA_TID_COUNT 256
43*e9dcd831SSlava Shwartsman 
44*e9dcd831SSlava Shwartsman enum mlx5_fpga_direction {
45*e9dcd831SSlava Shwartsman 	MLX5_FPGA_READ,
46*e9dcd831SSlava Shwartsman 	MLX5_FPGA_WRITE,
47*e9dcd831SSlava Shwartsman };
48*e9dcd831SSlava Shwartsman 
49*e9dcd831SSlava Shwartsman struct mlx5_fpga_transaction {
50*e9dcd831SSlava Shwartsman 	struct mlx5_fpga_conn *conn;
51*e9dcd831SSlava Shwartsman 	enum mlx5_fpga_direction direction;
52*e9dcd831SSlava Shwartsman 	size_t size;
53*e9dcd831SSlava Shwartsman 	u64 addr;
54*e9dcd831SSlava Shwartsman 	u8 *data;
55*e9dcd831SSlava Shwartsman 	void (*complete1)(const struct mlx5_fpga_transaction *complete,
56*e9dcd831SSlava Shwartsman 			 u8 status);
57*e9dcd831SSlava Shwartsman };
58*e9dcd831SSlava Shwartsman 
59*e9dcd831SSlava Shwartsman int mlx5_fpga_trans_device_init(struct mlx5_fpga_device *fdev);
60*e9dcd831SSlava Shwartsman void mlx5_fpga_trans_device_cleanup(struct mlx5_fpga_device *fdev);
61*e9dcd831SSlava Shwartsman int mlx5_fpga_trans_exec(const struct mlx5_fpga_transaction *trans);
62*e9dcd831SSlava Shwartsman void mlx5_fpga_trans_recv(void *cb_arg, struct mlx5_fpga_dma_buf *buf);
63*e9dcd831SSlava Shwartsman 
64*e9dcd831SSlava Shwartsman #endif /* __MLX_FPGA_TRANS_H__ */
65