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