4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at
9 * http://www.opensource.org/licenses/cddl1.txt.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2004-2012 Emulex. All rights reserved.
24 * Use is subject to license terms.
34 typedef struct emlxs_buf
36 fc_packet_t
*pkt
; /* scsi_pkt reference */
37 struct emlxs_port
*port
; /* pointer to port */
38 void *bmp
; /* Save the buffer pointer */
39 /* list for later use. */
40 struct emlxs_buf
*fc_fwd
; /* Use it by chip_Q */
41 struct emlxs_buf
*fc_bkwd
; /* Use it by chip_Q */
42 struct emlxs_buf
*next
; /* Use it when the iodone */
43 struct emlxs_node
*node
;
44 void *channel
; /* Save channel and used by */
46 struct emlxs_buf
*fpkt
; /* Flush pkt pointer */
47 struct XRIobj
*xrip
; /* Exchange resource */
51 uint32_t iotag
; /* iotag for this cmd */
52 uint32_t ticks
; /* save the timeout ticks */
53 /* for the fc_packet_t */
54 uint32_t abort_attempts
;
56 #define EMLXS_LUN_NONE 0xFFFFFFFF
58 uint32_t class; /* Save class and used by */
60 uint32_t ucmd
; /* Unsolicted command that */
61 /* this packet is responding */
63 int32_t flush_count
; /* Valid only in flush pkts */
73 #define EMLXS_FCT_ELS_CMD 0x01 /* Unsolicted */
74 #define EMLXS_FCT_ELS_REQ 0x02 /* Solicited */
75 #define EMLXS_FCT_ELS_RSP 0x04
76 #define EMLXS_FCT_CT_REQ 0x08 /* Solicited */
77 #define EMLXS_FCT_FCP_CMD 0x10 /* Unsolicted */
78 #define EMLXS_FCT_FCP_DATA 0x20
79 #define EMLXS_FCT_FCP_STATUS 0x40
84 #define EMLXS_FCT_SEND_STATUS 0x01
85 #define EMLXS_FCT_ABORT_INP 0x02
86 #define EMLXS_FCT_IO_INP 0x04
87 #define EMLXS_FCT_PLOGI_RECEIVED 0x10
88 #define EMLXS_FCT_REGISTERED 0x20
92 #define EMLXS_FCT_FCP_CMD_RECEIVED 1
93 #define EMLXS_FCT_ELS_CMD_RECEIVED 2
94 #define EMLXS_FCT_CMD_POSTED 3
95 #define EMLXS_FCT_CMD_WAITQ 4
96 #define EMLXS_FCT_SEND_CMD_RSP 5
97 #define EMLXS_FCT_SEND_ELS_RSP 6
98 #define EMLXS_FCT_SEND_ELS_REQ 7
99 #define EMLXS_FCT_SEND_CT_REQ 8
100 #define EMLXS_FCT_RSP_PENDING 9
101 #define EMLXS_FCT_REQ_PENDING 10
102 #define EMLXS_FCT_REG_PENDING 11
103 #define EMLXS_FCT_REG_COMPLETE 12
104 #define EMLXS_FCT_OWNED 13
105 #define EMLXS_FCT_SEND_FCP_DATA 14
106 #define EMLXS_FCT_SEND_FCP_STATUS 15
107 #define EMLXS_FCT_DATA_PENDING 16
108 #define EMLXS_FCT_STATUS_PENDING 17
109 #define EMLXS_FCT_PKT_COMPLETE 18
110 #define EMLXS_FCT_PKT_FCPRSP_COMPLETE 19
111 #define EMLXS_FCT_PKT_ELSRSP_COMPLETE 20
112 #define EMLXS_FCT_PKT_ELSCMD_COMPLETE 21
113 #define EMLXS_FCT_PKT_CTCMD_COMPLETE 22
114 #define EMLXS_FCT_REQ_COMPLETE 23
115 #define EMLXS_FCT_CLOSE_PENDING 24
116 #define EMLXS_FCT_ABORT_PENDING 25
117 #define EMLXS_FCT_ABORT_DONE 26
118 #define EMLXS_FCT_IO_DONE 27
120 #define EMLXS_FCT_IOCB_ISSUED 256 /* For tracing only */
121 #define EMLXS_FCT_IOCB_COMPLETE 257 /* For tracing only */
123 stmf_data_buf_t
*fct_buf
;
125 #endif /* SFCT_SUPPORT */
127 #ifdef SAN_DIAG_SUPPORT
128 hrtime_t sd_start_time
;
129 #endif /* SAN_DIAG_SUPPORT */
136 #define EMLXS_FCT_STATE_CHG(_fct_cmd, _cmd_sbp, _state) \
137 (_cmd_sbp)->fct_state = _state; \
138 emlxs_fct_io_trace((_cmd_sbp)->port, _fct_cmd, _state)
140 /* define to set fct_state */
141 #define EMLXS_FCT_STATE_CHG(_fct_cmd, _cmd_sbp, _state) \
142 (_cmd_sbp)->fct_state = _state
143 #endif /* FCT_IO_TRACE */
147 #define PACKET_IN_COMPLETION 0x00000001
148 #define PACKET_IN_TXQ 0x00000002
149 #define PACKET_IN_CHIPQ 0x00000004
150 #define PACKET_IN_DONEQ 0x00000008
152 #define PACKET_FCP_RESET 0x00000030
153 #define PACKET_FCP_TGT_RESET 0x00000010
154 #define PACKET_FCP_LUN_RESET 0x00000020
155 #define PACKET_POLLED 0x00000040
158 #define PACKET_FCP_SWAPPED 0x00000100
159 #define PACKET_ELS_SWAPPED 0x00000200
160 #define PACKET_CT_SWAPPED 0x00000400
161 #define PACKET_CSP_SWAPPED 0x00000800
162 #endif /* EMLXS_I386 */
164 #define PACKET_STALE 0x00001000
166 #define PACKET_IN_TIMEOUT 0x00010000
167 #define PACKET_IN_FLUSH 0x00020000
168 #define PACKET_IN_ABORT 0x00040000
169 #define PACKET_XRI_CLOSED 0x00080000 /* An XRI abort/close was issued */
171 #define PACKET_CHIP_COMP 0x00100000
172 #define PACKET_COMPLETED 0x00200000
173 #define PACKET_ULP_OWNED 0x00400000
175 #define PACKET_STATE_VALID 0x01000000
176 #define PACKET_FCP_RSP_VALID 0x02000000
177 #define PACKET_ELS_RSP_VALID 0x04000000
178 #define PACKET_CT_RSP_VALID 0x08000000
180 #define PACKET_DELAY_REQUIRED 0x10000000
181 #define PACKET_ALLOCATED 0x40000000
182 #define PACKET_VALID 0x80000000
185 #define STALE_PACKET ((emlxs_buf_t *)0xFFFFFFFF)
189 * From fc_error.h pkt_reason (except for state = NPORT_RJT, FABRIC_RJT,
190 * NPORT_BSY, FABRIC_BSY, LS_RJT, BA_RJT, FS_RJT)
192 * FCA unique error codes can begin after FC_REASON_FCA_UNIQUE.
193 * Each FCA defines its own set with values greater >= 0x7F
195 #define FC_REASON_FCA_DEFINED 0x100
199 * Device VPD save area
202 typedef struct emlxs_vpd
211 uint8_t feaLevelHigh
;
214 uint32_t postKernRev
;
215 char postKernName
[32];
223 char sli1FwLabel
[32];
227 char sli2FwLabel
[32];
231 char sli3FwLabel
[32];
235 char sli4FwLabel
[32];
240 char fcode_version
[32];
241 char boot_version
[32];
247 char manufacturer
[80];
249 char model_desc
[256];
250 char prog_types
[256];
258 typedef struct emlxs_queue
260 void *q_first
; /* queue first element */
261 void *q_last
; /* queue last element */
262 uint16_t q_cnt
; /* current length of queue */
263 uint16_t q_max
; /* max length queue can get */
265 typedef emlxs_queue_t Q
;
270 * This structure is used when allocating a buffer pool.
271 * Note: this should be identical to gasket buf_info (fldl.h).
273 typedef struct emlxs_buf_info
275 int32_t size
; /* Specifies the number of bytes to allocate. */
276 int32_t align
; /* The desired address boundary. */
280 #define FC_MBUF_DMA 0x01 /* blocks are for DMA */
281 #define FC_MBUF_PHYSONLY 0x02 /* For malloc - map a given virtual */
282 /* address to physical address (skip */
284 /* For free - just unmap the given */
285 /* physical address (skip the free). */
286 #define FC_MBUF_IOCTL 0x04 /* called from dfc_ioctl */
287 #define FC_MBUF_UNLOCK 0x08 /* called with driver unlocked */
288 #define FC_MBUF_SNGLSG 0x10 /* allocate a single contiguous */
289 /* physical memory */
290 #define FC_MBUF_DMA32 0x20
292 uint64_t phys
; /* specifies physical buffer pointer */
293 void *virt
; /* specifies virtual buffer pointer */
297 typedef emlxs_buf_info_t MBUF_INFO
;
300 #define EMLXS_MAX_HBQ 16 /* Max HBQs handled by firmware */
301 #define EMLXS_ELS_HBQ_ID 0
302 #define EMLXS_IP_HBQ_ID 1
303 #define EMLXS_CT_HBQ_ID 2
304 #define EMLXS_FCT_HBQ_ID 3
307 #define EMLXS_NUM_HBQ 4 /* Number of HBQs supported by driver */
309 #define EMLXS_NUM_HBQ 3 /* Number of HBQs supported by driver */
310 #endif /* SFCT_SUPPORT */
314 * An IO Channel is a object that comprises a xmit/cmpl
316 * For SLI3, an IO path maps to a ring (cmd/rsp)
317 * For SLI4, an IO path map to a queue pair (WQ/CQ)
319 typedef struct emlxs_channel
321 struct emlxs_hba
*hba
; /* ptr to hba for channel */
322 void *iopath
; /* ptr to SLI3/4 io path */
325 IOCBQ
*rsp_head
; /* deferred completion head */
326 IOCBQ
*rsp_tail
; /* deferred completion tail */
327 emlxs_thread_t intr_thread
;
333 #define EMLXS_NEEDS_TRIGGER 1
335 /* Protected by EMLXS_TX_CHANNEL_LOCK */
336 emlxs_queue_t nodeq
; /* Node service queue */
338 kmutex_t channel_cmd_lock
;
341 /* Channel command counters */
346 uint32_t hbaSendCmd_sbp
;
347 uint32_t hbaCmplCmd_sbp
;
350 typedef emlxs_channel_t CHANNEL
;
353 * Should be able to handle max number of io paths for a
354 * SLI4 HBA (EMLXS_MAX_WQS) or for a SLI3 HBA (MAX_RINGS)
356 #define MAX_CHANNEL EMLXS_MSI_MAX_INTRS
359 /* Structure used to access adapter rings */
360 typedef struct emlxs_ring
362 void *fc_cmdringaddr
; /* virtual offset for cmd */
364 void *fc_rspringaddr
; /* virtual offset for rsp */
367 void *fc_mpon
; /* index ptr for match */
369 void *fc_mpoff
; /* index ptr for match */
371 struct emlxs_hba
*hba
; /* ptr to hba for ring */
373 uint8_t fc_numCiocb
; /* number of command iocb's */
375 uint8_t fc_numRiocb
; /* number of response iocb's */
377 uint8_t fc_rspidx
; /* current index in response */
379 uint8_t fc_cmdidx
; /* current index in command */
381 uint8_t fc_port_rspidx
;
382 uint8_t fc_port_cmdidx
;
385 uint16_t fc_missbufcnt
; /* buf cnt we need to repost */
390 typedef emlxs_ring_t RING
;
393 #ifdef SAN_DIAG_SUPPORT
395 * Although right now it's just 1 field, SAN Diag anticipates that this
396 * structure will grow in the future.
398 typedef struct sd_timestat_level0
{
400 } sd_timestat_level0_t
;
403 typedef struct emlxs_node
405 struct emlxs_node
*nlp_list_next
;
406 struct emlxs_node
*nlp_list_prev
;
408 NAME_TYPE nlp_portname
; /* port name */
409 NAME_TYPE nlp_nodename
; /* node name */
411 uint32_t nlp_DID
; /* fibre channel D_ID */
413 uint16_t nlp_Rpi
; /* login id returned by */
415 uint16_t nlp_Xri
; /* login id returned by */
418 uint8_t nlp_fcp_info
; /* Remote class info */
421 #define NLP_FCP_TGT_DEVICE 0x10 /* FCP TGT device */
422 #define NLP_FCP_INI_DEVICE 0x20 /* FCP Initiator device */
423 #define NLP_FCP_2_DEVICE 0x40 /* FCP-2 TGT device */
424 #define NLP_EMLX_VPORT 0x80 /* Virtual port */
427 #define EMLXS_SET_DFC_STATE(_n, _state) if (_n && _n->nlp_active)\
428 {(_n)->dfc_state = (_state); }
430 uint32_t nlp_force_rscn
;
431 uint32_t nlp_tag
; /* Tag used by port_offline */
434 #define NODE_POOL_ALLOCATED 0x00000001
438 /* Protected by EMLXS_TX_CHANNEL_LOCK */
439 uint32_t nlp_active
; /* Node active flag */
441 uint32_t nlp_flag
[MAX_CHANNEL
]; /* Node level channel */
445 #define NLP_CLOSED 0x1
446 #define NLP_OFFLINE 0x2
447 #define NLP_RPI_XRI 0x4
449 uint32_t nlp_tics
[MAX_CHANNEL
]; /* gate timeout */
450 emlxs_queue_t nlp_tx
[MAX_CHANNEL
]; /* Transmit Q head */
451 emlxs_queue_t nlp_ptx
[MAX_CHANNEL
]; /* Priority transmit */
453 void *nlp_next
[MAX_CHANNEL
]; /* Service Request */
454 /* Queue pointer used */
455 /* when node needs */
457 #ifdef DHCHAP_SUPPORT
458 emlxs_node_dhc_t node_dhc
;
459 #endif /* DHCHAP_SUPPORT */
461 #ifdef SAN_DIAG_SUPPORT
462 sd_timestat_level0_t sd_dev_bucket
[SD_IO_LATENCY_MAX_BUCKETS
];
465 struct RPIobj
*rpip
; /* SLI4 only */
466 #define EMLXS_NODE_TO_RPI(_p, _n) \
467 ((_n)?((_n->rpip)?_n->rpip:emlxs_rpi_find(_p, _n->nlp_Rpi)):NULL)
469 #ifdef NODE_THROTTLE_SUPPORT
470 uint32_t io_throttle
;
472 #endif /* NODE_THROTTLE_SUPPORT */
475 typedef emlxs_node_t NODELIST
;
479 #define NADDR_LEN 6 /* MAC network address length */
480 typedef struct emlxs_fcip_nethdr
482 NAME_TYPE fc_destname
; /* destination port name */
483 NAME_TYPE fc_srcname
; /* source port name */
484 } emlxs_fcip_nethdr_t
;
485 typedef emlxs_fcip_nethdr_t NETHDR
;
488 #define MEM_NLP 0 /* memory segment to hold node list entries */
489 #define MEM_IOCB 1 /* memory segment to hold iocb commands */
490 #define MEM_MBOX 2 /* memory segment to hold mailbox cmds */
491 #define MEM_BPL 3 /* and to hold buffer ptr lists - SLI2 */
492 #define MEM_BUF 4 /* memory segment to hold buffer data */
493 #define MEM_ELSBUF 4 /* memory segment to hold buffer data */
494 #define MEM_IPBUF 5 /* memory segment to hold IP buffer data */
495 #define MEM_CTBUF 6 /* memory segment to hold CT buffer data */
496 #define MEM_FCTBUF 7 /* memory segment to hold FCT buffer data */
500 #define MEM_FCTSEG 10 /* must be greater than FC_MAX_SEG */
503 #endif /* SFCT_SUPPORT */
506 /* A BPL entry is 12 bytes. Subtract 2 for command and response buffers */
507 #define BPL_TO_SGLLEN(_bpl) ((_bpl/12)-2)
508 #define MEM_BPL_SIZE 36 /* Default size */
510 /* A SGL entry is 16 bytes. Subtract 2 for command and response buffers */
511 #define SGL_TO_SGLLEN(_sgl) ((_sgl/16)-2)
512 #define MEM_SGL_SIZE 4096 /* Default size */
514 #define MEM_BUF_SIZE 1024
515 #define MEM_BUF_COUNT 64
517 #define MEM_ELSBUF_SIZE MEM_BUF_SIZE
518 #define MEM_ELSBUF_COUNT hba->max_nodes
519 #define MEM_IPBUF_SIZE 65535
520 #define MEM_IPBUF_COUNT 60
521 #define MEM_CTBUF_SIZE MAX_CT_PAYLOAD /* (1024*320) */
522 #define MEM_CTBUF_COUNT 8
523 #define MEM_FCTBUF_SIZE 65535
524 #define MEM_FCTBUF_COUNT 128
526 typedef struct emlxs_memseg
533 uint32_t fc_total_memsize
;
534 uint32_t fc_memsize
; /* size of mem blks */
535 uint32_t fc_numblks
; /* no of mem blks */
536 uint32_t fc_memget_cnt
; /* no of mem get blks */
537 uint32_t fc_memput_cnt
; /* no of mem put blks */
538 uint32_t fc_memflag
; /* emlxs_buf_info_t FLAGS */
539 #define FC_MEMSEG_PUT_ENABLED 0x20000000
540 #define FC_MEMSEG_GET_ENABLED 0x40000000
541 #define FC_MEMSEG_DYNAMIC 0x80000000
543 uint32_t fc_memalign
;
547 uint32_t fc_hi_water
;
548 uint32_t fc_lo_water
;
549 uint32_t fc_step
; /* Dyn increment. Zero = static */
550 uint32_t fc_low
; /* Lowest free count (dyn only) */
551 uint32_t fc_last
; /* Last fc_numblks (dyn only) */
554 typedef emlxs_memseg_t MEMSEG
;
557 /* Board stat counters */
558 typedef struct emlxs_stats
563 uint32_t LinkMultiEvent
;
566 uint32_t MboxCompleted
; /* MboxError + MbxGood */
570 uint32_t MboxInvalid
;
572 uint32_t IocbIssued
[MAX_CHANNEL
];
573 uint32_t IocbReceived
[MAX_CHANNEL
];
574 uint32_t IocbTxPut
[MAX_CHANNEL
];
575 uint32_t IocbTxGet
[MAX_CHANNEL
];
576 uint32_t IocbRingFull
[MAX_CHANNEL
];
577 uint32_t IocbThrottled
;
579 uint32_t IntrEvent
[8];
582 uint32_t FcpCompleted
; /* FcpGood + FcpError */
586 uint32_t FcpEvent
; /* FcpStray + FcpCompleted */
589 uint32_t FctRingEvent
;
590 uint32_t FctRingError
;
591 uint32_t FctRingDropped
;
592 #endif /* SFCT_SUPPORT */
594 uint32_t ElsEvent
; /* ElsStray + ElsCmplt (cmd + rsp) */
597 uint32_t ElsCmdIssued
;
598 uint32_t ElsCmdCompleted
; /* ElsCmdGood + ElsCmdError */
600 uint32_t ElsCmdError
;
602 uint32_t ElsRspIssued
;
603 uint32_t ElsRspCompleted
;
605 uint32_t ElsRcvEvent
; /* ElsRcvErr + ElsRcvDrop + ElsCmdRcv */
606 uint32_t ElsRcvError
;
607 uint32_t ElsRcvDropped
;
608 uint32_t ElsCmdReceived
; /* ElsRscnRcv + ElsPlogiRcv + ... */
609 uint32_t ElsRscnReceived
;
610 uint32_t ElsFlogiReceived
;
611 uint32_t ElsPlogiReceived
;
612 uint32_t ElsPrliReceived
;
613 uint32_t ElsPrloReceived
;
614 uint32_t ElsLogoReceived
;
615 uint32_t ElsAdiscReceived
;
616 uint32_t ElsAuthReceived
;
617 uint32_t ElsGenReceived
;
619 uint32_t CtEvent
; /* CtStray + CtCompleted (cmd + rsp) */
622 uint32_t CtCmdIssued
;
623 uint32_t CtCmdCompleted
; /* CtCmdGood + CtCmdError */
627 uint32_t CtRspIssued
;
628 uint32_t CtRspCompleted
;
630 uint32_t CtRcvEvent
; /* CtRcvError + CtRcvDrop + CtCmdRcvd */
632 uint32_t CtRcvDropped
;
633 uint32_t CtCmdReceived
;
635 uint32_t IpEvent
; /* IpStray + IpSeqCmpl + IpBcastCmpl */
638 uint32_t IpSeqIssued
;
639 uint32_t IpSeqCompleted
; /* IpSeqGood + IpSeqError */
643 uint32_t IpBcastIssued
;
644 uint32_t IpBcastCompleted
; /* IpBcastGood + IpBcastError */
645 uint32_t IpBcastGood
;
646 uint32_t IpBcastError
;
648 uint32_t IpRcvEvent
; /* IpDrop + IpSeqRcv + IpBcastRcv */
650 uint32_t IpSeqReceived
;
651 uint32_t IpBcastReceived
;
654 uint32_t ElsUbPosted
;
657 uint32_t FctUbPosted
;
658 #endif /* SFCT_SUPPORT */
660 uint32_t ResetTime
; /* Time of last reset */
662 uint32_t ElsTestReceived
;
663 uint32_t ElsEstcReceived
;
664 uint32_t ElsFarprReceived
;
665 uint32_t ElsEchoReceived
;
666 uint32_t ElsRlsReceived
;
667 uint32_t ElsRtvReceived
;
672 #define FC_MAX_ADPTMSG (8*28) /* max size of a msg from adapter */
674 #define EMLXS_NUM_THREADS 8
675 #define EMLXS_MIN_TASKS 8
676 #define EMLXS_MAX_TASKS 8
678 #define EMLXS_NUM_HASH_QUES 32
679 #define EMLXS_DID_HASH(x) ((x) & (EMLXS_NUM_HASH_QUES - 1))
683 #define FC_TRAN_COMPLETED 0x8000
686 typedef struct emlxs_dfc_event
698 typedef struct emlxs_hba_event
708 #define TGTPORTSTAT port->fct_stat
711 * FctP2IOXcnt will count IOs by their fcpDL. Counters
712 * are for buckets of various power of 2 sizes.
714 * Bucket 1 >= 512 < 1024
715 * Bucket 2 >= 1024 < 2048
716 * Bucket 3 >= 2048 < 4096
717 * Bucket 4 >= 4096 < 8192
718 * Bucket 5 >= 8192 < 16K
719 * Bucket 6 >= 16K < 32K
720 * Bucket 7 >= 32K < 64K
721 * Bucket 8 >= 64K < 128K
722 * Bucket 9 >= 128K < 256K
723 * Bucket 10 >= 256K < 512K
724 * Bucket 11 >= 512K < 1MB
725 * Bucket 12 >= 1MB < 2MB
726 * Bucket 13 >= 2MB < 4MB
727 * Bucket 14 >= 4MB < 8MB
730 #define MAX_TGTPORT_IOCNT 16
734 * These routines will bump the right counter, based on
735 * the size of the IO inputed, with the least number of
736 * comparisions. A max of 5 comparisions is only needed
737 * to classify the IO in one of 16 ranges. A binary search
738 * to locate the high bit in the size is used.
740 #define EMLXS_BUMP_RDIOCTR(port, cnt) \
742 /* Use binary search to find the first high bit */ \
743 if (cnt & 0xffff0000) { \
744 if (cnt & 0xff800000) { \
745 TGTPORTSTAT.FctP2IORcnt[15]++; \
748 /* It must be 0x007f0000 */ \
749 if (cnt & 0x00700000) { \
750 if (cnt & 0x00400000) { \
751 TGTPORTSTAT.FctP2IORcnt[14]++; \
754 /* it must be 0x00300000 */ \
755 if (cnt & 0x00200000) { \
756 TGTPORTSTAT.FctP2IORcnt[13]++; \
759 /* It must be 0x00100000 */ \
760 TGTPORTSTAT.FctP2IORcnt[12]++; \
765 /* It must be 0x000f0000 */ \
766 if (cnt & 0x000c0000) { \
767 if (cnt & 0x00080000) { \
768 TGTPORTSTAT.FctP2IORcnt[11]++; \
771 /* It must be 0x00040000 */ \
772 TGTPORTSTAT.FctP2IORcnt[10]++; \
776 /* It must be 0x00030000 */ \
777 if (cnt & 0x00020000) { \
778 TGTPORTSTAT.FctP2IORcnt[9]++; \
781 /* It must be 0x00010000 */ \
782 TGTPORTSTAT.FctP2IORcnt[8]++; \
789 if (cnt & 0x0000fe00) { \
790 if (cnt & 0x0000f000) { \
791 if (cnt & 0x0000c000) { \
792 if (cnt & 0x00008000) { \
793 TGTPORTSTAT.FctP2IORcnt[7]++; \
796 /* It must be 0x00004000 */ \
797 TGTPORTSTAT.FctP2IORcnt[6]++; \
801 /* It must be 0x00000300 */ \
802 if (cnt & 0x00000200) { \
803 TGTPORTSTAT.FctP2IORcnt[5]++; \
806 /* It must be 0x00000100 */ \
807 TGTPORTSTAT.FctP2IORcnt[4]++; \
812 /* It must be 0x00000e00 */ \
813 if (cnt & 0x00000800) { \
814 TGTPORTSTAT.FctP2IORcnt[3]++; \
817 /* It must be 0x00000600 */ \
818 if (cnt & 0x00000400) { \
819 TGTPORTSTAT.FctP2IORcnt[2]++; \
822 /* It must be 0x00000200 */ \
823 TGTPORTSTAT.FctP2IORcnt[1]++; \
829 /* It must be 0x000001ff */ \
830 TGTPORTSTAT.FctP2IORcnt[0]++; \
836 #define EMLXS_BUMP_WRIOCTR(port, cnt) \
838 /* Use binary search to find the first high bit */ \
839 if (cnt & 0xffff0000) { \
840 if (cnt & 0xff800000) { \
841 TGTPORTSTAT.FctP2IOWcnt[15]++; \
844 /* It must be 0x007f0000 */ \
845 if (cnt & 0x00700000) { \
846 if (cnt & 0x00400000) { \
847 TGTPORTSTAT.FctP2IOWcnt[14]++; \
850 /* It must be 0x00300000 */ \
851 if (cnt & 0x00200000) { \
852 TGTPORTSTAT.FctP2IOWcnt[13]++; \
855 /* It must be 0x00100000 */ \
856 TGTPORTSTAT.FctP2IOWcnt[12]++; \
861 /* It must be 0x000f0000 */ \
862 if (cnt & 0x000c0000) { \
863 if (cnt & 0x00080000) { \
864 TGTPORTSTAT.FctP2IOWcnt[11]++; \
867 /* it must be 0x00040000 */ \
868 TGTPORTSTAT.FctP2IOWcnt[10]++; \
872 /* It must be 0x00030000 */ \
873 if (cnt & 0x00020000) { \
874 TGTPORTSTAT.FctP2IOWcnt[9]++; \
877 /* It must be 0x00010000 */ \
878 TGTPORTSTAT.FctP2IOWcnt[8]++; \
885 if (cnt & 0x0000fe00) { \
886 if (cnt & 0x0000f000) { \
887 if (cnt & 0x0000c000) { \
888 if (cnt & 0x00008000) { \
889 TGTPORTSTAT.FctP2IOWcnt[7]++; \
892 /* It must be 0x00004000 */ \
893 TGTPORTSTAT.FctP2IOWcnt[6]++; \
897 /* It must be 0x00000300 */ \
898 if (cnt & 0x00000200) { \
899 TGTPORTSTAT.FctP2IOWcnt[5]++; \
902 /* It must be 0x00000100 */ \
903 TGTPORTSTAT.FctP2IOWcnt[4]++; \
908 /* It must be 0x00000e00 */ \
909 if (cnt & 0x00000800) { \
910 TGTPORTSTAT.FctP2IOWcnt[3]++; \
913 /* It must be 0x00000600 */ \
914 if (cnt & 0x00000400) { \
915 TGTPORTSTAT.FctP2IOWcnt[2]++; \
918 /* It must be 0x00000200 */ \
919 TGTPORTSTAT.FctP2IOWcnt[1]++; \
925 /* It must be 0x000001ff */ \
926 TGTPORTSTAT.FctP2IOWcnt[0]++; \
931 typedef struct emlxs_tgtport_stat
934 uint64_t FctP2IOWcnt
[MAX_TGTPORT_IOCNT
]; /* Writes */
935 uint64_t FctP2IORcnt
[MAX_TGTPORT_IOCNT
]; /* Reads */
936 uint64_t FctIOCmdCnt
; /* Other, ie TUR */
937 uint64_t FctCmdReceived
; /* total IOs */
938 uint64_t FctReadBytes
; /* total read bytes */
939 uint64_t FctWriteBytes
; /* total write bytes */
941 /* IOCB handling counters */
942 uint64_t FctEvent
; /* FctStray + FctCompleted */
943 uint64_t FctCompleted
; /* FctCmplGood + FctCmplError */
944 uint64_t FctCmplGood
;
946 uint32_t FctCmplError
;
949 /* Fct event counters */
950 uint32_t FctRcvDropped
;
951 uint32_t FctOverQDepth
;
952 uint32_t FctOutstandingIO
;
953 uint32_t FctFailedPortRegister
;
954 uint32_t FctPortRegister
;
955 uint32_t FctPortDeregister
;
957 uint32_t FctAbortSent
;
958 uint32_t FctNoBuffer
;
959 uint32_t FctScsiStatusErr
;
960 uint32_t FctScsiQfullErr
;
961 uint32_t FctScsiResidOver
;
962 uint32_t FctScsiResidUnder
;
963 uint32_t FctScsiSenseErr
;
966 } emlxs_tgtport_stat_t
;
969 #define MAX_IO_TRACE 67
970 typedef struct emlxs_iotrace
974 uint8_t marker
; /* 0xff */
975 uint8_t trc
[MAX_IO_TRACE
]; /* trc[0] = index */
977 #endif /* FCT_IO_TRACE */
978 #endif /* SFCT_SUPPORT */
981 #include <emlxs_fcf.h>
984 * Port Information Data Structure
987 typedef struct emlxs_port
989 struct emlxs_hba
*hba
;
991 /* Virtual port management */
992 struct VPIobj VPIobj
;
993 struct VPIobj
*vpip
; /* &VPIobj */
995 uint32_t vpi
; /* Legacy vpi == vpip->index */
997 uint32_t mode_mask
; /* User configured */
998 #define MODE_NONE 0x00000000
999 #define MODE_INITIATOR 0x00000001
1000 #define MODE_TARGET 0x00000002
1001 #define MODE_ALL 0x00000003
1004 #define EMLXS_PORT_ENABLED 0x00000001 /* vport setting */
1005 #define EMLXS_PORT_CONFIG 0x00000002 /* vport setting */
1007 #define EMLXS_INI_ENABLED 0x00000010 /* emlxs_mode_init */
1008 #define EMLXS_INI_BOUND 0x00000020 /* emlxs_fca_bind_port */
1009 #define EMLXS_TGT_ENABLED 0x00000040 /* emlxs_mode_init */
1010 #define EMLXS_TGT_BOUND 0x00000080 /* emlxs_fct_bind_port */
1011 #define EMLXS_PORT_BOUND (EMLXS_INI_BOUND|EMLXS_TGT_BOUND)
1013 #define EMLXS_PORT_IP_UP 0x00000100
1014 #define EMLXS_PORT_RESTRICTED 0x00000200 /* Restrict logins */
1016 #define EMLXS_PORT_REG_VPI 0x00010000 /* SLI3 */
1017 #define EMLXS_PORT_REG_VPI_CMPL 0x00020000 /* SLI3 */
1019 #define EMLXS_PORT_FLOGI_CMPL 0x01000000 /* Fabric login */
1022 #define EMLXS_PORT_RESET_MASK 0x0000FFFF /* Flags to keep */
1023 /* across hard reset */
1024 #define EMLXS_PORT_LINKDOWN_MASK 0x00FFFFFF /* Flags to keep */
1025 /* across link reset */
1028 #define EMLXS_OPT_RESTRICT 0x00000001 /* Force restricted */
1030 #define EMLXS_OPT_UNRESTRICT 0x00000002 /* Force Unrestricted */
1032 #define EMLXS_OPT_RESTRICT_MASK 0x00000003
1035 /* FC world wide names */
1041 /* Common service paramters */
1043 SERV_PARM fabric_sparam
;
1044 SERV_PARM prev_fabric_sparam
;
1046 /* fc_id management */
1050 /* support FC_PORT_GET_P2P_INFO only */
1053 /* FC_AL management */
1055 uint8_t granted_alpa
;
1056 uint8_t alpa_map
[128];
1058 /* Node management */
1059 emlxs_node_t node_base
;
1060 uint32_t node_count
;
1061 krwlock_t node_rwlock
;
1062 emlxs_node_t
*node_table
[EMLXS_NUM_HASH_QUES
];
1064 /* Polled packet management */
1065 kcondvar_t pkt_lock_cv
; /* pkt polling */
1066 kmutex_t pkt_lock
; /* pkt polling */
1070 uint32_t ulp_statec
;
1071 void (*ulp_statec_cb
) (); /* Port state change */
1072 /* callback routine */
1073 void (*ulp_unsol_cb
) (); /* unsolicited event */
1074 /* callback routine */
1075 opaque_t ulp_handle
;
1077 /* ULP unsolicited buffers */
1080 emlxs_unsol_buf_t
*ub_pool
;
1081 uint32_t ub_post
[MAX_CHANNEL
];
1084 emlxs_ub_priv_t
*ub_wait_head
; /* Unsolicited IO received */
1085 /* before link up */
1086 emlxs_ub_priv_t
*ub_wait_tail
; /* Unsolicited IO received */
1087 /* before link up */
1089 #ifdef DHCHAP_SUPPORT
1090 emlxs_port_dhc_t port_dhc
;
1091 #endif /* DHCHAP_SUPPORT */
1094 emlxs_memseg_t
*fct_memseg
; /* Array */
1095 uint32_t fct_memseg_cnt
;
1097 /* Default buffer counts */
1098 #define FCT_BUF_COUNT_2K 16
1099 #define FCT_BUF_COUNT_4K 0
1100 #define FCT_BUF_COUNT_8K 16
1101 #define FCT_BUF_COUNT_16K 0
1102 #define FCT_BUF_COUNT_32K 0
1103 #define FCT_BUF_COUNT_64K 16
1104 #define FCT_BUF_COUNT_128K 16
1105 #define FCT_BUF_COUNT_256K 0
1108 stmf_port_provider_t
*port_provider
;
1109 fct_local_port_t
*fct_port
;
1110 uint8_t fct_els_only_bmap
;
1113 #define FCT_STATE_PORT_ONLINE 0x00000001
1114 #define FCT_STATE_NOT_ACKED 0x00000002
1115 #define FCT_STATE_LINK_UP 0x00000010
1116 #define FCT_STATE_LINK_UP_ACKED 0x00000020
1117 #define FCT_STATE_FLOGI_CMPL 0x00000040
1119 emlxs_tgtport_stat_t fct_stat
;
1121 /* Used to save fct_cmd for deferred unsol ELS commands, except FLOGI */
1122 emlxs_buf_t
*fct_wait_head
;
1123 emlxs_buf_t
*fct_wait_tail
;
1125 /* Used to save context for deferred unsol FLOGIs */
1126 fct_flogi_xchg_t fx
;
1129 emlxs_iotrace_t
*iotrace
;
1130 uint16_t iotrace_cnt
;
1131 uint16_t iotrace_index
;
1132 kmutex_t iotrace_mtx
;
1133 #endif /* FCT_IO_TRACE */
1135 #endif /* SFCT_SUPPORT */
1137 uint32_t clean_address_timer
;
1138 emlxs_buf_t
*clean_address_sbp
;
1140 #ifdef SAN_DIAG_SUPPORT
1141 uint8_t sd_io_latency_state
;
1142 #define SD_INVALID 0x00
1143 #define SD_COLLECTING 0x01
1144 #define SD_STOPPED 0x02
1146 /* SD event management list */
1147 uint32_t sd_event_mask
; /* bit-mask */
1148 emlxs_dfc_event_t sd_events
[MAX_DFC_EVENTS
];
1155 #define FC_HA_REG(_hba) ((volatile uint32_t *) \
1156 ((_hba)->sli.sli3.ha_reg_addr))
1159 #define FC_CA_REG(_hba) ((volatile uint32_t *) \
1160 ((_hba)->sli.sli3.ca_reg_addr))
1162 /* Host Status reg */
1163 #define FC_HS_REG(_hba) ((volatile uint32_t *) \
1164 ((_hba)->sli.sli3.hs_reg_addr))
1167 #define FC_HC_REG(_hba) ((volatile uint32_t *) \
1168 ((_hba)->sli.sli3.hc_reg_addr))
1170 /* BIU Configuration reg */
1171 #define FC_BC_REG(_hba) ((volatile uint32_t *) \
1172 ((_hba)->sli.sli3.bc_reg_addr))
1174 /* Used by SBUS adapter */
1175 /* TITAN Cntl reg */
1176 #define FC_SHC_REG(_hba) ((volatile uint32_t *) \
1177 ((_hba)->sli.sli3.shc_reg_addr))
1179 /* TITAN Status reg */
1180 #define FC_SHS_REG(_hba) ((volatile uint32_t *) \
1181 ((_hba)->sli.sli3.shs_reg_addr))
1183 /* TITAN Update reg */
1184 #define FC_SHU_REG(_hba) ((volatile uint32_t *) \
1185 ((_hba)->sli.sli3.shu_reg_addr))
1187 /* MPU Semaphore reg */
1188 #define FC_SEMA_REG(_hba) ((volatile uint32_t *)\
1189 ((_hba)->sli.sli4.MPUEPSemaphore_reg_addr))
1191 /* Bootstrap Mailbox Doorbell reg */
1192 #define FC_MBDB_REG(_hba) ((volatile uint32_t *) \
1193 ((_hba)->sli.sli4.MBDB_reg_addr))
1195 /* MQ Doorbell reg */
1196 #define FC_MQDB_REG(_hba) ((volatile uint32_t *) \
1197 ((_hba)->sli.sli4.MQDB_reg_addr))
1199 /* CQ Doorbell reg */
1200 #define FC_CQDB_REG(_hba) ((volatile uint32_t *) \
1201 ((_hba)->sli.sli4.CQDB_reg_addr))
1203 /* WQ Doorbell reg */
1204 #define FC_WQDB_REG(_hba) ((volatile uint32_t *) \
1205 ((_hba)->sli.sli4.WQDB_reg_addr))
1207 /* RQ Doorbell reg */
1208 #define FC_RQDB_REG(_hba) ((volatile uint32_t *) \
1209 ((_hba)->sli.sli4.RQDB_reg_addr))
1212 #define FC_SLIM2_MAILBOX(_hba) ((MAILBOX *)(_hba)->sli.sli3.slim2.virt)
1214 #define FC_SLIM1_MAILBOX(_hba) ((MAILBOX *)(_hba)->sli.sli3.slim_addr)
1216 #define FC_MAILBOX(_hba) (((_hba)->flag & FC_SLIM2_MODE) ? \
1217 FC_SLIM2_MAILBOX(_hba) : FC_SLIM1_MAILBOX(_hba))
1219 #define WRITE_CSR_REG(_hba, _regp, _value) ddi_put32(\
1220 (_hba)->sli.sli3.csr_acc_handle, (uint32_t *)(_regp), \
1223 #define READ_CSR_REG(_hba, _regp) ddi_get32(\
1224 (_hba)->sli.sli3.csr_acc_handle, (uint32_t *)(_regp))
1226 #define WRITE_SLIM_ADDR(_hba, _regp, _value) ddi_put32(\
1227 (_hba)->sli.sli3.slim_acc_handle, (uint32_t *)(_regp), \
1230 #define READ_SLIM_ADDR(_hba, _regp) ddi_get32(\
1231 (_hba)->sli.sli3.slim_acc_handle, (uint32_t *)(_regp))
1233 #define WRITE_SLIM_COPY(_hba, _bufp, _slimp, _wcnt) ddi_rep_put32(\
1234 (_hba)->sli.sli3.slim_acc_handle, (uint32_t *)(_bufp), \
1235 (uint32_t *)(_slimp), (_wcnt), DDI_DEV_AUTOINCR)
1237 #define READ_SLIM_COPY(_hba, _bufp, _slimp, _wcnt) ddi_rep_get32(\
1238 (_hba)->sli.sli3.slim_acc_handle, (uint32_t *)(_bufp), \
1239 (uint32_t *)(_slimp), (_wcnt), DDI_DEV_AUTOINCR)
1241 /* Used by SBUS adapter */
1242 #define WRITE_SBUS_CSR_REG(_hba, _regp, _value) ddi_put32(\
1243 (_hba)->sli.sli3.sbus_csr_handle, (uint32_t *)(_regp), \
1246 #define READ_SBUS_CSR_REG(_hba, _regp) ddi_get32(\
1247 (_hba)->sli.sli3.sbus_csr_handle, (uint32_t *)(_regp))
1249 #define SBUS_WRITE_FLASH_COPY(_hba, _offset, _value) ddi_put8(\
1250 (_hba)->sli.sli3.sbus_flash_acc_handle, \
1251 (uint8_t *)((volatile uint8_t *)(_hba)->sli.sli3.sbus_flash_addr + \
1252 (_offset)), (uint8_t)(_value))
1254 #define SBUS_READ_FLASH_COPY(_hba, _offset) ddi_get8(\
1255 (_hba)->sli.sli3.sbus_flash_acc_handle, \
1256 (uint8_t *)((volatile uint8_t *)(_hba)->sli.sli3.sbus_flash_addr + \
1259 /* SLI4 registers */
1260 #define WRITE_BAR0_REG(_hba, _regp, _value) ddi_put32(\
1261 (_hba)->sli.sli4.bar0_acc_handle, (uint32_t *)(_regp), \
1264 #define READ_BAR0_REG(_hba, _regp) ddi_get32(\
1265 (_hba)->sli.sli4.bar0_acc_handle, (uint32_t *)(_regp))
1267 #define WRITE_BAR1_REG(_hba, _regp, _value) ddi_put32(\
1268 (_hba)->sli.sli4.bar1_acc_handle, (uint32_t *)(_regp), \
1271 #define READ_BAR1_REG(_hba, _regp) ddi_get32(\
1272 (_hba)->sli.sli4.bar1_acc_handle, (uint32_t *)(_regp))
1274 #define WRITE_BAR2_REG(_hba, _regp, _value) ddi_put32(\
1275 (_hba)->sli.sli4.bar2_acc_handle, (uint32_t *)(_regp), \
1278 #define READ_BAR2_REG(_hba, _regp) ddi_get32(\
1279 (_hba)->sli.sli4.bar2_acc_handle, (uint32_t *)(_regp))
1282 #define EMLXS_STATE_CHANGE(_hba, _state)\
1284 mutex_enter(&EMLXS_PORT_LOCK); \
1285 EMLXS_STATE_CHANGE_LOCKED((_hba), (_state)); \
1286 mutex_exit(&EMLXS_PORT_LOCK); \
1289 /* Used when EMLXS_PORT_LOCK is already held */
1290 #define EMLXS_STATE_CHANGE_LOCKED(_hba, _state) \
1292 if ((_hba)->state != (_state)) \
1294 uint32_t _st = _state; \
1295 EMLXS_MSGF(EMLXS_CONTEXT, \
1296 &emlxs_state_msg, "%s --> %s", \
1297 emlxs_ffstate_xlate((_hba)->state), \
1298 emlxs_ffstate_xlate(_state)); \
1299 (_hba)->state = (_state); \
1300 if ((_st) == FC_ERROR) \
1302 (_hba)->flag |= FC_HARDWARE_ERROR; \
1308 #define EMLXS_CHK_ACC_HANDLE(_hba, _acc) \
1309 if (emlxs_fm_check_acc_handle(_hba, _acc) != DDI_FM_OK) { \
1310 EMLXS_MSGF(EMLXS_CONTEXT, \
1311 &emlxs_invalid_access_handle_msg, NULL); \
1313 #endif /* FMA_SUPPORT */
1316 * This is the HBA control area for the adapter
1319 #ifdef MODSYM_SUPPORT
1321 typedef struct emlxs_modsym
1323 ddi_modhandle_t mod_fctl
; /* For Leadville */
1325 /* Leadville (fctl) */
1326 int (*fc_fca_attach
)(dev_info_t
*, fc_fca_tran_t
*);
1327 int (*fc_fca_detach
)(dev_info_t
*);
1328 int (*fc_fca_init
)(struct dev_ops
*);
1331 uint32_t fct_modopen
;
1332 uint32_t reserved
; /* Padding for alignment */
1334 ddi_modhandle_t mod_fct
; /* For Comstar */
1335 ddi_modhandle_t mod_stmf
; /* For Comstar */
1338 void* (*fct_alloc
)(fct_struct_id_t
, int, int);
1339 void (*fct_free
)(void *);
1340 void* (*fct_scsi_task_alloc
)(void *, uint16_t, uint32_t, uint8_t *,
1341 uint16_t, uint16_t);
1342 int (*fct_register_local_port
)(fct_local_port_t
*);
1343 void (*fct_deregister_local_port
)(fct_local_port_t
*);
1344 void (*fct_handle_event
)(fct_local_port_t
*, int, uint32_t, caddr_t
);
1345 void (*fct_post_rcvd_cmd
)(fct_cmd_t
*, stmf_data_buf_t
*);
1346 void (*fct_ctl
)(void *, int, void *);
1347 void (*fct_queue_cmd_for_termination
)(fct_cmd_t
*, fct_status_t
);
1348 void (*fct_send_response_done
)(fct_cmd_t
*, fct_status_t
, uint32_t);
1349 void (*fct_send_cmd_done
)(fct_cmd_t
*, fct_status_t
, uint32_t);
1350 void (*fct_scsi_data_xfer_done
)(fct_cmd_t
*, stmf_data_buf_t
*,
1352 fct_status_t (*fct_port_shutdown
)
1353 (fct_local_port_t
*, uint32_t, char *);
1354 fct_status_t (*fct_port_initialize
)
1355 (fct_local_port_t
*, uint32_t, char *);
1356 void (*fct_cmd_fca_aborted
)
1357 (fct_cmd_t
*, fct_status_t
, int);
1358 fct_status_t (*fct_handle_rcvd_flogi
)
1359 (fct_local_port_t
*, fct_flogi_xchg_t
*);
1361 /* Comstar (stmf) */
1362 void* (*stmf_alloc
)(stmf_struct_id_t
, int, int);
1363 void (*stmf_free
)(void *);
1364 void (*stmf_deregister_port_provider
) (stmf_port_provider_t
*);
1365 int (*stmf_register_port_provider
) (stmf_port_provider_t
*);
1366 #endif /* SFCT_SUPPORT */
1368 extern emlxs_modsym_t emlxs_modsym
;
1370 #define MODSYM(_f) emlxs_modsym._f
1374 #define MODSYM(_f) _f
1376 #endif /* MODSYM_SUPPORT */
1380 typedef struct RPIHdrTmplate
1382 uint32_t Word
[16]; /* 64 bytes */
1386 typedef struct EQ_DESC
1388 uint16_t host_index
;
1391 uint16_t msix_vector
;
1392 kmutex_t lastwq_lock
;
1403 typedef struct CQ_DESC
1405 uint16_t host_index
;
1410 #define EMLXS_CQ_TYPE_GROUP1 1 /* associated with a MQ and async events */
1411 #define EMLXS_CQ_TYPE_GROUP2 2 /* associated with a WQ and RQ */
1415 CHANNEL
*channelp
; /* ptr to CHANNEL associated with CQ */
1424 typedef struct WQ_DESC
1426 uint16_t host_index
;
1428 uint16_t port_index
;
1429 uint16_t release_depth
;
1430 #define WQE_RELEASE_DEPTH (8 * EMLXS_NUM_WQ_PAGES)
1441 typedef struct RQ_DESC
1443 uint16_t host_index
;
1449 MBUF_INFO rqb
[RQ_DEPTH
];
1458 typedef struct RXQ_DESC
1461 emlxs_queue_t active
;
1466 typedef struct MQ_DESC
1468 uint16_t host_index
;
1476 /* Define the number of queues the driver will be using */
1477 #define EMLXS_MAX_EQS EMLXS_MSI_MAX_INTRS
1478 #define EMLXS_MAX_WQS EMLXS_MAX_WQS_PER_EQ * EMLXS_MAX_EQS
1479 #define EMLXS_MAX_RQS 2 /* ONLY 1 pair is allowed */
1480 #define EMLXS_MAX_MQS 1
1482 /* One CQ for each WQ & (RQ pair) plus one for the MQ */
1483 #define EMLXS_MAX_CQS (EMLXS_MAX_WQS + (EMLXS_MAX_RQS/2) + 1)
1485 /* The First CQ created is ALWAYS for mbox / event handling */
1486 #define EMLXS_CQ_MBOX 0
1488 /* The Second CQ created is ALWAYS for unsol rcv handling */
1489 /* At this time we are allowing ONLY 1 pair of RQs */
1490 #define EMLXS_CQ_RCV 1
1492 /* The remaining CQs are for WQ completions */
1493 #define EMLXS_CQ_OFFSET_WQ 2
1496 /* FCFI RQ Configuration */
1497 #define EMLXS_FCFI_RQ0_INDEX 0
1498 #define EMLXS_FCFI_RQ0_RMASK 0 /* match all */
1499 #define EMLXS_FCFI_RQ0_RCTL 0 /* match all */
1500 #define EMLXS_FCFI_RQ0_TMASK 0 /* match all */
1501 #define EMLXS_FCFI_RQ0_TYPE 0 /* match all */
1503 #define EMLXS_RXQ_ELS 0
1504 #define EMLXS_RXQ_CT 1
1505 #define EMLXS_MAX_RXQS 2
1507 #define PCI_CONFIG_SIZE 0x80
1509 typedef struct emlxs_sli3
1511 /* SLIM management */
1514 /* HBQ management */
1515 uint32_t hbq_count
; /* Total number of HBQs */
1517 HBQ_INIT_t hbq_table
[EMLXS_NUM_HBQ
];
1519 /* Adapter memory management */
1522 ddi_acc_handle_t csr_acc_handle
;
1523 ddi_acc_handle_t slim_acc_handle
;
1525 /* SBUS adapter management */
1526 caddr_t sbus_flash_addr
; /* Virt addr of R/W */
1528 caddr_t sbus_core_addr
; /* Virt addr of TITAN */
1530 caddr_t sbus_csr_addr
; /* Virt addr of TITAN */
1532 ddi_acc_handle_t sbus_flash_acc_handle
;
1533 ddi_acc_handle_t sbus_core_acc_handle
;
1534 ddi_acc_handle_t sbus_csr_handle
;
1536 /* SLI 2/3 Adapter register management */
1537 uint32_t *bc_reg_addr
; /* virtual offset for BIU */
1539 uint32_t *ha_reg_addr
; /* virtual offset for host */
1541 uint32_t *hc_reg_addr
; /* virtual offset for host */
1543 uint32_t *ca_reg_addr
; /* virtual offset for FF */
1545 uint32_t *hs_reg_addr
; /* virtual offset for */
1547 uint32_t *shc_reg_addr
; /* virtual offset for SBUS */
1549 uint32_t *shs_reg_addr
; /* virtual offset for SBUS */
1551 uint32_t *shu_reg_addr
; /* virtual offset for SBUS */
1553 uint16_t hgp_ring_offset
;
1554 uint16_t hgp_hbq_offset
;
1555 uint16_t iocb_cmd_size
;
1556 uint16_t iocb_rsp_size
;
1557 uint32_t hc_copy
; /* local copy of HC register */
1559 /* Ring management */
1560 uint32_t ring_count
;
1561 emlxs_ring_t ring
[MAX_RINGS
];
1562 kmutex_t ring_cmd_lock
[MAX_RINGS
];
1563 uint8_t ring_masks
[4]; /* number of masks/rings used */
1564 uint8_t ring_rval
[6];
1565 uint8_t ring_rmask
[6];
1566 uint8_t ring_tval
[6];
1567 uint8_t ring_tmask
[6];
1569 /* Protected by EMLXS_FCTAB_LOCK */
1570 MATCHMAP
**bpl_table
; /* iotag table for */
1572 uint32_t mem_bpl_size
;
1575 typedef struct emlxs_sli4
1577 MATCHMAP bootstrapmb
;
1581 ddi_acc_handle_t bar0_acc_handle
;
1582 ddi_acc_handle_t bar1_acc_handle
;
1583 ddi_acc_handle_t bar2_acc_handle
;
1585 /* SLI4 Adapter register management */
1586 uint32_t *MPUEPSemaphore_reg_addr
;
1587 uint32_t *MBDB_reg_addr
;
1589 uint32_t *CQDB_reg_addr
;
1590 uint32_t *MQDB_reg_addr
;
1591 uint32_t *WQDB_reg_addr
;
1592 uint32_t *RQDB_reg_addr
;
1593 uint32_t *SEMA_reg_addr
;
1594 uint32_t *STATUS_reg_addr
;
1595 uint32_t *CNTL_reg_addr
;
1596 uint32_t *ERR1_reg_addr
;
1597 uint32_t *ERR2_reg_addr
;
1598 uint32_t *PHYSDEV_reg_addr
;
1601 #define EMLXS_SLI4_INTR_ENABLED 0x00000001
1602 #define EMLXS_SLI4_HW_ERROR 0x00000002
1603 #define EMLXS_SLI4_DOWN_LINK 0x00000004
1604 #define EMLXS_SLI4_PHON 0x00000008
1605 #define EMLXS_SLI4_PHWQ 0x00000010
1606 #define EMLXS_SLI4_NULL_XRI 0x00000020
1608 #define EMLXS_SLI4_FCF_INIT 0x10000000
1609 #define EMLXS_SLI4_FCOE_MODE 0x80000000
1611 #define SLI4_FCOE_MODE (hba->sli.sli4.flag & EMLXS_SLI4_FCOE_MODE)
1612 #define SLI4_FC_MODE (!SLI4_FCOE_MODE)
1617 uint16_t XRIExtCount
;
1618 uint16_t XRIExtSize
;
1619 uint16_t XRIBase
[MAX_EXTENTS
];
1622 uint16_t RPIExtCount
;
1623 uint16_t RPIExtSize
;
1624 uint16_t RPIBase
[MAX_EXTENTS
];
1627 uint16_t VPIExtCount
;
1628 uint16_t VPIExtSize
;
1629 uint16_t VPIBase
[MAX_EXTENTS
];
1632 uint16_t VFIExtCount
;
1633 uint16_t VFIExtSize
;
1634 uint16_t VFIBase
[MAX_EXTENTS
];
1640 VFIobj_t
*VFI_table
;
1642 /* Save Config Region 23 info */
1644 tlv_fcfconnectlist_t cfgFCF
;
1647 MBUF_INFO dump_region
;
1648 #define EMLXS_DUMP_REGION_SIZE 1024
1651 MBUF_INFO HeaderTmplate
;
1654 /* Double linked list for available XRIs */
1655 XRIobj_t
*XRIfree_f
;
1656 XRIobj_t
*XRIfree_b
;
1657 uint32_t xrif_count
;
1658 uint32_t mem_sgl_size
;
1660 /* Double linked list for XRIs in use */
1661 XRIobj_t
*XRIinuse_f
;
1662 XRIobj_t
*XRIinuse_b
;
1663 uint32_t xria_count
;
1665 kmutex_t que_lock
[EMLXS_MAX_WQS
];
1666 EQ_DESC_t eq
[EMLXS_MAX_EQS
];
1667 CQ_DESC_t cq
[EMLXS_MAX_CQS
];
1668 WQ_DESC_t wq
[EMLXS_MAX_WQS
];
1669 RQ_DESC_t rq
[EMLXS_MAX_RQS
];
1670 RXQ_DESC_t rxq
[EMLXS_MAX_RXQS
];
1672 uint32_t que_stat_timer
;
1674 uint32_t ue_mask_lo
;
1675 uint32_t ue_mask_hi
;
1679 uint8_t port_name
[4];
1680 uint32_t link_number
;
1685 typedef struct emlxs_sli_api
1687 int (*sli_map_hdw
)();
1688 void (*sli_unmap_hdw
)();
1689 int32_t (*sli_online
)();
1690 void (*sli_offline
)();
1691 uint32_t (*sli_hba_reset
)();
1692 void (*sli_hba_kill
)();
1693 void (*sli_issue_iocb_cmd
)();
1694 uint32_t (*sli_issue_mbox_cmd
)();
1695 uint32_t (*sli_prep_fct_iocb
)();
1696 uint32_t (*sli_prep_fcp_iocb
)();
1697 uint32_t (*sli_prep_ip_iocb
)();
1698 uint32_t (*sli_prep_els_iocb
)();
1699 uint32_t (*sli_prep_ct_iocb
)();
1700 void (*sli_poll_intr
)();
1701 int32_t (*sli_intx_intr
)();
1702 uint32_t (*sli_msi_intr
)();
1703 void (*sli_disable_intr
)();
1704 void (*sli_timer
)();
1705 void (*sli_poll_erratt
)();
1706 uint32_t (*sli_reg_did
)();
1707 uint32_t (*sli_unreg_node
)();
1712 typedef struct emlxs_hba
1717 uint8_t pci_function_number
;
1718 uint8_t pci_device_number
;
1719 uint8_t pci_bus_number
;
1720 uint8_t pci_cap_offset
[PCI_CAP_MAX_PTR
];
1721 uint16_t pci_ecap_offset
[PCI_EXT_CAP_MAX_PTR
];
1724 int32_t fm_caps
; /* FMA capabilities */
1725 #endif /* FMA_SUPPORT */
1726 fc_fca_tran_t
*fca_tran
;
1728 /* DMA attributes */
1729 ddi_dma_attr_t dma_attr
;
1730 ddi_dma_attr_t dma_attr_ro
;
1731 ddi_dma_attr_t dma_attr_1sg
;
1732 ddi_dma_attr_t dma_attr_fcip_rsp
;
1735 emlxs_model_t model_info
;
1736 emlxs_vpd_t vpd
; /* vital product data */
1741 PROG_ID load_list
[MAX_LOAD_ENTRY
];
1742 WAKE_UP_PARMS wakeup_parms
;
1744 uint32_t io_throttle
;
1750 #define SLI_INTF_VALID_MASK 0xe0000000
1751 #define SLI_INTF_VALID 0xc0000000
1753 #define SLI_INTF_HINT2_MASK 0x1f000000
1754 #define SLI_INTF_HINT2_0 0x00000000
1756 #define SLI_INTF_HINT1_MASK 0x00ff0000
1757 #define SLI_INTF_HINT1_0 0x00000000
1758 #define SLI_INTF_HINT1_1 0x00010000
1759 #define SLI_INTF_HINT1_2 0x00020000
1761 #define SLI_INTF_IF_TYPE_MASK 0x0000f000
1762 #define SLI_INTF_IF_TYPE_0 0x00000000
1763 #define SLI_INTF_IF_TYPE_1 0x00001000
1764 #define SLI_INTF_IF_TYPE_2 0x00002000
1765 #define SLI_INTF_IF_TYPE_3 0x00003000
1767 #define SLI_INTF_FAMILY_MASK 0x00000f00
1768 #define SLI_INTF_FAMILY_BE2 0x00000000
1769 #define SLI_INTF_FAMILY_BE3 0x00000100
1770 #define SLI_INTF_FAMILY_LANCER_A 0x00000a00
1771 #define SLI_INTF_FAMILY_LANCER_B 0x00000b00
1773 #define SLI_INTF_SLI_REV_MASK 0x000000f0
1774 #define SLI_INTF_SLI_REV_NONE 0x00000000
1775 #define SLI_INTF_SLI_REV_3 0x00000030
1776 #define SLI_INTF_SLI_REV_4 0x00000040
1778 #define SLI_INTF_RESERVED1 0x0000000e
1780 #define SLI_INTF_FUNC_TYPE_MASK 0x00000001
1781 #define SLI_INTF_FUNC_PF 0x00000000
1782 #define SLI_INTF_FUNC_VF 0x00000001
1784 /* Link management */
1785 uint32_t link_event_tag
;
1788 uint16_t qos_linkspeed
;
1789 uint32_t linkup_wait_flag
;
1790 kcondvar_t linkup_lock_cv
;
1791 kmutex_t linkup_lock
;
1793 /* Memory Pool management */
1794 emlxs_memseg_t memseg
[FC_MAX_SEG
]; /* memory for buffer */
1796 kmutex_t memget_lock
; /* locks all memory pools get */
1797 kmutex_t memput_lock
; /* locks all memory pools put */
1800 /* Fibre Channel Service Parameters */
1802 uint32_t fc_edtov
; /* E_D_TOV timer value */
1803 uint32_t fc_arbtov
; /* ARB_TOV timer value */
1804 uint32_t fc_ratov
; /* R_A_TOV timer value */
1805 uint32_t fc_rttov
; /* R_T_TOV timer value */
1806 uint32_t fc_altov
; /* AL_TOV timer value */
1807 uint32_t fc_crtov
; /* C_R_TOV timer value */
1808 uint32_t fc_citov
; /* C_I_TOV timer value */
1810 /* Adapter State management */
1812 #define FC_ERROR 0x01 /* Adapter shutdown */
1813 #define FC_KILLED 0x02 /* Adapter interlocked/killed */
1814 #define FC_WARM_START 0x03 /* Adapter reset, but not restarted */
1815 #define FC_INIT_START 0x10 /* Adapter restarted */
1816 #define FC_INIT_NVPARAMS 0x11
1817 #define FC_INIT_REV 0x12
1818 #define FC_INIT_CFGPORT 0x13
1819 #define FC_INIT_CFGRING 0x14
1820 #define FC_INIT_INITLINK 0x15
1821 #define FC_LINK_DOWN 0x20
1822 #define FC_LINK_DOWN_PERSIST 0x21
1823 #define FC_LINK_UP 0x30
1824 #define FC_CLEAR_LA 0x31
1825 #define FC_READY 0x40
1828 #define FC_ONLINING_MODE 0x00000001
1829 #define FC_ONLINE_MODE 0x00000002
1830 #define FC_OFFLINING_MODE 0x00000004
1831 #define FC_OFFLINE_MODE 0x00000008
1833 #define FC_NPIV_ENABLED 0x00000010 /* NPIV enabled on adapter */
1834 #define FC_NPIV_SUPPORTED 0x00000020 /* NPIV supported on fabric */
1835 #define FC_NPIV_UNSUPPORTED 0x00000040 /* NPIV unsupported on fabric */
1836 #define FC_NPIV_LINKUP 0x00000100 /* NPIV enabled, supported, */
1837 /* and link is ready */
1838 #define FC_NPIV_DELAY_REQUIRED 0x00000200 /* Delay issuing FLOGI/FDISC */
1839 /* and NameServer cmds */
1841 #define FC_BOOTSTRAPMB_INIT 0x00000400
1842 #define FC_FIP_SUPPORTED 0x00000800 /* FIP supported */
1844 #define FC_FABRIC_ATTACHED 0x00001000
1845 #define FC_PT_TO_PT 0x00002000
1846 #define FC_BYPASSED_MODE 0x00004000
1847 #define FC_MENLO_MODE 0x00008000 /* Menlo maintenance mode */
1849 #define FC_DUMP_SAFE 0x00010000 /* Safe to DUMP */
1850 #define FC_DUMP_ACTIVE 0x00020000 /* DUMP in progress */
1851 #define FC_NEW_FABRIC 0x00040000
1853 #define FC_SLIM2_MODE 0x00100000 /* SLIM in host memory */
1854 #define FC_INTERLOCKED 0x00200000
1855 #define FC_HBQ_ENABLED 0x00400000
1856 #define FC_ASYNC_EVENTS 0x00800000
1858 #define FC_ILB_MODE 0x01000000
1859 #define FC_ELB_MODE 0x02000000
1860 #define FC_LOOPBACK_MODE 0x03000000 /* Loopback Mode Mask */
1861 #define FC_DUMP 0x04000000 /* DUMP in progress */
1862 #define FC_SHUTDOWN 0x08000000 /* SHUTDOWN in progress */
1864 #define FC_OVERTEMP_EVENT 0x10000000 /* FC_ERROR reason: */
1865 /* over temperature event */
1866 #define FC_MBOX_TIMEOUT 0x20000000 /* FC_ERROR reason: */
1867 /* mailbox timeout event */
1868 #define FC_DMA_CHECK_ERROR 0x40000000 /* Shared memory (slim,..) */
1869 /* DMA handle went bad */
1870 #define FC_HARDWARE_ERROR 0x80000000 /* FC_ERROR state triggered */
1872 #define FC_RESET_MASK 0x00030C1F /* Bits to protect during */
1874 #define FC_LINKDOWN_MASK 0xFFF30C1F /* Bits to protect during */
1879 #define FW_UPDATE_NEEDED 0x00000001
1880 #define FW_UPDATE_KERNEL 0x00000002
1882 uint32_t temperature
; /* Last reported temperature */
1884 /* SBUS adapter management */
1885 caddr_t sbus_pci_addr
; /* Virt addr of TITAN */
1887 ddi_acc_handle_t sbus_pci_handle
;
1889 /* PCI BUS adapter management */
1891 ddi_acc_handle_t pci_acc_handle
;
1894 #define EMLXS_HBA_SLI1_MODE 1
1895 #define EMLXS_HBA_SLI2_MODE 2
1896 #define EMLXS_HBA_SLI3_MODE 3
1897 #define EMLXS_HBA_SLI4_MODE 4
1899 /* SLI private data */
1905 /* SLI API entry point routines */
1906 emlxs_sli_api_t sli_api
;
1908 uint32_t io_poll_count
; /* Number of poll commands */
1911 /* IO Completion management */
1912 uint32_t iodone_count
; /* Number of IO's on done Q */
1913 /* Protected by EMLXS_PORT_LOCK */
1914 emlxs_buf_t
*iodone_list
; /* fc_packet being deferred */
1915 emlxs_buf_t
*iodone_tail
; /* fc_packet being deferred */
1916 emlxs_thread_t iodone_thread
;
1917 emlxs_thread_t
*spawn_thread_head
;
1918 emlxs_thread_t
*spawn_thread_tail
;
1919 kmutex_t spawn_lock
;
1920 uint32_t spawn_open
;
1922 /* IO Channel management */
1924 emlxs_channel_t chan
[MAX_CHANNEL
];
1925 kmutex_t channel_tx_lock
;
1926 uint8_t channel_fcp
; /* Default channel to use for FCP IO */
1927 #define CHANNEL_FCT channel_fcp
1928 uint8_t channel_ip
; /* Default channel to use for IP IO */
1929 uint8_t channel_els
; /* Default channel to use for ELS IO */
1930 uint8_t channel_ct
; /* Default channel to use for CT IO */
1932 /* IOTag management */
1933 emlxs_buf_t
**fc_table
; /* sc_buf pointers indexed by */
1935 uint16_t fc_iotag
; /* used to identify I/Os */
1936 uint16_t fc_oor_iotag
; /* OutOfRange (fc_table) iotags */
1937 /* typically used for Abort/close */
1938 #define EMLXS_MAX_ABORT_TAG 0x7fff
1939 uint16_t max_iotag
; /* ALL IOCBs except aborts */
1940 kmutex_t iotag_lock
;
1941 uint32_t io_count
; /* No of IO holding */
1943 uint32_t channel_tx_count
; /* No of IO on tx Q */
1945 /* Mailbox Management */
1946 uint32_t mbox_queue_flag
;
1947 emlxs_queue_t mbox_queue
;
1948 void *mbox_mqe
; /* active mbox mqe */
1949 void *mbox_mbq
; /* active MAILBOXQ */
1950 kcondvar_t mbox_lock_cv
; /* MBX_SLEEP */
1951 kmutex_t mbox_lock
; /* MBX_SLEEP */
1952 uint32_t mbox_timer
;
1954 /* Interrupt management */
1956 uint32_t intr_unclaimed
;
1957 uint32_t intr_autoClear
;
1958 uint32_t intr_busy_cnt
;
1960 uint32_t intr_flags
;
1961 #define EMLXS_INTX_INITED 0x0001
1962 #define EMLXS_INTX_ADDED 0x0002
1963 #define EMLXS_MSI_ENABLED 0x0010
1964 #define EMLXS_MSI_INITED 0x0020
1965 #define EMLXS_MSI_ADDED 0x0040
1966 #define EMLXS_INTR_INITED (EMLXS_INTX_INITED|EMLXS_MSI_INITED)
1967 #define EMLXS_INTR_ADDED (EMLXS_INTX_ADDED|EMLXS_MSI_ADDED)
1970 ddi_intr_handle_t
*intr_htable
;
1973 uint32_t intr_count
;
1976 uint32_t intr_map
[EMLXS_MSI_MAX_INTRS
];
1979 kmutex_t msiid_lock
; /* for last_msiid */
1982 kmutex_t intr_lock
[EMLXS_MSI_MAX_INTRS
];
1983 int chan2msi
[MAX_CHANNEL
];
1984 /* Index is the channel id */
1985 int msi2chan
[EMLXS_MSI_MAX_INTRS
];
1986 /* Index is the MSX-X msg id */
1987 #endif /* MSI_SUPPORT */
1989 uint32_t heartbeat_timer
;
1990 uint32_t heartbeat_flag
;
1991 uint32_t heartbeat_active
;
1993 /* IOCTL management */
1994 kmutex_t ioctl_lock
;
1995 uint32_t ioctl_flags
;
1996 #define EMLXS_OPEN 0x00000001
1997 #define EMLXS_OPEN_EXCLUSIVE 0x00000002
1999 /* Timer management */
2000 kcondvar_t timer_lock_cv
;
2001 kmutex_t timer_lock
;
2002 timeout_id_t timer_id
;
2003 uint32_t timer_tics
;
2004 uint32_t timer_flags
;
2005 #define EMLXS_TIMER_STARTED 0x0000001
2006 #define EMLXS_TIMER_BUSY 0x0000002
2007 #define EMLXS_TIMER_KILL 0x0000004
2008 #define EMLXS_TIMER_ENDED 0x0000008
2011 uint32_t linkup_timer
;
2012 uint32_t discovery_timer
;
2015 /* Power Management */
2018 #define EMLXS_PM_IN_ATTACH 0x00000001
2019 #define EMLXS_PM_IN_DETACH 0x00000002
2020 #define EMLXS_PM_IN_SOL_CB 0x00000010
2021 #define EMLXS_PM_IN_UNSOL_CB 0x00000020
2022 #define EMLXS_PM_IN_LINK_RESET 0x00000100
2023 #define EMLXS_PM_IN_HARD_RESET 0x00000200
2024 #define EMLXS_PM_SUSPENDED 0x01000000
2028 #define EMLXS_PM_ADAPTER_DOWN 0
2029 #define EMLXS_PM_ADAPTER_UP 1
2033 uint8_t pm_config
[PCI_CONFIG_SIZE
];
2035 uint32_t pm_idle_timer
;
2036 uint32_t pm_active
; /* Only used by timer */
2037 #endif /* IDLE_TIMER */
2039 /* Loopback management */
2040 uint32_t loopback_tics
;
2043 /* Event management */
2044 emlxs_event_queue_t event_queue
;
2045 uint32_t event_mask
;
2046 uint32_t event_timer
;
2047 emlxs_dfc_event_t dfc_event
[MAX_DFC_EVENTS
];
2048 emlxs_hba_event_t hba_event
;
2050 /* Parameter management */
2051 emlxs_config_t config
[NUM_CFG_PARAM
];
2053 /* Driver stat management */
2055 emlxs_stats_t stats
;
2057 /* Log management */
2058 emlxs_msg_log_t log
;
2060 /* Port managment */
2063 uint32_t num_of_ports
;
2065 kmutex_t port_lock
; /* locks port, nodes, rings */
2066 emlxs_port_t port
[MAX_VPORTS
+ 1]; /* port specific info */
2067 /* Last one is for */
2068 /* NPIV ready test */
2070 #ifdef DHCHAP_SUPPORT
2073 emlxs_auth_cfg_t auth_cfg
; /* Default auth_cfg. */
2074 /* Points to list of entries. */
2075 /* Protected by auth_lock */
2076 uint32_t auth_cfg_count
;
2077 emlxs_auth_key_t auth_key
; /* Default auth_key. */
2078 /* Points to list of entries. */
2079 /* Protected by auth_lock */
2080 uint32_t auth_key_count
;
2082 #endif /* DHCHAP_SUPPORT */
2085 uint32_t underrun_counter
;
2086 #endif /* TEST_SUPPORT */
2088 #ifdef MODFW_SUPPORT
2089 ddi_modhandle_t fw_modhandle
;
2090 #endif /* MODFW_SUPPORT */
2093 emlxs_file_t dump_txtfile
;
2094 emlxs_file_t dump_dmpfile
;
2095 emlxs_file_t dump_ceefile
;
2097 #define EMLXS_DUMP_LOCK hba->dump_lock
2098 #define EMLXS_TXT_FILE 1
2099 #define EMLXS_DMP_FILE 2
2100 #define EMLXS_CEE_FILE 3
2102 #define EMLXS_DRV_DUMP 0
2103 #define EMLXS_TEMP_DUMP 1
2104 #define EMLXS_USER_DUMP 2
2106 #endif /* DUMP_SUPPORT */
2108 uint32_t reset_request
;
2109 #define FC_LINK_RESET 1
2110 #define FC_PORT_RESET 2
2112 uint32_t reset_state
;
2113 #define FC_LINK_RESET_INP 1
2114 #define FC_PORT_RESET_INP 2
2118 #define EMLXS_SLI_MAP_HDW (hba->sli_api.sli_map_hdw)
2119 #define EMLXS_SLI_UNMAP_HDW (hba->sli_api.sli_unmap_hdw)
2120 #define EMLXS_SLI_ONLINE (hba->sli_api.sli_online)
2121 #define EMLXS_SLI_OFFLINE (hba->sli_api.sli_offline)
2122 #define EMLXS_SLI_HBA_RESET (hba->sli_api.sli_hba_reset)
2123 #define EMLXS_SLI_HBA_KILL (hba->sli_api.sli_hba_kill)
2124 #define EMLXS_SLI_ISSUE_IOCB_CMD (hba->sli_api.sli_issue_iocb_cmd)
2125 #define EMLXS_SLI_ISSUE_MBOX_CMD (hba->sli_api.sli_issue_mbox_cmd)
2126 #define EMLXS_SLI_PREP_FCT_IOCB (hba->sli_api.sli_prep_fct_iocb)
2127 #define EMLXS_SLI_PREP_FCP_IOCB (hba->sli_api.sli_prep_fcp_iocb)
2128 #define EMLXS_SLI_PREP_IP_IOCB (hba->sli_api.sli_prep_ip_iocb)
2129 #define EMLXS_SLI_PREP_ELS_IOCB (hba->sli_api.sli_prep_els_iocb)
2130 #define EMLXS_SLI_PREP_CT_IOCB (hba->sli_api.sli_prep_ct_iocb)
2131 #define EMLXS_SLI_POLL_INTR (hba->sli_api.sli_poll_intr)
2132 #define EMLXS_SLI_INTX_INTR (hba->sli_api.sli_intx_intr)
2133 #define EMLXS_SLI_MSI_INTR (hba->sli_api.sli_msi_intr)
2134 #define EMLXS_SLI_DISABLE_INTR (hba->sli_api.sli_disable_intr)
2135 #define EMLXS_SLI_TIMER (hba->sli_api.sli_timer)
2136 #define EMLXS_SLI_POLL_ERRATT (hba->sli_api.sli_poll_erratt)
2137 #define EMLXS_SLI_REG_DID (hba->sli_api.sli_reg_did)
2138 #define EMLXS_SLI_UNREG_NODE (hba->sli_api.sli_unreg_node)
2140 #define EMLXS_HBA_T 1 /* flag emlxs_hba_t is already typedefed */
2143 #define EMLXS_INTR_INIT(_hba, _m) emlxs_msi_init(_hba, _m)
2144 #define EMLXS_INTR_UNINIT(_hba) emlxs_msi_uninit(_hba)
2145 #define EMLXS_INTR_ADD(_hba) emlxs_msi_add(_hba)
2146 #define EMLXS_INTR_REMOVE(_hba) emlxs_msi_remove(_hba)
2148 #define EMLXS_INTR_INIT(_hba, _m) emlxs_intx_init(_hba, _m)
2149 #define EMLXS_INTR_UNINIT(_hba) emlxs_intx_uninit(_hba)
2150 #define EMLXS_INTR_ADD(_hba) emlxs_intx_add(_hba)
2151 #define EMLXS_INTR_REMOVE(_hba) emlxs_intx_remove(_hba)
2152 #endif /* MSI_SUPPORT */
2155 /* Power Management Component */
2156 #define EMLXS_PM_ADAPTER 0
2159 #define DRV_TIME (uint32_t)(ddi_get_time() - emlxs_device.drv_timestamp)
2161 #define HBA port->hba
2162 #define PPORT hba->port[0]
2163 #define VPORT(x) hba->port[x]
2164 #define EMLXS_TIMER_LOCK hba->timer_lock
2165 #define VPD hba->vpd
2166 #define CFG hba->config[0]
2167 #define LOG hba->log
2168 #define EVENTQ hba->event_queue
2169 #define EMLXS_MBOX_LOCK hba->mbox_lock
2170 #define EMLXS_MBOX_CV hba->mbox_lock_cv
2171 #define EMLXS_LINKUP_LOCK hba->linkup_lock
2172 #define EMLXS_LINKUP_CV hba->linkup_lock_cv
2173 #define EMLXS_TX_CHANNEL_LOCK hba->channel_tx_lock /* ring txq lock */
2174 #define EMLXS_MEMGET_LOCK hba->memget_lock /* mempool get lock */
2175 #define EMLXS_MEMPUT_LOCK hba->memput_lock /* mempool put lock */
2176 #define EMLXS_IOCTL_LOCK hba->ioctl_lock /* ioctl lock */
2177 #define EMLXS_SPAWN_LOCK hba->spawn_lock /* spawn lock */
2178 #define EMLXS_PM_LOCK hba->pm_lock /* pm lock */
2179 #define HBASTATS hba->stats
2180 #define EMLXS_CMD_RING_LOCK(n) hba->sli.sli3.ring_cmd_lock[n]
2182 #define EMLXS_QUE_LOCK(n) hba->sli.sli4.que_lock[n]
2183 #define EMLXS_MSIID_LOCK hba->msiid_lock
2185 #define EMLXS_FCTAB_LOCK hba->iotag_lock
2187 #define EMLXS_FCF_LOCK hba->sli.sli4.fcf_lock
2189 #define EMLXS_PORT_LOCK hba->port_lock /* locks ports, */
2191 #define EMLXS_INTR_LOCK(_id) hba->intr_lock[_id] /* locks intr threads */
2193 #define EMLXS_PKT_LOCK port->pkt_lock /* used for pkt */
2195 #define EMLXS_PKT_CV port->pkt_lock_cv /* Used for pkt */
2197 #define EMLXS_UB_LOCK port->ub_lock /* locks unsolicited */
2200 /* These SWAPs will swap on any platform */
2201 #define SWAP32_BUFFER(_b, _c) emlxs_swap32_buffer(_b, _c)
2202 #define SWAP32_BCOPY(_s, _d, _c) emlxs_swap32_bcopy(_s, _d, _c)
2204 #define SWAP64(_x) ((((uint64_t)(_x) & 0xFF)<<56) | \
2205 (((uint64_t)(_x) & 0xFF00)<<40) | \
2206 (((uint64_t)(_x) & 0xFF0000)<<24) | \
2207 (((uint64_t)(_x) & 0xFF000000)<<8) | \
2208 (((uint64_t)(_x) & 0xFF00000000)>>8) | \
2209 (((uint64_t)(_x) & 0xFF0000000000)>>24) | \
2210 (((uint64_t)(_x) & 0xFF000000000000)>>40) | \
2211 (((uint64_t)(_x) & 0xFF00000000000000)>>56))
2213 #define SWAP32(_x) ((((uint32_t)(_x) & 0xFF)<<24) | \
2214 (((uint32_t)(_x) & 0xFF00)<<8) | \
2215 (((uint32_t)(_x) & 0xFF0000)>>8) | \
2216 (((uint32_t)(_x) & 0xFF000000)>>24))
2218 #define SWAP16(_x) ((((uint16_t)(_x) & 0xFF)<<8) | \
2219 (((uint16_t)(_x) & 0xFF00)>>8))
2221 #define SWAP24_LO(_x) ((((uint32_t)(_x) & 0xFF)<<16) | \
2222 ((uint32_t)(_x) & 0xFF00FF00) | \
2223 (((uint32_t)(_x) & 0x00FF0000)>>16))
2225 #define SWAP24_HI(_x) (((uint32_t)(_x) & 0x00FF00FF) | \
2226 (((uint32_t)(_x) & 0x0000FF00)<<16) | \
2227 (((uint32_t)(_x) & 0xFF000000)>>16))
2229 /* These LE_SWAPs will only swap on a LE platform */
2230 #ifdef EMLXS_LITTLE_ENDIAN
2231 #define LE_SWAP32_BUFFER(_b, _c) SWAP32_BUFFER(_b, _c)
2232 #define LE_SWAP32_BCOPY(_s, _d, _c) SWAP32_BCOPY(_s, _d, _c)
2233 #define LE_SWAP64(_x) SWAP64(_x)
2234 #define LE_SWAP32(_x) SWAP32(_x)
2235 #define LE_SWAP16(_x) SWAP16(_x)
2236 #define LE_SWAP24_LO(_x) SWAP24_LO(X)
2237 #define LE_SWAP24_HI(_x) SWAP24_HI(X)
2239 #if (EMLXS_MODREVX == EMLXS_MODREV2X)
2241 #define LE_SWAP24_LO(_x) (_x)
2243 #define LE_SWAP24_HI(_x) (_x)
2244 #endif /* EMLXS_MODREV2X */
2246 #else /* BIG ENDIAN */
2247 #define LE_SWAP32_BUFFER(_b, _c)
2248 #define LE_SWAP32_BCOPY(_s, _d, _c) bcopy(_s, _d, _c)
2249 #define LE_SWAP64(_x) (_x)
2250 #define LE_SWAP32(_x) (_x)
2251 #define LE_SWAP16(_x) (_x)
2252 #define LE_SWAP24_LO(_x) (_x)
2253 #define LE_SWAP24_HI(_x) (_x)
2254 #endif /* EMLXS_LITTLE_ENDIAN */
2256 /* These BE_SWAPs will only swap on a BE platform */
2257 #ifdef EMLXS_BIG_ENDIAN
2258 #define BE_SWAP32_BUFFER(_b, _c) SWAP32_BUFFER(_b, _c)
2259 #define BE_SWAP32_BCOPY(_s, _d, _c) SWAP32_BCOPY(_s, _d, _c)
2260 #define BE_SWAP64(_x) SWAP64(_x)
2261 #define BE_SWAP32(_x) SWAP32(_x)
2262 #define BE_SWAP16(_x) SWAP16(_x)
2263 #else /* LITTLE ENDIAN */
2264 #define BE_SWAP32_BUFFER(_b, _c)
2265 #define BE_SWAP32_BCOPY(_s, _d, _c) bcopy(_s, _d, _c)
2266 #define BE_SWAP64(_x) (_x)
2267 #define BE_SWAP32(_x) (_x)
2268 #define BE_SWAP16(_x) (_x)
2269 #endif /* EMLXS_BIG_ENDIAN */
2271 #define EMLXS_DFC_RESET_ALL 0x10
2272 #define EMLXS_DFC_RESET_ALL_FORCE_DUMP 0x11
2278 #endif /* _EMLXS_FC_H */