Back to home page

OSCL-LXR

 
 

    


0001 /***********************license start***************
0002  * Author: Cavium Networks
0003  *
0004  * Contact: support@caviumnetworks.com
0005  * This file is part of the OCTEON SDK
0006  *
0007  * Copyright (c) 2003-2008 Cavium Networks
0008  *
0009  * This file is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License, Version 2, as
0011  * published by the Free Software Foundation.
0012  *
0013  * This file is distributed in the hope that it will be useful, but
0014  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
0015  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
0016  * NONINFRINGEMENT.  See the GNU General Public License for more
0017  * details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this file; if not, write to the Free Software
0021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0022  * or visit http://www.gnu.org/licenses/.
0023  *
0024  * This file may also be available under a different license from Cavium.
0025  * Contact Cavium Networks for more information
0026  ***********************license end**************************************/
0027 
0028 /*
0029  * Functions for LOOP initialization, configuration,
0030  * and monitoring.
0031  */
0032 #include <asm/octeon/octeon.h>
0033 
0034 #include <asm/octeon/cvmx-config.h>
0035 
0036 #include <asm/octeon/cvmx-helper.h>
0037 #include <asm/octeon/cvmx-pip-defs.h>
0038 
0039 /**
0040  * Probe a LOOP interface and determine the number of ports
0041  * connected to it. The LOOP interface should still be down
0042  * after this call.
0043  *
0044  * @interface: Interface to probe
0045  *
0046  * Returns Number of ports on the interface. Zero to disable.
0047  */
0048 int __cvmx_helper_loop_probe(int interface)
0049 {
0050     union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs;
0051     int num_ports = 4;
0052     int port;
0053 
0054     /* We need to disable length checking so packet < 64 bytes and jumbo
0055        frames don't get errors */
0056     for (port = 0; port < num_ports; port++) {
0057         union cvmx_pip_prt_cfgx port_cfg;
0058         int ipd_port = cvmx_helper_get_ipd_port(interface, port);
0059         port_cfg.u64 = cvmx_read_csr(CVMX_PIP_PRT_CFGX(ipd_port));
0060         port_cfg.s.maxerr_en = 0;
0061         port_cfg.s.minerr_en = 0;
0062         cvmx_write_csr(CVMX_PIP_PRT_CFGX(ipd_port), port_cfg.u64);
0063     }
0064 
0065     /* Disable FCS stripping for loopback ports */
0066     ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS);
0067     ipd_sub_port_fcs.s.port_bit2 = 0;
0068     cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64);
0069     return num_ports;
0070 }
0071 
0072 /**
0073  * Bringup and enable a LOOP interface. After this call packet
0074  * I/O should be fully functional. This is called with IPD
0075  * enabled but PKO disabled.
0076  *
0077  * @interface: Interface to bring up
0078  *
0079  * Returns Zero on success, negative on failure
0080  */
0081 int __cvmx_helper_loop_enable(int interface)
0082 {
0083     /* Do nothing. */
0084     return 0;
0085 }