Skip to content

Commit 7290178

Browse files
GuangguanWangdavem330
authored andcommitted
net/smc: add vendor unique experimental options area in clc handshake
Add vendor unique experimental options area in clc handshake. In clc accept and confirm msg, vendor unique experimental options use the 16-Bytes reserved field, which defined in struct smc_clc_fce_gid_ext in previous version. Because of the struct smc_clc_first_contact_ext is widely used and limit the scope of modification, this patch moves the 16-Bytes reserved field out of struct smc_clc_fce_gid_ext, and followed with the struct smc_clc_first_contact_ext in a new struct names struct smc_clc_first_contact_ext_v2x. For SMC-R first connection, in previous version, the struct smc_clc_ first_contact_ext and the 16-Bytes reserved field has already been included in clc accept and confirm msg. Thus, this patch use struct smc_clc_first_contact_ext_v2x instead of the struct smc_clc_first_ contact_ext and the 16-Bytes reserved field in SMC-R clc accept and confirm msg is compatible with previous version. For SMC-D first connection, in previous version, only the struct smc_ clc_first_contact_ext is included in clc accept and confirm msg, and the 16-Bytes reserved field is not included. Thus, when the negotiated smc release version is the version before v2.1, we still use struct smc_clc_first_contact_ext for compatible consideration. If the negotiated smc release version is v2.1 or later, use struct smc_clc_first_contact_ ext_v2x instead. Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com> Reviewed-by: Tony Lu <tonylu@linux.alibaba.com> Reviewed-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1e70094 commit 7290178

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

net/smc/af_smc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ static int smc_connect_ism_vlan_cleanup(struct smc_sock *smc,
11441144

11451145
#define SMC_CLC_MAX_ACCEPT_LEN \
11461146
(sizeof(struct smc_clc_msg_accept_confirm_v2) + \
1147-
sizeof(struct smc_clc_first_contact_ext) + \
1147+
sizeof(struct smc_clc_first_contact_ext_v2x) + \
11481148
sizeof(struct smc_clc_msg_trail))
11491149

11501150
/* CLC handshake during connect */

net/smc/smc_clc.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ smc_clc_msg_acc_conf_valid(struct smc_clc_msg_accept_confirm_v2 *clc_v2)
391391
return false;
392392
} else {
393393
if (hdr->typev1 == SMC_TYPE_D &&
394-
ntohs(hdr->length) != SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 &&
395-
(ntohs(hdr->length) != SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 +
396-
sizeof(struct smc_clc_first_contact_ext)))
394+
ntohs(hdr->length) < SMCD_CLC_ACCEPT_CONFIRM_LEN_V2)
397395
return false;
398396
if (hdr->typev1 == SMC_TYPE_R &&
399397
ntohs(hdr->length) < SMCR_CLC_ACCEPT_CONFIRM_LEN_V2)
@@ -420,13 +418,19 @@ smc_clc_msg_decl_valid(struct smc_clc_msg_decline *dclc)
420418
return true;
421419
}
422420

423-
static void smc_clc_fill_fce(struct smc_clc_first_contact_ext *fce, int *len, int release_nr)
421+
static int smc_clc_fill_fce(struct smc_clc_first_contact_ext_v2x *fce,
422+
struct smc_init_info *ini)
424423
{
424+
int ret = sizeof(*fce);
425+
425426
memset(fce, 0, sizeof(*fce));
426-
fce->os_type = SMC_CLC_OS_LINUX;
427-
fce->release = release_nr;
428-
memcpy(fce->hostname, smc_hostname, sizeof(smc_hostname));
429-
(*len) += sizeof(*fce);
427+
fce->fce_v2_base.os_type = SMC_CLC_OS_LINUX;
428+
fce->fce_v2_base.release = ini->release_nr;
429+
memcpy(fce->fce_v2_base.hostname, smc_hostname, sizeof(smc_hostname));
430+
if (ini->is_smcd && ini->release_nr < SMC_RELEASE_1)
431+
ret = sizeof(struct smc_clc_first_contact_ext);
432+
433+
return ret;
430434
}
431435

432436
/* check if received message has a correct header length and contains valid
@@ -986,13 +990,13 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
986990
u8 *eid, struct smc_init_info *ini)
987991
{
988992
struct smc_connection *conn = &smc->conn;
993+
struct smc_clc_first_contact_ext_v2x fce;
989994
struct smc_clc_msg_accept_confirm *clc;
990-
struct smc_clc_first_contact_ext fce;
991995
struct smc_clc_fce_gid_ext gle;
992996
struct smc_clc_msg_trail trl;
997+
int i, len, fce_len;
993998
struct kvec vec[5];
994999
struct msghdr msg;
995-
int i, len;
9961000

9971001
/* send SMC Confirm CLC msg */
9981002
clc = (struct smc_clc_msg_accept_confirm *)clc_v2;
@@ -1018,8 +1022,10 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10181022
if (eid && eid[0])
10191023
memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
10201024
len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;
1021-
if (first_contact)
1022-
smc_clc_fill_fce(&fce, &len, ini->release_nr);
1025+
if (first_contact) {
1026+
fce_len = smc_clc_fill_fce(&fce, ini);
1027+
len += fce_len;
1028+
}
10231029
clc_v2->hdr.length = htons(len);
10241030
}
10251031
memcpy(trl.eyecatcher, SMCD_EYECATCHER,
@@ -1063,15 +1069,14 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10631069
memcpy(clc_v2->r1.eid, eid, SMC_MAX_EID_LEN);
10641070
len = SMCR_CLC_ACCEPT_CONFIRM_LEN_V2;
10651071
if (first_contact) {
1066-
smc_clc_fill_fce(&fce, &len, ini->release_nr);
1067-
fce.v2_direct = !link->lgr->uses_gateway;
1068-
memset(&gle, 0, sizeof(gle));
1072+
fce_len = smc_clc_fill_fce(&fce, ini);
1073+
len += fce_len;
1074+
fce.fce_v2_base.v2_direct = !link->lgr->uses_gateway;
10691075
if (clc->hdr.type == SMC_CLC_CONFIRM) {
1076+
memset(&gle, 0, sizeof(gle));
10701077
gle.gid_cnt = ini->smcrv2.gidlist.len;
10711078
len += sizeof(gle);
10721079
len += gle.gid_cnt * sizeof(gle.gid[0]);
1073-
} else {
1074-
len += sizeof(gle.reserved);
10751080
}
10761081
}
10771082
clc_v2->hdr.length = htons(len);
@@ -1094,17 +1099,14 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10941099
sizeof(trl);
10951100
if (version > SMC_V1 && first_contact) {
10961101
vec[i].iov_base = &fce;
1097-
vec[i++].iov_len = sizeof(fce);
1102+
vec[i++].iov_len = fce_len;
10981103
if (!conn->lgr->is_smcd) {
10991104
if (clc->hdr.type == SMC_CLC_CONFIRM) {
11001105
vec[i].iov_base = &gle;
11011106
vec[i++].iov_len = sizeof(gle);
11021107
vec[i].iov_base = &ini->smcrv2.gidlist.list;
11031108
vec[i++].iov_len = gle.gid_cnt *
11041109
sizeof(gle.gid[0]);
1105-
} else {
1106-
vec[i].iov_base = &gle.reserved;
1107-
vec[i++].iov_len = sizeof(gle.reserved);
11081110
}
11091111
}
11101112
}

net/smc/smc_clc.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ struct smc_clc_msg_proposal_prefix { /* prefix part of clc proposal message*/
147147
struct smc_clc_msg_smcd { /* SMC-D GID information */
148148
struct smc_clc_smcd_gid_chid ism; /* ISM native GID+CHID of requestor */
149149
__be16 v2_ext_offset; /* SMC Version 2 Extension Offset */
150-
u8 reserved[28];
150+
u8 vendor_oui[3]; /* vendor organizationally unique identifier */
151+
u8 vendor_exp_options[5];
152+
u8 reserved[20];
151153
};
152154

153155
struct smc_clc_smcd_v2_extension {
@@ -231,8 +233,17 @@ struct smc_clc_first_contact_ext {
231233
u8 hostname[SMC_MAX_HOSTNAME_LEN];
232234
};
233235

236+
struct smc_clc_first_contact_ext_v2x {
237+
struct smc_clc_first_contact_ext fce_v2_base;
238+
u8 reserved3[4];
239+
__be32 vendor_exp_options;
240+
u8 reserved4[8];
241+
} __packed; /* format defined in
242+
* IBM Shared Memory Communications Version 2 (Third Edition)
243+
* (https://www.ibm.com/support/pages/node/7009315)
244+
*/
245+
234246
struct smc_clc_fce_gid_ext {
235-
u8 reserved[16];
236247
u8 gid_cnt;
237248
u8 reserved2[3];
238249
u8 gid[][SMC_GID_SIZE];

0 commit comments

Comments
 (0)