• Home
  • Raw
  • Download

Lines Matching refs:lnk

70 static void smc_ibdev_cnt_inc(struct smc_link *lnk)  in smc_ibdev_cnt_inc()  argument
72 atomic_inc(&lnk->smcibdev->lnk_cnt_by_port[lnk->ibport - 1]); in smc_ibdev_cnt_inc()
75 static void smc_ibdev_cnt_dec(struct smc_link *lnk) in smc_ibdev_cnt_dec() argument
77 atomic_dec(&lnk->smcibdev->lnk_cnt_by_port[lnk->ibport - 1]); in smc_ibdev_cnt_dec()
130 struct smc_link *lnk = &conn->lgr->lnk[i]; in smcr_lgr_conn_assign_link() local
132 if (lnk->state != expected || lnk->link_is_asym) in smcr_lgr_conn_assign_link()
135 conn->lnk = lnk; /* temporary, SMC server assigns link*/ in smcr_lgr_conn_assign_link()
142 lnk2 = &conn->lgr->lnk[j]; in smcr_lgr_conn_assign_link()
145 conn->lnk = lnk2; in smcr_lgr_conn_assign_link()
150 if (!conn->lnk) in smcr_lgr_conn_assign_link()
151 conn->lnk = lnk; in smcr_lgr_conn_assign_link()
154 if (!conn->lnk) in smcr_lgr_conn_assign_link()
156 atomic_inc(&conn->lnk->conn_cnt); in smcr_lgr_conn_assign_link()
200 if (conn->lnk) in __smc_lgr_unregister_conn()
201 atomic_dec(&conn->lnk->conn_cnt); in __smc_lgr_unregister_conn()
397 if (!smc_link_usable(&lgr->lnk[i])) in smc_nl_handle_lgr()
399 if (smc_nl_fill_lgr_link(lgr, &lgr->lnk[i], skb, cb)) in smc_nl_handle_lgr()
605 struct smc_link *lnk = &lgr->lnk[i]; in smcr_lgr_link_deactivate_all() local
607 if (smc_link_sendable(lnk)) in smcr_lgr_link_deactivate_all()
608 lnk->state = SMC_LNK_INACTIVE; in smcr_lgr_link_deactivate_all()
672 if (smc_link_usable(&lgr->lnk[i]) && in smcr_next_link_id()
673 lgr->lnk[i].link_id == link_id) in smcr_next_link_id()
690 int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, in smcr_link_init() argument
698 lnk->link_id = smcr_next_link_id(lgr); in smcr_link_init()
699 lnk->lgr = lgr; in smcr_link_init()
700 lnk->link_idx = link_idx; in smcr_link_init()
701 lnk->smcibdev = ini->ib_dev; in smcr_link_init()
702 lnk->ibport = ini->ib_port; in smcr_link_init()
703 smc_ibdev_cnt_inc(lnk); in smcr_link_init()
704 smcr_copy_dev_info_to_link(lnk); in smcr_link_init()
705 lnk->path_mtu = ini->ib_dev->pattr[ini->ib_port - 1].active_mtu; in smcr_link_init()
706 atomic_set(&lnk->conn_cnt, 0); in smcr_link_init()
707 smc_llc_link_set_uid(lnk); in smcr_link_init()
708 INIT_WORK(&lnk->link_down_wrk, smc_link_down_work); in smcr_link_init()
715 lnk->psn_initial = rndvec[0] + (rndvec[1] << 8) + in smcr_link_init()
717 rc = smc_ib_determine_gid(lnk->smcibdev, lnk->ibport, in smcr_link_init()
718 ini->vlan_id, lnk->gid, &lnk->sgid_index); in smcr_link_init()
721 rc = smc_llc_link_init(lnk); in smcr_link_init()
724 rc = smc_wr_alloc_link_mem(lnk); in smcr_link_init()
727 rc = smc_ib_create_protection_domain(lnk); in smcr_link_init()
730 rc = smc_ib_create_queue_pair(lnk); in smcr_link_init()
733 rc = smc_wr_create_link(lnk); in smcr_link_init()
736 lnk->state = SMC_LNK_ACTIVATING; in smcr_link_init()
740 smc_ib_destroy_queue_pair(lnk); in smcr_link_init()
742 smc_ib_dealloc_protection_domain(lnk); in smcr_link_init()
744 smc_wr_free_link_mem(lnk); in smcr_link_init()
746 smc_llc_link_clear(lnk, false); in smcr_link_init()
748 smc_ibdev_cnt_dec(lnk); in smcr_link_init()
750 memset(lnk, 0, sizeof(struct smc_link)); in smcr_link_init()
751 lnk->state = SMC_LNK_UNUSED; in smcr_link_init()
762 struct smc_link *lnk; in smc_lgr_create() local
825 lnk = &lgr->lnk[link_idx]; in smc_lgr_create()
826 rc = smcr_link_init(lgr, lnk, link_idx, ini); in smc_lgr_create()
914 smc_wr_tx_put_slot(conn->lnk, in smc_switch_cursor()
923 atomic_dec(&conn->lnk->conn_cnt); in smc_switch_link_and_count()
924 conn->lnk = to_lnk; in smc_switch_link_and_count()
925 atomic_inc(&conn->lnk->conn_cnt); in smc_switch_link_and_count()
943 if (!smc_link_active(&lgr->lnk[i]) || i == from_lnk->link_idx) in smc_switch_conns()
945 if (is_dev_err && from_lnk->smcibdev == lgr->lnk[i].smcibdev && in smc_switch_conns()
946 from_lnk->ibport == lgr->lnk[i].ibport) { in smc_switch_conns()
949 to_lnk = &lgr->lnk[i]; in smc_switch_conns()
960 if (conn->lnk != from_lnk) in smc_switch_conns()
1074 struct smc_link *lnk) in smcr_buf_unmap_link() argument
1077 buf_desc->is_reg_mr[lnk->link_idx] = false; in smcr_buf_unmap_link()
1078 if (!buf_desc->is_map_ib[lnk->link_idx]) in smcr_buf_unmap_link()
1081 if (buf_desc->mr_rx[lnk->link_idx]) { in smcr_buf_unmap_link()
1083 buf_desc->mr_rx[lnk->link_idx]); in smcr_buf_unmap_link()
1084 buf_desc->mr_rx[lnk->link_idx] = NULL; in smcr_buf_unmap_link()
1086 smc_ib_buf_unmap_sg(lnk, buf_desc, DMA_FROM_DEVICE); in smcr_buf_unmap_link()
1088 smc_ib_buf_unmap_sg(lnk, buf_desc, DMA_TO_DEVICE); in smcr_buf_unmap_link()
1090 sg_free_table(&buf_desc->sgt[lnk->link_idx]); in smcr_buf_unmap_link()
1091 buf_desc->is_map_ib[lnk->link_idx] = false; in smcr_buf_unmap_link()
1095 static void smcr_buf_unmap_lgr(struct smc_link *lnk) in smcr_buf_unmap_lgr() argument
1097 struct smc_link_group *lgr = lnk->lgr; in smcr_buf_unmap_lgr()
1104 smcr_buf_unmap_link(buf_desc, true, lnk); in smcr_buf_unmap_lgr()
1109 smcr_buf_unmap_link(buf_desc, false, lnk); in smcr_buf_unmap_lgr()
1114 static void smcr_rtoken_clear_link(struct smc_link *lnk) in smcr_rtoken_clear_link() argument
1116 struct smc_link_group *lgr = lnk->lgr; in smcr_rtoken_clear_link()
1120 lgr->rtokens[i][lnk->link_idx].rkey = 0; in smcr_rtoken_clear_link()
1121 lgr->rtokens[i][lnk->link_idx].dma_addr = 0; in smcr_rtoken_clear_link()
1126 void smcr_link_clear(struct smc_link *lnk, bool log) in smcr_link_clear() argument
1130 if (!lnk->lgr || lnk->state == SMC_LNK_UNUSED) in smcr_link_clear()
1132 lnk->peer_qpn = 0; in smcr_link_clear()
1133 smc_llc_link_clear(lnk, log); in smcr_link_clear()
1134 smcr_buf_unmap_lgr(lnk); in smcr_link_clear()
1135 smcr_rtoken_clear_link(lnk); in smcr_link_clear()
1136 smc_ib_modify_qp_error(lnk); in smcr_link_clear()
1137 smc_wr_free_link(lnk); in smcr_link_clear()
1138 smc_ib_destroy_queue_pair(lnk); in smcr_link_clear()
1139 smc_ib_dealloc_protection_domain(lnk); in smcr_link_clear()
1140 smc_wr_free_link_mem(lnk); in smcr_link_clear()
1141 smc_ibdev_cnt_dec(lnk); in smcr_link_clear()
1142 put_device(&lnk->smcibdev->ibdev->dev); in smcr_link_clear()
1143 smcibdev = lnk->smcibdev; in smcr_link_clear()
1144 memset(lnk, 0, sizeof(struct smc_link)); in smcr_link_clear()
1145 lnk->state = SMC_LNK_UNUSED; in smcr_link_clear()
1156 smcr_buf_unmap_link(buf_desc, is_rmb, &lgr->lnk[i]); in smcr_buf_free()
1220 if (lgr->lnk[i].state != SMC_LNK_UNUSED) in smc_lgr_free()
1221 smcr_link_clear(&lgr->lnk[i], false); in smc_lgr_free()
1405 if (lgr->lnk[i].smcibdev == smcibdev) in smc_smcr_terminate_all()
1406 smcr_link_down_cond_sched(&lgr->lnk[i]); in smc_smcr_terminate_all()
1435 if (smc_link_usable(&lgr->lnk[i])) in smcr_lgr_set_type()
1436 lgr->lnk[i].link_is_asym = false; in smcr_lgr_set_type()
1468 lgr->lnk[asym_lnk_idx].link_is_asym = true; in smcr_lgr_set_type_asym()
1510 static void smcr_link_down(struct smc_link *lnk) in smcr_link_down() argument
1512 struct smc_link_group *lgr = lnk->lgr; in smcr_link_down()
1516 if (!lgr || lnk->state == SMC_LNK_UNUSED || list_empty(&lgr->list)) in smcr_link_down()
1519 to_lnk = smc_switch_conns(lgr, lnk, true); in smcr_link_down()
1521 smcr_link_clear(lnk, true); in smcr_link_down()
1525 del_link_id = lnk->link_id; in smcr_link_down()
1544 smcr_link_clear(lnk, true); in smcr_link_down()
1551 void smcr_link_down_cond(struct smc_link *lnk) in smcr_link_down_cond() argument
1553 if (smc_link_downing(&lnk->state)) in smcr_link_down_cond()
1554 smcr_link_down(lnk); in smcr_link_down_cond()
1558 void smcr_link_down_cond_sched(struct smc_link *lnk) in smcr_link_down_cond_sched() argument
1560 if (smc_link_downing(&lnk->state)) in smcr_link_down_cond_sched()
1561 schedule_work(&lnk->link_down_wrk); in smcr_link_down_cond_sched()
1576 struct smc_link *lnk = &lgr->lnk[i]; in smcr_port_err() local
1578 if (smc_link_usable(lnk) && in smcr_port_err()
1579 lnk->smcibdev == smcibdev && lnk->ibport == ibport) in smcr_port_err()
1580 smcr_link_down_cond_sched(lnk); in smcr_port_err()
1658 if (!smc_link_active(&lgr->lnk[i])) in smcr_lgr_match()
1660 if ((lgr->role == SMC_SERV || lgr->lnk[i].peer_qpn == clcqpn) && in smcr_lgr_match()
1661 !memcmp(lgr->lnk[i].peer_gid, &lcl->gid, SMC_GID_SIZE) && in smcr_lgr_match()
1662 !memcmp(lgr->lnk[i].peer_mac, lcl->mac, sizeof(lcl->mac))) in smcr_lgr_match()
1832 struct smc_link *lnk) in smcr_buf_map_link() argument
1836 if (buf_desc->is_map_ib[lnk->link_idx]) in smcr_buf_map_link()
1839 rc = sg_alloc_table(&buf_desc->sgt[lnk->link_idx], 1, GFP_KERNEL); in smcr_buf_map_link()
1842 sg_set_buf(buf_desc->sgt[lnk->link_idx].sgl, in smcr_buf_map_link()
1846 rc = smc_ib_buf_map_sg(lnk, buf_desc, in smcr_buf_map_link()
1856 rc = smc_ib_get_memory_region(lnk->roce_pd, in smcr_buf_map_link()
1859 buf_desc, lnk->link_idx); in smcr_buf_map_link()
1862 smc_ib_sync_sg_for_device(lnk, buf_desc, DMA_FROM_DEVICE); in smcr_buf_map_link()
1864 buf_desc->is_map_ib[lnk->link_idx] = true; in smcr_buf_map_link()
1868 smc_ib_buf_unmap_sg(lnk, buf_desc, in smcr_buf_map_link()
1871 sg_free_table(&buf_desc->sgt[lnk->link_idx]); in smcr_buf_map_link()
1893 static int _smcr_buf_map_lgr(struct smc_link *lnk, struct mutex *lock, in _smcr_buf_map_lgr() argument
1903 rc = smcr_buf_map_link(buf_desc, is_rmb, lnk); in _smcr_buf_map_lgr()
1913 int smcr_buf_map_lgr(struct smc_link *lnk) in smcr_buf_map_lgr() argument
1915 struct smc_link_group *lgr = lnk->lgr; in smcr_buf_map_lgr()
1919 rc = _smcr_buf_map_lgr(lnk, &lgr->rmbs_lock, in smcr_buf_map_lgr()
1923 rc = _smcr_buf_map_lgr(lnk, &lgr->sndbufs_lock, in smcr_buf_map_lgr()
1934 int smcr_buf_reg_lgr(struct smc_link *lnk) in smcr_buf_reg_lgr() argument
1936 struct smc_link_group *lgr = lnk->lgr; in smcr_buf_reg_lgr()
1945 rc = smcr_link_reg_rmb(lnk, buf_desc); in smcr_buf_reg_lgr()
1990 struct smc_link *lnk = &lgr->lnk[i]; in smcr_buf_map_usable_links() local
1992 if (!smc_link_usable(lnk)) in smcr_buf_map_usable_links()
1994 if (smcr_buf_map_link(buf_desc, is_rmb, lnk)) { in smcr_buf_map_usable_links()
2134 if (!conn->lgr || conn->lgr->is_smcd || !smc_link_active(conn->lnk)) in smc_sndbuf_sync_sg_for_cpu()
2136 smc_ib_sync_sg_for_cpu(conn->lnk, conn->sndbuf_desc, DMA_TO_DEVICE); in smc_sndbuf_sync_sg_for_cpu()
2141 if (!conn->lgr || conn->lgr->is_smcd || !smc_link_active(conn->lnk)) in smc_sndbuf_sync_sg_for_device()
2143 smc_ib_sync_sg_for_device(conn->lnk, conn->sndbuf_desc, DMA_TO_DEVICE); in smc_sndbuf_sync_sg_for_device()
2153 if (!smc_link_active(&conn->lgr->lnk[i])) in smc_rmb_sync_sg_for_cpu()
2155 smc_ib_sync_sg_for_cpu(&conn->lgr->lnk[i], conn->rmb_desc, in smc_rmb_sync_sg_for_cpu()
2167 if (!smc_link_active(&conn->lgr->lnk[i])) in smc_rmb_sync_sg_for_device()
2169 smc_ib_sync_sg_for_device(&conn->lgr->lnk[i], conn->rmb_desc, in smc_rmb_sync_sg_for_device()
2247 if (lgr->lnk[link_idx].link_id == link_id) { in smc_rtoken_set2()
2259 int smc_rtoken_add(struct smc_link *lnk, __be64 nw_vaddr, __be32 nw_rkey) in smc_rtoken_add() argument
2261 struct smc_link_group *lgr = smc_get_lgr(lnk); in smc_rtoken_add()
2267 if (lgr->rtokens[i][lnk->link_idx].rkey == rkey && in smc_rtoken_add()
2268 lgr->rtokens[i][lnk->link_idx].dma_addr == dma_addr && in smc_rtoken_add()
2277 lgr->rtokens[i][lnk->link_idx].rkey = rkey; in smc_rtoken_add()
2278 lgr->rtokens[i][lnk->link_idx].dma_addr = dma_addr; in smc_rtoken_add()
2283 int smc_rtoken_delete(struct smc_link *lnk, __be32 nw_rkey) in smc_rtoken_delete() argument
2285 struct smc_link_group *lgr = smc_get_lgr(lnk); in smc_rtoken_delete()
2290 if (lgr->rtokens[i][lnk->link_idx].rkey == rkey && in smc_rtoken_delete()
2305 struct smc_link *lnk, in smc_rmb_rtoken_handling() argument
2308 conn->rtoken_idx = smc_rtoken_add(lnk, clc->r0.rmb_dma_addr, in smc_rmb_rtoken_handling()