xref: /freebsd/sys/dev/mthca/mthca_dev.h (revision b633e08c705fe43180567eae26923d6f6f98c8d9)
133ec1ccbSHans Petter Selasky /*
233ec1ccbSHans Petter Selasky  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
333ec1ccbSHans Petter Selasky  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
433ec1ccbSHans Petter Selasky  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
533ec1ccbSHans Petter Selasky  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
633ec1ccbSHans Petter Selasky  * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
733ec1ccbSHans Petter Selasky  *
833ec1ccbSHans Petter Selasky  * This software is available to you under a choice of one of two
933ec1ccbSHans Petter Selasky  * licenses.  You may choose to be licensed under the terms of the GNU
1033ec1ccbSHans Petter Selasky  * General Public License (GPL) Version 2, available from the file
1133ec1ccbSHans Petter Selasky  * COPYING in the main directory of this source tree, or the
1233ec1ccbSHans Petter Selasky  * OpenIB.org BSD license below:
1333ec1ccbSHans Petter Selasky  *
1433ec1ccbSHans Petter Selasky  *     Redistribution and use in source and binary forms, with or
1533ec1ccbSHans Petter Selasky  *     without modification, are permitted provided that the following
1633ec1ccbSHans Petter Selasky  *     conditions are met:
1733ec1ccbSHans Petter Selasky  *
1833ec1ccbSHans Petter Selasky  *      - Redistributions of source code must retain the above
1933ec1ccbSHans Petter Selasky  *        copyright notice, this list of conditions and the following
2033ec1ccbSHans Petter Selasky  *        disclaimer.
2133ec1ccbSHans Petter Selasky  *
2233ec1ccbSHans Petter Selasky  *      - Redistributions in binary form must reproduce the above
2333ec1ccbSHans Petter Selasky  *        copyright notice, this list of conditions and the following
2433ec1ccbSHans Petter Selasky  *        disclaimer in the documentation and/or other materials
2533ec1ccbSHans Petter Selasky  *        provided with the distribution.
2633ec1ccbSHans Petter Selasky  *
2733ec1ccbSHans Petter Selasky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2833ec1ccbSHans Petter Selasky  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2933ec1ccbSHans Petter Selasky  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3033ec1ccbSHans Petter Selasky  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3133ec1ccbSHans Petter Selasky  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3233ec1ccbSHans Petter Selasky  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3333ec1ccbSHans Petter Selasky  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3433ec1ccbSHans Petter Selasky  * SOFTWARE.
3533ec1ccbSHans Petter Selasky  */
3633ec1ccbSHans Petter Selasky 
3733ec1ccbSHans Petter Selasky #ifndef MTHCA_DEV_H
3833ec1ccbSHans Petter Selasky #define MTHCA_DEV_H
3933ec1ccbSHans Petter Selasky 
4033ec1ccbSHans Petter Selasky #include <linux/spinlock.h>
4133ec1ccbSHans Petter Selasky #include <linux/kernel.h>
4233ec1ccbSHans Petter Selasky #include <linux/pci.h>
4333ec1ccbSHans Petter Selasky #include <linux/dma-mapping.h>
4433ec1ccbSHans Petter Selasky #include <linux/timer.h>
4533ec1ccbSHans Petter Selasky #include <linux/mutex.h>
4633ec1ccbSHans Petter Selasky #include <linux/list.h>
4733ec1ccbSHans Petter Selasky #include <linux/semaphore.h>
4833ec1ccbSHans Petter Selasky 
4933ec1ccbSHans Petter Selasky #include "mthca_provider.h"
5033ec1ccbSHans Petter Selasky #include "mthca_doorbell.h"
5133ec1ccbSHans Petter Selasky 
5233ec1ccbSHans Petter Selasky #define DRV_NAME	"ib_mthca"
5333ec1ccbSHans Petter Selasky #define PFX		DRV_NAME ": "
5433ec1ccbSHans Petter Selasky #ifndef DRV_VERSION
5533ec1ccbSHans Petter Selasky #define DRV_VERSION	"1.0"
5633ec1ccbSHans Petter Selasky #endif
5733ec1ccbSHans Petter Selasky #define DRV_RELDATE	"April 4, 2008"
5833ec1ccbSHans Petter Selasky 
5933ec1ccbSHans Petter Selasky enum {
6033ec1ccbSHans Petter Selasky 	MTHCA_FLAG_DDR_HIDDEN = 1 << 1,
6133ec1ccbSHans Petter Selasky 	MTHCA_FLAG_SRQ        = 1 << 2,
6233ec1ccbSHans Petter Selasky 	MTHCA_FLAG_MSI_X      = 1 << 3,
6333ec1ccbSHans Petter Selasky 	MTHCA_FLAG_NO_LAM     = 1 << 4,
6433ec1ccbSHans Petter Selasky 	MTHCA_FLAG_FMR        = 1 << 5,
6533ec1ccbSHans Petter Selasky 	MTHCA_FLAG_MEMFREE    = 1 << 6,
6633ec1ccbSHans Petter Selasky 	MTHCA_FLAG_PCIE       = 1 << 7,
6733ec1ccbSHans Petter Selasky 	MTHCA_FLAG_SINAI_OPT  = 1 << 8
6833ec1ccbSHans Petter Selasky };
6933ec1ccbSHans Petter Selasky 
7033ec1ccbSHans Petter Selasky enum {
7133ec1ccbSHans Petter Selasky 	MTHCA_MAX_PORTS = 2
7233ec1ccbSHans Petter Selasky };
7333ec1ccbSHans Petter Selasky 
7433ec1ccbSHans Petter Selasky enum {
7533ec1ccbSHans Petter Selasky 	MTHCA_BOARD_ID_LEN = 64
7633ec1ccbSHans Petter Selasky };
7733ec1ccbSHans Petter Selasky 
7833ec1ccbSHans Petter Selasky enum {
7933ec1ccbSHans Petter Selasky 	MTHCA_EQ_CONTEXT_SIZE =  0x40,
8033ec1ccbSHans Petter Selasky 	MTHCA_CQ_CONTEXT_SIZE =  0x40,
8133ec1ccbSHans Petter Selasky 	MTHCA_QP_CONTEXT_SIZE = 0x200,
8233ec1ccbSHans Petter Selasky 	MTHCA_RDB_ENTRY_SIZE  =  0x20,
8333ec1ccbSHans Petter Selasky 	MTHCA_AV_SIZE         =  0x20,
8433ec1ccbSHans Petter Selasky 	MTHCA_MGM_ENTRY_SIZE  = 0x100,
8533ec1ccbSHans Petter Selasky 
8633ec1ccbSHans Petter Selasky 	/* Arbel FW gives us these, but we need them for Tavor */
8733ec1ccbSHans Petter Selasky 	MTHCA_MPT_ENTRY_SIZE  =  0x40,
8833ec1ccbSHans Petter Selasky 	MTHCA_MTT_SEG_SIZE    =  0x40,
8933ec1ccbSHans Petter Selasky 
9033ec1ccbSHans Petter Selasky 	MTHCA_QP_PER_MGM      = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2)
9133ec1ccbSHans Petter Selasky };
9233ec1ccbSHans Petter Selasky 
9333ec1ccbSHans Petter Selasky enum {
9433ec1ccbSHans Petter Selasky 	MTHCA_EQ_CMD,
9533ec1ccbSHans Petter Selasky 	MTHCA_EQ_ASYNC,
9633ec1ccbSHans Petter Selasky 	MTHCA_EQ_COMP,
9733ec1ccbSHans Petter Selasky 	MTHCA_NUM_EQ
9833ec1ccbSHans Petter Selasky };
9933ec1ccbSHans Petter Selasky 
10033ec1ccbSHans Petter Selasky enum {
10133ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_NOP            = 0x00,
10233ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_RDMA_WRITE     = 0x08,
10333ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09,
10433ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_SEND           = 0x0a,
10533ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_SEND_IMM       = 0x0b,
10633ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_RDMA_READ      = 0x10,
10733ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_ATOMIC_CS      = 0x11,
10833ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_ATOMIC_FA      = 0x12,
10933ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_BIND_MW        = 0x18,
11033ec1ccbSHans Petter Selasky 	MTHCA_OPCODE_INVALID        = 0xff
11133ec1ccbSHans Petter Selasky };
11233ec1ccbSHans Petter Selasky 
11333ec1ccbSHans Petter Selasky enum {
11433ec1ccbSHans Petter Selasky 	MTHCA_CMD_USE_EVENTS         = 1 << 0,
11533ec1ccbSHans Petter Selasky 	MTHCA_CMD_POST_DOORBELLS     = 1 << 1
11633ec1ccbSHans Petter Selasky };
11733ec1ccbSHans Petter Selasky 
11833ec1ccbSHans Petter Selasky enum {
11933ec1ccbSHans Petter Selasky 	MTHCA_CMD_NUM_DBELL_DWORDS = 8
12033ec1ccbSHans Petter Selasky };
12133ec1ccbSHans Petter Selasky 
12233ec1ccbSHans Petter Selasky struct mthca_cmd {
12333ec1ccbSHans Petter Selasky 	struct pci_pool          *pool;
12433ec1ccbSHans Petter Selasky 	struct mutex              hcr_mutex;
12533ec1ccbSHans Petter Selasky 	struct semaphore 	  poll_sem;
12633ec1ccbSHans Petter Selasky 	struct semaphore 	  event_sem;
12733ec1ccbSHans Petter Selasky 	int              	  max_cmds;
12833ec1ccbSHans Petter Selasky 	spinlock_t                context_lock;
12933ec1ccbSHans Petter Selasky 	int                       free_head;
13033ec1ccbSHans Petter Selasky 	struct mthca_cmd_context *context;
13133ec1ccbSHans Petter Selasky 	u16                       token_mask;
13233ec1ccbSHans Petter Selasky 	u32                       flags;
13333ec1ccbSHans Petter Selasky 	void __iomem             *dbell_map;
13433ec1ccbSHans Petter Selasky 	u16                       dbell_offsets[MTHCA_CMD_NUM_DBELL_DWORDS];
13533ec1ccbSHans Petter Selasky };
13633ec1ccbSHans Petter Selasky 
13733ec1ccbSHans Petter Selasky struct mthca_limits {
13833ec1ccbSHans Petter Selasky 	int      num_ports;
13933ec1ccbSHans Petter Selasky 	int      vl_cap;
14033ec1ccbSHans Petter Selasky 	int      mtu_cap;
14133ec1ccbSHans Petter Selasky 	int      gid_table_len;
14233ec1ccbSHans Petter Selasky 	int      pkey_table_len;
14333ec1ccbSHans Petter Selasky 	int      local_ca_ack_delay;
14433ec1ccbSHans Petter Selasky 	int      num_uars;
14533ec1ccbSHans Petter Selasky 	int      max_sg;
14633ec1ccbSHans Petter Selasky 	int      num_qps;
14733ec1ccbSHans Petter Selasky 	int      max_wqes;
14833ec1ccbSHans Petter Selasky 	int	 max_desc_sz;
14933ec1ccbSHans Petter Selasky 	int	 max_qp_init_rdma;
15033ec1ccbSHans Petter Selasky 	int      reserved_qps;
15133ec1ccbSHans Petter Selasky 	int      num_srqs;
15233ec1ccbSHans Petter Selasky 	int      max_srq_wqes;
15333ec1ccbSHans Petter Selasky 	int      max_srq_sge;
15433ec1ccbSHans Petter Selasky 	int      reserved_srqs;
15533ec1ccbSHans Petter Selasky 	int      num_eecs;
15633ec1ccbSHans Petter Selasky 	int      reserved_eecs;
15733ec1ccbSHans Petter Selasky 	int      num_cqs;
15833ec1ccbSHans Petter Selasky 	int      max_cqes;
15933ec1ccbSHans Petter Selasky 	int      reserved_cqs;
16033ec1ccbSHans Petter Selasky 	int      num_eqs;
16133ec1ccbSHans Petter Selasky 	int      reserved_eqs;
16233ec1ccbSHans Petter Selasky 	int      num_mpts;
16333ec1ccbSHans Petter Selasky 	int      num_mtt_segs;
16433ec1ccbSHans Petter Selasky 	int	 mtt_seg_size;
16533ec1ccbSHans Petter Selasky 	int      fmr_reserved_mtts;
16633ec1ccbSHans Petter Selasky 	int      reserved_mtts;
16733ec1ccbSHans Petter Selasky 	int      reserved_mrws;
16833ec1ccbSHans Petter Selasky 	int      reserved_uars;
16933ec1ccbSHans Petter Selasky 	int      num_mgms;
17033ec1ccbSHans Petter Selasky 	int      num_amgms;
17133ec1ccbSHans Petter Selasky 	int      reserved_mcgs;
17233ec1ccbSHans Petter Selasky 	int      num_pds;
17333ec1ccbSHans Petter Selasky 	int      reserved_pds;
17433ec1ccbSHans Petter Selasky 	u32      page_size_cap;
17533ec1ccbSHans Petter Selasky 	u32      flags;
17633ec1ccbSHans Petter Selasky 	u16      stat_rate_support;
17733ec1ccbSHans Petter Selasky 	u8       port_width_cap;
17833ec1ccbSHans Petter Selasky };
17933ec1ccbSHans Petter Selasky 
18033ec1ccbSHans Petter Selasky struct mthca_alloc {
18133ec1ccbSHans Petter Selasky 	u32            last;
18233ec1ccbSHans Petter Selasky 	u32            top;
18333ec1ccbSHans Petter Selasky 	u32            max;
18433ec1ccbSHans Petter Selasky 	u32            mask;
18533ec1ccbSHans Petter Selasky 	spinlock_t     lock;
18633ec1ccbSHans Petter Selasky 	unsigned long *table;
18733ec1ccbSHans Petter Selasky };
18833ec1ccbSHans Petter Selasky 
18933ec1ccbSHans Petter Selasky struct mthca_array {
19033ec1ccbSHans Petter Selasky 	struct {
19133ec1ccbSHans Petter Selasky 		void    **page;
19233ec1ccbSHans Petter Selasky 		int       used;
19333ec1ccbSHans Petter Selasky 	} *page_list;
19433ec1ccbSHans Petter Selasky };
19533ec1ccbSHans Petter Selasky 
19633ec1ccbSHans Petter Selasky struct mthca_uar_table {
19733ec1ccbSHans Petter Selasky 	struct mthca_alloc alloc;
19833ec1ccbSHans Petter Selasky 	u64                uarc_base;
19933ec1ccbSHans Petter Selasky 	int                uarc_size;
20033ec1ccbSHans Petter Selasky };
20133ec1ccbSHans Petter Selasky 
20233ec1ccbSHans Petter Selasky struct mthca_pd_table {
20333ec1ccbSHans Petter Selasky 	struct mthca_alloc alloc;
20433ec1ccbSHans Petter Selasky };
20533ec1ccbSHans Petter Selasky 
20633ec1ccbSHans Petter Selasky struct mthca_buddy {
20733ec1ccbSHans Petter Selasky 	unsigned long **bits;
20833ec1ccbSHans Petter Selasky 	int	       *num_free;
20933ec1ccbSHans Petter Selasky 	int             max_order;
21033ec1ccbSHans Petter Selasky 	spinlock_t      lock;
21133ec1ccbSHans Petter Selasky };
21233ec1ccbSHans Petter Selasky 
21333ec1ccbSHans Petter Selasky struct mthca_mr_table {
21433ec1ccbSHans Petter Selasky 	struct mthca_alloc      mpt_alloc;
21533ec1ccbSHans Petter Selasky 	struct mthca_buddy      mtt_buddy;
21633ec1ccbSHans Petter Selasky 	struct mthca_buddy     *fmr_mtt_buddy;
21733ec1ccbSHans Petter Selasky 	u64                     mtt_base;
21833ec1ccbSHans Petter Selasky 	u64                     mpt_base;
21933ec1ccbSHans Petter Selasky 	struct mthca_icm_table *mtt_table;
22033ec1ccbSHans Petter Selasky 	struct mthca_icm_table *mpt_table;
22133ec1ccbSHans Petter Selasky 	struct {
22233ec1ccbSHans Petter Selasky 		void __iomem   *mpt_base;
22333ec1ccbSHans Petter Selasky 		void __iomem   *mtt_base;
22433ec1ccbSHans Petter Selasky 		struct mthca_buddy mtt_buddy;
22533ec1ccbSHans Petter Selasky 	} tavor_fmr;
22633ec1ccbSHans Petter Selasky };
22733ec1ccbSHans Petter Selasky 
22833ec1ccbSHans Petter Selasky struct mthca_eq_table {
22933ec1ccbSHans Petter Selasky 	struct mthca_alloc alloc;
23033ec1ccbSHans Petter Selasky 	void __iomem      *clr_int;
23133ec1ccbSHans Petter Selasky 	u32                clr_mask;
23233ec1ccbSHans Petter Selasky 	u32                arm_mask;
23333ec1ccbSHans Petter Selasky 	struct mthca_eq    eq[MTHCA_NUM_EQ];
23433ec1ccbSHans Petter Selasky 	u64                icm_virt;
23533ec1ccbSHans Petter Selasky 	struct page       *icm_page;
23633ec1ccbSHans Petter Selasky 	dma_addr_t         icm_dma;
23733ec1ccbSHans Petter Selasky 	int                have_irq;
23833ec1ccbSHans Petter Selasky 	u8                 inta_pin;
23933ec1ccbSHans Petter Selasky };
24033ec1ccbSHans Petter Selasky 
24133ec1ccbSHans Petter Selasky struct mthca_cq_table {
24233ec1ccbSHans Petter Selasky 	struct mthca_alloc 	alloc;
24333ec1ccbSHans Petter Selasky 	spinlock_t         	lock;
24433ec1ccbSHans Petter Selasky 	struct mthca_array      cq;
24533ec1ccbSHans Petter Selasky 	struct mthca_icm_table *table;
24633ec1ccbSHans Petter Selasky };
24733ec1ccbSHans Petter Selasky 
24833ec1ccbSHans Petter Selasky struct mthca_srq_table {
24933ec1ccbSHans Petter Selasky 	struct mthca_alloc 	alloc;
25033ec1ccbSHans Petter Selasky 	spinlock_t         	lock;
25133ec1ccbSHans Petter Selasky 	struct mthca_array      srq;
25233ec1ccbSHans Petter Selasky 	struct mthca_icm_table *table;
25333ec1ccbSHans Petter Selasky };
25433ec1ccbSHans Petter Selasky 
25533ec1ccbSHans Petter Selasky struct mthca_qp_table {
25633ec1ccbSHans Petter Selasky 	struct mthca_alloc     	alloc;
25733ec1ccbSHans Petter Selasky 	u32                    	rdb_base;
25833ec1ccbSHans Petter Selasky 	int                    	rdb_shift;
25933ec1ccbSHans Petter Selasky 	int                    	sqp_start;
26033ec1ccbSHans Petter Selasky 	spinlock_t             	lock;
26133ec1ccbSHans Petter Selasky 	struct mthca_array     	qp;
26233ec1ccbSHans Petter Selasky 	struct mthca_icm_table *qp_table;
26333ec1ccbSHans Petter Selasky 	struct mthca_icm_table *eqp_table;
26433ec1ccbSHans Petter Selasky 	struct mthca_icm_table *rdb_table;
26533ec1ccbSHans Petter Selasky };
26633ec1ccbSHans Petter Selasky 
26733ec1ccbSHans Petter Selasky struct mthca_av_table {
26833ec1ccbSHans Petter Selasky 	struct pci_pool   *pool;
26933ec1ccbSHans Petter Selasky 	int                num_ddr_avs;
27033ec1ccbSHans Petter Selasky 	u64                ddr_av_base;
27133ec1ccbSHans Petter Selasky 	void __iomem      *av_map;
27233ec1ccbSHans Petter Selasky 	struct mthca_alloc alloc;
27333ec1ccbSHans Petter Selasky };
27433ec1ccbSHans Petter Selasky 
27533ec1ccbSHans Petter Selasky struct mthca_mcg_table {
27633ec1ccbSHans Petter Selasky 	struct mutex		mutex;
27733ec1ccbSHans Petter Selasky 	struct mthca_alloc 	alloc;
27833ec1ccbSHans Petter Selasky 	struct mthca_icm_table *table;
27933ec1ccbSHans Petter Selasky };
28033ec1ccbSHans Petter Selasky 
28133ec1ccbSHans Petter Selasky struct mthca_catas_err {
28233ec1ccbSHans Petter Selasky 	u64			addr;
28333ec1ccbSHans Petter Selasky 	u32 __iomem	       *map;
28433ec1ccbSHans Petter Selasky 	u32			size;
28533ec1ccbSHans Petter Selasky 	struct timer_list	timer;
28633ec1ccbSHans Petter Selasky 	struct list_head	list;
28733ec1ccbSHans Petter Selasky };
28833ec1ccbSHans Petter Selasky 
28933ec1ccbSHans Petter Selasky extern struct mutex mthca_device_mutex;
29033ec1ccbSHans Petter Selasky 
29133ec1ccbSHans Petter Selasky struct mthca_dev {
29233ec1ccbSHans Petter Selasky 	struct ib_device  ib_dev;
29333ec1ccbSHans Petter Selasky 	struct pci_dev   *pdev;
29433ec1ccbSHans Petter Selasky 
29533ec1ccbSHans Petter Selasky 	int          	 hca_type;
29633ec1ccbSHans Petter Selasky 	unsigned long	 mthca_flags;
29733ec1ccbSHans Petter Selasky 	unsigned long    device_cap_flags;
29833ec1ccbSHans Petter Selasky 
29933ec1ccbSHans Petter Selasky 	u32              rev_id;
30033ec1ccbSHans Petter Selasky 	char             board_id[MTHCA_BOARD_ID_LEN];
30133ec1ccbSHans Petter Selasky 
30233ec1ccbSHans Petter Selasky 	/* firmware info */
30333ec1ccbSHans Petter Selasky 	u64              fw_ver;
30433ec1ccbSHans Petter Selasky 	union {
30533ec1ccbSHans Petter Selasky 		struct {
30633ec1ccbSHans Petter Selasky 			u64 fw_start;
30733ec1ccbSHans Petter Selasky 			u64 fw_end;
30833ec1ccbSHans Petter Selasky 		}        tavor;
30933ec1ccbSHans Petter Selasky 		struct {
31033ec1ccbSHans Petter Selasky 			u64 clr_int_base;
31133ec1ccbSHans Petter Selasky 			u64 eq_arm_base;
31233ec1ccbSHans Petter Selasky 			u64 eq_set_ci_base;
31333ec1ccbSHans Petter Selasky 			struct mthca_icm *fw_icm;
31433ec1ccbSHans Petter Selasky 			struct mthca_icm *aux_icm;
31533ec1ccbSHans Petter Selasky 			u16 fw_pages;
31633ec1ccbSHans Petter Selasky 		}        arbel;
31733ec1ccbSHans Petter Selasky 	}                fw;
31833ec1ccbSHans Petter Selasky 
31933ec1ccbSHans Petter Selasky 	u64              ddr_start;
32033ec1ccbSHans Petter Selasky 	u64              ddr_end;
32133ec1ccbSHans Petter Selasky 
32233ec1ccbSHans Petter Selasky 	MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
32333ec1ccbSHans Petter Selasky 	struct mutex cap_mask_mutex;
32433ec1ccbSHans Petter Selasky 
32533ec1ccbSHans Petter Selasky 	void __iomem    *hcr;
32633ec1ccbSHans Petter Selasky 	void __iomem    *kar;
32733ec1ccbSHans Petter Selasky 	void __iomem    *clr_base;
32833ec1ccbSHans Petter Selasky 	union {
32933ec1ccbSHans Petter Selasky 		struct {
33033ec1ccbSHans Petter Selasky 			void __iomem *ecr_base;
33133ec1ccbSHans Petter Selasky 		} tavor;
33233ec1ccbSHans Petter Selasky 		struct {
33333ec1ccbSHans Petter Selasky 			void __iomem *eq_arm;
33433ec1ccbSHans Petter Selasky 			void __iomem *eq_set_ci_base;
33533ec1ccbSHans Petter Selasky 		} arbel;
33633ec1ccbSHans Petter Selasky 	} eq_regs;
33733ec1ccbSHans Petter Selasky 
33833ec1ccbSHans Petter Selasky 	struct mthca_cmd    cmd;
33933ec1ccbSHans Petter Selasky 	struct mthca_limits limits;
34033ec1ccbSHans Petter Selasky 
34133ec1ccbSHans Petter Selasky 	struct mthca_uar_table uar_table;
34233ec1ccbSHans Petter Selasky 	struct mthca_pd_table  pd_table;
34333ec1ccbSHans Petter Selasky 	struct mthca_mr_table  mr_table;
34433ec1ccbSHans Petter Selasky 	struct mthca_eq_table  eq_table;
34533ec1ccbSHans Petter Selasky 	struct mthca_cq_table  cq_table;
34633ec1ccbSHans Petter Selasky 	struct mthca_srq_table srq_table;
34733ec1ccbSHans Petter Selasky 	struct mthca_qp_table  qp_table;
34833ec1ccbSHans Petter Selasky 	struct mthca_av_table  av_table;
34933ec1ccbSHans Petter Selasky 	struct mthca_mcg_table mcg_table;
35033ec1ccbSHans Petter Selasky 
35133ec1ccbSHans Petter Selasky 	struct mthca_catas_err catas_err;
35233ec1ccbSHans Petter Selasky 
35333ec1ccbSHans Petter Selasky 	struct mthca_uar       driver_uar;
35433ec1ccbSHans Petter Selasky 	struct mthca_db_table *db_tab;
35533ec1ccbSHans Petter Selasky 	struct mthca_pd        driver_pd;
35633ec1ccbSHans Petter Selasky 	struct mthca_mr        driver_mr;
35733ec1ccbSHans Petter Selasky 
35833ec1ccbSHans Petter Selasky 	struct ib_mad_agent  *send_agent[MTHCA_MAX_PORTS][2];
35933ec1ccbSHans Petter Selasky 	struct ib_ah         *sm_ah[MTHCA_MAX_PORTS];
36033ec1ccbSHans Petter Selasky 	spinlock_t            sm_lock;
36133ec1ccbSHans Petter Selasky 	u8                    rate[MTHCA_MAX_PORTS];
36233ec1ccbSHans Petter Selasky 	bool		      active;
36333ec1ccbSHans Petter Selasky };
36433ec1ccbSHans Petter Selasky 
36533ec1ccbSHans Petter Selasky #ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
36633ec1ccbSHans Petter Selasky extern int mthca_debug_level;
36733ec1ccbSHans Petter Selasky 
36833ec1ccbSHans Petter Selasky #define mthca_dbg(mdev, format, arg...)					\
36933ec1ccbSHans Petter Selasky 	do {								\
37033ec1ccbSHans Petter Selasky 		if (mthca_debug_level)					\
37133ec1ccbSHans Petter Selasky 			dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \
37233ec1ccbSHans Petter Selasky 	} while (0)
37333ec1ccbSHans Petter Selasky 
37433ec1ccbSHans Petter Selasky #else /* CONFIG_INFINIBAND_MTHCA_DEBUG */
37533ec1ccbSHans Petter Selasky 
37633ec1ccbSHans Petter Selasky #define mthca_dbg(mdev, format, arg...) do { (void) mdev; } while (0)
37733ec1ccbSHans Petter Selasky 
37833ec1ccbSHans Petter Selasky #endif /* CONFIG_INFINIBAND_MTHCA_DEBUG */
37933ec1ccbSHans Petter Selasky 
38033ec1ccbSHans Petter Selasky #define mthca_err(mdev, format, arg...) \
38133ec1ccbSHans Petter Selasky 	dev_err(&mdev->pdev->dev, format, ## arg)
38233ec1ccbSHans Petter Selasky #define mthca_info(mdev, format, arg...) \
38333ec1ccbSHans Petter Selasky 	dev_info(&mdev->pdev->dev, format, ## arg)
38433ec1ccbSHans Petter Selasky #define mthca_warn(mdev, format, arg...) \
38533ec1ccbSHans Petter Selasky 	dev_warn(&mdev->pdev->dev, format, ## arg)
38633ec1ccbSHans Petter Selasky 
38733ec1ccbSHans Petter Selasky extern void __buggy_use_of_MTHCA_GET(void);
38833ec1ccbSHans Petter Selasky extern void __buggy_use_of_MTHCA_PUT(void);
38933ec1ccbSHans Petter Selasky 
39033ec1ccbSHans Petter Selasky #define MTHCA_GET(dest, source, offset)                               \
39133ec1ccbSHans Petter Selasky 	do {                                                          \
39233ec1ccbSHans Petter Selasky 		void *__p = (char *) (source) + (offset);             \
39333ec1ccbSHans Petter Selasky 		switch (sizeof (dest)) {                              \
39433ec1ccbSHans Petter Selasky 		case 1: (dest) = *(u8 *) __p;       break;	      \
39533ec1ccbSHans Petter Selasky 		case 2: (dest) = be16_to_cpup(__p); break;	      \
39633ec1ccbSHans Petter Selasky 		case 4: (dest) = be32_to_cpup(__p); break;	      \
39733ec1ccbSHans Petter Selasky 		case 8: (dest) = be64_to_cpup(__p); break;	      \
39833ec1ccbSHans Petter Selasky 		default: __buggy_use_of_MTHCA_GET();		      \
39933ec1ccbSHans Petter Selasky 		}                                                     \
40033ec1ccbSHans Petter Selasky 	} while (0)
40133ec1ccbSHans Petter Selasky 
40233ec1ccbSHans Petter Selasky #define MTHCA_PUT(dest, source, offset)                               \
40333ec1ccbSHans Petter Selasky 	do {                                                          \
40433ec1ccbSHans Petter Selasky 		void *__d = ((char *) (dest) + (offset));	      \
40533ec1ccbSHans Petter Selasky 		switch (sizeof(source)) {                             \
40633ec1ccbSHans Petter Selasky 		case 1: *(u8 *) __d = (source);                break; \
40733ec1ccbSHans Petter Selasky 		case 2:	*(__be16 *) __d = cpu_to_be16(source); break; \
40833ec1ccbSHans Petter Selasky 		case 4:	*(__be32 *) __d = cpu_to_be32(source); break; \
40933ec1ccbSHans Petter Selasky 		case 8:	*(__be64 *) __d = cpu_to_be64(source); break; \
41033ec1ccbSHans Petter Selasky 		default: __buggy_use_of_MTHCA_PUT();		      \
41133ec1ccbSHans Petter Selasky 		}                                                     \
41233ec1ccbSHans Petter Selasky 	} while (0)
41333ec1ccbSHans Petter Selasky 
41433ec1ccbSHans Petter Selasky int mthca_reset(struct mthca_dev *mdev);
41533ec1ccbSHans Petter Selasky 
41633ec1ccbSHans Petter Selasky u32 mthca_alloc(struct mthca_alloc *alloc);
41733ec1ccbSHans Petter Selasky void mthca_free(struct mthca_alloc *alloc, u32 obj);
41833ec1ccbSHans Petter Selasky int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
41933ec1ccbSHans Petter Selasky 		     u32 reserved);
42033ec1ccbSHans Petter Selasky void mthca_alloc_cleanup(struct mthca_alloc *alloc);
42133ec1ccbSHans Petter Selasky void *mthca_array_get(struct mthca_array *array, int index);
42233ec1ccbSHans Petter Selasky int mthca_array_set(struct mthca_array *array, int index, void *value);
42333ec1ccbSHans Petter Selasky void mthca_array_clear(struct mthca_array *array, int index);
42433ec1ccbSHans Petter Selasky int mthca_array_init(struct mthca_array *array, int nent);
42533ec1ccbSHans Petter Selasky void mthca_array_cleanup(struct mthca_array *array, int nent);
42633ec1ccbSHans Petter Selasky int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
42733ec1ccbSHans Petter Selasky 		    union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
42833ec1ccbSHans Petter Selasky 		    int hca_write, struct mthca_mr *mr);
42933ec1ccbSHans Petter Selasky void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
43033ec1ccbSHans Petter Selasky 		    int is_direct, struct mthca_mr *mr);
43133ec1ccbSHans Petter Selasky 
43233ec1ccbSHans Petter Selasky int mthca_init_uar_table(struct mthca_dev *dev);
43333ec1ccbSHans Petter Selasky int mthca_init_pd_table(struct mthca_dev *dev);
43433ec1ccbSHans Petter Selasky int mthca_init_mr_table(struct mthca_dev *dev);
43533ec1ccbSHans Petter Selasky int mthca_init_eq_table(struct mthca_dev *dev);
43633ec1ccbSHans Petter Selasky int mthca_init_cq_table(struct mthca_dev *dev);
43733ec1ccbSHans Petter Selasky int mthca_init_srq_table(struct mthca_dev *dev);
43833ec1ccbSHans Petter Selasky int mthca_init_qp_table(struct mthca_dev *dev);
43933ec1ccbSHans Petter Selasky int mthca_init_av_table(struct mthca_dev *dev);
44033ec1ccbSHans Petter Selasky int mthca_init_mcg_table(struct mthca_dev *dev);
44133ec1ccbSHans Petter Selasky 
44233ec1ccbSHans Petter Selasky void mthca_cleanup_uar_table(struct mthca_dev *dev);
44333ec1ccbSHans Petter Selasky void mthca_cleanup_pd_table(struct mthca_dev *dev);
44433ec1ccbSHans Petter Selasky void mthca_cleanup_mr_table(struct mthca_dev *dev);
44533ec1ccbSHans Petter Selasky void mthca_cleanup_eq_table(struct mthca_dev *dev);
44633ec1ccbSHans Petter Selasky void mthca_cleanup_cq_table(struct mthca_dev *dev);
44733ec1ccbSHans Petter Selasky void mthca_cleanup_srq_table(struct mthca_dev *dev);
44833ec1ccbSHans Petter Selasky void mthca_cleanup_qp_table(struct mthca_dev *dev);
44933ec1ccbSHans Petter Selasky void mthca_cleanup_av_table(struct mthca_dev *dev);
45033ec1ccbSHans Petter Selasky void mthca_cleanup_mcg_table(struct mthca_dev *dev);
45133ec1ccbSHans Petter Selasky 
45233ec1ccbSHans Petter Selasky int mthca_register_device(struct mthca_dev *dev);
45333ec1ccbSHans Petter Selasky void mthca_unregister_device(struct mthca_dev *dev);
45433ec1ccbSHans Petter Selasky 
45533ec1ccbSHans Petter Selasky void mthca_start_catas_poll(struct mthca_dev *dev);
45633ec1ccbSHans Petter Selasky void mthca_stop_catas_poll(struct mthca_dev *dev);
45733ec1ccbSHans Petter Selasky int __mthca_restart_one(struct pci_dev *pdev);
45833ec1ccbSHans Petter Selasky int mthca_catas_init(void);
45933ec1ccbSHans Petter Selasky void mthca_catas_cleanup(void);
46033ec1ccbSHans Petter Selasky 
46133ec1ccbSHans Petter Selasky int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
46233ec1ccbSHans Petter Selasky void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
46333ec1ccbSHans Petter Selasky 
46433ec1ccbSHans Petter Selasky int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd);
46533ec1ccbSHans Petter Selasky void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd);
46633ec1ccbSHans Petter Selasky 
46733ec1ccbSHans Petter Selasky int mthca_write_mtt_size(struct mthca_dev *dev);
46833ec1ccbSHans Petter Selasky 
46933ec1ccbSHans Petter Selasky struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size);
47033ec1ccbSHans Petter Selasky void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt);
47133ec1ccbSHans Petter Selasky int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
47233ec1ccbSHans Petter Selasky 		    int start_index, u64 *buffer_list, int list_len);
47333ec1ccbSHans Petter Selasky int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
47433ec1ccbSHans Petter Selasky 		   u64 iova, u64 total_size, u32 access, struct mthca_mr *mr);
47533ec1ccbSHans Petter Selasky int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
47633ec1ccbSHans Petter Selasky 			   u32 access, struct mthca_mr *mr);
47733ec1ccbSHans Petter Selasky int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
47833ec1ccbSHans Petter Selasky 			u64 *buffer_list, int buffer_size_shift,
47933ec1ccbSHans Petter Selasky 			int list_len, u64 iova, u64 total_size,
48033ec1ccbSHans Petter Selasky 			u32 access, struct mthca_mr *mr);
48133ec1ccbSHans Petter Selasky void mthca_free_mr(struct mthca_dev *dev,  struct mthca_mr *mr);
48233ec1ccbSHans Petter Selasky 
48333ec1ccbSHans Petter Selasky int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
48433ec1ccbSHans Petter Selasky 		    u32 access, struct mthca_fmr *fmr);
48533ec1ccbSHans Petter Selasky int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
48633ec1ccbSHans Petter Selasky 			     int list_len, u64 iova);
48733ec1ccbSHans Petter Selasky void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
48833ec1ccbSHans Petter Selasky int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
48933ec1ccbSHans Petter Selasky 			     int list_len, u64 iova);
49033ec1ccbSHans Petter Selasky void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
49133ec1ccbSHans Petter Selasky int mthca_free_fmr(struct mthca_dev *dev,  struct mthca_fmr *fmr);
49233ec1ccbSHans Petter Selasky 
49333ec1ccbSHans Petter Selasky int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt);
49433ec1ccbSHans Petter Selasky void mthca_unmap_eq_icm(struct mthca_dev *dev);
49533ec1ccbSHans Petter Selasky 
49633ec1ccbSHans Petter Selasky int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
49733ec1ccbSHans Petter Selasky 		  struct ib_wc *entry);
49833ec1ccbSHans Petter Selasky int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
49933ec1ccbSHans Petter Selasky int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
50033ec1ccbSHans Petter Selasky int mthca_init_cq(struct mthca_dev *dev, int nent,
50133ec1ccbSHans Petter Selasky 		  struct mthca_ucontext *ctx, u32 pdn,
50233ec1ccbSHans Petter Selasky 		  struct mthca_cq *cq);
50333ec1ccbSHans Petter Selasky void mthca_free_cq(struct mthca_dev *dev,
50433ec1ccbSHans Petter Selasky 		   struct mthca_cq *cq);
50533ec1ccbSHans Petter Selasky void mthca_cq_completion(struct mthca_dev *dev, u32 cqn);
50633ec1ccbSHans Petter Selasky void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
50733ec1ccbSHans Petter Selasky 		    enum ib_event_type event_type);
50833ec1ccbSHans Petter Selasky void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn,
50933ec1ccbSHans Petter Selasky 		    struct mthca_srq *srq);
51033ec1ccbSHans Petter Selasky void mthca_cq_resize_copy_cqes(struct mthca_cq *cq);
51133ec1ccbSHans Petter Selasky int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent);
51233ec1ccbSHans Petter Selasky void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int cqe);
51333ec1ccbSHans Petter Selasky 
51433ec1ccbSHans Petter Selasky int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
515*b633e08cSHans Petter Selasky 		    struct ib_srq_attr *attr, struct mthca_srq *srq,
516*b633e08cSHans Petter Selasky 		    struct ib_udata *udata);
51733ec1ccbSHans Petter Selasky void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
51833ec1ccbSHans Petter Selasky int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
51933ec1ccbSHans Petter Selasky 		     enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
52033ec1ccbSHans Petter Selasky int mthca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
52133ec1ccbSHans Petter Selasky int mthca_max_srq_sge(struct mthca_dev *dev);
52233ec1ccbSHans Petter Selasky void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
52333ec1ccbSHans Petter Selasky 		     enum ib_event_type event_type);
52433ec1ccbSHans Petter Selasky void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
525c3987b8eSHans Petter Selasky int mthca_tavor_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
526c3987b8eSHans Petter Selasky 			      const struct ib_recv_wr **bad_wr);
527c3987b8eSHans Petter Selasky int mthca_arbel_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
528c3987b8eSHans Petter Selasky 			      const struct ib_recv_wr **bad_wr);
52933ec1ccbSHans Petter Selasky 
53033ec1ccbSHans Petter Selasky void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
53133ec1ccbSHans Petter Selasky 		    enum ib_event_type event_type);
53233ec1ccbSHans Petter Selasky int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
53333ec1ccbSHans Petter Selasky 		   struct ib_qp_init_attr *qp_init_attr);
53433ec1ccbSHans Petter Selasky int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
53533ec1ccbSHans Petter Selasky 		    struct ib_udata *udata);
536c3987b8eSHans Petter Selasky int mthca_tavor_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
537c3987b8eSHans Petter Selasky 			  const struct ib_send_wr **bad_wr);
538c3987b8eSHans Petter Selasky int mthca_tavor_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
539c3987b8eSHans Petter Selasky 			     const struct ib_recv_wr **bad_wr);
540c3987b8eSHans Petter Selasky int mthca_arbel_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
541c3987b8eSHans Petter Selasky 			  const struct ib_send_wr **bad_wr);
542c3987b8eSHans Petter Selasky int mthca_arbel_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
543c3987b8eSHans Petter Selasky 			     const struct ib_recv_wr **bad_wr);
54433ec1ccbSHans Petter Selasky void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
54533ec1ccbSHans Petter Selasky 			int index, int *dbd, __be32 *new_wqe);
54633ec1ccbSHans Petter Selasky int mthca_alloc_qp(struct mthca_dev *dev,
54733ec1ccbSHans Petter Selasky 		   struct mthca_pd *pd,
54833ec1ccbSHans Petter Selasky 		   struct mthca_cq *send_cq,
54933ec1ccbSHans Petter Selasky 		   struct mthca_cq *recv_cq,
55033ec1ccbSHans Petter Selasky 		   enum ib_qp_type type,
55133ec1ccbSHans Petter Selasky 		   enum ib_sig_type send_policy,
55233ec1ccbSHans Petter Selasky 		   struct ib_qp_cap *cap,
553*b633e08cSHans Petter Selasky 		   struct mthca_qp *qp,
554*b633e08cSHans Petter Selasky 		   struct ib_udata *udata);
55533ec1ccbSHans Petter Selasky int mthca_alloc_sqp(struct mthca_dev *dev,
55633ec1ccbSHans Petter Selasky 		    struct mthca_pd *pd,
55733ec1ccbSHans Petter Selasky 		    struct mthca_cq *send_cq,
55833ec1ccbSHans Petter Selasky 		    struct mthca_cq *recv_cq,
55933ec1ccbSHans Petter Selasky 		    enum ib_sig_type send_policy,
56033ec1ccbSHans Petter Selasky 		    struct ib_qp_cap *cap,
56133ec1ccbSHans Petter Selasky 		    int qpn,
56233ec1ccbSHans Petter Selasky 		    int port,
563*b633e08cSHans Petter Selasky 		    struct mthca_sqp *sqp,
564*b633e08cSHans Petter Selasky 		    struct ib_udata *udata);
56533ec1ccbSHans Petter Selasky void mthca_free_qp(struct mthca_dev *dev, struct mthca_qp *qp);
56633ec1ccbSHans Petter Selasky int mthca_create_ah(struct mthca_dev *dev,
56733ec1ccbSHans Petter Selasky 		    struct mthca_pd *pd,
56833ec1ccbSHans Petter Selasky 		    struct ib_ah_attr *ah_attr,
56933ec1ccbSHans Petter Selasky 		    struct mthca_ah *ah);
57033ec1ccbSHans Petter Selasky int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah);
57133ec1ccbSHans Petter Selasky int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
57233ec1ccbSHans Petter Selasky 		  struct ib_ud_header *header);
57333ec1ccbSHans Petter Selasky int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr);
57433ec1ccbSHans Petter Selasky int mthca_ah_grh_present(struct mthca_ah *ah);
57533ec1ccbSHans Petter Selasky u8 mthca_get_rate(struct mthca_dev *dev, int static_rate, u8 port);
57633ec1ccbSHans Petter Selasky enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port);
57733ec1ccbSHans Petter Selasky 
57833ec1ccbSHans Petter Selasky int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
57933ec1ccbSHans Petter Selasky int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
58033ec1ccbSHans Petter Selasky 
58133ec1ccbSHans Petter Selasky int mthca_process_mad(struct ib_device *ibdev,
58233ec1ccbSHans Petter Selasky 		      int mad_flags,
58333ec1ccbSHans Petter Selasky 		      u8 port_num,
58433ec1ccbSHans Petter Selasky 		      const struct ib_wc *in_wc,
58533ec1ccbSHans Petter Selasky 		      const struct ib_grh *in_grh,
58633ec1ccbSHans Petter Selasky 		      const struct ib_mad_hdr *in, size_t in_mad_size,
58733ec1ccbSHans Petter Selasky 		      struct ib_mad_hdr *out, size_t *out_mad_size,
58833ec1ccbSHans Petter Selasky 		      u16 *out_mad_pkey_index);
58933ec1ccbSHans Petter Selasky int mthca_create_agents(struct mthca_dev *dev);
59033ec1ccbSHans Petter Selasky void mthca_free_agents(struct mthca_dev *dev);
59133ec1ccbSHans Petter Selasky 
to_mdev(struct ib_device * ibdev)59233ec1ccbSHans Petter Selasky static inline struct mthca_dev *to_mdev(struct ib_device *ibdev)
59333ec1ccbSHans Petter Selasky {
59433ec1ccbSHans Petter Selasky 	return container_of(ibdev, struct mthca_dev, ib_dev);
59533ec1ccbSHans Petter Selasky }
59633ec1ccbSHans Petter Selasky 
mthca_is_memfree(struct mthca_dev * dev)59733ec1ccbSHans Petter Selasky static inline int mthca_is_memfree(struct mthca_dev *dev)
59833ec1ccbSHans Petter Selasky {
59933ec1ccbSHans Petter Selasky 	return dev->mthca_flags & MTHCA_FLAG_MEMFREE;
60033ec1ccbSHans Petter Selasky }
60133ec1ccbSHans Petter Selasky 
60233ec1ccbSHans Petter Selasky #endif /* MTHCA_DEV_H */
603