![]() |
|
|||
0001 /***********************license start*************** 0002 * Author: Cavium Networks 0003 * 0004 * Contact: support@caviumnetworks.com 0005 * This file is part of the OCTEON SDK 0006 * 0007 * Copyright (c) 2003-2008 Cavium Networks 0008 * 0009 * This file is free software; you can redistribute it and/or modify 0010 * it under the terms of the GNU General Public License, Version 2, as 0011 * published by the Free Software Foundation. 0012 * 0013 * This file is distributed in the hope that it will be useful, but 0014 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 0015 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 0016 * NONINFRINGEMENT. See the GNU General Public License for more 0017 * details. 0018 * 0019 * You should have received a copy of the GNU General Public License 0020 * along with this file; if not, write to the Free Software 0021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0022 * or visit http://www.gnu.org/licenses/. 0023 * 0024 * This file may also be available under a different license from Cavium. 0025 * Contact Cavium Networks for more information 0026 ***********************license end**************************************/ 0027 0028 /* 0029 * 0030 * Small helper utilities. 0031 * 0032 */ 0033 0034 #ifndef __CVMX_HELPER_UTIL_H__ 0035 #define __CVMX_HELPER_UTIL_H__ 0036 0037 /** 0038 * Convert a interface mode into a human readable string 0039 * 0040 * @mode: Mode to convert 0041 * 0042 * Returns String 0043 */ 0044 extern const char 0045 *cvmx_helper_interface_mode_to_string(cvmx_helper_interface_mode_t mode); 0046 0047 /** 0048 * Setup Random Early Drop to automatically begin dropping packets. 0049 * 0050 * @pass_thresh: 0051 * Packets will begin slowly dropping when there are less than 0052 * this many packet buffers free in FPA 0. 0053 * @drop_thresh: 0054 * All incoming packets will be dropped when there are less 0055 * than this many free packet buffers in FPA 0. 0056 * Returns Zero on success. Negative on failure 0057 */ 0058 extern int cvmx_helper_setup_red(int pass_thresh, int drop_thresh); 0059 0060 /** 0061 * Get the version of the CVMX libraries. 0062 * 0063 * Returns Version string. Note this buffer is allocated statically 0064 * and will be shared by all callers. 0065 */ 0066 extern const char *cvmx_helper_get_version(void); 0067 0068 /** 0069 * Setup the common GMX settings that determine the number of 0070 * ports. These setting apply to almost all configurations of all 0071 * chips. 0072 * 0073 * @interface: Interface to configure 0074 * @num_ports: Number of ports on the interface 0075 * 0076 * Returns Zero on success, negative on failure 0077 */ 0078 extern int __cvmx_helper_setup_gmx(int interface, int num_ports); 0079 0080 /** 0081 * Returns the IPD/PKO port number for a port on the given 0082 * interface. 0083 * 0084 * @interface: Interface to use 0085 * @port: Port on the interface 0086 * 0087 * Returns IPD/PKO port number 0088 */ 0089 extern int cvmx_helper_get_ipd_port(int interface, int port); 0090 0091 /** 0092 * Returns the IPD/PKO port number for the first port on the given 0093 * interface. 0094 * 0095 * @interface: Interface to use 0096 * 0097 * Returns IPD/PKO port number 0098 */ 0099 static inline int cvmx_helper_get_first_ipd_port(int interface) 0100 { 0101 return cvmx_helper_get_ipd_port(interface, 0); 0102 } 0103 0104 /** 0105 * Returns the IPD/PKO port number for the last port on the given 0106 * interface. 0107 * 0108 * @interface: Interface to use 0109 * 0110 * Returns IPD/PKO port number 0111 */ 0112 static inline int cvmx_helper_get_last_ipd_port(int interface) 0113 { 0114 extern int cvmx_helper_ports_on_interface(int interface); 0115 0116 return cvmx_helper_get_first_ipd_port(interface) + 0117 cvmx_helper_ports_on_interface(interface) - 1; 0118 } 0119 0120 /** 0121 * Free the packet buffers contained in a work queue entry. 0122 * The work queue entry is not freed. 0123 * 0124 * @work: Work queue entry with packet to free 0125 */ 0126 static inline void cvmx_helper_free_packet_data(struct cvmx_wqe *work) 0127 { 0128 uint64_t number_buffers; 0129 union cvmx_buf_ptr buffer_ptr; 0130 union cvmx_buf_ptr next_buffer_ptr; 0131 uint64_t start_of_buffer; 0132 0133 number_buffers = work->word2.s.bufs; 0134 if (number_buffers == 0) 0135 return; 0136 buffer_ptr = work->packet_ptr; 0137 0138 /* 0139 * Since the number of buffers is not zero, we know this is 0140 * not a dynamic short packet. We need to check if it is a 0141 * packet received with IPD_CTL_STATUS[NO_WPTR]. If this is 0142 * true, we need to free all buffers except for the first 0143 * one. The caller doesn't expect their WQE pointer to be 0144 * freed 0145 */ 0146 start_of_buffer = ((buffer_ptr.s.addr >> 7) - buffer_ptr.s.back) << 7; 0147 if (cvmx_ptr_to_phys(work) == start_of_buffer) { 0148 next_buffer_ptr = 0149 *(union cvmx_buf_ptr *) cvmx_phys_to_ptr(buffer_ptr.s.addr - 8); 0150 buffer_ptr = next_buffer_ptr; 0151 number_buffers--; 0152 } 0153 0154 while (number_buffers--) { 0155 /* 0156 * Remember the back pointer is in cache lines, not 0157 * 64bit words 0158 */ 0159 start_of_buffer = 0160 ((buffer_ptr.s.addr >> 7) - buffer_ptr.s.back) << 7; 0161 /* 0162 * Read pointer to next buffer before we free the 0163 * current buffer. 0164 */ 0165 next_buffer_ptr = 0166 *(union cvmx_buf_ptr *) cvmx_phys_to_ptr(buffer_ptr.s.addr - 8); 0167 cvmx_fpa_free(cvmx_phys_to_ptr(start_of_buffer), 0168 buffer_ptr.s.pool, 0); 0169 buffer_ptr = next_buffer_ptr; 0170 } 0171 } 0172 0173 /** 0174 * Returns the interface number for an IPD/PKO port number. 0175 * 0176 * @ipd_port: IPD/PKO port number 0177 * 0178 * Returns Interface number 0179 */ 0180 extern int cvmx_helper_get_interface_num(int ipd_port); 0181 0182 /** 0183 * Returns the interface index number for an IPD/PKO port 0184 * number. 0185 * 0186 * @ipd_port: IPD/PKO port number 0187 * 0188 * Returns Interface index number 0189 */ 0190 extern int cvmx_helper_get_interface_index_num(int ipd_port); 0191 0192 #endif /* __CVMX_HELPER_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |