1 /***********************license start***************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2008 Cavium Networks
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
30 * Helper functions for common, but complicated tasks.
34 #ifndef __CVMX_HELPER_H__
35 #define __CVMX_HELPER_H__
37 #include "cvmx-config.h"
42 CVMX_HELPER_INTERFACE_MODE_DISABLED
,
43 CVMX_HELPER_INTERFACE_MODE_RGMII
,
44 CVMX_HELPER_INTERFACE_MODE_GMII
,
45 CVMX_HELPER_INTERFACE_MODE_SPI
,
46 CVMX_HELPER_INTERFACE_MODE_PCIE
,
47 CVMX_HELPER_INTERFACE_MODE_XAUI
,
48 CVMX_HELPER_INTERFACE_MODE_SGMII
,
49 CVMX_HELPER_INTERFACE_MODE_PICMG
,
50 CVMX_HELPER_INTERFACE_MODE_NPI
,
51 CVMX_HELPER_INTERFACE_MODE_LOOP
,
52 } cvmx_helper_interface_mode_t
;
57 uint64_t reserved_20_63
:44;
58 uint64_t link_up
:1; /**< Is the physical link up? */
59 uint64_t full_duplex
:1; /**< 1 if the link is full duplex */
60 uint64_t speed
:18; /**< Speed of the link in Mbps */
62 } cvmx_helper_link_info_t
;
64 #include "cvmx-helper-fpa.h"
66 #include <asm/octeon/cvmx-helper-errata.h>
67 #include "cvmx-helper-loop.h"
68 #include "cvmx-helper-npi.h"
69 #include "cvmx-helper-rgmii.h"
70 #include "cvmx-helper-sgmii.h"
71 #include "cvmx-helper-spi.h"
72 #include "cvmx-helper-util.h"
73 #include "cvmx-helper-xaui.h"
76 * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
77 * priorities[16]) is a function pointer. It is meant to allow
78 * customization of the PKO queue priorities based on the port
79 * number. Users should set this pointer to a function before
80 * calling any cvmx-helper operations.
82 extern void (*cvmx_override_pko_queue_priority
) (int pko_port
,
83 uint64_t priorities
[16]);
86 * cvmx_override_ipd_port_setup(int ipd_port) is a function
87 * pointer. It is meant to allow customization of the IPD port
88 * setup before packet input/output comes online. It is called
89 * after cvmx-helper does the default IPD configuration, but
90 * before IPD is enabled. Users should set this pointer to a
91 * function before calling any cvmx-helper operations.
93 extern void (*cvmx_override_ipd_port_setup
) (int ipd_port
);
96 * This function enables the IPD and also enables the packet interfaces.
97 * The packet interfaces (RGMII and SPI) must be enabled after the
98 * IPD. This should be called by the user program after any additional
99 * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD
100 * is not set in the executive-config.h file.
102 * Returns 0 on success
105 extern int cvmx_helper_ipd_and_packet_input_enable(void);
108 * Initialize the PIP, IPD, and PKO hardware to support
109 * simple priority based queues for the ethernet ports. Each
110 * port is configured with a number of priority queues based
111 * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower
112 * priority than the previous.
114 * Returns Zero on success, non-zero on failure
116 extern int cvmx_helper_initialize_packet_io_global(void);
119 * Does core local initialization for packet io
121 * Returns Zero on success, non-zero on failure
123 extern int cvmx_helper_initialize_packet_io_local(void);
126 * Returns the number of ports on the given interface.
127 * The interface must be initialized before the port count
130 * @interface: Which interface to return port count for.
132 * Returns Port count for interface
133 * -1 for uninitialized interface
135 extern int cvmx_helper_ports_on_interface(int interface
);
138 * Return the number of interfaces the chip has. Each interface
139 * may have multiple ports. Most chips support two interfaces,
140 * but the CNX0XX and CNX1XX are exceptions. These only support
143 * Returns Number of interfaces on chip
145 extern int cvmx_helper_get_number_of_interfaces(void);
148 * Get the operating mode of an interface. Depending on the Octeon
149 * chip and configuration, this function returns an enumeration
150 * of the type of packet I/O supported by an interface.
152 * @interface: Interface to probe
154 * Returns Mode of the interface. Unknown or unsupported interfaces return
157 extern cvmx_helper_interface_mode_t
cvmx_helper_interface_get_mode(int
161 * Auto configure an IPD/PKO port link state and speed. This
162 * function basically does the equivalent of:
163 * cvmx_helper_link_set(ipd_port, cvmx_helper_link_get(ipd_port));
165 * @ipd_port: IPD/PKO port to auto configure
167 * Returns Link state after configure
169 extern cvmx_helper_link_info_t
cvmx_helper_link_autoconf(int ipd_port
);
172 * Return the link state of an IPD/PKO port as returned by
173 * auto negotiation. The result of this function may not match
174 * Octeon's link config if auto negotiation has changed since
175 * the last call to cvmx_helper_link_set().
177 * @ipd_port: IPD/PKO port to query
181 extern cvmx_helper_link_info_t
cvmx_helper_link_get(int ipd_port
);
184 * Configure an IPD/PKO port for the specified link state. This
185 * function does not influence auto negotiation at the PHY level.
186 * The passed link state must always match the link state returned
187 * by cvmx_helper_link_get(). It is normally best to use
188 * cvmx_helper_link_autoconf() instead.
190 * @ipd_port: IPD/PKO port to configure
191 * @link_info: The new link state
193 * Returns Zero on success, negative on failure
195 extern int cvmx_helper_link_set(int ipd_port
,
196 cvmx_helper_link_info_t link_info
);
199 * This function probes an interface to determine the actual
200 * number of hardware ports connected to it. It doesn't setup the
201 * ports or enable them. The main goal here is to set the global
202 * interface_port_count[interface] correctly. Hardware setup of the
203 * ports will be performed later.
205 * @interface: Interface to probe
207 * Returns Zero on success, negative on failure
209 extern int cvmx_helper_interface_probe(int interface
);
212 * Configure a port for internal and/or external loopback. Internal loopback
213 * causes packets sent by the port to be received by Octeon. External loopback
214 * causes packets received from the wire to sent out again.
216 * @ipd_port: IPD/PKO port to loopback.
218 * Non zero if you want internal loopback
220 * Non zero if you want external loopback
222 * Returns Zero on success, negative on failure.
224 extern int cvmx_helper_configure_loopback(int ipd_port
, int enable_internal
,
225 int enable_external
);
227 #endif /* __CVMX_HELPER_H__ */