3 * Copyright 2007 Free Software Foundation, Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef INCLUDED_ETHERNET_H
20 #define INCLUDED_ETHERNET_H
22 #include "usrp2_mac_addr.h"
25 typedef void (*ethernet_link_changed_callback_t)(int speed);
29 * \brief one time call to initialize ethernet
31 void ethernet_init(void);
34 * \brief Specify the function to call on link state changes.
36 * When the link comes up, speed is the link speed in Mbit/s.
37 * When the link goes down, speed is 0.
39 void ethernet_register_link_changed_callback(ethernet_link_changed_callback_t cb);
42 * \returns ethernet MAC address
44 const u2_mac_addr_t *ethernet_mac_addr(void);
47 * \brief write mac address to eeprom and begin using it
49 bool ethernet_set_mac_addr(const u2_mac_addr_t *t);
53 * \brief read RMON regs and return error mask
55 int ethernet_check_errors(void);
57 #define RME_RX_CRC 0x0001
58 #define RME_RX_FIFO_FULL 0x0002
59 #define RME_RX_2SHORT_2LONG 0x0004
61 #define RME_TX_JAM_DROP 0x0010
62 #define RME_TX_FIFO_UNDER 0x0020
63 #define RME_TX_FIFO_OVER 0x0040
66 typedef enum { LS_UNKNOWN, LS_DOWN, LS_UP } eth_link_state_t;
68 // flow control bitmasks
70 #define FC_WE_TX 0x1 // we send PAUSE frames
71 #define FC_WE_RX 0x2 // we honor received PAUSE frames
72 #define FC_SYMM (FC_WE_TX | FC_WE_RX)
74 #define S_UNKNOWN (-1) // unknown link speed
77 eth_link_state_t link_state;
78 int link_speed; // in Mb/s
82 #endif /* INCLUDED_ETHERNET_H */