xref: /freebsd/sys/dev/isci/scil/intel_sas.h (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * This file is provided under a dual BSD/GPLv2 license.  When using or
5  * redistributing this file, you may do so under either license.
6  *
7  * GPL LICENSE SUMMARY
8  *
9  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23  * The full GNU General Public License is included in this distribution
24  * in the file called LICENSE.GPL.
25  *
26  * BSD LICENSE
27  *
28  * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  *
35  *   * Redistributions of source code must retain the above copyright
36  *     notice, this list of conditions and the following disclaimer.
37  *   * Redistributions in binary form must reproduce the above copyright
38  *     notice, this list of conditions and the following disclaimer in
39  *     the documentation and/or other materials provided with the
40  *     distribution.
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  */
54 #ifndef _INTEL_SAS_H_
55 #define _INTEL_SAS_H_
56 
57 /**
58  * @file
59  *
60  * @brief This file contains all of the definitions relating to structures,
61  *        constants, etc. defined by the SAS specification.
62  */
63 
64 #include <dev/isci/types.h>
65 #include <dev/isci/scil/intel_sata.h>
66 #include <dev/isci/scil/intel_scsi.h>
67 
68 /**
69  * @struct SCI_SAS_ADDRESS
70  * @brief  This structure depicts how a SAS address is represented by SCI.
71  */
72 typedef struct SCI_SAS_ADDRESS
73 {
74    /**
75     * This member contains the higher 32-bits of the SAS address.
76     */
77    U32 high;
78 
79    /**
80     * This member contains the lower 32-bits of the SAS address.
81     */
82    U32 low;
83 
84 } SCI_SAS_ADDRESS_T;
85 
86 /**
87  * @struct SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS
88  * @brief  This structure depicts the contents of bytes 2 and 3 in the
89  *         SAS IDENTIFY ADDRESS FRAME (IAF).
90  *         @note For specific information on each of these
91  *               individual fields please reference the SAS specification
92  *               Link layer section on address frames.
93  */
94 typedef struct SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS
95 {
96    union
97    {
98       struct
99       {
100          U16  restricted1        : 1;
101          U16  smp_initiator      : 1;
102          U16  stp_initiator      : 1;
103          U16  ssp_initiator      : 1;
104          U16  reserved3          : 4;
105          U16  restricted2        : 1;
106          U16  smp_target         : 1;
107          U16  stp_target         : 1;
108          U16  ssp_target         : 1;
109          U16  reserved4          : 4;
110       } bits;
111 
112       U16 all;
113    } u;
114 
115 } SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T;
116 
117 /**
118  * @struct SCI_SAS_IDENTIFY_ADDRESS_FRAME
119  * @brief  This structure depicts the contents of the SAS IDENTIFY ADDRESS
120  *         FRAME (IAF).
121  *         @note For specific information on each of these
122  *               individual fields please reference the SAS specification
123  *               Link layer section on address frames.
124  */
125 typedef struct SCI_SAS_IDENTIFY_ADDRESS_FRAME
126 {
127    U16  address_frame_type : 4;
128    U16  device_type        : 3;
129    U16  reserved1          : 1;
130    U16  reason             : 4;
131    U16  reserved2          : 4;
132 
133    SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T protocols;
134 
135    SCI_SAS_ADDRESS_T  device_name;
136    SCI_SAS_ADDRESS_T  sas_address;
137 
138    U32  phy_identifier      : 8;
139    U32  break_reply_capable : 1;
140    U32  requested_in_zpsds  : 1;
141    U32  in_zpsds_persistent : 1;
142    U32  reserved5           : 21;
143 
144    U32  reserved6[4];
145 
146 } SCI_SAS_IDENTIFY_ADDRESS_FRAME_T;
147 
148 /**
149  * @struct SAS_CAPABILITIES
150  * @brief  This structure depicts the various SAS capabilities supported
151  *         by the directly attached target device.  For specific information
152  *         on each of these individual fields please reference the SAS
153  *         specification Phy layer section on speed negotiation windows.
154  */
155 typedef struct SAS_CAPABILITIES
156 {
157    union
158    {
159 #if defined (SCIC_SDS_4_ENABLED)
160       struct
161       {
162          /**
163           * The SAS specification indicates the start bit shall always be set to
164           * 1.  This implementation will have the start bit set to 0 if the
165           * PHY CAPABILITIES were either not received or speed negotiation failed.
166           */
167          U32  start                       : 1;
168          U32  tx_ssc_type                 : 1;
169          U32  reserved1                   : 2;
170          U32  requested_logical_link_rate : 4;
171 
172          U32  gen1_without_ssc_supported  : 1;
173          U32  gen1_with_ssc_supported     : 1;
174          U32  gen2_without_ssc_supported  : 1;
175          U32  gen2_with_ssc_supported     : 1;
176          U32  gen3_without_ssc_supported  : 1;
177          U32  gen3_with_ssc_supported     : 1;
178          U32  reserved2                   : 17;
179          U32  parity                      : 1;
180       } bits;
181 #endif // (SCIC_SDS_4_ENABLED)
182 
183       U32 all;
184    } u;
185 
186 } SAS_CAPABILITIES_T;
187 
188 /**
189  * @enum  _SCI_SAS_LINK_RATE
190  * @brief This enumeration depicts the SAS specification defined link speeds.
191  */
192 typedef enum _SCI_SAS_LINK_RATE
193 {
194    SCI_SAS_NO_LINK_RATE = 0,
195    SCI_SATA_SPINUP_HOLD = 0x3,
196    SCI_SAS_150_GB = 0x8,
197    SCI_SAS_300_GB = 0x9,
198    SCI_SAS_600_GB = 0xA
199 } SCI_SAS_LINK_RATE;
200 
201 /**
202  * @enum  _SCI_SAS_TASK_ATTRIBUTE
203  * @brief This enumeration depicts the SAM/SAS specification defined task
204  *        attribute values for a command information unit.
205  */
206 typedef enum _SCI_SAS_TASK_ATTRIBUTE
207 {
208    SCI_SAS_SIMPLE_ATTRIBUTE = 0,
209    SCI_SAS_HEAD_OF_QUEUE_ATTRIBUTE = 1,
210    SCI_SAS_ORDERED_ATTRIBUTE = 2,
211    SCI_SAS_ACA_ATTRIBUTE = 4,
212 } SCI_SAS_TASK_ATTRIBUTE;
213 
214 /**
215  * @enum  _SCI_SAS_TASK_MGMT_FUNCTION
216  * @brief This enumeration depicts the SAM/SAS specification defined task
217  *        management functions.
218  *        @note This HARD_RESET function listed here is not actually defined
219  *              as a task management function in the industry standard.
220  */
221 typedef enum _SCI_SAS_TASK_MGMT_FUNCTION
222 {
223    SCI_SAS_ABORT_TASK = SCSI_TASK_REQUEST_ABORT_TASK,
224    SCI_SAS_ABORT_TASK_SET = SCSI_TASK_REQUEST_ABORT_TASK_SET,
225    SCI_SAS_CLEAR_TASK_SET = SCSI_TASK_REQUEST_CLEAR_TASK_SET,
226    SCI_SAS_LOGICAL_UNIT_RESET = SCSI_TASK_REQUEST_LOGICAL_UNIT_RESET,
227    SCI_SAS_I_T_NEXUS_RESET = SCSI_TASK_REQUEST_I_T_NEXUS_RESET,
228    SCI_SAS_CLEAR_ACA = SCSI_TASK_REQUEST_CLEAR_ACA,
229    SCI_SAS_QUERY_TASK = SCSI_TASK_REQUEST_QUERY_TASK,
230    SCI_SAS_QUERY_TASK_SET = SCSI_TASK_REQUEST_QUERY_TASK_SET,
231    SCI_SAS_QUERY_ASYNCHRONOUS_EVENT = SCSI_TASK_REQUEST_QUERY_UNIT_ATTENTION,
232    SCI_SAS_HARD_RESET = 0xFF
233 } SCI_SAS_TASK_MGMT_FUNCTION_T;
234 
235 
236 /**
237  * @enum  _SCI_SAS_FRAME_TYPE
238  * @brief This enumeration depicts the SAS specification defined SSP frame
239  *        types.
240  */
241 typedef enum _SCI_SAS_FRAME_TYPE
242 {
243    SCI_SAS_DATA_FRAME = 0x01,
244    SCI_SAS_XFER_RDY_FRAME = 0x05,
245    SCI_SAS_COMMAND_FRAME = 0x06,
246    SCI_SAS_RESPONSE_FRAME = 0x07,
247    SCI_SAS_TASK_FRAME = 0x16
248 } SCI_SAS_FRAME_TYPE_T;
249 
250 
251 /**
252  * @struct SCI_SSP_COMMAND_IU
253  * @brief This structure depicts the contents of the SSP COMMAND
254  *        INFORMATION UNIT. For specific information on each of these
255  *        individual fields please reference the SAS specification SSP
256  *        transport layer section.
257  */
258 typedef struct SCI_SSP_COMMAND_IU
259 {
260 
261    U32 lun[2];
262 
263    U32 additional_cdb_length  : 6;
264    U32 reserved0              : 2;
265    U32 reserved1              : 8;
266    U32 enable_first_burst     : 1;
267    U32 task_priority          : 4;
268    U32 task_attribute         : 3;
269    U32 reserved2              : 8;
270 
271    U32 cdb[4];
272 
273 } SCI_SSP_COMMAND_IU_T;
274 
275 /**
276  * @struct SCI_SSP_TASK_IU
277  * @brief This structure depicts the contents of the SSP TASK INFORMATION
278  *        UNIT. For specific information on each of these individual fields
279  *        please reference the SAS specification SSP transport layer
280  *        section.
281  */
282 typedef struct SCI_SSP_TASK_IU
283 {
284    U32 lun_upper;
285    U32 lun_lower;
286 
287    U32 reserved0     : 8;
288    U32 task_function : 8;
289    U32 reserved1     : 8;
290    U32 reserved2     : 8;
291 
292    U32 reserved3     : 16;
293    U32 task_tag      : 16;
294 
295    U32 reserved4[3];
296 
297 } SCI_SSP_TASK_IU_T;
298 
299 #define SSP_RESPONSE_IU_MAX_DATA 64
300 
301 #define SCI_SSP_RESPONSE_IU_DATA_PRESENT_MASK   (0x03)
302 
303 /**
304  * @struct SCI_SSP_RESPONSE_IU
305  * @brief This structure depicts the contents of the SSP RESPONSE
306  *        INFORMATION UNIT. For specific information on each of these
307  *        individual fields please reference the SAS specification SSP
308  *        transport layer section.
309  */
310 typedef struct SCI_SSP_RESPONSE_IU
311 {
312    U8  reserved0[8];
313 
314    U8  retry_delay_timer[2];
315    U8  data_present;
316    U8  status;
317 
318    U8  reserved1[4];
319    U8  sense_data_length[4];
320    U8  response_data_length[4];
321 
322    U32 data[SSP_RESPONSE_IU_MAX_DATA];
323 
324 } SCI_SSP_RESPONSE_IU_T;
325 
326 /**
327  * @enum  _SCI_SAS_DATA_PRESENT_TYPE
328  * @brief This enumeration depicts the SAS specification defined SSP data present
329  *        types in SCI_SSP_RESPONSE_IU.
330  */
331 typedef enum _SCI_SSP_RESPONSE_IU_DATA_PRESENT_TYPE
332 {
333    SCI_SSP_RESPONSE_IU_NO_DATA = 0x00,
334    SCI_SSP_RESPONSE_IU_RESPONSE_DATA = 0x01,
335    SCI_SSP_RESPONSE_IU_SENSE_DATA = 0x02
336 } SCI_SSP_RESPONSE_IU_DATA_PRESENT_TYPE_T;
337 
338 /**
339  * @struct SCI_SSP_FRAME_HEADER
340  *
341  * @brief This structure depicts the contents of an SSP frame header.  For
342  *        specific information on the individual fields please reference
343  *        the SAS specification transport layer SSP frame format.
344  */
345 typedef struct SCI_SSP_FRAME_HEADER
346 {
347    // Word 0
348    U32 hashed_destination_address  :24;
349    U32 frame_type                  : 8;
350 
351    // Word 1
352    U32 hashed_source_address       :24;
353    U32 reserved1_0                 : 8;
354 
355    // Word 2
356    U32 reserved2_2                 : 6;
357    U32 fill_bytes                  : 2;
358    U32 reserved2_1                 : 3;
359    U32 tlr_control                 : 2;
360    U32 retry_data_frames           : 1;
361    U32 retransmit                  : 1;
362    U32 changing_data_pointer       : 1;
363    U32 reserved2_0                 :16;
364 
365    // Word 3
366    U32 uiResv4;
367 
368    // Word 4
369    U16 target_port_transfer_tag;
370    U16 tag;
371 
372    // Word 5
373    U32 data_offset;
374 
375 } SCI_SSP_FRAME_HEADER_T;
376 
377 /**
378  * @struct SMP_REQUEST_HEADER
379  * @brief  This structure defines the contents of an SMP Request header.
380  *         @note For specific information on each of these
381  *               individual fields please reference the SAS specification.
382  */
383 typedef struct SMP_REQUEST_HEADER
384 {
385    U8 smp_frame_type;                // byte 0
386    U8 function;                      // byte 1
387    U8 allocated_response_length;     // byte 2
388    U8 request_length;                // byte 3
389 } SMP_REQUEST_HEADER_T;
390 
391 /**
392  * @struct SMP_RESPONSE_HEADER
393  * @brief  This structure depicts the contents of the SAS SMP DISCOVER
394  *         RESPONSE frame.  For specific information on each of these
395  *         individual fields please reference the SAS specification Link
396  *         layer section on address frames.
397  */
398 typedef struct SMP_RESPONSE_HEADER
399 {
400    U8 smp_frame_type;      // byte 0
401    U8 function;            // byte 1
402    U8 function_result;     // byte 2
403    U8 response_length;     // byte 3
404 } SMP_RESPONSE_HEADER_T;
405 
406 /**
407  * @struct SMP_REQUEST_GENERAL
408  * @brief  This structure defines the contents of an SMP Request that
409  *         is comprised of the SMP_REQUEST_HEADER and a CRC.
410  *         @note For specific information on each of these
411  *               individual fields please reference the SAS specification.
412  */
413 typedef struct SMP_REQUEST_GENERAL
414 {
415   U32 crc;            // bytes 4-7
416 
417 } SMP_REQUEST_GENERAL_T;
418 
419 /**
420  * @struct SMP_REQUEST_PHY_IDENTIFIER
421  * @brief  This structure defines the contents of an SMP Request that
422  *         is comprised of the SMP_REQUEST_HEADER and a phy identifier.
423  *         Examples: SMP_REQUEST_DISCOVER, SMP_REQUEST_REPORT_PHY_SATA.
424  *         @note For specific information on each of these
425  *               individual fields please reference the SAS specification.
426  */
427 typedef struct SMP_REQUEST_PHY_IDENTIFIER
428 {
429   U32 reserved_byte4_7;      // bytes 4-7
430 
431   U32 ignore_zone_group:1;    // byte 8
432   U32 reserved_byte8:7;
433 
434   U32 phy_identifier:8;       // byte 9
435   U32 reserved_byte10:8;      // byte 10
436   U32 reserved_byte11:8;      // byte 11
437 
438 } SMP_REQUEST_PHY_IDENTIFIER_T;
439 
440 /**
441  * @struct SMP_REQUEST_CONFIGURE_ROUTE_INFORMATION
442  * @brief  This structure defines the contents of an SMP Configure Route
443  *         Information request.
444  *         @note For specific information on each of these
445  *               individual fields please reference the SAS specification.
446  */
447 typedef struct SMP_REQUEST_CONFIGURE_ROUTE_INFORMATION
448 {
449   U32 expected_expander_change_count:16;    // bytes 4-5
450   U32 expander_route_index_high:8;
451   U32 expander_route_index:8;              // bytes 6-7
452 
453   U32 reserved_byte8:8;           // bytes 8
454   U32 phy_identifier:8;           // bytes 9
455   U32 reserved_byte_10_11:16;     // bytes 10-11
456 
457   U32 reserved_byte_12_bit_0_6:7;
458   U32 disable_route_entry:1;    // byte 12
459   U32 reserved_byte_13_15:24;   // bytes 13-15
460 
461   U32 routed_sas_address[2];    // bytes 16-23
462   U8 reserved_byte_24_39[16];    // bytes 24-39
463 
464 } SMP_REQUEST_CONFIGURE_ROUTE_INFORMATION_T;
465 
466 /**
467  * @struct SMP_REQUEST_PHY_CONTROL
468  * @brief  This structure defines the contents of an SMP Phy Controller
469  *         request.
470  *         @note For specific information on each of these
471  *               individual fields please reference the SAS specification.
472  */
473 typedef struct SMP_REQUEST_PHY_CONTROL
474 {
475   U16 expected_expander_change_count;   // byte 4-5
476 
477   U16 reserved_byte_6_7;   // byte 6-7
478   U8 reserved_byte_8;      // byte 8
479 
480   U8 phy_identifier;       // byte 9
481   U8 phy_operation;        // byte 10
482 
483   U8 update_partial_pathway_timeout_value:1;
484   U8 reserved_byte_11_bit_1_7:7;   // byte 11
485 
486   U8 reserved_byte_12_23[12];      // byte 12-23
487 
488   U8 attached_device_name[8];      // byte 24-31
489 
490   U8 reserved_byte_32_bit_3_0:4;   // byte 32
491   U8 programmed_minimum_physical_link_rate:4;
492 
493   U8 reserved_byte_33_bit_3_0:4;   // byte 33
494   U8 programmed_maximum_physical_link_rate:4;
495 
496   U16 reserved_byte_34_35;      // byte 34-35
497 
498   U8 partial_pathway_timeout_value:4;
499   U8 reserved_byte_36_bit_4_7:4;  // byte 36
500 
501   U16 reserved_byte_37_38;  // byte 37-38
502   U8 reserved_byte_39;      // byte 39
503 
504 } SMP_REQUEST_PHY_CONTROL_T;
505 
506 /**
507  * @struct SMP_REQUEST_VENDOR_SPECIFIC
508  * @brief  This structure depicts the vendor specific space for SMP request.
509  */
510  #define SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH 1016
511 typedef struct SMP_REQUEST_VENDOR_SPECIFIC
512 {
513    U8 request_bytes[SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH];
514 }SMP_REQUEST_VENDOR_SPECIFIC_T;
515 
516 /**
517  * @struct SMP_REQUEST
518  * @brief  This structure simply unionizes the existing request
519  *         structures into a common request type.
520  */
521 typedef struct _SMP_REQUEST
522 {
523   SMP_REQUEST_HEADER_T header;
524 
525   union
526   {            // bytes 4-N
527     SMP_REQUEST_GENERAL_T                       report_general;
528     SMP_REQUEST_PHY_IDENTIFIER_T                discover;
529     SMP_REQUEST_GENERAL_T                       report_manufacturer_information;
530     SMP_REQUEST_PHY_IDENTIFIER_T                report_phy_sata;
531     SMP_REQUEST_PHY_CONTROL_T                   phy_control;
532     SMP_REQUEST_PHY_IDENTIFIER_T                report_phy_error_log;
533     SMP_REQUEST_PHY_IDENTIFIER_T                report_route_information;
534     SMP_REQUEST_CONFIGURE_ROUTE_INFORMATION_T   configure_route_information;
535     SMP_REQUEST_VENDOR_SPECIFIC_T               vendor_specific_request;
536   } request;
537 
538 } SMP_REQUEST_T;
539 
540 
541 /**
542  * @struct SMP_RESPONSE_REPORT_GENERAL
543  * @brief  This structure depicts the SMP Report General for
544  *         expander devices.  It adheres to the SAS-2.1 specification.
545  *         @note For specific information on each of these
546  *               individual fields please reference the SAS specification
547  *               Application layer section on SMP.
548  */
549 typedef struct SMP_RESPONSE_REPORT_GENERAL
550 {
551   U16 expander_change_count;  //byte 4-5
552   U16 expander_route_indexes; //byte 6-7
553 
554   U32 reserved_byte8:7;        //byte 8 bit 0-6
555   U32 long_response:1;         //byte 8 bit 7
556 
557   U32 number_of_phys:8;        //byte 9
558 
559   U32 configurable_route_table:1; //byte 10
560   U32 configuring:1;
561   U32 configures_others:1;
562   U32 open_reject_retry_supported:1;
563   U32 stp_continue_awt:1;
564   U32 self_configuring:1;
565   U32 zone_configuring:1;
566   U32 table_to_table_supported:1;
567 
568   U32 reserved_byte11:8;       //byte 11
569 
570   U32 enclosure_logical_identifier_high; //byte 12-15
571   U32 enclosure_logical_identifier_low;  //byte 16-19
572 
573   U32 reserved_byte20_23;
574   U32 reserved_byte24_27;
575 
576 } SMP_RESPONSE_REPORT_GENERAL_T;
577 
578 typedef struct SMP_RESPONSE_REPORT_GENERAL_LONG
579 {
580    SMP_RESPONSE_REPORT_GENERAL_T sas1_1;
581 
582    struct
583    {
584       U16 reserved1;
585       U16 stp_bus_inactivity_time_limit;
586       U16 stp_max_connect_time_limit;
587       U16 stp_smp_i_t_nexus_loss_time;
588 
589       U32 zoning_enabled                         : 1;
590       U32 zoning_supported                       : 1;
591       U32 physicaL_presence_asserted             : 1;
592       U32 zone_locked                            : 1;
593       U32 reserved2                              : 1;
594       U32 num_zone_groups                        : 3;
595       U32 saving_zoning_enabled_supported        : 3;
596       U32 saving_zone_perms_table_supported      : 1;
597       U32 saving_zone_phy_info_supported         : 1;
598       U32 saving_zone_manager_password_supported : 1;
599       U32 saving                                 : 1;
600       U32 reserved3                              : 1;
601       U32 max_number_routed_sas_addresses        : 16;
602 
603       SCI_SAS_ADDRESS_T active_zone_manager_sas_address;
604 
605       U16 zone_lock_inactivity_time_limit;
606       U16 reserved4;
607 
608       U8 reserved5;
609       U8 first_enclosure_connector_element_index;
610       U8 number_of_enclosure_connector_element_indices;
611       U8 reserved6;
612 
613       U32 reserved7                            : 7;
614       U32 reduced_functionality                : 1;
615       U32 time_to_reduce_functionality         : 8;
616       U32 initial_time_to_reduce_functionality : 8;
617       U8  max_reduced_functionality_time;
618 
619       U16 last_self_config_status_descriptor_index;
620       U16 max_number_of_stored_self_config_status_descriptors;
621 
622       U16 last_phy_event_list_descriptor_index;
623       U16 max_number_of_stored_phy_event_list_descriptors;
624    } sas2;
625 
626 } SMP_RESPONSE_REPORT_GENERAL_LONG_T;
627 
628 /**
629  * @struct SMP_RESPONSE_REPORT_MANUFACTURER_INFORMATION
630  * @brief  This structure depicts the SMP report manufacturer
631  *         information for expander devices.  It adheres to the
632  *         SAS-2.1 specification.
633  *         @note For specific information on each of these
634  *               individual fields please reference the SAS specification
635  *               Application layer section on SMP.
636  */
637 typedef struct SMP_RESPONSE_REPORT_MANUFACTURER_INFORMATION
638 {
639   U32 expander_change_count : 16;    // bytes 4-5
640   U32 reserved1             : 16;
641 
642   U32 sas1_1_format         : 1;
643   U32 reserved2             : 31;
644 
645   U8  vendor_id[8];
646   U8  product_id[16];
647   U8  product_revision_level[4];
648   U8  component_vendor_id[8];
649   U8  component_id[2];
650   U8  component_revision_level;
651   U8  reserved3;
652   U8  vendor_specific[8];
653 
654 } SMP_RESPONSE_REPORT_MANUFACTURER_INFORMATION_T;
655 
656 #define SMP_RESPONSE_DISCOVER_FORMAT_1_1_SIZE 52
657 #define SMP_RESPONSE_DISCOVER_FORMAT_2_SIZE   116
658 
659 /**
660  * @struct SMP_DISCOVER_RESPONSE_PROTOCOLS
661  * @brief  This structure depicts the discover response where the
662  *         supported protocols by the remote phy are specified.
663  *         @note For specific information on each of these
664  *               individual fields please reference the SAS specification
665  *               Link layer section on address frames.
666  */
667 typedef struct SMP_DISCOVER_RESPONSE_PROTOCOLS
668 {
669    union
670    {
671       struct
672       {
673          U16  attached_sata_host           : 1;
674          U16  attached_smp_initiator       : 1;
675          U16  attached_stp_initiator       : 1;
676          U16  attached_ssp_initiator       : 1;
677          U16  reserved3                    : 4;
678          U16  attached_sata_device         : 1;
679          U16  attached_smp_target          : 1;
680          U16  attached_stp_target          : 1;
681          U16  attached_ssp_target          : 1;
682          U16  reserved4                    : 3;
683          U16  attached_sata_port_selector  : 1;
684       } bits;
685 
686       U16 all;
687    } u;
688 
689 } SMP_DISCOVER_RESPONSE_PROTOCOLS_T;
690 
691 /**
692  * @struct SMP_RESPONSE_DISCOVER_FORMAT
693  * @brief  This structure defines the SMP phy discover response format.
694  *         It handles both SAS1.1 and SAS 2 definitions.  The unions
695  *         indicate locations where the SAS specification versions
696  *         differ from one another.
697  */
698 typedef struct SMP_RESPONSE_DISCOVER
699 {
700 
701    union
702    {
703       struct
704       {
705          U8 reserved[2];
706       } sas1_1;
707 
708       struct
709       {
710          U16  expander_change_count;
711       } sas2;
712 
713    } u1;
714 
715    U8   reserved1[3];
716    U8   phy_identifier;
717    U8   reserved2[2];
718 
719    union
720    {
721       struct
722       {
723          U16  reserved1                     : 4;
724          U16  attached_device_type          : 3;
725          U16  reserved2                     : 1;
726          U16  negotiated_physical_link_rate : 4;
727          U16  reserved3                     : 4;
728       } sas1_1;
729 
730       struct
731       {
732          U16  attached_reason              : 4;
733          U16  attached_device_type         : 3;
734          U16  reserved2                    : 1;
735          U16  negotiated_logical_link_rate : 4;
736          U16  reserved3                    : 4;
737       } sas2;
738 
739    } u2;
740 
741    SMP_DISCOVER_RESPONSE_PROTOCOLS_T protocols;
742    SCI_SAS_ADDRESS_T  sas_address;
743    SCI_SAS_ADDRESS_T  attached_sas_address;
744 
745    U8   attached_phy_identifier;
746 
747    union
748    {
749       struct
750       {
751          U8   reserved;
752       } sas1_1;
753 
754       struct
755       {
756          U8   attached_break_reply_capable     : 1;
757          U8   attached_requested_inside_zpsds  : 1;
758          U8   attached_inside_zpsds_persistent : 1;
759          U8   reserved1                        : 5;
760       } sas2;
761 
762    } u3;
763 
764    U8   reserved_for_identify[6];
765 
766    U32  hardware_min_physical_link_rate   : 4;
767    U32  programmed_min_physical_link_rate : 4;
768    U32  hardware_max_physical_link_rate   : 4;
769    U32  programmed_max_physical_link_rate : 4;
770    U32  phy_change_count                  : 8;
771    U32  partial_pathway_timeout_value     : 4;
772    U32  reserved5                         : 3;
773    U32  virtual_phy                       : 1;
774 
775    U32  routing_attribute                 : 4;
776    U32  reserved6                         : 4;
777    U32  connector_type                    : 7;
778    U32  reserved7                         : 1;
779    U32  connector_element_index           : 8;
780    U32  connector_physical_link           : 8;
781 
782    U16  reserved8;
783    U16  vendor_specific;
784 
785    union
786    {
787       struct
788       {
789          /**
790           * In the SAS 1.1 specification this structure ends after 52 bytes.
791           * As a result, the contents of this field should never have a
792           * real value.  It is undefined.
793           */
794          U8 undefined[SMP_RESPONSE_DISCOVER_FORMAT_2_SIZE
795                       - SMP_RESPONSE_DISCOVER_FORMAT_1_1_SIZE];
796       } sas1_1;
797 
798       struct
799       {
800          SCI_SAS_ADDRESS_T attached_device_name;
801 
802          U32  zoning_enabled                             : 1;
803          U32  inside_zpsds                               : 1;
804          U32  zone_group_persistent                      : 1;
805          U32  reserved1                                  : 1;
806          U32  requested_inside_zpsds                     : 1;
807          U32  inside_zpsds_persistent                    : 1;
808          U32  requested_inside_zpsds_changed_by_expander : 1;
809          U32  reserved2                                  : 1;
810          U32  reserved_for_zoning_fields                 : 16;
811          U32  zone_group                                 : 8;
812 
813          U8   self_configuration_status;
814          U8   self_configuration_levels_completed;
815          U16  reserved_for_self_config_fields;
816 
817          SCI_SAS_ADDRESS_T self_configuration_sas_address;
818 
819          U32  programmed_phy_capabilities;
820          U32  current_phy_capabilities;
821          U32  attached_phy_capabilities;
822 
823          U32  reserved3;
824 
825          U32  reserved4                     : 16;
826          U32  negotiated_physical_link_rate : 4;
827          U32  reason                        : 4;
828          U32  hardware_muxing_supported     : 1;
829          U32  negotiated_ssc                : 1;
830          U32  reserved5                     : 6;
831 
832          U32  default_zoning_enabled          : 1;
833          U32  reserved6                       : 1;
834          U32  default_zone_group_persistent   : 1;
835          U32  reserved7                       : 1;
836          U32  default_requested_inside_zpsds  : 1;
837          U32  default_inside_zpsds_persistent : 1;
838          U32  reserved8                       : 2;
839          U32  reserved9                       : 16;
840          U32  default_zone_group              : 8;
841 
842          U32  saved_zoning_enabled          : 1;
843          U32  reserved10                    : 1;
844          U32  saved_zone_group_persistent   : 1;
845          U32  reserved11                    : 1;
846          U32  saved_requested_inside_zpsds  : 1;
847          U32  saved_inside_zpsds_persistent : 1;
848          U32  reserved12                    : 18;
849          U32  saved_zone_group              : 8;
850 
851          U32  reserved14                     : 2;
852          U32  shadow_zone_group_persistent   : 1;
853          U32  reserved15                     : 1;
854          U32  shadow_requested_inside_zpsds  : 1;
855          U32  shadow_inside_zpsds_persistent : 1;
856          U32  reserved16                     : 18;
857          U32  shadow_zone_group              : 8;
858 
859          U8   device_slot_number;
860          U8   device_slot_group_number;
861          U8   device_slot_group_output_connector[6];
862       } sas2;
863 
864    } u4;
865 
866 } SMP_RESPONSE_DISCOVER_T;
867 
868 /**
869  * @struct SMP_RESPONSE_REPORT_PHY_SATA
870  * @brief  This structure depicts the contents of the SAS SMP REPORT
871  *         PHY SATA frame.  For specific information on each of these
872  *         individual fields please reference the SAS specification Link
873  *         layer section on address frames.
874  */
875 typedef struct SMP_RESPONSE_REPORT_PHY_SATA
876 {
877   U32 ignored_byte_4_7;       // bytes 4-7
878 
879   U32  affiliations_valid:1;
880   U32  affiliations_supported:1;
881   U32  reserved_byte11:6;     // byte 11
882   U32  ignored_byte10:8;      // byte 10
883   U32  phy_identifier:8;      // byte  9
884   U32  reserved_byte_8:8;     // byte  8
885 
886   U32  reserved_12_15;
887   U32  stp_sas_address[2];
888   U8   device_to_host_fis[20];
889   U32  reserved_44_47;
890   U32  affiliated_stp_initiator_sas_address[2];
891 
892 } SMP_RESPONSE_REPORT_PHY_SATA_T;
893 
894 typedef struct SMP_RESPONSE_VENDOR_SPECIFIC
895 {
896    U8 response_bytes[SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH];
897 }SMP_RESPONSE_VENDOR_SPECIFIC_T;
898 
899 typedef union SMP_RESPONSE_BODY
900 {
901    SMP_RESPONSE_REPORT_GENERAL_T report_general;
902    SMP_RESPONSE_REPORT_MANUFACTURER_INFORMATION_T report_manufacturer_information;
903    SMP_RESPONSE_DISCOVER_T discover;
904    SMP_RESPONSE_REPORT_PHY_SATA_T report_phy_sata;
905    SMP_RESPONSE_VENDOR_SPECIFIC_T vendor_specific_response;
906 } SMP_RESPONSE_BODY_T;
907 
908 /**
909  * @struct SMP_RESPONSE
910  * @brief  This structure simply unionizes the existing response
911  *         structures into a common response type.
912  */
913 typedef struct _SMP_RESPONSE
914 {
915    SMP_RESPONSE_HEADER_T header;
916 
917    SMP_RESPONSE_BODY_T   response;
918 
919 } SMP_RESPONSE_T;
920 
921 // SMP Request Functions
922 #define SMP_FUNCTION_REPORT_GENERAL                   0x00
923 #define SMP_FUNCTION_REPORT_MANUFACTURER_INFORMATION  0x01
924 #define SMP_FUNCTION_DISCOVER                         0x10
925 #define SMP_FUNCTION_REPORT_PHY_ERROR_LOG             0x11
926 #define SMP_FUNCTION_REPORT_PHY_SATA                  0x12
927 #define SMP_FUNCTION_REPORT_ROUTE_INFORMATION         0X13
928 #define SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION      0X90
929 #define SMP_FUNCTION_PHY_CONTROL                      0x91
930 #define SMP_FUNCTION_PHY_TEST                         0x92
931 
932 #define SMP_FRAME_TYPE_REQUEST          0x40
933 #define SMP_FRAME_TYPE_RESPONSE         0x41
934 
935 #define PHY_OPERATION_NOP               0x00
936 #define PHY_OPERATION_LINK_RESET        0x01
937 #define PHY_OPERATION_HARD_RESET        0x02
938 #define PHY_OPERATION_DISABLE           0x03
939 #define PHY_OPERATION_CLEAR_ERROR_LOG   0x05
940 #define PHY_OPERATION_CLEAR_AFFILIATION 0x06
941 
942 #define NPLR_PHY_ENABLED_UNK_LINK_RATE 0x00
943 #define NPLR_PHY_DISABLED     0x01
944 #define NPLR_PHY_ENABLED_SPD_NEG_FAILED   0x02
945 #define NPLR_PHY_ENABLED_SATA_HOLD  0x03
946 #define NPLR_PHY_ENABLED_1_5G    0x08
947 #define NPLR_PHY_ENABLED_3_0G    0x09
948 
949 // SMP Function Result values.
950 #define SMP_RESULT_FUNCTION_ACCEPTED              0x00
951 #define SMP_RESULT_UNKNOWN_FUNCTION               0x01
952 #define SMP_RESULT_FUNCTION_FAILED                0x02
953 #define SMP_RESULT_INVALID_REQUEST_FRAME_LEN      0x03
954 #define SMP_RESULT_INAVALID_EXPANDER_CHANGE_COUNT 0x04
955 #define SMP_RESULT_BUSY                           0x05
956 #define SMP_RESULT_INCOMPLETE_DESCRIPTOR_LIST     0x06
957 #define SMP_RESULT_PHY_DOES_NOT_EXIST             0x10
958 #define SMP_RESULT_INDEX_DOES_NOT_EXIST           0x11
959 #define SMP_RESULT_PHY_DOES_NOT_SUPPORT_SATA      0x12
960 #define SMP_RESULT_UNKNOWN_PHY_OPERATION          0x13
961 #define SMP_RESULT_UNKNOWN_PHY_TEST_FUNCTION      0x14
962 #define SMP_RESULT_PHY_TEST_IN_PROGRESS           0x15
963 #define SMP_RESULT_PHY_VACANT                     0x16
964 
965 /* Attached Device Types */
966 #define SMP_NO_DEVICE_ATTACHED      0
967 #define SMP_END_DEVICE_ONLY         1
968 #define SMP_EDGE_EXPANDER_DEVICE    2
969 #define SMP_FANOUT_EXPANDER_DEVICE  3
970 
971 /* Expander phy routine attribute */
972 #define DIRECT_ROUTING_ATTRIBUTE        0
973 #define SUBTRACTIVE_ROUTING_ATTRIBUTE   1
974 #define TABLE_ROUTING_ATTRIBUTE         2
975 
976 #endif // _INTEL_SAS_H_
977 
978