]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-zip.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-zip.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 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  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43
44 /**
45  * @file
46  *
47  * Header file for the zip (deflate) block
48  *
49  * <hr>$Revision: 41586 $<hr>
50  */
51
52 #ifndef __CVMX_ZIP_H__
53 #define __CVMX_ZIP_H__
54
55 #ifdef  __cplusplus
56 extern "C" {
57 #endif
58
59 typedef union {
60    uint64_t u64;
61    struct {
62 #if __BYTE_ORDER == __BIG_ENDIAN
63       uint64_t unused              :  5;
64       uint64_t full_block_write    :  1;
65       uint64_t no_l2_alloc         :  1;
66       uint64_t little_endian       :  1;
67       uint64_t length              : 16;
68       uint64_t ptr                 : 40;
69 #else
70       uint64_t ptr                 : 40;
71       uint64_t length              : 16;
72       uint64_t little_endian       :  1;
73       uint64_t no_l2_alloc         :  1;
74       uint64_t full_block_write    :  1;
75       uint64_t unused              :  5;
76 #endif
77    } s;
78 } cvmx_zip_ptr_t;
79 #define CVMX_ZIP_PTR_MAX_LEN    ((1 << 16) - 1)
80
81
82 typedef enum {
83    CVMX_ZIP_COMPLETION_NOTDONE  = 0,
84    CVMX_ZIP_COMPLETION_SUCCESS  = 1,
85    CVMX_ZIP_COMPLETION_OTRUNC   = 2,
86    CVMX_ZIP_COMPLETION_STOP     = 3,
87    CVMX_ZIP_COMPLETION_ITRUNC   = 4,
88    CVMX_ZIP_COMPLETION_RBLOCK   = 5,
89    CVMX_ZIP_COMPLETION_NLEN     = 6,
90    CVMX_ZIP_COMPLETION_BADCODE  = 7,
91    CVMX_ZIP_COMPLETION_BADCODE2 = 8,
92    CVMX_ZIP_COMPLETION_ZERO_LEN = 9,
93    CVMX_ZIP_COMPLETION_PARITY   = 10
94 } cvmx_zip_completion_code_t;
95
96 typedef union {
97    uint64_t u64[3];
98    struct {
99
100       // WORD 0
101 #if __BYTE_ORDER == __BIG_ENDIAN
102       uint64_t crc32               : 32;
103       uint64_t adler               : 32;
104 #else
105       uint64_t adler               : 32;
106       uint64_t crc32               : 32;
107 #endif
108
109       // WORD 1
110 #if __BYTE_ORDER == __BIG_ENDIAN
111       uint64_t totalbyteswritten   : 32;
112       uint64_t totalbytesread      : 32;
113 #else
114       uint64_t totalbytesread      : 32;
115       uint64_t totalbyteswritten   : 32;
116 #endif
117
118       // WORD 2
119 #if __BYTE_ORDER == __BIG_ENDIAN
120       uint64_t                      totalbitsprocessed  : 32; // decompression only
121       uint64_t                      unused20            :  5;
122       uint64_t                      exnum               :  3; // compression only
123       uint64_t                      unused21            :  1;
124       uint64_t                      exbits              :  7; // compression only
125       uint64_t                      unused22            :  7;
126       uint64_t                      eof                 :  1; // decompression only
127       cvmx_zip_completion_code_t    completioncode      :  8; // If polling, SW should set this to zero and wait for non-zero
128 #else
129       cvmx_zip_completion_code_t    completioncode      :  8; // If polling, SW should set this to zero and wait for non-zero
130       uint64_t                      eof                 :  1; // decompression only
131       uint64_t                      unused22            :  7;
132       uint64_t                      exbits              :  7; // compression only
133       uint64_t                      unused21            :  1;
134       uint64_t                      exnum               :  3; // compression only
135       uint64_t                      unused20            :  5;
136       uint64_t                      totalbitsprocessed  : 32; // decompression only
137 #endif
138    } s;
139 } cvmx_zip_result_t;
140
141 typedef union {
142    uint64_t u64[8];
143    struct {
144
145       // WORD 0
146 #if __BYTE_ORDER == __BIG_ENDIAN
147       uint64_t unused00            :  8;
148       uint64_t totaloutputlength   : 24;
149       uint64_t unused01            :  5;
150       uint64_t exnum               :  3;
151       uint64_t unused02            :  1;
152       uint64_t exbits              :  7;
153       uint64_t unused03            :  6;
154       uint64_t speed               :  1;
155       uint64_t forcefixed          :  1;
156       uint64_t forcedynamic        :  1;
157       uint64_t eof                 :  1;
158       uint64_t bof                 :  1;
159       uint64_t compress            :  1;
160       uint64_t unused04            :  1;
161       uint64_t dscatter            :  1;
162       uint64_t dgather             :  1;
163       uint64_t hgather             :  1;
164 #else
165       uint64_t hgather             :  1;
166       uint64_t dgather             :  1;
167       uint64_t dscatter            :  1;
168       uint64_t unused04            :  1;
169       uint64_t compress            :  1;
170       uint64_t bof                 :  1;
171       uint64_t eof                 :  1;
172       uint64_t forcedynamic        :  1;
173       uint64_t forcefixed          :  1;
174       uint64_t speed               :  1;
175       uint64_t unused03            :  6;
176       uint64_t exbits              :  7;
177       uint64_t unused02            :  1;
178       uint64_t exnum               :  3;
179       uint64_t unused01            :  5;
180       uint64_t totaloutputlength   : 24;
181       uint64_t unused00            :  8;
182 #endif
183
184       // WORD 1
185 #if __BYTE_ORDER == __BIG_ENDIAN
186       uint64_t historylength       : 16;
187       uint64_t unused10            : 16;
188       uint64_t adler32             : 32;
189 #else
190       uint64_t adler32             : 32;
191       uint64_t unused10            : 16;
192       uint64_t historylength       : 16;
193 #endif
194
195       // WORD 2
196       cvmx_zip_ptr_t ctx_ptr;
197
198       // WORD 3
199       cvmx_zip_ptr_t hist_ptr;
200
201       // WORD 4
202       cvmx_zip_ptr_t in_ptr;
203
204       // WORD 5
205       cvmx_zip_ptr_t out_ptr;
206
207       // WORD 6
208       cvmx_zip_ptr_t result_ptr;
209
210       // WORD 7
211       cvmx_zip_ptr_t wq_ptr;
212
213    } s;
214 } cvmx_zip_command_t;
215
216
217 /**
218  * Initialize the ZIP block
219  *
220  * @return Zero on success, negative on failure
221  */
222 int cvmx_zip_initialize(void);
223
224 /**
225  * Shutdown the ZIP block. ZIP must be idle when
226  * this function is called.
227  *
228  * @return Zero on success, negative on failure
229  */
230 int cvmx_zip_shutdown(void);
231
232 /**
233  * Submit a command to the ZIP block
234  *
235  * @param command Zip command to submit
236  *
237  * @return Zero on success, negative on failure
238  */
239 int cvmx_zip_submit(cvmx_zip_command_t *command);
240
241 /* CSR typedefs have been moved to cvmx-csr-*.h */
242
243 #ifdef  __cplusplus
244 }
245 #endif
246
247 #endif  /* __CVMX_ZIP_H__ */