tte_buffer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef TTE_BUFFER_H_
00018 #define TTE_BUFFER_H_
00019
00020 #include "tte_eth_driver.h"
00021 #include "tte_api.h"
00022 #include "tte_config.h"
00023
00024
00025 #define MAX_CTRLS (1u)
00026
00027
00028 typedef struct {
00029 uint32_t head, tail;
00030 } tte_queue_buf_t;
00031
00032
00033 typedef struct {
00034 uint8_t fresh_data[2];
00035 uint8_t empty_data;
00036 uint8_t last_written_page;
00037 } tte_state_buf_t;
00038
00039
00041 typedef struct {
00042 uint8_t ctrl;
00043 uint8_t type;
00044 tte_message_conf_t *msg_conf;
00045
00046 eth_buffer_t *page_list;
00047 uint32_t page_count;
00048 int32_t write_lock, read_lock;
00049
00050 uint32_t dropped_frames;
00051 tte_buffer_t *cb_arg;
00052 void (*insert_cb)(void*);
00053 void (*remove_cb)(void*);
00054
00055 union {
00056 tte_queue_buf_t queue;
00057 tte_state_buf_t state;
00058 };
00059
00060 uint16_t size;
00061 } tte_priv_buf_t;
00062
00063
00064 #define tte_get_priv_buf(p_tte_buf) ( (tte_priv_buf_t *) (p_tte_buf)->priv )
00065
00066
00067
00068 extern tte_priv_buf_t bg_tx_buf[MAX_CTRLS];
00069 extern tte_priv_buf_t bg_rx_buf[MAX_CTRLS];
00070
00071 extern tte_priv_buf_t tt_tx_buf[TARGET_MAX_TT_TX_BUFS];
00072 extern tte_priv_buf_t tt_rx_buf[TARGET_MAX_TT_RX_BUFS];
00073
00074 extern void tte_clear_state_buf(tte_priv_buf_t *buf);
00075 extern void tte_clear_queue_buf(tte_priv_buf_t *buf);
00076 extern void tte_flush_queue_buf(tte_priv_buf_t *buf, int32_t (*free_fn)(uint8_t, eth_buffer_t *));
00077 extern void tte_flush_state_buf(tte_priv_buf_t *buf, int32_t (*free_fn)(uint8_t, eth_buffer_t *));
00078
00079
00080 extern int32_t tte_open_buf_for_reading(tte_priv_buf_t *buf, uint8_t ** const frame,
00081 tte_buf_status_t * const status, int32_t * const page);
00082
00083 extern int32_t tte_close_buf_for_reading(tte_priv_buf_t * buf,
00084 int32_t (*free_fn)(uint8_t, eth_buffer_t *));
00085
00086 extern int32_t tte_open_buf_for_writing(tte_priv_buf_t * buf, int32_t * const page);
00087
00088 extern int32_t tte_close_buf_for_writing(tte_priv_buf_t * buf, uint16_t size);
00089
00090 #endif
00091