1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _NPI_ZCP_H 27 #define _NPI_ZCP_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <npi.h> 34 #include <nxge_zcp_hw.h> 35 36 typedef enum zcp_buf_region_e { 37 BAM_4BUF = 1, 38 BAM_8BUF = 2, 39 BAM_16BUF = 3, 40 BAM_32BUF = 4 41 } zcp_buf_region_t; 42 43 typedef enum zcp_config_e { 44 CFG_ZCP = 0x01, 45 CFG_ZCP_ECC_CHK = 0x02, 46 CFG_ZCP_PAR_CHK = 0x04, 47 CFG_ZCP_BUF_RESP = 0x08, 48 CFG_ZCP_BUF_REQ = 0x10, 49 CFG_ZCP_ALL = 0x1F 50 } zcp_config_t; 51 52 typedef enum zcp_iconfig_e { 53 ICFG_ZCP_RRFIFO_UNDERRUN = RRFIFO_UNDERRUN, 54 ICFG_ZCP_RRFIFO_OVERRUN = RRFIFO_OVERRUN, 55 ICFG_ZCP_RSPFIFO_UNCORR_ERR = RSPFIFO_UNCORR_ERR, 56 ICFG_ZCP_BUFFER_OVERFLOW = BUFFER_OVERFLOW, 57 ICFG_ZCP_STAT_TBL_PERR = STAT_TBL_PERR, 58 ICFG_ZCP_DYN_TBL_PERR = BUF_DYN_TBL_PERR, 59 ICFG_ZCP_BUF_TBL_PERR = BUF_TBL_PERR, 60 ICFG_ZCP_TT_PROGRAM_ERR = TT_PROGRAM_ERR, 61 ICFG_ZCP_RSP_TT_INDEX_ERR = RSP_TT_INDEX_ERR, 62 ICFG_ZCP_SLV_TT_INDEX_ERR = SLV_TT_INDEX_ERR, 63 ICFG_ZCP_TT_INDEX_ERR = ZCP_TT_INDEX_ERR, 64 ICFG_ZCP_CFIFO_ECC3 = CFIFO_ECC3, 65 ICFG_ZCP_CFIFO_ECC2 = CFIFO_ECC2, 66 ICFG_ZCP_CFIFO_ECC1 = CFIFO_ECC1, 67 ICFG_ZCP_CFIFO_ECC0 = CFIFO_ECC0, 68 ICFG_ZCP_ALL = (RRFIFO_UNDERRUN | RRFIFO_OVERRUN | 69 RSPFIFO_UNCORR_ERR | STAT_TBL_PERR | 70 BUF_DYN_TBL_PERR | BUF_TBL_PERR | 71 TT_PROGRAM_ERR | RSP_TT_INDEX_ERR | 72 SLV_TT_INDEX_ERR | ZCP_TT_INDEX_ERR | 73 CFIFO_ECC3 | CFIFO_ECC2 | CFIFO_ECC1 | 74 CFIFO_ECC0 | BUFFER_OVERFLOW) 75 } zcp_iconfig_t; 76 77 typedef enum tte_sflow_attr_mask_e { 78 TTE_RDC_TBL_OFF = 0x0001, 79 TTE_BUF_SIZE = 0x0002, 80 TTE_NUM_BUF = 0x0004, 81 TTE_ULP_END = 0x0008, 82 TTE_ULP_END_EN = 0x0010, 83 TTE_UNMAP_ALL_EN = 0x0020, 84 TTE_TMODE = 0x0040, 85 TTE_SKIP = 0x0080, 86 TTE_HBM_RING_BASE_ADDR = 0x0100, 87 TTE_HBM_RING_SIZE = 0x0200, 88 TTE_HBM_BUSY = 0x0400, 89 TTE_HBM_TOQ = 0x0800, 90 TTE_SFLOW_ATTR_ALL = 0x0FFF 91 } tte_sflow_attr_mask_t; 92 93 typedef enum tte_dflow_attr_mask_e { 94 TTE_MAPPED_IN = 0x0001, 95 TTE_ANCHOR_SEQ = 0x0002, 96 TTE_ANCHOR_OFFSET = 0x0004, 97 TTE_ANCHOR_BUFFER = 0x0008, 98 TTE_ANCHOR_BUF_FLAG = 0x0010, 99 TTE_UNMAP_ON_LEFT = 0x0020, 100 TTE_ULP_END_REACHED = 0x0040, 101 TTE_ERR_STAT = 0x0080, 102 TTE_HBM_WR_PTR = 0x0100, 103 TTE_HBM_HOQ = 0x0200, 104 TTE_HBM_PREFETCH_ON = 0x0400, 105 TTE_DFLOW_ATTR_ALL = 0x07FF 106 } tte_dflow_attr_mask_t; 107 108 #define IS_VALID_BAM_REGION(region)\ 109 ((region == BAM_4BUF) || (region == BAM_8BUF) ||\ 110 (region == BAM_16BUF) || (region == BAM_32BUF)) 111 112 #define ZCP_WAIT_RAM_READY(handle, val) {\ 113 uint32_t cnt = MAX_PIO_RETRIES;\ 114 do {\ 115 NXGE_REG_RD64(handle, ZCP_RAM_ACC_REG, &val);\ 116 cnt--;\ 117 } while ((ram_ctl.bits.ldw.busy != 0) && (cnt > 0));\ 118 } 119 120 #define ZCP_DMA_THRES_INVALID 0x10 121 #define ZCP_BAM_REGION_INVALID 0x11 122 #define ZCP_ROW_INDEX_INVALID 0x12 123 #define ZCP_SFLOW_ATTR_INVALID 0x13 124 #define ZCP_DFLOW_ATTR_INVALID 0x14 125 #define ZCP_FLOW_ID_INVALID 0x15 126 #define ZCP_BAM_BANK_INVALID 0x16 127 #define ZCP_BAM_WORD_EN_INVALID 0x17 128 129 #define NPI_ZCP_OPCODE_INVALID ((ZCP_BLK_ID << 8) | OPCODE_INVALID) 130 #define NPI_ZCP_CONFIG_INVALID ((ZCP_BLK_ID << 8) | CONFIG_INVALID) 131 #define NPI_ZCP_DMA_THRES_INVALID ((ZCP_BLK_ID << 8) |\ 132 ZCP_DMA_THRES_INVALID) 133 #define NPI_ZCP_BAM_REGION_INVALID ((ZCP_BLK_ID << 8) |\ 134 ZCP_BAM_REGION_INVALID) 135 #define NPI_ZCP_ROW_INDEX_INVALID ((ZCP_BLK_ID << 8) |\ 136 ZCP_ROW_INDEX_INVALID) 137 #define NPI_ZCP_SFLOW_ATTR_INVALID ((ZCP_BLK_ID << 8) |\ 138 ZCP_SFLOW_ATTR_INVALID) 139 #define NPI_ZCP_DFLOW_ATTR_INVALID ((ZCP_BLK_ID << 8) |\ 140 ZCP_DFLOW_ATTR_INVALID) 141 #define NPI_ZCP_FLOW_ID_INVALID ((ZCP_BLK_ID << 8) |\ 142 ZCP_FLOW_ID_INVALID) 143 #define NPI_ZCP_MEM_WRITE_FAILED ((ZCP_BLK_ID << 8) | WRITE_FAILED) 144 #define NPI_ZCP_MEM_READ_FAILED ((ZCP_BLK_ID << 8) | READ_FAILED) 145 #define NPI_ZCP_BAM_BANK_INVALID ((ZCP_BLK_ID << 8) |\ 146 (ZCP_BAM_BANK_INVALID)) 147 #define NPI_ZCP_BAM_WORD_EN_INVALID ((ZCP_BLK_ID << 8) |\ 148 (ZCP_BAM_WORD_EN_INVALID)) 149 #define NPI_ZCP_PORT_INVALID(portn) ((ZCP_BLK_ID << 8) | PORT_INVALID |\ 150 (portn << 12)) 151 152 /* ZCP HW NPI Prototypes */ 153 npi_status_t npi_zcp_config(npi_handle_t, config_op_t, 154 zcp_config_t); 155 npi_status_t npi_zcp_iconfig(npi_handle_t, config_op_t, 156 zcp_iconfig_t); 157 npi_status_t npi_zcp_get_istatus(npi_handle_t, zcp_iconfig_t *); 158 npi_status_t npi_zcp_clear_istatus(npi_handle_t); 159 npi_status_t npi_zcp_set_dma_thresh(npi_handle_t, uint16_t); 160 npi_status_t npi_zcp_set_bam_region(npi_handle_t, 161 zcp_buf_region_t, 162 zcp_bam_region_reg_t *); 163 npi_status_t npi_zcp_set_sdt_region(npi_handle_t, 164 zcp_buf_region_t, uint16_t); 165 npi_status_t npi_zcp_tt_static_entry(npi_handle_t, io_op_t, 166 uint16_t, tte_sflow_attr_mask_t, 167 tte_sflow_attr_t *); 168 npi_status_t npi_zcp_tt_dynamic_entry(npi_handle_t, io_op_t, 169 uint16_t, tte_dflow_attr_mask_t, 170 tte_dflow_attr_t *); 171 npi_status_t npi_zcp_tt_bam_entry(npi_handle_t, io_op_t, 172 uint16_t, uint8_t, 173 uint8_t, zcp_ram_unit_t *); 174 npi_status_t npi_zcp_tt_cfifo_entry(npi_handle_t, io_op_t, 175 uint8_t, uint16_t, 176 zcp_ram_unit_t *); 177 178 npi_status_t npi_zcp_rest_cfifo_port(npi_handle_t, uint8_t); 179 npi_status_t npi_zcp_rest_cfifo_all(npi_handle_t); 180 181 #ifdef __cplusplus 182 } 183 #endif 184 185 #endif /* _NPI_ZCP_H */ 186