2015-04-04 13:51:21 -06:00
|
|
|
/*
|
|
|
|
* This file is based on code from OCTEON SDK by Cavium Networks.
|
2009-05-05 18:35:21 -06:00
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2007 Cavium Networks
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License, Version 2, as
|
|
|
|
* published by the Free Software Foundation.
|
2015-04-04 13:51:21 -06:00
|
|
|
*/
|
2009-05-05 18:35:21 -06:00
|
|
|
|
2015-08-13 07:21:46 -06:00
|
|
|
#include <asm/octeon/cvmx-pip.h>
|
|
|
|
#include <asm/octeon/cvmx-helper.h>
|
|
|
|
#include <asm/octeon/cvmx-helper-util.h>
|
|
|
|
|
2009-05-05 18:35:21 -06:00
|
|
|
/**
|
2010-02-16 18:25:32 -07:00
|
|
|
* cvm_oct_get_buffer_ptr - convert packet data address to pointer
|
2009-05-05 18:35:21 -06:00
|
|
|
* @packet_ptr: Packet data hardware address
|
2010-02-16 18:25:32 -07:00
|
|
|
*
|
2009-05-05 18:35:21 -06:00
|
|
|
* Returns Packet buffer pointer
|
|
|
|
*/
|
|
|
|
static inline void *cvm_oct_get_buffer_ptr(union cvmx_buf_ptr packet_ptr)
|
|
|
|
{
|
|
|
|
return cvmx_phys_to_ptr(((packet_ptr.s.addr >> 7) - packet_ptr.s.back)
|
|
|
|
<< 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-26 22:34:18 -06:00
|
|
|
* INTERFACE - convert IPD port to logical interface
|
2009-05-05 18:35:21 -06:00
|
|
|
* @ipd_port: Port to check
|
|
|
|
*
|
|
|
|
* Returns Logical interface
|
|
|
|
*/
|
|
|
|
static inline int INTERFACE(int ipd_port)
|
|
|
|
{
|
2015-08-13 07:21:46 -06:00
|
|
|
int interface = cvmx_helper_get_interface_num(ipd_port);
|
|
|
|
|
|
|
|
if (interface >= 0)
|
|
|
|
return interface;
|
|
|
|
else if (ipd_port == CVMX_PIP_NUM_INPUT_PORTS)
|
|
|
|
return 10;
|
2014-09-27 05:58:31 -06:00
|
|
|
panic("Illegal ipd_port %d passed to INTERFACE\n", ipd_port);
|
2009-05-05 18:35:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-16 18:25:32 -07:00
|
|
|
* INDEX - convert IPD/PKO port number to the port's interface index
|
2009-05-05 18:35:21 -06:00
|
|
|
* @ipd_port: Port to check
|
|
|
|
*
|
|
|
|
* Returns Index into interface port list
|
|
|
|
*/
|
|
|
|
static inline int INDEX(int ipd_port)
|
|
|
|
{
|
2015-08-13 07:21:46 -06:00
|
|
|
return cvmx_helper_get_interface_index_num(ipd_port);
|
2009-05-05 18:35:21 -06:00
|
|
|
}
|