cvmx-mgmt-port.h revision 215990
1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Networks nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40 41 42 43 44 45 46/** 47 * @file 48 * 49 * Support functions for managing the MII management port 50 * 51 * <hr>$Revision: 49448 $<hr> 52 */ 53 54#ifndef __CVMX_MGMT_PORT_H__ 55#define __CVMX_MGMT_PORT_H__ 56 57#include "cvmx-helper.h" 58#include "cvmx-helper-board.h" 59 60#ifdef __cplusplus 61extern "C" { 62#endif 63 64#define CVMX_MGMT_PORT_NUM_PORTS 2 /* Right now we only have one mgmt port */ 65#define CVMX_MGMT_PORT_NUM_TX_BUFFERS 16 /* Number of TX ring buffer entries and buffers */ 66#define CVMX_MGMT_PORT_NUM_RX_BUFFERS 128 /* Number of RX ring buffer entries and buffers */ 67#define CVMX_MGMT_PORT_TX_BUFFER_SIZE 12288 /* Size of each TX/RX buffer */ 68#define CVMX_MGMT_PORT_RX_BUFFER_SIZE 1536 /* Size of each TX/RX buffer */ 69 70typedef enum 71{ 72 CVMX_MGMT_PORT_SUCCESS = 0, 73 CVMX_MGMT_PORT_NO_MEMORY = -1, 74 CVMX_MGMT_PORT_INVALID_PARAM = -2, 75 CVMX_MGMT_PORT_INIT_ERROR = -3, 76} cvmx_mgmt_port_result_t; 77 78 79/* Enumeration of Net Device interface flags. */ 80typedef enum 81{ 82 CVMX_IFF_PROMISC = 0x100, /* receive all packets */ 83 CVMX_IFF_ALLMULTI = 0x200, /* receive all multicast packets */ 84} cvmx_mgmt_port_netdevice_flags_t; 85 86/** 87 * Called to initialize a management port for use. Multiple calls 88 * to this function accross applications is safe. 89 * 90 * @param port Port to initialize 91 * 92 * @return CVMX_MGMT_PORT_SUCCESS or an error code 93 */ 94extern cvmx_mgmt_port_result_t cvmx_mgmt_port_initialize(int port); 95 96/** 97 * Shutdown a management port. This currently disables packet IO 98 * but leaves all hardware and buffers. Another application can then 99 * call initialize() without redoing the hardware setup. 100 * 101 * @param port Management port 102 * 103 * @return CVMX_MGMT_PORT_SUCCESS or an error code 104 */ 105extern cvmx_mgmt_port_result_t cvmx_mgmt_port_shutdown(int port); 106 107/** 108 * Enable packet IO on a management port 109 * 110 * @param port Management port 111 * 112 * @return CVMX_MGMT_PORT_SUCCESS or an error code 113 */ 114extern cvmx_mgmt_port_result_t cvmx_mgmt_port_enable(int port); 115 116/** 117 * Disable packet IO on a management port 118 * 119 * @param port Management port 120 * 121 * @return CVMX_MGMT_PORT_SUCCESS or an error code 122 */ 123extern cvmx_mgmt_port_result_t cvmx_mgmt_port_disable(int port); 124 125/** 126 * Send a packet out the management port. The packet is copied so 127 * the input buffer isn't used after this call. 128 * 129 * @param port Management port 130 * @param packet_len Length of the packet to send. It does not include the final CRC 131 * @param buffer Packet data 132 * 133 * @return CVMX_MGMT_PORT_SUCCESS or an error code 134 */ 135extern cvmx_mgmt_port_result_t cvmx_mgmt_port_send(int port, int packet_len, void *buffer); 136 137/** 138 * Receive a packet from the management port. 139 * 140 * @param port Management port 141 * @param buffer_len Size of the buffer to receive the packet into 142 * @param buffer Buffer to receive the packet into 143 * 144 * @return The size of the packet, or a negative erorr code on failure. Zero 145 * means that no packets were available. 146 */ 147extern int cvmx_mgmt_port_receive(int port, int buffer_len, void *buffer); 148 149/** 150 * Set the MAC address for a management port 151 * 152 * @param port Management port 153 * @param mac New MAC address. The lower 6 bytes are used. 154 * 155 * @return CVMX_MGMT_PORT_SUCCESS or an error code 156 */ 157extern cvmx_mgmt_port_result_t cvmx_mgmt_port_set_mac(int port, uint64_t mac); 158 159/** 160 * Get the MAC address for a management port 161 * 162 * @param port Management port 163 * 164 * @return MAC address 165 */ 166extern uint64_t cvmx_mgmt_port_get_mac(int port); 167#define CVMX_MGMT_PORT_GET_MAC_ERROR ((unsigned long long)-2LL) 168 169/** 170 * Set the multicast list. 171 * 172 * @param port Management port 173 * @param flags Interface flags 174 * 175 * @return 176 */ 177extern void cvmx_mgmt_port_set_multicast_list(int port, int flags); 178 179/** 180 * Set the maximum packet allowed in. Size is specified 181 * including L2 but without FCS. A normal MTU would corespond 182 * to 1514 assuming the standard 14 byte L2 header. 183 * 184 * @param port Management port 185 * @param size_without_fcs 186 * Size in bytes without FCS 187 */ 188extern void cvmx_mgmt_port_set_max_packet_size(int port, int size_without_fcs); 189 190/** 191 * Return the link state of an RGMII/MII port as returned by 192 * auto negotiation. The result of this function may not match 193 * Octeon's link config if auto negotiation has changed since 194 * the last call to __cvmx_mgmt_port_link_set(). 195 * 196 * @param port The RGMII/MII interface port to query 197 * 198 * @return Link state 199 */ 200extern cvmx_helper_link_info_t cvmx_mgmt_port_link_get(int port); 201 202/** 203 * Configure RGMII/MII port for the specified link state. This 204 * function does not influence auto negotiation at the PHY level. 205 * 206 * @param port RGMII/MII interface port 207 * @param link_info The new link state 208 * 209 * @return Zero on success, negative on failure 210 */ 211extern int cvmx_mgmt_port_link_set(int port, cvmx_helper_link_info_t link_info); 212 213#ifdef __cplusplus 214} 215#endif 216 217#endif /* __CVMX_MGMT_PORT_H__ */ 218