[SCSI] tgt: convert libsrp and ibmvstgt to use srp_transport
This converts libsrp and ibmvstgt to use srp transport. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Acked-by: Brian King <brking@us.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Bu işleme şunda yer alıyor:

işlemeyi yapan:
James Bottomley

ebeveyn
62fe88261b
işleme
17b0bcfad7
@@ -25,6 +25,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_host.h>
|
||||
#include <scsi/scsi_transport_srp.h>
|
||||
#include <scsi/scsi_tgt.h>
|
||||
#include <scsi/libsrp.h>
|
||||
#include <asm/hvcall.h>
|
||||
@@ -68,9 +69,12 @@ struct vio_port {
|
||||
unsigned long liobn;
|
||||
unsigned long riobn;
|
||||
struct srp_target *target;
|
||||
|
||||
struct srp_rport *rport;
|
||||
};
|
||||
|
||||
static struct workqueue_struct *vtgtd;
|
||||
static struct scsi_transport_template *ibmvstgt_transport_template;
|
||||
|
||||
/*
|
||||
* These are fixed for the system and come from the Open Firmware device tree.
|
||||
@@ -188,6 +192,7 @@ static int send_rsp(struct iu_entry *iue, struct scsi_cmnd *sc,
|
||||
static void handle_cmd_queue(struct srp_target *target)
|
||||
{
|
||||
struct Scsi_Host *shost = target->shost;
|
||||
struct srp_rport *rport = target_to_port(target)->rport;
|
||||
struct iu_entry *iue;
|
||||
struct srp_cmd *cmd;
|
||||
unsigned long flags;
|
||||
@@ -200,7 +205,8 @@ retry:
|
||||
if (!test_and_set_bit(V_FLYING, &iue->flags)) {
|
||||
spin_unlock_irqrestore(&target->lock, flags);
|
||||
cmd = iue->sbuf->buf;
|
||||
err = srp_cmd_queue(shost, cmd, iue, 0);
|
||||
err = srp_cmd_queue(shost, cmd, iue,
|
||||
(unsigned long)rport, 0);
|
||||
if (err) {
|
||||
eprintk("cannot queue cmd %p %d\n", cmd, err);
|
||||
srp_iu_put(iue);
|
||||
@@ -359,6 +365,16 @@ static void process_login(struct iu_entry *iue)
|
||||
union viosrp_iu *iu = vio_iu(iue);
|
||||
struct srp_login_rsp *rsp = &iu->srp.login_rsp;
|
||||
uint64_t tag = iu->srp.rsp.tag;
|
||||
struct Scsi_Host *shost = iue->target->shost;
|
||||
struct srp_target *target = host_to_srp_target(shost);
|
||||
struct vio_port *vport = target_to_port(target);
|
||||
struct srp_rport_identifiers ids;
|
||||
|
||||
memset(&ids, 0, sizeof(ids));
|
||||
sprintf(ids.port_id, "%x", vport->dma_dev->unit_address);
|
||||
ids.roles = SRP_RPORT_ROLE_INITIATOR;
|
||||
if (!vport->rport)
|
||||
vport->rport = srp_rport_add(shost, &ids);
|
||||
|
||||
/* TODO handle case that requested size is wrong and
|
||||
* buffer format is wrong
|
||||
@@ -412,7 +428,9 @@ static int process_tsk_mgmt(struct iu_entry *iue)
|
||||
fn = 0;
|
||||
}
|
||||
if (fn)
|
||||
scsi_tgt_tsk_mgmt_request(iue->target->shost, fn,
|
||||
scsi_tgt_tsk_mgmt_request(iue->target->shost,
|
||||
(unsigned long)iue->target->shost,
|
||||
fn,
|
||||
iu->srp.tsk_mgmt.task_tag,
|
||||
(struct scsi_lun *) &iu->srp.tsk_mgmt.lun,
|
||||
iue);
|
||||
@@ -721,7 +739,8 @@ static int ibmvstgt_eh_abort_handler(struct scsi_cmnd *sc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ibmvstgt_tsk_mgmt_response(u64 mid, int result)
|
||||
static int ibmvstgt_tsk_mgmt_response(struct Scsi_Host *shost,
|
||||
u64 itn_id, u64 mid, int result)
|
||||
{
|
||||
struct iu_entry *iue = (struct iu_entry *) ((void *) mid);
|
||||
union viosrp_iu *iu = vio_iu(iue);
|
||||
@@ -747,6 +766,20 @@ static int ibmvstgt_tsk_mgmt_response(u64 mid, int result)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id,
|
||||
int result)
|
||||
{
|
||||
struct srp_target *target = host_to_srp_target(shost);
|
||||
struct vio_port *vport = target_to_port(target);
|
||||
|
||||
if (result) {
|
||||
eprintk("%p %d\n", shost, result);
|
||||
srp_rport_del(vport->rport);
|
||||
vport->rport = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t system_id_show(struct class_device *cdev, char *buf)
|
||||
{
|
||||
return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
|
||||
@@ -804,6 +837,7 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
|
||||
shost = scsi_host_alloc(&ibmvstgt_sht, sizeof(struct srp_target));
|
||||
if (!shost)
|
||||
goto free_vport;
|
||||
shost->transportt = ibmvstgt_transport_template;
|
||||
err = scsi_tgt_alloc_queue(shost);
|
||||
if (err)
|
||||
goto put_host;
|
||||
@@ -837,8 +871,8 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
|
||||
err = scsi_add_host(shost, target->dev);
|
||||
if (err)
|
||||
goto destroy_queue;
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
destroy_queue:
|
||||
crq_queue_destroy(target);
|
||||
free_srp_target:
|
||||
@@ -857,6 +891,7 @@ static int ibmvstgt_remove(struct vio_dev *dev)
|
||||
struct vio_port *vport = target->ldata;
|
||||
|
||||
crq_queue_destroy(target);
|
||||
srp_remove_host(shost);
|
||||
scsi_remove_host(shost);
|
||||
scsi_tgt_free_queue(shost);
|
||||
srp_target_free(target);
|
||||
@@ -909,15 +944,24 @@ static int get_system_info(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct srp_function_template ibmvstgt_transport_functions = {
|
||||
.it_nexus_response = ibmvstgt_it_nexus_response,
|
||||
};
|
||||
|
||||
static int ibmvstgt_init(void)
|
||||
{
|
||||
int err = -ENOMEM;
|
||||
|
||||
printk("IBM eServer i/pSeries Virtual SCSI Target Driver\n");
|
||||
|
||||
ibmvstgt_transport_template =
|
||||
srp_attach_transport(&ibmvstgt_transport_functions);
|
||||
if (!ibmvstgt_transport_template)
|
||||
return err;
|
||||
|
||||
vtgtd = create_workqueue("ibmvtgtd");
|
||||
if (!vtgtd)
|
||||
return err;
|
||||
goto release_transport;
|
||||
|
||||
err = get_system_info();
|
||||
if (err)
|
||||
@@ -928,9 +972,10 @@ static int ibmvstgt_init(void)
|
||||
goto destroy_wq;
|
||||
|
||||
return 0;
|
||||
|
||||
destroy_wq:
|
||||
destroy_workqueue(vtgtd);
|
||||
release_transport:
|
||||
srp_release_transport(ibmvstgt_transport_template);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -940,6 +985,7 @@ static void ibmvstgt_exit(void)
|
||||
|
||||
destroy_workqueue(vtgtd);
|
||||
vio_unregister_driver(&ibmvstgt_driver);
|
||||
srp_release_transport(ibmvstgt_transport_template);
|
||||
}
|
||||
|
||||
MODULE_DESCRIPTION("IBM Virtual SCSI Target");
|
||||
|
Yeni konuda referans
Bir kullanıcı engelle