568
568
scmnd->sc_data_direction);
571
static void srp_remove_req(struct srp_target_port *target,
572
struct srp_request *req, s32 req_lim_delta)
576
srp_unmap_data(req->scmnd, target, req);
572
* srp_claim_req - Take ownership of the scmnd associated with a request.
573
* @target: SRP target port.
575
* @scmnd: If NULL, take ownership of @req->scmnd. If not NULL, only take
576
* ownership of @req->scmnd if it equals @scmnd.
579
* Either NULL or a pointer to the SCSI command the caller became owner of.
581
static struct scsi_cmnd *srp_claim_req(struct srp_target_port *target,
582
struct srp_request *req,
583
struct scsi_cmnd *scmnd)
587
spin_lock_irqsave(&target->lock, flags);
591
} else if (req->scmnd == scmnd) {
596
spin_unlock_irqrestore(&target->lock, flags);
602
* srp_free_req() - Unmap data and add request to the free request list.
604
static void srp_free_req(struct srp_target_port *target,
605
struct srp_request *req, struct scsi_cmnd *scmnd,
610
srp_unmap_data(scmnd, target, req);
577
612
spin_lock_irqsave(&target->lock, flags);
578
613
target->req_lim += req_lim_delta;
580
614
list_add_tail(&req->list, &target->free_reqs);
581
615
spin_unlock_irqrestore(&target->lock, flags);
584
618
static void srp_reset_req(struct srp_target_port *target, struct srp_request *req)
586
req->scmnd->result = DID_RESET << 16;
587
req->scmnd->scsi_done(req->scmnd);
588
srp_remove_req(target, req, 0);
620
struct scsi_cmnd *scmnd = srp_claim_req(target, req, NULL);
623
scmnd->result = DID_RESET << 16;
624
scmnd->scsi_done(scmnd);
625
srp_free_req(target, req, scmnd, 0);
591
629
static int srp_reconnect_target(struct srp_target_port *target)
1055
1093
complete(&target->tsk_mgmt_done);
1057
1095
req = &target->req_ring[rsp->tag];
1096
scmnd = srp_claim_req(target, req, NULL);
1060
1098
shost_printk(KERN_ERR, target->scsi_host,
1061
1099
"Null scmnd for RSP w/tag %016llx\n",
1062
1100
(unsigned long long) rsp->tag);
1102
spin_lock_irqsave(&target->lock, flags);
1103
target->req_lim += be32_to_cpu(rsp->req_lim_delta);
1104
spin_unlock_irqrestore(&target->lock, flags);
1063
1108
scmnd->result = rsp->status;
1065
1110
if (rsp->flags & SRP_RSP_FLAG_SNSVALID) {
1074
1119
else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER))
1075
1120
scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt));
1077
srp_remove_req(target, req, be32_to_cpu(rsp->req_lim_delta));
1122
srp_free_req(target, req, scmnd,
1123
be32_to_cpu(rsp->req_lim_delta));
1078
1125
scmnd->host_scribble = NULL;
1079
1126
scmnd->scsi_done(scmnd);
1614
1661
struct srp_target_port *target = host_to_target(scmnd->device->host);
1615
1662
struct srp_request *req = (struct srp_request *) scmnd->host_scribble;
1618
1664
shost_printk(KERN_ERR, target->scsi_host, "SRP abort called\n");
1620
if (!req || target->qp_in_error)
1622
if (srp_send_tsk_mgmt(target, req->index, scmnd->device->lun,
1623
SRP_TSK_ABORT_TASK))
1627
if (!target->tsk_mgmt_status) {
1628
srp_remove_req(target, req, 0);
1629
scmnd->result = DID_ABORT << 16;
1666
if (!req || target->qp_in_error || !srp_claim_req(target, req, scmnd))
1668
srp_send_tsk_mgmt(target, req->index, scmnd->device->lun,
1669
SRP_TSK_ABORT_TASK);
1670
srp_free_req(target, req, scmnd, 0);
1671
scmnd->result = DID_ABORT << 16;
1637
1676
static int srp_reset_device(struct scsi_cmnd *scmnd)