2 * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #include <linux/mutex.h>
36 #include <linux/list.h>
37 #include <linux/spinlock.h>
38 #include <linux/idr.h>
39 #include <linux/workqueue.h>
41 #include <rdma/ib_verbs.h>
44 #include "cxgb3_offload.h"
51 struct iwch_rnic_attributes
{
53 u32 max_wrs
; /* Max for any SQ/RQ */
55 u32 max_sge_per_rdma_write_wr
; /* for RDMA Write WR */
59 u32 max_phys_buf_entries
; /* for phys buf list */
63 * The memory page sizes supported by this RNIC.
64 * Bit position i in bitmap indicates page of
65 * size (4k)^i. Phys block list mode unsupported.
67 u32 mem_pgsizes_bitmask
;
72 * The maximum number of RDMA Reads that can be outstanding
73 * per QP with this RNIC as the target.
75 u32 max_rdma_reads_per_qp
;
78 * The maximum number of resources used for RDMA Reads
79 * by this RNIC with this RNIC as the target.
81 u32 max_rdma_read_resources
;
84 * The max depth per QP for initiation of RDMA Read
87 u32 max_rdma_read_qp_depth
;
90 * The maximum depth for initiation of RDMA Read
91 * operations by this RNIC on all QPs
93 u32 max_rdma_read_depth
;
94 u8 rq_overflow_handled
;
100 u8 local_invalidate_fence
;
101 u32 cq_overflow_detection
;
105 struct ib_device ibdev
;
106 struct cxio_rdev rdev
;
107 u32 device_cap_flags
;
108 struct iwch_rnic_attributes attr
;
113 struct list_head entry
;
114 struct delayed_work db_drop_task
;
117 static inline struct iwch_dev
*to_iwch_dev(struct ib_device
*ibdev
)
119 return container_of(ibdev
, struct iwch_dev
, ibdev
);
122 static inline struct iwch_dev
*rdev_to_iwch_dev(struct cxio_rdev
*rdev
)
124 return container_of(rdev
, struct iwch_dev
, rdev
);
127 static inline int t3b_device(const struct iwch_dev
*rhp
)
129 return rhp
->rdev
.t3cdev_p
->type
== T3B
;
132 static inline int t3a_device(const struct iwch_dev
*rhp
)
134 return rhp
->rdev
.t3cdev_p
->type
== T3A
;
137 static inline struct iwch_cq
*get_chp(struct iwch_dev
*rhp
, u32 cqid
)
139 return idr_find(&rhp
->cqidr
, cqid
);
142 static inline struct iwch_qp
*get_qhp(struct iwch_dev
*rhp
, u32 qpid
)
144 return idr_find(&rhp
->qpidr
, qpid
);
147 static inline struct iwch_mr
*get_mhp(struct iwch_dev
*rhp
, u32 mmid
)
149 return idr_find(&rhp
->mmidr
, mmid
);
152 static inline int insert_handle(struct iwch_dev
*rhp
, struct idr
*idr
,
153 void *handle
, u32 id
)
159 if (!idr_pre_get(idr
, GFP_KERNEL
)) {
162 spin_lock_irq(&rhp
->lock
);
163 ret
= idr_get_new_above(idr
, handle
, id
, &newid
);
165 spin_unlock_irq(&rhp
->lock
);
166 } while (ret
== -EAGAIN
);
171 static inline void remove_handle(struct iwch_dev
*rhp
, struct idr
*idr
, u32 id
)
173 spin_lock_irq(&rhp
->lock
);
175 spin_unlock_irq(&rhp
->lock
);
178 extern struct cxgb3_client t3c_client
;
179 extern cxgb3_cpl_handler_func t3c_handlers
[NUM_CPL_CMDS
];
180 extern void iwch_ev_dispatch(struct cxio_rdev
*rdev_p
, struct sk_buff
*skb
);