STAGING: Octeon: Use common helpers for determining interface and port

Currently the Octeon Ethernet driver hardcodes the mapping between
interface/port and IPD port number. Since we have generic helpers for
the very same purpose, we might as well use them instead. This prevents
having the same information in multiple places.

Signed-off-by: Janne Huttunen <janne.huttunen@nokia.com>
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Acked-by: David Daney <david.daney@cavium.com>
Cc: David Daney <ddaney.cavm@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Janne Huttunen <janne.huttunen@nokia.com>
Cc: Aaro Koskinen <aaro.koskinen@nokia.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org
Patchwork: https://patchwork.linux-mips.org/patch/10975/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Janne Huttunen 2015-08-13 16:21:46 +03:00 committed by Ralf Baechle
parent 31705376a2
commit 1d39a5e4ce

View file

@ -8,6 +8,10 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <asm/octeon/cvmx-pip.h>
#include <asm/octeon/cvmx-helper.h>
#include <asm/octeon/cvmx-helper-util.h>
/** /**
* cvm_oct_get_buffer_ptr - convert packet data address to pointer * cvm_oct_get_buffer_ptr - convert packet data address to pointer
* @packet_ptr: Packet data hardware address * @packet_ptr: Packet data hardware address
@ -28,14 +32,12 @@ static inline void *cvm_oct_get_buffer_ptr(union cvmx_buf_ptr packet_ptr)
*/ */
static inline int INTERFACE(int ipd_port) static inline int INTERFACE(int ipd_port)
{ {
if (ipd_port < 32) /* Interface 0 or 1 for RGMII,GMII,SPI, etc */ int interface = cvmx_helper_get_interface_num(ipd_port);
return ipd_port >> 4;
else if (ipd_port < 36) /* Interface 2 for NPI */ if (interface >= 0)
return 2; return interface;
else if (ipd_port < 40) /* Interface 3 for loopback */ else if (ipd_port == CVMX_PIP_NUM_INPUT_PORTS)
return 3; return 10;
else if (ipd_port == 40) /* Non existent interface for POW0 */
return 4;
panic("Illegal ipd_port %d passed to INTERFACE\n", ipd_port); panic("Illegal ipd_port %d passed to INTERFACE\n", ipd_port);
} }
@ -47,7 +49,5 @@ static inline int INTERFACE(int ipd_port)
*/ */
static inline int INDEX(int ipd_port) static inline int INDEX(int ipd_port)
{ {
if (ipd_port < 32) return cvmx_helper_get_interface_index_num(ipd_port);
return ipd_port & 15;
return ipd_port & 3;
} }