Re: Kernel crash with unsupported DIF protection type

2012-09-21 Thread Hannes Reinecke
On 09/20/2012 09:53 PM, Martin K. Petersen wrote:
 Hannes == Hannes Reinecke h...@suse.de writes:
 
 Hannes I recently got my hands on some weird drives, insisting on
 Hannes having been formatted with protection type 7:
 
 Lovely :|
 
Hehe. Probably _really_ future drives :-)

 
 Hannes I've attached a tentative patch, which allows the system to
 Hannes boot.  However, I'm not completely happy with that, as the
 Hannes capacity is _still_ updated after revalidation:
 
 How about this?
 
 
 sd: Ensure we correctly disable devices with unknown protection type
 
 We set the capacity to zero when we discovered a device formatted with
 an unknown DIF protection type. However, the read_capacity code would
 override the capacity and cause the device to be enabled regardless.
 
 Make sd_read_protection_type() return an error if the protection type is
 unknown. Also prevent duplicate printk lines when the device is being
 revalidated.
 
 Reported-by: Hannes Reinecke h...@suse.de
 Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
 
 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
 index 1cf2d5d..1c54564 100644
 --- a/drivers/scsi/sd.c
 +++ b/drivers/scsi/sd.c
 @@ -1820,34 +1820,42 @@ sd_spinup_disk(struct scsi_disk *sdkp)
  /*
   * Determine whether disk supports Data Integrity Field.
   */
 -static void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
 *buffer)
 +static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
 *buffer)
  {
   struct scsi_device *sdp = sdkp-device;
   u8 type;
 + int ret = 0;
  
   if (scsi_device_protection(sdp) == 0 || (buffer[12]  1) == 0)
 - return;
 + return ret;
  
   type = ((buffer[12]  1)  7) + 1; /* P_TYPE 0 = Type 1 */
  
 - if (type == sdkp-protection_type || !sdkp-first_scan)
 - return;
 + if (type  SD_DIF_TYPE3_PROTECTION)
 + ret = -ENODEV;
 + else if (scsi_host_dif_capable(sdp-host, type))
 + ret = 1;
 +
 + if (sdkp-first_scan || type != sdkp-protection_type)
 + switch (ret) {
 + case -ENODEV:
 + sd_printk(KERN_ERR, sdkp, formatted with unsupported \
 +protection type %u. Disabling disk!\n,
 +   type);
 + break;
 + case 1:
 + sd_printk(KERN_NOTICE, sdkp,
 +   Enabling DIF Type %u protection\n, type);
 + break;
 + case 0:
 + sd_printk(KERN_NOTICE, sdkp,
 +   Disabling DIF Type %u protection\n, type);
 + break;
 + }
  
   sdkp-protection_type = type;
  
 - if (type  SD_DIF_TYPE3_PROTECTION) {
 - sd_printk(KERN_ERR, sdkp, formatted with unsupported  \
 -   protection type %u. Disabling disk!\n, type);
 - sdkp-capacity = 0;
 - return;
 - }
 -
 - if (scsi_host_dif_capable(sdp-host, type))
 - sd_printk(KERN_NOTICE, sdkp,
 -   Enabling DIF Type %u protection\n, type);
 - else
 - sd_printk(KERN_NOTICE, sdkp,
 -   Disabling DIF Type %u protection\n, type);
 + return ret;
  }
  
  static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device 
 *sdp,
 @@ -1943,7 +1951,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, 
 struct scsi_device *sdp,
   sector_size = get_unaligned_be32(buffer[8]);
   lba = get_unaligned_be64(buffer[0]);
  
 - sd_read_protection_type(sdkp, buffer);
 + if (sd_read_protection_type(sdkp, buffer)  0) {
 + sdkp-capacity = 0;
 + return -ENODEV;
 + }
  
   if ((sizeof(sdkp-capacity) == 4)  (lba = 0xULL)) {
   sd_printk(KERN_ERR, sdkp, Too big for this kernel. Use a 
 
Yup. That's what I had in mind.

Acked-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)


--
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] qla2xxx: Fix endianness of task management response code

2012-09-21 Thread James Bottomley
On Wed, 2012-09-19 at 07:09 -0700, Roland Dreier wrote:
 On Wed, Sep 19, 2012 at 12:59 AM, James Bottomley
 james.bottom...@hansenpartnership.com wrote:
  Is this also true on Big Endian Hardware?  Because the fix you have
  assumes that the TIO IOCB with SCSI status mode 1 should be CPU
  endian ... that doesn't look right since this is passed directly over
  the PCI bus (and the PCI bus is little endian), so shouldn't the correct
  fix be to replace cpu_to_be32 with cpu_to_le32?
 
 After my patch the assignment is to a u8, and that byte is in the right
 place in memory.  So I don't think there's any endianness bug.

The data in status1 appears to get used a word at a time ... what about
the other three bytes you don't set; are they guaranteed to be zero? (in
which case this works, it just looks wrong from the way the thing is
used in the rest of the code).

James


--
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] qla2xxx: Fix endianness of task management response code

2012-09-21 Thread Roland Dreier
On Fri, Sep 21, 2012 at 1:02 AM, James Bottomley
james.bottom...@hansenpartnership.com wrote:
 The data in status1 appears to get used a word at a time ... what about
 the other three bytes you don't set; are they guaranteed to be zero? (in
 which case this works, it just looks wrong from the way the thing is
 used in the rest of the code).

Yes, the structure comes from

ctio = (struct ctio7_to_24xx *)qla2x00_alloc_iocbs(ha, NULL);

a few lines earlier, and that does:

/* Prep packet */
memset(pkt, 0, REQUEST_ENTRY_SIZE);

before

return pkt;
--
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] iscsi: Don't disable BH on BH context

2012-09-21 Thread Michael Christie

On Aug 20, 2012, at 8:28 PM, Ying Xue ying@windriver.com wrote:

 Since we have already in BH context when iscsi_sw_tcp_write_space()
 is called, it's unnecessary to disable BH.

Hey,

I do don't think this is right anymore. It looks like it can be called in 
sock_setsockopt.

 
 Signed-off-by: Ying Xue ying@windriver.com
 Acked-by: Michael Christie micha...@cs.wisc.edu
 ---
 drivers/scsi/iscsi_tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
 index 9220861..d763857 100644
 --- a/drivers/scsi/iscsi_tcp.c
 +++ b/drivers/scsi/iscsi_tcp.c
 @@ -194,7 +194,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
   struct iscsi_sw_tcp_conn *tcp_sw_conn;
   void (*old_write_space)(struct sock *);
 
 - read_lock_bh(sk-sk_callback_lock);
 + read_lock(sk-sk_callback_lock);
   conn = sk-sk_user_data;
   if (!conn) {
   read_unlock_bh(sk-sk_callback_lock);
 @@ -204,7 +204,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
   tcp_conn = conn-dd_data;
   tcp_sw_conn = tcp_conn-dd_data;
   old_write_space = tcp_sw_conn-old_write_space;
 - read_unlock_bh(sk-sk_callback_lock);
 + read_unlock(sk-sk_callback_lock);
 
   old_write_space(sk);
 
 -- 
 1.7.11
 
 --
 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

--
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] iscsi: Don't disable BH on BH context

2012-09-21 Thread Ying Xue

Michael Christie wrote:

On Aug 20, 2012, at 8:28 PM, Ying Xue ying@windriver.com wrote:

  

Since we have already in BH context when iscsi_sw_tcp_write_space()
is called, it's unnecessary to disable BH.



Hey,

I do don't think this is right anymore. It looks like it can be called in 
sock_setsockopt.

  
I just finds it seems this is an unnecessary action to disable BH on BH 
context when I look through iscsi code.
If you can confirm the iscsi_sw_tcp_write_space() is also called in 
process context, please ignore the noise.


Regards,
Ying



Signed-off-by: Ying Xue ying@windriver.com
Acked-by: Michael Christie micha...@cs.wisc.edu
---
drivers/scsi/iscsi_tcp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 9220861..d763857 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -194,7 +194,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
struct iscsi_sw_tcp_conn *tcp_sw_conn;
void (*old_write_space)(struct sock *);

-   read_lock_bh(sk-sk_callback_lock);
+   read_lock(sk-sk_callback_lock);
conn = sk-sk_user_data;
if (!conn) {
read_unlock_bh(sk-sk_callback_lock);
@@ -204,7 +204,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
tcp_conn = conn-dd_data;
tcp_sw_conn = tcp_conn-dd_data;
old_write_space = tcp_sw_conn-old_write_space;
-   read_unlock_bh(sk-sk_callback_lock);
+   read_unlock(sk-sk_callback_lock);

old_write_space(sk);

--
1.7.11

--
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




  


--
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] aic7xxx_old: silence GCC warnings

2012-09-21 Thread Paul Bolle
Building the aic7xxx_old driver triggers these GCC warnings:
drivers/scsi/aic7xxx_old.c:7901:5: warning: case value '257' not in 
enumerated type 'ahc_chip' [-Wswitch]
drivers/scsi/aic7xxx_old.c:7898:5: warning: case value '513' not in 
enumerated type 'ahc_chip' [-Wswitch]
drivers/scsi/aic7xxx_old.c:8517:5: warning: case value '257' not in 
enumerated type 'ahc_chip' [-Wswitch]
drivers/scsi/aic7xxx_old.c:8510:5: warning: case value '513' not in 
enumerated type 'ahc_chip' [-Wswitch]

Fix these warnings by adopting the idiom used elsewhere in this driver.
Since AHC_EISA and AHC_VL are only ever set for AHC_AIC7770 this fix
should not lead to any functional change.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
0) I noticed these warnings while building v3.6-rc6 on current Fedora
17, using Fedora's default config.

1) Compile tested only.

2) This patch is not checkpatch clean. But this file actually triggers
thousands of checkpatch errors and warnings:
total: 4779 errors, 7528 warnings, 11149 lines checked

So I didn't bother to fix the few errors and warnings this patch
triggers by sticking to this file (lack of) coding style.

 drivers/scsi/aic7xxx_old.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 5b212f0..1a381c8 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -7893,12 +7893,12 @@ aic7xxx_register(struct scsi_host_template *template, 
struct aic7xxx_host *p,
 
   printk(KERN_INFO (scsi%d) %s found at , p-host_no,
 board_names[p-board_name_index]);
-  switch(p-chip)
+  switch(p-chip  ~AHC_CHIPID_MASK)
   {
-case (AHC_AIC7770|AHC_EISA):
+case AHC_EISA:
   printk(EISA slot %d\n, p-pci_device_fn);
   break;
-case (AHC_AIC7770|AHC_VL):
+case AHC_VL:
   printk(VLB slot %d\n, p-pci_device_fn);
   break;
 default:
@@ -8505,16 +8505,16 @@ aic7xxx_load_seeprom(struct aic7xxx_host *p, unsigned 
char *sxfrctl1)
   {
 printk(KERN_INFO aic7xxx: Loading serial EEPROM...);
   }
-  switch (p-chip)
+  switch (p-chip  ~AHC_CHIPID_MASK)
   {
-case (AHC_AIC7770|AHC_EISA):  /* None of these adapters have seeproms. */
+case AHC_EISA:  /* None of these adapters have seeproms. */
   if (aic_inb(p, SCSICONF)  TERM_ENB)
 p-flags |= AHC_TERM_ENB_A;
   if ( (p-features  AHC_TWIN)  (aic_inb(p, SCSICONF + 1)  TERM_ENB) )
 p-flags |= AHC_TERM_ENB_B;
   break;
 
-case (AHC_AIC7770|AHC_VL):
+case AHC_VL:
   have_seeprom = read_284x_seeprom(p, (struct seeprom_config *) scarray);
   break;
 
-- 
1.7.11.4

--
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] mvsas: use correct named constants

2012-09-21 Thread Paul Bolle
Building the mvsas driver triggers these GCC warnings:
drivers/scsi/mvsas/mv_sas.c:1156:34: warning: comparison between 'enum 
sas_device_type' and 'enum sas_dev_type' [-Wenum-compare]
drivers/scsi/mvsas/mv_sas.c:1159:39: warning: comparison between 'enum 
sas_device_type' and 'enum sas_dev_type' [-Wenum-compare]

Silence these warnings by using the named constants from enum
sas_device_type with the same value as the currently used named
constants.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
0) I noticed these warnings while building v3.6-rc6 on current Fedora
17, using Fedora's default config.

1) Compile tested only.

 drivers/scsi/mvsas/mv_sas.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 4539d59..f663d9a 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -1153,10 +1153,10 @@ void mvs_update_phyinfo(struct mvs_info *mvi, int i, 
int get_st)
phy-identify.device_type =
phy-att_dev_info  PORT_DEV_TYPE_MASK;
 
-   if (phy-identify.device_type == SAS_END_DEV)
+   if (phy-identify.device_type == SAS_END_DEVICE)
phy-identify.target_port_protocols =
SAS_PROTOCOL_SSP;
-   else if (phy-identify.device_type != NO_DEVICE)
+   else if (phy-identify.device_type != SAS_PHY_UNUSED)
phy-identify.target_port_protocols =
SAS_PROTOCOL_SMP;
if (oob_done)
-- 
1.7.11.4

--
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: Kernel crash with unsupported DIF protection type

2012-09-21 Thread Hannes Reinecke
On 09/20/2012 09:53 PM, Martin K. Petersen wrote:
 Hannes == Hannes Reinecke h...@suse.de writes:
 
 Hannes I recently got my hands on some weird drives, insisting on
 Hannes having been formatted with protection type 7:
 
 Lovely :|
 
 
 Hannes I've attached a tentative patch, which allows the system to
 Hannes boot.  However, I'm not completely happy with that, as the
 Hannes capacity is _still_ updated after revalidation:
 
 How about this?
 
 
 sd: Ensure we correctly disable devices with unknown protection type
 
 We set the capacity to zero when we discovered a device formatted with
 an unknown DIF protection type. However, the read_capacity code would
 override the capacity and cause the device to be enabled regardless.
 
 Make sd_read_protection_type() return an error if the protection type is
 unknown. Also prevent duplicate printk lines when the device is being
 revalidated.
 
 Reported-by: Hannes Reinecke h...@suse.de
 Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
 
 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
 index 1cf2d5d..1c54564 100644
 --- a/drivers/scsi/sd.c
 +++ b/drivers/scsi/sd.c
 @@ -1820,34 +1820,42 @@ sd_spinup_disk(struct scsi_disk *sdkp)
  /*
   * Determine whether disk supports Data Integrity Field.
   */
 -static void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
 *buffer)
 +static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
 *buffer)
  {
   struct scsi_device *sdp = sdkp-device;
   u8 type;
 + int ret = 0;
  
   if (scsi_device_protection(sdp) == 0 || (buffer[12]  1) == 0)
 - return;
 + return ret;
  
   type = ((buffer[12]  1)  7) + 1; /* P_TYPE 0 = Type 1 */
  
 - if (type == sdkp-protection_type || !sdkp-first_scan)
 - return;
 + if (type  SD_DIF_TYPE3_PROTECTION)
 + ret = -ENODEV;
 + else if (scsi_host_dif_capable(sdp-host, type))
 + ret = 1;
 +
 + if (sdkp-first_scan || type != sdkp-protection_type)
 + switch (ret) {
 + case -ENODEV:
 + sd_printk(KERN_ERR, sdkp, formatted with unsupported \
 +protection type %u. Disabling disk!\n,
 +   type);
 + break;
 + case 1:
 + sd_printk(KERN_NOTICE, sdkp,
 +   Enabling DIF Type %u protection\n, type);
 + break;
 + case 0:
 + sd_printk(KERN_NOTICE, sdkp,
 +   Disabling DIF Type %u protection\n, type);
 + break;
 + }
  
   sdkp-protection_type = type;
  
 - if (type  SD_DIF_TYPE3_PROTECTION) {
 - sd_printk(KERN_ERR, sdkp, formatted with unsupported  \
 -   protection type %u. Disabling disk!\n, type);
 - sdkp-capacity = 0;
 - return;
 - }
 -
 - if (scsi_host_dif_capable(sdp-host, type))
 - sd_printk(KERN_NOTICE, sdkp,
 -   Enabling DIF Type %u protection\n, type);
 - else
 - sd_printk(KERN_NOTICE, sdkp,
 -   Disabling DIF Type %u protection\n, type);
 + return ret;
  }
  
  static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device 
 *sdp,
 @@ -1943,7 +1951,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, 
 struct scsi_device *sdp,
   sector_size = get_unaligned_be32(buffer[8]);
   lba = get_unaligned_be64(buffer[0]);
  
 - sd_read_protection_type(sdkp, buffer);
 + if (sd_read_protection_type(sdkp, buffer)  0) {
 + sdkp-capacity = 0;
 + return -ENODEV;
 + }
  
   if ((sizeof(sdkp-capacity) == 4)  (lba = 0xULL)) {
   sd_printk(KERN_ERR, sdkp, Too big for this kernel. Use a 

Hehe. It helps to actually test patches.

Now I get:
sd 6:0:0:0: [sdb] formatted with unsupported protection type 7.
Disabling disk!

and silence after that.
However, I still get:

sd 6:0:0:0: [sdb] Write Protect is off
sd 6:0:0:0: [sdb] Mode Sense: cf 00 10 08
sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled,
supports DPO and FUA
sd 6:0:0:0: [sdb] Enabling DIX T10-DIF-TYPE1-CRC protection
sd 6:0:0:0: [sdb] Attached SCSI disk

which is a bit odd, given that the disk is disabled.
Plus that we never actually claimed to support type1.
So maybe we should add this patch, too?

diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 0cb39ff..e0500bf 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -320,7 +320,7 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
dif = 0; dix = 1;
}

-   if (!dix)
+   if (!dix || type  SD_DIF_TYPE3_PROTECTION)
return;

/* Enable DMA of protection information */

But then, main issue is resolved, as the system continues to boot.
So my Acked-by: still stands.

Cheers,


Re: Kernel crash with unsupported DIF protection type

2012-09-21 Thread Martin K. Petersen
 Hannes == Hannes Reinecke h...@suse.de writes:

Hannes Hehe. It helps to actually test patches.

I did. However, with scsi_debug I have all sorts of sanity checks in
place. Not sure what your disk is connected to?


Hannes sd 6:0:0:0: [sdb] Write Protect is off sd 6:0:0:0: [sdb] Mode
Hannes Sense: cf 00 10 08 sd 6:0:0:0: [sdb] Write cache: disabled, read
Hannes cache: enabled, supports DPO and FUA sd 6:0:0:0: [sdb] Enabling
Hannes DIX T10-DIF-TYPE1-CRC protection sd 6:0:0:0: [sdb] Attached SCSI
Hannes disk

DIX and DIF are orthogonal. If the HBA driver does not support the
appropriate DIF type we'll still enable DIX. That's a feature.

But there are two issues here. First we should not configure DIX if
capacity is 0. Secondly, we need some bounds checking in the host mask
checking to protect against crackpot disks.

Updated patch below...


sd: Ensure we correctly disable devices with unknown protection type

We set the capacity to zero when we discovered a device formatted with
an unknown DIF protection type. However, the read_capacity code would
override the capacity and cause the device to be enabled regardless.

Make sd_read_protection_type() return an error if the protection type is
unknown. Also prevent duplicate printk lines when the device is being
revalidated.

Reported-by: Hannes Reinecke h...@suse.de
Signed-off-by: Martin K. Petersen martin.peter...@oracle.com

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1cf2d5d..7a22db3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1820,34 +1820,42 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 /*
  * Determine whether disk supports Data Integrity Field.
  */
-static void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
+static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
 {
struct scsi_device *sdp = sdkp-device;
u8 type;
+   int ret = 0;
 
if (scsi_device_protection(sdp) == 0 || (buffer[12]  1) == 0)
-   return;
+   return ret;
 
type = ((buffer[12]  1)  7) + 1; /* P_TYPE 0 = Type 1 */
 
-   if (type == sdkp-protection_type || !sdkp-first_scan)
-   return;
+   if (type  SD_DIF_TYPE3_PROTECTION)
+   ret = -ENODEV;
+   else if (scsi_host_dif_capable(sdp-host, type))
+   ret = 1;
+
+   if (sdkp-first_scan || type != sdkp-protection_type)
+   switch (ret) {
+   case -ENODEV:
+   sd_printk(KERN_ERR, sdkp, formatted with unsupported \
+  protection type %u. Disabling disk!\n,
+ type);
+   break;
+   case 1:
+   sd_printk(KERN_NOTICE, sdkp,
+ Enabling DIF Type %u protection\n, type);
+   break;
+   case 0:
+   sd_printk(KERN_NOTICE, sdkp,
+ Disabling DIF Type %u protection\n, type);
+   break;
+   }
 
sdkp-protection_type = type;
 
-   if (type  SD_DIF_TYPE3_PROTECTION) {
-   sd_printk(KERN_ERR, sdkp, formatted with unsupported  \
- protection type %u. Disabling disk!\n, type);
-   sdkp-capacity = 0;
-   return;
-   }
-
-   if (scsi_host_dif_capable(sdp-host, type))
-   sd_printk(KERN_NOTICE, sdkp,
- Enabling DIF Type %u protection\n, type);
-   else
-   sd_printk(KERN_NOTICE, sdkp,
- Disabling DIF Type %u protection\n, type);
+   return ret;
 }
 
 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device 
*sdp,
@@ -1943,7 +1951,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, 
struct scsi_device *sdp,
sector_size = get_unaligned_be32(buffer[8]);
lba = get_unaligned_be64(buffer[0]);
 
-   sd_read_protection_type(sdkp, buffer);
+   if (sd_read_protection_type(sdkp, buffer)  0) {
+   sdkp-capacity = 0;
+   return -ENODEV;
+   }
 
if ((sizeof(sdkp-capacity) == 4)  (lba = 0xULL)) {
sd_printk(KERN_ERR, sdkp, Too big for this kernel. Use a 
@@ -2788,7 +2799,8 @@ static void sd_probe_async(void *data, async_cookie_t 
cookie)
}
 
add_disk(gd);
-   sd_dif_config_host(sdkp);
+   if (sdkp-capacity)
+   sd_dif_config_host(sdkp);
 
sd_revalidate_disk(gd);
 
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5f7d5b3..b19223d 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -871,7 +871,11 @@ static inline unsigned int scsi_host_dif_capable(struct 
Scsi_Host *shost, unsign
static unsigned char cap[] = { 0,
   SHOST_DIF_TYPE1_PROTECTION,
   

Re: Kernel crash with unsupported DIF protection type

2012-09-21 Thread Martin K. Petersen
 Martin == Martin K Petersen martin.peter...@oracle.com writes:

Martin Updated patch below...

This time without mangled closing bracket...


sd: Ensure we correctly disable devices with unknown protection type

We set the capacity to zero when we discovered a device formatted with
an unknown DIF protection type. However, the read_capacity code would
override the capacity and cause the device to be enabled regardless.

Make sd_read_protection_type() return an error if the protection type is
unknown. Also prevent duplicate printk lines when the device is being
revalidated.

Reported-by: Hannes Reinecke h...@suse.de
Signed-off-by: Martin K. Petersen martin.peter...@oracle.com

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1cf2d5d..7a22db3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1820,34 +1820,42 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 /*
  * Determine whether disk supports Data Integrity Field.
  */
-static void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
+static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char 
*buffer)
 {
struct scsi_device *sdp = sdkp-device;
u8 type;
+   int ret = 0;
 
if (scsi_device_protection(sdp) == 0 || (buffer[12]  1) == 0)
-   return;
+   return ret;
 
type = ((buffer[12]  1)  7) + 1; /* P_TYPE 0 = Type 1 */
 
-   if (type == sdkp-protection_type || !sdkp-first_scan)
-   return;
+   if (type  SD_DIF_TYPE3_PROTECTION)
+   ret = -ENODEV;
+   else if (scsi_host_dif_capable(sdp-host, type))
+   ret = 1;
+
+   if (sdkp-first_scan || type != sdkp-protection_type)
+   switch (ret) {
+   case -ENODEV:
+   sd_printk(KERN_ERR, sdkp, formatted with unsupported \
+  protection type %u. Disabling disk!\n,
+ type);
+   break;
+   case 1:
+   sd_printk(KERN_NOTICE, sdkp,
+ Enabling DIF Type %u protection\n, type);
+   break;
+   case 0:
+   sd_printk(KERN_NOTICE, sdkp,
+ Disabling DIF Type %u protection\n, type);
+   break;
+   }
 
sdkp-protection_type = type;
 
-   if (type  SD_DIF_TYPE3_PROTECTION) {
-   sd_printk(KERN_ERR, sdkp, formatted with unsupported  \
- protection type %u. Disabling disk!\n, type);
-   sdkp-capacity = 0;
-   return;
-   }
-
-   if (scsi_host_dif_capable(sdp-host, type))
-   sd_printk(KERN_NOTICE, sdkp,
- Enabling DIF Type %u protection\n, type);
-   else
-   sd_printk(KERN_NOTICE, sdkp,
- Disabling DIF Type %u protection\n, type);
+   return ret;
 }
 
 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device 
*sdp,
@@ -1943,7 +1951,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, 
struct scsi_device *sdp,
sector_size = get_unaligned_be32(buffer[8]);
lba = get_unaligned_be64(buffer[0]);
 
-   sd_read_protection_type(sdkp, buffer);
+   if (sd_read_protection_type(sdkp, buffer)  0) {
+   sdkp-capacity = 0;
+   return -ENODEV;
+   }
 
if ((sizeof(sdkp-capacity) == 4)  (lba = 0xULL)) {
sd_printk(KERN_ERR, sdkp, Too big for this kernel. Use a 
@@ -2788,7 +2799,8 @@ static void sd_probe_async(void *data, async_cookie_t 
cookie)
}
 
add_disk(gd);
-   sd_dif_config_host(sdkp);
+   if (sdkp-capacity)
+   sd_dif_config_host(sdkp);
 
sd_revalidate_disk(gd);
 
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5f7d5b3..4908480 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -873,6 +873,9 @@ static inline unsigned int scsi_host_dif_capable(struct 
Scsi_Host *shost, unsign
   SHOST_DIF_TYPE2_PROTECTION,
   SHOST_DIF_TYPE3_PROTECTION };
 
+   if (target_type  SHOST_DIF_TYPE3_PROTECTION)
+   return 0;
+
return shost-prot_capabilities  cap[target_type] ? target_type : 0;
 }
 
@@ -884,6 +887,9 @@ static inline unsigned int scsi_host_dix_capable(struct 
Scsi_Host *shost, unsign
   SHOST_DIX_TYPE2_PROTECTION,
   SHOST_DIX_TYPE3_PROTECTION };
 
+   if (target_type  SHOST_DIX_TYPE3_PROTECTION)
+   return 0;
+
return shost-prot_capabilities  cap[target_type];
 #endif
return 0;
--
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  

Re: [RFC PATCH] libata: scsi: flush cache on scsi stop command

2012-09-21 Thread Gwendal Grignou
On Wed, Sep 19, 2012 at 1:56 AM, Aaron Lu aaron...@intel.com wrote:
 scsi stop command is used to put a device into stopped power
 condition, and scsi devices will take care of its internal cache
 before entering this power condition. For ata devices, this command
 should be translated to flush cache + standby immediate, currently,
 we are translating it to only standby.

 This patch handle this by sending flush cache command when standby is
 to be sent, and in its qc complete function, send the actual standby.

 This patch will be used to support poweroff hard disk either when
 runtime or when system is going to S3/S4/S5. The sd_suspend will be
 modified to only send a stop command to the device if device manages
 start_stop, the current implementation will send a sync cache command,
 which is not necessary per the scsi spec.

 Signed-off-by: Aaron Lu aaron...@intel.com
 ---
  drivers/ata/libata-scsi.c | 32 ++--
  1 file changed, 30 insertions(+), 2 deletions(-)

 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
 index 8ec81ca..de6e734 100644
 --- a/drivers/ata/libata-scsi.c
 +++ b/drivers/ata/libata-scsi.c
 @@ -1759,6 +1759,27 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd 
 *qc)
 ata_qc_free(qc);
  }

 +static void ata_flush_qc_complete(struct ata_queued_cmd *qc)
 +{
 +   if (qc-err_mask) {
 +   ata_gen_ata_sense(qc);
 +   qc-scsidone(qc-scsicmd);
 +   ata_qc_free(qc);
 +   } else {
 +   qc-complete_fn = ata_scsi_qc_complete;
 +   qc-tf.command = ATA_CMD_STANDBYNOW1;
 +   ata_qc_issue(qc);
 +   }
 +}
 +
 +static void ata_qc_issue_flush(struct ata_queued_cmd *qc)
 +{
 +   qc-complete_fn = ata_flush_qc_complete;
 +   qc-tf.command = qc-dev-flags  ATA_DFLAG_FLUSH_EXT ?
 +   ATA_CMD_FLUSH_EXT : ATA_CMD_FLUSH;
 +   ata_qc_issue(qc);
 +}
 +
  /**
   * ata_scsi_translate - Translate then issue SCSI command to ATA device
   * @dev: ATA device to which the command is addressed
 @@ -1821,8 +1842,15 @@ static int ata_scsi_translate(struct ata_device *dev, 
 struct scsi_cmnd *cmd,
 goto defer;
 }

 -   /* select device, send command to hardware */
 -   ata_qc_issue(qc);
 +   /*
 +* If we received scsi stop command,
 +* we will need to flush cache first
 +*/
 +   if (qc-tf.command == ATA_CMD_STANDBYNOW1  ata_try_flush_cache(dev))
You are adding tests on the data path.
What about changing the xlat function ata_scsi_start_stop_xlat to -
when stop is requested:
- if try_flush_cache is true,
 change qc-complete_fn to ata_flush_qc_complete
 build a flush command
- else
 do as usual.

ata_flush_qc_complete remains the same.

 +   ata_qc_issue_flush(qc);
 +   else
 +   /* select device, send command to hardware */
 +   ata_qc_issue(qc);

 VPRINTK(EXIT\n);
 return 0;
 --
 1.7.12.21.g871e293

 --
 To unsubscribe from this list: send the line unsubscribe linux-ide in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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 v3] scsi_lib: rate-limit the error message from failing commands

2012-09-21 Thread Mike Snitzer
On Thu, Aug 30, 2012 at 7:25 PM, Jens Axboe ax...@kernel.dk wrote:
 On 2012-08-30 14:06, Yi Zou wrote:
 [
 Jens/James,

 This is a rather old rate limt patch but never gets picked up in upstream, 
 so I
 am resending it here as v3, with some minor changes so it is directly 
 applicable
 to the current linux-2.6.git tree. I don't have that many LUNs that the 
 original
 issue was reported but the patch was already reviewed and acked in the past,
 I did retest w/ stress I/O on 4 LUNs I have right now.

 Original thread can be found at:
 http://comments.gmane.org/gmane.linux.scsi/73497
 http://www.open-fcoe.org/patchwork/patch/2436/

 Can you please pull this patch in? it's been hanging there for a long time.
 Original patch description is below.

 I've pulled in the block bit.

James,

Do you intend to pick up the scsi_lib.c change?
--
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 v7 2/6] scsi: sr: support runtime pm

2012-09-21 Thread Rafael J. Wysocki
On Friday, September 21, 2012, Aaron Lu wrote:
 On Thu, Sep 20, 2012 at 10:48:10PM +0200, Rafael J. Wysocki wrote:
  On Wednesday, September 12, 2012, Aaron Lu wrote:
   Place the ODD into runtime suspend state as soon as there is nobody
   using it.
  
  OK, so how is ODD related to the sr driver?
 
 As Alan has explained, ODD(optical disk drive) is driven by scsi
 sr driver.

OK, but what about writing ODD (Optical Disk Drive) in the changelog?

People reading git logs may not know all of the hardware acronyms and the
0 message doesn't go into the git log. :-)

   The only exception is, if we just find that a new medium is
   inserted, we wait for the next events checking to idle it.
  
  What exactly do you mean by to idle it?
 
 I mean to put its usage count so that its idle callback will kick in.

So I'd just write that directly in the changelog.

  Does this patch have any functional effect without the following patches?
 
 Yes, this one alone takes care of ODD's runtime pm

I suppose you mean the runtime PM status and usage counter?  I.e. the software
state?

 while the following
 patches take care of removing its power after it's runtime suspended.
 But it doesn't have any real benefit without the following patches.

Please put that information into the changelog too.

   Based on ideas of Alan Stern and Oliver Neukum.
   
   Signed-off-by: Aaron Lu aaron...@intel.com
   ---
drivers/scsi/sr.c | 29 +
1 file changed, 25 insertions(+), 4 deletions(-)
   
   diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
   index 5fc97d2..7a8222f 100644
   --- a/drivers/scsi/sr.c
   +++ b/drivers/scsi/sr.c
   @@ -45,6 +45,7 @@
#include linux/blkdev.h
#include linux/mutex.h
#include linux/slab.h
   +#include linux/pm_runtime.h
#include asm/uaccess.h

#include scsi/scsi.h
   @@ -146,8 +147,12 @@ static inline struct scsi_cd *scsi_cd_get(struct 
   gendisk *disk)
 kref_get(cd-kref);
 if (scsi_device_get(cd-device))
 goto out_put;
   + if (scsi_autopm_get_device(cd-device))
   + goto out_pm;
 goto out;
  
  Why don't you do
  
   + if (!scsi_autopm_get_device(cd-device))
   + goto out;
  
  without the new label?
 
 I was just stupidly following the pattern.
 Thanks and I'll change this.
 
  

   + out_pm:
   + scsi_device_put(cd-device);
 out_put:
 kref_put(cd-kref, sr_kref_release);
 cd = NULL;
   @@ -163,6 +168,7 @@ static void scsi_cd_put(struct scsi_cd *cd)
 mutex_lock(sr_ref_mutex);
 kref_put(cd-kref, sr_kref_release);
 scsi_device_put(sdev);
   + scsi_autopm_put_device(sdev);
 mutex_unlock(sr_ref_mutex);
}

   @@ -211,7 +217,7 @@ static unsigned int sr_check_events(struct 
   cdrom_device_info *cdi,
 unsigned int clearing, int slot)
{
 struct scsi_cd *cd = cdi-handle;
   - bool last_present;
   + bool last_present = cd-media_present;
 struct scsi_sense_hdr sshdr;
 unsigned int events;
 int ret;
   @@ -220,6 +226,8 @@ static unsigned int sr_check_events(struct 
   cdrom_device_info *cdi,
 if (CDSL_CURRENT != slot)
 return 0;

   + scsi_autopm_get_device(cd-device);
   +
 events = sr_get_events(cd-device);
 cd-get_event_changed |= events  DISK_EVENT_MEDIA_CHANGE;

   @@ -246,10 +254,9 @@ static unsigned int sr_check_events(struct 
   cdrom_device_info *cdi,
 }

 if (!(clearing  DISK_EVENT_MEDIA_CHANGE))
   - return events;
   + goto out;
do_tur:
 /* let's see whether the media is there with TUR */
   - last_present = cd-media_present;
 ret = scsi_test_unit_ready(cd-device, SR_TIMEOUT, MAX_RETRIES, sshdr);

 /*
   @@ -270,7 +277,7 @@ do_tur:
 }

 if (cd-ignore_get_event)
   - return events;
   + goto out;

 /* check whether GET_EVENT is reporting spurious MEDIA_CHANGE */
 if (!cd-tur_changed) {
   @@ -287,6 +294,12 @@ do_tur:
 cd-tur_changed = false;
 cd-get_event_changed = false;

   +out:
   + if (cd-media_present  !last_present)
   + pm_runtime_put_noidle(cd-device-sdev_gendev);
   + else
   + scsi_autopm_put_device(cd-device);
   +
  
  This thing is asking for a comment.
  
  It looks like you're kind of avoiding to call _idle() for the device, but 
  why?
  What might go wrong if pm_runtime_put() is used instead of the whole 
  conditional,
  among other things?
 
 The above code means, if we found that a disc is just inserted(reflected
 by cd-media_present is true and last_present is false), we do not want
 to put the device into suspend state immediately until next poll. In the
 interval, some programs may decide to use this device by opening it.
 
 Nothing will go wrong, but it can possibly avoid a runtime status change.

OK, so suppose the condition is true and we do the _noidle() put.  Who's
going to suspend the device in that case if no one actually uses the device?

  

Re: [PATCH v7 3/6] scsi: sr: support zero power ODD(ZPODD)

2012-09-21 Thread Rafael J. Wysocki
On Friday, September 21, 2012, Aaron Lu wrote:
 On Fri, Sep 21, 2012 at 12:07:23AM +0200, Rafael J. Wysocki wrote:
  On Wednesday, September 12, 2012, Aaron Lu wrote:
static struct scsi_driver sr_template = {
 .owner  = THIS_MODULE,
   @@ -87,6 +89,8 @@ static struct scsi_driver sr_template = {
 .name   = sr,
 .probe  = sr_probe,
 .remove = sr_remove,
   + .suspend= sr_suspend,
   + .resume = sr_resume,
 },
 .done   = sr_done,
};
   @@ -172,6 +176,52 @@ static void scsi_cd_put(struct scsi_cd *cd)
 mutex_unlock(sr_ref_mutex);
}
  
  Besides, I need some help to understand how this is supposed to work.
  
  Do I think correctly that sr_suspend(), for example, will be run by the
  SCSI bus type layer in case of a CD device runtime suspend?  However,
 
 Yes.
 
  won't this routine be used during system suspend as well and won't it cause
  problems to happen if so?
 
 On system suspend, nothing needs to be done.
 I'll add the following code in next version.
 
   if (!PMSG_IS_AUTO(msg))
   return 0;

Please don't.  The pm_message_t thing is obsolete and shoulnd't really be
used by device drivers.  I know that ATA relies on it internally, but that's
just something that needs to be changed at one point.

Moreover, I'd like to migrate SCSI drivers to the PM handling based on struct
dev_pm_ops eventually and your change is kind of going in the opposite
direction.  I don't know how much effort the migration is going to take,
though, so perhaps we can just make this change first.

On a slightly related note, suppose that we have an enabled bit in flags
in struct acpi_device_power_state and suppose that we have a helper
function pm_platform_power_off_allowed(dev, bool), such that if the driver
(or subsystem) does pm_platform_power_off_allowed(dev, false) and the
platform is ACPI, the enabled bit for the D3cold state will be cleared.
Then, the ACPI device PM routines will never use D3cold as the device
power state.

In that case, it seems, you won't need the ready_to_power_off flag in struct
scsi_device any more.

Thanks,
Rafael
--
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 v7 0/6] ZPODD patches

2012-09-21 Thread Rafael J. Wysocki
On Friday, September 21, 2012, Aaron Lu wrote:
 On Thu, Sep 20, 2012 at 10:00:51PM +0200, Rafael J. Wysocki wrote:
  On Wednesday, September 19, 2012, Aaron Lu wrote:
   Thanks Rafael, and if there is any question/problem,
   please kindly let me know.
  
  Well, unfortunately my initial review indicates that the patchset is not
  quite ready to go upstream yet.
  
  I'll send comments in replies to the individual patches, but overall I can
  say that at this stage of development, when I look at the patches, it should
  be clear to me not only what is being changed, but _why_ it is being changed
  in the first place and, secondly, why it is being changed in this particular
  way.  It's far from that, though.
 
 I'm adding zero power support for optical disk drive(ZPODD), which is
 made possible with the newly defined device attention(DA) pin introduced
 in SATA 3.1 spec.
 
 The idea here is to use runtime pm to achieve this, so I basically did 2
 things:
 1 Add runtime pm support for ODD;
 2 Add power off support for ODD after it is runtime suspended.
 
 Patch 2 is runtime pm support for ODD, the reason it is done this way is
 discussed here:
 http://www.spinics.net/lists/linux-scsi/msg61551.html

Why isn't it explained in the patch changelog, then?  People should be able
to learn why things are done the way they are done from git logs.

 The basic idea is, the ODD will be runtime suspended as long as there is
 nobody using it, that is, no programs opening the block device.
 
 The ODD will be polled periodically, so it will be runtime resumed
 before checking if there is any events pending and suspended when done.

OK.  So what happens if we power off the drive via runtime PM.  Does it
it really make sense to resumie it through polling in that case?

 The only exception is, if we found a disc is just inserted, we will not
 idle it immediately at the end of the poll, reason explained in another
 mail.
 
 This is the rational I wrote patch 2, and patch 1 is used by patch 2.
 
 Patch 3 is adding power off support for ODD after it is runtime
 suspended, the condition is specified in section 15:
 ftp://ftp.seagate.com/sff/INF-8090.PDF
 
 That is, for tray type ODD: no media inside and door closed; for slot
 type ODD: no media inside.
 
 The is the reason sr_suspend is written, for non-ZPODD capable devices,
 it does nothing; for ZPODD devices, it will check the above condition to
 see if it is ready to be powered off. The ready_to_power_off flag will be
 used by ATA layer to decide if power can be removed.

Now, James says he doesn't like the way ready_to_power_off is used.  Sure
enough, it is totally irrelevant to the majority of SCSI devices.  It actually
is totally irrelevant to everything in the SCSI subsystem except for the sr
driver and libata.  So I wonder if you have considered any alternative
way to address the use case at hand?

 When in powered off state, if user presses the eject button or insert a
 disc, an ACPI event will be generated and our acpi wake handler will
 pm_runtime_resume the ODD. And if it is a tray type ODD, its tray should
 be ejected(need_eject flag) after powered on. This is patch 3.

That sounds reasonable enough, but the role of the powered_off and
need_eject flags could be explained a bit better.  In particular, it would
be nice to have explained why they have to be present in struct scsi_device,
because they don't seem to be particularly useful for many SCSI devices
that aren't CD drives (the need_eject one in particular).

 And patch 4-6 introduces a new sysfs file may_power_off to give user a
 chance to disable the power off of the device due to various reasons
 like the ODD claims support of device attention while actually it is
 broken.

User space has an interface to disable runtime PM of any device and it looks
like that interface should be sufficient to disable the feature in question.
Why do you think the new interface is needed?

 I hope it makes more sense to you now.

Well, thanks for the explanation. :-)

Rafael
--
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 00/15] bfa: Update the driver version to 3.1.2.1

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Hi James,

The following patch-set includes bug-fixes, firmware naming convention 
change,
adds new features such as FC Arbitrated Loop support, Diagnostic Port 
(D-port),
IO throttle, FRU update support, QoS bandwidth config support to the 
BFA driver
and updates the Brocade BFA driver to v3.1.2.1.

I have compiled and tested the code against your scsi-misc.

Thanks,
Krishna C Gudipati

Krishna Gudipati (15):
  bfa: Add support for FC Arbitrated Loop topology.
  bfa: IOCFC state machine enhancements
  bfa: Flash Controller PLL initialization fixes
  bfa: Add support to have mfg date as part of adapter attributes
  bfa: Fix few attributes in the RHBA CT passthru command
  bfa: Fix to handle firmware tskim abort request response
  bfa: Add diagnostic port (D-Port) support
  bfa: Fabric Assigned Address implementation fix
  bfa: Add support for user to configure bandwidth on QoS priorities
  bfa: Add support for IO throttling at port level
  bfa: Add support to configure min/max bandwidth for a pcifn
  bfa: Support Power on Hours display and diag temp sensor fixes
  bfa: Add support to read/update the FRU data.
  bfa: Firmware image naming convention update
  bfa: Update the driver version to 3.1.2.1

 drivers/scsi/bfa/bfa_core.c  |   85 -
 drivers/scsi/bfa/bfa_defs.h  |   61 +++-
 drivers/scsi/bfa/bfa_defs_svc.h  |  119 +-
 drivers/scsi/bfa/bfa_fc.h|5 +
 drivers/scsi/bfa/bfa_fcbuild.c   |4 +
 drivers/scsi/bfa/bfa_fcpim.c |  123 ++-
 drivers/scsi/bfa/bfa_fcpim.h |   13 +-
 drivers/scsi/bfa/bfa_fcs.c   |   64 +++-
 drivers/scsi/bfa/bfa_fcs.h   |   23 +-
 drivers/scsi/bfa/bfa_fcs_lport.c |  155 -
 drivers/scsi/bfa/bfa_fcs_rport.c |  288 +--
 drivers/scsi/bfa/bfa_ioc.c   |  494 -
 drivers/scsi/bfa/bfa_ioc.h   |   63 +++-
 drivers/scsi/bfa/bfa_ioc_ct.c|  236 +++--
 drivers/scsi/bfa/bfa_modules.h   |1 +
 drivers/scsi/bfa/bfa_port.c  |   32 ++
 drivers/scsi/bfa/bfa_port.h  |3 +
 drivers/scsi/bfa/bfa_svc.c   |  732 +-
 drivers/scsi/bfa/bfa_svc.h   |   30 ++-
 drivers/scsi/bfa/bfad.c  |6 +-
 drivers/scsi/bfa/bfad_bsg.c  |  373 +---
 drivers/scsi/bfa/bfad_bsg.h  |   63 -
 drivers/scsi/bfa/bfad_drv.h  |2 +-
 drivers/scsi/bfa/bfi.h   |   72 -
 drivers/scsi/bfa/bfi_ms.h|   14 +
 drivers/scsi/bfa/bfi_reg.h   |3 +
 26 files changed, 2762 insertions(+), 302 deletions(-)

-- 
1.7.3.rc1

--
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 01/15] bfa: Add support for FC Arbitrated Loop topology.

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Add private loop topology support at 2G/4G/8G speeds with following
  limitations
  1. No support for multiple initiators in the loop
  2. No public loop support. If attached to a loop with an FL_Port,
 device continues to work as a private NL_Port in the loop
  3. No auto topology detection. User has to manually set the
 configured topology to loop if attaching to loop.
- When loop topology is configured, enabling FC port features
  QoS/Trunk/TRL are not allowed and vice versa.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h  |5 +
 drivers/scsi/bfa/bfa_defs_svc.h  |   87 +---
 drivers/scsi/bfa/bfa_fc.h|5 +
 drivers/scsi/bfa/bfa_fcbuild.c   |4 +
 drivers/scsi/bfa/bfa_fcs.c   |   64 +++--
 drivers/scsi/bfa/bfa_fcs.h   |   19 ++-
 drivers/scsi/bfa/bfa_fcs_lport.c |  141 +++-
 drivers/scsi/bfa/bfa_fcs_rport.c |  282 +-
 drivers/scsi/bfa/bfa_svc.c   |   93 +++--
 drivers/scsi/bfa/bfa_svc.h   |8 +-
 drivers/scsi/bfa/bfad_bsg.c  |  112 +++-
 drivers/scsi/bfa/bfi_ms.h|   12 ++
 12 files changed, 713 insertions(+), 119 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index b5a1595..f1c9314 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -159,6 +159,8 @@ enum bfa_status {
BFA_STATUS_BEACON_ON= 72,   /* Port Beacon already on */
BFA_STATUS_ENOFSAVE = 78,   /*  No saved firmware trace */
BFA_STATUS_IOC_DISABLED = 82,   /* IOC is already disabled */
+   BFA_STATUS_ERROR_TRL_ENABLED  = 87,   /* TRL is enabled */
+   BFA_STATUS_ERROR_QOS_ENABLED  = 88,   /* QoS is enabled */
BFA_STATUS_NO_SFP_DEV = 89, /* No SFP device check or replace SFP */
BFA_STATUS_MEMTEST_FAILED = 90, /* Memory test failed contact support */
BFA_STATUS_LEDTEST_OP = 109, /* LED test is operating */
@@ -184,6 +186,9 @@ enum bfa_status {
BFA_STATUS_FAA_ACQ_ADDR = 200,  /* Acquiring addr */
BFA_STATUS_ERROR_TRUNK_ENABLED = 203,   /* Trunk enabled on adapter */
BFA_STATUS_MAX_ENTRY_REACHED = 212, /* MAX entry reached */
+   BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
+   BFA_STATUS_LOOP_UNSUPP_MEZZ = 231, /* Loop topology is not supported
+   * on mezz cards */
BFA_STATUS_MAX_VAL  /* Unknown error code */
 };
 #define bfa_status_t enum bfa_status
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 36756ce..20749f1 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -324,12 +324,46 @@ struct bfa_fw_fcoe_port_stats_s {
struct bfa_fw_fip_stats_s   fip_stats;
 };
 
+/**
+ * @brief LPSM statistics
+ */
+struct bfa_fw_lpsm_stats_s {
+   u32 cls_rx; /* LPSM cls_rx  */
+   u32 cls_tx; /* LPSM cls_tx  */
+   u32 arbf0_rx;   /* LPSM abrf0 rcvd  */
+   u32 arbf0_tx;   /* LPSM abrf0 xmit  */
+   u32 init_rx;/* LPSM loop init start */
+   u32 unexp_hwst; /* LPSM unknown hw state*/
+   u32 unexp_frame;/* LPSM unknown_frame   */
+   u32 unexp_prim; /* LPSM unexpected primitive*/
+   u32 prev_alpa_unavail; /* LPSM prev alpa unavailable */
+   u32 alpa_unavail;   /* LPSM alpa not available  */
+   u32 lip_rx; /* LPSM lip rcvd*/
+   u32 lip_f7f7_rx;/* LPSM lip f7f7 rcvd   */
+   u32 lip_f8_rx;  /* LPSM lip f8 rcvd */
+   u32 lip_f8f7_rx;/* LPSM lip f8f7 rcvd   */
+   u32 lip_other_rx;   /* LPSM lip other rcvd  */
+   u32 lip_tx; /* LPSM lip xmit*/
+   u32 retry_tov;  /* LPSM retry TOV   */
+   u32 lip_tov;/* LPSM LIP wait TOV*/
+   u32 idle_tov;   /* LPSM idle wait TOV   */
+   u32 arbf0_tov;  /* LPSM arbfo wait TOV  */
+   u32 stop_loop_tov;  /* LPSM stop loop wait TOV  */
+   u32 lixa_tov;   /* LPSM lisa wait TOV   */
+   u32 lixx_tov;   /* LPSM lilp/lirp wait TOV  */
+   u32 cls_tov;/* LPSM cls wait TOV*/
+   u32 sler;   /* LPSM SLER recvd  */
+   u32 failed; /* LPSM failed  */
+   u32 success;/* LPSM online  */
+};
+
 /*
  * IOC firmware FC uport stats
  */
 struct 

[PATCH 02/15] bfa: IOCFC state machine enhancements

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Add support to handle STOP/DISABLE events in the IOCFC state machine.
- Made changes to bring the IOC down on a flash driver config read 
failure.
- Added logic to clean the use count and fail sync registers during 
IOCFC init.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_core.c   |   53 +
 drivers/scsi/bfa/bfa_ioc.c|   11 
 drivers/scsi/bfa/bfa_ioc_ct.c |   25 ---
 3 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index b7c326f..837879d 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -274,6 +274,15 @@ bfa_iocfc_sm_initing(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
case IOCFC_E_IOC_ENABLED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_dconf_read);
break;
+
+   case IOCFC_E_DISABLE:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabling);
+   break;
+
+   case IOCFC_E_STOP:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_stopping);
+   break;
+
case IOCFC_E_IOC_FAILED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_init_failed);
break;
@@ -298,6 +307,15 @@ bfa_iocfc_sm_dconf_read(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
case IOCFC_E_DCONF_DONE:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_init_cfg_wait);
break;
+
+   case IOCFC_E_DISABLE:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabling);
+   break;
+
+   case IOCFC_E_STOP:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_stopping);
+   break;
+
case IOCFC_E_IOC_FAILED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_init_failed);
break;
@@ -322,6 +340,15 @@ bfa_iocfc_sm_init_cfg_wait(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
case IOCFC_E_CFG_DONE:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_init_cfg_done);
break;
+
+   case IOCFC_E_DISABLE:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabling);
+   break;
+
+   case IOCFC_E_STOP:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_stopping);
+   break;
+
case IOCFC_E_IOC_FAILED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_init_failed);
break;
@@ -433,6 +460,12 @@ bfa_iocfc_sm_stopping(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
bfa_cb_queue(iocfc-bfa, iocfc-bfa-iocfc.stop_hcb_qe,
 bfa_iocfc_stop_cb, iocfc-bfa);
break;
+
+   case IOCFC_E_IOC_ENABLED:
+   case IOCFC_E_DCONF_DONE:
+   case IOCFC_E_CFG_DONE:
+   break;
+
default:
bfa_sm_fault(iocfc-bfa, event);
break;
@@ -454,6 +487,15 @@ bfa_iocfc_sm_enabling(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
case IOCFC_E_IOC_ENABLED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_cfg_wait);
break;
+
+   case IOCFC_E_DISABLE:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabling);
+   break;
+
+   case IOCFC_E_STOP:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_dconf_write);
+   break;
+
case IOCFC_E_IOC_FAILED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_failed);
 
@@ -493,6 +535,13 @@ bfa_iocfc_sm_cfg_wait(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
 bfa_iocfc_enable_cb, iocfc-bfa);
iocfc-bfa-iocfc.cb_reqd = BFA_FALSE;
break;
+   case IOCFC_E_DISABLE:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabling);
+   break;
+
+   case IOCFC_E_STOP:
+   bfa_fsm_set_state(iocfc, bfa_iocfc_sm_dconf_write);
+   break;
case IOCFC_E_IOC_FAILED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_failed);
if (iocfc-bfa-iocfc.cb_reqd == BFA_FALSE)
@@ -524,6 +573,10 @@ bfa_iocfc_sm_disabling(struct bfa_iocfc_s *iocfc, enum 
iocfc_event event)
case IOCFC_E_IOC_DISABLED:
bfa_fsm_set_state(iocfc, bfa_iocfc_sm_disabled);
break;
+   case IOCFC_E_IOC_ENABLED:
+   case IOCFC_E_DCONF_DONE:
+   case IOCFC_E_CFG_DONE:
+   break;
default:
bfa_sm_fault(iocfc-bfa, event);
break;
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 7689872..28ace31 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -731,8 +731,7 @@ bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf_s *iocpf)
/*
 * Unlock the hw semaphore. Should be here only once per boot.
 */
-   

[PATCH 03/15] bfa: Flash Controller PLL initialization fixes

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Made changes to check the flash controller status before IOC 
initialization.
- Made changes to poll on the FLASH_STS_REG bit to check if the flash 
controller
  initialization is completed during the PLL init.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_ioc_ct.c |  211 +
 drivers/scsi/bfa/bfi_reg.h|3 +
 2 files changed, 131 insertions(+), 83 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c
index 29efbb7..de4e726 100644
--- a/drivers/scsi/bfa/bfa_ioc_ct.c
+++ b/drivers/scsi/bfa/bfa_ioc_ct.c
@@ -744,25 +744,6 @@ bfa_ioc_ct2_mem_init(void __iomem *rb)
 void
 bfa_ioc_ct2_mac_reset(void __iomem *rb)
 {
-   u32 r32;
-
-   bfa_ioc_ct2_sclk_init(rb);
-   bfa_ioc_ct2_lclk_init(rb);
-
-   /*
-* release soft reset on s_clk  l_clk
-*/
-   r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG));
-   writel(r32  ~__APP_PLL_SCLK_LOGIC_SOFT_RESET,
-   (rb + CT2_APP_PLL_SCLK_CTL_REG));
-
-   /*
-* release soft reset on s_clk  l_clk
-*/
-   r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG));
-   writel(r32  ~__APP_PLL_LCLK_LOGIC_SOFT_RESET,
-   (rb + CT2_APP_PLL_LCLK_CTL_REG));
-
/* put port0, port1 MAC  AHB in reset */
writel((__CSI_MAC_RESET | __CSI_MAC_AHB_RESET),
rb + CT2_CSI_MAC_CONTROL_REG(0));
@@ -770,8 +751,21 @@ bfa_ioc_ct2_mac_reset(void __iomem *rb)
rb + CT2_CSI_MAC_CONTROL_REG(1));
 }
 
+static void
+bfa_ioc_ct2_enable_flash(void __iomem *rb)
+{
+   u32 r32;
+
+   r32 = readl((rb + PSS_GPIO_OUT_REG));
+   writel(r32  ~1, (rb + PSS_GPIO_OUT_REG));
+   r32 = readl((rb + PSS_GPIO_OE_REG));
+   writel(r32 | 1, (rb + PSS_GPIO_OE_REG));
+}
+
 #define CT2_NFC_MAX_DELAY  1000
-#define CT2_NFC_VER_VALID  0x143
+#define CT2_NFC_PAUSE_MAX_DELAY 4000
+#define CT2_NFC_VER_VALID  0x147
+#define CT2_NFC_STATE_RUNNING   0x2001
 #define BFA_IOC_PLL_POLL   100
 
 static bfa_boolean_t
@@ -787,6 +781,20 @@ bfa_ioc_ct2_nfc_halted(void __iomem *rb)
 }
 
 static void
+bfa_ioc_ct2_nfc_halt(void __iomem *rb)
+{
+   int i;
+
+   writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_SET_REG);
+   for (i = 0; i  CT2_NFC_MAX_DELAY; i++) {
+   if (bfa_ioc_ct2_nfc_halted(rb))
+   break;
+   udelay(1000);
+   }
+   WARN_ON(!bfa_ioc_ct2_nfc_halted(rb));
+}
+
+static void
 bfa_ioc_ct2_nfc_resume(void __iomem *rb)
 {
u32 r32;
@@ -802,105 +810,142 @@ bfa_ioc_ct2_nfc_resume(void __iomem *rb)
WARN_ON(1);
 }
 
-bfa_status_t
-bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode)
+static void
+bfa_ioc_ct2_clk_reset(void __iomem *rb)
 {
-   u32 wgn, r32, nfc_ver, i;
+   u32 r32;
 
-   wgn = readl(rb + CT2_WGN_STATUS);
-   nfc_ver = readl(rb + CT2_RSC_GPR15_REG);
+   bfa_ioc_ct2_sclk_init(rb);
+   bfa_ioc_ct2_lclk_init(rb);
 
-   if ((wgn == (__A2T_AHB_LOAD | __WGN_READY)) 
-   (nfc_ver = CT2_NFC_VER_VALID)) {
-   if (bfa_ioc_ct2_nfc_halted(rb))
-   bfa_ioc_ct2_nfc_resume(rb);
+   /*
+* release soft reset on s_clk  l_clk
+*/
+   r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG));
+   writel(r32  ~__APP_PLL_SCLK_LOGIC_SOFT_RESET,
+   (rb + CT2_APP_PLL_SCLK_CTL_REG));
 
-   writel(__RESET_AND_START_SCLK_LCLK_PLLS,
-  rb + CT2_CSI_FW_CTL_SET_REG);
+   r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG));
+   writel(r32  ~__APP_PLL_LCLK_LOGIC_SOFT_RESET,
+   (rb + CT2_APP_PLL_LCLK_CTL_REG));
 
-   for (i = 0; i  BFA_IOC_PLL_POLL; i++) {
-   r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG);
-   if (r32  __RESET_AND_START_SCLK_LCLK_PLLS)
-   break;
-   }
+}
 
-   WARN_ON(!(r32  __RESET_AND_START_SCLK_LCLK_PLLS));
+static void
+bfa_ioc_ct2_nfc_clk_reset(void __iomem *rb)
+{
+   u32 r32, i;
 
-   for (i = 0; i  BFA_IOC_PLL_POLL; i++) {
-   r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG);
-   if (!(r32  __RESET_AND_START_SCLK_LCLK_PLLS))
-   break;
-   }
+   r32 = readl((rb + PSS_CTL_REG));
+   r32 |= (__PSS_LPU0_RESET | __PSS_LPU1_RESET);
+   writel(r32, (rb + PSS_CTL_REG));
+
+   writel(__RESET_AND_START_SCLK_LCLK_PLLS, rb + CT2_CSI_FW_CTL_SET_REG);
+
+   for (i = 0; i  BFA_IOC_PLL_POLL; i++) {
+   r32 = readl(rb + CT2_NFC_FLASH_STS_REG);
+
+   if ((r32  __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS))
+   break;
+   }
+   WARN_ON(!(r32 

[PATCH 04/15] bfa: Add support to have mfg date as part of adapter attributes

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Made changes to expose mfg day/month/year as part of the
  adapter attributes for user space applications.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h |4 
 drivers/scsi/bfa/bfa_ioc.c  |4 
 drivers/scsi/bfa/bfi.h  |3 +++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index f1c9314..4e6 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -254,6 +254,10 @@ struct bfa_adapter_attr_s {
 
u8  is_mezz;
u8  trunk_capable;
+   u8  mfg_day;/* manufacturing day */
+   u8  mfg_month;  /* manufacturing month */
+   u16 mfg_year;   /* manufacturing year */
+   u16 rsvd;
 };
 
 /*
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 28ace31..be33725 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -1750,6 +1750,7 @@ bfa_ioc_getattr_reply(struct bfa_ioc_s *ioc)
attr-card_type = be32_to_cpu(attr-card_type);
attr-maxfrsize = be16_to_cpu(attr-maxfrsize);
ioc-fcmode = (attr-port_mode == BFI_PORT_MODE_FC);
+   attr-mfg_year  = be16_to_cpu(attr-mfg_year);
 
bfa_fsm_send_event(ioc, IOC_E_FWRSP_GETATTR);
 }
@@ -2496,6 +2497,9 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
ad_attr-cna_capable = bfa_ioc_is_cna(ioc);
ad_attr-trunk_capable = (ad_attr-nports  1) 
  !bfa_ioc_is_cna(ioc)  !ad_attr-is_mezz;
+   ad_attr-mfg_day = ioc_attr-mfg_day;
+   ad_attr-mfg_month = ioc_attr-mfg_month;
+   ad_attr-mfg_year = ioc_attr-mfg_year;
 }
 
 enum bfa_ioc_type_e
diff --git a/drivers/scsi/bfa/bfi.h b/drivers/scsi/bfa/bfi.h
index b2ba0b2..e6269c2 100644
--- a/drivers/scsi/bfa/bfi.h
+++ b/drivers/scsi/bfa/bfi.h
@@ -288,6 +288,9 @@ struct bfi_ioc_attr_s {
charoptrom_version[BFA_VERSION_LEN];
struct  bfa_mfg_vpd_s   vpd;
u32 card_type;  /*  card type   */
+   u8  mfg_day;/* manufacturing day */
+   u8  mfg_month;  /* manufacturing month */
+   u16 mfg_year;   /* manufacturing year */
 };
 
 /*
-- 
1.7.3.rc1

--
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 05/15] bfa: Fix few attributes in the RHBA CT passthru command

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Made changes to set the RHBA command max payload based on
  the port configured frame size.
- Made changes to fix the driver/fw version size in FMDI structure.
- Fix to pass the fw version for FDMI attribute type
  FDMI_HBA_ATTRIB_FW_VERSION rather than driver version.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_fcs.h   |4 ++--
 drivers/scsi/bfa/bfa_fcs_lport.c |   14 +++---
 drivers/scsi/bfa/bfa_ioc.h   |3 ++-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
index f2a6a3c..a449706 100644
--- a/drivers/scsi/bfa/bfa_fcs.h
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -642,9 +642,9 @@ struct bfa_fcs_fdmi_hba_attr_s {
u8 model[16];
u8 model_desc[256];
u8 hw_version[8];
-   u8 driver_version[8];
+   u8 driver_version[BFA_VERSION_LEN];
u8 option_rom_ver[BFA_VERSION_LEN];
-   u8 fw_version[8];
+   u8 fw_version[BFA_VERSION_LEN];
u8 os_name[256];
__be32max_ct_pyld;
 };
diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index c58a5e0..1224d04 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -2014,13 +2014,10 @@ bfa_fcs_lport_fdmi_build_rhba_pyld(struct 
bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
 sizeof(templen));
}
 
-   /*
-* f/w Version = driver version
-*/
attr = (struct fdmi_attr_s *) curr_ptr;
attr-type = cpu_to_be16(FDMI_HBA_ATTRIB_FW_VERSION);
-   templen = (u16) strlen(fcs_hba_attr-driver_version);
-   memcpy(attr-value, fcs_hba_attr-driver_version, templen);
+   templen = (u16) strlen(fcs_hba_attr-fw_version);
+   memcpy(attr-value, fcs_hba_attr-fw_version, templen);
templen = fc_roundup(templen, sizeof(u32));
curr_ptr += sizeof(attr-type) + sizeof(templen) + templen;
len += templen;
@@ -2422,6 +2419,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s 
*fdmi,
 {
struct bfa_fcs_lport_s *port = fdmi-ms-port;
struct bfa_fcs_driver_info_s  *driver_info = port-fcs-driver_info;
+   struct bfa_fcs_fdmi_port_attr_s fcs_port_attr;
 
memset(hba_attr, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s));
 
@@ -2457,7 +2455,9 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s 
*fdmi,
sizeof(driver_info-host_os_patch));
}
 
-   hba_attr-max_ct_pyld = cpu_to_be32(FC_MAX_PDUSZ);
+   /* Retrieve the max frame size from the port attr */
+   bfa_fcs_fdmi_get_portattr(fdmi, fcs_port_attr);
+   hba_attr-max_ct_pyld = fcs_port_attr.max_frm_size;
 }
 
 static void
@@ -2517,7 +2517,7 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s 
*fdmi,
/*
 * Max PDU Size.
 */
-   port_attr-max_frm_size = cpu_to_be32(FC_MAX_PDUSZ);
+   port_attr-max_frm_size = cpu_to_be32(pport_attr.pport_cfg.maxfrsize);
 
/*
 * OS device Name
diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
index 593ce6b..47038da 100644
--- a/drivers/scsi/bfa/bfa_ioc.h
+++ b/drivers/scsi/bfa/bfa_ioc.h
@@ -761,7 +761,8 @@ bfa_status_tbfa_dconf_update(struct bfa_s *bfa);
 #define bfa_ioc_maxfrsize(__ioc)   ((__ioc)-attr-maxfrsize)
 #define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)-attr-rx_bbcredit)
 #define bfa_ioc_speed_sup(__ioc)   \
-   BFI_ADAPTER_GETP(SPEED, (__ioc)-attr-adapter_prop)
+   ((bfa_ioc_is_cna(__ioc)) ? BFA_PORT_SPEED_10GBPS :  \
+BFI_ADAPTER_GETP(SPEED, (__ioc)-attr-adapter_prop))
 #define bfa_ioc_get_nports(__ioc)  \
BFI_ADAPTER_GETP(NPORTS, (__ioc)-attr-adapter_prop)
 
-- 
1.7.3.rc1

--
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 06/15] bfa: Fix to handle firmware tskim abort request response

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Enhance tracing to include both tskim tag and event.
- Handle the tskim abort response from firmware in the
  tskim state machine cleanup state and proceed with the
  tskim cleanup.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_fcpim.c |   18 +++---
 drivers/scsi/bfa/bfa_fcpim.h |4 +++-
 drivers/scsi/bfa/bfi_ms.h|1 +
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 1633963..4118d84 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -158,6 +158,7 @@ enum bfa_tskim_event {
BFA_TSKIM_SM_IOS_DONE   = 7,/*  IO and sub TM completions   */
BFA_TSKIM_SM_CLEANUP= 8,/*  TM cleanup on ITN offline   */
BFA_TSKIM_SM_CLEANUP_DONE = 9,  /*  TM abort completion */
+   BFA_TSKIM_SM_UTAG   = 10,   /*  TM completion unknown tag  */
 };
 
 /*
@@ -3036,7 +3037,7 @@ bfa_ioim_abort(struct bfa_ioim_s *ioim)
 static void
 bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_START:
@@ -3074,7 +3075,7 @@ bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum 
bfa_tskim_event event)
 static void
 bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_DONE:
@@ -3110,7 +3111,7 @@ bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum 
bfa_tskim_event event)
 static void
 bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_DONE:
@@ -3119,6 +3120,7 @@ bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum 
bfa_tskim_event event)
 */
break;
 
+   case BFA_TSKIM_SM_UTAG:
case BFA_TSKIM_SM_CLEANUP_DONE:
bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
bfa_tskim_cleanup_ios(tskim);
@@ -3138,7 +3140,7 @@ bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum 
bfa_tskim_event event)
 static void
 bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_IOS_DONE:
@@ -3170,7 +3172,7 @@ bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum 
bfa_tskim_event event)
 static void
 bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_QRESUME:
@@ -3207,7 +3209,7 @@ static void
 bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_DONE:
@@ -3238,7 +3240,7 @@ bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
 static void
 bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
 {
-   bfa_trc(tskim-bfa, event);
+   bfa_trc(tskim-bfa, tskim-tsk_tag  16 | event);
 
switch (event) {
case BFA_TSKIM_SM_HCB:
@@ -3560,6 +3562,8 @@ bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
if (rsp-tsk_status == BFI_TSKIM_STS_ABORTED) {
bfa_stats(tskim-itnim, tm_cleanup_comps);
bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP_DONE);
+   } else if (rsp-tsk_status == BFI_TSKIM_STS_UTAG) {
+   bfa_sm_send_event(tskim, BFA_TSKIM_SM_UTAG);
} else {
bfa_stats(tskim-itnim, tm_fw_rsps);
bfa_sm_send_event(tskim, BFA_TSKIM_SM_DONE);
diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
index 36f26da..b81d51c 100644
--- a/drivers/scsi/bfa/bfa_fcpim.h
+++ b/drivers/scsi/bfa/bfa_fcpim.h
@@ -51,7 +51,9 @@ void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw);
 #define BFA_ITN_FROM_TAG(_fcp, _tag)   \
((_fcp)-itn_arr + ((_tag)  ((_fcp)-num_itns - 1)))
 #define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \
-   bfa_mem_get_dmabuf_kva(_fcp, _tag, BFI_IOIM_SNSLEN)
+   bfa_mem_get_dmabuf_kva(_fcp, (_tag  BFA_IOIM_IOTAG_MASK),  \
+   BFI_IOIM_SNSLEN)
+
 
 #define BFA_ITNIM_MIN   32
 #define BFA_ITNIM_MAX   1024
diff --git a/drivers/scsi/bfa/bfi_ms.h b/drivers/scsi/bfa/bfi_ms.h
index 1f73db9..c89defc 100644
--- a/drivers/scsi/bfa/bfi_ms.h
+++ b/drivers/scsi/bfa/bfi_ms.h
@@ -840,6 +840,7 @@ enum bfi_tskim_status {
 */

[PATCH 07/15] bfa: Add diagnostic port (D-Port) support

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Introduced support for D-Port which is a new port mode during which
  link level diagnostics can be run.
- Provided mechanism to dynamically configure D-Port and initiate 
diagnostic
  tests to isolate any link level issues.
- In D-Port mode, the HBA port does not participate in fabric or login 
to the
  remote device or run data traffic.
- Diagnostic tests include running various loopback tests in 
conjunction with
  the attached device.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h |   16 ++
 drivers/scsi/bfa/bfa_defs_svc.h |1 +
 drivers/scsi/bfa/bfa_port.c |   32 +++
 drivers/scsi/bfa/bfa_port.h |3 +
 drivers/scsi/bfa/bfa_svc.c  |  505 ++-
 drivers/scsi/bfa/bfa_svc.h  |   19 ++
 drivers/scsi/bfa/bfad_bsg.c |   56 +
 drivers/scsi/bfa/bfad_bsg.h |   10 +
 drivers/scsi/bfa/bfi.h  |   19 ++
 9 files changed, 658 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index 4e6..b4d5d87 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -165,6 +165,7 @@ enum bfa_status {
BFA_STATUS_MEMTEST_FAILED = 90, /* Memory test failed contact support */
BFA_STATUS_LEDTEST_OP = 109, /* LED test is operating */
BFA_STATUS_INVALID_MAC  = 134, /*  Invalid MAC address */
+   BFA_STATUS_CMD_NOTSUPP_CNA = 146, /* Command not supported for CNA */
BFA_STATUS_PBC  = 154, /*  Operation not allowed for pre-boot
*  configuration */
BFA_STATUS_BAD_FWCFG = 156, /* Bad firmware configuration */
@@ -189,6 +190,10 @@ enum bfa_status {
BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
BFA_STATUS_LOOP_UNSUPP_MEZZ = 231, /* Loop topology is not supported
* on mezz cards */
+   BFA_STATUS_DPORT_ENABLED = 235, /* D-port mode is already enabled */
+   BFA_STATUS_DPORT_DISABLED = 236, /* D-port mode is already disabled */
+   BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
+   BFA_STATUS_DPORT_ERR = 245, /* D-port mode is enabled */
BFA_STATUS_MAX_VAL  /* Unknown error code */
 };
 #define bfa_status_t enum bfa_status
@@ -508,6 +513,17 @@ struct bfa_ioc_aen_data_s {
 };
 
 /*
+ * D-port states
+ *
+*/
+enum bfa_dport_state {
+   BFA_DPORT_ST_DISABLED   = 0,/* D-port is Disabled */
+   BFA_DPORT_ST_DISABLING  = 1,/* D-port is Disabling */
+   BFA_DPORT_ST_ENABLING   = 2,/* D-port is Enabling */
+   BFA_DPORT_ST_ENABLED= 3,/* D-port is Enabled */
+};
+
+/*
  * -- mfg definitions 
  */
 
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 20749f1..4533b28 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -722,6 +722,7 @@ enum bfa_port_states {
BFA_PORT_ST_PREBOOT_DISABLED= 13,
BFA_PORT_ST_TOGGLING_QWAIT  = 14,
BFA_PORT_ST_ACQ_ADDR= 15,
+   BFA_PORT_ST_DPORT   = 16,
BFA_PORT_ST_MAX_STATE,
 };
 
diff --git a/drivers/scsi/bfa/bfa_port.c b/drivers/scsi/bfa/bfa_port.c
index 95e4ad8..8ea7697 100644
--- a/drivers/scsi/bfa/bfa_port.c
+++ b/drivers/scsi/bfa/bfa_port.c
@@ -250,6 +250,12 @@ bfa_port_enable(struct bfa_port_s *port, 
bfa_port_endis_cbfn_t cbfn,
return BFA_STATUS_IOC_FAILURE;
}
 
+   /* if port is d-port enabled, return error */
+   if (port-dport_enabled) {
+   bfa_trc(port, BFA_STATUS_DPORT_ERR);
+   return BFA_STATUS_DPORT_ERR;
+   }
+
if (port-endis_pending) {
bfa_trc(port, BFA_STATUS_DEVBUSY);
return BFA_STATUS_DEVBUSY;
@@ -300,6 +306,12 @@ bfa_port_disable(struct bfa_port_s *port, 
bfa_port_endis_cbfn_t cbfn,
return BFA_STATUS_IOC_FAILURE;
}
 
+   /* if port is d-port enabled, return error */
+   if (port-dport_enabled) {
+   bfa_trc(port, BFA_STATUS_DPORT_ERR);
+   return BFA_STATUS_DPORT_ERR;
+   }
+
if (port-endis_pending) {
bfa_trc(port, BFA_STATUS_DEVBUSY);
return BFA_STATUS_DEVBUSY;
@@ -431,6 +443,10 @@ bfa_port_notify(void *arg, enum bfa_ioc_event_e event)
port-endis_cbfn = NULL;
port-endis_pending = BFA_FALSE;
}
+
+   /* clear D-port mode */
+   if (port-dport_enabled)
+   bfa_port_set_dportenabled(port, BFA_FALSE);
break;
default:
break;
@@ -467,6 +483,7 @@ bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s 
*ioc,

[PATCH 08/15] bfa: Fabric Assigned Address implementation fix

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Made changes such that once the PWWN is acquired from the fabric 
through FAA,
  and if the FAPWWN configuration is modified on the switch side, 
driver should
  show relevant information to the user.
- Added logic to cache the reason code when the given port is disabled 
implicitly
  due to FAA error condition.
- If the port is disabled, while sending SCN to upper layer, update the
  reason code appropriately. With this, BFA FC port state machine will 
enter
  into faa_err_config state. This state will be shown to the user.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs_svc.h |3 +-
 drivers/scsi/bfa/bfa_svc.c  |   88 ++-
 2 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 4533b28..76ea10d 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -721,7 +721,7 @@ enum bfa_port_states {
BFA_PORT_ST_FWMISMATCH  = 12,
BFA_PORT_ST_PREBOOT_DISABLED= 13,
BFA_PORT_ST_TOGGLING_QWAIT  = 14,
-   BFA_PORT_ST_ACQ_ADDR= 15,
+   BFA_PORT_ST_FAA_MISCONFIG   = 15,
BFA_PORT_ST_DPORT   = 16,
BFA_PORT_ST_MAX_STATE,
 };
@@ -792,6 +792,7 @@ enum bfa_port_linkstate_rsn {
BFA_PORT_LINKSTATE_RSN_LOCAL_FAULT  = 9,
BFA_PORT_LINKSTATE_RSN_REMOTE_FAULT = 10,
BFA_PORT_LINKSTATE_RSN_TIMEOUT  = 11,
+   BFA_PORT_LINKSTATE_RSN_FAA_MISCONFIG= 12,
 
 
 
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 549bd45..309ab2a 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -69,6 +69,7 @@ enum bfa_fcport_sm_event {
BFA_FCPORT_SM_HWFAIL= 9,/*  IOC h/w failure */
BFA_FCPORT_SM_DPORTENABLE = 10, /*  enable dport  */
BFA_FCPORT_SM_DPORTDISABLE = 11,/*  disable dport */
+   BFA_FCPORT_SM_FAA_MISCONFIG = 12,   /* FAA misconfiguratin */
 };
 
 /*
@@ -201,6 +202,8 @@ static void bfa_fcport_sm_iocfail(struct bfa_fcport_s 
*fcport,
enum bfa_fcport_sm_event event);
 static voidbfa_fcport_sm_dport(struct bfa_fcport_s *fcport,
enum bfa_fcport_sm_event event);
+static voidbfa_fcport_sm_faa_misconfig(struct bfa_fcport_s *fcport,
+   enum bfa_fcport_sm_event event);
 
 static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
enum bfa_fcport_ln_sm_event event);
@@ -231,6 +234,7 @@ static struct bfa_sm_table_s hal_port_sm_table[] = {
{BFA_SM(bfa_fcport_sm_iocdown), BFA_PORT_ST_IOCDOWN},
{BFA_SM(bfa_fcport_sm_iocfail), BFA_PORT_ST_IOCDOWN},
{BFA_SM(bfa_fcport_sm_dport), BFA_PORT_ST_DPORT},
+   {BFA_SM(bfa_fcport_sm_faa_misconfig), BFA_PORT_ST_FAA_MISCONFIG},
 };
 
 
@@ -2180,6 +2184,12 @@ bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
break;
 
+   case BFA_FCPORT_SM_FAA_MISCONFIG:
+   bfa_fcport_reset_linkinfo(fcport);
+   bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
+   bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
+   break;
+
default:
bfa_sm_fault(fcport-bfa, event);
}
@@ -2236,6 +2246,12 @@ bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
break;
 
+   case BFA_FCPORT_SM_FAA_MISCONFIG:
+   bfa_fcport_reset_linkinfo(fcport);
+   bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
+   bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
+   break;
+
default:
bfa_sm_fault(fcport-bfa, event);
}
@@ -2322,6 +2338,12 @@ bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
break;
 
+   case BFA_FCPORT_SM_FAA_MISCONFIG:
+   bfa_fcport_reset_linkinfo(fcport);
+   bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
+   bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
+   break;
+
default:
bfa_sm_fault(fcport-bfa, event);
}
@@ -2415,6 +2437,12 @@ bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
}
break;
 
+   case BFA_FCPORT_SM_FAA_MISCONFIG:
+   bfa_fcport_reset_linkinfo(fcport);
+   bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
+   bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
+   

[PATCH 09/15] bfa: Add support for user to configure bandwidth on QoS priorities

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Made changes to provide an option for user to configure the
  bandwidth percentage for High/Medium/Low QoS priorities.

Signed-off-by: Sudarsana Reddy Kalluru skall...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h |2 +
 drivers/scsi/bfa/bfa_defs_svc.h |   15 ++--
 drivers/scsi/bfa/bfa_svc.c  |   46 +-
 drivers/scsi/bfa/bfa_svc.h  |3 ++
 drivers/scsi/bfa/bfad_bsg.c |   26 +-
 drivers/scsi/bfa/bfad_bsg.h |8 ++
 6 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index b4d5d87..f8df2c9 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -190,6 +190,8 @@ enum bfa_status {
BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
BFA_STATUS_LOOP_UNSUPP_MEZZ = 231, /* Loop topology is not supported
* on mezz cards */
+   BFA_STATUS_QOS_BW_INVALID = 234,   /* Invalid QOS bandwidth
+   * configuration */
BFA_STATUS_DPORT_ENABLED = 235, /* D-port mode is already enabled */
BFA_STATUS_DPORT_DISABLED = 236, /* D-port mode is already disabled */
BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 76ea10d..18e4f6b 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -522,6 +522,14 @@ enum bfa_qos_bw_alloc {
BFA_QOS_BW_LOW  =  10,  /*  bandwidth allocation for Low */
 };
 #pragma pack(1)
+
+struct bfa_qos_bw_s {
+   u8  qos_bw_set;
+   u8  high;
+   u8  med;
+   u8  low;
+};
+
 /*
  * QoS attribute returned in QoS Query
  */
@@ -529,7 +537,8 @@ struct bfa_qos_attr_s {
u8  state;  /*  QoS current state */
u8  rsvd1[3];
u32 total_bb_cr;/*  Total BB Credits */
-   u32 rsvd2[2];
+   struct bfa_qos_bw_s qos_bw; /* QOS bw cfg */
+   struct bfa_qos_bw_s qos_bw_op;  /* QOS bw operational */
 };
 
 /*
@@ -887,7 +896,7 @@ struct bfa_port_cfg_s {
u8   rsvd1;
u16  path_tov;  /*  device path timeout */
u16  q_depth;   /*  SCSI Queue depth*/
-   u32  rsvd2;
+   struct bfa_qos_bw_s qos_bw; /* QOS bandwidth*/
 };
 #pragma pack()
 
@@ -935,7 +944,7 @@ struct bfa_port_attr_s {
 
/* FCoE specific  */
u16 fcoe_vlan;
-   u8  rsvd1[2];
+   u8  rsvd1[6];
 };
 
 /*
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 309ab2a..299c1c8 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -3067,6 +3067,7 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
 */
do_gettimeofday(tv);
fcport-stats_reset_time = tv.tv_sec;
+   fcport-stats_dma_ready = BFA_FALSE;
 
/*
 * initialize and set default configuration
@@ -3077,6 +3078,9 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
port_cfg-maxfrsize = 0;
 
port_cfg-trl_def_speed = BFA_PORT_SPEED_1GBPS;
+   port_cfg-qos_bw.high = BFA_QOS_BW_HIGH;
+   port_cfg-qos_bw.med = BFA_QOS_BW_MED;
+   port_cfg-qos_bw.low = BFA_QOS_BW_LOW;
 
INIT_LIST_HEAD(fcport-stats_pending_q);
INIT_LIST_HEAD(fcport-statsclr_pending_q);
@@ -3596,6 +3600,7 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
case BFI_FCPORT_I2H_ENABLE_RSP:
if (fcport-msgtag == i2hmsg.penable_rsp-msgtag) {
 
+   fcport-stats_dma_ready = BFA_TRUE;
if (fcport-use_flash_cfg) {
fcport-cfg = i2hmsg.penable_rsp-port_cfg;
fcport-cfg.maxfrsize =
@@ -3611,6 +3616,8 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
else
fcport-trunk.attr.state =
BFA_TRUNK_DISABLED;
+   fcport-qos_attr.qos_bw =
+   i2hmsg.penable_rsp-port_cfg.qos_bw;
fcport-use_flash_cfg = BFA_FALSE;
}
 
@@ -3619,6 +3626,9 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
else
fcport-qos_attr.state = BFA_QOS_DISABLED;
 
+   fcport-qos_attr.qos_bw_op =
+   i2hmsg.penable_rsp-port_cfg.qos_bw;
+
bfa_sm_send_event(fcport, 

[PATCH 10/15] bfa: Add support for IO throttling at port level

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Add capability to limit the number of exchanges on a port to
  avoid queue-full conditions from the target side.

Signed-off-by: Sudarsana Reddy Kalluru skall...@brocade.com
Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_core.c  |9 +++-
 drivers/scsi/bfa/bfa_defs_svc.h  |   13 +
 drivers/scsi/bfa/bfa_fcpim.c |  105 --
 drivers/scsi/bfa/bfa_fcpim.h |9 +++-
 drivers/scsi/bfa/bfa_fcs_rport.c |6 ++-
 drivers/scsi/bfa/bfa_ioc.h   |3 +
 drivers/scsi/bfa/bfad_bsg.c  |   36 +
 drivers/scsi/bfa/bfad_bsg.h  |9 +++
 8 files changed, 182 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 837879d..eb29628 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -983,7 +983,8 @@ bfa_iocfc_send_cfg(void *bfa_arg)
cfg_info-single_msix_vec = 1;
cfg_info-endian_sig = BFI_IOC_ENDIAN_SIG;
cfg_info-num_cqs = cfg-fwcfg.num_cqs;
-   cfg_info-num_ioim_reqs = cpu_to_be16(cfg-fwcfg.num_ioim_reqs);
+   cfg_info-num_ioim_reqs = cpu_to_be16(bfa_fcpim_get_throttle_cfg(bfa,
+  cfg-fwcfg.num_ioim_reqs));
cfg_info-num_fwtio_reqs = cpu_to_be16(cfg-fwcfg.num_fwtio_reqs);
 
bfa_dma_be_addr_set(cfg_info-cfgrsp_addr, iocfc-cfgrsp_dma.pa);
@@ -1245,10 +1246,14 @@ bfa_iocfc_qreg(struct bfa_s *bfa, struct 
bfi_iocfc_qreg_s *qreg)
 static void
 bfa_iocfc_res_recfg(struct bfa_s *bfa, struct bfa_iocfc_fwcfg_s *fwcfg)
 {
+   struct bfa_iocfc_s  *iocfc   = bfa-iocfc;
+   struct bfi_iocfc_cfg_s  *cfg_info = iocfc-cfginfo;
+
bfa_fcxp_res_recfg(bfa, fwcfg-num_fcxp_reqs);
bfa_uf_res_recfg(bfa, fwcfg-num_uf_bufs);
bfa_rport_res_recfg(bfa, fwcfg-num_rports);
-   bfa_fcp_res_recfg(bfa, fwcfg-num_ioim_reqs);
+   bfa_fcp_res_recfg(bfa, cpu_to_be16(cfg_info-num_ioim_reqs),
+ fwcfg-num_ioim_reqs);
bfa_tskim_res_recfg(bfa, fwcfg-num_tskim_reqs);
 }
 
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 18e4f6b..0e37e23 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -875,6 +875,19 @@ struct bfa_lunmask_cfg_s {
struct bfa_lun_mask_s   lun_list[MAX_LUN_MASK_CFG];
 };
 
+struct bfa_throttle_cfg_s {
+   u16 is_valid;
+   u16 value;
+   u32 rsvd;
+};
+
+struct bfa_defs_fcpim_throttle_s {
+   u16 max_value;
+   u16 cur_value;
+   u16 cfg_value;
+   u16 rsvd;
+};
+
 /*
  *  Physical port configuration
  */
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 4118d84..27b5609 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -3703,6 +3703,7 @@ bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
struct bfa_mem_dma_s *seg_ptr;
u16 idx, nsegs, num_io_req;
 
+   fcp-max_ioim_reqs = cfg-fwcfg.num_ioim_reqs;
fcp-num_ioim_reqs = cfg-fwcfg.num_ioim_reqs;
fcp-num_fwtio_reqs  = cfg-fwcfg.num_fwtio_reqs;
fcp-num_itns   = cfg-fwcfg.num_rports;
@@ -3725,6 +3726,7 @@ bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
bfa_iocfc_set_snsbase(bfa, idx, fcp-snsbase[idx].pa);
}
 
+   fcp-throttle_update_required = 1;
bfa_fcpim_attach(fcp, bfad, cfg, pcidev);
 
bfa_iotag_attach(fcp);
@@ -3763,23 +3765,33 @@ bfa_fcp_iocdisable(struct bfa_s *bfa)
 {
struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
 
-   /* Enqueue unused ioim resources to free_q */
-   list_splice_tail_init(fcp-iotag_unused_q, fcp-iotag_ioim_free_q);
-
bfa_fcpim_iocdisable(fcp);
 }
 
 void
-bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw)
+bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw, u16 max_ioim_fw)
 {
struct bfa_fcp_mod_s*mod = BFA_FCP_MOD(bfa);
struct list_head*qe;
int i;
 
+   /* Update io throttle value only once during driver load time */
+   if (!mod-throttle_update_required)
+   return;
+
for (i = 0; i  (mod-num_ioim_reqs - num_ioim_fw); i++) {
bfa_q_deq_tail(mod-iotag_ioim_free_q, qe);
list_add_tail(qe, mod-iotag_unused_q);
}
+
+   if (mod-num_ioim_reqs != num_ioim_fw) {
+   bfa_trc(bfa, mod-num_ioim_reqs);
+   bfa_trc(bfa, num_ioim_fw);
+   }
+
+   mod-max_ioim_reqs = max_ioim_fw;
+   mod-num_ioim_reqs = num_ioim_fw;
+   mod-throttle_update_required = 0;
 }
 
 void
@@ -3837,3 +3849,88 @@ bfa_iotag_attach(struct bfa_fcp_mod_s *fcp)
 
bfa_mem_kva_curp(fcp) = (u8 *) iotag;
 }
+
+
+/**
+ * To send config req, first try to use throttle value from 

[PATCH 11/15] bfa: Add support to configure min/max bandwidth for a pcifn

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Added support to configure minimum bandwidth for a pcifn.
- Minimum bandwith is guaranteed at per queue level.
- Added support to update pcifn bandwidth dynamically without
  a server reboot.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_core.c |9 +
 drivers/scsi/bfa/bfa_defs.h |4 +++-
 drivers/scsi/bfa/bfa_ioc.c  |   20 
 drivers/scsi/bfa/bfa_ioc.h  |8 
 drivers/scsi/bfa/bfad_bsg.c |   20 +---
 drivers/scsi/bfa/bfad_bsg.h |3 ++-
 drivers/scsi/bfa/bfi.h  |3 ++-
 7 files changed, 41 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index eb29628..89ebd44 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -838,19 +838,20 @@ void
 bfa_isr_enable(struct bfa_s *bfa)
 {
u32 umsk;
-   int pci_func = bfa_ioc_pcifn(bfa-ioc);
+   int port_id = bfa_ioc_portid(bfa-ioc);
 
-   bfa_trc(bfa, pci_func);
+   bfa_trc(bfa, bfa_ioc_pcifn(bfa-ioc));
+   bfa_trc(bfa, port_id);
 
bfa_msix_ctrl_install(bfa);
 
if (bfa_asic_id_ct2(bfa-ioc.pcidev.device_id)) {
umsk = __HFN_INT_ERR_MASK_CT2;
-   umsk |= pci_func == 0 ?
+   umsk |= port_id == 0 ?
__HFN_INT_FN0_MASK_CT2 : __HFN_INT_FN1_MASK_CT2;
} else {
umsk = __HFN_INT_ERR_MASK;
-   umsk |= pci_func == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
+   umsk |= port_id == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
}
 
writel(umsk, bfa-iocfc.bfa_regs.intr_status);
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index f8df2c9..f0b251e 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -190,6 +190,7 @@ enum bfa_status {
BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
BFA_STATUS_LOOP_UNSUPP_MEZZ = 231, /* Loop topology is not supported
* on mezz cards */
+   BFA_STATUS_INVALID_BW = 233,/* Invalid bandwidth value */
BFA_STATUS_QOS_BW_INVALID = 234,   /* Invalid QOS bandwidth
* configuration */
BFA_STATUS_DPORT_ENABLED = 235, /* D-port mode is already enabled */
@@ -749,7 +750,8 @@ struct bfa_ablk_cfg_pf_s {
u8  rsvd[1];
u16 num_qpairs;
u16 num_vectors;
-   u32 bw;
+   u16 bw_min;
+   u16 bw_max;
 };
 
 struct bfa_ablk_cfg_port_s {
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index be33725..a8fcc81 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -3019,7 +3019,6 @@ bfa_ablk_config_swap(struct bfa_ablk_cfg_s *cfg)
struct bfa_ablk_cfg_inst_s *cfg_inst;
int i, j;
u16 be16;
-   u32 be32;
 
for (i = 0; i  BFA_ABLK_MAX; i++) {
cfg_inst = cfg-inst[i];
@@ -3030,8 +3029,10 @@ bfa_ablk_config_swap(struct bfa_ablk_cfg_s *cfg)
cfg_inst-pf_cfg[j].num_qpairs = be16_to_cpu(be16);
be16 = cfg_inst-pf_cfg[j].num_vectors;
cfg_inst-pf_cfg[j].num_vectors = be16_to_cpu(be16);
-   be32 = cfg_inst-pf_cfg[j].bw;
-   cfg_inst-pf_cfg[j].bw = be16_to_cpu(be32);
+   be16 = cfg_inst-pf_cfg[j].bw_min;
+   cfg_inst-pf_cfg[j].bw_min = be16_to_cpu(be16);
+   be16 = cfg_inst-pf_cfg[j].bw_max;
+   cfg_inst-pf_cfg[j].bw_max = be16_to_cpu(be16);
}
}
 }
@@ -3173,7 +3174,8 @@ bfa_ablk_query(struct bfa_ablk_s *ablk, struct 
bfa_ablk_cfg_s *ablk_cfg,
 
 bfa_status_t
 bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
-   u8 port, enum bfi_pcifn_class personality, int bw,
+   u8 port, enum bfi_pcifn_class personality,
+   u16 bw_min, u16 bw_max,
bfa_ablk_cbfn_t cbfn, void *cbarg)
 {
struct bfi_ablk_h2i_pf_req_s *m;
@@ -3197,7 +3199,8 @@ bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
bfi_h2i_set(m-mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_CREATE,
bfa_ioc_portid(ablk-ioc));
m-pers = cpu_to_be16((u16)personality);
-   m-bw = cpu_to_be32(bw);
+   m-bw_min = cpu_to_be16(bw_min);
+   m-bw_max = cpu_to_be16(bw_max);
m-port = port;
bfa_ioc_mbox_queue(ablk-ioc, ablk-mb);
 
@@ -3297,8 +3300,8 @@ bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port, 
enum bfa_mode_s mode,
 }
 
 bfa_status_t
-bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, int bw,
-   bfa_ablk_cbfn_t cbfn, void *cbarg)
+bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, u16 bw_min,
+  u16 

[PATCH 12/15] bfa: Support Power on Hours display and diag temp sensor fixes

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Add Power On Hours display support during sfpshow
- Fix to properly set the diag temperature sensor status variable.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h |   29 +
 drivers/scsi/bfa/bfa_defs_svc.h |4 
 drivers/scsi/bfa/bfa_ioc.c  |   14 +-
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index f0b251e..daf7314 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -918,11 +918,40 @@ struct sfp_diag_ext_s {
u8  ext_status_ctl[2];
 };
 
+/*
+ * Diagnostic: Data Fields -- Address A2h
+ * General Use Fields: User Writable Table - Features's Control Registers
+ * Total 32 bytes
+ */
+struct sfp_usr_eeprom_s {
+   u8  rsvd1[2];   /* 128-129 */
+   u8  ewrap;  /* 130 */
+   u8  rsvd2[2];   /*  */
+   u8  owrap;  /* 133 */
+   u8  rsvd3[2];   /*  */
+   u8  prbs;   /* 136: PRBS 7 generator */
+   u8  rsvd4[2];   /*  */
+   u8  tx_eqz_16;  /* 139: TX Equalizer (16xFC) */
+   u8  tx_eqz_8;   /* 140: TX Equalizer (8xFC) */
+   u8  rsvd5[2];   /*  */
+   u8  rx_emp_16;  /* 143: RX Emphasis (16xFC) */
+   u8  rx_emp_8;   /* 144: RX Emphasis (8xFC) */
+   u8  rsvd6[2];   /*  */
+   u8  tx_eye_adj; /* 147: TX eye Threshold Adjust */
+   u8  rsvd7[3];   /*  */
+   u8  tx_eye_qctl;/* 151: TX eye Quality Control */
+   u8  tx_eye_qres;/* 152: TX eye Quality Result */
+   u8  rsvd8[2];   /*  */
+   u8  poh[3]; /* 155-157: Power On Hours */
+   u8  rsvd9[2];   /*  */
+};
+
 struct sfp_mem_s {
struct sfp_srlid_base_s srlid_base;
struct sfp_srlid_ext_s  srlid_ext;
struct sfp_diag_base_s  diag_base;
struct sfp_diag_ext_s   diag_ext;
+   struct sfp_usr_eeprom_s usr_eeprom;
 };
 
 /*
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 0e37e23..ec03c8c 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -258,6 +258,7 @@ struct bfa_fw_port_lksm_stats_s {
u32hwsm_lrr_rx;/*  No. of times LRR rx-ed by HWSM  */
u32hwsm_lr_rx; /*  No. of times LR rx-ed by HWSM   */
u32bbsc_lr;/* LKSM LR tx for credit recovery   */
+   u32 rsvd;
 };
 
 struct bfa_fw_port_snsm_stats_s {
@@ -270,6 +271,9 @@ struct bfa_fw_port_snsm_stats_s {
u32sync_lost;  /*  Sync loss count */
u32sig_lost;   /*  Signal loss count   */
u32asn8g_attempts; /* SNSM HWSM at 8Gbps attempts  */
+   u32adapt_success;  /* SNSM adaptation success   */
+   u32adapt_fails;/* SNSM adaptation failures */
+   u32adapt_ign_fails;/* SNSM adaptation failures ignored */
 };
 
 struct bfa_fw_port_physm_stats_s {
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index a8fcc81..caf1e45 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -4687,22 +4687,25 @@ diag_tempsensor_comp(struct bfa_diag_s *diag, 
bfi_diag_ts_rsp_t *rsp)
diag-tsensor.temp-temp = be16_to_cpu(rsp-temp);
diag-tsensor.temp-ts_junc = rsp-ts_junc;
diag-tsensor.temp-ts_brd = rsp-ts_brd;
-   diag-tsensor.temp-status = BFA_STATUS_OK;
 
if (rsp-ts_brd) {
+   /* tsensor.temp-status is brd_temp status */
+   diag-tsensor.temp-status = rsp-status;
if (rsp-status == BFA_STATUS_OK) {
diag-tsensor.temp-brd_temp =
be16_to_cpu(rsp-brd_temp);
-   } else {
-   bfa_trc(diag, rsp-status);
+   } else
diag-tsensor.temp-brd_temp = 0;
-   diag-tsensor.temp-status = BFA_STATUS_DEVBUSY;
-   }
}
+
+   bfa_trc(diag, rsp-status);
bfa_trc(diag, rsp-ts_junc);
bfa_trc(diag, rsp-temp);
bfa_trc(diag, rsp-ts_brd);
bfa_trc(diag, rsp-brd_temp);
+
+   /* tsensor status is always good bcos we always have junction temp */
+   diag-tsensor.status = BFA_STATUS_OK;
diag-tsensor.cbfn(diag-tsensor.cbarg, diag-tsensor.status);
diag-tsensor.lock = 0;
 }
@@ -4931,6 +4934,7 @@ bfa_diag_tsensor_query(struct bfa_diag_s *diag,
diag-tsensor.temp = result;
diag-tsensor.cbfn = cbfn;
diag-tsensor.cbarg = cbarg;
+   diag-tsensor.status = BFA_STATUS_OK;
 
/* Send msg to fw */
diag_tempsensor_send(diag);
-- 
1.7.3.rc1

--
To unsubscribe from 

[PATCH 13/15] bfa: Add support to read/update the FRU data.

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Add FRU sub-module to support FRU read/write/update.
- Add support to read/write from the temp FRU module.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfa_core.c|   14 ++
 drivers/scsi/bfa/bfa_defs.h|1 +
 drivers/scsi/bfa/bfa_ioc.c |  445 
 drivers/scsi/bfa/bfa_ioc.h |   49 +
 drivers/scsi/bfa/bfa_modules.h |1 +
 drivers/scsi/bfa/bfad_bsg.c|  125 +++-
 drivers/scsi/bfa/bfad_bsg.h|   35 +++-
 drivers/scsi/bfa/bfi.h |   47 -
 drivers/scsi/bfa/bfi_ms.h  |1 +
 9 files changed, 713 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 89ebd44..342d7d9 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -165,6 +165,16 @@ bfa_com_phy_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
bfa_phy_memclaim(phy, phy_dma-kva_curp, phy_dma-dma_curp, mincfg);
 }
 
+static void
+bfa_com_fru_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
+{
+   struct bfa_fru_s*fru = BFA_FRU(bfa);
+   struct bfa_mem_dma_s*fru_dma = BFA_MEM_FRU_DMA(bfa);
+
+   bfa_fru_attach(fru, bfa-ioc, bfa, bfa-trcmod, mincfg);
+   bfa_fru_memclaim(fru, fru_dma-kva_curp, fru_dma-dma_curp, mincfg);
+}
+
 /*
  * BFA IOC FC related definitions
  */
@@ -1752,6 +1762,7 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct 
bfa_meminfo_s *meminfo,
struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
struct bfa_mem_dma_s *diag_dma = BFA_MEM_DIAG_DMA(bfa);
struct bfa_mem_dma_s *phy_dma = BFA_MEM_PHY_DMA(bfa);
+   struct bfa_mem_dma_s *fru_dma = BFA_MEM_FRU_DMA(bfa);
 
WARN_ON((cfg == NULL) || (meminfo == NULL));
 
@@ -1776,6 +1787,8 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct 
bfa_meminfo_s *meminfo,
bfa_mem_dma_setup(meminfo, diag_dma, bfa_diag_meminfo());
bfa_mem_dma_setup(meminfo, phy_dma,
  bfa_phy_meminfo(cfg-drvcfg.min_cfg));
+   bfa_mem_dma_setup(meminfo, fru_dma,
+ bfa_fru_meminfo(cfg-drvcfg.min_cfg));
 }
 
 /*
@@ -1848,6 +1861,7 @@ bfa_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
bfa_com_flash_attach(bfa, cfg-drvcfg.min_cfg);
bfa_com_diag_attach(bfa);
bfa_com_phy_attach(bfa, cfg-drvcfg.min_cfg);
+   bfa_com_fru_attach(bfa, cfg-drvcfg.min_cfg);
 }
 
 /*
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index daf7314..0efdf31 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -196,6 +196,7 @@ enum bfa_status {
BFA_STATUS_DPORT_ENABLED = 235, /* D-port mode is already enabled */
BFA_STATUS_DPORT_DISABLED = 236, /* D-port mode is already disabled */
BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
+   BFA_STATUS_FRU_NOT_PRESENT = 240, /* fru module not present */
BFA_STATUS_DPORT_ERR = 245, /* D-port mode is enabled */
BFA_STATUS_MAX_VAL  /* Unknown error code */
 };
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index caf1e45..29bf74d 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -5956,3 +5956,448 @@ bfa_dconf_modexit(struct bfa_s *bfa)
struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
bfa_sm_send_event(dconf, BFA_DCONF_SM_EXIT);
 }
+
+/*
+ * FRU specific functions
+ */
+
+#define BFA_FRU_DMA_BUF_SZ 0x02000 /* 8k dma buffer */
+#define BFA_FRU_CHINOOK_MAX_SIZE 0x1
+#define BFA_FRU_LIGHTNING_MAX_SIZE 0x200
+
+static void
+bfa_fru_notify(void *cbarg, enum bfa_ioc_event_e event)
+{
+   struct bfa_fru_s *fru = cbarg;
+
+   bfa_trc(fru, event);
+
+   switch (event) {
+   case BFA_IOC_E_DISABLED:
+   case BFA_IOC_E_FAILED:
+   if (fru-op_busy) {
+   fru-status = BFA_STATUS_IOC_FAILURE;
+   fru-cbfn(fru-cbarg, fru-status);
+   fru-op_busy = 0;
+   }
+   break;
+
+   default:
+   break;
+   }
+}
+
+/*
+ * Send fru write request.
+ *
+ * @param[in] cbarg - callback argument
+ */
+static void
+bfa_fru_write_send(void *cbarg, enum bfi_fru_h2i_msgs msg_type)
+{
+   struct bfa_fru_s *fru = cbarg;
+   struct bfi_fru_write_req_s *msg =
+   (struct bfi_fru_write_req_s *) fru-mb.msg;
+   u32 len;
+
+   msg-offset = cpu_to_be32(fru-addr_off + fru-offset);
+   len = (fru-residue  BFA_FRU_DMA_BUF_SZ) ?
+   fru-residue : BFA_FRU_DMA_BUF_SZ;
+   msg-length = cpu_to_be32(len);
+
+   /*
+* indicate if it's the last msg of the whole write operation
+*/
+   msg-last = (len == fru-residue) ? 1 : 0;
+
+   bfi_h2i_set(msg-mh, BFI_MC_FRU, 

[PATCH 14/15] bfa: Firmware image naming convention update

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Change details:
- Modified the firmware naming convention to contain the
  firmware image version (3.1.0.0).
- The new convention is firmware-image-firmware-version.bin
- The change will enforce loading only compatible firmware with this 
driver
  and also avoid over-writing the old firmware image in-order to load 
new
  version driver as the firmware names used to be the same.

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfad.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index c374949..895b0e5 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -63,9 +63,9 @@ int   max_rport_logins = BFA_FCS_MAX_RPORT_LOGINS;
 u32bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
 u32*bfi_image_cb, *bfi_image_ct, *bfi_image_ct2;
 
-#define BFAD_FW_FILE_CBcbfw.bin
-#define BFAD_FW_FILE_CTctfw.bin
-#define BFAD_FW_FILE_CT2   ct2fw.bin
+#define BFAD_FW_FILE_CBcbfw-3.1.0.0.bin
+#define BFAD_FW_FILE_CTctfw-3.1.0.0.bin
+#define BFAD_FW_FILE_CT2   ct2fw-3.1.0.0.bin
 
 static u32 *bfad_load_fwimg(struct pci_dev *pdev);
 static void bfad_free_fwimg(void);
-- 
1.7.3.rc1

--
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 15/15] bfa: Update the driver version to 3.1.2.1

2012-09-21 Thread kgudipat
From: Krishna Gudipati kgudi...@brocade.com

Signed-off-by: Krishna Gudipati kgudi...@brocade.com
---
 drivers/scsi/bfa/bfad_drv.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 1840651..0c64a04 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -57,7 +57,7 @@
 #ifdef BFA_DRIVER_VERSION
 #define BFAD_DRIVER_VERSIONBFA_DRIVER_VERSION
 #else
-#define BFAD_DRIVER_VERSION3.1.2.0
+#define BFAD_DRIVER_VERSION3.1.2.1
 #endif
 
 #define BFAD_PROTO_NAME FCPI_NAME
-- 
1.7.3.rc1

--
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