isci: Intel(R) C600 Series Chipset Storage Control Unit Driver
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / scsi / isci / core / sci_base_memory_descriptor_list.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 _SCI_BASE_MEMORY_DESCRIPTOR_LIST_H_
57 #define _SCI_BASE_MEMORY_DESCRIPTOR_LIST_H_
58
59 /**
60  * This file contains the protected interface structures, constants and
61  *    interface methods for the struct sci_base_memory_descriptor_list object.
62  *
63  *
64  */
65
66
67 #include "sci_types.h"
68 #include "sci_memory_descriptor_list.h"
69
70
71 /**
72  * struct sci_base_memory_descriptor_list - This structure contains all of the
73  *    fields necessary to implement a simple stack for managing the list of
74  *    available controller indices.
75  *
76  *
77  */
78 struct sci_base_memory_descriptor_list {
79         /**
80          * This field indicates the length of the memory descriptor entry array.
81          */
82         u32 length;
83
84         /**
85          * This field is utilized to provide iterator pattern functionality.
86          * It indicates the index of the next memory descriptor in the iteration.
87          */
88         u32 next_index;
89
90         /**
91          * This field will point to the list of memory descriptors.
92          */
93         struct sci_physical_memory_descriptor *mde_array;
94
95         /**
96          * This field simply allows a user to chain memory descriptor lists
97          * together if desired.  This field will be initialized to
98          * SCI_INVALID_HANDLE.
99          */
100         struct sci_base_memory_descriptor_list *next_mdl;
101
102 };
103
104 /**
105  * sci_base_mdl_construct() - This method is invoked to construct an memory
106  *    descriptor list. It initializes the fields of the MDL.
107  * @mdl: This parameter specifies the memory descriptor list to be constructed.
108  * @mde_array: This parameter specifies the array of memory descriptor entries
109  *    to be managed by this list.
110  * @mde_array_length: This parameter specifies the size of the array of entries.
111  * @next_mdl: This parameter specifies a subsequent MDL object to be managed by
112  *    this MDL object.
113  *
114  * none.
115  */
116 void sci_base_mdl_construct(
117         struct sci_base_memory_descriptor_list *mdl,
118         struct sci_physical_memory_descriptor *mde_array,
119         u32 mde_array_length,
120         struct sci_base_memory_descriptor_list *next_mdl);
121
122 /**
123  * sci_base_mde_construct() -
124  *
125  * This macro constructs an memory descriptor entry with the given alignment
126  * and size
127  */
128 #define sci_base_mde_construct(mde, alignment, size, attributes) \
129         { \
130                 (mde)->constant_memory_alignment  = (alignment); \
131                 (mde)->constant_memory_size       = (size); \
132                 (mde)->constant_memory_attributes = (attributes); \
133         }
134
135 /**
136  * sci_base_mde_is_valid() - This method validates that the memory descriptor
137  *    is correctly filled out by the SCI User
138  * @mde: This parameter is the mde entry to validate
139  * @alignment: This parameter specifies the expected alignment of the memory
140  *    for the mde.
141  * @size: This parameter specifies the memory size expected for the mde its
142  *    value should not have been changed by the SCI User.
143  * @attributes: This parameter specifies the attributes for the memory
144  *    descriptor provided.
145  *
146  * bool This method returns an indication as to whether the supplied MDE is
147  * valid or not. true The MDE is valid. false The MDE is not valid.
148  */
149 bool sci_base_mde_is_valid(
150         struct sci_physical_memory_descriptor *mde,
151         u32 alignment,
152         u32 size,
153         u16 attributes);
154
155 #endif /* _SCI_BASE_MEMORY_DESCRIPTOR_LIST_H_ */