Commit 5205ac44 authored by Wen Gu's avatar Wen Gu Committed by David S. Miller

net/smc: introduce sub-functions for smc_clc_send_confirm_accept()

There is a large if-else block in smc_clc_send_confirm_accept() and it
is better to split it into two sub-functions.
Suggested-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Signed-off-by: default avatarWen Gu <guwen@linux.alibaba.com>
Reviewed-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac053a16
......@@ -998,29 +998,21 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
return reason_code;
}
/* build and send CLC CONFIRM / ACCEPT message */
static int smc_clc_send_confirm_accept(struct smc_sock *smc,
static void
smcd_clc_prep_confirm_accept(struct smc_connection *conn,
struct smc_clc_msg_accept_confirm_v2 *clc_v2,
int first_contact, u8 version,
u8 *eid, struct smc_init_info *ini)
u8 *eid, struct smc_init_info *ini,
int *fce_len,
struct smc_clc_first_contact_ext_v2x *fce_v2x,
struct smc_clc_msg_trail *trl)
{
struct smc_clc_first_contact_ext_v2x fce_v2x;
struct smc_connection *conn = &smc->conn;
struct smcd_dev *smcd = conn->lgr->smcd;
struct smc_clc_msg_accept_confirm *clc;
struct smc_clc_fce_gid_ext gle;
struct smc_clc_msg_trail trl;
int i, len, fce_len;
struct kvec vec[5];
struct msghdr msg;
int len;
/* send SMC Confirm CLC msg */
clc = (struct smc_clc_msg_accept_confirm *)clc_v2;
clc->hdr.version = version; /* SMC version */
if (first_contact)
clc->hdr.typev2 |= SMC_FIRST_CONTACT_MASK;
if (conn->lgr->is_smcd) {
/* SMC-D specific settings */
clc = (struct smc_clc_msg_accept_confirm *)clc_v2;
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
sizeof(SMCD_EYECATCHER));
clc->hdr.typev1 = SMC_TYPE_D;
......@@ -1037,21 +1029,34 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;
if (first_contact) {
fce_len = smc_clc_fill_fce_v2x(&fce_v2x, ini);
len += fce_len;
*fce_len = smc_clc_fill_fce_v2x(fce_v2x, ini);
len += *fce_len;
}
clc_v2->hdr.length = htons(len);
}
memcpy(trl.eyecatcher, SMCD_EYECATCHER,
memcpy(trl->eyecatcher, SMCD_EYECATCHER,
sizeof(SMCD_EYECATCHER));
} else {
}
static void
smcr_clc_prep_confirm_accept(struct smc_connection *conn,
struct smc_clc_msg_accept_confirm_v2 *clc_v2,
int first_contact, u8 version,
u8 *eid, struct smc_init_info *ini,
int *fce_len,
struct smc_clc_first_contact_ext_v2x *fce_v2x,
struct smc_clc_fce_gid_ext *gle,
struct smc_clc_msg_trail *trl)
{
struct smc_clc_msg_accept_confirm *clc;
struct smc_link *link = conn->lnk;
int len;
/* SMC-R specific settings */
clc = (struct smc_clc_msg_accept_confirm *)clc_v2;
memcpy(clc->hdr.eyecatcher, SMC_EYECATCHER,
sizeof(SMC_EYECATCHER));
clc->hdr.typev1 = SMC_TYPE_R;
clc->hdr.length = htons(SMCR_CLC_ACCEPT_CONFIRM_LEN);
memcpy(clc->r0.lcl.id_for_peer, local_systemid,
sizeof(local_systemid));
memcpy(&clc->r0.lcl.gid, link->gid, SMC_GID_SIZE);
......@@ -1083,22 +1088,50 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
memcpy(clc_v2->r1.eid, eid, SMC_MAX_EID_LEN);
len = SMCR_CLC_ACCEPT_CONFIRM_LEN_V2;
if (first_contact) {
fce_len = smc_clc_fill_fce_v2x(&fce_v2x, ini);
len += fce_len;
fce_v2x.fce_v2_base.v2_direct =
*fce_len = smc_clc_fill_fce_v2x(fce_v2x, ini);
len += *fce_len;
fce_v2x->fce_v2_base.v2_direct =
!link->lgr->uses_gateway;
if (clc->hdr.type == SMC_CLC_CONFIRM) {
memset(&gle, 0, sizeof(gle));
gle.gid_cnt = ini->smcrv2.gidlist.len;
len += sizeof(gle);
len += gle.gid_cnt * sizeof(gle.gid[0]);
memset(gle, 0, sizeof(*gle));
gle->gid_cnt = ini->smcrv2.gidlist.len;
len += sizeof(*gle);
len += gle->gid_cnt * sizeof(gle->gid[0]);
}
}
clc_v2->hdr.length = htons(len);
}
memcpy(trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
}
memcpy(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
}
/* build and send CLC CONFIRM / ACCEPT message */
static int smc_clc_send_confirm_accept(struct smc_sock *smc,
struct smc_clc_msg_accept_confirm_v2 *clc_v2,
int first_contact, u8 version,
u8 *eid, struct smc_init_info *ini)
{
struct smc_clc_first_contact_ext_v2x fce_v2x;
struct smc_connection *conn = &smc->conn;
struct smc_clc_msg_accept_confirm *clc;
struct smc_clc_fce_gid_ext gle;
struct smc_clc_msg_trail trl;
int i, fce_len;
struct kvec vec[5];
struct msghdr msg;
/* send SMC Confirm CLC msg */
clc = (struct smc_clc_msg_accept_confirm *)clc_v2;
clc->hdr.version = version; /* SMC version */
if (first_contact)
clc->hdr.typev2 |= SMC_FIRST_CONTACT_MASK;
if (conn->lgr->is_smcd)
smcd_clc_prep_confirm_accept(conn, clc_v2, first_contact,
version, eid, ini, &fce_len,
&fce_v2x, &trl);
else
smcr_clc_prep_confirm_accept(conn, clc_v2, first_contact,
version, eid, ini, &fce_len,
&fce_v2x, &gle, &trl);
memset(&msg, 0, sizeof(msg));
i = 0;
vec[i].iov_base = clc_v2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment