2019-10-20 10:15:56 +03:00
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2005-07-27 11:45:40 -07:00
/*
2011-08-02 11:08:22 -07:00
* Copyright ( c ) 2004 , 2011 Intel Corporation . All rights reserved .
2005-07-27 11:45:40 -07:00
* Copyright ( c ) 2004 Topspin Corporation . All rights reserved .
* Copyright ( c ) 2004 Voltaire Corporation . All rights reserved .
2019-10-20 10:15:56 +03:00
* Copyright ( c ) 2019 , Mellanox Technologies inc . All rights reserved .
2005-07-27 11:45:40 -07:00
*/
2019-10-20 10:15:55 +03:00
# ifndef CM_MSGS_H
2005-07-27 11:45:40 -07:00
# define CM_MSGS_H
2020-01-16 13:00:32 -04:00
# include <rdma/ibta_vol1_c12.h>
2005-08-25 13:40:04 -07:00
# include <rdma/ib_mad.h>
2007-06-28 19:16:51 -07:00
# include <rdma/ib_cm.h>
2005-07-27 11:45:40 -07: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 */
struct cm_req_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 rsvd4 ;
__be64 service_id ;
__be64 local_ca_guid ;
__be32 rsvd24 ;
__be32 local_qkey ;
2005-07-27 11:45:40 -07:00
/* local QPN:24, responder resources:8 */
2005-08-13 21:05:57 -07:00
__be32 offset32 ;
2005-07-27 11:45:40 -07:00
/* local EECN:24, initiator depth:8 */
2005-08-13 21:05:57 -07:00
__be32 offset36 ;
2005-07-27 11:45:40 -07:00
/*
* remote EECN : 24 , remote CM response timeout : 5 ,
* transport service type : 2 , end - to - end flow control : 1
*/
2005-08-13 21:05:57 -07:00
__be32 offset40 ;
2005-07-27 11:45:40 -07:00
/* starting PSN:24, local CM response timeout:5, retry count:3 */
2005-08-13 21:05:57 -07:00
__be32 offset44 ;
__be16 pkey ;
2005-07-27 11:45:40 -07:00
/* path MTU:4, RDC exists:1, RNR retry count:3. */
u8 offset50 ;
2011-05-13 10:46:20 -07:00
/* max CM Retries:4, SRQ:1, extended transport type:3 */
2005-07-27 11:45:40 -07:00
u8 offset51 ;
2005-08-13 21:05:57 -07:00
__be16 primary_local_lid ;
__be16 primary_remote_lid ;
2005-07-27 11:45:40 -07:00
union ib_gid primary_local_gid ;
union ib_gid primary_remote_gid ;
/* flow label:20, rsvd:6, packet rate:6 */
2005-08-13 21:05:57 -07:00
__be32 primary_offset88 ;
2005-07-27 11:45:40 -07:00
u8 primary_traffic_class ;
u8 primary_hop_limit ;
/* SL:4, subnet local:1, rsvd:3 */
u8 primary_offset94 ;
/* local ACK timeout:5, rsvd:3 */
u8 primary_offset95 ;
2005-08-13 21:05:57 -07:00
__be16 alt_local_lid ;
__be16 alt_remote_lid ;
2005-07-27 11:45:40 -07:00
union ib_gid alt_local_gid ;
union ib_gid alt_remote_gid ;
/* flow label:20, rsvd:6, packet rate:6 */
2005-08-13 21:05:57 -07:00
__be32 alt_offset132 ;
2005-07-27 11:45:40 -07:00
u8 alt_traffic_class ;
u8 alt_hop_limit ;
/* SL:4, subnet local:1, rsvd:3 */
u8 alt_offset138 ;
/* local ACK timeout:5, rsvd:3 */
u8 alt_offset139 ;
2015-05-03 09:48:26 -04:00
u32 private_data [ IB_CM_REQ_PRIVATE_DATA_SIZE / sizeof ( u32 ) ] ;
2005-07-27 11:45:40 -07:00
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
static inline __be32 cm_req_get_local_qpn ( struct cm_req_msg * req_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( req_msg - > offset32 ) > > 8 ) ;
}
2005-08-13 21:05:57 -07:00
static inline void cm_req_set_local_qpn ( struct cm_req_msg * req_msg , __be32 qpn )
2005-07-27 11:45:40 -07:00
{
req_msg - > offset32 = cpu_to_be32 ( ( be32_to_cpu ( qpn ) < < 8 ) |
( be32_to_cpu ( req_msg - > offset32 ) &
0x000000FF ) ) ;
}
static inline enum ib_qp_type cm_req_get_qp_type ( struct cm_req_msg * req_msg )
{
2020-01-16 13:00:33 -04:00
u8 transport_type = IBA_GET ( CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg ) ;
2005-07-27 11:45:40 -07:00
switch ( transport_type ) {
case 0 : return IB_QPT_RC ;
case 1 : return IB_QPT_UC ;
2011-05-13 10:46:20 -07:00
case 3 :
2020-01-16 13:00:33 -04:00
switch ( IBA_GET ( CM_REQ_EXTENDED_TRANSPORT_TYPE , req_msg ) ) {
2011-05-13 10:46:20 -07:00
case 1 : return IB_QPT_XRC_TGT ;
default : return 0 ;
}
2005-07-27 11:45:40 -07:00
default : return 0 ;
}
}
static inline void cm_req_set_qp_type ( struct cm_req_msg * req_msg ,
enum ib_qp_type qp_type )
{
switch ( qp_type ) {
case IB_QPT_UC :
2020-01-16 13:00:33 -04:00
IBA_SET ( CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg , 1 ) ;
2005-10-20 12:29:36 -07:00
break ;
2011-05-13 10:46:20 -07:00
case IB_QPT_XRC_INI :
2020-01-16 13:00:33 -04:00
IBA_SET ( CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg , 3 ) ;
IBA_SET ( CM_REQ_EXTENDED_TRANSPORT_TYPE , req_msg , 1 ) ;
2011-05-13 10:46:20 -07:00
break ;
2005-07-27 11:45:40 -07:00
default :
2020-01-16 13:00:33 -04:00
IBA_SET ( CM_REQ_TRANSPORT_SERVICE_TYPE , req_msg , 0 ) ;
2005-07-27 11:45:40 -07:00
}
}
2005-08-13 21:05:57 -07:00
static inline __be32 cm_req_get_starting_psn ( struct cm_req_msg * req_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( req_msg - > offset44 ) > > 8 ) ;
}
static inline void cm_req_set_starting_psn ( struct cm_req_msg * req_msg ,
2005-08-13 21:05:57 -07:00
__be32 starting_psn )
2005-07-27 11:45:40 -07:00
{
req_msg - > offset44 = cpu_to_be32 ( ( be32_to_cpu ( starting_psn ) < < 8 ) |
( be32_to_cpu ( req_msg - > offset44 ) & 0x000000FF ) ) ;
}
2005-08-13 21:05:57 -07:00
static inline __be32 cm_req_get_primary_flow_label ( struct cm_req_msg * req_msg )
2005-07-27 11:45:40 -07:00
{
2005-08-13 21:05:57 -07:00
return cpu_to_be32 ( be32_to_cpu ( req_msg - > primary_offset88 ) > > 12 ) ;
2005-07-27 11:45:40 -07:00
}
static inline void cm_req_set_primary_flow_label ( struct cm_req_msg * req_msg ,
2005-08-13 21:05:57 -07:00
__be32 flow_label )
2005-07-27 11:45:40 -07:00
{
req_msg - > primary_offset88 = cpu_to_be32 (
( be32_to_cpu ( req_msg - > primary_offset88 ) &
0x00000FFF ) |
( be32_to_cpu ( flow_label ) < < 12 ) ) ;
}
2005-08-13 21:05:57 -07:00
static inline __be32 cm_req_get_alt_flow_label ( struct cm_req_msg * req_msg )
2005-07-27 11:45:40 -07:00
{
2005-08-13 21:05:57 -07:00
return cpu_to_be32 ( be32_to_cpu ( req_msg - > alt_offset132 ) > > 12 ) ;
2005-07-27 11:45:40 -07:00
}
static inline void cm_req_set_alt_flow_label ( struct cm_req_msg * req_msg ,
2005-08-13 21:05:57 -07:00
__be32 flow_label )
2005-07-27 11:45:40 -07:00
{
req_msg - > alt_offset132 = cpu_to_be32 (
( be32_to_cpu ( req_msg - > alt_offset132 ) &
0x00000FFF ) |
( be32_to_cpu ( flow_label ) < < 12 ) ) ;
}
/* Message REJected or MRAed */
enum cm_msg_response {
CM_MSG_RESPONSE_REQ = 0x0 ,
CM_MSG_RESPONSE_REP = 0x1 ,
CM_MSG_RESPONSE_OTHER = 0x2
} ;
struct cm_mra_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
/* message MRAed:2, rsvd:6 */
u8 offset8 ;
/* service timeout:5, rsvd:3 */
u8 offset9 ;
u8 private_data [ IB_CM_MRA_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_rej_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
/* message REJected:2, rsvd:6 */
u8 offset8 ;
/* reject info length:7, rsvd:1. */
u8 offset9 ;
2005-08-13 21:05:57 -07:00
__be16 reason ;
2005-07-27 11:45:40 -07:00
u8 ari [ IB_CM_REJ_ARI_LENGTH ] ;
u8 private_data [ IB_CM_REJ_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_rep_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
__be32 local_qkey ;
2005-07-27 11:45:40 -07:00
/* local QPN:24, rsvd:8 */
2005-08-13 21:05:57 -07:00
__be32 offset12 ;
2005-07-27 11:45:40 -07:00
/* local EECN:24, rsvd:8 */
2005-08-13 21:05:57 -07:00
__be32 offset16 ;
2005-07-27 11:45:40 -07:00
/* starting PSN:24 rsvd:8 */
2005-08-13 21:05:57 -07:00
__be32 offset20 ;
2005-07-27 11:45:40 -07:00
u8 resp_resources ;
u8 initiator_depth ;
/* target ACK delay:5, failover accepted:2, end-to-end flow control:1 */
u8 offset26 ;
/* RNR retry count:3, SRQ:1, rsvd:5 */
u8 offset27 ;
2005-08-13 21:05:57 -07:00
__be64 local_ca_guid ;
2005-07-27 11:45:40 -07:00
u8 private_data [ IB_CM_REP_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
static inline __be32 cm_rep_get_local_qpn ( struct cm_rep_msg * rep_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( rep_msg - > offset12 ) > > 8 ) ;
}
2005-08-13 21:05:57 -07:00
static inline void cm_rep_set_local_qpn ( struct cm_rep_msg * rep_msg , __be32 qpn )
2005-07-27 11:45:40 -07:00
{
rep_msg - > offset12 = cpu_to_be32 ( ( be32_to_cpu ( qpn ) < < 8 ) |
( be32_to_cpu ( rep_msg - > offset12 ) & 0x000000FF ) ) ;
}
2011-08-02 11:08:22 -07:00
static inline __be32 cm_rep_get_local_eecn ( struct cm_rep_msg * rep_msg )
{
return cpu_to_be32 ( be32_to_cpu ( rep_msg - > offset16 ) > > 8 ) ;
}
static inline void cm_rep_set_local_eecn ( struct cm_rep_msg * rep_msg , __be32 eecn )
{
rep_msg - > offset16 = cpu_to_be32 ( ( be32_to_cpu ( eecn ) < < 8 ) |
( be32_to_cpu ( rep_msg - > offset16 ) & 0x000000FF ) ) ;
}
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 ) ?
cm_rep_get_local_eecn ( rep_msg ) : cm_rep_get_local_qpn ( rep_msg ) ;
}
2005-08-13 21:05:57 -07:00
static inline __be32 cm_rep_get_starting_psn ( struct cm_rep_msg * rep_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( rep_msg - > offset20 ) > > 8 ) ;
}
static inline void cm_rep_set_starting_psn ( struct cm_rep_msg * rep_msg ,
2005-08-13 21:05:57 -07:00
__be32 starting_psn )
2005-07-27 11:45:40 -07:00
{
rep_msg - > offset20 = cpu_to_be32 ( ( be32_to_cpu ( starting_psn ) < < 8 ) |
( be32_to_cpu ( rep_msg - > offset20 ) & 0x000000FF ) ) ;
}
struct cm_rtu_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
u8 private_data [ IB_CM_RTU_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_dreq_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
/* remote QPN/EECN:24, rsvd:8 */
2005-08-13 21:05:57 -07:00
__be32 offset8 ;
2005-07-27 11:45:40 -07:00
u8 private_data [ IB_CM_DREQ_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
static inline __be32 cm_dreq_get_remote_qpn ( struct cm_dreq_msg * dreq_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( dreq_msg - > offset8 ) > > 8 ) ;
}
2005-08-13 21:05:57 -07:00
static inline void cm_dreq_set_remote_qpn ( struct cm_dreq_msg * dreq_msg , __be32 qpn )
2005-07-27 11:45:40 -07:00
{
dreq_msg - > offset8 = cpu_to_be32 ( ( be32_to_cpu ( qpn ) < < 8 ) |
( be32_to_cpu ( dreq_msg - > offset8 ) & 0x000000FF ) ) ;
}
struct cm_drep_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
u8 private_data [ IB_CM_DREP_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_lap_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
__be32 rsvd8 ;
2005-07-27 11:45:40 -07:00
/* remote QPN/EECN:24, remote CM response timeout:5, rsvd:3 */
2005-08-13 21:05:57 -07:00
__be32 offset12 ;
__be32 rsvd16 ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
__be16 alt_local_lid ;
__be16 alt_remote_lid ;
2005-07-27 11:45:40 -07:00
union ib_gid alt_local_gid ;
union ib_gid alt_remote_gid ;
/* flow label:20, rsvd:4, traffic class:8 */
2005-08-13 21:05:57 -07:00
__be32 offset56 ;
2005-07-27 11:45:40 -07:00
u8 alt_hop_limit ;
/* rsvd:2, packet rate:6 */
2005-08-13 21:05:57 -07:00
u8 offset61 ;
2005-07-27 11:45:40 -07:00
/* SL:4, subnet local:1, rsvd:3 */
2005-08-13 21:05:57 -07:00
u8 offset62 ;
2005-07-27 11:45:40 -07:00
/* local ACK timeout:5, rsvd:3 */
2005-08-13 21:05:57 -07:00
u8 offset63 ;
2005-07-27 11:45:40 -07:00
u8 private_data [ IB_CM_LAP_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
static inline __be32 cm_lap_get_flow_label ( struct cm_lap_msg * lap_msg )
2005-07-27 11:45:40 -07:00
{
2005-08-13 21:05:57 -07:00
return cpu_to_be32 ( be32_to_cpu ( lap_msg - > offset56 ) > > 12 ) ;
2005-07-27 11:45:40 -07:00
}
struct cm_apr_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 local_comm_id ;
__be32 remote_comm_id ;
2005-07-27 11:45:40 -07:00
u8 info_length ;
u8 ap_status ;
2011-12-19 21:46:53 +02:00
__be16 rsvd ;
2005-07-27 11:45:40 -07:00
u8 info [ IB_CM_APR_INFO_LENGTH ] ;
u8 private_data [ IB_CM_APR_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_sidr_req_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 request_id ;
__be16 pkey ;
__be16 rsvd ;
__be64 service_id ;
2005-07-27 11:45:40 -07:00
2015-05-03 09:48:26 -04:00
u32 private_data [ IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE / sizeof ( u32 ) ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
struct cm_sidr_rep_msg {
struct ib_mad_hdr hdr ;
2005-08-13 21:05:57 -07:00
__be32 request_id ;
2005-07-27 11:45:40 -07:00
u8 status ;
u8 info_length ;
2005-08-13 21:05:57 -07:00
__be16 rsvd ;
2005-07-27 11:45:40 -07:00
/* QPN:24, rsvd:8 */
2005-08-13 21:05:57 -07:00
__be32 offset8 ;
__be64 service_id ;
__be32 qkey ;
2005-07-27 11:45:40 -07:00
u8 info [ IB_CM_SIDR_REP_INFO_LENGTH ] ;
u8 private_data [ IB_CM_SIDR_REP_PRIVATE_DATA_SIZE ] ;
2019-02-25 08:52:30 +02:00
} __packed ;
2005-07-27 11:45:40 -07:00
2005-08-13 21:05:57 -07:00
static inline __be32 cm_sidr_rep_get_qpn ( struct cm_sidr_rep_msg * sidr_rep_msg )
2005-07-27 11:45:40 -07:00
{
return cpu_to_be32 ( be32_to_cpu ( sidr_rep_msg - > offset8 ) > > 8 ) ;
}
static inline void cm_sidr_rep_set_qpn ( struct cm_sidr_rep_msg * sidr_rep_msg ,
2005-08-13 21:05:57 -07:00
__be32 qpn )
2005-07-27 11:45:40 -07:00
{
sidr_rep_msg - > offset8 = cpu_to_be32 ( ( be32_to_cpu ( qpn ) < < 8 ) |
( be32_to_cpu ( sidr_rep_msg - > offset8 ) &
0x000000FF ) ) ;
}
# endif /* CM_MSGS_H */