18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * Marvell OcteonTX CPT driver 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2019 Marvell International Ltd. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 78c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License version 2 as 88c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __OTX_CPTVF_H 128c2ecf20Sopenharmony_ci#define __OTX_CPTVF_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/list.h> 158c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 168c2ecf20Sopenharmony_ci#include <linux/device.h> 178c2ecf20Sopenharmony_ci#include "otx_cpt_common.h" 188c2ecf20Sopenharmony_ci#include "otx_cptvf_reqmgr.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* Flags to indicate the features supported */ 218c2ecf20Sopenharmony_ci#define OTX_CPT_FLAG_DEVICE_READY BIT(1) 228c2ecf20Sopenharmony_ci#define otx_cpt_device_ready(cpt) ((cpt)->flags & OTX_CPT_FLAG_DEVICE_READY) 238c2ecf20Sopenharmony_ci/* Default command queue length */ 248c2ecf20Sopenharmony_ci#define OTX_CPT_CMD_QLEN (4*2046) 258c2ecf20Sopenharmony_ci#define OTX_CPT_CMD_QCHUNK_SIZE 1023 268c2ecf20Sopenharmony_ci#define OTX_CPT_NUM_QS_PER_VF 1 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistruct otx_cpt_cmd_chunk { 298c2ecf20Sopenharmony_ci u8 *head; 308c2ecf20Sopenharmony_ci dma_addr_t dma_addr; 318c2ecf20Sopenharmony_ci u32 size; /* Chunk size, max OTX_CPT_INST_CHUNK_MAX_SIZE */ 328c2ecf20Sopenharmony_ci struct list_head nextchunk; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct otx_cpt_cmd_queue { 368c2ecf20Sopenharmony_ci u32 idx; /* Command queue host write idx */ 378c2ecf20Sopenharmony_ci u32 num_chunks; /* Number of command chunks */ 388c2ecf20Sopenharmony_ci struct otx_cpt_cmd_chunk *qhead;/* 398c2ecf20Sopenharmony_ci * Command queue head, instructions 408c2ecf20Sopenharmony_ci * are inserted here 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci struct otx_cpt_cmd_chunk *base; 438c2ecf20Sopenharmony_ci struct list_head chead; 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistruct otx_cpt_cmd_qinfo { 478c2ecf20Sopenharmony_ci u32 qchunksize; /* Command queue chunk size */ 488c2ecf20Sopenharmony_ci struct otx_cpt_cmd_queue queue[OTX_CPT_NUM_QS_PER_VF]; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct otx_cpt_pending_qinfo { 528c2ecf20Sopenharmony_ci u32 num_queues; /* Number of queues supported */ 538c2ecf20Sopenharmony_ci struct otx_cpt_pending_queue queue[OTX_CPT_NUM_QS_PER_VF]; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define for_each_pending_queue(qinfo, q, i) \ 578c2ecf20Sopenharmony_ci for (i = 0, q = &qinfo->queue[i]; i < qinfo->num_queues; i++, \ 588c2ecf20Sopenharmony_ci q = &qinfo->queue[i]) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct otx_cptvf_wqe { 618c2ecf20Sopenharmony_ci struct tasklet_struct twork; 628c2ecf20Sopenharmony_ci struct otx_cptvf *cptvf; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct otx_cptvf_wqe_info { 668c2ecf20Sopenharmony_ci struct otx_cptvf_wqe vq_wqe[OTX_CPT_NUM_QS_PER_VF]; 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistruct otx_cptvf { 708c2ecf20Sopenharmony_ci u16 flags; /* Flags to hold device status bits */ 718c2ecf20Sopenharmony_ci u8 vfid; /* Device Index 0...OTX_CPT_MAX_VF_NUM */ 728c2ecf20Sopenharmony_ci u8 num_vfs; /* Number of enabled VFs */ 738c2ecf20Sopenharmony_ci u8 vftype; /* VF type of SE_TYPE(2) or AE_TYPE(1) */ 748c2ecf20Sopenharmony_ci u8 vfgrp; /* VF group (0 - 8) */ 758c2ecf20Sopenharmony_ci u8 node; /* Operating node: Bits (46:44) in BAR0 address */ 768c2ecf20Sopenharmony_ci u8 priority; /* 778c2ecf20Sopenharmony_ci * VF priority ring: 1-High proirity round 788c2ecf20Sopenharmony_ci * robin ring;0-Low priority round robin ring; 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ci struct pci_dev *pdev; /* Pci device handle */ 818c2ecf20Sopenharmony_ci void __iomem *reg_base; /* Register start address */ 828c2ecf20Sopenharmony_ci void *wqe_info; /* BH worker info */ 838c2ecf20Sopenharmony_ci /* MSI-X */ 848c2ecf20Sopenharmony_ci cpumask_var_t affinity_mask[OTX_CPT_VF_MSIX_VECTORS]; 858c2ecf20Sopenharmony_ci /* Command and Pending queues */ 868c2ecf20Sopenharmony_ci u32 qsize; 878c2ecf20Sopenharmony_ci u32 num_queues; 888c2ecf20Sopenharmony_ci struct otx_cpt_cmd_qinfo cqinfo; /* Command queue information */ 898c2ecf20Sopenharmony_ci struct otx_cpt_pending_qinfo pqinfo; /* Pending queue information */ 908c2ecf20Sopenharmony_ci /* VF-PF mailbox communication */ 918c2ecf20Sopenharmony_ci bool pf_acked; 928c2ecf20Sopenharmony_ci bool pf_nacked; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ciint otx_cptvf_send_vf_up(struct otx_cptvf *cptvf); 968c2ecf20Sopenharmony_ciint otx_cptvf_send_vf_down(struct otx_cptvf *cptvf); 978c2ecf20Sopenharmony_ciint otx_cptvf_send_vf_to_grp_msg(struct otx_cptvf *cptvf, int group); 988c2ecf20Sopenharmony_ciint otx_cptvf_send_vf_priority_msg(struct otx_cptvf *cptvf); 998c2ecf20Sopenharmony_ciint otx_cptvf_send_vq_size_msg(struct otx_cptvf *cptvf); 1008c2ecf20Sopenharmony_ciint otx_cptvf_check_pf_ready(struct otx_cptvf *cptvf); 1018c2ecf20Sopenharmony_civoid otx_cptvf_handle_mbox_intr(struct otx_cptvf *cptvf); 1028c2ecf20Sopenharmony_civoid otx_cptvf_write_vq_doorbell(struct otx_cptvf *cptvf, u32 val); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#endif /* __OTX_CPTVF_H */ 105