Commit 8574cf40 authored by Karsten Graul's avatar Karsten Graul Committed by David S. Miller

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: default avatarKarsten Graul <kgraul@linux.ibm.com>
Reviewed-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6c868a3e
...@@ -128,7 +128,7 @@ struct smc_link { ...@@ -128,7 +128,7 @@ struct smc_link {
/* For now we just allow one parallel link per link group. The SMC protocol /* For now we just allow one parallel link per link group. The SMC protocol
* allows more (up to 8). * allows more (up to 8).
*/ */
#define SMC_LINKS_PER_LGR_MAX 1 #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_FIRST_CONTACT 1 /* first contact to a peer */
......
...@@ -541,6 +541,30 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf) ...@@ -541,6 +541,30 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf)
/********************************* receive ***********************************/ /********************************* receive ***********************************/
static int smc_llc_alloc_alt_link(struct smc_link_group *lgr,
enum smc_lgr_type lgr_new_t)
{
int i;
if (lgr->type == SMC_LGR_SYMMETRIC ||
(lgr->type != SMC_LGR_SINGLE &&
(lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER)))
return -EMLINK;
if (lgr_new_t == SMC_LGR_ASYMMETRIC_LOCAL ||
lgr_new_t == SMC_LGR_ASYMMETRIC_PEER) {
for (i = SMC_LINKS_PER_LGR_MAX - 1; i >= 0; i--)
if (lgr->lnk[i].state == SMC_LNK_UNUSED)
return i;
} else {
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++)
if (lgr->lnk[i].state == SMC_LNK_UNUSED)
return i;
}
return -EMLINK;
}
static void smc_llc_rx_delete_link(struct smc_link *link, static void smc_llc_rx_delete_link(struct smc_link *link,
struct smc_llc_msg_del_link *llc) struct smc_llc_msg_del_link *llc)
{ {
......
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