1*4882a593Smuzhiyun /***********************license start************************************ 2*4882a593Smuzhiyun * Copyright (c) 2003-2017 Cavium, Inc. 3*4882a593Smuzhiyun * All rights reserved. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * License: one of 'Cavium License' or 'GNU General Public License Version 2' 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * This file is provided under the terms of the Cavium License (see below) 8*4882a593Smuzhiyun * or under the terms of GNU General Public License, Version 2, as 9*4882a593Smuzhiyun * published by the Free Software Foundation. When using or redistributing 10*4882a593Smuzhiyun * this file, you may do so under either license. 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * Cavium License: Redistribution and use in source and binary forms, with 13*4882a593Smuzhiyun * or without modification, are permitted provided that the following 14*4882a593Smuzhiyun * conditions are met: 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * * Redistributions of source code must retain the above copyright 17*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer. 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * * Redistributions in binary form must reproduce the above 20*4882a593Smuzhiyun * copyright notice, this list of conditions and the following 21*4882a593Smuzhiyun * disclaimer in the documentation and/or other materials provided 22*4882a593Smuzhiyun * with the distribution. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * * Neither the name of Cavium Inc. nor the names of its contributors may be 25*4882a593Smuzhiyun * used to endorse or promote products derived from this software without 26*4882a593Smuzhiyun * specific prior written permission. 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * This Software, including technical data, may be subject to U.S. export 29*4882a593Smuzhiyun * control laws, including the U.S. Export Administration Act and its 30*4882a593Smuzhiyun * associated regulations, and may be subject to export or import 31*4882a593Smuzhiyun * regulations in other countries. 32*4882a593Smuzhiyun * 33*4882a593Smuzhiyun * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 34*4882a593Smuzhiyun * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS 35*4882a593Smuzhiyun * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH 36*4882a593Smuzhiyun * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 37*4882a593Smuzhiyun * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 38*4882a593Smuzhiyun * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) 39*4882a593Smuzhiyun * WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A 40*4882a593Smuzhiyun * PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET 41*4882a593Smuzhiyun * ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE 42*4882a593Smuzhiyun * ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES 43*4882a593Smuzhiyun * WITH YOU. 44*4882a593Smuzhiyun ***********************license end**************************************/ 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #ifndef __ZIP_MAIN_H__ 47*4882a593Smuzhiyun #define __ZIP_MAIN_H__ 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun #include "zip_device.h" 50*4882a593Smuzhiyun #include "zip_regs.h" 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun /* PCI device IDs */ 53*4882a593Smuzhiyun #define PCI_DEVICE_ID_THUNDERX_ZIP 0xA01A 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* ZIP device BARs */ 56*4882a593Smuzhiyun #define PCI_CFG_ZIP_PF_BAR0 0 /* Base addr for normal regs */ 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* Maximum available zip queues */ 59*4882a593Smuzhiyun #define ZIP_MAX_NUM_QUEUES 8 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun #define ZIP_128B_ALIGN 7 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun /* Command queue buffer size */ 64*4882a593Smuzhiyun #define ZIP_CMD_QBUF_SIZE (8064 + 8) 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun struct zip_registers { 67*4882a593Smuzhiyun char *reg_name; 68*4882a593Smuzhiyun u64 reg_offset; 69*4882a593Smuzhiyun }; 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun /* ZIP Compression - Decompression stats */ 72*4882a593Smuzhiyun struct zip_stats { 73*4882a593Smuzhiyun atomic64_t comp_req_submit; 74*4882a593Smuzhiyun atomic64_t comp_req_complete; 75*4882a593Smuzhiyun atomic64_t decomp_req_submit; 76*4882a593Smuzhiyun atomic64_t decomp_req_complete; 77*4882a593Smuzhiyun atomic64_t comp_in_bytes; 78*4882a593Smuzhiyun atomic64_t comp_out_bytes; 79*4882a593Smuzhiyun atomic64_t decomp_in_bytes; 80*4882a593Smuzhiyun atomic64_t decomp_out_bytes; 81*4882a593Smuzhiyun atomic64_t decomp_bad_reqs; 82*4882a593Smuzhiyun }; 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun /* ZIP Instruction Queue */ 85*4882a593Smuzhiyun struct zip_iq { 86*4882a593Smuzhiyun u64 *sw_head; 87*4882a593Smuzhiyun u64 *sw_tail; 88*4882a593Smuzhiyun u64 *hw_tail; 89*4882a593Smuzhiyun u64 done_cnt; 90*4882a593Smuzhiyun u64 pend_cnt; 91*4882a593Smuzhiyun u64 free_flag; 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun /* ZIP IQ lock */ 94*4882a593Smuzhiyun spinlock_t lock; 95*4882a593Smuzhiyun }; 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun /* ZIP Device */ 98*4882a593Smuzhiyun struct zip_device { 99*4882a593Smuzhiyun u32 index; 100*4882a593Smuzhiyun void __iomem *reg_base; 101*4882a593Smuzhiyun struct pci_dev *pdev; 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun /* Different ZIP Constants */ 104*4882a593Smuzhiyun u64 depth; 105*4882a593Smuzhiyun u64 onfsize; 106*4882a593Smuzhiyun u64 ctxsize; 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun struct zip_iq iq[ZIP_MAX_NUM_QUEUES]; 109*4882a593Smuzhiyun struct zip_stats stats; 110*4882a593Smuzhiyun }; 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* Prototypes */ 113*4882a593Smuzhiyun struct zip_device *zip_get_device(int node_id); 114*4882a593Smuzhiyun int zip_get_node_id(void); 115*4882a593Smuzhiyun void zip_reg_write(u64 val, u64 __iomem *addr); 116*4882a593Smuzhiyun u64 zip_reg_read(u64 __iomem *addr); 117*4882a593Smuzhiyun void zip_update_cmd_bufs(struct zip_device *zip_dev, u32 queue); 118*4882a593Smuzhiyun u32 zip_load_instr(union zip_inst_s *instr, struct zip_device *zip_dev); 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun #endif /* ZIP_MAIN_H */ 121