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