Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
0002 /*
0003  * Copyright (c) 2004, 2011 Intel Corporation.  All rights reserved.
0004  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
0005  * Copyright (c) 2004 Voltaire Corporation.  All rights reserved.
0006  * Copyright (c) 2019, Mellanox Technologies inc.  All rights reserved.
0007  */
0008 #ifndef CM_MSGS_H
0009 #define CM_MSGS_H
0010 
0011 #include <rdma/ibta_vol1_c12.h>
0012 #include <rdma/ib_mad.h>
0013 #include <rdma/ib_cm.h>
0014 
0015 /*
0016  * Parameters to routines below should be in network-byte order, and values
0017  * are returned in network-byte order.
0018  */
0019 
0020 #define IB_CM_CLASS_VERSION 2 /* IB specification 1.2 */
0021 
0022 static inline enum ib_qp_type cm_req_get_qp_type(struct cm_req_msg *req_msg)
0023 {
0024     u8 transport_type = IBA_GET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg);
0025     switch (transport_type) {
0026     case 0: return IB_QPT_RC;
0027     case 1: return IB_QPT_UC;
0028     case 3:
0029         switch (IBA_GET(CM_REQ_EXTENDED_TRANSPORT_TYPE, req_msg)) {
0030         case 1: return IB_QPT_XRC_TGT;
0031         default: return 0;
0032         }
0033     default: return 0;
0034     }
0035 }
0036 
0037 static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg,
0038                       enum ib_qp_type qp_type)
0039 {
0040     switch (qp_type) {
0041     case IB_QPT_UC:
0042         IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 1);
0043         break;
0044     case IB_QPT_XRC_INI:
0045         IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 3);
0046         IBA_SET(CM_REQ_EXTENDED_TRANSPORT_TYPE, req_msg, 1);
0047         break;
0048     default:
0049         IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 0);
0050     }
0051 }
0052 
0053 /* Message REJected or MRAed */
0054 enum cm_msg_response {
0055     CM_MSG_RESPONSE_REQ = 0x0,
0056     CM_MSG_RESPONSE_REP = 0x1,
0057     CM_MSG_RESPONSE_OTHER = 0x2
0058 };
0059 
0060 static inline __be32 cm_rep_get_qpn(struct cm_rep_msg *rep_msg, enum ib_qp_type qp_type)
0061 {
0062     return (qp_type == IB_QPT_XRC_INI) ?
0063                cpu_to_be32(IBA_GET(CM_REP_LOCAL_EE_CONTEXT_NUMBER,
0064                        rep_msg)) :
0065                cpu_to_be32(IBA_GET(CM_REP_LOCAL_QPN, rep_msg));
0066 }
0067 
0068 #endif /* CM_MSGS_H */