xref: /freebsd/sys/dev/pms/RefTisa/discovery/api/dm.h (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1 /*******************************************************************************
2 **
3 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
4 *
5 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
6 *that the following conditions are met:
7 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8 *following disclaimer.
9 *2. Redistributions in binary form must reproduce the above copyright notice,
10 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
11 *with the distribution.
12 *
13 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
18 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
19 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21 *
22 * $FreeBSD$
23 *
24 ********************************************************************************/
25 /********************************************************************************
26 **
27 *   dm.h
28 *
29 *   Abstract:   This module defines the contants, enum and #define definition used
30 *               by Discovery Moduled (DM).
31 *
32 ********************************************************************************/
33 
34 #ifndef DM_H
35 
36 #define DM_H
37 
38 /*************************************************
39  *   constants for type field in agsaMem_t
40  *************************************************/
41 #define DM_CACHED_MEM                             0x00     /**< CACHED memory type */
42 #define DM_DMA_MEM                                0x01     /**< DMA memory type */
43 #define DM_CACHED_DMA_MEM                         0x02     /**< CACHED DMA memory type */
44 
45 /*************************************************
46  *   constants for API return values
47  *************************************************/
48 #define DM_RC_SUCCESS                             0x00     /**< Successful function return value */
49 #define DM_RC_FAILURE                             0x01     /**< Failed function return value */
50 #define DM_RC_BUSY                                0x02     /**< Busy function return value */
51 #define DM_RC_VERSION_INCOMPATIBLE                0x03     /**< Version miss match */
52 #define DM_RC_VERSION_UNTESTED                    0x04     /**< Version not tested */
53 
54 
55 
56 /*************************************************
57  *   Discovery option
58  *************************************************/
59 #define DM_DISCOVERY_OPTION_FULL_START			0x00     /**< Full discovery */
60 #define DM_DISCOVERY_OPTION_INCREMENTAL_START		0x01     /**< Incremental discovery */
61 #define DM_DISCOVERY_OPTION_ABORT			0x02     /**< Discovery abort */
62 
63 
64 /*************************************************
65  *   Discovery status
66  *************************************************/
67 enum dmDiscoveryState_e
68 {
69   dmDiscCompleted  = 0,
70   dmDiscFailed,
71   dmDiscAborted,
72   dmDiscAbortFailed,
73   dmDiscInProgress,
74   dmDiscAbortInvalid, /* no discovery to abort */
75   dmDiscAbortInProgress, /* abort in progress */
76 
77 };
78 
79 /*************************************************
80  *   Device status
81  *************************************************/
82 enum dmDeviceState_e
83 {
84   dmDeviceNoChange = 0,
85   dmDeviceArrival,
86   dmDeviceRemoval,
87   dmDeviceMCNChange,
88   dmDeviceRateChange,
89 };
90 
91 typedef struct  dmContext_s {
92 		void		*tdData;
93 		void		*dmData;
94 } dmContext_t;
95 
96 typedef struct{
97         bit16	smpTimeout;
98         bit16	it_NexusTimeout;
99         bit16	firstBurstSize;
100         bit8	 flag;
101         bit8	 devType_S_Rate;
102         bit8 	sasAddressHi[4];
103         bit8 	sasAddressLo[4];
104         bit8    initiator_ssp_stp_smp;
105         bit8    target_ssp_stp_smp;
106         /* bit8 - bit14 are set by the user of DM such as TDM for directly attached expander
107            0 - 7; PhyID
108            8: non SMP or not
109            9 - 10: types of expander, valid only when bit8 is set
110                    10b (2): edge expander
111                    11b (3): fanout expander
112            11 - 14: MCN
113         */
114         bit16   ext;
115         bit8    sataDeviceType;
116         bit8    reserved;
117 } dmDeviceInfo_t;
118 
119 
120 typedef struct{
121 	void 	*virtPtr;
122 	void 	*osHandle;
123 	bit32 	physAddrUpper;
124 	bit32 	physAddrLower;
125 	bit32 	totalLength;
126 	bit32 	numElements;
127 	bit32 	singleElementLength;
128 	bit32 	alignment;
129 	bit32 	type;
130 	bit32 	reserved;
131 } dmMem_t;
132 
133 #define DM_NUM_MEM_CHUNKS 8
134 
135 typedef struct{
136 	bit32 		count;
137 	dmMem_t 	dmMemory[DM_NUM_MEM_CHUNKS];
138 } dmMemoryRequirement_t;
139 
140 typedef    dmContext_t    dmPortContext_t;
141 
142 typedef    dmContext_t    dmRoot_t;
143 
144 typedef struct{
145  bit32   numDevHandles;
146  bit32   tbd1;
147  bit32   tbd2;
148 #ifdef DM_DEBUG
149  bit32   DMDebugLevel;
150 #endif
151  bit32   itNexusTimeout;
152 } dmSwConfig_t;
153 
154 typedef struct{
155                bit8  	sasRemoteAddressHi[4];
156                bit8  	sasRemoteAddressLo[4];
157                bit8  	sasLocalAddressHi[4];
158                bit8  	sasLocalAddressLo[4];
159                bit32    flag;
160 } dmPortInfo_t;
161 
162 
163 #endif  /* DM_H */
164