@@ -998,6 +998,112 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
998
998
return reason_code ;
999
999
}
1000
1000
1001
+ static void
1002
+ smcd_clc_prep_confirm_accept (struct smc_connection * conn ,
1003
+ struct smc_clc_msg_accept_confirm_v2 * clc_v2 ,
1004
+ int first_contact , u8 version ,
1005
+ u8 * eid , struct smc_init_info * ini ,
1006
+ int * fce_len ,
1007
+ struct smc_clc_first_contact_ext_v2x * fce_v2x ,
1008
+ struct smc_clc_msg_trail * trl )
1009
+ {
1010
+ struct smcd_dev * smcd = conn -> lgr -> smcd ;
1011
+ struct smc_clc_msg_accept_confirm * clc ;
1012
+ int len ;
1013
+
1014
+ /* SMC-D specific settings */
1015
+ clc = (struct smc_clc_msg_accept_confirm * )clc_v2 ;
1016
+ memcpy (clc -> hdr .eyecatcher , SMCD_EYECATCHER ,
1017
+ sizeof (SMCD_EYECATCHER ));
1018
+ clc -> hdr .typev1 = SMC_TYPE_D ;
1019
+ clc -> d0 .gid = htonll (smcd -> ops -> get_local_gid (smcd ));
1020
+ clc -> d0 .token = htonll (conn -> rmb_desc -> token );
1021
+ clc -> d0 .dmbe_size = conn -> rmbe_size_comp ;
1022
+ clc -> d0 .dmbe_idx = 0 ;
1023
+ memcpy (& clc -> d0 .linkid , conn -> lgr -> id , SMC_LGR_ID_SIZE );
1024
+ if (version == SMC_V1 ) {
1025
+ clc -> hdr .length = htons (SMCD_CLC_ACCEPT_CONFIRM_LEN );
1026
+ } else {
1027
+ clc_v2 -> d1 .chid = htons (smc_ism_get_chid (smcd ));
1028
+ if (eid && eid [0 ])
1029
+ memcpy (clc_v2 -> d1 .eid , eid , SMC_MAX_EID_LEN );
1030
+ len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 ;
1031
+ if (first_contact ) {
1032
+ * fce_len = smc_clc_fill_fce_v2x (fce_v2x , ini );
1033
+ len += * fce_len ;
1034
+ }
1035
+ clc_v2 -> hdr .length = htons (len );
1036
+ }
1037
+ memcpy (trl -> eyecatcher , SMCD_EYECATCHER ,
1038
+ sizeof (SMCD_EYECATCHER ));
1039
+ }
1040
+
1041
+ static void
1042
+ smcr_clc_prep_confirm_accept (struct smc_connection * conn ,
1043
+ struct smc_clc_msg_accept_confirm_v2 * clc_v2 ,
1044
+ int first_contact , u8 version ,
1045
+ u8 * eid , struct smc_init_info * ini ,
1046
+ int * fce_len ,
1047
+ struct smc_clc_first_contact_ext_v2x * fce_v2x ,
1048
+ struct smc_clc_fce_gid_ext * gle ,
1049
+ struct smc_clc_msg_trail * trl )
1050
+ {
1051
+ struct smc_clc_msg_accept_confirm * clc ;
1052
+ struct smc_link * link = conn -> lnk ;
1053
+ int len ;
1054
+
1055
+ /* SMC-R specific settings */
1056
+ clc = (struct smc_clc_msg_accept_confirm * )clc_v2 ;
1057
+ memcpy (clc -> hdr .eyecatcher , SMC_EYECATCHER ,
1058
+ sizeof (SMC_EYECATCHER ));
1059
+ clc -> hdr .typev1 = SMC_TYPE_R ;
1060
+ memcpy (clc -> r0 .lcl .id_for_peer , local_systemid ,
1061
+ sizeof (local_systemid ));
1062
+ memcpy (& clc -> r0 .lcl .gid , link -> gid , SMC_GID_SIZE );
1063
+ memcpy (& clc -> r0 .lcl .mac , & link -> smcibdev -> mac [link -> ibport - 1 ],
1064
+ ETH_ALEN );
1065
+ hton24 (clc -> r0 .qpn , link -> roce_qp -> qp_num );
1066
+ clc -> r0 .rmb_rkey =
1067
+ htonl (conn -> rmb_desc -> mr [link -> link_idx ]-> rkey );
1068
+ clc -> r0 .rmbe_idx = 1 ; /* for now: 1 RMB = 1 RMBE */
1069
+ clc -> r0 .rmbe_alert_token = htonl (conn -> alert_token_local );
1070
+ switch (clc -> hdr .type ) {
1071
+ case SMC_CLC_ACCEPT :
1072
+ clc -> r0 .qp_mtu = link -> path_mtu ;
1073
+ break ;
1074
+ case SMC_CLC_CONFIRM :
1075
+ clc -> r0 .qp_mtu = min (link -> path_mtu , link -> peer_mtu );
1076
+ break ;
1077
+ }
1078
+ clc -> r0 .rmbe_size = conn -> rmbe_size_comp ;
1079
+ clc -> r0 .rmb_dma_addr = conn -> rmb_desc -> is_vm ?
1080
+ cpu_to_be64 ((uintptr_t )conn -> rmb_desc -> cpu_addr ) :
1081
+ cpu_to_be64 ((u64 )sg_dma_address
1082
+ (conn -> rmb_desc -> sgt [link -> link_idx ].sgl ));
1083
+ hton24 (clc -> r0 .psn , link -> psn_initial );
1084
+ if (version == SMC_V1 ) {
1085
+ clc -> hdr .length = htons (SMCR_CLC_ACCEPT_CONFIRM_LEN );
1086
+ } else {
1087
+ if (eid && eid [0 ])
1088
+ memcpy (clc_v2 -> r1 .eid , eid , SMC_MAX_EID_LEN );
1089
+ len = SMCR_CLC_ACCEPT_CONFIRM_LEN_V2 ;
1090
+ if (first_contact ) {
1091
+ * fce_len = smc_clc_fill_fce_v2x (fce_v2x , ini );
1092
+ len += * fce_len ;
1093
+ fce_v2x -> fce_v2_base .v2_direct =
1094
+ !link -> lgr -> uses_gateway ;
1095
+ if (clc -> hdr .type == SMC_CLC_CONFIRM ) {
1096
+ memset (gle , 0 , sizeof (* gle ));
1097
+ gle -> gid_cnt = ini -> smcrv2 .gidlist .len ;
1098
+ len += sizeof (* gle );
1099
+ len += gle -> gid_cnt * sizeof (gle -> gid [0 ]);
1100
+ }
1101
+ }
1102
+ clc_v2 -> hdr .length = htons (len );
1103
+ }
1104
+ memcpy (trl -> eyecatcher , SMC_EYECATCHER , sizeof (SMC_EYECATCHER ));
1105
+ }
1106
+
1001
1107
/* build and send CLC CONFIRM / ACCEPT message */
1002
1108
static int smc_clc_send_confirm_accept (struct smc_sock * smc ,
1003
1109
struct smc_clc_msg_accept_confirm_v2 * clc_v2 ,
@@ -1006,11 +1112,10 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
1006
1112
{
1007
1113
struct smc_clc_first_contact_ext_v2x fce_v2x ;
1008
1114
struct smc_connection * conn = & smc -> conn ;
1009
- struct smcd_dev * smcd = conn -> lgr -> smcd ;
1010
1115
struct smc_clc_msg_accept_confirm * clc ;
1011
1116
struct smc_clc_fce_gid_ext gle ;
1012
1117
struct smc_clc_msg_trail trl ;
1013
- int i , len , fce_len ;
1118
+ int i , fce_len ;
1014
1119
struct kvec vec [5 ];
1015
1120
struct msghdr msg ;
1016
1121
@@ -1019,86 +1124,14 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
1019
1124
clc -> hdr .version = version ; /* SMC version */
1020
1125
if (first_contact )
1021
1126
clc -> hdr .typev2 |= SMC_FIRST_CONTACT_MASK ;
1022
- if (conn -> lgr -> is_smcd ) {
1023
- /* SMC-D specific settings */
1024
- memcpy (clc -> hdr .eyecatcher , SMCD_EYECATCHER ,
1025
- sizeof (SMCD_EYECATCHER ));
1026
- clc -> hdr .typev1 = SMC_TYPE_D ;
1027
- clc -> d0 .gid = htonll (smcd -> ops -> get_local_gid (smcd ));
1028
- clc -> d0 .token = htonll (conn -> rmb_desc -> token );
1029
- clc -> d0 .dmbe_size = conn -> rmbe_size_comp ;
1030
- clc -> d0 .dmbe_idx = 0 ;
1031
- memcpy (& clc -> d0 .linkid , conn -> lgr -> id , SMC_LGR_ID_SIZE );
1032
- if (version == SMC_V1 ) {
1033
- clc -> hdr .length = htons (SMCD_CLC_ACCEPT_CONFIRM_LEN );
1034
- } else {
1035
- clc_v2 -> d1 .chid = htons (smc_ism_get_chid (smcd ));
1036
- if (eid && eid [0 ])
1037
- memcpy (clc_v2 -> d1 .eid , eid , SMC_MAX_EID_LEN );
1038
- len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 ;
1039
- if (first_contact ) {
1040
- fce_len = smc_clc_fill_fce_v2x (& fce_v2x , ini );
1041
- len += fce_len ;
1042
- }
1043
- clc_v2 -> hdr .length = htons (len );
1044
- }
1045
- memcpy (trl .eyecatcher , SMCD_EYECATCHER ,
1046
- sizeof (SMCD_EYECATCHER ));
1047
- } else {
1048
- struct smc_link * link = conn -> lnk ;
1049
-
1050
- /* SMC-R specific settings */
1051
- memcpy (clc -> hdr .eyecatcher , SMC_EYECATCHER ,
1052
- sizeof (SMC_EYECATCHER ));
1053
- clc -> hdr .typev1 = SMC_TYPE_R ;
1054
- clc -> hdr .length = htons (SMCR_CLC_ACCEPT_CONFIRM_LEN );
1055
- memcpy (clc -> r0 .lcl .id_for_peer , local_systemid ,
1056
- sizeof (local_systemid ));
1057
- memcpy (& clc -> r0 .lcl .gid , link -> gid , SMC_GID_SIZE );
1058
- memcpy (& clc -> r0 .lcl .mac , & link -> smcibdev -> mac [link -> ibport - 1 ],
1059
- ETH_ALEN );
1060
- hton24 (clc -> r0 .qpn , link -> roce_qp -> qp_num );
1061
- clc -> r0 .rmb_rkey =
1062
- htonl (conn -> rmb_desc -> mr [link -> link_idx ]-> rkey );
1063
- clc -> r0 .rmbe_idx = 1 ; /* for now: 1 RMB = 1 RMBE */
1064
- clc -> r0 .rmbe_alert_token = htonl (conn -> alert_token_local );
1065
- switch (clc -> hdr .type ) {
1066
- case SMC_CLC_ACCEPT :
1067
- clc -> r0 .qp_mtu = link -> path_mtu ;
1068
- break ;
1069
- case SMC_CLC_CONFIRM :
1070
- clc -> r0 .qp_mtu = min (link -> path_mtu , link -> peer_mtu );
1071
- break ;
1072
- }
1073
- clc -> r0 .rmbe_size = conn -> rmbe_size_comp ;
1074
- clc -> r0 .rmb_dma_addr = conn -> rmb_desc -> is_vm ?
1075
- cpu_to_be64 ((uintptr_t )conn -> rmb_desc -> cpu_addr ) :
1076
- cpu_to_be64 ((u64 )sg_dma_address
1077
- (conn -> rmb_desc -> sgt [link -> link_idx ].sgl ));
1078
- hton24 (clc -> r0 .psn , link -> psn_initial );
1079
- if (version == SMC_V1 ) {
1080
- clc -> hdr .length = htons (SMCR_CLC_ACCEPT_CONFIRM_LEN );
1081
- } else {
1082
- if (eid && eid [0 ])
1083
- memcpy (clc_v2 -> r1 .eid , eid , SMC_MAX_EID_LEN );
1084
- len = SMCR_CLC_ACCEPT_CONFIRM_LEN_V2 ;
1085
- if (first_contact ) {
1086
- fce_len = smc_clc_fill_fce_v2x (& fce_v2x , ini );
1087
- len += fce_len ;
1088
- fce_v2x .fce_v2_base .v2_direct =
1089
- !link -> lgr -> uses_gateway ;
1090
- if (clc -> hdr .type == SMC_CLC_CONFIRM ) {
1091
- memset (& gle , 0 , sizeof (gle ));
1092
- gle .gid_cnt = ini -> smcrv2 .gidlist .len ;
1093
- len += sizeof (gle );
1094
- len += gle .gid_cnt * sizeof (gle .gid [0 ]);
1095
- }
1096
- }
1097
- clc_v2 -> hdr .length = htons (len );
1098
- }
1099
- memcpy (trl .eyecatcher , SMC_EYECATCHER , sizeof (SMC_EYECATCHER ));
1100
- }
1101
-
1127
+ if (conn -> lgr -> is_smcd )
1128
+ smcd_clc_prep_confirm_accept (conn , clc_v2 , first_contact ,
1129
+ version , eid , ini , & fce_len ,
1130
+ & fce_v2x , & trl );
1131
+ else
1132
+ smcr_clc_prep_confirm_accept (conn , clc_v2 , first_contact ,
1133
+ version , eid , ini , & fce_len ,
1134
+ & fce_v2x , & gle , & trl );
1102
1135
memset (& msg , 0 , sizeof (msg ));
1103
1136
i = 0 ;
1104
1137
vec [i ].iov_base = clc_v2 ;
0 commit comments