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