cvmx-mgmt-port.h revision 210286
1/***********************license start*************** 2 * Copyright (c) 2003-2008 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 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS 25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH 26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY 27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT 28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES 29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR 30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET 31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT 32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 33 * 34 * 35 * For any questions regarding licensing please contact marketing@caviumnetworks.com 36 * 37 ***********************license end**************************************/ 38 39 40 41 42 43 44/** 45 * @file 46 * 47 * Support functions for managing the MII management port 48 * 49 * <hr>$Revision: 42115 $<hr> 50 */ 51 52#ifndef __CVMX_MGMT_PORT_H__ 53#define __CVMX_MGMT_PORT_H__ 54 55#define CVMX_MGMT_PORT_NUM_PORTS 2 /* Right now we only have one mgmt port */ 56#define CVMX_MGMT_PORT_NUM_TX_BUFFERS 16 /* Number of TX ring buffer entries and buffers */ 57#define CVMX_MGMT_PORT_NUM_RX_BUFFERS 128 /* Number of RX ring buffer entries and buffers */ 58#define CVMX_MGMT_PORT_TX_BUFFER_SIZE 12288 /* Size of each TX/RX buffer */ 59#define CVMX_MGMT_PORT_RX_BUFFER_SIZE 1536 /* Size of each TX/RX buffer */ 60 61typedef enum 62{ 63 CVMX_MGMT_PORT_SUCCESS = 0, 64 CVMX_MGMT_PORT_NO_MEMORY = -1, 65 CVMX_MGMT_PORT_INVALID_PARAM = -2, 66} cvmx_mgmt_port_result_t; 67 68 69/* Enumeration of Net Device interface flags. */ 70typedef enum 71{ 72 CVMX_IFF_PROMISC = 0x100, /* receive all packets */ 73 CVMX_IFF_ALLMULTI = 0x200, /* receive all multicast packets */ 74} cvmx_mgmt_port_netdevice_flags_t; 75 76/** 77 * Called to initialize a management port for use. Multiple calls 78 * to this function accross applications is safe. 79 * 80 * @param port Port to initialize 81 * 82 * @return CVMX_MGMT_PORT_SUCCESS or an error code 83 */ 84extern cvmx_mgmt_port_result_t cvmx_mgmt_port_initialize(int port); 85 86/** 87 * Shutdown a management port. This currently disables packet IO 88 * but leaves all hardware and buffers. Another application can then 89 * call initialize() without redoing the hardware setup. 90 * 91 * @param port Management port 92 * 93 * @return CVMX_MGMT_PORT_SUCCESS or an error code 94 */ 95extern cvmx_mgmt_port_result_t cvmx_mgmt_port_shutdown(int port); 96 97/** 98 * Enable packet IO on a management port 99 * 100 * @param port Management port 101 * 102 * @return CVMX_MGMT_PORT_SUCCESS or an error code 103 */ 104extern cvmx_mgmt_port_result_t cvmx_mgmt_port_enable(int port); 105 106/** 107 * Disable packet IO on a management port 108 * 109 * @param port Management port 110 * 111 * @return CVMX_MGMT_PORT_SUCCESS or an error code 112 */ 113extern cvmx_mgmt_port_result_t cvmx_mgmt_port_disable(int port); 114 115/** 116 * Send a packet out the management port. The packet is copied so 117 * the input buffer isn't used after this call. 118 * 119 * @param port Management port 120 * @param packet_len Length of the packet to send. It does not include the final CRC 121 * @param buffer Packet data 122 * 123 * @return CVMX_MGMT_PORT_SUCCESS or an error code 124 */ 125extern cvmx_mgmt_port_result_t cvmx_mgmt_port_send(int port, int packet_len, void *buffer); 126 127/** 128 * Receive a packet from the management port. 129 * 130 * @param port Management port 131 * @param buffer_len Size of the buffer to receive the packet into 132 * @param buffer Buffer to receive the packet into 133 * 134 * @return The size of the packet, or a negative erorr code on failure. Zero 135 * means that no packets were available. 136 */ 137extern int cvmx_mgmt_port_receive(int port, int buffer_len, void *buffer); 138 139/** 140 * Get the management port link status: 141 * 100 = 100Mbps, full duplex 142 * 10 = 10Mbps, full duplex 143 * 0 = Link down 144 * -10 = 10Mpbs, half duplex 145 * -100 = 100Mbps, half duplex 146 * 147 * @param port Management port 148 * 149 * @return 150 */ 151extern int cvmx_mgmt_port_get_link(int port); 152 153/** 154 * Set the MAC address for a management port 155 * 156 * @param port Management port 157 * @param mac New MAC address. The lower 6 bytes are used. 158 * 159 * @return CVMX_MGMT_PORT_SUCCESS or an error code 160 */ 161extern cvmx_mgmt_port_result_t cvmx_mgmt_port_set_mac(int port, uint64_t mac); 162 163/** 164 * Get the MAC address for a management port 165 * 166 * @param port Management port 167 * 168 * @return MAC address 169 */ 170extern uint64_t cvmx_mgmt_port_get_mac(int port); 171 172/** 173 * Set the multicast list. 174 * 175 * @param port Management port 176 * @param flags Interface flags 177 * 178 * @return 179 */ 180extern void cvmx_mgmt_port_set_multicast_list(int port, int flags); 181 182/** 183 * Set the maximum packet allowed in. Size is specified 184 * including L2 but without FCS. A normal MTU would corespond 185 * to 1514 assuming the standard 14 byte L2 header. 186 * 187 * @param port Management port 188 * @param size_without_crc 189 * Size in bytes without FCS 190 */ 191extern void cvmx_mgmt_port_set_max_packet_size(int port, int size_without_fcs); 192 193#endif /* __CVMX_MGMT_PORT_H__ */ 194