1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Networks (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 Networks 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 NETWORKS 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**************************************/
49 * Helper functions for common, but complicated tasks.
51 * <hr>$Revision: 49448 $<hr>
54 #ifndef __CVMX_HELPER_H__
55 #define __CVMX_HELPER_H__
57 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
58 #include <asm/octeon/cvmx.h>
59 #include <asm/octeon/cvmx-config.h>
60 #elif !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL)
61 #include "executive-config.h"
62 #include "cvmx-config.h"
74 CVMX_HELPER_INTERFACE_MODE_DISABLED,
75 CVMX_HELPER_INTERFACE_MODE_RGMII,
76 CVMX_HELPER_INTERFACE_MODE_GMII,
77 CVMX_HELPER_INTERFACE_MODE_SPI,
78 CVMX_HELPER_INTERFACE_MODE_PCIE,
79 CVMX_HELPER_INTERFACE_MODE_XAUI,
80 CVMX_HELPER_INTERFACE_MODE_SGMII,
81 CVMX_HELPER_INTERFACE_MODE_PICMG,
82 CVMX_HELPER_INTERFACE_MODE_NPI,
83 CVMX_HELPER_INTERFACE_MODE_LOOP,
84 CVMX_HELPER_INTERFACE_MODE_SRIO,
85 } cvmx_helper_interface_mode_t;
92 uint64_t reserved_20_63 : 44;
93 uint64_t link_up : 1; /**< Is the physical link up? */
94 uint64_t full_duplex : 1; /**< 1 if the link is full duplex */
95 uint64_t speed : 18; /**< Speed of the link in Mbps */
97 } cvmx_helper_link_info_t;
99 #include "cvmx-helper-fpa.h"
101 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
103 #include "cvmx-helper-errata.h"
104 #include "cvmx-helper-loop.h"
105 #include "cvmx-helper-npi.h"
106 #include "cvmx-helper-rgmii.h"
107 #include "cvmx-helper-sgmii.h"
108 #include "cvmx-helper-spi.h"
109 #include "cvmx-helper-srio.h"
110 #include "cvmx-helper-xaui.h"
113 * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
114 * priorities[16]) is a function pointer. It is meant to allow
115 * customization of the PKO queue priorities based on the port
116 * number. Users should set this pointer to a function before
117 * calling any cvmx-helper operations.
119 extern void (*cvmx_override_pko_queue_priority)(int pko_port, uint64_t priorities[16]);
122 * cvmx_override_ipd_port_setup(int ipd_port) is a function
123 * pointer. It is meant to allow customization of the IPD port
124 * setup before packet input/output comes online. It is called
125 * after cvmx-helper does the default IPD configuration, but
126 * before IPD is enabled. Users should set this pointer to a
127 * function before calling any cvmx-helper operations.
129 extern void (*cvmx_override_ipd_port_setup)(int ipd_port);
132 * This function enables the IPD and also enables the packet interfaces.
133 * The packet interfaces (RGMII and SPI) must be enabled after the
134 * IPD. This should be called by the user program after any additional
135 * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD
136 * is not set in the executive-config.h file.
138 * @return 0 on success
141 extern int cvmx_helper_ipd_and_packet_input_enable(void);
144 * Initialize the PIP, IPD, and PKO hardware to support
145 * simple priority based queues for the ethernet ports. Each
146 * port is configured with a number of priority queues based
147 * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower
148 * priority than the previous.
150 * @return Zero on success, non-zero on failure
152 extern int cvmx_helper_initialize_packet_io_global(void);
155 * Does core local initialization for packet io
157 * @return Zero on success, non-zero on failure
159 extern int cvmx_helper_initialize_packet_io_local(void);
162 * Undo the initialization performed in
163 * cvmx_helper_initialize_packet_io_global(). After calling this routine and the
164 * local version on each core, packet IO for Octeon will be disabled and placed
165 * in the initial reset state. It will then be safe to call the initialize
166 * later on. Note that this routine does not empty the FPA pools. It frees all
167 * buffers used by the packet IO hardware to the FPA so a function emptying the
168 * FPA after shutdown should find all packet buffers in the FPA.
170 * @return Zero on success, negative on failure.
172 extern int cvmx_helper_shutdown_packet_io_global(void);
175 * Does core local shutdown of packet io
177 * @return Zero on success, non-zero on failure
179 extern int cvmx_helper_shutdown_packet_io_local(void);
182 * Returns the number of ports on the given interface.
183 * The interface must be initialized before the port count
186 * @param interface Which interface to return port count for.
188 * @return Port count for interface
189 * -1 for uninitialized interface
191 extern int cvmx_helper_ports_on_interface(int interface);
194 * Return the number of interfaces the chip has. Each interface
195 * may have multiple ports. Most chips support two interfaces,
196 * but the CNX0XX and CNX1XX are exceptions. These only support
199 * @return Number of interfaces on chip
201 extern int cvmx_helper_get_number_of_interfaces(void);
204 * Get the operating mode of an interface. Depending on the Octeon
205 * chip and configuration, this function returns an enumeration
206 * of the type of packet I/O supported by an interface.
208 * @param interface Interface to probe
210 * @return Mode of the interface. Unknown or unsupported interfaces return
213 extern cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int interface);
216 * Auto configure an IPD/PKO port link state and speed. This
217 * function basically does the equivalent of:
218 * cvmx_helper_link_set(ipd_port, cvmx_helper_link_get(ipd_port));
220 * @param ipd_port IPD/PKO port to auto configure
222 * @return Link state after configure
224 extern cvmx_helper_link_info_t cvmx_helper_link_autoconf(int ipd_port);
227 * Return the link state of an IPD/PKO port as returned by
228 * auto negotiation. The result of this function may not match
229 * Octeon's link config if auto negotiation has changed since
230 * the last call to cvmx_helper_link_set().
232 * @param ipd_port IPD/PKO port to query
236 extern cvmx_helper_link_info_t cvmx_helper_link_get(int ipd_port);
239 * Configure an IPD/PKO port for the specified link state. This
240 * function does not influence auto negotiation at the PHY level.
241 * The passed link state must always match the link state returned
242 * by cvmx_helper_link_get(). It is normally best to use
243 * cvmx_helper_link_autoconf() instead.
245 * @param ipd_port IPD/PKO port to configure
246 * @param link_info The new link state
248 * @return Zero on success, negative on failure
250 extern int cvmx_helper_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
255 * This function probes an interface to determine the actual
256 * number of hardware ports connected to it. It doesn't setup the
257 * ports or enable them. The main goal here is to set the global
258 * interface_port_count[interface] correctly. Hardware setup of the
259 * ports will be performed later.
261 * @param interface Interface to probe
263 * @return Zero on success, negative on failure
265 extern int cvmx_helper_interface_probe(int interface);
268 * Configure a port for internal and/or external loopback. Internal loopback
269 * causes packets sent by the port to be received by Octeon. External loopback
270 * causes packets received from the wire to sent out again.
272 * @param ipd_port IPD/PKO port to loopback.
273 * @param enable_internal
274 * Non zero if you want internal loopback
275 * @param enable_external
276 * Non zero if you want external loopback
278 * @return Zero on success, negative on failure.
280 extern int cvmx_helper_configure_loopback(int ipd_port, int enable_internal, int enable_external);
282 #include "cvmx-helper-util.h"
284 #endif /* CVMX_ENABLE_PKO_FUNCTIONS */
290 #endif /* __CVMX_HELPER_H__ */