Skip to content

Commit 5ac54d8

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: introduce better field names
Field names "srv_first_contact" and "cln_first_contact" are misleading, since they apply to both, server and client. Rename them to "first_contact_peer" and "first_contact_local". Rename "ism_gid" by the more precise name "ism_peer_gid". Rename version constant "SMC_CLC_V1" into "SMC_V1". No functional change. Signed-off-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a60a2b1 commit 5ac54d8

File tree

6 files changed

+55
-57
lines changed

6 files changed

+55
-57
lines changed

net/smc/af_smc.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,11 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code)
523523

524524
/* abort connecting */
525525
static int smc_connect_abort(struct smc_sock *smc, int reason_code,
526-
int local_contact)
526+
int local_first)
527527
{
528528
bool is_smcd = smc->conn.lgr->is_smcd;
529529

530-
if (local_contact == SMC_FIRST_CONTACT)
530+
if (local_first)
531531
smc_lgr_cleanup_early(&smc->conn);
532532
else
533533
smc_conn_free(&smc->conn);
@@ -615,7 +615,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
615615
ini->is_smcd = false;
616616
ini->ib_lcl = &aclc->lcl;
617617
ini->ib_clcqpn = ntoh24(aclc->qpn);
618-
ini->srv_first_contact = aclc->hdr.flag;
618+
ini->first_contact_peer = aclc->hdr.flag;
619619

620620
mutex_lock(&smc_client_lgr_pending);
621621
reason_code = smc_conn_create(smc, ini);
@@ -626,7 +626,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
626626

627627
smc_conn_save_peer_info(smc, aclc);
628628

629-
if (ini->cln_first_contact == SMC_FIRST_CONTACT) {
629+
if (ini->first_contact_local) {
630630
link = smc->conn.lnk;
631631
} else {
632632
/* set link that was assigned by server */
@@ -643,51 +643,51 @@ static int smc_connect_rdma(struct smc_sock *smc,
643643
}
644644
if (!link)
645645
return smc_connect_abort(smc, SMC_CLC_DECL_NOSRVLINK,
646-
ini->cln_first_contact);
646+
ini->first_contact_local);
647647
smc->conn.lnk = link;
648648
}
649649

650650
/* create send buffer and rmb */
651651
if (smc_buf_create(smc, false))
652652
return smc_connect_abort(smc, SMC_CLC_DECL_MEM,
653-
ini->cln_first_contact);
653+
ini->first_contact_local);
654654

655-
if (ini->cln_first_contact == SMC_FIRST_CONTACT)
655+
if (ini->first_contact_local)
656656
smc_link_save_peer_info(link, aclc);
657657

658658
if (smc_rmb_rtoken_handling(&smc->conn, link, aclc))
659659
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RTOK,
660-
ini->cln_first_contact);
660+
ini->first_contact_local);
661661

662662
smc_close_init(smc);
663663
smc_rx_init(smc);
664664

665-
if (ini->cln_first_contact == SMC_FIRST_CONTACT) {
665+
if (ini->first_contact_local) {
666666
if (smc_ib_ready_link(link))
667667
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RDYLNK,
668-
ini->cln_first_contact);
668+
ini->first_contact_local);
669669
} else {
670670
if (smcr_lgr_reg_rmbs(link, smc->conn.rmb_desc))
671671
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_REGRMB,
672-
ini->cln_first_contact);
672+
ini->first_contact_local);
673673
}
674674
smc_rmb_sync_sg_for_device(&smc->conn);
675675

676676
reason_code = smc_clc_send_confirm(smc);
677677
if (reason_code)
678678
return smc_connect_abort(smc, reason_code,
679-
ini->cln_first_contact);
679+
ini->first_contact_local);
680680

681681
smc_tx_init(smc);
682682

683-
if (ini->cln_first_contact == SMC_FIRST_CONTACT) {
683+
if (ini->first_contact_local) {
684684
/* QP confirmation over RoCE fabric */
685685
smc_llc_flow_initiate(link->lgr, SMC_LLC_FLOW_ADD_LINK);
686686
reason_code = smcr_clnt_conf_first_link(smc);
687687
smc_llc_flow_stop(link->lgr, &link->lgr->llc_flow_lcl);
688688
if (reason_code)
689689
return smc_connect_abort(smc, reason_code,
690-
ini->cln_first_contact);
690+
ini->first_contact_local);
691691
}
692692
mutex_unlock(&smc_client_lgr_pending);
693693

@@ -707,8 +707,8 @@ static int smc_connect_ism(struct smc_sock *smc,
707707
int rc = 0;
708708

709709
ini->is_smcd = true;
710-
ini->ism_gid = aclc->gid;
711-
ini->srv_first_contact = aclc->hdr.flag;
710+
ini->ism_peer_gid = aclc->gid;
711+
ini->first_contact_peer = aclc->hdr.flag;
712712

713713
/* there is only one lgr role for SMC-D; use server lock */
714714
mutex_lock(&smc_server_lgr_pending);
@@ -724,7 +724,7 @@ static int smc_connect_ism(struct smc_sock *smc,
724724
return smc_connect_abort(smc, (rc == -ENOSPC) ?
725725
SMC_CLC_DECL_MAX_DMB :
726726
SMC_CLC_DECL_MEM,
727-
ini->cln_first_contact);
727+
ini->first_contact_local);
728728

729729
smc_conn_save_peer_info(smc, aclc);
730730
smc_close_init(smc);
@@ -733,7 +733,7 @@ static int smc_connect_ism(struct smc_sock *smc,
733733

734734
rc = smc_clc_send_confirm(smc);
735735
if (rc)
736-
return smc_connect_abort(smc, rc, ini->cln_first_contact);
736+
return smc_connect_abort(smc, rc, ini->first_contact_local);
737737
mutex_unlock(&smc_server_lgr_pending);
738738

739739
smc_copy_sock_settings_to_clc(smc);
@@ -1127,10 +1127,10 @@ static void smc_listen_out_err(struct smc_sock *new_smc)
11271127

11281128
/* listen worker: decline and fall back if possible */
11291129
static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
1130-
int local_contact)
1130+
bool local_first)
11311131
{
11321132
/* RDMA setup failed, switch back to TCP */
1133-
if (local_contact == SMC_FIRST_CONTACT)
1133+
if (local_first)
11341134
smc_lgr_cleanup_early(&new_smc->conn);
11351135
else
11361136
smc_conn_free(&new_smc->conn);
@@ -1190,7 +1190,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
11901190
int rc;
11911191

11921192
pclc_smcd = smc_get_clc_msg_smcd(pclc);
1193-
ini->ism_gid = pclc_smcd->gid;
1193+
ini->ism_peer_gid = pclc_smcd->gid;
11941194
rc = smc_conn_create(new_smc, ini);
11951195
if (rc)
11961196
return rc;
@@ -1199,7 +1199,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
11991199
if (smc_ism_cantalk(new_smc->conn.lgr->peer_gid,
12001200
new_smc->conn.lgr->vlan_id,
12011201
new_smc->conn.lgr->smcd)) {
1202-
if (ini->cln_first_contact == SMC_FIRST_CONTACT)
1202+
if (ini->first_contact_local)
12031203
smc_lgr_cleanup_early(&new_smc->conn);
12041204
else
12051205
smc_conn_free(&new_smc->conn);
@@ -1209,7 +1209,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
12091209
/* Create send and receive buffers */
12101210
rc = smc_buf_create(new_smc, true);
12111211
if (rc) {
1212-
if (ini->cln_first_contact == SMC_FIRST_CONTACT)
1212+
if (ini->first_contact_local)
12131213
smc_lgr_cleanup_early(&new_smc->conn);
12141214
else
12151215
smc_conn_free(&new_smc->conn);
@@ -1221,11 +1221,11 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
12211221
}
12221222

12231223
/* listen worker: register buffers */
1224-
static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact)
1224+
static int smc_listen_rdma_reg(struct smc_sock *new_smc, bool local_first)
12251225
{
12261226
struct smc_connection *conn = &new_smc->conn;
12271227

1228-
if (local_contact != SMC_FIRST_CONTACT) {
1228+
if (!local_first) {
12291229
if (smcr_lgr_reg_rmbs(conn->lnk, conn->rmb_desc))
12301230
return SMC_CLC_DECL_ERR_REGRMB;
12311231
}
@@ -1237,20 +1237,20 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact)
12371237
/* listen worker: finish RDMA setup */
12381238
static int smc_listen_rdma_finish(struct smc_sock *new_smc,
12391239
struct smc_clc_msg_accept_confirm *cclc,
1240-
int local_contact)
1240+
bool local_first)
12411241
{
12421242
struct smc_link *link = new_smc->conn.lnk;
12431243
int reason_code = 0;
12441244

1245-
if (local_contact == SMC_FIRST_CONTACT)
1245+
if (local_first)
12461246
smc_link_save_peer_info(link, cclc);
12471247

12481248
if (smc_rmb_rtoken_handling(&new_smc->conn, link, cclc)) {
12491249
reason_code = SMC_CLC_DECL_ERR_RTOK;
12501250
goto decline;
12511251
}
12521252

1253-
if (local_contact == SMC_FIRST_CONTACT) {
1253+
if (local_first) {
12541254
if (smc_ib_ready_link(link)) {
12551255
reason_code = SMC_CLC_DECL_ERR_RDYLNK;
12561256
goto decline;
@@ -1265,7 +1265,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,
12651265
return 0;
12661266

12671267
decline:
1268-
smc_listen_decline(new_smc, reason_code, local_contact);
1268+
smc_listen_decline(new_smc, reason_code, local_first);
12691269
return reason_code;
12701270
}
12711271

@@ -1358,13 +1358,13 @@ static void smc_listen_work(struct work_struct *work)
13581358
rc = smc_listen_rdma_init(new_smc, &ini);
13591359
if (rc)
13601360
goto out_unlock;
1361-
rc = smc_listen_rdma_reg(new_smc, ini.cln_first_contact);
1361+
rc = smc_listen_rdma_reg(new_smc, ini.first_contact_local);
13621362
if (rc)
13631363
goto out_unlock;
13641364
}
13651365

13661366
/* send SMC Accept CLC message */
1367-
rc = smc_clc_send_accept(new_smc, ini.cln_first_contact);
1367+
rc = smc_clc_send_accept(new_smc, ini.first_contact_local);
13681368
if (rc)
13691369
goto out_unlock;
13701370

@@ -1384,7 +1384,7 @@ static void smc_listen_work(struct work_struct *work)
13841384
/* finish worker */
13851385
if (!ism_supported) {
13861386
rc = smc_listen_rdma_finish(new_smc, &cclc,
1387-
ini.cln_first_contact);
1387+
ini.first_contact_local);
13881388
mutex_unlock(&smc_server_lgr_pending);
13891389
if (rc)
13901390
return;
@@ -1396,7 +1396,7 @@ static void smc_listen_work(struct work_struct *work)
13961396
out_unlock:
13971397
mutex_unlock(&smc_server_lgr_pending);
13981398
out_decl:
1399-
smc_listen_decline(new_smc, rc, ini.cln_first_contact);
1399+
smc_listen_decline(new_smc, rc, ini.first_contact_local);
14001400
}
14011401

14021402
static void smc_tcp_listen_work(struct work_struct *work)

net/smc/smc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "smc_ib.h"
2020

21+
#define SMC_V1 1 /* SMC version V1 */
22+
2123
#define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */
2224
#define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */
2325

net/smc/smc_clc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
320320
}
321321
datlen = ntohs(clcm->length);
322322
if ((len < sizeof(struct smc_clc_msg_hdr)) ||
323-
(clcm->version < SMC_CLC_V1) ||
323+
(clcm->version < SMC_V1) ||
324324
((clcm->type != SMC_CLC_DECLINE) &&
325325
(clcm->type != expected_type))) {
326326
smc->sk.sk_err = EPROTO;
@@ -389,7 +389,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
389389
memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
390390
dclc.hdr.type = SMC_CLC_DECLINE;
391391
dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline));
392-
dclc.hdr.version = SMC_CLC_V1;
392+
dclc.hdr.version = SMC_V1;
393393
dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0;
394394
if ((!smc->conn.lgr || !smc->conn.lgr->is_smcd) &&
395395
smc_ib_is_valid_local_systemid())
@@ -434,7 +434,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
434434
memset(&pclc, 0, sizeof(pclc));
435435
memcpy(pclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
436436
pclc.hdr.type = SMC_CLC_PROPOSAL;
437-
pclc.hdr.version = SMC_CLC_V1; /* SMC version */
437+
pclc.hdr.version = SMC_V1; /* SMC version */
438438
pclc.hdr.path = smc_type;
439439
if (smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B) {
440440
/* add SMC-R specifics */
@@ -499,8 +499,8 @@ int smc_clc_send_confirm(struct smc_sock *smc)
499499
/* send SMC Confirm CLC msg */
500500
memset(&cclc, 0, sizeof(cclc));
501501
cclc.hdr.type = SMC_CLC_CONFIRM;
502-
cclc.hdr.version = SMC_CLC_V1; /* SMC version */
503-
if (smc->conn.lgr->is_smcd) {
502+
cclc.hdr.version = SMC_V1; /* SMC version */
503+
if (conn->lgr->is_smcd) {
504504
/* SMC-D specific settings */
505505
memcpy(cclc.hdr.eyecatcher, SMCD_EYECATCHER,
506506
sizeof(SMCD_EYECATCHER));
@@ -557,7 +557,7 @@ int smc_clc_send_confirm(struct smc_sock *smc)
557557
}
558558

559559
/* send CLC ACCEPT message across internal TCP socket */
560-
int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact)
560+
int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact)
561561
{
562562
struct smc_connection *conn = &new_smc->conn;
563563
struct smc_clc_msg_accept_confirm aclc;
@@ -568,11 +568,11 @@ int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact)
568568

569569
memset(&aclc, 0, sizeof(aclc));
570570
aclc.hdr.type = SMC_CLC_ACCEPT;
571-
aclc.hdr.version = SMC_CLC_V1; /* SMC version */
571+
aclc.hdr.version = SMC_V1; /* SMC version */
572572
if (srv_first_contact)
573573
aclc.hdr.flag = 1;
574574

575-
if (new_smc->conn.lgr->is_smcd) {
575+
if (conn->lgr->is_smcd) {
576576
/* SMC-D specific settings */
577577
aclc.hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
578578
memcpy(aclc.hdr.eyecatcher, SMCD_EYECATCHER,

net/smc/smc_clc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define SMC_CLC_CONFIRM 0x03
2323
#define SMC_CLC_DECLINE 0x04
2424

25-
#define SMC_CLC_V1 0x1 /* SMC version */
2625
#define SMC_TYPE_R 0 /* SMC-R only */
2726
#define SMC_TYPE_D 1 /* SMC-D only */
2827
#define SMC_TYPE_N 2 /* neither SMC-R nor SMC-D */
@@ -200,6 +199,6 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info);
200199
int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
201200
struct smc_init_info *ini);
202201
int smc_clc_send_confirm(struct smc_sock *smc);
203-
int smc_clc_send_accept(struct smc_sock *smc, int srv_first_contact);
202+
int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact);
204203

205204
#endif

net/smc/smc_core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
418418
if (ini->is_smcd) {
419419
/* SMC-D specific settings */
420420
get_device(&ini->ism_dev->dev);
421-
lgr->peer_gid = ini->ism_gid;
421+
lgr->peer_gid = ini->ism_peer_gid;
422422
lgr->smcd = ini->ism_dev;
423423
lgr_list = &ini->ism_dev->lgr_list;
424424
lgr_lock = &lgr->smcd->lgr_lock;
@@ -1296,9 +1296,9 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
12961296

12971297
lgr_list = ini->is_smcd ? &ini->ism_dev->lgr_list : &smc_lgr_list.list;
12981298
lgr_lock = ini->is_smcd ? &ini->ism_dev->lgr_lock : &smc_lgr_list.lock;
1299-
ini->cln_first_contact = SMC_FIRST_CONTACT;
1299+
ini->first_contact_local = 1;
13001300
role = smc->listen_smc ? SMC_SERV : SMC_CLNT;
1301-
if (role == SMC_CLNT && ini->srv_first_contact)
1301+
if (role == SMC_CLNT && ini->first_contact_peer)
13021302
/* create new link group as well */
13031303
goto create;
13041304

@@ -1307,14 +1307,14 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
13071307
list_for_each_entry(lgr, lgr_list, list) {
13081308
write_lock_bh(&lgr->conns_lock);
13091309
if ((ini->is_smcd ?
1310-
smcd_lgr_match(lgr, ini->ism_dev, ini->ism_gid) :
1310+
smcd_lgr_match(lgr, ini->ism_dev, ini->ism_peer_gid) :
13111311
smcr_lgr_match(lgr, ini->ib_lcl, role, ini->ib_clcqpn)) &&
13121312
!lgr->sync_err &&
13131313
lgr->vlan_id == ini->vlan_id &&
13141314
(role == SMC_CLNT || ini->is_smcd ||
13151315
lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) {
13161316
/* link group found */
1317-
ini->cln_first_contact = SMC_REUSE_CONTACT;
1317+
ini->first_contact_local = 0;
13181318
conn->lgr = lgr;
13191319
rc = smc_lgr_register_conn(conn, false);
13201320
write_unlock_bh(&lgr->conns_lock);
@@ -1328,8 +1328,8 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
13281328
if (rc)
13291329
return rc;
13301330

1331-
if (role == SMC_CLNT && !ini->srv_first_contact &&
1332-
ini->cln_first_contact == SMC_FIRST_CONTACT) {
1331+
if (role == SMC_CLNT && !ini->first_contact_peer &&
1332+
ini->first_contact_local) {
13331333
/* Server reuses a link group, but Client wants to start
13341334
* a new one
13351335
* send out_of_sync decline, reason synchr. error
@@ -1338,7 +1338,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
13381338
}
13391339

13401340
create:
1341-
if (ini->cln_first_contact == SMC_FIRST_CONTACT) {
1341+
if (ini->first_contact_local) {
13421342
rc = smc_lgr_create(smc, ini);
13431343
if (rc)
13441344
goto out;

0 commit comments

Comments
 (0)