2019-10-20 07:15:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
|
2005-07-27 18:45:40 +00:00
|
|
|
/*
|
2011-08-02 18:08:22 +00:00
|
|
|
* Copyright (c) 2004, 2011 Intel Corporation. All rights reserved.
|
2005-07-27 18:45:40 +00:00
|
|
|
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004 Voltaire Corporation. All rights reserved.
|
2019-10-20 07:15:56 +00:00
|
|
|
* Copyright (c) 2019, Mellanox Technologies inc. All rights reserved.
|
2005-07-27 18:45:40 +00:00
|
|
|
*/
|
2019-10-20 07:15:55 +00:00
|
|
|
#ifndef CM_MSGS_H
|
2005-07-27 18:45:40 +00:00
|
|
|
#define CM_MSGS_H
|
|
|
|
|
2020-01-16 17:00:32 +00:00
|
|
|
#include <rdma/ibta_vol1_c12.h>
|
2005-08-25 20:40:04 +00:00
|
|
|
#include <rdma/ib_mad.h>
|
2007-06-29 02:16:51 +00:00
|
|
|
#include <rdma/ib_cm.h>
|
2005-07-27 18:45:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Parameters to routines below should be in network-byte order, and values
|
|
|
|
* are returned in network-byte order.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IB_CM_CLASS_VERSION 2 /* IB specification 1.2 */
|
|
|
|
|
|
|
|
static inline enum ib_qp_type cm_req_get_qp_type(struct cm_req_msg *req_msg)
|
|
|
|
{
|
2020-01-16 17:00:33 +00:00
|
|
|
u8 transport_type = IBA_GET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg);
|
2021-04-07 08:15:49 +00:00
|
|
|
switch (transport_type) {
|
2005-07-27 18:45:40 +00:00
|
|
|
case 0: return IB_QPT_RC;
|
|
|
|
case 1: return IB_QPT_UC;
|
2011-05-13 17:46:20 +00:00
|
|
|
case 3:
|
2020-01-16 17:00:33 +00:00
|
|
|
switch (IBA_GET(CM_REQ_EXTENDED_TRANSPORT_TYPE, req_msg)) {
|
2011-05-13 17:46:20 +00:00
|
|
|
case 1: return IB_QPT_XRC_TGT;
|
|
|
|
default: return 0;
|
|
|
|
}
|
2005-07-27 18:45:40 +00:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg,
|
|
|
|
enum ib_qp_type qp_type)
|
|
|
|
{
|
2021-04-07 08:15:49 +00:00
|
|
|
switch (qp_type) {
|
2005-07-27 18:45:40 +00:00
|
|
|
case IB_QPT_UC:
|
2020-01-16 17:00:33 +00:00
|
|
|
IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 1);
|
2005-10-20 19:29:36 +00:00
|
|
|
break;
|
2011-05-13 17:46:20 +00:00
|
|
|
case IB_QPT_XRC_INI:
|
2020-01-16 17:00:33 +00:00
|
|
|
IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 3);
|
|
|
|
IBA_SET(CM_REQ_EXTENDED_TRANSPORT_TYPE, req_msg, 1);
|
2011-05-13 17:46:20 +00:00
|
|
|
break;
|
2005-07-27 18:45:40 +00:00
|
|
|
default:
|
2020-01-16 17:00:33 +00:00
|
|
|
IBA_SET(CM_REQ_TRANSPORT_SERVICE_TYPE, req_msg, 0);
|
2005-07-27 18:45:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Message REJected or MRAed */
|
|
|
|
enum cm_msg_response {
|
|
|
|
CM_MSG_RESPONSE_REQ = 0x0,
|
|
|
|
CM_MSG_RESPONSE_REP = 0x1,
|
|
|
|
CM_MSG_RESPONSE_OTHER = 0x2
|
|
|
|
};
|
|
|
|
|
2011-08-02 18:08:22 +00:00
|
|
|
static inline __be32 cm_rep_get_qpn(struct cm_rep_msg *rep_msg, enum ib_qp_type qp_type)
|
|
|
|
{
|
|
|
|
return (qp_type == IB_QPT_XRC_INI) ?
|
2020-01-16 17:00:34 +00:00
|
|
|
cpu_to_be32(IBA_GET(CM_REP_LOCAL_EE_CONTEXT_NUMBER,
|
|
|
|
rep_msg)) :
|
|
|
|
cpu_to_be32(IBA_GET(CM_REP_LOCAL_QPN, rep_msg));
|
2005-07-27 18:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CM_MSGS_H */
|