Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved. | |
3 | * | |
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: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistributions of source code must retain the above | |
15 | * copyright notice, this list of conditions and the following | |
16 | * disclaimer. | |
17 | * | |
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. | |
22 | * | |
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 | |
30 | * SOFTWARE. | |
31 | * | |
d760ce8f | 32 | * $Id: mad_priv.h 1980 2005-03-11 22:33:53Z sean.hefty $ |
1da177e4 LT |
33 | */ |
34 | ||
35 | #ifndef __IB_MAD_PRIV_H__ | |
36 | #define __IB_MAD_PRIV_H__ | |
37 | ||
38 | #include <linux/pci.h> | |
39 | #include <linux/kthread.h> | |
40 | #include <linux/workqueue.h> | |
41 | #include <ib_mad.h> | |
42 | #include <ib_smi.h> | |
43 | ||
44 | ||
45 | #define PFX "ib_mad: " | |
46 | ||
47 | #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */ | |
48 | ||
49 | /* QP and CQ parameters */ | |
50 | #define IB_MAD_QP_SEND_SIZE 128 | |
51 | #define IB_MAD_QP_RECV_SIZE 512 | |
52 | #define IB_MAD_SEND_REQ_MAX_SG 2 | |
53 | #define IB_MAD_RECV_REQ_MAX_SG 1 | |
54 | ||
55 | #define IB_MAD_SEND_Q_PSN 0 | |
56 | ||
57 | /* Registration table sizes */ | |
58 | #define MAX_MGMT_CLASS 80 | |
59 | #define MAX_MGMT_VERSION 8 | |
60 | #define MAX_MGMT_OUI 8 | |
61 | #define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \ | |
62 | IB_MGMT_CLASS_VENDOR_RANGE2_START + 1) | |
63 | ||
64 | struct ib_mad_list_head { | |
65 | struct list_head list; | |
66 | struct ib_mad_queue *mad_queue; | |
67 | }; | |
68 | ||
69 | struct ib_mad_private_header { | |
70 | struct ib_mad_list_head mad_list; | |
71 | struct ib_mad_recv_wc recv_wc; | |
24239aff | 72 | struct ib_wc wc; |
1da177e4 LT |
73 | DECLARE_PCI_UNMAP_ADDR(mapping) |
74 | } __attribute__ ((packed)); | |
75 | ||
76 | struct ib_mad_private { | |
77 | struct ib_mad_private_header header; | |
78 | struct ib_grh grh; | |
79 | union { | |
80 | struct ib_mad mad; | |
81 | struct ib_rmpp_mad rmpp_mad; | |
82 | struct ib_smp smp; | |
83 | } mad; | |
84 | } __attribute__ ((packed)); | |
85 | ||
86 | struct ib_mad_agent_private { | |
87 | struct list_head agent_list; | |
88 | struct ib_mad_agent agent; | |
89 | struct ib_mad_reg_req *reg_req; | |
90 | struct ib_mad_qp_info *qp_info; | |
91 | ||
92 | spinlock_t lock; | |
93 | struct list_head send_list; | |
94 | struct list_head wait_list; | |
6a0c435e | 95 | struct list_head done_list; |
1da177e4 LT |
96 | struct work_struct timed_work; |
97 | unsigned long timeout; | |
98 | struct list_head local_list; | |
99 | struct work_struct local_work; | |
100 | struct list_head canceled_list; | |
101 | struct work_struct canceled_work; | |
102 | ||
103 | atomic_t refcount; | |
104 | wait_queue_head_t wait; | |
105 | u8 rmpp_version; | |
106 | }; | |
107 | ||
108 | struct ib_mad_snoop_private { | |
109 | struct ib_mad_agent agent; | |
110 | struct ib_mad_qp_info *qp_info; | |
111 | int snoop_index; | |
112 | int mad_snoop_flags; | |
113 | atomic_t refcount; | |
114 | wait_queue_head_t wait; | |
115 | }; | |
116 | ||
117 | struct ib_mad_send_wr_private { | |
118 | struct ib_mad_list_head mad_list; | |
119 | struct list_head agent_list; | |
d760ce8f | 120 | struct ib_mad_agent_private *mad_agent_priv; |
1da177e4 LT |
121 | struct ib_send_wr send_wr; |
122 | struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; | |
123 | u64 wr_id; /* client WR ID */ | |
124 | u64 tid; | |
125 | unsigned long timeout; | |
f75b7a52 | 126 | int retries; |
1da177e4 LT |
127 | int retry; |
128 | int refcount; | |
129 | enum ib_wc_status status; | |
130 | }; | |
131 | ||
132 | struct ib_mad_local_private { | |
133 | struct list_head completion_list; | |
134 | struct ib_mad_private *mad_priv; | |
135 | struct ib_mad_agent_private *recv_mad_agent; | |
136 | struct ib_send_wr send_wr; | |
137 | struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; | |
138 | u64 wr_id; /* client WR ID */ | |
139 | u64 tid; | |
f75b7a52 | 140 | int retries; |
1da177e4 LT |
141 | }; |
142 | ||
143 | struct ib_mad_mgmt_method_table { | |
144 | struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS]; | |
145 | }; | |
146 | ||
147 | struct ib_mad_mgmt_class_table { | |
148 | struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS]; | |
149 | }; | |
150 | ||
151 | struct ib_mad_mgmt_vendor_class { | |
152 | u8 oui[MAX_MGMT_OUI][3]; | |
153 | struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI]; | |
154 | }; | |
155 | ||
156 | struct ib_mad_mgmt_vendor_class_table { | |
157 | struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2]; | |
158 | }; | |
159 | ||
160 | struct ib_mad_mgmt_version_table { | |
161 | struct ib_mad_mgmt_class_table *class; | |
162 | struct ib_mad_mgmt_vendor_class_table *vendor; | |
163 | }; | |
164 | ||
165 | struct ib_mad_queue { | |
166 | spinlock_t lock; | |
167 | struct list_head list; | |
168 | int count; | |
169 | int max_active; | |
170 | struct ib_mad_qp_info *qp_info; | |
171 | }; | |
172 | ||
173 | struct ib_mad_qp_info { | |
174 | struct ib_mad_port_private *port_priv; | |
175 | struct ib_qp *qp; | |
176 | struct ib_mad_queue send_queue; | |
177 | struct ib_mad_queue recv_queue; | |
178 | struct list_head overflow_list; | |
179 | spinlock_t snoop_lock; | |
180 | struct ib_mad_snoop_private **snoop_table; | |
181 | int snoop_table_size; | |
182 | atomic_t snoop_count; | |
183 | }; | |
184 | ||
185 | struct ib_mad_port_private { | |
186 | struct list_head port_list; | |
187 | struct ib_device *device; | |
188 | int port_num; | |
189 | struct ib_cq *cq; | |
190 | struct ib_pd *pd; | |
191 | struct ib_mr *mr; | |
192 | ||
193 | spinlock_t reg_lock; | |
194 | struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION]; | |
195 | struct list_head agent_list; | |
196 | struct workqueue_struct *wq; | |
197 | struct work_struct work; | |
198 | struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE]; | |
199 | }; | |
200 | ||
201 | extern kmem_cache_t *ib_mad_cache; | |
202 | ||
203 | #endif /* __IB_MAD_PRIV_H__ */ |