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