Deleted Added
full compact
ispvar.h (52347) ispvar.h (53487)
1/* $FreeBSD: head/sys/dev/isp/ispvar.h 52347 1999-10-17 18:45:31Z mjacob $ */
1/* $FreeBSD: head/sys/dev/isp/ispvar.h 53487 1999-11-21 03:12:58Z mjacob $ */
2/*
3 * Soft Definitions for for Qlogic ISP SCSI adapters.
4 *
5 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
6 * NASA/Ames Research Center
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

32 *
33 */
34
35#ifndef _ISPVAR_H
36#define _ISPVAR_H
37
38#if defined(__NetBSD__) || defined(__OpenBSD__)
39#include <dev/ic/ispmbox.h>
2/*
3 * Soft Definitions for for Qlogic ISP SCSI adapters.
4 *
5 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
6 * NASA/Ames Research Center
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

32 *
33 */
34
35#ifndef _ISPVAR_H
36#define _ISPVAR_H
37
38#if defined(__NetBSD__) || defined(__OpenBSD__)
39#include <dev/ic/ispmbox.h>
40#ifdef ISP_TARGET_MODE
41#include <dev/ic/isp_target.h>
40#endif
42#endif
43#endif
41#ifdef __FreeBSD__
42#include <dev/isp/ispmbox.h>
44#ifdef __FreeBSD__
45#include <dev/isp/ispmbox.h>
46#ifdef ISP_TARGET_MODE
47#include <dev/isp/isp_target.h>
43#endif
48#endif
49#endif
44#ifdef __linux__
45#include "ispmbox.h"
50#ifdef __linux__
51#include "ispmbox.h"
52#ifdef ISP_TARGET_MODE
53#include "isp_target.h"
46#endif
54#endif
55#endif
47
48#define ISP_CORE_VERSION_MAJOR 1
56
57#define ISP_CORE_VERSION_MAJOR 1
49#define ISP_CORE_VERSION_MINOR 10
58#define ISP_CORE_VERSION_MINOR 11
50
51/*
52 * Vector for bus specific code to provide specific services.
53 */
54struct ispsoftc;
55struct ispmdvec {
56 u_int16_t (*dv_rd_reg) __P((struct ispsoftc *, int));
57 void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
58 int (*dv_mbxdma) __P((struct ispsoftc *));
59 int (*dv_dmaset) __P((struct ispsoftc *,
59
60/*
61 * Vector for bus specific code to provide specific services.
62 */
63struct ispsoftc;
64struct ispmdvec {
65 u_int16_t (*dv_rd_reg) __P((struct ispsoftc *, int));
66 void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
67 int (*dv_mbxdma) __P((struct ispsoftc *));
68 int (*dv_dmaset) __P((struct ispsoftc *,
60 ISP_SCSI_XFER_T *, ispreq_t *, u_int8_t *, u_int8_t));
69 ISP_SCSI_XFER_T *, ispreq_t *, u_int16_t *, u_int16_t));
61 void (*dv_dmaclr)
62 __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
63 void (*dv_reset0) __P((struct ispsoftc *));
64 void (*dv_reset1) __P((struct ispsoftc *));
65 void (*dv_dregs) __P((struct ispsoftc *));
66 const u_int16_t *dv_ispfw; /* ptr to f/w */
67 u_int16_t dv_fwlen; /* length of f/w */
68 u_int16_t dv_codeorg; /* code ORG for f/w */

--- 18 unchanged lines hidden (view full) ---

87#else
88#define _ISP_FC_LUN(isp) 16
89#endif
90#define _ISP_SCSI_LUN(isp) \
91 ((ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0))? 32 : 8)
92#define ISP_MAX_LUNS(isp) \
93 (IS_FC(isp)? _ISP_FC_LUN(isp) : _ISP_SCSI_LUN(isp))
94
70 void (*dv_dmaclr)
71 __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
72 void (*dv_reset0) __P((struct ispsoftc *));
73 void (*dv_reset1) __P((struct ispsoftc *));
74 void (*dv_dregs) __P((struct ispsoftc *));
75 const u_int16_t *dv_ispfw; /* ptr to f/w */
76 u_int16_t dv_fwlen; /* length of f/w */
77 u_int16_t dv_codeorg; /* code ORG for f/w */

--- 18 unchanged lines hidden (view full) ---

96#else
97#define _ISP_FC_LUN(isp) 16
98#endif
99#define _ISP_SCSI_LUN(isp) \
100 ((ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0))? 32 : 8)
101#define ISP_MAX_LUNS(isp) \
102 (IS_FC(isp)? _ISP_FC_LUN(isp) : _ISP_SCSI_LUN(isp))
103
104
105/*
106 * Macros to read, write ISP registers through bus specific code.
107 */
108
109#define ISP_READ(isp, reg) \
110 (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
111
112#define ISP_WRITE(isp, reg, val) \
113 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
114
115#define ISP_MBOXDMASETUP(isp) \
116 (*(isp)->isp_mdvec->dv_mbxdma)((isp))
117
118#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \
119 (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
120
121#define ISP_DMAFREE(isp, xs, hndl) \
122 if ((isp)->isp_mdvec->dv_dmaclr) \
123 (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
124
125#define ISP_RESET0(isp) \
126 if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
127#define ISP_RESET1(isp) \
128 if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
129#define ISP_DUMPREGS(isp) \
130 if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
131
132#define ISP_SETBITS(isp, reg, val) \
133 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
134
135#define ISP_CLRBITS(isp, reg, val) \
136 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
137
95/* this is the size of a queue entry (request and response) */
96#define QENTRY_LEN 64
97/* both request and result queue length must be a power of two */
98#define RQUEST_QUEUE_LEN MAXISPREQUEST
99/* I've seen wierdnesses with the result queue < 64 */
100#if MAXISPREQUEST > 64
101#define RESULT_QUEUE_LEN (MAXISPREQUEST/2)
102#else
103#define RESULT_QUEUE_LEN MAXISPREQUEST
104#endif
105#define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN))
106#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN)
107#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1))
108#define ISP_QAVAIL(in, out, qlen) \
109 ((in == out)? (qlen - 1) : ((in > out)? \
110 ((qlen - 1) - (in - out)) : (out - in - 1)))
138/* this is the size of a queue entry (request and response) */
139#define QENTRY_LEN 64
140/* both request and result queue length must be a power of two */
141#define RQUEST_QUEUE_LEN MAXISPREQUEST
142/* I've seen wierdnesses with the result queue < 64 */
143#if MAXISPREQUEST > 64
144#define RESULT_QUEUE_LEN (MAXISPREQUEST/2)
145#else
146#define RESULT_QUEUE_LEN MAXISPREQUEST
147#endif
148#define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN))
149#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN)
150#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1))
151#define ISP_QAVAIL(in, out, qlen) \
152 ((in == out)? (qlen - 1) : ((in > out)? \
153 ((qlen - 1) - (in - out)) : (out - in - 1)))
154
155#define ISP_ADD_REQUEST(isp, iptr) \
156 ISP_WRITE(isp, INMAILBOX4, iptr), isp->isp_reqidx = iptr
157
111/*
112 * SCSI Specific Host Adapter Parameters- per bus, per target
113 */
114
115typedef struct {
116 u_int isp_gotdparms : 1,
117 isp_req_ack_active_neg : 1,
118 isp_data_line_active_neg: 1,

--- 126 unchanged lines hidden (view full) ---

245 */
246struct ispsoftc {
247 /*
248 * Platform (OS) specific data
249 */
250 struct isposinfo isp_osinfo;
251
252 /*
158/*
159 * SCSI Specific Host Adapter Parameters- per bus, per target
160 */
161
162typedef struct {
163 u_int isp_gotdparms : 1,
164 isp_req_ack_active_neg : 1,
165 isp_data_line_active_neg: 1,

--- 126 unchanged lines hidden (view full) ---

292 */
293struct ispsoftc {
294 /*
295 * Platform (OS) specific data
296 */
297 struct isposinfo isp_osinfo;
298
299 /*
253 * Pointer to bus specific data
300 * Pointer to bus specific functions and data
254 */
255 struct ispmdvec * isp_mdvec;
256
257 /*
301 */
302 struct ispmdvec * isp_mdvec;
303
304 /*
258 * Mostly nonvolatile state.
305 * (Mostly) nonvolatile state. Board specific parameters
306 * may contain some volatile state (e.g., current loop state).
259 */
260
307 */
308
261 u_int isp_clock : 8,
262 isp_confopts : 8,
263 isp_fast_mttr : 1,
264 : 1,
265 isp_used : 1,
266 isp_dblev : 3,
267 isp_dogactive : 1,
268 isp_bustype : 1, /* BUS Implementation */
269 isp_type : 8; /* HBA Type and Revision */
309 void * isp_param; /* type specific */
310 u_int16_t isp_fwrev[3]; /* Loaded F/W revision */
311 u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */
312 u_int16_t isp_maxcmds; /* max possible I/O cmds */
313 u_int8_t isp_type; /* HBA Chip Type */
314 u_int8_t isp_revision; /* HBA Chip H/W Revision */
270
315
271 u_int16_t isp_fwrev[3]; /* Running F/W revision */
272 u_int16_t isp_romfw_rev[3]; /* 'ROM' F/W revision */
273 u_int16_t isp_maxcmds; /* max active I/O cmds */
274 void * isp_param;
316 u_int32_t : 4,
317 isp_touched : 1, /* board ever seen? */
318 isp_fast_mttr : 1, /* fast sram */
319 isp_bustype : 1, /* SBus or PCI */
320 isp_dogactive : 1, /* watchdog running */
321 isp_dblev : 8, /* debug level */
322 isp_clock : 8, /* input clock */
323 isp_confopts : 8; /* config options */
275
276 /*
277 * Volatile state
278 */
279
324
325 /*
326 * Volatile state
327 */
328
280 volatile u_int : 9,
329 volatile u_int32_t : 9,
281 isp_state : 3,
282 isp_sendmarker : 2, /* send a marker entry */
283 isp_update : 2, /* update parameters */
284 isp_nactive : 16; /* how many commands active */
285
286 volatile u_int16_t isp_reqodx; /* index of last ISP pickup */
287 volatile u_int16_t isp_reqidx; /* index of next request */
288 volatile u_int16_t isp_residx; /* index of next result */
289 volatile u_int16_t isp_lasthdls; /* last handle seed */
290
291 /*
330 isp_state : 3,
331 isp_sendmarker : 2, /* send a marker entry */
332 isp_update : 2, /* update parameters */
333 isp_nactive : 16; /* how many commands active */
334
335 volatile u_int16_t isp_reqodx; /* index of last ISP pickup */
336 volatile u_int16_t isp_reqidx; /* index of next request */
337 volatile u_int16_t isp_residx; /* index of next result */
338 volatile u_int16_t isp_lasthdls; /* last handle seed */
339
340 /*
292 * Active commands are stored here, found by handle functions.
341 * Active commands are stored here, indexed by handle functions.
293 */
294 ISP_SCSI_XFER_T **isp_xflist;
295
296 /*
297 * request/result queue pointers and dma handles for them.
298 */
299 caddr_t isp_rquest;
300 caddr_t isp_result;

--- 12 unchanged lines hidden (view full) ---

313#define ISP_INITSTATE 2
314#define ISP_RUNSTATE 3
315
316/*
317 * ISP Configuration Options
318 */
319#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */
320#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */
342 */
343 ISP_SCSI_XFER_T **isp_xflist;
344
345 /*
346 * request/result queue pointers and dma handles for them.
347 */
348 caddr_t isp_rquest;
349 caddr_t isp_result;

--- 12 unchanged lines hidden (view full) ---

362#define ISP_INITSTATE 2
363#define ISP_RUNSTATE 3
364
365/*
366 * ISP Configuration Options
367 */
368#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */
369#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */
321#define ISP_CFG_FULL_DUPLEX 0x01 /* Fibre Channel Only */
370#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */
371#define ISP_CFG_OWNWWN 0x02 /* override NVRAM wwn */
322
323#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic)
324#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2])
325
326/*
327 * Bus (implementation) types
328 */
329#define ISP_BT_PCI 0 /* PCI Implementations */

--- 17 unchanged lines hidden (view full) ---

347#define ISP_HA_FC_2200 0x20
348
349#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI)
350#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080)
351#define IS_12X0(isp) (isp->isp_type == ISP_HA_SCSI_12X0)
352#define IS_FC(isp) (isp->isp_type & ISP_HA_FC)
353
354/*
372
373#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic)
374#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2])
375
376/*
377 * Bus (implementation) types
378 */
379#define ISP_BT_PCI 0 /* PCI Implementations */

--- 17 unchanged lines hidden (view full) ---

397#define ISP_HA_FC_2200 0x20
398
399#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI)
400#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080)
401#define IS_12X0(isp) (isp->isp_type == ISP_HA_SCSI_12X0)
402#define IS_FC(isp) (isp->isp_type & ISP_HA_FC)
403
404/*
355 * Macros to read, write ISP registers through bus specific code.
356 */
357
358#define ISP_READ(isp, reg) \
359 (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
360
361#define ISP_WRITE(isp, reg, val) \
362 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
363
364#define ISP_MBOXDMASETUP(isp) \
365 (*(isp)->isp_mdvec->dv_mbxdma)((isp))
366
367#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \
368 (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
369
370#define ISP_DMAFREE(isp, xs, hndl) \
371 if ((isp)->isp_mdvec->dv_dmaclr) \
372 (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
373
374#define ISP_RESET0(isp) \
375 if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
376#define ISP_RESET1(isp) \
377 if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
378#define ISP_DUMPREGS(isp) \
379 if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
380
381#define ISP_SETBITS(isp, reg, val) \
382 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
383
384#define ISP_CLRBITS(isp, reg, val) \
385 (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
386
387/*
388 * Function Prototypes
389 */
390
391/*
392 * Reset Hardware. Totally. Assumes that you'll follow this with
393 * a call to isp_init.
394 */
395void isp_reset __P((struct ispsoftc *));

--- 24 unchanged lines hidden (view full) ---

420 * Assumes all locks are held and that no reentrancy issues need be dealt with.
421 *
422 */
423typedef enum {
424 ISPCTL_RESET_BUS, /* Reset Bus */
425 ISPCTL_RESET_DEV, /* Reset Device */
426 ISPCTL_ABORT_CMD, /* Abort Command */
427 ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters */
405 * Function Prototypes
406 */
407
408/*
409 * Reset Hardware. Totally. Assumes that you'll follow this with
410 * a call to isp_init.
411 */
412void isp_reset __P((struct ispsoftc *));

--- 24 unchanged lines hidden (view full) ---

437 * Assumes all locks are held and that no reentrancy issues need be dealt with.
438 *
439 */
440typedef enum {
441 ISPCTL_RESET_BUS, /* Reset Bus */
442 ISPCTL_RESET_DEV, /* Reset Device */
443 ISPCTL_ABORT_CMD, /* Abort Command */
444 ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters */
445#ifdef ISP_TARGET_MODE
446 ISPCTL_ENABLE_LUN, /* enable a LUN */
447 ISPCTL_MODIFY_LUN, /* enable a LUN */
448#endif
428 ISPCTL_FCLINK_TEST /* Test FC Link Status */
429} ispctl_t;
430int isp_control __P((struct ispsoftc *, ispctl_t, void *));
431
432
433/*
434 * Platform Dependent to Internal to External Control Function
435 * (each platform must provide such a function)

--- 5 unchanged lines hidden (view full) ---

441typedef enum {
442 ISPASYNC_NEW_TGT_PARAMS,
443 ISPASYNC_BUS_RESET, /* Bus Was Reset */
444 ISPASYNC_LOOP_DOWN, /* FC Loop Down */
445 ISPASYNC_LOOP_UP, /* FC Loop Up */
446 ISPASYNC_PDB_CHANGED, /* FC Port Data Base Changed */
447 ISPASYNC_CHANGE_NOTIFY, /* FC SNS Change Notification */
448 ISPASYNC_FABRIC_DEV, /* FC New Fabric Device */
449 ISPCTL_FCLINK_TEST /* Test FC Link Status */
450} ispctl_t;
451int isp_control __P((struct ispsoftc *, ispctl_t, void *));
452
453
454/*
455 * Platform Dependent to Internal to External Control Function
456 * (each platform must provide such a function)

--- 5 unchanged lines hidden (view full) ---

462typedef enum {
463 ISPASYNC_NEW_TGT_PARAMS,
464 ISPASYNC_BUS_RESET, /* Bus Was Reset */
465 ISPASYNC_LOOP_DOWN, /* FC Loop Down */
466 ISPASYNC_LOOP_UP, /* FC Loop Up */
467 ISPASYNC_PDB_CHANGED, /* FC Port Data Base Changed */
468 ISPASYNC_CHANGE_NOTIFY, /* FC SNS Change Notification */
469 ISPASYNC_FABRIC_DEV, /* FC New Fabric Device */
470 ISPASYNC_TARGET_CMD, /* New target command */
471 ISPASYNC_TARGET_EVENT /* New target event */
449} ispasync_t;
450int isp_async __P((struct ispsoftc *, ispasync_t, void *));
451
452/*
453 * lost command routine (XXXX IN TRANSITION XXXX)
454 */
455void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
456
457#endif /* _ISPVAR_H */
472} ispasync_t;
473int isp_async __P((struct ispsoftc *, ispasync_t, void *));
474
475/*
476 * lost command routine (XXXX IN TRANSITION XXXX)
477 */
478void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
479
480#endif /* _ISPVAR_H */