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.h 1.134 2004/11/18 14:53:45EST sf_support Exp $
28 struct lpfc_sli2_slim;
30 #define LPFC_MAX_TARGET 256 /* max nunber of targets
32 #define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els
34 #define LPFC_MAX_NS_RETRY 3 /* Try to get to the NameServer
35 3 times and then give up. */
36 #define LPFC_DFT_HBA_Q_DEPTH 2048 /* max cmds per hba */
37 #define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */
38 #define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */
40 /* Define the SLIM2 page size. */
41 #define LPFC_SLIM2_PAGE_AREA 8192
43 /* Define macros for 64 bit support */
44 #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
45 #define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32)))
46 #define getPaddr(high, low) ((dma_addr_t)( \
47 (( (u64)(high)<<16 ) << 16)|( (u64)(low))))
48 /* Provide maximum configuration definitions. */
49 #define LPFC_DRVR_TIMEOUT 16 /* driver iocb timeout value in sec */
50 #define MAX_FCP_TARGET 256 /* max num of FCP targets supported */
51 #define FC_MAX_ADPTMSG 64
57 #define putLunLow(lunlow, lun) \
62 #define putLunHigh(lunhigh, lun) \
64 lunhigh = swab16(lun); \
67 #else /* BIG_ENDIAN_HOST */
69 #define putLunLow(lunlow, lun) \
74 #define putLunHigh(lunhigh, lun) \
76 lunhigh = (uint32_t)(lun << 16); \
80 /****************************************************************************/
81 /* Device VPD save area */
82 /****************************************************************************/
83 typedef struct lpfc_vpd {
84 uint32_t status; /* vpd status value */
85 uint32_t length; /* number of bytes actually returned */
87 uint32_t rsvd1; /* Revision numbers */
101 uint8_t sli1FwName[16];
103 uint8_t sli2FwName[16];
107 struct lpfc_scsi_buf;
109 struct lpfc_hba_event {
110 uint32_t fc_eventcode;
121 /* Statistics for ELS commands */
123 uint32_t elsRetryExceeded;
124 uint32_t elsXmitRetry;
125 uint32_t elsDelayRetry;
127 uint32_t elsRcvFrame;
131 uint32_t elsRcvFARPR;
132 uint32_t elsRcvFLOGI;
133 uint32_t elsRcvPLOGI;
134 uint32_t elsRcvADISC;
135 uint32_t elsRcvPDISC;
141 uint32_t elsXmitFLOGI;
142 uint32_t elsXmitPLOGI;
143 uint32_t elsXmitPRLI;
144 uint32_t elsXmitADISC;
145 uint32_t elsXmitLOGO;
147 uint32_t elsXmitRNID;
148 uint32_t elsXmitFARP;
149 uint32_t elsXmitFARPR;
151 uint32_t elsXmitLSRJT;
153 uint32_t frameRcvBcast;
154 uint32_t frameRcvMulti;
155 uint32_t strayXmitCmpl;
156 uint32_t frameXmitDelay;
161 uint32_t LinkMultiEvent;
166 uint32_t fcpRemoteStop;
168 uint32_t fcpPortBusy;
170 uint32_t fcpLocalErr;
173 enum sysfs_mbox_state {
179 struct lpfc_sysfs_mbox {
180 enum sysfs_mbox_state state;
182 struct lpfcMboxq * mbox;
186 uint32_t intr_inited; /* flag for interrupt registration */
187 struct list_head hba_list; /* List of hbas/ports */
189 struct lpfc_sli2_slim *slim2p;
190 dma_addr_t slim2p_mapping;
194 #define LPFC_INIT_START 1 /* Initial state after board reset */
195 #define LPFC_INIT_MBX_CMDS 2 /* Initialize HBA with mbox commands */
196 #define LPFC_LINK_DOWN 3 /* HBA initialized, link is down */
197 #define LPFC_LINK_UP 4 /* Link is up - issue READ_LA */
198 #define LPFC_LOCAL_CFG_LINK 5 /* local NPORT Id configured */
199 #define LPFC_FLOGI 6 /* FLOGI sent to Fabric */
200 #define LPFC_FABRIC_CFG_LINK 7 /* Fabric assigned NPORT Id
202 #define LPFC_NS_REG 8 /* Register with NameServer */
203 #define LPFC_NS_QRY 9 /* Query NameServer for NPort ID list */
204 #define LPFC_BUILD_DISC_LIST 10 /* Build ADISC and PLOGI lists for
205 * device authentication / discovery */
206 #define LPFC_DISC_AUTH 11 /* Processing ADISC list */
207 #define LPFC_CLEAR_LA 12 /* authentication cmplt - issue
209 #define LPFC_HBA_READY 32
210 #define LPFC_HBA_ERROR 0xff
212 uint8_t fc_linkspeed; /* Link speed after last READ_LA */
214 uint32_t fc_eventTag; /* event tag for link attention */
215 uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */
217 uint32_t num_disc_nodes; /*in addition to hba_state */
219 uint8_t fcp_mapping; /* Map FCP devices based on WWNN WWPN or DID */
220 #define FCP_SEED_WWNN 0x1
221 #define FCP_SEED_WWPN 0x2
222 #define FCP_SEED_DID 0x4
223 #define FCP_SEED_MASK 0x7
224 #define FCP_SEED_AUTO 0x8 /* binding was created by auto mapping */
226 struct timer_list fc_estabtmo; /* link establishment timer */
227 struct timer_list fc_disctmo; /* Discovery rescue timer */
228 struct timer_list fc_fdmitmo; /* fdmi timer */
229 struct timer_list fc_scantmo; /* scsi scan host timer */
232 void *fc_evt_head; /* waiting for event queue */
233 void *fc_evt_tail; /* waiting for event queue */
235 uint16_t hba_event_put; /* hbaevent event put word anchor */
236 uint16_t hba_event_get; /* hbaevent event get word anchor */
237 uint32_t hba_event_missed; /* hbaevent missed event word anchor */
238 uint32_t sid_cnt; /* SCSI ID counter */
240 struct lpfc_hba_event hbaevt[MAX_HBAEVT];
242 /* These fields used to be binfo */
243 struct lpfc_name fc_nodename; /* fc nodename */
244 struct lpfc_name fc_portname; /* fc portname */
245 uint32_t fc_pref_DID; /* preferred D_ID */
246 uint8_t fc_pref_ALPA; /* preferred AL_PA */
247 uint32_t fc_edtov; /* E_D_TOV timer value */
248 uint32_t fc_arbtov; /* ARB_TOV timer value */
249 uint32_t fc_ratov; /* R_A_TOV timer value */
250 uint32_t fc_rttov; /* R_T_TOV timer value */
251 uint32_t fc_altov; /* AL_TOV timer value */
252 uint32_t fc_crtov; /* C_R_TOV timer value */
253 uint32_t fc_citov; /* C_I_TOV timer value */
254 uint32_t fc_myDID; /* fibre channel S_ID */
255 uint32_t fc_prevDID; /* previous fibre channel S_ID */
257 struct serv_parm fc_sparam; /* buffer for our service parameters */
258 struct serv_parm fc_fabparam; /* fabric service parameters buffer */
259 uint8_t alpa_map[128]; /* AL_PA map from READ_LA */
261 uint8_t fc_ns_retry; /* retries for fabric nameserver */
262 uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */
263 uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */
264 struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN];
266 uint32_t fc_flag; /* FC flags */
267 #define FC_PT2PT 0x1 /* pt2pt with no fabric */
268 #define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */
269 #define FC_DISC_TMO 0x4 /* Discovery timer running */
270 #define FC_PUBLIC_LOOP 0x8 /* Public loop */
271 #define FC_LBIT 0x10 /* LOGIN bit in loopinit set */
272 #define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */
273 #define FC_NLP_MORE 0x40 /* More node to process in node tbl */
274 #define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */
275 #define FC_FABRIC 0x100 /* We are fabric attached */
276 #define FC_ESTABLISH_LINK 0x200 /* Reestablish Link */
277 #define FC_RSCN_DISCOVERY 0x400 /* Authenticate all devices after RSCN*/
278 #define FC_LOADING 0x1000 /* HBA in process of loading drvr */
279 #define FC_UNLOADING 0x2000 /* HBA in process of unloading drvr */
280 #define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
281 #define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
283 uint32_t fc_topology; /* link topology, from LINK INIT */
285 struct lpfc_stats fc_stat;
287 /* These are the head/tail pointers for the bind, plogi, adisc, unmap,
288 * and map lists. Their counters are immediately following.
290 struct list_head fc_nlpbind_list;
291 struct list_head fc_plogi_list;
292 struct list_head fc_adisc_list;
293 struct list_head fc_reglogin_list;
294 struct list_head fc_prli_list;
295 struct list_head fc_nlpunmap_list;
296 struct list_head fc_nlpmap_list;
297 struct list_head fc_npr_list;
298 struct list_head fc_unused_list;
300 /* Keep counters for the number of entries in each list. */
301 uint16_t fc_bind_cnt;
302 uint16_t fc_plogi_cnt;
303 uint16_t fc_adisc_cnt;
304 uint16_t fc_reglogin_cnt;
305 uint16_t fc_prli_cnt;
306 uint16_t fc_unmap_cnt;
309 uint16_t fc_unused_cnt;
310 struct lpfc_nodelist fc_fcpnodev; /* nodelist entry for no device */
311 uint32_t nport_event_cnt; /* timestamp for nlplist entry */
313 struct lpfc_target *device_queue_hash[MAX_FCP_TARGET];
314 #define LPFC_RPI_HASH_SIZE 64
315 #define LPFC_RPI_HASH_FUNC(x) ((x) & (0x3f))
316 /* ptr to active D_ID / RPIs */
317 struct lpfc_nodelist *fc_nlplookup[LPFC_RPI_HASH_SIZE];
319 uint32_t RandomData[7];
321 uint32_t cfg_log_verbose;
322 uint32_t cfg_lun_queue_depth;
323 uint32_t cfg_nodev_tmo;
324 uint32_t cfg_hba_queue_depth;
325 uint32_t cfg_automap;
326 uint32_t cfg_fcp_class;
327 uint32_t cfg_use_adisc;
329 uint32_t cfg_topology;
330 uint32_t cfg_scan_down;
331 uint32_t cfg_link_speed;
332 uint32_t cfg_cr_delay;
333 uint32_t cfg_cr_count;
334 uint32_t cfg_fdmi_on;
335 uint32_t cfg_fcp_bind_method;
336 uint32_t cfg_discovery_threads;
337 uint32_t cfg_max_luns;
338 uint32_t cfg_scsi_hotplug;
340 lpfc_vpd_t vpd; /* vital product data */
342 #if defined(FC_TRANS_265_BLKPATCH)
344 * Provide a per-HBA timer for 2.6.5 kernels patched with the
345 * block/unblock FC transport patch.
347 struct timer_list dev_loss_timer;
350 struct Scsi_Host *host;
351 struct pci_dev *pcidev;
352 struct list_head dpc_disc;
356 struct completion dpc_startup;
357 struct completion dpc_exiting;
358 struct semaphore *dpc_wait;
360 unsigned long pci_bar0_map; /* Physical address for PCI BAR0 */
361 unsigned long pci_bar2_map; /* Physical address for PCI BAR2 */
362 void *slim_memmap_p; /* Kernel memory mapped address for PCI
364 void *ctrl_regs_memmap_p; /* Kernel memory mapped address for PCI
367 void *MBslimaddr; /* virtual address for mbox cmds */
368 void *HAregaddr; /* virtual address for host attn reg */
369 void *CAregaddr; /* virtual address for chip attn reg */
370 void *HSregaddr; /* virtual address for host status reg */
371 void *HCregaddr; /* virtual address for host ctl reg */
372 wait_queue_head_t linkevtwq;
373 wait_queue_head_t rscnevtwq;
374 wait_queue_head_t ctevtwq;
376 uint8_t brd_no; /* FC board number */
378 char SerialNumber[32]; /* adapter Serial Number */
379 char OptionROMVersion[32]; /* adapter BIOS / Fcode version */
381 struct timer_list els_tmofunc;
388 uint64_t fc4InputRequests;
389 uint64_t fc4OutputRequests;
390 uint64_t fc4ControlRequests;
392 struct lpfc_sysfs_mbox sysfs_mbox;
395 struct pci_pool *lpfc_scsi_dma_ext_pool;
396 struct pci_pool *lpfc_mbuf_pool;
397 struct lpfc_dma_pool lpfc_mbuf_safety_pool;
398 mempool_t *scsibuf_mem_pool;
400 mempool_t *iocb_mem_pool;
401 mempool_t *mbox_mem_pool;
402 mempool_t *nlp_mem_pool;
403 mempool_t *bind_mem_pool;
404 struct list_head freebufList;
405 struct list_head ctrspbuflist;
406 struct list_head rnidrspbuflist;
409 /* event mask definitions */
410 #define FC_REG_LINK_EVENT 0x1 /* Register for link up / down events */
411 #define FC_REG_RSCN_EVENT 0x2 /* Register for RSCN events */
412 #define FC_REG_CT_EVENT 0x4 /* Register for CT request events */
414 #define FC_FSTYPE_ALL 0xffff /* match on all fsTypes */
416 typedef struct fcEVT { /* Kernel level Event structure */
428 typedef struct fcEVTHDR { /* Kernel level Event Header */
432 #define E_SLEEPING_MODE 0x0001
435 #define E_GET_EVENT_ACTIVE 0x0001
445 struct list_head list;