1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Enterprise Fibre Channel Host Bus Adapters. *
4 * Refer to the README file included with this package for *
5 * driver version and adapter support. *
6 * Copyright (C) 2004 Emulex Corporation. *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU General Public License *
11 * as published by the Free Software Foundation; either version 2 *
12 * of the License, or (at your option) any later version. *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details, a copy of which *
18 * can be found in the file COPYING included with this package. *
19 *******************************************************************/
22 * $Id: lpfc_sli.h 1.36 2004/11/23 16:56:58EST sf_support Exp $
30 /* forward declaration for LPFC_IOCB_t's use */
33 /* This structure is used to handle IOCB requests / responses */
35 /* lpfc_iocbqs are used in double linked lists */
36 struct list_head list;
37 IOCB_t iocb; /* IOCB cmd */
38 uint8_t retry; /* retry counter for IOCB cmd - if needed */
40 #define LPFC_IO_POLL 1 /* Polling mode iocb */
41 #define LPFC_IO_LIBDFC 2 /* libdfc iocb */
42 #define LPFC_IO_WAIT 4
43 #define LPFC_IO_HIPRI 8 /* High Priority Queue signal flag */
47 uint32_t drvrTimeout; /* driver timeout in seconds */
48 void *context1; /* caller context information */
49 void *context2; /* caller context information */
50 void *context3; /* caller context information */
52 wait_queue_head_t *hipri_wait_queue; /* High Priority Queue wait
54 struct lpfc_iocbq *rsp_iocb;
55 struct lpfcMboxq *mbox;
58 void (*iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
63 #define SLI_IOCB_RET_IOCB 1 /* Return IOCB if cmd ring full */
64 #define SLI_IOCB_HIGH_PRIORITY 2 /* High priority command */
66 #define IOCB_SUCCESS 0
69 #define IOCB_TIMEDOUT 3
71 typedef struct lpfcMboxq {
72 /* MBOXQs are used in single linked lists */
73 struct list_head list; /* ptr to next mailbox command */
74 MAILBOX_t mb; /* Mailbox cmd */
75 void *context1; /* caller context information */
76 void *context2; /* caller context information */
78 void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *);
82 #define MBX_POLL 1 /* poll mailbox till command done, then
84 #define MBX_NOWAIT 2 /* issue command then return immediately */
85 #define MBX_STOP_IOCB 4 /* Stop iocb processing till mbox cmds
88 #define LPFC_MAX_RING_MASK 4 /* max num of rctl/type masks allowed per
90 #define LPFC_MAX_RING 4 /* max num of SLI rings used by driver */
92 /* Structure used to hold SLI ring information */
93 struct lpfc_sli_ring {
94 uint16_t flag; /* ring flags */
95 #define LPFC_DEFERRED_RING_EVENT 0x001 /* Deferred processing a ring event */
96 #define LPFC_CALL_RING_AVAILABLE 0x002 /* indicates cmd was full */
97 #define LPFC_STOP_IOCB_MBX 0x010 /* Stop processing IOCB cmds mbox */
98 #define LPFC_STOP_IOCB_EVENT 0x020 /* Stop processing IOCB cmds event */
99 #define LPFC_STOP_IOCB_MASK 0x030 /* Stop processing IOCB cmds mask */
100 uint16_t abtsiotag; /* tracks next iotag to use for ABTS */
102 uint32_t local_getidx; /* last available cmd index (from cmdGetInx) */
103 uint32_t next_cmdidx; /* next_cmd index */
105 uint8_t ringno; /* ring number */
106 uint8_t rspidx; /* current index in response ring */
107 uint8_t cmdidx; /* current index in command ring */
108 struct lpfc_iocbq ** fast_lookup; /* array of IOCB ptrs indexed by
110 struct list_head txq;
111 uint16_t txq_cnt; /* current length of queue */
112 uint16_t txq_max; /* max length */
113 struct list_head txcmplq;
114 uint16_t txcmplq_cnt; /* current length of queue */
115 uint16_t txcmplq_max; /* max length */
116 volatile uint32_t *cmdringaddr; /* virtual address for cmd rings */
117 volatile uint32_t *rspringaddr; /* virtual address for rsp rings */
118 uint32_t missbufcnt; /* keep track of buffers to post */
119 struct list_head postbufq;
120 uint16_t postbufq_cnt; /* current length of queue */
121 uint16_t postbufq_max; /* max length */
122 struct list_head iocb_continueq;
123 uint16_t iocb_continueq_cnt; /* current length of queue */
124 uint16_t iocb_continueq_max; /* max length */
128 uint8_t profile; /* profile associated with ring */
129 uint8_t rctl; /* rctl / type pair configured for ring */
130 uint8_t type; /* rctl / type pair configured for ring */
132 /* rcv'd unsol event */
133 void (*lpfc_sli_rcv_unsol_event) (struct lpfc_hba *,
134 struct lpfc_sli_ring *,
135 struct lpfc_iocbq *);
138 /* Structure used for configuring rings to a specific profile or rctl / type */
140 LPFC_RING_MASK_t prt[LPFC_MAX_RING_MASK];
141 uint32_t num_mask; /* number of mask entries in prt array */
142 uint32_t iotag_ctr; /* keeps track of the next iotag to use */
143 uint32_t iotag_max; /* max iotag value to use */
144 uint32_t fast_iotag; /* max fastlookup based iotag */
145 uint16_t numCiocb; /* number of command iocb's per ring */
146 uint16_t numRiocb; /* number of rsp iocb's per ring */
147 /* cmd ring available */
148 void (*lpfc_sli_cmd_available) (struct lpfc_hba *,
149 struct lpfc_sli_ring *);
153 LPFC_RING_INIT_t ringinit[LPFC_MAX_RING]; /* ring initialization info */
158 /* Structure used to hold SLI statistical counters and info */
160 uint64_t iocbEvent[LPFC_MAX_RING]; /* IOCB event counters */
161 uint64_t iocbCmd[LPFC_MAX_RING]; /* IOCB cmd issued */
162 uint64_t iocbRsp[LPFC_MAX_RING]; /* IOCB rsp received */
163 uint64_t iocbCmdDelay[LPFC_MAX_RING]; /* IOCB cmd ring delay */
164 uint64_t iocbCmdFull[LPFC_MAX_RING]; /* IOCB cmd ring full */
165 uint64_t iocbCmdEmpty[LPFC_MAX_RING]; /* IOCB cmd ring is now empty */
166 uint64_t iocbRspFull[LPFC_MAX_RING]; /* IOCB rsp ring full */
167 uint64_t mboxStatErr; /* Mbox cmds completed status error */
168 uint64_t mboxCmd; /* Mailbox commands issued */
169 uint64_t sliIntr; /* Count of Host Attention interrupts */
170 uint32_t errAttnEvent; /* Error Attn event counters */
171 uint32_t linkEvent; /* Link event counters */
172 uint32_t mboxEvent; /* Mailbox event counters */
173 uint32_t mboxBusy; /* Mailbox cmd busy */
176 /* Structure used to hold SLI information */
178 LPFC_SLI_INIT_t sliinit; /* initialization info */
179 /* Additional sli_flags */
180 #define LPFC_SLI_MBOX_ACTIVE 0x100 /* HBA mailbox is currently active */
181 #define LPFC_SLI2_ACTIVE 0x200 /* SLI2 overlay in firmware is active */
182 #define LPFC_PROCESS_LA 0x400 /* Able to process link attention */
184 struct lpfc_sli_ring ring[LPFC_MAX_RING];
185 int fcp_ring; /* ring used for FCP initiator commands */
188 int ip_ring; /* ring used for IP network drv cmds */
190 LPFC_SLI_STAT_t slistat; /* SLI statistical info */
191 struct list_head mboxq;
192 uint16_t mboxq_cnt; /* current length of queue */
193 uint16_t mboxq_max; /* max length */
194 LPFC_MBOXQ_t *mbox_active; /* active mboxq information */
196 struct timer_list mbox_tmo; /* Hold clk to timeout active mbox
199 volatile uint32_t *MBhostaddr; /* virtual address for mbox cmds */
202 /* Given a pointer to the start of the ring, and the slot number of
203 * the desired iocb entry, calc a pointer to that entry.
204 * (assume iocb entry size is 32 bytes, or 8 words)
206 #define IOCB_ENTRY(ring,slot) ((IOCB_t *)(((char *)(ring)) + ((slot) * 32)))
208 #define LPFC_SLI_ABORT_IMED 0 /* Immediate abort of IOCB, deque and
209 call compl routine immediately. */
210 #define LPFC_MBOX_TMO 30 /* Sec tmo for outstanding mbox
213 /* Flags for aborting I/Os on tx and txcmpl queues */
214 #define LPFC_ABORT_TXQ 1 /* Abort I/Os on txq */
215 #define LPFC_ABORT_TXCMPLQ 2 /* Abort I/Os on txcmplq */
216 #define LPFC_ABORT_ALLQ 3 /* Abort I/Os both txq and txcmplq */
218 #endif /* _H_LPFC_SLI */