1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * Support functions for managing the MII management port
49 * <hr>$Revision: 42115 $<hr>
52 #ifndef __CVMX_MGMT_PORT_H__
53 #define __CVMX_MGMT_PORT_H__
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 */
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;
69 /* Enumeration of Net Device interface flags. */
72 CVMX_IFF_PROMISC = 0x100, /* receive all packets */
73 CVMX_IFF_ALLMULTI = 0x200, /* receive all multicast packets */
74 } cvmx_mgmt_port_netdevice_flags_t;
77 * Called to initialize a management port for use. Multiple calls
78 * to this function accross applications is safe.
80 * @param port Port to initialize
82 * @return CVMX_MGMT_PORT_SUCCESS or an error code
84 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_initialize(int port);
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.
91 * @param port Management port
93 * @return CVMX_MGMT_PORT_SUCCESS or an error code
95 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_shutdown(int port);
98 * Enable packet IO on a management port
100 * @param port Management port
102 * @return CVMX_MGMT_PORT_SUCCESS or an error code
104 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_enable(int port);
107 * Disable packet IO on a management port
109 * @param port Management port
111 * @return CVMX_MGMT_PORT_SUCCESS or an error code
113 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_disable(int port);
116 * Send a packet out the management port. The packet is copied so
117 * the input buffer isn't used after this call.
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
123 * @return CVMX_MGMT_PORT_SUCCESS or an error code
125 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_send(int port, int packet_len, void *buffer);
128 * Receive a packet from the management port.
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
134 * @return The size of the packet, or a negative erorr code on failure. Zero
135 * means that no packets were available.
137 extern int cvmx_mgmt_port_receive(int port, int buffer_len, void *buffer);
140 * Get the management port link status:
141 * 100 = 100Mbps, full duplex
142 * 10 = 10Mbps, full duplex
144 * -10 = 10Mpbs, half duplex
145 * -100 = 100Mbps, half duplex
147 * @param port Management port
151 extern int cvmx_mgmt_port_get_link(int port);
154 * Set the MAC address for a management port
156 * @param port Management port
157 * @param mac New MAC address. The lower 6 bytes are used.
159 * @return CVMX_MGMT_PORT_SUCCESS or an error code
161 extern cvmx_mgmt_port_result_t cvmx_mgmt_port_set_mac(int port, uint64_t mac);
164 * Get the MAC address for a management port
166 * @param port Management port
168 * @return MAC address
170 extern uint64_t cvmx_mgmt_port_get_mac(int port);
173 * Set the multicast list.
175 * @param port Management port
176 * @param flags Interface flags
180 extern void cvmx_mgmt_port_set_multicast_list(int port, int flags);
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.
187 * @param port Management port
188 * @param size_without_crc
189 * Size in bytes without FCS
191 extern void cvmx_mgmt_port_set_max_packet_size(int port, int size_without_fcs);
193 #endif /* __CVMX_MGMT_PORT_H__ */