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