1215 lines · 31.3 KB · C
RawDownload
/* * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses.  You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * *     Redistribution and use in source and binary forms, with or *     without modification, are permitted provided that the following *     conditions are met: * *      - Redistributions of source code must retain the above *        copyright notice, this list of conditions and the following *        disclaimer. * *      - Redistributions in binary form must reproduce the above *        copyright notice, this list of conditions and the following *        disclaimer in the documentation and/or other materials *        provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef MLX5_DRIVER_H#define MLX5_DRIVER_H #include <linux/kernel.h>#include <linux/completion.h>#include <linux/pci.h>#include <linux/irq.h>#include <linux/spinlock_types.h>#include <linux/semaphore.h>#include <linux/slab.h>#include <linux/vmalloc.h>#include <linux/xarray.h>#include <linux/workqueue.h>#include <linux/mempool.h>#include <linux/interrupt.h>#include <linux/idr.h>#include <linux/notifier.h>#include <linux/refcount.h> #include <linux/mlx5/device.h>#include <linux/mlx5/doorbell.h>#include <linux/mlx5/eq.h>#include <linux/timecounter.h>#include <linux/ptp_clock_kernel.h>#include <net/devlink.h> enum {	MLX5_BOARD_ID_LEN = 64,}; enum {	/* one minute for the sake of bringup. Generally, commands must always	 * complete and we may need to increase this timeout value	 */	MLX5_CMD_TIMEOUT_MSEC	= 60 * 1000,	MLX5_CMD_WQ_MAX_NAME	= 32,}; enum {	CMD_OWNER_SW		= 0x0,	CMD_OWNER_HW		= 0x1,	CMD_STATUS_SUCCESS	= 0,}; enum mlx5_sqp_t {	MLX5_SQP_SMI		= 0,	MLX5_SQP_GSI		= 1,	MLX5_SQP_IEEE_1588	= 2,	MLX5_SQP_SNIFFER	= 3,	MLX5_SQP_SYNC_UMR	= 4,}; enum {	MLX5_MAX_PORTS	= 2,}; enum {	MLX5_ATOMIC_MODE_OFFSET = 16,	MLX5_ATOMIC_MODE_IB_COMP = 1,	MLX5_ATOMIC_MODE_CX = 2,	MLX5_ATOMIC_MODE_8B = 3,	MLX5_ATOMIC_MODE_16B = 4,	MLX5_ATOMIC_MODE_32B = 5,	MLX5_ATOMIC_MODE_64B = 6,	MLX5_ATOMIC_MODE_128B = 7,	MLX5_ATOMIC_MODE_256B = 8,}; enum {	MLX5_REG_QPTS            = 0x4002,	MLX5_REG_QETCR		 = 0x4005,	MLX5_REG_QTCT		 = 0x400a,	MLX5_REG_QPDPM           = 0x4013,	MLX5_REG_QCAM            = 0x4019,	MLX5_REG_DCBX_PARAM      = 0x4020,	MLX5_REG_DCBX_APP        = 0x4021,	MLX5_REG_FPGA_CAP	 = 0x4022,	MLX5_REG_FPGA_CTRL	 = 0x4023,	MLX5_REG_FPGA_ACCESS_REG = 0x4024,	MLX5_REG_CORE_DUMP	 = 0x402e,	MLX5_REG_PCAP		 = 0x5001,	MLX5_REG_PMTU		 = 0x5003,	MLX5_REG_PTYS		 = 0x5004,	MLX5_REG_PAOS		 = 0x5006,	MLX5_REG_PFCC            = 0x5007,	MLX5_REG_PPCNT		 = 0x5008,	MLX5_REG_PPTB            = 0x500b,	MLX5_REG_PBMC            = 0x500c,	MLX5_REG_PMAOS		 = 0x5012,	MLX5_REG_PUDE		 = 0x5009,	MLX5_REG_PMPE		 = 0x5010,	MLX5_REG_PELC		 = 0x500e,	MLX5_REG_PVLC		 = 0x500f,	MLX5_REG_PCMR		 = 0x5041,	MLX5_REG_PMLP		 = 0x5002,	MLX5_REG_PPLM		 = 0x5023,	MLX5_REG_PCAM		 = 0x507f,	MLX5_REG_NODE_DESC	 = 0x6001,	MLX5_REG_HOST_ENDIANNESS = 0x7004,	MLX5_REG_MCIA		 = 0x9014,	MLX5_REG_MFRL		 = 0x9028,	MLX5_REG_MLCR		 = 0x902b,	MLX5_REG_MTRC_CAP	 = 0x9040,	MLX5_REG_MTRC_CONF	 = 0x9041,	MLX5_REG_MTRC_STDB	 = 0x9042,	MLX5_REG_MTRC_CTRL	 = 0x9043,	MLX5_REG_MPEIN		 = 0x9050,	MLX5_REG_MPCNT		 = 0x9051,	MLX5_REG_MTPPS		 = 0x9053,	MLX5_REG_MTPPSE		 = 0x9054,	MLX5_REG_MPEGC		 = 0x9056,	MLX5_REG_MCQS		 = 0x9060,	MLX5_REG_MCQI		 = 0x9061,	MLX5_REG_MCC		 = 0x9062,	MLX5_REG_MCDA		 = 0x9063,	MLX5_REG_MCAM		 = 0x907f,	MLX5_REG_MIRC		 = 0x9162,	MLX5_REG_SBCAM		 = 0xB01F,	MLX5_REG_RESOURCE_DUMP   = 0xC000,}; enum mlx5_qpts_trust_state {	MLX5_QPTS_TRUST_PCP  = 1,	MLX5_QPTS_TRUST_DSCP = 2,}; enum mlx5_dcbx_oper_mode {	MLX5E_DCBX_PARAM_VER_OPER_HOST  = 0x0,	MLX5E_DCBX_PARAM_VER_OPER_AUTO  = 0x3,}; enum {	MLX5_ATOMIC_OPS_CMP_SWAP	= 1 << 0,	MLX5_ATOMIC_OPS_FETCH_ADD	= 1 << 1,	MLX5_ATOMIC_OPS_EXTENDED_CMP_SWAP = 1 << 2,	MLX5_ATOMIC_OPS_EXTENDED_FETCH_ADD = 1 << 3,}; enum mlx5_page_fault_resume_flags {	MLX5_PAGE_FAULT_RESUME_REQUESTOR = 1 << 0,	MLX5_PAGE_FAULT_RESUME_WRITE	 = 1 << 1,	MLX5_PAGE_FAULT_RESUME_RDMA	 = 1 << 2,	MLX5_PAGE_FAULT_RESUME_ERROR	 = 1 << 7,}; enum dbg_rsc_type {	MLX5_DBG_RSC_QP,	MLX5_DBG_RSC_EQ,	MLX5_DBG_RSC_CQ,}; enum port_state_policy {	MLX5_POLICY_DOWN	= 0,	MLX5_POLICY_UP		= 1,	MLX5_POLICY_FOLLOW	= 2,	MLX5_POLICY_INVALID	= 0xffffffff}; enum mlx5_coredev_type {	MLX5_COREDEV_PF,	MLX5_COREDEV_VF}; struct mlx5_field_desc {	int			i;}; struct mlx5_rsc_debug {	struct mlx5_core_dev   *dev;	void		       *object;	enum dbg_rsc_type	type;	struct dentry	       *root;	struct mlx5_field_desc	fields[];}; enum mlx5_dev_event {	MLX5_DEV_EVENT_SYS_ERROR = 128, /* 0 - 127 are FW events */	MLX5_DEV_EVENT_PORT_AFFINITY = 129,}; enum mlx5_port_status {	MLX5_PORT_UP        = 1,	MLX5_PORT_DOWN      = 2,}; enum mlx5_cmdif_state {	MLX5_CMDIF_STATE_UNINITIALIZED,	MLX5_CMDIF_STATE_UP,	MLX5_CMDIF_STATE_DOWN,}; struct mlx5_cmd_first {	__be32		data[4];}; struct mlx5_cmd_msg {	struct list_head		list;	struct cmd_msg_cache	       *parent;	u32				len;	struct mlx5_cmd_first		first;	struct mlx5_cmd_mailbox	       *next;}; struct mlx5_cmd_debug {	struct dentry	       *dbg_root;	void		       *in_msg;	void		       *out_msg;	u8			status;	u16			inlen;	u16			outlen;}; struct cmd_msg_cache {	/* protect block chain allocations	 */	spinlock_t		lock;	struct list_head	head;	unsigned int		max_inbox_size;	unsigned int		num_ent;}; enum {	MLX5_NUM_COMMAND_CACHES = 5,}; struct mlx5_cmd_stats {	u64		sum;	u64		n;	struct dentry  *root;	/* protect command average calculations */	spinlock_t	lock;}; struct mlx5_cmd {	struct mlx5_nb    nb; 	enum mlx5_cmdif_state	state;	void	       *cmd_alloc_buf;	dma_addr_t	alloc_dma;	int		alloc_size;	void	       *cmd_buf;	dma_addr_t	dma;	u16		cmdif_rev;	u8		log_sz;	u8		log_stride;	int		max_reg_cmds;	int		events;	u32 __iomem    *vector; 	/* protect command queue allocations	 */	spinlock_t	alloc_lock; 	/* protect token allocations	 */	spinlock_t	token_lock;	u8		token;	unsigned long	bitmask;	char		wq_name[MLX5_CMD_WQ_MAX_NAME];	struct workqueue_struct *wq;	struct semaphore sem;	struct semaphore pages_sem;	int	mode;	u16     allowed_opcode;	struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS];	struct dma_pool *pool;	struct mlx5_cmd_debug dbg;	struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];	int checksum_disabled;	struct mlx5_cmd_stats *stats;}; struct mlx5_port_caps {	int	gid_table_len;	int	pkey_table_len;	u8	ext_port_cap;	bool	has_smi;}; struct mlx5_cmd_mailbox {	void	       *buf;	dma_addr_t	dma;	struct mlx5_cmd_mailbox *next;}; struct mlx5_buf_list {	void		       *buf;	dma_addr_t		map;}; struct mlx5_frag_buf {	struct mlx5_buf_list	*frags;	int			npages;	int			size;	u8			page_shift;}; struct mlx5_frag_buf_ctrl {	struct mlx5_buf_list   *frags;	u32			sz_m1;	u16			frag_sz_m1;	u16			strides_offset;	u8			log_sz;	u8			log_stride;	u8			log_frag_strides;}; struct mlx5_core_psv {	u32	psv_idx;	struct psv_layout {		u32	pd;		u16	syndrome;		u16	reserved;		u16	bg;		u16	app_tag;		u32	ref_tag;	} psv;}; struct mlx5_core_sig_ctx {	struct mlx5_core_psv	psv_memory;	struct mlx5_core_psv	psv_wire;	struct ib_sig_err       err_item;	bool			sig_status_checked;	bool			sig_err_exists;	u32			sigerr_count;}; enum {	MLX5_MKEY_MR = 1,	MLX5_MKEY_MW,	MLX5_MKEY_INDIRECT_DEVX,}; struct mlx5_core_mkey {	u64			iova;	u64			size;	u32			key;	u32			pd;	u32			type;}; #define MLX5_24BIT_MASK		((1 << 24) - 1) enum mlx5_res_type {	MLX5_RES_QP	= MLX5_EVENT_QUEUE_TYPE_QP,	MLX5_RES_RQ	= MLX5_EVENT_QUEUE_TYPE_RQ,	MLX5_RES_SQ	= MLX5_EVENT_QUEUE_TYPE_SQ,	MLX5_RES_SRQ	= 3,	MLX5_RES_XSRQ	= 4,	MLX5_RES_XRQ	= 5,	MLX5_RES_DCT	= MLX5_EVENT_QUEUE_TYPE_DCT,}; struct mlx5_core_rsc_common {	enum mlx5_res_type	res;	refcount_t		refcount;	struct completion	free;}; struct mlx5_uars_page {	void __iomem	       *map;	bool			wc;	u32			index;	struct list_head	list;	unsigned int		bfregs;	unsigned long	       *reg_bitmap; /* for non fast path bf regs */	unsigned long	       *fp_bitmap;	unsigned int		reg_avail;	unsigned int		fp_avail;	struct kref		ref_count;	struct mlx5_core_dev   *mdev;}; struct mlx5_bfreg_head {	/* protect blue flame registers allocations */	struct mutex		lock;	struct list_head	list;}; struct mlx5_bfreg_data {	struct mlx5_bfreg_head	reg_head;	struct mlx5_bfreg_head	wc_head;}; struct mlx5_sq_bfreg {	void __iomem	       *map;	struct mlx5_uars_page  *up;	bool			wc;	u32			index;	unsigned int		offset;}; struct mlx5_core_health {	struct health_buffer __iomem   *health;	__be32 __iomem		       *health_counter;	struct timer_list		timer;	u32				prev;	int				miss_counter;	u8				synd;	u32				fatal_error;	u32				crdump_size;	/* wq spinlock to synchronize draining */	spinlock_t			wq_lock;	struct workqueue_struct	       *wq;	unsigned long			flags;	struct work_struct		fatal_report_work;	struct work_struct		report_work;	struct delayed_work		recover_work;	struct devlink_health_reporter *fw_reporter;	struct devlink_health_reporter *fw_fatal_reporter;}; struct mlx5_qp_table {	struct notifier_block   nb; 	/* protect radix tree	 */	spinlock_t		lock;	struct radix_tree_root	tree;}; struct mlx5_vf_context {	int	enabled;	u64	port_guid;	u64	node_guid;	/* Valid bits are used to validate administrative guid only.	 * Enabled after ndo_set_vf_guid	 */	u8	port_guid_valid:1;	u8	node_guid_valid:1;	enum port_state_policy	policy;}; struct mlx5_core_sriov {	struct mlx5_vf_context	*vfs_ctx;	int			num_vfs;	u16			max_vfs;}; struct mlx5_fc_pool {	struct mlx5_core_dev *dev;	struct mutex pool_lock; /* protects pool lists */	struct list_head fully_used;	struct list_head partially_used;	struct list_head unused;	int available_fcs;	int used_fcs;	int threshold;}; struct mlx5_fc_stats {	spinlock_t counters_idr_lock; /* protects counters_idr */	struct idr counters_idr;	struct list_head counters;	struct llist_head addlist;	struct llist_head dellist; 	struct workqueue_struct *wq;	struct delayed_work work;	unsigned long next_query;	unsigned long sampling_interval; /* jiffies */	u32 *bulk_query_out;	struct mlx5_fc_pool fc_pool;}; struct mlx5_events;struct mlx5_mpfs;

Lines 1–500 of 1215.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t