Skip to content

Commit 8574cf4

Browse files
karstengrdavem330
authored andcommitted
net/smc: allocate index for a new link
Add smc_llc_alloc_alt_link() to find a free link index for a new link, depending on the new link group type. And update constants for the maximum number of links to 3 (2 symmetric and 1 dangling asymmetric link). These maximum numbers are the same as used by other implementations of the SMC-R protocol. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c868a3 commit 8574cf4

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

net/smc/smc_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct smc_link {
128128
/* For now we just allow one parallel link per link group. The SMC protocol
129129
* allows more (up to 8).
130130
*/
131-
#define SMC_LINKS_PER_LGR_MAX 1
131+
#define SMC_LINKS_PER_LGR_MAX 3
132132
#define SMC_SINGLE_LINK 0
133133

134134
#define SMC_FIRST_CONTACT 1 /* first contact to a peer */

net/smc/smc_llc.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,30 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf)
541541

542542
/********************************* receive ***********************************/
543543

544+
static int smc_llc_alloc_alt_link(struct smc_link_group *lgr,
545+
enum smc_lgr_type lgr_new_t)
546+
{
547+
int i;
548+
549+
if (lgr->type == SMC_LGR_SYMMETRIC ||
550+
(lgr->type != SMC_LGR_SINGLE &&
551+
(lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
552+
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER)))
553+
return -EMLINK;
554+
555+
if (lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
556+
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER) {
557+
for (i = SMC_LINKS_PER_LGR_MAX - 1; i >= 0; i--)
558+
if (lgr->lnk[i].state == SMC_LNK_UNUSED)
559+
return i;
560+
} else {
561+
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
562+
if (lgr->lnk[i].state == SMC_LNK_UNUSED)
563+
return i;
564+
}
565+
return -EMLINK;
566+
}
567+
544568
static void smc_llc_rx_delete_link(struct smc_link *link,
545569
struct smc_llc_msg_del_link *llc)
546570
{

0 commit comments

Comments
 (0)