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