]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/octeon-sdk/cvmx-zip.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / octeon-sdk / cvmx-zip.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Networks (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 Networks 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  NETWORKS 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: 49448 $<hr>
52  */
53
54 #ifndef __CVMX_ZIP_H__
55 #define __CVMX_ZIP_H__
56
57 #ifdef  __cplusplus
58 extern "C" {
59 #endif
60
61 typedef union {
62    uint64_t u64;
63    struct {
64 #if __BYTE_ORDER == __BIG_ENDIAN
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
84 typedef 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
99 typedef union {
100    uint64_t u64[3];
101    struct {
102
103       // WORD 0
104 #if __BYTE_ORDER == __BIG_ENDIAN
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 #if __BYTE_ORDER == __BIG_ENDIAN
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 #if __BYTE_ORDER == __BIG_ENDIAN
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
144 typedef union {
145    uint64_t u64[8];
146    struct {
147
148       // WORD 0
149 #if __BYTE_ORDER == __BIG_ENDIAN
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            :  6;
157       uint64_t speed               :  1;
158       uint64_t forcefixed          :  1;
159       uint64_t forcedynamic        :  1;
160       uint64_t eof                 :  1;
161       uint64_t bof                 :  1;
162       uint64_t compress            :  1;
163       uint64_t unused04            :  1;
164       uint64_t dscatter            :  1;
165       uint64_t dgather             :  1;
166       uint64_t hgather             :  1;
167 #else
168       uint64_t hgather             :  1;
169       uint64_t dgather             :  1;
170       uint64_t dscatter            :  1;
171       uint64_t unused04            :  1;
172       uint64_t compress            :  1;
173       uint64_t bof                 :  1;
174       uint64_t eof                 :  1;
175       uint64_t forcedynamic        :  1;
176       uint64_t forcefixed          :  1;
177       uint64_t speed               :  1;
178       uint64_t unused03            :  6;
179       uint64_t exbits              :  7;
180       uint64_t unused02            :  1;
181       uint64_t exnum               :  3;
182       uint64_t unused01            :  5;
183       uint64_t totaloutputlength   : 24;
184       uint64_t unused00            :  8;
185 #endif
186
187       // WORD 1
188 #if __BYTE_ORDER == __BIG_ENDIAN
189       uint64_t historylength       : 16;
190       uint64_t unused10            : 16;
191       uint64_t adler32             : 32;
192 #else
193       uint64_t adler32             : 32;
194       uint64_t unused10            : 16;
195       uint64_t historylength       : 16;
196 #endif
197
198       // WORD 2
199       cvmx_zip_ptr_t ctx_ptr;
200
201       // WORD 3
202       cvmx_zip_ptr_t hist_ptr;
203
204       // WORD 4
205       cvmx_zip_ptr_t in_ptr;
206
207       // WORD 5
208       cvmx_zip_ptr_t out_ptr;
209
210       // WORD 6
211       cvmx_zip_ptr_t result_ptr;
212
213       // WORD 7
214       cvmx_zip_ptr_t wq_ptr;
215
216    } s;
217 } cvmx_zip_command_t;
218
219
220 /**
221  * Initialize the ZIP block
222  *
223  * @return Zero on success, negative on failure
224  */
225 int cvmx_zip_initialize(void);
226
227 /**
228  * Shutdown the ZIP block. ZIP must be idle when
229  * this function is called.
230  *
231  * @return Zero on success, negative on failure
232  */
233 int cvmx_zip_shutdown(void);
234
235 /**
236  * Submit a command to the ZIP block
237  *
238  * @param command Zip command to submit
239  *
240  * @return Zero on success, negative on failure
241  */
242 int cvmx_zip_submit(cvmx_zip_command_t *command);
243
244 /* CSR typedefs have been moved to cvmx-zip-defs.h */
245
246 #ifdef  __cplusplus
247 }
248 #endif
249
250 #endif  /* __CVMX_ZIP_H__ */