1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21 ********************************************************************************/
22 /*******************************************************************************/
26 * This file contains interrupt related functions in the SAS/SATA TD layer
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <dev/pms/config.h>
33 #include <dev/pms/freebsd/driver/common/osenv.h>
34 #include <dev/pms/freebsd/driver/common/ostypes.h>
35 #include <dev/pms/freebsd/driver/common/osdebug.h>
37 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
38 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
39 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
41 #include <dev/pms/RefTisa/tisa/api/titypes.h>
42 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
43 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
44 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
47 #include <dev/pms/RefTisa/sat/api/sm.h>
48 #include <dev/pms/RefTisa/sat/api/smapi.h>
49 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
53 #include <dev/pms/RefTisa/discovery/api/dm.h>
54 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
55 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
58 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
59 #include <dev/pms/freebsd/driver/common/osstring.h>
60 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
62 #ifdef INITIATOR_DRIVER
63 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
69 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
74 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
77 /*****************************************************************************
78 *! \biref tiCOMInterruptHandler
80 * Purpose: This function is called to service the hardware interrupt of the
83 * \param tiRoot: Pointer to initiator specific root data structure for this
84 * instance of the driver.
86 * \param channelNum: The zero-base channel number of the controller.
87 * 0xFFFFFFFF indicates that the OS-App Specific layer does
88 * not provide the channel number. The TD/LL Layer needs to
89 * discover of any of its own channels that are causing the
94 * \note - The only thing that this API will do is to acknowledge and mask
95 * the necessary hardware interrupt register. The actual processing
96 * of the interrupt handler is done in tiCOMDelayedInterruptHandler().
98 *****************************************************************************/
100 tiCOMInterruptHandler(
104 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
105 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
106 agsaRoot_t *agRoot = &(tdsaAllShared->agRootNonInt);
107 bit32 interruptPending = agFALSE;
109 interruptPending = saInterruptHandler(agRoot, channelNum);
111 return interruptPending;
113 } /* tiCOMInterruptHandler() */
116 /*****************************************************************************
117 *! \brief tiCOMDelayedInterruptHandler
119 * Purpose: This function is called to process the task associated with the
120 * interrupt handler. The task that this handler needs to do includes:
121 * completion of I/O, login event, error event, etc
123 * \param tiRoot: Pointer to initiator specific root data structure for
124 * this instance of the driver.
125 * \param channelNum: The zero-base channel number of the controller.
126 * 0xFFFFFFFF indicates that the OS-App Specific layer does
127 * not provide the channel number. The TD/LL Layer needs to
128 * discover of any of its own channels that are causing the
130 * \param count: Count on how many items (such as IO completion) need to
131 * be processed in this context.
132 * \param interruptContext: The thread/process context within which this
133 * function is called.
135 * tiInterruptContext: this function is called within an
137 * tiNonInterruptContext: this function is called outside an
141 *****************************************************************************/
144 tiCOMDelayedInterruptHandler(
151 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
152 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
153 agsaRoot_t *agRoot = agNULL;
156 TDSA_OUT_ENTER(tiRoot);
158 if(context == tiInterruptContext)
160 agRoot = &(tdsaAllShared->agRootInt);
164 agRoot = &(tdsaAllShared->agRootNonInt);
167 completed = saDelayedInterruptHandler(agRoot, channelNum, count);
171 TI_DBG3(("tiCOMDelayedInterruptHandler: processedMsgCount zero\n"));
175 TDSA_OUT_LEAVE(tiRoot);
178 } /* tiCOMDelayedInterruptHandler() */
181 /*****************************************************************************
182 *! \brief tiCOMSystemInterruptsActive
184 * Purpose: This function is called to indicate whether interrupts are
185 * active or not from this point in time.
187 * \param tiRoot: Pointer to initiator specific root data structure for
188 * this instance of the driver.
189 * \param sysIntsActive: Boolean value either true or false
193 *****************************************************************************/
195 tiCOMSystemInterruptsActive(
201 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
202 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
204 agRoot = &(tdsaAllShared->agRootNonInt);
206 #ifdef SPC_POLLINGMODE
207 if(sysIntsActive) return;
208 #endif /* SPC_POLLINGMODE */
210 tdsaAllShared->flags.sysIntsActive = sysIntsActive;
212 TI_DBG6(("tiCOMSystemInterruptsActive: start\n"));
213 /* enable low level interrupts */
214 if(agRoot->sdkData != agNULL)
216 saSystemInterruptsActive(
218 (agBOOLEAN) tdsaAllShared->flags.sysIntsActive
222 TI_DBG6(("tiCOMSystemInterruptsActive: end\n"));
223 } /* tiCOMSystemInterruptsActive */
227 tiComCountActiveIORequests(
231 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
232 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
234 agRoot = &(tdsaAllShared->agRootNonInt);
235 saCountActiveIORequests(agRoot );
238 /*****************************************************************************
239 *! \brief tiCOMInterruptEnable
241 * Purpose: This function is called to enable an interrupts on the specified channel
242 * active or not from this point in time.
244 * \param tiRoot: Pointer to initiator specific root data structure for
245 * this instance of the driver.
246 * \param : channelNum vector number for MSIX Zero for legacy interrupt
250 *****************************************************************************/
253 tiCOMInterruptEnable(
257 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
258 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
260 agRoot = &(tdsaAllShared->agRootNonInt);
262 saSystemInterruptsEnable(agRoot, channelNum);