xref: /freebsd/sys/dev/mlx5/mlx5_core/mlx5_core.h (revision 939c79a2)
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 
3520a63539SHans Petter Selasky #include <dev/mlxfw/mlxfw.h>
3620a63539SHans Petter Selasky 
37dc7e38acSHans Petter Selasky #define DRIVER_NAME "mlx5_core"
3876ee71dcSHans Petter Selasky #ifndef DRIVER_VERSION
390f3b263dSSlava Shwartsman #define DRIVER_VERSION "3.5.0"
4076ee71dcSHans Petter Selasky #endif
410f3b263dSSlava Shwartsman #define DRIVER_RELDATE "November 2018"
42dc7e38acSHans Petter Selasky 
43dc7e38acSHans Petter Selasky extern int mlx5_core_debug_mask;
44dc7e38acSHans Petter Selasky 
45dc7e38acSHans Petter Selasky #define mlx5_core_dbg(dev, format, ...)					\
46dc7e38acSHans Petter Selasky 	pr_debug("%s:%s:%d:(pid %d): " format,				\
47dc7e38acSHans Petter Selasky 		 (dev)->priv.name, __func__, __LINE__, curthread->td_proc->p_pid,	\
48dc7e38acSHans Petter Selasky 		 ##__VA_ARGS__)
49dc7e38acSHans Petter Selasky 
50dc7e38acSHans Petter Selasky #define mlx5_core_dbg_mask(dev, mask, format, ...)			\
51dc7e38acSHans Petter Selasky do {									\
52dc7e38acSHans Petter Selasky 	if ((mask) & mlx5_core_debug_mask)				\
53dc7e38acSHans Petter Selasky 		mlx5_core_dbg(dev, format, ##__VA_ARGS__);		\
54dc7e38acSHans Petter Selasky } while (0)
55dc7e38acSHans Petter Selasky 
56fba29462SHans Petter Selasky #define mlx5_core_err(_dev, format, ...)					\
57fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "ERR: ""%s:%d:(pid %d): " format, \
58fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
59dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
60dc7e38acSHans Petter Selasky 
61fba29462SHans Petter Selasky #define mlx5_core_warn(_dev, format, ...)				\
62fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "WARN: ""%s:%d:(pid %d): " format, \
63fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
64dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
65dc7e38acSHans Petter Selasky 
66dc7e38acSHans Petter Selasky enum {
67dc7e38acSHans Petter Selasky 	MLX5_CMD_DATA, /* print command payload only */
68dc7e38acSHans Petter Selasky 	MLX5_CMD_TIME, /* print command execution time */
69dc7e38acSHans Petter Selasky };
70dc7e38acSHans Petter Selasky 
71f20b553dSHans Petter Selasky enum mlx5_semaphore_space_address {
72f20b553dSHans Petter Selasky 	MLX5_SEMAPHORE_SW_RESET		= 0x20,
73f20b553dSHans Petter Selasky };
74f20b553dSHans Petter Selasky 
75cb4e4a6eSHans Petter Selasky struct mlx5_core_dev;
76cb4e4a6eSHans Petter Selasky 
77dc7e38acSHans Petter Selasky int mlx5_query_hca_caps(struct mlx5_core_dev *dev);
78dc7e38acSHans Petter Selasky int mlx5_query_board_id(struct mlx5_core_dev *dev);
79ed0cee0bSHans Petter Selasky int mlx5_query_qcam_reg(struct mlx5_core_dev *mdev, u32 *qcam,
80ed0cee0bSHans Petter Selasky 			u8 feature_group, u8 access_reg_group);
810358212dSHans Petter Selasky int mlx5_query_pcam_reg(struct mlx5_core_dev *dev, u32 *pcam,
820358212dSHans Petter Selasky 			u8 feature_group, u8 access_reg_group);
830358212dSHans Petter Selasky int mlx5_query_mcam_reg(struct mlx5_core_dev *dev, u32 *mcap,
840358212dSHans Petter Selasky 			u8 feature_group, u8 access_reg_group);
85939c79a2SHans Petter Selasky int mlx5_query_mfrl_reg(struct mlx5_core_dev *mdev, u8 *reset_level);
86939c79a2SHans Petter Selasky int mlx5_set_mfrl_reg(struct mlx5_core_dev *mdev, u8 reset_level);
87dc7e38acSHans Petter Selasky int mlx5_cmd_init_hca(struct mlx5_core_dev *dev);
88dc7e38acSHans Petter Selasky int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
89c0902569SHans Petter Selasky int mlx5_cmd_force_teardown_hca(struct mlx5_core_dev *dev);
90a4130a34SHans Petter Selasky int mlx5_cmd_fast_teardown_hca(struct mlx5_core_dev *dev);
91a2485fe5SHans Petter Selasky void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
92a2485fe5SHans Petter Selasky 		     unsigned long param);
93c0902569SHans Petter Selasky void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force);
94a2485fe5SHans Petter Selasky void mlx5_disable_device(struct mlx5_core_dev *dev);
954bb7662bSHans Petter Selasky void mlx5_recover_device(struct mlx5_core_dev *dev);
96dc7e38acSHans Petter Selasky 
97e9dcd831SSlava Shwartsman int mlx5_register_device(struct mlx5_core_dev *dev);
98e9dcd831SSlava Shwartsman void mlx5_unregister_device(struct mlx5_core_dev *dev);
99e9dcd831SSlava Shwartsman 
10020a63539SHans Petter Selasky int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw);
10120a63539SHans Petter Selasky 
102dc7e38acSHans Petter Selasky void mlx5e_init(void);
103dc7e38acSHans Petter Selasky void mlx5e_cleanup(void);
104dc7e38acSHans Petter Selasky 
105dc7e38acSHans Petter Selasky int mlx5_rename_eq(struct mlx5_core_dev *dev, int eq_ix, char *name);
106dc7e38acSHans Petter Selasky 
107e808190aSHans Petter Selasky int mlx5_fwdump_init(void);
108e808190aSHans Petter Selasky void mlx5_fwdump_fini(void);
1090285276cSHans Petter Selasky void mlx5_fwdump_prep(struct mlx5_core_dev *mdev);
110e808190aSHans Petter Selasky void mlx5_fwdump(struct mlx5_core_dev *mdev);
111e808190aSHans Petter Selasky void mlx5_fwdump_clean(struct mlx5_core_dev *mdev);
112e808190aSHans Petter Selasky 
113e808190aSHans Petter Selasky struct mlx5_crspace_regmap {
114e808190aSHans Petter Selasky 	uint32_t addr;
115e808190aSHans Petter Selasky 	unsigned cnt;
116e808190aSHans Petter Selasky };
117e808190aSHans Petter Selasky 
118e808190aSHans Petter Selasky extern struct pci_driver mlx5_core_driver;
119e808190aSHans Petter Selasky 
1208f7f0736SSlava Shwartsman SYSCTL_DECL(_hw_mlx5);
1218f7f0736SSlava Shwartsman 
122ba11bcecSHans Petter Selasky enum {
123ba11bcecSHans Petter Selasky 	MLX5_NIC_IFC_FULL		= 0,
124ba11bcecSHans Petter Selasky 	MLX5_NIC_IFC_DISABLED		= 1,
125ba11bcecSHans Petter Selasky 	MLX5_NIC_IFC_NO_DRAM_NIC	= 2,
126ba11bcecSHans Petter Selasky 	MLX5_NIC_IFC_INVALID		= 3,
127ba11bcecSHans Petter Selasky 	MLX5_NIC_IFC_SW_RESET		= 7,
128ba11bcecSHans Petter Selasky };
129ba11bcecSHans Petter Selasky 
130ba11bcecSHans Petter Selasky u8 mlx5_get_nic_state(struct mlx5_core_dev *dev);
131ba11bcecSHans Petter Selasky void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state);
132ba11bcecSHans Petter Selasky 
133dc7e38acSHans Petter Selasky #endif /* __MLX5_CORE_H__ */
134