tte_eth_driver.h
Go to the documentation of this file.00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TTE_ETH_DRIVER_H_
00023 #define TTE_ETH_DRIVER_H_
00024
00025 #include "tte_environment.h"
00026 #include "tte_common.h"
00027 #include "tte_hw_timer.h"
00028 #include "tte_api.h"
00029
00031 #define ETH_HEADER_LEN (14u)
00032
00034 typedef int32_t (*eth_rx_callback_t)(uint8_t ctrl, hwtime_t ts);
00035
00037 typedef struct {
00038 uint8_t addr[6];
00039 } __attribute__((__packed__)) eth_mac_addr_t;
00040
00041
00043 typedef enum {
00044 ETH_ERR_LINK = 1,
00045 ETH_ERR_IRQ = 2,
00046 ETH_ERR_RXOVER = 3,
00047 ETH_ERR_OTHER = 99,
00048 } eth_errror_code_t;
00049
00050
00053 typedef int32_t (*eth_error_callback_t)(uint8_t ctrl, int32_t error_code);
00054
00055
00057 enum {
00058 ETH_LINK_UP,
00059 ETH_LINK_DOWN
00060 };
00061
00062
00064 typedef struct {
00065 uint8_t da[6];
00066 uint8_t sa[6];
00067 uint16_t type;
00068 uint8_t data[1500];
00069 } __attribute__((__packed__)) eth_bg_frame_t;
00070
00071
00075 typedef struct {
00076 uint32_t ct_marker;
00077 uint16_t ct_id;
00078 uint8_t sa[6];
00079 uint16_t type;
00080 uint8_t data[1500];
00081 } __attribute__((__packed__)) eth_ct_frame_t;
00082
00083
00087 typedef struct {
00088 union {
00089 uint8_t *raw;
00090 eth_bg_frame_t *bg_frame;
00091 eth_ct_frame_t *ct_frame;
00092 };
00093 uint16_t size;
00094 uint16_t max_size;
00095 dma_addr_t dma_handle;
00096 #ifdef CHECK_ETH_BUF_OWNER
00097 uint32_t owned_by_drv;
00098 #endif
00099 } eth_buffer_t;
00100
00101
00103 typedef struct {
00104
00105 uint64_t rx_packets;
00106 uint64_t tx_packets;
00107 uint64_t rx_bytes;
00108 uint64_t tx_bytes;
00109 uint64_t rx_errors;
00110 uint64_t tx_errors;
00111 uint64_t rx_dropped;
00112 uint64_t tx_dropped;
00114
00115 uint64_t rx_length_errors;
00116 uint64_t rx_crc_errors;
00117 uint64_t rx_fifo_errors;
00119
00120 uint64_t tx_carrier_errors;
00121 } tte_eth_stats_t;
00122
00123
00125 typedef struct {
00126 uint8_t rx_done;
00127 uint8_t error;
00128 } eth_intr_t;
00129
00130
00146 extern int32_t eth_alloc_rx_bufs(uint8_t ctrl, uint32_t count);
00147
00148
00166 extern int32_t eth_alloc_tx_bufs(uint8_t ctrl, uint32_t count, uint16_t size);
00167
00168
00179 extern int32_t eth_clear_mc_list(uint8_t ctrl);
00180
00181
00187 extern void eth_exit(void);
00188
00189
00200 extern int32_t eth_flush_rx_queue(uint8_t ctrl);
00201
00202
00214 extern int32_t eth_flush_tx_queue(uint8_t ctrl);
00215
00216
00228 extern int32_t eth_free_buffers(uint8_t ctrl);
00229
00230
00245 extern int32_t eth_free_rx_buf(uint8_t ctrl, eth_buffer_t *buf);
00246
00247
00255 extern int32_t eth_get_card_count(void);
00256
00257
00273 extern int32_t eth_get_stats(uint8_t ctrl, tte_eth_stats_t *stats);
00274
00275
00286 extern int32_t eth_get_link_status(uint8_t ctrl);
00287
00288
00303 extern int32_t eth_get_mac_addr(uint8_t ctrl, eth_mac_addr_t *addr);
00304
00305
00317 extern int32_t eth_get_prom_mode(uint8_t ctrl);
00318
00319
00337 extern int32_t eth_get_rx_buf(uint8_t ctrl, eth_buffer_t *buf);
00338
00339
00359 extern int32_t eth_get_tx_buf(uint8_t ctrl, eth_buffer_t * buf, uint16_t size);
00360
00361
00370 extern int32_t eth_init(void);
00371
00372
00386 extern void eth_register_error_callback(uint8_t ctrl,
00387 eth_error_callback_t fn);
00388
00389
00408 extern void eth_register_rx_callback(uint8_t ctrl,
00409 eth_rx_callback_t fn);
00410
00411
00420 extern void eth_set_int_mask(uint8_t ctrl, eth_intr_t int_mask);
00421
00422
00436 extern int32_t eth_set_mac_addr(uint8_t ctrl, eth_mac_addr_t addr);
00437
00438
00457 extern int32_t eth_set_mc_list(uint8_t ctrl, eth_mac_addr_t *mac_list,
00458 uint32_t len);
00459
00460
00476 extern int32_t eth_set_multicast_addr(uint8_t ctrl, eth_mac_addr_t * mac_addr);
00477
00478
00495 extern int32_t eth_set_prom_mode(uint8_t ctrl, int32_t promisc);
00496
00497
00513 extern int32_t eth_start(uint8_t ctrl);
00514
00515
00528 extern int32_t eth_stop(uint8_t ctrl);
00529
00530
00531 #ifdef TTE_ETH_TEST
00532
00542 extern int32_t eth_test(uint8_t ctrl);
00543 #endif
00544
00560 extern int32_t eth_tx_buf(uint8_t ctrl, eth_buffer_t *buf);
00561
00562
00574 extern int32_t eth_free_tx_buf(uint8_t ctrl, eth_buffer_t *buf);
00575
00576 #endif
00577