1445371e8SJerin Jacob /* 2445371e8SJerin Jacob * BSD LICENSE 3445371e8SJerin Jacob * 4445371e8SJerin Jacob * Copyright (C) Cavium Inc. 2017. All rights reserved. 5445371e8SJerin Jacob * 6445371e8SJerin Jacob * Redistribution and use in source and binary forms, with or without 7445371e8SJerin Jacob * modification, are permitted provided that the following conditions 8445371e8SJerin Jacob * are met: 9445371e8SJerin Jacob * 10445371e8SJerin Jacob * * Redistributions of source code must retain the above copyright 11445371e8SJerin Jacob * notice, this list of conditions and the following disclaimer. 12445371e8SJerin Jacob * * Redistributions in binary form must reproduce the above copyright 13445371e8SJerin Jacob * notice, this list of conditions and the following disclaimer in 14445371e8SJerin Jacob * the documentation and/or other materials provided with the 15445371e8SJerin Jacob * distribution. 16445371e8SJerin Jacob * * Neither the name of Cavium networks nor the names of its 17445371e8SJerin Jacob * contributors may be used to endorse or promote products derived 18445371e8SJerin Jacob * from this software without specific prior written permission. 19445371e8SJerin Jacob * 20445371e8SJerin Jacob * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21445371e8SJerin Jacob * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22445371e8SJerin Jacob * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23445371e8SJerin Jacob * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24445371e8SJerin Jacob * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25445371e8SJerin Jacob * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26445371e8SJerin Jacob * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27445371e8SJerin Jacob * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28445371e8SJerin Jacob * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29445371e8SJerin Jacob * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30445371e8SJerin Jacob * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31445371e8SJerin Jacob */ 32445371e8SJerin Jacob 33445371e8SJerin Jacob #ifndef __OCTEONTX_PKO_H__ 34445371e8SJerin Jacob #define __OCTEONTX_PKO_H__ 35445371e8SJerin Jacob 36445371e8SJerin Jacob /* PKO maximum constants */ 37445371e8SJerin Jacob #define PKO_VF_MAX (32) 38445371e8SJerin Jacob #define PKO_VF_NUM_DQ (8) 39445371e8SJerin Jacob #define PKO_MAX_NUM_DQ (8) 40445371e8SJerin Jacob #define PKO_DQ_DRAIN_TO (1000) 41445371e8SJerin Jacob 42445371e8SJerin Jacob #define PKO_DQ_FC_SKID (4) 43445371e8SJerin Jacob #define PKO_DQ_FC_DEPTH_PAGES (2048) 44445371e8SJerin Jacob #define PKO_DQ_FC_STRIDE_16 (16) 45445371e8SJerin Jacob #define PKO_DQ_FC_STRIDE_128 (128) 46445371e8SJerin Jacob #define PKO_DQ_FC_STRIDE PKO_DQ_FC_STRIDE_16 47445371e8SJerin Jacob 48445371e8SJerin Jacob #define PKO_DQ_KIND_BIT 49 49445371e8SJerin Jacob #define PKO_DQ_STATUS_BIT 60 50445371e8SJerin Jacob #define PKO_DQ_OP_BIT 48 51445371e8SJerin Jacob 52445371e8SJerin Jacob /* PKO VF register offsets from VF_BAR0 */ 53445371e8SJerin Jacob #define PKO_VF_DQ_SW_XOFF(gdq) (0x000100 | (gdq) << 17) 54445371e8SJerin Jacob #define PKO_VF_DQ_WM_CTL(gdq) (0x000130 | (gdq) << 17) 55445371e8SJerin Jacob #define PKO_VF_DQ_WM_CNT(gdq) (0x000150 | (gdq) << 17) 56445371e8SJerin Jacob #define PKO_VF_DQ_FC_CONFIG (0x000160) 57445371e8SJerin Jacob #define PKO_VF_DQ_FC_STATUS(gdq) (0x000168 | (gdq) << 17) 58445371e8SJerin Jacob #define PKO_VF_DQ_OP_SEND(gdq, op) (0x001000 | (gdq) << 17 | (op) << 3) 59445371e8SJerin Jacob #define PKO_VF_DQ_OP_OPEN(gdq) (0x001100 | (gdq) << 17) 60445371e8SJerin Jacob #define PKO_VF_DQ_OP_CLOSE(gdq) (0x001200 | (gdq) << 17) 61445371e8SJerin Jacob #define PKO_VF_DQ_OP_QUERY(gdq) (0x001300 | (gdq) << 17) 62445371e8SJerin Jacob 63cad78ca2SJerin Jacob /* pko_send_hdr_s + pko_send_link */ 64cad78ca2SJerin Jacob #define PKO_CMD_SZ (2 << 1) 65cad78ca2SJerin Jacob #define PKO_SEND_GATHER_SUBDC (0x0ull << 60) 66cad78ca2SJerin Jacob #define PKO_SEND_GATHER_LDTYPE(x) ((x) << 58) 67cad78ca2SJerin Jacob #define PKO_SEND_GATHER_GAUAR(x) ((x) << 24) 68cad78ca2SJerin Jacob 69cad78ca2SJerin Jacob typedef struct octeontx_dq_s { 70cad78ca2SJerin Jacob void *lmtline_va; 71cad78ca2SJerin Jacob void *ioreg_va; 72cad78ca2SJerin Jacob void *fc_status_va; 73cad78ca2SJerin Jacob } octeontx_dq_t; 74cad78ca2SJerin Jacob 75*3813a10aSJerin Jacob /** 76*3813a10aSJerin Jacob * Function for extracting information out of a given DQ. 77*3813a10aSJerin Jacob * 78*3813a10aSJerin Jacob * It is intended to be used in slow path (configuration) in 79*3813a10aSJerin Jacob * octeontx_pko_channel_query(). 80*3813a10aSJerin Jacob * 81*3813a10aSJerin Jacob * @param dq The DQ to extract information from. 82*3813a10aSJerin Jacob * @param out Pointer to the user's structure he wants to fill. 83*3813a10aSJerin Jacob */ 84*3813a10aSJerin Jacob typedef void (*octeontx_pko_dq_getter_t)(octeontx_dq_t *dq, void *out); 85*3813a10aSJerin Jacob 86*3813a10aSJerin Jacob int 87*3813a10aSJerin Jacob octeontx_pko_channel_query_dqs(int chanid, void *out, size_t out_elem_size, 88*3813a10aSJerin Jacob size_t dq_num, octeontx_pko_dq_getter_t getter); 89cad78ca2SJerin Jacob int octeontx_pko_channel_open(int dq_base, int dq_num, int chanid); 90cad78ca2SJerin Jacob int octeontx_pko_channel_close(int chanid); 91cad78ca2SJerin Jacob int octeontx_pko_channel_start(int chanid); 92cad78ca2SJerin Jacob int octeontx_pko_channel_stop(int chanid); 93*3813a10aSJerin Jacob int octeontx_pko_vf_count(void); 94*3813a10aSJerin Jacob int octeontx_pko_init_fc(const size_t pko_vf_count); 95*3813a10aSJerin Jacob void octeontx_pko_fc_free(void); 96cad78ca2SJerin Jacob 97445371e8SJerin Jacob #endif /* __OCTEONTX_PKO_H__ */ 98