Lines Matching refs:tgt
152 struct snic_tgt *tgt = container_of(work, struct snic_tgt, scan_work); in snic_scsi_scan_tgt() local
153 struct Scsi_Host *shost = dev_to_shost(&tgt->dev); in snic_scsi_scan_tgt()
156 SNIC_HOST_INFO(shost, "Scanning Target id 0x%x\n", tgt->id); in snic_scsi_scan_tgt()
157 scsi_scan_target(&tgt->dev, in snic_scsi_scan_tgt()
158 tgt->channel, in snic_scsi_scan_tgt()
159 tgt->scsi_tgt_id, in snic_scsi_scan_tgt()
164 tgt->flags &= ~SNIC_TGT_SCAN_PENDING; in snic_scsi_scan_tgt()
175 struct snic_tgt *tgt = NULL; in snic_tgt_lookup() local
178 tgt = list_entry(cur, struct snic_tgt, list); in snic_tgt_lookup()
179 if (tgt->id == le32_to_cpu(tgtid->tgt_id)) in snic_tgt_lookup()
180 return tgt; in snic_tgt_lookup()
181 tgt = NULL; in snic_tgt_lookup()
184 return tgt; in snic_tgt_lookup()
193 struct snic_tgt *tgt = dev_to_tgt(dev); in snic_tgt_dev_release() local
195 SNIC_HOST_INFO(snic_tgt_to_shost(tgt), in snic_tgt_dev_release()
197 tgt->id, in snic_tgt_dev_release()
200 SNIC_BUG_ON(!list_empty(&tgt->list)); in snic_tgt_dev_release()
201 kfree(tgt); in snic_tgt_dev_release()
210 struct snic_tgt *tgt = container_of(work, struct snic_tgt, del_work); in snic_tgt_del() local
211 struct Scsi_Host *shost = snic_tgt_to_shost(tgt); in snic_tgt_del()
213 if (tgt->flags & SNIC_TGT_SCAN_PENDING) in snic_tgt_del()
217 scsi_block_targets(shost, &tgt->dev); in snic_tgt_del()
220 snic_tgt_scsi_abort_io(tgt); in snic_tgt_del()
223 scsi_target_unblock(&tgt->dev, SDEV_TRANSPORT_OFFLINE); in snic_tgt_del()
226 scsi_remove_target(&tgt->dev); /* ?? */ in snic_tgt_del()
227 device_del(&tgt->dev); in snic_tgt_del()
228 put_device(&tgt->dev); in snic_tgt_del()
237 struct snic_tgt *tgt = NULL; in snic_tgt_create() local
241 tgt = snic_tgt_lookup(snic, tgtid); in snic_tgt_create()
242 if (tgt) { in snic_tgt_create()
244 return tgt; in snic_tgt_create()
247 tgt = kzalloc(sizeof(*tgt), GFP_KERNEL); in snic_tgt_create()
248 if (!tgt) { in snic_tgt_create()
252 return tgt; in snic_tgt_create()
255 INIT_LIST_HEAD(&tgt->list); in snic_tgt_create()
256 tgt->id = le32_to_cpu(tgtid->tgt_id); in snic_tgt_create()
257 tgt->channel = 0; in snic_tgt_create()
260 tgt->tdata.typ = le16_to_cpu(tgtid->tgt_type); in snic_tgt_create()
265 tgt->tdata.disc_id = 0; in snic_tgt_create()
266 tgt->state = SNIC_TGT_STAT_INIT; in snic_tgt_create()
267 device_initialize(&tgt->dev); in snic_tgt_create()
268 tgt->dev.parent = get_device(&snic->shost->shost_gendev); in snic_tgt_create()
269 tgt->dev.release = snic_tgt_dev_release; in snic_tgt_create()
270 INIT_WORK(&tgt->scan_work, snic_scsi_scan_tgt); in snic_tgt_create()
271 INIT_WORK(&tgt->del_work, snic_tgt_del); in snic_tgt_create()
272 switch (tgt->tdata.typ) { in snic_tgt_create()
274 dev_set_name(&tgt->dev, "snic_das_tgt:%d:%d-%d", in snic_tgt_create()
275 snic->shost->host_no, tgt->channel, tgt->id); in snic_tgt_create()
279 dev_set_name(&tgt->dev, "snic_san_tgt:%d:%d-%d", in snic_tgt_create()
280 snic->shost->host_no, tgt->channel, tgt->id); in snic_tgt_create()
285 dev_set_name(&tgt->dev, "snic_das_tgt:%d:%d-%d", in snic_tgt_create()
286 snic->shost->host_no, tgt->channel, tgt->id); in snic_tgt_create()
291 list_add_tail(&tgt->list, &snic->disc.tgt_list); in snic_tgt_create()
292 tgt->scsi_tgt_id = snic->disc.nxt_tgt_id++; in snic_tgt_create()
293 tgt->state = SNIC_TGT_STAT_ONLINE; in snic_tgt_create()
298 tgt->id, snic_tgt_type_to_str(tgt->tdata.typ)); in snic_tgt_create()
300 ret = device_add(&tgt->dev); in snic_tgt_create()
308 list_del(&tgt->list); in snic_tgt_create()
310 put_device(&tgt->dev); in snic_tgt_create()
311 tgt = NULL; in snic_tgt_create()
313 return tgt; in snic_tgt_create()
316 SNIC_HOST_INFO(snic->shost, "Scanning %s.\n", dev_name(&tgt->dev)); in snic_tgt_create()
318 scsi_queue_work(snic->shost, &tgt->scan_work); in snic_tgt_create()
320 return tgt; in snic_tgt_create()
329 struct snic_tgt *tgt = NULL; in snic_handle_tgt_disc() local
363 tgt = snic_tgt_create(snic, &tgtid[i]); in snic_handle_tgt_disc()
364 if (!tgt) { in snic_handle_tgt_disc()
533 struct snic_tgt *tgt = NULL; in snic_tgt_del_all() local
543 tgt = list_entry(cur, struct snic_tgt, list); in snic_tgt_del_all()
544 tgt->state = SNIC_TGT_STAT_DEL; in snic_tgt_del_all()
545 list_del_init(&tgt->list); in snic_tgt_del_all()
546 SNIC_HOST_INFO(snic->shost, "Tgt %d q'ing for del\n", tgt->id); in snic_tgt_del_all()
547 queue_work(snic_glob->event_q, &tgt->del_work); in snic_tgt_del_all()
548 tgt = NULL; in snic_tgt_del_all()