2 * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
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:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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.
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
32 * $Id: mad_priv.h 1389 2004-12-27 22:56:47Z roland $
35 #ifndef __IB_MAD_PRIV_H__
36 #define __IB_MAD_PRIV_H__
38 #include <linux/pci.h>
39 #include <linux/kthread.h>
40 #include <linux/workqueue.h>
45 #define PFX "ib_mad: "
47 #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */
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
55 #define IB_MAD_SEND_Q_PSN 0
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
64 struct ib_mad_list_head {
65 struct list_head list;
66 struct ib_mad_queue *mad_queue;
69 struct ib_mad_private_header {
70 struct ib_mad_list_head mad_list;
71 struct ib_mad_recv_wc recv_wc;
72 DECLARE_PCI_UNMAP_ADDR(mapping)
73 } __attribute__ ((packed));
75 struct ib_mad_private {
76 struct ib_mad_private_header header;
80 struct ib_rmpp_mad rmpp_mad;
83 } __attribute__ ((packed));
85 struct ib_mad_agent_private {
86 struct list_head agent_list;
87 struct ib_mad_agent agent;
88 struct ib_mad_reg_req *reg_req;
89 struct ib_mad_qp_info *qp_info;
92 struct list_head send_list;
93 struct list_head wait_list;
94 struct work_struct timed_work;
95 unsigned long timeout;
96 struct list_head local_list;
97 struct work_struct local_work;
100 wait_queue_head_t wait;
104 struct ib_mad_snoop_private {
105 struct ib_mad_agent agent;
106 struct ib_mad_qp_info *qp_info;
110 wait_queue_head_t wait;
113 struct ib_mad_send_wr_private {
114 struct ib_mad_list_head mad_list;
115 struct list_head agent_list;
116 struct ib_mad_agent *agent;
117 struct ib_send_wr send_wr;
118 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
119 u64 wr_id; /* client WR ID */
121 unsigned long timeout;
124 enum ib_wc_status status;
127 struct ib_mad_local_private {
128 struct list_head completion_list;
129 struct ib_mad_private *mad_priv;
130 struct ib_mad_agent_private *recv_mad_agent;
131 struct ib_send_wr send_wr;
132 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
133 u64 wr_id; /* client WR ID */
137 struct ib_mad_mgmt_method_table {
138 struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
141 struct ib_mad_mgmt_class_table {
142 struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
145 struct ib_mad_mgmt_vendor_class {
146 u8 oui[MAX_MGMT_OUI][3];
147 struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
150 struct ib_mad_mgmt_vendor_class_table {
151 struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
154 struct ib_mad_mgmt_version_table {
155 struct ib_mad_mgmt_class_table *class;
156 struct ib_mad_mgmt_vendor_class_table *vendor;
159 struct ib_mad_queue {
161 struct list_head list;
164 struct ib_mad_qp_info *qp_info;
167 struct ib_mad_qp_info {
168 struct ib_mad_port_private *port_priv;
170 struct ib_mad_queue send_queue;
171 struct ib_mad_queue recv_queue;
172 struct list_head overflow_list;
173 spinlock_t snoop_lock;
174 struct ib_mad_snoop_private **snoop_table;
175 int snoop_table_size;
176 atomic_t snoop_count;
179 struct ib_mad_port_private {
180 struct list_head port_list;
181 struct ib_device *device;
188 struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
189 struct list_head agent_list;
190 struct workqueue_struct *wq;
191 struct work_struct work;
192 struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
195 #endif /* __IB_MAD_PRIV_H__ */