Path: blob/master/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
26481 views
/***********************license start***************1* Author: Cavium Networks2*3* Contact: [email protected]4* This file is part of the OCTEON SDK5*6* Copyright (c) 2003-2008 Cavium Networks7*8* This file is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License, Version 2, as10* published by the Free Software Foundation.11*12* This file is distributed in the hope that it will be useful, but13* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty14* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or15* NONINFRINGEMENT. See the GNU General Public License for more16* details.17*18* You should have received a copy of the GNU General Public License19* along with this file; if not, write to the Free Software20* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA21* or visit http://www.gnu.org/licenses/.22*23* This file may also be available under a different license from Cavium.24* Contact Cavium Networks for more information25***********************license end**************************************/2627/*28* Functions for NPI initialization, configuration,29* and monitoring.30*/31#include <asm/octeon/octeon.h>3233#include <asm/octeon/cvmx-config.h>3435#include <asm/octeon/cvmx-helper.h>3637#include <asm/octeon/cvmx-pip-defs.h>3839/**40* Probe a NPI interface and determine the number of ports41* connected to it. The NPI interface should still be down42* after this call.43*44* @interface: Interface to probe45*46* Returns Number of ports on the interface. Zero to disable.47*/48int __cvmx_helper_npi_probe(int interface)49{50#if CVMX_PKO_QUEUES_PER_PORT_PCI > 051if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))52return 4;53else if (OCTEON_IS_MODEL(OCTEON_CN56XX)54&& !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X))55/* The packet engines didn't exist before pass 2 */56return 4;57else if (OCTEON_IS_MODEL(OCTEON_CN52XX)58&& !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X))59/* The packet engines didn't exist before pass 2 */60return 4;61#endif62return 0;63}6465/**66* Bringup and enable a NPI interface. After this call packet67* I/O should be fully functional. This is called with IPD68* enabled but PKO disabled.69*70* @interface: Interface to bring up71*72* Returns Zero on success, negative on failure73*/74int __cvmx_helper_npi_enable(int interface)75{76/*77* On CN50XX, CN52XX, and CN56XX we need to disable length78* checking so packet < 64 bytes and jumbo frames don't get79* errors.80*/81if (!OCTEON_IS_MODEL(OCTEON_CN3XXX) &&82!OCTEON_IS_MODEL(OCTEON_CN58XX)) {83int num_ports = cvmx_helper_ports_on_interface(interface);84int port;85for (port = 0; port < num_ports; port++) {86union cvmx_pip_prt_cfgx port_cfg;87int ipd_port =88cvmx_helper_get_ipd_port(interface, port);89port_cfg.u64 =90cvmx_read_csr(CVMX_PIP_PRT_CFGX(ipd_port));91port_cfg.s.maxerr_en = 0;92port_cfg.s.minerr_en = 0;93cvmx_write_csr(CVMX_PIP_PRT_CFGX(ipd_port),94port_cfg.u64);95}96}9798/* Enables are controlled by the remote host, so nothing to do here */99return 0;100}101102103