isp_freebsd.h (155285) | isp_freebsd.h (155704) |
---|---|
1/* $FreeBSD: head/sys/dev/isp/isp_freebsd.h 155285 2006-02-04 08:39:02Z mjacob $ */ | 1/* $FreeBSD: head/sys/dev/isp/isp_freebsd.h 155704 2006-02-15 00:31:48Z mjacob $ */ |
2/*- 3 * Qlogic ISP SCSI Host Adapter FreeBSD Wrapper Definitions 4 * 5 * Copyright (c) 1997-2006 by Matthew Jacob 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 46 unchanged lines hidden (view full) --- 56#include <cam/cam_xpt_sim.h> 57#include <cam/cam_debug.h> 58#include <cam/scsi/scsi_all.h> 59#include <cam/scsi/scsi_message.h> 60 61#include "opt_ddb.h" 62#include "opt_isp.h" 63 | 2/*- 3 * Qlogic ISP SCSI Host Adapter FreeBSD Wrapper Definitions 4 * 5 * Copyright (c) 1997-2006 by Matthew Jacob 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 46 unchanged lines hidden (view full) --- 56#include <cam/cam_xpt_sim.h> 57#include <cam/cam_debug.h> 58#include <cam/scsi/scsi_all.h> 59#include <cam/scsi/scsi_message.h> 60 61#include "opt_ddb.h" 62#include "opt_isp.h" 63 |
64/* disabled until done correctly */ 65/* #define ISP_DAC_SUPPORTED 1 */ 66 | |
67/* 68 * Efficiency- get rid of SBus code && tests unless we need them. 69 */ 70#ifdef __sparc64__ 71#define ISP_SBUS_SUPPORTED 1 72#else 73#define ISP_SBUS_SUPPORTED 0 74#endif 75 76#define HANDLE_LOOPSTATE_IN_OUTER_LAYERS 1 77/* #define ISP_SMPLOCK 1 */ 78 79#ifdef ISP_SMPLOCK 80#define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE 81#else 82#define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY 83#endif 84 | 64/* 65 * Efficiency- get rid of SBus code && tests unless we need them. 66 */ 67#ifdef __sparc64__ 68#define ISP_SBUS_SUPPORTED 1 69#else 70#define ISP_SBUS_SUPPORTED 0 71#endif 72 73#define HANDLE_LOOPSTATE_IN_OUTER_LAYERS 1 74/* #define ISP_SMPLOCK 1 */ 75 76#ifdef ISP_SMPLOCK 77#define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE 78#else 79#define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY 80#endif 81 |
85typedef void ispfwfunc(int, int, int, u_int16_t **); | 82typedef void ispfwfunc(int, int, int, uint16_t **); |
86 87#ifdef ISP_TARGET_MODE 88#define ISP_TARGET_FUNCTIONS 1 89#define ATPDPSIZE 256 90typedef struct { | 83 84#ifdef ISP_TARGET_MODE 85#define ISP_TARGET_FUNCTIONS 1 86#define ATPDPSIZE 256 87typedef struct { |
91 u_int32_t orig_datalen; 92 u_int32_t bytes_xfered; 93 u_int32_t last_xframt; 94 u_int32_t tag : 16, | 88 uint32_t orig_datalen; 89 uint32_t bytes_xfered; 90 uint32_t last_xframt; 91 uint32_t tag : 16, |
95 lun : 13, /* not enough */ 96 state : 3; 97} atio_private_data_t; 98#define ATPD_STATE_FREE 0 99#define ATPD_STATE_ATIO 1 100#define ATPD_STATE_CAM 2 101#define ATPD_STATE_CTIO 3 102#define ATPD_STATE_LAST_CTIO 4 103#define ATPD_STATE_PDON 5 104 105typedef struct tstate { 106 struct tstate *next; 107 struct cam_path *owner; 108 struct ccb_hdr_slist atios; 109 struct ccb_hdr_slist inots; 110 lun_id_t lun; 111 int bus; | 92 lun : 13, /* not enough */ 93 state : 3; 94} atio_private_data_t; 95#define ATPD_STATE_FREE 0 96#define ATPD_STATE_ATIO 1 97#define ATPD_STATE_CAM 2 98#define ATPD_STATE_CTIO 3 99#define ATPD_STATE_LAST_CTIO 4 100#define ATPD_STATE_PDON 5 101 102typedef struct tstate { 103 struct tstate *next; 104 struct cam_path *owner; 105 struct ccb_hdr_slist atios; 106 struct ccb_hdr_slist inots; 107 lun_id_t lun; 108 int bus; |
112 u_int32_t hold; | 109 uint32_t hold; |
113 int atio_count; 114 int inot_count; 115} tstate_t; 116 117#define LUN_HASH_SIZE 32 118#define LUN_HASH_FUNC(isp, port, lun) \ 119 ((IS_DUALBUS(isp)) ? \ 120 (((lun) & ((LUN_HASH_SIZE >> 1) - 1)) << (port)) : \ 121 ((lun) & (LUN_HASH_SIZE - 1))) 122#endif 123 124struct isposinfo { 125 struct ispsoftc * next; | 110 int atio_count; 111 int inot_count; 112} tstate_t; 113 114#define LUN_HASH_SIZE 32 115#define LUN_HASH_FUNC(isp, port, lun) \ 116 ((IS_DUALBUS(isp)) ? \ 117 (((lun) & ((LUN_HASH_SIZE >> 1) - 1)) << (port)) : \ 118 ((lun) & (LUN_HASH_SIZE - 1))) 119#endif 120 121struct isposinfo { 122 struct ispsoftc * next; |
126 u_int64_t default_port_wwn; 127 u_int64_t default_node_wwn; 128 u_int32_t default_id; | 123 uint64_t default_port_wwn; 124 uint64_t default_node_wwn; 125 uint32_t default_id; |
129 device_t dev; 130 struct cam_sim *sim; 131 struct cam_path *path; 132 struct cam_sim *sim2; 133 struct cam_path *path2; 134 struct intr_config_hook ehook; | 126 device_t dev; 127 struct cam_sim *sim; 128 struct cam_path *path; 129 struct cam_sim *sim2; 130 struct cam_path *path2; 131 struct intr_config_hook ehook; |
135 u_int8_t : 1, | 132 uint8_t : 1, |
136 fcbsy : 1, 137 ktmature : 1, 138 mboxwaiting : 1, 139 intsok : 1, 140 simqfrozen : 3; 141 struct mtx lock; 142 struct cv kthread_cv; 143 struct proc *kproc; 144 bus_dma_tag_t cdmat; 145 bus_dmamap_t cdmap; 146#define isp_cdmat isp_osinfo.cdmat 147#define isp_cdmap isp_osinfo.cdmap 148#ifdef ISP_TARGET_MODE 149#define TM_WILDCARD_ENABLED 0x02 150#define TM_TMODE_ENABLED 0x01 | 133 fcbsy : 1, 134 ktmature : 1, 135 mboxwaiting : 1, 136 intsok : 1, 137 simqfrozen : 3; 138 struct mtx lock; 139 struct cv kthread_cv; 140 struct proc *kproc; 141 bus_dma_tag_t cdmat; 142 bus_dmamap_t cdmap; 143#define isp_cdmat isp_osinfo.cdmat 144#define isp_cdmap isp_osinfo.cdmap 145#ifdef ISP_TARGET_MODE 146#define TM_WILDCARD_ENABLED 0x02 147#define TM_TMODE_ENABLED 0x01 |
151 u_int8_t tmflags[2]; /* two busses */ | 148 uint8_t tmflags[2]; /* two busses */ |
152#define NLEACT 4 153 union ccb * leact[NLEACT]; 154 tstate_t tsdflt[2]; /* two busses */ 155 tstate_t *lun_hash[LUN_HASH_SIZE]; 156 atio_private_data_t atpdp[ATPDPSIZE]; 157#endif 158}; 159 --- 84 unchanged lines hidden (view full) --- 244#ifndef SCSI_BUSY 245#define SCSI_BUSY SCSI_STATUS_BUSY 246#endif 247#ifndef SCSI_QFULL 248#define SCSI_QFULL SCSI_STATUS_QUEUE_FULL 249#endif 250 251#define XS_T struct ccb_scsiio | 149#define NLEACT 4 150 union ccb * leact[NLEACT]; 151 tstate_t tsdflt[2]; /* two busses */ 152 tstate_t *lun_hash[LUN_HASH_SIZE]; 153 atio_private_data_t atpdp[ATPDPSIZE]; 154#endif 155}; 156 --- 84 unchanged lines hidden (view full) --- 241#ifndef SCSI_BUSY 242#define SCSI_BUSY SCSI_STATUS_BUSY 243#endif 244#ifndef SCSI_QFULL 245#define SCSI_QFULL SCSI_STATUS_QUEUE_FULL 246#endif 247 248#define XS_T struct ccb_scsiio |
249#define XS_DMA_ADDR_T bus_addr_t |
|
252#define XS_ISP(ccb) ((struct ispsoftc *) (ccb)->ccb_h.spriv_ptr1) 253#define XS_CHANNEL(ccb) cam_sim_bus(xpt_path_sim((ccb)->ccb_h.path)) 254#define XS_TGT(ccb) (ccb)->ccb_h.target_id 255#define XS_LUN(ccb) (ccb)->ccb_h.target_lun 256 257#define XS_CDBP(ccb) \ 258 (((ccb)->ccb_h.flags & CAM_CDB_POINTER)? \ 259 (ccb)->cdb_io.cdb_ptr : (ccb)->cdb_io.cdb_bytes) --- 58 unchanged lines hidden (view full) --- 318 319#if BYTE_ORDER == BIG_ENDIAN 320#ifdef ISP_SBUS_SUPPORTED 321#define ISP_IOXPUT_8(isp, s, d) *(d) = s 322#define ISP_IOXPUT_16(isp, s, d) \ 323 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s) 324#define ISP_IOXPUT_32(isp, s, d) \ 325 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s) | 250#define XS_ISP(ccb) ((struct ispsoftc *) (ccb)->ccb_h.spriv_ptr1) 251#define XS_CHANNEL(ccb) cam_sim_bus(xpt_path_sim((ccb)->ccb_h.path)) 252#define XS_TGT(ccb) (ccb)->ccb_h.target_id 253#define XS_LUN(ccb) (ccb)->ccb_h.target_lun 254 255#define XS_CDBP(ccb) \ 256 (((ccb)->ccb_h.flags & CAM_CDB_POINTER)? \ 257 (ccb)->cdb_io.cdb_ptr : (ccb)->cdb_io.cdb_bytes) --- 58 unchanged lines hidden (view full) --- 316 317#if BYTE_ORDER == BIG_ENDIAN 318#ifdef ISP_SBUS_SUPPORTED 319#define ISP_IOXPUT_8(isp, s, d) *(d) = s 320#define ISP_IOXPUT_16(isp, s, d) \ 321 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s) 322#define ISP_IOXPUT_32(isp, s, d) \ 323 *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s) |
326#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s)) | 324#define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) |
327#define ISP_IOXGET_16(isp, s, d) \ 328 d = (isp->isp_bustype == ISP_BT_SBUS)? \ | 325#define ISP_IOXGET_16(isp, s, d) \ 326 d = (isp->isp_bustype == ISP_BT_SBUS)? \ |
329 *((u_int16_t *)s) : bswap16(*((u_int16_t *)s)) | 327 *((uint16_t *)s) : bswap16(*((uint16_t *)s)) |
330#define ISP_IOXGET_32(isp, s, d) \ 331 d = (isp->isp_bustype == ISP_BT_SBUS)? \ | 328#define ISP_IOXGET_32(isp, s, d) \ 329 d = (isp->isp_bustype == ISP_BT_SBUS)? \ |
332 *((u_int32_t *)s) : bswap32(*((u_int32_t *)s)) | 330 *((uint32_t *)s) : bswap32(*((uint32_t *)s)) |
333#else 334#define ISP_IOXPUT_8(isp, s, d) *(d) = s 335#define ISP_IOXPUT_16(isp, s, d) *(d) = bswap16(s) 336#define ISP_IOXPUT_32(isp, s, d) *(d) = bswap32(s) | 331#else 332#define ISP_IOXPUT_8(isp, s, d) *(d) = s 333#define ISP_IOXPUT_16(isp, s, d) *(d) = bswap16(s) 334#define ISP_IOXPUT_32(isp, s, d) *(d) = bswap32(s) |
337#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s)) 338#define ISP_IOXGET_16(isp, s, d) d = bswap16(*((u_int16_t *)s)) 339#define ISP_IOXGET_32(isp, s, d) d = bswap32(*((u_int32_t *)s)) | 335#define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) 336#define ISP_IOXGET_16(isp, s, d) d = bswap16(*((uint16_t *)s)) 337#define ISP_IOXGET_32(isp, s, d) d = bswap32(*((uint32_t *)s)) |
340#endif 341#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp) 342#else 343#define ISP_IOXPUT_8(isp, s, d) *(d) = s 344#define ISP_IOXPUT_16(isp, s, d) *(d) = s 345#define ISP_IOXPUT_32(isp, s, d) *(d) = s 346#define ISP_IOXGET_8(isp, s, d) d = *(s) 347#define ISP_IOXGET_16(isp, s, d) d = *(s) --- 4 unchanged lines hidden (view full) --- 352/* 353 * Includes of common header files 354 */ 355 356#include <dev/isp/ispreg.h> 357#include <dev/isp/ispvar.h> 358#include <dev/isp/ispmbox.h> 359 | 338#endif 339#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp) 340#else 341#define ISP_IOXPUT_8(isp, s, d) *(d) = s 342#define ISP_IOXPUT_16(isp, s, d) *(d) = s 343#define ISP_IOXPUT_32(isp, s, d) *(d) = s 344#define ISP_IOXGET_8(isp, s, d) d = *(s) 345#define ISP_IOXGET_16(isp, s, d) d = *(s) --- 4 unchanged lines hidden (view full) --- 350/* 351 * Includes of common header files 352 */ 353 354#include <dev/isp/ispreg.h> 355#include <dev/isp/ispvar.h> 356#include <dev/isp/ispmbox.h> 357 |
358#ifdef ISP_TARGET_MODE 359#include <dev/isp/isp_tpublic.h> 360#endif 361 |
|
360void isp_prt(struct ispsoftc *, int level, const char *, ...) 361 __printflike(3, 4); 362/* 363 * isp_osinfo definiitions && shorthand 364 */ 365#define SIMQFRZ_RESOURCE 0x1 366#define SIMQFRZ_LOOPDOWN 0x2 367#define SIMQFRZ_TIMED 0x4 --- 61 unchanged lines hidden (view full) --- 429 isp->isp_lastmbxcmd); 430 isp->isp_mboxbsy = 0; 431 } 432 isp->isp_osinfo.mboxwaiting = 0; 433 } else { 434 int lim = ((isp->isp_mbxwrk0)? 240 : 60) * 10000; 435 int j; 436 for (j = 0; j < lim; j++) { | 362void isp_prt(struct ispsoftc *, int level, const char *, ...) 363 __printflike(3, 4); 364/* 365 * isp_osinfo definiitions && shorthand 366 */ 367#define SIMQFRZ_RESOURCE 0x1 368#define SIMQFRZ_LOOPDOWN 0x2 369#define SIMQFRZ_TIMED 0x4 --- 61 unchanged lines hidden (view full) --- 431 isp->isp_lastmbxcmd); 432 isp->isp_mboxbsy = 0; 433 } 434 isp->isp_osinfo.mboxwaiting = 0; 435 } else { 436 int lim = ((isp->isp_mbxwrk0)? 240 : 60) * 10000; 437 int j; 438 for (j = 0; j < lim; j++) { |
437 u_int16_t isr, sema, mbox; | 439 uint16_t isr, sema, mbox; |
438 if (isp->isp_mboxbsy == 0) { 439 break; 440 } 441 if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { 442 isp_intr(isp, isr, sema, mbox); 443 if (isp->isp_mboxbsy == 0) { 444 break; 445 } 446 } 447 USEC_DELAY(500); 448 } 449 if (isp->isp_mboxbsy != 0) { 450 isp_prt(isp, ISP_LOGWARN, 451 "Polled Mailbox Command (0x%x) Timeout", 452 isp->isp_lastmbxcmd); 453 } 454 } 455} 456 | 440 if (isp->isp_mboxbsy == 0) { 441 break; 442 } 443 if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { 444 isp_intr(isp, isr, sema, mbox); 445 if (isp->isp_mboxbsy == 0) { 446 break; 447 } 448 } 449 USEC_DELAY(500); 450 } 451 if (isp->isp_mboxbsy != 0) { 452 isp_prt(isp, ISP_LOGWARN, 453 "Polled Mailbox Command (0x%x) Timeout", 454 isp->isp_lastmbxcmd); 455 } 456 } 457} 458 |
457static __inline u_int64_t nanotime_sub(struct timespec *, struct timespec *); 458static __inline u_int64_t | 459static __inline uint64_t nanotime_sub(struct timespec *, struct timespec *); 460static __inline uint64_t |
459nanotime_sub(struct timespec *b, struct timespec *a) 460{ | 461nanotime_sub(struct timespec *b, struct timespec *a) 462{ |
461 u_int64_t elapsed; | 463 uint64_t elapsed; |
462 struct timespec x = *b; 463 timespecsub(&x, a); 464 elapsed = GET_NANOSEC(&x); 465 if (elapsed == 0) 466 elapsed++; 467 return (elapsed); 468} 469 --- 26 unchanged lines hidden --- | 464 struct timespec x = *b; 465 timespecsub(&x, a); 466 elapsed = GET_NANOSEC(&x); 467 if (elapsed == 0) 468 elapsed++; 469 return (elapsed); 470} 471 --- 26 unchanged lines hidden --- |