cvmx-zip.h revision 232812
1/***********************license start***************
2 * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 *   * Redistributions of source code must retain the above copyright
11 *     notice, this list of conditions and the following disclaimer.
12 *
13 *   * Redistributions in binary form must reproduce the above
14 *     copyright notice, this list of conditions and the following
15 *     disclaimer in the documentation and/or other materials provided
16 *     with the distribution.
17
18 *   * Neither the name of Cavium Inc. nor the names of
19 *     its contributors may be used to endorse or promote products
20 *     derived from this software without specific prior written
21 *     permission.
22
23 * This Software, including technical data, may be subject to U.S. export  control
24 * laws, including the U.S. Export Administration Act and its  associated
25 * regulations, and may be subject to export or import  regulations in other
26 * countries.
27
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
39
40
41
42
43
44
45
46/**
47 * @file
48 *
49 * Header file for the zip (deflate) block
50 *
51 * <hr>$Revision: 70030 $<hr>
52 */
53
54#ifndef __CVMX_ZIP_H__
55#define __CVMX_ZIP_H__
56
57#ifdef	__cplusplus
58extern "C" {
59#endif
60
61typedef union {
62   uint64_t u64;
63   struct {
64#ifdef __BIG_ENDIAN_BITFIELD
65      uint64_t unused              :  5;
66      uint64_t full_block_write    :  1;
67      uint64_t no_l2_alloc         :  1;
68      uint64_t little_endian       :  1;
69      uint64_t length              : 16;
70      uint64_t ptr                 : 40;
71#else
72      uint64_t ptr                 : 40;
73      uint64_t length              : 16;
74      uint64_t little_endian       :  1;
75      uint64_t no_l2_alloc         :  1;
76      uint64_t full_block_write    :  1;
77      uint64_t unused              :  5;
78#endif
79   } s;
80} cvmx_zip_ptr_t;
81#define CVMX_ZIP_PTR_MAX_LEN    ((1 << 16) - 1)
82
83
84typedef enum {
85   CVMX_ZIP_COMPLETION_NOTDONE  = 0,
86   CVMX_ZIP_COMPLETION_SUCCESS  = 1,
87   CVMX_ZIP_COMPLETION_OTRUNC   = 2,
88   CVMX_ZIP_COMPLETION_STOP     = 3,
89   CVMX_ZIP_COMPLETION_ITRUNC   = 4,
90   CVMX_ZIP_COMPLETION_RBLOCK   = 5,
91   CVMX_ZIP_COMPLETION_NLEN     = 6,
92   CVMX_ZIP_COMPLETION_BADCODE  = 7,
93   CVMX_ZIP_COMPLETION_BADCODE2 = 8,
94   CVMX_ZIP_COMPLETION_ZERO_LEN = 9,
95   CVMX_ZIP_COMPLETION_PARITY   = 10,
96   CVMX_ZIP_COMPLETION_FATAL    = 11
97} cvmx_zip_completion_code_t;
98
99typedef union {
100   uint64_t u64[3];
101   struct {
102
103      // WORD 0
104#ifdef __BIG_ENDIAN_BITFIELD
105      uint64_t crc32               : 32;
106      uint64_t adler               : 32;
107#else
108      uint64_t adler               : 32;
109      uint64_t crc32               : 32;
110#endif
111
112      // WORD 1
113#ifdef __BIG_ENDIAN_BITFIELD
114      uint64_t totalbyteswritten   : 32;
115      uint64_t totalbytesread      : 32;
116#else
117      uint64_t totalbytesread      : 32;
118      uint64_t totalbyteswritten   : 32;
119#endif
120
121      // WORD 2
122#ifdef __BIG_ENDIAN_BITFIELD
123      uint64_t                      totalbitsprocessed  : 32; // decompression only
124      uint64_t                      unused20            :  5;
125      uint64_t                      exnum               :  3; // compression only
126      uint64_t                      unused21            :  1;
127      uint64_t                      exbits              :  7; // compression only
128      uint64_t                      unused22            :  7;
129      uint64_t                      eof                 :  1; // decompression only
130      cvmx_zip_completion_code_t    completioncode      :  8; // If polling, SW should set this to zero and wait for non-zero
131#else
132      cvmx_zip_completion_code_t    completioncode      :  8; // If polling, SW should set this to zero and wait for non-zero
133      uint64_t                      eof                 :  1; // decompression only
134      uint64_t                      unused22            :  7;
135      uint64_t                      exbits              :  7; // compression only
136      uint64_t                      unused21            :  1;
137      uint64_t                      exnum               :  3; // compression only
138      uint64_t                      unused20            :  5;
139      uint64_t                      totalbitsprocessed  : 32; // decompression only
140#endif
141   } s;
142} cvmx_zip_result_t;
143
144typedef union {
145   uint64_t u64[8];
146   struct {
147
148      // WORD 0
149#ifdef __BIG_ENDIAN_BITFIELD
150      uint64_t unused00            :  8;
151      uint64_t totaloutputlength   : 24;
152      uint64_t unused01            :  5;
153      uint64_t exnum               :  3;
154      uint64_t unused02            :  1;
155      uint64_t exbits              :  7;
156      uint64_t unused03            :  4;
157      uint64_t flush               :  1;
158      uint64_t speed               :  2;
159      uint64_t forcefixed          :  1;
160      uint64_t forcedynamic        :  1;
161      uint64_t eof                 :  1;
162      uint64_t bof                 :  1;
163      uint64_t compress            :  1;
164      uint64_t unused04            :  1;
165      uint64_t dscatter            :  1;
166      uint64_t dgather             :  1;
167      uint64_t hgather             :  1;
168#else
169      uint64_t hgather             :  1;
170      uint64_t dgather             :  1;
171      uint64_t dscatter            :  1;
172      uint64_t unused04            :  1;
173      uint64_t compress            :  1;
174      uint64_t bof                 :  1;
175      uint64_t eof                 :  1;
176      uint64_t forcedynamic        :  1;
177      uint64_t forcefixed          :  1;
178      uint64_t speed               :  2;
179      uint64_t flush               :  1;
180      uint64_t unused03            :  4;
181      uint64_t exbits              :  7;
182      uint64_t unused02            :  1;
183      uint64_t exnum               :  3;
184      uint64_t unused01            :  5;
185      uint64_t totaloutputlength   : 24;
186      uint64_t unused00            :  8;
187#endif
188
189      // WORD 1
190#ifdef __BIG_ENDIAN_BITFIELD
191      uint64_t historylength       : 16;
192      uint64_t unused10            : 16;
193      uint64_t adler32             : 32;
194#else
195      uint64_t adler32             : 32;
196      uint64_t unused10            : 16;
197      uint64_t historylength       : 16;
198#endif
199
200      // WORD 2
201      cvmx_zip_ptr_t ctx_ptr;
202
203      // WORD 3
204      cvmx_zip_ptr_t hist_ptr;
205
206      // WORD 4
207      cvmx_zip_ptr_t in_ptr;
208
209      // WORD 5
210      cvmx_zip_ptr_t out_ptr;
211
212      // WORD 6
213      cvmx_zip_ptr_t result_ptr;
214
215      // WORD 7
216      cvmx_zip_ptr_t wq_ptr;
217
218   } s;
219} cvmx_zip_command_t;
220
221
222/**
223 * Initialize the ZIP block
224 *
225 * @return Zero on success, negative on failure
226 */
227int cvmx_zip_initialize(void);
228
229/**
230 * Initialize the ZIP QUEUE buffer
231 *
232 * @param queue : ZIP instruction queue
233 * @param zcoremask : ZIP coremask to use for this queue
234 *
235 * @return Zero on success, negative on failure
236 */
237int cvmx_zip_queue_initialize(int queue, int zcoremask);
238
239/**
240 * Shutdown the ZIP block. ZIP must be idle when
241 * this function is called.
242 *
243 * @return Zero on success, negative on failure
244 */
245int cvmx_zip_shutdown(void);
246
247/**
248 * Shutdown the ZIP block for a queue. ZIP must be idle when
249 * this function is called.
250 *
251 * @param queue   Zip instruction queue of the command
252 *
253 * @return Zero on success, negative on failure
254 */
255int cvmx_zip_queue_shutdown(int queue);
256
257/**
258 * Submit a command to the ZIP block
259 *
260 * @param command Zip command to submit
261 *
262 * @return Zero on success, negative on failure
263 */
264int cvmx_zip_submit(cvmx_zip_command_t *command);
265
266/**
267 * Submit a command to the ZIP block
268 *
269 * @param command Zip command to submit
270 * @param queue   Zip instruction queue of the command
271 *
272 * @return Zero on success, negative on failure
273 */
274int cvmx_zip_queue_submit(cvmx_zip_command_t *command, int queue);
275
276/* CSR typedefs have been moved to cvmx-zip-defs.h */
277
278#ifdef	__cplusplus
279}
280#endif
281
282#endif  /* __CVMX_ZIP_H__ */
283