xref: /freebsd/sys/dev/pms/RefTisa/sat/api/tdsmapi.h (revision 069ac184)
1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
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
7 *following disclaimer.
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.
11 *
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
20 *
21 *
22 ********************************************************************************/
23 /********************************************************************************
24 *   tmsmapi.h
25 *
26 *   Abstract:   This module contains function prototype of the SAT
27 *               Module (SM) API callback for initiator.
28 *******************************************************************************/
29 
30 #ifndef TDSMAPI_H
31 #define TDSMAPI_H
32 
33 osGLOBAL void
34 tdsmIDCompletedCB(
35                   smRoot_t   *smRoot,
36                   smIORequest_t   *smIORequest,
37                   smDeviceHandle_t   *smDeviceHandle,
38                   bit32    status,
39                   void    *IDdata
40                  );
41 
42 osGLOBAL FORCEINLINE void
43 tdsmIOCompletedCB(
44                   smRoot_t   *smRoot,
45                   smIORequest_t   *smIORequest,
46                   bit32    status,
47                   bit32    statusDetail,
48                   smSenseData_t   *senseData,
49                   bit32    interruptContext
50                   );
51 osGLOBAL void
52 tdsmEventCB(
53                 smRoot_t          *smRoot,
54                 smDeviceHandle_t  *smDeviceHandle,
55                 smIntrEventType_t  eventType,
56                 bit32              eventStatus,
57                 void              *parm
58                 );
59 
60 osGLOBAL FORCEINLINE void
61 tdsmSingleThreadedEnter(
62                         smRoot_t   *smRoot,
63                         bit32       syncLockId
64                        );
65 
66 osGLOBAL FORCEINLINE void
67 tdsmSingleThreadedLeave(
68                         smRoot_t   *smRoot,
69                         bit32       syncLockId
70                         );
71 
72 osGLOBAL FORCEINLINE bit8
73 tdsmBitScanForward(
74                   smRoot_t   *smRoot,
75                   bit32      *Index,
76                   bit32       Mask
77                   );
78 
79 #ifdef LINUX_VERSION_CODE
80 
81 osGLOBAL FORCEINLINE sbit32
82 tdsmInterlockedIncrement(
83                    smRoot_t        *smRoot,
84                    sbit32 volatile *Addend
85                    );
86 
87 osGLOBAL FORCEINLINE sbit32
88 tdsmInterlockedDecrement(
89                    smRoot_t         *smRoot,
90                    sbit32 volatile  *Addend
91                    );
92 
93 osGLOBAL FORCEINLINE sbit32
94 tdsmAtomicBitClear(
95                smRoot_t         *smRoot,
96                sbit32 volatile  *Destination,
97                sbit32            Value
98                );
99 
100 osGLOBAL FORCEINLINE sbit32
101 tdsmAtomicBitSet(
102                smRoot_t         *smRoot,
103                sbit32 volatile  *Destination,
104                sbit32            Value
105                );
106 
107 osGLOBAL FORCEINLINE sbit32
108 tdsmAtomicExchange(
109                smRoot_t        *smRoot,
110                sbit32 volatile *Target,
111                sbit32           Value
112                );
113 #else
114 
115 osGLOBAL FORCEINLINE sbit32
116 tdsmInterlockedIncrement(
117                    smRoot_t        *smRoot,
118                    sbit32 volatile *Addend
119                    );
120 
121 osGLOBAL FORCEINLINE sbit32
122 tdsmInterlockedDecrement(
123                    smRoot_t        *smRoot,
124                    sbit32 volatile *Addend
125                    );
126 
127 osGLOBAL FORCEINLINE sbit32
128 tdsmInterlockedAnd(
129                smRoot_t         *smRoot,
130                sbit32 volatile  *Destination,
131                sbit32            Value
132                );
133 
134 osGLOBAL FORCEINLINE sbit32
135 tdsmInterlockedOr(
136                smRoot_t         *smRoot,
137                sbit32 volatile  *Destination,
138                sbit32            Value
139                );
140 
141 osGLOBAL FORCEINLINE sbit32
142 tdsmInterlockedExchange(
143                smRoot_t        *smRoot,
144                sbit32 volatile *Target,
145                sbit32           Value
146                );
147 
148 #endif /*LINUX_VERSION_CODE*/
149 
150 osGLOBAL bit32
151 tdsmAllocMemory(
152                 smRoot_t    *smRoot,
153                 void        **osMemHandle,
154                 void        ** virtPtr,
155                 bit32       * physAddrUpper,
156                 bit32       * physAddrLower,
157                 bit32       alignment,
158                 bit32       allocLength,
159                 smBOOLEAN   isCacheable
160                );
161 
162 osGLOBAL bit32
163 tdsmFreeMemory(
164                smRoot_t    *smRoot,
165                void        *osDMAHandle,
166                bit32        allocLength
167               );
168 
169 osGLOBAL FORCEINLINE bit32
170 tdsmRotateQnumber(smRoot_t        *smRoot,
171                          smDeviceHandle_t *smDeviceHandle
172                          );
173 
174 osGLOBAL bit32
175 tdsmSetDeviceQueueDepth(smRoot_t      *smRoot,
176                                  smIORequest_t *smIORequest,
177                                  bit32          QueueDepth
178                                  );
179 
180 
181 #ifndef tdsmLogDebugString
182 GLOBAL void tdsmLogDebugString(
183                          smRoot_t     *smRoot,
184                          bit32        level,
185                          char         *string,
186                          void         *ptr1,
187                          void         *ptr2,
188                          bit32        value1,
189                          bit32        value2
190                          );
191 #endif
192 
193 
194 
195 osGLOBAL bit32 tdsmGetTransportParam(
196                         smRoot_t    *smRoot,
197                         char        *key,
198                         char        *subkey1,
199                         char        *subkey2,
200                         char        *subkey3,
201                         char        *subkey4,
202                         char        *subkey5,
203                         char        *valueName,
204                         char        *buffer,
205                         bit32       bufferLen,
206                         bit32       *lenReceived
207                         );
208 
209 #endif  /* TDSMAPI_H */
210 
211