[PATCH 6/17] qla2xxx: Add MBX command routines for ISP24xx support.

2005-07-06 Thread Andrew Vasquez
Add MBX command routines for ISP24xx support.

Generalize several routines [qla2x00_load_ram_ext(),
qla2x00_execute_fw(), qla2x00_verify_checksum()] to handle
larger addressing space.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]
---

 drivers/scsi/qla2xxx/qla_def.h  |3 
 drivers/scsi/qla2xxx/qla_gbl.h  |   28 +
 drivers/scsi/qla2xxx/qla_init.c |   33 +
 drivers/scsi/qla2xxx/qla_mbx.c  |  988 ++-
 drivers/scsi/qla2xxx/qla_os.c   |5 
 5 files changed, 811 insertions(+), 246 deletions(-)

ec7266d75bdacf5afc0f07a2ceacde8ea6a69d1d
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2028,7 +2028,8 @@ struct isp_operations {
int (*abort_target) (struct fc_port *);
int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
uint8_t, uint8_t, uint16_t *, uint8_t);
-   int (*fabric_logout) (struct scsi_qla_host *, uint16_t);
+   int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
+   uint8_t, uint8_t);
 
uint16_t (*calc_req_entries) (uint16_t);
void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -104,10 +104,10 @@ extern int
 qla2x00_load_ram(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t);
 
 extern int
-qla2x00_load_ram_ext(scsi_qla_host_t *, dma_addr_t, uint32_t, uint16_t);
+qla2x00_load_ram_ext(scsi_qla_host_t *, dma_addr_t, uint32_t, uint32_t);
 
 extern int
-qla2x00_execute_fw(scsi_qla_host_t *);
+qla2x00_execute_fw(scsi_qla_host_t *, uint32_t);
 
 extern void
 qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *,
@@ -123,7 +123,7 @@ extern int
 qla2x00_mbx_reg_test(scsi_qla_host_t *);
 
 extern int
-qla2x00_verify_checksum(scsi_qla_host_t *);
+qla2x00_verify_checksum(scsi_qla_host_t *, uint32_t);
 
 extern int
 qla2x00_issue_iocb(scsi_qla_host_t *, void *, dma_addr_t, size_t);
@@ -133,7 +133,7 @@ qla2x00_abort_command(scsi_qla_host_t *,
 
 #if USE_ABORT_TGT
 extern int
-qla2x00_abort_target(fc_port_t *fcport);
+qla2x00_abort_target(fc_port_t *);
 #endif
 
 extern int
@@ -167,12 +167,18 @@ qla2x00_send_sns(scsi_qla_host_t *, dma_
 extern int
 qla2x00_login_fabric(scsi_qla_host_t *, uint16_t, uint8_t, uint8_t, uint8_t,
 uint16_t *, uint8_t);
+extern int
+qla24xx_login_fabric(scsi_qla_host_t *, uint16_t, uint8_t, uint8_t, uint8_t,
+uint16_t *, uint8_t);
 
 extern int
 qla2x00_login_local_device(scsi_qla_host_t *, uint16_t, uint16_t *, uint8_t);
 
 extern int
-qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id);
+qla2x00_fabric_logout(scsi_qla_host_t *, uint16_t, uint8_t, uint8_t, uint8_t);
+
+extern int
+qla24xx_fabric_logout(scsi_qla_host_t *, uint16_t, uint8_t, uint8_t, uint8_t);
 
 extern int
 qla2x00_full_login_lip(scsi_qla_host_t *ha);
@@ -187,6 +193,18 @@ qla2x00_get_resource_cnts(scsi_qla_host_
 extern int
 qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map);
 
+extern int qla24xx_abort_command(scsi_qla_host_t *, srb_t *);
+extern int qla24xx_abort_target(fc_port_t *);
+
+extern int qla2x00_system_error(scsi_qla_host_t *);
+
+extern int
+qla2x00_get_serdes_params(scsi_qla_host_t *, uint16_t *, uint16_t *,
+uint16_t *);
+
+extern int
+qla2x00_set_serdes_params(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t);
+
 /*
  * Global Function Prototypes in qla_isr.c source file.
  */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -331,7 +331,9 @@ qla2x00_isp_firmware(scsi_qla_host_t *ha
qla_printk(KERN_INFO, ha, RISC CODE NOT loaded\n);
 
/* Verify checksum of loaded RISC code. */
-   rval = qla2x00_verify_checksum(ha);
+   rval = qla2x00_verify_checksum(ha,
+   IS_QLA24XX(ha) || IS_QLA25XX(ha) ? RISC_SADDRESS :
+   *ha-brd_info-fw_info[0].fwstart);
}
 
if (rval) {
@@ -756,13 +758,17 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
DEBUG(printk(scsi(%ld): Verifying Checksum of loaded RISC 
code.\n, ha-host_no));
 
-   rval = qla2x00_verify_checksum(ha);
+   rval = qla2x00_verify_checksum(ha,
+   IS_QLA24XX(ha) || IS_QLA25XX(ha) ? RISC_SADDRESS :
+   *ha-brd_info-fw_info[0].fwstart);
if (rval == QLA_SUCCESS) {
/* Start firmware execution. */
DEBUG(printk(scsi(%ld): Checksum OK, start 
firmware.\n, ha-host_no));
 
-   rval = qla2x00_execute_fw(ha);
+   rval = qla2x00_execute_fw(ha,
+   IS_QLA24XX(ha) || IS_QLA25XX(ha) ? RISC_SADDRESS

Re: [PATCH] remove some dead code in qla2xxx

2005-04-22 Thread Andrew Vasquez
ACK.

James, please apply - several of my follow-up patches are based
off a tree with these changes.



Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

= drivers/scsi/qla2xxx/qla_dbg.c 1.12 vs edited =
--- 1.12/drivers/scsi/qla2xxx/qla_dbg.c 2005-04-13 17:45:53 +02:00
+++ edited/drivers/scsi/qla2xxx/qla_dbg.c   2005-04-18 16:22:48 +02:00
@@ -1063,8 +1063,7 @@
return;
 
printk(  sp flags=0x%x\n, sp-flags);
-   printk(  r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n,
-   sp-r_start, sp-u_start, sp-f_start, sp-state);
+   printk(  state=%d\n, sp-state);
 }
 
 #if defined(QL_DEBUG_ROUTINES)
= drivers/scsi/qla2xxx/qla_def.h 1.30 vs edited =
--- 1.30/drivers/scsi/qla2xxx/qla_def.h 2005-04-13 17:45:53 +02:00
+++ edited/drivers/scsi/qla2xxx/qla_def.h   2005-04-18 16:35:47 +02:00
@@ -252,31 +252,12 @@
/* Request state */
uint16_t state;
 
-   /* Timing counts. */
-   unsigned long e_start;  /* Start of extend timeout */
-   unsigned long r_start;  /* Start of request */
-   unsigned long u_start;  /* When sent to RISC */
-   unsigned long f_start;  /* When placed in FO queue*/
-
/* Single transfer DMA context */
dma_addr_t dma_handle;
 
uint32_t request_sense_length;
uint8_t *request_sense_ptr;
 
-   int ext_history;
-
-   /* Suspend delay */
-   int delay;
-
-   /* Raw completion info for use by failover ? */
-   uint8_t fo_retry_cnt;   /* Retry count this request */
-   uint8_t err_id; /* error id */
-#define SRB_ERR_PORT   1   /* Request failed -- port down */
-#define SRB_ERR_LOOP   2   /* Request failed -- loop down */
-#define SRB_ERR_DEVICE 3   /* Request failed -- device error */
-#define SRB_ERR_OTHER  4
-
/* SRB magic number */
uint16_t magic;
 #define SRB_MAGIC   0x10CB
@@ -2082,23 +2063,8 @@
uint32_tcurrent_outstanding_cmd; 
srb_t   *status_srb;/* Status continuation entry. */
 
-   unsigned long   last_irq_cpu;   /* cpu where we got our last irq */
-
uint16_t   revision;
uint8_t   ports;
-   u_longactthreads;
-   u_longipreq_cnt;
-   u_longqthreads;
-
-   uint32_ttotal_isr_cnt;  /* Interrupt count */
-   uint32_ttotal_isp_aborts;   /* controller err cnt */
-   uint32_ttotal_lip_cnt;  /* LIP cnt */
-   uint32_ttotal_dev_errs; /* device error cnt */
-   uint32_ttotal_ios;  /* IO cnt */
-   uint64_ttotal_bytes;/* xfr byte cnt */
-   uint32_ttotal_mbx_timeout;  /* mailbox timeout cnt */
-   uint32_ttotal_loop_resync;  /* loop resyn cnt */
-   uint32_tdropped_frame_error_cnt;
 
/* ISP configuration data. */
uint16_tloop_id;/* Host adapter loop id */
@@ -2124,8 +2090,6 @@
 #define P2P_LOOP  3
 
 uint8_tmarker_needed; 
-   uint8_t sns_retry_cnt;
-   uint8_t mem_err;
 
uint8_t interrupts_on;
 
@@ -2138,16 +2102,11 @@
uint16_tnvram_base;
 
uint16_tloop_reset_delay;
-   uint16_tminimum_timeout;
uint8_t retry_count;
uint8_t login_timeout;
uint16_tr_a_tov;
int port_down_retry_count;
-   uint8_t loop_down_timeout;
uint8_t mbx_count;
-   uint16_tmax_probe_luns;
-   uint16_tmax_luns;
-   uint16_tmax_targets;
uint16_tlast_loop_id;
 
 uint32_t   login_retry_count; 
@@ -2181,7 +2140,6 @@
uint8_t dpc_active;  /* DPC routine is active */
 
/* Timeout timers. */
-   uint8_t queue_restart_timer;   
uint8_t loop_down_abort_time;/* port down timer */
atomic_tloop_down_timer; /* loop down timer */
uint8_t link_down_timeout;   /* link down timeout */
@@ -2230,18 +2188,6 @@
 
mbx_cmd_t   mc;
 
-   uint8_t *cmdline;
-
-   uint32_t failover_type;
-   uint32_t failback_delay;
-   unsigned long   cfg_flags;
-#defineCFG_ACTIVE  0   /* CFG during a failover, event update, 
or ioctl */
-#defineCFG_FAILOVER1   /* CFG during path change */
-
-   uint32_tbinding_type;
-#define BIND_BY_PORT_NAME  0
-#define BIND_BY_PORT_ID1
-
/* Basic firmware related information. */
struct qla_board_info   *brd_info;
uint16_tfw_major_version;
@@ -2273,12 +2219,6 @@
uint8_t node_name[WWN_SIZE];
uint8_t nvram_version; 
uint32_t

Re: Removing a disk from the qla2xxx driver.

2005-04-22 Thread Andrew Vasquez
On Wed, 20 Apr 2005, Rajat  Jain, Noida wrote:

 
 The driver documentstion says it has the qlascan command which can help in
 adding new disks by the following procedure:
 
 1) First add the Disk to the HBA.
 2) # echo scsi-qlascan  /proc/scsi/driver-name/adapter-id (The
 qla2xxx driver will rescan)

FYI:  these /proc interfaces are not present in the mainline
(upstream) qla2xxx driver.  Besides, typically these steps are only
needed if the topology isolates a LIP or SCN.  If the additional
device causes an RSCN (in the case of a fabric environment) to
propagate from the switch, the HBA will perform an SNS discovery and
login to the device.

Another alternative to forcing a LIP (and subsequently cause a
rescan), would be to initiate a bus-reset via sg_reset:

# sg_reset -b /dev/sg0

The only downside is the /dev/sg0 device-node requirement.

 3) # echo scsi add-single-device 0 1 2 3 /proc/scsi/scsi (The mid-level
 will add the device)
 

Yes, this will instruct the mid-layer to perform its own scan.

 However, what I wanted to know was that how can I REMOVE a SCSI device from
 the HBA at run time? By logic, I believe that the sequence should be:
 
 1) # echo scsi remove-single-device 0 1 2 3 /proc/scsi/scsi (The
 mid-level will remove the device)

This is the only step that is needed.

 2) Then remove the Disk from the HBA.
 3) # echo scsi-qlascan  /proc/scsi/driver-name/adapter-id (The
 qla2xxx driver will rescan, and will remove the disk)
 

No, the HBA's recognition of the device persists throughout the
driver's lifetime -- this is not necessary.

Hope this helps.

Regards,
Andrew Vasquez
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PATCH [6/5] qla2xxx: update version :)

2005-04-22 Thread Andrew Vasquez
On Tue, 19 Apr 2005, Christoph Hellwig wrote:

 On Wed, Apr 13, 2005 at 02:24:36PM -0700, Andrew Vasquez wrote:
  Ok, here's the deal -- QLogic's standard 8.01.00 driver contains the
  following major additions:
  
  * support for 4Gb ISPs
  * FCIP support
 
 Btw, any plans to do proper FCIP support integrated with the transport
 class code?


Ok, I'll bite (since this is the second time I've heard about FCIP
being 'integrated' with the transport classes) -- what did you have in
mind?  There's already a clear set of mature networking interface with
which a networking card's driver uses to interface with the stack.

Are you looking to generalize those interfaces
(open/hard_xmit/stop/etc.) into helpers transport helpers?


 (and finally fixing the damn NAA bug violating RFC 2625 ;-))
 -

Yes, I'll see what I can do from this side on getting this addressed
once and for all.

--
av
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PATCH [2/5] qla2xxx: add remote port codes...

2005-04-19 Thread Andrew Vasquez
On Wed, 13 Apr 2005, Christoph Hellwig wrote:

 
  +struct scsi_transport_template *
  +qla2x00_alloc_transport_tmpl(void)
  +{
  +   return (fc_attach_transport(qla2xxx_transport_functions));
  +}
 
 I don't see much of a point in this function vs just making
 qla2xxx_transport_functions non-static.
 
  --- a/drivers/scsi/qla2xxx/qla_gbl.h2005-04-13 08:38:23.0 
  -0700
  +++ b/drivers/scsi/qla2xxx/qla_gbl.h2005-04-13 08:42:33.0 
  -0700
  @@ -24,6 +24,7 @@
   #define__QLA_GBL_H
   
   #include linux/interrupt.h
  +#include scsi/scsi_transport.h
 
 shouldn't be needed, a simple forward-declaration of
 struct scsi_transport_template should do it.
 

Ok, makes sense.

James, please apply:


Make transport-functions structure non-static.  Replace #include of
scsi_transport.h with a forward declaration.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_attr.c |8 +---
 drivers/scsi/qla2xxx/qla_gbl.h  |4 ++--
 drivers/scsi/qla2xxx/qla_os.c   |3 ++-
 3 files changed, 5 insertions(+), 10 deletions(-)

drivers/scsi/qla2xxx/qla_attr.c: fb67d67bee97823d4d209cdbd9b356a5a2370683
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -300,7 +300,7 @@ qla2x00_set_rport_loss_tmo(struct fc_rpo
rport-dev_loss_tmo = ha-port_down_retry_count + 5;
 }
 
-static struct fc_function_template qla2xxx_transport_functions = {
+struct fc_function_template qla2xxx_transport_functions = {
 
.show_host_node_name = 1,
.show_host_port_name = 1,
@@ -322,12 +322,6 @@ static struct fc_function_template qla2x
 
 };
 
-struct scsi_transport_template *
-qla2x00_alloc_transport_tmpl(void)
-{
-   return (fc_attach_transport(qla2xxx_transport_functions));
-}
-
 void
 qla2x00_init_host_attr(scsi_qla_host_t *ha)
 {
drivers/scsi/qla2xxx/qla_gbl.h: e49d05b0167879a042b09941c240274530784c65
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -24,7 +24,6 @@
 #define__QLA_GBL_H
 
 #include linux/interrupt.h
-#include scsi/scsi_transport.h
 
 extern void qla2x00_remove_one(struct pci_dev *);
 extern int qla2x00_probe_one(struct pci_dev *, struct qla_board_info *);
@@ -248,9 +247,10 @@ extern void qla2x00_cancel_io_descriptor
 /*
  * Global Function Prototypes in qla_attr.c source file.
  */
+struct fc_function_template;
+extern struct fc_function_template qla2xxx_transport_functions;
 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
-extern struct scsi_transport_template *qla2x00_alloc_transport_tmpl(void);
 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
drivers/scsi/qla2xxx/qla_os.c: f949c701ec022d6db1791df0e55ce3e534359a1c
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2350,7 +2350,8 @@ qla2x00_module_init(void)
 #if DEBUG_QLA2100
strcat(qla2x00_version_str, -debug);
 #endif
-   qla2xxx_transport_template = qla2x00_alloc_transport_tmpl();
+   qla2xxx_transport_template =
+   fc_attach_transport(qla2xxx_transport_functions);
if (!qla2xxx_transport_template)
return -ENODEV;
 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PATCH [2/5] qla2xxx: add remote port codes...

2005-04-19 Thread Andrew Vasquez
On Wed, 13 Apr 2005, Christoph Hellwig wrote:

  atomic_set(fcport-state, FCS_ONLINE);
  +   if (ha-flags.init_done)
  +   qla2x00_reg_remote_port(ha, fcport);
   }
 
 ...
 
  -   goto probe_failed;
  +   goto probe_alloc_failed;
  }
   
  +   pci_set_drvdata(pdev, ha);
  +   host-this_id = 255;
  +   host-cmd_per_lun = 3;
  +   host-unique_id = ha-instance;
  +   host-max_cmd_len = MAX_CMDSZ;
  +   host-max_channel = ha-ports - 1;
  +   host-max_id = ha-max_targets;
  +   host-max_lun = ha-max_luns;
  +   host-transportt = qla2xxx_transport_template;
  +   if (scsi_add_host(host, pdev-dev))
  +   goto probe_alloc_failed;
  +
  +   qla2x00_alloc_sysfs_attr(ha);
  +
  if (qla2x00_initialize_adapter(ha) 
  !(ha-device_flags  DFLG_NO_CABLE)) {
 
 Now this I don't undersant.  You're moving the host registration earlier,
 maybe too earlier but I haven't checked that yet,


Yeah, that hunk is a residual of some other (trashy) changes I made
during early fc_rport integration and really should be reverted back
to the original...

 why do you still need
 the special case for delaying registration of the targets?
 

Ok, this is actually a concern I have with the current fc_rport
implementation (and yes, I realize I'm a day late) -- the auto-scan
logic employed during the creation of the fc_rport (via
fc_remote_port_add()).

Before I get into that though, let me answer your question -- the
reason I post-register the ports is because the driver is not ready
(during init-time) to process I/O originating from queuecommand().

This topic was discussed briefly during the implementation of
fc_rport -- some suggestions, if I recall correctly, were to either
block the host or post-register the rport at an appropriate time.
Each options has its caveats -- issuing and fc_remote_port_add() while
the host is blocked of course forces the user to perform a manual
rescan at some later time.  Post-registration on the otherhand still
requires some 'external' port structure (fc_port in the case of
qla2xxx) to exist until fc_rport creation and thus negating the
benefits and purpose of fc_rport-dd_data.  And again, since scanning
occurs immediately for 'target-type' (roles) fc_rports, the
fc_rport-dd_data which one would like to use at slave_alloc() time is
unset (NULL).

Perhaps I'm missing something fundamental -- as I've glanced through
lpfc and see slave_alloc() doing linear scans through its known lists
of ports trying to determine the proper lpfc_nodelist, whereas a:

rport = fc_remote_port_add() -- would create and fc_rport
given the rport_identifiers.

rport-dd_data = internal port data -- caller populates
 rport-dd_data with
 internal driver
 structure  (i.e. fc_port)

fc_remote_port_scan(rport) -- initiate scan.

  qla2xxx_slave_alloc() implementation would be something like:

struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
fc_port_t *fcport;

if (!rport)
return -ENXIO;
fcport = (struct fc_port *) rport-dd_data;
if (!fcport)
return -ENXIO;
...

One possibility (as to not break current functionality) is to add an
addition role modifier, say FC_RPORT_ROLE_NO_SCAN and | it into
rport_ids.roles prior to fc_remote_port_add() to indicate no scanning
should take place during the call.  Then once ready, the driver could
issue the corresponding fc_remote_port_scan() on the rport.

Looking ahead, this may also be useful in the case of port
authentication (i.e. FC-SP).

Does this sound like a reasonable extension?  I'll code up something
in the morning if others are interested?

 Also please propagate the full error that scsi_add_host returned.
 

Sure, I post another set of patches to address this and the early
host-addition code.

Thanks,
AV
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PATCH [6/5] qla2xxx: update version :)

2005-04-15 Thread Andrew Vasquez
On Wed, 13 Apr 2005, Christoph Hellwig wrote:

 On Wed, Apr 13, 2005 at 01:50:07PM -0700, Andrew Vasquez wrote:
Update version.
 
 Btw, Documentation/scsi/qla2xxx.revision.notes hasn't been updated for
 ages.  Either scrap it or give it some love, I don't mind too much which
 of these you prefer.
 

I'd prefer to drop it.  

James, please apply the following patch.  Thanks.





  Remove stale revisions file.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 Documentation/scsi/qla2xxx.revision.notes |  457 --
 1 files changed, 457 deletions(-)

--- a/Documentation/scsi/qla2xxx.revision.notes 2005-04-11 09:45:10.0 
-0700
+++ b/Documentation/scsi/qla2xxx.revision.notes 2005-04-31 16:00:00.0 
-0800
@@ -1,457 +0,0 @@
-/*
- * QLogic ISP2200 and ISP2300 Linux Driver Revision List File.
- *
- 
- *
- * Revision History
- *
- *  Rev  8.00.00b8 December 5, 2003AV
- * - Instruct mid-layer to perform initial scan.
- *
- *  Rev  8.00.00b7 December 5, 2003AV
- * - Resync with Linux Kernel 2.6.0-test11.
- * - Add basic NVRAM parser (extras/qla_nvr).
- *
- *  Rev  8.00.00b7-pre11 December 3, 2003  AV
- * - Sanitize the scsi_qla_host structure:
- *   - Purge unused elements.
- *   - Reorganize high-priority members (cache coherency).
- * - Add support for NVRAM access via a sysfs binary attribute:
- *   - Consolidate semaphore locking access.
- * - Fix more PCI posting issues.
- * - Add extras directory for dump/NVRAM tools.
- * - Remove unused qla_vendor.c file.
- *
- *  Rev  8.00.00b7-pre11 November 26, 2003 DG/AV
- * - Merge several patches from Christoph Hellwig [EMAIL PROTECTED]:
- *   - in Linux 2.6 both pci and the scsi layer use the generic
- * dma direction bits, use them directly instead of the scsi
- * and pci variants and the (noop) conversion routines.
- * - Fix _IOXX_BAD() usage for external IOCTL interface.
- * - Use atomic construct for HA loop_state member.
- * - Add generic model description text for HBA types.
- *
- *  Rev  8.00.00b7-pre5November 17, 2003   AV
- * - Merge several patches from Christoph Hellwig [EMAIL PROTECTED]:
- *   - patch to split the driver into a common qla2xxx.ko and a
- * qla2?00.ko for each HBA type - the latter modules are
- * only very small wrappers, mostly for the firmware
- * images, all the meat is in the common qla2xxx.ko.
- *   - make the failover code optional.
- *   - kill useless lock_kernel in dpc thread startup.
- *   - no need for modversions hacks in 2.6 (or 2.4).
- *   - kill qla2x00_register_with_Linux.
- *   - simplify EH code, cmd or it's hostdata can't be NULL, no
- * need to search whether the host it's ours, the midlayer
- * makes sure it won't call into a driver for some else
- * host.
- * - Merge several patches from Jes Sorensen
- *   [EMAIL PROTECTED]:
- *   - Call qla2x00_config_dma_addressing() before performing
- * any consistent allocations. This is required since the
- * dma mask settings will affect the memory
- * pci_alloc_consistent() will return.
- *   - Call pci_set_consistent_dma_mask() to allow for 64 bit
- * consistent allocations, required on some platforms such
- * as the SN2.
- *   - Wait 20 usecs (not sure how long is really necessary,
- * but this seems safe) after setting CSR_ISP_SOFT_RESET in
- * the ctrl_status register as the card doesn't respond to
- * PCI reads while in reset state. This causes a machine
- * check on some architectures.
- *   - Flush PCI writes before calling udelay() to ensure the
- * write is not sitting idle in-flight for a while before
- * hitting the hardware.
- *   - Include linux/vmalloc.h in qla_os.c since it uses
- * vmalloc().
- *   - Use auto-negotiate link speed when using default
- * parameters rather than NVRAM settings. Disable NVRAM
- * reading on SN2 since it's not possible to execute the
- * HBA's BIOS on an SN2. I suggest doing something similar
- * for all architectures that do not provide x86 BIOS
- * emulation.
- * - Clean-up slab-cache allocations:
- *   - locking.
- *   - mempool allocations in case of low-memory situations.
- * - Fallback to GA_NXT scan if GID_PT call returns more than
- *   MAX_FIBRE_DEVICES.
- * - Preserve iterating port ID across GA_NXT calls in
- *   qla2x00_find_all_fabric_devs().
- * - Pre-calculate ASCII firmware dump length as to not incur the
- *   cost-to-calculate at each invocation of a read().
- *
- *  Rev  8.00.00b6 November 4, 2003AV
- * - Add new 2300 TPX firmware (3.02.18).
- *
- *  Rev  8.00.00b6-pre25 October 20, 2003  RA

Re: PATCH [4/5] qla2xxx: cleanup DMA mappings...

2005-04-15 Thread Andrew Vasquez
On Wed, 13 Apr 2005, Christoph Hellwig wrote:

  +   struct page *page;
  +   unsigned long   offset;
  +
  +   page = virt_to_page(cmd-request_buffer);
  +   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
  +   req_dma = pci_map_page(ha-pdev, page, offset,
  +   cmd-request_bufflen, cmd-sc_data_direction);
 
 Why're you're redoing that code please switch to pci_map_single insted
 of these nasty operations to go to the page first, the code will become
 a lit simpler too, e.g. the above becomes just:
 
   req_dma = pci_map_single(ha-pdev, cmd-request_buffer,
   cmd-request_bufflen, cmd-sc_data_direction);
 

Ok, how about this as an alternative.



  Don't use cmd-request-nr_hw_segments as it may not be initialized
  (SG_IO in particular bypasses anything that initializes this and just
  uses scsi_do_req to insert a scsi_request directly on the head of the
  queue) and a bogus value here can trip up the checks to make sure that
  the number of segments will fit in the queue ring buffer, resulting in
  commands that are never completed.

  Fix up several issues with PCI DMA mapping and failure to check return
  values on the mappings.

  Make the check for space in the ring buffer happen after the DMA mapping
  is done since any checks done before the mapping has taken place are
  bogus.

  Doug Ledford [EMAIL PROTECTED].

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_iocb.c |   72 
+++--
 1 files changed, 33 insertions(+), 39 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_iocb.c   2005-04-13 08:45:53.0 -0700
+++ b/drivers/scsi/qla2xxx/qla_iocb.c   2005-04-15 08:24:01.0 -0700
@@ -216,18 +216,7 @@
cur_seg++;
}
} else {
-   dma_addr_t  req_dma;
-   struct page *page;
-   unsigned long   offset;
-
-   page = virt_to_page(cmd-request_buffer);
-   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
-   req_dma = pci_map_page(ha-pdev, page, offset,
-   cmd-request_bufflen, cmd-sc_data_direction);
-
-   sp-dma_handle = req_dma;
-
-   *cur_dsd++ = cpu_to_le32(req_dma);
+   *cur_dsd++ = cpu_to_le32(sp-dma_handle);
*cur_dsd++ = cpu_to_le32(cmd-request_bufflen);
}
 }
@@ -299,19 +288,8 @@
cur_seg++;
}
} else {
-   dma_addr_t  req_dma;
-   struct page *page;
-   unsigned long   offset;
-
-   page = virt_to_page(cmd-request_buffer);
-   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
-   req_dma = pci_map_page(ha-pdev, page, offset,
-   cmd-request_bufflen, cmd-sc_data_direction);
-
-   sp-dma_handle = req_dma;
-
-   *cur_dsd++ = cpu_to_le32(LSD(req_dma));
-   *cur_dsd++ = cpu_to_le32(MSD(req_dma));
+   *cur_dsd++ = cpu_to_le32(LSD(sp-dma_handle));
+   *cur_dsd++ = cpu_to_le32(MSD(sp-dma_handle));
*cur_dsd++ = cpu_to_le32(cmd-request_bufflen);
}
 }
@@ -345,6 +323,8 @@
ha = sp-ha;
reg = ha-iobase;
cmd = sp-cmd;
+   /* So we know we haven't pci_map'ed anything yet */
+   tot_dsds = 0;
 
/* Send marker if required */
if (ha-marker_needed != 0) {
@@ -369,8 +349,27 @@
if (index == MAX_OUTSTANDING_COMMANDS)
goto queuing_error;
 
+   /* Map the sg table so we have an accurate count of sg entries needed */
+   if (cmd-use_sg) {
+   sg = (struct scatterlist *) cmd-request_buffer;
+   tot_dsds = pci_map_sg(ha-pdev, sg, cmd-use_sg,
+   cmd-sc_data_direction);
+   if (tot_dsds == 0)
+   goto queuing_error;
+   } else if (cmd-request_bufflen) {
+   dma_addr_t  req_dma;
+
+   req_dma = pci_map_single(ha-pdev, cmd-request_buffer,
+   cmd-request_bufflen, cmd-sc_data_direction);
+   if (dma_mapping_error(req_dma))
+   goto queuing_error;
+
+   sp-dma_handle = req_dma;
+   tot_dsds = 1;
+   }
+
/* Calculate the number of request entries needed. */
-   req_cnt = (ha-calc_request_entries)(cmd-request-nr_hw_segments);
+   req_cnt = (ha-calc_request_entries)(tot_dsds);
if (ha-req_q_cnt  (req_cnt + 2)) {
cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
if (ha-req_ring_index  cnt)
@@ -382,19 +381,6 @@
if (ha-req_q_cnt  (req_cnt + 2))
goto queuing_error;
 
-   /* Finally, we have enough space, now perform mappings. */
-   tot_dsds = 0;
-   if (cmd-use_sg

PATCH [0/5] qla2xxx: remote port rework...

2005-04-13 Thread Andrew Vasquez

All,

With the remote port patches in the pipeline for 2.6.12, I'd like to
submit the following set of qla2xxx patches which strip many of the
legacy features from the driver.  Again, these 'features' have been
superceded in functionality and simplicity by additions present with
fc_rports.

Here's the breakdown of patches being submitted:

1) Remove internal command queuing.  This entails removal of the
   driver's *_queue lists as well as modifications and removal of
   routines which used them.  With the queuing removed -- the
   driver will be unable to tolerate cable-pulls.  Thus we depend
   on the next patch for support.

2) Add initial support for FC remote port infrastructure.

3) Remove internal lun discovery routines and support structures.
   The mid-layer has a more exhaustive and fully capable set of
   functions for lun discovery.

4) Clean-up DMA mappings -- patch originally submitted by
   Doug Ledford [EMAIL PROTECTED].

Don't use cmd-request-nr_hw_segments as it may not be initialized
(SG_IO in particular bypasses anything that initializes this and just
uses scsi_do_req to insert a scsi_request directly on the head of the
queue) and a bogus value here can trip up the checks to make sure that
the number of segments will fit in the queue ring buffer, resulting in
commands that are never completed.

Fix up several issues with PCI DMA mapping and failure to check return
values on the mappings.

Make the check for space in the ring buffer happen after the DMA mapping
is done since any checks done before the mapping has taken place are
bogus.

5) Remove /proc support.


Other patches in the queue:

a) Complete fc_host attributes support.

b) Support new queue-depth operations (via change_queue_depth()).

c) additional hardware (ISP) support.

d) Additional dusting and scrubbing: unused functions and structures
   left over from the cleanup.

e) firmware loading via request_firmware() infrastructure.

f) lock simplification and consolidation.


Regards,
Andrew Vasquez
QLogic Corporation
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PATCH [2/5] qla2xxx: add remote port codes...

2005-04-13 Thread Andrew Vasquez
  Add initial support for FC remote port infrastructure.

 o Use fc_remote_port...() registration and block/unlock
   functions.
 o Consolidate 'attribute' (fc-remote/sysfs) helpers into
   new qla_attr.c file.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/Makefile   |2 
 drivers/scsi/qla2xxx/qla_attr.c |  323 
 drivers/scsi/qla2xxx/qla_def.h  |3 
 drivers/scsi/qla2xxx/qla_gbl.h  |   12 +
 drivers/scsi/qla2xxx/qla_init.c |   31 +++
 drivers/scsi/qla2xxx/qla_os.c   |  302 -
 6 files changed, 403 insertions(+), 270 deletions(-)

--- a/drivers/scsi/qla2xxx/Makefile 2005-04-12 15:56:53.0 -0700
+++ b/drivers/scsi/qla2xxx/Makefile 2005-04-13 08:41:21.0 -0700
@@ -1,7 +1,7 @@
 EXTRA_CFLAGS += -DUNIQUE_FW_NAME
 
 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
-   qla_dbg.o qla_sup.o qla_rscn.o
+   qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o
 
 qla2100-y := ql2100.o ql2100_fw.o
 qla2200-y := ql2200.o ql2200_fw.o
--- a/drivers/scsi/qla2xxx/qla_attr.c   1969-12-31 16:00:00.0 -0800
+++ b/drivers/scsi/qla2xxx/qla_attr.c   2005-04-13 08:41:21.0 -0700
@@ -0,0 +1,323 @@
+/*
+ *  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003-2005 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include qla_def.h
+
+#include linux/version.h
+#include scsi/scsi_transport_fc.h
+
+/* SYSFS attributes - 
*/
+
+static ssize_t
+qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf, loff_t off,
+size_t count)
+{
+   struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+   struct device, kobj)));
+
+   if (ha-fw_dump_reading == 0)
+   return 0;
+   if (off  ha-fw_dump_buffer_len)
+   return 0;
+   if (off + count  ha-fw_dump_buffer_len)
+   count = ha-fw_dump_buffer_len - off;
+
+   memcpy(buf, ha-fw_dump_buffer[off], count);
+
+   return (count);
+}
+
+static ssize_t
+qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off,
+size_t count)
+{
+   struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+   struct device, kobj)));
+   int reading;
+   uint32_t dump_size;
+
+   if (off != 0)
+   return (0);
+
+   reading = simple_strtol(buf, NULL, 10);
+   switch (reading) {
+   case 0:
+   if (ha-fw_dump_reading == 1) {
+   qla_printk(KERN_INFO, ha,
+   Firmware dump cleared on (%ld).\n,
+   ha-host_no);
+
+   vfree(ha-fw_dump_buffer);
+   free_pages((unsigned long)ha-fw_dump,
+   ha-fw_dump_order);
+
+   ha-fw_dump_reading = 0;
+   ha-fw_dump_buffer = NULL;
+   ha-fw_dump = NULL;
+   }
+   break;
+   case 1:
+   if (ha-fw_dump != NULL  !ha-fw_dump_reading) {
+   ha-fw_dump_reading = 1;
+
+   dump_size = FW_DUMP_SIZE_1M;
+   if (ha-fw_memory_size  0x2) 
+   dump_size = FW_DUMP_SIZE_128K;
+   else if (ha-fw_memory_size  0x8) 
+   dump_size = FW_DUMP_SIZE_512K;
+   ha-fw_dump_buffer = (char *)vmalloc(dump_size);
+   if (ha-fw_dump_buffer == NULL) {
+   qla_printk(KERN_WARNING, ha,
+   Unable to allocate memory for firmware 
+   dump buffer (%d).\n, dump_size);
+
+   ha-fw_dump_reading = 0;
+   return (count);
+   }
+   qla_printk(KERN_INFO, ha,
+   Firmware dump ready for read on (%ld).\n,
+   ha-host_no);
+   memset(ha-fw_dump_buffer, 0, dump_size);
+   if (IS_QLA2100(ha) || IS_QLA2200(ha))
+   qla2100_ascii_fw_dump(ha);
+   else
+   qla2300_ascii_fw_dump(ha);
+   ha

PATCH [4/5] qla2xxx: cleanup DMA mappings...

2005-04-13 Thread Andrew Vasquez
  Don't use cmd-request-nr_hw_segments as it may not be initialized
  (SG_IO in particular bypasses anything that initializes this and just
  uses scsi_do_req to insert a scsi_request directly on the head of the
  queue) and a bogus value here can trip up the checks to make sure that
  the number of segments will fit in the queue ring buffer, resulting in
  commands that are never completed.

  Fix up several issues with PCI DMA mapping and failure to check return
  values on the mappings.

  Make the check for space in the ring buffer happen after the DMA mapping
  is done since any checks done before the mapping has taken place are
  bogus.

  Doug Ledford [EMAIL PROTECTED].

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_iocb.c |   77 +++-
 1 files changed, 38 insertions(+), 39 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_iocb.c   2005-04-13 08:45:53.0 -0700
+++ b/drivers/scsi/qla2xxx/qla_iocb.c   2005-04-13 08:56:17.0 -0700
@@ -216,18 +216,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *
cur_seg++;
}
} else {
-   dma_addr_t  req_dma;
-   struct page *page;
-   unsigned long   offset;
-
-   page = virt_to_page(cmd-request_buffer);
-   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
-   req_dma = pci_map_page(ha-pdev, page, offset,
-   cmd-request_bufflen, cmd-sc_data_direction);
-
-   sp-dma_handle = req_dma;
-
-   *cur_dsd++ = cpu_to_le32(req_dma);
+   *cur_dsd++ = cpu_to_le32(sp-dma_handle);
*cur_dsd++ = cpu_to_le32(cmd-request_bufflen);
}
 }
@@ -299,19 +288,8 @@ void qla2x00_build_scsi_iocbs_64(srb_t *
cur_seg++;
}
} else {
-   dma_addr_t  req_dma;
-   struct page *page;
-   unsigned long   offset;
-
-   page = virt_to_page(cmd-request_buffer);
-   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
-   req_dma = pci_map_page(ha-pdev, page, offset,
-   cmd-request_bufflen, cmd-sc_data_direction);
-
-   sp-dma_handle = req_dma;
-
-   *cur_dsd++ = cpu_to_le32(LSD(req_dma));
-   *cur_dsd++ = cpu_to_le32(MSD(req_dma));
+   *cur_dsd++ = cpu_to_le32(LSD(sp-dma_handle));
+   *cur_dsd++ = cpu_to_le32(MSD(sp-dma_handle));
*cur_dsd++ = cpu_to_le32(cmd-request_bufflen);
}
 }
@@ -345,6 +323,8 @@ qla2x00_start_scsi(srb_t *sp)
ha = sp-ha;
reg = ha-iobase;
cmd = sp-cmd;
+   /* So we know we haven't pci_map'ed anything yet */
+   tot_dsds = 0;
 
/* Send marker if required */
if (ha-marker_needed != 0) {
@@ -369,8 +349,32 @@ qla2x00_start_scsi(srb_t *sp)
if (index == MAX_OUTSTANDING_COMMANDS)
goto queuing_error;
 
+   /* Map the sg table so we have an accurate count of sg entries needed */
+   if (cmd-use_sg) {
+   sg = (struct scatterlist *) cmd-request_buffer;
+   tot_dsds = pci_map_sg(ha-pdev, sg, cmd-use_sg,
+   cmd-sc_data_direction);
+   if (tot_dsds == 0)
+   goto queuing_error;
+   } else if (cmd-request_bufflen) {
+   dma_addr_t  req_dma;
+   struct page *page;
+   unsigned long   offset;
+
+   page = virt_to_page(cmd-request_buffer);
+   offset = ((unsigned long)cmd-request_buffer  ~PAGE_MASK);
+   req_dma = pci_map_page(ha-pdev, page, offset,
+   cmd-request_bufflen, cmd-sc_data_direction);
+
+   if (dma_mapping_error(req_dma))
+   goto queuing_error;
+
+   sp-dma_handle = req_dma;
+   tot_dsds = 1;
+   }
+
/* Calculate the number of request entries needed. */
-   req_cnt = (ha-calc_request_entries)(cmd-request-nr_hw_segments);
+   req_cnt = (ha-calc_request_entries)(tot_dsds);
if (ha-req_q_cnt  (req_cnt + 2)) {
cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
if (ha-req_ring_index  cnt)
@@ -382,19 +386,6 @@ qla2x00_start_scsi(srb_t *sp)
if (ha-req_q_cnt  (req_cnt + 2))
goto queuing_error;
 
-   /* Finally, we have enough space, now perform mappings. */
-   tot_dsds = 0;
-   if (cmd-use_sg) {
-   sg = (struct scatterlist *) cmd-request_buffer;
-   tot_dsds = pci_map_sg(ha-pdev, sg, cmd-use_sg,
-   cmd-sc_data_direction);
-   if (tot_dsds == 0)
-   goto queuing_error;
-   } else if (cmd-request_bufflen) {
-   tot_dsds++;
-   }
-   req_cnt = (ha-calc_request_entries)(tot_dsds);
-
/* Build command

PATCH [3/5] qla2xxx: remove lun discovery codes...

2005-04-13 Thread Andrew Vasquez
  Remove internal lun discovery routines and support
  structures.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_attr.c   |   51 +-
 drivers/scsi/qla2xxx/qla_dbg.c|5 
 drivers/scsi/qla2xxx/qla_def.h|  103 
 drivers/scsi/qla2xxx/qla_gbl.h|   10 
 drivers/scsi/qla2xxx/qla_init.c   |  864 --
 drivers/scsi/qla2xxx/qla_inline.h |   17 
 drivers/scsi/qla2xxx/qla_iocb.c   |   13 
 drivers/scsi/qla2xxx/qla_isr.c|   37 -
 drivers/scsi/qla2xxx/qla_mbx.c|   21 
 drivers/scsi/qla2xxx/qla_os.c |  282 +---
 10 files changed, 103 insertions(+), 1300 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_attr.c   2005-04-13 08:41:21.0 -0700
+++ b/drivers/scsi/qla2xxx/qla_attr.c   2005-04-13 08:45:53.0 -0700
@@ -227,12 +227,17 @@ qla2x00_get_starget_node_name(struct scs
 {
struct Scsi_Host *host = dev_to_shost(starget-dev.parent);
scsi_qla_host_t *ha = to_qla_host(host);
-os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget-id);
+   fc_port_t *fcport;
uint64_t node_name = 0;
 
-   if (tq-fcport)
-   node_name = be64_to_cpu(*(uint64_t *)tq-fcport-node_name);
-   fc_starget_node_name(starget) = node_name;
+   list_for_each_entry(fcport, ha-fcports, list) {
+   if (starget-id == fcport-os_target_id) {
+   node_name = *(uint64_t *)fcport-node_name;
+   break;
+   }
+   }
+
+   fc_starget_node_name(starget) = be64_to_cpu(node_name);
 }
 
 static void
@@ -240,12 +245,17 @@ qla2x00_get_starget_port_name(struct scs
 {
struct Scsi_Host *host = dev_to_shost(starget-dev.parent);
scsi_qla_host_t *ha = to_qla_host(host);
-os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget-id);
+   fc_port_t *fcport;
uint64_t port_name = 0;
 
-   if (tq-fcport)
-   port_name = be64_to_cpu(*(uint64_t *)tq-fcport-port_name);
-   fc_starget_port_name(starget) = port_name;
+   list_for_each_entry(fcport, ha-fcports, list) {
+   if (starget-id == fcport-os_target_id) {
+   port_name = *(uint64_t *)fcport-port_name;
+   break;
+   }
+   }
+
+   fc_starget_port_name(starget) = be64_to_cpu(port_name);
 }
 
 static void
@@ -253,20 +263,25 @@ qla2x00_get_starget_port_id(struct scsi_
 {
struct Scsi_Host *host = dev_to_shost(starget-dev.parent);
scsi_qla_host_t *ha = to_qla_host(host);
-os_tgt_t *tq = (os_tgt_t *) TGT_Q(ha, starget-id);
-   uint32_t port_id = 0;
+   fc_port_t *fcport;
+   uint32_t port_id = ~0U;
+
+   list_for_each_entry(fcport, ha-fcports, list) {
+   if (starget-id == fcport-os_target_id) {
+   port_id = fcport-d_id.b.domain  16 |
+   fcport-d_id.b.area  8 | fcport-d_id.b.al_pa;
+   break;
+   }
+   }
 
-   if (tq-fcport)
-   port_id = tq-fcport-d_id.b.domain  16 |
-   tq-fcport-d_id.b.area  8 | tq-fcport-d_id.b.al_pa;
fc_starget_port_id(starget) = port_id;
 }
 
 static void
 qla2x00_get_rport_loss_tmo(struct fc_rport *rport)
 {
-   os_tgt_t *tq = rport-dd_data;
-   scsi_qla_host_t *ha = tq-ha;
+   struct Scsi_Host *host = rport_to_shost(rport);
+   scsi_qla_host_t *ha = to_qla_host(host);
 
rport-dev_loss_tmo = ha-port_down_retry_count + 5;
 }
@@ -274,8 +289,8 @@ qla2x00_get_rport_loss_tmo(struct fc_rpo
 static void
 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
 {
-   os_tgt_t *tq = rport-dd_data;
-   scsi_qla_host_t *ha = tq-ha;
+   struct Scsi_Host *host = rport_to_shost(rport);
+   scsi_qla_host_t *ha = to_qla_host(host);
 
if (timeout)
ha-port_down_retry_count = timeout;
@@ -292,7 +307,7 @@ static struct fc_function_template qla2x
.get_host_port_id = qla2x00_get_host_port_id,
.show_host_port_id = 1,
 
-   .dd_fcrport_size = sizeof(os_tgt_t *),
+   .dd_fcrport_size = sizeof(struct fc_port *),
 
.get_starget_node_name = qla2x00_get_starget_node_name,
.show_starget_node_name = 1,
--- a/drivers/scsi/qla2xxx/qla_dbg.c2005-04-13 08:40:14.0 -0700
+++ b/drivers/scsi/qla2xxx/qla_dbg.c2005-04-13 08:45:53.0 -0700
@@ -1065,11 +1065,6 @@ qla2x00_print_scsi_cmd(struct scsi_cmnd 
printk(  sp flags=0x%x\n, sp-flags);
printk(  r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n,
sp-r_start, sp-u_start, sp-f_start, sp-state);
-
-   printk( e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, 
-   port path=%d\n, sp-e_start, sp-ext_history, sp-fo_retry_cnt,
-   sp-lun_queue-fclun-fcport-loop_id,
-   sp-lun_queue-fclun-fcport-cur_path);
 }
 
 #if defined(QL_DEBUG_ROUTINES)
--- a/drivers/scsi/qla2xxx/qla_def.h2005-04-13

PATCH [5/5] qla2xxx: remove /proc interface

2005-04-13 Thread Andrew Vasquez
  Remove /proc support.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_os.c |  254 --
 1 files changed, 254 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_os.c 2005-04-13 08:56:07.0 -0700
+++ b/drivers/scsi/qla2xxx/qla_os.c 2005-04-13 08:58:47.0 -0700
@@ -119,19 +119,6 @@ module_param(ql2xloginretrycount, int, S
 MODULE_PARM_DESC(ql2xloginretrycount,
Specify an alternate value for the NVRAM login retry count.);
 
-/*
- * Proc structures and functions
- */
-struct info_str {
-   char*buffer;
-   int length;
-   off_t   offset;
-   int pos;
-};
-
-static void copy_mem_info(struct info_str *, char *, int);
-static int copy_info(struct info_str *, char *, ...);
-
 static void qla2x00_free_device(scsi_qla_host_t *);
 
 static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
@@ -151,14 +138,9 @@ static int qla2xxx_eh_host_reset(struct 
 static int qla2x00_loop_reset(scsi_qla_host_t *ha);
 static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *);
 
-static int qla2x00_proc_info(struct Scsi_Host *, char *, char **,
-off_t, int, int);
-
 static struct scsi_host_template qla2x00_driver_template = {
.module = THIS_MODULE,
.name   = qla2xxx,
-   .proc_name  = qla2xxx,
-   .proc_info  = qla2x00_proc_info,
.queuecommand   = qla2x00_queuecommand,
 
.eh_abort_handler   = qla2xxx_eh_abort,
@@ -1020,7 +1002,6 @@ qla2xxx_slave_alloc(struct scsi_device *
found++;
break;
}
-   
}
if (!found)
return -ENXIO;
@@ -1484,241 +1465,6 @@ qla2x00_free_device(scsi_qla_host_t *ha)
pci_disable_device(ha-pdev);
 }
 
-
-/*
- * The following support functions are adopted to handle
- * the re-entrant qla2x00_proc_info correctly.
- */
-static void
-copy_mem_info(struct info_str *info, char *data, int len)
-{
-   if (info-pos + len  info-offset + info-length)
-   len = info-offset + info-length - info-pos;
-
-   if (info-pos + len  info-offset) {
-   info-pos += len;
-   return;
-   }
- 
-   if (info-pos  info-offset) {
-   off_t partial;
- 
-   partial = info-offset - info-pos;
-   data += partial;
-   info-pos += partial;
-   len  -= partial;
-   }
- 
-   if (len  0) {
-   memcpy(info-buffer, data, len);
-   info-pos += len;
-   info-buffer += len;
-   }
-}
-
-static int
-copy_info(struct info_str *info, char *fmt, ...)
-{
-   va_list args;
-   char buf[256];
-   int len;
- 
-   va_start(args, fmt);
-   len = vsprintf(buf, fmt, args);
-   va_end(args);
- 
-   copy_mem_info(info, buf, len);
-
-   return (len);
-}
-
-/*
-* qla2x00_proc_info
-*
-* Description:
-*   Return information to handle /proc support for the driver.
-*
-* inout : decides the direction of the dataflow and the meaning of the
-* variables
-* buffer: If inout==0 data is being written to it else read from it
-* (ptr to a page buffer)
-* *start: If inout==0 start of the valid data in the buffer
-* offset: If inout==0 starting offset from the beginning of all
-* possible data to return.
-* length: If inout==0 max number of bytes to be written into the buffer
-* else number of bytes in buffer
-* Returns:
-*  0:  error. errno value.
-* = 0: sizeof data returned.
-*/
-int
-qla2x00_proc_info(struct Scsi_Host *shost, char *buffer,
-char **start, off_t offset, int length, int inout)
-{
-   struct info_str info;
-   int retval = -EINVAL;
-   uint32_ttmp_sn;
-   uint32_t*flags;
-   uint8_t *loop_state;
-   scsi_qla_host_t *ha;
-   char fw_info[30];
- 
-   DEBUG3(printk(KERN_INFO
-   Entering proc_info buff_in=%p, offset=0x%lx, length=0x%x\n,
-   buffer, offset, length);)
-
-   ha = (scsi_qla_host_t *) shost-hostdata;
-
-   if (inout) {
-   /* Has data been written to the file? */
-   DEBUG3(printk(
-   %s: has data been written to the file. \n,
-   __func__);)
-
-   return -ENOSYS;
-   }
-
-   if (start) {
-   *start = buffer;
-   }
-
-   info.buffer = buffer;
-   info.length = length;
-   info.offset = offset;
-   info.pos= 0;
-
-   /* start building the print buffer */
-   copy_info(info,
-   QLogic PCI to Fibre Channel Host Adapter for %s:\n
-   Firmware version %s, ,
-   ha-model_number

PATCH [6/5] qla2xxx: update version :)

2005-04-13 Thread Andrew Vasquez
  Update version.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_version.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_version.h2005-04-13 08:56:07.0 
-0700
+++ b/drivers/scsi/qla2xxx/qla_version.h2005-04-13 08:58:47.0 
-0700
@@ -19,9 +19,9 @@
 /*
  * Driver version 
  */
-#define QLA2XXX_VERSION  8.00.02b4-k
+#define QLA2XXX_VERSION  8.00.02b5-k
 
 #define QLA_DRIVER_MAJOR_VER   8
 #define QLA_DRIVER_MINOR_VER   0
 #define QLA_DRIVER_PATCH_VER   2
-#define QLA_DRIVER_BETA_VER4
+#define QLA_DRIVER_BETA_VER5
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fw: [Bugme-new] [Bug 4473] New: QLogic 2100: SCSI timeouts, device resets, and crashes kernel

2005-04-11 Thread Andrew Vasquez
On Mon, 11 Apr 2005, Mike Anderson wrote:

 I will add the same comment to the bug.
 
 Did this work on a previous version of the kernel? Just checking to
 understand if your connectivity to the storage unit or the unit itself
 could be an issue.
 
 If appears we are receiving timeouts, but on abort the qla is indicating
 that the IO has already been completed. We could have IOs that are taking
 near max timeout and then the error handler races with the completion of
 the IO.
 
 A debug step you could try is to raise the default timeout from 30 to
 something like 60 seconds to see if this effects the error. To do this
 just echo 60  /sys/block/sd${N}/device/timeout. Also you can run iostat
 during your testing to see what you IO times / queue depths look like.
 
 Andrew Vasquez may be able to add more info.
 

Greg,

The logs seem to indicate some (additional) problems with the ISP
after the device-reset completes:

qla2100 :00:06.0: scsi(0:0:1:0): DEVICE RESET ISSUED.
qla2100 :00:06.0: scsi(0:0:1:0): DEVICE RESET SUCCEEDED.
qla2100 :00:06.0: ISP System Error - mbx1=7737h mbx2=dc5h mbx3=0h.
qla2100 :00:06.0: Firmware dump saved to temp buffer (0/dcec).

there is a small tool availble (qla_dmp.sh):

ftp://ftp.qlogic.com/outgoing/linux/beta/8.x/test/qla_dmp.sh

which I'd like you to use if the machine is still in a somewhat usable
state and you see a message similar to the following:

qla2100 :00:06.0: ISP System Error - mbx1=7737h mbx2=dc5h mbx3=0h.
qla2100 :00:06.0: Firmware dump saved to temp buffer (0/dcec).

Execute the following command:

# ./qla_dmp.sh 0

The value passed to qla_dmp.sh should be the same as the first integer
in the 'saved to temp buffer' string (in this example, 0).  If the
operation was successful, a message like to following should be logged
in the messages file.

Firmware dumped to file fw_dump_20041217_023222.txt

compress the file (in this example):

# bzip2 fw_dump_20041217_023222.txt

and forward over the compressed file in addition to the
var/log/messages file.

--
av
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] adding per scsi-host workqueues for defered processing

2005-03-07 Thread Andrew Vasquez
On Sat, 05 Mar 2005, [EMAIL PROTECTED] wrote:

 In thinking this through a little further - if the workq is just
 for the transport, the transport ought to simply create and use
 the workq. There would be no need to modify the host structure.
 
 If we're trying to avoid the potential for several workq's on a
 per-host basis (one by the transport, another by the LLDD, another
 for ?) - the idea of one in the host is worth while.


Yes, that was the general idea -- reduce the number of worker-threads
contending for the same shost resource.  In also thinking a bit more
about this subject, I wonder if there are truly many other (useful)
purposes for a generic 'deferred' work_q at the shost level, other
than for scanning.  

There were some background tasks I shelved until the remote-ports
stuff settled down which I thought could use the deferred processing
thread:

* Initiate LIP -- several customers have asked for this ability as
  several topological configurations isolate disruptive FC events.
* Initiate LLDD rescan (i.e. ports (fibre channel), devices (iSCSI),
  etc.)

I had originally envisioned these functions residing in the transport.


 However, it
 should always be allocated and available. No create flag should
 be needed.
 

Not to sure about that -- a large percentage of drivers would not
(currently) benefit from having a deferred work_q created for each
shost instance it registered.  

--
AV
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2.6 patch] drivers/scsi/qla2xxx/: cleanups

2005-02-28 Thread Andrew Vasquez
On Mon, 28 Feb 2005, Adrian Bunk wrote:

 This patch contains the following cleanups:
 - make needlessly global code static

As Christoph mentioned, the firmware images are auto-generated, so I'd
rather hold off on those deltas.  Besides, I'm hoping in the near
future to drop the firmware from the distribution and begin to use the
request_firmware() interface exclusively.

 - kill the unused global *_version and *_version_str variables
   in the firmware files
 

The driver is also going through some significant overhauling with the
fc_remote_port stuffs -- where most internal queueing is stripped from
the driver.  

 -static __inline__ void qla2x00_add_timer_to_cmd(srb_t *, int);
 -static __inline__ void qla2x00_delete_timer_from_cmd(srb_t *);
 -
 -/**
 -*   qla2x00_add_timer_to_cmd
 -*
 -* Description:
 -*   Creates a timer for the specified command. The timeout is usually
 -*   the command time from kernel minus 2 secs.
 -*
 -* Input:
 -* sp - pointer to validate
 -*
 -* Returns:
 -* None.
 -**/
 -static inline void
 -qla2x00_add_timer_to_cmd(srb_t *sp, int timeout)
 -{
 - init_timer(sp-timer);
 - sp-timer.expires = jiffies + timeout * HZ;
 - sp-timer.data = (unsigned long) sp;
 - sp-timer.function = (void (*) (unsigned long))qla2x00_cmd_timeout;
 - add_timer(sp-timer);
 -}
 -
 -/**
 -*   qla2x00_delete_timer_from_cmd
 -*
 -* Description:
 -*   Delete the timer for the specified command.
 -*
 -* Input:
 -* sp - pointer to validate
 -*
 -* Returns:
 -* None.
 -**/
 -static inline void 
 -qla2x00_delete_timer_from_cmd(srb_t *sp)
 -{
 - if (sp-timer.function != NULL) {
 - del_timer(sp-timer);
 - sp-timer.function =  NULL;
 - sp-timer.data = (unsigned long) NULL;
 - }
 -}
 -

these codes will be dropped from the driver.

  /*
   * SRB allocation cache
   */
 -char srb_cachep_name[16];
 -kmem_cache_t *srb_cachep;
 +static char srb_cachep_name[16];
 +static kmem_cache_t *srb_cachep;
  
  /*
   * Stats for all adpaters.
 @@ -47,13 +47,12 @@
  /*
   * Ioctl related information.
   */
 -int num_hosts;
 -int apiHBAInstance;
 +static int num_hosts;
  
  /*
   * Module parameter information and variables
   */
 -int ql2xmaxqdepth;
 +static int ql2xmaxqdepth;
  module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
  MODULE_PARM_DESC(ql2xmaxqdepth,
   Maximum queue depth to report for target devices.);
 @@ -69,13 +68,13 @@
   Maximum number of command retries to a port that returns
   a PORT-DOWN status.);
  
 -int ql2xretrycount = 20;
 +static int ql2xretrycount = 20;
  module_param(ql2xretrycount, int, S_IRUGO|S_IWUSR);
  MODULE_PARM_DESC(ql2xretrycount,
   Maximum number of mid-layer retries allowed for a command.  
   Default value is 20, );
  
 -int displayConfig;
 +static int displayConfig;
  module_param(displayConfig, int, S_IRUGO|S_IWUSR);
  MODULE_PARM_DESC(displayConfig,
   If 1 then display the configuration used in 
 /etc/modprobe.conf.);
 @@ -100,7 +99,7 @@
   ZIO: Waiting time for Firmware before it generates an 
   interrupt to the host to notify completion of request.);
  
 -int ConfigRequired;
 +static int ConfigRequired;
  module_param(ConfigRequired, int, S_IRUGO|S_IRUSR);
  MODULE_PARM_DESC(ConfigRequired,
   If 1, then only configured devices passed in through the
 @@ -119,7 +118,7 @@
   target returns a NOT READY status.  Default is 10 
   iterations.);
  
 -int ql2xdoinitscan = 1;
 +static int ql2xdoinitscan = 1;
  module_param(ql2xdoinitscan, int, S_IRUGO|S_IWUSR);
  MODULE_PARM_DESC(ql2xdoinitscan,
   Signal mid-layer to perform scan after driver load: 0 -- no 
 @@ -163,6 +162,8 @@

I'll queue-up these for the next set of patches.

Thanks,
Andrew Vasquez
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


SCSI API generics (was Re: [PATCH] add block/unblock to iscsi class)

2005-02-23 Thread Andrew Vasquez
On Wed, 23 Feb 2005, Mike Christie wrote:

 The attached patch copies the code from the fc transport
 class which allows a LLD to block and unblock a device.
 The block/unblock code is used by the iscsi-sfnet
 driver in replacement of a internal timer doing the
 same thing.
 
 I understand that the target code is under construction
 and our group as well as the HW iSCSI guys are trying to move
 to something closer to the fc's rport model, so I was not
 sure if it is better to wait or get this basic functionality in
 first so we (and other SW and HW iSCSI drivers) can kill some
 of our duplicated code sooner and then incrementally update
 the class.
 

Speaking of which, are there any major objections to the patches
proposed here:

Add scsi_target_[un]block() and scsi_target_remove() generics
http://marc.theaimsgroup.com/?l=linux-scsim=110867050306738w=2

[RFC] adding per scsi-host workqueues for defered processing
http://marc.theaimsgroup.com/?l=linux-scsim=110903148407438w=2

which add some infrastructure changes for the transport classes.

--
AV
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SCSI API generics (was Re: [PATCH] add block/unblock to iscsi class)

2005-02-23 Thread Andrew Vasquez
On Wed, 23 Feb 2005, Mike Christie wrote:

 Andrew Vasquez wrote:
 
 Speaking of which, are there any major objections to the patches
 proposed here:
 
 Add scsi_target_[un]block() and scsi_target_remove() generics
 http://marc.theaimsgroup.com/?l=linux-scsim=110867050306738w=2
 
 [RFC] adding per scsi-host workqueues for defered processing
 http://marc.theaimsgroup.com/?l=linux-scsim=110903148407438w=2
 
 
 When using single_threaded_workqueues do all single threaded ones
 in the system use the same cpu_workqueue_struct? Will this be
 a potential bottleneck if we end up using the workqueue for more
 operations in the future?

The kernel-thread that is created for a single-threaded workqueue is
not bound to any particular CPU:

kthread.c:kthread()

... 
/* By default we can run anywhere, unlike keventd. */
set_cpus_allowed(current, CPU_MASK_ALL);

-- 
Andrew Vasquez
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC] adding per scsi-host workqueues for defered processing

2005-02-21 Thread Andrew Vasquez
Following discussions which resulted from the:

[RFC] target code updates to support scanned targets
http://marc.theaimsgroup.com/?l=linux-scsim=110850749515984w=2

thread, the overall consensus seems to be that transport-classes
should support a 'true-hotplug' mechanism of device discovery and
removal (this involves both registration and lun-scanning).  In order
to facilitate this ability and to not constrain the LLDD from the
typical restrictions of the storage scanning process:

* must be done from process context -- depending on transport type,
  discovery can occur from a non-process context
* potentially _long_ scan times -- even if discovery is done from a
  'sleeping' capable context, halting a LLDD for discovery purposes
  is typically undesirable.

I'd like to propose the addition of a per-Scsi_Host work-queue to
manage these scanning as well as any other (relevant)
lower-level-driver differed requests.

The attached patch adds:

1) a new scsi-host template member 'create_work_queue' which when set
   will create a single-threaded (the per-CPU option seemed too
   heavyweight) work-queue.
2) an exported helper function scsi_queue_work() to queue the work to
   the scsi-host work-queue.

the interface was kept flexible -- queuing of a work_struct object
rather than adding small wrapper functions to perform distinct
operations (i.e. scsi_scan_target_deferred(...), etc) so that any
'deferred' action could be requested by a transport-class or LLDD.

Example usage:

  scsi_transport_fc.h:

struct fc_rport {
...

struct work_struct scan_work;
} __attribute__((aligned(sizeof(unsigned long;

  scsi_transport_fc.c:

... 
static void fc_scan_rport_work(void *data)
{
struct fc_rport *rport = (struct fc_rport *)data;

scsi_scan_target(rport-dev, rport-channel,
rport-scsi_target_id, SCAN_WILD_CARD, 0);
}   

struct fc_rport *
fc_create_rport(struct Scsi_Host *shost, int channel,
struct fc_rport_identifiers  *ids)
{
...
INIT_WORK(rport-scan_work,
fc_scan_rport_work, rport);
...


void
fc_remote_port_unblock(struct fc_rport *rport)
{
struct Scsi_Host *shost = rport_to_shost(rport);
...
if (rport-port_state == FC_PORTSTATE_OFFLINE)
/* Initiate a full rescan, as all
 * scsi_target objects have been previously
 * torn-down. */
scsi_queue_work(shost, rport-scan_work);
else
scsi_target_unblock(rport-dev);

Anyway, comments?

--
Andrew Vasquez

= drivers/scsi/hosts.c 1.107 vs edited =
--- 1.107/drivers/scsi/hosts.c  2005-01-18 11:15:06 -08:00
+++ edited/drivers/scsi/hosts.c 2005-02-21 15:10:38 -08:00
@@ -160,6 +160,9 @@ static void scsi_host_dev_release(struct
shost-eh_notify = NULL;
}
 
+   if (shost-create_work_queue)
+   destroy_workqueue(shost-work_q);
+
scsi_proc_hostdir_rm(shost-hostt);
scsi_destroy_command_freelist(shost);
kfree(shost-shost_data);
@@ -247,6 +250,7 @@ struct Scsi_Host *scsi_host_alloc(struct
shost-cmd_per_lun = sht-cmd_per_lun;
shost-unchecked_isa_dma = sht-unchecked_isa_dma;
shost-use_clustering = sht-use_clustering;
+   shost-create_work_queue = sht-create_work_queue;
 
if (sht-max_host_blocked)
shost-max_host_blocked = sht-max_host_blocked;
@@ -285,16 +289,27 @@ struct Scsi_Host *scsi_host_alloc(struct
snprintf(shost-shost_classdev.class_id, BUS_ID_SIZE, host%d,
  shost-host_no);
 
+   if (shost-create_work_queue) {
+   snprintf(shost-work_q_name, KOBJ_NAME_LEN, scsi_wq_%d,
+   shost-host_no);
+   shost-work_q = create_singlethread_workqueue(
+   shost-work_q_name);
+   if (!shost-work_q)
+   goto fail_destroy_freelist;
+   }
+
shost-eh_notify = complete;
rval = kernel_thread(scsi_error_handler, shost, 0);
if (rval  0)
-   goto fail_destroy_freelist;
+   goto fail_destroy_workqueue;
wait_for_completion(complete);
shost-eh_notify = NULL;
 
scsi_proc_hostdir_add(shost-hostt);
return shost;
 
+ fail_destroy_workqueue:
+   destroy_workqueue(shost-work_q);
  fail_destroy_freelist:
scsi_destroy_command_freelist(shost);
  fail_kfree:
@@ -392,3 +407,26 @@ int scsi_is_host_device(const struct dev
return dev-release == scsi_host_dev_release;
 }
 EXPORT_SYMBOL(scsi_is_host_device);
+
+/**
+ * scsi_queue_work - Queue work to the Scsi_Host workqueue.
+ * @shost: Pointer

Re: [RFC] target code updates to support scanned targets

2005-02-17 Thread Andrew Vasquez
On Wed, 16 Feb 2005, Andrew Vasquez wrote:
 On Tue, 15 Feb 2005, James Bottomley wrote:
  Well, how about a different format for this, so there's a
  scsi_remove_target that takes a generic device (analogous to the
  scsi_scan_target) except that this time if the device isn't a target, we
  remove all the children of the device that are targets?
  
 
 along the same vein, we'll also need generic-device accessors to block
 and unblock all scsi_device children of an scsi_target.  currently,
 scsi_internal_devive_[block|unblock]() is issued across all sdevs for
 a given starget:
 
   void scsi_block_target(struct device *)
   void scsi_unblock_target(struct device *)
 
 one caveat with these parent-accessors is that we also lose
 'per-starget' (un)blocking/removal granualarity -- not sure if that's
 going to be a problem for other interfaces in the future.
 

Does the following seem reasonable?

* add scsi_target_block() and scsi_target_unblock() routines which
  take a generic-device.  Side note:  there are mixture of 
  scsi_object_action() and scsi_action_noun() functions defined
  in the scsi APIs -- going forward are there any 'guides' or
  suggestions on which to choose?
* modify scsi_remove_target() to take a generic-device.

-- 
Andrew Vasquez


= drivers/scsi/scsi_lib.c 1.149 vs edited =
--- 1.149/drivers/scsi/scsi_lib.c   2005-02-15 23:48:33 -08:00
+++ edited/drivers/scsi/scsi_lib.c  2005-02-17 11:17:22 -08:00
@@ -1889,3 +1889,55 @@ scsi_internal_device_unblock(struct scsi
return 0;
 }
 EXPORT_SYMBOL_GPL(scsi_internal_device_unblock);
+
+static void
+device_block(struct scsi_device *sdev, void *data)
+{
+   scsi_internal_device_block(sdev);
+}
+
+static int
+target_block(struct device *dev, void *data)
+{
+   if (scsi_is_target_device(dev))
+   starget_for_each_device(to_scsi_target(dev), NULL,
+   device_block);
+   return 0;
+}
+
+void
+scsi_target_block(struct device *dev)
+{
+   if (scsi_is_target_device(dev))
+   starget_for_each_device(to_scsi_target(dev), NULL,
+   device_block);
+   else
+   device_for_each_child(dev, NULL, target_block);
+}
+EXPORT_SYMBOL_GPL(scsi_target_block);
+
+static void
+device_unblock(struct scsi_device *sdev, void *data)
+{
+   scsi_internal_device_unblock(sdev);
+}
+
+static int
+target_unblock(struct device *dev, void *data)
+{
+   if (scsi_is_target_device(dev))
+   starget_for_each_device(to_scsi_target(dev), NULL,
+   device_unblock);
+   return 0;
+}
+
+void
+scsi_target_unblock(struct device *dev)
+{
+   if (scsi_is_target_device(dev))
+   starget_for_each_device(to_scsi_target(dev), NULL,
+   device_unblock);
+   else
+   device_for_each_child(dev, NULL, target_unblock);
+}
+EXPORT_SYMBOL_GPL(scsi_target_unblock);
= drivers/scsi/scsi_scan.c 1.141 vs edited =
--- 1.141/drivers/scsi/scsi_scan.c  2005-02-15 23:48:33 -08:00
+++ edited/drivers/scsi/scsi_scan.c 2005-02-16 10:21:35 -08:00
@@ -1385,7 +1385,7 @@ void scsi_forget_host(struct Scsi_Host *
spin_lock_irqsave(shost-host_lock, flags);
list_for_each_entry_safe(starget, tmp, shost-__targets, siblings) {
spin_unlock_irqrestore(shost-host_lock, flags);
-   scsi_remove_target(starget);
+   scsi_remove_target(starget-dev);
spin_lock_irqsave(shost-host_lock, flags);
}
spin_unlock_irqrestore(shost-host_lock, flags);
= drivers/scsi/scsi_sysfs.c 1.65 vs edited =
--- 1.65/drivers/scsi/scsi_sysfs.c  2005-02-15 23:48:33 -08:00
+++ edited/drivers/scsi/scsi_sysfs.c2005-02-16 17:05:37 -08:00
@@ -634,15 +634,7 @@ void scsi_remove_device(struct scsi_devi
 }
 EXPORT_SYMBOL(scsi_remove_device);
 
-/**
- * scsi_remove_target - try to remove a target and all its devices
- * @starget: the target to remove
- *
- * Note: This is slightly racy.  It is possible that if the user
- * requests the addition of another device then the target won't be
- * removed.
- */
-void scsi_remove_target(struct scsi_target *starget)
+void __scsi_remove_target(struct scsi_target *starget)
 {
struct Scsi_Host *shost = dev_to_shost(starget-dev.parent);
unsigned long flags;
@@ -660,6 +652,31 @@ void scsi_remove_target(struct scsi_targ
}
spin_unlock_irqrestore(shost-host_lock, flags);
scsi_target_reap(starget);
+}
+
+/**
+ * scsi_remove_target - try to remove a target and all its devices
+ * @dev: generic starget or parent of generic stargets to be removed
+ *
+ * Note: This is slightly racy.  It is possible that if the user
+ * requests the addition of another device then the target won't be
+ * removed.
+ */
+void scsi_remove_target(struct device *dev)
+{
+   struct device *rdev, *idev, *next

Re: [RFC] target code updates to support scanned targets

2005-02-16 Thread Andrew Vasquez
On Tue, 15 Feb 2005, James Bottomley wrote:

 On Tue, 2005-02-15 at 16:53 -0800, Andrew Vasquez wrote:
  Yes, but the parent needs to know if the starget is actually created.
  With the fc_rports snapshot I've been working with, I've coded up the
  following:
 
 Why do you need to know if the scan actually found any LUNs?
 

originally, just to handle the starget-specific interfaces originally
defined.

  +   if (unlikely(!rport-starget))
  dev_printk(KERN_ERR, rport-dev, TGT_ALLOC_FAILURE_MSG,
  __FUNCTION__, shost-host_no);
  
  so when the rport gets dropped (i.e. fc_remote_port_delete()), a
  scsi_remove_target() call can be issued.  I'm not entirely thrilled
  with the structure-member poking (any other suggestions on how to get
  the child, welcomed), but it does work.
 
 Well, how about a different format for this, so there's a
 scsi_remove_target that takes a generic device (analogous to the
 scsi_scan_target) except that this time if the device isn't a target, we
 remove all the children of the device that are targets?
 

along the same vein, we'll also need generic-device accessors to block
and unblock all scsi_device children of an scsi_target.  currently,
scsi_internal_devive_[block|unblock]() is issued across all sdevs for
a given starget:

void scsi_block_target(struct device *)
void scsi_unblock_target(struct device *)

one caveat with these parent-accessors is that we also lose
'per-starget' (un)blocking/removal granualarity -- not sure if that's
going to be a problem for other interfaces in the future.

--
Andrew
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2 scsi-rc-fixes-2.6] Midlayer rework to allow remote port between shost and starget

2005-02-09 Thread Andrew Vasquez
   This patch modifies the midlayer for the addition of transport
   objects to be layered between the scsi_host and the scsi_target.
   FC will be the first consumer - placing the remote port between
   the host and the target.
 

These seems to be some reference-counting problems during starget
creating while scanning:

 diff -puN a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 --- a/drivers/scsi/scsi_sysfs.c   2005-02-08 21:05:49.0 -0500
 +++ b/drivers/scsi/scsi_sysfs.c   2005-02-08 21:05:49.0 -0500
 @@ -170,12 +170,8 @@ void scsi_device_dev_release(struct devi
  
   if (delete) {
   struct scsi_target *starget = to_scsi_target(parent);
 - if (!starget-create) {
 - transport_remove_device(starget-dev);
 - device_del(parent);
 - }
 - transport_destroy_device(starget-dev);
 -
 + if (starget-scan_created)
 + __scsi_remove_target(starget);
   put_device(parent);
   }
   if (sdev-request_queue)

resulting in some slab corruption:

Slab corruption: start=d39c1ab4, len=256
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [c02971de](scsi_target_dev_release+0xe/0x20)
040: 6b 6b 6b 6b 6b 6b 6b 6b 6a 6b 6b 6b 6b 6b 6b 6b
Prev obj: start=d39c19a8, lfen=256
Redzoner: [](0x0)
000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
Next obj: start=d39c1bc0, len=256
Redzone: 0x170fc2a5/0x170fc2a5.
Last user: [c025f385](cfq_init_queue+0x85/0x1b0)
000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

small patch below should fix the problem.

--
AV


--- scsi-rport/drivers/scsi/scsi_sysfs.c.orig   2005-02-09 00:29:20.0 
-0800
+++ scsi-rport/drivers/scsi/scsi_sysfs.c2005-02-09 00:36:55.0 
-0800
@@ -172,7 +172,6 @@
struct scsi_target *starget = to_scsi_target(parent);
if (starget-scan_created)
__scsi_remove_target(starget);
-   put_device(parent);
}
if (sdev-request_queue)
scsi_free_queue(sdev-request_queue);

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


Re: still BUG's for smp_processor_id() on interrupt

2005-02-08 Thread Andrew Vasquez
On Tue, 08 Feb 2005, Patrick Mansfield wrote:

 I'm still getting lots of BUG's for the smp_processor_id, but via the
 interrupt function.
 

It's during the driver's init-time polling for interrupts...

 I am running the latest bk, it has your patch to qla_os.c:
 
 [elm3b79 qla2xxx]$ grep smp_proc qla_os.c
 if (_smp_processor_id() == ha-last_irq_cpu || was_empty)
 
 I'm running on a NUMAQ (sometimes has funky latencies). There are no
 errors for simple IO (dd if=/dev/sda of=/dev/null bs=64k). There are about
 40 disk drives attached.
 

Argg -- that was careless...  Again, the smp_processor_id() is used
only as a heuristic.  The attached patch should quash the noise.

Thanks.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED] 

= drivers/scsi/qla2xxx/qla_isr.c 1.23 vs edited =
--- 1.23/drivers/scsi/qla2xxx/qla_isr.c 2005-02-04 10:24:27 -08:00
+++ edited/drivers/scsi/qla2xxx/qla_isr.c   2005-02-08 22:41:08 -08:00
@@ -91,7 +91,7 @@
}
spin_unlock_irqrestore(ha-hardware_lock, flags);
 
-   ha-last_irq_cpu = smp_processor_id();
+   ha-last_irq_cpu = _smp_processor_id();
ha-total_isr_cnt++;
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
@@ -200,7 +200,7 @@
}
spin_unlock_irqrestore(ha-hardware_lock, flags);
 
-   ha-last_irq_cpu = smp_processor_id();
+   ha-last_irq_cpu = _smp_processor_id();
ha-total_isr_cnt++;
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PATCH [0/3] qla2xxx: new experimental changes...

2005-02-04 Thread Andrew Vasquez
All,

Here's a set of patches which begin to strip legacy features from the
qla2xxx driver.  These 'features' have been superceded in functionality
and simplicity by additions present (for some time) in the SCSI
mid-layer.

Here's the breakdown of patches being submitted:

 1. Remove internal command queuing.  This entails removal of the
driver's *_queue lists as well as modifications and removal of
routines which used them.  With the queuing removed -- the
driver will be unable to tolerate cable-pulls.  Thus we depend
on the next patch for support.
 2. Add initial support for FC remote port infrastructure.  This
patch is based off the proposal submitted by James Smart:
([Patch RFC ] Update FC transport for FC Remote Ports)
http://marc.theaimsgroup.com/?l=linux-scsim=110187926413504w=2
 3. Remove internal lun discovery routines and support structures.
The mid-layer has a more exhaustive and fully capable set of
functions for lun discovery.

Other patches in the queue:

 A. Complete fc_host attributes support.  This patch is mostly
complete, I'd just like to let the dust settle with the recent
transport_template changes.
 B. Additional dusting and scrubbing: /proc removal, unused
functions and structures left over from the cleanup.
 C. lock simplification and consolidation -- we're still reviewing
the implications of removing the driver's 'hardware_lock' and
begin using the host-host_lock exclusively.
 D. additional hardware (ISP) support.
 E. firmware loading via request_firmware() infrastructure.


Regards,
Andrew Vasquez
QLogic Corporation
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PATCH [2/3] qla2xxx: add FC remote port support.

2005-02-04 Thread Andrew Vasquez
  Add initial support for FC remote port infrastructure.  Depends
  on patches submitted by James Smart ([Patch RFC ] Update FC
  transport for FC Remote Ports)
  
 o Use fc_remote_port...() registration and block/unlock
   functions.
 o Consolidate 'attribute' (fc-remote/sysfs) helpers into
   new qla_attr.c file.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/Makefile   |2 
 drivers/scsi/qla2xxx/qla_attr.c |  321 
 drivers/scsi/qla2xxx/qla_def.h  |3 
 drivers/scsi/qla2xxx/qla_gbl.h  |   10 +
 drivers/scsi/qla2xxx/qla_init.c |   30 +++
 drivers/scsi/qla2xxx/qla_os.c   |  297 -
 6 files changed, 395 insertions(+), 268 deletions(-)

diff -Nru a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile
--- a/drivers/scsi/qla2xxx/Makefile 2005-02-04 09:53:53 -08:00
+++ b/drivers/scsi/qla2xxx/Makefile 2005-02-04 09:53:53 -08:00
@@ -1,7 +1,7 @@
 EXTRA_CFLAGS += -DUNIQUE_FW_NAME
 
 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
-   qla_dbg.o qla_sup.o qla_rscn.o
+   qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o
 
 qla2100-y := ql2100.o ql2100_fw.o
 qla2200-y := ql2200.o ql2200_fw.o
diff -Nru a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/qla2xxx/qla_attr.c   2005-02-04 09:53:53 -08:00
@@ -0,0 +1,321 @@
+/*
+ *  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003-2005 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include qla_def.h
+
+#include linux/version.h
+#include scsi/scsi_transport_fc.h
+
+/* SYSFS attributes - 
*/
+
+static ssize_t
+qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf, loff_t off,
+size_t count)
+{
+   struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+   struct device, kobj)));
+
+   if (ha-fw_dump_reading == 0)
+   return 0;
+   if (off  ha-fw_dump_buffer_len)
+   return 0;
+   if (off + count  ha-fw_dump_buffer_len)
+   count = ha-fw_dump_buffer_len - off;
+
+   memcpy(buf, ha-fw_dump_buffer[off], count);
+
+   return (count);
+}
+
+static ssize_t
+qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off,
+size_t count)
+{
+   struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+   struct device, kobj)));
+   int reading;
+   uint32_t dump_size;
+
+   if (off != 0)
+   return (0);
+
+   reading = simple_strtol(buf, NULL, 10);
+   switch (reading) {
+   case 0:
+   if (ha-fw_dump_reading == 1) {
+   qla_printk(KERN_INFO, ha,
+   Firmware dump cleared on (%ld).\n,
+   ha-host_no);
+
+   vfree(ha-fw_dump_buffer);
+   free_pages((unsigned long)ha-fw_dump,
+   ha-fw_dump_order);
+
+   ha-fw_dump_reading = 0;
+   ha-fw_dump_buffer = NULL;
+   ha-fw_dump = NULL;
+   }
+   break;
+   case 1:
+   if (ha-fw_dump != NULL  !ha-fw_dump_reading) {
+   ha-fw_dump_reading = 1;
+
+   dump_size = FW_DUMP_SIZE_1M;
+   if (ha-fw_memory_size  0x2) 
+   dump_size = FW_DUMP_SIZE_128K;
+   else if (ha-fw_memory_size  0x8) 
+   dump_size = FW_DUMP_SIZE_512K;
+   ha-fw_dump_buffer = (char *)vmalloc(dump_size);
+   if (ha-fw_dump_buffer == NULL) {
+   qla_printk(KERN_WARNING, ha,
+   Unable to allocate memory for firmware 
+   dump buffer (%d).\n, dump_size);
+
+   ha-fw_dump_reading = 0;
+   return (count);
+   }
+   qla_printk(KERN_INFO, ha,
+   Firmware dump ready for read on (%ld).\n,
+   ha-host_no);
+   memset(ha-fw_dump_buffer, 0, dump_size);
+   if (IS_QLA2100

Re: PATCH [0/3] qla2xxx: new experimental changes...

2005-02-04 Thread Andrew Vasquez
On Fri, 2005-02-04 at 20:35 +, Christoph Hellwig wrote:
 patch3 seems to not have made it to the list.

I'll resend...

   From a quick view
 the first three patches look fine, except for backing out one msleep
 conversion and the superflous return at the end of qla2xxx_slave_destroy
 

I'll send an incremental patch which fixes this.

--
AV
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PATCH [3/3] qla2xxx: remove internal lun discovery...

2005-02-04 Thread Andrew Vasquez
Repost: seems as though first one didn't make it to the list.

  Remove internal lun discovery routines and support
  structures.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_dbg.c|5 
 drivers/scsi/qla2xxx/qla_def.h|   69 
 drivers/scsi/qla2xxx/qla_gbl.h|6 
 drivers/scsi/qla2xxx/qla_init.c   |  584 --
 drivers/scsi/qla2xxx/qla_inline.h |   17 -
 drivers/scsi/qla2xxx/qla_iocb.c   |   13 
 drivers/scsi/qla2xxx/qla_isr.c|   36 --
 drivers/scsi/qla2xxx/qla_mbx.c|5 
 drivers/scsi/qla2xxx/qla_os.c |   98 --
 9 files changed, 21 insertions(+), 812 deletions(-)

diff -Nru a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
--- a/drivers/scsi/qla2xxx/qla_dbg.c2005-02-04 10:27:05 -08:00
+++ b/drivers/scsi/qla2xxx/qla_dbg.c2005-02-04 10:27:05 -08:00
@@ -1067,11 +1067,6 @@
printk(  sp flags=0x%x\n, sp-flags);
printk(  r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n,
sp-r_start, sp-u_start, sp-f_start, sp-state);
-
-   printk( e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, 
-   port path=%d\n, sp-e_start, sp-ext_history, sp-fo_retry_cnt,
-   sp-lun_queue-fclun-fcport-loop_id,
-   sp-lun_queue-fclun-fcport-cur_path);
 }
 
 #if defined(QL_DEBUG_ROUTINES)
diff -Nru a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
--- a/drivers/scsi/qla2xxx/qla_def.h2005-02-04 10:27:05 -08:00
+++ b/drivers/scsi/qla2xxx/qla_def.h2005-02-04 10:27:05 -08:00
@@ -253,8 +253,6 @@
 
/* Target/LUN queue pointers. */
struct os_tgt *tgt_queue;   /* ptr to visible ha's target */
-   struct os_lun *lun_queue;   /* ptr to visible ha's lun */
-   struct fc_lun *fclun;   /* FC LUN context pointer. */
 
/* Timing counts. */
unsigned long e_start;  /* Start of extend timeout */
@@ -1606,7 +1604,6 @@
  * SCSI Target Queue structure
  */
 typedef struct os_tgt {
-   struct os_lun *olun[MAX_LUNS]; /* LUN context pointer. */
struct fc_port *fcport;
unsigned long flags;
uint8_t port_down_retry_count;
@@ -1626,48 +1623,6 @@
 #define TQF_SUSPENDED  1
 #define TQF_RETRY_CMDS 2
 
-/*
- * SCSI LUN Queue structure
- */
-typedef struct os_lun {
-   struct fc_lun *fclun;   /* FC LUN context pointer. */
-   spinlock_t q_lock;  /* Lun Lock */
-
-   unsigned long q_flag;
-#define LUN_MPIO_RESET_CNTS1   /* Lun */
-#define LUN_MPIO_BUSY  2   /* Lun is changing paths  */
-#define LUN_EXEC_DELAYED   7   /* Lun execution is delayed */
-
-   u_long q_timeout;   /* total command timeouts */
-   atomic_t q_timer;   /* suspend timer */
-   uint32_t q_count;   /* current count */
-   uint32_t q_max; /* maxmum count lun can be suspended */
-   uint8_t q_state;/* lun State */
-#define LUN_STATE_READY1   /* lun is ready for i/o */
-#define LUN_STATE_RUN  2   /* lun has a timer running */
-#define LUN_STATE_WAIT 3   /* lun is suspended */
-#define LUN_STATE_TIMEOUT  4   /* lun has timed out */
-
-   u_long io_cnt;  /* total xfer count since boot */
-   u_long out_cnt; /* total outstanding IO count */
-   u_long w_cnt;   /* total writes */
-   u_long r_cnt;   /* total reads */
-   u_long avg_time;/*  */
-} os_lun_t;
-
-
-/* LUN BitMask structure definition, array of 32bit words,
- * 1 bit per lun.  When bit == 1, the lun is masked.
- * Most significant bit of mask[0] is lun 0, bit 24 is lun 7.
- */
-typedef struct lun_bit_mask {
-   /* Must allocate at least enough bits to accomodate all LUNs */
-#if ((MAX_FIBRE_LUNS  0x7) == 0)
-   uint8_t mask[MAX_FIBRE_LUNS  3];
-#else
-   uint8_t mask[(MAX_FIBRE_LUNS + 8)  3];
-#endif
-} lun_bit_mask_t;
 
 /*
  * Fibre channel port type.
@@ -1686,8 +1641,6 @@
  */
 typedef struct fc_port {
struct list_head list;
-   struct list_head fcluns;
-
struct scsi_qla_host *ha;
struct scsi_qla_host *vis_ha;   /* only used when suspending lun */
 
@@ -1717,7 +1670,6 @@
uint8_t mp_byte;/* multi-path byte (not used) */
uint8_t cur_path;   /* current path id */
 
-   lun_bit_mask_t lun_mask;
struct fc_rport *rport;
 } fc_port_t;
 
@@ -1765,25 +1717,6 @@
 #define FC_NO_LOOP_ID  0x1000
 
 /*
- * Fibre channel LUN structure.
- */
-typedef struct fc_lun {
-struct list_head list;
-
-   fc_port_t *fcport;
-   fc_port_t *o_fcport;
-   uint16_t lun;
-   atomic_t state;
-   uint8_t device_type;
-
-   uint8_t max_path_retries;
-   uint32_t flags;
-} fc_lun_t;
-
-#defineFLF_VISIBLE_LUN BIT_0

PATCH [3/3] qla2xxx: remove internal lun discovery...

2005-02-04 Thread Andrew Vasquez
  Remove internal lun discovery routines and support
  structures.

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_dbg.c|5 
 drivers/scsi/qla2xxx/qla_def.h|   69 
 drivers/scsi/qla2xxx/qla_gbl.h|6 
 drivers/scsi/qla2xxx/qla_init.c   |  584 --
 drivers/scsi/qla2xxx/qla_inline.h |   17 -
 drivers/scsi/qla2xxx/qla_iocb.c   |   13 
 drivers/scsi/qla2xxx/qla_isr.c|   36 --
 drivers/scsi/qla2xxx/qla_mbx.c|5 
 drivers/scsi/qla2xxx/qla_os.c |   98 --
 9 files changed, 21 insertions(+), 812 deletions(-)

diff -Nru a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
--- a/drivers/scsi/qla2xxx/qla_dbg.c2005-02-04 10:27:05 -08:00
+++ b/drivers/scsi/qla2xxx/qla_dbg.c2005-02-04 10:27:05 -08:00
@@ -1067,11 +1067,6 @@
printk(  sp flags=0x%x\n, sp-flags);
printk(  r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n,
sp-r_start, sp-u_start, sp-f_start, sp-state);
-
-   printk( e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, 
-   port path=%d\n, sp-e_start, sp-ext_history, sp-fo_retry_cnt,
-   sp-lun_queue-fclun-fcport-loop_id,
-   sp-lun_queue-fclun-fcport-cur_path);
 }
 
 #if defined(QL_DEBUG_ROUTINES)
diff -Nru a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
--- a/drivers/scsi/qla2xxx/qla_def.h2005-02-04 10:27:05 -08:00
+++ b/drivers/scsi/qla2xxx/qla_def.h2005-02-04 10:27:05 -08:00
@@ -253,8 +253,6 @@
 
/* Target/LUN queue pointers. */
struct os_tgt *tgt_queue;   /* ptr to visible ha's target */
-   struct os_lun *lun_queue;   /* ptr to visible ha's lun */
-   struct fc_lun *fclun;   /* FC LUN context pointer. */
 
/* Timing counts. */
unsigned long e_start;  /* Start of extend timeout */
@@ -1606,7 +1604,6 @@
  * SCSI Target Queue structure
  */
 typedef struct os_tgt {
-   struct os_lun *olun[MAX_LUNS]; /* LUN context pointer. */
struct fc_port *fcport;
unsigned long flags;
uint8_t port_down_retry_count;
@@ -1626,48 +1623,6 @@
 #define TQF_SUSPENDED  1
 #define TQF_RETRY_CMDS 2
 
-/*
- * SCSI LUN Queue structure
- */
-typedef struct os_lun {
-   struct fc_lun *fclun;   /* FC LUN context pointer. */
-   spinlock_t q_lock;  /* Lun Lock */
-
-   unsigned long q_flag;
-#define LUN_MPIO_RESET_CNTS1   /* Lun */
-#define LUN_MPIO_BUSY  2   /* Lun is changing paths  */
-#define LUN_EXEC_DELAYED   7   /* Lun execution is delayed */
-
-   u_long q_timeout;   /* total command timeouts */
-   atomic_t q_timer;   /* suspend timer */
-   uint32_t q_count;   /* current count */
-   uint32_t q_max; /* maxmum count lun can be suspended */
-   uint8_t q_state;/* lun State */
-#define LUN_STATE_READY1   /* lun is ready for i/o */
-#define LUN_STATE_RUN  2   /* lun has a timer running */
-#define LUN_STATE_WAIT 3   /* lun is suspended */
-#define LUN_STATE_TIMEOUT  4   /* lun has timed out */
-
-   u_long io_cnt;  /* total xfer count since boot */
-   u_long out_cnt; /* total outstanding IO count */
-   u_long w_cnt;   /* total writes */
-   u_long r_cnt;   /* total reads */
-   u_long avg_time;/*  */
-} os_lun_t;
-
-
-/* LUN BitMask structure definition, array of 32bit words,
- * 1 bit per lun.  When bit == 1, the lun is masked.
- * Most significant bit of mask[0] is lun 0, bit 24 is lun 7.
- */
-typedef struct lun_bit_mask {
-   /* Must allocate at least enough bits to accomodate all LUNs */
-#if ((MAX_FIBRE_LUNS  0x7) == 0)
-   uint8_t mask[MAX_FIBRE_LUNS  3];
-#else
-   uint8_t mask[(MAX_FIBRE_LUNS + 8)  3];
-#endif
-} lun_bit_mask_t;
 
 /*
  * Fibre channel port type.
@@ -1686,8 +1641,6 @@
  */
 typedef struct fc_port {
struct list_head list;
-   struct list_head fcluns;
-
struct scsi_qla_host *ha;
struct scsi_qla_host *vis_ha;   /* only used when suspending lun */
 
@@ -1717,7 +1670,6 @@
uint8_t mp_byte;/* multi-path byte (not used) */
uint8_t cur_path;   /* current path id */
 
-   lun_bit_mask_t lun_mask;
struct fc_rport *rport;
 } fc_port_t;
 
@@ -1765,25 +1717,6 @@
 #define FC_NO_LOOP_ID  0x1000
 
 /*
- * Fibre channel LUN structure.
- */
-typedef struct fc_lun {
-struct list_head list;
-
-   fc_port_t *fcport;
-   fc_port_t *o_fcport;
-   uint16_t lun;
-   atomic_t state;
-   uint8_t device_type;
-
-   uint8_t max_path_retries;
-   uint32_t flags;
-} fc_lun_t;
-
-#defineFLF_VISIBLE_LUN BIT_0
-#defineFLF_ACTIVE_LUN  BIT_1
-
-/*
  * FC-CT

Re: PATCH [0/3] qla2xxx: new experimental changes...

2005-02-04 Thread Andrew Vasquez
On Fri, 2005-02-04 at 17:46 -0500, Jeff Garzik wrote:
 Andrew Vasquez wrote:
  On Fri, 2005-02-04 at 20:35 +, Christoph Hellwig wrote:
  
 patch3 seems to not have made it to the list.
  
  
  I'll resend...
 
 Is patch #3 rather large?  I still haven't gotten it.
 

No it's actually about a third the size of patch #1.  I've checked MARC
and it appears the repost seems to have made it:

http://marc.theaimsgroup.com/?l=linux-scsim=110755144431861w=2

 I also wonder if vger is censoring xxx...
 

Not sure why it didn't go through.  Let me know if still have problems
receiving the email -- I can just forward it to you directly.

--
Andrew
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mid-layer handling of NOT_READY conditions...

2005-01-31 Thread Andrew Vasquez
On Sat, 2005-01-29 at 11:34 -0800, Patrick Mansfield wrote:
 On Sat, Jan 29, 2005 at 10:44:41AM -0600, James Bottomley wrote:
  On Fri, 2005-01-28 at 21:46 -0800, Andrew Vasquez wrote:
   Returning back DID_IMM_RETRY for these 'transport' related conditions
   would of course help in this issue -- but at the same time bring with it
   several side-effects which may not be desirable.
   
   So, beyond this particular circumstance, what would be considered a
   'proper' return status for this type of event? 
  
  Well, the correct return, since this is a condition from the storage, is
  simply the check condition and the sense code (rather than having the
  driver interpret it).
 
 But the transport hit a failure, not the storage device.
 
 I thought Andrew hit this sequence:
 
   - pull / replace cable
 
   - IO resumes but gets NOT_READY (the device could be logging back
 into the fibre or such)
 
   - a FC transport problem is hit, DID_BUSY_BUSY is returned, but
 scmd-retries has already been exhausted by the NOT_READY
 
 Did I misread something?
 

No, that's correct -- sorry about the confusion my second email caused.
I had only inquired about the 'correct' return status in the context of
avoiding the (cmd-retries  cmd-allowed) failure.

Would this be an approach to consider?  Or should we tackle the problem
by addressing the quirky (cmd-retries  cmd-allowed) state?
  
  That's what I think the correct approach should bewe have a few
  other quirky devices that aren't pleased with our current NOT_READY
  handling.  Were you going to look into coding up a patch for this?
 
 We don't track what errors caused a retry (doing so is too painful), or
 reset the retries. In scsi_decide_disposition() if we get a few retry
 cases for one or multiple errors, and then a different error that should
 reasonably be a retry case, we return SUCCESS instead of NEEDS_RETRY.
 
 Why not just set scmd-retries to zero in scsi_requeue_command()?
 

This is exactly what I was thinking would be a fairly straight-forward
approach at solving the problem...
 
 All callers are cases that we want to keep retrying if other errors are hit,
 and would fix other potential retry problems, not only the NOT_READY case.
 

given this fact.  I could code up a quick patch if this would be
acceptable???

 [There is one bad looking scsi_requeue_command() for UNIT_ATTENTION that
 looks like it could retry forever, independent of this problem.]


We could also retry forever if the storage never transitions from its
NOT_READY state (unlikely - unless totally borken).

 Fixing the NOT_READY case to quiesce (and not incrementing retries) would
 fix the problem or make it much less likely, and is still a good idea.
 

Yes, pounding on the storage box seems like a rather unfriendly
approach :-|

--
Andrew
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Mid-layer handling of NOT_READY conditions...

2005-01-31 Thread Andrew Vasquez
On Mon, 2005-01-31 at 11:56 -0500, [EMAIL PROTECTED] wrote:
  On Sat, 2005-01-29 at 11:34 -0800, Patrick Mansfield wrote:
   On Sat, Jan 29, 2005 at 10:44:41AM -0600, James Bottomley wrote:
On Fri, 2005-01-28 at 21:46 -0800, Andrew Vasquez wrote:
 Returning back DID_IMM_RETRY for these 'transport' 
  related conditions
 would of course help in this issue -- but at the same 
  time bring with it
 several side-effects which may not be desirable.
 
 So, beyond this particular circumstance, what would be 
  considered a
 'proper' return status for this type of event? 

Well, the correct return, since this is a condition from 
  the storage, is
simply the check condition and the sense code (rather 
  than having the
driver interpret it).
   
   But the transport hit a failure, not the storage device.
   
   I thought Andrew hit this sequence:
   
 - pull / replace cable
   
 - IO resumes but gets NOT_READY (the device could be 
  logging back
   into the fibre or such)
   
 - a FC transport problem is hit, DID_BUSY_BUSY is returned, but
   scmd-retries has already been exhausted by the NOT_READY
   
   Did I misread something?
   
  
  No, that's correct -- sorry about the confusion my second 
  email caused.
  I had only inquired about the 'correct' return status in the 
  context of
  avoiding the (cmd-retries  cmd-allowed) failure.
 
 So this maps into the fc_target_block/unblock functionality that was
 added to the fc class...  Adapter notifies driver of cable loss and
 starts the block, driver does not resume the traffic until the
 firmware says the login, etc

Yes.

  has the device ready to accept scsi
 traffic (Note: it does not guarantee the device can't respond with
 a NOT_READY sense code).

Exactly.

   If the transport hits a problem, there's
 no harm done as long as the problem is resolved within the block
 timeout. If the timeout is hit - it's because the user dicated that
 it wanted to know of errors within this time and if the device fails,
 it fails...
 
 In the multipath solution - the block time used by the transport gets
 set to 0 (or 1 second), so the i/o fails quickly and the multipath
 function can kick in.
 

A bit confused now, are you proposing that cmd-timeout_per_command time
be inclusive of potential transport failures resulting in a requested
retry?  And thus not be refreshed (as it currently is) upon retry
request.

 I am not a fan of a driver manufacturing a NOT_READY condition...
 

Again -- there is no manufacturing of check-conditions. Their existence
only highlighted the point that the retries value was being exhausted
(quickly) during the state and thus restricts a LLDD's ability to return
any status which would initiate a normal retry (i.e. DID_BUS_BUSY).

   
   Why not just set scmd-retries to zero in scsi_requeue_command()?
   
  
  This is exactly what I was thinking would be a fairly straight-forward
  approach at solving the problem...
 
 This is ultimately a hack, and raises the potential for the retries value
 to perpetually be rezero'd.  The better solution is the use the block
 primitives available to avoid the i/o being issued at all if the transport
 can't handle it.
 

Agree -- the midlayer internally plugging a device for a small period of
time while some NOT_READY (and any other similar) state is received from
the storage is the more appropriate direction.   Perhaps there could be
a combination of timing conditionals -- the fc_starget_dev_loss_tmo() to
time the overall pause in 'not-ready' plugging and a
period-to-wakeup-and-ping-the-storage time within the window?

--
av
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mid-layer handling of NOT_READY conditions...

2005-01-31 Thread Andrew Vasquez
On Mon, 2005-01-31 at 09:36 -0800, Patrick Mansfield wrote:
 On Mon, Jan 31, 2005 at 11:56:02AM -0500, [EMAIL PROTECTED] wrote:
   On Sat, 2005-01-29 at 11:34 -0800, Patrick Mansfield wrote:
 

Why not just set scmd-retries to zero in scsi_requeue_command()?

   
   This is exactly what I was thinking would be a fairly straight-forward
   approach at solving the problem...
  
  This is ultimately a hack, and raises the potential for the retries value
  to perpetually be rezero'd.  The better solution is the use the block
  primitives available to avoid the i/o being issued at all if the transport
  can't handle it.
 
 No, it does not change the potential to retry forever, someone still has
 to requeue the IO again outside of the NEEDS_RETRY/scsi_retry_command case
 for that to happen.
 
 We only check retries in scsi_decide_disposition (well not counting error
 handling), and if we hit the limit, return SUCCESS. The change is that we
 reset retries to zero if the command is *not* retried via
 NEEDS_RETRY/scsi_retry_command.
 
 It would be even clearer to zero retries in scsi_decide_disposition.
 
 For NOT_READY, we would be better off always using the
 scsi_requeue_command path ever: get rid of the check in scsi_check_sense,
 as it will be requeued via scsi_io_completion code. This would have to
 happen even if delaying retries to NOT_READY devices.
 

Here's a small patch against the latest scsi-rc-fixes tree I've been
running with which allows my basic cable-pull test to complete without
incident.

Please consider for inclusion.


As per Patrick M's suggestions:

  * reset a command's retries count in scsi_decide_disposition() in
case of additional requiring by upper layer.
  * remove redundant check for NOT_READY (ASC: 0x04 ASCQ: 0x01) in
scsi_check_sense().

Signed-off-by: Andrew Vasquez [EMAIL PROTECTED]

 scsi_error.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

= drivers/scsi/scsi_error.c 1.86 vs edited =
--- 1.86/drivers/scsi/scsi_error.c  2005-01-17 22:54:45 -08:00
+++ edited/drivers/scsi/scsi_error.c2005-01-31 23:01:54 -08:00
@@ -327,12 +327,6 @@ static int scsi_check_sense(struct scsi_
return NEEDS_RETRY;
}
/*
-* if the device is in the process of becoming ready, we 
-* should retry.
-*/
-   if ((sshdr.asc == 0x04)  (sshdr.ascq == 0x01))
-   return NEEDS_RETRY;
-   /*
 * if the device is not started, we need to wake
 * the error handler to start the motor
 */
@@ -1405,7 +1399,10 @@ int scsi_decide_disposition(struct scsi_
} else {
/*
 * no more retries - report this one back to upper level.
+* clear retries in case the command is requeued by
+* upper level.
 */
+   scmd-retries = 0;
return SUCCESS;
}
 }
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Mid-layer handling of NOT_READY conditions...

2005-01-28 Thread Andrew Vasquez
[PREFACE: Please forgive the rather long absence on linux-scsi, I've
been occupied by several non-related projects]


All,

While stripping out the remnants of internal queuing from the qla2xxx
driver and adding-in support for various fc_host/fc_remote constructs,
I've ran into a rather peculiar problem with respect to the way the SCSI
mid-layer handles NOT_READY conditions (notably ASC 0x04 and ASCQ 0x01).

I was doing simple short-duration cable-pulls when I noticed I/O errors
would occur at unexpected times as the storage returned to the topology.
The simplest case goes like this:

  * Issue I/O to device A
  * Device A falls off the topology 
  * Driver (qla2xxx) blocks additional requests to device A via
fc_remote_port_block() 
  * Short time later (couple of seconds) device A returns to
topology
  * Driver logs-into device and unblocks requests via
fc_remote_port_unblock().
  * I/O resumes

The storage still unable to process the commands returns
check-conditions (please excuse the crude printk()s):

*** check 1148/1/5 [1:0] sdev_st=2 status=2 [6/29/0].
*** check 1149/1/5 [1:0] sdev_st=2 status=2 [2/4/1].
scsi_decide_disposition: sc 0 RETRY incremented 2/5
*** check 1150/2/5 [1:0] sdev_st=2 status=2 [2/4/1].
scsi_decide_disposition: sc 0 RETRY incremented 3/5
*** check 1151/3/5 [1:0] sdev_st=2 status=2 [2/4/1].
scsi_decide_disposition: sc 0 RETRY incremented 4/5
*** check 1152/4/5 [1:0] sdev_st=2 status=2 [2/4/1].

while scsi_decide_disposition() agrees to retry the commands since
cmd-retries  cmd-allowed.  But when NOT_READYs persists beyond
cmd-allowed, scsi_decide_disposition() returns SUCCESS:

scsi_decide_disposition: sc 0 2 SUCCESS 6/5 [2/4/1]

and the command then begins additional processing via:

scsi_finish_command()
  sd_rw_itr()
scsi_io_completion()

at which point, the following check is made:

...
/*
 * If the device is in the process of becoming ready,
 * retry.
 */
if (sshdr.asc == 0x04  sshdr.ascq == 0x01) {
scsi_requeue_command(q, cmd);
return;
}

and the command is requeued to the request-q via blk_insert_request()
and started again with:

q-request_fn()
  scsi_request_fn()
scsi_dispatch_cmd()

There seems to be two problem with this approach:

 1. As the storage continues to return NOT_READY,
scsi_decide_disposition() blindly increments cmd-retries and
checks against cmd-allowed, returning SUCCESS (since at this
point cmd-retries is always greater than cmd-allowed) -- I've
seen this condition loop several hundred times while the
NOT_READY condition clears.
 2. as a result of the (cmd-retries  cmd-allowed) state of the
command, if a LLDD returns any status (other than DID_OK) which
could initiate a retry, the command is immediately failed.  As
an example, the qla2xxx driver returns DID_BUS_BUSY in case of
any 'transport' related problems during the exchange (dropped
frames, FCP protocal failures, etc.).

When the qla2xxx driver managed command queuing internally, a NOT_READY
status would cause the lun-queue to be frozen for some period time while
the storage settled-down.

Would this be an approach to consider?  Or should we tackle the problem
by addressing the quirky (cmd-retries  cmd-allowed) state?

Thanks,
Andrew Vasquez
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Mid-layer handling of NOT_READY conditions...

2005-01-28 Thread Andrew Vasquez
On Fri, 2005-01-28 at 15:24 -0800, Andrew Vasquez wrote:
 ...
 There seems to be two problem with this approach:
 
  1. As the storage continues to return NOT_READY,
 scsi_decide_disposition() blindly increments cmd-retries and
 checks against cmd-allowed, returning SUCCESS (since at this
 point cmd-retries is always greater than cmd-allowed) -- I've
 seen this condition loop several hundred times while the
 NOT_READY condition clears.
  2. as a result of the (cmd-retries  cmd-allowed) state of the
 command, if a LLDD returns any status (other than DID_OK) which
 could initiate a retry, the command is immediately failed.  As
 an example, the qla2xxx driver returns DID_BUS_BUSY in case of
 any 'transport' related problems during the exchange (dropped
 frames, FCP protocal failures, etc.).
 
 When the qla2xxx driver managed command queuing internally, a NOT_READY
 status would cause the lun-queue to be frozen for some period time while
 the storage settled-down.
 

Returning back DID_IMM_RETRY for these 'transport' related conditions
would of course help in this issue -- but at the same time bring with it
several side-effects which may not be desirable.

So, beyond this particular circumstance, what would be considered a
'proper' return status for this type of event? 

 Would this be an approach to consider?  Or should we tackle the problem
 by addressing the quirky (cmd-retries  cmd-allowed) state?
 

--
Andrew
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2   3