Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
c2_provider.h
Go to the documentation of this file.
1 /*
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 
51 struct c2_buf_list {
52  void *buf;
54 };
55 
56 
57 /* The user context keeps track of objects allocated for a
58  * particular user-mode client. */
59 struct c2_ucontext {
61 };
62 
63 struct c2_mtt;
64 
65 /* All objects associated with a PD are kept in the
66  * associated user context if present.
67  */
68 struct c2_pd {
69  struct ib_pd ibpd;
71 };
72 
73 struct c2_mr {
74  struct ib_mr ibmr;
75  struct c2_pd *pd;
76  struct ib_umem *umem;
77 };
78 
79 struct c2_av;
80 
81 enum c2_ah_type {
85 };
86 
87 struct c2_ah {
88  struct ib_ah ibah;
89 };
90 
91 struct c2_cq {
92  struct ib_cq ibcq;
95  int cqn;
96  int is_kernel;
98 
100  struct c2_mq mq;
101 };
102 
103 struct c2_wq {
105 };
106 struct iw_cm_id;
107 struct c2_qp {
108  struct ib_qp ibqp;
109  struct iw_cm_id *cm_id;
113  int qpn;
114 
120 
121  struct c2_mq sq_mq;
122  struct c2_mq rq_mq;
123 };
124 
130 };
131 
132 static inline struct c2_pd *to_c2pd(struct ib_pd *ibpd)
133 {
134  return container_of(ibpd, struct c2_pd, ibpd);
135 }
136 
137 static inline struct c2_ucontext *to_c2ucontext(struct ib_ucontext *ibucontext)
138 {
139  return container_of(ibucontext, struct c2_ucontext, ibucontext);
140 }
141 
142 static inline struct c2_mr *to_c2mr(struct ib_mr *ibmr)
143 {
144  return container_of(ibmr, struct c2_mr, ibmr);
145 }
146 
147 
148 static inline struct c2_ah *to_c2ah(struct ib_ah *ibah)
149 {
150  return container_of(ibah, struct c2_ah, ibah);
151 }
152 
153 static inline struct c2_cq *to_c2cq(struct ib_cq *ibcq)
154 {
155  return container_of(ibcq, struct c2_cq, ibcq);
156 }
157 
158 static inline struct c2_qp *to_c2qp(struct ib_qp *ibqp)
159 {
160  return container_of(ibqp, struct c2_qp, ibqp);
161 }
162 
163 static 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 */