]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/dev/pms/RefTisa/discovery/dm/dmdefs.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / dev / pms / RefTisa / discovery / dm / dmdefs.h
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 #ifndef __DMDEFS_H__
26 #define __DMDEFS_H__
27
28 #include <dev/pms/RefTisa/tisa/sassata/common/ossa.h>
29
30 #define DIRECT_SMP
31 //#undef DIRECT_SMP
32
33 /* the index for memory requirement, must be continious */
34 #define DM_ROOT_MEM_INDEX                          0                       /**< the index of dm root memory */
35 #define DM_PORT_MEM_INDEX                          1                       /**< the index of port context memory */
36 #define DM_DEVICE_MEM_INDEX                        2                       /**< the index of Device descriptors memory */
37 #define DM_EXPANDER_MEM_INDEX                      3                       /**< the index of Expander device descriptors memory */
38 #define DM_SMP_MEM_INDEX                           4                       /**< the index of SMP command descriptors memory */
39 #define DM_INDIRECT_SMP_MEM_INDEX                  5                       /**< the index of Indirect SMP command descriptors memory */
40
41
42
43 #define DM_MAX_NUM_PHYS                         16
44 #define DM_MAX_EXPANDER_PHYS                    256
45 #define DM_MAX_DEV                              2048
46 #define DM_MAX_EXPANDER_DEV                     32
47 #define DM_MAX_PORT_CONTEXT                     16
48 #define DM_MAX_SMP                              32
49 #define DM_MAX_INDIRECT_SMP                     DM_MAX_SMP
50
51 #define DM_USECS_PER_TICK                       1000000                   /**< defines the heart beat of the LL layer 10ms */
52
53 /*
54 *  FIS type 
55 */
56 #define PIO_SETUP_DEV_TO_HOST_FIS   0x5F
57 #define REG_DEV_TO_HOST_FIS         0x34 
58 #define SET_DEV_BITS_FIS            0xA1
59
60 #define DEFAULT_KEY_BUFFER_SIZE     64
61  
62 enum dm_locks_e
63 {
64   DM_PORT_LOCK = 0,
65   DM_DEVICE_LOCK,
66   DM_EXPANDER_LOCK,
67   DM_TIMER_LOCK,
68   DM_SMP_LOCK,
69   DM_MAX_LOCKS
70 };
71 /* default SMP timeout: 0xFFFF is the Maximum Allowed */
72 #define DEFAULT_SMP_TIMEOUT       0xFFFF
73
74 /* SMP direct payload size limit: IOMB direct payload size = 48 */
75 #define SMP_DIRECT_PAYLOAD_LIMIT 44
76
77 #define SMP_INDIRECT_PAYLOAD    512
78
79 /* SMP maximum payload size allowed by SAS spec withtout CRC 4 bytes */
80 #define SMP_MAXIMUM_PAYLOAD      1024
81
82 /*! \def MIN(a,b)
83 * \brief MIN macro
84 *
85 * use to find MIN of two values
86 */
87 #ifndef MIN
88 #define MIN(a,b) ((a) < (b) ? (a) : (b))
89 #endif
90
91 /*! \def MAX(a,b)
92 * \brief MAX macro
93 *
94 * use to find MAX of two values
95 */
96 #ifndef MAX
97 #define MAX(a,b) ((a) < (b) ? (b) : (a))
98 #endif
99
100 #ifndef agNULL
101 #define agNULL     ((void *)0)
102 #endif
103
104 /* for debugging print */
105 #if defined(DM_DEBUG)
106
107 /*
108 * for debugging purposes.  
109 */
110 extern bit32 gDMDebugLevel;
111
112 #define DM_DBG0(format) tddmLogDebugString(gDMDebugLevel, 0, format)
113 #define DM_DBG1(format) tddmLogDebugString(gDMDebugLevel, 1, format)
114 #define DM_DBG2(format) tddmLogDebugString(gDMDebugLevel, 2, format)
115 #define DM_DBG3(format) tddmLogDebugString(gDMDebugLevel, 3, format)
116 #define DM_DBG4(format) tddmLogDebugString(gDMDebugLevel, 4, format)
117 #define DM_DBG5(format) tddmLogDebugString(gDMDebugLevel, 5, format)
118 #define DM_DBG6(format) tddmLogDebugString(gDMDebugLevel, 6, format)
119
120
121 #else
122
123 #define DM_DBG0(format)
124 #define DM_DBG1(format)
125 #define DM_DBG2(format)
126 #define DM_DBG3(format)
127 #define DM_DBG4(format)
128 #define DM_DBG5(format)
129 #define DM_DBG6(format)
130
131 #endif /* DM_DEBUG */
132
133 //#define DM_ASSERT OS_ASSERT
134 //#define tddmLogDebugString TIDEBUG_MSG
135
136 /* discovery related state */
137 #define DM_DSTATE_NOT_STARTED                 0 
138 #define DM_DSTATE_STARTED                     1
139 #define DM_DSTATE_COMPLETED                   2
140 #define DM_DSTATE_COMPLETED_WITH_FAILURE      3
141
142 /* SAS/SATA discovery status */
143 #define DISCOVERY_NOT_START                       0                       /**< status indicates discovery not started */
144 #define DISCOVERY_UP_STREAM                       1                       /**< status indicates discover upstream */
145 #define DISCOVERY_DOWN_STREAM                     2                       /**< status indicates discover downstream */
146 #define DISCOVERY_CONFIG_ROUTING                  3                       /**< status indicates discovery config routing table */
147 #define DISCOVERY_SAS_DONE                        4                       /**< status indicates discovery done */
148 #define DISCOVERY_REPORT_PHY_SATA                 5                       /**< status indicates discovery report phy sata */
149
150 /* SMP function */
151 #define SMP_REPORT_GENERAL                         0x00
152 #define SMP_REPORT_MANUFACTURE_INFORMATION         0x01
153 #define SMP_READ_GPIO_REGISTER                     0x02
154 #define SMP_DISCOVER                               0x10
155 #define SMP_REPORT_PHY_ERROR_LOG                   0x11
156 #define SMP_REPORT_PHY_SATA                        0x12
157 #define SMP_REPORT_ROUTING_INFORMATION             0x13
158 #define SMP_WRITE_GPIO_REGISTER                    0x82
159 #define SMP_CONFIGURE_ROUTING_INFORMATION          0x90
160 #define SMP_PHY_CONTROL                            0x91
161 #define SMP_PHY_TEST_FUNCTION                      0x92
162 #define SMP_PMC_SPECIFIC                           0xC0
163 #define SMP_DISCOVER_LIST                          0x20
164
165
166 /* SMP function results */
167 #define SMP_FUNCTION_ACCEPTED                      0x00
168 #define UNKNOWN_SMP_FUNCTION                       0x01
169 #define SMP_FUNCTION_FAILED                        0x02
170 #define INVALID_REQUEST_FRAME_LENGTH               0x03
171 #define INVALID_EXPANDER_CHANGE_COUNT              0x04
172 #define SMP_FN_BUSY                                0x05
173 #define INCOMPLETE_DESCRIPTOR_LIST                 0x06
174 #define PHY_DOES_NOT_EXIST                         0x10
175 #define INDEX_DOES_NOT_EXIST                       0x11
176 #define PHY_DOES_NOT_SUPPORT_SATA                  0x12
177 #define UNKNOWN_PHY_OPERATION                      0x13
178 #define UNKNOWN_PHY_TEST_FUNCTION                  0x14
179 #define PHY_TEST_FUNCTION_IN_PROGRESS              0x15
180 #define PHY_VACANT                                 0x16
181 #define UNKNOWN_PHY_EVENT_SOURCE                   0x17
182 #define UNKNOWN_DESCRIPTOT_TYPE                    0x18
183 #define UNKNOWN_PHY_FILETER                        0x19
184 #define AFFILIATION_VIOLATION                      0x1A
185 #define SMP_ZONE_VIOLATION                         0x20
186 #define NO_MANAGEMENT_ACCESS_RIGHTS                0x21
187 #define UNKNOWN_ENABLE_DISABLE_ZONING_VALUE        0x22
188 #define ZONE_LOCK_VIOLATION                        0x23
189 #define NOT_ACTIVATED                              0x24
190 #define ZONE_GROUP_OUT_OF_RANGE                    0x25
191 #define NO_PHYSICAL_PRESENCE                       0x26
192 #define SAVING_NOT_SUPPORTED                       0x27
193 #define SOURCE_ZONE_GROUP_DOES_NOT_EXIST           0x28
194 #define DISABLED_PASSWORD_NOT_SUPPORTED            0x29
195
196 /* SMP PHY CONTROL OPERATION */
197 #define SMP_PHY_CONTROL_NOP                        0x00
198 #define SMP_PHY_CONTROL_LINK_RESET                 0x01
199 #define SMP_PHY_CONTROL_HARD_RESET                 0x02
200 #define SMP_PHY_CONTROL_DISABLE                    0x03
201 #define SMP_PHY_CONTROL_CLEAR_ERROR_LOG            0x05
202 #define SMP_PHY_CONTROL_CLEAR_AFFILIATION          0x06
203 #define SMP_PHY_CONTROL_XMIT_SATA_PS_SIGNAL        0x07
204
205 #define DM_VEN_DEV_SPC                               0x80010000
206 #define DM_VEN_DEV_ADAPSPC                           0x80810000
207 #define DM_VEN_DEV_SPCv                              0x80080000
208 #define DM_VEN_DEV_SPCve                             0x80090000
209 #define DM_VEN_DEV_SPCvplus                          0x80180000
210 #define DM_VEN_DEV_SPCveplus                         0x80190000
211 #define DM_VEN_DEV_ADAPvplus                         0x80880000
212 #define DM_VEN_DEV_ADAPveplus                        0x80890000
213
214 #define DMIsSPC(agr)           (DM_VEN_DEV_SPC        == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPC */
215 #define DMIsSPCADAP(agr)       (DM_VEN_DEV_SPC        == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPC */
216 #define DMIsSPCv(agr)          (DM_VEN_DEV_SPCv       == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCv */
217 #define DMIsSPCve(agr)         (DM_VEN_DEV_SPCve      == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCve */
218 #define DMIsSPCvplus(agr)      (DM_VEN_DEV_SPCvplus   == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCv+ */
219 #define DMIsSPCveplus(agr)     (DM_VEN_DEV_SPCveplus  == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCve+ */
220 #define DMIsSPCADAPvplus(agr)  (DM_VEN_DEV_ADAPvplus  == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCv+ */
221 #define DMIsSPCADAPveplus(agr) (DM_VEN_DEV_ADAPveplus == (ossaHwRegReadConfig32(agr,0 ) & 0xFFFF0000) ? 1 : 0) /* returns true config space read is SPCve+ */
222
223 /****************************************************************
224  *            SAS 1.1 Spec
225  ****************************************************************/
226 /* SMP header definition */
227 typedef struct dmSMPFrameHeader_s
228 {
229     bit8   smpFrameType;      /* The first byte of SMP frame represents the SMP FRAME TYPE */ 
230     bit8   smpFunction;       /* The second byte of the SMP frame represents the SMP FUNCTION */
231     bit8   smpFunctionResult; /* The third byte of SMP frame represents FUNCTION RESULT of the SMP response. */
232     bit8   smpReserved;       /* reserved */
233 } dmSMPFrameHeader_t;
234
235 /****************************************************************
236  *            report general request
237  ****************************************************************/
238 #ifdef FOR_COMPLETENESS
239 typedef struct smpReqReportGeneral_s 
240 {
241   /* nothing. some compiler disallowed structure with no member */
242 } smpReqReportGeneral_t; 
243 #endif
244
245 /****************************************************************
246  *            report general response
247  ****************************************************************/
248 #define REPORT_GENERAL_CONFIGURING_BIT     0x2
249 #define REPORT_GENERAL_CONFIGURABLE_BIT    0x1
250 #define REPORT_GENERAL_LONG_RESPONSE_BIT   0x80
251
252 typedef struct smpRespReportGeneral_s
253 {
254   bit8   expanderChangeCount16[2];
255   bit8   expanderRouteIndexes16[2];
256   bit8   reserved1; /* byte 9; has LONG Response for SAS 2 at bit 8 */
257   bit8   numOfPhys;
258   bit8   configuring_configurable;  
259     /* B7-2 : reserved */
260     /* B1   : configuring */
261     /* B0   : configurable */
262   bit8   reserved4[17];
263 } smpRespReportGeneral_t;
264
265 #define REPORT_GENERAL_IS_CONFIGURING(pResp) \
266   (((pResp)->configuring_configurable & REPORT_GENERAL_CONFIGURING_BIT) == \
267       REPORT_GENERAL_CONFIGURING_BIT)
268
269 #define REPORT_GENERAL_IS_CONFIGURABLE(pResp) \
270   (((pResp)->configuring_configurable & REPORT_GENERAL_CONFIGURABLE_BIT) == \
271       REPORT_GENERAL_CONFIGURABLE_BIT)
272
273 #define REPORT_GENERAL_GET_ROUTEINDEXES(pResp) \
274   DMA_BEBIT16_TO_BIT16(*(bit16 *)((pResp)->expanderRouteIndexes16))
275
276 #define REPORT_GENERAL_IS_LONG_RESPONSE(pResp) \
277   (((pResp)->reserved1 & REPORT_GENERAL_LONG_RESPONSE_BIT) == \
278       REPORT_GENERAL_LONG_RESPONSE_BIT)
279             
280 /****************************************************************
281  *            report manufacturer info response
282  ****************************************************************/
283 typedef struct smpRespReportManufactureInfo_s 
284 {
285   bit8    reserved1[8];
286   bit8    vendorIdentification[8];
287   bit8    productIdentification[16];
288   bit8    productRevisionLevel[4];
289   bit8    vendorSpecific[20];
290 } smpRespReportManufactureInfo_t;
291
292 /****************************************************************
293  *           discover request
294  ****************************************************************/
295 typedef struct smpReqDiscover_s 
296 {
297   bit32   reserved1;
298   bit8    reserved2;
299   bit8    phyIdentifier;
300   bit8    ignored;  
301   bit8    reserved3;  
302 } smpReqDiscover_t;
303
304 /****************************************************************
305  *           discover response
306  ****************************************************************/
307 typedef struct smpRespDiscover_s
308 {
309   bit8   reserved1[4];
310   bit8   reserved2;
311   bit8   phyIdentifier;
312   bit8   reserved3[2];  
313   bit8   attachedDeviceType; /* byte 12 */
314     /* B7   : reserved */
315     /* B6-4 : attachedDeviceType */
316     /* B3-0 : reserved */
317   bit8   negotiatedPhyLinkRate; /* byte 11 */
318     /* B7-4 : reserved */
319     /* B3-0 : negotiatedPhyLinkRate */
320   bit8   attached_Ssp_Stp_Smp_Sata_Initiator; /* byte 14 */
321     /* B7-4 : reserved */
322     /* B3   : attachedSspInitiator */
323     /* B2   : attachedStpInitiator */
324     /* B1   : attachedSmpInitiator */
325     /* B0   : attachedSataHost */
326   bit8   attached_SataPS_Ssp_Stp_Smp_Sata_Target; /* byte 15 */
327     /* B7   : attachedSataPortSelector */
328     /* B6-4 : reserved */
329     /* B3   : attachedSspTarget */
330     /* B2   : attachedStpTarget */
331     /* B1   : attachedSmpTarget */
332     /* B0   : attachedSatadevice */
333   bit8   sasAddressHi[4];
334   bit8   sasAddressLo[4];
335   bit8   attachedSasAddressHi[4];
336   bit8   attachedSasAddressLo[4];
337   bit8   attachedPhyIdentifier;
338   bit8   reserved9[7];
339   bit8   programmedAndHardware_MinPhyLinkRate;
340     /* B7-4 : programmedMinPhyLinkRate */
341     /* B3-0 : hardwareMinPhyLinkRate */
342   bit8   programmedAndHardware_MaxPhyLinkRate;
343     /* B7-4 : programmedMaxPhyLinkRate */
344     /* B3-0 : hardwareMaxPhyLinkRate */
345   bit8   phyChangeCount;
346   bit8   virtualPhy_partialPathwayTimeout; /* byte 43 */
347     /* B7   : virtualPhy*/
348     /* B6-4 : reserved */
349     /* B3-0 : partialPathwayTimeout */
350   bit8   routingAttribute;
351     /* B7-4 : reserved */
352     /* B3-0 : routingAttribute */
353   bit8   reserved13[5];
354   bit8   vendorSpecific[2];
355 } smpRespDiscover_t;
356
357 #define DISCRSP_SSP_BIT    0x08
358 #define DISCRSP_STP_BIT    0x04
359 #define DISCRSP_SMP_BIT    0x02
360 #define DISCRSP_SATA_BIT   0x01
361
362 #define DISCRSP_SATA_PS_BIT   0x80
363
364 #define DISCRSP_GET_ATTACHED_DEVTYPE(pResp) \
365   (((pResp)->attachedDeviceType & 0x70) >> 4)
366 #define DISCRSP_GET_LINKRATE(pResp) \
367   ((pResp)->negotiatedPhyLinkRate & 0x0F)
368
369 #define DISCRSP_IS_SSP_INITIATOR(pResp) \
370   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SSP_BIT) == DISCRSP_SSP_BIT)
371 #define DISCRSP_IS_STP_INITIATOR(pResp) \
372   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_STP_BIT) == DISCRSP_STP_BIT)
373 #define DISCRSP_IS_SMP_INITIATOR(pResp) \
374   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SMP_BIT) == DISCRSP_SMP_BIT)
375 #define DISCRSP_IS_SATA_HOST(pResp) \
376   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SATA_BIT) == DISCRSP_SATA_BIT)
377
378 #define DISCRSP_IS_SSP_TARGET(pResp) \
379   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SSP_BIT) == DISCRSP_SSP_BIT)
380 #define DISCRSP_IS_STP_TARGET(pResp) \
381   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_STP_BIT) == DISCRSP_STP_BIT)
382 #define DISCRSP_IS_SMP_TARGET(pResp) \
383   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SMP_BIT) == DISCRSP_SMP_BIT)
384 #define DISCRSP_IS_SATA_DEVICE(pResp) \
385   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SATA_BIT) == DISCRSP_SATA_BIT)
386 #define DISCRSP_IS_SATA_PORTSELECTOR(pResp) \
387   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SATA_PS_BIT) == DISCRSP_SATA_PS_BIT)
388
389 /* bit8 array[4] -> bit32 */
390 #define DISCRSP_GET_SAS_ADDRESSHI(pResp) \
391   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->sasAddressHi)
392 #define DISCRSP_GET_SAS_ADDRESSLO(pResp) \
393   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->sasAddressLo)
394
395 /* bit8 array[4] -> bit32 */
396 #define DISCRSP_GET_ATTACHED_SAS_ADDRESSHI(pResp) \
397   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->attachedSasAddressHi)
398 #define DISCRSP_GET_ATTACHED_SAS_ADDRESSLO(pResp) \
399   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->attachedSasAddressLo)
400
401 #define DISCRSP_VIRTUALPHY_BIT 0x80
402 #define DISCRSP_IS_VIRTUALPHY(pResp) \
403   (((pResp)->virtualPhy_partialPathwayTimeout & DISCRSP_VIRTUALPHY_BIT) == DISCRSP_VIRTUALPHY_BIT)
404
405 #define DISCRSP_GET_ROUTINGATTRIB(pResp) \
406   ((pResp)->routingAttribute & 0x0F)
407
408 /****************************************************************
409  *            report route table request
410  ****************************************************************/
411 typedef struct smpReqReportRouteTable_s
412 {
413   bit8   reserved1[2];
414   bit8   expanderRouteIndex16[20];
415   bit8   reserved2;
416   bit8   phyIdentifier;
417   bit8   reserved3[2];
418 } smpReqReportRouteTable_t;
419
420 /****************************************************************
421  *            report route response
422  ****************************************************************/
423 typedef struct smpRespReportRouteTable_s 
424 {
425   bit8   reserved1[2];
426   bit8   expanderRouteIndex16[2];
427   bit8   reserved2;
428   bit8   phyIdentifier;
429   bit8   reserved3[2];
430   bit8   disabled;
431     /* B7   : expander route entry disabled */
432     /* B6-0 : reserved */
433   bit8   reserved5[3];
434   bit8   routedSasAddressHi32[4];
435   bit8   routedSasAddressLo32[4];
436   bit8   reserved6[16];
437 } smpRespReportRouteTable_t;
438
439 /****************************************************************
440  *            configure route information request
441  ****************************************************************/
442 typedef struct smpReqConfigureRouteInformation_s
443 {
444   bit8   reserved1[2];
445   bit8   expanderRouteIndex[2];
446   bit8   reserved2;
447   bit8   phyIdentifier;
448   bit8   reserved3[2];
449   bit8   disabledBit_reserved4;
450   bit8   reserved5[3];
451   bit8   routedSasAddressHi[4];
452   bit8   routedSasAddressLo[4];
453   bit8   reserved6[16];
454 } smpReqConfigureRouteInformation_t;
455
456 /****************************************************************
457  *            configure route response
458  ****************************************************************/
459 #ifdef FOR_COMPLETENESS
460 typedef struct smpRespConfigureRouteInformation_s 
461 {
462   /* nothing. some compiler disallowed structure with no member */
463 } smpRespConfigureRouteInformation_t;
464 #endif
465
466 /****************************************************************
467  *            report Phy Sata request
468  ****************************************************************/
469 typedef struct smpReqReportPhySata_s
470 {
471   bit8   reserved1[4];
472   bit8   reserved2;
473   bit8   phyIdentifier;
474   bit8   reserved3[2];
475 } smpReqReportPhySata_t;
476
477 /****************************************************************
478  *            report Phy Sata response
479  ****************************************************************/
480 typedef struct smpRespReportPhySata_s 
481 {
482   bit8   reserved1[4];
483   bit8   reserved2;
484   bit8   phyIdentifier;
485   bit8   reserved3;
486   bit8   affiliations_sup_valid;
487     /* b7-2 : reserved */
488     /* b1   : Affiliations supported */
489     /* b0   : Affiliation valid */
490   bit8   reserved5[4];
491   bit8   stpSasAddressHi[4];
492   bit8   stpSasAddressLo[4];
493   bit8   regDevToHostFis[20];
494   bit8   reserved6[4];
495   bit8   affiliatedStpInitiatorSasAddressHi[4];
496   bit8   affiliatedStpInitiatorSasAddressLo[4];
497 } smpRespReportPhySata_t;
498
499
500 /****************************************************************
501  *            Phy Control request
502  ****************************************************************/
503 typedef struct smpReqPhyControl_s
504 {
505   bit8   reserved1[4];
506   bit8   reserved2;
507   bit8   phyIdentifier;
508   bit8   phyOperation;
509   bit8   updatePartialPathwayTOValue;
510     /* b7-1 : reserved */
511     /* b0   : update partial pathway timeout value */
512   bit8   reserved3[20];
513   bit8   programmedMinPhysicalLinkRate;
514     /* b7-4 : programmed Minimum Physical Link Rate*/
515     /* b3-0 : reserved */
516   bit8   programmedMaxPhysicalLinkRate;
517     /* b7-4 : programmed Maximum Physical Link Rate*/
518     /* b3-0 : reserved */
519   bit8   reserved4[2];
520   bit8   partialPathwayTOValue;
521     /* b7-4 : reserved */
522     /* b3-0 : partial Pathway TO Value */
523   bit8   reserved5[3];
524 } smpReqPhyControl_t;
525
526 /****************************************************************
527  *            Phy Control response
528  ****************************************************************/
529 #ifdef FOR_COMPLETENESS
530 typedef struct smpRespPhyControl_s 
531 {
532   /* nothing. some compiler disallowed structure with no member */
533 } smpRespPhyControl_t;
534 #endif
535
536
537 /****************************************************************
538  *            SAS 2 Rev 14c Spec
539  ****************************************************************/
540 /* SMP header definition */
541 typedef struct tdssSMPFrameHeader2_s
542 {
543     bit8   smpFrameType;      /* The first byte of SMP frame represents the SMP FRAME TYPE */ 
544     bit8   smpFunction;       /* The second byte of the SMP frame represents the SMP FUNCTION */
545     bit8   smpAllocLenFuncResult; /* The third byte of SMP frame represents ALLOCATED RESPONSE LENGTH of SMP request or FUNCTION RESULT of the SMP response. */
546     bit8   smpReqResLen;       /* The third byte of SMP frame represents REQUEST LENGTH of SMP request or RESPONSE LENGTH of the SMP response. */
547 } tdssSMPFrameHeader2_t;
548
549 /****************************************************************
550  *            report general request
551  ****************************************************************/
552 #ifdef FOR_COMPLETENESS
553 typedef struct smpReqReportGeneral2_s 
554 {
555   /* nothing. some compiler disallowed structure with no member */
556 } smpReqReportGeneral2_t; 
557 #endif
558
559 /****************************************************************
560  *            report general response
561  ****************************************************************/
562 #define REPORT_GENERAL_TABLE_TO_TABLE_SUPPORTED_BIT   0x80
563 #define REPORT_GENERAL_CONFIGURES_OTHERS_BIT          0x04
564
565 typedef struct smpRespReportGeneral2_s
566 {
567   bit8   expanderChangeCount16[2]; /* byte 4-5 */
568   bit8   expanderRouteIndexes16[2]; /* byte 6-7 */
569   bit8   LongResponse; /* byte 8 */
570   /* B7: LongResponse */
571   /* B6-0: Reserved */ 
572   bit8   numOfPhys; /* byte 9 */
573   bit8   byte10; 
574     /* B7   : TABLE TO TABLE SUPPORTED */
575     /* B6   : ZONE CONFIGURING */
576     /* B5   : SELF CONFIGURING */
577     /* B4   : STP CONTINUE AWT */
578     /* B3   : OPEN REJECT RETRY SUPPORTED */
579     /* B2   : CONFIGURES OTHERS */
580     /* B1   : CONFIGURING */
581     /* B0   : EXTERNALLY CONFIGURABLE ROUTE TABLE  */
582   bit8   reserved1; /* byte11 */
583   bit8   EnclosureLogicalID[8];
584   bit8   reserved2[8]; /* upto byte27; Spec 1.1 */
585   bit8   reserved3[2];
586   bit8   STPBusInactivityTimeLimit[2];
587   bit8   STPMaxConnectTimeLimit[2]; /* byte33 */
588   bit8   STPSMPI_TNexusLossTime[2]; /* byte35 */
589   bit8   byte36;
590     /* B7-6 : NUMBER OF ZONE GROUPS */
591     /* B5   : RESERVED */
592     /* B4   : ZONE LOCKED */
593     /* B3   : PHYSICAL PRESENCE SUPPORTED */
594     /* B2   : PHYSICAL PRESENCE ASSERTED */
595     /* B1   : ZONING SUPPORTED */
596     /* B0   : ZONING ENABLED */
597   bit8   byte37;
598     /* B7-5 : RESERVED */
599     /* B4   : SAVING */
600     /* B3   : SAVING ZONE MANAGER PASSWORD SUPPORTED */
601     /* B2   : SAVING ZONE PHY INFORMATION SUPPORTED   */
602     /* B1   : SAVING ZONE PERMISSION TABLE SUPPORTED */
603     /* B0   : SAVING ZONING ENABLED SUPPORTED */
604   bit8   MaxNumOfRoutedSASAddr[2]; /* byte39 */
605   bit8   ActiveZoneManagerSASAddr[8]; /* byte47 */
606   bit8   ZoneLockInactivityTimeLimit[2]; /* byte49 */  
607   bit8   reserved4[2];
608   bit8   reserved5; /* byte52 */
609   bit8   FirstEnclosureConnectorElementIdx; /* byte53 */  
610   bit8   NumOfEnclosureConnectorElementIdxs; /* byte54 */  
611   bit8   reserved6; /* byte55 */
612   bit8   ReducedFunctionality;
613   /* B7: ReducedFunctionality */
614   /* B6-0: Reserved */
615   bit8   TimeToReducedFunctionality;
616   bit8   InitialTimeToReducedFunctionality;
617   bit8   MaxReducedFunctionalityTime; /* byte59 */
618   bit8   LastSelfConfigurationStatusDescIdx[2];
619   bit8   MaxNumOfStoredSelfConfigurationStatusDesc[2];
620   bit8   LastPhyEventListDescIdx[2];
621   bit8   MaxNumbOfStoredPhyEventListDesc[2]; /* byte67 */
622   bit8   STPRejectToOpenLimit[2]; /* byte69 */
623   bit8   reserved7[2]; /* byte71 */
624     
625 } smpRespReportGeneral2_t;
626
627 #define SAS2_REPORT_GENERAL_GET_ROUTEINDEXES(pResp) \
628   DMA_BEBIT16_TO_BIT16(*(bit16 *)((pResp)->expanderRouteIndexes16))
629
630 #define SAS2_REPORT_GENERAL_IS_CONFIGURING(pResp) \
631   (((pResp)->byte10 & REPORT_GENERAL_CONFIGURING_BIT) == \
632       REPORT_GENERAL_CONFIGURING_BIT)
633
634 #define SAS2_REPORT_GENERAL_IS_CONFIGURABLE(pResp) \
635   (((pResp)->byte10 & REPORT_GENERAL_CONFIGURABLE_BIT) == \
636       REPORT_GENERAL_CONFIGURABLE_BIT)
637
638 #define SAS2_REPORT_GENERAL_IS_TABLE_TO_TABLE_SUPPORTED(pResp) \
639   (((pResp)->byte10 & REPORT_GENERAL_TABLE_TO_TABLE_SUPPORTED_BIT) == \
640       REPORT_GENERAL_TABLE_TO_TABLE_SUPPORTED_BIT)
641
642 #define SAS2_REPORT_GENERAL_IS_CONFIGURES_OTHERS(pResp) \
643   (((pResp)->byte10 & REPORT_GENERAL_CONFIGURES_OTHERS_BIT) == \
644       REPORT_GENERAL_CONFIGURES_OTHERS_BIT)
645
646 /****************************************************************
647  *            report manufacturer info request
648  ****************************************************************/
649 #ifdef FOR_COMPLETENESS
650 typedef struct smpReqReportManufactureInfo2_s 
651 {
652   /* nothing. some compiler disallowed structure with no member */
653 } smpReqReportManufactureInfo2_t; 
654 #endif
655
656 /****************************************************************
657  *            report manufacturer info response
658  ****************************************************************/
659 typedef struct smpRespReportManufactureInfo2_s 
660 {
661   bit16   ExpanderChangeCount; /* byte 4-5 */
662   bit8    reserved1[2]; /* byte 6-7 */
663   bit8    SAS11Format; /* byte 8 */
664     /* B7-1 : RESERVED */
665     /* B0   : SAS-1.1 Format */
666   bit8    reserved2[3]; /* byte 9-11 */
667   bit8    vendorIdentification[8]; /* byte 12-19 */
668   bit8    productIdentification[16]; /* byte 20-35 */
669   bit8    productRevisionLevel[4]; /* byte 36-39 */
670   bit8    componentVendorID[8]; /* byte 40-47 */
671   bit8    componentID[2]; /* byte 48-49 */
672   bit8    componentRevisionLevel; /* byte 50 */
673   bit8    reserved3; /* byte 51 */
674   bit8    vendorSpecific[8]; /* byte 52-59 */
675 } smpRespReportManufactureInfo2_t;
676
677 /****************************************************************
678  *           discover request
679  ****************************************************************/
680 typedef struct smpReqDiscover2_s 
681 {
682   bit32   reserved1; /* byte 4 - 7 */
683   bit8    IgnoreZoneGroup; /* byte 8 */
684   bit8    phyIdentifier; /* byte 9 */
685   bit16   reserved2;  /* byte 10 - 11*/
686 } smpReqDiscover2_t;
687
688 /****************************************************************
689  *           discover response
690  ****************************************************************/
691 typedef struct smpRespDiscover2_s
692 {
693   bit16  ExpanderChangeCount; /* byte 4 - 5 */
694   bit8   reserved1[3]; /* byte 6 - 8 */
695   bit8   phyIdentifier; /* byte 9 */
696   bit8   reserved2[2]; /* byte 10 - 11 */
697   bit8   attachedDeviceTypeReason; /* byte 12 */
698     /* B7   : RESERVED */
699     /* B6-4 : Attached Device Type */
700     /* B3-0 : Attached Reason */
701   bit8   NegotiatedLogicalLinkRate; /* byte 13 */
702     /* B7-4 : RESERVED */
703     /* B3-0 : Negotiated Logical Link Rate */
704   bit8   attached_Ssp_Stp_Smp_Sata_Initiator; /* byte 14 */
705     /* B7-4 : reserved */
706     /* B3   : attached SSP Initiator */
707     /* B2   : attached STP Initiator */
708     /* B1   : attached SMP Initiator */
709     /* B0   : attached SATA Host */
710   bit8   attached_SataPS_Ssp_Stp_Smp_Sata_Target; /* byte 15 */
711     /* B7   : attached SATA Port Selector */
712     /* B6-4 : reserved */
713     /* B3   : attached SSP Target */
714     /* B2   : attached STP Target */
715     /* B1   : attached SMP Target */
716     /* B0   : attached SATA device */
717   bit8   sasAddressHi[4]; /* byte 16 - 19 */
718   bit8   sasAddressLo[4]; /* byte 20 - 23 */
719   bit8   attachedSasAddressHi[4]; /* byte 24 - 27 */
720   bit8   attachedSasAddressLo[4]; /* byte 28 - 31 */
721   bit8   attachedPhyIdentifier; /* byte 32 */
722   bit8   byte33; /* byte 33 */
723     /* B7-3   : reserved */
724     /* B2   : attached Inside ZPSDS Persistent */
725     /* B1   : attached Requested Inside ZPSDS */
726     /* B0   : attached Break Reply Capable */
727   bit8   reserved3[6]; /* byte 34 - 39; for indentify address frame related fields */
728   bit8   programmedAndHardware_MinPhyLinkRate; /* byte 40 */
729     /* B7-4 : programmedMinPhyLinkRate */
730     /* B3-0 : hardwareMinPhyLinkRate */
731   bit8   programmedAndHardware_MaxPhyLinkRate; /* byte 41 */
732     /* B7-4 : programmedMaxPhyLinkRate */
733     /* B3-0 : hardwareMaxPhyLinkRate */
734   bit8   phyChangeCount;  /* byte 42 */
735   bit8   virtualPhy_partialPathwayTimeout; /* byte 43 */
736     /* B7   : virtualPhy*/
737     /* B6-4 : reserved */
738     /* B3-0 : partialPathwayTimeout */
739   bit8   routingAttribute; /* byte 44 */
740     /* B7-4 : reserved */
741     /* B3-0 : routingAttribute */
742   bit8   ConnectorType; /* byte 45 */
743     /* B7   : reserved */
744     /* B6-0 : Connector Type */
745   bit8   ConnectorElementIndex; /* byte 46 */
746   bit8   ConnectorPhysicalLink; /* byte 47 */
747   bit8   reserved4[2]; /* byte 48 - 49 */
748   bit8   vendorSpecific[2]; /* byte 50 - 51*/
749   bit8   AttachedDeviceName[8]; /* byte 52 - 59*/
750   bit8   byte60; /* byte 60 */
751     /* B7   : reserved */
752     /* B6   : Requested Inside ZPSDS Changed By Expander */
753     /* B5   : Inside ZPSDS Persistent */
754     /* B4   : Requested Inside ZPSDS */
755     /* B3   : reserved */
756     /* B2   : Zone Group Persistent */
757     /* B1   : Inside ZPSDS */
758     /* B0   : Zoning Enabled */
759   bit8   reserved5[2]; /* byte 61 - 62; zoning-related fields */
760   bit8   ZoneGroup; /* byte 63 */
761   bit8   SelfCongfiguringStatus; /* byte 64 */
762   bit8   SelfCongfigurationLevelsCompleted; /* byte 65 */
763   bit8   reserved6[2]; /* byte 66 - 67; self configuration related fields */
764   bit8   SelfConfigurationSASAddressHi[4]; /* byte 68 - 71 */
765   bit8   SelfConfigurationSASAddressLo[4]; /* byte 72 - 75 */
766   bit8   ProgrammedphyCapabilities[4]; /* byte 76 - 79 */
767   bit8   CurrentphyCapabilities[4]; /* byte 80 - 83 */
768   bit8   AttachedphyCapabilities[4]; /* byte 84 - 87 */
769   bit8   reserved7[6]; /* byte 88 - 93 */
770   bit8   ReasonNegotiatedPhysicalLinkRate; /* byte 94 */
771   bit8   NegotiatedSSCHWMuxingSupported; /* byte 95 */
772     /* B7-2 : reserved */
773     /* B1   : Negotiated SSC */
774     /* B0   : HW Muxing Supported */
775   bit8   byte96; /* byte 96 */
776     /* B7-6 : reserved */
777     /* B5   : Default Inside ZPSDS Persistent */
778     /* B4   : Default Requested Inside ZPSDS */
779     /* B3   : reserved */
780     /* B2   : Default Zone Group Persistent */
781     /* B1   : reserved */
782     /* B0   : Default Zoning Enabled */
783   bit8   reserved8; /* byte 97 */
784   bit8   reserved9; /* byte 98 */
785   bit8   DefaultZoneGroup; /* byte 99 */
786   bit8   byte100; /* byte 100 */
787     /* B7-6 : reserved */
788     /* B5   : Saved Inside ZPSDS Persistent */
789     /* B4   : Saved Requested Inside ZPSDS */
790     /* B3   : reserved */
791     /* B2   : Saved Zone Group Persistent */
792     /* B1   : reserved */
793     /* B0   : Saved Zoning Enabled */
794   bit8   reserved10; /* byte 101 */
795   bit8   reserved11; /* byte 102 */
796   bit8   SavedZoneGroup; /* byte 103 */
797   bit8   byte104; /* byte 104 */
798     /* B7-6 : reserved */
799     /* B5   : Shadow Inside ZPSDS Persistent */
800     /* B4   : Shadow Requested Inside ZPSDS */
801     /* B3   : reserved */
802     /* B2   : Shadow Zone Group Persistent */
803     /* B1-0 : reserved */
804   bit8   reserved12; /* byte 105 */
805   bit8   reserved13; /* byte 106 */
806   bit8   ShadowZoneGroup; /* byte 107 */
807   bit8   DeviceSlotNumber; /* byte 108 */
808   bit8   GroupNumber; /* byte 109 */
809   bit16  PathToEnclosure; /* byte 110 - 111 */
810    
811 } smpRespDiscover2_t;
812
813 #define SAS2_DISCRSP_SSP_BIT    0x08
814 #define SAS2_DISCRSP_STP_BIT    0x04
815 #define SAS2_DISCRSP_SMP_BIT    0x02
816 #define SAS2_DISCRSP_SATA_BIT   0x01
817
818 #define SAS2_DISCRSP_SATA_PS_BIT   0x80
819
820 #define SAS2_MUXING_SUPPORTED   0x01
821
822 #define SAS2_DISCRSP_GET_ATTACHED_DEVTYPE(pResp) \
823   (((pResp)->attachedDeviceTypeReason & 0x70) >> 4)
824 #define SAS2_DISCRSP_GET_LINKRATE(pResp) \
825   ((pResp)->ReasonNegotiatedPhysicalLinkRate & 0x0F)
826 #define SAS2_DISCRSP_GET_LOGICAL_LINKRATE(pResp) \
827   ((pResp)->NegotiatedLogicalLinkRate & 0x0F)
828
829 #define SAS2_DISCRSP_IS_SSP_INITIATOR(pResp) \
830   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SSP_BIT) == DISCRSP_SSP_BIT)
831 #define SAS2_DISCRSP_IS_STP_INITIATOR(pResp) \
832   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_STP_BIT) == DISCRSP_STP_BIT)
833 #define SAS2_DISCRSP_IS_SMP_INITIATOR(pResp) \
834   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SMP_BIT) == DISCRSP_SMP_BIT)
835 #define SAS2_DISCRSP_IS_SATA_HOST(pResp) \
836   (((pResp)->attached_Ssp_Stp_Smp_Sata_Initiator & DISCRSP_SATA_BIT) == DISCRSP_SATA_BIT)
837
838 #define SAS2_DISCRSP_IS_SSP_TARGET(pResp) \
839   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SSP_BIT) == DISCRSP_SSP_BIT)
840 #define SAS2_DISCRSP_IS_STP_TARGET(pResp) \
841   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_STP_BIT) == DISCRSP_STP_BIT)
842 #define SAS2_DISCRSP_IS_SMP_TARGET(pResp) \
843   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SMP_BIT) == DISCRSP_SMP_BIT)
844 #define SAS2_DISCRSP_IS_SATA_DEVICE(pResp) \
845   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SATA_BIT) == DISCRSP_SATA_BIT)
846 #define SAS2_DISCRSP_IS_SATA_PORTSELECTOR(pResp) \
847   (((pResp)->attached_SataPS_Ssp_Stp_Smp_Sata_Target & DISCRSP_SATA_PS_BIT) == DISCRSP_SATA_PS_BIT)
848
849 #define SAS2_DISCRSP_GET_SAS_ADDRESSHI(pResp) \
850   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->sasAddressHi)
851 #define SAS2_DISCRSP_GET_SAS_ADDRESSLO(pResp) \
852   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->sasAddressLo)
853
854 #define SAS2_DISCRSP_GET_ATTACHED_SAS_ADDRESSHI(pResp) \
855   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->attachedSasAddressHi)
856 #define SAS2_DISCRSP_GET_ATTACHED_SAS_ADDRESSLO(pResp) \
857   DMA_BEBIT32_TO_BIT32(*(bit32 *)(pResp)->attachedSasAddressLo)
858
859 #define SAS2_DISCRSP_VIRTUALPHY_BIT 0x80
860 #define SAS2_DISCRSP_IS_VIRTUALPHY(pResp) \
861   (((pResp)->virtualPhy_partialPathwayTimeout & DISCRSP_VIRTUALPHY_BIT) == DISCRSP_VIRTUALPHY_BIT)
862
863 #define SAS2_DISCRSP_GET_ROUTINGATTRIB(pResp) \
864   ((pResp)->routingAttribute & 0x0F)
865
866 #define SAS2_DISCRSP_IS_MUXING_SUPPORTED(pResp) \
867   (((pResp)->NegotiatedSSCHWMuxingSupported & SAS2_MUXING_SUPPORTED) == SAS2_MUXING_SUPPORTED)
868   
869 /****************************************************************
870  *           discover list request
871  ****************************************************************/
872 typedef struct smpReqDiscoverList2_s 
873 {
874   bit32   reserved1; /* byte 4 - 7 */
875   bit8    StartingPhyID; /* byte 8 */
876   bit8    MaxNumDiscoverDesc; /* byte 9 */
877   bit8    byte10;  /* byte 10 */
878     /* B7   : Ignore Zone Group */
879     /* B6-4 : Reserved */
880     /* B3-0 : Phy Filter */
881   bit8    byte11;  /* byte 11 */
882     /* B7-4 : Reserved */
883     /* B6-4 : Descriptor Type */
884   bit32   reserved2; /* byte 12 - 15 */
885   bit8    VendorSpecific[12]; /* byte 16 - 27 */
886 } smpReqDiscoverList2_t;
887
888
889
890 /****************************************************************
891  *           discover list response
892  ****************************************************************/
893 typedef struct smpRespDiscoverList2_s 
894 {
895   bit16   ExpanderChangeCount; /* byte 4 - 5 */
896   bit16   reserved1; /* byte 6 - 7 */
897   bit8    StartingPhyID; /* byte 8 */
898   bit8    MaxNumDiscoverDesc; /* byte 9 */
899   bit8    byte10;  /* byte 10 */
900     /* B7-4 : Reserved */
901     /* B3-0 : Phy Filter */
902   bit8    byte11;  /* byte 11 */
903     /* B7-4 : Reserved */
904     /* B6-4 : Descriptor Type */
905   bit8    DescLen;  /* byte 12 */
906   bit8    reserved2; /* byte 13 */
907   bit16   reserved3; /* byte 14 - 15 */
908   bit8    byte16; /* byte 16 */
909     /* B7   : Zoning Supported */
910     /* B6   : Zoning Enabled */
911     /* B5-4 : Reserved */
912     /* B3   : Self Configuring */
913     /* B2   : Zone Configuring */
914     /* B1   : Configuring */
915     /* B0   : Externally Configurable Route Table */
916   bit8    reserved4; /* byte 17 */
917   bit16   LastDescIdx; /* byte 18 - 19 */
918   bit16   LastPhyDescIdx; /* byte 20 - 21 */
919   bit8    reserved5[10]; /* byte 22 - 31 */
920   bit8    VendorSpecific[16]; /* byte 32 - 47 */
921 } smpRespDiscoverList2_t;
922
923
924
925 /****************************************************************
926  *            report route table request
927  ****************************************************************/
928 typedef struct smpReqReportRouteTable2_s
929 {
930   bit8   reserved1[2]; /* byte 4 - 5 */
931   bit8   expanderRouteIndex16[20]; /* byte 6- 7 */
932   bit8   reserved2; /* byte 8 */
933   bit8   phyIdentifier; /* byte 9 */
934   bit8   reserved3[2]; /* byte 10 -11  */
935 } smpReqReportRouteTable2_t;
936
937 /****************************************************************
938  *            report route response
939  ****************************************************************/
940 typedef struct smpRespReportRouteTable2_s 
941 {
942   bit16  expanderChangeCount; /* byte 4 - 5 */
943   bit16  expanderRouteIndex; /* byte 6 - 7 */
944   bit8   reserved1; /* byte 8 */
945   bit8   phyIdentifier; /* byte 9 */
946   bit8   reserved2[2]; /* byte 10 - 11 */
947   bit8   disabledBit_reserved3; /* byte 12 */
948     /* B7   : Expander Route Entry Disabled */
949     /* B6-0 : reserved */
950   bit8   reserved4[3]; /* byte 13-15 */
951   bit8   routedSasAddressHi[4]; /* byte 16-19 */
952   bit8   routedSasAddressLo[4]; /* byte 20-23 */
953   bit8   reserved5[16]; /* byte 24-39 */
954 } smpRespReportRouteTable2_t;
955
956 /****************************************************************
957  *            configure route information request
958  ****************************************************************/
959 typedef struct smpReqConfigureRouteInformation2_s
960 {
961   bit16  expectedExpanderChangeCount; /* byte 4-5 */
962   bit16  expanderRouteIndex; /* byte 6-7 */
963   bit8   reserved1; /* byte 8 */
964   bit8   phyIdentifier; /* byte 9 */
965   bit8   reserved2[2]; /* byte 10-11 */
966   bit8   disabledBit_reserved3; /* byte 12 */
967     /* B7   : Expander Route Entry Disabled */
968     /* B6-0 : reserved */
969   bit8   reserved4[3]; /* byte 13-15 */
970   bit8   routedSasAddressHi[4]; /* byte 16-19 */
971   bit8   routedSasAddressLo[4]; /* byte 20-23 */
972   bit8   reserved5[16]; /* byte 24-39 */
973 } smpReqConfigureRouteInformation2_t;
974
975 /****************************************************************
976  *            configure route response
977  ****************************************************************/
978 #ifdef FOR_COMPLETENESS
979 typedef struct smpRespConfigureRouteInformation2_s 
980 {
981   /* nothing. some compiler disallowed structure with no member */
982 } smpRespConfigureRouteInformation2_t;
983 #endif
984
985 /****************************************************************
986  *            report Phy Sata request
987  ****************************************************************/
988 typedef struct smpReqReportPhySata2_s
989 {
990   bit8   reserved1[5]; /* byte 4-8 */
991   bit8   phyIdentifier; /* byte 9 */
992   bit8   AffiliationContext; /* byte 10 */
993   bit8   reserved2; /* byte 11 */
994 } smpReqReportPhySata2_t;
995
996 /****************************************************************
997  *            report Phy Sata response
998  ****************************************************************/
999 typedef struct smpRespReportPhySata2_s 
1000 {
1001   bit16  expanderChangeCount; /* byte 4-5 */
1002   bit8   reserved1[3]; /* byte 6-8 */
1003   bit8   phyIdentifier; /* byte 9 */
1004   bit8   reserved2; /* byte 10 */
1005   bit8   byte11; /* byte 11 */
1006     /* b7-3 : reserved */
1007     /* b2   : STP I_T Nexus Loss Occurred */
1008     /* b1   : Affiliations supported */
1009     /* b0   : Affiliation valid */
1010   bit8   reserved3[4]; /* byte 12-15 */
1011   bit8   stpSasAddressHi[4]; /* byte 16-19 */
1012   bit8   stpSasAddressLo[4]; /* byte 20-23 */
1013   bit8   regDevToHostFis[20]; /* byte 24-43 */
1014   bit8   reserved4[4]; /* byte 44-47 */
1015   bit8   affiliatedStpInitiatorSasAddressHi[4]; /* byte 48-51 */
1016   bit8   affiliatedStpInitiatorSasAddressLo[4]; /* byte 52-55 */
1017   bit8   STPITNexusLossSASAddressHi[4]; /* byte 56-59 */
1018   bit8   STPITNexusLossSASAddressLo[4]; /* byte 60-63 */
1019   bit8   reserved5; /* byte 64 */
1020   bit8   AffiliationContext; /* byte 65 */
1021   bit8   CurrentAffiliationContexts; /* byte 66 */
1022   bit8   MaxAffiliationContexts; /* byte 67 */
1023   
1024 } smpRespReportPhySata2_t;
1025
1026 /****************************************************************
1027  *            Phy Control request
1028  ****************************************************************/
1029 typedef struct smpReqPhyControl2_s
1030 {
1031   bit16  expectedExpanderChangeCount; /* byte 4-5 */
1032   bit8   reserved1[3]; /* byte 6-8 */
1033   bit8   phyIdentifier; /* byte 9 */
1034   bit8   phyOperation; /* byte 10 */
1035   bit8   updatePartialPathwayTOValue; /* byte 11 */
1036     /* b7-1 : reserved */
1037     /* b0   : update partial pathway timeout value */
1038   bit8   reserved2[12]; /* byte 12-23 */
1039   bit8   AttachedDeviceName[8]; /* byte 24-31 */
1040   bit8   programmedMinPhysicalLinkRate; /* byte 32 */
1041     /* b7-4 : programmed Minimum Physical Link Rate*/
1042     /* b3-0 : reserved */
1043   bit8   programmedMaxPhysicalLinkRate; /* byte 33 */
1044     /* b7-4 : programmed Maximum Physical Link Rate*/
1045     /* b3-0 : reserved */
1046   bit8   reserved3[2]; /* byte 34-35 */
1047   bit8   partialPathwayTOValue; /* byte 36 */
1048     /* b7-4 : reserved */
1049     /* b3-0 : partial Pathway TO Value */
1050   bit8   reserved4[3]; /* byte 37-39 */
1051   
1052 } smpReqPhyControl2_t;
1053
1054 /****************************************************************
1055  *            Phy Control response
1056  ****************************************************************/
1057 #ifdef FOR_COMPLETENESS
1058 typedef struct smpRespPhyControl2_s 
1059 {
1060   /* nothing. some compiler disallowed structure with no member */
1061 } smpRespPhyControl2_t;
1062 #endif
1063
1064 #define SMP_REQUEST        0x40
1065 #define SMP_RESPONSE       0x41
1066
1067 /* bit8 array[4] -> bit32 */
1068 #define DM_GET_SAS_ADDRESSLO(sasAddressLo)                  \
1069     DMA_BEBIT32_TO_BIT32(*(bit32 *)sasAddressLo)
1070
1071 #define DM_GET_SAS_ADDRESSHI(sasAddressHi)                  \
1072     DMA_BEBIT32_TO_BIT32(*(bit32 *)sasAddressHi)
1073
1074
1075 #define DM_GET_LINK_RATE(input) (input & 0x0F)
1076
1077 #define DM_SAS_CONNECTION_RATE_1_5G                       0x08
1078 #define DM_SAS_CONNECTION_RATE_3_0G                       0x09
1079 #define DM_SAS_CONNECTION_RATE_6_0G                       0x0A
1080 #define DM_SAS_CONNECTION_RATE_12_0G                      0x0B
1081
1082 #define DISCOVERY_CONFIGURING_TIMER_VALUE (3 * 1000 * 1000)       /* 3 seconds */
1083 #define DISCOVERY_RETRIES                  3
1084 #define CONFIGURE_ROUTE_TIMER_VALUE       (1 * 1000 * 1000)       /* 1 seconds */
1085 #define DEVICE_REGISTRATION_TIMER_VALUE   (2 * 1000 * 1000)       /* 2 seconds */
1086 #define SMP_RETRIES                        5
1087 #define SMP_BUSY_TIMER_VALUE              (1 * 1000 * 1000)       /* 1 second */
1088 #define SMP_BUSY_RETRIES                   5
1089 #define SATA_ID_DEVICE_DATA_TIMER_VALUE   (3 * 1000 * 1000)       /* 3 second */
1090 #define SATA_ID_DEVICE_DATA_RETRIES        3
1091 #define BC_TIMER_VALUE                    (5 * 1000 * 1000)       /* 5 second */
1092 #define SMP_TIMER_VALUE                   (30 * 1000 * 1000)       /* 30 second */
1093
1094 #define STP_DEVICE_TYPE 0     /* SATA behind expander 00*/
1095 #define SAS_DEVICE_TYPE 1     /* SSP or SMP 01 */
1096 #define SATA_DEVICE_TYPE 2    /* direct SATA 10 */
1097 #define ATAPI_DEVICE_FLAG 0x200000   /* ATAPI device flag*/
1098
1099
1100 /* ATA device type */
1101 #define SATA_ATA_DEVICE                           0x01                       /**< ATA ATA device type */
1102 #define SATA_ATAPI_DEVICE                         0x02                       /**< ATA ATAPI device type */
1103 #define SATA_PM_DEVICE                            0x03                       /**< ATA PM device type */
1104 #define SATA_SEMB_DEVICE                          0x04                       /**< ATA SEMB device type */
1105 #define SATA_SEMB_WO_SEP_DEVICE                   0x05                       /**< ATA SEMB without SEP device type */
1106 #define UNKNOWN_DEVICE                            0xFF
1107
1108
1109 /* SAS device type definition. SAS spec(r.7) p206  */
1110 #define SAS_NO_DEVICE                    0
1111 #define SAS_END_DEVICE                   1
1112 #define SAS_EDGE_EXPANDER_DEVICE         2
1113 #define SAS_FANOUT_EXPANDER_DEVICE       3
1114
1115 /* routing attributes */
1116 #define SAS_ROUTING_DIRECT                             0x00
1117 #define SAS_ROUTING_SUBTRACTIVE                        0x01
1118 #define SAS_ROUTING_TABLE                              0x02
1119
1120 #define SAS_CONNECTION_RATE_1_5G                       0x08
1121 #define SAS_CONNECTION_RATE_3_0G                       0x09
1122 #define SAS_CONNECTION_RATE_6_0G                       0x0A
1123 #define SAS_CONNECTION_RATE_12_0G                      0x0B
1124
1125 #define IT_NEXUS_TIMEOUT    0x7D0 /* 2000 ms; old value was 0xFFFF */
1126
1127 /* bit8 array[4] -> bit32 */
1128 #define DEVINFO_GET_SAS_ADDRESSLO(devInfo) \
1129   DMA_BEBIT32_TO_BIT32(*(bit32 *)(devInfo)->sasAddressLo)
1130
1131 #define DEVINFO_GET_SAS_ADDRESSHI(devInfo) \
1132   DMA_BEBIT32_TO_BIT32(*(bit32 *)(devInfo)->sasAddressHi)
1133
1134 /* this macro is based on SAS spec, not sTSDK 0xC0 */
1135 #define DEVINFO_GET_DEVICETTYPE(devInfo) \
1136   (((devInfo)->devType_S_Rate & 0xC0) >> 6)
1137
1138 #define DEVINFO_GET_LINKRATE(devInfo) \
1139   ((devInfo)->devType_S_Rate & 0x0F)
1140
1141 /**< target device type */
1142 #define DM_DEFAULT_DEVICE 0
1143 #define DM_SAS_DEVICE 1
1144 #define DM_SATA_DEVICE 2
1145
1146 #define DEVICE_SSP_BIT         0x8   /* SSP Initiator port */
1147 #define DEVICE_STP_BIT         0x4   /* STP Initiator port */
1148 #define DEVICE_SMP_BIT         0x2   /* SMP Initiator port */
1149 #define DEVICE_SATA_BIT        0x1   /* SATA device, valid in the discovery response only */
1150
1151 #define DEVICE_IS_SSP_INITIATOR(DeviceData) \
1152   (((DeviceData)->initiator_ssp_stp_smp & DEVICE_SSP_BIT) == DEVICE_SSP_BIT)
1153
1154 #define DEVICE_IS_STP_INITIATOR(DeviceData) \
1155   (((DeviceData)->initiator_ssp_stp_smp & DEVICE_STP_BIT) == DEVICE_STP_BIT)
1156
1157 #define DEVICE_IS_SMP_INITIATOR(DeviceData) \
1158   (((DeviceData)->initiator_ssp_stp_smp & DEVICE_SMP_BIT) == DEVICE_SMP_BIT)
1159
1160 #define DEVICE_IS_SSP_TARGET(DeviceData) \
1161   (((DeviceData)->target_ssp_stp_smp & DEVICE_SSP_BIT) == DEVICE_SSP_BIT)
1162
1163 #define DEVICE_IS_STP_TARGET(DeviceData) \
1164   (((DeviceData)->target_ssp_stp_smp & DEVICE_STP_BIT) == DEVICE_STP_BIT)
1165
1166 #define DEVICE_IS_SMP_TARGET(DeviceData) \
1167   (((DeviceData)->target_ssp_stp_smp & DEVICE_SMP_BIT) == DEVICE_SMP_BIT)
1168
1169 #define DEVICE_IS_SATA_DEVICE(DeviceData) \
1170   (((DeviceData)->target_ssp_stp_smp & DEVICE_SATA_BIT) == DEVICE_SATA_BIT)
1171
1172 /* bit8 array[4] -> bit32 */
1173 #define DEVINFO_GET_SAS_ADDRESSLO(devInfo) \
1174   DMA_BEBIT32_TO_BIT32(*(bit32 *)(devInfo)->sasAddressLo)
1175
1176 #define DEVINFO_GET_SAS_ADDRESSHI(devInfo) \
1177   DMA_BEBIT32_TO_BIT32(*(bit32 *)(devInfo)->sasAddressHi)
1178
1179 /* this macro is based on SAS spec, not sTSDK 0xC0 */
1180 #define DEVINFO_GET_DEVICETTYPE(devInfo) \
1181   (((devInfo)->devType_S_Rate & 0xC0) >> 6)
1182
1183 #define DEVINFO_GET_LINKRATE(devInfo) \
1184   ((devInfo)->devType_S_Rate & 0x0F)
1185
1186
1187 #define DEVINFO_GET_EXT_SMP(devInfo) \
1188   (((devInfo)->ext & 0x100) >> 8)
1189
1190 #define DEVINFO_GET_EXT_EXPANDER_TYPE(devInfo) \
1191   (((devInfo)->ext & 0x600) >> 9)
1192
1193 #define DEVINFO_GET_EXT_MCN(devInfo) \
1194   (((devInfo)->ext & 0x7800) >> 11)
1195
1196
1197 #define DEVINFO_PUT_SMPTO(devInfo, smpto) \
1198   ((devInfo)->smpTimeout) = smpto
1199
1200 #define DEVINFO_PUT_ITNEXUSTO(devInfo, itnexusto) \
1201   ((devInfo)->it_NexusTimeout) = itnexusto
1202
1203 #define DEVINFO_PUT_FBS(devInfo, fbs) \
1204   ((devInfo)->firstBurstSize) = fbs
1205
1206 #define DEVINFO_PUT_FLAG(devInfo, tlr) \
1207   ((devInfo)->flag) = tlr
1208
1209 #define DEVINFO_PUT_DEV_S_RATE(devInfo, dev_s_rate) \
1210   ((devInfo)->devType_S_Rate) = dev_s_rate
1211
1212 /* bit32 -> bit8 array[4] */
1213 #define DEVINFO_PUT_SAS_ADDRESSLO(devInfo, src32) \
1214   *(bit32 *)((devInfo)->sasAddressLo) = BIT32_TO_DMA_BEBIT32(src32)
1215
1216 #define DEVINFO_PUT_SAS_ADDRESSHI(devInfo, src32) \
1217   *(bit32 *)((devInfo)->sasAddressHi) = BIT32_TO_DMA_BEBIT32(src32)
1218
1219 #define DEVINFO_PUT_INITIATOR_SSP_STP_SMP(devInfo, ini_ssp_stp_smp) \
1220   ((devInfo)->initiator_ssp_stp_smp) = ini_ssp_stp_smp
1221
1222 #define DEVINFO_PUT_TARGET_SSP_STP_SMP(devInfo, tgt_ssp_stp_smp) \
1223   ((devInfo)->target_ssp_stp_smp) = tgt_ssp_stp_smp
1224
1225 #define DEVINFO_PUT_EXT(devInfo, extension) \
1226   ((devInfo)->ext) = extension
1227
1228 #endif /* __DMDEFS_H__ */
1229