1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * This file is based on code from OCTEON SDK by Cavium Networks. 4 * 5 * Copyright (c) 2003-2007 Cavium Networks 6 */ 7 8 #include <asm/octeon/cvmx-pip.h> 9 #include <asm/octeon/cvmx-helper.h> 10 #include <asm/octeon/cvmx-helper-util.h> 11 12 /** 13 * cvm_oct_get_buffer_ptr - convert packet data address to pointer 14 * @packet_ptr: Packet data hardware address 15 * 16 * Returns Packet buffer pointer 17 */ 18 static inline void *cvm_oct_get_buffer_ptr(union cvmx_buf_ptr packet_ptr) 19 { 20 return cvmx_phys_to_ptr(((packet_ptr.s.addr >> 7) - packet_ptr.s.back) 21 << 7); 22 } 23 24 /** 25 * INTERFACE - convert IPD port to logical interface 26 * @ipd_port: Port to check 27 * 28 * Returns Logical interface 29 */ 30 static inline int INTERFACE(int ipd_port) 31 { 32 int interface; 33 34 if (ipd_port == CVMX_PIP_NUM_INPUT_PORTS) 35 return 10; 36 interface = cvmx_helper_get_interface_num(ipd_port); 37 if (interface >= 0) 38 return interface; 39 panic("Illegal ipd_port %d passed to %s\n", ipd_port, __func__); 40 } 41 42 /** 43 * INDEX - convert IPD/PKO port number to the port's interface index 44 * @ipd_port: Port to check 45 * 46 * Returns Index into interface port list 47 */ 48 static inline int INDEX(int ipd_port) 49 { 50 return cvmx_helper_get_interface_index_num(ipd_port); 51 } 52