Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
0003  * Copyright (c) 2005 Intel Corporation. All rights reserved.
0004  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
0005  * Copyright (c) 2009 HNR Consulting. All rights reserved.
0006  *
0007  * This software is available to you under a choice of one of two
0008  * licenses.  You may choose to be licensed under the terms of the GNU
0009  * General Public License (GPL) Version 2, available from the file
0010  * COPYING in the main directory of this source tree, or the
0011  * OpenIB.org BSD license below:
0012  *
0013  *     Redistribution and use in source and binary forms, with or
0014  *     without modification, are permitted provided that the following
0015  *     conditions are met:
0016  *
0017  *      - Redistributions of source code must retain the above
0018  *        copyright notice, this list of conditions and the following
0019  *        disclaimer.
0020  *
0021  *      - Redistributions in binary form must reproduce the above
0022  *        copyright notice, this list of conditions and the following
0023  *        disclaimer in the documentation and/or other materials
0024  *        provided with the distribution.
0025  *
0026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0027  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0028  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0029  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0030  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0031  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0032  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0033  * SOFTWARE.
0034  */
0035 
0036 #ifndef __IB_MAD_PRIV_H__
0037 #define __IB_MAD_PRIV_H__
0038 
0039 #include <linux/completion.h>
0040 #include <linux/err.h>
0041 #include <linux/workqueue.h>
0042 #include <rdma/ib_mad.h>
0043 #include <rdma/ib_smi.h>
0044 #include <rdma/opa_smi.h>
0045 
0046 #define IB_MAD_QPS_CORE     2 /* Always QP0 and QP1 as a minimum */
0047 
0048 /* QP and CQ parameters */
0049 #define IB_MAD_QP_SEND_SIZE 128
0050 #define IB_MAD_QP_RECV_SIZE 512
0051 #define IB_MAD_QP_MIN_SIZE  64
0052 #define IB_MAD_QP_MAX_SIZE  8192
0053 #define IB_MAD_SEND_REQ_MAX_SG  2
0054 #define IB_MAD_RECV_REQ_MAX_SG  1
0055 
0056 #define IB_MAD_SEND_Q_PSN   0
0057 
0058 /* Registration table sizes */
0059 #define MAX_MGMT_CLASS      80
0060 #define MAX_MGMT_VERSION    0x83
0061 #define MAX_MGMT_OUI        8
0062 #define MAX_MGMT_VENDOR_RANGE2  (IB_MGMT_CLASS_VENDOR_RANGE2_END - \
0063                 IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
0064 
0065 struct ib_mad_list_head {
0066     struct list_head list;
0067     struct ib_cqe cqe;
0068     struct ib_mad_queue *mad_queue;
0069 };
0070 
0071 struct ib_mad_private_header {
0072     struct ib_mad_list_head mad_list;
0073     struct ib_mad_recv_wc recv_wc;
0074     struct ib_wc wc;
0075     u64 mapping;
0076 } __packed;
0077 
0078 struct ib_mad_private {
0079     struct ib_mad_private_header header;
0080     size_t mad_size;
0081     struct ib_grh grh;
0082     u8 mad[];
0083 } __packed;
0084 
0085 struct ib_rmpp_segment {
0086     struct list_head list;
0087     u32 num;
0088     u8 data[];
0089 };
0090 
0091 struct ib_mad_agent_private {
0092     struct ib_mad_agent agent;
0093     struct ib_mad_reg_req *reg_req;
0094     struct ib_mad_qp_info *qp_info;
0095 
0096     spinlock_t lock;
0097     struct list_head send_list;
0098     struct list_head wait_list;
0099     struct list_head done_list;
0100     struct delayed_work timed_work;
0101     unsigned long timeout;
0102     struct list_head local_list;
0103     struct work_struct local_work;
0104     struct list_head rmpp_list;
0105 
0106     refcount_t refcount;
0107     union {
0108         struct completion comp;
0109         struct rcu_head rcu;
0110     };
0111 };
0112 
0113 struct ib_mad_snoop_private {
0114     struct ib_mad_agent agent;
0115     struct ib_mad_qp_info *qp_info;
0116     int snoop_index;
0117     int mad_snoop_flags;
0118     struct completion comp;
0119 };
0120 
0121 struct ib_mad_send_wr_private {
0122     struct ib_mad_list_head mad_list;
0123     struct list_head agent_list;
0124     struct ib_mad_agent_private *mad_agent_priv;
0125     struct ib_mad_send_buf send_buf;
0126     u64 header_mapping;
0127     u64 payload_mapping;
0128     struct ib_ud_wr send_wr;
0129     struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
0130     __be64 tid;
0131     unsigned long timeout;
0132     int max_retries;
0133     int retries_left;
0134     int retry;
0135     int refcount;
0136     enum ib_wc_status status;
0137 
0138     /* RMPP control */
0139     struct list_head rmpp_list;
0140     struct ib_rmpp_segment *last_ack_seg;
0141     struct ib_rmpp_segment *cur_seg;
0142     int last_ack;
0143     int seg_num;
0144     int newwin;
0145     int pad;
0146 };
0147 
0148 struct ib_mad_local_private {
0149     struct list_head completion_list;
0150     struct ib_mad_private *mad_priv;
0151     struct ib_mad_agent_private *recv_mad_agent;
0152     struct ib_mad_send_wr_private *mad_send_wr;
0153     size_t return_wc_byte_len;
0154 };
0155 
0156 struct ib_mad_mgmt_method_table {
0157     struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
0158 };
0159 
0160 struct ib_mad_mgmt_class_table {
0161     struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
0162 };
0163 
0164 struct ib_mad_mgmt_vendor_class {
0165     u8  oui[MAX_MGMT_OUI][3];
0166     struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
0167 };
0168 
0169 struct ib_mad_mgmt_vendor_class_table {
0170     struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
0171 };
0172 
0173 struct ib_mad_mgmt_version_table {
0174     struct ib_mad_mgmt_class_table *class;
0175     struct ib_mad_mgmt_vendor_class_table *vendor;
0176 };
0177 
0178 struct ib_mad_queue {
0179     spinlock_t lock;
0180     struct list_head list;
0181     int count;
0182     int max_active;
0183     struct ib_mad_qp_info *qp_info;
0184 };
0185 
0186 struct ib_mad_qp_info {
0187     struct ib_mad_port_private *port_priv;
0188     struct ib_qp *qp;
0189     struct ib_mad_queue send_queue;
0190     struct ib_mad_queue recv_queue;
0191     struct list_head overflow_list;
0192     spinlock_t snoop_lock;
0193     struct ib_mad_snoop_private **snoop_table;
0194     int snoop_table_size;
0195     atomic_t snoop_count;
0196 };
0197 
0198 struct ib_mad_port_private {
0199     struct list_head port_list;
0200     struct ib_device *device;
0201     int port_num;
0202     struct ib_cq *cq;
0203     struct ib_pd *pd;
0204 
0205     spinlock_t reg_lock;
0206     struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
0207     struct workqueue_struct *wq;
0208     struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
0209 };
0210 
0211 int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
0212 
0213 struct ib_mad_send_wr_private *
0214 ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
0215          const struct ib_mad_recv_wc *mad_recv_wc);
0216 
0217 void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
0218                  struct ib_mad_send_wc *mad_send_wc);
0219 
0220 void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);
0221 
0222 void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
0223               unsigned long timeout_ms);
0224 
0225 #endif  /* __IB_MAD_PRIV_H__ */