net/smc: add function to get link group from link
Replace a frequently used construct with a more readable variant, reducing the code. Also might come handy when we start to support more than a single per link group. Signed-off-by: Stefan Raspl <raspl@linux.ibm.com> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
bac6de7b63
commit
00e5fb263f
@@ -365,7 +365,7 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
|
|||||||
return; /* invalid message */
|
return; /* invalid message */
|
||||||
|
|
||||||
/* lookup connection */
|
/* lookup connection */
|
||||||
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
lgr = smc_get_lgr(link);
|
||||||
read_lock_bh(&lgr->conns_lock);
|
read_lock_bh(&lgr->conns_lock);
|
||||||
conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
|
conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
|
||||||
read_unlock_bh(&lgr->conns_lock);
|
read_unlock_bh(&lgr->conns_lock);
|
||||||
|
|||||||
@@ -266,4 +266,9 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
|
|||||||
u64 peer_gid);
|
u64 peer_gid);
|
||||||
void smcd_conn_free(struct smc_connection *conn);
|
void smcd_conn_free(struct smc_connection *conn);
|
||||||
void smc_core_exit(void);
|
void smc_core_exit(void);
|
||||||
|
|
||||||
|
static inline struct smc_link_group *smc_get_lgr(struct smc_link *link)
|
||||||
|
{
|
||||||
|
return container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -112,8 +112,7 @@ int smc_ib_modify_qp_reset(struct smc_link *lnk)
|
|||||||
|
|
||||||
int smc_ib_ready_link(struct smc_link *lnk)
|
int smc_ib_ready_link(struct smc_link *lnk)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr =
|
struct smc_link_group *lgr = smc_get_lgr(lnk);
|
||||||
container_of(lnk, struct smc_link_group, lnk[0]);
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rc = smc_ib_modify_qp_init(lnk);
|
rc = smc_ib_modify_qp_init(lnk);
|
||||||
|
|||||||
@@ -186,8 +186,7 @@ int smc_llc_send_confirm_link(struct smc_link *link, u8 mac[],
|
|||||||
union ib_gid *gid,
|
union ib_gid *gid,
|
||||||
enum smc_llc_reqresp reqresp)
|
enum smc_llc_reqresp reqresp)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr = container_of(link, struct smc_link_group,
|
struct smc_link_group *lgr = smc_get_lgr(link);
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
struct smc_llc_msg_confirm_link *confllc;
|
struct smc_llc_msg_confirm_link *confllc;
|
||||||
struct smc_wr_tx_pend_priv *pend;
|
struct smc_wr_tx_pend_priv *pend;
|
||||||
struct smc_wr_buf *wr_buf;
|
struct smc_wr_buf *wr_buf;
|
||||||
@@ -381,11 +380,9 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf, int llclen)
|
|||||||
static void smc_llc_rx_confirm_link(struct smc_link *link,
|
static void smc_llc_rx_confirm_link(struct smc_link *link,
|
||||||
struct smc_llc_msg_confirm_link *llc)
|
struct smc_llc_msg_confirm_link *llc)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr;
|
struct smc_link_group *lgr = smc_get_lgr(link);
|
||||||
int conf_rc;
|
int conf_rc;
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
/* RMBE eyecatchers are not supported */
|
/* RMBE eyecatchers are not supported */
|
||||||
if (llc->hd.flags & SMC_LLC_FLAG_NO_RMBE_EYEC)
|
if (llc->hd.flags & SMC_LLC_FLAG_NO_RMBE_EYEC)
|
||||||
conf_rc = 0;
|
conf_rc = 0;
|
||||||
@@ -411,8 +408,7 @@ static void smc_llc_rx_confirm_link(struct smc_link *link,
|
|||||||
static void smc_llc_rx_add_link(struct smc_link *link,
|
static void smc_llc_rx_add_link(struct smc_link *link,
|
||||||
struct smc_llc_msg_add_link *llc)
|
struct smc_llc_msg_add_link *llc)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr = container_of(link, struct smc_link_group,
|
struct smc_link_group *lgr = smc_get_lgr(link);
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
||||||
if (link->state == SMC_LNK_ACTIVATING)
|
if (link->state == SMC_LNK_ACTIVATING)
|
||||||
@@ -442,8 +438,7 @@ static void smc_llc_rx_add_link(struct smc_link *link,
|
|||||||
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)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr = container_of(link, struct smc_link_group,
|
struct smc_link_group *lgr = smc_get_lgr(link);
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
||||||
if (lgr->role == SMC_SERV)
|
if (lgr->role == SMC_SERV)
|
||||||
@@ -476,17 +471,14 @@ static void smc_llc_rx_test_link(struct smc_link *link,
|
|||||||
static void smc_llc_rx_confirm_rkey(struct smc_link *link,
|
static void smc_llc_rx_confirm_rkey(struct smc_link *link,
|
||||||
struct smc_llc_msg_confirm_rkey *llc)
|
struct smc_llc_msg_confirm_rkey *llc)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
||||||
link->llc_confirm_rkey_rc = llc->hd.flags &
|
link->llc_confirm_rkey_rc = llc->hd.flags &
|
||||||
SMC_LLC_FLAG_RKEY_NEG;
|
SMC_LLC_FLAG_RKEY_NEG;
|
||||||
complete(&link->llc_confirm_rkey);
|
complete(&link->llc_confirm_rkey);
|
||||||
} else {
|
} else {
|
||||||
rc = smc_rtoken_add(lgr,
|
rc = smc_rtoken_add(smc_get_lgr(link),
|
||||||
llc->rtoken[0].rmb_vaddr,
|
llc->rtoken[0].rmb_vaddr,
|
||||||
llc->rtoken[0].rmb_key);
|
llc->rtoken[0].rmb_key);
|
||||||
|
|
||||||
@@ -514,18 +506,15 @@ static void smc_llc_rx_confirm_rkey_cont(struct smc_link *link,
|
|||||||
static void smc_llc_rx_delete_rkey(struct smc_link *link,
|
static void smc_llc_rx_delete_rkey(struct smc_link *link,
|
||||||
struct smc_llc_msg_delete_rkey *llc)
|
struct smc_llc_msg_delete_rkey *llc)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr;
|
|
||||||
u8 err_mask = 0;
|
u8 err_mask = 0;
|
||||||
int i, max;
|
int i, max;
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
|
||||||
/* unused as long as we don't send this type of msg */
|
/* unused as long as we don't send this type of msg */
|
||||||
} else {
|
} else {
|
||||||
max = min_t(u8, llc->num_rkeys, SMC_LLC_DEL_RKEY_MAX);
|
max = min_t(u8, llc->num_rkeys, SMC_LLC_DEL_RKEY_MAX);
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
if (smc_rtoken_delete(lgr, llc->rkey[i]))
|
if (smc_rtoken_delete(smc_get_lgr(link), llc->rkey[i]))
|
||||||
err_mask |= 1 << (SMC_LLC_DEL_RKEY_MAX - 1 - i);
|
err_mask |= 1 << (SMC_LLC_DEL_RKEY_MAX - 1 - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,12 +572,10 @@ static void smc_llc_testlink_work(struct work_struct *work)
|
|||||||
struct smc_link *link = container_of(to_delayed_work(work),
|
struct smc_link *link = container_of(to_delayed_work(work),
|
||||||
struct smc_link, llc_testlink_wrk);
|
struct smc_link, llc_testlink_wrk);
|
||||||
unsigned long next_interval;
|
unsigned long next_interval;
|
||||||
struct smc_link_group *lgr;
|
|
||||||
unsigned long expire_time;
|
unsigned long expire_time;
|
||||||
u8 user_data[16] = { 0 };
|
u8 user_data[16] = { 0 };
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
|
|
||||||
if (link->state != SMC_LNK_ACTIVE)
|
if (link->state != SMC_LNK_ACTIVE)
|
||||||
return; /* don't reschedule worker */
|
return; /* don't reschedule worker */
|
||||||
expire_time = link->wr_rx_tstamp + link->llc_testlink_time;
|
expire_time = link->wr_rx_tstamp + link->llc_testlink_time;
|
||||||
@@ -602,7 +589,7 @@ static void smc_llc_testlink_work(struct work_struct *work)
|
|||||||
rc = wait_for_completion_interruptible_timeout(&link->llc_testlink_resp,
|
rc = wait_for_completion_interruptible_timeout(&link->llc_testlink_resp,
|
||||||
SMC_LLC_WAIT_TIME);
|
SMC_LLC_WAIT_TIME);
|
||||||
if (rc <= 0) {
|
if (rc <= 0) {
|
||||||
smc_lgr_terminate(lgr);
|
smc_lgr_terminate(smc_get_lgr(link));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
next_interval = link->llc_testlink_time;
|
next_interval = link->llc_testlink_time;
|
||||||
@@ -613,8 +600,7 @@ out:
|
|||||||
|
|
||||||
int smc_llc_link_init(struct smc_link *link)
|
int smc_llc_link_init(struct smc_link *link)
|
||||||
{
|
{
|
||||||
struct smc_link_group *lgr = container_of(link, struct smc_link_group,
|
struct smc_link_group *lgr = smc_get_lgr(link);
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
link->llc_wq = alloc_ordered_workqueue("llc_wq-%x:%x)", WQ_MEM_RECLAIM,
|
link->llc_wq = alloc_ordered_workqueue("llc_wq-%x:%x)", WQ_MEM_RECLAIM,
|
||||||
*((u32 *)lgr->id),
|
*((u32 *)lgr->id),
|
||||||
link->link_id);
|
link->link_id);
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
|
|||||||
if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask))
|
if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask))
|
||||||
return;
|
return;
|
||||||
if (wc->status) {
|
if (wc->status) {
|
||||||
struct smc_link_group *lgr;
|
|
||||||
|
|
||||||
for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) {
|
for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) {
|
||||||
/* clear full struct smc_wr_tx_pend including .priv */
|
/* clear full struct smc_wr_tx_pend including .priv */
|
||||||
memset(&link->wr_tx_pends[i], 0,
|
memset(&link->wr_tx_pends[i], 0,
|
||||||
@@ -103,9 +101,7 @@ static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
|
|||||||
clear_bit(i, link->wr_tx_mask);
|
clear_bit(i, link->wr_tx_mask);
|
||||||
}
|
}
|
||||||
/* terminate connections of this link group abnormally */
|
/* terminate connections of this link group abnormally */
|
||||||
lgr = container_of(link, struct smc_link_group,
|
smc_lgr_terminate(smc_get_lgr(link));
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
smc_lgr_terminate(lgr);
|
|
||||||
}
|
}
|
||||||
if (pnd_snd.handler)
|
if (pnd_snd.handler)
|
||||||
pnd_snd.handler(&pnd_snd.priv, link, wc->status);
|
pnd_snd.handler(&pnd_snd.priv, link, wc->status);
|
||||||
@@ -188,8 +184,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
|
|||||||
} else {
|
} else {
|
||||||
struct smc_link_group *lgr;
|
struct smc_link_group *lgr;
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group,
|
lgr = smc_get_lgr(link);
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
rc = wait_event_timeout(
|
rc = wait_event_timeout(
|
||||||
link->wr_tx_wait,
|
link->wr_tx_wait,
|
||||||
list_empty(&lgr->list) || /* lgr terminated */
|
list_empty(&lgr->list) || /* lgr terminated */
|
||||||
@@ -250,12 +245,8 @@ int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
|
|||||||
rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx],
|
rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx],
|
||||||
&failed_wr);
|
&failed_wr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
struct smc_link_group *lgr =
|
|
||||||
container_of(link, struct smc_link_group,
|
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
|
|
||||||
smc_wr_tx_put_slot(link, priv);
|
smc_wr_tx_put_slot(link, priv);
|
||||||
smc_lgr_terminate(lgr);
|
smc_lgr_terminate(smc_get_lgr(link));
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -283,11 +274,7 @@ int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
|
|||||||
SMC_WR_REG_MR_WAIT_TIME);
|
SMC_WR_REG_MR_WAIT_TIME);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
/* timeout - terminate connections */
|
/* timeout - terminate connections */
|
||||||
struct smc_link_group *lgr;
|
smc_lgr_terminate(smc_get_lgr(link));
|
||||||
|
|
||||||
lgr = container_of(link, struct smc_link_group,
|
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
smc_lgr_terminate(lgr);
|
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
}
|
}
|
||||||
if (rc == -ERESTARTSYS)
|
if (rc == -ERESTARTSYS)
|
||||||
@@ -380,8 +367,6 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
|
|||||||
smc_wr_rx_demultiplex(&wc[i]);
|
smc_wr_rx_demultiplex(&wc[i]);
|
||||||
smc_wr_rx_post(link); /* refill WR RX */
|
smc_wr_rx_post(link); /* refill WR RX */
|
||||||
} else {
|
} else {
|
||||||
struct smc_link_group *lgr;
|
|
||||||
|
|
||||||
/* handle status errors */
|
/* handle status errors */
|
||||||
switch (wc[i].status) {
|
switch (wc[i].status) {
|
||||||
case IB_WC_RETRY_EXC_ERR:
|
case IB_WC_RETRY_EXC_ERR:
|
||||||
@@ -390,9 +375,7 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
|
|||||||
/* terminate connections of this link group
|
/* terminate connections of this link group
|
||||||
* abnormally
|
* abnormally
|
||||||
*/
|
*/
|
||||||
lgr = container_of(link, struct smc_link_group,
|
smc_lgr_terminate(smc_get_lgr(link));
|
||||||
lnk[SMC_SINGLE_LINK]);
|
|
||||||
smc_lgr_terminate(lgr);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
smc_wr_rx_post(link); /* refill WR RX */
|
smc_wr_rx_post(link); /* refill WR RX */
|
||||||
|
|||||||
Reference in New Issue
Block a user