xref: /freebsd/sys/dev/isci/scil/scu_task_context.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 - 2011 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 _SCU_TASK_CONTEXT_H_
55 #define _SCU_TASK_CONTEXT_H_
56 
57 /**
58  * @file
59  *
60  * @brief This file contains the structures and constants for the SCU hardware
61  *        task context.
62  */
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif // __cplusplus
67 
68 #include <dev/isci/scil/sci_types.h>
69 
70 /**
71  * @enum SCU_SSP_TASK_TYPE
72  *
73  * @brief This enumberation defines the various SSP task types the SCU
74  *        hardware will accept.
75  *
76  * The definition for the various task types the SCU hardware will accept can
77  * be found in the DS specification.
78  */
79 typedef enum
80 {
81     SCU_TASK_TYPE_IOREAD,        ///< IO READ direction or no direction
82     SCU_TASK_TYPE_IOWRITE,       ///< IO Write direction
83     SCU_TASK_TYPE_SMP_REQUEST,   ///< SMP Request type
84     SCU_TASK_TYPE_RESPONSE,      ///< Driver generated response frame (targt mode)
85     SCU_TASK_TYPE_RAW_FRAME,     ///< Raw frame request type
86     SCU_TASK_TYPE_PRIMITIVE      ///< Request for a primitive to be transmitted
87 } SCU_SSP_TASK_TYPE;
88 
89 /**
90  * @enum SCU_SATA_TASK_TYPE
91  *
92  * @brief This enumeration defines the various SATA task types the SCU
93  *        hardware will accept.
94  *
95  * The definition for the various task types the SCU hardware will accept can
96  * be found in the DS specification.
97  */
98 typedef enum
99 {
100     SCU_TASK_TYPE_DMA_IN,           ///< Read request
101     SCU_TASK_TYPE_FPDMAQ_READ,      ///< NCQ read request
102     SCU_TASK_TYPE_PACKET_DMA_IN,    ///< Packet read request
103     SCU_TASK_TYPE_SATA_RAW_FRAME,   ///< Raw frame request
104     RESERVED_4,
105     RESERVED_5,
106     RESERVED_6,
107     RESERVED_7,
108     SCU_TASK_TYPE_DMA_OUT,          ///< Write request
109     SCU_TASK_TYPE_FPDMAQ_WRITE,     ///< NCQ write Request
110     SCU_TASK_TYPE_PACKET_DMA_OUT    ///< Packet write request
111 } SCU_SATA_TASK_TYPE;
112 
113 
114 /**
115  * @name SCU_CONTEXT_TYPE
116  */
117 /*@{*/
118 #define SCU_TASK_CONTEXT_TYPE  0
119 #define SCU_RNC_CONTEXT_TYPE   1
120 /*@}*/
121 
122 /**
123  * @name SCU_TASK_CONTEXT_VALIDITY
124  */
125 /*@{*/
126 #define SCU_TASK_CONTEXT_INVALID          0
127 #define SCU_TASK_CONTEXT_VALID            1
128 /*@}*/
129 
130 /**
131  * @name SCU_COMMAND_CODE
132  */
133 /*@{*/
134 #define SCU_COMMAND_CODE_INITIATOR_NEW_TASK   0
135 #define SCU_COMMAND_CODE_ACTIVE_TASK          1
136 #define SCU_COMMAND_CODE_PRIMITIVE_SEQ_TASK   2
137 #define SCU_COMMAND_CODE_TARGET_RAW_FRAMES    3
138 /*@}*/
139 
140 /**
141  * @name SCU_TASK_PRIORITY
142  */
143 /*@{*/
144 /**
145  * This priority is used when there is no priority request for this request.
146  */
147 #define SCU_TASK_PRIORITY_NORMAL          0
148 
149 /**
150  * This priority indicates that the task should be scheduled to the head
151  * of the queue.  The task will NOT be executed if the TX is suspended for
152  * the remote node.
153  */
154 #define SCU_TASK_PRIORITY_HEAD_OF_Q       1
155 
156 /**
157  * This priority indicates that the task will be executed before all
158  * SCU_TASK_PRIORITY_NORMAL and SCU_TASK_PRIORITY_HEAD_OF_Q tasks.
159  * The task WILL be executed if the TX is suspended for the remote node.
160  */
161 #define SCU_TASK_PRIORITY_HIGH            2
162 
163 /**
164  * This task priority is reserved and should not be used.
165  */
166 #define SCU_TASK_PRIORITY_RESERVED        3
167 /*@}*/
168 
169 #define SCU_TASK_INITIATOR_MODE           1
170 #define SCU_TASK_TARGET_MODE              0
171 
172 #define SCU_TASK_REGULAR                  0
173 #define SCU_TASK_ABORTED                  1
174 
175 //direction bit definition
176 /**
177  * @name SATA_DIRECTION
178  */
179 /*@{*/
180 #define SCU_SATA_WRITE_DATA_DIRECTION     0
181 #define SCU_SATA_READ_DATA_DIRECTION      1
182 /*@}*/
183 
184 /**
185  * @name SCU_COMMAND_CONTEXT_MACROS
186  *
187  * These macros provide the mask and shift operations to construct the various
188  * SCU commands
189  */
190 /*@{*/
191 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_SHIFT           21UL
192 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK            0x00E00000UL
193 #define scu_get_command_request_type(x) \
194                ((x) & SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK)
195 
196 #define SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_SHIFT        18UL
197 #define SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK         0x001C0000UL
198 #define scu_get_command_request_subtype(x) \
199                ((x) & SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK)
200 
201 #define SCU_CONTEXT_COMMAND_REQUEST_FULLTYPE_MASK        \
202    (                                                     \
203        SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK             \
204      | SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK          \
205    )
206 #define scu_get_command_request_full_type(x) \
207                ((x) & SCU_CONTEXT_COMMAND_REQUEST_FULLTYPE_MASK)
208 
209 #define SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT  16UL
210 #define SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_MASK   0x00010000UL
211 #define scu_get_command_protocl_engine_group(x) \
212                ((x) & SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_MASK)
213 
214 #define SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT           12UL
215 #define SCU_CONTEXT_COMMAND_LOGICAL_PORT_MASK            0x00007000UL
216 #define scu_get_command_reqeust_logical_port(x) \
217                ((x) & SCU_CONTEXT_COMMAND_LOGICAL_PORT_MASK)
218 
219 
220 #define MAKE_SCU_CONTEXT_COMMAND_TYPE(type) \
221    ((U32)(type) << SCU_CONTEXT_COMMAND_REQUEST_TYPE_SHIFT)
222 /*@}*/
223 
224 /**
225  * @name SCU_COMMAND_TYPES
226  *
227  * These constants provide the grouping of the different SCU command types.
228  */
229 /*@{*/
230 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC    MAKE_SCU_CONTEXT_COMMAND_TYPE(0UL)
231 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC    MAKE_SCU_CONTEXT_COMMAND_TYPE(1UL)
232 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC   MAKE_SCU_CONTEXT_COMMAND_TYPE(2UL)
233 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC   MAKE_SCU_CONTEXT_COMMAND_TYPE(3UL)
234 #define SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC  MAKE_SCU_CONTEXT_COMMAND_TYPE(6UL)
235 /*@}*/
236 
237 #define MAKE_SCU_CONTEXT_COMMAND_REQUEST(type, command) \
238    ((type) | (((U32)(command)) << SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_SHIFT))
239 
240 /**
241  * @name SCU_REQUEST_TYPES
242  *
243  * These constants are the various request types that can be posted to the SCU
244  * hardware.
245  */
246 /*@{*/
247 #define SCU_CONTEXT_COMMAND_REQUST_POST_TC \
248    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC, 0))
249 
250 #define SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT \
251    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC, 1))
252 
253 #define SCU_CONTEXT_COMMAND_REQUST_DUMP_TC \
254    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC, 0))
255 
256 #define SCU_CONTEXT_COMMAND_POST_RNC_32 \
257    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 0))
258 
259 #define SCU_CONTEXT_COMMAND_POST_RNC_96 \
260    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 1))
261 
262 #define SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE \
263    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 2))
264 
265 #define SCU_CONTEXT_COMMAND_DUMP_RNC_32 \
266    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC, 0))
267 
268 #define SCU_CONTEXT_COMMAND_DUMP_RNC_96 \
269    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC, 1))
270 
271 #define SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX \
272    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 0))
273 
274 #define SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX \
275    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 1))
276 
277 #define SCU_CONTEXT_COMMAND_POST_RNC_RESUME \
278    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 2))
279 
280 #define SCU_CONTEXT_IT_NEXUS_LOSS_TIMER_ENABLE \
281    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 3))
282 
283 #define SCU_CONTEXT_IT_NEXUS_LOSS_TIMER_DISABLE \
284    (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 4))
285 /*@}*/
286 
287 /**
288  * @name SCU_TASK_CONTEXT_PROTOCOL
289  * SCU Task context protocol types this is uesd to program the SCU Task
290  * context protocol field in word 0x00.
291  */
292 /*@{*/
293 #define SCU_TASK_CONTEXT_PROTOCOL_SMP    0x00
294 #define SCU_TASK_CONTEXT_PROTOCOL_SSP    0x01
295 #define SCU_TASK_CONTEXT_PROTOCOL_STP    0x02
296 #define SCU_TASK_CONTEXT_PROTOCOL_NONE   0x07
297 /*@}*/
298 
299 /**
300  * @struct SSP_TASK_CONTEXT
301  *
302  * @brief This is the SCU hardware definition for an SSP request.
303  */
304 struct SSP_TASK_CONTEXT
305 {
306    // OFFSET 0x18
307    U32  reserved00              : 24;
308    U32  frame_type              : 8;
309 
310    // OFFSET 0x1C
311    U32  reserved01;
312 
313    // OFFSET 0x20
314    U32  fill_bytes              : 2;
315    U32  reserved02              : 6;
316    U32  changing_data_pointer   : 1;
317    U32  retransmit              : 1;
318    U32  retry_data_frame        : 1;
319    U32  tlr_control             : 2;
320    U32  reserved03              : 19;
321 
322    // OFFSET 0x24
323    U32  uiRsvd4;
324 
325    // OFFSET 0x28
326    U32 target_port_transfer_tag : 16;
327    U32 tag                      : 16;
328 
329    // OFFSET 0x2C
330    U32 data_offset;
331 };
332 
333 /**
334  * @struct STP_TASK_CONTEXT
335  *
336  * @brief This is the SCU hardware definition for an STP request.
337  */
338 struct STP_TASK_CONTEXT
339 {
340    // OFFSET 0x18
341    U32 fis_type    : 8;
342    U32 pm_port     : 4;
343    U32 reserved0   : 3;
344    U32 control     : 1;
345    U32 command     : 8;
346    U32 features    : 8;
347 
348    // OFFSET 0x1C
349    U32 reserved1;
350 
351    // OFFSET 0x20
352    U32 reserved2;
353 
354    // OFFSET 0x24
355    U32 reserved3;
356 
357    // OFFSET 0x28
358    U32 ncq_tag     : 5;
359    U32 reserved4   : 27;
360 
361    // OFFSET 0x2C
362    U32 data_offset;    // TODO: What is this used for?
363 };
364 
365 /**
366  * @struct SMP_TASK_CONTEXT
367  *
368  * @brief This is the SCU hardware definition for an SMP request.
369  */
370 struct SMP_TASK_CONTEXT
371 {
372    // OFFSET 0x18
373    U32 response_length    : 8;
374    U32 function_result    : 8;
375    U32 function           : 8;
376    U32 frame_type         : 8;
377 
378    // OFFSET 0x1C
379    U32 smp_response_ufi   : 12;
380    U32 reserved1          : 20;
381 
382    // OFFSET 0x20
383    U32 reserved2;
384 
385    // OFFSET 0x24
386    U32 reserved3;
387 
388    // OFFSET 0x28
389    U32 reserved4;
390 
391    // OFFSET 0x2C
392    U32 reserved5;
393 };
394 
395 /**
396  * @struct PRIMITIVE_TASK_CONTEXT
397  *
398  * @brief This is the SCU hardware definition used when the driver wants to
399  *        send a primitive on the link.
400  */
401 struct PRIMITIVE_TASK_CONTEXT
402 {
403    // OFFSET 0x18
404    /**
405     * This field is the control word and it must be 0.
406     */
407    U32 control;  ///< must be set to 0
408 
409    // OFFSET 0x1C
410    /**
411     * This field specifies the primitive that is to be transmitted.
412     */
413    U32 sequence;
414 
415    // OFFSET 0x20
416    U32 reserved0;
417 
418    // OFFSET 0x24
419    U32 reserved1;
420 
421    // OFFSET 0x28
422    U32 reserved2;
423 
424    // OFFSET 0x2C
425    U32 reserved3;
426 };
427 
428 /**
429  * @union PROTOCOL_CONTEXT
430  *
431  * @brief The union of the protocols that can be selected in the SCU task
432  *        context field.
433  */
434 union PROTOCOL_CONTEXT
435 {
436     struct SSP_TASK_CONTEXT         ssp;
437     struct STP_TASK_CONTEXT         stp;
438     struct SMP_TASK_CONTEXT         smp;
439     struct PRIMITIVE_TASK_CONTEXT   primitive;
440     U32                             words[6];
441 };
442 
443 /**
444  * @struct SCU_SGL_ELEMENT
445  * @typedef SCU_SGL_ELEMENT_T
446  *
447  * @brief This structure represents a single SCU defined SGL element.
448  *
449  * SCU SGLs contain a 64 bit address with the maximum data transfer being 24
450  * bits in size.  The SGL can not cross a 4GB boundary.
451  */
452 typedef struct SCU_SGL_ELEMENT
453 {
454    /**
455     * This field is the upper 32 bits of the 64 bit physical address.
456     */
457    U32    address_upper;
458 
459    /**
460     * This field is the lower 32 bits of the 64 bit physical address.
461     */
462    U32    address_lower;
463 
464    /**
465     * This field is the number of bytes to transfer.
466     */
467    U32    length: 24;
468 
469    /**
470     * This field is the address modifier to be used when a virtual function is
471     * requesting a data transfer.
472     */
473    U32    address_modifier: 8;
474 
475 } SCU_SGL_ELEMENT_T;
476 
477 #define SCU_SGL_ELEMENT_PAIR_A   0
478 #define SCU_SGL_ELEMENT_PAIR_B   1
479 
480 /**
481  * @struct SCU_SGL_ELEMENT_PAIR
482  *
483  * @brief This structure is the SCU hardware definition of a pair of SGL
484  *        elements.
485  *
486  * The SCU hardware always works on SGL pairs.  They are referred to in the DS
487  * specification as SGL A and SGL B.  Each SGL pair is followed by the address
488  * of the next pair.
489  */
490 typedef struct SCU_SGL_ELEMENT_PAIR
491 {
492    // OFFSET 0x60-0x68
493    /**
494     * This field is the SGL element A of the SGL pair.
495     */
496    SCU_SGL_ELEMENT_T A;
497 
498    // OFFSET 0x6C-0x74
499    /**
500     * This field is the SGL element B of the SGL pair.
501     */
502    SCU_SGL_ELEMENT_T B;
503 
504    // OFFSET 0x78-0x7C
505    /**
506     * This field is the upper 32 bits of the 64 bit address to the next SGL
507     * element pair.
508     */
509    U32 next_pair_upper;
510 
511    /**
512     * This field is the lower 32 bits of the 64 bit address to the next SGL
513     * element pair.
514     */
515    U32 next_pair_lower;
516 
517 } SCU_SGL_ELEMENT_PAIR_T;
518 
519 /**
520  * @struct TRANSPORT_SNAPSHOT
521  *
522  * @brief This structure is the SCU hardware scratch area for the task
523  *        context.
524  *
525  * This is set to 0 by the driver but can be read by issuing a dump TC request
526  * to the SCU.
527  */
528 struct TRANSPORT_SNAPSHOT
529 {
530    // OFFSET 0x48
531    U32  xfer_rdy_write_data_length;
532 
533    // OFFSET 0x4C
534    U32  data_offset;
535 
536    // OFFSET 0x50
537    U32  data_transfer_size   : 24;
538    U32  reserved_50_0        : 8;
539 
540    // OFFSET 0x54
541    U32  next_initiator_write_data_offset;
542 
543    // OFFSET 0x58
544    U32  next_initiator_write_data_xfer_size : 24;
545    U32  reserved_58_0                       : 8;
546 };
547 
548 /**
549  * @struct SCU_TASK_CONTEXT
550  *
551  * @brief This structure defines the contents of the SCU silicon task context.
552  *        It lays out all of the fields according to the expected order and
553  *        location for the Storage Controller unit.
554  */
555 typedef struct SCU_TASK_CONTEXT
556 {
557    // OFFSET 0x00 ------
558    /**
559     * This field must be encoded to one of the valid SCU task priority values
560     *    - SCU_TASK_PRIORITY_NORMAL
561     *    - SCU_TASK_PRIORITY_HEAD_OF_Q
562     *    - SCU_TASK_PRIORITY_HIGH
563     */
564    U32    priority              : 2;
565 
566    /**
567     * This field must be set to TRUE if this is an initiator generated request.
568     * Until target mode is supported all task requests are initiator requests.
569     */
570    U32    initiator_request     : 1;
571 
572    /**
573     * This field must be set to one of the valid connection rates valid values
574     * are 0x8, 0x9, and 0xA.
575     */
576    U32    connection_rate       : 4;
577 
578    /**
579     * This field muse be programed when generating an SMP response since the SMP
580     * connection remains open until the SMP response is generated.
581     */
582    U32    protocol_engine_index : 3;
583 
584    /**
585     * This field must contain the logical port for the task request.
586     */
587    U32    logical_port_index    : 3;
588 
589    /**
590     * This field must be set to one of the SCU_TASK_CONTEXT_PROTOCOL values
591     *    - SCU_TASK_CONTEXT_PROTOCOL_SMP
592     *    - SCU_TASK_CONTEXT_PROTOCOL_SSP
593     *    - SCU_TASK_CONTEXT_PROTOCOL_STP
594     *    - SCU_TASK_CONTEXT_PROTOCOL_NONE
595     */
596    U32    protocol_type         : 3;
597 
598    /**
599     * This filed must be set to the TCi allocated for this task
600     */
601    U32    task_index            : 12;
602 
603    /**
604     * This field is reserved and must be set to 0x00
605     */
606    U32    reserved_00_0         : 1;
607 
608    /**
609     * For a normal task request this must be set to 0.  If this is an abort of
610     * this task request it must be set to 1.
611     */
612    U32    abort                 : 1;
613 
614    /**
615     * This field must be set to TRUE for the SCU hardware to process the task.
616     */
617    U32    valid                 : 1;
618 
619    /**
620     * This field must be set to SCU_TASK_CONTEXT_TYPE
621     */
622    U32    context_type          : 1;
623 
624    // OFFSET 0x04
625    /**
626     * This field contains the RNi that is the target of this request.
627     */
628    U32    remote_node_index     : 12;
629 
630    /**
631     * This field is programmed if this is a mirrored request, which we are not
632     * using, in which case it is the RNi for the mirrored target.
633     */
634    U32    mirrored_node_index   : 12;
635 
636    /**
637     * This field is programmed with the direction of the SATA reqeust
638     *    - SCU_SATA_WRITE_DATA_DIRECTION
639     *    - SCU_SATA_READ_DATA_DIRECTION
640     */
641    U32    sata_direction        : 1;
642 
643    /**
644     * This field is programmsed with one of the following SCU_COMMAND_CODE
645     *    - SCU_COMMAND_CODE_INITIATOR_NEW_TASK
646     *    - SCU_COMMAND_CODE_ACTIVE_TASK
647     *    - SCU_COMMAND_CODE_PRIMITIVE_SEQ_TASK
648     *    - SCU_COMMAND_CODE_TARGET_RAW_FRAMES
649     */
650    U32    command_code          : 2;
651 
652    /**
653     * This field is set to TRUE if the remote node should be suspended.
654     * This bit is only valid for SSP & SMP target devices.
655     */
656    U32    suspend_node          : 1;
657 
658    /**
659     * This field is programmed with one of the following command type codes
660     *
661     * For SAS requests use the SCU_SSP_TASK_TYPE
662     *    - SCU_TASK_TYPE_IOREAD
663     *    - SCU_TASK_TYPE_IOWRITE
664     *    - SCU_TASK_TYPE_SMP_REQUEST
665     *    - SCU_TASK_TYPE_RESPONSE
666     *    - SCU_TASK_TYPE_RAW_FRAME
667     *    - SCU_TASK_TYPE_PRIMITIVE
668     *
669     * For SATA requests use the SCU_SATA_TASK_TYPE
670     *    - SCU_TASK_TYPE_DMA_IN
671     *    - SCU_TASK_TYPE_FPDMAQ_READ
672     *    - SCU_TASK_TYPE_PACKET_DMA_IN
673     *    - SCU_TASK_TYPE_SATA_RAW_FRAME
674     *    - SCU_TASK_TYPE_DMA_OUT
675     *    - SCU_TASK_TYPE_FPDMAQ_WRITE
676     *    - SCU_TASK_TYPE_PACKET_DMA_OUT
677     */
678    U32    task_type             : 4;
679 
680    // OFFSET 0x08
681    /**
682     * This field is reserved and the must be set to 0x00
683     */
684    U32    link_layer_control          : 8;  // presently all reserved
685 
686    /**
687     * This field is set to TRUE when TLR is to be enabled
688     */
689    U32    ssp_tlr_enable              : 1;
690 
691    /**
692     * This is field specifies if the SCU DMAs a response frame to host
693     * memory for good response frames when operating in target mode.
694     */
695    U32    dma_ssp_target_good_response : 1;
696 
697    /**
698     * This field indicates if the SCU should DMA the response frame to
699     * host memory.
700     */
701    U32    do_not_dma_ssp_good_response : 1;
702 
703    /**
704     * This field is set to TRUE when strict ordering is to be enabled
705     */
706    U32    strict_ordering              : 1;
707 
708    /**
709     * This field indicates the type of endianness to be utilized for the
710     * frame.  command, task, and response frames utilized control_frame
711     * set to 1.
712     */
713    U32    control_frame               : 1;
714 
715    /**
716     * This field is reserved and the driver should set to 0x00
717     */
718    U32    tl_control_reserved         : 3;
719 
720    /**
721     * This field is set to TRUE when the SCU hardware task timeout control is to
722     * be enabled
723     */
724    U32    timeout_enable              : 1;
725 
726    /**
727     * This field is reserved and the driver should set it to 0x00
728     */
729    U32    pts_control_reserved        : 7;
730 
731    /**
732     * This field should be set to TRUE when block guard is to be enabled
733     */
734    U32    block_guard_enable          : 1;
735 
736    /**
737     * This field is reserved and the driver should set to 0x00
738     */
739    U32    sdma_control_reserved       : 7;
740 
741    // OFFSET 0x0C
742    /**
743     * This field is the address modifier for this io request it should be
744     * programmed with the virtual function that is making the request.
745     */
746    U32    address_modifier            : 16;
747 
748    /**
749     * @todo What we support mirrored SMP response frame?
750     */
751    U32    mirrored_protocol_engine    : 3;    // mirrored protocol Engine Index
752 
753    /**
754     * If this is a mirrored request the logical port index for the mirrored RNi
755     * must be programmed.
756     */
757    U32    mirrored_logical_port       : 4;    // mirrored local port index
758 
759    /**
760     * This field is reserved and the driver must set it to 0x00
761     */
762    U32    reserved_0C_0               : 8;
763 
764    /**
765     * This field must be set to TRUE if the mirrored request processing is to be
766     * enabled.
767     */
768    U32    mirror_request_enable       : 1;    // Mirrored request Enable
769 
770    // OFFSET 0x10
771    /**
772     * This field is the command iu length in dwords
773     */
774    U32    ssp_command_iu_length       : 8;
775 
776    /**
777     * This is the target TLR enable bit it must be set to 0 when creatning the
778     * task context.
779     */
780    U32    xfer_ready_tlr_enable       : 1;
781 
782    /**
783     * This field is reserved and the driver must set it to 0x00
784     */
785    U32    reserved_10_0               : 7;
786 
787    /**
788     * This is the maximum burst size that the SCU hardware will send in one
789     * connection its value is (N x 512) and N must be a multiple of 2.  If the
790     * value is 0x00 then maximum burst size is disabled.
791     */
792    U32    ssp_max_burst_size          : 16;
793 
794    // OFFSET 0x14
795    /**
796     * This filed is set to the number of bytes to be transferred in the request.
797     */
798    U32    transfer_length_bytes       : 24;   // In terms of bytes
799 
800    /**
801     * This field is reserved and the driver should set it to 0x00
802     */
803    U32    reserved_14_0               : 8;
804 
805    // OFFSET 0x18-0x2C
806    /**
807     * This union provides for the protocol specific part of the SCU Task Context.
808     */
809    union PROTOCOL_CONTEXT  type;
810 
811    // OFFSET 0x30-0x34
812    /**
813     * This field is the upper 32 bits of the 64 bit physical address of the
814     * command iu buffer
815     */
816    U32  command_iu_upper;
817 
818    /**
819     * This field is the lower 32 bits of the 64 bit physical address of the
820     * command iu buffer
821     */
822    U32  command_iu_lower;
823 
824    // OFFSET 0x38-0x3C
825    /**
826     * This field is the upper 32 bits of the 64 bit physical address of the
827     * response iu buffer
828     */
829    U32  response_iu_upper;
830 
831    /**
832     * This field is the lower 32 bits of the 64 bit physical address of the
833     * response iu buffer
834     */
835    U32  response_iu_lower;
836 
837    // OFFSET 0x40
838    /**
839     * This field is set to the task phase of the SCU hardware. The driver must
840     * set this to 0x01
841     */
842    U32  task_phase            : 8;
843 
844    /**
845     * This field is set to the transport layer task status.  The driver must set
846     * this to 0x00
847     */
848    U32  task_status           : 8;
849 
850    /**
851     * This field is used during initiator write TLR
852     */
853    U32  previous_extended_tag : 4;
854 
855    /**
856     * This field is set the maximum number of retries for a STP non-data FIS
857     */
858    U32  stp_retry_count       : 2;
859 
860    /**
861     * This field is reserved and the driver must set it to 0x00
862     */
863    U32  reserved_40_1         : 2;
864 
865    /**
866     * This field is used by the SCU TL to determine when to take a snapshot when
867     * tranmitting read data frames.
868     *    - 0x00 The entire IO
869     *    - 0x01 32k
870     *    - 0x02 64k
871     *    - 0x04 128k
872     *    - 0x08 256k
873     */
874    U32  ssp_tlr_threshold     : 4;
875 
876    /**
877     * This field is reserved and the driver must set it to 0x00
878     */
879    U32  reserved_40_2         : 4;
880 
881    // OFFSET 0x44
882    U32  write_data_length;   // read only set to 0
883 
884    // OFFSET 0x48-0x58
885    struct TRANSPORT_SNAPSHOT snapshot;  // read only set to 0
886 
887    // OFFSET 0x5C
888    U32  block_protection_enable       : 1;
889    U32  block_size                    : 2;
890    U32  block_protection_function     : 2;
891    U32  reserved_5C_0                 : 9;
892    U32  active_sgl_element            : 2;   // read only set to 0
893    U32  sgl_exhausted                 : 1;   // read only set to 0
894    U32  payload_data_transfer_error   : 4;   // read only set to 0
895    U32  frame_buffer_offset           : 11;  // read only set to 0
896 
897    // OFFSET 0x60-0x7C
898    /**
899     * This field is the first SGL element pair found in the TC data structure.
900     */
901    SCU_SGL_ELEMENT_PAIR_T sgl_pair_ab;
902    // OFFSET 0x80-0x9C
903    /**
904     * This field is the second SGL element pair found in the TC data structure.
905     */
906    SCU_SGL_ELEMENT_PAIR_T sgl_pair_cd;
907 
908    // OFFSET 0xA0-BC
909    SCU_SGL_ELEMENT_PAIR_T sgl_snapshot_ac;
910 
911    // OFFSET 0xC0
912    U32  active_sgl_element_pair; // read only set to 0
913 
914    // OFFSET 0xC4-0xCC
915    U32 reserved_C4_CC[3];
916 
917    // OFFSET 0xD0
918    U32  intermediate_crc_value : 16;
919    U32  initial_crc_seed       : 16;
920 
921    // OFFSET 0xD4
922    U32  application_tag_for_verify    : 16;
923    U32  application_tag_for_generate  : 16;
924 
925    // OFFSET 0xD8
926    U32  reference_tag_seed_for_verify_function;
927 
928    // OFFSET 0xDC
929    U32  reserved_DC;
930 
931    // OFFSET 0xE0
932    U32  reserved_E0_0                    : 16;
933    U32  application_tag_mask_for_generate: 16;
934 
935    // OFFSET 0xE4
936    U32  block_protection_control         : 16;
937    U32  application_tag_mask_for_verify  : 16;
938 
939    // OFFSET 0xE8
940    U32  block_protection_error  : 8;
941    U32  reserved_E8_0           :24;
942 
943    // OFFSET 0xEC
944    U32  reference_tag_seed_for_verify;
945 
946    // OFFSET 0xF0
947    U32  intermediate_crc_valid_snapshot  : 16;
948    U32  reserved_F0_0                    : 16;
949 
950    // OFFSET 0xF4
951    U32  reference_tag_seed_for_verify_function_snapshot;
952 
953    // OFFSET 0xF8
954    U32  snapshot_of_reserved_dword_DC_of_tc;
955 
956    // OFFSET 0xFC
957    U32  reference_tag_seed_for_generate_function_snapshot;
958 
959 } SCU_TASK_CONTEXT_T;
960 
961 #ifdef __cplusplus
962 }
963 #endif // __cplusplus
964 
965 #endif // _SCU_TASK_CONTEXT_H_
966