Path: blob/master/drivers/infiniband/core/mad_priv.h
37212 views
/*1* Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.2* Copyright (c) 2005 Intel Corporation. All rights reserved.3* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.4* Copyright (c) 2009 HNR Consulting. All rights reserved.5*6* This software is available to you under a choice of one of two7* licenses. You may choose to be licensed under the terms of the GNU8* General Public License (GPL) Version 2, available from the file9* COPYING in the main directory of this source tree, or the10* OpenIB.org BSD license below:11*12* Redistribution and use in source and binary forms, with or13* without modification, are permitted provided that the following14* conditions are met:15*16* - Redistributions of source code must retain the above17* copyright notice, this list of conditions and the following18* disclaimer.19*20* - Redistributions in binary form must reproduce the above21* copyright notice, this list of conditions and the following22* disclaimer in the documentation and/or other materials23* provided with the distribution.24*25* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,26* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF27* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND28* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS29* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN30* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN31* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE32* SOFTWARE.33*/3435#ifndef __IB_MAD_PRIV_H__36#define __IB_MAD_PRIV_H__3738#include <linux/completion.h>39#include <linux/err.h>40#include <linux/workqueue.h>41#include <rdma/ib_mad.h>42#include <rdma/ib_smi.h>434445#define PFX "ib_mad: "4647#define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */4849/* QP and CQ parameters */50#define IB_MAD_QP_SEND_SIZE 12851#define IB_MAD_QP_RECV_SIZE 51252#define IB_MAD_QP_MIN_SIZE 6453#define IB_MAD_QP_MAX_SIZE 819254#define IB_MAD_SEND_REQ_MAX_SG 255#define IB_MAD_RECV_REQ_MAX_SG 15657#define IB_MAD_SEND_Q_PSN 05859/* Registration table sizes */60#define MAX_MGMT_CLASS 8061#define MAX_MGMT_VERSION 862#define MAX_MGMT_OUI 863#define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \64IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)6566struct ib_mad_list_head {67struct list_head list;68struct ib_mad_queue *mad_queue;69};7071struct ib_mad_private_header {72struct ib_mad_list_head mad_list;73struct ib_mad_recv_wc recv_wc;74struct ib_wc wc;75u64 mapping;76} __attribute__ ((packed));7778struct ib_mad_private {79struct ib_mad_private_header header;80struct ib_grh grh;81union {82struct ib_mad mad;83struct ib_rmpp_mad rmpp_mad;84struct ib_smp smp;85} mad;86} __attribute__ ((packed));8788struct ib_rmpp_segment {89struct list_head list;90u32 num;91u8 data[0];92};9394struct ib_mad_agent_private {95struct list_head agent_list;96struct ib_mad_agent agent;97struct ib_mad_reg_req *reg_req;98struct ib_mad_qp_info *qp_info;99100spinlock_t lock;101struct list_head send_list;102struct list_head wait_list;103struct list_head done_list;104struct delayed_work timed_work;105unsigned long timeout;106struct list_head local_list;107struct work_struct local_work;108struct list_head rmpp_list;109110atomic_t refcount;111struct completion comp;112};113114struct ib_mad_snoop_private {115struct ib_mad_agent agent;116struct ib_mad_qp_info *qp_info;117int snoop_index;118int mad_snoop_flags;119atomic_t refcount;120struct completion comp;121};122123struct ib_mad_send_wr_private {124struct ib_mad_list_head mad_list;125struct list_head agent_list;126struct ib_mad_agent_private *mad_agent_priv;127struct ib_mad_send_buf send_buf;128u64 header_mapping;129u64 payload_mapping;130struct ib_send_wr send_wr;131struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];132__be64 tid;133unsigned long timeout;134int max_retries;135int retries_left;136int retry;137int refcount;138enum ib_wc_status status;139140/* RMPP control */141struct list_head rmpp_list;142struct ib_rmpp_segment *last_ack_seg;143struct ib_rmpp_segment *cur_seg;144int last_ack;145int seg_num;146int newwin;147int pad;148};149150struct ib_mad_local_private {151struct list_head completion_list;152struct ib_mad_private *mad_priv;153struct ib_mad_agent_private *recv_mad_agent;154struct ib_mad_send_wr_private *mad_send_wr;155};156157struct ib_mad_mgmt_method_table {158struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];159};160161struct ib_mad_mgmt_class_table {162struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];163};164165struct ib_mad_mgmt_vendor_class {166u8 oui[MAX_MGMT_OUI][3];167struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];168};169170struct ib_mad_mgmt_vendor_class_table {171struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];172};173174struct ib_mad_mgmt_version_table {175struct ib_mad_mgmt_class_table *class;176struct ib_mad_mgmt_vendor_class_table *vendor;177};178179struct ib_mad_queue {180spinlock_t lock;181struct list_head list;182int count;183int max_active;184struct ib_mad_qp_info *qp_info;185};186187struct ib_mad_qp_info {188struct ib_mad_port_private *port_priv;189struct ib_qp *qp;190struct ib_mad_queue send_queue;191struct ib_mad_queue recv_queue;192struct list_head overflow_list;193spinlock_t snoop_lock;194struct ib_mad_snoop_private **snoop_table;195int snoop_table_size;196atomic_t snoop_count;197};198199struct ib_mad_port_private {200struct list_head port_list;201struct ib_device *device;202int port_num;203struct ib_cq *cq;204struct ib_pd *pd;205struct ib_mr *mr;206207spinlock_t reg_lock;208struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];209struct list_head agent_list;210struct workqueue_struct *wq;211struct work_struct work;212struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];213};214215int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);216217struct ib_mad_send_wr_private *218ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,219struct ib_mad_recv_wc *mad_recv_wc);220221void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,222struct ib_mad_send_wc *mad_send_wc);223224void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);225226void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,227int timeout_ms);228229#endif /* __IB_MAD_PRIV_H__ */230231232