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