|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 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.                          * | 
|  | 7 | * www.emulex.com                                                  * | 
|  | 8 | *                                                                 * | 
|  | 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.          * | 
|  | 13 | *                                                                 * | 
|  | 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 | *******************************************************************/ | 
|  | 20 |  | 
|  | 21 | /* | 
|  | 22 | * $Id: lpfc_sli.h 1.42 2005/03/21 02:01:28EST sf_support Exp  $ | 
|  | 23 | */ | 
|  | 24 |  | 
|  | 25 | /* forward declaration for LPFC_IOCB_t's use */ | 
|  | 26 | struct lpfc_hba; | 
|  | 27 |  | 
|  | 28 | /* Define the context types that SLI handles for abort and sums. */ | 
|  | 29 | typedef enum _lpfc_ctx_cmd { | 
|  | 30 | LPFC_CTX_LUN, | 
|  | 31 | LPFC_CTX_TGT, | 
|  | 32 | LPFC_CTX_CTX, | 
|  | 33 | LPFC_CTX_HOST | 
|  | 34 | } lpfc_ctx_cmd; | 
|  | 35 |  | 
|  | 36 | /* This structure is used to handle IOCB requests / responses */ | 
|  | 37 | struct lpfc_iocbq { | 
|  | 38 | /* lpfc_iocbqs are used in double linked lists */ | 
|  | 39 | struct list_head list; | 
|  | 40 | IOCB_t iocb;		/* IOCB cmd */ | 
|  | 41 | uint8_t retry;		/* retry counter for IOCB cmd - if needed */ | 
|  | 42 | uint8_t iocb_flag; | 
|  | 43 | #define LPFC_IO_POLL	1	/* Polling mode iocb */ | 
|  | 44 | #define LPFC_IO_LIBDFC	2	/* libdfc iocb */ | 
|  | 45 | #define LPFC_IO_WAIT	4 | 
|  | 46 | #define LPFC_IO_HIPRI	8	/* High Priority Queue signal flag */ | 
|  | 47 |  | 
|  | 48 | uint8_t abort_count; | 
|  | 49 | uint8_t rsvd2; | 
|  | 50 | uint32_t drvrTimeout;	/* driver timeout in seconds */ | 
|  | 51 | void *context1;		/* caller context information */ | 
|  | 52 | void *context2;		/* caller context information */ | 
|  | 53 | void *context3;		/* caller context information */ | 
|  | 54 | union { | 
|  | 55 | wait_queue_head_t *hipri_wait_queue; /* High Priority Queue wait | 
|  | 56 | queue */ | 
|  | 57 | struct lpfc_iocbq  *rsp_iocb; | 
|  | 58 | struct lpfcMboxq   *mbox; | 
|  | 59 | } context_un; | 
|  | 60 |  | 
|  | 61 | void (*iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, | 
|  | 62 | struct lpfc_iocbq *); | 
|  | 63 |  | 
|  | 64 | }; | 
|  | 65 |  | 
|  | 66 | #define SLI_IOCB_RET_IOCB      1	/* Return IOCB if cmd ring full */ | 
|  | 67 | #define SLI_IOCB_HIGH_PRIORITY 2	/* High priority command */ | 
|  | 68 |  | 
|  | 69 | #define IOCB_SUCCESS        0 | 
|  | 70 | #define IOCB_BUSY           1 | 
|  | 71 | #define IOCB_ERROR          2 | 
|  | 72 | #define IOCB_TIMEDOUT       3 | 
|  | 73 |  | 
|  | 74 | typedef struct lpfcMboxq { | 
|  | 75 | /* MBOXQs are used in single linked lists */ | 
|  | 76 | struct list_head list;	/* ptr to next mailbox command */ | 
|  | 77 | MAILBOX_t mb;		/* Mailbox cmd */ | 
|  | 78 | void *context1;		/* caller context information */ | 
|  | 79 | void *context2;		/* caller context information */ | 
|  | 80 |  | 
|  | 81 | void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); | 
|  | 82 |  | 
|  | 83 | } LPFC_MBOXQ_t; | 
|  | 84 |  | 
|  | 85 | #define MBX_POLL        1	/* poll mailbox till command done, then | 
|  | 86 | return */ | 
|  | 87 | #define MBX_NOWAIT      2	/* issue command then return immediately */ | 
|  | 88 | #define MBX_STOP_IOCB   4	/* Stop iocb processing till mbox cmds | 
|  | 89 | complete */ | 
|  | 90 |  | 
|  | 91 | #define LPFC_MAX_RING_MASK  4	/* max num of rctl/type masks allowed per | 
|  | 92 | ring */ | 
|  | 93 | #define LPFC_MAX_RING       4	/* max num of SLI rings used by driver */ | 
|  | 94 |  | 
|  | 95 | struct lpfc_sli_ring; | 
|  | 96 |  | 
|  | 97 | struct lpfc_sli_ring_mask { | 
|  | 98 | uint8_t profile;	/* profile associated with ring */ | 
|  | 99 | uint8_t rctl;	/* rctl / type pair configured for ring */ | 
|  | 100 | uint8_t type;	/* rctl / type pair configured for ring */ | 
|  | 101 | uint8_t rsvd; | 
|  | 102 | /* rcv'd unsol event */ | 
|  | 103 | void (*lpfc_sli_rcv_unsol_event) (struct lpfc_hba *, | 
|  | 104 | struct lpfc_sli_ring *, | 
|  | 105 | struct lpfc_iocbq *); | 
|  | 106 | }; | 
|  | 107 |  | 
|  | 108 |  | 
|  | 109 | /* Structure used to hold SLI statistical counters and info */ | 
|  | 110 | struct lpfc_sli_ring_stat { | 
|  | 111 | uint64_t iocb_event;	 /* IOCB event counters */ | 
|  | 112 | uint64_t iocb_cmd;	 /* IOCB cmd issued */ | 
|  | 113 | uint64_t iocb_rsp;	 /* IOCB rsp received */ | 
|  | 114 | uint64_t iocb_cmd_delay; /* IOCB cmd ring delay */ | 
|  | 115 | uint64_t iocb_cmd_full;	 /* IOCB cmd ring full */ | 
|  | 116 | uint64_t iocb_cmd_empty; /* IOCB cmd ring is now empty */ | 
|  | 117 | uint64_t iocb_rsp_full;	 /* IOCB rsp ring full */ | 
|  | 118 | }; | 
|  | 119 |  | 
|  | 120 | /* Structure used to hold SLI ring information */ | 
|  | 121 | struct lpfc_sli_ring { | 
|  | 122 | uint16_t flag;		/* ring flags */ | 
|  | 123 | #define LPFC_DEFERRED_RING_EVENT 0x001	/* Deferred processing a ring event */ | 
|  | 124 | #define LPFC_CALL_RING_AVAILABLE 0x002	/* indicates cmd was full */ | 
|  | 125 | #define LPFC_STOP_IOCB_MBX       0x010	/* Stop processing IOCB cmds mbox */ | 
|  | 126 | #define LPFC_STOP_IOCB_EVENT     0x020	/* Stop processing IOCB cmds event */ | 
|  | 127 | #define LPFC_STOP_IOCB_MASK      0x030	/* Stop processing IOCB cmds mask */ | 
|  | 128 | uint16_t abtsiotag;	/* tracks next iotag to use for ABTS */ | 
|  | 129 |  | 
|  | 130 | uint32_t local_getidx;   /* last available cmd index (from cmdGetInx) */ | 
|  | 131 | uint32_t next_cmdidx;    /* next_cmd index */ | 
|  | 132 | uint8_t rsvd; | 
|  | 133 | uint8_t ringno;		/* ring number */ | 
|  | 134 | uint8_t rspidx;		/* current index in response ring */ | 
|  | 135 | uint8_t cmdidx;		/* current index in command ring */ | 
|  | 136 | uint16_t numCiocb;	/* number of command iocb's per ring */ | 
|  | 137 | uint16_t numRiocb;	/* number of rsp iocb's per ring */ | 
|  | 138 |  | 
|  | 139 | uint32_t fast_iotag;	/* max fastlookup based iotag           */ | 
|  | 140 | uint32_t iotag_ctr;	/* keeps track of the next iotag to use */ | 
|  | 141 | uint32_t iotag_max;	/* max iotag value to use               */ | 
|  | 142 | struct lpfc_iocbq ** fast_lookup; /* array of IOCB ptrs indexed by | 
|  | 143 | iotag */ | 
|  | 144 | struct list_head txq; | 
|  | 145 | uint16_t txq_cnt;	/* current length of queue */ | 
|  | 146 | uint16_t txq_max;	/* max length */ | 
|  | 147 | struct list_head txcmplq; | 
|  | 148 | uint16_t txcmplq_cnt;	/* current length of queue */ | 
|  | 149 | uint16_t txcmplq_max;	/* max length */ | 
|  | 150 | uint32_t *cmdringaddr;	/* virtual address for cmd rings */ | 
|  | 151 | uint32_t *rspringaddr;	/* virtual address for rsp rings */ | 
|  | 152 | uint32_t missbufcnt;	/* keep track of buffers to post */ | 
|  | 153 | struct list_head postbufq; | 
|  | 154 | uint16_t postbufq_cnt;	/* current length of queue */ | 
|  | 155 | uint16_t postbufq_max;	/* max length */ | 
|  | 156 | struct list_head iocb_continueq; | 
|  | 157 | uint16_t iocb_continueq_cnt;	/* current length of queue */ | 
|  | 158 | uint16_t iocb_continueq_max;	/* max length */ | 
|  | 159 |  | 
|  | 160 | struct lpfc_sli_ring_mask prt[LPFC_MAX_RING_MASK]; | 
|  | 161 | uint32_t num_mask;	/* number of mask entries in prt array */ | 
|  | 162 |  | 
|  | 163 | struct lpfc_sli_ring_stat stats;	/* SLI statistical info */ | 
|  | 164 |  | 
|  | 165 | /* cmd ring available */ | 
|  | 166 | void (*lpfc_sli_cmd_available) (struct lpfc_hba *, | 
|  | 167 | struct lpfc_sli_ring *); | 
|  | 168 | }; | 
|  | 169 |  | 
|  | 170 | /* Structure used to hold SLI statistical counters and info */ | 
|  | 171 | struct lpfc_sli_stat { | 
|  | 172 | uint64_t mbox_stat_err;  /* Mbox cmds completed status error */ | 
|  | 173 | uint64_t mbox_cmd;       /* Mailbox commands issued */ | 
|  | 174 | uint64_t sli_intr;       /* Count of Host Attention interrupts */ | 
|  | 175 | uint32_t err_attn_event; /* Error Attn event counters */ | 
|  | 176 | uint32_t link_event;     /* Link event counters */ | 
|  | 177 | uint32_t mbox_event;     /* Mailbox event counters */ | 
|  | 178 | uint32_t mbox_busy;	 /* Mailbox cmd busy */ | 
|  | 179 | }; | 
|  | 180 |  | 
|  | 181 | /* Structure used to hold SLI information */ | 
|  | 182 | struct lpfc_sli { | 
|  | 183 | uint32_t num_rings; | 
|  | 184 | uint32_t sli_flag; | 
|  | 185 |  | 
|  | 186 | /* Additional sli_flags */ | 
|  | 187 | #define LPFC_SLI_MBOX_ACTIVE      0x100	/* HBA mailbox is currently active */ | 
|  | 188 | #define LPFC_SLI2_ACTIVE          0x200	/* SLI2 overlay in firmware is active */ | 
|  | 189 | #define LPFC_PROCESS_LA           0x400	/* Able to process link attention */ | 
|  | 190 |  | 
|  | 191 | struct lpfc_sli_ring ring[LPFC_MAX_RING]; | 
|  | 192 | int fcp_ring;		/* ring used for FCP initiator commands */ | 
|  | 193 | int next_ring; | 
|  | 194 |  | 
|  | 195 | int ip_ring;		/* ring used for IP network drv cmds */ | 
|  | 196 |  | 
|  | 197 | struct lpfc_sli_stat slistat;	/* SLI statistical info */ | 
|  | 198 | struct list_head mboxq; | 
|  | 199 | uint16_t mboxq_cnt;	/* current length of queue */ | 
|  | 200 | uint16_t mboxq_max;	/* max length */ | 
|  | 201 | LPFC_MBOXQ_t *mbox_active;	/* active mboxq information */ | 
|  | 202 |  | 
|  | 203 | struct timer_list mbox_tmo;	/* Hold clk to timeout active mbox | 
|  | 204 | cmd */ | 
|  | 205 |  | 
|  | 206 | uint32_t *MBhostaddr;	/* virtual address for mbox cmds */ | 
|  | 207 | }; | 
|  | 208 |  | 
|  | 209 | /* Given a pointer to the start of the ring, and the slot number of | 
|  | 210 | * the desired iocb entry, calc a pointer to that entry. | 
|  | 211 | * (assume iocb entry size is 32 bytes, or 8 words) | 
|  | 212 | */ | 
|  | 213 | #define IOCB_ENTRY(ring,slot) ((IOCB_t *)(((char *)(ring)) + ((slot) * 32))) | 
|  | 214 |  | 
|  | 215 | #define LPFC_MBOX_TMO           30	/* Sec tmo for outstanding mbox | 
|  | 216 | command */ |