1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40 41/** 42 * @file 43 * 44 * Helper Functions for the Configuration Framework 45 * 46 * OCTEON_CN68XX introduces a flexible hw interface configuration 47 * scheme. To cope with this change and the requirements of 48 * configurability for other system resources, e.g., IPD/PIP pknd and 49 * PKO ports and queues, a configuration framework for the SDK is 50 * designed. It has two goals: first to recognize and establish the 51 * default configuration and, second, to allow the user to define key 52 * parameters in a high-level language. 53 * 54 * The helper functions query the QLM setup to help achieving the 55 * first goal. 56 * 57 * The second goal is accomplished by generating 58 * cvmx_helper_cfg_init() from a high-level lanaguage. 59 * 60 * <hr>$Revision: 0 $<hr> 61 */ 62 63#ifndef __CVMX_HELPER_CFG_H__ 64#define __CVMX_HELPER_CFG_H__ 65 66#define CVMX_HELPER_CFG_MAX_IFACE 9 67#define CVMX_HELPER_CFG_MAX_PKO_PORT 128 68#define CVMX_HELPER_CFG_MAX_PIP_BPID 64 69#define CVMX_HELPER_CFG_MAX_PIP_PKND 64 70#define CVMX_HELPER_CFG_MAX_PKO_QUEUES 256 71#define CVMX_HELPER_CFG_MAX_PORT_PER_IFACE 256 72 73#define CVMX_HELPER_CFG_INVALID_VALUE -1 /* The default return 74 * value upon failure 75 */ 76 77#ifdef __cplusplus 78extern "C" { 79#endif 80 81#define cvmx_helper_cfg_assert(cond) \ 82 do { \ 83 if (!(cond)) \ 84 { \ 85 cvmx_dprintf("cvmx_helper_cfg_assert (%s) at %s:%d\n", \ 86 #cond, __FILE__, __LINE__); \ 87 } \ 88 } while (0) 89 90/* 91 * Config Options 92 * 93 * These options have to be set via cvmx_helper_cfg_opt_set() before calling the 94 * routines that set up the hw. These routines process the options and set them 95 * correctly to take effect at runtime. 96 */ 97enum cvmx_helper_cfg_option { 98 CVMX_HELPER_CFG_OPT_USE_DWB, /* 99 * Global option to control if 100 * the SDK configures units (DMA, 101 * SSO, and PKO) to send don't 102 * write back (DWB) requests for 103 * freed buffers. Set to 1/0 to 104 * enable/disable DWB. 105 * 106 * For programs that fit inside 107 * L2, sending DWB just causes 108 * more L2 operations without 109 * benefit. 110 */ 111 112 CVMX_HELPER_CFG_OPT_MAX 113}; 114typedef enum cvmx_helper_cfg_option cvmx_helper_cfg_option_t; 115 116/* 117 * @INTERNAL 118 * Return configured pknd for the port 119 * 120 * @param interface the interface number 121 * @param index the port's index number 122 * @return the pknd 123 */ 124extern int __cvmx_helper_cfg_pknd(int interface, int index); 125 126/* 127 * @INTERNAL 128 * Return the configured bpid for the port 129 * 130 * @param interface the interface number 131 * @param index the port's index number 132 * @return the bpid 133 */ 134extern int __cvmx_helper_cfg_bpid(int interface, int index); 135 136/* 137 * @INTERNAL 138 * Return the configured pko_port base for the port 139 * 140 * @param interface the interface number 141 * @param index the port's index number 142 * @return the pko_port base 143 */ 144extern int __cvmx_helper_cfg_pko_port_base(int interface, int index); 145 146/* 147 * @INTERNAL 148 * Return the configured number of pko_ports for the port 149 * 150 * @param interface the interface number 151 * @param index the port's index number 152 * @return the number of pko_ports 153 */ 154extern int __cvmx_helper_cfg_pko_port_num(int interface, int index); 155 156/* 157 * @INTERNAL 158 * Return the configured pko_queue base for the pko_port 159 * 160 * @param pko_port 161 * @return the pko_queue base 162 */ 163extern int __cvmx_helper_cfg_pko_queue_base(int pko_port); 164 165/* 166 * @INTERNAL 167 * Return the configured number of pko_queues for the pko_port 168 * 169 * @param pko_port 170 * @return the number of pko_queues 171 */ 172extern int __cvmx_helper_cfg_pko_queue_num(int pko_port); 173 174/* 175 * @INTERNAL 176 * Return the interface the pko_port is configured for 177 * 178 * @param pko_port 179 * @return the interface for the pko_port 180 */ 181extern int __cvmx_helper_cfg_pko_port_interface(int pko_port); 182 183/* 184 * @INTERNAL 185 * Return the index of the port the pko_port is configured for 186 * 187 * @param pko_port 188 * @return the index of the port 189 */ 190extern int __cvmx_helper_cfg_pko_port_index(int pko_port); 191 192/* 193 * @INTERNAL 194 * Return the pko_eid of the pko_port 195 * 196 * @param pko_port 197 * @return the pko_eid 198 */ 199extern int __cvmx_helper_cfg_pko_port_eid(int pko_port); 200 201/* 202 * @INTERNAL 203 * Return the max# of pko queues allocated. 204 * 205 * @return the max# of pko queues 206 * 207 * Note: there might be holes in the queue space depending on user 208 * configuration. The function returns the highest queue's index in 209 * use. 210 */ 211extern int __cvmx_helper_cfg_pko_max_queue(void); 212 213/* 214 * @INTERNAL 215 * Return the max# of PKO DMA engines allocated. 216 * 217 * @return the max# of DMA engines 218 * 219 * NOTE: the DMA engines are allocated contiguously and starting from 220 * 0. 221 */ 222extern int __cvmx_helper_cfg_pko_max_engine(void); 223 224/* 225 * Get the value set for the config option ``opt''. 226 * 227 * @param opt is the config option. 228 * @return the value set for the option 229 */ 230extern uint64_t cvmx_helper_cfg_opt_get(cvmx_helper_cfg_option_t opt); 231 232/* 233 * Set the value for a config option. 234 * 235 * @param opt is the config option. 236 * @param val is the value to set for the opt. 237 * @return 0 for success and -1 on error 238 * 239 * Note an option here is a config-time parameter and this means that 240 * it has to be set before calling the corresponding setup functions 241 * that actually sets the option in hw. 242 */ 243extern int cvmx_helper_cfg_opt_set(cvmx_helper_cfg_option_t opt, uint64_t val); 244 245/* 246 * Retrieve the pko_port base given ipd_port. 247 * 248 * @param ipd_port is the IPD eport 249 * @return the corresponding PKO port base for the physical port 250 * represented by the IPD eport or CVMX_HELPER_CFG_INVALID_VALUE. 251 */ 252extern int cvmx_helper_cfg_ipd2pko_port_base(int ipd_port); 253 254/* 255 * Retrieve the number of pko_ports given ipd_port. 256 * 257 * @param ipd_port is the IPD eport 258 * @return the corresponding number of PKO ports for the physical port 259 * represented by IPD eport or CVMX_HELPER_CFG_INVALID_VALUE. 260 */ 261extern int cvmx_helper_cfg_ipd2pko_port_num(int ipd_port); 262 263/* 264 * @INTERNAL 265 * The init function 266 * 267 * @param none 268 * @return 0 for success. 269 * 270 * Note: this function is meant to be called to set the ``configured 271 * parameters,'' e.g., pknd, bpid, etc. and therefore should be before 272 * any of the corresponding cvmx_helper_cfg_xxxx() functions are 273 * called. 274 */ 275 276extern int __cvmx_helper_cfg_init(void); 277 278#ifdef __cplusplus 279} 280#endif 281 282#endif /* __CVMX_HELPER_CFG_H__ */ 283