1 /***********************license start***************
2 * Copyright (c) 2003-2008 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 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * Helper functions for common, but complicated tasks.
49 * <hr>$Revision: 41586 $<hr>
52 #ifndef __CVMX_HELPER_H__
53 #define __CVMX_HELPER_H__
55 #ifndef CVMX_DONT_INCLUDE_CONFIG
56 #include "executive-config.h"
57 #include "cvmx-config.h"
68 CVMX_HELPER_INTERFACE_MODE_DISABLED,
69 CVMX_HELPER_INTERFACE_MODE_RGMII,
70 CVMX_HELPER_INTERFACE_MODE_GMII,
71 CVMX_HELPER_INTERFACE_MODE_SPI,
72 CVMX_HELPER_INTERFACE_MODE_PCIE,
73 CVMX_HELPER_INTERFACE_MODE_XAUI,
74 CVMX_HELPER_INTERFACE_MODE_SGMII,
75 CVMX_HELPER_INTERFACE_MODE_PICMG,
76 CVMX_HELPER_INTERFACE_MODE_NPI,
77 CVMX_HELPER_INTERFACE_MODE_LOOP,
78 } cvmx_helper_interface_mode_t;
85 uint64_t reserved_20_63 : 44;
86 uint64_t link_up : 1; /**< Is the physical link up? */
87 uint64_t full_duplex : 1; /**< 1 if the link is full duplex */
88 uint64_t speed : 18; /**< Speed of the link in Mbps */
90 } cvmx_helper_link_info_t;
92 #include "cvmx-helper-fpa.h"
94 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
96 #include "cvmx-helper-errata.h"
97 #include "cvmx-helper-loop.h"
98 #include "cvmx-helper-npi.h"
99 #include "cvmx-helper-rgmii.h"
100 #include "cvmx-helper-sgmii.h"
101 #include "cvmx-helper-spi.h"
102 #include "cvmx-helper-xaui.h"
105 * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
106 * priorities[16]) is a function pointer. It is meant to allow
107 * customization of the PKO queue priorities based on the port
108 * number. Users should set this pointer to a function before
109 * calling any cvmx-helper operations.
111 extern void (*cvmx_override_pko_queue_priority)(int pko_port, uint64_t priorities[16]);
114 * cvmx_override_ipd_port_setup(int ipd_port) is a function
115 * pointer. It is meant to allow customization of the IPD port
116 * setup before packet input/output comes online. It is called
117 * after cvmx-helper does the default IPD configuration, but
118 * before IPD is enabled. Users should set this pointer to a
119 * function before calling any cvmx-helper operations.
121 extern void (*cvmx_override_ipd_port_setup)(int ipd_port);
124 * This function enables the IPD and also enables the packet interfaces.
125 * The packet interfaces (RGMII and SPI) must be enabled after the
126 * IPD. This should be called by the user program after any additional
127 * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD
128 * is not set in the executive-config.h file.
130 * @return 0 on success
133 extern int cvmx_helper_ipd_and_packet_input_enable(void);
136 * Initialize the PIP, IPD, and PKO hardware to support
137 * simple priority based queues for the ethernet ports. Each
138 * port is configured with a number of priority queues based
139 * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower
140 * priority than the previous.
142 * @return Zero on success, non-zero on failure
144 extern int cvmx_helper_initialize_packet_io_global(void);
147 * Does core local initialization for packet io
149 * @return Zero on success, non-zero on failure
151 extern int cvmx_helper_initialize_packet_io_local(void);
154 * Returns the number of ports on the given interface.
155 * The interface must be initialized before the port count
158 * @param interface Which interface to return port count for.
160 * @return Port count for interface
161 * -1 for uninitialized interface
163 extern int cvmx_helper_ports_on_interface(int interface);
166 * Return the number of interfaces the chip has. Each interface
167 * may have multiple ports. Most chips support two interfaces,
168 * but the CNX0XX and CNX1XX are exceptions. These only support
171 * @return Number of interfaces on chip
173 extern int cvmx_helper_get_number_of_interfaces(void);
176 * Get the operating mode of an interface. Depending on the Octeon
177 * chip and configuration, this function returns an enumeration
178 * of the type of packet I/O supported by an interface.
180 * @param interface Interface to probe
182 * @return Mode of the interface. Unknown or unsupported interfaces return
185 extern cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int interface);
188 * Auto configure an IPD/PKO port link state and speed. This
189 * function basically does the equivalent of:
190 * cvmx_helper_link_set(ipd_port, cvmx_helper_link_get(ipd_port));
192 * @param ipd_port IPD/PKO port to auto configure
194 * @return Link state after configure
196 extern cvmx_helper_link_info_t cvmx_helper_link_autoconf(int ipd_port);
199 * Return the link state of an IPD/PKO port as returned by
200 * auto negotiation. The result of this function may not match
201 * Octeon's link config if auto negotiation has changed since
202 * the last call to cvmx_helper_link_set().
204 * @param ipd_port IPD/PKO port to query
208 extern cvmx_helper_link_info_t cvmx_helper_link_get(int ipd_port);
211 * Configure an IPD/PKO port for the specified link state. This
212 * function does not influence auto negotiation at the PHY level.
213 * The passed link state must always match the link state returned
214 * by cvmx_helper_link_get(). It is normally best to use
215 * cvmx_helper_link_autoconf() instead.
217 * @param ipd_port IPD/PKO port to configure
218 * @param link_info The new link state
220 * @return Zero on success, negative on failure
222 extern int cvmx_helper_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
227 * This function probes an interface to determine the actual
228 * number of hardware ports connected to it. It doesn't setup the
229 * ports or enable them. The main goal here is to set the global
230 * interface_port_count[interface] correctly. Hardware setup of the
231 * ports will be performed later.
233 * @param interface Interface to probe
235 * @return Zero on success, negative on failure
237 extern int cvmx_helper_interface_probe(int interface);
240 * Configure a port for internal and/or external loopback. Internal loopback
241 * causes packets sent by the port to be received by Octeon. External loopback
242 * causes packets received from the wire to sent out again.
244 * @param ipd_port IPD/PKO port to loopback.
245 * @param enable_internal
246 * Non zero if you want internal loopback
247 * @param enable_external
248 * Non zero if you want external loopback
250 * @return Zero on success, negative on failure.
252 extern int cvmx_helper_configure_loopback(int ipd_port, int enable_internal, int enable_external);
254 #include "cvmx-helper-util.h"
256 #endif /* CVMX_ENABLE_PKO_FUNCTIONS */
262 #endif /* __CVMX_HELPER_H__ */