cvmx-zip.h revision 210286
194541Sru/***********************license start*************** 294541Sru * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights 394541Sru * reserved. 494541Sru * 594541Sru * 694541Sru * Redistribution and use in source and binary forms, with or without 794541Sru * modification, are permitted provided that the following conditions are 894541Sru * met: 994541Sru * 1094541Sru * * Redistributions of source code must retain the above copyright 1194541Sru * notice, this list of conditions and the following disclaimer. 1294541Sru * 1394541Sru * * Redistributions in binary form must reproduce the above 1494541Sru * copyright notice, this list of conditions and the following 1594541Sru * disclaimer in the documentation and/or other materials provided 1694541Sru * with the distribution. 1794541Sru * 1894541Sru * * Neither the name of Cavium Networks nor the names of 1994541Sru * its contributors may be used to endorse or promote products 2094541Sru * derived from this software without specific prior written 2194541Sru * permission. 2294541Sru * 2394541Sru * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 2494541Sru * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS 2594541Sru * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH 2694541Sru * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 2794541Sru * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 2894541Sru * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES 2994541Sru * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR 3094541Sru * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET 3194541Sru * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT 3294541Sru * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 3394541Sru * 3494541Sru * 3594541Sru * For any questions regarding licensing please contact marketing@caviumnetworks.com 3694541Sru * 3794541Sru ***********************license end**************************************/ 3894541Sru 3994541Sru 4094541Sru 4194541Sru 4294541Sru 4394541Sru 4494541Sru/** 4594541Sru * @file 4694541Sru * 4794541Sru * Header file for the zip (deflate) block 4894541Sru * 49115122Sru * <hr>$Revision: 41586 $<hr> 5094541Sru */ 5197388Sru 5294541Sru#ifndef __CVMX_ZIP_H__ 5394541Sru#define __CVMX_ZIP_H__ 5494541Sru 5594541Sru#ifdef __cplusplus 5694541Sruextern "C" { 5794541Sru#endif 5894541Sru 5994541Srutypedef union { 6094541Sru uint64_t u64; 6194541Sru struct { 6294541Sru#if __BYTE_ORDER == __BIG_ENDIAN 6394541Sru uint64_t unused : 5; 6494541Sru uint64_t full_block_write : 1; 6594541Sru uint64_t no_l2_alloc : 1; 6694541Sru uint64_t little_endian : 1; 6794541Sru uint64_t length : 16; 6894541Sru uint64_t ptr : 40; 6994541Sru#else 7094541Sru uint64_t ptr : 40; 7194541Sru uint64_t length : 16; 7294541Sru uint64_t little_endian : 1; 7394541Sru uint64_t no_l2_alloc : 1; 7494541Sru uint64_t full_block_write : 1; 7594541Sru uint64_t unused : 5; 7694541Sru#endif 7794541Sru } s; 7894541Sru} cvmx_zip_ptr_t; 7994541Sru#define CVMX_ZIP_PTR_MAX_LEN ((1 << 16) - 1) 8094541Sru 8194541Sru 8294541Srutypedef enum { 8394541Sru CVMX_ZIP_COMPLETION_NOTDONE = 0, 8494541Sru CVMX_ZIP_COMPLETION_SUCCESS = 1, 8594541Sru CVMX_ZIP_COMPLETION_OTRUNC = 2, 8694541Sru CVMX_ZIP_COMPLETION_STOP = 3, 8794541Sru CVMX_ZIP_COMPLETION_ITRUNC = 4, 8894541Sru CVMX_ZIP_COMPLETION_RBLOCK = 5, 8994541Sru CVMX_ZIP_COMPLETION_NLEN = 6, 9094541Sru CVMX_ZIP_COMPLETION_BADCODE = 7, 9194541Sru CVMX_ZIP_COMPLETION_BADCODE2 = 8, 9294541Sru CVMX_ZIP_COMPLETION_ZERO_LEN = 9, 9394541Sru CVMX_ZIP_COMPLETION_PARITY = 10 9494541Sru} cvmx_zip_completion_code_t; 9594541Sru 9694541Srutypedef union { 9794541Sru uint64_t u64[3]; 9894541Sru struct { 9994541Sru 10094541Sru // WORD 0 10194541Sru#if __BYTE_ORDER == __BIG_ENDIAN 10294541Sru uint64_t crc32 : 32; 10394541Sru uint64_t adler : 32; 10494541Sru#else 10594541Sru uint64_t adler : 32; 10694541Sru uint64_t crc32 : 32; 10794541Sru#endif 10894541Sru 10994541Sru // WORD 1 11094541Sru#if __BYTE_ORDER == __BIG_ENDIAN 11194541Sru uint64_t totalbyteswritten : 32; 11294541Sru uint64_t totalbytesread : 32; 11394541Sru#else 11494541Sru uint64_t totalbytesread : 32; 11594541Sru uint64_t totalbyteswritten : 32; 11694541Sru#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 141typedef 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 */ 222int 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 */ 230int 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 */ 239int 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__ */ 248