xref: /freebsd/sys/dev/mlx5/mlx5_core/mlx5_core.h (revision 7b9b93a8)
1dc7e38acSHans Petter Selasky /*-
27b9b93a8SHans Petter Selasky  * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
3dc7e38acSHans Petter Selasky  *
4dc7e38acSHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
5dc7e38acSHans Petter Selasky  * modification, are permitted provided that the following conditions
6dc7e38acSHans Petter Selasky  * are met:
7dc7e38acSHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
8dc7e38acSHans Petter Selasky  *    notice, this list of conditions and the following disclaimer.
9dc7e38acSHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
10dc7e38acSHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
11dc7e38acSHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
12dc7e38acSHans Petter Selasky  *
13dc7e38acSHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14dc7e38acSHans Petter Selasky  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15dc7e38acSHans Petter Selasky  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16dc7e38acSHans Petter Selasky  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17dc7e38acSHans Petter Selasky  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18dc7e38acSHans Petter Selasky  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19dc7e38acSHans Petter Selasky  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20dc7e38acSHans Petter Selasky  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21dc7e38acSHans Petter Selasky  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22dc7e38acSHans Petter Selasky  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23dc7e38acSHans Petter Selasky  * SUCH DAMAGE.
24dc7e38acSHans Petter Selasky  *
25dc7e38acSHans Petter Selasky  * $FreeBSD$
26dc7e38acSHans Petter Selasky  */
27dc7e38acSHans Petter Selasky 
28dc7e38acSHans Petter Selasky #ifndef __MLX5_CORE_H__
29dc7e38acSHans Petter Selasky #define __MLX5_CORE_H__
30dc7e38acSHans Petter Selasky 
31dc7e38acSHans Petter Selasky #include <linux/types.h>
32dc7e38acSHans Petter Selasky #include <linux/kernel.h>
33dc7e38acSHans Petter Selasky #include <linux/sched.h>
34dc7e38acSHans Petter Selasky 
35dc7e38acSHans Petter Selasky #define DRIVER_NAME "mlx5_core"
3676ee71dcSHans Petter Selasky #ifndef DRIVER_VERSION
377b9b93a8SHans Petter Selasky #define DRIVER_VERSION "3.4.2"
3876ee71dcSHans Petter Selasky #endif
397b9b93a8SHans Petter Selasky #define DRIVER_RELDATE "July 2018"
40dc7e38acSHans Petter Selasky 
41dc7e38acSHans Petter Selasky extern int mlx5_core_debug_mask;
42dc7e38acSHans Petter Selasky 
43dc7e38acSHans Petter Selasky #define mlx5_core_dbg(dev, format, ...)					\
44dc7e38acSHans Petter Selasky 	pr_debug("%s:%s:%d:(pid %d): " format,				\
45dc7e38acSHans Petter Selasky 		 (dev)->priv.name, __func__, __LINE__, curthread->td_proc->p_pid,	\
46dc7e38acSHans Petter Selasky 		 ##__VA_ARGS__)
47dc7e38acSHans Petter Selasky 
48dc7e38acSHans Petter Selasky #define mlx5_core_dbg_mask(dev, mask, format, ...)			\
49dc7e38acSHans Petter Selasky do {									\
50dc7e38acSHans Petter Selasky 	if ((mask) & mlx5_core_debug_mask)				\
51dc7e38acSHans Petter Selasky 		mlx5_core_dbg(dev, format, ##__VA_ARGS__);		\
52dc7e38acSHans Petter Selasky } while (0)
53dc7e38acSHans Petter Selasky 
54fba29462SHans Petter Selasky #define mlx5_core_err(_dev, format, ...)					\
55fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "ERR: ""%s:%d:(pid %d): " format, \
56fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
57dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
58dc7e38acSHans Petter Selasky 
59fba29462SHans Petter Selasky #define mlx5_core_warn(_dev, format, ...)				\
60fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "WARN: ""%s:%d:(pid %d): " format, \
61fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
62dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
63dc7e38acSHans Petter Selasky 
64dc7e38acSHans Petter Selasky enum {
65dc7e38acSHans Petter Selasky 	MLX5_CMD_DATA, /* print command payload only */
66dc7e38acSHans Petter Selasky 	MLX5_CMD_TIME, /* print command execution time */
67dc7e38acSHans Petter Selasky };
68dc7e38acSHans Petter Selasky 
69f20b553dSHans Petter Selasky enum mlx5_semaphore_space_address {
70f20b553dSHans Petter Selasky 	MLX5_SEMAPHORE_SW_RESET		= 0x20,
71f20b553dSHans Petter Selasky };
72f20b553dSHans Petter Selasky 
73cb4e4a6eSHans Petter Selasky struct mlx5_core_dev;
74cb4e4a6eSHans Petter Selasky 
75dc7e38acSHans Petter Selasky int mlx5_query_hca_caps(struct mlx5_core_dev *dev);
76dc7e38acSHans Petter Selasky int mlx5_query_board_id(struct mlx5_core_dev *dev);
77ed0cee0bSHans Petter Selasky int mlx5_query_qcam_reg(struct mlx5_core_dev *mdev, u32 *qcam,
78ed0cee0bSHans Petter Selasky 			u8 feature_group, u8 access_reg_group);
79dc7e38acSHans Petter Selasky int mlx5_cmd_init_hca(struct mlx5_core_dev *dev);
80dc7e38acSHans Petter Selasky int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
81c0902569SHans Petter Selasky int mlx5_cmd_force_teardown_hca(struct mlx5_core_dev *dev);
82a2485fe5SHans Petter Selasky void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
83a2485fe5SHans Petter Selasky 		     unsigned long param);
84c0902569SHans Petter Selasky void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force);
85a2485fe5SHans Petter Selasky void mlx5_disable_device(struct mlx5_core_dev *dev);
864bb7662bSHans Petter Selasky void mlx5_recover_device(struct mlx5_core_dev *dev);
87dc7e38acSHans Petter Selasky 
88dc7e38acSHans Petter Selasky void mlx5e_init(void);
89dc7e38acSHans Petter Selasky void mlx5e_cleanup(void);
90dc7e38acSHans Petter Selasky 
91dc7e38acSHans Petter Selasky int mlx5_rename_eq(struct mlx5_core_dev *dev, int eq_ix, char *name);
92dc7e38acSHans Petter Selasky 
93e808190aSHans Petter Selasky int mlx5_fwdump_init(void);
94e808190aSHans Petter Selasky void mlx5_fwdump_fini(void);
950285276cSHans Petter Selasky void mlx5_fwdump_prep(struct mlx5_core_dev *mdev);
96e808190aSHans Petter Selasky void mlx5_fwdump(struct mlx5_core_dev *mdev);
97e808190aSHans Petter Selasky void mlx5_fwdump_clean(struct mlx5_core_dev *mdev);
98e808190aSHans Petter Selasky 
99e808190aSHans Petter Selasky struct mlx5_crspace_regmap {
100e808190aSHans Petter Selasky 	uint32_t addr;
101e808190aSHans Petter Selasky 	unsigned cnt;
102e808190aSHans Petter Selasky };
103e808190aSHans Petter Selasky 
104e808190aSHans Petter Selasky extern struct pci_driver mlx5_core_driver;
105e808190aSHans Petter Selasky 
106dc7e38acSHans Petter Selasky #endif /* __MLX5_CORE_H__ */
107