RE: [PATCH] [RESEND] scsi: fnic: use 64-bit timestamps

2018-01-17 Thread Satish Kharat (satishkh)
Looks good to me.

Acked-by: Satish Kharat <satis...@cisco.com>

-Original Message-
From: Arnd Bergmann [mailto:a...@arndb.de] 
Sent: Wednesday, January 17, 2018 7:17 AM
To: Satish Kharat (satishkh) <satis...@cisco.com>; Sesidhar Baddela (sebaddel) 
<sebad...@cisco.com>; Karan Tilak Kumar (kartilak) <karti...@cisco.com>; James 
E.J. Bottomley <j...@linux.vnet.ibm.com>; Martin K. Petersen 
<martin.peter...@oracle.com>
Cc: Arnd Bergmann <a...@arndb.de>; Vasyl Gomonovych <gomonov...@gmail.com>; 
linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org
Subject: [PATCH] [RESEND] scsi: fnic: use 64-bit timestamps

struct timespec is deprecated since it overflows in 2038 on 32-bit 
architectures, so we should use timespec64 consistently.

I'm slightly adapting the format strings here, to make sure we print the 
nanoseconds with the correct number of leading zeroes.

Signed-off-by: Arnd Bergmann <a...@arndb.de>
---
Originally submitted in November 2017. Martin asked Satish to review my patch, 
but I never heard back after that, so I'm trying again now.
---
 drivers/scsi/fnic/fnic_debugfs.c |  2 +-
 drivers/scsi/fnic/fnic_stats.h   |  4 +--
 drivers/scsi/fnic/fnic_trace.c   | 58 
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 9858484dd126..6d3e1cb4fea6 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -614,7 +614,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
sizeof(struct io_path_stats) - sizeof(u64));
memset(fw_stats_p+1, 0,
sizeof(struct fw_stats) - sizeof(u64));
-   getnstimeofday(>stats_timestamps.last_reset_time);
+   ktime_get_real_ts64(>stats_timestamps.last_reset_time);
}
 
(*ppos)++;
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h 
index e007feedbf72..9daa6ada6fa0 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -18,8 +18,8 @@
 #define _FNIC_STATS_H_
 
 struct stats_timestamps {
-   struct timespec last_reset_time;
-   struct timespec last_read_time;
+   struct timespec64 last_reset_time;
+   struct timespec64 last_read_time;
 };
 
 struct io_path_stats {
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c 
index 4826f596cb31..abddde11982b 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -111,7 +111,7 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
int len = 0;
unsigned long flags;
char str[KSYM_SYMBOL_LEN];
-   struct timespec val;
+   struct timespec64 val;
fnic_trace_data_t *tbp;
 
spin_lock_irqsave(_trace_lock, flags); @@ -129,10 +129,10 @@ int 
fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
/* Convert function pointer to function name */
if (sizeof(unsigned long) < 8) {
sprint_symbol(str, tbp->fnaddr.low);
-   jiffies_to_timespec(tbp->timestamp.low, );
+   jiffies_to_timespec64(tbp->timestamp.low, );
} else {
sprint_symbol(str, tbp->fnaddr.val);
-   jiffies_to_timespec(tbp->timestamp.val, );
+   jiffies_to_timespec64(tbp->timestamp.val, );
}
/*
 * Dump trace buffer entry to memory file @@ -140,8 
+140,8 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
 */
len += snprintf(fnic_dbgfs_prt->buffer + len,
  (trace_max_pages * PAGE_SIZE * 3) - len,
- "%16lu.%16lu %-50s %8x %8x %16llx %16llx "
- "%16llx %16llx %16llx\n", val.tv_sec,
+ "%16llu.%09lu %-50s %8x %8x %16llx %16llx "
+ "%16llx %16llx %16llx\n", (u64)val.tv_sec,
  val.tv_nsec, str, tbp->host_no, tbp->tag,
  tbp->data[0], tbp->data[1], tbp->data[2],
  tbp->data[3], tbp->data[4]);
@@ -171,10 +171,10 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
/* Convert function pointer to function name */
if (sizeof(unsigned long) < 8) {
sprint_symbol(str, tbp->fnaddr.low);
-   jiffies_to_timespec(tbp->timestamp.low, );
+ 

[PATCH 1/1] fnic:correct speed display and add support for 25,40 and 100G

2017-06-26 Thread Satish Kharat
Setting speed based on the vinc device parameter read during
linkup. Also adding support to display 25,40 and 100G

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_fcs.c  | 24 
 drivers/scsi/fnic/fnic_io.h   |  9 +
 drivers/scsi/fnic/fnic_main.c | 14 --
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 245dcd9..d212eb5 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -65,6 +65,30 @@ void fnic_handle_link(struct work_struct *work)
fnic->link_status = vnic_dev_link_status(fnic->vdev);
fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
 
+   switch (vnic_dev_port_speed(fnic->vdev)) {
+   case DCEM_PORTSPEED_10G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_10GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_10GBIT;
+   break;
+   case DCEM_PORTSPEED_25G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_25GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_25GBIT;
+   break;
+   case DCEM_PORTSPEED_40G:
+   case DCEM_PORTSPEED_4x10G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_40GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_40GBIT;
+   break;
+   case DCEM_PORTSPEED_100G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_100GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_100GBIT;
+   break;
+   default:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_UNKNOWN;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_UNKNOWN;
+   break;
+   }
+
if (old_link_status == fnic->link_status) {
if (!fnic->link_status) {
/* DOWN -> DOWN */
diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h
index c35b8f1..e0bc659 100644
--- a/drivers/scsi/fnic/fnic_io.h
+++ b/drivers/scsi/fnic/fnic_io.h
@@ -66,4 +66,13 @@ struct fnic_io_req {
struct completion *dr_done; /* completion for device reset */
 };
 
+enum fnic_port_speeds {
+   DCEM_PORTSPEED_NONE = 0,
+   DCEM_PORTSPEED_1G= 1000,
+   DCEM_PORTSPEED_10G   = 1,
+   DCEM_PORTSPEED_40G   = 4,
+   DCEM_PORTSPEED_4x10G = 41000,
+   DCEM_PORTSPEED_25G   = 25000,
+   DCEM_PORTSPEED_100G  = 10,
+};
 #endif /* _FNIC_IO_H_ */
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index ba58b79..aacadbf 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -176,11 +176,21 @@ static void fnic_get_host_speed(struct Scsi_Host *shost)
 
/* Add in other values as they get defined in fw */
switch (port_speed) {
-   case 1:
+   case DCEM_PORTSPEED_10G:
fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
break;
+   case DCEM_PORTSPEED_25G:
+   fc_host_speed(shost) = FC_PORTSPEED_25GBIT;
+   break;
+   case DCEM_PORTSPEED_40G:
+   case DCEM_PORTSPEED_4x10G:
+   fc_host_speed(shost) = FC_PORTSPEED_40GBIT;
+   break;
+   case DCEM_PORTSPEED_100G:
+   fc_host_speed(shost) = FC_PORTSPEED_100GBIT;
+   break;
default:
-   fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
+   fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
}
 }
-- 
2.7.4



[PATCH 1/1] fnic: Zero io_cmpl_skip on fw reset completion

2017-06-26 Thread Satish Kharat
io_cmpl_skip keep track of number of completions to skip when
stats are reset. If a fw_reset happens immediately after stats
reset it could put it out of sync so need to reset io_cmpl_skip
when fw reset is completed.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d048f3b..beea14c 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -633,6 +633,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic 
*fnic,
 
atomic64_set(>fnic_stats.fw_stats.active_fw_reqs, 0);
atomic64_set(>fnic_stats.io_stats.active_ios, 0);
+   atomic64_set(>io_cmpl_skip, 0);
 
spin_lock_irqsave(>fnic_lock, flags);
 
-- 
2.7.4



[PATCH 1/1] fnic:added timestamp reporting in fnic debug stats

2017-06-26 Thread Satish Kharat
Added the timestamps for
1. current timestamp
2. last fnic stats read timestamp
3. last fnic stats reset timestamp
and the deltas since last stats read and last reset in fnic stats.
fnic stats uses debugfs

Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic_debugfs.c |  1 +
 drivers/scsi/fnic/fnic_stats.h   |  7 +++
 drivers/scsi/fnic/fnic_trace.c   | 24 
 3 files changed, 32 insertions(+)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index d6498fa..5e3d909 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -632,6 +632,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
sizeof(struct io_path_stats) - sizeof(u64));
memset(fw_stats_p+1, 0,
sizeof(struct fw_stats) - sizeof(u64));
+   getnstimeofday(>stats_timestamps.last_reset_time);
}
 
(*ppos)++;
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h
index 88c73cc..e007fee 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -16,6 +16,12 @@
  */
 #ifndef _FNIC_STATS_H_
 #define _FNIC_STATS_H_
+
+struct stats_timestamps {
+   struct timespec last_reset_time;
+   struct timespec last_read_time;
+};
+
 struct io_path_stats {
atomic64_t active_ios;
atomic64_t max_active_ios;
@@ -110,6 +116,7 @@ struct misc_stats {
 };
 
 struct fnic_stats {
+   struct stats_timestamps stats_timestamps;
struct io_path_stats io_stats;
struct abort_stats abts_stats;
struct terminate_stats term_stats;
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index b5ac538..4826f59 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -219,7 +219,31 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
int buf_size = debug->buf_size;
struct timespec val1, val2;
 
+   getnstimeofday();
len = snprintf(debug->debug_buffer + len, buf_size - len,
+   "--\n"
+"\t\tTime\n"
+   "--\n");
+
+   len += snprintf(debug->debug_buffer + len, buf_size - len,
+   "Current time :  [%ld:%ld]\n"
+   "Last stats reset time:  [%ld:%ld]\n"
+   "Last stats read time:   [%ld:%ld]\n"
+   "delta since last reset: [%ld:%ld]\n"
+   "delta since last read:  [%ld:%ld]\n",
+   val1.tv_sec, val1.tv_nsec,
+   stats->stats_timestamps.last_reset_time.tv_sec,
+   stats->stats_timestamps.last_reset_time.tv_nsec,
+   stats->stats_timestamps.last_read_time.tv_sec,
+   stats->stats_timestamps.last_read_time.tv_nsec,
+   timespec_sub(val1, stats->stats_timestamps.last_reset_time).tv_sec,
+   timespec_sub(val1, stats->stats_timestamps.last_reset_time).tv_nsec,
+   timespec_sub(val1, stats->stats_timestamps.last_read_time).tv_sec,
+   timespec_sub(val1, stats->stats_timestamps.last_read_time).tv_nsec);
+
+   stats->stats_timestamps.last_read_time = val1;
+
+   len += snprintf(debug->debug_buffer + len, buf_size - len,
  "--\n"
  "\t\tIO Statistics\n"
  "--\n");
-- 
2.7.4



[PATCH 1/1] fnic:changing queue command to return result DID_IMM_RETRY when rport is init

2017-06-26 Thread Satish Kharat
Currently the queue command returns DID_NO_CONNECT anytime the rport
is not in RPORT_ST_READY state. Changing it to return DID_NO_CONNECT
only when the rport is in RPORT_ST_DELETE state. When the rport is
in one of the init states retruning DID_IMM_RETRY.

Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d048f3b..cc48cb8 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -466,15 +466,27 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
}
 
rp = rport->dd_data;
-   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   if (!rp || rp->rp_state == RPORT_ST_DELETE) {
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
+   "rport 0x%x removed, returning DID_NO_CONNECT\n",
+   rport->port_id);
+
atomic64_inc(_stats->misc_stats.rport_not_ready);
sc->result = DID_NO_CONNECT<<16;
done(sc);
return 0;
}
 
+   if (rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n",
+   rport->port_id, rp->rp_state);
+
+   sc->result = DID_IMM_RETRY << 16;
+   done(sc);
+   return 0;
+   }
+
if (lp->state != LPORT_ST_READY || !(lp->link_up))
return SCSI_MLQUEUE_HOST_BUSY;
 
-- 
2.7.4



RE: [PATCH 1/1] fnic: Adding Check Condition counter to misc fnicstats

2017-03-22 Thread Satish Kharat (satishkh)
Hi Martin,
 Apologies for the delay. I was not able to verify this because of another fnic 
issue blocking this test. Just now submitted a fix for that 'fnic issue' (in 
the patch => [PATCH 1/1] fnic: bug fix for fip.fip_subcode in 
fnic_fcoe_send_vlan_req)

Did some quick verification and basic IO test, this patch looks good.

Thanks,
Satish Kharat

-Original Message-
From: Martin K. Petersen [mailto:martin.peter...@oracle.com] 
Sent: Wednesday, March 01, 2017 7:04 PM
To: Satish Kharat (satishkh) <satis...@cisco.com>
Cc: linux-scsi@vger.kernel.org; Sesidhar Baddela (sebaddel) <sebad...@cisco.com>
Subject: Re: [PATCH 1/1] fnic: Adding Check Condition counter to misc fnicstats

>>>>> "Satish" == Satish Kharat <satis...@cisco.com> writes:

Satish,

Satish> Just a simple counter of number of check conditions encountered 
Satish> on that host.

Please test and review the following:

https://patchwork.kernel.org/patch/9549777/

Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH 1/1] fnic: bug fix for fip.fip_subcode in fnic_fcoe_send_vlan_req

2017-03-22 Thread Satish Kharat
This is a bug introduced when they moved the fip subcodes
to central place. Was sending FIP_SC_VL_NOTE in fip.fip_subcode
for VLAN request in fnic_fcoe_send_vlan_req. Change is to use
FIP_SC_VL_REQ instead.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_fcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 3b7da66..f5e632f 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -359,7 +359,7 @@ static void fnic_fcoe_send_vlan_req(struct fnic *fnic)
 
vlan->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
vlan->fip.fip_op = htons(FIP_OP_VLAN);
-   vlan->fip.fip_subcode = FIP_SC_VL_NOTE;
+   vlan->fip.fip_subcode = FIP_SC_VL_REQ;
vlan->fip.fip_dl_len = htons(sizeof(vlan->desc) / FIP_BPW);
 
vlan->desc.mac.fd_desc.fip_dtype = FIP_DT_MAC;
-- 
2.7.4



[PATCH 1/1] fnic: minor cleanup in fnic_fcpio_itmf_cmpl_handler, removing else case

2017-02-28 Thread Satish Kharat
Getting rid of else case to make the flow look bit more simpler
logical

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..df443a9 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1128,12 +1128,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
}
 
CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
+   CMD_ABTS_STATUS(sc) = hdr_status;
 
/* If the status is IO not found consider it as success */
if (hdr_status == FCPIO_IO_NOT_FOUND)
CMD_ABTS_STATUS(sc) = FCPIO_SUCCESS;
-   else
-   CMD_ABTS_STATUS(sc) = hdr_status;
 
atomic64_dec(_stats->io_stats.active_ios);
if (atomic64_read(>io_cmpl_skip))
-- 
2.5.5



[PATCH 1/1] fnic: Ratelimit printks to avoid flooding when vlan is not set by the switch.i

2017-02-28 Thread Satish Kharat
From: Satish Kharat <satis...@satishkh.cisco.com>

This is to avoid the log from being filled with vlan discovery
messages when there is no vlan configured on the switch.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_fcs.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 3b7da66..8d2d86e 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -342,8 +342,11 @@ static void fnic_fcoe_send_vlan_req(struct fnic *fnic)
 
fnic_fcoe_reset_vlans(fnic);
fnic->set_vlan(fnic, 0);
-   FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
- "Sending VLAN request...\n");
+
+   if (printk_ratelimit())
+   FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
+ "Sending VLAN request...\n");
+
skb = dev_alloc_skb(sizeof(struct fip_vlan));
if (!skb)
return;
@@ -1313,10 +1316,11 @@ void fnic_handle_fip_timer(struct fnic *fnic)
 
spin_lock_irqsave(>vlans_lock, flags);
if (list_empty(>vlans)) {
-   /* no vlans available, try again */
-   FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
- "Start VLAN Discovery\n");
spin_unlock_irqrestore(>vlans_lock, flags);
+   /* no vlans available, try again */
+   if (printk_ratelimit())
+   FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "Start VLAN Discovery\n");
fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
return;
}
@@ -1332,10 +1336,11 @@ void fnic_handle_fip_timer(struct fnic *fnic)
spin_unlock_irqrestore(>vlans_lock, flags);
break;
case FIP_VLAN_FAILED:
-   /* if all vlans are in failed state, restart vlan disc */
-   FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
- "Start VLAN Discovery\n");
spin_unlock_irqrestore(>vlans_lock, flags);
+   /* if all vlans are in failed state, restart vlan disc */
+   if (printk_ratelimit())
+   FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "Start VLAN Discovery\n");
fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
break;
case FIP_VLAN_SENT:
-- 
2.5.5



[PATCH 1/1] fnic: Fix for "Number of Active IOs" in fnicstats becoming negative

2017-02-28 Thread Satish Kharat
Fixing the IO stats updation (Active IOs and IO completion) to
fix "Number of Active IOs" becoming negative in the fnistats
output.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..ec820cb 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1135,11 +1135,6 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
else
CMD_ABTS_STATUS(sc) = hdr_status;
 
-   atomic64_dec(_stats->io_stats.active_ios);
-   if (atomic64_read(>io_cmpl_skip))
-   atomic64_dec(>io_cmpl_skip);
-   else
-   atomic64_inc(_stats->io_stats.io_completions);
 
if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE)))
atomic64_inc(_stats->no_icmnd_itmf_cmpls);
@@ -1181,6 +1176,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
(((u64)CMD_FLAGS(sc) << 32) |
CMD_STATE(sc)));
sc->scsi_done(sc);
+   atomic64_dec(_stats->io_stats.active_ios);
+   if (atomic64_read(>io_cmpl_skip))
+   atomic64_dec(>io_cmpl_skip);
+   else
+   
atomic64_inc(_stats->io_stats.io_completions);
}
}
 
@@ -1970,6 +1970,11 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
/* Call SCSI completion function to complete the IO */
sc->result = (DID_ABORT << 16);
sc->scsi_done(sc);
+   atomic64_dec(_stats->io_stats.active_ios);
+   if (atomic64_read(>io_cmpl_skip))
+   atomic64_dec(>io_cmpl_skip);
+   else
+   atomic64_inc(_stats->io_stats.io_completions);
}
 
 fnic_abort_cmd_end:
-- 
2.5.5



[PATCH 1/1] fnic: Adding debug IO and Abort latency counter to fnic stats

2017-02-28 Thread Satish Kharat
The IO and Abort latency counter count the time taken to complete
the IO and abort command into broad buckets. It is not intend for
performance measurement, just a debug stat.
current_max_io_time tries to keep tarck of the maximun time an IO
has taken to complete if it > 30sec, it just another debug stat.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic.h   |  2 +-
 drivers/scsi/fnic/fnic_scsi.c  | 43 ++
 drivers/scsi/fnic/fnic_stats.h | 15 ++
 drivers/scsi/fnic/fnic_trace.c | 47 ++
 4 files changed, 102 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 9ddc920..99d00c9 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.21"
+#define DRV_VERSION"1.6.0.34"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..1f116b4 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -823,6 +823,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
spinlock_t *io_lock;
u64 cmd_trace;
unsigned long start_time;
+   unsigned long io_duration_time;
 
/* Decode the cmpl description to get the io_req id */
fcpio_header_dec(>hdr, , _status, );
@@ -1017,6 +1018,28 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic 
*fnic,
else
atomic64_inc(_stats->io_stats.io_completions);
 
+
+   io_duration_time = jiffies_to_msecs(jiffies) - 
jiffies_to_msecs(io_req->start_time);
+
+   if(io_duration_time <= 10)
+   atomic64_inc(_stats->io_stats.io_btw_0_to_10_msec);
+   else if(io_duration_time <= 100)
+   atomic64_inc(_stats->io_stats.io_btw_10_to_100_msec);
+   else if(io_duration_time <= 500)
+   atomic64_inc(_stats->io_stats.io_btw_100_to_500_msec);
+   else if(io_duration_time <= 5000)
+   atomic64_inc(_stats->io_stats.io_btw_500_to_5000_msec);
+   else if(io_duration_time <= 1)
+   atomic64_inc(_stats->io_stats.io_btw_5000_to_1_msec);
+   else if(io_duration_time <= 3)
+   atomic64_inc(_stats->io_stats.io_btw_1_to_3_msec);
+   else {
+   atomic64_inc(_stats->io_stats.io_greater_than_3_msec);
+
+   if(io_duration_time > 
atomic64_read(_stats->io_stats.current_max_io_time))
+   atomic64_set(_stats->io_stats.current_max_io_time, 
io_duration_time);
+   }
+
/* Call SCSI completion function to complete the IO */
if (sc->scsi_done)
sc->scsi_done(sc);
@@ -1793,6 +1816,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
struct terminate_stats *term_stats;
enum fnic_ioreq_state old_ioreq_state;
int tag;
+   unsigned long abt_issued_time;
DECLARE_COMPLETION_ONSTACK(tm_done);
 
/* Wait for rport to unblock */
@@ -1846,6 +1870,25 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
spin_unlock_irqrestore(io_lock, flags);
goto wait_pending;
}
+
+   abt_issued_time = jiffies_to_msecs(jiffies) - 
jiffies_to_msecs(io_req->start_time);
+   if (abt_issued_time <= 6000)
+   atomic64_inc(_stats->abort_issued_btw_0_to_6_sec);
+   else if (abt_issued_time > 6000 && abt_issued_time <= 2)
+   atomic64_inc(_stats->abort_issued_btw_6_to_20_sec);
+   else if (abt_issued_time > 2 && abt_issued_time <= 3)
+   atomic64_inc(_stats->abort_issued_btw_20_to_30_sec);
+   else if (abt_issued_time > 3 && abt_issued_time <= 4)
+   atomic64_inc(_stats->abort_issued_btw_30_to_40_sec);
+   else if (abt_issued_time > 4 && abt_issued_time <= 5)
+   atomic64_inc(_stats->abort_issued_btw_40_to_50_sec);
+   else if (abt_issued_time > 5 && abt_issued_time <= 6)
+   atomic64_inc(_stats->abort_issued_btw_50_to_60_sec);
+   else
+   atomic64_inc(_stats->abort_issued_greater_than_60_sec);
+
+   FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
+   "CBD Opcode: %02x Abort issued time: %lu msec\n", sc->cmnd[0], 
abt_issued_time);
/*
 * Command is still pending, need to abort it
 * If the firmware completes the command after this poi

[PATCH 1/1] fnic: Avoid false out-of-order detection for aborted command

2017-02-28 Thread Satish Kharat
If SCSI-ML has already issued abort on a command i.e
FNIC_IOREQ_ABTS_PENDING is set and we get a IO completion avoid
this being flagged as out-of-order completion by setting the
FNIC_IO_DONE flag in fnic_fcpio_icmnd_cmpl_handler

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 40 ++--
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..d851d89 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -876,32 +876,28 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic 
*fnic,
 
/*
 *  if SCSI-ML has already issued abort on this command,
-* ignore completion of the IO. The abts path will clean it up
+*  set completion of the IO. The abts path will clean it up
 */
if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
-   spin_unlock_irqrestore(io_lock, flags);
+
+   /*
+* set the FNIC_IO_DONE so that this doesn't get
+* flagged as 'out of order' if it was not aborted
+*/
+   CMD_FLAGS(sc) |= FNIC_IO_DONE;
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:
+   spin_unlock_irqrestore(io_lock, flags);
+   if(FCPIO_ABORTED == hdr_status)
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;
-   }
+
+   FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
+   "icmnd_cmpl abts pending "
+ "hdr status = %s tag = 0x%x sc = 0x%p"
+ "scsi_status = %x residual = %d\n",
+ fnic_fcpio_status_to_str(hdr_status),
+ id, sc,
+ icmnd_cmpl->scsi_status,
+ icmnd_cmpl->residual);
return;
}
 
-- 
2.5.5



[PATCH 1/1] fnic: Adding Check Condition counter to misc fnicstats

2017-02-28 Thread Satish Kharat
Just a simple counter of number of check conditions encountered on
that host.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c  | 3 +++
 drivers/scsi/fnic/fnic_stats.h | 1 +
 drivers/scsi/fnic/fnic_trace.c | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..d3b32da 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -919,6 +919,9 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
if (icmnd_cmpl->flags & FCPIO_ICMND_CMPL_RESID_UNDER)
xfer_len -= icmnd_cmpl->residual;
 
+   if (icmnd_cmpl->scsi_status == SAM_STAT_CHECK_CONDITION)
+   atomic64_inc(_stats->misc_stats.check_condition);
+
if (icmnd_cmpl->scsi_status == SAM_STAT_TASK_SET_FULL)
atomic64_inc(_stats->misc_stats.queue_fulls);
break;
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h
index 540cceb8..69acdac 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -88,6 +88,7 @@ struct misc_stats {
atomic64_t devrst_cpwq_alloc_failures;
atomic64_t io_cpwq_alloc_failures;
atomic64_t no_icmnd_itmf_cmpls;
+   atomic64_t check_condition;
atomic64_t queue_fulls;
atomic64_t rport_not_ready;
atomic64_t frame_errors;
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 5a5fa01..ec20b3e 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -357,6 +357,7 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
  "Number of Copy WQ Alloc Failures for Device Reset: %lld\n"
  "Number of Copy WQ Alloc Failures for IOs: %lld\n"
  "Number of no icmnd itmf Completions: %lld\n"
+ "Number of Check Conditions encountered: %lld\n"
  "Number of QUEUE Fulls: %lld\n"
  "Number of rport not ready: %lld\n"
  "Number of receive frame errors: %lld\n",
@@ -377,6 +378,7 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
  >misc_stats.devrst_cpwq_alloc_failures),
  (u64)atomic64_read(>misc_stats.io_cpwq_alloc_failures),
  (u64)atomic64_read(>misc_stats.no_icmnd_itmf_cmpls),
+ (u64)atomic64_read(>misc_stats.check_condition),
  (u64)atomic64_read(>misc_stats.queue_fulls),
  (u64)atomic64_read(>misc_stats.rport_not_ready),
  (u64)atomic64_read(>misc_stats.frame_errors));
-- 
2.5.5



[PATCH 1/1] scsi:fnic Avoid sending reset to fnic firmware when another reset is already in progress

2016-12-14 Thread Satish Kharat
This fix is to avoid calling fnic_fw_reset_handler through fnic_host_reset
when a finc reset is alreay in progress.

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  |  1 +
 drivers/scsi/fnic/fnic_scsi.c | 16 
 2 files changed, 17 insertions(+)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 9ddc920..9e4b770 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -248,6 +248,7 @@ struct fnic {
struct completion *remove_wait; /* device remove thread blocks */
 
atomic_t in_flight; /* io counter */
+   bool internal_reset_inprogress;
u32 _reserved;  /* fill hole */
unsigned long state_flags;  /* protected by host lock */
enum fnic_state state;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2544a37..adb3d58 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2581,6 +2581,19 @@ int fnic_host_reset(struct scsi_cmnd *sc)
unsigned long wait_host_tmo;
struct Scsi_Host *shost = sc->device->host;
struct fc_lport *lp = shost_priv(shost);
+   struct fnic *fnic = lport_priv(lp);
+   unsigned long flags;
+
+   spin_lock_irqsave(>fnic_lock, flags);
+   if (fnic->internal_reset_inprogress == 0) {
+   fnic->internal_reset_inprogress = 1;
+   } else {
+   spin_unlock_irqrestore(>fnic_lock, flags);
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "host reset in progress skipping another host reset\n");
+   return SUCCESS;
+   }
+   spin_unlock_irqrestore(>fnic_lock, flags);
 
/*
 * If fnic_reset is successful, wait for fabric login to complete
@@ -2601,6 +2614,9 @@ int fnic_host_reset(struct scsi_cmnd *sc)
}
}
 
+   spin_lock_irqsave(>fnic_lock, flags);
+   fnic->internal_reset_inprogress = 0;
+   spin_unlock_irqrestore(>fnic_lock, flags);
return ret;
 }
 
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fnic: Correcting rport check location in fnic_queuecommand_lck

2016-11-16 Thread Satish Kharat
Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 drivers/scsi/fnic/fnic_scsi.c | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index bfaba06..2544a37 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -441,30 +441,38 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
unsigned long ptr;
spinlock_t *io_lock = NULL;
int io_lock_acquired = 0;
+   struct fc_rport_libfc_priv *rp;
 
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));
+   if (!rport) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "returning DID_NO_CONNECT for IO as rport is 
NULL\n");
+   sc->result = DID_NO_CONNECT << 16;
+   done(sc);
+   return 0;
+   }
+
ret = fc_remote_port_chkready(rport);
if (ret) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "rport is not ready\n");
atomic64_inc(_stats->misc_stats.rport_not_ready);
sc->result = ret;
done(sc);
return 0;
}
 
-   if (rport) {
-   struct fc_rport_libfc_priv *rp = rport->dd_data;
-
-   if (!rp || rp->rp_state != RPORT_ST_READY) {
-   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   rp = rport->dd_data;
+   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
"returning DID_NO_CONNECT for IO as rport is 
removed\n");
-   atomic64_inc(_stats->misc_stats.rport_not_ready);
-   sc->result = DID_NO_CONNECT<<16;
-   done(sc);
-   return 0;
-   }
+   atomic64_inc(_stats->misc_stats.rport_not_ready);
+   sc->result = DID_NO_CONNECT<<16;
+   done(sc);
+   return 0;
}
 
if (lp->state != LPORT_ST_READY || !(lp->link_up))
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [fnic, snic] Updating maintainers list for Cisco FNI and SNIC drivers

2016-11-15 Thread Satish Kharat
Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 MAINTAINERS | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b3a7774..11fdf45 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3149,15 +3149,15 @@ S:  Supported
 F: drivers/clocksource
 
 CISCO FCOE HBA DRIVER
-M: Hiral Patel <hiral...@cisco.com>
-M: Suma Ramars <sram...@cisco.com>
-M: Brian Uchino <buch...@cisco.com>
+M: Satish Kharat <satis...@cisco.com>
+M: Sesidhar Baddela <sebad...@cisco.com>
+M: Karan Tilak Kumar <karti...@cisco.com>
 L: linux-scsi@vger.kernel.org
 S: Supported
 F: drivers/scsi/fnic/
 
 CISCO SCSI HBA DRIVER
-M: Narsimhulu Musini <nmus...@cisco.com>
+M: Karan Tilak Kumar <karti...@cisco.com>
 M: Sesidhar Baddela <sebad...@cisco.com>
 L: linux-scsi@vger.kernel.org
 S: Supported
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/3] Fix to cleanup aborted IO to avoid device being offlined by mid-layer

2016-03-19 Thread Satish Kharat
If an I/O times out and an abort issued by host, if the abort is
successful we need to set scsi status as DID_ABORT. Or else the
mid-layer error handler which looks for this error code, will
offline the device. Also if the original I/O is not found in fnic
firmware, we will consider the abort as successful.
The start_time assignment is moved because of the new goto.
Fnic driver version changed from 1.6.0.17a to 1.6.0.19,
version 1.6.0.18 has been skipped

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
Reviewed-by: Ewan D. Milne <emi...@redhat.com>
---
 * v1
 - Moved CMD_ABTS_STATUS assignment to else when not FCPIO_SUCCESS

 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 35 +--
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index ce129e5..52a53f8 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.17a"
+#define DRV_VERSION"1.6.0.19"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 266b909..b732fa3 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1092,6 +1092,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
atomic64_inc(
_stats->terminate_fw_timeouts);
break;
+   case FCPIO_ITMF_REJECTED:
+   FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
+   "abort reject recd. id %d\n",
+   (int)(id & FNIC_TAG_MASK));
+   break;
case FCPIO_IO_NOT_FOUND:
if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED)
atomic64_inc(_stats->abort_io_not_found);
@@ -1112,9 +1117,15 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
spin_unlock_irqrestore(io_lock, flags);
return;
}
-   CMD_ABTS_STATUS(sc) = hdr_status;
+
CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
 
+   /* If the status is IO not found consider it as success */
+   if (hdr_status == FCPIO_IO_NOT_FOUND)
+   CMD_ABTS_STATUS(sc) = FCPIO_SUCCESS;
+   else
+   CMD_ABTS_STATUS(sc) = hdr_status;
+
atomic64_dec(_stats->io_stats.active_ios);
if (atomic64_read(>io_cmpl_skip))
atomic64_dec(>io_cmpl_skip);
@@ -1927,21 +1938,33 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
 
+   start_time = io_req->start_time;
/*
 * firmware completed the abort, check the status,
-* free the io_req irrespective of failure or success
+* free the io_req if successful. If abort fails,
+* Device reset will clean the I/O.
 */
-   if (CMD_ABTS_STATUS(sc) != FCPIO_SUCCESS)
+   if (CMD_ABTS_STATUS(sc) == FCPIO_SUCCESS) {
+   CMD_SP(sc) = NULL;
+   }
+   else
+   {
ret = FAILED;
-
-   CMD_SP(sc) = NULL;
+   spin_unlock_irqrestore(io_lock, flags);
+   goto fnic_abort_cmd_end;
+   }
 
spin_unlock_irqrestore(io_lock, flags);
 
-   start_time = io_req->start_time;
fnic_release_ioreq_buf(fnic, io_req, sc);
mempool_free(io_req, fnic->io_req_pool);
 
+   if (sc->scsi_done) {
+   /* Call SCSI completion function to complete the IO */
+   sc->result = (DID_ABORT << 16);
+   sc->scsi_done(sc);
+   }
+
 fnic_abort_cmd_end:
FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no,
  sc->request->tag, sc,
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 3/3] Using rport->dd_data to check rport online instead of rport_lookup.

2016-03-19 Thread Satish Kharat
When issuing I/O we check if rport is online through libfc
rport_lookup() function which needs to be protected by mutex lock
that cannot acquired in I/O context. The change is to use midlayer
remote port’s dd_data which is preserved until its devloss timeout
and no protection is required.
The the scsi_cmnd error code is expected to be in the left 16 bits
of the result field. Changed to correct this.
Fnic driver version changed from 1.6.0.20 to 1.6.0.21

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 * v1
 - DID_NO_CONNECT left shifted 16 bits before assigning to sc->result
---
 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 20 +++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 1023eae..9ddc920 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.20"
+#define DRV_VERSION"1.6.0.21"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 026b93d..0e874a5 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -439,7 +439,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void 
(*done)(struct scsi_
int sg_count = 0;
unsigned long flags = 0;
unsigned long ptr;
-   struct fc_rport_priv *rdata;
spinlock_t *io_lock = NULL;
int io_lock_acquired = 0;
 
@@ -455,14 +454,17 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
return 0;
}
 
-   rdata = lp->tt.rport_lookup(lp, rport->port_id);
-   if (!rdata || (rdata->rp_state == RPORT_ST_DELETE)) {
-   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-   "returning IO as rport is removed\n");
-   atomic64_inc(_stats->misc_stats.rport_not_ready);
-   sc->result = DID_NO_CONNECT;
-   done(sc);
-   return 0;
+   if (rport) {
+   struct fc_rport_libfc_priv *rp = rport->dd_data;
+
+   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
+   atomic64_inc(_stats->misc_stats.rport_not_ready);
+   sc->result = DID_NO_CONNECT<<16;
+   done(sc);
+   return 0;
+   }
}
 
if (lp->state != LPORT_ST_READY || !(lp->link_up))
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] Fix to cleanup aborted IO to avoid device being offlined by mid-layer

2016-03-19 Thread Satish Kharat (satishkh)
Thanks for the review comments. I incorporated the comments, below is the 
updated patch: 


If an I/O times out and an abort issued by host, if the abort is
successful we need to set scsi status as DID_ABORT. Or else the
mid-layer error handler which looks for this error code, will
offline the device. Also if the original I/O is not found in fnic
firmware, we will consider the abort as successful.
The start_time assignment is moved because of the new goto.
Fnic driver version changed from 1.6.0.17a to 1.6.0.19,
version 1.6.0.18 has been skipped

Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 35 +--
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index ce129e5..52a53f8 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.17a"
+#define DRV_VERSION"1.6.0.19"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 266b909..b732fa3 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1092,6 +1092,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
atomic64_inc(
_stats->terminate_fw_timeouts);
break;
+   case FCPIO_ITMF_REJECTED:
+   FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
+   "abort reject recd. id %d\n",
+   (int)(id & FNIC_TAG_MASK));
+   break;
case FCPIO_IO_NOT_FOUND:
if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED)
atomic64_inc(_stats->abort_io_not_found);
@@ -1112,9 +1117,15 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic 
*fnic,
spin_unlock_irqrestore(io_lock, flags);
return;
}
-   CMD_ABTS_STATUS(sc) = hdr_status;
+
CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
 
+   /* If the status is IO not found consider it as success */
+   if (hdr_status == FCPIO_IO_NOT_FOUND)
+   CMD_ABTS_STATUS(sc) = FCPIO_SUCCESS;
+   else
+   CMD_ABTS_STATUS(sc) = hdr_status;
+
atomic64_dec(_stats->io_stats.active_ios);
if (atomic64_read(>io_cmpl_skip))
atomic64_dec(>io_cmpl_skip);
@@ -1927,21 +1938,33 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
 
+   start_time = io_req->start_time;
/*
 * firmware completed the abort, check the status,
-* free the io_req irrespective of failure or success
+* free the io_req if successful. If abort fails,
+* Device reset will clean the I/O.
 */
-   if (CMD_ABTS_STATUS(sc) != FCPIO_SUCCESS)
+   if (CMD_ABTS_STATUS(sc) == FCPIO_SUCCESS) {
+   CMD_SP(sc) = NULL;
+   }
+   else
+   {
ret = FAILED;
-
-   CMD_SP(sc) = NULL;
+   spin_unlock_irqrestore(io_lock, flags);
+   goto fnic_abort_cmd_end;
+   }
 
spin_unlock_irqrestore(io_lock, flags);
 
-   start_time = io_req->start_time;
fnic_release_ioreq_buf(fnic, io_req, sc);
mempool_free(io_req, fnic->io_req_pool);
 
+   if (sc->scsi_done) {
+   /* Call SCSI completion function to complete the IO */
+   sc->result = (DID_ABORT << 16);
+   sc->scsi_done(sc);
+   }
+
 fnic_abort_cmd_end:
FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no,
  sc->request->tag, sc,
-- 
2.4.3


From: Ewan Milne <emi...@redhat.com>
Sent: Monday, March 14, 2016 12:59 PM
To: Satish Kharat (satishkh)
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/5] Fix to cleanup aborted IO to avoid device being 
offlined by mid-layer

On Mon, 2016-03-14 at 11:14 -0700, Satish Kharat wrote:
> If an I/O times out and an abort issued by host, if the abort is
> successful we need to set scsi status as DID_ABORT. Or else the
> mid-layer error handler which looks for this error code, will
> offline the device. Also if the original I/O is not found in fnic
> firmware, we will consider the abort as successful.
> Fnic driver version changed from 1.6.0.17a to 1.6.0.19,
> v

[PATCH v1 2/3] Cleanup the I/O pending with fw and has timed out and is used to issue LUN reset

2016-03-18 Thread Satish Kharat
In case of LUN reset, the device reset command is issued with one of
the I/Os that has timed out on that LUN. The change is to also return
this I/O with error status set to DID_RESET. In case when the reset
is issued using the sg_reset tool (from sg3_utils) it is a new command
and new_sc is set to 1.
Fnic driver version changed from 1.6.0.19 to 1.6.0.20

Signed-off-by: Satish Kharat <satis...@cisco.com>
Signed-off-by: Sesidhar Baddela <sebad...@cisco.com>
---
 * v1
 - new_sc is set to 1 in cases like lunreset from sg_reset
---
 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 38 --
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 52a53f8..1023eae 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.19"
+#define DRV_VERSION"1.6.0.20"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index b732fa3..026b93d 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2042,7 +2042,9 @@ lr_io_req_end:
  * successfully aborted, 1 otherwise
  */
 static int fnic_clean_pending_aborts(struct fnic *fnic,
-struct scsi_cmnd *lr_sc)
+struct scsi_cmnd *lr_sc,
+bool new_sc)
+
 {
int tag, abt_tag;
struct fnic_io_req *io_req;
@@ -2060,10 +2062,10 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
spin_lock_irqsave(io_lock, flags);
sc = scsi_host_find_tag(fnic->lport->host, tag);
/*
-* ignore this lun reset cmd or cmds that do not belong to
-* this lun
+* ignore this lun reset cmd if issued using new SC
+* or cmds that do not belong to this lun
 */
-   if (!sc || sc == lr_sc || sc->device != lun_dev) {
+   if (!sc || ((sc == lr_sc) && new_sc) || sc->device != lun_dev) {
spin_unlock_irqrestore(io_lock, flags);
continue;
}
@@ -2169,11 +2171,27 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
goto clean_pending_aborts_end;
}
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
-   CMD_SP(sc) = NULL;
+
+   /* original sc used for lr is handled by dev reset code */
+   if (sc != lr_sc)
+   CMD_SP(sc) = NULL;
spin_unlock_irqrestore(io_lock, flags);
 
-   fnic_release_ioreq_buf(fnic, io_req, sc);
-   mempool_free(io_req, fnic->io_req_pool);
+   /* original sc used for lr is handled by dev reset code */
+   if (sc != lr_sc) {
+   fnic_release_ioreq_buf(fnic, io_req, sc);
+   mempool_free(io_req, fnic->io_req_pool);
+   }
+
+   /*
+* Any IO is returned during reset, it needs to call scsi_done
+* to return the scsi_cmnd to upper layer.
+*/
+   if (sc->scsi_done) {
+   /* Set result to let upper SCSI layer retry */
+   sc->result = DID_RESET << 16;
+   sc->scsi_done(sc);
+   }
}
 
schedule_timeout(msecs_to_jiffies(2 * fnic->config.ed_tov));
@@ -2267,6 +2285,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
int tag = 0;
DECLARE_COMPLETION_ONSTACK(tm_done);
int tag_gen_flag = 0;   /*to track tags allocated by fnic driver*/
+   bool new_sc = 0;
 
/* Wait for rport to unblock */
fc_block_scsi_eh(sc);
@@ -2312,13 +2331,12 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 * fix the way the EH ioctls work for real, but until
 * that happens we fail these explicit requests here.
 */
-   if (shost_use_blk_mq(sc->device->host))
-   goto fnic_device_reset_end;
 
tag = fnic_scsi_host_start_tag(fnic, sc);
if (unlikely(tag == SCSI_NO_TAG))
goto fnic_device_reset_end;
tag_gen_flag = 1;
+   new_sc=1;
}
io_lock = fnic_io_lock_hash(fnic, sc);
spin_lock_irqsave(io_lock, flags);
@@ -2453,7 +2471,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 * the lun reset cmd. If all cmds get cleaned, the lun reset
 * succ

[PATCH 4/5] Setting scsi host template to indicate that fnic does not support multiqueue

2016-03-14 Thread Satish Kharat
Fnic does not support mutiqueue. Setting the scsi_host_template in
fnic_host_template to indicate that.

Changing fnic_version from 1.6.0.21 to 1.6.0.22

Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  | 2 +-
 drivers/scsi/fnic/fnic_main.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 9ddc920..35264c7 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.21"
+#define DRV_VERSION"1.6.0.22"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 58ce902..fa8a121 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -119,6 +119,7 @@ static struct scsi_host_template fnic_host_template = {
.max_sectors = 0x,
.shost_attrs = fnic_attrs,
.track_queue_depth = 1,
+   .disable_blk_mq = 1,
 };
 
 static void
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] Leftshift returned scsi_cmnd error code 16 bits

2016-03-14 Thread Satish Kharat
The the scsi_cmnd error code is expected to be in the left 16 bits
of the result field. Change is to correct this.

Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  | 2 +-
 drivers/scsi/fnic/fnic_scsi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 35264c7..e4e22f1 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.22"
+#define DRV_VERSION"1.6.0.24"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 8492143..92a4ca3 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -461,7 +461,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void 
(*done)(struct scsi_
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
"returning DID_NO_CONNECT for IO as rport is 
removed\n");
atomic64_inc(_stats->misc_stats.rport_not_ready);
-   sc->result = DID_NO_CONNECT;
+   sc->result = DID_NO_CONNECT<<16;
done(sc);
return 0;
}
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] Cleanup the I/O that has timed out and is used to issue LUN reset

2016-03-14 Thread Satish Kharat
In case of LUN reset, the device reset command is issued with one of
the I/Os that has timed out on that LUN. The change is to also return
this I/O with error status set to DID_RESET.
Fnic driver version changed from 1.6.0.19 to 1.6.0.20

Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 35 +++
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 52a53f8..1023eae 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.19"
+#define DRV_VERSION"1.6.0.20"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index b9732b1..a3e0f69 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2041,7 +2041,9 @@ lr_io_req_end:
  * successfully aborted, 1 otherwise
  */
 static int fnic_clean_pending_aborts(struct fnic *fnic,
-struct scsi_cmnd *lr_sc)
+struct scsi_cmnd *lr_sc,
+bool new_sc)
+
 {
int tag, abt_tag;
struct fnic_io_req *io_req;
@@ -2059,10 +2061,10 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
spin_lock_irqsave(io_lock, flags);
sc = scsi_host_find_tag(fnic->lport->host, tag);
/*
-* ignore this lun reset cmd or cmds that do not belong to
-* this lun
+* ignore this lun reset cmd if issued using new SC
+* or cmds that do not belong to this lun
 */
-   if (!sc || sc == lr_sc || sc->device != lun_dev) {
+   if (!sc || ((sc == lr_sc) && new_sc) || sc->device != lun_dev) {
spin_unlock_irqrestore(io_lock, flags);
continue;
}
@@ -2168,11 +2170,27 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
goto clean_pending_aborts_end;
}
CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
-   CMD_SP(sc) = NULL;
+
+   /* original sc used for lr is handled by dev reset code */
+   if (sc != lr_sc)
+   CMD_SP(sc) = NULL;
spin_unlock_irqrestore(io_lock, flags);
 
-   fnic_release_ioreq_buf(fnic, io_req, sc);
-   mempool_free(io_req, fnic->io_req_pool);
+   /* original sc used for lr is handled by dev reset code */
+   if (sc != lr_sc) {
+   fnic_release_ioreq_buf(fnic, io_req, sc);
+   mempool_free(io_req, fnic->io_req_pool);
+   }
+
+   /*
+* Any IO is returned during reset, it needs to call scsi_done
+* to return the scsi_cmnd to upper layer.
+*/
+   if (sc->scsi_done) {
+   /* Set result to let upper SCSI layer retry */
+   sc->result = DID_RESET << 16;
+   sc->scsi_done(sc);
+   }
}
 
schedule_timeout(msecs_to_jiffies(2 * fnic->config.ed_tov));
@@ -2266,6 +2284,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
int tag = 0;
DECLARE_COMPLETION_ONSTACK(tm_done);
int tag_gen_flag = 0;   /*to track tags allocated by fnic driver*/
+   bool new_sc = 0;
 
/* Wait for rport to unblock */
fc_block_scsi_eh(sc);
@@ -2452,7 +2471,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 * the lun reset cmd. If all cmds get cleaned, the lun reset
 * succeeds
 */
-   if (fnic_clean_pending_aborts(fnic, sc)) {
+   if (fnic_clean_pending_aborts(fnic, sc, new_sc)) {
spin_lock_irqsave(io_lock, flags);
io_req = (struct fnic_io_req *)CMD_SP(sc);
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] Using rport->dd_data to check rport online instead of rport_lookup.

2016-03-14 Thread Satish Kharat
When issuing I/O we check if rport is online through libfc
rport_lookup() function which needs to be protected by mutex lock
that cannot acquired in I/O context. The change is to use midlayer
remote port’s dd_data which is preserved until its devloss timeout
and no protection is required.

Fnic driver version changed from 1.6.0.20 to 1.6.0.21

Signed-off-by: Satish Kharat <satis...@cisco.com>
---
 drivers/scsi/fnic/fnic.h  |  2 +-
 drivers/scsi/fnic/fnic_scsi.c | 20 +++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 1023eae..9ddc920 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
 
 #define DRV_NAME   "fnic"
 #define DRV_DESCRIPTION"Cisco FCoE HBA Driver"
-#define DRV_VERSION"1.6.0.20"
+#define DRV_VERSION"1.6.0.21"
 #define PFXDRV_NAME ": "
 #define DFX DRV_NAME "%d: "
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index a3e0f69..8492143 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -439,7 +439,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void 
(*done)(struct scsi_
int sg_count = 0;
unsigned long flags = 0;
unsigned long ptr;
-   struct fc_rport_priv *rdata;
spinlock_t *io_lock = NULL;
int io_lock_acquired = 0;
 
@@ -455,14 +454,17 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
return 0;
}
 
-   rdata = lp->tt.rport_lookup(lp, rport->port_id);
-   if (!rdata || (rdata->rp_state == RPORT_ST_DELETE)) {
-   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-   "returning IO as rport is removed\n");
-   atomic64_inc(_stats->misc_stats.rport_not_ready);
-   sc->result = DID_NO_CONNECT;
-   done(sc);
-   return 0;
+   if (rport) {
+   struct fc_rport_libfc_priv *rp = rport->dd_data;
+
+   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
+   atomic64_inc(_stats->misc_stats.rport_not_ready);
+   sc->result = DID_NO_CONNECT;
+   done(sc);
+   return 0;
+   }
}
 
if (lp->state != LPORT_ST_READY || !(lp->link_up))
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html