Lines Matching refs:tpg

209 	struct vhost_scsi_tpg *tpg;  member
304 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_get_fabric_wwn() local
306 struct vhost_scsi_tport *tport = tpg->tport; in vhost_scsi_get_fabric_wwn()
313 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_get_tpgt() local
315 return tpg->tport_tpgt; in vhost_scsi_get_tpgt()
320 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_check_prot_fabric_only() local
323 return tpg->tv_fabric_prot_type; in vhost_scsi_check_prot_fabric_only()
355 struct vhost_scsi_tpg *tpg = tmf->tpg; in vhost_scsi_release_tmf_res() local
358 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_release_tmf_res()
359 list_add_tail(&tpg->tmf_queue, &tmf->queue_entry); in vhost_scsi_release_tmf_res()
360 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_release_tmf_res()
588 vhost_scsi_get_cmd(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg, in vhost_scsi_get_cmd() argument
600 tv_nexus = tpg->tpg_nexus; in vhost_scsi_get_cmd()
905 struct vhost_scsi_tpg **vs_tpg, *tpg; in vhost_scsi_get_req() local
909 tpg = READ_ONCE(vs_tpg[*vc->target]); in vhost_scsi_get_req()
910 if (unlikely(!tpg)) { in vhost_scsi_get_req()
914 *tpgp = tpg; in vhost_scsi_get_req()
930 struct vhost_scsi_tpg **vs_tpg, *tpg; in vhost_scsi_handle_vq() local
988 ret = vhost_scsi_get_req(vq, &vc, &tpg); in vhost_scsi_handle_vq()
1085 cmd = vhost_scsi_get_cmd(vq, tpg, cdb, tag, lun, task_attr, in vhost_scsi_handle_vq()
1175 vhost_scsi_handle_tmf(struct vhost_scsi *vs, struct vhost_scsi_tpg *tpg, in vhost_scsi_handle_tmf() argument
1188 if (!tpg->tpg_nexus || !tpg->tpg_nexus->tvn_se_sess) { in vhost_scsi_handle_tmf()
1193 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_handle_tmf()
1194 if (list_empty(&tpg->tmf_queue)) { in vhost_scsi_handle_tmf()
1196 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_handle_tmf()
1200 tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf, in vhost_scsi_handle_tmf()
1203 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_handle_tmf()
1205 tmf->tpg = tpg; in vhost_scsi_handle_tmf()
1213 if (target_submit_tmr(&tmf->se_cmd, tpg->tpg_nexus->tvn_se_sess, NULL, in vhost_scsi_handle_tmf()
1253 struct vhost_scsi_tpg *tpg; in vhost_scsi_ctl_handle_vq() local
1335 ret = vhost_scsi_get_req(vq, &vc, &tpg); in vhost_scsi_ctl_handle_vq()
1340 vhost_scsi_handle_tmf(vs, tpg, vq, &v_req.tmf, &vc); in vhost_scsi_ctl_handle_vq()
1371 struct vhost_scsi_tpg *tpg, in vhost_scsi_send_evt() argument
1382 if (tpg && lun) { in vhost_scsi_send_evt()
1389 evt->event.lun[1] = tpg->tport_tpgt; in vhost_scsi_send_evt()
1538 struct vhost_scsi_tpg *tpg; in vhost_scsi_set_endpoint() local
1565 list_for_each_entry(tpg, &vhost_scsi_list, tv_tpg_list) { in vhost_scsi_set_endpoint()
1566 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1567 if (!tpg->tpg_nexus) { in vhost_scsi_set_endpoint()
1568 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1571 if (tpg->tv_tpg_vhost_count != 0) { in vhost_scsi_set_endpoint()
1572 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1575 tv_tport = tpg->tport; in vhost_scsi_set_endpoint()
1578 if (vs->vs_tpg && vs->vs_tpg[tpg->tport_tpgt]) { in vhost_scsi_set_endpoint()
1579 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1589 se_tpg = &tpg->se_tpg; in vhost_scsi_set_endpoint()
1593 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1596 tpg->tv_tpg_vhost_count++; in vhost_scsi_set_endpoint()
1597 tpg->vhost_scsi = vs; in vhost_scsi_set_endpoint()
1598 vs_tpg[tpg->tport_tpgt] = tpg; in vhost_scsi_set_endpoint()
1601 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_set_endpoint()
1646 tpg = vs_tpg[i]; in vhost_scsi_set_endpoint()
1647 if (tpg) { in vhost_scsi_set_endpoint()
1648 tpg->tv_tpg_vhost_count--; in vhost_scsi_set_endpoint()
1649 target_undepend_item(&tpg->se_tpg.tpg_group.cg_item); in vhost_scsi_set_endpoint()
1665 struct vhost_scsi_tpg *tpg; in vhost_scsi_clear_endpoint() local
1688 tpg = vs->vs_tpg[target]; in vhost_scsi_clear_endpoint()
1689 if (!tpg) in vhost_scsi_clear_endpoint()
1692 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_clear_endpoint()
1693 tv_tport = tpg->tport; in vhost_scsi_clear_endpoint()
1702 tv_tport->tport_name, tpg->tport_tpgt, in vhost_scsi_clear_endpoint()
1707 tpg->tv_tpg_vhost_count--; in vhost_scsi_clear_endpoint()
1708 tpg->vhost_scsi = NULL; in vhost_scsi_clear_endpoint()
1711 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_clear_endpoint()
1716 se_tpg = &tpg->se_tpg; in vhost_scsi_clear_endpoint()
1747 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_clear_endpoint()
1980 vhost_scsi_do_plug(struct vhost_scsi_tpg *tpg, in vhost_scsi_do_plug() argument
1984 struct vhost_scsi *vs = tpg->vhost_scsi; in vhost_scsi_do_plug()
2001 vhost_scsi_send_evt(vs, tpg, lun, in vhost_scsi_do_plug()
2007 static void vhost_scsi_hotplug(struct vhost_scsi_tpg *tpg, struct se_lun *lun) in vhost_scsi_hotplug() argument
2009 vhost_scsi_do_plug(tpg, lun, true); in vhost_scsi_hotplug()
2012 static void vhost_scsi_hotunplug(struct vhost_scsi_tpg *tpg, struct se_lun *lun) in vhost_scsi_hotunplug() argument
2014 vhost_scsi_do_plug(tpg, lun, false); in vhost_scsi_hotunplug()
2020 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_port_link() local
2032 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_port_link()
2033 tpg->tv_tpg_port_count++; in vhost_scsi_port_link()
2034 list_add_tail(&tmf->queue_entry, &tpg->tmf_queue); in vhost_scsi_port_link()
2035 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_port_link()
2037 vhost_scsi_hotplug(tpg, lun); in vhost_scsi_port_link()
2047 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_port_unlink() local
2053 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_port_unlink()
2054 tpg->tv_tpg_port_count--; in vhost_scsi_port_unlink()
2055 tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf, in vhost_scsi_port_unlink()
2059 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_port_unlink()
2061 vhost_scsi_hotunplug(tpg, lun); in vhost_scsi_port_unlink()
2070 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_tpg_attrib_fabric_prot_type_store() local
2083 tpg->tv_fabric_prot_type = val; in vhost_scsi_tpg_attrib_fabric_prot_type_store()
2092 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_tpg_attrib_fabric_prot_type_show() local
2095 return sprintf(page, "%d\n", tpg->tv_fabric_prot_type); in vhost_scsi_tpg_attrib_fabric_prot_type_show()
2105 static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, in vhost_scsi_make_nexus() argument
2110 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_make_nexus()
2111 if (tpg->tpg_nexus) { in vhost_scsi_make_nexus()
2112 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_make_nexus()
2119 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_make_nexus()
2128 tv_nexus->tvn_se_sess = target_setup_session(&tpg->se_tpg, 0, 0, in vhost_scsi_make_nexus()
2132 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_make_nexus()
2136 tpg->tpg_nexus = tv_nexus; in vhost_scsi_make_nexus()
2138 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_make_nexus()
2142 static int vhost_scsi_drop_nexus(struct vhost_scsi_tpg *tpg) in vhost_scsi_drop_nexus() argument
2147 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2148 tv_nexus = tpg->tpg_nexus; in vhost_scsi_drop_nexus()
2150 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2156 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2160 if (tpg->tv_tpg_port_count != 0) { in vhost_scsi_drop_nexus()
2161 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2164 tpg->tv_tpg_port_count); in vhost_scsi_drop_nexus()
2168 if (tpg->tv_tpg_vhost_count != 0) { in vhost_scsi_drop_nexus()
2169 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2172 tpg->tv_tpg_vhost_count); in vhost_scsi_drop_nexus()
2177 " %s Initiator Port: %s\n", vhost_scsi_dump_proto_id(tpg->tport), in vhost_scsi_drop_nexus()
2184 tpg->tpg_nexus = NULL; in vhost_scsi_drop_nexus()
2185 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_drop_nexus()
2194 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_tpg_nexus_show() local
2199 mutex_lock(&tpg->tv_tpg_mutex); in vhost_scsi_tpg_nexus_show()
2200 tv_nexus = tpg->tpg_nexus; in vhost_scsi_tpg_nexus_show()
2202 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_tpg_nexus_show()
2207 mutex_unlock(&tpg->tv_tpg_mutex); in vhost_scsi_tpg_nexus_show()
2216 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_tpg_nexus_store() local
2218 struct vhost_scsi_tport *tport_wwn = tpg->tport; in vhost_scsi_tpg_nexus_store()
2225 ret = vhost_scsi_drop_nexus(tpg); in vhost_scsi_tpg_nexus_store()
2283 ret = vhost_scsi_make_nexus(tpg, port_ptr); in vhost_scsi_tpg_nexus_store()
2303 struct vhost_scsi_tpg *tpg; in vhost_scsi_make_tpg() local
2312 tpg = kzalloc(sizeof(*tpg), GFP_KERNEL); in vhost_scsi_make_tpg()
2313 if (!tpg) { in vhost_scsi_make_tpg()
2317 mutex_init(&tpg->tv_tpg_mutex); in vhost_scsi_make_tpg()
2318 INIT_LIST_HEAD(&tpg->tv_tpg_list); in vhost_scsi_make_tpg()
2319 INIT_LIST_HEAD(&tpg->tmf_queue); in vhost_scsi_make_tpg()
2320 tpg->tport = tport; in vhost_scsi_make_tpg()
2321 tpg->tport_tpgt = tpgt; in vhost_scsi_make_tpg()
2323 ret = core_tpg_register(wwn, &tpg->se_tpg, tport->tport_proto_id); in vhost_scsi_make_tpg()
2325 kfree(tpg); in vhost_scsi_make_tpg()
2329 list_add_tail(&tpg->tv_tpg_list, &vhost_scsi_list); in vhost_scsi_make_tpg()
2332 return &tpg->se_tpg; in vhost_scsi_make_tpg()
2337 struct vhost_scsi_tpg *tpg = container_of(se_tpg, in vhost_scsi_drop_tpg() local
2341 list_del(&tpg->tv_tpg_list); in vhost_scsi_drop_tpg()
2346 vhost_scsi_drop_nexus(tpg); in vhost_scsi_drop_tpg()
2351 kfree(tpg); in vhost_scsi_drop_tpg()