diff options
Diffstat (limited to 'arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c')
-rw-r--r-- | arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c | 243 |
1 files changed, 0 insertions, 243 deletions
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c deleted file mode 100644 index c239e5f4ab9a..000000000000 --- a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | /***********************license start*************** | ||
2 | * Author: Cavium Networks | ||
3 | * | ||
4 | * Contact: support@caviumnetworks.com | ||
5 | * This file is part of the OCTEON SDK | ||
6 | * | ||
7 | * Copyright (c) 2003-2008 Cavium Networks | ||
8 | * | ||
9 | * This file is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License, Version 2, as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This file is distributed in the hope that it will be useful, but | ||
14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty | ||
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or | ||
16 | * NONINFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this file; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | * or visit http://www.gnu.org/licenses/. | ||
23 | * | ||
24 | * This file may also be available under a different license from Cavium. | ||
25 | * Contact Cavium Networks for more information | ||
26 | ***********************license end**************************************/ | ||
27 | |||
28 | /** | ||
29 | * @file | ||
30 | * | ||
31 | * Helper functions for FPA setup. | ||
32 | * | ||
33 | */ | ||
34 | #include "executive-config.h" | ||
35 | #include "cvmx-config.h" | ||
36 | #include "cvmx.h" | ||
37 | #include "cvmx-bootmem.h" | ||
38 | #include "cvmx-fpa.h" | ||
39 | #include "cvmx-helper-fpa.h" | ||
40 | |||
41 | /** | ||
42 | * Allocate memory for and initialize a single FPA pool. | ||
43 | * | ||
44 | * @pool: Pool to initialize | ||
45 | * @buffer_size: Size of buffers to allocate in bytes | ||
46 | * @buffers: Number of buffers to put in the pool. Zero is allowed | ||
47 | * @name: String name of the pool for debugging purposes | ||
48 | * Returns Zero on success, non-zero on failure | ||
49 | */ | ||
50 | static int __cvmx_helper_initialize_fpa_pool(int pool, uint64_t buffer_size, | ||
51 | uint64_t buffers, const char *name) | ||
52 | { | ||
53 | uint64_t current_num; | ||
54 | void *memory; | ||
55 | uint64_t align = CVMX_CACHE_LINE_SIZE; | ||
56 | |||
57 | /* | ||
58 | * Align the allocation so that power of 2 size buffers are | ||
59 | * naturally aligned. | ||
60 | */ | ||
61 | while (align < buffer_size) | ||
62 | align = align << 1; | ||
63 | |||
64 | if (buffers == 0) | ||
65 | return 0; | ||
66 | |||
67 | current_num = cvmx_read_csr(CVMX_FPA_QUEX_AVAILABLE(pool)); | ||
68 | if (current_num) { | ||
69 | cvmx_dprintf("Fpa pool %d(%s) already has %llu buffers. " | ||
70 | "Skipping setup.\n", | ||
71 | pool, name, (unsigned long long)current_num); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | memory = cvmx_bootmem_alloc(buffer_size * buffers, align); | ||
76 | if (memory == NULL) { | ||
77 | cvmx_dprintf("Out of memory initializing fpa pool %d(%s).\n", | ||
78 | pool, name); | ||
79 | return -1; | ||
80 | } | ||
81 | cvmx_fpa_setup_pool(pool, name, memory, buffer_size, buffers); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * Allocate memory and initialize the FPA pools using memory | ||
87 | * from cvmx-bootmem. Specifying zero for the number of | ||
88 | * buffers will cause that FPA pool to not be setup. This is | ||
89 | * useful if you aren't using some of the hardware and want | ||
90 | * to save memory. Use cvmx_helper_initialize_fpa instead of | ||
91 | * this function directly. | ||
92 | * | ||
93 | * @pip_pool: Should always be CVMX_FPA_PACKET_POOL | ||
94 | * @pip_size: Should always be CVMX_FPA_PACKET_POOL_SIZE | ||
95 | * @pip_buffers: | ||
96 | * Number of packet buffers. | ||
97 | * @wqe_pool: Should always be CVMX_FPA_WQE_POOL | ||
98 | * @wqe_size: Should always be CVMX_FPA_WQE_POOL_SIZE | ||
99 | * @wqe_entries: | ||
100 | * Number of work queue entries | ||
101 | * @pko_pool: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL | ||
102 | * @pko_size: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE | ||
103 | * @pko_buffers: | ||
104 | * PKO Command buffers. You should at minimum have two per | ||
105 | * each PKO queue. | ||
106 | * @tim_pool: Should always be CVMX_FPA_TIMER_POOL | ||
107 | * @tim_size: Should always be CVMX_FPA_TIMER_POOL_SIZE | ||
108 | * @tim_buffers: | ||
109 | * TIM ring buffer command queues. At least two per timer bucket | ||
110 | * is recommened. | ||
111 | * @dfa_pool: Should always be CVMX_FPA_DFA_POOL | ||
112 | * @dfa_size: Should always be CVMX_FPA_DFA_POOL_SIZE | ||
113 | * @dfa_buffers: | ||
114 | * DFA command buffer. A relatively small (32 for example) | ||
115 | * number should work. | ||
116 | * Returns Zero on success, non-zero if out of memory | ||
117 | */ | ||
118 | static int __cvmx_helper_initialize_fpa(int pip_pool, int pip_size, | ||
119 | int pip_buffers, int wqe_pool, | ||
120 | int wqe_size, int wqe_entries, | ||
121 | int pko_pool, int pko_size, | ||
122 | int pko_buffers, int tim_pool, | ||
123 | int tim_size, int tim_buffers, | ||
124 | int dfa_pool, int dfa_size, | ||
125 | int dfa_buffers) | ||
126 | { | ||
127 | int status; | ||
128 | |||
129 | cvmx_fpa_enable(); | ||
130 | |||
131 | if ((pip_buffers > 0) && (pip_buffers <= 64)) | ||
132 | cvmx_dprintf | ||
133 | ("Warning: %d packet buffers may not be enough for hardware" | ||
134 | " prefetch. 65 or more is recommended.\n", pip_buffers); | ||
135 | |||
136 | if (pip_pool >= 0) { | ||
137 | status = | ||
138 | __cvmx_helper_initialize_fpa_pool(pip_pool, pip_size, | ||
139 | pip_buffers, | ||
140 | "Packet Buffers"); | ||
141 | if (status) | ||
142 | return status; | ||
143 | } | ||
144 | |||
145 | if (wqe_pool >= 0) { | ||
146 | status = | ||
147 | __cvmx_helper_initialize_fpa_pool(wqe_pool, wqe_size, | ||
148 | wqe_entries, | ||
149 | "Work Queue Entries"); | ||
150 | if (status) | ||
151 | return status; | ||
152 | } | ||
153 | |||
154 | if (pko_pool >= 0) { | ||
155 | status = | ||
156 | __cvmx_helper_initialize_fpa_pool(pko_pool, pko_size, | ||
157 | pko_buffers, | ||
158 | "PKO Command Buffers"); | ||
159 | if (status) | ||
160 | return status; | ||
161 | } | ||
162 | |||
163 | if (tim_pool >= 0) { | ||
164 | status = | ||
165 | __cvmx_helper_initialize_fpa_pool(tim_pool, tim_size, | ||
166 | tim_buffers, | ||
167 | "TIM Command Buffers"); | ||
168 | if (status) | ||
169 | return status; | ||
170 | } | ||
171 | |||
172 | if (dfa_pool >= 0) { | ||
173 | status = | ||
174 | __cvmx_helper_initialize_fpa_pool(dfa_pool, dfa_size, | ||
175 | dfa_buffers, | ||
176 | "DFA Command Buffers"); | ||
177 | if (status) | ||
178 | return status; | ||
179 | } | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Allocate memory and initialize the FPA pools using memory | ||
186 | * from cvmx-bootmem. Sizes of each element in the pools is | ||
187 | * controlled by the cvmx-config.h header file. Specifying | ||
188 | * zero for any parameter will cause that FPA pool to not be | ||
189 | * setup. This is useful if you aren't using some of the | ||
190 | * hardware and want to save memory. | ||
191 | * | ||
192 | * @packet_buffers: | ||
193 | * Number of packet buffers to allocate | ||
194 | * @work_queue_entries: | ||
195 | * Number of work queue entries | ||
196 | * @pko_buffers: | ||
197 | * PKO Command buffers. You should at minimum have two per | ||
198 | * each PKO queue. | ||
199 | * @tim_buffers: | ||
200 | * TIM ring buffer command queues. At least two per timer bucket | ||
201 | * is recommened. | ||
202 | * @dfa_buffers: | ||
203 | * DFA command buffer. A relatively small (32 for example) | ||
204 | * number should work. | ||
205 | * Returns Zero on success, non-zero if out of memory | ||
206 | */ | ||
207 | int cvmx_helper_initialize_fpa(int packet_buffers, int work_queue_entries, | ||
208 | int pko_buffers, int tim_buffers, | ||
209 | int dfa_buffers) | ||
210 | { | ||
211 | #ifndef CVMX_FPA_PACKET_POOL | ||
212 | #define CVMX_FPA_PACKET_POOL -1 | ||
213 | #define CVMX_FPA_PACKET_POOL_SIZE 0 | ||
214 | #endif | ||
215 | #ifndef CVMX_FPA_WQE_POOL | ||
216 | #define CVMX_FPA_WQE_POOL -1 | ||
217 | #define CVMX_FPA_WQE_POOL_SIZE 0 | ||
218 | #endif | ||
219 | #ifndef CVMX_FPA_OUTPUT_BUFFER_POOL | ||
220 | #define CVMX_FPA_OUTPUT_BUFFER_POOL -1 | ||
221 | #define CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE 0 | ||
222 | #endif | ||
223 | #ifndef CVMX_FPA_TIMER_POOL | ||
224 | #define CVMX_FPA_TIMER_POOL -1 | ||
225 | #define CVMX_FPA_TIMER_POOL_SIZE 0 | ||
226 | #endif | ||
227 | #ifndef CVMX_FPA_DFA_POOL | ||
228 | #define CVMX_FPA_DFA_POOL -1 | ||
229 | #define CVMX_FPA_DFA_POOL_SIZE 0 | ||
230 | #endif | ||
231 | return __cvmx_helper_initialize_fpa(CVMX_FPA_PACKET_POOL, | ||
232 | CVMX_FPA_PACKET_POOL_SIZE, | ||
233 | packet_buffers, CVMX_FPA_WQE_POOL, | ||
234 | CVMX_FPA_WQE_POOL_SIZE, | ||
235 | work_queue_entries, | ||
236 | CVMX_FPA_OUTPUT_BUFFER_POOL, | ||
237 | CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, | ||
238 | pko_buffers, CVMX_FPA_TIMER_POOL, | ||
239 | CVMX_FPA_TIMER_POOL_SIZE, | ||
240 | tim_buffers, CVMX_FPA_DFA_POOL, | ||
241 | CVMX_FPA_DFA_POOL_SIZE, | ||
242 | dfa_buffers); | ||
243 | } | ||