1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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
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**************************************/
44 * Helper Functions for the Configuration Framework
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.
54 * The helper functions query the QLM setup to help achieving the
57 * The second goal is accomplished by generating
58 * cvmx_helper_cfg_init() from a high-level lanaguage.
60 * <hr>$Revision: 0 $<hr>
63 #ifndef __CVMX_HELPER_CFG_H__
64 #define __CVMX_HELPER_CFG_H__
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
73 #define CVMX_HELPER_CFG_INVALID_VALUE -1 /* The default return
81 #define cvmx_helper_cfg_assert(cond) \
85 cvmx_dprintf("cvmx_helper_cfg_assert (%s) at %s:%d\n", \
86 #cond, __FILE__, __LINE__); \
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.
97 enum 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.
106 * For programs that fit inside
107 * L2, sending DWB just causes
108 * more L2 operations without
112 CVMX_HELPER_CFG_OPT_MAX
114 typedef enum cvmx_helper_cfg_option cvmx_helper_cfg_option_t;
118 * Return configured pknd for the port
120 * @param interface the interface number
121 * @param index the port's index number
124 extern int __cvmx_helper_cfg_pknd(int interface, int index);
128 * Return the configured bpid for the port
130 * @param interface the interface number
131 * @param index the port's index number
134 extern int __cvmx_helper_cfg_bpid(int interface, int index);
138 * Return the configured pko_port base for the port
140 * @param interface the interface number
141 * @param index the port's index number
142 * @return the pko_port base
144 extern int __cvmx_helper_cfg_pko_port_base(int interface, int index);
148 * Return the configured number of pko_ports for the port
150 * @param interface the interface number
151 * @param index the port's index number
152 * @return the number of pko_ports
154 extern int __cvmx_helper_cfg_pko_port_num(int interface, int index);
158 * Return the configured pko_queue base for the pko_port
161 * @return the pko_queue base
163 extern int __cvmx_helper_cfg_pko_queue_base(int pko_port);
167 * Return the configured number of pko_queues for the pko_port
170 * @return the number of pko_queues
172 extern int __cvmx_helper_cfg_pko_queue_num(int pko_port);
176 * Return the interface the pko_port is configured for
179 * @return the interface for the pko_port
181 extern int __cvmx_helper_cfg_pko_port_interface(int pko_port);
185 * Return the index of the port the pko_port is configured for
188 * @return the index of the port
190 extern int __cvmx_helper_cfg_pko_port_index(int pko_port);
194 * Return the pko_eid of the pko_port
197 * @return the pko_eid
199 extern int __cvmx_helper_cfg_pko_port_eid(int pko_port);
203 * Return the max# of pko queues allocated.
205 * @return the max# of pko queues
207 * Note: there might be holes in the queue space depending on user
208 * configuration. The function returns the highest queue's index in
211 extern int __cvmx_helper_cfg_pko_max_queue(void);
215 * Return the max# of PKO DMA engines allocated.
217 * @return the max# of DMA engines
219 * NOTE: the DMA engines are allocated contiguously and starting from
222 extern int __cvmx_helper_cfg_pko_max_engine(void);
225 * Get the value set for the config option ``opt''.
227 * @param opt is the config option.
228 * @return the value set for the option
230 extern uint64_t cvmx_helper_cfg_opt_get(cvmx_helper_cfg_option_t opt);
233 * Set the value for a config option.
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
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.
243 extern int cvmx_helper_cfg_opt_set(cvmx_helper_cfg_option_t opt, uint64_t val);
246 * Retrieve the pko_port base given ipd_port.
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.
252 extern int cvmx_helper_cfg_ipd2pko_port_base(int ipd_port);
255 * Retrieve the number of pko_ports given ipd_port.
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.
261 extern int cvmx_helper_cfg_ipd2pko_port_num(int ipd_port);
268 * @return 0 for success.
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
276 extern int __cvmx_helper_cfg_init(void);
282 #endif /* __CVMX_HELPER_CFG_H__ */