Skip to content

Commit 45fa8da

Browse files
karstengrdavem330
authored andcommitted
net/smc: create improved SMC-R link_uid
The link_uid of an SMC-R link is exchanged between SMC peers and its value can be used for debugging purposes. Create a unique link_uid during link initialization and use it in communication with SMC-R peers. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a52bcc9 commit 45fa8da

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

net/smc/smc_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
331331
lnk->smcibdev = ini->ib_dev;
332332
lnk->ibport = ini->ib_port;
333333
lnk->path_mtu = ini->ib_dev->pattr[ini->ib_port - 1].active_mtu;
334+
smc_llc_link_set_uid(lnk);
334335
INIT_WORK(&lnk->link_down_wrk, smc_link_down_work);
335336
if (!ini->ib_dev->initialized) {
336337
rc = (int)smc_ib_setup_per_ibdev(ini->ib_dev);

net/smc/smc_core.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ struct smc_rdma_wr { /* work requests per message
7070
struct ib_rdma_wr wr_tx_rdma[SMC_MAX_RDMA_WRITES];
7171
};
7272

73+
#define SMC_LGR_ID_SIZE 4
74+
7375
struct smc_link {
7476
struct smc_ib_device *smcibdev; /* ib-device */
7577
u8 ibport; /* port - values 1 | 2 */
@@ -116,6 +118,7 @@ struct smc_link {
116118
u8 peer_mac[ETH_ALEN]; /* = gid[8:10||13:15] */
117119
u8 peer_gid[SMC_GID_SIZE]; /* gid of peer*/
118120
u8 link_id; /* unique # within link group */
121+
u8 link_uid[SMC_LGR_ID_SIZE]; /* unique lnk id */
119122
u8 link_idx; /* index in lgr link array */
120123
u8 link_is_asym; /* is link asymmetric? */
121124
struct smc_link_group *lgr; /* parent link group */
@@ -178,7 +181,6 @@ struct smc_rtoken { /* address/key of remote RMB */
178181
u32 rkey;
179182
};
180183

181-
#define SMC_LGR_ID_SIZE 4
182184
#define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */
183185
#define SMC_RMBE_SIZES 16 /* number of distinct RMBE sizes */
184186
/* theoretically, the RFC states that largest size would be 512K,

net/smc/smc_llc.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ static int smc_llc_add_pending_send(struct smc_link *link,
361361
int smc_llc_send_confirm_link(struct smc_link *link,
362362
enum smc_llc_reqresp reqresp)
363363
{
364-
struct smc_link_group *lgr = smc_get_lgr(link);
365364
struct smc_llc_msg_confirm_link *confllc;
366365
struct smc_wr_tx_pend_priv *pend;
367366
struct smc_wr_buf *wr_buf;
@@ -382,7 +381,7 @@ int smc_llc_send_confirm_link(struct smc_link *link,
382381
memcpy(confllc->sender_gid, link->gid, SMC_GID_SIZE);
383382
hton24(confllc->sender_qp_num, link->roce_qp->qp_num);
384383
confllc->link_num = link->link_id;
385-
memcpy(confllc->link_uid, lgr->id, SMC_LGR_ID_SIZE);
384+
memcpy(confllc->link_uid, link->link_uid, SMC_LGR_ID_SIZE);
386385
confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS;
387386
/* send llc message */
388387
rc = smc_wr_tx_send(link, pend);
@@ -845,7 +844,8 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
845844
if (rc)
846845
goto out_reject;
847846
smc_llc_save_add_link_info(lnk_new, llc);
848-
lnk_new->link_id = llc->link_num;
847+
lnk_new->link_id = llc->link_num; /* SMC server assigns link id */
848+
smc_llc_link_set_uid(lnk_new);
849849

850850
rc = smc_ib_ready_link(lnk_new);
851851
if (rc)
@@ -1775,12 +1775,22 @@ int smc_llc_do_delete_rkey(struct smc_link_group *lgr,
17751775
return rc;
17761776
}
17771777

1778+
void smc_llc_link_set_uid(struct smc_link *link)
1779+
{
1780+
__be32 link_uid;
1781+
1782+
link_uid = htonl(*((u32 *)link->lgr->id) + link->link_id);
1783+
memcpy(link->link_uid, &link_uid, SMC_LGR_ID_SIZE);
1784+
}
1785+
17781786
/* evaluate confirm link request or response */
17791787
int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry,
17801788
enum smc_llc_reqresp type)
17811789
{
1782-
if (type == SMC_LLC_REQ) /* SMC server assigns link_id */
1790+
if (type == SMC_LLC_REQ) { /* SMC server assigns link_id */
17831791
qentry->link->link_id = qentry->msg.confirm_link.link_num;
1792+
smc_llc_link_set_uid(qentry->link);
1793+
}
17841794
if (!(qentry->msg.raw.hdr.flags & SMC_LLC_FLAG_NO_RMBE_EYEC))
17851795
return -ENOTSUPP;
17861796
return 0;

net/smc/smc_llc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ int smc_llc_flow_initiate(struct smc_link_group *lgr,
9292
void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow);
9393
int smc_llc_eval_conf_link(struct smc_llc_qentry *qentry,
9494
enum smc_llc_reqresp type);
95+
void smc_llc_link_set_uid(struct smc_link *link);
9596
struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
9697
struct smc_link *lnk,
9798
int time_out, u8 exp_msg);

0 commit comments

Comments
 (0)