|
@@ -47,6 +47,7 @@ const char *fnic_state_str[] = {
|
|
};
|
|
};
|
|
|
|
|
|
static const char *fnic_ioreq_state_str[] = {
|
|
static const char *fnic_ioreq_state_str[] = {
|
|
|
|
+ [FNIC_IOREQ_NOT_INITED] = "FNIC_IOREQ_NOT_INITED",
|
|
[FNIC_IOREQ_CMD_PENDING] = "FNIC_IOREQ_CMD_PENDING",
|
|
[FNIC_IOREQ_CMD_PENDING] = "FNIC_IOREQ_CMD_PENDING",
|
|
[FNIC_IOREQ_ABTS_PENDING] = "FNIC_IOREQ_ABTS_PENDING",
|
|
[FNIC_IOREQ_ABTS_PENDING] = "FNIC_IOREQ_ABTS_PENDING",
|
|
[FNIC_IOREQ_ABTS_COMPLETE] = "FNIC_IOREQ_ABTS_COMPLETE",
|
|
[FNIC_IOREQ_ABTS_COMPLETE] = "FNIC_IOREQ_ABTS_COMPLETE",
|
|
@@ -165,6 +166,33 @@ static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * __fnic_set_state_flags
|
|
|
|
+ * Sets/Clears bits in fnic's state_flags
|
|
|
|
+ **/
|
|
|
|
+void
|
|
|
|
+__fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
|
|
|
|
+ unsigned long clearbits)
|
|
|
|
+{
|
|
|
|
+ struct Scsi_Host *host = fnic->lport->host;
|
|
|
|
+ int sh_locked = spin_is_locked(host->host_lock);
|
|
|
|
+ unsigned long flags = 0;
|
|
|
|
+
|
|
|
|
+ if (!sh_locked)
|
|
|
|
+ spin_lock_irqsave(host->host_lock, flags);
|
|
|
|
+
|
|
|
|
+ if (clearbits)
|
|
|
|
+ fnic->state_flags &= ~st_flags;
|
|
|
|
+ else
|
|
|
|
+ fnic->state_flags |= st_flags;
|
|
|
|
+
|
|
|
|
+ if (!sh_locked)
|
|
|
|
+ spin_unlock_irqrestore(host->host_lock, flags);
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* fnic_fw_reset_handler
|
|
* fnic_fw_reset_handler
|
|
* Routine to send reset msg to fw
|
|
* Routine to send reset msg to fw
|
|
@@ -175,9 +203,16 @@ int fnic_fw_reset_handler(struct fnic *fnic)
|
|
int ret = 0;
|
|
int ret = 0;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
+ /* indicate fwreset to io path */
|
|
|
|
+ fnic_set_state_flags(fnic, FNIC_FLAGS_FWRESET);
|
|
|
|
+
|
|
skb_queue_purge(&fnic->frame_queue);
|
|
skb_queue_purge(&fnic->frame_queue);
|
|
skb_queue_purge(&fnic->tx_queue);
|
|
skb_queue_purge(&fnic->tx_queue);
|
|
|
|
|
|
|
|
+ /* wait for io cmpl */
|
|
|
|
+ while (atomic_read(&fnic->in_flight))
|
|
|
|
+ schedule_timeout(msecs_to_jiffies(1));
|
|
|
|
+
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
|
|
|
|
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
@@ -193,9 +228,12 @@ int fnic_fw_reset_handler(struct fnic *fnic)
|
|
if (!ret)
|
|
if (!ret)
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"Issued fw reset\n");
|
|
"Issued fw reset\n");
|
|
- else
|
|
|
|
|
|
+ else {
|
|
|
|
+ fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET);
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"Failed to issue fw reset\n");
|
|
"Failed to issue fw reset\n");
|
|
|
|
+ }
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -312,6 +350,8 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
|
|
|
|
|
|
if (unlikely(!vnic_wq_copy_desc_avail(wq))) {
|
|
if (unlikely(!vnic_wq_copy_desc_avail(wq))) {
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "fnic_queue_wq_copy_desc failure - no descriptors\n");
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -351,16 +391,20 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
|
|
*/
|
|
*/
|
|
static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
|
|
static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
|
|
{
|
|
{
|
|
- struct fc_lport *lp;
|
|
|
|
|
|
+ struct fc_lport *lp = shost_priv(sc->device->host);
|
|
struct fc_rport *rport;
|
|
struct fc_rport *rport;
|
|
- struct fnic_io_req *io_req;
|
|
|
|
- struct fnic *fnic;
|
|
|
|
|
|
+ struct fnic_io_req *io_req = NULL;
|
|
|
|
+ struct fnic *fnic = lport_priv(lp);
|
|
struct vnic_wq_copy *wq;
|
|
struct vnic_wq_copy *wq;
|
|
int ret;
|
|
int ret;
|
|
- int sg_count;
|
|
|
|
|
|
+ u64 cmd_trace;
|
|
|
|
+ int sg_count = 0;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
unsigned long ptr;
|
|
unsigned long ptr;
|
|
|
|
|
|
|
|
+ if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
|
|
|
|
+ return SCSI_MLQUEUE_HOST_BUSY;
|
|
|
|
+
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
ret = fc_remote_port_chkready(rport);
|
|
ret = fc_remote_port_chkready(rport);
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -369,20 +413,21 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
- lp = shost_priv(sc->device->host);
|
|
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up))
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up))
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
|
|
|
|
|
|
+ atomic_inc(&fnic->in_flight);
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Release host lock, use driver resource specific locks from here.
|
|
* Release host lock, use driver resource specific locks from here.
|
|
* Don't re-enable interrupts in case they were disabled prior to the
|
|
* Don't re-enable interrupts in case they were disabled prior to the
|
|
* caller disabling them.
|
|
* caller disabling them.
|
|
*/
|
|
*/
|
|
spin_unlock(lp->host->host_lock);
|
|
spin_unlock(lp->host->host_lock);
|
|
|
|
+ CMD_STATE(sc) = FNIC_IOREQ_NOT_INITED;
|
|
|
|
+ CMD_FLAGS(sc) = FNIC_NO_FLAGS;
|
|
|
|
|
|
/* Get a new io_req for this SCSI IO */
|
|
/* Get a new io_req for this SCSI IO */
|
|
- fnic = lport_priv(lp);
|
|
|
|
-
|
|
|
|
io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
|
|
io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
ret = SCSI_MLQUEUE_HOST_BUSY;
|
|
ret = SCSI_MLQUEUE_HOST_BUSY;
|
|
@@ -393,6 +438,9 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
|
|
/* Map the data buffer */
|
|
/* Map the data buffer */
|
|
sg_count = scsi_dma_map(sc);
|
|
sg_count = scsi_dma_map(sc);
|
|
if (sg_count < 0) {
|
|
if (sg_count < 0) {
|
|
|
|
+ FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
|
|
|
|
+ sc->request->tag, sc, 0, sc->cmnd[0],
|
|
|
|
+ sg_count, CMD_STATE(sc));
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
@@ -427,8 +475,10 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
|
|
|
|
|
|
/* initialize rest of io_req */
|
|
/* initialize rest of io_req */
|
|
io_req->port_id = rport->port_id;
|
|
io_req->port_id = rport->port_id;
|
|
|
|
+ io_req->start_time = jiffies;
|
|
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
|
|
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
|
|
CMD_SP(sc) = (char *)io_req;
|
|
CMD_SP(sc) = (char *)io_req;
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED;
|
|
sc->scsi_done = done;
|
|
sc->scsi_done = done;
|
|
|
|
|
|
/* create copy wq desc and enqueue it */
|
|
/* create copy wq desc and enqueue it */
|
|
@@ -440,7 +490,9 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
|
|
* refetch the pointer under the lock.
|
|
* refetch the pointer under the lock.
|
|
*/
|
|
*/
|
|
spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc);
|
|
spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc);
|
|
-
|
|
|
|
|
|
+ FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
|
|
|
|
+ sc->request->tag, sc, 0, 0, 0,
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
CMD_SP(sc) = NULL;
|
|
CMD_SP(sc) = NULL;
|
|
@@ -450,8 +502,21 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ /* REVISIT: Use per IO lock in the final code */
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ISSUED;
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
|
|
+ cmd_trace = ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 |
|
|
|
|
+ (u64)sc->cmnd[8] << 32 | (u64)sc->cmnd[2] << 24 |
|
|
|
|
+ (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 |
|
|
|
|
+ sc->cmnd[5]);
|
|
|
|
+
|
|
|
|
+ FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
|
|
|
|
+ sc->request->tag, sc, io_req,
|
|
|
|
+ sg_count, cmd_trace,
|
|
|
|
+ (((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc)));
|
|
|
|
+ atomic_dec(&fnic->in_flight);
|
|
/* acquire host lock before returning to SCSI */
|
|
/* acquire host lock before returning to SCSI */
|
|
spin_lock(lp->host->host_lock);
|
|
spin_lock(lp->host->host_lock);
|
|
return ret;
|
|
return ret;
|
|
@@ -529,6 +594,8 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,
|
|
fnic_flush_tx(fnic);
|
|
fnic_flush_tx(fnic);
|
|
|
|
|
|
reset_cmpl_handler_end:
|
|
reset_cmpl_handler_end:
|
|
|
|
+ fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET);
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -622,6 +689,7 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic,
|
|
struct vnic_wq_copy *wq;
|
|
struct vnic_wq_copy *wq;
|
|
u16 request_out = desc->u.ack.request_out;
|
|
u16 request_out = desc->u.ack.request_out;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
+ u64 *ox_id_tag = (u64 *)(void *)desc;
|
|
|
|
|
|
/* mark the ack state */
|
|
/* mark the ack state */
|
|
wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count];
|
|
wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count];
|
|
@@ -632,6 +700,9 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic,
|
|
fnic->fw_ack_recd[0] = 1;
|
|
fnic->fw_ack_recd[0] = 1;
|
|
}
|
|
}
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_ack_handler,
|
|
|
|
+ fnic->lport->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3],
|
|
|
|
+ ox_id_tag[4], ox_id_tag[5]);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -651,27 +722,53 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
|
|
struct scsi_cmnd *sc;
|
|
struct scsi_cmnd *sc;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
|
|
+ u64 cmd_trace;
|
|
|
|
+ unsigned long start_time;
|
|
|
|
|
|
/* Decode the cmpl description to get the io_req id */
|
|
/* Decode the cmpl description to get the io_req id */
|
|
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
|
|
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
|
|
fcpio_tag_id_dec(&tag, &id);
|
|
fcpio_tag_id_dec(&tag, &id);
|
|
|
|
+ icmnd_cmpl = &desc->u.icmnd_cmpl;
|
|
|
|
|
|
- if (id >= FNIC_MAX_IO_REQ)
|
|
|
|
|
|
+ if (id >= FNIC_MAX_IO_REQ) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "Tag out of range tag %x hdr status = %s\n",
|
|
|
|
+ id, fnic_fcpio_status_to_str(hdr_status));
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
sc = scsi_host_find_tag(fnic->lport->host, id);
|
|
sc = scsi_host_find_tag(fnic->lport->host, id);
|
|
WARN_ON_ONCE(!sc);
|
|
WARN_ON_ONCE(!sc);
|
|
- if (!sc)
|
|
|
|
|
|
+ if (!sc) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "icmnd_cmpl sc is null - "
|
|
|
|
+ "hdr status = %s tag = 0x%x desc = 0x%p\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status), id, desc);
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_icmnd_cmpl_handler,
|
|
|
|
+ fnic->lport->host->host_no, id,
|
|
|
|
+ ((u64)icmnd_cmpl->_resvd0[1] << 16 |
|
|
|
|
+ (u64)icmnd_cmpl->_resvd0[0]),
|
|
|
|
+ ((u64)hdr_status << 16 |
|
|
|
|
+ (u64)icmnd_cmpl->scsi_status << 8 |
|
|
|
|
+ (u64)icmnd_cmpl->flags), desc,
|
|
|
|
+ (u64)icmnd_cmpl->residual, 0);
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
WARN_ON_ONCE(!io_req);
|
|
WARN_ON_ONCE(!io_req);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_REQ_NULL;
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "icmnd_cmpl io_req is null - "
|
|
|
|
+ "hdr status = %s tag = 0x%x sc 0x%p\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status), id, sc);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ start_time = io_req->start_time;
|
|
|
|
|
|
/* firmware completed the io */
|
|
/* firmware completed the io */
|
|
io_req->io_completed = 1;
|
|
io_req->io_completed = 1;
|
|
@@ -682,6 +779,28 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
|
|
*/
|
|
*/
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABTS_PENDING;
|
|
|
|
+ switch (hdr_status) {
|
|
|
|
+ case FCPIO_SUCCESS:
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_DONE;
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "icmnd_cmpl ABTS pending hdr status = %s "
|
|
|
|
+ "sc 0x%p scsi_status %x residual %d\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status), sc,
|
|
|
|
+ icmnd_cmpl->scsi_status,
|
|
|
|
+ icmnd_cmpl->residual);
|
|
|
|
+ break;
|
|
|
|
+ case FCPIO_ABORTED:
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABORTED;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "icmnd_cmpl abts pending "
|
|
|
|
+ "hdr status = %s tag = 0x%x sc = 0x%p\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status),
|
|
|
|
+ id, sc);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -765,6 +884,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
|
|
|
|
|
|
/* Break link with the SCSI command */
|
|
/* Break link with the SCSI command */
|
|
CMD_SP(sc) = NULL;
|
|
CMD_SP(sc) = NULL;
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_DONE;
|
|
|
|
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
@@ -772,6 +892,20 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
|
|
|
|
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
|
|
|
|
|
|
+ cmd_trace = ((u64)hdr_status << 56) |
|
|
|
|
+ (u64)icmnd_cmpl->scsi_status << 48 |
|
|
|
|
+ (u64)icmnd_cmpl->flags << 40 | (u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5];
|
|
|
|
+
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_icmnd_cmpl_handler,
|
|
|
|
+ sc->device->host->host_no, id, sc,
|
|
|
|
+ ((u64)icmnd_cmpl->_resvd0[1] << 56 |
|
|
|
|
+ (u64)icmnd_cmpl->_resvd0[0] << 48 |
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time)),
|
|
|
|
+ desc, cmd_trace,
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+
|
|
if (sc->sc_data_direction == DMA_FROM_DEVICE) {
|
|
if (sc->sc_data_direction == DMA_FROM_DEVICE) {
|
|
fnic->lport->host_stats.fcp_input_requests++;
|
|
fnic->lport->host_stats.fcp_input_requests++;
|
|
fnic->fcp_input_bytes += xfer_len;
|
|
fnic->fcp_input_bytes += xfer_len;
|
|
@@ -784,7 +918,6 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
|
|
/* Call SCSI completion function to complete the IO */
|
|
/* Call SCSI completion function to complete the IO */
|
|
if (sc->scsi_done)
|
|
if (sc->scsi_done)
|
|
sc->scsi_done(sc);
|
|
sc->scsi_done(sc);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/* fnic_fcpio_itmf_cmpl_handler
|
|
/* fnic_fcpio_itmf_cmpl_handler
|
|
@@ -801,28 +934,54 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
|
|
struct fnic_io_req *io_req;
|
|
struct fnic_io_req *io_req;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
|
|
+ unsigned long start_time;
|
|
|
|
|
|
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
|
|
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
|
|
fcpio_tag_id_dec(&tag, &id);
|
|
fcpio_tag_id_dec(&tag, &id);
|
|
|
|
|
|
- if ((id & FNIC_TAG_MASK) >= FNIC_MAX_IO_REQ)
|
|
|
|
|
|
+ if ((id & FNIC_TAG_MASK) >= FNIC_MAX_IO_REQ) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "Tag out of range tag %x hdr status = %s\n",
|
|
|
|
+ id, fnic_fcpio_status_to_str(hdr_status));
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK);
|
|
sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK);
|
|
WARN_ON_ONCE(!sc);
|
|
WARN_ON_ONCE(!sc);
|
|
- if (!sc)
|
|
|
|
|
|
+ if (!sc) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status), id);
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ }
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
WARN_ON_ONCE(!io_req);
|
|
WARN_ON_ONCE(!io_req);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "itmf_cmpl io_req is null - "
|
|
|
|
+ "hdr status = %s tag = 0x%x sc 0x%p\n",
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status), id, sc);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ start_time = io_req->start_time;
|
|
|
|
|
|
- if (id & FNIC_TAG_ABORT) {
|
|
|
|
|
|
+ if ((id & FNIC_TAG_ABORT) && (id & FNIC_TAG_DEV_RST)) {
|
|
|
|
+ /* Abort and terminate completion of device reset req */
|
|
|
|
+ /* REVISIT : Add asserts about various flags */
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "dev reset abts cmpl recd. id %x status %s\n",
|
|
|
|
+ id, fnic_fcpio_status_to_str(hdr_status));
|
|
|
|
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
|
|
|
|
+ CMD_ABTS_STATUS(sc) = hdr_status;
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
|
|
|
|
+ if (io_req->abts_done)
|
|
|
|
+ complete(io_req->abts_done);
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ } else if (id & FNIC_TAG_ABORT) {
|
|
/* Completion of abort cmd */
|
|
/* Completion of abort cmd */
|
|
if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) {
|
|
if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) {
|
|
/* This is a late completion. Ignore it */
|
|
/* This is a late completion. Ignore it */
|
|
@@ -832,6 +991,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
|
|
CMD_ABTS_STATUS(sc) = hdr_status;
|
|
CMD_ABTS_STATUS(sc) = hdr_status;
|
|
|
|
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"abts cmpl recd. id %d status %s\n",
|
|
"abts cmpl recd. id %d status %s\n",
|
|
(int)(id & FNIC_TAG_MASK),
|
|
(int)(id & FNIC_TAG_MASK),
|
|
@@ -855,14 +1015,58 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
|
|
|
|
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
- if (sc->scsi_done)
|
|
|
|
|
|
+ if (sc->scsi_done) {
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
|
|
|
|
+ sc->device->host->host_no, id,
|
|
|
|
+ sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ desc,
|
|
|
|
+ (((u64)hdr_status << 40) |
|
|
|
|
+ (u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 |
|
|
|
|
+ (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) |
|
|
|
|
+ CMD_STATE(sc)));
|
|
sc->scsi_done(sc);
|
|
sc->scsi_done(sc);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
} else if (id & FNIC_TAG_DEV_RST) {
|
|
} else if (id & FNIC_TAG_DEV_RST) {
|
|
/* Completion of device reset */
|
|
/* Completion of device reset */
|
|
CMD_LR_STATUS(sc) = hdr_status;
|
|
CMD_LR_STATUS(sc) = hdr_status;
|
|
|
|
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING;
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
|
|
|
|
+ sc->device->host->host_no, id, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ desc, 0,
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "Terminate pending "
|
|
|
|
+ "dev reset cmpl recd. id %d status %s\n",
|
|
|
|
+ (int)(id & FNIC_TAG_MASK),
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEV_RST_TIMED_OUT) {
|
|
|
|
+ /* Need to wait for terminate completion */
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
|
|
|
|
+ sc->device->host->host_no, id, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ desc, 0,
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "dev reset cmpl recd after time out. "
|
|
|
|
+ "id %d status %s\n",
|
|
|
|
+ (int)(id & FNIC_TAG_MASK),
|
|
|
|
+ fnic_fcpio_status_to_str(hdr_status));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
|
|
CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"dev reset cmpl recd. id %d status %s\n",
|
|
"dev reset cmpl recd. id %d status %s\n",
|
|
(int)(id & FNIC_TAG_MASK),
|
|
(int)(id & FNIC_TAG_MASK),
|
|
@@ -889,7 +1093,6 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
|
|
struct fcpio_fw_req *desc)
|
|
struct fcpio_fw_req *desc)
|
|
{
|
|
{
|
|
struct fnic *fnic = vnic_dev_priv(vdev);
|
|
struct fnic *fnic = vnic_dev_priv(vdev);
|
|
- int ret = 0;
|
|
|
|
|
|
|
|
switch (desc->hdr.type) {
|
|
switch (desc->hdr.type) {
|
|
case FCPIO_ACK: /* fw copied copy wq desc to its queue */
|
|
case FCPIO_ACK: /* fw copied copy wq desc to its queue */
|
|
@@ -906,11 +1109,11 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
|
|
|
|
|
|
case FCPIO_FLOGI_REG_CMPL: /* fw completed flogi_reg */
|
|
case FCPIO_FLOGI_REG_CMPL: /* fw completed flogi_reg */
|
|
case FCPIO_FLOGI_FIP_REG_CMPL: /* fw completed flogi_fip_reg */
|
|
case FCPIO_FLOGI_FIP_REG_CMPL: /* fw completed flogi_fip_reg */
|
|
- ret = fnic_fcpio_flogi_reg_cmpl_handler(fnic, desc);
|
|
|
|
|
|
+ fnic_fcpio_flogi_reg_cmpl_handler(fnic, desc);
|
|
break;
|
|
break;
|
|
|
|
|
|
case FCPIO_RESET_CMPL: /* fw completed reset */
|
|
case FCPIO_RESET_CMPL: /* fw completed reset */
|
|
- ret = fnic_fcpio_fw_reset_cmpl_handler(fnic, desc);
|
|
|
|
|
|
+ fnic_fcpio_fw_reset_cmpl_handler(fnic, desc);
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -920,7 +1123,7 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- return ret;
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -950,6 +1153,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
|
|
unsigned long flags = 0;
|
|
unsigned long flags = 0;
|
|
struct scsi_cmnd *sc;
|
|
struct scsi_cmnd *sc;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
|
|
+ unsigned long start_time = 0;
|
|
|
|
|
|
for (i = 0; i < FNIC_MAX_IO_REQ; i++) {
|
|
for (i = 0; i < FNIC_MAX_IO_REQ; i++) {
|
|
if (i == exclude_id)
|
|
if (i == exclude_id)
|
|
@@ -962,6 +1166,23 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
|
|
+ if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
|
|
|
|
+ !(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) {
|
|
|
|
+ /*
|
|
|
|
+ * We will be here only when FW completes reset
|
|
|
|
+ * without sending completions for outstanding ios.
|
|
|
|
+ */
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
|
|
|
|
+ if (io_req && io_req->dr_done)
|
|
|
|
+ complete(io_req->dr_done);
|
|
|
|
+ else if (io_req && io_req->abts_done)
|
|
|
|
+ complete(io_req->abts_done);
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ } else if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
goto cleanup_scsi_cmd;
|
|
goto cleanup_scsi_cmd;
|
|
@@ -975,6 +1196,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
|
|
* If there is a scsi_cmnd associated with this io_req, then
|
|
* If there is a scsi_cmnd associated with this io_req, then
|
|
* free the corresponding state
|
|
* free the corresponding state
|
|
*/
|
|
*/
|
|
|
|
+ start_time = io_req->start_time;
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
|
|
|
|
@@ -984,8 +1206,18 @@ cleanup_scsi_cmd:
|
|
" DID_TRANSPORT_DISRUPTED\n");
|
|
" DID_TRANSPORT_DISRUPTED\n");
|
|
|
|
|
|
/* Complete the command to SCSI */
|
|
/* Complete the command to SCSI */
|
|
- if (sc->scsi_done)
|
|
|
|
|
|
+ if (sc->scsi_done) {
|
|
|
|
+ FNIC_TRACE(fnic_cleanup_io,
|
|
|
|
+ sc->device->host->host_no, i, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ 0, ((u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 |
|
|
|
|
+ (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+
|
|
sc->scsi_done(sc);
|
|
sc->scsi_done(sc);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -998,6 +1230,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
|
|
struct scsi_cmnd *sc;
|
|
struct scsi_cmnd *sc;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
|
|
+ unsigned long start_time = 0;
|
|
|
|
|
|
/* get the tag reference */
|
|
/* get the tag reference */
|
|
fcpio_tag_id_dec(&desc->hdr.tag, &id);
|
|
fcpio_tag_id_dec(&desc->hdr.tag, &id);
|
|
@@ -1027,6 +1260,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
|
|
|
|
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
|
|
+ start_time = io_req->start_time;
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
|
|
|
|
@@ -1035,8 +1269,17 @@ wq_copy_cleanup_scsi_cmd:
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
|
|
" DID_NO_CONNECT\n");
|
|
" DID_NO_CONNECT\n");
|
|
|
|
|
|
- if (sc->scsi_done)
|
|
|
|
|
|
+ if (sc->scsi_done) {
|
|
|
|
+ FNIC_TRACE(fnic_wq_copy_cleanup_handler,
|
|
|
|
+ sc->device->host->host_no, id, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ 0, ((u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+
|
|
sc->scsi_done(sc);
|
|
sc->scsi_done(sc);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
|
|
static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
|
|
@@ -1044,8 +1287,18 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
|
|
struct fnic_io_req *io_req)
|
|
struct fnic_io_req *io_req)
|
|
{
|
|
{
|
|
struct vnic_wq_copy *wq = &fnic->wq_copy[0];
|
|
struct vnic_wq_copy *wq = &fnic->wq_copy[0];
|
|
|
|
+ struct Scsi_Host *host = fnic->lport->host;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
+ spin_lock_irqsave(host->host_lock, flags);
|
|
|
|
+ if (unlikely(fnic_chk_state_flags_locked(fnic,
|
|
|
|
+ FNIC_FLAGS_IO_BLOCKED))) {
|
|
|
|
+ spin_unlock_irqrestore(host->host_lock, flags);
|
|
|
|
+ return 1;
|
|
|
|
+ } else
|
|
|
|
+ atomic_inc(&fnic->in_flight);
|
|
|
|
+ spin_unlock_irqrestore(host->host_lock, flags);
|
|
|
|
+
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
|
|
|
|
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
@@ -1053,6 +1306,9 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
|
|
|
|
|
|
if (!vnic_wq_copy_desc_avail(wq)) {
|
|
if (!vnic_wq_copy_desc_avail(wq)) {
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
|
|
+ atomic_dec(&fnic->in_flight);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "fnic_queue_abort_io_req: failure: no descriptors\n");
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
fnic_queue_wq_copy_desc_itmf(wq, tag | FNIC_TAG_ABORT,
|
|
fnic_queue_wq_copy_desc_itmf(wq, tag | FNIC_TAG_ABORT,
|
|
@@ -1060,12 +1316,15 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
|
|
fnic->config.ra_tov, fnic->config.ed_tov);
|
|
fnic->config.ra_tov, fnic->config.ed_tov);
|
|
|
|
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
|
|
|
|
+ atomic_dec(&fnic->in_flight);
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
|
|
|
|
+static void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
{
|
|
{
|
|
int tag;
|
|
int tag;
|
|
|
|
+ int abt_tag;
|
|
struct fnic_io_req *io_req;
|
|
struct fnic_io_req *io_req;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
@@ -1075,13 +1334,14 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
|
|
|
|
FNIC_SCSI_DBG(KERN_DEBUG,
|
|
FNIC_SCSI_DBG(KERN_DEBUG,
|
|
fnic->lport->host,
|
|
fnic->lport->host,
|
|
- "fnic_rport_reset_exch called portid 0x%06x\n",
|
|
|
|
|
|
+ "fnic_rport_exch_reset called portid 0x%06x\n",
|
|
port_id);
|
|
port_id);
|
|
|
|
|
|
if (fnic->in_remove)
|
|
if (fnic->in_remove)
|
|
return;
|
|
return;
|
|
|
|
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
|
|
+ abt_tag = tag;
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
if (!sc)
|
|
if (!sc)
|
|
continue;
|
|
continue;
|
|
@@ -1096,6 +1356,15 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
|
|
|
|
+ (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) {
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "fnic_rport_exch_reset dev rst not pending sc 0x%p\n",
|
|
|
|
+ sc);
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Found IO that is still pending with firmware and
|
|
* Found IO that is still pending with firmware and
|
|
* belongs to rport that went away
|
|
* belongs to rport that went away
|
|
@@ -1104,9 +1373,29 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ if (io_req->abts_done) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "fnic_rport_exch_reset: io_req->abts_done is set "
|
|
|
|
+ "state is %s\n",
|
|
|
|
+ fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "rport_exch_reset "
|
|
|
|
+ "IO not yet issued %p tag 0x%x flags "
|
|
|
|
+ "%x state %d\n",
|
|
|
|
+ sc, tag, CMD_FLAGS(sc), CMD_STATE(sc));
|
|
|
|
+ }
|
|
old_ioreq_state = CMD_STATE(sc);
|
|
old_ioreq_state = CMD_STATE(sc);
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
|
|
|
|
+ abt_tag = (tag | FNIC_TAG_DEV_RST);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "fnic_rport_exch_reset dev rst sc 0x%p\n",
|
|
|
|
+ sc);
|
|
|
|
+ }
|
|
|
|
|
|
BUG_ON(io_req->abts_done);
|
|
BUG_ON(io_req->abts_done);
|
|
|
|
|
|
@@ -1118,7 +1407,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
/* Now queue the abort command to firmware */
|
|
/* Now queue the abort command to firmware */
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
|
|
|
|
- if (fnic_queue_abort_io_req(fnic, tag,
|
|
|
|
|
|
+ if (fnic_queue_abort_io_req(fnic, abt_tag,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
fc_lun.scsi_lun, io_req)) {
|
|
fc_lun.scsi_lun, io_req)) {
|
|
/*
|
|
/*
|
|
@@ -1127,12 +1416,17 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
* aborted later by scsi_eh, or cleaned up during
|
|
* aborted later by scsi_eh, or cleaned up during
|
|
* lun reset
|
|
* lun reset
|
|
*/
|
|
*/
|
|
- io_lock = fnic_io_lock_hash(fnic, sc);
|
|
|
|
-
|
|
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
|
|
CMD_STATE(sc) = old_ioreq_state;
|
|
CMD_STATE(sc) = old_ioreq_state;
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ } else {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET)
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
|
|
|
|
+ else
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1141,6 +1435,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
|
|
void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
{
|
|
{
|
|
int tag;
|
|
int tag;
|
|
|
|
+ int abt_tag;
|
|
struct fnic_io_req *io_req;
|
|
struct fnic_io_req *io_req;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
@@ -1154,14 +1449,15 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
|
|
|
|
FNIC_SCSI_DBG(KERN_DEBUG,
|
|
FNIC_SCSI_DBG(KERN_DEBUG,
|
|
fnic->lport->host, "fnic_terminate_rport_io called"
|
|
fnic->lport->host, "fnic_terminate_rport_io called"
|
|
- " wwpn 0x%llx, wwnn0x%llx, portid 0x%06x\n",
|
|
|
|
- rport->port_name, rport->node_name,
|
|
|
|
|
|
+ " wwpn 0x%llx, wwnn0x%llx, rport 0x%p, portid 0x%06x\n",
|
|
|
|
+ rport->port_name, rport->node_name, rport,
|
|
rport->port_id);
|
|
rport->port_id);
|
|
|
|
|
|
if (fnic->in_remove)
|
|
if (fnic->in_remove)
|
|
return;
|
|
return;
|
|
|
|
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
|
|
+ abt_tag = tag;
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
if (!sc)
|
|
if (!sc)
|
|
continue;
|
|
continue;
|
|
@@ -1180,6 +1476,14 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
|
|
|
|
+ (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) {
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "fnic_terminate_rport_io dev rst not pending sc 0x%p\n",
|
|
|
|
+ sc);
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
* Found IO that is still pending with firmware and
|
|
* Found IO that is still pending with firmware and
|
|
* belongs to rport that went away
|
|
* belongs to rport that went away
|
|
@@ -1188,9 +1492,27 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ if (io_req->abts_done) {
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "fnic_terminate_rport_io: io_req->abts_done is set "
|
|
|
|
+ "state is %s\n",
|
|
|
|
+ fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
|
|
+ }
|
|
|
|
+ if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) {
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "fnic_terminate_rport_io "
|
|
|
|
+ "IO not yet issued %p tag 0x%x flags "
|
|
|
|
+ "%x state %d\n",
|
|
|
|
+ sc, tag, CMD_FLAGS(sc), CMD_STATE(sc));
|
|
|
|
+ }
|
|
old_ioreq_state = CMD_STATE(sc);
|
|
old_ioreq_state = CMD_STATE(sc);
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
|
|
|
|
+ abt_tag = (tag | FNIC_TAG_DEV_RST);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "fnic_terminate_rport_io dev rst sc 0x%p\n", sc);
|
|
|
|
+ }
|
|
|
|
|
|
BUG_ON(io_req->abts_done);
|
|
BUG_ON(io_req->abts_done);
|
|
|
|
|
|
@@ -1203,7 +1525,7 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
/* Now queue the abort command to firmware */
|
|
/* Now queue the abort command to firmware */
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
|
|
|
|
- if (fnic_queue_abort_io_req(fnic, tag,
|
|
|
|
|
|
+ if (fnic_queue_abort_io_req(fnic, abt_tag,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
fc_lun.scsi_lun, io_req)) {
|
|
fc_lun.scsi_lun, io_req)) {
|
|
/*
|
|
/*
|
|
@@ -1212,12 +1534,17 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
|
|
* aborted later by scsi_eh, or cleaned up during
|
|
* aborted later by scsi_eh, or cleaned up during
|
|
* lun reset
|
|
* lun reset
|
|
*/
|
|
*/
|
|
- io_lock = fnic_io_lock_hash(fnic, sc);
|
|
|
|
-
|
|
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
|
|
CMD_STATE(sc) = old_ioreq_state;
|
|
CMD_STATE(sc) = old_ioreq_state;
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ } else {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET)
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
|
|
|
|
+ else
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1232,13 +1559,15 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
{
|
|
{
|
|
struct fc_lport *lp;
|
|
struct fc_lport *lp;
|
|
struct fnic *fnic;
|
|
struct fnic *fnic;
|
|
- struct fnic_io_req *io_req;
|
|
|
|
|
|
+ struct fnic_io_req *io_req = NULL;
|
|
struct fc_rport *rport;
|
|
struct fc_rport *rport;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
+ unsigned long start_time = 0;
|
|
int ret = SUCCESS;
|
|
int ret = SUCCESS;
|
|
- u32 task_req;
|
|
|
|
|
|
+ u32 task_req = 0;
|
|
struct scsi_lun fc_lun;
|
|
struct scsi_lun fc_lun;
|
|
|
|
+ int tag;
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
|
|
|
|
/* Wait for rport to unblock */
|
|
/* Wait for rport to unblock */
|
|
@@ -1249,9 +1578,13 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
|
|
|
|
fnic = lport_priv(lp);
|
|
fnic = lport_priv(lp);
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
- "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %d\n",
|
|
|
|
- rport->port_id, sc->device->lun, sc->request->tag);
|
|
|
|
|
|
+ tag = sc->request->tag;
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG,
|
|
|
|
+ fnic->lport->host,
|
|
|
|
+ "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %x flags %x\n",
|
|
|
|
+ rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc));
|
|
|
|
+
|
|
|
|
+ CMD_FLAGS(sc) = FNIC_NO_FLAGS;
|
|
|
|
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up)) {
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up)) {
|
|
ret = FAILED;
|
|
ret = FAILED;
|
|
@@ -1318,6 +1651,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
ret = FAILED;
|
|
ret = FAILED;
|
|
goto fnic_abort_cmd_end;
|
|
goto fnic_abort_cmd_end;
|
|
}
|
|
}
|
|
|
|
+ if (task_req == FCPIO_ITMF_ABT_TASK)
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABTS_ISSUED;
|
|
|
|
+ else
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_TERM_ISSUED;
|
|
|
|
|
|
/*
|
|
/*
|
|
* We queued an abort IO, wait for its completion.
|
|
* We queued an abort IO, wait for its completion.
|
|
@@ -1336,6 +1673,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
|
|
ret = FAILED;
|
|
ret = FAILED;
|
|
goto fnic_abort_cmd_end;
|
|
goto fnic_abort_cmd_end;
|
|
}
|
|
}
|
|
@@ -1344,6 +1682,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
/* fw did not complete abort, timed out */
|
|
/* fw did not complete abort, timed out */
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_TIMED_OUT;
|
|
ret = FAILED;
|
|
ret = FAILED;
|
|
goto fnic_abort_cmd_end;
|
|
goto fnic_abort_cmd_end;
|
|
}
|
|
}
|
|
@@ -1359,12 +1698,21 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
|
|
|
|
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
|
|
+ start_time = io_req->start_time;
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
|
|
|
|
fnic_abort_cmd_end:
|
|
fnic_abort_cmd_end:
|
|
|
|
+ FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no,
|
|
|
|
+ sc->request->tag, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ 0, ((u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
- "Returning from abort cmd %s\n",
|
|
|
|
|
|
+ "Returning from abort cmd type %x %s\n", task_req,
|
|
(ret == SUCCESS) ?
|
|
(ret == SUCCESS) ?
|
|
"SUCCESS" : "FAILED");
|
|
"SUCCESS" : "FAILED");
|
|
return ret;
|
|
return ret;
|
|
@@ -1375,16 +1723,28 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
|
|
struct fnic_io_req *io_req)
|
|
struct fnic_io_req *io_req)
|
|
{
|
|
{
|
|
struct vnic_wq_copy *wq = &fnic->wq_copy[0];
|
|
struct vnic_wq_copy *wq = &fnic->wq_copy[0];
|
|
|
|
+ struct Scsi_Host *host = fnic->lport->host;
|
|
struct scsi_lun fc_lun;
|
|
struct scsi_lun fc_lun;
|
|
int ret = 0;
|
|
int ret = 0;
|
|
unsigned long intr_flags;
|
|
unsigned long intr_flags;
|
|
|
|
|
|
|
|
+ spin_lock_irqsave(host->host_lock, intr_flags);
|
|
|
|
+ if (unlikely(fnic_chk_state_flags_locked(fnic,
|
|
|
|
+ FNIC_FLAGS_IO_BLOCKED))) {
|
|
|
|
+ spin_unlock_irqrestore(host->host_lock, intr_flags);
|
|
|
|
+ return FAILED;
|
|
|
|
+ } else
|
|
|
|
+ atomic_inc(&fnic->in_flight);
|
|
|
|
+ spin_unlock_irqrestore(host->host_lock, intr_flags);
|
|
|
|
+
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);
|
|
spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);
|
|
|
|
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
|
|
free_wq_copy_descs(fnic, wq);
|
|
free_wq_copy_descs(fnic, wq);
|
|
|
|
|
|
if (!vnic_wq_copy_desc_avail(wq)) {
|
|
if (!vnic_wq_copy_desc_avail(wq)) {
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "queue_dr_io_req failure - no descriptors\n");
|
|
ret = -EAGAIN;
|
|
ret = -EAGAIN;
|
|
goto lr_io_req_end;
|
|
goto lr_io_req_end;
|
|
}
|
|
}
|
|
@@ -1399,6 +1759,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
|
|
|
|
|
|
lr_io_req_end:
|
|
lr_io_req_end:
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
|
|
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
|
|
|
|
+ atomic_dec(&fnic->in_flight);
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1412,7 +1773,7 @@ lr_io_req_end:
|
|
static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
struct scsi_cmnd *lr_sc)
|
|
struct scsi_cmnd *lr_sc)
|
|
{
|
|
{
|
|
- int tag;
|
|
|
|
|
|
+ int tag, abt_tag;
|
|
struct fnic_io_req *io_req;
|
|
struct fnic_io_req *io_req;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
@@ -1421,6 +1782,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
struct scsi_lun fc_lun;
|
|
struct scsi_lun fc_lun;
|
|
struct scsi_device *lun_dev = lr_sc->device;
|
|
struct scsi_device *lun_dev = lr_sc->device;
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
|
|
+ enum fnic_ioreq_state old_ioreq_state;
|
|
|
|
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
@@ -1449,7 +1811,41 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
"Found IO in %s on lun\n",
|
|
"Found IO in %s on lun\n",
|
|
fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
|
|
|
|
- BUG_ON(CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING);
|
|
|
|
|
|
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
|
|
|
|
+ (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) {
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "%s dev rst not pending sc 0x%p\n", __func__,
|
|
|
|
+ sc);
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ old_ioreq_state = CMD_STATE(sc);
|
|
|
|
+ /*
|
|
|
|
+ * Any pending IO issued prior to reset is expected to be
|
|
|
|
+ * in abts pending state, if not we need to set
|
|
|
|
+ * FNIC_IOREQ_ABTS_PENDING to indicate the IO is abort pending.
|
|
|
|
+ * When IO is completed, the IO will be handed over and
|
|
|
|
+ * handled in this function.
|
|
|
|
+ */
|
|
|
|
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
|
|
+
|
|
|
|
+ if (io_req->abts_done)
|
|
|
|
+ shost_printk(KERN_ERR, fnic->lport->host,
|
|
|
|
+ "%s: io_req->abts_done is set state is %s\n",
|
|
|
|
+ __func__, fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
|
|
+
|
|
|
|
+ BUG_ON(io_req->abts_done);
|
|
|
|
+
|
|
|
|
+ abt_tag = tag;
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
|
|
|
|
+ abt_tag |= FNIC_TAG_DEV_RST;
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "%s: dev rst sc 0x%p\n", __func__, sc);
|
|
|
|
+ }
|
|
|
|
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
io_req->abts_done = &tm_done;
|
|
io_req->abts_done = &tm_done;
|
|
@@ -1458,17 +1854,25 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
/* Now queue the abort command to firmware */
|
|
/* Now queue the abort command to firmware */
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
int_to_scsilun(sc->device->lun, &fc_lun);
|
|
|
|
|
|
- if (fnic_queue_abort_io_req(fnic, tag,
|
|
|
|
|
|
+ if (fnic_queue_abort_io_req(fnic, abt_tag,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
FCPIO_ITMF_ABT_TASK_TERM,
|
|
fc_lun.scsi_lun, io_req)) {
|
|
fc_lun.scsi_lun, io_req)) {
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
if (io_req)
|
|
if (io_req)
|
|
io_req->abts_done = NULL;
|
|
io_req->abts_done = NULL;
|
|
|
|
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
|
|
|
|
+ CMD_STATE(sc) = old_ioreq_state;
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
ret = 1;
|
|
ret = 1;
|
|
goto clean_pending_aborts_end;
|
|
goto clean_pending_aborts_end;
|
|
|
|
+ } else {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET)
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
}
|
|
}
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED;
|
|
|
|
|
|
wait_for_completion_timeout(&tm_done,
|
|
wait_for_completion_timeout(&tm_done,
|
|
msecs_to_jiffies
|
|
msecs_to_jiffies
|
|
@@ -1479,8 +1883,8 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
- ret = 1;
|
|
|
|
- goto clean_pending_aborts_end;
|
|
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
|
|
io_req->abts_done = NULL;
|
|
io_req->abts_done = NULL;
|
|
@@ -1488,6 +1892,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
/* if abort is still pending with fw, fail */
|
|
/* if abort is still pending with fw, fail */
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
|
|
ret = 1;
|
|
ret = 1;
|
|
goto clean_pending_aborts_end;
|
|
goto clean_pending_aborts_end;
|
|
}
|
|
}
|
|
@@ -1498,10 +1903,75 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ schedule_timeout(msecs_to_jiffies(2 * fnic->config.ed_tov));
|
|
|
|
+
|
|
|
|
+ /* walk again to check, if IOs are still pending in fw */
|
|
|
|
+ if (fnic_is_abts_pending(fnic, lr_sc))
|
|
|
|
+ ret = FAILED;
|
|
|
|
+
|
|
clean_pending_aborts_end:
|
|
clean_pending_aborts_end:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * fnic_scsi_host_start_tag
|
|
|
|
+ * Allocates tagid from host's tag list
|
|
|
|
+ **/
|
|
|
|
+static inline int
|
|
|
|
+fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
|
|
|
|
+{
|
|
|
|
+ struct blk_queue_tag *bqt = fnic->lport->host->bqt;
|
|
|
|
+ int tag, ret = SCSI_NO_TAG;
|
|
|
|
+
|
|
|
|
+ BUG_ON(!bqt);
|
|
|
|
+ if (!bqt) {
|
|
|
|
+ pr_err("Tags are not supported\n");
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ do {
|
|
|
|
+ tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1);
|
|
|
|
+ if (tag >= bqt->max_depth) {
|
|
|
|
+ pr_err("Tag allocation failure\n");
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+ } while (test_and_set_bit(tag, bqt->tag_map));
|
|
|
|
+
|
|
|
|
+ bqt->tag_index[tag] = sc->request;
|
|
|
|
+ sc->request->tag = tag;
|
|
|
|
+ sc->tag = tag;
|
|
|
|
+ if (!sc->request->special)
|
|
|
|
+ sc->request->special = sc;
|
|
|
|
+
|
|
|
|
+ ret = tag;
|
|
|
|
+
|
|
|
|
+end:
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * fnic_scsi_host_end_tag
|
|
|
|
+ * frees tag allocated by fnic_scsi_host_start_tag.
|
|
|
|
+ **/
|
|
|
|
+static inline void
|
|
|
|
+fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc)
|
|
|
|
+{
|
|
|
|
+ struct blk_queue_tag *bqt = fnic->lport->host->bqt;
|
|
|
|
+ int tag = sc->request->tag;
|
|
|
|
+
|
|
|
|
+ if (tag == SCSI_NO_TAG)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ BUG_ON(!bqt || !bqt->tag_index[tag]);
|
|
|
|
+ if (!bqt)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ bqt->tag_index[tag] = NULL;
|
|
|
|
+ clear_bit(tag, bqt->tag_map);
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* SCSI Eh thread issues a Lun Reset when one or more commands on a LUN
|
|
* SCSI Eh thread issues a Lun Reset when one or more commands on a LUN
|
|
* fail to get aborted. It calls driver's eh_device_reset with a SCSI command
|
|
* fail to get aborted. It calls driver's eh_device_reset with a SCSI command
|
|
@@ -1511,13 +1981,17 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
{
|
|
{
|
|
struct fc_lport *lp;
|
|
struct fc_lport *lp;
|
|
struct fnic *fnic;
|
|
struct fnic *fnic;
|
|
- struct fnic_io_req *io_req;
|
|
|
|
|
|
+ struct fnic_io_req *io_req = NULL;
|
|
struct fc_rport *rport;
|
|
struct fc_rport *rport;
|
|
int status;
|
|
int status;
|
|
int ret = FAILED;
|
|
int ret = FAILED;
|
|
spinlock_t *io_lock;
|
|
spinlock_t *io_lock;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
+ unsigned long start_time = 0;
|
|
|
|
+ struct scsi_lun fc_lun;
|
|
|
|
+ int tag = 0;
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
DECLARE_COMPLETION_ONSTACK(tm_done);
|
|
|
|
+ int tag_gen_flag = 0; /*to track tags allocated by fnic driver*/
|
|
|
|
|
|
/* Wait for rport to unblock */
|
|
/* Wait for rport to unblock */
|
|
fc_block_scsi_eh(sc);
|
|
fc_block_scsi_eh(sc);
|
|
@@ -1529,8 +2003,8 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
|
|
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
rport = starget_to_rport(scsi_target(sc->device));
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
- "Device reset called FCID 0x%x, LUN 0x%x\n",
|
|
|
|
- rport->port_id, sc->device->lun);
|
|
|
|
|
|
+ "Device reset called FCID 0x%x, LUN 0x%x sc 0x%p\n",
|
|
|
|
+ rport->port_id, sc->device->lun, sc);
|
|
|
|
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up))
|
|
if (lp->state != LPORT_ST_READY || !(lp->link_up))
|
|
goto fnic_device_reset_end;
|
|
goto fnic_device_reset_end;
|
|
@@ -1539,6 +2013,16 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
if (fc_remote_port_chkready(rport))
|
|
if (fc_remote_port_chkready(rport))
|
|
goto fnic_device_reset_end;
|
|
goto fnic_device_reset_end;
|
|
|
|
|
|
|
|
+ CMD_FLAGS(sc) = FNIC_DEVICE_RESET;
|
|
|
|
+ /* Allocate tag if not present */
|
|
|
|
+
|
|
|
|
+ tag = sc->request->tag;
|
|
|
|
+ if (unlikely(tag < 0)) {
|
|
|
|
+ tag = fnic_scsi_host_start_tag(fnic, sc);
|
|
|
|
+ if (unlikely(tag == SCSI_NO_TAG))
|
|
|
|
+ goto fnic_device_reset_end;
|
|
|
|
+ tag_gen_flag = 1;
|
|
|
|
+ }
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
io_lock = fnic_io_lock_hash(fnic, sc);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
spin_lock_irqsave(io_lock, flags);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
@@ -1562,8 +2046,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE;
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %d\n",
|
|
|
|
- sc->request->tag);
|
|
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %x\n", tag);
|
|
|
|
|
|
/*
|
|
/*
|
|
* issue the device reset, if enqueue failed, clean up the ioreq
|
|
* issue the device reset, if enqueue failed, clean up the ioreq
|
|
@@ -1576,6 +2059,9 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
io_req->dr_done = NULL;
|
|
io_req->dr_done = NULL;
|
|
goto fnic_device_reset_clean;
|
|
goto fnic_device_reset_clean;
|
|
}
|
|
}
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_ISSUED;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
/*
|
|
/*
|
|
* Wait on the local completion for LUN reset. The io_req may be
|
|
* Wait on the local completion for LUN reset. The io_req may be
|
|
@@ -1588,12 +2074,13 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
if (!io_req) {
|
|
if (!io_req) {
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "io_req is null tag 0x%x sc 0x%p\n", tag, sc);
|
|
goto fnic_device_reset_end;
|
|
goto fnic_device_reset_end;
|
|
}
|
|
}
|
|
io_req->dr_done = NULL;
|
|
io_req->dr_done = NULL;
|
|
|
|
|
|
status = CMD_LR_STATUS(sc);
|
|
status = CMD_LR_STATUS(sc);
|
|
- spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
* If lun reset not completed, bail out with failed. io_req
|
|
* If lun reset not completed, bail out with failed. io_req
|
|
@@ -1602,7 +2089,53 @@ int fnic_device_reset(struct scsi_cmnd *sc)
|
|
if (status == FCPIO_INVALID_CODE) {
|
|
if (status == FCPIO_INVALID_CODE) {
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"Device reset timed out\n");
|
|
"Device reset timed out\n");
|
|
- goto fnic_device_reset_end;
|
|
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_TIMED_OUT;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ int_to_scsilun(sc->device->lun, &fc_lun);
|
|
|
|
+ /*
|
|
|
|
+ * Issue abort and terminate on the device reset request.
|
|
|
|
+ * If q'ing of the abort fails, retry issue it after a delay.
|
|
|
|
+ */
|
|
|
|
+ while (1) {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ if (CMD_FLAGS(sc) & FNIC_DEV_RST_TERM_ISSUED) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ if (fnic_queue_abort_io_req(fnic,
|
|
|
|
+ tag | FNIC_TAG_DEV_RST,
|
|
|
|
+ FCPIO_ITMF_ABT_TASK_TERM,
|
|
|
|
+ fc_lun.scsi_lun, io_req)) {
|
|
|
|
+ wait_for_completion_timeout(&tm_done,
|
|
|
|
+ msecs_to_jiffies(FNIC_ABT_TERM_DELAY_TIMEOUT));
|
|
|
|
+ } else {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
|
|
|
|
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
|
|
|
|
+ io_req->abts_done = &tm_done;
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
|
|
+ "Abort and terminate issued on Device reset "
|
|
|
|
+ "tag 0x%x sc 0x%p\n", tag, sc);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ while (1) {
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+ if (!(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ wait_for_completion_timeout(&tm_done,
|
|
|
|
+ msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT));
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
|
|
+ io_req->abts_done = NULL;
|
|
|
|
+ goto fnic_device_reset_clean;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
}
|
|
}
|
|
|
|
|
|
/* Completed, but not successful, clean up the io_req, return fail */
|
|
/* Completed, but not successful, clean up the io_req, return fail */
|
|
@@ -1645,11 +2178,24 @@ fnic_device_reset_clean:
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
|
|
if (io_req) {
|
|
if (io_req) {
|
|
|
|
+ start_time = io_req->start_time;
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
fnic_release_ioreq_buf(fnic, io_req, sc);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
mempool_free(io_req, fnic->io_req_pool);
|
|
}
|
|
}
|
|
|
|
|
|
fnic_device_reset_end:
|
|
fnic_device_reset_end:
|
|
|
|
+ FNIC_TRACE(fnic_device_reset, sc->device->host->host_no,
|
|
|
|
+ sc->request->tag, sc,
|
|
|
|
+ jiffies_to_msecs(jiffies - start_time),
|
|
|
|
+ 0, ((u64)sc->cmnd[0] << 32 |
|
|
|
|
+ (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
|
|
|
|
+ (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
|
|
|
|
+ (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
|
|
|
|
+
|
|
|
|
+ /* free tag if it is allocated */
|
|
|
|
+ if (unlikely(tag_gen_flag))
|
|
|
|
+ fnic_scsi_host_end_tag(fnic, sc);
|
|
|
|
+
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
|
|
"Returning from device reset %s\n",
|
|
"Returning from device reset %s\n",
|
|
(ret == SUCCESS) ?
|
|
(ret == SUCCESS) ?
|
|
@@ -1735,7 +2281,15 @@ void fnic_scsi_abort_io(struct fc_lport *lp)
|
|
DECLARE_COMPLETION_ONSTACK(remove_wait);
|
|
DECLARE_COMPLETION_ONSTACK(remove_wait);
|
|
|
|
|
|
/* Issue firmware reset for fnic, wait for reset to complete */
|
|
/* Issue firmware reset for fnic, wait for reset to complete */
|
|
|
|
+retry_fw_reset:
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
+ if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) {
|
|
|
|
+ /* fw reset is in progress, poll for its completion */
|
|
|
|
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
+ schedule_timeout(msecs_to_jiffies(100));
|
|
|
|
+ goto retry_fw_reset;
|
|
|
|
+ }
|
|
|
|
+
|
|
fnic->remove_wait = &remove_wait;
|
|
fnic->remove_wait = &remove_wait;
|
|
old_state = fnic->state;
|
|
old_state = fnic->state;
|
|
fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
|
|
fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
|
|
@@ -1776,7 +2330,14 @@ void fnic_scsi_cleanup(struct fc_lport *lp)
|
|
struct fnic *fnic = lport_priv(lp);
|
|
struct fnic *fnic = lport_priv(lp);
|
|
|
|
|
|
/* issue fw reset */
|
|
/* issue fw reset */
|
|
|
|
+retry_fw_reset:
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
|
|
|
+ if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) {
|
|
|
|
+ /* fw reset is in progress, poll for its completion */
|
|
|
|
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
|
|
|
+ schedule_timeout(msecs_to_jiffies(100));
|
|
|
|
+ goto retry_fw_reset;
|
|
|
|
+ }
|
|
old_state = fnic->state;
|
|
old_state = fnic->state;
|
|
fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
|
|
fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
|
|
fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr);
|
|
fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr);
|
|
@@ -1822,3 +2383,61 @@ call_fc_exch_mgr_reset:
|
|
fc_exch_mgr_reset(lp, sid, did);
|
|
fc_exch_mgr_reset(lp, sid, did);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * fnic_is_abts_pending() is a helper function that
|
|
|
|
+ * walks through tag map to check if there is any IOs pending,if there is one,
|
|
|
|
+ * then it returns 1 (true), otherwise 0 (false)
|
|
|
|
+ * if @lr_sc is non NULL, then it checks IOs specific to particular LUN,
|
|
|
|
+ * otherwise, it checks for all IOs.
|
|
|
|
+ */
|
|
|
|
+int fnic_is_abts_pending(struct fnic *fnic, struct scsi_cmnd *lr_sc)
|
|
|
|
+{
|
|
|
|
+ int tag;
|
|
|
|
+ struct fnic_io_req *io_req;
|
|
|
|
+ spinlock_t *io_lock;
|
|
|
|
+ unsigned long flags;
|
|
|
|
+ int ret = 0;
|
|
|
|
+ struct scsi_cmnd *sc;
|
|
|
|
+ struct scsi_device *lun_dev = NULL;
|
|
|
|
+
|
|
|
|
+ if (lr_sc)
|
|
|
|
+ lun_dev = lr_sc->device;
|
|
|
|
+
|
|
|
|
+ /* walk again to check, if IOs are still pending in fw */
|
|
|
|
+ for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
|
|
|
|
+ sc = scsi_host_find_tag(fnic->lport->host, tag);
|
|
|
|
+ /*
|
|
|
|
+ * ignore this lun reset cmd or cmds that do not belong to
|
|
|
|
+ * this lun
|
|
|
|
+ */
|
|
|
|
+ if (!sc || (lr_sc && (sc->device != lun_dev || sc == lr_sc)))
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ io_lock = fnic_io_lock_hash(fnic, sc);
|
|
|
|
+ spin_lock_irqsave(io_lock, flags);
|
|
|
|
+
|
|
|
|
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
|
|
|
|
+
|
|
|
|
+ if (!io_req || sc->device != lun_dev) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Found IO that is still pending with firmware and
|
|
|
|
+ * belongs to the LUN that we are resetting
|
|
|
|
+ */
|
|
|
|
+ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
|
|
|
|
+ "Found IO in %s on lun\n",
|
|
|
|
+ fnic_ioreq_state_to_str(CMD_STATE(sc)));
|
|
|
|
+
|
|
|
|
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
|
|
|
|
+ spin_unlock_irqrestore(io_lock, flags);
|
|
|
|
+ ret = 1;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|