linux/arch/mips/include/asm/octeon/cvmx-helper.h
<<
>>
Prefs
   1/***********************license start***************
   2 * Author: Cavium Networks
   3 *
   4 * Contact: support@caviumnetworks.com
   5 * This file is part of the OCTEON SDK
   6 *
   7 * Copyright (c) 2003-2008 Cavium Networks
   8 *
   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.
  12 *
  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
  17 * details.
  18 *
  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/.
  23 *
  24 * This file may also be available under a different license from Cavium.
  25 * Contact Cavium Networks for more information
  26 ***********************license end**************************************/
  27
  28/*
  29 *
  30 * Helper functions for common, but complicated tasks.
  31 *
  32 */
  33
  34#ifndef __CVMX_HELPER_H__
  35#define __CVMX_HELPER_H__
  36
  37#include <asm/octeon/cvmx-config.h>
  38#include <asm/octeon/cvmx-fpa.h>
  39#include <asm/octeon/cvmx-wqe.h>
  40
  41typedef enum {
  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;
  53
  54typedef union {
  55        uint64_t u64;
  56        struct {
  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 */
  61        } s;
  62} cvmx_helper_link_info_t;
  63
  64#include <asm/octeon/cvmx-helper-errata.h>
  65#include <asm/octeon/cvmx-helper-loop.h>
  66#include <asm/octeon/cvmx-helper-npi.h>
  67#include <asm/octeon/cvmx-helper-rgmii.h>
  68#include <asm/octeon/cvmx-helper-sgmii.h>
  69#include <asm/octeon/cvmx-helper-spi.h>
  70#include <asm/octeon/cvmx-helper-util.h>
  71#include <asm/octeon/cvmx-helper-xaui.h>
  72
  73/**
  74 * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
  75 * priorities[16]) is a function pointer. It is meant to allow
  76 * customization of the PKO queue priorities based on the port
  77 * number. Users should set this pointer to a function before
  78 * calling any cvmx-helper operations.
  79 */
  80extern void (*cvmx_override_pko_queue_priority) (int pko_port,
  81                                                 uint64_t priorities[16]);
  82
  83/**
  84 * cvmx_override_ipd_port_setup(int ipd_port) is a function
  85 * pointer. It is meant to allow customization of the IPD port
  86 * setup before packet input/output comes online. It is called
  87 * after cvmx-helper does the default IPD configuration, but
  88 * before IPD is enabled. Users should set this pointer to a
  89 * function before calling any cvmx-helper operations.
  90 */
  91extern void (*cvmx_override_ipd_port_setup) (int ipd_port);
  92
  93/**
  94 * This function enables the IPD and also enables the packet interfaces.
  95 * The packet interfaces (RGMII and SPI) must be enabled after the
  96 * IPD.  This should be called by the user program after any additional
  97 * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD
  98 * is not set in the executive-config.h file.
  99 *
 100 * Returns 0 on success
 101 *         -1 on failure
 102 */
 103extern int cvmx_helper_ipd_and_packet_input_enable(void);
 104
 105/**
 106 * Initialize the PIP, IPD, and PKO hardware to support
 107 * simple priority based queues for the ethernet ports. Each
 108 * port is configured with a number of priority queues based
 109 * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower
 110 * priority than the previous.
 111 *
 112 * Returns Zero on success, non-zero on failure
 113 */
 114extern int cvmx_helper_initialize_packet_io_global(void);
 115
 116/**
 117 * Does core local initialization for packet io
 118 *
 119 * Returns Zero on success, non-zero on failure
 120 */
 121extern int cvmx_helper_initialize_packet_io_local(void);
 122
 123/**
 124 * Returns the number of ports on the given interface.
 125 * The interface must be initialized before the port count
 126 * can be returned.
 127 *
 128 * @interface: Which interface to return port count for.
 129 *
 130 * Returns Port count for interface
 131 *         -1 for uninitialized interface
 132 */
 133extern int cvmx_helper_ports_on_interface(int interface);
 134
 135/**
 136 * Return the number of interfaces the chip has. Each interface
 137 * may have multiple ports. Most chips support two interfaces,
 138 * but the CNX0XX and CNX1XX are exceptions. These only support
 139 * one interface.
 140 *
 141 * Returns Number of interfaces on chip
 142 */
 143extern int cvmx_helper_get_number_of_interfaces(void);
 144
 145/**
 146 * Get the operating mode of an interface. Depending on the Octeon
 147 * chip and configuration, this function returns an enumeration
 148 * of the type of packet I/O supported by an interface.
 149 *
 150 * @interface: Interface to probe
 151 *
 152 * Returns Mode of the interface. Unknown or unsupported interfaces return
 153 *         DISABLED.
 154 */
 155extern cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int
 156                                                                   interface);
 157
 158/**
 159 * Return the link state of an IPD/PKO port as returned by
 160 * auto negotiation. The result of this function may not match
 161 * Octeon's link config if auto negotiation has changed since
 162 * the last call to cvmx_helper_link_set().
 163 *
 164 * @ipd_port: IPD/PKO port to query
 165 *
 166 * Returns Link state
 167 */
 168extern cvmx_helper_link_info_t cvmx_helper_link_get(int ipd_port);
 169
 170/**
 171 * Configure an IPD/PKO port for the specified link state. This
 172 * function does not influence auto negotiation at the PHY level.
 173 * The passed link state must always match the link state returned
 174 * by cvmx_helper_link_get().
 175 *
 176 * @ipd_port:  IPD/PKO port to configure
 177 * @link_info: The new link state
 178 *
 179 * Returns Zero on success, negative on failure
 180 */
 181extern int cvmx_helper_link_set(int ipd_port,
 182                                cvmx_helper_link_info_t link_info);
 183
 184/**
 185 * This function probes an interface to determine the actual
 186 * number of hardware ports connected to it. It doesn't setup the
 187 * ports or enable them. The main goal here is to set the global
 188 * interface_port_count[interface] correctly. Hardware setup of the
 189 * ports will be performed later.
 190 *
 191 * @interface: Interface to probe
 192 *
 193 * Returns Zero on success, negative on failure
 194 */
 195extern int cvmx_helper_interface_probe(int interface);
 196extern int cvmx_helper_interface_enumerate(int interface);
 197
 198/**
 199 * Configure a port for internal and/or external loopback. Internal loopback
 200 * causes packets sent by the port to be received by Octeon. External loopback
 201 * causes packets received from the wire to sent out again.
 202 *
 203 * @ipd_port: IPD/PKO port to loopback.
 204 * @enable_internal:
 205 *                 Non zero if you want internal loopback
 206 * @enable_external:
 207 *                 Non zero if you want external loopback
 208 *
 209 * Returns Zero on success, negative on failure.
 210 */
 211extern int cvmx_helper_configure_loopback(int ipd_port, int enable_internal,
 212                                          int enable_external);
 213
 214#endif /* __CVMX_HELPER_H__ */
 215