IB/mad: pass ib_mad_send_buf explicitly to the recv_handler
[deliverable/linux.git] / drivers / infiniband / core / mad_priv.h
CommitLineData
1da177e4
LT
1/*
2 * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
fa619a77
HR
3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
b76aabc3 5 * Copyright (c) 2009 HNR Consulting. All rights reserved.
1da177e4
LT
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
15 * conditions are met:
16 *
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer.
20 *
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
1da177e4
LT
34 */
35
36#ifndef __IB_MAD_PRIV_H__
37#define __IB_MAD_PRIV_H__
38
1b52fa98 39#include <linux/completion.h>
d7b20045 40#include <linux/err.h>
1da177e4 41#include <linux/workqueue.h>
a4d61e84
RD
42#include <rdma/ib_mad.h>
43#include <rdma/ib_smi.h>
f28990bc 44#include <rdma/opa_smi.h>
1da177e4 45
1da177e4
LT
46#define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */
47
48/* QP and CQ parameters */
49#define IB_MAD_QP_SEND_SIZE 128
50#define IB_MAD_QP_RECV_SIZE 512
b76aabc3
HR
51#define IB_MAD_QP_MIN_SIZE 64
52#define IB_MAD_QP_MAX_SIZE 8192
1da177e4
LT
53#define IB_MAD_SEND_REQ_MAX_SG 2
54#define IB_MAD_RECV_REQ_MAX_SG 1
55
56#define IB_MAD_SEND_Q_PSN 0
57
58/* Registration table sizes */
59#define MAX_MGMT_CLASS 80
548ead17 60#define MAX_MGMT_VERSION 0x83
1da177e4
LT
61#define MAX_MGMT_OUI 8
62#define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \
63 IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
64
65struct ib_mad_list_head {
66 struct list_head list;
67 struct ib_mad_queue *mad_queue;
68};
69
70struct ib_mad_private_header {
71 struct ib_mad_list_head mad_list;
72 struct ib_mad_recv_wc recv_wc;
24239aff 73 struct ib_wc wc;
1527106f 74 u64 mapping;
1da177e4
LT
75} __attribute__ ((packed));
76
77struct ib_mad_private {
78 struct ib_mad_private_header header;
c9082e51 79 size_t mad_size;
1da177e4 80 struct ib_grh grh;
c9082e51 81 u8 mad[0];
1da177e4
LT
82} __attribute__ ((packed));
83
f36e1793
JM
84struct ib_rmpp_segment {
85 struct list_head list;
86 u32 num;
87 u8 data[0];
88};
89
1da177e4
LT
90struct ib_mad_agent_private {
91 struct list_head agent_list;
92 struct ib_mad_agent agent;
93 struct ib_mad_reg_req *reg_req;
94 struct ib_mad_qp_info *qp_info;
95
96 spinlock_t lock;
97 struct list_head send_list;
98 struct list_head wait_list;
6a0c435e 99 struct list_head done_list;
c4028958 100 struct delayed_work timed_work;
1da177e4
LT
101 unsigned long timeout;
102 struct list_head local_list;
103 struct work_struct local_work;
fa619a77 104 struct list_head rmpp_list;
1da177e4
LT
105
106 atomic_t refcount;
1b52fa98 107 struct completion comp;
1da177e4
LT
108};
109
110struct ib_mad_snoop_private {
111 struct ib_mad_agent agent;
112 struct ib_mad_qp_info *qp_info;
113 int snoop_index;
114 int mad_snoop_flags;
115 atomic_t refcount;
1b52fa98 116 struct completion comp;
1da177e4
LT
117};
118
119struct ib_mad_send_wr_private {
120 struct ib_mad_list_head mad_list;
121 struct list_head agent_list;
d760ce8f 122 struct ib_mad_agent_private *mad_agent_priv;
34816ad9 123 struct ib_mad_send_buf send_buf;
1527106f
RC
124 u64 header_mapping;
125 u64 payload_mapping;
e622f2f4 126 struct ib_ud_wr send_wr;
1da177e4 127 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
97f52eb4 128 __be64 tid;
1da177e4 129 unsigned long timeout;
4fc8cd49
SH
130 int max_retries;
131 int retries_left;
1da177e4
LT
132 int retry;
133 int refcount;
134 enum ib_wc_status status;
fa619a77
HR
135
136 /* RMPP control */
f36e1793
JM
137 struct list_head rmpp_list;
138 struct ib_rmpp_segment *last_ack_seg;
139 struct ib_rmpp_segment *cur_seg;
fa619a77
HR
140 int last_ack;
141 int seg_num;
142 int newwin;
fa619a77 143 int pad;
1da177e4
LT
144};
145
146struct ib_mad_local_private {
147 struct list_head completion_list;
148 struct ib_mad_private *mad_priv;
149 struct ib_mad_agent_private *recv_mad_agent;
34816ad9 150 struct ib_mad_send_wr_private *mad_send_wr;
8e4349d1 151 size_t return_wc_byte_len;
1da177e4
LT
152};
153
154struct ib_mad_mgmt_method_table {
155 struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
156};
157
158struct ib_mad_mgmt_class_table {
159 struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
160};
161
162struct ib_mad_mgmt_vendor_class {
163 u8 oui[MAX_MGMT_OUI][3];
164 struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
165};
166
167struct ib_mad_mgmt_vendor_class_table {
168 struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
169};
170
171struct ib_mad_mgmt_version_table {
172 struct ib_mad_mgmt_class_table *class;
173 struct ib_mad_mgmt_vendor_class_table *vendor;
174};
175
176struct ib_mad_queue {
177 spinlock_t lock;
178 struct list_head list;
179 int count;
180 int max_active;
181 struct ib_mad_qp_info *qp_info;
182};
183
184struct ib_mad_qp_info {
185 struct ib_mad_port_private *port_priv;
186 struct ib_qp *qp;
187 struct ib_mad_queue send_queue;
188 struct ib_mad_queue recv_queue;
189 struct list_head overflow_list;
190 spinlock_t snoop_lock;
191 struct ib_mad_snoop_private **snoop_table;
192 int snoop_table_size;
193 atomic_t snoop_count;
194};
195
196struct ib_mad_port_private {
197 struct list_head port_list;
198 struct ib_device *device;
199 int port_num;
200 struct ib_cq *cq;
201 struct ib_pd *pd;
1da177e4
LT
202
203 spinlock_t reg_lock;
204 struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
205 struct list_head agent_list;
206 struct workqueue_struct *wq;
207 struct work_struct work;
208 struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
209};
210
fa619a77
HR
211int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
212
213struct ib_mad_send_wr_private *
f766c58f
IW
214ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
215 const struct ib_mad_recv_wc *mad_recv_wc);
fa619a77
HR
216
217void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
218 struct ib_mad_send_wc *mad_send_wc);
219
220void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);
221
222void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
223 int timeout_ms);
224
1da177e4 225#endif /* __IB_MAD_PRIV_H__ */
This page took 0.813626 seconds and 5 git commands to generate.