xref: /freebsd/sys/dev/mlx5/mlx5_core/mlx5_core.h (revision 0285276c)
1dc7e38acSHans Petter Selasky /*-
2dc7e38acSHans Petter Selasky  * Copyright (c) 2013-2015, 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"
36dc7e38acSHans Petter Selasky #define DRIVER_VERSION "1.23.0 (03 Mar 2015)"
37dc7e38acSHans Petter Selasky #define DRIVER_RELDATE "03 Mar 2015"
38dc7e38acSHans Petter Selasky 
39dc7e38acSHans Petter Selasky extern int mlx5_core_debug_mask;
40dc7e38acSHans Petter Selasky 
41dc7e38acSHans Petter Selasky #define mlx5_core_dbg(dev, format, ...)					\
42dc7e38acSHans Petter Selasky 	pr_debug("%s:%s:%d:(pid %d): " format,				\
43dc7e38acSHans Petter Selasky 		 (dev)->priv.name, __func__, __LINE__, curthread->td_proc->p_pid,	\
44dc7e38acSHans Petter Selasky 		 ##__VA_ARGS__)
45dc7e38acSHans Petter Selasky 
46dc7e38acSHans Petter Selasky #define mlx5_core_dbg_mask(dev, mask, format, ...)			\
47dc7e38acSHans Petter Selasky do {									\
48dc7e38acSHans Petter Selasky 	if ((mask) & mlx5_core_debug_mask)				\
49dc7e38acSHans Petter Selasky 		mlx5_core_dbg(dev, format, ##__VA_ARGS__);		\
50dc7e38acSHans Petter Selasky } while (0)
51dc7e38acSHans Petter Selasky 
52fba29462SHans Petter Selasky #define mlx5_core_err(_dev, format, ...)					\
53fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "ERR: ""%s:%d:(pid %d): " format, \
54fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
55dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
56dc7e38acSHans Petter Selasky 
57fba29462SHans Petter Selasky #define mlx5_core_warn(_dev, format, ...)				\
58fba29462SHans Petter Selasky 	device_printf((&(_dev)->pdev->dev)->bsddev, "WARN: ""%s:%d:(pid %d): " format, \
59fba29462SHans Petter Selasky 		__func__, __LINE__, curthread->td_proc->p_pid, \
60dc7e38acSHans Petter Selasky 		##__VA_ARGS__)
61dc7e38acSHans Petter Selasky 
62dc7e38acSHans Petter Selasky enum {
63dc7e38acSHans Petter Selasky 	MLX5_CMD_DATA, /* print command payload only */
64dc7e38acSHans Petter Selasky 	MLX5_CMD_TIME, /* print command execution time */
65dc7e38acSHans Petter Selasky };
66dc7e38acSHans Petter Selasky 
67cb4e4a6eSHans Petter Selasky struct mlx5_core_dev;
68cb4e4a6eSHans Petter Selasky 
69dc7e38acSHans Petter Selasky int mlx5_query_hca_caps(struct mlx5_core_dev *dev);
70dc7e38acSHans Petter Selasky int mlx5_query_board_id(struct mlx5_core_dev *dev);
71dc7e38acSHans Petter Selasky int mlx5_cmd_init_hca(struct mlx5_core_dev *dev);
72dc7e38acSHans Petter Selasky int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
73a2485fe5SHans Petter Selasky void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
74a2485fe5SHans Petter Selasky 		     unsigned long param);
75a2485fe5SHans Petter Selasky void mlx5_enter_error_state(struct mlx5_core_dev *dev);
76a2485fe5SHans Petter Selasky void mlx5_disable_device(struct mlx5_core_dev *dev);
77dc7e38acSHans Petter Selasky 
78dc7e38acSHans Petter Selasky void mlx5e_init(void);
79dc7e38acSHans Petter Selasky void mlx5e_cleanup(void);
80dc7e38acSHans Petter Selasky 
81dc7e38acSHans Petter Selasky int mlx5_rename_eq(struct mlx5_core_dev *dev, int eq_ix, char *name);
82dc7e38acSHans Petter Selasky 
83e808190aSHans Petter Selasky int mlx5_fwdump_init(void);
84e808190aSHans Petter Selasky void mlx5_fwdump_fini(void);
850285276cSHans Petter Selasky void mlx5_fwdump_prep(struct mlx5_core_dev *mdev);
86e808190aSHans Petter Selasky void mlx5_fwdump(struct mlx5_core_dev *mdev);
87e808190aSHans Petter Selasky void mlx5_fwdump_clean(struct mlx5_core_dev *mdev);
88e808190aSHans Petter Selasky 
89e808190aSHans Petter Selasky struct mlx5_crspace_regmap {
90e808190aSHans Petter Selasky 	uint32_t addr;
91e808190aSHans Petter Selasky 	unsigned cnt;
92e808190aSHans Petter Selasky };
93e808190aSHans Petter Selasky 
94e808190aSHans Petter Selasky extern struct pci_driver mlx5_core_driver;
95e808190aSHans Petter Selasky 
96dc7e38acSHans Petter Selasky #endif /* __MLX5_CORE_H__ */
97