18c2ecf20Sopenharmony_ci/***********************license start************************************
28c2ecf20Sopenharmony_ci * Copyright (c) 2003-2017 Cavium, Inc.
38c2ecf20Sopenharmony_ci * All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * License: one of 'Cavium License' or 'GNU General Public License Version 2'
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This file is provided under the terms of the Cavium License (see below)
88c2ecf20Sopenharmony_ci * or under the terms of GNU General Public License, Version 2, as
98c2ecf20Sopenharmony_ci * published by the Free Software Foundation. When using or redistributing
108c2ecf20Sopenharmony_ci * this file, you may do so under either license.
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Cavium License:  Redistribution and use in source and binary forms, with
138c2ecf20Sopenharmony_ci * or without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci * conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *  * Redistributions of source code must retain the above copyright
178c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci *  * Redistributions in binary form must reproduce the above
208c2ecf20Sopenharmony_ci *    copyright notice, this list of conditions and the following
218c2ecf20Sopenharmony_ci *    disclaimer in the documentation and/or other materials provided
228c2ecf20Sopenharmony_ci *    with the distribution.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci *  * Neither the name of Cavium Inc. nor the names of its contributors may be
258c2ecf20Sopenharmony_ci *    used to endorse or promote products derived from this software without
268c2ecf20Sopenharmony_ci *    specific prior written permission.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * This Software, including technical data, may be subject to U.S. export
298c2ecf20Sopenharmony_ci * control laws, including the U.S. Export Administration Act and its
308c2ecf20Sopenharmony_ci * associated regulations, and may be subject to export or import
318c2ecf20Sopenharmony_ci * regulations in other countries.
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
348c2ecf20Sopenharmony_ci * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS
358c2ecf20Sopenharmony_ci * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
368c2ecf20Sopenharmony_ci * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
378c2ecf20Sopenharmony_ci * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
388c2ecf20Sopenharmony_ci * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY)
398c2ecf20Sopenharmony_ci * WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A
408c2ecf20Sopenharmony_ci * PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET
418c2ecf20Sopenharmony_ci * ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE
428c2ecf20Sopenharmony_ci * ENTIRE  RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES
438c2ecf20Sopenharmony_ci * WITH YOU.
448c2ecf20Sopenharmony_ci ***********************license end**************************************/
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifndef __ZIP_MAIN_H__
478c2ecf20Sopenharmony_ci#define __ZIP_MAIN_H__
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#include "zip_device.h"
508c2ecf20Sopenharmony_ci#include "zip_regs.h"
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* PCI device IDs */
538c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_THUNDERX_ZIP   0xA01A
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* ZIP device BARs */
568c2ecf20Sopenharmony_ci#define PCI_CFG_ZIP_PF_BAR0   0  /* Base addr for normal regs */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* Maximum available zip queues */
598c2ecf20Sopenharmony_ci#define ZIP_MAX_NUM_QUEUES    8
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define ZIP_128B_ALIGN        7
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* Command queue buffer size */
648c2ecf20Sopenharmony_ci#define ZIP_CMD_QBUF_SIZE     (8064 + 8)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct zip_registers {
678c2ecf20Sopenharmony_ci	char  *reg_name;
688c2ecf20Sopenharmony_ci	u64   reg_offset;
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* ZIP Compression - Decompression stats */
728c2ecf20Sopenharmony_cistruct zip_stats {
738c2ecf20Sopenharmony_ci	atomic64_t    comp_req_submit;
748c2ecf20Sopenharmony_ci	atomic64_t    comp_req_complete;
758c2ecf20Sopenharmony_ci	atomic64_t    decomp_req_submit;
768c2ecf20Sopenharmony_ci	atomic64_t    decomp_req_complete;
778c2ecf20Sopenharmony_ci	atomic64_t    comp_in_bytes;
788c2ecf20Sopenharmony_ci	atomic64_t    comp_out_bytes;
798c2ecf20Sopenharmony_ci	atomic64_t    decomp_in_bytes;
808c2ecf20Sopenharmony_ci	atomic64_t    decomp_out_bytes;
818c2ecf20Sopenharmony_ci	atomic64_t    decomp_bad_reqs;
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* ZIP Instruction Queue */
858c2ecf20Sopenharmony_cistruct zip_iq {
868c2ecf20Sopenharmony_ci	u64        *sw_head;
878c2ecf20Sopenharmony_ci	u64        *sw_tail;
888c2ecf20Sopenharmony_ci	u64        *hw_tail;
898c2ecf20Sopenharmony_ci	u64        done_cnt;
908c2ecf20Sopenharmony_ci	u64        pend_cnt;
918c2ecf20Sopenharmony_ci	u64        free_flag;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	/* ZIP IQ lock */
948c2ecf20Sopenharmony_ci	spinlock_t  lock;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/* ZIP Device */
988c2ecf20Sopenharmony_cistruct zip_device {
998c2ecf20Sopenharmony_ci	u32               index;
1008c2ecf20Sopenharmony_ci	void __iomem      *reg_base;
1018c2ecf20Sopenharmony_ci	struct pci_dev    *pdev;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	/* Different ZIP Constants */
1048c2ecf20Sopenharmony_ci	u64               depth;
1058c2ecf20Sopenharmony_ci	u64               onfsize;
1068c2ecf20Sopenharmony_ci	u64               ctxsize;
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	struct zip_iq     iq[ZIP_MAX_NUM_QUEUES];
1098c2ecf20Sopenharmony_ci	struct zip_stats  stats;
1108c2ecf20Sopenharmony_ci};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* Prototypes */
1138c2ecf20Sopenharmony_cistruct zip_device *zip_get_device(int node_id);
1148c2ecf20Sopenharmony_ciint zip_get_node_id(void);
1158c2ecf20Sopenharmony_civoid zip_reg_write(u64 val, u64 __iomem *addr);
1168c2ecf20Sopenharmony_ciu64 zip_reg_read(u64 __iomem *addr);
1178c2ecf20Sopenharmony_civoid zip_update_cmd_bufs(struct zip_device *zip_dev, u32 queue);
1188c2ecf20Sopenharmony_ciu32 zip_load_instr(union zip_inst_s *instr, struct zip_device *zip_dev);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#endif /* ZIP_MAIN_H */
121