aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aic79xx_osm.h
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2005-07-22 10:44:04 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-08-03 12:45:14 -0400
commit73a25462100772b72a5d62fd66dff01b53018618 (patch)
treede112862069bcef5786b9878ca89bdcda9a0097c /drivers/scsi/aic7xxx/aic79xx_osm.h
parent60a13213840296b1e32d6781653a0eaa83d04382 (diff)
[SCSI] aic79xx: update to use scsi_transport_spi
This patch updates the aic79xx driver to take advantage of the scsi_transport_spi infrastructure. Patch is quite a mess as some procedures have been reshuffled to be closer to the aic7xxx driver. Rejections fixed and Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aic7xxx/aic79xx_osm.h')
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h197
1 files changed, 29 insertions, 168 deletions
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 792e97fef5b8..46edcf3e4e62 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -42,6 +42,7 @@
42#ifndef _AIC79XX_LINUX_H_ 42#ifndef _AIC79XX_LINUX_H_
43#define _AIC79XX_LINUX_H_ 43#define _AIC79XX_LINUX_H_
44 44
45#include <linux/config.h>
45#include <linux/types.h> 46#include <linux/types.h>
46#include <linux/blkdev.h> 47#include <linux/blkdev.h>
47#include <linux/delay.h> 48#include <linux/delay.h>
@@ -49,18 +50,23 @@
49#include <linux/pci.h> 50#include <linux/pci.h>
50#include <linux/smp_lock.h> 51#include <linux/smp_lock.h>
51#include <linux/version.h> 52#include <linux/version.h>
53#include <linux/interrupt.h>
52#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/slab.h>
53#include <asm/byteorder.h> 56#include <asm/byteorder.h>
54#include <asm/io.h> 57#include <asm/io.h>
55 58
56#include <linux/interrupt.h> /* For tasklet support. */ 59#include <scsi/scsi.h>
57#include <linux/config.h> 60#include <scsi/scsi_cmnd.h>
58#include <linux/slab.h> 61#include <scsi/scsi_eh.h>
62#include <scsi/scsi_device.h>
63#include <scsi/scsi_host.h>
64#include <scsi/scsi_tcq.h>
65#include <scsi/scsi_transport.h>
66#include <scsi/scsi_transport_spi.h>
59 67
60/* Core SCSI definitions */ 68/* Core SCSI definitions */
61#define AIC_LIB_PREFIX ahd 69#define AIC_LIB_PREFIX ahd
62#include "scsi.h"
63#include <scsi/scsi_host.h>
64 70
65/* Name space conflict with BSD queue macros */ 71/* Name space conflict with BSD queue macros */
66#ifdef LIST_HEAD 72#ifdef LIST_HEAD
@@ -95,7 +101,7 @@
95/************************* Forward Declarations *******************************/ 101/************************* Forward Declarations *******************************/
96struct ahd_softc; 102struct ahd_softc;
97typedef struct pci_dev *ahd_dev_softc_t; 103typedef struct pci_dev *ahd_dev_softc_t;
98typedef Scsi_Cmnd *ahd_io_ctx_t; 104typedef struct scsi_cmnd *ahd_io_ctx_t;
99 105
100/******************************* Byte Order ***********************************/ 106/******************************* Byte Order ***********************************/
101#define ahd_htobe16(x) cpu_to_be16(x) 107#define ahd_htobe16(x) cpu_to_be16(x)
@@ -115,7 +121,7 @@ typedef Scsi_Cmnd *ahd_io_ctx_t;
115/************************* Configuration Data *********************************/ 121/************************* Configuration Data *********************************/
116extern uint32_t aic79xx_allow_memio; 122extern uint32_t aic79xx_allow_memio;
117extern int aic79xx_detect_complete; 123extern int aic79xx_detect_complete;
118extern Scsi_Host_Template aic79xx_driver_template; 124extern struct scsi_host_template aic79xx_driver_template;
119 125
120/***************************** Bus Space/DMA **********************************/ 126/***************************** Bus Space/DMA **********************************/
121 127
@@ -145,11 +151,7 @@ struct ahd_linux_dma_tag
145}; 151};
146typedef struct ahd_linux_dma_tag* bus_dma_tag_t; 152typedef struct ahd_linux_dma_tag* bus_dma_tag_t;
147 153
148struct ahd_linux_dmamap 154typedef dma_addr_t bus_dmamap_t;
149{
150 dma_addr_t bus_addr;
151};
152typedef struct ahd_linux_dmamap* bus_dmamap_t;
153 155
154typedef int bus_dma_filter_t(void*, dma_addr_t); 156typedef int bus_dma_filter_t(void*, dma_addr_t);
155typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); 157typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
@@ -226,12 +228,12 @@ typedef struct timer_list ahd_timer_t;
226#define ahd_timer_init init_timer 228#define ahd_timer_init init_timer
227#define ahd_timer_stop del_timer_sync 229#define ahd_timer_stop del_timer_sync
228typedef void ahd_linux_callback_t (u_long); 230typedef void ahd_linux_callback_t (u_long);
229static __inline void ahd_timer_reset(ahd_timer_t *timer, u_int usec, 231static __inline void ahd_timer_reset(ahd_timer_t *timer, int usec,
230 ahd_callback_t *func, void *arg); 232 ahd_callback_t *func, void *arg);
231static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec); 233static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec);
232 234
233static __inline void 235static __inline void
234ahd_timer_reset(ahd_timer_t *timer, u_int usec, ahd_callback_t *func, void *arg) 236ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg)
235{ 237{
236 struct ahd_softc *ahd; 238 struct ahd_softc *ahd;
237 239
@@ -382,62 +384,12 @@ struct ahd_linux_device {
382 */ 384 */
383 u_int commands_since_idle_or_otag; 385 u_int commands_since_idle_or_otag;
384#define AHD_OTAG_THRESH 500 386#define AHD_OTAG_THRESH 500
385
386 int lun;
387 Scsi_Device *scsi_device;
388 struct ahd_linux_target *target;
389}; 387};
390 388
391typedef enum {
392 AHD_DV_REQUIRED = 0x01,
393 AHD_INQ_VALID = 0x02,
394 AHD_BASIC_DV = 0x04,
395 AHD_ENHANCED_DV = 0x08
396} ahd_linux_targ_flags;
397
398/* DV States */
399typedef enum {
400 AHD_DV_STATE_EXIT = 0,
401 AHD_DV_STATE_INQ_SHORT_ASYNC,
402 AHD_DV_STATE_INQ_ASYNC,
403 AHD_DV_STATE_INQ_ASYNC_VERIFY,
404 AHD_DV_STATE_TUR,
405 AHD_DV_STATE_REBD,
406 AHD_DV_STATE_INQ_VERIFY,
407 AHD_DV_STATE_WEB,
408 AHD_DV_STATE_REB,
409 AHD_DV_STATE_SU,
410 AHD_DV_STATE_BUSY
411} ahd_dv_state;
412
413struct ahd_linux_target { 389struct ahd_linux_target {
414 struct ahd_linux_device *devices[AHD_NUM_LUNS]; 390 struct scsi_device *sdev[AHD_NUM_LUNS];
415 int channel;
416 int target;
417 int refcount;
418 struct ahd_transinfo last_tinfo; 391 struct ahd_transinfo last_tinfo;
419 struct ahd_softc *ahd; 392 struct ahd_softc *ahd;
420 ahd_linux_targ_flags flags;
421 struct scsi_inquiry_data *inq_data;
422 /*
423 * The next "fallback" period to use for narrow/wide transfers.
424 */
425 uint8_t dv_next_narrow_period;
426 uint8_t dv_next_wide_period;
427 uint8_t dv_max_width;
428 uint8_t dv_max_ppr_options;
429 uint8_t dv_last_ppr_options;
430 u_int dv_echo_size;
431 ahd_dv_state dv_state;
432 u_int dv_state_retry;
433 uint8_t *dv_buffer;
434 uint8_t *dv_buffer1;
435
436 /*
437 * Cumulative counter of errors.
438 */
439 u_long errors_detected;
440 u_long cmds_since_error;
441}; 393};
442 394
443/********************* Definitions Required by the Core ***********************/ 395/********************* Definitions Required by the Core ***********************/
@@ -452,16 +404,11 @@ struct ahd_linux_target {
452/* 404/*
453 * Per-SCB OSM storage. 405 * Per-SCB OSM storage.
454 */ 406 */
455typedef enum {
456 AHD_SCB_UP_EH_SEM = 0x1
457} ahd_linux_scb_flags;
458
459struct scb_platform_data { 407struct scb_platform_data {
460 struct ahd_linux_device *dev; 408 struct ahd_linux_device *dev;
461 dma_addr_t buf_busaddr; 409 dma_addr_t buf_busaddr;
462 uint32_t xfer_len; 410 uint32_t xfer_len;
463 uint32_t sense_resid; /* Auto-Sense residual */ 411 uint32_t sense_resid; /* Auto-Sense residual */
464 ahd_linux_scb_flags flags;
465}; 412};
466 413
467/* 414/*
@@ -470,42 +417,24 @@ struct scb_platform_data {
470 * alignment restrictions of the various platforms supported by 417 * alignment restrictions of the various platforms supported by
471 * this driver. 418 * this driver.
472 */ 419 */
473typedef enum {
474 AHD_DV_WAIT_SIMQ_EMPTY = 0x01,
475 AHD_DV_WAIT_SIMQ_RELEASE = 0x02,
476 AHD_DV_ACTIVE = 0x04,
477 AHD_DV_SHUTDOWN = 0x08,
478 AHD_RUN_CMPLT_Q_TIMER = 0x10
479} ahd_linux_softc_flags;
480
481TAILQ_HEAD(ahd_completeq, ahd_cmd);
482
483struct ahd_platform_data { 420struct ahd_platform_data {
484 /* 421 /*
485 * Fields accessed from interrupt context. 422 * Fields accessed from interrupt context.
486 */ 423 */
487 struct ahd_linux_target *targets[AHD_NUM_TARGETS]; 424 struct scsi_target *starget[AHD_NUM_TARGETS];
488 struct ahd_completeq completeq;
489 425
490 spinlock_t spin_lock; 426 spinlock_t spin_lock;
491 u_int qfrozen; 427 u_int qfrozen;
492 pid_t dv_pid;
493 struct timer_list completeq_timer;
494 struct timer_list reset_timer; 428 struct timer_list reset_timer;
495 struct timer_list stats_timer;
496 struct semaphore eh_sem; 429 struct semaphore eh_sem;
497 struct semaphore dv_sem;
498 struct semaphore dv_cmd_sem; /* XXX This needs to be in
499 * the target struct
500 */
501 struct scsi_device *dv_scsi_dev;
502 struct Scsi_Host *host; /* pointer to scsi host */ 430 struct Scsi_Host *host; /* pointer to scsi host */
503#define AHD_LINUX_NOIRQ ((uint32_t)~0) 431#define AHD_LINUX_NOIRQ ((uint32_t)~0)
504 uint32_t irq; /* IRQ for this adapter */ 432 uint32_t irq; /* IRQ for this adapter */
505 uint32_t bios_address; 433 uint32_t bios_address;
506 uint32_t mem_busaddr; /* Mem Base Addr */ 434 uint32_t mem_busaddr; /* Mem Base Addr */
507 uint64_t hw_dma_mask; 435 uint64_t hw_dma_mask;
508 ahd_linux_softc_flags flags; 436#define AHD_SCB_UP_EH_SEM 0x1
437 uint32_t flags;
509}; 438};
510 439
511/************************** OS Utility Wrappers *******************************/ 440/************************** OS Utility Wrappers *******************************/
@@ -622,7 +551,7 @@ ahd_insb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
622 551
623/**************************** Initialization **********************************/ 552/**************************** Initialization **********************************/
624int ahd_linux_register_host(struct ahd_softc *, 553int ahd_linux_register_host(struct ahd_softc *,
625 Scsi_Host_Template *); 554 struct scsi_host_template *);
626 555
627uint64_t ahd_linux_get_memsize(void); 556uint64_t ahd_linux_get_memsize(void);
628 557
@@ -643,17 +572,6 @@ static __inline void ahd_lockinit(struct ahd_softc *);
643static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags); 572static __inline void ahd_lock(struct ahd_softc *, unsigned long *flags);
644static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags); 573static __inline void ahd_unlock(struct ahd_softc *, unsigned long *flags);
645 574
646/* Lock acquisition and release of the above lock in midlayer entry points. */
647static __inline void ahd_midlayer_entrypoint_lock(struct ahd_softc *,
648 unsigned long *flags);
649static __inline void ahd_midlayer_entrypoint_unlock(struct ahd_softc *,
650 unsigned long *flags);
651
652/* Lock held during command compeletion to the upper layer */
653static __inline void ahd_done_lockinit(struct ahd_softc *);
654static __inline void ahd_done_lock(struct ahd_softc *, unsigned long *flags);
655static __inline void ahd_done_unlock(struct ahd_softc *, unsigned long *flags);
656
657/* Lock held during ahd_list manipulation and ahd softc frees */ 575/* Lock held during ahd_list manipulation and ahd softc frees */
658extern spinlock_t ahd_list_spinlock; 576extern spinlock_t ahd_list_spinlock;
659static __inline void ahd_list_lockinit(void); 577static __inline void ahd_list_lockinit(void);
@@ -679,57 +597,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
679} 597}
680 598
681static __inline void 599static __inline void
682ahd_midlayer_entrypoint_lock(struct ahd_softc *ahd, unsigned long *flags)
683{
684 /*
685 * In 2.5.X and some 2.4.X versions, the midlayer takes our
686 * lock just before calling us, so we avoid locking again.
687 * For other kernel versions, the io_request_lock is taken
688 * just before our entry point is called. In this case, we
689 * trade the io_request_lock for our per-softc lock.
690 */
691#if AHD_SCSI_HAS_HOST_LOCK == 0
692 spin_unlock(&io_request_lock);
693 spin_lock(&ahd->platform_data->spin_lock);
694#endif
695}
696
697static __inline void
698ahd_midlayer_entrypoint_unlock(struct ahd_softc *ahd, unsigned long *flags)
699{
700#if AHD_SCSI_HAS_HOST_LOCK == 0
701 spin_unlock(&ahd->platform_data->spin_lock);
702 spin_lock(&io_request_lock);
703#endif
704}
705
706static __inline void
707ahd_done_lockinit(struct ahd_softc *ahd)
708{
709 /*
710 * In 2.5.X, our own lock is held during completions.
711 * In previous versions, the io_request_lock is used.
712 * In either case, we can't initialize this lock again.
713 */
714}
715
716static __inline void
717ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags)
718{
719#if AHD_SCSI_HAS_HOST_LOCK == 0
720 spin_lock(&io_request_lock);
721#endif
722}
723
724static __inline void
725ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags)
726{
727#if AHD_SCSI_HAS_HOST_LOCK == 0
728 spin_unlock(&io_request_lock);
729#endif
730}
731
732static __inline void
733ahd_list_lockinit(void) 600ahd_list_lockinit(void)
734{ 601{
735 spin_lock_init(&ahd_list_spinlock); 602 spin_lock_init(&ahd_list_spinlock);
@@ -909,20 +776,14 @@ ahd_flush_device_writes(struct ahd_softc *ahd)
909int ahd_linux_proc_info(struct Scsi_Host *, char *, char **, 776int ahd_linux_proc_info(struct Scsi_Host *, char *, char **,
910 off_t, int, int); 777 off_t, int, int);
911 778
912/*************************** Domain Validation ********************************/
913#define AHD_DV_CMD(cmd) ((cmd)->scsi_done == ahd_linux_dv_complete)
914#define AHD_DV_SIMQ_FROZEN(ahd) \
915 ((((ahd)->platform_data->flags & AHD_DV_ACTIVE) != 0) \
916 && (ahd)->platform_data->qfrozen == 1)
917
918/*********************** Transaction Access Wrappers **************************/ 779/*********************** Transaction Access Wrappers **************************/
919static __inline void ahd_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 780static __inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t);
920static __inline void ahd_set_transaction_status(struct scb *, uint32_t); 781static __inline void ahd_set_transaction_status(struct scb *, uint32_t);
921static __inline void ahd_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 782static __inline void ahd_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t);
922static __inline void ahd_set_scsi_status(struct scb *, uint32_t); 783static __inline void ahd_set_scsi_status(struct scb *, uint32_t);
923static __inline uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd); 784static __inline uint32_t ahd_cmd_get_transaction_status(struct scsi_cmnd *cmd);
924static __inline uint32_t ahd_get_transaction_status(struct scb *); 785static __inline uint32_t ahd_get_transaction_status(struct scb *);
925static __inline uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd); 786static __inline uint32_t ahd_cmd_get_scsi_status(struct scsi_cmnd *cmd);
926static __inline uint32_t ahd_get_scsi_status(struct scb *); 787static __inline uint32_t ahd_get_scsi_status(struct scb *);
927static __inline void ahd_set_transaction_tag(struct scb *, int, u_int); 788static __inline void ahd_set_transaction_tag(struct scb *, int, u_int);
928static __inline u_long ahd_get_transfer_length(struct scb *); 789static __inline u_long ahd_get_transfer_length(struct scb *);
@@ -941,7 +802,7 @@ static __inline void ahd_platform_scb_free(struct ahd_softc *ahd,
941static __inline void ahd_freeze_scb(struct scb *scb); 802static __inline void ahd_freeze_scb(struct scb *scb);
942 803
943static __inline 804static __inline
944void ahd_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 805void ahd_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status)
945{ 806{
946 cmd->result &= ~(CAM_STATUS_MASK << 16); 807 cmd->result &= ~(CAM_STATUS_MASK << 16);
947 cmd->result |= status << 16; 808 cmd->result |= status << 16;
@@ -954,7 +815,7 @@ void ahd_set_transaction_status(struct scb *scb, uint32_t status)
954} 815}
955 816
956static __inline 817static __inline
957void ahd_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 818void ahd_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
958{ 819{
959 cmd->result &= ~0xFFFF; 820 cmd->result &= ~0xFFFF;
960 cmd->result |= status; 821 cmd->result |= status;
@@ -967,7 +828,7 @@ void ahd_set_scsi_status(struct scb *scb, uint32_t status)
967} 828}
968 829
969static __inline 830static __inline
970uint32_t ahd_cmd_get_transaction_status(Scsi_Cmnd *cmd) 831uint32_t ahd_cmd_get_transaction_status(struct scsi_cmnd *cmd)
971{ 832{
972 return ((cmd->result >> 16) & CAM_STATUS_MASK); 833 return ((cmd->result >> 16) & CAM_STATUS_MASK);
973} 834}
@@ -979,7 +840,7 @@ uint32_t ahd_get_transaction_status(struct scb *scb)
979} 840}
980 841
981static __inline 842static __inline
982uint32_t ahd_cmd_get_scsi_status(Scsi_Cmnd *cmd) 843uint32_t ahd_cmd_get_scsi_status(struct scsi_cmnd *cmd)
983{ 844{
984 return (cmd->result & 0xFFFF); 845 return (cmd->result & 0xFFFF);
985} 846}