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