Path: blob/master/drivers/infiniband/hw/cxgb3/iwch_cm.h
15112 views
/*1* Copyright (c) 2006 Chelsio, Inc. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/31#ifndef _IWCH_CM_H_32#define _IWCH_CM_H_3334#include <linux/inet.h>35#include <linux/wait.h>36#include <linux/spinlock.h>37#include <linux/kref.h>3839#include <rdma/ib_verbs.h>40#include <rdma/iw_cm.h>4142#include "cxgb3_offload.h"43#include "iwch_provider.h"4445#define MPA_KEY_REQ "MPA ID Req Frame"46#define MPA_KEY_REP "MPA ID Rep Frame"4748#define MPA_MAX_PRIVATE_DATA 25649#define MPA_REV 0 /* XXX - amso1100 uses rev 0 ! */50#define MPA_REJECT 0x2051#define MPA_CRC 0x4052#define MPA_MARKERS 0x8053#define MPA_FLAGS_MASK 0xE05455#define put_ep(ep) { \56PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __func__, __LINE__, \57ep, atomic_read(&((ep)->kref.refcount))); \58WARN_ON(atomic_read(&((ep)->kref.refcount)) < 1); \59kref_put(&((ep)->kref), __free_ep); \60}6162#define get_ep(ep) { \63PDBG("get_ep (via %s:%u) ep %p, refcnt %d\n", __func__, __LINE__, \64ep, atomic_read(&((ep)->kref.refcount))); \65kref_get(&((ep)->kref)); \66}6768struct mpa_message {69u8 key[16];70u8 flags;71u8 revision;72__be16 private_data_size;73u8 private_data[0];74};7576struct terminate_message {77u8 layer_etype;78u8 ecode;79__be16 hdrct_rsvd;80u8 len_hdrs[0];81};8283#define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28)8485enum iwch_layers_types {86LAYER_RDMAP = 0x00,87LAYER_DDP = 0x10,88LAYER_MPA = 0x20,89RDMAP_LOCAL_CATA = 0x00,90RDMAP_REMOTE_PROT = 0x01,91RDMAP_REMOTE_OP = 0x02,92DDP_LOCAL_CATA = 0x00,93DDP_TAGGED_ERR = 0x01,94DDP_UNTAGGED_ERR = 0x02,95DDP_LLP = 0x0396};9798enum iwch_rdma_ecodes {99RDMAP_INV_STAG = 0x00,100RDMAP_BASE_BOUNDS = 0x01,101RDMAP_ACC_VIOL = 0x02,102RDMAP_STAG_NOT_ASSOC = 0x03,103RDMAP_TO_WRAP = 0x04,104RDMAP_INV_VERS = 0x05,105RDMAP_INV_OPCODE = 0x06,106RDMAP_STREAM_CATA = 0x07,107RDMAP_GLOBAL_CATA = 0x08,108RDMAP_CANT_INV_STAG = 0x09,109RDMAP_UNSPECIFIED = 0xff110};111112enum iwch_ddp_ecodes {113DDPT_INV_STAG = 0x00,114DDPT_BASE_BOUNDS = 0x01,115DDPT_STAG_NOT_ASSOC = 0x02,116DDPT_TO_WRAP = 0x03,117DDPT_INV_VERS = 0x04,118DDPU_INV_QN = 0x01,119DDPU_INV_MSN_NOBUF = 0x02,120DDPU_INV_MSN_RANGE = 0x03,121DDPU_INV_MO = 0x04,122DDPU_MSG_TOOBIG = 0x05,123DDPU_INV_VERS = 0x06124};125126enum iwch_mpa_ecodes {127MPA_CRC_ERR = 0x02,128MPA_MARKER_ERR = 0x03129};130131enum iwch_ep_state {132IDLE = 0,133LISTEN,134CONNECTING,135MPA_REQ_WAIT,136MPA_REQ_SENT,137MPA_REQ_RCVD,138MPA_REP_SENT,139FPDU_MODE,140ABORTING,141CLOSING,142MORIBUND,143DEAD,144};145146enum iwch_ep_flags {147PEER_ABORT_IN_PROGRESS = 0,148ABORT_REQ_IN_PROGRESS = 1,149RELEASE_RESOURCES = 2,150CLOSE_SENT = 3,151};152153struct iwch_ep_common {154struct iw_cm_id *cm_id;155struct iwch_qp *qp;156struct t3cdev *tdev;157enum iwch_ep_state state;158struct kref kref;159spinlock_t lock;160struct sockaddr_in local_addr;161struct sockaddr_in remote_addr;162wait_queue_head_t waitq;163int rpl_done;164int rpl_err;165unsigned long flags;166};167168struct iwch_listen_ep {169struct iwch_ep_common com;170unsigned int stid;171int backlog;172};173174struct iwch_ep {175struct iwch_ep_common com;176struct iwch_ep *parent_ep;177struct timer_list timer;178unsigned int atid;179u32 hwtid;180u32 snd_seq;181u32 rcv_seq;182struct l2t_entry *l2t;183struct dst_entry *dst;184struct sk_buff *mpa_skb;185struct iwch_mpa_attributes mpa_attr;186unsigned int mpa_pkt_len;187u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA];188u8 tos;189u16 emss;190u16 plen;191u32 ird;192u32 ord;193};194195static inline struct iwch_ep *to_ep(struct iw_cm_id *cm_id)196{197return cm_id->provider_data;198}199200static inline struct iwch_listen_ep *to_listen_ep(struct iw_cm_id *cm_id)201{202return cm_id->provider_data;203}204205static inline int compute_wscale(int win)206{207int wscale = 0;208209while (wscale < 14 && (65535<<wscale) < win)210wscale++;211return wscale;212}213214/* CM prototypes */215216int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);217int iwch_create_listen(struct iw_cm_id *cm_id, int backlog);218int iwch_destroy_listen(struct iw_cm_id *cm_id);219int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);220int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);221int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp);222int iwch_quiesce_tid(struct iwch_ep *ep);223int iwch_resume_tid(struct iwch_ep *ep);224void __free_ep(struct kref *kref);225void iwch_rearp(struct iwch_ep *ep);226int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, struct l2t_entry *l2t);227228int __init iwch_cm_init(void);229void __exit iwch_cm_term(void);230extern int peer2peer;231232#endif /* _IWCH_CM_H_ */233234235