Skip to content

Commit ad6c111

Browse files
karstengrdavem330
authored andcommitted
net/smc: asymmetric link tagging
New connections must not be assigned to asymmetric links. Add asymmetric link tagging using new link variable link_is_asym. The new helpers smcr_lgr_set_type() and smcr_lgr_set_type_asym() are called to set the state of the link group, and tag all links accordingly. smcr_lgr_conn_assign_link() respects the link tagging and will not assign new connections to links tagged as asymmetric link. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 56bc3b2 commit ad6c111

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

net/smc/smc_core.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static int smcr_lgr_conn_assign_link(struct smc_connection *conn, bool first)
132132
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
133133
struct smc_link *lnk = &conn->lgr->lnk[i];
134134

135-
if (lnk->state != expected)
135+
if (lnk->state != expected || lnk->link_is_asym)
136136
continue;
137137
if (conn->lgr->role == SMC_CLNT) {
138138
conn->lnk = lnk; /* temporary, SMC server assigns link*/
@@ -143,7 +143,8 @@ static int smcr_lgr_conn_assign_link(struct smc_connection *conn, bool first)
143143
struct smc_link *lnk2;
144144

145145
lnk2 = &conn->lgr->lnk[j];
146-
if (lnk2->state == expected) {
146+
if (lnk2->state == expected &&
147+
!lnk2->link_is_asym) {
147148
conn->lnk = lnk2;
148149
break;
149150
}
@@ -1030,6 +1031,25 @@ void smc_smcr_terminate_all(struct smc_ib_device *smcibdev)
10301031
}
10311032
}
10321033

1034+
/* set new lgr type and clear all asymmetric link tagging */
1035+
void smcr_lgr_set_type(struct smc_link_group *lgr, enum smc_lgr_type new_type)
1036+
{
1037+
int i;
1038+
1039+
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
1040+
if (smc_link_usable(&lgr->lnk[i]))
1041+
lgr->lnk[i].link_is_asym = false;
1042+
lgr->type = new_type;
1043+
}
1044+
1045+
/* set new lgr type and tag a link as asymmetric */
1046+
void smcr_lgr_set_type_asym(struct smc_link_group *lgr,
1047+
enum smc_lgr_type new_type, int asym_lnk_idx)
1048+
{
1049+
smcr_lgr_set_type(lgr, new_type);
1050+
lgr->lnk[asym_lnk_idx].link_is_asym = true;
1051+
}
1052+
10331053
/* abort connection, abort_work scheduled from tasklet context */
10341054
static void smc_conn_abort_work(struct work_struct *work)
10351055
{
@@ -1123,7 +1143,7 @@ static void smcr_link_down(struct smc_link *lnk)
11231143
smcr_link_clear(lnk);
11241144
return;
11251145
}
1126-
lgr->type = SMC_LGR_SINGLE;
1146+
smcr_lgr_set_type(lgr, SMC_LGR_SINGLE);
11271147
del_link_id = lnk->link_id;
11281148

11291149
if (lgr->role == SMC_SERV) {

net/smc/smc_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct smc_link {
117117
u8 peer_gid[SMC_GID_SIZE]; /* gid of peer*/
118118
u8 link_id; /* unique # within link group */
119119
u8 link_idx; /* index in lgr link array */
120+
u8 link_is_asym; /* is link asymmetric? */
120121
struct smc_link_group *lgr; /* parent link group */
121122
struct work_struct link_down_wrk; /* wrk to bring link down */
122123

@@ -380,6 +381,9 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
380381
void smcr_link_clear(struct smc_link *lnk);
381382
int smcr_buf_map_lgr(struct smc_link *lnk);
382383
int smcr_buf_reg_lgr(struct smc_link *lnk);
384+
void smcr_lgr_set_type(struct smc_link_group *lgr, enum smc_lgr_type new_type);
385+
void smcr_lgr_set_type_asym(struct smc_link_group *lgr,
386+
enum smc_lgr_type new_type, int asym_lnk_idx);
383387
int smcr_link_reg_rmb(struct smc_link *link, struct smc_buf_desc *rmb_desc);
384388
struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
385389
struct smc_link *from_lnk, bool is_dev_err);

net/smc/smc_llc.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,11 @@ static int smc_llc_cli_conf_link(struct smc_link *link,
796796
return -ENOLINK;
797797
}
798798
smc_llc_link_active(link_new);
799-
lgr->type = lgr_new_t;
799+
if (lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
800+
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER)
801+
smcr_lgr_set_type_asym(lgr, lgr_new_t, link_new->link_idx);
802+
else
803+
smcr_lgr_set_type(lgr, lgr_new_t);
800804
return 0;
801805
}
802806

@@ -1038,7 +1042,11 @@ static int smc_llc_srv_conf_link(struct smc_link *link,
10381042
return -ENOLINK;
10391043
}
10401044
smc_llc_link_active(link_new);
1041-
lgr->type = lgr_new_t;
1045+
if (lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
1046+
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER)
1047+
smcr_lgr_set_type_asym(lgr, lgr_new_t, link_new->link_idx);
1048+
else
1049+
smcr_lgr_set_type(lgr, lgr_new_t);
10421050
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
10431051
return 0;
10441052
}
@@ -1223,9 +1231,9 @@ static void smc_llc_process_cli_delete_link(struct smc_link_group *lgr)
12231231
if (lnk_del == lnk_asym) {
12241232
/* expected deletion of asym link, don't change lgr state */
12251233
} else if (active_links == 1) {
1226-
lgr->type = SMC_LGR_SINGLE;
1234+
smcr_lgr_set_type(lgr, SMC_LGR_SINGLE);
12271235
} else if (!active_links) {
1228-
lgr->type = SMC_LGR_NONE;
1236+
smcr_lgr_set_type(lgr, SMC_LGR_NONE);
12291237
smc_lgr_terminate_sched(lgr);
12301238
}
12311239
out_unlock:
@@ -1314,9 +1322,9 @@ static void smc_llc_process_srv_delete_link(struct smc_link_group *lgr)
13141322

13151323
active_links = smc_llc_active_link_count(lgr);
13161324
if (active_links == 1) {
1317-
lgr->type = SMC_LGR_SINGLE;
1325+
smcr_lgr_set_type(lgr, SMC_LGR_SINGLE);
13181326
} else if (!active_links) {
1319-
lgr->type = SMC_LGR_NONE;
1327+
smcr_lgr_set_type(lgr, SMC_LGR_NONE);
13201328
smc_lgr_terminate_sched(lgr);
13211329
}
13221330

0 commit comments

Comments
 (0)