uwb: Use kcalloc instead of kzalloc to allocate array
[zen-stable.git] / drivers / infiniband / hw / amso1100 / c2_provider.h
blobbf189987711f1a4da4890e07fd6f87eff1921e4a
1 /*
2 * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
3 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
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:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
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.
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.
35 #ifndef C2_PROVIDER_H
36 #define C2_PROVIDER_H
37 #include <linux/inetdevice.h>
39 #include <rdma/ib_verbs.h>
40 #include <rdma/ib_pack.h>
42 #include "c2_mq.h"
43 #include <rdma/iw_cm.h>
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)
51 struct c2_buf_list {
52 void *buf;
53 DEFINE_DMA_UNMAP_ADDR(mapping);
57 /* The user context keeps track of objects allocated for a
58 * particular user-mode client. */
59 struct c2_ucontext {
60 struct ib_ucontext ibucontext;
63 struct c2_mtt;
65 /* All objects associated with a PD are kept in the
66 * associated user context if present.
68 struct c2_pd {
69 struct ib_pd ibpd;
70 u32 pd_id;
73 struct c2_mr {
74 struct ib_mr ibmr;
75 struct c2_pd *pd;
76 struct ib_umem *umem;
79 struct c2_av;
81 enum c2_ah_type {
82 C2_AH_ON_HCA,
83 C2_AH_PCI_POOL,
84 C2_AH_KMALLOC
87 struct c2_ah {
88 struct ib_ah ibah;
91 struct 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;
99 u32 adapter_handle;
100 struct c2_mq mq;
103 struct c2_wq {
104 spinlock_t lock;
106 struct iw_cm_id;
107 struct 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;
115 u32 adapter_handle;
116 u32 send_sgl_depth;
117 u32 recv_sgl_depth;
118 u32 rdma_write_sgl_depth;
119 u8 state;
121 struct c2_mq sq_mq;
122 struct c2_mq rq_mq;
125 struct c2_cr_query_attrs {
126 u32 local_addr;
127 u32 remote_addr;
128 u16 local_port;
129 u16 remote_port;
132 static inline struct c2_pd *to_c2pd(struct ib_pd *ibpd)
134 return container_of(ibpd, struct c2_pd, ibpd);
137 static inline struct c2_ucontext *to_c2ucontext(struct ib_ucontext *ibucontext)
139 return container_of(ibucontext, struct c2_ucontext, ibucontext);
142 static inline struct c2_mr *to_c2mr(struct ib_mr *ibmr)
144 return container_of(ibmr, struct c2_mr, ibmr);
148 static inline struct c2_ah *to_c2ah(struct ib_ah *ibah)
150 return container_of(ibah, struct c2_ah, ibah);
153 static inline struct c2_cq *to_c2cq(struct ib_cq *ibcq)
155 return container_of(ibcq, struct c2_cq, ibcq);
158 static inline struct c2_qp *to_c2qp(struct ib_qp *ibqp)
160 return container_of(ibqp, struct c2_qp, ibqp);
163 static inline int is_rnic_addr(struct net_device *netdev, u32 addr)
165 struct in_device *ind;
166 int ret = 0;
168 ind = in_dev_get(netdev);
169 if (!ind)
170 return 0;
172 for_ifa(ind) {
173 if (ifa->ifa_address == addr) {
174 ret = 1;
175 break;
178 endfor_ifa(ind);
179 in_dev_put(ind);
180 return ret;
182 #endif /* C2_PROVIDER_H */