blob: bf189987711f1a4da4890e07fd6f87eff1921e4a [file] [log] [blame]
Tom Tuckerf94b5332006-09-22 15:22:48 -07001/*
2 * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 */
34
35#ifndef C2_PROVIDER_H
36#define C2_PROVIDER_H
37#include <linux/inetdevice.h>
38
39#include <rdma/ib_verbs.h>
40#include <rdma/ib_pack.h>
41
42#include "c2_mq.h"
43#include <rdma/iw_cm.h>
44
45#define C2_MPT_FLAG_ATOMIC (1 << 14)
46#define C2_MPT_FLAG_REMOTE_WRITE (1 << 13)
47#define C2_MPT_FLAG_REMOTE_READ (1 << 12)
48#define C2_MPT_FLAG_LOCAL_WRITE (1 << 11)
49#define C2_MPT_FLAG_LOCAL_READ (1 << 10)
50
51struct c2_buf_list {
52 void *buf;
FUJITA Tomonorie7494442010-04-21 15:23:10 -070053 DEFINE_DMA_UNMAP_ADDR(mapping);
Tom Tuckerf94b5332006-09-22 15:22:48 -070054};
55
56
57/* The user context keeps track of objects allocated for a
58 * particular user-mode client. */
59struct c2_ucontext {
60 struct ib_ucontext ibucontext;
61};
62
63struct c2_mtt;
64
65/* All objects associated with a PD are kept in the
66 * associated user context if present.
67 */
68struct c2_pd {
69 struct ib_pd ibpd;
70 u32 pd_id;
71};
72
73struct c2_mr {
74 struct ib_mr ibmr;
75 struct c2_pd *pd;
Roland Dreierf7c6a7b2007-03-04 16:15:11 -080076 struct ib_umem *umem;
Tom Tuckerf94b5332006-09-22 15:22:48 -070077};
78
79struct c2_av;
80
81enum c2_ah_type {
82 C2_AH_ON_HCA,
83 C2_AH_PCI_POOL,
84 C2_AH_KMALLOC
85};
86
87struct c2_ah {
88 struct ib_ah ibah;
89};
90
91struct c2_cq {
92 struct ib_cq ibcq;
93 spinlock_t lock;
94 atomic_t refcount;
95 int cqn;
96 int is_kernel;
97 wait_queue_head_t wait;
98
99 u32 adapter_handle;
100 struct c2_mq mq;
101};
102
103struct c2_wq {
104 spinlock_t lock;
105};
106struct iw_cm_id;
107struct c2_qp {
108 struct ib_qp ibqp;
109 struct iw_cm_id *cm_id;
110 spinlock_t lock;
111 atomic_t refcount;
112 wait_queue_head_t wait;
113 int qpn;
114
115 u32 adapter_handle;
116 u32 send_sgl_depth;
117 u32 recv_sgl_depth;
118 u32 rdma_write_sgl_depth;
119 u8 state;
120
121 struct c2_mq sq_mq;
122 struct c2_mq rq_mq;
123};
124
125struct c2_cr_query_attrs {
126 u32 local_addr;
127 u32 remote_addr;
128 u16 local_port;
129 u16 remote_port;
130};
131
132static inline struct c2_pd *to_c2pd(struct ib_pd *ibpd)
133{
134 return container_of(ibpd, struct c2_pd, ibpd);
135}
136
137static inline struct c2_ucontext *to_c2ucontext(struct ib_ucontext *ibucontext)
138{
139 return container_of(ibucontext, struct c2_ucontext, ibucontext);
140}
141
142static inline struct c2_mr *to_c2mr(struct ib_mr *ibmr)
143{
144 return container_of(ibmr, struct c2_mr, ibmr);
145}
146
147
148static inline struct c2_ah *to_c2ah(struct ib_ah *ibah)
149{
150 return container_of(ibah, struct c2_ah, ibah);
151}
152
153static inline struct c2_cq *to_c2cq(struct ib_cq *ibcq)
154{
155 return container_of(ibcq, struct c2_cq, ibcq);
156}
157
158static inline struct c2_qp *to_c2qp(struct ib_qp *ibqp)
159{
160 return container_of(ibqp, struct c2_qp, ibqp);
161}
162
163static inline int is_rnic_addr(struct net_device *netdev, u32 addr)
164{
165 struct in_device *ind;
166 int ret = 0;
167
168 ind = in_dev_get(netdev);
169 if (!ind)
170 return 0;
171
172 for_ifa(ind) {
173 if (ifa->ifa_address == addr) {
174 ret = 1;
175 break;
176 }
177 }
178 endfor_ifa(ind);
179 in_dev_put(ind);
180 return ret;
181}
182#endif /* C2_PROVIDER_H */