162306a36Sopenharmony_ci/***********************license start*************** 262306a36Sopenharmony_ci * Author: Cavium Networks 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Contact: support@caviumnetworks.com 562306a36Sopenharmony_ci * This file is part of the OCTEON SDK 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2003-2008 Cavium Networks 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify 1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as 1162306a36Sopenharmony_ci * published by the Free Software Foundation. 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 1662306a36Sopenharmony_ci * NONINFRINGEMENT. See the GNU General Public License for more 1762306a36Sopenharmony_ci * details. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 2062306a36Sopenharmony_ci * along with this file; if not, write to the Free Software 2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 2262306a36Sopenharmony_ci * or visit http://www.gnu.org/licenses/. 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci * This file may also be available under a different license from Cavium. 2562306a36Sopenharmony_ci * Contact Cavium Networks for more information 2662306a36Sopenharmony_ci ***********************license end**************************************/ 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/* 2962306a36Sopenharmony_ci * Functions for LOOP initialization, configuration, 3062306a36Sopenharmony_ci * and monitoring. 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci#include <asm/octeon/octeon.h> 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#include <asm/octeon/cvmx-config.h> 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#include <asm/octeon/cvmx-helper.h> 3762306a36Sopenharmony_ci#include <asm/octeon/cvmx-pip-defs.h> 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/** 4062306a36Sopenharmony_ci * Probe a LOOP interface and determine the number of ports 4162306a36Sopenharmony_ci * connected to it. The LOOP interface should still be down 4262306a36Sopenharmony_ci * after this call. 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * @interface: Interface to probe 4562306a36Sopenharmony_ci * 4662306a36Sopenharmony_ci * Returns Number of ports on the interface. Zero to disable. 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ciint __cvmx_helper_loop_probe(int interface) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; 5162306a36Sopenharmony_ci int num_ports = 4; 5262306a36Sopenharmony_ci int port; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci /* We need to disable length checking so packet < 64 bytes and jumbo 5562306a36Sopenharmony_ci frames don't get errors */ 5662306a36Sopenharmony_ci for (port = 0; port < num_ports; port++) { 5762306a36Sopenharmony_ci union cvmx_pip_prt_cfgx port_cfg; 5862306a36Sopenharmony_ci int ipd_port = cvmx_helper_get_ipd_port(interface, port); 5962306a36Sopenharmony_ci port_cfg.u64 = cvmx_read_csr(CVMX_PIP_PRT_CFGX(ipd_port)); 6062306a36Sopenharmony_ci port_cfg.s.maxerr_en = 0; 6162306a36Sopenharmony_ci port_cfg.s.minerr_en = 0; 6262306a36Sopenharmony_ci cvmx_write_csr(CVMX_PIP_PRT_CFGX(ipd_port), port_cfg.u64); 6362306a36Sopenharmony_ci } 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci /* Disable FCS stripping for loopback ports */ 6662306a36Sopenharmony_ci ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); 6762306a36Sopenharmony_ci ipd_sub_port_fcs.s.port_bit2 = 0; 6862306a36Sopenharmony_ci cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); 6962306a36Sopenharmony_ci return num_ports; 7062306a36Sopenharmony_ci} 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/** 7362306a36Sopenharmony_ci * Bringup and enable a LOOP interface. After this call packet 7462306a36Sopenharmony_ci * I/O should be fully functional. This is called with IPD 7562306a36Sopenharmony_ci * enabled but PKO disabled. 7662306a36Sopenharmony_ci * 7762306a36Sopenharmony_ci * @interface: Interface to bring up 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci * Returns Zero on success, negative on failure 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_ciint __cvmx_helper_loop_enable(int interface) 8262306a36Sopenharmony_ci{ 8362306a36Sopenharmony_ci /* Do nothing. */ 8462306a36Sopenharmony_ci return 0; 8562306a36Sopenharmony_ci} 86