Commit 5ac54d87 authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

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: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a60a2b1e
...@@ -523,11 +523,11 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code) ...@@ -523,11 +523,11 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code)
/* abort connecting */ /* abort connecting */
static int smc_connect_abort(struct smc_sock *smc, int reason_code, static int smc_connect_abort(struct smc_sock *smc, int reason_code,
int local_contact) int local_first)
{ {
bool is_smcd = smc->conn.lgr->is_smcd; bool is_smcd = smc->conn.lgr->is_smcd;
if (local_contact == SMC_FIRST_CONTACT) if (local_first)
smc_lgr_cleanup_early(&smc->conn); smc_lgr_cleanup_early(&smc->conn);
else else
smc_conn_free(&smc->conn); smc_conn_free(&smc->conn);
...@@ -615,7 +615,7 @@ static int smc_connect_rdma(struct smc_sock *smc, ...@@ -615,7 +615,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
ini->is_smcd = false; ini->is_smcd = false;
ini->ib_lcl = &aclc->lcl; ini->ib_lcl = &aclc->lcl;
ini->ib_clcqpn = ntoh24(aclc->qpn); ini->ib_clcqpn = ntoh24(aclc->qpn);
ini->srv_first_contact = aclc->hdr.flag; ini->first_contact_peer = aclc->hdr.flag;
mutex_lock(&smc_client_lgr_pending); mutex_lock(&smc_client_lgr_pending);
reason_code = smc_conn_create(smc, ini); reason_code = smc_conn_create(smc, ini);
...@@ -626,7 +626,7 @@ static int smc_connect_rdma(struct smc_sock *smc, ...@@ -626,7 +626,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
smc_conn_save_peer_info(smc, aclc); smc_conn_save_peer_info(smc, aclc);
if (ini->cln_first_contact == SMC_FIRST_CONTACT) { if (ini->first_contact_local) {
link = smc->conn.lnk; link = smc->conn.lnk;
} else { } else {
/* set link that was assigned by server */ /* set link that was assigned by server */
...@@ -643,51 +643,51 @@ static int smc_connect_rdma(struct smc_sock *smc, ...@@ -643,51 +643,51 @@ static int smc_connect_rdma(struct smc_sock *smc,
} }
if (!link) if (!link)
return smc_connect_abort(smc, SMC_CLC_DECL_NOSRVLINK, return smc_connect_abort(smc, SMC_CLC_DECL_NOSRVLINK,
ini->cln_first_contact); ini->first_contact_local);
smc->conn.lnk = link; smc->conn.lnk = link;
} }
/* create send buffer and rmb */ /* create send buffer and rmb */
if (smc_buf_create(smc, false)) if (smc_buf_create(smc, false))
return smc_connect_abort(smc, SMC_CLC_DECL_MEM, return smc_connect_abort(smc, SMC_CLC_DECL_MEM,
ini->cln_first_contact); ini->first_contact_local);
if (ini->cln_first_contact == SMC_FIRST_CONTACT) if (ini->first_contact_local)
smc_link_save_peer_info(link, aclc); smc_link_save_peer_info(link, aclc);
if (smc_rmb_rtoken_handling(&smc->conn, link, aclc)) if (smc_rmb_rtoken_handling(&smc->conn, link, aclc))
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RTOK, return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RTOK,
ini->cln_first_contact); ini->first_contact_local);
smc_close_init(smc); smc_close_init(smc);
smc_rx_init(smc); smc_rx_init(smc);
if (ini->cln_first_contact == SMC_FIRST_CONTACT) { if (ini->first_contact_local) {
if (smc_ib_ready_link(link)) if (smc_ib_ready_link(link))
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RDYLNK, return smc_connect_abort(smc, SMC_CLC_DECL_ERR_RDYLNK,
ini->cln_first_contact); ini->first_contact_local);
} else { } else {
if (smcr_lgr_reg_rmbs(link, smc->conn.rmb_desc)) if (smcr_lgr_reg_rmbs(link, smc->conn.rmb_desc))
return smc_connect_abort(smc, SMC_CLC_DECL_ERR_REGRMB, return smc_connect_abort(smc, SMC_CLC_DECL_ERR_REGRMB,
ini->cln_first_contact); ini->first_contact_local);
} }
smc_rmb_sync_sg_for_device(&smc->conn); smc_rmb_sync_sg_for_device(&smc->conn);
reason_code = smc_clc_send_confirm(smc); reason_code = smc_clc_send_confirm(smc);
if (reason_code) if (reason_code)
return smc_connect_abort(smc, reason_code, return smc_connect_abort(smc, reason_code,
ini->cln_first_contact); ini->first_contact_local);
smc_tx_init(smc); smc_tx_init(smc);
if (ini->cln_first_contact == SMC_FIRST_CONTACT) { if (ini->first_contact_local) {
/* QP confirmation over RoCE fabric */ /* QP confirmation over RoCE fabric */
smc_llc_flow_initiate(link->lgr, SMC_LLC_FLOW_ADD_LINK); smc_llc_flow_initiate(link->lgr, SMC_LLC_FLOW_ADD_LINK);
reason_code = smcr_clnt_conf_first_link(smc); reason_code = smcr_clnt_conf_first_link(smc);
smc_llc_flow_stop(link->lgr, &link->lgr->llc_flow_lcl); smc_llc_flow_stop(link->lgr, &link->lgr->llc_flow_lcl);
if (reason_code) if (reason_code)
return smc_connect_abort(smc, reason_code, return smc_connect_abort(smc, reason_code,
ini->cln_first_contact); ini->first_contact_local);
} }
mutex_unlock(&smc_client_lgr_pending); mutex_unlock(&smc_client_lgr_pending);
...@@ -707,8 +707,8 @@ static int smc_connect_ism(struct smc_sock *smc, ...@@ -707,8 +707,8 @@ static int smc_connect_ism(struct smc_sock *smc,
int rc = 0; int rc = 0;
ini->is_smcd = true; ini->is_smcd = true;
ini->ism_gid = aclc->gid; ini->ism_peer_gid = aclc->gid;
ini->srv_first_contact = aclc->hdr.flag; ini->first_contact_peer = aclc->hdr.flag;
/* there is only one lgr role for SMC-D; use server lock */ /* there is only one lgr role for SMC-D; use server lock */
mutex_lock(&smc_server_lgr_pending); mutex_lock(&smc_server_lgr_pending);
...@@ -724,7 +724,7 @@ static int smc_connect_ism(struct smc_sock *smc, ...@@ -724,7 +724,7 @@ static int smc_connect_ism(struct smc_sock *smc,
return smc_connect_abort(smc, (rc == -ENOSPC) ? return smc_connect_abort(smc, (rc == -ENOSPC) ?
SMC_CLC_DECL_MAX_DMB : SMC_CLC_DECL_MAX_DMB :
SMC_CLC_DECL_MEM, SMC_CLC_DECL_MEM,
ini->cln_first_contact); ini->first_contact_local);
smc_conn_save_peer_info(smc, aclc); smc_conn_save_peer_info(smc, aclc);
smc_close_init(smc); smc_close_init(smc);
...@@ -733,7 +733,7 @@ static int smc_connect_ism(struct smc_sock *smc, ...@@ -733,7 +733,7 @@ static int smc_connect_ism(struct smc_sock *smc,
rc = smc_clc_send_confirm(smc); rc = smc_clc_send_confirm(smc);
if (rc) if (rc)
return smc_connect_abort(smc, rc, ini->cln_first_contact); return smc_connect_abort(smc, rc, ini->first_contact_local);
mutex_unlock(&smc_server_lgr_pending); mutex_unlock(&smc_server_lgr_pending);
smc_copy_sock_settings_to_clc(smc); smc_copy_sock_settings_to_clc(smc);
...@@ -1127,10 +1127,10 @@ static void smc_listen_out_err(struct smc_sock *new_smc) ...@@ -1127,10 +1127,10 @@ static void smc_listen_out_err(struct smc_sock *new_smc)
/* listen worker: decline and fall back if possible */ /* listen worker: decline and fall back if possible */
static void smc_listen_decline(struct smc_sock *new_smc, int reason_code, static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
int local_contact) bool local_first)
{ {
/* RDMA setup failed, switch back to TCP */ /* RDMA setup failed, switch back to TCP */
if (local_contact == SMC_FIRST_CONTACT) if (local_first)
smc_lgr_cleanup_early(&new_smc->conn); smc_lgr_cleanup_early(&new_smc->conn);
else else
smc_conn_free(&new_smc->conn); smc_conn_free(&new_smc->conn);
...@@ -1190,7 +1190,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc, ...@@ -1190,7 +1190,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
int rc; int rc;
pclc_smcd = smc_get_clc_msg_smcd(pclc); pclc_smcd = smc_get_clc_msg_smcd(pclc);
ini->ism_gid = pclc_smcd->gid; ini->ism_peer_gid = pclc_smcd->gid;
rc = smc_conn_create(new_smc, ini); rc = smc_conn_create(new_smc, ini);
if (rc) if (rc)
return rc; return rc;
...@@ -1199,7 +1199,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc, ...@@ -1199,7 +1199,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
if (smc_ism_cantalk(new_smc->conn.lgr->peer_gid, if (smc_ism_cantalk(new_smc->conn.lgr->peer_gid,
new_smc->conn.lgr->vlan_id, new_smc->conn.lgr->vlan_id,
new_smc->conn.lgr->smcd)) { new_smc->conn.lgr->smcd)) {
if (ini->cln_first_contact == SMC_FIRST_CONTACT) if (ini->first_contact_local)
smc_lgr_cleanup_early(&new_smc->conn); smc_lgr_cleanup_early(&new_smc->conn);
else else
smc_conn_free(&new_smc->conn); smc_conn_free(&new_smc->conn);
...@@ -1209,7 +1209,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc, ...@@ -1209,7 +1209,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
/* Create send and receive buffers */ /* Create send and receive buffers */
rc = smc_buf_create(new_smc, true); rc = smc_buf_create(new_smc, true);
if (rc) { if (rc) {
if (ini->cln_first_contact == SMC_FIRST_CONTACT) if (ini->first_contact_local)
smc_lgr_cleanup_early(&new_smc->conn); smc_lgr_cleanup_early(&new_smc->conn);
else else
smc_conn_free(&new_smc->conn); smc_conn_free(&new_smc->conn);
...@@ -1221,11 +1221,11 @@ static int smc_listen_ism_init(struct smc_sock *new_smc, ...@@ -1221,11 +1221,11 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
} }
/* listen worker: register buffers */ /* listen worker: register buffers */
static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact) static int smc_listen_rdma_reg(struct smc_sock *new_smc, bool local_first)
{ {
struct smc_connection *conn = &new_smc->conn; struct smc_connection *conn = &new_smc->conn;
if (local_contact != SMC_FIRST_CONTACT) { if (!local_first) {
if (smcr_lgr_reg_rmbs(conn->lnk, conn->rmb_desc)) if (smcr_lgr_reg_rmbs(conn->lnk, conn->rmb_desc))
return SMC_CLC_DECL_ERR_REGRMB; return SMC_CLC_DECL_ERR_REGRMB;
} }
...@@ -1237,12 +1237,12 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact) ...@@ -1237,12 +1237,12 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact)
/* listen worker: finish RDMA setup */ /* listen worker: finish RDMA setup */
static int smc_listen_rdma_finish(struct smc_sock *new_smc, static int smc_listen_rdma_finish(struct smc_sock *new_smc,
struct smc_clc_msg_accept_confirm *cclc, struct smc_clc_msg_accept_confirm *cclc,
int local_contact) bool local_first)
{ {
struct smc_link *link = new_smc->conn.lnk; struct smc_link *link = new_smc->conn.lnk;
int reason_code = 0; int reason_code = 0;
if (local_contact == SMC_FIRST_CONTACT) if (local_first)
smc_link_save_peer_info(link, cclc); smc_link_save_peer_info(link, cclc);
if (smc_rmb_rtoken_handling(&new_smc->conn, link, cclc)) { if (smc_rmb_rtoken_handling(&new_smc->conn, link, cclc)) {
...@@ -1250,7 +1250,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc, ...@@ -1250,7 +1250,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,
goto decline; goto decline;
} }
if (local_contact == SMC_FIRST_CONTACT) { if (local_first) {
if (smc_ib_ready_link(link)) { if (smc_ib_ready_link(link)) {
reason_code = SMC_CLC_DECL_ERR_RDYLNK; reason_code = SMC_CLC_DECL_ERR_RDYLNK;
goto decline; goto decline;
...@@ -1265,7 +1265,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc, ...@@ -1265,7 +1265,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,
return 0; return 0;
decline: decline:
smc_listen_decline(new_smc, reason_code, local_contact); smc_listen_decline(new_smc, reason_code, local_first);
return reason_code; return reason_code;
} }
...@@ -1358,13 +1358,13 @@ static void smc_listen_work(struct work_struct *work) ...@@ -1358,13 +1358,13 @@ static void smc_listen_work(struct work_struct *work)
rc = smc_listen_rdma_init(new_smc, &ini); rc = smc_listen_rdma_init(new_smc, &ini);
if (rc) if (rc)
goto out_unlock; goto out_unlock;
rc = smc_listen_rdma_reg(new_smc, ini.cln_first_contact); rc = smc_listen_rdma_reg(new_smc, ini.first_contact_local);
if (rc) if (rc)
goto out_unlock; goto out_unlock;
} }
/* send SMC Accept CLC message */ /* send SMC Accept CLC message */
rc = smc_clc_send_accept(new_smc, ini.cln_first_contact); rc = smc_clc_send_accept(new_smc, ini.first_contact_local);
if (rc) if (rc)
goto out_unlock; goto out_unlock;
...@@ -1384,7 +1384,7 @@ static void smc_listen_work(struct work_struct *work) ...@@ -1384,7 +1384,7 @@ static void smc_listen_work(struct work_struct *work)
/* finish worker */ /* finish worker */
if (!ism_supported) { if (!ism_supported) {
rc = smc_listen_rdma_finish(new_smc, &cclc, rc = smc_listen_rdma_finish(new_smc, &cclc,
ini.cln_first_contact); ini.first_contact_local);
mutex_unlock(&smc_server_lgr_pending); mutex_unlock(&smc_server_lgr_pending);
if (rc) if (rc)
return; return;
...@@ -1396,7 +1396,7 @@ static void smc_listen_work(struct work_struct *work) ...@@ -1396,7 +1396,7 @@ static void smc_listen_work(struct work_struct *work)
out_unlock: out_unlock:
mutex_unlock(&smc_server_lgr_pending); mutex_unlock(&smc_server_lgr_pending);
out_decl: out_decl:
smc_listen_decline(new_smc, rc, ini.cln_first_contact); smc_listen_decline(new_smc, rc, ini.first_contact_local);
} }
static void smc_tcp_listen_work(struct work_struct *work) static void smc_tcp_listen_work(struct work_struct *work)
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "smc_ib.h" #include "smc_ib.h"
#define SMC_V1 1 /* SMC version V1 */
#define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */ #define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */
#define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */ #define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */
......
...@@ -320,7 +320,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, ...@@ -320,7 +320,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
} }
datlen = ntohs(clcm->length); datlen = ntohs(clcm->length);
if ((len < sizeof(struct smc_clc_msg_hdr)) || if ((len < sizeof(struct smc_clc_msg_hdr)) ||
(clcm->version < SMC_CLC_V1) || (clcm->version < SMC_V1) ||
((clcm->type != SMC_CLC_DECLINE) && ((clcm->type != SMC_CLC_DECLINE) &&
(clcm->type != expected_type))) { (clcm->type != expected_type))) {
smc->sk.sk_err = EPROTO; smc->sk.sk_err = EPROTO;
...@@ -389,7 +389,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info) ...@@ -389,7 +389,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)); memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
dclc.hdr.type = SMC_CLC_DECLINE; dclc.hdr.type = SMC_CLC_DECLINE;
dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline)); dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline));
dclc.hdr.version = SMC_CLC_V1; dclc.hdr.version = SMC_V1;
dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0; dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0;
if ((!smc->conn.lgr || !smc->conn.lgr->is_smcd) && if ((!smc->conn.lgr || !smc->conn.lgr->is_smcd) &&
smc_ib_is_valid_local_systemid()) smc_ib_is_valid_local_systemid())
...@@ -434,7 +434,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, ...@@ -434,7 +434,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
memset(&pclc, 0, sizeof(pclc)); memset(&pclc, 0, sizeof(pclc));
memcpy(pclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)); memcpy(pclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
pclc.hdr.type = SMC_CLC_PROPOSAL; pclc.hdr.type = SMC_CLC_PROPOSAL;
pclc.hdr.version = SMC_CLC_V1; /* SMC version */ pclc.hdr.version = SMC_V1; /* SMC version */
pclc.hdr.path = smc_type; pclc.hdr.path = smc_type;
if (smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B) { if (smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B) {
/* add SMC-R specifics */ /* add SMC-R specifics */
...@@ -499,8 +499,8 @@ int smc_clc_send_confirm(struct smc_sock *smc) ...@@ -499,8 +499,8 @@ int smc_clc_send_confirm(struct smc_sock *smc)
/* send SMC Confirm CLC msg */ /* send SMC Confirm CLC msg */
memset(&cclc, 0, sizeof(cclc)); memset(&cclc, 0, sizeof(cclc));
cclc.hdr.type = SMC_CLC_CONFIRM; cclc.hdr.type = SMC_CLC_CONFIRM;
cclc.hdr.version = SMC_CLC_V1; /* SMC version */ cclc.hdr.version = SMC_V1; /* SMC version */
if (smc->conn.lgr->is_smcd) { if (conn->lgr->is_smcd) {
/* SMC-D specific settings */ /* SMC-D specific settings */
memcpy(cclc.hdr.eyecatcher, SMCD_EYECATCHER, memcpy(cclc.hdr.eyecatcher, SMCD_EYECATCHER,
sizeof(SMCD_EYECATCHER)); sizeof(SMCD_EYECATCHER));
...@@ -557,7 +557,7 @@ int smc_clc_send_confirm(struct smc_sock *smc) ...@@ -557,7 +557,7 @@ int smc_clc_send_confirm(struct smc_sock *smc)
} }
/* send CLC ACCEPT message across internal TCP socket */ /* send CLC ACCEPT message across internal TCP socket */
int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact) int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact)
{ {
struct smc_connection *conn = &new_smc->conn; struct smc_connection *conn = &new_smc->conn;
struct smc_clc_msg_accept_confirm aclc; 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) ...@@ -568,11 +568,11 @@ int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact)
memset(&aclc, 0, sizeof(aclc)); memset(&aclc, 0, sizeof(aclc));
aclc.hdr.type = SMC_CLC_ACCEPT; aclc.hdr.type = SMC_CLC_ACCEPT;
aclc.hdr.version = SMC_CLC_V1; /* SMC version */ aclc.hdr.version = SMC_V1; /* SMC version */
if (srv_first_contact) if (srv_first_contact)
aclc.hdr.flag = 1; aclc.hdr.flag = 1;
if (new_smc->conn.lgr->is_smcd) { if (conn->lgr->is_smcd) {
/* SMC-D specific settings */ /* SMC-D specific settings */
aclc.hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN); aclc.hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
memcpy(aclc.hdr.eyecatcher, SMCD_EYECATCHER, memcpy(aclc.hdr.eyecatcher, SMCD_EYECATCHER,
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#define SMC_CLC_CONFIRM 0x03 #define SMC_CLC_CONFIRM 0x03
#define SMC_CLC_DECLINE 0x04 #define SMC_CLC_DECLINE 0x04
#define SMC_CLC_V1 0x1 /* SMC version */
#define SMC_TYPE_R 0 /* SMC-R only */ #define SMC_TYPE_R 0 /* SMC-R only */
#define SMC_TYPE_D 1 /* SMC-D only */ #define SMC_TYPE_D 1 /* SMC-D only */
#define SMC_TYPE_N 2 /* neither SMC-R nor SMC-D */ #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); ...@@ -200,6 +199,6 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info);
int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
struct smc_init_info *ini); struct smc_init_info *ini);
int smc_clc_send_confirm(struct smc_sock *smc); int smc_clc_send_confirm(struct smc_sock *smc);
int smc_clc_send_accept(struct smc_sock *smc, int srv_first_contact); int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact);
#endif #endif
...@@ -418,7 +418,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini) ...@@ -418,7 +418,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
if (ini->is_smcd) { if (ini->is_smcd) {
/* SMC-D specific settings */ /* SMC-D specific settings */
get_device(&ini->ism_dev->dev); get_device(&ini->ism_dev->dev);
lgr->peer_gid = ini->ism_gid; lgr->peer_gid = ini->ism_peer_gid;
lgr->smcd = ini->ism_dev; lgr->smcd = ini->ism_dev;
lgr_list = &ini->ism_dev->lgr_list; lgr_list = &ini->ism_dev->lgr_list;
lgr_lock = &lgr->smcd->lgr_lock; lgr_lock = &lgr->smcd->lgr_lock;
...@@ -1296,9 +1296,9 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) ...@@ -1296,9 +1296,9 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
lgr_list = ini->is_smcd ? &ini->ism_dev->lgr_list : &smc_lgr_list.list; lgr_list = ini->is_smcd ? &ini->ism_dev->lgr_list : &smc_lgr_list.list;
lgr_lock = ini->is_smcd ? &ini->ism_dev->lgr_lock : &smc_lgr_list.lock; lgr_lock = ini->is_smcd ? &ini->ism_dev->lgr_lock : &smc_lgr_list.lock;
ini->cln_first_contact = SMC_FIRST_CONTACT; ini->first_contact_local = 1;
role = smc->listen_smc ? SMC_SERV : SMC_CLNT; role = smc->listen_smc ? SMC_SERV : SMC_CLNT;
if (role == SMC_CLNT && ini->srv_first_contact) if (role == SMC_CLNT && ini->first_contact_peer)
/* create new link group as well */ /* create new link group as well */
goto create; goto create;
...@@ -1307,14 +1307,14 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) ...@@ -1307,14 +1307,14 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
list_for_each_entry(lgr, lgr_list, list) { list_for_each_entry(lgr, lgr_list, list) {
write_lock_bh(&lgr->conns_lock); write_lock_bh(&lgr->conns_lock);
if ((ini->is_smcd ? if ((ini->is_smcd ?
smcd_lgr_match(lgr, ini->ism_dev, ini->ism_gid) : smcd_lgr_match(lgr, ini->ism_dev, ini->ism_peer_gid) :
smcr_lgr_match(lgr, ini->ib_lcl, role, ini->ib_clcqpn)) && smcr_lgr_match(lgr, ini->ib_lcl, role, ini->ib_clcqpn)) &&
!lgr->sync_err && !lgr->sync_err &&
lgr->vlan_id == ini->vlan_id && lgr->vlan_id == ini->vlan_id &&
(role == SMC_CLNT || ini->is_smcd || (role == SMC_CLNT || ini->is_smcd ||
lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) { lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) {
/* link group found */ /* link group found */
ini->cln_first_contact = SMC_REUSE_CONTACT; ini->first_contact_local = 0;
conn->lgr = lgr; conn->lgr = lgr;
rc = smc_lgr_register_conn(conn, false); rc = smc_lgr_register_conn(conn, false);
write_unlock_bh(&lgr->conns_lock); write_unlock_bh(&lgr->conns_lock);
...@@ -1328,8 +1328,8 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) ...@@ -1328,8 +1328,8 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
if (rc) if (rc)
return rc; return rc;
if (role == SMC_CLNT && !ini->srv_first_contact && if (role == SMC_CLNT && !ini->first_contact_peer &&
ini->cln_first_contact == SMC_FIRST_CONTACT) { ini->first_contact_local) {
/* Server reuses a link group, but Client wants to start /* Server reuses a link group, but Client wants to start
* a new one * a new one
* send out_of_sync decline, reason synchr. error * 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) ...@@ -1338,7 +1338,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
} }
create: create:
if (ini->cln_first_contact == SMC_FIRST_CONTACT) { if (ini->first_contact_local) {
rc = smc_lgr_create(smc, ini); rc = smc_lgr_create(smc, ini);
if (rc) if (rc)
goto out; goto out;
......
...@@ -137,9 +137,6 @@ struct smc_link { ...@@ -137,9 +137,6 @@ struct smc_link {
#define SMC_LINKS_PER_LGR_MAX 3 #define SMC_LINKS_PER_LGR_MAX 3
#define SMC_SINGLE_LINK 0 #define SMC_SINGLE_LINK 0
#define SMC_FIRST_CONTACT 1 /* first contact to a peer */
#define SMC_REUSE_CONTACT 0 /* follow-on contact to a peer*/
/* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */ /* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */
struct smc_buf_desc { struct smc_buf_desc {
struct list_head list; struct list_head list;
...@@ -294,9 +291,9 @@ struct smc_clc_msg_local; ...@@ -294,9 +291,9 @@ struct smc_clc_msg_local;
struct smc_init_info { struct smc_init_info {
u8 is_smcd; u8 is_smcd;
u8 first_contact_peer;
u8 first_contact_local;
unsigned short vlan_id; unsigned short vlan_id;
int srv_first_contact;
int cln_first_contact;
/* SMC-R */ /* SMC-R */
struct smc_clc_msg_local *ib_lcl; struct smc_clc_msg_local *ib_lcl;
struct smc_ib_device *ib_dev; struct smc_ib_device *ib_dev;
...@@ -304,7 +301,7 @@ struct smc_init_info { ...@@ -304,7 +301,7 @@ struct smc_init_info {
u8 ib_port; u8 ib_port;
u32 ib_clcqpn; u32 ib_clcqpn;
/* SMC-D */ /* SMC-D */
u64 ism_gid; u64 ism_peer_gid;
struct smcd_dev *ism_dev; struct smcd_dev *ism_dev;
}; };
......
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